Order of operator evaluation

Use parentheses to group operations. Expressions within parentheses are evaluated before performing other operations. For example:

(UnitPrice - Discount) * Tax

The expression UnitPrice - Discount is evaluated before the rest of the expression.

Some operators are evaluated before others according to standard rules of precedence. Operators are evaluated in the following order:

Precedence Operators Description
first ( ) Operations within parentheses
second + and - unary plus and minus

The sign indicates a positive or negative expression, for example:

- quantity*rate

third =, <, >, <=, >=, != comparative operators
fourth ^ logical operator "exclusive or"
fifth & logical operator "and"
sixth | logical operator "or"
seventh * and / multiplication and division
eighth + and - addition and subtraction

Operators of equal precedence are evaluated left to right.


Feedback