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

  

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

posted on 2016-11-09 14:40  Honey_Badger  阅读(17882)  评论(0编辑  收藏  举报

导航

github