Math.round(-1.5)的返回值是-1。四舍五入的原理是在参数上加0.5然后做向下取整。
System.out.println(Math.round(-1.5)); //-1
System.out.println(Math.round(-1.6)); //-2
Math.round(-1.5)的返回值是-1。四舍五入的原理是在参数上加0.5然后做向下取整。
System.out.println(Math.round(-1.5)); //-1
System.out.println(Math.round(-1.6)); //-2