[New-bugs-announce] [issue23627] Incorrect string formatting of float values in Python 2.7

pushpendre rastogi report at bugs.python.org
Tue Mar 10 15:26:26 CET 2015


New submission from pushpendre rastogi:

Hi, The string formatting module in python 2.7 incorrectly formats floating point values. The following code shows the problem

>>> print "%.10s"%(-7.7176718e-05)
-7.7176718
>> print "%.10s"%(-0.0000771767)
-7.71767e-

Ideally the code should have thrown an exception (first preference)
or it should have printed  -0.0000771767 (second preference) or -7.7176718e-05 (third preference)

----------
components: Library (Lib)
messages: 237769
nosy: pushpendre rastogi
priority: normal
severity: normal
status: open
title: Incorrect string formatting of float values in Python 2.7
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23627>
_______________________________________


More information about the New-bugs-announce mailing list