floating-point comparisons illegitimate?

David G. Hough on validgh dgh
Fri Mar 15 07:37:00 PST 1991


While in general I don't think programmers should expect 
	A = expr
	if (A .eq. expr)
to always be true, I don't see any reason to expect
	A = B
	if (A .eq. B)
to fail.  There's nothing illegitimate about comparison of floating-point values,
in general, and I don't see how programs can avoid them efficiently.

It's worth remembering that out of several thousand modules in the IMSL library
and test programs, only one demonstrated a bug of this nature, while almost all 
of them benefitted from extended-precision register allocation in terms of
better performance and better accuracy.  The statistics for the NAG library are
similar.  Both were originally developed on conventional mainframes without
extended precision, and have been ported over the years to many platforms at
great cost, and I'm sure the developers would be happier not to have to do
anything different for 80x87 and 680x0 systems.

And you can always avoid these problems by turning off optimization, but the
difference between unoptimized and optimized code performance is getting
more substantial all the time, so not many people are interested in doing
that.



More information about the Numeric-interest mailing list