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!

4
  • Python had handle any size integer. Commented Jun 16, 2020 at 15:22
  • import math ... math.factorial(10000) should tell you all you really need to know. Commented Jun 16, 2020 at 15:23
  • stackoverflow.com/questions/7604966/… Commented Jun 16, 2020 at 15:23
  • @JohnColeman Yes, thank you. Commented Jun 16, 2020 at 15:27

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.