New submission from Per Rosengren <per.roseng...@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 <rep...@bugs.python.org> <http://bugs.python.org/issue7010> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com