Ruby 1.8.7 リファレンスマニュアル > ライブラリ一覧 > rationalライブラリ > Integerクラス > /

instance method Integer#/

self / other -> Rational | Float | Integer [redefined by rational]

商を計算します。

[PARAM] other:
自身を割る数

計算結果は以下のようになります。

  • otherが有理数(Rational)ならば、有理数(Rational)を返す。
  • otherがそれ以外なら、Integer#/と同じ。つまり、 other が整数(Integer)ならば、整数(Integer)を(整除)、浮動小数(Float)ならば、 浮動小数(Float)を返す。 ただし、いずれも、other == 0 の時は、ZeroDivisionErrorとなる。
[EXCEPTION] ZeroDivisionError:
other が 0 の時に発生します。
class Integer