Use isnan(3) to check for NaN

There's a standard C function (actually a macro) to check for NaN; let's use that for clarity.