Mok-Kong Shen wrote: > I like to compute log base 2 of a fairly large integer n but > with math.log(n,2) I got: > > OverflowError: long int too large to convert to float. > > Is there any feasible work-around for that?
What version of Python are you using? Python 2.7 can handle "fairly large" integers: >>> float(x) Traceback (most recent call last): File "<stdin>", line 1, in <module> OverflowError: long int too large to convert to float >>> math.log(x, 2) 50462500.07504181 Or maybe our idea of "fairly large" differ; so how large is fairly large? -- https://mail.python.org/mailman/listinfo/python-list