double payPercent=123.123456785;
BigDecimal bg = new BigDecimal(String.valueOf(payPercent)).setScale(8, RoundingMode.HALF_UP);
System.out.println(bg.doubleValue()); // 123.12345679;
java四舍五入保留n位小数
最新推荐文章于 2023-10-31 21:09:37 发布
double payPercent=123.123456785;
BigDecimal bg = new BigDecimal(String.valueOf(payPercent)).setScale(8, RoundingMode.HALF_UP);
System.out.println(bg.doubleValue()); // 123.12345679;