summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3fp.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3fp.dtx164
1 files changed, 94 insertions, 70 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx
index 82c1a9f6f59..35213537c69 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3fp.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-%% File: l3fp.dtx Copyright (C) 2010,2011 The LaTeX3 Project
+%% File: l3fp.dtx Copyright (C) 2010-2012 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
@@ -35,7 +35,7 @@
%
%<*driver|package>
\RequirePackage{l3names}
-\GetIdInfo$Id: l3fp.dtx 3086 2011-12-22 17:55:46Z bruno $
+\GetIdInfo$Id: l3fp.dtx 3154 2012-01-08 22:46:28Z bruno $
{L3 Experimental floating-point operations}
%</driver|package>
%<*driver>
@@ -144,6 +144,17 @@
% Sets the \meta{floating point variable} to |+0.000000000e0|.
% \end{function}
%
+% \begin{function}[added = 2012-01-07]
+% {\fp_zero_new:N, \fp_zero_new:c, \fp_gzero_new:N, \fp_gzero_new:c}
+% \begin{syntax}
+% \cs{fp_zero_new:N} \meta{floating point variable}
+% \end{syntax}
+% Ensures that the \meta{floating point variable} exists globally
+% by applying \cs{fp_new:N} if necessary, then applies
+% \cs{fp_(g)zero:N} to leave the \meta{floating point variable}
+% set to zero.
+% \end{function}
+%
% \begin{function}{\fp_set:Nn, \fp_set:cn, \fp_gset:Nn, \fp_gset:cn}
% \begin{syntax}
% \cs{fp_set:Nn} \meta{floating point variable} \Arg{value}
@@ -815,18 +826,18 @@
% \end{macrocode}
% \end{variable}
%
-% \begin{variable}{\l_fp_tmp_int}
+% \begin{variable}{\l_fp_internal_int}
% A scratch \texttt{int}: used only where the value is not carried
% forward.
% \begin{macrocode}
-\int_new:N \l_fp_tmp_int
+\int_new:N \l_fp_internal_int
% \end{macrocode}
% \end{variable}
%
-% \begin{variable}{\l_fp_tmp_tl}
+% \begin{variable}{\l_fp_internal_tl}
% A scratch token list variable for expanding material.
% \begin{macrocode}
-\tl_new:N \l_fp_tmp_tl
+\tl_new:N \l_fp_internal_tl
% \end{macrocode}
% \end{variable}
%
@@ -895,34 +906,34 @@
% \begin{macrocode}
\cs_new_protected:Npn \fp_split:Nn #1#2
{
- \tl_set:Nx \l_fp_tmp_tl {#2}
- \tl_set_rescan:Nno \l_fp_tmp_tl { \char_set_catcode_ignore:n { 32 } }
- { \l_fp_tmp_tl }
+ \tl_set:Nx \l_fp_internal_tl {#2}
+ \tl_set_rescan:Nno \l_fp_internal_tl { \char_set_catcode_ignore:n { 32 } }
+ { \l_fp_internal_tl }
\l_fp_split_sign_int \c_one
\fp_split_sign:
\use:c { l_fp_input_ #1 _sign_int } \l_fp_split_sign_int
- \exp_after:wN \fp_split_exponent:w \l_fp_tmp_tl e e \q_stop #1
+ \exp_after:wN \fp_split_exponent:w \l_fp_internal_tl e e \q_stop #1
}
\cs_new_protected_nopar:Npn \fp_split_sign:
{
\if_int_compare:w \pdftex_strcmp:D
- { \exp_after:wN \tl_head:w \l_fp_tmp_tl ? \q_stop } { - }
+ { \exp_after:wN \tl_head:w \l_fp_internal_tl ? \q_stop } { - }
= \c_zero
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
\exp_after:wN
- \tl_tail:w \l_fp_tmp_tl \prg_do_nothing: \q_stop
+ \tl_tail:w \l_fp_internal_tl \prg_do_nothing: \q_stop
}
\l_fp_split_sign_int -\l_fp_split_sign_int
\exp_after:wN \fp_split_sign:
\else:
\if_int_compare:w \pdftex_strcmp:D
- { \exp_after:wN \tl_head:w \l_fp_tmp_tl ? \q_stop } { + }
+ { \exp_after:wN \tl_head:w \l_fp_internal_tl ? \q_stop } { + }
= \c_zero
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
\exp_after:wN
- \tl_tail:w \l_fp_tmp_tl \prg_do_nothing: \q_stop
+ \tl_tail:w \l_fp_internal_tl \prg_do_nothing: \q_stop
}
\exp_after:wN \exp_after:wN \exp_after:wN \fp_split_sign:
\fi:
@@ -942,9 +953,9 @@
{ \fp_split_aux_iii:w {#1#2#3#4#5#6#7#8#9} }
\cs_new_protected:Npn \fp_split_aux_iii:w #1#2 \q_stop
{
- \l_fp_tmp_int 1 #1 \scan_stop:
+ \l_fp_internal_int 1 #1 \scan_stop:
\exp_after:wN \fp_split_decimal:w
- \int_use:N \l_fp_tmp_int 000000000 \q_stop
+ \int_use:N \l_fp_internal_int 000000000 \q_stop
}
\cs_new_protected:Npn \fp_split_decimal:w #1#2#3#4#5#6#7#8#9
{ \fp_split_decimal_aux:w {#2#3#4#5#6#7#8#9} }
@@ -1029,12 +1040,12 @@
#2 ##1##2##3##4##5##6##7##8 \scan_stop:
\tex_advance:D #3 \c_one_thousand_million
\tex_divide:D #3 \c_ten
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
##9
\exp_after:wN \use_none:n \int_use:N #3
}
- #3 \l_fp_tmp_tl \scan_stop:
+ #3 \l_fp_internal_tl \scan_stop:
\tex_advance:D #4 \c_one
}
\fp_standardise_aux:
@@ -1093,13 +1104,13 @@
\l_fp_input_b_integer_int #1#2#3#4#5#6#7#8 \scan_stop:
\tex_advance:D \l_fp_input_b_decimal_int \c_one_thousand_million
\tex_divide:D \l_fp_input_b_decimal_int \c_ten
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
#9
\exp_after:wN \use_none:n
\int_use:N \l_fp_input_b_decimal_int
}
- \l_fp_input_b_decimal_int \l_fp_tmp_tl \scan_stop:
+ \l_fp_input_b_decimal_int \l_fp_internal_tl \scan_stop:
\tex_advance:D \l_fp_input_b_exponent_int \c_one
}
\cs_new_protected_nopar:Npn \fp_level_input_exponents_b:
@@ -1118,13 +1129,13 @@
\l_fp_input_a_integer_int #1#2#3#4#5#6#7#8 \scan_stop:
\tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
\tex_divide:D \l_fp_input_a_decimal_int \c_ten
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
#9
\exp_after:wN \use_none:n
\int_use:N \l_fp_input_a_decimal_int
}
- \l_fp_input_a_decimal_int \l_fp_tmp_tl \scan_stop:
+ \l_fp_input_a_decimal_int \l_fp_internal_tl \scan_stop:
\tex_advance:D \l_fp_input_a_exponent_int \c_one
}
% \end{macrocode}
@@ -1193,6 +1204,19 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}
+% {\fp_zero_new:N, \fp_zero_new:c, \fp_gzero_new:N, \fp_gzero_new:c}
+% Create a floating point if needed, otherwise clear it.
+% \begin{macrocode}
+\cs_new_protected:Npn \fp_zero_new:N #1
+ { \cs_if_exist:NTF #1 { \fp_zero:N #1 } { \fp_new:N #1 } }
+\cs_new_protected:Npn \fp_gzero_new:N #1
+ { \cs_if_exist:NTF #1 { \fp_gzero:N #1 } { \fp_new:N #1 } }
+\cs_generate_variant:Nn \fp_zero_new:N { c }
+\cs_generate_variant:Nn \fp_gzero_new:N { c }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\fp_set:Nn, \fp_set:cn}
% \UnitTested
% \begin{macro}{\fp_gset:Nn, \fp_gset:cn}
@@ -1250,8 +1274,8 @@
% \UnitTested
% \begin{macro}[aux]{\fp_set_from_dim_aux:NNn}
% \begin{macro}[aux]{\fp_set_from_dim_aux:w}
-% \begin{variable}{\l_fp_tmp_dim}
-% \begin{variable}{\l_fp_tmp_skip}
+% \begin{variable}{\l_fp_internal_dim}
+% \begin{variable}{\l_fp_internal_skip}
% Here, dimensions are converted to fixed-points \emph{via} a
% temporary variable. This ensures that they always convert as points.
% The code is then essentially the same as for \cs{fp_set:Nn}, but with
@@ -1266,12 +1290,12 @@
\cs_new_protected:Npn \fp_set_from_dim_aux:NNn #1#2#3
{
\group_begin:
- \l_fp_tmp_skip \etex_glueexpr:D #3 \scan_stop:
- \l_fp_tmp_dim \l_fp_tmp_skip
+ \l_fp_internal_skip \etex_glueexpr:D #3 \scan_stop:
+ \l_fp_internal_dim \l_fp_internal_skip
\fp_split:Nn a
{
\exp_after:wN \fp_set_from_dim_aux:w
- \dim_use:N \l_fp_tmp_dim
+ \dim_use:N \l_fp_internal_dim
}
\fp_standardise:NNNN
\l_fp_input_a_sign_int
@@ -1307,8 +1331,8 @@
\fp_set_from_dim_aux:w
\cs_generate_variant:Nn \fp_set_from_dim:Nn { c }
\cs_generate_variant:Nn \fp_gset_from_dim:Nn { c }
-\dim_new:N \l_fp_tmp_dim
-\skip_new:N \l_fp_tmp_skip
+\dim_new:N \l_fp_internal_dim
+\skip_new:N \l_fp_internal_skip
% \end{macrocode}
% \end{variable}
% \end{variable}
@@ -2030,15 +2054,15 @@
{
\if_int_compare:w \l_fp_round_position_int < \l_fp_round_target_int
\bool_if:NTF \l_fp_round_carry_bool
- { \l_fp_tmp_int \int_eval:w #1 + \c_one \scan_stop: }
- { \l_fp_tmp_int \int_eval:w #1 \scan_stop: }
- \if_int_compare:w \l_fp_tmp_int = \c_ten
- \l_fp_tmp_int \c_zero
+ { \l_fp_internal_int \int_eval:w #1 + \c_one \scan_stop: }
+ { \l_fp_internal_int \int_eval:w #1 \scan_stop: }
+ \if_int_compare:w \l_fp_internal_int = \c_ten
+ \l_fp_internal_int \c_zero
\else:
\bool_set_false:N \l_fp_round_carry_bool
\fi:
\tl_set:Nx \l_fp_round_decimal_tl
- { \int_use:N \l_fp_tmp_int \l_fp_round_decimal_tl }
+ { \int_use:N \l_fp_internal_int \l_fp_round_decimal_tl }
\else:
\tl_set:Nx \l_fp_round_decimal_tl { 0 \l_fp_round_decimal_tl }
\if_int_compare:w \l_fp_round_position_int = \l_fp_round_target_int
@@ -2114,7 +2138,7 @@
\group_begin:
\fp_read:N #2
\tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
\if_int_compare:w \l_fp_input_a_sign_int < \c_zero
+
@@ -2129,7 +2153,7 @@
\int_use:N \l_fp_input_a_exponent_int
}
\exp_after:wN \group_end: \exp_after:wN
- #1 \exp_after:wN #2 \exp_after:wN { \l_fp_tmp_tl }
+ #1 \exp_after:wN #2 \exp_after:wN { \l_fp_internal_tl }
}
% \end{macrocode}
% \end{macro}
@@ -2883,16 +2907,16 @@
% \begin{macrocode}
\cs_new_protected:Npn \fp_div_integer:NNNNN #1#2#3#4#5
{
- \l_fp_tmp_int #1
- \tex_divide:D \l_fp_tmp_int #3
- \l_fp_tmp_int \int_eval:w #1 - \l_fp_tmp_int * #3 \int_eval_end:
+ \l_fp_internal_int #1
+ \tex_divide:D \l_fp_internal_int #3
+ \l_fp_internal_int \int_eval:w #1 - \l_fp_internal_int * #3 \int_eval_end:
#4 #1
\tex_divide:D #4 #3
#5 #2
\tex_divide:D #5 #3
- \tex_multiply:D \l_fp_tmp_int \c_one_thousand
- \tex_divide:D \l_fp_tmp_int #3
- #5 \int_eval:w #5 + \l_fp_tmp_int * \c_one_million \int_eval_end:
+ \tex_multiply:D \l_fp_internal_int \c_one_thousand
+ \tex_divide:D \l_fp_internal_int #3
+ #5 \int_eval:w #5 + \l_fp_internal_int * \c_one_million \int_eval_end:
\if_int_compare:w #5 > \c_one_thousand_million
\tex_advance:D #4 \c_one
\tex_advance:D #5 -\c_one_thousand_million
@@ -2962,21 +2986,21 @@
\if_int_compare:w \l_fp_input_a_integer_int = \c_zero
\l_fp_input_a_decimal_int #1#2#3#4#5#6#7#8 \scan_stop:
\else:
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
\int_use:N \l_fp_input_a_integer_int
#1#2#3#4#5#6#7#8
}
\l_fp_input_a_integer_int \c_zero
- \l_fp_input_a_decimal_int \l_fp_tmp_tl \scan_stop:
+ \l_fp_input_a_decimal_int \l_fp_internal_tl \scan_stop:
\fi:
\tex_divide:D \l_fp_input_a_extended_int \c_ten
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
#9
\int_use:N \l_fp_input_a_extended_int
}
- \l_fp_input_a_extended_int \l_fp_tmp_tl \scan_stop:
+ \l_fp_input_a_extended_int \l_fp_internal_tl \scan_stop:
\tex_advance:D \l_fp_input_a_exponent_int \c_one
}
% \end{macrocode}
@@ -3010,14 +3034,14 @@
{
\l_fp_output_integer_int #1#2#3#4#5#6#7#8 \scan_stop:
\tex_advance:D \l_fp_output_decimal_int \c_one_thousand_million
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
#9
\exp_after:wN \use_none:n
\int_use:N \l_fp_output_decimal_int
}
\exp_after:wN \fp_extended_normalise_output_aux_ii:NNNNNNNNN
- \l_fp_tmp_tl
+ \l_fp_internal_tl
}
\cs_new_protected:Npn \fp_extended_normalise_output_aux_ii:NNNNNNNNN
#1#2#3#4#5#6#7#8#9
@@ -3029,13 +3053,13 @@
{
\tex_advance:D \l_fp_output_extended_int \c_one_thousand_million
\tex_divide:D \l_fp_output_extended_int \c_ten
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
#1
\exp_after:wN \use_none:n
\int_use:N \l_fp_output_extended_int
}
- \l_fp_output_extended_int \l_fp_tmp_tl \scan_stop:
+ \l_fp_output_extended_int \l_fp_internal_tl \scan_stop:
\tex_advance:D \l_fp_output_exponent_int \c_one
}
% \end{macrocode}
@@ -4043,27 +4067,27 @@
\l_fp_exp_exponent_int \c_zero
\exp_after:wN \fp_exp_integer_tens:
\else:
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
\exp_after:wN \use_i:nnn
\int_use:N \l_fp_input_a_integer_int
}
\l_fp_input_a_integer_int
\int_eval:w
- \l_fp_input_a_integer_int - \l_fp_tmp_tl 00
+ \l_fp_input_a_integer_int - \l_fp_internal_tl 00
\int_eval_end:
\if_int_compare:w \l_fp_input_a_sign_int < \c_zero
\if_int_compare:w \l_fp_output_integer_int > 200 \scan_stop:
\fp_exp_const:cx { c_fp_exp ( \l_fp_arg_tl ) _fp }
{ \c_zero_fp }
\else:
- \fp_exp_integer_const:n { - \l_fp_tmp_tl 00 }
+ \fp_exp_integer_const:n { - \l_fp_internal_tl 00 }
\exp_after:wN \exp_after:wN \exp_after:wN
\exp_after:wN \exp_after:wN \exp_after:wN
\exp_after:wN \fp_exp_integer_tens:
\fi:
\else:
- \fp_exp_integer_const:n { \l_fp_tmp_tl 00 }
+ \fp_exp_integer_const:n { \l_fp_internal_tl 00 }
\exp_after:wN \exp_after:wN \exp_after:wN
\exp_after:wN \fp_exp_integer_tens:
\fi:
@@ -4081,19 +4105,19 @@
\l_fp_output_extended_int \l_fp_exp_extended_int
\l_fp_output_exponent_int \l_fp_exp_exponent_int
\if_int_compare:w \l_fp_input_a_integer_int > \c_nine
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
\exp_after:wN \use_i:nn
\int_use:N \l_fp_input_a_integer_int
}
\l_fp_input_a_integer_int
\int_eval:w
- \l_fp_input_a_integer_int - \l_fp_tmp_tl 0
+ \l_fp_input_a_integer_int - \l_fp_internal_tl 0
\int_eval_end:
\if_int_compare:w \l_fp_input_a_sign_int > \c_zero
- \fp_exp_integer_const:n { \l_fp_tmp_tl 0 }
+ \fp_exp_integer_const:n { \l_fp_internal_tl 0 }
\else:
- \fp_exp_integer_const:n { - \l_fp_tmp_tl 0 }
+ \fp_exp_integer_const:n { - \l_fp_internal_tl 0 }
\fi:
\fp_mul:NNNNNNNNN
\l_fp_exp_integer_int \l_fp_exp_decimal_int \l_fp_exp_extended_int
@@ -4562,21 +4586,21 @@
\if_int_compare:w \l_fp_exp_integer_int = \c_zero
\l_fp_exp_decimal_int #1#2#3#4#5#6#7#8 \scan_stop:
\else:
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
\int_use:N \l_fp_exp_integer_int
#1#2#3#4#5#6#7#8
}
\l_fp_exp_integer_int \c_zero
- \l_fp_exp_decimal_int \l_fp_tmp_tl \scan_stop:
+ \l_fp_exp_decimal_int \l_fp_internal_tl \scan_stop:
\fi:
\tex_divide:D \l_fp_exp_extended_int \c_ten
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
#9
\int_use:N \l_fp_exp_extended_int
}
- \l_fp_exp_extended_int \l_fp_tmp_tl \scan_stop:
+ \l_fp_exp_extended_int \l_fp_internal_tl \scan_stop:
\tex_advance:D \l_fp_exp_exponent_int \c_one
}
% \end{macrocode}
@@ -4769,13 +4793,13 @@
\if_int_compare:w \l_fp_output_integer_int = \c_zero
\l_fp_output_decimal_int #1#2#3#4#5#6#7#8 \scan_stop:
\else:
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
\int_use:N \l_fp_output_integer_int
#1#2#3#4#5#6#7#8
}
\l_fp_output_integer_int \c_zero
- \l_fp_output_decimal_int \l_fp_tmp_tl \scan_stop:
+ \l_fp_output_decimal_int \l_fp_internal_tl \scan_stop:
\fi:
\tex_advance:D \l_fp_output_exponent_int \c_one
}
@@ -5350,7 +5374,7 @@
% \begin{macrocode}
\cs_new_protected_nopar:cpn { fp_compare_<: }
{
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
\int_set:Nn \exp_not:N \l_fp_input_a_sign_int
{ \int_use:N \l_fp_input_b_sign_int }
@@ -5369,7 +5393,7 @@
\int_set:Nn \exp_not:N \l_fp_input_b_exponent_int
{ \int_use:N \l_fp_input_a_exponent_int }
}
- \l_fp_tmp_tl
+ \l_fp_internal_tl
\use:c { fp_compare_>: }
}
% \end{macrocode}
@@ -5397,12 +5421,12 @@
\prg_new_protected_conditional:Npnn \fp_compare:n #1 { T , F , TF }
{
\group_begin:
- \tl_set:Nx \l_fp_tmp_tl
+ \tl_set:Nx \l_fp_internal_tl
{
\group_end:
\fp_compare_aux_i:w #1 \exp_not:n { == \q_nil == \q_stop }
}
- \l_fp_tmp_tl
+ \l_fp_internal_tl
}
\cs_new_protected:Npn \fp_compare_aux_i:w #1 == #2 == #3 \q_stop
{