向上取整用Math.ceil(double a)向下取整用Math.floor(double a) // 举例: 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
本文共 289 字,大约阅读时间需要 1 分钟。
向上取整用Math.ceil(double a)向下取整用Math.floor(double a) // 举例: 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
转载于:https://www.cnblogs.com/yangjinwang/p/5993145.html