<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<script type="text/javascript">
//圆周率
// alert(Math.PI);
//绝对值
// alert(Math.abs(-3.1546416588546));
//对数进行上舍入取整
// alert(Math.ceil(-1.802316164)); //此项结果为-1
//下舍入
//alert(Math.floor(10.8));//10
// alert(Math.floor(-10.8));//-11
//0-1之间的随机数
alert(Math.random());
//四舍五入
alert(Math.round(5.5));//6
alert(Math.round(-5.5));//-5
</script>
</body>
</html>
js数学
最新推荐文章于 2022-06-17 19:36:38 发布