texlive[64424] Master/texmf-dist: calculator (17sep22)
commits+karl at tug.org
commits+karl at tug.org
Sat Sep 17 21:55:48 CEST 2022
Revision: 64424
http://tug.org/svn/texlive?view=revision&revision=64424
Author: karl
Date: 2022-09-17 21:55:48 +0200 (Sat, 17 Sep 2022)
Log Message:
-----------
calculator (17sep22)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/calculator/calculator.pdf
trunk/Master/texmf-dist/source/latex/calculator/calculator.dtx
trunk/Master/texmf-dist/source/latex/calculator/calculator.ins
trunk/Master/texmf-dist/tex/latex/calculator/calculator.sty
trunk/Master/texmf-dist/tex/latex/calculator/calculus.sty
Added Paths:
-----------
trunk/Master/texmf-dist/doc/latex/calculator/README.md
Removed Paths:
-------------
trunk/Master/texmf-dist/doc/latex/calculator/README
trunk/Master/texmf-dist/doc/latex/calculator/examples/
Deleted: trunk/Master/texmf-dist/doc/latex/calculator/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/calculator/README 2022-09-17 19:54:32 UTC (rev 64423)
+++ trunk/Master/texmf-dist/doc/latex/calculator/README 2022-09-17 19:55:48 UTC (rev 64424)
@@ -1,140 +0,0 @@
-
-The calculator and calculus packages: Use \LaTeX as a scientific calculator.
-
-Robert Fuster, 2012, 2014
-
-
-1. Licence
-----------
-This material is subject to the LaTeX Project Public License.
-
-See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
-for the details of that license.
-
-2. Changes in version 2.0
--------------------------
-- Inverse trigonometric and inverse hyperbolic functions are added
- (this completes the typical elementary functions)
-
-- Also vector (cross) product and angle between vectors can be evaluated
-
-- New length operations
-
-- ... and some other minor additions and changes
-
-3. About the packages
----------------------
-The calculator and calculus packages define several instructions which allow us
-to realize algebraic operations and to evaluate elementary functions
-and derivatives in our documents.
-
-My main goal is to define the arithmetic and functional calculations I need in
-my package "xpicture"
-(http://ctan.org/pkg/xpicture, http://www.upv.es/~rfuster/xpicture),
-but the numeric abilities of "calculator" and "calculus" may be useful
-in other contexts.
-
-3.1 The calculator package
---------------------------
-The operations implemented by the calculator package include
-- arithmetical calculations with real and integer numbers
-- two and three dimensional vectors and matrices arithmetics
-- computation of powers, square roots, trigonometric, exponential,
- logarithmic, hyperbolic, inverse trigonometric
- and inverse hyperbolic functions.
-
-In addition, some important numbers, such as pi, sqrt(2) or e, are predefined.
-
-Some simple examples:
-
-a) Simplify a fraction: if you type
-
- \FRACTIONSIMPLIFY{252}{2220}{\num}{\den}
-
- Then, $\num/\den$ equals to 21/186
-
-b) Compute elementary functions:
-
- \LOG{2}{\sol} ---> \sol equals 0.69315
-
- \LOG[10]{2}{\sol} ---> \sol equals 0.30103
-
- \SIN{\numberHALFPI}{\sol} ---> \sol equals 1
-
-c) More complex calculations:
- You can compute the value of sqrt(7.25)cos(pi/7) by typing
-
- \SQRT{7.25}{\tempa}
- \DIVIDE{\numberPI}{7}{\tempb}
- \COS{\tempb}{\tempc}
- \MULTIPLY{\tempa}{\tempc}{\sol}
-
- Then, the value 2.42589 is stored in \sol.
-
-d) Vectors and matrices:
-
- \SCALARPRODUCT(1,2)(2,1){\sol} ---> \sol equals 4
-
- \MATRIXPRODUCT(1,1;-1,2)(0,-1;1,1)(\sola,\solb;\solc,\sold)
- ---> \sola, \solb, \solc, \sold equals 1, 0, 2, 3.
-
-
-3.2. The calculus package
--------------------------
-This package adds to the calculator package several utilities to use and define
-real functions and their derivatives, including elementary functions,
-operations with functions, vector-valuated functions polar coordinates.
-When you call a "function", this function ant its derivative are evaluated
-simultaneously.
-
-Examples:
-
-a) Predefined functions:
-
- \SINfunction{\numberPI}{\sol}{\Dsol} --->
- \sol equals to 0 (=sin(pi)), and \Dsol equals -1 (=cos(pi)),
- because cos(t) is the derivative of sin(t).
-
-b) Defining new functions: You can define the function f(t)=exp(2t)cos(t)-t
-with the following code:
-
- \SCALEVARIABLEfunction{2}{\EXPfunction}{\functionA} % A=e^(2t)
- \MULTIPLY{\functionA}{\COSfunction}{\functionB} % b=e^(2t)cos(t)
- \SUBTRACTfunction{\functionB}{\IDENTITYfunction}{\functionF} % My function
-
-Then, \functionF{num}{\sol}{\Dsol} stores f(num) and f'(num) in \sol and \Dsol.
-
-
-4. Installation and documentation
----------------------------------
-1. Compile the installation file "calculator.ins",
-
- >> latex calculator.ins
-
- to generate the two essential files,
-
- "calculator.sty" and "calculus.sty".
-
- Move these two files where LaTeX search for
- (typically, in a local texmf tree, at tex/latex/calculator)
- and refresh the file database.
-
-2. To have the documentation and user's manual, "calculator.pdf",
- compile the source file "calculator.dtx" in the following sequence:
-
- >> pdflatex calculator.dtx
- >> makeindex -s gind.ist -o calculator.ind calculator.idx
- >> makeindex -s gglo.ist -o calculator.gls calculator.glo
- >> pdflatex calculator.dtx
- >> pdflatex calculator.dtx
-
-In addition, many small files, named "calculatorNN.tex" are generated.
-These files contain the source code of all examples included in the manual.
-You can store or discard this files.
-
----------------------------------------------------------------
-Robert Fuster
-rfuster at mat.upv.es
-
-Universitat Polit\`ecnica de Val\`encia, 2012/05/19, 2014/02/23
----------------------------------------------------------------
\ No newline at end of file
Added: trunk/Master/texmf-dist/doc/latex/calculator/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/calculator/README.md (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/calculator/README.md 2022-09-17 19:55:48 UTC (rev 64424)
@@ -0,0 +1,143 @@
+The calculator and calculus packages: Use \LaTeX as a scientific calculator.
+
+Robert Fuster, 2012, 2014, 2022
+
+
+1. Licence
+----------
+This material is subject to the LaTeX Project Public License.
+
+See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
+for the details of that license.
+
+2. Changes in version 2.1
+-------------------------
+- Some bugs fixed
+
+2. Changes in version 2.0
+-------------------------
+- Inverse trigonometric and inverse hyperbolic functions are added
+ (this completes the typical elementary functions)
+
+- Also vector (cross) product and angle between vectors can be evaluated
+
+- New length operations
+
+- ... and some other minor additions and changes
+
+3. About the packages
+---------------------
+The calculator and calculus packages define several instructions which allow us
+to realize algebraic operations and to evaluate elementary functions
+and derivatives in our documents.
+
+My main goal is to define the arithmetic and functional calculations I need in
+my package "xpicture"
+(http://ctan.org/pkg/xpicture, http://www.upv.es/~rfuster/xpicture),
+but the numeric abilities of "calculator" and "calculus" may be useful
+in other contexts.
+
+3.1 The calculator package
+--------------------------
+The operations implemented by the calculator package include
+- arithmetical calculations with real and integer numbers
+- two and three dimensional vectors and matrices arithmetics
+- computation of powers, square roots, trigonometric, exponential,
+ logarithmic, hyperbolic, inverse trigonometric
+ and inverse hyperbolic functions.
+
+In addition, some important numbers, such as pi, sqrt(2) or e, are predefined.
+
+Some simple examples:
+
+a) Simplify a fraction: if you type
+
+ \FRACTIONSIMPLIFY{252}{2220}{\num}{\den}
+
+ Then, $\num/\den$ equals to 21/186
+
+b) Compute elementary functions:
+
+ \LOG{2}{\sol} ---> \sol equals 0.69315
+
+ \LOG[10]{2}{\sol} ---> \sol equals 0.30103
+
+ \SIN{\numberHALFPI}{\sol} ---> \sol equals 1
+
+c) More complex calculations:
+ You can compute the value of sqrt(7.25)cos(pi/7) by typing
+
+ \SQRT{7.25}{\tempa}
+ \DIVIDE{\numberPI}{7}{\tempb}
+ \COS{\tempb}{\tempc}
+ \MULTIPLY{\tempa}{\tempc}{\sol}
+
+ Then, the value 2.42589 is stored in \sol.
+
+d) Vectors and matrices:
+
+ \SCALARPRODUCT(1,2)(2,1){\sol} ---> \sol equals 4
+
+ \MATRIXPRODUCT(1,1;-1,2)(0,-1;1,1)(\sola,\solb;\solc,\sold)
+ ---> \sola, \solb, \solc, \sold equals 1, 0, 2, 3.
+
+
+3.2. The calculus package
+-------------------------
+This package adds to the calculator package several utilities to use and define
+real functions and their derivatives, including elementary functions,
+operations with functions, vector-valuated functions polar coordinates.
+When you call a "function", this function ant its derivative are evaluated
+simultaneously.
+
+Examples:
+
+a) Predefined functions:
+
+ \SINfunction{\numberPI}{\sol}{\Dsol} --->
+ \sol equals to 0 (=sin(pi)), and \Dsol equals -1 (=cos(pi)),
+ because cos(t) is the derivative of sin(t).
+
+b) Defining new functions: You can define the function f(t)=exp(2t)cos(t)-t
+with the following code:
+
+ \SCALEVARIABLEfunction{2}{\EXPfunction}{\functionA} % A=e^(2t)
+ \MULTIPLY{\functionA}{\COSfunction}{\functionB} % b=e^(2t)cos(t)
+ \SUBTRACTfunction{\functionB}{\IDENTITYfunction}{\functionF} % My function
+
+Then, \functionF{num}{\sol}{\Dsol} stores f(num) and f'(num) in \sol and \Dsol.
+
+
+4. Installation and documentation
+---------------------------------
+1. Compile the installation file "calculator.ins",
+
+ >> latex calculator.ins
+
+ to generate the two essential files,
+
+ "calculator.sty" and "calculus.sty".
+
+ Move these two files where LaTeX search for
+ (typically, in a local texmf tree, at tex/latex/calculator)
+ and refresh the file database.
+
+2. To have the documentation and user's manual, "calculator.pdf",
+ compile the source file "calculator.dtx" in the following sequence:
+
+ >> pdflatex calculator.dtx
+ >> makeindex -s gind.ist -o calculator.ind calculator.idx
+ >> makeindex -s gglo.ist -o calculator.gls calculator.glo
+ >> pdflatex calculator.dtx
+ >> pdflatex calculator.dtx
+
+In addition, many small files, named "calculatorNN.tex" are generated.
+These files contain the source code of all examples included in the manual.
+You can store or discard this files.
+
+---------------------------------------------------------------
+Robert Fuster
+rfuster at mat.upv.es
+
+Universitat Polit\`ecnica de Val\`encia, 2012/05/19, 2014/02/23, 2022/09/15
+---------------------------------------------------------------
Property changes on: trunk/Master/texmf-dist/doc/latex/calculator/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/calculator/calculator.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/latex/calculator/calculator.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/calculator/calculator.dtx 2022-09-17 19:54:32 UTC (rev 64423)
+++ trunk/Master/texmf-dist/source/latex/calculator/calculator.dtx 2022-09-17 19:55:48 UTC (rev 64424)
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2012, 2014 by Robert Fuster <rfuster at mat.upv.es>
+% Copyright (C) 2012, 2014, 2022 by Robert Fuster <rfuster at mat.upv.es>
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, either version 1.3 of this license
@@ -27,7 +27,7 @@
%<*driver>
\documentclass{ltxdoc}
\ProvidesFile{calculator.dtx}
- [2014/02/20 v.2.0 documented calculator package]
+ [2022/09/15 v.2.1 documented calculator package]
\usepackage{calculus}
\usepackage{amsmath}
@@ -34,8 +34,9 @@
\usepackage[lmargin=1.75in,rmargin=1in]{geometry}
\usepackage{fancyvrb}
-\def\fileversion{2.0}
-\def\filedate{2014/02/20}
+\usepackage[colorlinks]{hyperref}
+\def\fileversion{2.1}
+\def\filedate{2022/09/15}
\GetFileInfo{calculator.dtx}
@@ -58,6 +59,7 @@
\newcommand{\Marg}[1]{\textnormal{\marg{#1}}}
\newcommand{\newinversion}[1]{\textnormal{\textit{(new in version~#1)}}}
+\newcommand{\renewinversion}[2][]{\textnormal{\footnote{code modified in version~#2\ifx"#1"\else\space (#1)\fi.}}}
\newcommand{\arccot}{\operatorname{arccot}}
\newcommand{\arsinh}{\operatorname{arsinh}}
@@ -97,11 +99,12 @@
%
% \fi
%
-% \CheckSum{3753}
+% \CheckSum{3913}
% \changes{v1.0}{2012/04/25}{First public version}
% \changes{v1.0a}{2012/06/10}{calculator.dtx modified to make it autoinstallable.
% calculus.dtx embedded in calculus.dtx}
% \changes{v2.0}{2014/02/20}{new calculator.dtx and calculator.ins files}
+% \changes{v2.1}{2022/09/15}{Some bugs fixed}
%% \CharacterTable
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
@@ -154,6 +157,10 @@
% (so that we can work with all the classic elementary functions),
% and also can do some additional calculation with vectors
% (such as the cross product and the angle between two vectors).
+
+% Version 2.1 fixes some bugs and calculation problems.\footnote{Thanks to
+% Schmitz Manuel, Thorsten Wolterin, Jim Cline,
+% Schremmer Alain and July Tikhonov.}
% \end{abstract}
%
% \tableofcontents
@@ -447,7 +454,8 @@
% \end{exemple}
% \item[\cs{FRACTIONALPART}\marg{num}\marg{\cs{cmd}}]%
% \SpecialUsageIndex{\FRACTIONALPART}%
-% Fractional part of \textttit{num}.
+% Fractional part of \textttit{num}.\renewinversion[thanks to July Tikhonov
+% who reported a bug and suggested the solution]{2.1}
% \begin{exemple}
% \FRACTIONALPART{1.256}{\sol}
% \sol
@@ -463,7 +471,9 @@
% truncates the number \textttit{num} to \textttit{n} decimal places.
% \item[\cs{ROUND}{[\textttit{n}]}\marg{num}\marg{\cs{cmd}}]%
% \SpecialUsageIndex{\ROUND}%
-% rounds the number \textttit{num} to \textttit{n} decimal places.
+% rounds the number \textttit{num} to \textttit{n} decimal places.%
+% \renewinversion[thanks to Jim Cline and Schremmer Alain
+% who reported a bug]{2.1}
%
% The optional argument \textttit{n} may be \texttt{0}, \texttt{1},
% \texttt{2}, \texttt{3} or \texttt{4} (the default is \texttt{2}).\footnote{%
@@ -1872,7 +1882,7 @@
% \begin{macrocode}
%<*calculator>
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{calculator}[2014/02/20 v.2.0]
+\ProvidesPackage{calculator}[2022/09/15 v.2.1]
% \end{macrocode}
% \subsection{Internal lengths and special numbers}
% \cs{cctr at lengtha} and \cs{cctr at lengthb}
@@ -1902,6 +1912,18 @@
% \end{macro}
% \subsection{Warning messages}
% \begin{macrocode}
+\def\cctr at Warntruncate#1#2{%
+ \PackageWarning{calculator}%
+ {The optional argument in truncate \MessageBreak
+ must be less than 5 \MessageBreak
+ I copy #1 to #2 \MessageBreak without truncating}}
+
+\def\cctr at Warnround#1#2{%
+ \PackageWarning{calculator}%
+ {The optional argument in round \MessageBreak
+ must be less than 5 \MessageBreak
+ I copy #1 to #2 \MessageBreak without rounding}}
+
\def\cctr at Warndivzero#1#2{%
\PackageWarning{calculator}%
{Division by 0.\MessageBreak
@@ -2347,7 +2369,7 @@
% returns the integer part of \textit{\#2}.
% \begin{macrocode}
\def\@@INTEGERPART#1.#2.#3)#4{\ifnum #11=1 \COPY{0}{#4}
- \else \COPY{#1}{#4}\fi}
+ \else \ADD{0}{#1}{#4}\fi}
\def\@INTEGERPART#1#2{\expandafter\@@INTEGERPART#1..){#2}}
\def\INTEGERPART#1#2{\begingroup
\ifdim #1\p@<\z@
@@ -2372,9 +2394,10 @@
% \cs{FRACTIONALPART}\marg{\#1}\marg{\#2}
% returns the fractional part of
% \textit{\#2}.
+% \changes{v2.1}{2022/09/15}{Bug fixed}
% \begin{macrocode}
-\def\@@FRACTIONALPART#1.#2.#3)#4{\ifnum #2=11 \COPY{0}{#4}
- \else \COPY{0.#2}{#4}\fi}
+\def\@@FRACTIONALPART#1.#2.#3)#4{\ifnum #21=1 \COPY{0}{#4}
+ \else \ADD{0}{0.#2}{#4}\fi}
\def\@FRACTIONALPART#1#2{\expandafter\@@FRACTIONALPART#1..){#2}}
\def\FRACTIONALPART#1#2{\begingroup
\ifdim #1\p@<\z@
@@ -2382,24 +2405,29 @@
\SUBTRACT{#1}{\cctr at tempA}{#2}
\else
\@FRACTIONALPART{#1}{#2}
- \fi\@OUTPUTSOL{#2}}
+ \fi\@OUTPUTSOL{#2}}
+
% \end{macrocode}
% \end{macro}
% \begin{macro}{\TRUNCATE}
% \cs{TRUNCATE}\oarg{\#1}\marg{\#2}\marg{\#3}
% truncates \textit{\#2} to \textit{\#1} (0, 1, 2 (default), 3 or 4) digits.
+% \changes{v2.1}{2022/09/15}{Bug fixed}
% \begin{macrocode}
\def\TRUNCATE{\@ifnextchar[\@@TRUNCATE\@TRUNCATE}
\def\@TRUNCATE#1#2{\@@TRUNCATE[2]{#1}{#2}}
\def\@@TRUNCATE[#1]#2#3{%
- \begingroup
+ \begingroup
+ \ifdim #1\p@ > 4\p@ \cctr at Warntruncate{#2}{\noexpand#3} \COPY{#2}{#3}
+ \else
\INTEGERPART{#2}{\cctr at tempa}
- \ifdim \cctr at tempa\p@ = #2\p@
- \expandafter\@@@TRUNCATE#2.00000)[#1]{#3}
+ \ifdim \cctr at tempa\p@ = #2\p@
+ \expandafter\@@@TRUNCATE\cctr at tempa.00000.)[#1]{#3}
\else
\expandafter\@@@TRUNCATE#200000.)[#1]{#3}
- \fi
- \@OUTPUTSOL{#3}}
+ \fi\fi
+ \@OUTPUTSOL{#3}}
+
\def\@@@TRUNCATE#1.#2#3#4#5#6.#7)[#8]#9{%
\ifcase #8
\COPY{#1}{#9}
@@ -2413,27 +2441,48 @@
% \begin{macro}{\ROUND}
% \cs{ROUND}\oarg{\#1}\marg{\#2}\marg{\#3}
% rounds \textit{\#2} to \textit{\#1} (0, 1, 2 (default), 3 or 4) digits.
+% \changes{v2.1}{2022/09/15}{Bug fixed}
% \begin{macrocode}
\def\ROUND{\@ifnextchar[\@@ROUND\@ROUND}
\def\@ROUND#1#2{\@@ROUND[2]{#1}{#2}}
\def\@@ROUND[#1]#2#3{%
- \begingroup
- \ifdim#2\p@<\z@
- \MULTIPLY{-1}{#2}{\cctr at temp}
- \@@ROUND[#1]{\cctr at temp}{#3}\COPY{-#3}{#3}
- \else
- \@@TRUNCATE[#1]{#2}{\cctr at tempe}
- \SUBTRACT{#2}{\cctr at tempe}{\cctr at tempc}
- \POWER{10}{#1}{\cctr at tempb}
- \MULTIPLY{\cctr at tempb}{\cctr at tempc}{\cctr at tempc}
- \ifdim\cctr at tempc\p@<0.5\p@
- \else
- \DIVIDE{1}{\cctr at tempb}{\cctr at tempb}
- \ADD{\cctr at tempe}{\cctr at tempb}{\cctr at tempe}
- \fi
- \@@TRUNCATE[#1]{\cctr at tempe}{#3}
- \fi
- \@OUTPUTSOL{#3}}
+ \begingroup
+ \ifdim #1\p@ > 4\p@ \cctr at Warnround{#2}{\noexpand#3} \COPY{#2}{#3}
+ \else
+ \INTEGERPART{#2}{\cctr at tempa}
+ \ifdim \cctr at tempa\p@ = #2\p@
+ \expandafter\@@@ROUND\cctr at tempa.00000.)[#1]{#3}
+ \else
+ \expandafter\@@@ROUND#200000.)[#1]{#3}
+ \fi
+ \fi
+ \@OUTPUTSOL{#3}}
+
+\def\@@@ROUND#1.#2#3#4#5#6.#7)[#8]#9{%
+ \ifcase #8
+ \COPY{#1}{#9} \ifnum #2>4 \ADD{#1}{1}{\cctr at tempp}\COPY{\cctr at tempp}{#9} \fi
+ \or\COPY{#1.#2}{#9} \ifnum #3>4 \ADD{#2}{1}\cctr at tempq\COPY{#1}{\cctr at tempp}
+ \ifnum\cctr at tempq=10\ADD{\cctr at tempp}{1}\cctr at tempp\COPY{0}{\cctr at tempq}\fi
+ \COPY{\cctr at tempp.\cctr at tempq}{#9}
+ \fi
+ \or\COPY{#1.#2#3}{#9} \ifnum #4>4 \ADD{#3}1\cctr at tempq\COPY{#2}{\cctr at tempp}\COPY{#1}{\cctr at tempo}
+ \ifnum\cctr at tempq=10\ADD{\cctr at tempp}{1}{\cctr at tempp}\COPY{0}{\cctr at tempq}\fi
+ \ifnum\cctr at tempp=10\ADD{\cctr at tempo}{1}\cctr at tempo\COPY{0}{\cctr at tempp}\fi
+ \COPY{\cctr at tempo.\cctr at tempp\cctr at tempq}{#9}
+ \fi
+ \or\COPY{#1.#2#3#4}{#9} \ifnum #5>4 \ADD{#4}1\cctr at tempq\COPY{#3}{\cctr at tempp}\COPY{#2}{\cctr at tempo}\COPY{#1}{\cctr at tempn}
+ \ifnum\cctr at tempq=10\ADD{\cctr at tempp}{1}{\cctr at tempp}\COPY{0}{\cctr at tempq}\fi
+ \ifnum\cctr at tempp=10\ADD{\cctr at tempo}{1}\cctr at tempo\COPY{0}{\cctr at tempp}\fi
+ \ifnum\cctr at tempo=10\ADD{\cctr at tempn}{1}\cctr at tempn\COPY{0}{\cctr at tempo}\fi
+ \COPY{\cctr at tempn.\cctr at tempo\cctr at tempp\cctr at tempq}{#9}
+ \fi
+ \or\COPY{#1.#2#3#4#5}{#9} \ifnum #6>4 \ADD{#5}1\cctr at tempq\COPY{#4}{\cctr at tempp}\COPY{#3}{\cctr at tempo}\COPY{#2}{\cctr at tempn}\COPY{#1}{\cctr at tempm}
+ \ifnum\cctr at tempq=10\ADD{\cctr at tempp}{1}{\cctr at tempp}\COPY{0}{\cctr at tempq}\fi
+ \ifnum\cctr at tempp=10\ADD{\cctr at tempo}{1}\cctr at tempo\COPY{0}{\cctr at tempp}\fi
+ \ifnum\cctr at tempo=10\ADD{\cctr at tempn}{1}\cctr at tempn\COPY{0}{\cctr at tempo}\fi
+ \ifnum\cctr at tempn=10\ADD{\cctr at tempm}{1}\cctr at tempm\COPY{0}{\cctr at tempn}\fi
+ \COPY{\cctr at tempm.\cctr at tempn\cctr at tempo\cctr at tempp\cctr at tempq}{#9}
+ \fi}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\GCD}
@@ -3196,9 +3245,11 @@
% \end{macrocode}
%
% We start with |\cctr at lengthb=5\p@| to ensure almost one iteration.
+% \changes{v2.1}{2022/09/15}{Changed stop criterion on iterations to 2sp}
% \begin{macrocode}
\cctr at lengthb=5\p@%
-% \end{macrocode}
+ \cctr at epsilon=2\cctr at epsilon%
+% \end{macrocode}
% Successive iterations
% \begin{macrocode}
\@whilenum \cctr at lengthb>\cctr at epsilon \do {%
@@ -4400,7 +4451,7 @@
\ProvidesPackage{calculus}[2014/02/20 v.2.0]
% \end{macrocode}
% This package requires the calculator package.
-% \begin{macrocode}
+% \begin{macrocode}
\RequirePackage{calculator}
% \end{macrocode}
% \subsection{Error and info messages}
Modified: trunk/Master/texmf-dist/source/latex/calculator/calculator.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/calculator/calculator.ins 2022-09-17 19:54:32 UTC (rev 64423)
+++ trunk/Master/texmf-dist/source/latex/calculator/calculator.ins 2022-09-17 19:55:48 UTC (rev 64424)
@@ -1,5 +1,5 @@
%%
-%% Copyright (C) 2012, 2014 by Robert Fuster <rfuster at mat.upv.es>
+%% Copyright (C) 2012, 2014, 2022 by Robert Fuster <rfuster at mat.upv.es>
%%
%% This work may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.3 of this license
@@ -55,9 +55,9 @@
\Msg{*****************************************************}
\Msg{* *}
\Msg{* To finish the installation you have to move the *}
-\Msg{* following file into a directory searched by TeX: *}
+\Msg{* following files into a directory searched by TeX: *}
\Msg{* *}
-\Msg{* calculator.sty *}
+\Msg{* calculator.sty calculus.sty *}
\Msg{* *}
\Msg{* (in a TDS compliant tree, something like *}
\Msg{* <a texmf dir>/tex/latex/calculator/ *}
Modified: trunk/Master/texmf-dist/tex/latex/calculator/calculator.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/calculator/calculator.sty 2022-09-17 19:54:32 UTC (rev 64423)
+++ trunk/Master/texmf-dist/tex/latex/calculator/calculator.sty 2022-09-17 19:55:48 UTC (rev 64424)
@@ -46,13 +46,26 @@
+
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{calculator}[2014/02/20 v.2.0]
+\ProvidesPackage{calculator}[2022/09/15 v.2.1]
\newdimen\cctr at lengtha
\newdimen\cctr at lengthb
\newdimen\cctr at epsilon
\cctr at epsilon=1sp
\def\cctr at logmaxnum{9.704}
+\def\cctr at Warntruncate#1#2{%
+ \PackageWarning{calculator}%
+ {The optional argument in truncate \MessageBreak
+ must be less than 5 \MessageBreak
+ I copy #1 to #2 \MessageBreak without truncating}}
+
+\def\cctr at Warnround#1#2{%
+ \PackageWarning{calculator}%
+ {The optional argument in round \MessageBreak
+ must be less than 5 \MessageBreak
+ I copy #1 to #2 \MessageBreak without rounding}}
+
\def\cctr at Warndivzero#1#2{%
\PackageWarning{calculator}%
{Division by 0.\MessageBreak
@@ -293,7 +306,7 @@
\begingroup
\INTEGERDIVISION{#1}{#2}{#3}{\cctr at temp}\@OUTPUTSOL{#3}}
\def\@@INTEGERPART#1.#2.#3)#4{\ifnum #11=1 \COPY{0}{#4}
- \else \COPY{#1}{#4}\fi}
+ \else \ADD{0}{#1}{#4}\fi}
\def\@INTEGERPART#1#2{\expandafter\@@INTEGERPART#1..){#2}}
\def\INTEGERPART#1#2{\begingroup
\ifdim #1\p@<\z@
@@ -307,8 +320,8 @@
\@INTEGERPART{#1}{#2}
\fi\@OUTPUTSOL{#2}}
\let\FLOOR\INTEGERPART
-\def\@@FRACTIONALPART#1.#2.#3)#4{\ifnum #2=11 \COPY{0}{#4}
- \else \COPY{0.#2}{#4}\fi}
+\def\@@FRACTIONALPART#1.#2.#3)#4{\ifnum #21=1 \COPY{0}{#4}
+ \else \ADD{0}{0.#2}{#4}\fi}
\def\@FRACTIONALPART#1#2{\expandafter\@@FRACTIONALPART#1..){#2}}
\def\FRACTIONALPART#1#2{\begingroup
\ifdim #1\p@<\z@
@@ -317,17 +330,21 @@
\else
\@FRACTIONALPART{#1}{#2}
\fi\@OUTPUTSOL{#2}}
+
\def\TRUNCATE{\@ifnextchar[\@@TRUNCATE\@TRUNCATE}
\def\@TRUNCATE#1#2{\@@TRUNCATE[2]{#1}{#2}}
\def\@@TRUNCATE[#1]#2#3{%
\begingroup
+ \ifdim #1\p@ > 4\p@ \cctr at Warntruncate{#2}{\noexpand#3} \COPY{#2}{#3}
+ \else
\INTEGERPART{#2}{\cctr at tempa}
\ifdim \cctr at tempa\p@ = #2\p@
- \expandafter\@@@TRUNCATE#2.00000)[#1]{#3}
+ \expandafter\@@@TRUNCATE\cctr at tempa.00000.)[#1]{#3}
\else
\expandafter\@@@TRUNCATE#200000.)[#1]{#3}
- \fi
+ \fi\fi
\@OUTPUTSOL{#3}}
+
\def\@@@TRUNCATE#1.#2#3#4#5#6.#7)[#8]#9{%
\ifcase #8
\COPY{#1}{#9}
@@ -339,23 +356,43 @@
\def\ROUND{\@ifnextchar[\@@ROUND\@ROUND}
\def\@ROUND#1#2{\@@ROUND[2]{#1}{#2}}
\def\@@ROUND[#1]#2#3{%
- \begingroup
- \ifdim#2\p@<\z@
- \MULTIPLY{-1}{#2}{\cctr at temp}
- \@@ROUND[#1]{\cctr at temp}{#3}\COPY{-#3}{#3}
- \else
- \@@TRUNCATE[#1]{#2}{\cctr at tempe}
- \SUBTRACT{#2}{\cctr at tempe}{\cctr at tempc}
- \POWER{10}{#1}{\cctr at tempb}
- \MULTIPLY{\cctr at tempb}{\cctr at tempc}{\cctr at tempc}
- \ifdim\cctr at tempc\p@<0.5\p@
- \else
- \DIVIDE{1}{\cctr at tempb}{\cctr at tempb}
- \ADD{\cctr at tempe}{\cctr at tempb}{\cctr at tempe}
- \fi
- \@@TRUNCATE[#1]{\cctr at tempe}{#3}
- \fi
- \@OUTPUTSOL{#3}}
+ \begingroup
+ \ifdim #1\p@ > 4\p@ \cctr at Warnround{#2}{\noexpand#3} \COPY{#2}{#3}
+ \else
+ \INTEGERPART{#2}{\cctr at tempa}
+ \ifdim \cctr at tempa\p@ = #2\p@
+ \expandafter\@@@ROUND\cctr at tempa.00000.)[#1]{#3}
+ \else
+ \expandafter\@@@ROUND#200000.)[#1]{#3}
+ \fi
+ \fi
+ \@OUTPUTSOL{#3}}
+
+\def\@@@ROUND#1.#2#3#4#5#6.#7)[#8]#9{%
+ \ifcase #8
+ \COPY{#1}{#9} \ifnum #2>4 \ADD{#1}{1}{\cctr at tempp}\COPY{\cctr at tempp}{#9} \fi
+ \or\COPY{#1.#2}{#9} \ifnum #3>4 \ADD{#2}{1}\cctr at tempq\COPY{#1}{\cctr at tempp}
+ \ifnum\cctr at tempq=10\ADD{\cctr at tempp}{1}\cctr at tempp\COPY{0}{\cctr at tempq}\fi
+ \COPY{\cctr at tempp.\cctr at tempq}{#9}
+ \fi
+ \or\COPY{#1.#2#3}{#9} \ifnum #4>4 \ADD{#3}1\cctr at tempq\COPY{#2}{\cctr at tempp}\COPY{#1}{\cctr at tempo}
+ \ifnum\cctr at tempq=10\ADD{\cctr at tempp}{1}{\cctr at tempp}\COPY{0}{\cctr at tempq}\fi
+ \ifnum\cctr at tempp=10\ADD{\cctr at tempo}{1}\cctr at tempo\COPY{0}{\cctr at tempp}\fi
+ \COPY{\cctr at tempo.\cctr at tempp\cctr at tempq}{#9}
+ \fi
+ \or\COPY{#1.#2#3#4}{#9} \ifnum #5>4 \ADD{#4}1\cctr at tempq\COPY{#3}{\cctr at tempp}\COPY{#2}{\cctr at tempo}\COPY{#1}{\cctr at tempn}
+ \ifnum\cctr at tempq=10\ADD{\cctr at tempp}{1}{\cctr at tempp}\COPY{0}{\cctr at tempq}\fi
+ \ifnum\cctr at tempp=10\ADD{\cctr at tempo}{1}\cctr at tempo\COPY{0}{\cctr at tempp}\fi
+ \ifnum\cctr at tempo=10\ADD{\cctr at tempn}{1}\cctr at tempn\COPY{0}{\cctr at tempo}\fi
+ \COPY{\cctr at tempn.\cctr at tempo\cctr at tempp\cctr at tempq}{#9}
+ \fi
+ \or\COPY{#1.#2#3#4#5}{#9} \ifnum #6>4 \ADD{#5}1\cctr at tempq\COPY{#4}{\cctr at tempp}\COPY{#3}{\cctr at tempo}\COPY{#2}{\cctr at tempn}\COPY{#1}{\cctr at tempm}
+ \ifnum\cctr at tempq=10\ADD{\cctr at tempp}{1}{\cctr at tempp}\COPY{0}{\cctr at tempq}\fi
+ \ifnum\cctr at tempp=10\ADD{\cctr at tempo}{1}\cctr at tempo\COPY{0}{\cctr at tempp}\fi
+ \ifnum\cctr at tempo=10\ADD{\cctr at tempn}{1}\cctr at tempn\COPY{0}{\cctr at tempo}\fi
+ \ifnum\cctr at tempn=10\ADD{\cctr at tempm}{1}\cctr at tempm\COPY{0}{\cctr at tempn}\fi
+ \COPY{\cctr at tempm.\cctr at tempn\cctr at tempo\cctr at tempp\cctr at tempq}{#9}
+ \fi}
\def\GCD#1#2#3{%
\begingroup
\ABSVALUE{#1}{\cctr at tempa}
@@ -748,6 +785,7 @@
\def\@BASICLOG#1#2{\begingroup
\SUBTRACT{#1}{1}{\cctr at tempw}
\cctr at lengthb=5\p@%
+ \cctr at epsilon=2\cctr at epsilon%
\@whilenum \cctr at lengthb>\cctr at epsilon \do {%
\COPY{\cctr at tempw}{\cctr at tempoldw}
\EXP{\cctr at tempw}{\cctr at tempxw}
Modified: trunk/Master/texmf-dist/tex/latex/calculator/calculus.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/calculator/calculus.sty 2022-09-17 19:54:32 UTC (rev 64423)
+++ trunk/Master/texmf-dist/tex/latex/calculator/calculus.sty 2022-09-17 19:55:48 UTC (rev 64424)
@@ -46,6 +46,7 @@
+
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{calculus}[2014/02/20 v.2.0]
\RequirePackage{calculator}
More information about the tex-live-commits
mailing list.