Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-662

org.apache.commons.lang3.math.Fraction does not reduce (Integer.MIN_VALUE, 2^k)

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0
    • Fix Version/s: 3.0
    • Component/s: lang.math.*
    • Labels:
      None

      Description

      The greatestCommonDivisor method in class Fraction does not find the gcd of Integer.MIN_VALUE and 2^k, and this case can be triggered by taking Integer.MIN_VALUE as the numerator. Note that the case of taking Integer.MIN_VALUE as the denominator is handled explicitly in the getReducedFraction factory method.

      FractionTest.java
      	// additional test cases
      	public void testReducedFactory_int_int() {
      		// ...
      		f = Fraction.getReducedFraction(Integer.MIN_VALUE, 2);
      		assertEquals(Integer.MIN_VALUE / 2, f.getNumerator());
      		assertEquals(1, f.getDenominator());
      
      	public void testReduce() {
      		// ...
      		f = Fraction.getFraction(Integer.MIN_VALUE, 2);
      		result = f.reduce();
      		assertEquals(Integer.MIN_VALUE / 2, result.getNumerator());
      		assertEquals(1, result.getDenominator());
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                chsemrau Christian Semrau
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: