Python 中的最大浮点数是多少?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3477283/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 11:16:26  来源:igfitidea点击:

What is the maximum float in Python?

pythonintlong-integermax

提问by ladyfafa

I think the maximum integer in python is available by calling sys.maxint.

我认为 python 中的最大整数可以通过调用sys.maxint.

What is the maximum floator longin Python?

最大值floatlong在 Python 中是多少?

回答by Dave Webb

For floathave a look at sys.float_info:

为了float看看sys.float_info

>>> import sys
>>> sys.float_info
sys.floatinfo(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2
250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsil
on=2.2204460492503131e-16, radix=2, rounds=1)

Specifically, sys.float_info.max:

具体来说,sys.float_info.max

>>> sys.float_info.max
1.7976931348623157e+308

If that's not big enough, there's always positive infinity:

如果这还不够大,总有正无穷大

>>> infinity = float("inf")
>>> infinity
inf
>>> infinity / 10000
inf

The longtype has unlimited precision, so I think you're only limited by available memory.

long类型具有无限精度,因此我认为您仅受可用内存的限制。

回答by GWW

sys.maxint is not the largest integer supported by python. It's the largest integer supported by python's regular integer type.

sys.maxint 不是python支持的最大整数。它是 python 的常规整数类型支持的最大整数。

回答by The Aelfinn

If you are using numpy, you can use dtype'float128' and get a max float of 10e+4931

如果您使用numpy的,你可以使用D型float128”,并得到的最大浮动10E + 4931

>>> np.finfo(np.float128)
finfo(resolution=1e-18, min=-1.18973149536e+4932, max=1.18973149536e+4932, dtype=float128)