码迷,mamicode.com
首页 > 编程语言 > 详细

JavaScript中的Math方法演示

时间:2017-05-07 14:01:12      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:alert   class   ext   方法   2.4   随机   rand   随机数   code   




<html>
<head>
<script type="text/javascript">


var  num = 12.4;

alert(Math.round(num));//12

alert(Math.ceil(num));//13

alert(Math.floor(num));//12

alert(Math.random()*10);//产生随机数

alert(parseInt(Math.random()*10));//产生0到9以内的整数


</script>

</head>
<body>
  this is my file 
</body>
</html>




JavaScript中的Math方法演示

标签:alert   class   ext   方法   2.4   随机   rand   随机数   code   

原文地址:http://www.cnblogs.com/cynchanpin/p/6820456.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!