I see your 127.32+, a tale of rationals
summary
A Rails betting site requires a zero-sum betting ledger and a three‑field calculator where stake, odds and profit are editable; floating point fails, integers force manual rounding, bigdecimal fails on recurring divisions, so the system uses exact rationals (Ruby rationals + a CoffeeScript rational class) and a Postgres rational type extension for persistence. The result preserves exact arithmetic across UI, app and DB, performs acceptably, and matches business rounding rules.
AI-written summary · about
chapters (7)
- 0:00Betting system problem
- 7:15Floats forbidden for money
- 14:44Integers for exact money
- 22:12Big decimal limitations
- 29:42Rationals as solution
- 35:12Database integration
- 37:00Summary








