Program: 54210
Project: 54210
Buggy source:
/** 
 * Returns a new   {@code BigDecimal} instance with the specified scale.<p> If the new scale is greater than the old scale, then additional zeros are added to the unscaled value. In this case no rounding is necessary. <p> If the new scale is smaller than the old scale, then trailing digits are removed. If these trailing digits are not zero, then the remaining unscaled value has to be rounded. For this rounding operation the specified rounding mode is used.
 * @param newScale scale of the result returned.
 * @param roundingMode rounding mode to be used to round the result.
 * @return a new {@code BigDecimal} instance with the specified scale.
 * @throws NullPointerException if {@code roundingMode == null}.
 * @throws ArithmeticException if {@code roundingMode == ROUND_UNNECESSARY}and rounding is necessary according to the given scale.
 */
public BigDecimal setScale(int newScale,RoundingMode roundingMode){
  if (roundingMode == null) {
    throw new NullPointerException();
  }
  double diffScale=newScale - scale;
  if (diffScale == 0) {
    return this;
  }
  if (diffScale > 0) {
    if (diffScale < DOUBLE_TEN_POW.length && (this.bitLength + DOUBLE_TEN_POW_BIT_LENGTH[(int)diffScale]) < 54) {
      return valueOf(this.smallValue * DOUBLE_TEN_POW[(int)diffScale],newScale);
    }
    return new BigDecimal(Multiplication.multiplyByTenPow(getUnscaledValue(),(int)diffScale),newScale);
  }
  if (this.bitLength < 54 && -diffScale < DOUBLE_TEN_POW.length) {
    return dividePrimitiveLongs((long)this.smallValue,(long)DOUBLE_TEN_POW[(int)-diffScale],newScale,roundingMode);
  }
  return divideBigIntegers(this.getUnscaledValue(),Multiplication.powerOf10(-diffScale),newScale,roundingMode);
}

Fixed version (ground truth):
/** 
 * Returns a new   {@code BigDecimal} instance with the specified scale.<p> If the new scale is greater than the old scale, then additional zeros are added to the unscaled value. In this case no rounding is necessary. <p> If the new scale is smaller than the old scale, then trailing digits are removed. If these trailing digits are not zero, then the remaining unscaled value has to be rounded. For this rounding operation the specified rounding mode is used.
 * @param newScale scale of the result returned.
 * @param roundingMode rounding mode to be used to round the result.
 * @return a new {@code BigDecimal} instance with the specified scale.
 * @throws NullPointerException if {@code roundingMode == null}.
 * @throws ArithmeticException if {@code roundingMode == ROUND_UNNECESSARY}and rounding is necessary according to the given scale.
 */
public BigDecimal setScale(int newScale,RoundingMode roundingMode){
  if (roundingMode == null) {
    throw new NullPointerException();
  }
  double diffScale=newScale - scale;
  if (diffScale == 0) {
    return this;
  }
  if (diffScale > 0) {
    if (diffScale < DOUBLE_TEN_POW.length && (this.bitLength + DOUBLE_TEN_POW_BIT_LENGTH[(int)diffScale]) < SMALL_VALUE_BITS) {
      return valueOf(this.smallValue * DOUBLE_TEN_POW[(int)diffScale],newScale);
    }
    return new BigDecimal(Multiplication.multiplyByTenPow(getUnscaledValue(),(int)diffScale),newScale);
  }
  if (this.bitLength < SMALL_VALUE_BITS && -diffScale < DOUBLE_TEN_POW.length) {
    return dividePrimitiveLongs((long)this.smallValue,(long)DOUBLE_TEN_POW[(int)-diffScale],newScale,roundingMode);
  }
  return divideBigIntegers(this.getUnscaledValue(),Multiplication.powerOf10(-diffScale),newScale,roundingMode);
}