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

Fraction.add(int) and Fraction.subtract(int) ignore risk of integer overflow

    XMLWordPrintableJSON

Details

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

    Description

      The methods add(int) and subtract(int) in the class org.apache.commons.numbers.fraction.Fraction do not take into account the risk of an integer overflow. For example, (2​31 - 1)/2 + 1 = (2​31 + 1)/2, so the numerator overflows an int, but when calculated with Fraction.add(int), the method still returns normally.

      Attachments

        1. NUMBERS-99.patch
          16 kB
          Gilles Sadowski

        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 - 20m
                  20m