optimization/9654: extra-precision fp comparisons are less accurate
Richard Addison-Wood
richard@wetafx.co.nz
Fri Feb 14 03:48:00 GMT 2003
It's quite reasonable to assume that
acos(1-0.5*DBL_EPSILON)
will not be 0. For a value of d that is
nearly 1:
acos(d) == sqrt(1-d*d)
is a good approximation (certainly within
representational limits ieee754 double
precision). The point to notice here is that
if d is distinguishable from 1, d*d will be
even more distinguishable from 1. All told,
it very reasonable to expect:
acos(1-0.5*DBL_EPSILON) == sqrt(DBL_EPSILON)
which is a value that is not particularly
close to 0. However, it is still close
enough to 0 so that:
sin(sqrt(DBL_EPSILON)) == sqrt(DBL_EPSILON)
is a good approximation.
Of course, this discourse into acos(), sin(),
and sqrt() is beside the point. With code
like this:
if (d < 1.0)
{
arglessthanone(d);
}
it should be the case that the arglessthanone()
function should not see an argument value that
is greater than or equal to 1.0.
More information about the Gcc-bugs
mailing list