diff options
author | Karl Berry <karl@freefriends.org> | 2008-09-14 01:14:49 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2008-09-14 01:14:49 +0000 |
commit | 72a95c88cc9c66ed8fff4aae20fa2fe4afaeca7a (patch) | |
tree | f5d4ffb25e2984dd83645787bc543f8067063b35 /Master/texmf-dist/doc/generic/xlop | |
parent | 2ed8df7c4a2430bf6cbda5257d9bded2389022e6 (diff) |
xlop.tex in runtime
git-svn-id: svn://tug.org/texlive/trunk@10589 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/generic/xlop')
-rw-r--r-- | Master/texmf-dist/doc/generic/xlop/xlop.tex | 3948 |
1 files changed, 0 insertions, 3948 deletions
diff --git a/Master/texmf-dist/doc/generic/xlop/xlop.tex b/Master/texmf-dist/doc/generic/xlop/xlop.tex deleted file mode 100644 index dea98da45d0..00000000000 --- a/Master/texmf-dist/doc/generic/xlop/xlop.tex +++ /dev/null @@ -1,3948 +0,0 @@ -\def\fileversion{0.22} -\def\filedate{2006/01/04} -%% -%% xlop.tex: -%% eXtra Large OPeration macros for Generic TeX. -%% See `user.pdf' for documentation; -%% `hacker.pdf' for explanation. -%% -%% Copyright 2005,2006, by Jean-C\^ome Charpentier -%% Jean-Come.Charpentier@wanadoo.fr -%% -%% This program may be distributed and/or modified under the -%% conditions of the LaTeX Project Public License, either version 1.3 -%% of this license or (at your option) any later version. -%% 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 2003/12/01 or later. - -\csname xlopLoaded\endcsname -\let\xlopLoaded\endinput -\edef\opAtCode{\the\catcode`\@} -\catcode`\@=11\relax -\newcount\count@z -\newcount\count@i -\newcount\count@ii -\newcount\count@iii -\newcount\count@iv -\newcount\count@v -\newtoks\op@currentstyle -\expandafter\ifx\csname @latexerr\endcsname\relax -\long\def\@ifundefined#1#2#3{% - \expandafter\ifx\csname #1\endcsname\relax - #2% - \else - #3% - \fi} -\def\@gobble#1{} -\def\@namedef#1{\expandafter\def\csname #1\endcsname} -\def\@nameuse#1{\csname #1\endcsname} -\def\typeout#1{\immediate\write\@unused{#1}} -\alloc@7\write\chardef\sixt@@n\@unused -\def\@spaces{\space\space\space\space} -\def\@ifnextchar#1#2#3{% - \let\@tempe#1\def\@tempa{#2}\def\@tempb{#3}\futurelet\@tempc\@ifnch} -\def\@ifnch{% - \ifx\@tempc\@sptoken - \let\@tempd\@xifnch - \else - \ifx\@tempc\@tempe - \let\@tempd\@tempa - \else - \let\@tempd\@tempb - \fi - \fi - \@tempd -} -\begingroup -\def\:{\global\let\@sptoken= } \: -\def\:{\@xifnch} \expandafter\gdef\: {\futurelet\@tempc\@ifnch} -\endgroup -\fi %LaTeX-like -\def\@nameedef#1{\expandafter\edef\csname #1\endcsname} -\def\@namexdef#1{\expandafter\xdef\csname #1\endcsname} -\typeout{`xlop' v\fileversion\space\space <\filedate> (jcc)} -\newif\ifop@error -\def\op@error{% - \begingroup - \global\op@errortrue - \newlinechar`\^^J - \op@@error -} -\def\op@@error#1#2{% - \xdef\op@errortext{#1}% - \xdef\op@errorhelp{#2}% - \endgroup -} -\def\op@errorwrite{% - \global\op@errorfalse - \begingroup - \newlinechar`\^^J - \expandafter\errhelp\expandafter{\op@errorhelp}% - \typeout{% - xlop error. \space See documentation for further information.^^J - \@spaces\@spaces\@spaces\@spaces - Type \space H <return> \space for immediate help.}% - \errmessage{\op@errortext}% - \endgroup -} -\def\op@warning{% - \begingroup - \newlinechar`\^^J - \op@@warning -} -\def\op@@warning#1{% - \typeout{xlop warning. - #1^^J\@spaces See documentation for further information.^^J}% - \endgroup -} -\let\@nil\relax -\def\opset#1{% - \Pop@set#1,\@nil - \ifop@error\op@errorwrite\fi - \ignorespaces -} -\def\Pop@set#1,{% - \Pop@@set#1==\@nil - \@ifnextchar\@nil{\@gobble}{\Pop@set}% -} -\def\Pop@@set#1=#2=#3\@nil{% - \@ifundefined{pOP@#1}% - {\Pop@@@set#1.={#2}} - {\@nameuse{pOP@#1}{#2}}% -} -\def\Pop@@@set#1.#2=#3{% - \@ifundefined{pOP@#1}% - {\op@error{Parameter `#1' not defined.}% - {\space\space Perhaps you have mispelling parameter!^^J - \space Are you sure about `#1'?^^J}}% - {\@nameuse{pOP@#1}[#2]{#3}}% -} -\def\op@string@lpar{(} -\def\op@string@rpar{)} -\def\op@string@comma{,} -\def\op@string@abs{abs} -\def\op@string@add{add} -\def\op@string@ceil{ceil} -\def\op@string@div{div} -\def\op@string@floor{floor} -\def\op@string@gcd{gcd} -\def\op@string@idiv{idiv} -\def\op@string@integer{integer} -\def\op@string@mod{mod} -\def\op@string@mul{mul} -\def\op@string@neg{neg} -\def\op@string@power{power} -\def\op@string@rest{rest} -\def\op@string@round{round} -\def\op@string@sub{sub} - -\def\op@string@all{all} -\def\op@string@american{american} -\def\op@string@both{both} -\def\op@string@bottom{bottom} -\def\op@string@center{center} -\def\op@string@decimal{decimal} -\def\op@string@delete{delete} -\def\op@string@display{display} -\def\op@string@divisor{divisor} -\def\op@string@error{error} -\def\op@string@false{false} -\def\op@string@french{french} -\def\op@string@last{last} -\def\op@string@left{left} -\def\op@string@none{none} -\def\op@string@nonzero{nonzero} -\def\op@string@right{right} -\def\op@string@russian{russian} -\def\op@string@shift{shift} -\def\op@string@silent{silent} -\def\op@string@strike{strike} -\def\op@string@text{text} -\def\op@string@top{top} -\def\op@string@true{true} -\def\op@string@warning{warning} - -\def\pOP@afterperiodsymbol#1{\def\op@afterperiodsymbol{#1}} -\def\pOP@approxsymbol#1{\def\op@approxsymbol{#1}} -\def\pOP@equalsymbol#1{\def\op@equalsymbol{#1}} -\def\pOP@addsymbol#1{\def\op@addsymbol{#1}} -\def\pOP@subsymbol#1{\def\op@subsymbol{#1}} -\def\pOP@mulsymbol#1{\def\op@mulsymbol{#1}} -\def\pOP@divsymbol#1{\def\op@divsymbol{#1}} -\def\pOP@decimalsepsymbol#1{\def\op@decimalsepsymbol{{#1}}} -\def\pOP@strikedecimalsepsymbol#1{\def\op@strikedecimalsepsymbol{#1}} -\def\pOP@shiftintermediarysymbol#1{\def\op@shiftintermediarysymbol{#1}} -\def\pOP@displayshiftintermediary#1{\edef\@tempa{#1}% - \ifx\@tempa\op@string@shift - \let\op@displayshiftintermediary\op@string@shift - \else\ifx\@tempa\op@string@all - \let\op@displayshiftintermediary\op@string@all - \else\ifx\@tempa\op@string@none - \let\op@displayshiftintermediary\op@string@none - \else - \op@error{Parameter displayshiftintermediary accept only `shift', - `all', and `none'.^^J \space Here, the value is `#1'}% - {Value must be `shift', `all', or `none'}% - \fi\fi\fi -} -\def\pOP@voperation#1{\edef\@tempa{#1}% - \ifx\@tempa\op@string@bottom - \let\op@voperation\op@string@bottom - \else\ifx\@tempa\op@string@center - \let\op@voperation\op@string@center - \else\ifx\@tempa\op@string@top - \let\op@voperation\op@string@top - \else - \op@error{Parameter voperation accept only `top', `center', - and `bottom'.^^J \space Here, the value is `#1'}% - {Value must be `top', `center', or `bottom'}% - \fi\fi\fi -} -\def\pOP@voperator#1{\edef\@tempa{#1}% - \ifx\@tempa\op@string@top - \let\op@voperator\op@string@top - \else\ifx\@tempa\op@string@bottom - \let\op@voperator\op@string@bottom - \else\ifx\@tempa\op@string@center - \let\op@voperator\op@string@center - \else - \op@error{Parameter voperator accept only `top', `center', - and `bottom'.^^J \space Here, the value is `#1'}% - {Value must be `top', `center', or `bottom'}% - \fi\fi\fi -} -\def\pOP@hfactor#1{\edef\@tempa{#1}% - \ifx\@tempa\op@string@right - \let\op@hfactor\op@string@right - \else\ifx\@tempa\op@string@decimal - \let\op@hfactor\op@string@decimal - \else - \op@error{Parameter hfactor accept only `right' - and `decimal'.^^J \space Here, the value is `#1'}% - {Value must be `right' or `decimal'}% - \fi\fi -} -\def\pOP@vruleperiod#1{\def\op@vruleperiod{#1}} -\newif\ifop@dividendbridge -\def\pOP@dividendbridge#1{\edef\@tempa{#1}% - \edef\@tempa{#1}% - \ifx\@tempa\op@string@false - \op@dividendbridgefalse - \else\ifx\@tempa\op@string@true - \op@dividendbridgetrue - \else\ifx\@tempa\empty - \op@dividendbridgetrue - \else - \op@error{Parameter dividendbridge accept only `true' and `false'.^^J - \space Here, the value is `#1'}% - {Value must be `true', or `false', or an empty value}% - \fi\fi\fi -} -\def\pOP@shiftdecimalsep#1{\edef\@tempa{#1}% - \ifx\@tempa\op@string@none - \let\op@shiftdecimalsep\op@string@none - \else\ifx\@tempa\op@string@divisor - \let\op@shiftdecimalsep\op@string@divisor - \else\ifx\@tempa\op@string@both - \let\op@shiftdecimalsep\op@string@both - \else - \op@error{Parameter shiftdecimalsep accept only `none', `divisor', - and `both'.^^J \space Here, the value is `#1'}% - {Value must be `none', `divisor', or `both'}% - \fi\fi\fi -} -\def\pOP@maxdivstep#1{\edef\op@maxdivstep{#1}} -\def\pOP@safedivstep#1{\edef\op@safedivstep{#1}} -\newif\ifop@period -\def\pOP@period#1{\edef\@tempa{#1}% - \ifx\@tempa\op@string@false - \op@periodfalse - \else\ifx\@tempa\op@string@true - \op@periodtrue - \else\ifx\@tempa\empty - \op@periodtrue - \else - \op@error{Parameter period accept only `true' and `false'.^^J - \space Here, the value is `#1'}% - {Value must be `true', or `false', or an empty value}% - \fi\fi\fi -} -\newif\ifop@deletezero -\def\pOP@deletezero#1{\edef\@tempa{#1}% - \ifx\@tempa\op@string@false - \op@deletezerofalse - \else\ifx\@tempa\op@string@true - \op@deletezerotrue - \else\ifx\@tempa\empty - \op@deletezerotrue - \else - \op@error{Parameter deletezero accept only `true' and `false'.^^J - \space Here, the value is `#1'}% - {Value must be `true', or `false', or an empty value}% - \fi\fi\fi -} -\newif\ifop@carryadd -\def\pOP@carryadd#1{\edef\@tempa{#1}% - \ifx\@tempa\op@string@false - \op@carryaddfalse - \else\ifx\@tempa\op@string@true - \op@carryaddtrue - \else\ifx\@tempa\empty - \op@carryaddtrue - \else - \op@error{Parameter carryadd accept only `true' and `false'.^^J - \space Here, the value is `#1'}% - {Value must be `true', or `false', or an empty value}% - \fi\fi\fi -} -\newif\ifop@carrysub -\def\pOP@carrysub#1{\edef\@tempa{#1}% - \ifx\@tempa\op@string@false - \op@carrysubfalse - \else\ifx\@tempa\op@string@true - \op@carrysubtrue - \else\ifx\@tempa\empty - \op@carrysubtrue - \else - \op@error{Parameter carrysub accept only `true' and `false'.^^J - \space Here, the value is `#1'}% - {Value must be `true', or `false', or an empty value}% - \fi\fi\fi -} -\def\pOP@offsetcarry#1{\edef\op@offsetcarry{#1}} -\def\pOP@style#1{\edef\@tempa{#1}% - \ifx\@tempa\op@string@display - \let\op@style\op@string@display - \else\ifx\@tempa\op@string@text - \let\op@style\op@string@text - \else - \op@error{Parameter style accept only `display' and `text'.^^J - \space Here, the value is `#1'}% - {Value must be `display' or `text'}% - \fi\fi -} -\def\pOP@displayintermediary#1{\edef\@tempa{#1}% - \ifx\@tempa\op@string@all - \let\op@displayintermediary\op@string@all - \else\ifx\@tempa\op@string@nonzero - \let\op@displayintermediary\op@string@nonzero - \else\ifx\@tempa\op@string@none - \let\op@displayintermediary\op@string@none - \else - \op@error{Parameter style accept only `all', `none', and `nonzero'.^^J - \space Here, the value is `#1'}% - {Value must be `all', `none', or `nonzero'}% - \fi\fi\fi -} -\newif\ifop@lastcarry -\def\pOP@lastcarry#1{\edef\@tempa{#1}% - \ifx\@tempa\op@string@false - \op@lastcarryfalse - \else\ifx\@tempa\op@string@true - \op@lastcarrytrue - \else\ifx\@tempa\empty - \op@lastcarrytrue - \else - \op@error{Parameter lastcarry accept only `true' and `false'.^^J - \space Here, the value is `#1'}% - {Value must be `true', or `false', or an empty value}% - \fi\fi\fi -} -\def\pOP@parenthesisnegative#1{\edef\@tempa{#1}% - \ifx\@tempa\op@string@all - \let\op@parenthesisnegative\op@string@all - \else\ifx\@tempa\op@string@last - \let\op@parenthesisnegative\op@string@last - \else\ifx\@tempa\op@string@none - \let\op@parenthesisnegative\op@string@none - \else - \op@error{Parameter parenthesisnegative accept only `all', `last' - and `none'.^^J - \space Here, the value is `#1'}% - {Value must be `all', `last', or `none'}% - \fi\fi\fi -} -\newdimen\opcolumnwidth -\def\pOP@columnwidth#1{\opcolumnwidth=#1\relax} -\newdimen\oplineheight -\newbox\op@strutbox -\def\pOP@lineheight#1{\oplineheight=#1\relax - \setbox\op@strutbox=\hbox{% - \vrule height.708333\oplineheight - depth .291667\oplineheight - width\z@}% -} -\def\op@strut{\relax\ifmmode - \copy\op@strutbox - \else - \unhcopy\op@strutbox - \fi -} -\newdimen\op@decimalsepwidth -\def\pOP@decimalsepwidth#1{\op@decimalsepwidth=#1} -\newdimen\op@decimalsepoffset -\def\pOP@decimalsepoffset#1{\op@decimalsepoffset=#1} -\newdimen\op@hrulewidth -\def\pOP@hrulewidth#1{\op@hrulewidth=#1\relax} -\newdimen\op@vrulewidth -\def\pOP@vrulewidth#1{\op@vrulewidth=#1\relax} -\def\pOP@behaviorsub#1{\edef\@tempa{#1}% - \ifx\@tempa\op@string@warning - \let\op@behaviorsub\op@string@warning - \else\ifx\@tempa\op@string@error - \let\op@behaviorsub\op@string@error - \else\ifx\@tempa\op@string@silent - \let\op@behaviorsub\op@string@silent - \else - \op@error{Parameter behaviorsub accept only `warning', `error' - and `silent'.^^J - \space Here, the value is `#1'}% - {Value must be `warning', `error', or `silent'}% - \fi\fi\fi -} -\def\pOP@country#1{\edef\@tempa{#1}% - \ifx\@tempa\op@string@french - \let\op@country\op@string@french - \else\ifx\@tempa\op@string@american - \let\op@country\op@string@american - \else\ifx\@tempa\op@string@russian - \let\op@country\op@string@russian - \else - \op@error{Parameter contry accept only some values.^^J - \space Value `#1' isn't a valid country for xlop}% - {For now, value must be `french', `russian', or `american'}% - \fi\fi\fi -} -\def\pOP@operandstyle{% - \@ifnextchar[{\pOP@@operandstyle}{\pOP@@operandstyle[0.]}% -} -\def\pOP@@operandstyle[#1.]#2{% - \@namedef{op@operandstyle.#1}{#2}% -} -\def\pOP@carrystyle{% - \@ifnextchar[{\pOP@@carrystyle}{\pOP@@carrystyle[0.]}% -} -\def\pOP@@carrystyle[#1.]#2{% - \@namedef{op@carrystyle.#1}{#2}% -} -\def\pOP@resultstyle{% - \@ifnextchar[{\pOP@@resultstyle}{\pOP@@resultstyle[0.]}% -} -\def\pOP@@resultstyle[#1.]#2{% - \@namedef{op@resultstyle.#1}{#2}% -} -\def\pOP@intermediarystyle{% - \@ifnextchar[{\pOP@@intermediarystyle}{\pOP@@intermediarystyle[0.]}% -} -\def\pOP@@intermediarystyle[#1.]#2{% - \@namedef{op@intermediarystyle.#1}{#2}% -} -\def\pOP@remainderstyle{% - \@ifnextchar[{\pOP@@remainderstyle}{\pOP@@remainderstyle[0.]}% -} -\def\pOP@@remainderstyle[#1.]#2{% - \@namedef{op@remainderstyle.#1}{#2}% -} -\def\pOP@nil#1{} - -\opset{afterperiodsymbol=$\ldots$,approxsymbol=$\approx$, - equalsymbol={$=$},addsymbol=$+$,subsymbol=$-$, - mulsymbol=$\times$,divsymbol=$\div$, - decimalsepsymbol=.,strikedecimalsepsymbol=, - shiftintermediarysymbol=$\cdot$,displayshiftintermediary=shift, - voperation=bottom,voperator=center, - hfactor=right,vruleperiod=-0.2,dividendbridge=false, - shiftdecimalsep=both,maxdivstep=10,safedivstep=50,period=false, - deletezero=true,carryadd=true,carrysub=false,offsetcarry=-0.35, - style=display,displayintermediary=none,lastcarry=false, - parenthesisnegative=none,columnwidth=2ex,lineheight=\baselineskip, - decimalsepwidth=0pt,decimalsepoffset=0pt, - hrulewidth=0.4pt,vrulewidth=0.4pt, - behaviorsub=silent,country=french, - operandstyle=,resultstyle=,remainderstyle=, - intermediarystyle=} -\expandafter\ifx\csname @latexerr\endcsname\relax - \opset{carrystyle=\sevenrm} -\else - \opset{carrystyle=\scriptsize} -\fi - -\count@z=`\0 \edef\op@numbegin{\the\count@z} -\count@z=`\9 \edef\op@numend{\the\count@z} -\count@z=`\+ \edef\op@plus{\the\count@z} -\count@z=`\- \edef\op@minus{\the\count@z} -\count@z=`\* \edef\op@multiply{\the\count@z} -\count@z=`\/ \edef\op@divide{\the\count@z} -\count@z=`\: \edef\op@idivide{\the\count@z} -\count@z=`\^ \edef\op@pow{\the\count@z} -\count@z=`\. \edef\op@dot{\the\count@z} -\count@z=`\, \edef\op@comma{\the\count@z} -\count@z=`\( \edef\op@lparenthesis{\the\count@z} -\count@z=`\) \edef\op@rparenthesis{\the\count@z} -\count@z=`\ \edef\op@space{\the\count@z} -\newcount\op@parenthesis -\newcount\op@token -\newcount\op@stack -\newcount\op@stackb -\newif\ifop@in@number -\newif\ifop@in@decimal -\newif\ifop@in@name -\newif\ifop@in@sign -\newif\ifop@isdigit -\newif\ifop@isplus -\newif\ifop@isminus -\newif\ifop@isdot -\newif\ifop@iscomma -\newif\ifop@isdecimalsep -\newif\ifop@ismultiply -\newif\ifop@isdivide -\newif\ifop@isidivide -\newif\ifop@ispower -\newif\ifop@islparenthesis -\newif\ifop@isrparenthesis -\newif\ifop@isspace -\newif\ifop@isother - -\newif\ifopgt -\newif\ifopge -\newif\ifopeq -\newif\ifopneq -\newif\ifople -\newif\ifoplt -\newif\ifop@again -\newif\ifop@carry -\def\op@testchar#1{% - \op@isdigitfalse - \op@isplusfalse - \op@isminusfalse - \op@isdecimalsepfalse - \count@z=`#1\relax - \ifnum\count@z=\op@plus\relax - \op@isplustrue - \else\ifnum\count@z=\op@minus\relax - \op@isminustrue - \else\ifnum\count@z=\op@dot\relax - \op@isdecimalseptrue - \else\ifnum\count@z=\op@comma\relax - \op@isdecimalseptrue - \else\ifnum\count@z<\op@numbegin\relax - \else\ifnum\count@z>\op@numend\relax - \else - \op@isdigittrue - \fi\fi\fi\fi\fi\fi -} -\def\op@split#1#2{% - \begingroup - \edef\op@arg{#1}% - \expandafter\op@readnumber\op@arg\@nil - \ifop@error - \op@error{Number name `#1' is undefined}% - {See documentation about number name}% - \let\next\relax - \let\op@arg\relax - \else - \edef\op@name{#2}% - \op@length - \count@i=\@nameuse{OP@\op@name @w}\relax - \edef\op@arg{\op@arg.}% - \let\next\op@@split - \fi - \expandafter\next\op@arg\@nil - \endgroup -} -\def\op@@split#1#2\@nil{% - \ifnum\count@i>0 - \edef\op@argi{#1}% - \edef\op@argii{#2}% - \let\next\op@@split - \expandafter\op@testchar\op@argi - \ifop@isdigit - \@namexdef{OP@\op@name @\the\count@i}{\op@argi}% - \advance\count@i by -1 - \fi - \else - \let\next\relax - \let\op@argii\relax - \fi - \expandafter\next\op@argii\@nil -} -\def\op@readnumber#1#2\@nil{% - \op@testchar{#1}% - \ifop@isdigit \else - \ifop@isplus \else - \ifop@isminus \else - \ifop@isdecimalsep \else - \@ifundefined{Op@#1#2}% - {\global\op@errortrue}% - {\edef\op@arg{\@nameuse{Op@#1#2}}}% - \fi\fi\fi\fi -} -\def\op@length{% - \begingroup - \expandafter\op@@length\op@arg\@nil - \ifnum\count@i=0 - \count@i=1 - \xdef\op@arg{0\op@arg}% - \fi - \@namexdef{OP@\op@name @i}{\the\count@i}% - \@namexdef{OP@\op@name @d}{\the\count@ii}% - \advance\count@i by \count@ii - \@namexdef{OP@\op@name @w}{\the\count@i}% - \endgroup -} -\def\op@@length#1#2\@nil{% - \edef\op@argi{#1}% - \edef\op@argii{#2}% - \expandafter\op@testchar\op@argi - \ifop@isdigit - \@namexdef{OP@\op@name @s}{0}% - \count@i=1 - \count@ii=0 - \ifx\empty\op@argii - \let\next\relax - \let\op@argii\relax - \else - \let\next\op@length@after@digit - \fi - \else \ifop@isplus - \@namexdef{OP@\op@name @s}{0}% - \let\next\op@length@after@sign - \else \ifop@isminus - \@namexdef{OP@\op@name @s}{1}% - \let\next\op@length@after@sign - \else \ifop@isdecimalsep - \@namexdef{OP@\op@name @s}{0}% - \count@i=0 - \count@ii=0 - \let\next\op@length@after@decimalsep - \else - \op@error{\op@argi\op@argii\space isn't a valid number}% - {See documentation for syntax of valid number}% - \let\next\relax - \let\op@argii\relax - \fi\fi\fi\fi - \ifx\empty\op@argii - \op@error{\op@argi\space isn't a valid number}% - {See documentation for syntax of valid number}% - \let\next\relax - \let\op@argii\relax - \fi - \expandafter\next\op@argii\@nil -} -\def\op@length@after@digit#1#2\@nil{% - \edef\op@argi{#1}% - \edef\op@argii{#2}% - \expandafter\op@testchar\op@argi - \ifop@isdigit - \advance\count@i by 1 - \let\next\op@length@after@digit - \else \ifop@isdecimalsep - \let\next\op@length@after@decimalsep - \else - \op@error{#1#2 not allowed here. \space I forget it}% - {See documentation for valid number. Characters before - are OK}% - \let\next\relax - \let\op@argii\relax - \fi\fi - \ifx\empty\op@argii - \let\next\relax - \fi - \expandafter\next\op@argii\@nil -} -\def\op@length@after@sign#1#2\@nil{% - \edef\op@argi{#1}% - \edef\op@argii{#2}% - \expandafter\op@testchar\op@argi - \ifop@isplus - \let\next\op@length@after@sign - \else \ifop@isminus - \ifnum\@nameuse{OP@\op@name @s}=0 - \@namexdef{OP@\op@name @s}{1}% - \else - \@namexdef{OP@\op@name @s}{0}% - \fi - \let\next\op@length@after@sign - \else \ifop@isdecimalsep - \ifx\empty\op@argii - \op@error{#1\space isn't a valid number}% - {See documentation for syntax of valid number}% - \let\next\relax - \else - \count@i=0 - \count@ii=0 - \let\next\op@length@after@decimalsep - \fi - \else \ifop@isdigit - \count@i=1 - \count@ii=0 - \ifx\empty\op@argii - \let\next\relax - \else - \let\next\op@length@after@digit - \fi - \fi\fi\fi\fi - \expandafter\next\op@argii\@nil -} -\def\op@length@after@decimalsep#1#2\@nil{% - \edef\op@argi{#1}% - \edef\op@argii{#2}% - \expandafter\op@testchar\op@argi - \ifop@isdigit - \advance\count@ii by 1 - \let\next\op@length@after@decimalsep - \else - \op@error{#1#2 not allowed here. \space I forget it}% - {See documentation for syntax of valid number. Characters - before is OK}% - \let\next\relax - \let\op@argii\relax - \fi - \ifx\empty\op@argii - \let\next\relax - \let\op@argii\relax - \fi - \expandafter\next\op@argii\@nil -} -\def\op@unsplit#1#2{% - \begingroup - \edef\op@name{#1}% - \ifnum\@nameuse{OP@\op@name @s}=1 - \def\op@macroname{-}% - \else - \def\op@macroname{}% - \fi - \count@z=\@nameuse{OP@\op@name @i}\relax - \count@i=\@nameuse{OP@\op@name @w}\relax - \loop - \ifnum\count@z>0 - \edef\op@macroname{\op@macroname - \@nameuse{OP@\op@name @\the\count@i}}% - \advance\count@z by-1 - \advance\count@i by-1 - \repeat - \ifnum\count@i>0 - \edef\op@macroname{\op@macroname\op@decimalsepsymbol}% - \loop - \ifnum\count@i>0 - \edef\op@macroname{\op@macroname - \@nameuse{OP@\op@name @\the\count@i}}% - \advance\count@i by-1 - \repeat - \fi - \@namexdef{Op@#2}{\op@macroname}% - \endgroup -} -\def\oplput(#1,#2)#3{\leavevmode - \vbox to\z@{\vss\hbox{\raise #2\oplineheight \hbox to\z@{% - \kern #1\opcolumnwidth #3\hss}}}% - \ignorespaces -} -\def\oprput(#1,#2)#3{\leavevmode - \vbox to \z@{\vss\hbox{\raise #2\oplineheight \hbox to\z@{% - \hss#3\kern -#1\opcolumnwidth}}}% - \ignorespaces -} -\def\ophline(#1,#2)#3{\leavevmode - \vbox to\z@{\vss\hbox{\raise #2\oplineheight \hbox to\z@{% - \kern #1\opcolumnwidth - \vrule width#3\opcolumnwidth - depth0.5\op@hrulewidth height0.5\op@hrulewidth \hss}}}% - \ignorespaces -} -\def\opvline(#1,#2)#3{\leavevmode - \vbox to\z@{\vss\hbox{\raise #2\oplineheight \hbox to\z@{% - \kern #1\opcolumnwidth \kern-0.5\op@vrulewidth - \vrule width\op@vrulewidth depth#3\oplineheight height\z@ \hss}}}% - \ignorespaces -} -\def\op@makebox#1#2#3#4{% - \begingroup - \edef\op@name{#4}% - \dimen0=\opcolumnwidth - \count@z=#1% - \advance\count@z by-\@nameuse{OP@\op@name @i}\relax - \multiply\dimen0 by\count@z - \global\setbox0=\hbox{% - \op@strut\vrule width\dimen0 height\z@ depth\z@}% - \count@z=\@nameuse{OP@\op@name @i}\relax - \count@i=\@nameuse{OP@\op@name @w}\relax - \loop - \ifnum\count@z>0 - \op@setstyle{#3.\the\count@z}% - \global\setbox0=\hbox{\box0 - \hbox to\opcolumnwidth{\hss\the\op@currentstyle - {\@nameuse{OP@\op@name @\the\count@i}}\hss}}% - \advance\count@z by-1 - \advance\count@i by-1 - \repeat - \ifnum\count@i>0 - \op@setstyle{#3.d}% - \global\setbox0=\hbox{\box0 - \hbox to\op@decimalsepwidth{\hss - \vrule width\op@decimalsepoffset height\z@ depth\z@ - \the\op@currentstyle\op@decimalsepsymbol \hss}}% - \count@z=-1 - \loop - \ifnum\count@i>0 - \op@setstyle{#3.\the\count@z}% - \global\setbox0=\hbox{\box0 - \hbox to\opcolumnwidth{\hss\the\op@currentstyle - {\@nameuse{OP@\op@name @\the\count@i}}\hss}}% - \advance\count@z by-1 - \advance\count@i by-1 - \repeat - \fi - \dimen0=\opcolumnwidth - \count@z=#2\relax - \advance\count@z by-\@nameuse{OP@\op@name @d}\relax - \multiply\dimen0 by\count@z - \global\setbox0=\hbox{\box0 - \vrule width\dimen0 height\z@ depth\z@}% - \endgroup -} -\def\op@setstyle#1{% - \edef\op@arg{#1}% - \expandafter\op@@setstyle\op@arg..\@nil -} -\def\op@@setstyle#1.#2.#3\@nil{% - \edef\op@styleroot{#1}% - \edef\op@styleindex{#2}% - \op@setstylesubindex#3.\@nil - \ifx\empty\op@stylesubindex - \@ifundefined{op@\op@styleroot.\op@styleindex}% - {\op@currentstyle={\@nameuse{op@\op@styleroot.0}}}% - {\op@currentstyle={\@nameuse{op@\op@styleroot.\op@styleindex}}}% - \else - \@ifundefined{op@\op@styleroot.\op@styleindex.\op@stylesubindex}% - {\@ifundefined{op@\op@styleroot.\op@styleindex}% - {\op@currentstyle={\@nameuse{op@\op@styleroot.0}}}% - {\op@currentstyle={\@nameuse{op@\op@styleroot.\op@styleindex}}}% - } - {\op@currentstyle= - {\@nameuse{op@\op@styleroot.\op@styleindex.\op@stylesubindex}}}% - \fi -} -\def\op@setstylesubindex#1.#2\@nil{\def\op@stylesubindex{#1}} -\def\opdisplay{\@ifnextchar[{\op@displaypar}{\op@displaypar[nil]}} -\def\op@displaypar[#1]#2#3{% - \begingroup - \opset{#1}% - \op@split{#3}{r}% - \ifop@error - \op@errorwrite - \else - \op@display{#2}{r}% - \fi - \endgroup -} -\def\op@display#1#2{% - \op@makebox{\@nameuse{OP@#2@i}}{\@nameuse{OP@#2@d}}{#1}{#2}% - \leavevmode\box0 -} -\def\opprint#1{% - \op@split{#1}{r}% - \ifop@error - \op@errorwrite - \else - \op@unsplit{r}{@r}% - \Op@@r - \fi -} -\def\op@format#1#2#3{% - \begingroup - \count@iii=#1\relax - \count@iv=#2\relax - \count@z=\count@iv - \advance\count@z by-\@nameuse{OP@#3@d}\relax - \ifnum\count@z>0 - \count@i=\@nameuse{OP@#3@w}\relax - \advance\count@z by\count@i\relax - \loop - \@namexdef{OP@#3@\the\count@z}{\@nameuse{OP@#3@\the\count@i}}% - \advance\count@i by-1 - \advance\count@z by-1\relax - \ifnum\count@i>0 - \repeat - \loop - \@namexdef{OP@#3@\the\count@z}{0}% - \advance\count@z by-1\relax - \ifnum\count@z>0 - \repeat - \@namexdef{OP@#3@d}{\the\count@iv}% - \count@i=\@nameuse{OP@#3@i}% - \advance\count@i by\count@iv\relax - \@namexdef{OP@#3@w}{\the\count@i}% - \fi - \count@z=\count@iii - \advance\count@z by-\@nameuse{OP@#3@i}\relax - \ifnum\count@z>0 - \count@i=\@nameuse{OP@#3@w}\relax - \loop - \advance\count@i by1 - \@namexdef{OP@#3@\the\count@i}{0}% - \advance\count@z by-1\relax - \ifnum\count@z>0 - \repeat - \@namexdef{OP@#3@i}{\the\count@iii}% - \fi - \count@i=\@nameuse{OP@#3@i}\relax - \advance\count@i by\@nameuse{OP@#3@d}\relax - \@namexdef{OP@#3@w}{\the\count@i}% - \endgroup -} -\def\opunzero#1{% - \op@split{#1}{uzr}% - \ifop@error - \op@errorwrite - \else - \op@unzero{uzr}% - \op@unsplit{uzr}{#1}% - \fi -} -\def\op@unzero#1{% - \begingroup - \count@z=\@nameuse{OP@#1@i}\relax - \count@i=\@nameuse{OP@#1@w}\relax - \count@ii=\@nameuse{OP@#1@i}\relax - \loop - \ifnum\count@z>1\relax - \ifnum\@nameuse{OP@#1@\the\count@i}=0\relax - \advance\count@ii by-1 - \else - \count@z=0 - \fi - \advance\count@z by-1 - \advance\count@i by-1 - \repeat - \@namexdef{OP@#1@i}{\the\count@ii}% - \count@z=\@nameuse{OP@#1@d}\relax - \count@i=1\relax - \count@ii=0\relax - \loop - \ifnum\count@z>0\relax - \ifnum\@nameuse{OP@#1@\the\count@i}=0\relax - \advance\count@ii by1 - \advance\count@z by-1 - \advance\count@i by1 - \else - \count@z=0 - \fi - \repeat - \ifnum\count@ii>0\relax - \count@z=1\relax - \count@i=\@nameuse{OP@#1@w}\relax - \count2=\count@ii - \advance\count@ii by1 - \loop - \@namexdef{OP@#1@\the\count@z}{\@nameuse{OP@#1@\the\count@ii}}% - \ifnum\count@ii<\count@i - \advance\count@z by1 - \advance\count@ii by1 - \repeat - \count@ii=\@nameuse{OP@#1@d}% - \advance\count@ii by-\count2 - \@namexdef{OP@#1@d}{\the\count@ii}% - \fi - \ifnum\@nameuse{OP@#1@i}=1\relax - \ifnum\@nameuse{OP@#1@d}=0\relax - \ifnum\@nameuse{OP@#1@1}=0 - \@namexdef{OP@#1@s}{0}% - \fi - \fi - \fi - \count@i=\@nameuse{OP@#1@i}\relax - \advance\count@i by\@nameuse{OP@#1@d}\relax - \@namexdef{OP@#1@w}{\the\count@i}% - \endgroup -} -\def\opcopy#1#2{% - \op@split{#1}{a}% - \ifop@error - \op@errorwrite - \else - \op@unsplit{a}{#2}% - \fi -} -\def\op@copy#1#2{% - \begingroup - \@namexdef{OP@#2@w}{\@nameuse{OP@#1@w}}% - \@namexdef{OP@#2@i}{\@nameuse{OP@#1@i}}% - \@namexdef{OP@#2@d}{\@nameuse{OP@#1@d}}% - \@namexdef{OP@#2@s}{\@nameuse{OP@#1@s}}% - \count@z=\@nameuse{OP@#2@w}\relax - \loop - \ifnum\count@z>0 - \@namexdef{OP@#2@\the\count@z}{\@nameuse{OP@#1@\the\count@z}}% - \advance\count@z by-1 - \repeat - \endgroup -} -\def\opcmp#1#2{% - \op@split{#1}{ca}% - \op@split{#2}{cb}% - \ifop@error - \op@errorwrite - \else - \op@cmp{ca}{cb}% - \fi -} -\def\op@cmp#1#2{% - \begingroup - \global\opgtfalse - \global\opgefalse - \global\opeqfalse - \global\opneqfalse - \global\oplefalse - \global\opltfalse - \op@copy{#1}{ca}% - \op@unzero{ca}% - \op@copy{#2}{cb}% - \op@unzero{cb}% - \ifnum\OP@ca@s>\OP@cb@s\relax - \global\oplttrue - \global\opletrue - \global\opneqtrue - \else \ifnum\OP@ca@s<\OP@cb@s\relax - \global\opgttrue - \global\opgetrue - \global\opneqtrue - \else - \ifnum\OP@ca@i>\OP@cb@i\relax - \global\opgetrue - \global\opgttrue - \global\opneqtrue - \else \ifnum\OP@ca@i<\OP@cb@i\relax - \global\opletrue - \global\oplttrue - \global\opneqtrue - \else - \op@againtrue - \count@i=\OP@ca@w\relax - \count@ii=\OP@cb@w\relax - \loop - \ifop@again - \ifnum\@nameuse{OP@ca@\the\count@i}> - \@nameuse{OP@cb@\the\count@ii}\relax - \op@againfalse - \global\opgttrue - \global\opgetrue - \global\opneqtrue - \else \ifnum\@nameuse{OP@ca@\the\count@i}< - \@nameuse{OP@cb@\the\count@ii}\relax - \op@againfalse - \global\oplttrue - \global\opletrue - \global\opneqtrue - \else \ifnum\count@i=1\relax - \op@againfalse - \ifnum\count@ii=1\relax - \global\opeqtrue - \global\opgetrue - \global\opletrue - \else - \global\oplttrue - \global\opletrue - \global\opneqtrue - \fi - \else \ifnum\count@ii=1\relax - \op@againfalse - \global\opgttrue - \global\opgetrue - \global\opneqtrue - \fi\fi\fi\fi - \advance\count@i by-1 - \advance\count@ii by-1 - \repeat - \fi\fi - \ifnum\OP@ca@s=1\relax - \ifopneq - \ifopgt - \global\opgtfalse - \global\opgefalse - \global\oplttrue - \global\opletrue - \else - \global\opgttrue - \global\opgetrue - \global\opltfalse - \global\oplefalse - \fi - \fi - \fi - \fi\fi - \endgroup -} -\def\op@max#1#2{% - \ifnum#1>#2 - #1% - \else - #2% - \fi -} -\def\op@textoperation#1#2#3#4#5{% - \mathsurround=\z@\relax - \ifop@deletezero - \op@unzero{#1}% - \op@unzero{#3}% - \op@unzero{#5}% - \fi - \op@unsplit{#1}{@a}% - \op@unsplit{#3}{@b}% - \op@unsplit{#5}{@r}% - \ifnum\@nameuse{OP@#1@s}=1\relax - \ifx\op@parenthesisnegative\op@string@all - $(\Op@@a)$% - \else - $\Op@@a$% - \fi - \else - $\Op@@a$% - \fi - $\>$\nobreak#2$\>$\penalty\binoppenalty - \ifnum\@nameuse{OP@#3@s}=1\relax - \ifx\op@parenthesisnegative\op@string@all - $(\Op@@b)$% - \else \ifx\op@parenthesisnegative\op@string@last - $(\Op@@b)$% - \else - $\Op@@b$% - \fi\fi - \else - $\Op@@b$% - \fi - $\;$\nobreak#4$\;$\penalty\relpenalty - \ifnum\@nameuse{OP@#5@s}=1\relax - \ifx\op@parenthesisnegative\op@string@all - $(\Op@@r)$% - \else - $\Op@@r$% - \fi - \else - $\Op@@r$% - \fi -} -\def\opadd{\@ifnextchar*{\op@addstar}{\op@addnostar}} -\def\op@addstar*#1#2#3{% - \begingroup - \op@split{#1}{a}% - \op@split{#2}{b}% - \ifop@error - \op@errorwrite - \else - \ifop@deletezero - \op@unzero{a}% - \op@unzero{b}% - \fi - \ifnum\OP@a@s=0 - \ifnum\OP@b@s=0 - \xdef\op@realsymbol{\op@addsymbol}% - \op@add{a}{b}{r}% - \else - \def\OP@b@s{0}% - \op@cmp{a}{b}% - \ifopgt - \xdef\op@realsymbol{\op@subsymbol}% - \op@sub{a}{b}{r}% - \else - \xdef\op@realsymbol{\op@subsymbol}% - \op@copy{a}{r}% - \op@copy{b}{a}% - \op@copy{r}{b}% - \op@sub{a}{b}{r}% - \xdef\OP@r@s{1}% - \fi - \fi - \else - \ifnum\OP@b@s=0 - \def\OP@a@s{0}% - \op@cmp{a}{b}% - \ifopgt - \xdef\op@realsymbol{\op@subsymbol}% - \op@sub{a}{b}{r}% - \xdef\OP@r@s{1}% - \else - \xdef\op@realsymbol{\op@subsymbol}% - \op@copy{a}{r}% - \op@copy{b}{a}% - \op@copy{r}{b}% - \op@sub{a}{b}{r}% - \fi - \else - \xdef\op@realsymbol{\op@addsymbol}% - \op@add{a}{b}{r}% - \xdef\OP@r@s{1}% - \fi - \fi - \ifop@error\else - \ifop@deletezero - \op@unzero{r}% - \fi - \op@unsplit{r}{#3}% - \fi - \fi - \endgroup -} -\def\op@addnostar{\@ifnextchar[{\op@addarg}{\op@addarg[nil]}} -\def\op@addarg[#1]#2#3{% - \begingroup - \opset{#1}% - \ifx\op@style\op@string@display - \ifx\op@country\op@string@french - \op@adddisplayone{#2}{#3}% - \else \ifx\op@country\op@string@american - \op@adddisplayone{#2}{#3}% - \else \ifx\op@country\op@string@russian - \op@adddisplayone{#2}{#3}% - \else - \op@error{Country \op@country\space isn't recognize} - {For now, only `french', `american' and - `russian' are valid} - \fi\fi\fi - \else - \op@addstar*{#2}{#3}{@r}% - \op@split{#2}{a}% - \op@split{#3}{b}% - \op@split{@r}{r}% - \ifop@deletezero - \op@unzero{a}% - \op@unzero{b}% - \fi - \op@textoperation{a}{\op@addsymbol}{b}{\op@equalsymbol}{r}% - \fi - \endgroup -} -\def\op@adddisplayone#1#2{% - \op@addstar*{#1}{#2}{@r}% - \op@addsubdisplayone -} -\def\op@add#1#2#3{% - \begingroup - \global\op@carryfalse - \count@i=\op@max{\@nameuse{OP@#1@i}}{\@nameuse{OP@#2@i}}% - \count@ii=\op@max{\@nameuse{OP@#1@d}}{\@nameuse{OP@#2@d}}% - \op@format{\the\count@i}{\the\count@ii}{#1}% - \op@format{\the\count@i}{\the\count@ii}{#2}% - \@namexdef{OP@#3@i}{\the\count@i}% - \@namexdef{OP@#3@d}{\the\count@ii}% - \@namexdef{OP@#3@s}{0}% - \xdef\OP@carry@s{0}% - \xdef\OP@carry@d{0}% - \advance\count@i by\count@ii - \@namexdef{OP@#3@w}{\the\count@i}% - \xdef\OP@carry@i{\the\count@i}% - \xdef\OP@carry@w{\the\count@i}% - \count@ii=1 - \def\op@carry{0}% - \@namexdef{OP@carry@1}{ }% - \loop - \count@z=\@nameuse{OP@#1@\the\count@ii}% - \advance\count@z by\@nameuse{OP@#2@\the\count@ii}% - \advance\count@z by\op@carry\relax - \ifnum\count@z>9 - \advance\count@z by-10 - \def\op@carry{1}% - \global\op@carrytrue - \else - \def\op@carry{0}% - \fi - \@namexdef{OP@#3@\the\count@ii}{\the\count@z}% - \ifnum\count@ii<\count@i - \advance\count@ii by1\relax - \ifnum\op@carry=0 - \@namexdef{OP@carry@\the\count@ii}{ }% - \else - \@namexdef{OP@carry@\the\count@ii}{1}% - \global\op@carrytrue - \fi - \repeat - \ifnum\op@carry=1 - \advance\count@i by1 - \@namexdef{OP@#3@w}{\the\count@i}% - \@namexdef{OP@#3@\the\count@i}{1}% - \ifop@lastcarry - \@namexdef{OP@carry@w}{\the\count@i}% - \@namexdef{OP@carry@i}{\the\count@i}% - \@namexdef{OP@carry@\the\count@i}{1}% - \global\op@carrytrue - \fi - \count@i=\@nameuse{OP@#3@i}\relax - \advance\count@i by1 - \@namexdef{OP@#3@i}{\the\count@i}% - \fi - \endgroup -} -\def\opsub{\@ifnextchar*{\op@substar}{\op@subnostar}} -\def\op@substar*#1#2#3{% - \begingroup - \op@split{#1}{a}% - \op@split{#2}{b}% - \ifop@error - \op@errorwrite - \else - \ifnum\OP@a@s=0 - \ifnum\OP@b@s=0 - \op@cmp{a}{b}% - \ifopgt - \xdef\op@realsymbol{\op@subsymbol}% - \op@sub{a}{b}{r}% - \else - \ifx\op@behaviorsub\op@string@warning - \op@warning{Substraction with first operand less than - second one} - \else\ifx\op@behaviorsub\op@string@error - \op@error{Substraction with first operand less than - second one}% - {I can't do a-b with a and b positive and a<b}% - \global\op@errortrue - \fi\fi - \ifop@error\else - \xdef\op@realsymbol{\op@subsymbol}% - \op@copy{a}{r}% - \op@copy{b}{a}% - \op@copy{r}{b}% - \op@sub{a}{b}{r}% - \xdef\OP@r@s{1}% - \fi - \fi - \else - \xdef\op@realsymbol{\op@addsymbol}% - \op@add{a}{b}{r}% - \fi - \else - \ifnum\OP@b@s=0 - \xdef\op@realsymbol{\op@addsymbol}% - \op@add{a}{b}{r}% - \xdef\OP@r@s{1}% - \else - \op@cmp{a}{b}% - \ifoplt - \xdef\op@realsymbol{\op@subsymbol}% - \op@sub{a}{b}{r}% - \xdef\OP@r@s{1}% - \else - \xdef\op@realsymbol{\op@subsymbol}% - \op@copy{a}{r}% - \op@copy{b}{a}% - \op@copy{r}{b}% - \op@sub{a}{b}{r}% - \fi - \fi - \fi - \ifop@error\else - \ifop@deletezero - \op@unzero{r}% - \fi - \op@unsplit{r}{#3}% - \fi - \fi - \endgroup -} -\def\op@subnostar{\@ifnextchar[{\op@subarg}{\op@subarg[nil]}} -\def\op@subarg[#1]#2#3{% - \begingroup - \opset{#1}% - \ifx\op@style\op@string@display - \ifx\op@country\op@string@french - \op@subdisplayone{#2}{#3}% - \else \ifx\op@country\op@string@american - \op@subdisplayone{#2}{#3}% - \else \ifx\op@country\op@string@russian - \op@subdisplayone{#2}{#3}% - \else - \op@error{Country \op@country\space isn't recognize} - {For now, only `french', `american' and - `russian' are valid} - \fi\fi\fi - \else - \op@substar*{#2}{#3}{@r}% - \op@split{#2}{a}% - \op@split{#3}{b}% - \op@split{@r}{r}% - \ifop@deletezero - \op@unzero{a}% - \op@unzero{b}% - \fi - \op@textoperation{a}{\op@subsymbol}{b}{\op@equalsymbol}{r}% - \fi - \endgroup -} -\def\op@subdisplayone#1#2{% - \op@substar*{#1}{#2}{@r}% - \op@addsubdisplayone -} -\def\op@sub#1#2#3{% - \begingroup - \global\op@carryfalse - \count@i=\op@max{\@nameuse{OP@#1@i}}{\@nameuse{OP@#2@i}}\relax - \count@ii=\op@max{\@nameuse{OP@#1@d}}{\@nameuse{OP@#2@d}}\relax - \count@iii=\@nameuse{OP@#2@w}\relax - \advance\count@iii by1 - \op@format{\the\count@i}{\the\count@ii}{#1}% - \op@format{\the\count@i}{\the\count@ii}{#2}% - \@namexdef{OP@#3@i}{\the\count@i}% - \@namexdef{OP@#3@d}{\the\count@ii}% - \@namexdef{OP@#3@s}{0}% - \xdef\OP@carry@s{0}% - \xdef\OP@carry@d{0}% - \advance\count@i by\count@ii - \@namexdef{OP@#3@w}{\the\count@i}% - \xdef\OP@carry@i{\the\count@i}% - \xdef\OP@carry@w{\the\count@i}% - \count@ii=1 - \def\op@carry{0}% - \@namexdef{OP@carry@1}{ }% - \loop - \count@z=\@nameuse{OP@#1@\the\count@ii}% - \advance\count@z by-\@nameuse{OP@#2@\the\count@ii}% - \advance\count@z by-\op@carry\relax - \ifnum\count@z<0 - \advance\count@z by10 - \def\op@carry{1}% - \else - \def\op@carry{0}% - \fi - \@namexdef{OP@#3@\the\count@ii}{\the\count@z}% - \ifnum\count@ii<\count@i - \advance\count@ii by1\relax - \@namexdef{OP@carry@\the\count@ii}{ }% - \ifnum\op@carry=0 \else - \ifop@lastcarry - \@namexdef{OP@carry@\the\count@ii}{1}% - \global\op@carrytrue - \else - \ifnum\count@ii<\count@iii\relax - \@namexdef{OP@carry@\the\count@ii}{1}% - \global\op@carrytrue - \fi - \fi - \fi - \repeat - \endgroup -} -\def\op@addsubdisplayone{% - \begingroup - \ifop@error\else - \ifop@deletezero - \op@unzero{a}% - \op@unzero{b}% - \fi - \ifx\op@realsymbol\op@subsymbol - \ifnum\OP@a@d<\OP@b@d\relax - \op@format{\OP@a@i}{\OP@b@d}{a}% - \fi - \fi - \count@i=\op@max{\OP@a@i}{\OP@b@i}% - \count@i=\op@max{\the\count@i}{\OP@r@i}% - \advance\count@i by1 - \count@ii=\op@max{\OP@a@d}{\OP@b@d}% - \count@ii=\op@max{\the\count@ii}{\OP@r@d}% - \count@z=\count@i - \advance\count@z by\count@ii - \setbox1=\hbox to\count@z\opcolumnwidth{% - \ifx\op@voperator\op@string@top - \oplput(0,2){\op@realsymbol}% - \else\ifx\op@voperator\op@string@bottom - \oplput(0,1){\op@realsymbol}% - \else - \oplput(0,1.5){\op@realsymbol}% - \fi\fi - \ophline(0,0.75){\the\count@z}% - \ifnum\OP@r@d>0\relax - \oplput(\the\count@z,0.75){% - \vrule width\op@decimalsepwidth - depth0.5\op@hrulewidth height0.5\op@hrulewidth} - \fi - \ifx\op@realsymbol\op@subsymbol - \ifop@carrysub - \ifop@carry - \op@makebox{\the\count@z}{0}{carrystyle}{carry}% - \oplput(\op@offsetcarry,2){\kern\opcolumnwidth\copy0}% - \oplput(\op@offsetcarry,1){\box0}% - \fi - \fi - \fi - \vbox{% - \ifx\op@realsymbol\op@addsymbol - \ifop@carryadd - \ifop@carry - \op@makebox{\the\count@z}{0}{carrystyle}{carry}% - \hbox{\box0}% - \fi - \fi - \fi - \op@makebox{\the\count@i}{\the\count@ii}{operandstyle.1}{a}% - \hbox{\box0}% - \op@makebox{\the\count@i}{\the\count@ii}{operandstyle.2}{b}% - \hbox{\box0}% - \op@makebox{\the\count@i}{\the\count@ii}{resultstyle}{r}% - \hbox{\box0}% - }% - }% - \leavevmode - \ifx\op@voperation\op@string@center - \lower1\oplineheight\box1 - \else\ifx\op@voperation\op@string@top - \lower2\oplineheight\box1 - \else - \box1 - \fi\fi - \fi - \endgroup -} -\def\opmul{\@ifnextchar*{\op@mulstar}{\op@mulnostar}} -\def\op@mulstar*#1#2#3{% - \begingroup - \op@split{#1}{a}% - \op@split{#2}{b}% - \ifop@error - \op@errorwrite - \else - \ifop@deletezero - \op@unzero{a}% - \op@unzero{b}% - \fi - \op@mul{a}{b}{r}% - \ifop@deletezero - \op@unzero{r}% - \fi - \xdef\op@realsymbol{\op@mulsymbol}% - \ifnum\OP@a@s=\OP@b@s\else - \xdef\OP@r@s{1}% - \fi - \ifop@error\else - \op@unsplit{r}{#3}% - \fi - \fi - \endgroup -} -\def\op@mulnostar{\@ifnextchar[{\op@mularg}{\op@mularg[nil]}} -\def\op@mularg[#1]#2#3{% - \begingroup - \opset{#1}% - \ifx\op@style\op@string@display - \ifx\op@country\op@string@french - \op@muldisplayone{#2}{#3}% - \else \ifx\op@country\op@string@american - \op@muldisplayone{#2}{#3}% - \else \ifx\op@country\op@string@russian - \op@muldisplayone{#2}{#3}% - \else - \op@error{Country \op@country\space isn't recognize} - {For now, only `french', `american' and - `russian' are valid} - \fi\fi\fi - \else - \op@mulstar*{#2}{#3}{@r}% - \op@split{#2}{a}% - \op@split{#3}{b}% - \op@split{@r}{r}% - \ifop@deletezero - \op@unzero{a}% - \op@unzero{b}% - \op@unzero{r}% - \fi - \op@textoperation{a}{\op@mulsymbol}{b}{\op@equalsymbol}{r}% - \fi - \endgroup -} -\def\op@muldisplayone#1#2{% - \begingroup - \ifop@error\else - \op@split{#1}{a}% - \op@split{#2}{b}% - \ifop@deletezero - \op@unzero{a}% - \op@unzero{b}% - \fi - \op@mul{a}{b}{r}% - \ifnum\OP@b@i=1 - \expandafter\if\csname OP@b@\OP@b@w\endcsname0 - \ifnum\OP@r@i>1 - \expandafter\if\csname OP@r@\OP@r@w\endcsname0 - \count@i=\OP@r@w - \advance\count@i\m@ne - \edef\OP@r@w{\the\count@i}% - \count@i=\OP@r@i - \advance\count@i\m@ne - \edef\OP@r@i{\the\count@i}% - \fi\fi\fi\fi - \setbox1=\hbox to\OP@r@w\opcolumnwidth{% - \vbox{% - \ifx\op@hfactor\op@string@right - \count@i=\OP@r@w - \advance\count@i by-\OP@a@d - \op@makebox{\the\count@i}{\OP@a@d}{operandstyle.1}{a}% - \hbox{\box0}% - \count@i=\OP@r@w - \advance\count@i by-\OP@b@d - \op@makebox{\the\count@i}{\OP@b@d}{operandstyle.2}{b}% - \hbox{\box0}% - \else - \count@i=\OP@r@w - \count@ii=\op@max{\OP@a@d}{\OP@b@d}% - \advance\count@i by-\count@ii - \op@makebox{\the\count@i}{\the\count@ii}{operandstyle.1}{a}% - \hbox{\box0}% - \op@makebox{\the\count@i}{\the\count@ii}{operandstyle.2}{b}% - \hbox{\box0}% - \fi - \op@againtrue - \ifx\op@displayintermediary\op@string@none - \ifnum\OP@b@w=1 - \op@againfalse - \fi - \fi - \global\count@z=0\relax - \ifop@again - \count@ii=0\relax - \setbox2=\hbox{}% - \loop - \ifnum\count@ii<\OP@b@w - \advance\count@ii by1 - \count@iii=\@nameuse{OP@b@\the\count@ii}% - \count@iv=\OP@r@w - \advance\count@iv by-\count@ii - \advance\count@iv by1 - \op@makebox{\the\count@iv}{0}% - {intermediarystyle.\the\count@ii}{T\the\count@iii}% - \ifx\op@displayintermediary\op@string@all - \hbox{\box0\copy2}% - \global\advance\count@z by1 - \else - \ifnum\the\count@iii=0 - \ifx\op@displayshiftintermediary\op@string@shift - \setbox2=\hbox{\box2\hbox to\opcolumnwidth{% - \hss\op@shiftintermediarysymbol\hss}}% - \fi - \else - \hbox{\box0\copy2}% - \global\advance\count@z by1 - \ifx\op@displayshiftintermediary\op@string@shift - \setbox2=\hbox{}% - \fi - \fi - \fi - \ifx\op@displayshiftintermediary\op@string@all - \setbox2=\hbox{\box2\hbox to\opcolumnwidth{% - \hss\op@shiftintermediarysymbol\hss}}% - \fi - \repeat - \fi - \op@makebox{\OP@r@i}{\OP@r@d}{resultstyle}{r}% - \hbox{\box0}% - }% - \count@i=\OP@r@w - \ophline(-\the\count@i,0.75){\the\count@i}% - \ifnum\OP@r@d>0\relax - \oprput(-\the\count@i,0.75){% - \vrule width\op@decimalsepwidth - depth0.5\op@hrulewidth height0.5\op@hrulewidth} - \fi - \ifx\op@hfactor\op@string@right - \count@i=\op@max{\OP@a@w}{\OP@b@w}% - \else - \count@i=\op@max{\OP@a@d}{\OP@b@d}% - \advance\count@i by\op@max{\OP@a@i}{\OP@b@i}% - \fi - \advance\count@i by1\relax - \ophline(-\the\count@i,\the\count@z.75){\the\count@i}% - \ifx\op@voperator\op@string@top - \advance\count@z by2 - \oplput(-\the\count@i,\the\count@z){\op@mulsymbol}% - \advance\count@z by-2 - \else\ifx\op@voperator\op@string@bottom - \advance\count@z by1 - \oplput(-\the\count@i,\the\count@z){\op@mulsymbol}% - \advance\count@z by-1 - \else - \advance\count@z by1 - \oplput(-\the\count@i,\the\count@z.5){\op@mulsymbol}% - \advance\count@z by-1 - \fi\fi - }% - \leavevmode - \ifx\op@voperation\op@string@center - \advance\count@z by3 - \dimen0=\oplineheight - \multiply\dimen0 by\count@z - \dimen0=0.5\dimen0 - \lower\dimen0\box1 - \else\ifx\op@voperation\op@string@top - \advance\count@z by2 - \dimen0=\oplineheight - \multiply\dimen0 by\count@z - \lower\dimen0\box1 - \else - \box1 - \fi\fi - \fi - \endgroup -} -\def\op@mul#1#2#3{% - \begingroup - \op@multable{#1}% - \count@z=\@nameuse{OP@#2@w}\relax - \op@copy{zero}{mr}% - \loop - \count@iii=\@nameuse{OP@#2@\the\count@z}% - \advance\count@z by-1 - \op@copy{T\the\count@iii}{rr}% - \op@lshift{\the\count@z}{rr}% - \op@add{rr}{mr}{mr}% - \ifnum\count@z>0 - \repeat - \count@z=\@nameuse{OP@#1@d}% - \advance\count@z by\@nameuse{OP@#2@d}% - \xdef\OP@mr@d{\the\count@z}% - \count@i=\OP@mr@w - \advance\count@i by-\count@z - \ifnum\count@i>0\relax - \xdef\OP@mr@i{\the\count@i}% - \else - \xdef\OP@mr@i{1}% - \count@z=\@nameuse{OP@mr@d}% - \advance\count@z by1 - \count@i=\@nameuse{OP@mr@w}% - \@namexdef{OP@mr@w}{\the\count@z}% - \loop - \ifnum\count@i<\count@z - \advance\count@i by1 - \@namexdef{OP@mr@\the\count@i}{0}% - \repeat - \fi - \op@copy{mr}{#3}% - \endgroup -} -\def\op@multable#1{% - \op@copy{#1}{T1}% - \@namexdef{OP@T1@i}{\@nameuse{OP@T1@w}}% - \@namexdef{OP@T1@d}{0}% - \@namexdef{OP@T1@s}{0}% - \op@add{T1}{T1}{T2}% - \op@add{T1}{T2}{T3}% - \op@add{T1}{T3}{T4}% - \op@add{T1}{T4}{T5}% - \op@add{T1}{T5}{T6}% - \op@add{T1}{T6}{T7}% - \op@add{T1}{T7}{T8}% - \op@add{T1}{T8}{T9}% - \op@unzero{T1}% - \op@format{\@nameuse{OP@T1@i}}{\@nameuse{OP@T1@d}}{T0}% -} -\def\op@lshift#1#2{% - \begingroup - \count@i=#1\relax - \count@z=\@nameuse{OP@#2@w}\relax - \advance\count@i by\count@z - \@namexdef{OP@#2@w}{\the\count@i}% - \@namexdef{OP@#2@i}{\the\count@i}% - \loop - \ifnum\count@z>0 - \@namexdef{OP@#2@\the\count@i}{\@nameuse{OP@#2@\the\count@z}}% - \advance\count@z by-1 - \advance\count@i by-1 - \repeat - \loop - \ifnum\count@i>0 - \@namexdef{OP@#2@\the\count@i}{0}% - \advance\count@i by-1 - \repeat - \endgroup -} -\def\op@rshift#1#2{% - \begingroup - \count@i=#1\relax - \count@z=\@nameuse{OP@#2@w}\relax - \advance\count@z by-\count@i - \ifnum\count@z>0 - \@namexdef{OP@#2@w}{\the\count@z}% - \@namexdef{OP@#2@i}{\the\count@z}% - \@namexdef{OP@#2@d}{0}% - \@namexdef{OP@#2@s}{0}% - \advance\count@i by1\relax - \count@ii=1 - \loop - \@namexdef{OP@#2@\the\count@ii}{\@nameuse{OP@#2@\the\count@i}}% - \advance\count@i by1 - \ifnum\count@ii<\count@z - \advance\count@ii by1 - \repeat - \else - \op@copy{zero}{#2}% - \fi - \endgroup -} -\def\opdiv{\@ifnextchar*{\op@divstar}{\op@divnostar}} -\def\op@divstar*{\@ifnextchar[{\op@divstararg}{\op@divstararg[nil]}} -\def\op@divstararg[#1]#2#3#4#5{% - \begingroup - \opset{#1} - \op@split{#2}{a}% - \op@split{#3}{b}% - \ifop@error - \op@errorwrite - \else - \op@unzero{a}% - \op@unzero{b}% - \edef\op@shift{\op@max{\OP@a@d}{\OP@b@d}}% - \op@mulpowerten{a}{\op@shift}% - \op@mulpowerten{b}{\op@shift}% - \xdef\OP@a@s{0}% - \xdef\OP@b@s{0}% - \ifop@period - \op@div{1}{a}{b}{q}{r}% - \else - \op@div{0}{a}{b}{q}{r}% - \fi - \op@split{#2}{a}% - \op@split{#3}{b}% - \op@unzero{a}% - \op@unzero{b}% - \ifnum\OP@a@s=0\relax - \ifnum\OP@b@s=0\relax - \else - \xdef\OP@q@s{1}% - \fi - \else - \xdef\OP@r@s{1}% - \ifnum\OP@b@s=0\relax - \xdef\OP@q@s{1}% - \fi - \fi - \ifop@error\else - \op@unsplit{q}{#4}% - \op@unsplit{r}{#5}% - \fi - \fi - \endgroup -} -\def\op@divnostar{\@ifnextchar[{\op@divarg}{\op@divarg[nil]}} -\def\op@divarg[#1]#2#3{% - \begingroup - \opset{#1}% - \op@split{#2}{a}% - \op@split{#3}{b}% - \ifop@error - \op@errorwrite - \else - \ifx\op@style\op@string@display - \op@unzero{a}% - \op@unzero{b}% - \ifx\op@shiftdecimalsep\op@string@none - \xdef\OP@a@i{\OP@a@w}% - \xdef\OP@a@d{0}% - \xdef\OP@b@i{\OP@b@w}% - \xdef\OP@b@d{0}% - \else\ifx\op@shiftdecimalsep\op@string@divisor - \xdef\OP@a@i{\OP@a@w}% - \xdef\OP@a@d{0}% - \xdef\OP@b@i{\OP@b@w}% - \xdef\OP@b@d{0}% - \op@unzero{a}% - \op@unzero{b}% - \else - \edef\op@shift{\op@max{\OP@a@d}{\OP@b@d}}% - \op@mulpowerten{a}{\op@shift}% - \op@mulpowerten{b}{\op@shift}% - \fi\fi - \fi - \ifop@period - \op@div{1}{a}{b}{q}{r}% - \else - \op@div{0}{a}{b}{q}{r}% - \fi - \ifx\op@style\op@string@display - \op@split{#2}{a}% - \op@split{#3}{b}% - \op@copy{q}{qq}% - \op@unzero{a}% - \op@unzero{b}% - \ifx\op@shiftdecimalsep\op@string@none - \def\op@shift{0}% - \count@v=\OP@a@d - \advance\count@v by-\OP@b@d\relax - \ifnum\count@v>0 - \op@divpowerten{qq}{\the\count@v}% - \else - \count@v=-\count@v - \op@mulpowerten{qq}{\the\count@v}% - \fi - \else\ifx\op@shiftdecimalsep\op@string@divisor - \edef\op@shift{\OP@a@d}% - \count@v=\OP@a@d - \advance\count@v by-\OP@b@d\relax - \ifnum\count@v>0 - \op@divpowerten{qq}{\the\count@v}% - \else - \count@v=-\count@v - \op@mulpowerten{qq}{\the\count@v}% - \fi - \edef\op@shift{\OP@b@d}% - \op@split{#2}{a}% - \ifx\op@strikedecimalsepsymbol\empty - \op@unzero{a}% - \else - \count@z=\OP@a@w - \fi - \op@mulpowerten{a}{\OP@b@d}% - \ifx\op@strikedecimalsepsymbol\empty\else - \advance\count@z by-\OP@a@d - \op@format{\the\count@z}{\OP@a@d}{a}% - \fi - \xdef\OP@b@i{\OP@b@w}% - \xdef\OP@b@d{0}% - \ifx\op@strikedecimalsepsymbol\empty - \op@unzero{b}% - \fi - \else - \edef\op@shift{\op@max{\OP@a@d}{\OP@b@d}}% - \ifx\op@strikedecimalsepsymbol\empty - \op@unzero{a}% - \op@unzero{b}% - \else - \count@z=\OP@a@w - \count@i=\OP@b@w - \fi - \op@mulpowerten{a}{\op@shift}% - \op@mulpowerten{b}{\op@shift}% - \ifx\op@strikedecimalsepsymbol\empty\else - \advance\count@z by-\OP@a@d - \op@format{\the\count@z}{\OP@a@d}{a}% - \advance\count@i by-\OP@b@d - \op@format{\the\count@i}{\OP@b@d}{b}% - \fi - \fi\fi - \ifx\op@country\op@string@french - \op@divdisplayone - \else \ifx\op@country\op@string@american - \op@divdisplayone - \else \ifx\op@country\op@string@russian - \op@divdisplayone - \else - \op@error{Country \op@country\space isn't recognize} - {For now, only `french', `american' and - `russian' are valid}% - \fi\fi\fi - \else - \ifnum\OP@a@s=\OP@b@s\else - \xdef\OP@q@s{1}% - \fi - \mathsurround=\z@\relax - \ifop@deletezero - \op@unzero{a}% - \op@unzero{b}% - \op@unzero{q}% - \fi - \op@unsplit{a}{@a}% - \op@unsplit{b}{@b}% - \op@unsplit{q}{@q}% - \ifnum\OP@a@s=1\relax - \ifx\op@parenthesisnegative\op@string@all - $(\Op@@a)$% - \else - $\Op@@a$% - \fi - \else - $\Op@@a$% - \fi - $\>$\nobreak\op@divsymbol$\>$\penalty\binoppenalty - \ifnum\OP@b@s=1\relax - \ifx\op@parenthesisnegative\op@string@all - $(\Op@@b)$% - \else \ifx\op@parenthesisnegative\op@string@last - $(\Op@@b)$% - \else - $\Op@@b$% - \fi\fi - \else - $\Op@@b$% - \fi - \op@cmp{zero}{r}% - \ifopeq - $\;$\nobreak\op@equalsymbol$\;$\penalty\relpenalty - \setbox0=\hbox{\Op@@q}% - \else - \ifop@period - $\;$\nobreak\op@equalsymbol$\;$\penalty\relpenalty - \setbox0=\hbox{% - \Op@@q - \setbox1=\hbox{0}% - \begingroup - \opcolumnwidth=\wd1 - \ophline(-\op@lengthperiod,\op@vruleperiod){\op@lengthperiod}% - \endgroup - \op@afterperiodsymbol - }% - \else - $\;$\nobreak\op@approxsymbol$\;$\penalty\relpenalty - \setbox0=\hbox{\Op@@q}% - \fi - \fi - \ifnum\OP@q@s=1\relax - \ifx\op@parenthesisnegative\op@string@all - $(\box0)$% - \else - $\box0$% - \fi - \else - $\box0$% - \fi - \fi - \fi - \endgroup -} -\def\opidiv{\@ifnextchar*{\op@idivstar}{\op@idivnostar}} -\def\op@idivstar*#1#2#3#4{% - \begingroup - \op@split{#1}{a}% - \op@split{#2}{b}% - \ifop@error - \op@errorwrite - \else - \op@unzero{a}% - \op@unzero{b}% - \edef\op@shift{\op@max{\OP@a@d}{\OP@b@d}}% - \op@mulpowerten{a}{\op@shift}% - \op@mulpowerten{b}{\op@shift}% - \xdef\OP@a@s{0}% - \xdef\OP@b@s{0}% - \op@periodfalse - \op@div{2}{a}{b}{q}{r}% - \op@split{#1}{a}% - \op@split{#2}{b}% - \op@unzero{a}% - \op@unzero{b}% - \ifnum\OP@a@s=0\relax - \ifnum\OP@b@s=0\relax - \else - \xdef\OP@q@s{1}% - \fi - \else - \op@add{one}{q}{q}% - \ifnum\OP@b@s=0\relax - \xdef\OP@q@s{1}% - \fi - \fi - \ifop@error\else - \op@unsplit{q}{#3}% - \op@unsplit{r}{#4}% - \fi - \fi - \endgroup -} -\def\op@idivnostar{\@ifnextchar[{\op@idivarg}{\op@idivarg[nil]}} -\def\op@idivarg[#1]#2#3{% - \begingroup - \opset{#1}% - \op@periodfalse - \let\op@shiftdecimalsep\op@string@both - \op@split{#2}{a}% - \op@split{#3}{b}% - \ifop@error - \op@errorwrite - \else - \ifx\op@style\op@string@display - \op@unzero{a}% - \op@unzero{b}% - \edef\op@shift{\op@max{\OP@a@d}{\OP@b@d}}% - \op@mulpowerten{a}{\op@shift}% - \op@mulpowerten{b}{\op@shift}% - \fi - \xdef\OP@a@s{0}% - \xdef\OP@b@s{0}% - \op@div{2}{a}{b}{q}{r}% - \op@split{#2}{a}% - \op@split{#3}{b}% - \op@unzero{a}% - \op@unzero{b}% - \ifx\op@style\op@string@display - \op@copy{q}{qq}% - \edef\op@shift{\op@max{\OP@a@d}{\OP@b@d}}% - \ifx\op@strikedecimalsepsymbol\empty\else - \count@z=\OP@a@w - \count@i=\OP@b@w - \fi - \op@mulpowerten{a}{\op@shift}% - \op@mulpowerten{b}{\op@shift}% - \ifx\op@strikedecimalsepsymbol\empty\else - \advance\count@z by-\OP@a@d - \op@format{\the\count@z}{\OP@a@d}{a}% - \advance\count@i by-\OP@b@d - \op@format{\the\count@i}{\OP@b@d}{b}% - \fi - \ifx\op@country\op@string@french - \op@divdisplayone - \else \ifx\op@country\op@string@american - \op@divdisplayone - \else \ifx\op@country\op@string@russian - \op@divdisplayone - \else - \op@error{Country \op@country\space isn't recognize} - {For now, only `french', `american' and - `russian' are valid}% - \fi\fi\fi - \else - \ifnum\OP@a@s=0\relax - \ifnum\OP@b@s=0\relax - \else - \xdef\OP@q@s{1}% - \fi - \else - \op@add{q}{one}{q}% - \op@sub{b}{r}{r} - \ifnum\OP@b@s=0\relax - \xdef\OP@q@s{1}% - \else - \fi - \fi - \mathsurround=\z@\relax - \ifop@deletezero - \op@unzero{a}% - \op@unzero{b}% - \op@unzero{q}% - \fi - \op@unsplit{a}{@a}% - \op@unsplit{b}{@b}% - \op@unsplit{q}{@q}% - \op@unsplit{r}{@r}% - \ifnum\OP@a@s=1\relax - \ifx\op@parenthesisnegative\op@string@all - $(\Op@@a)$% - \else - $\Op@@a$% - \fi - \else - $\Op@@a$% - \fi - $\;$\nobreak\op@equalsymbol$\;$\penalty\relpenalty - \ifnum\OP@b@s=1\relax - \ifx\op@parenthesisnegative\op@string@all - $(\Op@@b)$% - \else \ifx\op@parenthesisnegative\op@string@last - $\Op@@b$% - \else - $\Op@@b$% - \fi\fi - \else - $\Op@@b$% - \fi - $\>$\nobreak\op@mulsymbol$\>$\penalty\binoppenalty - \ifnum\OP@q@s=1\relax - \ifx\op@parenthesisnegative\op@string@all - $(\Op@@q)$% - \else \ifx\op@parenthesisnegative\op@string@last - $(\Op@@q)$% - \else - $\Op@@q$% - \fi\fi - \else - $\Op@@q$% - \fi - \op@cmp{zero}{r}% - \ifopeq\else - $\>$\nobreak\op@addsymbol$\>$\penalty\binoppenalty - \ifnum\OP@q@s=1\relax - \ifx\op@parenthesisnegative\op@string@all - $(\Op@@r)$% - \else \ifx\op@parenthesisnegative\op@string@last - $(\Op@@r)$% - \else - $\Op@@r$% - \fi\fi - \else - $\Op@@r$% - \fi - \fi - \fi - \fi - \endgroup -} -\def\op@divdisplayone{% - \begingroup - \count@z=\z@\relax - \count@i=\OP@a@w - \loop - \ifnum\@nameuse{OP@a@\the\count@i}=0 - \advance\count@i by-1 - \advance\count@z by1 - \repeat - \count@i=\op@firstlength - \advance\count@i by\count@z - \xdef\op@firstlength{\the\count@i}% - \setbox2=\vbox{% - \count@i=\op@firstlength - \advance\count@i by1 - \hbox{% - \ifx\op@displayintermediary\op@string@none\else - \kern\opcolumnwidth - \advance\count@i by1 - \fi - \ifop@dividendbridge - \vrule width0pt depth0pt height\oplineheight - \opvline(0,1){0.4}% - \ophline(0,1){\op@firstlength}% - \opvline(\op@firstlength,1){0.4}% - \fi - \op@display{operandstyle.1}{a}% - \ifnum\op@shift=0\relax\else - \count@v=\op@shift - \advance\count@v by\OP@a@d - \oplput(-\the\count@v,0){\op@strikedecimalsepsymbol}% - \fi - }% - \count@z=\OP@q@w - \count@ii=1\relax - \ifx\op@displayintermediary\op@string@none - \advance\count@i by-1\relax - \else - \count@iv=\@nameuse{OP@q@\the\count@z}\relax - \count@iii=\count@i - \advance\count@iii by-\@nameuse{OP@T\the\count@iv @w}% - \hbox{% - \ifx\op@voperator\op@string@center - \oplput(0,0.5){\op@subsymbol}% - \else\ifx\op@voperator\op@string@top - \oplput(0,1){\op@subsymbol}% - \else - \oplput(0,0){\op@subsymbol}% - \fi\fi - \ophline(1,-0.25){\op@firstlength}% - \advance\count@ii by1 - \kern\count@iii\opcolumnwidth - \op@display{intermediarystyle.1}% - {T\the\count@iv}% - }% - \fi - {\global\setbox4=\hbox{}\setbox4=\box4}% - \loop - \advance\count@z by-1 - \advance\count@i by1\relax - \ifnum\count@z>0\relax - \count@iv=\@nameuse{OP@q@\the\count@z}\relax - \ifnum\count@iv=0 - \ifx\op@displayintermediary\op@string@all - \count@v=\count@i - \advance\count@v by-\@nameuse{OP@R\the\count@ii @w}% - \hbox{% - \kern\count@v\opcolumnwidth - \op@display{remainderstyle.\the\count@ii}% - {R\the\count@ii}% - }% - \count@iii=\count@i - \advance\count@iii by-\@nameuse{OP@T\the\count@iv @w}% - \hbox{% - \kern\count@v\opcolumnwidth - \ifx\op@voperator\op@string@center - \oplput(-1,0.5){\op@subsymbol}% - \else\ifx\op@voperator\op@string@top - \oplput(-1,1){\op@subsymbol}% - \else - \oplput(-1,0){\op@subsymbol}% - \fi\fi - \ophline(0,-0.25){\@nameuse{OP@R\the\count@ii @w}}% - \kern-\count@v\opcolumnwidth - \kern\count@iii\opcolumnwidth - \op@display{intermediarystyle.\the\count@ii}% - {T\the\count@iv}% - }% - \else - \ifnum\@nameuse{OP@R\the\count@ii @w}=2 - \ifnum\@nameuse{OP@R\the\count@ii @2}=0 - \op@makebox{1}{0}{remainderstyle.\the\count@ii.1}{zero}% - \setbox4=\hbox to\opcolumnwidth{\hss\box0\hss}% - \fi - \fi - \fi - \advance\count@ii by1\relax - \else - \count@v=\count@i - \advance\count@v by-\@nameuse{OP@R\the\count@ii @w}% - \ifvoid4\relax\else - \advance\count@v by-1 - \fi - \hbox{% - \kern\count@v\opcolumnwidth\copy4 - \op@display{remainderstyle.\the\count@ii}% - {R\the\count@ii}% - }% - \advance\count@ii by1\relax - \ifx\op@displayintermediary\op@string@none - \else - \count@iii=\count@i - \advance\count@iii by-\@nameuse{OP@T\the\count@iv @w}% - \hbox{% - \kern\count@v\opcolumnwidth - \ifx\op@voperator\op@string@center - \oplput(-1,0.5){\op@subsymbol}% - \else\ifx\op@voperator\op@string@top - \oplput(-1,1){\op@subsymbol}% - \else - \oplput(-1,0){\op@subsymbol}% - \fi\fi - \advance\count@ii by-1 - \ifvoid4\relax - \ophline(0,-0.25){\@nameuse{OP@R\the\count@ii @w}}% - \else - \ophline(0,-0.25){\@nameuse{OP@T\the\count@iv @w}}% - \ophline(\@nameuse{OP@T\the\count@iv @w},-0.25){1}% - {\setbox4=\box4}% - \fi - \advance\count@ii by1 - \kern-\count@v\opcolumnwidth - \kern\count@iii\opcolumnwidth - \op@display{intermediarystyle.\the\count@ii}% - {T\the\count@iv}% - }% - \fi - \fi - \repeat - \advance\count@i by-1 - \count@iii=\count@i - \advance\count@iii by-\@nameuse{OP@R\the\count@ii @w}% - \hbox{% - \kern\count@iii\opcolumnwidth - \op@display{remainderstyle.\the\count@ii}% - {R\the\count@ii}% - }% - }% - \setbox3=\vbox{% - \count@v=\op@max{\OP@qq@w}{\OP@b@w} - \hbox{\ophline(-0.5,-0.25){\the\count@v.5}% - \op@display{operandstyle.2}{b}% - \ifnum\op@shift=0\relax\else - \count@v=\op@shift - \advance\count@v by\OP@b@d - \oplput(-\the\count@v,0){\op@strikedecimalsepsymbol}% - \fi} - \hbox{\op@display{resultstyle}{qq}} - }% - \dimen0=\ht2 - \ifdim\dimen0>\ht3 - \ht3=\ht2 - \else - \ht2=\ht3 - \fi - \ifx\op@voperation\op@string@top - \dimen0=\ht2 - \advance\dimen0 by-0.5\oplineheight - \ht2=0.75\oplineheight - \ht3=0.75\oplineheight - \dp2=\dimen0 - \dp2=\dimen0 - \fi - \setbox1=\hbox{% - \box2 - \kern0.5\opcolumnwidth - \kern-0.5\op@hrulewidth - \ifx\voperation\op@string@top - \vrule width\op@hrulewidth - \else - \vrule width\op@hrulewidth - \fi - \kern0.5\opcolumnwidth - \kern-0.5\op@hrulewidth - \box3 - }% - \ifx\op@voperation\op@string@center - \setbox1=\hbox{$\vcenter{\box1}$}% - \fi - \leavevmode\box1 - \endgroup -} -\def\op@div#1#2#3#4#5{% - \begingroup - \def\op@divmode{#1}% - \op@copy{#2}{da}% - \op@copy{#3}{db}% - \count@iv=0 - \count@iii=\op@max{\OP@da@d}{\OP@db@d}\relax - \op@powten{da}{\the\count@iii}% - \op@powten{db}{\the\count@iii}% - \ifnum\op@divmode=1 - \op@cmp{da}{maxinteger}% - \ifopgt - \op@warning{I can't deal period with such great dividend - (max = 2147483647).^^J - Use of maxdivstep instead period.}% - \def\op@divmode{0}% - \else \op@cmp{db}{maxdivperiod}% - \ifopgt - \op@warning{I can't deal period with such great divisor - (max = 214748363).^^J - Use of maxdivstep instead period.}% - \def\op@divmode{0}% - \else - \op@unsplit{da}{@a}% - \op@unsplit{db}{@b}% - \op@divperiod{\Op@@a}{\Op@@b}{op@lengthperiod}% - \ifnum\op@lengthperiod>\op@safedivstep - \op@warning{Period of division is too big - (\op@lengthperiod\space > safedivstep).^^J - \space\space\space Division will stop - before reach it.}% - \fi - \fi\fi - \fi - \op@multable{db}% - \op@cmp{da}{db}% - \ifople - \op@copy{da}{R}% - \count@i=\OP@da@w - \else - \xdef\OP@R@d{0}% - \xdef\OP@R@s{0}% - \count@i=\@nameuse{OP@db@w}% - \op@leftdividend{\the\count@i}% - \op@cmp{R}{db}% - \ifoplt - \ifnum\OP@da@w>\count@i - \advance\count@i by1 - \op@leftdividend{\the\count@i}% - \fi - \fi - \fi - \xdef\op@firstlength{\the\count@i}% - \count@i=-\count@i - \advance\count@i by\OP@da@w - \op@copy{R}{R0}% - \op@copy{zero}{dq}% - \count@ii=0 - \op@againtrue - \loop - \ifop@again - \op@tableextract{R}% - \op@multen{dq}% - \@namexdef{OP@dq@1}{\op@k}% - \op@sub{R}{T\op@k}{dr}% - \op@unzero{T\op@k}% - \op@multen{dr}% - \ifnum\count@i>0 - \@namexdef{OP@dr@1}{\@nameuse{OP@da@\the\count@i}}% - \fi - \advance\count@i by-1\relax - \op@unzero{dr}% - \ifnum\OP@dr@w=1 - \xdef\OP@dr@w{2}% - \xdef\OP@dr@i{2}% - \@namexdef{OP@dr@2}{0}% - \fi - \advance\count@ii by1\relax - \op@copy{dr}{R\the\count@ii}% - \op@copy{dr}{R}% - \ifcase\op@divmode\relax - \ifnum\count@ii<\op@maxdivstep\relax\else - \op@againfalse - \fi - \ifnum\count@i<0\relax% - \op@cmp{zero}{R}% - \ifopeq - \op@againfalse - \fi - \fi - \or - \ifnum\count@ii<\op@safedivstep\relax\else - \op@againfalse - \fi - \ifnum\count@i<-\op@lengthperiod\relax - \count@iv=\count@ii - \advance\count@iv by-\op@lengthperiod - \op@cmp{R\the\count@iv}{R\the\count@ii}% - \ifopeq - \op@againfalse - \fi - \fi - \or - \ifnum\count@i=-1 - \op@againfalse - \fi - \fi - \repeat - \op@copy{zero}{T0}% - \advance\count@i by1\relax - \ifnum\count@i<0 - \xdef\OP@dq@d{-\the\count@i}% - \count@z=\OP@dq@w - \advance\count@z by\count@i - \xdef\OP@dq@i{\the\count@z}% - \fi - \op@unzero{dq}% - \op@copy{dq}{#4}% - \op@unzero{dr}% - \op@copy{dr}{R}% - \op@rshift{1}{dr}% - \op@copy{dr}{R\the\count@ii}% - \count@i=\count@iii - \advance\count@i by1 - \advance\count@i by\OP@dq@d\relax - \count@ii=\count@i - \advance\count@ii by\OP@R@w - \op@format{\the\count@ii}{0}{R}% - \count@z=\OP@R@w - \advance\count@z by-\count@i - \xdef\OP@R@i{\the\count@z}% - \xdef\OP@R@d{\the\count@i}% - \op@unzero{R}% - \op@copy{R}{#5}% - \endgroup -} -\def\op@powten#1#2{% - \begingroup - \count@z=#2\relax - \advance\count@z by-\@nameuse{OP@#1@d}% - \@namexdef{OP@#1@d}{0}% - \count@i=\@nameuse{OP@#1@w}% - \advance\count@i by\count@z - \@namexdef{OP@#1@w}{\the\count@i}% - \@namexdef{OP@#1@i}{\the\count@i}% - \count@ii=\count@i - \advance\count@ii by-\count@z - \loop - \ifnum\count@ii>0 - \@namexdef{OP@#1@\the\count@i}{\@nameuse{OP@#1@\the\count@ii}}% - \advance\count@i by-1 - \advance\count@ii by-1 - \repeat - \loop - \ifnum\count@i>0 - \@namexdef{OP@#1@\the\count@i}{0}% - \advance\count@i by-1 - \repeat - \endgroup -} -\def\opdivperiod#1#2#3{% - \op@split{#1}{a}% - \op@split{#2}{b}% - \ifop@error\else - \op@unzero{a}% - \edef\OP@a@i{\OP@a@w}% - \def\OP@a@d{0}% - \def\OP@a@s{0}% - \op@unzero{b}% - \edef\OP@b@i{\OP@b@w}% - \def\OP@b@d{0}% - \def\OP@b@s{0}% - \op@cmp{a}{zero}% - \ifopeq - \op@unsplit{one}{#3}% - \else - \op@cmp{b}{zero}% - \ifopeq - \op@error{divisor must be nonzero}% - {You have to learn some math}% - \else - \op@cmp{a}{maxdivperiod}% - \ifopgt - \op@error{Arguments of \string\opdivperiod\space - must be less than 214748363}% - {Sorry}% - \else - \op@cmp{b}{maxdivperiod}% - \ifopgt - \op@error{Arguments of \string\opdivperiod\space - must be less than 214748363}% - {Sorry}% - \else - \op@unsplit{a}{@a}% - \op@unsplit{b}{@b}% - \op@divperiod{\Op@@a}{\Op@@b}{Op@@r}% - \opcopy{@r}{#3}% - \fi - \fi - \fi - \fi - \fi - \ifop@error\op@errorwrite\fi -} -\def\op@divperiod#1#2#3{% - \begingroup - \count@i=#1\relax - \count@ii=#2\relax - \ifnum\count@ii=0\relax - \@namexdef{#3}{1}% - \else - \op@gcd{\the\count@i}{\the\count@ii}{op@tmp}% - \count@iii=\op@tmp - \divide\count@ii by\count@iii - \op@twofiveQ{\the\count@ii}{op@tmp}% - \op@order{\op@tmp}{op@tmp}% - \@namexdef{#3}{\op@tmp}% - \fi - \endgroup -} -\def\opgcd#1#2#3{% - \op@split{#1}{a}% - \op@split{#2}{b}% - \ifop@error\else - \def\OP@a@s{0}% - \def\OP@b@s{0}% - \op@cmp{a}{zero}% - \ifopeq - \op@error{Arguments of \string\opgcd\space must be nonzero}% - {You have to learn some math}% - \else - \op@cmp{b}{zero}% - \ifopeq - \op@error{Arguments of \string\opgcd\space must be nonzero}% - {You have to learn some math}% - \else\ifnum\OP@a@d>0 - \op@error{Arguments of \string\opgcd\space must be integer}% - {You have to learn some math}% - \else\ifnum\OP@b@d>0 - \op@error{Arguments of \string\opgcd\space must be integer}% - {You have to learn some math}% - \else - \op@cmp{a}{maxinteger}% - \ifopgt - \op@error{Arguments of \string\opgcd\space must be less than - 2147483647}% - {Sorry}% - \else - \op@cmp{b}{maxinteger}% - \ifopgt - \op@error{Arguments of \string\opgcd\space must be less than - 2147483647}% - {Sorry}% - \else - \op@unsplit{a}{@a}% - \op@unsplit{b}{@b}% - \op@gcd{\Op@@a}{\Op@@b}{Op@@r}% - \opcopy{@r}{#3}% - \fi\fi\fi\fi\fi\fi - \fi - \ifop@error\op@errorwrite\fi -} -\def\op@gcd#1#2#3{% - \begingroup - \count@i=#1\relax - \count@ii=#2\relax - \loop - \count@iii=\count@i - \divide\count@iii by\count@ii - \multiply\count@iii by\count@ii - \advance\count@i by-\count@iii - \count@iii=\count@i\relax - \count@i=\count@ii\relax - \count@ii=\count@iii - \ifnum\count@ii>0 - \repeat - \@namexdef{#3}{\the\count@i}% - \endgroup -} -\def\op@twofiveQ#1#2{% - \begingroup - \count@i=#1\relax - \loop - \count@ii=\count@i - \divide\count@ii by2 - \multiply\count@ii by2 - \ifnum\count@ii=\count@i - \divide\count@i by2 - \repeat - \loop - \count@ii=\count@i - \divide\count@ii by5 - \multiply\count@ii by5 - \ifnum\count@ii=\count@i - \divide\count@i by5 - \repeat - \@namexdef{#2}{\the\count@i}% - \endgroup -} -\def\op@order#1#2{% - \begingroup - \count@i=1\relax - \count@ii=0 - \loop - \multiply\count@i by10 - \count@iii=\count@i - \divide\count@iii by#1\relax - \multiply\count@iii by#1\relax - \advance\count@i by-\count@iii - \advance\count@ii by1 - \ifnum\count@i>1 - \repeat - \@namexdef{#2}{\the\count@ii} - \endgroup -} -\def\op@leftdividend#1{% - \begingroup - \count@z=#1\relax - \count@i=\OP@da@w - \xdef\OP@R@w{\the\count@z}% - \xdef\OP@R@i{\the\count@z}% - \loop - \@namexdef{OP@R@\the\count@z}{\@nameuse{OP@da@\the\count@i}}% - \advance\count@i by-1 - \advance\count@z by-1 - \ifnum\count@z>0 - \repeat - \endgroup -} -\def\op@multen#1{% - \begingroup - \count@z=\@nameuse{OP@#1@w}\relax - \count@i=\count@z - \advance\count@i by1 - \@namexdef{OP@#1@w}{\the\count@i}% - \@namexdef{OP@#1@i}{\the\count@i}% - \loop - \ifnum\count@z>0 - \@namexdef{OP@#1@\the\count@i}{\@nameuse{OP@#1@\the\count@z}}% - \advance\count@z by-1 - \advance\count@i by-1 - \repeat - \@namexdef{OP@#1@1}{0}% - \endgroup -} -\def\op@mulpowerten#1#2{% - \begingroup - \ifnum\@nameuse{OP@#1@d}<#2\relax - \count@z=#2\relax - \advance\count@z by-\@nameuse{OP@#1@d}\relax - \count@ii=\@nameuse{OP@#1@w}% - \count@i=\@nameuse{OP@#1@w}% - \advance\count@i by\count@z - \@namexdef{OP@#1@w}{\the\count@i}% - \@namexdef{OP@#1@i}{\the\count@i}% - \@namexdef{OP@#1@d}{0}% - \loop - \ifnum\count@ii>0 - \@namexdef{OP@#1@\the\count@i}{\@nameuse{OP@#1@\the\count@ii}}% - \advance\count@i by-1 - \advance\count@ii by-1 - \repeat - \loop - \ifnum\count@z>0 - \@namexdef{OP@#1@\the\count@z}{0}% - \advance\count@z by-1\relax - \repeat - \else - \count@z=\@nameuse{OP@#1@d}\relax - \advance\count@z by-#2\relax - \@namexdef{OP@#1@d}{\the\count@z}% - \count@z=\@nameuse{OP@#1@i}\relax - \advance\count@z by#2\relax - \@namexdef{OP@#1@i}{\the\count@z}% - \fi - \op@unzero{#1}% - \endgroup -} -\def\op@divpowerten#1#2{% - \begingroup - \ifnum\@nameuse{OP@#1@i}>#2\relax - \count@z=\@nameuse{OP@#1@d}\relax - \advance\count@z by#2\relax - \@namexdef{OP@#1@d}{\the\count@z}% - \count@z=\@nameuse{OP@#1@i}\relax - \advance\count@z by-#2\relax - \@namexdef{OP@#1@i}{\the\count@z}% - \else - \count@z=\@nameuse{OP@#1@d}\relax - \advance\count@z by#2\relax - \@namexdef{OP@#1@d}{\the\count@z}% - \@namexdef{OP@#1@i}{1}% - \advance\count@z by1\relax - \count@i=\@nameuse{OP@#1@w}% - \@namexdef{OP@#1@w}{\the\count@z}% - \advance\count@z by1 - \loop - \ifnum\count@i<\count@z - \advance\count@i by1 - \@namexdef{OP@#1@\the\count@i}{0}% - \repeat - \fi - \op@unzero{#1}% - \endgroup -} -\def\op@tableextract#1{% - \op@cmp{#1}{T5}% - \ifopge \op@cmp{#1}{T7}% - \ifopge \op@cmp{#1}{T8}% - \ifopge \op@cmp{#1}{T9}% - \ifopge \gdef\op@k{9}% - \else \gdef\op@k{8}% - \fi - \else \gdef\op@k{7}% - \fi - \else \op@cmp{#1}{T6}% - \ifopge \gdef\op@k{6}% - \else \gdef\op@k{5}% - \fi - \fi - \else \op@cmp{#1}{T2}% - \ifopge \op@cmp{#1}{T3}% - \ifopge \op@cmp{#1}{T4}% - \ifopge \gdef\op@k{4}% - \else \gdef\op@k{3}% - \fi - \else \gdef\op@k{2}% - \fi - \else \op@cmp{#1}{T1}% - \ifopge \gdef\op@k{1}% - \else \gdef\op@k{0}% - \fi - \fi - \fi -} -\def\opwidth#1#2{% - \op@split{#1}{a}% - \ifop@error - \op@errorwrite - \else - \@namexdef{Op@#2}{\OP@a@w}% - \fi -} -\def\opintegerwidth#1#2{% - \op@split{#1}{a}% - \ifop@error - \op@errorwrite - \else - \@namexdef{Op@#2}{\OP@a@i}% - \fi -} -\def\opdecimalwidth#1#2{% - \op@split{#1}{a}% - \ifop@error - \op@errorwrite - \else - \@namexdef{Op@#2}{\OP@a@d}% - \fi -} -\def\opinteger#1#2{% - \op@split{#1}{a}% - \ifop@error - \op@errorwrite - \else - \op@integer{a}{b}% - \op@unsplit{b}{#2}% - \fi -} -\def\op@integer#1#2{% - \begingroup - \op@unzero{#1}% - \count@z=\@nameuse{OP@#1@d}\relax - \ifnum\count@z>0\relax - \count@i=0 - \loop - \ifnum\count@z<\@nameuse{OP@#1@w}% - \advance\count@z by1\relax - \advance\count@i by1\relax - \@namexdef{OP@#2@\the\count@i}{\@nameuse{OP@#1@\the\count@z}}% - \repeat - \@namexdef{OP@#2@w}{\the\count@i}% - \@namexdef{OP@#2@i}{\the\count@i}% - \@namexdef{OP@#2@d}{0}% - \else - \op@copy{#1}{#2}% - \fi - \@namexdef{OP@#2@s}{0}% - \endgroup -} -\def\opdecimal#1#2{% - \op@split{#1}{a}% - \ifop@error - \op@errorwrite - \else - \op@decimal{a}{b}% - \op@unsplit{b}{#2}% - \fi -} -\def\op@decimal#1#2{% - \op@unzero{#1}% - \ifop@error - \op@errorwrite - \else - \ifnum\@nameuse{OP@#1@d}=0\relax - \op@copy{zero}{#2}% - \else - \op@copy{#1}{#2}% - \@namexdef{OP@#2@i}{\@nameuse{OP@#1@d}}% - \@namexdef{OP@#2@w}{\@nameuse{OP@#1@d}}% - \@namexdef{OP@#2@d}{0}% - \@namexdef{OP@#2@s}{0}% - \fi - \fi -} -\def\opgetdigit#1#2#3{% - \op@split{#1}{a}% - \ifop@error - \op@errorwrite - \else - \ifnum\@nameuse{OP@a@w}>#2\relax - \@namexdef{Op@#3}{\@nameuse{OP@a@#2}}% - \else - \@namexdef{Op@#3}{0}% - \fi - \fi -} -\def\opsetdigit#1#2#3{% - \begingroup - \op@split{#1}{a}% - \op@split{#3}{b}% - \ifop@error - \op@errorwrite - \else - \op@unsplit{b}{@b}% - \@namexdef{OP@a@#2}{\Op@@b}% - \ifnum\OP@a@w<#2\relax - \count@z=\OP@a@w\relax - \advance\count@z by1\relax - \loop - \ifnum\count@z<#2\relax - \@namexdef{OP@a@\the\count@z}{0}% - \advance\count@z by1 - \repeat - \xdef\OP@a@w{#2}% - \count@z=#2\relax - \advance\count@z by-\OP@a@d - \xdef\OP@a@i{\the\count@z}% - \fi - \op@unsplit{a}{#1}% - \fi - \endgroup -} -\def\opgetintegerdigit#1#2#3{% - \begingroup - \op@split{#1}{a}% - \ifop@error - \op@errorwrite - \else - \count@z=\OP@a@d - \advance\count@z by#2\relax - \ifnum\OP@a@w>\count@z\relax - \@namexdef{Op@#3}{\@nameuse{OP@a@\the\count@z}}% - \else - \@namexdef{Op@#3}{0}% - \fi - \fi - \endgroup -} -\def\opsetintegerdigit#1#2#3{% - \begingroup - \op@split{#1}{a}% - \op@split{#3}{b}% - \ifop@error - \op@errorwrite - \else - \op@unsplit{b}{@b}% - \count@z=\OP@a@d - \advance\count@z by#2\relax - \@namexdef{OP@a@\the\count@z}{\Op@@b}% - \ifnum\OP@a@w>\count@z\relax\else - \count@i=\OP@a@w - \xdef\OP@a@w{\the\count@z}% - \advance\count@i by1 - \loop - \ifnum\count@i<\count@z - \@namexdef{OP@a@\the\count@i}{0}% - \advance\count@i by1 - \repeat - \advance\count@z by-\OP@a@d - \xdef\OP@a@i{\the\count@z}% - \fi - \op@unsplit{a}{#1}% - \fi - \endgroup -} -\def\opgetdecimaldigit#1#2#3{% - \begingroup - \op@split{#1}{a}% - \ifop@error - \op@errorwrite - \else - \ifnum\OP@a@d<#2\relax - \@namexdef{Op@#3}{0}% - \else - \count@z=\OP@a@d - \advance\count@z by-#2\relax - \advance\count@z by1 - \@namexdef{Op@#3}{\@nameuse{OP@a@\the\count@z}}% - \fi - \fi - \endgroup -} -\def\opsetdecimaldigit#1#2#3{% - \begingroup - \op@split{#1}{a}% - \op@split{#3}{b}% - \ifop@error - \op@errorwrite - \else - \op@unsplit{b}{@b}% - \ifnum\OP@a@d<\Op@@b\relax - \count@z=\Op@@b - \advance\count@z by-\OP@a@d - \advance\count@z by1\relax - \count@i=\OP@a@w - \advance\count@i by\count@z\relax - \count@z=\OP@a@w - \xdef\OP@a@w{\the\count@i}% - \xdef\OP@a@d{\Op@@b}% - \loop - \ifnum\count@z>0 - \@namexdef{OP@a@\the\count@i}{\@nameuse{OP@a@\the\count@z}}% - \advance\count@z by-1 - \advance\count@i by-1 - \repeat - \loop - \ifnum\count@i>1 - \@namexdef{OP@a@\the\count@i}{0}% - \advance\count@i by-1 - \repeat - \@namexdef{OP@a@1}{\Op@@b}% - \else - \count@z=\OP@a@d - \advance\count@z by-#2\relax - \advance\count@z by1 - \@namexdef{OP@a@\the\count@z}{\Op@@b}% - \fi - \op@unsplit{a}{#1}% - \fi - \endgroup -} -\def\opcastingoutnines#1#2{% - \begingroup - \op@split{#1}{a}% - \ifop@error - \op@errorwrite - \else - \count@z=\OP@a@w\relax - \count@i=0\relax - \loop - \ifnum\count@z>0 - \advance\count@i by\@nameuse{OP@a@\the\count@z}\relax - \ifnum\count@i>8 - \advance\count@i by-9 - \fi - \advance\count@z by-1 - \repeat - \opcopy{\the\count@i}{#2}% - \fi - \endgroup -} -\def\opcastingoutelevens#1#2{% - \begingroup - \op@split{#1}{a}% - \ifop@error - \op@errorwrite - \else - \count@ii=\OP@a@w - \advance\count@ii by1\relax - \count@i=0\relax - \count@z=-1\relax - \loop - \advance\count@z by2\relax - \ifnum\count@z<\count@ii - \advance\count@i by\@nameuse{OP@a@\the\count@z}\relax - \ifnum\count@i>10 - \advance\count@i by-11 - \fi - \repeat - \count@z=0\relax - \loop - \advance\count@z by2\relax - \ifnum\count@z<\count@ii - \advance\count@i by-\@nameuse{OP@a@\the\count@z}\relax - \ifnum\count@i<0 - \advance\count@i by11 - \fi - \repeat - \opcopy{\the\count@i}{#2}% - \fi - \endgroup -} -\def\opneg#1#2{% - \op@split{#1}{a}% - \ifop@error - \op@errorwrite - \else - \op@neg{a}{b}% - \op@unsplit{b}{#2}% - \fi -} -\def\op@neg#1#2{% - \begingroup - \op@copy{#1}{#2}% - \op@againfalse - \ifnum\@nameuse{OP@#2@d}>0 - \op@againtrue - \else\ifnum\@nameuse{OP@#2@i}>1 - \op@againtrue - \else\ifnum\@nameuse{OP@#2@1}>0 - \op@againtrue - \fi\fi\fi - \ifop@again - \count@z=1 - \advance\count@z by-\@nameuse{OP@#2@s}\relax - \@namexdef{OP@#2@s}{\the\count@z}% - \fi - \endgroup -} -\def\opabs#1#2{% - \op@split{#1}{a}% - \ifop@error - \op@errorwrite - \else - \xdef\OP@a@s{0}% - \op@unsplit{a}{#2}% - \fi -} -\def\oppower#1#2#3{% - \begingroup - \op@split{#1}{a}% - \op@split{#2}{b}% - \ifop@error\else - \op@unsplit{a}{@a}% - \op@unsplit{b}{@b}% - \ifnum\OP@b@d>0 - \op@error{Exponent must be an integer}% - {You can't use \string\oppower\space with non integer - exponent}% - \else - \op@cmp{a}{zero}% - \ifopeq - \op@cmp{b}{zero}% - \ifopeq - \opcopy{1}{#3}% - \else\ifopgt - \opcopy{0}{#3}% - \else - \op@error{Power of zero with negative exponent is an - error}% - {Remember that negative exponent involve inverse}% - \fi\fi - \else - \op@cmp{b}{zero}% - \ifoplt - \xdef\OP@b@s{0}% - \op@unsplit{b}{@b}% - \opdiv*{1}{@a}{@a}% - \fi - \op@cmp{b}{maxpower}% - \ifopgt - \op@error{Exponent is too big (>1073741824)}% - {Sorry}% - \else - \count@z=0 - \@namexdef{Op@@e0}{1}% - \xdef\Op@@tmp{1}% - \@namexdef{Op@@p0}{\Op@@a}% - \@namexdef{Op@@ptmp}{\@nameuse{Op@@p0}}% - \loop - \ifnum\@nameuse{Op@@e\the\count@z}<\Op@@b - \opadd*{@tmp}{@tmp}{@@tmp}% - \opmul*{@ptmp}{@ptmp}{@@ptmp}% - \advance\count@z by1 - \xdef\Op@@tmp{\Op@@@tmp}% - \xdef\Op@@ptmp{\Op@@@ptmp}% - \@namexdef{Op@@e\the\count@z}{\Op@@@tmp}% - \@namexdef{Op@@p\the\count@z}{\Op@@@ptmp}% - \repeat - \opcopy{1}{@r}% - \loop - \ifnum\Op@@b>0\relax - \ifnum\Op@@b<\@nameuse{Op@@e\the\count@z}\relax - \else - \opmul*{@r}{@p\the\count@z}{@r}% - \opsub*{@b}{@e\the\count@z}{@b}% - \fi - \advance\count@z by-1 - \repeat - \opcopy{@r}{#3}% - \fi - \fi - \fi - \fi - \ifop@error\op@errorwrite\fi - \endgroup -} -\def\opfloor#1#2#3{% - \op@split{#1}{fa}% - \op@split{#2}{fb}% - \ifop@error - \op@errorwrite - \else - \ifnum\OP@fa@s=1 - \xdef\OP@fa@s{0}% - \op@ceil{fa}{fb}% - \xdef\OP@fa@s{1}% - \else - \op@floor{fa}{fb}% - \fi - \op@unsplit{fa}{#3}% - \fi -} -\def\opround#1#2#3{% - \op@split{#1}{ra}% - \op@split{#2}{rb}% - \ifop@error - \op@errorwrite - \else - \op@unsplit{ra}{@ra}% - \op@unsplit{rb}{@rb}% - \ifnum\Op@@rb<0\relax - \opneg{@rb}{@rb}% - \ifnum\Op@@rb<\@nameuse{OP@ra@i}\relax - \else - \count@z=\@nameuse{OP@ra@i}% - \advance\count@z by-1 - \xdef\Op@@rb{\the\count@z}% - \fi - \opneg{@rb}{@rb}% - \fi - \oppower{0.1}{@rb}{@rr}% - \opmul*{0.5}{@rr}{@rr}% - \ifnum\OP@ra@s=0\relax - \opadd*{@ra}{@rr}{@ra}% - \opfloor{@ra}{#2}{#3}% - \else - \opneg{@ra}{@ra}% - \opadd*{@ra}{@rr}{@ra}% - \opfloor{@ra}{#2}{@ra}% - \opneg{@ra}{#3}% - \fi - \fi -} -\def\opceil#1#2#3{% - \op@split{#1}{ca}% - \op@split{#2}{cb}% - \ifop@error - \op@errorwrite - \else - \ifnum\OP@ca@s=1 - \xdef\OP@ca@s{0}% - \op@floor{ca}{cb}% - \xdef\OP@ca@s{1}% - \else - \op@ceil{ca}{cb}% - \fi - \op@unsplit{ca}{#3}% - \fi -} -\def\op@floor#1#2{% - \begingroup - \op@unsplit{#2}{@fb}% - \op@unzero{#1}% - \count@z=\Op@@fb\relax - \ifnum\count@z<0 - \count@z=-\count@z - \ifnum\count@z<\@nameuse{OP@#1@i}\relax\else - \count@z=\@nameuse{OP@#1@i}% - \advance\count@z by-1 - \fi - \op@integer{#1}{#1}% - \loop - \ifnum\count@z>0 - \@namexdef{OP@#1@\the\count@z}{0}% - \advance\count@z by-1\relax - \repeat - \else - \ifnum\count@z>\@nameuse{OP@#1@d}% - \advance\count@z by-\@nameuse{OP@#1@d}% - \count@i=\@nameuse{OP@#1@d}% - \advance\count@i by\count@z - \@namexdef{OP@#1@d}{\the\count@i}% - \count@i=\@nameuse{OP@#1@w}\relax - \count@ii=\count@i - \advance\count@ii by\count@z - \@namexdef{OP@#1@w}{\the\count@ii}% - \loop - \ifnum\count@i>0 - \@namexdef{OP@#1@\the\count@ii}{\@nameuse{OP@#1@\the\count@i}}% - \advance\count@i by-1 - \advance\count@ii by-1 - \repeat - \loop - \ifnum\count@ii>0 - \@namexdef{OP@#1@\the\count@ii}{0}% - \advance\count@ii by-1 - \repeat - \else - \advance\count@z by-\@nameuse{OP@#1@d}\relax - \count@z=-\count@z\relax - \count@i=\@nameuse{OP@#1@w}\relax - \count@ii=\count@i\relax - \advance\count@i by-\count@z - \@namexdef{OP@#1@w}{\the\count@i}\relax - \count@i=\@nameuse{OP@#1@d}\relax - \advance\count@i by-\count@z - \@namexdef{OP@#1@d}{\the\count@i}% - \count@i=0\relax - \loop - \ifnum\count@z<\count@ii - \advance\count@z by1\relax - \advance\count@i by1 - \@namexdef{OP@#1@\the\count@i}{\@nameuse{OP@#1@\the\count@z}}% - \repeat - \fi - \fi - \endgroup -} -\def\op@ceil#1#2{% - \op@unsplit{#1}{@Ca}% - \op@unsplit{#2}{@Cb}% - \op@unzero{#1}% - \count@z=\Op@@Cb\relax - \ifnum\count@z>0\relax - \ifnum\count@z<\@nameuse{OP@#1@d}\relax - \oppower{0.1}{\the\count@z}{@Cr}% - \opadd*{@Ca}{@Cr}{@Ca}% - \op@split{@Ca}{#1}% - \op@split{@Cb}{#2}% - \op@floor{#1}{#2}% - \else - \op@split{@Ca}{#1}% - \op@split{@Cb}{#2}% - \op@floor{#1}{#2}% - \fi - \else - \opneg{@Cb}{@Cb}% - \count@z=-\count@z\relax - \ifnum\count@z<\@nameuse{OP@#1@i}\relax - \oppower{10}{\the\count@z}{@Cr}% - \else - \count@z=\@nameuse{OP@#1@i}% - \advance\count@z by-1 - \oppower{10}{\the\count@z}{@Cr}% - \fi - \opadd*{@Ca}{@Cr}{@Ca}% - \opneg{@Cb}{@Cb}% - \op@split{@Ca}{#1}% - \op@split{@Cb}{#2}% - \op@floor{#1}{#2}% - \fi -} -\edef\opHatCode{\the\catcode`\^} -\catcode`\^=12\relax -\def\opexpr{\@ifnextchar[{\op@exprarg}{\op@exprarg[nil]}} -\def\op@exprarg[#1]{% - \opset{#1}% - \begingroup - \catcode`\^=12 - \catcode`*=12 - \catcode`/=12 - \catcode`:=12 - \catcode`+=12 - \catcode`-=12 - \catcode`.=12 - \catcode`,=12 - \catcode`(=12 - \catcode`)=12 - \catcode`\ =12 - \op@expr -} -\def\op@expr#1{% - \ifop@error - \op@errorwrite - \else - \xdef\op@expression{#1}\endgroup - \ifx\op@expression\empty - \op@error{Empty expression is not valid}% - {I say: "empty expression is not valid"}% - \else - \expandafter\op@scan@line\expandafter{\op@expression}% - \@ifundefined{OP@token\the\op@token}% - {\global\advance\op@token by-1}% - {\relax}% - \global\op@stack=0 - \op@search@term{1}{\the\op@token}% - \fi - \fi - \op@@expr -} -\def\op@@expr#1{% - \ifnum\op@stack=1 - \ifop@error - \op@errorwrite - \else - \opcopy{@s1}{#1}% - \fi - \else - \op@error{Bad expression (not enough operator or operand)}% - {Expression like 2 + 3 3 or 3 * 5 *}% - \op@errorwrite - \fi -} -\def\op@scan@line{% - \begingroup - \global\op@parenthesis=0 - \global\op@token=1 - \global\op@in@numberfalse - \global\op@in@decimalfalse - \global\op@in@namefalse - \global\op@in@signtrue - \catcode`\^=12 - \catcode`*=12 - \catcode`/=12 - \catcode`:=12 - \catcode`+=12 - \catcode`-=12 - \catcode`.=12 - \catcode`,=12 - \catcode`(=12 - \catcode`)=12 - \catcode`\ =12 - \op@scan@@line -} -\def\op@scan@@line#1{\op@scan@@@line#1\@nil\endgroup} -\def\op@scan@@@line#1#2\@nil{% - \op@testch@r{#1}% - \ifop@isdigit - \global\op@in@signfalse - \ifop@in@number - \op@token@append{#1}% - \else\ifop@in@name - \op@token@append{#1}% - \else - \op@in@numbertrue - \op@token@create{#1}% - \fi\fi - \fi - \ifop@isplus - \op@token@single{\op@string@add}% - \global\op@in@signtrue - \fi - \ifop@isminus - \op@token@single{\op@string@sub}% - \global\op@in@signtrue - \fi - \ifop@ismultiply - \op@token@single{\op@string@mul}% - \global\op@in@signtrue - \fi - \ifop@isdivide - \op@token@single{\op@string@div}% - \global\op@in@signtrue - \fi - \ifop@isidivide - \op@token@single{\op@string@idiv}% - \global\op@in@signtrue - \fi - \ifop@ispower - \op@token@single{\op@string@power}% - \global\op@in@signtrue - \fi - \ifop@isdot - \global\op@in@signfalse - \ifop@in@decimal - \op@error{Number width multiple decimal separators}% - {You write something like 12.34.56}% - \else\ifop@in@number - \op@in@decimaltrue - \op@token@append{.}% - \else - \op@token@create{.}% - \op@in@numbertrue - \op@in@decimaltrue - \fi\fi - \fi - \ifop@islparenthesis - \op@token@single{(}% - \global\op@in@signtrue - \fi - \ifop@isrparenthesis - \op@token@single{)}% - \global\op@in@signtrue - \fi - \ifop@iscomma - \op@token@single{,}% - \global\op@in@signtrue - \fi - \ifop@isspace - \ifop@in@number - \op@in@numberfalse - \op@in@decimalfalse - \global\advance\op@token by1 - \else\ifop@in@name - \op@in@namefalse - \global\advance\op@token by1 - \fi\fi - \fi - \ifop@isother - \global\op@in@signfalse - \ifop@in@name - \op@token@append{#1}% - \else\ifop@in@number - \op@in@numberfalse - \op@in@decimalfalse - \op@in@nametrue - \global\advance\op@token by1 - \op@token@create{#1}% - \else - \op@in@nametrue - \op@token@create{#1}% - \fi\fi - \fi - \def\@tempa{#2}% - \ifx\empty\@tempa - \let\next\relax - \else - \let\next\op@scan@@@line - \fi - \expandafter\next\@tempa\@nil -} -\def\op@search@subexpr#1#2{% - \begingroup - \count@i=#1\relax - \count@v=#2\relax - \ifnum\count@i=\count@v - \op@token@use{#1}% - \else - \count@iii=\count@v - \count@iv=\count@i - \advance\count@iv by-1 - \count@ii=0 - \loop - \ifnum\count@iii>\count@iv - \expandafter\ifx\csname OP@token\the\count@iii\endcsname - \op@string@rpar\relax - \advance\op@parenthesis by1 - \fi - \expandafter\ifx\csname OP@token\the\count@iii\endcsname - \op@string@lpar\relax - \advance\op@parenthesis by-1 - \fi - \expandafter\ifx\csname OP@token\the\count@iii\endcsname - \op@string@comma\relax - \ifnum\op@parenthesis=0 - \count@ii=\count@iii\relax - \count@iii=0 - \fi - \fi - \advance\count@iii by-1 - \repeat - \ifnum\count@ii=0\relax - \ifnum\op@parenthesis=0 - \op@search@term{\the\count@i}{\the\count@v}% - \else - \op@error{Unbalanced parenthesis in expression}% - {Error between tokens #1 and #2}% - \fi - \else - \advance\count@ii by-1 - \op@search@subexpr{\the\count@i}{\the\count@ii}% - \advance\count@ii by2 - \op@search@subexpr{\the\count@ii}{\the\count@v}% - \fi - \fi - \endgroup -} -\def\op@search@term#1#2{% - \begingroup - \count@i=#1\relax - \count@v=#2\relax - \ifnum\count@i=\count@v - \op@token@use{#1}% - \else - \count@iii=\count@v - \count@iv=\count@i - \advance\count@iv by-1 - \count@ii=0\relax - \loop - \ifnum\count@iii>\count@iv\relax - \expandafter\ifx\csname OP@token\the\count@iii\endcsname - \op@string@rpar\relax - \advance\op@parenthesis by1 - \fi - \expandafter\ifx\csname OP@token\the\count@iii\endcsname - \op@string@lpar\relax - \advance\op@parenthesis by-1 - \fi - \expandafter\ifx\csname OP@token\the\count@iii\endcsname - \op@string@add\relax - \ifnum\op@parenthesis=0 - \count@ii=\count@iii\relax - \count@iii=0 - \fi - \fi - \expandafter\ifx\csname OP@token\the\count@iii\endcsname - \op@string@sub\relax - \ifnum\op@parenthesis=0 - \count@ii=\count@iii\relax - \count@iii=0 - \fi - \fi - \advance\count@iii by-1 - \repeat - \ifnum\count@ii=0\relax - \ifnum\op@parenthesis=0 - \op@search@factor{\the\count@i}{\the\count@v}% - \else - \op@error{Unbalanced parenthesis in expression}% - {Error between tokens #1 and #2}% - \fi - \else - \advance\count@ii by-1 - \op@search@term{\the\count@i}{\the\count@ii}% - \advance\count@ii by2 - \op@search@term{\the\count@ii}{\the\count@v}% - \advance\count@ii by-1 - \op@token@use{\the\count@ii}% - \fi - \fi - \endgroup -} -\def\op@search@factor#1#2{% - \begingroup - \count@i=#1\relax - \count@v=#2\relax - \ifnum\count@i=\count@v - \op@token@use{#1}% - \else - \count@iii=\count@v - \count@iv=\count@i - \advance\count@iv by-1 - \count@ii=0 - \loop - \ifnum\count@iii>\count@iv - \expandafter\ifx\csname OP@token\the\count@iii\endcsname - \op@string@rpar\relax - \advance\op@parenthesis by1 - \fi - \expandafter\ifx\csname OP@token\the\count@iii\endcsname - \op@string@lpar\relax - \advance\op@parenthesis by-1 - \fi - \expandafter\ifx\csname OP@token\the\count@iii\endcsname - \op@string@mul\relax - \ifnum\op@parenthesis=0 - \count@ii=\count@iii\relax - \count@iii=0 - \fi - \fi - \expandafter\ifx\csname OP@token\the\count@iii\endcsname - \op@string@div\relax - \ifnum\op@parenthesis=0 - \count@ii=\count@iii\relax - \count@iii=0 - \fi - \fi - \expandafter\ifx\csname OP@token\the\count@iii\endcsname - \op@string@idiv\relax - \ifnum\op@parenthesis=0 - \count@ii=\count@iii\relax - \count@iii=0 - \fi - \fi - \advance\count@iii by-1 - \repeat - \ifnum\count@ii=0\relax - \ifnum\op@parenthesis=0 - \op@search@power{\the\count@i}{\the\count@v}% - \else - \op@error{Unbalanced parenthesis in expression}% - {Error between tokens #1 and #2}% - \fi - \else - \advance\count@ii by-1 - \op@search@factor{\the\count@i}{\the\count@ii}% - \advance\count@ii by2 - \op@search@factor{\the\count@ii}{\the\count@v}% - \advance\count@ii by-1 - \op@token@use{\the\count@ii}% - \fi - \fi - \endgroup -} -\def\op@search@power#1#2{% - \begingroup - \count@i=#1\relax - \count@v=#2\relax - \ifnum\count@i=\count@v - \op@token@use{#1}% - \else - \count@iii=\count@v - \count@iv=\count@i - \advance\count@iv by-1 - \count@ii=0 - \loop - \ifnum\count@iii>\count@iv - \expandafter\ifx\csname OP@token\the\count@iii\endcsname - \op@string@rpar\relax - \advance\op@parenthesis by1 - \fi - \expandafter\ifx\csname OP@token\the\count@iii\endcsname - \op@string@lpar\relax - \advance\op@parenthesis by-1 - \fi - \expandafter\ifx\csname OP@token\the\count@iii\endcsname - \op@string@power\relax - \ifnum\op@parenthesis=0 - \count@ii=\count@iii\relax - \count@iii=0 - \fi - \fi - \advance\count@iii by-1 - \repeat - \ifnum\count@ii=0\relax - \ifnum\op@parenthesis=0 - \op@search@primary{\the\count@i}{\the\count@v}% - \else - \op@error{Unbalanced parenthesis in expression}% - {Error between tokens #1 and #2}% - \fi - \else - \advance\count@ii by-1 - \op@search@power{\the\count@i}{\the\count@ii}% - \advance\count@ii by2 - \op@search@power{\the\count@ii}{\the\count@v}% - \advance\count@ii by-1 - \op@token@use{\the\count@ii}% - \fi - \fi - \endgroup -} -\def\op@search@primary#1#2{% - \begingroup - \count@i=#1\relax - \count@v=#2\relax - \ifnum\count@i=\count@v - \op@token@use{#1}% - \else - \expandafter\ifx\csname OP@token#1\endcsname\op@string@abs - \advance\count@i by1 - \op@search@primary{\the\count@i}{\the\count@v}% - \advance\count@i by-1 - \op@token@use{\the\count@i}% - \fi - \expandafter\ifx\csname OP@token#1\endcsname\op@string@ceil - \advance\count@i by1 - \op@search@primary{\the\count@i}{\the\count@v}% - \advance\count@i by-1 - \op@token@use{\the\count@i}% - \fi - \expandafter\ifx\csname OP@token#1\endcsname\op@string@decimal - \advance\count@i by1 - \op@search@primary{\the\count@i}{\the\count@v}% - \advance\count@i by-1 - \op@token@use{\the\count@i}% - \fi - \expandafter\ifx\csname OP@token#1\endcsname\op@string@floor - \advance\count@i by1 - \op@search@primary{\the\count@i}{\the\count@v}% - \advance\count@i by-1 - \op@token@use{\the\count@i}% - \fi - \expandafter\ifx\csname OP@token#1\endcsname\op@string@integer - \advance\count@i by1 - \op@search@primary{\the\count@i}{\the\count@v}% - \advance\count@i by-1 - \op@token@use{\the\count@i}% - \fi - \expandafter\ifx\csname OP@token#1\endcsname\op@string@gcd - \advance\count@i by1 - \op@search@primary{\the\count@i}{\the\count@v}% - \advance\count@i by-1 - \op@token@use{\the\count@i}% - \fi - \expandafter\ifx\csname OP@token#1\endcsname\op@string@mod - \advance\count@i by1 - \op@search@primary{\the\count@i}{\the\count@v}% - \advance\count@i by-1 - \op@token@use{\the\count@i}% - \fi - \expandafter\ifx\csname OP@token#1\endcsname\op@string@neg - \advance\count@i by1 - \op@search@primary{\the\count@i}{\the\count@v}% - \advance\count@i by-1 - \op@token@use{\the\count@i}% - \fi - \expandafter\ifx\csname OP@token#1\endcsname\op@string@rest - \advance\count@i by1 - \op@search@primary{\the\count@i}{\the\count@v}% - \advance\count@i by-1 - \op@token@use{\the\count@i}% - \fi - \expandafter\ifx\csname OP@token#1\endcsname\op@string@round - \advance\count@i by1 - \op@search@primary{\the\count@i}{\the\count@v}% - \advance\count@i by-1 - \op@token@use{\the\count@i}% - \fi - \expandafter\ifx\csname OP@token#1\endcsname - \op@string@lpar\relax - \expandafter\ifx\csname OP@token#2\endcsname - \op@string@rpar\relax - \advance\count@i by1 - \advance\count@v by-1 - \op@search@subexpr{\the\count@i}{\the\count@v}% - \else - \op@error{Garbage after parenthesis}% - {Error between tokens #1 and #2}% - \fi - \fi - \fi - \endgroup -} -\def\op@token@use#1{% - \edef\op@arg{\@nameuse{OP@token#1}}% - \ifx\op@arg\op@string@abs - \opabs{@s\the\op@stack}{@s\the\op@stack}% - \else\ifx\op@arg\op@string@add - \global\op@stackb=\op@stack - \global\advance\op@stackb by-1 - \opadd*{@s\the\op@stackb}{@s\the\op@stack}{@s\the\op@stackb}% - \global\op@stack=\op@stackb - \else\ifx\op@arg\op@string@ceil - \global\op@stackb=\op@stack - \global\advance\op@stackb by-1 - \opceil{@s\the\op@stackb}{@s\the\op@stack}{@s\the\op@stackb}% - \global\op@stack=\op@stackb - \else\ifx\op@arg\op@string@decimal - \opdecimal{@s\the\op@stack}{@s\the\op@stack}% - \else\ifx\op@arg\op@string@div - \global\op@stackb=\op@stack - \global\advance\op@stackb by-1 - \opdiv*{@s\the\op@stackb}{@s\the\op@stack}{@s\the\op@stackb}{r}% - \global\op@stack=\op@stackb - \else\ifx\op@arg\op@string@floor - \global\op@stackb=\op@stack - \global\advance\op@stackb by-1 - \opfloor{@s\the\op@stackb}{@s\the\op@stack}{@s\the\op@stackb}% - \global\op@stack=\op@stackb - \else\ifx\op@arg\op@string@gcd - \op@stackb=\op@stack - \global\advance\op@stackb by-1 - \opgcd{@s\the\op@stackb}{@s\the\op@stack}{@s\the\op@stackb}% - \global\op@stack=\op@stackb - \else\ifx\op@arg\op@string@idiv - \global\op@stackb=\op@stack - \global\advance\op@stackb by-1 - \opidiv*{@s\the\op@stackb}{@s\the\op@stack}{@s\the\op@stackb}{r}% - \global\op@stack=\op@stackb - \else\ifx\op@arg\op@string@integer - \opinteger{@s\the\op@stack}{@s\the\op@stack}% - \else\ifx\op@arg\op@string@mod - \global\op@stackb=\op@stack - \global\advance\op@stackb by-1 - \opidiv*{@s\the\op@stackb}{@s\the\op@stack}{@q}{@s\the\op@stackb}% - \global\op@stack=\op@stackb - \else\ifx\op@arg\op@string@mul - \global\op@stackb=\op@stack - \global\advance\op@stackb by-1 - \opmul*{@s\the\op@stackb}{@s\the\op@stack}{@s\the\op@stackb}% - \global\op@stack=\op@stackb - \else\ifx\op@arg\op@string@neg - \opneg{@s\the\op@stack}{@s\the\op@stack}% - \else\ifx\op@arg\op@string@power - \global\op@stackb=\op@stack - \global\advance\op@stackb by-1 - \oppower{@s\the\op@stackb}{@s\the\op@stack}{@s\the\op@stackb}% - \global\op@stack=\op@stackb - \else\ifx\op@arg\op@string@rest - \global\op@stackb=\op@stack - \global\advance\op@stackb by-1 - \opdiv*{@s\the\op@stackb}{@s\the\op@stack}{@q}{@s\the\op@stackb}% - \global\op@stack=\op@stackb - \else\ifx\op@arg\op@string@round - \global\op@stackb=\op@stack - \global\advance\op@stackb by-1 - \opround{@s\the\op@stackb}{@s\the\op@stack}{@s\the\op@stackb}% - \global\op@stack=\op@stackb - \else\ifx\op@arg\op@string@sub - \global\op@stackb=\op@stack - \global\advance\op@stackb by-1 - \opsub*{@s\the\op@stackb}{@s\the\op@stack}{@s\the\op@stackb}% - \global\op@stack=\op@stackb - \else - \global\advance\op@stack by1\relax - \opcopy{\op@arg}{@s\the\op@stack}% - \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi -} -\def\op@token@create#1{% - \@namexdef{OP@token\the\op@token}{#1}% - \global\advance\op@token by1 - \expandafter\global - \expandafter\let\csname OP@token\the\op@token\endcsname\relax - \global\advance\op@token by-1 -} -\def\op@token@append#1{% - \@namexdef{OP@token\the\op@token}{% - \@nameuse{OP@token\the\op@token}#1}% -} -\def\op@token@single#1{% - \edef\@tempa{#1}% - \ifop@in@name - \global\advance\op@token by1 - \op@in@namefalse - \fi - \ifop@in@number - \global\advance\op@token by1 - \op@in@numberfalse - \op@in@decimalfalse - \fi - \ifx\@tempa\op@string@add - \ifop@in@sign - \global\advance\op@token by-1 - \else - \op@token@create{#1}% - \fi - \else\ifx\@tempa\op@string@sub - \ifop@in@sign - \op@token@create{\op@string@neg}% - \else - \op@token@create{#1}% - \fi - \else - \op@token@create{#1}% - \fi\fi - \global\advance\op@token by1 -} -\def\op@testch@r#1{% - \op@isdigitfalse - \op@isplusfalse - \op@isminusfalse - \op@ismultiplyfalse - \op@isdividefalse - \op@isidividefalse - \op@ispowerfalse - \op@isdotfalse - \op@iscommafalse - \op@islparenthesisfalse - \op@isrparenthesisfalse - \op@isspacefalse - \op@isotherfalse - \count255=`#1\relax - \ifnum\count255=\op@plus \relax - \op@isplustrue - \else \ifnum\count255=\op@minus \relax - \op@isminustrue - \else \ifnum\count255=\op@multiply \relax - \op@ismultiplytrue - \else \ifnum\count255=\op@divide \relax - \op@isdividetrue - \else \ifnum\count255=\op@idivide \relax - \op@isidividetrue - \else \ifnum\count255=\op@pow \relax - \op@ispowertrue - \else \ifnum\count255=\op@dot \relax - \op@isdottrue - \else \ifnum\count255=\op@comma \relax - \op@iscommatrue - \else \ifnum\count255=\op@lparenthesis \relax - \op@islparenthesistrue - \else \ifnum\count255=\op@rparenthesis \relax - \op@isrparenthesistrue - \else \ifnum\count255=\op@space \relax - \op@isspacetrue - \else \ifnum\count255<\op@numbegin \relax - \op@isothertrue - \else \ifnum\count255>\op@numend \relax - \op@isothertrue - \else \op@isdigittrue - \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi -} -\op@split{0}{T0} -\op@split{0}{zero} -\op@split{1}{one} -\op@split{10}{ten} -\op@split{0.1}{tenth} -\op@split{2147483647}{maxinteger} -\op@split{214748364}{maxdivperiod} -\op@split{1073741823}{maxpower} -\catcode`\^=\opHatCode\relax -\catcode`\@=\opAtCode\relax -\endinput |