diff options
Diffstat (limited to 'math')
-rw-r--r-- | math/libm-test.inc | 18 | ||||
-rw-r--r-- | math/w_remainder.c | 4 | ||||
-rw-r--r-- | math/w_remainderf.c | 8 | ||||
-rw-r--r-- | math/w_remainderl.c | 4 |
4 files changed, 25 insertions, 9 deletions
diff --git a/math/libm-test.inc b/math/libm-test.inc index 70d936c0b0..96da7cde6b 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -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); diff --git a/math/w_remainder.c b/math/w_remainder.c index 9d7a7c5383..9ff53e3586 100644 --- a/math/w_remainder.c +++ b/math/w_remainder.c @@ -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; diff --git a/math/w_remainderf.c b/math/w_remainderf.c index 486e626c28..ab1ea2d87c 100644 --- a/math/w_remainderf.c +++ b/math/w_remainderf.c @@ -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 diff --git a/math/w_remainderl.c b/math/w_remainderl.c index 7635fb9363..e5460cdc43 100644 --- a/math/w_remainderl.c +++ b/math/w_remainderl.c @@ -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; |