summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/xlop
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-01-08 22:20:53 +0000
committerKarl Berry <karl@freefriends.org>2017-01-08 22:20:53 +0000
commit2fe97cec533b012f5030d9674055e5ef35b77e38 (patch)
treefd3b949c321850e7041ad808839f52e2d26f5cf6 /Master/texmf-dist/tex/generic/xlop
parente0f23b69a26bc15ad216fdc2acaaa91d7f300628 (diff)
xlop (8jan17)
git-svn-id: svn://tug.org/texlive/trunk@42899 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/xlop')
-rw-r--r--Master/texmf-dist/tex/generic/xlop/xlop.tex240
1 files changed, 236 insertions, 4 deletions
diff --git a/Master/texmf-dist/tex/generic/xlop/xlop.tex b/Master/texmf-dist/tex/generic/xlop/xlop.tex
index 057cea4540a..ef3360dd438 100644
--- a/Master/texmf-dist/tex/generic/xlop/xlop.tex
+++ b/Master/texmf-dist/tex/generic/xlop/xlop.tex
@@ -1,12 +1,12 @@
-\def\fileversion{0.25}
-\def\filedate{2013/02/26}
+\def\fileversion{0.26}
+\def\filedate{2017/01/07}
%%
%% 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
+%% Copyright 2005,2017, by Jean-C\^ome Charpentier
%% Jean-Come.Charpentier@wanadoo.fr
%%
%% This program may be distributed and/or modified under the
@@ -933,6 +933,11 @@
\advance\op@count@i by1
\xdef\op@@export{\@nameuse{OP@tmp@\the\op@count@vi}\op@@export}%
\repeat
+ % add 0.26
+ \ifnum\OP@tmp@s=1
+ \xdef\op@@export{-\op@@export}%
+ \fi
+ % end add 0.26
\fi
% comment 0.24
% \fi
@@ -1878,7 +1883,7 @@
\op@split{#3}{b}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Ajout du 20/11/2006 %%%
-%%% Sur indication de Cristophe Poulain %%%
+%%% Sur indication de Christophe Poulain %%%
\op@cmp{b}{zero}%
\ifopeq
\op@error{divisor must be nonzero}%
@@ -3481,6 +3486,233 @@
\op@floor{#1}{#2}%
\fi
}
+% add 0.26
+\op@split{0}{@zero}
+\op@split{1}{@one}
+\op@split{2}{@two}
+\op@split{3}{@three}
+\op@split{4}{@four}
+\op@split{5}{@five}
+\op@split{6}{@six}
+\op@split{7}{@seven}
+\op@split{8}{@height}
+\op@split{9}{@nine}
+\op@split{10}{@ten}
+
+\def\opsqrt{%
+ \@ifnextchar[{\op@sqrt}{\op@sqrt[nil]}%]
+}
+\def\op@sqrt[#1]#2#3{%
+ \begingroup
+ \opset{#1}%
+ \opcmp{0}{#2}%
+ \ifopeq
+ \op@copy{@zero}{U}%
+ \let\op@savemaxdivstep\op@maxdivstep
+ \else
+ \op@split{#2}{z}%
+ \op@count@z=\OP@z@i
+ \divide\op@count@z by2
+ \edef\op@savemaxdivstep{\op@maxdivstep}%
+ \op@count@i=\op@maxdivstep
+ \advance\op@count@i by\op@count@z
+ \advance\op@count@i by1
+ \edef\op@maxdivstep{\the\op@count@i}%
+ \ifodd\OP@z@i
+ \xdef\op@initsqrt{\@nameuse{OP@z@\OP@z@w}}%
+ \else
+ \op@count@z=\OP@z@w
+ \xdef\op@initsqrt{\@nameuse{OP@z@\the\op@count@z}}%
+ \advance\op@count@z by-1
+ \xdef\op@initsqrt{\op@initsqrt\@nameuse{OP@z@\the\op@count@z}}%
+ \fi
+ \ifnum\op@initsqrt<1
+ \op@copy{@zero}{u}%
+ \else\ifnum\op@initsqrt<3
+ \op@copy{@one}{u}%
+ \else\ifnum\op@initsqrt<7
+ \op@copy{@two}{u}%
+ \else\ifnum\op@initsqrt<13
+ \op@copy{@three}{u}%
+ \else\ifnum\op@initsqrt<21
+ \op@copy{@four}{u}%
+ \else\ifnum\op@initsqrt<31
+ \op@copy{@five}{u}%
+ \else\ifnum\op@initsqrt<43
+ \op@copy{@six}{u}%
+ \else\ifnum\op@initsqrt<57
+ \op@copy{@seven}{u}%
+ \else\ifnum\op@initsqrt<73
+ \op@copy{@height}{u}%
+ \else\ifnum\op@initsqrt<91
+ \op@copy{@nine}{u}%
+ \else
+ \op@copy{@ten}{u}%
+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+ \op@count@ii=\OP@z@i
+ \advance\op@count@ii by1
+ \divide\op@count@ii by2
+ \advance\op@count@ii by-1
+ \op@lshift{\the\op@count@ii}{u}%
+ \op@count@z=\OP@z@w
+ \advance\op@count@z by1
+ \edef\op@@maxdivstep{\op@maxdivstep}%
+ \loop
+ \op@mul{u}{u}{U}%
+ \op@add{U}{z}{U}%
+ \op@mul{u}{@two}{D}%
+ \edef\op@maxdivstep{\the\op@count@z}%
+ \op@div{0}{U}{D}{U}{r}%
+ \multiply\op@count@z by2
+ \ifnum\op@count@z>\op@@maxdivstep
+ \op@count@z=\op@@maxdivstep
+ \fi
+ \op@cmp{u}{U}%
+ \ifopneq
+ \op@copy{U}{u}%
+ \repeat
+ \fi
+ \op@unsplit{U}{#3}%
+ \opround{#3}{\op@savemaxdivstep}{#3}%
+ \endgroup
+}
+
+\def\opgfsqrt{%
+ \@ifnextchar[{\op@gfsqrt}{\op@gfsqrt[nil]}%]
+}
+\def\op@gfsqrt[#1]#2{%
+ \begingroup
+ \edef\op@saveparindent{\the\parindent}%
+ \parindent=0pt
+ \opset{#1}%
+ \op@split{#2}{sq}%
+ \opsqrt{#2}{@sqrt}%
+ \op@split{@sqrt}{sqrt}%
+ \op@split{\op@initsqrt}{init}%
+ \op@count@z=\OP@sqrt@w
+ \op@split{\@nameuse{OP@sqrt@\the\op@count@z}}{atosub}%
+ \op@mul{atosub}{atosub}{tosub}%
+ \setbox1=\hbox{\kern\opcolumnwidth
+ \op@display{operandstyle.1}{sq}}%
+ \setbox2=\vtop{%
+ \hbox{\ophline(-0.5,-0.25){\OP@sqrt@w.5}%
+ \op@display{resultstyle}{sqrt}}%
+ \hbox{\op@display{intermediarystyle.1}{atosub}%
+ \hbox to\opcolumnwidth{\hss\op@mulsymbol\hss}%
+ \op@display{intermediarystyle.1}{atosub}%
+ \hbox to\opcolumnwidth{\hss\op@equalsymbol\hss}%
+ \op@display{operandstyle.2}{tosub}}%
+ }
+ \op@sub{init}{tosub}{rest}%
+ \op@count@ii=\OP@init@w
+ \op@count@iii=\op@count@ii
+ \advance\op@count@iii by1
+ \setbox1=\hbox{\hsize=\op@count@iii\opcolumnwidth\vtop{%
+ \box1
+ \hbox{%
+ \op@makebox{\the\op@count@iii}{0}%
+ {operandstyle.2}{tosub}%
+ \box0}}}%
+ \op@unzero{rest}%
+ \op@copy{@zero}{cursqrt}%
+ \op@copy{@zero}{digitmul}%
+ \op@count@i=\OP@sq@w
+ \advance\op@count@i by-\OP@init@w
+ \op@count@iv=2
+ \loop
+ \ifnum\op@count@z>1
+ \op@lshift{2}{rest}%
+ \ifnum\op@count@i>0
+ \@namexdef{OP@rest@2}{\@nameuse{OP@sq@\the\op@count@i}}%
+ \advance\op@count@i by-1
+ \ifnum\op@count@i>0
+ \@namexdef{OP@rest@1}{\@nameuse{OP@sq@\the\op@count@i}}%
+ \advance\op@count@i by-1
+ \fi
+ \fi
+ \op@count@ii=\op@count@iii
+ \advance\op@count@ii by-\OP@tosub@w
+ \advance\op@count@ii by-1
+ \advance\op@count@iii by2
+ \setbox1=\hbox{\hsize=\op@count@iii\opcolumnwidth
+ \vtop{%
+ \hbox{\box1}%
+ \hbox{%
+ \oplput(\op@count@ii,0.75){\ophline(0,0){1}}%
+ \oplput(\op@count@ii,0.75){\ophline(1,0){\OP@tosub@w}}%
+ \advance\op@count@iv by-1
+ \op@makebox{\the\op@count@iii}{0}%
+ {remainderstyle.\the\op@count@iv}{rest}%
+ \advance\op@count@iv by1
+ \oplput(\op@count@ii,1.5){$-$}%
+ \box0}%
+ }}%
+ \op@multen{cursqrt}%
+ \@namexdef{OP@cursqrt@1}%
+ {\@nameuse{OP@sqrt@\the\op@count@z}}%
+ \advance\op@count@z by-1
+ \op@mul{cursqrt}{@two}{atosub}%
+ \op@unzero{atosub}%
+ \op@multen{atosub}%
+ \@namexdef{OP@atosub@1}%
+ {\@nameuse{OP@sqrt@\the\op@count@z}}%
+ \@namexdef{OP@digitmul@1}%
+ {\@nameuse{OP@sqrt@\the\op@count@z}}%
+ \op@mul{atosub}{digitmul}{tosub}%
+ \op@unzero{tosub}%
+ \setbox2=\hbox{\vtop{%
+ \hbox{\box2}%
+ \hbox{\vrule width0pt height0pt
+ depth\oplineheight}%
+ \hbox{%
+ \op@display
+ {intermediarystyle.\the\op@count@iv}{atosub}%
+ \hbox to\opcolumnwidth{\hss\op@mulsymbol\hss}%
+ \op@display
+ {intermediarystyle.\the\op@count@iv}{digitmul}%
+ \hbox to\opcolumnwidth{\hss\op@equalsymbol\hss}%
+ \advance\op@count@iv by1
+ \op@display{operandstyle.\the\op@count@iv}{tosub}%
+ }%
+ }}%
+ \op@sub{rest}{tosub}{rest}%
+ \op@unzero{rest}%
+ \advance\op@count@iv by1
+ \setbox1=\hbox{\hsize=\op@count@iii\opcolumnwidth
+ \vtop{%
+ \hbox{\box1}%
+ \hbox{%
+ \op@makebox{\the\op@count@iii}{0}%
+ {operandstyle.\the\op@count@iv}{tosub}%
+ \box0}}}%
+ \repeat
+ \op@count@ii=\op@count@iii
+ \advance\op@count@ii by-\OP@tosub@w
+ \advance\op@count@ii by-1
+ \setbox1=\hbox{\hsize=\op@count@iii\opcolumnwidth
+ \vtop{%
+ \hbox{\box1}%
+ \hbox{%
+ \oplput(\op@count@ii,0.75){%
+ \ophline(0,0){1}}%
+ \oplput(\op@count@ii,0.75){%
+ \ophline(1,0){\OP@tosub@w}}%
+ \op@makebox{\the\op@count@iii}{0}%
+ {remainderstyle.\the\op@count@iv}{rest}%
+ \oplput(\op@count@ii,1.5){$-$}%
+ \box0}%
+ }%
+ }%
+ \parindent=\op@saveparindent
+ \leavevmode\hbox{%
+ \box1
+ \kern0.5\opcolumnwidth
+ \vrule
+ \kern0.5\opcolumnwidth
+ \box2}%
+ \endgroup
+ }
+% end add 0.26
\edef\opHatCode{\the\catcode`\^}
\catcode`\^=12\relax
\def\opexpr{\@ifnextchar[{\op@exprarg}{\op@exprarg[nil]}}