Method: Rational#to_f

Defined in:
rational.c

#to_fFloat

Returns the value as a Float.

Rational(2).to_f      #=> 2.0
Rational(9, 4).to_f   #=> 2.25
Rational(-3, 4).to_f  #=> -0.75
Rational(20, 3).to_f  #=> 6.666666666666667

Returns:



1580
1581
1582
1583
1584
# File 'rational.c', line 1580

static VALUE
nurat_to_f(VALUE self)
{
    return DBL2NUM(nurat_to_double(self));
}