DEC2HEX Function (OpenOffice Calc)
Learn the DEC2HEX function in Apache OpenOffice Calc: Converts a decimal number to a hexadecimal number.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Availability and version history
- Introduced: Documented by Apache OpenOffice 4.1.16; original introduction not established.
- Availability: Supported in Apache OpenOffice 4.1.16, verified against its function registry. This identifies a supported release, not a final working version.
- Scope: Desktop Calc, using the English function name. Availability in other spreadsheet applications is separate.
- Checked: 2026-10-14 — function reference; versioned support. Documentation/source check; not a new native test. Existing example-specific test claims below retain their stated scope.
DEC2HEX converts a decimal value to uppercase hexadecimal text, normally using a signed forty-bit representation. The pinned 4.1.16 source has off-by-one range guards, so its two extra accepted endpoints do not round-trip through HEX2DEC. Digits A through F represent values 10 through 15. Negative results use ten hexadecimal digits, while ordinary nonnegative results omit leading zeros unless places is supplied.
Syntax and arguments
=DEC2HEX(number; places)
=DEC2HEX(number)
Number is required. After the pinned shared converter applies approximate floor, the source accepts effective values from -549755813889 through 549755813888, inclusive. This is one value beyond each end of the conventional signed forty-bit interval. For reliable signed round trips, restrict integers to -549755813888 through 549755813887. Optional places is an integer width from 1 to 10. It pads positive output with zeros but is not a request to round or retain decimal places. This callback receives a double, so its explicit floor rule matters for negative fractions. The examples use English names and semicolon separators.
Reproducible reference cases
| Formula | Reference result |
|---|---|
=DEC2HEX(255) |
"FF" |
=DEC2HEX(255;4) |
"00FF" |
=DEC2HEX(0) |
"0" |
=DEC2HEX(4095) |
"FFF" |
=DEC2HEX(-1) |
"FFFFFFFFFF" |
=DEC2HEX(-549755813888) |
"8000000000" |
=DEC2HEX(549755813887) |
"7FFFFFFFFF" |
=DEC2HEX(-1.2) |
"FFFFFFFFFE" |
=DEC2HEX(15.9) |
"F" |
=DEC2HEX(255;1) |
ERROR |
=DEC2HEX(549755813888) |
"8000000000" |
=DEC2HEX(-549755813889) |
"7FFFFFFFFF" |
=DEC2HEX(549755813889) |
ERROR |
=DEC2HEX(-549755813890) |
ERROR |
The first formula preserves the original example and expected result. Its historical comparable LibreOffice 25.2 check was not an OpenOffice native test. New results are independently checked mathematical/source expectations. Quotation marks identify returned text; ERROR denotes the source’s invalid-argument path without claiming an observed localized worksheet message.
Practical worksheet: create two-character byte labels
Enter decimal byte values 0,10,15,16,255 in A2:A6. In B2 enter =DEC2HEX(A2;2) and fill down. Expected strings are 00,0A,0F,10 and FF. In C2 enter =HEX2DEC(B2) and fill down; the original five integers are recovered. Keep the validation rule 0<=value<=255 separate from DEC2HEX’s much larger signed domain.
A negative input would return a ten-digit signed pattern rather than a two-character byte. A value of 256 needs three digits and cannot fit places=2. Width is therefore not a substitute for checking the permitted input range.
Advanced interpretation and checks
Inspect signed forty-bit values. FFFFFFFFFF is -1 under HEX2DEC’s ten-digit sign rule. Eight digits FFFFFFFF, by contrast, represent positive 4294967295, since the sign convention applies only at exactly ten characters. Within the conventional signed interval, the pair preserves numeric meaning rather than guessing the bit width used by another system. The extra accepted endpoints are exceptions described below.
Account for the source floor rule. DEC2HEX(-1.2) is modeled as floor(-1.2)=-2, giving FFFFFFFFFE in the inspected 4.1.16 helper. DEC2HEX(15.9) uses 15 and returns F. This is a source-specific expectation, not a fresh native observation or a promise of cross-product equivalence. Near-integer approximate-floor tolerance remains unverified; the exact boundary controls below are modeled directly from source.
Separate bytes from signed words. The text FF decodes to 255, not -1, because it has two characters. A signed eight-bit field needs its own interpretation rule: if its decoded byte is at least 128, subtract 256. That is an explicitly different external data convention, not an option on DEC2HEX.
Errors, limits and troubleshooting
The helper floors number before checking its constants. SCA_MAX16 is 549755813888 and SCA_MIN16 is -SCA_MAX16-1, so the actual guards extend beyond the normal signed bounds. Positive 549755813888 produces 8000000000, which HEX2DEC interprets as -549755813888. Negative -549755813889 produces 7FFFFFFFFF, which HEX2DEC interprets as positive 549755813887. These two sign-changing round trips are implementation-discrepancy controls, not recommended inputs. Enforce the conventional signed interval explicitly when reversibility is required. Values below -549755813889 or above 549755813888 after flooring fail; the full unsigned hexadecimal interval is not accepted. For accepted negative integers, the output contains ten hexadecimal digits even when a smaller valid places is requested. Invalid places values such as 0 or 11 still fail.
Positive output longer than places is rejected rather than truncated. A width of 4.9 is converted toward zero to four in the optional-argument converter. Use integer widths to avoid accidental dependence on conversion rules. The function returns a string, so a later numeric format does not change its base or make it an arithmetic integer.
Use hexadecimal digit text without prefixes when decoding the result with HEX2DEC. Prefixing a label with 0x is suitable for some external displays but changes the accepted input to that spreadsheet converter. Imported text parsing, localized separators, blank cells and array behavior are not covered by these scalar controls. Retain the original decimal source and the protocol’s signedness and width alongside its display label.
Related functions
Documentation and verification
See the Apache OpenOffice DEC2HEX reference, 4.1.16 Analysis callbacks and signed bounds, signed text decoder, decimal encoder, and optional width conversion. Official source snapshots were retrieved October 13, 2026 and re-read for this guide; no fresh retrieval or native execution is implied. Original introduction and final functioning version remain unestablished, separate from the pinned 4.1.16 support. No screenshots, native workbooks or cross-product compatibility claims were created for these controls.