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.

classification
Title: min() working incorrectly for decimal and float values
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: float compared to decimal is silently incorrect.
View: 2531
Assigned To: Nosy List: Umit.Oztosun, ezio.melotti, mark.dickinson
Priority: normal Keywords:

Created on 2010-01-18 08:34 by Umit.Oztosun, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg97991 - (view) Author: Umit Oztosun (Umit.Oztosun) Date: 2010-01-18 08:34
On MacOSX (10.5) Intel, Python 2.6.4

>>> from decimal import Decimal
>>> min(Decimal('3.0'), 10.2)
10.199999999999999

On Win32, Python 2.6.4

>>> from decimal import Decimal
>>> min(Decimal('3.0'), 10.2)
Decimal('3.0')

On Linux 32 bit, Python 2.6.4

>>> from decimal import Decimal
>>> min(Decimal('3.0'), 10.2)
10.199999999999999

However, the correct result of Win32 version seems completely coincidental, it produces invalid results for other values:

>>> min(Decimal('12.0'), 10.2)
Decimal('12.0')

We are already aware of problems related to float and Decimal comparison, but in this case it complicates matters worse: On Windows code seems to work OK, on other platforms its results are wrong; worse than this, Windows version works totally by coincidence in fact.

It should at least warn user or raise an error IMHO.
msg97992 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-01-18 08:41
Closing as duplicate of #2531.
History
Date User Action Args
2022-04-11 14:56:56adminsetgithub: 51978
2010-01-18 09:20:10floxsetsuperseder: float compared to decimal is silently incorrect.
2010-01-18 08:41:58ezio.melottisetstatus: open -> closed
priority: normal


nosy: + mark.dickinson, ezio.melotti
messages: + msg97992
resolution: duplicate
stage: resolved
2010-01-18 08:34:37Umit.Oztosuncreate