Category: FUNCTION | Updated: 2026-11-22
How to Use the DEC2BIN Function in Google Sheets | Convert Decimal to Binary
Syntax
=DEC2BIN(decimal_number, [significant_digits])
- decimal_number: Specifies the decimal integer (
-512to511) to convert to binary. Any fractional part is truncated. - significant_digits (optional): Specifies the number of characters (
1to10) for the output binary number. Leading zeros are padded on the left if needed.
Practical Example with a Table
Here is an example of converting decimal numbers to binary using the DEC2BIN function, including examples with digit padding and negative numbers.
| Input (Decimal) | Significant Digits | Formula | Result (Binary) | Description |
|---|---|---|---|---|
10 |
None | =DEC2BIN(A2) |
1010 | Standard binary notation |
10 |
8 |
=DEC2BIN(A3, B3) |
00001010 | Padded with leading zeros to 8 digits |
-1 |
None | =DEC2BIN(A4) |
1111111111 | Negative numbers always output as 10-digit two’s complement |
255 |
None | =DEC2BIN(A5) |
11111111 | Binary for the maximum 8-bit value |
Common Errors and Notes
- #NUM! Error: Occurs if
decimal_numberis less than-512or greater than511, or ifsignificant_digitsis smaller than the number of digits required by the converted result. - Significant Digits Ignored for Negative Numbers: When
decimal_numberis negative,significant_digitsis ignored and the result is always returned in 10-digit two’s complement format. - Return Value Is Text: Because
DEC2BINreturns a text string rather than a number, it cannot be used directly in arithmetic operations.
Frequently Asked Questions
Q. What range of decimal numbers can the DEC2BIN function convert?
A. It can convert integers from -512 to 511. Specifying 512 or higher, or -513 or lower, results in a "#NUM!" error.
Q. How do I always display the output binary number with 8 digits?
A. Specify `8` for the second argument "significant_digits." For example, decimal 5 is returned as an 8-character string padded with leading zeros: "00000101."