Java中.Math里面的ceil,floor,和round的区别在于:
ceil:中文的意思是天花板,意思就是向上取值,就是数学里面的进一法;返回的类型是:双精度浮点型double;
例如:Math.ceil(11.0000001);其结果等于12.0;
对于负数来说可以这样理解:取整:Math.ceil(-11.999999999);其结果等于-11.0;
floor:中文的意思是地板,其作用于ceil刚好相反;返回的类型是:单精度浮点型float;
例如:Math.floor(11.999999);其结果等于11.0;
对于负数来说:Math.floor(-11.00001);其结果等于-12.0;
round:意思是四舍五入;round返回的类型是长整型long;
Math.round(-11.00033);其结果等于-11;
Math.round(11.00033);其结果等于11;
Math.round(-11.58888);其结果等于-12;
Math.round(11.58888);其结果等于12;