/**
** 一般情况下 精度是保留2位小数,并且四舍五入。
<span style="white-space:pre"> </span>但是,如果涉及金钱的话,也有一些其他要求,比如只要整数位,保留2位小数且不要四舍五入。
**/
<span style="white-space:pre"> </span>double s = 152.80d;
System.out.println(Math.floor(s));
//返 回 152.0
DecimalFormat formater = new DecimalFormat("#0.##");
formater.setRoundingMode(RoundingMode.FLOOR);
System.out.println(formater.format(499999.1683));
// 返回499999.16
double f = 499999.1683;
BigDecimal b = new BigDecimal(f);
double f1 = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
System.out.println(f1);
//499999.17