summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-04-27 18:31:45 +0900
committerYukihiro Matsumoto <[email protected]>2012-04-27 18:31:45 +0900
commitee30c5a4a44fc26a8b5b8d6a0e35a7a4b6a6be50 (patch)
tree0ec0d2764b0bb6e0a2067d20a238f8b2176e130c /src
parentc8f8f8396ce98b37de5e160655bc6219c13d8248 (diff)
downloadmruby-ee30c5a4a44fc26a8b5b8d6a0e35a7a4b6a6be50.tar.gz
mruby-ee30c5a4a44fc26a8b5b8d6a0e35a7a4b6a6be50.zip
allow float/double switch
Diffstat (limited to 'src')
-rw-r--r--src/numeric.c36
1 files changed, 6 insertions, 30 deletions
diff --git a/src/numeric.c b/src/numeric.c
index a29692bab..23da9089c 100644
--- a/src/numeric.c
+++ b/src/numeric.c
@@ -101,29 +101,14 @@ const unsigned char mrb_nan[] = "\x00\x00\xc0\x7f";
const unsigned char mrb_nan[] = "\x7f\xc0\x00\x00";
#endif
-extern double round(double);
-
-#ifndef HAVE_ROUND
-double
-round(double x)
-{
- double f;
-
- if (x > 0.0) {
- f = floor(x);
- x = f + (x - f >= 0.5);
- }
- else if (x < 0.0) {
- f = ceil(x);
- x = f - (f - x >= 0.5);
- }
- return x;
-}
+#ifdef MRB_USE_FLOAT
+#define round(f) roundf(f)
+#define floor(f) floorf(f)
+#define ceil(f) ceilf(f)
+#define floor(f) floorf(f)
+#define fmod(x,y) fmodf(x,y)
#endif
-
-
-
void mrb_cmperr(mrb_state *mrb, mrb_value x, mrb_value y);
void
@@ -459,16 +444,7 @@ flodivmod(mrb_state *mrb, mrb_float x, mrb_float y, mrb_float *divp, mrb_float *
mrb_float div, mod;
if (y == 0.0) mrb_num_zerodiv(mrb);
-#ifdef HAVE_FMOD
mod = fmod(x, y);
-#else
- {
- mrb_float z;
-
- modf(x/y, &z);
- mod = x - z * y;
- }
-#endif
if (isinf(x) && !isinf(y) && !isnan(y))
div = x;
else