The Bitwise AND operator performs a bitwise AND of the bits of the first operand with the bits of the second operand. Bitwise AND can be used in both variable and integer constant expressions, but not in floating-point constant expressions.
Each bit of the two operands is subject to the following logic:
Bitwise AND Truth Table | ||
---|---|---|
A | B | Result |
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
Example:
Code Block |
---|
X := %00101100 & %00001111 |
...
Bitwise AND has an assignment form, &=, that uses the variable to its left as both the first operand and the result destination. For example,
Code Block |
---|
X &= $F 'Short form of X := X & $F |
...