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

Chris Angelico rosuav at gmail.com
Sat Mar 8 03:10:11 CET 2014


On Sat, Mar 8, 2014 at 1:02 PM, Guido van Rossum <guido at python.org> wrote:
> The repr() function does not round to a fixed number of decimals. It
> produces (in theory, dynamically, although I suspect that the current
> algorithm is better) the shortest decimal string that, when converted back
> to binary, equals *exactly* the input.

If that's the definition of a float's repr, then I'd support using
that by default for the construction of a Decimal from a float. You
can always use .as_integer_ratio() to get the exact stored
representation.

ChrisA


More information about the Python-ideas mailing list