[Python-ideas] Python Numbers as Human Concept Decimal System

Guido van Rossum guido at python.org
Sat Mar 8 05:44:18 CET 2014


On Fri, Mar 7, 2014 at 8:39 PM, Tim Peters <tim.peters at gmail.com> wrote:

> [Guido]
> > Decimal(repr(f)) == f returns False today (for the majority of float
> values
> > anyway) and under my proposal Decimal(f) == f would also return False. I
> > don't (yet :-) think that's a deal breaker.
>
> To the contrary, that's "a feature".  Current Pythons take equality
> testing seriously, striving to return True when & only when values are
> mathematically ("as if using infinite precision") identical, even when
> that's inconvenient to do:
>
> >>> 2**500 == 2.0**500
> True
> >>> 2**500 + 1 == 2.0**500
> False
>
> If information is lost when converting, it's doing nobody a favor for
> "==" to pretend it hasn't been lost.  So long as Decimal.from_float(f)
> == f is still True, then equality would be working as expected in all
> cases.
>

I agree. But what do you think of my main proposal? I would retract it if
you advised me so.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140307/58ffd2d3/attachment.html>


More information about the Python-ideas mailing list