DEC2BIN function

Converts a decimal number to its binary representation, optionally padding the result with leading zeros to a specified width.

=DEC2BIN(number, [places])

Generate a DEC2BIN formula

Describe what you need. The generator will reach for DEC2BIN where DEC2BIN is the right tool, and tell you when it is not.

How to get a better answer
  • Name your columns by letter and by header: "column F (Net Value)" beats "the amount column".
  • State every condition, including the negatives — "not cancelled" changes the formula's shape.
  • Say where the data starts if it is not row 1, and whether it will grow.
  • Check the settings above match your spreadsheet: the wrong argument separator is a syntax error on your machine.

Arguments

How DEC2BIN reads its arguments
numberrequiredplacesoptionalDEC2BIN
ArgumentRequiredDescription
numberRequiredA decimal integer to convert to binary; must be between -512 and 511 inclusive, or a #NUM! error occurs.
placesOptionalOptional. The number of binary digits to display; if the binary result has fewer digits, leading zeros are added; if omitted, no padding is applied.

Returns

A text string representing the binary equivalent of the input number.

Availability

Excel: All · Google Sheets: Supported

Worked examples

1. Convert a student's percentage score to binary

StudentSubjectAssignmentScoreMaxScore
AliceMathQuiz195100
BobMathQuiz187100
CharlieScienceLab92100
DianaEnglishEssay88100
=DEC2BIN(95)

Result: 1011111

Alice's Math Quiz score of 95 converts to binary 1011111, which equals 64+16+8+4+2+1. This representation might be used in specialized reporting systems or for analyzing score patterns in binary-encoded formats.

2. Display a score as 8-bit binary with padding

StudentSubjectAssignmentScoreMaxScore
AliceMathQuiz195100
BobMathQuiz187100
CharlieScienceLab92100
DianaEnglishEssay88100
=DEC2BIN(87,8)

Result: 01010111

Bob's score of 87 becomes 01010111 when formatted as 8-bit binary. The places parameter pads with leading zeros, ensuring all scores display at the same width regardless of their magnitude, useful for consistent data exports.

3. Convert assignment count to binary with padding

StudentSubjectAssignmentScoreMaxScore
AliceMathQuiz195100
BobMathQuiz187100
CharlieScienceLab92100
DianaEnglishEssay88100
=DEC2BIN(4,4)

Result: 0100

The dataset contains 4 assignment records. DEC2BIN(4,4) converts this to 4-bit binary 0100. This format is useful when exporting gradebook metadata to systems that require binary representation for record counts or indexing.

Common errors

Which DEC2BIN error are you seeing?
DEC2BIN returned an error#NUM!
If converting scores or values above 511, use DEC2HEX or DEC2OCT instead, or divide the number by a power of 2 before converting to bring it into range.
#VALUE!
Verify both arguments are numbers. If referencing cells, check that they contain actual numeric values, not text formatted to look like numbers (use VALUE() or change cell format if needed).
#NUM!
Provide a non-negative integer for places, or omit it if padding is not needed. Use INT() to round a decimal places value to the nearest whole number.
ErrorWhy it happensHow to fix it
#NUM!The number argument is outside the valid range. DEC2BIN accepts only integers from -512 to 511, the full range of a signed 10-bit binary number.If converting scores or values above 511, use DEC2HEX or DEC2OCT instead, or divide the number by a power of 2 before converting to bring it into range.
#VALUE!The number or places argument contains text, a date, a boolean, or other non-numeric value that cannot be converted to an integer.Verify both arguments are numbers. If referencing cells, check that they contain actual numeric values, not text formatted to look like numbers (use VALUE() or change cell format if needed).
#NUM!The places argument is a negative number or cannot be converted to a non-negative integer. DEC2BIN requires places to be a whole number ≥ 0.Provide a non-negative integer for places, or omit it if padding is not needed. Use INT() to round a decimal places value to the nearest whole number.

Tips and when to use something else

  • Use BIN2DEC to reverse the conversion and transform binary text strings back into decimal numbers suitable for calculations.
  • If you need base-16 or base-8 instead of binary, DEC2HEX and DEC2OCT provide the same conversion functionality with different number bases.
  • The places parameter controls only the display format, not the numeric value; padding with zeros does not change the actual data.
  • For bitwise operations on binary data, use BITAND, BITOR, BITXOR, BITLSHIFT, or BITRSHIFT instead of converting numbers to text.

Frequently asked questions

How do I convert a decimal number to binary in a spreadsheet?
Use DEC2BIN with the decimal number as the first argument. For example, =DEC2BIN(255) returns 11111111. To pad the result to a specific width, add the places parameter: =DEC2BIN(255,16) produces 0000000011111111 in 16-bit format.
What is the range of numbers DEC2BIN can convert?
DEC2BIN handles signed 10-bit integers, supporting the range -512 to 511. Numbers outside this range produce a #NUM! error. For larger numbers, use DEC2HEX (base-16) or DEC2OCT (base-8), or break large numbers into smaller parts before converting.
Can DEC2BIN handle negative numbers?
Yes, DEC2BIN supports negative integers from -512 to -1, representing them in two's complement binary form. For example, =DEC2BIN(-1) returns 1111111111 (ten 1s), which is the two's complement representation of -1 in 10-bit binary.
How do I pad binary output with leading zeros?
Use the places parameter to specify the desired bit width. For example, =DEC2BIN(5,8) returns 00000101 instead of 101. This ensures all converted values display at the same width, which is essential for consistent formatting when exporting data or creating reports.

Need a different formula?

The full generator is not scoped to one function — describe any spreadsheet problem and it will pick.

Open the formula generator

Reviewed 2026-09-17