Adding two Negative Numbers using 2's Complement

jaredjones picture jaredjones · Aug 31, 2014 · Viewed 15.5k times · Source

I was wondering if someone could double check my work for me real quick. If I'm given two negative numbers: -33 and -31. If I add them together what will be the result using 2's complement.

NOTE: A word length of 6-bits MUST being used for the operation.


MY ANSWER

So after doing this I computed -31 to be 100001 in 2's. I also computed -33 to be 011111 in 2's complement. When adding them together I got 1000000, however this number is 7 digits so I chopped off the higher order bit since I'm bound to a word length of 6-bits. This yields the number 000000. Which contains a sign bit of 0, meaning it would be even. However since the sum of 2 negative's cannot be even it's obviously an overflow. So I take the 2's of 000000 which is simply 000000.

So the answer should be: 0 since a buffer overflow occurred. Does this seem right to you guys? THANKS. :)

Answer

mch picture mch · Sep 3, 2014

First of all: -33 + (-31) cannot be 0.

-33 is not representable in 6bit 2's complement. 01 1111b is +31 in decimal, so the addition results in 0.

So the correct answer is something like that: There is no result because -33 is an invalid number in 6bit representation.

in 7 bit 2's complement -33 = 101 1111b

 110 0001
+101 1111
    =
1100 0000

which is equal to -64.