Binary multiplication

Thread Starter

aceminer

Joined Aug 26, 2011
21
OMG. I can do multiplication when its 110101 x 0110 = 1110111110
this would give me an answer of -66 when converted to dec.

however, i cant seem to get the answer of -66 when 010110 x 1101 = 1110111110
am i correct to say that 010110 = 22 and 1101 = -3, hence 22 x -3 = -66
but the answer i got was 0100011110 which means it is a positive number which doesnt make any sense.
 

Georacer

Joined Nov 25, 2009
5,154
This is why we need to be very specific about the word lengths when teaching or giving exercises. All of this could be avoided if we knew the word length.

In general I don't give too much time and attention to poorly defined exercises, they deserve what they get. It makes no sense to sweat over an ambiguous riddle. Imagine if we had an overflow...
 

joeyd999

Joined Jun 6, 2011
4,231
OMG. I can do multiplication when its 110101 x 0110 = 1110111110
this would give me an answer of -66 when converted to dec.

however, i cant seem to get the answer of -66 when 010110 x 1101 = 1110111110
am i correct to say that 010110 = 22 and 1101 = -3, hence 22 x -3 = -66
but the answer i got was 0100011110 which means it is a positive number which doesnt make any sense.
Signed multiplication doesn't really work this way...the msb 1 of a negative signed integer is not a 'significant' digit, and should not be used in the arithmetic. To do proper signed multiplication do the following:

1) Using two's complement, convert each negative integer to its absolute (positive) value.

2) Multiply the two positive numbers to create a positive result.

3) If the result is supposed to be negative (i.e. either, but not both of the original operands were negative), then two's compliment the result to get the proper negative result.

This is similar to decimal multiplication:

5 * -10 = 5 * 10 * -1 = 50 * -1 = -50
 
Top