Aleksandar Donev said:
> NAG has a float-store option
> and the manual says it helps "avoid problems with excess precision". How can
> extra precision be a problem?
Apart from agreeing with Steve Lionel's points, "excess" precision can be a
problem in the following kind of situation:
... code that calculates X
... code that calculates Y
(a) IF (X/=Y) THEN
(b) ... do something that assumed X/=Y, like dividing by X-Y,
or continuing with another iteration of the algorithm
(which thus never terminates).
Now, particularly with optimisation, it is quite common that one of X and Y
has to be stored to memory at some point in the computation, so at point
(a), X has been rounded (say to double precision), but Y is still in the
registers so is available to extended precision -- and so X/=Y.
But by the time it reaches point (b), Y has also been stored to memory,
rounding it to double precision, and might now be equal to X! So the code
does something wrong.
(Another amusing one is calculating A*B-A*C, when B>=C. On a machine with
fused multiply-add, the "excess precision" can give you a negative answer
instead of zero when B==C.)
You'll notice that these problems arise precisely when the "extra
precision" is not used for ALL parts of the calculations. But in the
normal course of events, extended precision is helpful rather than
harmful so we use it.
Cheers,
--
...........................Malcolm Cohen, NAG Ltd., Oxford, U.K.
([log in to unmask])
________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
|