Table 4.1 operator precedence and associativity – Teledyne LeCroy Protocol Analyzers File-Based Decoding User Manual User Manual
Page 16

Chapter 4: Operators
File-based Decoding User Manual
10
LeCroy Corporation
When operators of equal precedence occur in an expression, the operands are evaluated
according to the associativity of the operators. This means that if an operator's
associativity is left to right, then the operations is done starting from the left side of the
expression. So, the expression
4 + 9 - 6 + 5
would evaluate to 12. However, if the associative operator is used to group a part or parts
of the expression, those parts are evaluated first. Therefore,
( 4 + 9 ) - ( 6 + 5 )
has a value of 2.
In Table 4.1, Operator Precedence and Associativity, the operators are listed in order of
precedence, from highest to lowest. Operators on the same line have equal precedence,
and their associativity is shown in the second column.
Operator Symbol
Associativity
++ --
Right to left
[] ()
Left to right
~ ! sizeof head tail first next more
last prev
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
Table 4.1 Operator Precedence and Associativity