top of page

How to Use the DEC2HEX Function

How to Use the DEC2HEX Function in Excel

The DEC2HEX function converts decimal numbers into hexadecimal numbers.



= DEC2HEX(number, [places])

number - The decimal number you wish to convert to a hexadecimal number

[places] - Optional, number of significant digits to pad the hexadecimal number


The DEC2HEX function is part of the "Engineering" group of functions within Excel.

This function takes in decimal numbers and converts them into hexadecimal

The hexadecimal number can be up to 10 characters, or bits, in length. If the length exceeds this, a #NUM error will be returned.

This means the largest number than can be represented is "1F74876E7FF" in hexadecimal or 99999999999 in decimal form.

When using the optional places argument, the places number will pad the returned binary number with zeros.

Hexadecimal represents numbers more compactly than decimal data.

What is a Decimal Number

A decimal number is a number expressed in the base-10 numeral system, also known as the decimal system, the most commonly used system worldwide.

Each digit is based on its position, or place value, which increases by a power of 10 as you move from right to left.

understanding how decimal numbers are calculated

In this example, the number 102 is calculated by multiplying the ones place, "2", by 1, then the tens place by "0", and finally the hundreds place by "1", and adding the results together.

What is a Hexadecimal Number

The hexadecimal number system uses base 16, and uses the standard 0-9 digits, but also includes the letters A-F to represent higher numbers.

Hexadecimal Number Table

This table shows the hexadecimal version of the standard decimal numbers that we are used to working with.

Because hexadecimals use a base 16, this means that the as the numbers of digits increase, their place value, increases by a power of 16. The first being 16^0 = 1, next being 16^1 = 16, 16^2 = 256, and so on.

If we look at it visually, it would look like this:

understanding how binary numbers are calculated

In this example, the hexadecimal number 2B3 is calculated by multiplying the first value , "3", by 1, the second value "B" which represents 11 by 16, and finally the third value "2" by 256, and then adding them all together to get 691.


How to Convert Decimal Number to Hexadecimal

Let's say we have table of decimal numbers, and need to convert them into hexadecimal.

excel convert decimal number to hexadecimal with formula

The formula to convert from decimal to hexadecimal would be:

= DEC2HEX(decimal_number)

If we plug this formula into the table, the formula returns the correct hexadecimal number.

convert decimal numbers to hexadecimal numbers in excel

Using the DEC2HEX function in the right column lets us easily convert multiple decimal numbers at once.

excel convert decimal string to hexadecimal

bottom of page