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
(apropos "INFINITY")
include
SB-EXT:DOUBLE-FLOAT-NEGATIVE-INFINITY (bound)
SB-EXT:DOUBLE-FLOAT-POSITIVE-INFINITY (bound)
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.
Is there a way to represent infinity in Common Lisp in an im
-
- Posts: 153
- Joined: Tue Sep 03, 2013 5:32 am
Is there a way to represent infinity in Common Lisp in an im
Last edited by joeish80829 on Mon Oct 14, 2013 9:51 am, edited 1 time in total.
Re: Is there a way to represent infinity in Common Lisp in a
According to CLHS 12.1.4.3 Rule of Float Underflow and Overflow floating-point infinity is an arithmetic error:
I have no idea how to get a portable solution, but a very similar discussion can be found here:
Where "floating-point underflow" means a numer so close to zero that it cannot be represented by the smallest floating-point number of the respective floating-point format anymore.CLHS 12.1.4.3 wrote:An error of type floating-point-overflow or floating-point-underflow should be signaled if a floating-point computation causes exponent overflow or underflow, respectively.
I have no idea how to get a portable solution, but a very similar discussion can be found here:
- comp.lang.lisp -> convention for infinity
-
- Posts: 153
- Joined: Tue Sep 03, 2013 5:32 am
Re: Is there a way to represent infinity in Common Lisp in a
can you help me represent not a number (NAN) i would really appreeciate any help on this
Re: Is there a way to represent infinity in Common Lisp in a
Just an idea, don't know how much this really helps:
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.
- edgar
- Common-Lisp Net -> IEEE-Floats
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.
- edgar
-
- Posts: 153
- Joined: Tue Sep 03, 2013 5:32 am
Re: Is there a way to represent infinity in Common Lisp in a
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