Basics of Computer Science · Lesson 2a
3 minutes to read · bring a pen for the last part
Last time: a computer follows instructions exactly. This time, a harder question.
Your photos, your messages, your music, every game you have ever played — all of it is stored as nothing but on and off.
How can that possibly be enough?
Inside a chip, information is voltage. On a typical 3.3 volt chip, anything below 0.8 V counts as 0 and anything above 2.0 V counts as 1. The gap in between is deliberately treated as meaningless.
That gap is the whole trick. Electrical noise makes the voltage wobble a little — but a wobble is not enough to push a clear 0 up past 2.0 V. So the value survives. If we tried to squeeze ten different levels into the same range, small wobbles would start changing the data.
Two states is the choice that is hardest to get wrong. Not the most elegant one — the most reliable one.
One switch gives 2 possibilities. Add a second switch and each of those splits in two, so 4. Add a third: 8.
| Bits | Patterns |
|---|---|
| 1 | 2 |
| 2 | 4 |
| 3 | 8 |
| 4 | 16 |
| 8 | 256 |
Eight bits — one byte — gives 28 = 256 different patterns.
One detail worth noticing now: 256 patterns, but if you count from zero the biggest number you can reach is 255. Zero uses one of them up. That is the real reason colour values on a screen stop at 255 rather than 256.
Adding one single bit doubles what you can store. So how many patterns do 32 bits give?
Do not look it up — guess first, then work it out. Most people's first guess is wildly too low.
You can count on your fingers in binary. Each finger is one bit: down = 0, up = 1.
Give your fingers these values, starting from the right: 1, 2, 4, 8, 16. Any number you make is just the total of the fingers that are up.
One hand reaches 31. See if you can show your age.
Bring to the lesson
Convert numbers between decimal and binary in both directions, and finally settle why a 1 TB drive shows up on a computer as "931 GB" — neither number is wrong.