Announcing a new fast, exact precision decimal numbers crate `fastnum`
I have just finished making decimal library in Rust, fastnum.
It provides signed and unsigned exact precision decimal numbers suitable for financial calculations that require significant integral and fractional digits with no round-off errors (such as 0.1 + 0.2 ≠ 0.3).
Additionally, the crate can be used in no_std environments.
Why fastnum?
- Strictly exact precision: no round-off errors.
- Special values:
fastnumsupport±0,±InfinityandNaNspecial values with IEEE 754 semantic. - Blazing fast:
fastnumnumerics are as fast as native types, well almost :). - Trivially copyable types: all
fastnumnumerics are trivially copyable and can be stored on the stack, as they're fixed size. - No dynamic allocation: no heap allocations are made when creating or performing operations on an integer, no expensive sys-call's, no indirect addressing, cache-friendly.
- Compile-time integer and decimal parsing: all the
from_*methods areconst, which allows parsing numerics from string slices and floats at compile time. Additionally, the string to be parsed does not have to be a literal: it could, for example, be obtained viainclude_str!, orenv!. - Const-evaluated in compile time macro-helpers: any type has its own macro helper which can be used for definitions of constants or variables whose value is known in advance. This allows you to perform all the necessary checks at the compile time.
no-stdcompatible:fastnumcan be used inno_stdenvironments.constevaluation: nearly all methods defined onfastnumdecimals areconst, which allows complex compile-time calculations and checks.
Other functionality (such as serialization and deserialization via the serde, diesel and sqlx ORM's support) can be enabled via crate features.
Feedback on this here or on GitHub is welcome! Thanks!