Logarithm to any base

Type base a and the number x. The logarithm asks what power of a returns x. 2 and 8 give 3. 10 and 100 give 2. 3 and 27 give 3.000000.

Base 1, base ≤ 0 or x ≤ 0 returns 0. That is the same zero as log_a(1) on a valid base. Check the input before you trust a zero.

Input data

Results

Enter data and click Calculate.

How it works

A logarithm to any base is log_a(x) = ln(x)/ln(a). The calculator calls ln(b)/ln(a) when a > 0, a ≠ 1 and b > 0. 2 and 8 give 3, because 2³ = 8. 10 and 100 give 2, because 10² = 100.

The fields are base a and the number x. 3 and 27 in a notebook give 3. Here ln(27)/ln(3) is 3.0000000000000004, so the result is 3.000000, not a bare 3.

When a = 1, a ≤ 0 or x ≤ 0, the implementation returns 0. log_a(1) on a valid base is also 0, because a⁰ = 1. Those two zeros look the same. A bad base does not get a separate label.

The common logarithm is on the neighbouring page and keeps base 10. The natural logarithm keeps e. Here you pick a yourself.

The header units switch does not multiply anything. 2 and 8 stay 3 whatever the label says.

2 and 8 give 3. 10 and 100 give 2. 3 and 27 give 3.000000. Base 1, a negative base or x ≤ 0 give 0.

Formula

log_a(x) = ln(x)/ln(a), when a > 0, a ≠ 1, x > 0; otherwise 0

How to use

  1. Type base a and x, for example 2 and 8.
  2. Click Calculate. The logarithm comes out 3.
  3. 10 and 100 give 2. 3 and 27 give 3.000000.
  4. Base 1, base ≤ 0 or x ≤ 0 show 0, the same as log_a(1).
  5. Common and natural logarithms live on the neighbouring cards.

2 and 8 give 3

log_a(x) = ln(x)/ln(a). 2 and 8 give 3. 10 and 100 give 2. A bad base or x ≤ 0 returns 0, like log_a(1).

logarithm
The exponent that raises a to x. 2 and 8 give 3.
base
Field a. It must be > 0 and ≠ 1. 10 and 100 give 2. a = 1 returns 0.
number
Field x. It must be > 0. 3 and 27 give 3.000000. x ≤ 0 returns 0.

Examples

Example 1

  • a = 2
  • x = 8

3

What is log₂(8)? 3. Two to the third is 8.

Example 2

  • a = 10
  • x = 100

2

What is log₁₀(100)? 2. Ten to the second is 100.

Example 3

  • a = 3
  • x = 27

3.000000

What is log₃(27)? 3.000000. machine float misses 3, the calculator keeps six decimals.

Related calculators

Common questions

What is log₂(8)?

3. 2³ = 8. The calculator divides ln(8) by ln(2).

What does logarithm to any base mean?

What power of a returns x. Formula ln(x)/ln(a).

What is log₁₀(100)?

2. 10² = 100. Here you type 10 yourself; you do not have to open the log₁₀ card.

What is log₃(27)?

3.000000. In a notebook, 3. Here 3.0000000000000004 and six decimal places.

What if the base is 1?

The calculator returns 0. ln(1) = 0, so the divide does not run. That is the same zero as log_a(1).

What if x is 0 or negative?

Again 0. A real logarithm needs x > 0. There is no separate message.

What if the base is negative or 0?

Again 0. The base must be positive and not 1.

How is this different from the common logarithm?

There a is always 10. Here you type a. 10 and 100 give the same 2.

Where is ln?

On the natural-logarithm card. Base e also works here if you type about 2.71828.

Does a comma in 2.0 work?

Yes. 2.0 and 2,0 with 8 both give 3.

Knowledge sources

The calculator computes the same formula as the definition below.

Page updated in 2026.