4 ms·
It also helps to only round once. Calculate and save intermediate values. fee = accountX * 0.01 accountY = accountY + fee accountX = accountX - fee
by tedunangst 10y ago
It also helps to only round once. Calculate and save intermediate values.
fee = accountX * 0.01
accountY = accountY + fee
accountX = accountX - fee
vs
accountY = accountY + accountX * 0.01
accountX = accountX * 0.99
I've seen a fair bit of (non financial) accounting go wrong like this, where fractions just slip through the cracks.