Decimal to Hexadecimal: How to Convert, with Examples
Updated November 7, 2026
To convert decimal to hexadecimal, divide by 16 again and again, write down each remainder, then read the remainders from last to first. Remainders from 10 to 15 become the letters A to F. So 255 becomes FF, and 2026 becomes 7EA.
Convert decimal to hexWhat hexadecimal is
Everyday numbers are decimal, or base 10, which uses ten digits from 0 to 9. Hexadecimal is base 16, so it needs sixteen digits. It uses 0 to 9, then the letters A to F for the values 10 to 15.
In decimal, each place is worth ten times the one to its right: ones, tens, hundreds. In hex, each place is worth sixteen times as much: 1, 16, 256, 4096.
| Decimal | Hex | 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 |
| 10 | A | 1010 |
| 11 | B | 1011 |
| 12 | C | 1100 |
| 13 | D | 1101 |
| 14 | E | 1110 |
| 15 | F | 1111 |
How to convert decimal to hex
The method works for any whole number.
- 1Divide the number by 16.
- 2Write down the remainder, using A to F for 10 to 15.
- 3Divide the whole-number answer by 16 again.
- 4Keep going until the answer is 0.
- 5Read the remainders from last to first.
Worked example: 2026
Reading the remainders from the bottom up gives 7, E and A, so 2026 in hex is 7EA.
| Division | Answer | Remainder | Hex digit |
|---|---|---|---|
| 2026 ÷ 16 | 126 | 10 | A |
| 126 ÷ 16 | 7 | 14 | E |
| 7 ÷ 16 | 0 | 7 | 7 |
Worked example: 255
255 ÷ 16 is 15 with a remainder of 15, which gives F. Then 15 ÷ 16 is 0 with a remainder of 15, which gives another F. So 255 is FF, the largest value that fits in one byte.
How to convert hex back to decimal
Multiply each digit by its place value, then add the results. For 7EA, that's 7 × 256 = 1792, E (14) × 16 = 224, and A (10) × 1 = 10. Adding them gives 2026, which matches the example above.
A smaller example: 2F is 2 × 16 + 15, which is 47. To skip the sums, use the hex to decimal converter.
Why programmers use hex
One hex digit stands for exactly four binary digits, so hex is a compact way to write binary. One byte is eight binary digits, which is always two hex digits. The binary number 0010 1111 splits into 0010 and 1111, which gives 2F.
You'll see hex in web colors, memory addresses and raw data. In the color #FF8800, each pair is one channel: FF is 255 red, 88 is 136 green and 00 is 0 blue.
Code often marks hex with 0x, as in 0xFF, so that it can't be mistaken for a decimal number.
Quick reference
These values come up often. For anything else, use the decimal to hex converter.
| Decimal | Hex |
|---|---|
| 10 | A |
| 16 | 10 |
| 100 | 64 |
| 255 | FF |
| 256 | 100 |
| 1000 | 3E8 |
| 4096 | 1000 |
| 65535 | FFFF |