next up previous contents
Next: IEEE Arithmetic Up: Computer Representation of Numbers Previous: Rounding to nearest.   Contents

Arithmetic Operations

To perform arithmetic operations, the values of the operands are loaded into registers; the Arithmetic and Logic Unit (ALU) performs the operation, and puts the result in a third register; the value is then stored back in memory.

25<25 SetFigFontpt@pt xxxxxxsplain


The two operands are obviously floating point numbers. The result of the operation stored in memory must also be a floating point number.

Is there any problem here? Yes! Even if the operands are FP numbers, the result of an arithmetic operation may not be a FP number.

To understand this, let us add two floating point numbers, = (97.2) and = (6.43), using our toy FP system. To perform the summation we need to align the numbers by shifting the smaller one (6.43) to the right.

9. 7 2       01
0. 6 4 3     01
10. 3 6 3     01

The result (103.63) is not a floating number. We can round the result to obtain (104).

From this example we draw a first useful conclusion: the result of any arithmetic operation is, in general, corrupted by roundoff errors. Thus, the arithmetic result is different from the mathematical result.

If are floating point numbers, and is the result of mathematical addition, we will denote by the computed addition.

The fact that has surprising consequences. Let c= (0.999). Then


while


(you can readily verify this). Unlike mathematical addition, computed addition is not associative!




next up previous contents
Next: IEEE Arithmetic Up: Computer Representation of Numbers Previous: Rounding to nearest.   Contents
Adrian Sandu 2001-08-26