From 4d9cf40872a7b900f7025ad1099e16b24ec31b56 Mon Sep 17 00:00:00 2001 From: "Paul A. Patience" Date: Thu, 27 Jun 2024 14:23:51 -0400 Subject: [PATCH] quaviver: fix zero significand bug in integer-float/2 * code/integer-float-2.lisp (%integer-encode-float): Don't set the exponent bits when the significand is 0. --- code/integer-float-2.lisp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/code/integer-float-2.lisp b/code/integer-float-2.lisp index b8853b14..b480bd3a 100644 --- a/code/integer-float-2.lisp +++ b/code/integer-float-2.lisp @@ -36,15 +36,13 @@ (:signaling-nan (setf (ldb ',nan-payload-bytespec ,bits-var) (if (zerop ,significand-var) 1 ,significand-var))))) + ((zerop ,significand-var)) (t - (unless (zerop ,significand-var) - (let ((shift (- ,significand-size - (integer-length ,significand-var)))) - (setf ,significand-var (ash ,significand-var shift)) - (decf ,exponent-var shift))) - (cond ((zerop ,significand-var) - (setf (ldb ',exponent-bytespec ,bits-var) ,exponent-bias)) - ((< ,exponent-var ,min-exponent) + (let ((shift (- ,significand-size + (integer-length ,significand-var)))) + (setf ,significand-var (ash ,significand-var shift)) + (decf ,exponent-var shift)) + (cond ((< ,exponent-var ,min-exponent) (error 'floating-point-underflow :operation 'integer-float :operands (list ,client ',type 2