Share via


5.6.9.1 Operator Precedence and Associativity

When an expression contains multiple binary operators, the precedence of the operators controls the order in which the individual binary operators are evaluated. For example, in the expression x + y * z is evaluated as x + (y * z) because the * operator has higher precedence than the + operator. The following table lists the binary operators in descending order of precedence:

Category

Operators

Primary

All expressions not explicitly listed in this table

Exponentiation

^

Unary negation

-

Multiplicative

*, /

Integer division

\

Modulus

Mod

Additive

+, -

Concatenation

&

Relational

=, <>, <, >, <=, >=, Like, Is

Logical NOT

Not

Logical AND

And

Logical OR

Or

Logical XOR

Xor

Logical EQV

Eqv

Logical IMP

Imp

 

When an expression contains two operators with the same precedence, the associativity of the operators controls the order in which the operations are performed. All binary operators are left-associative, meaning that operations are performed from left to right. Precedence and associativity can be controlled using parenthetical expressions.