Robert, The std::numeric_limits class template has functions for this. I have used the following definition in my code: #ifndef NAN /** * Double-precision not-a-number. Some systems don't have the * C99-standard macro @p NAN defined. GNU gcc does as an extension, * but MSVC doesn't. */ # define NAN std::numeric_limits<double>::quiet_NaN() #endif I don't think serializing signaling NaNs makes any sense, so I suggest using the quiet version. The difference is that computing anything with quiet NaN produces a quiet NaN, whereas signaling NaN raises a FP exception. Furthermore, the result of computation with sNaN is not very well defined. I'd like to add one to your count of NaN users. I'm using it in many occasions, typically indicating an "undefined" or "not applicable" situation. Due to the aforementioned property, it is easy to track back calculation errors if undefined values are involved. (Just find the first non-NaN intermediate result.) Saving "I haven't yet defined the value of this formula" with a NaN makes sense to me. BR, Topi On Sun, 2005-11-13 at 16:02 -0800, Robert Ramey wrote:
Truth is, I don't even know how one goes about assigning a NaN or a +/inf to floating/double variable !!
Robert Ramey
-- Topi Mäenpää CTO, Intopii +358 40 774 7749