Python 溢出错误 : math range error

标签 python math overflow

尝试此计算时出现溢出错误,

output=math.exp(1391.12694245)*100

我知道发生这种情况是因为使用的数字“超出了 double 范围”。 但是有什么办法可以解决这个问题并获得输出值。 有人可以帮忙吗?

最佳答案

使用 numpy 中的超精度 float :

import numpy as np
np.exp(np.array([1391.12694245],dtype=np.float128))*100
# array([ 1.4413011e+606], dtype=float128)

关于Python 溢出错误 : math range error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42524679/

相关文章:

python - 如何缓存分页的 Django 查询集

C++ TTmath : Power of?

javascript - 溢出:隐藏在 firefox 3.6 中

Python threading.Condition.notify_all() 不触发下一个线程

python - Python XML解析和生成中<foo/>和<foo></foo>的区别

java - 数组值未按预期工作

php - PHP数据表的 overflow hidden

html - 图像调整到最大高度但页面溢出

python - 如何使菜单对于 openerp 7 中特定组下的用户不可见?

c - 这个数学舍入函数是如何工作的?