DEC2BIN (decimal number to binary number)

Navigation:  Formulas and functions > Functions from A to Z >

DEC2BIN (decimal number to binary number)

Previous pageReturn to chapter overviewNext page

Syntax:

DEC2BIN(Number [, Digits])

Description:

This converts the given decimal number (base 10) to a binary number (base 2).

Note: Please note that the result of this function is a text string and not a number.

Number is the number to be converted.

The permissible value range for Number is:

-(2^31) ≤ Number ≤ (2^31)-1

That is equivalent to:

-2,147,483,648 ≤ Number ≤ 2,147,483,647

The optional argument Digits lets you specify the number of places to be displayed. If omitted, Calculate determines the number of required places automatically.

Digits must be greater than zero. Digits should be an integer. If this is not the case, Calculate automatically truncates the decimal places.

If Digits are less than the minimum number of places required to display the number, the function returns a #NUM error value.

If Number is negative, the result is represented in 32-bit two's complement; the argument Digits is ignored in this case (see last example).

Example:

DEC2BIN(42) returns 101010

DEC2BIN(42, 8) returns 00101010

DEC2BIN(42, 4) returns the error value #NUM! because the number 42 cannot be represented with fewer than 6 binary digits

DEC2BIN(-42) returns 11111111111111111111111111010110

See also:

BIN2DEC, DEC2HEX, DEC2OCT, BASE