summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/oberdiek/bigintcalc.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/oberdiek/bigintcalc.sty')
-rw-r--r--Master/texmf-dist/tex/generic/oberdiek/bigintcalc.sty1831
1 files changed, 0 insertions, 1831 deletions
diff --git a/Master/texmf-dist/tex/generic/oberdiek/bigintcalc.sty b/Master/texmf-dist/tex/generic/oberdiek/bigintcalc.sty
deleted file mode 100644
index 0638702a1ec..00000000000
--- a/Master/texmf-dist/tex/generic/oberdiek/bigintcalc.sty
+++ /dev/null
@@ -1,1831 +0,0 @@
-%%
-%% This is file `bigintcalc.sty',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% bigintcalc.dtx (with options: `package')
-%%
-%% This is a generated file.
-%%
-%% Project: bigintcalc
-%% Version: 2016/05/16 v1.4
-%%
-%% Copyright (C)
-%% 2007, 2011, 2012 Heiko Oberdiek
-%% 2016-2019 Oberdiek Package Support Group
-%%
-%% This work may be distributed and/or modified under the
-%% conditions of the LaTeX Project Public License, either
-%% version 1.3c of this license or (at your option) any later
-%% version. This version of this license is in
-%% https://www.latex-project.org/lppl/lppl-1-3c.txt
-%% and the latest version of this license is in
-%% https://www.latex-project.org/lppl.txt
-%% and version 1.3 or later is part of all distributions of
-%% LaTeX version 2005/12/01 or later.
-%%
-%% This work has the LPPL maintenance status "maintained".
-%%
-%% The Current Maintainers of this work are
-%% Heiko Oberdiek and the Oberdiek Package Support Group
-%% https://github.com/ho-tex/oberdiek/issues
-%%
-%%
-%% The Base Interpreter refers to any `TeX-Format',
-%% because some files are installed in TDS:tex/generic//.
-%%
-%% This work consists of the main source file bigintcalc.dtx
-%% and the derived files
-%% bigintcalc.sty, bigintcalc.pdf, bigintcalc.ins, bigintcalc.drv,
-%% bigintcalc-test1.tex, bigintcalc-test2.tex,
-%% bigintcalc-test3.tex.
-%%
-\begingroup\catcode61\catcode48\catcode32=10\relax%
- \catcode13=5 % ^^M
- \endlinechar=13 %
- \catcode35=6 % #
- \catcode39=12 % '
- \catcode44=12 % ,
- \catcode45=12 % -
- \catcode46=12 % .
- \catcode58=12 % :
- \catcode64=11 % @
- \catcode123=1 % {
- \catcode125=2 % }
- \expandafter\let\expandafter\x\csname ver@bigintcalc.sty\endcsname
- \ifx\x\relax % plain-TeX, first loading
- \else
- \def\empty{}%
- \ifx\x\empty % LaTeX, first loading,
- % variable is initialized, but \ProvidesPackage not yet seen
- \else
- \expandafter\ifx\csname PackageInfo\endcsname\relax
- \def\x#1#2{%
- \immediate\write-1{Package #1 Info: #2.}%
- }%
- \else
- \def\x#1#2{\PackageInfo{#1}{#2, stopped}}%
- \fi
- \x{bigintcalc}{The package is already loaded}%
- \aftergroup\endinput
- \fi
- \fi
-\endgroup%
-\begingroup\catcode61\catcode48\catcode32=10\relax%
- \catcode13=5 % ^^M
- \endlinechar=13 %
- \catcode35=6 % #
- \catcode39=12 % '
- \catcode40=12 % (
- \catcode41=12 % )
- \catcode44=12 % ,
- \catcode45=12 % -
- \catcode46=12 % .
- \catcode47=12 % /
- \catcode58=12 % :
- \catcode64=11 % @
- \catcode91=12 % [
- \catcode93=12 % ]
- \catcode123=1 % {
- \catcode125=2 % }
- \expandafter\ifx\csname ProvidesPackage\endcsname\relax
- \def\x#1#2#3[#4]{\endgroup
- \immediate\write-1{Package: #3 #4}%
- \xdef#1{#4}%
- }%
- \else
- \def\x#1#2[#3]{\endgroup
- #2[{#3}]%
- \ifx#1\@undefined
- \xdef#1{#3}%
- \fi
- \ifx#1\relax
- \xdef#1{#3}%
- \fi
- }%
- \fi
-\expandafter\x\csname ver@bigintcalc.sty\endcsname
-\ProvidesPackage{bigintcalc}%
- [2016/05/16 v1.4 Expandable calculations on big integers (HO)]%
-\begingroup\catcode61\catcode48\catcode32=10\relax%
- \catcode13=5 % ^^M
- \endlinechar=13 %
- \catcode123=1 % {
- \catcode125=2 % }
- \catcode64=11 % @
- \def\x{\endgroup
- \expandafter\edef\csname BIC@AtEnd\endcsname{%
- \endlinechar=\the\endlinechar\relax
- \catcode13=\the\catcode13\relax
- \catcode32=\the\catcode32\relax
- \catcode35=\the\catcode35\relax
- \catcode61=\the\catcode61\relax
- \catcode64=\the\catcode64\relax
- \catcode123=\the\catcode123\relax
- \catcode125=\the\catcode125\relax
- }%
- }%
-\x\catcode61\catcode48\catcode32=10\relax%
-\catcode13=5 % ^^M
-\endlinechar=13 %
-\catcode35=6 % #
-\catcode64=11 % @
-\catcode123=1 % {
-\catcode125=2 % }
-\def\TMP@EnsureCode#1#2{%
- \edef\BIC@AtEnd{%
- \BIC@AtEnd
- \catcode#1=\the\catcode#1\relax
- }%
- \catcode#1=#2\relax
-}
-\TMP@EnsureCode{33}{12}% !
-\TMP@EnsureCode{36}{14}% $ (comment!)
-\TMP@EnsureCode{38}{14}% & (comment!)
-\TMP@EnsureCode{40}{12}% (
-\TMP@EnsureCode{41}{12}% )
-\TMP@EnsureCode{42}{12}% *
-\TMP@EnsureCode{43}{12}% +
-\TMP@EnsureCode{45}{12}% -
-\TMP@EnsureCode{46}{12}% .
-\TMP@EnsureCode{47}{12}% /
-\TMP@EnsureCode{58}{11}% : (letter!)
-\TMP@EnsureCode{60}{12}% <
-\TMP@EnsureCode{62}{12}% >
-\TMP@EnsureCode{63}{14}% ? (comment!)
-\TMP@EnsureCode{91}{12}% [
-\TMP@EnsureCode{93}{12}% ]
-\edef\BIC@AtEnd{\BIC@AtEnd\noexpand\endinput}
-\begingroup\expandafter\expandafter\expandafter\endgroup
-\expandafter\ifx\csname BIC@TestMode\endcsname\relax
-\else
- \catcode63=9 % ? (ignore)
-\fi
-? \let\BIC@@TestMode\BIC@TestMode
-\begingroup\expandafter\expandafter\expandafter\endgroup
-\expandafter\ifx\csname numexpr\endcsname\relax
- \catcode36=9 % $ (ignore)
-\else
- \catcode38=9 % & (ignore)
-\fi
-\let\BIC@Fi\fi
-\def\BIC@AfterFi#1#2\BIC@Fi{\fi#1}%
-\def\BIC@AfterFiFi#1#2\BIC@Fi{\fi\fi#1}%
-\def\BIC@AfterFiFiFi#1#2\BIC@Fi{\fi\fi\fi#1}%
-\begingroup
- \def\x#1{\endgroup
- \let\BIC@Space= #1%
- }%
-\x{ }
-\begingroup\expandafter\expandafter\expandafter\endgroup
-\expandafter\ifx\csname RequirePackage\endcsname\relax
- \def\TMP@RequirePackage#1[#2]{%
- \begingroup\expandafter\expandafter\expandafter\endgroup
- \expandafter\ifx\csname ver@#1.sty\endcsname\relax
- \input #1.sty\relax
- \fi
- }%
- \TMP@RequirePackage{pdftexcmds}[2007/11/11]%
-\else
- \RequirePackage{pdftexcmds}[2007/11/11]%
-\fi
-\begingroup\expandafter\expandafter\expandafter\endgroup
-\expandafter\ifx\csname pdf@escapehex\endcsname\relax
- \def\BIC@Expand#1{%
- \romannumeral0%
- \BIC@@Expand#1!\@nil{}%
- }%
- \def\BIC@@Expand#1#2\@nil#3{%
- \expandafter\ifcat\noexpand#1\relax
- \expandafter\@firstoftwo
- \else
- \expandafter\@secondoftwo
- \fi
- {%
- \expandafter\BIC@@Expand#1#2\@nil{#3}%
- }{%
- \ifx#1!%
- \expandafter\@firstoftwo
- \else
- \expandafter\@secondoftwo
- \fi
- { #3}{%
- \BIC@@Expand#2\@nil{#3#1}%
- }%
- }%
- }%
- \expandafter\ifx\csname @firstoftwo\endcsname\relax
- \long\def\@firstoftwo#1#2{#1}%
- \fi
- \expandafter\ifx\csname @secondoftwo\endcsname\relax
- \long\def\@secondoftwo#1#2{#2}%
- \fi
-\else
- \def\BIC@Expand#1{%
- \romannumeral0\expandafter\expandafter\expandafter\BIC@Space
- \pdf@unescapehex{%
- \expandafter\expandafter\expandafter
- \BIC@StripHexSpace\pdf@escapehex{#1}20\@nil
- }%
- }%
- \def\BIC@StripHexSpace#120#2\@nil{%
- #1%
- \ifx\\#2\\%
- \else
- \BIC@AfterFi{%
- \BIC@StripHexSpace#2\@nil
- }%
- \BIC@Fi
- }%
-\fi
-\def\BIC@Normalize#1#2{%
- \ifx#2-%
- \ifx\\#1\\%
- \BIC@AfterFiFi{%
- \BIC@Normalize-%
- }%
- \else
- \BIC@AfterFiFi{%
- \BIC@Normalize{}%
- }%
- \fi
- \else
- \ifx#2+%
- \BIC@AfterFiFi{%
- \BIC@Normalize{#1}%
- }%
- \else
- \ifx#20%
- \BIC@AfterFiFiFi{%
- \BIC@NormalizeZero{#1}%
- }%
- \else
- \BIC@AfterFiFiFi{%
- \BIC@NormalizeDigits#1#2%
- }%
- \fi
- \fi
- \BIC@Fi
-}
-\def\BIC@NormalizeZero#1#2{%
- \ifx#2!%
- \BIC@AfterFi{ 0}%
- \else
- \ifx#20%
- \BIC@AfterFiFi{%
- \BIC@NormalizeZero{#1}%
- }%
- \else
- \BIC@AfterFiFi{%
- \BIC@NormalizeDigits#1#2%
- }%
- \fi
- \BIC@Fi
-}
-\def\BIC@NormalizeDigits#1!{ #1}
-\def\bigintcalcNum#1{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@Normalize
- \expandafter\expandafter\expandafter{%
- \expandafter\expandafter\expandafter}%
- \BIC@Expand{#1}!%
-}
-\def\bigintcalcInv#1{%
- \romannumeral0\expandafter\expandafter\expandafter\BIC@Space
- \bigintcalcNum{-#1}%
-}
-\def\bigintcalcAbs#1{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@Abs
- \bigintcalcNum{#1}%
-}
-\def\BIC@Abs#1{%
- \ifx#1-%
- \expandafter\BIC@Space
- \else
- \expandafter\BIC@Space
- \expandafter#1%
- \fi
-}
-\def\bigintcalcSgn#1{%
- \number
- \expandafter\expandafter\expandafter\BIC@Sgn
- \bigintcalcNum{#1}! %
-}
-\def\BIC@Sgn#1#2!{%
- \ifx#1-%
- -1%
- \else
- \ifx#10%
- 0%
- \else
- 1%
- \fi
- \fi
-}
-\def\bigintcalcCmp#1#2{%
- \number
- \expandafter\expandafter\expandafter\BIC@Cmp
- \bigintcalcNum{#2}!{#1}%
-}
-\def\BIC@Cmp#1!#2{%
- \expandafter\expandafter\expandafter\BIC@@Cmp
- \bigintcalcNum{#2}!#1!%
-}
-\def\BIC@@Cmp#1#2!#3#4!{%
- \ifx#1-%
- \ifx#3-%
- \BIC@AfterFiFi{%
- \BIC@@Cmp#4!#2!%
- }%
- \else
- \BIC@AfterFiFi{%
- -1 %
- }%
- \fi
- \else
- \ifx#3-%
- \BIC@AfterFiFi{%
- 1 %
- }%
- \else
- \BIC@AfterFiFi{%
- \BIC@CmpLength#1#2!#3#4!#1#2!#3#4!%
- }%
- \fi
- \BIC@Fi
-}
-\def\BIC@PosCmp#1!#2!{%
- \BIC@CmpLength#1!#2!#1!#2!%
-}
-\def\BIC@CmpLength#1#2!#3#4!{%
- \ifx\\#2\\%
- \ifx\\#4\\%
- \BIC@AfterFiFi\BIC@CmpDiff
- \else
- \BIC@AfterFiFi{%
- \BIC@CmpResult{-1}%
- }%
- \fi
- \else
- \ifx\\#4\\%
- \BIC@AfterFiFi{%
- \BIC@CmpResult1%
- }%
- \else
- \BIC@AfterFiFi{%
- \BIC@CmpLength#2!#4!%
- }%
- \fi
- \BIC@Fi
-}
-\def\BIC@CmpResult#1#2!#3!{#1 }
-\def\BIC@CmpDiff#1#2!#3#4!{%
- \ifnum#1<#3 %
- \BIC@AfterFi{%
- -1 %
- }%
- \else
- \ifnum#1>#3 %
- \BIC@AfterFiFi{%
- 1 %
- }%
- \else
- \ifx\\#2\\%
- \BIC@AfterFiFiFi{%
- 0 %
- }%
- \else
- \BIC@AfterFiFiFi{%
- \BIC@CmpDiff#2!#4!%
- }%
- \fi
- \fi
- \BIC@Fi
-}
-\def\bigintcalcMin#1{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@MinMax
- \bigintcalcNum{#1}!-!%
-}
-\def\bigintcalcMax#1{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@MinMax
- \bigintcalcNum{#1}!!%
-}
-\def\BIC@MinMax#1!#2!#3{%
- \expandafter\expandafter\expandafter\BIC@@MinMax
- \bigintcalcNum{#3}!#1!#2!%
-}
-\def\BIC@@MinMax#1!#2!#3!{%
- \ifnum\BIC@@Cmp#1!#2!=#31 %
- \BIC@AfterFi{ #1}%
- \else
- \BIC@AfterFi{ #2}%
- \BIC@Fi
-}
-\def\bigintcalcOdd#1{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@Odd
- \bigintcalcAbs{#1}!%
-}
-\def\BigIntCalcOdd#1!{%
- \romannumeral0%
- \BIC@Odd#1!%
-}
-\def\BIC@Odd#1#2{%
- \ifx#2!%
- \ifodd#1 %
- \BIC@AfterFiFi{ 1}%
- \else
- \BIC@AfterFiFi{ 0}%
- \fi
- \else
- \expandafter\BIC@Odd\expandafter#2%
- \BIC@Fi
-}
-\def\bigintcalcInc#1{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@IncSwitch
- \bigintcalcNum{#1}!%
-}
-\def\BIC@IncSwitch#1#2!{%
- \ifcase\BIC@@Cmp#1#2!-1!%
- \BIC@AfterFi{ 0}%
- \or
- \BIC@AfterFi{%
- \BIC@Inc#1#2!{}%
- }%
- \else
- \BIC@AfterFi{%
- \expandafter-\romannumeral0%
- \BIC@Dec#2!{}%
- }%
- \BIC@Fi
-}
-\def\bigintcalcDec#1{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@DecSwitch
- \bigintcalcNum{#1}!%
-}
-\def\BIC@DecSwitch#1#2!{%
- \ifcase\BIC@Sgn#1#2! %
- \BIC@AfterFi{ -1}%
- \or
- \BIC@AfterFi{%
- \BIC@Dec#1#2!{}%
- }%
- \else
- \BIC@AfterFi{%
- \expandafter-\romannumeral0%
- \BIC@Inc#2!{}%
- }%
- \BIC@Fi
-}
-\def\BigIntCalcInc#1!{%
- \romannumeral0\BIC@Inc#1!{}%
-}
-\def\BigIntCalcDec#1!{%
- \romannumeral0\BIC@Dec#1!{}%
-}
-\def\BIC@Inc#1#2!#3{%
- \ifx\\#2\\%
- \BIC@AfterFi{%
- \BIC@@Inc1#1#3!{}%
- }%
- \else
- \BIC@AfterFi{%
- \BIC@Inc#2!{#1#3}%
- }%
- \BIC@Fi
-}
-\def\BIC@@Inc#1#2#3!#4{%
- \ifcase#1 %
- \ifx\\#3\\%
- \BIC@AfterFiFi{ #2#4}%
- \else
- \BIC@AfterFiFi{%
- \BIC@@Inc0#3!{#2#4}%
- }%
- \fi
- \else
- \ifnum#2<9 %
- \BIC@AfterFiFi{%
-& \expandafter\BIC@@@Inc\the\numexpr#2+1\relax
-$ \expandafter\expandafter\expandafter\BIC@@@Inc
-$ \ifcase#2 \expandafter1%
-$ \or\expandafter2%
-$ \or\expandafter3%
-$ \or\expandafter4%
-$ \or\expandafter5%
-$ \or\expandafter6%
-$ \or\expandafter7%
-$ \or\expandafter8%
-$ \or\expandafter9%
-$? \else\BigIntCalcError:ThisCannotHappen%
-$ \fi
- 0#3!{#4}%
- }%
- \else
- \BIC@AfterFiFi{%
- \BIC@@@Inc01#3!{#4}%
- }%
- \fi
- \BIC@Fi
-}
-\def\BIC@@@Inc#1#2#3!#4{%
- \ifx\\#3\\%
- \ifnum#2=1 %
- \BIC@AfterFiFi{ 1#1#4}%
- \else
- \BIC@AfterFiFi{ #1#4}%
- \fi
- \else
- \BIC@AfterFi{%
- \BIC@@Inc#2#3!{#1#4}%
- }%
- \BIC@Fi
-}
-\def\BIC@Dec#1#2!#3{%
- \ifx\\#2\\%
- \BIC@AfterFi{%
- \BIC@@Dec1#1#3!{}%
- }%
- \else
- \BIC@AfterFi{%
- \BIC@Dec#2!{#1#3}%
- }%
- \BIC@Fi
-}
-\def\BIC@@Dec#1#2#3!#4{%
- \ifcase#1 %
- \ifx\\#3\\%
- \BIC@AfterFiFi{ #2#4}%
- \else
- \BIC@AfterFiFi{%
- \BIC@@Dec0#3!{#2#4}%
- }%
- \fi
- \else
- \ifnum#2>0 %
- \BIC@AfterFiFi{%
-& \expandafter\BIC@@@Dec\the\numexpr#2-1\relax
-$ \expandafter\expandafter\expandafter\BIC@@@Dec
-$ \ifcase#2
-$? \BigIntCalcError:ThisCannotHappen%
-$ \or\expandafter0%
-$ \or\expandafter1%
-$ \or\expandafter2%
-$ \or\expandafter3%
-$ \or\expandafter4%
-$ \or\expandafter5%
-$ \or\expandafter6%
-$ \or\expandafter7%
-$ \or\expandafter8%
-$? \else\BigIntCalcError:ThisCannotHappen%
-$ \fi
- 0#3!{#4}%
- }%
- \else
- \BIC@AfterFiFi{%
- \BIC@@@Dec91#3!{#4}%
- }%
- \fi
- \BIC@Fi
-}
-\def\BIC@@@Dec#1#2#3!#4{%
- \ifx\\#3\\%
- \ifcase#1 %
- \ifx\\#4\\%
- \BIC@AfterFiFiFi{ 0}%
- \else
- \BIC@AfterFiFiFi{ #4}%
- \fi
- \else
- \BIC@AfterFiFi{ #1#4}%
- \fi
- \else
- \BIC@AfterFi{%
- \BIC@@Dec#2#3!{#1#4}%
- }%
- \BIC@Fi
-}
-\def\bigintcalcAdd#1{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@Add
- \bigintcalcNum{#1}!%
-}
-\def\BIC@Add#1!#2{%
- \expandafter\expandafter\expandafter
- \BIC@AddSwitch\bigintcalcNum{#2}!#1!%
-}
-\def\bigintcalcSub#1#2{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@Add
- \bigintcalcNum{-#2}!{#1}%
-}
-\def\BIC@AddSwitch#1#2!#3#4!{%
- \ifx#1-% x < 0
- \ifx#3-% y < 0
- \expandafter-\romannumeral0%
- \ifnum\BIC@PosCmp#2!#4!=1 % -x > -y
- \BIC@AfterFiFiFi{%
- \BIC@AddXY#2!#4!!!%
- }%
- \else % -x <= -y
- \BIC@AfterFiFiFi{%
- \BIC@AddXY#4!#2!!!%
- }%
- \fi
- \else % y >= 0
- \ifcase\BIC@PosCmp#2!#3#4!% -x = y
- \BIC@AfterFiFiFi{ 0}%
- \or % -x > y
- \expandafter-\romannumeral0%
- \BIC@AfterFiFiFi{%
- \BIC@SubXY#2!#3#4!!!%
- }%
- \else % -x <= y
- \BIC@AfterFiFiFi{%
- \BIC@SubXY#3#4!#2!!!%
- }%
- \fi
- \fi
- \else % x >= 0
- \ifx#3-% y < 0
- \ifcase\BIC@PosCmp#1#2!#4!% x = -y
- \BIC@AfterFiFiFi{ 0}%
- \or % x > -y
- \BIC@AfterFiFiFi{%
- \BIC@SubXY#1#2!#4!!!%
- }%
- \else % x <= -y
- \expandafter-\romannumeral0%
- \BIC@AfterFiFiFi{%
- \BIC@SubXY#4!#1#2!!!%
- }%
- \fi
- \else % y >= 0
- \ifnum\BIC@PosCmp#1#2!#3#4!=1 % x > y
- \BIC@AfterFiFiFi{%
- \BIC@AddXY#1#2!#3#4!!!%
- }%
- \else % x <= y
- \BIC@AfterFiFiFi{%
- \BIC@AddXY#3#4!#1#2!!!%
- }%
- \fi
- \fi
- \BIC@Fi
-}
-\def\BigIntCalcAdd#1!#2!{%
- \romannumeral0\BIC@AddXY#1!#2!!!%
-}
-\def\BigIntCalcSub#1!#2!{%
- \romannumeral0\BIC@SubXY#1!#2!!!%
-}
-\def\BIC@AddXY#1#2!#3#4!#5!#6!{%
- \ifx\\#2\\%
- \ifx\\#3\\%
- \BIC@AfterFiFi{%
- \BIC@DoAdd0!#1#5!#60!%
- }%
- \else
- \BIC@AfterFiFi{%
- \BIC@DoAdd0!#1#5!#3#6!%
- }%
- \fi
- \else
- \ifx\\#4\\%
- \ifx\\#3\\%
- \BIC@AfterFiFiFi{%
- \BIC@AddXY#2!{}!#1#5!#60!%
- }%
- \else
- \BIC@AfterFiFiFi{%
- \BIC@AddXY#2!{}!#1#5!#3#6!%
- }%
- \fi
- \else
- \BIC@AfterFiFi{%
- \BIC@AddXY#2!#4!#1#5!#3#6!%
- }%
- \fi
- \BIC@Fi
-}
-\def\BIC@DoAdd#1#2!#3#4!#5#6!{%
- \ifx\\#4\\%
- \BIC@AfterFi{%
-& \expandafter\BIC@Space
-& \the\numexpr#1+#3+#5\relax#2%
-$ \expandafter\expandafter\expandafter\BIC@AddResult
-$ \BIC@AddDigit#1#3#5#2%
- }%
- \else
- \BIC@AfterFi{%
- \expandafter\expandafter\expandafter\BIC@DoAdd
- \BIC@AddDigit#1#3#5#2!#4!#6!%
- }%
- \BIC@Fi
-}
-$ \def\BIC@AddResult#1{%
-$ \ifx#10%
-$ \expandafter\BIC@Space
-$ \else
-$ \expandafter\BIC@Space\expandafter#1%
-$ \fi
-$ }%
-\def\BIC@AddDigit#1#2#3{%
- \romannumeral0%
-& \expandafter\BIC@@AddDigit\the\numexpr#1+#2+#3!%
-$ \expandafter\BIC@@AddDigit\number%
-$ \csname
-$ BIC@AddCarry%
-$ \ifcase#1 %
-$ #2%
-$ \else
-$ \ifcase#2 1\or2\or3\or4\or5\or6\or7\or8\or9\or10\fi
-$ \fi
-$ \endcsname#3!%
-}
-\def\BIC@@AddDigit#1!{%
- \ifnum#1<10 %
- \BIC@AfterFi{ 0#1}%
- \else
- \BIC@AfterFi{ #1}%
- \BIC@Fi
-}
-$ \expandafter\def\csname BIC@AddCarry0\endcsname#1{#1}%
-$ \expandafter\def\csname BIC@AddCarry10\endcsname#1{1#1}%
-$ \def\BIC@Temp#1#2{%
-$ \expandafter\def\csname BIC@AddCarry#1\endcsname##1{%
-$ \ifcase##1 #1\or
-$ #2%
-$? \else\BigIntCalcError:ThisCannotHappen%
-$ \fi
-$ }%
-$ }%
-$ \BIC@Temp 0{1\or2\or3\or4\or5\or6\or7\or8\or9}%
-$ \BIC@Temp 1{2\or3\or4\or5\or6\or7\or8\or9\or10}%
-$ \BIC@Temp 2{3\or4\or5\or6\or7\or8\or9\or10\or11}%
-$ \BIC@Temp 3{4\or5\or6\or7\or8\or9\or10\or11\or12}%
-$ \BIC@Temp 4{5\or6\or7\or8\or9\or10\or11\or12\or13}%
-$ \BIC@Temp 5{6\or7\or8\or9\or10\or11\or12\or13\or14}%
-$ \BIC@Temp 6{7\or8\or9\or10\or11\or12\or13\or14\or15}%
-$ \BIC@Temp 7{8\or9\or10\or11\or12\or13\or14\or15\or16}%
-$ \BIC@Temp 8{9\or10\or11\or12\or13\or14\or15\or16\or17}%
-$ \BIC@Temp 9{10\or11\or12\or13\or14\or15\or16\or17\or18}%
-\def\BIC@SubXY#1#2!#3#4!#5!#6!{%
- \ifx\\#2\\%
- \ifx\\#3\\%
- \BIC@AfterFiFi{%
- \BIC@DoSub0!#1#5!#60!%
- }%
- \else
- \BIC@AfterFiFi{%
- \BIC@DoSub0!#1#5!#3#6!%
- }%
- \fi
- \else
- \ifx\\#4\\%
- \ifx\\#3\\%
- \BIC@AfterFiFiFi{%
- \BIC@SubXY#2!{}!#1#5!#60!%
- }%
- \else
- \BIC@AfterFiFiFi{%
- \BIC@SubXY#2!{}!#1#5!#3#6!%
- }%
- \fi
- \else
- \BIC@AfterFiFi{%
- \BIC@SubXY#2!#4!#1#5!#3#6!%
- }%
- \fi
- \BIC@Fi
-}
-\def\BIC@DoSub#1#2!#3#4!#5#6!{%
- \ifx\\#4\\%
- \BIC@AfterFi{%
- \expandafter\expandafter\expandafter\BIC@SubResult
- \BIC@SubDigit#1#3#5#2%
- }%
- \else
- \BIC@AfterFi{%
- \expandafter\expandafter\expandafter\BIC@DoSub
- \BIC@SubDigit#1#3#5#2!#4!#6!%
- }%
- \BIC@Fi
-}
-\def\BIC@SubResult#1{%
- \ifx#10%
- \expandafter\BIC@SubResult
- \else
- \expandafter\BIC@Space\expandafter#1%
- \fi
-}
-\def\BIC@SubDigit#1#2#3{%
- \romannumeral0%
-& \expandafter\BIC@@SubDigit\the\numexpr#2-#3-#1!%
-$ \expandafter\BIC@@AddDigit\number
-$ \csname
-$ BIC@SubCarry%
-$ \ifcase#1 %
-$ #3%
-$ \else
-$ \ifcase#3 1\or2\or3\or4\or5\or6\or7\or8\or9\or10\fi
-$ \fi
-$ \endcsname#2!%
-}
-& \def\BIC@@SubDigit#1!{%
-& \ifnum#1<0 %
-& \BIC@AfterFi{%
-& \expandafter\BIC@Space
-& \expandafter1\the\numexpr#1+10\relax
-& }%
-& \else
-& \BIC@AfterFi{ 0#1}%
-& \BIC@Fi
-& }%
-$ \expandafter\def\csname BIC@SubCarry0\endcsname#1{#1}%
-$ \expandafter\def\csname BIC@SubCarry10\endcsname#1{1#1}%
-$ \def\BIC@Temp#1#2{%
-$ \expandafter\def\csname BIC@SubCarry#1\endcsname##1{%
-$ \ifcase##1 #2%
-$? \else\BigIntCalcError:ThisCannotHappen%
-$ \fi
-$ }%
-$ }%
-$ \BIC@Temp 1{19\or0\or1\or2\or3\or4\or5\or6\or7\or8}%
-$ \BIC@Temp 2{18\or19\or0\or1\or2\or3\or4\or5\or6\or7}%
-$ \BIC@Temp 3{17\or18\or19\or0\or1\or2\or3\or4\or5\or6}%
-$ \BIC@Temp 4{16\or17\or18\or19\or0\or1\or2\or3\or4\or5}%
-$ \BIC@Temp 5{15\or16\or17\or18\or19\or0\or1\or2\or3\or4}%
-$ \BIC@Temp 6{14\or15\or16\or17\or18\or19\or0\or1\or2\or3}%
-$ \BIC@Temp 7{13\or14\or15\or16\or17\or18\or19\or0\or1\or2}%
-$ \BIC@Temp 8{12\or13\or14\or15\or16\or17\or18\or19\or0\or1}%
-$ \BIC@Temp 9{11\or12\or13\or14\or15\or16\or17\or18\or19\or0}%
-\def\bigintcalcShl#1{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@Shl
- \bigintcalcNum{#1}!%
-}
-\def\BIC@Shl#1#2!{%
- \ifx#1-%
- \BIC@AfterFi{%
- \expandafter-\romannumeral0%
-& \BIC@@Shl#2!!%
-$ \BIC@AddXY#2!#2!!!%
- }%
- \else
- \BIC@AfterFi{%
-& \BIC@@Shl#1#2!!%
-$ \BIC@AddXY#1#2!#1#2!!!%
- }%
- \BIC@Fi
-}
-\def\BigIntCalcShl#1!{%
- \romannumeral0%
-& \BIC@@Shl#1!!%
-$ \BIC@AddXY#1!#1!!!%
-}
-& \def\BIC@@Shl#1#2!{%
-& \ifx\\#2\\%
-& \BIC@AfterFi{%
-& \BIC@@@Shl0!#1%
-& }%
-& \else
-& \BIC@AfterFi{%
-& \BIC@@Shl#2!#1%
-& }%
-& \BIC@Fi
-& }%
-& \def\BIC@@@Shl#1#2!#3#4!{%
-& \ifx\\#4\\%
-& \BIC@AfterFi{%
-& \expandafter\BIC@Space
-& \the\numexpr#3*2+#1\relax#2%
-& }%
-& \else
-& \BIC@AfterFi{%
-& \expandafter\BIC@@@@Shl\the\numexpr#3*2+#1!#2!#4!%
-& }%
-& \BIC@Fi
-& }%
-& \def\BIC@@@@Shl#1!{%
-& \ifnum#1<10 %
-& \BIC@AfterFi{%
-& \BIC@@@Shl0#1%
-& }%
-& \else
-& \BIC@AfterFi{%
-& \BIC@@@Shl#1%
-& }%
-& \BIC@Fi
-& }%
-\def\bigintcalcShr#1{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@Shr
- \bigintcalcNum{#1}!%
-}
-\def\BIC@Shr#1#2!{%
- \ifx#1-%
- \expandafter-\romannumeral0%
- \BIC@AfterFi{%
- \BIC@@Shr#2!%
- }%
- \else
- \BIC@AfterFi{%
- \BIC@@Shr#1#2!%
- }%
- \BIC@Fi
-}
-\def\BigIntCalcShr#1!{%
- \romannumeral0%
- \BIC@@Shr#1!%
-}
-\def\BIC@@Shr#1#2!{%
- \ifcase#1 %
- \BIC@AfterFi{ 0}%
- \or
- \ifx\\#2\\%
- \BIC@AfterFiFi{ 0}%
- \else
- \BIC@AfterFiFi{%
- \BIC@@@Shr#1#2!!%
- }%
- \fi
- \else
- \BIC@AfterFi{%
- \BIC@@@Shr0#1#2!!%
- }%
- \BIC@Fi
-}
-\def\BIC@@@Shr#1#2#3!#4!{%
- \ifx\\#3\\%
- \ifodd#1#2 %
- \BIC@AfterFiFi{%
-& \expandafter\BIC@ShrResult\the\numexpr(#1#2-1)/2\relax
-$ \expandafter\expandafter\expandafter\BIC@ShrResult
-$ \csname BIC@ShrDigit#1#2\endcsname
- #4!%
- }%
- \else
- \BIC@AfterFiFi{%
-& \expandafter\BIC@ShrResult\the\numexpr#1#2/2\relax
-$ \expandafter\expandafter\expandafter\BIC@ShrResult
-$ \csname BIC@ShrDigit#1#2\endcsname
- #4!%
- }%
- \fi
- \else
- \ifodd#1#2 %
- \BIC@AfterFiFi{%
-& \expandafter\BIC@@@@Shr\the\numexpr(#1#2-1)/2\relax1%
-$ \expandafter\expandafter\expandafter\BIC@@@@Shr
-$ \csname BIC@ShrDigit#1#2\endcsname
- #3!#4!%
- }%
- \else
- \BIC@AfterFiFi{%
-& \expandafter\BIC@@@@Shr\the\numexpr#1#2/2\relax0%
-$ \expandafter\expandafter\expandafter\BIC@@@@Shr
-$ \csname BIC@ShrDigit#1#2\endcsname
- #3!#4!%
- }%
- \fi
- \BIC@Fi
-}
-& \def\BIC@ShrResult#1#2!{ #2#1}%
-$ \def\BIC@ShrResult#1#2#3!{ #3#1}%
-\def\BIC@@@@Shr#1#2#3!#4!{%
- \BIC@@@Shr#2#3!#4#1!%
-}
-$ \def\BIC@Temp#1#2#3#4{%
-$ \expandafter\def\csname BIC@ShrDigit#1#2\endcsname{#3#4}%
-$ }%
-$ \BIC@Temp 0000%
-$ \BIC@Temp 0101%
-$ \BIC@Temp 0210%
-$ \BIC@Temp 0311%
-$ \BIC@Temp 0420%
-$ \BIC@Temp 0521%
-$ \BIC@Temp 0630%
-$ \BIC@Temp 0731%
-$ \BIC@Temp 0840%
-$ \BIC@Temp 0941%
-$ \BIC@Temp 1050%
-$ \BIC@Temp 1151%
-$ \BIC@Temp 1260%
-$ \BIC@Temp 1361%
-$ \BIC@Temp 1470%
-$ \BIC@Temp 1571%
-$ \BIC@Temp 1680%
-$ \BIC@Temp 1781%
-$ \BIC@Temp 1890%
-$ \BIC@Temp 1991%
-\def\BIC@Tim#1!#2{%
- \romannumeral0%
- \ifcase#2 % 0
- \BIC@AfterFi{ 0}%
- \or % 1
- \BIC@AfterFi{ #1}%
- \or % 2
- \BIC@AfterFi{%
- \BIC@Shl#1!%
- }%
- \else % 3-9
- \BIC@AfterFi{%
- \BIC@@Tim#1!!#2%
- }%
- \BIC@Fi
-}
-\def\BIC@@Tim#1#2!{%
- \ifx\\#2\\%
- \BIC@AfterFi{%
- \BIC@ProcessTim0!#1%
- }%
- \else
- \BIC@AfterFi{%
- \BIC@@Tim#2!#1%
- }%
- \BIC@Fi
-}
-\def\BIC@ProcessTim#1#2!#3#4!#5{%
- \ifx\\#4\\%
- \BIC@AfterFi{%
- \expandafter\BIC@Space
-& \the\numexpr#3*#5+#1\relax
-$ \romannumeral0\BIC@TimDigit#3#5#1%
- #2%
- }%
- \else
- \BIC@AfterFi{%
- \expandafter\BIC@@ProcessTim
-& \the\numexpr#3*#5+#1%
-$ \romannumeral0\BIC@TimDigit#3#5#1%
- !#2!#4!#5%
- }%
- \BIC@Fi
-}
-\def\BIC@@ProcessTim#1#2!{%
- \ifx\\#2\\%
- \BIC@AfterFi{%
- \BIC@ProcessTim0#1%
- }%
- \else
- \BIC@AfterFi{%
- \BIC@ProcessTim#1#2%
- }%
- \BIC@Fi
-}
-$ \def\BIC@TimDigit#1#2#3{%
-$ \ifcase#1 % 0
-$ \BIC@AfterFi{ #3}%
-$ \or % 1
-$ \BIC@AfterFi{%
-$ \expandafter\BIC@Space
-$ \number\csname BIC@AddCarry#2\endcsname#3 %
-$ }%
-$ \else
-$ \ifcase#3 %
-$ \BIC@AfterFiFi{%
-$ \expandafter\BIC@Space
-$ \number\csname BIC@MulDigit#2\endcsname#1 %
-$ }%
-$ \else
-$ \BIC@AfterFiFi{%
-$ \expandafter\BIC@Space
-$ \romannumeral0%
-$ \expandafter\BIC@AddXY
-$ \number\csname BIC@MulDigit#2\endcsname#1!%
-$ #3!!!%
-$ }%
-$ \fi
-$ \BIC@Fi
-$ }%
-$ \def\BIC@Temp#1#2{%
-$ \expandafter\def\csname BIC@MulDigit#1\endcsname##1{%
-$ \ifcase##1 0%
-$ \or ##1%
-$ \or #2%
-$? \else\BigIntCalcError:ThisCannotHappen%
-$ \fi
-$ }%
-$ }%
-$ \BIC@Temp 3{6\or9\or12\or15\or18\or21\or24\or27}%
-$ \BIC@Temp 4{8\or12\or16\or20\or24\or28\or32\or36}%
-$ \BIC@Temp 5{10\or15\or20\or25\or30\or35\or40\or45}%
-$ \BIC@Temp 6{12\or18\or24\or30\or36\or42\or48\or54}%
-$ \BIC@Temp 7{14\or21\or28\or35\or42\or49\or56\or63}%
-$ \BIC@Temp 8{16\or24\or32\or40\or48\or56\or64\or72}%
-$ \BIC@Temp 9{18\or27\or36\or45\or54\or63\or72\or81}%
-\def\bigintcalcMul#1#2{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@Mul
- \bigintcalcNum{#1}!{#2}%
-}
-\def\BIC@Mul#1!#2{%
- \expandafter\expandafter\expandafter\BIC@MulSwitch
- \bigintcalcNum{#2}!#1!%
-}
-\def\BIC@MulSwitch#1#2!#3#4!{%
- \ifcase\BIC@Sgn#1#2! % x = 0
- \BIC@AfterFi{ 0}%
- \or % x > 0
- \ifcase\BIC@Sgn#3#4! % y = 0
- \BIC@AfterFiFi{ 0}%
- \or % y > 0
- \ifnum\BIC@PosCmp#1#2!#3#4!=1 % x > y
- \BIC@AfterFiFiFi{%
- \BIC@ProcessMul0!#1#2!#3#4!%
- }%
- \else % x <= y
- \BIC@AfterFiFiFi{%
- \BIC@ProcessMul0!#3#4!#1#2!%
- }%
- \fi
- \else % y < 0
- \expandafter-\romannumeral0%
- \ifnum\BIC@PosCmp#1#2!#4!=1 % x > -y
- \BIC@AfterFiFiFi{%
- \BIC@ProcessMul0!#1#2!#4!%
- }%
- \else % x <= -y
- \BIC@AfterFiFiFi{%
- \BIC@ProcessMul0!#4!#1#2!%
- }%
- \fi
- \fi
- \else % x < 0
- \ifcase\BIC@Sgn#3#4! % y = 0
- \BIC@AfterFiFi{ 0}%
- \or % y > 0
- \expandafter-\romannumeral0%
- \ifnum\BIC@PosCmp#2!#3#4!=1 % -x > y
- \BIC@AfterFiFiFi{%
- \BIC@ProcessMul0!#2!#3#4!%
- }%
- \else % -x <= y
- \BIC@AfterFiFiFi{%
- \BIC@ProcessMul0!#3#4!#2!%
- }%
- \fi
- \else % y < 0
- \ifnum\BIC@PosCmp#2!#4!=1 % -x > -y
- \BIC@AfterFiFiFi{%
- \BIC@ProcessMul0!#2!#4!%
- }%
- \else % -x <= -y
- \BIC@AfterFiFiFi{%
- \BIC@ProcessMul0!#4!#2!%
- }%
- \fi
- \fi
- \BIC@Fi
-}
-\def\BigIntCalcMul#1!#2!{%
- \romannumeral0%
- \BIC@ProcessMul0!#1!#2!%
-}
-\def\BIC@ProcessMul#1!#2!#3#4!{%
- \ifx\\#4\\%
- \BIC@AfterFi{%
- \expandafter\expandafter\expandafter\BIC@Space
- \bigintcalcAdd{\BIC@Tim#2!#3}{#10}%
- }%
- \else
- \BIC@AfterFi{%
- \expandafter\expandafter\expandafter\BIC@ProcessMul
- \bigintcalcAdd{\BIC@Tim#2!#3}{#10}!#2!#4!%
- }%
- \BIC@Fi
-}
-\def\bigintcalcSqr#1{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@Sqr
- \bigintcalcNum{#1}!%
-}
-\def\BIC@Sqr#1{%
- \ifx#1-%
- \expandafter\BIC@@Sqr
- \else
- \expandafter\BIC@@Sqr\expandafter#1%
- \fi
-}
-\def\BIC@@Sqr#1!{%
- \BIC@ProcessMul0!#1!#1!%
-}
-\def\bigintcalcFac#1{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@Fac
- \bigintcalcNum{#1}!%
-}
-\def\BIC@Fac#1#2!{%
- \ifx#1-%
- \BIC@AfterFi{ 0\BigIntCalcError:FacNegative}%
- \else
- \ifnum\BIC@PosCmp#1#2!13!<0 %
- \ifcase#1#2 %
- \BIC@AfterFiFiFi{ 1}% 0!
- \or\BIC@AfterFiFiFi{ 1}% 1!
- \or\BIC@AfterFiFiFi{ 2}% 2!
- \or\BIC@AfterFiFiFi{ 6}% 3!
- \or\BIC@AfterFiFiFi{ 24}% 4!
- \or\BIC@AfterFiFiFi{ 120}% 5!
- \or\BIC@AfterFiFiFi{ 720}% 6!
- \or\BIC@AfterFiFiFi{ 5040}% 7!
- \or\BIC@AfterFiFiFi{ 40320}% 8!
- \or\BIC@AfterFiFiFi{ 362880}% 9!
- \or\BIC@AfterFiFiFi{ 3628800}% 10!
- \or\BIC@AfterFiFiFi{ 39916800}% 11!
- \or\BIC@AfterFiFiFi{ 479001600}% 12!
-? \else\BigIntCalcError:ThisCannotHappen%
- \fi
- \else
- \BIC@AfterFiFi{%
- \BIC@ProcessFac#1#2!479001600!%
- }%
- \fi
- \BIC@Fi
-}
-\def\BIC@ProcessFac#1!#2!{%
- \ifnum\BIC@PosCmp#1!12!=0 %
- \BIC@AfterFi{ #2}%
- \else
- \BIC@AfterFi{%
- \expandafter\BIC@@ProcessFac
- \romannumeral0\BIC@ProcessMul0!#2!#1!%
- !#1!%
- }%
- \BIC@Fi
-}
-\def\BIC@@ProcessFac#1!#2!{%
- \expandafter\BIC@ProcessFac
- \romannumeral0\BIC@Dec#2!{}%
- !#1!%
-}
-\def\bigintcalcPow#1{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@Pow
- \bigintcalcNum{#1}!%
-}
-\def\BIC@Pow#1!#2{%
- \expandafter\expandafter\expandafter\BIC@PowSwitch
- \bigintcalcNum{#2}!#1!%
-}
-\def\BIC@PowSwitch#1#2!#3#4!{%
- \ifcase\ifx\\#2\\%
- \ifx#100 % y = 0
- \else\ifx#111 % y = 1
- \else\ifx#122 % y = 2
- \else4 % y > 2
- \fi\fi\fi
- \else
- \ifx#1-3 % y < 0
- \else4 % y > 2
- \fi
- \fi
- \BIC@AfterFi{ 1}% y = 0
- \or % y = 1
- \BIC@AfterFi{ #3#4}%
- \or % y = 2
- \ifx#3-% x < 0
- \BIC@AfterFiFi{%
- \BIC@ProcessMul0!#4!#4!%
- }%
- \else % x >= 0
- \BIC@AfterFiFi{%
- \BIC@ProcessMul0!#3#4!#3#4!%
- }%
- \fi
- \or % y < 0
- \ifcase\ifx\\#4\\%
- \ifx#300 % x = 0
- \else\ifx#311 % x = 1
- \else3 % x > 1
- \fi\fi
- \else
- \ifcase\BIC@MinusOne#3#4! %
- 3 % |x| > 1
- \or
- 2 % x = -1
-? \else\BigIntCalcError:ThisCannotHappen%
- \fi
- \fi
- \BIC@AfterFiFi{ 0\BigIntCalcError:DivisionByZero}% x = 0
- \or % x = 1
- \BIC@AfterFiFi{ 1}% x = 1
- \or % x = -1
- \ifcase\BIC@ModTwo#2! % even(y)
- \BIC@AfterFiFiFi{ 1}%
- \or % odd(y)
- \BIC@AfterFiFiFi{ -1}%
-? \else\BigIntCalcError:ThisCannotHappen%
- \fi
- \or % |x| > 1
- \BIC@AfterFiFi{ 0}%
-? \else\BigIntCalcError:ThisCannotHappen%
- \fi
- \or % y > 2
- \ifcase\ifx\\#4\\%
- \ifx#300 % x = 0
- \else\ifx#311 % x = 1
- \else4 % x > 1
- \fi\fi
- \else
- \ifx#3-%
- \ifcase\BIC@MinusOne#3#4! %
- 3 % x < -1
- \else
- 2 % x = -1
- \fi
- \else
- 4 % x > 1
- \fi
- \fi
- \BIC@AfterFiFi{ 0}% x = 0
- \or % x = 1
- \BIC@AfterFiFi{ 1}% x = 1
- \or % x = -1
- \ifcase\BIC@ModTwo#1#2! % even(y)
- \BIC@AfterFiFiFi{ 1}%
- \or % odd(y)
- \BIC@AfterFiFiFi{ -1}%
-? \else\BigIntCalcError:ThisCannotHappen%
- \fi
- \or % x < -1
- \ifcase\BIC@ModTwo#1#2! % even(y)
- \BIC@AfterFiFiFi{%
- \BIC@PowRec#4!#1#2!1!%
- }%
- \or % odd(y)
- \expandafter-\romannumeral0%
- \BIC@AfterFiFiFi{%
- \BIC@PowRec#4!#1#2!1!%
- }%
-? \else\BigIntCalcError:ThisCannotHappen%
- \fi
- \or % x > 1
- \BIC@AfterFiFi{%
- \BIC@PowRec#3#4!#1#2!1!%
- }%
-? \else\BigIntCalcError:ThisCannotHappen%
- \fi
-? \else\BigIntCalcError:ThisCannotHappen%
- \BIC@Fi
-}
-\def\BIC@ModTwo#1#2!{%
- \ifx\\#2\\%
- \ifodd#1 %
- \BIC@AfterFiFi1%
- \else
- \BIC@AfterFiFi0%
- \fi
- \else
- \BIC@AfterFi{%
- \BIC@ModTwo#2!%
- }%
- \BIC@Fi
-}
-\def\BIC@MinusOne#1#2!{%
- \ifx#1-%
- \BIC@@MinusOne#2!%
- \else
- 0%
- \fi
-}
-\def\BIC@@MinusOne#1#2!{%
- \ifx#11%
- \ifx\\#2\\%
- 1%
- \else
- 0%
- \fi
- \else
- 0%
- \fi
-}
-\def\BIC@PowRec#1!#2#3!#4!{%
- \ifcase\ifx#21\ifx\\#3\\0 \else1 \fi\else1 \fi % y = 1
- \ifnum\BIC@PosCmp#1!#4!=1 % x > r
- \BIC@AfterFiFi{%
- \BIC@ProcessMul0!#1!#4!%
- }%
- \else
- \BIC@AfterFiFi{%
- \BIC@ProcessMul0!#4!#1!%
- }%
- \fi
- \or
- \ifcase\BIC@ModTwo#2#3! % even(y)
- \BIC@AfterFiFi{%
- \expandafter\BIC@@PowRec\romannumeral0%
- \BIC@@Shr#2#3!%
- !#1!#4!%
- }%
- \or % odd(y)
- \ifnum\BIC@PosCmp#1!#4!=1 % x > r
- \BIC@AfterFiFiFi{%
- \expandafter\BIC@@@PowRec\romannumeral0%
- \BIC@ProcessMul0!#1!#4!%
- !#1!#2#3!%
- }%
- \else
- \BIC@AfterFiFiFi{%
- \expandafter\BIC@@@PowRec\romannumeral0%
- \BIC@ProcessMul0!#1!#4!%
- !#1!#2#3!%
- }%
- \fi
-? \else\BigIntCalcError:ThisCannotHappen%
- \fi
-? \else\BigIntCalcError:ThisCannotHappen%
- \BIC@Fi
-}
-\def\BIC@@PowRec#1!#2!#3!{%
- \expandafter\BIC@PowRec\romannumeral0%
- \BIC@ProcessMul0!#2!#2!%
- !#1!#3!%
-}
-\def\BIC@@@PowRec#1!#2!#3!{%
- \expandafter\BIC@@PowRec\romannumeral0%
- \BIC@@Shr#3!%
- !#2!#1!%
-}
-\def\bigintcalcDiv#1{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@Div
- \bigintcalcNum{#1}!%
-}
-\def\BIC@Div#1!#2{%
- \expandafter\expandafter\expandafter\BIC@DivSwitchSign
- \bigintcalcNum{#2}!#1!%
-}
-\def\BigIntCalcDiv#1!#2!{%
- \romannumeral0%
- \BIC@DivSwitchSign#2!#1!%
-}
-\def\BIC@DivSwitchSign#1#2!#3#4!{%
- \ifcase\BIC@Sgn#1#2! % y = 0
- \BIC@AfterFi{ 0\BigIntCalcError:DivisionByZero}%
- \or % y > 0
- \ifcase\BIC@Sgn#3#4! % x = 0
- \BIC@AfterFiFi{ 0}%
- \or % x > 0
- \BIC@AfterFiFi{%
- \BIC@DivSwitch{}#3#4!#1#2!%
- }%
- \else % x < 0
- \BIC@AfterFiFi{%
- \BIC@DivSwitch-#4!#1#2!%
- }%
- \fi
- \else % y < 0
- \ifcase\BIC@Sgn#3#4! % x = 0
- \BIC@AfterFiFi{ 0}%
- \or % x > 0
- \BIC@AfterFiFi{%
- \BIC@DivSwitch-#3#4!#2!%
- }%
- \else % x < 0
- \BIC@AfterFiFi{%
- \BIC@DivSwitch{}#4!#2!%
- }%
- \fi
- \BIC@Fi
-}
-\def\BIC@DivSwitch#1#2!#3#4!{%
- \ifcase\BIC@PosCmp#3#4!#2!% y = x
- \BIC@AfterFi{ #11}%
- \or % y > x
- \BIC@AfterFi{ 0}%
- \else % y < x
- \ifx\\#1\\%
- \else
- \expandafter-\romannumeral0%
- \fi
- \ifcase\ifx\\#4\\%
- \ifx#310 % y = 1
- \else\ifx#321 % y = 2
- \else\ifx#342 % y = 4
- \else3 % y > 2
- \fi\fi\fi
- \else
- 3 % y > 2
- \fi
- \BIC@AfterFiFi{ #2}% y = 1
- \or % y = 2
- \BIC@AfterFiFi{%
- \BIC@@Shr#2!%
- }%
- \or % y = 4
- \BIC@AfterFiFi{%
- \expandafter\BIC@@Shr\romannumeral0%
- \BIC@@Shr#2!!%
- }%
- \or % y > 2
- \BIC@AfterFiFi{%
- \BIC@DivStartX#2!#3#4!!!%
- }%
-? \else\BigIntCalcError:ThisCannotHappen%
- \fi
- \BIC@Fi
-}
-\def\BIC@DivStartX#1#2!#3#4!#5!#6!{%
- \ifx\\#4\\%
- \BIC@AfterFi{%
- \BIC@DivStartYii#6#3#4!{#5#1}#2=!%
- }%
- \else
- \BIC@AfterFi{%
- \BIC@DivStartX#2!#4!#5#1!#6#3!%
- }%
- \BIC@Fi
-}
-\def\BIC@DivStartYii#1!{%
- \expandafter\BIC@DivStartYiv\romannumeral0%
- \BIC@Shl#1!%
- !#1!%
-}
-\def\BIC@DivStartYiv#1!{%
- \expandafter\BIC@DivStartYvi\romannumeral0%
- \BIC@Shl#1!%
- !#1!%
-}
-\def\BIC@DivStartYvi#1!#2!{%
- \expandafter\BIC@DivStartYviii\romannumeral0%
- \BIC@AddXY#1!#2!!!%
- !#1!#2!%
-}
-\def\BIC@DivStartYviii#1!#2!{%
- \expandafter\BIC@DivStart\romannumeral0%
- \BIC@Shl#2!%
- !#1!#2!%
-}
-\def\BIC@DivStart#1!#2!#3!#4!#5!#6!{%
- \BIC@ProcessDiv#6!!#5!#4!#3!#2!#1!=%
-}
-\def\BIC@ProcessDiv#1#2#3!#4!#5!{%
- \ifcase\BIC@PosCmp#5!#1!% y = #1
- \ifx#2=%
- \BIC@AfterFiFi{\BIC@DivCleanup{#41}}%
- \else
- \BIC@AfterFiFi{%
- \BIC@ProcessDiv#2#3!#41!#5!%
- }%
- \fi
- \or % y > #1
- \ifx#2=%
- \BIC@AfterFiFi{\BIC@DivCleanup{#40}}%
- \else
- \ifx\\#4\\%
- \BIC@AfterFiFiFi{%
- \BIC@ProcessDiv{#1#2}#3!!#5!%
- }%
- \else
- \BIC@AfterFiFiFi{%
- \BIC@ProcessDiv{#1#2}#3!#40!#5!%
- }%
- \fi
- \fi
- \else % y < #1
- \BIC@AfterFi{%
- \BIC@@ProcessDiv{#1}#2#3!#4!#5!%
- }%
- \BIC@Fi
-}
-\def\BIC@DivCleanup#1#2={ #1}%
-\def\BIC@@ProcessDiv#1#2#3!#4!#5!#6!#7!{%
- \ifcase\BIC@PosCmp#7!#1!% 4y = #1
- \ifx#2=%
- \BIC@AfterFiFi{\BIC@DivCleanup{#44}}%
- \else
- \BIC@AfterFiFi{%
- \BIC@ProcessDiv#2#3!#44!#5!#6!#7!%
- }%
- \fi
- \or % 4y > #1
- \ifcase\BIC@PosCmp#6!#1!% 2y = #1
- \ifx#2=%
- \BIC@AfterFiFiFi{\BIC@DivCleanup{#42}}%
- \else
- \BIC@AfterFiFiFi{%
- \BIC@ProcessDiv#2#3!#42!#5!#6!#7!%
- }%
- \fi
- \or % 2y > #1
- \ifx#2=%
- \BIC@AfterFiFiFi{\BIC@DivCleanup{#41}}%
- \else
- \BIC@AfterFiFiFi{%
- \BIC@DivSub#1!#5!#2#3!#41!#5!#6!#7!%
- }%
- \fi
- \else % 2y < #1
- \BIC@AfterFiFi{%
- \expandafter\BIC@ProcessDivII\romannumeral0%
- \BIC@SubXY#1!#6!!!%
- !#2#3!#4!#5!23%
- #6!#7!%
- }%
- \fi
- \else % 4y < #1
- \BIC@AfterFi{%
- \BIC@@@ProcessDiv{#1}#2#3!#4!#5!#6!#7!%
- }%
- \BIC@Fi
-}
-\def\BIC@DivSub#1!#2!#3{%
- \expandafter\BIC@ProcessDiv\expandafter{%
- \romannumeral0%
- \BIC@SubXY#1!#2!!!%
- #3%
- }%
-}
-\def\BIC@ProcessDivII#1!#2#3!#4!#5!#6#7{%
- \ifcase\BIC@PosCmp#5!#1!% y = #1
- \ifx#2=%
- \BIC@AfterFiFi{\BIC@DivCleanup{#4#7}}%
- \else
- \BIC@AfterFiFi{%
- \BIC@ProcessDiv#2#3!#4#7!#5!%
- }%
- \fi
- \or % y > #1
- \ifx#2=%
- \BIC@AfterFiFi{\BIC@DivCleanup{#4#6}}%
- \else
- \BIC@AfterFiFi{%
- \BIC@ProcessDiv{#1#2}#3!#4#6!#5!%
- }%
- \fi
- \else % y < #1
- \ifx#2=%
- \BIC@AfterFiFi{\BIC@DivCleanup{#4#7}}%
- \else
- \BIC@AfterFiFi{%
- \BIC@DivSub#1!#5!#2#3!#4#7!#5!%
- }%
- \fi
- \BIC@Fi
-}
-\def\BIC@@@ProcessDiv#1#2#3!#4!#5!#6!#7!#8!#9!{%
- \ifcase\BIC@PosCmp#8!#1!% 6y = #1
- \ifx#2=%
- \BIC@AfterFiFi{\BIC@DivCleanup{#46}}%
- \else
- \BIC@AfterFiFi{%
- \BIC@ProcessDiv#2#3!#46!#5!#6!#7!#8!#9!%
- }%
- \fi
- \or % 6y > #1
- \BIC@AfterFi{%
- \expandafter\BIC@ProcessDivII\romannumeral0%
- \BIC@SubXY#1!#7!!!%
- !#2#3!#4!#5!45%
- #6!#7!#8!#9!%
- }%
- \else % 6y < #1
- \ifcase\BIC@PosCmp#9!#1!% 8y = #1
- \ifx#2=%
- \BIC@AfterFiFiFi{\BIC@DivCleanup{#48}}%
- \else
- \BIC@AfterFiFiFi{%
- \BIC@ProcessDiv#2#3!#48!#5!#6!#7!#8!#9!%
- }%
- \fi
- \or % 8y > #1
- \BIC@AfterFiFi{%
- \expandafter\BIC@ProcessDivII\romannumeral0%
- \BIC@SubXY#1!#8!!!%
- !#2#3!#4!#5!67%
- #6!#7!#8!#9!%
- }%
- \else % 8y < #1
- \BIC@AfterFiFi{%
- \expandafter\BIC@ProcessDivII\romannumeral0%
- \BIC@SubXY#1!#9!!!%
- !#2#3!#4!#5!89%
- #6!#7!#8!#9!%
- }%
- \fi
- \BIC@Fi
-}
-\def\bigintcalcMod#1{%
- \romannumeral0%
- \expandafter\expandafter\expandafter\BIC@Mod
- \bigintcalcNum{#1}!%
-}
-\def\BIC@Mod#1!#2{%
- \expandafter\expandafter\expandafter\BIC@ModSwitchSign
- \bigintcalcNum{#2}!#1!%
-}
-\def\BigIntCalcMod#1!#2!{%
- \romannumeral0%
- \BIC@ModSwitchSign#2!#1!%
-}
-\def\BIC@ModSwitchSign#1#2!#3#4!{%
- \ifcase\ifx\\#2\\%
- \ifx#100 % y = 0
- \else1 % y > 0
- \fi
- \else
- \ifx#1-2 % y < 0
- \else1 % y > 0
- \fi
- \fi
- \BIC@AfterFi{ 0\BigIntCalcError:DivisionByZero}%
- \or % y > 0
- \ifcase\ifx\\#4\\\ifx#300 \else1 \fi\else1 \fi % x = 0
- \BIC@AfterFiFi{ 0}%
- \else
- \BIC@AfterFiFi{%
- \BIC@ModSwitch{}#3#4!#1#2!%
- }%
- \fi
- \else % y < 0
- \ifcase\ifx\\#4\\%
- \ifx#300 % x = 0
- \else1 % x > 0
- \fi
- \else
- \ifx#3-2 % x < 0
- \else1 % x > 0
- \fi
- \fi
- \BIC@AfterFiFi{ 0}%
- \or % x > 0
- \BIC@AfterFiFi{%
- \BIC@ModSwitch--#3#4!#2!%
- }%
- \else % x < 0
- \BIC@AfterFiFi{%
- \BIC@ModSwitch-#4!#2!%
- }%
- \fi
- \BIC@Fi
-}
-\def\BIC@ModSwitch#1#2#3!#4#5!{%
- \ifcase\ifx\\#5\\%
- \ifx#410 % y = 1
- \else\ifx#421 % y = 2
- \else2 % y > 2
- \fi\fi
- \else2 % y > 2
- \fi
- \BIC@AfterFi{ 0}% y = 1
- \or % y = 2
- \ifcase\BIC@ModTwo#2#3! % even(x)
- \BIC@AfterFiFi{ 0}%
- \or % odd(x)
- \BIC@AfterFiFi{ #11}%
-? \else\BigIntCalcError:ThisCannotHappen%
- \fi
- \or % y > 2
- \ifx\\#1\\%
- \else
- \expandafter\BIC@Space\romannumeral0%
- \expandafter\BIC@ModMinus\romannumeral0%
- \fi
- \ifx#2-% x < 0
- \BIC@AfterFiFi{%
- \expandafter\expandafter\expandafter\BIC@ModX
- \bigintcalcSub{#2#3}{%
- \bigintcalcMul{#4#5}{\bigintcalcDiv{#2#3}{#4#5}}%
- }!#4#5!%
- }%
- \else % x > 0
- \BIC@AfterFiFi{%
- \expandafter\expandafter\expandafter\BIC@Space
- \bigintcalcSub{#2#3}{%
- \bigintcalcMul{#4#5}{\bigintcalcDiv{#2#3}{#4#5}}%
- }%
- }%
- \fi
-? \else\BigIntCalcError:ThisCannotHappen%
- \BIC@Fi
-}
-\def\BIC@ModMinus#1{%
- \ifx#10%
- \BIC@AfterFi{ 0}%
- \else
- \BIC@AfterFi{ -#1}%
- \BIC@Fi
-}
-\def\BIC@ModX#1#2!#3!{%
- \ifx#1-% z < 0
- \BIC@AfterFi{%
- \expandafter\BIC@Space\romannumeral0%
- \BIC@SubXY#3!#2!!!%
- }%
- \else % z >= 0
- \BIC@AfterFi{ #1#2}%
- \BIC@Fi
-}
-\BIC@AtEnd%
-%% \section{Installation}
-\endinput
-%%
-%% End of file `bigintcalc.sty'.