mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-25 05:51:55 -08:00
format: print 0 after decimal point with ~e for integer input
Example: (format t "~e" 1.0) used to print 1.e+0, now prints 1.0e+0 Code adapted from SBCL.
This commit is contained in:
parent
d0a24fe283
commit
d55d31df3b
1 changed files with 8 additions and 2 deletions
|
|
@ -1393,14 +1393,19 @@
|
|||
nil)))
|
||||
(if (and w ovf e (> elen e)) ;exponent overflow
|
||||
(dotimes (i w) (write-char ovf stream))
|
||||
(multiple-value-bind (fstr flen lpoint)
|
||||
(multiple-value-bind (fstr flen lpoint tpoint)
|
||||
(sys::flonum-to-string number spaceleft fdig (- expt) fmin)
|
||||
(when (eql fdig 0) (setq tpoint nil))
|
||||
(when w
|
||||
(decf spaceleft flen)
|
||||
(when lpoint
|
||||
(if (> spaceleft 0)
|
||||
(decf spaceleft)
|
||||
(setq lpoint nil))))
|
||||
(setq lpoint nil)))
|
||||
(when tpoint
|
||||
(if (<= spaceleft 0)
|
||||
(setq tpoint nil)
|
||||
(decf spaceleft))))
|
||||
(cond ((and w (< spaceleft 0) ovf)
|
||||
;;significand overflow
|
||||
(dotimes (i w) (write-char ovf stream)))
|
||||
|
|
@ -1411,6 +1416,7 @@
|
|||
(if atsign (write-char #\+ stream)))
|
||||
(when lpoint (write-char #\0 stream))
|
||||
(write-string fstr stream)
|
||||
(when tpoint (write-char #\0 stream))
|
||||
(write-char (if marker
|
||||
marker
|
||||
(format-exponent-marker number))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue