FastDecimal is a pure-Elixir library for arbitrary-precision decimal arithmetic, positioned as a drop-in replacement for the popular `decimal` library with ~10x average speedup (up to 97x for large multiplications). It achieves performance gains through a char-by-char parser, iolist-based string formatting, a pow10 lookup table, allocation-free batch accumulators, and short-circuit comparison clauses — all backed by benchmarks rather than guesswork. A Rust NIF prototype was tested and rejected because NIF dispatch overhead (~36ns) exceeded the cost of a pure-Elixir add (~12ns). The library ships with Ecto integration, a compatibility shim for migrating from `decimal`, 325+ tests including property-based and differential correctness checks, and built-in DoS protection against CVE-2026-32686-class exponent-amplification attacks.

15m read timeFrom github.com
Post cover image
Table of contents
BenchmarksReproduceTest coverageSecurityInstallationFeature surfaceMigrating from decimalEcto integrationDesign philosophyLicense

Sort: