Greetings! "Stewart W. Wilson" <[email protected]> writes:
> The fix does not seem to be exactly trivial. Please see the attached > paper by Steele and White from 1990. > Thanks so much for this reference! Unfortunately, using up to forty 32bit words in bignum arithmetic to print out floats looks prohibitively expensive, although the algorithm does appear to work nicely, at least when coded in lisp. GCL uses strtod for conversion, and I've whipped up a quick implementation which recursively truncates digits until this routine delivers a different result. See below. It does appear to me however that there is nothing which will comprehensively "do the right thing", in as much as the error between the internal and the printed representations might always accumulate to result in an incorrect rounding on output. This is conceptually different from your original query regarding simply the printed format of floats, but I mention it as you gave an example using a sum of two long-floats. See the short float analog and question below. Take care, ============================================================================= >most-positive-long-float 1.7976931348623157E308 >(* 0.5 most-positive-long-float) 8.988465674311579E307 >(+ 1.234 2.567) 3.801 >-9.99999999999999999999 -10.0 >-999999999999999999999.0 -1.0E21 >least-positive-long-float 4.0E-324 > ============================================================================= >>> I want to use GCL instead of paying for Allegro. >>> But GCL often prints numbers with too many places. >>> Example >>> >>>>(+ 1.234 2.567) >>> >>> 3.8010000000000002 >>> Am I correct in the guess that Allegro cannot give 3.801s0 for (+ 1.234s0 2.567s0), but rather (+ 1.234s0 2.567s0)? -- Camm Maguire [email protected] ========================================================================== "The earth is but one country, and mankind its citizens." -- Baha'u'llah _______________________________________________ Gcl-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/gcl-devel
