1     public static String divToString(double v1, double v2, int scale){
2         if (scale < 0) {
3             throw new IllegalArgumentException(
4                     "The scale must be a positive integer or zero");
5         }
6         BigDecimal b1 = new BigDecimal(Double.toString(v1));
7         BigDecimal b2 = new BigDecimal(Double.toString(v2));
8         return  b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).toString();
9     }

只要将BigDecimal 对象toString()就好。

相关文章:

  • 2021-10-04
  • 2021-12-12
  • 2021-12-02
  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
  • 2022-02-07
猜你喜欢
  • 2022-01-21
  • 2022-01-17
  • 2022-02-11
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
相关资源
相似解决方案