summaryrefslogtreecommitdiff
path: root/rational.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-14 14:12:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-14 14:12:30 +0000
commited778c2a89258a8459e32aeee273a872a33ca421 (patch)
tree555e16ad2e6ce43c3ff3c010e36cc116086f2a24 /rational.c
parent33758ded0838db9464d3d0916c8f74f4b12b2929 (diff)
rational.c (nurat_div): use the dedicated function nurat_to_f
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'rational.c')
-rw-r--r--rational.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/rational.c b/rational.c
index 366e25ed79..47e67f128d 100644
--- a/rational.c
+++ b/rational.c
@@ -41,6 +41,8 @@ static ID id_abs, id_idiv, id_integer_p,
#define f_inspect rb_inspect
#define f_to_s rb_obj_as_string
+static VALUE nurat_to_f(VALUE self);
+
#define binop(n,op) \
inline static VALUE \
f_##n(VALUE x, VALUE y)\
@@ -930,8 +932,7 @@ nurat_div(VALUE self, VALUE other)
}
}
else if (RB_FLOAT_TYPE_P(other)) {
- double d = nurat_to_double(self);
- VALUE v = rb_float_new(d);
+ VALUE v = nurat_to_f(self);
return rb_flo_div_flo(v, other);
}
else if (RB_TYPE_P(other, T_RATIONAL)) {
@@ -954,8 +955,6 @@ nurat_div(VALUE self, VALUE other)
}
}
-static VALUE nurat_to_f(VALUE self);
-
/*
* call-seq:
* rat.fdiv(numeric) -> float