summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-08-31 17:58:55 +0000
committerKarl Berry <karl@freefriends.org>2012-08-31 17:58:55 +0000
commit3301423440393adfdbbcfa0d8471e4b4c63df1e6 (patch)
tree6aa86f66a252f654a2bd2f28ee7b680fdac1b0a3 /Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx
parenta511edd7e6a05e250f2b2d8062a470734e3af33d (diff)
l3kernel 3160 (31aug12)
git-svn-id: svn://tug.org/texlive/trunk@27559 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx240
1 files changed, 121 insertions, 119 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx
index 591ccf5615e..22c72c7b482 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx
@@ -36,7 +36,7 @@
%
%<*driver>
\RequirePackage{l3bootstrap}
-\GetIdInfo$Id: l3fp-basics.dtx 4089 2012-08-14 04:52:20Z bruno $
+\GetIdInfo$Id: l3fp-basics.dtx 4151 2012-08-28 11:51:52Z bruno $
{L3 Floating-point arithmetic}
\documentclass[full]{l3doc}
\begin{document}
@@ -97,7 +97,7 @@
% \@@_basics_pack_high:NNNNNw,
% \@@_basics_pack_high_carry:w
% }
-% Addition and multiplication of mantissas are done in two steps:
+% Addition and multiplication of significands are done in two steps:
% first compute a (more or less) exact result, then round and pack
% digits in the final (braced) form. These functions take care of the
% packing, with special attention given to the case where rounding has
@@ -166,8 +166,8 @@
% detect an invalid operation in the case of $\infty - \infty$;
% \item for normal floating point numbers, compare the signs;
% \item to add two floating point numbers of the same sign or of
-% opposite signs, shift the mantissa of the smaller one to match the
-% bigger one, perform the addition or subtraction of mantissas,
+% opposite signs, shift the significand of the smaller one to match the
+% bigger one, perform the addition or subtraction of significands,
% check for a carry, round, and pack using the
% |\__fp_basics_pack_...| functions.
% \end{itemize}
@@ -332,7 +332,7 @@
% the result, and the \meta{final sign} are then given to
% \cs{@@_sanitize:Nw} which checks for overflow. The exponent is
% computed as the largest exponent |#2| or |#5|, incremented if there
-% is a carry. To add the mantissas, we decimate the smaller number by
+% is a carry. To add the significands, we decimate the smaller number by
% the difference between the exponents. This is done by
% \cs{@@_add_big_i:wNww} or \cs{@@_add_big_ii:wNww}. We need to bring
% the final sign with us in the midst of the calculation to round
@@ -361,13 +361,13 @@
% \cs{@@_add_big_i_o:wNww} \meta{shift} |;| \meta{final sign}
% \meta{body_1} |;| \meta{body_2} |;|
% \end{quote}
-% Shift the mantissa of the small number, then add with
-% \cs{@@_add_mantissa_o:NnnwnnnnN}.
+% Shift the significand of the small number, then add with
+% \cs{@@_add_significand_o:NnnwnnnnN}.
% \begin{macrocode}
\cs_new:Npn \@@_add_big_i_o:wNww #1; #2 #3; #4;
{
\@@_decimate:nNnnnn {#1}
- \@@_add_mantissa_o:NnnwnnnnN
+ \@@_add_significand_o:NnnwnnnnN
#4
#3
#2
@@ -375,7 +375,7 @@
\cs_new:Npn \@@_add_big_ii_o:wNww #1; #2 #3; #4;
{
\@@_decimate:nNnnnn {#1}
- \@@_add_mantissa_o:NnnwnnnnN
+ \@@_add_significand_o:NnnwnnnnN
#3
#4
#2
@@ -384,11 +384,11 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}[aux, rEXP]{\@@_add_mantissa_o:NnnwnnnnN}
+% \begin{macro}[aux, rEXP]{\@@_add_significand_o:NnnwnnnnN}
% \begin{macro}[aux, rEXP]
-% {\@@_add_mantissa_pack:NNNNNNN, \@@_add_mantissa_test_o:N}
+% {\@@_add_significand_pack:NNNNNNN, \@@_add_significand_test_o:N}
% \begin{quote}
-% \cs{@@_add_mantissa_o:NnnwnnnnN}
+% \cs{@@_add_significand_o:NnnwnnnnN}
% \meta{rounding digit}
% \Arg{Y'_1} \Arg{Y'_2} \meta{extra-digits} |;|
% \Arg{X_1} \Arg{X_2} \Arg{X_3} \Arg{X_4}
@@ -403,35 +403,35 @@
% give an exact power of $10$, for which it is easy to correct
% the result at the end.
% \begin{macrocode}
-\cs_new:Npn \@@_add_mantissa_o:NnnwnnnnN #1 #2#3 #4; #5#6#7#8
+\cs_new:Npn \@@_add_significand_o:NnnwnnnnN #1 #2#3 #4; #5#6#7#8
{
- \exp_after:wN \@@_add_mantissa_test_o:N
+ \exp_after:wN \@@_add_significand_test_o:N
\int_use:N \__int_eval:w 1#5#6 + #2
- \exp_after:wN \@@_add_mantissa_pack:NNNNNNN
+ \exp_after:wN \@@_add_significand_pack:NNNNNNN
\int_use:N \__int_eval:w 1#7#8 + #3 ; #1
}
-\cs_new:Npn \@@_add_mantissa_pack:NNNNNNN #1 #2#3#4#5#6#7
+\cs_new:Npn \@@_add_significand_pack:NNNNNNN #1 #2#3#4#5#6#7
{
\if_meaning:w 2 #1
+ \c_one
\fi:
; #2 #3 #4 #5 #6 #7 ;
}
-\cs_new:Npn \@@_add_mantissa_test_o:N #1
+\cs_new:Npn \@@_add_significand_test_o:N #1
{
\if_meaning:w 2 #1
- \exp_after:wN \@@_add_mantissa_carry_o:wwwNN
+ \exp_after:wN \@@_add_significand_carry_o:wwwNN
\else:
- \exp_after:wN \@@_add_mantissa_no_carry_o:wwwNN
+ \exp_after:wN \@@_add_significand_no_carry_o:wwwNN
\fi:
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
-% \begin{macro}[aux, rEXP]{\@@_add_mantissa_no_carry_o:wwwNN}
+% \begin{macro}[aux, rEXP]{\@@_add_significand_no_carry_o:wwwNN}
% \begin{quote}
-% \cs{@@_add_mantissa_no_carry_o:wwwNN}
+% \cs{@@_add_significand_no_carry_o:wwwNN}
% \meta{8d} |;| \meta{6d} |;| \meta{2d} |;|
% \meta{rounding digit} \meta{sign}
% \end{quote}
@@ -439,7 +439,7 @@
% packing function \cs{@@_basics_pack_high:NNNNNw} takes care of the
% case where rounding brings a carry.
% \begin{macrocode}
-\cs_new:Npn \@@_add_mantissa_no_carry_o:wwwNN
+\cs_new:Npn \@@_add_significand_no_carry_o:wwwNN
#1; #2; #3#4 ; #5#6
{
\exp_after:wN \@@_basics_pack_high:NNNNNw
@@ -452,16 +452,16 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux, rEXP]{\@@_add_mantissa_carry_o:wwwNN}
+% \begin{macro}[aux, rEXP]{\@@_add_significand_carry_o:wwwNN}
% \begin{quote}
-% \cs{@@_add_mantissa_carry_o:wwwNN}
+% \cs{@@_add_significand_carry_o:wwwNN}
% \meta{8d} |;| \meta{6d} |;| \meta{2d} |;|
% \meta{rounding digit} \meta{sign}
% \end{quote}
% The case where there is a carry is very similar. Rounding can even
% raise the first digit from $1$ to $2$, but we don't care.
% \begin{macrocode}
-\cs_new:Npn \@@_add_mantissa_carry_o:wwwNN
+\cs_new:Npn \@@_add_significand_carry_o:wwwNN
#1; #2; #3#4; #5#6
{
+ \c_one
@@ -490,7 +490,7 @@
% \end{quote}
% Rounding properly in some modes requires to know what the sign of
% the result will be. Thus, we start by comparing the exponents and
-% mantissas. If the numbers coincide, return zero. If the second
+% significands. If the numbers coincide, return zero. If the second
% number is larger, swap the numbers and call
% \cs{@@_sub_npos_i_o:Nnwnw} with the opposite of \meta{sign_1}.
% \begin{macrocode}
@@ -524,7 +524,7 @@
% and may be decreased if the two numbers are very close. If the two
% numbers have the same exponent, call the \texttt{near} auxiliary.
% Otherwise, decimate $y$, then call the \texttt{far} auxiliary to
-% evaluate the difference between the two mantissas. Note that we
+% evaluate the difference between the two significands. Note that we
% decimate by $1$ less than one could expect.
% \begin{macrocode}
\cs_new:Npn \@@_sub_npos_i_o:Nnwnw #1 #2#3; #4#5;
@@ -650,7 +650,7 @@
% and semi-colon delimiters to allow the \texttt{not_far} auxiliary to
% grab each piece individually, the \texttt{very_far} auxiliary to use
% \cs{@@_pack_eight:wNNNNNNNN}, and the \texttt{quite_far} to ignore
-% the mantissas easily (using the |;| delimiter).
+% the significands easily (using the |;| delimiter).
% \begin{macrocode}
\cs_new:Npn \@@_sub_back_far_o:NnnwnnnnN #1 #2#3 #4; #5#6#7#8
{
@@ -738,7 +738,7 @@
% \begin{macro}[aux, EXP]{\@@_sub_back_very_far_ii_o:nnNwwNN}
% The case where $x-y$ and $x$ have the same exponent is a bit more
% tricky, mostly because it cannot reuse the same auxiliaries. Shift
-% the $y$~mantissa by adding a leading~$0$. Then the logic is similar
+% the $y$~significand by adding a leading~$0$. Then the logic is similar
% to the \texttt{not_far} functions above. Rounding is a bit more
% complicated: we have two \meta{rounding} digits |#3| and |#6| (from
% the decimation, and from the new shift) to take into account, and
@@ -869,9 +869,9 @@
% After the computation, \cs{@@_sanitize:Nw} checks for overflow or
% underflow. As we did for addition, \cs{__int_eval:w} computes the
% exponent, catching any shift coming from the computation in the
-% mantissa. The \meta{final sign} is needed to do the rounding
-% properly in the mantissa computation. We setup the post-expansion
-% here, triggered by \cs{@@_mul_mantissa_o:nnnnNnnnn}.
+% significand. The \meta{final sign} is needed to do the rounding
+% properly in the significand computation. We setup the post-expansion
+% here, triggered by \cs{@@_mul_significand_o:nnnnNnnnn}.
% \begin{macrocode}
\cs_new:Npn \@@_mul_npos_o:Nww
#1 \s_@@ \@@_chk:w #2 #3 #4 #5 ; \s_@@ \@@_chk:w #6 #7 #8 #9 ;
@@ -880,21 +880,21 @@
\exp_after:wN #1
\int_use:N \__int_eval:w
#4 + #8
- \@@_mul_mantissa_o:nnnnNnnnn #5 #1 #9
+ \@@_mul_significand_o:nnnnNnnnn #5 #1 #9
}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux, rEXP]{\@@_mul_mantissa_o:nnnnNnnnn}
+% \begin{macro}[aux, rEXP]{\@@_mul_significand_o:nnnnNnnnn}
% \begin{macro}[aux, EXP]
-% {\@@_mul_mantissa_drop:NNNNNw, \@@_mul_mantissa_keep:NNNNNw}
+% {\@@_mul_significand_drop:NNNNNw, \@@_mul_significand_keep:NNNNNw}
% \begin{quote}
-% \cs{@@_mul_mantissa_o:nnnnNnnnn}
+% \cs{@@_mul_significand_o:nnnnNnnnn}
% \Arg{X_1} \Arg{X_2} \Arg{X_3} \Arg{X_4} \meta{sign}
% \Arg{Y_1} \Arg{Y_2} \Arg{Y_3} \Arg{Y_4}
% \end{quote}
% Note the three semicolons at the end of the definition. One is for
-% the last \cs{@@_mul_mantissa_drop:NNNNNw}; one is for
+% the last \cs{@@_mul_significand_drop:NNNNNw}; one is for
% \cs{@@_round_digit:Nw} later on; and one, preceeded by
% \cs{exp_after:wN}, which is correctly expanded (within an
% \cs{__int_eval:w}), is used by \cs{@@_basics_pack_low:NNNNNw}.
@@ -909,36 +909,36 @@
% known, and we can do the rounding within yet another set of
% \cs{__int_eval:w}.
% \begin{macrocode}
-\cs_new:Npn \@@_mul_mantissa_o:nnnnNnnnn #1#2#3#4 #5 #6#7#8#9
+\cs_new:Npn \@@_mul_significand_o:nnnnNnnnn #1#2#3#4 #5 #6#7#8#9
{
- \exp_after:wN \@@_mul_mantissa_test_f:NNN
+ \exp_after:wN \@@_mul_significand_test_f:NNN
\exp_after:wN #5
\int_use:N \__int_eval:w 99990000 + #1*#6 +
- \exp_after:wN \@@_mul_mantissa_keep:NNNNNw
+ \exp_after:wN \@@_mul_significand_keep:NNNNNw
\int_use:N \__int_eval:w 99990000 + #1*#7 + #2*#6 +
- \exp_after:wN \@@_mul_mantissa_keep:NNNNNw
+ \exp_after:wN \@@_mul_significand_keep:NNNNNw
\int_use:N \__int_eval:w 99990000 + #1*#8 + #2*#7 + #3*#6 +
- \exp_after:wN \@@_mul_mantissa_drop:NNNNNw
+ \exp_after:wN \@@_mul_significand_drop:NNNNNw
\int_use:N \__int_eval:w 99990000 + #1*#9 + #2*#8 + #3*#7 + #4*#6 +
- \exp_after:wN \@@_mul_mantissa_drop:NNNNNw
+ \exp_after:wN \@@_mul_significand_drop:NNNNNw
\int_use:N \__int_eval:w 99990000 + #2*#9 + #3*#8 + #4*#7 +
- \exp_after:wN \@@_mul_mantissa_drop:NNNNNw
+ \exp_after:wN \@@_mul_significand_drop:NNNNNw
\int_use:N \__int_eval:w 99990000 + #3*#9 + #4*#8 +
- \exp_after:wN \@@_mul_mantissa_drop:NNNNNw
+ \exp_after:wN \@@_mul_significand_drop:NNNNNw
\int_use:N \__int_eval:w 100000000 + #4*#9 ;
; \exp_after:wN ;
}
-\cs_new:Npn \@@_mul_mantissa_drop:NNNNNw #1#2#3#4#5 #6;
+\cs_new:Npn \@@_mul_significand_drop:NNNNNw #1#2#3#4#5 #6;
{ #1#2#3#4#5 ; + #6 }
-\cs_new:Npn \@@_mul_mantissa_keep:NNNNNw #1#2#3#4#5 #6;
+\cs_new:Npn \@@_mul_significand_keep:NNNNNw #1#2#3#4#5 #6;
{ #1#2#3#4#5 ; #6 ; }
% \end{macrocode}
% \end{macro}
% \end{macro}
%
-% \begin{macro}[aux, rEXP]{\@@_mul_mantissa_test_f:NNN}
+% \begin{macro}[aux, rEXP]{\@@_mul_significand_test_f:NNN}
% \begin{quote}
-% \cs{@@_mul_mantissa_test_f:NNN} \meta{sign} |1|
+% \cs{@@_mul_significand_test_f:NNN} \meta{sign} |1|
% \meta{digits 1--8} |;| \meta{digits 9--12} |;| \meta{digits 13--16} |;|
% |+| \meta{digits 17--20} |+| \meta{digits 21--24}
% |+| \meta{digits 25--28} |+| \meta{digits 29--32} |;|
@@ -950,19 +950,19 @@
% is zero, we care about digits $17$ and $18$, and whether further
% digits are zero.
% \begin{macrocode}
-\cs_new:Npn \@@_mul_mantissa_test_f:NNN #1 #2 #3
+\cs_new:Npn \@@_mul_significand_test_f:NNN #1 #2 #3
{
\if_meaning:w 0 #3
- \exp_after:wN \@@_mul_mantissa_small_f:NNwwwN
+ \exp_after:wN \@@_mul_significand_small_f:NNwwwN
\else:
- \exp_after:wN \@@_mul_mantissa_large_f:NwwNNNN
+ \exp_after:wN \@@_mul_significand_large_f:NwwNNNN
\fi:
#1 #3
}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux, EXP]{\@@_mul_mantissa_large_f:NwwNNNN}
+% \begin{macro}[aux, EXP]{\@@_mul_significand_large_f:NwwNNNN}
% In this branch, \meta{digit 1} is non-zero. The result is thus
% \meta{digits 1--16}, plus some rounding which depends on the digits
% $16$, $17$, and whether all subsequent digits are zero or not.
@@ -970,7 +970,7 @@
% integer expression), and replaces it by a \meta{rounding digit},
% suitable for \cs{@@_round:NNN}.
% \begin{macrocode}
-\cs_new:Npn \@@_mul_mantissa_large_f:NwwNNNN #1 #2; #3; #4#5#6#7; +
+\cs_new:Npn \@@_mul_significand_large_f:NwwNNNN #1 #2; #3; #4#5#6#7; +
{
\exp_after:wN \@@_basics_pack_high:NNNNNw
\int_use:N \__int_eval:w 1#2
@@ -984,7 +984,7 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux, rEXP]{\@@_mul_mantissa_small_f:NNwwwN}
+% \begin{macro}[aux, rEXP]{\@@_mul_significand_small_f:NNwwwN}
% In this branch, \meta{digit 1} is zero. Our result will thus be
% \meta{digits 2--17}, plus some rounding which depends on the digits
% $17$, $18$, and whether all subsequent digits are zero or not.
@@ -992,7 +992,7 @@
% \texttt{small_pack} auxiliary, by the next digit, to form a $9$
% digit number.
% \begin{macrocode}
-\cs_new:Npn \@@_mul_mantissa_small_f:NNwwwN #1 #2#3; #4#5; #6; + #7
+\cs_new:Npn \@@_mul_significand_small_f:NNwwwN #1 #2#3; #4#5; #6; + #7
{
- \c_one
\exp_after:wN \@@_basics_pack_high:NNNNNw
@@ -1056,7 +1056,7 @@
% \cs{@@_sanitize:Nw} checks for overflow or underflow; we provide it
% with the \meta{final sign}, and an integer expression in which we
% compute the exponent. We set up the arguments of
-% \cs{@@_div_mantissa_i_o:wnnw}, namely an integer \meta{y} obtained
+% \cs{@@_div_significand_i_o:wnnw}, namely an integer \meta{y} obtained
% by adding $1$ to the first $5$ digits of $Z$ (explanation given soon
% below), then the four \Arg{A_{i}}, then the four \Arg{Z_{i}}, a
% semi-colon, and the \meta{final sign}, used for rounding at the end.
@@ -1068,7 +1068,7 @@
\exp_after:wN #1
\int_use:N \__int_eval:w
#3 - #6
- \exp_after:wN \@@_div_mantissa_i_o:wnnw
+ \exp_after:wN \@@_div_significand_i_o:wnnw
\int_use:N \__int_eval:w #7 \use_i:nnnn #8 + \c_one ;
#4
{#7}{#8}#9 ;
@@ -1246,46 +1246,46 @@
% In each case, we know how to round to an integer, depending on the
% parity of $P$, and the rounding mode.
%
-% \subsubsection{Implementing the mantissa division}
+% \subsubsection{Implementing the significand division}
%
-% \begin{macro}[aux, rEXP]{\@@_div_mantissa_i_o:wnnw}
+% \begin{macro}[aux, rEXP]{\@@_div_significand_i_o:wnnw}
% \begin{quote}
-% \cs{@@_div_mantissa_i_o:wnnw} \meta{y} |;|
+% \cs{@@_div_significand_i_o:wnnw} \meta{y} |;|
% \Arg{A_1} \Arg{A_2} \Arg{A_3} \Arg{A_4}
% \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4} |;| \meta{sign}
% \end{quote}
% Compute $10^{6} + Q_{A}$ (a $7$~digit number thanks to the shift),
% unbrace \meta{A_1} and \meta{A_2}, and prepare the
% \meta{continuation} arguments for $4$ consecutive calls to
-% \cs{@@_div_mantissa_calc:wwnnnnnnn}. Each of these calls will need
+% \cs{@@_div_significand_calc:wwnnnnnnn}. Each of these calls will need
% \meta{y} (|#1|), and it turns out that we need post-expansion there,
% hence the \cs{__int_value:w}. Here, |#4| is six brace groups, which
% give the six first |n|-type arguments of the \texttt{calc} function.
% \begin{macrocode}
-\cs_new:Npn \@@_div_mantissa_i_o:wnnw #1 ; #2#3 #4 ;
+\cs_new:Npn \@@_div_significand_i_o:wnnw #1 ; #2#3 #4 ;
{
- \exp_after:wN \@@_div_mantissa_test_o:w
+ \exp_after:wN \@@_div_significand_test_o:w
\int_use:N \__int_eval:w
- \exp_after:wN \@@_div_mantissa_calc:wwnnnnnnn
+ \exp_after:wN \@@_div_significand_calc:wwnnnnnnn
\int_use:N \__int_eval:w 999999 + #2 #3 0 / #1 ;
#2 #3 ;
#4
- { \exp_after:wN \@@_div_mantissa_ii:wwn \__int_value:w #1 }
- { \exp_after:wN \@@_div_mantissa_ii:wwn \__int_value:w #1 }
- { \exp_after:wN \@@_div_mantissa_ii:wwn \__int_value:w #1 }
- { \exp_after:wN \@@_div_mantissa_iii:wwnnnnn \__int_value:w #1 }
+ { \exp_after:wN \@@_div_significand_ii:wwn \__int_value:w #1 }
+ { \exp_after:wN \@@_div_significand_ii:wwn \__int_value:w #1 }
+ { \exp_after:wN \@@_div_significand_ii:wwn \__int_value:w #1 }
+ { \exp_after:wN \@@_div_significand_iii:wwnnnnn \__int_value:w #1 }
}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[int, rEXP]{\@@_div_mantissa_calc:wwnnnnnnn}
+% \begin{macro}[int, rEXP]{\@@_div_significand_calc:wwnnnnnnn}
% \begin{macro}[aux, rEXP]
% {
-% \@@_div_mantissa_calc_i:wwnnnnnnn,
-% \@@_div_mantissa_calc_ii:wwnnnnnnn,
+% \@@_div_significand_calc_i:wwnnnnnnn,
+% \@@_div_significand_calc_ii:wwnnnnnnn,
% }
% \begin{quote}
-% \cs{@@_div_mantissa_calc:wwnnnnnnn} \meta{$10^{6}+{}$Q_{A}} |;|
+% \cs{@@_div_significand_calc:wwnnnnnnn} \meta{$10^{6}+{}$Q_{A}} |;|
% \meta{A_1} \meta{A_2} |;| \Arg{A_3} \Arg{A_4}
% \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4}
% \Arg{continuation}
@@ -1337,15 +1337,15 @@
% which produces totals in the range $[10^{9}, 2.1\cdot 10^{9}]$. We
% are flirting with \TeX{}'s limits once more.
% \begin{macrocode}
-\cs_new:Npn \@@_div_mantissa_calc:wwnnnnnnn 1#1
+\cs_new:Npn \@@_div_significand_calc:wwnnnnnnn 1#1
{
\if_meaning:w 1 #1
- \exp_after:wN \@@_div_mantissa_calc_i:wwnnnnnnn
+ \exp_after:wN \@@_div_significand_calc_i:wwnnnnnnn
\else:
- \exp_after:wN \@@_div_mantissa_calc_ii:wwnnnnnnn
+ \exp_after:wN \@@_div_significand_calc_ii:wwnnnnnnn
\fi:
}
-\cs_new:Npn \@@_div_mantissa_calc_i:wwnnnnnnn #1; #2;#3#4 #5#6#7#8 #9
+\cs_new:Npn \@@_div_significand_calc_i:wwnnnnnnn #1; #2;#3#4 #5#6#7#8 #9
{
1 1 #1
#9 \exp_after:wN ;
@@ -1362,7 +1362,7 @@
- #1 * #8 ;
{#5}{#6}{#7}{#8}
}
-\cs_new:Npn \@@_div_mantissa_calc_ii:wwnnnnnnn #1; #2;#3#4 #5#6#7#8 #9
+\cs_new:Npn \@@_div_significand_calc_ii:wwnnnnnnn #1; #2;#3#4 #5#6#7#8 #9
{
1 0 #1
#9 \exp_after:wN ;
@@ -1383,9 +1383,9 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}[aux, EXP]{\@@_div_mantissa_ii:wwn}
+% \begin{macro}[aux, EXP]{\@@_div_significand_ii:wwn}
% \begin{quote}
-% \cs{@@_div_mantissa_ii:wwn} \meta{y} |;|
+% \cs{@@_div_significand_ii:wwn} \meta{y} |;|
% \meta{B_1} |;| \Arg{B_2} \Arg{B_3} \Arg{B_4}
% \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4}
% \meta{continuations} \meta{sign}
@@ -1399,19 +1399,19 @@
% auxiliary is also used to compute $Q_{C}$ and $Q_{D}$ with the
% inputs $C$ and $D$ instead of $B$.
% \begin{macrocode}
-\cs_new:Npn \@@_div_mantissa_ii:wwn #1; #2;#3
+\cs_new:Npn \@@_div_significand_ii:wwn #1; #2;#3
{
- \exp_after:wN \@@_div_mantissa_pack:NNN
+ \exp_after:wN \@@_div_significand_pack:NNN
\int_use:N \__int_eval:w
- \exp_after:wN \@@_div_mantissa_calc:wwnnnnnnn
+ \exp_after:wN \@@_div_significand_calc:wwnnnnnnn
\int_use:N \__int_eval:w 999999 + #2 #3 0 / #1 ; #2 #3 ;
}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux, rEXP]{\@@_div_mantissa_iii:wwnnnnn}
+% \begin{macro}[aux, rEXP]{\@@_div_significand_iii:wwnnnnn}
% \begin{quote}
-% \cs{@@_div_mantissa_iii:wwnnnnn} \meta{y} |;|
+% \cs{@@_div_significand_iii:wwnnnnn} \meta{y} |;|
% \meta{E_1} |;| \Arg{E_2} \Arg{E_3} \Arg{E_4}
% \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4} \meta{sign}
% \end{quote}
@@ -1420,10 +1420,10 @@
% add (roughly) $5\cdot P$, which amounts to adding $P/2 \simeq E/Z$
% to $Q_{D}$, the appropriate correction from a hypothetical $Q_{E}$.
% \begin{macrocode}
-\cs_new:Npn \@@_div_mantissa_iii:wwnnnnn #1; #2;#3#4#5 #6#7
+\cs_new:Npn \@@_div_significand_iii:wwnnnnn #1; #2;#3#4#5 #6#7
{
0
- \exp_after:wN \@@_div_mantissa_iv:wwnnnnnnn
+ \exp_after:wN \@@_div_significand_iv:wwnnnnnnn
\int_use:N \__int_eval:w (\c_two * #2 #3) / #6 #7 ; % <- P
#2 ; {#3} {#4} {#5}
{#6} {#7}
@@ -1433,12 +1433,12 @@
%
% \begin{macro}[aux, rEXP]
% {
-% \@@_div_mantissa_iv:wwnnnnnnn,
-% \@@_div_mantissa_v:NNw,
-% \@@_div_mantissa_vi:Nw
+% \@@_div_significand_iv:wwnnnnnnn,
+% \@@_div_significand_v:NNw,
+% \@@_div_significand_vi:Nw
% }
% \begin{quote}
-% \cs{@@_div_mantissa_iv:wwnnnnnnn} \meta{P} |;|
+% \cs{@@_div_significand_iv:wwnnnnnnn} \meta{P} |;|
% \meta{E_1} |;| \Arg{E_2} \Arg{E_3} \Arg{E_4}
% \Arg{Z_1} \Arg{Z_2} \Arg{Z_3} \Arg{Z_4} \meta{sign}
% \end{quote}
@@ -1476,21 +1476,21 @@
% expressions explicitly). $T$ is negative if the first character is
% |-|, it is positive if the first character is neither |0| nor |-|.
% It is also positive if the first character is |0| and second
-% argument of \cs{@@_div_mantissa_vi:Nw}, a sum of several terms, is
+% argument of \cs{@@_div_significand_vi:Nw}, a sum of several terms, is
% also zero. Otherwise, there was an exact agreement: $T = 0$.
% \begin{macrocode}
-\cs_new:Npn \@@_div_mantissa_iv:wwnnnnnnn #1; #2;#3#4#5 #6#7#8#9
+\cs_new:Npn \@@_div_significand_iv:wwnnnnnnn #1; #2;#3#4#5 #6#7#8#9
{
+ \c_five * #1
- \exp_after:wN \@@_div_mantissa_vi:Nw
+ \exp_after:wN \@@_div_significand_vi:Nw
\int_use:N \__int_eval:w -20 + 2*#2#3 - #1*#6#7 +
- \exp_after:wN \@@_div_mantissa_v:NN
+ \exp_after:wN \@@_div_significand_v:NN
\int_use:N \__int_eval:w 199980 + 2*#4 - #1*#8 +
- \exp_after:wN \@@_div_mantissa_v:NN
+ \exp_after:wN \@@_div_significand_v:NN
\int_use:N \__int_eval:w 200000 + 2*#5 - #1*#9 ;
}
-\cs_new:Npn \@@_div_mantissa_v:NN #1#2 { #1#2 \__int_eval_end: + }
-\cs_new:Npn \@@_div_mantissa_vi:Nw #1#2;
+\cs_new:Npn \@@_div_significand_v:NN #1#2 { #1#2 \__int_eval_end: + }
+\cs_new:Npn \@@_div_significand_vi:Nw #1#2;
{
\if_meaning:w 0 #1
\if_int_compare:w \__int_eval:w #2 > \c_zero + \c_one \fi:
@@ -1502,15 +1502,15 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux, EXP]{\@@_div_mantissa_pack:NNN}
+% \begin{macro}[aux, EXP]{\@@_div_significand_pack:NNN}
% At this stage, we are in the following situation: \TeX{} is in the
% process of expanding several integer expressions, thus functions at
% the bottom expand before those above.
% \begin{quote}
-% \cs{@@_div_mantissa_test_o:w} $10^{6} + Q_{A}$
-% \cs{@@_div_mantissa_pack:NNN} $10^{6} + Q_{B}$
-% \cs{@@_div_mantissa_pack:NNN} $10^{6} + Q_{C}$
-% \cs{@@_div_mantissa_pack:NNN}
+% \cs{@@_div_significand_test_o:w} $10^{6} + Q_{A}$
+% \cs{@@_div_significand_pack:NNN} $10^{6} + Q_{B}$
+% \cs{@@_div_significand_pack:NNN} $10^{6} + Q_{C}$
+% \cs{@@_div_significand_pack:NNN}
% $10^{7} + 10\cdot Q_{D} + 5 \cdot P + \varepsilon$ |;| \meta{sign}
% \end{quote}
% Here, $\varepsilon = \operatorname{sign}(T)$ is $0$ in case $2E=PZ$,
@@ -1520,13 +1520,13 @@
% nothing special: it removes the $10^{6}$ and carries two digits (for
% the $10^{5}$'s and the $10^{4}$'s).
% \begin{macrocode}
-\cs_new:Npn \@@_div_mantissa_pack:NNN 1 #1 #2 { + #1 #2 ; }
+\cs_new:Npn \@@_div_significand_pack:NNN 1 #1 #2 { + #1 #2 ; }
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux, rEXP]{\@@_div_mantissa_test_o:w}
+% \begin{macro}[aux, rEXP]{\@@_div_significand_test_o:w}
% \begin{quote}
-% \cs{@@_div_mantissa_test_o:w} |1| |0| \meta{5d} |;|
+% \cs{@@_div_significand_test_o:w} |1| |0| \meta{5d} |;|
% ~~\meta{4d} |;| \meta{4d} |;| \meta{5d} |;| \meta{sign}
% \end{quote}
% The reason we know that the first two digits are |1| and |0| is that
@@ -1538,28 +1538,28 @@
% It is now time to round. This depends on how many digits the final
% result will have.
% \begin{macrocode}
-\cs_new:Npn \@@_div_mantissa_test_o:w 10 #1
+\cs_new:Npn \@@_div_significand_test_o:w 10 #1
{
\if_meaning:w 0 #1
- \exp_after:wN \@@_div_mantissa_small_o:wwwNNNNwN
+ \exp_after:wN \@@_div_significand_small_o:wwwNNNNwN
\else:
- \exp_after:wN \@@_div_mantissa_large_o:wwwNNNNwN
+ \exp_after:wN \@@_div_significand_large_o:wwwNNNNwN
\fi:
#1
}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux, EXP]{\@@_div_mantissa_small_o:wwwNNNNwN}
+% \begin{macro}[aux, EXP]{\@@_div_significand_small_o:wwwNNNNwN}
% \begin{quote}
-% \cs{@@_div_mantissa_small_o:wwwNNNNwN} |0| \meta{4d} |;|
+% \cs{@@_div_significand_small_o:wwwNNNNwN} |0| \meta{4d} |;|
% ~~\meta{4d} |;| \meta{4d} |;| \meta{5d} |;| \meta{final sign}
% \end{quote}
% Standard use of \cs{@@_basics_pack_low:NNNNNw} and
% \cs{@@_basics_pack_high:NNNNNw}. We finally get to use the
% \meta{final sign} which has been sitting there for a while.
% \begin{macrocode}
-\cs_new:Npn \@@_div_mantissa_small_o:wwwNNNNwN
+\cs_new:Npn \@@_div_significand_small_o:wwwNNNNwN
0 #1; #2; #3; #4#5#6#7#8; #9
{
\exp_after:wN \@@_basics_pack_high:NNNNNw
@@ -1572,9 +1572,9 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux, rEXP]{\@@_div_mantissa_large_o:wwwNNNNwN}
+% \begin{macro}[aux, rEXP]{\@@_div_significand_large_o:wwwNNNNwN}
% \begin{quote}
-% \cs{@@_div_mantissa_large_o:wwwNNNNwN} \meta{5d} |;|
+% \cs{@@_div_significand_large_o:wwwNNNNwN} \meta{5d} |;|
% ~~\meta{4d} |;| \meta{4d} |;| \meta{5d} |;| \meta{sign}
% \end{quote}
% We know that the final result cannot reach $10$, hence |1#1#2|,
@@ -1582,7 +1582,7 @@
% $2\cdot 10^{9}$. For rounding, we build the \meta{rounding digit}
% from the last two of our $18$ digits.
% \begin{macrocode}
-\cs_new:Npn \@@_div_mantissa_large_o:wwwNNNNwN
+\cs_new:Npn \@@_div_significand_large_o:wwwNNNNwN
#1; #2; #3; #4#5#6#7#8; #9
{
+ \c_one
@@ -1603,15 +1603,17 @@
%
% \begin{macro}[int, EXP]{\@@_neg_o:w}
% This function flips the sign of the \meta{floating point} and
-% expands after it in the input stream, just like \cs{@@_+_o:ww} etc.
+% expands after it in the input stream, just like \cs{@@_+_o:ww}
+% \emph{etc.} We add a hook used by \pkg{l3fp-expo}: anything before
+% \cs{s_@@} is ignored.
% \begin{macrocode}
-\cs_new:Npn \@@_neg_o:w \s_@@ \@@_chk:w #1 #2
+\cs_new:Npn \@@_neg_o:w #1 \s_@@ \@@_chk:w #2 #3
{
\exp_after:wN \@@_exp_after_o:w
\exp_after:wN \s_@@
\exp_after:wN \@@_chk:w
- \exp_after:wN #1
- \int_use:N \__int_eval:w \c_two - #2 \__int_eval_end:
+ \exp_after:wN #2
+ \int_use:N \__int_eval:w \c_two - #3 \__int_eval_end:
}
% \end{macrocode}
% \end{macro}