range of int() type.

KraftDiner bobrien18 at yahoo.com
Wed Aug 23 17:53:59 EDT 2006


Simon Forman wrote:
> 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
>

So what type / class should one use to represent a 16 bit integers
(signed or unsigned)?




> >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