Order of Operand Evaluation

The following listing lists the prio rity order of operators and their associativity.

Listing: Operator Precedence
Operators                          Associativity
() [] -> .                         left to right

! ~ ++ -- + - * & (type) sizeof    right to left

& / %                              left to right

+ -                                left to right

<< >>                              left to right

< <= > >=                          left to right

== !=                              left to right

&                                  left to right

^                                  left to right

|                                  left to right

&&                                 left to right

||                                 left to right

? :                                right to left

= += -= *= /= %= &= ^= |= <<= >>=  right to left

,                                  left to right

Unary +, -, and * have higher precedence than the binary forms.

The following listing has some examples of operator precedence

Listing: Examples of Operator Precedence
if (a&3 == 2)
`==' has higher precedence than `&', thus it is evaluated as:

if (a & (3==2)

which is the same as:

if (a&0)
Tip: Use brackets if you are unsure about associativity.