This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix spurious overflow exceptions from x86/x86_64 powl (bug 13872)


On 04/09/2012 07:32 PM, Joseph S. Myers wrote:
Bug 13872 is a problem with overflow exceptions for certain underflow
cases of x86 and x86_64 powl with very large exponents.  The problem
is that the y*log2(x) computation overflows (to minus infinity), and
while there is code to check for such overflow (to avoid NaNs
appearing in the computation of the fractional part), this is too late
to avoid overflow exceptions from underflow cases.  I propose this
patch to fix this problem by saturating the exponents to ± 2**78
(powl(1-2**-64, 2**64) is about 1/e, powl(1+2**-63, 2**64) is about
e^2, and in either case raising to the power 2**14 results in
underflow to 0 / overflow to +infinity).  This issue does not apply to
pow or powf because DBL_MAX * log2(DBL_TRUE_MIN) does not overflow the
range of long double and all these intermediate computations are in
long double

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]