Contact

DEC2BIN Function (OpenOffice Calc)

Engineering Intermediate OpenOffice Calc

Learn the DEC2BIN function in Apache OpenOffice Calc: Converts a decimal number to a binary number.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

Availability and version history

  • Introduced: Documented by Apache OpenOffice 4.1.16; original introduction not established.
  • Availability: Supported in Apache OpenOffice 4.1.16, verified against its function registry. This identifies a supported release, not a final working version.
  • Scope: Desktop Calc, using the English function name. Availability in other spreadsheet applications is separate.
  • Checked: 2026-10-14 — function reference; versioned support. Documentation/source check; not a new native test. Existing example-specific test claims below retain their stated scope.

DEC2BIN converts a decimal integer into binary digit text. It uses a signed ten-bit convention: positive values have up to nine significant binary digits, while negative values are returned as ten-digit two’s-complement strings. It is therefore a bounded signed converter, not a general formatter for arbitrary positive binary integers.

Syntax and arguments

=DEC2BIN(number; places)
=DEC2BIN(number)

Number is required. The supported integer range is -512 through 511. Optional places requests a minimum positive-output width from 1 through 10. When omitted, unnecessary leading zeros are left out. The pinned callback receives number as a 32-bit integer before passing it to the shared converter; these examples use explicit integers and do not certify the worksheet binding’s fractional-input conversion. The examples use English names and semicolon separators.

Reproducible reference cases

Formula Reference result
=DEC2BIN(10) "1010"
=DEC2BIN(10;8) "00001010"
=DEC2BIN(0) "0"
=DEC2BIN(511) "111111111"
=DEC2BIN(-1) "1111111111"
=DEC2BIN(-512) "1000000000"
=DEC2BIN(-1;1) "1111111111"
=DEC2BIN(10;3) ERROR
=DEC2BIN(512) ERROR
=DEC2BIN(-513) ERROR
=DEC2BIN(1;0) ERROR
=DEC2BIN(1;11) ERROR

The first formula preserves the original example and expected result. Its historical comparable LibreOffice 25.2 check was not an OpenOffice native test. New results are independently checked mathematical/source expectations. Quotation marks identify returned text; ERROR denotes the source’s invalid-argument path without claiming an observed localized worksheet message.

Practical worksheet: encode bounded instrument readings

Enter decimal readings -2,-1,0,1,10 in A2:A6. In B2 enter =DEC2BIN(A2;10) and fill down. Expected strings are 1111111110,1111111111,0000000000,0000000001 and 0000001010. In C2 enter =BIN2DEC(B2) and fill down; the numerical values recover -2,-1,0,1,10.

Keep A as the numeric source and B as a text representation. Adding binary strings as if they were decimal numbers would not perform binary arithmetic. The explicit width also documents that the negative values use the same ten-bit representation as the positive values.

Advanced interpretation and checks

Check the signed boundary. The ten-bit pattern 1000000000 represents -512 under this function pair, not positive 512. DEC2BIN(512) is rejected even though 512 has an unsigned ten-bit spelling. If the external device uses unsigned ten-bit values, its contract differs from this converter’s.

Explain a negative value. For -2, add 1024 to get the unsigned pattern value 1022, whose ten digits are 1111111110. BIN2DEC subtracts 1024 when it sees a ten-digit pattern beginning with 1. The two rules form a round trip for all 1024 integers in the accepted signed range.

Use padding as presentation. DEC2BIN(10;8) yields 00001010, but DEC2BIN(10;3) fails rather than discarding the high digit. A small valid places value such as 1 does not shorten a negative output. The argument is still validated: places=0 is invalid even for a negative number.

Errors, limits and troubleshooting

Values outside -512..511 and requested widths outside 1..10 follow the illegal-argument path. A positive output that needs more digits than places also fails. These errors are source-derived expectations, not newly observed error-message captures. Do not silently wrap an out-of-range input modulo 1024 unless that transformation is separately required and validated.

The places converter casts an ordinary finite numeric width to an integer toward zero; for example 4.9 requests four places. This does not establish the same conversion for the first argument, which has a different typed callback. Explicit integer widths and integer numbers avoid that distinction.

Store binary labels as text when exporting or pasting. A leading-zero string can lose its width if another application converts it to a decimal numeric cell. The visible characters alone do not record the original bit width or whether the protocol was signed. Empty references, text coercion, formula-array binding and file round trips were not freshly tested. The optional argument being omitted is also distinct from every possible blank-looking cell.

Documentation and verification

See the Apache OpenOffice DEC2BIN reference, 4.1.16 Analysis callbacks and signed bounds, signed text decoder, decimal encoder, and optional width conversion. Official source snapshots were retrieved October 13, 2026 and re-read for this guide; no fresh retrieval or native execution is implied. Original introduction and final functioning version remain unestablished, separate from the pinned 4.1.16 support. No screenshots, native workbooks or cross-product compatibility claims were created for these controls.