Skip to content
Snippets Groups Projects
Commit 75de5422 authored by rtoy's avatar rtoy
Browse files

Was failing to print enough digits for things like (format nil

"~9,,,-2E" 1.2345689d-3).   This change also allows us to get rid of
one other call to flonum-to-string, so printing should be faster now.

Some additional tests:

(assert (string= (format nil "~9,,,-2E" 1.2345689d3) ".00123d+6"))
(assert (string= (format nil "~9,,,-2E" -1.2345689d3) "-.0012d+6"))
(assert (string= (format nil "~9,,,-2E" 1.2345689d-3) ".00123d+0"))
(assert (string= (format nil "~9,,,-2E" -1.2345689d-3) "-.0012d+0"))
parent 9e71e519
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain. ;;; Carnegie Mellon University, and has been placed in the public domain.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/print.lisp,v 1.118 2008/01/25 19:16:12 rtoy Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/print.lisp,v 1.119 2008/01/26 02:09:44 rtoy Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -1511,21 +1511,18 @@ radix-R. If you have a power-list then pass it in as PL." ...@@ -1511,21 +1511,18 @@ radix-R. If you have a power-list then pass it in as PL."
(- (or fmin 0))) (- (or fmin 0)))
num-expt)) num-expt))
(if (and width (> width 1)) (if (and width (> width 1))
(let ((w (multiple-value-list (let ((ndigits (1- width)))
(let ((ndigits (1- width)) #+(or)
(scaled (+ num-expt (or scale 0)))) (progn
(when (and scale (< scale 0)) (format t "ndigits = ~A~%" ndigits)
(setf ndigits (- ndigits scaled 1))) (format t "scale = ~A~%" scale))
(fixup-flonum-to-digits x num-expt (when (and scale (< scale 0))
ndigits (setf ndigits (+ ndigits scale)))
t)))) (when (minusp num-expt)
(f (multiple-value-list (incf ndigits (- num-expt)))
(fixup-flonum-to-digits x num-expt (fixup-flonum-to-digits x num-expt
(- num-expt (or fmin 0) 1))))) ndigits
(cond t))
((>= (length (cadr w)) (length (cadr f)))
(values-list w))
(t (values-list f))))
(fixup-flonum-to-digits x num-expt))) (fixup-flonum-to-digits x num-expt)))
(let ((e (+ e (or scale 0))) (let ((e (+ e (or scale 0)))
(stream (make-string-output-stream))) (stream (make-string-output-stream)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment