Fix exp10 spurious overflows (bug 13924)

Andreas Jaeger aj@suse.com
Mon Apr 30 12:12:00 GMT 2012


On 04/29/2012 02:42 PM, Joseph S. Myers wrote:
> Bug 13924 is spurious overflow from exp10 (-DBL_MAX), and similarly
> exp10f (-FLT_MAX) (and the C version of exp10l (-LDBL_MAX)), which
> should be underflow cases not overflow, because the implementations
> multiply the argument by log(10) which overflows to negative infinity.
>
> I propose this patch to fix this overflow by checking for underflow
> cases before doing the multiplication.  In the case of exp10f, rather
> than checking for the underflow case it seems more natural to fix the
> float case of bug 13884 (exp10 inaccuracy) at the same time by doing
> exponentiation in double, which provides enough extra bits (actually
> you only need about 7 extra bits in this case) to make exp10f
> accurate.
>
> (The long double implementation changed isn't used on x86 or x86_64
> but the change is mechanical and analogous to the change to the double
> implementation.  The x86/x86_64 long double implementations have their
> own problems with exceptions, bug 13914.)
>
> Tested x86_64 and x86; no ulps changes needed.
>
> 2012-04-29  Joseph Myers<joseph@codesourcery.com>
>
> 	[BZ #13884]
> 	[BZ #13924]
> 	* math/e_exp10.c: Include<float.h>.
> 	(__ieee754_exp10): Handle underflow here rather than multiplying
> 	large negative argument by M_LN10.
> 	* math/e_exp10f.c (__ieee754_exp10f): Call __ieee754_exp instead
> 	of __ieee754_expf.
> 	* math/e_exp10l.c: Include<float.h>.
> 	(__ieee754_exp10l): Handle underflow here rather than multiplying
> 	large negative argument by M_LN10l.
> 	* math/libm-test.inc (exp10_test): Add another test.  Do not allow
> 	spurious overflow exception on underflow.

thanks, this is ok.

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



More information about the Libc-alpha mailing list