diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx | 71 |
1 files changed, 41 insertions, 30 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx index 382bfb3ecc3..de3bae56fd4 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-aux.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3fp-aux.dtx Copyright(C) 2011-2014,2016 The LaTeX3 Project +%% File: l3fp-aux.dtx Copyright(C) 2011-2014,2016-2017 The LaTeX3 Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -22,7 +22,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-aux.dtx 6805 2016-12-28 22:15:52Z joseph $ +\GetIdInfo$Id: l3fp-aux.dtx 6968 2017-02-20 16:08:44Z bruno $ {L3 Floating-point support functions} \documentclass[full]{l3doc} \begin{document} @@ -301,6 +301,22 @@ % \end{macrocode} % \end{variable} % +% \begin{variable}{\c_@@_prec_int, \c_@@_half_prec_int, \c_@@_block_int} +% The number of digits of floating points. +% \begin{macrocode} +\int_const:Nn \c_@@_prec_int { 16 } +\int_const:Nn \c_@@_half_prec_int { 8 } +\int_const:Nn \c_@@_block_int { 4 } +% \end{macrocode} +% \end{variable} +% +% \begin{variable}{\c_@@_myriad_int} +% Blocks have $4$~digits so this integer is useful. +% \begin{macrocode} +\int_const:Nn \c_@@_myriad_int { 10000 } +% \end{macrocode} +% \end{variable} +% % \begin{variable}[int]{\c_@@_max_exponent_int} % Normal floating point numbers have an exponent at most % \texttt{max_exponent} in absolute value. Larger numbers are rounded @@ -319,6 +335,14 @@ % \end{macrocode} % \end{variable} % +% \begin{variable}{\c_@@_max_exp_exponent_int} +% If a number's exponent is larger than that, its exponential +% overflows/underflows. +% \begin{macrocode} +\int_const:Nn \c_@@_max_exp_exponent_int { 5 } +% \end{macrocode} +% \end{variable} +% % \begin{macro}[int, EXP]{\@@_zero_fp:N, \@@_inf_fp:N} % In case of overflow or underflow, we have to output % a zero or infinity with a given sign. @@ -372,7 +396,7 @@ % turned to $2$ (negative), $1$ (\texttt{nan}) to $1$, and $2$ to $0$. % \begin{macrocode} \cs_new:Npn \@@_neg_sign:N #1 - { \__int_eval:w \c_two - #1 \__int_eval_end: } + { \__int_eval:w 2 - #1 \__int_eval_end: } % \end{macrocode} % \end{macro} % @@ -391,9 +415,9 @@ \cs_new:Npn \@@_sanitize:Nw #1 #2; { \if_case:w - \if_int_compare:w #2 > \c_@@_max_exponent_int \c_one \else: - \if_int_compare:w #2 < - \c_@@_max_exponent_int \c_two \else: - \if_meaning:w 1 #1 \c_three \else: \c_zero \fi: \fi: \fi: + \if_int_compare:w #2 > \c_@@_max_exponent_int 1 ~ \else: + \if_int_compare:w #2 < - \c_@@_max_exponent_int 2 ~ \else: + \if_meaning:w 1 #1 3 ~ \else: 0 ~ \fi: \fi: \fi: \or: \exp_after:wN \@@_overflow:w \or: \exp_after:wN \@@_underflow:w \or: \exp_after:wN \@@_sanitize_zero:w @@ -717,7 +741,7 @@ { \cs:w @@_decimate_ - \if_int_compare:w \__int_eval:w #1 > \c_sixteen + \if_int_compare:w \__int_eval:w #1 > \c_@@_prec_int tiny \else: \__int_to_roman:w \__int_eval:w #1 @@ -760,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 @@ -799,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 @@ -942,8 +953,8 @@ } \cs_new:Npn \@@_int_normal:nnnnn #1 #2#3#4#5 { - \if_int_compare:w #1 > \c_zero - \@@_decimate:nNnnnn { \c_sixteen - #1 } + \if_int_compare:w #1 > 0 \exp_stop_f: + \@@_decimate:nNnnnn { \c_@@_prec_int - #1 } \@@_int_test:Nw {#2} {#3} {#4} {#5} \else: @@ -1007,8 +1018,8 @@ \cs_new:Npn \@@_small_int_true:wTF #1; #2#3 { #2 {#1} } \cs_new:Npn \@@_small_int_normal:NnwTF #1#2#3; { - \if_int_compare:w #2 > \c_zero - \@@_decimate:nNnnnn { \c_sixteen - #2 } + \if_int_compare:w #2 > 0 \exp_stop_f: + \@@_decimate:nNnnnn { \c_@@_prec_int - #2 } \@@_small_int_test:NnnwNnw #3 #1 {#2} \else: @@ -1021,7 +1032,7 @@ \if_meaning:w 0 #1 \exp_after:wN \@@_small_int_true:wTF \__int_value:w \if_meaning:w 2 #5 - \fi: - \if_int_compare:w #6 > \c_eight + \if_int_compare:w #6 > \c_@@_half_prec_int 1 0000 0000 \else: #3 @@ -1045,13 +1056,13 @@ % \begin{macrocode} \cs_new:Npn \@@_array_count:n #1 { - \__int_value:w \__int_eval:w \c_zero + \__int_value:w \__int_eval:w 0 \@@_array_count_loop:Nw #1 { ? \__prg_break: } ; \__prg_break_point: \__int_eval_end: } \cs_new:Npn \@@_array_count_loop:Nw #1#2; - { \use_none:n #1 + \c_one \@@_array_count_loop:Nw } + { \use_none:n #1 + 1 \@@_array_count_loop:Nw } % \end{macrocode} % \end{macro} % \end{macro} |