format: flonum-to-string: Fix corner-case when printing "0.0".

When printing 0.0 and fdigits parameter set to 0 or nil, single "."
was printed, what is not valid float number. Now it at least prints
".0".

Signed-off-by: Daniel Kochmański <dkochmanski@turtle-solutions.eu>
This commit is contained in:
Daniel Kochmański 2015-05-10 20:13:06 +02:00
parent 5cbb3b905a
commit 1e2d00ed3a

View file

@ -99,11 +99,11 @@
(declare (type float x))
(cond ((zerop x)
;; Zero is a special case which FLOAT-STRING cannot handle.
(if fdigits
(if (and fdigits (/= fdigits 0))
(let ((s (make-string (1+ fdigits) :initial-element #\0)))
(setf (schar s 0) #\.)
(values s (length s) t (zerop fdigits) 0))
(values "." 1 t t 0)))
(values s (length s) t nil 0))
(values ".0" 2 t nil 0)))
(t
(multiple-value-bind (e string)
(cond