[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
Re: Paul Sephton's article "A Question Of Rounding" in the Linux Gazette
On 2007-10-03 17:22:19 +0200, Thorsten Siebenborn wrote:
"Most" is a bit harsh. One error is that the value 45.658 of
45.657784532 is accurate to five digits, not three (He obviously meant
three fractional digits). Then he didn't knew that 2.49999999999992
isn't binary, but must be already approximated. I have seen far worse
articles.
The confusion is more than that. He also wants 5000.525 (which is
smaller than 5000.525 when converted to binary) to be rounded to
5000.53 with "%.2f".
He means "Round away from zero" or according to the Draft standard,
"roundTiesToAway". So his idea of implementing other rounding modes
is in fact already anticipated in the new IEEE 754 R draft.
Basically what he really wants is decimal arithmetic with
roundTiesToAway. I told him in the bug report, mentioned
IEEE754R, and told him to wait for this being implemented.
But he doesn't understand that and still thinks that the
libraries (using binary arithmetic) are wrong:
The following code demonstrates the principles discussed in this
article, and properly converts binary IEEE values to decimal format
inside a buffer for display according to generally accepted
mathematical standards - at least for the Intel platform. Note that
printf("%.2f", 5000.525);
fails to produce the expected result in both Microsoft and GNU
libraries.
Of course, his code fails on 2749067691242291.0/549755813888.0 .
What is so wrong with the article that it should be killed ?
This article will lead many users to confusion.
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)