about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 15:14:41 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 15:14:41 +0000
commit6d4cde8a3d52cc674276f2c34bde05b77eb0eecd (patch)
treea814b6c6ac6e4b0142eebc39f71f95f96abec3e4
parente8fc28f713cd7819194dd493fcacde56b764e4fc (diff)
downloadglibc-6d4cde8a3d52cc674276f2c34bde05b77eb0eecd.tar.gz
glibc-6d4cde8a3d52cc674276f2c34bde05b77eb0eecd.tar.xz
glibc-6d4cde8a3d52cc674276f2c34bde05b77eb0eecd.zip
2007-04-30 Jakub Jelinek <jakub@redhat.com>
	* stdio-common/printf_fp.c (___printf_fp): Don't print negative sign
	for exponent 0.
	* stdio-common/tfformat.c (sprint_doubles): Add a new test.
-rw-r--r--ChangeLog6
-rw-r--r--stdio-common/printf_fp.c8
-rw-r--r--stdio-common/tfformat.c2
3 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index afe6ee0510..43c79445ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2007-04-30  Jakub Jelinek  <jakub@redhat.com>
 
+	* stdio-common/printf_fp.c (___printf_fp): Don't print negative sign
+	for exponent 0.
+	* stdio-common/tfformat.c (sprint_doubles): Add a new test.
+
+2007-04-30  Jakub Jelinek  <jakub@redhat.com>
+
 	[BZ #4439]
 	* resolv/inet_ntop.c (inet_ntop4): Take terminating '\0' into
 	account in the size check.
diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c
index 6784edf254..5ade1df0d8 100644
--- a/stdio-common/printf_fp.c
+++ b/stdio-common/printf_fp.c
@@ -793,7 +793,7 @@ ___printf_fp (FILE *fp,
   else
     {
       /* This is a special case.  We don't need a factor because the
-	 numbers are in the range of 0.0 <= fp < 8.0.  We simply
+	 numbers are in the range of 1.0 <= |fp| < 8.0.  We simply
 	 shift it to the right place and divide it by 1.0 to get the
 	 leading digit.	 (Of course this division is not really made.)	*/
       assert (0 <= exponent && exponent < 3 &&
@@ -1013,6 +1013,12 @@ ___printf_fp (FILE *fp,
 		  {
 		    *wstartp = '1';
 		    exponent += expsign == 0 ? 1 : -1;
+
+		    /* The above exponent adjustment could lead to 1.0e-00,
+		       e.g. for 0.999999999.  Make sure exponent 0 always
+		       uses + sign.  */
+		    if (exponent == 0)
+		      expsign = 0;
 		  }
 		else if (intdig_no == dig_max)
 		  {
diff --git a/stdio-common/tfformat.c b/stdio-common/tfformat.c
index 259e2e0b18..d67b3b504d 100644
--- a/stdio-common/tfformat.c
+++ b/stdio-common/tfformat.c
@@ -4021,6 +4021,8 @@ sprint_double_type sprint_doubles[] =
   {__LINE__, 0.000098,			"0.0001", "%#.0g"},
   {__LINE__, 0.0000996,			"0.00010", "%#.2g"},
   {__LINE__, 9.999999999999999e-05,	"0.0001", "%g"},
+  {__LINE__, 1.0,			"1.000000e+00", "%e"},
+  {__LINE__, .9999999999999999,		"1.000000e+00", "%e"},
 
   {0 }