%%
%% This is file `intcalc.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% intcalc.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Project: intcalc
%% Version: 2007/09/27 v1.1
%% 
%% Copyright (C) 2007 by
%%    Heiko Oberdiek <heiko.oberdiek at googlemail.com>
%% 
%% 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
%%    http://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%%    http://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".
%% 
%% This Current Maintainer of this work is Heiko Oberdiek.
%% 
%% 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 intcalc.dtx
%% and the derived files
%%    intcalc.sty, intcalc.pdf, intcalc.ins, intcalc.drv,
%%    intcalc-test1.tex, intcalc-test2.tex, intcalc-test3.tex,
%%    intcalc-test4.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@intcalc.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{intcalc}{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@intcalc.sty\endcsname
\ProvidesPackage{intcalc}%
  [2007/09/27 v1.1 Expandable calculations with 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 InCa@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\InCa@AtEnd{%
    \InCa@AtEnd
    \catcode#1=\the\catcode#1\relax
  }%
  \catcode#1=#2\relax
}
\TMP@EnsureCode{33}{12}% !
\TMP@EnsureCode{40}{12}% (
\TMP@EnsureCode{41}{12}% )
\TMP@EnsureCode{42}{12}% *
\TMP@EnsureCode{43}{12}% +
\TMP@EnsureCode{45}{12}% -
\TMP@EnsureCode{47}{12}% /
\TMP@EnsureCode{58}{11}% : (letter!)
\TMP@EnsureCode{60}{12}% <
\TMP@EnsureCode{62}{12}% >
\TMP@EnsureCode{63}{14}% ? (comment!)
\edef\InCa@AtEnd{\InCa@AtEnd\noexpand\endinput}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname InCa@TestMode\endcsname\relax
\else
  \catcode63=9 % ? (ignore)
\fi
? \let\InCa@@TestMode\InCa@TestMode
\def\InCa@Abs#1#2!{%
  \ifx#1-%
    #2%
  \else
    #1#2%
  \fi
}
\def\InCa@Sgn#1#2!{%
  \ifx#1-%
    -1%
  \else
    \ifx#10%
      0%
    \else
      1%
    \fi
  \fi
}
\def\InCa@Min#1!#2!{%
  \ifnum#1<#2 %
    #1%
  \else
    #2%
  \fi
}
\def\InCa@Max#1!#2!{%
  \ifnum#1>#2 %
    #1%
  \else
    #2%
  \fi
}
\def\InCa@Cmp#1!#2!{%
  \ifnum#1=#2 %
    0%
  \else
    \ifnum#1<#2 %
      -%
    \fi
    1%
  \fi
}
\def\InCa@Fac#1!{%
  \ifcase#1 1% 0!
  \or 1% 1!
  \or 2% 2!
  \or 6% 3!
  \or 24% 4!
  \or 120% 5!
  \or 720% 6!
  \or 5040% 7!
  \or 40320% 8!
  \or 362880% 9!
  \or 3628800% 10!
  \or 39916800% 11!
  \or 479001600% 12!
  \else
    \ifnum#1<\z@
      0\IntCalcError:FacNegative%
    \else
      0\IntCalcError:FacOverflow%
    \fi
  \fi
}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname numexpr\endcsname\relax
\else
  \def\intcalcNum#1{%
    \the\numexpr#1\relax
  }%
  \def\intcalcInv#1{%
    \number-\intcalcNum{#1} %
  }%
  \def\intcalcAbs#1{%
    \number\expandafter\InCa@Abs\the\numexpr#1! %
  }%
  \def\intcalcSgn#1{%
    \number\expandafter\InCa@Sgn\the\numexpr#1! %
  }%
  \def\intcalcMin#1#2{%
    \number\expandafter\InCa@Min
    \the\numexpr#1\expandafter!%
    \the\numexpr#2! %
  }%
  \def\intcalcMax#1#2{%
    \number\expandafter\InCa@Max
    \the\numexpr#1\expandafter!%
    \the\numexpr#2! %
  }%
  \def\intcalcCmp#1#2{%
    \number\expandafter\InCa@Cmp
    \the\numexpr#1\expandafter!\the\numexpr#2! %
  }%
  \def\intcalcInc#1{%
    \the\numexpr#1+1\relax
  }%
  \def\intcalcDec#1{%
    \the\numexpr#1-1\relax
  }%
  \def\IntCalcInc#1!{%
    \the\numexpr#1+1\relax
  }%
  \def\IntCalcDec#1!{%
    \the\numexpr#1-1\relax
  }%
  \def\intcalcAdd#1#2{%
    \the\numexpr#1+(#2)\relax
  }%
  \def\intcalcSub#1#2{%
    \the\numexpr#1-(#2)\relax
  }%
  \def\IntCalcAdd#1!#2!{%
    \the\numexpr#1+#2\relax
  }%
  \def\IntCalcSub#1!#2!{%
    \the\numexpr#1-#2\relax
  }%
  \def\intcalcShl#1{%
    \the\numexpr(#1)*2\relax
  }%
  \def\intcalcShr#1{%
    \number\expandafter\InCa@Shr\the\numexpr#1! %
  }%
  \def\IntCalcShl#1!{%
    \the\numexpr#1*2\relax
  }%
  \def\IntCalcShr#1!{%
    \the\numexpr\ifodd#1 (#1-1)\else#1\fi/2\relax
  }%
  \def\InCa@Shr#1#2!{%
    \ifx#1-%
      -\InCa@Shr#2!%
    \else
      \ifodd#1#2 %
        \the\numexpr(#1#2-1)/2\relax
      \else
        \the\numexpr#1#2/2\relax
      \fi
    \fi
  }%
  \def\intcalcMul#1#2{%
    \the\numexpr(#1)*(#2)\relax
  }%
  \def\IntCalcMul#1!#2!{%
    \the\numexpr#1*#2\relax
  }%
  \def\intcalcSqr#1{%
    \number\expandafter\InCa@Sqr\the\numexpr#1! %
  }%
  \def\InCa@Sqr#1!{%
    \the\numexpr#1*#1\relax
  }%
  \def\intcalcFac#1{%
    \number\expandafter\InCa@Fac\the\numexpr#1! %
  }%
  \def\intcalcPow#1#2{%
    \number\expandafter\InCa@Pow
    \the\numexpr#1\expandafter!%
    \the\numexpr#2! %
  }%
  \def\InCa@Pow#1#2!#3#4!{%
    \ifcase#3#4 % power = 0
      1%
    \or % power = 1
      #1#2%
    \or % power = 2
      \the\numexpr#1#2*#1#2\relax
    \else
      \ifcase#1#2 % basis = 0, power <> 0
        0%
        \ifx#3-% power < 0
          0\IntCalcError:DivisionByZero%
        \fi
      \or
        1% basis = 1
      \else
        \ifnum#1#2=\m@ne % basis = -1
          \ifodd#3#4 %
            -%
          \fi
          1%
        \else % |basis| > 1
          \ifx#3-% power < 0
            0%
          \else % power > 2
            \InCa@PowRec#1#2!#3#4!1!%
          \fi
        \fi
      \fi
    \fi
  }%
  \def\InCa@PowRec#1!#2!#3!{%
    \ifnum#2=\@ne
      \the\numexpr#1*#3\relax
    \else
      \ifodd#2 %
        \expandafter\InCa@PowRec
        \the\numexpr#1*#1\expandafter!%
        \the\numexpr(#2-1)/2\expandafter!%
        \the\numexpr#1*#3\expandafter\expandafter\expandafter!%
      \else
        \expandafter\InCa@PowRec
        \the\numexpr#1*#1\expandafter!%
        \the\numexpr(#2-1)/2\expandafter!%
        \number#3\expandafter\expandafter\expandafter!%
      \fi
    \fi
  }%
  \def\intcalcDiv#1#2{%
    \number\expandafter\InCa@Div
    \the\numexpr#1\expandafter!%
    \the\numexpr#2! %
  }%
  \def\InCa@Div#1!#2!{%
    \ifcase#2 %
      0\IntCalcError:DivisionByZero%
    \else
      \ifcase#1 %
        0%
      \else
        \expandafter\InCa@@Div
        \romannumeral 0%
        \ifnum#1<\z@
          \expandafter-\number-#1%
        \else
          \expandafter+\number#1%
        \fi
        \expandafter!%
        \romannumeral 0%
        \ifnum#2<\z@
          \expandafter-\number-#2%
        \else
          \expandafter+\number#2%
        \fi
        !%
      \fi
    \fi
  }%
  \def\InCa@Temp#1{%
    \def\IntCalcDiv##1!##2!{%
      \number
      \ifcase##2 %
        0\IntCalcError:DivisionByZero%
      \else
        \ifcase##1 %
          0%
        \else
          \the\numexpr(##1-(##2-1)/2)/##2\relax
        \fi
      \fi
      #1%
    }%
  }%
  \InCa@Temp{ }%
  \def\InCa@@Div#1#2!#3#4!{%
    #1#3%
    \the\numexpr(#2-(#4-1)/2)/#4\relax
  }%
  \def\intcalcMod#1#2{%
    \number\expandafter\InCa@Mod
    \the\numexpr#1\expandafter!%
    \the\numexpr#2! %
  }%
  \def\InCa@Mod#1!#2!{%
    \ifcase#2 %
      0\IntCalcError:DivisionByZero%
    \else
      \ifcase#1 %
        0%
      \else
        \expandafter\InCa@@Mod
        \romannumeral 0%
        \ifnum#1<\z@
          \expandafter-\number-#1%
        \else
          \expandafter+\number#1%
        \fi
        \expandafter!%
        \romannumeral 0%
        \ifnum#2<\z@
          \expandafter-\number-#2%
        \else
          \expandafter+\number#2%
        \fi
        !%
      \fi
    \fi
  }%
  \def\InCa@Temp#1{%
    \def\IntCalcMod##1!##2!{%
      \number
      \ifcase##2 %
        0\IntCalcError:DivisionByZero%
      \else
        \ifcase##1 %
          0%
        \else
          \the\numexpr##1-(##1-(##2-1)/2)/##2*##2\relax
        \fi
      \fi
      #1%
    }%
  }%
  \InCa@Temp{ }%
  \def\InCa@@Mod#1#2!#3#4!{%
    \if#3+%
      \if#1+%
        \the\numexpr#2-\InCa@@Div+#2!+#4!*#4\relax
      \else
        \expandafter\InCa@ModX
        \the\numexpr-#2+\InCa@@Div+#2!+#4!*#4!#4!%
      \fi
    \else
      -%
      \if#1+%
        \expandafter\InCa@ModX
        \the\numexpr-#2+\InCa@@Div+#2!+#4!*#4!#4!%
      \else
        \the\numexpr#2-\InCa@@Div+#2!+#4!*#4\relax
      \fi
    \fi
  }%
  \def\InCa@ModX#1!#2!{%
    \ifcase#1 %
      0%
    \else
      \the\numexpr#1+#2\relax
    \fi
  }%
  \expandafter\InCa@AtEnd
\fi%
\def\intcalcNum#1{%
  \number\expandafter\InCa@FirstOfOne\number#1! %
}
\def\intcalcInv#1{%
  \number\expandafter\InCa@FirstOfOne\number-#1! %
}
\def\InCa@FirstOfOne#1!{#1}
\def\intcalcAbs#1{%
  \number\expandafter\InCa@Abs\number#1! %
}
\def\intcalcSgn#1{%
  \number\expandafter\InCa@Sgn\number#1! %
}
\def\intcalcMin#1#2{%
  \number\expandafter\InCa@Min
  \number\number#1\expandafter!\number#2! %
}
\def\intcalcMax#1#2{%
  \number\expandafter\InCa@Max
  \number\number#1\expandafter!\number#2! %
}
\def\intcalcCmp#1#2{%
  \number\expandafter\InCa@Cmp
  \number\number#1\expandafter!\number#2! %
}%
\def\intcalcInc#1{%
  \number\expandafter\InCa@IncSwitch\number#1! %
}
\def\InCa@IncSwitch#1#2!{%
  \ifx#1-%
    -%
    \csname InCa@Empty%
    \InCa@Dec#2!%
  \else
    \csname InCa@Empty%
    \InCa@Inc#1#2!%
  \fi
}
\def\intcalcDec#1{%
  \number\expandafter\InCa@DecSwitch\number#1! %
}
\def\InCa@DecSwitch#1#2!{%
  \ifx#1-%
    -%
    \csname InCa@Empty%
    \expandafter\InCa@Inc#2!%
  \else
    \ifx#10%
      -1%
    \else
      \csname InCa@Empty%
      \InCa@Dec#1#2!%
    \fi
  \fi
}
\def\IntCalcInc#1!{%
  \number\csname InCa@Empty\InCa@Inc#1! %
}
\def\IntCalcDec#1!{%
  \number\csname InCa@Empty\InCa@Dec#1! %
}
\def\InCa@Inc#1#2{%
  \ifx#2!%
    \csname InCa@IncDigit#1\endcsname1%
  \else
    \csname InCa@IncDigit#1%
    \expandafter\InCa@Inc\expandafter#2%
  \fi
}
\def\InCa@Temp#1#2{%
  \expandafter\def\csname InCa@IncDigit#1\endcsname##1{%
    \endcsname
    0%
    \ifcase##1 %
      #1%
    \else
      #2%
    \fi
  }%
}
\InCa@Temp 01
\InCa@Temp 12
\InCa@Temp 23
\InCa@Temp 34
\InCa@Temp 45
\InCa@Temp 56
\InCa@Temp 67
\InCa@Temp 78
\InCa@Temp 89
\expandafter\def\csname InCa@IncDigit9\endcsname#1{%
  \expandafter\endcsname
  \ifcase#1 %
    09%
  \else
    10%
  \fi
}
\def\InCa@Dec#1#2{%
  \ifx#2!%
    \csname InCa@DecDigit#1\endcsname1%
  \else
    \csname InCa@DecDigit#1%
    \expandafter\InCa@Dec\expandafter#2%
  \fi
}
\def\InCa@Temp#1#2{%
  \expandafter\def\csname InCa@DecDigit#1\endcsname##1{%
    \endcsname
    0%
    \ifcase##1 %
      #1%
    \else
      #2%
    \fi
  }%
}
\InCa@Temp 98
\InCa@Temp 87
\InCa@Temp 76
\InCa@Temp 65
\InCa@Temp 54
\InCa@Temp 43
\InCa@Temp 32
\InCa@Temp 21
\InCa@Temp 10
\expandafter\def\csname InCa@DecDigit0\endcsname#1{%
  \expandafter\endcsname
  \ifcase#1 %
    00%
  \else
    19%
  \fi
}
\def\intcalcAdd#1#2{%
  \number
    \expandafter\InCa@AddSwitch
    \number\number#1\expandafter!%
    \number#2! %
}
\def\intcalcSub#1#2{%
  \number
    \expandafter\InCa@AddSwitch
    \number\number#1\expandafter!%
    \number-\number#2! %
}
\def\InCa@AddSwitch#1!#2!{%
  \ifnum#1<\z@
    \ifnum#2<\z@
      -%
      \ifnum#1<#2 %
        \expandafter\InCa@Add\number-#1\expandafter!%
        \@gobble#2!%
      \else
        \expandafter\InCa@Add\number-#2\expandafter!%
        \@gobble#1!%
      \fi
    \else
      \ifnum-#1>#2 %
        -%
        \expandafter\InCa@Sub\@gobble#1!#2!%
      \else
        \expandafter\InCa@Sub\number#2\expandafter!%
        \@gobble#1!%
      \fi
    \fi
  \else
    \ifnum#2<\z@
      \ifnum#1>-#2 %
        \expandafter\InCa@Sub\number#1\expandafter!%
        \@gobble#2!%
      \else
        -%
        \expandafter\InCa@Sub\@gobble#2!#1!%
      \fi
    \else
      \ifnum#1>#2 %
        \InCa@Add#1!#2!%
      \else
        \InCa@Add#2!#1!%
      \fi
    \fi
  \fi
}
\def\IntCalcAdd#1!#2!{%
  \number\InCa@Add#1!#2! %
}
\def\IntCalcSub#1!#2!{%
  \number\InCa@Sub#1!#2! %
}
\begingroup
  \def\x#1{\endgroup
    \let\InCa@Space= #1%
  }%
\x{ }
\def\InCa@Add#1!#2!{%
  \ifcase#2 %
    #1%
  \else
    \InCa@@Add#1!#2!000000000\InCa@Space
  \fi
}
\def\InCa@Sub#1!#2!{%
  \ifnum#1=#2 %
    0%
  \else
    \InCa@@Sub#1!#2!000000000\InCa@Space
  \fi
}
\def\InCa@@Add#1!#2#3!{%
  \ifx\InCa@Empty#3\InCa@Empty
    \@ReturnAfterElseFi{%
      \InCa@@@Add!!#1!#2%
    }%
  \else
    \@ReturnAfterFi{%
      \InCa@@Add#1!#3!#2%
    }%
  \fi
}
\def\InCa@@Sub#1!#2#3!{%
  \ifx\InCa@Empty#3\InCa@Empty
    \@ReturnAfterElseFi{%
      \InCa@@@Sub!!#1!#2%
    }%
  \else
    \@ReturnAfterFi{%
      \InCa@@Sub#1!#3!#2%
    }%
  \fi
}
\def\InCa@@@Add#1!#2!#3#4!#5{%
  \ifx\InCa@Empty#4\InCa@Empty
    \csname InCa@Empty%
    \@ReturnAfterElseFi{%
      \InCa@ProcessAdd#1#3!#5#2%
    }%
  \else
    \@ReturnAfterFi{%
      \InCa@@@Add#1#3!#5#2!#4!%
    }%
  \fi
}
\def\InCa@@@Sub#1!#2!#3#4!#5{%
  \ifx\InCa@Empty#4\InCa@Empty
    \csname @gobble%
    \@ReturnAfterElseFi{%
      \InCa@ProcessSub#1#3!#5#2%
    }%
  \else
    \@ReturnAfterFi{%
      \InCa@@@Sub#1#3!#5#2!#4!%
    }%
  \fi
}
\def\InCa@ProcessAdd#1#2!#3#4{%
  \ifx\InCa@Empty#2\InCa@Empty
    \csname InCa@AddDigit#1\endcsname#3%
    \romannumeral0#4%
  \else
    \csname InCa@AddDigit#1\csname InCa@DigitCarry#3%
    \@ReturnAfterFi{%
      \InCa@ProcessAdd#2!#4%
    }%
  \fi
}
\def\InCa@ProcessSub#1#2!#3#4{%
  \ifx\InCa@Empty#2\InCa@Empty
    \csname InCa@SubDigit#1\endcsname#3%
    \romannumeral0#4%
  \else
    \csname InCa@SubDigit#1\csname InCa@DigitCarry#3%
    \@ReturnAfterFi{%
      \InCa@ProcessSub#2!#4%
    }%
  \fi
}
\def\InCa@Temp#1#2{%
  \expandafter\def\csname InCa@DigitCarry#1\endcsname##1{%
    \ifcase##1 %
      \endcsname#1%
    \else
      \endcsname#2%
    \fi
  }%
}
\InCa@Temp 01
\InCa@Temp 12
\InCa@Temp 23
\InCa@Temp 34
\InCa@Temp 45
\InCa@Temp 56
\InCa@Temp 67
\InCa@Temp 78
\InCa@Temp 89
\InCa@Temp 9{{10}}
\expandafter\def\csname InCa@AddDigit0\endcsname#1{%
  \ifnum#1>9 %
    \endcsname10%
  \else
    \endcsname0#1%
  \fi
}
\def\InCa@Temp#1#2#3{%
  \expandafter\def\csname InCa@AddDigit#1\endcsname##1{%
    \ifnum##1>#2 %
      \endcsname 1%
    \else
      \endcsname 0%
    \fi
    \ifcase##1 #1% 0
    #3%
    \else #1% 10
    \fi
  }%
}
\InCa@Temp 18{%
  \or 2% 1
  \or 3% 2
  \or 4% 3
  \or 5% 4
  \or 6% 5
  \or 7% 6
  \or 8% 7
  \or 9% 8
  \or 0% 9
}%
\InCa@Temp 27{%
  \or 3% 1
  \or 4% 2
  \or 5% 3
  \or 6% 4
  \or 7% 5
  \or 8% 6
  \or 9% 7
  \or 0% 8
  \or 1% 9
}%
\InCa@Temp 36{%
  \or 4% 1
  \or 5% 2
  \or 6% 3
  \or 7% 4
  \or 8% 5
  \or 9% 6
  \or 0% 7
  \or 1% 8
  \or 2% 9
}%
\InCa@Temp 45{%
  \or 5% 1
  \or 6% 2
  \or 7% 3
  \or 8% 4
  \or 9% 5
  \or 0% 6
  \or 1% 7
  \or 2% 8
  \or 3% 9
}%
\InCa@Temp 54{%
  \or 6% 1
  \or 7% 2
  \or 8% 3
  \or 9% 4
  \or 0% 5
  \or 1% 6
  \or 2% 7
  \or 3% 8
  \or 4% 9
}%
\InCa@Temp 63{%
  \or 7% 1
  \or 8% 2
  \or 9% 3
  \or 0% 4
  \or 1% 5
  \or 2% 6
  \or 3% 7
  \or 4% 8
  \or 5% 9
}%
\InCa@Temp 72{%
  \or 8% 1
  \or 9% 2
  \or 0% 3
  \or 1% 4
  \or 2% 5
  \or 3% 6
  \or 4% 7
  \or 5% 8
  \or 6% 9
}%
\InCa@Temp 81{%
  \or 9% 1
  \or 0% 2
  \or 1% 3
  \or 2% 4
  \or 3% 5
  \or 4% 6
  \or 5% 7
  \or 6% 8
  \or 7% 9
}%
\InCa@Temp 90{%
  \or 0% 1
  \or 1% 2
  \or 2% 3
  \or 3% 4
  \or 4% 5
  \or 5% 6
  \or 6% 7
  \or 7% 8
  \or 8% 9
}%
\def\InCa@Temp#1#2{%
  \expandafter\def\csname InCa@SubDigit#1\endcsname##1{%
    \ifnum##1>#1 %
      \endcsname 1%
    \else
      \endcsname 0%
    \fi
    \ifcase##1 #1% 0
    #2%
    \else #1% 10
    \fi
  }%
}
\InCa@Temp 0{%
  \or 9% 1
  \or 8% 2
  \or 7% 3
  \or 6% 4
  \or 5% 5
  \or 4% 6
  \or 3% 7
  \or 2% 8
  \or 1% 9
}
\InCa@Temp 1{%
  \or 0% 1
  \or 9% 2
  \or 8% 3
  \or 7% 4
  \or 6% 5
  \or 5% 6
  \or 4% 7
  \or 3% 8
  \or 2% 9
}
\InCa@Temp 2{%
  \or 1% 1
  \or 0% 2
  \or 9% 3
  \or 8% 4
  \or 7% 5
  \or 6% 6
  \or 5% 7
  \or 4% 8
  \or 3% 9
}
\InCa@Temp 3{%
  \or 2% 1
  \or 1% 2
  \or 0% 3
  \or 9% 4
  \or 8% 5
  \or 7% 6
  \or 6% 7
  \or 5% 8
  \or 4% 9
}
\InCa@Temp 4{%
  \or 3% 1
  \or 2% 2
  \or 1% 3
  \or 0% 4
  \or 9% 5
  \or 8% 6
  \or 7% 7
  \or 6% 8
  \or 5% 9
}
\InCa@Temp 5{%
  \or 4% 1
  \or 3% 2
  \or 2% 3
  \or 1% 4
  \or 0% 5
  \or 9% 6
  \or 8% 7
  \or 7% 8
  \or 6% 9
}
\InCa@Temp 6{%
  \or 5% 1
  \or 4% 2
  \or 3% 3
  \or 2% 4
  \or 1% 5
  \or 0% 6
  \or 9% 7
  \or 8% 8
  \or 7% 9
}
\InCa@Temp 7{%
  \or 6% 1
  \or 5% 2
  \or 4% 3
  \or 3% 4
  \or 2% 5
  \or 1% 6
  \or 0% 7
  \or 9% 8
  \or 8% 9
}
\InCa@Temp 8{%
  \or 7% 1
  \or 6% 2
  \or 5% 3
  \or 4% 4
  \or 3% 5
  \or 2% 6
  \or 1% 7
  \or 0% 8
  \or 9% 9
}
\InCa@Temp 9{%
  \or 8% 1
  \or 7% 2
  \or 6% 3
  \or 5% 4
  \or 4% 5
  \or 3% 6
  \or 2% 7
  \or 1% 8
  \or 0% 9
}
\def\intcalcShl#1{%
  \number\expandafter\InCa@ShlSwitch\number#1! %
}
\def\InCa@ShlSwitch#1#2!{%
  \ifx#1-%
    -\csname InCa@Empty%
    \InCa@Shl#2!%
  \else
    \csname InCa@Empty%
    \InCa@Shl#1#2!%
  \fi
}
\def\IntCalcShl#1!{%
  \number
  \csname InCa@Empty%
  \InCa@Shl#1! %
}
\def\InCa@Shl#1#2{%
  \ifx#2!%
    \csname InCa@ShlDigit#1\endcsname0%
  \else
    \csname InCa@ShlDigit#1%
    \@ReturnAfterFi{%
      \InCa@Shl#2%
    }%
  \fi
}
\expandafter\def\csname InCa@ShlDigit0\endcsname{%
  \endcsname0%
}
\def\InCa@Temp#1#2#3#4#5{%
  \expandafter\def\csname InCa@ShlDigit#1\endcsname##1{%
    \expandafter\endcsname
    \ifcase##1 %
      #2#3%
    \else
      #4#5%
    \fi
  }%
}
\InCa@Temp 10203
\InCa@Temp 20405
\InCa@Temp 30607
\InCa@Temp 40809
\InCa@Temp 51011
\InCa@Temp 61213
\InCa@Temp 71415
\InCa@Temp 81617
\InCa@Temp 91819
\def\intcalcShr#1{%
  \number\expandafter\InCa@ShrSwitch\number#1! %
}
\def\InCa@ShrSwitch#1#2!{%
  \ifx#1-%
    -\InCa@Shr#2!%
  \else
    \InCa@Shr#1#2!%
  \fi
}
\def\IntCalcShr#1!{%
  \number\InCa@Shr#1! %
}
\def\InCa@Shr#1#2{%
  \InCa@ShrDigit#1!%
  \ifx#2!%
  \else
    \@ReturnAfterFi{%
      \ifodd#1 %
        \@ReturnAfterElseFi{%
          \InCa@Shr{1#2}%
        }%
      \else
        \expandafter\InCa@Shr\expandafter#2%
      \fi
    }%
  \fi
}
\def\InCa@ShrDigit#1!{%
  \ifcase#1 0% 0
  \or 0% 1
  \or 1% 2
  \or 1% 3
  \or 2% 4
  \or 2% 5
  \or 3% 6
  \or 3% 7
  \or 4% 8
  \or 4% 9
  \or 5% 10
  \or 5% 11
  \or 6% 12
  \or 6% 13
  \or 7% 14
  \or 7% 15
  \or 8% 16
  \or 8% 17
  \or 9% 18
  \or 9% 19
  \fi
}
\def\InCa@Temp#1{%
  \def\InCa@Tim##1##2{%
    \number
      \ifcase##2 % 0
        0%
      \or % 1
        ##1%
      \else % 2-9
        \csname InCa@Empty%
        \InCa@ProcessTim##2##1!%
      \fi
    #1%
  }%
}
\InCa@Temp{ }
\def\InCa@ProcessTim#1#2#3{%
  \ifx#3!%
    \csname InCa@TimDigit#2\endcsname#10%
  \else
    \csname InCa@TimDigit#2\csname InCa@Param#1%
    \@ReturnAfterFi{%
      \InCa@ProcessTim#1#3%
    }%
  \fi
}
\def\InCa@Temp#1{%
  \expandafter\def\csname InCa@Param#1\endcsname{%
    \endcsname#1%
  }%
}
\InCa@Temp 0%
\InCa@Temp 1%
\InCa@Temp 2%
\InCa@Temp 3%
\InCa@Temp 4%
\InCa@Temp 5%
\InCa@Temp 6%
\InCa@Temp 7%
\InCa@Temp 8%
\InCa@Temp 9%
\expandafter\def\csname InCa@TimDigit0\endcsname#1#2{%
  \endcsname
  0#2%
}
\expandafter\def\csname InCa@TimDigit1\endcsname#1#2{%
  \ifcase#2 %
    \endcsname 0#1%
  \else
    \csname InCa@AddDigit#1\endcsname #2%
  \fi
}
\def\InCa@Temp#1#2{%
  \expandafter\def\csname InCa@TimDigit#1\endcsname##1{%
    \expandafter\InCa@TimDigitCarry
    \number
      \ifcase##1 0% 0
      #2%
      \fi
    !%
  }%
}
\InCa@Temp 2{%
  \or  2% 1
  \or  4% 2
  \or  6% 3
  \or  8% 4
  \or 10% 5
  \or 12% 6
  \or 14% 7
  \or 16% 8
  \or 18% 9
}
\InCa@Temp 3{%
  \or  3% 1
  \or  6% 2
  \or  9% 3
  \or 12% 4
  \or 15% 5
  \or 18% 6
  \or 21% 7
  \or 24% 8
  \or 27% 9
}
\InCa@Temp 4{%
  \or  4% 1
  \or  8% 2
  \or 12% 3
  \or 16% 4
  \or 20% 5
  \or 24% 6
  \or 28% 7
  \or 32% 8
  \or 36% 9
}
\InCa@Temp 5{%
  \or  5% 1
  \or 10% 2
  \or 15% 3
  \or 20% 4
  \or 25% 5
  \or 30% 6
  \or 35% 7
  \or 40% 8
  \or 45% 9
}
\InCa@Temp 6{%
  \or  6% 1
  \or 12% 2
  \or 18% 3
  \or 24% 4
  \or 30% 5
  \or 36% 6
  \or 42% 7
  \or 48% 8
  \or 54% 9
}
\InCa@Temp 7{%
  \or  7% 1
  \or 14% 2
  \or 21% 3
  \or 28% 4
  \or 35% 5
  \or 42% 6
  \or 49% 7
  \or 56% 8
  \or 63% 9
}
\InCa@Temp 8{%
  \or  8% 1
  \or 16% 2
  \or 24% 3
  \or 32% 4
  \or 40% 5
  \or 48% 6
  \or 56% 7
  \or 64% 8
  \or 72% 9
}
\InCa@Temp 9{%
  \or  9% 1
  \or 18% 2
  \or 27% 3
  \or 36% 4
  \or 45% 5
  \or 54% 6
  \or 63% 7
  \or 72% 8
  \or 81% 9
}
\def\InCa@TimDigitCarry#1!{%
  \ifnum#1<10 %
    \csname InCa@AddDigit#1\expandafter\endcsname
  \else
    \@ReturnAfterFi{%
      \InCa@@TimDigitCarry#1!%
    }%
  \fi
}
\def\InCa@@TimDigitCarry#1#2!#3{%
  \csname InCa@DigitCarry#1%
  \csname InCa@AddDigit#2\endcsname #3%
}
\def\intcalcMul#1#2{%
  \number
    \expandafter\InCa@MulSwitch
    \number\number#1\expandafter!%
    \number#2! %
}
\def\InCa@MulSwitch#1!#2!{%
  \ifnum#1<\z@
    \ifnum#2<\z@
      \ifnum#1<#2 %
        \expandafter\InCa@Mul\number-#1\expandafter!%
        \@gobble#2!%
      \else
        \expandafter\InCa@Mul\number-#2\expandafter!%
        \@gobble#1!%
      \fi
    \else
      -%
      \ifnum-#1>#2 %
        \expandafter\InCa@Mul\@gobble#1!#2!%
      \else
        \expandafter\InCa@Mul\number#2\expandafter!%
        \@gobble#1!%
      \fi
    \fi
  \else
    \ifnum#2<\z@
      -%
      \ifnum#1>-#2 %
        \expandafter\InCa@Mul\number#1\expandafter!%
        \@gobble#2!%
      \else
        \expandafter\InCa@Mul\@gobble#2!#1!%
      \fi
    \else
      \ifnum#1>#2 %
        \InCa@Mul#1!#2!%
      \else
        \InCa@Mul#2!#1!%
      \fi
    \fi
  \fi
}
\def\IntCalcMul#1!#2!{%
  \number\InCa@Mul#1!#2! %
}
\def\InCa@Mul#1!#2!{%
  \ifcase#2 %
    0%
  \or
    #1%
  \or
    \csname InCa@Empty%
    \expandafter\InCa@Shl#1!%
  \else
    \ifnum#2<10 %
      \InCa@Tim{#1}#2%
    \else
      \InCa@ProcessMul!#2!#1!%
    \fi
  \fi
}
\def\InCa@ProcessMul#1!#2#3!#4!{%
  \ifx\InCa@Empty#3\InCa@Empty
    \expandafter\InCa@Add\number
    #10\expandafter\expandafter\expandafter!%
    \InCa@Tim{#4}#2!%
  \else
    \ifx\InCa@Empty#1\InCa@Empty
      \expandafter\expandafter\expandafter\InCa@ProcessMul
      \InCa@Tim{#4}#2!%
      #3!#4!%
    \else
      \expandafter\InCa@ProcessMul\number
      \expandafter\InCa@Add\number%
      #10\expandafter\expandafter\expandafter!%
      \InCa@Tim{#4}#2!!%
      #3!#4!%
    \fi
  \fi
}
\def\intcalcSqr#1{%
  \number\expandafter\InCa@Sqr\number#1! %
}
\def\InCa@Sqr#1#2!{%
  \ifx#1-%
    \InCa@Mul#2!#2!%
  \else
    \InCa@Mul#1#2!#1#2!%
  \fi
}
\def\intcalcFac#1{%
  \number\expandafter\InCa@Fac\number#1! %
}
\def\intcalcPow#1#2{%
  \number\expandafter\InCa@Pow
  \number\number#1\expandafter!%
  \number#2! %
}
\def\InCa@Pow#1#2!#3#4!{%
  \ifcase#3#4 % power = 0
    1%
  \or % power = 1
    #1#2%
  \or % power = 2
    \ifx#1-%
      \InCa@Mul#2!#2!%
    \else
      \InCa@Mul#1#2!#1#2!%
    \fi
  \else
    \ifcase#1#2 % basis = 0, power <> 0
      0%
      \ifx#3-% power < 0
        0\IntCalcError:DivisionByZero%
      \fi
    \or
      1% basis = 1
    \else
      \ifnum#1#2=\m@ne % basis = -1
        \ifodd#3#4 %
          -%
        \fi
        1%
      \else % |basis| > 1
        \ifx#3-% power < 0
          0%
        \else % power > 2
          \ifx#1-% basis < 0
            \ifodd#3#4 %
              -%
            \fi
            \InCa@PowRec#2!#3#4!1!%
          \else
            \InCa@PowRec#1#2!#3#4!1!%
          \fi
        \fi
      \fi
    \fi
  \fi
}
\def\InCa@PowRec#1!#2!#3!{%
  \ifnum#2=\@ne
    \ifnum#1>#3 %
      \InCa@Mul#1!#3!%
    \else
      \InCa@Mul#3!#1!%
    \fi
  \else
    \expandafter\InCa@PowRec
    \number\InCa@Mul#1!#1!\expandafter!%
    \number\intcalcShr{#2}\expandafter!%
    \number
    \ifodd#2 %
      \ifnum#1>#3 %
        \InCa@Mul#1!#3!%
      \else
        \InCa@Mul#3!#1!%
      \fi
    \else
      #3%
    \fi
    \expandafter!%
  \fi
}
\def\intcalcDiv#1#2{%
  \number\expandafter\InCa@Div
  \number\number#1\expandafter!%
  \number#2! %
}
\def\InCa@Div#1!#2!{%
  \ifcase#2 %
    0\IntCalcError:DivisionByZero%
  \else
    \ifcase#1 %
      0%
    \else
      \expandafter\InCa@DivSwitch
      \number#1\expandafter!%
      \number#2!%
    \fi
  \fi
}
\def\InCa@Temp#1{%
  \def\IntCalcDiv##1!##2!{%
    \number
    \ifcase##2 %
      0\IntCalcError:DivisionByZero%
    \else
      \ifcase##1 %
        0%
      \else
        \InCa@@Div##1!##2!%
      \fi
    \fi
    #1%
  }%
}
\InCa@Temp{ }%
\def\InCa@DivSwitch#1!#2!{%
  \ifnum#1<\z@
    \ifnum#2<\z@
      \expandafter\InCa@@Div\number-#1\expandafter!%
      \@gobble#2!%
    \else
      -%
      \expandafter\InCa@@Div\@gobble#1!#2!%
    \fi
  \else
    \ifnum#2<\z@
      -%
      \expandafter\InCa@@Div\number#1\expandafter!%
      \@gobble#2!%
    \else
      \InCa@@Div#1!#2!%
    \fi
  \fi
}
\def\InCa@@Div#1!#2!{%
  \ifnum#1>#2 %
    \ifcase#2 % 0 already catched
?     \IntCalcError:ThisCannotHappen%
    \or % 1
      #1%
    \or % 2
      \InCa@Shr#1!%
    \else
      \InCa@DivStart!#1!#2!#2!%
    \fi
  \else
    \ifnum#1=#2 %
      1%
    \else
      0%
    \fi
  \fi
}
\def\InCa@DivStart#1!#2#3!#4#5{%
  \ifx#5!%
    \@ReturnAfterElseFi{%
      \InCa@DivStartI{#1#2}#3=!%
    }%
  \else
    \@ReturnAfterFi{%
      \InCa@DivStart{#1#2}!#3!#5%
    }%
  \fi
}
\def\InCa@DivStartI#1!#2!{%
  \expandafter\InCa@DivStartII
  \number#2\expandafter\expandafter\expandafter!%
  \intcalcShl{#2}!%
  #1!%
}
\def\InCa@DivStartII#1!#2!{%
  \expandafter\InCa@DivStartIII
  \number#1\expandafter!%
  \number#2\expandafter\expandafter\expandafter!%
  \intcalcShl{#2}!%
}
\def\InCa@DivStartIII#1!#2!#3!{%
  \expandafter\InCa@DivStartIV
  \number#1\expandafter!%
  \number#2\expandafter!%
  \number#3\expandafter!%
  \number\InCa@Add#3!#2!\expandafter\expandafter\expandafter!%
  \intcalcShl{#3}!%
}
\def\InCa@DivStartIV#1!#2!#3!#4!#5!#6!{%
  \InCa@ProcessDiv#6!#1!#2!#3!#4!#5!/%
}
\def\InCa@ProcessDiv#1#2#3!#4!#5!#6!#7!#8!#9/{%
  #9%
  \ifnum#1<#4 % 0
    0%
    \ifx#2=%
    \else
      \InCa@ProcessDiv{#1#2}#3!#4!#5!#6!#7!#8!%
    \fi
  \else % 1-9
    \ifnum#1<#5 % 1
      1%
      \ifx#2=%
      \else
        \expandafter\InCa@ProcessDiv\expandafter{%
          \number\InCa@Sub#1!#4!%
          #2%
        }#3!#4!#5!#6!#7!#8!%
      \fi
    \else % 2-9
      \ifnum#1<#7 % 2 3 4 5
        \ifnum#1<#6 % 2 3
          \@ReturnAfterElseFi{%
            \expandafter\InCa@@ProcessDiv
            \number\InCa@Sub#1!#5!!%
            23%
          }%
        \else % 4 5
          \@ReturnAfterFi{%
            \expandafter\InCa@@ProcessDiv
            \number\InCa@Sub#1!#6!!%
            45%
          }%
        \fi
        #2#3!#4!#5!#6!#7!#8!%
      \else % 6 7 8 9
        \ifnum#1<#8 % 6 7
          \@ReturnAfterElseFi{%
            \expandafter\InCa@@ProcessDiv
            \number\InCa@Sub#1!#7!!%
            67%
          }%
        \else % 8 9
          \@ReturnAfterFi{%
            \expandafter\InCa@@ProcessDiv
            \number\InCa@Sub#1!#8!!%
            89%
          }%
        \fi
        #2#3!#4!#5!#6!#7!#8!%
      \fi
    \fi
  \fi
  \ifx#2=%
    \expandafter\@gobble
  \fi
  /%
}
\def\InCa@@ProcessDiv#1!#2#3#4#5!#6!{%
  \ifnum#1<#6 %
    #2%
    \@ReturnAfterElseFi{%
      \ifx#4=%
        \expandafter\InCa@CleanupIV
      \else
        \@ReturnAfterFi{%
          \InCa@ProcessDiv{#1#4}#5!#6!%
        }%
      \fi
    }%
  \else
    #3%
    \@ReturnAfterFi{%
      \ifx#4=%
        \expandafter\InCa@CleanupIV
      \else
        \@ReturnAfterFi{%
          \expandafter\InCa@ProcessDiv\expandafter{%
            \number\InCa@Sub#1!#6! %
            #4%
          }#5!#6!%
        }%
      \fi
    }%
  \fi
}
\def\InCa@CleanupIV#1!#2!#3!#4!{}
\def\intcalcMod#1#2{%
  \number\expandafter\InCa@Mod
  \number\number#1\expandafter!%
  \number#2! %
}
\def\InCa@Mod#1!#2!{%
  \ifcase#2 %
    0\IntCalcError:DivisionByZero%
  \else
    \ifnum#2<\z@
      -%
      \expandafter\InCa@Mod
      \number-#1\expandafter!%
      \number-#2!%
    \else
      \ifcase#1 %
        0%
      \else
        \ifcase#2 % 0 already catched
?         \IntCalcError:ThisCannotHappen%
        \or % 1
          0%
        \or % 2
          \ifodd#1 1\else 0\fi
        \else
          \ifnum#1<\z@
            \expandafter\InCa@ModShift
            \number-%
              \expandafter\InCa@Sub
              \number\@gobble#1\expandafter!%
              \number\intcalcMul{#2}{%
                \expandafter\InCa@Div\@gobble#1!#2!%
              }!%
            !#2!%
          \else
            \expandafter\InCa@Sub\number#1\expandafter!%
            \number\intcalcMul{#2}{\InCa@Div#1!#2!}!%
          \fi
        \fi
      \fi
    \fi
  \fi
}
\def\InCa@Temp#1{%
  \def\IntCalcMod##1!##2!{%
    \number
    \ifcase##2 %
      0\IntCalcError:DivisionByZero%
    \else
      \ifcase##1 %
        0%
      \else
        \ifcase##2 % 0 already catched
?         \IntCalcError:ThisCannotHappen
        \or % 1
          0%
        \or % 2
          \ifodd ##1 1\else 0\fi
        \else
          \expandafter\InCa@Sub\number##1\expandafter!%
          \number\intcalcMul{##2}{\InCa@Div##1!##2!}!%
        \fi
      \fi
    \fi
    #1%
  }%
}
\InCa@Temp{ }%
\def\InCa@ModShift#1!#2!{%
  \ifnum#1<\z@
    \expandafter\InCa@Sub\number#2\expandafter!%
    \@gobble#1!%
  \else
    #1%
  \fi
}
\def\InCa@Empty{}
\expandafter\ifx\csname @gobble\endcsname\relax
  \long\def\@gobble#1{}%
\fi
\long\def\@ReturnAfterFi#1\fi{\fi#1}%
\long\def\@ReturnAfterElseFi#1\else#2\fi{\fi#1}%
\InCa@AtEnd%
\endinput
%%
%% End of file `intcalc.sty'.
