summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r--Master/texmf-dist/source/generic/xint/xint.dtx2961
-rw-r--r--Master/texmf-dist/source/generic/xint/xint.ins2
2 files changed, 1515 insertions, 1448 deletions
diff --git a/Master/texmf-dist/source/generic/xint/xint.dtx b/Master/texmf-dist/source/generic/xint/xint.dtx
index dd00e51353d..d7cab49df27 100644
--- a/Master/texmf-dist/source/generic/xint/xint.dtx
+++ b/Master/texmf-dist/source/generic/xint/xint.dtx
@@ -1,8 +1,8 @@
% -*- coding: iso-latin-1; -*-
-% This file: xint.dtx (1.05a, 2013/05/02)
+% This file: xint.dtx (1.06, 2013/05/07)
%%
%%----------------------------------------------------------------
-%% The xint bundle (version 1.05a of May 2nd, 2013)
+%% The xint bundle (version 1.06 of May 7th, 2013)
%<xint>%% xint: Expandable operations on long numbers
%<xintgcd>%% xintgcd: Euclidean algorithm with xint package
%<xintfrac>%% xintfrac: Expandable operations on fractions
@@ -75,9 +75,9 @@
% \input xintcfrac.sty\relax % (loads xintfrac)
%
%<*none>
-\def\lasttimestamp{Time-stamp: <02-05-2013 17:37:34 CEST BURNOL>}
-\def\pkgversion{1.05a}
-\def\pkgdate{2013/05/02}
+\def\lasttimestamp{Time-stamp: <07-05-2013 19:08:02 CEST jfb>}
+\def\pkgversion{1.06}
+\def\pkgdate{2013/05/07}
\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}
@@ -166,6 +166,8 @@
% attention de positionner \toctransition *après* le début de la section
% "implémentation de xint"
+\def\stripatdot #1.{}
+
\let\savedsectionline\l@section
\etocsetstyle{section}{}{}
{\savedsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
@@ -173,9 +175,12 @@
{\begingroup
\setlength{\premulticols}{0pt}
\setlength{\multicolsep}{0pt}
- \setlength{\columnsep}{1em}
+ \setlength{\columnsep}{1.5em}
\begin{multicols}{2}}{}
- {\noindent\makebox[2.5em][l]{\etocnumber}\etocname\leaders\etoctoclineleaders\hfill\etocpage\endgraf}
+ {\noindent\makebox[1.5em][l]
+ {\ttfamily\expandafter\stripatdot\etocthenumber}%
+ \etocname\leaders\etoctoclineleaders\hfill
+ {\normalfont\etocpage}\endgraf}
{\end{multicols}\endgroup}%
\makeatother
@@ -244,6 +249,7 @@
\definecolor{niceone}{RGB}{38,128,192}
\usepackage[english]{babel}
+\usepackage[autolanguage,np]{numprint}
\usepackage[pdfencoding=pdfdoc,bookmarks=true]{hyperref}
@@ -349,7 +355,8 @@ pdfpagemode=UseOutlines}
\frenchspacing
\renewcommand\familydefault\sfdefault
-%---- WE WANT TO SEE ALL THOSE NUMBERS
+%---- QUICK WAY TO PRINT LONG THINGS, IN PARTICULAR, BUT NOT EXCLUSIVELY, LONG
+% NUMBERS
\def\allowsplits #1%
{%
\ifx #1\relax \else #1\hskip 0pt plus 1pt\relax
@@ -405,12 +412,14 @@ pdfpagemode=UseOutlines}
\section{Raison d'\^etre of these packages}
+\subsection{Some examples}
+
The main goal is to allow computations with integers and fractions of arbitrary
-sizes.\footnote{Here and elsewhere, ``arbitrarily big'' means roughly with
- numerators and denominators having strictly less than
+sizes.\footnote{Here and elsewhere, ``arbitrarily big'' means roughly numbers
+ with numerators and denominators having strictly less than
2\string^\string{31\string}=2147483648 digits. Memory constraints from the
|etex| or |pdftex| executables presumably limit even more the possible
- computations, not to mention the time taken by them.}
+ computations, not to mention the time taken by them.}
Here are some examples:
@@ -437,16 +446,36 @@ Here are some examples:
{\xintiSub {\xintiPow {2}{200}}{1}}\to\A\B\U\V\D
\printnumber\U$\times$(&7^200-3^200&)+\printnumber{\xintiOpp\V}$\times$(&2^200-1&)=\printnumber\D
+{\color{magenta}The Euclide algorithm applied to
+ \np{179876541573}
+ and \np{66172838904}:}\\
+{\color{blue}|\xintTypesetEuclideAlgorithm {179876541573}{66172838904}|}
+\xintTypesetEuclideAlgorithm {179876541573}{66172838904}
+
The first example uses only the base module \xintname, the next two require
-loading also the \xintfracname package, which deals with fractions. The last one
-requires the \xintgcdname package. The bundle also comprises the \xintseriesname
+loading also the \xintfracname package, which deals with fractions. The last two
+require the \xintgcdname package. The bundle also comprises the \xintseriesname
package, for partial sums of series with fractional coefficients, and
-\xintcfracname
-for continued fractions computations.
+\xintcfracname for continued fractions computations.
+
+To see more of \xintname in action, jump to the
+{\color{niceone}\autoref{sec:series}} describing the commands of the
+\xintseriesname{} package, especially as illustrated with the
+\hyperref[ssec:Machin]{\color{niceone}{traditional computations of $\pi$
+ and $\log 2$}}, or also see the
+{\color{niceone}\hyperlink{e-convergents}{computation of the convergents
+ of $e$}} made with the \xintcfracname package.
+
+Note that almost all of the computational results interspersed through the
+documentation are not hard-coded in the source of the document but just written
+there using the package macros, and were selected to not impact too much the
+compilation time.
+
+\subsection{Expandability, (in)-efficiency}
For some initially circumstantial reasons (related to the origins of the
-package, which will be mentioned next) all macros performing computations are
+package) all macros performing computations are
compatible with an expansion-only context. This programming constraint of
expandability weighs in a lot on the computation time as the macros may have to
shuffle around data containing hundreds of tokens: our current implementation
@@ -481,26 +510,30 @@ complete expandability.\footnote{I could, naturally,
be proven wrong!}\,\footnote{The Lua\TeX{} project possibly makes endeavours
such as \xintname appear even more insane that they are, in truth.}
+\subsection{Missing things}
+
Currently \xintname does not provide `floating-point' operations. The
\LaTeX3 project has implemented expandably floating-point computations
-with 16 significant digits
+with 16 significant figures
(\href{http://www.ctan.org/tex-archive/macros/latex/contrib/l3kernel}{\color{niceone}l3fp}), including
special functions such as exp, log, sine and cosine.
-The most blatantly lacking thing in \xintname so far is a decent input parser,
-allowing to type in computations in a usual infix form such as, for example
-|3*14+2.7^-2*5|. At this time, one has to type |\xintAdd {\xintMul
+The most blatantly lacking thing in the \xintname project is a decent input
+parser, allowing to type in computations in a usual infix form such as, for
+example |3*14+2.7^-2*5|. At this time, one has to type |\xintAdd {\xintMul
{3}{14}}{\xintMul{\xintPow{2.7}{-2}}{5}}|. Previous computation results can be
stored in macros and given as arguments to the package macros (see further on
for important aspects of this).
+
+\subsection{Origins of the package}
+
Package |bigintcalc| by \textsc{Heiko Oberdiek} already
provides expandable arithmetic operations on ``big integers'',
-exceeding the \TeX{} limits (of &2^{31}-1&), so why another
-one? \footnote{this section was written before the
+exceeding the \TeX{} limits (of &2^{31}-1&), so why another\footnote{this section was written before the
\xintfracname package; the author is not aware of another package allowing
expandable computations with arbitrarily big fractions.}
-
+one?
I got started on this in early March 2013, via a thread on the
|c.t.tex| usenet group, where \textsc{Ulrich D\,i\,e\,z} used the
@@ -514,12 +547,12 @@ try my hands at addition and multiplication.
I wrote macros \csa{bigMul} and \csa{bigAdd} which I posted to the
newsgroup; they appeared to work comparatively fast. These first
-versions did not use the \eTeX{} \csa{numexpr} macro, they worked
+versions did not use the \eTeX{} \csa{numexpr} primitive, they worked
one digit at a time, having previously stored carry-arithmetic in
1200 macros.
-I noticed that the |bigintcalc| package used the \csa{numexpr}
-\eTeX{} primitive when available, but (as far as I could tell) not
+I noticed that the |bigintcalc| package used\csa{numexpr}
+if available, but (as far as I could tell) not
to do computations many digits at a time. Using \csa{numexpr} for
one digit at a time for \csa{bigAdd} and \csa{bigMul} slowed them
a tiny bit but avoided cluttering \TeX{} memory with the 1200
@@ -535,17 +568,6 @@ The present package is the result of this initial questioning.
\end{framed}
-To see \xintname in action, jump to the
-{\color{niceone}\autoref{sec:series}} describing the commands of the
-\xintseriesname{} package, especially as illustrated with the
-\hyperref[ssec:Machin]{\color{niceone}{traditional computations of $\pi$
- and $\log 2$}}, or also see the
-{\color{niceone}\hyperlink{e-convergents}{computation of the convergents
- of $e$}} made with the \xintcfracname package. Note that almost all
-of the computational results interspersed through the documentation are
-not hard-coded in the source of the document but just written there
-using the package macros, and were selected to not impact too much the
-compilation time.
\section{Expansions}
@@ -566,13 +588,12 @@ of course in an |\edef|.
\edef\x{\xintQuo{\xintPow {2}{1000}}{\xintFac{100}}}
\edef\y{\xintLen{\x}}
-Furthermore the package macros give their final results in two
-expansion steps. They twice expand their arguments so that they
-can be arbitrarily chained. Hence \centeredline{%
- |\xintLen{\xintQuo{\xintPow{2}{1000}}{\xintFac{100}}}|} expands
-in two steps and tells us that &[2^{1000}/100!]& has {\y}
-digits. This is not so many, let us print them here:
-\printnumber\x.
+Furthermore the package macros give their final results in two expansion steps.
+They expand `fully' (the first token of) their arguments so that they can be
+arbitrarily chained. Hence \centeredline{%
+ |\xintLen{\xintQuo{\xintPow{2}{1000}}{\xintFac{100}}}|} expands in two steps
+and tells us that &[2^{1000}/100!]& has {\y} digits. This is not so many, let us
+print them here: \printnumber\x.
For the sake of typesetting this documentation and not have big numbers
extend into the margin and go beyond the page physical limits, I use
@@ -585,112 +606,176 @@ these commands (not provided by the package):
% Expands twice before printing.
\end{verbatim}
-The |\printnumber| macro is not part of the package and would need
-additional thinking for more general use. It may be used as
-|\printnumber {\xintQuo{\xintPow {2}{1000}}{\xintFac{100}}}|, or
-as |\printnumber\mynumber| if the macro |\mynumber| was previously
-defined via |\edef\mynumber {\|\texttt{xintQuo}|{\xintPow
- {2}{1000}}{\xintFac{100}}}|. A |\newcommand| or |\def| for the
-definition of |\mynumber| would not do for the reason which is
-explained in \autoref{item:xpxp} below (it would if we had inserted
-seven, and not only three |\expandafter|'s in the definition of |\printnumber|).
+The |\printnumber| macro is not part of the package and would need additional
+thinking for more general use. It may be used as |\printnumber
+{\xintQuo{\xintPow {2}{1000}}{\xintFac{100}}}|, or as |\printnumber\mynumber| if
+the macro |\mynumber| was previously defined via an |\edef|, as for
+example:\centeredline{ |\edef\mynumber {\|\texttt{xintQuo}|{\xintPow
+ {2}{1000}}{\xintFac{100}}}|}%
+or as
+ |\expandafter\printnumber\expandafter{\mynumber}|, if the macro |\mynumber| is
+ defined by a |\newcommand| or a |\def| (see below {\color{niceone}\autoref{item:xpxp}} for the
+ underlying expansion issue; adding four |\expandafter|'s to |\printnumber|
+ would allow to use it directly as |\printnumber\mynumber| with a |\mynumber|
+ itself defined via a |\def| or |\newcommand|).
+
+\def\x {\xintTrunc {300}{\xintPow{.7}{-25}}}%
Just to show off, let's print 300 digits (after the decimal point) of
the decimal expansion of &0.7^{-25}&:
\centeredline{|\printnumber {\xintTrunc {300}{\xintPow{.7}{-25}}}\dots|}
-\printnumber {\xintTrunc {300}{\xintPow{.7}{-25}}}\dots
+\expandafter\printnumber\expandafter {\x}\dots
This computation uses \xintfracname wich extends to fractions the basic
arithmetic operations defined for integers by \xintname.
-Important points, to be noted, related to the double expansion of arguments:
+
+Important points, to be noted, related to the expansion of arguments:
\begin{enumerate}
-\item When I say that the macros expand twice their arguments,
- this means that they expand the first token seen (for each
- argument), then expand again the first token of the result of
- the first expansion. For example
- \centeredline{|\def\x{12}\def\y{34}|%
- |\xintAdd {\x}{\x\y}|} is \emph{not} a legal construct. It works here
- by sheer luck as the |\y| gets expanded inside a |\numexpr|. But
- this would fail in general: if you need a more complete
- (expandable...) expansion of your initial input, you should use
- the \fbox{\csa{bigintcalcNum}} macro from the |bigintcalc|
- package. Or, outside of an expandable-only context, just massage
- your inputs through \csa{edef}'s.
+\item the macros expand `fully' their arguments,\vadjust{\vskip-\dp\strutbox
+ \hbox{\smash{\color{niceone}\llap{\strut\small CHANGED! (|1.06|)\
+ $\to$\kern\parindent
+ }}}\vskip\dp\strutbox } this means that they expand the
+ first token seen (for each argument), then expand \strut{} again, 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 \centeredline{|\def\x{12}\def\y{34}|%
+ |\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 are
+ expected by the
+ sub-routiunes of |\xintAdd|. It works here by sheer luck as the |\y|
+ gets expanded inside a |\numexpr|. But this would fail in general: if you need
+ a more complete (expandable...) expansion of your initial input, you should
+ use the \fbox{\csa{bigintcalcNum}} macro from the |bigintcalc| package. Or,
+ outside of an expandable-only context, just massage your inputs through
+ \csa{edef}'s.
\item Unfortunately, after |\def\x {12}|, one can not use just
{\color{blue}|-\x|} as input to one of the package macros: the rules above
- explain that the twice expansion will act only on the minus sign,
+ explain that the expansion will act only on the minus sign,
hence do nothing. The only way is to use the \csb{xintOpp}
macro, which replaces a number with its opposite.
\def\x {12}%
+\def\AplusBC #1#2#3{\xintAdd {#1}{\xintMul {#2}{#3}}}%
+
+
\item \label{item:xpxp} With the definition \centeredline{%
|\def\AplusBC #1#2#3{\xintAdd {#1}{\xintMul {#2}{#3}}}|} one
obtains an expandable macro producing the expected result, not
in two, but rather in three steps: a first expansion is consumed
- by the macro expanding to its definition. As a result {|\xintAdd
- {\AplusBC {1}{2}{3}}{4}|} would then miserably fail. The
- solution is to use the \emph{lowercase} form of
+ by the macro expanding to its definition. The new expansion policy starting
+ with the package
+ 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 \texttt{\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.}
+
+ 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
\csa{xintAdd}: \smallskip\centeredline {|\def\AplusBC
#1#2#3{|{\color{blue}|\romannumeral0\xintadd |}|{#1}{\xintMul {#2}{#3}}}|}
and then \csa{AplusBC} will share the same properties as do the
other \xintname `primitive' macros.
-% ENFIN DÉBARRASSÉ DES TRÈS TRÈS TRÈS CHIANTS EOL ERROR DE \verb !!!
-
-The lowercase form is \emph{only} for the external highest level of
-chained commands. All \xintname provided public macros have such a
-lowercase form precisely to facilitate building-up higher level macros
-based on them. 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
-This then allows further definitions, such as:\par
-\hspace*{1cm}|\def\aplusbcsquared #1#2#3{\aplusbc {#1}{#2}{\xintSqr{#3}}}|\par
-\hspace*{1cm}|\def\AplusBCSquared {\romannumeral0\aplusbcsquared}|\par
-\end{enumerate}
-\section {Inputs and outputs}
+ 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
+\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.
\begin{framed}
- \TeX{}'s count registers cannot be directly used but must be
- prefixed by |\the| or |\number|. The same for \csa{numexpr}
- expressions.
+ {\color{niceone}New with |1.06|}: those macro arguments which are
+ intrinsically constrained to obey the \TeX{} bounds on integers (see the next
+ section) are now systematically fed to a |\numexpr|, hence they will be
+ subjected to a complete expansion, registers are allowed, and things such as
+ |\mycount+\myothercount*17| become admissible arguments.
\end{framed}
+\section {Inputs and outputs}
-The arguments to most of the bundle macros are of three types:
+The arguments to most of the \xintname macros are of three types:
\begin{enumerate}
-\item `short' integers, \emph{i.e.} less in absolute value than
- \xintiSub{\xintiPow {2}{31}}1. I will refer to this as the `\TeX{}' or
- `|\numexpr|' limit. This is case for the exponent in the power function. In
- that specific case the limit is (if the number raised to this power is not 0
- or 1) even lowered to 999999999. The factorial function (since release |1.05|)
- refuses input larger than 999999. When these conditions are not met, the error
- may be signaled from a \csa{numexpr} expression rather than from a package
- macro.
-\item `long' integers, which are the bread and butter of the package macros.
- They are signed integers with a number of
- digits less than the \TeX-\csa{numexpr} bound. Concretely though, multiplying
- two 1000 digits numbers is already a longish operation.
-\item `gigantic' integers, with no limit on size whatsoever. Probably, they are
- made impossible by memory constraints of the \TeX{} implementations.
- Theoretically, the addition, but not the multiplication nor the division,
- could treat even such gigantic numbers. With the \xintfracname package loaded
- though, they are not accepted, even for addition.
-\item fractions: they should be the ratio of two long integers. The macro
- \csa{xintLen} returns the sum of their lengths, and this sum should then obey
- the \TeX-\csa{numexpr} bound.
+\item `short' integers, \emph{i.e.} less than (or equal to) in absolute value
+ \np{\xintiSub{\xintiPow {2}{31}}1}. I will refer to this as the `\TeX{}' or
+ `|\numexpr|' limit. This is the case for arguments which serve to count or
+ index something. It is also the case for exponent in the power function and
+ for the argument to the factorial function. The bounds have been (arbitrarily)
+ lowered to \np{999999999} and \np{999999} respectively for the latter cases.
+ When the argument exceeds the \TeX{} bound (either positively or negatively),
+ an error will originate from a \csa{numexpr} expression and it may
+ sometimes be followed by a more specific error `message' from a
+ package macros.
+\item `long' integers, which are the bread and butter of the package commands.
+ They are signed integers with a practically illimited number of digits.
+ Theoretically though, most of the macros require that the number of digits
+ itself be less than the \TeX-\csa{numexpr} bound (more precisely &2^31-9&).
+ Some macros, such as addition when \xintfracname has not been loaded, do not
+ measure first the length of their arguments and could theoretically be used
+ with `gigantic' integers with a larger number of digits. However memory
+ constraints from the \TeX{} implementation probably exclude such inputs.
+ Concretely though, multiplying out two 1000 digits numbers is already a
+ longish operation.
+\item `fractions': they become available after having loaded the \xintfracname
+ package. Their format on input will be described next, a fraction has a
+ numerator, a forward slash and then a denominator.
\end{enumerate}
+\begin{framed}
+ \TeX{}'s count registers cannot serve directly as arguments to the package
+ macros
+ accepting `long numbers' or fractions on input: they must be prefixed by
+ |\the| or |\number|. The same for \csa{numexpr} expressions. However,\strut{}
+ count registers and |\numexpr| expressions\vadjust{\vskip-\dp\strutbox
+ \hbox{\smash{\color{niceone}\llap{\strut\small NEW WITH |1.06|\
+ $\to$\kern\parindent
+ }}}\vskip\dp\strutbox } are allowed in arguments intrinsically
+ constrained to obey the \TeX{} bounds.
+\end{framed}
+
+
\edef\z {\xintAdd
{+--0367.8920280/-++278.289287}{-109.2882/+270.12898}}
-The package macros first operate a double expansion of their arguments. They
-expect these expansions to deliver numbers obeying two types of format:
+The package macros first operate a `full' expansion\vadjust{\vskip-\dp\strutbox
+ \hbox{\smash{\color{niceone}\llap{\strut\small NEW WITH |1.06|\ $\to$\
+ }}}\vskip\dp\strutbox } of their \strut{} arguments, as
+explained above: only the first token is repeatedly expanded until no more is
+possible.
+
+On the other hand, this
+expansion is\strut{} a \emph{complete one }\vadjust{\vskip-\dp\strutbox
+ \hbox{\smash{\color{niceone}\llap{\strut\small NEW WITH |1.06|\ $\to$\
+ }}}\vskip\dp\strutbox } for those arguments which
+are constrained to obey the \TeX{} bounds on numbers, as they are systematically
+inserted inside a |\numexpr...\relax| expression.
+
+
+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
be a string of digits, optionally preceded by a unique minus sign. The first
@@ -726,32 +811,35 @@ computes a euclidean quotient). It now does, because its arguments are in truth
integers.
A number can start directly with a decimal point:
- \centeredline{|\xintPow{-.3/.7}{11}=|{\xintPow{-.3/+.7}{11}}}%
-It is
- also licit to use |\A/\B| as input if each of |\A| and |\B| expands in
- at most two steps to a ``decimal number'' as examplified above by the
- numerators and denominators. Or one may have just one macro |\C| which
- expands to such a ``fraction with optional decimal points'', or mixed
- things such as |\A 245/7.77|, where the numerator will be the
- concatenation of the expansion of |\A| and |245|. But, as explained
- already |123\A| is a no-go.
+\centeredline{|\xintPow{-.3/.7}{11}=|{\xintPow{-.3/+.7}{11}}}%
+It is also licit to use |\A/\B| as input if each of |\A| and |\B| expands (in
+the sense previously described) to a ``decimal number'' as examplified above by
+the numerators and denominators. Or one may have just one macro |\C| which
+expands to such a ``fraction with optional decimal points'', or mixed things
+such as |\A 245/7.77|, where the numerator will be the concatenation of the
+expansion of |\A| and |245|. But, as explained already |123\A| is a no-go.
+
Loading \xintfracname not only relaxes the format of the inputs; it also
modifies the format of the outputs: except when filtered through the
\csb{xintIrr} macro, a fraction is always output in the |A/B[n]| form (which
-stands for &(A/B)10^n&; some macros print |A[n]| when the
-denominator is one). The |A| and |B| may end in zeros (\emph{i.e}, |n| does
+stands for &(A/B)10^n&; some macros print |A[n]| in certain circumstances when
+the denominator is one). The |A| and |B| may end in zeros (\emph{i.e}, |n| does
not represent all powers of ten), and will generally have a common factor. The
-denominator |B| is always strictly positive.
+denominator |B| is always strictly positive.
+
+A macro \csb{xintFrac} is provided
+for the typesetting (math-mode only) of such a `raw' output. Of course, the
+\csb{xintFrac} itself is not accepted as input to the package macros.
Direct user input of things such as |16000/289072[17]| or |3[-4]| is authorized.
It is even possible to use |\A/\B[17]| if |\A| expands to |16000| and |\B| to
-|289072|, or |\A| if |\A| expands to |3[-4]|. However, NEITHER the numerator NOR
-the denominator\strut{} may then have a decimal
-point.\vadjust{\vskip-\dp\strutbox
- \hbox{\smash{\color{niceone}\llap{\strut\small IMPORTANT!\ $\Bigg\{$\
- }}}\vskip\dp\strutbox } And, for this format, ONLY the numerator may carry
+|289072|, or |\A| if |\A| expands to |3[-4]|. However,\strut{}\vadjust{\vskip-\dp\strutbox
+ \hbox{\smash{\color{niceone}\llap{\strut\small IMPORTANT!\ $\to$\
+ }}}\vskip\dp\strutbox } NEITHER the numerator NOR
+the denominator may then have a decimal
+point. And, for this format, ONLY the numerator may carry
a UNIQUE minus sign (and no superfluous leading zeros; and NO plus sign).
The, more demanding, format with a power of ten represented by a number within
@@ -764,11 +852,12 @@ a UNIQUE minus sign (and no superfluous leading zeros; and NO plus sign).
they always output computation results in the |A/B[n]| form (or
|A[n]|).
- All computations done by \xintfracname on fractions are exact. Inputs
- containing decimal points do not make the package switch to a
- (currently non-existent) `floating-point' mode. The inputs, however
- long, are always converted into an exact internal representation.
-
+ \begin{framed}
+ All computations done by \xintfracname on fractions are exact. Inputs
+ containing decimal points do not make the package switch to a (currently
+ non-existent) `floating-point' mode. The inputs, however long, are always
+ converted into an exact internal representation.
+ \end{framed}
Generally speaking, there should be no spaces among the digits in the inputs.
Although most would be harmless in most macros, there are some cases
@@ -938,8 +1027,8 @@ within braces. Examples of multiple-output macros are \csb{xintDivision} which
gives first the quotient and then the remainder of euclidean division,
\csb{xintBezout} from the \xintgcdname package which outputs five numbers,
\csb{xintFtoCv} from the \xintcfracname package which returns the list of the
-convergents of a fraction, ... see the next section for ways to deal with such
-outputs.
+convergents of a fraction, ... the next two sections explain ways to deal,
+expandably or not, with such outputs.
See the \autoref{xintDecSplit} for a rare example of a bundle macro which may
return an empty string, or a number prefixed by a chain of zeros. This is the
@@ -983,16 +1072,21 @@ expandability. For example why not allow oneself the two definitions
\expandafter\allowsplits\meaning\tmpU\relax}, |\V|\texttt{:
\expandafter\allowsplits\meaning\tmpV\relax} and |\D=|\texttt{\tmpD}.
- When one does not know in advance the number of tokens, one can
- use \csa{xintAssignArray} or its synonym \csa{xintDigitsOf}:
+ When one does not know in advance the number of tokens, one can use
+ \csa{xintAssignArray} or its synonym \csa{xintDigitsOf}:
\centeredline{\csb{xintDigitsOf}\csa{xintiPow}|{2}{100}|\csbnolk{to}\csa{Out}}
- This defines \csa{Out} to be macro with one parameter,
- \csa{Out}|{0}| gives the size |N| of the array and
- \csa{Out}|{n}|, for |n| from |1| to |N| then gives the |n|th
- element of the array, here the |n|th digit of &2^{100}&, from
- the most significant to the least significant. As usual, the
- generated macro \csa{Out} is completely expandable and expands twice its
- (unique) argument. Consider the following code snippet:
+ This defines \csa{Out} to be macro with one parameter, \csa{Out}|{0}| gives
+ the size |N| of the array and \csa{Out}|{n}|, for |n| from |1| to |N| then
+ gives the |n|th element of the array, here the |n|th digit of &2^{100}&, from
+ the most significant to the least significant. As usual, the generated macro
+ \csa{Out} is completely expandable (in two steps). As it wouldn't make much
+ sense to allow indices exceeding the \TeX{} bounds, the macros created by
+ \csb{xintAssignArray} put their argument inside a
+ \csa{numexpr},\vadjust{\vskip-\dp\strutbox
+ \hbox{\smash{\color{niceone}\llap{\strut\small CHANGED (1.06)!\ $\Bigg\{$\
+ }}}\vskip\dp\strutbox } so it is completely\strut{} expanded and may be
+ a count register, not necessarily prefixed by |\the| or |\number|. Consider
+ the following code snippet:
\begin{verbatim}
\newcount\cnta
\newcount\cntb
@@ -1001,7 +1095,7 @@ expandability. For example why not allow oneself the two definitions
\cnta = 1
\cntb = 0
\loop
-\advance \cntb \xintiSqr{\Out{\the\cnta}}
+\advance \cntb \xintiSqr{\Out{\cnta}}
\ifnum \cnta < \Out{0}
\advance\cnta 1
\repeat
@@ -1009,7 +1103,7 @@ expandability. For example why not allow oneself the two definitions
|2^{100}| (=\xintiPow {2}{100}) has \Out{0} digits and the sum of
their squares is \the\cntb. These digits are, from the least to
the most significant: \cnta = \Out{0}
-\loop \Out{\the\cnta}\ifnum \cnta > 1 \advance\cnta -1 , \repeat.
+\loop \Out{\cnta}\ifnum \cnta > 1 \advance\cnta -1 , \repeat.
\endgroup
\end{verbatim}
@@ -1020,7 +1114,7 @@ the most significant: \cnta = \Out{0}
\cnta = 1
\cntb = 0
\loop
-\advance \cntb \xintiSqr{\Out{\the\cnta}}
+\advance \cntb \xintiSqr{\Out{\cnta}}
\ifnum \cnta < \Out{0}
\advance\cnta 1
\repeat
@@ -1028,7 +1122,7 @@ the most significant: \cnta = \Out{0}
&2^{100}& (=\z) has \Out{0} digits and the sum of
their squares is \the\cntb. These digits are, from the least to
the most significant: \cnta = \Out{0}
-\loop \Out{\the\cnta}\ifnum \cnta > 1 \advance\cnta -1 , \repeat.
+\loop \Out{\cnta}\ifnum \cnta > 1 \advance\cnta -1 , \repeat.
\endgroup
We used a group in order to release the memory taken by the
@@ -1058,33 +1152,10 @@ would have been a summand enclosed within braces, due to the rules
of \TeX{} for parsing macro arguments.
Note that |{-\xintRem{3347}{591}}| is not a valid input, because
-the double expansion will apply only to the minus sign and leave
+the expansion will apply only to the minus sign and leave
unaffected the |\xintRem|. So we used \csa{xint}\-|iOpp| which replaces
a number with its opposite.
-\def\justone #1{1}%
-
-Release |1.04| of \xintname has more macros returning lists of things (each one
-within group braces, or a single token) such as the convergents of a continued
-fraction. The two new expandable commands \csb{xintApply} and
-\csb{xintListWithSep} help manipulate and display such lists without having to
-go through the un-expandable \csb{xintAssignArray}.
-\begin{verbatim}
-\newcommand{\justone}[1]{1}%
-|2^{100}| (=\xintiPow {2}{100}) has
-\xintiSum{\xintApply {\justone}{\xintiPow {2}{100}}}
-digits and the sum of their squares is
-\xintiSum{\xintApply {\xintiSqr}{\xintiPow {2}{100}}}.
-These digits are, from the least to the most significant:
-\xintListWithSep {, }{\xintRev{\xintiPow {2}{100}}}.
-\end{verbatim}
-|2^{100}| (=\z) has \xintiSum{\xintApply\justone\z} digits and the sum of
-their squares is \xintiSum{\xintApply\xintiSqr\z}. These digits are, from the
-least to the most significant: \xintListWithSep {, }{\xintRev\z}.
-
-Of course, one could spare the CPU some repetitions with an earlier
-|\edef\z{\xintiPow {2}{100}}|, and using |\z| in place of
- |\xintiPow {2}{100}| everywhere in the above.
As a last example with \csa{xintAssignArray} here is one line
extracted from the source code of the \xintgcdname macro
@@ -1102,8 +1173,45 @@ from the first to the last step of the algorithm. The
\csa{xintTypesetEuclideAlgorithm} macro organizes this data
for typesetting: this is just an example of one way to do it.
+\section{Utilities for expandable manipulations}
+
+The\vadjust{\vskip-\dp\strutbox
+ \hbox{\smash{\color{niceone}\llap{\strut\small EXTENDED (1.06)\ $\to$\
+ }}}\vskip\dp\strutbox } package\strut{} now has more utilities to deal expandably with `lists of
+things', which were treated un-expandably in the previous section with
+\csa{xintAssign} and \csa{xintAssignArray}: \csb{xintRev},
+\csb{xintReverseOrder}, \csb{xintLen} and
+\csb{xintLength} since the first release, \csb{xintApply} and
+\csb{xintListWithSep} since |1.04|, \csb{xintRevWithBraces},
+\csb{xintCSVtoList}, \csb{xintNthElt} now with |1.06|.
-%% As an example: \xintTypesetEuclideAlgorithm {2362001530033}{981106461701}
+\edef\z{\xintiPow {2}{100}}
+
+As an example the following code uses only expandable operations:
+\begin{verbatim}
+|2^{100}| (=\xintiPow {2}{100}) has \xintLen{\xintiPow {2}{100}}} digits
+and the sum of their squares is
+\xintiSum{\xintApply {\xintiSqr}{\xintiPow {2}{100}}}.
+These digits are, from the least to the most significant:
+\xintListWithSep {, }{\xintRev{\xintiPow {2}{100}}}. The thirteenth most
+significant digit is \xintNthElt{13}{\xintiPow {2}{100}}. The seventh
+least significant one is \xintNthElt{7}{\xintRev{\xintiPow {2}{100}}}.
+\end{verbatim}
+|2^{100}| (=\z) has \xintLen{\z} digits and the sum of
+their squares is \xintiSum{\xintApply\xintiSqr\z}. These digits are, from the
+least to the most significant: \xintListWithSep {, }{\xintRev\z}. The
+thirteenth most
+significant digit is \xintNthElt{13}{\z}. The seventh
+least significant one is \xintNthElt{7}{\xintRev\z}.
+
+% The
+% thirteenth most
+% significant digit is \xintNthElt{13}{\xintiPow {2}{100}}. The seventh least
+% significant one is \xintNthElt{7}{\xintRev{\xintiPow {2}{100}}}.
+
+Of course, with an earlier
+|\edef\z{\xintiPow {2}{100}}|, using |\z| in place of
+ |\xintiPow {2}{100}| everywhere would spare the CPU some repetitions.
\section{Exceptions (error messages)}
@@ -1142,8 +1250,6 @@ others are more annoying as they may pass through unsignaled.
wrong).
\item using |[]| and decimal points at the same time |1.5/3.5[2]|.
\item using |[]| with a sign in the denominator |3/-5[7]|.
-\item defining macros which do not expand in only two steps and then use them as
- arguments: |\def\x #1{\xintMON {#1}}|, |\xintAdd {\x{3}}{\x{2}}|.
\item making a mistake in a macro name |\xintProduct {{2}{3}{4}}|. Well I should
|\let| it to be |\xintPrd|... at least such errors are not dangerous because
they do provoke compilation errors.
@@ -1158,21 +1264,14 @@ others are more annoying as they may pass through unsignaled.
\section{Package namespace}
-Inner macros of \xintname, \xintgcdname, \xintfracname, \xintseriesname,
-and \xintcfracname{} all begin either with |\XINT@| or with |\xint@|. The
-package public commands all start with |\xint|. The major forms have
-their initials capitalized, and lowercase forms, prefixed with
-|\romannumeral0|, allow definitions of further macros expanding in two
-steps to their full expansion (and can thus be chained with the
-`primitive' \xintname macros). Some other control sequence names are
-used only as delimiters, and left undefined.
-
-% The |\xintReverseOrder|\marg{tokens} macro uses |\xint@UNDEF| and
-% |\xint@undef| as dummy tokens and can be used on arbitrary token
-% strings not containing these control sequence names. Anything
-% within braces is treated as one unit: one level of exterior braces
-% is removed and the contents are not reverted.
-
+Inner macros of \xintname, \xintgcdname, \xintfracname, \xintseriesname, and
+\xintcfracname{} all begin either with |\XINT@| or with |\xint@|. The package
+public commands all start with |\xint|. The major forms have their initials
+capitalized, and lowercase forms, prefixed with |\romannumeral0|, allow
+definitions of further macros expanding in only two steps to their final
+outputs. Some other control sequences are used only as delimiters, and left
+undefined, they may have been defined elsewhere, their meaning doesn't matter
+and is not touched.
\section{Loading and usage}
@@ -1264,12 +1363,19 @@ database.
\def\m{\string{M\string}}
\def\x{\string{x\string}}
-\n{} (resp. \m{} or \x) stands for a normalised number within braces as
-described in the documentation, or for a control sequence expanding in at most
-two steps to such a number (without the braces!), or for a control sequence
-within braces expanding in at most two steps to such a number, of for material
-within braces which expands to such a number after two expansions of the first
-token.
+\texttt{\n} (or also \texttt{\m}) stands for a normalised number within braces
+as described in the documentation, or for a control sequence expanding (in the
+sense previously described) to such a number (without the braces!), or for a
+control sequence within braces expanding to such a number, of for material
+within braces which expands to such a number after repeated expansions of the
+first token. A count register or \csa{numexpr} expression must thus come first
+and be prefixed by |\the| or |\number|.
+
+The letter \texttt{x} stands for something which will be inserted in-between a
+|\numexpr| and a |\relax|. It will thus be completely expanded and must give an
+integer obeying the \TeX{} bounds. Thus, it may be for example a count register,
+or itself a \csa{numexpr} expression, or just a number written explicitely with
+digits or something like |4*\count 255 + 17|, etc...
Some of these macros are extended by \xintfracname to accept fractions
on input, and, generally, to output a fraction. This will be mentioned
@@ -1284,18 +1390,18 @@ format is the same. See the \xintfracname
\hyperref[sec:comfrac]{\color{niceone}documentation} for more
information.
-The integer-only macros are more efficient, even for simple things such
-as determining the sign of a number, as there is always some overhead
-due to parsing the fraction format on input; however except if one does
-really a lot of computations, there is no need in general to employ the
-integer-only variants. The exception is when the context requires that
-the macro returns a (possibly long) integer, with no forward slash nor
-trailing |[n]|. This may be because they are used in \xintname macros
-which remain strictly integer-only on input, such as \csb{xintDecSplit},
-or\vadjust{\vskip-\dp\strutbox
- \hbox{\smash{\color{niceone}\llap{\strut\small IMPORTANT!\ $\Bigg\{$\
- }}}\vskip\dp\strutbox } in\strut{} places where a (short) number is
-expected by \TeX{} such as after an |\ifnum| or inside a |\numexpr|.
+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; however except if one does thousands
+of times the same computation with various inputs, there is no need in general
+to employ the integer-only variants. The exception is when the context requires
+that the macro returns a (possibly long) integer, with no forward slash nor
+trailing |[n]|. This may be because they are used in \xintname macros which
+remain strictly integer-only on input, such as \csb{xintDecSplit},
+or\vadjust{\vskip-\dp\strutbox \hbox{\smash{\color{niceone}\llap{\strut\small
+ IMPORTANT!\ $\Bigg\{$\ }}}\vskip\dp\strutbox } in\strut{} places where a
+(short) number is expected by \TeX{} such as after an |\ifnum| or inside a
+|\numexpr|.
@@ -1305,7 +1411,9 @@ expected by \TeX{} such as after an |\ifnum| or inside a |\numexpr|.
\csa{xintRev\n} will revert the order of the digits of the number,
keeping the optional sign. Leading zeros
resulting from the operation are not removed (see the
-\csa{xintNum} macro for this).
+\csa{xintNum} macro for this). As all other macros dealing with numbers it first
+expands its argument (in the manner described, triggered by a
+|\romannumeral-`0|).
\centeredline{|\xintRev{-123000}|\texttt{=\xintRev{-123000}}}
\centeredline{|\xintNum{\xintRev{-123000}}|\texttt{=\xintNum{\xintRev{-123000}}}}
@@ -1319,57 +1427,148 @@ material does not get reverted. Spaces are gobbled.
\centeredline{|\xintReverseOrder{\xintDigitsOf\xintiPow {2}{100}\to\Stuff}|}
\centeredline{gives: \ttfamily{\string\Stuff\string\to1002\string\xintiPow\string\xintDigitsOf}}
-\subsection{\csbh{xintNum}}\label{xintiNum}
-
-\csa{xintNum\n} removes chains of plus or minus signs, followed by zeros.
-\centeredline{|\xintNum{+---++----+--000000000367941789479}|\texttt
- {=\xintNum{+---++----+--000000000367941789479}}} Extended by \xintfracname to
-accept also a fraction on input, as long as it reduces to an integer after
-division of the numerator by the denominator.
-\centeredline{|\xintNum{123.48/-0.03}|\texttt{=\xintNum{123.48/-0.03}}}
+\subsection{\csbh{xintRevWithBraces}}\label{xintRevWithBraces}
+
+{\small New in release |1.06|.\par}
+\edef\X{\xintRevWithBraces{12345}}
+\edef\y{\xintRevWithBraces\X}
+\expandafter\def\expandafter\w\expandafter
+ {\romannumeral0\xintrevwithbraces{{\A}{\B}{\C}{\D}{\E}}}
+
+
+\csa{xintRevWithBraces}\marg{list} first does the expansion of its argument
+(which thus may be macro), then it reverses the order of the tokens, or braced
+material, it encounters, adding a pair of braces to each (thus, maintaining
+brace pairs already existing). Spaces (in-between external brace pairs) are
+gobbled. This macro is mainly thought out for use on a `list' of such braced
+material; with such a list as argument the expansion will only hit against the
+first opening brace, hence do nothing, and the braced stuff may thus be macros
+one does not want to expand. \centeredline{|\edef\x{\xintRevWithBraces{12345}}|}
+\centeredline{|\meaning\x:|\ttfamily{\meaning\X}}
+\centeredline{|\edef\y{\xintRevWithBraces\x}|}%
+\centeredline{|\meaning\y:|\ttfamily{\meaning\y}} The examples above could be
+defined with |\edef|'s because the braced material did not contain macros.
+Alternatively: \centeredline{|\expandafter\def\expandafter\w\expandafter|}%
+\centeredline{|{\romannumeral0\xintrevwithbraces{{\A}{\B}{\C}{\D}{\E}}}|}
+\centeredline{|\meaning\w:|\ttfamily{\meaning\w}} The private macro |\XINT@RWB|
+does the same job without the initial expansion of its argument.
\subsection{\csbh{xintLen}}\label{xintiLen}
-\csa{xintLen\n} returns the length of the number, not counting the
-sign.
+\csa{xintLen\n} returns the length of the number, not counting the sign.
\centeredline{|\xintLen{-12345678901234567890123456789}|\texttt
- {=\xintLen{-12345678901234567890123456789}}} Extended by
-\xintfracname to fractions: the length of |A/B[n]| is the length
-of |A| plus the length of |B| plus the absolute value of |n| and
-minus one (an integer input as |N| is internally |N/1[0]| so the
-minus one means that the extended \csa{xintLen} behaves the same
-as the original for integers). The whole thing should sum up to
-less than circa &2^{31}&.
+ {=\xintLen{-12345678901234567890123456789}}} Extended by \xintfracname to
+fractions: the length of |A/B[n]| is the length of |A| plus the length of |B|
+plus the absolute value of |n| and minus one (an integer input as |N| is
+internally |N/1[0]| so the minus one means that the extended \csa{xintLen}
+behaves the same as the original for integers). The whole thing should sum up to
+less than circa &2^{31}&.
\subsection{\csbh{xintLength}}\label{xintLength}
-\csa{xintLength}\marg{list} does not do any expansion of
-its argument and just counts how many tokens there are. Things
-enclosed in braces count as one.
-\centeredline{|\xintLength {\xintiPow {2}{100}}=|\texttt{\xintLength
- {\xintiPow{2}{100}}}}
+\csa{xintLength}\marg{list} does not do any expansion of its argument and just
+counts how many tokens there are (possibly none). Things enclosed in braces
+count as one. \centeredline{|\xintLength {\xintiPow
+ {2}{100}}=|\texttt{\xintLength {\xintiPow{2}{100}}}}
\centeredline{${}\neq{}$|\xintLen {\xintiPow {2}{100}}=|\texttt{\xintLen
{\xintiPow{2}{100}}}}
+\subsection{\csbh{xintCSVtoList}}\label{xintCSVtoList}
+
+{\small New with release |1.06|.\par}
+
+\edef\X{\xintCSVtoList {1,2,a , b ,c d,x,y }}
+\def\y {a,b,c,d,e}
+\edef\z{\xintCSVtoList \y}
+
+\makeatletter \csa{xintCSVtoList}|{a,b,c...,z}| returns |{a}{b}{c}...{z}|. The
+argument may be a macro. It is first expanded: this means that if the argument
+is |a,b,..|, then |a|, if a macro, will be expanded which may or may not be a
+good thing. Chains of contiguous spaces are collapsed by the \TeX{} scanning
+into single spaces. \centeredline{|\xintCSVtoList {1,2,a , b ,c d,x,y
+ }->|\texttt{\expandafter\strip@prefix\meaning\X}}
+\centeredline{|\def\y{a,b,c,d,e}\xintCSVtoList\y->|\texttt{\expandafter\strip@prefix\meaning\z}}
+The private macro |\XINT@CSVtoL| does the same job without the initial
+expansion. \makeatother
+
+\subsection{\csbh{xintNthElt}}\label{xintNthElt}
+
+{\small New in release |1.06|.\par}
+
+\def\macro #1{\the\numexpr 9-#1\relax}
+
+\csa{xintNthElt}|{i}{list}| gets (expandably) the |i|th element of the |list|.
+The `list' may be a macro expanding to the `list' (which is just a
+sequence of tokens; spaces are gobbled as the macro will get the required
+element as an undelimited macro parameter). The first argument |i| may be a
+\TeX{} count register (it will be given to a |\numexpr|). The seeked element is
+returned with one pair of braces removed (if initially present).
+\centeredline{|\xintNthElt
+ {37}{\xintFac {100}}=|\texttt{\xintNthElt {37}{\xintFac {100}}}} is the
+thirty-seventh digit of &100!&. \centeredline{|\xintNthElt {10}{\xintFtoCv
+ {566827/208524}}=|\texttt{\xintNthElt {10}{\xintFtoCv {566827/208524}}}} is
+the tenth convergent of &566827/208524& (uses \xintcfracname package). Error
+cases, where |i<0| or is larger than the number of elements in the list are kept
+silent; the macro then returns nothing. Perhaps this will be changed in future
+versions. \centeredline{|\xintNthElt {7}{\xintCSVtoList {1,2,3,4,5,6,7,8,9}}=|%
+ \texttt{\xintNthElt {7}{\xintCSVtoList {1,2,3,4,5,6,7,8,9}}}}
+The private macro |\XINT@NthElt| does the same job
+without first expanding its second argument.
+
+\subsection{\csbh{xintListWithSep}}\label{xintListWithSep}
+
+{\small New with release |1.04|.\par}
+
+\def\macro #1{\the\numexpr 9-#1\relax}
+
+\csa{xintListWithSep}|{sep}{list}| just inserts the given separator |sep|
+in-between all elements of the given list. One level of braces is
+removed. An empty input gives an empty output, a singleton gives a singleton,
+the separator is used starting with at least two elements. The `list' argument
+may be a macro: it is expanded.
+\centeredline{|\xintListWithSep{:}{\xintFac
+ {20}}=|\texttt{\xintListWithSep{:}{\xintFac {20}}}}
+The private macro |XINT@LWS| does the same
+job without the initial expansion.
+
+\subsection{\csbh{xintApply}}\label{xintApply}
+
+{\small New in release |1.04|.\par}
+
+\def\macro #1{\the\numexpr 9-#1\relax}
+
+\csa{xintApply}|{\macro}{list}| applies the one parameter command |\macro| to
+each item in the `list' (no separator) given as second argument. Each item is
+given in turn as parameter to |\macro| which is (fully, as usual) expanded, and
+the result is braced. On output, a new list with these braced results. The
+`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 `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}}=|\texttt{\xintApply\macro{\xintFac {20}}}} The private macro
+|XINT@Apply| does the same job without the first initial expansion providing the
+`list'.
\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.
-Important: a double expansion is applied first to the material
-extending up to \csa{to}.
+Important: a `full' expansion (as previously described) is applied first to the
+material in front of \csa{xintAssign}.
\xintAssign\xintiPow {7}{13}\to\SevenToThePowerThirteen
\xintAssign\xintDivision{1000000000000}{133333333}\to\Q\R
-As a special exception, if after this initial double expansion a
+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 material between
+defined to be the complete expansion of the entire material between
\csa{xintAssign} and \csa{to}.
\centeredline{|\xintAssign\xintDivision{1000000000000}{133333333}\to\Q\R|}
\centeredline{|\meaning\Q: |\texttt{\meaning\Q}, |\meaning\R:
@@ -1383,22 +1582,23 @@ pure expansion contexts, as assignments are made via the
\subsection{\csbh{xintAssignArray}}\label{xintAssignArray}
+{\small Changed in release |1.06|.\par}
+
\xintAssignArray\xintBezout {1000}{113}\to\Bez
-\csa{xintAssignArray}\meta{braced things}\csa{to}\csa{myArray} first
-double expands the first token then defines \csa{myArray} to be a
-macro with one parameter, such that \csa{myArray\n} expands in two
-steps (which include the twice-expansion of \texttt{\n}) to give
-the |N|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 \texttt{\Bez0},
-|\Bez{1}| to \texttt{\Bez1}, |\Bez{2}| to \texttt{\Bez2},
-|\Bez{3}| to \texttt{\Bez3}, |\Bez{4}| to \texttt{\Bez4}, and
-|\Bez{5}| to \texttt{\Bez5}:
+\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 |N|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 \texttt{\Bez0}, |\Bez{1}| to
+\texttt{\Bez1}, |\Bez{2}| to \texttt{\Bez2}, |\Bez{3}| to \texttt{\Bez3},
+|\Bez{4}| to \texttt{\Bez4}, and |\Bez{5}| to \texttt{\Bez5}:
(\Bez3)${}\times{}$\Bez1${}-{}$(\Bez4)${}\times{}$\Bez2${}={}$\Bez5.
\subsection{\csbh{xintRelaxArray}}\label{xintRelaxArray}
@@ -1418,33 +1618,14 @@ an array giving all the digits of a given number.
|\digits{123}=|\digits{123}.
\endgroup
-\subsection{\csbh{xintApply}}\label{xintApply}
-
-{\small New in release |1.04|.\par}
-
-\def\macro #1{\the\numexpr 9-#1\relax}
-
-\csa{xintApply}|{\macro}{list}| applies the one parameter command |\macro| to
-each item in the `list' (no separator) given as second argument. For each item two
-expansions are done of |\macro| and the result is braced. On output, a new list
-with these braced results. The `list' may itself be some macro expanding in two
-steps to the list of tokens to which the command |\macro| will be applied. For
-example, if the `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}}=|\texttt{\xintApply\macro{\xintFac {20}}}}
-
-\subsection{\csbh{xintListWithSep}}\label{xintListWithSep}
-
-{\small New in release |1.04|.\par}
-
-\def\macro #1{\the\numexpr 9-#1\relax}
+\subsection{\csbh{xintNum}}\label{xintiNum}
-\csa{xintListWithSep}|{sep}{list}| just inserts the given separator |sep|
-in-between all elements of the given list. One level of braces is
-removed. See the discussion of
-\csb{xintApply}. \centeredline{|\xintListWithSep{:}{\xintFac
- {20}}=|\texttt{\xintListWithSep{:}{\xintFac {20}}}}
+\csa{xintNum\n} removes chains of plus or minus signs, followed by zeros.
+\centeredline{|\xintNum{+---++----+--000000000367941789479}|\texttt
+ {=\xintNum{+---++----+--000000000367941789479}}} Extended by \xintfracname to
+accept also a fraction on input, as long as it reduces to an integer after
+division of the numerator by the denominator.
+\centeredline{|\xintNum{123.48/-0.03}|\texttt{=\xintNum{123.48/-0.03}}}
\subsection{\csbh{xintSgn}}\label{xintiSgn}
@@ -1502,8 +1683,8 @@ put on a line with positive numbers on the right): |\xintiMin
\subsection{\csbh{xintSum}}\label{xintiSum}
\csa{xintSum}\marg{braced things} after expanding its argument
-twice expects to find a sequence of tokens (or braced material).
-Each is twice-expanded, and the sum of all these numbers is
+expects to find a sequence of tokens (or braced material).
+Each is expanded (with the usual meaning), and the sum of all these numbers is
returned.
\centeredline{%
\csa{xintiSum}|{{123}{-98763450}{\xintFac{7}}{\xintiMul{3347}{591}}}=|\texttt{%
@@ -1520,14 +1701,13 @@ to fractions.
\subsection{\csbh{xintSumExpr}}\label{xintiSumExpr}
-\csa{xintSumExpr}\meta{braced things}\csa{relax} is to what
-\csa{xintSum} expands. The argument is then double-expanded and should
-give a list of braced quantities or macros, each one will be double
-expanded in turn. \centeredline{%
+\csa{xintSumExpr}\meta{braced things}\csa{relax} is to what \csa{xintSum}
+expands. The argument is then expanded (with the usual meaning) and should give a
+list of braced quantities or macros, each one will be expanded in turn.
+\centeredline{%
\csa{xintiSumExpr}| {123}{-98763450}|%
|{\xintFac{7}}{\xintiMul{3347}{591}}\relax=|\texttt{%
- \xintiSumExpr
- {123}{-98763450}{\xintFac{7}}{\xintiMul{3347}{591}}\relax}}
+ \xintiSumExpr {123}{-98763450}{\xintFac{7}}{\xintiMul{3347}{591}}\relax}}
Note: I am not so happy with the name which seems to suggest that the
|+| sign should be used instead of braces. Perhaps this will change
@@ -1553,8 +1733,8 @@ Extended by \xintfracname to fractions.
\subsection{\csbh{xintPrd}}\label{xintiPrd}
\csa{xintPrd}\marg{braced things} after expanding its argument
-twice expects to find a sequence of tokens (or braced material).
-Each is twice-expanded, and the product of all these numbers is
+expects to find a sequence of tokens (or braced material).
+Each is expanded (with the usual meaning), and the product of all these numbers is
returned. \centeredline{%
\csa{xintiPrd}|{{-9876}{\xintFac{7}}{\xintiMul{3347}{591}}}=|%
\texttt{%
@@ -1581,12 +1761,11 @@ Extended by \xintfracname to fractions.
\subsection{\csbh{xintProductExpr}}\label{xintiProductExpr}
-\csa{xintProductExpr}\marg{argument}\csa{relax} is to what
-\csa{xintPrd} expands ; its argument is then twice expanded and should
-give a list of braced numbers or macros. Each will be twice expanded
-when it is its turn.
+\csa{xintProductExpr}\marg{argument}\csa{relax} is to what \csa{xintPrd} expands
+; its argument is expanded (with the usual meaning) and should give a list of
+braced numbers or macros. Each will be expanded when it is its turn.
\centeredline{\csa{xintiProductExpr}| 123456789123456789\relax=|\texttt{%
- \xintiProductExpr 123456789123456789\relax}}
+ \xintiProductExpr 123456789123456789\relax}}
Note: I am not so happy with the name which seems to suggest that the
|*| sign should be used instead of braces. Perhaps this will change
@@ -1596,10 +1775,13 @@ Extended by \xintfracname to fractions.
\subsection{\csbh{xintFac}}\label{xintFac}
-\csa{xintFac\n} returns the factorial. It is an error if the
+\csa{xintFac\x} returns the factorial. It is an error if the
argument is negative or at least &10^6&. It is not recommended to
launch the computation of things such as &100000!&, if you need
-your computer for other tasks.
+your computer for other tasks. Note that the argument is of the |x| type, it
+must obey the \TeX{} bounds, but on the other hand may involve count registers
+and even arithmetic operations as it will be completely expanded inside a
+|\numexpr|.
% temps obsolètes, mettre à jour
% On my laptop &1000!& (2568 digits)
@@ -1614,9 +1796,9 @@ your computer for other tasks.
\subsection{\csbh{xintPow}}\label{xintiPow}
-\csa{xintPow\n\m} returns |N^M|. When |M| is zero, this is 1. Some
-cases (|N| zero and |M| negative, \verb+|N|>1+ and |M| negative,
-\verb+|N|>1+ and |M| at least &10^9&) make \xintname throw errors.
+\csa{xintPow\n\x} returns |N^x|. When |x| is zero, this is 1. Some
+cases (|N| zero and |x| negative, \verb+|N|>1+ and |x| negative,
+\verb+|N|>1+ and |x| at least &10^9&) make \xintname throw errors.
Extended by \xintfracname to fractions. Of course, negative
exponents do not then cause errors anymore.
@@ -1832,7 +2014,7 @@ returns zero.
\xintAssign {\xintBezout {10000}{1113}}\to\A\B\U\V\D
\csa{xintBezout\n\m} returns five numbers |A|, |B|, |U|, |V|, |D| within
-braces. |A| is the first (twice-expanded) input number, |B| the
+braces. |A| is the first (expanded, as usual) input number, |B| the
second, |D| is the GCD, and \texttt{UA - VB = D}.
\centeredline{|\xintAssign {{\xintBezout {10000}{1113}}}\to\X|}
\centeredline{|\meaning\X: |\texttt{\meaning\X }.}
@@ -1909,7 +2091,7 @@ entry, and then these four things at each step until the end.
\catcode`\& 13
-\subsection{\csbh{xintTypesetEuclideAlgorithm}\hskip1cm\hspace*{0cm}}\label{xintTypesetEuclideAlgorithm}
+\subsection{\csbh{xintTypesetEuclideAlgorithm}}\label{xintTypesetEuclideAlgorithm}
This macro is just an example of how to organize the data returned
by \csa{xintEuclideAlgorithm}. Copy the source code to a new macro
@@ -1929,9 +2111,18 @@ and modify it to what is needed.
\section{Commands of the \xintfracname package}\label{sec:comfrac}
-The general rule of the bundle that each macro first double-expands each one of
-its arguments applies. This package was first included in release |1.03| of the
-\xintname bundle.
+\def\x{\string{x\string}}
+
+This package was first included in release |1.03| of the \xintname bundle. The
+general rule of the bundle that each macro first expands (what comes first,
+fully) each one of its arguments applies. As in the previous documentation, |x|
+stands for something which will be internally embedded in a \csa{numexpr}, thus
+completely expanded and then must deliver a number obeying the TeX{} bounds. It
+may be a count register or something like |4*\count 255 + 17|, etc...
+
+|f| stands for a fraction (or a possibly `long' integer), or something which
+expands to a fraction or a possibly long integer. See the earlier section on
+fraction formats.
\subsection{\csbh{xintLen}}\label{xintLen}
@@ -2069,31 +2260,31 @@ example.
\subsection{\csbh{xintTrunc}}\label{xintTrunc}
-\csa{xintTrunc}|{N}{f}| returns the start of the decimal expansion of the
-fraction |f|, with |N| digits after the decimal point. The argument |N| should
-be non-negative. When |N=0|, the integer part of |f| results, with an ending
-decimal point. Only when |f| evaluates to zero does \csa{xintTrunc} not print
-a decimal point. When |f| is not zero, the sign is maintained in the output,
-also when the digits are all zero. \centeredline{|\xintTrunc
- {16}{-803.2028/20905.298}=|\texttt{\xintTrunc {16}{-803.2028/20905.298}}}%
- \centeredline{|\xintTrunc
- {20}{-803.2028/20905.298}=|\texttt{\xintTrunc {20}{-803.2028/20905.298}}}%
- \centeredline{|\xintTrunc
- {10}{\xintPow {-11}{-11}}=|\texttt{\xintTrunc
- {10}{\xintPow {-11}{-11}}}}%
- \centeredline{|\xintTrunc
- {12}{\xintPow {-11}{-11}}=|\texttt{\xintTrunc
- {12}{\xintPow {-11}{-11}}}}%
-\centeredline{|\xintTrunc {12}{\xintAdd {-1/3}{3/9}}=|\texttt{\xintTrunc {12}{\xintAdd {-1/3}{3/9}}}} The
-digits printed are exact up to and including the last one. The identity
-|\xintTrunc {N}{-f}=-\xintTrunc {N}{f}| holds.\footnote{this is just a notation;
- currently |-\string\x| is not valid input to any package macro, one must use
- |\string\xintOpp\string{\string\x\string}| or |\string\xintiOpp\string{\string\x\string}|.}
+\csa{xintTrunc}|{x}{f}| returns the start of the decimal expansion of the
+fraction |f|, with |x| digits after the decimal point. The argument |x| should
+be non-negative. When |x=0|, the integer part of |f| results, with an ending
+decimal point. Only when |f| evaluates to zero does \csa{xintTrunc} not print a
+decimal point. When |f| is not zero, the sign is maintained in the output, also
+when the digits are all zero. \centeredline{|\xintTrunc
+ {16}{-803.2028/20905.298}=|\texttt{\xintTrunc {16}{-803.2028/20905.298}}}%
+\centeredline{|\xintTrunc {20}{-803.2028/20905.298}=|\texttt{\xintTrunc
+ {20}{-803.2028/20905.298}}}%
+\centeredline{|\xintTrunc {10}{\xintPow {-11}{-11}}=|\texttt{\xintTrunc
+ {10}{\xintPow {-11}{-11}}}}%
+\centeredline{|\xintTrunc {12}{\xintPow {-11}{-11}}=|\texttt{\xintTrunc
+ {12}{\xintPow {-11}{-11}}}}%
+\centeredline{|\xintTrunc {12}{\xintAdd {-1/3}{3/9}}=|\texttt{\xintTrunc
+ {12}{\xintAdd {-1/3}{3/9}}}} The digits printed are exact up to and
+including the last one. The identity |\xintTrunc {x}{-f}=-\xintTrunc {x}{f}|
+holds.\footnote{this is just a notation; currently |-\string\macro| is not valid
+ input to any package macro, one must use
+ |\string\xintOpp\string{\string\macro\string}| or
+ |\string\xintiOpp\string{\string\macro\string}|.}
\subsection{\csbh{xintiTrunc}}\label{xintiTrunc}
-\csa{xintiTrunc}|{N}{f}| returns the integer equal to |10^N| times what
-\csa{xintTrunc}|{N}{f}| would return. \centeredline{|\xintiTrunc
+\csa{xintiTrunc}|{x}{f}| returns the integer equal to |10^x| times what
+\csa{xintTrunc}|{x}{f}| would return. \centeredline{|\xintiTrunc
{16}{-803.2028/20905.298}=|\texttt{\xintiTrunc {16}{-803.2028/20905.298}}}%
\centeredline{|\xintiTrunc
{10}{\xintPow {-11}{-11}}=|\texttt{\xintiTrunc
@@ -2110,9 +2301,9 @@ all superfluous leading zeros.)
{\small New with release |1.04|.\par}
-\csa{xintRound}|{N}{f}| returns the start of the decimal expansion of the
-fraction |f|, rounded to |N| digits precision after the decimal point. The
-argument |N| should be non-negative. Only when |f| evaluates exactly to zero
+\csa{xintRound}|{x}{f}| returns the start of the decimal expansion of the
+fraction |f|, rounded to |x| digits precision after the decimal point. The
+argument |x| should be non-negative. Only when |f| evaluates exactly to zero
does \csa{xintRound} return |0| without decimal point. When |f| is not zero, its
sign is given in the output, also when the digits printed are all zero.
\centeredline{|\xintRound {16}{-803.2028/20905.298}=|\texttt{\xintRound
@@ -2127,7 +2318,7 @@ sign is given in the output, also when the digits printed are all zero.
{12}{\xintPow {-11}{-11}}}}%
\centeredline{|\xintRound {12}{\xintAdd {-1/3}{3/9}}=|\texttt{\xintRound
{12}{\xintAdd {-1/3}{3/9}}}}
-The identity |\xintRound {N}{-f}=-\xintRound {N}{f}| holds. And regarding
+The identity |\xintRound {x}{-f}=-\xintRound {x}{f}| holds. And regarding
$(-11)^{-11}$ here is some more or its expansion:
\centeredline{\xintTrunc {50}{\xintPow {-11}{-11}}\dots}
@@ -2135,8 +2326,8 @@ $(-11)^{-11}$ here is some more or its expansion:
{\small New with release |1.04|.\par}
-\csa{xintiRound}|{N}{f}| returns the integer equal to |10^N| times what
-\csa{xintRound}|{N}{f}| would return. \centeredline{|\xintiRound
+\csa{xintiRound}|{x}{f}| returns the integer equal to |10^x| times what
+\csa{xintRound}|{x}{f}| would return. \centeredline{|\xintiRound
{16}{-803.2028/20905.298}=|\texttt{\xintiRound {16}{-803.2028/20905.298}}}%
\centeredline{|\xintiRound {10}{\xintPow {-11}{-11}}=|\texttt{\xintiRound
{10}{\xintPow {-11}{-11}}}}%
@@ -2230,7 +2421,7 @@ available as \csb{xintiSgn}.
The macro is extended to fractions. The original is available as
\csb{xintiOpp}. Note that |\xintOpp {3}| now outputs \texttt{\xintOpp {3}}.
-\subsection{\csbh{xintGeq},~\csbh{xintDivision},~\csbh{xint\-Quo},~\csbh{xint\-Rem},~\csbh{xintFDg},~\csbh{xintLDg},~\csbh{xintMON},~\csbh{xintMMON}}
+\subsection{\csbh{xintGeq}, \csbh{xintDivision}, \csbh{xint\-Quo}, \csbh{xint\-Rem}, \csbh{xintFDg}, \csbh{xintLDg}, \csbh{xintMON}, \csbh{xintMMON}}
These macros are extended to accept a fraction on input if this fraction
in fact reduces to an integer (if not an |\xintError:NotAnInteger| will
@@ -2249,26 +2440,30 @@ as \csb{xintiNum}.
\section{Commands of the \xintseriesname package}\label{sec:series}
-There will be some exceptions to the general rule that
-each macro first double-expands each one of its arguments. This package was
+Some arguments to the package commands are macros which are expanded only later,
+when given their parameters. The arguments serving as indices
+({\color{niceone}new with |1.06|}) are systematically given to a |\numexpr|
+expressions, hence fully expanded, they may be count registers, etc...
+
+This package was
first released with version |1.03| of the \xintname bundle.
\subsection{\csbh{xintSeries}}\label{xintSeries}
-\def\coeff #1{\romannumeral0\xintimon{#1}/#1.5} % (-1)^n/(n+1/2)
+\def\coeff #1{\xintiMON{#1}/#1.5} % (-1)^n/(n+1/2)
\edef\w {\xintSeries {0}{50}{\coeff}}
\edef\z {\xintJrr {\w}[0]}
\csa{xintSeries}|{A}{B}{\coeff}| evaluates the sum of all values of the |\coeff
-{n}| from |n=A| to and including |n=B|. The initial and final indices must
-(after double-expansion) obey the \TeX{} and |\numexpr| constraint of being
-explicit numbers at most |2^31-1| (these conditions are not checked by
-the macro). The |\coeff| macro (which, as argument to \csa{xintSeries} is
-double-expanded only at the time of computing the successive |\coeff {n}|)
-should be defined as a one-parameter command, accepting on input a number (not a
-count register) and needing at most two expansions to compute its final result.
+{n}| from |n=A| to and including |n=B|. The initial and final indices must obey
+the |\numexpr| constraint of expanding to numbers at most |2^31-1|. The |\coeff|
+macro (which, as argument to \csa{xintSeries} is expanded only at the
+time of computing the successive |\coeff {n}|) should be defined as a
+one-parameter fully expandable command, providing its output from an input being
+an explicit number (string of digits, no need to make proviso for a count
+register).
\begin{verbatim}
-\def\coeff #1{\romannumeral0\xintimon{#1}/#1.5} % (-1)^n/(n+1/2)
+\def\coeff #1{\xintiMON{#1}/#1.5} % (-1)^n/(n+1/2)
\edef\w {\xintSeries {0}{50}{\coeff}} % we want to re-use it
\edef\z {\xintJrr {\w}[0]} % the [0] for a microsecond gain.
% \xintJrr preferred to \xintIrr: a big common factor is suspected.
@@ -2346,7 +2541,7 @@ digits) in the denominator. See the explanations in the next section.
% we can afford that, as \xintSeries is fast enough.
\noindent\hbox to 2em{\hfil\texttt{\the\cnta.} }%
\xintTrunc {12}
- {\xintSeries {1}{\the\cnta}{\coeffleibnitz}}\dots
+ {\xintSeries {1}{\cnta}{\coeffleibnitz}}\dots
\endgraf
\ifnum\cnta < 30 \advance\cnta 1 \repeat
\end{verbatim}
@@ -2354,33 +2549,31 @@ digits) in the denominator. See the explanations in the next section.
\def\coeffleibnitz #1{\the\numexpr\ifodd #1 1\else-1\fi\relax/#1[0]} \cnta 1
\loop
\noindent\hbox to 2em{\hfil\texttt{\the\cnta.} }%
- \xintTrunc {12}{\xintSeries {1}{\the\cnta}{\coeffleibnitz}}\dots
+ \xintTrunc {12}{\xintSeries {1}{\cnta}{\coeffleibnitz}}\dots
\endgraf
\ifnum\cnta < 30 \advance\cnta 1 \repeat
\end{multicols}
\subsection{\csbh{xintiSeries}}\label{xintiSeries}
-\def\coeff #1{\romannumeral0\xintitrunc {40}
+\def\coeff #1{\xintiTrunc {40}
{\the\numexpr\ifodd #1 -2\else2\fi\relax/\the\numexpr 2*#1+1\relax [0]}}%
\csa{xintiSeries}|{A}{B}{\coeff}| evaluates the sum of |\coeff
-{n}| from |n=A| to and including |n=B|. The initial and final indices must
-(after double-expansion) be explicit numbers at most |2^31-1| (these conditions
-are not checked by the macro). The
-|\coeff| macro (which, as argument to \csa{xintiSeries} is double-expanded only
+{n}| from |n=A| to and including |n=B|. The initial and final indices are given
+to a |\numexpr| expression. The
+|\coeff| macro (which, as argument to \csa{xintiSeries} is expanded only
at the time of computing |\coeff {n}|) should be defined as a
-one-parameter command, accepting on input a number (not a count register) and
-needing at most two expansions to compute its final result, \emph{which must be
- an integer}, in the format understood by the integer-only
+one-parameter fully expandable command, accepting on input an explicit number,
+and returning a (long) integer in the format understood by the integer-only
\csa{xintiAdd}.
\begin{verbatim}
-\def\coeff #1{\romannumeral0\xintitrunc {40}{\xintMON{#1}/#1.5}}%
+\def\coeff #1{\xintiTrunc {40}{\xintMON{#1}/#1.5}}%
% better:
-\def\coeff #1{\romannumeral0\xintitrunc {40}
+\def\coeff #1{\xintiTrunc {40}
{\the\numexpr 2*\xintiMON{#1}\relax/\the\numexpr 2*#1+1\relax [0]}}%
% better still:
-\def\coeff #1{\romannumeral0\xintitrunc {40}
+\def\coeff #1{\xintiTrunc {40}
{\the\numexpr\ifodd #1 -2\else2\fi\relax/\the\numexpr 2*#1+1\relax [0]}}%
% (-1)^n/(n+1/2) times 10^40, truncated to an integer.
\[ \sum_{n=0}^{n=50} \frac{(-1)^n}{n+\frac12} \approx
@@ -2390,7 +2583,8 @@ The |#1.5| trick to define the |\coeff| macro was neat, but |1/3.5|, for
example, turns internally into |10/35| whereas it would be more efficient to
have |2/7|. The second way of coding the wanted coefficient avoids a superfluous
factor of five and leads to a faster evaluation. The third way is faster, after
-all there is no need to use \csb{xintMON} (or rather \csb{xintiMON}) on integers
+all there is no need to use \csb{xintMON} (or rather \csb{xintiMON} which has
+less parsing overhead) on integers
obeying the \TeX{} bound. The denominator having no sign, we have added the
|[0]| as this speeds up (infinitesimally) the parsing.
\[ \sum_{n=0}^{n=50} \frac{(-1)^n}{n+\frac12} \approx \xintTrunc
@@ -2403,7 +2597,7 @@ interesting to compare with the computation where rounding rather than
truncation is used, and with the decimal
expansion of the exactly computed partial sum of the series:
\begin{verbatim}
-\def\coeff #1{\romannumeral0\xintiround {40} % rounding at 40
+\def\coeff #1{\xintiRound {40} % rounding at 40
{\the\numexpr\ifodd #1 -2\else2\fi\relax/\the\numexpr 2*#1+1\relax [0]}}%
% (-1)^n/(n+1/2) times 10^40, rounded to an integer.
\[ \sum_{n=0}^{n=50} \frac{(-1)^n}{n+\frac12} \approx
@@ -2413,7 +2607,7 @@ expansion of the exactly computed partial sum of the series:
\[ \sum_{n=0}^{n=50} \frac{(-1)^n}{n+\frac12}
= \xintTrunc {50}{\xintSeries {0}{50}{\exactcoeff}}\dots\]
\end{verbatim}
-\def\coeff #1{\romannumeral0\xintiround {40}
+\def\coeff #1{\xintiRound {40}
{\the\numexpr\ifodd #1 -2\else2\fi\relax/\the\numexpr 2*#1+1\relax [0]}}%
% (-1)^n/(n+1/2) times 10^40, rounded to an integer.
\[ \sum_{n=0}^{n=50} \frac{(-1)^n}{n+\frac12} \approx
@@ -2437,17 +2631,15 @@ estimated wrongly the 39th and 40th digits of the exact result\footnote{as
|F(n)|\footnote{the macro is designed to be useful when |F(n)/F(n-1)| is a
rational function of |n| but it may be used of course with any sort of general
term.} from |n=A| up to and including |n=B|, with the parameter |f| being (or
-expanding in two steps to) the value |F(A)| and |\ratio| being a one-parameter
-command, accepting on input a number |n| (not a count register, but also obeying
-the constraint of having value at most |2^31-1|) and producing after at most two
-expansions |F(n)/F(n-1)|. The initial and final indices must (after
-double-expansion) obey the \TeX{} and |\numexpr| constraint of being explicit
-numbers at most |2^31-1| (these conditions are not checked by the macro).
+expanding to) the value |F(A)| and |\ratio| being a one-parameter expandable
+command, accepting on input an explicit number |n| and producing after (full
+iterated) expansion (of the first token) |F(n)/F(n-1)|. The initial and final
+indices are given to a |\numexpr| expression.
\begin{verbatim}
\def\ratio #1{2/#1[0]}% 2/n, comes from the series of exp(2)
\cnta 0 % previously declared count
\loop
-\edef\z {\xintRationalSeries {0}{\the\cnta}{1}{\ratio }}%
+\edef\z {\xintRationalSeries {0}{\cnta}{1}{\ratio }}%
\noindent$\sum_{n=0}^{\the\cnta} \frac{2^n}{n!}=
\xintTrunc{12}\z\dots=
\xintFrac\z=\xintFrac{\xintIrr\z}$\vtop to 5pt{}\endgraf
@@ -2456,7 +2648,7 @@ numbers at most |2^31-1| (these conditions are not checked by the macro).
\def\ratio #1{2/#1[0]}% 2/n, comes from the series of exp(2)
\cnta 0
\loop
-\edef\z {\xintRationalSeries {0}{\the\cnta}{1}{\ratio }}%
+\edef\z {\xintRationalSeries {0}{\cnta}{1}{\ratio }}%
\noindent$\sum_{n=0}^{\the\cnta} \frac{2^n}{n!}=
\xintTrunc{12}\z\dots=
\xintFrac\z=\xintFrac{\xintIrr\z}$\vtop to 5pt{}\endgraf
@@ -2473,7 +2665,7 @@ evaluate the partial sums via a less silly iterative scheme.
\def\ratio #1{-1/#1[0]}% -1/n, comes from the series of exp(-1)
\cnta 0 % previously declared count
\loop
-\edef\z {\xintRationalSeries {0}{\the\cnta}{1}{\ratio }}%
+\edef\z {\xintRationalSeries {0}{\cnta}{1}{\ratio }}%
\noindent$\sum_{n=0}^{\the\cnta} \frac{(-1)^n}{n!}=
\xintTrunc{20}\z\dots=\xintFrac{\z}=\xintFrac{\xintIrr\z}$
\vtop to 5pt{}\endgraf
@@ -2483,29 +2675,29 @@ evaluate the partial sums via a less silly iterative scheme.
\cnta 0 % previously declared count
\loop
-\edef\z {\xintRationalSeries {0}{\the\cnta}{1}{\ratio }}%
+\edef\z {\xintRationalSeries {0}{\cnta}{1}{\ratio }}%
\noindent$\sum_{n=0}^{\the\cnta} \frac{(-1)^n}{n!}=
\xintTrunc{20}\z\dots=\xintFrac{\z}=\xintFrac{\xintIrr\z}$
\vtop to 5pt{}\endgraf
\ifnum\cnta<20 \advance\cnta 1 \repeat
- \def\ratioexp #1#2{\romannumeral0\xintdiv{#1}{#2}}% #1/#2
+ \def\ratioexp #1#2{\xintDiv{#1}{#2}}% #1/#2
\medskip We can incorporate an indeterminate if we define |\ratio| to be
a macro with two parameters: |\def\ratioexp
- #1#2{\romannumeral0\xintdiv{#1}{#2}}|\texttt{\%}| x/n: x=#1, n=#2|.
-Then, if |\x| expands (in two steps at most) to some fraction |x|, the
+ #1#2{\xintDiv{#1}{#2}}|\texttt{\%}| x/n: x=#1, n=#2|.
+Then, if |\x| expands to some fraction |x|, the
command \centeredline{|\xintRationalSeries {0}{b}{1}{\ratioexp{\x}}|}
will compute $\sum_{n=0}^{n=b} x^n/n!$:\par
\vspace*{-.5\baselineskip}
\begin{verbatim}
\cnta 0
-\def\ratioexp #1#2{\romannumeral0\xintdiv{#1}{#2}}% #1/#2
+\def\ratioexp #1#2{\xintDiv{#1}{#2}}% #1/#2
\loop
\noindent
$\sum_{n=0}^{\the\cnta} (.57)^n/n! = \xintTrunc {50}
- {\xintRationalSeries {0}{\the\cnta}{1}{\ratioexp{.57}}}\dots$
+ {\xintRationalSeries {0}{\cnta}{1}{\ratioexp{.57}}}\dots$
\vtop to 5pt {}\endgraf
\ifnum\cnta<50 \advance\cnta 10 \repeat
\end{verbatim}
@@ -2514,7 +2706,7 @@ $\sum_{n=0}^{\the\cnta} (.57)^n/n! = \xintTrunc {50}
\loop
\noindent
$\sum_{n=0}^{\the\cnta} (.57)^n/n! = \xintTrunc {50}
- {\xintRationalSeries {0}{\the\cnta}{1}{\ratioexp{.57}}}\dots$
+ {\xintRationalSeries {0}{\cnta}{1}{\ratioexp{.57}}}\dots$
\vtop to 5pt {}\endgraf
\ifnum\cnta<50 \advance\cnta 10 \repeat
Observe that in this last example the |x| was directly inserted; if it
@@ -2534,12 +2726,11 @@ Here is a slightly more complicated evaluation:
\begin{verbatim}
\cnta 1
\loop \edef\z {\xintRationalSeries
- {\the\cnta}
- {\the\numexpr 2*\cnta-1\relax}
- {\xintiPow {\the\cnta}{\the\cnta}/\xintFac{\the\cnta}}
+ {\cnta}
+ {2*\cnta-1}
+ {\xintiPow {\the\cnta}{\cnta}/\xintFac{\cnta}}
{\ratioexp{\the\cnta}}}%
-\edef\w {\xintRationalSeries {0}{\the\numexpr 2*\cnta-1\relax}{1}
- {\ratioexp{\the\cnta}}}%
+\edef\w {\xintRationalSeries {0}{2*\cnta-1}{1}{\ratioexp{\the\cnta}}}%
\noindent
$\sum_{n=\the\cnta}^{\the\numexpr 2*\cnta-1\relax} \frac{\the\cnta^n}{n!}/%
\sum_{n=0}^{\the\numexpr 2*\cnta-1\relax} \frac{\the\cnta^n}{n!} =
@@ -2549,12 +2740,11 @@ $\sum_{n=\the\cnta}^{\the\numexpr 2*\cnta-1\relax} \frac{\the\cnta^n}{n!}/%
\cnta 1
\begin{multicols}{2}
\loop \edef\z {\xintRationalSeries
- {\the\cnta}
- {\the\numexpr 2*\cnta-1\relax}
- {\xintiPow {\the\cnta}{\the\cnta}/\xintFac{\the\cnta}}
+ {\cnta}
+ {2*\cnta-1}
+ {\xintiPow {\the\cnta}{\cnta}/\xintFac{\cnta}}
{\ratioexp{\the\cnta}}}%
-\edef\w {\xintRationalSeries {0}{\the\numexpr 2*\cnta-1\relax}{1}
- {\ratioexp{\the\cnta}}}%
+\edef\w {\xintRationalSeries {0}{2*\cnta-1}{1}{\ratioexp{\the\cnta}}}%
\noindent$\sum_{n=\the\cnta}^{\the\numexpr 2*\cnta-1\relax} \frac{\the\cnta^n}{n!}/%
\sum_{n=0}^{\the\numexpr 2*\cnta-1\relax} \frac{\the\cnta^n}{n!} =
\xintTrunc{8}{\xintDiv\z\w}\dots$ \vtop to 5pt{}\endgraf
@@ -2566,15 +2756,14 @@ $\sum_{n=\the\cnta}^{\the\numexpr 2*\cnta-1\relax} \frac{\the\cnta^n}{n!}/%
{\small New with release |1.04|.\par}
\csa{xintRationalSeriesX}|{A}{B}{\first}{\ratio}{\x}| evaluates the sum of
-|F(n,x)| from |n=A| up to and including |n=B|, where |\x| expands in two
-steps at most to a fraction |x|, |\first| is a one-parameter macro such that
-|\first{\x}| expands in two steps at most to the first term |F(A,x)| of the
-series, and |\ratio| is a two parameter macro such that |\ratio{\x}{n}|
-expands in two steps at most to the ratio |F(n,x)/F(n-1,x)|. Thus, this
-is a parametrized version of \csa{xintRationalSeries}, where the
-parameter |\x| is evaluated only once at the beginning of the
-computation, and can thus itself be the yet unevaluated result of a
-previous computation.
+|F(n,x)| from |n=A| up to and including |n=B|, where |\x| expands to a fraction
+|x|, |\first| is a one-parameter macro such that |\first{\x}| expands in two
+steps at most to the first term |F(A,x)| of the series, and |\ratio| is a two
+parameter macro such that |\ratio{\x}{n}| expands to the
+ratio |F(n,x)/F(n-1,x)|. Hence, this is a parametrized version of
+\csa{xintRationalSeries}, where the parameter |\x| is evaluated only once at the
+beginning of the computation, and can thus itself be the yet unevaluated result
+of a previous computation.
Note the subtle differences between
\centeredline{|\xintRationalSeries {a}{b}{\first}{\ratio{\x}}|}%
@@ -2596,7 +2785,7 @@ next section.
\def\firstterm #1{1[0]}% first term of the exponential series
% although it is the constant 1, here it must be defined as a
% one-parameter macro. Next comes the ratio function for exp:
-\def\ratioexp #1#2{\romannumeral0\xintdiv {#1}{#2}}% x/n
+\def\ratioexp #1#2{\xintDiv {#1}{#2}}% x/n
% These are the (-1)^{n-1}/n of the log(1+h) series:
\def\coefflog #1{\the\numexpr\ifodd #1 1\else-1\fi\relax/#1[0]}%
% Let L(h) be the first 10 terms of the log(1+h) series and
@@ -2614,7 +2803,7 @@ next section.
\def\firstterm #1{1[0]}% first term of the exponential series
% although it is the constant 1, here it must be defined as a
% one-parameter macro. Next comes the ratio function for exp:
-\def\ratioexp #1#2{\romannumeral0\xintdiv {#1}{#2}}% x/n
+\def\ratioexp #1#2{\xintDiv {#1}{#2}}% x/n
% These are the (-1)^{n-1}/n of the log(1+h) series
\def\coefflog #1{\the\numexpr\ifodd #1 1\else-1\fi\relax/#1[0]}%
% Let L(h) be the first 10 terms of the log(1+h) series and
@@ -2725,20 +2914,17 @@ are available via the commands \csb{xintTrunc} and \csb{xintRound}.
\csa{xintPowerSeries}|{A}{B}{\coeff}{x}| evaluates the sum of
|\coeff{n}|\raisebox{.5ex}{|.|}|x^n| from |n=A| up to and including |n=B|. The
-initial and final indices must (after double-expansion) be
-explicit numbers at most |2^31-1| (these
-conditions are not checked by the macro). The |\coeff| macro (which, as argument
-to \csa{xintPowerSeries} is double-expanded only at the time
-|\coeff{n}| is needed) should be defined as a one-parameter command, accepting
-on input a number (not a count register) and needing at most two expansions to
-compute its final result.
-
-The |x| can be either a fraction directly input or a macro expanding in
-at most two steps to such a fraction. It is actually more efficient to
-encapsulate an explicit fraction |x| in such a macro (say |\x|), if it
-has big numerators and denominators (`big' means hundreds of
-digits) as it will then take less space in the processing until being
-(repeatedly) used.
+initial and final indices are given to a |\numexpr| expression. The |\coeff|
+macro (which, as argument to \csa{xintPowerSeries} is expanded only at the time
+|\coeff{n}| is needed) should be defined as a one-parameter expandable (in the
+now usual meaning) command,
+accepting on input an explicit number.
+
+The |x| can be either a fraction directly input or a macro expanding to such a
+fraction. It is actually more efficient to encapsulate an explicit fraction |x|
+in such a macro (say |\x|), if it has big numerators and denominators (`big'
+means hundreds of digits) as it will then take less space in the processing
+until being (repeatedly) used.
This macro computes the \emph{exact} result (one can use it also for
polynomial evaluation). With release |1.04| the Horner scheme for
@@ -2795,7 +2981,7 @@ was plaguing the |1.03| version. \footnote{with powers |x\string^k|,
% we can afford that, as \xintPowerSeries is fast enough.
\noindent\hbox to 2em{\hfil\texttt{\the\cnta.} }%
\xintTrunc {12}
- {\xintPowerSeries {1}{\the\cnta}{\coefflog}{\x}}\dots
+ {\xintPowerSeries {1}{\cnta}{\coefflog}{\x}}\dots
\endgraf
\ifnum \cnta < 30 \advance\cnta 1 \repeat
\end{verbatim}
@@ -2805,7 +2991,7 @@ was plaguing the |1.03| version. \footnote{with powers |x\string^k|,
\loop % in this loop we recompute from scratch each partial sum!
% we can afford that, as \xintPowerSeries is fast enough.
\noindent\hbox to 2em{\hfil\texttt{\the\cnta.} }%
- \xintTrunc {12}{\xintPowerSeries {1}{\the\cnta}{\coefflog}{\x}}\dots
+ \xintTrunc {12}{\xintPowerSeries {1}{\cnta}{\coefflog}{\x}}\dots
\endgraf
\ifnum \cnta < 30 \advance\cnta 1 \repeat
\end{multicols}
@@ -2835,24 +3021,23 @@ was plaguing the |1.03| version. \footnote{with powers |x\string^k|,
{\small New with release |1.04|.\par}
This is the same as \csb{xintPowerSeries} apart from the fact that the last
-parameter (aka |x|), is first twice expanded. If the |x| parameter is to be an
-explicit big fraction |f| with many (dozens) digits, rather than using
-|f| directly it is slightly better to have some macro |\x| |\def'|ined to expand
-to the explicit |f| and use \csb{xintPowerSeries}; but if |f| has not yet been
-evaluated and will be the output of a complicated expansion of some |\x|, and
-if, due to an expanding only context, an |\edef\z{\x}| is no option, then
-\csa{xintPowerSeriesX} should be used with |\x| as last parameter. This |\x|
-will be expanded (as usual, twice) and then its (explicit) output will be used.
-The reason why \csa{xintPowerSeries} doesn't do the same is that explicit
-fractions with many (dozens) digits slow down a bit the processing as
-there is some shuffling of tokens going on. With \csa{xintPowerSeriesX} the
-slowing down in token shuffling due to a very big fraction will not be avoided,
-but the far worse cost of re-doing each time the computations leading to
-such a fraction will be. The constraints of expandability make it impossible
-to encapsulate the result of this initial computation in a macro and have the
-best of both worlds.
+parameter (aka |x|), is first expanded before being then used. If the |x|
+parameter is to be an explicit big fraction |f| with many (dozens) digits,
+rather than using |f| directly it is slightly better to have some macro |\x|
+|\def'|ined to expand to the explicit |f| and use \csb{xintPowerSeries}; but if
+|f| has not yet been evaluated and will be the output of a complicated expansion
+of some |\x|, and if, due to an expanding only context, an |\edef\z{\x}| is no
+option, then \csa{xintPowerSeriesX} should be used with |\x| as last parameter.
+This |\x| will be expanded (as usual) and then its (explicit) output will be
+used. The reason why \csa{xintPowerSeries} doesn't do the same is that explicit
+fractions with many (dozens) digits slow down a bit the processing as there is
+some shuffling of tokens going on. With \csa{xintPowerSeriesX} the slowing down
+in token shuffling due to a very big fraction will not be avoided, but the far
+worse cost of re-doing each time the computations leading to such a fraction
+will be. The constraints of expandability make it impossible to encapsulate the
+result of this initial computation in a macro and have the best of both worlds.
\begin{verbatim}
-\def\ratioexp #1#2{\romannumeral0\xintdiv {#1}{#2}}% x/n
+\def\ratioexp #1#2{\xintDiv {#1}{#2}}% x/n
% These are the (-1)^{n-1}/n of the log(1+h) series:
\def\coefflog #1{\the\numexpr\ifodd #1 1\else-1\fi\relax/#1[0]}%
% Let L(h) be the first 10 terms of the log(1+h) series and
@@ -2869,7 +3054,7 @@ best of both worlds.
\ifnum\cnta < 12 \advance \cnta 1 \repeat
\end{verbatim}
\cnta 0
-\def\ratioexp #1#2{\romannumeral0\xintdiv {#1}{#2}}% x/n
+\def\ratioexp #1#2{\xintDiv {#1}{#2}}% x/n
% These are the (-1)^{n-1}/n of the log(1+h) series
\def\coefflog #1{\the\numexpr\ifodd #1 1\else-1\fi\relax/#1[0]}%
% Let L(h) be the first 10 terms of the log(1+h) series and
@@ -2892,13 +3077,14 @@ best of both worlds.
\csa{xintFxPtPowerSeries}|{A}{B}{\coeff}{x}{D}| computes the sum of
|\coeff{n}|\raisebox{.5ex}{|.|}|x^n| from |n=A| to |n=B| with each term of the
-series truncated to |D| digits after the decimal point. As usual, |A|
-and |B| are first twice-expanded. Regarding |D| it will be twice-expanded each
-time it will be used inside an \csa{xintTrunc}. The one-parameter macro |\coeff|
-is similarly only expanded when it is used inside the computations. Idem for
-|x|. If |x| itself is some complicated macro it is thus better to use the
-variant \csb{xintFxPtPowerSeriesX} which expands it first and then uses the
-result of that (double) expansion.
+series truncated to |D| digits after the decimal point. As usual, |A| and |B|
+are completely expanded through their inclusion in a |\numexpr| expression.
+Regarding |D| it will be similarly be expanded each time it is used inside an
+\csa{xintTrunc}. The one-parameter macro |\coeff| is similarly only expanded (in
+the usual meaning) when it is used inside the computations. Idem for |x|. If |x|
+itself is some complicated macro it is thus better to use the variant
+\csb{xintFxPtPowerSeriesX} which expands it first and then uses the result of
+that expansion.
The current (|1.04|) implementation is: the first power |x^A| is
computed exactly, then \emph{truncated}. Then each successive power is
@@ -2909,59 +3095,47 @@ truncating. Finally the sum is computed exactly. Apart from that
\csa{xintFxPtPowerSeries} (where |FxPt| means `fixed-point') is like
\csa{xintPowerSeries}.
+There should be a variant for things of the
+type $\sum c_n \frac {x^n}{n!}$ to avoid having to compute the factorial
+from scratch at each coefficient, the same way \csa{xintFxPtPowerSeries}
+does not compute |x^n| from scratch at each |n|. Perhaps in the next package
+release.
+
\def\coeffexp #1{1/\xintFac {#1}[0]}% [0] for faster parsing
\def\x {-1/2[0]}%
\def\ApproxExp #1#2{\xintFxPtPowerSeries {0}{#1}{\coeffexp}{\x}{#2}}%
\newcount\cnta
-\noindent\begin{minipage}{0.3\linewidth}
-\centeredline{$e^{-\frac12}\approx{}$}%
+\setlength{\multicolsep}{0pt}
+
+\begin{multicols}{3}[%
+\centeredline{$e^{-\frac12}\approx{}$}]%
\cnta 0
-\loop
-$\ApproxExp {\the\cnta}{20}$\\
+\noindent\loop
+$\ApproxExp {\cnta}{20}$\\
\ifnum\cnta<19
\advance\cnta 1
\repeat\par
-\end{minipage}
-\hfil
-\begin{minipage}{0.65\linewidth}
-\ttfamily\hyphenchar\font-1
+\end{multicols}
\begin{verbatim}
-\def\coeffexp #1{1/\xintFac {#1}[0]}%
-\def\x {-1/2[0]}% [0] for faster parsing
-\def\ApproxExp #1#2{\xintFxPtPowerSeries
- {0}{#1}{\coeffexp}{\x}{#2}}%
+\def\coeffexp #1{1/\xintFac {#1}[0]}% 1/n!
+\def\x {-1/2[0]}% [0] for faster input parsing
+\def\ApproxExp #1#2{\xintFxPtPowerSeries {0}{#1}{\coeffexp}{\x}{#2}}%
\cnta 0 % previously declared \count register
-\loop
-$\ApproxExp {\the\cnta}{20}$\\
-% truncates 20 digits after decimal point
-\ifnum\cnta<19
-\advance\cnta 1
-\repeat\par
-% One should **not** trust the final digits,
-% as the potential truncation errors of up to
-% 10^{-20} per term accumulate and never
-% disappear! (the effect is attenuated by the
-% alternating signs in the series). We can
-% confirm that the last two digits (of our
-% evaluation of the nineteenth partial sum)
-% are wrong via the evaluation with more
-% digits:
+\noindent\loop
+$\ApproxExp {\cnta}{20}$\\ % truncates 20 digits after decimal point
+\ifnum\cnta<19 \advance\cnta 1 \repeat\par
+% One should **not** trust the final digits, as the potential truncation
+% errors of up to 10^{-20} per term accumulate and never disappear! (the
+% effect is attenuated by the alternating signs in the series). We can
+% confirm that the last two digits (of our evaluation of the nineteenth
+% partial sum) are wrong via the evaluation with more digits:
\end{verbatim}
-\end{minipage}
-
-\centeredline{|\xintFxPtPowerSeries {0}{19}{\coeffexp}{\x}{25}=|}%
-\centeredline{%
+\centeredline{|\xintFxPtPowerSeries {0}{19}{\coeffexp}{\x}{25}=|
\xintFxPtPowerSeries {0}{19}{\coeffexp}{\x}{25}}
\texttt{\hyphenchar\font45 }
-There should be a variant for things of the
-type $\sum c_n \frac {x^n}{n!}$ to avoid having to compute the factorial
-from scratch at each coefficient, the same way \csa{xintFxPtPowerSeries}
-does not compute |x^n| from scratch at each |n|. Perhaps in the next package
-release.
-
\edef\z{\xintIrr {\xintPowerSeries {0}{19}{\coeffexp}{\x}}}
It is no difficulty for \xintfracname to compute exactly, with the help
@@ -2986,7 +3160,7 @@ of digits possibly of dubious significance.
\csa{xintFxPtPowerSeries}, the sum of
|\coeff{n}|\raisebox{.5ex}{|.|}|\x^n| from |n=A| to |n=B| with each term
of the series being \emph{truncated} to |D| digits after the decimal
-point. The sole difference is that |\x| is first expanded (twice) and it
+point. The sole difference is that |\x| is first expanded and it
is the result of this which is used in the computations.
% Let us illustrate this on the computation of |(1+y)^{5/3}| where
@@ -3121,7 +3295,8 @@ correct exact truncated one.
\def\xb {1/9[0]}% we will compute log(1-1/9)
\def\LogTwo #1%
% get log(2)=-2log(1-13/256)- 5log(1-1/9)
-{%
+{% we want to use \printnumber, hence need something expanding in two steps
+ % only, so we use here the \romannumeral0 method
\romannumeral0\expandafter\LogTwoDoIt \expandafter
% Nb Terms for 1/9:
{\the\numexpr #1*150/143\expandafter}\expandafter
@@ -3210,10 +3385,7 @@ zeros may be nine (and the last non-zero one should be decreased).
% Alternatives:
% \def\coeffarctg #1{1/\the\numexpr\xintiMON{#1}*(2*#1+1)\relax }%
% The [0] can *not* be used above, as the denominator is signed.
-% \def\coeffarctg #1{\the\numexpr\xintiMON{#1}\relax/%
- \the\numexpr 2*#1+1\relax [0]}%
-% \def\coeffarctg #1%
- {\romannumeral0\xintmon{#1}/\the\numexpr 2*#1+1\relax [0]}%
+% \def\coeffarctg #1{\xintiMON{#1}/\the\numexpr 2*#1+1\relax [0]}%
\def\xa {1/25[0]}% 1/5^2, the [0] for faster parsing
\def\xb {1/57121[0]}% 1/239^2, the [0] for faster parsing
\def\Machin #1{% \Machin {\mycount} is allowed
@@ -3222,7 +3394,7 @@ zeros may be nine (and the last non-zero one should be decreased).
{\the\numexpr (#1+3)*5/7\expandafter}\expandafter
% number of terms for arctg(1/239):
{\the\numexpr (#1+3)*10/45\expandafter}\expandafter
- % do the computations with 4 additional digits:
+ % do the computations with 3 additional digits:
{\the\numexpr #1+3\expandafter}\expandafter
% allow #1 to be a count register:
{\the\numexpr #1\relax }}%
@@ -3250,7 +3422,7 @@ zeros may be nine (and the last non-zero one should be decreased).
{\the\numexpr (#1+3)*5/7\expandafter}\expandafter
% number of terms for arctg(1/239):
{\the\numexpr (#1+3)*10/45\expandafter}\expandafter
- % do the computations with 4 additional digits:
+ % do the computations with 3 additional digits:
{\the\numexpr #1+3\expandafter}\expandafter
% allow #1 to be a count register:
{\the\numexpr #1\relax }}%
@@ -3305,7 +3477,7 @@ Let us use this variant for a loop showing the build-up of digits:
\begin{verbatim}
\cnta 0 % previously declared \count register
\loop
- \MachinBis{\cnta} \endgraf % TeX's \loop does not accept \par
+ \MachinBis{\cnta} \endgraf % Plain's \loop does not accept \par
\ifnum\cnta < 30 \advance\cnta 1 \repeat
\end{verbatim}
\begin{multicols}{2}
@@ -3528,20 +3700,20 @@ It produces:\par
}{\xintApply{\mymacro}{\xintFtoCv{49171/18089}}}.
-\def\cn #1{\romannumeral0\xintipow {2}{#1}}%
+\def\cn #1{\xintiPow {2}{#1}}%
The macro \csb{xintCntoF} allows to specify the coefficients as
functions of the index. The values to which expand the
coefficient function do not have to be integers. \centeredline{|\def\cn
- #1{\romannumeral0\xintipow {2}{#1}}% 2^n|}%
+ #1{\xintiPow {2}{#1}}% 2^n|}%
\centeredline{|\[\xintFrac{\xintCntoF {6}{\cn}}=\xintCFrac
[l]{\xintCntoF {6}{\cn}}\]|}%
\[\xintFrac{\xintCntoF {6}{\cn}}=\xintCFrac [l]{\xintCntoF
{6}{\cn}}\]
Notice the use of the optional argument |[l]| to \csa{xintCFrac}. Other
possibilities are |[r]| and (default) |[c]|.
-\def\cn #1{\romannumeral0\xintpow {2}{-#1}}%
-\centeredline{|\def\cn #1{\romannumeral0\xintpow {2}{-#1}}% 1/2^n|}%
+\def\cn #1{\xintPow {2}{-#1}}%
+\centeredline{|\def\cn #1{\xintPow {2}{-#1}}% 1/2^n|}%
\centeredline{%
|\[\xintFrac{\xintCntoF {6}{\cn}} = \xintGCFrac [r]{\xintCntoGC {6}{\cn}}|}%
\centeredline{| = [\xintFtoCs {\xintCntoF {6}{\cn}}]\]|}%
@@ -3668,9 +3840,9 @@ $1$ or $-1$.
which first computes then displays with the help of |\cfrac| the simple
continued fraction corresponding to the given fraction (or macro expanding in
two steps to one such). It admits an optional argument which may be |[l]|, |[r]|
-or (the default) |[c]| to specify the location of the one's in the numerators.
-Each numerator is typeset using the \csb{xintFrac} macro from the \xintfracname
-package.
+or (the default) |[c]| to specify the location of the one's in the numerators of
+the sub-fractions. Each coefficient is typeset using the \csb{xintFrac} macro
+from the \xintfracname package.
\subsection{\csbh{xintGCFrac}}\label{xintGCFrac}
@@ -3857,29 +4029,29 @@ with |\xintApply\xintIrr|.
\def\macro #1{\the\numexpr 1+#1*#1\relax}
-\csa{xintCntoF}|{N}{\macro}| computes the fraction |f| having
-coefficients |c(j)=\macro{j}| for |j=0,1,...,N|. The values do not have
-to be positive, nor integers, and it is thus not necessarily the case
-that the original |c(j)| are the true coefficients of the final |f|.
-One usually has to define the one-parameter |\macro| in advance.
-\centeredline{%
-|\def\macro #1{\the\numexpr 1+#1*#1\relax}\xintCntoF {5}{\macro}|}%
+\csa{xintCntoF}|{N}{\macro}| computes the fraction |f| having coefficients
+|c(j)=\macro{j}| for |j=0,1,...,N|. The |N| parameter is given to a |\numexpr|.
+The values of the coefficients, as returned by |\macro| do not have to be
+positive, nor integers, and it is thus not necessarily the case that the
+original |c(j)| are the true coefficients of the final |f|. \centeredline{%
+ |\def\macro #1{\the\numexpr 1+#1*#1\relax}\xintCntoF {5}{\macro}|}%
\centeredline{\xintCntoF {5}{\macro}}
\subsection{\csbh{xintGCntoF}}\label{xintGCntoF}
\def\coeffA #1{\the\numexpr #1+4-3*((#1+2)/3)\relax }%
-\def\coeffB #1{\romannumeral0\xintmon{#1}}% (-1)^n
+\def\coeffB #1{\xintMON{#1}}% (-1)^n
\csa{xintGCntoF}|{N}{\macroA}{\macroB}| returns the fraction |f| corresponding
to the inline generalized continued fraction |a0+b0/a1+b1/a2+....+b(N-1)/aN|,
-with |a(j)=\macroA{j}| and |b(j)=\macroB{j}|.
+with |a(j)=\macroA{j}| and |b(j)=\macroB{j}|. The |N| parameter is given to a
+|\numexpr|.
\[\xintGCFrac{\xintGCntoGC {6}{\coeffA}{\coeffB}}
= \xintFrac{\xintGCntoF {6}{\coeffA}{\coeffB}}\]
There is also \csb{xintGCntoGC} to get the `inline format' continued
fraction. The previous display was obtained with:
\centeredline{|\def\coeffA #1{\the\numexpr #1+4-3*((#1+2)/3)\relax }%|}%
-\centeredline{|\def\coeffB #1{\romannumeral0\xintmon{#1}}% (-1)^n|}%
+\centeredline{|\def\coeffB #1{\xintMON{#1}}% (-1)^n|}%
\centeredline{|\[\xintGCFrac{\xintGCntoGC {6}{\coeffA}{\coeffB}}|}%
\centeredline{| = \xintFrac{\xintGCntoF {6}{\coeffA}{\coeffB}}\]|}
@@ -3887,7 +4059,8 @@ fraction. The previous display was obtained with:
\subsection{\csbh{xintCntoCs}}\label{xintCntoCs}
\csa{xintCntoCs}|{N}{\macro}| produces the comma separated list of the
-corresponding coefficients, from |n=0| to |n=N|.
+corresponding coefficients, from |n=0| to |n=N|. The |N| is given to a
+|\numexpr|.
\centeredline{%
|\def\macro #1{\the\numexpr 1+#1*#1\relax}\xintCntoCs {5}{\macro}|}%
\centeredline{\xintCntoCs {5}{\macro}}%
@@ -3903,8 +4076,8 @@ corresponding coefficients, from |n=0| to |n=N|.
\csa{xintCntoGC}|{N}{\macro}| evaluates the |c(j)=\macro{j}| from |j=0|
to |j=N| and returns a continued fraction written in inline
-format: |{c(0)}+1/{c(1)}+1/...+1/{c(N)}|. It may then serve as input to
-other macros. The coefficients, after expansion, are, as shown, being
+format: |{c(0)}+1/{c(1)}+1/...+1/{c(N)}|. The parameter |N| is given to a
+|\numexpr|. The coefficients, after expansion, are, as shown, being
enclosed in an added pair of braces, they may thus be
fractions.
\centeredline{%
@@ -3917,11 +4090,10 @@ fractions.
\subsection{\csbh{xintGCntoGC}}\label{xintGCntoGC}
-\csa{xintGCntoGC}|{N}{\macroA}{\macroB}| evaluates the coefficients and
-then returns the corresponding
-|{a0}+{b0}/{a1}+{b1}/{a2}+...+{b(N-1)}/{aN}| inline generalized
-fraction. As shown, the coefficients are enclosed into added pairs of
-braces, and may thus be fractions.
+\csa{xintGCntoGC}|{N}{\macroA}{\macroB}| evaluates the coefficients and then
+returns the corresponding |{a0}+{b0}/{a1}+{b1}/{a2}+...+{b(N-1)}/{aN}| inline
+generalized fraction. |N| is givent to a |\numexpr|. As shown, the coefficients
+are enclosed into added pairs of braces, and may thus be fractions.
\begin{verbatim}
\def\an #1{\the\numexpr #1*#1*#1+1\relax}%
\def\bn #1{\the\numexpr \xintiMON{#1}*(#1+1)\relax}%
@@ -3949,9 +4121,9 @@ hundreds of coefficients.
\subsection{\csbh{xintGCtoGC}}\label{xintGCtoGC}
-\csa{xintGCtoGC}|{a+b/c+d/e+f/g+......+v/w+x/y}| twice-expands each one of the
-coefficients and returns an inline continued fraction of the same type, each
-coefficient being enclosed withing braces.
+\csa{xintGCtoGC}|{a+b/c+d/e+f/g+......+v/w+x/y}| expands (with the usual
+meaning) each one of the coefficients and returns an inline continued fraction
+of the same type, each expanded coefficient being enclosed withing braces.
\begin{verbatim}
\edef\x {\xintGCtoGC
{1+\xintPow{1.5}{3}/{1/7}+{-3/5}/\xintFac {6}+\xintCstoF {2,-7,-5}/16}}
@@ -3986,24 +4158,27 @@ first place.
%<*xint>
% \section {Package \xintname implementation}
%
-% The commenting of the macros is currently (\docdate) very
-% sparse. Some comments may be left-overs from previous versions
-% of the macro, with parameters in another order for example.
+% The commenting of the macros is currently (\docdate) very sparse. Some
+% comments may be left-overs from previous versions of the macro, with
+% parameters in another order for example.
%
% \toctransition
% \localtableofcontents
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
-% The method for package identification and reload detection is
-% copied verbatim from the packages by \textsc{Heiko Oberdiek}.
+% The method for package identification and reload detection is copied verbatim
+% from the packages by \textsc{Heiko Oberdiek}.
%
-% The method for catcodes was also inspired by these packages, we
-% proceed slightly differently. |1.05| adds a |\relax| near the end of
+% The method for catcodes was also inspired by these packages, we proceed
+% slightly differently. |1.05| adds a |\relax| near the end of
% |\XINT@restorecatcodes@endinput|. Plain TeX users following the doc
-% instruction to do |\input xint.sty\relax| were anyhow protected from
-% any side effect. I didn't realize earlier that the |\endinput| would
-% not have had the effect of stopping the scanning from the last
-% |\the\catcode61|.
+% instruction to do |\input xint.sty\relax| were anyhow protected from any side
+% effect. I didn't realize earlier that the |\endinput| would not have had the
+% effect of stopping the scanning from the last |\the\catcode61|.
+%
+% Starting with version |1.06| of the package, also |`| must be sanitized,
+% because we replace everywhere in the code the twice-expansion done with
+% |\expandafter| by the systematic use of |\romannumeral-`0|.
%
% \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
@@ -4045,6 +4220,7 @@ first place.
\endgroup
\edef\XINT@restorecatcodes@endinput
{%
+ \catcode96=\the\catcode96 % `
\catcode47=\the\catcode47 % /
\catcode41=\the\catcode41 % )
\catcode40=\the\catcode40 % (
@@ -4087,6 +4263,7 @@ first place.
\catcode40=12 % (
\catcode41=12 % )
\catcode47=12 % /
+ \catcode96=12 % `
}%
\XINT@setcatcodes
}%
@@ -4119,26 +4296,25 @@ first place.
\fi
\expandafter\x\csname ver@xint.sty\endcsname
\ProvidesPackage{xint}%
- [2013/05/02 v1.05a Expandable operations on long numbers (jfB)]%
+ [2013/05/07 v1.06 Expandable operations on long numbers (jfB)]%
% \end{macrocode}
% \subsection{Token management macros}
% \begin{macrocode}
-\def\xint@gobble #1{}%
-\def\xint@gobble@one #1{}%
-\def\xint@gobble@two #1#2{}%
-\def\xint@gobble@three #1#2#3{}%
-\def\xint@gobble@four #1#2#3#4{}%
-\def\xint@gobble@five #1#2#3#4#5{}%
-\def\xint@gobble@six #1#2#3#4#5#6{}%
-\def\xint@gobble@seven #1#2#3#4#5#6#7{}%
-\def\xint@gobble@eight #1#2#3#4#5#6#7#8{}%
+\def\xint@gobble #1{}%
+\def\xint@gobble@ {}%
+\def\xint@gobble@i #1{}%
+\def\xint@gobble@ii #1#2{}%
+\def\xint@gobble@iii #1#2#3{}%
+\def\xint@gobble@iv #1#2#3#4{}%
+\def\xint@gobble@v #1#2#3#4#5{}%
+\def\xint@gobble@vi #1#2#3#4#5#6{}%
+\def\xint@gobble@vii #1#2#3#4#5#6#7{}%
+\def\xint@gobble@viii #1#2#3#4#5#6#7#8{}%
\def\xint@firstoftwo #1#2{#1}%
\def\xint@secondoftwo #1#2{#2}%
\def\xint@firstoftwo@andstop #1#2{ #1}%
\def\xint@secondoftwo@andstop #1#2{ #2}%
-\def\xint@exchangetwo@keepbraces #1#2{{#2}{#1}}%
\def\xint@exchangetwo@keepbraces@andstop #1#2{ {#2}{#1}}%
-\def\xint@xpxp@andstop {\expandafter\expandafter\expandafter\space }%
\def\xint@minus@andstop { -}%
\def\xint@r #1\R {}%
\def\xint@w #1\W {}%
@@ -4160,19 +4336,15 @@ first place.
% \end{macrocode}
% \subsection{\csh{xintRev}, \csh{xintReverseOrder}}
% \begin{verbatim}
-% \xintRev: fait la double expansion, vérifie le signe
-% \xintReverseOrder: ne fait PAS la double expansion, ne regarde
-% PAS le signe.
+% \xintRev: fait l'expansion avec \romannumeral-`0, vérifie le signe
+% \xintReverseOrder: ne fait PAS l'expansion, ne regarde PAS le signe.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintRev {\romannumeral0\xintrev }%
\def\xintrev #1%
{%
- \expandafter\expandafter\expandafter
- \xint@rev
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\xint@rev\expandafter {\romannumeral-`0#1}%
}%
\def\xint@rev #1%
{%
@@ -4216,227 +4388,285 @@ first place.
\def\XINT@strip@undef #1\xint@undef {}%
\def\XINT@strip@UNDEF #1\xint@UNDEF {}%
% \end{macrocode}
-% \subsection{\csh{XINT@RQ}}
+% \subsection{\csh{xintRevWithBraces}}
% \begin{verbatim}
-% cette macro renverse et ajoute le nombre minimal de zéros à
-% la fin pour que la longueur soit alors multiple de 4
-% \romannumeral0\XINT@RQ {}<le truc à renverser>\R\R\R\R\R\R\R\R\Z
-% Attention, ceci n'est utilisé que pour des chaînes de chiffres, et donc le
-% comportement avec des {..} ou autres espaces n'a fait l'objet d'aucune
-% attention
+% New with 1.06. Makes the expansion of its argument and then reverses the
+% resulting tokens or braced tokens, adding a pair of braces to each (thus,
+% maintaining it when it was already there.)
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
-\def\XINT@RQ #1#2#3#4#5#6#7#8#9%
+\def\xintRevWithBraces {\romannumeral0\xintrevwithbraces }%
+\def\xintrevwithbraces #1%
{%
- \xint@r #9\XINT@RQ@end\R\XINT@RQ {#9#8#7#6#5#4#3#2#1}%
+ \expandafter\XINT@revwbr@prep\expandafter {\romannumeral-`0#1}%
}%
-\def\XINT@RQ@end\R\XINT@RQ #1#2\Z
+\def\XINT@RWB {\romannumeral0\XINT@revwbr@prep }%
+\def\XINT@revwbr@prep #1%
{%
- \XINT@RQ@end@ #1\Z
+ \XINT@revwbr@loop
+ {}#1\xint@undef\xint@undef\xint@undef\xint@undef
+ \xint@undef\xint@undef\xint@undef\xint@undef\Z
}%
-\def\XINT@RQ@end@ #1#2#3#4#5#6#7#8%
+\def\XINT@revwbr@loop #1#2#3#4#5#6#7#8#9%
{%
- \xint@r #8\XINT@RQ@end@viii
- #7\XINT@RQ@end@vii
- #6\XINT@RQ@end@vi
- #5\XINT@RQ@end@v
- #4\XINT@RQ@end@iv
- #3\XINT@RQ@end@iii
- #2\XINT@RQ@end@ii
- \R\XINT@RQ@end@i
- \Z #2#3#4#5#6#7#8%
+ \XINT@strip@undef #9\XINT@revwbr@finish@a\xint@undef
+ \XINT@revwbr@loop {{#9}{#8}{#7}{#6}{#5}{#4}{#3}{#2}#1}%
}%
-\def\XINT@RQ@end@viii #1\Z #2#3#4#5#6#7#8#9\Z { #9}%
-\def\XINT@RQ@end@vii #1\Z #2#3#4#5#6#7#8#9\Z { #8#9000}%
-\def\XINT@RQ@end@vi #1\Z #2#3#4#5#6#7#8#9\Z { #7#8#900}%
-\def\XINT@RQ@end@v #1\Z #2#3#4#5#6#7#8#9\Z { #6#7#8#90}%
-\def\XINT@RQ@end@iv #1\Z #2#3#4#5#6#7#8#9\Z { #5#6#7#8#9}%
-\def\XINT@RQ@end@iii #1\Z #2#3#4#5#6#7#8#9\Z { #4#5#6#7#8#9000}%
-\def\XINT@RQ@end@ii #1\Z #2#3#4#5#6#7#8#9\Z { #3#4#5#6#7#8#900}%
-\def\XINT@RQ@end@i \Z #1#2#3#4#5#6#7#8\Z { #1#2#3#4#5#6#7#80}%
-% \end{macrocode}
-% \subsection{\csh{XINT@cuz}}
-% \begin{macrocode}
-\def\xint@cleanupzeros@andstop #1#2#3#4%
+\def\XINT@revwbr@finish@a\xint@undef\XINT@revwbr@loop #1#2\Z
{%
- \expandafter\space\the\numexpr #1#2#3#4\relax
+ \XINT@revwbr@finish@b #2\R\R\R\R\R\R\R\Z #1%
}%
-\def\xint@cleanupzeros@nospace #1#2#3#4%
+\def\XINT@revwbr@finish@b #1#2#3#4#5#6#7#8\Z
{%
- \the\numexpr #1#2#3#4\relax
+ \xint@r #1\XINT@revwbr@finish@c 8%
+ #2\XINT@revwbr@finish@c 7%
+ #3\XINT@revwbr@finish@c 6%
+ #4\XINT@revwbr@finish@c 5%
+ #5\XINT@revwbr@finish@c 4%
+ #6\XINT@revwbr@finish@c 3%
+ #7\XINT@revwbr@finish@c 2%
+ \R\XINT@revwbr@finish@c 1\Z
}%
-\def\XINT@rev@andcuz #1%
+\def\XINT@revwbr@finish@c #1#2\Z
{%
- \expandafter\xint@cleanupzeros@andstop
- \romannumeral0\XINT@rord@main {}#1%
- \xint@UNDEF
- \xint@undef\xint@undef\xint@undef\xint@undef
- \xint@undef\xint@undef\xint@undef\xint@undef
- \xint@UNDEF
+ \expandafter\expandafter\expandafter
+ \space
+ \csname xint@gobble@\romannumeral #1\endcsname
}%
% \end{macrocode}
-% \vspace*{-.5\baselineskip}
+% \subsection{\csh{xintLen}, \csh{xintLength}}
% \begin{verbatim}
-% routine CleanUpZeros. Utilisée en particulier par la
-% soustraction.
-% INPUT: longueur **multiple de 4** (<-- ATTENTION)
-% OUTPUT: on a retiré tous les leading zéros, on n'est **plus*
-% nécessairement de longueur 4n
-% Délimiteur pour @main: \W\W\W\W\W\W\W\Z avec SEPT \W
+% \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.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
-\def\XINT@cuz #1%
+\def\xintiLen {\romannumeral0\xintilen }%
+\def\xintilen #1%
{%
- \XINT@cuz@loop #1\W\W\W\W\W\W\W\Z%
+ \expandafter\XINT@len@prep\expandafter {\romannumeral-`0#1}%
}%
-\def\XINT@cuz@loop #1#2#3#4#5#6#7#8%
+\let\xintLen\xintiLen \let\xintlen\xintilen
+\def\XINT@Len {\romannumeral0\XINT@len@prep }%
+\def\XINT@len@prep #1%
{%
- \xint@w #8\xint@cuz@enda\W
- \xint@z #8\xint@cuz@endb\Z
- \XINT@cuz@checka {#1#2#3#4#5#6#7#8}%
+ \XINT@length@fork
+ #1\xint@undef\xint@undef\xint@undef\xint@undef
+ \xint@undef\xint@undef\xint@undef\xint@undef\Z
}%
-\def\xint@cuz@enda #1\XINT@cuz@checka #2%
+\def\XINT@length@fork #1%
{%
- \xint@cuz@endaa #2%
+ \expandafter\XINT@length@loop
+ \xint@UDsignfork
+ #1\dummy {{0}}%
+ -\dummy {{0}#1}%
+ \xint@UDkrof
}%
-\def\xint@cuz@endaa #1#2#3#4#5\Z
+\def\XINT@Length {\romannumeral0\XINT@length }%
+\def\XINT@length #1%
{%
- \expandafter\space\the\numexpr #1#2#3#4\relax
+ \XINT@length@loop
+ {0}#1\xint@undef\xint@undef\xint@undef\xint@undef
+ \xint@undef\xint@undef\xint@undef\xint@undef\Z
}%
-\def\xint@cuz@endb\Z\XINT@cuz@checka #1{ 0}%
-\def\XINT@cuz@checka #1%
+\let\xintLength\XINT@Length
+\def\XINT@length@loop #1#2#3#4#5#6#7#8#9%
{%
- \expandafter \XINT@cuz@checkb \the\numexpr #1\relax
+ \XINT@strip@undef #9\XINT@length@finish@a\xint@undef
+ \expandafter\XINT@length@loop\expandafter {\the\numexpr #1+8\relax}%
}%
-\def\XINT@cuz@checkb #1%
+\def\XINT@length@finish@a\xint@undef
+ \expandafter\XINT@length@loop\expandafter #1#2\Z
{%
- \xint@zero #1\xint@cuz@backtoloop 0\XINT@cuz@Stop #1%
+ \XINT@length@finish@b #2\W\W\W\W\W\W\W\Z {#1}%
}%
-\def\XINT@cuz@Stop #1\W #2\Z{ #1}%
-\def\xint@cuz@backtoloop 0\XINT@cuz@Stop 0{\XINT@cuz@loop }%
+\def\XINT@length@finish@b #1#2#3#4#5#6#7#8\Z
+{%
+ \xint@w #1\XINT@length@finish@c 8%
+ #2\XINT@length@finish@c 7%
+ #3\XINT@length@finish@c 6%
+ #4\XINT@length@finish@c 5%
+ #5\XINT@length@finish@c 4%
+ #6\XINT@length@finish@c 3%
+ #7\XINT@length@finish@c 2%
+ \W\XINT@length@finish@c 1\Z
+}%
+\def\XINT@length@finish@c #1#2\Z #3{\expandafter\space\the\numexpr #3-#1\relax}%
% \end{macrocode}
-% \subsection{\csh{XINT@isOne}}
-% Added in |1.03|. Attention: does not do any expansion.
+% \subsection{\csh{xintCSVtoList}}
+% \begin{verbatim}
+% \xintCSVtoList {a,b,..,z} returns {a}{b}...{z}. The comma separated list may
+% be a macro which is first expanded. Each chain of spaces is collapsed
+% into one space only.
+% First included in release 1.06.
+% \end{verbatim}
+% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
-\def\XINT@isOne #1{\romannumeral0\XINT@isone #1\W\Z }%
-\def\XINT@isone #1#2%
+\def\xintCSVtoList {\romannumeral0\xintcsvtolist }%
+\def\xintcsvtolist #1%
{%
- \xint@one #1\XINT@isone@b 1\expandafter\space\expandafter 0\xint@z #2%
+ \expandafter\XINT@csvtol@prep\expandafter {\romannumeral-`0#1}%
}%
-\def\XINT@isone@b #1\xint@z #2%
+\def\XINT@CSVtoL {\romannumeral0\XINT@csvtol@prep }%
+\def\XINT@csvtol@prep #1%
{%
- \xint@w #2\XINT@isone@yes\W\expandafter\space\expandafter 0\xint@z
+ \XINT@csvtol@loop@a
+ {}#1,\xint@undef,\xint@undef,\xint@undef,\xint@undef,%
+ \xint@undef,\xint@undef,\xint@undef,\xint@undef,\Z
}%
-\def\XINT@isone@yes #1\Z{ 1}%
+\def\XINT@csvtol@loop@a #1#2,#3,#4,#5,#6,#7,#8,#9,%
+{%
+ \XINT@strip@undef #9\XINT@csvtol@finish@a\xint@undef
+ \XINT@csvtol@loop@b {#1}{{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}}%
+}%
+\def\XINT@csvtol@loop@b #1#2{\XINT@csvtol@loop@a {#1#2}}%
+\def\XINT@csvtol@finish@a\xint@undef\XINT@csvtol@loop@b #1#2#3\Z
+{%
+ \XINT@csvtol@finish@b #3\R,\R,\R,\R,\R,\R,\R,\Z #2{#1}%
+}%
+\def\XINT@csvtol@finish@b #1,#2,#3,#4,#5,#6,#7,#8\Z
+{%
+ \xint@r #1\XINT@csvtol@finish@c 8%
+ #2\XINT@csvtol@finish@c 7%
+ #3\XINT@csvtol@finish@c 6%
+ #4\XINT@csvtol@finish@c 5%
+ #5\XINT@csvtol@finish@c 4%
+ #6\XINT@csvtol@finish@c 3%
+ #7\XINT@csvtol@finish@c 2%
+ \R\XINT@csvtol@finish@c 1\Z
+}%
+\def\XINT@csvtol@finish@c #1#2\Z
+{%
+ \csname XINT@csvtol@finish@d\romannumeral #1\endcsname
+}%
+\def\XINT@csvtol@finish@dviii #1#2#3#4#5#6#7#8#9{ #9}%
+\def\XINT@csvtol@finish@dvii #1#2#3#4#5#6#7#8#9{ #9{#1}}%
+\def\XINT@csvtol@finish@dvi #1#2#3#4#5#6#7#8#9{ #9{#1}{#2}}%
+\def\XINT@csvtol@finish@dv #1#2#3#4#5#6#7#8#9{ #9{#1}{#2}{#3}}%
+\def\XINT@csvtol@finish@div #1#2#3#4#5#6#7#8#9{ #9{#1}{#2}{#3}{#4}}%
+\def\XINT@csvtol@finish@diii #1#2#3#4#5#6#7#8#9{ #9{#1}{#2}{#3}{#4}{#5}}%
+\def\XINT@csvtol@finish@dii #1#2#3#4#5#6#7#8#9{ #9{#1}{#2}{#3}{#4}{#5}{#6}}%
+\def\XINT@csvtol@finish@di #1#2#3#4#5#6#7#8#9{ #9{#1}{#2}{#3}{#4}{#5}{#6}{#7}}%
% \end{macrocode}
-% \subsection{\csh{xintNum}}
+% \subsection{\csh{xintListWithSep}}
% \begin{verbatim}
-% For example \xintNum {----+-+++---+----000000000000003}
-% 1.05 defines \xintiNum, as the original \xintNum will be a made a synonym of
-% \xintIrr in xintfrac
+% \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.
+% 1.06 modifies the `feature' of returning sep if the list is empty: the output
+% is now empty in that case. (sep was not used for a one element list, but
+% strangely it was for a zero-element list).
% \end{verbatim}
+% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
-\def\xintiNum {\romannumeral0\xintinum }%
-\def\xintinum #1%
+\def\xintListWithSep {\romannumeral0\xintlistwithsep }%
+\long\def\xintlistwithsep #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@num
- \expandafter\expandafter\expandafter
+ \expandafter\XINT@lws\expandafter {\romannumeral-`0#2}%
{#1}%
}%
-\let\xintNum\xintiNum \let\xintnum\xintinum
-\def\XINT@Num {\romannumeral0\XINT@num }%
-\def\XINT@num #1{\XINT@num@loop #1\R\R\R\R\R\R\R\R\Z }%
-\def\XINT@num@loop #1#2#3#4#5#6#7#8%
-{%
- \xint@r #8\XINT@num@end\R\XINT@num@NumEight #1#2#3#4#5#6#7#8%
+\long\def\XINT@LWS #1#2{\romannumeral0\XINT@lws@start {#1}#2\Z }%
+\long\def\XINT@lws #1#2%
+{%
+ \XINT@lws@start {#2}#1\Z
}%
-\def\XINT@num@end\R\XINT@num@NumEight #1\R #2\Z
+\long\def\XINT@lws@start #1#2%
{%
- \expandafter\space\the\numexpr #1+0\relax
+ \xint@z #2\XINT@lws@dont\Z
+ \XINT@lws@loop@a {#2}{#1}%
}%
-\def\XINT@num@NumEight #1#2#3#4#5#6#7#8%
+\long\def\XINT@lws@dont\Z\XINT@lws@loop@a #1#2{ }%
+\long\def\XINT@lws@loop@a #1#2#3%
{%
- \ifnum \numexpr #1#2#3#4#5#6#7#8+0\relax = 0
- \xint@afterfi {\expandafter\XINT@num@keepsign@a
- \the\numexpr #1#2#3#4#5#6#7#81\relax}%
+ \xint@z #3\XINT@lws@end\Z
+ \XINT@lws@loop@b {#1}{#2#3}{#2}%
+}%
+\long\def\XINT@lws@loop@b #1#2{\XINT@lws@loop@a {#1#2}}%
+\long\def\XINT@lws@end\Z\XINT@lws@loop@b #1#2#3{ #1}%
+% \end{macrocode}
+% \subsection{\csh{xintNthElt}}
+% \begin{verbatim}
+% \xintNthElt {{a}{b}...{z}} (or `tokens' abcd...z) returns the Nth
+% one (one pair of braces removed). The list is first expanded.
+% First included in release 1.06.
+% \end{verbatim}
+% \vspace*{-1.5\baselineskip}
+% \begin{macrocode}
+\def\xintNthElt {\romannumeral0\xintnthelt }%
+\def\xintnthelt #1#2%
+{%
+ \expandafter\XINT@nthelt\expandafter {\romannumeral-`0#2}%
+ {\numexpr #1\relax}%
+}%
+\def\XINT@NthElt #1#2{\romannumeral0\XINT@nthelt {#2}{\numexpr #1\relax}}%
+\def\XINT@nthelt #1#2%
+{%
+ \ifnum #2<1
+ \expandafter\XINT@nthelt@silentend
\else
- \xint@afterfi {\expandafter\XINT@num@finish
- \the\numexpr #1#2#3#4#5#6#7#8\relax}%
+ \expandafter\XINT@nthelt@loop@a
+ \fi {#2}#1\xint@undef\xint@undef\xint@undef\xint@undef
+ \xint@undef\xint@undef\xint@undef\xint@undef\Z
+}%
+\def\XINT@nthelt@silentend #1\Z { }%
+\def\XINT@nthelt@loop@a #1%
+{%
+ \ifnum #1>8
+ \expandafter\XINT@nthelt@loop@b
+ \else
+ \expandafter\XINT@nthelt@getit
\fi
+ {#1}%
}%
-\def\XINT@num@keepsign@a #1%
+\def\XINT@nthelt@loop@b #1#2#3#4#5#6#7#8#9%
{%
- \xint@one#1\XINT@num@gobacktoloop 1\XINT@num@keepsign@b
+ \XINT@strip@undef #9\XINT@nthelt@silentend\xint@undef
+ \expandafter\XINT@nthelt@loop@a\expandafter{\the\numexpr #1-8\relax}%
+}%
+\def\XINT@nthelt@getit #1%
+{%
+ \expandafter\expandafter\expandafter\XINT@nthelt@finish
+ \csname xint@gobble@\romannumeral\numexpr#1-1\endcsname
+}%
+\def\XINT@nthelt@finish #1#2\Z
+{%
+ \xint@UDwfork
+ #1\dummy { }%
+ \W\dummy { #1}%
+ \xint@UDkrof
}%
-\def\XINT@num@gobacktoloop 1\XINT@num@keepsign@b {\XINT@num@loop }%
-\def\XINT@num@keepsign@b #1{\XINT@num@loop -}%
-\def\XINT@num@finish #1\R #2\Z { #1}%
% \end{macrocode}
-% \subsection{\csh{xintLen}, \csh{xintLength}}
+% \subsection{\csh{xintApply}}
% \begin{verbatim}
-% \xintLen -> fait la double expansion, ne compte PAS le signe
-% \xintLength -> ne fait PAS la double expansion, compte le signe
+% \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.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
-\def\xintiLen {\romannumeral0\xintilen }%
-\def\xintilen #1%
+\def\xintApply {\romannumeral0\xintapply }%
+\def\xintapply #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@length@fork #1\R\R\R\R\R\R\R\R\Z
+ \expandafter\XINT@apply\expandafter {\romannumeral-`0#2}%
+ {#1}%
}%
-\let\xintLen\xintiLen \let\xintlen\xintilen
-\def\XINT@Len #1{\romannumeral0\XINT@length@fork #1\R\R\R\R\R\R\R\R\Z }%
-\def\XINT@length@fork #1%
+\def\XINT@Apply #1#2{\romannumeral0\XINT@apply@loop@a {}{#1}#2\Z }%
+\def\XINT@apply #1#2%
{%
- \expandafter\XINT@length@loop
- \xint@UDsignfork
- #1\dummy {{0}}%
- -\dummy {{0}#1}%
- \xint@UDkrof
+ \XINT@apply@loop@a {}{#2}#1\Z
}%
-\def\XINT@Length #1{\romannumeral0\XINT@length@loop {0}#1\R\R\R\R\R\R\R\R\Z }%
-\def\XINT@length #1{\XINT@length@loop {0}#1\R\R\R\R\R\R\R\R\Z }%
-\let\xintLength\XINT@Length
-\def\XINT@length@loop #1#2#3#4#5#6#7#8#9%
+\def\XINT@apply@loop@a #1#2#3%
{%
- \xint@r #9\XINT@length@end {#2#3#4#5#6#7#8#9}\R
- \expandafter\XINT@length@loop\expandafter {\the\numexpr #1+8\relax}%
+ \xint@z #3\XINT@apply@end\Z
+ \expandafter
+ \XINT@apply@loop@b
+ \expandafter {\romannumeral-`0#2{#3}}{#1}{#2}%
}%
-\def\XINT@length@end #1\R\expandafter\XINT@length@loop\expandafter #2#3\Z
-{%
- \XINT@length@end@ #1\W\W\W\W\W\W\W\W\Z {#2}%
-}%
-\def\XINT@length@end@ #1\R #2#3#4#5#6#7#8#9\Z
-{%
- \xint@w #2\XINT@length@end@i
- #3\XINT@length@end@ii
- #4\XINT@length@end@iii
- #5\XINT@length@end@iv
- #6\XINT@length@end@v
- #7\XINT@length@end@vi
- #8\XINT@length@end@vii
- \W\XINT@length@end@viii
-}%
-\def\XINT@length@end@viii #1%
- {\expandafter\space\the\numexpr #1-8\relax}%
-\def\XINT@length@end@vii #1\XINT@length@end@viii #2%
- {\expandafter\space\the\numexpr #2-7\relax}%
-\def\XINT@length@end@vi #1\XINT@length@end@viii #2%
- {\expandafter\space\the\numexpr #2-6\relax}%
-\def\XINT@length@end@v #1\XINT@length@end@viii #2%
- {\expandafter\space\the\numexpr #2-5\relax}%
-\def\XINT@length@end@iv #1\XINT@length@end@viii #2%
- {\expandafter\space\the\numexpr #2-4\relax}%
-\def\XINT@length@end@iii #1\XINT@length@end@viii #2%
- {\expandafter\space\the\numexpr #2-3\relax}%
-\def\XINT@length@end@ii #1\XINT@length@end@viii #2%
- {\expandafter\space\the\numexpr #2-2\relax}%
-\def\XINT@length@end@i #1\XINT@length@end@viii #2%
- {\expandafter\space\the\numexpr #2-1\relax}%
+\def\XINT@apply@loop@b #1#2{\XINT@apply@loop@a {#2{#1}}}%
+\def\XINT@apply@end\Z\expandafter\XINT@apply@loop@b\expandafter #1#2#3{ #2}%
% \end{macrocode}
% \subsection{\csh{xintAssign},~\csh{xintAssignArray},~\csh{xintDigitsOf}}
% \begin{verbatim}
@@ -4446,15 +4676,16 @@ first place.
% \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.
-% In version 1.05a I suddenly discover incongruous \expandafter's in
-% \XINT@assignarray@@@@end, which I remove.
+% In version 1.05a I suddenly see some incongruous \expandafter's in
+% \XINT@assignarray@@@@end, which I remove.
+% Release 1.06 modifies the macros created by \xintAssignArray to feed their
+% argument to a \numexpr
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintAssign #1\to
{%
- \expandafter\expandafter\expandafter
- \XINT@assign@a #1{}\to
+ \expandafter\XINT@assign@a\romannumeral-`0#1{}\to
}%
\def\XINT@assign@a #1% attention to the # at the beginning of next line
#{%
@@ -4502,8 +4733,8 @@ first place.
\edef\xint@arrayname {\string #1}%
\XINT@restoreescapechar
\count 255 0
- \expandafter\expandafter\expandafter
- \XINT@assignarray@loop #1\xint@undef
+ \expandafter
+ \XINT@assignarray@loop \romannumeral-`0#1\xint@undef
\csname\xint@arrayname 00\endcsname
\csname\xint@arrayname 0\endcsname
{\xint@arrayname}%
@@ -4536,11 +4767,9 @@ first place.
\def\XINT@assignarray@@@@end #1#2#3#4%
{%
\def #4##1%
- {\romannumeral0%
- \expandafter\expandafter\expandafter
- #1%
- \expandafter\expandafter\expandafter
- {##1}%
+ {%
+ \romannumeral0%
+ \expandafter #1\expandafter{\the\numexpr ##1}%
}%
\def #1##1%
{%
@@ -4560,73 +4789,160 @@ first place.
}%
\let\xintDigitsOf\xintAssignArray
% \end{macrocode}
-% \subsection{\csh{xintApply}}
+% \subsection{\csh{XINT@RQ}}
% \begin{verbatim}
-% \xintApply {\macro}{{a}{b}...{z}} returns {\macro{a}}...{\macro{b}}
-% where each instance of \macro is twice expanded. The list is first twice
-% expanded. Introduced with release 1.04.
+% cette macro renverse et ajoute le nombre minimal de zéros à
+% la fin pour que la longueur soit alors multiple de 4
+% \romannumeral0\XINT@RQ {}<le truc à renverser>\R\R\R\R\R\R\R\R\Z
+% Attention, ceci n'est utilisé que pour des chaînes de chiffres, et donc le
+% comportement avec des {..} ou autres espaces n'a fait l'objet d'aucune
+% attention
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
-\def\xintApply {\romannumeral0\xintapply }%
-\def\xintapply #1#2%
+\def\XINT@RQ #1#2#3#4#5#6#7#8#9%
{%
- \expandafter\expandafter\expandafter
- \XINT@apply
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \xint@r #9\XINT@RQ@end\R\XINT@RQ {#9#8#7#6#5#4#3#2#1}%
}%
-\def\XINT@apply #1#2%
+\def\XINT@RQ@end\R\XINT@RQ #1#2\Z
{%
- \XINT@apply@loop@a {}{#2}#1\Z
+ \XINT@RQ@end@ #1\Z
}%
-\def\XINT@apply@loop@a #1#2#3%
+\def\XINT@RQ@end@ #1#2#3#4#5#6#7#8%
{%
- \xint@z #3\XINT@apply@end\Z
- \expandafter\expandafter\expandafter
- \XINT@apply@loop@b
- \expandafter\expandafter\expandafter {#2{#3}}{#1}{#2}%
+ \xint@r #8\XINT@RQ@end@viii
+ #7\XINT@RQ@end@vii
+ #6\XINT@RQ@end@vi
+ #5\XINT@RQ@end@v
+ #4\XINT@RQ@end@iv
+ #3\XINT@RQ@end@iii
+ #2\XINT@RQ@end@ii
+ \R\XINT@RQ@end@i
+ \Z #2#3#4#5#6#7#8%
}%
-\def\XINT@apply@loop@b #1#2{\XINT@apply@loop@a {#2{#1}}}%
-\def\XINT@apply@end\Z
- \expandafter\expandafter\expandafter
- \XINT@apply@loop@b
- \expandafter\expandafter\expandafter #1#2#3{ #2}%
+\def\XINT@RQ@end@viii #1\Z #2#3#4#5#6#7#8#9\Z { #9}%
+\def\XINT@RQ@end@vii #1\Z #2#3#4#5#6#7#8#9\Z { #8#9000}%
+\def\XINT@RQ@end@vi #1\Z #2#3#4#5#6#7#8#9\Z { #7#8#900}%
+\def\XINT@RQ@end@v #1\Z #2#3#4#5#6#7#8#9\Z { #6#7#8#90}%
+\def\XINT@RQ@end@iv #1\Z #2#3#4#5#6#7#8#9\Z { #5#6#7#8#9}%
+\def\XINT@RQ@end@iii #1\Z #2#3#4#5#6#7#8#9\Z { #4#5#6#7#8#9000}%
+\def\XINT@RQ@end@ii #1\Z #2#3#4#5#6#7#8#9\Z { #3#4#5#6#7#8#900}%
+\def\XINT@RQ@end@i \Z #1#2#3#4#5#6#7#8\Z { #1#2#3#4#5#6#7#80}%
% \end{macrocode}
-% \subsection{\csh{xintListWithSep}}
+% \subsection{\csh{XINT@cuz}}
+% \begin{macrocode}
+\def\xint@cleanupzeros@andstop #1#2#3#4%
+{%
+ \expandafter\space\the\numexpr #1#2#3#4\relax
+}%
+\def\xint@cleanupzeros@nospace #1#2#3#4%
+{%
+ \the\numexpr #1#2#3#4\relax
+}%
+\def\XINT@rev@andcuz #1%
+{%
+ \expandafter\xint@cleanupzeros@andstop
+ \romannumeral0\XINT@rord@main {}#1%
+ \xint@UNDEF
+ \xint@undef\xint@undef\xint@undef\xint@undef
+ \xint@undef\xint@undef\xint@undef\xint@undef
+ \xint@UNDEF
+}%
+% \end{macrocode}
+% \vspace*{-.5\baselineskip}
% \begin{verbatim}
-% \xintListWithSep {sep}{{a}{b}...{z}} returns a sep b sep .... sep z
-% Introduced with release 1.04. The 'sep' can be \par, as the macro
-% xintlistwithsep etc... are declared long. 'sep' does not have to be a
-% single token.
+% routine CleanUpZeros. Utilisée en particulier par la
+% soustraction.
+% INPUT: longueur **multiple de 4** (<-- ATTENTION)
+% OUTPUT: on a retiré tous les leading zéros, on n'est **plus*
+% nécessairement de longueur 4n
+% Délimiteur pour @main: \W\W\W\W\W\W\W\Z avec SEPT \W
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
-\def\xintListWithSep {\romannumeral0\xintlistwithsep }%
-\long\def\xintlistwithsep #1#2%
+\def\XINT@cuz #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@lws
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \XINT@cuz@loop #1\W\W\W\W\W\W\W\Z%
}%
-\long\def\XINT@lws #1#2%
+\def\XINT@cuz@loop #1#2#3#4#5#6#7#8%
{%
- \XINT@lws@start {#2}#1\Z
+ \xint@w #8\xint@cuz@enda\W
+ \xint@z #8\xint@cuz@endb\Z
+ \XINT@cuz@checka {#1#2#3#4#5#6#7#8}%
}%
-\long\def\XINT@lws@start #1#2%
+\def\xint@cuz@enda #1\XINT@cuz@checka #2%
{%
- \xint@z #2\XINT@lws@dont\Z
- \XINT@lws@loop@a {#2}{#1}%
+ \xint@cuz@endaa #2%
}%
-\long\def\XINT@lws@dont\Z\XINT@lws@loop@a #1#2{ #2}%
-\long\def\XINT@lws@loop@a #1#2#3%
+\def\xint@cuz@endaa #1#2#3#4#5\Z
{%
- \xint@z #3\XINT@lws@end\Z
- \XINT@lws@loop@b {#1}{#2#3}{#2}%
+ \expandafter\space\the\numexpr #1#2#3#4\relax
}%
-\long\def\XINT@lws@loop@b #1#2{\XINT@lws@loop@a {#1#2}}%
-\long\def\XINT@lws@end\Z\XINT@lws@loop@b #1#2#3{ #1}%
+\def\xint@cuz@endb\Z\XINT@cuz@checka #1{ 0}%
+\def\XINT@cuz@checka #1%
+{%
+ \expandafter \XINT@cuz@checkb \the\numexpr #1\relax
+}%
+\def\XINT@cuz@checkb #1%
+{%
+ \xint@zero #1\xint@cuz@backtoloop 0\XINT@cuz@Stop #1%
+}%
+\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}}
+% Added in |1.03|. Attention: does not do any expansion.
+% \begin{macrocode}
+\def\XINT@isOne #1{\romannumeral0\XINT@isone #1\W\Z }%
+\def\XINT@isone #1#2%
+{%
+ \xint@one #1\XINT@isone@b 1\expandafter\space\expandafter 0\xint@z #2%
+}%
+\def\XINT@isone@b #1\xint@z #2%
+{%
+ \xint@w #2\XINT@isone@yes\W\expandafter\space\expandafter 0\xint@z
+}%
+\def\XINT@isone@yes #1\Z{ 1}%
+% \end{macrocode}
+% \subsection{\csh{xintNum}}
+% \begin{verbatim}
+% For example \xintNum {----+-+++---+----000000000000003}
+% 1.05 defines \xintiNum, which allows redefinition of \xintNum by xintfrac.sty
+% \end{verbatim}
+% \begin{macrocode}
+\def\xintiNum {\romannumeral0\xintinum }%
+\def\xintinum #1%
+{%
+ \expandafter\XINT@num\expandafter {\romannumeral-`0#1}%
+}%
+\let\xintNum\xintiNum \let\xintnum\xintinum
+\def\XINT@Num {\romannumeral0\XINT@num }%
+\def\XINT@num #1{\XINT@num@loop #1\R\R\R\R\R\R\R\R\Z }%
+\def\XINT@num@loop #1#2#3#4#5#6#7#8%
+{%
+ \xint@r #8\XINT@num@end\R\XINT@num@NumEight #1#2#3#4#5#6#7#8%
+}%
+\def\XINT@num@end\R\XINT@num@NumEight #1\R #2\Z
+{%
+ \expandafter\space\the\numexpr #1+0\relax
+}%
+\def\XINT@num@NumEight #1#2#3#4#5#6#7#8%
+{%
+ \ifnum \numexpr #1#2#3#4#5#6#7#8+0\relax = 0
+ \xint@afterfi {\expandafter\XINT@num@keepsign@a
+ \the\numexpr #1#2#3#4#5#6#7#81\relax}%
+ \else
+ \xint@afterfi {\expandafter\XINT@num@finish
+ \the\numexpr #1#2#3#4#5#6#7#8\relax}%
+ \fi
+}%
+\def\XINT@num@keepsign@a #1%
+{%
+ \xint@one#1\XINT@num@gobacktoloop 1\XINT@num@keepsign@b
+}%
+\def\XINT@num@gobacktoloop 1\XINT@num@keepsign@b {\XINT@num@loop }%
+\def\XINT@num@keepsign@b #1{\XINT@num@loop -}%
+\def\XINT@num@finish #1\R #2\Z { #1}%
% \end{macrocode}
% \subsection{\csh{xintSgn}}
% \begin{verbatim}
@@ -4637,8 +4953,7 @@ first place.
\def\xintiSgn {\romannumeral0\xintisgn }%
\def\xintisgn #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@sgn #1\Z%
+ \expandafter\XINT@sgn \romannumeral-`0#1\Z%
}%
\let\xintSgn\xintiSgn \let\xintsgn\xintisgn
\def\XINT@Sgn #1{\romannumeral0\XINT@sgn #1\Z }%
@@ -4656,18 +4971,16 @@ first place.
\def\xintiOpp {\romannumeral0\xintiopp }%
\def\xintiopp #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@opp #1%
+ \expandafter\XINT@opp \romannumeral-`0#1%
}%
\let\xintOpp\xintiOpp \let\xintopp\xintiopp
\def\XINT@Opp #1{\romannumeral0\XINT@opp #1}%
\def\XINT@opp #1%
{%
- \expandafter\space
\xint@UDzerominusfork
- #1-\dummy 0% zero
- 0#1\dummy {}% negative
- 0-\dummy {-#1}% positive
+ #1-\dummy { 0}% zero
+ 0#1\dummy { }% negative
+ 0-\dummy { -#1}% positive
\xint@UDkrof
}%
% \end{macrocode}
@@ -4676,15 +4989,14 @@ first place.
\def\xintiAbs {\romannumeral0\xintiabs }%
\def\xintiabs #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@abs #1%
+ \expandafter\XINT@abs \romannumeral-`0#1%
}%
\let\xintAbs\xintiAbs \let\xintabs\xintiabs
\def\XINT@Abs #1{\romannumeral0\XINT@abs #1}%
\def\XINT@abs #1%
{%
\xint@UDsignfork
- #1\dummy \space
+ #1\dummy { }%
-\dummy { #1}%
\xint@UDkrof
}%
@@ -4698,7 +5010,8 @@ first place.
% Release 1.03 re-organizes sub-routines to facilitate future developments: the
% diverse variants of addition, with diverse conditions on inputs and output are
% first listed; they will be used in multiplication, or in the summation, or in
-% the power routines.
+% the power routines. I am aware that the commenting is close to non-existent,
+% sorry about that.
%
% ADDITION
% I: \XINT@add@A
@@ -5119,16 +5432,12 @@ first place.
\def\xintiAdd {\romannumeral0\xintiadd }%
\def\xintiadd #1%
{%
- \expandafter\expandafter\expandafter
- \xint@add
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\xint@add\expandafter{\romannumeral-`0#1}%
}%
\let\xintAdd\xintiAdd \let\xintadd\xintiadd
\def\xint@add #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@add@fork #2\Z #1\Z
+ \expandafter\XINT@add@fork \romannumeral-`0#2\Z #1\Z
}%
\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 }%
@@ -5136,9 +5445,8 @@ first place.
% \vspace*{-.5\baselineskip}
% \begin{verbatim}
% ADDITION
-% Ici #1#2 vient du *deuxième* argument de \xintAdd
-% et #3#4 donc du *premier* [algo plus efficace lorsque
-% le premier est plus long que le second]
+% Ici #1#2 vient du *deuxième* argument de \xintAdd et #3#4 donc du *premier*
+% [algo plus efficace lorsque le premier est plus long que le second]
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
@@ -5185,9 +5493,8 @@ first place.
}%
\def\XINT@add@pre #1%
{%
- \expandafter\XINT@add@@pre\expandafter{%
- \romannumeral0\XINT@RQ {}#1\R\R\R\R\R\R\R\R\Z
- }%
+ \expandafter\XINT@add@@pre\expandafter
+ {\romannumeral0\XINT@RQ {}#1\R\R\R\R\R\R\R\R\Z }%
}%
\def\XINT@add@@pre #1#2%
{%
@@ -5202,16 +5509,12 @@ first place.
\def\xintiSub {\romannumeral0\xintisub }%
\def\xintisub #1%
{%
- \expandafter\expandafter\expandafter
- \xint@sub
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\xint@sub\expandafter{\romannumeral-`0#1}%
}%
\let\xintSub\xintiSub \let\xintsub\xintisub
\def\xint@sub #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@sub@fork #2\Z #1\Z
+ \expandafter\XINT@sub@fork \romannumeral-`0#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 }%
@@ -5262,9 +5565,8 @@ first place.
\def\xint@sub@pm #1\XINT@add@pre #2#3{ -#2}%
\def\XINT@sub@pre #1%
{%
- \expandafter\XINT@sub@@pre\expandafter{%
- \romannumeral0\XINT@RQ {}#1\R\R\R\R\R\R\R\R\Z
- }%
+ \expandafter\XINT@sub@@pre\expandafter
+ {\romannumeral0\XINT@RQ {}#1\R\R\R\R\R\R\R\R\Z }%
}%
\def\XINT@sub@@pre #1#2%
{%
@@ -5405,8 +5707,7 @@ first place.
}%
\def\XINT@sub@E #1#2#3#4#5#6%
{%
- \xint@w #3\xint@sub@F\W\XINT@sub@Eonestep
- #1{#6#5#4#3}{#2}%
+ \xint@w #3\xint@sub@F\W\XINT@sub@Eonestep #1{#6#5#4#3}{#2}%
}%
\def\XINT@sub@Eonestep #1#2%
{%
@@ -5428,9 +5729,8 @@ first place.
\def\XINT@sub@DD {\expandafter\xint@minus@andstop\romannumeral0\XINT@sub@D }%
\def\XINT@sub@Fdec #1#2#3#4#5#6%
{%
- \xint@w
- #3\xint@sub@Fdec@finish\W\XINT@sub@Fdec@onestep
- #1{#6#5#4#3}{#2}%
+ \xint@w #3\xint@sub@Fdec@finish\W
+ \XINT@sub@Fdec@onestep #1{#6#5#4#3}{#2}%
}%
\def\XINT@sub@Fdec@onestep #1#2%
{%
@@ -5446,9 +5746,8 @@ first place.
}%
\def\XINT@sub@Finc #1#2#3#4#5#6%
{%
- \xint@w
- #3\xint@sub@Finc@finish\W\XINT@sub@Finc@onestep
- #1{#6#5#4#3}{#2}%
+ \xint@w #3\xint@sub@Finc@finish\W
+ \XINT@sub@Finc@onestep #1{#6#5#4#3}{#2}%
}%
\def\XINT@sub@Finc@onestep #1#2%
{%
@@ -5461,8 +5760,7 @@ first place.
\def\xint@sub@Finc@finish\W\XINT@sub@Finc@onestep #1#2#3%
{%
\xint@UDzerofork
- #1\dummy {\expandafter\xint@minus@andstop%
- \xint@cleanupzeros@nospace}%
+ #1\dummy {\expandafter\xint@minus@andstop\xint@cleanupzeros@nospace}%
0\dummy { -1}%
\xint@UDkrof
#3%
@@ -5474,8 +5772,7 @@ first place.
0\dummy \XINT@sub@L % pas de retenue
\xint@UDkrof
}%
-\def\XINT@sub@L #1\W\X\Y\Z
- {\XINT@cuz@loop #1\W\W\W\W\W\W\W\Z }%
+\def\XINT@sub@L #1\W\X\Y\Z {\XINT@cuz@loop #1\W\W\W\W\W\W\W\Z }%
\def\XINT@sub@K #1%
{%
\expandafter
@@ -5489,9 +5786,8 @@ first place.
}%
\def\XINT@sub@KK #1#2#3#4#5#6%
{%
- \xint@w
- #3\xint@sub@KK@finish\W\XINT@sub@KK@onestep
- #1{#6#5#4#3}{#2}%
+ \xint@w #3\xint@sub@KK@finish\W
+ \XINT@sub@KK@onestep #1{#6#5#4#3}{#2}%
}%
\def\XINT@sub@KK@onestep #1#2%
{%
@@ -5503,8 +5799,8 @@ first place.
}%
\def\xint@sub@KK@finish\W\XINT@sub@KK@onestep #1#2#3%
{%
- \expandafter\xint@minus@andstop\romannumeral
- 0\XINT@cuz@loop #3\W\W\W\W\W\W\W\Z
+ \expandafter\xint@minus@andstop
+ \romannumeral0\XINT@cuz@loop #3\W\W\W\W\W\W\W\Z
}%
% \end{macrocode}
% \subsection{\csh{xintCmp}}
@@ -5512,16 +5808,12 @@ first place.
\def\xintiCmp {\romannumeral0\xinticmp }%
\def\xinticmp #1%
{%
- \expandafter\expandafter\expandafter
- \xint@cmp
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\xint@cmp\expandafter{\romannumeral-`0#1}%
}%
\let\xintCmp\xintiCmp \let\xintcmp\xinticmp
\def\xint@cmp #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@cmp@fork #2\Z #1\Z
+ \expandafter\XINT@cmp@fork \romannumeral-`0#2\Z #1\Z
}%
\def\XINT@Cmp #1#2{\romannumeral0\XINT@cmp@fork #2\Z #1\Z }%
% \end{macrocode}
@@ -5564,9 +5856,8 @@ first place.
}%
\def\XINT@cmp@pre #1%
{%
- \expandafter\XINT@cmp@@pre\expandafter{%
- \romannumeral0\XINT@RQ {}#1\R\R\R\R\R\R\R\R\Z
- }%
+ \expandafter\XINT@cmp@@pre\expandafter
+ {\romannumeral0\XINT@RQ {}#1\R\R\R\R\R\R\R\R\Z }%
}%
\def\XINT@cmp@@pre #1#2%
{%
@@ -5589,15 +5880,11 @@ first place.
% \begin{macrocode}
\def\XINT@cmp@A #1#2#3\W\X\Y\Z #4#5#6#7%
{%
- \xint@w
- #4\xint@cmp@az
- \W\XINT@cmp@B #1{#4#5#6#7}{#2}#3\W\X\Y\Z
+ \xint@w #4\xint@cmp@az\W\XINT@cmp@B #1{#4#5#6#7}{#2}#3\W\X\Y\Z
}%
\def\XINT@cmp@B #1#2#3#4#5#6#7%
{%
- \xint@w
- #4\xint@cmp@bz
- \W\XINT@cmp@onestep #1#2{#7#6#5#4}{#3}%
+ \xint@w#4\xint@cmp@bz\W\XINT@cmp@onestep #1#2{#7#6#5#4}{#3}%
}%
\def\XINT@cmp@onestep #1#2#3#4#5#6%
{%
@@ -5607,13 +5894,10 @@ first place.
{%
\XINT@cmp@A #2{#3#4}%
}%
-\def\xint@cmp@bz
- \W\XINT@cmp@onestep #1\Z { 1}%
+\def\xint@cmp@bz\W\XINT@cmp@onestep #1\Z { 1}%
\def\xint@cmp@az\W\XINT@cmp@B #1#2#3#4#5#6#7%
{%
- \xint@w
- #4\xint@cmp@ez
- \W\XINT@cmp@Eenter #1{#3}#4#5#6#7%
+ \xint@w #4\xint@cmp@ez\W\XINT@cmp@Eenter #1{#3}#4#5#6#7%
}%
\def\XINT@cmp@Eenter #1\Z { -1}%
\def\xint@cmp@ez\W\XINT@cmp@Eenter #1%
@@ -5631,19 +5915,18 @@ first place.
}%
\def\XINT@OneIfPositive@main #1#2#3#4%
{%
- \xint@z #4\xint@OneIfPositive@terminated\Z\XINT@OneIfPositive@onestep
- #1#2#3#4%
+ \xint@z #4\xint@OneIfPositive@terminated\Z
+ \XINT@OneIfPositive@onestep #1#2#3#4%
}%
\def\xint@OneIfPositive@terminated\Z\XINT@OneIfPositive@onestep\W\X\Y\Z { 0}%
\def\XINT@OneIfPositive@onestep #1#2#3#4%
{%
- \expandafter\XINT@OneIfPositive@check
- \the\numexpr #1#2#3#4\relax
+ \expandafter\XINT@OneIfPositive@check\the\numexpr #1#2#3#4\relax
}%
\def\XINT@OneIfPositive@check #1%
{%
- \xint@zero
- #1\xint@OneIfPositive@backtomain 0\XINT@OneIfPositive@finish #1%
+ \xint@zero #1\xint@OneIfPositive@backtomain 0%
+ \XINT@OneIfPositive@finish #1%
}%
\def\XINT@OneIfPositive@finish #1\W\X\Y\Z{ 1}%
\def\xint@OneIfPositive@backtomain 0\XINT@OneIfPositive@finish 0%
@@ -5659,15 +5942,12 @@ first place.
\def\xintiGeq {\romannumeral0\xintigeq }%
\def\xintigeq #1%
{%
- \expandafter\expandafter\expandafter
- \xint@geq
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\xint@geq\expandafter {\romannumeral-`0#1}%
}%
\let\xintGeq\xintiGeq \let\xintgeq\xintigeq
\def\xint@geq #1#2%
{%
- \expandafter\expandafter\expandafter\XINT@geq@fork #2\Z #1\Z
+ \expandafter\XINT@geq@fork \romannumeral-`0#2\Z #1\Z
}%
\def\XINT@Geq #1#2{\romannumeral0\XINT@geq@fork #2\Z #1\Z }%
% \end{macrocode}
@@ -5694,19 +5974,14 @@ first place.
}%
\def\XINT@geq@secondiszero #1#2#3#4{ 1}%
\def\XINT@geq@firstiszero #1#2#3#4{ 0}%
-\def\XINT@geq@plusplus #1#2#3#4%
- {\XINT@geq@pre {#4#2}{#3#1}}%
-\def\XINT@geq@minusminus #1#2#3#4%
- {\XINT@geq@pre {#2}{#1}}%
-\def\XINT@geq@minusplus #1#2#3#4%
- {\XINT@geq@pre {#4#2}{#1}}%
-\def\XINT@geq@plusminus #1#2#3#4%
- {\XINT@geq@pre {#2}{#3#1}}%
+\def\XINT@geq@plusplus #1#2#3#4{\XINT@geq@pre {#4#2}{#3#1}}%
+\def\XINT@geq@minusminus #1#2#3#4{\XINT@geq@pre {#2}{#1}}%
+\def\XINT@geq@minusplus #1#2#3#4{\XINT@geq@pre {#4#2}{#1}}%
+\def\XINT@geq@plusminus #1#2#3#4{\XINT@geq@pre {#2}{#3#1}}%
\def\XINT@geq@pre #1%
{%
- \expandafter\XINT@geq@@pre\expandafter{%
- \romannumeral0\XINT@RQ {}#1\R\R\R\R\R\R\R\R\Z
- }%
+ \expandafter\XINT@geq@@pre\expandafter
+ {\romannumeral0\XINT@RQ {}#1\R\R\R\R\R\R\R\R\Z }%
}%
\def\XINT@geq@@pre #1#2%
{%
@@ -5730,15 +6005,11 @@ first place.
% \begin{macrocode}
\def\XINT@geq@A #1#2#3\W\X\Y\Z #4#5#6#7%
{%
- \xint@w
- #4\xint@geq@az
- \W\XINT@geq@B #1{#4#5#6#7}{#2}#3\W\X\Y\Z
+ \xint@w #4\xint@geq@az\W\XINT@geq@B #1{#4#5#6#7}{#2}#3\W\X\Y\Z
}%
\def\XINT@geq@B #1#2#3#4#5#6#7%
{%
- \xint@w
- #4\xint@geq@bz
- \W\XINT@geq@onestep #1#2{#7#6#5#4}{#3}%
+ \xint@w #4\xint@geq@bz\W\XINT@geq@onestep #1#2{#7#6#5#4}{#3}%
}%
\def\XINT@geq@onestep #1#2#3#4#5#6%
{%
@@ -5751,9 +6022,7 @@ first place.
\def\xint@geq@bz\W\XINT@geq@onestep #1\W\X\Y\Z { 1}%
\def\xint@geq@az\W\XINT@geq@B #1#2#3#4#5#6#7%
{%
- \xint@w
- #4\xint@geq@ez
- \W\XINT@geq@Eenter #1%
+ \xint@w #4\xint@geq@ez\W\XINT@geq@Eenter #1%
}%
\def\XINT@geq@Eenter #1\W\X\Y\Z { 0}%
\def\xint@geq@ez\W\XINT@geq@Eenter #1%
@@ -5774,17 +6043,12 @@ first place.
\def\xintiMax {\romannumeral0\xintimax }%
\def\xintimax #1%
{%
- \expandafter\expandafter\expandafter
- \xint@max
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\xint@max\expandafter {\romannumeral-`0#1}%
}%
\let\xintMax\xintiMax \let\xintmax\xintimax
\def\xint@max #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@max@pre
- \expandafter\expandafter\expandafter {#2}{#1}%
+ \expandafter\XINT@max@pre\expandafter {\romannumeral-`0#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}}%
@@ -5852,17 +6116,12 @@ first place.
\def\xintiMin {\romannumeral0\xintimin }%
\def\xintimin #1%
{%
- \expandafter\expandafter\expandafter
- \xint@min
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\xint@min\expandafter {\romannumeral-`0#1}%
}%
\let\xintMin\xintiMin \let\xintmin\xintimin
\def\xint@min #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@min@pre
- \expandafter\expandafter\expandafter {#2}{#1}%
+ \expandafter\XINT@min@pre\expandafter {\romannumeral-`0#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}}%
@@ -5901,7 +6160,7 @@ first place.
\def\XINT@min@pluszero #1#2#3#4{\xint@firstoftwo@andstop }%
\def\XINT@min@minusplus #1#2#3#4{\xint@secondoftwo@andstop }%
\def\XINT@min@plusminus #1#2#3#4{\xint@firstoftwo@andstop }%
-\def\XINT@min@plusplus #1#2#3#4%
+\def\XINT@min@plusplus #1#2#3#4%
{%
\ifodd\XINT@Geq {#4#2}{#3#1}
\expandafter\xint@secondoftwo@andstop
@@ -5940,16 +6199,13 @@ first place.
\def\xintiSum {\romannumeral0\xintisum }%
\def\xintisum #1{\xintisumexpr #1\relax }%
\def\xintiSumExpr {\romannumeral0\xintisumexpr }%
-\def\xintisumexpr
-{%
- \expandafter\expandafter\expandafter\XINT@sumexpr
-}%
+\def\xintisumexpr {\expandafter\XINT@sumexpr\romannumeral-`0}%
\let\xintSum\xintiSum \let\xintsum\xintisum
\let\xintSumExpr\xintiSumExpr \let\xintsumexpr\xintisumexpr
\def\XINT@sumexpr {\XINT@sum@loop {0000}{0000}}%
\def\XINT@sum@loop #1#2#3%
{%
- \expandafter\expandafter\expandafter\XINT@sum@checksign #3\Z {#1}{#2}%
+ \expandafter\XINT@sum@checksign\romannumeral-`0#3\Z {#1}{#2}%
}%
\def\XINT@sum@checksign #1%
{%
@@ -5988,15 +6244,12 @@ first place.
\def\xintiMul {\romannumeral0\xintimul }%
\def\xintimul #1%
{%
- \expandafter\expandafter\expandafter
- \xint@mul
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\xint@mul\expandafter {\romannumeral-`0#1}%
}%
\let\xintMul\xintiMul \let\xintmul\xintimul
\def\xint@mul #1#2%
-{\expandafter\expandafter\expandafter
- \XINT@mul@fork #2\Z #1\Z
+{%
+ \expandafter\XINT@mul@fork \romannumeral-`0#2\Z #1\Z
}%
\def\XINT@Mul #1#2{\romannumeral0\XINT@mul@fork #2\Z #1\Z }%
% \end{macrocode}
@@ -6040,17 +6293,17 @@ first place.
}%
\def\XINT@mul@minusplus #1#2#3%
{%
- \expandafter\xint@minus@andstop\romannumeral0\expandafter
- \XINT@mul@choice@a
- \expandafter{\romannumeral0\XINT@length {#1#3}}%
- {\romannumeral0\XINT@length {#2}}{#2}{#1#3}%
+ \expandafter\xint@minus@andstop\romannumeral0\expandafter
+ \XINT@mul@choice@a
+ \expandafter{\romannumeral0\XINT@length {#1#3}}%
+ {\romannumeral0\XINT@length {#2}}{#2}{#1#3}%
}%
\def\XINT@mul@plusminus #1#2#3%
{%
- \expandafter\xint@minus@andstop\romannumeral0\expandafter
- \XINT@mul@choice@a
- \expandafter{\romannumeral0\XINT@length {#3}}%
- {\romannumeral0\XINT@length {#1#2}}{#1#2}{#3}%
+ \expandafter\xint@minus@andstop\romannumeral0\expandafter
+ \XINT@mul@choice@a
+ \expandafter{\romannumeral0\XINT@length {#3}}%
+ {\romannumeral0\XINT@length {#1#2}}{#1#2}{#3}%
}%
\def\XINT@mul@plusplus #1#2#3#4%
{%
@@ -6098,38 +6351,20 @@ first place.
}%
\def\XINT@mul@choice@i #1#2%
{%
- \ifcase \numexpr (#2-3)/4\relax
- \or \xint@afterfi {\ifnum #1<330 \expandafter \XINT@mul@choice@same
- \else \expandafter \XINT@mul@choice@permute \fi}%
- \or \xint@afterfi {\ifnum #1<168 \expandafter \XINT@mul@choice@same
- \else \expandafter \XINT@mul@choice@permute \fi}%
- \or \xint@afterfi {\ifnum #1<109 \expandafter \XINT@mul@choice@same
- \else \expandafter \XINT@mul@choice@permute \fi}%
- \or \xint@afterfi {\ifnum #1<80 \expandafter \XINT@mul@choice@same
- \else \expandafter \XINT@mul@choice@permute \fi}%
- \or \xint@afterfi {\ifnum #1<66 \expandafter \XINT@mul@choice@same
- \else \expandafter \XINT@mul@choice@permute \fi}%
- \or \xint@afterfi {\ifnum #1<52 \expandafter \XINT@mul@choice@same
- \else \expandafter \XINT@mul@choice@permute \fi}%
- \else \expandafter \XINT@mul@choice@permute
+ \ifnum #1<\numexpr\ifcase \numexpr (#2-3)/4\relax
+ \or 330\or 168\or 109\or 80\or 66\or 52\else 0\fi\relax
+ \expandafter\XINT@mul@choice@same
+ \else
+ \expandafter\XINT@mul@choice@permute
\fi
}%
\def\XINT@mul@choice@ii #1#2%
{%
- \ifcase \numexpr (#1-3)/4\relax
- \or \xint@afterfi {\ifnum #2<330 \expandafter \XINT@mul@choice@permute
- \else \expandafter \XINT@mul@choice@same \fi}%
- \or \xint@afterfi {\ifnum #2<168 \expandafter \XINT@mul@choice@permute
- \else \expandafter \XINT@mul@choice@same \fi}%
- \or \xint@afterfi {\ifnum #2<109 \expandafter \XINT@mul@choice@permute
- \else \expandafter \XINT@mul@choice@same \fi}%
- \or \xint@afterfi {\ifnum #2<80 \expandafter \XINT@mul@choice@permute
- \else \expandafter \XINT@mul@choice@same \fi}%
- \or \xint@afterfi {\ifnum #2<66 \expandafter \XINT@mul@choice@permute
- \else \expandafter \XINT@mul@choice@same \fi}%
- \or \xint@afterfi {\ifnum #2<52 \expandafter \XINT@mul@choice@permute
- \else \expandafter \XINT@mul@choice@same \fi}%
- \else \expandafter \XINT@mul@choice@same
+ \ifnum #2<\numexpr\ifcase \numexpr (#1-3)/4\relax
+ \or 330\or 168\or 109\or 80\or 66\or 52\else 0\fi\relax
+ \expandafter\XINT@mul@choice@permute
+ \else
+ \expandafter\XINT@mul@choice@same
\fi
}%
\def\XINT@mul@choice@same #1#2%
@@ -6184,8 +6419,7 @@ first place.
% \begin{macrocode}
\def\XINT@mul@Mr #1%
{%
- \expandafter\XINT@mul@Mr@checkifzeroorone
- \expandafter{\the\numexpr #1}%
+ \expandafter\XINT@mul@Mr@checkifzeroorone\expandafter{\the\numexpr #1}%
}%
\def\XINT@mul@Mr@checkifzeroorone #1%
{%
@@ -6214,8 +6448,8 @@ first place.
}%
\def\xint@mul@pr\Z\XINT@mul@Pr #1#2#3#4#5%
{%
- \xint@quatrezeros #1\XINT@mul@Mr@end@nocarry 0000\XINT@mul@Mr@end@carry
- #1{#4}%
+ \xint@quatrezeros #1\XINT@mul@Mr@end@nocarry 0000%
+ \XINT@mul@Mr@end@carry #1{#4}%
}%
\def\XINT@mul@Mr@end@nocarry 0000\XINT@mul@Mr@end@carry 0000#1{ #1}%
\def\XINT@mul@Mr@end@carry #1#2#3#4#5{ #5#4#3#2#1}%
@@ -6232,8 +6466,7 @@ first place.
% \begin{macrocode}
\def\XINT@mul@M #1%
{%
- \expandafter\XINT@mul@M@checkifzeroorone
- \expandafter{\the\numexpr #1}%
+ \expandafter\XINT@mul@M@checkifzeroorone\expandafter{\the\numexpr #1}%
}%
\def\XINT@mul@M@checkifzeroorone #1%
{%
@@ -6249,8 +6482,7 @@ first place.
\def\XINT@mul@M@zero #1\Z\Z\Z\Z { 0}%
\def\XINT@mul@M@one #1#2#3#4\Z\Z\Z\Z
{%
- \expandafter\xint@cleanupzeros@andstop
- \romannumeral0\XINT@rev{#4}%
+ \expandafter\xint@cleanupzeros@andstop\romannumeral0\XINT@rev{#4}%
}%
\def\XINT@mul@N #1#2#3#4#5#6#7%
{%
@@ -6485,10 +6717,7 @@ first place.
\def\xintiSqr {\romannumeral0\xintisqr }%
\def\xintisqr #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@sqr
- \expandafter\expandafter\expandafter
- {\xintiAbs{#1}}% fait l'expansion de #1 et se d\'ebarrasse du signe
+ \expandafter\XINT@sqr\expandafter {\romannumeral0\xintiabs{#1}}%
}%
\let\xintSqr\xintiSqr \let\xintsqr\xintisqr
\def\XINT@sqr #1%
@@ -6526,16 +6755,13 @@ first place.
\let\xintPrd\xintiPrd
\let\xintprd\xintiprd
\def\xintiProductExpr {\romannumeral0\xintiproductexpr }%
-\def\xintiproductexpr
-{%
- \expandafter\expandafter\expandafter\XINT@productexpr
-}%
+\def\xintiproductexpr {\expandafter\XINT@productexpr\romannumeral-`0}%
\let\xintProductExpr\xintiProductExpr
\let\xintproductexpr\xintiproductexpr
\def\XINT@productexpr {\XINT@prod@loop@a 1\Z }%
\def\XINT@prod@loop@a #1\Z #2%
{%
- \expandafter\expandafter\expandafter\XINT@prod@loop@b #2\Z #1\Z \Z
+ \expandafter\XINT@prod@loop@b \romannumeral-`0#2\Z #1\Z \Z
}%
\def\XINT@prod@loop@b #1%
{%
@@ -6563,12 +6789,8 @@ first place.
\def\xintFac {\romannumeral0\xintfac }%
\def\xintfac #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@fac@fork
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\XINT@fac@fork\expandafter{\the\numexpr #1}%
}%
-\def\XINT@Fac {\romannumeral0\XINT@fac@fork }%
\def\XINT@fac@fork #1%
{%
\ifcase\XINT@Sgn {#1}
@@ -6583,7 +6805,7 @@ first place.
}%
\def\XINT@fac@checklength #1%
{%
- \ifnum\numexpr #1\relax>999999
+ \ifnum #1>999999
\xint@afterfi{\expandafter\xintError:FactorialOfTooBigNumber
\expandafter\space\expandafter 1\xint@gobble }%
\else
@@ -6652,15 +6874,16 @@ first place.
% 1.02 modified the \XINT@posprod routine, and this meant that the original
% version was moved here and renamed to \XINT@pow@posprod, as it was well
% 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.
+% 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.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintiPow {\romannumeral0\xintipow }%
\def\xintipow #1%
{%
- \expandafter\expandafter\expandafter\xint@pow
- #1\Z%
+ \expandafter\xint@pow\romannumeral-`0#1\Z%
}%
\let\xintPow\xintiPow \let\xintpow\xintipow
\def\xint@pow #1#2\Z
@@ -6673,22 +6896,12 @@ first place.
}%
\def\XINT@pow@Aneg #1#2#3%
{%
- \expandafter\expandafter\expandafter
- \XINT@pow@Aneg@
- \expandafter\expandafter\expandafter
- {#3}{#2}%
+ \expandafter\XINT@pow@Aneg@\expandafter{\the\numexpr #3}{#2}%
}%
-% \end{macrocode}
-% \vspace*{-.5\baselineskip}
-% \begin{verbatim}
-% B = #1, xpxp déjà fait
-% \end{verbatim}
-% \vspace*{-1.5\baselineskip}
-% \begin{macrocode}
\def\XINT@pow@Aneg@ #1%
{%
- \ifcase\XINT@Odd{#1}
- \or \expandafter\XINT@pow@Aneg@Bodd
+ \ifodd #1
+ \expandafter\XINT@pow@Aneg@Bodd
\fi
\XINT@pow@Anonneg@ {#1}%
}%
@@ -6699,16 +6912,13 @@ first place.
% \end{macrocode}
% \vspace*{-.5\baselineskip}
% \begin{verbatim}
-% B = #3, faire le xpxp
+% B = #3, faire le xpxp. Modified with 1.06: use of \numexpr.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\XINT@pow@Anonneg #1#2#3%
{%
- \expandafter\expandafter\expandafter
- \XINT@pow@Anonneg@
- \expandafter\expandafter\expandafter
- {#3}{#1#2}%
+ \expandafter\XINT@pow@Anonneg@\expandafter {\the\numexpr #3}{#1#2}%
}%
% \end{macrocode}
% \vspace*{-.5\baselineskip}
@@ -6763,13 +6973,14 @@ first place.
% \vspace*{-.5\baselineskip}
% \begin{verbatim}
% B = #1 > 0, A = #2 > 1. With 1.05, I replace \xintiLen{#1}>9 by direct use
-% of \numexpr.
+% of \numexpr [to generate an error message if the exponent is too large]
+% 1.06: \numexpr was already used above.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\XINT@pow@checkBlength #1#2%
{%
- \ifnum\numexpr #1\relax >999999999
+ \ifnum #1>999999999
\expandafter\XINT@pow@BtooBig
\else
\expandafter\XINT@pow@loop
@@ -6875,16 +7086,12 @@ first place.
\def\xintiDivision {\romannumeral0\xintidivision }%
\def\xintidivision #1%
{%
- \expandafter\expandafter\expandafter
- \xint@division
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\xint@division\expandafter {\romannumeral-`0#1}%
}%
\let\xintDivision\xintiDivision \let\xintdivision\xintidivision
\def\xint@division #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@div@fork #2\Z #1\Z
+ \expandafter\XINT@div@fork \romannumeral-`0#2\Z #1\Z
}%
\def\XINT@Division #1#2{\romannumeral0\XINT@div@fork #2\Z #1\Z }%
% \end{macrocode}
@@ -7024,14 +7231,13 @@ first place.
\ifnum #2=1
\expandafter\XINT@div@prepareB@BisOne
\else
- \xint@afterfi{\XINT@div@prepareB@e {000}{3}{4}{#2}}%
- \fi
+ \expandafter\XINT@div@prepareB@e
+ \fi {000}{3}{4}{#2}%
}%
-\def\XINT@div@prepareB@BisOne #1{ {#1}{0}}%
+\def\XINT@div@prepareB@BisOne #1#2#3#4#5{ {#5}{0}}%
\def\XINT@div@prepareB@a #1%
{%
- \expandafter \XINT@div@prepareB@b \expandafter
- {\the\numexpr 4*((#1+1)/4)}{#1}%
+ \expandafter\XINT@div@prepareB@c\expandafter{\the\numexpr 4*((#1+1)/4)}{#1}%
}%
% \end{macrocode}
% \vspace*{-.5\baselineskip}
@@ -7040,31 +7246,22 @@ first place.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
-\def\XINT@div@prepareB@b #1#2%
+\def\XINT@div@prepareB@c #1#2%
{%
- \expandafter \XINT@div@prepareB@c \expandafter
- {\the\numexpr #1-#2}{#1}%
-}%
-% \end{macrocode}
-% \vspace*{-.5\baselineskip}
-% \begin{verbatim}
-% #1 = c
-% \end{verbatim}
-% \vspace*{-1.5\baselineskip}
-% \begin{macrocode}
-\def\XINT@div@prepareB@c #1%
-{%
- \ifcase #1
- \expandafter\XINT@div@prepareB@di
- \or \expandafter\XINT@div@prepareB@dii
- \or \expandafter\XINT@div@prepareB@diii
- \else \expandafter\XINT@div@prepareB@div
- \fi
+ \ifcase \numexpr #1-#2\relax
+ \expandafter\XINT@div@prepareB@d
+ \or
+ \expandafter\XINT@div@prepareB@di
+ \or
+ \expandafter\XINT@div@prepareB@dii
+ \or
+ \expandafter\XINT@div@prepareB@diii
+ \fi {#1}%
}%
-\def\XINT@div@prepareB@di {\XINT@div@prepareB@e {}{0}}%
-\def\XINT@div@prepareB@dii {\XINT@div@prepareB@e {0}{1}}%
-\def\XINT@div@prepareB@diii {\XINT@div@prepareB@e {00}{2}}%
-\def\XINT@div@prepareB@div {\XINT@div@prepareB@e {000}{3}}%
+\def\XINT@div@prepareB@d {\XINT@div@prepareB@e {}{0}}%
+\def\XINT@div@prepareB@di {\XINT@div@prepareB@e {0}{1}}%
+\def\XINT@div@prepareB@dii {\XINT@div@prepareB@e {00}{2}}%
+\def\XINT@div@prepareB@diii {\XINT@div@prepareB@e {000}{3}}%
% \end{macrocode}
% \vspace*{-.5\baselineskip}
% \begin{verbatim}
@@ -7124,8 +7321,7 @@ first place.
% \begin{macrocode}
\def\XINT@div@prepareA@b #1%
{%
- \expandafter\XINT@div@prepareA@c\expandafter
- {\the\numexpr 4*((#1+1)/4)}{#1}%
+ \expandafter\XINT@div@prepareA@c\expandafter{\the\numexpr 4*((#1+1)/4)}{#1}%
}%
% \end{macrocode}
% \vspace*{-.5\baselineskip}
@@ -7136,22 +7332,20 @@ first place.
% \begin{macrocode}
\def\XINT@div@prepareA@c #1#2%
{%
- \expandafter\XINT@div@prepareA@d \expandafter
- {\the\numexpr #1-#2}{#1}%
-}%
-\def\XINT@div@prepareA@d #1%
-{%
- \ifcase #1
- \expandafter\XINT@div@prepareA@di
- \or \expandafter\XINT@div@prepareA@dii
- \or \expandafter\XINT@div@prepareA@diii
- \else \expandafter\XINT@div@prepareA@div
- \fi
+ \ifcase \numexpr #1-#2\relax
+ \expandafter\XINT@div@prepareA@d
+ \or
+ \expandafter\XINT@div@prepareA@di
+ \or
+ \expandafter\XINT@div@prepareA@dii
+ \or
+ \expandafter\XINT@div@prepareA@diii
+ \fi {#1}%
}%
-\def\XINT@div@prepareA@di {\XINT@div@prepareA@e {}}%
-\def\XINT@div@prepareA@dii {\XINT@div@prepareA@e {0}}%
-\def\XINT@div@prepareA@diii {\XINT@div@prepareA@e {00}}%
-\def\XINT@div@prepareA@div {\XINT@div@prepareA@e {000}}%
+\def\XINT@div@prepareA@d {\XINT@div@prepareA@e {}}%
+\def\XINT@div@prepareA@di {\XINT@div@prepareA@e {0}}%
+\def\XINT@div@prepareA@dii {\XINT@div@prepareA@e {00}}%
+\def\XINT@div@prepareA@diii {\XINT@div@prepareA@e {000}}%
% \end{macrocode}
% \vspace*{-.5\baselineskip}
% \begin{verbatim}
@@ -7191,8 +7385,7 @@ first place.
% \begin{macrocode}
\def\XINT@div@finished@a #1#2#3%
{%
- \expandafter \XINT@div@finished@b \expandafter
- {\romannumeral0\XINT@cuz {#1}}%
+ \expandafter\XINT@div@finished@b\expandafter {\romannumeral0\XINT@cuz {#1}}%
}%
% \end{macrocode}
% \vspace*{-.5\baselineskip}
@@ -7207,16 +7400,15 @@ first place.
\ifcase \XINT@Sgn {#1}
\xint@afterfi {\XINT@div@finished@c {0}}%
\or
- \xint@afterfi {\expandafter\XINT@div@finished@c
- \expandafter
- {\romannumeral0\XINT@dsh@checksignx #5\Z {#1}}}%
+ \xint@afterfi {\expandafter\XINT@div@finished@c\expandafter
+ {\romannumeral0\XINT@dsh@checksignx #5\Z {#1}}%
+ }%
\fi
{#2}%
}%
\def\XINT@div@finished@c #1#2%
{%
- \expandafter\space\expandafter
- {\romannumeral0\XINT@rev@andcuz {#2}}{#1}%
+ \expandafter\space\expandafter {\romannumeral0\XINT@rev@andcuz {#2}}{#1}%
}%
% \end{macrocode}
% \vspace*{-.5\baselineskip}
@@ -7302,14 +7494,14 @@ first place.
\XINT@div@final@f {#1}%
{\romannumeral0\XINT@add@A 0{}#2000\W\X\Y\Z #4\W\X\Y\Z }%
}%
-\def\XINT@div@final@f #1#2#3% R,Q à développer,c
+\def\XINT@div@final@f #1#2#3% R,Q \`a d\'evelopper,c
{%
\ifcase \XINT@Sgn {#1}
\xint@afterfi {\XINT@div@final@end {0}}%
\or
- \xint@afterfi {\expandafter\XINT@div@final@end
- \expandafter % pas de leading zeros dans #1=R
- {\romannumeral0\XINT@dsh@checksignx #3\Z {#1}}}%
+ \xint@afterfi {\expandafter\XINT@div@final@end\expandafter
+ {\romannumeral0\XINT@dsh@checksignx #3\Z {#1}}%
+ }%
\fi
{#2}%
}%
@@ -7457,8 +7649,7 @@ first place.
\def\XINT@div@body@l #1#2#3#4#5#6#7%
{%
\expandafter\XINT@div@body@m
- \the\numexpr 100000000+#2\relax
- {#6}{#3}{#7}{#1#5}{#4}%
+ \the\numexpr 100000000+#2\relax {#6}{#3}{#7}{#1#5}{#4}%
}%
% \end{macrocode}
% \vspace*{-.5\baselineskip}
@@ -7674,7 +7865,7 @@ first place.
\def\xintiFDg {\romannumeral0\xintifdg }%
\def\xintifdg #1%
{%
- \expandafter\expandafter\expandafter\XINT@fdg #1\W\Z
+ \expandafter\XINT@fdg \romannumeral-`0#1\W\Z
}%
\let\xintFDg\xintiFDg \let\xintfdg\xintifdg
\def\XINT@FDg #1{\romannumeral0\XINT@fdg #1\W\Z }%
@@ -7697,10 +7888,7 @@ first place.
\def\xintiLDg {\romannumeral0\xintildg }%
\def\xintildg #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@ldg
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\XINT@ldg\expandafter {\romannumeral-`0#1}%
}%
\let\xintLDg\xintiLDg \let\xintldg\xintildg
\def\XINT@LDg #1{\romannumeral0\XINT@ldg {#1}}%
@@ -7772,7 +7960,7 @@ first place.
\def\xintDSL {\romannumeral0\xintdsl }%
\def\xintdsl #1%
{%
- \expandafter\expandafter\expandafter\XINT@dsl #1\Z
+ \expandafter\XINT@dsl \romannumeral-`0#1\Z
}%
\def\XINT@DSL #1{\romannumeral0\XINT@dsl #1\Z }%
\def\XINT@dsl #1%
@@ -7791,16 +7979,12 @@ first place.
\def\xintDSR {\romannumeral0\xintdsr }%
\def\xintdsr #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@dsr@a
- \expandafter\expandafter\expandafter
- {#1}\W\Z
+ \expandafter\XINT@dsr@a\expandafter {\romannumeral-`0#1}\W\Z
}%
\def\XINT@DSR #1{\romannumeral0\XINT@dsr@a {#1}\W\Z }%
\def\XINT@dsr@a
{%
- \expandafter\XINT@dsr@b
- \romannumeral0\XINT@rev
+ \expandafter\XINT@dsr@b\romannumeral0\XINT@rev
}%
\def\XINT@dsr@b #1#2#3\Z
{%
@@ -7821,13 +8005,15 @@ first place.
% si x > 0, et A < 0, fait A -> -quo(-A,10^(x))
% (donc pour x > 0 c'est comme DSR itéré x fois)
% \xintDSHr donne le `reste' (si x<=0 donne zéro).
+% Release 1.06 now feeds x to a \numexpr first. I will revise the legacy code on
+% another occasion.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintDSHr {\romannumeral0\xintdshr }%
\def\xintdshr #1%
{%
- \expandafter\expandafter\expandafter\XINT@dshr@checkxpositive #1\Z
+ \expandafter\XINT@dshr@checkxpositive \the\numexpr #1\relax\Z
}%
\def\XINT@dshr@checkxpositive #1%
{%
@@ -7840,21 +8026,16 @@ first place.
\def\XINT@dshr@xzeroorneg #1\Z #2{ 0}%
\def\XINT@dshr@xpositive #1\Z
{%
- \expandafter\xint@secondoftwo@andstop
- \romannumeral0\xintdsx {#1}%
+ \expandafter\xint@secondoftwo@andstop\romannumeral0\xintdsx {#1}%
}%
\def\xintDSH {\romannumeral0\xintdsh }%
\def\xintdsh #1#2%
{%
- \expandafter\expandafter\expandafter
- \xint@dsh
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\xint@dsh\expandafter {\romannumeral-`0#2}{#1}%
}%
\def\xint@dsh #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@dsh@checksignx #2\Z {#1}%
+ \expandafter\XINT@dsh@checksignx \the\numexpr #2\relax\Z {#1}%
}%
\def\XINT@dsh@checksignx #1%
{%
@@ -7886,20 +8067,20 @@ first place.
% On peut donc toujours reconstituer l'original A par 10^x Q \pm R
% où il faut prendre le signe plus si Q est positif ou nul et le signe moins si
% Q est strictement négatif.
+% Release 1.06 has a faster and more compactly coded \XINT@dsx@zeroloop.
+% Also, x is now given to a \numexpr. The earlier code should be then
+% simplified, but I leave as is for the time being.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintDSx {\romannumeral0\xintdsx }%
\def\xintdsx #1#2%
{%
- \expandafter\expandafter\expandafter
- \xint@dsx
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\xint@dsx\expandafter {\romannumeral-`0#2}{#1}%
}%
\def\xint@dsx #1#2%
{%
- \expandafter\expandafter\expandafter\XINT@dsx@checksignx #2\Z {#1}%
+ \expandafter\XINT@dsx@checksignx \the\numexpr #2\relax\Z {#1}%
}%
\def\XINT@DSx #1#2{\romannumeral0\XINT@dsx@checksignx #1\Z {#2}}%
\def\XINT@dsx #1#2{\XINT@dsx@checksignx #1\Z {#2}}%
@@ -7918,55 +8099,36 @@ first place.
}%
\def\XINT@dsx@xisNeg@checkA@ #1#2\Z #3%
{%
- \xint@zero #1\XINT@dsx@xisNeg@Azero 0\expandafter
- \XINT@dsx@xisNeg@checkx\expandafter
- {\romannumeral0\XINT@length {#3}}{#3}\Z {#1#2}%
+ \xint@zero #1\XINT@dsx@xisNeg@Azero 0%
+ \XINT@dsx@xisNeg@checkx {#3}{#3}\Z {#1#2}%
}%
-\def\XINT@dsx@xisNeg@Azero #1#2#3#4#5#6#7#8{ 0}%
+\def\XINT@dsx@xisNeg@Azero #1\Z #2{ 0}%
\def\XINT@dsx@xisNeg@checkx #1%
{%
- \ifnum #1> 9
- \xint@afterfi {\xintError:TooBigDecimalShift\XINT@dsx@toobigx }%
+ \ifnum #1> 999999999
+ \xint@afterfi
+ {\xintError:TooBigDecimalShift
+ \expandafter\space\expandafter 0\xint@gobble@iii }%
\else
\expandafter \XINT@dsx@zeroloop
\fi
}%
-\def\XINT@dsx@toobigx #1#2#3{ 0}%
\def\XINT@dsx@zeroloop #1%
{%
- \ifcase #1
- \XINT@dsx@exit
- \or
- \XINT@dsx@exiti
- \or
- \XINT@dsx@exitii
- \or
- \XINT@dsx@exitiii
- \or
- \XINT@dsx@exitiv
- \or
- \XINT@dsx@exitv
- \or
- \XINT@dsx@exitvi
- \or
- \XINT@dsx@exitvii
- \else
- \xint@afterfi
- {\expandafter
- \XINT@dsx@zeroloop
- \expandafter {\the\numexpr #1-8}00000000%
- }%
- \fi
+ \ifnum #1<9 \XINT@dsx@exita\fi
+ \expandafter\XINT@dsx@zeroloop\expandafter
+ {\the\numexpr #1-8}00000000%
+}%
+\def\XINT@dsx@exita\fi\expandafter\XINT@dsx@zeroloop
+{%
+ \fi\expandafter\XINT@dsx@exitb
}%
-\def\XINT@dsx@exit #1\fi #2\Z {\fi \XINT@dsx@addzeros {#2}}%
-\def\XINT@dsx@exiti #1\fi #2\Z {\fi \XINT@dsx@addzeros {0#2}}%
-\def\XINT@dsx@exitii #1\fi #2\Z {\fi \XINT@dsx@addzeros {00#2}}%
-\def\XINT@dsx@exitiii #1\fi #2\Z {\fi \XINT@dsx@addzeros {000#2}}%
-\def\XINT@dsx@exitiv #1\fi #2\Z {\fi \XINT@dsx@addzeros {0000#2}}%
-\def\XINT@dsx@exitv #1\fi #2\Z {\fi \XINT@dsx@addzeros {00000#2}}%
-\def\XINT@dsx@exitvi #1\fi #2\Z {\fi \XINT@dsx@addzeros {000000#2}}%
-\def\XINT@dsx@exitvii #1\fi #2\Z {\fi \XINT@dsx@addzeros {0000000#2}}%
-\def\XINT@dsx@addzeros #1#2{ #2#1}%
+\def\XINT@dsx@exitb #1%
+{%
+ \expandafter\expandafter\expandafter
+ \XINT@dsx@addzeros\csname xint@gobble@\romannumeral -#1\endcsname
+}%
+\def\XINT@dsx@addzeros #1\Z #2{ #2#1}%
\def\XINT@dsx@xisPos #1\Z #2%
{%
\XINT@dsx@checksignA #2\Z {#1}%
@@ -8024,17 +8186,23 @@ first place.
% \subsection{\csh{xintDecSplit},~\csh{xintDecSplitL},~\csh{xintDecSplitR}}
% \begin{verbatim}
% DECIMAL SPLIT
-% v1.01: **New** behavior, for use in future extensions of the xint bundle:
% The macro \xintDecSplit {x}{A} first replaces A with |A| (*)
% This macro cuts the number into two pieces L and R. The concatenation LR
% always reproduces |A|, and R may be empty or have leading zeros. The
% position of the cut is specified by the first argument x. If x is zero or
% positive the cut location is x slots to the left of the right end of the
% number. If x becomes equal to or larger than the length of the number then L
-% becomes empty. If x is negative the location of the cut is x slots to the
+% becomes empty. If x is negative the location of the cut is |x| slots to the
% right of the left end of the number.
% (*) warning: this may change in a future version. Only the behavior
% for A non-negative is guaranteed to remain the same.
+% v1.05a: \XINT@split@checksizex does not compute the length anymore, rather the
+% error will be from a \numexpr; but the limit of 999999999 does not make much
+% sense.
+% v1.06: Improvements in \XINT@split@fromleft@loop, \XINT@split@fromright@loop
+% and related macros. More readable coding, speed gains.
+% Also, I now feed immediately a \numexpr with x. Some simplifications may then
+% be perhaps made to the code, it is kept as is for the time being.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
@@ -8058,14 +8226,11 @@ first place.
}%
\def\xint@split #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@split@checksizex
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@split@checksizex\expandafter{\the\numexpr #2}{#1}%
}%
-\def\XINT@split@checksizex #1%
+\def\XINT@split@checksizex #1% 999999999 is anyhow very big, could be reduced
{%
- \ifnum\XINT@Len {#1} > 9
+ \ifnum\numexpr\XINT@Abs{#1}\relax > 999999999
\xint@afterfi {\xintError:TooBigDecimalSplit\XINT@split@bigx }%
\else
\expandafter\XINT@split@xfork
@@ -8089,77 +8254,51 @@ first place.
\xint@UDkrof
}%
\def\XINT@split@zerosplit #1\Z #2{ {#2}{}}%
-\def\XINT@split@fromleft #1\Z #2%
+\def\XINT@split@fromleft #1\Z #2%
{%
\XINT@split@fromleft@loop {#1}{}#2\W\W\W\W\W\W\W\W\Z
}%
\def\XINT@split@fromleft@loop #1%
{%
- \ifcase #1
- \XINT@split@fromleft@endsplit
- \or
- \XINT@split@fromleft@one@andend
- \or
- \XINT@split@fromleft@two@andend
- \or
- \XINT@split@fromleft@three@andend
- \or
- \XINT@split@fromleft@four@andend
- \or
- \XINT@split@fromleft@five@andend
- \or
- \XINT@split@fromleft@six@andend
- \or
- \XINT@split@fromleft@seven@andend
- \else
- \expandafter \XINT@split@fromleft@loop@perhaps
- \expandafter
- {\the\numexpr #1-8\expandafter\expandafter\expandafter }%
- \expandafter
- \XINT@split@fromleft@eight
- \fi
-}%
-\def\XINT@split@fromleft@endsplit #1\fi #2#3\W #4\Z
- {\expandafter\space\fi {#2}{#3}}%
-\def\XINT@split@fromleft@eight #1#2#3#4#5#6#7#8#9%
-{%
- #9{#1#2#3#4#5#6#7#8#9}%
+ \ifnum #1<8 \XINT@split@fromleft@exita\fi
+ \expandafter\XINT@split@fromleft@loop@perhaps\expandafter
+ {\the\numexpr #1-8\expandafter}\XINT@split@fromleft@eight
}%
+\def\XINT@split@fromleft@eight #1#2#3#4#5#6#7#8#9{#9{#1#2#3#4#5#6#7#8#9}}%
\def\XINT@split@fromleft@loop@perhaps #1#2%
{%
- \xint@w #2\XINT@split@fromleft@toofar\W \XINT@split@fromleft@loop
- {#1}%
+ \xint@w #2\XINT@split@fromleft@toofar\W\XINT@split@fromleft@loop {#1}%
}%
-\def\XINT@split@fromleft@toofar\W \XINT@split@fromleft@loop #1#2#3\Z
+\def\XINT@split@fromleft@toofar\W\XINT@split@fromleft@loop #1#2#3\Z
{%
\XINT@split@fromleft@toofar@b #2\Z
}%
\def\XINT@split@fromleft@toofar@b #1\W #2\Z { {#1}{}}%
-\def\XINT@split@fromleft@one@andend #1\fi
-{\fi\expandafter\XINT@split@fromleft@checkiftoofar\XINT@split@fromleft@one }%
-\def\XINT@split@fromleft@one #1#2{#2{#1#2}}%
-\def\XINT@split@fromleft@two@andend #1\fi
-{\fi\expandafter\XINT@split@fromleft@checkiftoofar\XINT@split@fromleft@two }%
-\def\XINT@split@fromleft@two #1#2#3{#3{#1#2#3}}%
-\def\XINT@split@fromleft@three@andend #1\fi
-{\fi\expandafter\XINT@split@fromleft@checkiftoofar\XINT@split@fromleft@three }%
-\def\XINT@split@fromleft@three #1#2#3#4{#4{#1#2#3#4}}%
-\def\XINT@split@fromleft@four@andend #1\fi
-{\fi\expandafter\XINT@split@fromleft@checkiftoofar\XINT@split@fromleft@four }%
-\def\XINT@split@fromleft@four #1#2#3#4#5{#5{#1#2#3#4#5}}%
-\def\XINT@split@fromleft@five@andend #1\fi
-{\fi\expandafter\XINT@split@fromleft@checkiftoofar\XINT@split@fromleft@five }%
-\def\XINT@split@fromleft@five #1#2#3#4#5#6{#6{#1#2#3#4#5#6}}%
-\def\XINT@split@fromleft@six@andend #1\fi
-{\fi\expandafter\XINT@split@fromleft@checkiftoofar\XINT@split@fromleft@six }%
-\def\XINT@split@fromleft@six #1#2#3#4#5#6#7{#7{#1#2#3#4#5#6#7}}%
-\def\XINT@split@fromleft@seven@andend #1\fi
-{\fi\expandafter\XINT@split@fromleft@checkiftoofar\XINT@split@fromleft@seven }%
-\def\XINT@split@fromleft@seven #1#2#3#4#5#6#7#8{#8{#1#2#3#4#5#6#7#8}}%
+\def\XINT@split@fromleft@exita\fi
+ \expandafter\XINT@split@fromleft@loop@perhaps\expandafter #1#2%
+ {\fi \XINT@split@fromleft@exitb #1}%
+\def\XINT@split@fromleft@exitb\the\numexpr #1-8\expandafter
+{%
+ \csname XINT@split@fromleft@endsplit@\romannumeral #1\endcsname
+}%
+\def\XINT@split@fromleft@endsplit@ #1#2\W #3\Z { {#1}{#2}}%
+\def\XINT@split@fromleft@endsplit@i #1#2%
+ {\XINT@split@fromleft@checkiftoofar #2{#1#2}}%
+\def\XINT@split@fromleft@endsplit@ii #1#2#3%
+ {\XINT@split@fromleft@checkiftoofar #3{#1#2#3}}%
+\def\XINT@split@fromleft@endsplit@iii #1#2#3#4%
+ {\XINT@split@fromleft@checkiftoofar #4{#1#2#3#4}}%
+\def\XINT@split@fromleft@endsplit@iv #1#2#3#4#5%
+ {\XINT@split@fromleft@checkiftoofar #5{#1#2#3#4#5}}%
+\def\XINT@split@fromleft@endsplit@v #1#2#3#4#5#6%
+ {\XINT@split@fromleft@checkiftoofar #6{#1#2#3#4#5#6}}%
+\def\XINT@split@fromleft@endsplit@vi #1#2#3#4#5#6#7%
+ {\XINT@split@fromleft@checkiftoofar #7{#1#2#3#4#5#6#7}}%
+\def\XINT@split@fromleft@endsplit@vii #1#2#3#4#5#6#7#8%
+ {\XINT@split@fromleft@checkiftoofar #8{#1#2#3#4#5#6#7#8}}%
\def\XINT@split@fromleft@checkiftoofar #1#2#3\W #4\Z
{%
- \xint@w #1\XINT@split@fromleft@wenttoofar\W
- \space {#2}{#3}%
+ \xint@w #1\XINT@split@fromleft@wenttoofar\W\space {#2}{#3}%
}%
\def\XINT@split@fromleft@wenttoofar\W\space #1%
{%
@@ -8177,72 +8316,48 @@ first place.
}%
\def\XINT@split@fromright@loop #1%
{%
- \ifcase #1
- \expandafter\XINT@split@fromright@endsplit
- \or
- \XINT@split@fromright@one@andend
- \or
- \XINT@split@fromright@two@andend
- \or
- \XINT@split@fromright@three@andend
- \or
- \XINT@split@fromright@four@andend
- \or
- \XINT@split@fromright@five@andend
- \or
- \XINT@split@fromright@six@andend
- \or
- \XINT@split@fromright@seven@andend
- \else
- \expandafter \XINT@split@fromright@loop@perhaps
- \expandafter
- {\the\numexpr
- #1-8\expandafter\expandafter\expandafter }%
- \expandafter
- \XINT@split@fromright@eight
- \fi
+ \ifnum #1<8 \XINT@split@fromright@exita\fi
+ \expandafter\XINT@split@fromright@loop@perhaps\expandafter
+ {\the\numexpr #1-8\expandafter }\XINT@split@fromright@eight
}%
-\def\XINT@split@fromright@endsplit #1#2\W #3\Z #4%
+\def\XINT@split@fromright@eight #1#2#3#4#5#6#7#8#9{#9{#9#8#7#6#5#4#3#2#1}}%
+\def\XINT@split@fromright@loop@perhaps #1#2%
{%
- \expandafter\space\expandafter {\romannumeral0\XINT@rev{#2}}{#1}%
+ \xint@w #2\XINT@split@fromright@toofar\W
+ \XINT@split@fromright@loop {#1}%
}%
-\def\XINT@split@fromright@eight #1#2#3#4#5#6#7#8#9%
+\def\XINT@split@fromright@toofar\W\XINT@split@fromright@loop #1#2#3\Z { {}}%
+\def\XINT@split@fromright@exita\fi
+ \expandafter\XINT@split@fromright@loop@perhaps\expandafter #1#2%
+ {\fi \XINT@split@fromright@exitb #1}%
+\def\XINT@split@fromright@exitb\the\numexpr #1-8\expandafter
{%
- #9{#9#8#7#6#5#4#3#2#1}%
+ \csname XINT@split@fromright@endsplit@\romannumeral #1\endcsname
}%
-\def\XINT@split@fromright@loop@perhaps #1#2%
+\def\XINT@split@fromright@endsplit@ #1#2\W #3\Z #4%
{%
- \xint@w #2\XINT@split@fromright@toofar\W\XINT@split@fromright@loop
- {#1}%
+ \expandafter\space\expandafter {\romannumeral0\XINT@rev{#2}}{#1}%
}%
-\def\XINT@split@fromright@toofar\W\XINT@split@fromright@loop #1#2#3\Z { {}}%
-\def\XINT@split@fromright@one@andend #1\fi {\fi\expandafter
- \XINT@split@fromright@checkiftoofar\XINT@split@fromright@one }%
-\def\XINT@split@fromright@one #1#2{#2{#2#1}}%
-\def\XINT@split@fromright@two@andend #1\fi {\fi\expandafter
- \XINT@split@fromright@checkiftoofar\XINT@split@fromright@two }%
-\def\XINT@split@fromright@two #1#2#3{#3{#3#2#1}}%
-\def\XINT@split@fromright@three@andend #1\fi {\fi\expandafter
- \XINT@split@fromright@checkiftoofar\XINT@split@fromright@three }%
-\def\XINT@split@fromright@three #1#2#3#4{#4{#4#3#2#1}}%
-\def\XINT@split@fromright@four@andend #1\fi {\fi\expandafter
- \XINT@split@fromright@checkiftoofar\XINT@split@fromright@four }%
-\def\XINT@split@fromright@four #1#2#3#4#5{#5{#5#4#3#2#1}}%
-\def\XINT@split@fromright@five@andend #1\fi {\fi\expandafter
- \XINT@split@fromright@checkiftoofar\XINT@split@fromright@five }%
-\def\XINT@split@fromright@five #1#2#3#4#5#6{#6{#6#5#4#3#2#1}}%
-\def\XINT@split@fromright@six@andend #1\fi {\fi\expandafter
- \XINT@split@fromright@checkiftoofar\XINT@split@fromright@six }%
-\def\XINT@split@fromright@six #1#2#3#4#5#6#7{#7{#7#6#5#4#3#2#1}}%
-\def\XINT@split@fromright@seven@andend #1\fi {\fi\expandafter
- \XINT@split@fromright@checkiftoofar\XINT@split@fromright@seven }%
-\def\XINT@split@fromright@seven #1#2#3#4#5#6#7#8{#8{#8#7#6#5#4#3#2#1}}%
+\def\XINT@split@fromright@endsplit@i #1#2%
+ {\XINT@split@fromright@checkiftoofar #2{#2#1}}%
+\def\XINT@split@fromright@endsplit@ii #1#2#3%
+ {\XINT@split@fromright@checkiftoofar #3{#3#2#1}}%
+\def\XINT@split@fromright@endsplit@iii #1#2#3#4%
+ {\XINT@split@fromright@checkiftoofar #4{#4#3#2#1}}%
+\def\XINT@split@fromright@endsplit@iv #1#2#3#4#5%
+ {\XINT@split@fromright@checkiftoofar #5{#5#4#3#2#1}}%
+\def\XINT@split@fromright@endsplit@v #1#2#3#4#5#6%
+ {\XINT@split@fromright@checkiftoofar #6{#6#5#4#3#2#1}}%
+\def\XINT@split@fromright@endsplit@vi #1#2#3#4#5#6#7%
+ {\XINT@split@fromright@checkiftoofar #7{#7#6#5#4#3#2#1}}%
+\def\XINT@split@fromright@endsplit@vii #1#2#3#4#5#6#7#8%
+ {\XINT@split@fromright@checkiftoofar #8{#8#7#6#5#4#3#2#1}}%
\def\XINT@split@fromright@checkiftoofar #1%
{%
\xint@w #1\XINT@split@fromright@wenttoofar\W
- \XINT@split@fromright@endsplit
+ \XINT@split@fromright@endsplit@
}%
-\def\XINT@split@fromright@wenttoofar\W\XINT@split@fromright@endsplit #1\Z #2%
+\def\XINT@split@fromright@wenttoofar\W\XINT@split@fromright@endsplit@ #1\Z #2%
{ {}{#2}}%
\XINT@restorecatcodes@endinput%
% \end{macrocode}
@@ -8366,6 +8481,7 @@ first place.
\edef\XINT@gcd@restorecatcodes@endinput
{%
\catcode36=\the\catcode36 % $
+ \catcode96=\the\catcode96 % `
\catcode47=\the\catcode47 % /
\catcode41=\the\catcode41 % )
\catcode40=\the\catcode40 % (
@@ -8416,7 +8532,7 @@ first place.
\fi
\expandafter\x\csname ver@xintgcd.sty\endcsname
\ProvidesPackage{xintgcd}%
- [2013/05/02 v1.05a Euclide algorithm with xint package (jfB)]%
+ [2013/05/07 v1.06 Euclide algorithm with xint package (jfB)]%
% \end{macrocode}
% \subsection{\csh{xintGCD}}
% \begin{macrocode}
@@ -8473,14 +8589,11 @@ first place.
\def\xintBezout {\romannumeral0\xintbezout }%
\def\xintbezout #1%
{%
- \expandafter\expandafter\expandafter
- \xint@bezout
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\xint@bezout\expandafter {\romannumeral-`0#1}%
}%
\def\xint@bezout #1#2%
{%
- \expandafter\expandafter\expandafter\XINT@bezout@fork #2\Z #1\Z
+ \expandafter\XINT@bezout@fork \romannumeral-`0#2\Z #1\Z
}%
% \end{macrocode}
% \vspace*{-.5\baselineskip}
@@ -8748,8 +8861,7 @@ first place.
}%
\def\XINT@euc #1#2%
{%
- \expandafter\XINT@euc@fork
- \romannumeral0\xintiabs {#2}\Z #1\Z
+ \expandafter\XINT@euc@fork \romannumeral0\xintiabs {#2}\Z #1\Z
}%
% \end{macrocode}
% \vspace*{-.5\baselineskip}
@@ -8860,8 +8972,7 @@ first place.
}%
\def\XINT@bezalg #1#2%
{%
- \expandafter\XINT@bezalg@fork
- \romannumeral0\xintiabs {#2}\Z #1\Z
+ \expandafter\XINT@bezalg@fork \romannumeral0\xintiabs {#2}\Z #1\Z
}%
% \end{macrocode}
% \vspace*{-.5\baselineskip}
@@ -9009,10 +9120,10 @@ first place.
\noindent
\count 255 1
\loop
- \hbox to \wd 0 {\hfil$\U{\the\numexpr 2*\count 255\relax}$}%
- ${} = \U{\the\numexpr 2*\count 255 + 3\relax}
- \times \U{\the\numexpr 2*\count 255 + 2\relax}
- + \U{\the\numexpr 2*\count 255 + 4\relax}$%
+ \hbox to \wd 0 {\hfil$\U{\numexpr 2*\count 255\relax}$}%
+ ${} = \U{\numexpr 2*\count 255 + 3\relax}
+ \times \U{\numexpr 2*\count 255 + 2\relax}
+ + \U{\numexpr 2*\count 255 + 4\relax}$%
\ifnum \count 255 < \N
\hfill\break
\advance \count 255 1
@@ -9046,25 +9157,25 @@ first place.
\count 255 1
\loop
\noindent
- \hbox to \wd 0 {\hfil$\BEZ{\the\numexpr 4*\count 255 - 2\relax}$}%
- ${} = \BEZ{\the\numexpr 4*\count 255 + 5\relax}
- \times \BEZ{\the\numexpr 4*\count 255 + 2\relax}
- + \BEZ{\the\numexpr 4*\count 255 + 6\relax}$\hfill\break
- \hbox to \wd 0 {\hfil$\BEZ{\the\numexpr 4*\count 255 +7\relax}$}%
- ${} = \BEZ{\the\numexpr 4*\count 255 + 5\relax}
- \times \BEZ{\the\numexpr 4*\count 255 + 3\relax}
- + \BEZ{\the\numexpr 4*\count 255 - 1\relax}$\hfill\break
- \hbox to \wd 0 {\hfil$\BEZ{\the\numexpr 4*\count 255 +8\relax}$}%
- ${} = \BEZ{\the\numexpr 4*\count 255 + 5\relax}
- \times \BEZ{\the\numexpr 4*\count 255 + 4\relax}
- + \BEZ{\the\numexpr 4*\count 255 \relax}$
+ \hbox to \wd 0 {\hfil$\BEZ{4*\count 255 - 2}$}%
+ ${} = \BEZ{4*\count 255 + 5}
+ \times \BEZ{4*\count 255 + 2}
+ + \BEZ{4*\count 255 + 6}$\hfill\break
+ \hbox to \wd 0 {\hfil$\BEZ{4*\count 255 +7}$}%
+ ${} = \BEZ{4*\count 255 + 5}
+ \times \BEZ{4*\count 255 + 3}
+ + \BEZ{4*\count 255 - 1}$\hfill\break
+ \hbox to \wd 0 {\hfil$\BEZ{4*\count 255 +8}$}%
+ ${} = \BEZ{4*\count 255 + 5}
+ \times \BEZ{4*\count 255 + 4}
+ + \BEZ{4*\count 255 }$
\endgraf
\ifnum \count 255 < \N
\advance \count 255 1
\repeat
\par
- \edef\U{\BEZ{\the\numexpr 4*\N + 4\relax}}%
- \edef\V{\BEZ{\the\numexpr 4*\N + 3\relax}}%
+ \edef\U{\BEZ{4*\N + 4}}%
+ \edef\V{\BEZ{4*\N + 3}}%
\edef\D{\BEZ5}%
\ifodd\N
$\U\times\A - \V\times \B = -\D$%
@@ -9198,6 +9309,7 @@ first place.
\catcode94=\the\catcode94 % ^
\catcode93=\the\catcode93 % ]
\catcode91=\the\catcode91 % [
+ \catcode96=\the\catcode96 % `
\catcode47=\the\catcode47 % /
\catcode41=\the\catcode41 % )
\catcode40=\the\catcode40 % (
@@ -9248,7 +9360,7 @@ first place.
\fi
\expandafter\x\csname ver@xintfrac.sty\endcsname
\ProvidesPackage{xintfrac}%
- [2013/05/02 v1.05a Expandable operations on fractions (jfB)]%
+ [2013/05/07 v1.06 Expandable operations on fractions (jfB)]%
% \end{macrocode}
% \subsection{\csh{xintLen}}
% \begin{macrocode}
@@ -9300,7 +9412,7 @@ first place.
\def\XINT@inFrac {\romannumeral0\XINT@infrac }%
\def\XINT@infrac #1%
{%
- \expandafter\expandafter\expandafter\XINT@infrac@ #1[\W]\Z\T
+ \expandafter\XINT@infrac@ \romannumeral-`0#1[\W]\Z\T
}%
\def\XINT@infrac@ #1[#2#3]#4\Z
{%
@@ -9323,7 +9435,7 @@ first place.
{%
\xint@UDwfork
#2\dummy \XINT@infrac@BCa
- \W\dummy {\expandafter\expandafter\expandafter\XINT@infrac@BCb #2}%
+ \W\dummy {\expandafter\XINT@infrac@BCb \romannumeral-`0#2}%
\xint@UDkrof
#3\Z #1\Z
}%
@@ -9337,7 +9449,7 @@ first place.
{%
\xint@UDwfork
#2\dummy \XINT@frac@A
- \W\dummy {\expandafter\expandafter\expandafter\XINT@frac@B #2}%
+ \W\dummy {\expandafter\XINT@frac@B \romannumeral-`0#2}%
\xint@UDkrof
#3.\W\Z #1.\W\Z
}%
@@ -9576,7 +9688,7 @@ first place.
\def\XINT@@frac@C #1#2#3#4#5%
{%
\ifcase\XINT@isOne {#5}
- \or \xint@afterfi {\expandafter\xint@firstoftwo@andstop\xint@gobble@two }%
+ \or \xint@afterfi {\expandafter\xint@firstoftwo@andstop\xint@gobble@ii }%
\fi
\space
\frac {#4}{#5}%
@@ -9738,7 +9850,7 @@ first place.
#2\Z {#3}%
}%
\def\XINT@irr@denomisone #1\Z #2{ #1}%
-\def\XINT@irr@negative #1\Z #2{\XINT@irr@D #1\Z #2\Z \XINT@opp}%
+\def\XINT@irr@negative #1\Z #2{\XINT@irr@D #1\Z #2\Z \xint@minus@andstop}%
\def\XINT@irr@nonneg #1\Z #2{\XINT@irr@D #1\Z #2\Z \space}%
\def\XINT@irr@D #1#2\Z #3#4\Z
{%
@@ -9801,7 +9913,7 @@ first place.
\def\xintnum #1{\expandafter\XINT@intcheck\romannumeral0\xintirr {#1}/\W\Z }%
\def\XINT@intcheck #1/#2#3\Z
{%
- \xint@w #2\xint@gobble@two\W\xintError:NotAnInteger
+ \xint@w #2\xint@gobble@ii\W\xintError:NotAnInteger
\space #1%
}%
% \end{macrocode}
@@ -9830,7 +9942,7 @@ first place.
#2\Z {#3}%
}%
\def\XINT@jrr@denomisone #1\Z #2{ #1}%
-\def\XINT@jrr@negative #1\Z #2{\XINT@jrr@D #1\Z #2\Z \XINT@opp}%
+\def\XINT@jrr@negative #1\Z #2{\XINT@jrr@D #1\Z #2\Z \xint@minus@andstop }%
\def\XINT@jrr@nonneg #1\Z #2{\XINT@jrr@D #1\Z #2\Z \space}%
\def\XINT@jrr@D #1#2\Z #3#4\Z
{%
@@ -9875,15 +9987,16 @@ first place.
}%
% \end{macrocode}
% \subsection{\csh{xintTrunc}, \csh{xintiTrunc}}
+% \begin{verbatim}
+% Modified in 1.06 to give the first argument to a \numexpr
+% \end{verbatim}
+% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintTrunc {\romannumeral0\xinttrunc }%
\def\xintiTrunc {\romannumeral0\xintitrunc }%
\def\xinttrunc #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@trunc
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\XINT@trunc\expandafter {\the\numexpr #1}%
}%
\def\XINT@trunc #1#2%
{%
@@ -9893,10 +10006,7 @@ first place.
}%
\def\xintitrunc #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@itrunc
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\XINT@itrunc\expandafter {\the\numexpr #1}%
}%
\def\XINT@itrunc #1#2%
{%
@@ -9966,7 +10076,7 @@ first place.
\ifnum #1 > 0
\xint@afterfi {\XINT@trunc@Ha {#2}}%
\else
- \xint@afterfi {\XINT@trunc@Hb {-#1}}%
+ \xint@afterfi {\XINT@trunc@Hb {-#1}}% -0,--1,--2, ....
\fi
}%
\def\XINT@trunc@Ha
@@ -9980,19 +10090,20 @@ first place.
\def\XINT@trunc@Hb #1#2#3%
{%
\expandafter #3\expandafter0\expandafter.%
- \romannumeral0\XINT@dsx@zeroloop {#1}\Z {}#2%
+ \romannumeral0\XINT@dsx@zeroloop {#1}\Z {}#2% #1=-0 possible!
}%
% \end{macrocode}
% \subsection{\csh{xintRound}, \csh{xintiRound}}
+% \begin{verbatim}
+% Modified in 1.06 to give the first argument to a \numexpr
+% \end{verbatim}
+% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintRound {\romannumeral0\xintround }%
\def\xintiRound {\romannumeral0\xintiround }%
\def\xintround #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@round
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\XINT@round\expandafter {\the\numexpr #1}%
}%
\def\XINT@round
{%
@@ -10000,10 +10111,7 @@ first place.
}%
\def\xintiround #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@iround
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\XINT@iround\expandafter {\the\numexpr #1}%
}%
\def\XINT@iround
{%
@@ -10128,11 +10236,11 @@ first place.
\def\xintSum {\romannumeral0\xintsum }%
\def\xintsum #1{\xintsumexpr #1\relax }%
\def\xintSumExpr {\romannumeral0\xintsumexpr }%
-\def\xintsumexpr {\expandafter\expandafter\expandafter\XINT@fsumexpr }%
+\def\xintsumexpr {\expandafter\XINT@fsumexpr\romannumeral-`0}%
\def\XINT@fsumexpr {\XINT@fsum@loop@a {0[0]}}%
\def\XINT@fsum@loop@a #1#2%
{%
- \expandafter\expandafter\expandafter\XINT@fsum@loop@b #2\Z {#1}%
+ \expandafter\XINT@fsum@loop@b \romannumeral-`0#2\Z {#1}%
}%
\def\XINT@fsum@loop@b #1%
{%
@@ -10177,6 +10285,10 @@ first place.
\def\xint@fsqr #1{\XINT@fmul@A #1#1}%
% \end{macrocode}
% \subsection{\csh{xintPow}}
+% \begin{verbatim}
+% Modified in 1.06 to give the exponent to a \numexpr
+% \end{verbatim}
+% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintPow {\romannumeral0\xintpow }%
\def\xintpow #1%
@@ -10185,8 +10297,7 @@ first place.
}%
\def\xint@fpow #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@fpow@fork #2\Z #1%
+ \expandafter\XINT@fpow@fork\the\numexpr #2\relax\Z #1%
}%
\def\XINT@fpow@fork #1#2\Z
{%
@@ -10226,11 +10337,11 @@ first place.
\def\xintPrd {\romannumeral0\xintprd }%
\def\xintprd #1{\xintproductexpr #1\relax }%
\def\xintProductExpr {\romannumeral0\xintproductexpr }%
-\def\xintproductexpr{\expandafter\expandafter\expandafter\XINT@fproductexpr }%
+\def\xintproductexpr {\expandafter\XINT@fproductexpr \romannumeral-`0}%
\def\XINT@fproductexpr {\XINT@fprod@loop@a {1[0]}}%
\def\XINT@fprod@loop@a #1#2%
{%
- \expandafter\expandafter\expandafter\XINT@fprod@loop@b #2\Z {#1}%
+ \expandafter\XINT@fprod@loop@b \romannumeral-`0#2\Z {#1}%
}%
\def\XINT@fprod@loop@b #1%
{%
@@ -10420,7 +10531,7 @@ first place.
\def\xintrem {\expandafter\xint@secondoftwo@andstop
\romannumeral0\xintdivision }%
% \end{macrocode}
-% \subsection{\csh{xintFDg},~\csh{xintLDg},~\csh{xintMON},~\csh{xintMMON},~\csh{xintOdd}}
+% \subsection{\csh{xintFDg},~\csh{xintLDg},~\csh{xintMON},~\csh{xint\-MMON},~\csh{xintOdd}}
% \begin{macrocode}
\def\xintFDg {\romannumeral0\xintfdg }%
\def\xintfdg #1%
@@ -10582,6 +10693,7 @@ first place.
{%
\catcode93=\the\catcode93 % ]
\catcode91=\the\catcode91 % [
+ \catcode96=\the\catcode96 % `
\catcode47=\the\catcode47 % /
\catcode41=\the\catcode41 % )
\catcode40=\the\catcode40 % (
@@ -10631,24 +10743,23 @@ first place.
\fi
\expandafter\x\csname ver@xintseries.sty\endcsname
\ProvidesPackage{xintseries}%
- [2013/05/02 v1.05a Expandable partial sums with xint package (jfB)]%
+ [2013/05/07 v1.06 Expandable partial sums with xint package (jfB)]%
% \end{macrocode}
% \subsection{\csh{xintSeries}}
+% \begin{verbatim}
+% Modified in 1.06 to give the indices first to a \numexpr rather than expanding
+% twice. I just use \the\numexpr and maintain the previous code after that.
+% \end{verbatim}
+% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintSeries {\romannumeral0\xintseries }%
\def\xintseries #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@series@i
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@series@i\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@series@i #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@series@ii
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@series@ii\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@series@ii #1#2#3%
{%
@@ -10668,25 +10779,24 @@ first place.
}%
\def\XINT@series@exit \fi #1#2#3#4#5#6#7#8%
{%
- \fi\xint@gobble@two #6%
+ \fi\xint@gobble@ii #6%
}%
% \end{macrocode}
% \subsection{\csh{xintiSeries}}
+% \begin{verbatim}
+% Modified in 1.06 to give the indices first to a \numexpr rather than expanding
+% twice. I just use \the\numexpr and maintain the previous code after that.
+% \end{verbatim}
+% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintiSeries {\romannumeral0\xintiseries }%
\def\xintiseries #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@iseries@i
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@iseries@i\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@iseries@i #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@iseries@ii
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@iseries@ii\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@iseries@ii #1#2#3%
{%
@@ -10706,7 +10816,7 @@ first place.
}%
\def\XINT@iseries@exit \fi #1#2#3#4#5#6#7#8%
{%
- \fi\xint@gobble@two #6%
+ \fi\xint@gobble@ii #6%
}%
% \end{macrocode}
% \subsection{\csh{xintPowerSeries}}
@@ -10715,23 +10825,19 @@ first place.
% The Horner scheme for polynomial evaluation is used in 1.04, this
% cures the denominator problem and drastically improves the efficiency
% of the macro.
+% Modified in 1.06 to give the indices first to a \numexpr rather than expanding
+% twice. I just use \the\numexpr and maintain the previous code after that.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintPowerSeries {\romannumeral0\xintpowerseries }%
\def\xintpowerseries #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@powseries@i
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@powseries@i\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@powseries@i #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@powseries@ii
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@powseries@ii\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@powseries@ii #1#2#3#4%
{%
@@ -10766,23 +10872,19 @@ first place.
% \subsection{\csh{xintPowerSeriesX}}
% \begin{verbatim}
% Same as \xintPowerSeries except for the initial expansion of the x parameter.
+% Modified in 1.06 to give the indices first to a \numexpr rather than expanding
+% twice. I just use \the\numexpr and maintain the previous code after that.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintPowerSeriesX {\romannumeral0\xintpowerseriesx }%
\def\xintpowerseriesx #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@powseriesx@i
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@powseriesx@i\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@powseriesx@i #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@powseriesx@ii
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@powseriesx@ii\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@powseriesx@ii #1#2#3#4%
{%
@@ -10790,8 +10892,9 @@ first place.
\xint@afterfi { 0[0]}%
\else
\xint@afterfi
- {\expandafter\expandafter\expandafter\XINT@powseriesx@pre
- \expandafter\expandafter\expandafter {#4}{#1}{#2}{#3}}%
+ {\expandafter\XINT@powseriesx@pre\expandafter
+ {\romannumeral-`0#4}{#1}{#2}{#3}%
+ }%
\fi
}%
\def\XINT@powseriesx@pre #1#2#3#4%
@@ -10807,23 +10910,19 @@ first place.
% computations possible with exponential type series, which would be completely
% inaccessible to \xintSeries.
% #1=a, #2=b, #3=F(a), #4=ratio function
+% Modified in 1.06 to give the indices first to a \numexpr rather than expanding
+% twice. I just use \the\numexpr and maintain the previous code after that.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintRationalSeries {\romannumeral0\xintratseries }%
\def\xintratseries #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@ratseries@i
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@ratseries@i\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@ratseries@i #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@ratseries@ii
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@ratseries@ii\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@ratseries@ii #1#2#3#4%
{%
@@ -10861,23 +10960,19 @@ first place.
% ratios F(n,x)/F(n-1,x). The argument x is first expanded and it is the value
% resulting from this which is used then throughout. The initial term F(a,x)
% must be defined as one-parameter macro which will be given x.
+% Modified in 1.06 to give the indices first to a \numexpr rather than expanding
+% twice. I just use \the\numexpr and maintain the previous code after that.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintRationalSeriesX {\romannumeral0\xintratseriesx }%
\def\xintratseriesx #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@ratseriesx@i
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@ratseriesx@i\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@ratseriesx@i #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@ratseriesx@ii
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@ratseriesx@ii\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@ratseriesx@ii #1#2#3#4#5%
{%
@@ -10885,8 +10980,9 @@ first place.
\xint@afterfi { 0[0]}%
\else
\xint@afterfi
- {\expandafter\expandafter\expandafter\XINT@ratseriesx@pre
- \expandafter\expandafter\expandafter {#5}{#2}{#1}{#4}{#3}}%
+ {\expandafter\XINT@ratseriesx@pre\expandafter
+ {\romannumeral-`0#5}{#2}{#1}{#4}{#3}%
+ }%
\fi
}%
\def\XINT@ratseriesx@pre #1#2#3#4#5%
@@ -10898,23 +10994,19 @@ first place.
% \begin{verbatim}
% I am not two happy with this piece of code. Will make it more economical
% another day.
+% Modified in 1.06 to give the indices first to a \numexpr rather than expanding
+% twice. I just use \the\numexpr and maintain the previous code after that.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintFxPtPowerSeries {\romannumeral0\xintfxptpowerseries }%
\def\xintfxptpowerseries #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@fppowseries@i
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@fppowseries@i\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@fppowseries@i #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@fppowseries@ii
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@fppowseries@ii\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@fppowseries@ii #1#2#3#4#5%
{%
@@ -10964,23 +11056,19 @@ first place.
% \subsection{\csh{xintFxPtPowerSeriesX}}
% \begin{verbatim}
% a,b,coeff,x,D
+% Modified in 1.06 to give the indices first to a \numexpr rather than expanding
+% twice. I just use \the\numexpr and maintain the previous code after that.
% \end{verbatim}
% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintFxPtPowerSeriesX {\romannumeral0\xintfxptpowerseriesx }%
\def\xintfxptpowerseriesx #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@fppowseriesx@i
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@fppowseriesx@i\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@fppowseriesx@i #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@fppowseriesx@ii
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@fppowseriesx@ii\expandafter {\the\numexpr #2}{#1}%
}%
\def\XINT@fppowseriesx@ii #1#2#3#4#5%
{%
@@ -10988,10 +11076,8 @@ first place.
\xint@afterfi { 0}%
\else
\xint@afterfi
- {\expandafter\expandafter\expandafter
- \XINT@fppowseriesx@pre
- \expandafter\expandafter\expandafter
- {#4}{#1}{#2}{#3}{#5}%
+ {\expandafter \XINT@fppowseriesx@pre \expandafter
+ {\romannumeral-`0#4}{#1}{#2}{#3}{#5}%
}%
\fi
}%
@@ -11124,6 +11210,7 @@ first place.
{%
\catcode93=\the\catcode93 % ]
\catcode91=\the\catcode91 % [
+ \catcode96=\the\catcode96 % `
\catcode47=\the\catcode47 % /
\catcode41=\the\catcode41 % )
\catcode40=\the\catcode40 % (
@@ -11173,7 +11260,7 @@ first place.
\fi
\expandafter\x\csname ver@xintcfrac.sty\endcsname
\ProvidesPackage{xintcfrac}%
- [2013/05/02 v1.05a Expandable continued fractions with xint package (jfB)]%
+ [2013/05/07 v1.06 Expandable continued fractions with xint package (jfB)]%
% \end{macrocode}
% \subsection{\csh{xintCFrac}}
% \begin{macrocode}
@@ -11285,7 +11372,7 @@ first place.
}%
\def\XINT@gcfrac
{%
- \expandafter\expandafter\expandafter\XINT@gcfrac@enter
+ \expandafter\XINT@gcfrac@enter\romannumeral-`0%
}%
\def\XINT@gcfrac@enter {\XINT@gcfrac@loop {}}%
\def\XINT@gcfrac@loop #1#2+#3/%
@@ -11316,8 +11403,7 @@ first place.
\def\xintGCtoGCx {\romannumeral0\xintgctogcx }%
\def\xintgctogcx #1#2#3%
{%
- \expandafter\expandafter\expandafter\XINT@gctgcx@start
- \expandafter\expandafter\expandafter {#3}{#1}{#2}%
+ \expandafter\XINT@gctgcx@start\expandafter {\romannumeral-`0#3}{#1}{#2}%
}%
\def\XINT@gctgcx@start #1#2#3{\XINT@gctgcx@loop@a {}{#2}{#3}#1+\W/}%
\def\XINT@gctgcx@loop@a #1#2#3#4+#5/%
@@ -11509,7 +11595,7 @@ first place.
\def\xintCstoF {\romannumeral0\xintcstof }%
\def\xintcstof #1%
{%
- \expandafter\expandafter\expandafter\XINT@cstf@prep #1,\W,%
+ \expandafter\XINT@cstf@prep \romannumeral-`0#1,\W,%
}%
\def\XINT@cstf@prep
{%
@@ -11547,7 +11633,7 @@ first place.
\def\xintiCstoF {\romannumeral0\xinticstof }%
\def\xinticstof #1%
{%
- \expandafter\expandafter\expandafter\XINT@icstf@prep #1,\W,%
+ \expandafter\XINT@icstf@prep \romannumeral-`0#1,\W,%
}%
\def\XINT@icstf@prep
{%
@@ -11556,8 +11642,8 @@ first place.
\def\XINT@icstf@loop@a #1#2#3#4#5,%
{%
\xint@w #5\XINT@icstf@end\W
- \expandafter\expandafter\expandafter
- \XINT@icstf@loop@b #5.{#1}{#2}{#3}{#4}%
+ \expandafter
+ \XINT@icstf@loop@b \romannumeral-`0#5.{#1}{#2}{#3}{#4}%
}%
\def\XINT@icstf@loop@b #1.#2#3#4#5%
{%
@@ -11577,7 +11663,7 @@ first place.
\def\xintGCtoF {\romannumeral0\xintgctof }%
\def\xintgctof #1%
{%
- \expandafter\expandafter\expandafter\XINT@gctf@prep #1+\W/%
+ \expandafter\XINT@gctf@prep \romannumeral-`0#1+\W/%
}%
\def\XINT@gctf@prep
{%
@@ -11640,7 +11726,7 @@ first place.
\def\xintiGCtoF {\romannumeral0\xintigctof }%
\def\xintigctof #1%
{%
- \expandafter\expandafter\expandafter\XINT@igctf@prep #1+\W/%
+ \expandafter\XINT@igctf@prep \romannumeral-`0#1+\W/%
}%
\def\XINT@igctf@prep
{%
@@ -11648,8 +11734,8 @@ first place.
}%
\def\XINT@igctf@loop@a #1#2#3#4#5+%
{%
- \expandafter\expandafter\expandafter\XINT@igctf@loop@b
- #5.{#1}{#2}{#3}{#4}%
+ \expandafter\XINT@igctf@loop@b
+ \romannumeral-`0#5.{#1}{#2}{#3}{#4}%
}%
\def\XINT@igctf@loop@b #1.#2#3#4#5%
{%
@@ -11665,8 +11751,8 @@ first place.
\def\XINT@igctf@loop@f #1#2#3#4/%
{%
\xint@w #4\XINT@igctf@end\W
- \expandafter\expandafter\expandafter\XINT@igctf@loop@g
- #4.{#2}{#3}#1%
+ \expandafter\XINT@igctf@loop@g
+ \romannumeral-`0#4.{#2}{#3}#1%
}%
\def\XINT@igctf@loop@g #1.#2#3%
{%
@@ -11689,7 +11775,7 @@ first place.
\def\xintCstoCv {\romannumeral0\xintcstocv }%
\def\xintcstocv #1%
{%
- \expandafter\expandafter\expandafter\XINT@cstcv@prep #1,\W,%
+ \expandafter\XINT@cstcv@prep \romannumeral-`0#1,\W,%
}%
\def\XINT@cstcv@prep
{%
@@ -11734,7 +11820,7 @@ first place.
\def\xintiCstoCv {\romannumeral0\xinticstocv }%
\def\xinticstocv #1%
{%
- \expandafter\expandafter\expandafter\XINT@icstcv@prep #1,\W,%
+ \expandafter\XINT@icstcv@prep \romannumeral-`0#1,\W,%
}%
\def\XINT@icstcv@prep
{%
@@ -11743,8 +11829,8 @@ first place.
\def\XINT@icstcv@loop@a #1#2#3#4#5#6,%
{%
\xint@w #6\XINT@icstcv@end\W
- \expandafter\expandafter\expandafter
- \XINT@icstcv@loop@b #6.{#2}{#3}{#4}{#5}{#1}%
+ \expandafter
+ \XINT@icstcv@loop@b \romannumeral-`0#6.{#2}{#3}{#4}{#5}{#1}%
}%
\def\XINT@icstcv@loop@b #1.#2#3#4#5%
{%
@@ -11770,7 +11856,7 @@ first place.
\def\xintGCtoCv {\romannumeral0\xintgctocv }%
\def\xintgctocv #1%
{%
- \expandafter\expandafter\expandafter\XINT@gctcv@prep #1+\W/%
+ \expandafter\XINT@gctcv@prep \romannumeral-`0#1+\W/%
}%
\def\XINT@gctcv@prep
{%
@@ -11843,7 +11929,7 @@ first place.
\def\xintiGCtoCv {\romannumeral0\xintigctocv }%
\def\xintigctocv #1%
{%
- \expandafter\expandafter\expandafter\XINT@igctcv@prep #1+\W/%
+ \expandafter\XINT@igctcv@prep \romannumeral-`0#1+\W/%
}%
\def\XINT@igctcv@prep
{%
@@ -11851,8 +11937,8 @@ first place.
}%
\def\XINT@igctcv@loop@a #1#2#3#4#5#6+%
{%
- \expandafter\expandafter\expandafter\XINT@igctcv@loop@b
- #6.{#2}{#3}{#4}{#5}{#1}%
+ \expandafter\XINT@igctcv@loop@b
+ \romannumeral-`0#6.{#2}{#3}{#4}{#5}{#1}%
}%
\def\XINT@igctcv@loop@b #1.#2#3#4#5%
{%
@@ -11868,8 +11954,8 @@ first place.
\def\XINT@igctcv@loop@f #1#2#3#4/%
{%
\xint@w #4\XINT@igctcv@end@a\W
- \expandafter\expandafter\expandafter\XINT@igctcv@loop@g
- #4.#1#2{#3}%
+ \expandafter\XINT@igctcv@loop@g
+ \romannumeral-`0#4.#1#2{#3}%
}%
\def\XINT@igctcv@loop@g #1.#2#3#4#5%
{%
@@ -11897,28 +11983,27 @@ first place.
\def\XINT@igctcv@end@b #1#2{ #2{#1[0]}}%
% \end{macrocode}
% \subsection{\csh{xintCntoF}}
+% \begin{verbatim}
+% Modified in 1.06 to give the N first to a \numexpr rather than expanding
+% twice. I just use \the\numexpr and maintain the previous code after that.
+% \end{verbatim}
+% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintCntoF {\romannumeral0\xintcntof }%
\def\xintcntof #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@cntf
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\XINT@cntf\expandafter {\the\numexpr #1}%
}%
\def\XINT@cntf #1#2%
{%
\ifnum #1>0
\xint@afterfi {\expandafter\XINT@cntf@loop\expandafter
- {\the\numexpr
- #1-1\expandafter\expandafter\expandafter}%
- \expandafter\expandafter\expandafter
- {#2{#1}}{#2}}%
+ {\the\numexpr #1-1\expandafter}\expandafter
+ {\romannumeral-`0#2{#1}}{#2}}%
\else
\xint@afterfi
{\ifnum #1=0
- \xint@afterfi {\expandafter\expandafter\expandafter
- \space #2{0}}%
+ \xint@afterfi {\expandafter\space \romannumeral-`0#2{0}}%
\else \xint@afterfi { 0[0]}%
\fi}%
\fi
@@ -11935,32 +12020,31 @@ first place.
\expandafter\XINT@cntf@loop\expandafter
#1\expandafter #2#3%
{%
- \fi\xint@gobble@two #2%
+ \fi\xint@gobble@ii #2%
}%
% \end{macrocode}
% \subsection{\csh{xintGCntoF}}
+% \begin{verbatim}
+% Modified in 1.06 to give the N first to a \numexpr rather than expanding
+% twice. I just use \the\numexpr and maintain the previous code after that.
+% \end{verbatim}
+% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintGCntoF {\romannumeral0\xintgcntof }%
\def\xintgcntof #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@gcntf
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\XINT@gcntf\expandafter {\the\numexpr #1}%
}%
\def\XINT@gcntf #1#2#3%
{%
\ifnum #1>0
\xint@afterfi {\expandafter\XINT@gcntf@loop\expandafter
- {\the\numexpr
- #1-1\expandafter\expandafter\expandafter}%
- \expandafter\expandafter\expandafter
- {#2{#1}}{#2}{#3}}%
+ {\the\numexpr #1-1\expandafter}\expandafter
+ {\romannumeral-`0#2{#1}}{#2}{#3}}%
\else
\xint@afterfi
{\ifnum #1=0
- \xint@afterfi {\expandafter\expandafter\expandafter
- \space #2{0}}%
+ \xint@afterfi {\expandafter\space\romannumeral-`0#2{0}}%
\else \xint@afterfi { 0[0]}%
\fi}%
\fi
@@ -11977,18 +12061,20 @@ first place.
\expandafter\XINT@gcntf@loop\expandafter
#1\expandafter #2#3#4%
{%
- \fi\xint@gobble@two #2%
+ \fi\xint@gobble@ii #2%
}%
% \end{macrocode}
% \subsection{\csh{xintCntoCs}}
+% \begin{verbatim}
+% Modified in 1.06 to give the N first to a \numexpr rather than expanding
+% twice. I just use \the\numexpr and maintain the previous code after that.
+% \end{verbatim}
+% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintCntoCs {\romannumeral0\xintcntocs }%
\def\xintcntocs #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@cntcs
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\XINT@cntcs\expandafter {\the\numexpr #1}%
}%
\def\XINT@cntcs #1#2%
{%
@@ -11996,38 +12082,36 @@ first place.
\xint@afterfi { 0[0]}%
\else
\xint@afterfi {\expandafter\XINT@cntcs@loop\expandafter
- {\the\numexpr
- #1-1\expandafter\expandafter\expandafter}%
- \expandafter\expandafter\expandafter
- {\expandafter\expandafter\expandafter
- {#2{#1}}}{#2}}%
+ {\the\numexpr #1-1\expandafter}\expandafter
+ {\expandafter{\romannumeral-`0#2{#1}}}{#2}}%
\fi
}%
\def\XINT@cntcs@loop #1#2#3%
{%
\ifnum #1>-1 \else \XINT@cntcs@exit \fi
\expandafter\XINT@cntcs@loop\expandafter
- {\the\numexpr #1-1\expandafter\expandafter\expandafter }%
- \expandafter\expandafter\expandafter
- {\expandafter\expandafter\expandafter{#3{#1}},#2}{#3}%
+ {\the\numexpr #1-1\expandafter }\expandafter
+ {\expandafter{\romannumeral-`0#3{#1}},#2}{#3}%
}%
\def\XINT@cntcs@exit \fi
\expandafter\XINT@cntcs@loop\expandafter
- #1\expandafter\expandafter\expandafter #2#3%
+ #1\expandafter #2#3%
{%
\fi\XINT@cntcs@@exit #2%
}%
\def\XINT@cntcs@@exit #1,{ }%
% \end{macrocode}
% \subsection{\csh{xintCntoGC}}
+% \begin{verbatim}
+% Modified in 1.06 to give the N first to a \numexpr rather than expanding
+% twice. I just use \the\numexpr and maintain the previous code after that.
+% \end{verbatim}
+% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintCntoGC {\romannumeral0\xintcntogc }%
\def\xintcntogc #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@cntgc
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\XINT@cntgc\expandafter {\the\numexpr #1}%
}%
\def\XINT@cntgc #1#2%
{%
@@ -12035,38 +12119,36 @@ first place.
\xint@afterfi { 0[0]}%
\else
\xint@afterfi {\expandafter\XINT@cntgc@loop\expandafter
- {\the\numexpr
- #1-1\expandafter\expandafter\expandafter}%
- \expandafter\expandafter\expandafter
- {\expandafter\expandafter\expandafter
- {#2{#1}}}{#2}}%
+ {\the\numexpr #1-1\expandafter}\expandafter
+ {\expandafter{\romannumeral-`0#2{#1}}}{#2}}%
\fi
}%
\def\XINT@cntgc@loop #1#2#3%
{%
\ifnum #1>-1 \else \XINT@cntgc@exit \fi
\expandafter\XINT@cntgc@loop\expandafter
- {\the\numexpr #1-1\expandafter\expandafter\expandafter }%
- \expandafter\expandafter\expandafter
- {\expandafter\expandafter\expandafter{#3{#1}}+1/#2}{#3}%
+ {\the\numexpr #1-1\expandafter }\expandafter
+ {\expandafter{\romannumeral-`0#3{#1}}+1/#2}{#3}%
}%
\def\XINT@cntgc@exit \fi
\expandafter\XINT@cntgc@loop\expandafter
- #1\expandafter\expandafter\expandafter #2#3%
+ #1\expandafter #2#3%
{%
\fi\XINT@cntgc@@exit #2%
}%
\def\XINT@cntgc@@exit #1+1/{ }%
% \end{macrocode}
% \subsection{\csh{xintGCntoGC}}
+% \begin{verbatim}
+% Modified in 1.06 to give the N first to a \numexpr rather than expanding
+% twice. I just use \the\numexpr and maintain the previous code after that.
+% \end{verbatim}
+% \vspace*{-1.5\baselineskip}
% \begin{macrocode}
\def\xintGCntoGC {\romannumeral0\xintgcntogc }%
\def\xintgcntogc #1%
{%
- \expandafter\expandafter\expandafter
- \XINT@gcntgc
- \expandafter\expandafter\expandafter
- {#1}%
+ \expandafter\XINT@gcntgc\expandafter {\the\numexpr #1}%
}%
\def\XINT@gcntgc #1#2#3%
{%
@@ -12074,33 +12156,24 @@ first place.
\xint@afterfi { {0[0]}}%
\else
\xint@afterfi {\expandafter\XINT@gcntgc@loop\expandafter
- {\the\numexpr
- #1-1\expandafter\expandafter\expandafter}%
- \expandafter\expandafter\expandafter
- {\expandafter\expandafter\expandafter
- {#2{#1}}}{#2}{#3}}%
+ {\the\numexpr #1-1\expandafter}\expandafter
+ {\expandafter{\romannumeral-`0#2{#1}}}{#2}{#3}}%
\fi
}%
\def\XINT@gcntgc@loop #1#2#3#4%
{%
\ifnum #1>-1 \else \XINT@gcntgc@exit \fi
- \expandafter\expandafter\expandafter
- \XINT@gcntgc@loop@b
- \expandafter\expandafter\expandafter
- {\expandafter\expandafter\expandafter
- {#4{#1}}/#2}{#3{#1}}{#1}{#3}{#4}%
+ \expandafter\XINT@gcntgc@loop@b\expandafter
+ {\expandafter{\romannumeral-`0#4{#1}}/#2}{#3{#1}}{#1}{#3}{#4}%
}%
\def\XINT@gcntgc@loop@b #1#2#3%
{%
\expandafter\XINT@gcntgc@loop\expandafter
- {\the\numexpr #3-1\expandafter\expandafter\expandafter}%
- \expandafter\expandafter\expandafter
- {\expandafter\expandafter\expandafter{#2}+#1}%
+ {\the\numexpr #3-1\expandafter}\expandafter
+ {\expandafter{\romannumeral-`0#2}+#1}%
}%
\def\XINT@gcntgc@exit \fi
- \expandafter\expandafter\expandafter
- \XINT@gcntgc@loop@b
- \expandafter\expandafter\expandafter #1#2#3#4#5%
+ \expandafter\XINT@gcntgc@loop@b\expandafter #1#2#3#4#5%
{%
\fi\XINT@gcntgc@@exit #1%
}%
@@ -12111,7 +12184,7 @@ first place.
\def\xintCstoGC {\romannumeral0\xintcstogc }%
\def\xintcstogc #1%
{%
- \expandafter\expandafter\expandafter\XINT@cstc@prep #1,\W,%
+ \expandafter\XINT@cstc@prep \romannumeral-`0#1,\W,%
}%
\def\XINT@cstc@prep #1,{\XINT@cstc@loop@a {{#1}}}%
\def\XINT@cstc@loop@a #1#2,%
@@ -12126,32 +12199,26 @@ first place.
\def\xintGCtoGC {\romannumeral0\xintgctogc }%
\def\xintgctogc #1%
{%
- \expandafter\expandafter\expandafter\XINT@gctgc@start #1+\W/%
+ \expandafter\XINT@gctgc@start \romannumeral-`0#1+\W/%
}%
\def\XINT@gctgc@start {\XINT@gctgc@loop@a {}}%
\def\XINT@gctgc@loop@a #1#2+#3/%
{%
- \xint@w #3\XINT@gctgc@end\W
- \expandafter\expandafter\expandafter
- \XINT@gctgc@loop@b
- \expandafter\expandafter\expandafter
- {#2}{#3}{#1}%
+ \xint@w #3\XINT@gctgc@end\W\expandafter\XINT@gctgc@loop@b\expandafter
+ {\romannumeral-`0#2}{#3}{#1}%
}%
\def\XINT@gctgc@loop@b #1#2%
{%
- \expandafter\expandafter\expandafter
- \XINT@gctgc@loop@c
- \expandafter\expandafter\expandafter
- {#2}{#1}%
+ \expandafter\XINT@gctgc@loop@c\expandafter
+ {\romannumeral-`0#2}{#1}%
}%
\def\XINT@gctgc@loop@c #1#2#3%
{%
\XINT@gctgc@loop@a {#3{#2}+{#1}/}%
}%
-\def\XINT@gctgc@end\W
- \expandafter\expandafter\expandafter\XINT@gctgc@loop@b
+\def\XINT@gctgc@end\W\expandafter\XINT@gctgc@loop@b
{%
- \expandafter\expandafter\expandafter\XINT@gctgc@@end
+ \expandafter\XINT@gctgc@@end
}%
\def\XINT@gctgc@@end #1#2#3{ #3{#1}}%
\XINT@cfrac@restorecatcodes@endinput%
@@ -12176,7 +12243,7 @@ first place.
Grave accent \` Left brace \{ Vertical bar \|
Right brace \} Tilde \~}
-\CheckSum{11712}
+\CheckSum{11366}
\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 a16c71d70ab..ff57cc3cab4 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.05a of May 2nd, 2013)
+%% The xint bundle (version 1.06 of May 7th, 2013)
%% Copyright (C) 2013 by Jean-Francois Burnol
%%----------------------------------------------------------------
%%