[issue18739] math.log of a long returns a different value of math.log of an int

2013-10-13 Thread Mark Dickinson
Mark Dickinson added the comment: Patch applied. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18739 ___

[issue18739] math.log of a long returns a different value of math.log of an int

2013-10-13 Thread Roundup Robot
Roundup Robot added the comment: New changeset f543863f4e43 by Mark Dickinson in branch '2.7': Issue #18739: Fix inconsistent results from math.log(n) and math.log(long(n)) http://hg.python.org/cpython/rev/f543863f4e43 -- nosy: +python-dev ___ Python

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-15 Thread Mark Dickinson
Mark Dickinson added the comment: Ah, Tim saw through my cunningly-laid false trail of incorrect issue numbers. Step 1 of my world domination plan is foiled! Yes, let's fix this. In my mind, it's definitely a bug that ints and longs aren't interchangeable here, and it would be nice to have

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-15 Thread Tim Peters
Tim Peters added the comment: +1 on fixing it in 2.7, for the reasons Mark gave. Way back when I introduced the original scheme, log(a_long) raised an exception, and the `int` and `long` types had a much higher wall between them. The original scheme changed an annoying failure into a pretty

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-15 Thread Mark Dickinson
Mark Dickinson added the comment: Here's a patch that simply backports the Python 3.x code to Python 2.7. -- keywords: +patch Added file: http://bugs.python.org/file31304/issue18739.patch ___ Python tracker rep...@bugs.python.org

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-15 Thread Mark Dickinson
Changes by Mark Dickinson dicki...@gmail.com: -- assignee: - mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18739 ___ ___

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-14 Thread Gregory P. Smith
New submission from Gregory P. Smith: This is a very odd inconsistency in math.log behavior. That said, it is probably only a single bit imprecision at the end of the float result. Still, 10 == 10L so I'd expect math.log of both to give the same result. oss/cpython/2.7:LOAS$ ./python Python

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-14 Thread Christian Heimes
Christian Heimes added the comment: Fascinating, how did you find the issue? -- nosy: +christian.heimes, mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18739 ___

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-14 Thread Tim Peters
Tim Peters added the comment: Yup - 2.7 evaluates this in a less precise way, as log(10L) = log(10./16 * 2**4) = log(0.625) + log(2)*4 log(10L) == log(0.625) + log(2)*4 True This patterns works well even for longs that are far too large to represent as a double; e.g., log(1L 5)

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-14 Thread Gregory P. Smith
Gregory P. Smith added the comment: We found this while refactoring an API to be more consistent about returning longs vs ints in specific cases. This resulted in another unittest that was using math.log for a nicer display of the value by magnitude to fail as the result was slightly

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-14 Thread Tim Peters
Tim Peters added the comment: FYI, the improvement was made in these 2 changesets: c8dc4b5e54fb a9349fd3d0f7 If desired, those could presumably be grafted back into the 2.7 branch. The commit messages refer to issue #9599, but that appears to be mistaken. --

[issue18739] math.log of a long returns a different value of math.log of an int

2013-08-14 Thread Tim Peters
Tim Peters added the comment: OK, the correct one is issue #9959. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18739 ___ ___ Python-bugs-list