A Logarithm is Just the Number of Digits

by Malte Skarupke

If you don’t have a good intuition for how logarithms work, (e.g. what does it mean that happiness scales with the log of income? Or why does an algorithm that runs in log(log(x)) steps always run in 5 steps or fewer?) here is how you can explain it to a third grader: It’s the number of digits (roughly). For example it’s the number of zeros in these:

log_{10}(100) = 2

log_{10}(1000) =3

log_{10}(0.01) = -2

log_{10}(0.001) = -3

For this to work out we have to transition through zero: log(1)=0

If it bothers you that I’m off by one, because clearly 100 has 3 digits, not 2, you can get the actual number of digits by rounding away from 0 to the next integer.

Where it gets complicated is when you have a number between two round numbers:

log_{10}(123) = ?

We can’t just count the number of digits. It’s got to be somewhere between the other two numbers, coming out to roughly 2.09. But lets not worry about those odd cases for now. Where this really helps is when trying to build an intuition for the logarithm rules:



This should now make sense to you. If we replace “log” with “number of digits” in that formula it’s


Here’s an example that makes it obvious that the number of digits after multiplication is the sum of the number of digits before multiplication:

100*1000 = 100000

log_{10}(100*1000) = log_{10}(100)+log_{10}(1000) = 2+3=5



Slightly harder to understand, but also comes out naturally with an example:

1000/100 = 10

log_{10}(1000/100) = log_{10}(1000) - log_{10}(100) = 3 - 2 = 1

Or the other way round:

100/1000 = 0.1

log_{10}(100/1000) = log_{10}(100)-log_{10}(1000) = 2-3 = -1

One way of looking at both of these is that multiplication is shifting digits to the left, division is shifting digits to the right. So if we just want the number of digits, we can count how many digits we’re shifting instead of doing a division/multiplication.


log_b(x^y) = y*log_b(x)

This says that if all we want is the number of digits of a power, we can save ourselves the exponentiation and instead multiply the number of digits of the input.

100^3 = 1,000,000

log_{10}(100^3) = 3*log_{10}(100) = 3 * 2 = 6

This one is less intuitive, but it makes sense that taking the power of something multiplies the number of digits. So x^6 will have twice as many digits as x^3:


log_{10}(1,000,000) = 2*log_{10}(1000)


log_b(\sqrt[y]{x}) = log_b(x)/y

This one is just a notational mess and looks super scary, but it’s the same as the previous example: If we just want the number of digits of a nth-root, we can save ourselves the root-taking and instead divide the number of digits of the input.

\sqrt[3]{1,000,000,000} = 1000

log_{10}(\sqrt[3]{1,000,000,000})=log_{10}(1,000,000,000)/3 = 9/3  = 3

Once again not intuitive, but it kinda makes sense that taking the root of something divides the number of digits. So \sqrt[6]{x} will have half as many digits as \sqrt[3]{x}. And \sqrt{x} will have half as many digits as x.

Change of Basis


This one is hardest to explain intuitively because it’s about different bases for the logs, so it’s talking about number of digits in different bases. It says that the number of digits can be calculated in any base, and can be changed from one base to another. And to change it you just multiply by a constant. So a number in base 2 will always have C times as many digits as the same number in base 10. The constant C in the formula is log_k(b) which does not depend on the input number x, only on the two bases. To go from base 2 to base 10 you multiply by 1/log_2(10) \approx 0.301...

This means that in a sense all logarithms are the same. Doesn’t matter if you want the number of digits in base 2 or base 10, you can transform from one to the other with a constant.

Lets take the classic example of 0b100'0000'0000=1024 which is almost the same as 10^3=1000:

log_2(1024) = 10

log_{10}(1024) = 3.01 = 10 * 0.301

log_{10}(1000) = 3

log_2(1000)=9.966 = 3/0.301

So we can go from base 2 to base 10 and back just by multiplying or dividing by a constant, 0.301.

Lets try some other numbers, 0b1000'0000=128 and 0b1'0000'0000'0000'0000'0000 = 1048576:


log_{10}(128)=2.107 = 7*0.301


log_{10}(1048576) = 6.0206=20*0.301

It always works out. I picked numbers here that are close to round numbers in base 10 as well, so we can see that in the last example, 6.0206 is correct because log_{10}(1000000)=6.

This means that the number of digits in base 2 grows just over three times as fast as the number of digits in base 10.

This also means that the original statement is more true: You can always make a logarithm be equal to the number of digits.

  • log_2(x) is just the number of digits of x multiplied by 3.322.
  • ln(x) is just the number of digits of x multiplied by 2.303.
  • log_{10}(x) is just the number of digits.

Explaining Simply

I hope this is helpful. This has definitely made it easier for me to look at formulas that contain logarithms. I also wish that logarithms were explained to me like this when I first learned about them, but saying that it’s just the number of digits would probably be too simple language for mathematicians. (see e.g. Wikipedia)

I understand that it often doesn’t exactly work, but I think it’s easier to explain the other cases when you start with “it’s just the number of digits.” Then you can explain all the examples at the beginning of this post, log_{10}(0.001)=-3, log_{10}(1)=0, as being necessary modifications to the simple definition in order to make it work for all positive real numbers.

The benefit is that “number of digits” makes many things obvious, like how fast something grows when it grows with a rate of log(n) (if the result goes up by 1, that means a digit was added to the input). I value that intuition and I’m surprised that nobody I know learned logarithms with this intuition.