Oracle / PLSQL: BIN_TO_NUM Function

This article is written about how to use the Oracle/PLSQL BIN_TO_NUM function with syntax and examples.

Description

The Oracle/PLSQL BIN_TO_NUM function converts a bit vector to a number.

Syntax

The syntax for the BIN_TO_NUM function in Oracle/PLSQL is:

BIN_TO_NUM( expr1, expr2, ... expr_n)

Parameters or Arguments

expr1, expr2, … expr_n

Values that must be either 0 or 1. They represent bits in a bit vector.

Returns

The BIN_TO_NUM function returns a numeric value.

Applies To

The BIN_TO_NUM function can be used in the following versions of Oracle/PLSQL:

Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i

Example

Let’s look at some Oracle BIN_TO_NUM function examples and explore how to use the BIN_TO_NUM function in Oracle/PLSQL.

For example:

BIN_TO_NUM(1)
Result: 1

BIN_TO_NUM(1,0)
Result: 2

BIN_TO_NUM(1,1)
Result: 3

BIN_TO_NUM(1,1,1,0)
Result: 14

BIN_TO_NUM(1,1,1,1)
Result: 15