[Top][All Lists]

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

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.9-21-ge8f329

From: Mark H Weaver
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.9-21-ge8f3299
Date: Sun, 14 Jul 2013 18:12:11 +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".

The branch, stable-2.0 has been updated
       via  e8f329972666db6c9d4644619473e14d54db3a80 (commit)
      from  10454601e03a20cc121d06d8004f96bb2a3b6fb5 (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 e8f329972666db6c9d4644619473e14d54db3a80
Author: Mark H Weaver <address@hidden>
Date:   Sun Jul 14 14:08:33 2013 -0400

    Fix 'bitwise-bit-count' for negative arguments.
    Fixes <>.
    Reported by Göran Weinholt <address@hidden>.
    * module/rnrs/arithmetic/bitwise.scm (bitwise-bit-count): If the
      argument is negative, return the 'bitwise-not' of the result of
      'logcount', as per R6RS.  Previously, 'bitwise-bit-count' was
      identical to 'logcount'.


Summary of changes:
 module/rnrs/arithmetic/bitwise.scm            |    6 +++++-
 test-suite/tests/r6rs-arithmetic-bitwise.test |    4 +++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/module/rnrs/arithmetic/bitwise.scm 
index bb3a207..ac870ff 100644
--- a/module/rnrs/arithmetic/bitwise.scm
+++ b/module/rnrs/arithmetic/bitwise.scm
@@ -53,9 +53,13 @@
                  (logand bitwise-and) 
                  (logior bitwise-ior) 
                  (logxor bitwise-xor)
-                 (logcount bitwise-bit-count)
                  (ash bitwise-arithmetic-shift)))
+  (define (bitwise-bit-count ei)
+    (if (negative? ei)
+        (bitwise-not (logcount ei))
+        (logcount ei)))
   (define (bitwise-if ei1 ei2 ei3)
     (bitwise-ior (bitwise-and ei1 ei2) (bitwise-and (bitwise-not ei1) ei3)))
diff --git a/test-suite/tests/r6rs-arithmetic-bitwise.test 
index a61fef8..c864f3b 100644
--- a/test-suite/tests/r6rs-arithmetic-bitwise.test
+++ b/test-suite/tests/r6rs-arithmetic-bitwise.test
@@ -43,7 +43,9 @@
 (with-test-prefix "bitwise-bit-count"
   (pass-if "bitwise-bit-count simple"
-    (eqv? (bitwise-bit-count #b101) 2)))
+    (eqv? (bitwise-bit-count #b101) 2))
+  (pass-if "bitwise-bit-count negative"
+    (eqv? (bitwise-bit-count #b-101) -2)))
 (with-test-prefix "bitwise-length"
   (pass-if "bitwise-length simple"

GNU Guile

reply via email to

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