-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.html
105 lines (104 loc) · 3.62 KB
/
index.html
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>浮点数计算示例</title>
<style>
*{
padding:0;
margin:0;
}
ul,li{
list-style:none;
}
input[type=text]{
width:160px;
height:40px;
}
input[type=button]{
padding:0 10px;
height:40px;
}
#resultList{
font-size:16px;
line-height:24px;
}
#resultList li{
padding-top:10px;
}
#resultList b{
color:green;
}
.opearation-wrap{
width:400px;
margin:100px auto 0 auto;
}
</style>
</head>
<body>
<div class="opearation-wrap">
<input type="text" id="inputNum0">
<input type="text" id="inputNum1"><br /><br />
<input type="button" value="执行+" id="startOperation0">
<input type="button" value="执行-" id="startOperation1">
<input type="button" value="执行*" id="startOperation2">
<input type="button" value="执行/" id="startOperation3">
<input type="button" value="执行all" id="startOperation">
<ul id="resultList">
<li>加法原始计算值<i></i><br>优化后计算值<em></em></li>
<li>减法原始计算值<i></i><br>优化后计算值<em></em></li>
<li>乘法原始计算值<i></i><br>优化后计算值<em></em></li>
<li>除法原始计算值<i></i><br>优化后计算值<em></em></li>
</ul>
</div>
<script src="jsFloatCompute.js"></script>
<script>
var numInput0=document.getElementById("inputNum0"),
numInput1=document.getElementById("inputNum1"),
resultList=document.getElementById("resultList"),
showListOld=resultList.getElementsByTagName("i"),
showList=resultList.getElementsByTagName("em");
//执行加法
document.getElementById("startOperation0").onclick=function(){
var num0=numInput0.value,
num1=numInput1.value;
showListOld[0].innerHTML=Number(num0)+Number(num1);
showList[0].innerHTML=jsFloat.add(num0,num1);
}
//执行减法
document.getElementById("startOperation1").onclick=function(){
var num0=numInput0.value,
num1=numInput1.value;
showListOld[1].innerHTML=num0-num1;
showList[1].innerHTML=jsFloat.subtract(num0,num1);
}
//执行乘法
document.getElementById("startOperation2").onclick=function(){
var num0=numInput0.value,
num1=numInput1.value;
showListOld[2].innerHTML=num0*num1;
showList[2].innerHTML=jsFloat.ride(num0,num1);
}
//执行除法
document.getElementById("startOperation3").onclick=function(){
var num0=numInput0.value,
num1=numInput1.value;
showListOld[3].innerHTML=num0/num1;
showList[3].innerHTML=jsFloat.divide(num0,num1);
}
//一次执行所有计算
document.getElementById("startOperation").onclick=function(){
var num0=numInput0.value,
num1=numInput1.value;
showListOld[0].innerHTML=Number(num0)+Number(num1);
showListOld[1].innerHTML=num0-num1;
showListOld[2].innerHTML=num0*num1;
showListOld[3].innerHTML=num0/num1;
showList[0].innerHTML=jsFloat.add(num0,num1);
showList[1].innerHTML=jsFloat.subtract(num0,num1);
showList[2].innerHTML=jsFloat.ride(num0,num1);
showList[3].innerHTML=jsFloat.divide(num0,num1);
}
</script>
</body>
</html>