# Estimate or calculate the number of digits of a multiplication

I would like to calculate the number of digits of these multiplications

2 x 4

200 x 300

2 (12321) (1000).

I don't exactly know how to start. Of course I know that I can multiply the numbers and count the digits,

2 x 4 = 8 (1 digit)

200 x 300 = 60,000 (5 digits)

2 (12321) (1000) = 24,642,008 (8 digits).

But If the numbers are very large, it would be difficult to make this procedure, so I was maybe looking for another way (This is why I asked myself the question in the first place).

You can take log10 of each of the numbers being multipled, sum them, floor them, then add one to get the number of digits.

i.e. In your last example of 2*12321*1000, which is actually equal to 24642000 (you missed a 0, so it has 8 digits).

Number of Digits = $\lfloor log_{10}(2) + log_{10}(12321) + log_{10}(1000) \rfloor +1 = 8 \\ =\lfloor log_{10}(2*12321*1000) \rfloor +1$

I'll begin explaining why this works with a simple observation: You can calculate the number of any power of 10 by simply taking the base-10 logarithm of it, and adding one.

For example $log_{10}1=log_{10}10^0=0$.

$log_{10}10^2 = log_{10}100=2$, etc.

So by adding one to each of these two examples above, we get the correct number of digits. This is just an artifact of the fact that we use base-10 to count. If we counted in base-2, we'd take log2, then add one.

Now, why do we have to floor the number and add one for any general number?

The number 12321 can be thought of as $12321 = 10^4 * 1.2321$, and since it has the same number of digits as $10^4$, the extra $*1.2321$ term should be "ignored" somehow.

Since multiplications in normal space become addition after you take the logarithm, we get:

$log_{10}12321 = log_{10}(10^4*1.2321) = log_{10}10^4 + log_{10}1.2321 \\ =4+log_{10}1.2321$

Since we chose to round down to the nearest power of 10, the number we multiply $10^i$ by will always be in the interval $[1,10)$, and any number in this interval will have satisfy $0<log_{10}r<1$ - so the reason we floor it is just to remove this "remainder".

The final step is just to add one, as I explained above.

• mm I'm having trouble understanding why do you take the logarithm of each of the numbers, and why you add 1...
– Trux
Commented Jul 5, 2014 at 21:37
• @Trux I edited my answer, please have a read through the new section and let me know if it helps at all. Commented Jul 5, 2014 at 21:56
• So, in my other examples: $log_{10}(200) + log_{10}(300) = log_{10}(200(300)) = log_{10}(60,000) = log_{10}(10^4) + log_{10}(6.0000) = log_{10}(10^4) + 0 + 1 = 5$
– Trux
Commented Jul 5, 2014 at 22:46
• But $log_{10}(2) + log_{10}(4) = log_{10}(8) = log_{10}((10^1)(0.8)) = log_{10}(10^1) + log_{10}(0.8) = 1 + 0 + 1 = 2$ , which is wrong. Why am I wrong? Thanks, it's been really helpful
– Trux
Commented Jul 5, 2014 at 22:53
• $log10(0.8)=-0.096910013008...$, so $\lfloor log_{10}(10)+log_{10}(0.8) \rfloor$ is actually 0. Commented Jul 6, 2014 at 1:25

Well, if you have whole number from the set $\{1, 2, ..., 9 \}$ than its logarithm is between $0$ and $1$ or it is in $[0,1 \rangle$ interval. If the whole number is between $10$ and $99$ than its logarithm is in $[1,2 \rangle$ interval ... If the whole number is between $10^n$ and $10^{n+1}-1$ than its logarithm is in $[n,n+1 \rangle$ interval.

So then, you can also see that when you take floor of the logarithm of the certain whole number and add 1 you get exactly the number of its digits. And it is same when you write number like few factors or any other way, you just use logarithm properties and so on... something like that is the explanation behind this question.

That's how I see it, haven't seen something like this here so just to put it down. Thnx, Z :-)

• Consider learning MathJax syntax Commented Aug 15, 2016 at 23:06
• Thank You for the reminder. I heavent been writing here before. So, math stuff is written same like in LaTeX. I didn't noticed before, thnx for the tip, it looks more nice now... Commented Aug 16, 2016 at 18:07
• Looks good! I cleaned it up a bit more and added some paragraph breaks. You can click edit to see what I did. Commented Aug 16, 2016 at 18:17
• Well, thnx again, it is much more nice now. I am not native english speaker so I made few mistakes there in spelling... I got some helpfull tips there in all. Thnx Commented Aug 16, 2016 at 18:28