 ## Back to Basics: Converting Binary to Decimal

Author: Bob Conner          Date: 3/11/19

To subscribe to our blog and receive a weekly summary of the previous week's blog posts go to #https://lnkd.in/eaSbfuj

Introduction

When I taught high school students, they were always intimated about converting from binary to decimal.  But once they relaxed, they quickly picked up the concepts.  So relax and let’s dig in.

Why do we need to know how to convert binary to decimal?  Subnetting!!!!!! We will discuss subnetting in a separate post, but at a 10,000 foot view subnetting gives you the ability to get more networks out of your IPv4 addressing scheme.

Definitions

Decimal

Decimal = base 10, which means there are 10 possible values when we use decimal to count.  Those values are 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.  When we run out of values we repeat them.  Therefore, we go to 10 (repeats 0 and 1), 11 (repeats the 1s), 12 (repeats the 1 and 2)…  Fortunately, you already know decimal.

Binary

Binary = base 2, which means there are only 2 values. Another way to look at it is Bi = 2 as in bicycle (2 wheels), bifocal (2 lenses in your eye glasses), bimonthly (twice per month), binocular (handheld optical instrument with 2 small telescopes side by side)…

Bit

Bit is the smallest unit in the computer world.  It can only have a single value: 1 or 0.  It is designated by a lower case “b”.  For example Gb = Giga bit.  1 = a value of 1 and 0 = a value of 0.

Byte

A byte is 8 bits and is represented by a capital “B”.  For example GB = Giga Byte.

## Conversion

Everything we do in computers is measured in bits or bytes.  Since we know that a byte = 8 bits let’s represent a byte as follows:

X X X X X X X X (8 Xs)

We also know that a bit can only be a 1 or a 0. So let’s change our Xs to 0s

0 0 0 0 0 0 0 0 (8 zeros)

We could have also represented a byte as all 1s

1 1 1 1 1 1 1 1 (8 ones)

Finally, we can do a combination of 1s and 0s to represent a byte:

1 0 1 0 1 0 1 0 (4 ones and 4 zeros)

When converting from binary to decimal, the position of the 1s and 0s has a big impact.  Therefore, each position in a byte equals a specific decimal number as follows:

Decimal Value 128      64        32        16        8          4          2          1

Binary Value        1        1         1          1        1          1          1          1

Thus, wherever you see a 1 in the binary row you add the decimal value that is above the 1.  If you see a 0 in the binary row then you skip the decimal value that is above the 0.

Therefore,

Decimal Value 128      64        32        16        8          4          2          1

Binary Value        0        0          0          0        0          0          0          0

= 0 because there are no binary 1 values.

Decimal Value 128      64        32        16        8          4          2          1

Binary Value        0        0          0          0        0          0          0          1

= 1 because there is a binary 1 under the decimal 1.

Decimal Value 128      64        32        16        8          4          2          1

Binary Value        0        0          0          0        0          0          1          0

= 2 because there is a binary 1 under the decimal 2.

Decimal Value 128      64        32        16        8          4          2          1

Binary Value        0        1         0           0        0          0          0          0

= 64 because there is a binary 1 under the decimal 64.

Now, here is where it becomes tricky. Obviously, there are more than 8 decimal values (1, 2, 4, 8, 16, 32, 64. 128). Therefore, if we have multiple binary 1s, then we add the decimal values together for each place there is a binary 1.  For example:

Decimal Value 128      64        32        16        8          4          2          1

Binary Value        0        0          0          0        0          0          1          1

= 3 because we have a binary 1 under the decimal 1 and a binary 1 under the decimal 2.  Therefore we add decimal 1 and decimal 2 together to get 3

Decimal Value 128      64        32        16        8          4          2          1

Binary Value        0        1          0          0        0          0          1          1

= 67 because we have a binary 1 under the decimal 1 and a binary 1 under the decimal 2 and a binary 1 under 64.  Therefore, we add decimal 1, decimal 2 and decimal 64 together.

Here is one more

Decimal Value 128      64        32        16        8          4          2          1

Binary Value       0        0          0          1        0          1          0          0

= 20 because we have a binary 1 under the decimal 16 and a binary 1 under the decimal 4.  Therefore, we add decimal 16 and decimal 4 together.

So, in a byte the maximum decimal value = 255 (11111111) and the minimum decimal value = 0 (00000000).  Question – How many different combinations are there?  The answer is below.

Now let’s watch a 3 minute video by Abigail Bornstein (LinkedIn Account) as she describes how to convert from binary to decimal.

Now let practice with converting 25 binary combinations to decimal.  The answers are below.

1)      00001110

2)      11111100

3)      01001010

4)      10000011

5)      01101110

6)      11101010

7)      10101101

8)      01010000

9)      11111010

10)  11100010

11)  11011101

12)  11010101

13)  01001101

14)  1110 (Start from right to left – same as 00001110)

15)  11001010

16)  11100100

17)  101011

18)  1100101

19)  10000

20)  1011111

21)  11011

22)  100

23)  1000001

24)  11111

Did you answer there were 255 possible values between binary 00000000 (0 Digital) to 11111111 (255 digital)?  If you did you were wrong.  There are 256.  00000000 (0 Digital) counts as a value.

1)   00001110 = 14

The number 14 can be expressed as: 8 + 4 + 2

2)    11111100 = 252

The number 252 can be expressed as:  128 + 64 + 32 + 16 + 8 + 4

3)    01001010 = 74

The number 74 can be expressed as: 64 + 8 + 2

4)    10000011 = 131

The number 131 can be expressed as: 128 + 2 + 1

5)    01101110 = 110

The number 110 can be expressed as: 64 + 32 + 8 + 4 + 2

1101110 is the same as 01101110  as you can always drop the leading 0s (the 0s on the left hand side).

6)    11101010 = 234

The number 234 can be expressed as: 128 + 64 + 32 + 8 + 2

7)    10101101 = 173

The number 173 can be expressed as: 128 + 32 + 8 + 4 + 1

8)    1010000 = 80

The number 80 can be expressed as: 64 + 16

1010000 is the same as 01010000 as you can always drop the leading 0 (the 0s on the left hand side).

9)    11111010 = 250

The number 250 can be expressed as: 128 + 64 + 32 + 16 + 8 + 2

10)  11100010 = 226

The number 226 can be expressed as: 128 + 64 + 32 + 2

11)  11011101 = 221

The number 221 can be expressed as: 128 + 64 + 16 + 8 + 4 + 1

12)  11010101 = 213

The number 213 can be expressed as: 128 + 64 + 16 + 4 + 1

13)  1001101 = 77

The number 77 can be expressed as: 64 + 8 + 4 + 1

1001101 is the same as 01001101 as you can always drop the leading 0 (the 0s on the left hand side).

14)  1110 = 14

The number 14 can be expressed as: 8 + 4 + 2

1110 is the same as 00001110 as you can always drop the leading 0s (the 0s on the left hand side).

15)  11001010 = 202

The number 202 can be expressed as: 128 + 64 + 8 + 2

16)  11100100 = 228

The number 228 can be expressed as: 128 + 64 + 32 + 4

17)  101011 = 43

The number 43 can be expressed as: 32 + 8 + 2 + 1

101011 is the same as 00101011 as you can always drop the leading 0s (the 0s on the left hand side).

18)  1100101 = 101

The number 101 can be expressed as: 64 + 32 + 4 + 1

1100101 is the same as 01100101 as you can always drop the leading 0s (the 0s on the left hand side).

19)  10000 = 16

The number 16 can be expressed as:16

10000 is the same as 00010000 as you can always drop the leading 0s (the 0s on the left hand side).

20)  1011111 = 95

The number 95 can be expressed as:64 + 16 + 8 + 4 + 2 + 1

1011111 is the same as 01011111 as you can always drop the leading 0s (the 0s on the left hand side).

21)  11011= 27

The number 27 can be expressed as:16 + 8 + 2 + 1

11011 is the same as 00011011 as you can always drop the leading 0s (the 0s on the left hand side).

22)  100 = 4

The number 4 can be expressed as: 4

100 is the same as 00000100 as you can always drop the leading 0s (the 0s on the left hand side).

23)  1000001 = 65

The number 65 can be expressed as: 64 + 1

1000001 is the same as 01000001 as you can always drop the leading 0s (the 0s on the left hand side).

24)  11111 = 31

The number 31 can be expressed as: 16 + 8 + 4 + 2 + 1

11111 is the same as 00011111 as you can always drop the leading 0s (the 0s on the left hand side).

25)  10100110 = 166

The number 166 can be expressed as:
128 + 32 + 4 + 2