[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Floating point coercion problem?
- To: email@example.com
- Subject: Floating point coercion problem?
- From: John M. Canning <firstname.lastname@example.org>
- Date: Thu, 28 Jun 90 16:59:29 EDT
Thank you for your reponse about the floating point co-processor (my v1.3.2
documentation is packed in a box waiting to be moved to another building).
Here is a floating point problem that could be a problem with the IEEE
floating point representation or MACL's integer to floating point conversion.
Consider the following function which should always return T:
(defun foo (x) (<= (- (+ x (sqrt 2)) x) (sqrt 2)))
But in MACL
(foo 6) => T
(foo 7) => nil
This table summarizes foo's results for some integers:
(I only tested up to 9999).
Furthermore, the error generated by adding and subtracting the same integer
is greater than long-float-epsilon.
(- (- (+ 7 (sqrt 2)) 7) (sqrt 2)) => 6.661338147750939E-16
long-float-epsilon => 1.1107651257114E-16
- John Canning