A.2.2 Operators

The precedence of all operators is shown in Table A.4. All operators within the same box have the same precedence. Operators in higher boxes have higher precedence than operators in lower ones. For instance the expression a + b * c means a + (b * c) rather than (a + b) * c.

Table A.4: Operator precedence.
Operator Rule
list subscripting name [ expr ]
function call name ( expr_sequence )
not expr
unary minus - expr
unary plus + expr
multiply expr * expr
divide expr / expr
modulo (remainder) expr % expr
add expr + expr
subtract expr - expr
less than expr < expr
less than or equal expr <= expr
greater than expr > expr
greater than or equal expr >= expr
equal expr == expr
not equal expr != expr
logical AND expr && expr
logical inclusive OR expr || expr

Each rule describes an expression. An expression again may contain other expressions described by these rules.

Unary operators are right-associative, binary operators are left-associative. For instance the expression a - b + c means (a - b) + c but not a - (b + c).

Not all operators are defined for all data types. Furthermore, the result of an operator depends on the data type of the operands given. In the following all operators are discussed and classified by the data type of their operands.

Robert Klima 2003-02-06