From a740b28b529f2fb2cf66446e2ee816fdcee11371 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 17 Feb 2014 08:00:06 +0900 Subject: define FLO_EPSILON depends on float/double --- src/numeric.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/numeric.c b/src/numeric.c index 8dc83cc1c..5526e6034 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -17,12 +17,13 @@ #ifdef MRB_USE_FLOAT #define floor(f) floorf(f) #define ceil(f) ceilf(f) -#define floor(f) floorf(f) #define fmod(x,y) fmodf(x,y) #define pow(x,y) powf(x,y) #define FLO_MAX_DIGITS 7 +#define FLO_EPSILON FLT_EPSILON #else #define FLO_MAX_DIGITS 14 +#define FLO_EPSILON DBL_EPSILON #endif static mrb_float @@ -162,12 +163,12 @@ mrb_flo_to_str(mrb_state *mrb, mrb_value flo) mrb_float fdigit = n / weight; if (fdigit < 0) fdigit = n = 0; - if (m < -1 && fdigit < FLT_EPSILON) { + if (m < -1 && fdigit < FLO_EPSILON) { if (e || exp > 0 || m <= -abs(exp)) { break; } } - digit = (int)floor(fdigit + FLT_EPSILON); + digit = (int)floor(fdigit + FLO_EPSILON); if (m == 0 && digit > 9) { n /= 10.0; exp++; -- cgit v1.2.3