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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// SPDX-FileCopyrightText: 2026 John Moxley
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Narrow-tier (D18 / D38) near-tie Ziv escalation plumbing.
//!
//! The narrow strict kernels evaluate on the 256-bit `Fixed`
//! intermediate at the fixed working scale `w = SCALE + STRICT_GUARD`.
//! A SINGLE-shot narrowing (or, for sin/cos, an
//! escalation hard-capped at the 75-digit `Fixed` constant window)
//! mis-rounds any input whose deciding digit lies below
//! the fixed working scale — the constructible family is an exact
//! rational Taylor partial landing exactly ON a rounding boundary with
//! the transcendental tail below reach (`sin(1e-38)` at D38<38> has its
//! `x³/6` deviation at fraction depth 115; `cosh(1e-19)` lands `x²/2`
//! exactly on the half with the `x⁴/24` tail at depth 77).
//!
//! The fix follows the wide campaign's shape: the fast path keeps the
//! single `Fixed` shot but narrows through
//! [`Fixed::round_to_i128_clear_of_tie`] — residuals clear of the
//! mode's deciding boundary by the near-tie band exit at today's cost —
//! and a near-tie escalates through the SAME generic Ziv walkers the
//! wide tiers run ([`wide_trig_core::round_to_storage_directed_g`] and
//! siblings), recomputing in the wider [`WZiv`] work integer via the
//! width-generic kernels (`trig_generic`, `exp_generic`). `Int<24>`
//! (1536 bits ≈ 462 decimal digits) reaches a probe depth of
//! ~`BITS/8 = 192` digits — comfortably past every constructible
//! narrow-tier deciding depth (≤ `3·38 = 114` for the odd-series
//! deviations, ≤ `2·38 + 2 = 78` for the even-series half families) —
//! so every constructible family resolves before the cap; only the
//! non-constructible Table-Maker's-Dilemma class remains at the cap,
//! the same contract the wide tiers carry at their precision horizon.
//!
//! [`Fixed::round_to_i128_clear_of_tie`]: crate::algos::support::fixed::Fixed::round_to_i128_clear_of_tie
//! [`wide_trig_core::round_to_storage_directed_g`]: crate::algos::support::wide_trig_core::round_to_storage_directed_g
use cratewide_trig_core as wtc;
use crateInt;
use crateRoundingMode;
/// The narrow tiers' near-tie escalation work integer — the same
/// `Int<24>` the integer-regime `exp` fallback
/// (`exp_series_2limb::WNarrow`) already runs in on every build.
pub type WZiv = ;
/// Lifts a raw `i128` storage value to the working scale: `raw · 10^guard`
/// as a signed [`WZiv`]. Total for every `i128` (the magnitude goes
/// through `from_u128`, so `i128::MIN` does not wrap).
pub
/// `π · 10^w`, correctly rounded, at a runtime working scale.
pub
/// `ln 2 · 10^w`, correctly rounded, at a runtime working scale.
pub
/// `ln 10 · 10^w`, correctly rounded, at a runtime working scale.
pub
/// The plain directed/nearest Ziv walker at the narrow storage —
/// `recompute(guard)` returns the kernel value at working scale
/// `scale + guard` in [`WZiv`]. Result-sign-agnostic at the cap (no
/// never-exact tail assumption): the unresolved endgame snaps to the
/// clean base narrowing, which is the correct answer for an EXACTLY
/// boundary-valued input (`powf(4, 0.5)`, `log_4(8)`).
pub
/// The `never_exact` walker — for a kernel whose true value is provably
/// NEVER on a storage grid line (`exp`/`exp2`/`cosh` after their exact
/// pins): an unresolved residual at the cap carries a strictly positive
/// sub-resolution tail. Mirrors the wide `exp`/`cosh` shape.
pub
/// Option-contract wrapper over [`walk`] for the kernels whose overflow
/// contract is a returned `None` (`ln`/`log`/`powf`/`exp`): the walker's
/// range check PANICS past storage, so a near-tie AT the storage extreme
/// (where the walker's ±1 could leave range) keeps the single-shot
/// verdict `base` instead — `base` is the plain rounding of the same
/// working value, and a tie that deep at the extreme is the
/// Table-Maker's-Dilemma residue either way. `base == None` (out of
/// range) propagates.
pub
/// [`walk_checked`] with the `never_exact` polarity (`exp` / `exp2`).
pub
/// The near-special-point walker (`acosh` near 1, `atanh` near ±1):
/// forces a confirm recompute even in the nearest modes. Mirrors the
/// wide `acosh`/`atanh` shape.
pub