HP C/iX Reference Manual (31506-90011)

56 Chapter5
Expressions
Operator Precedence
Operator Precedence
Precedence is the order in which the compiler groups operands with operators. The C
compiler evaluates certain operators and their operands before others. If operands are not
grouped using parentheses, the compiler groups them according to its own rules.
<Undefined Cross-Reference> shows the rules of operator precedence in the C language.
<Undefined Cross-Reference> lists the highest precedence operators first. Most operators
group from the left to the right but some group from the right to the left. The grouping
indicates how an expression containing several operators of the same precedence will be
evaluated. Left to right grouping means the expression
a/b * c/d
behaves as if it had been written:
a/b)*c)/d)
Likewise, an operator that groups from the right to the left causes the expression
a=b=c
to behave as if it had been written:
a=(b=c)
Table 5-1. C Operator Precedence
Operators Grouping
() [] -> . left to right
+ ! ~ - * & sizeof (See note
1
below.)
right to left
(
type
) 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