Problem with timeit

Steve D'Aprano steve+python at pearwood.info
Tue Dec 19 05:36:53 EST 2017


On 2017年12月19日 02:27 am, ast wrote:
> I discovered that log functions from math module
> works with integers, whatever their size, there is
> no conversion to float.
>>> import math
>> x = 123456**123456
>> math.log10(x)
> 628577.7303641582 (instantaneous)
>> so 628578 digits

Nice!
It also works with other bases:
py> x = 10**1000000
py> math.log(x, 2)
3321928.0948873623
py> x.bit_length()
3321929
Today I learned. Thank you.
-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /