End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Integer#to_r
int.to_r → rational
rational.c
View on GitHub ↗
static VALUE
integer_to_r(VALUE self)
{
return rb_rational_new1(self);
}
Returns the value as a rational.
Example
1.to_r #=> (1/1) (1<<64).to_r #=> (18446744073709551616/1)