Binary, Hex and Decimal Conversion

hex to decimal, binary to decimal, decimal to hex, decimal to binary notation conversions, calculations

In computer networking we use different numbering systems for different purposes. These numbering systems are binary, decimal and hex numbering systems. Here binary numbering is especially important for ip address subnetting calculations, hexadecimal numbering is important for ipv6 addressing and decimal numbering is important for ipv4 addressing and other parameter configurations.  In other words, even the language of computers is binary, we use the other two numbering systems especially for ip addressing and for other configuration values. In this lesson, we will focus on these numbering systems and we will learn how to convert hex to decimal, decimal to hex, decimal to binary and binary to decimal conversion. First of all, let’s explain these numbering systems one by one.

 


Subnetting Cheat Sheet Is Useful For This Lesson! FREE DOWNLOAD Subnetting Cheat Sheet!


hex to decimal, binary to decimal, decimal to hex, decimal to binary notation conversions, calculations

What is Decimal, Binary and Hexadecimal Notation?

Decimal numbering is the classical numbering system that we use in real life. We create new numbers with the digits from 0 to 9. The other name of this systems is decimal notation. It is also known as base-10. For example, 5, 145, 12678 are decimal notation examples.

 

Binary notation is the numbering system uses by computers. It uses only 0 and 1 digits or bits to create new numbers. In computer networking these values indicates voltage values. In other words, 1 means flow of electricity, while 0 represents no flow of electricity. We can give 10010, 1001, 1011111 as binary notation examples. Binary numbers is very important especially for ip subnetting.

 

Hexadecimal notation, or simply hex is the numbering system based on sixteen symbols including numbers from 0 to 9 and letters form A to F. Here, numbers show the same values but letters from A to F represents the values from ten to fifteen. For example, A451, 84AAFF, 5934BC45 can be hexadecimal number examples. In computer networking hex numbers are used with ipv6 addressing. IPv6 addresses are 128 bits hex numbers.

 

Now, let’s learn how to convert binary to decimal, decimal to binary, hex to decimal and decimal to hex with different examples.

 


How to Convert Hex to Decimal?

We have learned how to convert decimal to hex. Now, it is time to learn the reverse of it hex to decimal conversion. Hexadecimal numbers are used for IPv6 addresses in computer networking. Each IPv6 address is a 128 bits hexadecimal number.

 

To convert a hexadecimal number to a decimal number, we should know the place values of each digit.  Starting from the rightmost digit, the place values are 16^0, 16^1, 16^2, 16^3, 16^4 etc. We multiple each place value with the number on that digit. If this digit is a number from 0 to 9, you can use this value. But if it is a letter from A to F, before multiplication, you should convert it to a decimal equivalent. For example, for F, you should use 15.  After that, you can add each multiplication to find the decimal equivalent of that hex number.

 

Let’s do this conversion for 00D0. To convert this hex value to its decimal equivalent, we should multiple the place values with the digits and then we will add them to find the toral number.

 

(16^0) x 0 + (16^1) x D + (16^2) x 0 + (16^3) x 0

0 + 16 x 13 + 0 + 0 = 208

 

The decimal equivalent of 00D0 is 208.

 

Let’s do a second example with the hex number 12F8.

 

hex to decimal notations conversion calculation

 

(16^0) x 8 + (16^1) x F + (16^2) x 2 + (16^3) x 1

[1 x 8] + [16 x 15] + [256 x2] + [4096 x1]

8 + 240 +512 + 4096 = 4856

 

The decimal equivalent of hex 12F8 is 4856.

 

You can test yourself with hexadecimal to decimal conversion questions at the end of this lesson.

 


How to Convert Decimal to Hex?

To convert a decimal number to a hexadecimal number, we should divide the given decimal number by 16 every time and note the reminder as a new hex digit. Let’s do an example to show this conversion to you better.

 

We have 208 decimal number. Let’s convert this decimal to a hex number. We will divide the given number by 16 every time and note remainders. If remainder is higher than 9, we will use its letter value in hexadecimal notation.

 

208 / 16 = 13 (remainder = 0)

13 / 16= 0 (remainder =13), 13 = D

 

If we express the result with two digits, the result is D0. If we represent it with four digits, the result is 00D0.

 

Let’s do another example for decimal to hex conversion. Our decimal number is 4856.

 

decimal to hex notations conversion calculation

 

4856 / 16 = 303 (remainder = 8)

303 / 16 = 18 (remainder =15), 15 = F

18 / 16 = 1 (remainder= 2)

1 / 16 = 0 (remainder 1)

 

When we write down the remainder values beginning from the first digit, the hexadecimal equivalent of 4856 is 12F8.

 

You can test yourself with the below decimal to hex questions at the end of this lesson.

 

 


How to Convert Decimal to Binary?

Converting decimal numbers to binary numbers are important for ip addressing and subnetting especially. When we calculate available addresses with a given subnet mask, we convert decimal numbers to binary numbers and decide required bits.

To convert decimal to binary notation, you should divide the given number by 2 every time. At each step, you should write down the remainder as a new digit of the binary notation beginning with the first digit.

 

For example, let’s convert decimal 8 to its binary value. To convert decimal to binary, we should divide the given number, 8, by 2 every time. We will write down the remainders beginning with the first digit.

 

8 / 2 = 4 (remainder = 0)

4 / 2 = 2 (remainder = 0)

2 / 2= 1 (remainder = 0)

1 / 2 = 0 (remainder = 1)

 

When we write down the remainders form the first digit, the result is 1000. This is the binary equivalent of decimal 8.

 

Let’s give another example for decimal to binary conversion. This time our decimal number is 145.

 

decimal to binary notations conversion calculation

 

145 / 2 = 72 (remainder = 1)

72 / 2 = 36 (remainder = 0)

36 / 2 = 18 (remainder = 0)

18 / 2 = 9 (remainder = 0)

9 / 2 = 4 (remainder = 1)

4 / 2 = 2 (remainder = 0)

2 / 2 = 1 (remainder = 0)

1 / 2 = 1 (remainder = 1)

 

The result is 10010001.

 

At the end of this lesson, you can find decimal to binary conversion questions to practice more.

 


How to Convert Binary to Decimal?

After converting decimal to binary, now, let’s learn the reverse of this, binary to decimal conversion. Here, we can use the same examples above to show you also how to check your conversions.

 

For the first example, we have a binary number, 1000, and we will convert it to decimal notation. To do this, we will add the value of each bit that is 1. Here, each bit has special place value beginning from 1 and continues as 2^0, 2^1, 2^2, 2^3, 2^4, 2^5, 2^6, 2^7 and 2^8. In other words, their values are 2, 4, 8, 16, 32, 64 and 128.

 

Let’s write down the value of each digit.

 

1, 2, 4, 8.

 

Here, only the last bit is 1. So, we can only take its value for our decimal number. And it is 8. So, 8 is the decimal value of 1000.

 

Now, let’s do a more complex calculation with the second example. Our number is 10010001. Beginning with the least values digit (at the right side), the value of each bit is 1, 2, 4, 8, 16, 32, 64 and 128. So, for this binary number, the sum of the bit values will be like below:

 

binary to decimal notations conversion calculation

 

128 + 16 + 1 = 145

 

At the end of this lesson, you can find binary to decimal notation conversion questions to practice more.

 


Summary

In this lesson, we have learned how to convert hex to decimal notation, decimal to hexadecimal numbers, binary to decimal and decimal to binary numbers. If you do more practice on these lessons, you will be more familiar with these calculations. Below, you can find questions for to practice decimal, binary and hexadecimal conversions.

 


FREE DOWNLOAD Subnetting Cheat Sheet!


 

 

 

Lesson tags: numbering, decimal, IPv6, ip addressing, IPv4, binary, hexadecimal
Back to: CCNA 200-301 v1.1 > IPv4 Addressing

Leave a Reply

Your email address will not be published. Required fields are marked *

CCNA 200-301 v1.1

Collapse
Expand
Latest Blog Posts