Bit operations are performed similarly to
numeric operations . You can either use the statementCOMPUTE <x> = <bitexp>.
or omit the keyword COMPUTE, as in the statement
<x> = <bitexp>.
<bitexp> can be one of the following bit expressions:
Bit expression |
Meaning |
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-XOR <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 |
0 |
1 |
As with mathematical expressions, you can use parentheses with bit expressions.
DATA:
HEX3 = BIT-NOT ( HEX1 BIT-XOR HEX2 ).
WRITE HEX3.
The output is:
11
The bit operation is processed as displayed below: