HEX2OCT in Apple Numbers: Hexadecimal to Octal with Width and Error Checks
Use Apple Numbers HEX2OCT to convert hexadecimal text to octal, control leading zeroes and avoid invalid digits and signed-notation mistakes.
Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in Apple Numbers. How formula examples are checked
Verification (13 October 2026): Official Apple documentation and independent exact-integer arithmetic were reviewed. No native Numbers application execution or export/screenshot test was performed.
Quick answer: what HEX2OCT does
Turn a hexadecimal value (base 16) into its octal representation (base 8), useful for comparing systems that publish identifiers or masks in different bases.
One-line example: =HEX2OCT("3F") → 77 (Apple-documented or independently checked expected display). Official Apple HEX2OCT function reference (checked 2026-10-13).
Exact Apple Numbers syntax and argument order
=HEX2OCT(hex-string, convert-length)
hex-string — required, string value: Apple’s allowed characters are digits 0–9 and letters A–F. Quote letter-containing literals, such as "F" or "3F", so Numbers does not interpret them as a name. Apple’s individual help—not another spreadsheet’s rules—is the authority for source syntax. HEX2OCT.
convert-length — optional, numeric minimum width: Accepts 1–16, inclusive; omitted means 1. Left zero-padding is applied if the octal result has fewer characters. Width 3, for example, makes octal 17 appear as 017. It does not limit the value to three digits. HEX2OCT.
Hex digits A–F represent 10–15. Hex 3F equals 3×16 + 15 = 63 decimal, which is octal 77. The source and result are different notations for the same integer.
Formula punctuation and locale: These examples follow Apple’s English function reference, with commas separating arguments. In localized Numbers editions, translated function identifiers and semicolons may apply. For example, Apple’s Portuguese-Brazil article calls BIN2OCT BINPARAOCT and shows semicolons; this is a locale display. Use the function browser in the target Numbers locale rather than mechanically swapping separators. Apple’s localized BIN2OCT help; Apple argument types (checked 2026-10-13).
Step-by-step worksheet: copy the inputs and formulas
- Create a new spreadsheet in Numbers and add a table called Conversions. This guide assumes no special add-ons, scripts or API access.
- Type the headers shown below into row 1. Set imported code columns to Text before entering strings such as
00101,F, or3F; otherwise a conversion may silently change the source representation. - Enter source examples and formulas in the indicated rows. Each formula references cells in the same table; direct formulas use ordinary
A2,B2,C2syntax. Other tables or sheets need table-qualified references described in Apple’s official cell-reference guide. - Read the last column as the expected output, not a native-test report. For padded output keep an output column that preserves the displayed leading zeroes; evaluate actual formatting in Numbers before exporting a production file.
| A: source text | B: formula entered in Numbers | Expected display | Evidence |
|---|---|---|---|
F |
=HEX2OCT(A2,3) |
017 |
Apple-documented padding example |
3F |
=HEX2OCT(A3) |
77 |
Apple-documented conversion |
10 |
=HEX2OCT(A4) |
20 |
Independent arithmetic: 16 decimal |
7B |
=HEX2OCT(A5) |
173 |
Independent arithmetic: 123 decimal |
A0 |
=HEX2OCT(A6) |
240 |
Independent arithmetic: 160 decimal |
FF |
=HEX2OCT(A7,4) |
0377 |
Independent arithmetic + output width |
Testing distinction: A mathematical base conversion explains the expected numerical value; it does not prove that a particular Apple Numbers locale treats every source cell as text, preserves padding in an export or accepts values beyond documented limits. Apple’s argument types (checked 2026-10-13).
Formula examples explained, including the arithmetic
Example 1. =HEX2OCT("F",3) → 017. Hex F represents 15 decimal, or octal 17; width three adds a zero.
Example 2. =HEX2OCT("3F") → 77. Hex 3F = 63 decimal, octal 77.
Example 3. =HEX2OCT("FF",4) → 0377. FF = 255 decimal = octal 377, padded to four positions.
Advanced uses and independent cross-checks
Read an old hexadecimal mask in an octal-based system
The hexadecimal mask 7B encodes decimal 123: 7×16 + 11. Divide 123 by 8: 15 remainder 3, then 15 ÷ 8 gives 1 remainder 7. Reading the remainders backward gives octal 173. Use =HEX2OCT("7B") to express the same mask in the older scheme.
Produce a four-character octal export column
Keep the imported source code as text in column A. Enter =HEX2OCT(A2,4) in B2 and fill down. The formula’s leading zeroes are part of the expected representation, unlike changing the data with arithmetic. Note that wide values may exceed four characters; the width is a floor, not a cap.
Compare two routes to base 10
The same positive 3F may be checked using =HEX2DEC("3F"), whose documented expected output is 63, or generic =BASETONUM("3F",16), also 63. Converting decimal 63 to octal should yield 77. These cross-checks are independently reasoned or documented, not a native application test.
Edge cases, errors and troubleshooting
| Input or symptom | Why it fails or surprises | Corrective action |
|---|---|---|
=HEX2OCT("G2") |
G is not among the documented hexadecimal digits. | Use only 0–9 and A–F. |
=HEX2OCT("-F",8) |
Apple explicitly rejects a minus sign. | Do not prepend a sign to hexadecimal input. |
=HEX2OCT("F",0) |
Output width must be at least one. | Omit the second argument or use a valid width. |
=HEX2OCT("F",17) |
Documented width maximum is 16. | Choose 1–16. |
Unexpected output 17 instead of 017 |
Width omitted or too small. | Use =HEX2OCT("F",3) to specify three positions. |
Error-code limitation: Apple’s function article documents some inputs as “returns an error” without prescribing a stable literal error label. The table above intentionally says error rather than inventing a specific #VALUE!, #NUM! or implementation-specific diagnostic. If your locale reports something different, inspect Apple’s formula-error guidance and verify the source data type (checked 2026-10-13).
Negative numbers, bounds and implementation limitations
Apple says this function uses two’s-complement notation and that negative values produce 11-digit octal representations, while =HEX2OCT("-F",8) is explicitly an error. Do not assume a hex bit pattern’s sign from a standalone short string without the documented boundary and native testing. Do not copy Excel’s negative-range or precision rules into an Apple Numbers tutorial.
Copying formulas across sheets
If the original sample cells are stored in Table 2 instead of the same table, a reference can be written using Apple’s documented form Table 2::A2. To refer to a different sheet, a qualified example is Sheet 2::Table 2::A2. Do not assume Excel-style Sheet!A2 notation works in Numbers; use the application’s reference picker and the Apple reference instructions.
HEX2OCT compared with related conversion functions
Use HEX2OCT for hex → octal, HEX2DEC for hex → decimal, HEX2BIN for hex → binary and OCT2HEX for the opposite direction. Generic BASETONUM converts a source expressed in an indicated base into decimal; NUMTOBASE converts decimal into a target base. The dedicated functions do not establish compatibility limits with third-party spreadsheet engines. HEX2OCT and BASETONUM.
Application, release and platform compatibility: what is established
This function is present in the current official Apple Formulas and Functions Help, documentation edition 15.4, in the Engineering category. The general help is used with Numbers and related Apple productivity applications. Documentation edition 15.4 is not evidence that the function was introduced in Numbers app version 15.4, nor proof it behaves identically in all older macOS/iOS/iPadOS/iCloud releases. Official help; Numbers for Mac release notes (reviewed 2026-10-13).
Apple’s documented English syntax and example results are the evidence for these claims. This guide does not establish parity with Microsoft Excel, Google Sheets, LibreOffice, or browser-based spreadsheet tools: those products have independent error codes, limits, coercion rules, localization and negative-number encodings. Their behavior is not used as Apple Numbers evidence.
Precision and display policy
Base conversion is exact arithmetic only while the input can be represented and parsed accurately. The official individual function documentation does not specify a universal maximum exact integer magnitude, rounding or overflow policy for all possible inputs, so this guide deliberately avoids such thresholds. Treat long codes or signed values as data requiring native app checks. A width parameter adds zeros for presentation; it does not increase information in the underlying number.
Quick questions
Does this formula need an extension, macro or paid service? No. It is documented by Apple as a built-in spreadsheet function. No external API is required for the examples here.
Can I use a cell reference instead of typing an argument? Yes; the reproducible worksheet uses A2 and, where relevant, B2/C2. Refer to Apple’s Numbers-specific table scope syntax when using another table or sheet.
Are the displayed results verified in the Apple Numbers app? No. Apple-published examples were documentation-checked, and positive-number examples were independently computed. Native execution and formatting/export screenshots were not performed.
Official sources, checked 2026-10-13 (UTC)
- Apple official reference — Exact syntax; hex character set; width 1–16/default 1; leading zeroes; two’s-complement note; three official examples.
- Apple official reference — Apple definitions of string and numeric arguments.
- Apple official reference — Table-scoped reference syntax.
- Apple formula-error troubleshooting — diagnosing invalid formulas and references.
- Numbers for Mac release documentation — release context only; not a function-specific introduction date. Method: Manual comparison of Apple’s official help with independent Python exact-integer base arithmetic for positive examples, on 2026-10-13 UTC. Zero native Numbers execution. Unresolved native-behavior questions are identified explicitly in this guide.