Skip to content
instance method

Rational#**

(::Complex) -> ::Complex
(::Numeric) -> ::Numeric
self ** exponent → numeric

Returns self raised to the power exponent:

Example
Rational(2)    ** Rational(3)     #=> (8/1)
Rational(10)   ** -2              #=> (1/100)
Rational(10)   ** -2.0            #=> 0.01
Rational(-4)   ** Rational(1, 2)  #=> (0.0+2.0i)
Rational(1, 2) ** 0               #=> (1/1)
Rational(1, 2) ** 0.0             #=> 1.0

Ruby version changes

  1. 3.4
See also #* #+ .json_create #- also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0