1

I have trouble understanding when overflow occurs in unsinged addition and subtraction. For example,

   1 1 1 1 0 0 0 0 
+  0 0 1 1 1 0 0 0 
  __________________
   0 0 1 0 1 0 0 0 

Because of the 1 in the MSB, it results as overflow. I understand this problem, but when it gets to subtraction, I have trouble determining when it is overflow

For example,

   0 0 0 0 0 0 0 1               
-  0 0 0 0 0 0 1 1   

(After applying 2's complement)

   0 0 0 0 0 0 0 1 
+  1 1 1 1 1 1 0 1

   1 1 1 1 1 1 1 0 

Therefore the result should be "no overflow" because there is no 1 carry out in the end. However, the answer says "overflow". Could you please tell me why?

1

1 Answer 1

1

I'd probably call this underflow not overflow.

Think about it like this. You are trying to compute xy. Using two's complement you are implementing this as x + (2Ny) = 2N + (xy). So the result will only correctly represent (xy) if there is an overflow carry bit 2N that fell off the left. Otherwise the result you get is the two-s complement representation of a negative subtraction result.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.