看板 Python 關於我們 聯絡資訊
我剛才在 Spyder 的 iPython console 做簡單的加法,會出現浮點數錯誤。 請問這個計算誤差要如何避開或消除?謝謝。 In [5]: 0.86 + 3.2 Out[5]: 4.0600000000000005 In [6]: 3.86 + 0.2 Out[6]: 4.06 https://imgur.com/XpcRrka -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.229.98.97 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1604303603.A.61F.html
oToToT: 改用decimal? 11/02 16:13
aidansky0989: 這很正常,高精度浮點計算要Decimal 11/02 19:38
jackyhobingo: ieee754可以了解一下 11/09 13:20