W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>JavaScript 数字</h1> <p>浮点的算数并不总是 100% 精准:</p> <p id="demo1"></p> <p>但是乘法和除法是有用的:</p> <p id="demo2"></p> <script> var x = 0.2 + 0.1; document.getElementById("demo1").innerHTML = "0.2 + 0.1 = " + x; var y = (0.2*10 + 0.1*10) / 10; document.getElementById("demo2").innerHTML = "0.2 + 0.1 = " + y; </script> </body> </html>