Logarithm calculator
Compute logarithms in any base with the change-of-base formula, plus ln / log / log₂ shortcuts, exponential ⇄ logarithmic conversion, a common logarithm table and precision control.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
10
Logarithmic form:log₂(1024) = 10
The same relation b^x = n written two ways, rounded to the current precision
Derive the antilogarithm from base and exponent to verify both forms
| n | ln n | log n | log₂ n |
|---|---|---|---|
| 1 | 0 | 0 | 0 |
| 2 | 0.69314718 | 0.30103 | 1 |
| 3 | 1.09861229 | 0.47712125 | 1.5849625 |
| 4 | 1.38629436 | 0.60205999 | 2 |
| 5 | 1.60943791 | 0.69897 | 2.32192809 |
| 10 | 2.30258509 | 1 | 3.32192809 |
| 100 | 4.60517019 | 2 | 6.64385619 |
| 1000 | 6.90775528 | 3 | 9.96578428 |
| 0.1 | -2.30258509 | -1 | -3.32192809 |
| 0.5 | -0.69314718 | -0.30103 | -1 |
| e | 1 | 0.43429448 | 1.44269504 |
What this tool does
- Compute logarithms in any base: when the base is not e, 10 or 2 the change-of-base formula log_b(n) = ln n / ln b is applied for you.
- Sanity-check algorithm complexity: 1024 gives log₂ = 10, the number of comparisons a binary search needs over 1024 items.
- Practise converting between exponential and logarithmic form: base plus argument yields both log_b(n) = x and b^x = n, and base plus exponent recovers the argument to prove they are inverses.
- Read off a common logarithm table for 1, 2, 3, 4, 5, 10, 100, 1000, 0.1, 0.5 and e in ln, lg and log₂, with precision adjustable from 0 to 12 decimals.
Example
Input
Argument n = 1024, base b = 2
Output
log₂(1024) = 10 Exponential form: 2^10 = 1024
Bases e, 10 and 2 go straight to Math.log / log10 / log2, avoiding binary residue such as Math.log(1000) / Math.log(10) returning 2.9999999999999996.
Frequently asked questions
Why are there limits on the base and the argument?
A logarithm needs n > 0 and b > 0 with b ≠ 1. Zero, negative numbers, base 1 and non-numeric input all raise an error rather than silently returning -Infinity or NaN.
Will the result carry floating-point error?
For e, 10 and 2 the matching Math.log implementation is used and results are typically exact; other bases go through the change-of-base formula and pick up a little error. Display rounds to your chosen precision with a tiny correction term, so values like 2.9999999999999996 do not survive as such.
How precise can the output be?
Between 0 and 12 decimal places. JavaScript numbers are IEEE 754 doubles with roughly 15–17 significant digits, so digits beyond 12 would be fictional — hence the cap.
What does "result outside the representable range" mean?
When deriving the argument as b^x, a result above about 1.8e308 becomes Infinity and a result below the smallest subnormal becomes 0; the tool reports an error instead of printing Infinity. Use an arbitrary-precision calculator for such numbers.
Is the computation uploaded anywhere?
No. Everything is computed locally in your browser with JavaScript, no network requests are made, and it works offline.
Keywords:logarithm对数loglnlglog2换底公式change of baseexponential form指数式