Math.round?大侠们帮忙.

问题描述:

Math.round?大侠们帮忙.
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println(Math.round(-11.5));
System.out.println(Math.round(-12.4));
System.out.println(Math.round(-12.5));
System.out.println(Math.round(-12.6));
}
}
显示结果:
-11
-12
-12
-13
这些结果是怎么算出来的?
System.out.println(Math.round(-12.5));
System.out.println(Math.round(-12.6));
-12
-13
怎么结果不一样.
四舍六入五成双是什么意思?
1个回答 分类:综合 2014-12-14

问题解答:

我来补答
ound(参数)是最接近参数的整数是几,通俗讲就是四舍五入.
但是负数要注意,五入的时候要往大的数入.比如-12.5 就变-12而不是-13因为-12比-13大,
所以以上结果就算出来了
 
 
展开全文阅读
剩余:2000