Set the evaluation order of operators
- Last UpdatedJul 23, 2024
- 1 minute read
In any expression, you can use parentheses to force operators to be evaluated in a certain order. This works the same way as in any mathematical expression. If you do not use parentheses, your expression is evaluated based on the default precedence rules for operators. The operation with the highest precedence level is executed first, followed by the operation with the second-highest precedence level, and so on.
The following table shows the precedence level of each operator. Operators on the same row have the same precedence level.
|
-, NOT, ~ |
Highest precedence |
|
** |
|
|
*, /, MOD |
|
|
+, - |
|
|
SHL, SHR |
|
|
<, >, <=, >= |
|
|
==, <> |
|
|
& |
|
|
^ |
|
|
| |
|
|
AND |
|
|
OR |
|
|
= |
Lowest precedence |