HEX2DEC Function (LibreOffice Calc)
Convert hexadecimal text with LibreOffice HEX2DEC. Understand the ten-digit signed40-bit convention, compare shorter values and reject prefixes, invalid digits or excess length.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: HEX2DEC converts up to ten hexadecimal digits using a signed40-bit convention for full-width inputs. Shorter inputs do not use their first digit as an arbitrary-width sign bit.
Availability and version history
- Introduced: Documented by LibreOffice 26.8.1.1; original introduction not established.
- Availability: Supported in LibreOffice 26.8.1.1, 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.
The HEX2DEC function in LibreOffice Calc is used for this task: Converts a hexadecimal number to a decimal number. Convert a hexadecimal number into decimal.
This guide explains how to read the formula, reproduce a concrete example, interpret its result and recognize common input mistakes.
Syntax and arguments
HEX2DEC(number)
| Argument | Required? | Meaning |
|---|---|---|
Number |
Yes | The hexadecimal number to be converted (as text) |
Calc formulas normally use semicolons (;) between arguments in common configurations; the displayed separator may depend on settings or locale.
Worked example
=HEX2DEC("FF")
Expected result: 255.
Why it works: Convert a hexadecimal number into decimal.
How to use it in your own spreadsheet
- Identify the cells or inputs that correspond to the sample values above.
- Enter the formula in an empty cell, changing the references or literal values to match your sheet.
- Compare the output with a manual check on a small known example.
- Extend the formula to a larger dataset only after you understand the result.
Common problems and practical checks
- Check the accepted numeric domain, units and array dimensions for the specific operation.
- If an error appears, check that the function arguments are of the expected type.
- A pasted formula may produce an error when it uses the other program’s argument separator or unsupported options.
Additional worked application and edge cases
Accepted digits and signed width
The required input is a hexadecimal string with at most 10 characters. Use digits0–9 and lettersA–F, in either case. Quoted literals and references to cells containing text keep the intended representation explicit.
Ten hexadecimal digits represent40 bits. When a full ten-digit input has its highest bit set, HEX2DEC interprets it as a negative40-bit two’s-complement number. The resulting signed range is -549755813888 through549755813887.
Crucially, the inspected Calc source applies the negative interpretation only at the full ten-digit width. A shorter string beginning with F is not automatically negative.
Stepwise example: compare positive and negative codes
Put these strings in A2:A7 as text and enter =HEX2DEC(A2) in B2, copying down.
| Hexadecimal text | Independently expected decimal value |
|---|---|
| FF | 255 |
| 6a | 106 |
| 7FFFFFFFFF | 549755813887 |
| 8000000000 | -549755813888 |
| FFFFFFFFFF | -1 |
| FFFFFFFFFE | -2 |
The FF result preserves the original historical example. For the negative cases, convert the string as an unsigned40-bit integer and subtract2^40. For example, FFFFFFFFFF is2^40−1 unsigned, so its signed result is -1.
Second example: length changes the meaning
=HEX2DEC("FFFFFFFFF"), with nine F characters, is expected to return 68719476735, a positive number. Adding the tenth F changes the result to -1 under the function’s fixed signed convention.
Likewise, =HEX2DEC("00000000FF") has expected result255. Leading zeros preserve the positive value but count toward the ten-character limit. Trimming or padding imported strings without understanding the source width can therefore change their interpretation.
Advanced application: decode a signed40-bit export
Suppose a data source explicitly documents signed40-bit two’s-complement fields. Retain its ten-character text field and use HEX2DEC to obtain the signed value. Validate both the digit set and width before interpreting a negative result.
A signed32-bit field containing FFFFFFFF means -1 under a32-bit convention, but this eight-digit string is positive4294967295 under HEX2DEC’s convention. Do not mistake the spreadsheet’s result for proof that the exporting system used40 bits. The bit width is part of the input format, not something HEX2DEC discovers.
Invalid input and troubleshooting
The reviewed parser rejects nonhex characters, such as G, and strings longer than ten characters. It also rejects literal prefixes and punctuation such as 0xFF, #FF or -FF; supply the hexadecimal digits alone in the supported two’s-complement representation.
An empty string is mapped to0 by the inspected source, but that does not make an absent code a valid measured zero. Check missing values separately if the distinction matters. These parser findings are source-reviewed expectations, not new native error-display tests.
Keep hexadecimal values as text during import so automatic numeric/date conversion does not alter them. HEX2DEC returns a numeric decimal value and has no Places argument; padding options belong to other conversion functions. For wider or differently signed fields, use a method explicitly designed for that representation instead of dropping digits to fit the limit.
- Pinned Calc radix parser and sign handling, inspected October 17, 2026.
Verification scope for this addition: These added results were independently calculated or derived from the cited documentation/source. They were not newly tested in LibreOffice Calc. The original example-specific Calc 25.2.3.2 claims elsewhere on this page remain historical and apply only to those original examples. The cited 26.8.1.1 source tag is a code reference, not a claim of a new run in that release.
Related functions
Documentation and verification
- LibreOffice Calc Help
- The standalone example was calculated using LibreOffice Calc 25.2.3.2 on October 9, 2026 and its computed result matched the expected value. This does not certify every option, version, or other example.