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

 

;
posted @ 2014-07-22 21:27  nihao1314520  阅读(135)  评论(0编辑  收藏  举报