Basics of Binary Numbers

Before we start calculating subnets and talk about IP addressing, let’s first check out some basics of binary calculations. We are all used to work with decimal numbers where we count from 1 to 10. This is easy because we have 10 fingers so we don’t have to count off the top of our head.

In the binary system, we only work with 0 or 1.

0 = Off
1 = On

Let’s look at some examples how we can use binary to create some numbers:

128 64 32 16 8 4 2 1

Above we have 8 bits. The bit on the far left side is called the most significant bit (MSB) because this bit has the highest value (128) . The bit on the far right side is called the least significant bit (LSB) because this one has the lowest value (1).

So how do we convert decimal numbers into binary? Let’s look at some examples.

Decimal to Binary

If we want the decimal number “0” in binary this means we leave all the bits “off”.

128 64 32 16 8 4 2 1
0 0 0 0 0 0 0 0

Let’s take the decimal number 178 and turn it into binary. We do this by starting from the left and then try if each bit “fits” in to make this number:

128 64 32 16 8 4 2 1
1 0 1 1 0 0 1 0

128 + 32 + 16 + 2 = 178.

Here’s another, let’s say we want decimal number 31 in binary. Start from the left and see which bits “fit”:

128 64 32 16 8 4 2 1
0 0 0 1 1 1 1 1

16 + 8 + 4 + 2 + 1 = 31.

Let’s try one more, let’s turn the decimal number 255 into binary:

128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1

128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255.

When we use 8 bits then 255 is the highest decimal number we can create.

Binary to Decimal

Of course we can also do this the other way around. Let’s say we have the following binary numbers:

128 64 32 16 8 4 2 1
1 0 1 1 1 1 1 0

Just add all the decimal values when you see a “1”. In this example that’ll be 128 + 32 + 16 + 8 + 4 + 2 = 190.

Here’s one more:

128 64 32 16 8 4 2 1
0 0 0 1 0 1 1 0

This time we have 16 + 4 + 2 = 22.

When you add an additional bit then the decimal value doubles. For example: 2, 4, 8, 16, 32, 64, 128, etc. This is called the “powers of two”.

See if you can calculate some decimal numbers to binary (and the other way around) yourself.

Tags:


Forum Replies

  1. Rene,

    Great article, I think it’s a good way to teach the beginners about binary numbers.

    Keep this great job!!!

    Hug

  2. I believe your explanation is great.
    thanks

Ask a question or join the discussion by visiting our Community Forum