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年9月.
Number.isSafeInteger() は静的メソッドで、指定された値が安全な整数であるかどうかを判定します。
安全な整数かどうかをテストする値です。
論理値で、与えられた数値が安全な整数である数値であれば true を返します。そうでなければ false です。
安全な整数とは、 -(253 - 1) から 253 - 1 までのすべての整数であり、両端を含みます (±9,007,199,254,740,991)。安全な整数は次のようなものです。
例えば、253 - 1 は安全な整数です。正確に表現することができ、他の整数は、どの IEEE-754 丸めモードの下で丸めたものにもなっていません。対照的に、253 は安全な整数ではありません。これは IEEE-754 で正確に表現できますが、整数値 253 + 1 は直接 IEEE-754 では表現できず、四捨五入や切り捨ての丸めによって 253 になるからです。
完全な精度で ~9 千兆より大きい値や小さい値を扱うには、任意精度演算ライブラリーを使用する必要があります。数値の浮動小数点表現の詳細については、 What Every Programmer Needs to Know about Floating Point Arithmetic を参照してください。s
巨大な整数値については、 BigInt 型を使用することを検討してください。
| ECMAScript® 2027 Language Specification # sec-number.issafeinteger |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年8月26日 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.