Subject: Out of range floating point number determination
From: Raymond Toy
Date: Mon, 13 Aug 2012 10:27:12 -0700
On Mon, Aug 13, 2012 at 10:13 AM, Stavros Macrakis <macrakis at alum.mit.edu>wrote:
> Not sure why you say "not looking promising". You've shown that SBCL
> Maxima won't (incorrectly) return a non-finite number in this case.
>
> But does the non_finite code correctly detect such numbers if passed them?
> You may want to test by generating an Inf and NaN in Lisp (if SBCL supports
> that).
>
I'm pretty sure this works fine on sbcl because it works as expected on
cmucl, once you tell lisp not to signal errors on overflow or invalid
operations.
:lisp (ext:set-floating-point-modes :traps nil)
;; (Use sb-ext for sbcl?)
(%i2) 1e300*1e300;
(%o2) #.EXT:DOUBLE-FLOAT-POSITIVE-INFINITY
(%i3) ) %o2-%o2;
(%o3) #<DOUBLE-FLOAT Quiet NaN>
(%i4) ) non_finite(%o2);
(%o4) true
(%i5) non_finite(%o3);
(%o5) true
(%i6) non_finite(1e300);
(%o6) false
Ray