I have a process which returns a floating point number. Then I use the roundToDecimals
method to eliminate some digits.
roundToDecimals(weight,3)
----update june 22 2012 : 1.42 am----
public static double roundToDecimals(double d, int c) {
int temp=(int)((d*Math.pow(10,c)));
return (((double)temp)/Math.pow(10,c));
}
---end of update
It works well but returns more than 3 digits after the decimal point if the last digit is zero ex
0.0020
0.0060
0.333
0.071
Does anyone know how to deal with this kind of problem?