"It's all about money, money, money"
summary
Practical rules for handling money: never use floats — use BigDecimal or fixed-point types; prefer store integers for smallest unit (cents/kopecks) unless asset has variable subunits like crypto, where you need higher precision and a configurable scale. Choose rounding per business rule (round fees up, referral payouts down, aggregate high-precision values and round monthly). Persist amounts with correct DB precision, and implement a double-entry ledger with pessimistic locks (or event-sourced accounting) to avoid double-spend and keep books balanced.
AI-written summary · about
chapters (11)
- 0:00Introduction and welcome
- 1:26Fibonacci and money history
- 3:39Representing money in code
- 6:50Floating point money pitfalls
- 9:22Database precision for money
- 11:39Rounding money wisely
- 16:03Banking errors and rounding
- 16:46Double-entry accounting basics
- 21:07Why accounting matters in code
- 21:51Double-entry in Ruby systems
- 23:49Ensure your books balance
related talks
52mHow to Accurately Store Money in a Database
52mHow to Account Money Correctly in a Database
11mThe Value of Objects -
45mBeyond design patterns and principles - writing good OO code
44mWhy 0.1+0.2 != 0.3, or the Mysterious World of Floating-Point Numbers
46mIntegers, Floating Points or Exotic Representations ...
50mAvoiding mistakes with events
50mOne Rule to Rule Them All
