diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-02-17 08:00:06 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-02-17 09:47:39 +0900 |
| commit | a740b28b529f2fb2cf66446e2ee816fdcee11371 (patch) | |
| tree | fd31cc510bd01bc4dcd458471bba380e4edc37eb /src | |
| parent | 4b981adc585b7c6e3ce1a9d7735fedfd6887ab2f (diff) | |
| download | mruby-a740b28b529f2fb2cf66446e2ee816fdcee11371.tar.gz mruby-a740b28b529f2fb2cf66446e2ee816fdcee11371.zip | |
define FLO_EPSILON depends on float/double
Diffstat (limited to 'src')
| -rw-r--r-- | src/numeric.c | 7 |
1 files changed, 4 insertions, 3 deletions
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++; |
