Use isnan() to check for not-a-number
This is cleaner, more robust and more efficient than formatting the number as a string and checking for "NaN" or "nan" in the result.