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

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.0
    • 3.0
    • lang.math.*
    • 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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment