]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix remainder (NaN, 0)
authorAndreas Jaeger <aj@suse.de>
Fri, 7 Oct 2011 19:14:06 +0000 (15:14 -0400)
committerUlrich Drepper <drepper@gmail.com>
Fri, 7 Oct 2011 19:14:06 +0000 (15:14 -0400)
ChangeLog
NEWS
math/libm-test.inc
math/w_remainder.c
math/w_remainderf.c
math/w_remainderl.c

index 428847701d87c5721f497b0b321fc5c43105843f..39176920c18734e3dce4f7ceca7134c084bff539 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/NEWS b/NEWS
index 73552e6d57132afc7c249b436f0336ddbc5bb385..87649a867ba72c698e442227210d30dff7375808 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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.
index 70d936c0b0752ff025fbd93ef0e5a933a7fec9ba..96da7cde6b716ca53df800d1ad454be93dbcc2f5 100644 (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);
index 9d7a7c53830869cfdf51bf09ec5046f126a20b66..9ff53e35864aaf9e01ac8fc2db2a98f18850b968 100644 (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;
index 486e626c289eef7a1f722a805b7a2f3c46647fde..ab1ea2d87ce8cbe7d7ebf5bfabdceefcefbc04b1 100644 (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
index 7635fb93638a2ff392c8c59287325243498429df..e5460cdc43f9c76fe37899d10331d5ad4588b8c4 100644 (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;