Operator Precedence

Operators are evaluated in the following order:

  • ()  []
  • :
  • !  ~
  • *  /  %
  • +  -
  • <<  >>
  • <  <=  >  >=
  • =  !=
  • &
  • ^
  • |
  • &&
  • ||
  • &&?
  • ||?

For example, because the logical AND (&&) operator has a higher precedence than the logical OR (||) operator, the expression:

INT x := a || b && c;

is equivalent to:

INT x := a || (b && c);

Where operators are in the same group, evaluation is from left to right. For example, the multiplication (*) and the division (/) operators are in the same precedence group, so the expression:

INT x := a * b / c;

is equivalent to:

INT x := (a * b) / c;

N.B. Unlike C, an assignment is not a valid expression, so it is not possible to write

a := b := c;