Decimal(1) > 0.0 == False

Konstantin Veretennicov kveretennicov at
Wed Mar 1 23:44:46 CET 2006


I'm having hard time trying to justify this decimal quirk to my coworker
(he calls it a bug):

ActivePython 2.4.1 Build 247 (ActiveState Corp.) based on
Python 2.4.1 (#65, Jun 20 2005, 17:01:55) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import decimal
>>> 2.0 > decimal.Decimal(1) > 0.0

Why False?

It's so counter-intuitive. I understand that it may not be possible
to do precise comparison of decimal and float, but an exception would be
so much better than silent False!

- kv

More information about the Python-list mailing list