top of page

How to Use the DEC2BIN Function

How to Use the DEC2BIN Function in excel

The DEC2BIN function converts decimal numbers into binary numbers.

Contents:


Syntax

= DEC2BIN(number, [places])

number - The decimal number you wish to convert into a binary number

[places] - Optional, number of significant digits to pad the binary number with


Note: Only numbers from -511 to 511 will work, anything outside of that range will return a #NUM error


Explanation

The DEC2BIN function is part of the "Engineering" group of functions within Excel.


This function takes in decimal numbers and converts them into binary form.


When using the standard Excel functions, binary numbers can be up to 10 characters, or bits, in length. If the length exceeds this, a #NUM error will be returned.


This means the largest number than can be represented is "111111111" or 511, and the smallest is "1000000001" or -511.


DEC2BIN left padding with zeros

When using the optional, places argument, the places number will pad the returned binary number with zeros to the left.


If the number of significant digits is less than the binary number (like "2" used for the binary number for "101"), a #NUM error will be returned.


What is a Decimal Number

excel binary vs decimal numbers

Let's take a look at the number "102" and see how it works as a decimal and binary number.


A decimal number is a number expressed in the base-10 numeral system, also known as the decimal system, the most commonly used system worldwide.


Each digit is based on its position, or place value, which increases by a power of 10 as you move from right to left.


understanding how decimal numbers are calculated

In this example, the number 102 is calculated by multiplying the ones place, "2", by 1, then the tens place by "0", and finally the hundreds place by "1", and adding the results together.


What is a Binary Number

A binary number is a number expressed in the base-2 numeral system, which uses only two symbols, 0 and 1.


Each digit in a binary number is a bit, and the value of each bit is based on its position, with each position representing a power of 2, increasing as you move from right to left.

understanding how binary numbers are calculated

In this example, instead of the base increasing by 10x as we go up, the base is increased by 2x each step.


Each 0 and 1 value in the binary number is multiplied by the base, and the sum of all of the multiplied values is the corresponding decimal number.


Examples

How to Convert Decimal Numbers to Binary

Let's say we have table of regular, decimal numbers, and need to convert them into binary.

excel convert decimal number to binary with formula

The formula to convert from decimal to binary would be:

= DEC2BIN(binary_number)

If we plug this formula into the table, the formula returns the correct binary number.

convert decimal numbers to binary numbers in excel

Using the DEC2BIN function in the right column lets us easily convert multiple numbers at once.


excel convert decimal to binary string


bottom of page