delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2000/08/16/07:33:40

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-developers-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-developers-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com
Message-ID: <779F20BCCE5AD31186A50008C75D997917177B@silldn_mail1.sanwaint.com>
From: "Fifer, Eric" <EFifer AT sanwaint DOT com>
To: "'cygwin-developers AT sources DOT redhat DOT com'"
<cygwin-developers AT sources DOT redhat DOT com>
Cc: "'newlib AT sources DOT redhat DOT com'" <newlib AT sources DOT redhat DOT com>
Subject: printf("%.0f", 0.1) => 0.
Date: Wed, 16 Aug 2000 12:31:31 +0100
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C00775.86A03BF0
Content-Type: text/plain;
	charset="iso-8859-1"


I discovered this when testing the latest Perl:

	main()
	{
    		printf("%.0f\n", 0.1);
    		printf("%.0f\n", -0.1);
	}

Produces:

	0.
	-0.

The trailing dot is the problem.  Attached is a suggested
change that seems to fix the problem and not introduce any
others.

Regards,

Eric Fifer


------_=_NextPart_000_01C00775.86A03BF0
Content-Type: application/octet-stream;
	name="printf.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="printf.patch"

=0A=
ChangeLog=0A=
=0A=
	* libc/stdio/vfprintf.c (_vfprintf_r): suppress . with "%.0f", 0.1=0A=
=0A=
--- cygwin-1.1.4/newlib/libc/stdio/vfprintf.c.orig	Tue Aug 15 17:37:29 =
2000=0A=
+++ cygwin-1.1.4/newlib/libc/stdio/vfprintf.c	Wed Aug 16 10:15:54 =
2000=0A=
@@ -805,9 +805,11 @@=0A=
 					}=0A=
 				} else if (expt <=3D 0) {=0A=
 					PRINT("0", 1);=0A=
-					PRINT(decimal_point, 1);=0A=
-					PAD(-expt, zeroes);=0A=
-					PRINT(cp, ndig);=0A=
+					if(ndig) {=0A=
+						PRINT(decimal_point, 1);=0A=
+						PAD(-expt, zeroes);=0A=
+						PRINT(cp, ndig);=0A=
+					}=0A=
 				} else if (expt >=3D ndig) {=0A=
 					PRINT(cp, ndig);=0A=
 					PAD(expt - ndig, zeroes);=0A=

------_=_NextPart_000_01C00775.86A03BF0--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019