Operator precedence, Operator precedence -22 – Rockwell Automation 2098-IPD-xxx Ultra5000 C Programming using the Motion Library User Manual
Page 34

Publication 2098-PM001E-EN-P — July 2002
1-22
Programming Motion Control in C
For example, the following code yields the absolute value of a
number.
if (y < 0)
x = -y;
else
x = y;
This statement can be written as
x = (y < 0) ? –y : y;
The meaning of either statement above is: If y is less than zero, then x
= -y; else, x = y.
Operator Precedence
The following table shows the precedence of the operators introduced
in this chapter and the associativity (i.e., the direction in which each
operation flows).
Operator:
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
Note: Unary +, -, and * have higher precedence than the binary forms.