In this article, you will learn about the DEC2HEX function, its usage, syntax, and how to use it in your excel spreadsheet
DEC2HEX Function in Excel
The DEC2HEX function in Excel converts a decimal number to its hexadecimal values.
Similar to the DEC2BIN, the input numbers must contain only zeros and ones and it is restricted to only 10 characters, and if the value crosses the 10 character limit the function will return a “#NUM!” Error.
Syntax
=DEC2HEX (number, [places])
Arguments
- number – The decimal number you want to convert to hexadecimal.
- places – [optional] when left out or neglected, it uses the least number of characters required to represent the number, or else it combines the result with zeros up to the specified number of places.
How to use the DEC2HEX in excel worksheet?
Using this function in a Worksheet is simple; all you need to do is enter the function as a formula of the cell in the formula bar.
Take a look at the given example
Decimal number | Places | Hexadecimal Values |
100 | 4 | 0064 |
28 | – | 1C |
64 | 1 | #Num! |
The above numbers are the decimal version of some Hexadecimal numbers. To find out the Hexadecimal numbers, Enter the given decimal numbers in column A and the places argument in Column B, enter the following formula in column c
Formula: =DEC2HEX(A2,B2)
Here, A2 and B2 refers to the cell name or the cell address. Repeat the same to the other cells and you will get the Hexadecimal value of the decimal values.
In the Cell A4, you can find that the corresponding value is #NUM! error, that is due to the requirement of more character places than the prescribed limit of 1.