Created
February 23, 2012 23:53
-
-
Save xiaom/1895894 to your computer and use it in GitHub Desktop.
float point exception
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see http://www.johndcook.com/IEEE_exceptions_in_cpp.html for details | |
bool IsNumber(double x) | |
{ | |
// This looks like it should always be true, | |
// but it's false if x is a NaN. | |
return (x == x); | |
} | |
#include <float.h> | |
bool IsFiniteNumber(double x) | |
{ | |
return (x <= DBL_MAX && x >= -DBL_MAX); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment