Back in the dark ages, when mainframes walked the earth,
we would get "bug reports" about once a month about
the formatting of real numbers in SHARP APL. (For some unknown
reason, 0.07 came up frequently.) The problem was
that this number would display as something like:

   0.070000000000001

rather than as the 0.07 that the user had entered
I had a talk with Larry Breed around that
time, and he mentioned an idea for formatting that he had heard
about, but at the time, it wasn't in print. The basic idea is
this:

1. There is a range R of real numbers which, if entered into
    a computer, all map to the same floating-point number internally.

2. There is no way to determine which of the numbers originally
    was entered, hence there is no reason to pick one element of
    R over another as being somehow "more precise", when printing.

3. Hence, when printing, pick the number from R that has the
    fewest significant digits.

In the above example, of course, this is 0.07.

We talked this over, and Doug Forkes ended up rewriting the
real-number formatter along these lines. Net result: the
"bug reports" stopped coming in. Not a single complaint about
missing digits, etc.

Eventually, there came a few papers on the topic ( I think,
but am not sure, that LMB was referring to Steele's work.):

How to Print Floating-Point Numbers Accurately. Guy L. Steele Jr. Sun 
Microsystems Laboratories. 1 Network Drive, UBUR02-311. Burlington, MA 
01803 USA ...
grouper.ieee.org/groups/754/email/pdfq3pavhBfih.pdf - Similar -


Printing Floating-Point Numbers Quickly and Accurately. Robert G. 
Burger. R. Kent Dybvig. Indiana University Computer Science Department. 
Lindley Hall 215 ...
www.cs.indiana.edu/~burger/FP-Printing-PLDI96.pdf - Similar -

and the later companion paper:

How to read floating point numbers accurately

Proceedings of the ACM SIGPLAN 1990 conference on Programming language 
design and implementation table of contents
White Plains, New York, United States
Pages: 92 - 101
Year of Publication: 1990
ISBN:0-89791-364-7

William D. Clinger       University of Oregon

The latter one, I think, also gives some criteria for
choices in reading/printing real numbers, such as
creep avoidance. [This has nothing to do with computer
conferences.] Creep avoidance is what happens when you
repeatedly take a number, format it as characters,
convert the characters and convert it to a number.
You want the result to be stable, rather than creeping
up or down in value.

These are all very good papers, IMO.

And, as Joey points out, these are not things you do
to intermediate results!

Bob

Joey K Tuttle wrote:
> At 11:14  -0600 2009/08/07, DIETER ENSSLEN wrote:
>> thanks
>>
>> my reaction:  "ouch"  re the funny numbers. I really don't like 
>> funny numbers. i love numbers that are right on to the last listed 
>> digit, or maybe out by one there. how is a person supposed to 
>> generate pi or e or gamma=Euler-Mascheroni and such to 16, 32 or 
>> more or many more accurate digits as hobbyists do?
>>
>> Incidentally, I watched my pc download J602 into my smart phone over 
>> a while, then afterwards i have been unable to find any trace of it 
>> on the smart phone yet.
>>
> The hazards of floating point representation are well known - 
> sacrifice precision for speed. For most practical purposes, 
> "engineering precision" works well enough. As a hobby (when I was 11 
> years old) I memorized pi thusly -
> 
>     Pi 50
> 3.14159265358979323846264338327950288419716939937510
>     Pi
> (2: + j.~) ": [: (<....@o. % ]) 10"_ ^ x:
> 
>     (760+i.15) { Pi 800  NB. a part of pi commented on by Richard Feynman
> 134999999837297
> 
> See, for example: http://en.wikipedia.org/wiki/Feynman_point
> 
> But, as you can see, the presentation is formatted, not a number that 
> can be used in further calculations - depends on your objective... 
> The Hilbert matrix is a famous case difficult to deal with in 
> floating point. A nice article about that can be seen at:
> 
>    http://www.jsoftware.com/jwiki/Essays/Hilbert%20Matrix
> 
> There is a more general article about extended precision techniques found at:
> 
>    http://www.jsoftware.com/jwiki/Essays/Extended%20Precision%20Functions
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to