Signed Binary Numbers

joi

New member
Joined
Jul 10, 2006
Messages
7
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!
 
joi said:
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?

Your answer is correct. Do the decimal arithmetic and see that 12 is clearly wrong.

edit: Hold on, which is it? 33+(-21) or (33)-(-21)? You have both written in this post.

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!

Looks correct to me.
 
Top