delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/12/27/13:58:00

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-Id: <m14BLkq-005FNCC@smtp.web.de>
From: "Ulrich Jakobus" <u DOT jakobus AT web DOT de>
To: "cygwin AT sourceware DOT cygnus DOT com" <cygwin AT sourceware DOT cygnus DOT com>
Cc: "Johann van Tonder" <jvtonder AT emss DOT co DOT za>
Date: Wed, 27 Dec 2000 20:55:10 +0200
Reply-To: "Ulrich Jakobus" <u DOT jakobus AT web DOT de>
X-Mailer: PMMail 2000 Professional (2.10.2010) For Windows 2000 (5.0.2195;1)
MIME-Version: 1.0
Subject: cygwin/newlib bug in printf with %f format

Hello,

when printing floating point numbers which are very small
but not exactly zero using the %f format of printf, then 
since cygwin-1.1.5-6 (also still in recent cygwin-1.1.7) 
there is a formatting bug. cygwin-1.1.4 and earlier versions
were fine (I did not test versions between 1.1.4 and 1.1.5-6,
so I cannot tell precisely since when the problem exists).

To illustrate the problem, just compile the following code:

---------------------------------------
#include <stdio.h>
int main()
{
  printf ("%10.3f\n", 0.0);
  printf ("%10.3f\n", 0.0+1.0e-12);
  printf ("%10.3f\n", 1.0);
  printf ("%10.3f\n", 1.0+1.0e-12);
}
----------------------------------------

Output of this sample code should be

     0.000
     0.000
     1.000
     1.000

but with cygwin1.dll since version 1.1.5-6 it actually is

     0.000
     0
     1.000
     1.000

i.e. the second line is too short, the last four characters ".000"
are missing (this is very irritating when printing tables, since
all output following on the same line is shifted).

Could someone please try to identify this problem and fix
it? I just guess that it might be in libc/stdio/vfprintf.c
but am not sure.

Thanks very much and season greetings!

Ulrich





--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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