Operator Precedence

See AlsoFE8ON8

When several operations occur in an expression, each part is evaluated and resolved in a predetermined order.  That order is known as operator precedence.  Parentheses can be used to override the order of precedence and force some parts of an expression to be evaluated before others.  Operations within parentheses are always performed before those outside.  Within parentheses, however, normal operator precedence is maintained.

When expressions contain operators from more than one category, arithmetic operators are evaluated first, comparison operators are evaluated next, and logical operators are evaluated last.  Within individual categories, operators are evaluated in the order of precedence shown below:





Exponentiation (^)

Equality (=)


Negation ( - )

Inequality (<>)


Multiplication and division (*, / )

Less than (<)


Integer division (\)

Greater than (>)


Modulo arithmetic (Mod)

Less than or Equal to (<=)


Addition and subtraction (+, -)

Greater than or Equal to (>=)


String concatenation (&)







Note   All comparison operators have equal precedence, that is, they are evaluated in the left-to-right order in which they appear.


When multiplication and division occur together in an expression, each operation is evaluated as it occurs from left to right.  Likewise, when addition and subtraction occur together in an expression, each operation is evaluated in order of appearance from left to right.

The string concatenation operator (&) is not really an arithmetic operator, but in precedence it does fall after all arithmetic operators and before all comparison operators.  Similarly, the Like operator, while equal in precedence to all comparison operators, is actually a pattern-matching operator.

See Also

Arithmetic OperatorsSH0K1B

Comparison OperatorsNRJZ1K

Concatenation Operators2MYTW1K

Logical Operators1CQVUTN

Other Operators2HA580P

Arithmetic Operators

^ Operator2D400TN

* Operator1T8TWLM

/ Operator7HHL0NO

\ Operator8Y6K4D

Mod OperatorLANMOD

+ OperatorLANADD

- Operator2QGJSB

Concatenation Operators

& Operator40C5HGY

+ OperatorLANADD

Other Operators

Is OperatorLANIS

Like Operator3XXJZ34

Logical Operators

And OperatorLANAND

Eqv OperatorLANEQV

Imp OperatorLANIMP

Not OperatorLANNOT

Or OperatorLANOR

Xor OperatorLANXOR