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

//! Shared support kernels consumed across the algorithm families.
//!
//! Unlike the per-family trees (`algos::sqrt`, `algos::ln`, …) these are
//! not tied to one mathematical family; they are the cross-cutting
//! building blocks the families and the arithmetic layer share:
//!
//! - [`rescale`] — the `÷ 10^SCALE` policy matcher: one `const fn` classifier
//!   ([`rescale::select`]) behind a slice door and a typed door, selecting
//!   between the MG and Newton kernels below.
//! - [`mg_divide`] — the Moller-Granlund magic-number divide used by
//!   every multiplicative `÷ 10^SCALE` rescale path.
//! - [`fixed`] — the 256-bit sign-magnitude `Fixed` work integer the
//!   strict-transcendental fallback paths evaluate their series in.
//! - [`newton_reciprocal`] — the Newton-Raphson reciprocal divide for
//!   `n / 10^SCALE` at the wide tiers. A kept-alt: [`rescale`] holds the
//!   `Newton` arm but does not currently select it (uncached Newton is
//!   dominated by the MG chain, 9.18.2); kept for a baked-`r` revival.

pub(crate) mod fixed;
pub(crate) mod mg_divide;
// Narrow-tier (D18/D38) near-tie Ziv escalation plumbing: the WZiv work
// integer + thin walker bindings the narrow strict kernels escalate
// through when a `Fixed` single shot lands inside the near-tie band.
pub(crate) mod narrow_ziv;
pub(crate) mod rescale;

// Typed-`W` Newton-root seed bridge over the cross-algorithm seed leaf
// (`algo_x_support::seed`). Used by the wide fixed-point `sqrt` kernel,
// which needs the over-estimate seed (not the final floor root) to start
// its own scaled Newton loop. The floor-root surface itself is
// `W::isqrt` / `W::icbrt`.
pub(crate) mod seed_bridge;

// Tier-generic surface over the per-tier wide guard-digit cores. The
// `WideTrigCore` trait + six `*_series` functions collapse the 60
// per-tier `*_strict_<tier>` wrappers in `algos::{exp,ln,trig}::wide_kernel`
// to one generic function per transcendental. Always compiled; the
// per-tier `impl WideTrigCore` blocks are emitted by
// `decl_wide_transcendental!`.
pub(crate) mod wide_trig_core;

// Baked binary Tang `ln(1 + i/M)` lookup table (`M = 128`) + the
// width-generic accessor that slices a slot to the tier's needed binary
// precision and reconstructs `round(ln(1+i/M) · 10^w)` at working scale
// `w`. Replaces the per-call `ln_fixed` Series recompute in the wide
// `ln` Tang kernel. Generated by `scripts/gen_ln_tang_table.py` (mpmath
// oracle), committed, NOT built at build time (`build.rs` untouched).
// Gated to `_wide-support`: only the wide tiers (D57..D1232) carry the
// Tang `ln` path; the narrow tiers (D18/D38) never reach it.
#[cfg(feature = "_wide-support")]
pub(crate) mod ln_tang_table;

// Baked binary Tang `(sin(c_j), cos(c_j))` lookup table (`M = 512`) + the
// width-generic accessor that slices each component to the tier's needed
// binary precision and reconstructs `round(value · 10^w)` at working
// scale `w`. Replaces the per-call `sin_cos_fixed` Series recompute in
// the wide trig Tang kernel. Generated by
// `scripts/gen_sincos_tang_table.py` (mpmath oracle), committed, NOT
// built at build time (`build.rs` untouched). Gated to `_wide-support`:
// only the wide tiers carry the Tang trig path; the narrow tiers
// (D18/D38) never reach it.
#[cfg(feature = "_wide-support")]
pub(crate) mod sincos_tang_table;
// Baked binary Tang `exp(j · ln2 / M)` lookup table (single `M = 512`
// table; the `M = 128` tier D57 reads index `4·j`) + the width-generic
// accessor that slices a slot to the tier's needed binary precision and
// reconstructs `round(exp(j·ln2/M) · 10^w)` at working scale `w`.
// Replaces the per-call `exp_fixed` Series recompute in the wide `exp`
// Tang kernel. Each slot stores the FRACTIONAL part `exp(j·ln2/M) − 1`
// (a pure fraction, like the ln pilot); the integer `1` is re-added at
// convert time. Generated by `scripts/gen_exp_tang_table.py` (mpmath
// oracle), committed, NOT built at build time (`build.rs` untouched).
// Gated to `_wide-support`: only the wide tiers (D57..D1232) carry the
// Tang `exp` path; the narrow tiers (D18/D38) never reach it.
#[cfg(feature = "_wide-support")]
pub(crate) mod exp_tang_table;

// Baked binary Tang `atan(c_j)` lookup table (`M = 512`) + the
// width-generic accessor that slices a slot to the tier's needed binary
// precision and reconstructs `round(atan(j/M) · 10^w)` at working scale
// `w`. Replaces the per-call `atan_fixed` halving-chain Series recompute
// in the D57 atan Tang kernel (`algos::trig::atan_tang_3limb_s44_56`),
// which the samply probe showed accounted for ~74% of that kernel's
// time. Generated by `scripts/gen_atan_tang_table.py` (mpmath oracle),
// committed, NOT built at build time (`build.rs` untouched). Gated to
// `_wide-support`: only the wide tiers carry the Tang atan path; the
// narrow tiers (D18/D38) never reach it.
#[cfg(feature = "_wide-support")]
pub(crate) mod atan_tang_table;

// Newton-Raphson reciprocal divide for `n / 10^SCALE` at the wide tiers.
// Always compiled: the unified `decl_decimal_arithmetic!` mul/div path
// used by D18/D38 (default features) references the dispatcher in a
// const-folded `SCALE > 38` branch — dead for the narrow tiers but still
// type-checked. The kernels are generic over `Int<N>`, so this adds
// compile time, not a feature.
pub(crate) mod newton_reciprocal;