double 保留指定位数的小数

DecimalFormat df = new DecimalFormat("0.000");
        double d1 = 3.23556;
        System.out.println(df.format(d1));

保留三位小数,结果已经四舍五入了

猜你喜欢

转载自blog.csdn.net/guangyingposuo/article/details/87447090