fbpx

How To Convert Decimal To Binary

In this article, I will look at converting decimals to binary, hexadecimal and also look at the operation called “and.” These skills are important to learn when you start dealing with IP addresses. If your career starts taking you more towards the networking side of things, understanding how to convert numbers between different formats becomes essential to creating and managing a network.

What Is Decimal

When you think of the word “decimal,” you might think about a dot. This dot is called a decimal point, and it separates parts of a whole number from the whole number. These parts are called decimals. A decimal is a number less than 1. Whole numbers — also called units — are greater than or equal to 1. The decimal point basically signifies “and” as a way to separate these two different kinds of numbers.

Decimals are found to the right of the decimal point, and units are found to the left of the decimal point. If you want to write out four whole units and 12 decimal parts, it will look like this.

What Is Decimal

What Is Decimal

You can read this as “four point one two” or as “four and twelve one-hundredths.” The decimal number system is based on preceding powers of 10. This means it’s a series of numbers where each number is ten times bigger or smaller than the last.

If we move to the left of the decimal point, each position is 10 times bigger. If we move to the right, each position is 10 times smaller. When we encounter decimals in everyday life, from money to distance to time, we usually only take into account the tenths and hundredths place values. And now you know how to work with decimals!

Math Basics Decimals

Math Basics Decimals

What Is Binary

The regular number system that we’re used to is called decimal. It uses ten numbers, zero-nine. We can create any number, no matter how large, by just using these smaller numbers. Binary works the same way but only uses 2 numbers, zero and one.

Start counting… and once we hit the number 9, we’ve run out of numbers. So we set the number back to zero and then add one on the left to make 10. This can ripple through any number of digits. When we reach 99, we set both of them back to zero and then add one on the left.

What Is Binary

What Is Binary

With binary numbers, we do the same thing, but of course, we run out of numbers a lot faster. We go zero, one, and at this point, we change it back to zero and add a one on the left. This is a two in binary.

 

Convert Decimal To Binary

In computing, you have switches which can either be set to on or off. This gives you 2 possible values. To allow you to represent larger numbers computers group these switches together. The most common one you will deal with is a byte which is 8 bits.

A byte has a value of 0 to 255. To convert a decimal to a binary, I use the following table. Each bit in the table has a value assigned to it. You can see, going from right to left the first value has a 1 in the first position. The second position has a value of 2. Twice the previous value.

Convert Decimal To Binary

Convert Decimal To Binary

The 3 position has a value of 4. As you can see the value doubles in each position until the final value of 128. If I took a random number, say 174 and wanted to convert it into binary, I would do the following.

First I would go to bit 8 and work out if 174 is greater or equal to 128. If 174 is greater than 128, which it is, the result is a 1. I would then subtract 128 from 174 and place the result, 46 in the next column.

The next column has a value of 64. 46 is not greater than 64, so the result is no and gets a value of 0. I now move 46 to the next column and compare it with its value of 32. 46 is greater than 32, so I place a one in this column and subtract 32 from 46 to give me 14. I keep following the same procedure throughout the table.

Decimal To A Binary Table

Decimal To A Binary Table

You will notice that when I get to the second last column, the value 2 equals the column value. In this case, the value is equal to the column value, and thus the result is still a one. All columns after this will equal zero since there is no remainder to subtract from the column value. This gives us a binary value of 1 0 1 0 1 1 1 0. Using this method you can quickly and easily convert any decimal number into a binary number.

Decimal To Hexadecimal

With IP version 6, hexadecimal is used in the IP address, so you need to have an understanding of it to master IP version 6. If I were to take an IP version 4 address and convert to hexadecimal, I would do the following. First of all, I would convert the numbers into binary using the previously shown method.

Decimal To Hexadecimal

Decimal To Hexadecimal Table

Once the numbers are in binary, they are easier to work with. The next step is to divide the binary into groups of four. Dividing the bits up like this gives each group of 4 bits 16 different possible values. Hexadecimal uses 16 values, and thus that is where hexadecimal gets its name from.

It is a simple matter to convert these values into decimal values. As you can see each group of 4 bits has been given a value between 0 and 15. Once you have this value, you can use this table to determine the hexadecimal value. As you can see the first value 12 and gets a value of C. Values between 0 and 9 get the same value so therefore the values in the example 0, 9, 1, 1 and 3 all get the same values. It is not till we get too far right you see the value 14 will get the value of E, and the value 10 will get the value of A.

Certain IP version 6 addresses have IP version 4 addresses embedded in them. It is important to understand how to convert decimal to hexadecimal to understand IP version 6 addresses.

How The “and” Operator Works

Once you start working with more than one network, it is important to understand how the “and” operator works. Consider this table. When comparing two bits, if both bits are 1 the result is a one. You will notice that in all other cases the results is zero. All it takes is one or both bits to be zero and the result it zero. If you have trouble understanding this, think of the “and” operator as a multiplication operator instead. 1 times 1 is 1. 1 times 0 is 0. 0 times 1 is 0 and 0 times 0 is 0.

How The “and” Operator Works

How The “and” Operator Works

Later in the course, you will learn the “and” operator is used to determine the destination of a packet. Consider this small network. If a computer sends data over the network to a server, the computer needs to determine if the data is to be sent directly to the server or the data needs to be sent via a router.

If the server is on the same network as the client, it sends it directly to the server. If the server is on another network, the client computer sends the data to a router. By using the “and” operator, your computer can work out where to send the data.

Network To A Server

Network To A Server

Later on, in the blog, this process will be explained in more detail. This has been a short induction to converting decimals. If you don’t work a great deal on the networking side, you may want to consider using the windows calculator to convert decimals to hexadecimal and binary for you. Just remember to switch the calculator to scientific mode first. Before sitting for your exam, check the exam requirements.

A lot of the exams will allow you to use the windows calculator in the exam. If you are planning to sit any Cisco exams, you need to have an excellent understanding of how to convert decimals. Cisco doesn’t give you a calculator in the exam to help you and believe me, and you need to do the math fast.

Lastly, if you need more practice, there are a lot of resources on the internet. When I was first learning networking, I used a website called Learn To Subnet.

This is a great little site that will help you understand how to convert decimals to binary and also how to subnet. I will cover subnetting in more detail later in the blog. So don’t worry if you don’t understand it yet. For the present just make sure you understand the basics of binary and hexadecimal. If you don’t understand how to convert values, you can also cheat for the moment and use the windows calculator.

We will be happy to hear your thoughts

Leave a reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.