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

Re: [Scheme-reports] More NaN and Infsanity



Peter Bex writes:

> On Mon, Apr 30, 2012 at 03:41:10AM -0400, John Cowan wrote:
> > Peter Bex scripsit:
> > 
> > > What about (rationalize x y) where x or y are nan or inf?  The
> > > notation seems to indicate that nan is allowed, since it's "real
> > > but not rational".  However, that same sentence seems to
> > > indicate that rationalizing NaN would be an error.
> > 
> > Rationalizing infinity makes some sense, but rationalizing NaN
> > does not, at least not to me.
> 
> What would the result be then?  According to the spec, both the
> infinities and NaN are rational but not real so infinity is out,
> and I don't see any sane value other than infinity (or maybe nan)
> as output for, say (rationalize +inf.0 1).

The construction of the Stern-Brocot tree that I've seen (related to
the notion of the simplest rational in an interval) starts with two
extreme "values", 0/1 and 1/0. All positive rationals are built
between these. The pretense is that 1/0 is the simplest rational
representation of "infinity". So it may make sense to return +inf.0.

(Does the spec really say "rational but not real"?)


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