Logarithms: the one formula behind pH, decibels and bits
A logarithm answers one question: "what power do I have to raise this base to, to get this number?" log_b(x) is the exponent that turns b into x. Once you can answer that, the formula behind pH, decibels and how many bits a computer needs are all the same calculation wearing different units.
The method
Two facts do all the work:
- Natural log uses base e (about 2.71828) and is written
ln(x). - Any other base comes from the change-of-base rule:
log_b(x) = ln(x) ÷ ln(b). A calculator — or this tool — only needs to know natural log to compute a logarithm in any base at all.
For example, log₁₀(1000) = 3, because 10 raised to the 3rd power is 1000 — the whole calculation is just working that exponent backwards from an answer you already have.
Logarithms are only defined for positive x, and the base has to be positive and not equal to 1 — both restrictions come straight from what "a power that produces x" would even mean otherwise.
A real example: pH
pH is defined as −log₁₀([H⁺]), where [H⁺] is the hydrogen-ion concentration in moles per liter, and the everyday scale runs roughly 0 to 14. A solution with [H⁺] = 0.00001 mol/L (that is, 1×10 to the −5):
log₁₀(0.00001) = −5, so pH = −(−5) = 5.
Every whole step in pH is a 10× change in hydrogen-ion concentration — pH 4 is ten times more acidic than pH 5, not twice as much — because the scale is logarithmic, not linear.
A second example: decibels
Decibels compare a power ratio the same way: dB = 10 × log₁₀(P ÷ P₀), where P₀ is a reference power. If a speaker outputs 100 times more power than the reference:
log₁₀(100) = 2, so dB = 10 × 2 = 20.
A 20 dB gain sounds like a lot more than "100 times", and that gap between the multiplier and the label is the entire reason decibels exist — sound power spans such an enormous range that a linear scale would need numbers with a dozen digits to describe both a whisper and a jet engine.
A base you'll actually use: base 2
Computing doesn't use base 10 or base e; it counts in bits, each one either 0 or 1. The question "how many bits do I need to represent 256 distinct values" is exactly log₂(256).
The tool's own natural logs are ln(256) = 5.545177 and ln(2) = 0.693147, and log₂(256) = ln(256) ÷ ln(2) = 8 exactly, because 2⁸ = 256 — 256 is one of the 2-power table's own entries, so the change-of-base division comes out perfectly round.
Why the natural log is the one constant
Every one of those three examples used a different base — 10 for pH and decibels, 2 for bits — but every one of them was computed the exact same way: divide two natural logs. That's the whole reason ln shows up as its own button on a calculator instead of just base 10: it's the one logarithm every other base can be built from, and it's why the tool only ever needs one internal formula to answer all three questions.