diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/xint/xint.sty')
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xint.sty | 171 |
1 files changed, 114 insertions, 57 deletions
diff --git a/Master/texmf-dist/tex/generic/xint/xint.sty b/Master/texmf-dist/tex/generic/xint/xint.sty index e121c9bcffb..279468d168d 100644 --- a/Master/texmf-dist/tex/generic/xint/xint.sty +++ b/Master/texmf-dist/tex/generic/xint/xint.sty @@ -22,7 +22,7 @@ %% in the same archive or directory.) %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.03 of April 14, 2013) +%% The xint bundle (version 1.04 of April 25, 2013) %% xint: Expandable operations on long numbers %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -134,7 +134,7 @@ \fi \expandafter\x\csname ver@xint.sty\endcsname \ProvidesPackage{xint}% - [2013/04/14 v1.03 Expandable operations on long numbers (jfB)]% + [2013/04/25 v1.04 Expandable operations on long numbers (jfB)]% \def\xint@gobble #1{}% \def\xint@gobble@one #1{}% \def\xint@gobble@two #1#2{}% @@ -256,10 +256,9 @@ {% \the\numexpr #1#2#3#4\relax }% -\def\XINT@Rev@andcleanupzeros #1% +\def\XINT@rev@andcuz #1% {% - \romannumeral0\expandafter - \xint@cleanupzeros@andstop + \expandafter\xint@cleanupzeros@andstop \romannumeral0\XINT@rord@main {}#1% \xint@UNDEF \xint@undef\xint@undef\xint@undef\xint@undef @@ -505,6 +504,55 @@ }% }% \let\xintDigitsOf\xintAssignArray +\def\xintApply {\romannumeral0\xintapply }% +\def\xintapply #1#2% +{% + \expandafter\expandafter\expandafter + \XINT@apply + \expandafter\expandafter\expandafter + {#2}{#1}% +}% +\def\XINT@apply #1#2% +{% + \XINT@apply@loop@a {}{#2}#1\Z +}% +\def\XINT@apply@loop@a #1#2#3% +{% + \xint@z #3\XINT@apply@end\Z + \expandafter\expandafter\expandafter + \XINT@apply@loop@b + \expandafter\expandafter\expandafter {#2{#3}}{#1}{#2}% +}% +\def\XINT@apply@loop@b #1#2{\XINT@apply@loop@a {#2{#1}}}% +\def\XINT@apply@end\Z + \expandafter\expandafter\expandafter + \XINT@apply@loop@b + \expandafter\expandafter\expandafter #1#2#3{ #2}% +\def\xintListWithSep {\romannumeral0\xintlistwithsep }% +\long\def\xintlistwithsep #1#2% +{% + \expandafter\expandafter\expandafter + \XINT@lws + \expandafter\expandafter\expandafter + {#2}{#1}% +}% +\long\def\XINT@lws #1#2% +{% + \XINT@lws@start {#2}#1\Z +}% +\long\def\XINT@lws@start #1#2% +{% + \xint@z #2\XINT@lws@dont\Z + \XINT@lws@loop@a {#2}{#1}% +}% +\long\def\XINT@lws@dont\Z\XINT@lws@loop@a #1#2{ #2}% +\long\def\XINT@lws@loop@a #1#2#3% +{% + \xint@z #3\XINT@lws@end\Z + \XINT@lws@loop@b {#1}{#2#3}{#2}% +}% +\long\def\XINT@lws@loop@b #1#2{\XINT@lws@loop@a {#1#2}}% +\long\def\XINT@lws@end\Z\XINT@lws@loop@b #1#2#3{ #1}% \def\xintiSgn {\romannumeral0\xintisgn }% \def\xintisgn #1% {% @@ -752,8 +800,7 @@ }% \def\xint@addm@cz\W\XINT@addm@CD #1#2#3{\XINT@addm@end #1#3}% \def\XINT@addm@end #1#2#3#4#5% -{\expandafter\space\the\numexpr #1#2#3#4#5\relax -}% + {\expandafter\space\the\numexpr #1#2#3#4#5\relax }% \def\XINT@addp@A #1#2#3#4#5#6% {% \xint@w @@ -1115,7 +1162,7 @@ }% \def\XINT@sub@Eonestep #1#2% {\expandafter - \XINT@sub@backtoE\the\numexpr 110000-#2+#1-1\relax.% + \XINT@sub@backtoE\the\numexpr 109999-#2+#1\relax.% }% \def\XINT@sub@backtoE #1#2#3.#4% {% @@ -1533,18 +1580,22 @@ \def\XINT@sumexpr {\XINT@sum@loop {0000}{0000}}% \def\XINT@sum@loop #1#2#3% {% - \xint@relax #3\XINT@sum@finished\relax \expandafter\expandafter\expandafter \XINT@sum@checksign #3\Z {#1}{#2}% }% \def\XINT@sum@checksign #1% {% + \xint@relax #1\XINT@sum@finished\relax \xint@zero #1\XINT@sum@skipzeroinput0% \xint@UDsignfork #1\dummy \XINT@sum@N -\dummy {\XINT@sum@P #1}% \xint@UDkrof }% +\def\XINT@sum@finished #1\Z #2#3% +{% + \XINT@sub@A 1{}#3\W\X\Y\Z #2\W\X\Y\Z +}% \def\XINT@sum@skipzeroinput #1\xint@UDkrof #2\Z {\XINT@sum@loop }% \def\XINT@sum@P #1\Z #2% {% @@ -1563,10 +1614,6 @@ \W\X\Y\Z #3\W\X\Y\Z }{#2}% }% \def\XINT@sum@NN #1#2{\XINT@sum@loop {#2}{#1}}% -\def\XINT@sum@finished #1\Z #2#3% -{% - \XINT@sub@A 1{}#3\W\X\Y\Z #2\W\X\Y\Z -}% \def\xintiMul {\romannumeral0\xintimul }% \def\xintimul #1% {% @@ -2010,18 +2057,22 @@ }% \let\xintProductExpr\xintiProductExpr \let\xintproductexpr\xintiproductexpr -\def\XINT@productexpr {\XINT@prod@loop {1}}% -\def\XINT@prod@loop #1#2% +\def\XINT@productexpr {\XINT@prod@loop@a 1\Z }% +\def\XINT@prod@loop@a #1\Z #2% +{% + \expandafter\expandafter\expandafter + \XINT@prod@loop@b #2\Z #1\Z \Z +}% +\def\XINT@prod@loop@b #1% {% - \xint@relax #2\XINT@prod@finished\relax - \expandafter\XINT@prod@loop\expandafter - {\romannumeral0\xintimul {#2}{#1}}% + \xint@relax #1\XINT@prod@finished\relax + \XINT@prod@loop@c #1% }% -\def\XINT@prod@finished #1#2#3#4#5% +\def\XINT@prod@loop@c {% - \XINT@prod@finished@ #5% + \expandafter\XINT@prod@loop@a\romannumeral0\XINT@mul@fork }% -\def\XINT@prod@finished@ #1#2#3#4#5{ #5}% +\def\XINT@prod@finished #1\Z #2\Z \Z { #2}% \def\xintFac {\romannumeral0\xintfac }% \def\xintfac #1% {% @@ -2307,10 +2358,9 @@ \expandafter\XINT@div@BisNegative@post \romannumeral0\XINT@div@fork #1\Z #4#2\Z }% -\def\XINT@div@BisNegative@post #1#2% +\def\XINT@div@BisNegative@post #1% {% - \expandafter\space\expandafter - {\romannumeral0\XINT@opp #1}{#2}% + \expandafter\space\expandafter {\romannumeral0\XINT@opp #1}% }% \def\XINT@div@AisNegative #1#2#3#4% {% @@ -2328,13 +2378,12 @@ }% \def\XINT@div@AisNegative@zerorem #1#2#3% {% - \expandafter\space\expandafter - {\romannumeral0\XINT@opp #1}{0}% + \expandafter\space\expandafter {\romannumeral0\XINT@opp #1}{0}% }% \def\XINT@div@AisNegative@posrem #1% {% \expandafter \XINT@div@AisNegative@posrem@b \expandafter - {\romannumeral0\xintiopp {\XINT@Add{#1}{1}}}% + {\romannumeral0\xintiopp{\xintiAdd {#1}{1}}}% }% \def\XINT@div@AisNegative@posrem@b #1#2#3% {% @@ -2463,9 +2512,8 @@ }% \def\XINT@div@finished@c #1#2% {% - \expandafter \space \expandafter - {\romannumeral0\expandafter\xint@cleanupzeros@andstop - \romannumeral0\XINT@rev {#2}}{#1}% + \expandafter\space\expandafter + {\romannumeral0\XINT@rev@andcuz {#2}}{#1}% }% \def\XINT@div@final@a #1% {% @@ -2479,45 +2527,54 @@ \def\xint@div@final@c0000\XINT@div@final@c #1{\XINT@div@finished@a }% \def\XINT@div@final@c #1#2#3#4% {% - \expandafter \XINT@div@final@d \expandafter - {\the\numexpr #1/#4\relax}{#2}% -}% -\def\XINT@div@final@d #1#2#3#4#5% q,A,Q,L,B puis c -{% \expandafter \XINT@div@final@da \expandafter - {\romannumeral0\XINT@mul@M {#1}#5\Z\Z\Z\Z }% + {\the\numexpr #1-(#1/#4)*#4\expandafter }\expandafter + {\the\numexpr #1/#4\expandafter }\expandafter {\romannumeral0\xint@cleanupzeros@andstop #2}% - {#1}{#3}{#5}% }% -\def\XINT@div@final@da #1#2% +\def\XINT@div@final@da #1% {% - \expandafter\XINT@div@final@db\expandafter {#2}{#1}% + \ifnum #1>9 + \expandafter\XINT@div@final@dP + \else + \xint@afterfi + {\ifnum #1<0 + \expandafter\XINT@div@final@dN + \else + \expandafter\XINT@div@final@db + \fi }% + \fi }% -\def\XINT@div@final@db #1#2% A,qB, puis q,Q,B,c +\def\XINT@div@final@dN #1% {% - \ifcase\XINT@Geq {#1}{#2} - \expandafter\XINT@div@final@dc % A < qB - \or\expandafter\XINT@div@final@e % A au moins qB - \fi - {#1}{#2}% + \expandafter\XINT@div@final@dP\the\numexpr #1-1\relax }% -\def\XINT@div@final@e #1#2#3#4#5% A,qB,q,Q,B,puis c +\def\XINT@div@final@dP #1#2#3#4#5% q,A,Q,L,B (puis c) {% - \expandafter\XINT@div@final@f - \expandafter{\romannumeral0\xintisub {#1}{#2}}% - {\romannumeral0\xintiadd {\XINT@Rev@andcleanupzeros{#4}}{#3}}% + \expandafter \XINT@div@final@f \expandafter + {\romannumeral0\xintisub {#2}% + {\romannumeral0\XINT@mul@M {#1}#5\Z\Z\Z\Z }}% + {\romannumeral0\XINT@add@A 0{}#1000\W\X\Y\Z #3\W\X\Y\Z }% }% -\def\XINT@div@final@dc #1#2#3% A sans leading zeros,trash,q,Q,B,c +\def\XINT@div@final@db #1#2#3#4#5% q,A,Q,L,B (puis c) {% - \expandafter\XINT@div@final@dd - \expandafter{\the\numexpr #3-1\relax}{#1}% + \expandafter\XINT@div@final@dc\expandafter + {\romannumeral0\xintisub {#2}% + {\romannumeral0\XINT@mul@M {#1}#5\Z\Z\Z\Z }}% + {#1}{#2}{#3}{#4}{#5}% +}% +\def\XINT@div@final@dc #1#2% +{% + \ifnum\XINT@Sgn{#1}<0 + \xint@afterfi {\expandafter\XINT@div@final@dP + \the\numexpr #2-1\relax }% + \else \xint@afterfi {\XINT@div@final@e {#1}#2}% + \fi }% -\def\XINT@div@final@dd #1#2#3#4% q,A,Q,B puis c +\def\XINT@div@final@e #1#2#3#4#5#6% A final, q, trash, Q, L, B {% - \expandafter\XINT@div@final@f - \expandafter{\romannumeral0\xintisub - {#2}{\romannumeral0\XINT@mul@M {#1}#4\Z\Z\Z\Z }}% - {\romannumeral0\xintiadd {\XINT@Rev@andcleanupzeros{#3}}{#1}}% + \XINT@div@final@f {#1}% + {\romannumeral0\XINT@add@A 0{}#2000\W\X\Y\Z #4\W\X\Y\Z }% }% \def\XINT@div@final@f #1#2#3% R,Q à développer,c {% |