Counting to 31 on one hand
Tonight's idea
When you write 347, you really mean \(3 \times 100 + 4 \times 10 + 7 \times 1\). Each place is worth ten times the one to its right. That is base 10, and the ten is a choice, not a law.
In base 2 (binary) each place is worth twice the one to its right: 1, 2, 4, 8, 16, 32, and so on. The only digits you need are 0 and 1, because as soon as you would write a 2 you carry instead. So the binary number 1101 means \(1 \times 8 + 1 \times 4 + 0 \times 2 + 1 \times 1 = 13\).
Now the finger trick. Hold up your right hand, palm toward you. Each finger is worth a place value, and a finger up means 1, down means 0:
thumb 1 · index 2 · middle 4 · ring 8 · little 16
Thumb up alone is 1. Index alone is 2. Thumb and index is 3. Keep going and you reach 31 with all five up.
Computers use binary because a wire is either carrying current or it isn't: two states, two digits.
Watch one: turn 22 into binary, and 10110 back
22 to binary. Go through the place values, biggest first, asking "does it fit in what is left?" 16 fits (6 left). 8 does not. 4 fits (2 left). 2 fits (0 left). 1 does not. Write 1 for yes and 0 for no, under the place values:
| 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|
| 1 | 0 | 1 | 1 | 0 |
So 22 is 10110. 10110 back to base 10: same table, read the other way. Add the place values that have a 1 under them: \(16 + 4 + 2 = 22\).
Your turn
Tonight's core: the example and exercises 1 to 3. The rest can wait for another visit.
- Write these in binary: 5, 10, 19, 37.
- Write these in base 10: 1011, 11111, 1100100.
- Add in binary: \(1011 + 110\). Line the numbers up on the right, like ordinary addition, and when a column reaches 2 write 0 and carry 1. Check your answer by converting everything to base 10.
- A bit is one binary digit. What is the biggest number you can write with 8 bits? What about with both hands, 10 fingers? (Hint: it is one less than a power of 2. Why?)
- How many bits do you need to write the number 1000? And 1,000,000? (You don't need the exact binary, just the number of digits.)
- In binary, how can you tell at a glance whether a number is even? Whether it is a multiple of 4? Explain why.
Stretch: the mind-reading cards
Make five cards. Card A lists every number from 1 to 31 that has a 1 in the 1s place of its binary form. Card B lists every number with a 1 in the 2s place, and so on for 4, 8 and 16. Write the place value in the top-left corner of each card.
Ask a friend to think of a number from 1 to 31 and hand you every card their number appears on. Add up the top-left corners of those cards. That is their number.
Why does it work? And here is the real question: if you wanted to read minds up to 63, how many cards would you need, and what goes on the new one?
Answers
- 5 = 101, 10 = 1010, 19 = 10011, 37 = 100101.
- 1011 = 11, 11111 = 31, 1100100 = 100.
- \(1011 + 110 = 10001\). Check: \(11 + 6 = 17\), and 10001 is \(16 + 1 = 17\).
- 8 bits: 11111111 = 255. 10 bits: 1023. Each is one less than a power of 2 (\(2^8 = 256\), \(2^{10} = 1024\)) because all-ones is the number just before the next place value switches on, like 999 is just before 1000.
- 1000 needs 10 bits (\(2^9 = 512 \le 1000 < 1024 = 2^{10}\)). 1,000,000 needs 20 bits (\(2^{19} = 524{,}288\) and \(2^{20} = 1{,}048{,}576\)).
- Even numbers end in 0, because every place except the 1s place is even. Multiples of 4 end in 00, because every place except the 1s and 2s places is a multiple of 4.
Stretch. The cards:
| Card | Numbers |
|---|---|
| 1 | 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31 |
| 2 | 2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31 |
| 4 | 4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 23, 28, 29, 30, 31 |
| 8 | 8, 9, 10, 11, 12, 13, 14, 15, 24, 25, 26, 27, 28, 29, 30, 31 |
| 16 | 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 |
It works because handing you a card says "my number has a 1 in this place". The cards together spell out the binary form, and adding the place values converts it back. For 1 to 63 you need a sixth card headed 32, listing 32 through 63, and every other card gets 16 more numbers (its old list plus 32).