![]() |
![]() |
![]() |
![]() |
(..Expressions..) | Contents | Index | (Assignments (Var.)..) |
|
Analogous to the other expression classes, roughly speaking, all objects that represent boolean values belong to the class of boolean expressions. To be at bit more sophisticated, we distinguish again between elementary and compounded expressions. To the first group belong
Furthermore elementary boolean expressions are also obtained as results of comparisons between expressions of other types. Although they have been introduced earlier, their full syntax is given here again:
In case of strings and integers, RelOp may be any relational operator ==, !=, <, <=, >, or >= whatever.Going over to compounded boolean expressions, we observe that a parenthezised boolean expression is again a boolean expression:
Like in the context of integer expressions, the parentheses do the same here. Their high evaluation prioritiy causes the expression within to be evaluated first.
But what should parentheses be useful for without a chance to gain more complex boolean expressions connecting easy ones? Therefore, we have the logical operators && (AND), || (OR), and ! (NOT) at our disposal:
!BoolExpression
Remark:
If (boolean) results of comparisons are connected
by &&
or ||,
parentheses are not needed to make clear which
are the boolean expressions. The
evaluation priority of
relational operators is higher than the one of
AND and OR.
The situation changes as soon as the logical negation
! is involved:
its priority is higher than the members of both
RelOp and
LogOp.
Especially if the result of a
comparison should be denied, the comparison
must be collected in parentheses.
Observe furthermore that the priority of
&& is higher than of
||. (In case of remaining doubts you
may consult the operator table.)
Some examples of boolean expressions can be found in
example 14.
![]() |
![]() |
![]() |
![]() |
(..Expressions..) | Contents | Index | (Assignments (Var.)..) |