The LOG function returns the logarithm of a number in a specified base. It is the inverse of exponentiation and is useful for scaling, growth rates, and data transformation.
=LOG(number, [base])What does LOG do?
The LOG function calculates the logarithm of a positive number in any base you choose. A logarithm answers the question: to what power must the base be raised to produce this number? For example, LOG(100, 10) returns 2 because 10 squared is 100. If you omit the base, Excel assumes base 10.
Logarithms matter because they turn multiplication into addition and make exponential growth linear. In spreadsheets, they help you compare values that span orders of magnitude, compute compound growth rates, or convert between number systems. Office workers use them in finance, science, and data analysis without needing a scientific calculator.
Imagine you are analysing website traffic that grows exponentially. By taking the logarithm of monthly visitors, you can fit a straight trend line and forecast future growth more easily. The LOG function makes this transformation quick and repeatable across thousands of rows.
When to use LOG
- Calculating the pH of a solution from hydrogen ion concentration (base 10).
- Finding the doubling time of an investment or population using base 2.
- Converting between number bases, such as binary (base 2) or hexadecimal (base 16).
- Transforming skewed data for statistical analysis or charting.
- Computing the exponent needed to reach a target value in growth models.
- Measuring sound intensity in decibels or earthquake magnitude (base 10).
LOG syntax
=LOG(number, [base])| Argument | Required? | What to enter |
|---|---|---|
number | Required | The positive real number for which you want the logarithm. It must be greater than 0. Example: 100. |
base | Optional | The base of the logarithm. It must be a positive number not equal to 1. If omitted, Excel uses 10. Example: 2. |
What it returns: The logarithm of the given number in the specified base, as a numeric value.
LOG examples
1 Basic logarithm in base 10
This example shows the simplest use of LOG. The goal is to find the base-10 logarithm of 1000. The formula =LOG(B2) uses the default base of 10. Since 10 raised to the power 3 equals 1000, the formula returns 3.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Number | Value | |||
| 2 | 1000 | 1000 | 3 | ||
| 3 |
2 Logarithm with a custom base
Here you calculate the logarithm of 8 in base 2. The goal is to find how many times 2 must be multiplied by itself to get 8. The formula =LOG(B2, A2) uses the number in B2 and the base in A2. Because 2 cubed is 8, the result is 3.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Base | Number | |||
| 2 | 2 | 8 | 3 | ||
| 3 |
3 Calculating pH from hydrogen ion concentration
In chemistry, pH is the negative base-10 logarithm of hydrogen ion concentration. The goal is to compute pH for a sample with concentration 0.001. The formula =-LOG(B2) first calculates LOG(0.001) which is -3, then applies the negative sign to return 3. This matches the standard pH definition.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Sample | H+ Concentration (mol/L) | |||
| 2 | A | 0.001 | 3 | ||
| 3 |
4 Finding the exponent for compound growth
Suppose an investment grows from 1000 to 8000. You want to know how many doubling periods that represents. The goal is to compute the base-2 logarithm of the ratio 8000/1000 = 8. The formula =LOG(B2/A2, 2) divides the final value by the initial value and takes LOG base 2. Since 2^3 = 8, the result is 3, meaning the investment tripled in doublings.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Initial Value | Final Value | |||
| 2 | 1000 | 8000 | 3 | ||
| 3 |
5 Converting a number to binary length
In computing, the number of bits needed to represent a value n is floor(log2(n)) + 1. The goal is to find the bit length for the number 255. The formula =INT(LOG(B2, 2)) + 1 computes LOG base 2 of 255, which is approximately 7.994, takes the integer part (7), and adds 1 to get 8. This tells you that 255 requires 8 bits in binary.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Description | Value | |||
| 2 | Number | 255 | 8 | ||
| 3 |
Common LOG errors and how to fix them
| Error | Why it happens | How to fix it |
|---|---|---|
| #NUM! | The number argument is zero or negative, or the base is negative or equal to 1. | Ensure the number is greater than 0 and the base is a positive number not equal to 1. |
| #VALUE! | The number or base argument is non-numeric (e.g., text). | Check that both arguments are numbers or references to numeric cells. |
| #DIV/0! | The base is exactly 1, which would cause division by zero in the logarithm calculation. | Use a base other than 1; common bases are 10, 2, or e (using LN instead). |
| Wrong result (e.g., 1 instead of 10) | Forgetting that the default base is 10, not e or 2. | Always specify the base explicitly if you need something other than 10. |
Tips for using LOG
- Use
LOG(number, 10)or justLOG(number)for base-10 logarithms; useLN(number)for natural logarithms (base e). - To calculate logarithms in base 2, use
LOG(number, 2). - Remember that LOG(1) is always 0, regardless of the base.
- Combine LOG with INT or ROUND to get integer results for bit-length or digit-count calculations.
- When working with growth rates, LOG can linearise exponential trends for charting or regression.
Frequently asked questions
What is the difference between LOG and LN in Excel?
LOG lets you specify any base, while LN always uses base e (approximately 2.718). Use LN for natural logarithms and LOG for other bases.
Can I use LOG with a base less than 1?
No, the base must be a positive number not equal to 1. Bases less than 1 but greater than 0 are allowed, but they produce negative logarithms for numbers greater than 1.
Why does LOG return an error when I use a negative number?
Logarithms are only defined for positive numbers in real numbers. Excel returns #NUM! for zero or negative numbers.
How do I calculate the logarithm of a number in base 2?
Use =LOG(number, 2). For example, =LOG(8, 2) returns 3.
Related functions
Every example on this page was recalculated by SheetSkill’s spreadsheet engine. LOG reference