Home  >  Article  >  Backend Development  >  What is the maximum possible value of an integer in Python? (code example)

What is the maximum possible value of an integer in Python? (code example)

藏色散人
藏色散人Original
2019-03-16 14:32:278465browse

What is the maximum possible value of an integer in Python? (code example)

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:


Output in Python 3:


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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn