Bug in Python large negative literal assignment?

Keith Dart kdart at leviathan.kdart.com
Mon May 14 01:33:06 EDT 2001


I seem to have found a bug in how Python assigns the largest negative
literal:

Python 2.1 (#1, Apr 23 2001, 15:49:36) 
[GCC 2.95.1 19990816/Linux (release)] on linux2
Type "copyright", "credits" or "license" for more information.
Sourcing .pythonrc...
Python> # I cannot assign the following:
.more.. i = -2147483648
OverflowError: integer literal too large
Python> # however, I can do it the following ways:
.more.. i = -sys.maxint-1
Python> i
-2147483648
Python> i = 0x80000000
Python> i
-2147483648
Python> i = -2147483647 ; i = i - 1
Python> i
-2147483648
Python> i = -2147483647-1
Python> i
-2147483648
Python> i = -2147483648
OverflowError: integer literal too large

But, no, can't assign a max negative number as decimal literal.



                           \\|//
                           (O O)
-- --------------------oOOo~(_)~oOOo----------------------------------------
Keith Dart
<mailto:kdart at kdart.com>
<http://www.kdart.com/>
----------------------------------------------------------------------------
Ever since my brain transplant I ...
============================================================================




More information about the Python-list mailing list