How to use DEC2HEX Function in Excel

The Excel Dec2Hex function converts a decimal number into a Hexadecimal (Base 16) number

Syntax: =DEC2HEX (number, [places])

The DEC2HEX function syntax has the following arguments:

  • Number    Required. The decimal integer you want to convert. If number is negative, places is ignored and DEC2HEX returns a 10-character (40-bit) hexadecimal number in which the most significant bit is the sign bit. The remaining 39 bits are magnitude bits. Negative numbers are represented using two’s-complement notation.
  • Places    Optional. The number of characters to use. If places is omitted, DEC2HEX uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros).

Example: Let’s look at some Excel DEC2HEX function examples and explore how to use the DEC2HEX function as a worksheet function in Microsoft Excel:

BIN2HEX Function 1 - How to use DEC2HEX Function in Excel

Syntax:  =DEC2HEX(A2)


DEC2HEX Function in Excel - How to use DEC2HEX Function in Excel

Based on the Excel spreadsheet above, the following DEC2HEX examples would return:

Syntax: =DEC2HEX(A3)
Result: 13F122DDAE

Syntax: =DEC2HEX(A4)
Result: 1F

Syntax: =DEC2HEX(A5)
Result: 1

Syntax: =DEC2HEX(A6)
Result: 0

Syntax: =DEC2HEX(A7)

Syntax: =DEC2HEX(A8)
Result: 1C

Syntax: =DEC2HEX(A9)

Syntax: =DEC2HEX(A10)
Result: 15FE1

Syntax: =DEC2HEX(A11,B11)
Result: 0000000010

Syntax: =DEC2HEX(A12,B12)
Result: 0064

Syntax: =DEC2HEX(A13,B13)
Result: #NUM!

Syntax: =DEC2HEX(A14,B14)
Result: 0019

Syntax: =DEC2HEX(A15,B15)
Result: 0000000E


  • If Number is < -549,755,813,888 or if Number is > 549,755,813,887, DEC2HEX returns the #NUM! error value.
  • If Number is non-numeric, DEC2HEX returns the #VALUE! error value.
  • If the result of DEC2HEX requires more than the number of specified Places characters, it returns the #NUM! error value.
    For example, DEC2HEX(64,1) returns the error value because the result (40) requires two characters.
  • If Places is not an integer, the value of Places is truncated.
  • If Places is non-numeric, DEC2HEX returns the #VALUE! error value.
  • If Places is negative, DEC2HEX returns the #NUM! error value.

Add a Comment

Your email address will not be published. Required fields are marked *