[
https://issues.apache.org/jira/browse/MATH-1261?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gilles resolved MATH-1261.
--------------------------
Resolution: Fixed
Fix Version/s: 3.6
4.0
Fixed (using your second suggestion) in the following commits:
0820703df043ca5df06fe808bc2998296e7bbcc5 (3.6)
4c4b3e2e32ddae35e4c1a6ffce1cd2b2eafa958b (4.0)
Thanks for the report and fix!
> 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
> Reporter: Osamu Ikeuchi
> Priority: Minor
> Fix For: 4.0, 3.6
>
>
> The member methods multiply(int) / divide(int) in the class
> org.apache.commons.math3.fraction.Fraction do not have overflow checks.
> {code:java}
> return new Fraction(numerator * i, denominator);
> {code}
> should be
> {code:java}
> return new Fraction(ArithmeticUtils.mulAndCheck(numerator, i), denominator);
> {code}
> or, considering the case gcd(i, denominator) > 1,
> {code:java}
> return multiply(new Fraction(i));
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)