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
Compilealso 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. – Piotr Semenov Nov 24 '12 at 13:51With[{a = RandomInteger[{10^133, 10^345}], b = RandomInteger[{10^546, 10^865}], n = 10^6}, Timing@Do[a*b, {n}]]. The time is about 1.076sec on the average. For the sameaandbI have profiled the same stuff in PARI/GP (link) that is very fast well-known computer algebra system for number theory. Code wasgettime(); for(i=1,10^6,a*b); gettime(). Time is about 4.4sec on the average. – Piotr Semenov Nov 26 '12 at 07:42