In this article we are going to learn how to convert IP Address from Decimal to binary format. We already know that IP Address is a 32 bit logical address which is divided in 4 octets. We call each part an octet as it contains 8 binary digits or 8 bits. If you want to know literal meaning of octet, you can check it here. So we can say that each octet has a decimal number which we need to convert to binary format and so we have 4 decimal numbers which has to be converted to binary numbers.
To get understanding about IP addresses, it’s types and classes you can visit here.

So if know how to convert an octet to binary from Decimal, we should be able to do it for all the octets. We have two methods by which we learn how to Convert IP Address from Decimal to Binary:
- Power of 2 (PO2)
- Division by 2
Contents
Power of 2 (PO2) method to convert IP Address from Decimal to Binary format
In this method we need to make a table first which would look like this
When we look into the PO2 diagram below we see that we have 8 digits or 8 bits and these 8 bits make one octet.

This diagram contains values using formula:
2(PlaceNumber -1)
So if we look at 4th place the value should be 2(4-1) i.e. 23 =8.
This should be clear by now that we traverse this diagram in ascending order from right to left and the power of 2 is the value one less than PlaceNumber.
Convert IP Address from Decimal to Binary
We have an IP address: 170.40.1.25.
As mentioned above we need to convert it octet by octet. So we take first octet which is 170.
We take the first Number 170 and we need to run a loop or we say cuts to get equivalent Binary number.
First Cut
Number=170
Calculate PlaceNumber for 170
The formula here 2(PlaceNumber-1) <= Number where Number=170
So it becomes 2PlaceNumber-1 <=170
It is evident from below diagram that PlaceNumber-1=7 which gives us
PlaceNumber=8 and 27 = 128 <= 170

Get Binary Number for 128
Now we need to make the PlaceNumber Bit ON and all the other bits OFF and we get the number 10000000
Second Cut
Same as above we just get the Number changed
New Number=170-128=42
Calculate PlaceNumber for 42
The formula here 2(PlaceNumber-1) <= Number where Number=42
So it becomes 2PlaceNumber-1 <=42
It is evident from below diagram that PlaceNumber-1=5 which gives us
PlaceNumber=6 and 25 = 32 <= 42

Get Binary Number for 32
Now we need to make the PlaceNumber Bit ON and all the other bits OFF and we get the number 00100000
Third Cut
Same as above we just get the Number changed
New Number=42-32=10
Calculate PlaceNumber for 10
The formula here 2(PlaceNumber-1) <= Number where Number=10
So it becomes 2PlaceNumber-1 <=10
It is evident from below diagram that PlaceNumber-1=3 which gives us
PlaceNumber=4 and 23 = 8 <= 10

Get Binary Number for 8
Now we need to make the PlaceNumber Bit ON and all the other bits OFF and we get the number 00001000
Fourth Cut
Same as above we just get the Number changed
New Number=10-8=2
Calculate PlaceNumber for 2
The formula here 2(PlaceNumber-1) <= Number where Number=2
So it becomes 2PlaceNumber-1 <=2
It is evident from below diagram that PlaceNumber-1=1 which gives us Number=2 and PlaceNumber=2

Get Binary Number for 2
Now we need to make the PlaceNumber Bit ON and all the other bits OFF and we get the number 00000010
Now we have 4 binary numbers which we need to add and will get our binary equivalent for 170
1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
Final Binary number for 170 is
1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |
We have the IP 170.40.1.25
Now we need to follow the same procedure for the other octets and we will get the Binary equivalent of this IP which is
Octet1 | Octet2 | Octet3 | Octet1 |
---|---|---|---|
4170 | 40 | 1 | 25 |
10101010 | 00101000 | 00000001 | 00011001 |
Excellent