Binary is the fundamental building block for almost everything relating to technology. In this video, you’ll learn how to easily convert between a decimal number and its binary value.
As you start working more with networks and doing more IP subnetting, you’ll need to do more binary math. And in this video, I’ll show you how to convert to and from the binary format. Binary, of course, means a single bit that can either be 0 or 1. It’s either on or off.
And we usually represent this as a 0 for off and a 1 for on. When we put 8 of these bits together, we have what’s called a byte. We often refer to this byte as an octet to show that it is 8 bits that we are using in this calculation.
To be able to perform all of the conversions we’ll do today, we need to make a conversion chart. And this is our conversion chart that we will use to be able to perform our binary calculations.
We’ll start on the right side and put the number 1, and then we’ll double it. If we double 1, we have 2. If we double 2, we have 4. 4 times 2 is 8. 8 times 2 is 16, 32, 64, and 128. This allows us to perform any type of binary calculation. And this will be very handy when we start doing more IP subnetting.
I put in 8 different slots for this binary conversion chart, but depending on how many bits that you need to have in your conversion, you can keep extending this out by simply doubling the number and extending it out over a very long distance. You may find yourself using these longer charts when you do some additional IP subnetting, but the majority of what you’re working with will be 8 single bits made up into a byte.
Using our conversion chart, let’s do a binary calculation. This first question asks, what is binary 00000010 in decimal? The first thing we’ll do is write out this particular byte in this bit form– 0, 0, 0, 0, 0, 0, 1, 0. And of course, we want to know what the decimal equivalent is of that binary value. What we’ll do is put our conversion chart right on top of those numbers.
We’ll start with the 1, 2, 4, 8, 16, 32, 64, and 128. Every place there happens to be the binary 1, we’re going to bring down the number from our chart. Every place there’s a binary 0, we’re going to bring down a 0. And if we do that, we’re bringing down 0 plus 0 plus 0 plus 0 plus 0 plus 0 plus 2 plus 0.
Since that second bit is the one that has the 1 associated with it, we’re bringing down the 2 from our conversion chart. And if you perform that complicated math, you’ll find that the answer is 2 decimal. So 00000010 in binary is equal to 2 in decimal.
Let’s do another one. Let’s calculate 10000010 in binary and convert that to decimal. Same process occurs, we put down all of the bits. And we put our conversion chart right on the top.
Every place there is a 1, we’re going to bring down the number from our conversion chart. In every place there’s a 0, we bring down a 0. And if we perform this calculation, it’s 128 plus 0 plus 0 plus 0 plus 0 plus 0 plus 2 plus 0, meaning that binary 10000010 is 130 in decimal.
And let’s take it to the natural extreme and determine in decimal, what is the binary value of 11111111. Same process occurs, we’ll put down that binary value of all 1’s. We’ll put our conversion chart right on the top.
And now we’re adding together every single part of that conversion. So we need to calculate 128 plus 64 plus 32 plus 16 plus 8 plus 4 plus 2 plus 1, meaning that all 1’s in binary is the equivalent of 255 in decimal.
To do this the other direction, we need to perform a number of additional steps. If we want to take the decimal value of 154 and convert that to binary, we’re going to follow the same conversion chart. So we don’t know what those binary equivalents are yet, but we do know what our conversion chart looks like. The decimal 154 has a single combination of 1’s and 0’s that this could possibly be.
So what we’ll do is start with the 128. So is 128 less than or equal to 154? We know that 128 is less than or equal to 154. So we’ll put a 1 in that binary slot and bring down the 128.
Now, we’ll perform the same calculation, except now we know that 128 is part of this calculation, so we’ll add that to the next value in our conversion chart. So is 128 plus 64, which is 192– is that less than or equal to 154? It’s not because 192 is more than 154. So we’ll put a 0 in the slot with the 64.
Now let’s perform the same calculation with 32. 128 plus 32 is 160. Is 160 less than or equal to 154? It certainly isn’t. So we’ll put a 0 in that slot. Now, we move to 16. Is 128 plus 16, which is 144, less than or equal to 154? It is, so we’ll put a 1 and bring down the 16.
Next on our list is the 8. We’ll add up the 128 plus 16, which is 144, add 8 to that, which is 152. That is less than or equal to 154, so we’ll put a 1 in that slot and bring down the 8.
Now, we’ve got 128 plus 16 plus 8. We’re all the way up to 152. We’ll add 4 to that, which is 156. That is not less than or equal to 154, so we’ll put a 0 in the slot with the 4. Next on our list is the number 2. Is 152 plus 2 less than or equal to 154? Well, that is equal to 154.
So we’ll put a 1 in that slot, bring down the 2, and since it’s now equal to the number we were looking for, we know the 1 slot can’t be used. Therefore, 154 decimal is equal to the binary value of 10011010.
Although this is a few extra steps when you’re performing the decimal to binary conversion, it works for any type of decimal number, and you can easily calculate what the binary equivalent would be.
Of course, you could write out charts that had all of this information in it. If those charts were only dealing with 2 bits, then you’d only have 4 values that you could choose from– 0 through 3. If you had 3 bits, then you can extend that out to be 8 different values. 4 bits would be 16 values, and so on.
You can start to see a pattern as you begin extending out the number of bits, and this pattern is based on the powers of 2. This same chart we created before is really a powers of 2 chart. 2 to the 0 power is 1. 2 to the 1 power is 2. To the 2 power is 4, and so on.
This is the chart that you’ll be using to perform all of your binary calculations, all of your IP subnetting, and you’ll use it any time you need to make a conversion between binary and any other numerical format.