Contact

HEX2BIN Function (LibreOffice Calc)

Engineering Intermediate LibreOffice Calc

Learn the HEX2BIN function in LibreOffice Calc: Converts a hexadecimal number to a binary number.

Verification status: Selected examples were executed in LibreOffice Calc 25.2.3.2. This does not establish that every formula and edge case was tested. How formula examples are checked

Quick answer

HEX2BIN converts hexadecimal text to binary text in LibreOffice Calc. For example, =HEX2BIN("6a";8) returns 01101010. The letter a represents 10 in base 16, so 6a = 6×16 + 10 = decimal 106. With eight output places, Calc adds one zero to the seven-bit binary value 1101010.

Syntax and arguments in LibreOffice Calc

=HEX2BIN(Number [; Places])

Number — Required. Hexadecimal text containing digits 0–9 and letters A–F (case-insensitive), up to 10 hex characters under the signed analysis-functions convention.

Places — Optional. Number of output positions when padding a positive binary result with leading zeros. Without it, the positive result has the minimum needed width.

Square brackets around ; Places signify optional syntax, not literal characters to type. English Calc uses a semicolon argument separator. This function is documented in LibreOffice 26.8 Help’s Analysis Add-in group, and its behavior below was natively observed in LibreOffice Calc 25.2.3.2. The official entry does not provide a reliable minimum-version label, so none is invented. See the official syntax.

Worksheet example: hex configuration bytes

Enter codes as text in F2:F5 and type the corresponding formulas in G2:G5. Unlike arbitrary-length hexadecimal decoders, HEX2BIN’s output range is limited to a signed ten-bit binary result.

On a narrow screen, scroll this table sideways to see every column.

Row F: hex text G: Calc formula Expected G: binary text
2 6A =HEX2BIN(F2;8) 01101010
3 A =HEX2BIN(F3;8) 00001010
4 3F =HEX2BIN(F4;8) 00111111
5 0 =HEX2BIN(F5;4) 0000

You can verify row 2 numerically with =BIN2DEC(HEX2BIN("6A")), which returns 106. The output is text, important for leading zeros in bit masks. As with the other base functions, type a hexadecimal input such as "0A" into a text-formatted cell if its leading zero carries meaning.

Advanced application: signed 10-bit masks and bounds

=HEX2BIN("1FF") returns 111111111, representing the maximum positive result, decimal 511. A positive code "200" equals decimal 512 and produced Err:502, rather than a wider binary result. Increasing Places only adds padding; it does not expand the permitted value range.

A full-width hexadecimal two’s-complement value such as "FFFFFFFFFF" encodes -1. =HEX2BIN("FFFFFFFFFF") returns 1111111111 (ten ones). The native test =HEX2BIN("FFFFFFFFFF";2) still returned ten ones, demonstrating that negative fixed-width values did not shorten when Places was smaller. Do not interpret these full-width signed values as ordinary unsigned hex integers.

For an audit step, =DEC2HEX(BIN2DEC(HEX2BIN("6A"))) returns 6A, performing a round trip through binary and decimal. This example is safe because the intermediate positive value is inside HEX2BIN’s supported range.

Troubleshooting and documented limits

On a narrow screen, scroll this table sideways to see every column.

Input/formula Native Calc 25.2.3.2 observation Explanation
=HEX2BIN("G") Err:502 G is not a hexadecimal digit.
=HEX2BIN("6A";4) Err:502 Seven binary digits are needed to encode decimal 106.
=HEX2BIN("200") Err:502 Positive decimal 512 exceeds the maximum 511.
=HEX2BIN("FFFFFFFFFFF") Err:502 Eleven hexadecimal characters exceed the documented input limit.
=HEX2BIN("FFFFFFFFFF";2) 1111111111 Negative signed result retains its fixed ten-character width.

If a valid code unexpectedly fails, check the source cell for prefixed 0x notation, trailing spaces, non-hex letters and a value above the supported range. For larger numbers, HEX2DEC can decode a wider signed hexadecimal value into decimal, but HEX2BIN itself is not an unlimited binary conversion tool.

Microsoft documents HEX2BIN(number, [places]) for supported Excel versions (see Microsoft’s HEX2BIN function page). The English Excel separator is usually a comma, compared with the semicolon in English Calc formulas. Microsoft lists #NUM! / #VALUE! issues where Calc’s tested invalid inputs displayed Err:502. This is a documentation comparison; Excel and Google Sheets were not executed, nor were exported formulas round-tripped between applications.

HEX2DEC · HEX2OCT · BIN2DEC · DEC2BIN

Official documentation and actual testing

  • LibreOffice 26.8 Help — HEX2BIN, checked 2026-10-11: named function, arguments, optional padding, two’s-complement input notation.
  • Microsoft Support — HEX2BIN, checked 2026-10-11: Excel’s compatible function and signed ten-bit result limitations (not native Excel testing).
  • Native execution: LibreOffice Calc 25.2.3.2 via UNO, including valid reference-cell conversions, a round trip, and named Err:502 cases. Full test results, actual ODS file and script are included in the associated batch. LibreOffice 26.8 itself was not executed, and Help-version labels must not be misread as native test versions.

How this guide was checked

Selected example formulas were run in LibreOffice Calc 25.2.3.2 on Linux on October 12, 2026. The official Help may cover a newer version. Tests of selected formulas do not certify every locale, interactive array operation or file round trip. View the example-check record.

Official HEX2BIN reference · Editorial standards