Commit 23067adf authored by rtoy's avatar rtoy
Browse files

Handle 0.0 for ~G. This was causing an divide by zero error.

parent db5875c8
Loading
Loading
Loading
Loading
+9 −4
Changes for code/format.lisp: 9 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(ext:file-comment
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/format.lisp,v 1.81 2008/01/31 18:24:05 rtoy Exp $")
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/format.lisp,v 1.81.2.1 2008/02/29 17:58:45 rtoy Exp $")
;;;
;;; **********************************************************************
;;;
@@ -1432,8 +1432,13 @@
	;; Exponential notation would be used instead.
	
	(unless d
	  ;; flonum-to-digits doesn't like 0.0, so handle the special
	  ;; case here.  Set d to n so that dd = 0 <= d to use ~F
	  ;; format.
	  (if (zerop number)
	      (setq d n)
	      (let* ((q (length (nth-value 1 (lisp::flonum-to-digits (abs number))))))
	    (setq d (max q (min n 7)))))
		(setq d (max q (min n 7))))))
	(let* ((ee (if e (+ e 2) 4))
	       (ww (if w (- w ee) nil))
	       (dd (- d n)))
@@ -1447,13 +1452,13 @@
		 ;; Use dd fraction digits, even if that would cause
		 ;; the width to be exceeded.  We choose accuracy over
		 ;; width in this case.
		 (let* ((char (if (format-fixed-aux stream number ww
		 (let* ((fill-char (if (format-fixed-aux stream number ww
							 dd
							 nil
							 ovf pad atsign)
				       ovf
				       #\space)))
		   (dotimes (i ee) (write-char char stream))))
		   (dotimes (i ee) (write-char fill-char stream))))
		(t
		 (format-exp-aux stream number w
				 orig-d