[Python-ideas] Python Numbers as Human Concept Decimal System
Chris Angelico
rosuav at gmail.com
Sat Mar 8 18:43:56 CET 2014
On Sun, Mar 9, 2014 at 4:35 AM, Ron Adam <ron3200 at gmail.com> wrote:
> A repr should give the exact value its object if it's suppose to be a
> machine readable version of it. (As numbers __repr__ should do.)
As I understand it, float.__repr__ does indeed give the exact value,
in terms of reconstructing the float. There are infinitely many float
literals that will result in the exact same bit pattern, so any of
them is valid for repr(n) to return.
>>> 1.233999999999999985 == 1.234
True
>>> repr(1.233999999999999985)
'1.234'
ChrisA
More information about the Python-ideas
mailing list