Uploaded image for project: 'Commons Numbers'
  1. Commons Numbers
  2. NUMBERS-127

Fraction(int, int) rejects possibly reducible numerator or denominator 2^-31

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0
    • 1.0-beta1
    • fraction
    • None

    Description

      Since the sign of a fraction is held by the numerator, it is possible that the values passed as numerator and denominator need to be negated. This is not possible for 2^-31 due to overflow, so the constructor throws an exception in this case. However, the constructor forgets that this value might be reducible if the passed numerator and denominator are not coprime, so it rejects values where the representation in lowest terms would not overflow.

      Also, the check whether the denominator is negative and the corresponding negation of the numerator and denominator is coded twice, with the second conditional block being dead code because the sign has already been moved to the numerator by then.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Schamschi Heinrich Bohne
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h