summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/xint/xintfrac.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-10-28 22:36:18 +0000
committerKarl Berry <karl@freefriends.org>2014-10-28 22:36:18 +0000
commit6751ea76abc2df59197ab3c20fe780ecf9de81fb (patch)
treef0ddbcd0525b27fc8755bec4c667f0a4b076b2a0 /Master/texmf-dist/tex/generic/xint/xintfrac.sty
parent1eff88f8256fc97ff44035cfd29e162947e4fd67 (diff)
xint (28oct14)
git-svn-id: svn://tug.org/texlive/trunk@35458 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.sty488
1 files changed, 255 insertions, 233 deletions
diff --git a/Master/texmf-dist/tex/generic/xint/xintfrac.sty b/Master/texmf-dist/tex/generic/xint/xintfrac.sty
index 09d75a2a9b3..1a92682ecc7 100644
--- a/Master/texmf-dist/tex/generic/xint/xintfrac.sty
+++ b/Master/texmf-dist/tex/generic/xint/xintfrac.sty
@@ -20,11 +20,11 @@
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
-%%----------------------------------------------------------------
-%% The xint bundle (version 1.09n of April 1st, 2014)
-%% xintfrac: Expandable operations on fractions
+%% ---------------------------------------------------------------
+%% The xint bundle v1.1 (2014/10/28)
%% Copyright (C) 2013-2014 by Jean-Francois Burnol
-%%----------------------------------------------------------------
+%% xintfrac: Expandable operations on fractions
+%% ---------------------------------------------------------------
\begingroup\catcode61\catcode48\catcode32=10\relax%
\catcode13=5 % ^^M
\endlinechar=13 %
@@ -36,7 +36,6 @@
\catcode45=12 % -
\catcode46=12 % .
\catcode58=12 % :
- \def\space { }%
\let\z\endgroup
\expandafter\let\expandafter\x\csname ver@xintfrac.sty\endcsname
\expandafter\let\expandafter\w\csname ver@xint.sty\endcsname
@@ -53,7 +52,6 @@
\else
\ifx\x\relax % plain-TeX, first loading of xintfrac.sty
\ifx\w\relax % but xint.sty not yet loaded.
- \y{xintfrac}{now issuing \string\input\space xint.sty}%
\def\z{\endgroup\input xint.sty\relax}%
\fi
\else
@@ -61,48 +59,26 @@
\ifx\x\empty % LaTeX, first loading,
% variable is initialized, but \ProvidesPackage not yet seen
\ifx\w\relax % xint.sty not yet loaded.
- \y{xintfrac}{now issuing \string\RequirePackage{xint}}%
\def\z{\endgroup\RequirePackage{xint}}%
\fi
\else
- \y{xintfrac}{I was already loaded, aborting input}%
- \aftergroup\endinput
+ \aftergroup\endinput % xintfrac already loaded.
\fi
\fi
\fi
\z%
-\begingroup\catcode61\catcode48\catcode32=10\relax%
- \catcode13=5 % ^^M
- \endlinechar=13 %
- \catcode123=1 % {
- \catcode125=2 % }
- \catcode64=11 % @
- \catcode35=6 % #
- \catcode44=12 % ,
- \catcode45=12 % -
- \catcode46=12 % .
- \catcode58=12 % :
- \ifdefined\PackageInfo
- \def\y#1#2{\PackageInfo{#1}{#2}}%
- \else
- \def\y#1#2{\immediate\write-1{Package #1 Info: #2.}}%
- \fi
- \def\empty {}%
- \expandafter\let\expandafter\w\csname ver@xint.sty\endcsname
- \ifx\w\relax % Plain TeX, user gave a file name at the prompt
- \y{xintfrac}{Loading of package xint failed, aborting input}%
- \aftergroup\endinput
- \fi
- \ifx\w\empty % LaTeX, user gave a file name at the prompt
- \y{xintfrac}{Loading of package xint failed, aborting input}%
- \aftergroup\endinput
- \fi
-\endgroup%
-\XINTsetupcatcodes%
+\XINTsetupcatcodes% defined in xintkernel.sty
\XINT_providespackage
\ProvidesPackage{xintfrac}%
- [2014/04/01 v1.09n Expandable operations on fractions (jfB)]%
+ [2014/10/28 v1.1 Expandable operations on fractions (jfB)]%
\chardef\xint_c_xviii 18
+\def\XINT_cntSgnFork #1%
+{%
+ \ifcase #1\expandafter\xint_secondofthree
+ \or\expandafter\xint_thirdofthree
+ \else\expandafter\xint_firstofthree
+ \fi
+}%
\def\xintLen {\romannumeral0\xintlen }%
\def\xintlen #1%
{%
@@ -435,11 +411,16 @@
\expandafter{\romannumeral0\xint_dsh {#3}{#1}}{#2}}%
\def\XINT_rawz_Bb #1#2{ #2/#1}%
\def\xintFloor {\romannumeral0\xintfloor }%
-\def\xintfloor #1{\expandafter\XINT_floor
- \romannumeral0\xintrawwithzeros {#1}.}%
-\def\XINT_floor #1/#2.{\xintiiquo {#1}{#2}}%
+\def\xintfloor #1% devrais-je faire \xintREZ?
+ {\expandafter\XINT_ifloor \romannumeral0\xintrawwithzeros {#1}./1[0]}%
+\def\xintiFloor {\romannumeral0\xintifloor }%
+\def\xintifloor #1%
+ {\expandafter\XINT_ifloor \romannumeral0\xintrawwithzeros {#1}.}%
+\def\XINT_ifloor #1/#2.{\xintiiquo {#1}{#2}}%
\def\xintCeil {\romannumeral0\xintceil }%
\def\xintceil #1{\xintiiopp {\xintFloor {\xintOpp{#1}}}}%
+\def\xintiCeil {\romannumeral0\xinticeil }%
+\def\xinticeil #1{\xintiiopp {\xintiFloor {\xintOpp{#1}}}}%
\def\xintNumerator {\romannumeral0\xintnumerator }%
\def\xintnumerator
{%
@@ -617,15 +598,6 @@
\expandafter\XINT_e_end\expandafter{\the\numexpr #1+#4}{#2}{#3}%
}%
\def\XINT_e_end #1#2#3{ #2/#3[#1]}%
-\def\xintfE {\romannumeral0\xintfe }%
-\def\xintfe #1%
-{%
- \expandafter\XINT_fe \romannumeral0\XINT_infrac {#1}%
-}%
-\def\XINT_fe #1#2#3#4%
-{%
- \expandafter\XINT_e_end\expandafter{\the\numexpr #1+\xintNum{#4}}{#2}{#3}%
-}%
\def\xintFloatE {\romannumeral0\xintfloate }%
\def\xintfloate #1{\XINT_floate_chkopt #1\xint_relax }%
\def\XINT_floate_chkopt #1%
@@ -650,27 +622,11 @@
\expandafter\xint_exchangetwo_keepbraces\expandafter
{\the\numexpr #2+#5}{#1}{#3}{#4}\XINT_float_Q
}%
-\def\XINTinFloatfE {\romannumeral0\XINTinfloatfe }%
-\def\XINTinfloatfe [#1]#2%
-{%
- \expandafter\XINT_infloatfe_a\expandafter
- {\the\numexpr #1\expandafter}\romannumeral0\XINT_infrac {#2}%
-}%
-\def\XINT_infloatfe_a #1#2#3#4#5%
-{%
- \expandafter\expandafter\expandafter\XINT_infloat_a
- \expandafter\xint_exchangetwo_keepbraces\expandafter
- {\the\numexpr #2+\xintNum{#5}}{#1}{#3}{#4}\XINT_infloat_Q
-}%
-\def\xintiE {\romannumeral0\xintie }% for \xintiiexpr only
-\def\xintie #1%
-{%
- \expandafter\XINT_ie \romannumeral0\XINT_infrac {#1}% allows 3.123e3
-}%
-\def\XINT_ie #1#2#3#4% assumes #3=1 and uses \xint_dsh with its \numexpr
-{%
- \xint_dsh {#2}{0-(#1+#4)}% could have \xintNum{#4} for a bit more general
-}%
+\def\XINTinFloatE {\romannumeral0\XINTinfloate }%
+\def\XINTinfloate {\expandafter\XINT_infloate\romannumeral0\XINTinfloat [\XINTdigits]}%
+\def\XINT_infloate #1[#2]#3%
+ {\expandafter\XINT_infloate_end\expandafter {\the\numexpr #3+#2}{#1}}%
+\def\XINT_infloate_end #1#2{ #2[#1]}%
\def\xintIrr {\romannumeral0\xintirr }%
\def\xintirr #1%
{%
@@ -729,18 +685,11 @@
\expandafter\XINT_irr_finish\expandafter {#2}{#1}%
}%
\def\XINT_irr_finish #1#2#3{#3#1/#2}% changed in 1.08
-\def\xintNum {\romannumeral0\xintnum }%
-\def\xintnum #1{\expandafter\XINT_intcheck\romannumeral0\xintirr {#1}\Z }%
-\edef\XINT_intcheck #1/#2\Z
+\def\xintifInt {\romannumeral0\xintifint }%
+\def\xintifint #1{\expandafter\XINT_ifint\romannumeral0\xintrawwithzeros {#1}.}%
+\def\XINT_ifint #1/#2.%
{%
- \noexpand\if 0\noexpand\XINT_isOne {#2}\noexpand\xintError:NotAnInteger
- \noexpand\fi\space #1%
-}%
-\def\xintifInt {\romannumeral0\xintifint }%
-\def\xintifint #1{\expandafter\XINT_ifint\romannumeral0\xintirr {#1}\Z }%
-\def\XINT_ifint #1/#2\Z
-{%
- \if\XINT_isOne {#2}1%
+ \if 0\xintiiRem {#1}{#2}%
\expandafter\xint_firstoftwo_thenstop
\else
\expandafter\xint_secondoftwo_thenstop
@@ -808,27 +757,22 @@
\XINT_irr_finish {#3}{#4}%
}%
\def\xintTFrac {\romannumeral0\xinttfrac }%
-\def\xinttfrac #1%
- {\expandafter\XINT_tfrac_fork\romannumeral0\xintrawwithzeros {#1}\Z }%
+\def\xinttfrac #1{\expandafter\XINT_tfrac_fork\romannumeral0\xintrawwithzeros {#1}\Z }%
\def\XINT_tfrac_fork #1%
{%
\xint_UDzerominusfork
#1-\XINT_tfrac_zero
- 0#1\XINT_tfrac_N
- 0-{\XINT_tfrac_P #1}%
+ 0#1{\xintiiopp\XINT_tfrac_P }%
+ 0-{\XINT_tfrac_P #1}%
\krof
}%
\def\XINT_tfrac_zero #1\Z { 0/1[0]}%
-\def\XINT_tfrac_N {\expandafter\XINT_opp\romannumeral0\XINT_tfrac_P }%
-\def\XINT_tfrac_P #1/#2\Z
-{%
- \expandafter\XINT_rez_AB\romannumeral0\xintiirem{#1}{#2}\Z {0}{#2}%
-}%
-\def\XINTinFloatFrac {\romannumeral0\XINTinfloatfrac }%
+\def\XINT_tfrac_P #1/#2\Z {\expandafter\XINT_rez_AB
+ \romannumeral0\xintiirem{#1}{#2}\Z {0}{#2}}%
+\def\XINTinFloatFrac {\romannumeral0\XINTinfloatfrac [\XINTdigits]}%
\def\XINTinfloatfrac [#1]#2%
{%
- \expandafter\XINT_infloatfrac_a\expandafter
- {\romannumeral0\xinttfrac{#2}}{#1}%
+ \expandafter\XINT_infloatfrac_a\expandafter {\romannumeral0\xinttfrac{#2}}{#1}%
}%
\def\XINT_infloatfrac_a #1#2{\XINTinFloat [#2]{#1}}%
\def\xintTrunc {\romannumeral0\xinttrunc }%
@@ -926,8 +870,18 @@
\def\XINT_trunc_Hb #1#2#3%
{%
\expandafter #3\expandafter0\expandafter.%
- \romannumeral0\XINT_dsx_zeroloop {#1}{}\Z {}#2% #1=-0 autoris^^e9 !
+ \romannumeral0\XINT_dsx_zeroloop {#1}{}\Z {}#2% #1=-0 autoris\'e !
}%
+\def\xintTTrunc {\romannumeral0\xintttrunc }%
+\def\xintttrunc #1%
+{%
+ \expandafter\XINT_itrunc_G
+ \romannumeral0\expandafter\XINT_ttrunc_A
+ \romannumeral0\XINT_infrac {#1}0% this last 0 to let \XINT_itrunc_G be happy
+}%
+\def\XINT_ttrunc_A #1#2#3{\XINT_trunc_checkifzero {#1}#2\Z {#3}}%
+\let\xintNum \xintTTrunc
+\let\xintnum \xintttrunc
\def\xintRound {\romannumeral0\xintround }%
\def\xintiRound {\romannumeral0\xintiround }%
\def\xintround #1%
@@ -1409,6 +1363,57 @@
{\the\numexpr #3+#4+\xint_c_i-#2}{#1}%
}%
\def\XINT_float_Y #1#2{ #2e#1}%
+\def\xintPFloat {\romannumeral0\xintpfloat }%
+\def\xintpfloat #1{\XINT_pfloat_chkopt #1\xint_relax }%
+\def\XINT_pfloat_chkopt #1%
+{%
+ \ifx [#1\expandafter\XINT_pfloat_opt
+ \else\expandafter\XINT_pfloat_noopt
+ \fi #1%
+}%
+\def\XINT_pfloat_noopt #1\xint_relax
+{%
+ \expandafter\XINT_pfloat_a\expandafter\XINTdigits
+ \romannumeral0\XINTinfloat [\XINTdigits]{#1}%
+}%
+\def\XINT_pfloat_opt [\xint_relax #1]%#2%
+{%
+ \expandafter\XINT_pfloat_a\expandafter {\the\numexpr #1\expandafter}%
+ \romannumeral0\XINTinfloat [\numexpr #1\relax]%{#2}%
+}%
+\def\XINT_pfloat_a #1#2%
+{%
+ \xint_UDzerominusfork
+ #2-\XINT_pfloat_zero
+ 0#2\XINT_pfloat_neg
+ 0-{\XINT_pfloat_pos #2}%
+ \krof {#1}%
+}%
+\def\XINT_pfloat_zero #1[#2]{ 0}%
+\def\XINT_pfloat_neg
+ {\expandafter\xint_minus_thenstop\romannumeral0\XINT_pfloat_pos {}}%
+\def\XINT_pfloat_pos #1#2#3[#4]%
+{%
+ \ifnum#4>0 \xint_dothis\XINT_pfloat_no\fi
+ \ifnum#4>\numexpr-#2\relax \xint_dothis\XINT_pfloat_b\fi
+ \ifnum#4>\numexpr-#2-\xint_c_v\relax \xint_dothis\XINT_pfloat_B\fi
+ \xint_orthat\XINT_pfloat_no {#2}{#4}{#1#3}%
+}%
+\def\XINT_pfloat_no #1#2%
+{%
+ \expandafter\XINT_pfloat_no_b\expandafter{\the\numexpr #2+#1-\xint_c_i\relax}%
+}%
+\def\XINT_pfloat_no_b #1#2{\XINT_pfloat_no_c #2e#1}%
+\def\XINT_pfloat_no_c #1{ #1.}%
+\def\XINT_pfloat_b #1#2#3%
+ {\expandafter\XINT_pfloat_c
+ \romannumeral0\expandafter\XINT_split_fromleft_loop
+ \expandafter {\the\numexpr #1+#2-\xint_c_i}#3\W\W\W\W\W\W\W\W\Z }%
+\def\XINT_pfloat_c #1#2{ #1.#2}% #2 peut ^^eatre vide
+\def\XINT_pfloat_B #1#2#3%
+ {\expandafter\XINT_pfloat_C
+ \romannumeral0\XINT_dsx_zeroloop {\numexpr -#1-#2}{}\Z {}#3}%
+\def\XINT_pfloat_C { 0.}%
\def\XINTinFloat {\romannumeral0\XINTinfloat }%
\def\XINTinfloat [#1]#2%
{%
@@ -1499,66 +1504,108 @@
}%
\def\XINT_infloat_X #1#2{ #2[#1]}%
\def\xintAdd {\romannumeral0\xintadd }%
-\def\xintadd #1%
+\def\xintadd #1{\expandafter\xint_fadd\romannumeral0\xintraw {#1}}%
+\def\xint_fadd #1{\xint_gob_til_zero #1\XINT_fadd_Azero 0\XINT_fadd_a #1}%
+\def\XINT_fadd_Azero #1]{\xintraw }%
+\def\XINT_fadd_a #1/#2[#3]#4%
+ {\expandafter\XINT_fadd_b\romannumeral0\xintraw {#4}{#3}{#1}{#2}}%
+\def\XINT_fadd_b #1{\xint_gob_til_zero #1\XINT_fadd_Bzero 0\XINT_fadd_c #1}%
+\def\XINT_fadd_Bzero #1]#2#3#4{ #3/#4[#2]}%
+\def\XINT_fadd_c #1/#2[#3]#4%
{%
- \expandafter\xint_fadd\expandafter {\romannumeral0\XINT_infrac {#1}}%
+ \expandafter\XINT_fadd_Aa\expandafter{\the\numexpr #4-#3}{#3}{#4}{#1}{#2}%
}%
-\def\xint_fadd #1#2{\expandafter\XINT_fadd_A\romannumeral0\XINT_infrac{#2}#1}%
-\def\XINT_fadd_A #1#2#3#4%
+\def\XINT_fadd_Aa #1%
{%
- \ifnum #4 > #1
- \xint_afterfi {\XINT_fadd_B {#1}}%
+ \ifcase\XINT_cntSgn #1\Z
+ \expandafter\XINT_fadd_B
+ \or
+ \expandafter \XINT_fadd_Ba
\else
- \xint_afterfi {\XINT_fadd_B {#4}}%
- \fi
- {#1}{#4}{#2}{#3}%
+ \expandafter \XINT_fadd_Bb
+ \fi {#1}%
}%
-\def\XINT_fadd_B #1#2#3#4#5#6#7%
+\def\XINT_fadd_B #1#2#3#4#5#6#7{\XINT_fadd_C {#4}{#5}{#7}{#6}[#3]}%
+\def\XINT_fadd_Ba #1#2#3#4#5#6#7%
{%
\expandafter\XINT_fadd_C\expandafter
- {\romannumeral0\xintiimul {#7}{#5}}%
- {\romannumeral0\xintiiadd
- {\romannumeral0\xintiimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}%
- {\romannumeral0\xintiimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}%
- }%
- {#1}%
+ {\romannumeral0\XINT_dsx_zeroloop {#1}{}\Z {#6}}%
+ {#7}{#5}{#4}[#2]%
+}%
+\def\XINT_fadd_Bb #1#2#3#4#5#6#7%
+{%
+ \expandafter\XINT_fadd_C\expandafter
+ {\romannumeral0\XINT_dsx_zeroloop {-#1}{}\Z {#4}}%
+ {#5}{#7}{#6}[#3]%
}%
\def\XINT_fadd_C #1#2#3%
{%
- \expandafter\XINT_fadd_D\expandafter {#2}{#3}{#1}%
+ \ifcase\romannumeral0\XINT_cmp_pre {#2}{#3} %<- intentional space here.
+ \expandafter\XINT_fadd_eq
+ \or\expandafter\XINT_fadd_D
+ \else\expandafter\XINT_fadd_Da
+ \fi {#2}{#3}{#1}%
}%
-\def\XINT_fadd_D #1#2{\XINT_outfrac {#2}{#1}}%
-\def\xintSub {\romannumeral0\xintsub }%
-\def\xintsub #1%
+\def\XINT_fadd_eq #1#2#3#4%#5%
{%
- \expandafter\xint_fsub\expandafter {\romannumeral0\XINT_infrac {#1}}%
+ \expandafter\XINT_fadd_G
+ \romannumeral0\xintiiadd {#3}{#4}/#1%[#5]%
}%
-\def\xint_fsub #1#2%
- {\expandafter\XINT_fsub_A\romannumeral0\XINT_infrac {#2}#1}%
-\def\XINT_fsub_A #1#2#3#4%
+\def\XINT_fadd_D #1#2%
{%
- \ifnum #4 > #1
- \xint_afterfi {\XINT_fsub_B {#1}}%
- \else
- \xint_afterfi {\XINT_fsub_B {#4}}%
- \fi
- {#1}{#4}{#2}{#3}%
+ \expandafter\XINT_fadd_E\romannumeral0\XINT_div_prepare {#2}{#1}{#1}{#2}%
}%
-\def\XINT_fsub_B #1#2#3#4#5#6#7%
+\def\XINT_fadd_E #1#2%
{%
- \expandafter\XINT_fsub_C\expandafter
- {\romannumeral0\xintiimul {#7}{#5}}%
- {\romannumeral0\xintiisub
- {\romannumeral0\xintiimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}%
- {\romannumeral0\xintiimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}%
- }%
- {#1}%
+ \if0\XINT_Sgn #2\Z
+ \expandafter\XINT_fadd_F
+ \else\expandafter\XINT_fadd_K
+ \fi {#1}%
+}%
+\def\XINT_fadd_F #1#2#3#4#5%#6%
+{%
+ \expandafter\XINT_fadd_G
+ \romannumeral0\xintiiadd {\xintiiMul {#5}{#1}}{#4}/#2%[#6]%
+}%
+\def\XINT_fadd_Da #1#2%
+{%
+ \expandafter\XINT_fadd_Ea\romannumeral0\XINT_div_prepare {#1}{#2}{#1}{#2}%
+}%
+\def\XINT_fadd_Ea #1#2%
+{%
+ \if0\XINT_Sgn #2\Z
+ \expandafter\XINT_fadd_Fa
+ \else\expandafter\XINT_fadd_K
+ \fi {#1}%
+}%
+\def\XINT_fadd_Fa #1#2#3#4#5%#6%
+{%
+ \expandafter\XINT_fadd_G
+ \romannumeral0\xintiiadd {\xintiiMul {#4}{#1}}{#5}/#3%[#6]%
}%
-\def\XINT_fsub_C #1#2#3%
+\def\XINT_fadd_G #1{\if0#1\XINT_fadd_iszero\fi\space #1}%
+\def\XINT_fadd_K #1#2#3#4#5%
{%
- \expandafter\XINT_fsub_D\expandafter {#2}{#3}{#1}%
+ \expandafter\XINT_fadd_L
+ \romannumeral0\xintiiadd {\xintiiMul {#2}{#5}}{\xintiiMul {#3}{#4}}.%
+ {{#2}{#3}}%
}%
-\def\XINT_fsub_D #1#2{\XINT_outfrac {#2}{#1}}%
+\def\XINT_fadd_L #1{\if0#1\XINT_fadd_iszero\fi \XINT_fadd_M #1}%
+\def\XINT_fadd_M #1.#2{\expandafter\XINT_fadd_N \expandafter
+ {\romannumeral0\xintiimul #2}{#1}}%
+\def\XINT_fadd_N #1#2{ #2/#1}%
+\edef\XINT_fadd_iszero\fi #1[#2]{\noexpand\fi\space 0/1[0]}% ou [#2] originel?
+\def\xintSub {\romannumeral0\xintsub }%
+\def\xintsub #1{\expandafter\xint_fsub\romannumeral0\xintraw {#1}}%
+\def\xint_fsub #1{\xint_gob_til_zero #1\XINT_fsub_Azero 0\XINT_fsub_a #1}%
+\def\XINT_fsub_Azero #1]{\xintopp }%
+\def\XINT_fsub_a #1/#2[#3]#4%
+ {\expandafter\XINT_fsub_b\romannumeral0\xintraw {#4}{#3}{#1}{#2}}%
+\def\XINT_fsub_b #1{\xint_UDzerominusfork
+ #1-\XINT_fadd_Bzero
+ 0#1\XINT_fadd_c
+ 0-{\XINT_fadd_c -#1}%
+ \krof }%
\def\xintSum {\romannumeral0\xintsum }%
\def\xintsum #1{\xintsumexpr #1\relax }%
\def\xintSumExpr {\romannumeral0\xintsumexpr }%
@@ -1579,30 +1626,36 @@
}%
\def\XINT_fsum_finished #1\Z #2{ #2}%
\def\xintMul {\romannumeral0\xintmul }%
-\def\xintmul #1%
+\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}%
+\def\XINT_fmul_a #1[#2].#3%
+ {\expandafter\XINT_fmul_b\romannumeral0\xintraw {#3}#1[#2.]}%
+\def\XINT_fmul_b #1{\xint_gob_til_zero #1\XINT_fmul_zero 0\XINT_fmul_c #1}%
+\def\XINT_fmul_c #1/#2[#3]#4/#5[#6.]%
{%
- \expandafter\xint_fmul\expandafter {\romannumeral0\XINT_infrac {#1}}%
+ \expandafter\XINT_fmul_d
+ \expandafter{\the\numexpr #3+#6\expandafter}%
+ \expandafter{\romannumeral0\xintiimul {#5}{#2}}%
+ {\romannumeral0\xintiimul {#4}{#1}}%
}%
-\def\xint_fmul #1#2%
- {\expandafter\XINT_fmul_A\romannumeral0\XINT_infrac {#2}#1}%
-\def\XINT_fmul_A #1#2#3#4#5#6%
+\def\XINT_fmul_d #1#2#3%
{%
- \expandafter\XINT_fmul_B
- \expandafter{\the\numexpr #1+#4\expandafter}%
- \expandafter{\romannumeral0\xintiimul {#6}{#3}}%
- {\romannumeral0\xintiimul {#5}{#2}}%
+ \expandafter \XINT_fmul_e \expandafter{#3}{#1}{#2}%
}%
-\def\XINT_fmul_B #1#2#3%
-{%
- \expandafter \XINT_fmul_C \expandafter{#3}{#1}{#2}%
-}%
-\def\XINT_fmul_C #1#2{\XINT_outfrac {#2}{#1}}%
+\def\XINT_fmul_e #1#2{\XINT_outfrac {#2}{#1}}%
+\def\XINT_fmul_zero #1.#2{ 0/1[0]}%
\def\xintSqr {\romannumeral0\xintsqr }%
-\def\xintsqr #1%
+\def\xintsqr #1{\expandafter\xint_fsqr\romannumeral0\xintraw {#1}}%
+\def\xint_fsqr #1{\xint_gob_til_zero #1\XINT_fsqr_zero 0\XINT_fsqr_a #1}%
+\def\xint_fsqr_a #1/#2[#3]%
{%
- \expandafter\xint_fsqr\expandafter{\romannumeral0\XINT_infrac {#1}}%
+ \expandafter\XINT_fsqr_b
+ \expandafter{\the\numexpr #3+#3\expandafter}%
+ \expandafter{\romannumeral0\xintiisqr {#2}}%
+ {\romannumeral0\xintiisqr {#1}}%
}%
-\def\xint_fsqr #1{\XINT_fmul_A #1#1}%
+\def\XINT_fsqr_b #1#2#3{\expandafter \XINT_fmul_e \expandafter{#3}{#1}{#2}}%
+\def\XINT_fsqr_zero #1]{ 0/1[0]}%
\def\xintPow {\romannumeral0\xintpow }%
\def\xintpow #1%
{%
@@ -1685,7 +1738,55 @@
\expandafter{#3}{#1}{#2}%
}%
\def\XINT_fdiv_C #1#2{\XINT_outfrac {#2}{#1}}%
-\def\xintIsOne {\romannumeral0\xintisone }%
+\def\xintDivFloor {\romannumeral0\xintdivfloor }%
+\def\xintdivfloor #1#2{\xintfloor{\xintDiv {#1}{#2}}}%
+\def\xintDivTrunc {\romannumeral0\xintdivtrunc }%
+\def\xintdivtrunc #1#2{\xintitrunc 0{\xintDiv {#1}{#2}}}%
+\def\xintDivRound {\romannumeral0\xintdivround }%
+\def\xintdivround #1#2{\xintiround 0{\xintDiv {#1}{#2}}}%
+\def\xintMod {\romannumeral0\xintmod }%
+\def\xintmod #1{\expandafter\XINT_mod_a\romannumeral0\xintraw{#1}.}%
+\def\XINT_mod_a #1#2.#3%
+ {\expandafter\XINT_mod_b\expandafter #1\romannumeral0\xintraw{#3}#2.}%
+\def\XINT_mod_b #1#2% #1 de A, #2 de B.
+{%
+ \if0#2\xint_dothis\XINT_mod_divbyzero\fi
+ \if0#1\xint_dothis\XINT_mod_aiszero\fi
+ \if-#2\xint_dothis{\XINT_mod_bneg #1}\fi
+ \xint_orthat{\XINT_mod_bpos #1#2}%
+}%
+\def\XINT_mod_bpos #1%
+{%
+ \xint_UDsignfork
+ #1{\xintiiopp\XINT_mod_pos {}}%
+ -{\XINT_mod_pos #1}%
+ \krof
+}%
+\def\XINT_mod_bneg #1%
+{%
+ \xint_UDsignfork
+ #1{\xintiiopp\XINT_mod_pos {}}%
+ -{\XINT_mod_pos #1}%
+ \krof
+}%
+\def\XINT_mod_divbyzero #1.{\xintError:DivisionByZero\space 0/1[0]}%
+\def\XINT_mod_aiszero #1.{ 0/1[0]}%
+\def\XINT_mod_pos #1#2/#3[#4]#5/#6[#7].%
+{%
+ \expandafter\XINT_mod_pos_a
+ \the\numexpr\ifnum#7>#4 #4\else #7\fi\expandafter.\expandafter
+ {\romannumeral0\xintiimul {#6}{#3}}% n fois u
+ {\xintiiE{\xintiiMul {#1#5}{#3}}{#7-#4}}% m fois u
+ {\xintiiE{\xintiiMul {#2}{#6}}{#4-#7}}% t fois n
+}%
+\def\XINT_mod_pos_a #1.#2#3#4{\xintiirem {#3}{#4}/#2[#1]}%
+\def\XINTinFloatMod {\romannumeral0\XINTinfloatmod [\XINTdigits]}%
+\def\XINTinfloatmod [#1]#2#3{\expandafter\XINT_infloatmod\expandafter
+ {\romannumeral0\XINTinfloat[#1]{#2}}%
+ {\romannumeral0\XINTinfloat[#1]{#3}}{#1}}%
+\def\XINT_infloatmod #1#2{\expandafter\XINT_infloatmod_a\expandafter {#2}{#1}}%
+\def\XINT_infloatmod_a #1#2#3{\XINTinfloat [#3]{\xintMod {#2}{#1}}}%
+\def\xintIsOne {\romannumeral0\xintisone }%
\def\xintisone #1{\expandafter\XINT_fracisone
\romannumeral0\xintrawwithzeros{#1}\Z }%
\def\XINT_fracisone #1/#2\Z
@@ -1831,7 +1932,6 @@
\def\XINT_minof_d #1\Z
{\expandafter\XINT_minof_b\romannumeral0\xintmin {#1}}%
\def\XINT_minof_e #1\Z #2\Z { #2}%
-\def\xintCmp {\romannumeral0\xintcmp }%
\def\xintcmp #1%
{%
\expandafter\xint_fcmp\expandafter {\romannumeral0\xintraw {#1}}%
@@ -2514,84 +2614,6 @@
{\expandafter\XINT_flminof_b\romannumeral0\xintmin
{\XINTinFloat [\XINTdigits]{#1}}}%
\def\XINT_flminof_e #1\Z #2\Z { #2}%
-\def\xintRound:csv #1{\expandafter\XINT_round:_a\romannumeral-`0#1,,^}%
-\def\XINT_round:_a {\XINT_round:_b {}}%
-\def\XINT_round:_b #1#2,%
- {\expandafter\XINT_round:_c\romannumeral-`0#2,{#1}}%
-\def\XINT_round:_c #1{\if #1,\expandafter\XINT_:_f
- \else\expandafter\XINT_round:_d\fi #1}%
-\def\XINT_round:_d #1,%
- {\expandafter\XINT_round:_e\romannumeral0\xintiround 0{#1},}%
-\def\XINT_round:_e #1,#2{\XINT_round:_b {#2,#1}}%
-\def\xintFloat:csv #1{\expandafter\XINT_float:_a\romannumeral-`0#1,,^}%
-\def\XINT_float:_a {\XINT_float:_b {}}%
-\def\XINT_float:_b #1#2,%
- {\expandafter\XINT_float:_c\romannumeral-`0#2,{#1}}%
-\def\XINT_float:_c #1{\if #1,\expandafter\XINT_:_f
- \else\expandafter\XINT_float:_d\fi #1}%
-\def\XINT_float:_d #1,%
- {\expandafter\XINT_float:_e\romannumeral0\xintfloat {#1},}%
-\def\XINT_float:_e #1,#2{\XINT_float:_b {#2,#1}}%
-\def\xintSum:csv #1{\expandafter\XINT_sum:_a\romannumeral-`0#1,,^}%
-\def\XINT_sum:_a {\XINT_sum:_b {0/1[0]}}%
-\def\XINT_sum:_b #1#2,{\expandafter\XINT_sum:_c\romannumeral-`0#2,{#1}}%
-\def\XINT_sum:_c #1{\if #1,\expandafter\XINT_:_e
- \else\expandafter\XINT_sum:_d\fi #1}%
-\def\XINT_sum:_d #1,#2{\expandafter\XINT_sum:_b\expandafter
- {\romannumeral0\xintadd {#2}{#1}}}%
-\def\xintPrd:csv #1{\expandafter\XINT_prd:_a\romannumeral-`0#1,,^}%
-\def\XINT_prd:_a {\XINT_prd:_b {1/1[0]}}%
-\def\XINT_prd:_b #1#2,{\expandafter\XINT_prd:_c\romannumeral-`0#2,{#1}}%
-\def\XINT_prd:_c #1{\if #1,\expandafter\XINT_:_e
- \else\expandafter\XINT_prd:_d\fi #1}%
-\def\XINT_prd:_d #1,#2{\expandafter\XINT_prd:_b\expandafter
- {\romannumeral0\xintmul {#2}{#1}}}%
-\def\xintMaxof:csv #1{\expandafter\XINT_maxof:_b\romannumeral-`0#1,,}%
-\def\XINT_maxof:_b #1,#2,{\expandafter\XINT_maxof:_c\romannumeral-`0#2,{#1},}%
-\def\XINT_maxof:_c #1{\if #1,\expandafter\XINT_of:_e
- \else\expandafter\XINT_maxof:_d\fi #1}%
-\def\XINT_maxof:_d #1,{\expandafter\XINT_maxof:_b\romannumeral0\xintmax {#1}}%
-\def\xintMinof:csv #1{\expandafter\XINT_minof:_b\romannumeral-`0#1,,}%
-\def\XINT_minof:_b #1,#2,{\expandafter\XINT_minof:_c\romannumeral-`0#2,{#1},}%
-\def\XINT_minof:_c #1{\if #1,\expandafter\XINT_of:_e
- \else\expandafter\XINT_minof:_d\fi #1}%
-\def\XINT_minof:_d #1,{\expandafter\XINT_minof:_b\romannumeral0\xintmin {#1}}%
-\def\XINTinFloatMinof:csv #1{\expandafter\XINT_flminof:_a\romannumeral-`0#1,,}%
-\def\XINT_flminof:_a #1,{\expandafter\XINT_flminof:_b
- \romannumeral0\XINTinfloat [\XINTdigits]{#1},}%
-\def\XINT_flminof:_b #1,#2,%
- {\expandafter\XINT_flminof:_c\romannumeral-`0#2,{#1},}%
-\def\XINT_flminof:_c #1{\if #1,\expandafter\XINT_of:_e
- \else\expandafter\XINT_flminof:_d\fi #1}%
-\def\XINT_flminof:_d #1,%
- {\expandafter\XINT_flminof:_b\romannumeral0\xintmin
- {\XINTinFloat [\XINTdigits]{#1}}}%
-\def\XINTinFloatMaxof:csv #1{\expandafter\XINT_flmaxof:_a\romannumeral-`0#1,,}%
-\def\XINT_flmaxof:_a #1,{\expandafter\XINT_flmaxof:_b
- \romannumeral0\XINTinfloat [\XINTdigits]{#1},}%
-\def\XINT_flmaxof:_b #1,#2,%
- {\expandafter\XINT_flmaxof:_c\romannumeral-`0#2,{#1},}%
-\def\XINT_flmaxof:_c #1{\if #1,\expandafter\XINT_of:_e
- \else\expandafter\XINT_flmaxof:_d\fi #1}%
-\def\XINT_flmaxof:_d #1,%
- {\expandafter\XINT_flmaxof:_b\romannumeral0\xintmax
- {\XINTinFloat [\XINTdigits]{#1}}}%
-\def\XINTinFloatSum:csv #1{\expandafter\XINT_floatsum:_a\romannumeral-`0#1,,^}%
-\def\XINT_floatsum:_a {\XINT_floatsum:_b {0[0]}}%
-\def\XINT_floatsum:_b #1#2,%
- {\expandafter\XINT_floatsum:_c\romannumeral-`0#2,{#1}}%
-\def\XINT_floatsum:_c #1{\if #1,\expandafter\XINT_:_e
- \else\expandafter\XINT_floatsum:_d\fi #1}%
-\def\XINT_floatsum:_d #1,#2{\expandafter\XINT_floatsum:_b\expandafter
- {\romannumeral0\XINTinfloatadd {#2}{#1}}}%
-\def\XINTinFloatPred:csv #1{\expandafter\XINT_floatprd:_a\romannumeral-`0#1,,^}%
-\def\XINT_floatprd:_a {\XINT_floatprd:_b {1[0]}}%
-\def\XINT_floatprd:_b #1#2,%
- {\expandafter\XINT_floatprd:_c\romannumeral-`0#2,{#1}}%
-\def\XINT_floatprd:_c #1{\if #1,\expandafter\XINT_:_e
- \else\expandafter\XINT_floatprd:_d\fi #1}%
-\def\XINT_floatprd:_d #1,#2{\expandafter\XINT_floatprd:_b\expandafter
- {\romannumeral0\XINTinfloatmul {#2}{#1}}}%
\XINT_restorecatcodes_endinput%
\endinput
%%