[Math] negative binary subtraction using 2’s complement (and 5 bit representation)

binary

I'm wanting to carry out the calculation of 8 – 11 (assuming that 5 bits represents a number and also using 2s complement representation), however, I can't seem to get the correct answer. This is what I have so far;

8 in binary is 01000.
11 in binary is 01101, which we invert to get -11: 10010 and then add one => 10011.

Adding these together (8 + -11) I thought resulted in 11100, however, when converting this back to decimal I can see that this isn't the (final) answer. Does anyone know where I'm going wrong?

Best Answer

You representation of $11$ is wrong (you actually compute with $-13$), here the steps to get $8-11 = -3$

  8 = 01000
-11 = inv(01011)+1 = 10100+1 = 10101

  01000
+ 10101
= 11101 

Now compute $-3$ and see that results match:

 -3 = inv(00011)+1 = 11100+1 = 11101