HEX2DEC in Excel: Decode Hex Fields and Signed Forty-Bit Values
Decode hexadecimal text in Excel, inspect individual byte fields and understand when a ten-character value represents a negative number.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: HEX2DEC(number) converts up to ten hexadecimal characters to a decimal value. Short codes such as FF decode as positive numbers; full ten-character values use a forty-bit two’s-complement sign convention.
Availability and version history
- Introduced: the first introduction version is not established by the reviewed official history.
- Availability: official help lists Excel for Microsoft 365, Excel for Microsoft 365 for Mac, Excel 2024, Excel 2024 for Mac, Excel 2021, Excel 2021 for Mac, Excel 2019, Excel 2016.
- Checked: October 14, 2026; official HEX2DEC reference. Documentation and independent models; no native Excel execution or wider platform certification.
Syntax and accepted notation
=HEX2DEC(number)
The argument is required. Hexadecimal uses digits 0–9 and letters A–F, with at most ten characters, or forty bits. Microsoft documents #NUM! for invalid hexadecimal input. This guide uses explicit quoted uppercase strings and does not assume support for prefixes, whitespace or locale-specific forms.
The sign convention is fixed-width. The official example HEX2DEC("A5") returns 165, showing that a short code beginning with a high-valued digit is still positive. At the full ten-character width, a set highest bit represents a negative value.
For such a negative input, subtract 2^40, or 1099511627776, from its unsigned positional value. Do not interpret the remaining characters as a positive magnitude with a minus sign attached.
Example 1: decode imported codes
Format A2:A7 as Text and enter these exact strings. In B2 use =HEX2DEC(A2) and fill through B7.
| A, hexadecimal text | Expected decimal |
|---|---|
| 0F | 15 |
| 1A | 26 |
| A0 | 160 |
| FF | 255 |
| 0100 | 256 |
| 18A0FF | 1614079 |
For 1A, compute 1×16+10=26. For 0100, the 1 occupies the 16^2 position, giving 256. The leading zero preserves field width but adds no value.
A useful independent control is =HEX2DEC("FF")-HEX2DEC("FE"), which returns 1. The adjacent hexadecimal representations are ordinary consecutive quantities despite containing letters.
Keep the original text beside the decoded value if the source system requires fixed-width identifiers. Converting 0F and F gives the same decimal 15, so the numeric result alone cannot recover the original width.
Example 2: compare short and full-width values
| Formula | Expected decimal |
|---|---|
=HEX2DEC("FF") |
255 |
=HEX2DEC("FFFFFFFF") |
4294967295 |
=HEX2DEC("7FFFFFFFFF") |
549755813887 |
=HEX2DEC("8000000000") |
-549755813888 |
=HEX2DEC("FFFFFFFFFF") |
-1 |
The eight-character all-F string is positive because the function’s negative format is forty bits, not thirty-two. A file that defines a signed thirty-two-bit field requires a separate interpretation; do not silently assume HEX2DEC applies that narrower sign convention.
The full-width all-F string has unsigned value 1099511627775. Subtracting 1099511627776 gives −1. This explains the negative result without treating F as a minus-sign character.
Advanced example: split and check a six-character field
Enter the six-character string 18A0FF in D2. This example defines three two-character channels. Use these formulas in E2:G2:
=HEX2DEC(LEFT(D2,2))
=HEX2DEC(MID(D2,3,2))
=HEX2DEC(RIGHT(D2,2))
The outputs are 24, 160 and 255. LEFT, MID and RIGHT locate the explicitly defined fields. The source must have exactly six characters; silently accepting a shorter or longer string would change the intended boundaries.
In H2 use =E2*65536+F2*256+G2. The result is 1614079, matching =HEX2DEC(D2). This confirms the positional layout for the example.
Reconstruct the representation with:
=DEC2HEX(E2,2)&DEC2HEX(F2,2)&DEC2HEX(G2,2)
The result is 18A0FF. The two-character widths preserve channel boundaries, including leading zeros for smaller values. DEC2HEX supplies the reverse conversion under its own documented range.
Errors, formatting and interpretation
=HEX2DEC("G1") is invalid because G is not a hexadecimal digit. A label such as #18A0FF includes a presentation prefix outside the pure representation used here; remove a known prefix deliberately rather than assuming automatic cleanup.
Large decimal results may display in scientific notation or be rounded visually by a narrow column. Change the numeric display and column width before deciding that the underlying conversion lost digits. The exact expected integers above are independently calculated, not screenshot-based native precision tests.
For an unsigned radix conversion with a different width policy, consider DECIMAL after checking its own contract. Text cleanup, case variants, prefix acceptance and mixed-error precedence remain untested in this guide.
References and verification
Expected outputs are independently calculated examples or documented rules, not captured native Excel results. Formulas use English function names and comma argument separators. Locale, rendering and boundary restrictions are stated where relevant.