Contact

DEC2HEX Function (Gnumeric)

Engineering Intermediate Gnumeric

Learn the DEC2HEX function in Gnumeric: 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

DEC2HEX represents a decimal integer using hexadecimal digits 0–9 and A–F. Its text output is useful for codes and comparisons with hexadecimal data. An optional width pads nonnegative values with leading zeroes. Negative values use Gnumeric’s signed 40-bit conversion convention.

Syntax, range and width

=DEC2HEX(x[,places])

x is required. The inspected converter accepts integers from -549755813888 through 549755813887. Ordinary fractional numeric inputs are truncated toward zero before conversion; use deliberate integers when representing identifiers.

places is optional and requests a width from 1 through 10 digits. For a nonnegative input, the width must fit all significant digits. It cannot discard a leading digit to force a value into a smaller field. For a negative input, the function returns ten digits even when a smaller valid places value is supplied. Width validation still occurs, so do not interpret this as accepting arbitrary width arguments.

Retained example and padding

=DEC2HEX(255)

The expected text is FF because 255 = 15*16+15. =DEC2HEX(255,4) returns 00FF, with the leading zeroes included in the string rather than added only by formatting.

Put 15, 16 and 255 in A2:A4. Enter =DEC2HEX(A2,4) in B2 and fill down. Expected strings are 000F, 0010 and 00FF. Use =HEX2DEC(B2) in C2 and fill down for a decimal round-trip check, giving 15, 16 and 255.

Signed representation

=DEC2HEX(-1) returns FFFFFFFFFF, as does =DEC2HEX(-1,2). The ten-digit bit pattern represents 2^40-1 before the matching signed interpretation subtracts 2^40, producing -1.

This is not a string containing a minus sign and it is not a variable-width unsigned conversion. If another system expects an unsigned 64-bit field or a two-character signed byte, establish that system’s contract before using this output. The name alone does not guarantee representation compatibility.

Advanced use: a byte-sized field

For a byte code, validate that A2 is an integer from 0 through 255, then apply =DEC2HEX(A2,2). At A2=42, the result is 2A because 2*16+10=42. At A2=255 it is FF.

A larger integer may be accepted with a wider places setting but still violate the stated byte contract. Likewise, =DEC2HEX(15.9) gives F after truncation, but that is not evidence that fractional identifiers should be repaired silently. Separate validation from representation.

Errors and troubleshooting

=DEC2HEX(255,1) returns #NUM! because FF needs two digits. Out-of-range integers and invalid widths fail rather than extending the conversion to arbitrary precision. Booleans are not supported numeric identifiers in the inspected converter. Locale-dependent numeric text may follow a parsing path; the reproducible controls here use typed numbers.

If leading zeroes disappear after export, check the destination’s data type. An importer may reinterpret numeric-looking strings. Preserve the original decimal value and treat the hexadecimal column as text. These examples do not certify every locale, fractional width or extreme boundary.

Availability and verification

Version coverage: Gnumeric 1.12.57 has the scoped checks below. The 1.12.62 evidence is a documentation/source check dated October 14, 2026.

  • Introduced: Original introduction not established. The earliest demonstrated support in this guide is 1.12.57.
  • Availability: Supported in Gnumeric 1.12.62, based on the function-specific registration.
  • Scope: Desktop; the fn-eng function module must be included and enabled.
  • Checked: October 14, 2026. Documentation/source check; no new native test in Gnumeric 1.12.62.

The executable contract is also present in the official Gnumeric 1.12.57 fn-eng source. The saved source was originally retrieved on October 17, 2026 and re-inspected for this guide. The last functioning release is not established; support in a named version is not a retirement claim.

On October 17, 2026, Gnumeric ssconvert 1.12.57 recalculated a synthetic workbook in the C.UTF-8 locale. Scoped controls: =DEC2HEX(255) → FF; =DEC2HEX(255,4) → 00FF; =DEC2HEX(-1) → FFFFFFFFFF; =DEC2HEX(-1,2) → FFFFFFFFFF; =DEC2HEX(255,1) → #NUM!; =DEC2HEX(15.9) → F. These are native calculation-engine results, not GUI tests or screenshots. Other tutorial layouts and displayed outputs are independent expectations unless covered by these exact formulas. Input/output files, preserved formulas, raw values and hashes were retained. The XLSX importer logged an unused workbookProtection-element warning; changed-input controls and recorded results were checked.

Official references