Transcript
• Computer Science

# The Binary Base (Base 2)

From the class:  The Binary Number System

In a base 10 number system, like how we represent quantities today, we use 10 symbols. So it starts at 0, and we've got 1, 2, 3, all the way up to 9. So there's 10 of these symbols. And we use powers of 10 to multiply those quantities, depending upon where you are in the position of the number.

Well, there's another number system called base 2. And as you might have guessed, in a base 2 system, we only have two symbols instead of 10. So we can pick any two symbols we want. We could pick, for example, a smiley face as one and a frowny face as the other. But more commonly, we'll use 0 and 1. So just a 0 and 1. So it's quite a bit simpler to think about, because we only have these two symbols.

Now, this guy up here, his name is Gottfried Leibniz, is a German. And in 1679, he shows us, he writes a paper that i shows us the binary system as we think about it today, even though the concept of binary numbers actually goes back to ancient China. So what we're going to be looking at today originates with our friend Gottfried here.

Now, how does the binary number system work? Well, it works very similar to how a base 10 system works, except down here-- so I've drawn these white lines here, and these are going to represent our positions. And in position one, in the first position, that's going to be 2 to the power of 0, instead of 10 to the power of 0. And so this is still going to be called the ones place, and that's because 2 to the power of 0 is 1. Anything to the power of 0 is 1.

And then, in the next spot over, we're going to multiply by a multiple of 2 And that's going to give us the twos place. So this is going to be 2 to the power of 1, which is the twos place. And then, we'll multiply by 2 again to get 2 squared. And so that's going to be the fours place, and so on. So we just keep going indefinitely, using powers of 2 as we move from the right to the left.

Now, in these spots here, in these spaces, we can't use 0 through 9 anymore as our symbols. Instead, we can only use the symbols 0 or 1. And so if we put a 1, then we can take the 1 and multiply it by its magnitude. So in this case, 1 times 2 to the power of 0 is equal to 1.

And if we put a 0 in this position, or in any position, it just means that this position doesn't matter. So we just count it as a 0. In other words, in this case, it would be 0 times 2 to the 1, and 0 times anything is just a 0.

So we can put a 1 or a 0 in any one of these slots. And again, we just multiply it by the Factor-- or the multiple of 2. So in this case, 2 squared is 4 times 1 is 4. And just like we do in base 10, we add together the results of these to get our base 10 number.

So in this example, I've drawn 1 as 0, 1. And we could just put a zero in this spot here. And what this represents is-- let me draw the 2 to the third power. So this is 0 times 2 to the third power, which is just 0, plus 1 times 2 squared, which is 4 times 1, is 4; and then plus 0, and then finally, plus 1 times 2 to the 0th power, which is just 1. So this represents the number 5, or all of these numbers added up together.

Let me give you a little bit of terminology here. When we talk in base 10, each one of these positions is called a digit. And so in this example, we would say we've got four digits in this number. But in binary, we don't use the word digit. We use the word bit. And so each one of these spaces is called a bit. And a bit can be a 1 or a 0. And we use it to denote the idea of space.

So in this number, we have a 4-bit number, or at least we have a 4-bit set of spaces. So we could represent a set of numbers that fit in that space. If we get up to 8 bits, we call that a byte. So when you hear the word byte, you should be thinking eight of these slots, each of which can either be a 1 or 0. All right. We'll get to a couple more examples in a second.

But I want to talk about these two guys and why binary is interesting for computers. So it's 1847, and this guy, George Boole, he's a British guy, he writes a book called, Mathematical Analysis of Logic. And what he does there is he shows us how he can use binary numbers, or the idea of true and false, which you might be familiar with and attribute it to the type of Boolean. And that actually comes from this guy's name.

And he shows us how we can perform computations with these numbers. We can add and subtract and AND and OR them. So it's a pretty big set of discoveries from him.

Now, a little while later, in 1937, a guy named Claude Shannon is working on his Master's thesis at MIT. And what he shows is how to build a Boolean logic machine using just electronic relays and switches. So he actually builds, really, the first digital computer that uses a binary number system.

So why is binary interesting for computers? Well, because it only has two symbols, you can think of a way that we could represent those two symbols using voltages. So imagine that any kind of low voltage, below a certain threshold, we'll call that a 0. And if it crosses above a certain threshold, we'll call that a 1. And So you can design circuits that mimic or provide us with this binary number system much more easily than you could if you had to represent 10 symbols. So that's why the binary system works pretty well for computers.