Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


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

share|cite|improve this question
Maybe you elaborate what you mean by $C_{\rm in}$ and $C_{\rm out}$ and give other details as well (things like: how are negative numbers represented, and so on), so readers don't have to guess all this. – Florian Sep 19 '11 at 15:09
@Florian, I updated my question. I wonder tho if this should be in electronics.stackexchange instead ... – Jiew Meng Sep 20 '11 at 3:13
There are two differing conventions on how to handle carry-in/out for subtraction. Intel x86 and M68k use a carry-in as "borrow" (1 means subtract 1 more) and adapt their carry-out to mean the same, whereas PowerPC just adds the bitwise-inverted subtrahend plus the carry-in, which inverses the meaning, but is more consistent with the scheme for addition. What convention do you use? – ccorn Oct 19 '14 at 20:19
up vote 1 down vote accepted

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.

share|cite|improve this answer
Two's complement means that the sign bit has negative weight $-8$, and the other bits have the usual positive weights, so $1111$ represents $-1$, $1110$ represents $-2$ etc. – ccorn Oct 19 '14 at 20:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.