From: David B. <dbm...@gm...> - 2014-09-03 07:30:59
|
On 3/09/2014 8:21 AM, Robert Dodier wrote: > On 2014-09-01, David Billinghurst <dbm...@gm...> wrote: > >> I:87^611$ >> M:91^211$ >> sign(sqrt(I)-M); > Thanks for the example. Here's a proposed fix. This causes $FLOAT to > always fail (even for Lisps which otherwise allow float infinity) > and therefore SIGN1 takes a different route and sign returns 'pos. > > The patch assumes that (float inf) minus (float inf) != 0. > I'm pretty sure that's required by IEEE 754 (in fact I think the > result is supposed to be NaN) but I can't quote chapter & verse > at the moment. > > best > > Robert Dodier > > PS. > $ git diff src/comm.lisp > diff --git a/src/comm.lisp b/src/comm.lisp > index 42bdc12..1d6d178 100644 > --- a/src/comm.lisp > +++ b/src/comm.lisp > @@ -1178,7 +1178,7 @@ > (car result)))))) > > (defmfun $float (e) > - (cond ((numberp e) (float e)) > + (cond ((numberp e) (let ((e1 (float e))) (if (= (- e1 e1) 0) e1 (signal 'floating-point-overflow)))) > ((and (symbolp e) (mget e '$numer))) > ((or (atom e) (member 'array (cdar e) :test #'eq)) e) > ((eq (caar e) 'rat) (fpcofrat e)) This works for me with gcl-2.6.10 on Windows XP. Thanks. All regression tests pass. |