maximum value for long?
tjreedy at udel.edu
Wed Nov 19 03:45:45 CET 2003
"S.Susnjar" <forth at gmx.de> wrote in message
news:baab8c40.0311180906.a4ab9f7 at posting.google.com...
> Hello all,
> I have been programming in Python only for a month or so and have
> over a "problem" that I could not solve through rtfm.
Ref Man 3.2 The standard type hierarchy
There are two types of integers:
These represent numbers in the range -2147483648 through 2147483647.
(The range may be larger on machines with a larger natural word size,
but not smaller.) When the result of an operation would fall outside
this range, the exception OverflowError is raised. For the purpose of
shift and mask operations, integers are assumed to have a binary, 2's
complement notation using 32 or more bits, and hiding no bits from the
user (i.e., all 4294967296 different bit patterns correspond to
These represent numbers in an unlimited range, subject to available
(virtual) memory only. For the purpose of shift and mask operations, a
binary representation is assumed, and negative numbers are represented
in a variant of 2's complement which gives the illusion of an infinite
string of sign bits extending to the left.
In short, Python ints are C longs, while Python longs are extended or
arbitrary precision, and hence truly long. Your confusion over the
two meanings of 'long' is not unique among people with a C background
Terry J. Reedy
More information about the Python-list