java取整

舍掉小數取整:Math.floor(2.0)=2
舍掉小數取整:Math.floor(2.1)=2
舍掉小數取整:Math.floor(2.5)=2
舍掉小數取整:Math.floor(2.9)=2

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

四捨五入取整:Math.rint(2.0)=2
四捨五入取整:Math.rint(2.1)=2
四捨五入取整:Math.rint(2.5)=2
四捨五入取整:Math.rint(2.9)=3

四捨五入取整:Math.rint(-2.0)=-2
四捨五入取整:Math.rint(-2.1)=-2
四捨五入取整:Math.rint(-2.5)=-2
四捨五入取整:Math.rint(-2.9)=-3

湊整:Math.ceil(2.0)=2
湊整:Math.ceil(2.1)=3
湊整:Math.ceil(2.5)=3
湊整:Math.ceil(2.9)=3

湊整:Math.ceil(-2.0)=-2
湊整:Math.ceil(-2.1)=-2
湊整:Math.ceil(-2.5)=-2
湊整:Math.ceil(-2.9)=-2

四捨五入取整:Math.round(2.0)=2
四捨五入取整:Math.round(2.1)=2
四捨五入取整:Math.round(2.5)=3
四捨五入取整:Math.round(2.9)=3

四捨五入取整:Math.round(-2.0)=-2
四捨五入取整:Math.round(-2.1)=-2
四捨五入取整:Math.round(-2.5)=-2
四捨五入取整:Math.round(-2.9)=-3

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章