Rollover/wraparound time of time.clock() under win32?

Tim Peters tim.peters at gmail.com
Thu Sep 29 00:38:08 EDT 2005


[Russell Warren, playing w/ time.clock() on Windows]
> ...
> Based on this code and some quick math it confirms that not only will
> the rollover be a looong way out, but that there will not be any loss
> in precision until ~ 30 years down the road.  Checking my math:
>
>  (float(10**16 + 1) - float(10**16)) == 0
>  (float(10**15 + 1) - float(10**15)) == 1
>  ie: our double precision float can resolve unity differences out to
>      at least 10**15
>  Assuming 1 us/count we have 10**15 us / (3.15E13 us/year) = 31.7 yrs

It's about 9x larger than that (given your assumptions).  A double has
exactly 53 significand bits on almost all boxes now:

>>> 2.**53+1 - 2.**53
0.0
>>> 2.**53 - (2.**53-1)
1.0

That is, all integers with absolute value <= 2**53 are exactly
representable as doubles.



More information about the Python-list mailing list