四舍五入基本原理:加0.5并向下取整;
下面是代码块和实验结果:
System.out.println("Math.round(11.0): "+Math.round(11.0));
System.out.println("Math.round(-11.0): "+Math.round(-11.0));
System.out.println("Math.round(11.5): "+Math.round(11.5));
System.out.println("Math.round(-11.5): "+Math.round(-11.5));
Math.round(11.0): 11 Math.round(-11.0): -11 Math.round(11.5): 12 Math.round(-11.5): -11 Process finished with exit code 0



