Boolean expressions use Boolean operators to compare operands (typically, conditional expressions). When evaluated, Boolean expressions yield a logical result (true or false), depending on the nature of the Boolean operator and the values of the conditional expressions.
The standard rules of precedence for Boolean evaluation are used.
The software ceases to evaluate a Boolean expression as soon as the final result can be correctly predicted. For example, with OR, if the first conditional expression is logically true, then the Boolean expression must be logically true. The software does not bother to evaluate the remaining conditional expressions.
In the expression
LastName = 'Smith' or DeptNum = 'Sports'
if LastName = 'Smith' is logically true, then DeptNum = 'Sports' is not evaluated.
Note: Taking Boolean evaluation logic into account can be important to the functioning of an application program. For example, if any of the value expressions in the Boolean expression is written in the special assignment format, the assignment is not made if the portion of the Boolean expression containing the assignment is not evaluated.
Operator | Meaning |
not expr | NOTs the logic expression to the right. If the logic expression is true, the result of the Boolean expression is false; if the logic expression is false, the result of the Boolean expression is true. |
expr and expr | ANDs two logic expressions (one to the left and one to the right). If both logic expressions are true, the result of the Boolean expression is true; otherwise, the Boolean expression is false. |
expr or expr | ORs two logic expressions (one to the left and one to the right). If either (or both) of the logic expressions is (are) true, the result of the Boolean expression is true; if both of the logic expressions are false, the Boolean expression is false. |
expr xor expr | XORs two logic expressions (one to the left and one to the right). If either of the logic expressions is true, the result of the Boolean expression is true; if both of the logic expressions are true or if both are false, the Boolean expression is false. |