next up previous contents
Next: Cancellation (``Loss-of Significance'') Errors Up: Tipical pitfalls with floating Previous: Funny conversions   Contents

Memory versus register operands

The code
%{}
        data a /3.0/, b /10.0/  
        data x /3.0/, y /10.0/
        z = (y/x)-(b/a)
        call ratio(x,y,a1)
        call ratio(a,b,a2)
        call sub(a2,a1,c)
        print*, z-c
may produce a nonzero result. This is so because z is computed with register operands (and FP registers for Pentium are in extended precision, 80 bits) while for c the operands a and b are stored in the memory. (note that the Alpha compiler produces zero).



Adrian Sandu 2001-08-26