HEX2OCT in Google Sheets: Convert Hex Fields and Verify Octal Limits
Convert signed hexadecimal text to octal in Google Sheets, audit target limits and avoid silent decimal arithmetic on octal-looking results.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: HEX2OCT(signed_hexadecimal_number,[significant_digits]) converts hexadecimal text to signed octal. Use explicit padding for positive output fields and check the quantity with a decoder before arithmetic.
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 HEX2OCT reference. Documentation and independent models, with no native Sheets execution or wider client certification.
Syntax and the narrower target interval
=HEX2OCT(signed_hexadecimal_number,[significant_digits])
The dedicated reference marks significant_digits as optional. It gives the admitted positive endpoint 1FFFFFFF and negative endpoint FFE0000000. Their decimal values are 536870911 and −536870912, matching a thirty-bit signed octal target.
The input notation is forty-bit signed hexadecimal, but that does not mean every valid forty-bit quantity fits this output. Positive hex 20000000 represents 536870912, just beyond the specified target interval.
Hex digits A–F are case-insensitive. A valid numeric digit input is converted to its string form: numeric 199 and text “199” both mean hexadecimal 199 and produce octal 631, representing decimal 409. They are not treated as decimal 199.
A supplied width pads a nonnegative result with leading zeros. Too few positions produces documented #NUM!. Negative signed inputs ignore the supplied width; unusual or fractional width rules are not supplied by this reference.
Example 1: convert a collection of positive fields
Format A2:A6 as Plain text and enter only the first column. In B2 enter =HEX2OCT(A2,4) and fill down. The decimal checks are explanatory rather than an additional pasted input column.
| A, hex text | B, octal field | Decimal check |
|---|---|---|
| 09 | 0011 | 9 |
| 2A | 0052 | 42 |
| 5C | 0134 | 92 |
| A5 | 0245 | 165 |
| 16A | 0552 | 362 |
For 16A, the decimal check is 1×256+6×16+10=362. Octal 552 gives the same quantity through 5×64+5×8+2.
In C2 use =HEX2DEC(A2) and in D2 use =OCT2DEC(B2), filling down. Both columns return 9, 42, 92, 165 and 362. Compare them with =C2=D2; all five results are TRUE.
Example 2: negative encodings and endpoints
| Formula | Expected octal |
|---|---|
=HEX2OCT("FFFFFFFFFB",4) |
7777777773 |
=HEX2OCT("FFFFFFFFD6",4) |
7777777726 |
=HEX2OCT("FFE0000000",4) |
4000000000 |
=HEX2OCT("1FFFFFFF",10) |
3777777777 |
The quantities are −5, −42, −536870912 and 536870911. The negative results follow the thirty-bit two’s-complement model in OCT2DEC. A short hex D6 instead represents positive 214, whose octal form is 326.
This difference is about the full signed representation, not simply the last two visible hexadecimal digits. Shortening a negative string before conversion can change its quantity.
The valid width of four is ignored for the negative controls. These examples do not settle how invalid widths interact with otherwise negative inputs, nor every native error code outside the stated interval.
Advanced example: calculate in decimal, then choose an output base
Take the second and third fixture records, hex 2A and 5C. Their quantities are 42 and 92, for a total of 134. To return a four-position octal total, use:
=DEC2OCT(HEX2DEC(A3)+HEX2DEC(A4),4)
Expected result: 0206. To display the same total in hex, use =DEC2HEX(HEX2DEC(A3)+HEX2DEC(A4),2), giving 86.
Adding the octal-looking labels 0052 and 0134 directly would produce decimal 186. That is not a valid octal representation because it contains an eight. Even when the wrong result contains only digits zero through seven, it still needs a quantity check.
Advanced example: reverse the conversion with a chosen width
In E2 use =OCT2HEX(B2,3) and fill through E6. Expected results are 009, 02A, 05C, 0A5 and 16A. They preserve each quantity while using a new three-character field width.
OCT2HEX cannot infer whether the original positive input used two, three or more characters. Preserve that formatting separately when doing a character-for-character export audit.
Lowercase =HEX2OCT("a5",4) has the same expected output 0245 as uppercase A5. For positive results, padding is a display-length requirement, not an increase in the allowed numeric range.
Errors and scope checks
=HEX2OCT("1G",4) contains an invalid hex character and follows Google’s documented #NUM! rule. =HEX2OCT("16A",2) requires three octal digits and also follows the documented too-small-width rule.
The source warns about ordinary arithmetic coercing numeric-looking octal labels to decimal. Use HEX2DEC or OCT2DEC for calculations, rather than relying on cell appearance. Fractional inputs, unpinned width behavior and native precision boundaries remain untested.
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.