The bit-string operators and the operations they stand for are as follows:
Operators | Operations |
---|---|
& | and |
| | inclusive or |
^ | not (complement) |
Open PL/I supports the use of a tilde (~) as an operator symbol equivalent to a caret (^).
Open PL/I supports the use of an exclamation point (!) as an operator symbol equivalent to a single bar (|).
Bit-string operators require bit-string operands. Operands of other data types must be converted to bit-string values using the BIT built-in function.
The infix operators & and | operate on operands of dissimilar length by effectively extending the shorter value to the length of the longer value. This is done by appending zero bits to the right end of the shorter value.
The result of ^ is a bit string whose bits are the complement of the bits in the operand; that is, each 0 bit becomes a 1 bit and each 1 bit becomes a 0 bit.
The result of & and | is a bit string whose length is that of the larger operand. Each bit of the result is listed as follows:
First Operand | Second Operand | & | | |
---|---|---|---|
0 | 0 | 0 | 0 |
0 | 1 | 0 | 1 |
1 | 0 | 0 | 1 |
1 | 1 | 1 | 1 |
For instance, if X is '01011'B and Y is '11001'B, ^X produces '10100'B, X&Y produces '01001'B, and X | Y produces '11011'B. X&'11'B would produce '01000'B.