Featured Post

Friday, October 21, 2016

Subtraction of two numbers using one's complement and two's complement


Addition of two numbers:

                      Find the addition of 10 an 8?


           Let A=10------------>        1 0 1 0
           Let B=8-------------->    + 1 0 0 0         
                                                  1 0 0 1 0      

    Decimal Equivalent of 18 is 10010  which is equivalent to 10+8=18

   problem no 1:  Find the subtraction value of 10 and 9?
 
                         When subtracting a number from another number ( or if a number is negative) then we use one's complement and two's complement notations for a negative number and add the negative number in 1's and 2's complement numbers to the first number.

One's Complement: The one's complement of a number can be obtained by changing the binary digits 0 and 1 of a number  to 1 and 0 respectively.

Two's Complement: First find the one's complement of a given number and then add binary number 1 to one's complement


Subtracting two numbers using one's complement number

Let A= 10-------------------->     1010
Let B= -9--------------------->

    Binary   value    of            9    is            1 0 0 1        
    1's     complement     of    8    is             0 1 1 0

Now   A =     1  0  1  0                 ( total four digits)
           B =  + 0  1  1  0                 (total four digits)
   Result     1  0  0  0  0               (total five digits )
               
In this case the left most value( extra bit) is added to the result

     Result        0   0   0   0
                                 +   1  
                        0  0   0   1                    

The binary equivalent of 0 0 0 1 is   decimal value +1   (   9 - 8 =1)

Problem number 2: Find the value of 8 - 10 using one's complement?

The binary value of 8 is  1000


For -10 value  first we fine one' s complement value i.e., -10=0101

Let    A=  8 -------------->   1 0 0 0
         b= -10

Binary value of 10 is                                      1 0 1 0
One's complement of 10 is                             0 1 0 1



Now we add two's complement of 10 to binary value of 8

       A----------------->          1 0 0 0
      B------------------>      + 0 1 0 1 
                                            1 1 0 1

One at the left most bit indicates negative and the result is in one's complement form

The one's complement of 101 is 010  i.e., 2 and the final value is -2 ( 8 -10 =-2)

Problem no 3: Find the value of 10 -  9 using 2's complement

Two's Complement: First find the one's complement of a given number and then add binary number 1 to one's complement


 Binary   value    of            10      is               1 0 1 0      
    1's     complement     of   9   is                   0 1 1 0
    2's     complement     of   9  is                   0 1 1 1

Now   A =     1  0  1  0                 ( total four digits)
           B =  + 0  1  1 1                  (total four digits)
                  1  0  0  0  1                   (total five digit)

In this case ignore the left most bit, so the final result is 0 0 0 1   (  9 - 8 = +1)
                             

Problem no 4:  Find the value of 9 - 10

Binary   value    of                9     is                1 0 0 1      
    1's     complement     of    10    is                0 1 0 1
    2's     complement     of    10     is               0 1 1 0

Now   A =     1 0 0 1                 ( total four digits)
           B =  + 0 1 1 0                 (total four digits)
                   1 1 1 1 1            (total five digit)
In this case ignore the left most bit, so now the partial result is 1 1 1 1
And left most bit in 1 1 1 1 is 1 indicating that the result is negative and final result is in 2's complement form

The 2's complement of 1 1 1 1

                1's complement of 1 1 1 1 is            0 0 0 0

                2's complement of 1 1 1 1 is            0 0 0 0
                                                                             +   1   
                                                                          0 0 0 1
So the final result is -1  (9 -10 = -1)


Signed representation, one's complement of a number. two's complement of a number. 1's complement of a number. 2's complement of a number . adding two binary numbers, adding two binary numbers using 1's complement and 2' complement, Modi banned 500rs and 1000rs. new 500rs notes, new 1000rs note, new 2000 rupee note, new currency with chip enabled, 2000rs note with chip enabled.logic behind banning,hange, tax exemption on money, tax exemption on toll gate free, ATMS not wroking , firday new notes released ,  why 500 and 1000rs notes banned  abdul kalam photo on 200rs n otes, tax on currency exc500 100rs notes clab sample programs subtracting one number from second number using 1's complement and 2's complement. signed representation, signed magnitude representation 




No comments:

Post a Comment