Java中Math类的取整方法

Math类中主要提供了以下几种有关整数的方法:

1.static double cell(double a):返回大于等于a的最小整数:

2.static double floor(double a):返回小于等于a的最大整数

3.static double rint(double a):返回与a最相近的整数,返回10.0

4.static long round(double a):返回与a最相近的长整形数

5.static int round(float a):返回与a最相近的整型数

各方法运行如下:



猜你喜欢

转载自blog.csdn.net/weixin_42218884/article/details/80572517