In: Computer Science
Write 6 paragraphs Describing the algorithms that are actually used by modern computers to add, subtract, multiply and divide positive integers.
Modern computers reprsent data in the form of binary digits such as 0 and 1.which intern grouped into bytes.adding ,subtraction,multiplication and division are in the format of binary representations only.so we have to convert from decimal to binary format.
For conversion we have to store reaminder when the number is divided by 2 in the array.and next we have to divide that number by 2.we have to repeat this procedure until the number is greater than zero.then we have to print that array in reverse order.
The addition algorithm takes two operands(it is the data an algorithm operates on) and produces one result.adding two bits in one column may produce a carry bit.this is the carryin for the next bit column.when we add 1 and 1 we will get 10 and 1 is the carry bit.it is the carry in to the next column.
The subtraction algorithm takes two operands A and B.complement B to produce 2's complement of B.then add A and complement B then invert the bits and add 1.
The multiplication algorithm takes operands A and B (MULTICAND AND MULTIPLIER).the multiplicand is shifted and next bit of multiplier is examined it is also a shifting step.if this bit is 1,shifted multiplicand is added to the product.
The division algorithm takes the remainder r,the divisor d,and quotient q, at every step shift divisor right and compare it with current dividend.if divisor is larger,shift 0 as the next bit to the quotient.if the divisor is smaller,substract to get new dividend and shift 1 as the next bit of the quotient