[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: numeric tests
From: |
Dirk Herrmann |
Subject: |
Re: numeric tests |
Date: |
Thu, 19 Apr 2001 18:45:43 +0200 (MEST) |
On Wed, 4 Apr 2001, Bill Schottstaedt wrote:
> Out of mild curiousity, I translated some of Clisp's numerical tests
> (released under GPL in Clisp, so presumably this is ok) to Scheme
> using the "pass-if" style of Guile's tests, and noticed some odd
> cases. I spot-checked some of the worst looking results in
> gmp-3.0.1's pexpr program which agreed with Clisp (i.e. that the test
> should return 0). For example, test 313, guile=8192.0, 335 got 5+e123
> etc. In case there's interest (some of the tests are a bit nutty),
> the file is at ccrma-ftp.stanford.edu/pub/Lisp/number-tests.scm.
The problems seem to come from the fact, that the reader, as soon as it
sees an expression like <digits>/<digits>, will use a floating point
variable while parsing the digits. This can lead to inaccuracies during
parsing, because the construction of the floating point number itself
takes a number of potentially inaccurate floating point operations. In
contrast, (/ <digits> <digits>) will first read two exact integers, and
after that will perform a division to produce a floating point value.
Thus, any possible inaccuracy comes from the single final divide
operation.
Best regards,
Dirk Herrmann