diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/l3fp.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/l3fp.sty | 138 |
1 files changed, 72 insertions, 66 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3fp.sty b/Master/texmf-dist/tex/latex/l3kernel/l3fp.sty index 00d73728018..e22994a4726 100644 --- a/Master/texmf-dist/tex/latex/l3kernel/l3fp.sty +++ b/Master/texmf-dist/tex/latex/l3kernel/l3fp.sty @@ -13,7 +13,7 @@ %% %% Do not distribute a modified version of this file. %% -%% 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 @@ -46,7 +46,7 @@ %% %% ----------------------------------------------------------------------- \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} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} @@ -115,8 +115,8 @@ \int_new:N \l_fp_round_target_int \tl_new:N \l_fp_sign_tl \int_new:N \l_fp_split_sign_int -\int_new:N \l_fp_tmp_int -\tl_new:N \l_fp_tmp_tl +\int_new:N \l_fp_internal_int +\tl_new:N \l_fp_internal_tl \int_new:N \l_fp_trig_octant_int \int_new:N \l_fp_trig_sign_int \int_new:N \l_fp_trig_decimal_int @@ -136,34 +136,34 @@ } \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: @@ -183,9 +183,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} } @@ -252,12 +252,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: @@ -299,13 +299,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: @@ -324,13 +324,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 } \cs_new_protected:Npn \fp_tmp:w #1#2 { } @@ -352,6 +352,12 @@ { \tl_gset_eq:NN #1 \c_zero_fp } \cs_generate_variant:Nn \fp_zero:N { c } \cs_generate_variant:Nn \fp_gzero:N { c } +\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 } \cs_new_protected_nopar:Npn \fp_set:Nn { \fp_set_aux:NNn \tl_set:Nn } \cs_new_protected_nopar:Npn \fp_gset:Nn { \fp_set_aux:NNn \tl_gset:Nn } \cs_new_protected:Npn \fp_set_aux:NNn #1#2#3 @@ -393,12 +399,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 @@ -434,8 +440,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 \cs_new_eq:NN \fp_set_eq:NN \tl_set_eq:NN \cs_new_eq:NN \fp_set_eq:cN \tl_set_eq:cN \cs_new_eq:NN \fp_set_eq:Nc \tl_set_eq:Nc @@ -900,15 +906,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 @@ -956,7 +962,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 + @@ -971,7 +977,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 } } \cs_new_protected_nopar:Npn \fp_add:Nn { \fp_add_aux:NNn \tl_set:Nn } \cs_new_protected_nopar:Npn \fp_gadd:Nn { \fp_add_aux:NNn \tl_gset:Nn } @@ -1504,16 +1510,16 @@ } \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 @@ -1568,21 +1574,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 } \cs_new_protected_nopar:Npn \fp_extended_normalise_output: @@ -1600,14 +1606,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 @@ -1619,13 +1625,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 } \cs_new_protected_nopar:Npn \fp_trig_normalise: @@ -2347,27 +2353,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: @@ -2380,19 +2386,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 @@ -2723,21 +2729,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 } \cs_new_protected_nopar:Npn \fp_ln_mantissa: @@ -2860,13 +2866,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 } @@ -3304,7 +3310,7 @@ } \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 } @@ -3323,18 +3329,18 @@ \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_>: } } \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 { |