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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// SPDX-FileCopyrightText: 2026 John Moxley
// SPDX-License-Identifier: MIT OR Apache-2.0
//! `pow10` — `10^exp` in a work integer, **TABLE-FIRST**.
//!
//! Producing `10^exp` is a one-op "constant generation": the baked POW10
//! table ([`super::table::pow10_limbs`]) holds every in-range power as
//! `&'static [u64]` limbs; beyond the (feature-gated) baked range the
//! square-and-multiply `W::TEN.pow(exp)` is the fallback. The only decision
//! is "is `exp` in the baked range", which the `Option` from a single table
//! lookup already answers — so each door **matches that lookup directly**,
//! with no `select`/`Algorithm` pre-lookup that would only re-fetch the same
//! entry. `const fn`, so a const `exp` folds to the entry and a runtime `exp`
//! is one in-range branch then the single read.
//!
//! Three doors over the one table, by result type:
//!
//! * [`dispatch`] — generic over the work integer `W: BigInt`, `#[inline]`.
//! The everyday door for kernels that hold a `W`: a const-known `exp` folds
//! to the baked entry (zero-extended into `W`) or a const `TEN.pow`; a
//! runtime `exp` is one in-range branch then the single table read.
//! * [`dispatch_int`] — a `const fn` returning `Int<N>`, for the const-`EXP`
//! sites needing a `const { Int::<N>::TEN.pow(EXP) }` value:
//! **table-sourced** while still folding to a compile-time constant.
//! * [`dispatch_i128`] — the narrow-`i128` door for the D18/D38 hardware
//! paths (the value's low one or two limbs).
use crateBigInt;
use crateInt;
/// `10^exp` in the work integer `W`, **table-first**. `#[inline]`: a
/// const-known `exp` folds to the baked entry or a const `W::TEN.pow`; a
/// runtime `exp` is one in-range branch then the single table read. The
/// generic (`W: BigInt`) door — what kernels holding a work integer call.
///
/// Matches the baked entry directly — no `select` pre-lookup that would
/// re-fetch the same entry — mirroring [`dispatch_int`] / [`dispatch_i128`].
pub
/// `10^exp` as `Int<N>`, **table-first**, in a `const fn` — the const-`EXP`
/// door. Replaces `const { Int::<N>::TEN.pow(EXP) }` so the value is sourced
/// from the baked table (Table) rather than recomputed by square-and-multiply
/// (Function) at compile time; out-of-range still folds via the const
/// `Int::<N>::TEN.pow`. Zero-extends the narrowest-fit table limbs into
/// `[u64; N]` (the entry never exceeds `N` for an in-range `10^exp` that fits
/// `Int<N>`).
pub const
/// `10^exp` as `i128`, **table-first** — the narrow-`i128` door for the
/// D18/D38 hardware paths. Sources the value from the baked table (its low
/// one or two u64 limbs) when in range, else the const `10i128.pow(exp)`.
/// `const fn`, so a const `exp` folds. Valid only where `10^exp` fits `i128`
/// (`exp <= 38`), which every narrow caller guarantees; a larger `exp`
/// overflows exactly as the original `10i128.pow(exp)` did.
pub const