Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-663

org.apache.commons.lang3.math.Fraction does not always succeed in multiplyBy and divideBy

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0
    • Fix Version/s: 3.0
    • Component/s: lang.math.*
    • Labels:
      None

      Description

      The Fraction.multiplyBy and divideBy methods fail sometimes when the arguments are not reduced.

      FunctionTest.java
          public void testMultiply() {
              // ...
              f1 = Fraction.getFraction(Integer.MAX_VALUE, Integer.MAX_VALUE);
              f2 = Fraction.getFraction(42, 1);
              f = f1.multiplyBy(f2);
              assertEquals(42, f.getNumerator());
              assertEquals(1, f.getDenominator());
      
          public void testDivide() {
              // ...
              f1 = Fraction.getFraction(Integer.MAX_VALUE, Integer.MAX_VALUE);
              f2 = Fraction.getFraction(42, 1);
              f = f1.divideBy(f2);
              assertEquals(1, f.getNumerator());
              assertEquals(42, f.getDenominator());
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                chsemrau Christian Semrau
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: