Skip to content
instance method

Integer#to_f

() -> ::Float
to_f → float

Converts self to a Float:

Example
1.to_f  # => 1.0
-1.to_f # => -1.0

If the value of self does not fit in a Float, the result is infinity:

Example
(10**400).to_f  # => Infinity
(-10**400).to_f # => -Infinity
See also #to_bn #to_i #times #to_int also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0