Ruby 1.8.7 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Fixnumクラス > **

instance method Fixnum#**

self ** other -> Fixnum | Bignum | Float

算術演算子。冪(べき乗)を計算します。

[PARAM] other:
二項演算の右側の引数(対象)
[RETURN]
計算結果
p 2 ** 3 # => 8
p 2 ** 0 # => 1
p 0 ** 0 # => 1
self ** other -> Integer | Float | Rational [redefined by rational]
rpower(other) -> Integer | Float | Rational [redefined by rational]

冪(べき)乗を計算します。other が 0 以下の場合、計算結果を Rational オブジェクトで返します。

[PARAM] other:
自身を other 乗する数
2.rpower(3)           # => 8
2.rpower(-3)          # => Rational(1, 8)
class Fixnum