js笔记之Math random()、ceil()、floor()、round()
来源:互联网 发布:淘宝店铺营销推广内容 编辑:程序博客网 时间:2024/05/17 05:03
本文转自:http://blog.sina.com.cn/s/blog_7e4815650100wrfz.html
JavaScript: The Definitive Guide, 4thEdition中对Math.ceil(),Math.floor()与Math.round()三个函数的定义。
Math.random()
返回 0 ~ 1 之间的随机数。
Math.ceil()
ceil() 方法可对一个数进行上舍入。
参数必须是一个数值。返回值大于等于 x,并且与它最接近的整数。
Math.floor()
floor() 方法可对一个数进行下舍入。
参数可以是任意数值或表达式。返回值小于等于 x,且与 x 最接近的整数。
Math.round()
round() 方法可把一个数字舍入为最接近的整数
参数必须是一个数值。返回值与 x 最接近的整数。
document.writeln("Math.ceil(4.8992303)输出结果:"+Math.ceil(4.8992303)+"<br/>");document.writeln("Math.floor(4.8992303)输出结果:"+Math.floor(4.8992303)+"<br/>");document.writeln("Math.round(4.8992303)输出结果:"+Math.round(4.8992303)+"<br/><br/>");document.writeln("Math.ceil(4.29993354)输出结果:"+Math.ceil(4.29993354)+"<br/>");document.writeln("Math.floor(4.29993354)输出结果:"+Math.floor(4.29993354)+"<br/>");document.writeln("Math.round(4.29993354)输出结果:"+Math.round(4.29993354));
0 0
- js笔记之Math random()、ceil()、floor()、round()
- js笔记之Math random()、ceil()、floor()、round()
- JS 笔记之Math random()、ceil()、floor()、round()
- js笔记之Math random()、ceil()、floor()、round()
- js笔记之Math random()、ceil()、floor()、round()
- js笔记之Math random()、ceil()、floor()、round()
- js中Math之random,round,ceil,floor的用法
- JS:Math.random(),Math.ceil(),Math.floor()与Math.round()
- js函数Math random()、ceil()、floor()、round() 比较
- JS中Math之random,round,ceil,floor的用法总结
- Math ceil()、floor()、round()、random()使用
- Math.random()、Math.ceil()、Math.floor()、Math.round()
- javascript Math.random(),Math.floor(),Math.ceil(),Math.round()
- math.random()、math.floor()、math.round()、math.ceil()函数总结
- math.random()、math.floor()、math.round()、math.ceil()函数
- JS中的random()、floor()、ceil()、round()
- Math.round ceil floor
- js中的Math.ceil() 、Math.floor() 、Math.round() 的意思
- D层重构一《Sqlhelper》
- thinkphp文件上传与下载
- C++ rand,srand用法
- QT学习点滴记录(四)
- C++ explicit构造函数----禁止隐式格式转换
- js笔记之Math random()、ceil()、floor()、round()
- Explicit——谨慎定义隐式类型转换函数
- UNIX基本命令-目录及文件操作
- [cocos2d] 谁摸了我一下----触摸事件处理
- [cocos2d] 利用texture atlases生成动画
- [cocos2d] 调用动画方法
- Hibernate实体类对象生命周期的3种状态
- [cocos2d demo]新科娘收集水表
- [cocos2d]关于CCSprite的若干问题与误区