decimal-scaled 0.5.0

Const-generic base-10 fixed-point decimals (D18/D38/D76/D153/D307 and the half-width tiers up to D1232) with integer-only transcendentals correctly rounded to within 0.5 ULP — exact at the type's last representable place. Deterministic across every platform; no_std-friendly.
Documentation
// SPDX-FileCopyrightText: 2026 John Moxley
// SPDX-License-Identifier: MIT OR Apache-2.0

//! Algorithm library for numerical kernels.
//!
//! Self-contained algorithm implementations grouped by mathematical
//! family. Each kernel is a free function that takes the **raw storage
//! integer** plus runtime parameters (scale, rounding mode, …) and
//! returns a raw storage integer. None of them know about the typed
//! `Dxx<S>` wrapper; that lives in the type's method shell.
//!
//! # Why a separate algorithm library
//!
//! Three properties we want:
//!
//! 1. **Direct benchability.** A kernel is a function, not a method on
//!    a typed value; benchmarks can call it head-to-head against an
//!    alternative without going through the type wrapper.
//! 2. **Replaceable per (width, scale).** The choice of which kernel a
//!    given `Dxx<S>` uses lives in `crate::policy`, not in the type's
//!    method body. Swapping the chosen winner for a single cell is a
//!    one-line change in the policy file.
//! 3. **Multiple implementations side-by-side.** Newton vs Goldschmidt
//!    sqrt, Taylor vs AGM ln, lookup-table-bootstrapped vs
//!    cold-start — they coexist in this tree, ready to be promoted by
//!    a policy override.
//!
//! # Layout
//!
//! `algos::<family>::<variant>` — `algos::sqrt::sqrt_newton`,
//! `algos::sqrt::sqrt_mg_divide`, `algos::ln::taylor`, etc. The
//! `<variant>` name describes the algorithm, not the type that uses
//! it; one variant may serve many cells.

// `sqrt` / `cbrt` are unconditional — the narrow tier (D18/D38)
// kernels in `<family>::<family>_mg_divide` are always built; each
// wide-tier kernel inside `<family>::generic_wide` is independently
// feature-gated.
// Decimal arithmetic algorithm families — each operation, even the
// trivial `Int<N>`-layer ones, is a named `<fn>_<method>` kernel under
// `algos::<fn>/`, called *down* from the per-function policy matcher.
pub(crate) mod add;
pub(crate) mod cbrt;
pub(crate) mod div;
pub(crate) mod exp;
pub(crate) mod hypot;
pub(crate) mod ln;
pub(crate) mod log;
pub(crate) mod mul;
pub(crate) mod neg;
pub(crate) mod pow;
pub(crate) mod rem;
pub(crate) mod sqrt;
pub(crate) mod sub;
pub(crate) mod trig;

// Cross-cutting support kernels consumed by multiple families and the
// arithmetic layer: the Moller-Granlund magic-number divide
// (`support::mg_divide`), the 256-bit sign-magnitude `Fixed` work
// integer (`support::fixed`), and the Newton-Raphson reciprocal
// divide (`support::newton_reciprocal`).
pub(crate) mod support;

// Unit tests for the schoolbook baselines (add/sub/neg/rem/mul/div).
#[cfg(test)]
mod schoolbook_tests;