Converting Decimal IP Addresses to Binary IP
Addresses
You have already read about the math behind the conversion
process between decimal and binary. To convert IP addresses, you simply need to
follow a few additional rules:
|
1. |
When converting from a decimal IP address to binary, each of
the 4 decimal numbers in the decimal IP address converts to an 8-bit number,
giving you a total of 32 bits.
|
|
2. |
If a decimal number converts to a binary number that has less
than 8 digits, put binary 0s in front of the number to create an 8-digit binary
number.
|
|
3. |
The 32-bit binary IP address is formed by simply writing down
each of the 4 sets of 8 bits in order.
|
In other words, to convert a decimal IP address to its 32-bit
binary equivalent, you would convert each of the 4 decimal numbers in a decimal
IP address to a binary number. You might recall from Chapter 10 that each of the 4 numbers in a decimal IP
address, separated by periods, is called an octet. Essentially, you convert each
of the 4 decimal octets to 8-bit binary numbers. For any of these binary numbers
that converted to less than 8 digits, you would put binary 0s to the left to
make them 8 digits long. Finally, just think of the 4 octets as one long 32-bit
number, and you're done!
Table B-15 shows a
sample conversion of the IP address 100.235.2.2.