(format nil "~,1e" 99.999) ; => "10.0e+1"
Bug #876655 reported by
Alexander Klimov
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Triaged
|
Low
|
Unassigned |
Bug Description
on SBCL 1.0.52.1-805f1dd
(format nil "~,1e" 99.999) ; => "10.0e+1"
but it should produce the same result as
(format nil "~,1e" 100.001) ; => "1.0e+2"
The attached patch contains more tests.
I guess the culprit is format-exp-aux that uses scale-exponent on the non-rounded number, but applies (thru flonum-to-string) the produced exponent to the rounded number.
tags: | added: review |
tags: | removed: review |
To post a comment you must log in.
I'm not sure they are actually required to produce the same string.
My reasoning:
"k is a scale factor that defaults to one (not zero)" -
So k is 1.
"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."
Both "10.0e+1" and "1.0e+2" have 1 /significant/ digit before the decimal point.
d-k+1 = 1
Both have 1 digit after the decimal point, so unless there are other constraints which I missed, they both seem legal to me.
Can you lay out your reasoning as to why they should produce the same output?