Converting Decimal IP Addresses to Binary To convert from decimal to binary, reverse the above process, taking each octet's decimal value and converting it to binary, as follows: Step 1. | Referring to the weighting factors in Figure C-2, find the largest weighting factor that is smaller than or equal to the value of the octet. The binary number will have a 1 in the corresponding bit position and will have a 0 in any bit positions to the left of this 1.
| Step 2. | Subtract that weighting factor from the decimal octet value.
| Step 3. | Repeat this process using the new octet value, until the result is 0.
| Step 4. | Set any remaining bit positions in the binary number to 0.
| For example, consider the IP address 192.168.19.255. To write this address in binary, follow these steps: Step 1. | Select an octet to convert. The conversion of the second octet, 168, to binary is shown in Figure C-4.
Figure C-4. Converting an Octet from Decimal to Binary Figure C-4 describes the following points:
The largest weighting factor that is smaller than or equal to 168 is 128, so the binary number has a 1 in the 27 (128) position. Subtracting 128 from 168 results in 168 128 = 40. The largest weighting factor that is smaller than or equal to 40 is 32, so the binary number has a 1 in the 25 (32) position (with a 0 in the intermediary position). Subtracting 32 from 40 results in 40 32 = 8. The largest weighting factor that is smaller than or equal to 8 is 8, so the binary number has a 1 in the 23 (8) position (with a 0 in the intermediary position). Subtracting 8 from 8 results in 8 8 = 0. The remaining bit positions in the binary number are set to 0. Thus, 168 in decimal equals 10101000 in binary. | Step 2. | Repeat this process for the other three octets. The results are as follows:
192 decimal equals 11000000 binary. 19 decimal equals 00010011 binary. 255 decimal equals 11111111 binary. | Note Again, you can confirm these results using the decimal-to-binary conversion chart in Table C-1. Therefore, the IP address 192.168.19.255 in binary is as follows: 11000000 10101000 00010011 11111111 |