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

instance method Rational#%

self % other -> Rational | Float

剰余を計算します。絶対値が self の絶対値を越えない、符号が self と同じ Numeric を返します。

[PARAM] other:
自身を割る数

例:

Rational(3, 4) % 2               # => Rational(3, 4)
Rational(3, 4) % Rational(2, 1)  # => Rational(3, 4)
Rational(3, 4) % 2.0             # => 0.75
class Rational