BINARY

TOPIC 01 – DECIMAL NUMBERS IN BINARY

 

 

LESSON NOTE

 

 

SCIENTIFIC NOTATION FOR BASE 10

 

You have seen numbers expressed in their scientific notation (SN) form. 

 

Let's consider the SN of the number 4238 in base 10.

 

423810 = 4 x 1000 + 2 x 100 + 3 x 10 + 8 x 1

 

And we can also write the above with powers

 

423810 = 4 x 103 + 2 x 102 + 3 x 101 + 8 x 100

 

Of course, the powers all have a base of 10 because we are in base 10.

SCIENTIFIC NOTATION FOR BASE 2

Scientific notation works the same way for base 2.  And its use helps us convert numbers from one base to another.

 

Let's consider the SN of the number 1100 1011 in base 2.

1100 1011
2 = 1 x 128 + 1 x 64 + 0 x 32 + 0 x 16 + 1 x 8 + 0 x 4 + 1 x 2 + 1 x 1


or using powers

1100 1011
2 = 1 x 27 + 1 x 26 + 0 x 25 + 0 x 24 + 1 x 23 + 0 x 22 + 1 x 21 + 1 x 20

DECIMAL NUMBERS IN BASE 10

 

We can also express decimal numbers using scientific notation.

Let's consider the SN of the number 48.7325 in base 10.

 

48.732510 = 4 x 10 + 8 x 1 + 7 x 0.1 + 3 x 0.01 + 2 x 0.001 + 5 x 0.0001

 

or using powers

 

48.732510 = 4 x 101 + 8 x 100 + 7 x 10-1 + 3 x 10-2 + 2 x 10-3 + 5 x 10-4


DECIMAL NUMBERS IN BASE 2

Decimal numbers in base 2 can also be expressed in the same way using SN.

 

Let's consider the SN of the number 1010.0111 in base 2

 

We will start with powers this time and then use decimal numbers.


1010.0111
2 = 1 x 23 + 0 x 22 + 1 x 21 + 0 x 20 + 0 x 2-1 + 1 x 2-2 + 1 x 2-3 + 1 x 2-4

and with decimal numbers


1010.0111
2 = 1 x 23 + 0 x 22 + 1 x 21 + 0 x 20 + 0 x 0.5 + 1 x 0.25 + 1 x 0.125 + 1 x 0.0625

 

CONVERTING DECIMAL NUMBERS FROM BASE 2 TO BASE 10

This is easy.  We simply use the scientific notation like above and then multiply and add the values together in base 10.

 

Example – Convert 110.1012 to base 10.

Solution:

110.101
2 = 1 x 22 + 1 x 21 + 0 x 20 + 1 x 2-1 + 0 x 2-2 + 1 x 2-3

 

Of course, we can simply ignore the zeros giving us this:


110.101
2 = 1 x 22 + 1 x 21 + 1 x 2-1 + 1 x 2-3

 

And instead of powers, we can use actual numbers giving us this:


110.1012 = 1 x 4 + 1 x 2 + 1 x 0.5+ 1 x 0.125

 

And since all multiplications are by 1, we can just add the numbers up.


110.1012 = 4 + 2 + 0.5+ 0.125 = 6.625

 

THE CHART APPROACH

 

The following chart approach is a quick way of converting from base 2 to base 10 and works the same way as the above scientific notation approach.
 



 

 

 

 

 

 

 

23

22

21

20

2-1

2-2

 

We simply place the binary number at the top and add up the powers that line up with the 1s.  The powers can also be replaced by their actual value.

 

Example – Convert the number 10001.0112 to base 10.

Solution:

 

1

0

0

0

1

0

1

1

16

8

4

2

1

0.5

0.25

0.125

 

Therefore, the answer is 16 + 1 + 0.25 + 0.125 = 17.375

 

CONVERTING DECIMAL NUMBERS FROM BASE 10 to BASE 2

 

To convert decimal numbers from base 10 to base 2, we simply apply the chart method from above in reverse order.

 

Example – Convert the number 11.87510 to base 2.

 

The largest power of 2 that is smaller then 11.875 is 8.  So we will start there.  We aren't sure how long our chart has to be though so we will end it with … for now and extend it if necessary.

 

 

 

 

 

 

 

 

 

 

8

4

2

1

0.5

0.25

0.125

 

Let's get started. 


STEP 1 - There is an 8 in 11.875.  So we add a 1 above the 8 in the chart.  We now have to convert the remaining amount of 11.875 – 8 = 3.875.

 

STEP 2 – There is no 4 in 3.875.  So we add a 0 above the 4.

STEP 3 – There is a 2 in 3.875.  So we add a 1 above the 2 and remove that amount from 3.875 to get 1.875 left to work with.

STEP 4 – There is a 1 in 1.875.  So we add a 1 above the 1 and remove that amount from 1.875 to get 0.875.

 

UPDATE – This is how the chart looks like so far with the added material shown in red:

 

1

0

1

1

 

 

 

 

8

4

2

1

0.5

0.25

0.125

 

STEP 5 – We continue is the same way.  There is 0.5 in 0.875.  So we add a 1 above 0.5 in the chart and remove that from our number leaving us with 0.375.

 

STEP 6 – There is 0.25 in 0.375.  So we add a 1 over 0.25 and that leaves us with 0.125.

STEP 7 – There is 0.125 in 0.125.  We put a 1 over 0.125 and we are left with 0.  So we are done.

 

The final result in the chart is as follows:

 

1

0

1

1

1

1

1

8

4

2

1

0.5

0.25

0.125

                                                  

The answer is 1011.111.

 

INFINITE DECIMAL EXPANSIONS

 

It is important to note that numbers that have finite decimal expansions in base 10 do not necessarily have finite decimal expansions in base 2.

 

Example – Convert 0.110 to base 2.

Let's start with a chart.

 

 

 

 

 

 

 

 

1

0.5

0.25

0.125

0.0625

                                                  

 

STEP 1 – The value 1 goes into 0.1 zero times.  So we put 0 above the 1.

STEP 2 – The value 0.5 goes into 0.1 zero times.  So we put 0 above the 0.5.

STEP 3 – The value 0.25 goes into 0.1 zero times.  So we put 0 above the 0.25.

STEP 4 – The value 0.125 goes into 0.1 zero times.  So we put 0 above the 0.125.

STEP 5 – The value 0.0625 goes into 0.1 one time.  So we put 1 above 0.0625 and we are now left with 0.0375.

UPDATE – Here is what the chart looks like so far.  Other columns have also been added as we are not done.

 

 

0

0

0

0

1

 

 

 

1

0.5

0.25

0.125

0.0625

0.03125

0.015625

0.0078125

                                                  

 

STEP 6 – The value 0.03125 goes into 0.0375 one time. So we put 1 above 0.03125 and we are left with 0.00625.

STEP 7 – The value 0.015625 goes into 0.00625 zero times.  So we put 0 above 0.015625.

STEP 8 – The value 0.0078125 goes into 0.00625 zero times.  So we put 0 above 0.0078125.

 

UPDATE – Here is the chart so far:


0

0

0

0

1

1

0

0

 

1

0.5

0.25

0.125

0.0625

0.03125

0.015625

0.0078125

0.00390625

                                                  

STEP 9 – The value 0.00390625 goes into 0.00625 once.  So we put a 1 over 0.00390625 and we are left with 0.00234375.

 

So, so far we have 0.00011001 and we are not done.  And, the numbers are getting messy to work with. 

 

It turns out that the decimal expansion is the following: 0.00011001100110011001100110011001100110011001100110011001100110...