# [R6RS] NaNs and infinities

William D Clinger will at ccs.neu.edu
Wed Mar 8 18:24:54 EST 2006

```Kent quoting me:
> > This would be a bad thing to do if there were plausible
> > examples of problems it would cause.  If you can think
> > of such problems, we'd like to hear about them.
>
> programmers probably imagine.

I think you're worrying about the speed of rational?, integer?,
flodd?, fleven?, fltruncate? etc.  I don't think you need to
worry about the speed of rational? because its main use on
inexact numbers will be to distinguish the finite reals from
the infinities and NaNs.  If programmers don't want that
distinction, they will use real? instead.  I don't think you
need to worry about the speed of integer? on inexact reals,
because that doesn't happen often enough to worry about the
is already slower than most programmers realize.  I don't
think you need to worry about the speed of flodd? etc, for
the obvious reason.

> > In mathematics, a rational number has a finite integral
> > numerator and denominator.
>
> Hmm.  Implicit in this statement is that integers can be infinite (or
> "finite integral" would be redundant).

I was addressing a person who thinks integers can be infinite,
and didn't want his beliefs to get in the way of understanding
my point.

> Does this mean that infinite integers are irrational?

There are no infinite integers, in ordinary mathematical
usage or in the current draft of SRFI 77.

> Also, should (integer?  +inf.0) => #t even
> though (rational?  +inf.0) => #f?

No, of course not.  That's why (integer? +inf.0) => #f.

> > Both the standards document
> > and working programmers need some way to distinguish
> > the finite inexact reals from the infinities and NaNs.
> > That seems like a natural use for the rational? predicate,
> > which has not heretofore had much in the way of a portable
> > semantics on inexact numbers anyway.
>
> I prefer something more direct, and something that doesn't imply that
> +inf.0 is irrational, like exceptional-flonum?

Although +inf.0 is a flonum, other infinities may not be.

Your preference is noted.  For a different preference, see
http://srfi.schemers.org/srfi-77/mail-archive/msg00404.html,
question 9.

> So, it sounds like we can agree on (for nonnegative x):
>
>   (* x 0) => 0 or +nan.0 if x = +nan.0 or x = +inf.0
>           => 0 or 0.0 otherwise
>
>   (/ 0 x) => 0 or +nan.0 if x = +nan.0
>           => 0 or 0.0 otherwise
>
>   (/ x 0) => +nan.0 or raise exception if x = +nan.0 or x = 0.0
>           => +inf.0 or raise exception otherwise
>
> Right?

Right!

Will

```