else
excess_load = real_load;
- double balance = nb.get_debt() - nb.get_credit();
+ double balance;
+ if (nb.get_credit() > 0.0)
+ balance = nb.get_debt() - nb.get_credit();
+ else
+ balance = nb.get_debt();
load_to_send = std::min(excess_load,
std::max(0.0, balance));