Why -nan values appear

I perform some experiments with the cpp code and I got -nan values. Can anybody tell why I might get these values
NAN stands for Not A Number. You can get this kind of value when you do something that doesn't make sense, such as dividing by zero or computing the square root of a negative number.
Nans propagate also. So if you had this..

z = sqrt(-1);
x = z*5.2;
y = x+x/5.2;
m = y;
cout << m << endl; //m is nan but it is not the root cause of the probem! You have to trace it back until you find the source of the issue. This can be a huge undertaking in large projects.

Registered users can post here. Sign in or register to post.