我们使用十进制数来存储值。 我有一个简单的公式:价格*数量*百分比/100
def round_value(value):
x = math.floor(value)
if (value - x) < .50:
return x
else:
return math.ceil(value)
def calculate_reward(price, quantity, percent):
return round_value(price * quantity * percent / 100*)
所以就我而言,我的价值观是:
calculate_reward(Decimal(77), 2, 87)
在本地机器上我有:134
在服务器上:130
我什至不知道为什么服务器上会出现这种行为。 有谁知道吗?