python - 获取溢出错误 : math range error(trying to calculate power of a number)

标签 python math

<分区>

我正在尝试找到表达式的确切数字。我找不到它。下面是我试过的代码片段。

>>> math.pow(400.0,math.pow(400.0,400.0))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: math range error

当我尝试使用 numpy 时,我变得像:

>>> np.power(400.0,np.power(400.0,400.0))
>>> inf

但我无法得到确切的数字。谁能帮我解决这个问题。这对我有很大的帮助。

提前致谢。

最佳答案

您尝试计算的数字有 1.735057357739408×10^1041 个十进制数字(来自 wolframalpha )。您肯定无法获得它的确切表示。 inf 与您将要达到的一样接近。

关于python - 获取溢出错误 : math range error(trying to calculate power of a number),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22400801/

相关文章:

python - 展平 python 中的嵌套有序字典列表

python - 比较两个列表以返回一个列表,其中所有元素都为 0,但保持索引匹配的元素除外?

C# 将幅度/相位转换为实数/虚数

math - TI-84 Basic 可以处理 n 阶导数吗?

algorithm - 如何有效地测试任意多边形是否与正方形相交?

algorithm - 像 Exposé 中那样定位框

Python 与 Scala(用于 Spark 作业)

python - 在 Python 中将 32 位整数转换为四个 8 位整数的数组

python - 如何从 Python 中的数组中选择随机元素?

颜色动画的 jQuery 数学 - 特定颜色范围