HEX2OCT in Excel: Convert Hex Fields to Signed Octal Safely
Convert hexadecimal text to octal in Excel, verify the narrower thirty-bit target interval and check padding and negative sign-width changes.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: HEX2OCT(number,[places]) converts hexadecimal notation to octal. Its eligible quantities must fit the signed thirty-bit output interval, even though the input representation uses a forty-bit 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 2021, Excel 2021 for Mac, Excel 2019, Excel 2019 for Mac, Excel 2016. This reference lists Excel 2019 for Mac but omits Excel 2024 for Mac; the omission is not filled from another function.
- Checked: October 14, 2026; official HEX2OCT reference. Documentation and independent models; no native Excel execution or wider platform certification.
Syntax and conversion range
=HEX2OCT(number,[places])
Microsoft permits up to ten hexadecimal input characters and states positive maximum 1FFFFFFF and negative minimum FFE0000000 for this conversion. They represent 536870911 and −536870912, respectively.
Places is optional. Omission uses the minimum nonnegative output width; a larger count adds leading zeros. A width too short for the result produces #NUM!. Fractional places is truncated, nonnumeric places produces #VALUE!, and negative places produces #NUM!. Invalid hexadecimal input produces #NUM!.
Negative quantities ignore places and return ten octal characters. The source does not separately settle zero places or every out-of-range/error-precedence combination. Its Mac availability list also differs from some neighboring converters, as preserved above.
Example 1: convert positive fields with a fixed width
Format A2:A6 as Text and enter these hex strings. In B2 enter =HEX2OCT(A2) and in C2 enter =HEX2OCT(A2,4), then fill down.
Only the first table column is input data. The Decimal check column is explanatory and is not pasted into B; put calculated outputs in the worksheet cells specified above.
| Hex | Decimal check | Minimum octal | Width 4 |
|---|---|---|---|
| A | 10 | 12 | 0012 |
| 2D | 45 | 55 | 0055 |
| 65 | 101 | 145 | 0145 |
| F0 | 240 | 360 | 0360 |
| 1A0 | 416 | 640 | 0640 |
For 1A0, the hex positional calculation is 1×256+10×16=416. Its octal representation is 6×64+4×8=416. Both give the same quantity through different place weights.
In D2 use =HEX2DEC(A2) and in E2 use =OCT2DEC(C2), filling down. The columns both return 10, 45, 101, 240 and 416. That is a direct check of the numeric meaning, not just a comparison of output strings.
Example 2: distinguish input format from target capacity
=HEX2OCT("1FFFFFFF") has expected output 3777777777, the positive thirty-bit endpoint. Hexadecimal 20000000 represents 536870912, one above that allowed positive quantity.
The latter is a valid hexadecimal representation for HEX2DEC, but it lies outside HEX2OCT’s documented interval. More places cannot expand the target format. Do not remove leading digits or apply an unverified wraparound rule to make it fit.
The negative endpoint FFE0000000 represents −536870912 under forty-bit two’s complement and converts to octal 4000000000. The two strings have different widths in bits but preserve the same signed value.
Advanced example: inspect several negative quantities
| Hexadecimal | Decimal meaning | Expected octal |
|---|---|---|
| FFFFFFFFFF | -1 | 7777777777 |
| FFFFFFFF00 | -256 | 7777777400 |
| FFE0000000 | -536870912 | 4000000000 |
The −256 conversion is also a documented Microsoft control. An independent calculation adds 2^30 to −256 and expresses that unsigned value in ten octal positions.
A valid places argument of 4 does not shorten these negative outputs. In contrast, the short hex input FF is positive 255 and converts to octal 377. The converter does not infer an eight-bit signed-byte convention from a short input.
Use OCT2DEC to inspect the signed octal quantity after conversion. A representation that begins with several 7s is not automatically malformed; it may be the correct negative thirty-bit encoding.
Advanced check: convert back with an intentional width
For the positive fixture, =OCT2HEX(C2,3) returns three-character hex fields 00A, 02D, 065, 0F0 and 1A0. The quantities match the originals, but some character strings gain leading zeros.
OCT2HEX cannot know the original source width. Keep A alongside converted fields if an exact import/export round-trip matters. A numeric equality check and a byte-for-byte text check answer different questions.
A useful arithmetic control is decimal 45+101=146, whose hex representation is 92 and octal representation is 222. Decode the two source fields before adding, then select the intended output converter. Ordinary decimal arithmetic on the visible digits is not base-aware.
Errors and remaining scope
=HEX2OCT("1A0",2) needs three octal characters and follows the documented insufficient-width #NUM! rule. Places 4.9 is truncated to 4 and yields 0640. G0 is invalid hexadecimal and follows the documented invalid-input error.
The examples do not certify prefixes, whitespace, lowercase variants or unspecified error precedence. Their expected outputs are independently checked positional and two’s-complement calculations, within the function’s documented input and target intervals.
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.