[Python-ideas] Python Numbers as Human Concept Decimal System
Paul Du Bois
paul.dubois at gmail.com
Sat Mar 8 04:55:50 CET 2014
On Fri, Mar 7, 2014 at 6:15 PM, Guido van Rossum <guido at python.org> wrote:
> Or, Decimal(repr(some_float)), which DWIM.
>
Because I haven't seen anyone else bring this up, using a non-exact
conversion breaks the invariant "Decimal(f)==f".
There are so many pairs of numeric types that break that invariant that it
might not be a big deal; but in all other cases the invariant is broken
because it is theoretically impossible.
from decimal import Decimal
f = 2.2
print(Decimal(f)==f)
print(Decimal(repr(f))==f)
p
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140307/4f52a9e9/attachment.html>
More information about the Python-ideas
mailing list