对于第19行,它一直说[<class'minit.overflow'=“”>]。我该如何解决?

时间:2017-12-03 16:56:26

标签: python class decimal overflow

我一直遇到的问题是第19行k = Decimal(e**(k2-k1))

我已经将小数精度设置为8,将E的最大值设置为200.为什么它仍然给我[<class 'decimal.overflow'>]

这是我的代码:

from math import log
from math import e
from decimal import *
getcontext().prec = 8
getcontext().Emax = 200

Ea = range(0,161,5)
Temp = [700,730,760,790,810,840,910,1000]
Yi = [0.011,0.035,0.105,0.343,0.789,2.17,20.0,145]
R = 0.008314
A = 1.1*10**12

for a in Ea:
    kvalues = []
    for x in Temp:
        k1 = (-a/R*x)
        k2 = (log(A,e))
        #k = e**(log(A,e)-(-a/R*x))
        k = Decimal(e**(k2-k1))
        kvalues.append(k)

    sum = 0
    index = 0
    for yi in Yi:
        sum = sum + (yi - kvalues[index])**2
        index = index + 1
    print(sum, a)

0 个答案:

没有答案