File size: 894 Bytes
08aee07
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Math对象</title>
	</head>
	<body>
		<script>
			/*
			5. Math:数学对象
				1. 创建:
					* 特点:Math对象不用创建,直接使用。  Math.方法名();
			
				2. 方法:
					random():返回 0 ~ 1 之间的随机数。 含0不含1
					ceil(x):对数进行上舍入。
					floor(x):对数进行下舍入。
					round(x):把数四舍五入为最接近的整数。
				3. 属性:
					PI
			*/
			
			document.write(Math.PI + "<br/>");
			document.write(Math.random() + "<br/>");
			document.write(Math.round(3.14) + "<br/>");
			
			document.write(Math.ceil(3.14) + "<br/>");
			document.write(Math.floor(3.14) + "<br/>");
			
			/**
			 *	取 1~100 之间的随机整数
			 */
			var ret = Math.floor(Math.random() * 100) + 1;
			document.write(ret + "<br/>");
			
		</script>
	</body>
</html>