Skip to content

LOG

Returns the logarithm of a number to a base you choose. With no base it uses 10, so LOG(1000) is 3.

Syntax

=LOG(, )

Math and trigonometry

All versions of Excel.

Try it

Edit the formula in B2 or change the inputs. The sheet recalculates as you type.

B2
A
B
C
1
Number
LOG
2
1000
3
3

B2 =LOG(A2) returns 3

How LOG works

LOG answers the question "what power do I raise the base to in order to get this number?". =LOG(1000) is 3, because 10 to the power 3 is 1,000. =LOG(8, 2) is 3, because 2 to the power 3 is 8.

The base

With one argument LOG uses base 10, the common logarithm. The second argument changes the base: 2 for binary and doubling problems, 1.05 for 5% growth per period, or any other positive number except 1. For base e, use LN or =LOG(x, EXP(1)). A dedicated LOG10 function exists too, and is the same as LOG with one argument.

How many digits does a number have?

For a positive whole number, =INT(LOG(B2))+1 returns the count of digits. LOG10 of 98,765 is 4.99, INT gives 4, and adding 1 gives 5. Use =LEN(B2) if you are happy to treat the number as text.

How many periods does it take?

LOG with a growth factor as the base returns the number of periods. How many years for 2,000 to grow to 5,000 at 6% a year? =LOG(5000/2000, 1.06) is about 15.7, so the target is reached during year 16. Wrap it in ROUNDUP when you need whole periods. Also useful: the number of doublings needed to grow by a factor, =LOG(factor, 2).

Orders of magnitude

Logarithms compress large ranges. =LOG(B2) turns 10, 1,000 and 100,000 into 1, 3 and 5, so values that differ by orders of magnitude can share one chart axis. In practice, set the chart axis to a logarithmic scale and keep the original numbers.

LOG compared with LN

  • LOG(x, base) works with any base. LN is always base e.
  • =LN(x)/LN(base) is the same as =LOG(x, base), which is how you do it in other tools.
  • To undo a LOG, raise the base to the result: =10^LOG(x) or =POWER(base, LOG(x, base)) returns x.

Errors

The number must be positive, and the base must be positive and not 1. Zero, negatives and a base of 1 return #NUM! or #DIV/0!. Text returns #VALUE!.

Arguments

number
A positive number, such as B2. Zero or a negative number returns #NUM!.
baseoptional
The base of the logarithm, such as 2 or 1.05. If you leave it out, it is 10. It must be positive and not 1.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Base 10 by default

B2 =LOG(A2)

Result: 3

10 x 10 x 10 is 1,000, so the base-10 logarithm is 3.

B2
A
B
C
1
Number
LOG
2
1000
3
3

B2 =LOG(A2) returns 3

Example 2

A different base

C2 =LOG(A2,B2)

Result: 3

2 x 2 x 2 is 8, so it takes 3 doublings to reach 8.

C2
A
B
C
1
Number
Base
LOG
2
8
2
3
3

C2 =LOG(A2,B2) returns 3

Example 3

Logarithm of a fraction

B2 =LOG(A2)

Result: -2

A number below 1 has a negative logarithm. 10 to the power -2 is 0.01.

B2
A
B
C
1
Number
LOG
2
0.01
-2
3

B2 =LOG(A2) returns -2

Example 4

Count the digits in a whole number

B2 =INT(LOG(A2))+1

Result: 5

LOG(98765) is about 4.99. INT keeps 4, and adding 1 gives the 5 digits.

B2
A
B
C
1
Number
Digits
2
98765
5
3

B2 =INT(LOG(A2))+1 returns 5

Example 5

Whole years to reach a target

D2 =ROUNDUP(LOG(B2/A2,1+C2),0)

Result: 16

LOG(2.5, 1.06) is about 15.7, so the target is passed during the 16th year.

D2
A
B
C
D
1
Start
Target
Rate
Whole years
2
2000
5000
6%
16
3

D2 =ROUNDUP(LOG(B2/A2,1+C2),0) returns 16

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In B2, return how many digits the whole number in A2 has, using a logarithm. Fill it down to B6.

Answer in B2, then it fills down to B6.

B2
A
B
C
D
E
1
Invoice no.
Digits
Start
2000
2
5
Target
5000
3
120
Rate
6%
4
98765
Whole years
5
7
6
1500
7

Common mistakes

  • LOG with one argument is base 10, not base e. LOG(100) is 2. For the natural logarithm, use LN.
  • A number of zero or below returns #NUM!. A base of 1 also fails, since no power of 1 changes the number.
  • For a growth problem, the base is 1+rate, not the rate. LOG(2.5, 0.06) gives a negative number.
  • The result of LOG is rarely a whole number. Use ROUNDUP when you need complete periods, and INT when you want digit counts.
  • The digit-count formula is for positive whole numbers. For 0, decimals and negatives, use LEN or ABS first.

Questions people ask

What does LOG do in Excel?

It returns the power you raise a base to in order to get a number. LOG(1000) is 3 and LOG(8, 2) is 3. With no base it uses 10.

What is the difference between LOG and LN?

LN is always base e, about 2.718. LOG defaults to base 10 and accepts any base as its second argument.

How do I calculate a logarithm to another base?

Use the second argument: `=LOG(8, 2)`. The same result is `=LN(8)/LN(2)`.

How do I work out how many periods it takes to reach a target?

Use `=LOG(target/start, 1+rate)`, wrapped in ROUNDUP for whole periods. From 2,000 to 5,000 at 6% gives about 15.7.

Why does LOG return #NUM!?

The number is zero or negative, or the base is negative. Logs are defined only for positive numbers. A base of 1 also fails.

Learn LOG in a real sheet.

Tracks take you from the basics to modelling, one graded exercise at a time.