Subject: cygwin/newlib bug in printf with %f format
From: "Ulrich Jakobus" <[email-masked]>
To: "[email-masked]" <[email-masked]>
Cc: "Johann van Tonder" <[email-masked]>
Date: Wed, 27 Dec 2000 20:55:10 +0200

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