CMP 101 Fundamentals of Computer and programming in C Rohit Khokher
Computer Arithmetic Every thing that can be done in decimal number system can also be done in binary number system Binary Arithmetic
Addition 0+0=0 0+1=1 1+0=1 1+1=0 A carry of 1 to the next higher column Like in Decimal System 9+1=0
Examples
Subtraction 0-0=0 0-1=1 1-0=1 1-1=0 A borrow from the left column
Subtraction
Complementary Subtraction Complement = (base n -1) –m Where: M is the number. n denotes number of digits in m Complement of = =99-37 = 62 10
Complementary Method Find complement of subtrahend Add the minuend If there is carry of 1, add it. If no carry, then re-complement the result and negate the number.
Complementary Method Subtract (subtrahend) from (minuend) = 1 35, 35+1 =36 Subtract (subtrahend) from (minuend) = = - 17 There is a carry so add it There is no carry so re- complement and negate the result
Complementary Method Subtract from Subtrahend Complement Minuend Carry ?Yes 1Add it Result
Complementary Method Subtract from Subtrahend Complement Minuend Carry ?No Re-complement Place a Negative Sign
Multiplications 0×00 0×10 1×00 1× × Multiplicand Multiplier 1010 × SS For each 0 shift left
Multiplications 1111 x Carry
Division DividendDivisor Quotient Remainder Subtraction not possible quotient 0 Subtraction possible quotient Result