[issue23627] Incorrect string formatting of float values in Python 2.7

2015-03-10 Thread Eric V. Smith
Eric V. Smith added the comment: By using %s, you're asking the formatting code to first convert the parameter to a string. Then, by using .10, you're asking it to truncate the value. It's essentially equivalent to: >>> str(-7.7176718e-05) '-7.7176718e-05' >>> str(-7.7176718e-05)[:10] '-7.7176

[issue23627] Incorrect string formatting of float values in Python 2.7

2015-03-10 Thread pushpendre rastogi
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.771767) -7.71767e- Ideally the code should have thrown a