- Math.ceil、Math.floor、Math.round用法??
public static void main(String[] args) {
// Math.ceil(double)向上取整
System.out.println(Math.ceil(11.4)); //向上取整12
System.out.println(Math.ceil(-11.4)); //向上取整 -11
// Math.floor(double)向下取整
System.out.println(Math.floor(11.4)); //向下取整 11
System.out.println(Math.floor(-11.4)); //向下取整 -12
// Math.round(double)四舍五入, double + 0.5向下取整
System.out.println(Math.round(11.4));// 11.4 + 0.5 = 11.9 向下取整11
System.out.println(Math.round(-11.4)); // -11.4 + 0.5 = -10.9 向下取整 -11
System.out.println(Math.round(11.5));// 11.5 + 0.5 = 12.0 向下取整12
System.out.println(Math.round(-11.5)); // -11.5 + 0.5 = -11.0 向下取整 -11
}