The smallest and largest values of numeric types

Michael Hoffman at mh391.invalid
Tue Apr 17 20:41:52 CEST 2007

fumanchu wrote:
> On Apr 17, 7:12 am, t... at wrote:
>> How can I determine the smallest and largest values
>> of numeric types (for example int) possible in my
>> system? I think there exists a function for this task
>> but I don't know it.
> This should work for ints:
> import sys
> print sys.maxint

One should note that ints bigger than sys.maxint are possible almost 
seamlessly since Python will use longs for these numbers:

Python 2.5 (r25:51908, Mar 13 2007, 08:13:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import sys
 >>> sys.maxint
 >>> sys.maxint+1
 >>> sys.maxint*2
 >>> sys.maxint**10

Of course performance decreases for longer longs.
Michael Hoffman

More information about the Python-list mailing list