EN
What is the maximum possible integer number in Python ?
1 answers
9 points
I have noticed, when I sum two numbers they give result that is bigger than max unsigned int 64 value.
Does Python has some limits for the numbers?
1 answer
7 points
In Python 3, maximal integer number value is limited only by available memory.
Example program:
xxxxxxxxxx
1
x = 1
2
while x < 1000000000000000000000:
3
print(x, type(x))
4
x *= 10
Output:
xxxxxxxxxx
1
1 <class 'int'>
2
10 <class 'int'>
3
100 <class 'int'>
4
1000 <class 'int'>
5
10000 <class 'int'>
6
100000 <class 'int'>
7
1000000 <class 'int'>
8
10000000 <class 'int'>
9
100000000 <class 'int'>
10
1000000000 <class 'int'>
11
10000000000 <class 'int'>
12
100000000000 <class 'int'>
13
1000000000000 <class 'int'>
14
10000000000000 <class 'int'>
15
100000000000000 <class 'int'>
16
1000000000000000 <class 'int'>
17
10000000000000000 <class 'int'>
18
100000000000000000 <class 'int'>
19
1000000000000000000 <class 'int'>
20
10000000000000000000 <class 'int'>
21
100000000000000000000 <class 'int'>
Hint: Python 2 used
int
andlong
types, whereint
used 32 bits andlong
was limited by available memory.
References
0 commentsShow commentsAdd comment