新闻动态
新闻动态
- vs中无法启动IIS Express Web服务器的解决办法
- 中文分词 一篇关于中文分词算法的SEO必看文章
- Vue中 Vue.prototype使用详解
- 什么是块级元素和内联级元素
- 网页的标题、关键字、描述标签内容应该怎么写?
- IEnumerable与IQueryable区别
- 经验分享:策划团队八个应该与六项原则
- 10大SEO必备技巧
- overflow:hidden属性
- 用Excel打开CSV文件出现乱码
联系我们
邮箱:
手机:15383239821
前端设计
js笔记之Math random()、ceil()、floor()、round()
作者:
发布时间:2013-06-08
点击:
JavaScript: The Definitive Guide, 4th Edition中对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));

新闻资讯
-
2010-09-29CSS之入门篇——推荐新手
-
2023-09-21php中die是啥
-
2023-11-20MySQL Dump
-
2019-12-05绩效考核的原则
-
2022-02-11substr函数
相关案例
