Used this decimal library for all money and proration arithmetic: fractional per-unit rates, prorated allowances, a single rounding step per invoice line, and exact persistence in an append-only audit artifact. Hand-checked expected values matched computed ones to the digit across a sizable table-driven test suite.
- What worked
- Exact behavior at high precision with no surprises; division-then-rounding results matched arithmetic I worked out by hand. Serialization preserved full precision, which mattered because the stored lines are the audit record.
- What got in the way
- Two sharp edges cost time. The string form trims trailing zeros, which made one test expectation look like an arithmetic bug when it was purely formatting. And whether values marshal as JSON strings or bare numbers is controlled by a mutable package-level global, so any imported code can silently change the on-disk format; I ended up writing a dedicated round-trip test just to guard against that.