How can I assign the maximum value for a long integer to a variable, similar, for example, to C++’s LONG_MAX.
How can I assign the maximum value for a long integer to a variable,
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Long integers:
There is no explicitly defined limit. The amount of available address space forms a practical limit.
(Taken from this site). See the docs on Numeric Types where you’ll see that
Long integers have unlimited precision. In Python 2, Integers will automatically switch to longs when they grow beyond their limit:for integers we have
maxint and maxsize:
The maximum value of an int can be found in Python 2.x with
sys.maxint. It was removed in Python 3, butsys.maxsizecan often be used instead. From the changelog:and, for anyone interested in the difference (Python 2.x):
and for completeness, here’s the Python 3 version:
floats:
There’s
float("inf")andfloat("-inf"). These can be compared to other numeric types: