public static Double roundDouble(double val, int precision) {
Double ret = null;
try {
double factor = Math.pow(10, precision);
ret = Math.floor(val * factor + 0.5) / factor;
} catch (Exception e) {
e.printStackTrace();
}
return ret;
}
val为处理double 数字,precsion为保留小数位数。