Message75426
New patch based on catlee's patch: add toseconds() method to timedelta
but use the float type to keep the microseconds. The error between the
exact value and IEEE754 value is small: the error is smaller than one
second even with 999999999 days:
- with less than 16 days, the microsecond error is smaller than
0,01%.
- with less than 1000 days, the microsecond error is smaller than 1%
- with 99500 days or more, the microsecond error is bigger than 90%
To compute the error in microseconds:
>>> d=100; m=1
>>> e=abs((timedelta(days=d, microseconds=m).toseconds() -
d*86400)*1e6 - m)
>>> e*100/m
0.024044513702392578
For the seconds, this is no error even with 999999999 days. Error in
seconds:
>>> d=999999999; s=1; timedelta(days=d, seconds=m).toseconds() -
d*86400, s
(1.0, 1)
(no error, both values are the same) |
|
Date |
User |
Action |
Args |
2008-10-31 18:12:26 | vstinner | set | recipients:
+ vstinner, lemburg, tim.peters, skip.montanaro, brett.cannon, jribbens, guettli, catlee, tomster, erik.stephens, steve.roberts |
2008-10-31 18:12:26 | vstinner | set | messageid: <1225476746.23.0.155854035789.issue1673409@psf.upfronthosting.co.za> |
2008-10-31 18:12:25 | vstinner | link | issue1673409 messages |
2008-10-31 18:12:24 | vstinner | create | |
|