Operation on Integers

by: Maryam Jamilah bt Abdullah.

                >BINARY ADDITION                                           

  • ~       The four basic rules for binary addition are:



    1.      0 + 0 = 0           Sum of 0 with carry of 0

    2.      0 + 1 = 1           Sum of 1 with carry of 0

    3.      1 + 0 = 1           Sum of 1 with carry of 0

    4.      1 + 1 = 10           Sum of 0 with carry of 1

    Example:10+10=100            
                                                    1  0
                                          +        1  0
                                          __________
                                                1  0  0
                                          


          10 + 10 = 100, because  in the basic rule 0+0=0 and 1+1=10. Since 1 is largest digit in the binary system , any sum is greater that  1 requires a digit to be carried over. 




                                           >BINARY SUBTRACTION

    ·    The four basis rules for binary subtraction are:
    1.     0 - 0 = 0
    2.     1 - 1 = 0
    3.     1 -0  = 1
    4.     10 - 1 = 1            0-1 with a borrow of 1   
    ·     A borrow is required in binary subtraction only when we need to subtract a 1 from a 0 

    EXAMPLE:
    a)11-10
    b)101-011

    SOLUTION:
    a)       
                   1        1
    -       1         0
                0          1

    b)

                    1 0      2       1

         -    0         1          1
               0      0          1

    •    Left column: When a 1 is borrowed, a 0 is left , so 0 – 0 = 0
    •    Middle column: Borrow 1 from  left  column , making 2  which   mean 10 in  binary,when 2 borrowed it become 1, then 1-   1=0        
    • Right column: Borrow 1 from middle column , making 10then  10- 1=1  

          >BINARY MULTIPLICATION


    Multiplication in binary is similar to its decimal counterpart. Two numbers A and B can be multiplied by partial products: for each digit in B, the product of that digit in A is calculated and written on a new line, shifted leftward so that its rightmost digit lines up with the digit in B that was used. The sum of all these partial products gives the final result.

    Since there are only two digits in binary, there are only two possible outcomes of each partial multiplication:
    • If the digit in B is 0, the partial product is also 0
    • If the digit in B is 1, the partial product is equal to A
    For example, the binary numbers 1011 and 1010 are multiplied as follows:
               1 0 1 1   (A)
             × 1 0 1 0   (B)
             ---------
               0 0 0 0   ← Corresponds to a zero in B
       +     1 0 1 1     ← Corresponds to a one in B
       +   0 0 0 0
       + 1 0 1 1
       ---------------
       = 1 1 0 1 1 1 0

    >BINARY DIVISION


    Binary division is again similar to its decimal counterpart:
    Here, the divisor is 1012, or 5 decimal, while the dividend is 110112, or 27 decimal. The procedure is the same as that of decimal long division; here, the divisor 1012 goes into the first three digits 1102 of the dividend one time, so a "1" is written on the top line. This result is multiplied by the divisor, and subtracted from the first three digits of the dividend; the next digit (a "1") is included to obtain a new three-digit sequence:
                  
                 __1_________
    1 0 1   ) 1 1 0 1 1 
            −   1 0 1
                 -----
                0 1 1
    



0 comments:

Post a Comment