Three ways to convert
- To decimal: positional expansion — multiply each digit by the base raised to its position and add. FF₍16₎ = 15×16 + 15 = 255.
- From decimal: repeated division — divide by the base, read the remainders bottom-up. 255 ÷ 16 = 15 r F, 15 ÷ 16 = 0 r F → FF.
- Binary ↔ octal / hex: group bits by 3 (octal) or 4 (hex) and replace each group. 1111 1111 → FF.
Notes
- Integers of any length are converted exactly.
- Prefixes are accepted: 0x hex, 0b binary, 0o octal; spaces and underscores are ignored.
- Negative numbers: prefix with "-". Fractions are not supported yet.
Common values 0–255
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 2 | 2 |
| 3 | 11 | 3 | 3 |
| 4 | 100 | 4 | 4 |
| 5 | 101 | 5 | 5 |
| 6 | 110 | 6 | 6 |
| 7 | 111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
| 16 | 1 0000 | 20 | 10 |
| 32 | 10 0000 | 40 | 20 |
| 64 | 100 0000 | 100 | 40 |
| 100 | 110 0100 | 144 | 64 |
| 127 | 111 1111 | 177 | 7F |
| 128 | 1000 0000 | 200 | 80 |
| 255 | 1111 1111 | 377 | FF |
| 256 | 1 0000 0000 | 400 | 100 |
| 1000 | 11 1110 1000 | 1750 | 3E8 |
| 1024 | 100 0000 0000 | 2000 | 400 |
| 4096 | 1 0000 0000 0000 | 10000 | 1000 |
| 65535 | 1111 1111 1111 1111 | 177777 | FFFF |