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: enter image description here

Is this correct?

  • \$\begingroup\$ 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. \$\endgroup\$ – jippie Feb 4 '17 at 21:23
  • \$\begingroup\$ 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? \$\endgroup\$ – Wouter van Ooijen Feb 4 '17 at 21:48
  • \$\begingroup\$ A silly remark : If you consider the two inputs as two's complement numbers, you cannot overflow adding numbers of opposite signs... \$\endgroup\$ – TEMLIB Feb 4 '17 at 21:53
  • \$\begingroup\$ That remark is not silly, and it is a direct consequence of the b) part of the answer. \$\endgroup\$ – Wouter van Ooijen Feb 4 '17 at 22:21

Why not just actually do it?

+ 10111011

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.

  • \$\begingroup\$ 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. \$\endgroup\$ – old_timer Feb 5 '17 at 0:12

Your Answer

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

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