summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/expl3
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-09-15 23:59:34 +0000
committerKarl Berry <karl@freefriends.org>2010-09-15 23:59:34 +0000
commitffc97a564cf025403b74b69c48bc158f39145c9b (patch)
tree91831ffc43db63577e6b226bdb995a17ee84f251 /Master/texmf-dist/tex/latex/expl3
parent0ee0a7585d0a3abd4d2e0b604f8b5afec32e4a9c (diff)
expl3 2020 (14sep10)
git-svn-id: svn://tug.org/texlive/trunk@19747 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/expl3')
-rw-r--r--Master/texmf-dist/tex/latex/expl3/expl3.sty6
-rw-r--r--Master/texmf-dist/tex/latex/expl3/l3basics.sty4
-rw-r--r--Master/texmf-dist/tex/latex/expl3/l3box.sty7
-rw-r--r--Master/texmf-dist/tex/latex/expl3/l3clist.sty50
-rw-r--r--Master/texmf-dist/tex/latex/expl3/l3doc.cls6
-rw-r--r--Master/texmf-dist/tex/latex/expl3/l3expan.sty2
-rw-r--r--Master/texmf-dist/tex/latex/expl3/l3fp.sty2319
-rw-r--r--Master/texmf-dist/tex/latex/expl3/l3prg.sty86
8 files changed, 1850 insertions, 630 deletions
diff --git a/Master/texmf-dist/tex/latex/expl3/expl3.sty b/Master/texmf-dist/tex/latex/expl3/expl3.sty
index 63917163f94..8ab93d24188 100644
--- a/Master/texmf-dist/tex/latex/expl3/expl3.sty
+++ b/Master/texmf-dist/tex/latex/expl3/expl3.sty
@@ -49,7 +49,7 @@
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
-\GetIdInfo$Id: expl3.dtx 1987 2010-07-25 14:55:46Z joseph $
+\GetIdInfo$Id: expl3.dtx 2020 2010-09-14 10:37:46Z joseph $
{L3 Experimental code bundle wrapper}%
\ProvidesExplPackage
{\filename}{\filedate}{\fileversion}{\filedescription}
@@ -78,7 +78,7 @@
l3prop,
l3msg,
l3io,
- l3skip,
+ l3skip
}
\RequirePackage{
l3box,
@@ -88,7 +88,7 @@
l3xref,
l3file,
l3fp,
- l3luatex,
+ l3luatex
}
\RequirePackage{calc}
\bool_if:nT { \@l@expl@check@declarations@bool } {
diff --git a/Master/texmf-dist/tex/latex/expl3/l3basics.sty b/Master/texmf-dist/tex/latex/expl3/l3basics.sty
index b0535e6833a..785b120b2dc 100644
--- a/Master/texmf-dist/tex/latex/expl3/l3basics.sty
+++ b/Master/texmf-dist/tex/latex/expl3/l3basics.sty
@@ -48,7 +48,7 @@
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
-\GetIdInfo$Id: l3basics.dtx 1942 2010-06-07 17:06:11Z will $
+\GetIdInfo$Id: l3basics.dtx 1992 2010-08-04 20:41:40Z joseph $
{L3 Experimental basic definitions}
\ProvidesExplPackage
{\filename}{\filedate}{\fileversion}{\filedescription}
@@ -488,7 +488,7 @@
\cs_tmp:w \cs_new_protected:Npn \cs_gset_protected:Npn
\cs_tmp:w \cs_new_protected:Npx \cs_gset_protected:Npx
\cs_set:Npn \cs_tmp:w #1#2{
- \cs_new_nopar:Npn #1 { \exp_args:Nc #2 }
+ \cs_new_protected_nopar:Npn #1 { \exp_args:Nc #2 }
}
\cs_tmp:w \cs_set_nopar:cpn \cs_set_nopar:Npn
\cs_tmp:w \cs_set_nopar:cpx \cs_set_nopar:Npx
diff --git a/Master/texmf-dist/tex/latex/expl3/l3box.sty b/Master/texmf-dist/tex/latex/expl3/l3box.sty
index 69baad3296b..484e7c4a635 100644
--- a/Master/texmf-dist/tex/latex/expl3/l3box.sty
+++ b/Master/texmf-dist/tex/latex/expl3/l3box.sty
@@ -48,7 +48,7 @@
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
-\GetIdInfo$Id: l3box.dtx 1919 2010-05-22 05:56:38Z will $
+\GetIdInfo$Id: l3box.dtx 2015 2010-09-03 17:45:09Z mittelba $
{L3 Experimental Box module}
\ProvidesExplPackage
{\filename}{\filedate}{\fileversion}{\filedescription}
@@ -119,10 +119,15 @@
\cs_new_eq:NN \l_tmpa_box \@tempboxa
\box_new:N \l_tmpb_box
\cs_new_protected_nopar:Npn \vbox:n {\tex_vbox:D \scan_stop:}
+\cs_new_protected_nopar:Npn \vbox_top:n {\tex_vtop:D \scan_stop:}
\cs_new_protected:Npn \vbox_set:Nn #1#2 {\tex_setbox:D #1 \tex_vbox:D {#2}}
\cs_generate_variant:Nn \vbox_set:Nn {cn}
\cs_new_protected_nopar:Npn \vbox_gset:Nn {\pref_global:D \vbox_set:Nn}
\cs_generate_variant:Nn \vbox_gset:Nn {cn}
+\cs_new_protected:Npn \vbox_set_top:Nn #1#2 {\tex_setbox:D #1 \tex_vtop:D {#2}}
+\cs_generate_variant:Nn \vbox_set_top:Nn {cn}
+\cs_new_protected_nopar:Npn \vbox_gset_top:Nn {\pref_global:D \vbox_set_top:Nn}
+\cs_generate_variant:Nn \vbox_gset_top:Nn {cn}
\cs_new_protected:Npn \vbox_set_to_ht:Nnn #1#2#3 {
\tex_setbox:D #1 \tex_vbox:D to #2 {#3}
}
diff --git a/Master/texmf-dist/tex/latex/expl3/l3clist.sty b/Master/texmf-dist/tex/latex/expl3/l3clist.sty
index 17f8ff5f80f..e99dfef6703 100644
--- a/Master/texmf-dist/tex/latex/expl3/l3clist.sty
+++ b/Master/texmf-dist/tex/latex/expl3/l3clist.sty
@@ -48,7 +48,7 @@
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
-\GetIdInfo$Id: l3clist.dtx 1878 2010-03-29 07:15:02Z joseph $
+\GetIdInfo$Id: l3clist.dtx 1992 2010-08-04 20:41:40Z joseph $
{L3 Experimental comma separated lists}
\ProvidesExplPackage
{\filename}{\filedate}{\fileversion}{\filedescription}
@@ -156,48 +156,12 @@
\clist_put_aux:NNnnNn \tl_gset:Nn \tl_gput_right:Nn , {}
}
\cs_generate_variant:Nn \clist_gput_right:Nn {NV,No,Nx,cn,cV,co}
-\cs_new_nopar:Npn \clist_map_function:NN #1#2 {
- \clist_if_empty:NF #1 {
- \exp_after:wN \clist_map_function_aux:Nw
- \exp_after:wN #2 #1 , \q_recursion_tail , \q_recursion_stop
- }
-}
-\cs_generate_variant:Nn \clist_map_function:NN {cN}
-\cs_new:Npn \clist_map_function:nN #1#2 {
- \tl_if_blank:nF {#1} {
- \clist_map_function_aux:Nw #2 #1 , \q_recursion_tail , \q_recursion_stop
- }
-}
-\cs_new:Npn \clist_map_function_aux:Nw #1#2,{
- \quark_if_recursion_tail_stop:n{#2}
- #1{#2}
- \clist_map_function_aux:Nw #1
-}
-\cs_new_eq:NN \clist_map_break: \use_none_delimit_by_q_recursion_stop:w
-\int_new:N \g_clist_inline_level_int
-\cs_new_protected:Npn \clist_map_inline:Nn #1#2 {
- \clist_if_empty:NF #1 {
- \int_gincr:N \g_clist_inline_level_int
- \cs_gset:cpn {clist_map_inline_ \int_use:N \g_clist_inline_level_int :n}
- ##1{#2}
- \exp_last_unbraced:NcV \clist_map_function_aux:Nw
- {clist_map_inline_ \int_use:N \g_clist_inline_level_int :n}
- #1 , \q_recursion_tail , \q_recursion_stop
- \int_gdecr:N \g_clist_inline_level_int
- }
-}
-\cs_generate_variant:Nn \clist_map_inline:Nn {c}
-\cs_new_protected:Npn \clist_map_inline:nn #1#2 {
- \tl_if_empty:nF {#1} {
- \int_gincr:N \g_clist_inline_level_int
- \cs_gset:cpn {clist_map_inline_ \int_use:N \g_clist_inline_level_int :n}
- ##1{#2}
- \exp_args:Nc \clist_map_function_aux:Nw
- {clist_map_inline_ \int_use:N \g_clist_inline_level_int :n}
- #1 , \q_recursion_tail , \q_recursion_stop
- \int_gdecr:N \g_clist_inline_level_int
- }
-}
+\prg_new_map_functions:Nn , { clist }
+\cs_generate_variant:Nn \clist_map_function:NN { Nc }
+\cs_generate_variant:Nn \clist_map_function:NN { c }
+\cs_generate_variant:Nn \clist_map_function:NN { cc }
+\cs_generate_variant:Nn \clist_map_inline:Nn { c }
+\cs_generate_variant:Nn \clist_map_inline:Nn { nc }
\cs_new_protected:Npn \clist_map_variable:nNn #1#2#3 {
\tl_if_empty:nF {#1} {
\clist_map_variable_aux:Nnw #2 {#3} #1
diff --git a/Master/texmf-dist/tex/latex/expl3/l3doc.cls b/Master/texmf-dist/tex/latex/expl3/l3doc.cls
index e747cf92e84..b31d5e6ceb0 100644
--- a/Master/texmf-dist/tex/latex/expl3/l3doc.cls
+++ b/Master/texmf-dist/tex/latex/expl3/l3doc.cls
@@ -53,7 +53,7 @@
\let \filedateOld \filedate
\let \fileversionOld \fileversion
\let \filedescriptionOld \filedescription
-\GetIdInfo$Id: l3doc.dtx 1987 2010-07-25 14:55:46Z joseph $
+\GetIdInfo$Id: l3doc.dtx 2004 2010-08-18 19:39:24Z joseph $
{L3 Experimental documentation class}
\ProvidesExplClass
{\filename}{\filedate}{\fileversion}{\filedescription}
@@ -91,7 +91,7 @@
\ProcessOptions
\LoadClass{article}
\RequirePackage{doc}
-\RequirePackage{array,alphalph,color,fixltx2e,enumitem,textcomp,trace,underscore}
+\RequirePackage{array,alphalph,booktabs,color,fixltx2e,enumitem,textcomp,trace,underscore}
\bool_if:NT \g_doc_lmodern_bool {
\RequirePackage[T1]{fontenc}
\RequirePackage{lmodern}
@@ -100,7 +100,7 @@
\let\doc@verbatim\verbatim
\let\enddoc@verbatim\endverbatim
\let\doc@@verbatim\@verbatim
-\usepackage{verbatim}
+\RequirePackage{verbatim}
\AtBeginDocument{%
\let\verbatim\doc@verbatim
\let\endverbatim\enddoc@verbatim
diff --git a/Master/texmf-dist/tex/latex/expl3/l3expan.sty b/Master/texmf-dist/tex/latex/expl3/l3expan.sty
index 8a356ca0295..ddfce301801 100644
--- a/Master/texmf-dist/tex/latex/expl3/l3expan.sty
+++ b/Master/texmf-dist/tex/latex/expl3/l3expan.sty
@@ -48,7 +48,7 @@
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
-\GetIdInfo$Id: l3expan.dtx 1948 2010-06-10 18:53:09Z joseph $
+\GetIdInfo$Id: l3expan.dtx 1991 2010-08-04 19:49:35Z joseph $
{L3 Experimental Argument Expansion module}
\ProvidesExplPackage
{\filename}{\filedate}{\fileversion}{\filedescription}
diff --git a/Master/texmf-dist/tex/latex/expl3/l3fp.sty b/Master/texmf-dist/tex/latex/expl3/l3fp.sty
index 93915ae18be..8b7f7b67093 100644
--- a/Master/texmf-dist/tex/latex/expl3/l3fp.sty
+++ b/Master/texmf-dist/tex/latex/expl3/l3fp.sty
@@ -48,18 +48,57 @@
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
-\GetIdInfo$Id: l3fp.dtx 1985 2010-07-18 09:05:56Z joseph $
+\GetIdInfo$Id: l3fp.dtx 2021 2010-09-14 15:59:54Z joseph $
{L3 Experimental floating-point operations}
\ProvidesExplPackage
{\filename}{\filedate}{\fileversion}{\filedescription}
\package_check_loaded_expl:
+\int_new:N \c_forty_four
+\int_set:Nn \c_forty_four { 44 }
+\int_new:N \c_one_hundred
+\int_set:Nn \c_one_hundred { 100 }
+\int_new:N \c_one_thousand
+\int_set:Nn \c_one_thousand { 1000 }
+\int_new:N \c_one_million
+\int_set:Nn \c_one_million { 1 000 000 }
+\int_new:N \c_one_hundred_million
+\int_set:Nn \c_one_hundred_million { 100 000 000 }
+\int_new:N \c_five_hundred_million
+\int_set:Nn \c_five_hundred_million { 500 000 000 }
+\int_new:N \c_one_thousand_million
+\int_set:Nn \c_one_thousand_million { 1 000 000 000 }
+\int_new:N \c_fp_pi_by_four_decimal_int
+\int_set:Nn \c_fp_pi_by_four_decimal_int { 785 398 158 }
+\int_new:N \c_fp_pi_by_four_extended_int
+\int_set:Nn \c_fp_pi_by_four_extended_int { 897 448 310 }
+\int_new:N \c_fp_pi_decimal_int
+\int_set:Nn \c_fp_pi_decimal_int { 141 592 653 }
+\int_new:N \c_fp_pi_extended_int
+\int_set:Nn \c_fp_pi_extended_int { 589 793 238 }
+\int_new:N \c_fp_two_pi_decimal_int
+\int_set:Nn \c_fp_two_pi_decimal_int { 283 185 307 }
+\int_new:N \c_fp_two_pi_extended_int
+\int_set:Nn \c_fp_two_pi_extended_int { 179 586 477 }
+\tl_new:N \c_infinity_fp
+\tl_set:Nn \c_infinity_fp { + 2147483647 . 2147483647 e 2147483647 }
+\tl_new:N \c_pi_fp
+\tl_set:Nn \c_pi_fp { + 3.141592654 e 0 }
+\tl_new:N \c_undefined_fp
+\tl_set:Nn \c_undefined_fp { X 0.000000000 e 0 }
+\tl_new:N \c_zero_fp
+\tl_set:Nn \c_zero_fp { + 0.000000000 e 0 }
+\int_new:N \l_fp_count_int
+\int_new:N \l_fp_div_offset_int
+\int_new:N \l_fp_input_a_sign_int
\int_new:N \l_fp_input_a_integer_int
\int_new:N \l_fp_input_a_decimal_int
+\int_new:N \l_fp_input_a_exponent_int
+\int_new:N \l_fp_input_b_sign_int
\int_new:N \l_fp_input_b_integer_int
\int_new:N \l_fp_input_b_decimal_int
-\int_new:N \l_fp_input_a_sign_int
-\int_new:N \l_fp_input_b_sign_int
-\int_new:N \l_fp_split_sign_int
+\int_new:N \l_fp_input_b_exponent_int
+\int_new:N \l_fp_input_a_extended_int
+\int_new:N \l_fp_input_b_extended_int
\int_new:N \l_fp_mul_a_i_int
\int_new:N \l_fp_mul_a_ii_int
\int_new:N \l_fp_mul_a_iii_int
@@ -74,69 +113,227 @@
\int_new:N \l_fp_mul_b_vi_int
\int_new:N \l_fp_mul_output_int
\tl_new:N \l_fp_mul_output_tl
-\int_new:N \l_fp_div_count_int
-\int_new:N \l_fp_div_offset_int
\int_new:N \l_fp_output_sign_int
\int_new:N \l_fp_output_integer_int
\int_new:N \l_fp_output_decimal_int
+\int_new:N \l_fp_output_exponent_int
+\int_new:N \l_fp_output_extended_int
\bool_new:N \l_fp_round_carry_bool
\tl_new:N \l_fp_round_decimal_tl
-\int_new:N \l_fp_round_discard_int
\int_new:N \l_fp_round_position_int
+\int_new:N \l_fp_round_target_int
+\int_new:N \l_fp_split_sign_int
\int_new:N \l_fp_tmp_int
\tl_new:N \l_fp_tmp_tl
-\tl_new:N \c_zero_fp
-\tl_set:Nn \c_zero_fp { + 0.000000000 }
-\tl_new:N \c_undefined_fp
-\tl_set:Nn \c_undefined_fp { X 0.000000000 }
-\tl_new:N \c_infinity_fp
-\tl_set:Nn \c_infinity_fp { +2147483647.2147483647 }
-\tl_new:N \c_minus_infinity_fp
-\tl_set:Nn \c_minus_infinity_fp { -2147483647.2147483647 }
-\int_new:N \c_one_hundred_million
-\int_set:Nn \c_one_hundred_million { 100000000 }
-\int_new:N \c_one_thousand_million
-\int_set:Nn \c_one_thousand_million { 1000000000 }
-\prg_new_conditional:Npnn \fp_if_infinite:N #1 { p , T , F , TF } {
- \tex_ifx:D #1 \c_infinity_fp
- \prg_return_true:
+\tl_new:N \l_fp_trig_arg_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
+\int_new:N \l_fp_trig_extended_int
+\cs_new_protected_nopar:Npn \fp_read:N #1 {
+ \exp_after:wN \fp_read_aux:w #1 \q_stop
+}
+\cs_new_protected_nopar:Npn \fp_read_aux:w #1#2 . #3 e #4 \q_stop {
+ \tex_if:D #1 -
+ \l_fp_input_a_sign_int \c_minus_one
\tex_else:D
- \tex_ifx:D #1 \c_minus_infinity_fp
- \prg_return_true:
- \tex_else:D
- \prg_return_false:
- \tex_fi:D
+ \l_fp_input_a_sign_int \c_one
\tex_fi:D
+ \l_fp_input_a_integer_int #2 \scan_stop:
+ \l_fp_input_a_decimal_int #3 \scan_stop:
+ \l_fp_input_a_exponent_int #4 \scan_stop:
}
-\prg_new_conditional:Npnn \fp_if_plus_infinity:N #1 { p , T , F , TF } {
- \tex_ifx:D #1 \c_infinity_fp
- \prg_return_true:
+\cs_new_protected_nopar:Npn \fp_split:Nn #1#2 {
+ \tl_set:Nx \l_fp_tmp_tl {#2}
+ \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
+}
+\cs_new_protected_nopar:Npn \fp_split_sign: {
+ \tex_ifnum:D \pdf_strcmp:D
+ { \exp_after:wN \tl_head:w \l_fp_tmp_tl ? \q_nil } { - }
+ = \c_zero
+ \tl_set:Nx \l_fp_tmp_tl
+ {
+ \exp_after:wN
+ \tl_tail:w \l_fp_tmp_tl \prg_do_nothing: \q_nil
+ }
+ \l_fp_split_sign_int -\l_fp_split_sign_int
+ \exp_after:wN \fp_split_sign:
\tex_else:D
- \prg_return_false:
+ \tex_ifnum:D \pdf_strcmp:D
+ { \exp_after:wN \tl_head:w \l_fp_tmp_tl ? \q_nil } { + }
+ = \c_zero
+ \tl_set:Nx \l_fp_tmp_tl
+ {
+ \exp_after:wN
+ \tl_tail:w \l_fp_tmp_tl \prg_do_nothing: \q_nil
+ }
+ \exp_after:wN \exp_after:wN \exp_after:wN
+ \fp_split_sign:
+ \tex_fi:D
\tex_fi:D
}
-\prg_new_conditional:Npnn \fp_if_minus_infinity:N #1 { p , T , F , TF }
- {
- \tex_ifx:D #1 \c_minus_infinity_fp
- \prg_return_true:
+\cs_new_protected_nopar:Npn
+ \fp_split_exponent:w #1 e #2 e #3 \q_stop #4 {
+ \use:c { l_fp_input_ #4 _exponent_int }
+ \etex_numexpr:D 0 #2 \scan_stop:
+ \tex_afterassignment:D \fp_split_aux_i:w
+ \use:c { l_fp_input_ #4 _integer_int }
+ \etex_numexpr:D 0 #1 . . \q_stop #4
+}
+\cs_new_protected_nopar:Npn \fp_split_aux_i:w #1 . #2 . #3 \q_stop {
+ \fp_split_aux_ii:w #2 000000000 \q_stop
+}
+\cs_new_protected_nopar:Npn \fp_split_aux_ii:w #1#2#3#4#5#6#7#8#9 {
+ \fp_split_aux_iii:w {#1#2#3#4#5#6#7#8#9}
+}
+\cs_new_protected_nopar:Npn \fp_split_aux_iii:w #1#2 \q_stop {
+ \l_fp_tmp_int 1 #1 \scan_stop:
+ \exp_after:wN \fp_split_decimal:w
+ \int_use:N \l_fp_tmp_int 000000000 \q_stop
+}
+\cs_new_protected_nopar: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}
+}
+\cs_new_protected_nopar:Npn \fp_split_decimal_aux:w #1#2#3 \q_stop #4 {
+ \use:c { l_fp_input_ #4 _decimal_int } #1#2 \scan_stop:
+ \tex_ifnum:D
+ \etex_numexpr:D
+ \use:c { l_fp_input_ #4 _integer_int } +
+ \use:c { l_fp_input_ #4 _decimal_int }
+ \scan_stop:
+ = \c_zero
+ \use:c { l_fp_input_ #4 _sign_int } \c_one
+ \tex_fi:D
+ \tex_ifnum:D
+ \use:c { l_fp_input_ #4 _integer_int } < \c_one_thousand_million
\tex_else:D
- \prg_return_false:
+ \exp_after:wN \fp_overflow_msg:
\tex_fi:D
}
-\prg_new_conditional:Npnn \fp_if_undefined:N #1 { p , T , F , TF } {
- \tex_ifx:D #1 \c_undefined_fp
- \prg_return_true:
+\cs_new_protected_nopar:Npn \fp_standardise:NNNN #1#2#3#4 {
+ \tex_ifnum:D
+ \etex_numexpr:D #2 + #3 = \c_zero
+ #1 \c_one
+ #4 \c_zero
+ \exp_after:wN \use_none:nnnn
\tex_else:D
- \prg_return_false:
+ \exp_after:wN \fp_standardise_aux:NNNN
\tex_fi:D
+ #1#2#3#4
}
-\prg_new_conditional:Npnn \fp_if_zero:N #1 { p , T , F , TF } {
- \tex_ifx:D #1 \c_zero_fp
- \prg_return_true:
+\cs_new_protected_nopar:Npn \fp_standardise_aux:NNNN #1#2#3#4 {
+ \cs_set_protected_nopar:Npn \fp_standardise_aux:
+ {
+ \tex_ifnum:D #2 = \c_zero
+ \tex_advance:D #3 \c_one_thousand_million
+ \exp_after:wN \fp_standardise_aux:w
+ \int_use:N #3 \q_stop
+ \exp_after:wN \fp_standardise_aux:
+ \tex_fi:D
+ }
+ \cs_set_protected_nopar:Npn
+ \fp_standardise_aux:w ##1##2##3##4##5##6##7##8##9 \q_stop
+ {
+ #2 ##2 \scan_stop:
+ #3 ##3##4##5##6##7##8##9 0 \scan_stop:
+ \tex_advance:D #4 \c_minus_one
+ }
+ \fp_standardise_aux:
+ \cs_set_protected_nopar:Npn \fp_standardise_aux:
+ {
+ \tex_ifnum:D #2 > \c_nine
+ \tex_advance:D #2 \c_one_thousand_million
+ \exp_after:wN \use_i:nn \exp_after:wN
+ \fp_standardise_aux:w \int_use:N #2
+ \exp_after:wN \fp_standardise_aux:
+ \tex_fi:D
+ }
+ \cs_set_protected_nopar:Npn
+ \fp_standardise_aux:w ##1##2##3##4##5##6##7##8##9
+ {
+ #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
+ {
+ ##9
+ \exp_after:wN \use_none:n \int_use:N #3
+ }
+ #3 \l_fp_tmp_tl \scan_stop:
+ \tex_advance:D #4 \c_one
+ }
+ \fp_standardise_aux:
+ \tex_ifnum:D #4 < \c_one_hundred
+ \tex_ifnum:D #4 > -\c_one_hundred
+ \tex_else:D
+ #1 \c_one
+ #2 \c_zero
+ #3 \c_zero
+ #4 \c_zero
+ \tex_fi:D
\tex_else:D
- \prg_return_false:
+ \exp_after:wN \fp_overflow_msg:
\tex_fi:D
}
+\cs_new_protected_nopar:Npn \fp_standardise_aux: { }
+\cs_new_protected_nopar:Npn \fp_standardise_aux:w { }
+\cs_new_protected_nopar:Npn \fp_level_input_exponents: {
+ \tex_ifnum:D \l_fp_input_a_exponent_int > \l_fp_input_b_exponent_int
+ \exp_after:wN \fp_level_input_exponents_a:
+ \tex_else:D
+ \exp_after:wN \fp_level_input_exponents_b:
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_level_input_exponents_a: {
+ \tex_ifnum:D \l_fp_input_a_exponent_int > \l_fp_input_b_exponent_int
+ \tex_advance:D \l_fp_input_b_integer_int \c_one_thousand_million
+ \exp_after:wN \use_i:nn \exp_after:wN
+ \fp_level_input_exponents_a:NNNNNNNNN
+ \int_use:N \l_fp_input_b_integer_int
+ \exp_after:wN \fp_level_input_exponents_a:
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn
+ \fp_level_input_exponents_a:NNNNNNNNN #1#2#3#4#5#6#7#8#9 {
+ \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
+ {
+ #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:
+ \tex_advance:D \l_fp_input_b_exponent_int \c_one
+}
+\cs_new_protected_nopar:Npn \fp_level_input_exponents_b: {
+ \tex_ifnum:D \l_fp_input_b_exponent_int > \l_fp_input_a_exponent_int
+ \tex_advance:D \l_fp_input_a_integer_int \c_one_thousand_million
+ \exp_after:wN \use_i:nn \exp_after:wN
+ \fp_level_input_exponents_b:NNNNNNNNN
+ \int_use:N \l_fp_input_a_integer_int
+ \exp_after:wN \fp_level_input_exponents_b:
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn
+ \fp_level_input_exponents_b:NNNNNNNNN #1#2#3#4#5#6#7#8#9 {
+ \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
+ {
+ #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:
+ \tex_advance:D \l_fp_input_a_exponent_int \c_one
+}
+\cs_new_protected_nopar:Npn \fp_tmp:w #1#2 { }
\cs_new_protected_nopar:Npn \fp_new:N #1 {
\tl_new:N #1
\tl_gset_eq:NN #1 \c_zero_fp
@@ -159,21 +356,31 @@
\cs_new_protected_nopar:Npn \fp_set_aux:NNn #1#2#3 {
\group_begin:
\fp_split:Nn a {#3}
+ \fp_standardise:NNNN
+ \l_fp_input_a_sign_int
+ \l_fp_input_a_integer_int
+ \l_fp_input_a_decimal_int
+ \l_fp_input_a_exponent_int
\tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
- \tl_set:Nx \l_fp_tmp_tl
+ \cs_set_protected_nopar:Npx \fp_tmp:w
{
- \tex_ifnum:D \l_fp_input_a_sign_int < \c_zero
- -
- \tex_else:D
- +
- \tex_fi:D
- \int_use:N \l_fp_input_a_integer_int
- .
- \exp_after:wN \use_none:n
- \int_use:N \l_fp_input_a_decimal_int
+ \group_end:
+ #1 \exp_not:N #2
+ {
+ \tex_ifnum:D \l_fp_input_a_sign_int < \c_zero
+ -
+ \tex_else:D
+ +
+ \tex_fi:D
+ \int_use:N \l_fp_input_a_integer_int
+ .
+ \exp_after:wN \use_none:n
+ \int_use:N \l_fp_input_a_decimal_int
+ e
+ \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 }
+ \fp_tmp:w
}
\cs_generate_variant:Nn \fp_set:Nn { c }
\cs_generate_variant:Nn \fp_gset:Nn { c }
@@ -185,27 +392,38 @@
}
\cs_new_protected_nopar:Npn \fp_set_from_dim_aux:NNn #1#2#3 {
\group_begin:
- \l_fp_tmp_dim \etex_dimexpr:D #3 \scan_stop:
+ \l_fp_tmp_skip \etex_glueexpr:D #3 \scan_stop:
+ \l_fp_tmp_dim \l_fp_tmp_skip
\fp_split:Nn a
{
\exp_after:wN \fp_set_from_dim_aux:w
\dim_use:N \l_fp_tmp_dim
}
+ \fp_standardise:NNNN
+ \l_fp_input_a_sign_int
+ \l_fp_input_a_integer_int
+ \l_fp_input_a_decimal_int
+ \l_fp_input_a_exponent_int
\tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
- \tl_set:Nx \l_fp_tmp_tl
+ \cs_set_protected_nopar:Npx \fp_tmp:w
{
- \tex_ifnum:D \l_fp_input_a_sign_int < \c_zero
- -
- \tex_else:D
- +
- \tex_fi:D
- \int_use:N \l_fp_input_a_integer_int
- .
- \exp_after:wN \use_none:n
- \int_use:N \l_fp_input_a_decimal_int
+ \group_end:
+ #1 \exp_not:N #2
+ {
+ \tex_ifnum:D \l_fp_input_a_sign_int < \c_zero
+ -
+ \tex_else:D
+ +
+ \tex_fi:D
+ \int_use:N \l_fp_input_a_integer_int
+ .
+ \exp_after:wN \use_none:n
+ \int_use:N \l_fp_input_a_decimal_int
+ e
+ \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 }
+ \fp_tmp:w
}
\cs_set_protected_nopar:Npx \fp_set_from_dim_aux:w {
\cs_set_nopar:Npn \exp_not:N \fp_set_from_dim_aux:w
@@ -215,6 +433,7 @@
\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
\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
@@ -225,101 +444,507 @@
\cs_new_eq:NN \fp_gset_eq:cc \tl_gset_eq:cc
\cs_new_eq:NN \fp_show:N \tl_show:N
\cs_new_eq:NN \fp_show:c \tl_show:c
-\cs_new_eq:NN \fp_use:N \tl_use:N
-\cs_new_eq:NN \fp_use:c \tl_use:c
-\cs_new_protected_nopar:Npn \fp_read:N #1 {
- \exp_after:wN \fp_read_aux:w #1 \q_stop
+\cs_new_nopar:Npn \fp_use:N #1 {
+ \exp_after:wN \fp_use_aux:w #1 \q_stop
}
-\cs_new_protected_nopar:Npn \fp_read_aux:w #1#2 . #3 \q_stop {
+\cs_generate_variant:Nn \fp_use:N { c }
+\cs_new_nopar:Npn \fp_use_aux:w #1#2 e #3 \q_stop {
\tex_if:D #1 -
- \l_fp_input_a_sign_int \c_minus_one
+ -
+ \tex_fi:D
+ \tex_ifnum:D #3 > \c_zero
+ \exp_after:wN \fp_use_large:w
\tex_else:D
- \l_fp_input_a_sign_int \c_one
+ \tex_ifnum:D #3 < \c_zero
+ \exp_after:wN \exp_after:wN \exp_after:wN
+ \fp_use_small:w
+ \tex_else:D
+ \exp_after:wN \exp_after:wN \exp_after:wN
+ \fp_use_none:w
+ \tex_fi:D
\tex_fi:D
- \l_fp_input_a_integer_int #2 \scan_stop:
- \l_fp_input_a_decimal_int #3 \scan_stop:
+ #2 e #3 \q_stop
}
-\cs_new_protected_nopar:Npn \fp_split:Nn #1#2 {
- \tl_set:Nx \l_fp_tmp_tl {#2}
- \l_fp_split_sign_int \c_one
- \fp_split_sign:
- \use:c { l_fp_input_ #1 _sign_int } \l_fp_split_sign_int
- \tex_afterassignment:D \fp_split_aux_i:w
- \use:c { l_fp_input_ #1 _integer_int }
- \etex_numexpr:D 0 \l_fp_tmp_tl . . \q_stop #1
+\cs_new_nopar:Npn \fp_use_none:w #1 e #2 \q_stop {#1}
+\cs_new_nopar:Npn \fp_use_small:w #1 . #2 e #3 \q_stop {
+ 0 .
+ \prg_replicate:nn { -#3 - 1 } { 0 }
+ #1#2
}
-\cs_new_protected_nopar:Npn \fp_split_sign: {
- \tex_ifnum:D \pdf_strcmp:D
- { \exp_after:wN \tl_head:w \l_fp_tmp_tl ? \q_nil } { - }
- = \c_zero
- \tl_set:Nx \l_fp_tmp_tl
- {
- \exp_after:wN
- \tl_tail:w \l_fp_tmp_tl \prg_do_nothing: \q_nil
- }
- \l_fp_split_sign_int -\l_fp_split_sign_int
- \exp_after:wN \fp_split_sign:
+\cs_new_nopar:Npn \fp_use_large:w #1 . #2 e #3 \q_stop {
+ \tex_ifnum:D #3 < \c_ten
+ \exp_after:wN \fp_use_large_aux_i:w
\tex_else:D
- \tex_ifnum:D \pdf_strcmp:D
- { \exp_after:wN \tl_head:w \l_fp_tmp_tl ? \q_nil } { + }
- = \c_zero
- \tl_set:Nx \l_fp_tmp_tl
- {
- \exp_after:wN
- \tl_tail:w \l_fp_tmp_tl \prg_do_nothing: \q_nil
- }
+ \exp_after:wN \fp_use_large_aux_ii:w
+ \tex_fi:D
+ #1#2 e #3 \q_stop
+}
+\cs_new_nopar:Npn \fp_use_large_aux_i:w #1#2 e #3 \q_stop {
+ #1
+ \use:c { fp_use_large_aux_ #3 :w } #2 \q_stop
+}
+\cs_new_nopar:cpn { fp_use_large_aux_1:w } #1#2 \q_stop { #1 . #2 }
+\cs_new_nopar:cpn { fp_use_large_aux_2:w } #1#2#3 \q_stop {
+ #1#2 . #3
+}
+\cs_new_nopar:cpn { fp_use_large_aux_3:w } #1#2#3#4 \q_stop {
+ #1#2#3 . #4
+}
+\cs_new_nopar:cpn { fp_use_large_aux_4:w } #1#2#3#4#5 \q_stop {
+ #1#2#3#4 . #5
+}
+\cs_new_nopar:cpn { fp_use_large_aux_5:w } #1#2#3#4#5#6 \q_stop {
+ #1#2#3#4#5 . #6
+}
+\cs_new_nopar:cpn { fp_use_large_aux_6:w } #1#2#3#4#5#6#7 \q_stop {
+ #1#2#3#4#5#6 . #7
+}
+\cs_new_nopar:cpn { fp_use_large_aux_7:w } #1#2#3#4#5#6#7#8 \q_stop {
+ #1#2#3#4#6#7 . #8
+}
+\cs_new_nopar:cpn { fp_use_large_aux_8:w } #1#2#3#4#5#6#7#8#9 \q_stop {
+ #1#2#3#4#5#6#7#8 . #9
+}
+\cs_new_nopar:cpn { fp_use_large_aux_9:w } #1 \q_stop { #1 . }
+\cs_new_nopar:Npn \fp_use_large_aux_ii:w #1 e #2 \q_stop {
+ #1
+ \prg_replicate:nn { #2 - 9 } { 0 }
+ .
+}
+\cs_new_nopar:Npn \fp_to_int:N #1 {
+ \exp_after:wN \fp_to_int_aux:w #1 \q_stop
+}
+\cs_generate_variant:Nn \fp_to_int:N { c }
+\cs_new_nopar:Npn \fp_to_int_aux:w #1#2 e #3 \q_stop {
+ \tex_if:D #1 -
+ -
+ \tex_fi:D
+ \tex_ifnum:D #3 < \c_zero
+ \exp_after:wN \fp_to_int_small:w
+ \tex_else:D
+ \exp_after:wN \fp_to_int_large:w
+ \tex_fi:D
+ #2 e #3 \q_stop
+}
+\cs_new_nopar:Npn \fp_to_int_small:w #1 . #2 e #3 \q_stop {
+ \tex_ifnum:D #3 > \c_one
+ \tex_else:D
+ \tex_ifnum:D #1 < \c_five
+ 0
+ \tex_else:D
+ 1
+ \tex_fi:D
+ \tex_fi:D
+}
+\cs_new_nopar:Npn \fp_to_int_large:w #1 . #2 e #3 \q_stop {
+ \tex_ifnum:D #3 < \c_ten
+ \exp_after:wN \fp_to_int_large_aux_i:w
+ \tex_else:D
+ \exp_after:wN \fp_to_int_large_aux_ii:w
+ \tex_fi:D
+ #1#2 e #3 \q_stop
+}
+\cs_new_nopar:Npn \fp_to_int_large_aux_i:w #1#2 e #3 \q_stop {
+ \use:c { fp_to_int_large_aux_ #3 :w } #2 \q_stop {#1}
+}
+\cs_new_nopar:cpn { fp_to_int_large_aux_1:w } #1#2 \q_stop {
+ \fp_to_int_large_aux:nnn { #2 0 } {#1}
+}
+\cs_new_nopar:cpn { fp_to_int_large_aux_2:w } #1#2#3 \q_stop {
+ \fp_to_int_large_aux:nnn { #3 00 } {#1#2}
+}
+\cs_new_nopar:cpn { fp_to_int_large_aux_3:w } #1#2#3#4 \q_stop {
+ \fp_to_int_large_aux:nnn { #4 000 } {#1#2#3}
+}
+\cs_new_nopar:cpn { fp_to_int_large_aux_4:w } #1#2#3#4#5 \q_stop {
+ \fp_to_int_large_aux:nnn { #5 0000 } {#1#2#3#4}
+}
+\cs_new_nopar:cpn { fp_to_int_large_aux_5:w } #1#2#3#4#5#6 \q_stop {
+ \fp_to_int_large_aux:nnn { #6 00000 } {#1#2#3#4#5}
+}
+\cs_new_nopar:cpn { fp_to_int_large_aux_6:w } #1#2#3#4#5#6#7 \q_stop {
+ \fp_to_int_large_aux:nnn { #7 000000 } {#1#2#3#4#5#6}
+}
+\cs_new_nopar:cpn
+ { fp_to_int_large_aux_7:w } #1#2#3#4#5#6#7#8 \q_stop {
+ \fp_to_int_large_aux:nnn { #8 0000000 } {#1#2#3#4#5#6#7}
+}
+\cs_new_nopar:cpn
+ { fp_to_int_large_aux_8:w } #1#2#3#4#5#6#7#8#9 \q_stop {
+ \fp_to_int_large_aux:nnn { #9 00000000 } {#1#2#3#4#5#6#7#8}
+}
+\cs_new_nopar:cpn { fp_to_int_large_aux_9:w } #1 \q_stop {#1}
+\cs_new_nopar:Npn \fp_to_int_large_aux:nnn #1#2#3 {
+ \tex_ifnum:D #1 < \c_five_hundred_million
+ #3#2
+ \tex_else:D
+ \tex_number:D \etex_numexpr:D #3#2 + 1 \scan_stop:
+ \tex_fi:D
+}
+\cs_new_nopar:Npn \fp_to_int_large_aux_ii:w #1 e #2 \q_stop {
+ #1
+ \prg_replicate:nn { #2 - 9 } { 0 }
+}
+\cs_new_nopar:Npn \fp_to_tl:N #1 {
+ \exp_after:wN \fp_to_tl_aux:w #1 \q_stop
+}
+\cs_generate_variant:Nn \fp_to_tl:N { c }
+\cs_new_nopar:Npn \fp_to_tl_aux:w #1#2 e #3 \q_stop {
+ \tex_if:D #1 -
+ -
+ \tex_fi:D
+ \tex_ifnum:D #3 < \c_zero
+ \exp_after:wN \fp_to_tl_small:w
+ \tex_else:D
+ \exp_after:wN \fp_to_tl_large:w
+ \tex_fi:D
+ #2 e #3 \q_stop
+}
+\cs_new_nopar:Npn \fp_to_tl_large:w #1 e #2 \q_stop {
+ \tex_ifnum:D #2 < \c_ten
+ \exp_after:wN \fp_to_tl_large_aux_i:w
+ \tex_else:D
+ \exp_after:wN \fp_to_tl_large_aux_ii:w
+ \tex_fi:D
+ #1 e #2 \q_stop
+}
+\cs_new_nopar:Npn \fp_to_tl_large_aux_i:w #1 e #2 \q_stop {
+ \use:c { fp_to_tl_large_ #2 :w } #1 \q_stop
+}
+\cs_new_nopar:Npn \fp_to_tl_large_aux_ii:w #1 . #2 e #3 \q_stop {
+ #1
+ \fp_to_tl_large_zeros:NNNNNNNNN #2
+ e #3
+}
+\cs_new_nopar:cpn { fp_to_tl_large_0:w } #1 . #2 \q_stop {
+ #1
+ \fp_to_tl_large_zeros:NNNNNNNNN #2
+}
+\cs_new_nopar:cpn { fp_to_tl_large_1:w } #1 . #2#3 \q_stop {
+ #1#2
+ \fp_to_tl_large_zeros:NNNNNNNNN #3 0
+}
+\cs_new_nopar:cpn { fp_to_tl_large_2:w } #1 . #2#3#4 \q_stop {
+ #1#2#3
+ \fp_to_tl_large_zeros:NNNNNNNNN #4 00
+}
+\cs_new_nopar:cpn { fp_to_tl_large_3:w } #1 . #2#3#4#5 \q_stop {
+ #1#2#3#4
+ \fp_to_tl_large_zeros:NNNNNNNNN #5 000
+}
+\cs_new_nopar:cpn { fp_to_tl_large_4:w } #1 . #2#3#4#5#6 \q_stop {
+ #1#2#3#4#5
+ \fp_to_tl_large_zeros:NNNNNNNNN #6 0000
+}
+\cs_new_nopar:cpn { fp_to_tl_large_5:w } #1 . #2#3#4#5#6#7 \q_stop {
+ #1#2#3#4#5#6
+ \fp_to_tl_large_zeros:NNNNNNNNN #7 00000
+}
+\cs_new_nopar:cpn { fp_to_tl_large_6:w } #1 . #2#3#4#5#6#7#8 \q_stop {
+ #1#2#3#4#5#6#7
+ \fp_to_tl_large_zeros:NNNNNNNNN #8 000000
+}
+\cs_new_nopar:cpn { fp_to_tl_large_7:w } #1 . #2#3#4#5#6#7#8#9 \q_stop {
+ #1#2#3#4#5#6#7#8
+ \fp_to_tl_large_zeros:NNNNNNNNN #9 0000000
+}
+\cs_new_nopar:cpn { fp_to_tl_large_8:w } #1 . {
+ #1
+ \use:c { fp_to_tl_large_8_aux:w }
+}
+\cs_new_nopar:cpn
+ { fp_to_tl_large_8_aux:w } #1#2#3#4#5#6#7#8#9 \q_stop {
+ #1#2#3#4#5#6#7#8
+ \fp_to_tl_large_zeros:NNNNNNNNN #9 00000000
+}
+\cs_new_nopar:cpn { fp_to_tl_large_9:w } #1 . #2 \q_stop {#1#2}
+\cs_new_nopar:Npn \fp_to_tl_small:w #1 e #2 \q_stop {
+ \tex_ifnum:D #2 = \c_minus_one
+ \exp_after:wN \fp_to_tl_small_one:w
+ \tex_else:D
+ \tex_ifnum:D #2 = -\c_two
\exp_after:wN \exp_after:wN \exp_after:wN
- \fp_split_sign:
- \tex_fi:D
+ \fp_to_tl_small_two:w
+ \tex_else:D
+ \exp_after:wN \exp_after:wN \exp_after:wN
+ \fp_to_tl_small_aux:w
+ \tex_fi:D
\tex_fi:D
+ #1 e #2 \q_stop
}
-\cs_new_protected_nopar:Npn \fp_split_aux_i:w #1 . #2 . #3 \q_stop {
- \fp_split_aux_ii:w #2 000000000 \q_stop
+\cs_new_nopar:Npn \fp_to_tl_small_one:w #1 . #2 e #3 \q_stop {
+ \tex_ifnum:D \fp_use_ix:NNNNNNNNN #2 > \c_four
+ \tex_ifnum:D
+ \etex_numexpr:D #1 \fp_use_i_to_iix:NNNNNNNNN #2 + 1
+ < \c_one_thousand_million
+ 0.
+ \exp_after:wN \fp_to_tl_small_zeros:NNNNNNNNN
+ \tex_number:D
+ \etex_numexpr:D
+ #1 \fp_use_i_to_iix:NNNNNNNNN #2 + 1
+ \scan_stop:
+ \tex_else:D
+ 1
+ \tex_fi:D
+ \tex_else:D
+ 0. #1
+ \fp_to_tl_small_zeros:NNNNNNNNN #2
+ \tex_fi:D
}
-\cs_new_protected_nopar:Npn \fp_split_aux_ii:w #1#2#3#4#5#6#7#8#9 {
- \fp_split_aux_iii:w {#1#2#3#4#5#6#7#8#9}
+\cs_new_nopar:Npn \fp_to_tl_small_two:w #1 . #2 e #3 \q_stop {
+ \tex_ifnum:D \fp_use_iix_ix:NNNNNNNNN #2 > \c_forty_four
+ \tex_ifnum:D
+ \etex_numexpr:D #1 \fp_use_i_to_vii:NNNNNNNNN #2 0 + \c_ten
+ < \c_one_thousand_million
+ 0.0
+ \exp_after:wN \fp_to_tl_small_zeros:NNNNNNNNN
+ \tex_number:D
+ \etex_numexpr:D
+ #1 \fp_use_i_to_vii:NNNNNNNNN #2 0 + \c_ten
+ \scan_stop:
+ \tex_else:D
+ 0.1
+ \tex_fi:D
+ \tex_else:D
+ 0.0
+ #1
+ \fp_to_tl_small_zeros:NNNNNNNNN #2
+ \tex_fi:D
}
-\cs_new_protected_nopar:Npn \fp_split_aux_iii:w #1#2 \q_stop {
- \l_fp_tmp_int 1 #1 \scan_stop:
- \exp_after:wN \fp_split_decimal:w
- \int_use:N \l_fp_tmp_int 000000000 \q_stop
+\cs_new_nopar:Npn \fp_to_tl_small_aux:w #1 . #2 e #3 \q_stop {
+ #1
+ \fp_to_tl_large_zeros:NNNNNNNNN #2
+ e #3
+}
+\cs_new_nopar:Npn \fp_to_tl_large_zeros:NNNNNNNNN #1#2#3#4#5#6#7#8#9 {
+ \tex_ifnum:D #9 = \c_zero
+ \tex_ifnum:D #8 = \c_zero
+ \tex_ifnum:D #7 = \c_zero
+ \tex_ifnum:D #6 = \c_zero
+ \tex_ifnum:D #5 = \c_zero
+ \tex_ifnum:D #4 = \c_zero
+ \tex_ifnum:D #3 = \c_zero
+ \tex_ifnum:D #2 = \c_zero
+ \tex_ifnum:D #1 = \c_zero
+ \tex_else:D
+ . #1
+ \tex_fi:D
+ \tex_else:D
+ . #1#2
+ \tex_fi:D
+ \tex_else:D
+ . #1#2#3
+ \tex_fi:D
+ \tex_else:D
+ . #1#2#3#4
+ \tex_fi:D
+ \tex_else:D
+ . #1#2#3#4#5
+ \tex_fi:D
+ \tex_else:D
+ . #1#2#3#4#5#6
+ \tex_fi:D
+ \tex_else:D
+ . #1#2#3#4#5#6#7
+ \tex_fi:D
+ \tex_else:D
+ . #1#2#3#4#5#6#7#8
+ \tex_fi:D
+ \tex_else:D
+ . #1#2#3#4#5#6#7#8#9
+ \tex_fi:D
}
-\cs_new_protected_nopar: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}
+\cs_new_nopar:Npn \fp_to_tl_small_zeros:NNNNNNNNN #1#2#3#4#5#6#7#8#9 {
+ \tex_ifnum:D #9 = \c_zero
+ \tex_ifnum:D #8 = \c_zero
+ \tex_ifnum:D #7 = \c_zero
+ \tex_ifnum:D #6 = \c_zero
+ \tex_ifnum:D #5 = \c_zero
+ \tex_ifnum:D #4 = \c_zero
+ \tex_ifnum:D #3 = \c_zero
+ \tex_ifnum:D #2 = \c_zero
+ \tex_ifnum:D #1 = \c_zero
+ \tex_else:D
+ #1
+ \tex_fi:D
+ \tex_else:D
+ #1#2
+ \tex_fi:D
+ \tex_else:D
+ #1#2#3
+ \tex_fi:D
+ \tex_else:D
+ #1#2#3#4
+ \tex_fi:D
+ \tex_else:D
+ #1#2#3#4#5
+ \tex_fi:D
+ \tex_else:D
+ #1#2#3#4#5#6
+ \tex_fi:D
+ \tex_else:D
+ #1#2#3#4#5#6#7
+ \tex_fi:D
+ \tex_else:D
+ #1#2#3#4#5#6#7#8
+ \tex_fi:D
+ \tex_else:D
+ #1#2#3#4#5#6#7#8#9
+ \tex_fi:D
}
-\cs_new_protected_nopar:Npn \fp_split_decimal_aux:w #1#2#3 \q_stop #4 {
- \use:c { l_fp_input_ #4 _decimal_int } #1#2 \scan_stop:
- \tex_ifnum:D
- \etex_numexpr:D
- \use:c { l_fp_input_ #4 _integer_int } +
- \use:c { l_fp_input_ #4 _decimal_int }
- \scan_stop:
- = \c_zero
- \use:c { l_fp_input_ #4 _sign_int } \c_one
- \tex_fi:D
+\cs_new_nopar:Npn \fp_use_iix_ix:NNNNNNNNN #1#2#3#4#5#6#7#8#9 {#8#9}
+\cs_new_nopar:Npn \fp_use_ix:NNNNNNNNN #1#2#3#4#5#6#7#8#9 {#9}
+\cs_new_nopar:Npn \fp_use_i_to_vii:NNNNNNNNN #1#2#3#4#5#6#7#8#9 {
+ #1#2#3#4#5#6#7
+}
+\cs_new_nopar:Npn \fp_use_i_to_iix:NNNNNNNNN #1#2#3#4#5#6#7#8#9 {
+ #1#2#3#4#5#6#7#8
+}
+\cs_new_protected_nopar:Npn \fp_round_figures:Nn {
+ \fp_round_figures_aux:NNn \tl_set:Nn
+}
+\cs_generate_variant:Nn \fp_round_figures:Nn { c }
+\cs_new_protected_nopar:Npn \fp_ground_figures:Nn {
+ \fp_round_figures_aux:NNn \tl_gset:Nn
+}
+\cs_generate_variant:Nn \fp_ground_figures:Nn { c }
+\cs_new_protected_nopar:Npn \fp_round_figures_aux:NNn #1#2#3 {
+ \group_begin:
+ \fp_read:N #2
+ \int_set:Nn \l_fp_round_target_int { #3 - 1 }
+ \tex_ifnum:D \l_fp_round_target_int < \c_ten
+ \exp_after:wN \fp_round:
+ \tex_fi:D
+ \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
+ \cs_set_protected_nopar:Npx \fp_tmp:w
+ {
+ \group_end:
+ #1 \exp_not:N #2
+ {
+ \tex_ifnum:D \l_fp_input_a_sign_int < \c_zero
+ -
+ \tex_else:D
+ +
+ \tex_fi:D
+ \int_use:N \l_fp_input_a_integer_int
+ .
+ \exp_after:wN \use_none:n
+ \int_use:N \l_fp_input_a_decimal_int
+ e
+ \int_use:N \l_fp_input_a_exponent_int
+ }
+ }
+ \fp_tmp:w
+}
+\cs_new_protected_nopar:Npn \fp_round_places:Nn {
+ \fp_round_places_aux:NNn \tl_set:Nn
+}
+\cs_generate_variant:Nn \fp_round_places:Nn { c }
+\cs_new_protected_nopar:Npn \fp_ground_places:Nn {
+ \fp_round_places_aux:NNn \tl_gset:Nn
+}
+\cs_generate_variant:Nn \fp_ground_places:Nn { c }
+\cs_new_protected_nopar:Npn \fp_round_places_aux:NNn #1#2#3 {
+ \group_begin:
+ \fp_read:N #2
+ \int_set:Nn \l_fp_round_target_int
+ { #3 + \l_fp_input_a_exponent_int }
+ \tex_ifnum:D \l_fp_round_target_int < \c_ten
+ \exp_after:wN \fp_round:
+ \tex_fi:D
+ \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
+ \cs_set_protected_nopar:Npx \fp_tmp:w
+ {
+ \group_end:
+ #1 \exp_not:N #2
+ {
+ \tex_ifnum:D \l_fp_input_a_sign_int < \c_zero
+ -
+ \tex_else:D
+ +
+ \tex_fi:D
+ \int_use:N \l_fp_input_a_integer_int
+ .
+ \exp_after:wN \use_none:n
+ \int_use:N \l_fp_input_a_decimal_int
+ e
+ \int_use:N \l_fp_input_a_exponent_int
+ }
+ }
+ \fp_tmp:w
+}
+\cs_new_protected_nopar:Npn \fp_round: {
+ \bool_set_false:N \l_fp_round_carry_bool
+ \l_fp_round_position_int \c_eight
+ \tl_clear:N \l_fp_round_decimal_tl
+ \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
+ \exp_after:wN \use_i:nn \exp_after:wN
+ \fp_round_aux:NNNNNNNNN \int_use:N \l_fp_input_a_decimal_int
+}
+\cs_new_protected_nopar:Npn \fp_round_aux:NNNNNNNNN #1#2#3#4#5#6#7#8#9 {
+ \fp_round_loop:N #9#8#7#6#5#4#3#2#1
+ \bool_if:NT \l_fp_round_carry_bool
+ { \tex_advance:D \l_fp_input_a_integer_int \c_one }
+ \l_fp_input_a_decimal_int \l_fp_round_decimal_tl \scan_stop:
+ \tex_ifnum:D \l_fp_input_a_integer_int < \c_ten
+ \tex_else:D
+ \l_fp_input_a_integer_int \c_one
+ \tex_divide:D \l_fp_input_a_decimal_int \c_ten
+ \tex_advance:D \l_fp_input_a_exponent_int \c_one
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_round_loop:N #1 {
+ \tex_ifnum:D \l_fp_round_position_int < \l_fp_round_target_int
+ \bool_if:NTF \l_fp_round_carry_bool
+ { \l_fp_tmp_int \etex_numexpr:D #1 + \c_one \scan_stop: }
+ { \l_fp_tmp_int \etex_numexpr:D #1 \scan_stop: }
+ \tex_ifnum:D \l_fp_tmp_int = \c_ten
+ \l_fp_tmp_int \c_zero
+ \tex_else:D
+ \bool_set_false:N \l_fp_round_carry_bool
+ \tex_fi:D
+ \tl_set:Nx \l_fp_round_decimal_tl
+ { \int_use:N \l_fp_tmp_int \l_fp_round_decimal_tl }
+ \tex_else:D
+ \tl_set:Nx \l_fp_round_decimal_tl { 0 \l_fp_round_decimal_tl }
+ \tex_ifnum:D \l_fp_round_position_int = \l_fp_round_target_int
+ \tex_ifnum:D #1 > \c_four
+ \bool_set_true:N \l_fp_round_carry_bool
+ \tex_fi:D
+ \tex_fi:D
+ \tex_fi:D
+ \tex_advance:D \l_fp_round_position_int \c_minus_one
+ \tex_ifnum:D \l_fp_round_position_int > \c_minus_one
+ \exp_after:wN \fp_round_loop:N
+ \tex_fi:D
}
\cs_new_protected_nopar:Npn \fp_abs:N {
- \fp_abs:NN \tl_set:Nn
+ \fp_abs_aux:NN \tl_set:Nn
}
\cs_new_protected_nopar:Npn \fp_gabs:N {
- \fp_abs:NN \tl_gset:Nn
+ \fp_abs_aux:NN \tl_gset:Nn
}
\cs_generate_variant:Nn \fp_abs:N { c }
\cs_generate_variant:Nn \fp_gabs:N { c }
-\cs_new_protected_nopar:Npn \fp_abs:NN #1#2 {
+\cs_new_protected_nopar:Npn \fp_abs_aux:NN #1#2 {
\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
+ \cs_set_protected_nopar:Npx \fp_tmp:w
{
- +
- \int_use:N \l_fp_input_a_integer_int
- .
- \exp_after:wN \use_none:n
- \int_use:N \l_fp_input_a_decimal_int
+ \group_end:
+ #1 \exp_not:N #2
+ {
+ +
+ \int_use:N \l_fp_input_a_integer_int
+ .
+ \exp_after:wN \use_none:n
+ \int_use:N \l_fp_input_a_decimal_int
+ e
+ \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 }
+ \fp_tmp:w
}
\cs_new_protected_nopar:Npn \fp_neg:N {
\fp_neg_aux:NN \tl_set:Nn
@@ -344,6 +969,8 @@
.
\exp_after:wN \use_none:n
\int_use:N \l_fp_input_a_decimal_int
+ e
+ \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 }
@@ -360,11 +987,16 @@
\group_begin:
\fp_read:N #2
\fp_split:Nn b {#3}
+ \fp_standardise:NNNN
+ \l_fp_input_b_sign_int
+ \l_fp_input_b_integer_int
+ \l_fp_input_b_decimal_int
+ \l_fp_input_b_exponent_int
\fp_add_core:
- \exp_after:wN \group_end: \exp_after:wN
- #1 \exp_after:wN #2 \exp_after:wN { \l_fp_tmp_tl }
+ \fp_tmp:w #1#2
}
\cs_new_protected_nopar:Npn \fp_add_core: {
+ \fp_level_input_exponents:
\tex_ifnum:D
\etex_numexpr:D
\l_fp_input_a_sign_int * \l_fp_input_b_sign_int
@@ -374,17 +1006,30 @@
\tex_else:D
\exp_after:wN \fp_add_difference:
\tex_fi:D
- \tl_set:Nx \l_fp_tmp_tl
+ \l_fp_output_exponent_int \l_fp_input_a_exponent_int
+ \fp_standardise:NNNN
+ \l_fp_output_sign_int
+ \l_fp_output_integer_int
+ \l_fp_output_decimal_int
+ \l_fp_output_exponent_int
+ \cs_set_protected_nopar:Npx \fp_tmp:w ##1##2
{
- \tex_ifnum:D \l_fp_output_sign_int < \c_zero
- -
- \tex_else:D
- +
- \tex_fi:D
- \int_use:N \l_fp_output_integer_int
- .
- \exp_after:wN \use_none:n
- \int_use:N \l_fp_output_decimal_int
+ \group_end:
+ ##1 ##2
+ {
+ \tex_ifnum:D \l_fp_output_sign_int < \c_zero
+ -
+ \tex_else:D
+ +
+ \tex_fi:D
+ \int_use:N \l_fp_output_integer_int
+ .
+ \exp_after:wN \use_none:n
+ \tex_number:D \etex_numexpr:D
+ \l_fp_output_decimal_int + \c_one_thousand_million
+ e
+ \int_use:N \l_fp_output_exponent_int
+ }
}
}
\cs_new_protected_nopar:Npn \fp_add_sum: {
@@ -398,9 +1043,9 @@
\l_fp_input_a_decimal_int + \l_fp_input_b_decimal_int
\scan_stop:
\tex_ifnum:D \l_fp_output_decimal_int < \c_one_thousand_million
- \tex_advance:D \l_fp_output_decimal_int \c_one_thousand_million
\tex_else:D
\tex_advance:D \l_fp_output_integer_int \c_one
+ \tex_advance:D \l_fp_output_decimal_int -\c_one_thousand_million
\tex_fi:D
}
\cs_new_protected_nopar:Npn \fp_add_difference: {
@@ -433,14 +1078,6 @@
\tex_else:D
\l_fp_output_sign_int \l_fp_input_a_sign_int
\tex_fi:D
- \tex_ifnum:D
- \etex_numexpr:D
- \l_fp_output_integer_int + \l_fp_output_decimal_int
- \scan_stop:
- = \c_zero
- \l_fp_output_sign_int \c_one
- \tex_fi:D
- \tex_advance:D \l_fp_output_decimal_int \c_one_thousand_million
}
\cs_new_protected_nopar:Npn \fp_sub:Nn {
\fp_sub_aux:NNn \tl_set:Nn
@@ -454,10 +1091,14 @@
\group_begin:
\fp_read:N #2
\fp_split:Nn b {#3}
+ \fp_standardise:NNNN
+ \l_fp_input_b_sign_int
+ \l_fp_input_b_integer_int
+ \l_fp_input_b_decimal_int
+ \l_fp_input_b_exponent_int
\tex_multiply:D \l_fp_input_b_sign_int \c_minus_one
\fp_add_core:
- \exp_after:wN \group_end: \exp_after:wN
- #1 \exp_after:wN #2 \exp_after:wN { \l_fp_tmp_tl }
+ \fp_tmp:w #1#2
}
\cs_new_protected_nopar:Npn \fp_mul:Nn {
\fp_mul_aux:NNn \tl_set:Nn
@@ -471,93 +1112,80 @@
\group_begin:
\fp_read:N #2
\fp_split:Nn b {#3}
- \fp_mul_split:NNNN \l_fp_input_a_integer_int
- \l_fp_mul_a_i_int \l_fp_mul_a_ii_int \l_fp_mul_a_iii_int
- \fp_mul_split:NNNN \l_fp_input_a_decimal_int
- \l_fp_mul_a_iv_int \l_fp_mul_a_v_int \l_fp_mul_a_vi_int
- \fp_mul_split:NNNN \l_fp_input_b_integer_int
- \l_fp_mul_b_i_int \l_fp_mul_b_ii_int \l_fp_mul_b_iii_int
- \fp_mul_split:NNNN \l_fp_input_b_decimal_int
- \l_fp_mul_b_iv_int \l_fp_mul_b_v_int \l_fp_mul_b_vi_int
- \l_fp_mul_output_int \c_zero
- \tl_clear:N \l_fp_mul_output_tl
- \fp_mul_product:NN \l_fp_mul_a_iv_int \l_fp_mul_b_vi_int
- \fp_mul_product:NN \l_fp_mul_a_v_int \l_fp_mul_b_v_int
- \fp_mul_product:NN \l_fp_mul_a_vi_int \l_fp_mul_b_iv_int
- \tex_divide:D \l_fp_mul_output_int \c_thousand
- \fp_mul_product:NN \l_fp_mul_a_iii_int \l_fp_mul_b_vi_int
- \fp_mul_product:NN \l_fp_mul_a_iv_int \l_fp_mul_b_v_int
- \fp_mul_product:NN \l_fp_mul_a_v_int \l_fp_mul_b_iv_int
- \fp_mul_product:NN \l_fp_mul_a_vi_int \l_fp_mul_b_iii_int
- \fp_mul_end_level:
- \fp_mul_product:NN \l_fp_mul_a_ii_int \l_fp_mul_b_vi_int
- \fp_mul_product:NN \l_fp_mul_a_iii_int \l_fp_mul_b_v_int
- \fp_mul_product:NN \l_fp_mul_a_iv_int \l_fp_mul_b_iv_int
- \fp_mul_product:NN \l_fp_mul_a_v_int \l_fp_mul_b_iii_int
- \fp_mul_product:NN \l_fp_mul_a_vi_int \l_fp_mul_b_ii_int
- \fp_mul_end_level:
- \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_mul_b_vi_int
- \fp_mul_product:NN \l_fp_mul_a_ii_int \l_fp_mul_b_v_int
- \fp_mul_product:NN \l_fp_mul_a_iii_int \l_fp_mul_b_iv_int
- \fp_mul_product:NN \l_fp_mul_a_iv_int \l_fp_mul_b_iii_int
- \fp_mul_product:NN \l_fp_mul_a_v_int \l_fp_mul_b_ii_int
- \fp_mul_product:NN \l_fp_mul_a_vi_int \l_fp_mul_b_i_int
- \fp_mul_end_level:
- \l_fp_output_decimal_int 0 \l_fp_mul_output_tl \scan_stop:
- \tl_clear:N \l_fp_mul_output_tl
- \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_mul_b_v_int
- \fp_mul_product:NN \l_fp_mul_a_ii_int \l_fp_mul_b_iv_int
- \fp_mul_product:NN \l_fp_mul_a_iii_int \l_fp_mul_b_iii_int
- \fp_mul_product:NN \l_fp_mul_a_iv_int \l_fp_mul_b_ii_int
- \fp_mul_product:NN \l_fp_mul_a_v_int \l_fp_mul_b_i_int
- \fp_mul_end_level:
- \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_mul_b_iv_int
- \fp_mul_product:NN \l_fp_mul_a_ii_int \l_fp_mul_b_iii_int
- \fp_mul_product:NN \l_fp_mul_a_iii_int \l_fp_mul_b_ii_int
- \fp_mul_product:NN \l_fp_mul_a_iv_int \l_fp_mul_b_i_int
- \fp_mul_end_level:
- \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_mul_b_iii_int
- \fp_mul_product:NN \l_fp_mul_a_ii_int \l_fp_mul_b_ii_int
- \fp_mul_product:NN \l_fp_mul_a_iii_int \l_fp_mul_b_i_int
- \fp_mul_end_level:
- \l_fp_output_integer_int 0 \l_fp_mul_output_tl \scan_stop:
- \tl_clear:N \l_fp_mul_output_tl
- \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_mul_b_ii_int
- \fp_mul_product:NN \l_fp_mul_a_ii_int \l_fp_mul_b_i_int
- \fp_mul_end_level:
- \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_mul_b_i_int
- \fp_mul_end_level:
- \tex_ifnum:D \l_fp_mul_output_tl = \c_zero
- \tex_else:D
- \exp_after:wN \fp_msg_overflow:
- \tex_fi:D
- \tex_advance:D \l_fp_output_decimal_int \c_one_thousand_million
- \tl_set:Nx \l_fp_tmp_tl
+ \fp_standardise:NNNN
+ \l_fp_input_b_sign_int
+ \l_fp_input_b_integer_int
+ \l_fp_input_b_decimal_int
+ \l_fp_input_b_exponent_int
+ \fp_mul_int:
+ \l_fp_output_exponent_int
+ \etex_numexpr:D
+ \l_fp_input_a_exponent_int + \l_fp_input_b_exponent_int
+ \scan_stop:
+ \fp_standardise:NNNN
+ \l_fp_output_sign_int
+ \l_fp_output_integer_int
+ \l_fp_output_decimal_int
+ \l_fp_output_exponent_int
+ \cs_set_protected_nopar:Npx \fp_tmp:w
{
- \tex_ifnum:D
- \etex_numexpr:D
- \l_fp_input_a_sign_int * \l_fp_input_b_sign_int
- \scan_stop:
- < \c_zero
- \tex_ifnum:D
- \etex_numexpr:D
- \l_fp_output_integer_int + \l_fp_output_decimal_int
- \scan_stop:
- = \c_one_thousand_million
- +
- \tex_else:D
- -
- \tex_fi:D
- \tex_else:D
- +
- \tex_fi:D
- \int_use:N \l_fp_output_integer_int
- .
- \exp_after:wN \use_none:n
- \int_use:N \l_fp_output_decimal_int
+ \group_end:
+ #1 \exp_not:N #2
+ {
+ \tex_ifnum:D
+ \etex_numexpr:D
+ \l_fp_input_a_sign_int * \l_fp_input_b_sign_int
+ < \c_zero
+ \tex_ifnum:D
+ \etex_numexpr:D
+ \l_fp_output_integer_int + \l_fp_output_decimal_int
+ = \c_zero
+ +
+ \tex_else:D
+ -
+ \tex_fi:D
+ \tex_else:D
+ +
+ \tex_fi:D
+ \int_use:N \l_fp_output_integer_int
+ .
+ \exp_after:wN \use_none:n
+ \tex_number:D \etex_numexpr:D
+ \l_fp_output_decimal_int + \c_one_thousand_million
+ e
+ \int_use:N \l_fp_output_exponent_int
+ }
}
- \exp_after:wN \group_end: \exp_after:wN
- #1 \exp_after:wN #2 \exp_after:wN { \l_fp_tmp_tl }
+ \fp_tmp:w
+}
+\cs_new_protected_nopar:Npn \fp_mul_int: {
+ \fp_mul_split:NNNN \l_fp_input_a_decimal_int
+ \l_fp_mul_a_i_int \l_fp_mul_a_ii_int \l_fp_mul_a_iii_int
+ \fp_mul_split:NNNN \l_fp_input_b_decimal_int
+ \l_fp_mul_b_i_int \l_fp_mul_b_ii_int \l_fp_mul_b_iii_int
+ \l_fp_mul_output_int \c_zero
+ \tl_clear:N \l_fp_mul_output_tl
+ \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_mul_b_iii_int
+ \fp_mul_product:NN \l_fp_mul_a_ii_int \l_fp_mul_b_ii_int
+ \fp_mul_product:NN \l_fp_mul_a_iii_int \l_fp_mul_b_i_int
+ \tex_divide:D \l_fp_mul_output_int \c_one_thousand
+ \fp_mul_product:NN \l_fp_input_a_integer_int \l_fp_mul_b_iii_int
+ \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_mul_b_ii_int
+ \fp_mul_product:NN \l_fp_mul_a_ii_int \l_fp_mul_b_i_int
+ \fp_mul_product:NN \l_fp_mul_a_iii_int \l_fp_input_b_integer_int
+ \fp_mul_end_level:
+ \fp_mul_product:NN \l_fp_input_a_integer_int \l_fp_mul_b_ii_int
+ \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_mul_b_i_int
+ \fp_mul_product:NN \l_fp_mul_a_ii_int \l_fp_input_b_integer_int
+ \fp_mul_end_level:
+ \fp_mul_product:NN \l_fp_input_a_integer_int \l_fp_mul_b_i_int
+ \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_input_b_integer_int
+ \fp_mul_end_level:
+ \l_fp_output_decimal_int 0 \l_fp_mul_output_tl \scan_stop:
+ \tl_clear:N \l_fp_mul_output_tl
+ \fp_mul_product:NN \l_fp_input_a_integer_int \l_fp_input_b_integer_int
+ \fp_mul_end_level:
+ \l_fp_output_integer_int 0 \l_fp_mul_output_tl \scan_stop:
}
\cs_new_protected_nopar:Npn \fp_mul_split:NNNN #1#2#3#4 {
\tex_advance:D #1 \c_one_thousand_million
@@ -568,6 +1196,7 @@
#4 ##8##9 \scan_stop:
}
\exp_after:wN \fp_mul_split_aux:w \int_use:N #1 \q_stop
+ \tex_advance:D #1 -\c_one_thousand_million
}
\cs_new_protected_nopar:Npn \fp_mul_product:NN #1#2 {
\l_fp_mul_output_int
@@ -575,13 +1204,13 @@
}
\cs_new_protected_nopar:Npn \fp_mul_end_level: {
\tex_advance:D \l_fp_mul_output_int \c_one_thousand_million
- \exp_after:wN \fp_mul_end_level:w
- \int_use:N \l_fp_mul_output_int \q_stop
+ \exp_after:wN \use_i:nn \exp_after:wN
+ \fp_mul_end_level:NNNNNNNNN \int_use:N \l_fp_mul_output_int
}
-\cs_new_protected_nopar:Npn \fp_mul_end_level:w
- #1#2#3#4#5#6#7#8#9 \q_stop {
- \tl_set:Nx \l_fp_mul_output_tl { #8#9 \l_fp_mul_output_tl }
- \l_fp_mul_output_int #5#6#7 \scan_stop:
+\cs_new_protected_nopar:Npn \fp_mul_end_level:NNNNNNNNN
+ #1#2#3#4#5#6#7#8#9 {
+ \tl_set:Nx \l_fp_mul_output_tl { #7#8#9 \l_fp_mul_output_tl }
+ \l_fp_mul_output_int #1#2#3#4#5#6 \scan_stop:
}
\cs_new_protected_nopar:Npn \fp_div:Nn {
\fp_div_aux:NNn \tl_set:Nn
@@ -596,94 +1225,99 @@
\group_begin:
\fp_read:N #2
\fp_split:Nn b {#3}
+ \fp_standardise:NNNN
+ \l_fp_input_b_sign_int
+ \l_fp_input_b_integer_int
+ \l_fp_input_b_decimal_int
+ \l_fp_input_b_exponent_int
\tex_ifnum:D
\etex_numexpr:D
\l_fp_input_b_integer_int + \l_fp_input_b_decimal_int
- \scan_stop:
= \c_zero
- \tl_set_eq:NN \l_fp_tmp_tl \c_undefined_fp
+ \cs_set_protected_nopar:Npx \fp_tmp:w ##1##2
+ {
+ \group_end:
+ #1 \exp_not:N #2 { \c_undefined_fp }
+ }
\tex_else:D
\tex_ifnum:D
\etex_numexpr:D
\l_fp_input_a_integer_int + \l_fp_input_a_decimal_int
- \scan_stop:
= \c_zero
- \tl_set_eq:NN \l_fp_tmp_tl \c_zero_fp
+ \cs_set_protected_nopar:Npx \fp_tmp:w ##1##2
+ {
+ \group_end:
+ #1 \exp_not:N #2 { \c_zero_fp }
+ }
\tex_else:D
\exp_after:wN \exp_after:wN \exp_after:wN
\fp_div_aux:
\tex_fi:D
\tex_fi:D
- \exp_after:wN \group_end: \exp_after:wN
- #1 \exp_after:wN #2 \exp_after:wN { \l_fp_tmp_tl }
+ \fp_tmp:w #1#2
}
\cs_new_protected_nopar:Npn \fp_div_aux: {
- \l_fp_div_offset_int \c_one
- \tex_ifnum:D \l_fp_input_a_integer_int > \c_zero
- \exp_after:wN \fp_div_offset_create:
- \tex_fi:D
\l_fp_output_integer_int \c_zero
- \l_fp_output_decimal_int \c_one_thousand_million
+ \l_fp_output_decimal_int \c_zero
\cs_set_eq:NN \fp_div_store: \fp_div_store_integer:
+ \l_fp_div_offset_int \c_one_hundred_million
\fp_div_loop:
- \tl_set:Nx \l_fp_tmp_tl
+ \l_fp_output_exponent_int
+ \etex_numexpr:D
+ \l_fp_input_a_exponent_int - \l_fp_input_b_exponent_int
+ \scan_stop:
+ \fp_standardise:NNNN
+ \l_fp_output_sign_int
+ \l_fp_output_integer_int
+ \l_fp_output_decimal_int
+ \l_fp_output_exponent_int
+ \cs_set_protected_nopar:Npx \fp_tmp:w ##1##2
{
- \tex_ifnum:D
- \etex_numexpr:D
- \l_fp_input_a_sign_int * \l_fp_input_b_sign_int
- \scan_stop:
- < \c_zero
- \tex_ifnum:D
- \etex_numexpr:D
- \l_fp_output_integer_int + \l_fp_output_decimal_int
- \scan_stop:
- = \c_one_thousand_million
- +
- \tex_else:D
- -
- \tex_fi:D
- \tex_else:D
- +
- \tex_fi:D
- \int_use:N \l_fp_output_integer_int
- .
- \exp_after:wN \use_none:n
- \int_use:N \l_fp_output_decimal_int
+ \group_end:
+ ##1 ##2
+ {
+ \tex_ifnum:D
+ \etex_numexpr:D
+ \l_fp_input_a_sign_int * \l_fp_input_b_sign_int
+ < \c_zero
+ \tex_ifnum:D
+ \etex_numexpr:D
+ \l_fp_output_integer_int + \l_fp_output_decimal_int
+ = \c_zero
+ +
+ \tex_else:D
+ -
+ \tex_fi:D
+ \tex_else:D
+ +
+ \tex_fi:D
+ \int_use:N \l_fp_output_integer_int
+ .
+ \exp_after:wN \use_none:n
+ \tex_number:D \etex_numexpr:D
+ \l_fp_output_decimal_int + \c_one_thousand_million
+ \scan_stop:
+ e
+ \int_use:N \l_fp_output_exponent_int
+ }
}
}
-\cs_new_protected_nopar:Npn \fp_div_offset_create: {
- \tex_ifnum:D \l_fp_input_b_integer_int = \c_zero
- \tex_advance:D \l_fp_input_b_decimal_int \c_one_thousand_million
- \exp_after:wN \fp_div_offset_create_aux:w
- \int_use:N \l_fp_input_b_decimal_int \q_stop
- \exp_after:wN \fp_div_offset_create:
- \tex_fi:D
-}
-\cs_new_protected_nopar:Npn \fp_div_offset_create_aux:w
- #1#2#3#4#5#6#7#8#9 \q_stop {
- \l_fp_input_b_integer_int #2 \scan_stop:
- \l_fp_input_b_decimal_int #3#4#5#6#7#8#9 0 \scan_stop:
- \tex_multiply:D \l_fp_div_offset_int \c_ten
-}
\cs_new_protected_nopar:Npn \fp_div_loop: {
- \l_fp_div_count_int \c_zero
+ \l_fp_count_int \c_zero
\fp_div_divide:
- \tex_divide:D \l_fp_input_b_decimal_int \c_ten
- \tex_advance:D \l_fp_input_b_integer_int \c_one_thousand_million
- \exp_after:wN \fp_div_loop_aux_i:w
- \int_use:N \l_fp_input_b_integer_int
\fp_div_store:
+ \tex_multiply:D \l_fp_input_a_integer_int \c_ten
+ \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
+ \exp_after:wN \fp_div_loop_step:w
+ \int_use:N \l_fp_input_a_decimal_int \q_stop
\tex_ifnum:D
\etex_numexpr:D
\l_fp_input_a_integer_int + \l_fp_input_a_decimal_int
> \c_zero
- \tex_ifnum:D
- \etex_numexpr:D
- \l_fp_input_b_integer_int + \l_fp_input_b_decimal_int
- > \c_zero
- \exp_after:wN \exp_after:wN \exp_after:wN
- \fp_div_loop:
- \tex_fi:D
+ \tex_ifnum:D \l_fp_div_offset_int > \c_zero
+ \exp_after:wN \exp_after:wN \exp_after:wN
+ \fp_div_loop:
+ \tex_fi:D
\tex_fi:D
}
\cs_new_protected_nopar:Npn \fp_div_divide: {
@@ -702,18 +1336,8 @@
\tex_fi:D
\tex_fi:D
}
-\cs_new_protected_nopar:Npn \fp_div_loop_aux_i:w #1#2#3#4#5#6#7#8#9 {
- \fp_div_loop_aux_ii:w #2#3#4#5#6#7#8#9
-}
-\cs_new_protected_nopar:Npn \fp_div_loop_aux_ii:w #1#2#3#4#5#6#7#8#9 {
- \l_fp_input_b_integer_int #1#2#3#4#5#6#7#8 \scan_stop:
- \l_fp_input_b_decimal_int
- \etex_numexpr:D
- \l_fp_input_b_decimal_int + \c_one_hundred_million * #9
- \scan_stop:
-}
\cs_new_protected_nopar:Npn \fp_div_divide_aux: {
- \tex_advance:D \l_fp_div_count_int \c_one
+ \tex_advance:D \l_fp_count_int \c_one
\tex_advance:D \l_fp_input_a_integer_int -\l_fp_input_b_integer_int
\tex_advance:D \l_fp_input_a_decimal_int -\l_fp_input_b_decimal_int
\tex_ifnum:D \l_fp_input_a_decimal_int < \c_zero
@@ -724,40 +1348,745 @@
}
\cs_new_protected_nopar:Npn \fp_div_store: { }
\cs_new_protected_nopar:Npn \fp_div_store_integer: {
- \l_fp_output_integer_int
- \etex_numexpr:D
- \l_fp_output_integer_int +
- \l_fp_div_count_int * \l_fp_div_offset_int
- \scan_stop:
- \tex_ifnum:D \l_fp_div_offset_int > \c_one
- \tex_divide:D \l_fp_div_offset_int \c_ten
- \tex_else:D
- \cs_set_eq:NN \fp_div_store: \fp_div_store_decimal:
- \l_fp_div_offset_int \c_one_hundred_million
- \tex_fi:D
+ \l_fp_output_integer_int \l_fp_count_int
+ \cs_set_eq:NN \fp_div_store: \fp_div_store_decimal:
}
\cs_new_protected_nopar:Npn \fp_div_store_decimal: {
\l_fp_output_decimal_int
\etex_numexpr:D
\l_fp_output_decimal_int +
- \l_fp_div_count_int * \l_fp_div_offset_int
+ \l_fp_count_int * \l_fp_div_offset_int
\scan_stop:
\tex_divide:D \l_fp_div_offset_int \c_ten
}
-\prg_new_protected_conditional:Npnn \fp_compare:nNn #1#2#3
- { T , F , TF } {
+\cs_new_protected_nopar:Npn
+ \fp_div_loop_step:w #1#2#3#4#5#6#7#8#9 \q_stop {
+ \l_fp_input_a_integer_int
+ \etex_numexpr:D
+ #2 + \l_fp_input_a_integer_int
+ \scan_stop:
+ \l_fp_input_a_decimal_int #3#4#5#6#7#8#9 0 \scan_stop:
+}
+\cs_new_protected_nopar:Npn \fp_add:NNNNNNNNN #1#2#3#4#5#6#7#8#9 {
+ #7 \etex_numexpr:D #1 + #4 \scan_stop:
+ #8 \etex_numexpr:D #2 + #5 \scan_stop:
+ #9 \etex_numexpr:D #3 + #6 \scan_stop:
+ \tex_ifnum:D #9 < \c_one_thousand_million
+ \tex_else:D
+ \tex_advance:D #8 \c_one
+ \tex_advance:D #9 -\c_one_thousand_million
+ \tex_fi:D
+ \tex_ifnum:D #8 < \c_one_thousand_million
+ \tex_else:D
+ \tex_advance:D #7 \c_one
+ \tex_advance:D #8 -\c_one_thousand_million
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_sub:NNNNNNNNN #1#2#3#4#5#6#7#8#9 {
+ #7 \etex_numexpr:D #1 - #4 \scan_stop:
+ #8 \etex_numexpr:D #2 - #5 \scan_stop:
+ #9 \etex_numexpr:D #3 - #6 \scan_stop:
+ \tex_ifnum:D #9 < \c_zero
+ \tex_advance:D #8 \c_minus_one
+ \tex_advance:D #9 \c_one_thousand_million
+ \tex_fi:D
+ \tex_ifnum:D #8 < \c_zero
+ \tex_advance:D #7 \c_minus_one
+ \tex_advance:D #8 \c_one_thousand_million
+ \tex_fi:D
+ \tex_ifnum:D #7 < \c_zero
+ \tex_ifnum:D \etex_numexpr:D #8 + #9 = \c_zero
+ #7 -#7
+ \tex_else:D
+ \tex_advance:D #7 \c_one
+ #8 \etex_numexpr:D \c_one_thousand_million - #8 \scan_stop:
+ #9 \etex_numexpr:D \c_one_thousand_million - #9 \scan_stop:
+ \tex_fi:D
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_mul:NNNNNN #1#2#3#4#5#6 {
+ \fp_mul_split:NNNN #1
+ \l_fp_mul_a_i_int \l_fp_mul_a_ii_int \l_fp_mul_a_iii_int
+ \fp_mul_split:NNNN #2
+ \l_fp_mul_a_iv_int \l_fp_mul_a_v_int \l_fp_mul_a_vi_int
+ \fp_mul_split:NNNN #3
+ \l_fp_mul_b_i_int \l_fp_mul_b_ii_int \l_fp_mul_b_iii_int
+ \fp_mul_split:NNNN #4
+ \l_fp_mul_b_iv_int \l_fp_mul_b_v_int \l_fp_mul_b_vi_int
+ \l_fp_mul_output_int \c_zero
+ \tl_clear:N \l_fp_mul_output_tl
+ \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_mul_b_vi_int
+ \fp_mul_product:NN \l_fp_mul_a_ii_int \l_fp_mul_b_v_int
+ \fp_mul_product:NN \l_fp_mul_a_iii_int \l_fp_mul_b_iv_int
+ \fp_mul_product:NN \l_fp_mul_a_iv_int \l_fp_mul_b_iii_int
+ \fp_mul_product:NN \l_fp_mul_a_v_int \l_fp_mul_b_ii_int
+ \fp_mul_product:NN \l_fp_mul_a_vi_int \l_fp_mul_b_i_int
+ \tex_divide:D \l_fp_mul_output_int \c_one_thousand
+ \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_mul_b_v_int
+ \fp_mul_product:NN \l_fp_mul_a_ii_int \l_fp_mul_b_iv_int
+ \fp_mul_product:NN \l_fp_mul_a_iii_int \l_fp_mul_b_iii_int
+ \fp_mul_product:NN \l_fp_mul_a_iv_int \l_fp_mul_b_ii_int
+ \fp_mul_end_level:
+ \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_mul_b_iv_int
+ \fp_mul_product:NN \l_fp_mul_a_ii_int \l_fp_mul_b_iii_int
+ \fp_mul_product:NN \l_fp_mul_a_iii_int \l_fp_mul_b_ii_int
+ \fp_mul_product:NN \l_fp_mul_a_iv_int \l_fp_mul_b_i_int
+ \fp_mul_end_level:
+ \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_mul_b_iii_int
+ \fp_mul_product:NN \l_fp_mul_a_ii_int \l_fp_mul_b_ii_int
+ \fp_mul_product:NN \l_fp_mul_a_iii_int \l_fp_mul_b_i_int
+ \fp_mul_end_level:
+ #6 0 \l_fp_mul_output_tl \scan_stop:
+ \tl_clear:N \l_fp_mul_output_tl
+ \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_mul_b_ii_int
+ \fp_mul_product:NN \l_fp_mul_a_ii_int \l_fp_mul_b_i_int
+ \fp_mul_end_level:
+ \fp_mul_product:NN \l_fp_mul_a_i_int \l_fp_mul_b_i_int
+ \fp_mul_end_level:
+ \fp_mul_end_level:
+ #5 0 \l_fp_mul_output_tl \scan_stop:
+}
+\cs_new_protected_nopar: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 \etex_numexpr:D #1 - \l_fp_tmp_int * #3 \scan_stop:
+ #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 \etex_numexpr:D #5 + \l_fp_tmp_int * \c_one_million \scan_stop:
+ \tex_ifnum:D #5 > \c_one_thousand_million
+ \tex_advance:D #4 \c_one
+ \tex_advancd:D #5 -\c_one_thousand_million
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_trig_normalise: {
+ \tex_ifnum:D \l_fp_input_a_exponent_int < \c_ten
+ \l_fp_input_a_extended_int \c_zero
+ \fp_trig_normalise_aux_i:
+ \fp_trig_normalise_aux_ii:
+ \fp_trig_normalise_aux_iii:
+ \tex_ifnum:D \l_fp_input_a_integer_int < \c_zero
+ \l_fp_input_a_sign_int -\l_fp_input_a_sign_int
+ \l_fp_input_a_integer_int -\l_fp_input_a_integer_int
+ \tex_fi:D
+ \exp_after:wN \fp_trig_octant:
+ \tex_else:D
+ \l_fp_input_a_sign_int \c_one
+ \l_fp_output_integer_int \c_zero
+ \l_fp_output_decimal_int \c_zero
+ \l_fp_output_exponent_int \c_zero
+ \exp_after:wN \fp_trig_overflow_msg:
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_trig_normalise_aux_i: {
+ \tex_ifnum:D \l_fp_input_a_exponent_int > \c_zero
+ \tex_multiply:D \l_fp_input_a_integer_int \c_ten
+ \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
+ \exp_after:wN \fp_trig_normalise_aux:w
+ \int_use:N \l_fp_input_a_decimal_int \q_stop
+ \exp_after:wN \fp_trig_normalise_aux_i:
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn
+ \fp_trig_normalise_aux:w #1#2#3#4#5#6#7#8#9 \q_stop {
+ \l_fp_input_a_integer_int
+ \etex_numexpr:D \l_fp_input_a_integer_int + #2 \scan_stop:
+ \l_fp_input_a_decimal_int #3#4#5#6#7#8#9 0 \scan_stop:
+ \tex_advance:D \l_fp_input_a_exponent_int \c_minus_one
+}
+\cs_new_protected_nopar:Npn \fp_trig_normalise_aux_ii: {
+ \tex_ifnum:D \l_fp_input_a_exponent_int < \c_zero
+ \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
+ \exp_after:wN \use_i:nn \exp_after:wN
+ \fp_trig_normalise_aux:NNNNNNNNN
+ \int_use:N \l_fp_input_a_decimal_int
+ \exp_after:wN \fp_trig_normalise_aux_ii:
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn
+ \fp_trig_normalise_aux:NNNNNNNNN #1#2#3#4#5#6#7#8#9 {
+ \tex_ifnum:D \l_fp_input_a_integer_int = \c_zero
+ \l_fp_input_a_decimal_int #1#2#3#4#5#6#7#8 \scan_stop:
+ \tex_else:D
+ \tl_set:Nx \l_fp_tmp_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:
+ \tex_fi:D
+ \tex_divide:D \l_fp_input_a_extended_int \c_ten
+ \tl_set:Nx \l_fp_tmp_tl
+ {
+ #9
+ \int_use:N \l_fp_input_a_extended_int
+ }
+ \l_fp_input_a_extended_int \l_fp_tmp_tl \scan_stop:
+ \tex_advance:D \l_fp_input_a_exponent_int \c_one
+}
+\cs_new_protected_nopar:Npn \fp_trig_normalise_aux_iii: {
+ \tex_ifnum:D \l_fp_input_a_integer_int > \c_three
+ \fp_sub:NNNNNNNNN
+ \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
+ \l_fp_input_a_extended_int
+ \c_six \c_fp_two_pi_decimal_int \c_fp_two_pi_extended_int
+ \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
+ \l_fp_input_a_extended_int
+ \exp_after:wN \fp_trig_normalise_aux_iii:
+ \tex_else:D
+ \tex_ifnum:D \l_fp_input_a_integer_int > \c_two
+ \tex_ifnum:D \l_fp_input_a_decimal_int > \c_fp_pi_decimal_int
+ \fp_sub:NNNNNNNNN
+ \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
+ \l_fp_input_a_extended_int
+ \c_six \c_fp_two_pi_decimal_int \c_fp_two_pi_extended_int
+ \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
+ \l_fp_input_a_extended_int
+ \exp_after:wN \exp_after:wN \exp_after:wN
+ \exp_after:wN \exp_after:wN \exp_after:wN
+ \exp_after:wN \fp_trig_normalise_aux_iii:
+ \tex_fi:D
+ \tex_fi:D
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_trig_octant: {
+ \l_fp_trig_octant_int \c_one
+ \fp_trig_octant_aux:
+ \tex_ifnum:D \l_fp_input_a_decimal_int < \c_ten
+ \l_fp_input_a_decimal_int \c_zero
+ \l_fp_input_a_extended_int \c_zero
+ \tex_fi:D
+ \tex_ifodd:D \l_fp_trig_octant_int
+ \tex_else:D
+ \fp_sub:NNNNNNNNN
+ \c_zero \c_fp_pi_by_four_decimal_int \c_fp_pi_by_four_extended_int
+ \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
+ \l_fp_input_a_extended_int
+ \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
+ \l_fp_input_a_extended_int
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_trig_octant_aux: {
+ \tex_ifnum:D \l_fp_input_a_integer_int > \c_zero
+ \fp_sub:NNNNNNNNN
+ \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
+ \l_fp_input_a_extended_int
+ \c_zero \c_fp_pi_by_four_decimal_int \c_fp_pi_by_four_extended_int
+ \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
+ \l_fp_input_a_extended_int
+ \tex_advance:D \l_fp_trig_octant_int \c_one
+ \exp_after:wN \fp_trig_octant_aux:
+ \tex_else:D
+ \tex_ifnum:D
+ \l_fp_input_a_decimal_int > \c_fp_pi_by_four_decimal_int
+ \fp_sub:NNNNNNNNN
+ \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
+ \l_fp_input_a_extended_int
+ \c_zero \c_fp_pi_by_four_decimal_int
+ \c_fp_pi_by_four_extended_int
+ \l_fp_input_a_integer_int \l_fp_input_a_decimal_int
+ \l_fp_input_a_extended_int
+ \tex_advance:D \l_fp_trig_octant_int \c_one
+ \exp_after:wN \exp_after:wN \exp_after:wN
+ \fp_trig_octant_aux:
+ \tex_fi:D
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_sin:Nn {
+ \fp_sin_aux:NNn \tl_set:Nn
+}
+\cs_new_protected_nopar:Npn \fp_gsin:Nn {
+ \fp_sin_aux:NNn \tl_gset:Nn
+}
+\cs_generate_variant:Nn \fp_sin:Nn { c }
+\cs_generate_variant:Nn \fp_gsin:Nn { c }
+\cs_new_protected_nopar:Npn \fp_sin_aux:NNn #1#2#3 {
+ \group_begin:
+ \fp_split:Nn a {#3}
+ \fp_standardise:NNNN
+ \l_fp_input_a_sign_int
+ \l_fp_input_a_integer_int
+ \l_fp_input_a_decimal_int
+ \l_fp_input_a_exponent_int
+ \tl_set:Nx \l_fp_trig_arg_tl
+ {
+ \tex_ifnum:D \l_fp_input_a_sign_int < \c_zero
+ -
+ \tex_else:D
+ +
+ \tex_fi:D
+ \int_use:N \l_fp_input_a_integer_int
+ .
+ \exp_after:wN \use_none:n
+ \tex_number:D \etex_numexpr:D
+ \l_fp_input_a_decimal_int + \c_one_thousand_million
+ e
+ \int_use:N \l_fp_input_a_exponent_int
+ }
+ \tex_ifnum:D \l_fp_input_a_exponent_int < -\c_five
+ \cs_set_protected_nopar:Npx \fp_tmp:w
+ {
+ \group_end:
+ #1 \exp_not:N #2 { \l_fp_trig_arg_tl }
+ }
+ \tex_else:D
+ \etex_ifcsname:D
+ c_fp_sin ( \l_fp_trig_arg_tl ) _tl
+ \tex_endcsname:D
+ \tex_else:D
+ \exp_after:wN \exp_after:wN \exp_after:wN
+ \fp_sin_aux_i:
+ \tex_fi:D
+ \cs_set_protected_nopar:Npx \fp_tmp:w
+ {
+ \group_end:
+ #1 \exp_not:N #2
+ { \use:c { c_fp_sin ( \l_fp_trig_arg_tl ) _tl } }
+ }
+ \tex_fi:D
+ \fp_tmp:w
+}
+\cs_new_protected_nopar:Npn \fp_sin_aux_i: {
+ \fp_trig_normalise:
+ \fp_sin_aux_ii:
+ \tex_ifnum:D \l_fp_output_integer_int = \c_one
+ \l_fp_output_exponent_int \c_zero
+ \tex_else:D
+ \l_fp_output_integer_int \l_fp_output_decimal_int
+ \l_fp_output_decimal_int \l_fp_output_extended_int
+ \l_fp_output_exponent_int -\c_nine
+ \tex_fi:D
+ \fp_standardise:NNNN
+ \l_fp_input_a_sign_int
+ \l_fp_output_integer_int
+ \l_fp_output_decimal_int
+ \l_fp_output_exponent_int
+ \tl_new:c { c_fp_sin ( \l_fp_trig_arg_tl ) _tl }
+ \tl_set:cx { c_fp_sin ( \l_fp_trig_arg_tl ) _tl }
+ {
+ \tex_ifnum:D \l_fp_input_a_sign_int > \c_zero
+ +
+ \tex_else:D
+ -
+ \tex_fi:D
+ \int_use:N \l_fp_output_integer_int
+ .
+ \exp_after:wN \use_none:n
+ \tex_number:D \etex_numexpr:D
+ \l_fp_output_decimal_int + \c_one_thousand_million
+ \scan_stop:
+ e
+ \int_use:N \l_fp_output_exponent_int
+ }
+}
+\cs_new_protected_nopar:Npn \fp_sin_aux_ii: {
+ \tex_ifcase:D \l_fp_trig_octant_int
+ \tex_or:D
+ \exp_after:wN \fp_trig_calc_sin:
+ \tex_or:D
+ \exp_after:wN \fp_trig_calc_cos:
+ \tex_or:D
+ \exp_after:wN \fp_trig_calc_cos:
+ \tex_or:D
+ \exp_after:wN \fp_trig_calc_sin:
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_cos:Nn {
+ \fp_cos_aux:NNn \tl_set:Nn
+}
+\cs_new_protected_nopar:Npn \fp_gcos:Nn {
+ \fp_cos_aux:NNn \tl_gset:Nn
+}
+\cs_generate_variant:Nn \fp_cos:Nn { c }
+\cs_generate_variant:Nn \fp_gcos:Nn { c }
+\cs_new_protected_nopar:Npn \fp_cos_aux:NNn #1#2#3 {
+ \group_begin:
+ \fp_split:Nn a {#3}
+ \fp_standardise:NNNN
+ \l_fp_input_a_sign_int
+ \l_fp_input_a_integer_int
+ \l_fp_input_a_decimal_int
+ \l_fp_input_a_exponent_int
+ \tl_set:Nx \l_fp_trig_arg_tl
+ {
+ \tex_ifnum:D \l_fp_input_a_sign_int < \c_zero
+ -
+ \tex_else:D
+ +
+ \tex_fi:D
+ \int_use:N \l_fp_input_a_integer_int
+ .
+ \exp_after:wN \use_none:n
+ \tex_number:D \etex_numexpr:D
+ \l_fp_input_a_decimal_int + \c_one_thousand_million
+ e
+ \int_use:N \l_fp_input_a_exponent_int
+ }
+ \etex_ifcsname:D c_fp_cos ( \l_fp_trig_arg_tl ) _tl \tex_endcsname:D
+ \tex_else:D
+ \exp_after:wN \fp_cos_aux_i:
+ \tex_fi:D
+ \cs_set_protected_nopar:Npx \fp_tmp:w
+ {
+ \group_end:
+ #1 \exp_not:N #2
+ { \use:c { c_fp_cos ( \l_fp_trig_arg_tl ) _tl } }
+ }
+ \fp_tmp:w
+}
+\cs_new_protected_nopar:Npn \fp_cos_aux_i: {
+ \fp_trig_normalise:
+ \fp_cos_aux_ii:
+ \tex_ifnum:D \l_fp_output_integer_int = \c_one
+ \l_fp_output_exponent_int \c_zero
+ \tex_else:D
+ \l_fp_output_integer_int \l_fp_output_decimal_int
+ \l_fp_output_decimal_int \l_fp_output_extended_int
+ \l_fp_output_exponent_int -\c_nine
+ \tex_fi:D
+ \fp_standardise:NNNN
+ \l_fp_input_a_sign_int
+ \l_fp_output_integer_int
+ \l_fp_output_decimal_int
+ \l_fp_output_exponent_int
+ \tl_new:c { c_fp_cos ( \l_fp_trig_arg_tl ) _tl }
+ \tl_set:cx { c_fp_cos ( \l_fp_trig_arg_tl ) _tl }
+ {
+ \tex_ifnum:D \l_fp_input_a_sign_int > \c_zero
+ +
+ \tex_else:D
+ -
+ \tex_fi:D
+ \int_use:N \l_fp_output_integer_int
+ .
+ \exp_after:wN \use_none:n
+ \tex_number:D \etex_numexpr:D
+ \l_fp_output_decimal_int + \c_one_thousand_million
+ \scan_stop:
+ e
+ \int_use:N \l_fp_output_exponent_int
+ }
+}
+\cs_new_protected_nopar:Npn \fp_cos_aux_ii: {
+ \tex_ifcase:D \l_fp_trig_octant_int
+ \tex_or:D
+ \exp_after:wN \fp_trig_calc_cos:
+ \tex_or:D
+ \exp_after:wN \fp_trig_calc_sin:
+ \tex_or:D
+ \exp_after:wN \fp_trig_calc_sin:
+ \tex_or:D
+ \exp_after:wN \fp_trig_calc_cos:
+ \tex_fi:D
+ \tex_ifnum:D \l_fp_input_a_sign_int > \c_zero
+ \tex_ifnum:D \l_fp_trig_octant_int > \c_two
+ \l_fp_input_a_sign_int \c_minus_one
+ \tex_fi:D
+ \tex_else:D
+ \tex_ifnum:D \l_fp_trig_octant_int > \c_two
+ \tex_else:D
+ \l_fp_input_a_sign_int \c_one
+ \tex_fi:D
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_trig_calc_cos: {
+ \tex_ifnum:D \l_fp_input_a_decimal_int = \c_zero
+ \l_fp_output_integer_int \c_one
+ \l_fp_output_decimal_int \c_zero
+ \tex_else:D
+ \l_fp_trig_sign_int \c_minus_one
+ \fp_mul:NNNNNN
+ \l_fp_input_a_decimal_int \l_fp_input_a_extended_int
+ \l_fp_input_a_decimal_int \l_fp_input_a_extended_int
+ \l_fp_trig_decimal_int \l_fp_trig_extended_int
+ \fp_div_integer:NNNNN
+ \l_fp_trig_decimal_int \l_fp_trig_extended_int
+ \c_two
+ \l_fp_trig_decimal_int \l_fp_trig_extended_int
+ \l_fp_count_int \c_three
+ \tex_ifnum:D \l_fp_trig_extended_int = \c_zero
+ \tex_ifnum:D \l_fp_trig_decimal_int = \c_zero
+ \l_fp_output_integer_int \c_one
+ \l_fp_output_decimal_int \c_zero
+ \l_fp_output_extended_int \c_zero
+ \tex_else:D
+ \l_fp_output_integer_int \c_zero
+ \l_fp_output_decimal_int \c_one_thousand_million
+ \l_fp_output_extended_int \c_zero
+ \tex_fi:D
+ \tex_else:D
+ \l_fp_output_integer_int \c_zero
+ \l_fp_output_decimal_int 999999999 \scan_stop:
+ \l_fp_output_extended_int \c_one_thousand_million
+ \tex_fi:D
+ \tex_advance:D \l_fp_output_extended_int -\l_fp_trig_extended_int
+ \tex_advance:D \l_fp_output_decimal_int -\l_fp_trig_decimal_int
+ \exp_after:wN \fp_trig_calc_aux:
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_trig_calc_sin: {
+ \l_fp_output_integer_int \c_zero
+ \tex_ifnum:D \l_fp_input_a_decimal_int = \c_zero
+ \l_fp_output_decimal_int \c_zero
+ \tex_else:D
+ \l_fp_output_decimal_int \l_fp_input_a_decimal_int
+ \l_fp_output_extended_int \l_fp_input_a_extended_int
+ \l_fp_trig_sign_int \c_one
+ \l_fp_trig_decimal_int \l_fp_input_a_decimal_int
+ \l_fp_trig_extended_int \l_fp_input_a_extended_int
+ \l_fp_count_int \c_two
+ \exp_after:wN \fp_trig_calc_aux:
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_trig_calc_aux: {
+ \l_fp_trig_sign_int -\l_fp_trig_sign_int
+ \fp_mul:NNNNNN
+ \l_fp_trig_decimal_int \l_fp_trig_extended_int
+ \l_fp_input_a_decimal_int \l_fp_input_a_extended_int
+ \l_fp_trig_decimal_int \l_fp_trig_extended_int
+ \fp_mul:NNNNNN
+ \l_fp_trig_decimal_int \l_fp_trig_extended_int
+ \l_fp_input_a_decimal_int \l_fp_input_a_extended_int
+ \l_fp_trig_decimal_int \l_fp_trig_extended_int
+ \fp_div_integer:NNNNN
+ \l_fp_trig_decimal_int \l_fp_trig_extended_int
+ \l_fp_count_int
+ \l_fp_trig_decimal_int \l_fp_trig_extended_int
+ \tex_advance:D \l_fp_count_int \c_one
+ \fp_div_integer:NNNNN
+ \l_fp_trig_decimal_int \l_fp_trig_extended_int
+ \l_fp_count_int
+ \l_fp_trig_decimal_int \l_fp_trig_extended_int
+ \tex_advance:D \l_fp_count_int \c_one
+ \tex_ifnum:D \l_fp_trig_decimal_int > \c_zero
+ \tex_ifnum:D \l_fp_trig_sign_int > \c_zero
+ \tex_advance:D \l_fp_output_decimal_int \l_fp_trig_decimal_int
+ \tex_advance:D \l_fp_output_extended_int
+ \l_fp_trig_extended_int
+ \tex_ifnum:D \l_fp_output_extended_int < \c_one_thousand_million
+ \tex_else:D
+ \tex_advance:D \l_fp_output_decimal_int \c_one
+ \tex_advance:D \l_fp_output_extended_int
+ -\c_one_thousand_million
+ \tex_fi:D
+ \tex_ifnum:D \l_fp_output_decimal_int < \c_one_thousand_million
+ \tex_else:D
+ \tex_advance:D \l_fp_output_integer_int \c_one
+ \tex_advance:D \l_fp_output_decimal_int
+ -\c_one_thousand_million
+ \tex_fi:D
+ \tex_else:D
+ \tex_advance:D \l_fp_output_decimal_int -\l_fp_trig_decimal_int
+ \tex_advance:D \l_fp_output_extended_int
+ -\l_fp_input_a_extended_int
+ \tex_ifnum:D \l_fp_output_extended_int < \c_zero
+ \tex_advance:D \l_fp_output_decimal_int \c_minus_one
+ \tex_advance:D \l_fp_output_extended_int \c_one_thousand_million
+ \tex_fi:D
+ \tex_ifnum:D \l_fp_output_decimal_int < \c_zero
+ \tex_advance:D \l_fp_output_integer_int \c_minus_one
+ \tex_advance:D \l_fp_output_decimal_int \c_one_thousand_million
+ \tex_fi:D
+ \tex_fi:D
+ \exp_after:wN \fp_trig_calc_aux:
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_tan:Nn {
+ \fp_tan_aux:NNn \tl_set:Nn
+}
+\cs_new_protected_nopar:Npn \fp_gtan:Nn {
+ \fp_tan_aux:NNn \tl_gset:Nn
+}
+\cs_generate_variant:Nn \fp_tan:Nn { c }
+\cs_generate_variant:Nn \fp_gtan:Nn { c }
+\cs_new_protected_nopar:Npn \fp_tan_aux:NNn #1#2#3 {
+ \group_begin:
+ \fp_split:Nn a {#3}
+ \fp_standardise:NNNN
+ \l_fp_input_a_sign_int
+ \l_fp_input_a_integer_int
+ \l_fp_input_a_decimal_int
+ \l_fp_input_a_exponent_int
+ \tl_set:Nx \l_fp_trig_arg_tl
+ {
+ \tex_ifnum:D \l_fp_input_a_sign_int < \c_zero
+ -
+ \tex_else:D
+ +
+ \tex_fi:D
+ \int_use:N \l_fp_input_a_integer_int
+ .
+ \exp_after:wN \use_none:n
+ \tex_number:D \etex_numexpr:D
+ \l_fp_input_a_decimal_int + \c_one_thousand_million
+ e
+ \int_use:N \l_fp_input_a_exponent_int
+ }
+ \tex_ifnum:D \l_fp_input_a_exponent_int < -\c_five
+ \cs_set_protected_nopar:Npx \fp_tmp:w
+ {
+ \group_end:
+ #1 \exp_not:N #2 { \l_fp_trig_arg_tl }
+ }
+ \tex_else:D
+ \etex_ifcsname:D
+ c_fp_tan ( \l_fp_trig_arg_tl ) _tl
+ \tex_endcsname:D
+ \tex_else:D
+ \exp_after:wN \exp_after:wN \exp_after:wN
+ \fp_tan_aux_i:
+ \tex_fi:D
+ \cs_set_protected_nopar:Npx \fp_tmp:w
+ {
+ \group_end:
+ #1 \exp_not:N #2
+ { \use:c { c_fp_tan ( \l_fp_trig_arg_tl ) _tl } }
+ }
+ \tex_fi:D
+ \fp_tmp:w
+}
+\cs_new_protected_nopar:Npn \fp_tan_aux_i: {
+ \tex_ifnum:D \l_fp_input_a_exponent_int < \c_ten
+ \exp_after:wN \fp_tan_aux_ii:
+ \tex_else:D
+ \cs_new_eq:cN { c_fp_tan ( \l_fp_trig_arg_tl ) _tl }
+ \c_zero_fp
+ \exp_after:wN \fp_trig_overflow_msg:
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_tan_aux_ii: {
+ \fp_trig_normalise:
+ \fp_cos_aux_ii:
+ \tex_ifnum:D \l_fp_input_a_decimal_int = \c_zero
+ \tex_ifnum:D \l_fp_input_a_integer_int = \c_zero
+ \cs_new_eq:cN { c_fp_tan ( \l_fp_trig_arg_tl ) _tl }
+ \c_undefined_fp
+ \tex_else:D
+ \exp_after:wN \exp_after:wN \exp_after:wN
+ \fp_tan_aux_iii:
+ \tex_fi:D
+ \tex_else:D
+ \exp_after:wN \fp_tan_aux_iii:
+ \tex_fi:D
+}
+\cs_new_protected_nopar:Npn \fp_tan_aux_iii: {
+ \l_fp_input_b_integer_int \l_fp_output_decimal_int
+ \l_fp_input_b_decimal_int \l_fp_output_extended_int
+ \l_fp_input_b_exponent_int -\c_nine
+ \fp_standardise:NNNN
+ \l_fp_input_b_sign_int
+ \l_fp_input_b_integer_int
+ \l_fp_input_b_decimal_int
+ \l_fp_input_b_exponent_int
+ \fp_sin_aux_ii:
+ \l_fp_input_a_integer_int \l_fp_output_decimal_int
+ \l_fp_input_a_decimal_int \l_fp_output_extended_int
+ \l_fp_input_a_exponent_int -\c_nine
+ \fp_standardise:NNNN
+ \l_fp_input_a_sign_int
+ \l_fp_input_a_integer_int
+ \l_fp_input_a_decimal_int
+ \l_fp_input_a_exponent_int
+ \tex_ifnum:D \l_fp_input_a_decimal_int = \c_zero
+ \tex_ifnum:D \l_fp_input_a_integer_int = \c_zero
+ \cs_new_eq:cN { c_fp_tan ( \l_fp_trig_arg_tl ) _tl }
+ \c_zero_fp
+ \tex_else:D
+ \exp_after:wN \exp_after:wN \exp_after:wN
+ \fp_tan_aux_iv:
+ \tex_fi:D
+ \tex_else:D
+ \exp_after:wN \fp_tan_aux_iv:
+ \tex_fi:D
+}
+ \cs_new_protected_nopar:Npn \fp_tan_aux_iv: {
+ \l_fp_output_integer_int \c_zero
+ \l_fp_output_decimal_int \c_zero
+ \cs_set_eq:NN \fp_div_store: \fp_div_store_integer:
+ \l_fp_div_offset_int \c_one_hundred_million
+ \fp_div_loop:
+ \l_fp_output_exponent_int
+ \etex_numexpr:D
+ \l_fp_input_a_exponent_int - \l_fp_input_b_exponent_int
+ \scan_stop:
+ \tex_ifnum:D \l_fp_trig_octant_int < \c_three
+ \l_fp_output_sign_int \c_one
+ \tex_else:D
+ \l_fp_output_sign_int \c_minus_one
+ \tex_fi:D
+ \fp_standardise:NNNN
+ \l_fp_output_sign_int
+ \l_fp_output_integer_int
+ \l_fp_output_decimal_int
+ \l_fp_output_exponent_int
+ \tl_new:c { c_fp_tan ( \l_fp_trig_arg_tl ) _tl }
+ \tl_set:cx { c_fp_tan ( \l_fp_trig_arg_tl ) _tl }
+ {
+ \tex_ifnum:D \l_fp_output_sign_int > \c_zero
+ +
+ \tex_else:D
+ -
+ \tex_fi:D
+ \int_use:N \l_fp_output_integer_int
+ .
+ \exp_after:wN \use_none:n
+ \tex_number:D \etex_numexpr:D
+ \l_fp_output_decimal_int + \c_one_thousand_million
+ \scan_stop:
+ e
+ \int_use:N \l_fp_output_exponent_int
+ }
+}
+\prg_new_conditional:Npnn \fp_if_infinity:N #1 { p , T , F , TF } {
+ \tex_ifx:D #1 \c_infinity_fp
+ \prg_return_true:
+ \tex_else:D
+ \prg_return_false:
+ \tex_fi:D
+}
+\prg_new_conditional:Npnn \fp_if_undefined:N #1 { p , T , F , TF } {
+ \tex_ifx:D #1 \c_undefined_fp
+ \prg_return_true:
+ \tex_else:D
+ \prg_return_false:
+ \tex_fi:D
+}
+\prg_new_conditional:Npnn \fp_if_zero:N #1 { p , T , F , TF } {
+ \tex_ifx:D #1 \c_zero_fp
+ \prg_return_true:
+ \tex_else:D
+ \prg_return_false:
+ \tex_fi:D
+}
+\prg_new_protected_conditional:Npnn \fp_compare:nNn #1#2#3 { T , F , TF }
+ {
\group_begin:
\fp_split:Nn a {#1}
+ \fp_standardise:NNNN
+ \l_fp_input_a_sign_int
+ \l_fp_input_a_integer_int
+ \l_fp_input_a_decimal_int
+ \l_fp_input_a_exponent_int
\fp_split:Nn b {#3}
+ \fp_standardise:NNNN
+ \l_fp_input_b_sign_int
+ \l_fp_input_b_integer_int
+ \l_fp_input_b_decimal_int
+ \l_fp_input_b_exponent_int
\fp_compare_aux:N #2
}
-\prg_new_protected_conditional:Npnn \fp_compare:NNN #1#2#3
- { T , F , TF } {
+\prg_new_protected_conditional:Npnn \fp_compare:NNN #1#2#3 { T , F , TF }
+ {
\group_begin:
\fp_read:N #3
- \l_fp_input_b_sign_int \l_fp_input_a_sign_int
- \l_fp_input_b_integer_int \l_fp_input_a_integer_int
- \l_fp_input_b_decimal_int \l_fp_input_a_decimal_int
+ \l_fp_input_b_sign_int \l_fp_input_a_sign_int
+ \l_fp_input_b_integer_int \l_fp_input_a_integer_int
+ \l_fp_input_b_decimal_int \l_fp_input_a_decimal_int
+ \l_fp_input_b_exponent_int \l_fp_input_a_exponent_int
\fp_read:N #1
\fp_compare_aux:N #2
}
@@ -773,8 +2102,14 @@
\tex_ifnum:D \l_fp_input_a_sign_int = \l_fp_input_b_sign_int
\tex_ifnum:D \l_fp_input_a_integer_int = \l_fp_input_b_integer_int
\tex_ifnum:D \l_fp_input_a_decimal_int = \l_fp_input_b_decimal_int
- \group_end:
- \prg_return_true:
+ \tex_ifnum:D
+ \l_fp_input_a_exponent_int = \l_fp_input_b_exponent_int
+ \group_end:
+ \prg_return_true:
+ \tex_else:D
+ \group_end:
+ \prg_return_false:
+ \tex_fi:D
\tex_else:D
\group_end:
\prg_return_false:
@@ -823,270 +2158,102 @@
\tex_fi:D
}
\cs_new_protected_nopar:cpn { fp_compare_absolute_a > b: } {
- \tex_ifnum:D \l_fp_input_a_integer_int > \l_fp_input_b_integer_int
+ \tex_ifnum:D \l_fp_input_a_exponent_int > \l_fp_input_b_exponent_int
\group_end:
\prg_return_true:
\tex_else:D
- \tex_ifnum:D \l_fp_input_a_integer_int < \l_fp_input_b_integer_int
- \group_end:
- \prg_return_false:
- \tex_else:D
- \tex_ifnum:D \l_fp_input_a_decimal_int > \l_fp_input_b_decimal_int
+ \tex_ifnum:D \l_fp_input_a_exponent_int < \l_fp_input_b_exponent_int
+ \tex_ifnum:D
+ \etex_numexpr:D
+ \l_fp_input_b_integer_int + \l_fp_input_b_decimal_int
+ = \c_zero
\group_end:
\prg_return_true:
\tex_else:D
\group_end:
\prg_return_false:
\tex_fi:D
- \tex_fi:D
- \tex_fi:D
-}
-\cs_new_protected_nopar:cpn { fp_compare_absolute_a < b: } {
- \tex_ifnum:D \l_fp_input_b_integer_int > \l_fp_input_a_integer_int
- \group_end:
- \prg_return_true:
- \tex_else:D
- \tex_ifnum:D \l_fp_input_b_integer_int < \l_fp_input_a_integer_int
- \group_end:
- \prg_return_false:
\tex_else:D
- \tex_ifnum:D \l_fp_input_b_decimal_int > \l_fp_input_a_decimal_int
+ \tex_ifnum:D \l_fp_input_a_integer_int > \l_fp_input_b_integer_int
\group_end:
\prg_return_true:
\tex_else:D
- \group_end:
- \prg_return_false:
- \tex_fi:D
- \tex_fi:D
- \tex_fi:D
-}
-\keys_define:nn { fp } {
- precision .int_set:N = \l_fp_round_precision_int ,
- remove-trailing-zeros .bool_set:N = \l_fp_remove_zeros_bool ,
- round-mode .choice: ,
- round-mode
- / half-even .tl_set:N = \l_fp_round_mode_tl ,
- round-mode
- / half-from-zero .tl_set:N = \l_fp_round_mode_tl ,
- round-mode
- / none .tl_set:N = \l_fp_round_mode_tl ,
- round-mode
- / truncate .tl_set:N = \l_fp_round_mode_tl ,
-}
-\keys_set:nn { fp } {
- precision = 9 ,
- remove-trailing-zeros = true ,
- round-mode = none ,
-}
-\cs_new_protected_nopar:Npn \fp_to_tl:NN {
- \fp_to_tl_aux:NNN \tl_set:Nn
-}
-\cs_new_protected_nopar:Npn \fp_gto_tl:NN {
- \fp_to_tl_aux:NNN \tl_gset:Nn
-}
-\cs_generate_variant:Nn \fp_to_tl:NN { Nc }
-\cs_generate_variant:Nn \fp_to_tl:NN { c }
-\cs_generate_variant:Nn \fp_to_tl:NN { cc }
-\cs_generate_variant:Nn \fp_gto_tl:NN { Nc }
-\cs_generate_variant:Nn \fp_gto_tl:NN { c }
-\cs_generate_variant:Nn \fp_gto_tl:NN { cc }
-\cs_new_protected_nopar:Npn \fp_to_tl_aux:NNN #1#2#3 {
- \group_begin:
- \fp_read:N #2
- \use:c { fp_round_ \l_fp_round_mode_tl :}
- \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
- \tl_set:Nx \l_fp_tmp_tl
- {
- \tex_ifnum:D \l_fp_input_a_sign_int < \c_zero
- -
+ \tex_ifnum:D
+ \l_fp_input_a_integer_int < \l_fp_input_b_integer_int
+ \group_end:
+ \prg_return_false:
+ \tex_else:D
+ \tex_ifnum:D
+ \l_fp_input_a_decimal_int > \l_fp_input_b_decimal_int
+ \group_end:
+ \prg_return_true:
+ \tex_else:D
+ \group_end:
+ \prg_return_false:
+ \tex_fi:D
\tex_fi:D
- \int_use:N \l_fp_input_a_integer_int
- \intexpr_compare:nNnT { \l_fp_round_precision_int } > { \c_zero }
- {
- .
- \bool_if:NTF \l_fp_remove_zeros_bool
- {
- \exp_after:wN \use_i:nn
- \exp_after:wN \fp_remove_zeros:NNNNNNNNN
- }
- { \exp_after:wN \use_none:n }
- \int_use:N \l_fp_input_a_decimal_int
- }
- }
- \exp_after:wN \group_end: \exp_after:wN
- #1 \exp_after:wN #3 \exp_after:wN { \l_fp_tmp_tl }
-}
-\cs_new_nopar:Npn \fp_remove_zeros:NNNNNNNNN #1#2#3#4#5#6#7#8#9 {
- \fp_remove_zeros_aux:w #1#2#3#4#5#6#7#8#9 \q_stop 1
-}
-\cs_new_nopar:Npn \fp_remove_zeros_aux:w #1#2 \q_stop #3 {
- #1
- \intexpr_compare:nNnTF { 0 #2 } = { \c_zero }
- {
- \intexpr_compare:nNnF { \l_fp_round_precision_int } < { #3 + 1 }
- {
- \intexpr_compare:nNnT {#3} < { 9 }
- { \fp_remove_zeros_aux:w #2 \q_stop { #3 + 1 } }
- }
- }
- {
- \intexpr_compare:nNnT {#3} < { 9 }
- { \fp_remove_zeros_aux:w #2 \q_stop { #3 + 1 } }
- }
-}
-\cs_new_protected_nopar:cpn { fp_round_half-from-zero: } {
- \tex_ifnum:D \l_fp_round_precision_int < \c_nine
- \exp_after:wN \fp_round_from_zero:
- \tex_fi:D
-}
-\cs_new_protected_nopar:Npn \fp_round_from_zero: {
- \bool_set_false:N \l_fp_round_carry_bool
- \l_fp_round_position_int \c_eight
- \tl_clear:N \l_fp_round_decimal_tl
- \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
- \exp_after:wN \use_i:nn \exp_after:wN
- \fp_round_from_zero_aux:NNNNNNNNN
- \int_use:N \l_fp_input_a_decimal_int
-}
-\cs_new_protected_nopar:Npn \fp_round_from_zero_aux:NNNNNNNNN
- #1#2#3#4#5#6#7#8#9 {
- \fp_round_from_zero_decimal:N #9#8#7#6#5#4#3#2#1
- \fp_round_from_zero_integer:
-}
-\cs_new_protected_nopar:Npn \fp_round_from_zero_decimal:N #1 {
- \tex_ifnum:D \l_fp_round_position_int < \l_fp_round_precision_int
- \bool_if:NTF \l_fp_round_carry_bool
- { \l_fp_tmp_int \etex_numexpr:D #1 + \c_one \scan_stop: }
- { \l_fp_tmp_int \etex_numexpr:D #1 \scan_stop: }
- \tex_ifnum:D \l_fp_tmp_int = \c_ten
- \l_fp_tmp_int \c_zero
- \tex_else:D
- \bool_set_false:N \l_fp_round_carry_bool
- \tex_fi:D
- \tl_set:Nx \l_fp_round_decimal_tl
- { \int_use:N \l_fp_tmp_int \l_fp_round_decimal_tl }
- \tex_else:D
- \tl_set:Nx \l_fp_round_decimal_tl { 0 \l_fp_round_decimal_tl }
- \tex_ifnum:D \l_fp_round_position_int = \l_fp_round_precision_int
- \tex_ifnum:D #1 > \c_four
- \bool_set_true:N \l_fp_round_carry_bool
\tex_fi:D
\tex_fi:D
\tex_fi:D
- \tex_advance:D \l_fp_round_position_int \c_minus_one
- \tex_ifnum:D \l_fp_round_position_int > \c_minus_one
- \exp_after:wN \fp_round_from_zero_decimal:N
- \tex_fi:D
-}
-\cs_new_protected_nopar:Npn \fp_round_from_zero_integer: {
- \bool_if:NT \l_fp_round_carry_bool
- { \tex_advance:D \l_fp_input_a_integer_int \c_one }
- \l_fp_input_a_decimal_int \l_fp_round_decimal_tl \scan_stop:
-}
-\cs_new_protected_nopar:cpn { fp_round_half-even: } {
- \tex_ifnum:D \l_fp_round_precision_int < \c_nine
- \exp_after:wN \fp_round_even:
- \tex_fi:D
-}
-\cs_new_protected_nopar:Npn \fp_round_even: {
- \bool_set_false:N \l_fp_round_carry_bool
- \l_fp_round_position_int \c_eight
- \tl_clear:N \l_fp_round_decimal_tl
- \int_zero:N \l_fp_round_discard_int
- \tex_advance:D \l_fp_input_a_decimal_int \c_one_thousand_million
- \exp_after:wN \use_i:nn \exp_after:wN
- \fp_round_even_aux:NNNNNNNNN
- \int_use:N \l_fp_input_a_decimal_int
-}
-\cs_new_protected_nopar:Npn \fp_round_even_aux:NNNNNNNNN
- #1#2#3#4#5#6#7#8#9 {
- \fp_round_even_decimal:N #9#8#7#6#5#4#3#2#1
- \fp_round_even_integer:
}
-\cs_new_protected_nopar:Npn \fp_round_even_decimal:N #1 {
- \tex_ifnum:D \l_fp_round_position_int < \l_fp_round_precision_int
- \bool_if:NTF \l_fp_round_carry_bool
- {
- \tex_ifnum:D \l_fp_round_discard_int = \c_zero
- \l_fp_round_discard_int \c_one
- \tex_ifodd:D #1 \scan_stop:
- \l_fp_tmp_int \etex_numexpr:D #1 + \c_one \scan_stop:
- \tex_else:D
- \l_fp_tmp_int \etex_numexpr:D #1 \scan_stop:
- \tex_fi:D
- \tex_else:D
- \l_fp_tmp_int \etex_numexpr:D #1 + \c_one \scan_stop:
- \tex_fi:D
- }
- { \l_fp_tmp_int \etex_numexpr:D #1 \scan_stop: }
- \tex_ifnum:D \l_fp_tmp_int = \c_ten
- \l_fp_tmp_int \c_zero
+\cs_new_protected_nopar:cpn { fp_compare_absolute_a < b: } {
+ \tex_ifnum:D \l_fp_input_b_exponent_int > \l_fp_input_a_exponent_int
+ \tex_ifnum:D
+ \etex_numexpr:D
+ \l_fp_input_b_integer_int + \l_fp_input_b_decimal_int
+ = \c_zero
+ \group_end:
+ \prg_return_false:
\tex_else:D
- \bool_set_false:N \l_fp_round_carry_bool
+ \group_end:
+ \prg_return_true:
\tex_fi:D
- \tl_set:Nx \l_fp_round_decimal_tl
- { \int_use:N \l_fp_tmp_int \l_fp_round_decimal_tl }
\tex_else:D
- \tl_set:Nx \l_fp_round_decimal_tl { 0 \l_fp_round_decimal_tl }
- \tex_ifnum:D \l_fp_round_position_int = \l_fp_round_precision_int
- \tex_ifnum:D #1 > \c_four
- \bool_set_true:N \l_fp_round_carry_bool
- \tex_ifnum:D #1 = \c_five
+ \tex_ifnum:D \l_fp_input_b_exponent_int < \l_fp_input_a_exponent_int
+ \group_end:
+ \prg_return_false:
+ \tex_else:D
+ \tex_ifnum:D \l_fp_input_b_integer_int > \l_fp_input_a_integer_int
+ \group_end:
+ \prg_return_true:
+ \tex_else:D
+ \tex_ifnum:D
+ \l_fp_input_b_integer_int < \l_fp_input_a_integer_int
+ \group_end:
+ \prg_return_false:
\tex_else:D
- \l_fp_round_discard_int \c_one
+ \tex_ifnum:D
+ \l_fp_input_b_decimal_int > \l_fp_input_a_decimal_int
+ \group_end:
+ \prg_return_true:
+ \tex_else:D
+ \group_end:
+ \prg_return_false:
+ \tex_fi:D
\tex_fi:D
\tex_fi:D
- \tex_else:D
- \tex_advance:D \l_fp_round_discard_int #1 \scan_stop:
\tex_fi:D
\tex_fi:D
- \tex_advance:D \l_fp_round_position_int \c_minus_one
- \tex_ifnum:D \l_fp_round_position_int > \c_minus_one
- \exp_after:wN \fp_round_even_decimal:N
- \tex_fi:D
-}
-\cs_new_protected_nopar:Npn \fp_round_even_integer: {
- \bool_if:NT \l_fp_round_carry_bool
- {
- \tex_ifnum:D \l_fp_round_discard_int = \c_zero
- \tex_ifodd:D \l_fp_input_a_integer_int
- \tex_advance:D \l_fp_input_a_integer_int \c_one
- \tex_fi:D
- \tex_else:D
- \tex_advance:D \l_fp_input_a_integer_int \c_one
- \tex_fi:D
- }
- \l_fp_input_a_decimal_int \l_fp_round_decimal_tl \scan_stop:
-}
-\cs_new_protected_nopar:Npn \fp_round_none: {
- \l_fp_round_precision_int \c_one
-}
-\cs_new_protected_nopar:Npn \fp_round_truncate: {
- \intexpr_compare:nNnF { \l_fp_round_precision_int } > { 8 }
- {
- \intexpr_compare:nNnTF { \l_fp_round_precision_int } < { 1 }
- { \l_fp_input_a_decimal_int \c_zero \scan_stop: }
- {
- \int_set:Nn \l_fp_tmp_int
- {
- \prg_replicate:nn { 9 - \l_fp_round_precision_int }
- { 10 * }
- 1
- }
- \tex_divide:D \l_fp_input_a_decimal_int \l_fp_tmp_int
- \tex_multiply:D \l_fp_input_a_decimal_int \l_fp_tmp_int
- }
- }
}
-\cs_new_protected_nopar:Npn \fp_msg_overflow: {
+
+\msg_kernel_new:nnnn { fpu } { overflow }
+ { Number~too~big. }
+ {
+ The~input~given~is~too~big~for~the~LaTeX~floating~point~unit. \\
+ Further~errors~may~well~occur!
+ }
+\cs_new_protected_nopar:Npn \fp_overflow_msg: {
\msg_kernel_error:nn { fpu } { overflow }
}
-\msg_kernel_new:nnnn { fpu } { overflow }
- { Arithmetic~overflow. }
+\msg_kernel_new:nnnn { fpu } { trigonometric-overflow }
+ { Number~too~big~for~trigonometry~unit. }
{
- The~calculation~requested~exceeds~the~capacity \\
- of~the~fixed-point~unit.
+ The~trigonometry~code~can~only~work~with~numbers~smaller~
+ than~1000000000.
}
+\cs_new_protected_nopar:Npn \fp_trig_overflow_msg: {
+ \msg_kernel_error:nn { fpu } { trigonometric-overflow }
+}
%%
%%
%% End of file `l3fp.sty'.
diff --git a/Master/texmf-dist/tex/latex/expl3/l3prg.sty b/Master/texmf-dist/tex/latex/expl3/l3prg.sty
index 5476a648597..38112ebffa8 100644
--- a/Master/texmf-dist/tex/latex/expl3/l3prg.sty
+++ b/Master/texmf-dist/tex/latex/expl3/l3prg.sty
@@ -48,7 +48,7 @@
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
-\GetIdInfo$Id: l3prg.dtx 1853 2010-03-21 09:11:08Z joseph $
+\GetIdInfo$Id: l3prg.dtx 1992 2010-08-04 20:41:40Z joseph $
{L3 Experimental control structures}
\ProvidesExplPackage
{\filename}{\filedate}{\fileversion}{\filedescription}
@@ -478,6 +478,90 @@
}
}
}
+\cs_new_protected:Npn \prg_new_map_functions:Nn #1#2 {
+ \cs_if_free:cTF { #2 _map_function:NN }
+ { \prg_set_map_functions:Nn #1 {#2} }
+ {
+ \msg_kernel_error:nnx { code } { csname-already-defined }
+ { \token_to_str:c { #2 _map_function:NN } }
+ }
+}
+\cs_new_protected:Npn \prg_set_map_functions:Nn #1#2 {
+ \cs_gset_nopar:cpx { #2 _map_function:NN } ##1##2
+ {
+ \exp_not:N \tl_if_empty:NF ##1
+ {
+ \exp_not:N \exp_after:wN
+ \exp_not:c { #2 _map_function_aux:Nw }
+ \exp_not:N \exp_after:wN ##2 ##1
+ \exp_not:n { #1 \q_recursion_tail #1 \q_recursion_stop }
+ }
+ }
+ \cs_gset:cpx { #2 _map_function:nN } ##1##2
+ {
+ \exp_not:N \tl_if_blank:nF {##1}
+ {
+ \exp_not:c { #2 _map_function_aux:Nw } ##2 ##1
+ \exp_not:n { #1 \q_recursion_tail #1 \q_recursion_stop }
+ }
+ }
+ \cs_gset:cpx { #2 _map_function_aux:Nw } ##1##2 #1
+ {
+ \exp_not:N \quark_if_recursion_tail_stop:n {##2}
+ ##1 {##2}
+ \exp_not:c { #2 _map_function_aux:Nw } ##1
+ }
+ \cs_if_free:cT { g_ #2 _map_inline_int }
+ { \int_new:c { g_ #2 _map_inline_int } }
+ \cs_gset_protected_nopar:cpx { #2 _map_inline:Nn } ##1##2
+ {
+ \exp_not:N \tl_if_empty:NF ##1
+ {
+ \exp_not:N \int_gincr:N \exp_not:c { g_ #2 _map_inline_int }
+ \cs_gset:cpn
+ {
+ #2 _map_inline_
+ \exp_not:N \int_use:N \exp_not:c { g_ #2 _map_inline_int }
+ :n
+ }
+ ####1 {##2}
+ \exp_not:N \exp_last_unbraced:NcV
+ \exp_not:c { #2 _map_function_aux:Nw }
+ {
+ #2 _map_inline_
+ \exp_not:N \int_use:N \exp_not:c { g_ #2 _map_inline_int }
+ :n
+ }
+ ##1 \exp_not:n { #1 \q_recursion_tail #1 \q_recursion_stop }
+ \exp_not:N \int_gdecr:N \exp_not:c { g_ #2 _map_inline_int }
+ }
+ }
+ \cs_gset_protected:cpx { #2 _map_inline:nn } ##1##2
+ {
+ \exp_not:N \tl_if_empty:nF {##1}
+ {
+ \exp_not:N \int_gincr:N \exp_not:c { g_ #2 _map_inline_int }
+ \cs_gset:cpn
+ {
+ #2 _map_inline_
+ \exp_not:N \int_use:N \exp_not:c { g_ #2 _map_inline_int }
+ :n
+ }
+ ####1 {##2}
+ \exp_not:N \exp_args:Nc
+ \exp_not:c { #2 _map_function_aux:Nw }
+ {
+ #2 _map_inline_
+ \exp_not:N \int_use:N \exp_not:c { g_ #2 _map_inline_int }
+ :n
+ }
+ ##1 \exp_not:n { #1 \q_recursion_tail #1 \q_recursion_stop }
+ \exp_not:N \int_gdecr:N \exp_not:c { g_ #2 _map_inline_int }
+ }
+ }
+ \cs_gset_eq:cN { #2 _map_break: }
+ \use_none_delimit_by_q_recursion_stop:w
+}
%%
%%
%% End of file `l3prg.sty'.