Decimal to Binary:

Binary seems intimidating, I know. It’s just so different to what we’re used to. Luckily though it’s not actually that hard, so in this tutorial I will teach you how to convert decimal to binary, and my next guide will be the other way around.

The first thing to know is that a single binary digit is called a “bit”, and they are normally grouped in eights, called “bytes”. An example of a byte is “01000101“. There are 256 combinations of bits from one byte, so the biggest number that can be stored is 255 (one of the combinations is zero).

Let’s move on to how to convert a number from decimal to binary. I’m going to get a random number from google that we can work out together.

image

176, thank you google.

I start by writing out what each bit is worth if it is 1 as headings in a table. Counting from the right, each bit is worth double the last one, counting from 1. This gives me the following table:

image

Now we start reading from the left. If the heading we are on can be subtracted from the number we are trying to convert and give a result above 0, we put a one in that heading, otherwise we put a 0.

That is very wordy so I’ll show you instead. 176 - 128 = 48, so we put a 1 there:

image

After the last calculation we are left with 48. 48 - 64 = -16, so we put a 0 in that column.

image

We still have 48. 48 - 32 = 16.

image

16 - 16 = 0, so we put a 1. We are left with nothing, so we know the rest of the bits are going to be 0.

image

Our byte is 10110000.

And Vice Versa:

So know you know how to convert to binary, but how do you convert from binary to decimal? The short answer is you do the opposite.

For this we’re going to use the same byte we just worked out (10110000). Write out our byte, then write the headings on top.

image

Now we add all of the headings of ‘on’ bits together. We work out 128 + 32 + 16 which gives us an answer of 176.

Practice:

I cannot stress enough how useful practice is for learning this, so here are some practice questions. Once you’ve finished you can look up the answers online to check.

  1. 129 to binary
  2. 10100010 to decimal
  3. 255 to binary
  4. 254 to binary
  5. 00100011 to decimal

If you have any questions feel free to contact me and ask and I’ll help as much as I can.