Decimal to hex
Convert decimal numbers to hex. Negatives can show as 8 to 64-bit patterns.
Result
Settings
Result
Settings
Result
Settings
Result
Recent
To convert decimal to hex, keep dividing by 16 and read the remainders from the last one back to the first. Enter a whole number like 255 or 48879 and the hex form is ready to copy, in upper or lower case, with or without 0x and leading zeros. No sign-up and no cost.
How to do it by hand
- Divide the number by 16 and note the whole quotient and the remainder.
- Write remainders 10 to 15 as the letters A to F.
- Divide the quotient by 16 again, and repeat until it reaches 0.
- Read the remainders from the last one to the first. That string is the hex value.
Worked examples
200
200 ÷ 16 = 12 r 8, 12 ÷ 16 = 0 r 12 (C)
C8
4660
4660 ÷ 16 = 291 r 4, 291 ÷ 16 = 18 r 3, 18 ÷ 16 = 1 r 2, 1 ÷ 16 = 0 r 1
1234
48879
48879 ÷ 16 = 3054 r 15 (F), 3054 ÷ 16 = 190 r 14 (E), 190 ÷ 16 = 11 r 14 (E), 11 ÷ 16 = 0 r 11 (B)
BEEF
Common mistakes
- Reading the remainders top to bottom. The first remainder you get is the last digit.
- Writing a remainder like 12 as two characters. Each remainder is one hex digit, so 12 is C.
- Expecting a plain minus sign inside programs. Code usually stores -16 as F0 in 8 bits or FFF0 in 16 bits.
Common decimal values in hex
| Decimal | Hex | Binary |
|---|---|---|
| 10 | A | 1010 |
| 15 | F | 1111 |
| 16 | 10 | 10000 |
| 32 | 20 | 100000 |
| 64 | 40 | 1000000 |
| 100 | 64 | 1100100 |
| 127 | 7F | 1111111 |
| 128 | 80 | 10000000 |
| 200 | C8 | 11001000 |
| 255 | FF | 11111111 |
| 256 | 100 | 100000000 |
| 1,000 | 3E8 | 1111101000 |
| 1,024 | 400 | 10000000000 |
| 4,095 | FFF | 111111111111 |
| 4,096 | 1000 | 1000000000000 |
| 65,535 | FFFF | 1111111111111111 |
| 65,536 | 10000 | 10000000000000000 |
Questions people ask
How do I get FF for 255 instead of ff?
Pick upper case in the options. Lower case is there as well if your code style needs it.
Why does -1 come out as FFFFFFFF?
That is -1 written as a 32-bit two's complement. Choose 8, 16 or 64 bits to see FF, FFFF or sixteen Fs.
Can I convert a number with a decimal point?
Yes, in the fraction mode. 0.5 becomes 0.8 in hex, and digits that never stop are shown with a repeat mark.