Math.round()
就是数学中的四舍五入,举例:
System.out.println("Math.round(1.2)="+Math.round(1.2));
System.out.println("Math.round(1.5)="+Math.round(1.5));
System.out.println("Math.round(1.7)="+Math.round(1.7));
System.out.println("Math.round(-1.2)="+Math.round(-1.2));
System.out.println("Math.round(-1.5)="+Math.round(-1.5));
System.out.println("Math.round(-1.7)="+Math.round(-1.7));
结果输出为:
Math.round(1.2)=1
Math.round(1.5)=2
Math.round(1.