// Round a nonnegative amount to the nearest cash increment, resolving exact halves upwards. pub fn cash_rounding(amount: i64, increment: i64) -> i64 { if amount<0 || increment <= 0 { return -1; } let low = amount-amount%increment; if (amount-low)*2 >= increment { return low+increment; } low }