# Adding binary numbers using 2's complement

I am working on this question:

Add the following signed binary numbers using 2's complement arithmetic: 01110101 + 10111011. (b) Is there an overflow in this case?

I have got the following answers: Is this correct?

• Looks OK to me. Haven't been programming in assembly for ages, the Z80 (ancient CPU) has a oVerflow flag. I'd imagine modern CPU's have one too, but I'n not sure. – jippie Feb 4 '17 at 21:23
• Funny that you give a) b) and c) answers to a question that has only a b) (and an unmarked part before that). Do you know that the windows calculator has a programmer's mode that has a binary setting? – Wouter van Ooijen Feb 4 '17 at 21:48
• A silly remark : If you consider the two inputs as two's complement numbers, you cannot overflow adding numbers of opposite signs... – TEMLIB Feb 4 '17 at 21:53
• That remark is not silly, and it is a direct consequence of the b) part of the answer. – Wouter van Ooijen Feb 4 '17 at 22:21

Why not just actually do it?

 111111110
01110101
+ 10111011
==========
00110000


On the msbit what is the carry in and what is the carry out, are they the same? (answer yes they are).

So there is an unsigned overflow (carry out) but not a signed overflow.

• there is another way to look at it which can be derived from the carry in carry out thing, if the sign of the operands is the same and the sign bit of the result is different then signed overflow, otherwise not. In this case the sign bits of the operands are different so if the carry in were a 0 the result is 1 carry the 0, in and out the same, if the carry in is a 1 the result is 0 carry the 1, carry in and carry out the same. – old_timer Feb 5 '17 at 0:12