On Thu, 2004-07-01 at 20:57 -0500, Ron Johnson wrote:
> On Thu, 2004-07-01 at 20:32 -0500, Ron Johnson wrote:
> > On Thu, 2004-07-01 at 14:08 -0500, Friedrich Gurtler wrote:
> > > >
> > > >
> > > >I tried it in perl, the output i got was 3.
> > > >
> > > >3 is the length of the string 'inf', hahaha...
> > > >
> > > >ray
> > > >
> > >
> > > >Surprise..... 131 seconds. (Roughly under 3 minutes.)
> > > >
> > > >I got the same result
> > > >length: 903090
> > > >time: 131
> > > >
> > >
> > > I tried it in perl too, but got rather different results.
> > >
> > > use Math::BigInt lib=>'GMP';
> > > print Math::BigInt->new('1')->blsft(3000000, 2)->length() ."\n";
> > >
> > > fritz $ time perl test.pl
> > > 903090
> > >
> > > real 0m10.035s
> > > user 0m8.320s
> > > sys 0m0.160s
> > >
> > > 10 seconds on a 667 Mhz Mac. It is all about how smart your algorithm
> > > is. (Or perhaps Macs are that powerful! ;-) )
> >
> > 10 seconds, eh? What's that Mac running??
> >
> > $ uname -srm
> > Linux 2.6.6 i686
> >
> > $ cat bignum.pl
> > use Math::BigInt lib=>'GMP';
> > print Math::BigInt->new('1')->blsft(3000000, 2)->length() ."\n";
> >
> > time perl bignum.pl
> > 903090
> >
> > real 184m8.801s
> > user 181m28.241s
> > sys 0m1.110s
>
> Wow!!!!!!!
>
> I installed perl bindings for the GNU MP library, and the timing
> dropped to:
> $ time perl bignum.pl
> 903090
>
> real 0m2.071s
> user 0m2.012s
> sys 0m0.020s
I think the issue here is binary->decimal/string conversion.
$ cat bignum2.py
import time
t1 = time.clock()
a = 2**80000000
t2 = time.clock()
print t2 - t1
$ python bignum2.py
4.83
-- ----------------------------------------------------------------- Ron Johnson, Jr. ron.l.johnson@cox.net Jefferson, LA USA The difference between Rock&Roll and Country Music? Old Rockers still on tour are pathetic, but old Country singers are still great. ___________________ Nolug mailing list nolug@nolug.orgReceived on 07/01/04
This archive was generated by hypermail 2.2.0 : 12/19/08 EST