Suppose that I want to perform the following computation on binary numbers: $110101-110$. Working with $7$ bits, we consider the two's complement of $110$, which is $1111010$, and then the result is $110101+1111010=101111$ (we ignore the digits beyond the seventh bit), or in the decimal system, $+47$.
My problem appears when I try to compute $110-110101$, which should be $-47$ in the decimal system. I take the two's complement of $110101$, which is $1001011$, and then add $101+1001011=1010001$, but that is $-17$.
Could you please tell me what I did wrong?
The result of your last operation is correct, but you have interpreted the result in sign-and-magnitude. For a 7-bit word,
100 0000represents $-64$, the lowest number representable, and hence101 0001represents $-64+17=-47$ as expected.Sign-and-magnitude and two's complement representations agree when the number represented is positive.