How base conversion works
To convert to base b, divide by b repeatedly and read the remainders from last to first. To convert from base b, multiply each digit by b raised to its position.
0xFF = 15 × 16¹ + 15 × 16⁰ = 240 + 15 = 255
Quick reference
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 2 | 2 |
| 7 | 111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 32 | 100000 | 40 | 20 |
| 64 | 1000000 | 100 | 40 |
| 100 | 1100100 | 144 | 64 |
| 127 | 1111111 | 177 | 7F |
| 128 | 10000000 | 200 | 80 |
| 255 | 11111111 | 377 | FF |
| 256 | 100000000 | 400 | 100 |
| 1000 | 1111101000 | 1750 | 3E8 |
| 1024 | 10000000000 | 2000 | 400 |
| 4096 | 1000000000000 | 10000 | 1000 |
| 65535 | 1111111111111111 | 177777 | FFFF |
Prefixes 0x, 0b and 0o are accepted and ignored; underscores and spaces are allowed as digit separators.