
BITAND
The BITAND function returns the bitwise AND of two numbers.
BITAND(value-1, value-2)
value-1: The first number. value-1 must be an integer.
value-2: The second number. value-2 must be an integer.
Notes
Values can be in any order and return the same result.
The truth table for BITAND is below:
value-1 | value-2 | BITAND(value-1, value-2) |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
Examples |
---|
=BITAND(9,13) returns 9. The binary equivalent of 9 is 1001, and the binary equivalent of 13 is 1101; the bits match at the rightmost position and the position fourth from the right. This returns (2^0)+(2^3), or 9. =BITAND(12,3) returns 0. The binary equivalent of 12 is 1100, and the binary equivalent of 3 is 11 (which can also be represented as 0011); the bits don’t match in any position, so 0 is returned. |