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

BigFraction numerator constrainted by int size during multiplication

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0
    • 2.1
    • None
    • All

    Description

      When multiplying two BigFraction objects with numerators larger than will fit in an java-primitive int the result of BigFraction.ZERO is incorrectly returned.

      Test Case:

      BigFraction fractionA = new BigFraction(0.00131);
      BigFraction fractionB = new BigFraction(.37).reciprocal();
      BigFraction errorResult = fractionA.multiply(fractionB);
      System.out.println("Error Result: " + errorResult);
      BigFraction correctResult = new BigFraction(fractionA.getNumerator().multiply(fractionB.getNumerator()), fractionA.getDenominator().multiply(fractionB.getDenominator()));
      System.out.println("Correct Result: " + correctResult);

      Attachments

        Activity

          People

            Unassigned Unassigned
            mjtaylor Matt Taylor
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: