js Math

来源:互联网 发布:js查找节点的三种方法 编辑:程序博客网 时间:2024/05/16 09:27


<script type="text/javascript">
var v=10.4;
//向上舍入
document.write("ceil:"+Math.ceil(v));
document.write("<hr/>");
var v1=10.8
//向下舍入
document.write("floor"+Math.floor(v1));
document.write("<hr/>");
//四舍五入
document.write("round"+Math.round(v));
document.write("<hr/>");
document.write("round"+Math.round(v1));
//random()得到随机数
document.write("<hr/>");
document.write(Math.random());
//得到0-9之间的随机数
document.write("<hr/>");
document.write(Math.floor(Math.random()*10));

</script>
0 0
原创粉丝点击