X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ffloat.lisp;h=3b5690b15d997f4eff494d9ed55226f62f3b08f3;hb=b31eab5875e8058a2fdfcb879e23c2724d25a278;hp=88ffb3784ef85c8737a076e77b8001f28ce238e6;hpb=b049b6c0e09815ca01f79090dd8343efcaac72a1;p=sbcl.git diff --git a/src/code/float.lisp b/src/code/float.lisp index 88ffb37..3b5690b 100644 --- a/src/code/float.lisp +++ b/src/code/float.lisp @@ -810,12 +810,13 @@ (truly-the fixnum (%unary-round number)) (multiple-value-bind (bits exp) (integer-decode-float number) (let* ((shifted (ash bits exp)) - (rounded (if (and (minusp exp) - (oddp shifted) - (eql (logand bits - (lognot (ash -1 (- exp)))) - (ash 1 (- -1 exp)))) - (1+ shifted) + (rounded (if (minusp exp) + (let ((fractional-bits (logand bits (lognot (ash -1 (- exp))))) + (0.5bits (ash 1 (- -1 exp)))) + (cond + ((> fractional-bits 0.5bits) (1+ shifted)) + ((< fractional-bits 0.5bits) shifted) + (t (if (oddp shifted) (1+ shifted) shifted)))) shifted))) (if (minusp number) (- rounded)