Sunday, May 19, 2013

Binary Multiplication

You should hopefully have learnt how to multiply numbers together in decimal when you were at primary school. Let's recap:
 12
x 4
 --
  8   =  4*2
 40   =  4*10
 --
 48
And with a more complicated example:
 12
x14
 --
  8   =  4 * 2
 40   =  4 * 10
 20   =  10* 2
100   =  10* 10
 --
168
The same principle applies with binary. Let's take a look at an example:
 101
x 10
----
   0   =  0 * 101
1010   = 10 * 101 [or in denary 2 * 5 = 10]
Let's try a more complicated example:
   1011 [11]
  x 111 [7]
  ----
   1011 =   1 * 1011 
  10110 =  10 * 1011
 101100 = 100 * 1011
 ------ now add them together
1001101 = [77 double check with the decimal earlier]

Exersizes

101 * 10

Answer :
 101
x 10
----
1010
11 * 11
Answer :
  11
x 11
----
  11
 110
----
1001
1011 * 101
Answer :
  1011 
x  101
------
  1011
101100
------
110111

1111 * 111
Answer :
    1111  = 15
  x  111  = 7
  ------
    1111
   11110
  111100
  ------
 1101001 = 105
If you multiply a binary number by 2, how many spaces does it move to the left?

Answer :
1
If you multiply a binary number by 16, how many spaces does it move to the left?

Answer :
4 (as 2^4 = 16)
This is a short cut for multiplication in computers, and it uses machine code shift instructions to do this. Don't worry you don'tneed to know them for this syllabus

No comments:

Post a Comment