OCT2HEX Function (OpenOffice Calc)
Encode signed octal values as uppercase hexadecimal in Apache OpenOffice, with forty-bit sign extension and precise width rules.
Verification status: Eight reference formulas and 7 diagnostic cases were recalculated in Apache OpenOffice 4.1.16 on Linux x86-64, Build 9816, using XLSX import and GUI hard recalculation. Saved formula identities and typed results were checked. How formula examples are checked
Quick answer: =OCT2HEX("377") returned FF in the tested Apache OpenOffice 4.1.16 build.
Availability and version history
- Introduced: First release not established; documented by OpenOffice.org 3.3.
- Supported in: Apache OpenOffice 4.1.16; this identifies a verified release, not a final supported version.
- Scope: Desktop Calc with its Analysis add-in, English function names and semicolon-separated formulas.
- Checked: October 14, 2026. Eight reference formulas and the listed diagnostics were recalculated after XLSX import in 4.1.16 on Linux x86-64, Build 9816. Source and independent reference calculations were also checked.
What OCT2HEX returns
OCT2HEX decodes a signed octal code and returns uppercase hexadecimal text. Ten octal digits use a thirty-bit source convention; negative outputs are sign-extended into ten hexadecimal digits, a forty-bit representation. Release entry.
Syntax and arguments
=OCT2HEX(OctalNumber [; Places])
The octal input has at most ten digits 0–7. Exactly ten digits beginning with 4–7 are negative. Optional Places pads a nonnegative output and must convert to an integer from 1 through 10. Negative outputs use all ten hex digits even when a valid smaller width is supplied.
Reproducible examples
The native column records the saved 4.1.16 results. Text-returning conversion strings are retained exactly, including leading zeroes and uppercase hexadecimal letters. OCT2DEC, IMREAL and IMAGINARY return numeric values. These integer and quarter-unit references agree exactly with the saved results; errors are checked by display rather than interpreted from a numeric zero cache.
| Formula | Native 4.1.16 result | Independent reference |
|---|---|---|
=OCT2HEX("0") |
0 |
0 |
=OCT2HEX("1") |
1 |
1 |
=OCT2HEX("12") |
A |
A |
=OCT2HEX("377") |
FF |
FF |
=OCT2HEX("3777777777") |
1FFFFFFF |
1FFFFFFF |
=OCT2HEX("4000000000") |
FFE0000000 |
FFE0000000 |
=OCT2HEX("7777777777") |
FFFFFFFFFF |
FFFFFFFFFF |
=OCT2HEX("52") |
2A |
2A |
Practical worksheet
=OCT2HEX("52") returns 2A, representing decimal 42. =OCT2HEX("12";4) returns 000A. The uppercase letter is the hexadecimal digit for decimal 10, not an appended unit.
The positive code 3777777777 becomes 1FFFFFFF. The negative code 4000000000 becomes FFE0000000. The result retains the signed value while changing the representation width.
Advanced interpretation and checks
For a negative source value n, the output digits encode 2^40+n. Thus octal 7777777777, which is −1, becomes FFFFFFFFFF. Treating the source as an unsigned integer and merely regrouping bits would instead describe another value.
For nonnegative inputs, grouping source bits in threes and destination bits in fours provides an independent conversion check. Width padding adds leading zeroes after conversion, while sign extension fills the wider negative representation.
The observed Places=4.9 case documents conversion toward an integer width. Use an explicit integer in a data specification so a fractional formatting parameter cannot silently change the intended field size.
Boundaries and troubleshooting
A positive result longer than Places raises an error; it is not chopped to the requested width. Valid small widths do not shorten negative outputs, but Places=0 remains invalid. Illegal octal digit 8 is rejected, whereas an empty string decodes to zero. Preserve the text type when exporting hexadecimal codes.
These additional formulas were recalculated through the same import path. Error displays are retained as errors, even when an ODS numeric attribute stores zero.
| Formula | Observed result or error |
|---|---|
=OCT2HEX("12";4) |
000A |
=OCT2HEX("377";1) |
Err:502 |
=OCT2HEX("7777777777";1) |
FFFFFFFFFF |
=OCT2HEX("7777777777";0) |
Err:502 |
=OCT2HEX("8") |
Err:502 |
=OCT2HEX("") |
0 |
=OCT2HEX("12";4.9) |
000A |
Other spreadsheet implementations
The OCT2HEX guide for Gnumeric documents that product’s own syntax and tested behavior. A shared function name does not guarantee the same argument conversion, text parsing, branch or precision rules.
Official evidence and checking scope
- Function-specific release entry
- Conversion or strict complex parser
- Signed positional decoder
- Width conversion
The saved ODS retained every tested formula identity. A deliberately stale SUM cache changed from 999999 to 3, and an uncached SUM returned 7 after hard recalculation. Native evidence covers the eight reference formulas and listed diagnostics only. Other explanatory compositions are independent mathematical checks; other releases, locales and extreme-value behavior were not established by this run.