float of integer-decode-float isn't the identity
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Decoding 2d-308 with integer-
This happens with many floats smaller than COMMON-
But the Common Lisp Manual clearly says that this should be exact:
The product of the first result of decode-float or integer-
raised to the power of the second result, and of the third result is exactly equal to
the value of float.
To test:
(defun idf (x) (multiple-
(defun testfloat (k)
(let* ((kidf (idf k))
(kff (float (* (car kidf) (expt 2 (cadr kidf))) k))
(kss (scale-float (float (car kidf)) (cadr kidf))))
(format t "Input k: ~,15e, IDF ~s~%" k kidf)
(format t "float k: ~,15e, IDF ~s, diff ~,5e~%" kff (idf kff) (- k kff))
(format t "scale k: ~,15e, IDF ~s, diff ~,5e~%" kff (idf kss) (- k kss))))
(testfloat 2d-308)
gives
Input k: 2.0000000000000
float k: 1.9999985067133
scale k: 1.9999985067133
the floats and the IDFs should all be the same, and the diffs should be zero.
This problem was found while testing code on Maxima.
Versions tested:
SBCL 2.0.0 on Windows (Maxima 5.44.0):
SBCL 2.0.1.debian on Ubuntu under Windows WSL:
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
Please update the Maxima bug report when this changes status: /sourceforge. net/p/maxima/ bugs/3778/
https:/
Thanks