Reputation: 8424
I'm confused about where I'm going wrong in the following problem using binary multiplication with two's complement.
I am trying to multiply 12 * -6
.
We know that 12 = 01100
and -6 = 11010
, and sign-extended we get 00000 01100 * 11111 11010
. I tried multiplying these two numbers as follows:
1111111010
x 0000001100
------------
0000000000
0000000000
1111111010
+ 1111111010
---------------
10111110111000
This is definitely not -72
, so what am I doing wrong?
Upvotes: 1
Views: 2318
Reputation: 280181
Drop the digits from the left that don't fit in the data type:
10111110111000
truncates to
1110111000
You'll find that this is indeed -72
.
Upvotes: 1