-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path36.html
23 lines (22 loc) · 779 Bytes
/
36.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<html lang="en">
<head>
<title>JS Tutorials 205</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>JavaScript Numbers</h1>
<p>Floating point arithmetic is not always 100% accurate:</p>
<p id="target1"></p>
<p>But it helps to multiply and divide:</p>
<p id="target2"></p>
</body>
<script>
let x = 0.2 + 0.1;
let y = (0.2 * 10 + 0.1 * 10) / 10;
document.getElementById("target1").innerHTML = "0.2 + 0.1 = " + x;
document.getElementById("target2").innerHTML = "0.2 + 0.1 = " + y;
</script>
</html>