Wauvel

Excel like a finance pro.

← The library

Engineering function

DEC2HEX

Converts a decimal number to hexadecimal.

Rarely usedDifficulty 1200 · ProficientUsage rank #339 of 520
Practice · 2 questions →

When to use it

Converts a decimal number to hexadecimal text, optionally padded.

The shape of it

Syntax
=DEC2HEX(number, [places])

Worked examples

  • Simple

    =DEC2HEX(255) FF

    Two digits.

  • Padded

    =DEC2HEX(255,4) 00FF

    Padded to four.

  • Negative

    =DEC2HEX(-1) FFFFFFFFFF

    Negatives use 40-bit two's complement.

Worth knowing

  • Build a color code: DEC2HEX(r,2)&DEC2HEX(g,2)&DEC2HEX(b,2).
  • Range is -2^39 to 2^39-1.
  • The result is text.

Where it goes wrong

  • #NUM! outside the range or when places is too small.
  • Non-integers are truncated.

Related

Learn the moves here — or let Wauvel run them on your numbers.

Meet your AI CFO →

One CFO-grade Excel tip a week

A short, practical email for finance operators — functions, shortcuts, and the moves that save an afternoon. Free, unsubscribe anytime.