Bugs item #1202946, was opened at 2005-05-17 02:32
Message generated for change (Comment added) made by ncoghlan
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1202946&group_id=5470

Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
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: Nick Coghlan (ncoghlan)
Date: 2005-05-18 21: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-17 03: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

Reply via email to