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

Creating BigFraction objects is not consistent for negative/positive values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 3.3
    • None
    • None

    Description

      Creating a BigFraction object for large integer values will return different results whether the argument is positive or negative:

        BigFraction f1 = new BigFraction(-1e10, 1000); -> will return a fraction with a numerator of -1e10 and denominator of 1
        BigFraction f2 = new BigFraction(1e10, 1000); -> will throw a FractionConversionException
      

      the problem is in the check for overflow, it is not done on the absolute value of the argument, also it should be done only after the check if the argument is actually an integer.

      Attachments

        Activity

          People

            tn Thomas Neidhart
            tn Thomas Neidhart
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: