On 26 Apr, Glen Corby wrote:
> This isnt a dev-C++ specific question, but i am wondering if anyone knows how you check if a float or double carrys valid data.
>
> My program runs fine most of the time but every now and again it spits out -NaN.
> I figure its from uninitialised variables, however I cant track down where they enter the program without performing periodick checks at suspect locations.
>
> So is there a function like
> bool validFloat(float num) for instance?
Here a function from the open SciLab system (matlab clone)
try this
int mxIsNaN(double x)
{
if ( x != x )
return 1;
else return 0;
}
--
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
Institute of Technology, RWTH Aachen
D 52056 Aachen, Germany
|