Could someone show me an example where precedence of operators actually make a difference in expressions that involve boolean-only expressions using 1. && with || and 2. & with |
I remember seeing something in the "Nutshell" book about operator precedence regarding these operators. I don't think K&B (K&&B )'s book talks much about precedence using boolean expressions.
My current belief is that with expressions involving only the short-curcuit operators, the expression is evaluated left to right no matter what. And I don't have a CLUE what the order of evaluation is on expressions involving only & and
&& and || are short circuit operators. That means that as soon as the condition can be positively evaluated, all other conditions will NOT be checked. However, & and | will cause every condition to be checked no matter what results from previous condition checks. Therefore, check out how the value of 'i' is effected:
============ Mark wrote: Whoops. Sorry, I misread your question. ============
Again reopening a old topic .... but still, I feel the example suggested by Mark, had wrong comments ... The solution written, through the comments accompanying every line, were wrong .... Was that you tried to convey, in this thread by your above statement ?
And another reason for why I reopened this thread is, we never discussed here about the precedence , if an expression has a mix of || , &&, & , |.
Can someone give an example covering all of these? Btw. I will also give it a try!