This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fix acosf underflow (bug 14153)
On 05/24/2012 11:52 PM, Joseph S. Myers wrote:
Bug 14153 is a spurious underflow exception from acosf (2e-17); the
cause is the acosf implementation calculating a value on the order of
the cube of its argument, which underflows. There is a test for very
small arguments, maybe to avoid underflow, and if such an argument is
encountered it returns pi/2 (computed by adding high and low parts, I
suppose to get correct results for the current rounding mode and to
raise the inexact exception). However, this tests for values no more
than 2**-57, as if the test was unchanged from a "double" version of
the function; it suffices to test for values no more than 2**-26,
which avoids the problem with internal underflows. (For small x, the
correct value is essentially pi/2 - x. Compute pi/2 rounded to 25
bits - one more bit than float - which is the nearest value that is
representable as float or half way between two representable values.
Compute the difference of pi/2 and that rounded values; if |x| is
smaller than that difference then the result of rounding pi/2 - x will
be the same in any rounding mode as the result of rounding pi/2. Now
that difference is more than 2**-26.)
I propose this patch fixing the bug that way. Tested x86_64 and x86.
thanks, this is fine,
Andreas
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126