How to calculate the number of digits in a multiplication?
Answers
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 = ⌊log10(2)+log10(12321)+log10(1000)⌋+1=8=⌊log10(2∗12321∗1000)⌋+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 log101=log10100=0.
log10102=log10100=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=104∗1.2321, and since it has the same number of digits as 104, the extra ∗1.2321 term should be "ignored" somehow.
Since multiplications in normal space become addition after you take the logarithm, we get:
log1012321=log10(104∗1.2321)=log10104+log101.2321=4+log101.2321
Since we chose to round down to the nearest power of 10, the number we multiply 10i by will always be in the interval [1,10), and any number in this interval will have satisfy 0<log10r<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.
hope this helps...