In order of descending precedence (i.e. operators higher in the table are evaluated first):
Operators | Note | Associativity |
---|---|---|
! , ++ , -- | postfix unary operators | right |
~ , ! , - , ++ , -- | prefix unary operators | right |
% | modulo | left |
* , / | multiplication, division | left |
+ , - | addition, subtraction | left |
<< , >> , >>> | bitwise shifts | left |
& , | , ^ | bitwise operators | left |
== , != , < , <= , > , >= | comparison | left |
... | interval | left |
&& | logical and | left |
|| | logical or | left |
@ | metadata | right |
?: | ternary | right |
%= , *= , /= , += , -= , <<= , >>= , >>>= , &= , |= , ^= | compound assignment | right |
=> | arrow | right |
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 higher precedence than ==
, !=
, etc (comparison operators)