HOW TO FIND 2’s COMPLIMENT WITH TRICK?




Note: Compliments can be evaluated only for negative number. If number is positive we can not find compliment.

There are three methods to store negative number:

  1. Sign magnitude
  2. One’s compliment
  3. Two’s compliment

Sign magnitude:

In this method , 1 is used for negative number(Leftmost bit) and 0 is used for positive number(leftmost bit) before the number.

For example,

we want to store -25 (7 bit)

so number is negative then we will use 1 as leftmost bit before magnitude

Binary of negative number is 1001 1001

If number is positive i.e 25

Binary of positive number is 0001 1001.

 

One’s compliment:

It is very simple method in which 1 interchange with 0 and 0 interchange with 0.

For example, say number is 5

step 1: convert any number into binary. Above number is in decimal then the binary of this number is  (0 1 0 1)

Step 2: Now 1 interchange with 0 and 0 interchange with 0.

0 1 0 1 convert into 1 0 1 0

1 0 1 0 is the answer

 

Two’s compliment

This method is basically used to store to negative number into computer.

let’s take an example:

what is the two’s compliment of -8 ?

step 1: convert number into binary.

number is negative means leftmost bit will be 1  i.e

00000000 00001000

step 2: convert into one’s compliment

11111111 11110111

step 3: add 1 into result

11111111 11111000  THIS IS ANSWER

 

Now, i will tell you a simple trick to find 2’s compliment with one step only.

what is the number?

00000000 00001000

Now scan from right to left till 1 is present. when 1 is present the interchange the rest bits with 1 into 0 or 0 into 1.

In the above example, 1 is the forth position so right four bits remain same and after forth bit all bits interchange 1 with 0 or 0 with 1

11111111 11111000 This is the answer with trick

Leave a comment