To: djgpp AT sun DOT soe DOT clarkson DOT edu From: "Josef Spangler" Date: 22 Jul 93 14:55:48 MET Subject: printf format bug fixed; where is debug32v1.10a Hello DJGPP gcc freaks, 1. Question about go32 und debug32 version: ------------------------------------------- In the distibution djdev110.zip on omnigate the above programs have version 1.10. But these don't work with gr or grx graphics. In the pub subdir there is csdpmit1.zip with go32.exe version 1.10a and with this the graphics works again. But where can I find a new debug32? 2. Bug in printf %lg format found --------------------------------- The default precision lengths for the %g and %lg formats are to big. To clarify, test the following program: #include #include #include double anint(double x) { return ( floor(x+0.5) ); } /* fight the dust; approx gives the order of magnitude */ double hoover (double dusty, double approx) { double ani; ani = anint(dusty/(approx)) * approx; /* this gives dust */ printf("%le\t%le\t%le\t%lg\n",dusty,approx, ani, ani ); /* this is ok */ printf("%le\t%le\t%.14le\t%.14lg\n",dusty,approx, ani, ani ); return( anint(dusty/(approx)) * approx); } int main(void) { int i; double y = 0.0; double dusty,approx; dusty = 0.0; approx = 1.000000000000001e-4; for (i = 0; i < 5; i++) { y = hoover(dusty,approx); dusty += 0.5; } return 0; } The problem is in file libsrc\c\io\doprnt.c line 42, 43, where the default precision lengths are defined: #define DEFPREC 7 #define DEFLPREC 16 So without explicit specification more digits as valid are printed. Look at the following table: Name Bits valid digits DEFxPREC old DEFxPREC new float 32 7-8 7 6 double 64 15-16 16 14 long double 80 19-20 16 14 All other c compilers like gcc2.2.x on sparc, emx-0.8g, bcpp3.1, watcomc386v9.01, msc6.0 ... use a default len of 6 for %g *and* %lg Changing these values to 6/14 looks resonable and corrects the problem: #define DEFPREC 6 #define DEFLPREC 14 Please could this fix applied in the next release? with greetings J.Spangler =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Josef Spangler Phone: (+49) 941/943-2059 Institute for Applied Physics Fax: (+49) 941/943-4223 University of Regensburg Mail: js AT rphnw3 DOT ngate DOT uni-regensburg DOT de Universitaetsstr. 31 or: c4011 AT rphs1 DOT physik DOT uni-regensburg DOT de D-8400 Regensburg, Germany X400: spangler AT vax1 DOT rz DOT uni-regensburg DOT dbp DOT de