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 (-512 to 511) to convert to binary. Any fractional part is truncated.
  • significant_digits (optional): Specifies the number of characters (1 to 10) 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_number is less than -512 or greater than 511, or if significant_digits is smaller than the number of digits required by the converted result.
  • Significant Digits Ignored for Negative Numbers: When decimal_number is negative, significant_digits is ignored and the result is always returned in 10-digit two’s complement format.
  • Return Value Is Text: Because DEC2BIN returns 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."