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

Float#**

self ** other → numeric

Raises self to the power of other:

Example
f = 3.14
f ** 2              # => 9.8596
f ** -2             # => 0.1014239928597509
f ** 2.1            # => 11.054834900588839
f ** Rational(2, 1) # => 9.8596
f ** Complex(2, 0)  # => (9.8596+0i)
See also #* #+ #% #- also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0