Checking not a number value

Nov 23, 2016 at 8:44pm


Hi
I have a variable X, this variable sometimes returns not a number (nan). I want to check this variable if it is a not number or a number and make this variable equal to zero if it is not a number (nan). Anyone can help me plz..
Regards




Nov 23, 2016 at 8:51pm
Nov 23, 2016 at 9:10pm
As I am beginner, can u plz check this code:
if (isnan( double X ))
{
X=0;
}

Nov 23, 2016 at 10:00pm
1
2
3
4
if (std::isnan(X))
{
	X = 0;
}

Don't forget to include <cmath>.
Last edited on Nov 23, 2016 at 10:01pm
Nov 23, 2016 at 10:31pm
Okay.
Thanks it is working now.
Topic archived. No new replies allowed.