homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients belopolsky, cool-RR, facundobatista, mark.dickinson, rhettinger, skrah, vstinner
Date 2012年03月20日.00:14:54
SpamBayes Score 5.043653e-06
Marked as misclassified No
Message-id <1332202494.81.0.460679304607.issue14262@psf.upfronthosting.co.za>
In-reply-to
Content
My patch looses precision for big numbers. It's better to convert Decimal to a number of microseconds.
Wrong:
>>> value=86400*365.25*999999+1e-6; print(datetime.timedelta(seconds=value))
365249634 days, 18:00:00
>>> value=decimal.Decimal(86400*365.25*999999)+decimal.Decimal('1e-6'); print(datetime.timedelta(seconds=float(value)))
365249634 days, 18:00:00
Correct:
>>> value=decimal.Decimal(86400*365.25*999999)+decimal.Decimal('1e-6'); print(datetime.timedelta(microseconds=int(value*decimal.Decimal(10**6))))
365249634 days, 18:00:00.000001
I'm not completly conviced by the need of supporting Decimal in timedelta constructor. Why do you use Decimal if the result should be a timedelta? Why not using timedelta directly?
History
Date User Action Args
2012年03月20日 00:14:55vstinnersetrecipients: + vstinner, rhettinger, facundobatista, mark.dickinson, belopolsky, skrah, cool-RR
2012年03月20日 00:14:54vstinnersetmessageid: <1332202494.81.0.460679304607.issue14262@psf.upfronthosting.co.za>
2012年03月20日 00:14:54vstinnerlinkissue14262 messages
2012年03月20日 00:14:54vstinnercreate

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