/** * @Dscription: scale,保留几位小数点 molecular 分子,denominator 分母 * @Author: zyn * @Date: 2021/7/27 */ private static BigDecimal round(double molecular,double denominator,int scale){ double total = (molecular * 100.0) / denominator; double total2 = new BigDecimal(total).setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue(); return new BigDecimal(total2); } /** * @Dscription: scale,保留几位小数点 v,需要操作的数 * @Author: zyn * @Date: 2021/7/27 */ private static BigDecimal round(double f,int scale){ return new BigDecimal(f).setScale(scale, RoundingMode.UP); }