Issue7323
Created on 2009-11-14 18:39 by adamtj, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg95248 - (view) | Author: Adam Tomjack (adamtj) | Date: 2009-11-14 18:39 | |
These should all return False, or some of them should raise exceptions:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import decimal
>>> decimal.Decimal('0') > 0
False
>>> decimal.Decimal('0') < 0
False
>>> decimal.Decimal('0') > 0.0
True
>>> decimal.Decimal('0') < 0.0
False
>>> 0.0 > decimal.Decimal('0')
False
>>> 0.0 < decimal.Decimal('0')
True
>>> 0.0 < decimal.Decimal('0.0')
True
>>> decimal.Decimal('0') > decimal.Decimal('0')
False
|
|||
| msg95262 - (view) | Author: Mark Dickinson (mark.dickinson) * ![]() |
Date: 2009-11-14 22:20 | |
Unfortunately there's no easy way to fix this in 2.x, where any object is supposed to be comparable with any other. See issue 2531 for a previous discussion. It's fixed in 3.x: there a comparison (other than ==, !=) between a float and a Decimal does raise an exception. Closing as a duplicate of issue 2531. Issue 2531 is also closed, but you should feel free to add to the discussion there. |
|||
| msg95264 - (view) | Author: Mark Dickinson (mark.dickinson) * ![]() |
Date: 2009-11-14 22:39 | |
I've re-opened issue 2531: some recent changes (in particular, the backport of the 3.x float <-> string conversions to 2.x) may make previously rejected solutions viable again. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:54 | admin | set | github: 51572 |
| 2009-11-14 22:39:16 | mark.dickinson | set | messages: + msg95264 |
| 2009-11-14 22:20:49 | mark.dickinson | set | status: open -> closed resolution: duplicate superseder: float compared to decimal is silently incorrect. messages: + msg95262 |
| 2009-11-14 18:48:06 | r.david.murray | set | nosy:
+ mark.dickinson |
| 2009-11-14 18:39:33 | adamtj | set | type: behavior |
| 2009-11-14 18:39:19 | adamtj | create | |
