range of int() type.

Simon Forman rogue_pedro at yahoo.com
Wed Aug 23 17:36:09 EDT 2006


KraftDiner wrote:
> What is the range of a variable of type int()
>
> eg:
> i = int()
> print i.max()  # 0xFFFFFFFF
> print i.min() # 0x00000000
>
> is it a signed 16 bit or 32 bit or is it unsigned 16 or 32...
> I've noticed that it can be incremented into a new class of type
> long...

|>> import sys
|>> sys.maxint
2147483647

>From the sys module docs:
maxint
    The largest positive integer supported by Python's regular integer
type. This is at least 2**31-1. The largest negative integer is
-maxint-1 -- the asymmetry results from the use of 2's complement
binary arithmetic.

Peace,
~Simon

P.S. ints and longs are becoming unified soon.




More information about the Python-list mailing list