decimal-scaled¶
A fast, precise, decimal library.
- Decimal storage — unlike floating point,
1.1is exactly1.1. - Multiple rounding modes — six in total,
HalfToEvenby default. - Up to 4 Kb numbers — twelve widths,
D18toD1232. - Choose your precision at compile time — from 0 to one less than the width. i.e. D1232 can carry a precision of 1231 digits.
no_stdfriendly — the strict, integer-only path needs nostd.- Validated by 71,469,918 value tests — every width × scale × rounding mode.
-
Getting started
Install snippet, the first
D38<2>value, and a tour of the per-width macros. -
Reference
Per-topic reference pages: widths, rounding, conversions, serde, cross-scale operations, glossary.
-
Bench
Per-width speed tables, the precision surface, version history, and the like-for-like library comparison vs the top crates.io peers.
-
Correctness, proven
How the golden harness asserts every answer bit-exact against a multi-oracle set, for every rounding mode, across every shipped width.
-
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.
-
Project
Where the crate is heading, what changed in every release, and how to contribute.
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) |
Builds under no_std + alloc with default-features = false; the strict, integer-only path 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 Comparisons. |