# Binary Math – CompTIA Network+ N10-006 – 1.8

April 1, 2015

Your computer speaks in ones and zeros, and it will help with your subnetting practice if you also speak “binary.” In this video, you’ll learn how easy it really is to convert between decimal to binary and back again.

<< Previous: Network InfrastructuresNext: An Overview of IPv6 >>

In this video, we’re going to go through the process of performing calculations in binary. And although, that may seem a bit daunting at first, you’ll be surprised at just how easy it is to perform calculations with ones and zeroes. That’s one of the things that makes binary math so easy is that there are only two numbers. There’s a zero and a one. We sometimes refer to this as base two since there are only two numbers that make up this numbering system.

If we combine a group of ones and zeroes together into a group of eight we often call that a byte. Sometimes, you’ll hear it referred to as an octet just to make sure everyone understands that there are eight bits in that byte. It’s very easy to work with binary math when you have a conversion chart.

So let’s build one right now. Grab a pencil one sheet of paper. We’re going to write this one down ourselves. And we’ll use this conversion chart not only to perform the math in this video, but you’ll use this conversion chart do things like subnetting on IPv4 and IPv6 networks.

To build this chart, let’s draw eight zeroes on a piece of paper– 1, 2, 3, 4, 5, 6, 7, and 8. And above that, we’re going to perform some calculations. These are very easy calculations to do. On the far right, we’re just going to put the number one, and then we’re going to double that number. 1 times 2 is 2. 2 times 2 is 4. 4 times 2 is 8. And we’ll just keep doubling the numbers so that above each one of these zeroes we have the number 1, 2, 4, 8, 16, 32, 64 and 128. That is our binary conversion chart. With just this chart, you’ll be able to perform all the calculations that we need in this video.

If you wanted to also look at this from a different perspective, we can look at it from a base two perspective 2 the 0 power is 1. 2 to first power is 2. 2 to the second power is 4 and so forth. And then when you start performing a lot of IPv4 calculations and doing subnetting with IP, you’ll find that it may be easier to think in base two, rather than to think in the final numbers you’ll use. But in either case, you now have a conversion chart that we can use to perform some of these calculations.

Now that we have our conversion chart let’s perform our first calculation. And the question we have is what is binary 10000010 in decimal? And to perform this calculation, we’re going to write down that number. We don’t know exactly what the decimal value is of that quite yet. But now we’re going to add the numbers that we got from our conversion chart. We’ll just put them right across the top. This is where we perform the calculation.

We’re going to look at the number on the top. Every time there is a 1, we’re going to bring that number down to the bottom. And every time there’s a 0, we’re going to just bring a 0 down to the bottom. So the only place there is a 1 is under the 2, and we’ve got a 128. So we’ll bring down those two numbers, and all the rest are 0’s.

We’re now going to add all of those. So 128 plus 0 plus 0 plus 0 plus 0 plus 0 plus 2 plus 0, and we get 130. That is how easy it is to perform a decimal calculation when you have that binary number to begin with. And as long as you have this conversion chart you’ve created, you can grab any binary number and do the calculation of the decimal very quickly.

Let’s do another one. On this one, I’m going to give you the binary number 11111111 in decimal. And it’s the same process that we just performed. We’ll take those 1’s and we’ll bring them all the way down. We’ll add our conversion chart right on top of that and we’ll bring down every number that has a 1 associated with it. And in this particular case, every one of these has a 1 associated with it.

There’s no 0 in any one of these places. So our question is really going to be what is 128 plus 64 plus 32 plus 16 plus 8 plus 4 plus 2 plus 1. And if you add all of those together, you get 255 in decimal. Now you can take any binary number, put it into your conversion chart, and you should be able to get a decimal number on the other side

Now let’s reverse this process. Let’s now take a decimal number and determine what the binary number is of that. This process isn’t quite as straightforward, but we’re going to work backwards. And you’ll see it’s just an easy process to perform the calculations. Again, we’re going to bring down our binary number, but we don’t know are binary number. So we’re currently going to leave those blank. And we’re going to add our conversion chart across the top just as we have before.

And now we want to calculate this 154 decimal. And what’s interesting about this binary is that there’s only one combination of all of these numbers together that can add up to 154. So we start asking questions of this. For instance, is 128 less than or equal to 154? I would say that yes 128 is less than or equal to 154. So we’re going to bring down 128 and add a 1 right here into that decimal mark.

Now let’s move to the right. We’ll perform the same question and ask is 128 plus 64 less than or equal to 154? In this case, those two together are 192. They are not less than or equal to 154. So we’ll put a 0 and bring the 0 down. Now let’s add the next one over, which is 32. So our question will be is 128 plus 32 less than or equal to 154? Those combined together are 160. So those are not less than or equal to 154. We’ll bring a 0 down there.

So we keep performing this process. We’ll calculate, for instance, 128 plus 16 is 144. That is less than or equal to 154. So it gets a 1 and we add a 16 into the mix, and we’ll keep going. Now we’re up to 144. So we keep calculating. Is 144 plus 8 less than or equal to 154? It is. It’s 152.

So we add a 1 and bring that 8 down. Now we’ve got a 152. And you could almost now start doing the calculations in your head. 152 plus 4 is 156 that is not less than or equal to 154. 152 plus 2 is exactly equal to 154. So that’s a yes, and we know that there’s nothing left. We’re finally up to 154. So we can bring a 0 down at the 1 place.

So now we have this binary number for 154 which is 10011010. We’ve now taken 154 in decimal and we’ve converted it to binary just by performing simple edition and getting our binary number on the other side. We’ve been working with these eight bit octets, but of course you can have different sizes of calculations. And when you start getting into doing subnetting, you’ll find that you have certain numbers of bits that you have to work with.

For example, if you just have two bits there’s only a number of ways, in fact four ways that you can turn these bits on and off. 00 is 0, 01 is 1, 10 is 2, 11 is 3. There’s only four things that you could really come up with when you’re working with two bits. And as you start working through calculations, when you have three bits are four bits, all the way through eight bits you can see the maximum number of addresses that you might be able to have in a particular grouping will be based on the size of these numbers of bits.

And in a later video, we’ll do a lot more IP subnetting. And you’ll become more accustomed to seeing and using these different sizes of bits and groups. When you get into more advanced subnetting, you’ll find you very easily exceed more than eight bits in a single address. And I’ve added this conversion chart here, because once we get past those eight bits, we start extending up. It’s the same process. We just keep doubling the number every time.

So 2 to the seventh power 128 to the eighth is 256. We double 256 to get the 512. We double 512 to get to 1024. Double 1024 to get to 2048 and so on. So you should be able to extrapolate out as far as you need to whenever you’re doing the subnetting just by going through this conversion chart and doubling the numbers until you get to the value you need.

Category: CompTIA Network+ N10-006