Contact

HEX2BIN Function (OpenOffice Calc)

Engineering Intermediate OpenOffice Calc

Convert hexadecimal codes to signed binary in Apache OpenOffice, with strict output limits, case-insensitive digits and sign-extension examples.

Verification status: Eight reference formulas and 7 diagnostic cases were recalculated in Apache OpenOffice 4.1.16 on Linux x86-64, Build 9816, using XLSX import and GUI hard recalculation. Saved formula identities and typed results were checked. How formula examples are checked

Quick answer: =HEX2BIN("FF") returned 11111111 in the tested Apache OpenOffice 4.1.16 build.

Availability and version history

  • Introduced: First release not established; documented by OpenOffice.org 3.3.
  • Supported in: Apache OpenOffice 4.1.16; this identifies a verified release, not a final supported version.
  • Scope: Desktop Calc with its Analysis add-in, English function names and semicolon-separated formulas.
  • Checked: October 14, 2026. Eight reference formulas and the listed diagnostics were recalculated after XLSX import in 4.1.16 on Linux x86-64, Build 9816. Source and independent reference calculations were also checked.

What HEX2BIN returns

HEX2BIN reads up to ten hexadecimal digits using a signed forty-bit input convention, then returns a binary string in the much narrower signed ten-bit range. A syntactically valid hexadecimal input can therefore still be outside the output domain. Release entry.

Syntax and arguments

=HEX2BIN(HexNumber [; Places])

HexNumber accepts digits 0–9 and letters A–F in either case, without a sign or 0x prefix. Exactly ten hex digits with first digit 8–F represent a negative value. The decoded result must be from −512 through 511. Optional Places is an integer from 1 through 10 after conversion and pads nonnegative output.

Reproducible examples

The native column records the saved 4.1.16 results. Text-returning conversion strings are retained exactly, including leading zeroes and uppercase hexadecimal letters. OCT2DEC, IMREAL and IMAGINARY return numeric values. These integer and quarter-unit references agree exactly with the saved results; errors are checked by display rather than interpreted from a numeric zero cache.

Formula Native 4.1.16 result Independent reference
=HEX2BIN("0") 0 0
=HEX2BIN("1") 1 1
=HEX2BIN("A") 1010 1010
=HEX2BIN("FF") 11111111 11111111
=HEX2BIN("1FF") 111111111 111111111
=HEX2BIN("FFFFFFFFFF") 1111111111 1111111111
=HEX2BIN("FFFFFFFE00") 1000000000 1000000000
=HEX2BIN("2A") 101010 101010

Practical worksheet

=HEX2BIN("2A") returns 101010, representing decimal 42. =HEX2BIN("A";8) returns 00001010. The lower-case input ff is accepted as the same value as FF.

The maximum positive binary result comes from 1FF, which represents 511. 200 represents 512 and is rejected even though all of its characters are valid hexadecimal digits. Input parsing and output-range checking are separate steps.

Advanced interpretation and checks

Ten hex F digits represent −1 under the forty-bit source convention and convert to ten binary ones. The code FFFFFFFE00 represents −512 and converts to 1000000000. The sign is decoded before the result is narrowed to ten bits.

For nonnegative values that fit, each hex digit maps to four binary digits, after which unnecessary leading zeros can be omitted or deliberately restored with Places. For negative values, a raw digit grouping would keep forty bits and would not be the specified output format.

Keep hex codes as text so letters and leading zeroes survive import. A value’s appearance alone does not establish its intended sign width.

Boundaries and troubleshooting

The diagnostics test one value above 511 and one below −512. A too-small width raises an error for a positive result. Empty input is decoded as zero, while whitespace and illegal digits are rejected. Do not silently treat rejected source data as a valid zero code.

These additional formulas were recalculated through the same import path. Error displays are retained as errors, even when an ODS numeric attribute stores zero.

Formula Observed result or error
=HEX2BIN("A";8) 00001010
=HEX2BIN("1FF";8) Err:502
=HEX2BIN("200") Err:502
=HEX2BIN("FFFFFFFDFF") Err:502
=HEX2BIN("ff") 11111111
=HEX2BIN("") 0
=HEX2BIN(" G") Err:502

Other spreadsheet implementations

The HEX2BIN guide for Gnumeric documents that product’s own syntax and tested behavior. A shared function name does not guarantee the same argument conversion, text parsing, branch or precision rules.

Official evidence and checking scope

The saved ODS retained every tested formula identity. A deliberately stale SUM cache changed from 999999 to 3, and an uncached SUM returned 7 after hard recalculation. Native evidence covers the eight reference formulas and listed diagnostics only. Other explanatory compositions are independent mathematical checks; other releases, locales and extreme-value behavior were not established by this run.