java中的几种取整函数


舍掉小数取整:Math.floor(2)=2
舍掉小数取整:Math.floor(2.1)=2
舍掉小数取整:Math.floor(2.5)=2
舍掉小数取整:Math.floor(2.9)=2
负数舍掉小数取整:Math.floor(-2)=-2
负数舍掉小数取整:Math.floor(-2.1)=-3
负数舍掉小数取整:Math.floor(-2.5)=-3
负数舍掉小数取整:Math.floor(-2.9)=-3

见小数取整:Math.ceil(2)=2
见小数取整:Math.ceil(2.1)=3
见小数取整:Math.ceil(2.5)=3
见小数取整:Math.ceil(2.9)=3

负数见小数取整:Math.ceil(-2)=-2
负数见小数取整:Math.ceil(-2.1)=-2
负数见小数取整:Math.ceil(-2.5)=-2
负数见小数取整:Math.ceil(-2.9)=-2

  

*****************************************************************************************************


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM