python若干整数的最大值_python – 长整数的最大值

长整数:

没有明确定义的限制。可用地址空间的量形成实际限制。

(从this站点)。参见Numeric Types上的文档,您将看到长整数具有无限精度。在Python 2中,当它们超出其限制时,整数将自动切换到长整型:

>>> import sys

>>> type(sys.maxsize)

>>> type(sys.maxsize+1)

对于整数,我们有

maxint和maxsize:

int的最大值可以在带有sys.maxint的Python 2.x中找到。它在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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值