Skip to content
UniKit

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.

Common bases
Logarithm
10

Logarithmic form:log₂(1024) = 10

Exponential ⇄ logarithmic form

The same relation b^x = n written two ways, rounded to the current precision

Logarithmic log_b(n) = xlog_3(27) = 3
Exponential b^x = n3^3 = 27
Antilogarithm b^x27

Derive the antilogarithm from base and exponent to verify both forms

Common logarithm tableBases e, 10 and 2
nln nlog nlog₂ n
1000
20.693147180.301031
31.098612290.477121251.5849625
41.386294360.602059992
51.609437910.698972.32192809
102.3025850913.32192809
1004.6051701926.64385619
10006.9077552839.96578428
0.1-2.30258509-1-3.32192809
0.5-0.69314718-0.30103-1
e10.434294481.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指数式

Related tools