Bits: why computers count in ones and zeros
Everything inside a computer is a tiny switch that is on or off. See how ones and zeros can count, and try it with a live binary counter.
Here is a strange fact. Inside a computer there are no numbers, no letters, no pictures and no music. There are only tiny switches, and each one is either on or off. Everything else is built from that.
The switch
Think of a light switch. It has two settings: on and off. Nothing in between.
Inside a computer chip there are billions of microscopic electronic switches called transistors. Each one is on (electricity flows) or off (it does not). We write "on" as 1 and "off" as 0.
One of these 1-or-0 values is called a bit, short for binary digit.
Why only two?
It would be possible to build a machine with ten settings, like our digits 0 to 9. But it would be hard to make every setting reliable. Electricity is a bit messy: voltages wobble, and wires pick up noise.
A switch that is clearly on or clearly off is easy to tell apart, even with some wobble. So computers use two settings, and are very good at never mixing them up.
Counting with only two digits
If you only have 0 and 1, how can you count past 1? The same way we count past 9. When we run out of digits, we add a new column.
In everyday counting, each column is worth 10 times the one on its right: ones, tens, hundreds. In binary, each column is worth 2 times the one on its right: 1, 2, 4, 8, 16, and so on.
To read a binary number, add up the columns that have a 1:
| Binary | Working | Number |
|---|---|---|
| 101 | 4 + 0 + 1 | 5 |
| 110 | 4 + 2 + 0 | 6 |
| 1101 | 8 + 4 + 0 + 1 | 13 |
Try it
Here are eight switches. The number under each switch is what it is worth. Flip them and watch the total.
0All switches are off, so the number is 0.
Try these:
- Make 5. Which switches did you need?
- Make 255, the biggest number with 8 bits. What do you notice?
- Make 100. Is there more than one way? (No. Every number has exactly one binary form.)
Bits, bytes and storage
Eight bits make one byte. With 8 switches you can make 256 different patterns (from 0 to 255).
Every extra bit doubles the number of patterns you can make: 1 bit gives 2, 2 bits give 4, 3 bits give 8, and 10 bits give 1,024. That doubling is why computers can store such huge amounts with a modest number of switches.
We measure storage in bytes:
| Unit | About how many bytes | Roughly what fits |
|---|---|---|
| Kilobyte (KB) | a thousand | a short email |
| Megabyte (MB) | a million | a photo or a song |
| Gigabyte (GB) | a billion | a film |
| Terabyte (TB) | a thousand billion | thousands of films |
You have five fingers on a hand. Let each finger be a bit: up is 1, down is 0. The thumb is worth 1, the next finger is 2, then 4, 8, and 16. With one hand you can count from 0 to 31. With two hands, up to 1,023.
What is next?
If everything is bits, how does a computer store a letter, a photo or a song? That is the next lesson.
Words to know
- Bit
- A single 0 or 1. The smallest piece of information in a computer.
- Binary
- Counting with only two digits, 0 and 1.
- Byte
- A group of 8 bits.
- Transistor
- A tiny electronic switch. A chip has billions of them.
Check yourself
What number is the binary number 1010?
Show the answer
8 + 0 + 2 + 0 = 10.
Why do computers use only two settings, on and off?
Show the answer
Two settings are easy to tell apart reliably, even when the electricity wobbles a little.
How many different patterns can 3 bits make?
Show the answer
8, because each extra bit doubles the number: 2 × 2 × 2.
What is the biggest number you can make with 8 bits?
Show the answer
255, which is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1.