Easily Convert Decimal to Binary

convert decimal to binaryComputers and people communicate with each other very easily these days, or at least, that’s how it appears. Software is made to be completely user-friendly, and as such you can now simply type in words and numbers, and your computer will usually know what you mean. The truth is different however, and when you get down to the most basic of languages, your computer really only understands one simple language, binary. Every calculation inside a computer is operated through a series of very small transistors that have two possible states, on and off. These relate in binary language to either a one or a zero, and it’s through using these ones and zeros that your computer can determine the answer to complex calculations very quickly. It’s for this reason that binary is the foundation of all computing – something you can find out about at Udemy from this course.

Humans however work on a decimal system with number from zero to nine, most probably because we all have ten fingers. This makes an interesting dilemma when communicating with computers, because we’re in decimal (base-10), and computers are in binary (base-2). So how do we easily convert decimal to binary?

To answer that question requires that we have a basic knowledge of how base-2 (or binary) works. Once we have that knowledge then it becomes easy to convert decimal to binary, and back again, with a few simple mathematical tricks.

First, you have to remember that in binary there can only ever be two different types of digit, a zero and a one. So, if we start off at the most basic sum of all, 1 plus 1, what do we get? The answer is 2 of course, but in the binary language we cannot use the number 2, we can only use the numbers one and zero, so after 1 we start a new column and use 10. The one denotes how many twos we have, and the zero denotes how many ones we have. 10 = 2 + 0 = 2.

If we add on another one to our sum to make three, we have 11, because we now have one 2, and one 1 to make three. Going on further, if we now add another one to our sum to get four, we run into the same problem again where we run out of digits, so we have to create a third column. So in binary 4 is written as 100. The 1 is the number of fours, and then we have no twos and no ones. 100 = 4 + 0 + 0 = 4. With me so far? If not, you can learn more about binary arithmetic here.

Now, the more astute will have started to notice a pattern here, and that is every time we have to make a new column, is when we hit a power of two. Two to the power of one is 2 of course, and two to the power of two is four. So our next column should be two to the power of three, and then two to the power of four, and so on. So our first eight columns are 128, 64, 32, 16, 8, 4, 2, 1. A number one in any of these columns tells us that the amount that column represents is true. A zero says the amount in that column is false. We can then add up all columns with a one, and get the decimal amount. This is how we would successfully convert a binary number into decimal, (which you can read about here) but we actually want to do the reverse, and easily convert decimal to binary. So here goes…

 

Now that we have an understanding of how the relationship between decimal and binary works, here’s a method to easily convert decimal to binary. All you need is a chart that looks something like this:

128  64  32  16  8  4  2  1

This is basically a reverse list of numbers that are a power of two. You can start from any number that is a power of two that you like, but in this example I’ve started with 128, which is suitable for any number under 256.

Now to begin, take your decimal number and see if you can subtract the first number on the chart without ending up with a negative number. As an example, let’s use the number 188. You can definitely subtract 128 from 188, so put the number 1 underneath 128 on your chart. What are you left with? Well, 188 – 128 is 60, so move along to the next number. Can you subtract 64 from 60. No you cannot, so put a 0 under 64 on your chart.  It’s pretty obvious what we’re doing here, but for arguments sake let’s continue with our method. Can we subtract 32 from 60? Yes, so put a 1 underneath 32. We can subtract 16 from 28, 8 from 12, and 4 from 4, so they all get 1s. Finally we have nothing remaining, so put a 0 underneath remaining numbers.

Your chart should look something like this:

 

128 64  32  16  8   4   2   1

1     0     1     1    1    1   0   0

So the binary for 188 is 10111100

 

With practice you’ll be about to do this in your head. In fact, you can learn more about easy mental arithmetic here. But let’s try another one, so we get the hang of it. What is the binary equivalent of 241?

We can subtract 128 from 241, leaving us 113. We can also subtract 64 from 113, so the first two numbers on our chart receives a 1. We are left with 49, so we can also put a 1 under the number 32, and the number 16. This leaves us with the grand total of 1, so put a 0 under everything else except the 1 at the end. Our chart should look like this:

 

128 64  32  16  8  4  2  1

1     1    1    1   0  0  0  1

So the binary for 241 is 11110001

 

Congratulations, you can now easily convert decimal to binary.  Now that you’ve mastered that, why not try your hand at some advanced math skills with a course on easy advanced math at Udemy.