Chapter 12. Operator Precedence
When a mathematical or logical expression is being evaluated, all the operators (+,*,DIV etc) are given a priority of 1 to 7. Priority 1 operators are those acted upon first, and priority 7 last.
Here is the complete list:
| Priority | Operator | |
|---|---|---|
| 1 | - | Unary minus |
| + | Unary plus | |
| NOT | Logical NOT | |
| FN | Functions | |
| () | Brackets | |
| ?!$ | Indirection operators | |
| 2 | ^ | Raise to the power |
| 3 | * | Multiplication |
| / | Division | |
| DIV | Integer division | |
| MOD | Integer remainder | |
| 4 | + | Addition |
| - | Subtraction | |
| 5 | = | Equal to |
| <> | Not equal to | |
| < | Less than | |
| > | Greater than | |
| <= | Less than or equal to | |
| >= | Greater than or equal to | |
| 6 | AND | Logical and bitwise AND |
| 7 | OR | Logical and bitwise OR |
| EOR | Logical and bitwise Exclusive OR | |
Operators with the same priority are executed left to right, as they appear in the expression. For example, 22 MOD 3/7 is evaluated as (22 MOD 3)/7. All priorities may be overridden by using brackets.