I've been trying to write this as a comment, but the system tells me that I'm not allowed to do so, so I write it as an answer.
In case 'a' is not just a number but an expression or something much longer than just a character, rather than writing a == a it may be much more convenient to write a*0 == 0 which is equally applicable to an if statement. In this particular case, if you want to do something whenever a is not a nan,
if (a*0==0) {do whatever}
Or, conversely, if you want to do something only when a=nan,
(a*0!=0) {do whatever}