Bit operations are performed similarly to numeric operations . You can either use the statement
COMPUTE <x> = <bitexp>.
or omit the keyword COMPUTE, as in the statement
<x> = <bitexp>.
<bitexp> can be one of the following bit expressions:
Bit expression |
Description |
BIT-NOT <y> |
Negation |
<y> BIT-AND <z> |
And |
<y> BIT-XOR <z> |
Exclusive or |
<y> BIT-OR <z> |
Or |
The operands <y> and <z> are linked bit by bit in the above operators, and the result is placed in the result field <x>. The result field <x>, and the operands <y> and <z> must all be of type X. If the field lengths are different, all operands are converted to the field length of the result field <x>.
The following rules apply to bit operations:
<y> |
<z> |
BIT-NOT <y> |
<y> BIT-AND <z> |
<y> BIT-OR <z> |
<y> BIT-XOR <z> |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
1 |
1 |
0 |
1 |
1 |
1 |
0 |
0 |
0 |
1 |
1 |
1 |
1 |
0 |
1 |
1 |
0 |
As with mathematical expressions, you can use parentheses with bit expressions.

DATA: hex1(1) TYPE x
VALUE 'B5',
hex2(1) TYPE x VALUE '5B',
hex3(1) TYPE x.
hex3 = BIT-NOT ( hex1 BIT-XOR hex2 ).
WRITE hex3.
The list output is:
11
The bit operation is processed as displayed below:
