Skip to content

Converting IP Addresses: Decimal to Binary Guide

Binaries in IP Addresses

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.

Can you convert an IP address to binary?

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

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^01
2^12
2^24
2^38
2^416
2^532
2^664
2^7128

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:

10
21
310
411
5100
6101
7110
8111
91000
101001

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:

1000000

0100000

0010000

0001000

0000100

0000010

0000001

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

1111111

127 = 1111111 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. If you want to dive deeper and feel cool about it, check out our guide on how to convert an IP address to Hex. It’s a great way to expand your tech skills and impress your friends!

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
  • All
  • Easy Prey Podcast
  • General Tech Topics, News & Emerging Trends
  • Home Computing to Boost Online Performance & Security
  • IP Addresses
  • Networking Basics: Learn How Networks Work
  • Online Privacy Topics to Stay Safe in a Risky World
  • Online Safety
  • Uncategorized
Diagram comparing public and private IP addresses: local devices use private IPs via a router, which connects to the internet through a single public IP from an ISP.

Public IP vs. Private IP Address: What’s the Difference and Why It Matters

Have you ever looked up your IP address on a tool like WhatIsMyIPAddress.com’s tool and noticed what…

[Read More]
A server room featuring a laptop connected to a glowing neon cloud network, illustrating the concepts of IP address data exchange

What Is an IP Address and What Information Does an IP Address Reveal?

An IP Address (short for Internet Protocol Address) is a unique string of numbers assigned to your…

[Read More]
Courtney Werning talks about investment fraud and recovery options.

Investment Fraud: When Investing Losses Aren’t Just from Risk

If you invest money anywhere, you hopefully know that investing comes with inherent risk. But not every…

[Read More]
A person relaxing on a balcony beside an open laptop on a table, enjoying a peaceful setting with a panoramic view.

How to Stay at an Airbnb Without Compromising Your Privacy or Safety

You found it. The perfect charming A-frame tucked into the mountains, wood-burning fireplace, panoramic windows, and a…

[Read More]
Charles Wallace talks about uncovering the story of elder financial abuse that happened to his mother.

This Story of Elder Financial Abuse Reveals Warning Signs that Get Overlooked

Not all elder financial abuse stories start with a scam, or even an obvious problem. A friendly…

[Read More]
Digital art of glowing social media icons interconnected by vibrant blue and white data streams.

Social Media Hacking Isn’t Random, It’s Data-Driven

You don’t have to click a malicious link to become a target. Sometimes, all it takes is…

[Read More]