OCT2HEX Function (LibreOffice Calc)
Learn the OCT2HEX function in LibreOffice Calc: Converts an octal number to a hexadecimal number.
Verification status: Selected examples were executed in LibreOffice Calc 25.2.3.2. This does not establish that every formula and edge case was tested. How formula examples are checked
Quick answer
OCT2HEX turns an octal code into hexadecimal text, making it useful when switching between base-8 diagnostic values and base-16 identifiers. =OCT2HEX("144";4) produces 0064: octal 144 is decimal 100, and decimal 100 is hexadecimal 64. Places=4 pads the two hexadecimal digits with two leading zeros.
Exact function syntax
=OCT2HEX(Number [; Places])
Number — Required. Text representing an octal number, digits 0–7, with up to 10 octal characters. A cell holding text works.
Places — Optional. Requested minimum character count for positive output; larger widths pad with leading zeros. The optional argument may be omitted.
The official Calc 26.8 Help lists this among Analysis Add-In functions and documents signed two’s-complement treatment. English-language Calc formulas use semicolons between arguments, unlike comma-separated examples in English Excel. Square brackets above indicate the optional argument and should not be typed. LibreOffice function reference.
Step-by-step conversion table
Enter the values into A2:A5 as text. Place =OCT2HEX(A2;4) in B2 and fill down. The four-character output is useful for aligning codes in a parts catalogue.
On a narrow screen, scroll this table sideways to see every column.
| Row | A: octal code | B: formula | Expected B: hex text |
|---|---|---|---|
| 2 | 144 |
=OCT2HEX(A2;4) |
0064 |
| 3 | 17 |
=OCT2HEX(A3;4) |
000F |
| 4 | 7 |
=OCT2HEX(A4;4) |
0007 |
| 5 | 0 |
=OCT2HEX(A5;4) |
0000 |
Without the optional width, =OCT2HEX("17") returns F, not 000F. Hexadecimal digits use 0–9 and A–F; the letter F stands for decimal 15. If the result must be exactly four characters for display, specify Places=4 and keep the cell as text.
Advanced use: verify a cross-base import
An audit formula is =HEX2DEC(OCT2HEX("144")); Calc returns 100. This is a useful round-trip numeric check, because the outer HEX2DEC converts the intermediate hex text into decimal. The original octal text and final hex text are different representations of the same value, so direct string equality is not the correct comparison.
For signed codes, =OCT2HEX("7777777777") returns FFFFFFFFFF in tested Calc 25.2.3.2. Those are ten F characters representing -1 in a 40-bit two’s-complement hexadecimal field. Giving this negative code Places=2 still returned FFFFFFFFFF during native testing. That output is not an ordinary unsigned conversion of the octal digits; when working with device registers, confirm the original sign convention before interpreting it.
Difference from OCT2BIN: OCT2HEX can output hexadecimal values for much larger positive signed 30-bit inputs than OCT2BIN’s limited 10-bit binary output. The width parameter pads positive text; it does not change the signed interpretation of Number.
Edge cases, Err:502 and common corrections
On a narrow screen, scroll this table sideways to see every column.
| Formula or situation | Calc 25.2.3.2 observation | Fix / interpretation |
|---|---|---|
=OCT2HEX("8") |
Err:502 |
Octal digits must be between 0 and 7. |
=OCT2HEX("123G") |
Err:502 |
The input is not an octal number. |
=OCT2HEX("144";1) |
Err:502 |
Decimal 100 is hex 64; the output needs at least 2 characters. |
=OCT2HEX("7777777777";2) |
FFFFFFFFFF |
Negative fixed-width output ignores the requested short Places. |
| Conversion looks wrong after import | Not a test assertion | Check whether the octal code was imported as text and whether zero padding was lost. |
In a regional Calc installation where the function list or separator looks different, insert OCT2HEX using Insert → Function and select the arguments in the formula editor. If a formula looks accepted but results differ, check that the input is octal—not decimal 144—and that text codes are clean.
Excel, other software and related guides
Microsoft provides the same OCT2HEX conversion concept in its official base-conversion reference. Excel’s documented formulas commonly use commas (=OCT2HEX("144",4)); Calc’s English syntax uses semicolons. We did not execute Excel or Google Sheets; workbook interchange, extensions, error presentation and locale names have not been independently tested.
Official sources and validation record
- LibreOffice 26.8 Help — OCT2HEX and analysis add-in functions, accessed 2026-10-11: function name, exact arguments and octal/signed code semantics.
- Microsoft Support — number-base conversion functions, accessed 2026-10-11: Excel’s corresponding conversion behavior; documentation comparison only.
- Native Calc execution: Valid conversion and stated error formulas were checked in LibreOffice 25.2.3.2 using an actual UNO-connected spreadsheet; the ODS and test JSON are included. Compatibility with Help 26.8 and other application versions is not a native-test result.
How this guide was checked
Selected example formulas were run in LibreOffice Calc 25.2.3.2 on Linux on October 12, 2026. The official Help may cover a newer version. Tests of selected formulas do not certify every locale, interactive array operation or file round trip. View the example-check record.