In Python, large values can be stored, such as the following Python sample program:
x = 10000000000000000000000000000000000000000000; x = x + 1 print (x)
Output:
10000000000000000000000000000000000000000001
In Python, integers The value is not limited by the number of bits and can be extended to the limit of available memory. Therefore, we never need any special arrangement to store large numbers (imagine doing the above arithmetic in C/C++).
In Python 3, for all types of integers, there is only one type "int". In Python 2.7. There are two different types "int" (32 bit) and "long int" which is the same as Python 3.x's "int", i.e. can store arbitrarily large numbers.
#Python 2.7中有两种类型:int和long int #在Python 3中只有一种类型:int x = 10 print(type(x)) x = 10000000000000000000000000000000000000000000 print(type(x))
Output in Python 2.7:
<type 'int'> <type 'long'>
Output in Python 3:
<type 'int'> <type 'int'>
This article is an introduction to the maximum possible value of an integer in Python. Hope it helps those in need! (Related recommendations: "Python Tutorial")
The above is the detailed content of What is the maximum possible value of an integer in Python? (code example). For more information, please follow other related articles on the PHP Chinese website!