当前位置:   article > 正文

python若干整数的最大值和最小值,整数的最大值和最小值

python3 minimum integer

I am looking for minimum and maximum values for integers in python. For eg., in Java, we have Integer.MIN_VALUE and Integer.MAX_VALUE. Is there something like this in python?

解决方案

Python 3

In Python 3, this question doesn't apply. The plain int type is unbounded.

However, you might actually be looking for the machine's

Python 2

In Python 2, the maximum value for plain int values is available as sys.maxint:

>>> sys.maxint

9223372036854775807

You can calculate the minimum value with -sys.maxint - 1 as shown here.

Python seamlessly switches from plain to long integers once you exceed this value. So most of the time, you won't need to know it.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/615572
推荐阅读
相关标签
  

闽ICP备14008679号