diff options
author | Karl Berry <karl@freefriends.org> | 2020-02-01 22:09:55 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-02-01 22:09:55 +0000 |
commit | 3cac8298f5b8b21ddd1aecbea42a135a9c5e4cb8 (patch) | |
tree | 9920a659b7ad3860aeb7f391e499b7ccf7f886f8 /Master/texmf-dist/tex/generic/xint/xintfrac.sty | |
parent | 22cb4622b403ec9e42484b7af858243a417e2d12 (diff) |
xint (1feb20)
git-svn-id: svn://tug.org/texlive/trunk@53622 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/xint/xintfrac.sty')
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintfrac.sty | 224 |
1 files changed, 178 insertions, 46 deletions
diff --git a/Master/texmf-dist/tex/generic/xint/xintfrac.sty b/Master/texmf-dist/tex/generic/xint/xintfrac.sty index a9371efa96a..b8e08f1936f 100644 --- a/Master/texmf-dist/tex/generic/xint/xintfrac.sty +++ b/Master/texmf-dist/tex/generic/xint/xintfrac.sty @@ -21,8 +21,8 @@ %% same distribution. (The sources need not necessarily be %% in the same archive or directory.) %% --------------------------------------------------------------- -%% The xint bundle 1.3f 2019/09/10 -%% Copyright (C) 2013-2019 by Jean-Francois Burnol +%% The xint bundle 1.4 2020/01/31 +%% Copyright (C) 2013-2020 by Jean-Francois Burnol %% xintfrac: Expandable operations on fractions %% --------------------------------------------------------------- \begingroup\catcode61\catcode48\catcode32=10\relax% @@ -70,7 +70,7 @@ \XINTsetupcatcodes% defined in xintkernel.sty \XINT_providespackage \ProvidesPackage{xintfrac}% - [2019/09/10 v1.3f Expandable operations on fractions (JFB)]% + [2020/01/31 v1.4 Expandable operations on fractions (JFB)]% \def\XINT_cntSgnFork #1% {% \ifcase #1\expandafter\xint_secondofthree @@ -453,6 +453,42 @@ \else\expandafter\xint_secondoftwo \fi { #2}{ #2/#3}% }% +\def\xintSPRaw {\romannumeral0\xintspraw }% +\def\xintspraw #1{\expandafter\XINT_spraw\romannumeral`&&@#1[\W]}% +\def\XINT_spraw #1[#2#3]{\xint_gob_til_W #2\XINT_spraw_a\W\XINT_spraw_p #1[#2#3]}% +\def\XINT_spraw_a\W\XINT_spraw_p #1[\W]{ #1}% +\def\XINT_spraw_p #1[\W]{\xintpraw {#1}}% +\def\xintFracToSci #1% + {\expandafter\XINT_FracToSci\romannumeral`&&@#1/\W[\R]}% +\def\XINT_FracToSci #1/#2#3[#4% +{% + \xint_gob_til_W #2\XINT_FracToSci_no\W + \xint_gob_til_R #4\XINT_FracToSci_yesno\R + \XINT_FracToSci_yesyes #1/#2#3[#4% +}% +\def\XINT_FracToSci_no #1\XINT_FracToSci_yesyes #2[#3% +{% + \xint_gob_til_R #3\XINT_FracToSci_nono\R + \XINT_FracToSci_noyes #2[#3% +}% +\def\XINT_FracToSci_nono\R\XINT_FracToSci_noyes #1/\W[\R]{#1}% +\def\XINT_FracToSci_noyes #1#2[#3]/\W[\R]% +{% + #1\xint_gob_til_zero#1\expandafter\iffalse\xint_gobble_ii0\iftrue + #2\ifnum #3=\xint_c_\else\xintFracToSciE#3\fi\fi +}% +\def\XINT_FracToSci_yesno\R\XINT_FracToSci_yesyes #1#2/#3/\W[\R]% +{% + #1\xint_gob_til_zero#1\expandafter\iffalse\xint_gobble_ii0\iftrue + #2\if\XINT_isOne{#3}1\else/#3\fi\fi +}% +\def\XINT_FracToSci_yesyes #1#2/#3[#4]/\W[\R]% +{% + #1\xint_gob_til_zero#1\expandafter\iffalse\xint_gobble_ii0\iftrue + #2\ifnum #4=\xint_c_\else\xintFracToSciE#4\fi + \if\XINT_isOne{#3}1\else/#3\fi\fi +}% +\def\xintFracToSciE{e}% \def\xintRawWithZeros {\romannumeral0\xintrawwithzeros }% \def\xintrawwithzeros {% @@ -1340,21 +1376,21 @@ 0-{\XINT_fadd_c -#1}% \krof }% \def\xintSum {\romannumeral0\xintsum }% -\def\xintsum #1{\expandafter\XINT_fsumexpr\romannumeral`&&@#1\xint:}% -\def\XINT_fsumexpr {\XINT_fsum_loop_a {0/1[0]}}% -\def\XINT_fsum_loop_a #1#2% -{% - \expandafter\XINT_fsum_loop_b \romannumeral`&&@#2\xint:{#1}% -}% -\def\XINT_fsum_loop_b #1% +\def\xintsum #1{\expandafter\XINT_sum\romannumeral`&&@#1^}% +\def\XINT_Sum{\romannumeral0\XINT_sum}% +\def\XINT_sum#1% {% - \xint_gob_til_xint: #1\XINT_fsum_finished\xint:\XINT_fsum_loop_c #1% + \xint_gob_til_^ #1\XINT_sum_empty ^% + \expandafter\XINT_sum_loop\romannumeral0\xintraw{#1}\xint: }% -\def\XINT_fsum_loop_c #1\xint:#2% +\def\XINT_sum_empty ^#1\xint:{ 0/1[0]}% +\def\XINT_sum_loop #1\xint:#2% {% - \expandafter\XINT_fsum_loop_a\expandafter{\romannumeral0\xintadd {#2}{#1}}% + \xint_gob_til_^ #2\XINT_sum_end ^% + \expandafter\XINT_sum_loop + \romannumeral0\xintadd{#1}{\romannumeral0\xintraw{#2}}\xint: }% -\def\XINT_fsum_finished #1\xint:\xint:#2{ #2}% +\def\XINT_sum_end ^#1\xintadd #2#3\xint:{ #2}% \def\xintMul {\romannumeral0\xintmul }% \def\xintmul #1{\expandafter\XINT_fmul\romannumeral0\xintraw {#1}.}% \def\XINT_fmul #1{\xint_gob_til_zero #1\XINT_fmul_zero 0\XINT_fmul_a #1}% @@ -1449,21 +1485,21 @@ \the\numexpr\xintNum{#1}\expandafter.\the\numexpr\xintNum{#2}.[0]% }% \def\xintPrd {\romannumeral0\xintprd }% -\def\xintprd #1{\expandafter\XINT_fprdexpr \romannumeral`&&@#1\xint:}% -\def\XINT_fprdexpr {\XINT_fprod_loop_a {1/1[0]}}% -\def\XINT_fprod_loop_a #1#2% +\def\xintprd #1{\expandafter\XINT_prd\romannumeral`&&@#1^}% +\def\XINT_Prd{\romannumeral0\XINT_prd}% +\def\XINT_prd#1% {% - \expandafter\XINT_fprod_loop_b \romannumeral`&&@#2\xint:{#1}% + \xint_gob_til_^ #1\XINT_prd_empty ^% + \expandafter\XINT_prd_loop\romannumeral0\xintraw{#1}\xint: }% -\def\XINT_fprod_loop_b #1% +\def\XINT_prd_empty ^#1\xint:{ 1/1[0]}% +\def\XINT_prd_loop #1\xint:#2% {% - \xint_gob_til_xint: #1\XINT_fprod_finished\xint:\XINT_fprod_loop_c #1% + \xint_gob_til_^ #2\XINT_prd_end ^% + \expandafter\XINT_prd_loop + \romannumeral0\xintmul{#1}{\romannumeral0\xintraw{#2}}\xint: }% -\def\XINT_fprod_loop_c #1\xint:#2% -{% - \expandafter\XINT_fprod_loop_a\expandafter{\romannumeral0\xintmul {#1}{#2}}% -}% -\def\XINT_fprod_finished#1\xint:\xint:#2{ #2}% +\def\XINT_prd_end ^#1\xintmul #2#3\xint:{ #2}% \def\xintDiv {\romannumeral0\xintdiv }% \def\xintdiv #1% {% @@ -1720,16 +1756,22 @@ \else \xint_afterfi{ #2}% \fi }% -\def\xintMaxof {\romannumeral0\xintmaxof }% -\def\xintmaxof #1{\expandafter\XINT_maxof_a\romannumeral`&&@#1\xint:}% -\def\XINT_maxof_a #1{\expandafter\XINT_maxof_b\romannumeral0\xintraw{#1}!}% -\def\XINT_maxof_b #1!#2% - {\expandafter\XINT_maxof_c\romannumeral`&&@#2!{#1}!}% -\def\XINT_maxof_c #1% - {\xint_gob_til_xint: #1\XINT_maxof_e\xint:\XINT_maxof_d #1}% -\def\XINT_maxof_d #1!% - {\expandafter\XINT_maxof_b\romannumeral0\xintmax {#1}}% -\def\XINT_maxof_e #1!#2!{ #2}% +\def\xintMaxof {\romannumeral0\xintmaxof }% +\def\xintmaxof #1{\expandafter\XINT_maxof\romannumeral`&&@#1^}% +\def\XINT_Maxof{\romannumeral0\XINT_maxof}% +\def\XINT_maxof#1% +{% + \xint_gob_til_^ #1\XINT_maxof_empty ^% + \expandafter\XINT_maxof_loop\romannumeral0\xintraw{#1}\xint: +}% +\def\XINT_maxof_empty ^#1\xint:{ 0/1[0]}% +\def\XINT_maxof_loop #1\xint:#2% +{% + \xint_gob_til_^ #2\XINT_maxof_e ^% + \expandafter\XINT_maxof_loop + \romannumeral0\xintmax{#1}{\romannumeral0\xintraw{#2}}\xint: +}% +\def\XINT_maxof_e ^#1\xintmax #2#3\xint:{ #2}% \def\xintMin {\romannumeral0\xintmin }% \def\xintmin #1% {% @@ -1764,16 +1806,21 @@ \else \xint_afterfi{ #1}% \fi }% -\def\xintMinof {\romannumeral0\xintminof }% -\def\xintminof #1{\expandafter\XINT_minof_a\romannumeral`&&@#1\xint:}% -\def\XINT_minof_a #1{\expandafter\XINT_minof_b\romannumeral0\xintraw{#1}!}% -\def\XINT_minof_b #1!#2% - {\expandafter\XINT_minof_c\romannumeral`&&@#2!{#1}!}% -\def\XINT_minof_c #1% - {\xint_gob_til_xint: #1\XINT_minof_e\xint:\XINT_minof_d #1}% -\def\XINT_minof_d #1!% - {\expandafter\XINT_minof_b\romannumeral0\xintmin {#1}}% -\def\XINT_minof_e #1!#2!{ #2}% +\def\xintMinof {\romannumeral0\xintminof }% +\def\xintminof #1{\expandafter\XINT_minof\romannumeral`&&@#1^}% +\def\XINT_Minof{\romannumeral0\XINT_minof}% +\def\XINT_minof#1% +{% + \xint_gob_til_^ #1\XINT_minof_empty ^% + \expandafter\XINT_minof_loop\romannumeral0\xintraw{#1}\xint: +}% +\def\XINT_minof_empty ^#1\xint:{ 0/1[0]}% +\def\XINT_minof_loop #1\xint:#2% +{% + \xint_gob_til_^ #2\XINT_minof_e ^% + \expandafter\XINT_minof_loop\romannumeral0\xintmin{#1}{\romannumeral0\xintraw{#2}}\xint: +}% +\def\XINT_minof_e ^#1\xintmin #2#3\xint:{ #2}% \def\xintCmp {\romannumeral0\xintcmp }% \def\xintcmp #1% {% @@ -1878,6 +1925,82 @@ \def\XINT_inv_b #1.#2{ #2[#1]}% \def\xintSgn {\romannumeral0\xintsgn }% \def\xintsgn #1{\expandafter\XINT_sgn\romannumeral0\xintraw {#1}\xint:}% +\def\xintGCD {\romannumeral0\xintgcd}% +\def\xintgcd #1#2{\XINT_fgcdof{#1}{#2}^}% +\def\xintLCM {\romannumeral0\xintlcm}% +\def\xintlcm #1#2{\XINT_flcmof{#1}{#2}^}% +\def\xintGCDof {\romannumeral0\xintgcdof}% +\def\xintgcdof #1{\expandafter\XINT_fgcdof\romannumeral`&&@#1^}% +\def\XINT_GCDof{\romannumeral0\XINT_fgcdof}% +\def\XINT_fgcdof #1% +{% + \xint_gob_til_^ #1\XINT_fgcdof_empty ^% + \expandafter\XINT_fgcdof_loop\romannumeral0\xintiiabs#1\xint: +}% +\def\XINT_fgcdof_empty ^#1\xint:{ 1/1[0]}% +\def\XINT_fgcdof_loop #1\xint:#2% +{% + \expandafter\XINT_fgcdof_loop_a\romannumeral0\xintiiabs#2\xint:#1\xint: +}% +\def\XINT_fgcdof_loop_a#1#2\xint:#3\xint: +{% + \xint_gob_til_^ #1\XINT_fgcdof_end ^% + \xint_gob_til_zero #1\XINT_fgcdof_skip 0% + \expandafter\XINT_fgcdof_loop_b\romannumeral0\xintmod{#1#2}{#3}\xint:#3\xint: +}% +\def\XINT_fgcdof_end ^#1\xint:#2\xint:{ #2}% +\def\XINT_fgcdof_skip 0% + \expandafter\XINT_fgcdof_loop_b\romannumeral0\xintmod#1\xint: +{% + \XINT_fgcdof_loop +}% +\def\XINT_fgcdof_loop_b#1#2\xint:#3\xint: +{% + \xint_gob_til_zero #1\XINT_fgcdof_next 0% + \expandafter\XINT_fgcdof_loop_b\romannumeral0\xintmod{#3}{#1#2}\xint:#1#2\xint: +}% +\def\XINT_fgcdof_next 0% + \expandafter\XINT_fgcdof_loop_b\romannumeral0\xintmod#1#2\xint:#3\xint:#4% +{% + \expandafter\XINT_fgcdof_loop_a\romannumeral0\xintiiabs#4\xint:#1\xint: +}% +\def\xintLCMof {\romannumeral0\xintlcmof}% +\def\xintlcmof #1{\expandafter\XINT_flcmof\romannumeral`&&@#1^}% +\def\XINT_LCMof{\romannumeral0\XINT_flcmof}% +\def\XINT_flcmof #1% +{% + \xint_gob_til_^ #1\XINT_flcmof_empty ^% + \expandafter\XINT_flcmof_loop\romannumeral0\xintiiabs\xintRaw{#1}\xint: +}% +\def\XINT_flcmof_empty ^#1\xint:{ 0/1[0]}% +\def\XINT_flcmof_loop #1% +{% + \xint_gob_til_zero #1\XINT_flcmof_zero 0% + \expandafter\XINT_flcmof_d\romannumeral0\XINT_inv #1% +}% +\def\XINT_flcmof_zero #1^{ 0/1[0]}% +\def\XINT_flcmof_d #1\xint:#2% +{% + \expandafter\XINT_flcmof_loop_a\romannumeral0\xintiiabs#2\xint:#1\xint: +}% +\def\XINT_flcmof_loop_a #1#2\xint:% +{% + \xint_gob_til_^ #1\XINT_flcmof_end ^% + \xint_gob_til_zero #1\XINT_flcmof_zero 0% + \expandafter\XINT_flcmof_loop_b\romannumeral0\expandafter\XINT_inv + \romannumeral0\xintraw{#1#2}\xint: +}% +\def\XINT_flcmof_end ^#1\xint:#2\xint:{\XINT_inv #2}% +\def\XINT_flcmof_loop_b #1#2\xint:#3\xint: +{% + \xint_gob_til_zero #1\XINT_flcmof_next 0% + \expandafter\XINT_flcmof_loop_b\romannumeral0\xintmod{#3}{#1#2}\xint:#1#2\xint: +}% +\def\XINT_flcmof_next 0% + \expandafter\XINT_flcmof_loop_b\romannumeral0\xintmod#1#2\xint:#3\xint:#4% +{% + \expandafter\XINT_flcmof_loop_a\romannumeral0\xintiiabs#4\xint:#1\xint: +}% \mathchardef\XINTdigits 16 \def\xintDigits #1=% {\afterassignment \xint_gobble_i \mathchardef\XINTdigits=}% @@ -3278,7 +3401,7 @@ {\romannumeral0\XINTinfloat[#1]{#3}}% {#1}% }% -\def\XINT_infloatdivmod #1#2#3{ #1,\XINTinFloat[#3]{#2}}% +\def\XINT_infloatdivmod #1#2#3{\expanded{{#1}{\XINTinFloat[#3]{#2}}}}% \def\xintifFloatInt {\romannumeral0\xintiffloatint}% \def\xintiffloatint #1{\expandafter\XINT_iffloatint \romannumeral0\xintrez{\XINTinFloat[\XINTdigits]{#1}}}% @@ -3291,6 +3414,11 @@ \def\xintFloatIsInt {\romannumeral0\xintfloatisint}% \def\xintfloatisint #1{\expandafter\XINT_iffloatint \romannumeral0\xintrez{\XINTinFloat[\XINTdigits]{#1}}10}% +\def\XINTinFloatdigits {\XINTinFloat [\XINTdigits]}% +\def\XINTinFloatSdigits {\XINTinFloatS [\XINTdigits]}% +\def\XINTinFloatSqrtdigits {\XINTinFloatSqrt[\XINTdigits]}% +\def\XINTinFloatFacdigits {\XINTinFloatFac [\XINTdigits]}% +\def\XINTFloatiLogTendigits{\XINTFloatiLogTen[\XINTdigits]}% \def\XINTinRandomFloatS{\romannumeral0\XINTinrandomfloatS}% \def\XINTinRandomFloatSdigits{\XINTinRandomFloatS[\XINTdigits]}% \def\XINTinrandomfloatS[#1]% @@ -3363,6 +3491,10 @@ \def\XINTinFloatLog#1{\XINTinFloatMul{\PoorManLogBaseTen{#1}}{23025850923[-10]}}% \def\xintExp#1{\PoorManPowerOfTen{\xintMul{#1}{434294481903[-12]}}}% \def\XINTinFloatExp#1{\PoorManPowerOfTen{\XINTinFloatMul{#1}{434294481903[-12]}}}% +\let\XINTinFloatMaxof\XINT_Maxof +\let\XINTinFloatMinof\XINT_Minof +\let\XINTinFloatSum\XINT_Sum +\let\XINTinFloatPrd\XINT_Prd \XINT_restorecatcodes_endinput% \endinput %% |