Improve jv_is_integer()

This commit is contained in:
Mark Feit authored and Nicolas Williams committed 2019-04-07 14:33:36 -05:00
1 parent 263e1061ea
commit ad9fc9f559
1 file changed
+5 -4
+5 -4
View File
@@ -7,6 +7,7 @@
#include <stdarg.h>
#include <limits.h>
#include <math.h>
#include <float.h>
#include "jv_alloc.h"
#include "jv.h"
@@ -152,11 +153,11 @@ int jv_is_integer(jv j){
return 0;
}
double x = jv_number_value(j);
if(x != x || x > INT_MAX || x < INT_MIN){
return 0;
}
return x == (int)x;
double ipart;
double fpart = modf(x, &ipart);
return fabs(fpart) < DBL_EPSILON;
}
/*