When an expression contains multiple operators, the precedence of the operators controls the order in which the individual operators are evaluated. For example, the expression x + y * z
is evaluated as x + (y * z)
because the *
operator has higher precedence than the +
operator. The following table gives all operators in order of precedence from highest to lowest:
Category | Operators |
---|---|
Primary | All non-operator expressions |
Exponentiation | ^ |
Unary negation | + , - |
Multiplicative | * , / |
Integer division | \ |
Modulus | Mod |
Additive | +, - |
Bitwise NOT | BitNot |
Bitwise AND | BitAnd |
Bitwise OR | BitOr |
Bitwise XOR | BitXor |
Concatenation | & |
Relational | =, <>, <, >, <=, >=, TypeOf…Is , Is , Like |
Conditional NOT | Not |
Conditional AND | And |
Conditional OR | Or |
Conditional XOR | Xor |
When an operand occurs between 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.