[cmucl-help] NaN
Marco Antoniotti
marcoxa at cs.nyu.edu
Sat Jan 7 23:44:23 UTC 2017
Hi
I am fiddling around with some IEEE floating points.
I see that the following code produces a (almost nice) “quiet” NaN.
CL-USER> (ext:with-float-traps-masked (:invalid)
(* 0.0 ext:double-float-positive-infinity))
#<DOUBLE-FLOAT Quiet NaN>
Alas, there seem to be no way to tell the compiler that we are actually executing the multiplication within the ext:with-float-traps-masked. This prevents us, for example to do things like
(defparameter NAN (ext:with-float-traps-masked (:invalid)
(* 0.0 ext:double-float-positive-infinity))
in a file and having it compiled “nicely”. The compiler complains (warns) about a FLOATING-POINT-INVALID-OPERATION
; In: DEFPARAMETER NAN
; (* 0.0 EXTENSIONS:DOUBLE-FLOAT-POSITIVE-INFINITY)
; Warning: Lisp error during constant folding:
; Arithmetic error FLOATING-POINT-INVALID-OPERATION signalled.
; Operation was *, operands (0.0d0 #.EXT:DOUBLE-FLOAT-POSITIVE-INFINITY).
Note that the value is then assigned correctly, but it seems very hard (at least I did not figure out how to do it) to get to the constant folding time to catch and muffle the warning.
Any ideas?
Apart from that, what would take to have a “NaN” object available all the time?
In LW and CCL you have the special syntax and object
1D+-0
For NaN
Cheers
--
Marco Antoniotti
More information about the cmucl-help
mailing list