diff options
Diffstat (limited to 'Master/texmf-dist/source/latex-dev/l3kernel/l3fp-extended.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex-dev/l3kernel/l3fp-extended.dtx | 317 |
1 files changed, 164 insertions, 153 deletions
diff --git a/Master/texmf-dist/source/latex-dev/l3kernel/l3fp-extended.dtx b/Master/texmf-dist/source/latex-dev/l3kernel/l3fp-extended.dtx index d633ce3bc32..ce61593e9dc 100644 --- a/Master/texmf-dist/source/latex-dev/l3kernel/l3fp-extended.dtx +++ b/Master/texmf-dist/source/latex-dev/l3kernel/l3fp-extended.dtx @@ -42,7 +42,7 @@ % {latex-team@latex-project.org}^^A % }^^A % } -% \date{Released 2025-01-14} +% \date{Released 2025-01-18} % % \maketitle % @@ -76,7 +76,7 @@ % enough to be rounded away when converting back to a floating point % number. The fixed point numbers are expressed as % \begin{quote} -% \Arg{a_1} \Arg{a_2} \Arg{a_3} \Arg{a_4} \Arg{a_5} \Arg{a_6} |;| +% \Arg{a_1} \Arg{a_2} \Arg{a_3} \Arg{a_4} \Arg{a_5} \Arg{a_6} \cs{@@_sep:} % \end{quote} % where each \meta{a_i} is exactly $4$ digits (ranging from |0000| to % |9999|), except \meta{a_1}, which may be any \enquote{not-too-large} @@ -89,7 +89,8 @@ % % Most functions we define here have the form % \begin{syntax} -% \cs{@@_fixed_\meta{calculation}:wwn} \meta{operand_1} |;| \meta{operand_2} |;| \Arg{continuation} +% \cs{@@_fixed_\meta{calculation}:wwn} \meta{operand_1} \cs{@@_sep:} +% ~~\meta{operand_2} \cs{@@_sep:} \Arg{continuation} % \end{syntax} % They perform the \meta{calculation} on the two \meta{operands}, then % feed the result ($6$ brace groups followed by a semicolon) to the @@ -97,9 +98,9 @@ % Some functions only accept an \texttt{N}-type \meta{continuation}. % This allows constructions such as % \begin{quote} -% \cs{@@_fixed_add:wwn} \meta{X_1} |;| \meta{X_2} |;| \\ -% \cs{@@_fixed_mul:wwn} \meta{X_3} |;| \\ -% \cs{@@_fixed_add:wwn} \meta{X_4} |;| \\ +% \cs{@@_fixed_add:wwn} \meta{X_1} \cs{@@_sep:} \meta{X_2} \cs{@@_sep:} \\ +% \cs{@@_fixed_mul:wwn} \meta{X_3} \cs{@@_sep:} \\ +% \cs{@@_fixed_add:wwn} \meta{X_4} \cs{@@_sep:} \\ % \end{quote} % to compute $(X_1+X_2)\cdot X_3 + X_4$. This turns out to be very % appropriate for computing continued fractions and Taylor series. @@ -116,29 +117,29 @@ % The fixed-point number~$1$, used in \pkg{l3fp-expo}. % \begin{macrocode} \tl_const:Nn \c_@@_one_fixed_tl - { {10000} {0000} {0000} {0000} {0000} {0000} ; } + { {10000} {0000} {0000} {0000} {0000} {0000} \@@_sep: } % \end{macrocode} % \end{variable} % % \begin{macro}[EXP]{\@@_fixed_continue:wn} % This function simply calls the next function. % \begin{macrocode} -\cs_new:Npn \@@_fixed_continue:wn #1; #2 { #2 #1; } +\cs_new:Npn \@@_fixed_continue:wn #1\@@_sep: #2 { #2 #1\@@_sep: } % \end{macrocode} % \end{macro} % % \begin{macro}[EXP]{\@@_fixed_add_one:wN} % \begin{syntax} -% \cs{@@_fixed_add_one:wN} \meta{a} |;| \meta{continuation} +% \cs{@@_fixed_add_one:wN} \meta{a} \cs{@@_sep:} \meta{continuation} % \end{syntax} % This function adds $1$ to the fixed point \meta{a}, by changing % $a_1$ to $10000+a_1$, then calls the \meta{continuation}. This % requires $a_1 + 10000 < 2^{31}$. % \begin{macrocode} -\cs_new:Npn \@@_fixed_add_one:wN #1#2; #3 +\cs_new:Npn \@@_fixed_add_one:wN #1#2\@@_sep: #3 { \exp_after:wN #3 \exp_after:wN - { \int_value:w \@@_int_eval:w \c_@@_myriad_int + #1 } #2 ; + { \int_value:w \@@_int_eval:w \c_@@_myriad_int + #1 } #2 \@@_sep: } % \end{macrocode} % \end{macro} @@ -151,13 +152,13 @@ % exactly $4$~digits. The choice of shifts allows~|#1| to be in the % range $[0, 5\cdot 10^{8}-1]$. % \begin{macrocode} -\cs_new:Npn \@@_fixed_div_myriad:wn #1#2#3#4#5#6; +\cs_new:Npn \@@_fixed_div_myriad:wn #1#2#3#4#5#6\@@_sep: { \exp_after:wN \@@_fixed_mul_after:wwn \int_value:w \@@_int_eval:w \c_@@_leading_shift_int \exp_after:wN \@@_pack:NNNNNw \int_value:w \@@_int_eval:w \c_@@_trailing_shift_int - + #1 ; {#2}{#3}{#4}{#5}; + + #1 \@@_sep: {#2}{#3}{#4}{#5}\@@_sep: } % \end{macrocode} % \end{macro} @@ -167,7 +168,8 @@ % calling this auxiliary. It braces the last block of digits, and % places the \meta{continuation} |#3| in front. % \begin{macrocode} -\cs_new:Npn \@@_fixed_mul_after:wwn #1; #2; #3 { #3 {#1} #2; } +\cs_new:Npn \@@_fixed_mul_after:wwn #1\@@_sep: #2\@@_sep: #3 + { #3 {#1} #2\@@_sep: } % \end{macrocode} % \end{macro} % @@ -176,20 +178,20 @@ % \begin{macro}[EXP]{\@@_fixed_mul_short:wwn} % \begin{syntax}\parskip=0pt\obeylines % \cs{@@_fixed_mul_short:wwn} -% | |\Arg{a_1} \Arg{a_2} \Arg{a_3} \Arg{a_4} \Arg{a_5} \Arg{a_6} |;| -% | |\Arg{b_0} \Arg{b_1} \Arg{b_2} |;| \Arg{continuation} +% | |\Arg{a_1} \Arg{a_2} \Arg{a_3} \Arg{a_4} \Arg{a_5} \Arg{a_6} \cs{@@_sep:} +% | |\Arg{b_0} \Arg{b_1} \Arg{b_2} \cs{@@_sep:} \Arg{continuation} % \end{syntax} % Computes the product $c=ab$ of $a=\sum_i \meta{a_i} 10^{-4i}$ and % $b=\sum_i \meta{b_i} 10^{-4i}$, rounds it to the closest multiple of % $10^{-24}$, and leaves \meta{continuation} \Arg{c_1} \ldots{} -% \Arg{c_6} |;| in the input stream, where each of the \meta{c_i} are +% \Arg{c_6} \cs{@@_sep:} in the input stream, where each of the \meta{c_i} are % blocks of $4$~digits, except \meta{c_1}, which is any \TeX{} % integer. Note that indices for \meta{b} start at~$0$: for instance % a second operand of |{0001}{0000}{0000}| leaves the first operand % unchanged (rather than dividing it by $10^{4}$, as % \cs{@@_fixed_mul:wwn} would). % \begin{macrocode} -\cs_new:Npn \@@_fixed_mul_short:wwn #1#2#3#4#5#6; #7#8#9; +\cs_new:Npn \@@_fixed_mul_short:wwn #1#2#3#4#5#6\@@_sep: #7#8#9\@@_sep: { \exp_after:wN \@@_fixed_mul_after:wwn \int_value:w \@@_int_eval:w \c_@@_leading_shift_int @@ -210,7 +212,7 @@ \int_value:w \@@_int_eval:w \c_@@_trailing_shift_int + #4*#9 + #5*#8 + #6*#7 + ( #5*#9 + #6*#8 + #6*#9 / \c_@@_myriad_int ) - / \c_@@_myriad_int ; ; + / \c_@@_myriad_int \@@_sep: \@@_sep: } % \end{macrocode} % \end{macro} @@ -225,7 +227,7 @@ % \@@_fixed_div_int_after:Nw % } % \begin{syntax} -% \cs{@@_fixed_div_int:wwN} \meta{a} |;| \meta{n} |;| \meta{continuation} +% \cs{@@_fixed_div_int:wwN} \meta{a} \cs{@@_sep:} \meta{n} \cs{@@_sep:} \meta{continuation} % \end{syntax} % Divides the fixed point number \meta{a} by the (small) integer % $0<\meta{n}<10^4$ and feeds the result to the \meta{continuation}. @@ -255,7 +257,7 @@ % \cs{@@_fixed_div_int_pack:Nw} $9999 + Q_{4}$ \\ % \cs{@@_fixed_div_int_pack:Nw} $9999 + Q_{5}$ \\ % \cs{@@_fixed_div_int_pack:Nw} $9999$ \\ -% \cs{@@_fixed_div_int_auxii:wnn} $Q_{6}$ |;| \Arg{n} \Arg{a_{6}} +% \cs{@@_fixed_div_int_auxii:wnn} $Q_{6}$ \cs{@@_sep:} \Arg{n} \Arg{a_{6}} % \end{quote} % where expansion is happening from the last line up. The % \texttt{iii} auxiliary adds $Q_{6} + 2 \simeq a_{6}/n + 1$ to the @@ -268,27 +270,27 @@ % brace group is produced by the \texttt{after} auxiliary, which % places the \meta{continuation} as appropriate. % \begin{macrocode} -\cs_new:Npn \@@_fixed_div_int:wwN #1#2#3#4#5#6 ; #7 ; #8 +\cs_new:Npn \@@_fixed_div_int:wwN #1#2#3#4#5#6 \@@_sep: #7 \@@_sep: #8 { \exp_after:wN \@@_fixed_div_int_after:Nw \exp_after:wN #8 \int_value:w \@@_int_eval:w - 1 \@@_fixed_div_int:wnN - #1; {#7} \@@_fixed_div_int_auxi:wnn - #2; {#7} \@@_fixed_div_int_auxi:wnn - #3; {#7} \@@_fixed_div_int_auxi:wnn - #4; {#7} \@@_fixed_div_int_auxi:wnn - #5; {#7} \@@_fixed_div_int_auxi:wnn - #6; {#7} \@@_fixed_div_int_auxii:wnn ; + #1\@@_sep: {#7} \@@_fixed_div_int_auxi:wnn + #2\@@_sep: {#7} \@@_fixed_div_int_auxi:wnn + #3\@@_sep: {#7} \@@_fixed_div_int_auxi:wnn + #4\@@_sep: {#7} \@@_fixed_div_int_auxi:wnn + #5\@@_sep: {#7} \@@_fixed_div_int_auxi:wnn + #6\@@_sep: {#7} \@@_fixed_div_int_auxii:wnn \@@_sep: } -\cs_new:Npn \@@_fixed_div_int:wnN #1; #2 #3 +\cs_new:Npn \@@_fixed_div_int:wnN #1\@@_sep: #2 #3 { \exp_after:wN #3 - \int_value:w \@@_int_eval:w #1 / #2 - 1 ; + \int_value:w \@@_int_eval:w #1 / #2 - 1 \@@_sep: {#2} {#1} } -\cs_new:Npn \@@_fixed_div_int_auxi:wnn #1; #2 #3 +\cs_new:Npn \@@_fixed_div_int_auxi:wnn #1\@@_sep: #2 #3 { + #1 \exp_after:wN \@@_fixed_div_int_pack:Nw @@ -296,9 +298,9 @@ \exp_after:wN \@@_fixed_div_int:wnN \int_value:w \@@_int_eval:w #3 - #1*#2 \@@_int_eval_end: } -\cs_new:Npn \@@_fixed_div_int_auxii:wnn #1; #2 #3 { + #1 + 2 ; } -\cs_new:Npn \@@_fixed_div_int_pack:Nw #1 #2; { + #1; {#2} } -\cs_new:Npn \@@_fixed_div_int_after:Nw #1 #2; { #1 {#2} } +\cs_new:Npn \@@_fixed_div_int_auxii:wnn #1\@@_sep: #2 #3 { + #1 + 2 \@@_sep: } +\cs_new:Npn \@@_fixed_div_int_pack:Nw #1 #2\@@_sep: { + #1\@@_sep: {#2} } +\cs_new:Npn \@@_fixed_div_int_after:Nw #1 #2\@@_sep: { #1 {#2} } % \end{macrocode} % \end{macro} % \end{macro} @@ -314,7 +316,7 @@ % \@@_fixed_add_after:NNNNNwn % } % \begin{syntax} -% \cs{@@_fixed_add:wwn} \meta{a} |;| \meta{b} |;| \Arg{continuation} +% \cs{@@_fixed_add:wwn} \meta{a} \cs{@@_sep:} \meta{b} \cs{@@_sep:} \Arg{continuation} % \end{syntax} % Computes $a+b$ (resp.\ $a-b$) and feeds the result to the % \meta{continuation}. This function requires $0\leq a_{1},b_{1}\leq @@ -333,7 +335,7 @@ % \begin{macrocode} \cs_new:Npn \@@_fixed_add:wwn { \@@_fixed_add:Nnnnnwnn + } \cs_new:Npn \@@_fixed_sub:wwn { \@@_fixed_add:Nnnnnwnn - } -\cs_new:Npn \@@_fixed_add:Nnnnnwnn #1 #2#3#4#5 #6; #7#8 +\cs_new:Npn \@@_fixed_add:Nnnnnwnn #1 #2#3#4#5 #6\@@_sep: #7#8 { \exp_after:wN \@@_fixed_add_after:NNNNNwn \int_value:w \@@_int_eval:w 9 9999 9998 + #2#3 #1 #7#8 @@ -341,15 +343,16 @@ \int_value:w \@@_int_eval:w 1 9999 9998 + #4#5 \@@_fixed_add:nnNnnnwn #6 #1 } -\cs_new:Npn \@@_fixed_add:nnNnnnwn #1#2 #3 #4#5 #6#7 ; #8 +\cs_new:Npn \@@_fixed_add:nnNnnnwn #1#2 #3 #4#5 #6#7 \@@_sep: #8 { #3 #4#5 \exp_after:wN \@@_fixed_add_pack:NNNNNwn - \int_value:w \@@_int_eval:w 2 0000 0000 #3 #6#7 + #1#2 ; {#8} ; + \int_value:w \@@_int_eval:w + 2 0000 0000 #3 #6#7 + #1#2 \@@_sep: {#8} \@@_sep: } -\cs_new:Npn \@@_fixed_add_pack:NNNNNwn #1 #2#3#4#5 #6; #7 - { + #1 ; {#7} {#2#3#4#5} {#6} } -\cs_new:Npn \@@_fixed_add_after:NNNNNwn 1 #1 #2#3#4#5 #6; #7 +\cs_new:Npn \@@_fixed_add_pack:NNNNNwn #1 #2#3#4#5 #6\@@_sep: #7 + { + #1 \@@_sep: {#7} {#2#3#4#5} {#6} } +\cs_new:Npn \@@_fixed_add_after:NNNNNwn 1 #1 #2#3#4#5 #6\@@_sep: #7 { #7 {#1#2#3#4#5} {#6} } % \end{macrocode} % \end{macro} @@ -361,7 +364,7 @@ % \begin{macro}[EXP]{\@@_fixed_mul:wwn} % \begin{macro}[EXP]{\@@_fixed_mul:nnnnnnnw} % \begin{syntax} -% \cs{@@_fixed_mul:wwn} \meta{a} |;| \meta{b} |;| \Arg{continuation} +% \cs{@@_fixed_mul:wwn} \meta{a} \cs{@@_sep:} \meta{b} \cs{@@_sep:} \Arg{continuation} % \end{syntax} % Computes $a\times b$ and feeds the result to \meta{continuation}. % This function requires $0\leq a_{1}, b_{1} < 10000$. Once more, we @@ -402,7 +405,7 @@ % is finally placed in front of the $6$ brace groups by % \cs{@@_fixed_mul_after:wwn}. % \begin{macrocode} -\cs_new:Npn \@@_fixed_mul:wwn #1#2#3#4 #5; #6#7#8#9 +\cs_new:Npn \@@_fixed_mul:wwn #1#2#3#4 #5\@@_sep: #6#7#8#9 { \exp_after:wN \@@_fixed_mul_after:wwn \int_value:w \@@_int_eval:w \c_@@_leading_shift_int @@ -424,10 +427,10 @@ + ( #3*#9 + #4*#8 + \@@_fixed_mul:nnnnnnnw #5 {#6}{#7} {#1}{#2} } -\cs_new:Npn \@@_fixed_mul:nnnnnnnw #1#2 #3#4 #5#6 #7#8 ; +\cs_new:Npn \@@_fixed_mul:nnnnnnnw #1#2 #3#4 #5#6 #7#8 \@@_sep: { #1*#4 + #2*#3 + #5*#8 + #6*#7 ) / \c_@@_myriad_int - + #1*#3 + #5*#7 ; ; + + #1*#3 + #5*#7 \@@_sep: \@@_sep: } % \end{macrocode} % \end{macro} @@ -442,9 +445,9 @@ % \@@_fixed_mul_one_minus_mul:wwn, % } % \begin{syntax} -% \cs{@@_fixed_mul_add:wwwn} \meta{a} |;| \meta{b} |;| \meta{c} |;| \Arg{continuation} -% \cs{@@_fixed_mul_sub_back:wwwn} \meta{a} |;| \meta{b} |;| \meta{c} |;| \Arg{continuation} -% \cs{@@_fixed_one_minus_mul:wwn} \meta{a} |;| \meta{b} |;| \Arg{continuation} +% \cs{@@_fixed_mul_add:wwwn} \meta{a} \cs{@@_sep:} \meta{b} \cs{@@_sep:} \meta{c} \cs{@@_sep:} \Arg{continuation} +% \cs{@@_fixed_mul_sub_back:wwwn} \meta{a} \cs{@@_sep:} \meta{b} \cs{@@_sep:} \meta{c} \cs{@@_sep:} \Arg{continuation} +% \cs{@@_fixed_one_minus_mul:wwn} \meta{a} \cs{@@_sep:} \meta{b} \cs{@@_sep:} \Arg{continuation} % \end{syntax} % Sometimes called |FMA| (fused multiply-add), these functions % compute $a\times b + c$, $c - a\times b$, and $1 - a\times b$ and @@ -482,32 +485,33 @@ % Each of the three function starts the first two levels (the first, % corresponding to $10^{-4}$, is empty), with $c_{1} c_{2}$ in the % first level, calls the \texttt{i} auxiliary with arguments described -% later, and adds a trailing ${} + c_{5}c_{6}$ |;| -% \Arg{continuation}~|;|. The ${} + c_{5}c_{6}$ piece, which is +% later, and adds a trailing ${} + c_{5}c_{6}$ \cs{@@_sep:} +% \Arg{continuation}~\cs{@@_sep:}. The ${} + c_{5}c_{6}$ piece, which is % omitted for \cs{@@_fixed_one_minus_mul:wwn}, is taken in the % integer expression for the $10^{-24}$ level. % \begin{macrocode} -\cs_new:Npn \@@_fixed_mul_add:wwwn #1; #2; #3#4#5#6#7#8; +\cs_new:Npn \@@_fixed_mul_add:wwwn #1\@@_sep: #2\@@_sep: #3#4#5#6#7#8\@@_sep: { \exp_after:wN \@@_fixed_mul_after:wwn \int_value:w \@@_int_eval:w \c_@@_big_leading_shift_int \exp_after:wN \@@_pack_big:NNNNNNw \int_value:w \@@_int_eval:w \c_@@_big_middle_shift_int + #3 #4 \@@_fixed_mul_add:Nwnnnwnnn + - + #5 #6 ; #2 ; #1 ; #2 ; + - + #7 #8 ; ; + + #5 #6 \@@_sep: #2 \@@_sep: #1 \@@_sep: #2 \@@_sep: + + + #7 #8 \@@_sep: \@@_sep: } -\cs_new:Npn \@@_fixed_mul_sub_back:wwwn #1; #2; #3#4#5#6#7#8; +\cs_new:Npn \@@_fixed_mul_sub_back:wwwn + #1\@@_sep: #2\@@_sep: #3#4#5#6#7#8\@@_sep: { \exp_after:wN \@@_fixed_mul_after:wwn \int_value:w \@@_int_eval:w \c_@@_big_leading_shift_int \exp_after:wN \@@_pack_big:NNNNNNw \int_value:w \@@_int_eval:w \c_@@_big_middle_shift_int + #3 #4 \@@_fixed_mul_add:Nwnnnwnnn - - + #5 #6 ; #2 ; #1 ; #2 ; - - + #7 #8 ; ; + + #5 #6 \@@_sep: #2 \@@_sep: #1 \@@_sep: #2 \@@_sep: - + + #7 #8 \@@_sep: \@@_sep: } -\cs_new:Npn \@@_fixed_one_minus_mul:wwn #1; #2; +\cs_new:Npn \@@_fixed_one_minus_mul:wwn #1\@@_sep: #2\@@_sep: { \exp_after:wN \@@_fixed_mul_after:wwn \int_value:w \@@_int_eval:w \c_@@_big_leading_shift_int @@ -515,17 +519,17 @@ \int_value:w \@@_int_eval:w \c_@@_big_middle_shift_int + 1 0000 0000 \@@_fixed_mul_add:Nwnnnwnnn - - ; #2 ; #1 ; #2 ; - - ; ; + \@@_sep: #2 \@@_sep: #1 \@@_sep: #2 \@@_sep: - + \@@_sep: \@@_sep: } % \end{macrocode} % \end{macro} % % \begin{macro}[EXP]{\@@_fixed_mul_add:Nwnnnwnnn} % \begin{syntax} -% \cs{@@_fixed_mul_add:Nwnnnwnnn} \meta{op} |+| \meta{c_3} \meta{c_4} |;| -% ~~\meta{b} |;| \meta{a} |;| \meta{b} |;| \meta{op} -% ~~|+| \meta{c_5} \meta{c_6} |;| +% \cs{@@_fixed_mul_add:Nwnnnwnnn} \meta{op} |+| \meta{c_3} \meta{c_4} \cs{@@_sep:} +% ~~\meta{b} \cs{@@_sep:} \meta{a} \cs{@@_sep:} \meta{b} \cs{@@_sep:} \meta{op} +% ~~|+| \meta{c_5} \meta{c_6} \cs{@@_sep:} % \end{syntax} % Here, \meta{op} is either |+| or |-|. Arguments |#3|, |#4|, |#5| % are \meta{b_1}, \meta{b_2}, \meta{b_3}; arguments |#7|, |#8|, |#9| @@ -539,7 +543,7 @@ % we've read, but not \meta{b}, since there is another copy later in % the input stream. % \begin{macrocode} -\cs_new:Npn \@@_fixed_mul_add:Nwnnnwnnn #1 #2; #3#4#5#6; #7#8#9 +\cs_new:Npn \@@_fixed_mul_add:Nwnnnwnnn #1 #2\@@_sep: #3#4#5#6\@@_sep: #7#8#9 { #1 #7*#3 \exp_after:wN \@@_pack_big:NNNNNNw @@ -557,8 +561,8 @@ % % \begin{macro}[EXP]{\@@_fixed_mul_add:nnnnwnnnn} % \begin{syntax} -% \cs{@@_fixed_mul_add:nnnnwnnnn} \meta{a} |;| \meta{b} |;| \meta{op} -% ~~|+| \meta{c_5} \meta{c_6} |;| +% \cs{@@_fixed_mul_add:nnnnwnnnn} \meta{a} \cs{@@_sep:} \meta{b} \cs{@@_sep:} \meta{op} +% ~~|+| \meta{c_5} \meta{c_6} \cs{@@_sep:} % \end{syntax} % Level $10^{-20}$ is $(a_{1} \cdot b_{4} + a_{2} \cdot b_{3} + a_{3} % \cdot b_{2} + a_{4} \cdot b_{1})$, multiplied by the sign, which was @@ -577,7 +581,7 @@ % To do all this, we keep $a_{1}$, $a_{5}$, $a_{6}$, and the % corresponding pieces of \meta{b}. % \begin{macrocode} -\cs_new:Npn \@@_fixed_mul_add:nnnnwnnnn #1#2#3#4#5; #6#7#8#9 +\cs_new:Npn \@@_fixed_mul_add:nnnnwnnnn #1#2#3#4#5\@@_sep: #6#7#8#9 { ( #1*#9 + #2*#8 + #3*#7 + #4*#6 ) \exp_after:wN \@@_pack_big:NNNNNNw @@ -585,7 +589,7 @@ \@@_fixed_mul_add:nnnnwnnwN { #6 + #4*#7 + #3*#8 + #2*#9 + #1 } { #7 + #4*#8 + #3*#9 + #2 } - {#1} #5; + {#1} #5\@@_sep: {#6} } % \end{macrocode} @@ -594,8 +598,8 @@ % \begin{macro}[EXP]{\@@_fixed_mul_add:nnnnwnnwN} % \begin{syntax} % \cs{@@_fixed_mul_add:nnnnwnnwN} \Arg{partial_1} \Arg{partial_2} -% ~~\Arg{a_1} \Arg{a_5} \Arg{a_6} |;| \Arg{b_1} \Arg{b_5} \Arg{b_6} |;| -% ~~\meta{op} |+| \meta{c_5} \meta{c_6} |;| +% ~~\Arg{a_1} \Arg{a_5} \Arg{a_6} \cs{@@_sep:} \Arg{b_1} \Arg{b_5} \Arg{b_6} \cs{@@_sep:} +% ~~\meta{op} |+| \meta{c_5} \meta{c_6} \cs{@@_sep:} % \end{syntax} % Complete the \meta{partial_1} and \meta{partial_2} expressions as % explained for the \texttt{ii} auxiliary. The second one is divided @@ -607,7 +611,7 @@ % expected by the packing auxiliaries. See \pkg{l3fp-aux} for the % definition of the shifts and packing auxiliaries. % \begin{macrocode} -\cs_new:Npn \@@_fixed_mul_add:nnnnwnnwN #1#2 #3#4#5; #6#7#8; #9 +\cs_new:Npn \@@_fixed_mul_add:nnnnwnnwN #1#2 #3#4#5\@@_sep: #6#7#8\@@_sep: #9 { #9 (#4* #1 *#7) #9 (#5*#6+#4* #2 *#7+#3*#8) / \c_@@_myriad_int @@ -637,21 +641,22 @@ \cs_new:Npn \@@_ep_to_fixed:wwn #1,#2 { \exp_after:wN \@@_ep_to_fixed_auxi:www - \int_value:w \@@_int_eval:w 1 0000 0000 + #2 \exp_after:wN ; + \int_value:w \@@_int_eval:w 1 0000 0000 + #2 \exp_after:wN \@@_sep: \exp:w \exp_end_continue_f:w - \prg_replicate:nn { 4 - \int_max:nn {#1} { -32 } } { 0 } ; + \prg_replicate:nn { 4 - \int_max:nn {#1} { -32 } } { 0 } \@@_sep: } -\cs_new:Npn \@@_ep_to_fixed_auxi:www 1#1; #2; #3#4#5#6#7; +\cs_new:Npn \@@_ep_to_fixed_auxi:www + 1#1\@@_sep: #2\@@_sep: #3#4#5#6#7\@@_sep: { \@@_pack_eight:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN - \@@_ep_to_fixed_auxii:nnnnnnnwn ; + \@@_ep_to_fixed_auxii:nnnnnnnwn \@@_sep: #2 #1#3#4#5#6#7 0000 ! } -\cs_new:Npn \@@_ep_to_fixed_auxii:nnnnnnnwn #1#2#3#4#5#6#7; #8! #9 - { #9 {#1#2}{#3}{#4}{#5}{#6}{#7}; } +\cs_new:Npn \@@_ep_to_fixed_auxii:nnnnnnnwn #1#2#3#4#5#6#7\@@_sep: #8! #9 + { #9 {#1#2}{#3}{#4}{#5}{#6}{#7}\@@_sep: } % \end{macrocode} % \end{macro} % \end{macro} @@ -675,14 +680,14 @@ % any digit that did not make it in the final mantissa (typically only % zeros, unless the original first block has more than~$4$ digits). % \begin{macrocode} -\cs_new:Npn \@@_ep_to_ep:wwN #1,#2#3#4#5#6#7; #8 +\cs_new:Npn \@@_ep_to_ep:wwN #1,#2#3#4#5#6#7\@@_sep: #8 { \exp_after:wN #8 \int_value:w \@@_int_eval:w #1 + 4 \exp_after:wN \use_i:nn \exp_after:wN \@@_ep_to_ep_loop:N \int_value:w \@@_int_eval:w 1 0000 0000 + #2 \@@_int_eval_end: - #3#4#5#6#7 ; ; ! + #3#4#5#6#7 \@@_sep: \@@_sep: ! } \cs_new:Npn \@@_ep_to_ep_loop:N #1 { @@ -694,21 +699,21 @@ \@@_ep_to_ep_loop:N } \cs_new:Npn \@@_ep_to_ep_end:www - #1 \fi: \@@_ep_to_ep_loop:N #2; #3! + #1 \fi: \@@_ep_to_ep_loop:N #2\@@_sep: #3! { \fi: - \if_meaning:w ; #1 + \if_meaning:w \@@_sep: #1 - 2 * \c_@@_max_exponent_int \@@_ep_to_ep_zero:ww \fi: \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN \@@_pack_twice_four:wNNNNNNNN - \@@_use_i:ww , ; - #1 #2 0000 0000 0000 0000 0000 0000 ; + \@@_use_i:ww , \@@_sep: + #1 #2 0000 0000 0000 0000 0000 0000 \@@_sep: } -\cs_new:Npn \@@_ep_to_ep_zero:ww \fi: #1; #2; #3; - { \fi: , {1000}{0000}{0000}{0000}{0000}{0000} ; } +\cs_new:Npn \@@_ep_to_ep_zero:ww \fi: #1\@@_sep: #2\@@_sep: #3\@@_sep: + { \fi: , {1000}{0000}{0000}{0000}{0000}{0000} \@@_sep: } % \end{macrocode} % \end{macro} % \end{macro} @@ -723,12 +728,14 @@ % works if the numbers are normalized so that their first block is % in~$[1000,9999]$. % \begin{macrocode} -\cs_new:Npn \@@_ep_compare:wwww #1,#2#3#4#5#6#7; - { \@@_ep_compare_aux:wwww {#1}{#2}{#3}{#4}{#5}; #6#7; } -\cs_new:Npn \@@_ep_compare_aux:wwww #1;#2;#3,#4#5#6#7#8#9; +\cs_new:Npn \@@_ep_compare:wwww #1,#2#3#4#5#6#7\@@_sep: + { \@@_ep_compare_aux:wwww {#1}{#2}{#3}{#4}{#5}\@@_sep: #6#7\@@_sep: } +\cs_new:Npn \@@_ep_compare_aux:wwww + #1\@@_sep:#2\@@_sep:#3,#4#5#6#7#8#9\@@_sep: { \if_case:w - \@@_compare_npos:nwnw #1; {#3}{#4}{#5}{#6}{#7}; \exp_stop_f: + \@@_compare_npos:nwnw + #1\@@_sep: {#3}{#4}{#5}{#6}{#7}\@@_sep: \exp_stop_f: \if_int_compare:w #2 = #8#9 \exp_stop_f: 0 \else: @@ -749,19 +756,19 @@ % and~|#4| as fixed point numbers, and sum the exponents |#1| % and~|#3|. The result's first block is in $[100,9999]$. % \begin{macrocode} -\cs_new:Npn \@@_ep_mul:wwwwn #1,#2; #3,#4; +\cs_new:Npn \@@_ep_mul:wwwwn #1,#2\@@_sep: #3,#4\@@_sep: { - \@@_ep_to_ep:wwN #3,#4; + \@@_ep_to_ep:wwN #3,#4\@@_sep: \@@_fixed_continue:wn { - \@@_ep_to_ep:wwN #1,#2; + \@@_ep_to_ep:wwN #1,#2\@@_sep: \@@_ep_mul_raw:wwwwN } \@@_fixed_continue:wn } -\cs_new:Npn \@@_ep_mul_raw:wwwwN #1,#2; #3,#4; #5 +\cs_new:Npn \@@_ep_mul_raw:wwwwN #1,#2\@@_sep: #3,#4\@@_sep: #5 { - \@@_fixed_mul:wwn #2; #4; + \@@_fixed_mul:wwn #2\@@_sep: #4\@@_sep: { \exp_after:wN #5 \int_value:w \@@_int_eval:w #1 + #3 , } } % \end{macrocode} @@ -901,12 +908,12 @@ % \meta{denominator} \meta{numerator}, responsible for estimating the % inverse of the denominator. % \begin{macrocode} -\cs_new:Npn \@@_ep_div:wwwwn #1,#2; #3,#4; +\cs_new:Npn \@@_ep_div:wwwwn #1,#2\@@_sep: #3,#4\@@_sep: { - \@@_ep_to_ep:wwN #1,#2; + \@@_ep_to_ep:wwN #1,#2\@@_sep: \@@_fixed_continue:wn { - \@@_ep_to_ep:wwN #3,#4; + \@@_ep_to_ep:wwN #3,#4\@@_sep: \@@_ep_div_esti:wwwwn } } @@ -935,24 +942,25 @@ % $10^{-9}a/(1-\epsilon)$, that is, $1/(10\meta{d})$ and we finally % multiply this by the numerator~|#8|. % \begin{macrocode} -\cs_new:Npn \@@_ep_div_esti:wwwwn #1,#2#3; #4, +\cs_new:Npn \@@_ep_div_esti:wwwwn #1,#2#3\@@_sep: #4, { \exp_after:wN \@@_ep_div_estii:wwnnwwn \int_value:w \@@_int_eval:w 10 0000 0000 / ( #2 + 1 ) - \exp_after:wN ; + \exp_after:wN \@@_sep: \int_value:w \@@_int_eval:w #4 - #1 + 1 , - {#2} #3; + {#2} #3\@@_sep: } -\cs_new:Npn \@@_ep_div_estii:wwnnwwn #1; #2,#3#4#5; #6; #7 +\cs_new:Npn \@@_ep_div_estii:wwnnwwn + #1\@@_sep: #2,#3#4#5\@@_sep: #6\@@_sep: #7 { \exp_after:wN \@@_ep_div_estiii:NNNNNwwwn \int_value:w \@@_int_eval:w 10 0000 0000 - 1750 - + #1 000 + (10 0000 0000 / #3 - #1) * (1000 - #4 / 10) ; - {#3}{#4}#5; #6; { #7 #2, } + + #1 000 + (10 0000 0000 / #3 - #1) * (1000 - #4 / 10) \@@_sep: + {#3}{#4}#5\@@_sep: #6\@@_sep: { #7 #2, } } -\cs_new:Npn \@@_ep_div_estiii:NNNNNwwwn 1#1#2#3#4#5#6; #7; +\cs_new:Npn \@@_ep_div_estiii:NNNNNwwwn 1#1#2#3#4#5#6\@@_sep: #7\@@_sep: { - \@@_fixed_mul_short:wwn #7; {#1}{#2#3#4#5}{#6}; + \@@_fixed_mul_short:wwn #7\@@_sep: {#1}{#2#3#4#5}{#6}\@@_sep: \@@_ep_div_epsi:wnNNNNNn {#1#2#3#4}#5#6 \@@_fixed_mul:wwn } @@ -978,28 +986,29 @@ % combination of \texttt{short_mul} and \texttt{div_myriad} is both % faster and more precise than a simple \texttt{mul}. % \begin{macrocode} -\cs_new:Npn \@@_ep_div_epsi:wnNNNNNn #1#2#3#4#5#6; +\cs_new:Npn \@@_ep_div_epsi:wnNNNNNn #1#2#3#4#5#6\@@_sep: { \exp_after:wN \@@_ep_div_epsii:wwnNNNNNn \int_value:w \@@_int_eval:w 1 9998 - #2 \exp_after:wN \@@_ep_div_eps_pack:NNNNNw \int_value:w \@@_int_eval:w 1 9999 9998 - #3#4 \exp_after:wN \@@_ep_div_eps_pack:NNNNNw - \int_value:w \@@_int_eval:w 2 0000 0000 - #5#6 ; ; + \int_value:w \@@_int_eval:w 2 0000 0000 - #5#6 \@@_sep: \@@_sep: } -\cs_new:Npn \@@_ep_div_eps_pack:NNNNNw #1#2#3#4#5#6; - { + #1 ; {#2#3#4#5} {#6} } -\cs_new:Npn \@@_ep_div_epsii:wwnNNNNNn 1#1; #2; #3#4#5#6#7#8 +\cs_new:Npn \@@_ep_div_eps_pack:NNNNNw #1#2#3#4#5#6\@@_sep: + { + #1 \@@_sep: {#2#3#4#5} {#6} } +\cs_new:Npn \@@_ep_div_epsii:wwnNNNNNn 1#1\@@_sep: #2\@@_sep: #3#4#5#6#7#8 { - \@@_fixed_mul:wwn {0000}{#1}#2; {0000}{#1}#2; + \@@_fixed_mul:wwn {0000}{#1}#2\@@_sep: {0000}{#1}#2\@@_sep: \@@_fixed_add_one:wN - \@@_fixed_mul:wwn {10000} {#1} #2 ; + \@@_fixed_mul:wwn {10000} {#1} #2 \@@_sep: { - \@@_fixed_mul_short:wwn {0000}{#1}#2; {#3}{#4#5#6#7}{#8000}; + \@@_fixed_mul_short:wwn + {0000}{#1}#2\@@_sep: {#3}{#4#5#6#7}{#8000}\@@_sep: \@@_fixed_div_myriad:wn \@@_fixed_mul:wwn } - \@@_fixed_add:wwn {#3}{#4#5#6#7}{#8000}{0000}{0000}{0000}; + \@@_fixed_add:wwn {#3}{#4#5#6#7}{#8000}{0000}{0000}{0000}\@@_sep: } % \end{macrocode} % \end{macro} @@ -1047,9 +1056,9 @@ % mantissa and an altered continuation where we have stored the % result's exponent. % \begin{macrocode} -\cs_new:Npn \@@_ep_isqrt:wwn #1,#2; +\cs_new:Npn \@@_ep_isqrt:wwn #1,#2\@@_sep: { - \@@_ep_to_ep:wwN #1,#2; + \@@_ep_to_ep:wwN #1,#2\@@_sep: \@@_ep_isqrt_auxi:wwn } \cs_new:Npn \@@_ep_isqrt_auxi:wwn #1, @@ -1060,10 +1069,10 @@ { (1 - #1) / 2 , 535 , { 0 } { } } { 1 - #1 / 2 , 168 , { } { 0 } } } -\cs_new:Npn \@@_ep_isqrt_auxii:wwnnnwn #1, #2, #3#4 #5#6; #7 +\cs_new:Npn \@@_ep_isqrt_auxii:wwnnnwn #1, #2, #3#4 #5#6\@@_sep: #7 { \@@_ep_isqrt_esti:wwwnnwn #2, 0, #5, {#3} {#4} - {#5} #6 ; { #7 #1 , } + {#5} #6 \@@_sep: { #7 #1 , } } % \end{macrocode} % \end{macro} @@ -1106,13 +1115,14 @@ { \exp_after:wN \@@_ep_isqrt_estiii:NNNNNwwwn \int_value:w \@@_int_eval:w 1000 0000 + #2 * #2 #5 * 5 - \exp_after:wN , \int_value:w \@@_int_eval:w 10000 + #2 ; + \exp_after:wN , \int_value:w \@@_int_eval:w 10000 + #2 \@@_sep: } -\cs_new:Npn \@@_ep_isqrt_estiii:NNNNNwwwn 1#1#2#3#4#5#6, 1#7#8; #9; +\cs_new:Npn \@@_ep_isqrt_estiii:NNNNNwwwn + 1#1#2#3#4#5#6, 1#7#8\@@_sep: #9\@@_sep: { - \@@_fixed_mul_short:wwn #9; {#1} {#2#3#4#5} {#600} ; + \@@_fixed_mul_short:wwn #9\@@_sep: {#1} {#2#3#4#5} {#600} \@@_sep: \@@_ep_isqrt_epsi:wN - \@@_fixed_mul_short:wwn {#7} {#80} {0000} ; + \@@_fixed_mul_short:wwn {#7} {#80} {0000} \@@_sep: } % \end{macrocode} % \end{macro} @@ -1124,19 +1134,19 @@ % multiplications. The \texttt{epsii} auxiliary receives $z$ as~|#1| % and $y$ as~|#2|. % \begin{macrocode} -\cs_new:Npn \@@_ep_isqrt_epsi:wN #1; +\cs_new:Npn \@@_ep_isqrt_epsi:wN #1\@@_sep: { - \@@_fixed_sub:wwn {15000}{0000}{0000}{0000}{0000}{0000}; #1; - \@@_ep_isqrt_epsii:wwN #1; - \@@_ep_isqrt_epsii:wwN #1; - \@@_ep_isqrt_epsii:wwN #1; + \@@_fixed_sub:wwn {15000}{0000}{0000}{0000}{0000}{0000}\@@_sep: #1\@@_sep: + \@@_ep_isqrt_epsii:wwN #1\@@_sep: + \@@_ep_isqrt_epsii:wwN #1\@@_sep: + \@@_ep_isqrt_epsii:wwN #1\@@_sep: } -\cs_new:Npn \@@_ep_isqrt_epsii:wwN #1; #2; +\cs_new:Npn \@@_ep_isqrt_epsii:wwN #1\@@_sep: #2\@@_sep: { - \@@_fixed_mul:wwn #1; #1; - \@@_fixed_mul_sub_back:wwwn #2; - {15000}{0000}{0000}{0000}{0000}{0000}; - \@@_fixed_mul:wwn #1; + \@@_fixed_mul:wwn #1\@@_sep: #1\@@_sep: + \@@_fixed_mul_sub_back:wwwn #2\@@_sep: + {15000}{0000}{0000}{0000}{0000}{0000}\@@_sep: + \@@_fixed_mul:wwn #1\@@_sep: } % \end{macrocode} % \end{macro} @@ -1156,9 +1166,10 @@ % \begin{macrocode} \cs_new:Npn \@@_ep_to_float_o:wwN #1, { + \@@_int_eval:w #1 \@@_fixed_to_float_o:wN } -\cs_new:Npn \@@_ep_inv_to_float_o:wwN #1,#2; +\cs_new:Npn \@@_ep_inv_to_float_o:wwN #1,#2\@@_sep: { - \@@_ep_div:wwwwn 1,{1000}{0000}{0000}{0000}{0000}{0000}; #1,#2; + \@@_ep_div:wwwwn + 1,{1000}{0000}{0000}{0000}{0000}{0000}\@@_sep: #1,#2\@@_sep: \@@_ep_to_float_o:wwN } % \end{macrocode} @@ -1178,9 +1189,9 @@ % a floating point number. This could perhaps remain in % \pkg{l3fp-trig}. % \begin{macrocode} -\cs_new:Npn \@@_fixed_to_float_rad_o:wN #1; +\cs_new:Npn \@@_fixed_to_float_rad_o:wN #1\@@_sep: { - \@@_fixed_mul:wwn #1; {5729}{5779}{5130}{8232}{0876}{7981}; + \@@_fixed_mul:wwn #1\@@_sep: {5729}{5779}{5130}{8232}{0876}{7981}\@@_sep: { \@@_ep_to_float_o:wwN 2, } } % \end{macrocode} @@ -1190,11 +1201,11 @@ % \begin{macro}[rEXP] % {\@@_fixed_to_float_o:wN, \@@_fixed_to_float_o:Nw} % \begin{syntax} -% \ldots{} \cs{@@_int_eval:w} \meta{exponent} \cs{@@_fixed_to_float_o:wN} \Arg{a_1} \Arg{a_2} \Arg{a_3} \Arg{a_4} \Arg{a_5} \Arg{a_6} |;| \meta{sign} +% \ldots{} \cs{@@_int_eval:w} \meta{exponent} \cs{@@_fixed_to_float_o:wN} \Arg{a_1} \Arg{a_2} \Arg{a_3} \Arg{a_4} \Arg{a_5} \Arg{a_6} \cs{@@_sep:} \meta{sign} % \end{syntax} % yields % \begin{quote} -% \meta{exponent'} |;| \Arg{a'_1} \Arg{a'_2} \Arg{a'_3} \Arg{a'_4} |;| +% \meta{exponent'} \cs{@@_sep:} \Arg{a'_1} \Arg{a'_2} \Arg{a'_3} \Arg{a'_4} \cs{@@_sep:} % \end{quote} % And the \texttt{to_fixed} version gives six brace groups instead of % $4$, ensuring that $1000\leq\meta{a'_1}\leq 9999$. At this stage, we @@ -1204,9 +1215,9 @@ % %^^A todo: round properly when rounding to infinity: I need the sign. % \begin{macrocode} -\cs_new:Npn \@@_fixed_to_float_o:Nw #1#2; - { \@@_fixed_to_float_o:wN #2; #1 } -\cs_new:Npn \@@_fixed_to_float_o:wN #1#2#3#4#5#6; #7 +\cs_new:Npn \@@_fixed_to_float_o:Nw #1#2\@@_sep: + { \@@_fixed_to_float_o:wN #2\@@_sep: #1 } +\cs_new:Npn \@@_fixed_to_float_o:wN #1#2#3#4#5#6\@@_sep: #7 { % for the 8-digit-at-the-start thing + \@@_int_eval:w \c_@@_block_int \exp_after:wN \exp_after:wN @@ -1217,8 +1228,8 @@ \int_value:w 1#2 \exp_after:wN \@@_use_none_stop_f:n \int_value:w 1#3#4 \exp_after:wN \@@_use_none_stop_f:n \int_value:w 1#5#6 - \exp_after:wN ; - \exp_after:wN ; + \exp_after:wN \@@_sep: + \exp_after:wN \@@_sep: } \cs_new:Npn \@@_fixed_to_loop:N #1 { @@ -1230,36 +1241,36 @@ \exp_after:wN #1 \fi: } -\cs_new:Npn \@@_fixed_to_loop_end:w #1 #2 ; +\cs_new:Npn \@@_fixed_to_loop_end:w #1 #2 \@@_sep: { - \if_meaning:w ; #1 + \if_meaning:w \@@_sep: #1 \exp_after:wN \@@_fixed_to_float_zero:w \else: \exp_after:wN \@@_pack_twice_four:wNNNNNNNN \exp_after:wN \@@_pack_twice_four:wNNNNNNNN \exp_after:wN \@@_fixed_to_float_pack:ww - \exp_after:wN ; + \exp_after:wN \@@_sep: \fi: - #1 #2 0000 0000 0000 0000 ; + #1 #2 0000 0000 0000 0000 \@@_sep: } -\cs_new:Npn \@@_fixed_to_float_zero:w ; 0000 0000 0000 0000 ; +\cs_new:Npn \@@_fixed_to_float_zero:w \@@_sep: 0000 0000 0000 0000 \@@_sep: { - - 2 * \c_@@_max_exponent_int ; - {0000} {0000} {0000} {0000} ; + - 2 * \c_@@_max_exponent_int \@@_sep: + {0000} {0000} {0000} {0000} \@@_sep: } -\cs_new:Npn \@@_fixed_to_float_pack:ww #1 ; #2#3 ; ; +\cs_new:Npn \@@_fixed_to_float_pack:ww #1 \@@_sep: #2#3 \@@_sep: \@@_sep: { \if_int_compare:w #2 > 4 \exp_stop_f: \exp_after:wN \@@_fixed_to_float_round_up:wnnnnw \fi: - ; #1 ; + \@@_sep: #1 \@@_sep: } -\cs_new:Npn \@@_fixed_to_float_round_up:wnnnnw ; #1#2#3#4 ; +\cs_new:Npn \@@_fixed_to_float_round_up:wnnnnw \@@_sep: #1#2#3#4 \@@_sep: { \exp_after:wN \@@_basics_pack_high:NNNNNw \int_value:w \@@_int_eval:w 1 #1#2 \exp_after:wN \@@_basics_pack_low:NNNNNw - \int_value:w \@@_int_eval:w 1 #3#4 + 1 ; + \int_value:w \@@_int_eval:w 1 #3#4 + 1 \@@_sep: } % \end{macrocode} % \end{macro} |