//Math中ceil,floor,rint和round的用法。
public class Test {
public static void main(String[] args){
// 要是正数就去掉小数点加1,要是负数就去点小数。
System.out.println(Math.ceil(15.1));
// 要是正数就去掉小数,要是负数就去掉小数减1
System.out.println(Math.floor(-8.001));
// 返回最接近参数并等于某一整数的 double 值,5为分界点。
System.out.println(Math.rint(27.9));
// round和rint的用法,有点相同。
System.out.println(Math.round(27.9));
}
}
Math中ceil,floor,rint和round的用法
最新推荐文章于 2023-04-02 19:24:19 发布