How to convert decimal to hex
- Type your decimal numbers into Input, one per line.
- The hex value of each appears in the output, in capitals by default.
- Untick Uppercase hex if your code or style uses lowercase digits like ff.
Converting decimal to hex by hand
Divide by 16 and note the remainder, then divide the result by 16 again until you reach 0. Write remainders from 10 to 15 as A to F, then read them from the last one back to the first. For 48879:
| Division | Result | Remainder | Hex digit |
|---|---|---|---|
| 48879 ÷ 16 | 3054 | 15 | F |
| 3054 ÷ 16 | 190 | 14 | E |
| 190 ÷ 16 | 11 | 14 | E |
| 11 ÷ 16 | 0 | 11 | B |
Read from the bottom up, the digits spell BEEF. To check, multiply back: 11 × 4096 + 14 × 256 + 14 × 16 + 15 = 48879.
Common values in hex
| Decimal | Hex | Why it comes up |
|---|---|---|
| 15 | F | Largest single hex digit |
| 127 | 7F | Largest signed 8-bit number |
| 255 | FF | Largest value in one byte |
| 1024 | 400 | One kibibyte |
| 4096 | 1000 | 4 KiB, a common memory page size |
| 65535 | FFFF | Largest 16-bit value and highest TCP port |
| 2147483647 | 7FFFFFFF | Largest signed 32-bit number |
| 4294967295 | FFFFFFFF | Largest unsigned 32-bit number |
Each extra hex digit multiplies the range by 16, so two digits cover one byte, four cover 16 bits and eight cover 32 bits.