[issue22134] string formatting float rounding errors

2014-08-04 Thread Ned Deily

Ned Deily added the comment:

What you are seeing is due to the limitations of binary floating-point 
arithmetic.  The issue is described in more detail in the Python tutorial:

https://docs.python.org/2/tutorial/floatingpoint.html#tut-fp-issues

--
nosy: +ned.deily
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22134] string formatting float rounding errors

2014-08-04 Thread Larry

New submission from Larry:

Certain values close to the rounding boundary are rounded down instead of up; 
and this is done somewhat inconsistently.


#Example (python v2.7.8, and previous)

#almost an odd-even pattern, but not quite
for x in [1.045, 1.145, 1.245, 1.345, 1.445, 1.545, 1.645, 1.745, 1.845, 1.945]:
print "{0:.3f} => {0:.2f}".format(x)

#while ..6 rounds up correctly
for x in [1.046, 1.146, 1.246, 1.346, 1.446, 1.546, 1.646, 1.746, 1.846, 1.946]:
print "{0:.3f} => {0:.2f}".format(x)

--
messages: 224747
nosy: Larry
priority: normal
severity: normal
status: open
title: string formatting float rounding errors
type: behavior
versions: Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com