Tuesday, April 8, 2014
Bits of Binary: How to count in binary
Description
For a written transcript, go to How to count in binary
Music under Creative Commons License By Attribution 3.0.
Intro/Exit: "Hot Swing" by Kevin MacLeod at http://incompetech.com
Incidental: "Feelin Good" and "Cold Funk" by Kevin MacLeod at http://incompetech.com
Transcript
If you recognize this as the number 31, you can skip this video. But if you want to know how to count to 1023 on just your fingers, we'll find out in this episode of the House of Hacks.
Hi Makers, Builders and Do-It-Yourselfers. Harley here.
In the last episode of Bits of Binary, I talked a bit about different binary systems in general and binary numbers in particular. You can click here if you're interested in this introduction.
In this episode, I'll start with the basics of decimal numbers that you may already know. I'll then relate that to alternate number systems in general and then binary numbers specifically. Finally I'll wrap up with how to count in binary.
When we were young, we learned to count on our fingers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.
A couple years later we learned there's actually a special value that's no quantity: 0. And and with this new knowledge we found that 10 really isn't a number in the same way as the other nine are. It's a combination of 1 and this new non-value value. We found that at the core, we have 0 through 9 as our ten digits, not 1 to 10.
While were were still reeling from this new information, we learned you can count the groups of 0 through 9 and keep track of that in the "ten's column." So, now we could have 10 through 19 and 20 through 29 all the way up to 90 through 99. And then we could add a "hundreds column" for 100 through 199 and so forth. Numbers could actually be arbitrarily large by just adding another column.
This was mind blowing!
There were numbers incomprehensibly large to our young minds like "million" and "billion" with all kinds of crazy numbers of columns.
Then as we grew and got more sophisticated, we learned about something called exponents. These columns we were so comfortable with could now be represented by 10 raised to number of the column. So the "ten's column" was 10^1 and the "hundred's column" was 10^2. The "unit's column" took advantage of a weird property of exponents that said "anything raised to the power of 0 is 1."
It was explained any number could be split into its constituent parts by taking the digit in each column and multiplying it by the power of 10 for that column and adding the results together for the other columns. We found the simple columns we learned early in our education were just shorthand for much more heady concepts.
For example, the number 123 could be written (1 x 10^2) + (2 x 10^1) + (3 x 10^0).
If you're anything like me, this is about where the educational system stopped. There was no direct talk about this "5" being an abstract symbol for an underlying value. They did talk about it in an oblique way when they talked about other cultures having other number systems such as Roman numerals I, V, X, L and C. But that was about it. It was simply given that "5" meant "*****" this many things.
This was the decimal number system and how those of us now middle aged in the United States probably learned it.
If you had your young mind blown when you learned the ten's column was 10 raised to 1 and the hundred's column was 10 raised to 2, here's another mind blowing revelation...
The column base, the 10 so far, doesn't have to be limited to the number 10. It can be any anything!!
For example, this base could be 16 where you'd have the familiar zero and 15 other symbols. In this base, this many objects "**** **** **** ****" would be written as 10. Even though it looks like ten, it isn't. It's sixteen. And if you add one more "*", it'd be written 11 meaning seventeen.
Or the base could be 8 where you'd have zero and 7 other symbols. In this case the quantity seventeen would be represented by the series of digits 21. But in decimal, it'd still be represented by 17 and in base 16 it'd still be 11.
When dealing with multiple number systems at the same time, typically we put a subscript after the number to indicate the base for that number. So in the example of seventeen items, the previous bases would be written as 11(16), 21(8) and 17(10). This helps reduce confusion. But typically only one system is used at a time, and the base is left off, since it's implied by the context.
As you're trying to get your brain around all this, let's talk specifically about today's topic: binary. Its base is 2 so all we have is zero and one other digit: 1. That's it. 0 and 1, 1 and 0. Easy!
Let's look again at the columns we learned about when we learned about exponents. Just like in decimal where column one was 10 to the 0 and column two was 10 to the 1 and column three was 10 to the 2 and so on, in binary column one is 2 to the 0 and column two is 2 to the 1 and column three is 2 to the 2. That means the value of these columns if we multiply them by 1, are 1, 10 and 100 for decimal. And for binary they are 1, 2, 4, 8 and so forth.
Going back to our earlier example, in decimal, for each column's power of ten, you can multiply it by a number from 0 to 9, because your base is 10.
Binary however is much easier. For each column's power of two, you can only multiply it by either 0 or 1, because that's all the digits we have.
So, let's see what happens when we count from 0 to 10. For comparison, let's see both decimal and binary side by side. 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
See this pattern...
If we use a finger to indicate one and apply this pattern to our fingers...
zero, one, two, three, eight, nine, ten.
By continuing this pattern, on one hand we can count to the number 31. This is 16. Plus 8. Plus 4. Plus 2. Plus 1. That totals 31. So, how high can you count using both hands?
Thanks for watching this episode of Bits of Binary. In the next episode, we're going to look at how to convert back and forth between binary and the more familiar decimal numbers.
And I've created a playlist over here that will be filled in as more episodes in this series are added.
If you liked this, let me know by hitting the "like" button.
If you are already a subscriber, "thank you!" but if you aren't, be sure to "subscribe" so you don't miss future videos.
I'd love to hear from you in the comments below if you have any thoughts or questions on this topic.
Until next time, go make something. It doesn't have to be perfect, just have fun!