FastDecimal v1.0.0 is a pure-Elixir arbitrary-precision decimal arithmetic library designed as a drop-in replacement for the popular `decimal` package. It targets fintech, ledger, and pricing hot paths, achieving a geometric mean speedup of ~10× (JIT) to ~8× (interpreter) over `decimal` across 22 benchmark scenarios. Key design choices include a char-by-char parser, iolist-based string formatting, and allocation-free batch accumulators. A Rust NIF prototype was benchmarked and rejected because NIF dispatch overhead (~36 ns) exceeded the cost of a pure-Elixir add (~12 ns). The library ships with Ecto integration, a compatibility shim for easy migration, 325+ tests including property-based and differential correctness checks, and built-in DoS protection against CVE-2026-32686-class exponent-amplification attacks. Notable regressions: `to_string :scientific` is 0.76× slower than `decimal`.

13m read timeFrom hexdocs.pm
Post cover image
Table of contents
BenchmarksReproduceTest coverageSecurityInstallationFeature surfaceMigrating from decimalEcto integrationDesign philosophyLicense

Sort: