Compute the logarithm of any positive value in any positive base (except 1). Three presets cover the most common cases: log base 10, natural log (base e), and log base 2. Any other base you type is handled by change-of-base under the hood.
What this tool does
Two inputs: a value (x) and a base (b). The result is log_b(x) — the exponent you’d need to raise b to in order to get x. Below the result, the tool shows a verification row computing b raised to that result, which should return the original value (modulo floating-point precision). That’s a useful sanity check when you’re not sure you got the question right.
The three preset buttons jump the base to a common value:
- log₁₀ — base 10, the common logarithm used in chemistry, acoustics, seismology, and scientific notation
- ln — base e ≈ 2.71828, the natural logarithm used in calculus and exponential growth / decay
- log₂ — base 2, the binary logarithm used in computer science, information theory, and anything involving binary trees or halving
You can also just type the base manually — 3, 7, 0.5, or any other positive number ≠ 1.
Example: pH of a solution
pH is defined as −log₁₀ of the hydrogen ion concentration in mol/L. If a solution has [H⁺] = 0.001 mol/L, paste 0.001 with base 10 to get log₁₀(0.001) = −3. Negate that: pH = 3 (an acidic solution). If the concentration is 10⁻⁷ (neutral water), you’d get log₁₀(0.0000001) = −7, so pH = 7 as expected.
The negation step is conventional in chemistry — pH is always the negative log of the concentration so the numbers come out as small positive values instead of large negatives. This tool gives you the raw logarithm; you flip the sign yourself.
Example: bit width of an integer
You need to know how many bits it takes to represent a number in binary. The answer is ⌈log₂(n+1)⌉ — the base-2 logarithm, rounded up. For n = 1000, paste 1001 with base 2 (presets: log₂) to get about 9.967; round up to 10 bits. Check: 2¹⁰ = 1024, which is indeed just enough to cover 1000 — verifiable in one step with the exponent calculator.
More generally: log₂(n) tells you how many times you can halve n before you reach 1. It’s the classic measure of algorithmic depth for binary search, heaps, and balanced trees.
Example: decibels
dB = 10 × log₁₀(P/P₀), where P is the measured power and P₀ is a reference power. For a signal that’s 100× stronger than the reference, paste 100 with base 10 to get log₁₀(100) = 2, multiply by 10 → 20 dB. For 1000× → 30 dB. Every 10 dB is one order of magnitude, which is why the log scale is useful for quantities that span huge ranges.
Change of base
For any base that isn’t 10, e, or 2, the tool uses the identity log_b(x) = ln(x) / ln(b). This lets you compute a logarithm in a base your calculator doesn’t have a dedicated button for — log₃(27) = ln(27) / ln(3) ≈ 3.0, log₇(49) = ln(49) / ln(7) = 2, and so on. The tool does this automatically when the base you type isn’t one of the presets.
The presets use the browser’s dedicated Math.log10 / Math.log / Math.log2 functions, which are very slightly more accurate than the change-of-base formula because they skip the division. For everyday values the difference is invisible — the change-of-base result matches to 15+ decimal places.
What this tool does not do
It doesn’t handle complex numbers. Log of a negative number is a valid complex value, but the tool throws a domain error rather than returning a complex result. For that, you need a computer algebra system like WolframAlpha or SymPy.
It doesn’t show a step-by-step derivation for arbitrary bases beyond the verification row. It computes the answer and shows a check, which covers the “did I get the right answer?” question but not the “can you explain why?” question. For worked-example tutorials, a maths textbook or Khan Academy will be more useful.
It doesn’t do antilog (the inverse, b^y given y). Use the exponent calculator for that — it goes the other direction on the same relationship.
It doesn’t handle logarithms of zero or negative values. These are mathematically undefined over the real numbers, so the tool surfaces a domain error instead of silently returning NaN or negative infinity.