java中Math.round(-1.5)的结果是多少呢?
下文笔者讲述Math.round(-1.5)和Math.round(1.5)的结果简介说明,如下所示
Math.round是向上舍弃 所以整的四舍五入向上增加 负的数字,则直接丢弃例:
package com.java265.other;
public class Test16 {
/**
* java265.com 示例程序
*/
public static void main(String[] args) {
System.out.println(Math.round(-1.1));
System.out.println(Math.round(-1.2));
System.out.println(Math.round(-1.3));
System.out.println(Math.round(-1.4));
System.out.println(Math.round(-1.5));
System.out.println(Math.round(-1.6));
System.out.println(Math.round(-1.7));
System.out.println(Math.round(-1.8));
System.out.println(Math.round(-1.9));
System.out.println(Math.round(-2.0));
System.out.println(Math.round(1.1));
System.out.println(Math.round(1.2));
System.out.println(Math.round(1.3));
System.out.println(Math.round(1.4));
System.out.println(Math.round(1.5));
System.out.println(Math.round(1.6));
System.out.println(Math.round(1.7));
System.out.println(Math.round(1.8));
System.out.println(Math.round(1.9));
System.out.println(Math.round(2.0));
}
}
-----运行以上代码,将输出以下信息------
-1
-1
-1
-1
-1
-2
-2
-2
-2
-2
1
1
1
1
2
2
2
2
2
2
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。


