
If you come from a programming background of Java or C#, you would have known that there is a limit to the max and the min size of an integer datatype based on the underlying system architecture (which is -231 to -231-1 for 64 bit Operating Systems)
But, do you know that the int data type is an arbitrary precision integer, which means that it can represent integers of any size without overflow.
Reference:https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex
"An integer giving the maximum value a variable of type Py_ssize_t can take. It’s usually 2**31 - 1 on a 32-bit platform and 2**63 - 1 on a 64-bit platform."
Reference:https://docs.python.org/3/library/sys.html#sys.maxsize
Example:
import sys
print(f"Max Int: {sys.maxsize}")
print(f"Min Int: {-sys.maxsize - 1}")
Output:
Max Int: 9223372036854775807
Min Int: -9223372036854775808
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!