Why Banks Using NestJS Must Never Store Money as Floating-Point Numbers
A mid-sized bank's finance officer discovered a recurring reconciliation discrepancy that took engineers two days to investigate, only to find no single bug or breach was responsible. The root cause traced back to an early architectural decision to represent monetary values using standard floating-point numbers, which cannot store certain decimal values exactly. JavaScript's floating-point format, while suitable for scientific computing, silently accumulates tiny rounding errors when used for currency calculations across millions of transactions. To prevent such drift, engineers building financial systems in NestJS are advised to enforce three layers of protection: validating amounts as decimal strings at the DTO level, storing values in fixed-precision numeric database columns, and using dedicated decimal arithmetic libraries for all calculations. The article argues that this single design choice — how money is represented internally — determines whether a financial system can maintain long-term numerical accuracy.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in