Method: Rational#fdiv
- Defined in:
- rational.c
#fdiv(numeric) ⇒ Float
956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 |
# File 'rational.c', line 956
static VALUE
nurat_fdiv(VALUE self, VALUE other)
{
VALUE div;
if (f_zero_p(other))
return rb_rational_div(self, rb_float_new(0.0));
if (FIXNUM_P(other) && other == LONG2FIX(1))
return nurat_to_f(self);
div = rb_rational_div(self, other);
if (RB_TYPE_P(div, T_RATIONAL))
return nurat_to_f(div);
if (RB_FLOAT_TYPE_P(div))
return div;
return rb_funcall(div, idTo_f, 0);
}
|