Skip to content

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

instance method

Float#+

self + other → numeric

Returns a new Float which is the sum of self and other:

Example
f = 3.14
f + 1                 # => 4.140000000000001
f + 1.0               # => 4.140000000000001
f + Rational(1, 1)    # => 4.140000000000001
f + Complex(1, 0)     # => (4.140000000000001+0i)
See also #** #- #* #-@ also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0