Little IT school - Lesson 2

 

 

 

 

Converting decimal numbers into binary ones 

Decimal numbers are numbers based on number 10. Each figure in some decimal number is a multiplier of number 10 to the power of some number. What does it mean? Here is an example: 

number 345  = 3*100 + 4*10 + 5*1 = 3* 10+ 4*101 + 5*10 

 105=100 000

 

 

 104=10 000

 

 

 103=1 000

 

 

 102=100

 

 

 101=10

 

 

 100=1

 

 

Each figure multiplies the power of number 10 for given position in the whole number and by adding these values we get final value. When we use decimal numbers we find it quite usual so that we don’t think about how they are formed. Since it is decimal system (decimal means 10) then we use figures from 0 to 9 (which there are 10 altogether) as multipliers. 

It is similar with binary numbers with the difference that we use number 2 as a base and the powers of number 2, as well as figures 0 and 1 which are used as multipliers for the position in the number. Binary means 2, so we use first two numbers, i.e. 0 and 1. Here are the values of different positions in a binary number: 

 27=128

 

 

 26=64

 

 

 25=32

 

 

 24=16

 

 

 23=8

 

 

 22=4

 

 

 21=2

 

 

 20=1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Here is an example: 

Binary number 0000 0001 is actually number 1 (decimal)
0*128 + 0* 64 + 0* 32 + 0*16 + 0*8 + 0* 4 + 0* 2 + 1*1 = 1  

 27=128

 

 

 26=64

 

 

 25=32

 

 

 24=16

 

 

 23=8

 

 

 22=4

 

 

 21=2

 

 

 20=1

 

 

 0

 

 

 0

 

 

 0

 

 

 0

 

 

 0

 

 

 0

 

 

 0

 

 

1

 

 

Binary number 0000 0101 is actually number 5 (decimal)
0*128 + 0* 64 + 0* 32 + 0*16 + 0*8 + 1* 4 + 0* 2 + 1*1 = 4 + 1 = 5 
 

 27=128

 

 

 26=64

 

 

 25=32

 

 

 24=16

 

 

 23=8

 

 

 22=4

 

 

 21=2

 

 

 20=1

 

 

 0

 

 

 

 

 0

 

 

 0

 

 

 0

 

 

 1

 

 

 

 

1

 

 

Here is the method how we transform decimal numbers into binary ones: 

*We will take number 9 decimal as first example. We divide it by number 2 and write down the rest after divisin, which is number 1, and this number 1 will be the first number on the right side of the binary number. 

9/2 = 4 and the rest 1 

The result of division, is divided again by 2 

4/2=2 and the rest is 0  

Again, the result is divided by 2

2/2=1 and the rest is 0 

1/2 = 0 and the rest is 1 

So, our decimal 9 is 1001 binary (we take the rest numbers from above to the bottom and write them from the right side to the left side) 

*Second example will be decimal number 14 

14/2=7 and the rest is 0 

7/2=3 and the rest is 1 

3/2= 1 and the rest is 1 

1/2 = 0 and the rest is 1 

14 decimal is = 1110 binary  

Let’s check this: 

 27=128 

 26=64 

 25=32 

 24=16

 23=8

 22=4 

 21=2

 20=1

 1 

 1 

1 

0 

     we multiply  upper values with 1 or 0 and sum them all up 

 

 

 

 

 

 

 

 

 

 

 

 

8 

4 

 2

0 

8+4+2+0=14 

This means that we transformed the decimal number into binary one well. 

In this way you can transform any decimal number into binary one. Whatever we enter into a computer, it transforms it into binary numbers because they are convenient for processing inside digital devices. 

A new lesson soon - Building a virtual computer and then, its programming!