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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 4.0, 3.6
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: