How to convert
- Repeated division: divide the decimal number by 16, note each remainder until the quotient is 0, then read the remainders bottom-up.
- Remainders 10–15 become A–F. Example: 255 ÷ 16 = 15 r 15 (F), 15 ÷ 16 = 0 r 15 (F), so 255 = FF.
Notes
- Integers of any length are converted exactly — no scientific notation.
- Prefixes are accepted: 0x for hex, 0b for binary, 0o for octal; spaces and underscores are ignored.
- Negative numbers: prefix with "-". Fractions are not supported yet.
Decimal to Hex table
| Decimal | Hex | Binary |
|---|---|---|
| 0 | 0 | 0 |
| 1 | 1 | 1 |
| 2 | 2 | 10 |
| 3 | 3 | 11 |
| 4 | 4 | 100 |
| 5 | 5 | 101 |
| 6 | 6 | 110 |
| 7 | 7 | 111 |
| 8 | 8 | 1000 |
| 9 | 9 | 1001 |
| 10 | A | 1010 |
| 11 | B | 1011 |
| 12 | C | 1100 |
| 13 | D | 1101 |
| 14 | E | 1110 |
| 15 | F | 1111 |
| 16 | 10 | 1 0000 |
| 32 | 20 | 10 0000 |
| 64 | 40 | 100 0000 |
| 100 | 64 | 110 0100 |
| 127 | 7F | 111 1111 |
| 128 | 80 | 1000 0000 |
| 255 | FF | 1111 1111 |
| 256 | 100 | 1 0000 0000 |
| 1000 | 3E8 | 11 1110 1000 |
| 1024 | 400 | 100 0000 0000 |
| 4096 | 1000 | 1 0000 0000 0000 |
| 65535 | FFFF | 1111 1111 1111 1111 |