Python RuntimeWarning:long_scalars中遇到溢出

时间:2019-08-02 00:09:28

标签: python runtime-error

我正在尝试执行以下代码:

K_1 = [(-1, 196), (1, 197), (-1, 210), (Fraction(1, 15), 14)]

r_1, r_2 = 0, 0
for i in range(1, len(K_1)):
    if K_1[i][0] < 0:
        r_1 += Fraction(K_1[i][0], -1 * K_1[i][1])  #alpha in alpha
    else:
        r_2 += Fraction(K_1[i][0], -1 *  K_1[i][1]) #beta in alpha

我收到以下警告消息:

RuntimeWarning: overflow encountered in long_scalars
  return Fraction(a.numerator * db + b.numerator * da,

RuntimeWarning: overflow encountered in long_scalars
  da * db)

0 个答案:

没有答案