Engineering

DEC2HEX Formula

Converts a decimal (base 10) integer to its hexadecimal (base 16) representation as a text string. DEC2HEX is widely used for working with color codes (RGB), memory addresses, MAC addresses, and any context where hexadecimal notation is standard.

Syntax

DEC2HEX(number, [places])
ParameterDescription
number Parameter of the DEC2HEX function.
[places] (Optional.) Parameter of the DEC2HEX function.
Try DEC2HEX in Viztab — free, no signup

Examples

Convert to hex

Formula
=DEC2HEX(255)
'FF'. The decimal number 255 equals FF in hexadecimal (15*16 + 15).

Color code construction

Formula
=DEC2HEX(200, 2)&DEC2HEX(100, 2)&DEC2HEX(50, 2)
'C86432'. Builds an RGB hex color code from decimal R=200, G=100, B=50 values, each padded to 2 digits.

With leading zeros

Formula
=DEC2HEX(16, 4)
'0010'. Pads the hex result to 4 characters with leading zeros.

Common Errors

#NUM!

The number is outside the valid range (-549,755,813,888 to 549,755,813,887), or places is too small.

#VALUE!

The argument is non-numeric or places is invalid.

Tips

Useful for web colors

Build CSS hex colors: ="#"&DEC2HEX(R,2)&DEC2HEX(G,2)&DEC2HEX(B,2) converts RGB values to a web color like #FF6633.

Case is uppercase

DEC2HEX returns uppercase letters (A-F). If you need lowercase, wrap in LOWER(): =LOWER(DEC2HEX(255)) returns 'ff'.

10-character max (40-bit)

The output is up to 10 hex characters. For numbers larger than the supported range, you'll need a custom solution.

Try DEC2HEX in Viztab

Import your data and use DEC2HEX with 370+ other formulas. No signup required.

Open Viztab

Related Formulas