5.3.4 Precedence

In order of descending precedence (i.e. operators higher in the table are evaluated first):

OperatorsNoteAssociativity
!, ++, --postfix unary operatorsright
~, !, -, ++, --prefix unary operatorsright
%moduloleft
*, /multiplication, divisionleft
+, -addition, subtractionleft
<<, >>, >>>bitwise shiftsleft
&, |, ^bitwise operatorsleft
==, !=, <, <=, >, >=comparisonleft
...intervalleft
&&logical andleft
||logical orleft
@metadataright
?:ternaryright
%=, *=, /=, +=, -=, <<=, >>=, >>>=, &=, |=, ^=compound assignmentright
=>arrowright
Differences from C-like precedence

Many languages (C++, Java, PHP, JavaScript, etc) use the same operator precedence rules as C. In Haxe, there are a couple of differences from these rules:

  • % (modulo) has a higher precedence than * and /; in C they have the same precedence
  • |, &, ^ (bitwise operators) have the same precedence; in C the three operators all have a different precedence
  • |, &, ^ (bitwise operators) also have a lower precedence than ==, !=, etc (comparison operators)