File this under “math I should have realized”.

Even after all these years, I still find logarithms to be challenging, compelling, and *surprising*. This post is about an idea that snuck up on me this morning. And it snuck up even though:

- I have written:
**Log**on many whiteboards and many review sheets._{2}8 = 3 because 2^{3}= 8 - I have learned (and taught!) the classic collection of assorted log properties
- I have read David Mermin’s lovely piece “Logarithms!” (and blogged about it here.)
- I have written a chapter on exponential functions and logarithms in “Advanced Math for Young Students”.

And yet, there is a basic idea about logarithms that I never really thought about (until this morning). So here it is:

*The integer part of the logarithm of an integer is one less than the number of digits the integer has when it is represented in the same base as the logarithm itself. *

You could write:

*Floor[Log _{b} N] *

*+ 1 = the number of N’s digits when N is represented in base b.*In other words, the logarithm counts the digits — and not just in base-10. You just have to round down and add 1. I would like to explain this, if for no other reason than to convince myself that it is true!

*Starting with base 10:*

Let’s look at some common (base 10) logarithms that we can find without a calculator:

Log 1 = 0 …because
10^{0} = 1

Log 10 = 1 …because
10^{1} = 10

Log 100 = 2 …because
10^{2} = 100

Log 1000 = 3 …because
10^{3} = 1000

Log 10000 = 4 …because
10^{4} = 10000

I think you get the idea. If we construct a number, say N, by writing a 1 followed by k zeroes, then the common (base 10) logarithm, log N = k. And the number will have k + 1 digits: the k zeroes and the 1 in front of them. So for each of these, adding 1 to the common logarithm gives you the number of digits.

Now let’s look at one that you do need a calculator for. I’ll report three decimal places:

Log 375 = 2.574 …because 10^{2.574} = 374.973 ≈ 375

And it makes sense: 375 is more than 100 so its common logarithm is greater than 2. But 375 is also less than 1000 so its common logarithm is less than 3. It is more than the smallest 3 digit number and less than the smallest 4 digit number. And if you take the common logarithm, which was 2.574, round it down and then add 1, you get the number of digits. Nice.

Let’s try another (again reporting 3 decimal places):

Log (8787) = 3.944 … because 10^{3.944} ≈ 8787 (though with a little more round-off error, but still…)

And this makes sense too: 8787 is more than 1000 so its common log is greater than 3. But it is less than 10000 so its common log is less than 4. In fact, it is closer to 10000 so its log is close to 4, but still less. And if we round down 3.944 and add 1, again we get the number of digits in the number we started with.

OK, I admit that I kind-of knew that already. But for some reason, this next step caught me by surprise…let’s move away from base 10 and see what happens.

*Other bases and other logarithms*

On and off this year, I have been playing with James Tanton’s invention, “Exploding Dots”. If you have not yet seen this, you really should take a look. You can get started here. But really, Google it – those dots are not just exploding, they are proliferating!

One thing that Exploding Dots teaches you almost immediately and organically is how to express numbers in other bases. And something interesting happens when you look at the base 2 logarithms as you look at the base 2 representations…

So if a number N
happens to be an integer power of 2, say 2* ^{k}*,
then we know two things:

1. Its base-2 logarithm, log_{2} N = k

2. Its base-2 representation will consist of k zeroes and a leading 1. And that makes k + 1 digits.

Now let’s get some help from a calculator.

Log_{2} 5 = 2.322 …because 2^{2.322} ≈ 5

Does it make sense? Well, since 5 is more than 4, we expect its base-2 logarithm to be more than 2. But 5 is less than 8, so we expect its base-2 logarithm to be less than 3. So this looks right.

But we are not done! If we explode some dots, we can find the base 2 representation.

5 = 1 0 1 and that makes 3 digits – which is also what we get when we round down the base-2 logarithm and then add 1!

OK, let’s check a big number:

500 expressed in base 2 is 1 1 1 1 0 1 0 0 (which you might want to check…)

I see 9 digits.

Log_{2} 500 = 8.966 (and yes, it
checks out: 2^{8.966 } ≈ 500)

Round it down and add 1…YES!

*So if you want to know the number of digits in the base-b
representation of a number, find the base-b logarithm, round it down to its
floor and then add one. The logarithm is
the digit counter!*