Math
Log Base 2 Calculator
Find log₂(x): the power you raise 2 to in order to get x.
Powers of 2 such as 32 give an exact whole-number answer (log₂ 32 = 5); other values get a precise decimal plus the number of bits and doublings that answer represents.
Any positive number. Try 1024, 0.25, or 1000.
Try an example
Result
log₂(x)
—
- Exact form
- —
- Bits to store integers 0 to x - 1
- —
- Doublings from 1 to x
- —
- ln(x)
- —
- log₁₀(x)
- —
Student quick launch
Grade planning, algebra checks, and formulas students reach for most.
Study path
Use this calculator with
Follow these when you want the formula behind the answer, a short lesson, or nearby tools in the same topic.
What log base 2 means
The binary The exponent you would need to raise a base to in order to get a number. log₂(x) answers the question: 2 to what power equals x? Since 2^5 = 32, log₂(32) = 5. It is the natural logarithm of computing: every extra bit doubles the number of values you can represent, and every halving of a search space is one step of binary search.
Powers of 2 reference
| x | log₂(x) | Meaning |
|---|---|---|
| 1 | 0 | 2^0 = 1 |
| 2 | 1 | one doubling |
| 8 | 3 | 3 bits hold 0–7 |
| 256 | 8 | one byte holds 0–255 |
| 1,024 | 10 | a kibi (2^10) |
| 1,048,576 | 20 | a mebi (2^20) |
| 0.5 | -1 | one halving |
| 10 | 3.3219 | not a power of 2 |
Where log base 2 shows up
- Binary search on N sorted items needs about log₂(N) comparisons.
- Information theory: a fair coin flip carries log₂(2) = 1 bit; a fair die carries log₂(6) ≈ 2.585 bits.
- Music: an octave is a doubling of frequency, so log₂(f₂/f₁) counts octaves.
- Doubling time problems: the number of doublings from a to b is log₂(b/a).
How to use it
- Enter a positive number x.
- If x is a power of 2 (or a power of 2 raised to a fraction, like √2), the exact The small raised number saying how many times to multiply the base by itself. is shown.
- Otherwise read the decimal value and the change-of-base steps.
- Use the bits line for computer-science questions: an n-bit field holds 2^n values.
How to read the answer
log₂(x) counts how many times you double 1 to reach x. Whole-number answers mean x is a power of 2. Values between 0 and 1 give negative answers because they need halvings, not doublings.
Common mistakes and edge cases
- log₂(0) and log₂ of negatives are undefined.
- log₂(x) is not x / 2; it is an exponent, not a division.
- The number of bits to store x itself is floor(log₂ x) + 1, while log₂ x bits store the values 0 through x - 1.
- Calculator buttons labelled log are The number being raised to a power, or the side a shape's height is measured from. 10; divide by log(2) to convert.
Worked examples
Power of 2
log₂(32)
log₂(x)
5
Not a power of 2
log₂(10)
log₂(x)
3.32192809
Fraction
log₂(0.25)
log₂(x)
-2
One byte
log₂(256)
log₂(x)
8
Large power of 2
log₂(1024) = 10, a kibi
log₂(x)
10
Large decimal
log₂(1,000,000)
log₂(x)
19.93156857
log₂(1)
Any base to the power 0 is 1
log₂(x)
0
Undefined
log₂(0) has no answer
log₂(x)
Error
Frequently asked questions
What is log base 2 of 32?+
5, because 2^5 = 32.
How do I calculate log base 2 on a normal calculator?+
Use change of base: press log of your number, then divide by log(2) ≈ 0.30103. Or use ln and divide by ln(2) ≈ 0.6931.
How many bits do I need for a number N?+
To store the values 0 through N - 1 you need ceil(log₂ N) bits. To store N itself you need floor(log₂ N) + 1 bits. For N = 1000, that is 10 bits either way.
Why is log₂ of a fraction negative?+
Because 2 to a negative power is a fraction: 2^-2 = 1/4, so log₂(0.25) = -2. Numbers between 0 and 1 need halvings instead of doublings.
Is log₂(x) the same as ln(x)?+
No. ln uses base e ≈ 2.718. They differ by a constant factor: log₂(x) = ln(x) / ln(2) ≈ 1.4427 × ln(x).
How is log₂ used in binary search?+
Each comparison halves the remaining list, so a list of N items is searched in about log₂(N) steps: about 20 comparisons for a million items.
About this calculator
- Written by
- mathcheck editorial team
- Last reviewed
- September 4, 2026
Method
- Uses the values entered by the user and stable formulas documented on the page.
Related calculators
Logarithm Calculator
Calculate logarithms in any valid base with common log, natural log, and change-of-base steps.
Natural Log Calculator
Calculate the natural logarithm ln(x) or its inverse e^x, with exact answers for powers of e, the matching log₁₀ and log₂ values, series terms, and step-by-step work.
Change of Base Formula Calculator
Evaluate log_b(x) in any base with the change of base formula, showing both the ln and log₁₀ routes, exact answers when x is a power of b, and every step.
Antilog Calculator
Calculate the antilogarithm b^y for base 10, 2, e, or any custom base, with exact answers for whole-number exponents, scientific notation, and the inverse log check.
Exponent Calculator
Calculate powers with positive, negative, and decimal exponents while showing the exponent rule used.
Base Converter
Convert any number between any two bases from 2 to 36 with the steps shown: place-value expansion to decimal, repeated division into the target base, and fraction handling with repeat detection.
Last updated: September 4, 2026