From 60e2497894748d137b6b3ef3e50f34627c15dffb Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Fri, 7 Oct 2011 12:39:33 +0100 Subject: [PATCH] really fix float rounding on 32-bit platforms Now, as well as not giving completely the wrong answer for most larger-than-fixnum double floats, we additionally don't try to perform arithmetic on NIL for larger-than-fixnum single-floats. --- src/code/float.lisp | 4 ++-- tests/float.pure.lisp | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/code/float.lisp b/src/code/float.lisp index 483a6cf..3b5690b 100644 --- a/src/code/float.lisp +++ b/src/code/float.lisp @@ -816,8 +816,8 @@ (cond ((> fractional-bits 0.5bits) (1+ shifted)) ((< fractional-bits 0.5bits) shifted) - (t (if (oddp shifted) (1+ shifted) shifted))))) - )) + (t (if (oddp shifted) (1+ shifted) shifted)))) + shifted))) (if (minusp number) (- rounded) rounded))))))) diff --git a/tests/float.pure.lisp b/tests/float.pure.lisp index e2aed69..60b3a36 100644 --- a/tests/float.pure.lisp +++ b/tests/float.pure.lisp @@ -381,3 +381,7 @@ (assert (= (round 1073741823.3d0) 1073741823)) (assert (= (round 1073741823.5d0) 1073741824)) (assert (= (round 1073741823.7d0) 1073741824))) + +(with-test (:name :round-single-to-bignum) + (assert (= (round 1e14) 100000000376832)) + (assert (= (round 1e19) 9999999980506447872))) -- 1.7.10.4