On Saturday 01 September 2012 22:29:17 Warren Smith wrote:
Gay's algorithm to print a number is available as C code here: http://netlib2.cs.utk.edu/fp/dtoa.c code is over 70 pages long!!
Here are some thoughts about how to be a little more sane:
1. Start with a IEEE standard 64-bit real X. Assume X>0 wlog.
(Gay's code attempts to work correctly for a number of different varieties of floating-point arithmetic; IEEE hadn't conquered everything the way it has now.)
The "critical multiplication" to produce Y could be done in exact arithmetic, or just extended enough beyond the usual 53-bit IEEE mantissa's precision. Intel processors have internal 80-bit reals, right?
(A large fraction of Gay's code is concerned with implementing that exact arithmetic.) -- g