Marsden. (lp#816564)
* bug fix: obsolete instance protocol fires when shared slots are added
or removed.
+ * bug fix: fixed-format floating point printing with scaling factors.
+ (lp#811386)
changes in sbcl-1.0.50 relative to sbcl-1.0.49:
* enhancement: errors from FD handlers now provide a restart to remove
(values-list w))
(t (values-list f))))
(flonum-to-digits x)))
- (let ((e (+ e (or scale 0)))
+ (let ((e (if (zerop x)
+ e
+ (+ e (or scale 0))))
(stream (make-string-output-stream)))
(if (plusp e)
(progn
(write-string "." stream)
(dotimes (i (- e))
(write-char #\0 stream))
- (write-string string stream)
+ (write-string string stream :end (when fdigits
+ (min (length string)
+ (max (or fmin 0)
+ (+ fdigits e)))))
(when fdigits
(dotimes (i (+ fdigits e (- (length string))))
(write-char #\0 stream)))))
(when (and d (zerop d)) (setq tpoint nil))
(when w
(decf spaceleft flen)
- ;; See CLHS 22.3.3.2. "If the parameter d is
- ;; omitted, ... [and] if the fraction to be
- ;; printed is zero then a single zero digit should
- ;; appear after the decimal point." So we need to
- ;; subtract one from here because we're going to
- ;; add an extra 0 digit later. [rtoy]
- (when (and (zerop number) (null d))
- (decf spaceleft))
(when lpoint
(if (or (> spaceleft 0) tpoint)
(decf spaceleft)
(if atsign (write-char #\+ stream)))
(when lpoint (write-char #\0 stream))
(write-string fstr stream)
- (when (and (zerop number) (null d))
- ;; It's later and we're adding the zero
- ;; digit.
- (write-char #\0 stream))
(write-char (if marker
marker
(format-exponent-marker number))
(list f (read-from-string (prin1-to-string f))))
oops)))))
+(with-test (:name :bug-811386)
+ (assert (equal " 0.00" (format nil "~7,2,-2f" 0)))
+ (assert (equal " 0.00" (format nil "~7,2,2f" 0)))
+ (assert (equal " 0.01" (format nil "~7,2,-2f" 1)))
+ (assert (equal " 100.00" (format nil "~7,2,2f" 1)))
+ (assert (equal " 0.00" (format nil "~7,2,-2f" 0.1)))
+ (assert (equal " 10.00" (format nil "~7,2,2f" 0.1)))
+ (assert (equal " 0.01" (format nil "~7,2,-2f" 0.5))))
+
;;; success