Twos complement is one of the building block for Computer Organization and Architecture to get an A+. To study the twos complement, you need a 1 pound of XOR logical rules in your ingredients.
Did you read or know already about the XOR? Okay… now let’s go. For example, if you want to convert 3 (0011) in the negative format (twos-compliment), how can we do that?
XOR with 1
First, we have to XOR all the bits with 1 as many as the bit to be XOR-ed.
Add with 1
Just a binary addition it with 1.
That’s all. You get it. 1101 is -3. How come? 1101, the first ‘1’ is -8, the first ‘1’ is always to be the minus sign for the twos compliment and its value is always two to the power of the position of the bit its belong to. The remainding ‘1’ and the other ‘0’ is not a minus. So, you get -8+4+1=-8+5=-3.