Join Timothy Pintello for an in-depth discussion in this video Working with the binary numbering system, part of Networking Foundations: IP Addressing.
- The first thing I want to talk about when it comes to IP addressing is the binary numbering system. However, to understand the binary numbering system, let's first look at the base 10 numbering system, or the decimal system. This is the numbering system most people use when it comes to counting and things like that. In the base 10 numbering system, or the decimal system, we use 10 symbols to represent the values 0 to 9. Each value in the position to the left is multiplied by 10 times the value located in the position to the right.
Thus, we have 1000s, 100s, 10s, 1s, and so on, in our numbering system. As a result, we can take the value 4783 and we can look at it like this. We have 4 x 1000 + 7 x 100 + 8 x 10 + 3 x 1, giving us the 4783 value.
The base 2 numbering system, also called binary, works in a similar way. The big difference, though, is that we only have two symbols, 0 and 1, instead of ten symbols, 0 through 9. In the case of the base 2 system, each value to the left is multiplied by 2 times the value of the symbol to the right. As a result, we have 16s, 8s, 4s, 2s, and 1s instead of 1000s, 100s, 10s, 1s, et cetera.
As a result, we can take the binary value 1011 and we can say we have 1 x 16 + 0 x 8 + 1 x 4 + 1 x 2 + 1 x 1. If we add all this up, we end up with the decimal equivalent of 23. In the case of the binary numbering system, all binary values, or all numbers, are represented by 1s and 0s.
In electronis, 1 is generally represented by power being on or at a higher voltage. 0 is represented by power being off or at a lower voltage. In networking, we usually only need to convert numbers with 8 bits or less, because of the IP version 4 addressing. To convert binary to decimal, let's go ahead and start out with a table I've created. The first line or the top line of the table is two to the power of, and then, in sequential order, it'd be 2 to the power of 0, 2 to the power of 1, 2 to the power of 2, 2 to the power of 3, 2 to the power of 4, et cetera, on up to 2 to the power of 7.
I stopped at 2 to the power of 7 because that gives us eight bits. 0 through 7 is eight bits. If, for some reason, I needed to convert a much larger binary value to decimal, I would just continue this table on to the left, out as far as I need it to go. Whether that's 2 to the 15 for a 16 bit number or 2 to the 31 for a 32 bit number. Once I've gone ahead and put my values of 2 to the power at the top, I go ahead in my middle row, or the second row, I put the decimal equivalent of that value.
So 2 to the 0 is 1, 2 to the 1 is 2, 2 to the 2 is 4, 2 to the 3 is 8, 2 to the 4th power is 16, 2 to the 5th power is 32, 2 to the 6th power is 64, and 2 to the 7th power is 128, and, again, if I needed a longer number I'd just keep going out until I got to whatever number I needed to get out to for the bits I'm using. Now that we have our table, let's go ahead and put a binary value in that table.
In this case, I've chosen the binary value 10110001. So our eight binary values there on the bottom. Now that I have the binary value on the bottom row there, all I have to do is add up all the boxes with a 1 in them. In this case that would give me 128 + 32 + 16 + 1, which equals 177.
So, by using this table, I'm able to determine that the decimal value of 10110001 is the decimal value of 177. Going the other way isn't that much more difficult. Again we'll start out with the first two rows of our table filled up, and now we'll take a decimal value. In this case, let's take the decimal value 203. Now we take that decimal value 203 and we look at the boxes up here, and we determine which box is the largest number you can subtract from 203.
In this case, that is 128. So you subtract 128 from 203, and we get the value of 75. We then place a 1 in the 128 box. Now we take our remaining value of 75 and we repeat the process. We look at our table and we see that the largest number on the table we can subtract from 75 is 64. So that's what we do. We subtract 64 from 75 and get the result of 11.
We then place a 1 in the 64 box. Once more, we take our result of 11 and we look at this and see which value up here is the largest number I can subtract from 11. In this case, the largest number I can subtract from 11 is the number 8, with a result of 3. So I place a 1 in the 8 box, and then I take the 3 and decide, what is the largest number I can subtract from 3? In this case, the largest number I can subtract from 3 is 2, and that gives the result of 1.
So I place a 1 in the 2 box, and then, since I have a 1 left, I go ahead and place a 1 in the 1 box. Now I've placed the 1s where I need to place the 1s, I go back and add 0s to all the empty boxes. Now you have the binary equivalent of the value 203. That binary equivalent is 11001011. This will work with any decimal value you have.
If, for some reason, I have a number that is bigger than the biggest number I put up here, I just, again, would add extra positions out to the left of my table.
- Binary, hexadecimal, and octal numbering
- How logical and physical addressing work together
- Comparing broadcast and collision domains
- IPv4 classless addressing
- Subnetting with IPv4 and IPv6
- IPv6 reserved ranges
- IPv6 link local, 6to4 tunneling, and 4to6
- Configuring DHCP and DNS in Windows Server
- WINS and NAT
- Port, packets, and remote access