It doesn't look like I can test if 2 single floats are equal (=)
or not reliably. I'm using cmucl-19b-test-x86-linux. To reproduce
this problem, enter the following forms into the REPL (do not compile them):
(declaim (inline sf=))
(defun sf= (x y)
(< (abs (- (the Single-Float x)
(the Single-Float y)))
single-float-epsilon))
(defun test (wh w)
(declare (type fixnum w))
(print (list (car wh)
(/ w 3.8208954)
(= (the Single-Float (car wh))
(/ w 3.8208954))
(sf= (the Single-Float (car wh))
(/ w 3.8208954))
(< (abs (- (car wh)
(/ w 3.8208954)))
single-float-epsilon))))
Evaluating (test '(217.48828 . 0.0) 831) will give you:
(217.48828 217.48828 T T T), which is good.
After you do (compile 'sf=) and (compile 'test), evaluating
(test '(217.48828 . 0.0) 831) will give you (217.48828 217.48828 NIL NIL T),
which is weird.
The same code, interpreted or compiled, in Allegro CL 6.2 trial edition
gives (217.48828 217.48828 T T T).
If I strip all the type declarations in SF= and TEST, CMUCL always give
(217.48828 217.48828 T T T), regarless if COMPILE is applied to SF= or TEST.
But I do like to keep the type declarations in my real code.
Any ideas?
Thanks a lot.
-cph