2017-09-03 104 views
-1

我有一個非常奇怪的零除法錯誤。我的代碼Cython浮點除法錯誤:零分(數字太大或太小?)

from numpy import pi 
cdef double a0 = 0.02 
cdef double c = 2.998e8 
cdef double me = 9e-31 
cdef double s = 50.0 
cdef L = 800e-9 
cdef q = 1.602e-19 
cdef double E1=(a0*c*me*s*L*sqrt(pi))/(q*(1.602*10**(-13))*sqrt(2.0)) #some code 

但是它給出了一個

ZeroDivisionError: float division 

儘管他們都是雙打。這些數字對於雙數據類型來說太大還是小兩個?我在python shell中測試了這個計算,沒有錯誤。 在此先感謝您的幫助和/或建議。

回答

0
cdef double E1=(a0*c*me*s*L*sqrt(pi))/(q*(1.602*10**(-13))*sqrt(2.0)) #some code 

cdef double E1=(a0*c*me*s*L*sqrt(pi))/(q*(1.602*10.0**(-13))*sqrt(2.0)) #some code 

即變化10〜10.0

相關問題