Out of range floating point number determination



Maxima is not designed to work with non-finite IEEE floats.  In theory, it
should give an error when they are generated, but obviously it does not in
many cases.  Just to complicate matters, different underlying Lisps may
have slightly different behavior for these numbers.

With that caveat, the following works for me:

      non_finite(x) := not is(x-x = 0.0)$

Tested in GCL Maxima:

    xinf: float(10^400)$
    xnan: xinf-xinf$                  -- this causes an error if you try to
print it
    ?print(xinf)  => #<1.#INF00e+000>     -- using Lisp printer
    ?print(xnan) => #<-1.#IND00e+000>

    non_finite(xinf) => true
    non_finite(xnan) => true
    non_finite(4.94e-324) => false  -- smallest positive float
    non_finite(1.797e308) => false   -- close to the largest positive float

I'd be interested to know whether this works on other implementations.

                   -s