摘要: 方法1:用Math.round计算,这里返回的数字格式的.float price=89.89;int itemNum=3;float totalPrice=price*itemNum;float num=(float)(Math.round(totalPrice*100)/100);//如果要求精确4位就*10000然后/10000方法2:用DecimalFormat 返回的是String格式的.该类对十进制进行全面的封装.像%号,千分位,小数精度.科学计算.float price=1.2;DecimalFormat decimalFormat=new DecimalFormat(" 阅读全文