I can help you regarding the first problem.
Using the following method you do precesion upto any value.
/**
* This method provides a more sophisticated use of Math.round(double)
* for getting the the precision values.
*
* @param value The value to round.
* @param precision The basically an indicator of what digit to apply round
to.
* @return The resultant value.
*/
public static final float getPrecisionRound (float value, int precision) {
String sPattern = "####.0";
for (int i=1;i<precision ; i++)
sPattern += "0";
java.text.DecimalFormat df = new java.text.DecimalFormat (sPattern);
return Float.parseFloat (df.format(value));
}
So you should call this method as ---> getPrecisionRound (1.12345,3)
Here
1.12345 => The number you want to do precision.
3 => round it and just keep three digit after " ."