fractionDigits static method
Implementation
static String fractionDigits(double frac, int maxDecimals) {
String out = "";
double rest = frac;
double place = 0.1;
int i = 0;
while (i < maxDecimals) {
int digit = VlJson.digitAt(rest, place);
out = out + VlJson.digitChar(digit);
rest = rest - digit.toDouble() * place;
place = place / 10.0;
i = i + 1;
}
int end = out.length;
bool stop = false;
while (end > 0 && false == stop) {
if ( out.substring(end - 1, end ) == "0" ) {
end = end - 1;
} else {
stop = true;
}
}
return out.substring(0, end );
}