Math.ceil floor 函数例子
来源:互联网 发布:ubuntu on windows 10 编辑:程序博客网 时间:2024/06/05 09:17
Math.floor()、Math.ceil()、BigDecimal都是Java中的取整函数,但返回值却不一样!
floor :地板的意思;
ceil :天花板的意思;
Math.floor() 通过该函数计算后的返回值是舍去小数点后的数值
如:Math.floor(3.2)返回3
Math.floor(3.9)返回3Math.floor(3.0)返回3
Math.ceil() ceil函数只要小数点非0,将返回整数部分+1
如:Math.ceil(3.2)返回4Math.ceil(3.9)返回4
Math.ceil(3.0)返回3
BigDecimal四舍五入 传统的四舍五入,在Math类中并没有直接提供,必须使用Java.math.BigDecimal类来实现
new BigDecimal("2.0").setScale(0, BigDecimal.ROUND_HALF_UP)返回2new BigDecimal("2.4").setScale(0, BigDecimal.ROUND_HALF_UP)返回2
new BigDecimal("2.5").setScale(0, BigDecimal.ROUND_HALF_UP)返回3
阅读全文
1 0
- Math.ceil floor 函数例子
- math.random()、math.floor()、math.round()、math.ceil()函数总结
- math.random()、math.floor()、math.round()、math.ceil()函数
- math.floor、math.ceil
- Java Math floor round ceil 函数
- Math 的三个函数 round ceil floor
- Java Math floor round ceil 函数
- Math.ceil() 、Math.floor() 、Math.round() 三个函数的理解
- javascript中的Math.ceil() 、Math.floor() 、Math.round() 三个函数
- java math.ceil() floor()
- Math.round ceil floor
- javascript.Math.ceil/floor
- JS中的Math.ceil和Math.floor函数的用法
- python 内建函数range/math.ceil/math.floor
- JS中的Math.ceil和Math.floor函数的用法
- Math.ceil和Math.floor
- Javascript Math ceil()、floor()、round()三个函数的区别
- js Math.abs,ceil,floor,round,toFixed函数的使用
- 03.15 Linux必掌握的目录结构
- 百炼 1657:Distance on Chessboard
- React-Native踩过的那些坑
- switch case语句
- [日常Debug]Hive问题之org.apache.hadoop.security.AccessControlException
- Math.ceil floor 函数例子
- javascript字符串
- eclipse项目中.classpath文件详解
- ArcGIS中我国常用的坐标系统WKID列表
- Java语言基础——字符串String
- mysql复杂delete操作
- linux iptables防火墙使用模板
- 算法概论 课后习题 8.3 证明
- Xcode Simulators 下载以及安装技巧