[Python-Dev] Decimal <-> float comparisons in py3k. (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Tue Mar 16 23:46:04 CET 2010
- Previous message: [Python-Dev] Decimal <-> float comparisons in py3k.
- Next message: [Python-Dev] Decimal <-> float comparisons in py3k.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Steven D'Aprano wrote:
But no such problems arise with comparisons, which will always return a bool, and will avoid the current ... interesting ... behaviour. In 3.1:
Decimal(1) == 1 == 1.0 True Decimal(1) == 1.0 False Decimal.fromfloat(1.0) == 1 == 1.0 True Decimal.fromfloat(1.0) == 1.0 False Replacing False with an exception doesn't make it any less bizarre.
Allowing the comparisons also doesn't introduce the potential for large cumulative errors which are possible when actual implicit arithmetic conversions are allowed.
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] Decimal <-> float comparisons in py3k.
- Next message: [Python-Dev] Decimal <-> float comparisons in py3k.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]