X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcode%2Fcross-float.lisp;h=f7b995eb32202e7aedb66ccd31abe2a0f8091414;hb=1c91b0bc7eb814af6a8c58a99a83a024716138e8;hp=e0b2eb009f751ef30ca55d88f348a30b310c289a;hpb=22b819c0cd0ca0ea5be52ba280b9e9e0b8e86210;p=sbcl.git diff --git a/src/code/cross-float.lisp b/src/code/cross-float.lisp index e0b2eb0..f7b995e 100644 --- a/src/code/cross-float.lisp +++ b/src/code/cross-float.lisp @@ -214,13 +214,18 @@ ;; IEEE float special cases ((zerop bits) 0.0) ((= bits #x-80000000) -0.0) - (t (let ((sign (ecase (ldb (byte 1 31) bits) - (0 1.0) - (1 -1.0))) - (expt (- (ldb (byte 8 23) bits) 127)) - (mant (* (logior (ldb (byte 23 0) bits) - (ash 1 23)) - (expt 0.5 23)))) + (t (let* ((sign (ecase (ldb (byte 1 31) bits) + (0 1.0) + (1 -1.0))) + (iexpt (ldb (byte 8 23) bits)) + (expt (if (zerop iexpt) ; denormalized + -126 + (- iexpt 127))) + (mant (* (logior (ldb (byte 23 0) bits) + (if (zerop iexpt) + 0 + (ash 1 23))) + (expt 0.5 23)))) (* sign (kludge-opaque-expt 2.0 expt) mant))))) (defun make-double-float (hi lo) @@ -232,9 +237,14 @@ (sign (ecase (ldb (byte 1 63) bits) (0 1.0d0) (1 -1.0d0))) - (expt (- (ldb (byte 11 52) bits) 1023)) + (iexpt (ldb (byte 11 52) bits)) + (expt (if (zerop iexpt) ; denormalized + -1022 + (- iexpt 1023))) (mant (* (logior (ldb (byte 52 0) bits) - (ash 1 52)) + (if (zerop iexpt) + 0 + (ash 1 52))) (expt 0.5d0 52)))) (* sign (kludge-opaque-expt 2.0d0 expt) mant)))))