取整函数Math.foor()、Math.ceil()、Math.round()的区别

floor: 求小于参数的最大整数。返回double类型-----n. 地板,地面
         例如:Math.floor(-4.2) = -5.0
-----------------------------------------------------------
ceil:   求大于参数的最小整数。返回double类型-----vt. 装天花板;
         例如:Math.ceil(5.6) = 6.0
-----------------------------------------------------------
round: 对小数进行四舍五入后的结果。返回int类型
         例如:Math.round(-4.6) = -5

猜你喜欢

转载自blog.csdn.net/shytan/article/details/81033450