js_ Math 方法

<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>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章