[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

generating a n-a-n float



I need to generate a not-a-number float. I know I can do this by
catching an error:

  (flet ((generate-nan (signal) (dbg:proceed signal :use-non-trap-result)))
    (let ((d 0.0))
      (scl:condition-bind ((sys:float-invalid-operation #'generate-nan))
         (/ d d))))

[note: I need the variable d because the compiler will otherwise try
to evaluate (/ 0.0 0.0)]

Surely there must be a simpler way. I'd also like control over the
exact values in the various fields.

The reason I need this is as follows: I want to communicate with an
SPlus program via rpc; I want to send homogeneous vectors of data
(floats); and I need to be able to represent missing data (the "NA"
value in SPlus). A very simple way to do this is to use a designated
n-a-n value (which I can pass as a float) to represent "NA".  This is
*much* simpler than messing with heterogeneous data vectors, if only I
could cleanly generate a specific n-a-n.

Replies by email to rshapiro@arris.com. Thanks --

rs