1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// SPDX-FileCopyrightText: 2026 John Moxley
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Const-`N` fast-arm divmod wrappers for the fixed-width `Int<N>` types.
//!
//! [`div_rem_mag_fixed`] / [`div_rem_mag_slice`] front the divisor-shape
//! policy [`crate::int::policy::div_rem`], adding the native single-/
//! double-limb fast arms the fixed-width `Int<N>` types lower to.
use cratedispatch as div_rem_dispatch;
/// Const-`N` fast-arm divmod over little-endian u64 magnitude limbs.
///
/// `num`, `den`, `quot`, `rem` are all `N`-limb magnitudes (sign handling
/// is the caller's; this is an unsigned division of the magnitudes). The
/// quotient and remainder are written into `quot` / `rem`.
///
/// Because `N` is a compile-time constant, the `if N == …` ladder
/// const-folds per monomorphisation:
///
/// * `N == 1` lowers to a single native `u64` `/` + `%` (the hardware
/// `idiv`).
/// * `N == 2` widens to native `u128` `/` + `%`.
/// * `N >= 3` falls through to the shared [`div_rem_dispatch`] (Knuth-D /
/// Burnikel–Ziegler).
///
/// All three arms are behaviour-identical: truncating (Euclidean on
/// non-negative magnitudes) division. The divisor must be non-zero (the
/// caller guards this before delegating).
pub
/// Variable-length divmod over little-endian `u64` magnitude slices,
/// routed through the divisor-shape policy so the optimal engine
/// (hardware single-limb / Knuth / Burnikel–Ziegler) is selected at run
/// time. The int-algos-layer entry for callers whose operands have a
/// **runtime live length** that no const-`N` `Int<N>` width can express
/// (the reciprocal-table buffers in
/// [`crate::algos::support::newton_reciprocal`] are the one such caller):
/// it lets them reach the dispatching divmod without importing the
/// `int::policy` layer directly. Fixed-width `Int<N>` callers take
/// [`div_rem_mag_fixed`] instead. The divisor must be non-zero.
pub