
Convert decimal numbers to hexadecimal text in Excel. Useful for memory addresses, color values, and any workflow that needs compact base-16 output.
DEC2HEX converts a decimal number into hexadecimal text. If you start with a normal base-10 value and need a base-16 result like FF or 0400, this is the function to use.
It comes up a lot in technical work because hex is shorter and easier to read than long binary strings. It is also common in memory addresses, register values, and color codes, so DEC2HEX is a simple way to move between the numbers people usually type and the format systems often display.
Turns a base-10 number into base-16 text.
Returns text made of 0-9 and A-F.
=DEC2HEX(number, [places])
number is the decimal value to convert. places is optional and pads the result with leading zeros when you need a fixed width.
The result is hexadecimal text, not a numeric hex type. If you need a short display such as FF, you can use the formula with just the number. If you need a fixed-width result such as 00FF, add places.
number must be a whole number in Excel's supported range for this function. places is optional and only affects positive values. It is useful when the workbook needs a consistent text width for codes, addresses, or exported output. Negative values ignore places and return the signed 10-character format.
DEC2HEX is best when you already have a decimal number and want a hex string back:
| Function | What it does | Typical use | Result |
|---|---|---|---|
DEC2HEX |
Converts decimal to hexadecimal | Addresses, IDs, color channels | Hex text |
HEX2DEC |
Converts hexadecimal to decimal | Turn hex back into a number for math | Number |
DEC2BIN |
Converts decimal to binary | Bit patterns and flags | Binary text |
DEC2OCT |
Converts decimal to octal | Legacy or Unix-style workflows | Octal text |
The most common use is formatting. If a worksheet stores values as decimal but a report or system expects hex, DEC2HEX gives you that translation directly. A value like 1024 becomes 400, and if you want a fixed-width result you can ask for 0400 instead.
The places argument matters only for positive numbers. It pads the result with zeros on the left, which is useful for codes, addresses, and display formats where every value should have the same length. If the converted result is longer than the places value, Excel returns #NUM!.
Negative numbers work differently. Excel returns them as 10-character hexadecimal values and ignores the places argument. That behavior follows the signed format these engineering conversion functions use, so results like FFFFFFFFFF are expected for -1.
This is the standard decimal-to-hex conversion pattern. Excel returns FF, which is a common reference point because it shows the maximum value that fits in one unsigned byte. The example is simple, but it gives a clear sense of how DEC2HEX compresses a familiar decimal number into base-16 form.
=DEC2HEX(255) // Returns "FF"
Convert Decimal 255 to hexadecimal. Formula: =DEC2HEX(255).
Padding matters when the hex output has to match a field width used by addresses, codes, or exported text formats. The decimal value 1024 becomes 400 naturally, but with 4 places Excel returns 0400, preserving the same value in a format that aligns cleanly with other fixed-width results.
=DEC2HEX(1024, 4) // Returns "0400"
Convert 1024 to a 4-character padded hex string. Formula: =DEC2HEX(1024, 4).
Negative decimal values do not simply gain a minus sign in the hex output. Instead, Excel returns a signed 10-character engineering-format result. Here, -1 becomes FFFFFFFFFF, which is the representation you need to recognize when working with signed technical values.
=DEC2HEX(-1) // Returns "FFFFFFFFFF"
Convert -1 to 10-character hexadecimal (40-bit). Formula: =DEC2HEX(-1).
This example shows a practical formatting use outside low-level engineering data. An RGB channel is often stored as a two-character hex byte, so converting 165 to A5 makes the value ready for color-code style output without any extra text manipulation.
=DEC2HEX(165, 2) // Returns "A5"
Convert color component 165 to 2-digit hex. Formula: =DEC2HEX(165, 2).
HEX2DEC if you need to convert the result back into a number.Tell your friends about this post