pow(other) -> NumericRuby 2.5.0 から[permalink][rdoc][edit]pow(other, modulo) -> Integer-
selfのother乗を返します。moduloを指定しない場合は Integer#** と同じです。- [PARAM]
other: -
selfに対する冪指数(べきしすう) - [PARAM]
modulo: -
指定すると、計算途中に巨大な値を生成せずに
(self**other) % moduloと同じ結果を返します。 - [EXCEPTION]
TypeError: -
2引数
powでotherやmoduloにInteger以外を指定した場合に発生します。 - [EXCEPTION]
RangeError: -
2引数
powでotherに負の数を指定した場合に発生します。 - [EXCEPTION]
ArgumentError: - 計算結果が巨大になりすぎる場合に発生します。
p 2.pow(3) # => 8 p 3.pow(3, 8) # => 3 p 3.pow(3, -8) # => -5 p 3.pow(2, -2) # => -1 p -3.pow(3, 8) # => 5 p -3.pow(3, -8) # => -3 p 5.pow(2, -8) # => -7[SEE_ALSO] Integer#**
- [PARAM]