Is there an implementation independent way of representing infinity or not a number (NAN) in Common Lisp? It would need to be a double float, and have both positive and negative values. In SBCL, the results of

but I need it to be available in all implementations. I have an addendum to a package to write that runs on all platforms and it needs a representation of infinity and NAN. Even functions from another library would suffice.

Last edited by joeish80829 on Mon Oct 14, 2013 9:51 am, edited 1 time in total.

The IEEE-Floats library can decode floats given in IEEE binary format and map non-numbers like Inf and NaN to Common Lisp keywords like :not-a-number, :positive-infinity, and :negative-infinity. This could help to identify non-numbers computed by the C-code.

Caution: The big disadvantage is that not a single built-in Common Lisp math function will work with the :not-a-number, :positive-infinity, and :negative-infinity keywords, so either the keywords must be filtered out directly after the conversion or you must write your own math functions that can compute with the :not-a-number, :positive-infinity, and :negative-infinity keywords.

ok i got iee-floats loaded and its part of my library now. I have a function that detects if a number is nan and one that detects whether a number is infinity havent tested nan out but my infinity function needs the number to be a double-float ....SBCL's SB-EXT:DOUBLE-FLOAT-POSITIVE-INFINITY works but i would need it to be implimentation independent ....ny advice from here