Operator Precedence

Language Items List

When more than one operation occurs in an expression, each part is handled in a predetermined order of precedence. You can alter the order of precedence by placing operations within parentheses. This forces the operations inside the parentheses to be evaluated first, before those placed outside of the parentheses. Normal operator precedence, however, is followed within parentheses.

When there are operators from more than one category in an expression, the following order is assigned: the arithmetic operators are evaluated first, the comparison operators second, and the logical operators last. Within these three categories, the operators are evaluated in the order of precedence shown in the following table:


(1) Arithmetic (2) Comparison* (3) Logical


Exponentiation (^) Equality (=) Not

Negation (-) Inequality (<>) And

Multiplication and division (*,/) Greater than (>) Or

Integer division (\) Less than (<) Xor

Module arithmetic (Mod) Greater than or Equal to () Eqv

Addition and subtraction (+,-) Less than or Equal to () Imp

String concatenation Like

When addition and subtraction or multiplication and division occur together in an expression, each operation is evaluated from left-to-right in the order that it occurs.


Note: The string concatenation operator (&) is not a true arithmetic operator. It has been included with the arithmetic operators because that is where it falls in the order of precedence. Similarly, Like is not a true comparison operator, it is used for pattern-matching. It has been placed with the comparison operators because it is equal in precedence to all comparison operators and falls before the logical operators.

See Also:

Arithmetic Operators
Comparison Operators
Operator Precedence