Date: Thu, 14 Aug 2003 11:27:49 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: rich AT phekda DOT freeserve DOT co DOT uk Message-Id: <7458-Thu14Aug2003112749+0300-eliz@elta.co.il> X-Mailer: emacs 21.3.50 (via feedmail 8 I) and Blat ver 1.8.9 CC: djgpp-workers AT delorie DOT com In-reply-to: <3F3B2D8E.F90E84B5@phekda.freeserve.co.uk> (message from Richard Dawe on Thu, 14 Aug 2003 07:34:54 +0100) Subject: Re: Anomaly in printf() References: <46 DOT 3c4de930 DOT 2c6a2e90 AT aol DOT com> <3F3B2D8E DOT F90E84B5 AT phekda DOT freeserve DOT co DOT uk> Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > Date: Thu, 14 Aug 2003 07:34:54 +0100 > From: Richard Dawe > > Esa A E Peuha wrote: > > > > > > A mistake is in multiplying by 0.1 instead of dividing by 10 and taking > > > the remainder. > > > > I agree. This should definitely divide by ten to produce as accurate > > result as possible. Multiplying by 0.1 will cause errors when the > > number has large absolute value. Could someone test the following patch > > before I commit it? > [snip] > > FWIW the patch makes no difference to the result of the Cygnus test suite for > me. If anyone's interested, I've put the results here: > > http://www.phekda.freeserve.co.uk/richdawe/djgpp/2.04/ > > And K. B. Williams's test program (the one that displays "Begin with Rounding > Mode at Startup") shows the same results, when compiled with a patched libc. As I'd expect, FWIW: the problem seems to be that the result of either multiplying by 0.1 or dividing by 10 does not have an exact FP representation. That is, we are seeing inaccuracies in the last significant digit which are to be expected. I don't know how to fix this without a radical change in the algorithm. Btw, the code we have in _doprnt was originally taken from the BSD libc, IIRC. So if someone has access to FreeBSD, it'd be interesting to see if they exibit the same problem with K.B.'s test program.