Math.ceil() 、Math.floor() 、Math.round() 三个函数的理解
来源:互联网 发布:剑桥美国经济史知乎 编辑:程序博客网 时间:2024/05/09 15:06
首先还是看看JavaScript: The Definitive Guide, 4th Edition中对三个函数的定义。
Math.ceil(): round anumber up
Arguments: Any numeric value or expression
Returns: The closest integer greater than or equal tox.
-----------------------------------------------------------------------------------------------
Math.floor(): round a number down
Arguments: Any numeric value or expression
Returns: The closest integer less than or equal tox.
-----------------------------------------------------------------------------------------------
Math.round(): round to thenearest integer
Arguments: Any number.
Returns: The integer closest tox.
以前一直会三个函数的使用产生混淆,现在通过对三个函数的原型定义的理解,其实很容易记住三个函数。
现在做一个总结:
1. Math.ceil()用作向上取整。
2. Math.floor()用作向下取整。
3. Math.round() 我们数学中常用到的四舍五入取整。
转自:http://www.jb51.net/article/23276.htm
- Math.ceil() 、Math.floor() 、Math.round() 三个函数的理解
- Math 的三个函数 round ceil floor
- JavaScipt中的Math.ceil() 、Math.floor() 、Math.round() 三个函数的理解
- javascript中的Math.ceil() 、Math.floor() 、Math.round() 三个函数
- Javascript Math ceil()、floor()、round()三个函数的区别
- Javascript Math ceil()、floor()、round()三个函数的区别
- Javascript Math ceil()、floor()、round()三个函数的区别
- Javascript Math ceil()、floor()、round()三个函数的区别
- Javascript Math ceil().floor().round() 三个函数的区别
- Javascript Math ceil()、floor()、round()三个函数的区别
- Javascript Math ceil()、floor()、round()三个函数的区别
- Javascript Math ceil()、floor()、round()三个函数的区别
- Javascript Math ceil()、floor()、round()三个函数的区别
- Javascript Math ceil()、floor()、round()三个函数的区别
- Javascript Math ceil()、floor()、round()三个函数的区别
- Javascript Math ceil()、floor()、round()三个函数的区别
- math.random()、math.floor()、math.round()、math.ceil()函数总结
- math.random()、math.floor()、math.round()、math.ceil()函数
- C# 文件转字节数组 byte[]
- android-----XUtils框架之BitmapUtils源码分析
- 【Oracle】GoldenGate 12.2 OGG-01201 Error reported by MGR : Access denied.
- 广东海洋大学 电子1151 孔yanfei python语言程序设计 第六周
- 扛得住双11的Mysql---操作系统
- Math.ceil() 、Math.floor() 、Math.round() 三个函数的理解
- Mysql 存储过程 处理批量插入具有一定特点的数据
- 正则表达式详解
- ubuntu 14.04.4 install
- 翻译 SystemClock类
- 写在最初
- 电脑的无线图标没有了怎么办
- 广东海洋大学 电子1151 孔yanfei python语言程序设计 第七周
- ADB操作命令