What is the maximum value that an Integer can hold in python?

+1 vote
91 views
asked Aug 6, 2016 by Hitesh Garg (124 points)  

Is there any way in python to get the maximum number one can use for python or does it have some constant variable defined like INT_MAX which holds the maximum value an integer can hold?

1 Answer

+1 vote
answered Nov 24, 2016 by Hitesh Garg (124 points)  
 
Best answer

In python 3 int and long are actually merged and the value has no such importance.

But in python 2 we have

import sys
print sys.maxint  #2147483647

And the negative value is -2147483648 (i.e. -sys.maxint - 1).

But in python 3 if you assign a value higher than this then it will also be assigned as the range is increased this time. This sys.maxint is replaced by sys.maxsize.

In python 3

import sys
print(sys.maxint)  #2147483647
Welcome to Codingeek Q&A, where you can ask questions and receive answers from other members of the community.
...