Skip to content

Commit

Permalink
burger-dybvig, schubfach: ensure integer signs
Browse files Browse the repository at this point in the history
* code/burger-dybvig/implementation.lisp (quaviver:float-decimal):
* code/schubfach/implementation.lisp (%float-decimal): Wrap FLOAT-SIGN
calls in FLOOR to convert signs to integer.
  • Loading branch information
paulapatience committed Jun 12, 2024
1 parent 1fd6c18 commit cd2e010
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions code/burger-dybvig/implementation.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
for high-out = (* (+ value (* factor (1+ d))) (expt 10 scale))
finally (return (values result
(- scale (length result))
(float-sign x)))
(floor (float-sign x))))
do (cond ((and (> low-out low)
(>= high-out high))
(vector-push-extend d result)
Expand Down Expand Up @@ -318,7 +318,7 @@
(go next)))
(return (values result
(- s (length result))
(float-sign x)))))
(floor (float-sign x))))))

(defun int-1 (x)
(let* ((v- (predecessor x))
Expand Down Expand Up @@ -351,7 +351,7 @@
;;; but reimplements the algorithm they present in Common Lisp.
(defmethod quaviver:float-decimal ((client client-2) x)
(if (zerop x)
(values #(0) 0 (float-sign x))
(values #(0) 0 (floor (float-sign x)))
(multiple-value-bind (f e sign)
(integer-decode-float x)
;; adjust mantissa and exponent
Expand Down
2 changes: 1 addition & 1 deletion code/schubfach/implementation.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@

(defun %float-decimal (client value bits significand-bits exponent-offset pow-10)
(if (zerop value)
(values 0 0 (float-sign value))
(values 0 0 (floor (float-sign value)))
(let* ((width (ash bits 1))
(value-bits (quaviver:float-bits client value))
(ieee-significand (ldb (byte (1- significand-bits) 0) value-bits))
Expand Down

0 comments on commit cd2e010

Please sign in to comment.