This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
floating-point formatting issue
- From: Allin Cottrell <cottrell at wfu dot edu>
- To: libc-alpha at sources dot redhat dot com
- Date: Sat, 28 Jul 2007 13:59:11 -0400 (EDT)
- Subject: floating-point formatting issue
I'm running this by the list in case it's already handled in CVS.
There's an issue with the handling of the "%g" format specifier
in the glibc 2.6 release. Consider this program:
#include <stdio.h>
int main (void)
{
printf("x = %#.5g\n", 51.0);
printf("y = %#.5g\n", 50.999999);
return 0;
}
As I understand the C standard, this should print
x = 51.000
y = 51.000
but on my system with glibc 2.6 it prints
x = 51.000
y = 51.00
(This seems to be the converse of a bug in glibc <= 2.5, whereby
it would append an extra zero when printing certain numbers with
the "%#.<digits>g" specifier.)
--
Allin Cottrell
Department of Economics
Wake Forest University, NC