Back in Chapter 4, we took a very basic and introductory look at the concept of an IP address. Recall that IP addresses are logical addresses made up of two parts – the first part represents a network, and the other, a unique host on that network. Before we get into the details of IP addressing, you’ll first need to know a little more about how binary and decimal numbers relate to each other.

## Binary-Decimal Conversions

Remember that IP addresses are 32-bits in length, but are usually represented in dotted-decimal notation. As such, the address 192.168.2.200 can also be represented as:

11000000 10101000 00000010 11001000

But why should you care about the binary version? The answer is absolutely critical – in order to truly understand how IP addressing works, you must always take a look at elements such as addresses and subnet masks in binary form. After you’ve had lots of practice in binary, you’ll get very good at “understanding” the numbers when you see them in decimal. Just remember that when starting off, it is important that you convert addresses to binary – doing so will ultimately unlock the secrets of subnetting, determining if hosts are on the same or different networks, and whether IP addresses are valid.

Having said that, our first logical step is learning how to do decimal-to-binary conversions and vice versa. Recall that a 32-bit address is actually grouped into four octets in its decimal form – each octet represents 8 bits in binary. The figure below outlines the decimal and binary values for each of the 8 bits.

DECIMAL | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

BINARY | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |

Notice that each of the eight binary digits has a single decimal value associated with it. An important pattern should be clear in the decimal row – moving from right to left, the value doubles in each successive column.

This is part of what make binary numbering so useful – for any given decimal number, there is one (and only one), way to represent it in binary. After a few examples, understanding how binary numbering works will be clear.

We’ll start with converting binary to decimal, since this is the easiest way to illustrate the conversion process. Imagine you wanted to convert the binary number 01010101 to decimal. Using Table 5-1, you’ll notice that each binary “1” value corresponds to the decimal value above it. If we add together the decimal values that correspond to the 1s in the binary number, we’ll have completed the conversion process. For example, the decimal value of the binary number 01010101 would be:

0 + 64 + 0 + 16 + 0 + 4 + 1 = 85

All I did was take the decimal value of each of the 1s in the binary number and replace them with their corresponding decimal value. In cases where the binary digit was 0, I did not add that value. Consider another example, the binary number 11100011. In this case, the corresponding decimal value would be calculated as:

128 + 64 + 32 + 0 + 0 + 0 + 2 + 1 = 227

I’ve left the 0 decimal values in my examples to act as placeholders – you should consider doing this until you feel comfortable that you remember the decimal values associated with each binary digit.