[issue1869] Builtin round function is sometimes inaccurate for floats

2009-06-07 Thread Mark Dickinson
Mark Dickinson added the comment: See also issue 6228. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http:

[issue1869] Builtin round function is sometimes inaccurate for floats

2009-04-18 Thread Mark Dickinson
Mark Dickinson added the comment: The two problems mentioned above have now been fixed in r71715. There are (at least) two remaining problems with the round function in 2.x that I'm not going to fix, because the added complication doesn't seem worth it. (1) round(x, n) doesn't give correct re

[issue1869] Builtin round function is sometimes inaccurate for floats

2009-04-18 Thread Mark Dickinson
Mark Dickinson added the comment: I take that back. The 2.7 round still has some problems. Here's one example: >>> x = 5e15 + 1 # exactly representable as an IEEE 754 double >>> x 5001.0 >>> round(x) 5002.0 Another nit: >>> round(-0.0, 0) # should retain the sign of

[issue1869] Builtin round function is sometimes inaccurate for floats

2009-04-18 Thread Mark Dickinson
Mark Dickinson added the comment: Closing this. I think 2.7 is fine as it is. -- resolution: -> fixed status: open -> closed ___ Python tracker ___

[issue1869] Builtin round function is sometimes inaccurate for floats

2009-04-18 Thread Mark Dickinson
Mark Dickinson added the comment: Fixed in py3k in r71701. Some of this fix can be backported to 2.7. -- versions: -Python 3.1 ___ Python tracker ___ __

[issue1869] Builtin round function is sometimes inaccurate for floats

2009-04-17 Thread Mark Dickinson
Changes by Mark Dickinson : -- components: +Interpreter Core ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: htt

[issue1869] Builtin round function is sometimes inaccurate for floats

2009-04-17 Thread Mark Dickinson
Mark Dickinson added the comment: Updated patch, with tests. -- stage: test needed -> patch review Added file: http://bugs.python.org/file13715/issue1869_2.patch ___ Python tracker _

[issue1869] Builtin round function is sometimes inaccurate for floats

2009-04-17 Thread Mark Dickinson
Mark Dickinson added the comment: Note that the correctly rounded string<->decimal code only exists in 3.1, so it won't be possible to backport all this good stuff to 2.7. -- ___ Python tracker

[issue1869] Builtin round function is sometimes inaccurate for floats

2009-04-17 Thread Mark Dickinson
Mark Dickinson added the comment: Here's a patch that improves float rounding in a number of respects: (1) (when available) it uses the recently added correctly-rounded str <- > float conversions in Python/dtoa.c. This means that: - round(x, n) finally does what the docs say it does: rounds

[issue1869] Builtin round function is sometimes inaccurate for floats

2009-03-11 Thread Mark Dickinson
Mark Dickinson added the comment: ...and issue 5473 -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://m

[issue1869] Builtin round function is sometimes inaccurate for floats

2009-01-31 Thread Mark Dickinson
Mark Dickinson added the comment: See also issue 5118. ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pytho

[issue1869] Builtin round function is sometimes inaccurate for floats

2009-01-28 Thread Mark Dickinson
Mark Dickinson added the comment: See also issue 4707. -- priority: low -> normal ___ Python tracker ___ ___ Python-bugs-list mailing

[issue1869] Builtin round function is sometimes inaccurate for floats

2008-08-17 Thread George Boutsioukis
George Boutsioukis <[EMAIL PROTECTED]> added the comment: Hi Mark, Yes, I see where you are going with this and I agree. I think the py3k round function is a bit more accurate, any chance this can be backported to 2.7(after modifying the half-rounding)? Anyway, I was just playing around with th

[issue1869] Builtin round function is sometimes inaccurate for floats

2008-08-17 Thread Mark Dickinson
Mark Dickinson <[EMAIL PROTECTED]> added the comment: Hit submit too soon; sorry... But it would be reasonable to aim for correctly rounded results when the second argument to round is not too large (less than 22 in absolute value, for example), so that 10**abs(n) is exactly representable as a

[issue1869] Builtin round function is sometimes inaccurate for floats

2008-08-17 Thread Mark Dickinson
Mark Dickinson <[EMAIL PROTECTED]> added the comment: Thanks for the patch, George! This patch fixes the problem in some, but not all cases. I'd like to take this a little further. As far as I can see, getting correctly rounded results in all cases is out of reach without either writing lots

[issue1869] Builtin round function is sometimes inaccurate for floats

2008-07-18 Thread George Boutsioukis
George Boutsioukis <[EMAIL PROTECTED]> added the comment: The issue is that the implementation of round includes multiplying the number by 10**ndigits, thus unnecessarily losing some precision for large numbers within the IEEE754 double limits. This means that even smaller numbers can produce the

[issue1869] Builtin round function is sometimes inaccurate for floats

2008-01-18 Thread Mark Dickinson
New submission from Mark Dickinson: The documentation for the builtin round(x, n) says: "Values are rounded to the closest multiple of 10 to the power minus n." This isn't always true; for example: Python 2.6a0 (trunk:59634M, Dec 31 2007, 17:27:56) [GCC 4.0.1 (Apple Computer, Inc. build 5370