|
| Previous: 2.6.4 Sum Operators | TOC | Index | Back | Next: 2.6.6 Relational Operators |
In T3X, all bit operations have the same precedence. Grouping such operations often requires parentheses. Otherwise, the evaluation is performed from the left to the right.
The operation A&B results in the bitwise AND of A and B. Each bit is the result of computing the logical product of one bit in A with the bit at the same position in B.
A|B yields the result of performing a bitwise OR on A and B. Each bit in the result is a logical sum of a bit in A and the bit at the same position in B.
A^B performs a bitwise exclusive OR (XOR). In this case, the computation of a single bit is done by combining bits at the same positions in A and B using a logical negative equivalence ('not equal') operation.
See the following table for the results of applying logical operations to pairs of bits.
| A | B | AND,* | OR,+ | XOR,\= |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
A<<B evaluates to the value of A with all bits shifted to the left by B positions. After this an operation, the sign of the result is undefined.
A>>B yields the result of shifting the bits of A to the right by B positions. After this an operation, the sign of the result is undefined.
Technically speaking, the shift operators in T3X perform bitwise rather than arithmetic shift operations. This implementation has been chosen, because it is in some cases hard to manipulate bit fields using arithmetic shift operators.
| Previous: 2.6.4 Sum Operators | TOC | Index | Back | Next: 2.6.6 Relational Operators |