Program: 54806
Project: 54806
Buggy source:
/** 
 * This method formats a <code>double</code> into a fractional representation.
 * @param number value need to be formated
 * @param result result will be written here
 * @param minIntDigits minimum integer digits
 */
private void subformatFixed(double number,StringBuffer result,int minIntDigits){
  double power=Math.pow(10,maximumFractionDigits);
  number=Math.round(number * power);
  double intValue=(double)Math.floor(number / power);
  double fracValue=(double)Math.floor(number - intValue * power);
  boolean fractionPresent=(minimumFractionDigits > 0) || (fracValue > 0);
  String intPart=String.valueOf(intValue);
  String grouping=isCurrencyFormat ? numberConstants.monetaryGroupingSeparator() : numberConstants.groupingSeparator();
  String decimal=isCurrencyFormat ? numberConstants.monetarySeparator() : numberConstants.decimalSeparator();
  int zeroDelta=numberConstants.zeroDigit().charAt(0) - '0';
  int digitLen=intPart.length();
  if (intValue > 0 || minIntDigits > 0) {
    for (int i=digitLen; i < minIntDigits; i++) {
      result.append(numberConstants.zeroDigit());
    }
    for (int i=0; i < digitLen; i++) {
      result.append((char)(intPart.charAt(i) + zeroDelta));
      if (digitLen - i > 1 && groupingSize > 0 && ((digitLen - i) % groupingSize == 1)) {
        result.append(grouping);
      }
    }
  }
 else   if (!fractionPresent) {
    result.append(numberConstants.zeroDigit());
  }
  if (decimalSeparatorAlwaysShown || fractionPresent) {
    result.append(decimal);
  }
  String fracPart=String.valueOf(fracValue + power);
  int fracLen=fracPart.length();
  while (fracPart.charAt(fracLen - 1) == '0' && fracLen > minimumFractionDigits + 1) {
    fracLen--;
  }
  for (int i=1; i < fracLen; i++) {
    result.append((char)(fracPart.charAt(i) + zeroDelta));
  }
}

Fixed version (ground truth):
/** 
 * This method formats a <code>double</code> into a fractional representation.
 * @param number value need to be formated
 * @param result result will be written here
 * @param minIntDigits minimum integer digits
 */
private void subformatFixed(double number,StringBuffer result,int minIntDigits){
  double power=Math.pow(10,maximumFractionDigits);
  double intValue=(double)Math.floor(number);
  double fracValue=(double)Math.floor((number - intValue) * power + 0.5d);
  if (fracValue >= power) {
    intValue+=1.0;
    fracValue-=power;
  }
  boolean fractionPresent=(minimumFractionDigits > 0) || (fracValue > 0);
  String intPart=makeIntString(intValue);
  String grouping=isCurrencyFormat ? numberConstants.monetaryGroupingSeparator() : numberConstants.groupingSeparator();
  String decimal=isCurrencyFormat ? numberConstants.monetarySeparator() : numberConstants.decimalSeparator();
  int zeroDelta=numberConstants.zeroDigit().charAt(0) - '0';
  int digitLen=intPart.length();
  if (intValue > 0 || minIntDigits > 0) {
    for (int i=digitLen; i < minIntDigits; i++) {
      result.append(numberConstants.zeroDigit());
    }
    for (int i=0; i < digitLen; i++) {
      result.append((char)(intPart.charAt(i) + zeroDelta));
      if (digitLen - i > 1 && groupingSize > 0 && ((digitLen - i) % groupingSize == 1)) {
        result.append(grouping);
      }
    }
  }
 else   if (!fractionPresent) {
    result.append(numberConstants.zeroDigit());
  }
  if (decimalSeparatorAlwaysShown || fractionPresent) {
    result.append(decimal);
  }
  String fracPart=makeIntString(Math.floor(fracValue + power + 0.5d));
  int fracLen=fracPart.length();
  while (fracPart.charAt(fracLen - 1) == '0' && fracLen > minimumFractionDigits + 1) {
    fracLen--;
  }
  for (int i=1; i < fracLen; i++) {
    result.append((char)(fracPart.charAt(i) + zeroDelta));
  }
}