
Converting decimal into binary
So far, we have learned how to convert binary into a decimal. Now it's time to do the opposite and convert a decimal number into binary format. There are many different techniques for converting decimal to binary and vice versa. Here, I will show you a very simple step-by-step method that will make the conversion process seamless. We must remember the following:
- Convert one octet at a time
- The maximum value an octet can have is 255
First, we will convert the IPv4 address, 172.20.10.48, into a binary value. We shall begin with the first octet, then move onto the second, and so on. Our process regarding conversion includes the utilization of the radix 2 with its positioning values. We will start by subtracting the highest power of 2, which is 27 = 128, then 26 = 64, and so on. If our decimal value is able to be subtracted from a power of 2, we will place a 1 to indicate YES or a 0 to indicate NO:
- Let's begin by converting 172 into binary:
- Could 172 minus 128 (27)? Yes, with a remainder of 44. We get a 1.
- Could 44 minus 64 (26)? No, therefore we carry the 44 forward to try with another lesser power of 2. We get a 0.
- Could 44 minus 32 (25)? Yes, with a remainder of 12. We get a 1.
- Could 12 minus 16 (24)? No, therefore we will carry the 12 forward to try with a lesser power of 2. We get a 0.
- Could 12 minus 8 (23)? Yes, with a remainder of 4. We get a 1.
- Could 4 minus 4 (22)? Yes, with a remainder of 0. We get a 1.
- Could 0 minus 2 (21)? No, we get a 0.
- Could 0 minus 1 (20)? No, we get our final value, 0. Since there are no more powers of 2, we stop here.
For a better visualization, the following is a diagram demonstrating how this works:
To arrange our binary value, starting from the top to the bottom with the values of 1s and 0s, we get 10101100 as the binary equivalent of 172.
- Next, we'll convert the second octet, 20, into binary:
- Could 20 minus 128 (27)? No, therefore we will carry the 20 forward to try to minus a lesser power of 2. We get a 0.
- Could 20 minus 64 (26)? No, therefore we will carry the 20 forward to try to minus a lesser power of 2. We get a 0.
- Could 20 minus 32 (25)? No, therefore we will carry the 20 forward to try to minus a lesser power of 2. We get a 0.
- Could 20 minus 16 (24)? Yes, with a reminder of 4. Now, we have a 1.
- Could 4 minus 8 (23)? No, therefore we will carry the 8 forward to try to minus a lesser power of 2. We get a 0.
- Could 4 minus 4 (22)? Yes, with a remainder of 0. We get another 1.
- Could 0 minus 2 (21)? No, therefore we get a 0.
- Could 0 minus 1 (20)? No, we got our final value, 0. Since there are no more powers of 2, we stop here.
For a better visualization, the following is a diagram demonstrating how this works:
Starting from the top to the bottom with the values of 1s and 0s, we get 00010100 as the binary equivalent of 20.
- Now, it's time to convert 10 into its binary format:
- Could 10 minus 128 (27)? No, therefore we get a 0.
- Could 10 minus 64 (26)? No, therefore we get a 0.
- Could 10 minus 32 (25)? No, therefore we get a 0.
- Could 10 minus 16 (24)? No, therefore we get a 0.
- Could 10 minus 8 (23)? Yes, with a remainder of 2. We get a 1.
- Could 2 minus 4 (22)? No, therefore we get a 0.
- Could 2 minus 2 (21)? Yes, with a remainder of 0. We get a 1.
- Could 0 minus 1 (20)? No, we got our final value, 0. Since there are no more powers of 2, we stop here.
For a better visualization, the following is a diagram demonstrating how this works:
Starting from the top to the bottom with the values of 1s and 0s, we get 00001010 as the binary equivalent of 10.
- Now, for our last octet, we will be converting 48 into binary:
- Could 48 minus 128 (27)? No, therefore we get a 0.
- Could 48 minus 64 (26)? No, therefore we get a 0.
- Could 48 minus 32 (25)? Yes, with a remainder of 16. We get a 1.
- Could 16 minus 16 (24)? Yes, with a remainder of 0. We get a 1.
- Could 0 minus 8 (23)? No, therefore we get a 0.
- Could 0 minus 4 (22)? No, therefore we get a 0.
- Could 0 minus 2 (21)? No, therefore we get a 0.
- Could 0 minus 1 (20)? No, we got our final value, 0. Since there are no more powers of 2, we stop here.
For a better visualization, the following is a diagram demonstrating how this works:
Starting from the top to the bottom, with the values of 1s and 0s, we get 00110000 as the binary equivalent of 48.
Now, let's put everything together to see the binary equivalent of 172.20.10.48. We get the following:

Therefore, 172.20.11.48 = 10101100.00010100.00001010.00110000.