decimal-scaled¶
Const-generic base-10 fixed-point decimals — thirteen widths from D9 to D1231 — with ≤ 0.5 ULP correctly-rounded integer-only transcendentals. Deterministic across every platform. no_std-friendly. Caller-chosen rounding mode at every lossy operation.
-
Getting started
Install snippet, the first
D38<2>value, and a tour of the per-width macros. -
Usage guides
Per-topic deep-dives: widths, scales, strict-vs-fast routing, rounding, macros, Cargo features.
-
Benchmarks
Per-width speed tables plus the §5 like-for-like library comparison vs the top crates.io peers.
-
API reference
Rustdoc for every type, trait, method, and Cargo feature across every supported width.
-
Algorithms
Möller–Granlund magic-multiply, artanh-series transcendentals, Cody-Waite range reduction - the catalogue of techniques the crate uses and why.
-
Roadmap
The wide-tier
÷ 10^SCALE,mul, and transcendental-throughput gaps and the planned algorithmic fix per item. -
Changelog
What changed in every release.
Why decimal-scaled¶
| You need… | decimal-scaled gives you… |
|---|---|
Decimal arithmetic that doesn't drift (0.1 + 0.2 == 0.3) |
Base-10 storage; exact + - %, correctly-rounded * /. |
| Bit-identical results across Linux / macOS / Windows / ARM / x86 | *_strict transcendentals - integer-only, no platform libm. |
| Compile-time-fixed precision with zero per-value scale byte | Const-generic D38<19>, D76<35> etc. - scale is in the type. |
no_std (or no_std + alloc) |
Default features build under no_std; the strict tier needs no libm. |
≤ 0.5 ULP correctly-rounded ln / exp / sin / cos / tan / sqrt / atan / sinh / cosh / tanh and friends — by default |
At every shipped width, HalfToEven by default, bit-identical across every platform. Switch rounding mode per call via *_with(mode) or crate-wide via the rounding-* features. See Benchmarks §5. |
What it isn't¶
For runtime-variable scale, look at rust_decimal. For arbitrary precision at runtime, look at bigdecimal or dashu-float. For binary fixed-point (DSP, embedded radio), look at fixed. decimal-scaled is for the case where you want decimal, compile-time-fixed, and deterministic - all three.