I found _isnan() in float.h for VS2008, but I would like to SET a variable to a NaN intentionally, not check if it is one.
Is this possible?
Thanks,
David
I found _isnan() in float.h for VS2008, but I would like to SET a variable to a NaN intentionally, not check if it is one.
Is this possible?
Thanks,
David
>Is this possible?
Yes, but it's not the most brilliant of ideas. What exactly are you trying to do that prompted this question?
there are numeric_limits<float>::quiet_NaN() and numeric_limits<float>::signaling_NaN()
I found quite_NaN and it seems to work well - i'm surprised there is no "isnan" function included though!
you can write a simple one though
bool isnan(double x)
{
return (x!=x);
}
which utilizes the fact that NaN's are not equal to anything, even themselves.
I have a big grid of numbers that I am reading in, but sometimes instead of a number i get a "blank" that i need to put something in to recognize that there was infact nothing there. How else would I do that without nan's if the possible values of these numbers range from -inf to inf?
Thanks,
Dave
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.