Formualizer Docs

DEC2HEX

Converts a decimal integer to hexadecimal text.

Optionally pads the result with leading zeros using places.

The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.

Syntax

=DEC2HEX(number, [places])

Arguments

ArgumentTypeRequiredDefault
numbernumberRequired—
placesnumberOptional—

Return type

Can return text.

Remarks

  • number is coerced to an integer and must be in [-2^39, 2^39 - 1].
  • Negative values are returned as 10-digit two's-complement hexadecimal strings.
  • places must be at least the output width and at most 10, or #NUM! is returned.

Examples

Convert a decimal integer using the shortest output.

Formula =DEC2HEX(30)

Expected result 1E

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Request eight characters to see the leading-zero padding.

Formula =DEC2HEX(30,8)

Expected result 0000001E

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Convert a negative value to its signed representation.

Formula =DEC2HEX(-1)

Expected result FFFFFFFFFF

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

A nonzero value cannot fit in a zero-place output.

Formula =DEC2HEX(30,0)

Expected result #NUM!

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Convert decimal to hex

Formula =DEC2HEX(255)

Expected result FF

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Pad hexadecimal output

Formula =DEC2HEX(31,4)

Expected result 001F

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

FAQ

How are negative values formatted by DEC2HEX?

Negative outputs use 10-digit two's-complement hexadecimal representation.

Implementation

Engine source

On this page