It’s been a long time since I’ve done much math with my kids or blogged about math. We’ve been busy with other things. But recently my kids have been asking me about how computers work. I like to give in-depth answers to such questions, so we set out on a quest to understand how they work. I saw the following video of a marble binary adder some time ago (see also woodgears.ca).
My short-term goal is to get my kids to understand the ins and outs of how it works and perhaps build one ourselves. The long-term goal is to understand and build as many components of an actual computer as we can and understand how they fit together to make a real computer. What would be really cool would be to see how much of this we can do with marbles!
Today I mostly wanted to introduce binary representations of numbers and how binary arithmetic works. I started by asking my kids about numeral systems. I made sure that they understood that though, for instance, the ancient Romans used different numerals than us, they had the same numbers as we do.
Next we play-acted a scenario that I dictated to them. “You have crash-landed on an alien planet. You need to communicate home, but your microphone was broken in the crash. All that you can use to communicate is a numeric key pad. What’s worse, the only button that works on it is 1. Also, you can only hit the button up to three times before transmitting.” As I asked them for numbers they quickly invented “unary”:
One 1 Two 11 Three 111
I asked them for four, but of course they couldn’t do it without being able to hit the button more than three times.
“After cryo-sleeping through the night you awake and set to work trying to repair your keypad. Finally, you get the 0 to work. You can still only hit three buttons before transmitting. Now what numbers can you make?” Again they started with unary, but I insisted that they make more than one, two and three. Here is what they came up with:
Zero 101 One 000 Two 001 Three 011 Four 110 Five 111 Six 010 Seven 100
As far as I can tell they chose the representation of each number randomly!
“After another night’s cryo-sleep you manage to get the keypad to allow ten key punches before a transmit. But now I need you to be able to send me numbers up to one thousand.” This had them stumped for a while. I decided to help. I suggested that they needed some sort of pattern, since making random assignments would be confusing and take a long time. they were still having a hard time, so I suggested we look at addition. I had them explain the algorithm they use to add multi-digit numbers together. Then we started a chart and I convinced them to try to use addition to continue it. Here was our beginning:
Zero 0000000000 One 0000000001
We agreed that these seemed like reasonable choices. They pointed out that we could have represented one as 1000000000 with about as much justification as our choice above, but we agreed that 0000000001 fit with our normal conventions better. I suggested we try adding one to itself to get two:
1 0000000001 +0000000001 ---------- 000000001?
They decided that if we were going to have a process for adding similar to what they were used to in base-10 then there should be a 1 carried as shown above. The only question was what to make the ? be. There are only two choices. After experimenting with both we found that if two is represented by 11 this leads to unary again (which we knew was unacceptable for the required task). On the other hand two being represented by 10 leads to something nice. Once they had played with it for some time I told them that this numeral system had been invented by others already and that it is called binary.
Finally we were ready to watch the above video together. With the background of binary representations and binary addition, they were able to understand quite a bit of how the machine works. Next they need to understand each of the logic gates at work in the machine and how they fit together to actually make an adder, but all of that is for another day.
I am very much an outsider when it comes to computers. I’m just a math guy. I’m planning on looking at the book The Elements of Computing Systems to learn more about building a computer from the ground up. This is going to be a voyage of discovery for both me and my kids. Any suggestions from experts are welcome!