\begin{lemma}
Let $q$ be a signed 64-bit integer with $-342\le q\le308$.  Casting $q$ to
signed 32 bits succeeds.  If
\[
 e_q=\left\lfloor\frac{217706q}{65536}\right\rfloor-q,
 \qquad T_q=2^{127-e_q}5^q,
\]
then the extracted fixed-point exponent routine succeeds and returns
$q+e_q+63$.  Moreover the checked difference $q-(-342)$, its cast to a
64-bit \texttt{usize}, and the corresponding access to the extracted
power-of-five table all succeed.  Writing the accessed pair as $(a_q,b_q)$
and $D_q=a_q2^{64}+b_q$, one has
\[
 2^{127}\le T_q<2^{128}.                                \tag{1}
\]
If $q<0$, there are positive integers $n,z_n$ with $q=-n$ such that
\[
 2^{z_n-1}<5^n<2^{z_n},\qquad
 e_q=-z_n,\qquad T_q=\frac{2^{z_n+127}}{5^n}.             \tag{2}
\]
For the small nonnegative ranges needed below,
\[
 0\le q\le55\Longrightarrow D_q=T_q,qquad
 0\le q\le23\Longrightarrow b_q=0.                     \tag{3}
\]
Finally,
\[
 \begin{array}{ll}
 D_q\le T_q<D_q+1,&q<-27\text{ or }q\ge0,\\
 D_q-1<T_q<D_q,&-27\le q<0.
 \end{array}
\]
\end{lemma}
\begin{proof}
Put $P_0=1$ and $P_{n+1}=5P_n$, so induction gives $P_n=5^n$.
For $n>0$, let $z_n$ be the unique positive integer for which
\[
                     2^{z_n-1}<P_n<2^{z_n}.                 \tag{4}
\]
Both inequalities are strict because the odd integer $5^n>1$ is not a power
of two.  The following recurrence is a finite certificate for the 651 table
entries.  Starting from $P_0$, multiply by five successively to obtain
$P_1,\ldots,P_{342}$ for the negative indices and $P_1,\ldots,P_{308}$ for
the nonnegative indices.  At every multiplication, compare with consecutive
powers of two to obtain the unique $z_n$ in (4).  Define
\[
 D_q=\begin{cases}
 \left\lfloor
   \dfrac{\left\lfloor2^{2z_{-q}+128}/P_{-q}\right\rfloor+1}
         {2^{z_{-q}+1}}
 \right\rfloor,&-342\le q<-27,\\[5pt]
 \left\lfloor2^{z_{-q}+127}/P_{-q}\right\rfloor+1,
      &-27\le q<0,\\[5pt]
 P_q2^{127-(P_q.\mathit{bitLength}-1)},
      &q\ge0\text{ and }P_q<2^{128},\\[3pt]
 \left\lfloor P_q/2^{(P_q.\mathit{bitLength}-1)-127}\right\rfloor,
      &q\ge0\text{ and }P_q\ge2^{128}.
 \end{cases}                                               \tag{5}
\]
All operations in this certificate are multiplication by five, comparison,
shift, and Euclidean division of nonnegative integers.  Dividing each $D_q$
by $B=2^{64}$ gives a quotient and remainder.  Direct recurrence evaluation
gives exactly the pair at index $q+342$ of
\noderef{num_imp_dec2flt_table_POWER_OF_FIVE_128}.  The endpoints and origin,
which also check the alignment, are
\[
\begin{array}{c|c}
q&(a_q,b_q)\\ \hline
-342&(17218479456385750618,1242899115359157055)\\
0&(9223372036854775808,0)\\
308&(10261342003245940623,6273243709394548296).
\end{array}
\]
There are exactly $342+1+308=651$ indices, so the two stated recurrence
passes check every literal and establish $D_q=a_qB+b_q$ throughout the
specified interval.

We next prove the directed bounds, rather than merely trusting the table
generation rule.  For $q=-n<-27$, set $K=2^{z_n+1}$ and divide
$N=2^{z_n+127}$ as $N=kP_n+r$.  Oddness gives $1\le r<P_n$.  The numerator
in the first line of (5) is
\[
 Kk+\left\lfloor Kr/P_n\right\rfloor+1.
\]
By (4), $P_n<K/2$, hence $K/P_n>2$.  Thus
$0\le\lfloor Kr/P_n\rfloor$ and
\[
 \lfloor Kr/P_n\rfloor+1
 \le Kr/P_n+1
 \le K-K/P_n+1<K.
\]
The outer quotient by $K$ is therefore $k$.  Since $0<r<P_n$, this says
$D_q=\lfloor N/P_n\rfloor<T_q=N/P_n<D_q+1$.  For
$-27\le q=-n<0$, the same nondivisibility gives
$D_q=\lfloor N/P_n\rfloor+1=\lceil T_q\rceil$, whence
$D_q-1<T_q<D_q$.  For $q\ge0$, the last two lines of (5) are respectively
the exact normalized integer and its floor, giving
$D_q\le T_q<D_q+1$.

The same 651-step recurrence checks
\[
 65536(q+e_q)\le217706q<65536(q+e_q+1)                    \tag{6}
\]
at every index.  For $q=-n<0$ the candidate used in this check is
$e_q=-z_n$, with $z_n$ from (4).  For $q\ge0$ it is the unique integer
$e_q$ satisfying
\[
                         2^{e_q}\le P_q<2^{e_q+1}.          \tag{7}
\]
At each of the 651 indices, direct integer multiplication verifies the left
comparison in (6) for the recorded $q+e_q$ and the right comparison for its
successor $q+e_q+1$.  Thus Euclidean division by the positive number
$65536$ gives
$e_q=\lfloor217706q/65536\rfloor-q$, including the asserted equality
$e_q=-z_n$ at negative indices.

These same inequalities give all of the additional exported conclusions.
If $q=-n<0$, (4), $e_q=-z_n$, and the definition of $T_q$ give
\[
 T_q=2^{z_n+127}/5^n,\qquad
 2^{127}<T_q<2^{128}.
\]
If $q\ge0$, (7) and $T_q=2^{127-e_q}P_q$ instead give
$2^{127}\le T_q<2^{128}$.  This proves (1) and (2).  For
$0\le q\le55$, direct integer comparison gives
\[
 P_q\le5^{55}=277555756156289135105907917022705078125
 <340282366920938463463374607431768211456=2^{128},
\]
so the third line of (5) applies and is exactly
$D_q=P_q2^{127-e_q}=T_q$.  For $0\le q\le23$, one has
$P_q\le5^{23}=11920928955078125<18014398509481984=2^{54}$;
(7) therefore gives $e_q\le53$.  Hence
$D_q=P_q2^{127-e_q}$ is divisible by $2^{74}$ and in particular by
$2^{64}$.  Since $D_q=a_q2^{64}+b_q$ with $0\le b_q<2^{64}$, uniqueness of
Euclidean remainder gives $b_q=0$.  This proves (3).

Finally unfold \noderef{num_imp_dec2flt_lemire_power}.  The checked constant
addition is $152170+65536=217706$.  On $[-342,308]$ its product with $q$ is
between $-74455452$ and $67053448$, well inside signed 32-bit range, so the
wrapping multiplication has the ordinary integer value.  Arithmetic right
shift by $16$ is division with floor by $65536$, and the final addition of
$63$ is also in range.  Thus it returns $q+e_q+63$ normally.  The cast of
$q$ is in range.  Also $0\le q+342\le650$, so the checked subtraction, the
64-bit \texttt{usize} cast, and access to the length-651 table all succeed.
This establishes every success equation, the normalization and negative-index
representation, both small-range exactness clauses, and both directed
intervals in the statement.
\end{proof}
