Program: 26906
Project: 26906
Buggy source:
/** 
 * Formats the given number to the given number of decimals, and returns the number as a string, maximum 35 characters.
 * @param number
 * @param digitCount
 * @param separateTousands set this to true to separate thousands values
 * @return
 */
public static String formatNumber(float number,int digitCount,boolean separateThousands){
  char[] out=new char[35];
  boolean neg=false;
  if (number == 0) {
    return "String_Node_Str";
  }
  boolean zero=false;
  if (number < 1 && number > -1) {
    zero=true;
  }
  if (number < 0) {
    neg=true;
    number=-number;
  }
  if (digitCount > POW_10.length) {
    digitCount=POW_10.length - 1;
  }
  number*=POW_10[digitCount];
  long lval=Math.round(number);
  int ind=out.length - 1;
  int charCount=0;
  boolean decimalPointAdded=false;
  while (lval != 0 || charCount < (digitCount + 1)) {
    int digit=(int)(lval % 10);
    lval=lval / 10;
    out[ind--]=(char)(digit + '0');
    charCount++;
    if (charCount == digitCount) {
      out[ind--]=',';
      charCount++;
      decimalPointAdded=true;
    }
 else     if (separateThousands && lval != 0 && charCount > digitCount) {
      if (decimalPointAdded) {
        if ((charCount - digitCount) % 4 == 0) {
          out[ind--]='.';
          charCount++;
        }
      }
 else {
        if ((charCount - digitCount) % 4 == 3) {
          out[ind--]='.';
          charCount++;
        }
      }
    }
  }
  if (zero)   out[ind--]='0';
  if (neg)   out[ind--]='-';
  int start=out.length - charCount;
  return String.valueOf(out,start,out.length - start);
}

Fixed version (ground truth):
/** 
 * Formats the given number to the given number of decimals, and returns the number as a string, maximum 35 characters.
 * @param number
 * @param digitCount
 * @param separateTousands set this to true to separate thousands values
 * @return
 */
public static String formatNumber(float number,int digitCount,boolean separateThousands){
  char[] out=new char[35];
  boolean neg=false;
  if (number == 0) {
    return "String_Node_Str";
  }
  boolean zero=false;
  if (number < 1 && number > -1) {
    zero=true;
  }
  if (number < 0) {
    neg=true;
    number=-number;
  }
  if (digitCount > POW_10.length) {
    digitCount=POW_10.length - 1;
  }
  number*=POW_10[digitCount];
  long lval=Math.round(number);
  int ind=out.length - 1;
  int charCount=0;
  boolean decimalPointAdded=false;
  while (lval != 0 || charCount < (digitCount + 1)) {
    int digit=(int)(lval % 10);
    lval=lval / 10;
    out[ind--]=(char)(digit + '0');
    charCount++;
    if (charCount == digitCount) {
      out[ind--]=',';
      charCount++;
      decimalPointAdded=true;
    }
 else     if (separateThousands && lval != 0 && charCount > digitCount) {
      if (decimalPointAdded) {
        if ((charCount - digitCount) % 4 == 0) {
          out[ind--]='.';
          charCount++;
        }
      }
 else {
        if ((charCount - digitCount) % 4 == 3) {
          out[ind--]='.';
          charCount++;
        }
      }
    }
  }
  if (zero) {
    out[ind--]='0';
    charCount+=1;
  }
  if (neg) {
    out[ind--]='-';
    charCount+=1;
  }
  int start=out.length - charCount;
  return String.valueOf(out,start,out.length - start);
}