HEX2DEC in Google Sheets: Case-Insensitive Hex and Signed Fields
Decode uppercase or lowercase hex in Google Sheets, preserve numeric-input semantics and inspect fixed-width fields with signed-boundary checks.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: HEX2DEC(signed_hexadecimal_number) interprets hexadecimal notation and returns a decimal quantity. Google explicitly accepts either letter case and defines a signed forty-bit two’s-complement format.
Availability and version history
- Introduced: first introduction date is not established by the reviewed official history; no desktop release number is inferred.
- Availability: documented in the rolling Google Sheets service; these examples use the web worksheet workflow.
- Checked: October 14, 2026; official HEX2DEC reference. Documentation and independent models, with no native Sheets execution or wider client certification.
Syntax, letter case and numeric inputs
=HEX2DEC(signed_hexadecimal_number)
The input is a signed hexadecimal string. Digits 0–9 and letters A–F are valid, with lowercase a–f equivalent. Other digits produce documented #NUM! errors.
Google identifies the positive endpoint as 7fffffffff and the negative endpoint as 8000000000. A valid numeric input is converted to the matching digit string: HEX2DEC(199) and HEX2DEC("199") both return 409, because 1×256+9×16+9=409.
That conversion does not mean the input quantity 199 stays 199. The function interprets its digits in base sixteen. Prefixes, extra whitespace, excessive widths and a complete error-precedence policy are not established by the short reference and remain unverified here.
Example 1: decode mixed-case imports
Set A2:A7 to Plain text and enter these strings. Put =HEX2DEC(A2) in B2 and fill down.
| Hexadecimal text | Expected decimal |
|---|---|
| f3 | 243 |
| F3 | 243 |
| 09 | 9 |
| 1f | 31 |
| 80 | 128 |
| 408009 | 4227081 |
The first two rows confirm Google’s documented case-insensitive rule. Hex f3 is 15×16+3=243. The leading zero in 09 preserves a two-character field but adds no numeric value.
A separate control using numeric 199 is useful because it contains only digits. Its expected decoded value is 409, whereas ordinary decimal arithmetic on 199 still uses the quantity 199. Keep encoded data and actual numeric measurements clearly labeled.
Example 2: distinguish short positive codes from signed full width
The signed convention uses forty bits, corresponding to ten hexadecimal positions. Independently computed controls are:
| Formula | Expected decimal |
|---|---|
=HEX2DEC("F0") |
240 |
=HEX2DEC("FFFFFFFF") |
4294967295 |
=HEX2DEC("7FFFFFFFFF") |
549755813887 |
=HEX2DEC("8000000000") |
-549755813888 |
=HEX2DEC("FFFFFFFFF0") |
-16 |
The eight-character all-F input stays positive in this forty-bit format. Do not silently interpret it as a signed thirty-two-bit integer just because another system uses that convention.
For a negative full-width value, subtract 2^40, or 1099511627776, from its unsigned positional value. FFFFFFFFF0 has unsigned value 1099511627760, giving −16. The first character is not a standalone minus sign followed by a positive magnitude.
Advanced example: inspect three two-character fields
Enter 408009 in D2 as Plain text. This example defines three two-character channels. In E2:G2 use:
=HEX2DEC(LEFT(D2,2))
=HEX2DEC(MID(D2,3,2))
=HEX2DEC(RIGHT(D2,2))
The expected values are 64, 128 and 9. Their independent packed total is =E2*65536+F2*256+G2, yielding 4227081, equal to =HEX2DEC(D2).
LEFT, MID and RIGHT extract the fields only because this example explicitly requires a six-character source. A missing leading zero would move those boundaries and must be treated as a data-format issue.
Reconstruct with =DEC2HEX(E2,2)&DEC2HEX(F2,2)&DEC2HEX(G2,2). The result is 408009. DEC2HEX supplies padding so the final 9 returns as 09.
Advanced example: arithmetic after decoding
A code 200 represents decimal 512. To add decimal 16, use:
=HEX2DEC("200")+16
=DEC2HEX(HEX2DEC("200")+16)
The first result is numeric 528; the second is representation 210. Adding 16 directly to digit string 200 as ordinary decimal arithmetic instead produces 216. Google’s DEC2HEX documentation specifically warns about this silent interpretation risk.
If the desired increment itself arrives as a hexadecimal string such as 10, decode both operands: =HEX2DEC("200")+HEX2DEC("10") also gives 528. State the base of every input instead of relying on how it happens to look.
Errors and display checks
=HEX2DEC("G2") contains an invalid hexadecimal letter and follows the documented #NUM! rule. A known prefix such as # in a display label must be handled deliberately; its acceptance is not assumed here.
Large decimal outputs can appear in scientific notation or with fewer displayed digits. Inspect the number format and column width before treating a rounded display as a changed quantity. Exact native large-number precision and malformed-input error precedence were not executed in this review.
References and verification
Examples use fictional data, English function names and comma separators. Expected outputs are independent mathematical calculations or explicitly documented rules, not native Sheets captures. Check the spreadsheet locale when reproducing punctuation-sensitive formulas.