BIN_TO_NUM function in Oracle

BIN_TO_NUM is one of the vital Conversion functions of Oracle. It is used to convert a bit vector to a number. The BIN_TO_NUM function is supported in the various versions of the Oracle/PLSQL, including, Oracle 12c, Oracle 11g, Oracle 10g and Oracle 9i.

Syntax:

BIN_TO_NUM ( expr1, expr2, ... expr_n )

Parameters: expr1, expr2, … expr_n: It is used to specify the bit values.

Example 1:

BIN_TO_NUM (1)

Output:

1

Explanation: The numeric value of bit 1 is 1.

Example 2:

BIN_TO_NUM (1,1)

Output:

3

Explanation: The numeric value of 11 is 3.

Example 3:

BIN_TO_NUM (1,1,1)

Output:

7

Explanation: The numeric value of 111 is 7.

Example 4:

BIN_TO_NUM (1,1,1,1)

Output:

15

Explanation: The numeric value of 1111 is 15.

Example 5:

BIN_TO_NUM (1,1,0,1)

Output:

13

Explanation: The numeric value of 1101 is 13.

Please follow and like us:
Content Protection by DMCA.com