Is there a direct way to determine how many digits a power of 2 will contain without actually performing the multiplication?
An estimation would help as well if there is no absolute solution.
EDIT: In both decimal and binary bases.
|
Is there a direct way to determine how many digits a power of 2 will contain without actually performing the multiplication? An estimation would help as well if there is no absolute solution. EDIT: In both decimal and binary bases. |
|||||||||||||||||||
|
|
If you solve for $x$ the equation $$2^{n}=10^{x}$$ you get the exponent of $10$ $$x=\frac{n\ln 2}{ \ln 10}\approx 0.30103n\qquad \text{(see comment)}$$ Answer to the edit. In binary base since $$2^{n}=1\cdot 2^{n}+0\cdot 2^{n-1}+\cdots +0\cdot 2^{2}+0\cdot 2^{1}+0\cdot 2^{0},$$ we have $n+1$ bits $$\left( 2^{n}\right) _{2}=\underset{n+1\text{ bits}}{\underbrace{1\overset{n\text{ 0's}}{\overbrace{0\ldots 000}}}}.$$ Comment. The number $x$ is never an integer because $2^{n}$ can only terminate in $2,4,6$ or $8$. So, as commented by Random832, the number of digits in decimal base is $$\left\lfloor 1+\frac{n\ln 2}{\ln 10}\right\rfloor =1+\left\lfloor n\,\log _{10}2\right\rfloor ,$$ which is the sequence A034887 in OEIS (Gost's comment). |
|||||||||||||
|
|
There's an estimate of great use in computer science: $2^{10k} \approx 10^{3k}. $ In particular it's always just a bit bigger, so $2^{10}$ has four digits, $2^{20}$ has seven, and so on. I'm not sure how to find cutoffs for lengths not a multiple of 3. |
||||
|
|
|
IntegerPart(log(x)+1) where |
|||
|
|
|
I'm not sure if there is a proof for this, but there is a repeating pattern that seems to hold true for as large as I can verify. As mentioned in another answer, a $2^{10}$ step increases the base 10 number by three digits. It seems within each $2^{10}$ there is a pattern where each base 10 digit will increment on each of these powers of two: $2^{4} \cdot 2^{3} \cdot 2^{3}$. One could make a pretty efficient function to compute the number of digits using this pattern. Again, not sure how long this pattern holds true for, but the number is pretty large. |
|||||||
|