#256 bug in format ~f

Stable_release
open
nobody
None
1
2013-03-31
2013-03-31
Anonymous
No

Comparing output from different implementations I've found a bug on the floating-point formatter:

(format t "~5f" 123.123)
123.12 ;; should be 123.1 ("Exactly w characters will be output.", hyperspec 22.3.3.1)

When the value is close to zero, there are two additional characters in the output instead of one:

(format t "~5f" 0.00000001)
.000000 ;; should be 0.0, I think (but most implementations print .0000)

"If the parameter d is omitted, then there is no constraint on the number of digits to appear after the decimal point. A value is chosen for d in such a way that as many digits as possible may be printed subject to the width constraint imposed by the parameter w and the constraint that no trailing zero digits may appear in the fraction, except that if the fraction to be printed is zero, then a single zero digit should appear after the decimal point if permitted by the width constraint."

Discussion


Anonymous


Cancel   Add attachments