Python中的最大浮点数是多少?
The maximum integer in Python 2 is available by calling sys.maxint
.
What is the maximum float
or long
in Python?
See also: Maximum and Minimum values for ints.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于
float
,请查看sys .float_info
:具体来说,
sys.float_info.max
:如果不够大,总是有正无穷:
int
具有无限的精度,因此它仅受可用内存的限制。For
float
have a look atsys.float_info
:Specifically,
sys.float_info.max
:If that's not big enough, there's always positive infinity:
int
has unlimited precision, so it's only limited by available memory.sys.maxsize
(以前的sys.maxint
)不是Python支持的最大整数。它是 python 常规整数类型支持的最大整数。sys.maxsize
(previouslysys.maxint
) is not the largest integer supported by python. It's the largest integer supported by python's regular integer type.如果您使用 numpy,则可以使用 dtype 'float128' 并获得最大浮点数 10e+4931
If you are using numpy, you can use dtype 'float128' and get a max float of 10e+4931
在 python 3 中没有 sys.maxint
有一个
sys.maxsize
并不意味着将最大int限制为20亿!
这意味着包含整数的对象的大小最大为 20 亿字节。即一个非常非常大的数字
对于
float
,请查看sys.float_info
,特别是
sys.float_info.max
In python 3 there is no
sys.maxint
There is a
sys.maxsize
That does not mean that the maximum int is limited to 2 billion!
It means that the size of the object containing the integer has a maximum size of 2 billion bytes. I.e. a very very large number
For
float
have a look atsys.float_info
And specifically
sys.float_info.max