黑马程序员技术交流社区
标题:
Math.round();
[打印本页]
作者:
wangzhye
时间:
2016-6-2 22:07
标题:
Math.round();
Math.round(m) = (int)Math.floor(a + 0.5f)
Math.ceil(x):比x大的最小值。
Math.round(x):四舍五入。
Math.floor(x):比x小的最大值。
jdk说得很明白了,
-11.5+0.5=-11 Math.floor(-11)=-11
-11.3+0.5=-10.8 Math.floor(-10.8)= -11
-11.8+0.5=-11.3 Math.floor(-11.3)= -12
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2