Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1261

Overflow checks in Fraction multiply(int) / divide(int)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.0, 3.6
    • Labels:
      None

      Description

      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));
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              osamu.ikeuchi Osamu Ikeuchi
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: