1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2018-11-14 14:12:30 +00:00
parent 33758ded08
commit ed778c2a89

View file

@ -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