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

BigFraction numerator constrainted by int size during multiplication

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.1
    • Labels:
      None
    • Environment:

      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

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

              Dates

              • Created:
                Updated:
                Resolved: