您的位置:首页 > Web前端 > JavaScript

js_ Math 方法

2018-02-27 14:21 399 查看
<html>
<head>
<title>js</title>
</head>
<body>
<script>
document.write(Math.PI+'</br>'); //3.141592653589793
document.write(Math.min(1,4,2)+'</br>');// 最小数 1
document.write(Math.max(1,4,2)+'</br>'); // 最大数 4
document.write(Math.round(12.61)+'</br>'); //第一位小数四舍五入,和后面的小数没有关系 13
document.write(Math.ceil(12.11)+'</br>');//向上舍入 13
document.write(Math.floor(12.61)+'</br>'); // 向下舍入 12
document.write(Math.floor(Math.random()*100+1)+'</br>');//0~100之间的随机数
</script>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  js Math 方法