Number systems explained for beginners
A number system is a way of writing numbers using a fixed set of digits. The number of digits is called the base or radix.
| System | Base | Digits |
|---|---|---|
| Binary | 2 | 0, 1 |
| Octal | 8 | 0 to 7 |
| Decimal | 10 | 0 to 9 |
| Hexadecimal | 16 | 0 to 9, A to F |
Place value
Every digit is worth its value times a power of the base. In decimal, 345 means 3 x 100 + 4 x 10 + 5 x 1. In binary the places from the right are 1, 2, 4, 8, 16 and so on, so 1011 means 8 + 0 + 2 + 1 = 11.
Why computers use binary, octal and hex
Computers store everything as bits, which are 0 or 1. Long binary numbers are hard to read, so people group bits: 3 bits make one octal digit, and 4 bits make one hexadecimal digit. That is why hex and octal are short ways to write binary.
0 to 15 in all four systems
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 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 |
Next: binary to decimal, binary to hex and octal and binary.