# arithmetic – 2’s complement substraction

In two’s complement, we compute $$a-b$$ by adding $$a$$ and $$-b$$. To compute $$-b$$ in two’s complement, we invert all bits in $$b$$, and increment the result by $$1$$.

Let’s see how it works in your example. You haven’t specified the bit length, but it appears to be $$8$$. We have $$50 = 00110010$$, and so $$-50 = 11001101+1 = 11001110$$. Similarly, $$48 = 00110000$$, and so $$-48 = 11001111+1 = 11010000$$. In order to subtract $$-48$$ from $$-50$$, we first negate $$-48$$: $$-(-48) = 00101111+1 = 00110000$$. Now we add $$-50$$ and $$-(-48)$$: $$11001110+00110000 = 11111110$$. Since the MSB is $$1$$, we know that this is a negative number. To find out negative what, we invert it: $$-(11111110) = 00000001+1=00000010$$, which is $$2$$. Therefore $$-50-(-48)=-2$$.