Operators and Precedence
Operators and Precedence
This table
lists all operators from the highest precedence to the lowest precedence.
Precedence Table (high to low precedence)
Operator Description Associativity
() Parentheses left-to-right
** Exponent right-to-left
+x, -x, ~x Unary plus, Unary minus, Bitwise NOT left-to-right
*, /, %, // Multiplication/division/modulus/floor division left-to-right
+, – Addition/subtraction left-to-right
(Bitwise shift operator)Bitwise shift left, Bitwise shift
<< ,>> left-to-right
right
& Bitwise AND left-to-right
^ Bitwise exclusive OR (XOR) left-to-right
| Bitwise inclusive OR left-to-right
Comaprison operator
<,<=,
>,>= Relational less than/less than or equal to
Relational greater than/greater than or equal to. left-to-right
== ,!=
Relational is equal to/is not equal toleft-to-right
= Assignment
+= ,-= Addition/subtraction assignment
*= ,/= Multiplication/division assignment
right-to-left
%=, &= Modulus/bitwise AND assignment
^= ,|= Bitwise exclusive/inclusive OR assignment
<<= ,>>= Bitwise shift left/right assignment
not Logical NOT right-to-left
and Logical AND left-to-right
or Logical OR left-to-right