#1: prin1 and ~E produce different outputs. ------------------------+--------------------------------------------------- Reporter: anonymous | Owner: somebody Type: defect | Status: new Priority: minor | Milestone: Component: component1 | Version: Keywords: printing | ------------------------+--------------------------------------------------- (let ((x (random 1d-3))) (values (prin1-to-string x) (format nil "~E" x)))
will produce different significant digits. I think the problem is in ~E which calls lisp::scale-exponent to scale the number between 0.1 and 1. I think we could just call flonum-to-digits which will give us the digits and the exponent. We can massage that into the desired digits and exponent as in scale-exponent, but we won't have the round-off problem.
Maybe.
#1: prin1 and ~E produce different outputs. ------------------------+--------------------------------------------------- Reporter: anonymous | Owner: rtoy Type: defect | Status: assigned Priority: minor | Milestone: Component: Core | Version: Resolution: | Keywords: printing ------------------------+--------------------------------------------------- Changes (by rtoy):
* status: new => assigned * owner: somebody => rtoy
#1: prin1 and ~E produce different outputs. ------------------------+--------------------------------------------------- Reporter: anonymous | Owner: rtoy Type: defect | Status: assigned Priority: minor | Milestone: Component: Core | Version: 19c Resolution: | Keywords: printing ------------------------+--------------------------------------------------- Changes (by rtoy):
* version: => 19c
#1: prin1 and ~E produce different outputs. ------------------------+--------------------------------------------------- Reporter: anonymous | Owner: rtoy Type: defect | Status: assigned Priority: minor | Milestone: Component: Core | Version: 19c Resolution: | Keywords: printing ------------------------+--------------------------------------------------- Old description:
(let ((x (random 1d-3))) (values (prin1-to-string x) (format nil "~E" x)))
will produce different significant digits. I think the problem is in ~E which calls lisp::scale-exponent to scale the number between 0.1 and 1. I think we could just call flonum-to-digits which will give us the digits and the exponent. We can massage that into the desired digits and exponent as in scale-exponent, but we won't have the round-off problem.
Maybe.
New description:
{{{ (let ((x (random 1d-3))) (values (prin1-to-string x) (format nil "~E" x))) }}}
will produce different significant digits. I think the problem is in ~E which calls lisp::scale-exponent to scale the number between 0.1 and 1. I think we could just call flonum-to-digits which will give us the digits and the exponent. We can massage that into the desired digits and exponent as in scale-exponent, but we won't have the round-off problem.
Maybe.
#1: prin1 and ~E produce different outputs. ------------------------+--------------------------------------------------- Reporter: anonymous | Owner: rtoy Type: defect | Status: closed Priority: minor | Milestone: Component: Core | Version: 19c Resolution: fixed | Keywords: printing ------------------------+--------------------------------------------------- Changes (by rtoy):
* resolution: => fixed * status: assigned => closed
Comment:
One particular example is {{{ (format nil "~E" 1.234567890123456789d4) "1.2345678901234565d+0" }}}
The right answer is {{{ "1.2345678901234567d+0" }}}
which is what {{{prin1}}} returns.
This should now be fixed in CVS.