You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Osamu Ikeuchi (JIRA)" <ji...@apache.org> on 2015/08/20 14:47:52 UTC

[jira] [Created] (MATH-1261) Overflow checks in Fraction multiply(int) / divide(int)

Osamu Ikeuchi created MATH-1261:
-----------------------------------

             Summary: Overflow checks in Fraction multiply(int) / divide(int)
                 Key: MATH-1261
                 URL: https://issues.apache.org/jira/browse/MATH-1261
             Project: Commons Math
          Issue Type: Bug
    Affects Versions: 3.5
            Reporter: Osamu Ikeuchi
            Priority: Minor


The member methods multiply(int) / divide(int) in the class org.apache.commons.math3.fraction.Fraction do not have overflow checks.

return new Fraction(numerator * i, denominator);

should be

return new Fraction(ArithmeticUtils.mulAndCheck(numerator, i), denominator);

or, considering the case gcd(i, denominator) > 1,

return multiply(new Fraction(i));



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)