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(-1
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/30 18:21:05
![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(-1](/uploads/image/z/3999964-4-4.jpg?t=Math.round%3F%E5%A4%A7%E4%BE%A0%E4%BB%AC%E5%B8%AE%E5%BF%99.public+class+Test+%7B%2F%2A%2A%2A+%40param+args%2A%2Fpublic+static+void+main%28String%5B%5D+args%29+%7BSystem.out.println%28Math.round%28-11.5%29%29%3BSystem.out.println%28Math.round%28-12.4%29%29%3BSystem.out.println%28Math.round%28-12.5%29%29%3BSystem.out.println%28Math.round%28-1)
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(-1
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
怎么结果不一样.
四舍六入五成双是什么意思?
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(-1
round(参数)是最接近参数的整数是几,通俗讲就是四舍五入.
但是负数要注意,五入的时候要往大的数入.比如-12.5 就变-12而不是-13因为-12比-13大,
所以以上结果就算出来了