Math 常用的方法
来源:互联网 发布:淘宝网的购买流程 编辑:程序博客网 时间:2024/05/17 02:47
舍掉小数取整:Math.floor(2)=2
舍掉小数取整:Math.floor(2.1)=2
舍掉小数取整:Math.floor(-2.1)=-3
舍掉小数取整:Math.floor(-2.5)=-3
舍掉小数取整:Math.floor(-2.9)=-3
四舍五入取整:Math.rint(2)=2
四舍五入取整:Math.rint(2.1)=2
四舍五入取整:Math.rint(-2.5)=-2
四舍五入取整:Math.rint(2.5)=2
四舍五入取整:Math.rint(2.9)=3
四舍五入取整:Math.rint(-2.9)=-3
四舍五入取整:Math.rint(-2.49)=-2
四舍五入取整:Math.rint(-2.51)=-3
凑整:Math.ceil(2)=2
凑整:Math.ceil(2.1)=3
凑整:Math.ceil(2.5)=3
凑整:Math.ceil(2.9)=3
舍掉小数取整: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)=-2
凑整:Math.ceil(-2.5)=-2
凑整:Math.ceil(-2.9)=-2
Math.round(3.14)3
Math.round(3.5)4
Math.round(-3.14)-3
Math.round(-3.5)-3
总结:floor向下取整,ceil向上取整;round和rint四舍五入,取绝对值后舍入,然后加上符号,遇到.5的时候向绝对值小的方向舍之。
http://www.521000.com/forum.php?mod=viewthread&tid=4425228
http://www.521000.com/forum.php?mod=viewthread&tid=4425229
http://www.521000.com/forum.php?mod=viewthread&tid=4425230
http://www.521000.com/forum.php?mod=viewthread&tid=4425231
- Math 常用的方法
- Math类的常用方法
- Java的Math常用方法
- C# Math常用的方法
- js的Math常用方法
- Math类的常用方法
- Math中常用的方法
- Math类的常用方法
- Math类常用的方法
- math类的常用方法
- Math类的常用方法
- java.math.Math类常用的常量和方法
- java.math.Math类整理 常用的常量和方法
- ava.math.Math类常用的常量和方法:
- Java.math.Math类常用的常量和方法
- java.math.Math类常用的常量和方法
- js常用的Math对象的方法
- Math 类的几个常用方法
- VS2015配置32位boost库
- 触碰大师们的思想(二)之 策略模式
- 使用ueditor实现多图片上传案例——截取字符串层Util(SubString_text)
- 使用ueditor实现多图片上传案例——Servlet层(UploadServlet)
- 项目banner设计网站
- Math 常用的方法
- 使用ueditor实现多图片上传案例——前台数据层(Index.jsp)
- volatile关键字
- 删除ubuntu,安装CentOS 7(原先是windows 8.1、ubuntu双系统)
- GoldenDream-十月
- TV颜色空间—YUV,YIQ,YCbCr
- 我的“游戏职业”生涯03
- Seetaface 01 Seetaface win10 vs2015编译(cmake自动配置,可选mfc界面)
- 洛谷 P1119 灾后重建(Floyd)