Decimal to hex
Type a whole decimal number, also called denary or base 10, and get its hexadecimal value, with the division steps.
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 digit | Decimal | Binary |
|---|---|---|
0 | 0 | 0000 |
1 | 1 | 0001 |
2 | 2 | 0010 |
3 | 3 | 0011 |
4 | 4 | 0100 |
5 | 5 | 0101 |
6 | 6 | 0110 |
7 | 7 | 0111 |
8 | 8 | 1000 |
9 | 9 | 1001 |
A | 10 | 1010 |
B | 11 | 1011 |
C | 12 | 1100 |
D | 13 | 1101 |
E | 14 | 1110 |
F | 15 | 1111 |
Common values
| Decimal | Hex | Binary |
|---|---|---|
| 0 | 0 | 0 |
| 1 | 1 | 1 |
| 9 | 9 | 1001 |
| 10 | A | 1010 |
| 15 | F | 1111 |
| 16 | 10 | 10000 |
| 32 | 20 | 100000 |
| 64 | 40 | 1000000 |
| 100 | 64 | 1100100 |
| 127 | 7F | 1111111 |
| 128 | 80 | 10000000 |
| 192 | C0 | 11000000 |
| 200 | C8 | 11001000 |
| 255 | FF | 11111111 |
| 256 | 100 | 100000000 |
| 1,000 | 3E8 | 1111101000 |
| 4,095 | FFF | 111111111111 |
| 65,535 | FFFF | 1111111111111111 |
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 digits | Largest value | Decimal |
|---|---|---|
| 1 | F | 15 |
| 2 | FF | 255 |
| 3 | FFF | 4,095 |
| 4 | FFFF | 65,535 |
| 6 | FFFFFF | 16,777,215 |
| 8 | FFFFFFFF | 4,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