[Python-Dev] Decimal <-> float comparisons in py3k.

Robert Kern robert.kern at gmail.com
Thu Mar 18 20:45:50 CET 2010

On 2010-03-18 13:27 PM, Glenn Linderman wrote:

> As any non-naïve float user is aware, the proper form of float
> comparisons is not to use < or > or == or !=, but rather, instead of
> using < (to follow along with your example), one should use:
> Decimal('1.1') - 2.2 < epsilon

Not at all. This is quite incorrect for most use cases. Fuzzy comparisons are 
sometimes useful for equality testing, but almost never for ordering.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

More information about the Python-Dev mailing list