According to this page, and other similar ones, the rules for detecting overflow when adding signed binary numbers in 2's complement form are the following:
- If the sum of two positive numbers yields a negative result, the sum has overflowed.
- If the sum of two negative numbers yields a positive result, the sum has overflowed.
- Otherwise, the sum has not overflowed.
This, however, appears not to work for 3-bit signed numbers. For example consider adding -2 and -2, +2 is 010 and it's 2's complement is then 110. Then -2+-2 = 110+110 = 1100. When we discard the carry, the sign of the number is negative, because -4 can not be represented as a 3-bit signed number. I am trying to optimize a design for a school assignment and currently the best I can do is just handle the case where it gets to 100 (I just turn the overflow flag on if this happens). Any help is much appreciated.