Practice free

DEC2HEX function

DEC2HEX converts a decimal number to its hexadecimal equivalent and returns it as text, not a number. It turns up in IT, networking and low-level data work.

Example

Read it as a sentence: turn the decimal number 255 into hexadecimal, which gives FF.

Practice this in the app

Syntax

DEC2HEX(number, [places])

Arguments in [square brackets] are optional.

number (required)
The whole decimal number to convert (negatives allowed within the 10-digit range).
places (optional)
Minimum number of characters in the result; pads with leading zeros.

Returns: The hexadecimal equivalent.

What Excel actually returns

Each formula below was run in desktop Excel. The result is exactly what the cell showed, errors included.

FormulaExcel showsCase
=DEC2HEX(13) D Typical
=DEC2HEX(-13) FFFFFFFFF3 Negative (two's complement)
=DEC2HEX(0) 0 Zero
=DEC2HEX({1,2}) 1 Spill
=DEC2HEX(13.9) D Decimal 13.9 truncates
=DEC2HEX("13") D Text number
=DEC2HEX("abc") #VALUE! Invalid digit
=DEC2HEX(1E+15) #NUM! Too long input

Watch out for

  • Input is limited to 10 characters.
  • Result is text, not a number.

Where it works

Excel
DEC2HEX is in every version of Excel from 2007 on.
Google Sheets
Same name, same behaviour for everyday use.

Part of Engineering functions. Every result on this page was measured in desktop Excel, build 16.0.20527. Last updated .