This tutorial explains how to convert a decimal IP address to a binary IP address and a
binary IP address in a decimal IP address step by step with examples. Learn the easiest method to convert a decimal
IP address and subnet mask in binary IP address and subnet mask respectively.

Both an IP address and a subnet mask collectively provide a digital identity to an interface. The two addresses are always used together. Without a subnet mask, an IP address is an ambiguous address, and without an IP address, a subnet mask is just a number.

Both addresses are 32 bits long. These bits are divided into four parts. Each part is known as Octet and contains 8 bits.
The bytes are separated by periods and written in a sequence.

Two popular notations are used to write these addresses, binary and decimal.

In binary notation, the four bytes are written in binary format.

Here are examples of IP addresses in binary notation: –

00001010.00001010.00001010.00001010
10101100.10101000.00000001.00000001
11000000.10101000.00000001.00000001

Here are examples of subnet masks in binary notation: –

11111111.00000000.00000000.00000000
11111111.11111111.00000000.00000000
11111111.11111111.11111111.00000000

In decimal notation, the four bytes are written in decimal format. A decimal equivalent value of the bits is used in each byte.

Here are examples of IP addresses in decimal notation: –

10.10.10.10
172.168.1.1
192.168.1.1

Examples of the subnet mask in decimal notation are: –

255.0.0.0
255.255.0.0
255.255.255.0

In real life, you rarely need to convert an IP address and subnet mask from decimal format to binary format and vice versa. But if you are preparing for a Cisco exam, I highly recommend that you learn this conversion. Almost all Cisco exams have questions about IP addresses. Learning this conversion will help you more effectively resolve issues related to IP addressing.

Understand basic value and position

With the exception of the base value, the binary system works in exactly the same way as the decimal system. The base value is the numbers that are used to construct the numbers in both systems.
In the binary system, two digits (0 and 1) are used to construct the numbers while in the decimal system, ten digits (0,1,2,3,4,5,6,7,8,9) are used to build the Numbers.

In order to convert a number from binary to decimal and vice versa, we need to change the base value. After changing the base value, the resulting number can be written to a new system.

Since the IP address and the subnet mask are both constructed from 32 bits and these bits are divided into 4 bytes,
in order to convert these addresses to decimal binary and vice versa, we only need to understand the numbers that can be constructed from a byte or 8 bits.

A little can be turned on or off. In binary system sure the bit is written 1 and of the bit is written 0 in number.
In the decimal system, if the bit is activated, its position value is added in number and if the bit is deactivated, its position value is ignored in number.

The following table lists the position value of each bit in a byte.

Bit position 1 2 3 4 5 6 seven 8
Position value 128 64 32 16 8 4 2 1
Key points
  • Whichever system we use to write the byte, it always contains the 8 bits. The 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 0 (0 + 0 + 0 + 0 + 0 + 0 + 0 + 0) in decimal system.
  • A number in which all 8 bits are on is written as 11111111 in the binary system. The same number is written 255 (128 + 64 + 32 + 16 + 8 + 4 + 2 + 1) in decimal system.

Converting from a decimal number to a binary number

To convert a decimal number to a binary number, do the following: –

  • 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 approximate area of ​​your spreadsheet. 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 what you wrote in the first step and compare it with the position value of the second bit. If the sum is greater than the position value, ignore the position value. If the sum is less than or equal to the position value, add the position value to sum.
  • Repeat this process until the 8 bits are compared. If the sum becomes equal to any bit, write all the bore bits as 0.
Surgery In decimal In binary
Add Use position value Set the bit to 1
Jump Ignore position value Set the bit to 0

Let’s take an example. Convert a decimal number 117 to binary.

  • The decimal number given is 117
  • The direction of the calculation is From left to right
Bit position position value Comparison Operation in decimal Decimal value Binary operation Binary value
1 128 128 is greater than 117 Jump 0 Of 0
2 64 0 + 64 = 64 is less than 117 Add 64 Sure 1
3 32 0 + 64 + 32 = 96 is less than 117 Add 32 Sure 1
4 16 0 + 64 + 32 + 16 = 112 is less than 117 Add 16 Sure 1
5 8 0 + 64 + 32 + 16 + 8 = 120 is greater than 117 Jump 0 Of 0
6 4 0 + 64 + 32 + 16 + 0 + 4 = 116 is less than 117 Add 4 Sure 1
seven 2 0 + 64 + 32 + 16 + 0 + 4 + 2 = 118 is greater than 117 Jump 0 Of 0
8 1 0 + 64 + 32 + 16 + 0 + 4 + 0 + 1 = 117 equals 117 Add 1 Sure 1

Once the above comparison has been made on raw paper: –

  • To write the number given in decimal format, add all the values ​​in 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 number given in binary format, write all the values ​​in the binary field from left to right. In this example, it would be 11110101.

Converting a binary number to a decimal number

To convert a binary number to a decimal number, add the values ​​of all on bits. Let’s take an example. Convert binary number 10101010 in decimal number.

  • The binary number given is 10101010
  • The direction of the calculation is From left to right
Bit position 1 2 3 4 5 6 seven 8
position value 128 64 32 16 8 4 2 1
In binary 1 0 1 0 1 0 1 0
Bit status Sure Of Sure Of Sure Of Sure Of
If the bit state is activated, use the 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 decimal system.

Practice for you

  • Choose a number between 0 and 255 and convert it to binary.
  • Choose any combination from 00000000 to 11111111 and convert it to decimal.

Converting an IP address and a subnet mask

As we know, the IP address and the subnet mask are both constructed from 4 individual bytes separated by periods. We can use the above methods to convert all bytes individually. Once the four bytes are converted, we can merge them again by separating them by periods.

convert binary to decimal

That’s it for this tutorial. If you have comments, suggestions, and comments on this tutorial, send me an email. If you like this tutorial, don’t forget to share it via your favorite social network.

Author

Write A Comment