Converts a decimal number to hexadecimal.
DEC2HEX(number, numdigits)
returns a hexadecimal number as text, given the decimal number, which must be between -239 and 239-1 inclusive, and may be text or a number.
The output is a hexadecimal number with up to ten digits in two's complement representation.numdigits is an optional number specifying the number of digits to return.
DEC2HEX(30)
returns 1E as text.
DEC2HEX("30")
returns 1E as text. DEC2HEX will accept a decimal number given as text.
DEC2HEX(30, 4)
returns 001E as text. Leading zeroes are added to make 4 digits.
DEC2HEX(-2)
returns FFFFFFFFFE as text.
Converting RGB Color Codes
In web design, colors are often represented using hexadecimal codes, where each pair of characters (from 00 to FF) corresponds to the intensity of red, green, and blue (RGB). The decimal values for red, green, and blue can range from 0 to 255. To get the correct hexadecimal color code, you need to convert each decimal value to its hexadecimal equivalent and then concatenate them.
Let's say a web designer wants to find the hexadecimal code for a specific shade of purple, which has the following decimal RGB values:
Here’s how the DEC2HEX function would be used in an Excel spreadsheet to perform this conversion.
Scenario: A web designer is creating a color palette and has a list of decimal RGB values that need to be converted to hexadecimal codes.
Decimal Value | DEC2HEX Formula | Hexadecimal Value | ||
|---|---|---|---|---|
A | B | C | ||
1 | Red: 128 | DEC2HEX(128, 2) | 80 | |
2 | Green: 0 | DEC2HEX(0, 2) | 00 | |
3 | Blue: 128 | DEC2HEX(128, 2) | 80 |
Explanation of the Formula:
Result:
By converting each decimal value and then concatenating the results, the web designer gets the final hexadecimal color code: #800080. This code can now be used in CSS or HTML to apply the correct shade of purple to a web page element.
PRODUCT & FEATURES
RESOURCES
Terms | Privacy | Spam Policy
© 2026 Zapof