Math.round(Doble a);
将双精度浮点值舍入为最接近的整数值。
参数 a:类型System.Dounble,要舍入的双精度浮点数。
返回值 类型:System.Double.为接近a的整数。请注意,此方法返回Double,而不是整数类型。
Math.round(11.5) = 12;
Math.round(-11.5) = -11;
Math.round(11.46) = 11;
Math.round(-11.46) = -11;
Math.round(11.68) = 12;
Math.round(-11.68) = -12;
可以这么理解:当参数小数点后面不是5的时候,保留参数的符号,对整数部分进行四舍五入,符号不变;
当参数小数点后面是5是,不管正负,(数轴上)向右取整。