guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.9-32-gb4c55c


From: Mark H Weaver
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.9-32-gb4c55c9
Date: Tue, 16 Jul 2013 09:20:50 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=b4c55c9ccedd47c16007b590f064ef3bd67565aa

The branch, stable-2.0 has been updated
       via  b4c55c9ccedd47c16007b590f064ef3bd67565aa (commit)
      from  ad922d065c5f8b01c4ace3ee34d26300409e44fa (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b4c55c9ccedd47c16007b590f064ef3bd67565aa
Author: Mark H Weaver <address@hidden>
Date:   Tue Jul 16 05:18:15 2013 -0400

    min and max: NaNs beat infinities, per R6RS errata.
    
    Fixes <http://bugs.gnu.org/14865>.
    Reported by Göran Weinholt <address@hidden>.
    
    * libguile/numbers.c (scm_min, scm_max): NaNs beat infinities, as per
      the R6RS errata.
    
    * test-suite/tests/numbers.test (min, max): Update tests.

-----------------------------------------------------------------------

Summary of changes:
 libguile/numbers.c            |   18 ++++++++----------
 test-suite/tests/numbers.test |   16 ++++++++--------
 2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/libguile/numbers.c b/libguile/numbers.c
index d09b7c5..6107310 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -7219,17 +7219,16 @@ scm_max (SCM x, SCM y)
          double xx = SCM_REAL_VALUE (x);
          double yy = SCM_REAL_VALUE (y);
 
-         /* For purposes of max: +inf.0 > nan > everything else, per R6RS */
+         /* For purposes of max: nan > +inf.0 > everything else,
+             per the R6RS errata */
          if (xx > yy)
            return x;
          else if (SCM_LIKELY (xx < yy))
            return y;
          /* If neither (xx > yy) nor (xx < yy), then
             either they're equal or one is a NaN */
-         else if (SCM_UNLIKELY (isnan (xx)))
-           return DOUBLE_IS_POSITIVE_INFINITY (yy) ? y : x;
-         else if (SCM_UNLIKELY (isnan (yy)))
-           return DOUBLE_IS_POSITIVE_INFINITY (xx) ? x : y;
+         else if (SCM_UNLIKELY (xx != yy))
+           return (xx != xx) ? x : y;  /* Return the NaN */
          /* xx == yy, but handle signed zeroes properly */
          else if (double_is_non_negative_zero (yy))
            return y;
@@ -7379,17 +7378,16 @@ scm_min (SCM x, SCM y)
          double xx = SCM_REAL_VALUE (x);
          double yy = SCM_REAL_VALUE (y);
 
-         /* For purposes of min: -inf.0 < nan < everything else, per R6RS */
+         /* For purposes of min: nan < -inf.0 < everything else,
+             per the R6RS errata */
          if (xx < yy)
            return x;
          else if (SCM_LIKELY (xx > yy))
            return y;
          /* If neither (xx < yy) nor (xx > yy), then
             either they're equal or one is a NaN */
-         else if (SCM_UNLIKELY (isnan (xx)))
-           return DOUBLE_IS_NEGATIVE_INFINITY (yy) ? y : x;
-         else if (SCM_UNLIKELY (isnan (yy)))
-           return DOUBLE_IS_NEGATIVE_INFINITY (xx) ? x : y;
+         else if (SCM_UNLIKELY (xx != yy))
+           return (xx != xx) ? x : y;  /* Return the NaN */
          /* xx == yy, but handle signed zeroes properly */
          else if (double_is_non_negative_zero (xx))
            return y;
diff --git a/test-suite/tests/numbers.test b/test-suite/tests/numbers.test
index ab0880d..0d4285a 100644
--- a/test-suite/tests/numbers.test
+++ b/test-suite/tests/numbers.test
@@ -2690,7 +2690,7 @@
       (pass-if (eqv? 5/2 (max 5/2 2))))
 
     (with-test-prefix "infinities and NaNs"
-      ;; +inf.0 beats everything else, including NaNs
+      ;; +inf.0 beats everything except NaNs
       (pass-if (eqv?  +inf.0   (max   +inf.0    123   )))
       (pass-if (eqv?  +inf.0   (max    123     +inf.0 )))
       (pass-if (eqv?  +inf.0   (max   +inf.0   -123.3 )))
@@ -2703,11 +2703,9 @@
       (pass-if (eqv?  +inf.0   (max (- big*2)  +inf.0 )))
       (pass-if (eqv?  +inf.0   (max   +inf.0   +inf.0 )))
       (pass-if (eqv?  +inf.0   (max   +inf.0   +inf.0 )))
-      (pass-if (eqv?  +inf.0   (max   +inf.0   +nan.0 )))
-      (pass-if (eqv?  +inf.0   (max   +nan.0   +inf.0 )))
       (pass-if (eqv?  +inf.0   (max   +inf.0   +inf.0 )))
 
-      ;; NaNs beat everything except +inf.0
+      ;; NaNs beat everything
       (pass-if (real-nan?      (max   +nan.0    123   )))
       (pass-if (real-nan?      (max    123     +nan.0 )))
       (pass-if (real-nan?      (max   +nan.0    123.3 )))
@@ -2721,6 +2719,8 @@
       (pass-if (real-nan?      (max   +nan.0   -inf.0 )))
       (pass-if (real-nan?      (max   -inf.0   +nan.0 )))
       (pass-if (real-nan?      (max   +nan.0   +nan.0 )))
+      (pass-if (real-nan?      (max   +inf.0   +nan.0 )))
+      (pass-if (real-nan?      (max   +nan.0   +inf.0 )))
 
       ;; -inf.0 always loses, except against itself
       (pass-if (eqv?   -inf.0  (max   -inf.0   -inf.0 )))
@@ -2868,7 +2868,7 @@
       (pass-if (eqv? 2   (min 5/2 2))))
 
     (with-test-prefix "infinities and NaNs"
-      ;; -inf.0 beats everything else, including NaNs
+      ;; -inf.0 beats everything except NaNs
       (pass-if (eqv?  -inf.0   (min   -inf.0    123   )))
       (pass-if (eqv?  -inf.0   (min    123     -inf.0 )))
       (pass-if (eqv?  -inf.0   (min   -inf.0   -123.3 )))
@@ -2881,11 +2881,9 @@
       (pass-if (eqv?  -inf.0   (min (- big*2)  -inf.0 )))
       (pass-if (eqv?  -inf.0   (min   -inf.0   +inf.0 )))
       (pass-if (eqv?  -inf.0   (min   +inf.0   -inf.0 )))
-      (pass-if (eqv?  -inf.0   (min   -inf.0   +nan.0 )))
-      (pass-if (eqv?  -inf.0   (min   +nan.0   -inf.0 )))
       (pass-if (eqv?  -inf.0   (min   -inf.0   -inf.0 )))
 
-      ;; NaNs beat everything except -inf.0
+      ;; NaNs beat everything
       (pass-if (real-nan?      (min   +nan.0    123   )))
       (pass-if (real-nan?      (min    123     +nan.0 )))
       (pass-if (real-nan?      (min   +nan.0    123.3 )))
@@ -2899,6 +2897,8 @@
       (pass-if (real-nan?      (min   +nan.0   +inf.0 )))
       (pass-if (real-nan?      (min   +inf.0   +nan.0 )))
       (pass-if (real-nan?      (min   +nan.0   +nan.0 )))
+      (pass-if (real-nan?      (min   -inf.0   +nan.0 )))
+      (pass-if (real-nan?      (min   +nan.0   -inf.0 )))
 
       ;; +inf.0 always loses, except against itself
       (pass-if (eqv?   +inf.0  (min   +inf.0   +inf.0 )))


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]