執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
前往 Spaces
<!DOCTYPE html> <html> <body> <h2>JavaScript Number Methods</h2> <p>The toPrecision() method returns a string, with a number written with a specified length:</p> <p id="demo"></p> <script> let x = 9.656; document.getElementById("demo").innerHTML = x.toPrecision() + "<br>" + x.toPrecision(2) + "<br>" + x.toPrecision(4) + "<br>" + x.toPrecision(6); </script> </body> </html>