summaryrefslogtreecommitdiff
path: root/rational.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-08-02 11:25:41 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-08-02 11:26:58 +0900
commitf9a0492b76956b545c746ab0d3ec0e555e77dfcd (patch)
tree9db8b0b1fec93c6eed5b51af63d2929a6ef00199 /rational.c
parentffe4a6ebf93166544c4265271f7b8cffa2208af6 (diff)
Expanded f_ceil
Diffstat (limited to 'rational.c')
-rw-r--r--rational.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/rational.c b/rational.c
index 3737db4..1dc08a0 100644
--- a/rational.c
+++ b/rational.c
@@ -43,13 +43,6 @@ static ID id_abs, id_idiv, id_integer_p,
static VALUE nurat_to_f(VALUE self);
-#define fun1(n) \
-inline static VALUE \
-f_##n(VALUE x)\
-{\
- return rb_funcall(x, id_##n, 0);\
-}
-
inline static VALUE
f_add(VALUE x, VALUE y)
{
@@ -1597,7 +1590,16 @@ nurat_to_r(VALUE self)
}
#define id_ceil rb_intern("ceil")
-#define f_ceil(x) rb_funcall((x), id_ceil, 0)
+static VALUE
+f_ceil(VALUE x)
+{
+ if (RB_INTEGER_TYPE_P(x))
+ return x;
+ if (RB_FLOAT_TYPE_P(x))
+ return rb_float_ceil(x, 0);
+
+ return rb_funcall(x, id_ceil, 0);
+}
#define id_quo rb_intern("quo")
#define f_quo(x,y) rb_funcall((x), id_quo, 1, (y))