Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Integer#fdiv

fdiv(numeric) → float

Returns the Float result of dividing self by numeric:

Example
4.fdiv(2)      # => 2.0
4.fdiv(-2)      # => -2.0
-4.fdiv(2)      # => -2.0
4.fdiv(2.0)      # => 2.0
4.fdiv(Rational(3, 4))      # => 5.333333333333333

Raises an exception if numeric cannot be converted to a Float.

See also #even? #floor #downto #gcd also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0