diff options
author | Karl Berry <karl@freefriends.org> | 2017-01-29 22:34:57 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-01-29 22:34:57 +0000 |
commit | fabbcd2656be5dca3e1986ddcc8c827a23e9aedf (patch) | |
tree | 4f669dff01da1c31477e1e876fc878cddd5c06ab /Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx | |
parent | ebc35af4250051fed5186c59ba4eaff9949142e2 (diff) |
l3 (29jan17)
git-svn-id: svn://tug.org/texlive/trunk@43088 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx | 143 |
1 files changed, 76 insertions, 67 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx index 68282396cce..fa1b7538c83 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-logic.dtx @@ -1,42 +1,28 @@ % \iffalse meta-comment % %% File: l3fp-logic.dtx Copyright (C) 2011-2014,2016 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 -%% license or (at your option) any later version. The latest version -%% of this license is in the file -%% -%% http://www.latex-project.org/lppl.txt -%% -%% This file is part of the "l3kernel bundle" (The Work in LPPL) -%% and all files in that bundle must be distributed together. -%% -%% The released version of this bundle is available from CTAN. -%% -%% ----------------------------------------------------------------------- -%% -%% The development version of the bundle can be found at -%% -%% http://www.latex-project.org/svnroot/experimental/trunk/ -%% -%% for those people who are interested. -%% -%%%%%%%%%%% -%% NOTE: %% -%%%%%%%%%%% -%% -%% Snapshots taken from the repository represent work in progress and may -%% not work or may contain conflicting material! We therefore ask -%% people _not_ to put them into distributions, archives, etc. without -%% prior consultation with the LaTeX Project Team. -%% -%% ----------------------------------------------------------------------- -%% +% +% It may be distributed and/or modified under the conditions of the +% LaTeX Project Public License (LPPL), either version 1.3c of this +% license or (at your option) any later version. The latest version +% of this license is in the file +% +% http://www.latex-project.org/lppl.txt +% +% This file is part of the "l3kernel bundle" (The Work in LPPL) +% and all files in that bundle must be distributed together. +% +% ----------------------------------------------------------------------- +% +% The development version of the bundle can be found at +% +% https://github.com/latex3/latex3 +% +% for those people who are interested. % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-logic.dtx 6759 2016-11-21 17:04:08Z joseph $ +\GetIdInfo$Id: l3fp-logic.dtx 6805 2016-12-28 22:15:52Z joseph $ {L3 Floating-point conditionals} \begin{document} \DocInput{\jobname.dtx} @@ -318,56 +304,72 @@ % % \begin{macro}[EXP]{\fp_step_function:nnnN, \fp_step_function:nnnc} % \begin{macro}[EXP, aux]{\@@_step:wwwN} -% \begin{macro}[EXP, aux]{\@@_step:NnnnN, \@@_step:NfnnN} -% The approach here is much the same as \cs{int_step_function:nnnN} except we -% do not have a convenient low-level way to evaluation each argument to give -% a pure number. Instead, the internal parser is used to leave values in the -% internal format (and avoid a more expensive \texttt{f}-type expansion of -% multiple uses of \texttt{fp_eval:n}). +% \begin{macro}[EXP, aux]{\@@_step:NnnnnN, \@@_step:NfnnnN} +% The approach here is somewhat similar to +% \cs{int_step_function:nnnN}. There are two subtleties: we use the +% internal parser \cs{@@_parse:n} to avoid converting back and forth +% from the internal representation; and (due to rounding) even a +% non-zero step does not guarantee that the loop counter will +% increase. % \begin{macrocode} \cs_new:Npn \fp_step_function:nnnN #1#2#3 { \exp_after:wN \@@_step:wwwN - \exp:w \exp_end_continue_f:w \@@_parse_o:n {#1} : - \exp:w \exp_end_continue_f:w \@@_parse_o:n {#2} : - \exp:w \exp_end_continue_f:w \@@_parse:n {#3} : + \exp:w \exp_end_continue_f:w \@@_parse_o:n {#1} + \exp:w \exp_end_continue_f:w \@@_parse_o:n {#2} + \exp:w \exp_end_continue_f:w \@@_parse:n {#3} } \cs_generate_variant:Nn \fp_step_function:nnnN { nnnc } -% \end{macrocode} -% Here, |#1| will be passed to the output on the first pass of the loop. -% To avoid this being in internal form, an \texttt{f}-type expansion is used -% here on that value only. The second and third arguments will be converted -% during the loop itself. +% \end{macrocode} +% Only \enquote{normal} floating points (not $\pm 0$, +% $\pm\texttt{inf}$, \texttt{nan}) can be used as step; if positive, +% call \cs{@@_step:NnnnnN} with argument |>| otherwise~|<|. This +% function has one more argument than its integer counterpart, namely +% the previous value, to catch the case where the loop has made no +% progress. Conversion to decimal is done just before calling the +% user's function. % \begin{macrocode} -\cs_new:Npn \@@_step:wwwN #1 : #2 : #3 : #4 +\cs_new:Npn \@@_step:wwwN #1 ; \s_@@ \@@_chk:w #2#3#4 ; #5; #6 { - \fp_compare:nNnTF {#2} > 0 - { \@@_step:NfnnN > } + \token_if_eq_meaning:NNTF #2 1 + { + \token_if_eq_meaning:NNTF #3 0 + { \@@_step:NnnnnN > } + { \@@_step:NnnnnN < } + } { - \fp_compare:nNnTF {#2} = 0 + \token_if_eq_meaning:NNTF #2 0 + { \__msg_kernel_expandable_error:nnn { kernel } { zero-step } {#6} } { - \__msg_kernel_expandable_error:nnn { kernel } { zero-step } {#4} - \use_none:nnnn + \@@_error:nnfn { bad-step } { } + { \fp_to_tl:n { \s_@@ \@@_chk:w #2#3#4 ; } } {#6} } - { \@@_step:NfnnN < } + \use_none:nnnnn } - { \fp_eval:n {#1} } {#2} {#3} #4 + { #1 ; } { \c_nan_fp } { \s_@@ \@@_chk:w #2#3#4 ; } { #5 ; } #6 } - -\cs_new:Npn \@@_step:NnnnN #1#2#3#4#5 +\cs_new:Npn \@@_step:NnnnnN #1#2#3#4#5#6 { - \fp_compare:nNnF {#2} #1 {#4} + \fp_compare:nNnTF {#2} = {#3} + { + \@@_error:nffn { tiny-step } + { \fp_to_tl:n {#3} } { \fp_to_tl:n {#4} } {#6} + } { - #5 {#2} - \@@_step:NfnnN - #1 { \fp_eval:n { #2 + #3 } } {#3} {#4} #5 + \fp_compare:nNnF {#2} #1 {#5} + { + \exp_args:Nf #6 { \@@_to_decimal_dispatch:w #2 } + \@@_step:NfnnnN + #1 { \@@_parse:n { #2 + #4 } } {#2} {#4} {#5} #6 + } } } -\cs_generate_variant:Nn \@@_step:NnnnN { Nf } +\cs_generate_variant:Nn \@@_step:NnnnnN { Nf } % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} +% % \begin{macro}{\fp_step_inline:nnnn} % As for \cs{int_step_inline:nnnn}, create a global function and apply it, % following up with a break point. @@ -384,6 +386,13 @@ % \end{macrocode} % \end{macro} % +% \begin{macrocode} +\__msg_kernel_new:nnn { kernel } { fp-bad-step } + { Invalid~step~size~#2~in~step~function~#3. } +\__msg_kernel_new:nnn { kernel } { fp-tiny-step } + { Tiny~step~size~(#1+#2=#1)~in~step~function~#3. } +% \end{macrocode} +% % \subsection{Extrema} % % \begin{macro}[int, EXP]{\@@_minmax_o:Nw} @@ -400,9 +409,9 @@ \cs_new:Npn \@@_minmax_o:Nw #1#2 @ { \if_meaning:w 0 #1 - \exp_after:wN \@@_minmax_loop:Nww \exp_after:wN \c_one + \exp_after:wN \@@_minmax_loop:Nww \exp_after:wN + \else: - \exp_after:wN \@@_minmax_loop:Nww \exp_after:wN \c_minus_one + \exp_after:wN \@@_minmax_loop:Nww \exp_after:wN - \fi: #2 \s_@@ \@@_chk:w 2 #1 \s_@@_exact ; @@ -412,7 +421,7 @@ % \end{macro} % % \begin{macro}[aux, EXP]{\@@_minmax_loop:Nww} -% The first argument is $-1$ or $1$ to denote the case where the +% The first argument is $-$ or $+$ to denote the case where the % currently largest (smallest) number found (first floating point % argument) should be replaced by the new number (second floating % point argument). If the new number is \texttt{nan}, keep that as @@ -436,7 +445,7 @@ \@@_compare_back:ww \s_@@ \@@_chk:w #4#5; \s_@@ \@@_chk:w #2#3; - = #1 + = #1 \c_one \@@_minmax_auxii:ww \else: \@@_minmax_auxi:ww @@ -545,7 +554,7 @@ \@@_exp_after_array_f:w #3 \s_@@_stop \exp_after:wN @ \exp:w - \@@_parse_operand:Nw \c_two + \@@_parse_operand:Nw \c_@@_prec_colon_int \@@_parse_expand:w \else: \__msg_kernel_expandable_error:nnnn |