IP Addressing Series – Part 5: Binary Conversion for Networking
Binary Conversion for Networking – Learn How to Convert from Decimal to Binary and Binary to Decimal
Understanding the Concept of Binary Conversion
In Networking, devices communicate using numbers. Computers and networking devices use the binary number system, while humans use the decimal numbers to process information.
Binary is the language of computers. Every single task performed by a computer, like Sending data over network, Opening websites, File transferring and process any kind of information, all represented using only two digits which are 0 and 1.
These digits are known as binary digits or bits.
In this blog, we will learn binary number system in depth and understand how to convert decimal to binary and binary to decimal, also understanding its role in networking using some examples.
Let’s understand what is Binary Number System?
The Binary number system is a base-2 number system that defines it only uses two digits:
- 0
- 1
All binary numbers rely on 0 and 1, while decimal number system uses base-10.
Every single digit in a binary number system is called a bit.
A bit is the smallest unit of data in a computer or networking, it uses only two digits unlike decimal number system, which uses ten digits from 0 to 9.
The binary number system uses only two values to represent all data and information such as:
101010
This binary number contains six bits because it consists of six binary digits. Computers use binary because electronic circuits easily represent these two states:
- ON = 1
- OFF = 0
These two states match with the binary digits 1 and 0. Since computers naturally work with these two states because binary is the perfect language for digital systems.
What are Bits and Bytes?
Bits and bytes are two basic terms that are used in computers and networking.
Bits
A bit is the tiniest unit of data in a computer, it can have only one of two values:
- 0
- 1
Example
- 0
- 1
- 1001
- 1100
- 1101
These are the combinations of bits.
Byte
A group of 8 bits is called a byte. Bytes are used to calculate and classify data in computer networking.
Example:
11000000
This binary number having 8 bits, so collection of 8 bits is called one byte.
A single byte describe 256 values which range from 0 to 255. In IPv4 addresses, every octet contain one byte.
Why are Binary Numbers Essential in Networking?
Humans read and write IP addresses in decimal numbers but computers and networking devices use binary numbers (0s and 1s).
Let’s understand some key points:
- Data is converted into binary so that the device can understand and process it easily.
- Data is convert into binary before being sent from one device to another.
- Subnetting is performed using binary values.
- Routers use binary numbers for data packets forwarding.
- CIDR notation is based on binary bits.
- Network address and broadcast address are calculated using binary values.
In simple words, we can say that binary is the basics of networking.
A strong understanding of IP addressing is also helpful for binary conversion.
Binary Place Values
Binary place value means every function in binary number has a fixed value, each position describe a power of 2.
In an 8-bit binary number, the place values are:
128, 64, 32, 16, 8, 4, 2, 1
These values are made by raising 2 to different powers:
- 27 = 128
- 26 = 64
- 25 = 32
- 24 = 16
- 23 = 8
- 22 = 4
- 21 = 2
- 20 = 1
Each position in a binary number can contain 0 or 1,
- If a position contains 1, its value is included in the total.
- If a position contains 0, its value is rejected.
Binary Place Value Table
This table is most important in networking because it explains the basics of binary conversion.
These binary place values used to convert IP addresses and subnet masks from binary to decimal format. By understanding these values, a user can easily convert binary and decimal without the help of a calculator.
Let’s understand:
(11000000) this is the binary number which is equivalent with the place values:
128, 64, 32, 16, 8, 4, 2, 1
1, 1, 0, 0, 0, 0, 0, 0
Only the positive with 1 are counted
128 + 64 = 192
So now:
11000000 = 192.
Convert from Decimal to Binary
For converting decimal number (base-10) into a binary number (base-2), we continuously divide the number by 2 and write down the remainders which is called division by 2 method.
Sample 1: Convert decimal (20) to binary
- 20 ÷ 2 = 10, remainder 0
- 10 ÷ 2 = 5, remainder 0
- 5 ÷ 2 = 2, remainder 1
- 2 ÷ 2 = 1, remainder 0
- 1 ÷ 2 = 0, remainder 1
Now write the remainder from bottom to top:
10100
So:
Decimal 20 = 10100 binary
Sample 2: Convert decimal (30) to binary
- 30 ÷ 2 = 15, remainder 0
- 15 ÷ 2 = 7, remainder 1
- 7 ÷ 2 = 3, remainder 1
- 3 ÷ 2 = 1, remainder 1
- 1 ÷ 2 = 0, remainder 1
Now write the remainder from bottom to top:
11110
So:
Decimal 30 = 11110 binary.
Convert from Binary to decimal
For converting a binary number returning into the decimal number, we multiply every number by its place value and add the results.
This procedure helps to understand the actual value of binary number in the decimal system.
Sample 1: convert 10100 (binary) to decimal
now match the place values
16, 8, 4, 2, 1
1, 0, 1, 0, 0
Now add the 1
16 + 4 =20
So,
10100 = 20 decimal
Sample 2: convert 11110 (binary) to decimal
now match the place values
16, 8, 4, 2, 1
1, 1, 1, 1, 0
Now add the 1
16 + 8 + 4 + 2 =30
So,
11110 = 30 decimal
8-bit Rule in Networking
In IPv4 address, Every IP address on the internet has 4 sections called octets, and each octet contains 8 bits.
This is known as 8-bit rule. Also learn OSI model, it helps understanding in data flow and binary processing.
Example of an IP address:
192.168.1.1
When an octet is converted into 8-bit binary value:
- 192 = 11000000
- 168 = 10101000
- 1 = 00000001
- 1 = 00000001
The IP address 192.168.1.1 Becomes:
11000000.10101000.00000001.00000001
This binary representation is called 8-bit rule in networking. Learn IPv4 in details.
Why the Maximum Value is 255?
Do you know why an IPv4 octets usually range from 0 to 255? The logic behind is binary number system.
Let's understand how:
Maximum 8-bit binary value
The largest 8-bit binary number is:
11111111
Let's convert it into decimal using place values:
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1
= 255
Minimum 8-bit binary value
The smallest 8-bit binary number is:
00000000
All bits are 0, so the value is also
= 0
Now the result is:
- Minimum = 0
- Maximum = 255
So the full range of IPv4 octet is:
0 to 255
Do you know that IPv6 addresses are 128-bit and also use binary representation, read more about IPv6 addresses in details.
Shortcut Method for Quick Binary Conversion
Networking professionals prefer place value method which is a fastest technique.
This procedure is useful for subnetting and IP address calculations. Rather dividing by 2, compare the decimal number with the binary place value.
Example: Convert 15 to binary
Place value table:
128, 64, 32, 16, 8, 4, 2, 1
Now check which values add up to 15
- 128 No because it is equal to 0
- 64 No because it is equal to 0
- 32 No because it is equal to 0
- 16 No because it is equal to 0
- 8 yes because it is equal to 1 (15 -8 =7)
- 4 yes because it is equal to 1 (7 -4 =3)
- 2 yes because it is equal to 1 (3 -2 =1)
- 1 yes because it is equal to 1 (1 -1 =0)
The result is:
00001111
So,
15 (decimal) = 00001111 (binary)
The place value method is much faster than repeated division.
Interview Questions to Remember
Define binary number system?
The Binary number system is a base-2 number system that defines it only uses two digits:
- 0
- 1
All binary numbers rely on 0 and 1, while decimal number system uses base-10.
Why computer systems using binary?
Computer uses binary because electronic circuit easily represent these two states:
- ON = 1
- OFF = 0
Define Bit?
A bit is the smallest unit of data in a computer, it can have only one of two values:
- 0
- 1
Define Byte?
A group of 8 bits is called a byte. Bytes are used to measure and represent data in computer or networking.
For example:
11000000
This binary number having 8 bits, so collection of 8 bits is called one byte.
Why binary number system is important in computer and networking?
Binary is important because:
- Data convert into binary before sending from one device to another
- Subnetting perform using binary values
- Router use binary number for data packets forwarding
- CIDR notation is based on binary bits.
- Network address and broadcast address are calculated using binary values
Write down the binary form of decimal 20?
Binary 10100 = 20 decimal
Write down the decimal form of binary 11110?
16, 8, 4, 2, 1
1, 1, 1, 1, 0
Now add the 1.
16 + 8 + 4 + 2 =30
So,
11110 = 30 decimal.
How many bits are in one octet of IPv4?
In IPv4 address, Every IP address on the internet has 4 sections called octets, and each octet contains 8 bits.
Write down the range of IPv4 octet?
The range of IPv4 octet is:
- Minimum = 0
- Maximum = 255
So the full range of IPv4 octet is:
0 to 255
11111111 = 255
Define Binary place value?
Binary place value means every function in binary number has a fixed value, each position describe a power of 2.
In an 8-bit binary number, the place values are:
128, 64, 32, 16, 8, 4, 2, 1
Write the binary form of 192?
The binary form of 192 = 11000000
Write the difference between decimal and binary number system?
Decimal number system uses base-10 from (0-9) while binary number system uses base-2 (0 or 1).
Conclusion
Binary number system is the most important foundation of computer networking. IP addresses usually written in decimal format for human understanding but network devices uses them in binary format.
In conclusion, we learned about binary number system in depth, how bits and bytes work, and its importance, decimal and binary format. We also explore 8-bit rule used in IPv4.
A solid understanding of binary is essential for learners.
These concepts are basic but advanced topics such as Subnet masks, subnetting, CIDR notations all rely on binary calculations. By learning and with a strong understanding of binary conversion, you are ready to move on to the next topic of your networking journey.
If you found this post helpful and want to learn more topics, subscribe to our blog for more networking basics articles, share your thoughts & queries in comments, and don't forget to check out our latest post.


Comments
Post a Comment