python 浮點數計算的問題

原來沒太注意浮點數計算會有問題,記錄下 運行結果: from decimal import Decimal def calc(a,b): c = 2*(a+b) s = a*b print(c, s, sep='____________') calc(Decimal('1.5'),Decimal('2.3')) calc(1.5,2.3)7.6____________3
相關文章
相關標籤/搜索