#291 FORMAT treats scale factor for exponential notation incorrectly

Stable_release
open
nobody
5
2014-05-20
2014-05-20
Robert Dodier
No

CLHS says (22.3.3.2): "k is a scale factor that defaults to one (not zero)" ... "If k is zero, then d digits are printed after the decimal point, and a single zero digit appears before the decimal point if the total field width will permit it. If k is positive, then it must be strictly less than d+2; k significant digits are printed before the decimal point, and d-k+1 digits are printed after the decimal point. If k is negative, then it must be strictly greater than -d; a single zero digit appears before the decimal point if the total field width will permit it, and after the decimal point are printed first -k zeros and then d+k significant digits."

Here's what I get with ECL built today from Git (advertised version = 13.5.1).

> (loop for k in '(-2 -1 0 1 2) do (format t "~,4,,ve~%" k 1.23456789e-10))
0.01235e-8
0.1235e-9
1.2346e-10
12.3457e-11
123.457e-12
NIL

From what I can tell, those are all wrong according to the CLHS description above. I think these (from SBCL 1.0.55.0) are correct:

* (loop for k in '(-2 -1 0 1 2) do (format t "~,4,,ve~%" k 1.23456789e-10))
0.0012e-7
0.0123e-8
0.1235e-9
1.2346e-10
12.346e-11
NIL

Discussion


Anonymous


Cancel   Add attachments