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.

IP Address octets

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:

  1. Power of 2 (PO2)
  2. Division by 2

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.

IP Address Place Numbers, IP Address to Binary

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 2 = 128 <= 170

 

Convert IP Address to Binary with Place Number 8

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 2 = 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 2 = 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

Place Number 1

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

10101010

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

Octet1Octet2Octet3Octet1
417040125
10101010001010000000000100011001

FAQs

What’s an IP address anyway?

Think of an IP address like a home address for devices on the internet. It’s how computers find each other in the vast digital universe!

Why bother converting it to binary?

You know how humans prefer languages like English or Spanish? Well, computers speak in 1s and 0s – that’s binary. Converting IP addresses to binary helps machines understand them.

Decimal? Binary? Sounds complicated, right?

Nah! Just as we count using numbers 0-9 (decimal), computers use only 0s and 1s (binary). It’s like translating a sentence from English to French!

How do I spot a decimal IP address?

Ever seen something like 192.168.1.1? That’s an IP in decimal. Imagine it as the phone number for a device on the internet.

Okay, got it. But, how does it look in binary?

Each of those numbers you see in the decimal IP? They get their own 8-bit binary representation. So, 192 might look like 11000000 in binary. Cool, huh?

Does this conversion serve a real-world purpose?

Absolutely! Ever heard of subnetting or IP routing? They often require a grasp of binary representation of IP addresses. It’s like reading a map in a computer’s language!

Can I convert them manually?

Sure thing! It’s a bit of math, but if you’ve ever played with division and remainders, you’re on the right track. Remember when we learned long division in school? Similar vibes!

Is there a tool to make this easier?

Oh, totally! There are loads of online converters that do the heavy lifting for you. It’s like having a personal translator for computer-speak.

Binary seems confusing. Any tips?

Practice! Try converting some decimal numbers to binary on paper. It’s like learning to ride a bike – wobbly at first, but soon you’ll be cruising!

Why is this knowledge useful to me?

In the digital age, understanding the basics of IP and binary can give you a sneak peek into the backend of the internet. Plus, it’s a cool party trick, right? Imagine being the tech guru in your group!

 

Good reads

  1. What is IP Address
  2. What is VPC