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月.
Math.log2() は静的メソッドで、数値の 2 を底とした対数を返します。
∀x>0,𝙼𝚊𝚝𝚑.𝚕𝚘𝚐𝟸(𝚡)=log2(x)=the unique y such that 2y=x\forall x > 0,\;\mathtt{\operatorname{Math.log2}(x)} = \log_2(x) = \text{the unique } y \text{ such that } 2^y = x0 以上の数値です。
x の 2 を底とした対数です。 x < 0 であった場合、 NaN が返されます。
log2() は Math の静的メソッドであるため、生成した Math オブジェクトのメソッドとしてではなく、常に Math.log2() として使用するようにしてください (Math はコンストラクターではありません)。
この関数は Math.log(x) / Math.log(2) と同等です。 log2(e) には定数 Math.LOG2E を使用してください(これは 1 / Math.LN2 です)。
| ECMAScript® 2027 Language Specification # sec-math.log2 |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年10月2日 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.