SQL BITEND(), BIN_TO_NUM() Functions

SQL BITEND() Function

SQL BITEND() function take bitwise vector value and return the bitwise AND vector value.

If function taken argument any of the NULL pass return result will NULL.

During this function taken two numeric numbers are explicitly convert to a bitwise binary values that are perform AND operation and again convert final binary value to a numeric value return.

Supported Oracle SQL Version

  • Oracle 8i
  • Oracle 9i
  • Oracle 10g
  • Oracle 11g
  • Oracle 12c
  • Oracle 18c

Example

Consider following example BITEND() function.

SQL> SELECT BITAND(6,3) FROM DUAL;

BITAND(6,3)
-----------
          2

Example Explanation

  • Above example we pass two number 6,4. We are pass into BITAND(8,4) function.
  • Explicitly 6,4 convert into binary 6 = (0110) , 4 = (0100).
  • Perform AND operation 0110 AND 0100 = 0100.
  • Again explicitly convert binary to number value 0100 = 4.
  • Finally 4 value return BITAND(value1, value2) function.

SQL BIN_TO_NUM() Function

SQL BIN_TO_NUM() function take any number of bit values. every value is must be either 0 or 1. This all bit values convert to a hexadecimal numeric value.

Supported Oracle SQL Version

  • Oracle 9i
  • Oracle 10g
  • Oracle 11g
  • Oracle 12c
  • Oracle 18c

Example

Consider following example BIN_TO_NUM() function.

SQL> SELECT BIN_TO_NUM(0,1,1,0) FROM DUAL;

BIN_TO_NUM(0,1,1,0)
-------------------
                  6