向上取整用Math.ceil(double a)

向下取整用Math.floor(double a)
举例:

public static void main(String[] args) throws Exception {
        double a = 35;
        double b = 20;
        double c = a / b;
        System.out.println("c===>" + c); // 1.75
        System.out.println("c===>" + Math.ceil(c)); // 2.0
        System.out.println(Math.floor(c)); // 1.0
    }

相关文章:

  • 2021-11-21
  • 2022-12-23
  • 2021-05-06
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
猜你喜欢
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案