日期:2014-05-20 浏览次数:20663 次
public double getResult(double a,double b){
if(b==0)
return 0;
String rStr = a/b+"";
int pointIdx = rStr.indexOf(".");
if(pointIdx>0 && (pointIdx+2)<rStr.length()){
double ret = Double.parseDouble(rStr.substring(0,pointIdx+3));
return Integer.parseInt(rStr.substring(pointIdx+3,pointIdx+4))<5?ret:ret+0.01;
}
return a/b;
}