java数字(double/float)向上取整,向下取整,四舍五入

向上取整:Math.ceil(double a) 
向下取整:Math.floor(double a) 
四舍五入取整:Math.round(double a) 

例:

Math.ceil(24.1)--> 25

Math.floor(24.8)--> 24

Math.round(24.1)--> 24

Math.round(24.8)--> 25

猜你喜欢

转载自blog.csdn.net/geniushorse/article/details/83182241