0

I'm having slight confusion over two's complement. I have reviewed What is “2's Complement”?.

I'm trying to add -2 + -3 = -5. Here's my thought process:

+2 = 0010
-2 = 1110 # in twos complement

+3 = 0011 
-3 = 1101 # in twos complement

 1101
+1101
-----
10010 # What is this?

I know -5 is 1011 in Two's Complement. But I'm not sure what I did when I added -2 + -3 in the example above.

An explanation of the process to add -2 + -3 would be appreciated. Thank you for your assistance!

2
  • 3
    Your "What's this" adds -3 and -3, and the answer is 11010, not what you have. So it is -6 - the correct answer for that sum. Commented Jun 21, 2015 at 21:42
  • Ah. I made a typo, but I see now. The way I was adding binary wasn't correct. Your comment helped! Commented Jun 21, 2015 at 21:52

1 Answer 1

1

In 4 bit 2'scomplement -2 is 1110 and +3 is 0011 so

11110  carry 
 1110  -2
+0011  +3
 ----
10001  which is 0001 or simply 1 ignoring the carry in bit 5

Stepping through the process from the right to the left:

  1. 1 + 0 results in 1 with no carry

  2. 1 + 1 results in 0 with a carry of 1

  3. 1 + 0 + the carry of 1 results 0 with a carry of 1

  4. 1 + 0 + the carry of 1 results in 0 with a carry of 1

  5. just the carry of 1 results in 1 with nothing more to carry

For reference see the Wikipedia article on 2's complement particularly the section on addition at https://en.wikipedia.org/wiki/Two%27s_complement#Addition. There are a number of online 2's complement calculators to help with conversions and one of them is at http://www.exploringbinary.com/twos-complement-converter/

Let me know if you want to see how -3 + -3 is done, since that is what you attempted. It is a similar process, but be sure start with bit length large enough to avoid overflow as determined when the leftmost two bits in the carry row have different values.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.