If I have the expression:

 1011 0000 1110
-1000 1110 0001

Then, I find the twos complement of the second number:

 0111 0001 1110
+0000 0000 0001
 0111 0000 1111

I then add this to the first number:

 1011 0000 1110
+0111 0000 1111
 0010 0001 1101

But the answer given is:

 0010 0001 1100

Can anybody see my error?

  • $\begingroup$ I don't see how this is a computer science question. $\endgroup$ – Raphael Dec 6 '14 at 9:08
  • $\begingroup$ @Raphael, it's part of my Digital System Architecture module on my BEng Electronic Engineering course. I'm not sure if it counts as a CS question; I just assumed anybody that studies CS might be able to give me a hand. $\endgroup$ – smollma Dec 6 '14 at 16:08
  • $\begingroup$ @Raphael, in hindsight, perhaps the Electrical Engineering forum is the place for it. $\endgroup$ – smollma Dec 6 '14 at 16:09
  • $\begingroup$ Neither, imho. When it comes down to it, you are asking, "how to add two numbers?". Granted, twos complement is not the encoding we learn in elementary school, but the scope/difficulty of the task is the same as back then. Being able to do so is a tool but neither (part of) what computer science or electrical engineering is about. $\endgroup$ – Raphael Dec 6 '14 at 16:11

The given answer can't be correct: Just from the last digits it claims that the result of subtracting an odd number from an even number is even.

However, you also made a mistake in your calculation: The 2's complement should be 0111 0001 1111.


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.