Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • I knew about their use as bitwise operators, just today I saw them in an if for the first time. Not sure if eager boolean evaluation is the correct name for this. Commented Sep 19, 2013 at 13:48
  • 1
    I know you know :-) but the point is that if you expect them to function like eager versions of || and &&, you or your readers will be caught out. Because (1 & 2) != (1 && 2). Commented Sep 19, 2013 at 13:52
  • 1
    The solution would be to write if (!!(first=foo()) & !!(second = bar())) but you're starting to write code that's doesn't have an immediately obvious meaning at that point. Best to just not try using bitwise operators as logical ones. Commented Sep 19, 2013 at 16:50