Log Base 2 Calculator
The binary logarithm — how many doublings a number represents, and the unit behind bits, octaves and algorithmic complexity.
log₂ x answers "2 to what power gives x?".
How the log base 2 calculator works
log₂ x answers "2 to what power gives x?". It is computed as ln x ÷ ln 2, since JavaScript's Math.log is natural.
It is the natural scale for anything that doubles: bits of information, octaves in music, levels in a binary tree, and the running time of a binary search on n items.
Formula: log₂ x = ln x / ln 2
Worked examples
| Inputs | log₂ x | Note |
|---|---|---|
| 1024 | 10 | exactly 10 |
| 1,000,000 | 19.93156857 | 19.93 — a million is just under 2²⁰ |
| 3 | 1.5849625 | 1.585 |
FAQFrequently asked questions
What is log base 2 used for?
Anything that doubles: bits of information, octaves, binary tree depth, and the O(log n) running time of divide-and-conquer algorithms.
How many bits store a number?
⌈log₂(n+1)⌉. A million needs 20 bits.
Why is a million about 2²⁰?
Because 2¹⁰ = 1,024 ≈ 1,000, so 2²⁰ ≈ 1,048,576. That approximation is why a "megabyte" has two different meanings.
Can I take log₂ of a negative number?
Not in the reals. Logarithms of negatives are complex.
What is log₂ of 3?
1.585 — 3 sits between 2 and 4, closer to the upper end than a linear reading suggests.
Where these figures come from
- NIST Digital Library of Mathematical Functions — reference definitions for elementary and special functions
- Wolfram MathWorld — definitions and formulas for every topic on this page
- NIST/SEMATECH e-Handbook of Statistical Methods — the statistical formulas (mean, variance, z, confidence intervals, sample size)
- Australian Curriculum (ACARA) — Mathematics — the terms and methods taught in Australian schools
Last checked: September 2026. Formulas are fixed by mathematics and do not change with tax years or regulations.