Fix remainder (NaN, 0)

This commit is contained in:
Andreas Jaeger 2011-10-07 15:14:06 -04:00 committed by Ulrich Drepper
parent 48693bea9e
commit bf5824458c
6 changed files with 38 additions and 12 deletions

View File

@ -1,3 +1,13 @@
2011-09-29 Andreas Jaeger <aj@suse.de>
[BZ #6779]
[BZ #6783]
* math/w_remainderl.c (__remainderl): Handle (NaN, 0) and (Inf,y)
correctly.
* math/w_remainder.c (__remainder): Likewise.
* math/w_remainderf.c (__remainderf): Likewise.
* math/libm-test.inc (remainder_test): Add test cases.
2011-10-04 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* stdlib/longlong.h: Update from GCC. Fix zarch smul_ppmm and

6
NEWS
View File

@ -9,9 +9,9 @@ Version 2.15
* The following bugs are resolved with this release:
9696, 11589, 12403, 12847, 12868, 12852, 12874, 12885, 12907, 12922,
12935, 13007, 13021, 13067, 13068, 13090, 13092, 13114, 13118, 13123,
13134, 13138, 13150
6779, 6783, 9696, 11589, 12403, 12847, 12868, 12852, 12874, 12885, 12907,
12922, 12935, 13007, 13021, 13067, 13068, 13090, 13092, 13114, 13118,
13123, 13134, 13138, 13150
* New program pldd to list loaded object of a process
Implemented by Ulrich Drepper.

View File

@ -189,7 +189,7 @@ static FLOAT max_error, real_max_error, imag_max_error;
#define MANT_DIG CHOOSE ((LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1), \
(LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1))
(LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1))
static void
init_max_error (void)
@ -4940,11 +4940,27 @@ remainder_test (void)
START (remainder);
errno = 0;
TEST_ff_f (remainder, 1, 0, nan_value, INVALID_EXCEPTION);
check_int ("errno for remainder(1, 0) = EDOM ", errno, EDOM, 0, 0, 0);
errno = 0;
TEST_ff_f (remainder, 1, minus_zero, nan_value, INVALID_EXCEPTION);
check_int ("errno for remainder(1, -0) = EDOM ", errno, EDOM, 0, 0, 0);
errno = 0;
TEST_ff_f (remainder, plus_infty, 1, nan_value, INVALID_EXCEPTION);
check_int ("errno for remainder(INF, 1) = EDOM ", errno, EDOM, 0, 0, 0);
errno = 0;
TEST_ff_f (remainder, minus_infty, 1, nan_value, INVALID_EXCEPTION);
check_int ("errno for remainder(-INF, 1) = EDOM ", errno, EDOM, 0, 0, 0);
errno = 0;
TEST_ff_f (remainder, nan_value, nan_value, nan_value);
check_int ("errno for remainder(NAN, NAN) unchanged", errno, 0, 0, 0, 0);
errno = 0;
TEST_ff_f (remainder, 0, nan_value, nan_value);
check_int ("errno for remainder(0, NAN) unchanged", errno, 0, 0, 0, 0);
errno = 0;
TEST_ff_f (remainder, nan_value, 0, nan_value);
check_int ("errno for remainder(NaN, 0) unchanged", errno, 0, 0, 0, 0);
TEST_ff_f (remainder, 1.625, 1.0, -0.375);
TEST_ff_f (remainder, -1.625, 1.0, 0.375);

View File

@ -33,8 +33,8 @@ static char rcsid[] = "$NetBSD: w_remainder.c,v 1.6 1995/05/10 20:49:44 jtc Exp
#else
double z;
z = __ieee754_remainder(x,y);
if(_LIB_VERSION == _IEEE_ || __isnan(y)) return z;
if(y==0.0)
if(_LIB_VERSION == _IEEE_ || __isnan(y) || __isnan(x)) return z;
if(y==0.0 || __isinf(x))
return __kernel_standard(x,y,28); /* remainder(x,0) */
else
return z;

View File

@ -8,7 +8,7 @@
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@ -17,7 +17,7 @@
static char rcsid[] = "$NetBSD: w_remainderf.c,v 1.3 1995/05/10 20:49:46 jtc Exp $";
#endif
/*
/*
* wrapper remainderf(x,p)
*/
@ -36,8 +36,8 @@ static char rcsid[] = "$NetBSD: w_remainderf.c,v 1.3 1995/05/10 20:49:46 jtc Exp
#else
float z;
z = __ieee754_remainderf(x,y);
if(_LIB_VERSION == _IEEE_ || __isnanf(y)) return z;
if(y==(float)0.0)
if(_LIB_VERSION == _IEEE_ || __isnanf(y) || __isnanf(x)) return z;
if(y==(float)0.0 || __isinff(x))
/* remainder(x,0) */
return (float)__kernel_standard((double)x,(double)y,128);
else

View File

@ -38,8 +38,8 @@ static char rcsid[] = "$NetBSD: $";
#else
long double z;
z = __ieee754_remainderl(x,y);
if(_LIB_VERSION == _IEEE_ || __isnanl(y)) return z;
if(y==0.0)
if(_LIB_VERSION == _IEEE_ || __isnanl(y) || __isnanl(x)) return z;
if(y==0.0 || __isinfl(x))
return __kernel_standard(x,y,228); /* remainder(x,0) */
else
return z;