Convert Decimal IP address in Binary and Binary in Decimal
An IP address provides a unique identity to a device in a computer network. It contains a network address and a host address. It is always written with the subnet mask. Both IP address and subnet mask can be written in decimal and binary. Computers or network devices use these addresses in binary. However, they allow you to configure these addresses in decimal. You do so, they convert them into binary before each use. As a network professional or administrator, it is essential to understand this conversion. It allows you to learn how network devices use these addresses. This tutorial provides the easiest method for converting a decimal IP address and subnet mask into a binary IP address and subnet mask.
An IP address and a subnet mask together provide a numeric identity for an interface. Both addresses are always used together. Without a subnet mask, an IP address is ambiguous, and without an IP address, a subnet mask is just a number. Both addresses are 32 bits in length. These bits are divided into four parts. Each part, known as an Octet, contains 8 bits. Octets are separated by periods and written in a sequence.

Two popular notations for writing these addresses are binary and decimal. In binary notation, all four octets are written in binary format. Examples of IP addresses in binary notation are the following: -
00001010.00001010.00001010.00001010 10101100.10101000.00000001.00000001 11000000.10101000.00000001.00000001
Examples of subnet masks in binary notation are the following: -
11111111.00000000.00000000.00000000 11111111.11111111.00000000.00000000 11111111.11111111.11111111.00000000
In decimal notation, all four octets are written in decimal format. A decimal equivalent value of the bits is used in each octet. Examples of IP addresses in decimal notation are as follows: -
10.10.10.10 172.168.1.1 192.168.1.1
Examples of subnet masks in decimal notation are the following: -
255.0.0.0 255.255.0.0 255.255.255.0
Base value and position
Except for the base value, the binary system works exactly the same as the decimal system. Base value is the set of digits used to build numbers in both systems. In the binary system, two digits (0 and 1) are used to represent numbers, while in the decimal system, ten digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) are used.
To convert a binary number to decimal and vice versa, you need to change the base. Once the base value is changed, the resulting number can be written in the new system. Since IP addresses and subnet masks are 32 bits each, and these bits are divided into 4 octets, to convert these addresses from decimal to binary and vice versa, you only need to understand the numbers that can be built from an octet (8 bits).
A bit can be either on or off. In the binary system, an ON bit is written as 1, and an OFF bit is written as 0 in a number. In the decimal system, if a bit is on, its position value is added to the number. If it is off, its position value is skipped.
The following table lists the position value of each bit in an octet.
| Bit position | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| Position value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Key points
- Regardless of which system you use to write the octet, it always contains all 8 bits. Bits are always written from left to right.
- A number in which all 8 bits are off is written as 00000000 in the binary system. The same number is written as 0 (0+0+0+0+0+0+0+0) in the decimal system.
- A number in which all 8 bits are on is written as 11111111 in the binary system. The same number is written as 255 (128+64+32+16+8+4+2+1) in the decimal system.
Converting a decimal number to a binary number
To convert a decimal number into a binary number, follow these steps: -
- Compare the position value of the first bit with the given number. If the given number is greater than the position value, write 0 in the rough area of your worksheet. If the given number is less than or equal to the position value, write the position value.
- Add the position value of the second bit to whatever you have written in the first step, and compare it with the position value of the second bit. If the sum is greater than the position value, skip the position value. If the sum is less than or equal to the position value, add the position value to the sum.
- Repeat this process until all 8 bits are compared. If the sum becomes equal at any bit, write all remaining bits as 0.
| Operation | In Decimal | In Binary |
| Add | Use position value | Set bit to 1 |
| Skip | Skip position value | Set bit to 0 |
Let’s take an example. Convert the decimal number 117 to binary.
- Given decimal number is 117
- Calculation direction is left to Right.
| Bit position | position value | Comparison | Operation in decimal | Value in decimal | Operation in Binary | Value in binary |
| 1 | 128 | 128 is greater than 117 | Skip | 0 | Off | 0 |
| 2 | 64 | 0+64 = 64 is less than 117 | Add | 64 | On | 1 |
| 3 | 32 | 0+64+32 = 96 is less than 117 | Add | 32 | On | 1 |
| 4 | 16 | 0+64+32+16 = 112 is less than 117 | Add | 16 | On | 1 |
| 5 | 8 | 0+64+32+16+8 = 120 is greater than 117 | Skip | 0 | Off | 0 |
| 6 | 4 | 0+64+32+16+0+4 = 116 is less than 117 | Add | 4 | On | 1 |
| 7 | 2 | 0+64+32+16+0+4+2 = 118 is greater than 117 | Skip | 0 | Off | 0 |
| 8 | 1 | 0+64+32+16+0+4+0+1 = 117 is equivalent to 117 | Add | 1 | On | 1 |
Once the above comparison is done on the rough paper: -
- To write the given number in decimal format, sum all the values of the decimal field and write the result. In this example, it would be 0+64+32+16+0+4+0+1 = 117.
- To write the given number in binary format, write all the values of the binary field from left to right. In this example, it would be 11110101.
To convert a binary number to a decimal number, sum the values of all the bits. Let’s take an example.
Convert the binary number 10101010 to a decimal number.
- Given binary number is 10101010
- Calculation direction is left to Right.
| Bit position | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| position value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| In binary | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |
| Bit status | On | Off | On | Off | On | Off | On | Off |
| If bit status is on, use position value in decimal | 128 | 0 | 32 | 0 | 8 | 0 | 2 | 0 |
The binary number 10101010 is equal to the number 170 (128+0+32+0+8+0+2+0) in the decimal system.
Both an IP address and a subnet mask are composed of 4 octets separated by periods. You can use the above methods to convert all octets individually. Once all four octets are converted, merge them again, separating by periods.

This tutorial is part of the tutorial series "IP Addressing, and Subnetting in Computer Networks Explained with examples". Other parts of this series are the following.
Chapter 01 Introduction to Subnetting
Chapter 02 Network Address Basic Concepts Explained with Examples
Chapter 03 The Subnet Mask and Slash Notation
Chapter 04 Converting Decimal IP Addresses to Binary and Binary to Decimal
Chapter 05 Basic Subnetting in Computer Networks Explained
Chapter 06 Subnetting Tutorial - Subnetting Explained with Examples
Chapter 07 Subnetting Tricks: Subnetting Made Easy with Examples
Chapter 08 FLSM Subnetting and VLSM Subnetting
Chapter 09 VLSM Subnetting Explained with Examples
Chapter 10 VLSM Subnetting Examples and Calculation Explained
Chapter 11 Route Summarization Advantages and Disadvantages
Chapter 12 Supernetting Tutorial: - Supernetting Explained with Examples
Conclusion
Converting a binary number into decimal and vice versa is an essential task. This tutorial introduced an easy-to-follow method for converting IP addresses and subnet masks in both formats. By following the steps explained in this tutorial, you can easily convert any IP address and subnet in both formats.
Author Laxmi Goswami Updated on 2026-05-07