This topic may have beaten to death by now, but a few comments:

1. Guy Steele and Jon White wrote 
   "How to print floating-point numbers accurately"
   in 1990 (SIGPLAN PLDI 1990). This paper set the stage for
   proper formatting of floating-point numbers.

2. Doug Forkes analyzed their approach (which was available
   by rumor quite a bit earlier, new of which had been brought to
   us at I.P. Sharp by LMB (Larry M. Breed)), and rewrote the
floating-point
   formatter for SHARP APL. Doug's approach was, if I recall 
   correctly, quite a bit faster than the Steele/White approach.
   I think he did something along the lines of what Burger and 
   Dybvig, below, did, but would welcome word from Doug on this.

   Doug's  implementation had one notable effect: The bug reports
   that we'd get about once a month about bad formatting of 0.07,
   which would print as something like 0.070000000000001 with the 
   old formatter, but which printed as 0.07 with the new one, simply
   stopped coming in. 

3. Robert G. Burger and R. Kent Dybvig. Printing floating-point numbers
quickly and accurately. In Proceedings of the ACM SIGPLAN '96 Conference
on Programming Language Design and Implementation, pages 108--116.
http://citeseer.ist.psu.edu/28233.html 
This paper presents the same approach to numeric formatting, but their
algorithm is substantially faster than that of Steele and White.

The change is NOT, in my opinion, cosmetic, as it also corrects a number
of other evils, such as racheting, which can occur when you repeatedly
format and unformat a number, and it slowly increases or decreases in
value.
Both papers are worthy of reading, as they make it quite evident that
correct formatting is (a) not costly and is (b) not merely cosmetic.

4. I have heard rumors that the new IEEE floating-point standard will
   contain formatting rules that conform to the above papers.
   That means that new FPU boxes will likely include formatter and
   unformatter instructions, at which point any complaints about
   "large price to pay" will certainly go away.

Bob

ps: I've never understood people who prefer fast answers to
correct ones.

On Tue, 2007-10-02 at 20:16 -0400, John Randall wrote:
> > On 10/2/07, Raul Miller <[EMAIL PROTECTED]> wrote:
> >
> >> It seems to me that if a number displayed with the digits
> >> indicated by 9!:10 has exactly the same bit pattern as that
> >> number displayed to full precision then the more concise
> >> variant should be used.
> >>
> 99>> Currently, we get:
> 9>>
> >>   6.3&]
> >> 6.2999999999999998&]
> >
> Raul:
> 
> For printing a floating point number, J has simply to round it to a
> fixed number of significant digits. It does not have to consider other
> decimal numbers with the same bit pattern.
> 
> What you are suggesting seems considerably more complicated: it would
> require J to take a floating point number and, among all decimal
> numbers with the same bit pattern, select the one with the fewest
> significant digits.
> 
> In my opinion, this a large price to pay for a cosmetic improvement.
> However, I may be misunderstanding what you are saying.
> 
> 
> Best wishes,
> 
> John
> 
> /
> 
> ----------------------------------------------------------------------
> 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