java中的几种取整函数

时间:2023-03-09 16:25:01
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

  

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

java中的几种取整函数