The easiest guide to “Twos Compliment”

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.

0011

1111

———–XOR

1100

Add with 1

Just a binary addition it with 1.

1100

1

———ADD

1101

Finish

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s