python长整数最大值_长整数的最大值

长整数:

没有明确定义的限制。可用地址空间的数量构成了一个实际的限制。

(取自this站点)。查看Numeric Types上的文档,您将在其中看到Long integers have unlimited precision。在Python2中,当整数增长超过其限制时,它们将自动切换到long:>>> import sys

>>> type(sys.maxsize)

>>> type(sys.maxsize+1)

对于整数我们有

maxint和maxsize:

int的最大值可以在Python 2.x中找到,sys.maxint。它在Python 3中被删除,但是sys.maxsize通常可以被使用。来自the changelog:The sys.maxint constant was removed, since there is no longer a limit

to the value of integers. However, sys.maxsize can be used as an

integer larger than any practical list or string index. It conforms to

the implementation’s “natural” integer size and is typically the same

as sys.maxint in previous releases on the same platform (assuming the

same build options).

对the difference(Python 2.x)感兴趣的人:sys.maxint The largest positive integer supported by Python’s regular

integer type. This is at least 2**31-1. The largest negative integer

is -maxint-1 — the asymmetry results from the use of 2’s complement

binary arithmetic.

sys.maxsize The largest positive integer supported by the platform’s

Py_ssize_t type, and thus the maximum size lists, strings, dicts, and

many other containers can have.sys.maxsize

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.

浮动:

有float("inf")和float("-inf")。这些可以与其他数字类型进行比较:>>> import sys

>>> float("inf") > sys.maxsize

True

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值