BITAND

2023-10-31 11:17:12  Updated

Purpose

BITAND() returns a bitwise AND 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 expr1 or expr2 is NULL, the function returns NULL.
  • 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

Contact Us