Formualizer Docs

DEC2BIN

Converts a decimal integer to binary text.

Optionally pads the result with leading zeros using places.

The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.

Syntax

=DEC2BIN(number, [places])

Arguments

ArgumentTypeRequiredDefault
numbernumberRequired—
placesnumberOptional—

Return type

Can return text.

Remarks

  • number is coerced to an integer and must be in [-512, 511].
  • Negative values are returned as 10-bit two's-complement binary strings.
  • places must be at least the output width and at most 10, or #NUM! is returned.

Examples

Convert a decimal integer using the shortest output.

Formula =DEC2BIN(30)

Expected result 11110

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Request eight characters to see the leading-zero padding.

Formula =DEC2BIN(30,8)

Expected result 00011110

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Convert a negative value to its signed representation.

Formula =DEC2BIN(-1)

Expected result 1111111111

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

A nonzero value cannot fit in a zero-place output.

Formula =DEC2BIN(30,0)

Expected result #NUM!

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Convert a positive integer

Formula =DEC2BIN(42)

Expected result 101010

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Pad binary output

Formula =DEC2BIN(5,8)

Expected result 00000101

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

FAQ

What limits apply to DEC2BIN?

number must be in [-512, 511], and optional places must be between output width and 10, else #NUM!.

Implementation

Engine source

On this page