[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.9-36-g069037
From: |
Mark H Weaver |
Subject: |
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.9-36-g0690378 |
Date: |
Tue, 16 Jul 2013 21:40:25 +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=06903786211afd9a554b8f009a37111f729607ee
The branch, stable-2.0 has been updated
via 06903786211afd9a554b8f009a37111f729607ee (commit)
from 1f4f2a12d093fe4f156ef25ebc4a25d05185e5f9 (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 06903786211afd9a554b8f009a37111f729607ee
Author: Mark H Weaver <address@hidden>
Date: Tue Jul 16 17:38:14 2013 -0400
Fix R6RS 'fixnum-width'.
Fixes <http://bugs.gnu.org/14879>.
Reported by Göran Weinholt <address@hidden>.
* module/rnrs/arithmetic/fixnums.scm (fixnum-width): Rewrite to avoid
inexact arithmetic, and correct the off-by-one error.
* test-suite/tests/r6rs-arithmetic-fixnums.test (fixnum-width): Add
tests.
-----------------------------------------------------------------------
Summary of changes:
module/rnrs/arithmetic/fixnums.scm | 7 +++++--
test-suite/tests/r6rs-arithmetic-fixnums.test | 8 ++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/module/rnrs/arithmetic/fixnums.scm
b/module/rnrs/arithmetic/fixnums.scm
index dbf9ee7..7a5a621 100644
--- a/module/rnrs/arithmetic/fixnums.scm
+++ b/module/rnrs/arithmetic/fixnums.scm
@@ -95,8 +95,11 @@
(rnrs exceptions (6))
(rnrs lists (6)))
- (define fixnum-width
- (let ((w (inexact->exact (round (/ (log (+ most-positive-fixnum 1)) (log
2))))))
+ (define fixnum-width
+ (let ((w (do ((i 0 (+ 1 i))
+ (n 1 (* 2 n)))
+ ((> n most-positive-fixnum)
+ (+ 1 i)))))
(lambda () w)))
(define (greatest-fixnum) most-positive-fixnum)
diff --git a/test-suite/tests/r6rs-arithmetic-fixnums.test
b/test-suite/tests/r6rs-arithmetic-fixnums.test
index 01a7a89..60c3b87 100644
--- a/test-suite/tests/r6rs-arithmetic-fixnums.test
+++ b/test-suite/tests/r6rs-arithmetic-fixnums.test
@@ -23,6 +23,14 @@
:use-module ((rnrs exceptions) :version (6))
:use-module (test-suite lib))
+(with-test-prefix "fixnum-width"
+ (pass-if-equal "consistent with least-fixnum"
+ (- (expt 2 (- (fixnum-width) 1)))
+ (least-fixnum))
+ (pass-if-equal "consistent with greatest-fixnum"
+ (- (expt 2 (- (fixnum-width) 1)) 1)
+ (greatest-fixnum)))
+
(with-test-prefix "fixnum?"
(pass-if "fixnum? is #t for fixnums" (fixnum? 0))
hooks/post-receive
--
GNU Guile
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.9-36-g0690378,
Mark H Weaver <=