As far as I know, the two’s complement algo is:
1.Represent the decimal in binary.
2.Inverse all bits.
3.Add 1 to the last bit.
For the number 3, which its representation is: 0000000000000011 the result of the two’s complement would be 1111111111111101 which is -3.
So far so good.
But for the number 2 which its representation is 0000000000000010 the result of the two’s complement would be 1111111111111101, which isn’t 2 but -3.
What am I doing wrong?
It works for negative too: