[issue5118] '%.2f' % 2.545 doesn't round correctly

2012-05-03 Thread Mark Dickinson
Mark Dickinson added the comment: > That's because Python uses floating point registers of the x86-CPU- > architecture to store point values. This method is inaccurate and causes > such problems. Yes, exactly; this is the root cause. And as you suggest, Python *could* use a different numeric

[issue5118] '%.2f' % 2.545 doesn't round correctly

2012-05-03 Thread Ultrasick
Ultrasick added the comment: Ok, let's sum that up: There is a rounding problem. That's because Python uses floating point registers of the x86-CPU-architecture to store point values. This method is inaccurate and causes such problems. So Python inherits this bug from this value storing meth

[issue5118] '%.2f' % 2.545 doesn't round correctly

2012-04-19 Thread Mark Dickinson
Mark Dickinson added the comment: > Well this IS a bug. I assume that you're referring to behaviour like this: Python 2.7.2 (default, Jan 13 2012, 17:11:09) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> x = 2.5

[issue5118] '%.2f' % 2.545 doesn't round correctly

2012-04-19 Thread Zeev Rotshtein
Zeev Rotshtein added the comment: Well this IS a bug. There is a certain globally accepted manner in which rounding work and python does something else. P.S.: A bug is when something doesn't do what it's supposed to do the way it's supposed to do it. This definition does not depend on "intern

[issue5118] '%.2f' % 2.545 doesn't round correctly

2009-01-31 Thread Mark Dickinson
Mark Dickinson added the comment: > result is 2.55 and not 2.54. If python doesn't deliver "2.55" as the > result of it's rounding algorithm then it's doing it wrong. And if Sorry, but that's just not true. I suggest that you (a) read the section on floating-point[1] in the Python tutorial, a

[issue5118] '%.2f' % 2.545 doesn't round correctly

2009-01-31 Thread Ultrasick
Ultrasick added the comment: Well that's not what I have learned how rounding works. I think that's the more common way: 0.4 -> 0 0.5 -> 1 0.6 -> 1 I hope you don't try to spread the misbehavoir of pythons way of rounding print '%.2f' % 2.545 // returns 2.54 to the built in round() function.

[issue5118] '%.2f' % 2.545 doesn't round correctly

2009-01-31 Thread Mark Dickinson
Mark Dickinson added the comment: > So you might want to reopen the bug. But either way I don't consider > this bug as really serious either. I don't understand. As far as I can see '%.2f' % 2.545 is returning the correct result: there is no bug here, so no need to reopen. '%.2f' should *not*

[issue5118] '%.2f' % 2.545 doesn't round correctly

2009-01-31 Thread Ultrasick
Ultrasick added the comment: I am sorry but I am not a C programmer. I cannot provide any patches. As far as I understood this issue and issue #1869 have a common problem but this issue wouldn't be solved if issue #1869 is solved. "print '%.2f' % 2.545" doesn't seam to use the built in round()

[issue5118] '%.2f' % 2.545 doesn't round correctly

2009-01-31 Thread Mark Dickinson
Mark Dickinson added the comment: > print round(2.545, 2) // returns 2.55 Aha! Yes, that one *is* a bug (see issue #1869), though it's not one that I regard as terribly serious, and not one that can be easily solved in all cases. Here's why I don't see it as particularly serious: you're rou

[issue5118] '%.2f' % 2.545 doesn't round correctly

2009-01-31 Thread Ultrasick
Ultrasick added the comment: print round(2.545, 2) // returns 2.55 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http:

[issue5118] '%.2f' % 2.545 doesn't round correctly

2009-01-31 Thread Mark Dickinson
Changes by Mark Dickinson : -- status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mai

[issue5118] '%.2f' % 2.545 doesn't round correctly

2009-01-31 Thread Mark Dickinson
Mark Dickinson added the comment: This is not a bug; it's a consequence of the finite accuracy of floating- point arithmetic. If you look at the actual value that's stored for '2.545', you'll see that it's actually slightly less than 2.545, so rounding it down is the correct thing to do. >>

[issue5118] '%.2f' % 2.545 doesn't round correctly

2009-01-31 Thread Ultrasick
New submission from Ultrasick : print '%.2f' % 2.544 // returns 2.54 print '%.2f' % 2.545 // returns 2.54 but should return 2.55 print '%.2f' % 2.546 // returns 2.55 -- messages: 80868 nosy: Ultrasick severity: normal status: open title: '%.2f' % 2.545 doesn't round correctly type: behav