Program: 36208
Project: 36208
Buggy source:
/** 
 * Returns the integer and fraction parts of this fraction. The return array is guaranteed to have exactly two elements. The first is guaranteed to be a BigInteger, and the second is guaranteed to be a BigFraction. The first element is the result of integer division of numerator by denominator, using the supplied division mode. The second element is the fraction given by numerator mod denominator, using the given division mode. Note that the division mode only matters if this fraction is negative. Because the sign of a BigFraction is always carried by the numerator, the FLOOR and EUCLIDEAN division modes will always produce the same result. Some examples: <table> <tr><th>Fraction</th><th>TRUNCATE</th><th>FLOOR</th><th>EUCLIDEAN</th></tr> <tr><td> 4/1</td><td>[ 4,  0/1]</td><td>[ 4, 0/1]</td><td>[ 4, 0/1]</td></tr> <tr><td> 4/3</td><td>[ 1,  1/3]</td><td>[ 1, 1/3]</td><td>[ 1, 1/3]</td></tr> <tr><td> 2/7</td><td>[ 0,  2/7]</td><td>[ 0, 2/7]</td><td>[ 0, 2/7]</td></tr> <tr><td>-2/7</td><td>[ 0, -2/7]</td><td>[-1, 5/7]</td><td>[-1, 5/7]</td></tr> <tr><td>-4/3</td><td>[-1, -1/3]</td><td>[-2, 2/3]</td><td>[-2, 2/3]</td></tr> <tr><td>-4/1</td><td>[-4,  0/1]</td><td>[-4, 0/1]</td><td>[-4, 0/1]</td></tr> </table>
 * @see DivisionMode
 */
public Number[] getParts(DivisionMode divisionMode){
  if (denominator.equals(BigInteger.ONE))   return new Number[]{numerator,BigFraction.ZERO};
  final BigInteger[] divmod=numerator.divideAndRemainder(denominator);
  BigInteger iPart=divmod[0];
  BigInteger fPart=divmod[1];
  if (numerator.signum() < 0 && divisionMode != DivisionMode.TRUNCATED) {
    iPart=iPart.subtract(BigInteger.ONE);
    fPart=fPart.add(denominator);
  }
  return new Number[]{iPart,new BigFraction(fPart,denominator,Reduced.YES)};
}

Fixed version (ground truth):
/** 
 * Returns the integer and fraction parts of this fraction. The return array is guaranteed to have exactly two elements. The first is guaranteed to be a BigInteger, and the second is guaranteed to be a BigFraction. The first element is the result of integer division of numerator by denominator, using the supplied division mode. The second element is the fraction given by numerator mod denominator, using the given division mode. Note that the division mode only matters if this fraction is negative. Because the sign of a BigFraction is always carried by the numerator, the FLOOR and EUCLIDEAN division modes will always produce the same result. Some examples: <table summary="Examples of rounding modes"> <tr><th>Fraction</th><th>TRUNCATE</th><th>FLOOR</th><th>EUCLIDEAN</th></tr> <tr><td> 4/1</td><td>[ 4,  0/1]</td><td>[ 4, 0/1]</td><td>[ 4, 0/1]</td></tr> <tr><td> 4/3</td><td>[ 1,  1/3]</td><td>[ 1, 1/3]</td><td>[ 1, 1/3]</td></tr> <tr><td> 2/7</td><td>[ 0,  2/7]</td><td>[ 0, 2/7]</td><td>[ 0, 2/7]</td></tr> <tr><td>-2/7</td><td>[ 0, -2/7]</td><td>[-1, 5/7]</td><td>[-1, 5/7]</td></tr> <tr><td>-4/3</td><td>[-1, -1/3]</td><td>[-2, 2/3]</td><td>[-2, 2/3]</td></tr> <tr><td>-4/1</td><td>[-4,  0/1]</td><td>[-4, 0/1]</td><td>[-4, 0/1]</td></tr> </table>
 * @see DivisionMode
 */
public Number[] getParts(DivisionMode divisionMode){
  if (denominator.equals(BigInteger.ONE))   return new Number[]{numerator,BigFraction.ZERO};
  final BigInteger[] divmod=numerator.divideAndRemainder(denominator);
  BigInteger iPart=divmod[0];
  BigInteger fPart=divmod[1];
  if (numerator.signum() < 0 && divisionMode != DivisionMode.TRUNCATED) {
    iPart=iPart.subtract(BigInteger.ONE);
    fPart=fPart.add(denominator);
  }
  return new Number[]{iPart,new BigFraction(fPart,denominator,Reduced.YES)};
}