Date: Sun, 12 Jul 1998 20:05:59 +0300 (IDT) From: Eli Zaretskii To: DJ Delorie , Andrew Gibson cc: djgpp-workers AT delorie DOT com, Kbwms AT aol DOT com Subject: printf "%g" format conversions Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk The change in cvtl (on doprnt.c) was applied incorrectly, which made it work erratically, and cause nasty crashes with "%.1g". A patch is attached. However, I'm unsure about whether this change is justified. What it does is to cause e.g. printf ("%.3g", 0.01234) print "0.0123" instead of "0.012", as in v2.01. I wonder whether this is correct? The ANSI standard says that, under certain conditions (which hold in this example), %g behaves as %f would. But "%.3f" will print 0.012 here, so aren't we violating the standard? *** src/libc/ansi/stdio/doprnt.c~0 Sun Jun 28 23:58:02 1998 --- src/libc/ansi/stdio/doprnt.c Sat Jul 11 12:27:30 1998 *************** cvtl(long double number, int prec, int f *** 527,532 **** --- 527,533 ---- *p-- = '0'; } number = integer; + fract = modfl(number, &integer); /* If integer is zero then we need to look at where the sig figs are */ if (integer<1) { /* If fract is zero the zero before the decimal point is a sig fig */ *************** cvtl(long double number, int prec, int f *** 534,540 **** /* If fract is non-zero all sig figs are in fractional part */ else doextradps=1; } - fract = modfl(number, &integer); /* * get integer portion of number; put into the end of the buffer; the * .01 is added for modf(356.0 / 10, &integer) returning .59999999... --- 535,540 ----