diff options
author | Karl Berry <karl@freefriends.org> | 2013-09-24 22:26:51 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-09-24 22:26:51 +0000 |
commit | d9dac37ce48e9caf9f59e903857484b52bec72cb (patch) | |
tree | 18c82bb521e2ac15cd9bf1e3e2602ea2bd568373 /Master/texmf-dist | |
parent | 60832b1a02dcf82922ff377c63d5fd5a57c201ad (diff) |
xint (24sep13)
git-svn-id: svn://tug.org/texlive/trunk@31744 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/generic/xint/README | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/generic/xint/xint.pdf | bin | 770070 -> 834985 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/generic/xint/xint.dtx | 3957 | ||||
-rw-r--r-- | Master/texmf-dist/source/generic/xint/xint.ins | 2 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xint.sty | 329 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintbinhex.sty | 8 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintcfrac.sty | 36 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintexpr.sty | 1112 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintfrac.sty | 303 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintgcd.sty | 68 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintseries.sty | 24 |
11 files changed, 4121 insertions, 1720 deletions
diff --git a/Master/texmf-dist/doc/generic/xint/README b/Master/texmf-dist/doc/generic/xint/README index 357fe2400e8..e17bc05843f 100644 --- a/Master/texmf-dist/doc/generic/xint/README +++ b/Master/texmf-dist/doc/generic/xint/README @@ -1,5 +1,5 @@ The xint bundle -Release 1.08b (2013/06/14). Documentation version: 2013/04/16. +Release 1.09a (2013/09/24). author: Jean-Francois Burnol Style files which will self-extract from xint.dtx: diff --git a/Master/texmf-dist/doc/generic/xint/xint.pdf b/Master/texmf-dist/doc/generic/xint/xint.pdf Binary files differindex b21ea8d18dd..3ee24e6b15d 100644 --- a/Master/texmf-dist/doc/generic/xint/xint.pdf +++ b/Master/texmf-dist/doc/generic/xint/xint.pdf diff --git a/Master/texmf-dist/source/generic/xint/xint.dtx b/Master/texmf-dist/source/generic/xint/xint.dtx index c232673fea1..2ca1b97fa16 100644 --- a/Master/texmf-dist/source/generic/xint/xint.dtx +++ b/Master/texmf-dist/source/generic/xint/xint.dtx @@ -1,5 +1,5 @@ % -*- coding: iso-latin-1; -*- -% xint.dtx, 1.08b (2013/06/14) +% xint.dtx, 1.09a (2013/09/24) % Copyright (C) 2013 by Jean-François Burnol % Style files which will self-extract from xint.dtx: % (base) xint.sty Expandable operations on long numbers @@ -10,9 +10,6 @@ % xintseries.sty Expandable partial sums with xint package % xintcfrac.sty Expandable continued fractions with xint package % To be used with Plain TeX (\input) or LaTeX (\usepackage) -%<*doc> -\def\lasttimestamp{Time-stamp: <16-06-2013 08:53:40 CEST *>} -%</doc> % License % ======= % @@ -84,7 +81,7 @@ % %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.08b of June 14, 2013) +%% The xint bundle (version 1.09a of September 22, 2013) %<xint>%% xint: Expandable operations on long numbers %<xintfrac>%% xintfrac: Expandable operations on fractions %<xintexpr>%% xintexpr: Expandable expression parser @@ -96,8 +93,9 @@ %%---------------------------------------------------------------- %% %<*doc> -\def\pkgversion{1.08b} -\def\pkgdate{2013/06/14} +\def\lasttimestamp{Time-stamp: <24-09-2013 15:29:15 CEST *>} +\def\pkgversion{1.09a} +\def\pkgdate{2013/09/24} \def\striptimestamp #1 <#2 #3 #4 #5>{#2 at #3 #4} \def\getdocdate #1 <#2-#3-#4 #5>{#4/#3/#2} \edef\docdate{\expandafter\getdocdate\lasttimestamp} @@ -148,6 +146,8 @@ \documentclass[a4paper,11pt,abstract]{scrdoc} +%% \OnlyDescription + \pagestyle{headings} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} @@ -421,9 +421,10 @@ pdfpagemode=UseOutlines} % voilà \lverb! bye bye \begin{verbatim} % % bref, pour \lverb: d'abord il est \long. Ensuite j'utilise $ si j'ai besoin de -% control sequences. En fait j'ai juste eu besoin pour \%. Car le % lui je le -% mets (maintiens, donc la partie implémentation) à ignore. Ah, et finalement -% j'utilise aussi $\. Les espaces sont normaux. +% control sequences. [sans arguments, sinon il me faudrait avoir des caratères +% de catcode 1 et 2 aussi] En fait j'ai juste eu besoin pour \%. Car le % lui je +% le mets (maintiens, donc la partie implémentation) à ignore. Ah, et +% finalement j'utilise aussi $\. Les espaces sont normaux. % Enfin, je fais de & un caractère de commentaires. Tout cela c'est pour % la partie Implémentation. % @@ -446,14 +447,16 @@ pdfpagemode=UseOutlines} \begingroup \lccode `\~=`#1\relax \lowercase {\endgroup \def ~{\leavevmode \kern \z@ \char `#1 }}% } -% \makestarlowast ajouté le 8 juin +% \makestarlowast ajouté le 8 juin. Le 22 septembre je supprime ici +% le \catcode`\& 14 que j'avais ajouté, car je pense en avoir besoin +% uniquement dans \lverb et \dverb. \def\verb {% \relax \ifmmode\hbox\else\leavevmode\null\fi \bgroup \MicroFont \let\do\do@noligs \verbatim@nolig@list \let\do\@makeother \dospecials - \catcode32 10 \makestarlowast \catcode`\& 14 \@jfverb + \catcode32 10 \makestarlowast \@jfverb } \def\@jfverb #1{\catcode`#1\active\lccode`\~`#1\lowercase{\let~\egroup}} % ATTENTION! @@ -601,10 +604,11 @@ pdfpagemode=UseOutlines} to fractional numbers with arbitrarily long numerators and denominators. \xintexprname provides an expandable parser |\xintexpr . . . \relax| of - expressions constructed with decimal numbers, fractions, numbers in - scientific notation, the basic operations as infix operators, parentheses, - sign prefixes, factorial symbol, and sub-expressions or macros expanding - to the previous items. + expressions involving arithmetic operations in infix notation on decimal + numbers, fractions, numbers in scientific notation, with parentheses, + factorial symbol, function names, comparison operators, logic operators, 2way + and 3way conditionals (they do \emph{not} evaluate the false branches), + sub-expressions, macros expanding to the previous items. The \xintbinhexname package is for conversions to and from binary and hexadecimal bases, \xintseriesname provides some basic functionality for @@ -621,19 +625,366 @@ pdfpagemode=UseOutlines} load the package components. \end{abstract} + +\section{Quick introduction} + +The \xintname bundle consists of three principal components \xintname, +\xintfracname (which loads \xintname), and \xintexprname (which loads +\xintfracname), and four additional modules. They may be used with Plain +\TeX{}, \LaTeX{} or any other macro package based on \TeX{}; the package +requires the \eTeX{} extensions (|\numexpr|, |\ifcsname|) which in modern +distributions are made available by default, except if you invoke \TeX{} under +the name |tex| in command line. + +The goal is too compute \emph{exactly}, purely by expansion, without counters +nor assignments nor definitions, with arbitrarily big numbers and fractions. As +will be commented upon more about later, this works fine when the data has +dozens of digits, but multiplying out two &1000& digits numbers under this +constraint of expandability is expensive; so in many cases the user will round +intermediate results. There are also macros working with arbitrary-precision +floating point numbers (default is &16& digits). The only non-algebraic +operation which is implemented is the extraction of square roots (with a given +floating point precision). + +All computations can be done chaining the suitable +package macros; and \xintname also provides some expandable utilities for easing +up the task to write expandable macros depending on conditional evaluations. + +Most users will prefer to access the package functionalities via the +\csb{xintexpr}| ... \relax| parser which allows infix notations, function names (corresponding +to some of the package macros), comparison operators, boolean operators, 2way +and 3way conditionals. Furthermore, it is naturally possible to use arbitrary +(expandable) macros within an |\xintexpr|-ession, but the arguments (within +braces following the macro) +will be scooped by the macro +during its expansion (however the arguments may also be encapsulated in their +own |\xintexpr|-essions, if the need arises to use infix notation there). + +\xintexprSafeCatcodes +\newcommand\formula[3]{\xinttheexpr round((#1 & (#2 | #3)) * (355/113*#3 - + (#1 - #2/2)^2), 8)\relax } +\xintexprRestoreCatcodes + + +Here is some random formula, defining a \LaTeX{} command with three parameters, +\centeredline{\verb$\newcommand\formula[3]{\xinttheexpr ... \relax}$} +\centeredline{\verb$where ... is: round((#1 & (#2 | #3)) * (355/113*#3 - (#1 - + #2/2)^2), 8)$} + +\smallskip + +Let |a=#1|, |b=#2|, |c=#3| be the parameters. The first term is the logical +operation |a and (b or c)| where a number or fraction has truth value &1& if it +is non-zero, and &0& otherwise. So here it means that |a| must be non-zero as +well as |b| or |c|, for this first operand to be &1&, else the formula returns +&0&. This multiplies a second term which is algebraic. Finally the result (where +all intermediate computations are done \emph{exactly}) is rounded to a value +with &8& digits after the decimal mark, and printed. \centeredline{|\formula + {771.3/9.1}{1.51e2}{37.73} expands to |% + \digitstt{\formula {771.3/9.1}{1.51e2}{37.73}}} + +\begin{itemize} +\item as everything gets expanded, the characters + \verb$+,-,*,/,^,&,|,?,:,<,>,=,(,)$ and the comma ($,$), which are used in the + |infix| syntax, should not be active (for example if + they serve as shorthands for some language in the |Babel| system) at the time + of the expressions (if they are in use therein). The command + \csb{xintexprSafeCatcodes} resets these characters to their standard catcodes + and \csb{xintexprRestoreCatcodes} restores the status prevailing at the time + of the previous \csa{xintexprSafeCatcodes}. +\item the formula may of course be written via the suitable chaining of the + package macros. Here one could use: + \centeredline + {|\xintRound {8}{\xintMul {\xintAND {#1}{\xintOR {#2}{#3}}}{\xintSub |} + \centeredline + {| {\xintMul {355/113}{#3}}{\xintPow {\xintSub {#1}{\xintDiv {#2}{2}}}{2}}}}|} + with the inherent difficulty of keeping up with braces and everything... +\item if such a formula is used thousands of times in a document (for plots?), + this could impact some parts of the \TeX{} program memory (for technical + reasons explained in \autoref{sec:comexpr}). So, a utility \csb{xintNewExpr} + is provided to do the work of translating an |\xintexpr|-ession with + parameters into a chain of macro evaluations.\footnote{As its makes some macro + definitions, it is not an expandable command. It does not need protection + against active characters as it does it itself.} + \centeredline{|\xintNewExpr\formula[3]|} + \centeredline{\verb${ round((#1 & (#2 | #3)) * (355/113*#3 - (#1 - #2/2)^2), + 8) }$} + one gets a command |\formula| with three parameters and meaning: + +\xintNewExpr\formula[3] +{ round((#1 & (#2 | #3)) * (355/113*#3 - (#1 - #2/2)^2), + 8) } + +{\centering\ttfamily + +\meaning\formula + +} +This does the same thing as the hand-written version from the previous item. The +use even thousands of times of such an |\xintNewExpr|-generated |\formula| +has no memory impact. +\item count registers and |\numexpr|-essions \emph{must} be prefixed by |\the| + (or |\number|) when used inside |\xintexpr|. However, they may be used + directly as arguments to most package macros, without being prefixed by + |\the|. See \hyperlink{useofcount}{Use of count registers}. With release + |1.09a| this functionality has been + added to many of macros of the integer only \xintname (with the cost of a + small extra overhead; earlier, this overhead was added through the loading + of + \xintfracname). +\item like a |\numexpr|, an |\xintexpr| is not directly printable, one uses + equivalently |\xintthe\xintexpr| or \csb{xinttheexpr}. One may for example + define: \centeredline{|\def\x {\xintexpr \a + \b \relax} \def\y {\xintexpr \x + * \a \relax}|} where |\x| could have been defined equivalently for its use + in |\y| as {|\def\x {( \a + \b )}|} but the earlier method is better than with + parentheses, as it allows {|\xintthe\x|}. +\item sometimes one needs an integer, not a fraction or decimal number. The + |round| function rounds to the neareast integer (half-integers are rounded + towards $\pm\infty$), and |\xintexpr round(...)\relax| has an alternative + syntax as |\xintnumexpr ... \relax|. There is also the |\xintthenumexpr|. The + rounding is applied to the final result only. +\item there is also |\xintfloatexpr ... \relax| where the algebra is done in + floating point approximation (also for each intermediate result). Use the + syntax + |\xintDigits:=N;| to set the precision. Default: &16& digits. + \centeredline{|\xintthefloatexpr 2^{100000}\relax|: \xintthefloatexpr + 2^{100000}\relax } The square-root operation can be used in |\xintexpr|, it + is computed as a float with the precision set by |\xintDigits| or by the + optional second argument: \centeredline{|\xinttheexpr sqrt(2,60)\relax|:} + \centeredline{\xinttheexpr sqrt(2,60)\relax } Notice the |a/b[n]| notation + (usually |/b| even if |b=1| gets printed; this is the exception) which is the + default format of the macros of the \xintfracname + package (hence of |\xintexpr|). To get a float format from the |\xintexpr| one + needs something more: \centeredline{|\xintFloat[60]{\xinttheexpr + sqrt(2,60)\relax}|:} \centeredline{\xintFloat[60]{\xinttheexpr + sqrt(2,60)\relax }} The precision used by |\xintfloatexpr| must be set by + |\xintDigits|, it can not be passed as an option to |\xintfloatexpr|. + \centeredline{|\xintDigits:=48; \xintthefloatexpr 2^{100000}\relax|: } + \centeredline{\begingroup \xintDigits:=48;\xintthefloatexpr + 2^{100000}\relax \endgroup} Floats are quickly indispensable when using the + power function (which can only have an integer exponent), as exact results + will easily have hundreds of digits. +\item when producing very long numbers there is the question of printing them on + the page, without going beyond the page limits. In this document, I have most + of the time made use of these little macros (not provided by the package:) +\begingroup\makeatletter\def\verbatim@font{\ttfamily\footnotesize} +\begin{verbatim} +\def\allowsplits #1% +{% + \ifx #1\relax \else #1\hskip 0pt plus 1pt\relax + \expandafter\allowsplits\fi +}% +\def\printnumber #1% +{\expandafter\expandafter\expandafter + \allowsplits #1\relax }% Expands twice before printing. +%% (all macros from the xint bundle expand in two steps to their final output) +\end{verbatim} +\endgroup +An alternative (explained later) is to suitably configure the thousand separator +with tthe \href{http://www.ctan.org/pkg/numprint}{numprint} package (does not +work in math mode; I also tried \href{http://www.ctan.org/pkg/siunitx}{siunitx} +but even in text mode could not get it to break numbers accross lines). +\end{itemize} + +\section{Summary of the \csh{xintexpr} syntax}\label{sec:exprsummary} + +An expression is built with infix operators (including comparison and boolean +operators) and parentheses, and functions. And there are two special branching +constructs. The parser expands everything from the left to the right and +everything may thus be revealed step by step by expansion of macros. At any +given time the parser is in one of two modes: either it looks for a number or it +looks for an operator. When looking for a number it may find instead a function. +The function is evaluated after the comma separated list of its arguments has +been. Or it may find a minus sign as prefix. Or it may find an opening +parenthesis. When looking for an operator it may find the |!| for the factorial, +or the conditional operators |?| and |:|, or some more genuine infix operator, +in that case a comparison of precedences is made with the previously +found operator. The result is that the formula should evaluate as one expects. +Note that |2^-10| is perfectly accepted input, no need for parentheses. And +|-2^-10^-5*3| does |(-((2^(-10))^(-5)))*3|. + +Spaces anywhere are allowed. + +The characters used in the syntax should not +of course have been made active. Use \csb{xintexprSafeCatcodes}, +\csb{xintexprRestoreCatcodes} if need be (of course, this can not be done +expandably... ). Apart from that infix operators may be of catcode letter or +other, it does not matter, or even of catcode tabulation, math superscript, or +math subscript. This should cause no problem. As an alternative to +|\xintexprSafeCatcodes| one may also use |\string| inside the expression. + +Although the |A/B[N]| notation is the output format of most \xintfracname +macros, for user input in an |\xintexpr..\relax| it is mandatory to use for such +a fraction rather the scientific notation |AeN/B| (or |A/Be-N|; capital |E| is +allowed): the square brackets are \emph{not} understood by the parser. Or, as an +alternative \emph{braces} can be used: |{A/B[N]}|. + +Braces are indeed allowed in their usual r\^ole for arguments to macros (which +are then not seen by the parser but scooped by the macro), or to encapsulate +\emph{arbitrary} completely expandable material which will not be parsed but +directly completely expanded and \emph{must} return an integer or fraction +possibly with decimal mark or in |A/B[N]| notation, but is not allowed to have +the |e| or |E|. Braced material is not allowed to expand to some infix operator +or parenthesis, it is allowed only in locations where the parser expects to find +a (decimal) number. There is a final r\^ole of braces with the conditional +operators |?| and |:|, described next. + +One may use sub-|\xintexpr|-expressions nested within a larger one. It is even +possible to alternate |\xintfloatexpr|-essions with |\xintexpr|-essions. Do not +use |\xinttheexpr| inside an |\xintexpr|: this gives a number in |A/B[n]| +format which requires protection by braces. Do not put within braces numbers in +scientific notation. + + +Here is, listed from the highest priority to the lowest, the complete list of +operators and functions. Functions always produce \emph{numbers or fractions}. +The |?| and |:| conditional operators are a bit special, though. + +The minus sign as prefix has various precedence levels: |\xintexpr +-3-4*-5^-7\relax| evaluates as |(-3)-(4*(-(5^(-7))))| and |-3^-4*-5-7| as +|(-((3^(-4))*(-5)))-7|. + +The |\relax| at the end of an expression is absolutely \emph{mandatory}. + + % reduce, + % sqr, sqrt, abs, sgn, floor, ceil, quo, rem, round, trunc, float, gcd, lcm, + % max, min, sum, prd, add, mul, not, all, any, xor + % ?, !, if, ifsgn, ?, :. + +\begin{itemize} +\item + \begin{description} + \item[functions with one argument] + \texttt{floor, ceil, reduce, sqr, abs, sgn, ?, !, not}. The |?(x)| function + returns + the truth value, &1& if |x<>0|, &0& if |x=0|. The |!(x)| is the logical + not. The |reduce| function puts the fraction in irreducible form. + \item[functions with one mandatory and a second optional argument] + \texttt{round, trunc, float, sqrt}. For example + |round(2^9/3^5,12)=|\digitstt{\xinttheexpr round(2^9/3^5,12)\relax.} + \item[functions with two arguments] + \texttt{quo, rem}. These functions are integer only, they give the quotient + and remainder in Euclidean division (more generally one can use + the |floor| function). + \item[functions with three arguments] + |if(cond,yes,no)| checks if |cond| is true or false and takes + the corresponding branch. Both ``branches'' are evaluated (they are not + really branches but just numbers). + \item[The ? operator] |(cond)?{yes}{no}| evaluates the condition. It then + acts as a macro with two mandatory arguments within braces (hence this + escapes from the parser scope, the braces can not be hidden in a macro), + chooses the correct branch \emph{without evaluating the wrong one}. Once + the braces are removed, the parser scans and expands the uncovered material + so for example \centeredline{|\xintexpr (3>2)?{5+6}{7-1}2^3\relax|} is + legal and computes + |5+62^3=|\digitstt{\xinttheexpr(3>2)?{5+(6}{7-(1}2^3)\relax}. Note though + that it would be better practice to include here the |2^3| inside the + branches. The contents of the branches may be arbitrary as long as once + glued to what is next the syntax is respected: \centeredline{|\xintexpr + (3>2)?{5+(6}{7-(1}2^3)\relax| also works.} + \item[functions with four arguments] + |ifsgn(cond,<0,=0,>0)| checks the sign of |cond| and + proceeds correspondingly. All three are evaluated; contrarily to the |?| + the formed operand is then final, the parser must found an operator after + it, not more digits. + \item[The : operator] |(cond):{<0}{=0}{>0}|. Only the correct branch is + un-braced, the two others are swallowed. The un-braced material will then + be parsed as usual. + \item[functions with an arbitrary number of arguments] + \texttt{all, any, xor, add=sum, mul=prd, max, min, gcd, lcm}: the last two + are integer-only and require the \xintgcdname package. + \item[! as postfix] computes the factorial of an integer. This is the exact + factorial even inside |\xintfloatexpr|. + \end{description} +\item The |e| and |E| of the scientific notation. They are treated as infix + operators of highest priority. The decimal mark is scanned in a special + direct way: in |1.12e3| first |1.12| is formed then only |e| is found. |1e3-1| + is |999|. +\item The power operator |^|. +\item Multiplication and division &*&, |/|. +\item Addition and subtraction |+|, |-|. +\item Comparison operators |<|, |>|, |=|. +\item Logical and: |&|. +\item Logical or: \verb$|$. +\item The comma |,|. One can thus do |\xintthenumexpr 2^3,3^4,5^6\relax|: + \xintthenumexpr 2^3,3^4,5^6\relax. +\item The parentheses. +\end{itemize} + +% \begin{framed} +% Sep. 22, 2013. For lack of time, I have only minimally revised the remainder +% of this documentation from its earlier state, which was for version |1.08b|. I +% have shortened some sections, but some material may be now a little obsolete. +% I have tried to include a brief summary of all new commands but may have +% forgotten one or two. Apart from all the extensions to the |\xintexpr| syntax +% other notable changes are: +% \begin{itemize} +% \item when only the \xintname package is loaded, the input format is relaxed +% as use of the |\xintNum| normalizing macro has been added to most commands +% (as was already the case with \xintfracname loaded). This means in +% particular that count +% registers may be input directly as arguments to the macros, without +% prefixing by |\the|. +% \item the |\xintNewExpr| constructor now works with the standard macro +% parameter +% character |#|. +% % \item \xintgcdname has the new functions |\xintGCDof| and |\xintLCMof| working +% % on lists of braces numbers. They are mapped to the |gcd| and |lcm| of +% % |\xintexpr|. +% \end{itemize} +% \end{framed} + + \setcounter{tocdepth}{2} \tableofcontents \FutureTOCsDoNotObeyInnerTocdepth -\clearpage +%\clearpage \section{Presentation} + +\footnotesize + \subsection{Recent changes} -Release |1.08b|: + +\noindent Release |1.09a| (|[2013/09/24]|): +\begin{itemize} +\item |\xintexpr..\relax| and + |\xintfloatexpr..\relax| admit functions in their + syntax, with comma separated values as arguments, among them \texttt{reduce, + sqr, sqrt, abs, sgn, floor, ceil, quo, rem, round, trunc, float, gcd, lcm, + max, min, sum, prd, add, mul, not, all, any, xor}. +\item comparison (|<|, |>|, |=|) and logical (\verb$|$, |&|) operators. +\item the command |\xintthe| which converts |\xintexpr|essions into printable + format (like |\the| with |\numexpr|) is more efficient, for example one can do + |\xintthe\x| if |\x| was def'ined to be an |\xintexpr..\relax|: +\centeredline{|\def\x{\xintexpr 3^57\relax}\def\y{\xintexpr \x^(-2)\relax}|} +\centeredline{|\def\z{\xintexpr + \y-3^-114\relax}|\hspace{1cm}|\xintthe\z=|\begingroup +\def\x{\xintexpr 3^57\relax}\def\y{\xintexpr \x^(-2)\relax}% +\def\z{\xintexpr \y-3^-114\relax}\digitstt{\xintthe\z}\endgroup} +\item |\xintnumexpr .. \relax| is |\xintexpr round( .. ) \relax|. +\item |\xintNewExpr| now works with the standard macro parameter character |#|. +\item both regular |\xintexpr|-essions and commands defined by |\xintNewExpr| + will work with comma separated lists of expressions, +\item new commands |\xintFloor|, |\xintCeil|, |\xintMaxof|, |\xintMinof| + (package \xintfracname), |\xintGCDof|, |\xintLCM|, |\xintLCMof| (package + \xintgcdname), |\xintifLt|, |\xintifGt|, |\xintifSgn|, |\xintANDof|, + ... +\item The arithmetic macros from package \xintname now filter their operands via + |\xintNum| which means that they may use directly count registers and + |\numexpr|-essions without having to prefix them by |\the|. This is thus + similar to the situation holding previously but with \xintfracname loaded. +\item a bug introduced in |1.08b| made |\xintCmp| crash when one of its + arguments was zero. +\end{itemize} + + +\noindent Release |1.08b| (|[2013/06/14]|): \begin{itemize} \item Correction of a problem with spaces inside |\xintexpr|-essions. \item Additional improvements to the handling of floating point numbers. @@ -698,6 +1049,8 @@ To write the |\xintexpr| parser I benefited from the commented source of the \LaTeX3 parser; the |\xintexpr| parser has its own features and peculiarities. See \hyperref[sec:comexpr]{its documentation}. +\normalsize + \subsection{Overview} The main characteristics are: @@ -1025,9 +1378,7 @@ Important points, to be noted, related to the expansion of arguments: \item the macros expand `fully' their arguments, this means that they expand the first token seen (for each argument), then expand \MyMarginNote{Changed in |1.06|}, etc..., until something un-expandable - such as a\strut{} digit or a brace is hit against.\footnote{the - knowledgeable people will have recognized - \texttt{\string\romannumeral-\string`0}} This example + such as a\strut{} digit or a brace is hit against. This example \centeredline{|\def\x{98765}\def\y{43210}|% |\xintAdd {\x}{\x\y}|} is \emph{not} a legal construct, as the |\y| will remain untouched by expansion and not get converted into the digits which @@ -1067,12 +1418,12 @@ Important points, to be noted, related to the expansion of arguments: release |1.06| allows to use this inside other package `primitives' or also similar macros: {|\xintAdd {\AplusBC {1}{2}{3}}{4}|} does work and returns \digitstt{\xintAdd - {\AplusBC {1}{2}{3}}{4}}.\footnote{this strange thing is because this - document uses \xintfracname, and we have printed the raw output of addition - which is automatically a fraction.} + {\AplusBC {1}{2}{3}}{4}}. If, for some reason, it is important to create a macro expanding in two steps - to its final value, the solution is to use the \emph{lowercase} form of + to its final value, one may either do: +\smallskip\centeredline {|\def\AplusBC + #1#2#3{|{\color{blue}|\romannumeral-`0\xintAdd |}|{#1}{\xintMul {#2}{#3}}}|}or use the \emph{lowercase} form of \csa{xintAdd}: \smallskip\centeredline {|\def\AplusBC #1#2#3{|{\color{blue}|\romannumeral0\xintadd |}|{#1}{\xintMul {#2}{#3}}}|} @@ -1080,35 +1431,34 @@ Important points, to be noted, related to the expansion of arguments: other \xintname `primitive' macros. - The lowercase form is \emph{only} for the external highest level of chained - commands. All \xintname provided public macros have such a lowercase form. To - more fully imitate the \xintname standard habits, the example above should - thus be treated via the creation of two macros:\par\parskip0pt - \hspace*{1cm}|\def\aplusbc #1#2#3{\xintadd {#1}{\xintMul {#2}{#3}}}|\par - \hspace*{1cm}|\def\AplusBC {\romannumeral0\aplusbc}|\par - Or, for people using the \LaTeX{} vocabulary:\par - \hspace*{1cm}|\newcommand*{\aplusbc}[3]{\xintadd {#1}{\xintMul - {#2}{#3}}}|\par - \hspace*{1cm}|\newcommand*{\AplusBC}{\romannumeral0\aplusbc}|\par - - This then allows further definitions of macros expanding in two steps only, - such as:\par - |\def\aplusbcsquared #1#2#3{\aplusbc {#1}{#2}{\xintSqr{#3}}}|\par - |\def\AplusBCSquared {\romannumeral0\aplusbcsquared}|\par - |\newcommand*\myalgebra [6]{\xintmul {\AplusBC {#1}{#2}{#3}}{\AplusBC - {#4}{#5}{#6}}}|\par - |\newcommand*\MyAlgebra {\romannumeral0\myalgebra}|\par +% All \xintname provided public macros have such a lowercase form. To +% more fully imitate the \xintname standard habits, the example above should +% thus be treated via the creation of two macros:\par\parskip0pt +% \hspace*{1cm}|\def\aplusbc #1#2#3{\xintadd {#1}{\xintMul {#2}{#3}}}|\par +% \hspace*{1cm}|\def\AplusBC {\romannumeral0\aplusbc}|\par +% Or, for people using the \LaTeX{} vocabulary:\par +% \hspace*{1cm}|\newcommand*{\aplusbc}[3]{\xintadd {#1}{\xintMul +% {#2}{#3}}}|\par +% \hspace*{1cm}|\newcommand*{\AplusBC}{\romannumeral0\aplusbc}|\par + +% This then allows further definitions of macros expanding in two steps only, +% such as:\par +% |\def\aplusbcsquared #1#2#3{\aplusbc {#1}{#2}{\xintSqr{#3}}}|\par +% |\def\AplusBCSquared {\romannumeral0\aplusbcsquared}|\par +% |\newcommand*\myalgebra [6]{\xintmul {\AplusBC {#1}{#2}{#3}}{\AplusBC +% {#4}{#5}{#6}}}|\par +% |\newcommand*\MyAlgebra {\romannumeral0\myalgebra}|\par \end{enumerate} -The |\romannumeral0| things above look like an invitation to hacker's -territory; if it is not important that the macro expands in two steps only, -there is no reason to follow these guidelines. Just chain arbitrarily the -package macros, and the new ones will be completely expandable and usable one -within the other. +The |\romannumeral0| and |\romannumeral-`0| things above look like an invitation +to hacker's territory; if it is not important that the macro expands in two +steps only, there is no reason to follow these guidelines. Just chain +arbitrarily the package macros, and the new ones will be completely expandable +and usable one within the other. Release |1.07| has the \csb{xintNewExpr} command\MyMarginNote{New with |1.07|} which automatizes the creation of such expandable macros: -\centeredline{|\xintNewExpr\AplusBC[3]{_1+_2*_3}|} creates the |\AplusBC| +\centeredline{|\xintNewExpr\AplusBC[3]{#1+#2*#3}|} creates the |\AplusBC| macro doing the above and expanding in two expansion steps. @@ -1117,7 +1467,14 @@ macro doing the above and expanding in two expansion steps. The core bundle constituents are \xintname, \xintfracname, \xintexprname, each one loading its predecessor. The base constituent \xintname only deals with integers, of arbitrary sizes, and apart from its macro \csb{xintNum}, -the input format is rather strict. Then \xintfracname extends the scope to +the input format is rather strict. + +\begin{framed} + With release |1.09a|, arithmetic macros of \xintname parse their arguments + automatically through \csb{xintNum}. +\end{framed} + +Then \xintfracname extends the scope to fractions: numerators and denominators are separated by a forward slash and may contain each an optional fractional part after the decimal mark (which has to be a dot) and a @@ -1163,21 +1520,21 @@ extending in generality: should be avoided. \end{enumerate} -\begin{framed} - With only package \xintname loaded \TeX{}'s count registers must be prefixed - by |\the| or |\number| inside the arguments to the package macros, except in - places (argument of the factorial, exponent of the power function, ...) where - the documentation of the macro says otherwise. - - With the macros\MyMarginNote[\kern\FrameSep\kern\FrameRule]{Not previously - documented} of \xintfracname (including those of \xintname extended to - fractions) a count register is \emph{accepted} on input, with no need to be - prefixed by |\the| or |\number|. - - Inside |\xinttheexpr...\relax|, count registers must again be prefixed by - |\the| or - |\number| (if they are not arguments to macros of \xintfracname). -\end{framed} +% \begin{framed} +% With only package \xintname loaded \TeX{}'s count registers must be prefixed +% by |\the| or |\number| inside the arguments to the package macros, except in +% places (argument of the factorial, exponent of the power function, ...) where +% the documentation of the macro says otherwise. + +% With the macros\MyMarginNote[\kern\FrameSep\kern\FrameRule]{Not previously +% documented} of \xintfracname (including those of \xintname extended to +% fractions) a count register is \emph{accepted} on input, with no need to be +% prefixed by |\the| or |\number|. + +% Inside |\xinttheexpr...\relax|, count registers must again be prefixed by +% |\the| or +% |\number| (if they are not arguments to macros of \xintfracname). +% \end{framed} \edef\z {\xintAdd @@ -1192,10 +1549,12 @@ extending in generality: numbers, as they are systematically inserted inside a |\numexpr...\relax| expression. +\def\obsolete{\MyMarginNote{This paragraph made obsolete by \digitstt{1.09a}.}} The allowed input formats for `long numbers' and `fractions' are: \begin{enumerate} -\item the strict format is when \xintfracname is not loaded. The number should +\item the strict format is when \xintfracname is not loaded.\obsolete + The number should be a string of digits, optionally preceded by a unique minus sign. The first digit can be zero only if the number is zero. A plus sign is not accepted. There is a macro \csb{xintNum} which normalizes to this form an input having @@ -1205,7 +1564,7 @@ The allowed input formats for `long numbers' and `fractions' are: {+-+-+----++-++----0000000009876543210}}}% Note that |-0| is not legal input and will confuse \xintname (but not \csa{xintNum} which even accepts an empty input). -\item the extended format is with \xintfracname is loaded: the macros are +\item the extended format is when \xintfracname is loaded: the macros are extended from operating on integers to operating on fractions, which are input as (or expand to) |A/B| (or just an integer |A|), where |A| and |B| will be automatically given to the sign and zeros normalizing macro \csb{xintNum}. @@ -1266,7 +1625,7 @@ applies in particular to the number of digits to truncate or round with, to the indices of a series partial sum, \dots With \xintfracname.sty loaded and for arguments of macros accepting fractions on -inputs, use\MyMarginNote{Not previously documented} of count +inputs, use of count registers and even direct algebra with them is possible: a count register |\mycountA| or |\count 255| is admissible as numerator or also as denominator, with no need to be prefixed by |\the| or |\number|. It is even possible to have @@ -1284,23 +1643,27 @@ the maximal allowed number of tokens (the braced slash counts for only one). {\cnta+\cntb{/}17/1+\cnta*\cntb}|\digitstt{->\cnta 10 \cntb 35 \xintRaw {\cnta+\cntb{/}17/1+\cnta*\cntb}}} -This possibility of using directly count registers and even algebraic expression -is only for arguments to macros of \xintfracname: inside |\xintexpr...\relax| -one can not use directly a count register, it must be prefixed by |\the| or -|\number|. And with only \xintname.sty is loaded, the \emph{only} macro allowing -the -above is \csb{xintNum}: -\centeredline{|\cnta 10 \cntb 100 \xintNum - {\cnta+\cntb+\cnta*\cntb}|\digitstt{->\cnta 10 \cntb 100 \xintNum - {\cnta+\cntb+\cnta*\cntb}}} -Note that |\cnta+\cntb+2*\cnta*\cntb| would be too long (it has nine tokens). -Using braces works: -\centeredline{|\cnta 10 \cntb 100 \xintNum - {\cnta+\cntb+{2*\cnta*\cntb}}|\digitstt{->\cnta 10 \cntb 100 \xintNum - {\cnta+\cntb+{2*\cnta*\cntb}}}} -The braces should be used for some sub-part of the expression, not for the -entire thing; alternatively, one can always use |\numexpr {arbitrarily long - expression}\relax| as input: +% This possibility of using directly count registers and even algebraic expression +% is only for arguments to macros of \xintfracname: inside |\xintexpr...\relax| +% one can not use directly a count register, it must be prefixed by |\the| or +% |\number|. + +% And with only \xintname.sty is loaded, the \emph{only} macro allowing +% the +% above is \csb{xintNum}: +% \centeredline{|\cnta 10 \cntb 100 \xintNum +% {\cnta+\cntb+\cnta*\cntb}|\digitstt{->\cnta 10 \cntb 100 \xintNum +% {\cnta+\cntb+\cnta*\cntb}}} +% Note that |\cnta+\cntb+2*\cnta*\cntb| would be too long (it has nine tokens). +% Using braces works: +% \centeredline{|\cnta 10 \cntb 100 \xintNum +% {\cnta+\cntb+{2*\cnta*\cntb}}|\digitstt{->\cnta 10 \cntb 100 \xintNum +% {\cnta+\cntb+{2*\cnta*\cntb}}}} +% The braces should be used for some sub-part of the expression, not for the +% entire thing; + +For long algebraic expressions, the trick is to encompass them in |\numexpr +... \relax| \emph{inside a pair of braces}: \dverb|& \cnta 100 \cntb 10 \cntc 1 \xintRaw {\numexpr {\cnta*\cnta+\cntb*\cntb+\cntc*\cntc+ @@ -1314,16 +1677,18 @@ entire thing; alternatively, one can always use |\numexpr {arbitrarily long Macros expecting fractions may be fed with arbitrarily long |\numexpr|-expressions by the trick of using |\numexpr {long_expression}\relax| as numerator and/or denominator of the - argument to the macro. + argument to the macro. This is a trick as the braces would not be accepted + as regular +|\numexpr|-syntax: and indeed, they + are removed at some point in the processing. - Macros expecting an - integer obeying the \TeX{} bound must to the contrary receive directly - |long_expression| as argument (or |\numexpr long_expression\relax|, but - this is redundant as it will be done by the macro itself.) + + Contrarily, macros expecting an + integer obeying the \TeX{} bound are capable of receiving directly + |long_expression| as argument, the |\numexpr ... \relax| will be + added internally (without the braces of course, they are not legal inside + |\numexpr|). \end{framed} -This is a trick as the braces would not be accepted as regular -|\numexpr|-syntax: and indeed, they - are removed at some point in the processing. \paragraph {Outputs: } loading \xintfracname not only relaxes the format of the inputs; it also modifies the format of the outputs: except when a fraction is @@ -1376,16 +1741,17 @@ allowed use of braces, see the \hyperref[sec:comexpr]{documentation}) be completely harmless, and even recommended for making the source more legible. -Syntax such as |\xintMul\A\B| -is accepted and equivalent\footnote{see however near the end of - \hyperref[sec:ifcase]{this later section} for the important +Syntax such as |\xintMul\A\B| is accepted and equivalent\footnote{see however + near the end of \hyperref[sec:ifcase]{this later section} for the important difference when used in contexts where \TeX{} expects a number, such as following an \csa{ifcase} or an \csa{ifnum}.} to |\xintMul {\A}{\B}|. Or course |\xintAdd\xintMul\A\B\C| does not work, the product operation must be put -within braces: |\xintAdd{\xintMul\A\B}\C|. -It would be nice to have a functional form |\add(x,\mul(y,z))| but -this is not provided by the package. Arguments must be either -within braces or a single control sequence. +within braces: |\xintAdd{\xintMul\A\B}\C|. It would be nice to have a functional +form |\add(x,\mul(y,z))| but this is not provided by the package.\footnote{yes + it is with the |1.09a| \csa{xintexpr}, \csa{xintexpr} + \texttt{add(x,mul(y,z))}\csa{relax}.} Arguments must be either within braces +or a +single control sequence. Note that |-| and |+| may serve only as unary operators, on \emph{explicit} numbers. They can not serve to prefix macros evaluating to such numbers, @@ -1403,32 +1769,33 @@ fractions on input,\footnote{of course, the power function does not accept a when \xintfracname is not loaded. }\,\footnote{also \csb{xintCmp}, \csb{xintSgn}, \csb{xintOpp}, \csb{xintAbs}, \csb{xintMax}, \csb{xintMin} are extended to fractions and have their integer-only initial - synonyms.}\,\footnote{and \csb{xintQuo}, \csb{xintRem}, \csb{xintDivision}, - \csb{xintGeq}, \csb{xintFDg}, \csb{xintLDg}, \csb{xintOdd}, \csb{xintMON}, - \csb{xintMMON} all accept a fractional input as long as it reduces to an - integer.} and produce on output a -fractional number |f=A/B[n]| where |A| and |B| are integers, with |B| positive, -and |n| is a signed ``small'' integer (\emph{i.e} less in absolute value than -|2^{31}-9|). This represents |(A/B)| times |10^n|. The fraction |f| may be, and -generally is, reducible, and |A| and |B| may well end up with zeros (\emph{i.e.} -|n| does not contain all powers of 10). Conversely, this format is accepted on -input (and is parsed more quickly than fractions containing decimal points; the -input may be a number without denominator).\footnote{at each stage of the - computations, the sum of |n| and the length of |A|, or of the absolute value - of |n| and the length of |B|, must be kept less than - |2\string^\string{31\string}-9|.} + synonyms.}\,\footnote{and \csb{xintFac}, \csb{xintQuo}, \csb{xintRem}, + \csb{xintDivision}, \csb{xintGeq}, \csb{xintFDg}, \csb{xintLDg}, + \csb{xintOdd}, \csb{xintMON}, \csb{xintMMON} all accept a fractional input as + long as it reduces to an integer.} and produce on output a fractional number +|f=A/B[n]| where |A| and |B| are integers, with |B| positive, and |n| is a +signed ``small'' integer (\emph{i.e} less in absolute value than |2^{31}-9|). +This represents |(A/B)| times |10^n|. The fraction |f| may be, and generally is, +reducible, and |A| and |B| may well end up with zeros (\emph{i.e.} |n| does not +contain all powers of 10). Conversely, this format is accepted on input (and is +parsed more quickly than fractions containing decimal points; the input may be a +number without denominator).\footnote{at each stage of the computations, the sum + of |n| and the length of |A|, or of the absolute value of |n| and the length + of |B|, must be kept less than |2\string^\string{31\string}-9|.} The \csb{xintiAdd}, \csb{xintiSub}, \csb{xintiMul}, \csb{xintiPow}, -\csb{xintiSum}, \csb{xintiPrd}, etc... are the original un-modified integer-only -versions. They have less parsing overhead. +\csb{xintiSum}, \csb{xintiPrd}, etc... are the +original\MyMarginNote{\digitstt{1.09a}: now original uses also \csa{xintNum}} +un-modified +integer-only versions. They have less parsing overhead. -The macro \csb{xintRaw} prints\MyMarginNote{Changed in |1.07|} the fraction +The macro \csb{xintRaw} prints the fraction directly from its internal representation in |A/B[n]| form. To convert the trailing |[n]| into explicit zeros either at the numerator or the denominator, use \csb{xintRawWithZeros}. In both cases the |B| is printed -even if it has value |1|. +even if it has value |1|.\MyMarginNote{Changed in |1.07|} Conversely (sort of), the macro \csb{xintREZ} puts all powers of ten into the |[n]| (REZ stands for remove zeros). @@ -1531,10 +1898,14 @@ With |\def\A{1}|: Release |1.07| provides the expandable\MyMarginNote{New with |1.07|} \csb{xintSgnFork} which chooses one of three branches according to whether its -argument expand to |-1|, |0| or |1|. This, rather than the corresponding +argument expands to |-1|, |0| or |1|. This, rather than the corresponding |\ifcase|, should be used when such a fork is needed as argument to one of the package macros. +Release |1.09a| has \csb{xintifSgn} which does not require\MyMarginNote{New with |1.09a|} its first argument to +be |-1|, |0|, |1|, it first computes the sign. There are also \csb{xintifZero}, +\csb{xintifNotZero}, \csb{xintifGt}, \csb{xintifLt}, \csb{xintifEq}. + \section{Multiple outputs}\label{sec:multout} @@ -1918,7 +2289,8 @@ database. \def\x{\string{x\string}} \texttt{\n} (or also \texttt{\m}) stands for a (long) number within braces with -one optional minus sign and no leading zeros, or for a control sequence possibly +one optional minus sign and no leading zeros,\MyMarginNote{|1.09a| uses + \csa{xintNum} in most macros} or for a control sequence possibly within braces and expanding to such a number (without the braces!), or for material within braces which expands to such a number after repeated expansions of the first token. @@ -1931,38 +2303,56 @@ digits or something like |4*\count 255 + 17|, etc... A count register or \csa{numexpr} expression, used as an argument to a macro dealing with long integers, must be prefixed by |\the| or -|\number|. +|\number|.\MyMarginNote{Changed in |1.09a|, see below} + +Some of these macros are extended by \xintfracname to accept fractions on input, +and, generally, to output a fraction. This will be mentioned and the original +integer only macro \csa{xintAbc} remains then available under the name +\csa{xintiAbc}. Even the original integer-only macros may now accept fractions +on input as long as they are integers in disguise; they still produce on output +integers without any forward slash mark nor trailing |[n]|. On the other hand +macros such as |\xintAdd| will output fractions |A/B[n]|, with |B| present even +if its value is one. To +remove this unit denominator and convert the |[n]| part into explicit zeros, one +has \csb{xintNum}. This is mandatory when the computation result is fetched into +a context where \TeX{} expects a number (assuming it does not exceed &2^31&). +See the also the \xintfracname \hyperref[sec:comfrac]{documentation} for more +information on how macros of \xintname are modified after loading \xintfracname +(or \xintexprname). + + +In release |1.09a|, even with \xintfracname not loaded, many macros parse +automatically their arguments via \csb{xintNum} which removes extraneous plus or +minus signs, leading zeros, and allows direct use of a count register, without +|\the|. -Some of these macros are extended by \xintfracname to accept fractions -on input, and, generally, to output a fraction. This will be mentioned -and the original macro \csa{xintAbc} remains then available under the -name \csa{xintiAbc}. -\begin{framed} - For the macros extended by the loading of \xintfracname.sty, it is not - necessary anymore to prefix a count register with |\the|. See the previous - `\hyperlink{useofcount}{Use of count registers}' section. -\end{framed} -Some macros such as \csa{xintQuo} or \csa{xintNum} (which are among those made -to accept fractions on input when \xintfracname.sty is loaded) check that the -fraction is an integer in disguise. They still produce on output integers -without any forward slash mark nor trailing |[n]|. Again the original is still -available with an additional `i' in the name, in case it is important to skip -the parsing, but here the output format is the same. See the \xintfracname -\hyperref[sec:comfrac]{documentation} for more information. - -The integer-only macros are a bit more efficient, even for simple things such as -determining the sign of a (long) number, as there is always some overhead due to -the parsing the fraction format on input. This overhead, when package -\xintfracname has been loaded and has modified the \xintname routines, usually -will not matter much, but there are contexts where obtaining\strut{} an integer -without -a forward slash nor trailing |[n]| is mandatory:\IMPORTANT{} -for example after an |\ifnum| or inside a -|\numexpr| (for `short' integers) or when used as argument to one of the package -macros which are stricly integer-only on input such as \csb{xintiSqrt}, or -\csb{xintDouble} or \csb{xintDecSplit}. A fraction which in disguise is an -integer can be stripped of the slash and trailing |[n]| using \csb{xintNum}. + + +% \begin{framed} +% For macros extended by \xintfracname.sty, count registers +% used in their arguments need no |\the| prefix. See the +% previous `\hyperlink{useofcount}{Use of count registers}' section. +% \end{framed} + + +% Some macros such as \csa{xintQuo} or \csa{xintNum} (which are among those made +% to accept fractions on input when \xintfracname.sty is loaded) check that the +% fraction is an integer in disguise. + + +% The integer-only macros are a bit more efficient, even for simple things such as +% determining the sign of a (long) number, as there is always some overhead due to +% the parsing the fraction format on input. This overhead, when package +% \xintfracname has been loaded and has modified the \xintname routines, usually +% will not matter much, but there are contexts where obtaining\strut{} an integer +% without +% a forward slash nor trailing |[n]| is mandatory:\IMPORTANT{} +% for example after an |\ifnum| or inside a +% |\numexpr| (for `short' integers) or when used as argument to one of the package +% macros which are stricly integer-only on input such as \csb{xintiSqrt}, or +% \csb{xintDouble} or \csb{xintDecSplit}. + \localtableofcontents @@ -2121,21 +2511,32 @@ job without the initial expansion. \def\macro #1{\the\numexpr 9-#1\relax} -\csa{xintApply}|{\macro}|\marg{list} applies the one parameter command |\macro| -to -each item in the \meta{list} (no separator) given as second argument. Each item -is -given in turn as parameter to |\macro| which is expanded (as usual, \emph{i.e.} -fully for what comes first), and -the result is braced. On output, a new list with these braced results. The -\meta{list} may itself be some macro expanding (in the previously described way) -to -the list of tokens to which the command |\macro| will be applied. For example, -if the \meta{list} expands to some positive number, then each digit will be -replaced -by the result of applying |\macro| on it. \centeredline{|\def\macro - #1{\the\numexpr 9-#1\relax}|} \centeredline{|\xintApply\macro{\xintFac - {20}}|\digitstt{=\xintApply\macro{\xintFac {20}}}} +\csa{xintApply}|{\macro}|\marg{list} expandably applies the one parameter +command |\macro| to each item in the \meta{list} given as second argument and +return a new list with these outputs: each item is given one after the other as +parameter to |\macro| which is expanded (as usual, \emph{i.e.} fully for what +comes first), and the result is braced. On output, a new list with these braced +results (if |\macro| is defined to start with a space, the space will be gobbled +and the following replacement text of |\macro| will not be executed; |\macro| +may aslo be something like |\macro|\marg{fixed\_first}, then the list elements +will serve as second argument to |\macro|). + +Being expandable, |\xintApply| is useful for example inside alignments where +implicit groups make standard loops constructs fail. In such situation it is +often not wished that the new list elements be braced, see +\csb{xintApplyUnbraced}. + +For faster code, there is the non-expandable \csb{xintApplyInline} which does +like \csa{xintApplyUnbraced} but executes |\macro| immediately in the expansion +flow. + +The \meta{list} may +itself be some macro expanding (in the previously described way) to the list of +tokens to which the command |\macro| will be applied. For example, if the +\meta{list} expands to some positive number, then each digit will be replaced by +the result of applying |\macro| on it. \centeredline{|\def\macro #1{\the\numexpr + 9-#1\relax}|} \centeredline{|\xintApply\macro{\xintFac + {20}}|\digitstt{=\xintApply\macro{\xintFac {20}}}} The macro \csa{xintApplyNoExpand} does the same job without the first initial expansion @@ -2148,13 +2549,13 @@ which gave the \meta{list} of braced tokens to which |\macro| is applied. \def\macro #1{\expandafter\def\csname myself#1\endcsname {#1}} \xintApplyUnbraced\macro{{elta}{eltb}{eltc}} -\csa{xintApplyUnbraced}|{\macro}|\marg{list} is like \csb{xintApply} except that -the -various outputs are not again braced. The net effect is the same as doing +\csa{xintApplyUnbraced}|{\macro}|\marg{list} is like \csb{xintApply}. The +difference is that after having expanding its second argument, and then applied +|\macro| fully expanded to each token or braced thing found, it reassembles the +outputs without enclosing them in braces. The net effect is the same as doing \centeredline{|\xintListWithSep {}{\xintApply {\macro}|\marg{list}|}|} -This command is useful for non-expandable -things like doing macro definitions, for which braces are an inconvenience. -(sorry for the silly example: ) +This is useful for preparing a macro which will itself define some other macros +or make assignments. % sorry also for the silly coding of the following verbatim block \lverb|& $ $ $ $ \def\macro #1{\expandafter\def\csname myself#1\endcsname {#1}}$\ @@ -2166,35 +2567,46 @@ initial expansion which gave the \meta{list} of braced tokens to which |\macro| is applied. +\subsection{\csbh{xintApplyInline}}\label{xintApplyInline} + +{\small New in release |1.09a|.\par} + +\csa{xintApplyInline}|{\macro}|\marg{list} works non expandably. It immediately +applies the one-parameter |\macro| to the first element of the expanded list, +and then with each element until reaching the end. This is to be used in +situations where the code needs to do immediately some repetitive things, it can +not be used to prepare material inside some macro for later execution, +contrarily to \csb{xintApply} or \csb{xintApplyUnbraced}. + + \subsection{\csbh{xintAssign}}\label{xintAssign} \csa{xintAssign}\meta{braced things}\csa{to}% \meta{as many cs as they are things} defines (without checking if something gets overwritten) the control sequences on the right of -\csa{to} to be the complete expansions of the successive things on -the left of \csa{to} enclosed within braces. +\csa{to} to be the complete expansions of the successive braced things found on +the left of \csa{to}. -Important: a `full' expansion (as previously described) is applied first to the -material in front of \csa{xintAssign}. +A `full' expansion is first applied first to the +material in front of \csa{xintAssign}, which may thus be a macro expanding to a +list of braced items. \xintAssign\xintiPow {7}{13}\to\SevenToThePowerThirteen \xintAssign\xintDivision{1000000000000}{133333333}\to\Q\R -As a special exception, if after this initial expansion a -brace does not immediately follows \csa{xintAssign}, it is assumed -that there is only one control sequence to define and it is then -defined to be the complete expansion of the entire material between -\csa{xintAssign} and \csa{to}. +Special case: if after this initial expansion no brace is found immediately +after \csa{xintAssign}, it is assumed that there is only one control sequence +following |\to|, and this control sequence is then defined via |\edef| as the +complete expansion of the material between \csa{xintAssign} and \csa{to}. \centeredline{|\xintAssign\xintDivision{1000000000000}{133333333}\to\Q\R|} -\centeredline{|\meaning\Q: |\digitstt{\meaning\Q}, |\meaning\R: - |\digitstt{\meaning\R}} \centeredline{|\xintAssign\xintiPow +\centeredline{|\meaning\Q: |\digitstt{\meaning\Q}, |\meaning\R:| + \digitstt{\meaning\R}} \centeredline{|\xintAssign\xintiPow {7}{13}\to\SevenToThePowerThirteen|} \centeredline{|\SevenToThePowerThirteen|\digitstt{=\SevenToThePowerThirteen}} - -Of course this macro and its cousins completely break usage in -pure expansion contexts, as assignments are made via the -\csa{edef} primitive. +\centeredline{(same as |\edef\SevenToThePowerThirteen{\xintiPow {7}{13}}|)} This +macro uses various \csa{edef}'s, thus is incompatible with expansion-only +contexts. \subsection{\csbh{xintAssignArray}}\label{xintAssignArray} @@ -2203,18 +2615,21 @@ pure expansion contexts, as assignments are made via the \xintAssignArray\xintBezout {1000}{113}\to\Bez -\csa{xintAssignArray}\meta{braced things}\csa{to}\csa{myArray} first -expands fully the first token then defines \csa{myArray} to be a macro with one -parameter, such that \csa{myArray\x} expands in two steps (which provoke the -full expansion of the `short' number \texttt{\x}, given to a -|\numexpr|) to give the |x|th braced -thing, itself completely expanded. \csa{myArray}|{0}| returns the number |M| of -elements of the array so that the successive elements are \csa{myArray}|{1}|, -\dots, \csa{myArray}|{M}|. \centeredline{|\xintAssignArray\xintBezout - {1000}{113}\to\Bez|} will set |\Bez{0}| to \digitstt{\Bez0}, |\Bez{1}| to -\digitstt{\Bez1}, |\Bez{2}| to \digitstt{\Bez2}, |\Bez{3}| to \digitstt{\Bez3}, -|\Bez{4}| to \digitstt{\Bez4}, and |\Bez{5}| to \digitstt{\Bez5}: +\csa{xintAssignArray}\meta{braced things}\csa{to}\csa{myArray} first expands +fully what comes immediately after |\xintAssignArray| and expects to find a list +of braced things |{A}{B}...| (or tokens). It then defines \csa{myArray} as a +macro with one parameter, such that \csa{myArray\x} expands to give the +completely expanded |x|th braced thing of this original list (the argument +\texttt{\x} itself is fed to a |\numexpr| by |\myArray|, and |\myArray| expands +in two steps to its output). With |0| as parameter, \csa{myArray}|{0}| returns +the number |M| of elements of the array so that the successive elements are +\csa{myArray}|{1}|, \dots, \csa{myArray}|{M}|. +\centeredline{|\xintAssignArray\xintBezout {1000}{113}\to\Bez|} will set +|\Bez{0}| to \digitstt{\Bez0}, |\Bez{1}| to \digitstt{\Bez1}, |\Bez{2}| to +\digitstt{\Bez2}, |\Bez{3}| to \digitstt{\Bez3}, |\Bez{4}| to \digitstt{\Bez4}, +and |\Bez{5}| to \digitstt{\Bez5}: \digitstt{(\Bez3)${}\times{}$\Bez1${}-{}$(\Bez4)${}\times{}$\Bez2${}={}$\Bez5.} +This macro is incompatible with expansion-only contexts. \subsection{\csbh{xintRelaxArray}}\label{xintRelaxArray} @@ -2259,43 +2674,67 @@ prefixed by |\the| and a |\numexpr...\relax| also should be prefixed by |\the|). This utility is provided to help construct expandable macros choosing depending on a condition which one of the package macros to use, or which values to confer to their arguments. -\dverb(& -\def\myfunction #1% -% expands to |x+1| if x < -1, x-1 if x > 1, else 1 - x^2 -% rounded to two decimal places - {\xintRound {2}{\xintSgnFork - {\xintSgnFork{\xintGeq{#1}{1}}{}{0}{\xintSgn{#1}}} - {\xintSub{-1}{#1}}{\xintSub{1}{\xintSqr{#1}}}{\xintSub{#1}{1}}}}% -\xintListWithSep{,\,}{\xintApply\myfunction - {{-5/2}{-2}{-3/2}{-1}{-1/2}{0}{1/2}{1}{3/2}{2}{5/2}}} -( - -\def\myfunction #1% - {\xintRound {2}{\xintSgnFork - {\xintSgnFork{\xintGeq{#1}{1}}{}{0}{\xintSgn{#1}}} - {\xintSub{-1}{#1}}{\xintSub{1}{\xintSqr{#1}}}{\xintSub{#1}{1}}}}% -\digitstt{\xintListWithSep{,\,}{\xintApply\myfunction - {{-5/2}{-2}{-3/2}{-1}{-1/2}{0}{1/2}{1}{3/2}{2}{5/2}}}} - -Using an \xintexprname-ession, one may simplify the coding: -\dverb*& -\def\myfunction #1% expands to |x+1| if x < -1, x-1 if x > 1, else 1 - x^2 - {\xintRound {2}{\xinttheexpr\xintSgnFork - {\xintSgnFork{\xintGeq{#1}{1}}{}{0}{\xintSgn{#1}}} - { -#1 - 1 }{ 1 - (#1)^2 }{ #1 - 1 } \relax }}% -* - -\def\myfunction #1% expands to |x+1| if x < -1, x-1 if x > 1, else 1 - x^2 - {\xintRound {2}{\xinttheexpr\xintSgnFork - {\xintSgnFork{\xintGeq{#1}{1}}{}{0}{\xintSgn{#1}}} - { -#1 - 1 }{ 1 - (#1)^2 }{ #1 - 1 } \relax }}% - -\digitstt{\xintListWithSep{,\,}{\xintApply\myfunction - {{-5/2}{-2}{-3/2}{-1}{-1/2}{0}{1/2}{1}{3/2}{2}{5/2}}}} - -Notice the use of parentheses, with |#1=-1|, |1-#1^2| would give |1--1^2| which -evaluates to |2|. Or with |#1=3/2|, |1-#1^2| gives |1-3/2^2| which evaluates -inside an \xintexprname-ession to |1-3/4=1/4| not |1-9/4=-5/4|. +% \dverb(& +% \def\myfunction #1% +% % expands to |x+1| if x < -1, x-1 if x > 1, else 1 - x^2 +% % rounded to two decimal places +% {\xintRound {2}{\xintSgnFork +% {\xintSgnFork{\xintGeq{#1}{1}}{}{0}{\xintSgn{#1}}} +% {\xintSub{-1}{#1}}{\xintSub{1}{\xintSqr{#1}}}{\xintSub{#1}{1}}}}% +% \xintListWithSep{,\,}{\xintApply\myfunction +% {{-5/2}{-2}{-3/2}{-1}{-1/2}{0}{1/2}{1}{3/2}{2}{5/2}}} +% ( + +% \def\myfunction #1% +% {\xintRound {2}{\xintSgnFork +% {\xintSgnFork{\xintGeq{#1}{1}}{}{0}{\xintSgn{#1}}} +% {\xintSub{-1}{#1}}{\xintSub{1}{\xintSqr{#1}}}{\xintSub{#1}{1}}}}% +% \digitstt{\xintListWithSep{,\,}{\xintApply\myfunction +% {{-5/2}{-2}{-3/2}{-1}{-1/2}{0}{1/2}{1}{3/2}{2}{5/2}}}} + +% Using an \xintexprname-ession, one may simplify the coding: +% \dverb*& +% \def\myfunction #1% expands to |x+1| if x < -1, x-1 if x > 1, else 1 - x^2 +% {\xintRound {2}{\xinttheexpr\xintSgnFork +% {\xintSgnFork{\xintGeq{#1}{1}}{}{0}{\xintSgn{#1}}} +% { -#1 - 1 }{ 1 - (#1)^2 }{ #1 - 1 } \relax }}% +% * + +% \def\myfunction #1% expands to |x+1| if x < -1, x-1 if x > 1, else 1 - x^2 +% {\xintRound {2}{\xinttheexpr\xintSgnFork +% {\xintSgnFork{\xintGeq{#1}{1}}{}{0}{\xintSgn{#1}}} +% { -#1 - 1 }{ 1 - (#1)^2 }{ #1 - 1 } \relax }}% + +% \digitstt{\xintListWithSep{,\,}{\xintApply\myfunction +% {{-5/2}{-2}{-3/2}{-1}{-1/2}{0}{1/2}{1}{3/2}{2}{5/2}}}} + +% Notice the use of parentheses, with |#1=-1|, |1-#1^2| would give |1--1^2| which +% evaluates to |2|. Or with |#1=3/2|, |1-#1^2| gives |1-3/2^2| which evaluates +% inside an \xintexprname-ession to |1-3/4=1/4| not |1-9/4=-5/4|. + +\subsection{\csbh{xintifSgn}}\label{xintifSgn} +{\small New with release |1.09a|.\par} + +Same as \csa{xintSgnFork} except that the first argument may be any integer (or +fraction with \xintfracname loaded), it +is its sign whih decides the three way branching. + +\subsection{\csbh{xintifZero}}\label{xintifZero} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintifNotZero}}\label{xintifNotZero} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintifEq}}\label{xintifEq} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintifGt}}\label{xintifGt} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintifLt}}\label{xintifLt} +{\small New with release |1.09a|.\par} + + \subsection{\csbh{xintOpp}}\label{xintiOpp} @@ -2323,11 +2762,49 @@ by \xintfracname to fractions. \csa{xintCmp\n\m} returns 1 if |N>M|, 0 if |N=M|, and -1 if |N<M|. Extended by \xintfracname to fractions. +\subsection{\csbh{xintEq}}\label{xintEq} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintGt}}\label{xintGt} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintLt}}\label{xintLt} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintIsZero}}\label{xintIsZero} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintIsNotZero}}\label{xintIsNotZero} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintIsOne}}\label{xintIsOne} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintAND}}\label{xintAND} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintOR}}\label{xintOR} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintXOR}}\label{xintXOR} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintANDof}}\label{xintANDof} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintORof}}\label{xintORof} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintXORof}}\label{xintXORof} +{\small New with release |1.09a|.\par} + + + \subsection{\csbh{xintGeq}}\label{xintiGeq} \csa{xintGeq\n\m} returns 1 if the \emph{absolute value} of the first number is at least equal to the absolute value of the second number. If \verb+|N|<|M|+ it -returns 0. Extended by \xintfracname to fractions (starting with relaease +returns 0. Extended by \xintfracname to fractions (starting with release |1.07|). Please note that the macro compares \emph{absolute values}. \subsection{\csbh{xintMax}}\label{xintiMax} @@ -2337,6 +2814,9 @@ structure on the relative integers (\emph{i.e.} the right-most number if they are put on a line with positive numbers on the right): |\xintiMax {-5}{-6}|\digitstt{=\xintiMax{-5}{-6}}. Extended by \xintfracname to fractions. +\subsection{\csbh{xintMaxof}}\label{xintMaxof} +{\small New with release |1.09a|.\par} + \subsection{\csbh{xintMin}}\label{xintiMin} \csa{xintMin\n\m} returns the smallest of the two in the sense of the order @@ -2344,6 +2824,9 @@ structure on the relative integers (\emph{i.e.} the left-most number if they are put on a line with positive numbers on the right): |\xintiMin {-5}{-6}|\digitstt{=\xintiMin{-5}{-6}}. Extended by \xintfracname to fractions. +\subsection{\csbh{xintMinof}}\label{xintMinof} +{\small New with release |1.09a|.\par} + \subsection{\csbh{xintSum}}\label{xintiSum} \csa{xintSum}\marg{braced things} after expanding its argument @@ -2554,11 +3037,6 @@ euclidean division by ten. \csa{xintOdd\n} is 1 if the number is odd and 0 otherwise. -\begin{framed} -The macros described next are strictly for integer-only arguments. If -\xintfracname is loaded, use \csb{xintNum} if necessary. -\end{framed} - \subsection{\csbh{xintiSqrt}, \csbh{xintiSquareRoot}}\label{xintiSqrt} \label{xintiSquareRoot} @@ -2587,6 +3065,11 @@ most |1/2M|; if |N| is a perfect square |k^2| then |M=k+1| and this gives Package \xintfracname has \csb{xintFloatSqrt} for square roots of floating point numbers. +\begin{framed} +The macros described next are strictly for integer-only arguments. If +\xintfracname is loaded, use \csb{xintNum} if necessary. +\end{framed} + \subsection{\csbh{xintInc}, \csbh{xintDec}} \label{xintInc} \label{xintDec} @@ -2753,7 +3236,7 @@ fully) each one of its arguments applies. |f| stands for an integer or a fraction (see \autoref{sec:inputs} for the accepted input formats) or something which expands to an integer or fraction. It is possible to use in the numerator or the denominator of |f| count -registers\MyMarginNote{Not previously documented} and even expressions with +registers and even expressions with infix arithmetic operators, under some rules which are explained in the previous \hyperlink{useofcount}{Use of count registers} section. @@ -2766,13 +3249,13 @@ must expand to an integer obeying the \TeX{} bound. The fraction format on output is the scientific notation for the `float' macros, and the |A/B[n]| format for all other fraction macros, with the exception of \csb{xintTrunc}, {\color{blue}\string\xint\-Round} (which produce decimal -numbers) -and \csb{xintIrr}, \csb{xintJrr}, \csb{xintRawWithZeros} (which return an |A/B| -with no trailing |[n]|, even if |B| turns out to be |1|). Use \csb{xintNum} for -fractions a priori known to simplify to integers: |\xintNum {\xintAdd {2}{3}}| -gives \digitstt{\xintNum {\xintAdd {2}{3}}} whereas |\xintAdd {2}{3}| returns -\digitstt{\xintAdd {2}{3}}. Some macros (among them \csb{xintiTrunc}, -\csb{xintiRound}, and \csb{xintFac}) already produce integers on output. +numbers) and \csb{xintIrr}, \csb{xintJrr}, \csb{xintRawWithZeros} (which returns +an |A/B| with no trailing |[n]|, and prints the |B| even if it is |1|). Use +\csb{xintNum} for fractions a priori known to simplify to integers: |\xintNum +{\xintAdd {2}{3}}| gives \digitstt{\xintNum {\xintAdd {2}{3}}} whereas |\xintAdd +{2}{3}| returns \digitstt{\xintAdd {2}{3}}. Some macros (among them +\csb{xintiTrunc}, \csb{xintiRound}, and \csb{xintFac}) already produce integers +on output. \localtableofcontents @@ -2814,6 +3297,13 @@ as returned by \csa{xintNumerator}|{f}| and |B| as returned by \centeredline{\digitstt{\xintRawWithZeros{\the\numexpr 571*987\relax.123e-10/\the\numexpr -201+59\relax e-7}}} +\subsection{\csbh{xintFloor}}\label{xintFloor} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintCeil}}\label{xintCeil} +{\small New with release |1.09a|.\par} + + \subsection{\csbh{xintNumerator}}\label{xintNumerator} This returns the numerator corresponding to the internal representation of a @@ -2906,7 +3396,7 @@ otherwise simplify the fraction. {\small New with |1.07|.} |\xintE {f}{x}| multiplies the fraction |f| by &10^x&. The \emph{second} -argument |x| must obey the \TeX{} bounds. It may be a count register: |\count +argument |x| must obey the \TeX{} bounds. Example: |\count 255 123456789 \xintE {10}{\count 255}|\digitstt{->\count 255 123456789 \xintE {10}{\count 255}}. Be careful that for obvious reasons such gigantic numbers should not be given to \csb{xintNum}, or added to something @@ -3268,6 +3758,9 @@ tens does not take a quasi-infinite time, contrarily to the earlier, somewhat dumb version (the earlier version indirectly led to the creation of giant chains of zeros in certain circumstances, causing a serious efficiency impact). +\subsection{\csbh{xintIsOne}} +{\small New with release |1.09a|.\par} + \subsection{\csbh{xintGeq}}\label{xintGeq} {\small Rewritten in |1.08a|.\par} @@ -3289,6 +3782,8 @@ The macro is extended to fractions. But now |\xintMax {2}{3}| returns \digitstt{\xintMax {2}{3}}. The original is available as \csb{xintiMax}. +\subsection{\csbh{xintMaxof}} +{\small New with release |1.09a|.\par} \subsection{\csbh{xintMin}}\label{xintMin} {\small Rewritten in |1.08a|.\par} @@ -3296,6 +3791,9 @@ The macro is extended to fractions. But now |\xintMax {2}{3}| returns The macro is extended to fractions. The original is available as \csb{xintiMin}. +\subsection{\csbh{xintMinof}} +{\small New with release |1.09a|.\par} + \subsection{\csbh{xintAbs}}\label{xintAbs} The macro is extended to fractions. The original is available as @@ -3344,6 +3842,22 @@ The \xintexprname package was first released with version |1.07| of the \xintname bundle. Loading this package automatically loads \xintfracname, hence also \xintname. +\begin{framed} + Release |1.09a| has extended the scope of |\xintexpr|-essions with infix + comparison operators (|<|, |>|, |=|), logical operators (|&|, \verb+|+), + functions (|round|, |sqrt|, |max|, |all|, etc...) and conditional branching + (|if| and |?|, |ifsgn| and |:|, the function forms evaluate the skipped + branches, the |?| and |:| operators do not). + + Refer to the first pages of this manual for the current situation. Apart from + some adjustments in the description of |\xintNewExpr| which now works with + |#|, and removal of obsolete material, the documentation in this section is + close to its earlier state describing |1.08b| and is lacking in examples + illustrating all the new functionality with |1.09a|. +\end{framed} + +%% \clearpage + \localtableofcontents \subsection{The \csbh{xintexpr} expressions}\label{xintexpr}% @@ -3352,7 +3866,8 @@ also \xintname. An \xintexprname{}ession is a construct \csb{xintexpr}\meta{expandable\_expression}|\relax| where the expandable -expression is read and expanded from left to right, and whose constituents +expression is read and expanded from left to right, and whose constituents\MyMarginNote{See \autoref{sec:exprsummary} for + up-to-date information} should be (they are uncovered by iterated left to right expansion of the contents during the scanning): \begin{itemize} @@ -3362,18 +3877,6 @@ contents during the scanning): \item fractions |A/B|, or |a.b/c.d| or |a.beN/c.deM|, if they are to be treated as one entity should then be parenthesized, \emph{e.g.} disambiguating |A/B^2| from |(A/B)^2|, -\item fractions |A/B[n]| as produced on output by the macros of the - \xintfracname package; they \emph{must} be enclosed in one pair of braces, for - example |{13/35[3]}| or |{\x\y\z}| with |\x| expanding to |13/|, |\y| - expanding to |35[| and |\z| expanding to |3]|, (\emph{note that using - parentheses does not suffice, braces are required: the parser can not digest - directly square brackets. Material within braces \emph{must} after complete - expansion give either an integer {\upshape|A|} or a fraction in - {\upshape|A/B|} or {\upshape|A/B[n]|} form; it is only in the latter case - that braces are mandatory. They should \emph{not} be used for material - expanding to a fraction in scientific notation, or something else than an - integer or fraction, etc... of course braces also appear in the completely - other r\^ole of feeding macros with their parameters.}), \item the standard binary operators, |+|, |-|, |*|, |/|, and |^| (the |**| notation for exponentiation is not recognized and will give an error), \item opening and closing parentheses, with arbitrary level of nesting, @@ -3381,6 +3884,14 @@ contents during the scanning): \item |!| as postfix factorial operator (applied to a non-negative integer), \item and sub-expressions |\xintexpr|\meta{stuff}|\relax| (they do not need to be put within parentheses). +\item braced material |{...}| which is only allowed to arise when the parser is + starting to fetch an operand; the material will be completely expanded and + \emph{must} deliver some number |A|, or fraction |A/B|, possibly with decimal + mark or ending |[n]|, but without the |e|, |E| of the scientific notation. + Conversely fractions in |A/B[n]| format with the ending |[n]| \emph{must} be + enclosed in such braces. Of course braces also appear in the completely + other r\^ole of feeding macros with their parameters, they will then not be + seen by the parser at all as they are managed by the macro. \end{itemize} @@ -3392,81 +3903,68 @@ uses one of the two equivalent forms: \item \csb{xintthe}|\xintexpr|\meta{expandable\_expression}|\relax|. \end{itemize} -Both forms are equivalent and produce, always, a fraction in the standard -|A/B[n]| format (even when the result is an integer; as usual no automatic -simplification is done, and adding fractions multiplies all the denominators). -\centeredline{|\xinttheexpr - 1+1/2!+1/3!+1/4!+1/5!\relax|\digitstt{=\xinttheexpr1+1/2!+1/3!+1/4!+1/5!\relax}} - -One will usually post-process with |\xintIrr|, |\xintTrunc| or |\xintRound|, or -|\xintFloat|, or |\xintNum| (when the output is known to be an integer) to get -the result in the desired form. One may imagine some future version where the -output format will be given as optional argument to |\xintexpr|. -\centeredline{|\xintIrr{\xinttheexpr - 1+1/2!+1/3!+1/4!+1/5!\relax}|% - \digitstt{=\xintIrr{\xinttheexpr1+1/2!+1/3!+1/4!+1/5!\relax}}} -\centeredline{|\xinttheexpr 1.99^-2 - 2.01^-2 \relax|\digitstt{=\xinttheexpr - 1.99^-2 - 2.01^-2 \relax}} \centeredline{|\xintRound{10}{\xinttheexpr - 1.99^-2 - 2.01^-2 \relax}|\digitstt{=\xintRound{10}{\xinttheexpr 1.99^-2 - - 2.01^-2 \relax}}} +As with other package macros the computations are done \emph{exactly}, and with +no simplification of the result. The output format can be coded\MyMarginNote{new + with |1.09a|} inside the expression through the use of one of the functions +|round|, |trunc|, |float|, |reduce|.\footnote{In |round| and |trunc| the second + optional parameter is the number of digits of the fractional part; in |float| + it is the total number of digits.} +\centeredline{|\xinttheexpr 1/5!-1/7!-1/9!\relax|% + \digitstt{=\xinttheexpr 1/5!-1/7!-1/9!\relax}} +\centeredline{|\xinttheexpr round(1/5!-1/7!-1/9!,18)\relax|% + \digitstt{=\xinttheexpr round(1/5!-1/7!-1/9!,18)\relax}} +\centeredline{|\xinttheexpr float(1/5!-1/7!-1/9!,18)\relax|% + \digitstt{=\xinttheexpr float(1/5!-1/7!-1/9!,18)\relax}} +\centeredline{|\xinttheexpr reduce(1/5!-1/7!-1/9!)\relax|% + \digitstt{=\xinttheexpr reduce(1/5!-1/7!-1/9!)\relax}} +\centeredline{|\xinttheexpr 1.99^-2 - 2.01^-2 \relax|% + \digitstt{=\xinttheexpr 1.99^-2 - 2.01^-2 \relax}} +\centeredline{|\xinttheexpr round(1.99^-2 - 2.01^-2, 10)\relax|% + \digitstt{=\xinttheexpr round(1.99^-2 - 2.01^-2, 10) \relax}} \smallskip -Again: \begin{itemize} -\item \xintexprname{}essions evaluate through expansion to arbitrarily big - fractions (in a non-directly printable form), +\item |\xintexpr|-essions evaluate through expansion to arbitrarily big + fractions, and are prefixed by |\xintthe| for printing (or use + |\xinttheexpr|). \item the standard operations of addition, subtraction, multiplication, division, power, are written in infix form, \item recognized numbers on input are either integers, decimal numbers, or numbers written in scientific notation, (or anything expanding to the previous - things), -\item fractions on input which contain the |[n]| part, or macros expanding to - some |A/B[n]| with the trailing |[n]| must be enclosed in - (precisely one) pair of braces to be parsable by the expression - scanner,\footnote{the reason why the braced material should not be a number in - scientific notation is that the `e' will become of catcode other and not be - understood then by the package macros; this is different from an `e' - directly seen by the parser, for which the catcode does not matter. Of - course if the brace pair is for feeding an argument to a macro, then all of - the above is irrelevant.} + things), +\item macros encountered on the way must be fully expandable, +\item fractions on input with the ending |[n]| part, or macros expanding to + such some |A/B[n]| must be enclosed in + (exactly one) pair of braces, \item the expression may contain arbitrarily many levels of nested parenthesized sub-expressions, -\item sub-contents evaluating to fractions should be either +\item sub-contents giving numbers of fractions should be either \begin{enumerate} - \item parenthesized,\footnote{recall that the parser does not produce - explicit fractions |A/B[n]|, hence the bracing rule does not - apply - to the result of the evaluation of the contents within parentheses; - except of course if it was produced by some other means giving an - explicit |A/B[n]|, but then braces should have been used, not - parentheses.} + \item parenthesized, \item a sub-expression |\xintexpr...\relax|, - \item or braced (use of infix operators inside the braced material will have - to - be - understood by the enclosed macros, which may be external to the - package, or explicitely enclosed in a sub |\xinttheexpr...\relax|). + \item or within braces. \end{enumerate} \item an expression can not be given as argument to the other package macros, nor printed, for this one must use |\xinttheexpr...\relax| or |\xintthe\xintexpr...\relax|, -\item the output of these latter expressions is always in the |A/B[n]| - form, and may serve as input to the other package macros accepting fractions, -\item |\xinttheexpr...\relax| as a sub-constituent of an |\xintexpr...\relax| - must be within some braces, else it should be written directly as +\item one does not use |\xinttheexpr...\relax| as a sub-constituent of an + |\xintexpr...\relax| as it would have to be put + within some braces, and it is simpler to write it directly as |\xintexpr...\relax|, \item as usual no simplification is done on the output and is the responsability of post-processing, \item very long output will need special macros to break across lines, like the |\printnumber| macro used in this documentation, -\item everything is expanded along the way, the expression may contain - macros, but of course use of |+|, |*|, ... within their arguments - is only possible if - these macros know how to deal with them, +\item use of |+|, |*|, ... inside parameters to macros is out of the scope of + the |\xintexpr| parser, \item finally each \xintexprname{}ession is completely expandable and obtains its result in two expansion steps. \end{itemize} +With defined macros destined to be re-used within another one, one has the +choice between parentheses or |\xintexpr...\relax|: |\def\x {(\a+\b)}| or +|\def\x {\xintexpr \a+\b\relax}|. The latter is better as it allows |\xintthe|. + \subsection{\texorpdfstring{\texttt{\protect\string\numexpr}}{\textbackslash numexpr} expressions, count and dimension registers} They can not be used directly but must be prefixed by |\the| or |\number| for @@ -3483,6 +3981,23 @@ decimal point. \subsection{Catcodes and spaces} + +\subsubsection{\csbh{xintexprSafeCatcodes}}\label{xintexprSafeCatcodes} +{\small New with release |1.09a|.\par} + +Active characters will interfere with |\xintexpr|-essions. One may prefix them +with |\string| or use the command \csa{xintexprSafeCatcodes} before the +|\xintexpr|-essions. This (locally) sets the catcodes of the characters acting +as operators to safe values. The command \csb{xintNewExpr} does it by itself, +in a group. + +\subsubsection{\csbh{xintexprRestoreCatcodes}}\label{xintexprRestoreCatcodes} +{\small New with release |1.09a|.\par} + +Restores the catcodes to the earlier state. + +\bigskip + Spaces inside an |\xinttheexpr...\relax| should mostly be innocuous\footnote{release |1.08b| fixes a bug in this context.} (if the expression contains macros, then it is the macro which is responsible for @@ -3518,12 +4033,14 @@ with catcodes and spaces is not as flexible within the macro arguments. \subsection{Expandability} As is the case with all other package macros |\xintexpr| expands in two steps to -its final (non-printable) result; and similarly for |\xinttheexpr|. The -`lowercase' form are a bit unusual as these macros are already in lowercase... : -|\xinteval| for |\xintexpr| and |\xinttheeval| for |\xinttheexpr|. +its final (non-printable) result; and similarly for |\xinttheexpr|. -Similarly, -there are |\xintfloateval| and |\xintthefloateval|. +% The +% `lowercase' form are a bit unusual as these macros are already in lowercase... : +% |\xinteval| for |\xintexpr| and |\xinttheeval| for |\xinttheexpr|. + +% Similarly, +% there are |\xintfloateval| and |\xintthefloateval|. As explained above the expressions should contain only expandable material, except that braces are allowed when they enclose either a fraction (or decimal @@ -3564,72 +4081,82 @@ was necessary to do before the availability of the \xintexprname package. \subsection{The \csbh{xintNewExpr} command}\label{xintNewExpr} -This allows to define a completely expandable macro with parameters, expanding -in two steps to its final evaluation, and corresponding to the given -\xintname{}expression where the parameters are input using the underscore as -macro-parameter: |_1|, ..., |_9|.\footnote{using the character |\#| as in - standard macros would have been more complicated to implement, the question - mark |?| is sometimes made active for reasons of punctuation, the dollar sign - was perfect but my text editor does some automatic font coloring and size - change when visualizing a |.tex| file and encountering such a |\$|, there was - also the tab character |\&| which could have been used. Perhaps a future - release could leave the choice of the character to the user.} +% This allows to define a completely expandable macro with parameters, expanding +% in two steps to its final evaluation, and corresponding to the given +% \xintname{}expression where the parameters are input using the usual +% macro-parameter: |#1|, ..., |#9|. The command is used -as:\centeredline{|\xintNewExpr{\myformula}[n]|\marg{stuff}} +as:\centeredline{|\xintNewExpr{\myformula}[n]|\marg{stuff}, where} \begin{itemize} \item \meta{stuff} will be inserted inside |\xinttheexpr . . . \relax|, \item |n| is an integer between zero and nine, inclusive, and tells how many - parameters will |\myformula| have (it is mandatory even - if the macro to be defined will have no parameters), -\item placeholders |_1|, |_2|, ..., |_n| are used inside \meta{stuff} to play - the r\^ole of the macro parameters. + parameters will |\myformula| have (it is \emph{mandatory} despite the bracket + notation, and |n=0| if the macro to be defined has no parameter -- but what + the point then?, an |\edef| will do fine with |\xinttheexpr..\relax|), +\item the placeholders |#1|, |#2|, ..., |#n| are used inside \meta{stuff} + in their usual r\^ole. \end{itemize} The macro |\myformula| is defined without checking if it already exists, \LaTeX{} users might prefer to do first |\newcommand*\myformula {}| to get a reasonable error message in case |\myformula| already exists. +The definition of |\myformula| made by |\xintNewExpr| is global, it transcends +\TeX{} groups or \LaTeX{} environments. The protection against active characters +is done automatically. + It will be a completely expandable macro entirely built-up using |\xintAdd|, |\xintSub|, |\xintMul|, |\xintDiv|, |\xintPow|, |\xintOpp| and |\xintFac| and -corresponding to the formula as written with the infix operators. +corresponding to the formula as written with the infix +operators.\MyMarginNote{|1.09a|: and many others... } + +\begin{framed} + A ``formula'' created by |\xintNewExpr| is thus a macro whose parameters are + given to a possibly very complicated combination of the various macros of + \xintname and \xintfracname; hence one can not use infix notation and hope to + do |\myformula {28^7-35^12}| (contrarily to the case where one would just made + earlier + \centeredline{|\def\myformula #1{\xinttheexpr (#1)^3\relax}|\;,} for example.) + One will have to do |\myformula {\xinttheexpr 28^7-35^12\relax}|, or redefine + |\myformula| to have more parameters. +\end{framed} -The formula may of course contain besides the infix operators and macro -parameters some arbitrary decimal numbers, fractions (within braces) and also -macros. If these macros do not involve the parameters, nothing special needs to -be done, they will be expanded once during the construction of the formula. But -if the parameters are to be used within the macros themselves, this has to be -coded in a specific manner, which is to be explained after first examining a few -simpler examples: +% The formula may of course contain besides the infix operators and macro +% parameters some arbitrary decimal numbers, fractions (within braces) and also +% macros. If these macros do not involve the parameters, nothing special needs to +% be done, they will be expanded once during the construction of the formula. But +% if the parameters are to be used within the macros themselves, then the macro +% should be code with an underscore |_| rather than a backslash |\|. \dverb|& -\xintNewExpr\myformA[4]{ _1 + _2 * _3^_4 } -\xintNewExpr\myformB[3]{ (_1 + 1.75)^_2 + _3*2.7 } -\xintNewExpr\myformC[3]{ _1*_1+_2*_2+_3*_3-(_1*_2+_2*_3+_3*_1) } -\xintNewExpr\myformD[2]{ (1+1.5*_1)^_2 - (1+1.5*_2)^_1 } -\xintNewExpr\myformE[2]{ -----((((((_1*10-5*_2)))))) } -\xintNewExpr\myformF[4]{ -_1^-_2*-_3-_4 } -\xintNewExpr\myformG[4]{ -_1*-_2^-_3-_4 } -\xintNewExpr\DET[9]{ _1*_5*_9+_2*_6*_7+_3*_4*_8-_1*_6*_8-_2*_4*_9-_3*_5*_7 } +&\xintNewExpr\myformA[4]{ #1 + #2 * #3^#4 } +&\xintNewExpr\myformB[3]{ (#1 + 1.75)^#2 + #3*2.7 } +&\xintNewExpr\myformC[3]{ #1*#1+#2*#2+#3*#3-(#1*#2+#2*#3+#3*#1) } +&\xintNewExpr\myformD[2]{ (1+1.5*#1)^#2 - (1+1.5*#2)^#1 } +&\xintNewExpr\myformE[2]{ -----((((((#1*10-5*#2)))))) } +&\xintNewExpr\myformF[4]{ -#1^-#2*-#3-#4 } +&\xintNewExpr\myformG[4]{ -#1*-#2^-#3-#4 } +\xintNewExpr\DET[9]{ #1*#5*#9+#2*#6*#7+#3*#4*#8-#1*#6*#8-#2*#4*#9-#3*#5*#7 } | -\xintNewExpr\myformA[4]{ _1 + _2 * _3^_4 } -\xintNewExpr\myformB[3]{ (_1 + 1.75)^_2 + _3*2.7 } -\xintNewExpr\myformC[3]{ _1*_1+_2*_2+_3*_3-(_1*_2+_2*_3+_3*_1) } -\xintNewExpr\myformD[2]{ (1+1.5*_1)^_2 - (1+1.5*_2)^_1 } -\xintNewExpr\myformE[2]{ -----((((((_1*10-5*_2)))))) } -\xintNewExpr\myformF[4]{ -_1^-_2*-_3-_4 } -\xintNewExpr\myformG[4]{ -_1*-_2^-_3-_4 } -\xintNewExpr\DET[9]{ _1*_5*_9+_2*_6*_7+_3*_4*_8-_1*_6*_8-_2*_4*_9-_3*_5*_7 } +% \xintNewExpr\myformA[4]{ #1 + #2 * #3^#4 } +% \xintNewExpr\myformB[3]{ (#1 + 1.75)^#2 + #3*2.7 } +% \xintNewExpr\myformC[3]{ #1*#1+#2*#2+#3*#3-(#1*#2+#2*#3+#3*#1) } +% \xintNewExpr\myformD[2]{ (1+1.5*#1)^#2 - (1+1.5*#2)^#1 } +% \xintNewExpr\myformE[2]{ -----((((((#1*10-5*#2)))))) } +% \xintNewExpr\myformF[4]{ -#1^-#2*-#3-#4 } +% \xintNewExpr\myformG[4]{ -#1*-#2^-#3-#4 } +\xintNewExpr\DET[9]{ #1*#5*#9+#2*#6*#7+#3*#4*#8-#1*#6*#8-#2*#4*#9-#3*#5*#7 } \ttfamily -|\meaning\myformA:|\printnumber{\meaning\myformA}\endgraf -|\meaning\myformB:|\printnumber{\meaning\myformB}\endgraf -|\meaning\myformC:|\printnumber{\meaning\myformC}\endgraf -|\meaning\myformD:|\printnumber{\meaning\myformD}\endgraf -|\meaning\myformE:|\printnumber{\meaning\myformE}\endgraf -|\meaning\myformF:|\printnumber{\meaning\myformF}\endgraf -|\meaning\myformG:|\printnumber{\meaning\myformG}\endgraf +% |\meaning\myformA:|\printnumber{\meaning\myformA}\endgraf +% |\meaning\myformB:|\printnumber{\meaning\myformB}\endgraf +% |\meaning\myformC:|\printnumber{\meaning\myformC}\endgraf +% |\meaning\myformD:|\printnumber{\meaning\myformD}\endgraf +% |\meaning\myformE:|\printnumber{\meaning\myformE}\endgraf +% |\meaning\myformF:|\printnumber{\meaning\myformF}\endgraf +% |\meaning\myformG:|\printnumber{\meaning\myformG}\endgraf |\meaning\DET:|\printnumber{\meaning\DET}\endgraf @@ -3638,13 +4165,15 @@ simpler examples: \centeredline{|\xintNum{\DET {1}{2}{3}{10}{0}{-10}{21}{2}{-17}}|% \digitstt{=\xintNum{\DET {1}{2}{3}{10}{0}{-10}{21}{2}{-17}}}} + \rmfamily + \emph{Remark:} |\meaning| has been used within the argument to a |\printnumber| command, to avoid going into the right margin, but this zaps all spaces originally in the output from |\meaning|. Here is as an illustration the raw output of -|\meaning| on the last example: +|\meaning| on the previous example: \ttfamily \meaning\DET @@ -3652,150 +4181,90 @@ output of This is why |\printnumber| was used, to have breaks across lines. -\smallskip +\subsubsection {Use of conditional operators} -For macros to be inserted within such a created \xintname-formula command, there -are two cases: -\begin{enumerate} -\item the macro does not involve the numbered parameters in its arguments: it - may then be left as is, and will be evaluated once during the construction of - the formula, -\item it does involve some of the parameters withing its arguments: then the - whole thing (macro + argument) should be - braced (this is not necessary if it is already included into a braced group) - and the macro should be coded with |:| replacing |\|. -\end{enumerate} + The |1.09a| conditional operators |?| and |:| can not be parsed by + |\xintNewExpr| when they contain macro parameters within their scope, and not + only numerical data. However using the functions |if| and, respectively + |ifsgn|, the parsing should succeed. Moreover the created macro will \emph{not + evaluate the branches to be skipped}, thus behaving exactly like |?| and |:| + would have in the |\xintexpr|. -Here are some examples; they are rather silly but this is to -illustrate the general principles. +\xintNewExpr\Formula [3]{ if((#1>#2) & (#2>#3), + sqrt(#1-#2)*sqrt(#2-#3), #1^2+#3/#2) } -\dverb|& -\xintNewExpr\myformH[2]{ {:xintMax{_1}{_2}} } -\xintNewExpr\myformI[2]{ {:xintRound{_1}{_2}} - {:xintTrunc{_1}{_2}} } -\xintNewExpr\myformJ[3]{ {:xintSgnFork{:xintSgn{_1}} - {\xinttheexpr _2 + _3\relax } - {\xinttheexpr _2 - _3\relax } - {\xinttheexpr _2 * _3\relax }} } -| - -\xintNewExpr\myformH[2]{ {:xintMax{_1}{_2}} } -\xintNewExpr\myformI[2]{ {:xintRound{_1}{_2}} - {:xintTrunc{_1}{_2}} } -\xintNewExpr\myformJ[3]{ {:xintSgnFork{:xintSgn{_1}} - {\xinttheexpr _2 + _3\relax } - {\xinttheexpr _2 - _3\relax } - {\xinttheexpr _2 * _3\relax }} } +\centeredline{|\xintNewExpr\Formula [3]|} +\centeredline{|{ if((#1>#2) & (#2>#3), + sqrt(#1-#2)*sqrt(#2-#3), #1^2+#3/#2) }|} \ttfamily -\noindent|\meaning\myformH:|\printnumber{\meaning\myformH}\endgraf -\noindent|\meaning\myformI:|\printnumber{\meaning\myformI}\endgraf -\noindent|\meaning\myformJ:|\printnumber{\meaning\myformJ}\endgraf +\noindent|\meaning\Formula:|\printnumber{\meaning\Formula}\endgraf + +\rmfamily +This formula (with |\xintifNotZero|) will gobble the false branch. + +Remark: this +|\XINTinFloatSqrt| macro is a non-user package macro used internally within +|\xintexpr|-essions, it produces the result in |A[n]| form rather +than in scientific notation, and for reasons of the inner workings of +|\xintexpr|-essions, this is necessary; of course a hand-made macro would +have used instead the equivalent |\xintFloatSqrt|. -% |\myformJ {-13}{100}{10}=|\myformJ {-13}{100}{10}, and -% |\myformJ {0}{100}{10}=|\myformJ {0}{100}{10}, and -% |\myformJ {3}{100}{10}=|\myformJ {3}{100}{10}\endgraf +Another example -% |\myformI {12}{1/123}=|\myformI {12}{1/123}, |\myformI {13}{1/123}=|\myformI -% {13}{1/123}, |\xintTrunc {15}{1/123}=|\xintTrunc {15}{1/123} +\xintNewExpr\myformula[3]{ ifsgn(#1,#2/#3,#2-#3,#2*#3) } +\centeredline{|\xintNewExpr\myformula [3]|} +\centeredline{|{ ifsgn(#1,#2/#3,#2-#3,#2*#3) }|} + +\ttfamily +\noindent\printnumber{\meaning\myformula}\endgraf \rmfamily +Again, this macro gobbles the false branches, as would have the operator |:| +inside an |\xintexpr|-ession. -One more example: -\dverb(& -\xintNewExpr\myfunction[1] - { {:xintSgnFork {:xintSgnFork {:xintGeq{_1}{1}} {}{0}{:xintSgn{_1}}} - {\xinttheexpr -_1 - 1 \relax } - {\xinttheexpr 1 - _1^2 \relax } - {\xinttheexpr _1 - 1 \relax }} } -( - -\xintNewExpr\myfunction[1] - { {:xintSgnFork {:xintSgnFork {:xintGeq{_1}{1}} {}{0}{:xintSgn{_1}}} - {\xinttheexpr -_1 - 1 \relax } - {\xinttheexpr 1 - _1^2 \relax } - {\xinttheexpr _1 - 1 \relax }} }% - -The principles were explained earlier: -\begin{enumerate} -\item parameters are denoted |_1|, |_2|, ... , |_9|, -\item anything which can not be immediately expanded, because the parameters - appear within, must be enclosed, together - with its arguments, in a brace pair (no need to add one if it already exists), -\item and the macros must be written with a |:| as control character, rather - than a |\|. This rule applies only to the macros involved in the previous - item. -\item Finally, if the infix operators |+|, |-|, |*|, |/|, |^| are to be used - inside macro arguments, this should be done within an |\xinttheexpr...\relax|; - but this rule applies in general also independently of the |\xintNewExpr| - context. -\end{enumerate} -The produced macro |\myfunction| turns out to have meaning in this last case: -\digitstt{\printnumber{\meaning\myfunction }} -The reason why these created macros are made to start with -|\romannumeral0\xintraw| is in order for them to expand in only two steps. Of -course in the last example their occurences in the three sub-branches is -redundant, but we had to use |\xinttheexpr| in each of the three sub-branch, -else the formal parsing done by |\xintNewExpr| would not have had a chance to -discover the binary infix operators and convert them to their macro form. +\subsubsection{Use of macros} -Things like a closing parenthesis only arising from the expansion of a macro -when the parser goes from left to right will be hard to make understandable to -\csb{xintNewExpr}, if the macro is to contain some of the parameters within its -arguments. -\dverb|& -\def\formula #1#2#3{\xinttheexpr #2\xintSgnFork{\xintSgn{#1}}+-*#3\relax } -| -is a perfectly valid macro definition, which will work to produce |#2+#3|, -|#2-#3|, or |#2*#3| depending on the sign of |#1|. But if we tried the -following: -\dverb|& -\xintNewExpr\formula[3]{_2{:xintSgnFork{:xintSgn{_1}}+-*}_3} -| -we would discover that it would not compile, despite seemingly following the -enunciated rules. I recall: -\begin{enumerate}\setcounter{enumi}{4} -\item braced material, if not an argument to a macro, should correspond to the - evaluation of a fraction, and in particular it can not be - used to produce an infix operator or an opening or closing - parenthesis, etc... -\end{enumerate} -This rule was mentioned in the description of \xintexprname{}-ession, -and it -has to be obeyed in the syntax of the expression argument to \csa{xintNewExpr}. -We could try then: -\dverb|& -\xintNewExpr\formula[3]{{_2:xintSgnFork{:xintSgn{_1}}+-*_3}} -| -This time, |\xintNewExpr| works but the produced |\formula| has meaning -\xintNewExpr\formula[3]{{_2:xintSgnFork{:xintSgn{_1}}+-*_3}}\endgraf -\noindent\digitstt{\printnumber{\meaning\formula}}\endgraf -Clearly this macro will not work. +For macros\MyMarginNote{Changed in |1.09a|!} to be inserted within such a created \xintname-formula command, there +are two cases: +\begin{itemize} +\item the macro does not involve the numbered parameters in its arguments: it + may then be left as is, and will be evaluated once during the construction of + the formula, +\item it does involve at least one of the parameters as argument. Then: + \begin{enumerate} + \item the whole thing (macro + argument) should be braced (not necessary if it + is already included into a braced group), + \item the macro should be coded with an underscore |_| in place of the + backslash |\|. + \item the parameters should be coded with a dollar sign |$1|, |$2|, etc... + \end{enumerate} +\end{itemize} + +Here is a silly example illustrating the general principle (the macros here have +equivalent functional forms which are more convenient; but some of the more +obscure package macros of \xintname dealing with integers do not have functions +pre-defined to be in correspondance with them): -We may try -\dverb|& -\xintNewExpr\formula[3]{{:xinttheexpr - _2:xintSgnFork{:xintSgn{_1}}+-*_3:relax}} -| -but this gives \xintNewExpr\formula[3]{{:xinttheexpr - _2:xintSgnFork{:xintSgn{_1}}+-*_3:relax}}\endgraf -\noindent\digitstt{\printnumber{\meaning\formula}} -and -there was no point whatsoever in it all, as what we want is to avoid the use of -|\xintexpr|\dots so we end up having to do: \dverb|& -\xintNewExpr\formula[3]{{:xintSgnFork{:xintSgn{_1}} - {\xinttheexpr _2+_3\relax} - {\xinttheexpr _2-_3\relax} - {\xinttheexpr _2*_3\relax}}} +\xintNewExpr\myformI[2]{ {_xintRound{$1}{$2}} - {_xintTrunc{$1}{$2}} } | -which is like what was done with |\myformJ|. -All of the previous examples may not be very convincing, because it is easier -for the user to define directly a macro with parameters not using |\xinttheexpr| -and achieving the wished-for computation, but |\xintNewExpr| would prove very -useful on more complicated cases with a high level of nesting of macros. +\xintNewExpr\myformI[2]{ {_xintRound{$1}{$2}} - {_xintTrunc{$1}{$2}} } +\ttfamily +\noindent|\meaning\myformI:|\printnumber{\meaning\myformI}\endgraf + +\rmfamily + +\subsection{\csbh{xintnumexpr}, + \csbh{xintthenumexpr}}\label{xintnumexpr}\label{xintthenumexpr} + +Equivalent to doing |\xintexpr round(...)\relax|. Thus, only the final result is +rounded to an integer. The rounding is towards $+\infty$ for positive numbers +and towards $-\infty$ for negative ones. \subsection{\csbh{xintfloatexpr}, \csbh{xintthefloatexpr}}\label{xintfloatexpr}\label{xintthefloatexpr} @@ -3855,7 +4324,7 @@ otherwise if one starts using the Power function. Then, |\xintthefloat| is often useful; and sometimes indispensable to achieve the (approximate) computation in reasonable time. -We can try some crazy things:\footnote{this evaluation takes a about a fifth of a second already on my laptop. Recall the constraints of expandability.} +We can try some crazy things: \centeredline{|\xintDigits:=12;\xintthefloatexpr 1.000000000000001^1e15\relax|} \centeredline{\xintDigits:=12;% \digitstt{\xintthefloatexpr 1.000000000000001^1e15\relax}} @@ -3892,21 +4361,20 @@ expression will have been evaluated with the then current setting for \subsection{Technicalities and experimental status} -As already mentioned \csa{xintNewExpr}|\myformula[n]| does not check the -prior existence of a macro |\myformula|. And the number of parameters |n| given -as mandatory argument withing square brackets should of course be at least equal -to the actual maximal index following an underscore in the expression. +As already mentioned \csa{xintNewExpr}|\myformula[n]| does not check the prior +existence of a macro |\myformula|. And the number of parameters |n| given as +mandatory argument withing square brackets should of course be (at least) equal +to the number of parameters in the expression. Obviously I should mention that \csa{xintNewExpr} itself can not be used in an expansion-only context, as it creates a macro. The format of the output of |\xintexpr|\meta{stuff}|\relax| is a |!| (with -catcode 11) followed by |\XINT_expr_illegaluse| which prints an error message in -the document and in the log file if it is executed, and next a token |\.A/B[n]| -(which is a single control sequence: these are the famous things which may -impact the hash-table). Using |\xinttheexpr| means zapping the first -two things, and opening up the third token to access its name and get the result -|A/B[n]| of the evaluation of the expression. +catcode 11) followed by |\XINT_expr_usethe| which prints an error message in +the document and in the log file if it is executed, then a token doing the +actual printing and finally a token |\.A/B[n]|. Using |\xinttheexpr| means +zapping the first two things, the third one will then recover |A/B[n]| from the +undefined control sequence |\.A/B[n]|. I decided to put all intermediate results (from each evaluation of an infix operators, or of a parenthesized subpart of the expression, or from application @@ -3917,16 +4385,24 @@ with undefined meaning), thus providing tremendous relief to the programmer in his/her expansion control. \begin{framed} - This implementation and user interface are currently to be considered - \emph{experimental}, they have not been yet extensively tested. Indeed the - additions brought to the \xintname bundle with release |1.07| are rather - extant and I just haven't had time to thoroughly validate them all. + This implementation and user interface are still to be considered + \emph{experimental}. \end{framed} -Some `error messages' will be issued by the scanner in case of problems, but -errors may also be issued from low-level \TeX{} processing, and are most of the -time unrecoverable. An attempt has been made to handle gracefully missing or -extraneous parentheses. +Syntax errors in the input like using a one-argument function such as |reduce| +with two will generate low-level \TeX{} processing unrecoverable errors, with +cryptic accompanying message. + +Some other problems will give rise to `error messages' macros giving some +indication on the location and nature of the problem. Mainly, an attempt has +been made to handle gracefully missing or extraneous parentheses. + +When the scanner is looking for a number and finds something else not otherwise +treated, it assumes it is the start of the function name and will expand forward +in the hope of hitting an opening parenthesis; if none is found at least it +should stop when encountering the |\relax| marking the end of the expressions. + +Note that |\relax| is absolutely mandatory (contrarily to a |\numexpr|). \subsection{Acknowledgements} @@ -4042,6 +4518,15 @@ returns zero. \centeredline{|\xintGCD{123456789012345}{9876543210321}=|\digitstt {\xintGCD{123456789012345}{9876543210321}}} +\subsection{\csbh{xintGCDof}}\label{xintGCDof} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintLCM}}\label{xintLCM} +{\small New with release |1.09a|.\par} + +\subsection{\csbh{xintLCMof}}\label{xintLCMof} +{\small New with release |1.09a|.\par} + \subsection{\csbh{xintBezout}}\label{xintBezout} \xintAssign{{\xintBezout {10000}{1113}}}\to\X @@ -4126,7 +4611,7 @@ entry, and then these four things at each step until the end. \catcode`\& 13 -\subsection{\csbh{xintTypesetEuclideAlgorithm}\allowbreak\null\hspace*{.25cm}}% +\subsection{\csbh{xintTypesetEuclideAlgorithm}\texorpdfstring{\allowbreak\null\hspace*{.25cm}}{}}% \label{xintTypesetEuclideAlgorithm} This macro is just an example of how to organize the data returned @@ -4157,7 +4642,7 @@ they may be count registers, etc... This package was first released with version |1.03| of the \xintname bundle. -% \clearpage +%% \clearpage \localtableofcontents @@ -5889,8 +6374,12 @@ first place. \makeatletter \StopEventually{\end{document}\endinput} -\makeatother +\def\storedlinecounts {} +\def\StoreCodelineNo #1{\edef\storedlinecounts{\storedlinecounts + {{#1}{\the\c@CodelineNo}}}\c@CodelineNo\z@ } + +\makeatother \newgeometry{hmarginratio=4:3,hscale=0.75} @@ -5908,6 +6397,13 @@ first place. % % The commenting of the macros is currently (\docdate) very sparse. % +% With release |1.09a| all macros doing arithmetic operations and a few more +% apply +% systematically |\xintnum| to their arguments; this adds a little overhead but +% this is +% more convenient for using count registers even with infix notation; also this +% is what |xintfrac.sty| did all along. Simplifies the discussion in the +% documentation too. % % \localtableofcontents % \subsection{Catcodes, \protect\eTeX{} and reload detection} @@ -5929,6 +6425,7 @@ first place. % Starting with version |1.06b| I decide that I suffer from an indigestion of @ % signs, so I replace them all with underscores |_|, \`a la \LaTeX 3. % +% % \begin{macrocode} \begingroup\catcode61\catcode48\catcode32=10\relax% \catcode13=5 % ^^M @@ -6049,7 +6546,7 @@ first place. \fi \expandafter\x\csname ver@xint.sty\endcsname \ProvidesPackage{xint}% - [2013/06/14 v1.08b Expandable operations on long numbers (jfB)]% + [2013/09/24 v1.09a Expandable operations on long numbers (jfB)]% % \end{macrocode} % \subsection{Token management, constants} % \begin{macrocode} @@ -6203,13 +6700,13 @@ first place. % \xintLen -> fait l'expansion, ne compte PAS le signe.$\ % \xintLength -> ne fait PAS l'expansion, compte le signe.$\ % 1.06: improved code is roughly 20$% faster than the one from earlier -% versions.| +% versions. 1.09a, \xintnum inserted| % \begin{macrocode} \def\xintiLen {\romannumeral0\xintilen }% \def\xintilen #1% {% \expandafter\XINT_length_fork - \romannumeral-`0#1\xint_relax\xint_relax\xint_relax\xint_relax + \romannumeral0\xintnum{#1}\xint_relax\xint_relax\xint_relax\xint_relax \xint_relax\xint_relax\xint_relax\xint_relax\Z }% \let\xintLen\xintiLen \let\xintlen\xintilen @@ -6262,8 +6759,10 @@ first place. % \end{macrocode} % \subsection{\csh{xintCSVtoList}} % \lverb|& -% \xintCSVtoList {a,b,..,z} returns {a}{b}...{z}. The comma separated list may -% be a macro which is first expanded. Each chain of spaces from the initial +% \xintCSVtoList transforms a,b,..,z into {a}{b}...{z}. The comma separated list +% may +% be a macro which is first expanded (protect the first item with a space if it +% is not to be expanded). Each chain of spaces from the initial % input will be collapsed as usual by the TeX initial scanning % First included in release 1.06.| % \begin{macrocode} @@ -6320,7 +6819,7 @@ first place. % \end{macrocode} % \subsection{\csh{xintListWithSep}} % \lverb|& -% \xintListWithSep {sep}{{a}{b}...{z}} returns a sep b sep .... sep z$\ +% \xintListWithSep {\sep}{{a}{b}...{z}} returns a \sep b \sep .... \sep z$\ % Included in release 1.04. The 'sep' can be \par's: the macro % xintlistwithsep etc... are all declared long. 'sep' does not have to be a % single token. The list may be a macro it is first expanded. @@ -6408,8 +6907,8 @@ first place. % \subsection{\csh{xintApply}} % \lverb|& % \xintApply {\macro}{{a}{b}...{z}} returns {\macro{a}}...{\macro{b}} -% where each instance of \macro is expanded. The list is first -% expanded. Introduced with release 1.04| +% where each instance of \macro is fully expanded. The list is first +% expanded and may thus be a macro. Introduced with release 1.04.| % \begin{macrocode} \def\xintApply {\romannumeral0\xintapply }% \def\xintApplyNoExpand {\romannumeral0\xintapplynoexpand }% @@ -6432,10 +6931,13 @@ first place. % \end{macrocode} % \subsection{\csh{xintApplyUnbraced}} % \lverb|& -% \xintApplyUnbraced {\macro}{{a}{b}...{z}} returns \macro{a}...\macro{b} -% where each instance of \macro is expanded using \romannumeral-`0. No braces +% \xintApplyUnbraced {\macro}{{a}{b}...{z}} returns \macro{a}...\macro{z} +% where each instance of \macro is expanded using \romannumeral-`0. The second +% argument may be a macro as it is first expanded itself (fully). No braces % are added: this allows for example a non-expandable \def in \macro, without -% having to do \gdef. The list is first expanded. Introduced with release 1.06b| +% having to do \gdef. The list is first expanded. Introduced with release 1.06b. +% Define \macro to start with a space if it is not expandable or its execution +% should be delayed only when all of \macro{a}...\macro{z} is ready. | % \begin{macrocode} \def\xintApplyUnbraced {\romannumeral0\xintapplyunbraced }% \def\xintApplyUnbracedNoExpand {\romannumeral0\xintapplyunbracednoexpand }% @@ -6457,7 +6959,30 @@ first place. \def\XINT_applyunbr_end\Z \expandafter\XINT_applyunbr_loop_b\expandafter #1#2#3{ #2}% % \end{macrocode} -% +% \subsection{\csh{xintApplyInline}} +% \lverb|& +% \xintApplyInline\macro{{a}{b}...{z}} has the same effect as executing +% \macro{a} and then applying again \xintApplyInline to the shortened list +% {{b}...{z}} until +% nothing is left. This is a non-expandable command which will result in +% more efficient code than using +% \xintApplyUnbraced. It uses a \futurelet and a \def and its endoflist marker +% is the catcode 11 colon. Expands (fully, not completely) its second argument +% first, which may thus be +% a macro.| +% \begin{macrocode} +\def\xintApplyInline #1#2% +{% + \def\XINT_apply_themacro {#1}% + \expandafter\XINT_applyinline_a\romannumeral-`0#2:% +}% +\def\XINT_applyinline_a {\futurelet\XINT_apply_nexttoken\XINT_applyinline_b }% +\def\XINT_applyinline_b #1% +{% + \ifx\XINT_apply_nexttoken :\expandafter\xint_gobble_iii\fi + \XINT_apply_themacro {#1}\XINT_applyinline_a +}% +% \end{macrocode} % \subsection{\csh{xintAssign},~\csh{xintAssignArray},~\csh{xintDigitsOf}} % \lverb|& % \xintAssign {a}{b}..{z}\to\A\B...\Z,$\ @@ -6465,16 +6990,14 @@ first place. % % version 1.01 corrects an oversight in 1.0 related to the value of % \escapechar at the time of using \xintAssignArray or \xintRelaxArray -% These macros are an exception in the xint bundle, they do not care at -% all about compatibility with expansion-only contexts. +% These macros are non-expandable. % % In version 1.05a I suddenly see some incongruous \expandafter's in (what is % called now) \XINT_assignarray_end_c, which I remove. % % Release 1.06 modifies the macros created by \xintAssignArray to feed their -% argument to a \numexpr. -% -% Release 1.06a detects an incredible typo in 1.01, (bad copy-paste from +% argument to a \numexpr. Release 1.06a detects an incredible typo in 1.01, (bad +% copy-paste from % \xintRelaxArray) which caused \xintAssignArray to use #1 rather than the #2 as % in the correct earlier 1.0 version!!! This went through undetected because % \xint_arrayname, although weird, was still usable: the probability to @@ -6739,10 +7262,14 @@ first place. \def\XINT_cuz_stop #1\W #2\Z{ #1}% \def\xint_cuz_backtoloop 0\XINT_cuz_stop 0{\XINT_cuz_loop }% % \end{macrocode} -% \subsection{\csh{XINT\_isOne}} +% \subsection{\csh{xintIsOne}} % \lverb|& -% Added in 1.03. Attention: does not do any expansion.| +% Added in 1.03. Attention: \XINT_isOne does not do any expansion. Release 1.09a +% defines \xintIsOne which is more user-friendly. xintfrac will have its own +% version. | % \begin{macrocode} +\def\xintIsOne {\romannumeral0\xintisone }% +\def\xintisone #1{\expandafter\XINT_isone \romannumeral0\xintnum{#1}\W\Z }% \def\XINT_isOne #1{\romannumeral0\XINT_isone #1\W\Z }% \def\XINT_isone #1#2% {% @@ -6761,7 +7288,13 @@ first place. % For example \xintNum {----+-+++---+----000000000000003}$\ % 1.05 defines \xintiNum, which allows redefinition of \xintNum by xintfrac.sty % Slightly modified in 1.06b (\R->\xint_relax) to avoid initial re-scan of -% input stack (while still allowing empty #1)| +% input stack (while still allowing empty #1). In versions earlier than 1.09a +% it was entirely up to the user to apply \xintnum; starting with 1.09a +% arithmetic +% macros of xint.sty (like earlier already xintfrac.sty with its own \xintnum) +% make use of \xintnum. This allows arguments to +% be count registers, or even \numexpr arbitrary long expressions (with the +% trick of braces, see the user documentation).| % \begin{macrocode} \def\xintiNum {\romannumeral0\xintinum }% \def\xintinum #1% @@ -6805,14 +7338,18 @@ first place. % \end{macrocode} % \subsection{\csh{xintSgn}} % \lverb|& -% Changed in 1.05. Earlier code was unnecessarily strange.| +% Changed in 1.05. Earlier code was unnecessarily strange. 1.09a with \xintnum| % \begin{macrocode} \def\xintiSgn {\romannumeral0\xintisgn }% \def\xintisgn #1% {% \expandafter\XINT_sgn \romannumeral-`0#1\Z% }% -\let\xintSgn\xintiSgn \let\xintsgn\xintisgn +\def\xintSgn {\romannumeral0\xintsgn }% +\def\xintsgn #1% +{% + \expandafter\XINT_sgn \romannumeral0\xintnum{#1}\Z% +}% \def\XINT_Sgn #1{\romannumeral0\XINT_sgn #1\Z }% \def\XINT_sgn #1#2\Z {% @@ -6825,9 +7362,9 @@ first place. % \end{macrocode} % \subsection{\csh{xintSgnFork}} % \lverb|& -% Expandable three-way fork added in 1.07. It is not used in the code but is -% provided for use inside the arguments to the package macros. The argument #1 -% must expand to -1,0 or 1. A \count should be put within a \numexpr..\relax.| +% Expandable three-way fork added in 1.07. The argument #1 +% must expand to -1,0 or 1. A \count should be put within a \numexpr..\relax. +% No space allowed between the condition and the branches! | % \begin{macrocode} \def\xintSgnFork {\romannumeral0\xintsgnfork }% \def\xintsgnfork #1% @@ -6838,12 +7375,100 @@ first place. \fi }% % \end{macrocode} +% \subsection{\csh{xintifSgn}} +% \lverb|& +% Expandable three-way fork added in 1.09a. Branches expandably depending on +% whether if <0, =0, >0. No space between condition and branches!. The use of +% \romannumeral0\xintsgn rather than \xintSgn is related to the (partial) +% acceptability of the ternary operator : in \xintNewExpr | +% \begin{macrocode} +\def\xintifSgn {\romannumeral0\xintifsgn }% +\def\xintifsgn #1% +{% + \ifcase \romannumeral0\xintsgn{#1} + \xint_afterfi{\expandafter\space\xint_secondofthree}% + \or\xint_afterfi{\expandafter\space\xint_thirdofthree}% + \else\xint_afterfi{\expandafter\space\xint_firstofthree}% + \fi +}% +% \end{macrocode} +% \subsection{\csh{xintifZero},~\csh{xintifNotZero}} +% \lverb|& +% Expandable two-way fork added in 1.09a. Branches expandably depending on +% whether the argument is zero (branch A) or not (branch B). No space allowed +% between +% condition and branches!| +% \begin{macrocode} +\def\xintifZero {\romannumeral0\xintifzero }% +\def\xintifzero #1% +{% + \if\xintSgn{\xintAbs{#1}}0% + \xint_afterfi{\expandafter\space\xint_firstoftwo}% + \else + \xint_afterfi{\expandafter\space\xint_secondoftwo}% + \fi +}% +\def\xintifNotZero {\romannumeral0\xintifnotzero }% +\def\xintifnotzero #1% +{% + \if\xintSgn{\xintAbs{#1}}1% + \xint_afterfi{\expandafter\space\xint_firstoftwo}% + \else + \xint_afterfi{\expandafter\space\xint_secondoftwo}% + \fi +}% +% \end{macrocode} +% \subsection{\csh{xintifEq}} +% \lverb|& +% \xintifEq {n}{m}{YES if n=m}{NO if n<>m}. No space before branches!| +% \begin{macrocode} +\def\xintifEq {\romannumeral0\xintifeq }% +\def\xintifeq #1#2% +{% + \if\xintCmp{#1}{#2}0% + \xint_afterfi{\expandafter\space\xint_firstoftwo}% + \else\xint_afterfi{\expandafter\space\xint_secondoftwo}% + \fi +}% +% \end{macrocode} +% \subsection{\csh{xintifGt}} +% \lverb|& +% \xintifEq {n}{m}{YES if n>m}{NO if n<=m}.| +% \begin{macrocode} +\def\xintifGt {\romannumeral0\xintifgt }% +\def\xintifgt #1#2% +{% + \if\xintCmp{#1}{#2}1% + \xint_afterfi{\expandafter\space\xint_firstoftwo}% + \else\xint_afterfi{\expandafter\space\xint_secondoftwo}% + \fi +}% +% \end{macrocode} +% \subsection{\csh{xintifLt}} +% \lverb|& +% \xintifEq {n}{m}{YES if n<m}{NO if n>=m}.| +% \begin{macrocode} +\def\xintifLt {\romannumeral0\xintiflt }% +\def\xintiflt #1#2% +{% + \xintSgnFork{\xintCmp{#1}{#2}}% + {\expandafter\space\xint_firstoftwo}% + {\expandafter\space\xint_secondoftwo}% + {\expandafter\space\xint_secondoftwo}% +}% +% \end{macrocode} % \subsection{\csh{xintOpp}} +% \lverb|\xintnum added in 1.09a| % \begin{macrocode} +\def\xintiiOpp {\romannumeral0\xintiiopp }% +\def\xintiiopp #1% +{% + \expandafter\XINT_opp \romannumeral-`0#1% +}% \def\xintiOpp {\romannumeral0\xintiopp }% \def\xintiopp #1% {% - \expandafter\XINT_opp \romannumeral-`0#1% + \expandafter\XINT_opp \romannumeral0\xintnum{#1}% }% \let\xintOpp\xintiOpp \let\xintopp\xintiopp \def\XINT_Opp #1{\romannumeral0\XINT_opp #1}% @@ -6857,11 +7482,19 @@ first place. }% % \end{macrocode} % \subsection{\csh{xintAbs}} +% \lverb|Release 1.09a has now \xintiabs which does \xintnum (contrarily to some +% other i-macros, but similarly as \xintiAdd etc...) and this is +% inherited by DecSplit, by Sqr, and macros of xintgcd.sty.| % \begin{macrocode} +\def\xintiiAbs {\romannumeral0\xintiiabs }% +\def\xintiiabs #1% +{% + \expandafter\XINT_abs \romannumeral-`0#1% +}% \def\xintiAbs {\romannumeral0\xintiabs }% \def\xintiabs #1% {% - \expandafter\XINT_abs \romannumeral-`0#1% + \expandafter\XINT_abs \romannumeral0\xintnum{#1}% }% \let\xintAbs\xintiAbs \let\xintabs\xintiabs \def\XINT_Abs #1{\romannumeral0\XINT_abs #1}% @@ -7281,17 +7914,27 @@ first place. \def\xint_addp_Gz\W\XINT_addp_G #1#2{ #2}% % \end{macrocode} % \subsection{\csh{xintAdd}} +% \lverb|Release 1.09a has \xintnum added into \xintiAdd.| % \begin{macrocode} +\def\xintiiAdd {\romannumeral0\xintiiadd }% +\def\xintiiadd #1% +{% + \expandafter\xint_iiadd\expandafter{\romannumeral-`0#1}% +}% +\def\xint_iiadd #1#2% +{% + \expandafter\XINT_add_fork \romannumeral-`0#2\Z #1\Z +}% \def\xintiAdd {\romannumeral0\xintiadd }% \def\xintiadd #1% {% - \expandafter\xint_add\expandafter{\romannumeral-`0#1}% + \expandafter\xint_add\expandafter{\romannumeral0\xintnum{#1}}% }% -\let\xintAdd\xintiAdd \let\xintadd\xintiadd \def\xint_add #1#2% {% - \expandafter\XINT_add_fork \romannumeral-`0#2\Z #1\Z + \expandafter\XINT_add_fork \romannumeral0\xintnum{#2}\Z #1\Z }% +\let\xintAdd\xintiAdd \let\xintadd\xintiadd \def\XINT_Add #1#2{\romannumeral0\XINT_add_fork #2\Z #1\Z }% \def\XINT_add #1#2{\XINT_add_fork #2\Z #1\Z }% % \end{macrocode} @@ -7350,19 +7993,29 @@ first place. }% % \end{macrocode} % \subsection{\csh{xintSub}} +% \lverb|Release 1.09a has \xintnum added into \xintiSub.| % \begin{macrocode} +\def\xintiiSub {\romannumeral0\xintiisub }% +\def\xintiisub #1% +{% + \expandafter\xint_iisub\expandafter{\romannumeral-`0#1}% +}% +\def\xint_iisub #1#2% +{% + \expandafter\XINT_sub_fork \romannumeral-`0#2\Z #1\Z +}% \def\xintiSub {\romannumeral0\xintisub }% \def\xintisub #1% {% - \expandafter\xint_sub\expandafter{\romannumeral-`0#1}% + \expandafter\xint_sub\expandafter{\romannumeral0\xintnum{#1}}% }% -\let\xintSub\xintiSub \let\xintsub\xintisub \def\xint_sub #1#2% {% - \expandafter\XINT_sub_fork \romannumeral-`0#2\Z #1\Z + \expandafter\XINT_sub_fork \romannumeral0\xintnum{#2}\Z #1\Z }% \def\XINT_Sub #1#2{\romannumeral0\XINT_sub_fork #2\Z #1\Z }% \def\XINT_sub #1#2{\XINT_sub_fork #2\Z #1\Z }% +\let\xintSub\xintiSub \let\xintsub\xintisub % \end{macrocode} % \lverb|& % SOUSTRACTION @@ -7632,16 +8285,17 @@ first place. }% % \end{macrocode} % \subsection{\csh{xintCmp}} +% \lverb|Release 1.09a has \xintnum added into \xintiCmp.| % \begin{macrocode} \def\xintiCmp {\romannumeral0\xinticmp }% \def\xinticmp #1% {% - \expandafter\xint_cmp\expandafter{\romannumeral-`0#1}% + \expandafter\xint_cmp\expandafter{\romannumeral0\xintnum{#1}}% }% \let\xintCmp\xintiCmp \let\xintcmp\xinticmp \def\xint_cmp #1#2% {% - \expandafter\XINT_cmp_fork \romannumeral-`0#2\Z #1\Z + \expandafter\XINT_cmp_fork \romannumeral0\xintnum{#2}\Z #1\Z }% \def\XINT_Cmp #1#2{\romannumeral0\XINT_cmp_fork #2\Z #1\Z }% % \end{macrocode} @@ -7758,20 +8412,136 @@ first place. \def\xint_OneIfPositive_backtomain 0\XINT_OneIfPositive_finish 0% {\XINT_OneIfPositive_main }% % \end{macrocode} +% \subsection{\csh{xintEq},~\csh{xintGt},~\csh{xintLt}} +% \lverb|1.09a.| +% \begin{macrocode} +\def\xintEq {\romannumeral0\xinteq }% +\def\xinteq #1#2{\xintifeq{#1}{#2}{1}{0}}% +\def\xintGt {\romannumeral0\xintgt }% +\def\xintgt #1#2{\xintifgt{#1}{#2}{1}{0}}% +\def\xintLt {\romannumeral0\xintlt }% +\def\xintlt #1#2{\xintiflt{#1}{#2}{1}{0}}% +% \end{macrocode} +% \subsection{\csh{xintIsZero},~\csh{xintIsNotZero}} +% \lverb|1.09a.| +% \begin{macrocode} +\def\xintIsZero {\romannumeral0\xintiszero }% +\def\xintiszero #1{\xintifsgn {#1}{0}{1}{0}}% +\def\xintIsNotZero {\romannumeral0\xintisnotzero }% +\def\xintisnotzero #1{\xintifsgn {#1}{1}{0}{1}}% +% \end{macrocode} +% \subsection{\csh{xintAND},~\csh{xintOR},~\csh{xintXOR}} +% \lverb|1.09a.| +% \begin{macrocode} +\def\xintAND {\romannumeral0\xintand }% +\def\xintand #1#2{\xintifzero {#1}{0}{\xintifzero {#2}{0}{1}}}% +\def\xintOR {\romannumeral0\xintor }% +\def\xintor #1#2{\xintifzero {#1}{\xintifzero {#2}{0}{1}}{1}}% +\def\xintXOR {\romannumeral0\xintxor }% +\def\xintxor #1#2{\ifcase \numexpr\xintIsZero{#1}+\xintIsZero{#2}\relax + \xint_afterfi{ 0}% + \or\xint_afterfi{ 1}% + \else\xint_afterfi { 0}% + \fi }% +% \end{macrocode} +% \subsection{\csh{xintANDof}} +% \lverb|New with 1.09a. \xintANDof works with an empty list.| +% \begin{macrocode} +\def\xintANDof {\romannumeral0\xintandof }% +\def\xintandof #1{\expandafter\XINT_andof_a\romannumeral-`0#1\relax }% +\def\XINT_andof_a #1{\expandafter\XINT_andof_b\romannumeral-`0#1\Z }% +\def\XINT_andof_b #1% + {\xint_gob_til_relax #1\XINT_andof_e\relax\XINT_andof_c #1}% +\def\XINT_andof_c #1\Z + {\xintifZero{#1}{\XINT_andof_no}{\XINT_andof_a}}% +\def\XINT_andof_no #1\relax { 0}% +\def\XINT_andof_e #1\Z { 1}% +% \end{macrocode} +% \subsection{\csh{xintANDof:csv}} +% \lverb|1.09a. For use by \xintexpr.| +% \begin{macrocode} +\def\xintANDof:csv #1{\expandafter\XINT_andof:_a\romannumeral-`0#1,,^}% +\def\XINT_andof:_a {\expandafter\XINT_andof:_b\romannumeral-`0}% +\def\XINT_andof:_b #1{\if #1,\expandafter\XINT_andof:_e + \else\expandafter\XINT_andof:_c\fi #1}% +\def\XINT_andof:_c #1,{\xintifZero{#1}{\XINT_andof:_no}{\XINT_andof:_a}}% +\def\XINT_andof:_no #1^{0}% +\def\XINT_andof:_e #1^{1}% +% \end{macrocode} +% \subsection{\csh{xintORof}} +% \lverb|New with 1.09a. Works also with an empty list.| +% \begin{macrocode} +\def\xintORof {\romannumeral0\xintorof }% +\def\xintorof #1{\expandafter\XINT_orof_a\romannumeral-`0#1\relax }% +\def\XINT_orof_a #1{\expandafter\XINT_orof_b\romannumeral-`0#1\Z }% +\def\XINT_orof_b #1% + {\xint_gob_til_relax #1\XINT_orof_e\relax\XINT_orof_c #1}% +\def\XINT_orof_c #1\Z + {\xintifZero{#1}{\XINT_orof_a}{\XINT_orof_yes}}% +\def\XINT_orof_yes #1\relax { 1}% +\def\XINT_orof_e #1\Z { 0}% +% \end{macrocode} +% \subsection{\csh{xintORof:csv}} +% \lverb|1.09a. For use by \xintexpr.| +% \begin{macrocode} +\def\xintORof:csv #1{\expandafter\XINT_orof:_a\romannumeral-`0#1,,^}% +\def\XINT_orof:_a {\expandafter\XINT_orof:_b\romannumeral-`0}% +\def\XINT_orof:_b #1{\if #1,\expandafter\XINT_orof:_e + \else\expandafter\XINT_orof:_c\fi #1}% +\def\XINT_orof:_c #1,{\xintifZero{#1}{\XINT_orof:_a}{\XINT_orof:_yes}}% +\def\XINT_orof:_yes #1^{1}% +\def\XINT_orof:_e #1^{0}% +% \end{macrocode} +% \subsection{\csh{xintXORof}} +% \lverb|New with 1.09a. Works with an empty list, too.| +% \begin{macrocode} +\def\xintXORof {\romannumeral0\xintxorof }% +\def\xintxorof #1{\expandafter\XINT_xorof_a\expandafter + 0\romannumeral-`0#1\relax }% +\def\XINT_xorof_a #1#2{\expandafter\XINT_xorof_b\romannumeral-`0#2\Z #1}% +\def\XINT_xorof_b #1% + {\xint_gob_til_relax #1\XINT_xorof_e\relax\XINT_xorof_c #1}% +\def\XINT_xorof_c #1\Z #2% + {\xintifZero {#1}{\XINT_xorof_a #2}{\ifcase #2 + \xint_afterfi{\XINT_xorof_a 1}% + \else + \xint_afterfi{\XINT_xorof_a 0}% + \fi }% + }% +\def\XINT_xorof_e #1\Z #2{ #2}% +% \end{macrocode} +% \subsection{\csh{xintXORof:csv}} +% \lverb|1.09a. For use by \xintexpr.| +% \begin{macrocode} +\def\xintXORof:csv #1{\expandafter\XINT_xorof:_a\expandafter + 0\romannumeral-`0#1,,^}% +\def\XINT_xorof:_a #1#2,{\expandafter\XINT_xorof:_b\romannumeral-`0#2,#1}% +\def\XINT_xorof:_b #1{\if #1,\expandafter\XINT_xorof:_e + \else\expandafter\XINT_xorof:_c\fi #1}% +\def\XINT_xorof:_c #1,#2% + {\xintifZero {#1}{\XINT_xorof:_a #2}{\ifcase #2 + \xint_afterfi{\XINT_xorof:_a 1}% + \else + \xint_afterfi{\XINT_xorof:_a 0}% + \fi }% + }% +\def\XINT_xorof:_e ,#1#2^{#1}% allows empty list +% \end{macrocode} % \subsection{\csh{xintGeq}} -% \lverb|& +% \lverb|& +% Release 1.09a has \xintnum added into \xintiGeq. % PLUS GRAND OU ÉGAL % attention compare les **valeurs absolues**| % \begin{macrocode} \def\xintiGeq {\romannumeral0\xintigeq }% \def\xintigeq #1% {% - \expandafter\xint_geq\expandafter {\romannumeral-`0#1}% + \expandafter\xint_geq\expandafter {\romannumeral0\xintnum{#1}}% }% \let\xintGeq\xintiGeq \let\xintgeq\xintigeq \def\xint_geq #1#2% {% - \expandafter\XINT_geq_fork \romannumeral-`0#2\Z #1\Z + \expandafter\XINT_geq_fork \romannumeral0\xintnum{#2}\Z #1\Z }% \def\XINT_Geq #1#2{\romannumeral0\XINT_geq_fork #2\Z #1\Z }% % \end{macrocode} @@ -7859,17 +8629,18 @@ first place. % The rationale is that it is more efficient than using \xintCmp. % 1.03 makes the code a tiny bit slower but easier to re-use for fractions. % Note: actually since 1.08a code for fractions does not all reduce to these -% entry points, so perhaps I should revert the changes made in 1.03.| +% entry points, so perhaps I should revert the changes made in 1.03. Release +% 1.09a has \xintnum added into \xintiMax.| % \begin{macrocode} \def\xintiMax {\romannumeral0\xintimax }% \def\xintimax #1% {% - \expandafter\xint_max\expandafter {\romannumeral-`0#1}% + \expandafter\xint_max\expandafter {\romannumeral0\xintnum{#1}}% }% \let\xintMax\xintiMax \let\xintmax\xintimax \def\xint_max #1#2% {% - \expandafter\XINT_max_pre\expandafter {\romannumeral-`0#2}{#1}% + \expandafter\XINT_max_pre\expandafter {\romannumeral0\xintnum{#2}}{#1}% }% \def\XINT_max_pre #1#2{\XINT_max_fork #1\Z #2\Z {#2}{#1}}% \def\XINT_Max #1#2{\romannumeral0\XINT_max_fork #2\Z #1\Z {#1}{#2}}% @@ -7922,17 +8693,33 @@ first place. \fi }% % \end{macrocode} +% \subsection{\csh{xintMaxof}} +% \lverb|New with 1.09a|. +% \begin{macrocode} +\def\xintiMaxof {\romannumeral0\xintimaxof }% +\def\xintimaxof #1{\expandafter\XINT_imaxof_a\romannumeral-`0#1\relax }% +\def\XINT_imaxof_a #1{\expandafter\XINT_imaxof_b\romannumeral0\xintnum{#1}\Z }% +\def\XINT_imaxof_b #1\Z #2% + {\expandafter\XINT_imaxof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_imaxof_c #1% + {\xint_gob_til_relax #1\XINT_imaxof_e\relax\XINT_imaxof_d #1}% +\def\XINT_imaxof_d #1\Z + {\expandafter\XINT_imaxof_b\romannumeral0\xintimax {#1}}% +\def\XINT_imaxof_e #1\Z #2\Z { #2}% +\let\xintMaxof\xintiMaxof \let\xintmaxof\xintimaxof +% \end{macrocode} % \subsection{\csh{xintMin}} +% \lverb|\xintnum added New with 1.09a|. % \begin{macrocode} \def\xintiMin {\romannumeral0\xintimin }% \def\xintimin #1% {% - \expandafter\xint_min\expandafter {\romannumeral-`0#1}% + \expandafter\xint_min\expandafter {\romannumeral0\xintnum{#1}}% }% \let\xintMin\xintiMin \let\xintmin\xintimin \def\xint_min #1#2% {% - \expandafter\XINT_min_pre\expandafter {\romannumeral-`0#2}{#1}% + \expandafter\XINT_min_pre\expandafter {\romannumeral0\xintnum{#2}}{#1}% }% \def\XINT_min_pre #1#2{\XINT_min_fork #1\Z #2\Z {#2}{#1}}% \def\XINT_Min #1#2{\romannumeral0\XINT_min_fork #2\Z #1\Z {#1}{#2}}% @@ -7985,6 +8772,21 @@ first place. \fi }% % \end{macrocode} +% \subsection{\csh{xintMinof}} +% \lverb|1.09a| +% \begin{macrocode} +\def\xintiMinof {\romannumeral0\xintiminof }% +\def\xintiminof #1{\expandafter\XINT_iminof_a\romannumeral-`0#1\relax }% +\def\XINT_iminof_a #1{\expandafter\XINT_iminof_b\romannumeral0\xintnum{#1}\Z }% +\def\XINT_iminof_b #1\Z #2% + {\expandafter\XINT_iminof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_iminof_c #1% + {\xint_gob_til_relax #1\XINT_iminof_e\relax\XINT_iminof_d #1}% +\def\XINT_iminof_d #1\Z + {\expandafter\XINT_iminof_b\romannumeral0\xintimin {#1}}% +\def\XINT_iminof_e #1\Z #2\Z { #2}% +\let\xintMinof\xintiMinof \let\xintminof\xintiminof +% \end{macrocode} % \subsection{\csh{xintSum}, \csh{xintSumExpr}} % \lverb|& % \xintSum {{a}{b}...{z}}$\ @@ -7993,7 +8795,8 @@ first place. % computations). Also the way \xintSum and \xintSumExpr ...\relax are related. % has been modified. Now \xintSumExpr \z \relax is accepted input when % \z expands to a list of braced terms (prior only \xintSum {\z} or \xintSum \z -% was possible). | +% was possible). 1.09a does NOT add \xintnum (I would need for this to +% re-organize the code first). | % \begin{macrocode} \def\xintiSum {\romannumeral0\xintisum }% \def\xintisum #1{\xintisumexpr #1\relax }% @@ -8039,17 +8842,27 @@ first place. \def\XINT_sum_NN #1#2{\XINT_sum_loop {#2}{#1}}% % \end{macrocode} % \subsection{\csh{xintMul}} +% \lverb|1.09a adds \xintnum| % \begin{macrocode} +\def\xintiiMul {\romannumeral0\xintiimul }% +\def\xintiimul #1% +{% + \expandafter\xint_iimul\expandafter {\romannumeral-`0#1}% +}% +\def\xint_iimul #1#2% +{% + \expandafter\XINT_mul_fork \romannumeral-`0#2\Z #1\Z +}% \def\xintiMul {\romannumeral0\xintimul }% \def\xintimul #1% {% - \expandafter\xint_mul\expandafter {\romannumeral-`0#1}% + \expandafter\xint_mul\expandafter {\romannumeral0\xintnum{#1}}% }% -\let\xintMul\xintiMul \let\xintmul\xintimul \def\xint_mul #1#2% {% - \expandafter\XINT_mul_fork \romannumeral-`0#2\Z #1\Z + \expandafter\XINT_mul_fork \romannumeral0\xintnum{#2}\Z #1\Z }% +\let\xintMul\xintiMul \let\xintmul\xintimul \def\XINT_Mul #1#2{\romannumeral0\XINT_mul_fork #2\Z #1\Z }% % \end{macrocode} % \lverb|& @@ -8494,6 +9307,11 @@ first place. % \end{macrocode} % \subsection{\csh{xintSqr}} % \begin{macrocode} +\def\xintiiSqr {\romannumeral0\xintiisqr }% +\def\xintiisqr #1% +{% + \expandafter\XINT_sqr\expandafter {\romannumeral0\xintiiabs{#1}}% +}% \def\xintiSqr {\romannumeral0\xintisqr }% \def\xintisqr #1% {% @@ -8565,14 +9383,18 @@ first place. % With release 1.05, rather than using \XINT_Length I opt finally for direct use % of \numexpr (which will throw a suitable number too big message), and to raise % the \xintError:$\ FactorialOfTooBigNumber for argument larger than 1000000 -% (rather than 1000000000).| +% (rather than 1000000000). With 1.09a, \xintFac uses \xintnum.| % \begin{macrocode} \def\xintiFac {\romannumeral0\xintifac }% \def\xintifac #1% {% \expandafter\XINT_fac_fork\expandafter{\the\numexpr #1}% }% -\let\xintFac\xintiFac \let\xintfac\xintifac +\def\xintFac {\romannumeral0\xintfac }% +\def\xintfac #1% +{% + \expandafter\XINT_fac_fork\expandafter{\romannumeral0\xintnum{#1}}% +}% \def\XINT_fac_fork #1% {% \ifcase\XINT_Sgn {#1} @@ -8659,12 +9481,12 @@ first place. % adapted for computing powers. Then I moved in 1.03 the special variants of % multiplication (hence of addition) which were needed to earlier in this file. % Modified in 1.06, the exponent is given to a \numexpr rather than twice -% expanded. | +% expanded. \xintnum added in 1.09a.| % \begin{macrocode} \def\xintiPow {\romannumeral0\xintipow }% \def\xintipow #1% {% - \expandafter\xint_pow\romannumeral-`0#1\Z% + \expandafter\xint_pow\romannumeral0\xintnum{#1}\Z% }% \let\xintPow\xintiPow \let\xintpow\xintipow \def\xint_pow #1#2\Z @@ -8770,7 +9592,7 @@ first place. \xint_afterfi{\expandafter\XINT_pow_loop_a \expandafter{\the\numexpr 2*(#1/2)-#1\expandafter }% b mod 2 \expandafter{\the\numexpr #1-#1/2\expandafter }% [b/2] - \expandafter{\romannumeral0\xintisqr{#2}}}% + \expandafter{\romannumeral0\xintiisqr{#2}}}% \fi {{#2}}% }% @@ -8833,6 +9655,7 @@ first place. }% % \end{macrocode} % \subsection{\csh{xintDivision}, \csh{xintQuo}, \csh{xintRem}} +% \lverb|1.09a inserts the use of \xintnum| % \begin{macrocode} \def\xintiQuo {\romannumeral0\xintiquo }% \def\xintiRem {\romannumeral0\xintirem }% @@ -8850,12 +9673,12 @@ first place. \def\xintiDivision {\romannumeral0\xintidivision }% \def\xintidivision #1% {% - \expandafter\xint_division\expandafter {\romannumeral-`0#1}% + \expandafter\xint_division\expandafter {\romannumeral0\xintnum{#1}}% }% \let\xintDivision\xintiDivision \let\xintdivision\xintidivision \def\xint_division #1#2% {% - \expandafter\XINT_div_fork \romannumeral-`0#2\Z #1\Z + \expandafter\XINT_div_fork \romannumeral0\xintnum{#2}\Z #1\Z }% \def\XINT_Division #1#2{\romannumeral0\XINT_div_fork #2\Z #1\Z }% % \end{macrocode} @@ -8941,7 +9764,7 @@ first place. \def\XINT_div_AisNegative_posrem #1% {% \expandafter \XINT_div_AisNegative_posrem_b \expandafter - {\romannumeral0\xintiopp{\xintInc {#1}}}% + {\romannumeral0\xintiiopp{\xintInc {#1}}}% }% \def\XINT_div_AisNegative_posrem_b #1#2#3% {% @@ -9171,14 +9994,14 @@ first place. \def\XINT_div_final_dP #1#2#3#4#5% q,A,Q,L,B (puis c) {% \expandafter \XINT_div_final_f \expandafter - {\romannumeral0\xintisub {#2}% + {\romannumeral0\xintiisub {#2}% {\romannumeral0\XINT_mul_M {#1}#5\Z\Z\Z\Z }}% {\romannumeral0\XINT_add_A 0{}#1000\W\X\Y\Z #3\W\X\Y\Z }% }% \def\XINT_div_final_db #1#2#3#4#5% q,A,Q,L,B (puis c) {% \expandafter\XINT_div_final_dc\expandafter - {\romannumeral0\xintisub {#2}% + {\romannumeral0\xintiisub {#2}% {\romannumeral0\XINT_mul_M {#1}#5\Z\Z\Z\Z }}% {#1}{#2}{#3}{#4}{#5}% }% @@ -9513,14 +10336,19 @@ first place. % \subsection{\csh{xintFDg}} % \lverb|& % FIRST DIGIT. Code simplified in 1.05. -% And prepared for redefinition by xintfrac to parse through \xintNum| +% And prepared for redefinition by xintfrac to parse through \xintNum. Version +% 1.09a inserts the \xintnum here.| % \begin{macrocode} \def\xintiFDg {\romannumeral0\xintifdg }% \def\xintifdg #1% {% \expandafter\XINT_fdg \romannumeral-`0#1\W\Z }% -\let\xintFDg\xintiFDg \let\xintfdg\xintifdg +\def\xintFDg {\romannumeral0\xintfdg }% +\def\xintfdg #1% +{% + \expandafter\XINT_fdg \romannumeral0\xintnum{#1}\W\Z +}% \def\XINT_FDg #1{\romannumeral0\XINT_fdg #1\W\Z }% \def\XINT_fdg #1#2#3\Z {% @@ -9534,14 +10362,18 @@ first place. % \subsection{\csh{xintLDg}} % \lverb|& % LAST DIGIT. Simplified in 1.05. And prepared for extension by xintfrac -% to parse through \xintNum| +% to parse through \xintNum. 1.09a has it here.| % \begin{macrocode} \def\xintiLDg {\romannumeral0\xintildg }% \def\xintildg #1% {% \expandafter\XINT_ldg\expandafter {\romannumeral-`0#1}% }% -\let\xintLDg\xintiLDg \let\xintldg\xintildg +\def\xintLDg {\romannumeral0\xintldg }% +\def\xintldg #1% +{% + \expandafter\XINT_ldg\expandafter {\romannumeral0\xintnum{#1}}% +}% \def\XINT_LDg #1{\romannumeral0\XINT_ldg {#1}}% \def\XINT_ldg #1% {% @@ -9571,8 +10403,24 @@ first place. \xint_afterfi{ -1}% \fi }% -\let\xintMON\xintiMON \let\xintmon\xintimon -\let\xintMMON\xintiMMON \let\xintmmon\xintimmon +\def\xintMON {\romannumeral0\xintmon }% +\def\xintmon #1% +{% + \ifodd\xintLDg {#1} + \xint_afterfi{ -1}% + \else + \xint_afterfi{ 1}% + \fi +}% +\def\xintMMON {\romannumeral0\xintmmon }% +\def\xintmmon #1% +{% + \ifodd\xintLDg {#1} + \xint_afterfi{ 1}% + \else + \xint_afterfi{ -1}% + \fi +}% % \end{macrocode} % \subsection{\csh{xintOdd}} % \lverb|& @@ -9596,7 +10444,15 @@ first place. \xint_afterfi{ 0}% \fi }% -\let\xintOdd\xintiOdd \let\xintodd\xintiodd +\def\xintOdd {\romannumeral0\xintodd }% +\def\xintodd #1% +{% + \ifodd\xintLDg{#1} + \xint_afterfi{ 1}% + \else + \xint_afterfi{ 0}% + \fi +}% % \end{macrocode} % \subsection{\csh{xintDSL}} % \lverb|& @@ -10013,7 +10869,7 @@ first place. { {}{#2}}% % \end{macrocode} % \subsection{\csh{xintDouble}} -% \lverb!v1.08! +% \lverb|v1.08| % \begin{macrocode} \def\xintDouble {\romannumeral0\xintdouble }% \def\xintdouble #1% @@ -10201,7 +11057,7 @@ first place. \def\XINT_inc_end\W #1\relax #2{ 1#2}% % \end{macrocode} % \subsection{\csh{xintiSqrt}, \csh{xintiSquareRoot}} -% \lverb!v1.08! +% \lverb!v1.08. 1.09a uses \xintnum! % \begin{macrocode} \def\XINT_dsx_addzerosnofuss #1{\XINT_dsx_zeroloop {#1}{}\Z }% \def\xintiSqrt {\romannumeral0\xintisqrt }% @@ -10211,7 +11067,7 @@ first place. \W\W\W\W\W\W\W\W }% \def\xintiSquareRoot {\romannumeral0\xintisquareroot }% \def\xintisquareroot #1% - {\expandafter\XINT_sqrt_checkin\romannumeral-`0#1\Z}% + {\expandafter\XINT_sqrt_checkin\romannumeral0\xintnum{#1}\Z}% \def\XINT_sqrt_checkin #1% {% \xint_UDzerominusfork @@ -10365,13 +11221,13 @@ first place. {% \expandafter\XINT_sqrt_big_f_a\expandafter {\the\numexpr #2+#3\expandafter}\expandafter - {\romannumeral-`0\XINT_dsx_addzerosnofuss + {\romannumeral0\XINT_dsx_addzerosnofuss {\numexpr #4-\xint_c_iv\relax}{#1}}{#4}% }% \def\XINT_sqrt_big_f_a #1#2#3#4% {% \expandafter\XINT_sqrt_big_g\expandafter - {\romannumeral0\xintisub + {\romannumeral0\xintiisub {\XINT_dsx_addzerosnofuss {\numexpr \xint_c_ii*#3-\xint_c_viii\relax}{#1}}{#4}}% {#2}{#3}% @@ -10392,8 +11248,8 @@ first place. \def\XINT_sqrt_big_k #1#2#3% {% \expandafter\XINT_sqrt_big_l\expandafter - {\romannumeral0\xintisub {#3}{#1}}% - {\romannumeral0\xintiadd {#2}{\xintiSqr {#1}}}% + {\romannumeral0\xintiisub {#3}{#1}}% + {\romannumeral0\xintiiadd {#2}{\xintiiSqr {#1}}}% }% \def\XINT_sqrt_big_l #1#2% {% @@ -10408,10 +11264,13 @@ first place. %\def<*xintbinhex>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12 } %</xint> %<*xintbinhex> +% +% \StoreCodelineNo {xint} +% % \section{Package \xintbinhexname implementation} % % The commenting is currently (\docdate) very sparse. -% +% % \localtableofcontents % \subsection{Catcodes, \protect\eTeX{} and reload detection} % @@ -10574,7 +11433,7 @@ first place. \fi \expandafter\x\csname ver@xintbinhex.sty\endcsname \ProvidesPackage{xintbinhex}% - [2013/06/14 v1.08b Expandable binary and hexadecimal conversions (jfB)]% + [2013/09/24 v1.09a Expandable binary and hexadecimal conversions (jfB)]% % \end{macrocode} % \subsection{Constants, etc...} % \lverb!v1.08! @@ -10593,14 +11452,14 @@ first place. \expandafter\edef\csname XINT_sdth_#1\endcsname {\ifcase #1 0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or 8\or 9\or A\or B\or C\or D\or E\or F\fi}}% -\xintApplyUnbraced\XINT_tmp_def +\xintApplyInline\XINT_tmp_def {{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}}% \def\XINT_tmp_def #1{% \expandafter\edef\csname XINT_sdtb_#1\endcsname {\ifcase #1 0000\or 0001\or 0010\or 0011\or 0100\or 0101\or 0110\or 0111\or 1000\or 1001\or 1010\or 1011\or 1100\or 1101\or 1110\or 1111\fi}}% -\xintApplyUnbraced\XINT_tmp_def +\xintApplyInline\XINT_tmp_def {{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}}% \let\XINT_tmp_def\empty \expandafter\def\csname XINT_sbtd_0000\endcsname {0}% @@ -11172,6 +12031,9 @@ first place. %\def<*xintgcd>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12 } %</xintbinhex> %<*xintgcd> +% +% \StoreCodelineNo {xintbinhex} +% % \section{Package \xintgcdname implementation} % % The commenting is currently (\docdate) very sparse. @@ -11340,9 +12202,13 @@ first place. \fi \expandafter\x\csname ver@xintgcd.sty\endcsname \ProvidesPackage{xintgcd}% - [2013/06/14 v1.08b Euclide algorithm with xint package (jfB)]% + [2013/09/24 v1.09a Euclide algorithm with xint package (jfB)]% % \end{macrocode} % \subsection{\csh{xintGCD}} +% The macros of |1.09a| benefits from the |\xintnum| which has been inserted +% inside |\xintiabs| in \xintname; +% this is a little overhead but is more convenient for the +% user and also makes it easier to use into |\xintexpr|essions. % \begin{macrocode} \def\xintGCD {\romannumeral0\xintgcd }% \def\xintgcd #1% @@ -11385,16 +12251,87 @@ first place. {#1}% }% % \end{macrocode} +% \subsection{\csh{xintGCDof}} +% \lverb|New with 1.09a. I also tried an optimization (not working two by two) +% which I thought was clever but +% it seemed to be less efficient ...| +% \begin{macrocode} +\def\xintGCDof {\romannumeral0\xintgcdof }% +\def\xintgcdof #1{\expandafter\XINT_gcdof_a\romannumeral-`0#1\relax }% +\def\XINT_gcdof_a #1{\expandafter\XINT_gcdof_b\romannumeral-`0#1\Z }% +\def\XINT_gcdof_b #1\Z #2{\expandafter\XINT_gcdof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_gcdof_c #1{\xint_gob_til_relax #1\XINT_gcdof_e\relax\XINT_gcdof_d #1}% +\def\XINT_gcdof_d #1\Z {\expandafter\XINT_gcdof_b\romannumeral0\xintgcd {#1}}% +\def\XINT_gcdof_e #1\Z #2\Z { #2}% +% \end{macrocode} +% \subsection{\csh{xintGCDof:csv}} +% \lverb|1.09a. For use by \xintexpr.| +% \begin{macrocode} +\def\xintGCDof:csv #1{\expandafter\XINT_gcdof:_b\romannumeral-`0#1,,}% +\def\XINT_gcdof:_b #1,#2,{\expandafter\XINT_gcdof:_c\romannumeral-`0#2,{#1},}% +\def\XINT_gcdof:_c #1{\if #1,\expandafter\XINT_gcdof:_e + \else\expandafter\XINT_gcdof:_d\fi #1}% +\def\XINT_gcdof:_d #1,{\expandafter\XINT_gcdof:_b\romannumeral0\xintgcd {#1}}% +\def\XINT_gcdof:_e ,#1,{#1}% +% \end{macrocode} +% \subsection{\csh{xintLCM}} +% \lverb|New with 1.09a| +% \begin{macrocode} +\def\xintLCM {\romannumeral0\xintlcm}% +\def\xintlcm #1% +{% + \expandafter\XINT_lcm\expandafter{\romannumeral0\xintiabs {#1}}% +}% +\def\XINT_lcm #1#2% +{% + \expandafter\XINT_lcm_fork\romannumeral0\xintiabs {#2}\Z #1\Z +}% +\def\XINT_lcm_fork #1#2\Z #3#4\Z +{% + \xint_UDzerofork + #1\dummy \XINT_lcm_BisZero + #3\dummy \XINT_lcm_AisZero + 0\dummy \expandafter + \krof + \XINT_lcm_notzero\expandafter{\romannumeral0\XINT_gcd_loop {#1#2}{#3#4}}% + {#1#2}{#3#4}% +}% +\def\XINT_lcm_AisZero #1#2#3#4#5{ 0}% +\def\XINT_lcm_BisZero #1#2#3#4#5{ 0}% +\def\XINT_lcm_notzero #1#2#3{\xintiimul {#2}{\xintQuo{#3}{#1}}}% +% \end{macrocode} +% \subsection{\csh{xintLCMof}} +% \lverb|New with 1.09a| +% \begin{macrocode} +\def\xintLCMof {\romannumeral0\xintlcmof }% +\def\xintlcmof #1{\expandafter\XINT_lcmof_a\romannumeral-`0#1\relax }% +\def\XINT_lcmof_a #1{\expandafter\XINT_lcmof_b\romannumeral-`0#1\Z }% +\def\XINT_lcmof_b #1\Z #2{\expandafter\XINT_lcmof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_lcmof_c #1{\xint_gob_til_relax #1\XINT_lcmof_e\relax\XINT_lcmof_d #1}% +\def\XINT_lcmof_d #1\Z {\expandafter\XINT_lcmof_b\romannumeral0\xintlcm {#1}}% +\def\XINT_lcmof_e #1\Z #2\Z { #2}% +% \end{macrocode} +% \subsection{\csh{xintLCMof:csv}} +% \lverb|1.09a. For use by \xintexpr.| +% \begin{macrocode} +\def\xintLCMof:csv #1{\expandafter\XINT_lcmof:_a\romannumeral-`0#1,,}% +\def\XINT_lcmof:_a #1,#2,{\expandafter\XINT_lcmof:_c\romannumeral-`0#2,{#1},}% +\def\XINT_lcmof:_c #1{\if#1,\expandafter\XINT_lcmof:_e + \else\expandafter\XINT_lcmof:_d\fi #1}% +\def\XINT_lcmof:_d #1,{\expandafter\XINT_lcmof:_a\romannumeral0\xintlcm {#1}}% +\def\XINT_lcmof:_e ,#1,{#1}% +% \end{macrocode} % \subsection{\csh{xintBezout}} +% \lverb|1.09a inserts use of \xintnum| % \begin{macrocode} \def\xintBezout {\romannumeral0\xintbezout }% \def\xintbezout #1% {% - \expandafter\xint_bezout\expandafter {\romannumeral-`0#1}% + \expandafter\xint_bezout\expandafter {\romannumeral0\xintnum{#1}}% }% \def\xint_bezout #1#2% {% - \expandafter\XINT_bezout_fork \romannumeral-`0#2\Z #1\Z + \expandafter\XINT_bezout_fork \romannumeral0\xintnum{#2}\Z #1\Z }% % \end{macrocode} % \lverb|#3#4 = A, #1#2=B| @@ -11453,7 +12390,7 @@ first place. \def\XINT_bezout_mm_post #1#2% {% \expandafter\XINT_bezout_mm_postb\expandafter - {\romannumeral0\xintiopp{#2}}{\romannumeral0\xintiopp{#1}}% + {\romannumeral0\xintiiopp{#2}}{\romannumeral0\xintiiopp{#1}}% }% \def\XINT_bezout_mm_postb #1#2% {% @@ -11474,7 +12411,7 @@ first place. \def\XINT_bezout_mp_post #1#2% {% \expandafter\XINT_bezout_mp_postb\expandafter - {\romannumeral0\xintiopp {#2}}{#1}% + {\romannumeral0\xintiiopp {#2}}{#1}% }% \def\XINT_bezout_mp_postb #1#2#3#4#5% {% @@ -11536,8 +12473,8 @@ first place. \def\XINT_bezout_loop_b #1#2#3#4#5#6#7#8% {% \expandafter \XINT_bezout_loop_c \expandafter - {\romannumeral0\xintiadd{\XINT_Mul{#5}{#2}}{#7}}% - {\romannumeral0\xintiadd{\XINT_Mul{#6}{#2}}{#8}}% + {\romannumeral0\xintiiadd{\XINT_Mul{#5}{#2}}{#7}}% + {\romannumeral0\xintiiadd{\XINT_Mul{#6}{#2}}{#8}}% {#1}{#3}{#4}{#5}{#6}% }% % \end{macrocode} @@ -11725,8 +12662,8 @@ first place. \def\XINT_bezalg_b #1#2#3#4#5#6#7#8% {% \expandafter\XINT_bezalg_c\expandafter - {\romannumeral0\xintiadd {\xintiMul {#6}{#2}}{#8}}% - {\romannumeral0\xintiadd {\xintiMul {#5}{#2}}{#7}}% + {\romannumeral0\xintiiadd {\xintiiMul {#6}{#2}}{#8}}% + {\romannumeral0\xintiiadd {\xintiiMul {#5}{#2}}{#7}}% {#1}{#2}{#3}{#4}{#5}{#6}% }% % \end{macrocode} @@ -11880,6 +12817,9 @@ first place. %\def<*xintfrac>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12 } %</xintgcd> %<*xintfrac> +% +% \StoreCodelineNo {xintgcd} +% % \section{Package \xintfracname implementation} % % The commenting is currently (\docdate) very sparse. @@ -12048,7 +12988,7 @@ first place. \fi \expandafter\x\csname ver@xintfrac.sty\endcsname \ProvidesPackage{xintfrac}% - [2013/06/14 v1.08b Expandable operations on fractions (jfB)]% + [2013/09/24 v1.09a Expandable operations on fractions (jfB)]% \chardef\xint_c_vi 6 \chardef\xint_c_vii 7 \chardef\xint_c_xviii 18 @@ -12404,6 +13344,20 @@ first place. \expandafter{\romannumeral0\xint_dsh {#3}{#1}}{#2}}% \def\XINT_rawz_Bb #1#2{ #2/#1}% % \end{macrocode} +% \subsection{\csh{xintFloor}} +% \lverb|1.09a| +% \begin{macrocode} +\def\xintFloor {\romannumeral0\xintfloor }% +\def\xintfloor #1{\expandafter\XINT_floor + \romannumeral0\xintrawwithzeros {#1}.}% +\def\XINT_floor #1/#2.{\xintiquo {#1}{#2}}% +% \end{macrocode} +% \subsection{\csh{xintCeil}} +% \lverb|1.09a| +% \begin{macrocode} +\def\xintCeil {\romannumeral0\xintceil }% +\def\xintceil #1{\xintiiopp {\xintFloor {\xintOpp{#1}}}}% +% \end{macrocode} % \subsection{\csh{xintNumerator}} % \begin{macrocode} \def\xintNumerator {\romannumeral0\xintnumerator }% @@ -12758,8 +13712,8 @@ first place. \def\XINT_jrr_loop_b #1#2#3#4#5#6#7% {% \expandafter \XINT_jrr_loop_c \expandafter - {\romannumeral0\xintiadd{\XINT_Mul{#4}{#1}}{#6}}% - {\romannumeral0\xintiadd{\XINT_Mul{#5}{#1}}{#7}}% + {\romannumeral0\xintiiadd{\XINT_Mul{#4}{#1}}{#6}}% + {\romannumeral0\xintiiadd{\XINT_Mul{#5}{#1}}{#7}}% {#2}{#3}{#4}{#5}% }% \def\XINT_jrr_loop_c #1#2% @@ -12953,19 +13907,36 @@ first place. \XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z \Z }% % \end{macrocode} +% \subsection{\csh{xintRound:csv}} +% \lverb|1.09a. For use by \xintthenumexpr.| +% \begin{macrocode} +\def\xintRound:csv #1{\expandafter\XINT_round:_a\romannumeral-`0#1,,^}% +\def\XINT_round:_a {\XINT_round:_b {}}% +\def\XINT_round:_b #1#2,% + {\expandafter\XINT_round:_c\romannumeral-`0#2,{#1}}% +\def\XINT_round:_c #1{\if #1,\expandafter\XINT_round:_f + \else\expandafter\XINT_round:_d\fi #1}% +\def\XINT_round:_d #1,% + {\expandafter\XINT_round:_e\romannumeral0\xintiround 0{#1},}% +\def\XINT_round:_e #1,#2{\XINT_round:_b {#2,#1}}% +\def\XINT_round:_f ,#1#2^{\xint_gobble_i #1}% +% \end{macrocode} % \subsection{\csh{xintDigits}} +% \lverb|& +% The mathchardef used to be called \XINT_digits, but for reasons originating in +% \xintNewExpr, release 1.09a uses \XINTdigits without underscore.| % \begin{macrocode} -\mathchardef\XINT_digits 16 +\mathchardef\XINTdigits 16 \def\xintDigits #1#2% - {\afterassignment \xint_gobble_i \mathchardef\XINT_digits=}% -\def\xinttheDigits {\number\XINT_digits }% + {\afterassignment \xint_gobble_i \mathchardef\XINTdigits=}% +\def\xinttheDigits {\number\XINTdigits }% % \end{macrocode} % \subsection{\csh{xintFloat}} % \lverb|1.07. Completely re-written in 1.08a, with spectacular speed % gains. The earlier version was seriously silly when dealing with % inputs having a big power of ten. Again some modifications in 1.08b % for a better treatment of cases with long explicit numerators or -% denominators. | +% denominators. Macro \xintFloat:csv added in 1.09 for use by xintexpr.| % \begin{macrocode} \def\xintFloat {\romannumeral0\xintfloat }% \def\xintfloat #1{\XINT_float_chkopt #1\Z }% @@ -12977,7 +13948,7 @@ first place. }% \def\XINT_float_noopt #1\Z {% - \expandafter\XINT_float_a\expandafter\XINT_digits + \expandafter\XINT_float_a\expandafter\XINTdigits \romannumeral0\XINT_infrac {#1}\XINT_float_Q }% \def\XINT_float_opt [\Z #1]#2% @@ -13017,7 +13988,8 @@ first place. \def\XINT_float_Ma #1#2#3% {% \expandafter\XINT_float_Mb\expandafter - {\the\numexpr #1-#2\expandafter}\expandafter + {\the\numexpr #1-#2\expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter {\expandafter\xint_firstoftwo \romannumeral0\XINT_split_fromleft_loop {#2}{}#3\W\W\W\W\W\W\W\W\Z }{#2}% @@ -13048,7 +14020,8 @@ first place. \expandafter\XINT_float_P\expandafter {\the\numexpr #2\expandafter}\expandafter {\the\numexpr #2\expandafter}\expandafter - {\the\numexpr #3-#1+#2\expandafter}\expandafter + {\the\numexpr #3-#1+#2\expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter {\expandafter\xint_firstoftwo \romannumeral0\XINT_split_fromleft_loop {#2}{}#4\W\W\W\W\W\W\W\W\Z }% @@ -13070,13 +14043,13 @@ first place. {% \expandafter\XINT_float_Sa \romannumeral0\xintiquo {#2}% - {\romannumeral-`0\XINT_dsx_addzerosnofuss {-#1}{#3}}\Z {#1}% + {\XINT_dsx_addzerosnofuss {-#1}{#3}}\Z {#1}% }% \def\XINT_float_Rii #1#2#3% {% \expandafter\XINT_float_Sa \romannumeral0\xintiquo - {\romannumeral-`0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}\Z {#1}% + {\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}\Z {#1}% }% \def\XINT_float_Sa #1% {% @@ -13139,14 +14112,35 @@ first place. }% \def\XINT_float_Y #1#2{ #2e#1}% % \end{macrocode} +% \subsection{\csh{xintFloat:csv}} +% \lverb|1.09a. For use by \xintthefloatexpr.| +% \begin{macrocode} +\def\xintFloat:csv #1{\expandafter\XINT_float:_a\romannumeral-`0#1,,^}% +\def\XINT_float:_a {\XINT_float:_b {}}% +\def\XINT_float:_b #1#2,% + {\expandafter\XINT_float:_c\romannumeral-`0#2,{#1}}% +\def\XINT_float:_c #1{\if #1,\expandafter\XINT_float:_f + \else\expandafter\XINT_float:_d\fi #1}% +\def\XINT_float:_d #1,% + {\expandafter\XINT_float:_e\romannumeral0\xintfloat {#1},}% +\def\XINT_float:_e #1,#2{\XINT_float:_b {#2,#1}}% +\def\XINT_float:_f ,#1#2^{\xint_gobble_i #1}% +% \end{macrocode} % \subsection{\csh{XINT\_inFloat}} % \lverb|1.07. Completely rewritten in 1.08a for immensely greater efficiency % when the % power of ten is big: previous version had some very serious bottlenecks % arising from the creation of long strings of zeros, which made things such as % 2^999999 completely impossible, but now even 2^999999999 with 24 significant -% digits is no problem! Again (slightly) improved in 1.08b. | +% digits is no problem! Again (slightly) improved in 1.08b. +% +% For convenience in xintexpr.sty (special r\^ole of the underscore in +% \xintNewExpr) 1.09a adds \XINTinFloat. I also decide in 1.09a not to use +% anymore \romannumeral`-0 mais \romannumeral0 in the float routines, for +% consistency of style. +% | % \begin{macrocode} +\def\XINTinFloat {\romannumeral0\XINT_inFloat }% \def\XINT_inFloat [#1]#2% {% \expandafter\XINT_infloat_a\expandafter @@ -13165,8 +14159,8 @@ first place. 0-\dummy {\XINT_float_K #1}% \krof }% -\def\XINT_infloat_zero #1\Z #2#3#4#5{0[0]}% -\def\XINT_infloat_J {\expandafter-\romannumeral-`0\XINT_float_K }% +\def\XINT_infloat_zero #1\Z #2#3#4#5{ 0[0]}% +\def\XINT_infloat_J {\expandafter-\romannumeral0\XINT_float_K }% \def\XINT_infloat_Q #1% {% \ifnum #1<\xint_c_ @@ -13179,13 +14173,13 @@ first place. {% \expandafter\XINT_infloat_S\expandafter {\romannumeral0\xintiquo {#2}% - {\romannumeral-`0\XINT_dsx_addzerosnofuss {-#1}{#3}}}{#1}% + {\XINT_dsx_addzerosnofuss {-#1}{#3}}}{#1}% }% \def\XINT_infloat_Rii #1#2#3% {% \expandafter\XINT_infloat_S\expandafter {\romannumeral0\xintiquo - {\romannumeral-`0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}}{#1}% + {\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}}{#1}% }% \def\XINT_infloat_S #1#2#3% {% @@ -13256,10 +14250,10 @@ first place. \def\XINT_fadd_B #1#2#3#4#5#6#7% {% \expandafter\XINT_fadd_C\expandafter - {\romannumeral0\xintimul {#7}{#5}}% - {\romannumeral0\xintiadd - {\romannumeral0\xintimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% - {\romannumeral0\xintimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% + {\romannumeral0\xintiimul {#7}{#5}}% + {\romannumeral0\xintiiadd + {\romannumeral0\xintiimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% + {\romannumeral0\xintiimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% }% {#1}% }% @@ -13290,10 +14284,10 @@ first place. \def\XINT_fsub_B #1#2#3#4#5#6#7% {% \expandafter\XINT_fsub_C\expandafter - {\romannumeral0\xintimul {#7}{#5}}% - {\romannumeral0\xintisub - {\romannumeral0\xintimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% - {\romannumeral0\xintimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% + {\romannumeral0\xintiimul {#7}{#5}}% + {\romannumeral0\xintiisub + {\romannumeral0\xintiimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% + {\romannumeral0\xintiimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% }% {#1}% }% @@ -13325,6 +14319,18 @@ first place. }% \def\XINT_fsum_finished #1\Z #2{ #2}% % \end{macrocode} +% \subsection{\csh{xintSum:csv}} +% \lverb|1.09a. For use by \xintexpr.| +% \begin{macrocode} +\def\xintSum:csv #1{\expandafter\XINT_sum:_a\romannumeral-`0#1,,^}% +\def\XINT_sum:_a {\XINT_sum:_b {0/1[0]}}% +\def\XINT_sum:_b #1#2,{\expandafter\XINT_sum:_c\romannumeral-`0#2,{#1}}% +\def\XINT_sum:_c #1{\if #1,\expandafter\XINT_sum:_e + \else\expandafter\XINT_sum:_d\fi #1}% +\def\XINT_sum:_d #1,#2{\expandafter\XINT_sum:_b\expandafter + {\romannumeral0\xintadd {#2}{#1}}}% +\def\XINT_sum:_e ,#1#2^{#1}% allows empty list +% \end{macrocode} % \subsection{\csh{xintMul}} % \begin{macrocode} \def\xintMul {\romannumeral0\xintmul }% @@ -13338,8 +14344,8 @@ first place. {% \expandafter\XINT_fmul_B \expandafter{\the\numexpr #1+#4\expandafter}% - \expandafter{\romannumeral0\xintimul {#6}{#3}}% - {\romannumeral0\xintimul {#5}{#2}}% + \expandafter{\romannumeral0\xintiimul {#6}{#3}}% + {\romannumeral0\xintiimul {#5}{#2}}% }% \def\XINT_fmul_B #1#2#3% {% @@ -13445,6 +14451,18 @@ first place. }% \def\XINT_fprod_finished #1\Z #2{ #2}% % \end{macrocode} +% \subsection{\csh{xintPrd:csv}} +% \lverb|1.09a. For use by \xintexpr.| +% \begin{macrocode} +\def\xintPrd:csv #1{\expandafter\XINT_prd:_a\romannumeral-`0#1,,^}% +\def\XINT_prd:_a {\XINT_prd:_b {1/1[0]}}% +\def\XINT_prd:_b #1#2,{\expandafter\XINT_prd:_c\romannumeral-`0#2,{#1}}% +\def\XINT_prd:_c #1{\if #1,\expandafter\XINT_prd:_e + \else\expandafter\XINT_prd:_d\fi #1}% +\def\XINT_prd:_d #1,#2{\expandafter\XINT_prd:_b\expandafter + {\romannumeral0\xintmul {#2}{#1}}}% +\def\XINT_prd:_e ,#1#2^{#1}% allows empty list +% \end{macrocode} % \subsection{\csh{xintDiv}} % \begin{macrocode} \def\xintDiv {\romannumeral0\xintdiv }% @@ -13458,8 +14476,8 @@ first place. {% \expandafter\XINT_fdiv_B \expandafter{\the\numexpr #4-#1\expandafter}% - \expandafter{\romannumeral0\xintimul {#2}{#6}}% - {\romannumeral0\xintimul {#3}{#5}}% + \expandafter{\romannumeral0\xintiimul {#2}{#6}}% + {\romannumeral0\xintiimul {#3}{#5}}% }% \def\XINT_fdiv_B #1#2#3% {% @@ -13468,6 +14486,16 @@ first place. }% \def\XINT_fdiv_C #1#2{\XINT_outfrac {#2}{#1}}% % \end{macrocode} +% \subsection{\csh{xintIsOne}} +% \lverb|& +% New with 1.09a. Could be more efficient. For fractions with big powers of +% tens, it is better to use \xintCmp{f}{1}.| +% \begin{macrocode} +\def\xintIsOne {\romannumeral0\xintisone }% +\def\xintisone #1{\expandafter\XINT_fracisone + \romannumeral0\xintrawwithzeros{#1}\Z }% +\def\XINT_fracisone #1/#2\Z{\xintsgnfork{\XINT_Cmp {#1}{#2}}{0}{1}{0}}% +% \end{macrocode} % \subsection{\csh{xintGeq}} % \lverb|& % Rewritten completely in 1.08a to be less dumb when comparing fractions having @@ -13493,8 +14521,8 @@ first place. \xint_gob_til_zero #4\XINT_fgeq_Zi 0% \expandafter\XINT_fgeq_C\expandafter {\the\numexpr #7-#3\expandafter}\expandafter - {\romannumeral0\xintimul {#4#5}{#2}}% - {\romannumeral0\xintimul {#6}{#1}}% + {\romannumeral0\xintiimul {#4#5}{#2}}% + {\romannumeral0\xintiimul {#6}{#1}}% }% \def\XINT_fgeq_Zi 0#1#2#3#4#5#6#7{ 0}% \def\XINT_fgeq_C #1#2#3% @@ -13566,6 +14594,62 @@ first place. \fi }% % \end{macrocode} +% \subsection{\csh{xintMaxof}} +% \lverb|\xintMaxof:csv is for private use in \xintexpr. Even with only one +% argument, there does not seem to be really a motive for using \xintraw.| +% \begin{macrocode} +\def\xintMaxof {\romannumeral0\xintmaxof }% +\def\xintmaxof #1{\expandafter\XINT_maxof_a\romannumeral-`0#1\relax }% +\def\XINT_maxof_a #1{\expandafter\XINT_maxof_b\romannumeral0\xintraw{#1}\Z }% +\def\XINT_maxof_b #1\Z #2% + {\expandafter\XINT_maxof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_maxof_c #1% + {\xint_gob_til_relax #1\XINT_maxof_e\relax\XINT_maxof_d #1}% +\def\XINT_maxof_d #1\Z + {\expandafter\XINT_maxof_b\romannumeral0\xintmax {#1}}% +\def\XINT_maxof_e #1\Z #2\Z { #2}% +% \end{macrocode} +% \subsection{\csh{xintMaxof:csv}} +% \lverb|1.09a. For use by \xintexpr.| +% \begin{macrocode} +\def\xintMaxof:csv #1{\expandafter\XINT_maxof:_b\romannumeral-`0#1,,}% +\def\XINT_maxof:_b #1,#2,{\expandafter\XINT_maxof:_c\romannumeral-`0#2,{#1},}% +\def\XINT_maxof:_c #1{\if #1,\expandafter\XINT_maxof:_e + \else\expandafter\XINT_maxof:_d\fi #1}% +\def\XINT_maxof:_d #1,{\expandafter\XINT_maxof:_b\romannumeral0\xintmax {#1}}% +\def\XINT_maxof:_e ,#1,{#1}% +% \end{macrocode} +% \subsection{\csh{xintFloatMaxof}} +% \lverb|1.09a, for use by \xintNewFloatExpr.| +% \begin{macrocode} +\def\xintFloatMaxof {\romannumeral0\xintflmaxof }% +\def\xintflmaxof #1{\expandafter\XINT_flmaxof_a\romannumeral-`0#1\relax }% +\def\XINT_flmaxof_a #1{\expandafter\XINT_flmaxof_b + \romannumeral0\XINT_inFloat [\XINTdigits]{#1}\Z }% +\def\XINT_flmaxof_b #1\Z #2% + {\expandafter\XINT_flmaxof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_flmaxof_c #1% + {\xint_gob_til_relax #1\XINT_flmaxof_e\relax\XINT_flmaxof_d #1}% +\def\XINT_flmaxof_d #1\Z + {\expandafter\XINT_flmaxof_b\romannumeral0\xintmax + {\XINTinFloat [\XINTdigits]{#1}}}% +\def\XINT_flmaxof_e #1\Z #2\Z { #2}% +% \end{macrocode} +% \subsection{\csh{xintFloatMaxof:csv}} +% \lverb|1.09a. For use by \xintfloatexpr.| +% \begin{macrocode} +\def\xintFloatMaxof:csv #1{\expandafter\XINT_flmaxof:_a\romannumeral-`0#1,,}% +\def\XINT_flmaxof:_a #1,{\expandafter\XINT_flmaxof:_b + \romannumeral0\XINT_inFloat [\XINTdigits]{#1},}% +\def\XINT_flmaxof:_b #1,#2,% + {\expandafter\XINT_flmaxof:_c\romannumeral-`0#2,{#1},}% +\def\XINT_flmaxof:_c #1{\if #1,\expandafter\XINT_flmaxof:_e + \else\expandafter\XINT_flmaxof:_d\fi #1}% +\def\XINT_flmaxof:_d #1,% + {\expandafter\XINT_flmaxof:_b\romannumeral0\xintmax + {\XINTinFloat [\XINTdigits]{#1}}}% +\def\XINT_flmaxof:_e ,#1,{#1}% +% \end{macrocode} % \subsection{\csh{xintMin}} % \lverb|& % Rewritten completely in 1.08a.| @@ -13605,10 +14689,69 @@ first place. \fi }% % \end{macrocode} +% \subsection{\csh{xintMinof}} +% \begin{macrocode} +\def\xintMinof {\romannumeral0\xintminof }% +\def\xintminof #1{\expandafter\XINT_minof_a\romannumeral-`0#1\relax }% +\def\XINT_minof_a #1{\expandafter\XINT_minof_b\romannumeral0\xintraw{#1}\Z }% +\def\XINT_minof_b #1\Z #2% + {\expandafter\XINT_minof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_minof_c #1% + {\xint_gob_til_relax #1\XINT_minof_e\relax\XINT_minof_d #1}% +\def\XINT_minof_d #1\Z + {\expandafter\XINT_minof_b\romannumeral0\xintmin {#1}}% +\def\XINT_minof_e #1\Z #2\Z { #2}% +% \end{macrocode} +% \subsection{\csh{xintMinof:csv}} +% \lverb|1.09a. For use by \xintexpr.| +% \begin{macrocode} +\def\xintMinof:csv #1{\expandafter\XINT_minof:_b\romannumeral-`0#1,,}% +\def\XINT_minof:_b #1,#2,{\expandafter\XINT_minof:_c\romannumeral-`0#2,{#1},}% +\def\XINT_minof:_c #1{\if #1,\expandafter\XINT_minof:_e + \else\expandafter\XINT_minof:_d\fi #1}% +\def\XINT_minof:_d #1,{\expandafter\XINT_minof:_b\romannumeral0\xintmin {#1}}% +\def\XINT_minof:_e ,#1,{#1}% +% \end{macrocode} +% \subsection{\csh{xintFloatMinof}} +% \lverb|1.09a, for use by \xintNewFloatExpr.| +% \begin{macrocode} +\def\xintFloatMinof {\romannumeral0\xintflminof }% +\def\xintflminof #1{\expandafter\XINT_flminof_a\romannumeral-`0#1\relax }% +\def\XINT_flminof_a #1{\expandafter\XINT_flminof_b + \romannumeral0\XINT_inFloat [\XINTdigits]{#1}\Z }% +\def\XINT_flminof_b #1\Z #2% + {\expandafter\XINT_flminof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_flminof_c #1% + {\xint_gob_til_relax #1\XINT_flminof_e\relax\XINT_flminof_d #1}% +\def\XINT_flminof_d #1\Z + {\expandafter\XINT_flminof_b\romannumeral0\xintmin + {\XINTinFloat [\XINTdigits]{#1}}}% +\def\XINT_flminof_e #1\Z #2\Z { #2}% +% \end{macrocode} +% \subsection{\csh{xintFloatMinof:csv}} +% \lverb|1.09a. For use by \xintfloatexpr.| +% \begin{macrocode} +\def\xintFloatMinof:csv #1{\expandafter\XINT_flminof:_a\romannumeral-`0#1,,}% +\def\XINT_flminof:_a #1,{\expandafter\XINT_flminof:_b + \romannumeral0\XINT_inFloat [\XINTdigits]{#1},}% +\def\XINT_flminof:_b #1,#2,% + {\expandafter\XINT_flminof:_c\romannumeral-`0#2,{#1},}% +\def\XINT_flminof:_c #1{\if #1,\expandafter\XINT_flminof:_e + \else\expandafter\XINT_flminof:_d\fi #1}% +\def\XINT_flminof:_d #1,% + {\expandafter\XINT_flminof:_b\romannumeral0\xintmin + {\XINTinFloat [\XINTdigits]{#1}}}% +\def\XINT_flminof:_e ,#1,{#1}% +% \end{macrocode} % \subsection{\csh{xintCmp}} % \lverb|& % Rewritten completely in 1.08a to be less dumb when comparing fractions having -% big powers of tens.| +% big powers of tens. Incredibly, it seems that 1.08b introduced a bug in +% delimited arguments making the macro just non-functional when one of the input +% was zero! I +% did not detect this until working on release 1.09a, somehow I had not tested +% that +% \xintCmp just did NOT work! I must have done some last minute change... | % \begin{macrocode} \def\xintCmp {\romannumeral0\xintcmp }% \def\xintcmp #1% @@ -13642,9 +14785,9 @@ first place. \krof #1#2% }% -\def\XINT_fcmp_zerozero #1[#2]#3[#4]{ 0}% -\def\XINT_fcmp_firstzero #1[#2]#3[#4]{ -1}% -\def\XINT_fcmp_secondzero #1[#2]#3[#4]{ 1}% +\def\XINT_fcmp_zerozero #1#2#3#4{ 0}% 1.08b had some [ and ] here!!! +\def\XINT_fcmp_firstzero #1#2#3#4{ -1}% incredibly I never saw that until +\def\XINT_fcmp_secondzero #1#2#3#4{ 1}% preparing 1.09a. \def\XINT_fcmp_pos #1#2#3#4% {% \XINT_fcmp_B #1#3#2#4% @@ -13653,8 +14796,8 @@ first place. {% \expandafter\XINT_fcmp_C\expandafter {\the\numexpr #6-#3\expandafter}\expandafter - {\romannumeral0\xintimul {#4}{#2}}% - {\romannumeral0\xintimul {#5}{#1}}% + {\romannumeral0\xintiimul {#4}{#2}}% + {\romannumeral0\xintiimul {#5}{#1}}% }% \def\XINT_fcmp_C #1#2#3% {% @@ -13786,7 +14929,7 @@ first place. % \begin{macrocode} \def\xintFloatAdd {\romannumeral0\xintfloatadd }% \def\xintfloatadd #1{\XINT_fladd_chkopt \xintfloat #1\Z }% -\def\XINTinFloatAdd {\romannumeral-`0\XINTinfloatadd }% +\def\XINTinFloatAdd {\romannumeral0\XINTinfloatadd }% \def\XINTinfloatadd #1{\XINT_fladd_chkopt \XINT_inFloat #1\Z }% \def\XINT_fladd_chkopt #1#2% {% @@ -13796,7 +14939,7 @@ first place. }% \def\XINT_fladd_noopt #1#2\Z #3% {% - #1[\XINT_digits]{\XINT_FL_Add {\XINT_digits+2}{#2}{#3}}% + #1[\XINTdigits]{\XINT_FL_Add {\XINTdigits+2}{#2}{#3}}% }% \def\XINT_fladd_opt #1[\Z #2]#3#4% {% @@ -13805,11 +14948,11 @@ first place. \def\XINT_FL_Add #1#2% {% \expandafter\XINT_FL_Add_a\expandafter{\the\numexpr #1\expandafter}% - \expandafter{\romannumeral-`0\XINT_inFloat [#1]{#2}}% + \expandafter{\romannumeral0\XINT_inFloat [#1]{#2}}% }% \def\XINT_FL_Add_a #1#2#3% {% - \expandafter\XINT_FL_Add_b\romannumeral-`0\XINT_inFloat [#1]{#3}#2{#1}% + \expandafter\XINT_FL_Add_b\romannumeral0\XINT_inFloat [#1]{#3}#2{#1}% }% \def\XINT_FL_Add_b #1% {% @@ -13837,7 +14980,7 @@ first place. % \begin{macrocode} \def\xintFloatSub {\romannumeral0\xintfloatsub }% \def\xintfloatsub #1{\XINT_flsub_chkopt \xintfloat #1\Z }% -\def\XINTinFloatSub {\romannumeral-`0\XINTinfloatsub }% +\def\XINTinFloatSub {\romannumeral0\XINTinfloatsub }% \def\XINTinfloatsub #1{\XINT_flsub_chkopt \XINT_inFloat #1\Z }% \def\XINT_flsub_chkopt #1#2% {% @@ -13847,7 +14990,7 @@ first place. }% \def\XINT_flsub_noopt #1#2\Z #3% {% - #1[\XINT_digits]{\XINT_FL_Add {\XINT_digits+2}{#2}{\xintOpp{#3}}}% + #1[\XINTdigits]{\XINT_FL_Add {\XINTdigits+2}{#2}{\xintOpp{#3}}}% }% \def\XINT_flsub_opt #1[\Z #2]#3#4% {% @@ -13859,7 +15002,7 @@ first place. % \begin{macrocode} \def\xintFloatMul {\romannumeral0\xintfloatmul}% \def\xintfloatmul #1{\XINT_flmul_chkopt \xintfloat #1\Z }% -\def\XINTinFloatMul {\romannumeral-`0\XINTinfloatmul }% +\def\XINTinFloatMul {\romannumeral0\XINTinfloatmul }% \def\XINTinfloatmul #1{\XINT_flmul_chkopt \XINT_inFloat #1\Z }% \def\XINT_flmul_chkopt #1#2% {% @@ -13869,7 +15012,7 @@ first place. }% \def\XINT_flmul_noopt #1#2\Z #3% {% - #1[\XINT_digits]{\XINT_FL_Mul {\XINT_digits+2}{#2}{#3}}% + #1[\XINTdigits]{\XINT_FL_Mul {\XINTdigits+2}{#2}{#3}}% }% \def\XINT_flmul_opt #1[\Z #2]#3#4% {% @@ -13878,20 +15021,20 @@ first place. \def\XINT_FL_Mul #1#2% {% \expandafter\XINT_FL_Mul_a\expandafter{\the\numexpr #1\expandafter}% - \expandafter{\romannumeral-`0\XINT_inFloat [#1]{#2}}% + \expandafter{\romannumeral0\XINT_inFloat [#1]{#2}}% }% \def\XINT_FL_Mul_a #1#2#3% {% - \expandafter\XINT_FL_Mul_b\romannumeral-`0\XINT_inFloat [#1]{#3}#2% + \expandafter\XINT_FL_Mul_b\romannumeral0\XINT_inFloat [#1]{#3}#2% }% -\def\XINT_FL_Mul_b #1[#2]#3[#4]{\xintE{\xintiMul {#1}{#3}}{#2+#4}}% +\def\XINT_FL_Mul_b #1[#2]#3[#4]{\xintE{\xintiiMul {#1}{#3}}{#2+#4}}% % \end{macrocode} % \subsection{\csh{xintFloatDiv}} % \lverb|1.07| % \begin{macrocode} \def\xintFloatDiv {\romannumeral0\xintfloatdiv}% \def\xintfloatdiv #1{\XINT_fldiv_chkopt \xintfloat #1\Z }% -\def\XINTinFloatDiv {\romannumeral-`0\XINTinfloatdiv }% +\def\XINTinFloatDiv {\romannumeral0\XINTinfloatdiv }% \def\XINTinfloatdiv #1{\XINT_fldiv_chkopt \XINT_inFloat #1\Z }% \def\XINT_fldiv_chkopt #1#2% {% @@ -13901,7 +15044,7 @@ first place. }% \def\XINT_fldiv_noopt #1#2\Z #3% {% - #1[\XINT_digits]{\XINT_FL_Div {\XINT_digits+2}{#2}{#3}}% + #1[\XINTdigits]{\XINT_FL_Div {\XINTdigits+2}{#2}{#3}}% }% \def\XINT_fldiv_opt #1[\Z #2]#3#4% {% @@ -13910,20 +15053,78 @@ first place. \def\XINT_FL_Div #1#2% {% \expandafter\XINT_FL_Div_a\expandafter{\the\numexpr #1\expandafter}% - \expandafter{\romannumeral-`0\XINT_inFloat [#1]{#2}}% + \expandafter{\romannumeral0\XINT_inFloat [#1]{#2}}% }% \def\XINT_FL_Div_a #1#2#3% {% - \expandafter\XINT_FL_Div_b\romannumeral-`0\XINT_inFloat [#1]{#3}#2% + \expandafter\XINT_FL_Div_b\romannumeral0\XINT_inFloat [#1]{#3}#2% }% \def\XINT_FL_Div_b #1[#2]#3[#4]{\xintE{#3/#1}{#4-#2}}% % \end{macrocode} +% \subsection{\csh{xintFloatSum}} +% \lverb|1.09a: quick write-up, for use by \xintfloatexpr, will need to be +% thought through again.| +% \begin{macrocode} +\def\xintFloatSum {\romannumeral0\xintfloatsum }% +\def\xintfloatsum #1{\expandafter\XINT_floatsum_a\romannumeral-`0#1\relax }% +\def\XINT_floatsum_a #1{\expandafter\XINT_floatsum_b + \romannumeral0\xintraw{#1}\Z }% normalizes if only 1 +\def\XINT_floatsum_b #1\Z #2% but a bit wasteful + {\expandafter\XINT_floatsum_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_floatsum_c #1% + {\xint_gob_til_relax #1\XINT_floatsum_e\relax\XINT_floatsum_d #1}% +\def\XINT_floatsum_d #1\Z + {\expandafter\XINT_floatsum_b\romannumeral0\XINTinfloatadd {#1}}% +\def\XINT_floatsum_e #1\Z #2\Z { #2}% +% \end{macrocode} +% \subsection{\csh{xintFloatSum:csv}} +% \lverb|1.09a. For use by \xintfloatexpr.| +% \begin{macrocode} +\def\xintFloatSum:csv #1{\expandafter\XINT_floatsum:_a\romannumeral-`0#1,,^}% +\def\XINT_floatsum:_a {\XINT_floatsum:_b {0/1[0]}}% +\def\XINT_floatsum:_b #1#2,% + {\expandafter\XINT_floatsum:_c\romannumeral-`0#2,{#1}}% +\def\XINT_floatsum:_c #1{\if #1,\expandafter\XINT_floatsum:_e + \else\expandafter\XINT_floatsum:_d\fi #1}% +\def\XINT_floatsum:_d #1,#2{\expandafter\XINT_floatsum:_b\expandafter + {\romannumeral0\XINTinfloatadd {#2}{#1}}}% +\def\XINT_floatsum:_e ,#1#2^{#1}% allows empty list +% \end{macrocode} +% \subsection{\csh{xintFloatPrd}} +% \lverb|1.09a: quick write-up, for use by \xintfloatexpr, will need to be +% thought through again.| +% \begin{macrocode} +\def\xintFloatPrd {\romannumeral0\xintfloatprd }% +\def\xintfloatprd #1{\expandafter\XINT_floatprd_a\romannumeral-`0#1\relax }% +\def\XINT_floatprd_a #1{\expandafter\XINT_floatprd_b + \romannumeral0\xintraw{#1}\Z }% +\def\XINT_floatprd_b #1\Z #2% + {\expandafter\XINT_floatprd_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_floatprd_c #1% + {\xint_gob_til_relax #1\XINT_floatprd_e\relax\XINT_floatprd_d #1}% +\def\XINT_floatprd_d #1\Z + {\expandafter\XINT_floatprd_b\romannumeral0\XINTinfloatmul {#1}}% +\def\XINT_floatprd_e #1\Z #2\Z { #2}% +% \end{macrocode} +% \subsection{\csh{xintFloatPrd:csv}} +% \lverb|1.09a. For use by \xintfloatexpr.| +% \begin{macrocode} +\def\xintFloatPrd:csv #1{\expandafter\XINT_floatprd:_a\romannumeral-`0#1,,^}% +\def\XINT_floatprd:_a {\XINT_floatprd:_b {1/1[0]}}% +\def\XINT_floatprd:_b #1#2,% + {\expandafter\XINT_floatprd:_c\romannumeral-`0#2,{#1}}% +\def\XINT_floatprd:_c #1{\if #1,\expandafter\XINT_floatprd:_e + \else\expandafter\XINT_floatprd:_d\fi #1}% +\def\XINT_floatprd:_d #1,#2{\expandafter\XINT_floatprd:_b\expandafter + {\romannumeral0\XINTinfloatmul {#2}{#1}}}% +\def\XINT_floatprd:_e ,#1#2^{#1}% allows empty list +% \end{macrocode} % \subsection{\csh{xintFloatPow}} % \lverb|1.07| % \begin{macrocode} \def\xintFloatPow {\romannumeral0\xintfloatpow}% \def\xintfloatpow #1{\XINT_flpow_chkopt \xintfloat #1\Z }% -\def\XINTinFloatPow {\romannumeral-`0\XINTinfloatpow }% +\def\XINTinFloatPow {\romannumeral0\XINTinfloatpow }% \def\XINTinfloatpow #1{\XINT_flpow_chkopt \XINT_inFloat #1\Z }% \def\XINT_flpow_chkopt #1#2% {% @@ -13936,7 +15137,7 @@ first place. {% \expandafter\XINT_flpow_checkB_start\expandafter {\the\numexpr #3\expandafter}\expandafter - {\the\numexpr \XINT_digits}{#2}{#1[\XINT_digits]}% + {\the\numexpr \XINTdigits}{#2}{#1[\XINTdigits]}% }% \def\XINT_flpow_opt #1[\Z #2]#3#4% {% @@ -13968,7 +15169,7 @@ first place. \def\XINT_flpow_checkB_d #1#2#3#4% {% \expandafter \XINT_flpow_a - \romannumeral-`0\XINT_inFloat [#1]{#4}{#1}{#2}#3% + \romannumeral0\XINT_inFloat [#1]{#4}{#1}{#2}#3% }% \def\XINT_flpow_a #1% {% @@ -14003,7 +15204,7 @@ first place. \xint_afterfi{\expandafter\XINT_flpow_loop_a \expandafter{\the\numexpr 2*(#2/2)-#2\expandafter }% b mod 2 \expandafter{\the\numexpr #2-#2/2\expandafter }% [b/2] - \expandafter{\romannumeral-`0\XINTinfloatmul [#1]{#3}{#3}}}% + \expandafter{\romannumeral0\XINTinfloatmul [#1]{#3}{#3}}}% \fi {#1}{{#3}}% }% @@ -14037,7 +15238,7 @@ first place. \def\XINT_flpow_prd_compute #1\Z #2#3% {% \expandafter\XINT_flpow_prd_getnext\expandafter - {\romannumeral-`0\XINTinfloatmul [#3]{#1}{#2}}{#3}% + {\romannumeral0\XINTinfloatmul [#3]{#1}{#2}}{#3}% }% \def\XINT_flpow_prd_end\relax\XINT_flpow_prd_compute \relax\Z #1#2#3% @@ -14066,7 +15267,7 @@ first place. % \begin{macrocode} \def\xintFloatPower {\romannumeral0\xintfloatpower}% \def\xintfloatpower #1{\XINT_flpower_chkopt \xintfloat #1\Z }% -\def\XINTinFloatPower {\romannumeral-`0\XINTinfloatpower}% +\def\XINTinFloatPower {\romannumeral0\XINTinfloatpower}% \def\XINTinfloatpower #1{\XINT_flpower_chkopt \XINT_inFloat #1\Z }% \def\XINT_flpower_chkopt #1#2% {% @@ -14078,8 +15279,8 @@ first place. \def\XINT_flpower_noopt #1#2\Z #3% {% \expandafter\XINT_flpower_checkB_start\expandafter - {\the\numexpr \XINT_digits\expandafter}\expandafter - {\romannumeral0\xintnum{#3}}{#2}{#1[\XINT_digits]}% + {\the\numexpr \XINTdigits\expandafter}\expandafter + {\romannumeral0\xintnum{#3}}{#2}{#1[\XINTdigits]}% }% \def\XINT_flpower_opt #1[\Z #2]#3#4% {% @@ -14111,7 +15312,7 @@ first place. \def\XINT_flpower_checkB_d #1#2#3#4% {% \expandafter \XINT_flpower_a - \romannumeral-`0\XINT_inFloat [#1]{#4}{#1}{#2}#3% + \romannumeral0\XINT_inFloat [#1]{#4}{#1}{#2}#3% }% \def\XINT_flpower_a #1% {% @@ -14143,7 +15344,7 @@ first place. {% \ifcase\XINT_isOne {#2} \xint_afterfi{\expandafter\XINT_flpower_loop_x\expandafter - {\romannumeral-`0\XINTinfloatmul [#1]{#3}{#3}}% + {\romannumeral0\XINTinfloatmul [#1]{#3}{#3}}% {\romannumeral0\xintdivision {#2}{2}}}% \or \expandafter\XINT_flpow_loop_end \fi @@ -14169,7 +15370,7 @@ first place. % \begin{macrocode} \def\xintFloatSqrt {\romannumeral0\xintfloatsqrt }% \def\xintfloatsqrt #1{\XINT_flsqrt_chkopt \xintfloat #1\Z }% -\def\XINTinFloatSqrt {\romannumeral-`0\XINTinfloatsqrt }% +\def\XINTinFloatSqrt {\romannumeral0\XINTinfloatsqrt }% \def\XINTinfloatsqrt #1{\XINT_flsqrt_chkopt \XINT_inFloat #1\Z }% \def\XINT_flsqrt_chkopt #1#2% {% @@ -14179,7 +15380,7 @@ first place. }% \def\XINT_flsqrt_noopt #1#2\Z {% - #1[\XINT_digits]{\XINT_FL_sqrt \XINT_digits {#2}}% + #1[\XINTdigits]{\XINT_FL_sqrt \XINTdigits {#2}}% }% \def\XINT_flsqrt_opt #1[\Z #2]#3% {% @@ -14196,7 +15397,7 @@ first place. \def\XINT_FL_sqrt_a #1#2% {% \expandafter\XINT_FL_sqrt_checkifzeroorneg - \romannumeral-`0\XINT_inFloat [#1]{#2}% + \romannumeral0\XINT_inFloat [#1]{#2}% }% \def\XINT_FL_sqrt_checkifzeroorneg #1% {% @@ -14296,14 +15497,14 @@ first place. \def\XINT_flsqrt_big_f #1% {% \expandafter\XINT_flsqrt_big_fa\expandafter - {\romannumeral0\xintisqr {#1}}{#1}% + {\romannumeral0\xintiisqr {#1}}{#1}% }% \def\XINT_flsqrt_big_fa #1#2#3#4% {% \expandafter\XINT_flsqrt_big_fb\expandafter - {\romannumeral-`0\XINT_dsx_addzerosnofuss + {\romannumeral0\XINT_dsx_addzerosnofuss {\numexpr #3-\xint_c_viii\relax}{#2}}% - {\romannumeral0\xintisub + {\romannumeral0\xintiisub {\XINT_dsx_addzerosnofuss {\numexpr \xint_c_ii*(#3-\xint_c_viii)\relax}{#1}}{#4}}% {#3}% @@ -14329,7 +15530,7 @@ first place. {% \expandafter\XINT_flsqrt_big_l\expandafter {\romannumeral0\XINT_sub_pre {#3}{#1}}% - {\romannumeral0\xintiadd {#2}{\romannumeral0\XINT_sqr {#1}}}% + {\romannumeral0\xintiiadd {#2}{\romannumeral0\XINT_sqr {#1}}}% }% \def\XINT_flsqrt_big_l #1#2% {% @@ -14340,7 +15541,7 @@ first place. {% \expandafter\XINT_flsqrt_big_end_b\expandafter {\the\numexpr -#4+#5/\xint_c_ii\expandafter}\expandafter - {\romannumeral0\xintisub + {\romannumeral0\xintiisub {\XINT_dsx_addzerosnofuss {#4}{#3}}% {\xintHalf{\xintiQuo{\XINT_dsx_addzerosnofuss {#4}{#2}}{#3}}}}% }% @@ -14352,6 +15553,9 @@ first place. %\def<*xintseries>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12 } %</xintfrac> %<*xintseries> +% +% \StoreCodelineNo {xintfrac} +% % \section{Package \xintseriesname implementation} % % The commenting is currently (\docdate) very sparse. @@ -14520,7 +15724,7 @@ first place. \fi \expandafter\x\csname ver@xintseries.sty\endcsname \ProvidesPackage{xintseries}% - [2013/06/14 v1.08b Expandable partial sums with xint package (jfB)]% + [2013/09/24 v1.09a Expandable partial sums with xint package (jfB)]% % \end{macrocode} % \subsection{\csh{xintSeries}} % \lverb|& @@ -14580,7 +15784,7 @@ first place. \ifnum #3>#1 \else \XINT_iseries_exit \fi \expandafter\XINT_iseries_loop\expandafter {\the\numexpr #1+1\expandafter }\expandafter - {\romannumeral0\xintiadd {#2}{#4{#1}}}% + {\romannumeral0\xintiiadd {#2}{#4{#1}}}% {#3}{#4}% }% \def\XINT_iseries_exit \fi #1#2#3#4#5#6#7#8% @@ -14791,7 +15995,7 @@ first place. {% \expandafter\XINT_fppowseries_loop_i\expandafter {\the\numexpr #2+\xint_c_i\expandafter}\expandafter - {\romannumeral0\xintiadd {#4}{\xintiTrunc {#7}{\xintMul {#6{#2}}{#1}}}}% + {\romannumeral0\xintiiadd {#4}{\xintiTrunc {#7}{\xintMul {#6{#2}}{#1}}}}% {#1}{#3}{#5}{#6}{#7}% }% \def\XINT_fppowseries_exit_i\fi\expandafter\XINT_fppowseries_loop_ii @@ -14799,7 +16003,7 @@ first place. \def\XINT_fppowseries_exit_ii #1#2#3#4#5#6#7% {% \xinttrunc {#7} - {\xintiAdd {#4}{\xintiTrunc {#7}{\xintMul {#6{#2}}{#1}}}[-#7]}% + {\xintiiadd {#4}{\xintiTrunc {#7}{\xintMul {#6{#2}}{#1}}}[-#7]}% }% % \end{macrocode} % \subsection{\csh{xintFxPtPowerSeriesX}} @@ -14850,7 +16054,7 @@ first place. {% \expandafter\XINT_flpowseries\expandafter {\the\numexpr #1\expandafter}\expandafter - {\the\numexpr #2}\XINT_digits + {\the\numexpr #2}\XINTdigits }% \def\XINT_flpowseries_opt [\Z #1]#2#3% {% @@ -14865,7 +16069,7 @@ first place. \else \xint_afterfi {\expandafter\XINT_flpowseries_loop_pre\expandafter - {\romannumeral-`0\XINTinfloatpow [#3]{#5}{#1}}% + {\romannumeral0\XINTinfloatpow [#3]{#5}{#1}}% {#1}{#5}{#2}{#4}{#3}% }% \fi @@ -14875,7 +16079,7 @@ first place. \ifnum #4>#2 \else\XINT_flpowseries_dont_i \fi \expandafter\XINT_flpowseries_loop_i\expandafter {\the\numexpr #2+\xint_c_i\expandafter}\expandafter - {\romannumeral-`0\XINTinfloatmul [#6]{#5{#2}}{#1}}% + {\romannumeral0\XINTinfloatmul [#6]{#5{#2}}{#1}}% {#1}{#3}{#4}{#5}{#6}% }% \def\XINT_flpowseries_dont_i \fi\expandafter\XINT_flpowseries_loop_i @@ -14885,14 +16089,14 @@ first place. {% \ifnum #5>#1 \else \XINT_flpowseries_exit_i \fi \expandafter\XINT_flpowseries_loop_ii\expandafter - {\romannumeral-`0\XINTinfloatmul [#7]{#3}{#4}}% + {\romannumeral0\XINTinfloatmul [#7]{#3}{#4}}% {#1}{#4}{#2}{#5}{#6}{#7}% }% \def\XINT_flpowseries_loop_ii #1#2#3#4#5#6#7% {% \expandafter\XINT_flpowseries_loop_i\expandafter {\the\numexpr #2+\xint_c_i\expandafter}\expandafter - {\romannumeral-`0\XINTinfloatadd [#7]{#4}% + {\romannumeral0\XINTinfloatadd [#7]{#4}% {\XINTinfloatmul [#7]{#6{#2}}{#1}}}% {#1}{#3}{#5}{#6}{#7}% }% @@ -14919,7 +16123,7 @@ first place. {% \expandafter\XINT_flpowseriesx\expandafter {\the\numexpr #1\expandafter}\expandafter - {\the\numexpr #2}\XINT_digits + {\the\numexpr #2}\XINTdigits }% \def\XINT_flpowseriesx_opt [\Z #1]#2#3% {% @@ -14941,7 +16145,7 @@ first place. \def\XINT_flpowseriesx_pre #1#2#3#4#5% {% \expandafter\XINT_flpowseries_loop_pre\expandafter - {\romannumeral-`0\XINTinfloatpow [#5]{#1}{#2}}% + {\romannumeral0\XINTinfloatpow [#5]{#1}{#2}}% {#2}{#1}{#3}{#4}{#5}% }% \XINT_series_restorecatcodes_endinput% @@ -14951,6 +16155,9 @@ first place. %\def<*xintcfrac>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12 } %</xintseries> %<*xintcfrac> +% +% \StoreCodelineNo {xintseries} +% % \section{Package \xintcfracname implementation} % % The commenting is currently (\docdate) very sparse. @@ -15119,7 +16326,7 @@ first place. \fi \expandafter\x\csname ver@xintcfrac.sty\endcsname \ProvidesPackage{xintcfrac}% - [2013/06/14 v1.08b Expandable continued fractions with xint package (jfB)]% + [2013/09/24 v1.09a Expandable continued fractions with xint package (jfB)]% % \end{macrocode} % \subsection{\csh{xintCFrac}} % \begin{macrocode} @@ -15469,8 +16676,8 @@ first place. \expandafter\XINT_cstf_loop_c\expandafter {\romannumeral0\XINT_mul_fork #2\Z #4\Z }% {\romannumeral0\XINT_mul_fork #2\Z #3\Z }% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% }% \def\XINT_cstf_loop_c #1#2% {% @@ -15506,8 +16713,8 @@ first place. \def\XINT_icstf_loop_b #1.#2#3#4#5% {% \expandafter\XINT_icstf_loop_c\expandafter - {\romannumeral0\xintiadd {#5}{\XINT_Mul {#1}{#3}}}% - {\romannumeral0\xintiadd {#4}{\XINT_Mul {#1}{#2}}}% + {\romannumeral0\xintiiadd {#5}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {#4}{\XINT_Mul {#1}{#2}}}% {#2}{#3}% }% \def\XINT_icstf_loop_c #1#2% @@ -15537,8 +16744,8 @@ first place. \expandafter\XINT_gctf_loop_c\expandafter {\romannumeral0\XINT_mul_fork #2\Z #4\Z }% {\romannumeral0\XINT_mul_fork #2\Z #3\Z }% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% }% \def\XINT_gctf_loop_c #1#2% {% @@ -15599,8 +16806,8 @@ first place. \def\XINT_igctf_loop_b #1.#2#3#4#5% {% \expandafter\XINT_igctf_loop_c\expandafter - {\romannumeral0\xintiadd {#5}{\XINT_Mul {#1}{#3}}}% - {\romannumeral0\xintiadd {#4}{\XINT_Mul {#1}{#2}}}% + {\romannumeral0\xintiiadd {#5}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {#4}{\XINT_Mul {#1}{#2}}}% {#2}{#3}% }% \def\XINT_igctf_loop_c #1#2% @@ -15651,8 +16858,8 @@ first place. \expandafter\XINT_cstcv_loop_c\expandafter {\romannumeral0\XINT_mul_fork #2\Z #4\Z }% {\romannumeral0\XINT_mul_fork #2\Z #3\Z }% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% }% \def\XINT_cstcv_loop_c #1#2% {% @@ -15694,8 +16901,8 @@ first place. \def\XINT_icstcv_loop_b #1.#2#3#4#5% {% \expandafter\XINT_icstcv_loop_c\expandafter - {\romannumeral0\xintiadd {#5}{\XINT_Mul {#1}{#3}}}% - {\romannumeral0\xintiadd {#4}{\XINT_Mul {#1}{#2}}}% + {\romannumeral0\xintiiadd {#5}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {#4}{\XINT_Mul {#1}{#2}}}% {{#2}{#3}}% }% \def\XINT_icstcv_loop_c #1#2% @@ -15731,8 +16938,8 @@ first place. \expandafter\XINT_gctcv_loop_c\expandafter {\romannumeral0\XINT_mul_fork #2\Z #4\Z }% {\romannumeral0\XINT_mul_fork #2\Z #3\Z }% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% }% \def\XINT_gctcv_loop_c #1#2% {% @@ -15803,8 +17010,8 @@ first place. \def\XINT_igctcv_loop_b #1.#2#3#4#5% {% \expandafter\XINT_igctcv_loop_c\expandafter - {\romannumeral0\xintiadd {#5}{\XINT_Mul {#1}{#3}}}% - {\romannumeral0\xintiadd {#4}{\XINT_Mul {#1}{#2}}}% + {\romannumeral0\xintiiadd {#5}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {#4}{\XINT_Mul {#1}{#2}}}% {{#2}{#3}}% }% \def\XINT_igctcv_loop_c #1#2% @@ -16080,31 +17287,93 @@ first place. %\def<*xintexpr>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12 } %</xintcfrac> %<*xintexpr> +% +% \StoreCodelineNo {xintcfrac} +% % \section{Package \xintexprname implementation} % -% The commenting is currently (\docdate) very sparse. I was greatly helped in -% the task of writing this expandable parser by the comments provided in +% The first version was released in June 2013. I was greatly helped in +% this task of writing an expandable parser of infix operations by the +% comments provided in % |l3fp-parse.dtx|. One will recognize in particular the idea of the `until' -% macros; but I have not looked into the actual |l3fp| code beyond the very -% useful comments provided in its documentation. My main hurdle was that my data -% has no a priori bound on its size; this led me to experiment with a technique +% macros; I have not looked into the actual |l3fp| code beyond the very +% useful comments provided in its documentation. +% +% A main worry was that my data +% has no a priori bound on its size; to keep the code reasonably +% efficient, I experimented with a +% technique % of storing and retrieving data expandably as \emph{names} of control -% sequences. Also brace pairs have a special rôle related to the parsing of -% |A/B[n]| fractions; this is \emph{experimental} and perhaps I will opt for -% another solution at a later stage, -% for example one where such fractions should be user-prefixed by some marker, -% for example |!| (which could not be confused there with its other use as -% postfix symbol for the factorial function). There are thus some essential -% differences of principle with the |l3fp| workplan. Of course, my task was -% on the other hand simplified by the fact that I do not implement boolean -% operators nor function names. To circumvent the potential hash-table impact I +% sequences. Intermediate computation results are stored as control sequences +% |\.a/b[n]|. +% +% Another peculiarity is that the input is allowed to contain (but only +% where the scanner looks for a +% number or fraction) material within braces |{...}|. This will be +% expanded completely and must give an integer, decimal number or fraction +% (not in scientific notation). Conversely any fraction (or macro giving +% on expansion one such; of course this does not apply to intermediate +% computation results, only to user input) in the +% |A/B[n]| format \emph{with the brackets} \textbf{must} be enclosed in +% such braces, square brackets +% are not acceptable by the expression parser. +% +% These two things are a bit \emph{experimental} and perhaps I will opt for +% another approach at a later stage. To circumvent the potential hash-table +% impact of the |\.a/b[n]| I % have provided the macro creators |\xintNewExpr| and |\xintNewFloatExpr|. % -% Version |1.08b| tries to correct a problem originating in the attempt to +% Roughly speaking, the parser mechanism is as follows: at any given time the +% last found +% ``operator'' has its associated |until| macro awaiting some news from the +% token +% flow; first |getnext| expands forward in the hope to construct some +% number, which may come from a parenthesized sub-expression, from some +% braced material, or from a digit by digit scan. After this number has +% been formed the next operator is looked for by the |getop| macro. Once |getop| +% has finished its job, |until| is presented with three tokens: the first one is +% the precedence level of the new found operator (which may be an end of +% expression marker), the second is the operator character token (earlier +% versions had here already some macro name, but in order to keep as much common +% code to expr and floatexpr common as possible, this was modied) of the new +% found +% operator, and the third +% one is the newly found number (which was encountered just before the +% new operator). +% +% The +% |until| macro of the earlier operator examines the precedence level of +% the new found one, and either executes the earlier operator (in the case of +% a binary operation, with the found number and a previously stored one) or it +% delays execution, giving the hand to the |until| macro of the operator +% having been found of higher precedence. +% +% A minus sign acting as +% prefix gets converted into a (unary) operator +% inheriting the precedence level of the previous operator. +% +% Once the end of the expression is found (it has to be marked by a |\relax|) +% the final result is output as four tokens: the first one a catcode 11 +% exclamation mark, the second one an error generating macro, the third one a +% printing macro and +% the fourth is |\.a/b[n]|. The prefix +% |\xintthe| makes the output printable by killing the first two tokens. +% +% Version |1.08b| |[2013/06/14]| corrected a problem originating in the +% attempt to % attribute a special rôle to braces: expansion could be stopped by space % tokens, as various macros tried to expand without grabbing what came next. % They now have a doubled |\romannumeral-`0|. % +% Version |1.09a| |[2013/09/24]| has a better mechanism regarding |\xintthe|, +% more commenting and better organization of the code, and most +% importantly it implements functions, comparison operators, logic operators, +% conditionals. The code was reorganized and expansion proceeds a bit +% differently in order to have the |_getnext| and |_getop| codes entirely +% shared by |\xintexpr| and |\xintfloatexpr|. |\xintNewExpr| was rewritten in +% order to work with the standard macro parameter character |#|, to be catcode +% protected and to also allow comma separated expressions. +% % \localtableofcontents % \subsection{Catcodes, \protect\eTeX{} and reload detection} % @@ -16215,6 +17484,10 @@ first place. \endgroup \edef\XINT_expr_restorecatcodes_endinput {% + \catcode63=\the\catcode63 % ? + \catcode124=\the\catcode124 % | + \catcode38=\the\catcode38 % & + \catcode64=\the\catcode64 % @ \catcode33=\the\catcode33 % ! \catcode93=\the\catcode93 % ] \catcode91=\the\catcode91 % [ @@ -16242,17 +17515,20 @@ first place. \noexpand\endinput }% \XINT_setcatcodes % defined in xint.sty - \catcode91=12 % [ - \catcode93=12 % ] - \catcode33=11 % ! + \catcode91=12 % [ + \catcode93=12 % ] + \catcode33=11 % ! + \catcode64=11 % @ + \catcode38=12 % & + \catcode124=12 % | + \catcode63=11 % ? }% \x % \end{macrocode} % \subsection{Package identification} % \begin{macrocode} \begingroup - \catcode64=11 % @ - \catcode58=12 % : + \catcode58=12 % : (but doesn't matter) \expandafter\ifx\csname ProvidesPackage\endcsname\relax \def\x#1#2#3[#4]{\endgroup \immediate\write-1{Package: #3 #4}% @@ -16271,222 +17547,85 @@ first place. \fi \expandafter\x\csname ver@xintexpr.sty\endcsname \ProvidesPackage{xintexpr}% - [2013/06/14 v1.08b Expandable expression parser (jfB)]% + [2013/09/24 v1.09a Expandable expression parser (jfB)]% % \end{macrocode} % \subsection{Helper macros} % \begin{macrocode} \def\xint_gob_til_dot #1.{}% \def\xint_gob_til_dot_andstop #1.{ }% -\def\xint_gob_til_! #1!{}% ! of catcode 11 -\def\XINT_expr_string {\expandafter\xint_gob_til_dot\string }% +\def\xint_gob_til_! #1!{}% nota bene: ! is of catcode 11 \def\XINT_expr_unexpectedtoken {\xintError:ignored }% +\def\XINT_newexpr_stripprefix #1>{\noexpand\romannumeral-`0}% +\def\xint_firstofone #1{#1}% % \end{macrocode} -% \subsection{\csh{xintexpr},~\csh{xinttheexpr},~\csh{xintthe}} +% \subsection{Encapsulation in pseudo names} % \begin{macrocode} -\def\xintexpr {\romannumeral0\xinteval }% -\def\xinteval -{% - \expandafter\XINT_expr_until_end\romannumeral-`0% - \expandafter\XINT_expr_checkifprefix_ii\romannumeral-`0% - \XINT_expr_getnext -}% -\def\xinttheexpr {\romannumeral0\xinttheeval }% -\def\xinttheeval {\expandafter\XINT_expr_the\romannumeral0\xinteval }% -\def\XINT_expr_the #1#2#3{\xintraw{\XINT_expr_string #3}}% -\def\xintthe #1{\ifx#1\xintexpr \expandafter\xinttheexpr - \else\expandafter\xintthefloatexpr\fi}% -% \end{macrocode} -% \subsection{Parenthesized expressions} -% \begin{macrocode} -\def\XINT_expr_until_end #1% -{% - \ifcase#1% - \expandafter\xint_gobble_vi - \or - \expandafter\XINT_expr_extra_closing_paren - \fi - \expandafter\XINT_expr_until_end\romannumeral-`0\romannumeral-`0% -}% -\def\XINT_expr_extra_closing_paren {\xintError:removed }% -\def\XINT_expr_endofexpr {!\XINT_illegaluse }% -\def\XINT_illegaluse - {Illegal_here_use_xintthe\xintError:use_xintthe!\xint_gobble_i }% -\def\XINT_expr_oparen -{% - \expandafter\XINT_expr_until_cparen\romannumeral-`0% - \expandafter\XINT_expr_checkifprefix_ii\romannumeral-`0% - \XINT_expr_getnext -}% -\def\XINT_expr_until_cparen #1% -{% - \ifcase#1% - \expandafter\XINT_expr_missing_cparen - \or - \else \xint_afterfi - {\expandafter\XINT_expr_until_cparen\romannumeral-`0\romannumeral-`0}% - \fi -}% -\def\XINT_expr_missing_cparen #1% -{% - \xintError:inserted \xint_c_ \XINT_expr_endofexpr -}% -% \end{macrocode} -% \subsection{Infix operators, minus as prefix, scientific notation} -% \begin{macrocode} -\def\xint_tmp_def #1#2#3% -{% - \expandafter\xint_tmp_do_defs - \csname XINT_expr_op_#1\expandafter\endcsname - \csname XINT_expr_until_#1\expandafter\endcsname - \csname XINT_expr_checkifprefix_#2\expandafter\endcsname - \csname XINT_expr_precedence_#1\expandafter\endcsname - \csname xint_c_#2\expandafter\endcsname - \csname xint#3\endcsname -}% -\def\xint_tmp_do_defs #1#2#3#4#5#6% -{% - \def #1##1% \XINT_expr_op_? - {% - \expandafter #2\expandafter ##1\romannumeral-`0\expandafter - #3\romannumeral-`0\XINT_expr_getnext - }% - \def #2##1##2##3##4% \XINT_expr_until_? - {% - \ifnum ##2>#5% - \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0##3##4}% - \else - \xint_afterfi - {\expandafter ##2\expandafter ##3% - \csname .#6{\XINT_expr_string ##1}{\XINT_expr_string ##4}\endcsname }% - \fi - }% - \let #4#5% -}% -\xint_tmp_def +{ii}{Add}% -\xint_tmp_def -{ii}{Sub}% -\xint_tmp_def *{iii}{Mul}% -\xint_tmp_def /{iii}{Div}% -\xint_tmp_def ^{iv}{Pow}% -\xint_tmp_def e{v}{fE}% -\xint_tmp_def E{v}{fE}% -\def\xint_tmp_def #1% -{% - \expandafter\xint_tmp_do_defs - \csname XINT_expr_checkifprefix_#1\expandafter\endcsname - \csname XINT_expr_op_-#1\endcsname -}% -\def\xint_tmp_do_defs #1#2% -{% - \def #1##1% - {\xint_UDsignfork - ##1\dummy #2% - -\dummy ##1% - \krof }% -}% -\xint_tmp_def {ii}% -\xint_tmp_def {iii}% -\xint_tmp_def {iv}% -\xint_tmp_def {v}% -\def\xint_tmp_def #1% -{% - \expandafter\xint_tmp_do_defs - \csname XINT_expr_op_-#1\expandafter\endcsname - \csname XINT_expr_until_-#1\expandafter\endcsname - \csname XINT_expr_checkifprefix_#1\expandafter\endcsname - \csname xint_c_#1\endcsname -}% -\def\xint_tmp_do_defs #1#2#3#4% -{% - \def #1% \XINT_expr_op_-ii,iii,iv,v - {% - \expandafter #2\romannumeral-`0\expandafter - #3\romannumeral-`0\XINT_expr_getnext - }% - \def #2##1##2##3% \XINT_expr_until_-ii,iii,iv,v - {% - \ifnum ##1>#4% - \xint_afterfi {\expandafter #2\romannumeral-`0##2##3}% - \else - \xint_afterfi {\expandafter ##1\expandafter ##2% - \csname .\xintOpp{\XINT_expr_string ##3}\endcsname }% - \fi - }% -}% -\xint_tmp_def {ii}% -\xint_tmp_def {iii}% -\xint_tmp_def {iv}% -\xint_tmp_def {v}% +\def\XINT_expr_lock #1!{\expandafter\space\csname .#1\endcsname }% +\def\XINT_expr_unlock {\expandafter\xint_gob_til_dot\string }% +\def\XINT_expr_usethe {use_xintthe!\xintError:use_xintthe! }% +\def\XINT_expr_done {!\XINT_expr_usethe\XINT_expr_print }% +\def\XINT_expr_print #1{\XINT_expr_unlock #1}% +\def\XINT_flexpr_done {!\XINT_expr_usethe\XINT_flexpr_print }% +\def\XINT_flexpr_print #1{\xintFloat:csv{\XINT_expr_unlock #1}}% +\def\XINT_numexpr_print #1{\xintRound:csv{\XINT_expr_unlock #1}}% % \end{macrocode} -% \subsection{Get next infix operator or closing parenthesis or factorial or -% expression end} -% \lverb|June 14 (1.08b): I add here a second \romannumeral-`0, as in -% \XINT_expr_getnext and other macros which are trying to expand the next token -% but without grabbing it.| +% \subsection{\csh{xintexpr},~\csh{xinttheexpr},~\csh{xintthe}} % \begin{macrocode} -\def\XINT_expr_getop #1% -{% - \expandafter\XINT_expr_getop_a\expandafter #1% - \romannumeral-`0\romannumeral-`0% -}% -\def\XINT_expr_getop_a #1#2% -{% - \ifcat #2\relax - \ifx #2\relax - \expandafter\expandafter\expandafter - \XINT_expr_foundendofexpr - \else - \XINT_expr_unexpectedtoken - \expandafter\expandafter\expandafter - \XINT_expr_getop - \fi - \else - \expandafter\XINT_expr_op_found\expandafter #2% - \fi - #1% -}% -\def\XINT_expr_foundendofexpr {\xint_c_ \XINT_expr_endofexpr }% -\def\XINT_expr_op_found #1% +\def\xintexpr {\romannumeral0\xinteval }% +\def\xinteval {% - \ifcsname XINT_expr_precedence_\string #1\endcsname - \expandafter\xint_afterfi\expandafter - {\csname XINT_expr_precedence_\string #1\expandafter\endcsname - \csname XINT_expr_op_\string #1\endcsname }% - \else - \XINT_expr_unexpectedtoken - \expandafter\XINT_expr_getop - \fi -}% -\expandafter\let\csname XINT_expr_precedence_)\endcsname \xint_c_i -\expandafter\let\csname XINT_expr_op_)\endcsname\XINT_expr_getop -\def\xint_tmp_def -{% - \expandafter\xint_tmp_do_defs - \csname XINT_expr_precedence_!\expandafter\endcsname - \csname XINT_expr_op_!\endcsname + \expandafter\XINT_expr_until_end_a \romannumeral-`0\XINT_expr_getnext }% -\def\xint_tmp_do_defs #1#2% +\def\xinttheeval {\expandafter\xint_gobble_ii\romannumeral0\xinteval }% +\def\xinttheexpr {\romannumeral-`0\xinttheeval }% +\def\XINT_numexpr_post !\XINT_expr_usethe\XINT_expr_print% + { !\XINT_expr_usethe\XINT_numexpr_print }% +\def\xintnumexpr {\romannumeral0\expandafter\XINT_numexpr_post + \romannumeral0\xinteval }% +\def\xintthenumexpr {\romannumeral-`0\xintthe\xintnumexpr }% +\def\xintfloatexpr {\romannumeral0\xintfloateval }% +\def\xintfloateval {% - \def #1##1##2% - {\ifx ##1#2% - \expandafter\xint_firstoftwo - \else\expandafter\xint_secondoftwo - \fi{\expandafter\XINT_expr_getop}{\expandafter\XINT_flexpr_getop}% - \csname .\xintFac{\XINT_expr_string ##2}/1[0]\endcsname }% - \let#2\empty + \expandafter\XINT_flexpr_until_end_a \romannumeral-`0\XINT_expr_getnext }% -\xint_tmp_def +\def\xintthefloatexpr {\romannumeral-`0\xintthe\xintfloatexpr }% +\def\xintthe #1{\romannumeral-`0\expandafter\xint_gobble_ii\romannumeral-`0#1}% % \end{macrocode} -% \subsection{Get next opening parenthesis or minus prefix or decimal number or -% braced fraction or sub-xintexpression} +% \subsection{\csh{XINT\_get\_next}: looking for a number} % \lverb|June 14: 1.08b adds a second \romannumeral-`0 to \XINT_expr_getnext in % an attempt to solve a problem with space tokens stopping the \romannumeral % and thus preventing expansion of the following token. For example: 1+ % \the\cnta caused a problem, as `\the' was not expanded. I did not define % \XINT_expr_getnext as a macro with parameter (which would have cured % preventively this), precisely to try to recognize brace pairs. The second -% \romannumeral-`0 is added here for the same reason in other places: -% \XINT_expr_scannum_intpart_b, \XINT_expr_scannum_transition, -% \XINT_expr_scannum_decpart_b, and \XINT_expr_getop.| +% \romannumeral-`0 is added for the same reason in other places. +% +% The get-next scans forward to find a number: after expansion of what +% comes next, an opening parenthesis signals a parenthesized +% sub-expression, a ! with catcode 11 signals there was there an +% \xintexpr.. \relax sub-expression (now evaluated), a minus is a prefix +% operator, a plus +% is silently ignored, a digit or decimal point signals to start gathering +% a number, braced material {...} is allowed and will be directly fed +% into a \csname..\endcsname for complete expansion which must delivers a +% (fractional) number, possibly ending in [n]; explicit square brackets +% must be enclosed into such braces. Once a number issues from the +% previous procedures, it is a locked into a \csname...\endcsname, and the +% flow then proceeds with \XINT_expr_getop which will scan for an infix +% or postfix operator following the number. +% +% A special r\^ole is played by underscores _ for use with \xintNewExpr +% to input macro parameters. +% +% Release 1.09a implements functions; the idea is that a letter +% (actually, anything not otherwise recognized!) +% triggers the function name gatherer, the comma is +% promoted to a binary operator of +% priority intermediate between parentheses and infix operators. The code had +% some other revisions in order for all the _getnext and _getop macros to now be +% shared by \xintexpr and \xintflexpr. Perhaps some of the comments are now +% obsolete. +% | % \begin{macrocode} \def\XINT_expr_getnext {% @@ -16521,308 +17660,732 @@ first place. #2\dummy \XINT_expr_getnext_onetoken_wehope \W\dummy \XINT_expr_getnext_gotbracedstuff \krof -}% +}% doubly braced things are not acceptable, will cause errors. \def\XINT_expr_getnext_emptybracepair #1{\XINT_expr_getnext }% -\def\XINT_expr_getnext_gotbracedstuff #1\W\Z #2% +\def\XINT_expr_getnext_gotbracedstuff #1\W\Z #2% {..} -> number/fraction {% \expandafter\XINT_expr_getop\csname .#2\endcsname }% -\def\XINT_expr_getnext_onetoken_wehope\Z #1% +\def\XINT_expr_getnext_onetoken_wehope\Z #1% #1 isn't a control sequence! {% \xint_gob_til_! #1\XINT_expr_subexpr !% \expandafter\XINT_expr_getnext_onetoken_fork\string #1% -}% -\def\XINT_expr_subexpr !#1!{\expandafter\XINT_expr_getop\xint_gobble_i }% +}% after this #1 should be now a catcode 12 token. +\def\XINT_expr_subexpr !#1!{\expandafter\XINT_expr_getop\xint_gobble_ii }% +% \end{macrocode} +% \lverb|1.09a: In order to have this code shared by \xintexpr and +% \xintfloatexpr, I +% have moved to the until macros the responsability to choose expr or floatexpr, +% hence here, the opening parenthesis for example can not be triggered directly +% as it would not know in which context it works. Hence the \xint_c_x ({}. And +% also the mechanism of \xintNewExpr has been modified to allow use of #. | +% \begin{macrocode} \begingroup -\lccode`*=`_ +\lccode`*=`# \lowercase{\endgroup \def\XINT_expr_sixwayfork #1(-.+*\dummy #2#3\krof {#2}% \def\XINT_expr_getnext_onetoken_fork #1% -{% +{% The * is in truth catcode 12 #. For (clever!) use with \xintNewExpr. \XINT_expr_sixwayfork - #1-.+*\dummy \XINT_expr_oparen + #1-.+*\dummy {\xint_c_x ({}}% back to until to trigger oparen (#1.+*\dummy -% - (-#1+*\dummy {\XINT_expr_scannum_start\XINT_expr_scannum_decpart_b.}% + (-#1+*\dummy {\XINT_expr_scandec_II.}% (-.#1*\dummy \XINT_expr_getnext% - (-.+#1\dummy {\XINT_expr_scannum_start\XINT_expr_scannum_decpart_b*}% - (-.+*\dummy {\XINT_expr_scannum_check #1}% + (-.+#1\dummy {\XINT_expr_scandec_II}% + (-.+*\dummy {\XINT_expr_scan_dec_or_func #1}% \krof }}% -\def\XINT_expr_scannum_check #1% +% \end{macrocode} +% \subsection{\csh{XINT\_expr\_scan\_dec\_or\_func}: collecting an integer or +% decimal number or function name} +% \begin{macrocode} +\def\XINT_expr_scan_dec_or_func #1% this #1 of catcode 12 {% \ifnum \xint_c_ix<1#1 - \expandafter\XINT_expr_scannum_start + \expandafter\XINT_expr_scandec_I + \else % We assume we are dealing with a function name!! + \expandafter\XINT_expr_scanfunc + \fi #1% +}% +\def\XINT_expr_scanfunc +{% + \expandafter\XINT_expr_func\romannumeral-`0\XINT_expr_scanfunc_c +}% +\def\XINT_expr_scanfunc_c #1% +{% + \expandafter #1\romannumeral-`0\expandafter + \XINT_expr_scanfunc_a\romannumeral-`0\romannumeral-`0% +}% +\def\XINT_expr_scanfunc_a #1% please no braced things here! +{% + \ifcat #1\relax % missing opening parenthesis, probably + \expandafter\XINT_expr_scanfunc_panic \else - \xint_afterfi{\XINT_expr_unexpectedtoken - \expandafter\XINT_expr_getnext\xint_gobble_ii}% - \fi \XINT_expr_scannum_intpart_b #1% + \xint_afterfi{\expandafter\XINT_expr_scanfunc_b \string #1}% + \fi +}% +\def\XINT_expr_scanfunc_b #1% +{% + \if #1(\else\expandafter \XINT_expr_scanfunc_c \fi #1% +}% +\def\XINT_expr_scanfunc_panic {\xintError:bigtroubleahead(0\relax }% +% \end{macrocode} +% \lverb|1.09a: functions are a new component, and here also we do not know if +% we are in an \xintexpr or an \xintfloatexpr. Hence the method with the @.| +% \begin{macrocode} +\def\XINT_expr_func #1(% common to expr and flexpr +{% + \xint_c_x @{#1}% }% -\def\XINT_expr_scannum_stopscan {!}% ! catcode 11 -\def\XINT_expr_gathernum #1!% ! with catcode 11 +\def\XINT_expr_scandec_I {% - \expandafter\space\csname .#1\endcsname + \expandafter\XINT_expr_getop\romannumeral-`0\expandafter + \XINT_expr_lock\romannumeral-`0\XINT_expr_scanintpart_b }% -\def\XINT_expr_scannum_start #1% +\def\XINT_expr_scandec_II {% - \expandafter\XINT_expr_getop - \romannumeral-`0\expandafter\XINT_expr_gathernum - \romannumeral-`0#1% + \expandafter\XINT_expr_getop\romannumeral-`0\expandafter + \XINT_expr_lock\romannumeral-`0\XINT_expr_scanfracpart_b }% -\def\XINT_expr_scannum_intpart_a #1% +\def\XINT_expr_scanintpart_a #1% {% \ifnum \xint_c_ix<1\string#1 - \expandafter\expandafter\expandafter - \XINT_expr_scannum_intpart_b + \expandafter\expandafter\expandafter\XINT_expr_scanintpart_b \expandafter\string \else \if #1.% \expandafter\expandafter\expandafter - \XINT_expr_scannum_transition + \XINT_expr_scandec_transition \else - \expandafter\expandafter\expandafter - \XINT_expr_scannum_stopscan + \expandafter\expandafter\expandafter !% ! of catcode 11... \fi \fi #1% }% -\def\XINT_expr_scannum_intpart_b #1% +\def\XINT_expr_scanintpart_b #1% {% \expandafter #1\romannumeral-`0\expandafter - \XINT_expr_scannum_intpart_a\romannumeral-`0\romannumeral-`0% + \XINT_expr_scanintpart_a\romannumeral-`0\romannumeral-`0% }% -\def\XINT_expr_scannum_transition #1% +\def\XINT_expr_scandec_transition #1% {% \expandafter.\romannumeral-`0\expandafter - \XINT_expr_scannum_decpart_a\romannumeral-`0\romannumeral-`0% + \XINT_expr_scanfracpart_a\romannumeral-`0\romannumeral-`0% }% -\def\XINT_expr_scannum_decpart_a #1% +\def\XINT_expr_scanfracpart_a #1% {% \ifnum \xint_c_ix<1\string#1 - \expandafter\expandafter\expandafter - \XINT_expr_scannum_decpart_b\expandafter\string + \expandafter\expandafter\expandafter\XINT_expr_scanfracpart_b + \expandafter\string \else - \expandafter \XINT_expr_scannum_stopscan + \expandafter !% \fi #1% }% -\def\XINT_expr_scannum_decpart_b #1% +\def\XINT_expr_scanfracpart_b #1% {% \expandafter #1\romannumeral-`0\expandafter - \XINT_expr_scannum_decpart_a\romannumeral-`0\romannumeral-`0% + \XINT_expr_scanfracpart_a\romannumeral-`0\romannumeral-`0% }% % \end{macrocode} -% \subsection{\csh{xintfloatexpr},~\csh{xintthefloatexpr}} -% \lverb|1.08b: various doublings of \romannumeral-`0 to avoid some -% expansion/space token problems| +% \subsection{\csh{XINT\_expr\_getop}: looking for an operator} +% \lverb|June 14 (1.08b): I add here a second \romannumeral-`0, because +% \XINT_expr_getnext and others try to expand the next token +% but without grabbing it. +% +% This finds the next infix operator or closing parenthesis or postfix +% exclamation mark ! +% or expression end. It then leaves in the token flow +% <precedence> <operator> <locked number>. The <precedence> is generally +% a character command which thus stops expansion and gives back control to an +% \XINT_expr_until_<op> command; or it is the minus sign which will be +% converted by a suitable \XINT_expr_checkifprefix_<p> into an operator +% with a given inherited precedence; or, in the case of the postfix!, +% <precedence> is +% \empty, expansion goes on with <operator_!> which does the factorial +% on the locked number and then re-activates \XINT_expr_getop. +% +% In versions earlier than 1.09a the <operator> was already made in to a control +% sequence; but now it is a left as a token and will be converted by the until +% macro which knows if it is in a \xintexpr or an \xintfloatexpr. +% | % \begin{macrocode} -\def\xintfloatexpr {\romannumeral0\xintfloateval }% -\def\xintfloateval +\def\XINT_expr_getop #1% this #1 is the current locked computed value +{% full expansion of next token, first swallowing a possible space + \expandafter\XINT_expr_getop_a\expandafter #1% + \romannumeral-`0\romannumeral-`0% +}% +\def\XINT_expr_getop_a #1#2% +{% if an un-expandable control sequence is found, must be the ending \relax + \ifcat #2\relax + \ifx #2\relax + \expandafter\expandafter\expandafter + \XINT_expr_foundend + \else + \XINT_expr_unexpectedtoken + \expandafter\expandafter\expandafter + \XINT_expr_getop + \fi + \else + \expandafter\XINT_expr_foundop\expandafter #2% + \fi + #1% +}% +\def\XINT_expr_foundend {\xint_c_ \relax }% \relax is a place holder here. +\def\XINT_expr_foundop #1% then becomes <prec> <op> and is followed by <\.f> +{% 1.09a: no control sequence \XINT_expr_op_#1, code common to expr/flexpr + \ifcsname XINT_expr_precedence_#1\endcsname + \expandafter\xint_afterfi\expandafter + {\csname XINT_expr_precedence_#1\endcsname #1}% + \else + \XINT_expr_unexpectedtoken + \expandafter\XINT_expr_getop + \fi +}% +% \end{macrocode} +% \subsection{Parentheses} +% \lverb|1.09a removes some doubling of \romannumeral-`\0 from 1.08b +% which served no useful purpose here (I think...). | +% \begin{macrocode} +\def\xint_tmp_do_defs #1#2#3#4#5% {% - \expandafter\XINT_expr_until_end\romannumeral-`0% - \expandafter\XINT_flexpr_checkifprefix_ii\romannumeral-`0% - \XINT_flexpr_getnext + \def#1##1% + {% + \xint_UDsignfork + ##1\dummy {\expandafter#1\romannumeral-`0#3}% + -\dummy {#2##1}% + \krof + }% + \def#2##1##2% + {% + \ifcase ##1\expandafter #4% + \or \xint_afterfi{% + \XINT_expr_extra_closing_paren + \expandafter #1\romannumeral-`0\XINT_expr_getop + }% + \else \xint_afterfi{% + \expandafter#1\romannumeral-`0\csname XINT_#5_op_##2\endcsname + }% + \fi + }% }% -\def\xintthefloatexpr {\romannumeral0\xintthefloateval }% -\def\xintthefloateval - {\expandafter\XINT_flexpr_the\romannumeral0\xintfloateval }% -\def\XINT_flexpr_the #1#2#3{\xintfloat{\XINT_expr_string #3}}% -\def\XINT_flexpr_oparen +\expandafter\xint_tmp_do_defs + \csname XINT_expr_until_end_a\expandafter\endcsname + \csname XINT_expr_until_end_b\expandafter\endcsname + \csname XINT_expr_op_-vi\expandafter\endcsname + \csname XINT_expr_done\endcsname + {expr}% +\expandafter\xint_tmp_do_defs + \csname XINT_flexpr_until_end_a\expandafter\endcsname + \csname XINT_flexpr_until_end_b\expandafter\endcsname + \csname XINT_flexpr_op_-vi\expandafter\endcsname + \csname XINT_flexpr_done\endcsname + {flexpr}% +\def\XINT_expr_extra_closing_paren {\xintError:removed }% +\def\xint_tmp_do_defs #1#2#3#4#5#6% {% - \expandafter\XINT_expr_until_cparen\romannumeral-`0% - \expandafter\XINT_flexpr_checkifprefix_ii\romannumeral-`0% - \XINT_flexpr_getnext -}% -\def\xint_tmp_def #1#2#3% + \def #1{\expandafter #3\romannumeral-`0\XINT_expr_getnext }% + \let #2#1% + \def #3##1{\xint_UDsignfork + ##1\dummy {\expandafter #3\romannumeral-`0#5}% + -\dummy {#4##1}% + \krof }% + \def #4##1##2% + {% + \ifcase ##1\expandafter \XINT_expr_missing_cparen + \or \expandafter \XINT_expr_getop + \else \xint_afterfi + {\expandafter #3\romannumeral-`0\csname XINT_#6_op_##2\endcsname }% + \fi + }% +}% +\expandafter\xint_tmp_do_defs + \csname XINT_expr_op_(\expandafter\endcsname + \csname XINT_expr_oparen\expandafter\endcsname + \csname XINT_expr_until_)_a\expandafter\endcsname + \csname XINT_expr_until_)_b\expandafter\endcsname + \csname XINT_expr_op_-vi\endcsname + {expr}% +\expandafter\xint_tmp_do_defs + \csname XINT_flexpr_op_(\expandafter\endcsname + \csname XINT_flexpr_oparen\expandafter\endcsname + \csname XINT_flexpr_until_)_a\expandafter\endcsname + \csname XINT_flexpr_until_)_b\expandafter\endcsname + \csname XINT_flexpr_op_-vi\endcsname + {flexpr}% +\def\XINT_expr_missing_cparen {\xintError:inserted \xint_c_ \XINT_expr_done }% +\expandafter\let\csname XINT_expr_precedence_)\endcsname \xint_c_i +\expandafter\let\csname XINT_expr_op_)\endcsname\XINT_expr_getop +\expandafter\let\csname XINT_flexpr_precedence_)\endcsname \xint_c_i +\expandafter\let\csname XINT_flexpr_op_)\endcsname\XINT_expr_getop +% \end{macrocode} +% \subsection{The \csh{XINT\_expr\_until\_<op>} macros for boolean operators, +% comparison operators, arithmetic operators, scientfic notation.} +% \lverb|Extended in 1.09a with comparison and boolean operators.| +% \begin{macrocode} +\def\xint_tmp_def #1#2#3#4#5#6% {% \expandafter\xint_tmp_do_defs - \csname XINT_flexpr_op_#1\expandafter\endcsname - \csname XINT_flexpr_until_#1\expandafter\endcsname - \csname XINT_flexpr_checkifprefix_#2\expandafter\endcsname - \csname XINT_expr_precedence_#1\expandafter\endcsname - \csname xint_c_#2\expandafter\endcsname - \csname XINTinFloat#3\endcsname -}% + \csname XINT_#1_op_#3\expandafter\endcsname + \csname XINT_#1_until_#3_a\expandafter\endcsname + \csname XINT_#1_until_#3_b\expandafter\endcsname + \csname XINT_#1_op_-#5\expandafter\endcsname + \csname xint_c_#4\expandafter\endcsname + \csname #2#6\expandafter\endcsname + \csname XINT_expr_precedence_#3\endcsname {#1}% +}% +\def\xint_tmp_do_defs #1#2#3#4#5#6#7#8% +{% + \def #1##1% \XINT_expr_op_<op> + {% keep value, get next number and operator, then do until + \expandafter #2\expandafter ##1% + \romannumeral-`0\expandafter\XINT_expr_getnext + }% + \def #2##1##2% \XINT_expr_until_<op>_a + {\xint_UDsignfork + ##2\dummy {\expandafter #2\expandafter ##1\romannumeral-`0#4}% + -\dummy {#3##1##2}% + \krof }% + \def #3##1##2##3##4% \XINT_expr_until_<op>_b + {% either execute next operation now, or first do next (possibly unary) + \ifnum ##2>#5% + \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0% + \csname XINT_#8_op_##3\endcsname {##4}}% + \else + \xint_afterfi + {\expandafter ##2\expandafter ##3% + \csname .#6{\XINT_expr_unlock ##1}{\XINT_expr_unlock ##4}\endcsname }% + \fi + }% + \let #7#5% +}% +\def\xint_tmp_def_a #1{\xint_tmp_def {expr}{xint}#1}% +\xintApplyInline {\xint_tmp_def_a }{% + {|{iii}{vi}{OR}}% + {&{iv}{vi}{AND}}% + {<{v}{vi}{Lt}}% + {>{v}{vi}{Gt}}% + {={v}{vi}{Eq}}% + {+{vi}{vi}{Add}}% + {-{vi}{vi}{Sub}}% + {*{vii}{vii}{Mul}}% + {/{vii}{vii}{Div}}% + {^{viii}{viii}{Pow}}% + {e{ix}{ix}{fE}}% + {E{ix}{ix}{fE}}% +}% +\def\xint_tmp_def_a #1{\xint_tmp_def {flexpr}{xint}#1}% +\xintApplyInline {\xint_tmp_def_a }{% + {|{iii}{vi}{OR}}% + {&{iv}{vi}{AND}}% + {<{v}{vi}{Lt}}% + {>{v}{vi}{Gt}}% + {={v}{vi}{Eq}}% +}% +\def\xint_tmp_def_a #1{\xint_tmp_def {flexpr}{XINTinFloat}#1}% +\xintApplyInline {\xint_tmp_def_a }{% + {+{vi}{vi}{Add}}% + {-{vi}{vi}{Sub}}% + {*{vii}{vii}{Mul}}% + {/{vii}{vii}{Div}}% + {^{viii}{viii}{Power}}% + {e{ix}{ix}{fE}}% + {E{ix}{ix}{fE}}% +}% +\let\xint_tmp_def_a\empty +% \end{macrocode} +% \subsection{The comma as binary operator} +% \lverb|New with 1.09a.| +% \begin{macrocode} \def\xint_tmp_do_defs #1#2#3#4#5#6% {% - \def #1##1% \XINT_flexpr_op_? + \def #1##1% \XINT_expr_op_,_a {% - \expandafter #2\expandafter ##1\romannumeral-`0\expandafter - #3\romannumeral-`0\XINT_flexpr_getnext + \expandafter #2\expandafter ##1\romannumeral-`0\XINT_expr_getnext }% - \def #2##1##2##3##4% \XINT_flexpr_until_? + \def #2##1##2% \XINT_expr_until_,_a + {\xint_UDsignfork + ##2\dummy {\expandafter #2\expandafter ##1\romannumeral-`0#4}% + -\dummy {#3##1##2}% + \krof }% + \def #3##1##2##3##4% \XINT_expr_until_,_b {% - \ifnum ##2>#5% - \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0##3##4}% + \ifnum ##2>\xint_c_ii + \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0% + \csname XINT_#6_op_##3\endcsname {##4}}% \else \xint_afterfi {\expandafter ##2\expandafter ##3% - \csname .#6{\XINT_expr_string ##1}% - {\XINT_expr_string ##4}\endcsname }% + \csname .\XINT_expr_unlock ##1,\XINT_expr_unlock ##4\endcsname }% \fi }% + \let #5\xint_c_ii }% -\xint_tmp_def +{ii}{Add}% -\xint_tmp_def -{ii}{Sub}% -\xint_tmp_def *{iii}{Mul}% -\xint_tmp_def /{iii}{Div}% -\xint_tmp_def ^{iv}{Power}% -\xint_tmp_def e{v}{fE}% -\xint_tmp_def E{v}{fE}% -\def\xint_tmp_def #1% +\expandafter\xint_tmp_do_defs + \csname XINT_expr_op_,\expandafter\endcsname + \csname XINT_expr_until_,_a\expandafter\endcsname + \csname XINT_expr_until_,_b\expandafter\endcsname + \csname XINT_expr_op_-vi\expandafter\endcsname + \csname XINT_expr_precedence_,\endcsname {expr}% +\expandafter\xint_tmp_do_defs + \csname XINT_flexpr_op_,\expandafter\endcsname + \csname XINT_flexpr_until_,_a\expandafter\endcsname + \csname XINT_flexpr_until_,_b\expandafter\endcsname + \csname XINT_flexpr_op_-vi\expandafter\endcsname + \csname XINT_expr_precedence_,\endcsname {flexpr}% +% \end{macrocode} +% \subsection{? as two-way conditional} +% \lverb|New with 1.09a.| +% \begin{macrocode} +\def \XINT_expr_precedence_? #1#2#3#4% {% - \expandafter\xint_tmp_do_defs - \csname XINT_flexpr_checkifprefix_#1\expandafter\endcsname - \csname XINT_flexpr_op_-#1\endcsname + \xintifZero{\XINT_expr_unlock #2}% + {\XINT_expr_getnext #4}% + {\XINT_expr_getnext #3}% }% -\def\xint_tmp_do_defs #1#2% +% \end{macrocode} +% \subsection{: as three-way conditional} +% \lverb|New with 1.09a.| +% \begin{macrocode} +\def \XINT_expr_precedence_: #1#2#3#4#5% {% - \def #1##1% - {\xint_UDsignfork - ##1\dummy #2% - -\dummy ##1% - \krof }% + \xintifSgn {\XINT_expr_unlock #2}% + {\XINT_expr_getnext #3}% + {\XINT_expr_getnext #4}% + {\XINT_expr_getnext #5}% }% -\xint_tmp_def {ii}% -\xint_tmp_def {iii}% -\xint_tmp_def {iv}% -\xint_tmp_def {v}% -\def\xint_tmp_def #1% +% \end{macrocode} +% \subsection{\csh{XINT\_expr\_op\_-<level>}: minus as prefix inherits its precedence level} +% \begin{macrocode} +\def\xint_tmp_def #1#2% {% \expandafter\xint_tmp_do_defs - \csname XINT_flexpr_op_-#1\expandafter\endcsname - \csname XINT_expr_until_-#1\expandafter\endcsname - \csname XINT_flexpr_checkifprefix_#1\expandafter\endcsname - \csname xint_c_#1\endcsname + \csname XINT_#1_op_-#2\expandafter\endcsname + \csname XINT_#1_until_-#2_a\expandafter\endcsname + \csname XINT_#1_until_-#2_b\expandafter\endcsname + \csname xint_c_#2\endcsname {#1}% }% -\def\xint_tmp_do_defs #1#2#3#4% +\def\xint_tmp_do_defs #1#2#3#4#5% {% - \def #1% \XINT_flexpr_op_-ii,iii,iv,v - {% - \expandafter #2\romannumeral-`0\expandafter - #3\romannumeral-`0\XINT_flexpr_getnext + \def #1% \XINT_expr_op_-<level> + {% get next number+operator then switch to _until macro + \expandafter #2\romannumeral-`0\XINT_expr_getnext + }% + \def #2##1% \XINT_expr_until_-<l>_a + {\xint_UDsignfork + ##1\dummy {\expandafter #2\romannumeral-`0#1}% + -\dummy {#3##1}% + \krof }% + \def #3##1##2##3% \XINT_expr_until_-<l>_b + {% _until tests precedence level with next op, executes now or postpones + \ifnum ##1>#4% + \xint_afterfi {\expandafter #2\romannumeral-`0% + \csname XINT_#5_op_##2\endcsname {##3}}% + \else + \xint_afterfi {\expandafter ##1\expandafter ##2% + \csname .\xintOpp{\XINT_expr_unlock ##3}\endcsname }% + \fi }% }% -\xint_tmp_def {ii}% -\xint_tmp_def {iii}% -\xint_tmp_def {iv}% -\xint_tmp_def {v}% +\xintApplyInline{\xint_tmp_def {expr}}{{vi}{vii}{viii}{ix}}% +\xintApplyInline{\xint_tmp_def {flexpr}}{{vi}{vii}{viii}{ix}}% +% \end{macrocode} +% \subsection{! as postfix factorial operator of highest precedence} +% \lverb|\XINT_expr_precedence_! is not a \chardef constant indicating a +% precedence level but its gets executed immediately on the number is followed. +% It acts the same in \xintexpr and \xintfloatexpr and triggers the exact +% \xintFac.| +% \begin{macrocode} +\expandafter\def\csname XINT_expr_precedence_!\endcsname #1#2% + {\expandafter\XINT_expr_getop + \csname .\xintFac{\XINT_expr_unlock #2}[0]\endcsname }% +% \end{macrocode} +% \subsection{Functions} +% \lverb|New with 1.09a.| +% \begin{macrocode} \let\xint_tmp_def\empty \let\xint_tmp_do_defs\empty -\def\XINT_flexpr_getop #1% -{% - \expandafter\XINT_flexpr_getop_a\expandafter #1% - \romannumeral-`0\romannumeral-`0% +\def\XINT_expr_op_@ #1% +{% + \ifcsname XINT_expr_func_#1\endcsname + \xint_afterfi{% + \expandafter\expandafter\csname XINT_expr_func_#1\endcsname + }% + \else \xintError:unknownfunction + \xint_afterfi{\expandafter\XINT_expr_func_unknown}% + \fi + \romannumeral-`0\XINT_expr_oparen }% -\def\XINT_flexpr_getop_a #1#2% +\def\XINT_flexpr_op_@ #1% {% - \ifcat #2\relax - \ifx #2\relax - \expandafter\expandafter\expandafter - \XINT_expr_foundendofexpr - \else - \XINT_expr_unexpectedtoken - \expandafter\expandafter\expandafter - \XINT_flexpr_getop - \fi - \else - \expandafter\XINT_flexpr_op_found\expandafter #2% + \ifcsname XINT_flexpr_func_#1\endcsname + \xint_afterfi{% + \expandafter\expandafter\csname XINT_flexpr_func_#1\endcsname + }% + \else \xintError:unknownfunction + \xint_afterfi{\expandafter\XINT_expr_func_unknown}% \fi - #1% + \romannumeral-`0\XINT_flexpr_oparen }% -\def\XINT_flexpr_op_found #1% +\def\XINT_expr_func_unknown #1#2#3% {% - \ifcsname XINT_expr_precedence_\string #1\endcsname - \expandafter\xint_afterfi\expandafter - {\csname XINT_expr_precedence_\string #1\expandafter\endcsname - \csname XINT_flexpr_op_\string #1\endcsname }% - \else - \XINT_expr_unexpectedtoken - \expandafter\XINT_flexpr_getop - \fi + \expandafter #1\expandafter #2\csname .0[0]\endcsname }% -\expandafter\let\csname XINT_flexpr_op_)\endcsname\XINT_flexpr_getop -\def\XINT_flexpr_getnext +\def\XINT_expr_func_reduce #1#2#3% {% - \expandafter\XINT_flexpr_getnext_checkforbraced_a - \romannumeral-`0\romannumeral-`0% + \expandafter #1\expandafter #2\csname + .\xintIrr {\XINT_expr_unlock #3}\endcsname }% -\def\XINT_flexpr_getnext_checkforbraced_a #1% +\let\XINT_flexpr_func_reduce\XINT_expr_func_reduce +\def\XINT_expr_func_sqr #1#2#3% {% - \XINT_flexpr_getnext_checkforbraced_b #1\W\Z {#1}% + \expandafter #1\expandafter #2\csname + .\xintSqr {\XINT_expr_unlock #3}\endcsname }% -\def\XINT_flexpr_getnext_checkforbraced_b #1#2% +\def\XINT_flexpr_func_sqr #1#2#3% {% - \xint_UDwfork - #1\dummy \XINT_flexpr_getnext_emptybracepair - #2\dummy \XINT_flexpr_getnext_onetoken_perhaps - \W\dummy \XINT_flexpr_getnext_gotbracedstuff - \krof + \expandafter #1\expandafter #2\csname + .\XINTinFloatMul {\XINT_expr_unlock #3}{\XINT_expr_unlock #3}\endcsname }% -\def\XINT_flexpr_getnext_onetoken_perhaps\Z #1% +\def\XINT_expr_func_abs #1#2#3% {% - \expandafter\XINT_flexpr_getnext_checkforbraced_c\expandafter - {\romannumeral-`0#1}% + \expandafter #1\expandafter #2\csname + .\xintAbs {\XINT_expr_unlock #3}\endcsname }% -\def\XINT_flexpr_getnext_checkforbraced_c #1% +\let\XINT_flexpr_func_abs\XINT_expr_func_abs +\def\XINT_expr_func_sgn #1#2#3% {% - \XINT_flexpr_getnext_checkforbraced_d #1\W\Z {#1}% + \expandafter #1\expandafter #2\csname + .\xintSgn {\XINT_expr_unlock #3}\endcsname }% -\def\XINT_flexpr_getnext_checkforbraced_d #1#2% +\let\XINT_flexpr_func_sgn\XINT_expr_func_sgn +\def\XINT_expr_func_floor #1#2#3% {% - \xint_UDwfork - #1\dummy \XINT_flexpr_getnext_emptybracepair - #2\dummy \XINT_flexpr_getnext_onetoken_wehope - \W\dummy \XINT_flexpr_getnext_gotbracedstuff - \krof + \expandafter #1\expandafter #2\csname + .\xintFloor {\XINT_expr_unlock #3}\endcsname }% -\def\XINT_flexpr_getnext_emptybracepair #1{\XINT_flexpr_getnext }% -\def\XINT_flexpr_getnext_gotbracedstuff #1\W\Z #2% +\let\XINT_flexpr_func_floor\XINT_expr_func_floor +\def\XINT_expr_func_ceil #1#2#3% {% - \expandafter\XINT_flexpr_getop\csname .#2\endcsname + \expandafter #1\expandafter #2\csname + .\xintCeil {\XINT_expr_unlock #3}\endcsname }% -\def\XINT_flexpr_getnext_onetoken_wehope\Z #1% +\let\XINT_flexpr_func_ceil\XINT_expr_func_ceil +\def\XINT_expr_twoargs #1,#2,{{#1}{#2}}% +\def\XINT_expr_func_quo #1#2#3% {% - \xint_gob_til_! #1\XINT_flexpr_subexpr !% - \expandafter\XINT_flexpr_getnext_onetoken_fork\string #1% + \expandafter #1\expandafter #2\csname .% + \expandafter\expandafter\expandafter\xintQuo + \expandafter\XINT_expr_twoargs + \romannumeral-`0\XINT_expr_unlock #3,\endcsname }% -\def\XINT_flexpr_subexpr !#1!{\expandafter\XINT_flexpr_getop\xint_gobble_i }% -\begingroup -\lccode`*=`_ -\lowercase{\endgroup -\def\XINT_flexpr_getnext_onetoken_fork #1% +\let\XINT_flexpr_func_quo\XINT_expr_func_quo +\def\XINT_expr_func_rem #1#2#3% {% - \XINT_expr_sixwayfork - #1-.+*\dummy \XINT_flexpr_oparen - (#1.+*\dummy -% - (-#1+*\dummy {\XINT_flexpr_scannum_start\XINT_expr_scannum_decpart_b.}% - (-.#1*\dummy \XINT_flexpr_getnext% - (-.+#1\dummy {\XINT_flexpr_scannum_start\XINT_expr_scannum_decpart_b*}% - (-.+*\dummy {\XINT_flexpr_scannum_check #1}% - \krof -}}% -\def\XINT_flexpr_scannum_check #1% + \expandafter #1\expandafter #2\csname .% + \expandafter\expandafter\expandafter\xintRem + \expandafter\XINT_expr_twoargs + \romannumeral-`0\XINT_expr_unlock #3,\endcsname +}% +\let\XINT_flexpr_func_rem\XINT_expr_func_rem +\def\XINT_expr_oneortwo #1#2#3,#4,#5.% {% - \ifnum \xint_c_ix<1#1 - \expandafter\XINT_flexpr_scannum_start - \else - \xint_afterfi - {\XINT_expr_unexpectedtoken - \expandafter\XINT_flexpr_getnext\xint_gobble_ii}% - \fi \XINT_expr_scannum_intpart_b #1% + \if\relax#5\relax\expandafter\xint_firstoftwo\else + \expandafter\xint_secondoftwo\fi + {#1{0}{#3}}{#2{\xintNum {#4}}{#3}}% +}% +\def\XINT_expr_func_round #1#2#3% +{% + \expandafter #1\expandafter #2\csname .% + \expandafter\XINT_expr_oneortwo + \expandafter\xintiRound\expandafter\xintRound + \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname +}% +\let\XINT_flexpr_func_round\XINT_expr_func_round +\def\XINT_expr_func_trunc #1#2#3% +{% + \expandafter #1\expandafter #2\csname .% + \expandafter\XINT_expr_oneortwo + \expandafter\xintiTrunc\expandafter\xintTrunc + \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname +}% +\let\XINT_flexpr_func_trunc\XINT_expr_func_trunc +\def\XINT_expr_argandopt #1,#2,#3.% +{% + \if\relax#3\relax\expandafter\xint_firstoftwo\else + \expandafter\xint_secondoftwo\fi + {[\XINTdigits]{#1}}{[\xintNum {#2}]{#1}}% +}% +\def\XINT_expr_func_float #1#2#3% +{% + \expandafter #1\expandafter #2\csname .% + \expandafter\XINTinFloat + \romannumeral-`0\expandafter\XINT_expr_argandopt + \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname +}% +\let\XINT_flexpr_func_float\XINT_expr_func_float +\def\XINT_expr_func_sqrt #1#2#3% +{% + \expandafter #1\expandafter #2\csname .% + \expandafter\XINTinFloatSqrt + \romannumeral-`0\expandafter\XINT_expr_argandopt + \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname +}% +\let\XINT_flexpr_func_sqrt\XINT_expr_func_sqrt +\def\XINT_expr_func_gcd #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintGCDof:csv{\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_flexpr_func_gcd\XINT_expr_func_gcd +\def\XINT_expr_func_lcm #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintLCMof:csv{\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_flexpr_func_lcm\XINT_expr_func_lcm +\def\XINT_expr_func_max #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintMaxof:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_flexpr_func_max #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintFloatMaxof:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_expr_func_min #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintMinof:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_flexpr_func_min #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintFloatMinof:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_expr_func_sum #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintSum:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_flexpr_func_sum #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintFloatSum:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_expr_func_prd #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintPrd:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_flexpr_func_prd #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintFloatPrd:csv{\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_expr_func_add\XINT_expr_func_sum +\let\XINT_expr_func_mul\XINT_expr_func_prd +\let\XINT_flexpr_func_add\XINT_flexpr_func_sum +\let\XINT_flexpr_func_mul\XINT_flexpr_func_prd +\def\XINT_expr_func_? #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintIsNotZero {\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_flexpr_func_? \XINT_expr_func_? +\def\XINT_expr_func_! #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintIsZero {\XINT_expr_unlock #3}\endcsname }% -\def\XINT_flexpr_scannum_start #1% +\let\XINT_flexpr_func_! \XINT_expr_func_! +\def\XINT_expr_func_not #1#2#3% {% - \expandafter\XINT_flexpr_getop - \romannumeral-`0\expandafter\XINT_expr_gathernum - \romannumeral-`0#1% + \expandafter #1\expandafter #2\csname + .\xintIsZero {\XINT_expr_unlock #3}\endcsname }% +\let\XINT_flexpr_func_not \XINT_expr_func_not +\def\XINT_expr_func_all #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintANDof:csv{\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_flexpr_func_all\XINT_expr_func_all +\def\XINT_expr_func_any #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintORof:csv{\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_flexpr_func_any\XINT_expr_func_any +\def\XINT_expr_func_xor #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintXORof:csv{\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_flexpr_func_xor\XINT_expr_func_xor +\def\xintifNotZero:: #1,#2,#3,{\xintifNotZero{#1}{#2}{#3}}% +\def\XINT_expr_func_if #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\expandafter\xintifNotZero:: + \romannumeral-`0\XINT_expr_unlock #3,\endcsname +}% +\let\XINT_flexpr_func_if\XINT_expr_func_if +\def\xintifSgn:: #1,#2,#3,#4,{\xintifSgn{#1}{#2}{#3}{#4}}% +\def\XINT_expr_func_ifsgn #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\expandafter\xintifSgn:: + \romannumeral-`0\XINT_expr_unlock #3,\endcsname +}% +\let\XINT_flexpr_func_ifsgn\XINT_expr_func_ifsgn % \end{macrocode} % \subsection{\csh{xintNewExpr}} -% \begin{macrocode} +% \lverb|& +% Rewritten in 1.09a. Now, the parameters of the formula are entered in the +% usual way by the user, with # not _. And _ is assigned to make macros +% not expand. This way, : is freed, as we now need it for the ternary operator. +% (on numeric data; if use with macro parameters, should be coded with the +% functionn ifsgn , rather)| +% \begin{macrocode} +\def\XINT_newexpr_print #1{\ifnum\xintNthElt{0}{#1}>1 + \expandafter\xint_firstoftwo + \else + \expandafter\xint_secondoftwo + \fi + {_xintListWithSep,{#1}}{\xint_firstofone#1}}% +\def\XINT_expr_tmp #1% + {\expandafter\def\csname xint#1\endcsname {_xint#1}}% +\expandafter\def\expandafter\XINT_expr_protect\expandafter +{% + \romannumeral0% + \xintapplyunbraced\XINT_expr_tmp{\xintCSVtoList{% + Floor,Ceil,iRound,Round,iTrunc,Trunc,% + Lt,Gt,Eq,AND,OR,% + IsNotZero,IsZero,% + ifNotZero,ifSgn,% + Irr,Num,Abs,Sgn,Opp,Quo,Rem,% + Add,Sub,Mul,Sqr,Div,Pow,Fac,fE}}% + \def\xintGCDof:csv ##1{_xintGCDof {\xintCSVtoList {##1}}}% + \def\xintLCMof:csv ##1{_xintLCMof {\xintCSVtoList {##1}}}% + \def\xintMaxof:csv ##1{_xintMaxof {\xintCSVtoList {##1}}}% + \def\xintMinof:csv ##1{_xintMinof {\xintCSVtoList {##1}}}% + \def\xintSum:csv ##1{_xintSum {\xintCSVtoList {##1}}}% + \def\xintPrd:csv ##1{_xintPrd {\xintCSVtoList {##1}}}% + \def\xintANDof:csv ##1{_xintANDof {\xintCSVtoList {##1}}}% + \def\xintORof:csv ##1{_xintORof {\xintCSVtoList {##1}}}% + \def\xintXORof:csv ##1{_xintXORof {\xintCSVtoList {##1}}}% + \def\XINTinFloat {_XINTinFloat}% + \def\XINTinFloatSqrt {_XINTinFloatSqrt}% + \def\XINTdigits {_XINTdigits}% + \def\XINT_expr_print ##1{\expandafter\XINT_newexpr_print\expandafter + {\romannumeral0\xintcsvtolist{\XINT_expr_unlock ##1}}}% +}% \catcode`* 13 -\def\xintNewExpr #1[#2]#3% +\def\xintNewExpr #1[#2]% {% - \begingroup + \begingroup \ifcase #2\relax \toks0 {\xdef #1}% \or \toks0 {\xdef #1##1}% @@ -16834,40 +18397,75 @@ first place. \or \toks0 {\xdef #1##1##2##3##4##5##6##7}% \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8}% \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8##9}% - \else - \immediate\write-1{Package xintexpr Error! illegal number of macro - parameters.}% \fi - \def\xintAdd {:xintAdd}% - \def\xintSub {:xintSub}% - \def\xintMul {:xintMul}% - \def\xintDiv {:xintDiv}% - \def\xintPow {:xintPow}% - \def\xintFac {:xintFac}% - \def\xintOpp {:xintOpp}% - \def\xintfE {:xintfE}% - \def\xintraw { :romannumeral0:xintraw}% - \def\XINT_expr_the ##1##2##3% - {\expandafter\xintraw - \expandafter{\romannumeral-`0\XINT_expr_string ##3}}% - \lccode`\*=`: \lowercase {\def*}{!noexpand!}% - \catcode`: 13 - \endlinechar -1 + \xintexprSafeCatcodes + \XINT_NewExpr +}% +\def\XINT_NewExpr #1% +{% + \def\xintTmp ##1##2##3##4##5##6##7##8##9{#1}% + \XINT_expr_protect + \lccode`\*=`_ \lowercase {\def*}{!noexpand!}% + \catcode`_ 13 \catcode`: 11 \endlinechar -1 \everyeof {\noexpand }% - \edef\xintNewExprtmp + \edef\XINTtmp ##1##2##3##4##5##6##7##8##9% {\scantokens - \expandafter{\romannumeral0\xinttheeval #3\relax}}% - \lccode`\*=`_ \lowercase {\def*}{####}% - \catcode`_ 13 \catcode`! 0 \catcode`: 11 - \the\toks0 {\scantokens\expandafter{\xintNewExprtmp }}% + \expandafter{\romannumeral-`0\xinttheexpr + \xintTmp {####1}{####2}{####3}% + {####4}{####5}{####6}% + {####7}{####8}{####9}% + \relax}}% + \lccode`\*=`\$ \lowercase {\def*}{####}% + \catcode`\$ 13 \catcode`! 0 \catcode`_ 11 % + \the\toks0 + {\scantokens\expandafter{\expandafter + \XINT_newexpr_stripprefix\meaning\XINTtmp}}% \endgroup }% % \end{macrocode} % \subsection{\csh{xintNewFloatExpr}} % \begin{macrocode} -\def\xintNewFloatExpr #1[#2]#3% +\def\XINT_newflexpr_print #1{\ifnum\xintNthElt{0}{#1}>1 + \expandafter\xint_firstoftwo + \else + \expandafter\xint_secondoftwo + \fi + {_xintListWithSep,{\xintApply{_xintFloat}{#1}}} + {_xintFloat#1}}% +\expandafter\def\expandafter\XINT_flexpr_protect\expandafter {% - \begingroup + \romannumeral0% + \xintapplyunbraced\XINT_expr_tmp{\xintCSVtoList{% + Floor,Ceil,iRound,Round,iTrunc,Trunc,% + Lt,Gt,Eq,AND,OR,% + IsNotZero,IsZero,% + ifNotZero,ifSgn,% + Irr,Num,Abs,Sgn,Opp,Quo,Rem,Fac}}% + \def\xintGCDof:csv ##1{_xintGCDof {\xintCSVtoList {##1}}}% + \def\xintLCMof:csv ##1{_xintLCMof {\xintCSVtoList {##1}}}% + \def\xintFloatMaxof:csv ##1{_xintFloatMaxof {\xintCSVtoList {##1}}}% + \def\xintFloatMinof:csv ##1{_xintFloatMinof {\xintCSVtoList {##1}}}% + \def\xintFloatSum:csv ##1{_xintFloatSum {\xintCSVtoList {##1}}}% + \def\xintFloatPrd:csv ##1{_xintFloatPrd {\xintCSVtoList {##1}}}% + \def\xintANDof:csv ##1{_xintANDof {\xintCSVtoList {##1}}}% + \def\xintORof:csv ##1{_xintORof {\xintCSVtoList {##1}}}% + \def\xintXORof:csv ##1{_xintXORof {\xintCSVtoList {##1}}}% + \def\XINTinFloat {_XINTinFloat}% + \def\XINTinFloatSqrt {_XINTinFloatSqrt}% + \def\XINTinFloatAdd {_XINTinFloatAdd}% + \def\XINTinFloatSub {_XINTinFloatSub}% + \def\XINTinFloatMul {_XINTinFloatMul}% + \def\XINTinFloatDiv {_XINTinFloatDiv}% + \def\XINTinFloatPower {_XINTinFloatPower}% + \def\XINTinFloatfE {_XINTinFloatfE}% + \def\XINTdigits {_XINTdigits}% + \def\XINT_flexpr_print ##1{\expandafter\XINT_newflexpr_print\expandafter + {\romannumeral0\xintcsvtolist{\XINT_expr_unlock ##1}}}% +}% +\let\XINT_expr_tmp\empty +\def\xintNewFloatExpr #1[#2]% +{% + \begingroup \ifcase #2\relax \toks0 {\xdef #1}% \or \toks0 {\xdef #1##1}% @@ -16879,40 +18477,99 @@ first place. \or \toks0 {\xdef #1##1##2##3##4##5##6##7}% \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8}% \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8##9}% - \else - \immediate\write-1{Package xintexpr Error! illegal number of macro - parameters.}% \fi - \def\XINTinFloatAdd {:XINTinFloatAdd}% - \def\XINTinFloatSub {:XINTinFloatSub}% - \def\XINTinFloatMul {:XINTinFloatMul}% - \def\XINTinFloatDiv {:XINTinFloatDiv}% - \def\XINTinFloatPower {:XINTinFloatPower}% - \def\xintFac {:xintFac}% - \def\xintOpp {:xintOpp}% - \def\XINTinFloatfE {:XINTinFloatfE}% - \def\xintfloat { :romannumeral0:xintfloat}% - \def\XINT_flexpr_the ##1##2##3% - {\expandafter\xintfloat - \expandafter{\romannumeral-`0\XINT_expr_string ##3}}% - \lccode`\*=`: \lowercase {\def*}{!noexpand!}% - \catcode`: 13 - \endlinechar -1 + \xintexprSafeCatcodes + \XINT_NewFloatExpr +}% +\def\XINT_NewFloatExpr #1% +{% + \def\xintTmp ##1##2##3##4##5##6##7##8##9{#1}% + \XINT_flexpr_protect + \lccode`\*=`_ \lowercase {\def*}{!noexpand!}% + \catcode`_ 13 \catcode`: 11 \endlinechar -1 % \everyeof {\noexpand }% - \edef\xintNewExprtmp + \edef\XINTtmp ##1##2##3##4##5##6##7##8##9% {\scantokens - \expandafter{\romannumeral0\xintthefloateval #3\relax}}% - \lccode`\*=`_ \lowercase {\def*}{####}% - \catcode`_ 13 \catcode`! 0 \catcode`: 11 - \the\toks0 {\scantokens\expandafter{\xintNewExprtmp }}% + \expandafter{\romannumeral-`0\xintthefloatexpr + \xintTmp {####1}{####2}{####3}% + {####4}{####5}{####6}% + {####7}{####8}{####9}% + \relax}}% + \lccode`\*=`\$ \lowercase {\def*}{####}% + \catcode`\$ 13 \catcode`! 0 \catcode`_ 11 % + \the\toks0 + {\scantokens\expandafter + {\expandafter\XINT_newexpr_stripprefix\meaning\XINTtmp}}% \endgroup }% +\let\xintexprRestoreCatcodes\relax +\def\xintexprSafeCatcodes +{% for end user. + \edef\xintexprRestoreCatcodes {% + \catcode63=\the\catcode63 % ? + \catcode124=\the\catcode124 % | + \catcode38=\the\catcode38 % & + \catcode33=\the\catcode33 % ! + \catcode93=\the\catcode93 % ] + \catcode91=\the\catcode91 % [ + \catcode94=\the\catcode94 % ^ + \catcode95=\the\catcode95 % _ + \catcode47=\the\catcode47 % / + \catcode41=\the\catcode41 % ) + \catcode40=\the\catcode40 % ( + \catcode42=\the\catcode42 % * + \catcode43=\the\catcode43 % + + \catcode62=\the\catcode62 % > + \catcode60=\the\catcode60 % < + \catcode58=\the\catcode58 % : + \catcode46=\the\catcode46 % . + \catcode45=\the\catcode45 % - + \catcode44=\the\catcode44 % , + \catcode61=\the\catcode61\relax % = + }% this is just for some standard situation with a few made active by Babel + \catcode63=12 % ? + \catcode124=12 % | + \catcode38=4 % & + \catcode33=12 % ! + \catcode93=12 % ] + \catcode91=12 % [ + \catcode94=7 % ^ + \catcode95=8 % _ + \catcode47=12 % / + \catcode41=12 % ) + \catcode40=12 % ( + \catcode42=12 % * + \catcode43=12 % + + \catcode62=12 % > + \catcode60=12 % < + \catcode58=12 % : + \catcode46=12 % . + \catcode45=12 % - + \catcode44=12 % , + \catcode61=12 % = +}% \XINT_expr_restorecatcodes_endinput% % \end{macrocode} % \DeleteShortVerb{\|} % \MakePercentComment %</xintexpr> %<*doc> +\StoreCodelineNo {xintexpr} + +\def\mymacro #1{\mymacroaux #1} +\def\mymacroaux #1#2{\strut \texttt{#1:}& \digitstt{ #2.}\tabularnewline } +\indent +\begin{tabular}[t]{r@{}r} +\xintApplyUnbraced\mymacro\storedlinecounts +\end{tabular} +\def\mymacroaux #1#2{#2}% +\parbox[t]{10cm}{Total number of code lines: + \digitstt{\xintiSum{\xintApply\mymacro\storedlinecounts}}. Each package starts + with circa \digitstt{140} lines (\digitstt{114} for \texttt{xint}) dealing + with catcodes, identification and reloading management\strut. Version + \texttt{\pkgversion} of \texttt{\pkgdate}.\par} + + \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 @@ -16928,7 +18585,7 @@ first place. Right bracket \] Circumflex \^ Underscore \_ Grave accent \` Left brace \{ Vertical bar \| Right brace \} Tilde \~} -\CheckSum{17408} +\CheckSum{19450} \makeatletter\check@checksum\makeatother \Finale %% diff --git a/Master/texmf-dist/source/generic/xint/xint.ins b/Master/texmf-dist/source/generic/xint/xint.ins index 22554e24c0d..55dfe197584 100644 --- a/Master/texmf-dist/source/generic/xint/xint.ins +++ b/Master/texmf-dist/source/generic/xint/xint.ins @@ -1,6 +1,6 @@ %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.08b of June 14, 2013) +%% The xint bundle (version 1.09a of September 22, 2013) %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- %% diff --git a/Master/texmf-dist/tex/generic/xint/xint.sty b/Master/texmf-dist/tex/generic/xint/xint.sty index 21911c686ee..3b0f6239b6d 100644 --- a/Master/texmf-dist/tex/generic/xint/xint.sty +++ b/Master/texmf-dist/tex/generic/xint/xint.sty @@ -22,7 +22,7 @@ %% in the same archive or directory.) %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.08b of June 14, 2013) +%% The xint bundle (version 1.09a of September 22, 2013) %% xint: Expandable operations on long numbers %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -140,7 +140,7 @@ \fi \expandafter\x\csname ver@xint.sty\endcsname \ProvidesPackage{xint}% - [2013/06/14 v1.08b Expandable operations on long numbers (jfB)]% + [2013/09/24 v1.09a Expandable operations on long numbers (jfB)]% \def\xint_gobble_ {}% \def\xint_gobble_i #1{}% \def\xint_gobble_ii #1#2{}% @@ -271,7 +271,7 @@ \def\xintilen #1% {% \expandafter\XINT_length_fork - \romannumeral-`0#1\xint_relax\xint_relax\xint_relax\xint_relax + \romannumeral0\xintnum{#1}\xint_relax\xint_relax\xint_relax\xint_relax \xint_relax\xint_relax\xint_relax\xint_relax\Z }% \let\xintLen\xintiLen \let\xintlen\xintilen @@ -474,6 +474,17 @@ \def\XINT_applyunbr_loop_b #1#2{\XINT_applyunbr_loop_a {#2#1}}% \def\XINT_applyunbr_end\Z \expandafter\XINT_applyunbr_loop_b\expandafter #1#2#3{ #2}% +\def\xintApplyInline #1#2% +{% + \def\XINT_apply_themacro {#1}% + \expandafter\XINT_applyinline_a\romannumeral-`0#2:% +}% +\def\XINT_applyinline_a {\futurelet\XINT_apply_nexttoken\XINT_applyinline_b }% +\def\XINT_applyinline_b #1% +{% + \ifx\XINT_apply_nexttoken :\expandafter\xint_gobble_iii\fi + \XINT_apply_themacro {#1}\XINT_applyinline_a +}% \def\xintAssign #1\to {% \expandafter\XINT_assign_a\romannumeral-`0#1{}\to @@ -706,6 +717,8 @@ }% \def\XINT_cuz_stop #1\W #2\Z{ #1}% \def\xint_cuz_backtoloop 0\XINT_cuz_stop 0{\XINT_cuz_loop }% +\def\xintIsOne {\romannumeral0\xintisone }% +\def\xintisone #1{\expandafter\XINT_isone \romannumeral0\xintnum{#1}\W\Z }% \def\XINT_isOne #1{\romannumeral0\XINT_isone #1\W\Z }% \def\XINT_isone #1#2% {% @@ -762,7 +775,11 @@ {% \expandafter\XINT_sgn \romannumeral-`0#1\Z% }% -\let\xintSgn\xintiSgn \let\xintsgn\xintisgn +\def\xintSgn {\romannumeral0\xintsgn }% +\def\xintsgn #1% +{% + \expandafter\XINT_sgn \romannumeral0\xintnum{#1}\Z% +}% \def\XINT_Sgn #1{\romannumeral0\XINT_sgn #1\Z }% \def\XINT_sgn #1#2\Z {% @@ -780,10 +797,66 @@ \else\xint_afterfi{\expandafter\space\xint_firstofthree}% \fi }% +\def\xintifSgn {\romannumeral0\xintifsgn }% +\def\xintifsgn #1% +{% + \ifcase \romannumeral0\xintsgn{#1} + \xint_afterfi{\expandafter\space\xint_secondofthree}% + \or\xint_afterfi{\expandafter\space\xint_thirdofthree}% + \else\xint_afterfi{\expandafter\space\xint_firstofthree}% + \fi +}% +\def\xintifZero {\romannumeral0\xintifzero }% +\def\xintifzero #1% +{% + \if\xintSgn{\xintAbs{#1}}0% + \xint_afterfi{\expandafter\space\xint_firstoftwo}% + \else + \xint_afterfi{\expandafter\space\xint_secondoftwo}% + \fi +}% +\def\xintifNotZero {\romannumeral0\xintifnotzero }% +\def\xintifnotzero #1% +{% + \if\xintSgn{\xintAbs{#1}}1% + \xint_afterfi{\expandafter\space\xint_firstoftwo}% + \else + \xint_afterfi{\expandafter\space\xint_secondoftwo}% + \fi +}% +\def\xintifEq {\romannumeral0\xintifeq }% +\def\xintifeq #1#2% +{% + \if\xintCmp{#1}{#2}0% + \xint_afterfi{\expandafter\space\xint_firstoftwo}% + \else\xint_afterfi{\expandafter\space\xint_secondoftwo}% + \fi +}% +\def\xintifGt {\romannumeral0\xintifgt }% +\def\xintifgt #1#2% +{% + \if\xintCmp{#1}{#2}1% + \xint_afterfi{\expandafter\space\xint_firstoftwo}% + \else\xint_afterfi{\expandafter\space\xint_secondoftwo}% + \fi +}% +\def\xintifLt {\romannumeral0\xintiflt }% +\def\xintiflt #1#2% +{% + \xintSgnFork{\xintCmp{#1}{#2}}% + {\expandafter\space\xint_firstoftwo}% + {\expandafter\space\xint_secondoftwo}% + {\expandafter\space\xint_secondoftwo}% +}% +\def\xintiiOpp {\romannumeral0\xintiiopp }% +\def\xintiiopp #1% +{% + \expandafter\XINT_opp \romannumeral-`0#1% +}% \def\xintiOpp {\romannumeral0\xintiopp }% \def\xintiopp #1% {% - \expandafter\XINT_opp \romannumeral-`0#1% + \expandafter\XINT_opp \romannumeral0\xintnum{#1}% }% \let\xintOpp\xintiOpp \let\xintopp\xintiopp \def\XINT_Opp #1{\romannumeral0\XINT_opp #1}% @@ -795,10 +868,15 @@ 0-\dummy { -#1}% positive \krof }% +\def\xintiiAbs {\romannumeral0\xintiiabs }% +\def\xintiiabs #1% +{% + \expandafter\XINT_abs \romannumeral-`0#1% +}% \def\xintiAbs {\romannumeral0\xintiabs }% \def\xintiabs #1% {% - \expandafter\XINT_abs \romannumeral-`0#1% + \expandafter\XINT_abs \romannumeral0\xintnum{#1}% }% \let\xintAbs\xintiAbs \let\xintabs\xintiabs \def\XINT_Abs #1{\romannumeral0\XINT_abs #1}% @@ -1131,16 +1209,25 @@ \def\XINT_addp_endGy_zeros 0000\XINT_addp_endGy 0000#1\Z{ #1}% \def\XINT_addp_endGy #1#2#3#4#5\Z{ #5#1#2#3#4}% \def\xint_addp_Gz\W\XINT_addp_G #1#2{ #2}% +\def\xintiiAdd {\romannumeral0\xintiiadd }% +\def\xintiiadd #1% +{% + \expandafter\xint_iiadd\expandafter{\romannumeral-`0#1}% +}% +\def\xint_iiadd #1#2% +{% + \expandafter\XINT_add_fork \romannumeral-`0#2\Z #1\Z +}% \def\xintiAdd {\romannumeral0\xintiadd }% \def\xintiadd #1% {% - \expandafter\xint_add\expandafter{\romannumeral-`0#1}% + \expandafter\xint_add\expandafter{\romannumeral0\xintnum{#1}}% }% -\let\xintAdd\xintiAdd \let\xintadd\xintiadd \def\xint_add #1#2% {% - \expandafter\XINT_add_fork \romannumeral-`0#2\Z #1\Z + \expandafter\XINT_add_fork \romannumeral0\xintnum{#2}\Z #1\Z }% +\let\xintAdd\xintiAdd \let\xintadd\xintiadd \def\XINT_Add #1#2{\romannumeral0\XINT_add_fork #2\Z #1\Z }% \def\XINT_add #1#2{\XINT_add_fork #2\Z #1\Z }% \def\XINT_add_fork #1#2\Z #3#4\Z @@ -1189,18 +1276,27 @@ \romannumeral0\XINT_RQ {}#2\R\R\R\R\R\R\R\R\Z \W\X\Y\Z #1\W\X\Y\Z }% +\def\xintiiSub {\romannumeral0\xintiisub }% +\def\xintiisub #1% +{% + \expandafter\xint_iisub\expandafter{\romannumeral-`0#1}% +}% +\def\xint_iisub #1#2% +{% + \expandafter\XINT_sub_fork \romannumeral-`0#2\Z #1\Z +}% \def\xintiSub {\romannumeral0\xintisub }% \def\xintisub #1% {% - \expandafter\xint_sub\expandafter{\romannumeral-`0#1}% + \expandafter\xint_sub\expandafter{\romannumeral0\xintnum{#1}}% }% -\let\xintSub\xintiSub \let\xintsub\xintisub \def\xint_sub #1#2% {% - \expandafter\XINT_sub_fork \romannumeral-`0#2\Z #1\Z + \expandafter\XINT_sub_fork \romannumeral0\xintnum{#2}\Z #1\Z }% \def\XINT_Sub #1#2{\romannumeral0\XINT_sub_fork #2\Z #1\Z }% \def\XINT_sub #1#2{\XINT_sub_fork #2\Z #1\Z }% +\let\xintSub\xintiSub \let\xintsub\xintisub \def\XINT_sub_fork #1#2\Z #3#4\Z {% \xint_UDsignsfork @@ -1442,12 +1538,12 @@ \def\xintiCmp {\romannumeral0\xinticmp }% \def\xinticmp #1% {% - \expandafter\xint_cmp\expandafter{\romannumeral-`0#1}% + \expandafter\xint_cmp\expandafter{\romannumeral0\xintnum{#1}}% }% \let\xintCmp\xintiCmp \let\xintcmp\xinticmp \def\xint_cmp #1#2% {% - \expandafter\XINT_cmp_fork \romannumeral-`0#2\Z #1\Z + \expandafter\XINT_cmp_fork \romannumeral0\xintnum{#2}\Z #1\Z }% \def\XINT_Cmp #1#2{\romannumeral0\XINT_cmp_fork #2\Z #1\Z }% \def\XINT_cmp_fork #1#2\Z #3#4\Z @@ -1546,15 +1642,94 @@ \def\XINT_OneIfPositive_finish #1\W\X\Y\Z{ 1}% \def\xint_OneIfPositive_backtomain 0\XINT_OneIfPositive_finish 0% {\XINT_OneIfPositive_main }% +\def\xintEq {\romannumeral0\xinteq }% +\def\xinteq #1#2{\xintifeq{#1}{#2}{1}{0}}% +\def\xintGt {\romannumeral0\xintgt }% +\def\xintgt #1#2{\xintifgt{#1}{#2}{1}{0}}% +\def\xintLt {\romannumeral0\xintlt }% +\def\xintlt #1#2{\xintiflt{#1}{#2}{1}{0}}% +\def\xintIsZero {\romannumeral0\xintiszero }% +\def\xintiszero #1{\xintifsgn {#1}{0}{1}{0}}% +\def\xintIsNotZero {\romannumeral0\xintisnotzero }% +\def\xintisnotzero #1{\xintifsgn {#1}{1}{0}{1}}% +\def\xintAND {\romannumeral0\xintand }% +\def\xintand #1#2{\xintifzero {#1}{0}{\xintifzero {#2}{0}{1}}}% +\def\xintOR {\romannumeral0\xintor }% +\def\xintor #1#2{\xintifzero {#1}{\xintifzero {#2}{0}{1}}{1}}% +\def\xintXOR {\romannumeral0\xintxor }% +\def\xintxor #1#2{\ifcase \numexpr\xintIsZero{#1}+\xintIsZero{#2}\relax + \xint_afterfi{ 0}% + \or\xint_afterfi{ 1}% + \else\xint_afterfi { 0}% + \fi }% +\def\xintANDof {\romannumeral0\xintandof }% +\def\xintandof #1{\expandafter\XINT_andof_a\romannumeral-`0#1\relax }% +\def\XINT_andof_a #1{\expandafter\XINT_andof_b\romannumeral-`0#1\Z }% +\def\XINT_andof_b #1% + {\xint_gob_til_relax #1\XINT_andof_e\relax\XINT_andof_c #1}% +\def\XINT_andof_c #1\Z + {\xintifZero{#1}{\XINT_andof_no}{\XINT_andof_a}}% +\def\XINT_andof_no #1\relax { 0}% +\def\XINT_andof_e #1\Z { 1}% +\def\xintANDof:csv #1{\expandafter\XINT_andof:_a\romannumeral-`0#1,,^}% +\def\XINT_andof:_a {\expandafter\XINT_andof:_b\romannumeral-`0}% +\def\XINT_andof:_b #1{\if #1,\expandafter\XINT_andof:_e + \else\expandafter\XINT_andof:_c\fi #1}% +\def\XINT_andof:_c #1,{\xintifZero{#1}{\XINT_andof:_no}{\XINT_andof:_a}}% +\def\XINT_andof:_no #1^{0}% +\def\XINT_andof:_e #1^{1}% +\def\xintORof {\romannumeral0\xintorof }% +\def\xintorof #1{\expandafter\XINT_orof_a\romannumeral-`0#1\relax }% +\def\XINT_orof_a #1{\expandafter\XINT_orof_b\romannumeral-`0#1\Z }% +\def\XINT_orof_b #1% + {\xint_gob_til_relax #1\XINT_orof_e\relax\XINT_orof_c #1}% +\def\XINT_orof_c #1\Z + {\xintifZero{#1}{\XINT_orof_a}{\XINT_orof_yes}}% +\def\XINT_orof_yes #1\relax { 1}% +\def\XINT_orof_e #1\Z { 0}% +\def\xintORof:csv #1{\expandafter\XINT_orof:_a\romannumeral-`0#1,,^}% +\def\XINT_orof:_a {\expandafter\XINT_orof:_b\romannumeral-`0}% +\def\XINT_orof:_b #1{\if #1,\expandafter\XINT_orof:_e + \else\expandafter\XINT_orof:_c\fi #1}% +\def\XINT_orof:_c #1,{\xintifZero{#1}{\XINT_orof:_a}{\XINT_orof:_yes}}% +\def\XINT_orof:_yes #1^{1}% +\def\XINT_orof:_e #1^{0}% +\def\xintXORof {\romannumeral0\xintxorof }% +\def\xintxorof #1{\expandafter\XINT_xorof_a\expandafter + 0\romannumeral-`0#1\relax }% +\def\XINT_xorof_a #1#2{\expandafter\XINT_xorof_b\romannumeral-`0#2\Z #1}% +\def\XINT_xorof_b #1% + {\xint_gob_til_relax #1\XINT_xorof_e\relax\XINT_xorof_c #1}% +\def\XINT_xorof_c #1\Z #2% + {\xintifZero {#1}{\XINT_xorof_a #2}{\ifcase #2 + \xint_afterfi{\XINT_xorof_a 1}% + \else + \xint_afterfi{\XINT_xorof_a 0}% + \fi }% + }% +\def\XINT_xorof_e #1\Z #2{ #2}% +\def\xintXORof:csv #1{\expandafter\XINT_xorof:_a\expandafter + 0\romannumeral-`0#1,,^}% +\def\XINT_xorof:_a #1#2,{\expandafter\XINT_xorof:_b\romannumeral-`0#2,#1}% +\def\XINT_xorof:_b #1{\if #1,\expandafter\XINT_xorof:_e + \else\expandafter\XINT_xorof:_c\fi #1}% +\def\XINT_xorof:_c #1,#2% + {\xintifZero {#1}{\XINT_xorof:_a #2}{\ifcase #2 + \xint_afterfi{\XINT_xorof:_a 1}% + \else + \xint_afterfi{\XINT_xorof:_a 0}% + \fi }% + }% +\def\XINT_xorof:_e ,#1#2^{#1}% allows empty list \def\xintiGeq {\romannumeral0\xintigeq }% \def\xintigeq #1% {% - \expandafter\xint_geq\expandafter {\romannumeral-`0#1}% + \expandafter\xint_geq\expandafter {\romannumeral0\xintnum{#1}}% }% \let\xintGeq\xintiGeq \let\xintgeq\xintigeq \def\xint_geq #1#2% {% - \expandafter\XINT_geq_fork \romannumeral-`0#2\Z #1\Z + \expandafter\XINT_geq_fork \romannumeral0\xintnum{#2}\Z #1\Z }% \def\XINT_Geq #1#2{\romannumeral0\XINT_geq_fork #2\Z #1\Z }% \def\XINT_geq_fork #1#2\Z #3#4\Z @@ -1624,12 +1799,12 @@ \def\xintiMax {\romannumeral0\xintimax }% \def\xintimax #1% {% - \expandafter\xint_max\expandafter {\romannumeral-`0#1}% + \expandafter\xint_max\expandafter {\romannumeral0\xintnum{#1}}% }% \let\xintMax\xintiMax \let\xintmax\xintimax \def\xint_max #1#2% {% - \expandafter\XINT_max_pre\expandafter {\romannumeral-`0#2}{#1}% + \expandafter\XINT_max_pre\expandafter {\romannumeral0\xintnum{#2}}{#1}% }% \def\XINT_max_pre #1#2{\XINT_max_fork #1\Z #2\Z {#2}{#1}}% \def\XINT_Max #1#2{\romannumeral0\XINT_max_fork #2\Z #1\Z {#1}{#2}}% @@ -1669,15 +1844,26 @@ \expandafter\xint_secondoftwo_andstop \fi }% +\def\xintiMaxof {\romannumeral0\xintimaxof }% +\def\xintimaxof #1{\expandafter\XINT_imaxof_a\romannumeral-`0#1\relax }% +\def\XINT_imaxof_a #1{\expandafter\XINT_imaxof_b\romannumeral0\xintnum{#1}\Z }% +\def\XINT_imaxof_b #1\Z #2% + {\expandafter\XINT_imaxof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_imaxof_c #1% + {\xint_gob_til_relax #1\XINT_imaxof_e\relax\XINT_imaxof_d #1}% +\def\XINT_imaxof_d #1\Z + {\expandafter\XINT_imaxof_b\romannumeral0\xintimax {#1}}% +\def\XINT_imaxof_e #1\Z #2\Z { #2}% +\let\xintMaxof\xintiMaxof \let\xintmaxof\xintimaxof \def\xintiMin {\romannumeral0\xintimin }% \def\xintimin #1% {% - \expandafter\xint_min\expandafter {\romannumeral-`0#1}% + \expandafter\xint_min\expandafter {\romannumeral0\xintnum{#1}}% }% \let\xintMin\xintiMin \let\xintmin\xintimin \def\xint_min #1#2% {% - \expandafter\XINT_min_pre\expandafter {\romannumeral-`0#2}{#1}% + \expandafter\XINT_min_pre\expandafter {\romannumeral0\xintnum{#2}}{#1}% }% \def\XINT_min_pre #1#2{\XINT_min_fork #1\Z #2\Z {#2}{#1}}% \def\XINT_Min #1#2{\romannumeral0\XINT_min_fork #2\Z #1\Z {#1}{#2}}% @@ -1717,6 +1903,17 @@ \expandafter\xint_firstoftwo_andstop \fi }% +\def\xintiMinof {\romannumeral0\xintiminof }% +\def\xintiminof #1{\expandafter\XINT_iminof_a\romannumeral-`0#1\relax }% +\def\XINT_iminof_a #1{\expandafter\XINT_iminof_b\romannumeral0\xintnum{#1}\Z }% +\def\XINT_iminof_b #1\Z #2% + {\expandafter\XINT_iminof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_iminof_c #1% + {\xint_gob_til_relax #1\XINT_iminof_e\relax\XINT_iminof_d #1}% +\def\XINT_iminof_d #1\Z + {\expandafter\XINT_iminof_b\romannumeral0\xintimin {#1}}% +\def\XINT_iminof_e #1\Z #2\Z { #2}% +\let\xintMinof\xintiMinof \let\xintminof\xintiminof \def\xintiSum {\romannumeral0\xintisum }% \def\xintisum #1{\xintisumexpr #1\relax }% \def\xintiSumExpr {\romannumeral0\xintisumexpr }% @@ -1759,16 +1956,25 @@ \W\X\Y\Z #3\W\X\Y\Z }{#2}% }% \def\XINT_sum_NN #1#2{\XINT_sum_loop {#2}{#1}}% +\def\xintiiMul {\romannumeral0\xintiimul }% +\def\xintiimul #1% +{% + \expandafter\xint_iimul\expandafter {\romannumeral-`0#1}% +}% +\def\xint_iimul #1#2% +{% + \expandafter\XINT_mul_fork \romannumeral-`0#2\Z #1\Z +}% \def\xintiMul {\romannumeral0\xintimul }% \def\xintimul #1% {% - \expandafter\xint_mul\expandafter {\romannumeral-`0#1}% + \expandafter\xint_mul\expandafter {\romannumeral0\xintnum{#1}}% }% -\let\xintMul\xintiMul \let\xintmul\xintimul \def\xint_mul #1#2% {% - \expandafter\XINT_mul_fork \romannumeral-`0#2\Z #1\Z + \expandafter\XINT_mul_fork \romannumeral0\xintnum{#2}\Z #1\Z }% +\let\xintMul\xintiMul \let\xintmul\xintimul \def\XINT_Mul #1#2{\romannumeral0\XINT_mul_fork #2\Z #1\Z }% \def\XINT_mul_fork #1#2\Z #3#4\Z {% @@ -2128,6 +2334,11 @@ \romannumeral0\XINT_mul_Mr {#2}#4\Z\Z\Z\Z \W\X\Y\Z 0#3\W\X\Y\Z }% \def\XINT_mulr_finish_c #1\XINT_mulr_finish_ciii \W\W\W\W #2#3\Z\Z\Z\Z { #2}% +\def\xintiiSqr {\romannumeral0\xintiisqr }% +\def\xintiisqr #1% +{% + \expandafter\XINT_sqr\expandafter {\romannumeral0\xintiiabs{#1}}% +}% \def\xintiSqr {\romannumeral0\xintisqr }% \def\xintisqr #1% {% @@ -2169,7 +2380,11 @@ {% \expandafter\XINT_fac_fork\expandafter{\the\numexpr #1}% }% -\let\xintFac\xintiFac \let\xintfac\xintifac +\def\xintFac {\romannumeral0\xintfac }% +\def\xintfac #1% +{% + \expandafter\XINT_fac_fork\expandafter{\romannumeral0\xintnum{#1}}% +}% \def\XINT_fac_fork #1% {% \ifcase\XINT_Sgn {#1} @@ -2250,7 +2465,7 @@ \def\xintiPow {\romannumeral0\xintipow }% \def\xintipow #1% {% - \expandafter\xint_pow\romannumeral-`0#1\Z% + \expandafter\xint_pow\romannumeral0\xintnum{#1}\Z% }% \let\xintPow\xintiPow \let\xintpow\xintipow \def\xint_pow #1#2\Z @@ -2338,7 +2553,7 @@ \xint_afterfi{\expandafter\XINT_pow_loop_a \expandafter{\the\numexpr 2*(#1/2)-#1\expandafter }% b mod 2 \expandafter{\the\numexpr #1-#1/2\expandafter }% [b/2] - \expandafter{\romannumeral0\xintisqr{#2}}}% + \expandafter{\romannumeral0\xintiisqr{#2}}}% \fi {{#2}}% }% @@ -2400,12 +2615,12 @@ \def\xintiDivision {\romannumeral0\xintidivision }% \def\xintidivision #1% {% - \expandafter\xint_division\expandafter {\romannumeral-`0#1}% + \expandafter\xint_division\expandafter {\romannumeral0\xintnum{#1}}% }% \let\xintDivision\xintiDivision \let\xintdivision\xintidivision \def\xint_division #1#2% {% - \expandafter\XINT_div_fork \romannumeral-`0#2\Z #1\Z + \expandafter\XINT_div_fork \romannumeral0\xintnum{#2}\Z #1\Z }% \def\XINT_Division #1#2{\romannumeral0\XINT_div_fork #2\Z #1\Z }% \def\XINT_div_fork #1#2\Z #3#4\Z @@ -2458,7 +2673,7 @@ \def\XINT_div_AisNegative_posrem #1% {% \expandafter \XINT_div_AisNegative_posrem_b \expandafter - {\romannumeral0\xintiopp{\xintInc {#1}}}% + {\romannumeral0\xintiiopp{\xintInc {#1}}}% }% \def\XINT_div_AisNegative_posrem_b #1#2#3% {% @@ -2618,14 +2833,14 @@ \def\XINT_div_final_dP #1#2#3#4#5% q,A,Q,L,B (puis c) {% \expandafter \XINT_div_final_f \expandafter - {\romannumeral0\xintisub {#2}% + {\romannumeral0\xintiisub {#2}% {\romannumeral0\XINT_mul_M {#1}#5\Z\Z\Z\Z }}% {\romannumeral0\XINT_add_A 0{}#1000\W\X\Y\Z #3\W\X\Y\Z }% }% \def\XINT_div_final_db #1#2#3#4#5% q,A,Q,L,B (puis c) {% \expandafter\XINT_div_final_dc\expandafter - {\romannumeral0\xintisub {#2}% + {\romannumeral0\xintiisub {#2}% {\romannumeral0\XINT_mul_M {#1}#5\Z\Z\Z\Z }}% {#1}{#2}{#3}{#4}{#5}% }% @@ -2882,7 +3097,11 @@ {% \expandafter\XINT_fdg \romannumeral-`0#1\W\Z }% -\let\xintFDg\xintiFDg \let\xintfdg\xintifdg +\def\xintFDg {\romannumeral0\xintfdg }% +\def\xintfdg #1% +{% + \expandafter\XINT_fdg \romannumeral0\xintnum{#1}\W\Z +}% \def\XINT_FDg #1{\romannumeral0\XINT_fdg #1\W\Z }% \def\XINT_fdg #1#2#3\Z {% @@ -2897,7 +3116,11 @@ {% \expandafter\XINT_ldg\expandafter {\romannumeral-`0#1}% }% -\let\xintLDg\xintiLDg \let\xintldg\xintildg +\def\xintLDg {\romannumeral0\xintldg }% +\def\xintldg #1% +{% + \expandafter\XINT_ldg\expandafter {\romannumeral0\xintnum{#1}}% +}% \def\XINT_LDg #1{\romannumeral0\XINT_ldg {#1}}% \def\XINT_ldg #1% {% @@ -2922,8 +3145,24 @@ \xint_afterfi{ -1}% \fi }% -\let\xintMON\xintiMON \let\xintmon\xintimon -\let\xintMMON\xintiMMON \let\xintmmon\xintimmon +\def\xintMON {\romannumeral0\xintmon }% +\def\xintmon #1% +{% + \ifodd\xintLDg {#1} + \xint_afterfi{ -1}% + \else + \xint_afterfi{ 1}% + \fi +}% +\def\xintMMON {\romannumeral0\xintmmon }% +\def\xintmmon #1% +{% + \ifodd\xintLDg {#1} + \xint_afterfi{ 1}% + \else + \xint_afterfi{ -1}% + \fi +}% \def\xintiOdd {\romannumeral0\xintiodd }% \def\xintiodd #1% {% @@ -2941,7 +3180,15 @@ \xint_afterfi{ 0}% \fi }% -\let\xintOdd\xintiOdd \let\xintodd\xintiodd +\def\xintOdd {\romannumeral0\xintodd }% +\def\xintodd #1% +{% + \ifodd\xintLDg{#1} + \xint_afterfi{ 1}% + \else + \xint_afterfi{ 0}% + \fi +}% \def\xintDSL {\romannumeral0\xintdsl }% \def\xintdsl #1% {% @@ -3458,7 +3705,7 @@ \W\W\W\W\W\W\W\W }% \def\xintiSquareRoot {\romannumeral0\xintisquareroot }% \def\xintisquareroot #1% - {\expandafter\XINT_sqrt_checkin\romannumeral-`0#1\Z}% + {\expandafter\XINT_sqrt_checkin\romannumeral0\xintnum{#1}\Z}% \def\XINT_sqrt_checkin #1% {% \xint_UDzerominusfork @@ -3612,13 +3859,13 @@ {% \expandafter\XINT_sqrt_big_f_a\expandafter {\the\numexpr #2+#3\expandafter}\expandafter - {\romannumeral-`0\XINT_dsx_addzerosnofuss + {\romannumeral0\XINT_dsx_addzerosnofuss {\numexpr #4-\xint_c_iv\relax}{#1}}{#4}% }% \def\XINT_sqrt_big_f_a #1#2#3#4% {% \expandafter\XINT_sqrt_big_g\expandafter - {\romannumeral0\xintisub + {\romannumeral0\xintiisub {\XINT_dsx_addzerosnofuss {\numexpr \xint_c_ii*#3-\xint_c_viii\relax}{#1}}{#4}}% {#2}{#3}% @@ -3639,8 +3886,8 @@ \def\XINT_sqrt_big_k #1#2#3% {% \expandafter\XINT_sqrt_big_l\expandafter - {\romannumeral0\xintisub {#3}{#1}}% - {\romannumeral0\xintiadd {#2}{\xintiSqr {#1}}}% + {\romannumeral0\xintiisub {#3}{#1}}% + {\romannumeral0\xintiiadd {#2}{\xintiiSqr {#1}}}% }% \def\XINT_sqrt_big_l #1#2% {% diff --git a/Master/texmf-dist/tex/generic/xint/xintbinhex.sty b/Master/texmf-dist/tex/generic/xint/xintbinhex.sty index d023151c236..8b9ab594cf3 100644 --- a/Master/texmf-dist/tex/generic/xint/xintbinhex.sty +++ b/Master/texmf-dist/tex/generic/xint/xintbinhex.sty @@ -22,7 +22,7 @@ %% in the same archive or directory.) %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.08b of June 14, 2013) +%% The xint bundle (version 1.09a of September 22, 2013) %% xintbinhex: Expandable binary and hexadecimal conversions %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -163,7 +163,7 @@ \fi \expandafter\x\csname ver@xintbinhex.sty\endcsname \ProvidesPackage{xintbinhex}% - [2013/06/14 v1.08b Expandable binary and hexadecimal conversions (jfB)]% + [2013/09/24 v1.09a Expandable binary and hexadecimal conversions (jfB)]% \chardef\xint_c_xvi 16 \chardef\xint_c_ii^v 32 \chardef\xint_c_ii^vi 64 @@ -178,14 +178,14 @@ \expandafter\edef\csname XINT_sdth_#1\endcsname {\ifcase #1 0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or 8\or 9\or A\or B\or C\or D\or E\or F\fi}}% -\xintApplyUnbraced\XINT_tmp_def +\xintApplyInline\XINT_tmp_def {{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}}% \def\XINT_tmp_def #1{% \expandafter\edef\csname XINT_sdtb_#1\endcsname {\ifcase #1 0000\or 0001\or 0010\or 0011\or 0100\or 0101\or 0110\or 0111\or 1000\or 1001\or 1010\or 1011\or 1100\or 1101\or 1110\or 1111\fi}}% -\xintApplyUnbraced\XINT_tmp_def +\xintApplyInline\XINT_tmp_def {{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}}% \let\XINT_tmp_def\empty \expandafter\def\csname XINT_sbtd_0000\endcsname {0}% diff --git a/Master/texmf-dist/tex/generic/xint/xintcfrac.sty b/Master/texmf-dist/tex/generic/xint/xintcfrac.sty index 87eabb785ed..139e4cb47f6 100644 --- a/Master/texmf-dist/tex/generic/xint/xintcfrac.sty +++ b/Master/texmf-dist/tex/generic/xint/xintcfrac.sty @@ -22,7 +22,7 @@ %% in the same archive or directory.) %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.08b of June 14, 2013) +%% The xint bundle (version 1.09a of September 22, 2013) %% xintcfrac: Expandable continued fractions with xint package %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -165,7 +165,7 @@ \fi \expandafter\x\csname ver@xintcfrac.sty\endcsname \ProvidesPackage{xintcfrac}% - [2013/06/14 v1.08b Expandable continued fractions with xint package (jfB)]% + [2013/09/24 v1.09a Expandable continued fractions with xint package (jfB)]% \def\xintCFrac {\romannumeral0\xintcfrac }% \def\xintcfrac #1% {% @@ -485,8 +485,8 @@ \expandafter\XINT_cstf_loop_c\expandafter {\romannumeral0\XINT_mul_fork #2\Z #4\Z }% {\romannumeral0\XINT_mul_fork #2\Z #3\Z }% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% }% \def\XINT_cstf_loop_c #1#2% {% @@ -519,8 +519,8 @@ \def\XINT_icstf_loop_b #1.#2#3#4#5% {% \expandafter\XINT_icstf_loop_c\expandafter - {\romannumeral0\xintiadd {#5}{\XINT_Mul {#1}{#3}}}% - {\romannumeral0\xintiadd {#4}{\XINT_Mul {#1}{#2}}}% + {\romannumeral0\xintiiadd {#5}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {#4}{\XINT_Mul {#1}{#2}}}% {#2}{#3}% }% \def\XINT_icstf_loop_c #1#2% @@ -547,8 +547,8 @@ \expandafter\XINT_gctf_loop_c\expandafter {\romannumeral0\XINT_mul_fork #2\Z #4\Z }% {\romannumeral0\XINT_mul_fork #2\Z #3\Z }% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% }% \def\XINT_gctf_loop_c #1#2% {% @@ -606,8 +606,8 @@ \def\XINT_igctf_loop_b #1.#2#3#4#5% {% \expandafter\XINT_igctf_loop_c\expandafter - {\romannumeral0\xintiadd {#5}{\XINT_Mul {#1}{#3}}}% - {\romannumeral0\xintiadd {#4}{\XINT_Mul {#1}{#2}}}% + {\romannumeral0\xintiiadd {#5}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {#4}{\XINT_Mul {#1}{#2}}}% {#2}{#3}% }% \def\XINT_igctf_loop_c #1#2% @@ -655,8 +655,8 @@ \expandafter\XINT_cstcv_loop_c\expandafter {\romannumeral0\XINT_mul_fork #2\Z #4\Z }% {\romannumeral0\XINT_mul_fork #2\Z #3\Z }% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% }% \def\XINT_cstcv_loop_c #1#2% {% @@ -695,8 +695,8 @@ \def\XINT_icstcv_loop_b #1.#2#3#4#5% {% \expandafter\XINT_icstcv_loop_c\expandafter - {\romannumeral0\xintiadd {#5}{\XINT_Mul {#1}{#3}}}% - {\romannumeral0\xintiadd {#4}{\XINT_Mul {#1}{#2}}}% + {\romannumeral0\xintiiadd {#5}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {#4}{\XINT_Mul {#1}{#2}}}% {{#2}{#3}}% }% \def\XINT_icstcv_loop_c #1#2% @@ -729,8 +729,8 @@ \expandafter\XINT_gctcv_loop_c\expandafter {\romannumeral0\XINT_mul_fork #2\Z #4\Z }% {\romannumeral0\XINT_mul_fork #2\Z #3\Z }% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% - {\romannumeral0\xintiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#6}}{\XINT_Mul {#1}{#4}}}% + {\romannumeral0\xintiiadd {\XINT_Mul {#2}{#5}}{\XINT_Mul {#1}{#3}}}% }% \def\XINT_gctcv_loop_c #1#2% {% @@ -798,8 +798,8 @@ \def\XINT_igctcv_loop_b #1.#2#3#4#5% {% \expandafter\XINT_igctcv_loop_c\expandafter - {\romannumeral0\xintiadd {#5}{\XINT_Mul {#1}{#3}}}% - {\romannumeral0\xintiadd {#4}{\XINT_Mul {#1}{#2}}}% + {\romannumeral0\xintiiadd {#5}{\XINT_Mul {#1}{#3}}}% + {\romannumeral0\xintiiadd {#4}{\XINT_Mul {#1}{#2}}}% {{#2}{#3}}% }% \def\XINT_igctcv_loop_c #1#2% diff --git a/Master/texmf-dist/tex/generic/xint/xintexpr.sty b/Master/texmf-dist/tex/generic/xint/xintexpr.sty index 45378ace18a..3c1de7ed8a9 100644 --- a/Master/texmf-dist/tex/generic/xint/xintexpr.sty +++ b/Master/texmf-dist/tex/generic/xint/xintexpr.sty @@ -22,7 +22,7 @@ %% in the same archive or directory.) %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.08b of June 14, 2013) +%% The xint bundle (version 1.09a of September 22, 2013) %% xintexpr: Expandable expression parser %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -114,6 +114,10 @@ \endgroup \edef\XINT_expr_restorecatcodes_endinput {% + \catcode63=\the\catcode63 % ? + \catcode124=\the\catcode124 % | + \catcode38=\the\catcode38 % & + \catcode64=\the\catcode64 % @ \catcode33=\the\catcode33 % ! \catcode93=\the\catcode93 % ] \catcode91=\the\catcode91 % [ @@ -141,14 +145,17 @@ \noexpand\endinput }% \XINT_setcatcodes % defined in xint.sty - \catcode91=12 % [ - \catcode93=12 % ] - \catcode33=11 % ! + \catcode91=12 % [ + \catcode93=12 % ] + \catcode33=11 % ! + \catcode64=11 % @ + \catcode38=12 % & + \catcode124=12 % | + \catcode63=11 % ? }% \x \begingroup - \catcode64=11 % @ - \catcode58=12 % : + \catcode58=12 % : (but doesn't matter) \expandafter\ifx\csname ProvidesPackage\endcsname\relax \def\x#1#2#3[#4]{\endgroup \immediate\write-1{Package: #3 #4}% @@ -167,191 +174,40 @@ \fi \expandafter\x\csname ver@xintexpr.sty\endcsname \ProvidesPackage{xintexpr}% - [2013/06/14 v1.08b Expandable expression parser (jfB)]% + [2013/09/24 v1.09a Expandable expression parser (jfB)]% \def\xint_gob_til_dot #1.{}% \def\xint_gob_til_dot_andstop #1.{ }% -\def\xint_gob_til_! #1!{}% ! of catcode 11 -\def\XINT_expr_string {\expandafter\xint_gob_til_dot\string }% +\def\xint_gob_til_! #1!{}% nota bene: ! is of catcode 11 \def\XINT_expr_unexpectedtoken {\xintError:ignored }% -\def\xintexpr {\romannumeral0\xinteval }% +\def\XINT_newexpr_stripprefix #1>{\noexpand\romannumeral-`0}% +\def\xint_firstofone #1{#1}% +\def\XINT_expr_lock #1!{\expandafter\space\csname .#1\endcsname }% +\def\XINT_expr_unlock {\expandafter\xint_gob_til_dot\string }% +\def\XINT_expr_usethe {use_xintthe!\xintError:use_xintthe! }% +\def\XINT_expr_done {!\XINT_expr_usethe\XINT_expr_print }% +\def\XINT_expr_print #1{\XINT_expr_unlock #1}% +\def\XINT_flexpr_done {!\XINT_expr_usethe\XINT_flexpr_print }% +\def\XINT_flexpr_print #1{\xintFloat:csv{\XINT_expr_unlock #1}}% +\def\XINT_numexpr_print #1{\xintRound:csv{\XINT_expr_unlock #1}}% +\def\xintexpr {\romannumeral0\xinteval }% \def\xinteval {% - \expandafter\XINT_expr_until_end\romannumeral-`0% - \expandafter\XINT_expr_checkifprefix_ii\romannumeral-`0% - \XINT_expr_getnext -}% -\def\xinttheexpr {\romannumeral0\xinttheeval }% -\def\xinttheeval {\expandafter\XINT_expr_the\romannumeral0\xinteval }% -\def\XINT_expr_the #1#2#3{\xintraw{\XINT_expr_string #3}}% -\def\xintthe #1{\ifx#1\xintexpr \expandafter\xinttheexpr - \else\expandafter\xintthefloatexpr\fi}% -\def\XINT_expr_until_end #1% -{% - \ifcase#1% - \expandafter\xint_gobble_vi - \or - \expandafter\XINT_expr_extra_closing_paren - \fi - \expandafter\XINT_expr_until_end\romannumeral-`0\romannumeral-`0% -}% -\def\XINT_expr_extra_closing_paren {\xintError:removed }% -\def\XINT_expr_endofexpr {!\XINT_illegaluse }% -\def\XINT_illegaluse - {Illegal_here_use_xintthe\xintError:use_xintthe!\xint_gobble_i }% -\def\XINT_expr_oparen -{% - \expandafter\XINT_expr_until_cparen\romannumeral-`0% - \expandafter\XINT_expr_checkifprefix_ii\romannumeral-`0% - \XINT_expr_getnext -}% -\def\XINT_expr_until_cparen #1% -{% - \ifcase#1% - \expandafter\XINT_expr_missing_cparen - \or - \else \xint_afterfi - {\expandafter\XINT_expr_until_cparen\romannumeral-`0\romannumeral-`0}% - \fi -}% -\def\XINT_expr_missing_cparen #1% -{% - \xintError:inserted \xint_c_ \XINT_expr_endofexpr -}% -\def\xint_tmp_def #1#2#3% -{% - \expandafter\xint_tmp_do_defs - \csname XINT_expr_op_#1\expandafter\endcsname - \csname XINT_expr_until_#1\expandafter\endcsname - \csname XINT_expr_checkifprefix_#2\expandafter\endcsname - \csname XINT_expr_precedence_#1\expandafter\endcsname - \csname xint_c_#2\expandafter\endcsname - \csname xint#3\endcsname -}% -\def\xint_tmp_do_defs #1#2#3#4#5#6% -{% - \def #1##1% \XINT_expr_op_? - {% - \expandafter #2\expandafter ##1\romannumeral-`0\expandafter - #3\romannumeral-`0\XINT_expr_getnext - }% - \def #2##1##2##3##4% \XINT_expr_until_? - {% - \ifnum ##2>#5% - \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0##3##4}% - \else - \xint_afterfi - {\expandafter ##2\expandafter ##3% - \csname .#6{\XINT_expr_string ##1}{\XINT_expr_string ##4}\endcsname }% - \fi - }% - \let #4#5% -}% -\xint_tmp_def +{ii}{Add}% -\xint_tmp_def -{ii}{Sub}% -\xint_tmp_def *{iii}{Mul}% -\xint_tmp_def /{iii}{Div}% -\xint_tmp_def ^{iv}{Pow}% -\xint_tmp_def e{v}{fE}% -\xint_tmp_def E{v}{fE}% -\def\xint_tmp_def #1% -{% - \expandafter\xint_tmp_do_defs - \csname XINT_expr_checkifprefix_#1\expandafter\endcsname - \csname XINT_expr_op_-#1\endcsname -}% -\def\xint_tmp_do_defs #1#2% -{% - \def #1##1% - {\xint_UDsignfork - ##1\dummy #2% - -\dummy ##1% - \krof }% -}% -\xint_tmp_def {ii}% -\xint_tmp_def {iii}% -\xint_tmp_def {iv}% -\xint_tmp_def {v}% -\def\xint_tmp_def #1% -{% - \expandafter\xint_tmp_do_defs - \csname XINT_expr_op_-#1\expandafter\endcsname - \csname XINT_expr_until_-#1\expandafter\endcsname - \csname XINT_expr_checkifprefix_#1\expandafter\endcsname - \csname xint_c_#1\endcsname -}% -\def\xint_tmp_do_defs #1#2#3#4% -{% - \def #1% \XINT_expr_op_-ii,iii,iv,v - {% - \expandafter #2\romannumeral-`0\expandafter - #3\romannumeral-`0\XINT_expr_getnext - }% - \def #2##1##2##3% \XINT_expr_until_-ii,iii,iv,v - {% - \ifnum ##1>#4% - \xint_afterfi {\expandafter #2\romannumeral-`0##2##3}% - \else - \xint_afterfi {\expandafter ##1\expandafter ##2% - \csname .\xintOpp{\XINT_expr_string ##3}\endcsname }% - \fi - }% -}% -\xint_tmp_def {ii}% -\xint_tmp_def {iii}% -\xint_tmp_def {iv}% -\xint_tmp_def {v}% -\def\XINT_expr_getop #1% -{% - \expandafter\XINT_expr_getop_a\expandafter #1% - \romannumeral-`0\romannumeral-`0% -}% -\def\XINT_expr_getop_a #1#2% -{% - \ifcat #2\relax - \ifx #2\relax - \expandafter\expandafter\expandafter - \XINT_expr_foundendofexpr - \else - \XINT_expr_unexpectedtoken - \expandafter\expandafter\expandafter - \XINT_expr_getop - \fi - \else - \expandafter\XINT_expr_op_found\expandafter #2% - \fi - #1% + \expandafter\XINT_expr_until_end_a \romannumeral-`0\XINT_expr_getnext }% -\def\XINT_expr_foundendofexpr {\xint_c_ \XINT_expr_endofexpr }% -\def\XINT_expr_op_found #1% -{% - \ifcsname XINT_expr_precedence_\string #1\endcsname - \expandafter\xint_afterfi\expandafter - {\csname XINT_expr_precedence_\string #1\expandafter\endcsname - \csname XINT_expr_op_\string #1\endcsname }% - \else - \XINT_expr_unexpectedtoken - \expandafter\XINT_expr_getop - \fi -}% -\expandafter\let\csname XINT_expr_precedence_)\endcsname \xint_c_i -\expandafter\let\csname XINT_expr_op_)\endcsname\XINT_expr_getop -\def\xint_tmp_def -{% - \expandafter\xint_tmp_do_defs - \csname XINT_expr_precedence_!\expandafter\endcsname - \csname XINT_expr_op_!\endcsname -}% -\def\xint_tmp_do_defs #1#2% +\def\xinttheeval {\expandafter\xint_gobble_ii\romannumeral0\xinteval }% +\def\xinttheexpr {\romannumeral-`0\xinttheeval }% +\def\XINT_numexpr_post !\XINT_expr_usethe\XINT_expr_print% + { !\XINT_expr_usethe\XINT_numexpr_print }% +\def\xintnumexpr {\romannumeral0\expandafter\XINT_numexpr_post + \romannumeral0\xinteval }% +\def\xintthenumexpr {\romannumeral-`0\xintthe\xintnumexpr }% +\def\xintfloatexpr {\romannumeral0\xintfloateval }% +\def\xintfloateval {% - \def #1##1##2% - {\ifx ##1#2% - \expandafter\xint_firstoftwo - \else\expandafter\xint_secondoftwo - \fi{\expandafter\XINT_expr_getop}{\expandafter\XINT_flexpr_getop}% - \csname .\xintFac{\XINT_expr_string ##2}/1[0]\endcsname }% - \let#2\empty + \expandafter\XINT_flexpr_until_end_a \romannumeral-`0\XINT_expr_getnext }% -\xint_tmp_def +\def\xintthefloatexpr {\romannumeral-`0\xintthe\xintfloatexpr }% +\def\xintthe #1{\romannumeral-`0\expandafter\xint_gobble_ii\romannumeral-`0#1}% \def\XINT_expr_getnext {% \expandafter\XINT_expr_getnext_checkforbraced_a @@ -385,300 +241,648 @@ #2\dummy \XINT_expr_getnext_onetoken_wehope \W\dummy \XINT_expr_getnext_gotbracedstuff \krof -}% +}% doubly braced things are not acceptable, will cause errors. \def\XINT_expr_getnext_emptybracepair #1{\XINT_expr_getnext }% -\def\XINT_expr_getnext_gotbracedstuff #1\W\Z #2% +\def\XINT_expr_getnext_gotbracedstuff #1\W\Z #2% {..} -> number/fraction {% \expandafter\XINT_expr_getop\csname .#2\endcsname }% -\def\XINT_expr_getnext_onetoken_wehope\Z #1% +\def\XINT_expr_getnext_onetoken_wehope\Z #1% #1 isn't a control sequence! {% \xint_gob_til_! #1\XINT_expr_subexpr !% \expandafter\XINT_expr_getnext_onetoken_fork\string #1% -}% -\def\XINT_expr_subexpr !#1!{\expandafter\XINT_expr_getop\xint_gobble_i }% +}% after this #1 should be now a catcode 12 token. +\def\XINT_expr_subexpr !#1!{\expandafter\XINT_expr_getop\xint_gobble_ii }% \begingroup -\lccode`*=`_ +\lccode`*=`# \lowercase{\endgroup \def\XINT_expr_sixwayfork #1(-.+*\dummy #2#3\krof {#2}% \def\XINT_expr_getnext_onetoken_fork #1% -{% +{% The * is in truth catcode 12 #. For (clever!) use with \xintNewExpr. \XINT_expr_sixwayfork - #1-.+*\dummy \XINT_expr_oparen + #1-.+*\dummy {\xint_c_x ({}}% back to until to trigger oparen (#1.+*\dummy -% - (-#1+*\dummy {\XINT_expr_scannum_start\XINT_expr_scannum_decpart_b.}% + (-#1+*\dummy {\XINT_expr_scandec_II.}% (-.#1*\dummy \XINT_expr_getnext% - (-.+#1\dummy {\XINT_expr_scannum_start\XINT_expr_scannum_decpart_b*}% - (-.+*\dummy {\XINT_expr_scannum_check #1}% + (-.+#1\dummy {\XINT_expr_scandec_II}% + (-.+*\dummy {\XINT_expr_scan_dec_or_func #1}% \krof }}% -\def\XINT_expr_scannum_check #1% +\def\XINT_expr_scan_dec_or_func #1% this #1 of catcode 12 {% \ifnum \xint_c_ix<1#1 - \expandafter\XINT_expr_scannum_start + \expandafter\XINT_expr_scandec_I + \else % We assume we are dealing with a function name!! + \expandafter\XINT_expr_scanfunc + \fi #1% +}% +\def\XINT_expr_scanfunc +{% + \expandafter\XINT_expr_func\romannumeral-`0\XINT_expr_scanfunc_c +}% +\def\XINT_expr_scanfunc_c #1% +{% + \expandafter #1\romannumeral-`0\expandafter + \XINT_expr_scanfunc_a\romannumeral-`0\romannumeral-`0% +}% +\def\XINT_expr_scanfunc_a #1% please no braced things here! +{% + \ifcat #1\relax % missing opening parenthesis, probably + \expandafter\XINT_expr_scanfunc_panic \else - \xint_afterfi{\XINT_expr_unexpectedtoken - \expandafter\XINT_expr_getnext\xint_gobble_ii}% - \fi \XINT_expr_scannum_intpart_b #1% + \xint_afterfi{\expandafter\XINT_expr_scanfunc_b \string #1}% + \fi +}% +\def\XINT_expr_scanfunc_b #1% +{% + \if #1(\else\expandafter \XINT_expr_scanfunc_c \fi #1% +}% +\def\XINT_expr_scanfunc_panic {\xintError:bigtroubleahead(0\relax }% +\def\XINT_expr_func #1(% common to expr and flexpr +{% + \xint_c_x @{#1}% }% -\def\XINT_expr_scannum_stopscan {!}% ! catcode 11 -\def\XINT_expr_gathernum #1!% ! with catcode 11 +\def\XINT_expr_scandec_I {% - \expandafter\space\csname .#1\endcsname + \expandafter\XINT_expr_getop\romannumeral-`0\expandafter + \XINT_expr_lock\romannumeral-`0\XINT_expr_scanintpart_b }% -\def\XINT_expr_scannum_start #1% +\def\XINT_expr_scandec_II {% - \expandafter\XINT_expr_getop - \romannumeral-`0\expandafter\XINT_expr_gathernum - \romannumeral-`0#1% + \expandafter\XINT_expr_getop\romannumeral-`0\expandafter + \XINT_expr_lock\romannumeral-`0\XINT_expr_scanfracpart_b }% -\def\XINT_expr_scannum_intpart_a #1% +\def\XINT_expr_scanintpart_a #1% {% \ifnum \xint_c_ix<1\string#1 - \expandafter\expandafter\expandafter - \XINT_expr_scannum_intpart_b + \expandafter\expandafter\expandafter\XINT_expr_scanintpart_b \expandafter\string \else \if #1.% \expandafter\expandafter\expandafter - \XINT_expr_scannum_transition + \XINT_expr_scandec_transition \else - \expandafter\expandafter\expandafter - \XINT_expr_scannum_stopscan + \expandafter\expandafter\expandafter !% ! of catcode 11... \fi \fi #1% }% -\def\XINT_expr_scannum_intpart_b #1% +\def\XINT_expr_scanintpart_b #1% {% \expandafter #1\romannumeral-`0\expandafter - \XINT_expr_scannum_intpart_a\romannumeral-`0\romannumeral-`0% + \XINT_expr_scanintpart_a\romannumeral-`0\romannumeral-`0% }% -\def\XINT_expr_scannum_transition #1% +\def\XINT_expr_scandec_transition #1% {% \expandafter.\romannumeral-`0\expandafter - \XINT_expr_scannum_decpart_a\romannumeral-`0\romannumeral-`0% + \XINT_expr_scanfracpart_a\romannumeral-`0\romannumeral-`0% }% -\def\XINT_expr_scannum_decpart_a #1% +\def\XINT_expr_scanfracpart_a #1% {% \ifnum \xint_c_ix<1\string#1 - \expandafter\expandafter\expandafter - \XINT_expr_scannum_decpart_b\expandafter\string + \expandafter\expandafter\expandafter\XINT_expr_scanfracpart_b + \expandafter\string \else - \expandafter \XINT_expr_scannum_stopscan + \expandafter !% \fi #1% }% -\def\XINT_expr_scannum_decpart_b #1% +\def\XINT_expr_scanfracpart_b #1% {% \expandafter #1\romannumeral-`0\expandafter - \XINT_expr_scannum_decpart_a\romannumeral-`0\romannumeral-`0% + \XINT_expr_scanfracpart_a\romannumeral-`0\romannumeral-`0% }% -\def\xintfloatexpr {\romannumeral0\xintfloateval }% -\def\xintfloateval +\def\XINT_expr_getop #1% this #1 is the current locked computed value +{% full expansion of next token, first swallowing a possible space + \expandafter\XINT_expr_getop_a\expandafter #1% + \romannumeral-`0\romannumeral-`0% +}% +\def\XINT_expr_getop_a #1#2% +{% if an un-expandable control sequence is found, must be the ending \relax + \ifcat #2\relax + \ifx #2\relax + \expandafter\expandafter\expandafter + \XINT_expr_foundend + \else + \XINT_expr_unexpectedtoken + \expandafter\expandafter\expandafter + \XINT_expr_getop + \fi + \else + \expandafter\XINT_expr_foundop\expandafter #2% + \fi + #1% +}% +\def\XINT_expr_foundend {\xint_c_ \relax }% \relax is a place holder here. +\def\XINT_expr_foundop #1% then becomes <prec> <op> and is followed by <\.f> +{% 1.09a: no control sequence \XINT_expr_op_#1, code common to expr/flexpr + \ifcsname XINT_expr_precedence_#1\endcsname + \expandafter\xint_afterfi\expandafter + {\csname XINT_expr_precedence_#1\endcsname #1}% + \else + \XINT_expr_unexpectedtoken + \expandafter\XINT_expr_getop + \fi +}% +\def\xint_tmp_do_defs #1#2#3#4#5% {% - \expandafter\XINT_expr_until_end\romannumeral-`0% - \expandafter\XINT_flexpr_checkifprefix_ii\romannumeral-`0% - \XINT_flexpr_getnext + \def#1##1% + {% + \xint_UDsignfork + ##1\dummy {\expandafter#1\romannumeral-`0#3}% + -\dummy {#2##1}% + \krof + }% + \def#2##1##2% + {% + \ifcase ##1\expandafter #4% + \or \xint_afterfi{% + \XINT_expr_extra_closing_paren + \expandafter #1\romannumeral-`0\XINT_expr_getop + }% + \else \xint_afterfi{% + \expandafter#1\romannumeral-`0\csname XINT_#5_op_##2\endcsname + }% + \fi + }% }% -\def\xintthefloatexpr {\romannumeral0\xintthefloateval }% -\def\xintthefloateval - {\expandafter\XINT_flexpr_the\romannumeral0\xintfloateval }% -\def\XINT_flexpr_the #1#2#3{\xintfloat{\XINT_expr_string #3}}% -\def\XINT_flexpr_oparen +\expandafter\xint_tmp_do_defs + \csname XINT_expr_until_end_a\expandafter\endcsname + \csname XINT_expr_until_end_b\expandafter\endcsname + \csname XINT_expr_op_-vi\expandafter\endcsname + \csname XINT_expr_done\endcsname + {expr}% +\expandafter\xint_tmp_do_defs + \csname XINT_flexpr_until_end_a\expandafter\endcsname + \csname XINT_flexpr_until_end_b\expandafter\endcsname + \csname XINT_flexpr_op_-vi\expandafter\endcsname + \csname XINT_flexpr_done\endcsname + {flexpr}% +\def\XINT_expr_extra_closing_paren {\xintError:removed }% +\def\xint_tmp_do_defs #1#2#3#4#5#6% {% - \expandafter\XINT_expr_until_cparen\romannumeral-`0% - \expandafter\XINT_flexpr_checkifprefix_ii\romannumeral-`0% - \XINT_flexpr_getnext + \def #1{\expandafter #3\romannumeral-`0\XINT_expr_getnext }% + \let #2#1% + \def #3##1{\xint_UDsignfork + ##1\dummy {\expandafter #3\romannumeral-`0#5}% + -\dummy {#4##1}% + \krof }% + \def #4##1##2% + {% + \ifcase ##1\expandafter \XINT_expr_missing_cparen + \or \expandafter \XINT_expr_getop + \else \xint_afterfi + {\expandafter #3\romannumeral-`0\csname XINT_#6_op_##2\endcsname }% + \fi + }% }% -\def\xint_tmp_def #1#2#3% +\expandafter\xint_tmp_do_defs + \csname XINT_expr_op_(\expandafter\endcsname + \csname XINT_expr_oparen\expandafter\endcsname + \csname XINT_expr_until_)_a\expandafter\endcsname + \csname XINT_expr_until_)_b\expandafter\endcsname + \csname XINT_expr_op_-vi\endcsname + {expr}% +\expandafter\xint_tmp_do_defs + \csname XINT_flexpr_op_(\expandafter\endcsname + \csname XINT_flexpr_oparen\expandafter\endcsname + \csname XINT_flexpr_until_)_a\expandafter\endcsname + \csname XINT_flexpr_until_)_b\expandafter\endcsname + \csname XINT_flexpr_op_-vi\endcsname + {flexpr}% +\def\XINT_expr_missing_cparen {\xintError:inserted \xint_c_ \XINT_expr_done }% +\expandafter\let\csname XINT_expr_precedence_)\endcsname \xint_c_i +\expandafter\let\csname XINT_expr_op_)\endcsname\XINT_expr_getop +\expandafter\let\csname XINT_flexpr_precedence_)\endcsname \xint_c_i +\expandafter\let\csname XINT_flexpr_op_)\endcsname\XINT_expr_getop +\def\xint_tmp_def #1#2#3#4#5#6% {% \expandafter\xint_tmp_do_defs - \csname XINT_flexpr_op_#1\expandafter\endcsname - \csname XINT_flexpr_until_#1\expandafter\endcsname - \csname XINT_flexpr_checkifprefix_#2\expandafter\endcsname - \csname XINT_expr_precedence_#1\expandafter\endcsname - \csname xint_c_#2\expandafter\endcsname - \csname XINTinFloat#3\endcsname + \csname XINT_#1_op_#3\expandafter\endcsname + \csname XINT_#1_until_#3_a\expandafter\endcsname + \csname XINT_#1_until_#3_b\expandafter\endcsname + \csname XINT_#1_op_-#5\expandafter\endcsname + \csname xint_c_#4\expandafter\endcsname + \csname #2#6\expandafter\endcsname + \csname XINT_expr_precedence_#3\endcsname {#1}% +}% +\def\xint_tmp_do_defs #1#2#3#4#5#6#7#8% +{% + \def #1##1% \XINT_expr_op_<op> + {% keep value, get next number and operator, then do until + \expandafter #2\expandafter ##1% + \romannumeral-`0\expandafter\XINT_expr_getnext + }% + \def #2##1##2% \XINT_expr_until_<op>_a + {\xint_UDsignfork + ##2\dummy {\expandafter #2\expandafter ##1\romannumeral-`0#4}% + -\dummy {#3##1##2}% + \krof }% + \def #3##1##2##3##4% \XINT_expr_until_<op>_b + {% either execute next operation now, or first do next (possibly unary) + \ifnum ##2>#5% + \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0% + \csname XINT_#8_op_##3\endcsname {##4}}% + \else + \xint_afterfi + {\expandafter ##2\expandafter ##3% + \csname .#6{\XINT_expr_unlock ##1}{\XINT_expr_unlock ##4}\endcsname }% + \fi + }% + \let #7#5% }% +\def\xint_tmp_def_a #1{\xint_tmp_def {expr}{xint}#1}% +\xintApplyInline {\xint_tmp_def_a }{% + {|{iii}{vi}{OR}}% + {&{iv}{vi}{AND}}% + {<{v}{vi}{Lt}}% + {>{v}{vi}{Gt}}% + {={v}{vi}{Eq}}% + {+{vi}{vi}{Add}}% + {-{vi}{vi}{Sub}}% + {*{vii}{vii}{Mul}}% + {/{vii}{vii}{Div}}% + {^{viii}{viii}{Pow}}% + {e{ix}{ix}{fE}}% + {E{ix}{ix}{fE}}% +}% +\def\xint_tmp_def_a #1{\xint_tmp_def {flexpr}{xint}#1}% +\xintApplyInline {\xint_tmp_def_a }{% + {|{iii}{vi}{OR}}% + {&{iv}{vi}{AND}}% + {<{v}{vi}{Lt}}% + {>{v}{vi}{Gt}}% + {={v}{vi}{Eq}}% +}% +\def\xint_tmp_def_a #1{\xint_tmp_def {flexpr}{XINTinFloat}#1}% +\xintApplyInline {\xint_tmp_def_a }{% + {+{vi}{vi}{Add}}% + {-{vi}{vi}{Sub}}% + {*{vii}{vii}{Mul}}% + {/{vii}{vii}{Div}}% + {^{viii}{viii}{Power}}% + {e{ix}{ix}{fE}}% + {E{ix}{ix}{fE}}% +}% +\let\xint_tmp_def_a\empty \def\xint_tmp_do_defs #1#2#3#4#5#6% {% - \def #1##1% \XINT_flexpr_op_? + \def #1##1% \XINT_expr_op_,_a {% - \expandafter #2\expandafter ##1\romannumeral-`0\expandafter - #3\romannumeral-`0\XINT_flexpr_getnext + \expandafter #2\expandafter ##1\romannumeral-`0\XINT_expr_getnext }% - \def #2##1##2##3##4% \XINT_flexpr_until_? + \def #2##1##2% \XINT_expr_until_,_a + {\xint_UDsignfork + ##2\dummy {\expandafter #2\expandafter ##1\romannumeral-`0#4}% + -\dummy {#3##1##2}% + \krof }% + \def #3##1##2##3##4% \XINT_expr_until_,_b {% - \ifnum ##2>#5% - \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0##3##4}% + \ifnum ##2>\xint_c_ii + \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0% + \csname XINT_#6_op_##3\endcsname {##4}}% \else \xint_afterfi {\expandafter ##2\expandafter ##3% - \csname .#6{\XINT_expr_string ##1}% - {\XINT_expr_string ##4}\endcsname }% + \csname .\XINT_expr_unlock ##1,\XINT_expr_unlock ##4\endcsname }% \fi }% + \let #5\xint_c_ii }% -\xint_tmp_def +{ii}{Add}% -\xint_tmp_def -{ii}{Sub}% -\xint_tmp_def *{iii}{Mul}% -\xint_tmp_def /{iii}{Div}% -\xint_tmp_def ^{iv}{Power}% -\xint_tmp_def e{v}{fE}% -\xint_tmp_def E{v}{fE}% -\def\xint_tmp_def #1% +\expandafter\xint_tmp_do_defs + \csname XINT_expr_op_,\expandafter\endcsname + \csname XINT_expr_until_,_a\expandafter\endcsname + \csname XINT_expr_until_,_b\expandafter\endcsname + \csname XINT_expr_op_-vi\expandafter\endcsname + \csname XINT_expr_precedence_,\endcsname {expr}% +\expandafter\xint_tmp_do_defs + \csname XINT_flexpr_op_,\expandafter\endcsname + \csname XINT_flexpr_until_,_a\expandafter\endcsname + \csname XINT_flexpr_until_,_b\expandafter\endcsname + \csname XINT_flexpr_op_-vi\expandafter\endcsname + \csname XINT_expr_precedence_,\endcsname {flexpr}% +\def \XINT_expr_precedence_? #1#2#3#4% {% - \expandafter\xint_tmp_do_defs - \csname XINT_flexpr_checkifprefix_#1\expandafter\endcsname - \csname XINT_flexpr_op_-#1\endcsname + \xintifZero{\XINT_expr_unlock #2}% + {\XINT_expr_getnext #4}% + {\XINT_expr_getnext #3}% }% -\def\xint_tmp_do_defs #1#2% +\def \XINT_expr_precedence_: #1#2#3#4#5% {% - \def #1##1% - {\xint_UDsignfork - ##1\dummy #2% - -\dummy ##1% - \krof }% + \xintifSgn {\XINT_expr_unlock #2}% + {\XINT_expr_getnext #3}% + {\XINT_expr_getnext #4}% + {\XINT_expr_getnext #5}% }% -\xint_tmp_def {ii}% -\xint_tmp_def {iii}% -\xint_tmp_def {iv}% -\xint_tmp_def {v}% -\def\xint_tmp_def #1% +\def\xint_tmp_def #1#2% {% \expandafter\xint_tmp_do_defs - \csname XINT_flexpr_op_-#1\expandafter\endcsname - \csname XINT_expr_until_-#1\expandafter\endcsname - \csname XINT_flexpr_checkifprefix_#1\expandafter\endcsname - \csname xint_c_#1\endcsname + \csname XINT_#1_op_-#2\expandafter\endcsname + \csname XINT_#1_until_-#2_a\expandafter\endcsname + \csname XINT_#1_until_-#2_b\expandafter\endcsname + \csname xint_c_#2\endcsname {#1}% }% -\def\xint_tmp_do_defs #1#2#3#4% +\def\xint_tmp_do_defs #1#2#3#4#5% {% - \def #1% \XINT_flexpr_op_-ii,iii,iv,v - {% - \expandafter #2\romannumeral-`0\expandafter - #3\romannumeral-`0\XINT_flexpr_getnext + \def #1% \XINT_expr_op_-<level> + {% get next number+operator then switch to _until macro + \expandafter #2\romannumeral-`0\XINT_expr_getnext + }% + \def #2##1% \XINT_expr_until_-<l>_a + {\xint_UDsignfork + ##1\dummy {\expandafter #2\romannumeral-`0#1}% + -\dummy {#3##1}% + \krof }% + \def #3##1##2##3% \XINT_expr_until_-<l>_b + {% _until tests precedence level with next op, executes now or postpones + \ifnum ##1>#4% + \xint_afterfi {\expandafter #2\romannumeral-`0% + \csname XINT_#5_op_##2\endcsname {##3}}% + \else + \xint_afterfi {\expandafter ##1\expandafter ##2% + \csname .\xintOpp{\XINT_expr_unlock ##3}\endcsname }% + \fi }% }% -\xint_tmp_def {ii}% -\xint_tmp_def {iii}% -\xint_tmp_def {iv}% -\xint_tmp_def {v}% +\xintApplyInline{\xint_tmp_def {expr}}{{vi}{vii}{viii}{ix}}% +\xintApplyInline{\xint_tmp_def {flexpr}}{{vi}{vii}{viii}{ix}}% +\expandafter\def\csname XINT_expr_precedence_!\endcsname #1#2% + {\expandafter\XINT_expr_getop + \csname .\xintFac{\XINT_expr_unlock #2}[0]\endcsname }% \let\xint_tmp_def\empty \let\xint_tmp_do_defs\empty -\def\XINT_flexpr_getop #1% +\def\XINT_expr_op_@ #1% {% - \expandafter\XINT_flexpr_getop_a\expandafter #1% - \romannumeral-`0\romannumeral-`0% + \ifcsname XINT_expr_func_#1\endcsname + \xint_afterfi{% + \expandafter\expandafter\csname XINT_expr_func_#1\endcsname + }% + \else \xintError:unknownfunction + \xint_afterfi{\expandafter\XINT_expr_func_unknown}% + \fi + \romannumeral-`0\XINT_expr_oparen }% -\def\XINT_flexpr_getop_a #1#2% +\def\XINT_flexpr_op_@ #1% {% - \ifcat #2\relax - \ifx #2\relax - \expandafter\expandafter\expandafter - \XINT_expr_foundendofexpr - \else - \XINT_expr_unexpectedtoken - \expandafter\expandafter\expandafter - \XINT_flexpr_getop - \fi - \else - \expandafter\XINT_flexpr_op_found\expandafter #2% + \ifcsname XINT_flexpr_func_#1\endcsname + \xint_afterfi{% + \expandafter\expandafter\csname XINT_flexpr_func_#1\endcsname + }% + \else \xintError:unknownfunction + \xint_afterfi{\expandafter\XINT_expr_func_unknown}% \fi - #1% + \romannumeral-`0\XINT_flexpr_oparen }% -\def\XINT_flexpr_op_found #1% +\def\XINT_expr_func_unknown #1#2#3% {% - \ifcsname XINT_expr_precedence_\string #1\endcsname - \expandafter\xint_afterfi\expandafter - {\csname XINT_expr_precedence_\string #1\expandafter\endcsname - \csname XINT_flexpr_op_\string #1\endcsname }% - \else - \XINT_expr_unexpectedtoken - \expandafter\XINT_flexpr_getop - \fi + \expandafter #1\expandafter #2\csname .0[0]\endcsname }% -\expandafter\let\csname XINT_flexpr_op_)\endcsname\XINT_flexpr_getop -\def\XINT_flexpr_getnext +\def\XINT_expr_func_reduce #1#2#3% {% - \expandafter\XINT_flexpr_getnext_checkforbraced_a - \romannumeral-`0\romannumeral-`0% + \expandafter #1\expandafter #2\csname + .\xintIrr {\XINT_expr_unlock #3}\endcsname }% -\def\XINT_flexpr_getnext_checkforbraced_a #1% +\let\XINT_flexpr_func_reduce\XINT_expr_func_reduce +\def\XINT_expr_func_sqr #1#2#3% {% - \XINT_flexpr_getnext_checkforbraced_b #1\W\Z {#1}% + \expandafter #1\expandafter #2\csname + .\xintSqr {\XINT_expr_unlock #3}\endcsname }% -\def\XINT_flexpr_getnext_checkforbraced_b #1#2% +\def\XINT_flexpr_func_sqr #1#2#3% {% - \xint_UDwfork - #1\dummy \XINT_flexpr_getnext_emptybracepair - #2\dummy \XINT_flexpr_getnext_onetoken_perhaps - \W\dummy \XINT_flexpr_getnext_gotbracedstuff - \krof + \expandafter #1\expandafter #2\csname + .\XINTinFloatMul {\XINT_expr_unlock #3}{\XINT_expr_unlock #3}\endcsname }% -\def\XINT_flexpr_getnext_onetoken_perhaps\Z #1% +\def\XINT_expr_func_abs #1#2#3% {% - \expandafter\XINT_flexpr_getnext_checkforbraced_c\expandafter - {\romannumeral-`0#1}% + \expandafter #1\expandafter #2\csname + .\xintAbs {\XINT_expr_unlock #3}\endcsname }% -\def\XINT_flexpr_getnext_checkforbraced_c #1% +\let\XINT_flexpr_func_abs\XINT_expr_func_abs +\def\XINT_expr_func_sgn #1#2#3% {% - \XINT_flexpr_getnext_checkforbraced_d #1\W\Z {#1}% + \expandafter #1\expandafter #2\csname + .\xintSgn {\XINT_expr_unlock #3}\endcsname }% -\def\XINT_flexpr_getnext_checkforbraced_d #1#2% +\let\XINT_flexpr_func_sgn\XINT_expr_func_sgn +\def\XINT_expr_func_floor #1#2#3% {% - \xint_UDwfork - #1\dummy \XINT_flexpr_getnext_emptybracepair - #2\dummy \XINT_flexpr_getnext_onetoken_wehope - \W\dummy \XINT_flexpr_getnext_gotbracedstuff - \krof + \expandafter #1\expandafter #2\csname + .\xintFloor {\XINT_expr_unlock #3}\endcsname }% -\def\XINT_flexpr_getnext_emptybracepair #1{\XINT_flexpr_getnext }% -\def\XINT_flexpr_getnext_gotbracedstuff #1\W\Z #2% +\let\XINT_flexpr_func_floor\XINT_expr_func_floor +\def\XINT_expr_func_ceil #1#2#3% {% - \expandafter\XINT_flexpr_getop\csname .#2\endcsname + \expandafter #1\expandafter #2\csname + .\xintCeil {\XINT_expr_unlock #3}\endcsname }% -\def\XINT_flexpr_getnext_onetoken_wehope\Z #1% +\let\XINT_flexpr_func_ceil\XINT_expr_func_ceil +\def\XINT_expr_twoargs #1,#2,{{#1}{#2}}% +\def\XINT_expr_func_quo #1#2#3% {% - \xint_gob_til_! #1\XINT_flexpr_subexpr !% - \expandafter\XINT_flexpr_getnext_onetoken_fork\string #1% + \expandafter #1\expandafter #2\csname .% + \expandafter\expandafter\expandafter\xintQuo + \expandafter\XINT_expr_twoargs + \romannumeral-`0\XINT_expr_unlock #3,\endcsname }% -\def\XINT_flexpr_subexpr !#1!{\expandafter\XINT_flexpr_getop\xint_gobble_i }% -\begingroup -\lccode`*=`_ -\lowercase{\endgroup -\def\XINT_flexpr_getnext_onetoken_fork #1% +\let\XINT_flexpr_func_quo\XINT_expr_func_quo +\def\XINT_expr_func_rem #1#2#3% {% - \XINT_expr_sixwayfork - #1-.+*\dummy \XINT_flexpr_oparen - (#1.+*\dummy -% - (-#1+*\dummy {\XINT_flexpr_scannum_start\XINT_expr_scannum_decpart_b.}% - (-.#1*\dummy \XINT_flexpr_getnext% - (-.+#1\dummy {\XINT_flexpr_scannum_start\XINT_expr_scannum_decpart_b*}% - (-.+*\dummy {\XINT_flexpr_scannum_check #1}% - \krof -}}% -\def\XINT_flexpr_scannum_check #1% + \expandafter #1\expandafter #2\csname .% + \expandafter\expandafter\expandafter\xintRem + \expandafter\XINT_expr_twoargs + \romannumeral-`0\XINT_expr_unlock #3,\endcsname +}% +\let\XINT_flexpr_func_rem\XINT_expr_func_rem +\def\XINT_expr_oneortwo #1#2#3,#4,#5.% {% - \ifnum \xint_c_ix<1#1 - \expandafter\XINT_flexpr_scannum_start - \else - \xint_afterfi - {\XINT_expr_unexpectedtoken - \expandafter\XINT_flexpr_getnext\xint_gobble_ii}% - \fi \XINT_expr_scannum_intpart_b #1% + \if\relax#5\relax\expandafter\xint_firstoftwo\else + \expandafter\xint_secondoftwo\fi + {#1{0}{#3}}{#2{\xintNum {#4}}{#3}}% +}% +\def\XINT_expr_func_round #1#2#3% +{% + \expandafter #1\expandafter #2\csname .% + \expandafter\XINT_expr_oneortwo + \expandafter\xintiRound\expandafter\xintRound + \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname +}% +\let\XINT_flexpr_func_round\XINT_expr_func_round +\def\XINT_expr_func_trunc #1#2#3% +{% + \expandafter #1\expandafter #2\csname .% + \expandafter\XINT_expr_oneortwo + \expandafter\xintiTrunc\expandafter\xintTrunc + \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname +}% +\let\XINT_flexpr_func_trunc\XINT_expr_func_trunc +\def\XINT_expr_argandopt #1,#2,#3.% +{% + \if\relax#3\relax\expandafter\xint_firstoftwo\else + \expandafter\xint_secondoftwo\fi + {[\XINTdigits]{#1}}{[\xintNum {#2}]{#1}}% +}% +\def\XINT_expr_func_float #1#2#3% +{% + \expandafter #1\expandafter #2\csname .% + \expandafter\XINTinFloat + \romannumeral-`0\expandafter\XINT_expr_argandopt + \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname }% -\def\XINT_flexpr_scannum_start #1% +\let\XINT_flexpr_func_float\XINT_expr_func_float +\def\XINT_expr_func_sqrt #1#2#3% {% - \expandafter\XINT_flexpr_getop - \romannumeral-`0\expandafter\XINT_expr_gathernum - \romannumeral-`0#1% + \expandafter #1\expandafter #2\csname .% + \expandafter\XINTinFloatSqrt + \romannumeral-`0\expandafter\XINT_expr_argandopt + \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname +}% +\let\XINT_flexpr_func_sqrt\XINT_expr_func_sqrt +\def\XINT_expr_func_gcd #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintGCDof:csv{\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_flexpr_func_gcd\XINT_expr_func_gcd +\def\XINT_expr_func_lcm #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintLCMof:csv{\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_flexpr_func_lcm\XINT_expr_func_lcm +\def\XINT_expr_func_max #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintMaxof:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_flexpr_func_max #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintFloatMaxof:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_expr_func_min #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintMinof:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_flexpr_func_min #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintFloatMinof:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_expr_func_sum #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintSum:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_flexpr_func_sum #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintFloatSum:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_expr_func_prd #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintPrd:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_flexpr_func_prd #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintFloatPrd:csv{\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_expr_func_add\XINT_expr_func_sum +\let\XINT_expr_func_mul\XINT_expr_func_prd +\let\XINT_flexpr_func_add\XINT_flexpr_func_sum +\let\XINT_flexpr_func_mul\XINT_flexpr_func_prd +\def\XINT_expr_func_? #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintIsNotZero {\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_flexpr_func_? \XINT_expr_func_? +\def\XINT_expr_func_! #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintIsZero {\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_flexpr_func_! \XINT_expr_func_! +\def\XINT_expr_func_not #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintIsZero {\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_flexpr_func_not \XINT_expr_func_not +\def\XINT_expr_func_all #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintANDof:csv{\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_flexpr_func_all\XINT_expr_func_all +\def\XINT_expr_func_any #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintORof:csv{\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_flexpr_func_any\XINT_expr_func_any +\def\XINT_expr_func_xor #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\xintXORof:csv{\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_flexpr_func_xor\XINT_expr_func_xor +\def\xintifNotZero:: #1,#2,#3,{\xintifNotZero{#1}{#2}{#3}}% +\def\XINT_expr_func_if #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\expandafter\xintifNotZero:: + \romannumeral-`0\XINT_expr_unlock #3,\endcsname +}% +\let\XINT_flexpr_func_if\XINT_expr_func_if +\def\xintifSgn:: #1,#2,#3,#4,{\xintifSgn{#1}{#2}{#3}{#4}}% +\def\XINT_expr_func_ifsgn #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .\expandafter\xintifSgn:: + \romannumeral-`0\XINT_expr_unlock #3,\endcsname +}% +\let\XINT_flexpr_func_ifsgn\XINT_expr_func_ifsgn +\def\XINT_newexpr_print #1{\ifnum\xintNthElt{0}{#1}>1 + \expandafter\xint_firstoftwo + \else + \expandafter\xint_secondoftwo + \fi + {_xintListWithSep,{#1}}{\xint_firstofone#1}}% +\def\XINT_expr_tmp #1% + {\expandafter\def\csname xint#1\endcsname {_xint#1}}% +\expandafter\def\expandafter\XINT_expr_protect\expandafter +{% + \romannumeral0% + \xintapplyunbraced\XINT_expr_tmp{\xintCSVtoList{% + Floor,Ceil,iRound,Round,iTrunc,Trunc,% + Lt,Gt,Eq,AND,OR,% + IsNotZero,IsZero,% + ifNotZero,ifSgn,% + Irr,Num,Abs,Sgn,Opp,Quo,Rem,% + Add,Sub,Mul,Sqr,Div,Pow,Fac,fE}}% + \def\xintGCDof:csv ##1{_xintGCDof {\xintCSVtoList {##1}}}% + \def\xintLCMof:csv ##1{_xintLCMof {\xintCSVtoList {##1}}}% + \def\xintMaxof:csv ##1{_xintMaxof {\xintCSVtoList {##1}}}% + \def\xintMinof:csv ##1{_xintMinof {\xintCSVtoList {##1}}}% + \def\xintSum:csv ##1{_xintSum {\xintCSVtoList {##1}}}% + \def\xintPrd:csv ##1{_xintPrd {\xintCSVtoList {##1}}}% + \def\xintANDof:csv ##1{_xintANDof {\xintCSVtoList {##1}}}% + \def\xintORof:csv ##1{_xintORof {\xintCSVtoList {##1}}}% + \def\xintXORof:csv ##1{_xintXORof {\xintCSVtoList {##1}}}% + \def\XINTinFloat {_XINTinFloat}% + \def\XINTinFloatSqrt {_XINTinFloatSqrt}% + \def\XINTdigits {_XINTdigits}% + \def\XINT_expr_print ##1{\expandafter\XINT_newexpr_print\expandafter + {\romannumeral0\xintcsvtolist{\XINT_expr_unlock ##1}}}% }% \catcode`* 13 -\def\xintNewExpr #1[#2]#3% +\def\xintNewExpr #1[#2]% {% - \begingroup + \begingroup \ifcase #2\relax \toks0 {\xdef #1}% \or \toks0 {\xdef #1##1}% @@ -690,37 +894,72 @@ \or \toks0 {\xdef #1##1##2##3##4##5##6##7}% \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8}% \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8##9}% - \else - \immediate\write-1{Package xintexpr Error! illegal number of macro - parameters.}% \fi - \def\xintAdd {:xintAdd}% - \def\xintSub {:xintSub}% - \def\xintMul {:xintMul}% - \def\xintDiv {:xintDiv}% - \def\xintPow {:xintPow}% - \def\xintFac {:xintFac}% - \def\xintOpp {:xintOpp}% - \def\xintfE {:xintfE}% - \def\xintraw { :romannumeral0:xintraw}% - \def\XINT_expr_the ##1##2##3% - {\expandafter\xintraw - \expandafter{\romannumeral-`0\XINT_expr_string ##3}}% - \lccode`\*=`: \lowercase {\def*}{!noexpand!}% - \catcode`: 13 - \endlinechar -1 + \xintexprSafeCatcodes + \XINT_NewExpr +}% +\def\XINT_NewExpr #1% +{% + \def\xintTmp ##1##2##3##4##5##6##7##8##9{#1}% + \XINT_expr_protect + \lccode`\*=`_ \lowercase {\def*}{!noexpand!}% + \catcode`_ 13 \catcode`: 11 \endlinechar -1 \everyeof {\noexpand }% - \edef\xintNewExprtmp + \edef\XINTtmp ##1##2##3##4##5##6##7##8##9% {\scantokens - \expandafter{\romannumeral0\xinttheeval #3\relax}}% - \lccode`\*=`_ \lowercase {\def*}{####}% - \catcode`_ 13 \catcode`! 0 \catcode`: 11 - \the\toks0 {\scantokens\expandafter{\xintNewExprtmp }}% + \expandafter{\romannumeral-`0\xinttheexpr + \xintTmp {####1}{####2}{####3}% + {####4}{####5}{####6}% + {####7}{####8}{####9}% + \relax}}% + \lccode`\*=`\$ \lowercase {\def*}{####}% + \catcode`\$ 13 \catcode`! 0 \catcode`_ 11 % + \the\toks0 + {\scantokens\expandafter{\expandafter + \XINT_newexpr_stripprefix\meaning\XINTtmp}}% \endgroup }% -\def\xintNewFloatExpr #1[#2]#3% +\def\XINT_newflexpr_print #1{\ifnum\xintNthElt{0}{#1}>1 + \expandafter\xint_firstoftwo + \else + \expandafter\xint_secondoftwo + \fi + {_xintListWithSep,{\xintApply{_xintFloat}{#1}}} + {_xintFloat#1}}% +\expandafter\def\expandafter\XINT_flexpr_protect\expandafter {% - \begingroup + \romannumeral0% + \xintapplyunbraced\XINT_expr_tmp{\xintCSVtoList{% + Floor,Ceil,iRound,Round,iTrunc,Trunc,% + Lt,Gt,Eq,AND,OR,% + IsNotZero,IsZero,% + ifNotZero,ifSgn,% + Irr,Num,Abs,Sgn,Opp,Quo,Rem,Fac}}% + \def\xintGCDof:csv ##1{_xintGCDof {\xintCSVtoList {##1}}}% + \def\xintLCMof:csv ##1{_xintLCMof {\xintCSVtoList {##1}}}% + \def\xintFloatMaxof:csv ##1{_xintFloatMaxof {\xintCSVtoList {##1}}}% + \def\xintFloatMinof:csv ##1{_xintFloatMinof {\xintCSVtoList {##1}}}% + \def\xintFloatSum:csv ##1{_xintFloatSum {\xintCSVtoList {##1}}}% + \def\xintFloatPrd:csv ##1{_xintFloatPrd {\xintCSVtoList {##1}}}% + \def\xintANDof:csv ##1{_xintANDof {\xintCSVtoList {##1}}}% + \def\xintORof:csv ##1{_xintORof {\xintCSVtoList {##1}}}% + \def\xintXORof:csv ##1{_xintXORof {\xintCSVtoList {##1}}}% + \def\XINTinFloat {_XINTinFloat}% + \def\XINTinFloatSqrt {_XINTinFloatSqrt}% + \def\XINTinFloatAdd {_XINTinFloatAdd}% + \def\XINTinFloatSub {_XINTinFloatSub}% + \def\XINTinFloatMul {_XINTinFloatMul}% + \def\XINTinFloatDiv {_XINTinFloatDiv}% + \def\XINTinFloatPower {_XINTinFloatPower}% + \def\XINTinFloatfE {_XINTinFloatfE}% + \def\XINTdigits {_XINTdigits}% + \def\XINT_flexpr_print ##1{\expandafter\XINT_newflexpr_print\expandafter + {\romannumeral0\xintcsvtolist{\XINT_expr_unlock ##1}}}% +}% +\let\XINT_expr_tmp\empty +\def\xintNewFloatExpr #1[#2]% +{% + \begingroup \ifcase #2\relax \toks0 {\xdef #1}% \or \toks0 {\xdef #1##1}% @@ -732,34 +971,77 @@ \or \toks0 {\xdef #1##1##2##3##4##5##6##7}% \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8}% \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8##9}% - \else - \immediate\write-1{Package xintexpr Error! illegal number of macro - parameters.}% \fi - \def\XINTinFloatAdd {:XINTinFloatAdd}% - \def\XINTinFloatSub {:XINTinFloatSub}% - \def\XINTinFloatMul {:XINTinFloatMul}% - \def\XINTinFloatDiv {:XINTinFloatDiv}% - \def\XINTinFloatPower {:XINTinFloatPower}% - \def\xintFac {:xintFac}% - \def\xintOpp {:xintOpp}% - \def\XINTinFloatfE {:XINTinFloatfE}% - \def\xintfloat { :romannumeral0:xintfloat}% - \def\XINT_flexpr_the ##1##2##3% - {\expandafter\xintfloat - \expandafter{\romannumeral-`0\XINT_expr_string ##3}}% - \lccode`\*=`: \lowercase {\def*}{!noexpand!}% - \catcode`: 13 - \endlinechar -1 + \xintexprSafeCatcodes + \XINT_NewFloatExpr +}% +\def\XINT_NewFloatExpr #1% +{% + \def\xintTmp ##1##2##3##4##5##6##7##8##9{#1}% + \XINT_flexpr_protect + \lccode`\*=`_ \lowercase {\def*}{!noexpand!}% + \catcode`_ 13 \catcode`: 11 \endlinechar -1 % \everyeof {\noexpand }% - \edef\xintNewExprtmp + \edef\XINTtmp ##1##2##3##4##5##6##7##8##9% {\scantokens - \expandafter{\romannumeral0\xintthefloateval #3\relax}}% - \lccode`\*=`_ \lowercase {\def*}{####}% - \catcode`_ 13 \catcode`! 0 \catcode`: 11 - \the\toks0 {\scantokens\expandafter{\xintNewExprtmp }}% + \expandafter{\romannumeral-`0\xintthefloatexpr + \xintTmp {####1}{####2}{####3}% + {####4}{####5}{####6}% + {####7}{####8}{####9}% + \relax}}% + \lccode`\*=`\$ \lowercase {\def*}{####}% + \catcode`\$ 13 \catcode`! 0 \catcode`_ 11 % + \the\toks0 + {\scantokens\expandafter + {\expandafter\XINT_newexpr_stripprefix\meaning\XINTtmp}}% \endgroup }% +\let\xintexprRestoreCatcodes\relax +\def\xintexprSafeCatcodes +{% for end user. + \edef\xintexprRestoreCatcodes {% + \catcode63=\the\catcode63 % ? + \catcode124=\the\catcode124 % | + \catcode38=\the\catcode38 % & + \catcode33=\the\catcode33 % ! + \catcode93=\the\catcode93 % ] + \catcode91=\the\catcode91 % [ + \catcode94=\the\catcode94 % ^ + \catcode95=\the\catcode95 % _ + \catcode47=\the\catcode47 % / + \catcode41=\the\catcode41 % ) + \catcode40=\the\catcode40 % ( + \catcode42=\the\catcode42 % * + \catcode43=\the\catcode43 % + + \catcode62=\the\catcode62 % > + \catcode60=\the\catcode60 % < + \catcode58=\the\catcode58 % : + \catcode46=\the\catcode46 % . + \catcode45=\the\catcode45 % - + \catcode44=\the\catcode44 % , + \catcode61=\the\catcode61\relax % = + }% this is just for some standard situation with a few made active by Babel + \catcode63=12 % ? + \catcode124=12 % | + \catcode38=4 % & + \catcode33=12 % ! + \catcode93=12 % ] + \catcode91=12 % [ + \catcode94=7 % ^ + \catcode95=8 % _ + \catcode47=12 % / + \catcode41=12 % ) + \catcode40=12 % ( + \catcode42=12 % * + \catcode43=12 % + + \catcode62=12 % > + \catcode60=12 % < + \catcode58=12 % : + \catcode46=12 % . + \catcode45=12 % - + \catcode44=12 % , + \catcode61=12 % = +}% \XINT_expr_restorecatcodes_endinput% \endinput %% diff --git a/Master/texmf-dist/tex/generic/xint/xintfrac.sty b/Master/texmf-dist/tex/generic/xint/xintfrac.sty index 162aa549471..dc3c8ad2f9a 100644 --- a/Master/texmf-dist/tex/generic/xint/xintfrac.sty +++ b/Master/texmf-dist/tex/generic/xint/xintfrac.sty @@ -22,7 +22,7 @@ %% in the same archive or directory.) %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.08b of June 14, 2013) +%% The xint bundle (version 1.09a of September 22, 2013) %% xintfrac: Expandable operations on fractions %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -165,7 +165,7 @@ \fi \expandafter\x\csname ver@xintfrac.sty\endcsname \ProvidesPackage{xintfrac}% - [2013/06/14 v1.08b Expandable operations on fractions (jfB)]% + [2013/09/24 v1.09a Expandable operations on fractions (jfB)]% \chardef\xint_c_vi 6 \chardef\xint_c_vii 7 \chardef\xint_c_xviii 18 @@ -480,6 +480,12 @@ \def\XINT_rawz_Ba #1#2#3{\expandafter\XINT_rawz_Bb \expandafter{\romannumeral0\xint_dsh {#3}{#1}}{#2}}% \def\XINT_rawz_Bb #1#2{ #2/#1}% +\def\xintFloor {\romannumeral0\xintfloor }% +\def\xintfloor #1{\expandafter\XINT_floor + \romannumeral0\xintrawwithzeros {#1}.}% +\def\XINT_floor #1/#2.{\xintiquo {#1}{#2}}% +\def\xintCeil {\romannumeral0\xintceil }% +\def\xintceil #1{\xintiiopp {\xintFloor {\xintOpp{#1}}}}% \def\xintNumerator {\romannumeral0\xintnumerator }% \def\xintnumerator {% @@ -781,8 +787,8 @@ \def\XINT_jrr_loop_b #1#2#3#4#5#6#7% {% \expandafter \XINT_jrr_loop_c \expandafter - {\romannumeral0\xintiadd{\XINT_Mul{#4}{#1}}{#6}}% - {\romannumeral0\xintiadd{\XINT_Mul{#5}{#1}}{#7}}% + {\romannumeral0\xintiiadd{\XINT_Mul{#4}{#1}}{#6}}% + {\romannumeral0\xintiiadd{\XINT_Mul{#5}{#1}}{#7}}% {#2}{#3}{#4}{#5}% }% \def\XINT_jrr_loop_c #1#2% @@ -965,10 +971,20 @@ {% \XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z \Z }% -\mathchardef\XINT_digits 16 +\def\xintRound:csv #1{\expandafter\XINT_round:_a\romannumeral-`0#1,,^}% +\def\XINT_round:_a {\XINT_round:_b {}}% +\def\XINT_round:_b #1#2,% + {\expandafter\XINT_round:_c\romannumeral-`0#2,{#1}}% +\def\XINT_round:_c #1{\if #1,\expandafter\XINT_round:_f + \else\expandafter\XINT_round:_d\fi #1}% +\def\XINT_round:_d #1,% + {\expandafter\XINT_round:_e\romannumeral0\xintiround 0{#1},}% +\def\XINT_round:_e #1,#2{\XINT_round:_b {#2,#1}}% +\def\XINT_round:_f ,#1#2^{\xint_gobble_i #1}% +\mathchardef\XINTdigits 16 \def\xintDigits #1#2% - {\afterassignment \xint_gobble_i \mathchardef\XINT_digits=}% -\def\xinttheDigits {\number\XINT_digits }% + {\afterassignment \xint_gobble_i \mathchardef\XINTdigits=}% +\def\xinttheDigits {\number\XINTdigits }% \def\xintFloat {\romannumeral0\xintfloat }% \def\xintfloat #1{\XINT_float_chkopt #1\Z }% \def\XINT_float_chkopt #1% @@ -979,7 +995,7 @@ }% \def\XINT_float_noopt #1\Z {% - \expandafter\XINT_float_a\expandafter\XINT_digits + \expandafter\XINT_float_a\expandafter\XINTdigits \romannumeral0\XINT_infrac {#1}\XINT_float_Q }% \def\XINT_float_opt [\Z #1]#2% @@ -1019,7 +1035,8 @@ \def\XINT_float_Ma #1#2#3% {% \expandafter\XINT_float_Mb\expandafter - {\the\numexpr #1-#2\expandafter}\expandafter + {\the\numexpr #1-#2\expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter {\expandafter\xint_firstoftwo \romannumeral0\XINT_split_fromleft_loop {#2}{}#3\W\W\W\W\W\W\W\W\Z }{#2}% @@ -1050,7 +1067,8 @@ \expandafter\XINT_float_P\expandafter {\the\numexpr #2\expandafter}\expandafter {\the\numexpr #2\expandafter}\expandafter - {\the\numexpr #3-#1+#2\expandafter}\expandafter + {\the\numexpr #3-#1+#2\expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter {\expandafter\xint_firstoftwo \romannumeral0\XINT_split_fromleft_loop {#2}{}#4\W\W\W\W\W\W\W\W\Z }% @@ -1072,13 +1090,13 @@ {% \expandafter\XINT_float_Sa \romannumeral0\xintiquo {#2}% - {\romannumeral-`0\XINT_dsx_addzerosnofuss {-#1}{#3}}\Z {#1}% + {\XINT_dsx_addzerosnofuss {-#1}{#3}}\Z {#1}% }% \def\XINT_float_Rii #1#2#3% {% \expandafter\XINT_float_Sa \romannumeral0\xintiquo - {\romannumeral-`0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}\Z {#1}% + {\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}\Z {#1}% }% \def\XINT_float_Sa #1% {% @@ -1140,6 +1158,17 @@ {\the\numexpr #3+#4+\xint_c_i-#2}{#1}% }% \def\XINT_float_Y #1#2{ #2e#1}% +\def\xintFloat:csv #1{\expandafter\XINT_float:_a\romannumeral-`0#1,,^}% +\def\XINT_float:_a {\XINT_float:_b {}}% +\def\XINT_float:_b #1#2,% + {\expandafter\XINT_float:_c\romannumeral-`0#2,{#1}}% +\def\XINT_float:_c #1{\if #1,\expandafter\XINT_float:_f + \else\expandafter\XINT_float:_d\fi #1}% +\def\XINT_float:_d #1,% + {\expandafter\XINT_float:_e\romannumeral0\xintfloat {#1},}% +\def\XINT_float:_e #1,#2{\XINT_float:_b {#2,#1}}% +\def\XINT_float:_f ,#1#2^{\xint_gobble_i #1}% +\def\XINTinFloat {\romannumeral0\XINT_inFloat }% \def\XINT_inFloat [#1]#2% {% \expandafter\XINT_infloat_a\expandafter @@ -1158,8 +1187,8 @@ 0-\dummy {\XINT_float_K #1}% \krof }% -\def\XINT_infloat_zero #1\Z #2#3#4#5{0[0]}% -\def\XINT_infloat_J {\expandafter-\romannumeral-`0\XINT_float_K }% +\def\XINT_infloat_zero #1\Z #2#3#4#5{ 0[0]}% +\def\XINT_infloat_J {\expandafter-\romannumeral0\XINT_float_K }% \def\XINT_infloat_Q #1% {% \ifnum #1<\xint_c_ @@ -1172,13 +1201,13 @@ {% \expandafter\XINT_infloat_S\expandafter {\romannumeral0\xintiquo {#2}% - {\romannumeral-`0\XINT_dsx_addzerosnofuss {-#1}{#3}}}{#1}% + {\XINT_dsx_addzerosnofuss {-#1}{#3}}}{#1}% }% \def\XINT_infloat_Rii #1#2#3% {% \expandafter\XINT_infloat_S\expandafter {\romannumeral0\xintiquo - {\romannumeral-`0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}}{#1}% + {\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}}{#1}% }% \def\XINT_infloat_S #1#2#3% {% @@ -1246,10 +1275,10 @@ \def\XINT_fadd_B #1#2#3#4#5#6#7% {% \expandafter\XINT_fadd_C\expandafter - {\romannumeral0\xintimul {#7}{#5}}% - {\romannumeral0\xintiadd - {\romannumeral0\xintimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% - {\romannumeral0\xintimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% + {\romannumeral0\xintiimul {#7}{#5}}% + {\romannumeral0\xintiiadd + {\romannumeral0\xintiimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% + {\romannumeral0\xintiimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% }% {#1}% }% @@ -1277,10 +1306,10 @@ \def\XINT_fsub_B #1#2#3#4#5#6#7% {% \expandafter\XINT_fsub_C\expandafter - {\romannumeral0\xintimul {#7}{#5}}% - {\romannumeral0\xintisub - {\romannumeral0\xintimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% - {\romannumeral0\xintimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% + {\romannumeral0\xintiimul {#7}{#5}}% + {\romannumeral0\xintiisub + {\romannumeral0\xintiimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% + {\romannumeral0\xintiimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% }% {#1}% }% @@ -1308,6 +1337,14 @@ \expandafter\XINT_fsum_loop_a\expandafter{\romannumeral0\xintadd {#2}{#1}}% }% \def\XINT_fsum_finished #1\Z #2{ #2}% +\def\xintSum:csv #1{\expandafter\XINT_sum:_a\romannumeral-`0#1,,^}% +\def\XINT_sum:_a {\XINT_sum:_b {0/1[0]}}% +\def\XINT_sum:_b #1#2,{\expandafter\XINT_sum:_c\romannumeral-`0#2,{#1}}% +\def\XINT_sum:_c #1{\if #1,\expandafter\XINT_sum:_e + \else\expandafter\XINT_sum:_d\fi #1}% +\def\XINT_sum:_d #1,#2{\expandafter\XINT_sum:_b\expandafter + {\romannumeral0\xintadd {#2}{#1}}}% +\def\XINT_sum:_e ,#1#2^{#1}% allows empty list \def\xintMul {\romannumeral0\xintmul }% \def\xintmul #1% {% @@ -1319,8 +1356,8 @@ {% \expandafter\XINT_fmul_B \expandafter{\the\numexpr #1+#4\expandafter}% - \expandafter{\romannumeral0\xintimul {#6}{#3}}% - {\romannumeral0\xintimul {#5}{#2}}% + \expandafter{\romannumeral0\xintiimul {#6}{#3}}% + {\romannumeral0\xintiimul {#5}{#2}}% }% \def\XINT_fmul_B #1#2#3% {% @@ -1398,6 +1435,14 @@ \expandafter\XINT_fprod_loop_a\expandafter{\romannumeral0\xintmul {#1}{#2}}% }% \def\XINT_fprod_finished #1\Z #2{ #2}% +\def\xintPrd:csv #1{\expandafter\XINT_prd:_a\romannumeral-`0#1,,^}% +\def\XINT_prd:_a {\XINT_prd:_b {1/1[0]}}% +\def\XINT_prd:_b #1#2,{\expandafter\XINT_prd:_c\romannumeral-`0#2,{#1}}% +\def\XINT_prd:_c #1{\if #1,\expandafter\XINT_prd:_e + \else\expandafter\XINT_prd:_d\fi #1}% +\def\XINT_prd:_d #1,#2{\expandafter\XINT_prd:_b\expandafter + {\romannumeral0\xintmul {#2}{#1}}}% +\def\XINT_prd:_e ,#1#2^{#1}% allows empty list \def\xintDiv {\romannumeral0\xintdiv }% \def\xintdiv #1% {% @@ -1409,8 +1454,8 @@ {% \expandafter\XINT_fdiv_B \expandafter{\the\numexpr #4-#1\expandafter}% - \expandafter{\romannumeral0\xintimul {#2}{#6}}% - {\romannumeral0\xintimul {#3}{#5}}% + \expandafter{\romannumeral0\xintiimul {#2}{#6}}% + {\romannumeral0\xintiimul {#3}{#5}}% }% \def\XINT_fdiv_B #1#2#3% {% @@ -1418,6 +1463,10 @@ \expandafter{#3}{#1}{#2}% }% \def\XINT_fdiv_C #1#2{\XINT_outfrac {#2}{#1}}% +\def\xintIsOne {\romannumeral0\xintisone }% +\def\xintisone #1{\expandafter\XINT_fracisone + \romannumeral0\xintrawwithzeros{#1}\Z }% +\def\XINT_fracisone #1/#2\Z{\xintsgnfork{\XINT_Cmp {#1}{#2}}{0}{1}{0}}% \def\xintGeq {\romannumeral0\xintgeq }% \def\xintgeq #1% {% @@ -1438,8 +1487,8 @@ \xint_gob_til_zero #4\XINT_fgeq_Zi 0% \expandafter\XINT_fgeq_C\expandafter {\the\numexpr #7-#3\expandafter}\expandafter - {\romannumeral0\xintimul {#4#5}{#2}}% - {\romannumeral0\xintimul {#6}{#1}}% + {\romannumeral0\xintiimul {#4#5}{#2}}% + {\romannumeral0\xintiimul {#6}{#1}}% }% \def\XINT_fgeq_Zi 0#1#2#3#4#5#6#7{ 0}% \def\XINT_fgeq_C #1#2#3% @@ -1505,6 +1554,45 @@ \or \xint_afterfi{ #2}% \fi }% +\def\xintMaxof {\romannumeral0\xintmaxof }% +\def\xintmaxof #1{\expandafter\XINT_maxof_a\romannumeral-`0#1\relax }% +\def\XINT_maxof_a #1{\expandafter\XINT_maxof_b\romannumeral0\xintraw{#1}\Z }% +\def\XINT_maxof_b #1\Z #2% + {\expandafter\XINT_maxof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_maxof_c #1% + {\xint_gob_til_relax #1\XINT_maxof_e\relax\XINT_maxof_d #1}% +\def\XINT_maxof_d #1\Z + {\expandafter\XINT_maxof_b\romannumeral0\xintmax {#1}}% +\def\XINT_maxof_e #1\Z #2\Z { #2}% +\def\xintMaxof:csv #1{\expandafter\XINT_maxof:_b\romannumeral-`0#1,,}% +\def\XINT_maxof:_b #1,#2,{\expandafter\XINT_maxof:_c\romannumeral-`0#2,{#1},}% +\def\XINT_maxof:_c #1{\if #1,\expandafter\XINT_maxof:_e + \else\expandafter\XINT_maxof:_d\fi #1}% +\def\XINT_maxof:_d #1,{\expandafter\XINT_maxof:_b\romannumeral0\xintmax {#1}}% +\def\XINT_maxof:_e ,#1,{#1}% +\def\xintFloatMaxof {\romannumeral0\xintflmaxof }% +\def\xintflmaxof #1{\expandafter\XINT_flmaxof_a\romannumeral-`0#1\relax }% +\def\XINT_flmaxof_a #1{\expandafter\XINT_flmaxof_b + \romannumeral0\XINT_inFloat [\XINTdigits]{#1}\Z }% +\def\XINT_flmaxof_b #1\Z #2% + {\expandafter\XINT_flmaxof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_flmaxof_c #1% + {\xint_gob_til_relax #1\XINT_flmaxof_e\relax\XINT_flmaxof_d #1}% +\def\XINT_flmaxof_d #1\Z + {\expandafter\XINT_flmaxof_b\romannumeral0\xintmax + {\XINTinFloat [\XINTdigits]{#1}}}% +\def\XINT_flmaxof_e #1\Z #2\Z { #2}% +\def\xintFloatMaxof:csv #1{\expandafter\XINT_flmaxof:_a\romannumeral-`0#1,,}% +\def\XINT_flmaxof:_a #1,{\expandafter\XINT_flmaxof:_b + \romannumeral0\XINT_inFloat [\XINTdigits]{#1},}% +\def\XINT_flmaxof:_b #1,#2,% + {\expandafter\XINT_flmaxof:_c\romannumeral-`0#2,{#1},}% +\def\XINT_flmaxof:_c #1{\if #1,\expandafter\XINT_flmaxof:_e + \else\expandafter\XINT_flmaxof:_d\fi #1}% +\def\XINT_flmaxof:_d #1,% + {\expandafter\XINT_flmaxof:_b\romannumeral0\xintmax + {\XINTinFloat [\XINTdigits]{#1}}}% +\def\XINT_flmaxof:_e ,#1,{#1}% \def\xintMin {\romannumeral0\xintmin }% \def\xintmin #1% {% @@ -1539,6 +1627,45 @@ \or \xint_afterfi{ #1}% \fi }% +\def\xintMinof {\romannumeral0\xintminof }% +\def\xintminof #1{\expandafter\XINT_minof_a\romannumeral-`0#1\relax }% +\def\XINT_minof_a #1{\expandafter\XINT_minof_b\romannumeral0\xintraw{#1}\Z }% +\def\XINT_minof_b #1\Z #2% + {\expandafter\XINT_minof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_minof_c #1% + {\xint_gob_til_relax #1\XINT_minof_e\relax\XINT_minof_d #1}% +\def\XINT_minof_d #1\Z + {\expandafter\XINT_minof_b\romannumeral0\xintmin {#1}}% +\def\XINT_minof_e #1\Z #2\Z { #2}% +\def\xintMinof:csv #1{\expandafter\XINT_minof:_b\romannumeral-`0#1,,}% +\def\XINT_minof:_b #1,#2,{\expandafter\XINT_minof:_c\romannumeral-`0#2,{#1},}% +\def\XINT_minof:_c #1{\if #1,\expandafter\XINT_minof:_e + \else\expandafter\XINT_minof:_d\fi #1}% +\def\XINT_minof:_d #1,{\expandafter\XINT_minof:_b\romannumeral0\xintmin {#1}}% +\def\XINT_minof:_e ,#1,{#1}% +\def\xintFloatMinof {\romannumeral0\xintflminof }% +\def\xintflminof #1{\expandafter\XINT_flminof_a\romannumeral-`0#1\relax }% +\def\XINT_flminof_a #1{\expandafter\XINT_flminof_b + \romannumeral0\XINT_inFloat [\XINTdigits]{#1}\Z }% +\def\XINT_flminof_b #1\Z #2% + {\expandafter\XINT_flminof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_flminof_c #1% + {\xint_gob_til_relax #1\XINT_flminof_e\relax\XINT_flminof_d #1}% +\def\XINT_flminof_d #1\Z + {\expandafter\XINT_flminof_b\romannumeral0\xintmin + {\XINTinFloat [\XINTdigits]{#1}}}% +\def\XINT_flminof_e #1\Z #2\Z { #2}% +\def\xintFloatMinof:csv #1{\expandafter\XINT_flminof:_a\romannumeral-`0#1,,}% +\def\XINT_flminof:_a #1,{\expandafter\XINT_flminof:_b + \romannumeral0\XINT_inFloat [\XINTdigits]{#1},}% +\def\XINT_flminof:_b #1,#2,% + {\expandafter\XINT_flminof:_c\romannumeral-`0#2,{#1},}% +\def\XINT_flminof:_c #1{\if #1,\expandafter\XINT_flminof:_e + \else\expandafter\XINT_flminof:_d\fi #1}% +\def\XINT_flminof:_d #1,% + {\expandafter\XINT_flminof:_b\romannumeral0\xintmin + {\XINTinFloat [\XINTdigits]{#1}}}% +\def\XINT_flminof:_e ,#1,{#1}% \def\xintCmp {\romannumeral0\xintcmp }% \def\xintcmp #1% {% @@ -1571,9 +1698,9 @@ \krof #1#2% }% -\def\XINT_fcmp_zerozero #1[#2]#3[#4]{ 0}% -\def\XINT_fcmp_firstzero #1[#2]#3[#4]{ -1}% -\def\XINT_fcmp_secondzero #1[#2]#3[#4]{ 1}% +\def\XINT_fcmp_zerozero #1#2#3#4{ 0}% 1.08b had some [ and ] here!!! +\def\XINT_fcmp_firstzero #1#2#3#4{ -1}% incredibly I never saw that until +\def\XINT_fcmp_secondzero #1#2#3#4{ 1}% preparing 1.09a. \def\XINT_fcmp_pos #1#2#3#4% {% \XINT_fcmp_B #1#3#2#4% @@ -1582,8 +1709,8 @@ {% \expandafter\XINT_fcmp_C\expandafter {\the\numexpr #6-#3\expandafter}\expandafter - {\romannumeral0\xintimul {#4}{#2}}% - {\romannumeral0\xintimul {#5}{#1}}% + {\romannumeral0\xintiimul {#4}{#2}}% + {\romannumeral0\xintiimul {#5}{#1}}% }% \def\XINT_fcmp_C #1#2#3% {% @@ -1696,7 +1823,7 @@ }% \def\xintFloatAdd {\romannumeral0\xintfloatadd }% \def\xintfloatadd #1{\XINT_fladd_chkopt \xintfloat #1\Z }% -\def\XINTinFloatAdd {\romannumeral-`0\XINTinfloatadd }% +\def\XINTinFloatAdd {\romannumeral0\XINTinfloatadd }% \def\XINTinfloatadd #1{\XINT_fladd_chkopt \XINT_inFloat #1\Z }% \def\XINT_fladd_chkopt #1#2% {% @@ -1706,7 +1833,7 @@ }% \def\XINT_fladd_noopt #1#2\Z #3% {% - #1[\XINT_digits]{\XINT_FL_Add {\XINT_digits+2}{#2}{#3}}% + #1[\XINTdigits]{\XINT_FL_Add {\XINTdigits+2}{#2}{#3}}% }% \def\XINT_fladd_opt #1[\Z #2]#3#4% {% @@ -1715,11 +1842,11 @@ \def\XINT_FL_Add #1#2% {% \expandafter\XINT_FL_Add_a\expandafter{\the\numexpr #1\expandafter}% - \expandafter{\romannumeral-`0\XINT_inFloat [#1]{#2}}% + \expandafter{\romannumeral0\XINT_inFloat [#1]{#2}}% }% \def\XINT_FL_Add_a #1#2#3% {% - \expandafter\XINT_FL_Add_b\romannumeral-`0\XINT_inFloat [#1]{#3}#2{#1}% + \expandafter\XINT_FL_Add_b\romannumeral0\XINT_inFloat [#1]{#3}#2{#1}% }% \def\XINT_FL_Add_b #1% {% @@ -1743,7 +1870,7 @@ \def\XINT_FL_Add_zerobis 0\XINT_FL_Add_d #1[#2]0[0]#3{#1[#2]}% \def\xintFloatSub {\romannumeral0\xintfloatsub }% \def\xintfloatsub #1{\XINT_flsub_chkopt \xintfloat #1\Z }% -\def\XINTinFloatSub {\romannumeral-`0\XINTinfloatsub }% +\def\XINTinFloatSub {\romannumeral0\XINTinfloatsub }% \def\XINTinfloatsub #1{\XINT_flsub_chkopt \XINT_inFloat #1\Z }% \def\XINT_flsub_chkopt #1#2% {% @@ -1753,7 +1880,7 @@ }% \def\XINT_flsub_noopt #1#2\Z #3% {% - #1[\XINT_digits]{\XINT_FL_Add {\XINT_digits+2}{#2}{\xintOpp{#3}}}% + #1[\XINTdigits]{\XINT_FL_Add {\XINTdigits+2}{#2}{\xintOpp{#3}}}% }% \def\XINT_flsub_opt #1[\Z #2]#3#4% {% @@ -1761,7 +1888,7 @@ }% \def\xintFloatMul {\romannumeral0\xintfloatmul}% \def\xintfloatmul #1{\XINT_flmul_chkopt \xintfloat #1\Z }% -\def\XINTinFloatMul {\romannumeral-`0\XINTinfloatmul }% +\def\XINTinFloatMul {\romannumeral0\XINTinfloatmul }% \def\XINTinfloatmul #1{\XINT_flmul_chkopt \XINT_inFloat #1\Z }% \def\XINT_flmul_chkopt #1#2% {% @@ -1771,7 +1898,7 @@ }% \def\XINT_flmul_noopt #1#2\Z #3% {% - #1[\XINT_digits]{\XINT_FL_Mul {\XINT_digits+2}{#2}{#3}}% + #1[\XINTdigits]{\XINT_FL_Mul {\XINTdigits+2}{#2}{#3}}% }% \def\XINT_flmul_opt #1[\Z #2]#3#4% {% @@ -1780,16 +1907,16 @@ \def\XINT_FL_Mul #1#2% {% \expandafter\XINT_FL_Mul_a\expandafter{\the\numexpr #1\expandafter}% - \expandafter{\romannumeral-`0\XINT_inFloat [#1]{#2}}% + \expandafter{\romannumeral0\XINT_inFloat [#1]{#2}}% }% \def\XINT_FL_Mul_a #1#2#3% {% - \expandafter\XINT_FL_Mul_b\romannumeral-`0\XINT_inFloat [#1]{#3}#2% + \expandafter\XINT_FL_Mul_b\romannumeral0\XINT_inFloat [#1]{#3}#2% }% -\def\XINT_FL_Mul_b #1[#2]#3[#4]{\xintE{\xintiMul {#1}{#3}}{#2+#4}}% +\def\XINT_FL_Mul_b #1[#2]#3[#4]{\xintE{\xintiiMul {#1}{#3}}{#2+#4}}% \def\xintFloatDiv {\romannumeral0\xintfloatdiv}% \def\xintfloatdiv #1{\XINT_fldiv_chkopt \xintfloat #1\Z }% -\def\XINTinFloatDiv {\romannumeral-`0\XINTinfloatdiv }% +\def\XINTinFloatDiv {\romannumeral0\XINTinfloatdiv }% \def\XINTinfloatdiv #1{\XINT_fldiv_chkopt \XINT_inFloat #1\Z }% \def\XINT_fldiv_chkopt #1#2% {% @@ -1799,7 +1926,7 @@ }% \def\XINT_fldiv_noopt #1#2\Z #3% {% - #1[\XINT_digits]{\XINT_FL_Div {\XINT_digits+2}{#2}{#3}}% + #1[\XINTdigits]{\XINT_FL_Div {\XINTdigits+2}{#2}{#3}}% }% \def\XINT_fldiv_opt #1[\Z #2]#3#4% {% @@ -1808,16 +1935,56 @@ \def\XINT_FL_Div #1#2% {% \expandafter\XINT_FL_Div_a\expandafter{\the\numexpr #1\expandafter}% - \expandafter{\romannumeral-`0\XINT_inFloat [#1]{#2}}% + \expandafter{\romannumeral0\XINT_inFloat [#1]{#2}}% }% \def\XINT_FL_Div_a #1#2#3% {% - \expandafter\XINT_FL_Div_b\romannumeral-`0\XINT_inFloat [#1]{#3}#2% + \expandafter\XINT_FL_Div_b\romannumeral0\XINT_inFloat [#1]{#3}#2% }% \def\XINT_FL_Div_b #1[#2]#3[#4]{\xintE{#3/#1}{#4-#2}}% +\def\xintFloatSum {\romannumeral0\xintfloatsum }% +\def\xintfloatsum #1{\expandafter\XINT_floatsum_a\romannumeral-`0#1\relax }% +\def\XINT_floatsum_a #1{\expandafter\XINT_floatsum_b + \romannumeral0\xintraw{#1}\Z }% normalizes if only 1 +\def\XINT_floatsum_b #1\Z #2% but a bit wasteful + {\expandafter\XINT_floatsum_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_floatsum_c #1% + {\xint_gob_til_relax #1\XINT_floatsum_e\relax\XINT_floatsum_d #1}% +\def\XINT_floatsum_d #1\Z + {\expandafter\XINT_floatsum_b\romannumeral0\XINTinfloatadd {#1}}% +\def\XINT_floatsum_e #1\Z #2\Z { #2}% +\def\xintFloatSum:csv #1{\expandafter\XINT_floatsum:_a\romannumeral-`0#1,,^}% +\def\XINT_floatsum:_a {\XINT_floatsum:_b {0/1[0]}}% +\def\XINT_floatsum:_b #1#2,% + {\expandafter\XINT_floatsum:_c\romannumeral-`0#2,{#1}}% +\def\XINT_floatsum:_c #1{\if #1,\expandafter\XINT_floatsum:_e + \else\expandafter\XINT_floatsum:_d\fi #1}% +\def\XINT_floatsum:_d #1,#2{\expandafter\XINT_floatsum:_b\expandafter + {\romannumeral0\XINTinfloatadd {#2}{#1}}}% +\def\XINT_floatsum:_e ,#1#2^{#1}% allows empty list +\def\xintFloatPrd {\romannumeral0\xintfloatprd }% +\def\xintfloatprd #1{\expandafter\XINT_floatprd_a\romannumeral-`0#1\relax }% +\def\XINT_floatprd_a #1{\expandafter\XINT_floatprd_b + \romannumeral0\xintraw{#1}\Z }% +\def\XINT_floatprd_b #1\Z #2% + {\expandafter\XINT_floatprd_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_floatprd_c #1% + {\xint_gob_til_relax #1\XINT_floatprd_e\relax\XINT_floatprd_d #1}% +\def\XINT_floatprd_d #1\Z + {\expandafter\XINT_floatprd_b\romannumeral0\XINTinfloatmul {#1}}% +\def\XINT_floatprd_e #1\Z #2\Z { #2}% +\def\xintFloatPrd:csv #1{\expandafter\XINT_floatprd:_a\romannumeral-`0#1,,^}% +\def\XINT_floatprd:_a {\XINT_floatprd:_b {1/1[0]}}% +\def\XINT_floatprd:_b #1#2,% + {\expandafter\XINT_floatprd:_c\romannumeral-`0#2,{#1}}% +\def\XINT_floatprd:_c #1{\if #1,\expandafter\XINT_floatprd:_e + \else\expandafter\XINT_floatprd:_d\fi #1}% +\def\XINT_floatprd:_d #1,#2{\expandafter\XINT_floatprd:_b\expandafter + {\romannumeral0\XINTinfloatmul {#2}{#1}}}% +\def\XINT_floatprd:_e ,#1#2^{#1}% allows empty list \def\xintFloatPow {\romannumeral0\xintfloatpow}% \def\xintfloatpow #1{\XINT_flpow_chkopt \xintfloat #1\Z }% -\def\XINTinFloatPow {\romannumeral-`0\XINTinfloatpow }% +\def\XINTinFloatPow {\romannumeral0\XINTinfloatpow }% \def\XINTinfloatpow #1{\XINT_flpow_chkopt \XINT_inFloat #1\Z }% \def\XINT_flpow_chkopt #1#2% {% @@ -1830,7 +1997,7 @@ {% \expandafter\XINT_flpow_checkB_start\expandafter {\the\numexpr #3\expandafter}\expandafter - {\the\numexpr \XINT_digits}{#2}{#1[\XINT_digits]}% + {\the\numexpr \XINTdigits}{#2}{#1[\XINTdigits]}% }% \def\XINT_flpow_opt #1[\Z #2]#3#4% {% @@ -1862,7 +2029,7 @@ \def\XINT_flpow_checkB_d #1#2#3#4% {% \expandafter \XINT_flpow_a - \romannumeral-`0\XINT_inFloat [#1]{#4}{#1}{#2}#3% + \romannumeral0\XINT_inFloat [#1]{#4}{#1}{#2}#3% }% \def\XINT_flpow_a #1% {% @@ -1897,7 +2064,7 @@ \xint_afterfi{\expandafter\XINT_flpow_loop_a \expandafter{\the\numexpr 2*(#2/2)-#2\expandafter }% b mod 2 \expandafter{\the\numexpr #2-#2/2\expandafter }% [b/2] - \expandafter{\romannumeral-`0\XINTinfloatmul [#1]{#3}{#3}}}% + \expandafter{\romannumeral0\XINTinfloatmul [#1]{#3}{#3}}}% \fi {#1}{{#3}}% }% @@ -1931,7 +2098,7 @@ \def\XINT_flpow_prd_compute #1\Z #2#3% {% \expandafter\XINT_flpow_prd_getnext\expandafter - {\romannumeral-`0\XINTinfloatmul [#3]{#1}{#2}}{#3}% + {\romannumeral0\XINTinfloatmul [#3]{#1}{#2}}{#3}% }% \def\XINT_flpow_prd_end\relax\XINT_flpow_prd_compute \relax\Z #1#2#3% @@ -1956,7 +2123,7 @@ }% \def\xintFloatPower {\romannumeral0\xintfloatpower}% \def\xintfloatpower #1{\XINT_flpower_chkopt \xintfloat #1\Z }% -\def\XINTinFloatPower {\romannumeral-`0\XINTinfloatpower}% +\def\XINTinFloatPower {\romannumeral0\XINTinfloatpower}% \def\XINTinfloatpower #1{\XINT_flpower_chkopt \XINT_inFloat #1\Z }% \def\XINT_flpower_chkopt #1#2% {% @@ -1968,8 +2135,8 @@ \def\XINT_flpower_noopt #1#2\Z #3% {% \expandafter\XINT_flpower_checkB_start\expandafter - {\the\numexpr \XINT_digits\expandafter}\expandafter - {\romannumeral0\xintnum{#3}}{#2}{#1[\XINT_digits]}% + {\the\numexpr \XINTdigits\expandafter}\expandafter + {\romannumeral0\xintnum{#3}}{#2}{#1[\XINTdigits]}% }% \def\XINT_flpower_opt #1[\Z #2]#3#4% {% @@ -2001,7 +2168,7 @@ \def\XINT_flpower_checkB_d #1#2#3#4% {% \expandafter \XINT_flpower_a - \romannumeral-`0\XINT_inFloat [#1]{#4}{#1}{#2}#3% + \romannumeral0\XINT_inFloat [#1]{#4}{#1}{#2}#3% }% \def\XINT_flpower_a #1% {% @@ -2033,7 +2200,7 @@ {% \ifcase\XINT_isOne {#2} \xint_afterfi{\expandafter\XINT_flpower_loop_x\expandafter - {\romannumeral-`0\XINTinfloatmul [#1]{#3}{#3}}% + {\romannumeral0\XINTinfloatmul [#1]{#3}{#3}}% {\romannumeral0\xintdivision {#2}{2}}}% \or \expandafter\XINT_flpow_loop_end \fi @@ -2055,7 +2222,7 @@ }% \def\xintFloatSqrt {\romannumeral0\xintfloatsqrt }% \def\xintfloatsqrt #1{\XINT_flsqrt_chkopt \xintfloat #1\Z }% -\def\XINTinFloatSqrt {\romannumeral-`0\XINTinfloatsqrt }% +\def\XINTinFloatSqrt {\romannumeral0\XINTinfloatsqrt }% \def\XINTinfloatsqrt #1{\XINT_flsqrt_chkopt \XINT_inFloat #1\Z }% \def\XINT_flsqrt_chkopt #1#2% {% @@ -2065,7 +2232,7 @@ }% \def\XINT_flsqrt_noopt #1#2\Z {% - #1[\XINT_digits]{\XINT_FL_sqrt \XINT_digits {#2}}% + #1[\XINTdigits]{\XINT_FL_sqrt \XINTdigits {#2}}% }% \def\XINT_flsqrt_opt #1[\Z #2]#3% {% @@ -2082,7 +2249,7 @@ \def\XINT_FL_sqrt_a #1#2% {% \expandafter\XINT_FL_sqrt_checkifzeroorneg - \romannumeral-`0\XINT_inFloat [#1]{#2}% + \romannumeral0\XINT_inFloat [#1]{#2}% }% \def\XINT_FL_sqrt_checkifzeroorneg #1% {% @@ -2182,14 +2349,14 @@ \def\XINT_flsqrt_big_f #1% {% \expandafter\XINT_flsqrt_big_fa\expandafter - {\romannumeral0\xintisqr {#1}}{#1}% + {\romannumeral0\xintiisqr {#1}}{#1}% }% \def\XINT_flsqrt_big_fa #1#2#3#4% {% \expandafter\XINT_flsqrt_big_fb\expandafter - {\romannumeral-`0\XINT_dsx_addzerosnofuss + {\romannumeral0\XINT_dsx_addzerosnofuss {\numexpr #3-\xint_c_viii\relax}{#2}}% - {\romannumeral0\xintisub + {\romannumeral0\xintiisub {\XINT_dsx_addzerosnofuss {\numexpr \xint_c_ii*(#3-\xint_c_viii)\relax}{#1}}{#4}}% {#3}% @@ -2215,7 +2382,7 @@ {% \expandafter\XINT_flsqrt_big_l\expandafter {\romannumeral0\XINT_sub_pre {#3}{#1}}% - {\romannumeral0\xintiadd {#2}{\romannumeral0\XINT_sqr {#1}}}% + {\romannumeral0\xintiiadd {#2}{\romannumeral0\XINT_sqr {#1}}}% }% \def\XINT_flsqrt_big_l #1#2% {% @@ -2226,7 +2393,7 @@ {% \expandafter\XINT_flsqrt_big_end_b\expandafter {\the\numexpr -#4+#5/\xint_c_ii\expandafter}\expandafter - {\romannumeral0\xintisub + {\romannumeral0\xintiisub {\XINT_dsx_addzerosnofuss {#4}{#3}}% {\xintHalf{\xintiQuo{\XINT_dsx_addzerosnofuss {#4}{#2}}{#3}}}}% }% diff --git a/Master/texmf-dist/tex/generic/xint/xintgcd.sty b/Master/texmf-dist/tex/generic/xint/xintgcd.sty index 467e62a9925..c7ff8245b84 100644 --- a/Master/texmf-dist/tex/generic/xint/xintgcd.sty +++ b/Master/texmf-dist/tex/generic/xint/xintgcd.sty @@ -22,7 +22,7 @@ %% in the same archive or directory.) %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.08b of June 14, 2013) +%% The xint bundle (version 1.09a of September 22, 2013) %% xintgcd: Euclidean algorithm with xint package %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -165,7 +165,7 @@ \fi \expandafter\x\csname ver@xintgcd.sty\endcsname \ProvidesPackage{xintgcd}% - [2013/06/14 v1.08b Euclide algorithm with xint package (jfB)]% + [2013/09/24 v1.09a Euclide algorithm with xint package (jfB)]% \def\xintGCD {\romannumeral0\xintgcd }% \def\xintgcd #1% {% @@ -199,14 +199,62 @@ \romannumeral0\XINT_div_prepare {#1}{#2}\Z {#1}% }% +\def\xintGCDof {\romannumeral0\xintgcdof }% +\def\xintgcdof #1{\expandafter\XINT_gcdof_a\romannumeral-`0#1\relax }% +\def\XINT_gcdof_a #1{\expandafter\XINT_gcdof_b\romannumeral-`0#1\Z }% +\def\XINT_gcdof_b #1\Z #2{\expandafter\XINT_gcdof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_gcdof_c #1{\xint_gob_til_relax #1\XINT_gcdof_e\relax\XINT_gcdof_d #1}% +\def\XINT_gcdof_d #1\Z {\expandafter\XINT_gcdof_b\romannumeral0\xintgcd {#1}}% +\def\XINT_gcdof_e #1\Z #2\Z { #2}% +\def\xintGCDof:csv #1{\expandafter\XINT_gcdof:_b\romannumeral-`0#1,,}% +\def\XINT_gcdof:_b #1,#2,{\expandafter\XINT_gcdof:_c\romannumeral-`0#2,{#1},}% +\def\XINT_gcdof:_c #1{\if #1,\expandafter\XINT_gcdof:_e + \else\expandafter\XINT_gcdof:_d\fi #1}% +\def\XINT_gcdof:_d #1,{\expandafter\XINT_gcdof:_b\romannumeral0\xintgcd {#1}}% +\def\XINT_gcdof:_e ,#1,{#1}% +\def\xintLCM {\romannumeral0\xintlcm}% +\def\xintlcm #1% +{% + \expandafter\XINT_lcm\expandafter{\romannumeral0\xintiabs {#1}}% +}% +\def\XINT_lcm #1#2% +{% + \expandafter\XINT_lcm_fork\romannumeral0\xintiabs {#2}\Z #1\Z +}% +\def\XINT_lcm_fork #1#2\Z #3#4\Z +{% + \xint_UDzerofork + #1\dummy \XINT_lcm_BisZero + #3\dummy \XINT_lcm_AisZero + 0\dummy \expandafter + \krof + \XINT_lcm_notzero\expandafter{\romannumeral0\XINT_gcd_loop {#1#2}{#3#4}}% + {#1#2}{#3#4}% +}% +\def\XINT_lcm_AisZero #1#2#3#4#5{ 0}% +\def\XINT_lcm_BisZero #1#2#3#4#5{ 0}% +\def\XINT_lcm_notzero #1#2#3{\xintiimul {#2}{\xintQuo{#3}{#1}}}% +\def\xintLCMof {\romannumeral0\xintlcmof }% +\def\xintlcmof #1{\expandafter\XINT_lcmof_a\romannumeral-`0#1\relax }% +\def\XINT_lcmof_a #1{\expandafter\XINT_lcmof_b\romannumeral-`0#1\Z }% +\def\XINT_lcmof_b #1\Z #2{\expandafter\XINT_lcmof_c\romannumeral-`0#2\Z {#1}\Z}% +\def\XINT_lcmof_c #1{\xint_gob_til_relax #1\XINT_lcmof_e\relax\XINT_lcmof_d #1}% +\def\XINT_lcmof_d #1\Z {\expandafter\XINT_lcmof_b\romannumeral0\xintlcm {#1}}% +\def\XINT_lcmof_e #1\Z #2\Z { #2}% +\def\xintLCMof:csv #1{\expandafter\XINT_lcmof:_a\romannumeral-`0#1,,}% +\def\XINT_lcmof:_a #1,#2,{\expandafter\XINT_lcmof:_c\romannumeral-`0#2,{#1},}% +\def\XINT_lcmof:_c #1{\if#1,\expandafter\XINT_lcmof:_e + \else\expandafter\XINT_lcmof:_d\fi #1}% +\def\XINT_lcmof:_d #1,{\expandafter\XINT_lcmof:_a\romannumeral0\xintlcm {#1}}% +\def\XINT_lcmof:_e ,#1,{#1}% \def\xintBezout {\romannumeral0\xintbezout }% \def\xintbezout #1% {% - \expandafter\xint_bezout\expandafter {\romannumeral-`0#1}% + \expandafter\xint_bezout\expandafter {\romannumeral0\xintnum{#1}}% }% \def\xint_bezout #1#2% {% - \expandafter\XINT_bezout_fork \romannumeral-`0#2\Z #1\Z + \expandafter\XINT_bezout_fork \romannumeral0\xintnum{#2}\Z #1\Z }% \def\XINT_bezout_fork #1#2\Z #3#4\Z {% @@ -251,7 +299,7 @@ \def\XINT_bezout_mm_post #1#2% {% \expandafter\XINT_bezout_mm_postb\expandafter - {\romannumeral0\xintiopp{#2}}{\romannumeral0\xintiopp{#1}}% + {\romannumeral0\xintiiopp{#2}}{\romannumeral0\xintiiopp{#1}}% }% \def\XINT_bezout_mm_postb #1#2% {% @@ -269,7 +317,7 @@ \def\XINT_bezout_mp_post #1#2% {% \expandafter\XINT_bezout_mp_postb\expandafter - {\romannumeral0\xintiopp {#2}}{#1}% + {\romannumeral0\xintiiopp {#2}}{#1}% }% \def\XINT_bezout_mp_postb #1#2#3#4#5% {% @@ -307,8 +355,8 @@ \def\XINT_bezout_loop_b #1#2#3#4#5#6#7#8% {% \expandafter \XINT_bezout_loop_c \expandafter - {\romannumeral0\xintiadd{\XINT_Mul{#5}{#2}}{#7}}% - {\romannumeral0\xintiadd{\XINT_Mul{#6}{#2}}{#8}}% + {\romannumeral0\xintiiadd{\XINT_Mul{#5}{#2}}{#7}}% + {\romannumeral0\xintiiadd{\XINT_Mul{#6}{#2}}{#8}}% {#1}{#3}{#4}{#5}{#6}% }% \def\XINT_bezout_loop_c #1#2% @@ -421,8 +469,8 @@ \def\XINT_bezalg_b #1#2#3#4#5#6#7#8% {% \expandafter\XINT_bezalg_c\expandafter - {\romannumeral0\xintiadd {\xintiMul {#6}{#2}}{#8}}% - {\romannumeral0\xintiadd {\xintiMul {#5}{#2}}{#7}}% + {\romannumeral0\xintiiadd {\xintiiMul {#6}{#2}}{#8}}% + {\romannumeral0\xintiiadd {\xintiiMul {#5}{#2}}{#7}}% {#1}{#2}{#3}{#4}{#5}{#6}% }% \def\XINT_bezalg_c #1#2#3#4#5#6% diff --git a/Master/texmf-dist/tex/generic/xint/xintseries.sty b/Master/texmf-dist/tex/generic/xint/xintseries.sty index 2a63f12eb29..1b65cfb260f 100644 --- a/Master/texmf-dist/tex/generic/xint/xintseries.sty +++ b/Master/texmf-dist/tex/generic/xint/xintseries.sty @@ -22,7 +22,7 @@ %% in the same archive or directory.) %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.08b of June 14, 2013) +%% The xint bundle (version 1.09a of September 22, 2013) %% xintseries: Expandable partial sums with xint package %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -165,7 +165,7 @@ \fi \expandafter\x\csname ver@xintseries.sty\endcsname \ProvidesPackage{xintseries}% - [2013/06/14 v1.08b Expandable partial sums with xint package (jfB)]% + [2013/09/24 v1.09a Expandable partial sums with xint package (jfB)]% \def\xintSeries {\romannumeral0\xintseries }% \def\xintseries #1#2% {% @@ -211,7 +211,7 @@ \ifnum #3>#1 \else \XINT_iseries_exit \fi \expandafter\XINT_iseries_loop\expandafter {\the\numexpr #1+1\expandafter }\expandafter - {\romannumeral0\xintiadd {#2}{#4{#1}}}% + {\romannumeral0\xintiiadd {#2}{#4{#1}}}% {#3}{#4}% }% \def\XINT_iseries_exit \fi #1#2#3#4#5#6#7#8% @@ -369,7 +369,7 @@ {% \expandafter\XINT_fppowseries_loop_i\expandafter {\the\numexpr #2+\xint_c_i\expandafter}\expandafter - {\romannumeral0\xintiadd {#4}{\xintiTrunc {#7}{\xintMul {#6{#2}}{#1}}}}% + {\romannumeral0\xintiiadd {#4}{\xintiTrunc {#7}{\xintMul {#6{#2}}{#1}}}}% {#1}{#3}{#5}{#6}{#7}% }% \def\XINT_fppowseries_exit_i\fi\expandafter\XINT_fppowseries_loop_ii @@ -377,7 +377,7 @@ \def\XINT_fppowseries_exit_ii #1#2#3#4#5#6#7% {% \xinttrunc {#7} - {\xintiAdd {#4}{\xintiTrunc {#7}{\xintMul {#6{#2}}{#1}}}[-#7]}% + {\xintiiadd {#4}{\xintiTrunc {#7}{\xintMul {#6{#2}}{#1}}}[-#7]}% }% \def\xintFxPtPowerSeriesX {\romannumeral0\xintfxptpowerseriesx }% \def\xintfxptpowerseriesx #1#2% @@ -415,7 +415,7 @@ {% \expandafter\XINT_flpowseries\expandafter {\the\numexpr #1\expandafter}\expandafter - {\the\numexpr #2}\XINT_digits + {\the\numexpr #2}\XINTdigits }% \def\XINT_flpowseries_opt [\Z #1]#2#3% {% @@ -430,7 +430,7 @@ \else \xint_afterfi {\expandafter\XINT_flpowseries_loop_pre\expandafter - {\romannumeral-`0\XINTinfloatpow [#3]{#5}{#1}}% + {\romannumeral0\XINTinfloatpow [#3]{#5}{#1}}% {#1}{#5}{#2}{#4}{#3}% }% \fi @@ -440,7 +440,7 @@ \ifnum #4>#2 \else\XINT_flpowseries_dont_i \fi \expandafter\XINT_flpowseries_loop_i\expandafter {\the\numexpr #2+\xint_c_i\expandafter}\expandafter - {\romannumeral-`0\XINTinfloatmul [#6]{#5{#2}}{#1}}% + {\romannumeral0\XINTinfloatmul [#6]{#5{#2}}{#1}}% {#1}{#3}{#4}{#5}{#6}% }% \def\XINT_flpowseries_dont_i \fi\expandafter\XINT_flpowseries_loop_i @@ -450,14 +450,14 @@ {% \ifnum #5>#1 \else \XINT_flpowseries_exit_i \fi \expandafter\XINT_flpowseries_loop_ii\expandafter - {\romannumeral-`0\XINTinfloatmul [#7]{#3}{#4}}% + {\romannumeral0\XINTinfloatmul [#7]{#3}{#4}}% {#1}{#4}{#2}{#5}{#6}{#7}% }% \def\XINT_flpowseries_loop_ii #1#2#3#4#5#6#7% {% \expandafter\XINT_flpowseries_loop_i\expandafter {\the\numexpr #2+\xint_c_i\expandafter}\expandafter - {\romannumeral-`0\XINTinfloatadd [#7]{#4}% + {\romannumeral0\XINTinfloatadd [#7]{#4}% {\XINTinfloatmul [#7]{#6{#2}}{#1}}}% {#1}{#3}{#5}{#6}{#7}% }% @@ -480,7 +480,7 @@ {% \expandafter\XINT_flpowseriesx\expandafter {\the\numexpr #1\expandafter}\expandafter - {\the\numexpr #2}\XINT_digits + {\the\numexpr #2}\XINTdigits }% \def\XINT_flpowseriesx_opt [\Z #1]#2#3% {% @@ -502,7 +502,7 @@ \def\XINT_flpowseriesx_pre #1#2#3#4#5% {% \expandafter\XINT_flpowseries_loop_pre\expandafter - {\romannumeral-`0\XINTinfloatpow [#5]{#1}{#2}}% + {\romannumeral0\XINTinfloatpow [#5]{#1}{#2}}% {#2}{#1}{#3}{#4}{#5}% }% \XINT_series_restorecatcodes_endinput% |