Beside *10^n
, is there a faster way to add thousands of zeros to end of a number?
Updated
Timings:
In[230]:= First[Timing[prime*10^100000000]]
Out[230]= 3.625
In[25]:= First[
Timing[FromDigits[
Join[IntegerDigits[prime], ConstantArray[0, 100000000]]]]]
Out[25]= 7.547
Updated
According to Mr.Wizard answer:
In[46]:= First[Timing[2213*1*^200000000]]
Out[46]= 0.015 (* The real timing on the clock is 5 seconds *)
In[45]:= First[Timing[2213*10^200000000]]
Out[45]= 5.11
In[3]:= First[Timing[ToExpression["2213*1*^200000000"]]]
Out[3]= 5.078
But the strange thing is that by using special 1*^
notation, the reported timing is almost zero while by clock it takes roughly the same time of 10^n
. Maybe Timing
function doesn't take Mathematica built-in notations into account.!!
Updated 2
Yet The fastest method to beat native *^10
adding zero method is by shifting, even though the improvement is very tiny.
In[16]:= First[Timing[1223*10^100000000]]
Out[16]= 2.625
In[17]:= First[Timing[BitShiftLeft[1223*5^100000000, 100000000]]]
Out[17]= 2.547
Compile
also will give no effect because you use very big numbers those cannot be fitted by machine numbers. Mathematica is well suited for symbolic computations and prototyping of numerical algorithms but not for great numerical performance. $\endgroup$