using an if statement to switch nan values in an array to 0.0?
c, floating-point, nan
Solution
From what I remember, in every language, NaN will compare false to everything, including itself. You can use this behavior to weed it out:
if( angle[i] != angle[i] ) { angle[i] = 0.0 };
This looks like C, C++, or Java; in all of these, this trick should work.
Problem
I am doing some calculations with points and the vectors between the points and it is no surprise to me that I get nan for when the points are very close together. What I am trying to do now is rid all the nan values in the array that I have stored in an array along with the good data. I am hoping to just use a bit of code like so: ``` if( angle[i] == nan ) { angle[i] = 0.0 }; ``` at least that is what I have tried and I get errors when I try that. Does any one know how to get rid of nan values and replace them with just a 0.0?