Java基础———第一弹

来源:互联网 发布:大承网络 编辑:程序博客网 时间:2024/06/07 01:12

(1)Math类中提供了三个取整的方法:ceil   floor  round

ceil 向上取整  Math.ceil(11.3)=12     Math.ceil(-11.3)=-11

floor 向下取整 Math.floor(11.6)=11    Math.floor(-11.6)=-12

round 四舍五入 算法为Math.floor(x+0.5)  即将原来的数字加上0.5 在向下取整   

                  Math.round(11.5)=12                    Math.round(-11.5)=-11




0 0
原创粉丝点击