Skip to content

Commit

Permalink
jaffer: fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
yitzchak committed Jun 27, 2024
1 parent 4d9cf40 commit ef62339
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions code/jaffer/implementation.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@
(bex (- (integer-length ,significand)
(integer-length scale)
,significand-size))
(tmp (+ bex ,exponent 1021 ,significand-size)))
(tmp (+ bex ,exponent 1021 ,significand-size))
(mantlen ,significand-size))
(when (minusp tmp)
(decf bex (1+ tmp))
(setf scale (ash scale 1)))
(incf mantlen tmp))
(let* ((num (ash ,significand (- bex)))
(quotient (round num scale)))
(when (> (integer-length quotient) ,significand-size)
(when (> (integer-length quotient) mantlen)
(incf bex)
(setf quotient (round num (ash scale 2))))
(setf quotient (round num (ash scale 1))))
(scale-float (coerce quotient ',result-type) (+ bex exponent))))
(let ((num (* ,significand (expt 5 ,exponent)))
(bex (- (integer-length ,significand-size))))
(let* ((num (* ,significand (expt 5 ,exponent)))
(bex (- (integer-length num) ,significand-size)))
(if (plusp bex)
(scale-float (coerce (round num (ash 1 bex)) ',result-type)
(+ bex exponent))
Expand Down

0 comments on commit ef62339

Please sign in to comment.