[New-bugs-announce] [issue7010] Rounding when converting float tuple to str
Per Rosengren
report at bugs.python.org
Mon Sep 28 09:43:58 CEST 2009
New submission from Per Rosengren <per.rosengren at gmail.com>:
When a floating point value is stored, the actual value stored is
something at most some small number eps larger or smaller than the
original value. Python knows this, so if it stores 0.1, and then prints
the stored value, it rounds off decimals less significant than eps.
For some reason, if it prints a tuple with the same value, it doesn't do
the rounding properly. This behavior is incorrect, and very annoying for
instance when printing manually entered constants in tuples.
'''Shows that floats in tuples are not rounded like floats.
>>> print(.1)
0.1
>>> print((.1,))
(0.10000000000000001,)
'''
import doctest
doctest.testmod(verbose=True)
----------
components: Interpreter Core
messages: 93193
nosy: scientist47
severity: normal
status: open
title: Rounding when converting float tuple to str
type: behavior
versions: Python 2.6, Python 3.0
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7010>
_______________________________________
More information about the New-bugs-announce
mailing list