A computer has an alphabet of two characters. Today you find out why that isn't a limitation.
You skimmed this one back in 0.2. Re-read it — it lands differently now that you've encoded a picture by hand. Enrolled in our Runestone course? Open it from there so your progress counts.
First lesson of Bits. Unit 0 told you that everything becomes 0s and 1s. That was the claim. Unit 1 is where you prove it — starting with the question you should have asked in 0.2 and probably didn't: how do you count past 1?
Send them a number. Any number. Now send them a bigger one. What's the minimum you need in order to say anything at all? Most people's first instinct is that two symbols isn't enough for anything interesting. Most people are wrong, and by the end of this page you'll be counting to 31 on one hand.
Two symbols is not a poverty problem. It's a length problem. One flash of the flashlight can only say two things — but two flashes in a row can say four, and three can say eight. You don't get more meaning by inventing more symbols. You get it by using more positions.
Watch three positions do it:
| Pattern | Means | Pattern | Means |
|---|---|---|---|
| 000 | 0 | 100 | 4 |
| 001 | 1 | 101 | 5 |
| 010 | 2 | 110 | 6 |
| 011 | 3 | 111 | 7 |
Eight patterns from three positions. Add a fourth position and you don't get one more pattern — you get double, because every old pattern can now be preceded by a 0 or a 1. That doubling is the whole engine.
Now, which pattern means which number? You already know the rule — you've used it since first grade, just with a different number. In decimal, the columns are worth 1, 10, 100, 1000: each column is ten times the one to its right, because you have ten symbols. Binary has two symbols, so each column is twice the one to its right: 1, 2, 4, 8, 16, 32…
To read a binary number, add up the column values wherever there's a 1. So
10011 is 16 + 2 + 1 = 19. That's it. That's the entire
conversion, and you'll drill it properly in 1.2.
One last piece of vocabulary, and it's the one people quietly get wrong for years. Bits are almost never handled one at a time. They're grouped into eights, and a group of eight bits is a byte. Eight bits means 28 = 256 patterns — enough for every letter, digit, and punctuation mark on a keyboard with room to spare, which is exactly why the grouping stuck.
You saw a byte in 0.2 without being told: 01001000 is the letter H, and it's
eight bits because that's one byte.
Hold up one hand, palm toward you. Your thumb is 1, index finger is 2, middle is 4, ring is 8, pinky is 16. A finger up is a 1; a finger down is a 0.
Now count out loud from 0, raising and lowering fingers as you go. 1 is the thumb. 2 is index alone — drop the thumb. 3 is thumb and index. 4 is middle alone. That drop-and-carry moment is the same thing that happens when 9 rolls over to 10 in decimal.
Keep going until you hit all five fingers up. Write down what number that is before you check it below. Then answer this: with a second hand, how high could you count?
Do the fingers first — that's the part that sticks. Then use this to check yourself. Click a column to flip its bit.
Python will show you the same patterns, and you'll write this yourself in 1.10. For now just read it:
# How many patterns do n bits give you? print(2 ** 3) → 8 # the table above print(2 ** 5) → 32 # one hand: 0 through 31 print(2 ** 8) → 256 # one byte # Show a number in binary: print(bin(19)) → '0b10011' # the 0b just means "binary"
Notice 2 ** 5 is 32 but the highest you can count to is 31. Thirty-two
patterns, and one of them is spent on zero. That off-by-one is the single most
common mistake on this topic, and it comes back with a vengeance in 1.3.
You just used all three of these. Now they get names.
Five questions in AP format. Pick an answer to see feedback immediately.
Reducing everything to two symbols did something nobody designed on purpose: it made perfect copies free.
Photocopy a photograph and you get a worse photograph. Dub a cassette and you get a hissier cassette. Every analog copy is a little further from the original, because you're copying a physical thing and physical things smear. But copying a file means copying a list of 0s and 1s, and a 1 copied is just… a 1. There is no "slightly blurry" version of the number 1. Copy number ten thousand is bit-for-bit identical to the original.
That one property is why the music industry was restructured between 1999 and 2003, why software can be sold to a million people without manufacturing a million of anything, and why a photo you regret sending cannot be recalled — not because someone is being cruel, but because there is no longer a meaningful difference between the original and the copy.