问题描述
在python中,当计算大量(整数或浮点数)时,该数字似乎将以科学计数法存储,因此会变得不准确。 例如
>>> rst = 15
>>> dst = [10,14,10,14]
>>> [float(dst[i])*float(rst)**float(i) for i in range(len(dst))]
[10.0,210.0,2250.0,47250.0,506250.0,10631250.0,113906250.0,2392031250.0,25628906250.0,538207031250.0,5766503906250.0,121096582031250.0,1297463378906250.0,2.724673095703125e+16]
>>> # please note the last element is stored in scientific notation
>>> # but if calculate 14*15**13 (same as how the last element is calculated)
>>> 14*15**13
>>> 27246730957031250
>>> # result is fine
>>> 14*15**13 == dst[-1]
>>> False
我应该如何在python大数计算中抑制科学计数法
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)