Incorrect Decimal-Float behaviour in comparison tests

Cassiano, Marco mcassiano at
Fri Mar 3 16:14:27 CET 2006

I have difficulties with a weird Python 2.4.2 behaviour in comparing Decimal to Floats.

For Example :

>>> from decimal import Decimal
>>> a=Decimal('3.7')
>>> b=6.3

>>> if a > b :print a,b,'a is greater than b - NOT TRUE!!!!'
... else: print a,b,'b is greater than a - CORRECT'

3.7 6.3 a is greater than b - NOT TRUE!!!!

Have you ever encountered this behaviour ? It seems a bug to me...
Do you konw if there is any patch available for this?

Thank you very much

Marco Cassiano 
Manifatture del Nord srl unipersonale
Gruppo MaxMara 

viale Regina Elena 13-15 
42100 Reggio Emilia RE 

Sede operativa:
via Mazzacurati 6
42100 Reggio Emilia RE

Tel. +39 0522 358215 
Fax +39 0522 268715 
email : mcassiano at 


More information about the Python-list mailing list