某些数字的Python计算问题

问题描述 投票:1回答:1

我正在使用Odoo 10,并且在使用Python计算时遇到了一些舍入问题。例如:我的公式是:

a = 224.689511
b = 195.382186
c = 1000

return round((a - b) * c, 2)

返回值为29307.32但是正确的值为29307.33

四舍五入前的值为29307.324999999997,但应为29307.325

这种情况有解决方案吗?

python odoo-10
1个回答
0
投票

[29307.325舍入为29307.33,因为您只需要小数点后两位]

© www.soinside.com 2019 - 2024. All rights reserved.