# Examples 7.2.2:
BOOL

The features of the pervasive class BIT are used in individual examples below.

#### not

The following two code fragments are identical in meaning although the first will usually be more efficient (dependent upon the implementation).

if truth_value then
...
else
...
end

if truth_value then
...
elsif truth_value.not then
...
end

Note that truth_value.not is the identical expression to ~truth_value.

#### is_eq

In practice it is not often necessary to use an equality test on two truth values. However, this is provided for completeness as -

if truth_value = true then ...

which is, of course, identical to

if truth_value then ...

#### and

Where it is necessary to satisfy two conditions simultaneously before taking some action then the following could be written -

case first_pred
and second_pred
when true then
do_something
when false then
do_something_else
end

which uses a case construction as an alternative to an if-statement.

#### or

The other canonical logical operator could be used in expressing the following version of De Moivre's theorem.

~(A and B) = ~A or ~B

where A and B are truth values.

| Specification Index |  | Language Index |  | Section 7 Index

Comments or enquiries should be made to Keith Hopper . Page last modified: Tuesday, 23 May 2000. |