Operators evaluation order and precedence in decreasing relevance

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, from left to right

^

Bitwise XOR, from left to right

|

Bitwise OR, from left to right

&&

Logic AND, from left to right

||

Logic OR, from left to right

= += -+ */ /= %= &= ^= <<= =>> }=

Assignment operators, from left to right

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.213.209