How to determine if a binary addition/subtraction has an overflow

$\begingroup$

From what I understand from my lecture notes, overflow occurs when:

  • $C_{in} \neq C_{out}$
  • Change in sign

For $C_{in} \neq C_{out}$: suppose $111+111=1110=110$. In this case $C_{in}=0, C_{out}=1$, but consider a carry in then: $111+111+1=1111=111$ which according my the rules 1 above, is NOT overflow... so I suppose my understanding is wrong? If so how will I determine overflow systematically?

UPDATE

For those who are not sure what $C_{in}, C_{out}$ means and how to add/subtract binary, I hope the below working will help

enter image description here

$\endgroup$ 3

2 Answers

$\begingroup$

I think you have to specify, what your sign bit is (I assume the left most) and then treat every addition separately $$ \begin{eqnarray*} 0\_111&+&0\_111&+&0\_001 & = 1\_110 &+&0\_001&= 1\_111 \\ 7&+&7&+&1&\neq_{a}-6&+&1&\neq_b-7\\ \end{eqnarray*} $$ to get $a.$ your overflow, followed by $b.$ nonsense.

$\endgroup$ 1 $\begingroup$

First of all, in your example, you are doing three-bit addition and there is no overflow. Thus your rule does not fail for given example 111 + 111 + 001 = 111
(-1) + (-1) + (+1) = (-1)

If you are not clear with that rule just see the below mentioned simple method to know if there is an overflow.

First of all, if there is a carry out just ignore it also don't worry about carry in.Then

Case 1: Two numbers have different most significant bit There will never be overflow.

Case 2: Two numbers have same most significant bit If the output has most significant bit same as input, your answer is correct(no overflow) else if the output has the most significant bit different than input, there was an overflow.

$\endgroup$

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like