Paul,
one way to do it is with the C++ Standard Library's numeric_limits class, like this:
#include
double myQuietNan = std::numeric_limits::quiet_NaN();
double mySignalingNan = std::numeric_limits::signaling_NaN();
There are two kinds of NaN's - quiet and signaling.
a signaling NaN announces its presence in a floating point operation by throwing an exception. A quiet NaN does not raise an exception, but the results of using it in a floating point operation are not always obvious. You probably want to use the quiet NaN representation.
- Glenn