Program: 69322
Project: 69322
Buggy source:
/** 
 * Computes value precision if more precise than existing one For instance 3.4 has a precision of 0.1 and 1400 has a precision of 100. That is the position where the first significant digit appears, or in double representation, the value of the exponent
 * @param precision
 * @param value
 * @return precision
 */
protected static double getPrecision(double precision,double pValue,FormatSpecifier fs,ULocale locale,boolean bIsPercent){
  double value=Math.abs(pValue);
  value=getValidDouble(value);
  final boolean isFirst=Double.isNaN(precision);
  if (value == 0) {
    if (isFirst || precision == 0) {
      return 1;
    }
    return precision;
  }
  if (isFirst) {
    precision=0;
  }
  if (precision == 0) {
    if (bIsPercent) {
      precision=1;
    }
 else {
      precision=Math.pow(10,Math.floor(Math.log(value) / Math.log(10)));
    }
  }
  double check=value / precision;
  int loopCounter=0;
  while (Math.floor(check) != check && loopCounter < 20) {
    loopCounter++;
    precision/=10;
    check=value / precision;
  }
  if (loopCounter == 20)   logger.log(ILogger.WARNING,"String_Node_Str" + value);
  if (fs != null) {
    if (fs instanceof NumberFormatSpecifier) {
      NumberFormatSpecifier ns=(NumberFormatSpecifier)fs;
      if (ns.isSetFractionDigits()) {
        double multiplier=ns.isSetMultiplier() ? ns.getMultiplier() : 1;
        if (multiplier != 0) {
          double formatPrecision=Math.pow(10,-ns.getFractionDigits()) / multiplier;
          if (precision == 0)           precision=formatPrecision;
 else           precision=Math.max(precision,formatPrecision);
        }
      }
    }
  }
  return precision;
}

Fixed version (ground truth):
/** 
 * Computes value precision if more precise than existing one For instance 3.4 has a precision of 0.1 and 1400 has a precision of 100. That is the position where the first significant digit appears, or in double representation, the value of the exponent
 * @param precision
 * @param value
 * @return precision
 */
protected static double getPrecision(double precision,double pValue,FormatSpecifier fs,ULocale locale,boolean bIsPercent){
  double value=Math.abs(pValue);
  value=getValidDouble(value);
  final boolean isFirst=Double.isNaN(precision);
  if (value == 0) {
    if (isFirst || precision == 0) {
      return 1;
    }
    return precision;
  }
  if (isFirst) {
    precision=0;
  }
  if (precision == 0) {
    if (bIsPercent) {
      precision=1;
    }
 else {
      precision=Math.pow(10,Math.floor(Math.log(value) / Math.log(10)));
    }
  }
  double check=value / precision;
  int loopCounter=0;
  while (!ChartUtil.mathEqual(Math.floor(check),check) && loopCounter < 20) {
    loopCounter++;
    precision/=10;
    check=value / precision;
  }
  if (loopCounter == 20)   logger.log(ILogger.WARNING,"String_Node_Str" + value);
  if (fs != null) {
    if (fs instanceof NumberFormatSpecifier) {
      NumberFormatSpecifier ns=(NumberFormatSpecifier)fs;
      if (ns.isSetFractionDigits()) {
        double multiplier=ns.isSetMultiplier() ? ns.getMultiplier() : 1;
        if (multiplier != 0) {
          double formatPrecision=Math.pow(10,-ns.getFractionDigits()) / multiplier;
          if (precision == 0)           precision=formatPrecision;
 else           precision=Math.max(precision,formatPrecision);
        }
      }
    }
  }
  return precision;
}