Method: Rational#fdiv

Defined in:
rational.c

#fdiv(numeric) ⇒ Float

Performs division and returns the value as a Float.

Rational(2, 3).fdiv(1)       #=> 0.6666666666666666
Rational(2, 3).fdiv(0.5)     #=> 1.3333333333333333
Rational(2).fdiv(3)          #=> 0.6666666666666666

Returns:



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);
}