finance
Installation
SKILL.md
Finance & Accounting
Representing money in code
Always store money as integer cents (or smallest currency unit), never as floats.
# BAD — float arithmetic is unpredictable
price = 1.10 + 2.20 # 3.3000000000000003
# GOOD — integers in cents
price_cents = 110 + 220 # 330
# Display
def format_usd(cents: int) -> str:
return f"${cents / 100:,.2f}"
In PostgreSQL: NUMERIC(12, 0) for cents, NUMERIC(14, 2) if you need fractional cents (e.g., per-unit pricing).