Rules of Precedence for Operators
Documentation | Blog | Demos | Support
Rules of Precedence for Operators
0 out of 5 stars
5 Stars | 0% | |
4 Stars | 0% | |
3 Stars | 0% | |
2 Stars | 0% | |
1 Stars | 0% |
Operator | Rule of Precedence |
Conditional Operators | are evaluated first |
NOT | NOT is evaluated first. |
AND | AND is evaluated next. |
OR, XOR | OR and XOR are evaluated last. |
Note: Operators of equal precedence are evaluated from left to right in the expression.
Parentheses can be used to explicitly determine the order of evaluation, overriding the order described above. Each pair of parentheses can contain only one Boolean expression. For example:
not (Salary > 4500 xor LastName = ‘Smith’)
causes the XOR expression to be evaluated before the NOT.
Examples
Some examples of Boolean expressions are shown below:
DeptNum=’Sports’ and Salary > 45000 and LastName = ‘Smith’
Logically true when all three conditional expressions are true; otherwise, logically false.
LastName = ‘Allan’ or Firstname = ‘Allan’
Logically true when either of the conditional expressions is true; otherwise, logically false.
not Salary > 45000
Logically true when the conditional expression is logically false and vice versa.
not ProdCode between 542 and 863
Logically true when the conditional expression is logically false and vice versa.
not LastName in (‘Smith’, ‘Jones’)
Logically true when the conditional expression is logically false and vice versa.
not FirstName like ‘ Sm%’
Logically true when the conditional expression is logically false and vice versa.
0 out of 5 stars
5 Stars | 0% | |
4 Stars | 0% | |
3 Stars | 0% | |
2 Stars | 0% | |
1 Stars | 0% |