Ruby 4.0 リファレンスマニュアル

instance method Rational#**

self ** other -> Rational | Float[permalink][rdoc][edit]
(Complex) → Complex
(Numeric) → Numeric

selfother 乗を返します。

Rational オブジェクトを左項とする算術演算子 ** はこのメソッドの呼び出しになります。

[PARAM] other:
self に対する冪指数(べきしすう)
[EXCEPTION] ArgumentError:
計算結果の分母・分子が巨大すぎる場合に発生します。

otherFloat を指定した場合は、計算結果を Float で返します。 other が有理数であっても、計算結果が無理数だった場合は Float を返します。

r = Rational(3, 4)
p r ** Rational(2, 1)  # => (9/16)
p r ** 2             # => (9/16)
p r ** 2.0           # => 0.5625
p r ** Rational(1, 2)  # => 0.8660254037844386

計算結果の分母・分子が巨大すぎるときは ArgumentError が発生します。

計算結果が巨大すぎる例
p Rational(2) ** 10000000000000000000
# ~> ArgumentError: exponent is too large

判定の閾値は変わりえます。