1
$\begingroup$

Subtract using 8-bit signed magnitude arithmetic 11011001 from (00100011 + 00001101 ) The result also should be signed magnitude format. I do it like this

(+0 0001101 ) + (+0 0100011)=+0 0110000

then

(+0 0110000)- (-1 1011001)= -1 0001010

is this correct??

$\endgroup$
1
$\begingroup$

Doesn't the first bit itself want to be the sign? (If the leading bit is $1$, it means the number wants to be negative.)

Note that $11111111$ plays the role of $-1$, and similarly, for any byte $x$ in binary, $$-x = (x\ {\rm xor}\ 11111111)+1$$ Using this, $-1 1011001 = (00100110)+1 = 00100111$. Hope it helps.

$\endgroup$
  • $\begingroup$ That's two's complement, not signed magnitude. Under signed magnitude, 11111111 is -127. $\endgroup$ – Joe Z. Mar 12 '13 at 1:42
1
$\begingroup$

Your first calculation is correct.

Your second calculation is dubious. Although you are performing the arithmetic correctly (the end result is 137), you seem to be overflowing the integers the wrong way (-1 0001010 is -10; it seems like you just wrapped around from 127 to 0 going in the negative direction). I don't know enough about signed magnitude arithmetic to be sure, though (most computer systems nowadays just use two's complement like in Berci's answer).

$\endgroup$
1
$\begingroup$

The leading bit being one means the number is negative. Since we are to subtract it, we can change the leading bit to $0$ and add all three, getting $$\ \ \ 0001101\\ \ \ \ 0100011\\ \underline{+1011001}\\ 10001001$$ which is an overflow. In base $10$ this is $13+35+89=137$. As the largest positive number in signed 8-bit is $+127$ this is consistent.

$\endgroup$

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.