DEC2BIN Function
Converts a decimal number to binary.
Category
Engineering
Available in
All versions, Microsoft 365
Returns
Binary text (up to 10 characters)
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
Arguments
| Argument | Required? | What it does |
|---|---|---|
| number | Yes | The whole number to convert, from −512 to 511. Any decimal part is dropped (3.9 is treated as 3). |
| places | No | How 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.
| A | B | |
|---|---|---|
| 1 | Decimal | Binary |
| 2 | 5 | 101 |
| 3 | 10 | 1010 |
| 4 | 255 | 11111111 |
| 5 | -1 | 1111111111 |
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.
| A | B | C | |
|---|---|---|---|
| 1 | Person | Code | Flags |
| 2 | Ana | 13 | 1101 |
| 3 | Ben | 3 | 0011 |
| 4 | Cy | 8 | 1000 |
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.

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.