Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help
next up previous contents
Next: Bit operations Up: Keywords, Operators and Declarations Previous: Keywords   Contents

Operators

At last, here is a table of operators and precedence.

The lines of the table are in order of precedence, so `a * b + 6' is interpreted as `(a * b) + 6'. When in doubt put brackets in!

The Associativity column shows how the operators group. E.g. `' groups left to right, meaning that is equivalent to rather than . Both are pretty useless expressions.

Associativity Operator
left to right () [], ->, .
right to left ! (negation), ~ (bit-not)
++, --, - (unary) , * (unary), & (unary), sizeof
right to left cast (type)
left to right *, /, % (modulus)
left to right - +
left to right <<, >>
left to right <, <=, >, >=
left to right ==, !=
left to right & (bit-and), | (bit-or)
left to right ^ (bit-xor)
left to right && (logical and)
left to right || (logical or)
right to left ?:
right to left =, +=, -=, /=, %=, >>=, &=
left to right ,


next up previous contents
Next: Bit operations Up: Keywords, Operators and Declarations Previous: Keywords   Contents
Tim Love 2010-04-27