This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]