diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx | 74 |
1 files changed, 65 insertions, 9 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx index 31a0ba85783..37ae94e798d 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-round.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3fp-round.dtx Copyright(C) 2011-2012,2014-2016 The LaTeX3 Project +%% File: l3fp-round.dtx Copyright(C) 2011-2012,2014-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,8 +22,8 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-round.dtx 6968 2017-02-20 16:08:44Z bruno $ - {L3 Floating-point rounding} +\def\ExplFileDate{2017/03/18} +\def\ExplFileVersion{7019} \begin{document} \DocInput{\jobname.dtx} \end{document} @@ -71,6 +71,63 @@ % ^^A todo: optimize all rounding functions for various rounding modes. % ^^A todo: reduce the number of almost identical functions. % +% \begin{macro}[aux, EXP] +% { +% \@@_parse_word_trunc:N, +% \@@_parse_word_floor:N, +% \@@_parse_word_ceil:N +% } +% \begin{macrocode} +\cs_new:Npn \@@_parse_word_trunc:N + { \@@_parse_function:NNN \@@_round_o:Nw \@@_round_to_zero:NNN } +\cs_new:Npn \@@_parse_word_floor:N + { \@@_parse_function:NNN \@@_round_o:Nw \@@_round_to_ninf:NNN } +\cs_new:Npn \@@_parse_word_ceil:N + { \@@_parse_function:NNN \@@_round_o:Nw \@@_round_to_pinf:NNN } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[aux, EXP] +% { +% \@@_parse_word_round:N, \@@_parse_round:Nw, +% \@@_parse_round_deprecation_error:Nw +% } +% \begin{macro}[aux, deprecated = 2017-12-31]{round+, round0, round-} +% This looks for |+|, |-|, |0| after |round|. That syntax is deprecated. +% \begin{macrocode} +\cs_new:Npn \@@_parse_word_round:N #1#2 + { + \if_meaning:w + #2 + \@@_parse_round:Nw \@@_round_to_pinf:NNN + \else: + \if_meaning:w 0 #2 + \@@_parse_round:Nw \@@_round_to_zero:NNN + \else: + \if_meaning:w - #2 + \@@_parse_round:Nw \@@_round_to_ninf:NNN + \fi: + \fi: + \fi: + \@@_parse_function:NNN + \@@_round_o:Nw \@@_round_to_nearest:NNN #1 + #2 + } +\cs_new:Npn \@@_parse_round:Nw + #1 #2 \@@_round_to_nearest:NNN #3#4 { #2 #1 #3 } +\cs_new:Npn \@@_parse_round_deprecation_error:Nw + #1 #2 \@@_round_to_nearest:NNN #3#4 + { + \@@_error:nnfn { fp-deprecated } { round#4() } + { + \str_case:nn {#2} + { { + } { ceil } { 0 } { trunc } { - } { floor } } + } { } + #2 #1 #3 + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% % \subsection{Rounding tools} % % \begin{variable}{\c_@@_five_int} @@ -344,7 +401,6 @@ % % ^^A todo: This macro is intermingled with l3fp-parse. % ^^A todo: Add explanations. -% ^^A todo: This macro f-expands rather than o-expands after itself, is that an issue? % \begin{macro}[aux,EXP]{\@@_round_o:Nw} % The |trunc|, |ceil| and |floor| functions expect one or two % arguments (the second is $0$ by default), and the |round| function @@ -361,7 +417,7 @@ \or: \@@_round:Nww #1 #2 \exp:w \else: \@@_round:Nwww #1 #2 @ \exp:w \fi: - \exp_end_continue_f:w + \exp_after:wN \exp_end: } % \end{macrocode} % \end{macro} @@ -371,9 +427,9 @@ \cs_new:Npn \@@_round_no_arg_o:Nw #1 { \cs_if_eq:NNTF #1 \@@_round_to_nearest:NNN - { \@@_error:nnnn { num-args } { round () } { 1 } { 3 } } + { \@@_error:nnnn { fp-num-args } { round () } { 1 } { 3 } } { - \@@_error:nffn { num-args } + \@@_error:nffn { fp-num-args } { \@@_round_name_from_cs:N #1 () } { 1 } { 2 } } \exp_after:wN \c_nan_fp @@ -404,12 +460,12 @@ #2 ; #3 ; } { - \@@_error:nnnn { num-args } { round () } { 1 } { 3 } + \@@_error:nnnn { fp-num-args } { round () } { 1 } { 3 } \exp_after:wN \c_nan_fp } } { - \@@_error:nffn { num-args } + \@@_error:nffn { fp-num-args } { \@@_round_name_from_cs:N #1 () } { 1 } { 2 } \exp_after:wN \c_nan_fp } |