hey...first time posting....i'm trying to get my programming skills back after 8 years of not using them. uphill battle, to say the least.
in any event, in going through the tutorials i hit a snag with the boolean operators AND, NOT, and OR.
i understand that they are processed in a specific (not, and, or) order, but within a complex statement how does it get processed?
the quiz example is !(1 && !(0 || 1))....what is the order of operations for this statement?
thanks for the help understanding this.
You figure it out the same way you do for arithmetic operators if you remember PEMA- Parenthesis, exponents, multiplication, addition. The boolean negation, AND and OR operators are analogous to the arithmetic negation, multiplication and addition operators.
Parenthesis are evaluated first, followed by negation, and and or.
So the expression you posted is analogous to
-(1 * -(0+1))
thank you very much. i had a feeling that it was easier than i was making it out to be.
But of course the compiler will only evaluate the parantheses if the first expression turns out to be true. It goes left-to-right and stops as soon as the result is known (for example if it encounters '0 && 1' it evaluates 0, which turns out to be false, and stops cuz the expression has to be false, too)