[TAG] article "A Question Of Rounding" in issue #143 (Was: [Bug libc/4943] Inconsistent rounding behaviour for sprintf and IEEE doubles)

Paul Sephton paul at inet.co.za
Fri Oct 5 10:44:48 MSD 2007


On Fri, 2007-10-05 at 09:27 +0530, Kapil Hari Paranjape wrote:
> [TAG] Paul Sephton's article "A Question Of Rounding"
> 
> On Wed Oct 3 13:49:39 PDT 2007 Paul Sephton wrote:
> 
> > The numbers 0.5, 1.5, 2.5 ... are EXACTLY represented by the FPU.
> 
> Once you realise that "floating point numbers" are not "numbers" but
> "intervals" or (more strictly) "values with error bars", you will see
> why a lot of people who work with "floating point" implementations 
> got upset with your article and other remarks. A statement such as the
> one above would be interpreted as "meaningless" by those "in the know".
> 
> To explain this a bit futher:
> 
> This expectation is even correct from the "common man's" perspective,
> but it is wrong from the perspective of how the programming language
> is defined.
> 
> They are implementing one type of thing and you are interested in
> something else.

There is a principle involved here, called "The principle of least
surprise" http://en.wikipedia.org/wiki/Principle_of_least_astonishment
states that "when two elements of an interface conflict or are
ambiguous, the behaviour should be that which will least surprise the
human user or programmer at the time the conflict arises."

In the context of decimal arithmetic, and conversion from a binary
format to decimal, one does not generally expect bankers rounding to be
the default.  One would rather expect scientific rounding.

> It is only recently that a large number of people have started using
> floating point in the context of "decimal arithmetic". Hence there is
> a serious attempt to create a new standard which is aimed to resolve
> (among other things) the issues you raise.

Define "recent"?  You might be interested in a quite old article
entitled "How to print Floating-Point numbers accurately". 

http://delivery.acm.org/10.1145/100000/93559/p112-steele.pdf?key1=93559&key2=0819941911&coll=portal&dl=ACM&CFID=1611300&CFTOKEN=36033037

It covers VAX, IBM and IEEE arithmetic.






More information about the TAG mailing list