Purpose
The BITAND function performs a bitwise AND operation on its input parameters.
Syntax
BITAND (expr1,expr2)
Parameters
| Parameter | Description |
|---|---|
| expr1 | The first value to be used in the bitwise AND operation. This is a NUMBER type expression. |
| expr2 | The second value to be used in the bitwise AND operation. This is a NUMBER type expression. |
Note
- If either
expr1orexpr2isNULL, the result isNULL. - If the parameters are not integers, they are converted to integers before the operation is performed.
Return type
Returns a NUMBER data type or NULL.
Examples
Assume a=2 and b=3. The binary representation of a is 0100, and the binary representation of b is 0110. When performing a bitwise AND operation, each corresponding bit is compared. If both bits are 1, the result is 1; otherwise, it is 0.
obclient> SELECT BITAND(2,3) FROM DUAL;
+-------------+
| BITAND(2,3) |
+-------------+
| 2 |
+-------------+
1 row in set
