Splitting 33.33 + 33.33 = $99.99: a cent disappears. Financial code must allocate amounts exactly.
Implement with decimal.Decimal (never floats):
to_cents(amount): convert a string like "12.345" to integer cents using banker's rounding (ROUND_HALF_EVEN): "0.125" → 12 and "0.135" → 14allocate(total_cents, weights): split integer cents in proportion to weights (ints or Decimals). Round each share down, then hand out the leftover cents one at a time to the shares with the largest remainders (ties: earlier index). The shares must sum exactly to the total.format_cents(c): "$1,234.50" style, with a leading - for negatives ("-$0.05")