[cmucl-imp] [cmucl-help] NaN
Marco Antoniotti
marcoxa at cs.nyu.edu
Mon Jan 9 08:17:53 UTC 2017
Hi Ray
maybe we can just have this discussion here.
I am not a person who knows all that much about the IEEE fine details, but I would like to have a “higher level” portable API to access IEEE NaNs, infinities, and rounding modes. I am kind of familiar with the C99 API.
Would you like to have an API consisting of something like (given a package “M”, not its real name) the following? Assuming all “quiet” NaNs.
Parameter NaN
Constant <float-length>-float-positive-infinity
Constant <float-length>-float-negative-infinity
Type rounding-mode (member :positive :negative :toward-zero :to-nearest)
Struct floating-point-configuration
Function current-floating-point-configuration
Function (setf current-floating-point-configuration)
Macro with-floating-point-configuration
Function current-rounding-mode
Function (setf current-rounding-mode)
Macro with-rounding-mode
Details to be filled…
This covers CMUCL and SBCL and (mostly) LW. CCL could be bent to comply. For ECL and ABCL pressures can be made; ACL is another story.
What do you think?
MA
> On Jan 8, 2017, at 23:58 , Raymond Toy <toy.raymond at gmail.com> wrote:
>
> Oops. Meant to reply to all.
>
> ---------- Forwarded message ----------
> From: Raymond Toy <toy.raymond at gmail.com>
> Date: Sun, Jan 8, 2017 at 10:00 AM
> Subject: Re: [cmucl-help] NaN
> To: Marco Antoniotti <marcoxa at cs.nyu.edu>
>
>
>
>
> On Sat, Jan 7, 2017 at 3:44 PM, Marco Antoniotti <marcoxa at cs.nyu.edu> wrote:
>
>> 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).
>>
>
> What version? I don't get any warnings from snapshot-2017-01.
>
>
>>
>> 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?
>>
>
> Since you're using cmucl-specific functions, you could always just
> construct the NaN directly using kernel:make-double-float. Something like
> (kernel:make-double-float -524288 0)
>
>
> --
> Ray
>
>
>
> --
> Ray
> _______________________________________________
> cmucl-imp mailing list
> cmucl-imp at lists.zs64.net
> https://lists.zs64.net/mailman/listinfo/cmucl-imp
--
Marco Antoniotti
More information about the cmucl-imp
mailing list