[issue17259] locale.format() rounding is not reliable for floats

2013-02-20 Thread Francis Nimick
New submission from Francis Nimick: Locale.format() doesn't work correctly with floating point numbers. locale.format('%.0f', 5.5) - 6 locale.format('%.0f', 6.5) - 6 locale.format('%.0f', 7.5) - 8 locale.format('%.0f', 8.5) - 8 It seems that if the number before the decimal point is even, it

[issue17259] locale.format() rounding is not reliable for floats

2013-02-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: http://docs.python.org/library/functions.html#round -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17259 ___

[issue17259] locale.format() rounding is not reliable for floats

2013-02-20 Thread Francis Nimick
Francis Nimick added the comment: I did end up using round - does that mean the locale.format() behavior is correct? It's not specified anywhere in the doc that I can find. -- ___ Python tracker rep...@bugs.python.org

[issue17259] locale.format() rounding is not reliable for floats

2013-02-20 Thread R. David Murray
R. David Murray added the comment: Perhaps Serhiy meant to direct your attention to the note in the round docs. Floating point is tricky. In Python3 the round is actually half to even. I'm not sure what the rounding algorithm is for %f, but I have a suspicion it might be half to even. I

[issue17259] locale.format() rounding is not reliable for floats

2013-02-20 Thread Eric V. Smith
Eric V. Smith added the comment: Mark is the ultimate authority here, but my recollection is (and a quick scan of the code shows) that half to even rounding is used in all of our float to string conversions. So that includes %f and float.__format__, among others. --