When you combine several operators in a single expression, the operations are performed in the following order.
Order | Operator | Description |
---|---|---|
1 | ! | Boolean NOT |
2 | - | Negation (as in -1) |
3 | *, / and % | Multiplication, division, and modulus |
4 | + and - | Addition and subtraction |
5 | < , <=, >, and >= | Comparison |
6 | == and != | Equivalence |
7 | && | Boolean AND |
8 | || | Boolean OR |
When operators with the same precedence are encountered, operators are evaluated from left to right. However, when part of a formula is enclosed in parentheses, it is evaluated first.