【问题标题】:Max integer value of python3 [duplicate]python3的最大整数值[重复]
【发布时间】:2019-08-15 06:56:11
【问题描述】:

对于 64 位系统,python 中整数的最大值是多少。

我尝试了 sys.maxsize 并尝试将值增加 1,但仍将类型显示为 int。如果它被转换为长数据类型,为什么它没有在末尾附加 L。另外如何找到long类型的最大值?

sys.maxsize
9223372036854775807
type(sys.maxsize +1)
<class 'int'>
sys.maxsize+1
9223372036854775808

【问题讨论】:

  • Python 3 没有 long 数据类型。这两种整数类型被统一为int,它本质上等同于Python 2 long,即任意大小的整数类型。

标签: python python-3.x


【解决方案1】:

在Python3中,整数的值不受位数的限制,可以扩展到可用内存的限制

print(100**100)

输出: 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-16
    • 2013-10-30
    • 1970-01-01
    • 1970-01-01
    • 2021-02-20
    • 1970-01-01
    • 2019-05-11
    相关资源
    最近更新 更多