Hi. I am having a problem with signed binary numbers. There are two questions: Perform the arithmetic operations (+33)+(-21) and (-37)-(-26) in binary using signed 2’s complement representation for negative numbers.
For the +33 - (-21), This is what I did:
33 -> 0100001 [It's positive, so the leading bit is 0
-21 -> 0010101 (+21) -> To get negative, I did 2s complement and got 1101011
Since subtraction is another form of addition [ 33 + (-21)], I took the 2s complement of the subtrahend, which put me back to where I started: 0010101. I added this to the minuend, 0100001, and got 0110110. This is way off. The answer is positive 12 (0001100). Where did I go wrong?
For the (-37)-(-26), This is what I did:
-37 -> 0100101 (+37) -> To get negative, I did 2s complement and got 1011011
-26 -> 0011010 (+26) -> To get negative, I did 2s complement and got 1100110
I took the 2s complement of the subtrahend again and added it to the minuend, 1011011. I got 1110101. I think this is correct. Could someone double check this?
Thanks for any help on this!
For the +33 - (-21), This is what I did:
33 -> 0100001 [It's positive, so the leading bit is 0
-21 -> 0010101 (+21) -> To get negative, I did 2s complement and got 1101011
Since subtraction is another form of addition [ 33 + (-21)], I took the 2s complement of the subtrahend, which put me back to where I started: 0010101. I added this to the minuend, 0100001, and got 0110110. This is way off. The answer is positive 12 (0001100). Where did I go wrong?
For the (-37)-(-26), This is what I did:
-37 -> 0100101 (+37) -> To get negative, I did 2s complement and got 1011011
-26 -> 0011010 (+26) -> To get negative, I did 2s complement and got 1100110
I took the 2s complement of the subtrahend again and added it to the minuend, 1011011. I got 1110101. I think this is correct. Could someone double check this?
Thanks for any help on this!