[Python-Dev] Decimal & amp; lt; -& amp; gt; float comparisons in py3k. (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Sun Mar 21 02:10:08 CET 2010
- Previous message: [Python-Dev] 0.1
- Next message: [Python-Dev] Decimal & amp; lt; -& amp; gt; float comparisons in py3k.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Greg Ewing wrote:
Antoine Pitrou wrote:
We forbid comparisons when there is a real danger or ambiguity, such as unicode vs. bytes. There is no such danger or ambiguity when comparing a decimal with a float. So do you think that float("0.1") and Decimal("0.1") should be equal or not, and why?
Note that Antoine's point was that float("0.1") and Decimal.from_float(0.1) should compare equal. The latter exactly matches the underlying binary floating point value:
dec.fromfloat(0.1) Decimal('0.1000000000000000055511151231257827021181583404541015625')
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] 0.1
- Next message: [Python-Dev] Decimal & amp; lt; -& amp; gt; float comparisons in py3k.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]