Say I have 21 - 10 = 10 in decimal.
Signed method:
10101 - 1010 ----- 1011 = 11 (in decimal) So far so good,
Now if I decide to use two's complement
(0) 10101 (21) + 10110 (-10) ----- (1) 01011 = (11) Here it shows I have a carry in of zero and carry out of one. If I follow the rules of underflow and overflow, this should be considered as an underflow and should not be getting the correct answer in the end.
However, if I decide to add one more bit to work with:
(1) 010101 (21) + 110110 (-10) ----- (1) 001011 = (11) In this case, I get the correct answer and no overflow.
I cannot seem to figure out what's happening here and why is it that I'm getting the correct answer for each of these cases in two's complement.
Any clarification would help!