JavaScript Math对象
来源:互联网 发布:手机数据流量改dns 编辑:程序博客网 时间:2024/06/05 15:08
1.向上取整(.ceil()):
<script type="text/javascript"> document.write(Math.ceil(0.8) + "<br />") document.write(Math.ceil(6.3) + "<br />") document.write(Math.ceil(5) + "<br />") document.write(Math.ceil(3.5) + "<br />") document.write(Math.ceil(-5.1) + "<br />") document.write(Math.ceil(-5.9))</script>
2.向下取整(.floor()):
<script type="text/javascript"> document.write(Math.floor(0.8)+ "<br>") document.write(Math.floor(6.3)+ "<br>") document.write(Math.floor(5)+ "<br>") document.write(Math.floor(3.5)+ "<br>") document.write(Math.floor(-5.1)+ "<br>") document.write(Math.floor(-5.9))</script>
3.四舍五入(.round()):
<span style="font-size:18px;"><script type="text/javascript"> document.write(Math.round(1.6)+ "<br>"); document.write(Math.round(2.5)+ "<br>"); document.write(Math.round(0.49)+ "<br>"); document.write(Math.round(-6.4)+ "<br>"); document.write(Math.round(-6.6));</script></span>
4.随机数(.random()):
<script type="text/javascript"> document.write(Math.random());//0-1之间</script>
0 0
- JavaScript中的Math对象
- javascript中的Math对象
- Javascript 内置对象 Math
- javascript Math 对象介绍
- Javascript之Math对象
- javascript Math对象
- JavaScript演示Math对象
- javascript Math对象
- JavaScript Math 对象
- JavaScript Math对象方法
- JavaScript Math 对象
- 4. JavaScript Math 对象
- javascript之Math对象
- JavaScript Math 对象总结
- JavaScript Math 对象
- javascript Math()对象
- JavaScript Math对象
- Javascript 内置对象 MATH
- mfc添加可停靠隐藏等功能的侧边栏
- Spring实战- Aop 使用注解引入新功能(六)
- Java中的Runnable、Callable、Future、FutureTask的区别
- JZOJ4848 永恒的契约
- 静态库制作使用示例
- JavaScript Math对象
- 强制将 SSH 的host key type由 ECDSA替换为RSA
- iOS 开发 XMPP即时通讯项目开发(仿微信)-详解之xmpp环境搭建(数据库/客户端/服务器)
- 1212
- Java 成员变量 局部变量 静态变量的比较
- Java加密技术
- zookeeper超时--minSessionTimeout与maxSessionTimeout
- 学校蓝桥杯选拔题分鱼
- ThinkPHP3.2 视图