Log Base 2 Calculator
Enter any positive number to get its base-2 logarithm — the power you must raise 2 to in order to reach it. Exact powers of 2 are flagged, and the change-of-base steps are shown.
Example: with Number (x) 32 → Log base 2: 5 (exact).
Computed by the calculator below using its default values. Change any input to see your own numbers.
π» Master binary math with a CS workbook
Check it outWhat log base 2 tells you
log₂(x) answers one question: 2 to what power equals x? Because 2⁵ = 32, log₂(32) = 5 exactly. The easy anchors: log₂(1) = 0, log₂(2) = 1, log₂(8) = 3, and log₂(1024) = 10. Between powers the answer is irrational — log₂(10) ≈ 3.321928, log₂(5) ≈ 2.321928, log₂(3) ≈ 1.584963, and log₂(1000) ≈ 9.965784.
Most calculators lack a log₂ button, so use change of base: log₂(x) = ln(x) ÷ ln(2), or log₁₀(x) ÷ 0.30103. Base-2 logs are everywhere in computing: n bits can represent 2ⁿ values, so you need ⌈log₂(N)⌉ bits to label N things, and a binary search of a million items takes about log₂(1,000,000) ≈ 20 comparisons. Halving times and doublings (Moore’s-law-style growth) are log₂ problems too.
How itβs calculated
The result is Math.log2(x), the base-2 logarithm, equivalent by the change-of-base rule to ln(x) ÷ ln(2) with ln(2) ≈ 0.693147. When x is an exact power of 2 (checked by re-raising 2 to the rounded result) the answer is shown as an exact integer; otherwise it is rounded to 6 decimal places. Logarithms are undefined for zero and negative numbers, so those inputs return no result.
Results update as you type and are estimates, not professional advice β verify important decisions with a qualified professional.
Common mistakes
- Trying to take log₂ of 0 or a negative number — the log is undefined there; log₂(x) is only negative (not impossible) for 0 < x < 1.
- Confusing log₂(x) with x² or with log₁₀(x) — log₂(100) ≈ 6.64, not 10 or 2.
- Using log₂(N) bits instead of the ceiling ⌈log₂(N)⌉ — 1,000 labels need 10 bits, because 2⁹ = 512 falls short.
Frequently asked questions
What is log base 2 of 10?
log₂(10) ≈ 3.321928, because 2³ = 8 falls short of 10 and 2⁴ = 16 overshoots. Handy corollary: every decimal digit carries about 3.32 bits of information.
What is log base 2 of 1?
Exactly 0, because 2⁰ = 1. Every logarithm, whatever its base, equals 0 at 1.
How do I calculate log base 2 on a regular calculator?
Use change of base: log₂(x) = ln(x) ÷ ln(2). For 32: ln(32) ≈ 3.465736, ln(2) ≈ 0.693147, and 3.465736 ÷ 0.693147 = 5.
Can log base 2 be negative?
Yes, for inputs between 0 and 1: log₂(0.5) = −1 and log₂(0.25) = −2, since 2⁻¹ = 0.5 and 2⁻² = 0.25.
What is log base 2 of 1000?
log₂(1000) ≈ 9.965784 — just under 10, because 2¹⁰ = 1024 is slightly more than 1000.