# How to Convert an IP Address to Binary?

If you run a network with subnets and routing protocols, you’ll probably have to convert your IP address into binary at some point. Most of the time, we humans don’t need to know the binary code for things. But the computers we love and use so much read in binary, so knowing how binary works and why you might need to convert your IP into binary can be helpful.

This tutorial will show you how to convert a dotted decimal IP address into binary and explain what situations you might need it for.

## What is the binary code for an IP address?

An IP address is a 32-bit number. Those 32 bits are separated into four groups of eight bits each. Those eight bits are called octets. You can convert each of the four groups into binary, then combine all four together to get one long binary code for your IP address, made up entirely of 0s and 1s.

## Why do you need to convert an IP address to binary?

While you, a human, probably find it easier to identify an IP address when it’s in decimal form, a computer understands an IP address with binary. To help with networking and subnetting, we need to be able to put IP addresses in binary so that computers can recognize them.

There are four reasons why you’d want to convert IP addresses to binary.

### 1. Understand the IP address structure

An IP address is made up of 32 binary bits. When you convert it, you can see the 0s and 1s that form the structure.

### 2. Subnetting and routing

A subnet is a network inside a network and it lets you connect more people to the Internet without having to use more IP addresses. When setting up a subnet or working with routing protocols, you have to do a lot of calculations. Converting IP addresses into binary makes those calculations easier.

### 3. Programming and configuring network devices

Network devices and software often work with the binary versions of IP addresses. So if you want to set them up properly, you’ll need to convert your IP to binary.

### 4. Troubleshooting

When you look at the binary version of an IP, you can more easily find which network a subnet belongs to. Why would you need to find that? If you’re having issues with your network, figuring out where everything fits in your network is one of the most important troubleshooting steps.

As you may have guessed from the reasons above, you probably don’t need to convert any IP address into binary unless you’re a network administrator. Or if you start running experiments with your home network.

Now that you know why you might need to convert an IP address from decimal to binary, let’s go over how to do it.

## How to convert an IP address to binary

Technically, IP addresses are not in decimal format, they are *dotted decimal* format. That means there’s a decimal point in between each group of numbers. An IPv4 address has four groups and therefore three decimal points. To convert an IP address to binary, you simply convert each of these groups one at a time.

Before you can do that, however, you have to know how to convert regular numbers into binary.

### How to count in binary

Binary only uses two digits: 0 and 1. So counting works a bit differently than in the decimal number system. You have to pay attention to each column when you’re counting. Each column represents a power of 2.

The column the furthest to the right is 2^0, the one next to it is 2^1. Then 2^2, then 2^3, and so on. It helps to know what these numbers are so here’s a chart:

2^0 | 1 |

2^1 | 2 |

2^2 | 4 |

2^3 | 8 |

2^4 | 16 |

2^5 | 32 |

2^6 | 64 |

2^7 | 256 |

To count up, you start with all zeros. Then change the rightmost 0 to 1, that’s 1.

For 2, change the 1 to 0 and change the 0 next to it to 1.

For 3, change the 1 to 0 and put a 1 in the next column.

Once you reach a column value of 1, change it to 0 and carry the 1 over to the next column. This is just like normal addition where you carry the 1. The pattern continues as you count up. When a column hits 1, flip it to 0 and carry the 1 over.

This allows you to count infinitely in binary by adding more and more columns as needed. Counting in binary follows the same logic as normal counting but only uses the digits 0 and 1 and columns representing powers of two. With practice, you’ll get used to reading binary numbers and counting in this base 2 system.

Let’s count to 10 in binary:

1 | 0 |

2 | 1 |

3 | 10 |

4 | 11 |

5 | 100 |

6 | 101 |

7 | 110 |

8 | 111 |

9 | 1000 |

10 | 1001 |

If you want to convert a number, like 127, into binary, you have to do so using the power of 2. Go back to the power of 2 chart and look for the closest number to 127 that is *not *greater than 127. It’s 64. So you start by writing the binary for 64 which is 100000. Why? Because 64 is 2 to the sixth power (2^6) You put a 1 first, then five 0s behind it.

We’re not done yet. We need to get all the way to 127 and so far we’re only at 64. Let’s skip ahead a bit and write it out like this:

64 + 32 + 16 + 8 + 4 + 2 + 1 = 127.

You’ll need to write out the binary code for each of the numbers in the equation above, and stack them on top of each other, like you would when adding large decimal numbers together:

100000

010000

001000

000100

000010

000001

Notice how the 1 moves over to the right by one spot for each number? Now, add these digits up and you get:

111111

127 = 111111 in binary.

If it still doesn’t make sense, this video from Carl Oliver on converting numbers to binary might help.

Now that you can convert decimal numbers to binary, you’re ready to convert a dotted decimal IP address into binary.

### Convert dotted decimal IP into binary: example

To convert a dotted decimal IP address into binary, you need to convert one group at a time. Let’s take the example IP address of 194.128.56.26 and convert it to binary. Take it one group at a time.

194 = 11000010

128 = 10000000

56 = 111000

26 = 11010

Now combine them all into one long binary number:

194.128.56.26 = 110000101000000011100011010

That’s the IP address in binary.

## How do you convert IP to decimal?

Since an IP address is technically in dotted decimal notation, you can use binary to find the decimal value. Take the above example of 194.128.56.26. In binary, it’s 110000101000000011100011010. If you can convert decimal numbers, like 127, to binary, then you can convert binary numbers to decimal as well. So 110000101000000011100011010 in decimal would be:

101,975,834

That’s your IP address, in decimal format. It’s the real IP address number but it’s too difficult for humans to deal with and computers prefer 0s and 1s, so we express it in dotted decimal.

## IP addresses and binary

Learning to convert your IP address into binary is good to know if you’re interested in computer networking. It’s a simple, logical calculation if you think about it. Now that you know how to do it, you can understand your network better — or use it as a nerdy party trick.

## Related Articles

- All
- Easy Prey Podcast
- General Topics
- Home Computing
- IP Addresses
- Networking Basics: Learn How Networks Work
- Online Privacy
- Online Safety
- Uncategorized

### Top VPNs That Let You Choose Your Location

Did you know that all VPNs change your location, and many of them let you choose your…

[Read More]### Should I Use CyberGhost VPN for Torrenting?

The chaotic sea of the Internet offers so much content and interactive opportunities, it can feel overwhelming….

[Read More]### What to Do If You Fell for a Scam: A Comprehensive Guide

So you fell for a scam. It can happen to anybody. No matter how smart, capable, aware,…

[Read More]### Making the Employee Onboarding and Offobarding Process Easier and More Secure

Fifty years ago, it wasn’t very common for employees to change jobs. Once they were hired, they…

[Read More]### How to Choose the Right VPN for PlayStation

Adults and kids alike enjoy hours submersed in the adventures of online gaming. You can network and…

[Read More]### 8 Ways To Tell if an Online Source is Legit

In the digital age, the amount of information at our fingertips is staggering. Between newspaper and magazine…

[Read More]