Use `div` (integer divition) instead of `/` for rational numbers.

parent 0c91da25
...@@ -94,9 +94,9 @@ class Rational < Numeric ...@@ -94,9 +94,9 @@ class Rational < Numeric
def _simplify def _simplify
a = numerator a = numerator
b = denominator b = denominator
a, b = b, a % b while !b.zero? a, b = b, a % b until b.zero?
@numerator /= a @numerator = @numerator.div(a)
@denominator /= a @denominator = @denominator.div(a)
end end
attr_reader :numerator, :denominator attr_reader :numerator, :denominator
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment