Bugs item #1202946, was opened at 2005-05-16 11:32 Message generated for change (Comment added) made by rhettinger You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1202946&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 2.4 >Status: Closed >Resolution: Out of Date Priority: 5 Submitted By: ric-b (ric-b) Assigned to: Nobody/Anonymous (nobody) Summary: Problem with abs function Initial Comment: On windows version I get : >>> abs(-9999999999999999999) Traceback (most recent call last): File "<pyshell#7>", line 1, in -toplevel- abs(-9999999999999999999) OverflowError: long too big to convert does not handle new longs. I am using the following work around: t = a - b # calc t = abs(a - b) if t < 0 : t *= -1 ---------------------------------------------------------------------- >Comment By: Raymond Hettinger (rhettinger) Date: 2005-05-26 02:12 Message: Logged In: YES user_id=80475 No response from the OP. Presuming that Terry's explanation is correct. Please re-open if presented with evidence to the contrary. ---------------------------------------------------------------------- Comment By: Terry J. Reedy (tjreedy) Date: 2005-05-18 21:10 Message: Logged In: YES user_id=593130 Python 2.2.1 (#34, Apr 9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> abs(-9999999999999999999) 9999999999999999999L Ric-b: what windows version? Even older? If the problem is not with current or future (cvs) Python, please close this. ---------------------------------------------------------------------- Comment By: Nick Coghlan (ncoghlan) Date: 2005-05-18 06:53 Message: Logged In: YES user_id=1038590 I tried the OP's example in wxPython's PyShell as well as in the standard interpreter, and got the same result as Raymond. However, I was able to provoke a similar looking error by trying to convert a large long to a float (and the exception is telling the plain truth - a double precision float can't handle a number that big): Py> num = 1.0 Py> lng = -999999999999999999999999999999999999999999999999999999999999999999999 99999999999999999999999999999999999999999999999999999999999999999999999999999999 99999999999999999999999999999999999999999999999999999999999999999999999999999999 99999999999999999999999999999999999999999999999999999999999999999999999999999999 99999999999999999999999999999999999999999999999999999999999999999999999999999999 999999999999 Py> num += abs(lng) Traceback (most recent call last): File "<stdin>", line 1, in ? OverflowError: long int too large to convert to float ---------------------------------------------------------------------- Comment By: Raymond Hettinger (rhettinger) Date: 2005-05-16 12:33 Message: Logged In: YES user_id=80475 That's odd. It works for me: Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> abs(-9999999999999999999) 9999999999999999999L ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1202946&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com