Log Base 2 Calculator
Log base 2 of 8 is 3, because 2 x 2 x 2 = 8. This log base 2 calculator finds the binary logarithm of any positive number, the exponent you raise 2 to in order to get your value. It also shows log base 10 and the natural log for comparison, and flags exact powers of two, the numbers computer science cares about most.
Quick answer
Log base 2 of a number asks, 2 raised to what power gives this number?
Log base 2
3
Log base 10
0.90309
Natural log (ln)
2.079442
Exact power of two
Yes
What this tells you
- •Log base 2 of a number asks, 2 raised to what power gives this number?
- •For exact powers of two the answer is a whole number. Log2 of 1024 is exactly 10.
- •For everything else it is a decimal. Log2 of 10 is about 3.32.
- •Binary logs show up anywhere things double or halve, like binary search steps, bits of information, and memory sizes.
How to Use
- 1Enter any positive number.
- 2Read the base-2 logarithm as the main result.
- 3Compare against log base 10 and the natural log below it.
- 4A note tells you when your input is an exact power of two.
How It Works
Formula
log2(x) = ln(x) / ln(2)Any logarithm can be computed from another base by division, and the natural log is the usual bridge. Log2 of 10 is ln(10) / ln(2), which is 2.3026 / 0.6931, about 3.3219. The result is the power of 2 that produces your number, so 2 raised to 3.3219 is 10.
Calculation note: values are processed in the order shown above, using the current input units.
Worked Examples
Log base 2 of 8
2 to the power 3 is 8, so the binary log is exactly 3.
Log base 2 of 1,000,000
A binary search over a million sorted items needs at most 20 comparisons.
Log base 2 of 0.5
One half is 2 to the power -1, so logs of values below 1 are negative.
Log Base 2 of Common Values
Binary logarithms for values you meet in computing and math.
| x | log2(x) |
|---|---|
| 1 | 0 |
| 2 | 1 |
| 8 | 3 |
| 10 | 3.3219 |
| 100 | 6.6439 |
| 256 | 8 |
| 1024 | 10 |
| 1048576 | 20 |
Common mistakes
- Taking the log of zero or a negative number. The logarithm is only defined for positive values.
- Mixing up log2 and log10 on a calculator. Most calculators' log key is base 10, so log(8) shows 0.903, not 3.
- Rounding too early in change-of-base division. Keep full precision in ln(x) and ln(2) until the final answer.