The big idea
Inside a computer there are billions of tiny switches. Each switch is either off or on. We write off as 0 and on as 1. A single 0 or 1 is called a bit (short for binary digit). Everything a computer stores — your photos, your music, this sentence — is really just long rows of bits.
Explained simply
You normally count in denary (base 10). Each column is worth ten times the one to its right: ones, tens, hundreds. Binary (base 2) works the same way, except each column is worth two times the one to its right.
For an 8-bit number the column values are:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|
A group of 8 bits is called a byte. To read a binary number, add up the column values that have a 1 under them. The smallest 8-bit number is 0 (all zeros) and the largest is 255 (all ones).
Long rows of 0s and 1s are hard for people to read, so programmers use hexadecimal (base 16). Hex uses the digits 0–9 and then the letters A–F for the values 10–15. The trick is that one hex digit always matches exactly four bits, which is called a nibble. So a byte is always just two hex digits.
Worked example
Convert 181 from denary to binary. Work from the biggest column down. Does 128 fit into 181? Yes, so write 1 and keep 53. Does 64 fit into 53? No, write 0. 32 fits, write 1 and keep 21. 16 fits, write 1 and keep 5. 8 does not fit (0). 4 fits (1), keep 1. 2 does not fit (0). 1 fits (1).