[latex3-commits] [l3svn] r6968 - Some more removals of integers

noreply at latex-project.org noreply at latex-project.org
Mon Feb 20 17:08:44 CET 2017


Author: bruno
Date: 2017-02-20 17:08:44 +0100 (Mon, 20 Feb 2017)
New Revision: 6968

Modified:
   trunk/l3kernel/l3fp-aux.dtx
   trunk/l3kernel/l3fp-round.dtx
   trunk/l3kernel/l3skip.dtx
Log:
Some more removals of integers


Modified: trunk/l3kernel/l3fp-aux.dtx
===================================================================
--- trunk/l3kernel/l3fp-aux.dtx	2017-02-20 14:51:30 UTC (rev 6967)
+++ trunk/l3kernel/l3fp-aux.dtx	2017-02-20 16:08:44 UTC (rev 6968)
@@ -784,7 +784,8 @@
 %   The arguments are as follows: |#1| indicates which function is
 %   being defined; after one step of expansion, |#2| yields the
 %   \enquote{extra digits} which are then converted by
-%   \cs{@@_round_digit:Nw} to the \meta{rounding} digit.
+%   \cs{@@_round_digit:Nw} to the \meta{rounding} digit (note the |+|
+%   separating blocks of digits to avoid overflowing \TeX{}'s integers).
 %   This triggers the \texttt{f}-expansion of
 %   \cs{@@_decimate_pack:nnnnnnnnnnw},\footnote{No, the argument
 %     spec is not a mistake: the function calls an auxiliary to
@@ -823,21 +824,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}[EXP, aux]
-%   {\@@_round_digit:Nw, \@@_decimate_pack:nnnnnnnnnnw}
-%   %   ^^A \cs{@@_round_digit:Nw} moved to \pkg{l3fp-round}.
-%   \cs{@@_round_digit:Nw} will receive the \enquote{extra digits}
-%   as its argument, and its expansion is triggered by \cs{__int_value:w}.
-%   If the first digit is neither $0$ nor $5$, then it is the \meta{rounding}
-%   digit.  Otherwise, if the remaining digits are not all zero, we need
-%   to add $1$ to that leading digit to get the rounding digit. Some caution
-%   is required, though, because there may be more than $10$
-%   \enquote{extra digits}, and this may overflow \TeX{}'s integers.
-%   Instead of feeding the digits directly to \cs{@@_round_digit:Nw},
-%   they come split into several blocks, separated by $+$. Hence the first
-%   \cs{__int_eval:w} here.
-%    \begin{macrocode}
-%    \end{macrocode}
+% \begin{macro}[EXP, aux]{\@@_decimate_pack:nnnnnnnnnnw}
 %   The computation of the \meta{rounding} digit leaves an unfinished
 %   \cs{__int_value:w}, which expands the following functions. This
 %   allows us to repack nicely the digits we keep. Those digits come

Modified: trunk/l3kernel/l3fp-round.dtx
===================================================================
--- trunk/l3kernel/l3fp-round.dtx	2017-02-20 14:51:30 UTC (rev 6967)
+++ trunk/l3kernel/l3fp-round.dtx	2017-02-20 16:08:44 UTC (rev 6968)
@@ -106,16 +106,16 @@
 % (but there is not interface for that yet).
 %
 % The rounding tools available in this module are many variations on a
-% base function \cs{@@_round:NNN}, which expands to \cs{c_zero} or
-% \cs{c_one} depending on whether the final result should be rounded up
+% base function \cs{@@_round:NNN}, which expands to |0\exp_stop_f:| or
+% |1\exp_stop_f:| depending on whether the final result should be rounded up
 % or down.
 % \begin{itemize}
 %   \item \cs{@@_round:NNN} \meta{sign} \meta{digit_1} \meta{digit_2}
-%     can expand to \cs{c_zero} or \cs{c_one}.
+%     can expand to |0\exp_stop_f:| or |1\exp_stop_f:|.
 %   \item \cs{@@_round_s:NNNw} \meta{sign} \meta{digit_1} \meta{digit_2}
-%     \meta{more digits}|;| can expand to |\c_zero ;| or |\c_one ;|.
+%     \meta{more digits}|;| can expand to |0\exp_stop_f:;| or |1\exp_stop_f:;|.
 %   \item \cs{@@_round_neg:NNN} \meta{sign} \meta{digit_1} \meta{digit_2}
-%     can expand to \cs{c_zero} or \cs{c_one}.
+%     can expand to |0\exp_stop_f:| or |1\exp_stop_f:|.
 % \end{itemize}
 % See implementation comments for details on the syntax.
 %
@@ -135,8 +135,8 @@
 %   \end{syntax}
 %   If rounding the number $\meta{final sign}
 %   \meta{digit_1}.\meta{digit_2}$ to an integer rounds it towards zero
-%   (truncates it), this function expands to \cs{c_zero}, and otherwise
-%   to \cs{c_one}.  Typically used within the scope of an
+%   (truncates it), this function expands to |0\exp_stop_f:|, and otherwise
+%   to |1\exp_stop_f:|.  Typically used within the scope of an
 %   \cs{__int_eval:w}, to add~$1$ if needed, and thereby round
 %   correctly.  The result depends on the rounding mode.
 %
@@ -145,9 +145,9 @@
 %   rounding towards~$-\infty$ or towards~$+\infty$. Also recall that
 %   \meta{final sign} is~$0$ for positive, and~$2$ for negative.
 %
-%   By default, the functions below return \cs{c_zero}, but this is
+%   By default, the functions below return |0\exp_stop_f:|, but this is
 %   superseded by \cs{@@_round_return_one:}, which instead returns
-%   \cs{c_one}, expanding everything and removing \cs{c_zero} in the
+%   |1\exp_stop_f:|, expanding everything and removing |0\exp_stop_f:| in the
 %   process.  In the case of rounding towards~$\pm\infty$ or
 %   towards~$0$, this is not really useful, but it prepares us for the
 %   \enquote{round to nearest, ties to even} mode.
@@ -163,25 +163,25 @@
 %   or up towards $+\infty$.
 %    \begin{macrocode}
 \cs_new:Npn \@@_round_return_one:
-  { \exp_after:wN \c_one \exp:w }
+  { \exp_after:wN 1 \exp_after:wN \exp_stop_f: \exp:w }
 \cs_new:Npn \@@_round_to_ninf:NNN #1 #2 #3
   {
     \if_meaning:w 2 #1
-      \if_int_compare:w #3 > \c_zero
+      \if_int_compare:w #3 > 0 \exp_stop_f:
         \@@_round_return_one:
       \fi:
     \fi:
-    \c_zero
+    0 \exp_stop_f:
   }
-\cs_new:Npn \@@_round_to_zero:NNN #1 #2 #3 { \c_zero }
+\cs_new:Npn \@@_round_to_zero:NNN #1 #2 #3 { 0 \exp_stop_f: }
 \cs_new:Npn \@@_round_to_pinf:NNN #1 #2 #3
   {
     \if_meaning:w 0 #1
-      \if_int_compare:w #3 > \c_zero
+      \if_int_compare:w #3 > 0 \exp_stop_f:
         \@@_round_return_one:
       \fi:
     \fi:
-    \c_zero
+    0 \exp_stop_f:
   }
 \cs_new:Npn \@@_round_to_nearest:NNN #1 #2 #3
   {
@@ -194,7 +194,7 @@
         \fi:
       \fi:
     \fi:
-    \c_zero
+    0 \exp_stop_f:
   }
 \cs_new:Npn \@@_round_to_nearest_ninf:NNN #1 #2 #3
   {
@@ -207,14 +207,14 @@
         \fi:
       \fi:
     \fi:
-    \c_zero
+    0 \exp_stop_f:
   }
 \cs_new:Npn \@@_round_to_nearest_zero:NNN #1 #2 #3
   {
     \if_int_compare:w #3 > \c_@@_five_int
       \@@_round_return_one:
     \fi:
-    \c_zero
+    0 \exp_stop_f:
   }
 \cs_new:Npn \@@_round_to_nearest_pinf:NNN #1 #2 #3
   {
@@ -227,7 +227,7 @@
         \fi:
       \fi:
     \fi:
-    \c_zero
+    0 \exp_stop_f:
   }
 \cs_new_eq:NN \@@_round:NNN \@@_round_to_nearest:NNN
 %    \end{macrocode}
@@ -239,9 +239,9 @@
 %     \cs{@@_round_s:NNNw} \meta{final sign} \meta{digit} \meta{more digits} |;|
 %   \end{syntax}
 %   Similar to \cs{@@_round:NNN}, but with an extra semicolon, this
-%   function expands to |\c_zero ;| if rounding $\meta{final sign}
+%   function expands to |0\exp_stop_f:;| if rounding $\meta{final sign}
 %   \meta{digit}.\meta{more digits}$ to an integer truncates, and to
-%   |\c_one ;| otherwise.  The \meta{more digits} part must be a digit,
+%   |1\exp_stop_f:;| otherwise.  The \meta{more digits} part must be a digit,
 %   followed by something that does not overflow a \cs{int_use:N}
 %   \cs{__int_eval:w} construction.  The only relevant information about
 %   this piece is whether it is zero or not.
@@ -255,7 +255,7 @@
       \if_int_odd:w 0 \if_meaning:w 0 #3 1 \fi:
                       \if_meaning:w 5 #3 1 \fi:
                 \exp_stop_f:
-        \if_int_compare:w \__int_eval:w #4 > \c_zero
+        \if_int_compare:w \__int_eval:w #4 > 0 \exp_stop_f:
           1 +
         \fi:
       \fi:
@@ -277,11 +277,11 @@
 %    \begin{macrocode}
 \cs_new:Npn \@@_round_digit:Nw #1 #2;
   {
-    \if_int_odd:w \if_meaning:w 0 #1 \c_one \else:
-                  \if_meaning:w 5 #1 \c_one \else:
-                  \c_zero \fi: \fi:
-      \if_int_compare:w \__int_eval:w #2 > \c_zero
-        \__int_eval:w \c_one +
+    \if_int_odd:w \if_meaning:w 0 #1 1 \else:
+                  \if_meaning:w 5 #1 1 \else:
+                  0 \fi: \fi: \exp_stop_f:
+      \if_int_compare:w \__int_eval:w #2 > 0 \exp_stop_f:
+        \__int_eval:w 1 +
       \fi:
     \fi:
     #1
@@ -303,15 +303,15 @@
 %   \begin{syntax}
 %     \cs{@@_round_neg:NNN} \meta{final sign} \meta{digit_1} \meta{digit_2}
 %   \end{syntax}
-%   This expands to \cs{c_zero} or \cs{c_one} after doing the following
+%   This expands to |0\exp_stop_f:| or |1\exp_stop_f:| after doing the following
 %   test. Starting from a number of
 %   the form $ \meta{final sign}0.\meta{15 digits}\meta{digit_1} $ with exactly
 %   $15$ (non-all-zero) digits before \meta{digit_1}, subtract from it
 %   $\meta{final sign}0.0\ldots{}0\meta{digit_2}$, where there are $16$~zeros.
 %   If in the current rounding mode the result should be rounded down,
-%   then this function returns \cs{c_one}. Otherwise, \emph{i.e.},
+%   then this function returns |1\exp_stop_f:|. Otherwise, \emph{i.e.},
 %   if the result is rounded back to the first operand, then this function
-%   returns \cs{c_zero}.
+%   returns |0\exp_stop_f:|.
 %
 %   It turns out that this negative \enquote{round to nearest}
 %   is identical to the positive one. And this is the default mode.
@@ -319,10 +319,10 @@
 \cs_new_eq:NN \@@_round_to_ninf_neg:NNN \@@_round_to_pinf:NNN
 \cs_new:Npn \@@_round_to_zero_neg:NNN #1 #2 #3
   {
-    \if_int_compare:w #3 > \c_zero
+    \if_int_compare:w #3 > 0 \exp_stop_f:
       \@@_round_return_one:
     \fi:
-    \c_zero
+    0 \exp_stop_f:
   }
 \cs_new_eq:NN \@@_round_to_pinf_neg:NNN \@@_round_to_ninf:NNN
 \cs_new_eq:NN \@@_round_to_nearest_neg:NNN \@@_round_to_nearest:NNN
@@ -332,7 +332,7 @@
     \if_int_compare:w #3 < \c_@@_five_int \else:
       \@@_round_return_one:
     \fi:
-    \c_zero
+    0 \exp_stop_f:
   }
 \cs_new_eq:NN \@@_round_to_nearest_pinf_neg:NNN \@@_round_to_nearest_ninf:NNN
 \cs_new_eq:NN \@@_round_neg:NNN \@@_round_to_nearest_neg:NNN

Modified: trunk/l3kernel/l3skip.dtx
===================================================================
--- trunk/l3kernel/l3skip.dtx	2017-02-20 14:51:30 UTC (rev 6967)
+++ trunk/l3kernel/l3skip.dtx	2017-02-20 16:08:44 UTC (rev 6968)
@@ -1470,7 +1470,7 @@
       ##1 . ##2 \tl_to_str:n { pt }
   }
       {
-        \int_compare:nNnTF {#2} > \c_zero
+        \int_compare:nNnTF {#2} > { 0 }
           { #1 . #2 }
           { #1 }
       }
@@ -1699,7 +1699,7 @@
   {
     \if_int_compare:w
       \__str_if_eq_x:nn { \skip_eval:n { #1 } } { \skip_eval:n { #2 } }
-      = \c_zero
+      = 0 \exp_stop_f:
         \prg_return_true:
     \else:
         \prg_return_false:



More information about the latex3-commits mailing list