[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] More NaN and Infsanity



Peter Bex scripsit:

> So, concretely, what should the behaviour of rationalize be for these
> values?
> 
> It seems to me that both situations should probably be an error.

I agree.  If you look at Alan Bawden's implementation in the IEEE Scheme
standard (online at http://trac.sacrideo.us/wg/wiki/RationalizeDefinition ),
you can see that if the first argument is non-rational, an error
is signalled.  However, the second argument can be infinite, in which
case the result is 0.0, rather arbitrarily, because the boundaries of
the interval are going to be +inf.0 and -inf.0.  Signalling an error
for this case would be all right with me.

In any case, the numbers egg is buggy: it always returns an exact
rational even if the arguments are inexact.  Chibi's version of Bawden
is also buggy: it goes into an infinite loop if the second argument is
non-rational.  Bawden's code may not be the fastest, but it's elegant:
I suggest adopting it.

-- 
Go, and never darken my towels again!           John Cowan
        --Rufus T. Firefly                      http://ccil.org/~cowan

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports