How to use the binary / hex / decimal converter
- Type a number in the box for the base you have.
- Read the conversions in the other boxes.
- For another base, such as base 36, set Custom base.
The four common bases
| Base | Name | Digits | Used for |
|---|---|---|---|
| 2 | Binary | 0 1 | How computers store everything |
| 8 | Octal | 0 to 7 | Unix file permissions (chmod 755) |
| 10 | Decimal | 0 to 9 | Everyday counting |
| 16 | Hexadecimal | 0 to 9, A to F | Colors (#FF8800), memory addresses, bytes |
Counting in each base
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 2 | 2 |
| 5 | 101 | 5 | 5 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 100 | 1100100 | 144 | 64 |
| 255 | 11111111 | 377 | FF |
| 1024 | 10000000000 | 2000 | 400 |
Converting by hand
Binary to decimal: each position is worth double the one to its right (1, 2, 4, 8, 16…). Add the values where there is a 1. 1011 = 8 + 0 + 2 + 1 = 11.
Decimal to binary: divide by 2 repeatedly and note the remainders, then read them from last to first. 11 → 5 r1 → 2 r1 → 1 r0 → 0 r1, which reads 1011.
Binary to hex: split the bits into groups of four from the right and convert each group. 1111 1111 = F F. This neat fit is why programrs prefer hex to decimal.
Prefixes such as 0x (hex), 0b (binary) and 0o (octal) are accepted and ignored, as are spaces and underscores.