0
\$\begingroup\$

I have a simple question about converting from signed magnitude representation to signed 2's complement.

I have no difficulty converting, for example, the signed magnitude 5-bit binary number 00100 (4 in base 10) to signed 2's complement, because it is 00100. Likewise, the signed magnitude 5-bit binary number 10001 (-1 in base 10) is 11111 in signed 2's complement.

What I don't understand is how the signed binary number 10000 (this would be -0, correct?) is converted to 2's complement. Can anyone offer some insight? Thank you.

\$\endgroup\$
1
\$\begingroup\$

some numbers like -0 in particular cannot be represented. is there a difference between +0 and -0? There is one or maybe two (or few)numbers that are a problem and they are around the end points. 10000 being minus zero if you see the sign bit set you negate the other bits, invert and add one so 1111 + 1 = 10000 or 0000, leaving you with the number 10000 in twos complement which is what -32 not -0. what about sign magnitude 11111 minus 15. 10001, that works fine. what about 00000 that works fine what about 01111, that works fine. so you have the one exception, if the sign is 1 and the magnitude is zero then flip the sign, else negate the magnitude and keep the sign.

\$\endgroup\$
  • \$\begingroup\$ Thanks! I thought this was the case. So, if a truth table were to be made of this, then input 10000 would be represented by don't cares, correct? \$\endgroup\$ – HustleN Mar 14 '17 at 5:01
  • 1
    \$\begingroup\$ I would argue 10000 becomes 00000 as +0 = -0, but you could also call it an invalid case. The same pattern has a problem going the other way 10000 twos complement does not have a sign magnitude pair in the same number of bits. \$\endgroup\$ – old_timer Mar 14 '17 at 5:05

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.