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.
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.