编辑下面的代码:【加编码】
<html> <body> <p id="demo">Click the button to display the formatted number.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var num = new Number(13.3714); var a = num.toPrecision(); var b = num.toPrecision(2); var c = num.toPrecision(3); var d = num.toPrecision(10); var n=a + "<br>" + b + "<br>" + c + "<br>" + d; var x = document.getElementById("demo"); x.innerHTML=n } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂