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]

Patch for expf wrongly returning infinity (bug 3406)


expf wrongly returns infinity when it should return a value just below
FLT_MAX, as reported in bug 3406, because w_expf.c has a wrong figure
for the largest expf input with finite float output.  The figure in
e_expf.c for the smallest expf input with infinite float output is
correct; this patch changes w_expf.c to use the correct value (the
next float lower than the one in e_expf.c).

2008-02-11  Joseph Myers  <joseph@codesourcery.com>

	[BZ #3406]
	* sysdeps/ieee754/flt-32/w_expf.c (o_threshold): Correct value.
	* math/libm-test.inc (exp_test): Test 88.72269439697265625.

Index: math/libm-test.inc
===================================================================
RCS file: /cvs/glibc/libc/math/libm-test.inc,v
retrieving revision 1.77
diff -u -p -r1.77 libm-test.inc
--- math/libm-test.inc	28 Oct 2007 01:14:25 -0000	1.77
+++ math/libm-test.inc	11 Feb 2008 20:34:51 -0000
@@ -2510,6 +2510,7 @@ exp_test (void)
   TEST_f_f (exp, 3, M_E3l);
   TEST_f_f (exp, 0.75L, 2.11700001661267466854536981983709561L);
   TEST_f_f (exp, 50.0L, 5184705528587072464087.45332293348538L);
+  TEST_f_f (exp, 88.72269439697265625L, 3.40233126623160774937554134772290447915e38L);
 #ifdef TEST_LDOUBLE
   /* The result can only be represented in long double.  */
   TEST_f_f (exp, 1000.0L, 0.197007111401704699388887935224332313e435L);
Index: sysdeps/ieee754/flt-32/w_expf.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/ieee754/flt-32/w_expf.c,v
retrieving revision 1.1
diff -u -p -r1.1 w_expf.c
--- sysdeps/ieee754/flt-32/w_expf.c	14 Jul 1999 00:03:46 -0000	1.1
+++ sysdeps/ieee754/flt-32/w_expf.c	11 Feb 2008 20:34:52 -0000
@@ -29,7 +29,7 @@ static const float
 #else
 static float
 #endif
-o_threshold=  8.8721679688e+01,  /* 0x42b17180 */
+o_threshold=  8.8722831726e+01,  /* 0x42b17217 */
 u_threshold= -1.0397208405e+02;  /* 0xc2cff1b5 */
 
 #ifdef __STDC__

-- 
Joseph S. Myers
joseph@codesourcery.com


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