Purpose
You can call this function to perform a bitwise AND operation on the binary representation of the input parameters.
Syntax
BITAND (expr1,expr2)
Parameters
| Parameter | Description |
|---|---|
| expr1 | The first value on which the bitwise AND operation is performed. It is of the NUMBER data type. |
| expr2 | The second value on which the bitwise AND operation is performed. It is of the NUMBER data type. |
Note
- If either
expr1orexpr2isNULL, the function returnsNULL.- If either parameter is not an integer, it is converted to an integer before the AND operation is performed.
Return type
The return type is NUMBER, or the function returns NULL.
Examples
If a = 2 and b = 3, a is 0100 and b is 0110 in binary. The function compares the binary representations. If the corresponding bit positions are both 1, 1 is returned for the bit. Otherwise, 0 is returned for the bit.
obclient> SELECT BITAND(2,3) FROM DUAL;
+-------------+
BITAND(2,3)
+-------------+
2
+-------------+
1 row in set