DEC2BIN in Excel: Pad Binary Text and Handle Negative Values
Convert decimal integers to binary in Excel, choose a minimum width and understand ten-bit negative results and documented input limits.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: DEC2BIN(number,[places]) converts a decimal integer from −512 through 511 to binary notation. Omitted places uses the minimum width for nonnegative values; negative inputs use a ten-character two’s-complement representation.
Availability and version history
- Introduced: the first introduction version is not established by the reviewed official history.
- Availability: official help lists Excel for Microsoft 365, Excel for Microsoft 365 for Mac, Excel 2024, Excel 2024 for Mac, Excel 2021 for Mac, Excel 2019, Excel 2016. This particular reference omits Excel 2021 for Windows; that client is not inferred from the Mac listing.
- Checked: October 14, 2026; official DEC2BIN reference. Documentation and independent models; no native Excel execution or wider platform certification.
Syntax and optional width
=DEC2BIN(number,[places])
number is required and documented as a decimal integer. places is optional and supplies a padded character width. For nonnegative values, it must be wide enough for the result; omission uses the minimum necessary characters.
Microsoft states that noninteger places is truncated. Zero or negative places produces #NUM!, as does a width too short for the representation. Nonnumeric number or places arguments produce #VALUE!; numbers outside −512 through 511 produce #NUM!.
For a negative input, the reference specifically says valid place values are ignored and the result is ten characters. That wording does not establish that invalid place values are harmless. The examples below use valid positive widths when supplying the argument to a negative number.
Example 1: build aligned binary labels
Enter 0, 3, 9, 18 and 31 in A2:A6. In B2 enter =DEC2BIN(A2) and in C2 enter =DEC2BIN(A2,8). Fill both down.
| Decimal | Minimum representation | Width 8 |
|---|---|---|
| 0 | 0 | 00000000 |
| 3 | 11 | 00000011 |
| 9 | 1001 | 00001001 |
| 18 | 10010 | 00010010 |
| 31 | 11111 | 00011111 |
The width-eight column is easier to compare visually because the bit positions line up. Padding does not multiply the number or allocate a larger numeric range. The underlying quantities remain 0, 3, 9, 18 and 31.
In D2 use =BIN2DEC(C2) and fill down. The decoded numbers match column A. BIN2DEC reads the bit representation; ordinary arithmetic on a displayed sequence of digits is not a substitute for base conversion.
Example 2: negative values use ten-bit two’s complement
Enter −1, −2, −100 and −512 in F2:F5. Use =DEC2BIN(F2) in G2 and fill down:
| Decimal | Expected binary representation |
|---|---|
| -1 | 1111111111 |
| -2 | 1111111110 |
| -100 | 1110011100 |
| -512 | 1000000000 |
For −100, add 1024 to obtain 924 and express that value in ten binary positions. This independently produces 1110011100. Decoding the full-width representation subtracts 1024 again.
=DEC2BIN(-1,4) still produces 1111111111, because the valid width argument is ignored for this negative value. The output is not −1 written with a minus sign and is not an eight-bit byte representation.
A ten-character positive control is =DEC2BIN(511,10), yielding 0111111111. The leading zero distinguishes it from the negative full-width range. An input of 512 is outside the documented interval even though unsigned binary 1000000000 exists mathematically.
Advanced example: inspect fields in a small packed record
A report stores two four-bit fields as a decimal value. Enter 57 in J2. Use:
=DEC2BIN(J2,8)
=BITRSHIFT(J2,4)
=BITAND(J2,15)
The expected outputs are 00111001, 3 and 9. The first formula supplies a readable bit label; the other two extract the high and low fields numerically. BITRSHIFT removes the lower four bits, while BITAND keeps them with mask 15.
If high=15 and low=15, the packed value is 255 and the width-eight representation is 11111111. BIN2DEC still decodes that eight-character value as positive 255, because its negative encoding applies at ten-bit width. Do not infer an eight-bit signed convention from a visual byte layout.
Width errors and safe boundaries
=DEC2BIN(9,4)returns 1001;=DEC2BIN(9,3)returns documented#NUM!because four positions are required.=DEC2BIN(9,4.9)uses truncated width 4 and returns 1001.=DEC2BIN(9,0)has documented#NUM!behavior.=DEC2BIN(-513)and=DEC2BIN(512)lie outside the allowed number range.
The reference explicitly calls number an integer but does not separately explain fractional-number coercion; those inputs are not assigned an assumed truncation rule here. For larger positive integers, investigate BASE under its own documented limits instead of extending DEC2BIN’s range. Preserve the numeric source beside the representation for sorting, arithmetic and audit checks.
References and verification
Expected outputs are independently calculated examples or documented rules, not captured native Excel results. Formulas use English function names and comma argument separators. Locale, rendering and boundary restrictions are stated where relevant.