From 3c160594e9c926555206b6cc73afd0bf43eefaf8 Mon Sep 17 00:00:00 2001
From: rtoy <rtoy>
Date: Thu, 31 Jan 2008 18:24:05 +0000
Subject: [PATCH] Revise again.  Don't limit the fraction digits.  Just print
 out whatever dd says.  This allows ~G to match what Fortran does, and also
 defers to ~F to let it decide what to do.

The following tests now fail:

(assert (string= (format nil "~9,5G" pi) "3.142    "))
(assert (string= (format nil "~12,,,,'%g" 1.2345678d1) "12.34568 "))

The former should be
(assert (string= (format nil "~9,5G" pi) "3.1416    "))

and the latter should be removed or changed to

(assert (string= (format nil "~12,,,,'%g" 1.2345678d1) "%%%%%%%%%%%%"))
---
 code/format.lisp | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/code/format.lisp b/code/format.lisp
index ba5cc4ae9..5b5103a28 100644
--- a/code/format.lisp
+++ b/code/format.lisp
@@ -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.80 2008/01/30 15:35:29 rtoy Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/format.lisp,v 1.81 2008/01/31 18:24:05 rtoy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -1444,16 +1444,11 @@
 	    (format t "ww = ~A~%" ww)
 	    (format t "dd = ~A~%" dd))
 	  (cond ((<= 0 dd d)
-		 ;; Figure out how many fraction digits we really want
-		 ;; to print.  If we can, use dd.  If not, adjust it
-		 ;; so that we print as many fraction digits as
-		 ;; possible without exceeding the width constraint,
-		 ;; if any.
-		 (let* ((ndigits (if ww
-				     (max 0 (min dd (- ww 1 n)))
-				     dd))
-			(char (if (format-fixed-aux stream number ww
-						    ndigits
+		 ;; 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
+						    dd
 						    nil
 						    ovf pad atsign)
 				  ovf
-- 
GitLab