handle numerical rounding problem more gracefully

This commit is contained in:
Christof Petig 2021-03-27 23:46:35 +01:00
parent 79cc3af058
commit 0937761f21

View File

@ -581,7 +581,6 @@ fn trade_at_site(
} else {
debug!("bought {:?} {} {}", *g, paid_amount, *price);
}
good_delivery[*g] += paid_amount;
if economy.stocks[*g] - paid_amount < 0.0 {
info!(
"BUG {:?} {:?} {} TO {:?} OSR {:?} ND {:?}",
@ -592,8 +591,9 @@ fn trade_at_site(
order_stock_ratio,
next_demand[*g]
);
paid_amount = economy.stocks[*g];
}
assert!(economy.stocks[*g] - paid_amount >= 0.0);
good_delivery[*g] += paid_amount;
economy.stocks[*g] -= paid_amount;
}
}