printing anomaly
Roy Smith
roy at panix.com
Sun Mar 20 20:02:58 EST 2005
In article <7xoeddom58.fsf at ruckus.brouhaha.com>,
Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:
> What's the deal with this?
>
> >>> print 3.2
> 3.2
> >>> print [3.2]
> [3.2000000000000002]
> >>>
>
> Yes, I know that 3.2 isn't an exact binary fraction. I'm wondering
> why it's converted differently depending on whether it's in a list.
That's intersting. It looks like it's the difference between str() and
repr():
>>> print str(3.2)
3.2
>>> print repr(3.2)
3.2000000000000002
More information about the Python-list
mailing list