Operators are evaluated in a precise order and we must keep this in mind when working with them. It is not so easy to remember what is evaluated before and what after, so the following table will help us to keep in mind the order and precedence of operators:
Operator |
Evaluation order |
++ -- |
Unary operators for incrementing/decrementing, evaluated from left to right |
+- !~ |
Unary plus and minus, evaluated from right to left |
* / % |
Multiplication, division, modulo, are evaluated from left to right and are evaluated after |
+ - |
Addition and subtraction are evaluated from left to right |
<<>> |
Bitwise shift are evaluated from left to right |
<= =><> |
Comparison operators, from left to right |
== != |
Equality operators, from left to right |
& |
Bitwise AND... |