java 四舍五入

    double f = 111231.035;
        BigDecimal l = new BigDecimal(f);
        double c = l.setScale(2, RoundingMode.HALF_UP).doubleValue();
        System.out.println("返回值:"+c)
        double d = 323.5627614;
        DecimalFormat format = new DecimalFormat("#.000");
        String c = format.format(d);
        System.out.println("格式化后 "+c);

格式化后 323.563
;
原文地址:https://www.cnblogs.com/lihaolihao/p/3861434.html