Skip to content

Commit

Permalink
quaviver: fix zero significand bug in integer-float/2
Browse files Browse the repository at this point in the history
* code/integer-float-2.lisp (%integer-encode-float): Don't set the
exponent bits when the significand is 0.
  • Loading branch information
paulapatience committed Jun 27, 2024
1 parent d6295f2 commit 4d9cf40
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions code/integer-float-2.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4d9cf40

Please sign in to comment.