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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// SPDX-FileCopyrightText: 2026 John Moxley
// SPDX-License-Identifier: MIT OR Apache-2.0

//! `sub_int_layer` — decimal subtraction via the `Int<N>` layer.

use crate::int::types::Int;

/// Decimal subtraction via the `Int<N>` layer. Panics on overflow in BOTH
/// debug and release — a fixed-width decimal has no ±∞/NaN and silently
/// returning a wrapped value is a wrong number with no signal, so the
/// default operator fails loudly (the explicit `wrapping_sub` /
/// `checked_sub` / `saturating_sub` / `overflowing_sub` variants carry the
/// modular / `None` / clamp / flag policies). No rescaling needed —
/// same-SCALE operands share the scale factor.
#[inline]
pub(crate) fn sub_int_layer<const N: usize>(a: Int<N>, b: Int<N>) -> Int<N> {
    a.checked_sub(b).expect("attempt to subtract with overflow")
}