A bit operation is specified by combining operands with one of the following logical operators:
¬ & |
The not/exclusive-or symbol (¬), can be used as a prefix or infix operator. The and (&) symbol and the or (|) symbol, can be used as infix operators only. (The operators have the same function as in Boolean algebra.)
Operands of a bit operation are converted, if necessary, to bit strings before the operation is performed. If the operands of an infix operation do not have the same length, the shorter is padded on the right with '0'B.
The result of a bit operation is a bit string equal in length to the length of the operands.
Bit operations are performed on a bit-by-bit basis. Table 19 illustrates the result for each bit position for each of the operators. Table 20 shows some examples of bit operations.
| A | B | ¬A | ¬B | A&B | A|B | A¬B |
|---|---|---|---|---|---|---|
| 1 | 1 | 0 | 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 0 | 1 | 1 |
| 0 | 0 | 1 | 1 | 0 | 0 | 0 |
| For these operands and values | This operation | Yields this result |
|---|---|---|
|
A = '010111'B B = '111111'B C = '110'B D = 5 |
¬ A |
'101000'B |
|
¬ C |
'001'B |
|
|
C & B |
'110000'B |
|
|
A | B |
'111111'B |
|
|
A ¬ B |
''101000''B |
|
|
A ¬ C |
'100111'B |
|
|
C | B |
'111111'B |
|
|
A | (¬C) |
'011111'B |
|
|
¬((¬C)|(¬B)) |
'110111'B |
|
|
SUBSTR(A,1,1)|(D=5) |
'1'B |
In addition to the not, exclusive-or, and, and or operations using the operators ¬, &, and |, Boolean operations can be performed using the BOOL built-in function discussed in BOOL.