IP Subnetting Part 3: Understanding the Binary

I’ve often stated how simple subnetting really is. While each individual concept is rather simple, it is the combination that make the holistic process challenging. If we, as humans, could look at the process more like computers and network devices, subnetting would be a much simpler process. In short, some knowledge of binary is an important requirement prior to sharing more complex subnetting examples.

This article will demonstrate the process of converting binary to and from the more familiar decimal numbering system. This will establish the necessary baseline knowledge required to understand when applying subnet masks to IP addresses. The first question we need to answer is–

What is Binary?

Binary, also known as base-2, is a numbering system in which each position only has two possible values. We often represent one possible value as zero and the other possible value as one. Alternatively, it could be represented many other ways including: positive and negative voltage, black and white colors, voltage and no voltage present, or null and not null. This simplicity in representation is what makes the system so advantageous for a computer’s limited discreet capabilities.

In this article, we will represent binary digits using either a one or a zero. To simply demonstrate the process of counting and introduce binary, I like to think about how a car’s odomoter works. With the more familiar decimal system, each digit is some value between 0 and 9. When the digit is currently at 9, the next value will be 0. However when the digit transitions from 9 to 0, the digit to the left also increases by one. This is a process in math that is sometimes referred to as carrying.

Binary is similar, but each value is represented as 0 or 1. When a positional value is 1, the increase takes it back to zero. It is at that point, the value to the left is increased by one. To better understand, let’s take a look at the process of counting in binary. In the example below, I am using eight positions to represent the typical 8 bits (IP octets are eight bits).

Binary     Decimal
00000000 =    0
00000001 =    1
00000010 =    2
00000011 =    3
00000100 =    4
00000101 =    5
00000110 =    6
00000111 =    7
00001000 =    8

As can be seen in the example, the mechanics of incrementing the digits are very similar to that of the decimal numbering system. The difference is that binary has a maximum possible value of one. Increases iteratively increment values to the left similar to that of increasing the decimal value of 999 by 1 (to 1000).

Counting in Binary

0
1
01

Counting in Decimal

0
1
2
3
...
8
9
10

Converting from Binary to Decimal

It’s not typical that we will be counting in binary. However, we do need to know how to translate between binary and decimal. That is rather simple when we understand the value of each position in a binary number and know how to work through the process. With eight bit values, the first bit position has a value of 128 and the values are halved (divided by 2) as we transition through to the least significant bit.

128   64   32   16   8   4   2   1

To demonstrate the application of this, we can use a binary example. For our example, we will use 11001101. By multiplying the positional value to the one or zero in the binary number, then adding the vlues together, we can convert the binary numbers to a decimal value.

Binary Position Value
128   64   32   16    8   4   2   1  // Positional Value
 1     1    0    0    1   1   0   1  // Binary Number
---   --   --   --   --  --  --  --
128 + 64  + 0  + 0  + 8 + 4 + 0 + 1  = 205 // Decimal Value

Using this process, we have determined that the binary number 11001101 is the equivalent of the decimal number 205. This process can be simplified using the multiplicative identity property. This property that states any number, multiplied by one, is the original number. We also know that anything mulitplied by zero is zero. Therefore we can shortcut this process by simply adding together the positional values that are associated with a one in the binary number.

Binary Position Value
128 + 64 + 32 + 16  + 8 = 4 + 2 + 1  = 205 //Decimal Value
 1     1    0    0    1   1   0   1  // Binary Number

Converting from Decimal to Binary

Understanding how to convert from decimal to binary is as important as important as converting from binary to decimal. The process is basically the inverse of what we just learned and is not overly complex. To demonstrate, we can convert the decimal number 205 back to a binary number. We need to use the same series of positional values to perform the conversion.

128   64   32   16   8   4   2   1

Using the decimal number we wish to convert alongside the above values, we can determine which bits should be zero and which should be one. To start this process, we ask if our number is divisible by the 128. The answer must be zero or one. For this process, we don’t care about any remainder.

205/128 = 1

128   64   32   16   8   4   2   1
 1     ?    ?    ?   ?   ?   ?   ?   //binary number

So we know that the first bit is going to be a one. This process used 128 of our original value of 205. So we subtract 128 from the original value and go through the process for the next value.

  
205 - 128 = 77  //we use 128 because first bit is 1

The next iteration is--
77/64 = 1

128   64   32   16   8   4   2   1
 1     1    ?    ?   ?   ?   ?   ?   //binary number

Continuing this process, we subtract 64 from 77, leaving us 13.

77 - 64 = 13  //we subract 64 because that bit is a 1

13/32 = 0

128   64   32   16   8   4   2   1
 1     1    0    ?   ?   ?   ?   ?

Since 13/32 resulted in zero, there is no need to subtract anything before iterating the next bit value. So we will next attempt to divide 13 by 16.

13 - 0 = 13  //we subract 0 because that bit is a 0

13/16 = 0

128   64   32   16   8   4   2   1
 1     1    0    0   ?   ?   ?   ?

Again, our division resulted in zero. Therefore, there is no need to subtract anything before iterating the next bit value. So we will next attempt to divide 13 by 8.

13 - 0 = 13  //we subract 0 because that bit is a 0

13/8 = 1

128   64   32   16   8   4   2   1
 1     1    0    0   1   ?   ?   ?   //binary number

This process is continued until there is no value remaining.

13 - 8 = 5
 5 / 4 = 1 (position with value of 4 = 1)
 5 - 4 = 1
 1 / 2 = 0 (position with value of 2 = 0)
 1 - 0 = 1 
 1 / 1 = 1 (position with value of 1 = 1)
 1 - 1 = 0 //nothing left
 

128   64   32   16   8   4   2   1
 1     1    0    0   1   1   0   1   //binary number

This article should have served as an introduction to binary. The key concepts addressed include the mechanics of the base-2 system and conversion. In an upcoming article, we will look at the relevance of this numbering system as it pertains to subnet masks. We will also address more advanced subnetting concepts that require a thorough understanding of the binary numbering system.

Related Articles

About Paul Stewart, CCIE 26009 (Security)

Paul is a Network and Security Engineer, Trainer and Blogger who enjoys understanding how things really work. With over 15 years of experience in the technology industry, Paul has helped many organizations build, maintain and secure their networks and systems.
This entry was posted in CCNA, Certification, General, Network, Technology and tagged , , , , . Bookmark the permalink.

One Response to IP Subnetting Part 3: Understanding the Binary

  1. Pingback: IP Subnetting Part 4: Subnetting a Class C Network - PacketU

Leave a Reply