in metrics-core/src/benchmarks/java/com/amazon/metrics/DoubleFormat.java [130:150]
private static int countLeadingZeros(int fraction) {
int max = (int) MAX;
// detect this error because otherwise you get infinite looping...
if(fraction < 0) {
throw new IllegalArgumentException("Negative fraction: " + fraction);
}
// if the fraction is zero, specify minimumFractionDigits-1 as the zero count
// otherwise no fraction will be displayed.
if(fraction == 0) {
return -1;
}
int count = 0;
while( (fraction *= 10) < max ) {
count++;
}
return count;
}