Related Function:

The DEC2HEX function converts a decimal number to hexadecimal number.

Syntax

=DEC2HEX(number,[places])

Note: Hexadecimal (base 16), decimal (base 10), octal (base 8), and binary (base 2) are the most commonly used numeral systems in engineering and computing. Therefore, Excel has provided functions to convert numeric values to and from each of these systems.

Arguments

Argument Description
number The decimal integer you want to convert

  If number is negative, places is ignored and DEC2HEX returns a 10-character (40-bit) hexadecimal number
  The most significant bit of number is the sign bit
  The remaining 39 bits are magnitude bits
  Negative numbers are represented using two’s-complement notation
[places] Optional. Defines 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)

Examples

  A B C
1 Formula Result Notes
2 =DEC2HEX(100,4) 0064 Converts decimal value 100 to hexadecimal with 4 characters, “padded” with two leading zeros
3 =DEC2HEX(28) 1C Converts decimal value 28 to hexadecimal
4 =DEC2HEX(16,10) 0000000010 Converts decimal value 16 to hexadecimal with 10 characters, “padded” with eight leading zeros
5 =DEC2HEX(-16) FFFFFFFFF0 Converts decimal value -16 to hexadecimal

Common Function Error(s)

Problem What went wrong
#VALUE! Occurs if either:

  the supplied number argument is not numeric
  the supplied [places] argument is not numeric
#NUM! Occurs if either:

  the supplied [places] argument ≤ 0
  the result of DEC2HEX requires more than the number of [places] characters specified
  the supplied number argument is < -549,755,813,888 or > 549,755,813,887
#NAME? Occurs when Analysis ToolPak add-in is not enabled