bdhar bdhar - 11 months ago 74
Python Question

Maximum and Minimum values for ints

I am looking for minimum and maximum values for integers in python. For eg., in Java, we have

. Is there something like this in python?

Answer Source

In Python 2, there's sys.maxint:

>>> sys.maxint

And you can calculate the minimum value with -sys.maxint - 1 as seen here. Of course Python just switches from plain to long integers once you exceed this value.

In Python 3 this value has no significance at all for integers. (However, a closely related value is still available as sys.maxsize, in case you're actually looking for the machine's word size.)