[Python-Dev] Decimal & amp; lt; -& amp; gt; float comparisons in py3k. (original) (raw)

Guido van Rossum guido at python.org
Sun Mar 21 18:07:56 CET 2010


On Sat, Mar 20, 2010 at 11:59 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:

Greg Ewing wrote:

Nick Coghlan wrote:

Note that Antoine's point was that float("0.1") and Decimal.fromfloat(0.1) should compare equal. That would mean that Decimal("0.1") != float("0.1"), which might be surprising to someone who didn't realise they were mixing floats and decimals. That's fine - binary floats are surprising. That's why Decimal exists in the first place.

Decimals can be just as surprising:

Decimal(1) / Decimal(3) * Decimal(3) == Decimal(1) False

-- --Guido van Rossum (python.org/~guido)



More information about the Python-Dev mailing list