Re: Division and right shift in python

2009-08-26 Thread Cevahir Demirkıran
Thanks for the answer. Run it with a big number: f2(9230821908403878236537264867326482638462035732098490238409328947638257462745672354627356427356742563256745362772537532756732673275732,9) I had this result: 8.1015883211e-06 1.06158743591e-05 512 2009/8/26 Mark Tolonen > > > "Cevahir Demirkira

Re: Division and right shift in python

2009-08-26 Thread Dave Angel
Mark Tolonen wrote: "Cevahir Demirkiran" wrote in message news:3f74e020908251648k7b391a09g78b155507b2f2...@mail.gmail.com... Hi, I would like to do a floor division by a power of 2 in python to make it faster than / (modular division in 2.x). However, it is slower. What is the reason of that

Re: Division and right shift in python

2009-08-26 Thread Cevahir Demirkıran
The previous one was slower but now it is faster. How can I make this more consistent? Why cannot I control it? Where can I find the algorithms implemented under for example pow, /, %, etc.? I could not see them in python documentation? f2(28136791827937127971286375648628461979219783642686202802

Re: Division and right shift in python

2009-08-25 Thread Chris Rebert
On Tue, Aug 25, 2009 at 8:40 PM, Mark Tolonen wrote: > > "Cevahir Demirkiran" wrote in message > news:3f74e020908251648k7b391a09g78b155507b2f2...@mail.gmail.com... >> >> Hi, >> >> I would like to do a floor division by a power of 2 in python to make it >> faster than / (modular division in 2.x). >

Re: Division and right shift in python

2009-08-25 Thread Mark Tolonen
"Cevahir Demirkiran" wrote in message news:3f74e020908251648k7b391a09g78b155507b2f2...@mail.gmail.com... Hi, I would like to do a floor division by a power of 2 in python to make it faster than / (modular division in 2.x). However, it is slower. What is the reason of that? I checked them via:

Division and right shift in python

2009-08-25 Thread Cevahir Demirkıran
Hi, I would like to do a floor division by a power of 2 in python to make it faster than / (modular division in 2.x). However, it is slower. What is the reason of that? I checked them via: def f2(x,n): t1 = clock() r = x/pow(2,n) t2 = clock() print (t2-t1) print r t2 = cl