Fixed-size decimal numbers implemented in pure Rust for exact-precision financial and crypto calculations.
fastnum is a Rust library that implements fixed-size decimal numbers with exact precision, designed for financial, cryptocurrency, and other applications requiring accurate fixed-point calculations without rounding errors. It provides high-performance arithmetic operations, support for special values like NaN and Infinity, and avoids dynamic allocation by using fixed-size integer storage.
Rust developers working on financial systems, cryptocurrency applications, trading platforms, or any domain requiring exact decimal precision and high-performance numeric computations.
Developers choose fastnum for its combination of exact precision, high performance (comparable to native types), fixed-size stack allocation, and comprehensive feature set including const evaluation, no_std support, and optional integrations with popular crates like serde and rand.
Fixed-size decimal numbers implemented in pure Rust
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Eliminates rounding errors such as 0.1 + 0.2 = 0.3, which is critical for financial and crypto applications as emphasized in the README's overview.
Uses fixed-size integers to avoid dynamic allocation, making types trivially copyable and improving cache-friendliness, demonstrated in allocation benchmarks where it outperforms bigdecimal.
Supports ±0, ±Infinity, and NaN with standard semantics, enabling robust error handling in mathematical operations as listed in the features.
Most methods are const, allowing compile-time parsing and calculations, enhancing performance and safety for known values, as highlighted in the 'Why fastnum?' section.
The library is pre-1.0.0, so breaking changes in the public API are possible, as warned in the documentation, which could disrupt long-term projects.
Precision is arbitrary but fixed at compile-time and cannot be adjusted dynamically, limiting flexibility compared to arbitrary-precision alternatives like BigDecimal.
Benchmarks show operations like division are significantly slower than native f64, which might impact latency-sensitive applications such as high-frequency trading.