0

In most compiled languages, the max value for an integer was around 2.147 billion. In Javascript, it is around 10^308. But what is it in Python? If, in the Javascript console, you ask 10 to the power of 309, it return Infinity. But, if you do that in the python shell, it returns a one with 309 zeros. I tried 10^500, 10^500, 10^1000, and even 10^10000 in the shell, and all of them returned a one with the respective number of zeroes. For the last one, I had to confirm the printing of the number, as it made the shell a tad bit slower.
So, do you know what the max value for a Python variable Is?

Thanks for your help!

cs1349459
  • 911
  • 9
  • 27

2 Answers2

0

Python uses a big number integer library in its implementation of an integer type.

This means the number is arbitrarily large.

Eventually you'll hit a limit such as memory. sys.int_info gives you information on the integer, including the largest it can be.

Harjit Singh
  • 45
  • 10
0

This is how you can check the maximum value

import sys
print("Float value information: ",sys.float_info)
print("\nInteger value information: ",sys.int_info)
print("\nMaximum size of an integer: ",sys.maxsize)
roygbiv
  • 339
  • 3
  • 18