Integers in python are supposed to be unlimited but I'm getting OverflowError: (34, 'Result too large')

Integers in python are supposed to be unlimited but I'm getting OverflowError: (34, 'Result too large')

我遇到了溢出问题,但我不确定为什么,因为整数在 pytho 中应该是无限的。 问题发生在最后一行。 溢出错误:(34,'Result too large')。

temperature_planet = 200
temperature_atmosphere = 250

epsilon = 0.25
dt = 60*10
heat_capacity = 1E5
insolation = 1370
sigma = 5.67E-8
planet_radius = 6.4E6
while True:
        temperature_planet += dt*(circle*insolation + sphere* epsilon*sigma* temperature_atmosphere**4 - sphere*sigma*temperature_planet**4)/heat_capacity

如果我尝试用 decimal.Decimal 初始化 temperature_planet,我得到:
类型错误:* 不支持的操作数类型:'float' 和 'decimal.Decimal'

这是因为您使用 python2 而不是 python3 进行编译。

检查另一个问题:Maximum and Minimum values for ints

您正在使用各种浮点数...epsilonheat_capacitysigmaplanet_radius...

你的表情,

dt*(circle*insolation + sphere* epsilon*sigma* temperature_atmosphere**4 - sphere*sigma*temperature_planet**4)/heat_capacity

永远是一个浮点数。为什么您会有其他期望?