Python OverflowError: math range error

Python OverflowError: math range error

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

output=math.exp(1391.12694245)*100

我知道会发生这种情况,因为使用的数字是 'outside the range of a double'。 但是有什么办法可以解决这个问题并获得输出值。 有人可以帮忙吗?

使用 numpy 中的超精度浮点数:

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