Util

1.   获取指定位数小数

 /**
     * 获取指定位数小数
     * @param src 源数据
     * @param num 指定位数
     * @return
     */
    public static double get2decimal(double src, int num) {
        String fo = "0.";
        for(int i=0; i<num; i++) {
            fo+="0";
        }
        DecimalFormat df = new DecimalFormat(fo); 
        return Double.parseDouble(df.format(src));
    }

猜你喜欢

转载自www.cnblogs.com/redhat0019/p/9144106.html