DEC2BIN Function

Converts a decimal number to binary.

Category

Engineering

Available in

All versions, Microsoft 365

Returns

Binary text (up to 10 characters)

Want to practice DEC2BIN in a real spreadsheet? Open a blank sheet in our Practice Sandbox and try it with live data, with the AI Excel tutor beside you. No Excel needed — just a free account.Try it free in the Sandbox

Overview

DEC2BIN converts a decimal number into binary. Decimal (base 10) is the everyday number system. Binary (base 2) uses only the digits 0 and 1.

The input must be from −512 to 511, or DEC2BIN returns #NUM!. Negative numbers use a fixed 10-character form called two's complement: the first digit acts as the minus sign. For example −1 is 1111111111 in binary, 7777777777 in octal and FFFFFFFFFF in hex.

Syntax

=DEC2BIN(number, [places])

Arguments

ArgumentRequired?What it does
numberYesThe whole number to convert, from −512 to 511. Any decimal part is dropped (3.9 is treated as 3).
placesNoHow many characters to show, padding with leading zeros (e.g. 8 turns 101 into 00000101). Ignored for negative numbers.

Examples

Example 1 — Decimal to binary

Each row converts the value in column A.

B2fx=DEC2BIN(A2)
AB
1DecimalBinary
25101
3101010
425511111111
5-11111111111
=DEC2BIN(A2) Explain

Example 2 — Show access codes as fixed-width flags

Northstar stores each person's app access as one number. Four places shows all four switches, Admin first.

C2fx=DEC2BIN(B2,4)
ABC
1PersonCodeFlags
2Ana131101
3Ben30011
4Cy81000
=DEC2BIN(B2,4) Explain

Read right to left: View, Edit, Approve, Admin. Ana (1101) can view, approve and administer, but not edit.

Common mistakes

  • #NUM! The number is outside −512 to 511, or places is too small to fit the answer (DEC2BIN(9,2) — 9 needs four binary digits).

Notes

  • The answer is text, so it keeps leading zeros. Convert back with the matching ...2DEC function before doing maths with it.
  • Related functions: BIN2DEC, DEC2HEX, DEC2OCT, BASE.
Kyle Stott

Author

Kyle Stott

Certified Microsoft Excel Expert

Kyle has worked professionally with Microsoft Excel for over a decade and has consulted on and taught Excel best practices to over 400 companies across 30+ countries.