Use float arithmetic when should use integer arithmetic
Closed this issue · 1 comments
Yehouda commented
parse-number/parse-number.lisp
Line 256 in de944fd
The code for make-float/whole does floating-point arithmetic when it should do integer arithmetic, which can lose precision. It should do all computation in integers, and then coerce to float, somehing like:
(let ((integer-value (* (number-value whole-place)
(expt 10
(number-value exp-place))))
(type (type-for-exponent-marker exp-marker))
(coerce integer-value type))
make-float/frac should do the same, compute a ratio number, and then coerce.
running on LispWorks:
CL-USER 113 > (read-from-string "5d50")
(read-from-string "5d50")
5.0D50
4
CL-USER 114 > (parse-number:parse-number "5d50")
(parse-number:parse-number "5d50")
5.000000000000027D50
Should also add large exponents to the tests.