Math
来源:互联网 发布:网络鲜花销售 编辑:程序博客网 时间:2024/05/17 15:36
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
- Math
- math
- Math
- Math
- Math
- Math
- math
- Math
- math
- Math
- Math
- Math
- Math
- Math
- Math
- Math
- Math
- Math
- 宜信笔试题 把m升水倒入n个杯子
- nrf51822 --- 特征值添加描述
- 创建二维码
- 第五周上机实践项目2(2):游戏中的角色类
- 转载知乎一篇关于大数据生态技术的文章
- Math
- bzoj 1060(贪心+树形DP)
- 第四周项目5--用递归方法求解(3)
- Android OkHttp完全解析
- 【Raspberry Pi系列】2. 多种传输方式的比较
- Poj 1742 Coins【多重背包】
- java web 前端学习。
- Flume-ng 1.6.0安装、配置与使用
- 查看Hadoop源代码