• Computer Science

Introduction: Number Systems

From the class:  The Binary Number System

Take a look at these numbers. They might look familiar if you've spent a lot of time around computers. And notice the pattern. There are all powers of 2. That's the main idea in the base 2 positional binary number system, which you'll be learning about in this class.

But to understand that, let's talk about how number systems work. There's a couple of really powerful ideas here from a very, very long time ago that we still use today. So I'm going to write the number 12 here. And we take for granted the fact that we can represent the quantity 12 by using these set of symbols here.

But this was actually an invention. And this kind of invention for writing quantities is called a number system. And I want to break that down a little bit for you so that you can understand the properties of this system that we use today. This is called the base 10 positional number system. And that invention actually comes all the way back from Babylon 4,000 years ago.

But let's take a step back and actually invent our own system first. And so let's say that we're cave people and it's thousands and thousands and thousands of years ago. And what we want to do is to come up with a way of representing this quantity 12. So what we might do is come up with a system that we'll just call it the tally system. So if you've ever played cards, you would know what this means.

And the tally system is quite simple. We could have a rock in our cave and we say every time we want to represent a quantity of one, we just put a tick mark on the rock. So the tick mark looks sort of just like the number one. And so if we want to represent the quantity 2, we just add another tick mark. And three and four and so on. And we'll go all the way up to 12. So 5, 6, 7, 8, 9, 10, 11, 12.

And in this number system, it's quite easy to remember. I only have to remember this one symbol. So this thing here is called a symbol. And this symbol can be anything we want. We could have made it a smiley face if we wanted to. It just represents something. It's our way of saying, when you see this picture, what it means is the quantity 1. And then in our system, we said just add up the symbols in your head and the total sum of the number of ones that you see is going to equal the number that we're trying to represent.

Now, let's make a couple of observations about this system that we just invented. One is that it takes up a lot of space. In fact, it takes up the same number of positions as the number that we're trying to represent. So what if we wanted to represent the number 3,520? Well, we would need a pretty big rock because we'd have to write a lot of tick marks.

The other issue here is that it's a little bit hard to count after a while, and it's pretty easy to make mistakes. The system would be a little better if we could somehow multiply by orders of magnitude. Like if I just was able to quickly pick out the fives, I could just say 5, 10, 15.

So let's make this system a little bit better by saying that 5 is going to be represented by four ticks. So 1, 2, 3, 4. And then a line through all of them. And when you see this, that means they number 5, or the quantity 5. So 3, 4, 5. So this is 10 plus 2 individual 1s. And this gives us our quantity of 12 as well.

So what I've just done here is I've added a new symbol. So this is a new symbol. Again, just a picture that means something. And this particular symbol means 5. So when our human brains see this picture here, we don't even have to think about it. We don't have to go and count these individual tick marks. We just immediately, we say, oh, this is 5. Great.

And then we add a another 5 and then we say, oh, we're back to our original symbol, so we need to add those together one by one. And we get our 12. So this is a little bit better. This is a two symbol system. But it still takes up a lot of space to represent the numbers. And if we wanted to multiply two numbers together or add them, it's still quite tricky. We have to do quite a bit of work in our head.

Now, another feature or attribute of this system that we came up with is that position doesn't matter. And what I mean by that is let's say we take these last two tick marks here and I decided I just want to move that to the beginning. This represents the same exact quantity, 12 is what we had before. And if I take this and I move it to the end, it doesn't matter. It's the same number as what we had before. So what we say is that the position, in this case, does not matter.

Now let's go back to the number system that we actually use today and I'm going to talk about what 12 actually means if you break it down into the system parts that it's comprised of. And this number system is just ingenious. And what's amazing about it is that it came so long ago, I mean, almost 4,000 years ago in Babylon. And they came up with this notion of position and saying that the position actually does matter.

And so what we need to do in a positional system, let me clear this up a little bit, is we say we need to come up with some set of symbols. And the symbols could represent quantities. In our system, we say that there's 10 symbols, one to represent each number below 10.

So we could say the symbol 0 to represent 0, the symbol 1 to represent 1, all the way up to 9. And notice that there's no 10. It just stops at 9. And so in a positional number system, what it says is that if you want to go up to the next number, you move one position to the left. So we go from right to left. And this next position is going to be an order of magnitude larger than the previous position.

So specifically in our system, that order of magnitude is 10. And so in this first position here, this is actually going to be this number, 2, multiplied by 10 to the 0th power. Now, anything to the 0th power is actually just 1. And so from grade school, you remember that this is often called the ones place. But for this class, you should think about it as 10 to the power of 0.

Now, if we move to the next spot, what we're doing is taking this order of magnitude, which is 10, and increasing it by a factor of 10. So we're going to say now that this is 10 to the first power. So multiplying by 10. And if we had another position here, we would say that that's another factor of 10. So 10 squared. So each position increases by a factor of 10.

So by the way, this number here, 10, there's a name for this number. It's called the base. So this is a base 10 system. That's the system that we use. And in base 10, what we're going to do, or in any base, is we're going to take the digit that's up on top and multiply it by what's down below. So in this case, we're going to say we'll work our way from left to right to make it a little simpler. So we say 1 times 10 to the power of 1 is equal to, well, 10.

And then we'll go to the next level and we're going to add that. So we'll say 1 or plus 2 times its order of magnitude, which is going to be 10 to the 0th power. And anything to the 0th power is 1 times 2 is 2. And then we'll sum those. So this number actually represents the component 10 plus the component 2, which is equal to 12.

One of the cool things about this system is that we only need these 10 symbols to represent an infinite number of quantities. I've cleaned this up a little bit. And let's try representing a larger number, breaking down a larger number. Let's just say we want to represent the quantity 135.

Well, the way we can break down this number, just like we did before, is keep in mind that each position is an order of magnitude. And since we're using a base 10 system, the first position is going to be the base, which is 10, to the power of 0. So we always start at the 0th power. We always start with 1. And then the next position is going to be the base to the next power, which is 1. And then the next position is going to be 10 or the base to the next power, which is 2.

So this position here is going to be the hundredths place. And this is going to be the tens place and this is going to be the ones place. And the way that we can think about what this number represents is we can start from the left and just kind of work our way to the right. And we'll say 1 times 10 squared, which is equal to 1 times 100, which is just equal to 100.

And then we add the next position. So this is going to be 3 now. So the symbol times or the quantity represented by the symbol 3 times 10 to the first power, which is going to be 3 times 10, which is 30.

And then you can get the hang of this, that the next one is going to be 5 times 10 to the 0th power. This is 2 in case it's a little hard to read. So this is 10 to the 0th power. And that's going to be 5 times 1, which is 5. And we take each of these individual numbers and we add them together to get to 135.

Another quick vocabulary word or another way to think about this is imagine that we had the 135 tick marks like our original system. Well, what we've done is we've encoded the quantity 135 by using these symbols in these positions. And so this is kind of a nice encoding system. We call it a base 10 positional system. And notice it only takes three spaces instead of 135 spaces for each one of our tick marks. So this is arguably a much, much better system than the one we invented.

Now you might be wondering, where did these symbols come from? The symbols 0 through 9. And turns out they actually came from India a long time ago, about 2,000 years ago. And so oftentimes this number system here is called the Hindu Arabic system. And that's because it started in India, the Hindu Arabic system.

And then the Persians in India picked it up and then eventually it made its way to the rest of the Arab world, and then from there across all of Europe. And one of the people that helped to do that was a guy you've probably heard of named Fibonacci. So this number system has been around for quite a while.

But it turns out that the idea of position, the idea of position in orders of magnitude, came all the way from one of the earliest civilizations in Babylon. Except they didn't use a base 10. They used a different base, one that you might recognize as how we tell time. The base is actually base 60.

So to convert this to base 60, let's start by getting rid of these tens, because we no longer want the base 10. We want to change this to base 60. And the subscript here doesn't apply either. So it's no longer base 10. And I'll replace the tens with 60. So 60 to the 0th power, 60 to the first power, and 60 to the second power. And then so that people know that we're representing 1, 3, 5 in base 60, I'll put a little subscript here.

Now, the way to do this math is the same way that we just did it previously in base 10. So we'll work our away from left to right, just for convenience. And I'll say 1 times 60 squared. And that sum is going to be 3,600.

And then add to that the next position, 3 times 60 to the first power. So 3 times 60, which is 180. And then finally, the last position we'll add is 5 times 60 to the 0th power, which is just 1. So this is going to be just 5. And then adding each of these components together, let's see, we get 5 plus 8, 7, and 3.

Now, you might recognize this. This is actually how we tell time even today. But it came from a very long time ago. So this is actually the hours column, the minutes column, and the seconds column. And what we've just done here is to say that this time, 1, 3, 5, represents 3,785 seconds. And so you can see that these symbols here could mean different things depending upon the base that we're in. And normally we're in base 10.

So we've taken a look at three different systems in this video. The first is one that we invented ourself, the tick mark system, which wasn't very efficient. And then we looked at the positional number system invented in Babylon. And we looked at two different bases. The first is base 10, which is how we write numbers normally. Then we looked at a base 60, which was actually the original base.

And in the rest of the class, we're going to look at two more bases. Base 2, also known as the binary system, and then base 16, which is known as the hexadecimal base or hex for short. So this is going to be hex and this is going to be binary. So hopefully you get a sense here of the mechanics, though, of how we're representing our numbers. So converting to base 2 or to 16 should be relatively straightforward.