160 likes | 301 Views
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. A carry of 1 to the next higher column. Examples. 5. 2. 7. 1. 1. 1.
E N D
CMP 101 Fundamentals of Computer and programming in C RohitKhokher
Computer Arithmetic Every thing that can be done in decimal number system can also be done in binary number system Binary Arithmetic
Addition A carry of 1 to the next higher column
Examples 5 2 7 1 1 1 1 1 0 0
Examples 1 1 1 1 1 1 0 0 0 0 1 0
Subtraction A borrow from the left column 10
Subtraction 1 2 2 2 0 0 0 0 1 1 1
Complementary Subtraction Complement = (basen -1) –m Where: M is the number. n denotes number of digits in m Complement of 3710 = 102 -1-37=99-37 = 6210
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 5610 (subtrahend) from 9210 (minuend) 99-56 + 92 =135, 35+1 =36 There is a carry so add it Subtract 3510 (subtrahend) from 1810 (minuend) 99-35 + 18 =82 There is no carry so re-complement and negate the result 99-82 = -17
Complementary Method Subtract 0111000 from 10111000 Result
Complementary Method Subtract 100011 from 010010 Place a Negative Sign
Multiplications Multiplicand Multiplier For each 0 shift left
Multiplications Carry 1 1 1 1 1 1 1 1
Division Quotient 0 1 0 1 Divisor Dividend Result 0101.11 0 Subtraction not possible quotient 0 Subtraction possible quotient 1 Remainder