diff options
author | Karl Berry <karl@freefriends.org> | 2016-01-03 22:15:29 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-01-03 22:15:29 +0000 |
commit | 339b409afa91db4c85735e3320e9a7b0b362f052 (patch) | |
tree | e8fc129d431f3326b8cac4bf895f594f2e37be08 /Master/texmf-dist/tex/generic | |
parent | bdb7a6514bc9dd631b9c574425f7b376b3e3f9c9 (diff) |
apnum (3jan16)
git-svn-id: svn://tug.org/texlive/trunk@39265 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic')
-rw-r--r-- | Master/texmf-dist/tex/generic/apnum/apnum.tex | 89 |
1 files changed, 82 insertions, 7 deletions
diff --git a/Master/texmf-dist/tex/generic/apnum/apnum.tex b/Master/texmf-dist/tex/generic/apnum/apnum.tex index 919c95fa0c9..e3a7bb53161 100644 --- a/Master/texmf-dist/tex/generic/apnum/apnum.tex +++ b/Master/texmf-dist/tex/generic/apnum/apnum.tex @@ -4,7 +4,7 @@ % See the documentation apnum.pdf or apnum.d for more information -\def\apVERSION{1.4a <Dec 2015>} +\def\apVERSION{1.5 <Jan 2016>} \message{The Arbitrary Precision Numbers, \apVERSION} %%%%%%%%%%%% Internal registers, sec. 2.1 in apnum.pdf @@ -591,7 +591,7 @@ \def\apROUNDd#1.@#2{\def\XOUT{#1}\edef\XOUT{\apREMzerosR\XOUT}% \ifnum\apnumX=0 \def\tmpd{}\fi \ifx\tmpd\empty - \ifx\tmpc\empty \def#2{0}% + \ifx\tmpc\empty \def#2{0}% \else \edef#2{\ifnum\apnumG<0-\fi\tmpc}\fi \else\edef#2{\ifnum\apnumG<0-\fi\tmpc.\tmpd}\fi } @@ -722,12 +722,17 @@ \let\OUT=\XOUT % remainder is the output \apEND % end of group } -\def\iROUND#1{\relax \evaldef\OUT{#1}\apEnum\OUT \apROUND\OUT0} +\def\iFLOOR#1{\relax \evaldef\OUT{#1}\apEnum\OUT \apROUND\OUT0% + \ifnum\apSIGN<0 \ifx\XOUT\empty \else \apPLUS\OUT{-1}\fi\fi + \def\tmp{0}\ifx\tmp\OUT \apSIGN=0 \fi +} \def\iFRAC#1{\relax \evaldef\OUT{#1}\apEnum\OUT \apROUND\OUT0% % preparing the parameter - \ifx\XOUT\empty \def\OUT{0}\apSIGN=0 % empty fraction part means zero - \else \edef\OUT{.\XOUT}\apSIGN=1 % else OUT = dot+fraction part - \fi + \ifx\XOUT\empty \def\OUT{0}\apSIGN=0 % empty fraction part means zero + \else \ifnum\apSIGN<0 + \edef\XOUT{-.\XOUT}\apPLUS1\XOUT % OUT = 1 - .\XOUT + \else \edef\OUT{.\XOUT}\apSIGN=1 % else OUT = .\XOUT + \fi \fi } \def\FAC#1{\relax \apINIT % "function-like" in the group, FAC = factorial @@ -999,6 +1004,7 @@ \ifnum\apTOT=0 \advance\apFRAC by-3 \else \apFRAC=\apTOT \fi \ifnum\apFRAC<0 \apFRAC=-\apFRAC \fi \apROUND\OUT\apFRAC + \def\X{0}\ifx\OUT\X \apSIGN=0 \fi \ifnum\apSIGN<0 \edef\OUT{-\OUT}\fi \apEND } @@ -1060,8 +1066,73 @@ } \def\ACOS#1{\relax \apPIexec \apPLUS\apPIhalf{-\ASIN{#1}}} +%%%%%%%%%%%% Printing expressions, sec 2.11 in apnum.pdf + +\def\eprint#1#2{\bgroup \apnumA=0 \apnumE=1 \apEVALb#1\limits + \let\apEPe=\relax \apEPi #2\tmpb \apEPe \egroup +} +\def\apEPi{\let\apPLUS=\apEPplus \let\apMINUS=\apEPminus + \let\apMUL=\apEPmul \let\apDIV=\apEPdiv \let\apPOWx=\apEPpow \def\apPPn##1{##1}% + \let\EXP=\apEPexp \def\LN{\apEPf{ln}}\let\SQRT=\apEPsqrt + \def\SIN{\apEPf{sin}}\def\COS{\apEPf{cos}}\def\TAN{\apEPf{tan}}% + \def\ASIN{\apEPf{arcsin}}\def\ACOS{\apEPf{arccos}}\def\ATAN{\apEPf{arctan}}% + \let\PI=\pi \def\PIhalf{{\pi\over2}}% + \let\ABS=\apEPabs \let\FAC=\apEPfac \let\BINOM=\apEPbinom + \let\SGN=\apEPsgn \let\iDIV=\apEPidiv \let\iMOD=\apEPimod + \let\iFLOOR=\apEPifloor \let\iFRAC=\apEPifrac + \let\apEPi=\relax \apEPj +} +\def\apEPj{} +\def\apEPplus#1#2{{#1}+{#2}} +\def\apEPminus#1#2{{#1}-\apEPp#2\empty\end!!...} +\def\apEPmul#1#2{\def\tmpa{#1}\def\tmpb{-1}% + \ifx\tmpa\tmpb -\else \apEPp#1\empty\end!!...\apMULop\fi + \apEPp#2\empty\end!!!..} +\def\apEPdiv#1#2{{#1}\over{#2}} +\def\apEPpow#1#2{% + \let\apEPy=\empty \apEPpowa{#1}\end{#2}% + \ifx\apEPy\empty \apEPp#1\empty\end!!!!!^{#2}\else#1\fi +} +\def\apEPpowa#1{\expandafter\apEPpowb#1;} +\def\apEPpowb#1#2;\end#3{\ifx#1\apEPf \def\apEPy{\let\apEPy=\empty #3}\fi} +\let\apEPy=\empty +\def\apEPf#1#2{\mathop{\rm#1}\nolimits + \ifx\apEPy\empty \else ^{\apEPy}\let\apEPy=\empty \fi + \eprint{#2}{\expandafter\apEPb}% +} +\def\apEPb#1{\def\next{\left(\def\apEPe{\right)}}% + \ifx\apPPn#1\let\next=\relax \fi + \ifx\apDIV#1\let\next=\relax \fi + \next#1% +} +\def\apEPp#1#2\end#3#4#5#6#7{% + \apEPa#1\bgroup{\left(}#3#4#5#6#7#1#2\apEPa#1\egroup{\right)}#3#4#5#6#7} +\def\apEPa#1#2#3#4#5#6#7#8{% + \ifx#1\apEPplus \ifx#4.#2\else#3\fi\fi + \ifx#1\apEPminus \ifx#5.#2\else#3\fi\fi + \ifx#1\apEPmul \ifx#6.#2\else#3\fi\fi + \ifx#1\apEPdiv \ifx#7.#2\else#3\fi\fi + \ifx#1\apEPpow \ifx#8.#2\else#3\fi\fi + \ifx#1-\empty \ifx#6.#2\else#3\fi\fi +} +\let\apMULop=\cdot +\def\apEPabs#1{\left|\eprint{#1}{}\right|} +\def\apEPfac#1{\eprint{#1}{\expandafter\apEPb}\,!} +\def\apEPbinom#1#2{{\eprint{#1}{}\choose\eprint{#2}{}}} +\def\apEPsqrt#1{\sqrt{\eprint{#1}{}}} +\def\apEPexp#1{{\rm e}^{\eprint{#1}{}}} +\def\apEPsgn#1{\mathop{\rm sign}\eprint{#1}{\expandafter\apEPb}} +\def\apEPdivmod#1#2#3{\left[\eprint{#2}{\expandafter\apEPb}% + \mathbin{\rm #1}\eprint{#3}{\expandafter\apEPb}\right]} +\def\apEPidiv{\apEPdivmod{div}} +\def\apEPimod{\apEPdivmod{mod}} +\def\apEPifloor#1{\left\lfloor\eprint{#1}{}\right\rfloor} +\def\apEPifrac#1{\left\{\eprint{#1}{}\right\}} + +\def\corrnum#1{\edef#1{\expandafter\apEPc#1\end}} +\def\apEPc#1#2\end{\ifx#1-{-}\apEPc#2\end\else \ifx#1.0.#2\else #1#2\fi\fi} -%%%%%%%%%%%% Conclusion, sec. 2.11 in apnum.pdf +%%%%%%%%%%%% Conclusion, sec. 2.12 in apnum.pdf \let\PLUS=\apPLUS \let\MINUS=\apMINUS \let\MUL=\apMUL \let\DIV=\apDIV \let\POW=\apPOW \let\SIGN=\apSIGN \let\ROUND=\apROUND \let\NORM=\apNORM \let\ROLL=\apROLL @@ -1097,3 +1168,7 @@ - \SIN, \COS, \TAN added - \apTOT=0 by default 1.4a \end -> \limits, internal change in \ebvaldef because LaTeX redefines \end +1.4b \apSINCOS: \ifx\OUT eq 0 added after \apROUND (bug fixed). +1.5 <Jan 2015> + - \iROUND replaced by \iFLOOR, \iFRAC corrected (for negative numbers) + - \eprint introduced |