Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
toPrecision() は Number 値のメソッドで、この数値を指定された有効桁数で表す文字列を返します。
有効数字の数を指定する整数です。
指定された数値を、指定された有効桁数で表します。指数が precision 以上または -6 未満の場合、科学記数法が使用されます。precision 引数が省略された場合、Number.prototype.toString() と同じ動作をします。
precision が 1 以上 100 以下の範囲にない場合に発生します。
TypeErrorこれのメソッドが Number ではないオブジェクトに対して呼び出した場合、例外が発生します。
| ECMAScript® 2027 Language Specification # sec-number.prototype.toprecision |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年8月28日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.