colorcodekit

Decimal to hex

Type a whole decimal number, also called denary or base 10, and get its hexadecimal value, with the division steps.

—

Working


Switch to hex to decimal

How decimal to hex works

Decimal is base 10 and hexadecimal is base 16. To convert a decimal number, divide it by 16, keep the remainder, then divide the quotient by 16 again, until the quotient is 0. Each remainder from 0 to 15 is one hex digit, where 10 to 15 are written A to F. The remainders read from last to first are the hex number.

For 500: 500 ÷ 16 = 31 remainder 4; 31 ÷ 16 = 1 remainder 15 (F); 1 ÷ 16 = 0 remainder 1. Reading from the last remainder gives 1F4.

Hex digits

Hex digitDecimalBinary
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
A101010
B111011
C121100
D131101
E141110
F151111

Common values

DecimalHexBinary
000
111
991001
10A1010
15F1111
161010000
3220100000
64401000000
100641100100
1277F1111111
1288010000000
192C011000000
200C811001000
255FF11111111
256100100000000
1,0003E81111101000
4,095FFF111111111111
65,535FFFF1111111111111111

How big can a hex number get?

Each extra hex digit multiplies the range by 16. Two digits cover 0 to 255, which is one color channel or one byte.

Hex digitsLargest valueDecimal
1F15
2FF255
3FFF4,095
4FFFF65,535
6FFFFFF16,777,215
8FFFFFFFF4,294,967,295

Hex numbers and hex colors

A hex color code such as #9CAF88 is three hex numbers side by side: red 9C = 156, green AF = 175 and blue 88 = 136. That is why each channel runs from 0 to 255, because FF is the largest two-digit hex number. If the hex number has exactly six digits, the converter also shows it read as a color. For color work, the hex to RGB and RGB to hex converters split a code into its three channels for you.

Things that trip people up

  • Hex 10 is sixteen, not ten. The digits run 0 to F before the number carries.
  • Letters are numbers. A is 10, B is 11, C is 12, D is 13, E is 14 and F is 15.
  • Prefixes are not part of the number. 0x1F4, #1F4 and 1F4 are the same value. This converter ignores the prefix.
  • Leading zeros change nothing. 00FF and FF are both 255. They matter only for fixed-width fields, such as a six-digit color code.

Related converters

Frequently asked questions

How do I convert decimal to hex?

Divide the number by 16 repeatedly, write down each remainder as a hex digit (10 to 15 are A to F), and read the remainders from last to first. 500 gives remainders 4, 15 and 1, so the hex value is 1F4.

What is 255 in hex?

FF. 255 ÷ 16 is 15 remainder 15, and 15 is F in hex.

What is denary?

Denary is another name for decimal, the base-10 system we count in. The two words mean the same thing.

Can I convert negative or fractional numbers?

This converter handles whole numbers from 0 up. Negative numbers need a fixed bit width and two's complement, and fractions have their own method, so they are not handled here.

Content updated