Re: [math-fun] How do you print a number? DUHHHHH!!!!!!!
To make a long story short, the whole point of the Steele/White algorithm is to print out just enough digits so that readbaseten(printbaseten(x))=x, down to the last bit. But this presumes that decimal expansions can resolve down to the individual bit; i.e., that readbaseten() is an "onto" function. There are many ways to try to program this kind of function, including some sort of Newton procedure. Given modern 256+ bit SIMD capabilities, there has to be an algorithm that is both fast & accurate. I recall that the original IBM 709/7090 Fortran went to extraordinary lengths to read & print floating point numbers accurately; I naively assumed that all Fortran's were capable of this. At 06:07 PM 8/31/2012, Warren Smith wrote:
Here are two papers on this topic cited in the Steele-White retrospective:
David M. Gay: Correctly Rounded Binary-Decimal and Decimal-Binary Conversions (1990) http://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.31.4049&rep=rep1&typ... Gay's algorithm is implemented (I think) inside his language AMPL, and also available from netlib.
Robert Burger , R. Kent Dybvig: Printing Floating-Point Numbers Quickly and Accurately, http://citeseer.ist.psu.edu/viewdoc/download;jsessionid=EC593AC56FA08763D0A9... They say Steele & White's print algorithm is "unacceptably slow for practical use." B&D's algorithm is implemented inside "chez scheme."
It seems to me all these algorithms are VERY complicated. There must be something better than any of them...
-- Warren D. Smith http://RangeVoting.org <-- add your endorsement (by clicking "endorse" as 1st step)
participants (1)
-
Henry Baker