summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/generic/xint/xint.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-01-09 23:59:41 +0000
committerKarl Berry <karl@freefriends.org>2014-01-09 23:59:41 +0000
commitaf91cefd8b0ad8fe98e9ef318d337636b3f54a19 (patch)
tree6b68c531657de5b211fa117d8b08836300bc5583 /Master/texmf-dist/source/generic/xint/xint.dtx
parent3e2f1017cfd105d03e88036cae3a040a59d1c3b5 (diff)
xint (9jan14)
git-svn-id: svn://tug.org/texlive/trunk@32618 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/generic/xint/xint.dtx')
-rw-r--r--Master/texmf-dist/source/generic/xint/xint.dtx4290
1 files changed, 2791 insertions, 1499 deletions
diff --git a/Master/texmf-dist/source/generic/xint/xint.dtx b/Master/texmf-dist/source/generic/xint/xint.dtx
index 2148abb6c4e..7d46a1c9278 100644
--- a/Master/texmf-dist/source/generic/xint/xint.dtx
+++ b/Master/texmf-dist/source/generic/xint/xint.dtx
@@ -1,16 +1,16 @@
% -*- coding: iso-latin-1; time-stamp-format: "%02d-%02m-%:y %02H:%02M:%02S %Z" -*-
-% File: xint.dtx, package: 1.09i (2013/12/18), documentation: 2013/12/18
+% File: xint.dtx, package: 1.09j (2014/01/09), documentation: 2014/01/09
% License: LaTeX Project Public License 1.3c or later.
-% Copyright (C) 2013 by Jean-Francois Burnol <jfbu at free dot fr>
+% Copyright (C) 2013-2014 by Jean-Francois Burnol <jfbu at free dot fr>
%<*dtx>
-\def\lasttimestamp{Time-stamp: <18-12-2013 11:32:32 CET>}
+\def\lasttimestamp{Time-stamp: <09-01-2014 19:14:30 CET>}
%</dtx>
%<*drv>
-\def\xintdate {2013/12/18}
-\def\xintversion {1.09i}
+\def\xintdate {2014/01/09}
+\def\xintversion {1.09j}
%</drv>
%%----------------------------------------------------------------
-%% The xint bundle (version 1.09i of December 18, 2013)
+%% The xint bundle (version 1.09j of January 9, 2014)
%<xinttools>%% xinttools: Expandable and non-expandable utilities
%<xint>%% xint: Expandable operations on long numbers
%<xintfrac>%% xintfrac: Expandable operations on fractions
@@ -19,7 +19,7 @@
%<xintgcd>%% xintgcd: Euclidean algorithm with xint package
%<xintseries>%% xintseries: Expandable partial sums with xint package
%<xintcfrac>%% xintcfrac: Expandable continued fractions with xint package
-%% Copyright (C) 2013 by Jean-Francois Burnol
+%% Copyright (C) 2013-2014 by Jean-Francois Burnol
%%----------------------------------------------------------------
% Installation
% ============
@@ -169,7 +169,7 @@
%%
\input docstrip.tex
\askforoverwritefalse
-\generate{\usepreamble\nopreamble
+\generate{\nopreamble
\file{xint.tex}{\from{xint.dtx}{drv}}
\usepreamble\defaultpreamble
\file{xinttools.sty}{\from{xint.dtx}{xinttools}}
@@ -280,7 +280,7 @@
% no use of docstrip to extract files if latex compilation was on etoc.tex
\ifdefined\MessageDeFin\AtEndDocument{\MessageDeFin}\fi
%-------------------------------------------------------------------------------
-\documentclass[abstract]{scrdoc}
+\documentclass {scrdoc}
\ifnum\NoSourceCode=1 \OnlyDescription\fi
\makeatletter
\ifnum\Withdvipdfmx=1
@@ -299,6 +299,42 @@
\makeatother
\pagestyle{headings}
+\makeatletter
+% January 4, 2014
+% took me a while to pinpoint yesterday evening the origin of the problem, if
+% only I had visited
+% http://www.komascript.de/release3.12 immediately!
+%
+% as I subscribe to c.t.tex and d.c.t.tex I thought a problem with KOMA scrartcl
+% would have been mentioned there, if as crippling as is this one, so I
+% initially thought something related to TOCs had changed in KOMA and that etoc
+% was now incompatible, and thus I started examining this, until finally
+% understanding this had nothing to do with the TOC but originated in a
+% buggy \sectionmark, revealed with pagestyle headings.
+%
+% This morning I see this is fixed in the experimental archive
+% http://www.komascript.de/~mkohm/texlive-KOMA/archive/ and appears in the
+% CHANGELOG as r1584. It is a bit hard for me to understand why such a typo with
+% big consequences is not yet fixed in the CTAN distributed version. I did waste
+% 90 minutes on that, at a time I was concentrating on xint things. Bugs are
+% unavoidable, especially typos like this originating from modifying earlier
+% code, but this tiny typo is severely annoying to users (*) and in my humble
+% opinion a CTAN update should have been done sooner. Ok, this was a
+% turn-of-year time...
+%
+% (*) compiling old documents is broken, and one sometimes does not want to
+% modify the source files.
+%
+\def\buggysectionmark #1{% KOMA 3.12 as released to CTAN December 2013
+ \if@twoside\expandafter\markboth\else\expandafter\markright\fi
+ {\MakeMarkcase{\ifnumbered{section}{\sectionmarkformat\fi}{}#1}}{}}
+\ifx\buggysectionmark\sectionmark
+\def\sectionmark #1{%
+ \if@twoside\expandafter\markboth\else\expandafter\markright\fi
+ {\MakeMarkcase{\ifnumbered{section}{\sectionmarkformat}{}#1}}{}}
+\fi
+\makeatother
+
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
@@ -336,8 +372,8 @@
\etocsetstyle{section}{}
{}
- {\ifnum\etocthenumber=26 \gdef\sectioncouleur{{joli}}\fi
- \ifnum\etocthenumber=34 \gdef\sectioncouleur{[named]{RoyalPurple}}\fi
+ {\ifnum\etocthenumber=27 \gdef\sectioncouleur{{joli}}\fi
+ \ifnum\etocthenumber=35 \gdef\sectioncouleur{[named]{RoyalPurple}}\fi
\savedsectionline{\numberline{\expandafter\textcolor\sectioncouleur
{\etocnumber}}\etocname}
{{\mdseries\etocpage}}%
@@ -375,6 +411,7 @@
%--- TXFONTS: TXTT WILL BE MADE SMALLER AND WILL ALLOW HYPHENATION
\usepackage{txfonts}
+\usepackage{pifont}
% malheureusement, comme j'utilise des diacritiques dans mes
% parties commentées, imprimées verbatim, je ne pourrai pas
@@ -430,7 +467,8 @@
\def\digitstt {\bgroup\fontfamily {lmtt}\selectfont\let\next=}
\usepackage{xspace}
-\usepackage[dvipsnames]{color}
+%\usepackage[dvipsnames]{color}
+\usepackage[dvipsnames]{xcolor}
\usepackage{framed}
\definecolor{joli}{RGB}{225,95,0}
@@ -444,10 +482,13 @@
\definecolor{INERT}{RGB}{199,200,194}
\definecolor{PIVOT}{RGB}{109,8,57}
+\usepackage[para]{footmisc}
+
\usepackage[english]{babel}
\usepackage[autolanguage,np]{numprint}
\AtBeginDocument{\npthousandsep{,\hskip .5pt plus .1pt minus .1pt}}
+
\usepackage[pdfencoding=pdfdoc]{hyperref}
\hypersetup{%
linktoc=all,%
@@ -463,6 +504,11 @@ pdfstartview=FitH,%
pdfpagemode=UseOutlines}
\usepackage{bookmark}
+\usepackage{picture} % permet d'utiliser des unités dans les dimensions de la
+ % picture et dans \put
+\usepackage{graphicx}
+\usepackage{eso-pic}
+
%---- \MyMarginNote: a simple macro for some margin notes with no fuss
% je m'aperçois que je peux l'utiliser dans les footnotes...
@@ -488,6 +534,11 @@ pdfpagemode=UseOutlines}
\smash{\hbox to 0pt {\hss\color[named]{PineGreen}%
\itshape \xintListWithSep{\,}{#1}\ $\star$\quad }}%
\vskip\dp\strutbox }\strut{}}
+\def\retype #1{%
+ \vadjust{\vskip-\dp\strutbox
+ \smash{\hbox to 0pt {\hss\color[named]{PineGreen}%
+ \itshape \xintListWithSep{\,}{#1}\ \ding{73}\quad }}%
+ \vskip\dp\strutbox }\strut{}}
\def\ntype #1{%
\vadjust{\vskip-\dp\strutbox
\smash{\hbox to 0pt {\hss\color[named]{PineGreen}%
@@ -690,9 +741,9 @@ pdfpagemode=UseOutlines}
\ifx #1\relax \else #1\hskip 0pt plus 1pt\relax
\expandafter\allowsplits\fi
}%
-\def\printnumber #1%
-{\expandafter\expandafter\expandafter
- \allowsplits #1\relax }% Expands twice before printing.
+\def\printnumber #1% first ``fully'' expands its argument.
+{\expandafter\allowsplits \romannumeral-`0#1\relax }%
+
%--- counts used in particular in the samples from the documentation of the
% xintseries.sty package
@@ -712,15 +763,56 @@ pdfpagemode=UseOutlines}
% 22 octobre 2013
\newcommand\fexpan {\textit{f}-expan}
+\catcode`_ 11
+% December 7, 2013. Expandably computing a big Fibonacci number
+% with the help of TeX+\numexpr+\xintexpr, (c) Jean-François Burnol
+% added January 7 to xint.dtx
+\def\Fibonacci #1{%
+ \expandafter\Fibonacci_a\expandafter
+ {\the\numexpr #1\expandafter}\expandafter
+ {\romannumeral0\xintiieval 1\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 1\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 0\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 1\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 0\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 1\relax}}
+%
+\def\Fibonacci_a #1{%
+ \ifcase #1
+ \expandafter\Fibonacci_end_i
+ \or
+ \expandafter\Fibonacci_end_ii
+ \else
+ \ifodd #1
+ \expandafter\expandafter\expandafter\Fibonacci_b_ii
+ \else
+ \expandafter\expandafter\expandafter\Fibonacci_b_i
+ \fi
+ \fi {#1}%
+}%
+\def\Fibonacci_b_i #1#2#3#4{\expandafter\Fibonacci_a\expandafter
+ {\the\numexpr #1/2\expandafter}\expandafter
+ {\romannumeral0\xintiieval sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval (#2+#4)*#3\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval sqr(#3)+sqr(#4)\relax}%
+}% end of Fibonacci_b_i
+\def\Fibonacci_b_ii #1#2#3#4#5#6#7{\expandafter\Fibonacci_a\expandafter
+ {\the\numexpr (#1-1)/2\expandafter}\expandafter
+ {\romannumeral0\xintiieval sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval (#2+#4)*#3\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval sqr(#3)+sqr(#4)\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval #2*#5+#3*#6\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval #2*#6+#3*#7\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval #3*#6+#4*#7\relax}%
+}% end of Fibonacci_b_ii
+\def\Fibonacci_end_i #1#2#3#4#5#6#7{\xintthe#6}
+\def\Fibonacci_end_ii #1#2#3#4#5#6#7{\xinttheiiexpr #2*#6+#3*#7\relax}
+\catcode`_ 8
+
+\def\Fibo #1.{\Fibonacci {#1}}
+
\begin{document}\thispagestyle{empty}\rmfamily
\pdfbookmark[1]{Title page}{TOP}
-
-% Octobre 2013: le & est devenu assez pénible puisque j'en ai besoin dans mes
-% exemples de \xintApplyInline/\xintFor avec des tabulars. Donc je décide
-% (après avoir temporairement fait des choses un peu lourdes avec \lverb) de
-% le remplacer par @ car il n'y en a quasi pas dans la partie user manual;
-% idem pour \dverb. Cependant je dois faire attention avec un @ actif par
-% exemple dans les tables de matières. Bon on va voir.
\makeatletter
\begingroup\lccode`\~=`@
@@ -731,6 +823,25 @@ pdfpagemode=UseOutlines}
\catcode`\@ \active
\def\jfendshrtverb #1@{#1\endgroup }
+% nice background added for 1.09j release, January 7, 2014.
+% superbe, non? moi très content!
+\AddToShipoutPicture*{%
+ \put(10.5cm,14.85cm)
+ {\makebox(0,0)
+ {\resizebox{17cm}{!}{\vbox
+ {\hsize 8cm\Huge\baselineskip.8\baselineskip\color{black!10}%
+ \digitstt{F(1250)=\printnumber{\romannumeral-`0\Fibonacci{1250}}}\par}}%
+ }
+ }%
+}
+
+% Octobre 2013: le & est devenu assez pénible puisque j'en ai besoin dans mes
+% exemples de \xintApplyInline/\xintFor avec des tabulars. Donc je décide
+% (après avoir temporairement fait des choses un peu lourdes avec \lverb) de
+% le remplacer par @ car il n'y en a quasi pas dans la partie user manual;
+% idem pour \dverb. Cependant je dois faire attention avec un @ actif par
+% exemple dans les tables de matières. Bon on va voir.
+
{\normalfont\Large\parindent0pt \parfillskip 0pt\relax
\leftskip 2cm plus 1fil \rightskip 2cm plus 1fil
The \xintname bundle\par}%
@@ -746,7 +857,157 @@ pdfpagemode=UseOutlines}
\setcounter{footnote}{0}
\bigskip
+
+% comme \dverb ne fait pas un \par à la fin, il y a un problème avec le
+% \baselineskip si on ne le spécifie pas en plus; il faudra que je voie si
+% vraiment j'utilise \dverb sans terminer un paragraphe, il doit y avoir au plus
+% quelque cas.
+\begingroup\footnotesize\def\MacroFont {\ttfamily\baselineskip10pt\relax}
+\baselineskip 10pt
+\dverb|@
+\input xintexpr.sty
+\catcode`_ 11
+% December 7, 2013. Expandably computing a big Fibonacci number
+% using TeX+\numexpr+\xintexpr, (c) Jean-François Burnol
+\def\Fibonacci #1{%
+ \expandafter\Fibonacci_a\expandafter
+ {\the\numexpr #1\expandafter}\expandafter
+ {\romannumeral0\xintiieval 1\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 1\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 0\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 1\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 0\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 1\relax}}%
+\def\Fibonacci_a #1{%
+ \ifcase #1
+ \expandafter\Fibonacci_end_i
+ \or
+ \expandafter\Fibonacci_end_ii
+ \else
+ \ifodd #1
+ \expandafter\expandafter\expandafter\Fibonacci_b_ii
+ \else
+ \expandafter\expandafter\expandafter\Fibonacci_b_i
+ \fi
+ \fi {#1}%
+}%
+
+\def\Fibonacci_b_i #1#2#3#4{\expandafter\Fibonacci_a\expandafter
+ {\the\numexpr #1/2\expandafter}\expandafter
+ {\romannumeral0\xintiieval sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval (#2+#4)*#3\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval sqr(#3)+sqr(#4)\relax}%
+}%
+
+\def\Fibonacci_b_ii #1#2#3#4#5#6#7{\expandafter\Fibonacci_a\expandafter
+ {\the\numexpr (#1-1)/2\expandafter}\expandafter
+ {\romannumeral0\xintiieval sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval (#2+#4)*#3\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval sqr(#3)+sqr(#4)\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval #2*#5+#3*#6\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval #2*#6+#3*#7\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval #3*#6+#4*#7\relax}%
+}%
+
+\def\Fibonacci_end_i #1#2#3#4#5#6#7{\xintthe#6}%
+\def\Fibonacci_end_ii #1#2#3#4#5#6#7{\xinttheiiexpr #2*#6+#3*#7\relax}%
+\catcode`_ 8
+
+% This \Fibonacci macro is designed to compute *one* Fibonacci number, not a
+% whole sequence of them. Let's reap the fruits of our work:
+
+\message{F(1250)=\Fibonacci {1250}}
+\bye |\ttfamily\% see \autoref{ssec:fibonacci} for some explanations and
+more.\par
+\endgroup
+
+\clearpage
+\pdfbookmark[1]{Snapshot}{SNAPSHOT}
+
+The title page illustrates that \xintname is dedicated to do computations on
+numbers exceeding the \TeX{} limit of \digitstt{\number"7FFFFFFF} (already
+@9876543210@ and @F(47)@\digitstt{=\Fibonacci {47}} for example are too big for
+\TeX{} and \eTeX{}), in an \emph{expandable} way, hence the package macros can
+be used inside an |\edef| or |\write| for example, as here within |\message|.
+
+What is more important is that they can be nested one within the other, because
+(1.)~each one completely expands under the sole process of repeated expansion of
+the first token (two expansions suffice), and (2.)~the package macros (dealing
+with computations) apply this \fexpan sion to each of their arguments. The
+|\Fibonacci| macro from this document front page is \fexpan dable (although not
+in only two steps but this does not matter), thus if we are interested in
+knowing how many digits @F(1250)@ has, suffices to use |\xintLen {\Fibonacci
+ {1250}}| (which expands to \digitstt{\xintLen {\Fibonacci {1250}}}), or if we
+want to check the formula @gcd(F(1859),F(1573))=F(gcd(1859,1573))=F(143)@, we
+only need\footnote{The \csa{xintGCD} macro is provided by the \xintgcdname
+ package.}
+\centeredline{|\xintGCD{\Fibonacci{1859}}{\Fibonacci{1573}}=\Fibonacci{\xintGCD{1859}{1573}}|}
+\centeredline{\digitstt{\printnumber{\xintGCD{\Fibonacci{1859}}{\Fibonacci{1573}}}=\printnumber{\Fibonacci{\xintGCD{1859}{1573}}}}}
+
+The |\Fibonacci| macro expanded its
+|\xintGCD{}{}| argument via the services of |\numexpr|: this step requires
+something obeying the \TeX{} bound, naturally! (but
+\digitstt{F(\xintiiPow2{31}}) would be rather big anyhow...). \`A propos, the
+\eTeX{} extensions must be enabled for \xintname, this is the case by default
+except if you invoke \TeX{} under the name |tex| in command line (|etex| should
+be used then, or |pdftex| in |DVI| output mode).
+
+Computations with @100@ or @200@ digits are still reasonably fast, but
+the situation then deteriorates swiftly, it takes of the order of
+seconds for the package to multiply exactly two numbers each of @1000@
+digits and it would take hours for numbers each of @20000@ digits.
+Perhaps some faster routines could emerge from an approach which, while
+maintaining expandability would renounce at \fexpan dability (without
+impacting the input save stack). There is one such routine
+\csbxint{XTrunc} which is able to write to a file (or inside an |\edef|)
+tens of thousands of digits of a (reasonably-sized) fraction.
+
+There is also the possibility to use ``Float'' routines, although no attempt has
+been made to implement float-standards such as |NaN|s, apart from certifying
+exact rounding for the basic operations (the only non-algebraic operation
+currently implemented is square root extraction). I doubt one could do the
+following on a pocket calculator:\smallskip
+\centeredline{$(1.1547)^{2^{35}}=(1.1547)^{\xintiiPow {2}{35}}\approx\hbox
+ \bgroup|\xintFloatPower [48] {1.1547}{\xintiiPow {2}{35}}|}$}
+\centeredline{\digitstt{=\np{\xintFloatPower [48] {1.1547}{\xintiiPow
+ {2}{35}}}}}
+%
+Notice that @2^35@ exceeds \TeX's bound, but \csa{xintFloatPower} allows it,
+what counts is the exponent of the result which, while dangerously close to
+@2^31@ is not quite there yet. The printing of the result was done via the
+|\numprint| command from the \href{http://ctan.org/pkg/numprint}{numprint}
+package\footnote{\url{http://ctan.org/pkg/numprint}}.
+
+\footnotesize
+When producing very long numbers there is the question of printing them on
+ the page, without going beyond the page limits. In this document, I have most
+ of the time made use of these macros (not provided by the package:)
+
+\begingroup\baselineskip10pt\def\MacroFont{\footnotesize\ttfamily\relax }%
+\dverb|@
+\def\allowsplits #1{\ifx #1\relax \else #1\hskip 0pt plus 1pt\relax
+ \expandafter\allowsplits\fi}%
+\def\printnumber #1{\expandafter\allowsplits \romannumeral-`0#1\relax }%
+% \printnumber first ``fully'' expands its argument.|
+\par\endgroup
+An alternative (\autoref{fn:np}) is to suitably configure the thousand separator
+with the \href{http://ctan.org/pkg/numprint}{numprint} package (does not work in
+math mode; I also tried \href{http://ctan.org/pkg/siunitx}{siunitx} but even in
+text mode could not get it to break numbers accross lines). Recently I became
+aware of the
+\href{http://ctan.org/pkg/seqsplit}{seqsplit}
+package\footnote{\url{http://ctan.org/pkg/seqsplit}}
+which can be used to achieve this splitting accross lines, and does work
+in inline math mode.\par
+\normalsize
+
+\pagebreak[3]
+%\phantomsection\etoctoccontentsline*{toctobookmark}{Abstract}{1}
+\pdfbookmark[1]{Abstract}{ABSTRACT}
+
\begin{addmargin}{1cm}\footnotesize
+ \begin{center} \bfseries\large Description of the packages\par\smallskip
+ \end{center}\medskip
\makeatletter
\renewenvironment{description}
{\list{}{\topsep\z@ \parsep\z@ \labelwidth\z@ \itemindent-\leftmargin
@@ -797,7 +1058,10 @@ pdfpagemode=UseOutlines}
load the package components.
\end{addmargin}
+
\bigskip
+
+% \clearpage
% 18 octobre 2013, je remets la TOC ici.
% je ne veux pas non plus que la main toc se liste elle-même donc je passe pour
@@ -887,46 +1151,78 @@ But one will presumably prefer to use the (expandable!) \csbxint{expr}| ...
boolean operators, 2way and 3way conditionals, unpacking of count and dimen
registers or variables...
-\footnotesize
-When producing very long numbers there is the question of printing them on
- the page, without going beyond the page limits. In this document, I have most
- of the time made use of these macros (not provided by the package:)
-
-\begingroup\baselineskip10pt\def\MacroFont{\footnotesize\ttfamily\relax }%
-\dverb|@
-\def\allowsplits #1%
- {\ifx #1\relax \else #1\hskip 0pt plus 1pt\relax\expandafter\allowsplits\fi}%
-\def\printnumber #1{\expandafter\expandafter\expandafter\allowsplits #1\relax }%
-%% (all macros from the xint bundle expand in two steps to their final output).|\par\endgroup
-An alternative (\autoref{fn:np}) is to suitably configure the thousand separator
-with the \href{http://ctan.org/pkg/numprint}{numprint} package (does not work in
-math mode; I also tried \href{http://ctan.org/pkg/siunitx}{siunitx} but even in
-text mode could not get it to break numbers accross lines). Recently I became
-aware of the
-\href{http://ctan.org/pkg/seqsplit}{seqsplit}
-package\footnote{\url{http://ctan.org/pkg/seqsplit}}
-which can be used to achieve this splitting accross lines, and does work
-in inline math mode.
+\section {Interesting illustrations}
+\label{sec:awesome}
+
-\normalsize
The utilities provided by \xinttoolsname (\autoref{sec:tools}), some
-completely expandable, others not, are of independent interest. Their use is
-illustrated through various examples: among those, it is shown in
-\autoref{ssec:quicksort} how to implement in a completely expandable way the
-quick sort algorithm and also how to illustrate it graphically. Other examples
-include some dynamically constructed alignments with automatically computed
-prime number cells (\autoref{ssec:primesI}, \autoref{ssec:primesIII}).
-
-Some other computational examples are \hyperref[ssec:Machin]{the
- computations of $\pi$ and $\log 2$} using \xintname and the computation of the
-\hyperlink{e-convergents}{convergents of $e$} with the further help of the
-\xintcfracname package.
-
+completely expandable, others not, are of independent interest. Their
+use is illustrated through various examples: among those, it is shown in
+\autoref{ssec:quicksort} how to implement in a completely expandable way
+the \hyperref[quicksort]{Quick Sort algorithm} and also how to
+illustrate it graphically. Other examples include some dynamically
+constructed alignments with automatically computed prime number cells:
+one using a completely expandable prime test and \csbxint{ApplyUnbraced}
+(\autoref{ssec:primesI}), another one with \csbxint{For*}
+(\autoref{ssec:primesIII}).
+
+One has also a \hyperref[edefprimes]{computation of primes
+ within an \csa{edef}} (\autoref{xintiloop}), with the help of
+\csbxint{iloop}. Also with \csbxint{iloop} an
+\hyperref[ssec:factorizationtable]{automatically generated table of
+ factorizations} (\autoref{ssec:factorizationtable}).
+
+The title page fun with Fibonacci numbers is continued in
+\autoref{ssec:fibonacci} with \csbxint{For*} joining the game,.
+
+The computations of \hyperref[ssec:Machin]{ $\pi$ and $\log 2$}
+(\autoref{ssec:Machin}) using \xintname and the computation of the
+\hyperlink{e-convergents}{convergents of $e$} with the further help of
+the \xintcfracname package are among further examples.
+
+There is also an example of an \hyperref[xintXTrunc]{interactive
+ session}, where results are output to the log or to a file.
\section{Recent changes}
\footnotesize
+\noindent Release |1.09j| (|[2014/01/09]|)
+\begin{itemize}
+\item The core division routines have been re-written for some (limited)
+ efficiency gain, more pronounced for small divisors. As a result the
+ \hyperlink{Machin1000}{computation of one thousand digits of $\pi$}
+ is close to three times faster than with earlier releases.
+\item Some various other small improvements, particularly in the power routines.
+\item A new macro \csbxint{XTrunc} is designed to produce thousands or even tens
+ of thousands of digits of the decimal expansion of a fraction. Although
+ completely expandable it has its use limited to inside an |\edef|, |\write|,
+ |\message|, \dots. It
+ can thus not be nested as argument to another package macro.
+\item the tacit multiplication done in \csbxint{expr}|..\relax| on encountering
+ a count register or variable, or a |\numexpr|, while scanning a (decimal)
+ number, is extended to the case of a sub |\xintexpr|-ession.
+\item \csbxint{expr} can now be used in an |\edef| with no |\xintthe|
+ prefix; it will execute completely the computation, and the error
+ message about a missing |\xintthe| will be inhibited. Previously, in
+ the absence of |\xintthe|, expansion could only be a full one (with
+ |\romannumeral-`0|), not a complete one (with |\edef|). Note that this
+ differs from the behavior of the non-expandable |\numexpr|: |\the| or
+ |\number| are needed not only to print but also to trigger the
+ computation, whereas |\xintthe| is mandatory only for the printing step.
+\item the default behavior of \csbxint {Assign} is changed, it now does not do
+ any further expansion beyond the initial full-expansion which provided the
+ list of items to be assigned to macros.
+\item bug-fix: |1.09i| did an unexplainable change to |\XINT_infloat_zero| which
+ broke the floating point routines for vanishing operands =:(((
+\item dtx bug-fix: the |1.09i .ins| file produced a buggy |.tex| file.
+\end{itemize}
+
+
+
+For a more detailed change history, see \autoref{sec:releases}. Main recent
+additions: \smallskip
+
\noindent Release |1.09i| (|[2013/12/18]|)
\begin{itemize}
\item \csbxint{iiexpr} is a variant of \csbxint{expr} which is optimized to deal
@@ -938,39 +1234,16 @@ Some other computational examples are \hyperref[ssec:Machin]{the
count, dimen, and skip registers or variables without explicit |\the/\number|:
the parser inserts automatically |\number| and a tacit multiplication is
implied when a register or variable immediately follows a number or fraction.
- Regarding dimensions and |\number|, see the further discussion in
- \autoref{sec:Dimensions}.
-\item new conditional \csbxint{ifOne}; |\xintifTrueFalse| renamed to
- \csbxint{ifTrueAelseB}; new macros \csbxint{TFrac} (`fractional part', mapped
- to function |frac| in |\xintexpr|-essions), \csbxint{FloatE}.
-\item \csbxint{Assign} admits an optional argument to specify the expansion type
- to be used: |[]| (none), |[o]| (once), |[oo]| (twice), |[f]| (full), others,
- to
- define the macros (the default is |[e]| which means to use |\edef|).
-\item related to the previous item, \xinttoolsname defines (only if the names
- have not already been assigned) \hyperref[odef]{\ttfamily\char92odef},
+\item \xinttoolsname defines \hyperref[odef]{\ttfamily\char92odef},
\hyperref[oodef]{\ttfamily\char92oodef},
\hyperref[fdef]{\ttfamily\char92fdef}. These tools are provided for the case
one uses the package macros in a non-expandable context, particularly
\hyperref[oodef]{\ttfamily\char92oodef} which expands twice the macro
- replacement text and is thus a faster alternative to |\edef| taking into
- account that the \xintname bundle macros expand already completely in only two
- steps. This can be significant when repeatedly making (re)-definitions
- expanding to hundreds of digits.
-\item some across the board slight efficiency improvement as a result of
- modifications of various types to ``fork'' macros and ``branching
- conditionals'' which are used internally.
-\item bug-fix: |\xintAND| and |\xintOR| inserted a space token in some cases and
- did not expand as promised in two steps (bug dating back to |1.09a| I think;
- this bug was without consequences when using |&| and \verb+|+ in
- \csa{xintexpr-}essions, it affected only the macro form)
- |:-((|.
-\item bug-fix: \csbxint{FtoCCv} still ended fractions with the |[0]|'s which
- were supposed to have been removed since release |1.09b|.
+ replacement text and is thus a faster alternative to |\edef|. This can be
+ significant when repeatedly making |\def|-initions expanding to hundreds of
+ digits.
\end{itemize}
-For a more detailed change history, see \autoref{sec:releases}. Main recent
-additions:
\noindent Release |1.09h| (|[2013/11/28]|):
\begin{itemize}
@@ -1024,7 +1297,8 @@ additions:
\csbxint{expr} syntax; also added \csbxint{boolexpr} and \csbxint{ifboolexpr}.
\item \csbxint{For} is a new type of loop, whose replacement text inserts the
comma separated values or list items via macro parameters, rather than
- encapsulated in macros; the loops are nestable up to four levels,
+ encapsulated in macros; the loops are nestable up to four levels (nine
+ levels since |1.09f|),
and their replacement texts are allowed to close groups as happens with the
tabulation in alignments,
\item \csbxint{ApplyInline} has been enhanced in order to be usable for
@@ -1076,9 +1350,10 @@ The main characteristics are:
have to compute the length of the inputs and these lengths must be treatable
as \TeX{} integers, which are at most \digitstt{\number "7FFFFFFF}
in absolute value.
- This is a distant theoretical upper bound,
+ This is a distant irrelevant upper bound, as no such thing can fit
+ in \TeX's memory! And besides,
the true limitation is from the \emph{time} taken by the
-expansion-compatible algorithms, this will be commented upon soon.
+expansion-compatible algorithms, as will be commented upon soon.
As just recalled, ten-digits numbers starting with a @3@ already exceed the
\TeX{} bound on integers; and \TeX{} does not have a native processing of
@@ -1190,11 +1465,11 @@ of the \xintexprname package.
Computation of a Bezout identity with |7^200-3^200| and |2^200-1|:}\par
{\color[named]{Purple}
\dverb|@
-\xintAssign [oo]\xintBezout {\xinttheiexpr 7^200-3^200\relax}
+\xintAssign \xintBezout {\xinttheiexpr 7^200-3^200\relax}
{\xinttheiexpr 2^200-1\relax}\to\A\B\U\V\D|%
\centeredline {|\U$\times$(7^200-3^200)+\xintiOpp\V$\times$(2^200-1)=\D|}}%
%
-\xintAssign [oo]\xintBezout {\xinttheiexpr 7^200-3^200\relax}
+\xintAssign \xintBezout {\xinttheiexpr 7^200-3^200\relax}
{\xinttheiexpr 2^200-1\relax}\to\A\B\U\V\D
\digitstt
{\printnumber\U$\times$(@7^200-3^200@)+%
@@ -1229,7 +1504,7 @@ $\frac{\pi^2}{144}-\frac1{162}={}$%
lines works only in text mode. The number itself was (of course...) computed
initially with \xintname, with 30 digits of $\pi$ as input.
See
- \hyperref[ssec:Machin]{{how \xintname may compute $\pi$
+ \hyperref[ssec:Machin]{{how {\xintname} may compute $\pi$
from scratch}}.} I also used (this is a lengthier computation
than the one above) \xintseriesname to evaluate the sum with \np{100000} terms,
obtaining 16
@@ -1982,7 +2257,7 @@ length command defined by \csa{newlength} with \csa{number} will thus discard
the |plus| and |minus| glue components and return the dimension component as
described above, and usable in the \xintname bundle macros.
-This conversion\MyMarginNote{New!} is done automatically inside an
+This conversion is done automatically inside an
|\xintexpr|-essions, with tacit multiplication implied if prefixed by some
(integral or decimal) number.
@@ -2180,7 +2455,7 @@ package.
\section{Assignments}\label{sec:assign}
-\xintAssign [oo]\xintBezout{357}{323}\to\tmpA\tmpB\tmpU\tmpV\tmpD
+\xintAssign \xintBezout{357}{323}\to\tmpA\tmpB\tmpU\tmpV\tmpD
It might not be necessary to maintain at all times complete
expandability. For example why not allow oneself the two definitions
@@ -2207,13 +2482,13 @@ and |\D| to \digitstt{\tmpD}. And indeed
Thus, what |\xintAssign| does is to first apply an
\hyperref[sec:expansions]{\fexpan sion} to what comes next; it then defines one
-after the other (using |\edef|; an optional argument allows to modify the
+after the other (using |\def|; an optional argument allows to modify the
expansion type, see \autoref{xintAssign} for details), the macros found after
|\to| to correspond to the successive braced contents (or single tokens) located
prior to |\to|.
\xintAssign
-[oo]\xintBezout{3570902836026}{200467139463}\to\tmpA\tmpB\tmpU\tmpV\tmpD
+\xintBezout{3570902836026}{200467139463}\to\tmpA\tmpB\tmpU\tmpV\tmpD
\centeredline{\csbxint{Assign}\csa{xintBezout}|{3570902836026}{200467139463}|%
\csbnolk{to}|\A\B\U\V\D|}
@@ -2406,7 +2681,6 @@ sequences:
\xintError:ignored
\xintError:removed
\xintError:inserted
-\xintError:use_xintthe!
\xintError:bigtroubleahead
\xintError:unknownfunction|
@@ -2461,7 +2735,7 @@ and is not touched.
\xinttoolsname defines \hyperref[odef]{\ttfamily\char92odef},
\hyperref[oodef]{\ttfamily\char92oodef}, \hyperref[fdef]{\ttfamily\char92fdef},
-but only if macros with these names do not already exist (|\XINT_oodef| etc...
+but only if macros with these names do not already exist (|\xintoodef| etc...
are defined anyhow for use in \csbxint{Assign} and \csbxint{AssignArray}).
\section{Loading and usage}
@@ -2519,7 +2793,7 @@ get the tokens). In an |\xintexpr|-ession, the `e' may be uppercased: `E'.
\makeatother The \xintname packages presuppose that the \csa{space},
-\csa{empty}, |\m@ne|, |\z@|\MyMarginNote{New!} and |\@ne| control sequences
+\csa{empty}, |\m@ne|, |\z@| and |\@ne| control sequences
have their meanings as in Plain \TeX{} or \LaTeX2e.
\catcode`@ \active
@@ -2669,7 +2943,7 @@ with @8@ digits after the decimal mark, and printed.
This does the same thing as the hand-written version from the previous item. The
use even thousands of times of such an |\xintNewExpr|-generated |\formula|
has no memory impact.
-\item count registers\MyMarginNote{New!} and |\numexpr|-essions are accepted
+\item count registers and |\numexpr|-essions are accepted
(LaTeX{}'s counters can be inserted using |\value|) without needing |\the| or
|\number| as prefix. Also dimen registers and
control sequences, skip registers and control sequences (\LaTeX{}'s
@@ -2677,7 +2951,10 @@ has no memory impact.
using |\number|, discarding the stretch and shrink components and giving the
dimension value in |sp| units (@1/65536@th of a \TeX{} point). Furthermore,
tacit multiplication is implied, when immediately prefixed by a (decimal)
- number.
+ number.
+\item The tacit multiplication is done also when the parser encounters a
+ sub-|\xintexpr|-ession.\MyMarginNote{New!} (but not in front of an
+ unexpected opening parenthesis).
\item like a |\numexpr|, an |\xintexpr| is not directly printable, one
uses equivalently |\xintthe\xintexpr| or \csbxint{theexpr}. One may
for example define: \centeredline{|\def\x {\xintexpr \a + \b \relax}
@@ -2690,7 +2967,7 @@ has no memory impact.
syntax as \csbxint{iexpr}| ... \relax|. There is also
\csbxint{theiexpr}. The
rounding is applied to the final result only.
-\item \csbxint{iiexpr}| ... \relax|\MyMarginNote{New!} (\csbxint{theiiexpr}) is
+\item \csbxint{iiexpr}| ... \relax| (\csbxint{theiiexpr}) is
another variant which deals only with (long) integers and skips the overhead
of the fraction internal format. The infix operator |/| does euclidean
division.
@@ -2797,7 +3074,7 @@ use |\xinttheexpr| inside an |\xintexpr|: this gives a number in |A/B[n]|
format which requires protection by braces. Do not put within braces numbers in
scientific notation.
-See \autoref{xintiiexpr}\MyMarginNote{New!} for the speed-optimized variant
+See \autoref{xintiiexpr} for the speed-optimized variant
\csbxint{iiexpr} which deals only with long integers.
Here is, listed from the highest priority to the lowest, the complete
@@ -2829,16 +3106,36 @@ The |\relax| at the end of an expression is absolutely \emph{mandatory}.
\labelwidth\parindent
\itemindent\labelwidth}%
\item
- Functions are at the same top level of priority.
+ Functions are at the same top level of priority. All functions even
+ |?| and |!| (as prefix) require parentheses around their argument
+ (possiblty a comma separated list).
+ \begin{framed}
+ \ctexttt{floor, ceil, frac, reduce, sqr, abs, sgn, ?, !, not, bool,
+ togl, round, trunc, float, sqrt, quo, rem, if, ifsgn, all, any,
+ xor, add (=sum), mul (=prd), max, min, gcd, lcm.}
+
+ |quo| and |rem|
+ operate only on integers; |gcd| and |lcm| also and require
+ \xintgcdname loaded; |togl| requires the |etoolbox| package.
+ \end{framed}
\begin{description}
\item[functions with one (numeric) argument] (numeric: any expression leading
to an integer, decimal number, fraction, or floating number in scientific
notation) \ctexttt{floor, ceil, frac, reduce, sqr, abs, sgn, ?, !, not}. The
|?(x)| function returns the truth value, @1@ if |x<>0|, @0@ if |x=0|. The
|!(x)| is the logical not. The |reduce| function puts the fraction in
- irreducible form. The |frac|\MyMarginNote{New} function is fractional part
- (same sign as the number, complements truncation towards zero). Like the
- other functions |!| and |?| \emph{must} use parentheses.
+ irreducible form. The |frac| function is fractional part,
+ same sign as the number:\newline
+ \null\quad\quad|\xinttheexpr
+ frac(-3.57)\relax|$\to$\digitstt{\xinttheexpr frac(-3.57)\relax}\newline
+ \null\quad\quad|\xinttheexpr
+ trunc(frac(-3.57),2)\relax|$\to$\digitstt{\xinttheexpr
+ trunc(frac(-3.57),2)\relax}\newline
+ \null\quad\quad|\xintthefloatexpr
+ frac(-3.57)\relax|$\to$\digitstt{\xintthefloatexpr
+ frac(-3.57)\relax}.\newline
+ Like
+ the other functions |!| and |?| \emph{must} use parentheses.
\item[functions with one (alphabetical) argument] \hypertarget{item:bool}
{\ctexttt{bool,togl}}.
@@ -2926,7 +3223,7 @@ The |\relax| at the end of an expression is absolutely \emph{mandatory}.
the vocabulary |all| and |any|. They must have at least one
argument.
\end{description}
-\item The three postfix operators:
+\item The three postfix operators \ctexttt{!, ?, :}.
\begin{description}
\item[{\color[named]{DarkOrchid}!}] computes the factorial of an integer. |sqrt(36)!| evaluates to |6!|
(\digitstt{=\np{\xinttheexpr sqrt(36)!\relax}}) and not to the square root of
@@ -2979,11 +3276,12 @@ The |\relax| at the end of an expression is absolutely \emph{mandatory}.
associative: \begingroup\def\MicroFont{\ttfamily}%
|\xinttheiexpr 100-50-2\relax| evaluates to
\xinttheiexpr 100-50-2\relax, not \xinttheiexpr 100-(50-2)\relax.\endgroup
-\item Comparison operators |<|, |>|, |=|.
-\item Conjunction (logical and): |&|.
-\item Inclusive disjunction (logical or): \verb$|$.
+\item Comparison operators |<|, |>|, |=| (currently, no @<=@, @>=@,
+ \dots! ).
+\item Conjunction (logical and): |&|. (no @&&@\,!)
+\item Inclusive disjunction (logical or): \verb$|$. (no @||@\,!)
\item The comma |,|. \def\MicroFont{\ttfamily}%
- One can thus do |\xinttheiexpr 2^3,3^4,5^6\relax| and obtain as output
+ With |\xinttheiexpr 2^3,3^4,5^6\relax| one obtains as output
\xinttheiexpr 2^3,3^4,5^6\relax.
\item The parentheses.
\endlist
@@ -2999,6 +3297,48 @@ See \autoref{ssec:countinexpr} for count and dimen registers and variables.
\footnotesize
+\noindent Release |1.09i| (|[2013/12/18]|)
+\begin{itemize}
+\item \csbxint{iiexpr} is a variant of \csbxint{expr} which is optimized to deal
+ only with (long) integers, |/| does a euclidean quotient.
+\item |\xintnumexpr|, |\xintthenumexpr|, |\xintNewNumExpr| are renamed,
+ respectively, \csbxint{iexpr}, \csbxint{theiexpr}, \csbxint{NewIExpr}. The
+ earlier denominations are kept but to be removed at some point.
+\item it is now possible within |\xintexpr...\relax| and its variants to use
+ count, dimen, and skip registers or variables without explicit |\the/\number|:
+ the parser inserts automatically |\number| and a tacit multiplication is
+ implied when a register or variable immediately follows a number or fraction.
+ Regarding dimensions and |\number|, see the further discussion in
+ \autoref{sec:Dimensions}.
+\item new conditional \csbxint{ifOne}; |\xintifTrueFalse| renamed to
+ \csbxint{ifTrueAelseB}; new macros \csbxint{TFrac} (`fractional part', mapped
+ to function |frac| in |\xintexpr|-essions), \csbxint{FloatE}.
+\item \csbxint{Assign} admits an optional argument to specify the expansion
+ type to be used: |[]| (none, default), |[o]| (once), |[oo]| (twice), |[f]|
+ (full), |[e]| (|\edef|),... to define the macros
+\item related to the previous item, \xinttoolsname defines
+ \hyperref[odef]{\ttfamily\char92odef},
+ \hyperref[oodef]{\ttfamily\char92oodef},
+ \hyperref[fdef]{\ttfamily\char92fdef} (if the names have already been
+ assigned, it uses |\xintoodef| etc...). These tools are provided for the
+ case one uses the package macros in a non-expandable context, particularly
+ \hyperref[oodef]{\ttfamily\char92oodef} which expands twice the macro
+ replacement text and is thus a faster alternative to |\edef| taking into
+ account that the \xintname bundle macros expand already completely in only
+ two steps. This can be significant when repeatedly making |\def|-initions
+ expanding to hundreds of digits.
+\item some across the board slight efficiency improvement as a result of
+ modifications of various types to ``fork'' macros and ``branching
+ conditionals'' which are used internally.
+\item bug-fix: |\xintAND| and |\xintOR| inserted a space token in some cases and
+ did not expand as promised in two steps (bug dating back to |1.09a| I think;
+ this bug was without consequences when using |&| and \verb+|+ in
+ \csa{xintexpr-}essions, it affected only the macro form)
+ |:-((|.
+\item bug-fix: \csbxint{FtoCCv} still ended fractions with the |[0]|'s which
+ were supposed to have been removed since release |1.09b|.
+\end{itemize}
+
\noindent Release |1.09h| (|[2013/11/28]|):
\begin{itemize}
\item parts of the documentation have been re-written or re-organized,
@@ -3051,7 +3391,7 @@ See \autoref{ssec:countinexpr} for count and dimen registers and variables.
for big integers, but do parse their inputs via \csbxint{Num} (since release
|1.09a|). They too may have doubled-|i| variants for matters of programming
optimization when working only with (big) integers and not fractions or
- decimal numbers, interested advanced users should check the code source.
+ decimal numbers.
\end{itemize}
@@ -3099,9 +3439,9 @@ version \fexpan ds the un-braced list items. After
\item added |\xintNewNumExpr| (now \csbxint{NewIExpr} and \csbxint{NewBoolExpr},
\item \csbxint{For} is a new type of loop, whose replacement text inserts the
comma separated values or list items via macro parameters, rather than
- encapsulated in macros; the loops are nestable up to four levels,
- and their replacement texts are allowed to close groups as happens with the
- tabulation in alignments,
+ encapsulated in macros; the loops are nestable up to four levels (nine
+ levels since |1.09f|) and their replacement texts are allowed to close
+ groups as happens with the tabulation in alignments,
\item \csbxint{Forpair}, \csbxint{Forthree}, \csbxint{Forfour} are experimental
variants of \csbxint{For},
\item \csbxint{ApplyInline} has been enhanced in order to be usable for
@@ -3256,6 +3596,8 @@ This section contains various concrete examples and ends with a
\hyperref[ssec:quicksort]{completely expandable implementation of the Quick Sort
algorithm} together with a graphical illustration of its action.
+\clearpage
+
\localtableofcontents
@@ -3838,6 +4180,8 @@ character. The \csbxint{For*} macro would be more elegant here.
\end{tabular}
There are \arabic{primecount} prime numbers up to 1000.?
+The table has been put in \hyperref[primesupto1000]{float} which appears
+\vpageref{primesupto1000}.
We had to be careful to use in the last row \csbxint{Seq} with its optional
argument |[1]| so as to not generate a decreasing sequence from |1| to |0|, but
really an empty sequence in case the row turns out to already have all its
@@ -3872,6 +4216,7 @@ cells (which doesn't happen here but would with a number of columns dividing
\newcommand{\OneTab}[1]{&}
\begin{figure*}[ht!]
\centering
+ \phantomsection\label{primesupto1000}
\begin{tabular}{|*{\NbOfColumns}{r}|}
\hline
2\setcounter{cellcount}{1}\setcounter{primecount}{1}%
@@ -3893,22 +4238,29 @@ cells (which doesn't happen here but would with a number of columns dividing
% {\small New with release |1.09g|. Release |1.09h|
% makes them long macros.\par}
-|\xintloop|\meta{stuff}|\if<test>...\repeat|\etype{} is an expandable loop
-compatible with nesting. If a sub-loop is to be used all the material from the
-start and up to the complete subloop inclusive should be braced; these braces
-will be removed and do not create a group.
+|\xintloop|\meta{stuff}|\if<test>...\repeat|\retype{} is an expandable loop
+compatible with nesting. However to break out of the loop one almost always need
+some un-expandable step. The cousin \csbxint{iloop} is \csbxint{loop} with an
+embedded expandable mechanism allowing to exit from the loop. The iterated
+commands may contain |\par| tokens or empty lines.
+
+If a sub-loop is to be used all the material from the start of the main loop and
+up to the end of the entire subloop should be braced; these braces will be
+removed and do not create a group. The simplest to allow the nesting of one or
+more sub-loops is to brace everything between \csa{xintloop} and \csa{repeat},
+being careful not to leave a space between the closing brace and |\repeat|.
As this loop and \csbxint{iloop} will primarily be of interest to experienced
\TeX{} macro programmers, my description will assume that the user is
-knowledgeable enough. The iterated commands may contain |\par| tokens or empty
-lines.
+knowledgeable enough. Some examples in this document will be perhaps more
+illustrative than my attemps at explanation of use.
-One can abort the loop with \csbxint{breakloop}; this should not be used in the
-final test, and one should expand the |\fi| from the corresponding test before.
-One has also \csbxint{breakloopanddo} whose first argument will be inserted in
-the token stream after the loop; one may need a macro such as |\xint_afterfi| to
-move the whole thing after the |\fi|, as a simple |\expandafter| will not be
-enough.
+One can abort the loop with \csbxint{breakloop}; this should not be used inside
+the final test, and one should expand the |\fi| from the corresponding test
+before. One has also \csbxint{breakloopanddo} whose first argument will be
+inserted in the token stream after the loop; one may need a macro such as
+|\xint_afterfi| to move the whole thing after the |\fi|, as a simple
+|\expandafter| will not be enough.
One will usually employ some count registers to manage the exit test from the
loop; this breaks expandability, see \csbxint{iloop} for an expandable integer
@@ -4117,14 +4469,18 @@ illustrate use of the nesting capabilities of |\xintloop|.\footnote{for a more
\label{xintouteriloopindex}
%{\small New with release |1.09g|.\par}
-\csa{xintiloop}|[start+delta]|\meta{stuff}|\if<test> ... \repeat|\etype{} is a
-completely expandable nestable loop having access via \csbxint{iloopindex} to
-the integer index of the iteration, with starting value |start| (which may be a
-|\count|) and increment |delta| (\emph{id.}). Currently |[start+delta]| is a
-\emph{mandatory argument}, it is an error to omit it; perhaps a future release
-will make it optional with default |1+1|. A space after the closing square
-bracket is not significant, it will be ignored. Spaces inside the square
-brackets will also be ignored as the two arguments are first given to a
+\csa{xintiloop}|[start+delta]|\meta{stuff}|\if<test> ... \repeat|\retype{} is a
+completely expandable nestable loop. complete expandability depends naturally on
+the actual iterated contents, and complete expansion will not be achievable
+under a sole \fexpan sion, as is indicated by the hollow star in the margin;
+thus the loop can be used inside an |\edef| but not inside arguments to the
+package macros. It can be used inside an |\xintexpr..\relax|.
+
+This loop benefits via \csbxint{iloopindex} to (a limited access to) the integer
+index of the iteration. The starting value |start| (which may be a |\count|) and
+increment |delta| (\emph{id.}) are mandatory arguments. A space after the
+closing square bracket is not significant, it will be ignored. Spaces inside the
+square brackets will also be ignored as the two arguments are first given to a
|\numexpr...\relax|. Empty lines and explicit |\par| tokens are accepted.
As with \csbxint{loop}, this tool will mostly be of interest to advanced users.
@@ -4188,12 +4544,13 @@ of |\endtemplate|; in such cases one can always either replace |&| by a macro
expanding to it or replace it by a suitable |\firstofone{&}|, and similarly for
|\cr|.
+\phantomsection\label{edefprimes}
As an example, let us construct an |\edef\z{...}| which will define |\z| to be a
list of prime numbers:
\dverb|@
\edef\z
-{\xintiloop [10001+2]%
- {\xintiloop [3+2]%
+{\xintiloop [10001+2]
+ {\xintiloop [3+2]
\ifnum\xintouteriloopindex<\numexpr\xintiloopindex*\xintiloopindex\relax
\xintouteriloopindex,
\expandafter\xintbreakiloop
@@ -4207,8 +4564,8 @@ list of prime numbers:
\meaning\z|
\begingroup%\ttfamily
\edef\z
-{\xintiloop [10001+2]%
- {\xintiloop [3+2]%
+{\xintiloop [10001+2]
+ {\xintiloop [3+2]
\ifnum\xintouteriloopindex<\numexpr\xintiloopindex*\xintiloopindex\relax
\xintouteriloopindex,
\expandafter\xintbreakiloop
@@ -4372,6 +4729,7 @@ which is described later; none of this uses count registers.
\end{tabular}\par }
\subsection{A table of factorizations}
+\label{ssec:factorizationtable}
As one more example with \csbxint{iloop} let us use an alignment to display the
factorization of some numbers. The loop will actually only play a minor r\^ole
@@ -4392,7 +4750,7 @@ To spare some fractions of a second in the compilation time of this document
\tabskip1ex
\halign {\hfil\strut#\hfil&&\hfil#\hfil\cr\noalign{\hrule}
\xintiloop ["7FFFFFE0+1]
- \expandafter\bf\xintiloopindex &
+ \expandafter\bfseries\xintiloopindex &
\ifnum\xintiloopindex="7FFFFFED
\number"7FFFFFED\cr\noalign{\hrule}
\expandafter\xintiloopskiptonext
@@ -4400,7 +4758,7 @@ To spare some fractions of a second in the compilation time of this document
\expandafter\factorize\xintiloopindex.\cr\noalign{\hrule}
\ifnum\xintiloopindex<"7FFFFFFE
\repeat
- \bf \number"7FFFFFFF&\number "7FFFFFFF\cr\noalign{\hrule}
+ \bfseries \number"7FFFFFFF&\number "7FFFFFFF\cr\noalign{\hrule}
}|\par\smallskip
\endgroup
@@ -4477,7 +4835,7 @@ The reason for some strange looking expressions is to avoid arithmetic overflow.
\tabskip1ex
\centeredline{\vbox{\halign {\hfil\strut#\hfil&&\hfil#\hfil\cr\noalign{\hrule}
\xintiloop ["7FFFFFE0+1]
- \expandafter\bf\xintiloopindex &
+ \expandafter\bfseries\xintiloopindex &
\ifnum\xintiloopindex="7FFFFFED
\number"7FFFFFED\cr\noalign{\hrule}
\expandafter\xintiloopskiptonext
@@ -4485,7 +4843,7 @@ The reason for some strange looking expressions is to avoid arithmetic overflow.
\expandafter\factorize\xintiloopindex.\cr\noalign{\hrule}
\ifnum\xintiloopindex<"7FFFFFFE
\repeat
- \bf \number"7FFFFFFF&\number "7FFFFFFF\cr\noalign{\hrule}
+ \bfseries \number"7FFFFFFF&\number "7FFFFFFF\cr\noalign{\hrule}
}}}
\centeredline{A table of factorizations}
\end{figure*}
@@ -5161,7 +5519,275 @@ been put in a \hyperref[primes]{float}, which appears
\end{tabular}
\end{figure*}?
+\subsection{Some arithmetic with Fibonacci numbers}
+\label{ssec:fibonacci}
+
+Here is again the code employed on the title page to compute Fibonacci numbers:
+
+\begingroup\footnotesize\baselineskip10pt
+\def\MacroFont {\ttfamily}
+\dverb|@
+\def\Fibonacci #1{% \Fibonacci{N} computes F(N) with F(0)=0, F(1)=1.
+ \expandafter\Fibonacci_a\expandafter
+ {\the\numexpr #1\expandafter}\expandafter
+ {\romannumeral0\xintiieval 1\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 1\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 0\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 1\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 0\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 1\relax}}
+%
+\def\Fibonacci_a #1{%
+ \ifcase #1
+ \expandafter\Fibonacci_end_i
+ \or
+ \expandafter\Fibonacci_end_ii
+ \else
+ \ifodd #1
+ \expandafter\expandafter\expandafter\Fibonacci_b_ii
+ \else
+ \expandafter\expandafter\expandafter\Fibonacci_b_i
+ \fi
+ \fi {#1}%
+}% (* signs omitted from the next macros, 1.09j has tacit multiplication)
+\def\Fibonacci_b_i #1#2#3#4{\expandafter\Fibonacci_a\expandafter
+ {\the\numexpr #1/2\expandafter}\expandafter
+ {\romannumeral0\xintiieval sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval (#2+#4)#3\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval sqr(#3)+sqr(#4)\relax}%
+}% end of Fibonacci_b_i
+\def\Fibonacci_b_ii #1#2#3#4#5#6#7{\expandafter\Fibonacci_a\expandafter
+ {\the\numexpr (#1-1)/2\expandafter}\expandafter
+ {\romannumeral0\xintiieval sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval (#2+#4)#3\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval sqr(#3)+sqr(#4)\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval #2#5+#3#6\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval #2#6+#3#7\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval #3#6+#4#7\relax}%
+}% end of Fibonacci_b_ii
+\def\Fibonacci_end_i #1#2#3#4#5#6#7{{#5}{#6}}% {F(N+1)}{F(N)} in \xintexpr format
+\def\Fibonacci_end_ii #1#2#3#4#5#6#7%
+ {\expandafter
+ {\romannumeral0\xintiieval #2#5+#3#6\expandafter\relax
+ \expandafter}\expandafter
+ {\romannumeral0\xintiieval #2#6+#3#7\relax}}% idem.
+% \FibonacciN returns F(N) (also in encapsulated format: needs \xintthe for printing)
+\def\FibonacciN {\expandafter\xint_secondoftwo\romannumeral-`0\Fibonacci }%
+|\par\endgroup
+\catcode`_ 11
+\def\Fibonacci_end_i #1#2#3#4#5#6#7{{#5}{#6}}%
+\def\Fibonacci_end_ii #1#2#3#4#5#6#7%
+ {\expandafter
+ {\romannumeral0\xintiieval #2#5+#3#6\expandafter\relax
+ \expandafter}\expandafter
+ {\romannumeral0\xintiieval #2#6+#3#7\relax}}%
+% \Fibonacci returns {F(N+1)}{F(N)} (both in \xintexpr encapsulation)
+% \FibonacciN returns F(N) (also in encapsulated format)
+\def\FibonacciN {\expandafter\xint_secondoftwo\romannumeral-`0\Fibonacci }%
+\catcode`_ 8
+
+% ok
+% \def\Fibo #1.{\xintthe\FibonacciN {#1}}% to use \xintiloopindex...
+% \message{\xintiloop [0+1]
+% \expandafter\Fibo\xintiloopindex.,
+% \ifnum\xintiloopindex<49 \repeat \xintthe\FibonacciN{50}.}
+
+I have modified the ending, as I now want not only one specific value |F(N)| but
+a pair of successive values which can serve as starting point of another routine
+devoted to compute a whole sequence |F(N), F(N+1), F(N+2),....|. This pair is,
+for efficiency, kept in the encapsulated internal \xintexprname format.
+|\FibonacciN| outputs the single |F(N)|, also as an |\xintexpr|-ession, and
+printing it will thus need the |\xintthe| prefix.
+
+\begingroup\footnotesize\sffamily\baselineskip 10pt\let\MacroFont\ttfamily
+Here a code snippet which
+checks the routine via a \string\message\ of the first @51@ Fibonacci
+numbers (this is not an efficient way to generate a sequence of such
+numbers, it is only for validating \csa{FibonacciN}).
+%
+\dverb|@
+\def\Fibo #1.{\xintthe\FibonacciN {#1}}%
+\message{\xintiloop [0+1] \expandafter\Fibo\xintiloopindex.,
+ \ifnum\xintiloopindex<49 \repeat \xintthe\FibonacciN{50}.}|\par
+\endgroup
+
+The various |\romannumeral0\xintiieval| could very well all have been
+|\xintiiexpr|'s but then we would have needed more |\expandafter|'s.
+Indeed the order of expansion must be controlled for the whole thing to work,
+and |\romannumeral0\xintiieval| is the first expanded form of |\xintiiexpr|.
+
+The way we use |\expandafter|'s to chain successive |\xintexpr| evaluations is
+exactly analogous to well-known expandable techniques made possible by
+|\numexpr|.
+
+\begin{framed}
+ There is a difference though: |\numexpr| is \emph{NOT} expandable, and to
+ force its expansion we must prefix it with |\the| or |\number|. On the other
+ hand |\xintexpr|, |\xintiexpr|, ..., (or |\xinteval|, |\xintieval|, ...)
+ expand fully when prefixed by |\romannumeral-`0|: the computation is fully
+ executed and its result encapsulated in a private format.
+
+ Using |\xintthe| as prefix is necessary to print the result (this is like
+ |\the| for |\numexpr|), but it is not necessary to get the computation done
+ (contrarily to the situation with |\numexpr|).
+
+ And, starting with release |1.09j|, it is also allowed to expand a non
+ |\xintthe| prefixed |\xintexpr|-ession inside an |\edef|: the private format
+ is now protected, hence the error message complaining about a missing
+ |\xintthe| will not be executed, and the integrity of the format will be
+ preserved.
+
+ This new possibility brings some efficiency gain, when one writes
+ non-expandable algorithms using \xintexprname. If |\xintthe| is
+ employed inside |\edef| the number or fraction will be un-locked into
+ its possibly hundreds of digits and all these tokens will possibly
+ weigh on the upcoming shuffling of (braced) tokens. The private
+ encapsulated format has only a few tokens, hence expansion will
+ proceed a bit faster.
+
+ \indent see footnote\footnotemark
+\end{framed}
+
+\footnotetext{To be completely honest the examination by \TeX{} of all
+ successive digits was not avoided, as it occurs already in the locking-up of
+ the result, what is avoided is to spend time un-locking, and then have
+ the macros shuffle around possibly hundreds of digit tokens rather
+ than a few control words.\par
+ Technical note: I decided (somewhat hesitantly) for
+ reasons of optimization purposes to skip in the private \csa{xintexpr}
+ format a \csa{protect}-ion for the \csa{.=digits/digits[digits]}
+ control sequences used internally. Thus in the improbable case that
+ some macro package (such control sequence names are unavailable to the
+ casual user) has given a meaning to one such control sequence, there
+ is a possibility of a crash when embedding an \csa{xintexpr} without
+ \csa{xintthe} prefix in an \csa{edef} (the computations by themselves
+ do proceed perfectly correctly even if these control sequences have
+ acquired some non \csa{relax} meaning).}
+
+Our |\Fibonacci| expands completely under \fexpan sion,
+so we can use \hyperref[fdef]{\ttfamily\char92fdef} rather than |\edef| in a
+situation such as \centeredline {|\fdef \X {\FibonacciN {100}}|} but for the
+reasons explained above, it is as efficient to employ |\edef|. And if we want
+\centeredline{|\edef \Y {(\FibonacciN{100},\FibonacciN{200})}|,} then |\edef| is
+necessary.
+
+Allright, so let's now give the code to generate a sequence of braced Fibonacci
+numbers |{F(N)}{F(N+1)}{F(N+2)}...|, using |\Fibonacci| for the first
+two and then using the standard recursion |F(N+2)=F(N+1)+F(N)|:
+
+\catcode`_ 11
+\def\FibonacciSeq #1#2{%#1=starting index, #2>#1=ending index
+ \expandafter\Fibonacci_Seq\expandafter
+ {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2-1}%
+}%
+\def\Fibonacci_Seq #1#2{%
+ \expandafter\Fibonacci_Seq_loop\expandafter
+ {\the\numexpr #1\expandafter}\romannumeral0\Fibonacci {#1}{#2}%
+}%
+\def\Fibonacci_Seq_loop #1#2#3#4{% standard Fibonacci recursion
+ {#3}\unless\ifnum #1<#4 \Fibonacci_Seq_end\fi
+ \expandafter\Fibonacci_Seq_loop\expandafter
+ {\the\numexpr #1+1\expandafter}\expandafter
+ {\romannumeral0\xintiieval #2+#3\relax}{#2}{#4}%
+}%
+\def\Fibonacci_Seq_end\fi\expandafter\Fibonacci_Seq_loop\expandafter
+ #1\expandafter #2#3#4{\fi {#3}}%
+\catcode`_ 8
+
+\begingroup\footnotesize\baselineskip10pt
+\def\MacroFont {\ttfamily}
+\dverb|@
+\catcode`_ 11
+\def\FibonacciSeq #1#2{%
+ \expandafter\Fibonacci_Seq\expandafter
+ {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2-1}%
+}%
+\def\Fibonacci_Seq #1#2{%
+ \expandafter\Fibonacci_Seq_loop\expandafter
+ {\the\numexpr #1\expandafter}\romannumeral0\Fibonacci {#1}{#2}%
+}%
+\def\Fibonacci_Seq_loop #1#2#3#4{% standard Fibonacci recursion
+ {#3}\unless\ifnum #1<#4 \Fibonacci_Seq_end\fi
+ \expandafter\Fibonacci_Seq_loop\expandafter
+ {\the\numexpr #1+1\expandafter}\expandafter
+ {\romannumeral0\xintiieval #2+#3\relax}{#2}{#4}%
+}%
+\def\Fibonacci_Seq_end\fi\expandafter\Fibonacci_Seq_loop\expandafter
+ #1\expandafter #2#3#4{\fi {#3}}%
+\catcode`_ 8
+|\par\endgroup
+
+Deliberately and for optimization, this |\FibonacciSeq| macro is
+completely expandable but not \fexpan dable. It would be easy to modify
+it to be so. But I wanted to check that the \csbxint{For*} does apply
+full expansion to what comes next each time it fetches an item from its
+list argument. Thus, there is no need to generate lists of braced
+Fibonacci numbers beforehand, as \csbxint{For*}, without using any
+|\edef|, still manages to generate the list via iterated full expansion.
+
+I initially used only one |\halign| in a three-column |multicols|
+environment, but |multicols| only knows to divide the page horizontally
+evenly, thus I employed in the end one |\halign| for each column (I
+could have then used a |tabular| as no column break was then needed).
+
+
+\begin{figure*}[ht!]
+ \phantomsection\label{fibonacci}
+ \newcounter{index}
+ \fdef\Fibxxx{\FibonacciN {30}}%
+ \setcounter{index}{30}%
+\centeredline{\tabskip 1ex
+\vbox{\halign{\bfseries#.\hfil&#\hfil &\hfil #\cr
+ \xintFor* #1 in {\FibonacciSeq {30}{59}}\do
+ {\theindex &\xintthe#1 &
+ \xintRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{index}\cr }}%
+}\vrule
+\vbox{\halign{\bfseries#.\hfil&#\hfil &\hfil #\cr
+ \xintFor* #1 in {\FibonacciSeq {60}{89}}\do
+ {\theindex &\xintthe#1 &
+ \xintRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{index}\cr }}%
+}\vrule
+\vbox{\halign{\bfseries#.\hfil&#\hfil &\hfil #\cr
+ \xintFor* #1 in {\FibonacciSeq {90}{119}}\do
+ {\theindex &\xintthe#1 &
+ \xintRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{index}\cr }}%
+}}%
+%
+\centeredline{Some Fibonacci numbers together with their residues modulo
+ |F(30)|\digitstt{=\xintthe\Fibxxx}}
+\end{figure*}
+
+\begingroup\footnotesize\baselineskip10pt
+\def\MacroFont {\ttfamily}
+\dverb|@
+\newcounter{index}
+\tabskip 1ex
+ \fdef\Fibxxx{\FibonacciN {30}}%
+ \setcounter{index}{30}%
+\vbox{\halign{\bfseries#.\hfil&#\hfil &\hfil #\cr
+ \xintFor* #1 in {\FibonacciSeq {30}{59}}\do
+ {\theindex &\xintthe#1 &
+ \xintRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{index}\cr }}%
+}\vrule
+\vbox{\halign{\bfseries#.\hfil&#\hfil &\hfil #\cr
+ \xintFor* #1 in {\FibonacciSeq {60}{89}}\do
+ {\theindex &\xintthe#1 &
+ \xintRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{index}\cr }}%
+}\vrule
+\vbox{\halign{\bfseries#.\hfil&#\hfil &\hfil #\cr
+ \xintFor* #1 in {\FibonacciSeq {90}{119}}\do
+ {\theindex &\xintthe#1 &
+ \xintRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{index}\cr }}%
+}%
+|\par\endgroup
+
+This produces the Fibonacci numbers from |F(30)| to |F(119)|, and
+computes also all the
+congruence classes modulo |F(30)|. The output has
+been put in a \hyperref[fibonacci]{float}, which appears
+\vpageref[above]{fibonacci}. I leave to the mathematically inclined
+readers the task to explain the visible patterns\dots |;-)|.
\subsection{\csbh{xintForpair}, \csbh{xintForthree}, \csbh{xintForfour}}\label{xintForpair}\label{xintForthree}\label{xintForfour}
% {\small New in |1.09c|. The \csa{xintifForFirst}
@@ -5203,41 +5829,52 @@ separated list and the replacement text.
% substantially modified at some later stage.
\subsection{\csbh{xintAssign}}\label{xintAssign}
-%\small{ |1.09i| adds optional parameter.\par}
+%\small{ |1.09i| adds optional parameter. |1.09j| has default optional
+% parameter |[]| rather than |[e]|\par}
\csa{xintAssign}\meta{braced things}\csa{to}%
-\meta{as many cs as they are things}\ntype{{(f$\to$\lowast x)}{\lowast N}}
-defines (without checking if
-something gets overwritten) the control sequences on the right of
-\csa{to} to be the complete expansions of the successive braced things found on
-the left of \csa{to}. It is not expandable.
+\meta{as many cs as they are things} %\ntype{{(f$\to$\lowast [x)}{\lowast N}}
+%
+defines (without checking if something gets overwritten) the control sequences
+on the right of \csa{to} to expand to the successive tokens or braced items
+found one after the otehr on the on the left of \csa{to}. It is not expandable.
A `full' expansion is first applied to the material in front of
\csa{xintAssign}, which may thus be a macro expanding to a list of braced items.
-\xintAssign [oo]\xintiPow {7}{13}\to\SevenToThePowerThirteen
-\xintAssign [oo]\xintDivision{1000000000000}{133333333}\to\Q\R
+\xintAssign \xintiPow {7}{13}\to\SevenToThePowerThirteen
+\xintAssign \xintDivision{1000000000000}{133333333}\to\Q\R
Special case: if after this initial expansion no brace is found immediately
after \csa{xintAssign}, it is assumed that there is only one control sequence
following |\to|, and this control sequence is then defined via
-|\edef|\ntype{xN} as the complete expansion of the material between
-\csa{xintAssign} and \csa{to}.
-\centeredline{|\xintAssign [oo]\xintDivision{1000000000000}{133333333}\to\Q\R|}
+|\def| to expand to the material between
+\csa{xintAssign} and \csa{to}. Other types of expansions are specified through
+an optional parameter to \csa{xintAssign}, see \emph{infra}.
+\centeredline{|\xintAssign \xintDivision{1000000000000}{133333333}\to\Q\R|}
\centeredline{|\meaning\Q: |\digitstt{\meaning\Q}, |\meaning\R:|
- \digitstt{\meaning\R}} \centeredline{|\xintAssign [oo]\xintiPow
+ \digitstt{\meaning\R}} \centeredline{|\xintAssign \xintiPow
{7}{13}\to\SevenToThePowerThirteen|}
\centeredline{|\SevenToThePowerThirteen|\digitstt{=\SevenToThePowerThirteen}}
\centeredline{(same as |\edef\SevenToThePowerThirteen{\xintiPow {7}{13}}|)}
-\noindent\csa{xintAssign}\MyMarginNote{New!} admits now an optional parameter,
-for example |\xintAssign [oo]...|. This means that the definitions of the macros
-initially on the right of |\to| will be made with
-\hyperref[oodef]{\ttfamily\char92oodef} which expands twice the replacement
-text. The default is |[e]|, which makes the definitions with |\edef|. Other
-possibilities: |[], [x], [g], [o], [go], [oo], [goo], [f], [gf]|.
+\noindent\csa{xintAssign}\MyMarginNote{Changed!} admits since |1.09i| an
+optional parameter, for example |\xintAssign [e]...| or |\xintAssign [oo]
+...|. The latter means that the definitions of the macros initially on the
+right of |\to| will be made with \hyperref[oodef]{\ttfamily\char92oodef} which
+expands twice the replacement text. The default is simply to make the
+definitions with |\def|, corresponding to an empty optional paramter |[]|.
+Possibilities: |[], [g], [e], [x], [o], [go], [oo], [goo], [f], [gf]|.
+
+In all cases, recall that |\xintAssign| starts with an \fexpan sion of what
+comes next; this produces some list of tokens or braced items, and the
+optional parameter only intervenes to decide the expansion type to be applied
+then to each one of these items.
+\emph{Note:} prior to release |1.09j|, |\xintAssign| did an |\edef| by
+default, but it now does |\def|. Use the optional parameter |[e]| to force use
+of |\edef|.
% This
% macro uses various \csa{edef}'s, thus is incompatible with expansion-only
@@ -5248,47 +5885,50 @@ possibilities: |[], [x], [g], [o], [go], [oo], [goo], [f], [gf]|.
% argument through a |\numexpr...\relax|. |1.09i| adds optional
% parameter. \par}
-\xintAssignArray [oo]\xintBezout {1000}{113}\to\Bez
+\xintAssignArray \xintBezout {1000}{113}\to\Bez
\csa{xintAssignArray}\meta{braced
- things}\csa{to}\csa{myArray}\ntype{{(f$\to$\lowast x)}N} first expands
-fully what comes immediately after |\xintAssignArray| and expects to find a list
-of braced things |{A}{B}...| (or tokens). It then defines \csa{myArray} as a
-macro with one parameter, such that \csa{myArray\x} expands to give the
-completely expanded |x|th braced thing of this original list (the argument
-\texttt{\x} itself is fed to a |\numexpr| by |\myArray|, and |\myArray| expands
-in two steps to its output). With |0| as parameter, \csa{myArray}|{0}| returns
-the number |M| of elements of the array so that the successive elements are
-\csa{myArray}|{1}|, \dots, \csa{myArray}|{M}|.
-\centeredline{|\xintAssignArray [oo]\xintBezout {1000}{113}\to\Bez|} will set
+ things}\csa{to}\csa{myArray} %\ntype{{(f$\to$\lowast x)}N}
+%
+first expands fully what comes immediately after |\xintAssignArray| and
+expects to find a list of braced things |{A}{B}...| (or tokens). It then
+defines \csa{myArray} as a macro with one parameter, such that \csa{myArray\x}
+expands to give the |x|th braced thing of this original
+list (the argument \texttt{\x} itself is fed to a |\numexpr| by |\myArray|,
+and |\myArray| expands in two steps to its output). With |0| as parameter,
+\csa{myArray}|{0}| returns the number |M| of elements of the array so that the
+successive elements are \csa{myArray}|{1}|, \dots, \csa{myArray}|{M}|.
+\centeredline{|\xintAssignArray \xintBezout {1000}{113}\to\Bez|} will set
|\Bez{0}| to \digitstt{\Bez0}, |\Bez{1}| to \digitstt{\Bez1}, |\Bez{2}| to
-\digitstt{\Bez2}, |\Bez{3}| to \digitstt{\Bez3}, |\Bez{4}| to \digitstt{\Bez4},
-and |\Bez{5}| to \digitstt{\Bez5}:
+\digitstt{\Bez2}, |\Bez{3}| to \digitstt{\Bez3}, |\Bez{4}| to
+\digitstt{\Bez4}, and |\Bez{5}| to \digitstt{\Bez5}:
\digitstt{(\Bez3)${}\times{}$\Bez1${}-{}$(\Bez4)${}\times{}$\Bez2${}={}$\Bez5.}
This macro is incompatible with expansion-only contexts.
-\csa{xintAssignArray}\MyMarginNote{New!} admits now an optional parameter, for
-example |\xintAssignArray [oo]...|. This means that the definitions of the
-macros will be made with \hyperref[oodef]{\ttfamily\char92oodef} (defined
-\emph{infra}), which expands twice the replacement text. This is more
-efficient in terms of speed compared to an |\edef|. The default is |[e]|, which
-makes the definitions with |\edef|. Other possibilities: |[], [o], [oo], [f]|.
-Contrarily to \csbxint{Assign} one can not use the |g| here to make the
-definitions global. For this, one should rather do |\xintAssignArray| within a
-group starting with |\globaldefs 1|.
+\csa{xintAssignArray}\MyMarginNote{Changed!} admits now an optional
+parameter, for example |\xintAssignArray [e]...|. This means that the
+definitions of the macros will be made with |\edef|. The default is
+|[]|, which makes the definitions with |\def|. Other possibilities: |[],
+[o], [oo], [f]|. Contrarily to \csbxint{Assign} one can not use the |g|
+here to make the definitions global. For this, one should rather do
+|\xintAssignArray| within a group starting with |\globaldefs 1|.
+
+Note that prior to release |1.09j| each item (token or braced material) was
+submitted to an |\edef|, but the default is now to use |\def|.
\subsection{\csbh{xintRelaxArray}}\label{xintRelaxArray}
-\csa{xintRelaxArray}\csa{myArray}\ntype{N} (globally) sets to \csa{relax} all
-macros which were defined by the previous \csa{xintAssignArray}
-with \csa{myArray} as array macro.
+\csa{xintRelaxArray}\csa{myArray} %\ntype{N}
+%
+(globally) sets to \csa{relax} all macros which were defined by the previous
+\csa{xintAssignArray} with \csa{myArray} as array macro.
\subsection{\csbh{odef}, \csbh{oodef}, \csbh{fdef}}
\label{odef}
\label{oodef}
\label{fdef}
-\csa{oodef}|\controlsequence {<stuff>}|\MyMarginNote{New!} does
+\csa{oodef}|\controlsequence {<stuff>}| does
\dverb|@
\expandafter\expandafter\expandafter\def
\expandafter\expandafter\expandafter\controlsequence
@@ -5593,6 +6233,7 @@ chunk as pivot.
% \par
}
+\phantomsection\label{quicksort}
\begingroup\offinterlineskip
\small
\QSinitialize {{1.0}{0.5}{0.3}{1.5}{1.8}{2.0}{1.7}{0.4}{1.2}{1.4}%
@@ -6068,31 +6709,40 @@ integer is available as \csbxint{iiPrd}, also with \xintfracname loaded.
\subsection{\csbh{xintPow}}\label{xintiPow}\label{xintiiPow}
-\csa{xintPow\n\x}\etype{\Numf\numx} returns |N^x|. When |x| is zero, this is
-1. If |N| is zero and |x<0|, if \verb+|N|>1+ and |x<0| negative, or if
-\verb+|N|>1+ and |x>999999999|, then an error is raised. |2^999999999| has
-\np{301029996} digits; each exact multiplication of two one thousand digits
-numbers already takes a few seconds, so needless to say this bound is completely
-irrealistic. Already |2^9999| has \np{3010} digits,\footnote{on my laptop
- |\string\xintiPow \{2\}\{9999\}| obtains all |3010| digits in about ten or
- eleven seconds. In contrast, the float versions for |8|, |16|, |24|, or even
- more significant figures, do their jobs in circa one hundredth of a second
- (|1.08b|). This is done without |log|/|exp| which are not (yet?) implemented
- in \xintfracname. The \LaTeX3
- \href{http://www.ctan.org/tex-archive/macros/latex/contrib/l3kernel}{l3fp}
- does this with |log|/|exp| and is ten times faster (|16| figures only).} so I
-should perhaps lower the bound to |99999|.
+\csa{xintPow\n\x}\etype{\Numf\numx} returns |N^x|. When |x| is zero, this is 1.
+If |N| is zero and |x<0|, if \verb+|N|>1+ and |x<0| negative, or if \verb+|N|>1+
+and |x>100000|,\MyMarginNote{Changed!} then an error is raised. Indeed |2^50000|
+already has \digitstt{\xintLen{\xintFloatPow [1]{2}{50000}}} digits; each exact
+multiplication of two one thousand digits numbers already takes a few seconds,
+and it would take hours for the expandable computation to conclude with two
+numbers with each circa @15000@ digits. Perhaps some completely expandable but
+not \fexpan dable variants could fare better?
Extended by \xintfracname to fractions (\csbxint{Pow}) and to floats
-(\csbxint{FloatPow}). Negative exponents do not then cause errors anymore. The
-float version is able to deal with things such as |2^999999999| without any
-problem. For example
-|\xintFloatPow[4]{2}{9999}|\digitstt{=\xintFloatPow[4]{2}{9999}} and
-|\xintFloatPow[4]{2}{999999999}| \digitstt{=\xintFloatPow[4]{2}{999999999}}.
+(\csbxint{FloatPow}). Negative exponents do not then cause errors
+anymore. The float version is able to deal with things such as
+|2^999999999| without any problem. For example
+|\xintFloatPow[4]{2}{50000}|\digitstt{=\xintFloatPow[4]{2}{50000}} and
+|\xintFloatPow[4]{2}{999999999}|
+\digitstt{=\xintFloatPow[4]{2}{999999999}}.\footnote{On my laptop
+ |\string\xintiiPow \{2\}\{9999\}| obtains all |3010| digits in about
+ ten or eleven seconds. In contrast, the float versions for |8|, |16|,
+ |24|, or even more significant figures, do their jobs in less than one
+ hundredth of a second (|1.09j|; we used in the text only four
+ significant digits only for reasons of space, not time.) This is done
+ without |log|/|exp| which are not (yet?) implemented in \xintfracname.
+ The \LaTeX3
+ \href{http://www.ctan.org/tex-archive/macros/latex/contrib/l3kernel}{l3fp}
+ does this with |log|/|exp| and is ten times faster (|16| figures
+ only).}
\csa{xintiPow} is a synonym not modified by \xintfracname, and
\csa{xintiiPow} is an integer only variant skipping the \csbxint{Num}
-overhead.\etype{f\numx}
+overhead\etype{f\numx}, it produces the same result as \csa{xintiPow}
+with stricter assumptions on the inputs, and is thus a tiny bit faster.
+Within an \csbxint{iiexpr}|..\relax| the infix operator |^| is mapped
+to \csa{xintiiPow} (in \csbxint{expr}, the \xintfracname routine
+\csbxint{FloatPower} is used instead.)
@@ -6212,7 +6862,7 @@ odd integer and in that case executes the |YES| branch.
\subsection{\csbh{xintFac}}\label{xintiFac}
\csa{xintFac\x}\etype{\numx} returns the factorial. It is an error if the
-argument is negative or at least @10^6@.
+argument is negative or at least @10^5@.% avant 1.09j c'était 1000000.
With \xintfracname loaded, the macro is modified to accept a fraction as
argument, as long as this fraction turns out to be an integer: |\xintFac
@@ -6719,14 +7369,17 @@ when the output is an integer.
\subsection{\csbh{xintTrunc}}\label{xintTrunc}
-\csa{xintTrunc}|{x}{f}|\etype{\numx\Ff} 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}|\digitstt{=\xintTrunc
- {16}{-803.2028/20905.298}}}%
+\csa{xintTrunc}|{x}{f}|\etype{\numx\Ff} returns the integral part, a dot, and
+then the first |x| digits of the decimal
+expansion of the fraction |f|. The
+argument |x| should be non-negative.
+
+In the special case when |f| evaluates to @0@, the output is @0@ with no decimal
+point nor decimal digits, else the post decimal mark digits are always printed.
+A non-zero negative |f| which is smaller in absolute value than |10^{-x}| will
+give @-0.000...@.
+\centeredline{|\xintTrunc
+ {16}{-803.2028/20905.298}|\digitstt{=\xintTrunc {16}{-803.2028/20905.298}}}%
\centeredline{|\xintTrunc {20}{-803.2028/20905.298}|\digitstt{=\xintTrunc
{20}{-803.2028/20905.298}}}%
\centeredline{|\xintTrunc {10}{\xintPow {-11}{-11}}|\digitstt{=\xintTrunc
@@ -6735,25 +7388,128 @@ maintained in the output, also when the digits are all zero.
{12}{\xintPow {-11}{-11}}}}%
\centeredline{|\xintTrunc {12}{\xintAdd {-1/3}{3/9}}|\digitstt{=\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{Recall that |-\string\macro| is not valid as argument to any
- package macro, one must use |\string\xintOpp\string{\string\macro\string}| or
- |\string\xintiOpp\string{\string\macro\string}|, except inside
- |\string\xinttheexpr...\string\relax|.}
+including the last one.
+
+% The identity |\xintTrunc {x}{-f}=-\xintTrunc {x}{f}|
+% holds.\footnote{Recall that |-\string\macro| is not valid as argument to any
+% package macro, one must use |\string\xintOpp\string{\string\macro\string}| or
+% |\string\xintiOpp\string{\string\macro\string}|, except inside
+% |\string\xinttheexpr...\string\relax|.}
\subsection{\csbh{xintiTrunc}}\label{xintiTrunc}
\csa{xintiTrunc}|{x}{f}|\etype{\numx\Ff} returns the integer equal to |10^x|
-times what \csa{xintTrunc}|{x}{f}| would return. \centeredline{|\xintiTrunc
+times what \csa{xintTrunc}|{x}{f}| would produce.
+%
+\centeredline{|\xintiTrunc
{16}{-803.2028/20905.298}|\digitstt{=\xintiTrunc {16}{-803.2028/20905.298}}}%
\centeredline{|\xintiTrunc {10}{\xintPow {-11}{-11}}|\digitstt{=\xintiTrunc
{10}{\xintPow {-11}{-11}}}}%
\centeredline{|\xintiTrunc {12}{\xintPow {-11}{-11}}|\digitstt{=\xintiTrunc
{12}{\xintPow {-11}{-11}}}}%
-Differences between \csa{xintTrunc}|{0}{f}| and \csa{xintiTrunc}|{0}{f}|: the
-former cannot be used inside integer-only macros, and the latter removes the
-decimal point, and never returns |-0| (and removes all superfluous leading
-zeros.)
+The difference between \csa{xintTrunc}|{0}{f}| and \csa{xintiTrunc}|{0}{f}| is
+that the latter never has the decimal mark always present in the former except
+for |f=0|. And \csa{xintTrunc}|{0}{-0.5}| returns ``\digitstt{\xintTrunc
+ 0{-0.5}}'' whereas \csa{xintiTrunc}|{0}{-0.5}| simply returns
+``\digitstt{\xintiTrunc 0{-0.5}}''.
+
+\subsection{\csbh{xintXTrunc}}\label{xintXTrunc}
+
+%{\small New with release |1.09j|.\par}
+
+\csa{xintXTrunc}|{x}{f}|\retype{\numx\Ff} is completely expandable but not
+\fexpan dable, as is indicated by the hollow star in the margin. It can not be
+used as argument to the other package macros, but is designed to be used inside
+an |\edef|, or rather a |\write|. Here is an example session where the user
+after some warming up checks that @1/66049=1/257^2@ has period @257*256=65792@
+(it is also checked here that this is indeed the smallest period).
+%
+\begingroup\small
+\dverb|@
+xxx:_xint $ etex -jobname worksheet-66049
+This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
+ restricted \write18 enabled.
+**\relax
+entering extended mode
+
+*\input xintfrac.sty
+(./xintfrac.sty (./xint.sty (./xinttools.sty)))
+*\message{\xintTrunc {100}{1/71}}% Warming up!
+
+0.01408450704225352112676056338028169014084507042253521126760563380281690140845
+07042253521126760563380
+*\message{\xintTrunc {350}{1/71}}% period is 35
+
+0.01408450704225352112676056338028169014084507042253521126760563380281690140845
+0704225352112676056338028169014084507042253521126760563380281690140845070422535
+2112676056338028169014084507042253521126760563380281690140845070422535211267605
+6338028169014084507042253521126760563380281690140845070422535211267605633802816
+901408450704225352112676056338028169
+*\edef\Z {\xintXTrunc {65792}{1/66049}}% getting serious...
+
+*\def\trim 0.{}\oodef\Z {\expandafter\trim\Z}% removing 0.
+
+*\edef\W {\xintXTrunc {131584}{1/66049}}% a few seconds
+
+*\oodef\W {\expandafter\trim\W}
+
+*\oodef\ZZ {\expandafter\Z\Z}% doubling the period
+
+*\ifx\W\ZZ \message{YES!}\else\message{BUG!}\fi % xint never has bugs...
+YES!
+*\message{\xintTrunc {260}{1/66049}}% check visually that 256 is not a period
+
+0.00001514027464458205271843631243470756559523989765174340262532362337052794137
+6856576178291874214598252812306015231116292449545034746930309315810988811337037
+6538630410755651107511090251177156353616254598858423291798513225029902042423049
+5541189117170585474420505
+*\edef\X {\xintXTrunc {257*128}{1/66049}}% infix here ok, less than 8 tokens
+
+*\oodef\X {\expandafter\trim\X}% we now have the first 257*128 digits
+
+*\oodef\XX {\expandafter\X\X}% was 257*128 a period?
+
+*\ifx\XX\Z \message{257*128 is a period}\else \message{257 * 128 not a period}\fi
+257 * 128 not a period
+*\immediate\write-1 {1/66049=0.\Z... (repeat)}
+
+*\oodef\ZA {\xintNum {\Z}}% we remove the 0000, or we could use next \xintiMul
+
+*\immediate\write-1 {10\string^65792-1=\xintiiMul {\ZA}{66049}}
+
+*% This was slow :( I should write a multiplication, still completely
+
+*% expandable, but not f-expandable, which could be much faster on such cases.
+
+*\bye
+No pages of output.
+Transcript written on worksheet-66049.log.
+xxx:_xint $ |
+\endgroup
+
+Using |\xintTrunc| rather than |\xintXTrunc| would be hopeless on such long
+outputs (and even |\xintXTrunc| needed of the order of seconds to complete
+here). But it is not worth it to use |\xintXTrunc| for less than hundreds of
+digits.
+
+Fraction arguments to |\xintXTrunc| corresponding to a |A/B[N]| with a negative
+|N| are treated somewhat less efficiently (additional memory impact) than for positive or zero |N|. This is because the algorithm tries to work with the
+smallest denominator hence does not extend |B| with zeroes, and technical
+reasons lead to the use of some tricks.\footnote{Technical note: I do not
+ provide an |\char92 xintXFloat| because this would almost certainly mean
+ having to clone the entire core division routines into a ``long division''
+ variant. But this could have given another approach to the implementation of
+ |\char 92 xintXTrunc|, especially for the case of a negative |N|. Doing these
+ things with \TeX{} is an effort. Besides an
+ |\char 92 xintXFloat| would be interesting only if also for example the square
+ root routine was provided in an |X| version (I have not given thought to
+ that). If feasible |X| routines would be interesting in the |\char 92
+ xintexpr| context where things are expanded inside |\char92 csname..\char92
+ endcsname|.}
+
+Contrarily to \csbxint{Trunc}, in the case of the second argument revealing
+itself to be exactly zero, \csbxint{XTrunc} will output @0.000...@, not @0@.
+Also, the first argument must be at least @1@.
\subsection{\csbh{xintRound}}\label{xintRound}
@@ -6974,26 +7730,18 @@ accept fractions on input. The output will now always be in the form |A/B[n]|
{2/3}{0}|\digitstt{=\xintPow{2/3}{0}}). The original is available as
\csbxint{iPow}.
-% \xintDigits:= 3;
-
-The exponent is allowed to be input as a
-fraction but it must simplify to an integer: |\xintPow
-{2/3}{10/2}|\digitstt{=\xintPow {2/3}{10/2}}. This integer will be checked to
-not exceed |999999999|; future releases will presumably lower this limit as
-even much much smaller values already create gigantic numerators and
-denominators which can not be computed exactly in a reasonable time. Indeed
-|2^999999999| has \digitstt{\xintLen {\xintFloatPow [1]{2}{999999999}}} digits.
-
-
-
-% \xintDigits:= 16;
+The exponent is allowed to be input as a fraction but it must simplify to an
+integer: |\xintPow {2/3}{10/2}|\digitstt{=\xintPow {2/3}{10/2}}. This integer
+will be checked to not exceed |100000|. Indeed |2^50000| already has
+\digitstt{\xintLen {\xintFloatPow [1]{2}{50000}}} digits, and squaring such a
+number would take hours (I think) with the expandable routine of \xintname.
\subsection{\csbh{xintFloatPow}}\label{xintFloatPow}
%{\small New with |1.07|.\par}
|\xintFloatPow [P]{f}{x}|\etype{{\upshape[\numx]}\Ff\numx} uses either the
optional argument |P| or the value of |\xintDigits|. It computes a floating
-approximation to |f^x|.
+approximation to |f^x|. The precision |P| must be at least |1|, naturally.
The exponent |x| will be fed to a |\numexpr|, hence count registers are accepted
on input for this |x|. And the absolute value \verb+|x|+ must obey the \TeX{}
@@ -7261,6 +8009,10 @@ through the use of one of the functions |round|, |trunc|, |float|,
\item a sub-expression |\xintexpr...\relax|,
\item or within braces.
\end{enumerate}
+ When a sub-expression is hit against in the midst of absorbing the
+ digits of a number, a |*| multiplication sign is tacitly
+ implied.\MyMarginNote{New!} No such tacit multiplication is implied
+ by an opening parenthesis.
\item an expression can not be given as argument to the other package macros,
nor printed, for this one must use |\xinttheexpr...\relax| or
|\xintthe\xintexpr...\relax|,
@@ -7272,16 +8024,20 @@ through the use of one of the functions |round|, |trunc|, |float|,
\endlist
\endgroup
-% With defined macros destined to be re-used within another one, one has the
-% choice between parentheses or |\xintexpr...\relax|: |\def\x {(\a+\b)}| or
-% |\def\x {\xintexpr \a+\b\relax}|. The latter is better as it allows |\xintthe|.
+In an algorithm implemented non-expandably, one may define macros to
+expand to infix expressions to be used within others. One then has the
+choice between parentheses or |\xintexpr...\relax|: |\def\x {(\a+\b)}|
+or |\def\x {\xintexpr \a+\b\relax}|. The latter is the better choice as
+it allows also to be prefixed with |\xintthe|. Furthemore, if |\a| and
+|\b| are already defined |\oodef\x {\xintexpr \a+\b\relax}| will do the
+computation on the spot.
\subsection{\texorpdfstring{\texttt{\protect\string\numexpr}}{\textbackslash
numexpr} or \texorpdfstring{\texttt{\protect\string\dimexpr}}{\textbackslash
dimexpr} expressions, count and dimension registers and variables}
\label{ssec:countinexpr}
-Count registers,\MyMarginNote{New!} count control sequences, dimen registers,
+Count registers, count control sequences, dimen registers,
dimen control sequences, skips and skip control sequences, |\numexpr|,
|\dimexpr|, |\glueexpr| can be inserted directly, they will be unpacked using
|\number| (which gives the internal value in terms of scaled points for the
@@ -7374,7 +8130,7 @@ is not the same within such macro arguments (or within braces used to protect
square brackets).
-\subsection{Expandability}
+\subsection{Expandability, \csh{xinteval}}
As is the case with all other package macros |\xintexpr| expands in two steps to
its final (non-printable) result; and similarly for |\xinttheexpr|.
@@ -7384,6 +8140,17 @@ except that braces are allowed when they enclose either a fraction (or decimal
number) or something arbitrarily complicated but expanding (in a manner
compatible to an expansion only context) to such a fraction or decimal number.
+The once expanded |\xintexpr| is |\romannumeral0\xinteval|. And there is
+similarly |\xintieval|, |\xintiieval|, and |\xintfloateval|. For the
+other cases one can use |\romannumeral-`0| as prefix.
+
+For the construction of expandable algorithms using chains of
+|\xinteval|-uations see \autoref{ssec:fibonacci}.\MyMarginNote{New!}
+
+An expression can only be legally finished by a |\relax| token, which
+will be absorbed.
+
+
\subsection{Memory considerations}
The parser creates an undefined control sequence for each intermediate
@@ -7394,13 +8161,19 @@ into a computation). So, a moderately sized expression might create 10, or 20
such control sequences. On my \TeX{} installation, the memory available for such
things is of circa \np{200000} multi-letter control words. So this means that a
document containing hundreds, perhaps even thousands of expressions will compile
-with no problem. But, if the package is used for computing plots\footnote{this
- is not very probable as so far \xintname does not include a mathematical
- library with floating point calculations, but provides only the basic
+with no problem.
+
+Besides the hash table, also \TeX{} main memory is impacted. Thus, if
+\xintexprname is used for computing plots\footnote{this is not very
+ probable as so far \xintname does not include a mathematical library
+ with floating point calculations, but provides only the basic
operations of algebra.}, this may cause a problem.
+
+
There is a solution.\footnote{which convinced me that I could stick with the
- parser implementation despite its potential impact on the hash-table.}
+ parser implementation despite its potential impact on the hash-table
+ and other parts of \TeX{}'s memory.}
A
document can possibly do tens of thousands of evaluations only
@@ -7408,13 +8181,14 @@ if some formulas are being used repeatedly, for example inside loops, with
counters being incremented, or with data being fetched from a file. So it is the
same formula used again and again with varying numbers inside.
-With the \csbxint{NewExpr} command, it is possible to convert once and for all
-an expression containing parameters into an expandable macro with parameters.
-Only this initial definition of this macro actually activates the \csbxint{expr}
-parser and will (very moderately) impact the hash-table: once this unique
-parsing is done, a macro with parameters is produced which is built-up
-recursively from the \csbxint{Add}, \csbxint{Mul}, etc... macros, exactly as it
-was necessary to do before the availability of the \xintexprname package.
+With the \csbxint{NewExpr} command, it is possible to convert once and
+for all an expression containing parameters into an expandable macro
+with parameters. Only this initial definition of this macro actually
+activates the \csbxint{expr} parser and will (very moderately) impact
+the hash-table: once this unique parsing is done, a macro with
+parameters is produced which is built-up recursively from the
+\csbxint{Add}, \csbxint{Mul}, etc... macros, exactly as it would be
+necessary to do without the facilities of the \xintexprname package.
\subsection{The \csbh{xintNewExpr} command}\label{xintNewExpr}
@@ -7630,7 +8404,7 @@ produce (long) integers.
To input a fraction to |round|, |trunc|, |floor| or |ceil| one can
use braces, else the |/| will do the euclidean quotient.
-The minus sign should be put together with the fraction: |round(-{30/78})| is
+The minus sign should be put together with the fraction: |round(-{30/18})| is
illegal (even if the fraction had been an integer), use
|round({-30/18})|\digitstt{=\xinttheiiexpr round({-30/18})\relax}.
@@ -7802,6 +8576,11 @@ setting for |\xintDigits|.
Like \csbxint{NewExpr} but using |\xinttheiexpr|. Former denomination was
|\xintNewNumExpr| which is deprecated and should not be used.
+\subsection{\csbh{xintNewIIExpr}}\label{xintNewIIExpr}
+%{\small New in |1.09i|.\par }
+
+Like \csbxint{NewExpr} but using |\xinttheiiexpr|.
+
\subsection{\csbh{xintNewBoolExpr}}\label{xintNewBoolExpr}
%{\small New in |1.09c|.\par }
@@ -7820,14 +8599,27 @@ Obviously I should mention that \csa{xintNewExpr} itself can not be used in an
expansion-only context, as it creates a macro.
The |\escapechar| setting may be arbitrary when using
-|\xintexpr|.\MyMarginNote{New!}
+|\xintexpr|.
+
+The format of the output\MyMarginNote{Changed!} of
+|\xintexpr|\meta{stuff}|\relax| is a |!| (with catcode 11) followed by
+|\XINT_expr_usethe| which prints an error message in the document and in
+the log file if it is executed, then a |\xint_protect| token, a token
+doing the actual printing and finally a token |\.=A/B[n]|. Using
+|\xinttheexpr| means zapping the first three things, the fourth one will
+then unlock |A/B[n]| from the (presumably undefined, but it does not
+matter) control sequence |\.=A/B[n]|.
-The format of the output of |\xintexpr|\meta{stuff}|\relax| is a |!| (with
-catcode 11) followed by |\XINT_expr_usethe| which prints an error message in
-the document and in the log file if it is executed, then a token doing the
-actual printing and finally a token |\.=A/B[n]|. Using |\xinttheexpr| means
-zapping the first two things, the third one will then recover |A/B[n]| from the
-(presumably undefined, but it does not matter) control sequence |\.=A/B[n]|.
+Thanks to the release |1.09j| added |\xint_protect| token and the fact
+that |\XINT_expr_usethe| is |\protected|, one can now use |\xintexpr|
+inside an |\edef|, with no need of the |\xintthe| prefix.
+
+\begin{framed}
+ Note that |\xintexpr| is thus compatible to complete expansion,
+ contrarily to |\numexpr| which is non-expandable if not prefixed by
+ |\the|. See \autoref{ssec:fibonacci} for some illustration.%
+ \MyMarginNote[\kern\dimexpr\FrameSep+\FrameRule\relax]{New!}
+\end{framed}
I decided to put all intermediate results (from each evaluation of an infix
operators, or of a parenthesized subpart of the expression, or from application
@@ -7837,6 +8629,15 @@ expandably and encapsulates an arbitrarily long fraction in a single token (left
with undefined meaning), thus providing tremendous relief to the programmer in
his/her expansion control.
+\begin{framed}
+ As the |\xintexpr| computations corresponding to functions and infix
+ or postfix operators are done inside |\csname...\endcsname|, the
+ \fexpan dability could possibly be dropped and one could imagine
+ implementing the basic operations with expandable but not \fexpan
+ dable macros (as \csbxint{XTrunc}.) I have not investigated that
+ possibility.
+\end{framed}
+
% \begin{framed}
% This implementation and user interface are still to be considered
% \emph{experimental}.
@@ -9078,16 +9879,14 @@ algorithm always gets better than |10^{-D}| precision, but again, strings of
zeros or nines encountered in the decimal expansion may falsify the ending
digits, nines may be zeros (and the last non-nine one should be increased) and
zeros may be nine (and the last non-zero one should be decreased).
+
+\hypertarget{MachinCode}{}
\dverb|@
% pi = 16 Arctg(1/5) - 4 Arctg(1/239) (John Machin's formula)
\def\coeffarctg #1{\the\numexpr\ifodd#1 -1\else1\fi\relax/%
\the\numexpr 2*#1+1\relax [0]}%
% the above computes (-1)^n/(2n+1).
-% Alternatives:
-% \def\coeffarctg #1{1/\the\numexpr\xintiiMON{#1}*(2*#1+1)\relax }%
-% The [0] can *not* be used above, as the denominator is signed.
-% \def\coeffarctg #1{\xintiiMON{#1}/\the\numexpr 2*#1+1\relax [0]}%
-\def\xa {1/25[0]}% 1/5^2, the [0] for faster parsing
+\def\xa {1/25[0]}% 1/5^2, the [0] for (infinitesimally) faster parsing
\def\xb {1/57121[0]}% 1/239^2, the [0] for faster parsing
\def\Machin #1{% \Machin {\mycount} is allowed
\romannumeral0\expandafter\MachinA \expandafter
@@ -9104,7 +9903,7 @@ zeros may be nine (and the last non-zero one should be decreased).
% #3=#4+3: digits for evaluation of the necessary number of terms
% to be kept in the arctangent series, also used to truncate each
% individual summand.
-{\xinttrunc {#4} % must be lowercase to stop \romannumeral0!
+{\xinttrunc {#4} % lowercase macro to match the initial \romannumeral0.
{\xintSub
{\xintMul {16/5}{\xintFxPtPowerSeries {0}{#1}{\coeffarctg}{\xa}{#3}}}
{\xintMul {4/239}{\xintFxPtPowerSeries {0}{#2}{\coeffarctg}{\xb}{#3}}}%
@@ -9188,32 +9987,49 @@ Let us use this variant for a loop showing the build-up of digits:
\end{multicols}
-You want more digits and have some time? Copy the |\Machin|
-code to a Plain \TeX{} or \LaTeX{} document loading \xintseriesname, and
-compile:
-\dverb|@
-\newwrite\outfile
-\immediate\openout\outfile \jobname-out\relax
-\immediate\write\outfile {\Machin {1000}}
-\immediate\closeout\outfile|
-
-This will create a file with the correct first 1000 digits of $\pi$
-after the decimal point. On my laptop (a 2012 model) this took about 42
-seconds last time I tried (and for 200 digits it is less than 1 second).
-As mentioned in the introduction, the file
-\href{http://www.ctan.org/pkg/pi}{pi.tex} by \textsc{D.
- Roegel} shows that orders of magnitude faster computations are
-possible within \TeX{}, but recall our constraints of complete
-expandability and be merciful, please.
-
-% \newwrite\outfile
-% \immediate\openout\outfile \jobname-out\relax
-% \pdfresettimer
-% \immediate\write\outfile {\Machin {1000}}
-% \edef\temps{\the\pdfelapsedtime}
-% \immediate\closeout\outfile
-
-% \temps: \xintRound {2}{\temps/65536} secondes
+\hypertarget{Machin1000}{}
+%
+You want more digits and have some time? Copy the
+\hyperlink{MachinCode}{|\char 92 Machin|} code to a \TeX{} file, and compile it
+with |etex| (or |pdftex|):
+\dverb|@
+% Compile with e-TeX extensions enabled (etex, pdftex, ...)
+\input xintfrac.sty
+\input xintseries.sty
+% pi = 16 Arctg(1/5) - 4 Arctg(1/239) (John Machin's formula)
+\def\coeffarctg #1{\the\numexpr\ifodd#1 -1\else1\fi\relax/%
+ \the\numexpr 2*#1+1\relax [0]}%
+\def\xa {1/25[0]}%
+\def\xb {1/57121[0]}%
+\def\Machin #1{%
+ \romannumeral0\expandafter\MachinA \expandafter
+ {\the\numexpr (#1+3)*5/7\expandafter}\expandafter
+ {\the\numexpr (#1+3)*10/45\expandafter}\expandafter
+ {\the\numexpr #1+3\expandafter}\expandafter
+ {\the\numexpr #1\relax }}%
+\def\MachinA #1#2#3#4%
+{\xinttrunc {#4}
+ {\xintSub
+ {\xintMul {16/5}{\xintFxPtPowerSeries {0}{#1}{\coeffarctg}{\xa}{#3}}}
+ {\xintMul {4/239}{\xintFxPtPowerSeries {0}{#2}{\coeffarctg}{\xb}{#3}}}%
+}}%
+\pdfresettimer
+\oodef\Z {\Machin {1000}}
+\odef\W {\the\pdfelapsedtime}
+\message{\Z}
+\message{computed in \xintRound {2}{\W/65536} seconds.}
+\bye |
+
+This will log the first 1000 digits of $\pi$ after the decimal point. On my
+laptop (a 2012 model) this took about @16@ seconds last time I tried.
+\footnote{With \texttt{1.09i} and earlier \xintname releases, this used to be
+ \digitstt{42} seconds; the \texttt{1.09j} division is much faster with small
+ denominators as occurs here with \digitstt{\char92xa=1/25}, and I believe this
+ to be the main explanation for the speed gain.} As mentioned in the
+introduction, the file \href{http://www.ctan.org/pkg/pi}{pi.tex} by \textsc{D.
+ Roegel} shows that orders of magnitude faster computations are possible within
+\TeX{}, but recall our constraints of complete expandability and be merciful,
+please.
\textbf{Why truncating rather than rounding?} One of our main competitors
@@ -10039,7 +10855,7 @@ first place.
\fi
\XINT_providespackage
\ProvidesPackage {xinttools}%
- [2013/12/18 v1.09i Expandable and non-expandable utilities (jfB)]%
+ [2014/01/09 v1.09j Expandable and non-expandable utilities (jfB)]%
% \end{macrocode}
% \subsection{Token management, constants}
% \lverb|In 1.09e \xint_undef replaced everywhere by \xint_bye.
@@ -10058,9 +10874,9 @@ first place.
\xint_firstofone{\let\XINT_sptoken= } %<- space here!
\long\def\xint_firstoftwo #1#2{#1}%
\long\def\xint_secondoftwo #1#2{#2}%
-\long\def\xint_firstoftwo_afterstop #1#2{ #1}%
-\long\def\xint_secondoftwo_afterstop #1#2{ #2}%
-\def\xint_minus_afterstop { -}%
+\long\def\xint_firstoftwo_thenstop #1#2{ #1}%
+\long\def\xint_secondoftwo_thenstop #1#2{ #2}%
+\def\xint_minus_thenstop { -}%
\long\def\xint_gob_til_R #1\R {}%
\long\def\xint_gob_til_W #1\W {}%
\long\def\xint_gob_til_Z #1\Z {}%
@@ -10073,7 +10889,16 @@ first place.
\chardef\xint_c_viii 8
\newtoks\XINT_toks
% \end{macrocode}
-% \subsection{ \csh{XINT\_odef}, \csh{XINT\_godef}, \csh{odef}}
+% \subsection{ \csh{xintodef}, \csh{xintgodef}, \csh{odef}}
+% \lverb|1.09i. For use in \xintAssign. No parameter text! 1.09j uses \xint...
+% rather than \XINT_.... \xintAssign [o] will use the preexisting \odef if there
+% was one before xint' loading.|
+% \begin{macrocode}
+\def\xintodef #1{\expandafter\def\expandafter#1\expandafter }%
+\ifdefined\odef\else\let\odef\xintodef\fi
+\def\xintgodef {\global\xintodef }%
+% \end{macrocode}
+% \subsection{ \csh{xintoodef}, \csh{xintgoodef}, \csh{oodef}}
% \lverb|1.09i. Can be prefixed with \global. No parameter text. The alternative
% $\
% $null \def\oodef #1#{\def\XINT_tmpa{#1}%$\
@@ -10082,28 +10907,22 @@ first place.
% $null $quad $quad $quad \expandafter\expandafter\expandafter\XINT_tmpa$\
% $null $quad $quad $quad \expandafter\expandafter\expandafter }%$\
% could not be prefixed by \global. Anyhow, macro parameter tokens would have to
-% somehow not be seen by expanded stuff, except if designed for it.|
-% \begin{macrocode}
-\def\XINT_odef #1{\expandafter\def\expandafter#1\expandafter }%
-\ifdefined\odef\else\let\odef\XINT_odef\fi
-\def\XINT_godef {\global\XINT_odef }%
-% \end{macrocode}
-% \subsection{ \csh{XINT\_oodef}, \csh{XINT\_goodef}, \csh{oodef}}
-% \lverb|1.09i. For use in \xintAssign. No parameter text!|
+% somehow not be seen by expanded stuff, except if designed for it.
+% \xintAssign [oo] (etc...) uses the pre-existing \oodef if there was one. |
% \begin{macrocode}
-\def\XINT_oodef #1{\expandafter\expandafter\expandafter\def
+\def\xintoodef #1{\expandafter\expandafter\expandafter\def
\expandafter\expandafter\expandafter#1%
\expandafter\expandafter\expandafter }%
-\ifdefined\oodef\else\let\oodef\XINT_oodef\fi
-\def\XINT_goodef {\global\XINT_oodef }%
+\ifdefined\oodef\else\let\oodef\xintoodef\fi
+\def\xintgoodef {\global\xintoodef }%
% \end{macrocode}
-% \subsection{ \csh{XINT\_fdef}, \csh{XINT\_gfdef}, \csh{fdef}}
+% \subsection{ \csh{xintfdef}, \csh{xintgfdef}, \csh{fdef}}
% \lverb|1.09i. No parameter text! |
% \begin{macrocode}
-\def\XINT_fdef #1#2{\expandafter\def\expandafter#1\expandafter
+\def\xintfdef #1#2{\expandafter\def\expandafter#1\expandafter
{\romannumeral-`0#2}}%
-\ifdefined\fdef\else\let\fdef\XINT_fdef\fi
-\def\XINT_gfdef {\global\XINT_fdef }%
+\ifdefined\fdef\else\let\fdef\xintfdef\fi
+\def\xintgfdef {\global\xintfdef }% should be \global\fdef if \fdef pre-exists?
% \end{macrocode}
% \subsection{ \csh{xintReverseOrder}}
% \lverb|\xintReverseOrder: does NOT expand its argument.|
@@ -10656,7 +11475,7 @@ first place.
\def\XINT_seq #1#2%
{%
\ifcase\ifnum #1=#2 0\else\ifnum #2>#1 1\else -1\fi\fi\space
- \expandafter\xint_firstoftwo_afterstop
+ \expandafter\xint_firstoftwo_thenstop
\or
\expandafter\XINT_seq_p
\else
@@ -10667,20 +11486,20 @@ first place.
\def\XINT_seq_p #1#2%
{%
\ifnum #1>#2
- \xint_afterfi{\expandafter\XINT_seq_p}%
+ \expandafter\expandafter\expandafter\XINT_seq_p
\else
\expandafter\XINT_seq_e
\fi
- \expandafter{\the\numexpr #1-1}{#2}{#1}%
+ \expandafter{\the\numexpr #1-\xint_c_i}{#2}{#1}%
}%
\def\XINT_seq_n #1#2%
{%
\ifnum #1<#2
- \xint_afterfi{\expandafter\XINT_seq_n}%
+ \expandafter\expandafter\expandafter\XINT_seq_n
\else
\expandafter\XINT_seq_e
\fi
- \expandafter{\the\numexpr #1+1}{#2}{#1}%
+ \expandafter{\the\numexpr #1+\xint_c_i}{#2}{#1}%
}%
\def\XINT_seq_e #1#2#3{ }%
\def\XINT_seq_opt [\xint_bye #1]#2#3%
@@ -11248,19 +12067,32 @@ first place.
% 1.09i allows an optional parameter \xintAssign [oo] for example, then \oodef
% rather than \edef is used. Idem for \xintAssignArray. However in the latter
% case, the global variant is not available, one should use \globaldefs for
-% that. |
+% that.
+%
+% 1.09j: I decide that the default behavior of \xintAssign should be to use
+% \def, not \edef when assigning to a cs an item of the list. This is a
+% breaking change but I don't think anybody on earth is using xint anyhow.
+% Also use of the optional parameter was broken if it was [], [g], [e], [x] as
+% the corresponding \XINT_... macros had not been defined (in the initial
+% version I did not have the XINT_ prefix; then I added it in case \oodef was
+% pre-existing and thus was not redefined by the package which instead had
+% \XINT_oodef, now \xintoodef.)|
% \begin{macrocode}
\def\xintAssign{\def\XINT_flet_macro {\XINT_assign_fork}\XINT_flet_zapsp }%
\def\XINT_assign_fork
{%
- \let\XINT_assign_def\edef
+ \let\XINT_assign_def\def
\ifx\XINT_token[\expandafter\XINT_assign_opt
\else\expandafter\XINT_assign_a
\fi
}%
\def\XINT_assign_opt [#1]%
{%
- \expandafter\let\expandafter\XINT_assign_def \csname XINT_#1def\endcsname
+ \ifcsname #1def\endcsname
+ \expandafter\let\expandafter\XINT_assign_def \csname #1def\endcsname
+ \else
+ \expandafter\let\expandafter\XINT_assign_def \csname xint#1def\endcsname
+ \fi
\XINT_assign_a
}%
\long\def\XINT_assign_a #1\to
@@ -11304,15 +12136,19 @@ first place.
\XINT_flet_zapsp }%
\def\XINT_assignarray_fork
{%
- \let\XINT_assignarray_def\edef
+ \let\XINT_assignarray_def\def
\ifx\XINT_token[\expandafter\XINT_assignarray_opt
\else\expandafter\XINT_assignarray
\fi
}%
\def\XINT_assignarray_opt [#1]%
{%
- \expandafter\let\expandafter\XINT_assignarray_def
- \csname XINT_#1def\endcsname
+ \ifcsname #1def\endcsname
+ \expandafter\let\expandafter\XINT_assignarray_def \csname #1def\endcsname
+ \else
+ \expandafter\let\expandafter\XINT_assignarray_def
+ \csname xint#1def\endcsname
+ \fi
\XINT_assignarray
}%
\long\def\XINT_assignarray #1\to #2%
@@ -11424,8 +12260,7 @@ first place.
\else
\ifx\x\relax % plain-TeX, first loading of xint.sty
\ifx\w\relax % but xinttools.sty not yet loaded.
- \y{xint}{Package xinttools is required}%
- \y{xint}{Will try \string\input\space xinttools.sty}%
+ \y{xint}{now issuing \string\input\space xinttools.sty}%
\def\z{\endgroup\input xinttools.sty\relax}%
\fi
\else
@@ -11433,8 +12268,7 @@ first place.
\ifx\x\empty % LaTeX, first loading,
% variable is initialized, but \ProvidesPackage not yet seen
\ifx\w\relax % xinttools.sty not yet loaded.
- \y{xint}{Package xinttools is required}%
- \y{xint}{Will try \string\RequirePackage{xinttools}}%
+ \y{xint}{now issuing \string\RequirePackage{xinttools}}%
\def\z{\endgroup\RequirePackage{xinttools}}%
\fi
\else
@@ -11483,16 +12317,16 @@ first place.
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xint}%
- [2013/12/18 v1.09i Expandable operations on long numbers (jfB)]%
+ [2014/01/09 v1.09j Expandable operations on long numbers (jfB)]%
% \end{macrocode}
% \subsection{Token management, constants}
% \begin{macrocode}
\long\def\xint_firstofthree #1#2#3{#1}%
\long\def\xint_secondofthree #1#2#3{#2}%
\long\def\xint_thirdofthree #1#2#3{#3}%
-\long\def\xint_firstofthree_afterstop #1#2#3{ #1}% 1.09i
-\long\def\xint_secondofthree_afterstop #1#2#3{ #2}%
-\long\def\xint_thirdofthree_afterstop #1#2#3{ #3}%
+\long\def\xint_firstofthree_thenstop #1#2#3{ #1}% 1.09i
+\long\def\xint_secondofthree_thenstop #1#2#3{ #2}%
+\long\def\xint_thirdofthree_thenstop #1#2#3{ #3}%
\def\xint_gob_til_zero #10{}%
\def\xint_gob_til_zeros_iii #1000{}%
\def\xint_gob_til_zeros_iv #10000{}%
@@ -11501,7 +12335,7 @@ first place.
\def\xint_gob_til_minus #1-{}%
\def\xint_gob_til_relax #1\relax {}%
\def\xint_exchangetwo_keepbraces #1#2{{#2}{#1}}%
-\def\xint_exchangetwo_keepbraces_afterstop #1#2{ {#2}{#1}}%
+\def\xint_exchangetwo_keepbraces_thenstop #1#2{ {#2}{#1}}%
\def\xint_UDzerofork #10#2#3\krof {#2}%
\def\xint_UDsignfork #1-#2#3\krof {#2}%
\def\xint_UDwfork #1\W#2#3\krof {#2}%
@@ -11509,17 +12343,21 @@ first place.
\def\xint_UDonezerofork #110#2#3\krof {#2}%
\def\xint_UDzerominusfork #10-#2#3\krof {#2}%
\def\xint_UDsignsfork #1--#2#3\krof {#2}%
-% \chardef\xint_c_ 0 % done in xinttools
+% \chardef\xint_c_ 0 % already done in xinttools
\chardef\xint_c_i 1
\chardef\xint_c_ii 2
\chardef\xint_c_iii 3
\chardef\xint_c_iv 4
\chardef\xint_c_v 5
-% \chardef\xint_c_vi 6 % done in xintfrac
-% \chardef\xinf_c_vii 7 % done in xintfrac
-% \chardef\xint_c_viii 8 % done in xinttools
-\chardef\xint_c_ix 9
-\chardef\xint_c_x 10
+% \chardef\xint_c_vi 6 % will be done in xintfrac
+% \chardef\xinf_c_vii 7 % will be done in xintfrac
+% \chardef\xint_c_viii 8 % already done in xinttools
+\chardef\xint_c_ix 9
+\chardef\xint_c_x 10
+\chardef\xint_c_ii^v 32 % not used in xint, common to xintfrac and xintbinhex
+\chardef\xint_c_ii^vi 64
+\mathchardef\xint_c_ixixixix 9999
+\mathchardef\xint_c_x^iv 10000
\newcount\xint_c_x^viii \xint_c_x^viii 100000000
% \end{macrocode}
% \subsection{\csh{xintRev}}
@@ -11542,7 +12380,7 @@ first place.
\def\XINT_rev_fork #1%
{%
\xint_UDsignfork
- #1{\expandafter\xint_minus_afterstop\romannumeral0\XINT_rord_main {}}%
+ #1{\expandafter\xint_minus_thenstop\romannumeral0\XINT_rord_main {}}%
-{\XINT_rord_main {}#1}%
\krof
}%
@@ -11674,7 +12512,7 @@ first place.
{%
\noexpand\expandafter\space\noexpand\the\numexpr #1#2#3#4\relax
}%
-\def\xint_cleanupzeros_nospace #1#2#3#4%
+\def\xint_cleanupzeros_nostop #1#2#3#4%
{%
\the\numexpr #1#2#3#4\relax
}%
@@ -11800,11 +12638,12 @@ first place.
\def\XINT_num_keepsign_b #1{\XINT_num_loop -}%
\def\XINT_num_finish #1\xint_relax #2\Z { #1}%
% \end{macrocode}
-% \subsection{\csh{xintSgn}, \csh{xintiiSgn}, \csh{XINT\_Sgn}, \csh{XINT\_\_Sgn}}
+% \subsection{\csh{xintSgn}, \csh{xintiiSgn}, \csh{XINT\_Sgn}, \csh{XINT\_cntSgn}}
% \lverb|&
% Changed in 1.05. Earlier code was unnecessarily strange. 1.09a with \xintnum
%
-% 1.09i defines \XINT_Sgn and \XINT__Sgn for reasons of internal optimizations|
+% 1.09i defines \XINT_Sgn and \XINT_cntSgn (was \XINT__Sgn in 1.09i) for reasons
+% of internal optimizations|
% \begin{macrocode}
\def\xintiiSgn {\romannumeral0\xintiisgn }%
\def\xintiisgn #1%
@@ -11832,7 +12671,7 @@ first place.
0-{1}%
\krof
}%
-\def\XINT__Sgn #1#2\Z
+\def\XINT_cntSgn #1#2\Z
{%
\xint_UDzerominusfork
#1-\z@
@@ -11849,24 +12688,23 @@ first place.
\def\xintToggle #1{\romannumeral-`0\iftoggle{#1}{1}{0}}%
% \end{macrocode}
% \subsection{\csh{xintSgnFork}}
-% \lverb|&
-% Expandable three-way fork added in 1.07. The argument #1
-% must expand to -1,0 or 1. 1.09i has _afterstop things for efficiency|
+% \lverb|Expandable three-way fork added in 1.07. The argument #1 must expand
+% to -1,0 or 1. 1.09i has _afterstop, renamed _thenstop later, for efficiency.|
% \begin{macrocode}
\def\xintSgnFork {\romannumeral0\xintsgnfork }%
\def\xintsgnfork #1%
{%
- \ifcase #1 \expandafter\xint_secondofthree_afterstop
- \or\expandafter\xint_thirdofthree_afterstop
- \else\expandafter\xint_firstofthree_afterstop
+ \ifcase #1 \expandafter\xint_secondofthree_thenstop
+ \or\expandafter\xint_thirdofthree_thenstop
+ \else\expandafter\xint_firstofthree_thenstop
\fi
}%
% \end{macrocode}
-% \subsection{\csh{XINT\_\_SgnFork}}
+% \subsection{\csh{XINT\_cntSgnFork}}
% \lverb|1.09i. Used internally, #1 must expand to \m@ne, \z@, or \@ne or
-% equivalent. Does not insert a \romannumeral0 stopping space token.|
+% equivalent. Does not insert a space token to stop a romannumeral0 expansion.|
% \begin{macrocode}
-\def\XINT__SgnFork #1%
+\def\XINT_cntSgnFork #1%
{%
\ifcase #1\expandafter\xint_secondofthree
\or\expandafter\xint_thirdofthree
@@ -11882,15 +12720,16 @@ first place.
% to the transformation of the ternary operator : in \xintNewExpr. I hope I have
% explained there the details because right now off hand I can't recall why.
%
-% 1.09i has \xint_firstofthreeafterstop etc for faster expansion.|
+% 1.09i has \xint_firstofthreeafterstop (now _thenstop) etc for faster
+% expansion.|
% \begin{macrocode}
\def\xintifSgn {\romannumeral0\xintifsgn }%
\def\xintifsgn #1%
{%
\ifcase \romannumeral0\xintsgn{#1}
- \expandafter\xint_secondofthree_afterstop
- \or\expandafter\xint_thirdofthree_afterstop
- \else\expandafter\xint_firstofthree_afterstop
+ \expandafter\xint_secondofthree_thenstop
+ \or\expandafter\xint_thirdofthree_thenstop
+ \else\expandafter\xint_firstofthree_thenstop
\fi
}%
% \end{macrocode}
@@ -11905,18 +12744,18 @@ first place.
\def\xintifzero #1%
{%
\if0\xintSgn{#1}%
- \expandafter\xint_firstoftwo_afterstop
+ \expandafter\xint_firstoftwo_thenstop
\else
- \expandafter\xint_secondoftwo_afterstop
+ \expandafter\xint_secondoftwo_thenstop
\fi
}%
\def\xintifNotZero {\romannumeral0\xintifnotzero }%
\def\xintifnotzero #1%
{%
\if0\xintSgn{#1}%
- \expandafter\xint_secondoftwo_afterstop
+ \expandafter\xint_secondoftwo_thenstop
\else
- \expandafter\xint_firstoftwo_afterstop
+ \expandafter\xint_firstoftwo_thenstop
\fi
}%
% \end{macrocode}
@@ -11927,9 +12766,9 @@ first place.
\def\xintifone #1%
{%
\if1\xintIsOne{#1}%
- \expandafter\xint_firstoftwo_afterstop
+ \expandafter\xint_firstoftwo_thenstop
\else
- \expandafter\xint_secondoftwo_afterstop
+ \expandafter\xint_secondoftwo_thenstop
\fi
}%
% \end{macrocode}
@@ -11945,42 +12784,42 @@ first place.
% \subsection{\csh{xintifCmp}}
% \lverb|&
% 1.09e
-% \xintifCmp {n}{m}{if n<m}{if n=m}{if n>m}. _afterstop in 1.09i.|
+% \xintifCmp {n}{m}{if n<m}{if n=m}{if n>m}.|
% \begin{macrocode}
\def\xintifCmp {\romannumeral0\xintifcmp }%
\def\xintifcmp #1#2%
{%
\ifcase\xintCmp {#1}{#2}
- \expandafter\xint_secondofthree_afterstop
- \or\expandafter\xint_thirdofthree_afterstop
- \else\expandafter\xint_firstofthree_afterstop
+ \expandafter\xint_secondofthree_thenstop
+ \or\expandafter\xint_thirdofthree_thenstop
+ \else\expandafter\xint_firstofthree_thenstop
\fi
}%
% \end{macrocode}
% \subsection{\csh{xintifEq}}
% \lverb|&
% 1.09a
-% \xintifEq {n}{m}{YES if n=m}{NO if n<>m}. _afterstop in 1.09i.|
+% \xintifEq {n}{m}{YES if n=m}{NO if n<>m}.|
% \begin{macrocode}
\def\xintifEq {\romannumeral0\xintifeq }%
\def\xintifeq #1#2%
{%
\if0\xintCmp{#1}{#2}%
- \expandafter\xint_firstoftwo_afterstop
- \else\expandafter\xint_secondoftwo_afterstop
+ \expandafter\xint_firstoftwo_thenstop
+ \else\expandafter\xint_secondoftwo_thenstop
\fi
}%
% \end{macrocode}
% \subsection{\csh{xintifGt}}
% \lverb|&
-% 1.09a \xintifGt {n}{m}{YES if n>m}{NO if n<=m}. _afterstop style in 1.09i|
+% 1.09a \xintifGt {n}{m}{YES if n>m}{NO if n<=m}.|
% \begin{macrocode}
\def\xintifGt {\romannumeral0\xintifgt }%
\def\xintifgt #1#2%
{%
\if1\xintCmp{#1}{#2}%
- \expandafter\xint_firstoftwo_afterstop
- \else\expandafter\xint_secondoftwo_afterstop
+ \expandafter\xint_firstoftwo_thenstop
+ \else\expandafter\xint_secondoftwo_thenstop
\fi
}%
% \end{macrocode}
@@ -11992,8 +12831,8 @@ first place.
\def\xintiflt #1#2%
{%
\ifnum\xintCmp{#1}{#2}<\xint_c_
- \expandafter\xint_firstoftwo_afterstop
- \else \expandafter\xint_secondoftwo_afterstop
+ \expandafter\xint_firstoftwo_thenstop
+ \else \expandafter\xint_secondoftwo_thenstop
\fi
}%
% \end{macrocode}
@@ -12004,9 +12843,9 @@ first place.
\def\xintifodd #1%
{%
\if\xintOdd{#1}1%
- \expandafter\xint_firstoftwo_afterstop
+ \expandafter\xint_firstoftwo_thenstop
\else
- \expandafter\xint_secondoftwo_afterstop
+ \expandafter\xint_secondoftwo_thenstop
\fi
}%
% \end{macrocode}
@@ -12517,7 +13356,7 @@ first place.
% \begin{macrocode}
\def\XINT_add_minusminus #1#2#3#4%
{%
- \expandafter\xint_minus_afterstop%
+ \expandafter\xint_minus_thenstop%
\romannumeral0\XINT_add_pre {#2}{#1}%
}%
\def\XINT_add_minusplus #1#2#3#4%
@@ -12607,7 +13446,7 @@ first place.
\def\xint_sub_mp0\XINT_add_pre #1#2{ #2}%
\def\XINT_sub_plusminus #1#2#3#4%
{%
- \xint_gob_til_zero #3\xint_sub_pm0\expandafter\xint_minus_afterstop%
+ \xint_gob_til_zero #3\xint_sub_pm0\expandafter\xint_minus_thenstop%
\romannumeral0\XINT_add_pre {#2}{#3#1}%
}%
\def\xint_sub_pm #1\XINT_add_pre #2#3{ -#2}%
@@ -12760,7 +13599,7 @@ first place.
\krof
{#3}%
}%
-\def\XINT_sub_DD {\expandafter\xint_minus_afterstop\romannumeral0\XINT_sub_D }%
+\def\XINT_sub_DD {\expandafter\xint_minus_thenstop\romannumeral0\XINT_sub_D }%
\def\XINT_sub_Fdec #1#2#3#4#5#6%
{%
\xint_gob_til_W #3\xint_sub_Fdec_finish\W
@@ -12776,7 +13615,7 @@ first place.
}%
\def\xint_sub_Fdec_finish\W\XINT_sub_Fdec_onestep #1#2%
{%
- \expandafter\xint_minus_afterstop\romannumeral0\XINT_cuz
+ \expandafter\xint_minus_thenstop\romannumeral0\XINT_cuz
}%
\def\XINT_sub_Finc #1#2#3#4#5#6%
{%
@@ -12794,7 +13633,8 @@ first place.
\def\xint_sub_Finc_finish\W\XINT_sub_Finc_onestep #1#2#3%
{%
\xint_UDzerofork
- #1{\expandafter\xint_minus_afterstop\xint_cleanupzeros_nospace}%
+ #1{\expandafter\expandafter\expandafter
+ \xint_minus_thenstop\xint_cleanupzeros_nostop}%
0{ -1}%
\krof
#3%
@@ -12833,7 +13673,7 @@ first place.
}%
\def\xint_sub_KK_finish\W\XINT_sub_KK_onestep #1#2#3%
{%
- \expandafter\xint_minus_afterstop
+ \expandafter\xint_minus_thenstop
\romannumeral0\XINT_cuz_loop #3\W\W\W\W\W\W\W\Z
}%
% \end{macrocode}
@@ -12991,20 +13831,6 @@ first place.
\let\xintNot\xintIsZero
\let\xintIsFalse\xintIsZero
% \end{macrocode}
-% \subsection{\csh{xintIsTrue:csv}}
-% \lverb|1.09c. For use by \xinttheboolexpr.|
-% \begin{macrocode}
-\def\xintIsTrue:csv #1{\expandafter\XINT_istrue:_a\romannumeral-`0#1,,^}%
-\def\XINT_istrue:_a {\XINT_istrue:_b {}}%
-\def\XINT_istrue:_b #1#2,%
- {\expandafter\XINT_istrue:_c\romannumeral-`0#2,{#1}}%
-\def\XINT_istrue:_c #1{\if #1,\expandafter\XINT_:_f
- \else\expandafter\XINT_istrue:_d\fi #1}%
-\def\XINT_istrue:_d #1,%
- {\expandafter\XINT_istrue:_e\romannumeral0\xintisnotzero {#1},}%
-\def\XINT_istrue:_e #1,#2{\XINT_istrue:_b {#2,#1}}%
-\def\XINT_:_f ,#1#2^{\xint_gobble_i #1}%
-% \end{macrocode}
% \subsection{\csh{xintAND}, \csh{xintOR}, \csh{xintXOR}}
% \lverb|1.09a. Embarrasing bugs in \xintAND and \xintOR which inserted a space
% token corrected in 1.09i. \xintxor restyled with \if (faster) in 1.09i|
@@ -13034,17 +13860,6 @@ first place.
\def\XINT_andof_no #1\relax { 0}%
\def\XINT_andof_e #1\Z { 1}%
% \end{macrocode}
-% \subsection{\csh{xintANDof:csv}}
-% \lverb|1.09a. For use by \xintexpr.|
-% \begin{macrocode}
-\def\xintANDof:csv #1{\expandafter\XINT_andof:_a\romannumeral-`0#1,,^}%
-\def\XINT_andof:_a {\expandafter\XINT_andof:_b\romannumeral-`0}%
-\def\XINT_andof:_b #1{\if #1,\expandafter\XINT_andof:_e
- \else\expandafter\XINT_andof:_c\fi #1}%
-\def\XINT_andof:_c #1,{\xintifTrueAelseB {#1}{\XINT_andof:_a}{\XINT_andof:_no}}%
-\def\XINT_andof:_no #1^{0}%
-\def\XINT_andof:_e #1^{1}%
-% \end{macrocode}
% \subsection{\csh{xintORof}}
% \lverb|New with 1.09a. Works also with an empty list.|
% \begin{macrocode}
@@ -13058,17 +13873,6 @@ first place.
\def\XINT_orof_yes #1\relax { 1}%
\def\XINT_orof_e #1\Z { 0}%
% \end{macrocode}
-% \subsection{\csh{xintORof:csv}}
-% \lverb|1.09a. For use by \xintexpr.|
-% \begin{macrocode}
-\def\xintORof:csv #1{\expandafter\XINT_orof:_a\romannumeral-`0#1,,^}%
-\def\XINT_orof:_a {\expandafter\XINT_orof:_b\romannumeral-`0}%
-\def\XINT_orof:_b #1{\if #1,\expandafter\XINT_orof:_e
- \else\expandafter\XINT_orof:_c\fi #1}%
-\def\XINT_orof:_c #1,{\xintifTrueAelseB{#1}{\XINT_orof:_yes}{\XINT_orof:_a}}%
-\def\XINT_orof:_yes #1^{1}%
-\def\XINT_orof:_e #1^{0}%
-% \end{macrocode}
% \subsection{\csh{xintXORof}}
% \lverb|New with 1.09a. Works with an empty list, too. \XINT_xorof_c more
% efficient in 1.09i|
@@ -13086,21 +13890,6 @@ first place.
}%
\def\XINT_xorof_e #1\Z #2{ #2}%
% \end{macrocode}
-% \subsection{\csh{xintXORof:csv}}
-% \lverb|1.09a. For use by \xintexpr.|
-% \begin{macrocode}
-\def\xintXORof:csv #1{\expandafter\XINT_xorof:_a\expandafter
- 0\romannumeral-`0#1,,^}%
-\def\XINT_xorof:_a #1#2,{\expandafter\XINT_xorof:_b\romannumeral-`0#2,#1}%
-\def\XINT_xorof:_b #1{\if #1,\expandafter\XINT_:_e
- \else\expandafter\XINT_xorof:_c\fi #1}%
-\def\XINT_xorof:_c #1,#2%
- {\xintifTrueAelseB {#1}{\if #20\xint_afterfi{\XINT_xorof:_a 1}%
- \else\xint_afterfi{\XINT_xorof:_a 0}\fi}%
- {\XINT_xorof:_a #2}%
- }%
-\def\XINT_:_e ,#1#2^{#1}% allows empty list
-% \end{macrocode}
% \subsection{\csh{xintGeq}}
% \lverb|&
% Release 1.09a has \xintnum added into \xintGeq. Unused and useless \xintiGeq
@@ -13242,17 +14031,17 @@ first place.
% \lverb|&
% A = #4#2, B = #3#1|
% \begin{macrocode}
-\def\XINT_max_zerozero #1#2#3#4{\xint_firstoftwo_afterstop }%
-\def\XINT_max_zeroplus #1#2#3#4{\xint_firstoftwo_afterstop }%
-\def\XINT_max_pluszero #1#2#3#4{\xint_secondoftwo_afterstop }%
-\def\XINT_max_minusplus #1#2#3#4{\xint_firstoftwo_afterstop }%
-\def\XINT_max_plusminus #1#2#3#4{\xint_secondoftwo_afterstop }%
+\def\XINT_max_zerozero #1#2#3#4{\xint_firstoftwo_thenstop }%
+\def\XINT_max_zeroplus #1#2#3#4{\xint_firstoftwo_thenstop }%
+\def\XINT_max_pluszero #1#2#3#4{\xint_secondoftwo_thenstop }%
+\def\XINT_max_minusplus #1#2#3#4{\xint_firstoftwo_thenstop }%
+\def\XINT_max_plusminus #1#2#3#4{\xint_secondoftwo_thenstop }%
\def\XINT_max_plusplus #1#2#3#4%
{%
\ifodd\XINT_Geq {#4#2}{#3#1}
- \expandafter\xint_firstoftwo_afterstop
+ \expandafter\xint_firstoftwo_thenstop
\else
- \expandafter\xint_secondoftwo_afterstop
+ \expandafter\xint_secondoftwo_thenstop
\fi
}%
% \end{macrocode}
@@ -13261,9 +14050,9 @@ first place.
\def\XINT_max_minusminus #1#2#3#4%
{%
\ifodd\XINT_Geq {#1}{#2}
- \expandafter\xint_firstoftwo_afterstop
+ \expandafter\xint_firstoftwo_thenstop
\else
- \expandafter\xint_secondoftwo_afterstop
+ \expandafter\xint_secondoftwo_thenstop
\fi
}%
% \end{macrocode}
@@ -13282,16 +14071,6 @@ first place.
\def\XINT_imaxof_e #1\Z #2\Z { #2}%
\let\xintMaxof\xintiMaxof \let\xintmaxof\xintimaxof
% \end{macrocode}
-% \subsection{\csh{xintiMaxof:csv}}
-% \lverb|1.09i. For use by \xintiiexpr.|
-% \begin{macrocode}
-\def\xintiMaxof:csv #1{\expandafter\XINT_imaxof:_b\romannumeral-`0#1,,}%
-\def\XINT_imaxof:_b #1,#2,{\expandafter\XINT_imaxof:_c\romannumeral-`0#2,{#1},}%
-\def\XINT_imaxof:_c #1{\if #1,\expandafter\XINT_of:_e
- \else\expandafter\XINT_imaxof:_d\fi #1}%
-\def\XINT_imaxof:_d #1,{\expandafter\XINT_imaxof:_b\romannumeral0\xintimax {#1}}%
-\def\XINT_of:_e ,#1,{#1}%
-% \end{macrocode}
% \subsection{\csh{xintMin}}
% \lverb|\xintnum added New with 1.09a.|
% \begin{macrocode}
@@ -13331,17 +14110,17 @@ first place.
% \lverb|&
% A = #4#2, B = #3#1|
% \begin{macrocode}
-\def\XINT_min_zerozero #1#2#3#4{\xint_firstoftwo_afterstop }%
-\def\XINT_min_zeroplus #1#2#3#4{\xint_secondoftwo_afterstop }%
-\def\XINT_min_pluszero #1#2#3#4{\xint_firstoftwo_afterstop }%
-\def\XINT_min_minusplus #1#2#3#4{\xint_secondoftwo_afterstop }%
-\def\XINT_min_plusminus #1#2#3#4{\xint_firstoftwo_afterstop }%
+\def\XINT_min_zerozero #1#2#3#4{\xint_firstoftwo_thenstop }%
+\def\XINT_min_zeroplus #1#2#3#4{\xint_secondoftwo_thenstop }%
+\def\XINT_min_pluszero #1#2#3#4{\xint_firstoftwo_thenstop }%
+\def\XINT_min_minusplus #1#2#3#4{\xint_secondoftwo_thenstop }%
+\def\XINT_min_plusminus #1#2#3#4{\xint_firstoftwo_thenstop }%
\def\XINT_min_plusplus #1#2#3#4%
{%
\ifodd\XINT_Geq {#4#2}{#3#1}
- \expandafter\xint_secondoftwo_afterstop
+ \expandafter\xint_secondoftwo_thenstop
\else
- \expandafter\xint_firstoftwo_afterstop
+ \expandafter\xint_firstoftwo_thenstop
\fi
}%
% \end{macrocode}
@@ -13350,9 +14129,9 @@ first place.
\def\XINT_min_minusminus #1#2#3#4%
{%
\ifodd\XINT_Geq {#1}{#2}
- \expandafter\xint_secondoftwo_afterstop
+ \expandafter\xint_secondoftwo_thenstop
\else
- \expandafter\xint_firstoftwo_afterstop
+ \expandafter\xint_firstoftwo_thenstop
\fi
}%
% \end{macrocode}
@@ -13371,16 +14150,7 @@ first place.
\def\XINT_iminof_e #1\Z #2\Z { #2}%
\let\xintMinof\xintiMinof \let\xintminof\xintiminof
% \end{macrocode}
-% \subsection{\csh{xintiMinof:csv}}
-% \lverb|1.09i. For use by \xintiiexpr.|
-% \begin{macrocode}
-\def\xintiMinof:csv #1{\expandafter\XINT_iminof:_b\romannumeral-`0#1,,}%
-\def\XINT_iminof:_b #1,#2,{\expandafter\XINT_iminof:_c\romannumeral-`0#2,{#1},}%
-\def\XINT_iminof:_c #1{\if #1,\expandafter\XINT_of:_e
- \else\expandafter\XINT_iminof:_d\fi #1}%
-\def\XINT_iminof:_d #1,{\expandafter\XINT_iminof:_b\romannumeral0\xintimin {#1}}%
-% \end{macrocode}
-% \subsection{\csh{xintSum}, \csh{xintSumExpr}}
+% \subsection{\csh{xintSum}}
% \lverb|&
% \xintSum {{a}{b}...{z}}$\
% \xintSumExpr {a}{b}...{z}\relax$\
@@ -13436,17 +14206,6 @@ first place.
}%
\def\XINT_sum_NN #1#2{\XINT_sum_loop {#2}{#1}}%
% \end{macrocode}
-% \subsection{\csh{xintiiSum:csv}}
-% \lverb|1.09i. For use by \xintiiexpr.|
-% \begin{macrocode}
-\def\xintiiSum:csv #1{\expandafter\XINT_iisum:_a\romannumeral-`0#1,,^}%
-\def\XINT_iisum:_a {\XINT_iisum:_b {0}}%
-\def\XINT_iisum:_b #1#2,{\expandafter\XINT_iisum:_c\romannumeral-`0#2,{#1}}%
-\def\XINT_iisum:_c #1{\if #1,\expandafter\XINT_:_e
- \else\expandafter\XINT_iisum:_d\fi #1}%
-\def\XINT_iisum:_d #1,#2{\expandafter\XINT_iisum:_b\expandafter
- {\romannumeral0\xintiiadd {#2}{#1}}}%
-% \end{macrocode}
% \subsection{\csh{xintMul}}
% \lverb|1.09a adds \xintnum|
% \begin{macrocode}
@@ -13507,14 +14266,14 @@ first place.
}%
\def\XINT_mul_minusplus #1#2#3%
{%
- \expandafter\xint_minus_afterstop\romannumeral0\expandafter
+ \expandafter\xint_minus_thenstop\romannumeral0\expandafter
\XINT_mul_choice_a
\expandafter{\romannumeral0\xintlength {#1#3}}%
{\romannumeral0\xintlength {#2}}{#2}{#1#3}%
}%
\def\XINT_mul_plusminus #1#2#3%
{%
- \expandafter\xint_minus_afterstop\romannumeral0\expandafter
+ \expandafter\xint_minus_thenstop\romannumeral0\expandafter
\XINT_mul_choice_a
\expandafter{\romannumeral0\xintlength {#3}}%
{\romannumeral0\xintlength {#1#2}}{#1#2}{#3}%
@@ -13931,7 +14690,7 @@ first place.
\Z\Z\Z\Z #1\W\W\W\W
}%
% \end{macrocode}
-% \subsection{\csh{xintPrd}, \csh{xintPrdExpr}}
+% \subsection{\csh{xintPrd}}
% \lverb|&
% \xintPrd {{a}...{z}}$\
% \xintPrdExpr {a}...{z}\relax$\
@@ -13968,31 +14727,13 @@ first place.
\let\xintprdexpr\xintiiprdexpr
\def\XINT_prdexpr {\XINT_prod_loop_a 1\Z }%
\def\XINT_prod_loop_a #1\Z #2%
-{%
- \expandafter\XINT_prod_loop_b \romannumeral-`0#2\Z #1\Z \Z
-}%
+ {\expandafter\XINT_prod_loop_b \romannumeral-`0#2\Z #1\Z \Z}%
\def\XINT_prod_loop_b #1%
-{%
- \xint_gob_til_relax #1\XINT_prod_finished\relax
- \XINT_prod_loop_c #1%
-}%
+ {\xint_gob_til_relax #1\XINT_prod_finished\relax\XINT_prod_loop_c #1}%
\def\XINT_prod_loop_c
-{%
- \expandafter\XINT_prod_loop_a\romannumeral0\XINT_mul_fork
-}%
+ {\expandafter\XINT_prod_loop_a\romannumeral0\XINT_mul_fork }%
\def\XINT_prod_finished #1\Z #2\Z \Z { #2}%
% \end{macrocode}
-% \subsection{\csh{xintiiPrd:csv}}
-% \lverb|1.09i. For use by \xintiiexpr.|
-% \begin{macrocode}
-\def\xintiiPrd:csv #1{\expandafter\XINT_iiprd:_a\romannumeral-`0#1,,^}%
-\def\XINT_iiprd:_a {\XINT_iiprd:_b {1}}%
-\def\XINT_iiprd:_b #1#2,{\expandafter\XINT_iiprd:_c\romannumeral-`0#2,{#1}}%
-\def\XINT_iiprd:_c #1{\if #1,\expandafter\XINT_:_e
- \else\expandafter\XINT_iiprd:_d\fi #1}%
-\def\XINT_iiprd:_d #1,#2{\expandafter\XINT_iiprd:_b\expandafter
- {\romannumeral0\xintiimul {#2}{#1}}}%
-% \end{macrocode}
% \subsection{\csh{xintFac}}
% \lverb|&
% Modified with 1.02 and again in 1.03 for greater efficiency. I am
@@ -14002,7 +14743,11 @@ first place.
% With release 1.05, rather than using \xintLength I opt finally for direct use
% of \numexpr (which will throw a suitable number too big message), and to raise
% the \xintError:$\ FactorialOfTooBigNumber for argument larger than 1000000
-% (rather than 1000000000). With 1.09a, \xintFac uses \xintnum.|
+% (rather than 1000000000). With 1.09a, \xintFac uses \xintnum.
+%
+% 1.09j for no special reason, I lower the maximal number from 999999 to 100000.
+% Any how this computation would need more memory than TL2013 standard allows to
+% TeX. And I don't even mention time... |
% \begin{macrocode}
\def\xintiFac {\romannumeral0\xintifac }%
\def\xintifac #1%
@@ -14012,7 +14757,7 @@ first place.
\let\xintFac\xintiFac \let\xintfac\xintifac
\def\XINT_fac_fork #1%
{%
- \ifcase\XINT__Sgn #1\Z
+ \ifcase\XINT_cntSgn #1\Z
\xint_afterfi{\expandafter\space\expandafter 1\xint_gobble_i }%
\or
\expandafter\XINT_fac_checklength
@@ -14024,11 +14769,11 @@ first place.
}%
\def\XINT_fac_checklength #1%
{%
- \ifnum #1>999999
+ \ifnum #1>100000
\xint_afterfi{\expandafter\xintError:FactorialOfTooBigNumber
\expandafter\space\expandafter 1\xint_gobble_i }%
\else
- \xint_afterfi{\ifnum #1>9999
+ \xint_afterfi{\ifnum #1>\xint_c_ixixixix
\expandafter\XINT_fac_big_loop
\else
\expandafter\XINT_fac_loop
@@ -14089,17 +14834,29 @@ first place.
}%
% \end{macrocode}
% \subsection{\csh{xintPow}}
-% \lverb|&
-% 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.
-% Modified in 1.06, the exponent is given to a \numexpr rather than twice
-% expanded. \xintnum added in 1.09a. However this added some overhead to some
-% inner macros of the \xintPow routine of xintfrac.sty... we did the similar
-% things correctly for \xintiadd etc, but not here, so 1.09f has now the
-% necessary \xintiipow.|
+% \lverb|1.02 modified the \XINT_posprod routine, the was renamed
+% \XINT_pow_posprod and moved here, as it was well adapted for computing powers.
+% Then 1.03 moved the special variants of multiplication (hence of addition)
+% which were needed to earlier in this style file.
+%
+% Modified in 1.06, the exponent is given to a \numexpr rather than twice
+% expanded. \xintnum added in 1.09a.
+%
+% \XINT_pow_posprod: Routine de produit servant pour le calcul des
+% puissances. Chaque nouveau terme est plus grand que ce qui a déjà été calculé.
+% Par conséquent on a intérêt à le conserver en second dans la routine de
+% multiplication, donc le précédent calcul a intérêt à avoir été donné sur 4n, à
+% l'envers. Il faut donc modifier la multiplication pour qu'elle fasse cela. Ce
+% qui oblige à utiliser une version spéciale de l'addition également.
+%
+% 1.09j has reorganized the main loop, the described above \XINT_pow_posprod
+% routine has been removed, intermediate multiplications are done
+% immediately. Also, the maximal accepted exponent is now 100000 (no such
+% restriction in \xintFloatPow, which accepts any exponent less than 2^31, and
+% in \xintFloatPower which accepts long integers as exponent).
+%
+% 2^100000=9.990020930143845e30102 and multiplication of two numbers
+% with 30000 digits would take hours on my laptop (seconds for 1000 digits).|
% \begin{macrocode}
\def\xintiiPow {\romannumeral0\xintiipow }%
\def\xintiipow #1%
@@ -14136,8 +14893,7 @@ first place.
\expandafter\XINT_opp\romannumeral0\XINT_pow_Anonneg_
}%
% \end{macrocode}
-% \lverb|&
-% B = #3, faire le xpxp. Modified with 1.06: use of \numexpr.|
+% \lverb|B = #3, faire le xpxp. Modified with 1.06: use of \numexpr.|
% \begin{macrocode}
\def\XINT_pow_Anonneg #1#2#3%
{%
@@ -14159,12 +14915,11 @@ first place.
}%
\def\XINT_pow_AisOne #1#2{ 1}%
% \end{macrocode}
-% \lverb|&
-% #1 = B|
+% \lverb|#1 = B|
% \begin{macrocode}
\def\XINT_pow_AisZero #1#2%
{%
- \ifcase\XINT__Sgn #1\Z
+ \ifcase\XINT_cntSgn #1\Z
\xint_afterfi { 1}%
\or
\xint_afterfi { 0}%
@@ -14174,7 +14929,7 @@ first place.
}%
\def\XINT_pow_AatleastTwo #1%
{%
- \ifcase\XINT__Sgn #1\Z
+ \ifcase\XINT_cntSgn #1\Z
\expandafter\XINT_pow_BisZero
\or
\expandafter\XINT_pow_checkBsize
@@ -14183,123 +14938,150 @@ first place.
\fi
{#1}%
}%
-\edef\XINT_pow_BisNegative #1#2{\noexpand\xintError:FractionRoundedToZero\space 0}%
+\edef\XINT_pow_BisNegative #1#2%
+ {\noexpand\xintError:FractionRoundedToZero\space 0}%
\def\XINT_pow_BisZero #1#2{ 1}%
% \end{macrocode}
-% \lverb|&
-% B = #1 > 0, A = #2 > 1. With 1.05, I replace \xintiLen{#1}>9 by direct
-% use
-% of \numexpr [to generate an error message if the exponent is too large]
-% 1.06: \numexpr was already used above.|
+% \lverb|B = #1 > 0, A = #2 > 1. With 1.05, I replace \xintiLen{#1}>9 by
+% direct use of \numexpr [to generate an error message if the exponent is too
+% large] 1.06: \numexpr was already used above.|
% \begin{macrocode}
-\def\XINT_pow_checkBsize #1#2%
+\def\XINT_pow_checkBsize #1%
{%
- \ifnum #1>999999999
+ \ifnum #1>100000
\expandafter\XINT_pow_BtooBig
\else
- \expandafter\XINT_pow_loop
- \fi
- {#1}{#2}\XINT_pow_posprod
- \xint_relax
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_relax
-}%
-\edef\XINT_pow_BtooBig #1\xint_relax #2\xint_relax
- {\noexpand\xintError:ExponentTooBig\space 0}%
-\def\XINT_pow_loop #1#2%
-{%
- \ifnum #1 = 1
- \expandafter\XINT_pow_loop_end
- \else
- \xint_afterfi{\expandafter\XINT_pow_loop_a
- \expandafter{\the\numexpr 2*(#1/2)-#1\expandafter }% b mod 2
- \expandafter{\the\numexpr #1-#1/2\expandafter }% [b/2]
- \expandafter{\romannumeral0\xintiisqr{#2}}}%
+ \expandafter\XINT_pow_loopI
\fi
- {{#2}}%
+ {#1}%
}%
-\def\XINT_pow_loop_end {\romannumeral0\XINT_rord_main {}\relax }%
-\def\XINT_pow_loop_a #1%
+\edef\XINT_pow_BtooBig #1#2{\noexpand\xintError:ExponentTooBig\space 0}%
+\def\XINT_pow_loopI #1%
{%
- \ifnum #1 = 1
- \expandafter\XINT_pow_loop
+ \ifnum #1=\xint_c_i\XINT_pow_Iend\fi
+ \ifodd #1
+ \expandafter\XINT_pow_loopI_odd
\else
- \expandafter\XINT_pow_loop_throwaway
+ \expandafter\XINT_pow_loopI_even
\fi
+ {#1}%
}%
-\def\XINT_pow_loop_throwaway #1#2#3%
+\edef\XINT_pow_Iend\fi #1\fi #2#3{\noexpand\fi\space #3}%
+\def\XINT_pow_loopI_even #1#2%
{%
- \XINT_pow_loop {#1}{#2}%
+ \expandafter\XINT_pow_loopI\expandafter
+ {\the\numexpr #1/\xint_c_ii\expandafter}\expandafter
+ {\romannumeral0\xintiisqr {#2}}%
}%
-% \end{macrocode}
-% \lverb|&
-% Routine de produit servant pour le calcul des puissances. Chaque
-% nouveau
-% terme est plus grand que ce qui a déjà été calculé. Par conséquent on a
-% intérêt à le conserver en second dans la routine de multiplication, donc le
-% précédent calcul a intérêt à avoir été donné sur 4n, à l'envers. Il faut
-% donc modifier la multiplication pour qu'elle fasse cela. Ce qui oblige à
-% utiliser une version spéciale de l'addition également.|
-% \begin{macrocode}
-\def\XINT_pow_posprod #1%
+\def\XINT_pow_loopI_odd #1#2%
{%
- \XINT_pow_pprod_checkifempty #1\Z
+ \expandafter\XINT_pow_loopI_odda\expandafter
+ {\romannumeral0\XINT_RQ {}#2\R\R\R\R\R\R\R\R\Z }{#1}{#2}%
}%
-\def\XINT_pow_pprod_checkifempty #1%
+\def\XINT_pow_loopI_odda #1#2#3%
{%
- \xint_gob_til_relax #1\XINT_pow_pprod_emptyproduct\relax
- \XINT_pow_pprod_RQfirst #1%
+ \expandafter\XINT_pow_loopII\expandafter
+ {\the\numexpr #2/\xint_c_ii-\xint_c_i\expandafter}\expandafter
+ {\romannumeral0\xintiisqr {#3}}{#1}%
}%
-\def\XINT_pow_pprod_emptyproduct #1\Z { 1}%
-\def\XINT_pow_pprod_RQfirst #1\Z
+\def\XINT_pow_loopII #1%
{%
- \expandafter\XINT_pow_pprod_getnext\expandafter
- {\romannumeral0\XINT_RQ {}#1\R\R\R\R\R\R\R\R\Z}%
+ \ifnum #1 = \xint_c_i\XINT_pow_IIend\fi
+ \ifodd #1
+ \expandafter\XINT_pow_loopII_odd
+ \else
+ \expandafter\XINT_pow_loopII_even
+ \fi
+ {#1}%
}%
-\def\XINT_pow_pprod_getnext #1#2%
+\def\XINT_pow_loopII_even #1#2%
{%
- \XINT_pow_pprod_checkiffinished #2\Z {#1}%
+ \expandafter\XINT_pow_loopII\expandafter
+ {\the\numexpr #1/\xint_c_ii\expandafter}\expandafter
+ {\romannumeral0\xintiisqr {#2}}%
}%
-\def\XINT_pow_pprod_checkiffinished #1%
+\def\XINT_pow_loopII_odd #1#2#3%
{%
- \xint_gob_til_relax #1\XINT_pow_pprod_end\relax
- \XINT_pow_pprod_compute #1%
+ \expandafter\XINT_pow_loopII_odda\expandafter
+ {\romannumeral0\XINT_mulr_enter #3\Z\Z\Z\Z #2\W\W\W\W}{#1}{#2}%
}%
-\def\XINT_pow_pprod_compute #1\Z #2%
+\def\XINT_pow_loopII_odda #1#2#3%
{%
- \expandafter\XINT_pow_pprod_getnext\expandafter
- {\romannumeral0\XINT_mulr_enter #2\Z\Z\Z\Z #1\W\W\W\W }%
+ \expandafter\XINT_pow_loopII\expandafter
+ {\the\numexpr #2/\xint_c_ii-\xint_c_i\expandafter}\expandafter
+ {\romannumeral0\xintiisqr {#3}}{#1}%
}%
-\def\XINT_pow_pprod_end\relax\XINT_pow_pprod_compute #1\Z #2%
+\def\XINT_pow_IIend\fi #1\fi #2#3#4%
{%
- \expandafter\xint_cleanupzeros_andstop
- \romannumeral0\xintreverseorder {#2}%
+ \fi\XINT_mul_enter #4\Z\Z\Z\Z #3\W\W\W\W
}%
% \end{macrocode}
% \subsection{\csh{xintDivision}, \csh{xintQuo}, \csh{xintRem}}
-% \lverb|1.09a inserts the use of \xintnum. However this was also used in
-% internal macros in places it should not for reasons of efficency, so in 1.09f
-% I reinstall the private versions with less overhead. Besides, there was some
-% duplicated code in xintfrac.sty which is removed.|
+% \lverb|The 1.09a release inserted the use of \xintnum. The \xintiiDivision
+% etc... are the ones which do only \romannumeral-`0.
+%
+% January 5, 2014: Naturally, addition, subtraction, multiplication and division
+% are the first things I did and since then I had left the division
+% untouched. So in preparation of release 1.09j, I started revisiting the
+% division, I did various minor improvements obtaining roughly
+% 10$% efficiency gain. Then I decided I
+% should deliberately impact the input save stack, with the hope to gain more
+% speed from removing tokens and leaving them upstream.
+%
+% For this however I had to modify the underlying mathematical algorithm. The
+% initial one is a bit unusual I guess, and, I trust, rather efficient, but it
+% does not produce the quotient digits (in base 10000) one by one; at any given
+% time it is possible that some correction will be made, which means it is not
+% an appropriate algorithm for a TeX implementation which will abandon the
+% quotient upstream. Thus I now have with 1.09j a new underlying mathematical
+% algorithm, presumably much more standard. It is a bit complicated to implement
+% expandably these things, but in the end I had regained the already mentioned
+% 10$% efficiency and even more for
+% small to medium sized inputs (up to 30$% perhaps). And in passing I did a
+% special routine for divisors < 10000, which is 5 to 10 times faster still.
+%
+% But, I then tested a variant of my new implementation which again did not
+% impact the input save stack and, for sizes of up to 200 digits, it is not much
+% worse, indeed it is perhaps actually better than the one abandoning the
+% quotient digits upstream (and in the end putting them in the correct order).
+% So, finally, I re-incorporated the produced quotient digits within a tail
+% recursion. Hence \xintDivision, like all other routines in xint (except
+% \xintSeq without optional parameter) still does not impact the input save
+% stack. One can have a produced quotient longer than 4x5000=20000 digits, and
+% no need to worry about \xintTrunc, \xintRound, \xintFloat, \xintFloatSqrt,
+% etc... and all other places using the division.
+%
+% However outputting to a file (which is basically the only thing one can do,
+% multiplying out two 20000 digits numbers already takes hours, for 100000 it
+% would be days if not weeks) 100000 digits is slow... the truncation routine
+% will add 100000 zeros (circa) and then trim them four by four. Definitely I
+% should do a routine XTrunc which will work by blocks of say 64, and
+% furthermore, being destined to be used in and \edef or a \write, it could be
+% much more efficient as it could simply be based on tail loop, which so far
+% nothing in xint does because I want things to expand fully under
+% \romannumeral-`0 (and don't imagine inserting chains of thousands of
+% \expandafter's...) in order to be nestable. Inside \xintexpr such style of
+% tail recursion leaving downstream things should definitely be implemented for
+% the routines for which it is possible as things get expanded inside
+% \csname..\endcsname. I don't do yet anything like this for 1.09j. |
% \begin{macrocode}
\def\xintiiQuo {\romannumeral0\xintiiquo }%
\def\xintiiRem {\romannumeral0\xintiirem }%
-\def\xintiiquo {\expandafter\xint_firstoftwo_afterstop
- \romannumeral0\xintiidivision }%
-\def\xintiirem {\expandafter\xint_secondoftwo_afterstop
- \romannumeral0\xintiidivision }%
+\def\xintiiquo {\expandafter\xint_firstoftwo_thenstop
+ \romannumeral0\xintiidivision }%
+\def\xintiirem {\expandafter\xint_secondoftwo_thenstop
+ \romannumeral0\xintiidivision }%
\def\xintQuo {\romannumeral0\xintquo }%
\def\xintRem {\romannumeral0\xintrem }%
-\def\xintquo {\expandafter\xint_firstoftwo_afterstop
- \romannumeral0\xintdivision }%
-\def\xintrem {\expandafter\xint_secondoftwo_afterstop
- \romannumeral0\xintdivision }%
+\def\xintquo {\expandafter\xint_firstoftwo_thenstop
+ \romannumeral0\xintdivision }%
+\def\xintrem {\expandafter\xint_secondoftwo_thenstop
+ \romannumeral0\xintdivision }%
% \end{macrocode}
-% \lverb|&
-% #1 = A, #2 = B. On calcule le quotient de A par B.$\
-% 1.03 adds the detection of 1 for B.|
+% \lverb|#1 = A, #2 = B. On calcule le quotient et le reste dans la division
+% euclidienne de A par B.|
% \begin{macrocode}
+\def\xintiiDivision {\romannumeral0\xintiidivision }%
\def\xintiidivision #1%
{%
\expandafter\xint_iidivision\expandafter {\romannumeral-`0#1}%
@@ -14317,11 +15099,9 @@ first place.
{%
\expandafter\XINT_div_fork \romannumeral0\xintnum{#2}\Z #1\Z
}%
-\def\XINT_Division #1#2{\romannumeral0\XINT_div_fork #2\Z #1\Z }%
% \end{macrocode}
-% \lverb|&
-% #1#2 = 2e input = diviseur = B.
-% #3#4 = 1er input = divisé = A|
+% \lverb|#1#2 = 2e input = diviseur = B.
+% #3#4 = 1er input = divisé = A.|
% \begin{macrocode}
\def\XINT_div_fork #1#2\Z #3#4\Z
{%
@@ -14347,49 +15127,44 @@ first place.
%
% Cases with B<0 or especially A<0 are treated sub-optimally in terms of
% post-processing, things get reversed which could have been produced directly
-% in the wanted order, but A,B>0 is given priority for optimization. |
+% in the wanted order, but A,B>0 is given priority for optimization. I should
+% revise the next few macros, definitely.|
% \begin{macrocode}
-\def\XINT_div_plusplus #1#2#3#4%
-{%
- \XINT_div_prepare {#3#1}{#4#2}%
-}%
+\def\XINT_div_plusplus #1#2#3#4{\XINT_div_prepare {#3#1}{#4#2}}%
% \end{macrocode}
-% \lverb|&
-% B = #3#1 < 0, A non nul positif ou négatif|
+% \lverb|B = #3#1 < 0, A non nul positif ou négatif|
% \begin{macrocode}
\def\XINT_div_BisNegative #1#2#3#4%
{%
- \expandafter\XINT_div_BisNegative_post
+ \expandafter\XINT_div_BisNegative_b
\romannumeral0\XINT_div_fork #1\Z #4#2\Z
}%
-\edef\XINT_div_BisNegative_post #1%
+\edef\XINT_div_BisNegative_b #1%
{%
\noexpand\expandafter\space\noexpand\expandafter
{\noexpand\romannumeral0\noexpand\XINT_opp #1}%
}%
% \end{macrocode}
-% \lverb|&
-% B = #3#1 > 0, A =-#2< 0|
+% \lverb|B = #3#1 > 0, A =-#2< 0|
% \begin{macrocode}
\def\XINT_div_AisNegative #1#2#3#4%
{%
- \expandafter\XINT_div_AisNegative_post
+ \expandafter\XINT_div_AisNegative_b
\romannumeral0\XINT_div_prepare {#3#1}{#2}{#3#1}%
}%
-\def\XINT_div_AisNegative_post #1#2%
+\def\XINT_div_AisNegative_b #1#2%
{%
\if0\XINT_Sgn #2\Z
- \expandafter \XINT_div_AisNegative_zerorem
+ \expandafter \XINT_div_AisNegative_Rzero
\else
- \expandafter \XINT_div_AisNegative_posrem
+ \expandafter \XINT_div_AisNegative_Rpositive
\fi
{#1}{#2}%
}%
% \end{macrocode}
-% \lverb|&
-% en #3 on a une copie de B (à l'endroit)|
+% \lverb|en #3 on a une copie de B (à l'endroit)|
% \begin{macrocode}
-\edef\XINT_div_AisNegative_zerorem #1#2#3%
+\edef\XINT_div_AisNegative_Rzero #1#2#3%
{%
\noexpand\expandafter\space\noexpand\expandafter
{\noexpand\romannumeral0\noexpand\XINT_opp #1}{0}%
@@ -14399,22 +15174,21 @@ first place.
% remplace Reste par B - Reste, après avoir remplacé Q par -(Q+1)
% de sorte que la formule a = qb + r, 0<= r < |b| est valable!
% \begin{macrocode}
-\def\XINT_div_AisNegative_posrem #1%
+\def\XINT_div_AisNegative_Rpositive #1%
{%
- \expandafter \XINT_div_AisNegative_posrem_b \expandafter
+ \expandafter \XINT_div_AisNegative_Rpositive_b \expandafter
{\romannumeral0\xintiiopp{\xintInc {#1}}}%
}%
-\def\XINT_div_AisNegative_posrem_b #1#2#3%
+\def\XINT_div_AisNegative_Rpositive_b #1#2#3%
{%
- \expandafter \xint_exchangetwo_keepbraces_afterstop \expandafter
- {\romannumeral0\XINT_sub {#3}{#2}}{#1}%
+ \expandafter \xint_exchangetwo_keepbraces_thenstop \expandafter
+ {\romannumeral0\XINT_sub {#3}{#2}}{#1}%
}%
% \end{macrocode}
% \lverb|&
-% par la suite A et B sont > 0.
+% Pour la suite A et B sont > 0.
% #1 = B. Pour le moment à l'endroit.
-% Calcul du plus petit K = 4n >= longueur de B$\
-% 1.03 adds the interception of B=1|
+% Calcul du plus petit K = 4n >= longueur de B|
% \begin{macrocode}
\def\XINT_div_prepare #1%
{%
@@ -14423,476 +15197,583 @@ first place.
}%
\def\XINT_div_prepareB_aa #1%
{%
- \ifnum #1=1
- \expandafter\XINT_div_prepareB_ab
+ \ifnum #1=\xint_c_i
+ \expandafter\XINT_div_prepareB_onedigit
\else
\expandafter\XINT_div_prepareB_a
\fi
{#1}%
}%
-\def\XINT_div_prepareB_ab #1#2%
-{%
- \ifnum #2=1
- \expandafter\XINT_div_prepareB_BisOne
- \else
- \expandafter\XINT_div_prepareB_e
- \fi {000}{3}{4}{#2}%
-}%
-\def\XINT_div_prepareB_BisOne #1#2#3#4#5{ {#5}{0}}%
\def\XINT_div_prepareB_a #1%
{%
\expandafter\XINT_div_prepareB_c\expandafter
{\the\numexpr \xint_c_iv*((#1+\xint_c_i)/\xint_c_iv)}{#1}%
}%
% \end{macrocode}
-% \lverb|&
-% #1 = K|
+% \lverb|B=1 and B=2 treated specially.|
+% \begin{macrocode}
+\def\XINT_div_prepareB_onedigit #1#2%
+{%
+ \ifcase#2
+ \or\expandafter\XINT_div_BisOne
+ \or\expandafter\XINT_div_BisTwo
+ \else\expandafter\XINT_div_prepareB_e
+ \fi {000}{0}{4}{#2}%
+}%
+\def\XINT_div_BisOne #1#2#3#4#5{ {#5}{0}}%
+\def\XINT_div_BisTwo #1#2#3#4#5%
+{%
+ \expandafter\expandafter\expandafter\XINT_div_BisTwo_a
+ \ifodd\xintiiLDg{#5} \expandafter1\else \expandafter0\fi {#5}%
+}%
+\edef\XINT_div_BisTwo_a #1#2%
+{%
+ \noexpand\expandafter\space\noexpand\expandafter
+ {\noexpand\romannumeral0\noexpand\xinthalf {#2}}{#1}%
+}%
+% \end{macrocode}
+% \lverb|#1 = K. 1.09j uses \csname, earlier versions did it with
+% \ifcase.|
% \begin{macrocode}
\def\XINT_div_prepareB_c #1#2%
{%
- \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}%
+ \csname XINT_div_prepareB_d\romannumeral\numexpr#1-#2\endcsname
+ {#1}%
}%
-\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}}%
+\def\XINT_div_prepareB_d {\XINT_div_prepareB_e {}{0000}}%
+\def\XINT_div_prepareB_di {\XINT_div_prepareB_e {0}{000}}%
+\def\XINT_div_prepareB_dii {\XINT_div_prepareB_e {00}{00}}%
+\def\XINT_div_prepareB_diii {\XINT_div_prepareB_e {000}{0}}%
+\def\XINT_div_cleanR #10000.{{#1}}%
% \end{macrocode}
-% \lverb|&
-% #1 = zéros à rajouter à B, #2=c, #3=K, #4 = B|
+% \lverb|#1 = zéros à rajouter à B, #2=c [modifié dans 1.09j, ce sont maintenant
+% des zéros explicites en nombre 4 - ancien c, et on utilisera
+% \XINT_div_cleanR et non plus \XINT_dsh_checksignx pour nettoyer à la fin
+% des zéros en excès dans le Reste; in all comments next, «c» stands now {0} or
+% {00} or {000} or {0000} rather than a digit as in earlier versions], #3=K, #4
+% = B|
% \begin{macrocode}
\def\XINT_div_prepareB_e #1#2#3#4%
{%
- \XINT_div_prepareB_f #4#1\Z {#3}{#2}{#1}%
+ \ifnum#3=\xint_c_iv\expandafter\XINT_div_prepareLittleB_f
+ \else\expandafter\XINT_div_prepareB_f
+ \fi
+ #4#1{#3}{#2}{#1}%
}%
% \end{macrocode}
-% \lverb|&
-% x = #1#2#3#4 = 4 premiers chiffres de B. #1 est non nul.
-% Ensuite on renverse B pour calculs plus rapides par la suite.|
+% \lverb|x = #1#2#3#4 = 4 premiers chiffres de B. #1 est non nul. B is reversed.
+% With 1.09j or latter x+1 and (x+1)/2 are pre-computed. Si K=4 on ne renverse
+% pas B, et donc B=x dans la suite. De plus pour K=4 on ne travaille pas avec
+% x+1 et (x+1)/2 mais avec x et x/2.|
% \begin{macrocode}
-\def\XINT_div_prepareB_f #1#2#3#4#5\Z
-{%
- \expandafter \XINT_div_prepareB_g \expandafter
- {\romannumeral0\xintreverseorder {#1#2#3#4#5}}{#1#2#3#4}%
+\def\XINT_div_prepareB_f #1#2#3#4#5#{%
+ \expandafter\XINT_div_prepareB_g
+ \the\numexpr #1#2#3#4+\xint_c_i\expandafter
+ .\the\numexpr (#1#2#3#4+\xint_c_i)/\xint_c_ii\expandafter
+ .\romannumeral0\xintreverseorder {#1#2#3#4#5}.{#1#2#3#4}%
+}%
+\def\XINT_div_prepareLittleB_f #1#{%
+ \expandafter\XINT_div_prepareB_g \the\numexpr #1/\xint_c_ii.{}.{}.{#1}%
}%
% \end{macrocode}
% \lverb|&
-% #3= K, #4 = c, #5= {} ou {0} ou {00} ou {000}, #6 = A initial
-% #1 = B préparé et renversé, #2 = x = quatre premiers chiffres
-% On multiplie aussi A par 10^c.$\
-% B, x, K, c, {} ou {0} ou {00} ou {000}, A initial|
+% #1 = x' = x+1= 1+quatre premiers chiffres de B, #2 = y = (x+1)/2 précalculé
+% #3 = B préparé et maintenant renversé, #4=x,
+% #5 = K, #6 = «c», #7= {} ou {0} ou {00} ou {000}, #8 = A initial
+% On multiplie aussi A par 10^c. -> AK{x'yx}B«c». Par contre dans le
+% cas little on a #1=y=(x/2), #2={}, #3={}, #4=x, donc cela donne
+% ->AK{y{}x}{}«c», il n'y a pas de B.|
% \begin{macrocode}
-\def\XINT_div_prepareB_g #1#2#3#4#5#6%
+\def\XINT_div_prepareB_g #1.#2.#3.#4#5#6#7#8%
{%
- \XINT_div_prepareA_a {#6#5}{#2}{#3}{#1}{#4}%
+ \XINT_div_prepareA_a {#8#7}{#5}{{#1}{#2}{#4}}{#3}{#6}%
}%
% \end{macrocode}
-% \lverb|&
-% A, x, K, B, c, |
+% \lverb|A, K, {x'yx}, B«c» |
% \begin{macrocode}
\def\XINT_div_prepareA_a #1%
{%
- \expandafter \XINT_div_prepareA_b \expandafter
- {\romannumeral0\xintlength {#1}}{#1}% A >0 ici
+ \expandafter\XINT_div_prepareA_b\expandafter
+ {\romannumeral0\xintlength {#1}}{#1}%
}%
% \end{macrocode}
-% \lverb|&
-% L0, A, x, K, B, ...|
+% \lverb|L0, A, K, {x'yx}, B«c»|
% \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 \xint_c_iv*((#1+\xint_c_i)/\xint_c_iv)}{#1}%
}%
% \end{macrocode}
-% \lverb|&
-% L, L0, A, x, K, B,...|
+% \lverb|L, L0, A, K, {x'yx}, B, «c»|
% \begin{macrocode}
\def\XINT_div_prepareA_c #1#2%
{%
- \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}%
+ \csname XINT_div_prepareA_d\romannumeral\numexpr #1-#2\endcsname
+ {#1}%
}%
\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}
-% \lverb|&
-% #1#3 = A préparé, #2 = longueur de ce A préparé, |
+% \lverb|#1#3 = A préparé, #2 = longueur de ce A préparé, #4=K, #5={x'yx}->
+% LKAx'yxB«c»|
% \begin{macrocode}
-\def\XINT_div_prepareA_e #1#2#3%
+\def\XINT_div_prepareA_e #1#2#3#4#5%
{%
- \XINT_div_startswitch {#1#3}{#2}%
+ \XINT_div_start_a {#2}{#4}{#1#3}#5%
}%
% \end{macrocode}
-% \lverb|&
-% A, L, x, K, B, c|
+% \lverb|L, K, A, x',y,x, B, «c» (avec y{}x{} au lieu de x'yxB dans la
+% variante little)|
% \begin{macrocode}
-\def\XINT_div_startswitch #1#2#3#4%
+\def\XINT_div_start_a #1#2%
{%
- \ifnum #2 > #4
- \expandafter\XINT_div_body_a
+ \ifnum #2=\xint_c_iv \expandafter\XINT_div_little_b
\else
- \ifnum #2 = #4
- \expandafter\expandafter\expandafter\XINT_div_final_a
- \else
- \expandafter\expandafter\expandafter\XINT_div_finished_a
- \fi\fi {#1}{#4}{#3}{0000}{#2}%
-}%
+ \ifnum #1 < #2
+ \expandafter\expandafter\expandafter\XINT_div_III_aa
+ \else
+ \expandafter\expandafter\expandafter\XINT_div_start_b
+ \fi
+ \fi
+ {#1}{#2}%
+}%
% \end{macrocode}
-% \lverb|&
-% ---- "Finished": A, K, x, Q, L, B, c|
+% \lverb|L, K, A, x',y,x, B, «c».|
% \begin{macrocode}
-\def\XINT_div_finished_a #1#2#3%
+\def\XINT_div_III_aa #1#2#3#4#5#6#7%
{%
- \expandafter\XINT_div_finished_b\expandafter {\romannumeral0\XINT_cuz {#1}}%
+ \expandafter\expandafter\expandafter
+ \XINT_div_III_b\xint_cleanupzeros_nostop #3.{0000}%
}%
% \end{macrocode}
-% \lverb|&
-% A, Q, L, B, c
-% no leading zeros in A at this stage|
+% \lverb|R.Q«c».|
% \begin{macrocode}
-\def\XINT_div_finished_b #1#2#3#4#5%
+\def\XINT_div_III_b #1%
{%
- \if0\XINT_Sgn #1\Z
- \xint_afterfi {\XINT_div_finished_c {0}}%
+ \if0#1%
+ \expandafter\XINT_div_III_bRzero
\else
- \xint_afterfi {\expandafter\XINT_div_finished_c\expandafter
- {\romannumeral0\XINT_dsh_checksignx #5\Z {#1}}%
- }%
+ \expandafter\XINT_div_III_bRpos
\fi
- {#2}%
+ #1%
}%
-\edef\XINT_div_finished_c #1#2%
+\def\XINT_div_III_bRzero 0.#1#2%
{%
- \noexpand\expandafter\space\noexpand\expandafter
- {\noexpand\romannumeral0\noexpand\XINT_rev_andcuz {#2}}{#1}%
+ \expandafter\space\expandafter
+ {\romannumeral0\XINT_cuz_loop #1\W\W\W\W\W\W\W\Z}{0}%
+}%
+\def\XINT_div_III_bRpos #1.#2#3%
+{%
+ \expandafter\XINT_div_III_c \XINT_div_cleanR #1#3.{#2}%
+}%
+\def\XINT_div_III_c #1#2%
+{%
+ \expandafter\space\expandafter
+ {\romannumeral0\XINT_cuz_loop #2\W\W\W\W\W\W\W\Z}{#1}%
}%
% \end{macrocode}
-% \lverb|&
-% ---- "Final": A, K, x, Q, L, B, c|
+% \lverb|L, K, A, x',y,x, B, «c»->K.A.x{LK{x'y}x}B«c»|
+% \begin{macrocode}
+\def\XINT_div_start_b #1#2#3#4#5#6%
+{%
+ \XINT_div_start_c {#2}.#3.{#6}{{#1}{#2}{{#4}{#5}}{#6}}%
+}%
+% \end{macrocode}
+% \lverb|Kalpha.A.x{LK{x'y}x}, B, «c», au début #2=alpha est vide|
+% \begin{macrocode}
+\def\XINT_div_start_c #1#2.#3#4#5#6%
+{%
+ \ifnum #1=\xint_c_iv\XINT_div_start_ca\fi
+ \expandafter\XINT_div_start_c\expandafter
+ {\the\numexpr #1-\xint_c_iv}#2#3#4#5#6.%
+}%
+\def\XINT_div_start_ca\fi\expandafter\XINT_div_start_c\expandafter
+ #1#2#3#4#5{\fi\XINT_div_start_d {#2#3#4#5}#2#3#4#5}%
+% \end{macrocode}
+% \lverb|#1=a, #2=alpha (de longueur K, à l'endroit).#3=reste de A.#4=x,
+% #5={LK{x'y}x},#6=B,«c» -> a, x, alpha, B, {0000}, L, K, {x'y},x,
+% alpha'=reste de A, B{}«c». Pour K=4 on a en fait B=x, faudra revoir après.|
% \begin{macrocode}
-\def\XINT_div_final_a #1%
+\def\XINT_div_start_d #1#2.#3.#4#5#6%
{%
- \XINT_div_final_b #1\Z
+ \XINT_div_I_a {#1}{#4}{#2}{#6}{0000}#5{#3}{#6}{}%
}%
-\def\XINT_div_final_b #1#2#3#4#5\Z
+% \end{macrocode}
+% \lverb|Ceci est le point de retour de la boucle principale. a, x, alpha, B,
+% q0, L, K, {x'y}, x, alpha', BQ«c» |
+% \begin{macrocode}
+\def\XINT_div_I_a #1#2%
{%
- \xint_gob_til_zeros_iv #1#2#3#4\xint_div_final_c0000%
- \XINT_div_final_c {#1#2#3#4}{#1#2#3#4#5}%
+ \expandafter\XINT_div_I_b\the\numexpr #1/#2.{#1}{#2}%
+}%
+\def\XINT_div_I_b #1%
+{%
+ \xint_gob_til_zero #1\XINT_div_I_czero 0\XINT_div_I_c #1%
}%
-\def\xint_div_final_c0000\XINT_div_final_c #1{\XINT_div_finished_a }%
% \end{macrocode}
-% \lverb|&
-% a, A, K, x, Q, L, B ,c
-% 1.01: code ré-écrit pour optimisations diverses.
-% 1.04: again, code rewritten for tiny speed increase (hopefully).|
+% \lverb|On intercepte quotient nul: #1=a, x, alpha, B, #5=q0, L, K, {x'y}, x,
+% alpha', BQ«c» -> q{alpha} L, K, {x'y}, x, alpha', BQ«c»|
% \begin{macrocode}
-\def\XINT_div_final_c #1#2#3#4%
+\def\XINT_div_I_czero 0%
+ \XINT_div_I_c 0.#1#2#3#4#5{\XINT_div_I_g {#5}{#3}}%
+\def\XINT_div_I_c #1.#2#3%
{%
- \expandafter \XINT_div_final_da \expandafter
- {\the\numexpr #1-(#1/#4)*#4\expandafter }\expandafter
- {\the\numexpr #1/#4\expandafter }\expandafter
- {\romannumeral0\xint_cleanupzeros_andstop #2}%
+ \expandafter\XINT_div_I_da\the\numexpr #2-#1*#3.#1.%
}%
% \end{macrocode}
-% \lverb|&
-% r, q, A sans leading zéros, Q, L, B à l'envers sur 4n, c|
+% \lverb|r.q.alpha, B, q0, L, K, {x'y}, x, alpha', BQ«c»|
% \begin{macrocode}
-\def\XINT_div_final_da #1%
+\def\XINT_div_I_da #1.%
{%
\ifnum #1>\xint_c_ix
- \expandafter\XINT_div_final_dP
+ \expandafter\XINT_div_I_dP
\else
- \xint_afterfi
- {\ifnum #1<\xint_c_
- \expandafter\XINT_div_final_dN
- \else
- \expandafter\XINT_div_final_db
- \fi }%
+ \ifnum #1<\xint_c_
+ \expandafter\expandafter\expandafter\XINT_div_I_dN
+ \else
+ \expandafter\expandafter\expandafter\XINT_div_I_db
+ \fi
\fi
}%
-\def\XINT_div_final_dN #1%
-{%
- \expandafter\XINT_div_final_dP\the\numexpr #1-\xint_c_i\relax
-}%
-\def\XINT_div_final_dP #1#2#3#4#5% q,A,Q,L,B (puis c)
+\def\XINT_div_I_dN #1.%
{%
- \expandafter \XINT_div_final_f \expandafter
- {\romannumeral0\xintiisub {#2}%
- {\romannumeral0\XINT_mul_M {#1}#5\Z\Z\Z\Z }}%
- {\romannumeral0\XINT_add_A 0{}#1000\W\X\Y\Z #3\W\X\Y\Z }%
+ \expandafter\XINT_div_I_dP\the\numexpr #1-\xint_c_i.%
}%
-\def\XINT_div_final_db #1#2#3#4#5% q,A,Q,L,B (puis c)
+\def\XINT_div_I_db #1.#2#3% #1=q=un chiffre, #2=alpha, #3=B
{%
- \expandafter\XINT_div_final_dc\expandafter
- {\romannumeral0\xintiisub {#2}%
- {\romannumeral0\XINT_mul_M {#1}#5\Z\Z\Z\Z }}%
- {#1}{#2}{#3}{#4}{#5}%
+ \expandafter\XINT_div_I_dc\expandafter
+ {\romannumeral0\expandafter\XINT_div_sub_xpxp\expandafter
+ {\romannumeral0\xintreverseorder{#2}}%
+ {\romannumeral0\XINT_mul_Mr {#1}#3\Z\Z\Z\Z }}%
+ #1{#2}{#3}%
}%
-\def\XINT_div_final_dc #1#2% 1.09i re-styles the conditional here
+\def\XINT_div_I_dc #1#2%
{%
- \ifnum\XINT__Sgn #1\Z<\xint_c_
+ \if-#1% s'arranger pour que si négatif on ait renvoyé alpha=-.
\expandafter\xint_firstoftwo
- \else\expandafter\xint_secondoftwo
- \fi
- {\expandafter\XINT_div_final_dP\the\numexpr #2-\xint_c_i\relax}%
- {\XINT_div_final_e {#1}#2}%
+ \else\expandafter\xint_secondoftwo\fi
+ {\expandafter\XINT_div_I_dP\the\numexpr #2-\xint_c_i.}%
+ {\XINT_div_I_e {#1}#2}%
}%
-\def\XINT_div_final_e #1#2#3#4#5#6% A final, q, trash, Q, L, B
+% \end{macrocode}
+% \lverb|alpha,q,ancien alpha,B, q0->1nouveauq.alpha, L, K, {x'y},x, alpha',
+% BQ«c»|
+% \begin{macrocode}
+\def\XINT_div_I_e #1#2#3#4#5%
{%
- \XINT_div_final_f {#1}%
- {\romannumeral0\XINT_add_A 0{}#2000\W\X\Y\Z #4\W\X\Y\Z }%
+ \expandafter\XINT_div_I_f \the\numexpr \xint_c_x^iv+#2+#5{#1}%
}%
-\def\XINT_div_final_f #1#2#3% R,Q \`a d\'evelopper,c. re-styled in 1.09i
+% \end{macrocode}
+% \lverb|q.alpha, B, q0, L, K, {x'y},x, alpha'BQ«c» (intercepter q=0?)
+% -> 1nouveauq.nouvel alpha, L, K, {x'y}, x, alpha',BQ«c»|
+% \begin{macrocode}
+\def\XINT_div_I_dP #1.#2#3#4%
{%
- \if0\XINT_Sgn #1\Z
- \expandafter\xint_firstoftwo
- \else\expandafter\xint_secondoftwo
- \fi
- {\XINT_div_final_end {0}}%
- {\expandafter\XINT_div_final_end\expandafter
- {\romannumeral0\XINT_dsh_checksignx #3\Z {#1}}%
- }%
- {#2}%
+ \expandafter \XINT_div_I_f \the\numexpr \xint_c_x^iv+#1+#4\expandafter
+ {\romannumeral0\expandafter\XINT_div_sub_xpxp\expandafter
+ {\romannumeral0\xintreverseorder{#2}}%
+ {\romannumeral0\XINT_mul_Mr {#1}#3\Z\Z\Z\Z }}%
}%
-\edef\XINT_div_final_end #1#2%
+% \end{macrocode}
+% \lverb|1#1#2#3#4=nouveau q, nouvel alpha, L, K, {x'y},x,alpha', BQ«c»|
+% \begin{macrocode}
+\def\XINT_div_I_f 1#1#2#3#4{\XINT_div_I_g {#1#2#3#4}}%
+% \end{macrocode}
+% \lverb|#1=q,#2=nouvel alpha,#3=L, #4=K, #5={x'y}, #6=x, #7= alpha',#8=B,
+% #9=Q«c» -> {x'y}alpha.alpha'.{{x'y}xKL}B{Qq}«c»|
+% \begin{macrocode}
+\def\XINT_div_I_g #1#2#3#4#5#6#7#8#9%
{%
- \noexpand\expandafter\space\noexpand\expandafter {#2}{#1}%
+ \ifnum#3=#4
+ \expandafter\XINT_div_III_ab
+ \else
+ \expandafter\XINT_div_I_h
+ \fi
+ {#5}#2.#7.{{#5}{#6}{#4}{#3}}{#8}{#9#1}%
}%
% \end{macrocode}
-% \lverb|&
-% Boucle Principale (on reviendra en div_body_b pas div_body_a)$\
-% A, K, x, Q, L, B, c|
+% \lverb|{x'y}alpha.alpha'.{{x'y}xKL}B{Qq}«c» -> R sans leading zeros.{Qq}«c»|
% \begin{macrocode}
-\def\XINT_div_body_a #1%
+\def\XINT_div_III_ab #1#2.#3.#4#5%
{%
- \XINT_div_body_b #1\Z {#1}%
+ \expandafter\XINT_div_III_b
+ \romannumeral0\XINT_cuz_loop #2#3\W\W\W\W\W\W\W\Z.%
}%
-\def\XINT_div_body_b #1#2#3#4#5#6#7#8#9\Z
+% \end{macrocode}
+% \lverb|#1={x'y}alpha.#2#3#4#5#6=reste de A.
+% #7={{x'y},x,K,L},#8=B,nouveauQ«c» devient {x'y},alpha sur K+4 chiffres.B,
+% {{x'y},x,K,L}, #6= nouvel alpha',B,nouveauQ«c»|
+% \begin{macrocode}
+\def\XINT_div_I_h #1.#2#3#4#5#6.#7#8%
{%
- \XINT_div_body_c {#1#2#3#4#5#6#7#8}%
+ \XINT_div_II_b #1#2#3#4#5.{#8}{#7}{#6}{#8}%
}%
% \end{macrocode}
-% \lverb|&
-% a, A, K, x, Q, L, B, c|
+% \lverb|{x'y}alpha.B, {{x'y},x,K,L}, nouveau alpha',B, Q«c» On
+% intercepte la situation avec alpha débutant par 0000 qui est la seule qui
+% pourrait donner un q1 nul. Donc q1 est non nul et la soustraction spéciale
+% recevra un q1*B de longueur K ou K+4 et jamais 0000. Ensuite un q2 éventuel
+% s'il est calculé est nécessairement non nul lui aussi. Comme dans la phase I
+% on a aussi intercepté un q nul, la soustraction spéciale ne reçoit donc jamais
+% un qB nul. Note: j'ai testé plusieurs fois que ma technique de gob_til_zeros
+% est plus rapide que d'utiliser un \ifnum |
% \begin{macrocode}
-\def\XINT_div_body_c #1#2#3%
+\def\XINT_div_II_b #1#2#3#4#5#6#7#8#9%
{%
- \XINT_div_body_d {#3}{}#2\Z {#1}{#3}%
+ \xint_gob_til_zeros_iv #2#3#4#5\XINT_div_II_skipc 0000%
+ \XINT_div_II_c #1{#2#3#4#5}{#6#7#8#9}%
}%
-\def\XINT_div_body_d #1#2#3#4#5#6%
+% \end{macrocode}
+% \lverb|x'y{0000}{4chiffres}reste de alpha.#6=B,#7={{x'y},x,K,L}, alpha',B,
+% Q«c» -> {x'y}x,K,L (à diminuer de 4), {alpha sur
+% K}B{q1=0000}{alpha'}B,Q«c»|
+% \begin{macrocode}
+\def\XINT_div_II_skipc 0000\XINT_div_II_c #1#2#3#4#5.#6#7%
{%
- \ifnum #1 >\xint_c_
- \expandafter\XINT_div_body_d
- \expandafter{\the\numexpr #1-\xint_c_iv\expandafter }%
- \else
- \expandafter\XINT_div_body_e
- \fi
- {#6#5#4#3#2}%
-}%
-\def\XINT_div_body_e #1#2\Z #3%
+ \XINT_div_II_k #7{#4#5}{#6}{0000}%
+}%
+% \end{macrocode}
+% \lverb|x'ya->1qx'yalpha.B, {{x'y},x,K,L}, nouveau alpha',B, Q«c»|
+% \begin{macrocode}
+\def\XINT_div_II_c #1#2#3#4%
{%
- \XINT_div_body_f {#3}{#1}{#2}%
+ \expandafter\XINT_div_II_d\the\numexpr (#3#4+#2)/#1+\xint_c_ixixixix\relax
+ {#1}{#2}#3#4%
}%
% \end{macrocode}
-% \lverb|&
-% a, alpha (à l'envers), alpha' (à l'endroit), K, x, Q, L, B (à l'envers), c|
+% \lverb|1 suivi de q1 sur quatre chiffres, #5=x', #6=y, #7=alpha.#8=B,
+% {{x'y},x,K,L}, alpha', B, Q«c» --> nouvel alpha.x',y,B,q1,{{x'y},x,K,L},
+% alpha', B, Q«c» |
% \begin{macrocode}
-\def\XINT_div_body_f #1#2#3#4#5#6#7#8%
+\def\XINT_div_II_d 1#1#2#3#4#5#6#7.#8%
{%
- \expandafter\XINT_div_body_gg
- \the\numexpr (#1+(#5+\xint_c_i)/\xint_c_ii)/(#5+\xint_c_i)+99999\relax
- {#8}{#2}{#8}{#4}{#5}{#3}{#6}{#7}{#8}%
+ \expandafter\XINT_div_II_e
+ \romannumeral0\expandafter\XINT_div_sub_xpxp\expandafter
+ {\romannumeral0\xintreverseorder{#7}}%
+ {\romannumeral0\XINT_mul_Mr {#1#2#3#4}#8\Z\Z\Z\Z }.%
+ {#5}{#6}{#8}{#1#2#3#4}%
}%
% \end{macrocode}
-% \lverb|&
-% q1 sur six chiffres (il en a 5 au max), B, alpha, B, K, x, alpha', Q, L, B, c|
+% \lverb|alpha.x',y,B,q1, {{x'y},x,K,L}, alpha', B, Q«c»|
% \begin{macrocode}
-\def\XINT_div_body_gg #1#2#3#4#5#6%
+\def\XINT_div_II_e #1#2#3#4%
{%
- \xint_UDzerofork
- #2\XINT_div_body_gk
- 0{\XINT_div_body_ggk #2}%
- \krof
- {#3#4#5#6}%
+ \xint_gob_til_zeros_iv #1#2#3#4\XINT_div_II_skipf 0000%
+ \XINT_div_II_f #1#2#3#4%
}%
-\def\XINT_div_body_gk #1#2#3%
+% \end{macrocode}
+% \lverb|0000alpha sur K chiffres.#2=x',#3=y,#4=B,#5=q1, #6={{x'y},x,K,L},
+% #7=alpha',BQ«c» -> {x'y}x,K,L (à diminuer de 4),
+% {alpha sur K}B{q1}{alpha'}BQ«c»|
+% \begin{macrocode}
+\def\XINT_div_II_skipf 0000\XINT_div_II_f 0000#1.#2#3#4#5#6%
{%
- \expandafter\XINT_div_body_h
- \romannumeral0\XINT_div_sub_xpxp
- {\romannumeral0\XINT_mul_Mr {#1}#2\Z\Z\Z\Z }{#3}\Z {#1}%
+ \XINT_div_II_k #6{#1}{#4}{#5}%
}%
-\def\XINT_div_body_ggk #1#2#3%
+% \end{macrocode}
+% \lverb|a1 (huit chiffres), alpha (sur K+4), x', y, B, q1, {{x'y},x,K,L},
+% alpha', B,Q«c»|
+% \begin{macrocode}
+\def\XINT_div_II_f #1#2#3#4#5#6#7#8#9.%
{%
- \expandafter \XINT_div_body_gggk \expandafter
- {\romannumeral0\XINT_mul_Mr {#1}0000#3\Z\Z\Z\Z }%
- {\romannumeral0\XINT_mul_Mr {#2}#3\Z\Z\Z\Z }%
- {#1#2}%
+ \XINT_div_II_fa {#1#2#3#4#5#6#7#8}{#1#2#3#4#5#6#7#8#9}%
}%
-\def\XINT_div_body_gggk #1#2#3#4%
+\def\XINT_div_II_fa #1#2#3#4%
{%
- \expandafter\XINT_div_body_h
- \romannumeral0\XINT_div_sub_xpxp
- {\romannumeral0\expandafter\XINT_mul_Ar
- \expandafter0\expandafter{\expandafter}#2\W\X\Y\Z #1\W\X\Y\Z }%
- {#4}\Z {#3}%
+ \expandafter\XINT_div_II_g\expandafter
+ {\the\numexpr (#1+#4)/#3-\xint_c_i}{#2}%
}%
% \end{macrocode}
-% \lverb|&
-% alpha1 = alpha-q1 B, \Z, q1, B, K, x, alpha', Q, L, B, c|
+% \lverb|#1=q, #2=alpha (K+4), #3=B, #4=q1, {{x'y},x,K,L}, alpha', BQ«c»
+% -> 1 puis nouveau q sur 4 chiffres, nouvel alpha sur K chiffres,
+% B, {{x'y},x,K,L}, alpha',BQ«c» |
% \begin{macrocode}
-\def\XINT_div_body_h #1#2#3#4#5#6#7#8#9\Z
+\def\XINT_div_II_g #1#2#3#4%
{%
- \ifnum #1#2#3#4>\xint_c_
- \xint_afterfi{\XINT_div_body_i {#1#2#3#4#5#6#7#8}}%
- \else
- \expandafter\XINT_div_body_k
- \fi
- {#1#2#3#4#5#6#7#8#9}%
+ \expandafter \XINT_div_II_h
+ \the\numexpr #4+#1+\xint_c_x^iv\expandafter\expandafter\expandafter
+ {\expandafter\xint_gobble_iv
+ \romannumeral0\expandafter\XINT_div_sub_xpxp\expandafter
+ {\romannumeral0\xintreverseorder{#2}}%
+ {\romannumeral0\XINT_mul_Mr {#1}#3\Z\Z\Z\Z }}{#3}%
}%
-\def\XINT_div_body_k #1#2#3%
+% \end{macrocode}
+% \lverb|1 puis nouveau q sur 4 chiffres, #5=nouvel alpha sur K chiffres,
+% #6=B, #7={{x'y},x,K,L} avec L à ajuster, alpha', BQ«c»
+% -> {x'y}x,K,L à diminuer de 4, {alpha}B{q}, alpha', BQ«c»|
+% \begin{macrocode}
+\def\XINT_div_II_h 1#1#2#3#4#5#6#7%
{%
- \XINT_div_body_l {#1}{#2}%
+ \XINT_div_II_k #7{#5}{#6}{#1#2#3#4}%
}%
% \end{macrocode}
-% \lverb|&
-% a1, alpha1 (à l'endroit), q1, B, K, x, alpha', Q, L, B, c|
+% \lverb|{x'y}x,K,L à diminuer de 4, alpha, B{q}alpha',BQ«c»
+% ->nouveau L.K,x',y,x,alpha.B,q,alpha',B,Q«c»
+% ->{LK{x'y}x},x,a,alpha.B,q,alpha',B,Q«c»|
% \begin{macrocode}
-\def\XINT_div_body_i #1#2#3#4#5#6%
+\def\XINT_div_II_k #1#2#3#4#5%
{%
- \expandafter\XINT_div_body_j
- \expandafter{\the\numexpr (#1+(#6+1)/2)/(#6+1)-1}%
- {#2}{#3}{#4}{#5}{#6}%
+ \expandafter\XINT_div_II_l \the\numexpr #4-\xint_c_iv.{#3}#1{#2}#5.%
}%
-\def\XINT_div_body_j #1#2#3#4%
+\def\XINT_div_II_l #1.#2#3#4#5#6#7#8#9%
{%
- \expandafter \XINT_div_body_l \expandafter
- {\romannumeral0\XINT_div_sub_xpxp
- {\romannumeral0\XINT_mul_Mr {#1}#4\Z\Z\Z\Z }{\xintReverseOrder{#2}}}%
- {#3+#1}%
+ \XINT_div_II_m {{#1}{#2}{{#3}{#4}}{#5}}{#5}{#6#7#8#9}#6#7#8#9%
}%
% \end{macrocode}
-% \lverb|&
-% alpha2 (à l'endroit, ou alpha1), q1+q2 (ou q1), K, x, alpha', Q, L, B, c|
+% \lverb|{LK{x'y}x},x,a,alpha.B{q}alpha'BQ -> a, x, alpha, B, q,
+% L, K, {x'y}, x, alpha', BQ«c» |
% \begin{macrocode}
-\def\XINT_div_body_l #1#2#3#4#5#6#7%
+\def\XINT_div_II_m #1#2#3#4.#5#6%
{%
- \expandafter\XINT_div_body_m
- \the\numexpr \xint_c_x^viii+#2\relax {#6}{#3}{#7}{#1#5}{#4}%
+ \XINT_div_I_a {#3}{#2}{#4}{#5}{#6}#1%
}%
% \end{macrocode}
-% \lverb|&
-% chiffres de q, Q, K, L, A'=nouveau A, x, B, c|
+% \lverb|L, K, A, y,{},x, {},«c»->A.{yx}L{}«c» Comme ici K=4, dans
+% la phase I on n'a pas besoin de alpha, car a = alpha. De plus on a maintenu B
+% dans l'ordre qui est donc la même chose que x. Par ailleurs la phase I est
+% simplifiée, il s'agit simplement de la division euclidienne de a par x, et de
+% plus on n'a à la faire qu'une unique fois et ensuite la phase II peut boucler
+% sur elle-même au lieu de revenir en phase I, par conséquent il n'y a pas non
+% plus de q0 ici. Enfin, le y est (x/2) pas ((x+1)/2) il n'y a pas de x'=x+1|
% \begin{macrocode}
-\def\XINT_div_body_m 1#1#2#3#4#5#6#7#8%
+\def\XINT_div_little_b #1#2#3#4#5#6#7%
{%
- \ifnum #1#2#3#4>\xint_c_
- \xint_afterfi {\XINT_div_body_n {#8#7#6#5#4#3#2#1}}%
- \else
- \xint_afterfi {\XINT_div_body_n {#8#7#6#5}}%
- \fi
+ \XINT_div_little_c #3.{{#4}{#6}}{#1}%
}%
% \end{macrocode}
-% \lverb|&
-% q renversé, Q, K, L, A', x, B, c|
+% \lverb|#1#2#3#4=a, #5=alpha'=reste de A.#6={yx}, #7=L, «c» -> a,
+% y, x, L, alpha'=reste de A, «c».|
% \begin{macrocode}
-\def\XINT_div_body_n #1#2%
+\def\XINT_div_little_c #1#2#3#4#5.#6#7%
{%
- \expandafter\XINT_div_body_o\expandafter
- {\romannumeral0\XINT_addr_A 0{}#1\W\X\Y\Z #2\W\X\Y\Z }%
+ \XINT_div_littleI_a {#1#2#3#4}#6{#7}{#5}%
}%
% \end{macrocode}
-% \lverb|&
-% q+Q, K, L, A', x, B, c|
+% \lverb|a, y, x, L, alpha',«c» On calcule ici (contrairement à la
+% phase I générale) le vrai quotient euclidien de a par x=B, c'est donc un
+% chiffre de 0 à 9. De plus on n'a à faire cela qu'une unique fois.|
% \begin{macrocode}
-\def\XINT_div_body_o #1#2#3#4%
+\def\XINT_div_littleI_a #1#2#3%
{%
- \XINT_div_body_p {#3}{#2}{}#4\Z {#1}%
+ \expandafter\XINT_div_littleI_b
+ \the\numexpr (#1+#2)/#3-\xint_c_i{#1}{#2}{#3}%
}%
% \end{macrocode}
-% \lverb|&
-% L, K, {}, A'\Z, q+Q, x, B, c |
+% \lverb|On intercepte quotient nul: [est-ce vraiment utile? ou n'est-ce pas
+% plutôt une perte de temps en moyenne? il faudrait tester] q=0#1=a,
+% #2=y, x, L, alpha', «c» ->
+% II_a avec L{alpha}alpha'.{yx}{0000}«c». Et en cas de quotient non nul on
+% procède avec littleI_c avec #1=q, #2=a, #3=y, #4=x -> {nouvel alpha sur 4
+% chiffres}q{yx},L,alpha',«c».|
% \begin{macrocode}
-\def\XINT_div_body_p #1#2#3#4#5#6#7%
+\def\XINT_div_littleI_b #1%
{%
- \ifnum #1 > #2
- \xint_afterfi
- {\ifnum #4#5#6#7 > \xint_c_
- \expandafter\XINT_div_body_q
- \else
- \expandafter\XINT_div_body_repeatp
- \fi }%
- \else
- \expandafter\XINT_div_gotofinal_a
- \fi
- {#1}{#2}{#3}#4#5#6#7%
+ \xint_gob_til_zero #1\XINT_div_littleI_skip 0\XINT_div_littleI_c #1%
+}%
+\def\XINT_div_littleI_skip 0\XINT_div_littleI_c 0#1#2#3#4#5%
+ {\XINT_div_littleII_a {#4}{#1}#5.{{#2}{#3}}{0000}}%
+\def\XINT_div_littleI_c #1#2#3#4%
+{%
+ \expandafter\expandafter\expandafter\XINT_div_littleI_e
+ \expandafter\expandafter\expandafter
+ {\expandafter\xint_gobble_i\the\numexpr \xint_c_x^iv+#2-#1*#4}#1{{#3}{#4}}%
}%
% \end{macrocode}
-% \lverb|&
-% L, K, zeros, A' avec moins de zéros\Z, q+Q, x, B, c|
+% \lverb|#1=nouvel alpha sur 4 chiffres#2=q,#3={yx}, #4=L, #5=alpha',«c» ->
+% L{alpha}alpha'.{yx}{000q}«c» point d'entrée de la boucle principale|
+% \begin{macrocode}
+\def\XINT_div_littleI_e #1#2#3#4#5%
+ {\XINT_div_littleII_a {#4}{#1}#5.{#3}{000#2}}%
+% \end{macrocode}
+% \lverb|L{alpha}alpha'.{yx}Q«c» et c'est là qu'on boucle|
% \begin{macrocode}
-\def\XINT_div_body_repeatp #1#2#3#4#5#6#7%
+\def\XINT_div_littleII_a #1%
{%
- \expandafter\XINT_div_body_p\expandafter{\the\numexpr #1-4}{#2}{0000#3}%
+ \ifnum#1=\xint_c_iv
+ \expandafter\XINT_div_littleIII_ab
+ \else
+ \expandafter\XINT_div_littleII_b
+ \fi {#1}%
}%
% \end{macrocode}
-% \lverb|&
-% L -> L-4, zeros->zeros+0000, répéter jusqu'à ce que soit L=K
-% soit on ne trouve plus 0000$\
-% nouveau L, K, zeros, nouveau A=#4, \Z, Q+q (à l'envers), x, B, c|
+% \lverb|L{alpha}alpha'.{yx}Q«c» -> (en fait #3 est vide normalement ici) R
+% sans leading zeros.Q«c»|
% \begin{macrocode}
-\def\XINT_div_body_q #1#2#3#4\Z #5#6%
+\def\XINT_div_littleIII_ab #1#2#3.#4%
{%
- \XINT_div_body_b #4\Z {#4}{#2}{#6}{#3#5}{#1}%
+ \expandafter\XINT_div_III_b\the\numexpr #2#3.%
}%
% \end{macrocode}
-% \lverb|&
-% A, K, x, Q, L, B, c --> iterate$\
-% Boucle Principale achevée. ATTENTION IL FAUT AJOUTER 4 ZEROS DE MOINS QUE CEUX
-% QUI ONT ÉTÉ PRÉPARÉS DANS #3!!$\
-% L, K (L=K), zeros, A\Z, Q, x, B, c|
+% \lverb|L{alpha}alpha'.{yx}Q«c». On diminue L de quatre, comme cela c'est
+% fait.|
+% \begin{macrocode}
+\def\XINT_div_littleII_b #1%
+{%
+ \expandafter\XINT_div_littleII_c\expandafter {\the\numexpr #1-\xint_c_iv}%
+}%
+% \end{macrocode}
+% \lverb|{nouveauL}{alpha}alpha'.{yx}Q«c». On prélève 4 chiffres de alpha' ->
+% {nouvel alpha sur huit chiffres}yx{nouveau L}{nouvel alpha'}Q«c». Regarder
+% si l'ancien alpha était 0000 n'avancerait à rien car obligerait à refaire une
+% chose comme la phase I, donc on ne perd pas de temps avec ça, on reste en
+% permanence en phase II.|
% \begin{macrocode}
-\def\XINT_div_gotofinal_a #1#2#3#4\Z %
+\def\XINT_div_littleII_c #1#2#3#4#5#6#7.#8%
{%
- \XINT_div_gotofinal_b #3\Z {#4}{#1}%
+ \XINT_div_littleII_d {#2#3#4#5#6}#8{#1}{#7}%
}%
-\def\XINT_div_gotofinal_b 0000#1\Z #2#3#4#5%
+\def\XINT_div_littleII_d #1#2#3%
{%
- \XINT_div_final_a {#2}{#3}{#5}{#1#4}{#3}%
+ \expandafter\XINT_div_littleII_e\the\numexpr (#1+#2)/#3+\xint_c_ixixixix.%
+ {#1}{#2}{#3}%
}%
% \end{macrocode}
-% \lverb|&
-% La soustraction spéciale.
-%
-% Elle fait l'expansion (une fois pour le premier, deux fois pour le second) de
-% ses arguments. Ceux-ci doivent être à l'envers sur 4n. De plus on sait a
-% priori que le second est > le premier. Et le résultat de la différence est
-% renvoyé **avec la même longueur que le second** (donc avec des leading zéros
-% éventuels), et *à l'endroit*.|
+% \lverb|1 suivi de #1=q1 sur quatre chiffres.#2=alpha, #3=y, #4=x,
+% L, alpha', Q«c» --> nouvel alpha sur 4.{q1}{yx},L,alpha', Q«c» |
+% \begin{macrocode}
+\def\XINT_div_littleII_e 1#1.#2#3#4%
+{%
+ \expandafter\expandafter\expandafter\XINT_div_littleII_f
+ \expandafter\xint_gobble_i\the\numexpr \xint_c_x^iv+#2-#1*#4.%
+ {#1}{{#3}{#4}}%
+}%
+% \end{macrocode}
+% \lverb|alpha.q,{yx},L,alpha',Q«c»->L{alpha}alpha'.{yx}{q}Q«c»|
% \begin{macrocode}
-\def\XINT_div_sub_xpxp #1%
+\def\XINT_div_littleII_f #1.#2#3#4#5#6%
{%
- \expandafter \XINT_div_sub_xpxp_a \expandafter{#1}%
+ \XINT_div_littleII_a {#4}{#1}#5.{#3}{#6#2}%
}%
-\def\XINT_div_sub_xpxp_a #1#2%
+% \end{macrocode}
+% \lverb|La soustraction spéciale. Dans 1.09j, elle fait A-qB, pour A (en fait
+% alpha dans mes dénominations des commentaires du code) et qB chacun de
+% longueur K ou K+4, avec K au moins huit multiple de quatre, qB a ses quatre
+% chiffres significatifs (qui sont à droite) non nuls. Si A-qB<0 il suffit de
+% renvoyer -, le résultat n'importe pas. On est sûr que qB est non nul. On le
+% met dans cette version en premier pour tester plus facilement le cas avec qB
+% de longueur K+4 et A de longueur seulement K. Lorsque la longueur de qB est
+% inférieure ou égale à celle de A, on va jusqu'à la fin de A et donc c'est la
+% retenue finale qui décide du cas négatif éventuel. Le résultat non négatif est
+% toujours donc renvoyé avec la même longueur que A, et il est dans l'ordre.
+% J'ai fait une implémentation des phases I et II en maintenant alpha toujours à
+% l'envers afin d'éviter le reverse order systématique fait sur A (ou plutôt
+% alpha), mais alors il fallait que la soustraction ici s'arrange pour repérer
+% les huit chiffres les plus significatifs, au final ce n'était pas plus rapide,
+% et même pénalisant pour de gros inputs. Dans les versions 1.09i et antérieures
+% (en fait je pense qu'ici rien quasiment n'avait bougé depuis la première
+% implémentation), la soustraction spéciale n'était pratiquée que dans des cas
+% avec certainement A-qB positif ou nul. De plus on n'excluait pas q=0, donc il
+% fallait aussi faire un éventuel reverseorder sur ce qui était encore non
+% traité. Les cas avec q=0 sont maintenant interceptés en amont et comme A et qB
+% ont toujours quasiment la même longueur on ne s'embarrasse pas de
+% complications pour la fin.|
+% \begin{macrocode}
+\def\XINT_div_sub_xpxp #1#2% #1=alpha déjà renversé, #2 se développe en qB
{%
- \expandafter\expandafter\expandafter\XINT_div_sub_xpxp_b
- #2\W\X\Y\Z #1\W\X\Y\Z
+ \expandafter\XINT_div_sub_xpxp_b #2\W\X\Y\Z #1\W\X\Y\Z
}%
\def\XINT_div_sub_xpxp_b
{%
@@ -14911,61 +15792,49 @@ first place.
\def\XINT_div_sub_onestep #1#2#3#4#5#6%
{%
\expandafter\XINT_div_sub_backtoA
- \the\numexpr 11#5#4#3#2-#6+#1-\xint_c_i.%
+ \the\numexpr 11#6-#5#4#3#2+#1-\xint_c_i.%
}%
\def\XINT_div_sub_backtoA #1#2#3.#4%
{%
\XINT_div_sub_A #2{#3#4}%
}%
-\def\xint_div_sub_bz\W\XINT_div_sub_onestep #1#2#3#4#5#6#7%
-{%
- \xint_UDzerofork
- #1\XINT_div_sub_C %
- 0\XINT_div_sub_D % pas de retenue
- \krof
- {#7}#2#3#4#5%
-}%
-\def\XINT_div_sub_D #1#2\W\X\Y\Z
-{%
- \expandafter\space
- \romannumeral0%
- \XINT_rord_main {}#2%
- \xint_relax
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_relax
- #1%
-}%
-\def\XINT_div_sub_C #1#2#3#4#5%
+% \end{macrocode}
+% \lverb|si on arrive en sub_bz c'est que qB était de longueur K+4 et A
+% seulement de longueur K, le résultat est donc < 0, renvoyer juste -|
+% \begin{macrocode}
+\def\xint_div_sub_bz\W\XINT_div_sub_onestep #1\Z { -}%
+% \end{macrocode}
+% \lverb|si on arrive en sub_az c'est que qB était de longueur inférieure ou
+% égale à celle de A, donc on continue jusqu'à la fin de A, et on vérifiera la
+% retenue à la fin.|
+% \begin{macrocode}
+\def\xint_div_sub_az\W\XINT_div_sub_B #1#2{\XINT_div_sub_C #1}%
+\def\XINT_div_sub_C #1#2#3#4#5#6%
{%
- \xint_gob_til_W #2\xint_div_sub_cz\W
- \XINT_div_sub_AC_onestep {#5#4#3#2}{#1}%
+ \xint_gob_til_W #3\xint_div_sub_cz\W
+ \XINT_div_sub_C_onestep #1{#6#5#4#3}{#2}%
}%
-\def\XINT_div_sub_AC_onestep #1%
+\def\XINT_div_sub_C_onestep #1#2%
{%
- \expandafter\XINT_div_sub_backtoC\the\numexpr 11#1-\xint_c_i.%
+ \expandafter\XINT_div_sub_backtoC \the\numexpr 11#2+#1-\xint_c_i.%
}%
\def\XINT_div_sub_backtoC #1#2#3.#4%
{%
- \XINT_div_sub_AC_checkcarry #2{#3#4}% la retenue va \^etre examin\'ee
+ \XINT_div_sub_C #2{#3#4}%
}%
-\def\XINT_div_sub_AC_checkcarry #1%
+% \end{macrocode}
+% \lverb|une fois arrivé en sub_cz on teste la retenue pour voir si le résultat
+% final est en fait négatif, dans ce cas on renvoie seulement -|
+% \begin{macrocode}
+\def\xint_div_sub_cz\W\XINT_div_sub_C_onestep #1#2%
{%
- \xint_gob_til_one #1\xint_div_sub_AC_nocarry 1\XINT_div_sub_C
+ \if#10% retenue
+ \expandafter\xint_div_sub_neg
+ \else\expandafter\xint_div_sub_ok
+ \fi
}%
-\def\xint_div_sub_AC_nocarry 1\XINT_div_sub_C #1#2\W\X\Y\Z
-{%
- \expandafter\space
- \romannumeral0%
- \XINT_rord_main {}#2%
- \xint_relax
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_relax
- #1%
-}%
-\def\xint_div_sub_cz\W\XINT_div_sub_AC_onestep #1#2{ #2}%
-\def\xint_div_sub_az\W\XINT_div_sub_B #1#2#3#4\Z { #3}%
+\def\xint_div_sub_neg #1{ -}%
+\def\xint_div_sub_ok #1{ #1}%
% \end{macrocode}
% \lverb|&
% &
@@ -15136,14 +16005,14 @@ first place.
% \end{macrocode}
% \subsection{\csh{xintDSH}, \csh{xintDSHr}}
% \lverb+DECIMAL SHIFTS \xintDSH {x}{A}$\
-% si x <= 0, fait A -> A.10^(|x|). v1.03 corrige l'oversight pour A=0.n
+% si x <= 0, fait A -> A.10^(|x|). v1.03 corrige l'oversight pour A=0.$\
% si x > 0, et A >=0, fait A -> quo(A,10^(x))$\
% 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.+
+% Release 1.06 now feeds x to a \numexpr first. I will have to revise this code
+% at some point.+
% \begin{macrocode}
\def\xintDSHr {\romannumeral0\xintdshr }%
\def\xintdshr #1%
@@ -15161,7 +16030,7 @@ first place.
\def\XINT_dshr_xzeroorneg #1\Z #2{ 0}%
\def\XINT_dshr_xpositive #1\Z
{%
- \expandafter\xint_secondoftwo_afterstop\romannumeral0\xintdsx {#1}%
+ \expandafter\xint_secondoftwo_thenstop\romannumeral0\xintdsx {#1}%
}%
\def\xintDSH {\romannumeral0\xintdsh }%
\def\xintdsh #1#2%
@@ -15183,7 +16052,7 @@ first place.
\def\XINT_dsh_xiszero #1\Z #2{ #2}%
\def\XINT_dsh_xisPos #1\Z #2%
{%
- \expandafter\xint_firstoftwo_afterstop
+ \expandafter\xint_firstoftwo_thenstop
\romannumeral0\XINT_dsx_checksignA #2\Z {#1}% via DSx
}%
% \end{macrocode}
@@ -15208,14 +16077,18 @@ first place.
% Also, x is now given to a \numexpr. The earlier code should be then
% simplified, but I leave as is for the time being.
%
-% In 1.07, I decide to modify
-% the coding of \XINT_dsx_zeroloop, to avoid
-% impacting the input stack (which prevented doing truncation or rounding or
-% float with more than eight times the size of input stack; 40000 = 8x5000
-% digits on my installation.) I think this was the only place in the code with
-% such non tail recursion, as I recall being careful to avoid problems within
-% the Factorial and Power routines, but I would need to check. Too tired now
-% after having finished \xintexpr, \xintNewExpr, and \xintfloatexpr!+
+% Release 1.07 modified the coding of \XINT_dsx_zeroloop, to avoid impacting the
+% input stack. Indeed the truncating, rounding, and conversion to float routines
+% all use internally \XINT_dsx_zeroloop (via \XINT_dsx_addzerosnofuss), and they
+% were thus roughly limited to generating N = 8 times the input save stack size
+% digits. On TL2012 and TL2013, this means 40000 = 8x5000 digits. Although
+% generating more than 40000 digits is more like a one shot thing, I wanted to
+% open the possibility of outputting tens of thousands of digits to faile, thus
+% I re-organized \XINT_dsx_zeroloop.
+%
+% January 5, 2014: but it is only with the new division implementation of 1.09j
+% and also with its special \xintXTrunc routine that the possibility mentioned
+% in the last paragraph has become a concrete one in terms of computation time.+
% \begin{macrocode}
\def\xintDSx {\romannumeral0\xintdsx }%
\def\xintdsx #1#2%
@@ -15249,7 +16122,7 @@ first place.
\def\XINT_dsx_xisNeg_Azero #1\Z #2{ 0}%
\def\XINT_dsx_xisNeg_checkx #1%
{%
- \ifnum #1>999999999
+ \ifnum #1>1000000
\xint_afterfi
{\xintError:TooBigDecimalShift
\expandafter\space\expandafter 0\xint_gobble_iv }%
@@ -15257,11 +16130,12 @@ first place.
\expandafter \XINT_dsx_zeroloop
\fi
}%
+\def\XINT_dsx_addzerosnofuss #1{\XINT_dsx_zeroloop {#1}{}\Z }%
\def\XINT_dsx_zeroloop #1#2%
{%
- \ifnum #1<9 \XINT_dsx_exita\fi
+ \ifnum #1<\xint_c_ix \XINT_dsx_exita\fi
\expandafter\XINT_dsx_zeroloop\expandafter
- {\the\numexpr #1-8}{#200000000}%
+ {\the\numexpr #1-\xint_c_viii}{#200000000}%
}%
\def\XINT_dsx_exita\fi\expandafter\XINT_dsx_zeroloop
{%
@@ -15359,12 +16233,12 @@ first place.
\def\xintDecSplitR {\romannumeral0\xintdecsplitr }%
\def\xintdecsplitl
{%
- \expandafter\xint_firstoftwo_afterstop
+ \expandafter\xint_firstoftwo_thenstop
\romannumeral0\xintdecsplit
}%
\def\xintdecsplitr
{%
- \expandafter\xint_secondoftwo_afterstop
+ \expandafter\xint_secondoftwo_thenstop
\romannumeral0\xintdecsplit
}%
\def\xintDecSplit {\romannumeral0\xintdecsplit }%
@@ -15388,7 +16262,7 @@ first place.
}%
\def\XINT_split_bigx #1\Z #2%
{%
- \ifcase\XINT__Sgn #1\Z
+ \ifcase\XINT_cntSgn #1\Z
\or \xint_afterfi { {}{#2}}% positive big x
\else
\xint_afterfi { {#2}{}}% negative big x
@@ -15409,9 +16283,9 @@ first place.
}%
\def\XINT_split_fromleft_loop #1%
{%
- \ifnum #1<8 \XINT_split_fromleft_exita\fi
+ \ifnum #1<\xint_c_viii\XINT_split_fromleft_exita\fi
\expandafter\XINT_split_fromleft_loop_perhaps\expandafter
- {\the\numexpr #1-8\expandafter}\XINT_split_fromleft_eight
+ {\the\numexpr #1-\xint_c_viii\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%
@@ -15427,7 +16301,7 @@ first place.
\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
+\def\XINT_split_fromleft_exitb\the\numexpr #1-\xint_c_viii\expandafter
{%
\csname XINT_split_fromleft_endsplit_\romannumeral #1\endcsname
}%
@@ -15467,9 +16341,9 @@ first place.
}%
\def\XINT_split_fromright_loop #1%
{%
- \ifnum #1<8 \XINT_split_fromright_exita\fi
+ \ifnum #1<\xint_c_viii\XINT_split_fromright_exita\fi
\expandafter\XINT_split_fromright_loop_perhaps\expandafter
- {\the\numexpr #1-8\expandafter }\XINT_split_fromright_eight
+ {\the\numexpr #1-\xint_c_viii\expandafter }\XINT_split_fromright_eight
}%
\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%
@@ -15481,7 +16355,7 @@ first place.
\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
+\def\XINT_split_fromright_exitb\the\numexpr #1-\xint_c_viii\expandafter
{%
\csname XINT_split_fromright_endsplit_\romannumeral #1\endcsname
}%
@@ -15531,7 +16405,7 @@ first place.
}%
\def\XINT_dbl_zero #1\Z \W\W\W\W\W\W\W { 0}%
\def\XINT_dbl_neg
- {\expandafter\xint_minus_afterstop\romannumeral0\XINT_dbl_pos }%
+ {\expandafter\xint_minus_thenstop\romannumeral0\XINT_dbl_pos }%
\def\XINT_dbl_pos
{%
\expandafter\XINT_dbl_a \expandafter{\expandafter}\expandafter 0%
@@ -15630,7 +16504,7 @@ first place.
}%
\def\XINT_dec_zero #1\W\W\W\W\W\W\W\W { -1}%
\def\XINT_dec_neg
- {\expandafter\xint_minus_afterstop\romannumeral0\XINT_inc_pos }%
+ {\expandafter\xint_minus_thenstop\romannumeral0\XINT_inc_pos }%
\def\XINT_dec_pos
{%
\expandafter\XINT_dec_a \expandafter{\expandafter}%
@@ -15701,14 +16575,12 @@ first place.
\def\XINT_inc_end\W #1\relax #2{ 1#2}%
% \end{macrocode}
% \subsection{\csh{xintiSqrt}, \csh{xintiSquareRoot}}
-% \lverb|v1.08. 1.09a uses \xintnum. Very embarrassing to discover at the
-% time of 1.09e that \xintiSqrt {0} was buggy!
+% \lverb|v1.08. 1.09a uses \xintnum.
%
% Some overhead was added inadvertently in 1.09a to inner routines when
-% \xintiquo and \xintidivision were promoted to use \xintnum. Reverted in 1.09f.
-% |
+% \xintiquo and \xintidivision were also promoted to use \xintnum; release 1.09f
+% thus uses \xintiiquo and \xintiidivision xhich avoid this \xintnum overhead. |
% \begin{macrocode}
-\def\XINT_dsx_addzerosnofuss #1{\XINT_dsx_zeroloop {#1}{}\Z }%
\def\xintiSqrt {\romannumeral0\xintisqrt }%
\def\xintisqrt
{\expandafter\XINT_sqrt_post\romannumeral0\xintisquareroot }%
@@ -15725,12 +16597,12 @@ first place.
0-{\XINT_sqrt #1}%
\krof
}%
-\def\XINT_sqrt_iszero #1\Z { 1.}% 1.09e was wrong from inception in 1.08 :-((
-\edef\XINT_sqrt_isneg #1\Z {\noexpand\xintError:RootOfNegative\space 1.}%
+\def\XINT_sqrt_iszero #1\Z { 1.}%
+\edef\XINT_sqrt_isneg #1\Z {\noexpand\xintError:RootOfNegative\space 1.}%
\def\XINT_sqrt #1\Z
{%
- \expandafter\XINT_sqrt_start\expandafter
- {\romannumeral0\xintlength {#1}}{#1}%
+ \expandafter\XINT_sqrt_start\expandafter
+ {\romannumeral0\xintlength {#1}}{#1}%
}%
\def\XINT_sqrt_start #1%
{%
@@ -15770,40 +16642,19 @@ first place.
}%
\def\XINT_sqrt_c #1#2%
{%
- \expandafter #2%
- \ifcase #1
- \or 2\or 2\or 2\or 3\or 3\or 3\or 3\or 3\or %3+5
- 4\or 4\or 4\or 4\or 4\or 4\or 4\or %+7
- 5\or 5\or 5\or 5\or 5\or 5\or 5\or 5\or 5\or %+9
- 6\or 6\or 6\or 6\or 6\or 6\or 6\or 6\or 6\or 6\or 6\or %+11
- 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or %+13
- 8\or 8\or 8\or 8\or 8\or 8\or 8\or
- 8\or 8\or 8\or 8\or 8\or 8\or 8\or 8\or %+15
- 9\or 9\or 9\or 9\or 9\or 9\or 9\or 9\or
- 9\or 9\or 9\or 9\or 9\or 9\or 9\or 9\or 9\or %+17
- 10\or 10\or 10\or 10\or 10\or 10\or 10\or 10\or 10\or
- 10\or 10\or 10\or 10\or 10\or 10\or 10\or 10\or 10\or 10\or\fi %+19
-}%
-\def\XINT_sqrt_small_d #1\or #2\fi #3%
-{%
- \fi
- \expandafter\XINT_sqrt_small_de
- \ifcase \numexpr #3/\xint_c_ii-\xint_c_i\relax
- {}%
- \or
- 0%
- \or
- {00}%
- \or
- {000}%
- \or
- {0000}%
- \or
- \fi {#1}%
+ \expandafter #2\expandafter
+ {\the\numexpr\ifnum #1>\xint_c_iii
+ \ifnum #1>\xint_c_viii
+ \ifnum #1>15 \ifnum #1>24 \ifnum #1>35
+ \ifnum #1>48 \ifnum #1>63 \ifnum #1>80
+ 10\else 9\fi \else 8\fi \else 7\fi \else 6\fi
+ \else 5\fi \else 4\fi \else 3\fi \else 2\fi \relax }%
}%
-\def\XINT_sqrt_small_de #1\or #2\fi #3%
+\def\XINT_sqrt_small_d #1#2%
{%
- \fi\XINT_sqrt_small_e {#3#1}%
+ \expandafter\XINT_sqrt_small_e\expandafter
+ {\the\numexpr #1\ifcase \numexpr #2/\xint_c_ii-\xint_c_i\relax
+ \or 0\or 00\or 000\or 0000\fi }%
}%
\def\XINT_sqrt_small_e #1#2%
{%
@@ -15830,15 +16681,14 @@ first place.
{\the\numexpr #3-#1}%
}%
\def\XINT_sqrt_small_end #1#2#3{ {#3}{#2}}%
-\def\XINT_sqrt_big_d #1\or #2\fi #3%
+\def\XINT_sqrt_big_d #1#2%
{%
- \fi
- \ifodd #3
- \xint_afterfi{\expandafter\XINT_sqrt_big_eB}%
+ \ifodd #2
+ \expandafter\expandafter\expandafter\XINT_sqrt_big_eB
\else
- \xint_afterfi{\expandafter\XINT_sqrt_big_eA}%
+ \expandafter\expandafter\expandafter\XINT_sqrt_big_eA
\fi
- \expandafter{\the\numexpr #3/\xint_c_ii }{#1}%
+ \expandafter {\the\numexpr #2/\xint_c_ii }{#1}%
}%
\def\XINT_sqrt_big_eA #1#2#3%
{%
@@ -15884,7 +16734,7 @@ first place.
\def\XINT_sqrt_big_g #1#2%
{%
\expandafter\XINT_sqrt_big_j
- \romannumeral0\xintiidivision{#1}
+ \romannumeral0\xintiidivision{#1}%
{\romannumeral0\XINT_dbl_pos #2\R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W }{#2}%
}%
\def\XINT_sqrt_big_j #1%
@@ -15906,6 +16756,108 @@ first place.
{#2}{#1}%
}%
\def\XINT_sqrt_big_end #1#2#3#4{ {#3}{#2}}%
+% \end{macrocode}
+% \subsection{\csh{xintIsTrue:csv}}
+% \lverb|1.09c. For use by \xinttheboolexpr.(inside \csname, no need for a
+% \romannumeral here). The macros may well be defined already here. I
+% make no advertisement because I have inserted no space parsing in the
+% :csv macros, as they will be used only with privately created comma
+% separated lists, having no space naturally. Nevertheless they exist
+% and can be used.|
+% \begin{macrocode}
+\def\xintIsTrue:csv #1{\expandafter\XINT_istrue:_a\romannumeral-`0#1,,^}%
+\def\XINT_istrue:_a {\XINT_istrue:_b {}}%
+\def\XINT_istrue:_b #1#2,%
+ {\expandafter\XINT_istrue:_c\romannumeral-`0#2,{#1}}%
+\def\XINT_istrue:_c #1{\if #1,\expandafter\XINT_:_f
+ \else\expandafter\XINT_istrue:_d\fi #1}%
+\def\XINT_istrue:_d #1,%
+ {\expandafter\XINT_istrue:_e\romannumeral0\xintisnotzero {#1},}%
+\def\XINT_istrue:_e #1,#2{\XINT_istrue:_b {#2,#1}}%
+\def\XINT_:_f ,#1#2^{\xint_gobble_i #1}%
+% \end{macrocode}
+% \subsection{\csh{xintANDof:csv}}
+% \lverb|1.09a. For use by \xintexpr (inside \csname, no need for a
+% \romannumeral here).|
+% \begin{macrocode}
+\def\xintANDof:csv #1{\expandafter\XINT_andof:_a\romannumeral-`0#1,,^}%
+\def\XINT_andof:_a {\expandafter\XINT_andof:_b\romannumeral-`0}%
+\def\XINT_andof:_b #1{\if #1,\expandafter\XINT_andof:_e
+ \else\expandafter\XINT_andof:_c\fi #1}%
+\def\XINT_andof:_c #1,{\xintifTrueAelseB {#1}{\XINT_andof:_a}{\XINT_andof:_no}}%
+\def\XINT_andof:_no #1^{0}%
+\def\XINT_andof:_e #1^{1}% works with empty list
+% \end{macrocode}
+% \subsection{\csh{xintORof:csv}}
+% \lverb|1.09a. For use by \xintexpr.|
+% \begin{macrocode}
+\def\xintORof:csv #1{\expandafter\XINT_orof:_a\romannumeral-`0#1,,^}%
+\def\XINT_orof:_a {\expandafter\XINT_orof:_b\romannumeral-`0}%
+\def\XINT_orof:_b #1{\if #1,\expandafter\XINT_orof:_e
+ \else\expandafter\XINT_orof:_c\fi #1}%
+\def\XINT_orof:_c #1,{\xintifTrueAelseB{#1}{\XINT_orof:_yes}{\XINT_orof:_a}}%
+\def\XINT_orof:_yes #1^{1}%
+\def\XINT_orof:_e #1^{0}% works with empty list
+% \end{macrocode}
+% \subsection{\csh{xintXORof:csv}}
+% \lverb|1.09a. For use by \xintexpr (inside a \csname..\endcsname).|
+% \begin{macrocode}
+\def\xintXORof:csv #1{\expandafter\XINT_xorof:_a\expandafter
+ 0\romannumeral-`0#1,,^}%
+\def\XINT_xorof:_a #1#2,{\expandafter\XINT_xorof:_b\romannumeral-`0#2,#1}%
+\def\XINT_xorof:_b #1{\if #1,\expandafter\XINT_:_e
+ \else\expandafter\XINT_xorof:_c\fi #1}%
+\def\XINT_xorof:_c #1,#2%
+ {\xintifTrueAelseB {#1}{\if #20\xint_afterfi{\XINT_xorof:_a 1}%
+ \else\xint_afterfi{\XINT_xorof:_a 0}\fi}%
+ {\XINT_xorof:_a #2}%
+ }%
+\def\XINT_:_e ,#1#2^{#1}% allows empty list
+% \end{macrocode}
+% \subsection{\csh{xintiMaxof:csv}}
+% \lverb|1.09i. For use by \xintiiexpr.|
+% \begin{macrocode}
+\def\xintiMaxof:csv #1{\expandafter\XINT_imaxof:_b\romannumeral-`0#1,,}%
+\def\XINT_imaxof:_b #1,#2,{\expandafter\XINT_imaxof:_c\romannumeral-`0#2,{#1},}%
+\def\XINT_imaxof:_c #1{\if #1,\expandafter\XINT_of:_e
+ \else\expandafter\XINT_imaxof:_d\fi #1}%
+\def\XINT_imaxof:_d #1,{\expandafter\XINT_imaxof:_b\romannumeral0\xintimax {#1}}%
+\def\XINT_of:_e ,#1,{#1}%
+\let\xintMaxof:csv\xintiMaxof:csv
+% \end{macrocode}
+% \subsection{\csh{xintiMinof:csv}}
+% \lverb|1.09i. For use by \xintiiexpr.|
+% \begin{macrocode}
+\def\xintiMinof:csv #1{\expandafter\XINT_iminof:_b\romannumeral-`0#1,,}%
+\def\XINT_iminof:_b #1,#2,{\expandafter\XINT_iminof:_c\romannumeral-`0#2,{#1},}%
+\def\XINT_iminof:_c #1{\if #1,\expandafter\XINT_of:_e
+ \else\expandafter\XINT_iminof:_d\fi #1}%
+\def\XINT_iminof:_d #1,{\expandafter\XINT_iminof:_b\romannumeral0\xintimin {#1}}%
+\let\xintMinof:csv\xintiMinof:csv
+% \end{macrocode}
+% \subsection{\csh{xintiiSum:csv}}
+% \lverb|1.09i. For use by \xintiiexpr.|
+% \begin{macrocode}
+\def\xintiiSum:csv #1{\expandafter\XINT_iisum:_a\romannumeral-`0#1,,^}%
+\def\XINT_iisum:_a {\XINT_iisum:_b {0}}%
+\def\XINT_iisum:_b #1#2,{\expandafter\XINT_iisum:_c\romannumeral-`0#2,{#1}}%
+\def\XINT_iisum:_c #1{\if #1,\expandafter\XINT_:_e
+ \else\expandafter\XINT_iisum:_d\fi #1}%
+\def\XINT_iisum:_d #1,#2{\expandafter\XINT_iisum:_b\expandafter
+ {\romannumeral0\xintiiadd {#2}{#1}}}%
+\let\xintSum:csv\xintiiSum:csv
+% \end{macrocode}
+% \subsection{\csh{xintiiPrd:csv}}
+% \lverb|1.09i. For use by \xintiiexpr.|
+% \begin{macrocode}
+\def\xintiiPrd:csv #1{\expandafter\XINT_iiprd:_a\romannumeral-`0#1,,^}%
+\def\XINT_iiprd:_a {\XINT_iiprd:_b {1}}%
+\def\XINT_iiprd:_b #1#2,{\expandafter\XINT_iiprd:_c\romannumeral-`0#2,{#1}}%
+\def\XINT_iiprd:_c #1{\if #1,\expandafter\XINT_:_e
+ \else\expandafter\XINT_iiprd:_d\fi #1}%
+\def\XINT_iiprd:_d #1,#2{\expandafter\XINT_iiprd:_b\expandafter
+ {\romannumeral0\xintiimul {#2}{#1}}}%
+\let\xintPrd:csv\xintiiPrd:csv
\XINT_restorecatcodes_endinput%
% \end{macrocode}
%\catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11
@@ -15960,8 +16912,7 @@ first place.
\else
\ifx\x\relax % plain-TeX, first loading of xintbinhex.sty
\ifx\w\relax % but xint.sty not yet loaded.
- \y{xintbinhex}{Package xint is required}%
- \y{xintbinhex}{Will try \string\input\space xint.sty}%
+ \y{xintbinhex}{now issuing \string\input\space xint.sty}%
\def\z{\endgroup\input xint.sty\relax}%
\fi
\else
@@ -15969,8 +16920,7 @@ first place.
\ifx\x\empty % LaTeX, first loading,
% variable is initialized, but \ProvidesPackage not yet seen
\ifx\w\relax % xint.sty not yet loaded.
- \y{xintbinhex}{Package xint is required}%
- \y{xintbinhex}{Will try \string\RequirePackage{xint}}%
+ \y{xintbinhex}{now issuing \string\RequirePackage{xint}}%
\def\z{\endgroup\RequirePackage{xint}}%
\fi
\else
@@ -16019,14 +16969,14 @@ first place.
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintbinhex}%
- [2013/12/18 v1.09i Expandable binary and hexadecimal conversions (jfB)]%
+ [2014/01/09 v1.09j Expandable binary and hexadecimal conversions (jfB)]%
% \end{macrocode}
% \subsection{Constants, etc...}
% \lverb!v1.08!
% \begin{macrocode}
\chardef\xint_c_xvi 16
-\chardef\xint_c_ii^v 32
-\chardef\xint_c_ii^vi 64
+% \chardef\xint_c_ii^v 32 % already done in xint.sty
+% \chardef\xint_c_ii^vi 64 % already done in xint.sty
\chardef\xint_c_ii^vii 128
\mathchardef\xint_c_ii^viii 256
\mathchardef\xint_c_ii^xii 4096
@@ -16141,7 +17091,7 @@ first place.
-{\XINT_dth_P #1}%
\krof
}%
-\def\XINT_dth_N {\expandafter\xint_minus_afterstop\romannumeral0\XINT_dth_P }%
+\def\XINT_dth_N {\expandafter\xint_minus_thenstop\romannumeral0\XINT_dth_P }%
\def\XINT_dth_P {\expandafter\XINT_dth_III\romannumeral-`0\XINT_dtbh_I {0.}}%
\def\xintDecToBin {\romannumeral0\xintdectobin }%
\def\xintdectobin #1%
@@ -16153,7 +17103,7 @@ first place.
-{\XINT_dtb_P #1}%
\krof
}%
-\def\XINT_dtb_N {\expandafter\xint_minus_afterstop\romannumeral0\XINT_dtb_P }%
+\def\XINT_dtb_N {\expandafter\xint_minus_thenstop\romannumeral0\XINT_dtb_P }%
\def\XINT_dtb_P {\expandafter\XINT_dtb_III\romannumeral-`0\XINT_dtbh_I {0.}}%
\def\XINT_dtbh_I #1#2#3#4#5%
{%
@@ -16293,7 +17243,7 @@ first place.
-{\XINT_htd_I {0000}#1}%
\krof
}%
-\def\XINT_htd_neg {\expandafter\xint_minus_afterstop
+\def\XINT_htd_neg {\expandafter\xint_minus_thenstop
\romannumeral0\XINT_htd_I {0000}}%
\def\XINT_htd_I #1#2#3#4#5%
{%
@@ -16381,7 +17331,7 @@ first place.
-{\XINT_btd_I {000000}#1}%
\krof
}%
-\def\XINT_btd_neg {\expandafter\xint_minus_afterstop
+\def\XINT_btd_neg {\expandafter\xint_minus_thenstop
\romannumeral0\XINT_btd_I {000000}}%
\def\XINT_btd_I #1#2#3#4#5#6#7#8#9%
{%
@@ -16497,7 +17447,7 @@ first place.
-{\XINT_bth_P #1}%
\krof
}%
-\def\XINT_bth_N {\expandafter\xint_minus_afterstop\romannumeral0\XINT_bth_P }%
+\def\XINT_bth_N {\expandafter\xint_minus_thenstop\romannumeral0\XINT_bth_P }%
\def\XINT_bth_P {\expandafter\XINT_bth_I\expandafter{\expandafter}%
\romannumeral0\XINT_OQ {}}%
\def\XINT_bth_I #1#2#3#4#5#6#7#8#9%
@@ -16535,7 +17485,7 @@ first place.
-{\XINT_htb_P #1}%
\krof
}%
-\def\XINT_htb_N {\expandafter\xint_minus_afterstop\romannumeral0\XINT_htb_P }%
+\def\XINT_htb_N {\expandafter\xint_minus_thenstop\romannumeral0\XINT_htb_P }%
\def\XINT_htb_P {\XINT_htb_I_a {}}%
\def\XINT_htb_I_a #1#2#3#4#5#6#7#8#9%
{%
@@ -16580,7 +17530,7 @@ first place.
-{\XINT_chtb_P #1}%
\krof
}%
-\def\XINT_chtb_N {\expandafter\xint_minus_afterstop\romannumeral0\XINT_chtb_P }%
+\def\XINT_chtb_N {\expandafter\xint_minus_thenstop\romannumeral0\XINT_chtb_P }%
\def\XINT_chtb_P {\expandafter\XINT_chtb_I\expandafter{\expandafter}%
\romannumeral0\XINT_OQ {}}%
\def\XINT_chtb_I #1#2#3#4#5#6#7#8#9%
@@ -16668,8 +17618,7 @@ first place.
\else
\ifx\x\relax % plain-TeX, first loading of xintgcd.sty
\ifx\w\relax % but xint.sty not yet loaded.
- \y{xintgcd}{Package xint is required}%
- \y{xintgcd}{Will try \string\input\space xint.sty}%
+ \y{xintgcd}{now issuing \string\input\space xint.sty}%
\def\z{\endgroup\input xint.sty\relax}%
\fi
\else
@@ -16677,8 +17626,7 @@ first place.
\ifx\x\empty % LaTeX, first loading,
% variable is initialized, but \ProvidesPackage not yet seen
\ifx\w\relax % xint.sty not yet loaded.
- \y{xintgcd}{Package xint is required}%
- \y{xintgcd}{Will try \string\RequirePackage{xint}}%
+ \y{xintgcd}{now issuing \string\RequirePackage{xint}}%
\def\z{\endgroup\RequirePackage{xint}}%
\fi
\else
@@ -16727,7 +17675,7 @@ first place.
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintgcd}%
- [2013/12/18 v1.09i Euclide algorithm with xint package (jfB)]%
+ [2014/01/09 v1.09j Euclide algorithm with xint package (jfB)]%
% \end{macrocode}
% \subsection{\csh{xintGCD}}
% The macros of |1.09a| benefits from the |\xintnum| which has been inserted
@@ -16789,15 +17737,6 @@ first place.
\def\XINT_gcdof_d #1\Z {\expandafter\XINT_gcdof_b\romannumeral0\xintgcd {#1}}%
\def\XINT_gcdof_e #1\Z #2\Z { #2}%
% \end{macrocode}
-% \subsection{\csh{xintGCDof:csv}}
-% \lverb|1.09a. For use by \xintexpr.|
-% \begin{macrocode}
-\def\xintGCDof:csv #1{\expandafter\XINT_gcdof:_b\romannumeral-`0#1,,}%
-\def\XINT_gcdof:_b #1,#2,{\expandafter\XINT_gcdof:_c\romannumeral-`0#2,{#1},}%
-\def\XINT_gcdof:_c #1{\if #1,\expandafter\XINT_of:_e
- \else\expandafter\XINT_gcdof:_d\fi #1}%
-\def\XINT_gcdof:_d #1,{\expandafter\XINT_gcdof:_b\romannumeral0\xintgcd {#1}}%
-% \end{macrocode}
% \subsection{\csh{xintLCM}}
% \lverb|New with 1.09a. Inadvertent use of \xintiQuo which was promoted at the
% same time to add the \xintnum overhead. So with 1.09f \xintiiQuo without the
@@ -16837,15 +17776,6 @@ first place.
\def\XINT_lcmof_d #1\Z {\expandafter\XINT_lcmof_b\romannumeral0\xintlcm {#1}}%
\def\XINT_lcmof_e #1\Z #2\Z { #2}%
% \end{macrocode}
-% \subsection{\csh{xintLCMof:csv}}
-% \lverb|1.09a. For use by \xintexpr.|
-% \begin{macrocode}
-\def\xintLCMof:csv #1{\expandafter\XINT_lcmof:_a\romannumeral-`0#1,,}%
-\def\XINT_lcmof:_a #1,#2,{\expandafter\XINT_lcmof:_c\romannumeral-`0#2,{#1},}%
-\def\XINT_lcmof:_c #1{\if#1,\expandafter\XINT_of:_e
- \else\expandafter\XINT_lcmof:_d\fi #1}%
-\def\XINT_lcmof:_d #1,{\expandafter\XINT_lcmof:_a\romannumeral0\xintlcm {#1}}%
-% \end{macrocode}
% \subsection{\csh{xintBezout}}
% \lverb|1.09a inserts use of \xintnum|
% \begin{macrocode}
@@ -17335,6 +18265,24 @@ first place.
\par
\endgroup
}%
+% \end{macrocode}
+% \subsection{\csh{xintGCDof:csv}}
+% \lverb|1.09a. For use by \xintexpr.|
+% \begin{macrocode}
+\def\xintGCDof:csv #1{\expandafter\XINT_gcdof:_b\romannumeral-`0#1,,}%
+\def\XINT_gcdof:_b #1,#2,{\expandafter\XINT_gcdof:_c\romannumeral-`0#2,{#1},}%
+\def\XINT_gcdof:_c #1{\if #1,\expandafter\XINT_of:_e
+ \else\expandafter\XINT_gcdof:_d\fi #1}%
+\def\XINT_gcdof:_d #1,{\expandafter\XINT_gcdof:_b\romannumeral0\xintgcd {#1}}%
+% \end{macrocode}
+% \subsection{\csh{xintLCMof:csv}}
+% \lverb|1.09a. For use by \xintexpr.|
+% \begin{macrocode}
+\def\xintLCMof:csv #1{\expandafter\XINT_lcmof:_a\romannumeral-`0#1,,}%
+\def\XINT_lcmof:_a #1,#2,{\expandafter\XINT_lcmof:_c\romannumeral-`0#2,{#1},}%
+\def\XINT_lcmof:_c #1{\if#1,\expandafter\XINT_of:_e
+ \else\expandafter\XINT_lcmof:_d\fi #1}%
+\def\XINT_lcmof:_d #1,{\expandafter\XINT_lcmof:_a\romannumeral0\xintlcm {#1}}%
\XINT_restorecatcodes_endinput%
% \end{macrocode}
%\catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11
@@ -17389,8 +18337,7 @@ first place.
\else
\ifx\x\relax % plain-TeX, first loading of xintfrac.sty
\ifx\w\relax % but xint.sty not yet loaded.
- \y{xintfrac}{Package xint is required}%
- \y{xintfrac}{Will try \string\input\space xint.sty}%
+ \y{xintfrac}{now issuing \string\input\space xint.sty}%
\def\z{\endgroup\input xint.sty\relax}%
\fi
\else
@@ -17398,8 +18345,7 @@ first place.
\ifx\x\empty % LaTeX, first loading,
% variable is initialized, but \ProvidesPackage not yet seen
\ifx\w\relax % xint.sty not yet loaded.
- \y{xintfrac}{Package xint is required}%
- \y{xintfrac}{Will try \string\RequirePackage{xint}}%
+ \y{xintfrac}{now issuing \string\RequirePackage{xint}}%
\def\z{\endgroup\RequirePackage{xint}}%
\fi
\else
@@ -17448,11 +18394,10 @@ first place.
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintfrac}%
- [2013/12/18 v1.09i Expandable operations on fractions (jfB)]%
+ [2014/01/09 v1.09j Expandable operations on fractions (jfB)]%
\chardef\xint_c_vi 6
\chardef\xint_c_vii 7
\chardef\xint_c_xviii 18
-\mathchardef\xint_c_x^iv 10000
% \end{macrocode}
% \subsection{\csh{xintLen}}
% \begin{macrocode}
@@ -17511,7 +18456,7 @@ first place.
% \begin{macrocode}
\def\XINT_outfrac #1#2#3%
{%
- \ifcase\XINT__Sgn #3\Z
+ \ifcase\XINT_cntSgn #3\Z
\expandafter \XINT_outfrac_divisionbyzero
\or
\expandafter \XINT_outfrac_P
@@ -17820,7 +18765,7 @@ first place.
}%
\def\XINT_rawz #1%
{%
- \ifcase\XINT__Sgn #1\Z
+ \ifcase\XINT_cntSgn #1\Z
\expandafter\XINT_rawz_Ba
\or
\expandafter\XINT_rawz_A
@@ -17857,7 +18802,7 @@ first place.
}%
\def\XINT_numer #1%
{%
- \ifcase\XINT__Sgn #1\Z
+ \ifcase\XINT_cntSgn #1\Z
\expandafter\XINT_numer_B
\or
\expandafter\XINT_numer_A
@@ -17878,7 +18823,7 @@ first place.
}%
\def\XINT_denom #1%
{%
- \ifcase\XINT__Sgn #1\Z
+ \ifcase\XINT_cntSgn #1\Z
\expandafter\XINT_denom_B
\or
\expandafter\XINT_denom_A
@@ -17906,7 +18851,7 @@ first place.
\def\XINT_fracfrac_C 0\XINT_fracfrac_D #1#2#3%
{%
\if1\XINT_isOne {#3}%
- \xint_afterfi {\expandafter\xint_firstoftwo_afterstop\xint_gobble_ii }%
+ \xint_afterfi {\expandafter\xint_firstoftwo_thenstop\xint_gobble_ii }%
\fi
\space
\frac {#2}{#3}%
@@ -17943,7 +18888,7 @@ first place.
}%
\def\XINT_sgnfrac_N
{%
- \expandafter\xint_minus_afterstop\romannumeral0\XINT_sgnfrac_P
+ \expandafter\xint_minus_thenstop\romannumeral0\XINT_sgnfrac_P
}%
% \end{macrocode}
% \subsection{\csh{xintFwOver}}
@@ -17997,7 +18942,7 @@ first place.
}%
\def\XINT_sgnfwover_N
{%
- \expandafter\xint_minus_afterstop\romannumeral0\XINT_sgnfwover_P
+ \expandafter\xint_minus_thenstop\romannumeral0\XINT_sgnfwover_P
}%
% \end{macrocode}
% \subsection{\csh{xintREZ}}
@@ -18020,7 +18965,7 @@ first place.
\krof
}%
\def\XINT_rez_zero #1\Z #2#3{ 0/1[0]}%
-\def\XINT_rez_neg {\expandafter\xint_minus_afterstop\romannumeral0\XINT_rez_B }%
+\def\XINT_rez_neg {\expandafter\xint_minus_thenstop\romannumeral0\XINT_rez_B }%
\def\XINT_rez_B #1\Z
{%
\expandafter\XINT_rez_C\romannumeral0\XINT_factortens {#1}%
@@ -18037,21 +18982,21 @@ first place.
\def\XINT_rez_E #1#2#3{ #3/#2[#1]}%
% \end{macrocode}
% \subsection{\csh{xintE}}
-% \lverb|added with with 1.07, together with support for `floats'. The fraction
-% comes first here, contrarily to \xintTrunc and \xintRound.
+% \lverb|1.07: The fraction is the first argument contrarily to \xintTrunc and
+% \xintRound.
%
-% \xintfE (1.07) and \xintiE (1.09i) for \xintexpr and cousins. It is quite
-% annoying that \numexpr does not know how to deal correctly with - : \numexpr
-% -(1)\relax is illegal!
+% \xintfE (1.07) and \xintiE (1.09i) are for \xintexpr and cousins. It is quite
+% annoying that \numexpr does not know how to deal correctly with a minus sign -
+% as prefix: \numexpr -(1)\relax is illegal! (one can do \numexpr 0-(1)\relax).
%
-% the 1.07 \xintE put directly its second argument in a \numexpr. The \xintfE
-% first uses \xintNum on it, this necessary for use in \xintexpr. (but then one
-% cannot use directly infix notation in the second argument of \xintfE)
+% the 1.07 \xintE puts directly its second argument in a \numexpr. The \xintfE
+% first uses \xintNum on it, this is necessary for use in \xintexpr. (but
+% one cannot use directly infix notation in the second argument of \xintfE)
%
% 1.09i also adds \xintFloatE and modifies \XINTinFloatfE, although currently
-% the latter is only used from
-% \xintfloatexpr hence always with \XINTdigits, it comes equipped with its first
-% argument withing brackets as the other \XINTinFloat... macros. |
+% the latter is only used from \xintfloatexpr hence always with \XINTdigits, it
+% comes equipped with its first argument withing brackets as the other
+% \XINTinFloat... macros. |
% \begin{macrocode}
\def\xintE {\romannumeral0\xinte }%
\def\xinte #1%
@@ -18096,8 +19041,8 @@ first place.
\expandafter\xint_exchangetwo_keepbraces\expandafter
{\the\numexpr #2+#5}{#1}{#3}{#4}\XINT_float_Q
}%
-\def\XINTinFloatfE {\romannumeral0\XINT_inFloatfE }%
-\def\XINT_inFloatfE [#1]#2%
+\def\XINTinFloatfE {\romannumeral0\XINTinfloatfe }%
+\def\XINTinfloatfe [#1]#2%
{%
\expandafter\XINT_infloatfe_a\expandafter
{\the\numexpr #1\expandafter}\romannumeral0\XINT_infrac {#2}%
@@ -18145,7 +19090,7 @@ first place.
#2\Z {#3}%
}%
\def\XINT_irr_denomisone #1\Z #2{ #1/1}% changed in 1.08
-\def\XINT_irr_negative #1\Z #2{\XINT_irr_D #1\Z #2\Z \xint_minus_afterstop}%
+\def\XINT_irr_negative #1\Z #2{\XINT_irr_D #1\Z #2\Z \xint_minus_thenstop}%
\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
{%
@@ -18206,16 +19151,16 @@ first place.
}%
% \end{macrocode}
% \subsection{\csh{xintifInt}}
-% \lverb|1.09e. xintfrac.sty only. 1.09i uses _afterstop|
+% \lverb|1.09e. xintfrac.sty only.|
% \begin{macrocode}
\def\xintifInt {\romannumeral0\xintifint }%
\def\xintifint #1{\expandafter\XINT_ifint\romannumeral0\xintirr {#1}\Z }%
\def\XINT_ifint #1/#2\Z
{%
\if\XINT_isOne {#2}1%
- \expandafter\xint_firstoftwo_afterstop
+ \expandafter\xint_firstoftwo_thenstop
\else
- \expandafter\xint_secondoftwo_afterstop
+ \expandafter\xint_secondoftwo_thenstop
\fi
}%
% \end{macrocode}
@@ -18242,7 +19187,7 @@ first place.
#2\Z {#3}%
}%
\def\XINT_jrr_denomisone #1\Z #2{ #1/1}% changed in 1.08
-\def\XINT_jrr_negative #1\Z #2{\XINT_jrr_D #1\Z #2\Z \xint_minus_afterstop }%
+\def\XINT_jrr_negative #1\Z #2{\XINT_jrr_D #1\Z #2\Z \xint_minus_thenstop }%
\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
{%
@@ -18314,25 +19259,31 @@ first place.
}%
% \end{macrocode}
% \subsection{\csh{XINTinFloatFrac}}
-% \lverb|1.09i, for frac in \xintfloatexpr. Will have to think it again some
-% day. This version first computes with exact precision the fractional part then
-% only converts it into a float with the asked for number of digits. |
+% \lverb|1.09i, for frac in \xintfloatexpr. This version computes
+% exactly from the input the fractional part and then only converts it
+% into a float with the asked-for number of digits. I will have to think
+% it again some day, certainly. |
% \begin{macrocode}
-\def\XINTinFloatFrac {\romannumeral0\XINT_inFloatFrac }%
-\def\XINT_inFloatFrac [#1]#2%
+\def\XINTinFloatFrac {\romannumeral0\XINTinfloatfrac }%
+\def\XINTinfloatfrac [#1]#2%
{%
\expandafter\XINT_infloatfrac_a\expandafter
{\romannumeral0\xinttfrac{#2}}{#1}%
}%
-\def\XINT_infloatfrac_a #1#2{\XINT_inFloat [#2]{#1}}%
+\def\XINT_infloatfrac_a #1#2{\XINTinFloat [#2]{#1}}%
% \end{macrocode}
% \subsection{\csh{xintTrunc}, \csh{xintiTrunc}}
% \lverb|&
-% Modified in 1.06 to give the first argument to a \numexpr. 1.09f fixes the
-% overhead added in 1.09a to some inner routines when \xintiquo was redefined to
-% use \xintnum, whereas it should not. Now uses \xintiiquo.|
+% Modified in 1.06 to give the first argument to a \numexpr.
+%
+% 1.09f fixes the overhead added in 1.09a to some inner routines when \xintiquo
+% was redefined to use \xintnum. Now uses \xintiiquo, rather.
+%
+% 1.09j: minor improvements, \XINT_trunc_E was very strange and defined two
+% never occuring branches; also, optimizes the call to the division routine, and
+% the zero loops.|
% \begin{macrocode}
-\def\xintTrunc {\romannumeral0\xinttrunc }%
+\def\xintTrunc {\romannumeral0\xinttrunc }%
\def\xintiTrunc {\romannumeral0\xintitrunc }%
\def\xinttrunc #1%
{%
@@ -18363,10 +19314,10 @@ first place.
{%
\xint_gob_til_zero #2\XINT_trunc_iszero0\XINT_trunc_B {#1}{#2#3}%
}%
-\def\XINT_trunc_iszero #1#2#3#4#5{ 0\Z 0}%
+\def\XINT_trunc_iszero0\XINT_trunc_B #1#2#3{ 0\Z 0}%
\def\XINT_trunc_B #1%
{%
- \ifcase\XINT__Sgn #1\Z
+ \ifcase\XINT_cntSgn #1\Z
\expandafter\XINT_trunc_D
\or
\expandafter\XINT_trunc_D
@@ -18377,43 +19328,40 @@ first place.
}%
\def\XINT_trunc_C #1#2#3%
{%
- \expandafter \XINT_trunc_E
- \romannumeral0\xint_dsh {#3}{#1}\Z #2\Z
+ \expandafter\XINT_trunc_CE\expandafter
+ {\romannumeral0\XINT_dsx_zeroloop {-#1}{}\Z {#3}}{#2}%
}%
+\def\XINT_trunc_CE #1#2{\XINT_trunc_E #2.{#1}}%
\def\XINT_trunc_D #1#2%
{%
- \expandafter \XINT_trunc_DE \expandafter
- {\romannumeral0\xint_dsh {#2}{-#1}}%
+ \expandafter\XINT_trunc_E
+ \romannumeral0\XINT_dsx_zeroloop {#1}{}\Z {#2}.%
}%
-\def\XINT_trunc_DE #1#2{\XINT_trunc_E #2\Z #1\Z }%
-\def\XINT_trunc_E #1#2\Z #3#4\Z
+\def\XINT_trunc_E #1%
{%
- \xint_UDsignsfork
- #1#3\XINT_trunc_minusminus
- #1-{\XINT_trunc_minusplus #3}%
- #3-{\XINT_trunc_plusminus #1}%
- --{\XINT_trunc_plusplus #3#1}%
- \krof
- {#4}{#2}%
-}%
-\def\XINT_trunc_minusminus #1#2{\xintiiquo {#1}{#2}\Z \space}%
-\def\XINT_trunc_minusplus #1#2#3{\xintiiquo {#1#2}{#3}\Z \xint_minus_afterstop}%
-\def\XINT_trunc_plusminus #1#2#3{\xintiiquo {#2}{#1#3}\Z \xint_minus_afterstop}%
-\def\XINT_trunc_plusplus #1#2#3#4{\xintiiquo {#1#3}{#2#4}\Z \space}%
+ \xint_UDsignfork
+ #1\XINT_trunc_Fneg
+ -{\XINT_trunc_Fpos #1}%
+ \krof
+}%
+\def\XINT_trunc_Fneg #1.#2{\expandafter\xint_firstoftwo_thenstop
+ \romannumeral0\XINT_div_prepare {#2}{#1}\Z \xint_minus_thenstop}%
+\def\XINT_trunc_Fpos #1.#2{\expandafter\xint_firstoftwo_thenstop
+ \romannumeral0\XINT_div_prepare {#2}{#1}\Z \space }%
\def\XINT_itrunc_G #1#2\Z #3#4%
{%
- \xint_gob_til_zero #1\XINT_trunc_zero 0\xint_firstoftwo {#3#1#2}0%
+ \xint_gob_til_zero #1\XINT_trunc_zero 0#3#1#2%
}%
+\def\XINT_trunc_zero 0#1#20{ 0}%
\def\XINT_trunc_G #1\Z #2#3%
{%
\xint_gob_til_zero #2\XINT_trunc_zero 0%
\expandafter\XINT_trunc_H\expandafter
{\the\numexpr\romannumeral0\xintlength {#1}-#3}{#3}{#1}#2%
}%
-\def\XINT_trunc_zero 0#10{ 0}%
\def\XINT_trunc_H #1#2%
{%
- \ifnum #1 > 0
+ \ifnum #1 > \xint_c_
\xint_afterfi {\XINT_trunc_Ha {#2}}%
\else
\xint_afterfi {\XINT_trunc_Hb {-#1}}% -0,--1,--2, ....
@@ -18430,12 +19378,11 @@ first place.
\def\XINT_trunc_Hb #1#2#3%
{%
\expandafter #3\expandafter0\expandafter.%
- \romannumeral0\XINT_dsx_zeroloop {#1}{}\Z {}#2% #1=-0 possible!
+ \romannumeral0\XINT_dsx_zeroloop {#1}{}\Z {}#2% #1=-0 autorisé !
}%
% \end{macrocode}
% \subsection{\csh{xintRound}, \csh{xintiRound}}
-% \lverb|&
-% Modified in 1.06 to give the first argument to a \numexpr.|
+% \lverb|Modified in 1.06 to give the first argument to a \numexpr.|
% \begin{macrocode}
\def\xintRound {\romannumeral0\xintround }%
\def\xintiRound {\romannumeral0\xintiround }%
@@ -18502,18 +19449,286 @@ first place.
\XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z \Z
}%
% \end{macrocode}
-% \subsection{\csh{xintRound:csv}}
-% \lverb|1.09a. For use by \xinttheiexpr.|
+% \subsection{\csh{xintXTrunc}}
+% \lverb|1.09j [2014/01/06] This is completely expandable but not f-expandable.
+% Designed be used inside an \edef or a \write, if one is interested in getting
+% tens of thousands of digits from the decimal expansion of some fraction... it
+% is not worth using it rather than \xintTrunc if for less than *hundreds* of
+% digits. For efficiency it clones part of the preparatory division macros, as
+% the same denominator will be used again and again. The D parameter which says
+% how many digits to keep after decimal mark must be at least 1 (and it is
+% forcefully set to such a value if found negative or zero, to avoid an eternal
+% loop).
+%
+% For reasons of efficiency I try to use the shortest possible denominator, so
+% if the fraction is A/B[N], I want to use B. For N at least zero, just
+% immediately replace A by A.10^N. The first division then may be a little
+% longish but the next ones will be fast (if B is not too big). For N<0, this is
+% a bit more complicated. I thought somewhat about this, and I would need a
+% rather complicated approach going through a long division algorithm, forcing
+% me to essentially clone the actual division with some differences; a side
+% thing is that as this would use blocks of four digits I would have a hard time
+% allowing a non-multiple of four number of post decimal mark digits.
+%
+% Thus, for N<0, another method is followed. First the euclidean division
+% A/B=Q+R/B is done. The number of digits of Q is M. If |N|\leq D, we launch
+% inside a \csname the routine for obtaining D-|N| next digits (this may impact
+% TeX's memory if D is very big), call them T. We then need to position the
+% decimal mark D slots from the right of QT, which has length M+D-|N|, hence |N|
+% slots from the right of Q. We thus avoid having to work will the T, as D may
+% be very very big (\xintXTrunc's only goal is to make it possible to learn by
+% hearts decimal expansions with thousands of digits). We can use the
+% \xintDecSplit for that on Q . Computing the length M of Q was a more or less
+% unavoidable step. If |N|>D, the \csname step is skipped we need to remove the
+% D-|N| last digits from Q, etc.. we compare D-|N| with the length M of Q etc...
+% (well in this last, very uncommon, branch, I stopped trying to optimize thinsg
+% and I even do an \xintnum to ensure a 0 if something comes out empty from
+% \xintDecSplit).|
% \begin{macrocode}
-\def\xintRound:csv #1{\expandafter\XINT_round:_a\romannumeral-`0#1,,^}%
-\def\XINT_round:_a {\XINT_round:_b {}}%
-\def\XINT_round:_b #1#2,%
- {\expandafter\XINT_round:_c\romannumeral-`0#2,{#1}}%
-\def\XINT_round:_c #1{\if #1,\expandafter\XINT_:_f
- \else\expandafter\XINT_round:_d\fi #1}%
-\def\XINT_round:_d #1,%
- {\expandafter\XINT_round:_e\romannumeral0\xintiround 0{#1},}%
-\def\XINT_round:_e #1,#2{\XINT_round:_b {#2,#1}}%
+\def\xintXTrunc #1#2%
+{%
+ \expandafter\XINT_xtrunc_a\expandafter
+ {\the\numexpr #1\expandafter}\romannumeral0\xintraw {#2}%
+}%
+\def\XINT_xtrunc_a #1%
+{%
+ \expandafter\XINT_xtrunc_b\expandafter
+ {\the\numexpr\ifnum#1<\xint_c_i \xint_c_i-\fi #1}%
+}%
+\def\XINT_xtrunc_b #1%
+{%
+ \expandafter\XINT_xtrunc_c\expandafter
+ {\the\numexpr (#1+\xint_c_ii^v)/\xint_c_ii^vi-\xint_c_i}{#1}%
+}%
+\def\XINT_xtrunc_c #1#2%
+{%
+ \expandafter\XINT_xtrunc_d\expandafter
+ {\the\numexpr #2-\xint_c_ii^vi*#1}{#1}{#2}%
+}%
+\def\XINT_xtrunc_d #1#2#3#4/#5[#6]%
+{%
+ \XINT_xtrunc_e #4.{#6}{#5}{#3}{#2}{#1}%
+}%
+% #1=numerator.#2=N,#3=B,#4=D,#5=Blocs,#6=extra
+\def\XINT_xtrunc_e #1%
+{%
+ \xint_UDzerominusfork
+ #1-\XINT_xtrunc_zero
+ 0#1\XINT_xtrunc_N
+ 0-{\XINT_xtrunc_P #1}%
+ \krof
+}%
+\def\XINT_xtrunc_zero .#1#2#3#4#5%
+{%
+ 0.\romannumeral0\expandafter\XINT_dsx_zeroloop\expandafter
+ {\the\numexpr #5}{}\Z {}%
+ \xintiloop [#4+-1]
+ \ifnum \xintiloopindex>\xint_c_
+ 0000000000000000000000000000000000000000000000000000000000000000%
+ \repeat
+}%
+\def\XINT_xtrunc_N {-\XINT_xtrunc_P }%
+\def\XINT_xtrunc_P #1.#2%
+{%
+ \ifnum #2<\xint_c_
+ \expandafter\XINT_xtrunc_negN_Q
+ \else
+ \expandafter\XINT_xtrunc_Q
+ \fi {#2}{#1}.%
+}%
+\def\XINT_xtrunc_negN_Q #1#2.#3#4#5#6%
+{%
+ \expandafter\XINT_xtrunc_negN_R
+ \romannumeral0\XINT_div_prepare {#3}{#2}{#3}{#1}{#4}%
+}%
+% #1=Q, #2=R, #3=B, #4=N<0, #5=D
+\def\XINT_xtrunc_negN_R #1#2#3#4#5%
+{%
+ \expandafter\XINT_xtrunc_negN_S\expandafter
+ {\the\numexpr -#4}{#5}{#2}{#3}{#1}%
+}%
+\def\XINT_xtrunc_negN_S #1#2%
+{%
+ \expandafter\XINT_xtrunc_negN_T\expandafter
+ {\the\numexpr #2-#1}{#1}{#2}%
+}%
+\def\XINT_xtrunc_negN_T #1%
+{%
+ \ifnum \xint_c_<#1
+ \expandafter\XINT_xtrunc_negNA
+ \else
+ \expandafter\XINT_xtrunc_negNW
+ \fi {#1}%
+}%
+% #1=D-|N|>0, #2=|N|, #3=D, #4=R, #5=B, #6=Q
+\def\XINT_xtrunc_unlock #10.{ }%
+\def\XINT_xtrunc_negNA #1#2#3#4#5#6%
+{%
+ \expandafter\XINT_xtrunc_negNB\expandafter
+ {\romannumeral0\expandafter\expandafter\expandafter
+ \XINT_xtrunc_unlock\expandafter\string
+ \csname\XINT_xtrunc_b {#1}#4/#5[0]\expandafter\endcsname
+ \expandafter}\expandafter
+ {\the\numexpr\xintLength{#6}-#2}{#6}%
+}%
+\def\XINT_xtrunc_negNB #1#2#3{\XINT_xtrunc_negNC {#2}{#3}#1}%
+\def\XINT_xtrunc_negNC #1%
+{%
+ \ifnum \xint_c_ < #1
+ \expandafter\XINT_xtrunc_negNDa
+ \else
+ \expandafter\XINT_xtrunc_negNE
+ \fi {#1}%
+}%
+\def\XINT_xtrunc_negNDa #1#2%
+{%
+ \expandafter\XINT_xtrunc_negNDb%
+ \romannumeral0\XINT_split_fromleft_loop {#1}{}#2\W\W\W\W\W\W\W\W\Z
+}%
+\def\XINT_xtrunc_negNDb #1#2{#1.#2}%
+\def\XINT_xtrunc_negNE #1#2%
+{%
+ 0.\romannumeral0\XINT_dsx_zeroloop {-#1}{}\Z {}#2%
+}%
+% #1=D-|N|<=0, #2=|N|, #3=D, #4=R, #5=B, #6=Q
+\def\XINT_xtrunc_negNW #1#2#3#4#5#6%
+{%
+ \expandafter\XINT_xtrunc_negNX\expandafter
+ {\romannumeral0\xintnum{\xintDecSplitL {-#1}{#6}}}{#3}%
+}%
+\def\XINT_xtrunc_negNX #1#2%
+{%
+ \expandafter\XINT_xtrunc_negNC\expandafter
+ {\the\numexpr\xintLength {#1}-#2}{#1}%
+}%
+\def\XINT_xtrunc_Q #1%
+{%
+ \expandafter\XINT_xtrunc_prepare_I
+ \romannumeral0\XINT_dsx_zeroloop {#1}{}\Z
+}%
+\def\XINT_xtrunc_prepare_I #1.#2#3%
+{%
+ \expandafter\XINT_xtrunc_prepareB_aa\expandafter
+ {\romannumeral0\xintlength {#2}}{#2}{#1}%
+}%
+\def\XINT_xtrunc_prepareB_aa #1%
+{%
+ \ifnum #1=\xint_c_i
+ \expandafter\XINT_xtrunc_prepareB_onedigit
+ \else
+ \expandafter\XINT_xtrunc_prepareB_PaBa
+ \fi
+ {#1}%
+}%
+\def\XINT_xtrunc_prepareB_onedigit #1#2%
+{%
+ \ifcase#2
+ \or\expandafter\XINT_xtrunc_BisOne
+ \or\expandafter\XINT_xtrunc_BisTwo
+ \else\expandafter\XINT_xtrunc_prepareB_PaBe
+ \fi {000}{0}{4}{#2}%
+}%
+\def\XINT_xtrunc_BisOne #1#2#3#4#5#6#7%
+{%
+ #5.\romannumeral0\expandafter\XINT_dsx_zeroloop\expandafter
+ {\the\numexpr #7}{}\Z {}%
+ \xintiloop [#6+-1]
+ \ifnum \xintiloopindex>\xint_c_
+ 0000000000000000000000000000000000000000000000000000000000000000%
+ \repeat
+}%
+\def\XINT_xtrunc_BisTwo #1#2#3#4#5#6#7%
+{%
+ \xintHalf {#5}.\ifodd\xintiiLDg{#5} 5\else 0\fi
+ \romannumeral0\expandafter\XINT_dsx_zeroloop\expandafter
+ {\the\numexpr #7-\xint_c_i}{}\Z {}%
+ \xintiloop [#6+-1]
+ \ifnum \xintiloopindex>\xint_c_
+ 0000000000000000000000000000000000000000000000000000000000000000%
+ \repeat
+}%
+\def\XINT_xtrunc_prepareB_PaBa #1#2%
+{%
+ \expandafter\XINT_xtrunc_Pa\expandafter
+ {\romannumeral0\XINT_xtrunc_prepareB_a {#1}{#2}}%
+}%
+\def\XINT_xtrunc_prepareB_a #1%
+{%
+ \expandafter\XINT_xtrunc_prepareB_c\expandafter
+ {\the\numexpr \xint_c_iv*((#1+\xint_c_i)/\xint_c_iv)}{#1}%
+}%
+\def\XINT_xtrunc_prepareB_c #1#2%
+{%
+ \csname XINT_xtrunc_prepareB_d\romannumeral\numexpr#1-#2\endcsname
+ {#1}%
+}%
+\def\XINT_xtrunc_prepareB_d {\XINT_xtrunc_prepareB_e {}{0000}}%
+\def\XINT_xtrunc_prepareB_di {\XINT_xtrunc_prepareB_e {0}{000}}%
+\def\XINT_xtrunc_prepareB_dii {\XINT_xtrunc_prepareB_e {00}{00}}%
+\def\XINT_xtrunc_prepareB_diii {\XINT_xtrunc_prepareB_e {000}{0}}%
+\def\XINT_xtrunc_prepareB_PaBe #1#2#3#4%
+{%
+ \expandafter\XINT_xtrunc_Pa\expandafter
+ {\romannumeral0\XINT_xtrunc_prepareB_e {#1}{#2}{#3}{#4}}%
+}%
+\def\XINT_xtrunc_prepareB_e #1#2#3#4%
+{%
+ \ifnum#3=\xint_c_iv\expandafter\XINT_xtrunc_prepareLittleB_f
+ \else\expandafter\XINT_xtrunc_prepareB_f
+ \fi
+ #4#1{#3}{#2}{#1}%
+}%
+\def\XINT_xtrunc_prepareB_f #1#2#3#4#5#{%
+ \expandafter\space
+ \expandafter\XINT_div_prepareB_g
+ \the\numexpr #1#2#3#4+\xint_c_i\expandafter
+ .\the\numexpr (#1#2#3#4+\xint_c_i)/\xint_c_ii\expandafter
+ .\romannumeral0\xintreverseorder {#1#2#3#4#5}.{#1#2#3#4}%
+}%
+\def\XINT_xtrunc_prepareLittleB_f #1#{%
+ \expandafter\space\expandafter
+ \XINT_div_prepareB_g \the\numexpr #1/\xint_c_ii.{}.{}.{#1}%
+}%
+\def\XINT_xtrunc_Pa #1#2%
+{%
+ \expandafter\XINT_xtrunc_Pb\romannumeral0#1{#2}{#1}%
+}%
+\def\XINT_xtrunc_Pb #1#2#3#4{#1.\XINT_xtrunc_A {#4}{#2}{#3}}%
+\def\XINT_xtrunc_A #1%
+{%
+ \unless\ifnum #1>\xint_c_ \XINT_xtrunc_transition\fi
+ \expandafter\XINT_xtrunc_B\expandafter{\the\numexpr #1-\xint_c_i}%
+}%
+\def\XINT_xtrunc_B #1#2#3%
+{%
+ \expandafter\XINT_xtrunc_D\romannumeral0#3%
+ {#20000000000000000000000000000000000000000000000000000000000000000}%
+ {#1}{#3}%
+}%
+\def\XINT_xtrunc_D #1#2#3%
+{%
+ \romannumeral0\expandafter\XINT_dsx_zeroloop\expandafter
+ {\the\numexpr \xint_c_ii^vi-\xintLength{#1}}{}\Z {}#1%
+ \XINT_xtrunc_A {#3}{#2}%
+}%
+\def\XINT_xtrunc_transition\fi
+ \expandafter\XINT_xtrunc_B\expandafter #1#2#3#4%
+{%
+ \fi
+ \ifnum #4=\xint_c_ \XINT_xtrunc_abort\fi
+ \expandafter\XINT_xtrunc_x\expandafter
+ {\romannumeral0\XINT_dsx_zeroloop {#4}{}\Z {#2}}{#3}{#4}%
+}%
+\def\XINT_xtrunc_x #1#2%
+{%
+ \expandafter\XINT_xtrunc_y\romannumeral0#2{#1}%
+}%
+\def\XINT_xtrunc_y #1#2#3%
+{%
+ \romannumeral0\expandafter\XINT_dsx_zeroloop\expandafter
+ {\the\numexpr #3-\xintLength{#1}}{}\Z {}#1%
+}%
+\def\XINT_xtrunc_abort\fi\expandafter\XINT_xtrunc_x\expandafter #1#2#3{\fi}%
% \end{macrocode}
% \subsection{\csh{xintDigits}}
% \lverb|&
@@ -18530,9 +19745,10 @@ first place.
% gains. The earlier version was seriously silly when dealing with
% inputs having a big power of ten. Again some modifications in 1.08b
% for a better treatment of cases with long explicit numerators or
-% denominators. Macro \xintFloat:csv added in 1.09 for use by xintexpr. Here
-% again some inner macros used the \xintiquo with extra \xintnum overhead in
-% 1.09a, reverted in 1.09f.|
+% denominators.
+%
+% Here again some inner macros used the \xintiquo with extra \xintnum overhead
+% in 1.09a, 1.09f reinstalled use of \xintiiquo without this overhead.|
% \begin{macrocode}
\def\xintFloat {\romannumeral0\xintfloat }%
\def\xintfloat #1{\XINT_float_chkopt #1\Z }%
@@ -18566,7 +19782,7 @@ first place.
\krof
}%
\def\XINT_float_zero #1\Z #2#3#4#5{ 0.e0}%
-\def\XINT_float_J {\expandafter\xint_minus_afterstop\romannumeral0\XINT_float_K }%
+\def\XINT_float_J {\expandafter\xint_minus_thenstop\romannumeral0\XINT_float_K }%
\def\XINT_float_K #1\Z #2% #1=A, #2=P, #3=n, #4=B
{%
\expandafter\XINT_float_L\expandafter
@@ -18708,39 +19924,29 @@ first place.
}%
\def\XINT_float_Y #1#2{ #2e#1}%
% \end{macrocode}
-% \subsection{\csh{xintFloat:csv}}
-% \lverb|1.09a. For use by \xintthefloatexpr.|
-% \begin{macrocode}
-\def\xintFloat:csv #1{\expandafter\XINT_float:_a\romannumeral-`0#1,,^}%
-\def\XINT_float:_a {\XINT_float:_b {}}%
-\def\XINT_float:_b #1#2,%
- {\expandafter\XINT_float:_c\romannumeral-`0#2,{#1}}%
-\def\XINT_float:_c #1{\if #1,\expandafter\XINT_:_f
- \else\expandafter\XINT_float:_d\fi #1}%
-\def\XINT_float:_d #1,%
- {\expandafter\XINT_float:_e\romannumeral0\xintfloat {#1},}%
-\def\XINT_float:_e #1,#2{\XINT_float:_b {#2,#1}}%
-% \end{macrocode}
-% \subsection{\csh{XINT\_inFloat}}
+% \subsection{\csh{XINTinFloat}}
% \lverb|1.07. Completely rewritten in 1.08a for immensely greater efficiency
-% when the
-% power of ten is big: previous version had some very serious bottlenecks
-% arising from the creation of long strings of zeros, which made things such as
-% 2^999999 completely impossible, but now even 2^999999999 with 24 significant
-% digits is no problem! Again (slightly) improved in 1.08b.
+% when the power of ten is big: previous version had some very serious
+% bottlenecks arising from the creation of long strings of zeros, which made
+% things such as 2^999999 completely impossible, but now even 2^999999999 with
+% 24 significant digits is no problem! Again (slightly) improved in 1.08b.
%
-% For convenience in xintexpr.sty (special r\^ole of the underscore in
-% \xintNewExpr) 1.09a adds \XINTinFloat. I also decide in 1.09a not to use
-% anymore \romannumeral`-0 mais \romannumeral0 in the float routines, for
-% consistency of style.
+% I decide in 1.09a not to use anymore \romannumeral`-0 mais \romannumeral0 also
+% in the float routines, for consistency of style.
%
-% Here
-% again some inner macros used the \xintiquo with extra \xintnum overhead in
-% 1.09a, reverted in 1.09f.
-% |
+% Here again some inner macros used the \xintiquo with extra \xintnum overhead
+% in 1.09a, 1.09f fixed that to use \xintiiquo for example.
+%
+% 1.09i added a stupid bug to \XINT_infloat_zero when it changed 0[0] to a silly
+% 0/1[0], breaking in particular \xintFloatAdd when one of the argument is zero
+% :(((
+%
+% 1.09j fixes this. Besides, for notational coherence \XINT_inFloat and
+% \XINT_infloat have been renamed respectively \XINTinFloat and \XINT_infloat in
+% release 1.09j.|
% \begin{macrocode}
-\def\XINTinFloat {\romannumeral0\XINT_inFloat }%
-\def\XINT_inFloat [#1]#2%
+\def\XINTinFloat {\romannumeral0\XINTinfloat }%
+\def\XINTinfloat [#1]#2%
{%
\expandafter\XINT_infloat_a\expandafter
{\the\numexpr #1\expandafter}%
@@ -18758,7 +19964,9 @@ first place.
0-{\XINT_float_K #1}%
\krof
}%
-\def\XINT_infloat_zero #1\Z #2#3#4#5{ 0/1[0]}%
+\def\XINT_infloat_zero #1\Z #2#3#4#5{ 0[0]}%
+% the 0[0] was stupidly changed to 0/1[0] in 1.09i, with the result that the
+% Float addition would crash when an operand was zero
\def\XINT_infloat_J {\expandafter-\romannumeral0\XINT_float_K }%
\def\XINT_infloat_Q #1%
{%
@@ -18896,7 +20104,7 @@ first place.
}%
\def\XINT_fsub_D #1#2{\XINT_outfrac {#2}{#1}}%
% \end{macrocode}
-% \subsection{\csh{xintSum}, \csh{xintSumExpr}}
+% \subsection{\csh{xintSum}}
% \begin{macrocode}
\def\xintSum {\romannumeral0\xintsum }%
\def\xintsum #1{\xintsumexpr #1\relax }%
@@ -18918,17 +20126,6 @@ first place.
}%
\def\XINT_fsum_finished #1\Z #2{ #2}%
% \end{macrocode}
-% \subsection{\csh{xintSum:csv}}
-% \lverb|1.09a. For use by \xintexpr.|
-% \begin{macrocode}
-\def\xintSum:csv #1{\expandafter\XINT_sum:_a\romannumeral-`0#1,,^}%
-\def\XINT_sum:_a {\XINT_sum:_b {0/1[0]}}%
-\def\XINT_sum:_b #1#2,{\expandafter\XINT_sum:_c\romannumeral-`0#2,{#1}}%
-\def\XINT_sum:_c #1{\if #1,\expandafter\XINT_:_e
- \else\expandafter\XINT_sum:_d\fi #1}%
-\def\XINT_sum:_d #1,#2{\expandafter\XINT_sum:_b\expandafter
- {\romannumeral0\xintadd {#2}{#1}}}%
-% \end{macrocode}
% \subsection{\csh{xintMul}}
% \begin{macrocode}
\def\xintMul {\romannumeral0\xintmul }%
@@ -18962,14 +20159,17 @@ first place.
% \end{macrocode}
% \subsection{\csh{xintPow}}
% \lverb|&
-% Modified in 1.06 to give the exponent to a \numexpr.$\
+% Modified in 1.06 to give the exponent to a \numexpr.
+%
% With 1.07 and for use within the \xintexpr parser, we must allow
% fractions (which are integers in disguise) as input to the exponent, so we
% must have a variant which uses \xintNum and not only \numexpr
-% for normalizing the input. Hence the \xintfPow here. 1.08b: well actually I
+% for normalizing the input. Hence the \xintfPow here.
+%
+% 1.08b: well actually I
% think that with xintfrac.sty loaded the exponent should always be allowed to
% be a fraction giving an integer. So I do as for \xintFac, and remove here the
-% duplicated. The \xintexpr can thus use directly \xintPow.|
+% duplicated. Then \xintexpr can use the \xintPow as defined here.|
% \begin{macrocode}
\def\xintPow {\romannumeral0\xintpow }%
\def\xintpow #1%
@@ -19024,7 +20224,7 @@ first place.
\expandafter\XINT_fac_fork\expandafter{\the\numexpr \xintNum{#1}}%
}%
% \end{macrocode}
-% \subsection{\csh{xintPrd}, \csh{xintPrdExpr}}
+% \subsection{\csh{xintPrd}}
% \begin{macrocode}
\def\xintPrd {\romannumeral0\xintprd }%
\def\xintprd #1{\xintprdexpr #1\relax }%
@@ -19046,17 +20246,6 @@ first place.
}%
\def\XINT_fprod_finished #1\Z #2{ #2}%
% \end{macrocode}
-% \subsection{\csh{xintPrd:csv}}
-% \lverb|1.09a. For use by \xintexpr.|
-% \begin{macrocode}
-\def\xintPrd:csv #1{\expandafter\XINT_prd:_a\romannumeral-`0#1,,^}%
-\def\XINT_prd:_a {\XINT_prd:_b {1/1[0]}}%
-\def\XINT_prd:_b #1#2,{\expandafter\XINT_prd:_c\romannumeral-`0#2,{#1}}%
-\def\XINT_prd:_c #1{\if #1,\expandafter\XINT_:_e
- \else\expandafter\XINT_prd:_d\fi #1}%
-\def\XINT_prd:_d #1,#2{\expandafter\XINT_prd:_b\expandafter
- {\romannumeral0\xintmul {#2}{#1}}}%
-% \end{macrocode}
% \subsection{\csh{xintDiv}}
% \begin{macrocode}
\def\xintDiv {\romannumeral0\xintdiv }%
@@ -19127,7 +20316,7 @@ first place.
}%
\def\XINT_fgeq_D #1#2#3%
{%
- \expandafter\XINT__SgnFork\romannumeral-`0\expandafter\XINT__Sgn
+ \expandafter\XINT_cntSgnFork\romannumeral-`0\expandafter\XINT_cntSgn
\the\numexpr #2+\xintLength{#3}-\xintLength{#1}\relax\Z
{ 0}{\XINT_fgeq_E #2\Z {#3}{#1}}{ 1}%
}%
@@ -19174,7 +20363,7 @@ first place.
#1#5{#2/#3[#4]}{#6/#7[#8]}%
}%
\def\XINT_fmax_minusminus --%
- {\expandafter\xint_minus_afterstop\romannumeral0\XINT_fmin_nonneg_b }%
+ {\expandafter\xint_minus_thenstop\romannumeral0\XINT_fmin_nonneg_b }%
\def\XINT_fmax_firstneg #1-#2#3{ #1#2}%
\def\XINT_fmax_secondneg -#1#2#3{ #1#3}%
\def\XINT_fmax_nonneg_a #1#2#3#4%
@@ -19190,8 +20379,6 @@ first place.
}%
% \end{macrocode}
% \subsection{\csh{xintMaxof}}
-% \lverb|\xintMaxof:csv is for private use in \xintexpr. Even with only one
-% argument, there does not seem to be really a motive for using \xintraw.|
% \begin{macrocode}
\def\xintMaxof {\romannumeral0\xintmaxof }%
\def\xintmaxof #1{\expandafter\XINT_maxof_a\romannumeral-`0#1\relax }%
@@ -19204,45 +20391,6 @@ first place.
{\expandafter\XINT_maxof_b\romannumeral0\xintmax {#1}}%
\def\XINT_maxof_e #1\Z #2\Z { #2}%
% \end{macrocode}
-% \subsection{\csh{xintMaxof:csv}}
-% \lverb|1.09a. For use by \xintexpr.|
-% \begin{macrocode}
-\def\xintMaxof:csv #1{\expandafter\XINT_maxof:_b\romannumeral-`0#1,,}%
-\def\XINT_maxof:_b #1,#2,{\expandafter\XINT_maxof:_c\romannumeral-`0#2,{#1},}%
-\def\XINT_maxof:_c #1{\if #1,\expandafter\XINT_of:_e
- \else\expandafter\XINT_maxof:_d\fi #1}%
-\def\XINT_maxof:_d #1,{\expandafter\XINT_maxof:_b\romannumeral0\xintmax {#1}}%
-% \end{macrocode}
-% \subsection{\csh{XINTinFloatMaxof}}
-% \lverb|1.09a, for use by \xintNewFloatExpr. Name changed in 1.09h|
-% \begin{macrocode}
-\def\XINTinFloatMaxof {\romannumeral0\XINTinfloatmaxof }%
-\def\XINTinfloatmaxof #1{\expandafter\XINT_flmaxof_a\romannumeral-`0#1\relax }%
-\def\XINT_flmaxof_a #1{\expandafter\XINT_flmaxof_b
- \romannumeral0\XINT_inFloat [\XINTdigits]{#1}\Z }%
-\def\XINT_flmaxof_b #1\Z #2%
- {\expandafter\XINT_flmaxof_c\romannumeral-`0#2\Z {#1}\Z}%
-\def\XINT_flmaxof_c #1%
- {\xint_gob_til_relax #1\XINT_flmaxof_e\relax\XINT_flmaxof_d #1}%
-\def\XINT_flmaxof_d #1\Z
- {\expandafter\XINT_flmaxof_b\romannumeral0\xintmax
- {\XINTinFloat [\XINTdigits]{#1}}}%
-\def\XINT_flmaxof_e #1\Z #2\Z { #2}%
-% \end{macrocode}
-% \subsection{\csh{XINTinFloatMaxof:csv}}
-% \lverb|1.09a. For use by \xintfloatexpr. Name changed in 1.09h|
-% \begin{macrocode}
-\def\XINTinFloatMaxof:csv #1{\expandafter\XINT_flmaxof:_a\romannumeral-`0#1,,}%
-\def\XINT_flmaxof:_a #1,{\expandafter\XINT_flmaxof:_b
- \romannumeral0\XINT_inFloat [\XINTdigits]{#1},}%
-\def\XINT_flmaxof:_b #1,#2,%
- {\expandafter\XINT_flmaxof:_c\romannumeral-`0#2,{#1},}%
-\def\XINT_flmaxof:_c #1{\if #1,\expandafter\XINT_of:_e
- \else\expandafter\XINT_flmaxof:_d\fi #1}%
-\def\XINT_flmaxof:_d #1,%
- {\expandafter\XINT_flmaxof:_b\romannumeral0\xintmax
- {\XINTinFloat [\XINTdigits]{#1}}}%
-% \end{macrocode}
% \subsection{\csh{xintMin}}
% \lverb|&
% Rewritten completely in 1.08a.|
@@ -19267,7 +20415,7 @@ first place.
#1#5{#2/#3[#4]}{#6/#7[#8]}%
}%
\def\XINT_fmin_minusminus --%
- {\expandafter\xint_minus_afterstop\romannumeral0\XINT_fmax_nonneg_b }%
+ {\expandafter\xint_minus_thenstop\romannumeral0\XINT_fmax_nonneg_b }%
\def\XINT_fmin_firstneg #1-#2#3{ -#3}%
\def\XINT_fmin_secondneg -#1#2#3{ -#2}%
\def\XINT_fmin_nonneg_a #1#2#3#4%
@@ -19295,45 +20443,6 @@ first place.
{\expandafter\XINT_minof_b\romannumeral0\xintmin {#1}}%
\def\XINT_minof_e #1\Z #2\Z { #2}%
% \end{macrocode}
-% \subsection{\csh{xintMinof:csv}}
-% \lverb|1.09a. For use by \xintexpr.|
-% \begin{macrocode}
-\def\xintMinof:csv #1{\expandafter\XINT_minof:_b\romannumeral-`0#1,,}%
-\def\XINT_minof:_b #1,#2,{\expandafter\XINT_minof:_c\romannumeral-`0#2,{#1},}%
-\def\XINT_minof:_c #1{\if #1,\expandafter\XINT_of:_e
- \else\expandafter\XINT_minof:_d\fi #1}%
-\def\XINT_minof:_d #1,{\expandafter\XINT_minof:_b\romannumeral0\xintmin {#1}}%
-% \end{macrocode}
-% \subsection{\csh{XINTinFloatMinof}}
-% \lverb|1.09a, for use by \xintNewFloatExpr. Name changed in 1.09h|
-% \begin{macrocode}
-\def\XINTinFloatMinof {\romannumeral0\XINTinfloatminof }%
-\def\XINTinfloatminof #1{\expandafter\XINT_flminof_a\romannumeral-`0#1\relax }%
-\def\XINT_flminof_a #1{\expandafter\XINT_flminof_b
- \romannumeral0\XINT_inFloat [\XINTdigits]{#1}\Z }%
-\def\XINT_flminof_b #1\Z #2%
- {\expandafter\XINT_flminof_c\romannumeral-`0#2\Z {#1}\Z}%
-\def\XINT_flminof_c #1%
- {\xint_gob_til_relax #1\XINT_flminof_e\relax\XINT_flminof_d #1}%
-\def\XINT_flminof_d #1\Z
- {\expandafter\XINT_flminof_b\romannumeral0\xintmin
- {\XINTinFloat [\XINTdigits]{#1}}}%
-\def\XINT_flminof_e #1\Z #2\Z { #2}%
-% \end{macrocode}
-% \subsection{\csh{XINTinFloatMinof:csv}}
-% \lverb|1.09a. For use by \xintfloatexpr. Name changed in 1.09h|
-% \begin{macrocode}
-\def\XINTinFloatMinof:csv #1{\expandafter\XINT_flminof:_a\romannumeral-`0#1,,}%
-\def\XINT_flminof:_a #1,{\expandafter\XINT_flminof:_b
- \romannumeral0\XINT_inFloat [\XINTdigits]{#1},}%
-\def\XINT_flminof:_b #1,#2,%
- {\expandafter\XINT_flminof:_c\romannumeral-`0#2,{#1},}%
-\def\XINT_flminof:_c #1{\if #1,\expandafter\XINT_of:_e
- \else\expandafter\XINT_flminof:_d\fi #1}%
-\def\XINT_flminof:_d #1,%
- {\expandafter\XINT_flminof:_b\romannumeral0\xintmin
- {\XINTinFloat [\XINTdigits]{#1}}}%
-% \end{macrocode}
% \subsection{\csh{xintCmp}}
% \lverb|&
% Rewritten completely in 1.08a to be less dumb when comparing fractions having
@@ -19397,7 +20506,7 @@ first place.
}%
\def\XINT_fcmp_D #1#2#3%
{%
- \expandafter\XINT__SgnFork\romannumeral-`0\expandafter\XINT__Sgn
+ \expandafter\XINT_cntSgnFork\romannumeral-`0\expandafter\XINT_cntSgn
\the\numexpr #2+\xintLength{#3}-\xintLength{#1}\relax\Z
{ -1}{\XINT_fcmp_E #2\Z {#3}{#1}}{ 1}%
}%
@@ -19439,13 +20548,13 @@ first place.
\def\xintSgn {\romannumeral0\xintsgn }%
\def\xintsgn #1{\expandafter\XINT_sgn\romannumeral0\xintraw {#1}\Z }%
% \end{macrocode}
-% \subsection{\csh{xintFloatAdd}}
+% \subsection{\csh{xintFloatAdd}, \csh{XINTinFloatAdd}}
% \lverb|1.07|
% \begin{macrocode}
\def\xintFloatAdd {\romannumeral0\xintfloatadd }%
\def\xintfloatadd #1{\XINT_fladd_chkopt \xintfloat #1\Z }%
\def\XINTinFloatAdd {\romannumeral0\XINTinfloatadd }%
-\def\XINTinfloatadd #1{\XINT_fladd_chkopt \XINT_inFloat #1\Z }%
+\def\XINTinfloatadd #1{\XINT_fladd_chkopt \XINTinfloat #1\Z }%
\def\XINT_fladd_chkopt #1#2%
{%
\ifx [#2\expandafter\XINT_fladd_opt
@@ -19463,11 +20572,11 @@ first place.
\def\XINT_FL_Add #1#2%
{%
\expandafter\XINT_FL_Add_a\expandafter{\the\numexpr #1\expandafter}%
- \expandafter{\romannumeral0\XINT_inFloat [#1]{#2}}%
+ \expandafter{\romannumeral0\XINTinfloat [#1]{#2}}%
}%
\def\XINT_FL_Add_a #1#2#3%
{%
- \expandafter\XINT_FL_Add_b\romannumeral0\XINT_inFloat [#1]{#3}#2{#1}%
+ \expandafter\XINT_FL_Add_b\romannumeral0\XINTinfloat [#1]{#3}#2{#1}%
}%
\def\XINT_FL_Add_b #1%
{%
@@ -19490,13 +20599,13 @@ first place.
\def\XINT_FL_Add_zero 0\XINT_FL_Add_c 0[0]#1[#2]#3{#1[#2]}%
\def\XINT_FL_Add_zerobis 0\XINT_FL_Add_d #1[#2]0[0]#3{#1[#2]}%
% \end{macrocode}
-% \subsection{\csh{xintFloatSub}}
+% \subsection{\csh{xintFloatSub}, \csh{XINTinFloatSub}}
% \lverb|1.07|
% \begin{macrocode}
\def\xintFloatSub {\romannumeral0\xintfloatsub }%
\def\xintfloatsub #1{\XINT_flsub_chkopt \xintfloat #1\Z }%
\def\XINTinFloatSub {\romannumeral0\XINTinfloatsub }%
-\def\XINTinfloatsub #1{\XINT_flsub_chkopt \XINT_inFloat #1\Z }%
+\def\XINTinfloatsub #1{\XINT_flsub_chkopt \XINTinfloat #1\Z }%
\def\XINT_flsub_chkopt #1#2%
{%
\ifx [#2\expandafter\XINT_flsub_opt
@@ -19512,13 +20621,13 @@ first place.
#1[#2]{\XINT_FL_Add {#2+2}{#3}{\xintOpp{#4}}}%
}%
% \end{macrocode}
-% \subsection{\csh{xintFloatMul}}
+% \subsection{\csh{xintFloatMul}, \csh{XINTinFloatMul}}
% \lverb|1.07|
% \begin{macrocode}
\def\xintFloatMul {\romannumeral0\xintfloatmul}%
\def\xintfloatmul #1{\XINT_flmul_chkopt \xintfloat #1\Z }%
\def\XINTinFloatMul {\romannumeral0\XINTinfloatmul }%
-\def\XINTinfloatmul #1{\XINT_flmul_chkopt \XINT_inFloat #1\Z }%
+\def\XINTinfloatmul #1{\XINT_flmul_chkopt \XINTinfloat #1\Z }%
\def\XINT_flmul_chkopt #1#2%
{%
\ifx [#2\expandafter\XINT_flmul_opt
@@ -19536,21 +20645,21 @@ first place.
\def\XINT_FL_Mul #1#2%
{%
\expandafter\XINT_FL_Mul_a\expandafter{\the\numexpr #1\expandafter}%
- \expandafter{\romannumeral0\XINT_inFloat [#1]{#2}}%
+ \expandafter{\romannumeral0\XINTinfloat [#1]{#2}}%
}%
\def\XINT_FL_Mul_a #1#2#3%
{%
- \expandafter\XINT_FL_Mul_b\romannumeral0\XINT_inFloat [#1]{#3}#2%
+ \expandafter\XINT_FL_Mul_b\romannumeral0\XINTinfloat [#1]{#3}#2%
}%
\def\XINT_FL_Mul_b #1[#2]#3[#4]{\xintE{\xintiiMul {#1}{#3}}{#2+#4}}%
% \end{macrocode}
-% \subsection{\csh{xintFloatDiv}}
+% \subsection{\csh{xintFloatDiv}, \csh{XINTinFloatDiv}}
% \lverb|1.07|
% \begin{macrocode}
\def\xintFloatDiv {\romannumeral0\xintfloatdiv}%
\def\xintfloatdiv #1{\XINT_fldiv_chkopt \xintfloat #1\Z }%
\def\XINTinFloatDiv {\romannumeral0\XINTinfloatdiv }%
-\def\XINTinfloatdiv #1{\XINT_fldiv_chkopt \XINT_inFloat #1\Z }%
+\def\XINTinfloatdiv #1{\XINT_fldiv_chkopt \XINTinfloat #1\Z }%
\def\XINT_fldiv_chkopt #1#2%
{%
\ifx [#2\expandafter\XINT_fldiv_opt
@@ -19568,11 +20677,11 @@ first place.
\def\XINT_FL_Div #1#2%
{%
\expandafter\XINT_FL_Div_a\expandafter{\the\numexpr #1\expandafter}%
- \expandafter{\romannumeral0\XINT_inFloat [#1]{#2}}%
+ \expandafter{\romannumeral0\XINTinfloat [#1]{#2}}%
}%
\def\XINT_FL_Div_a #1#2#3%
{%
- \expandafter\XINT_FL_Div_b\romannumeral0\XINT_inFloat [#1]{#3}#2%
+ \expandafter\XINT_FL_Div_b\romannumeral0\XINTinfloat [#1]{#3}#2%
}%
\def\XINT_FL_Div_b #1[#2]#3[#4]{\xintE{#3/#1}{#4-#2}}%
% \end{macrocode}
@@ -19584,7 +20693,7 @@ first place.
\def\XINTinFloatSum {\romannumeral0\XINTinfloatsum }%
\def\XINTinfloatsum #1{\expandafter\XINT_floatsum_a\romannumeral-`0#1\relax }%
\def\XINT_floatsum_a #1{\expandafter\XINT_floatsum_b
- \romannumeral0\XINT_inFloat[\XINTdigits]{#1}\Z }%
+ \romannumeral0\XINTinfloat[\XINTdigits]{#1}\Z }%
\def\XINT_floatsum_b #1\Z #2%
{\expandafter\XINT_floatsum_c\romannumeral-`0#2\Z {#1}\Z}%
\def\XINT_floatsum_c #1%
@@ -19593,18 +20702,6 @@ first place.
{\expandafter\XINT_floatsum_b\romannumeral0\XINTinfloatadd {#1}}%
\def\XINT_floatsum_e #1\Z #2\Z { #2}%
% \end{macrocode}
-% \subsection{\csh{XINTinFloatSum:csv}}
-% \lverb|1.09a. For use by \xintfloatexpr. Renamed in 1.09h|
-% \begin{macrocode}
-\def\XINTinFloatSum:csv #1{\expandafter\XINT_floatsum:_a\romannumeral-`0#1,,^}%
-\def\XINT_floatsum:_a {\XINT_floatsum:_b {0/1[0]}}%
-\def\XINT_floatsum:_b #1#2,%
- {\expandafter\XINT_floatsum:_c\romannumeral-`0#2,{#1}}%
-\def\XINT_floatsum:_c #1{\if #1,\expandafter\XINT_:_e
- \else\expandafter\XINT_floatsum:_d\fi #1}%
-\def\XINT_floatsum:_d #1,#2{\expandafter\XINT_floatsum:_b\expandafter
- {\romannumeral0\XINTinfloatadd {#2}{#1}}}%
-% \end{macrocode}
% \subsection{\csh{XINTinFloatPrd}}
% \lverb|1.09a: quick write-up, for use by \xintfloatexpr, will need to be
% thought through again. Renamed (and slightly modified) in 1.09h. Should be
@@ -19613,7 +20710,7 @@ first place.
\def\XINTinFloatPrd {\romannumeral0\XINTinfloatprd }%
\def\XINTinfloatprd #1{\expandafter\XINT_floatprd_a\romannumeral-`0#1\relax }%
\def\XINT_floatprd_a #1{\expandafter\XINT_floatprd_b
- \romannumeral0\XINT_inFloat[\XINTdigits]{#1}\Z }%
+ \romannumeral0\XINTinfloat[\XINTdigits]{#1}\Z }%
\def\XINT_floatprd_b #1\Z #2%
{\expandafter\XINT_floatprd_c\romannumeral-`0#2\Z {#1}\Z}%
\def\XINT_floatprd_c #1%
@@ -19622,25 +20719,14 @@ first place.
{\expandafter\XINT_floatprd_b\romannumeral0\XINTinfloatmul {#1}}%
\def\XINT_floatprd_e #1\Z #2\Z { #2}%
% \end{macrocode}
-% \subsection{\csh{XINTinFloatPrd:csv}}
-% \lverb|1.09a. For use by \xintfloatexpr. Renamed in 1.09h|
-% \begin{macrocode}
-\def\XINTinFloatPred:csv #1{\expandafter\XINT_floatprd:_a\romannumeral-`0#1,,^}%
-\def\XINT_floatprd:_a {\XINT_floatprd:_b {1/1[0]}}%
-\def\XINT_floatprd:_b #1#2,%
- {\expandafter\XINT_floatprd:_c\romannumeral-`0#2,{#1}}%
-\def\XINT_floatprd:_c #1{\if #1,\expandafter\XINT_:_e
- \else\expandafter\XINT_floatprd:_d\fi #1}%
-\def\XINT_floatprd:_d #1,#2{\expandafter\XINT_floatprd:_b\expandafter
- {\romannumeral0\XINTinfloatmul {#2}{#1}}}%
-% \end{macrocode}
-% \subsection{\csh{xintFloatPow}}
-% \lverb|1.07|
+% \subsection{\csh{xintFloatPow}, \csh{XINTinFloatPow}}
+% \lverb|1.07. Release 1.09j has re-organized the core loop, and
+% \XINT_flpow_prd sub-routine has been removed.|
% \begin{macrocode}
\def\xintFloatPow {\romannumeral0\xintfloatpow}%
\def\xintfloatpow #1{\XINT_flpow_chkopt \xintfloat #1\Z }%
\def\XINTinFloatPow {\romannumeral0\XINTinfloatpow }%
-\def\XINTinfloatpow #1{\XINT_flpow_chkopt \XINT_inFloat #1\Z }%
+\def\XINTinfloatpow #1{\XINT_flpow_chkopt \XINTinfloat #1\Z }%
\def\XINT_flpow_chkopt #1#2%
{%
\ifx [#2\expandafter\XINT_flpow_opt
@@ -19679,12 +20765,12 @@ first place.
{%
\expandafter\XINT_flpow_checkB_d \expandafter
{\the\numexpr \expandafter\xintLength\expandafter
- {\the\numexpr #1*20/3}+#1+#2+1}%
+ {\the\numexpr #1*20/\xint_c_iii }+#1+#2+\xint_c_i }%
}%
\def\XINT_flpow_checkB_d #1#2#3#4%
{%
\expandafter \XINT_flpow_a
- \romannumeral0\XINT_inFloat [#1]{#4}{#1}{#2}#3%
+ \romannumeral0\XINTinfloat [#1]{#4}{#1}{#2}#3%
}%
\def\XINT_flpow_a #1%
{%
@@ -19694,82 +20780,86 @@ first place.
0-{\XINT_flpow_b 0#1}%
\krof
}%
-\def\XINT_flpow_zero [#1]#2#3#4#5%
-{%
- \if #41 \xint_afterfi {\xintError:DivisionByZero\space 1.e2147483647}%
- \else \xint_afterfi { 0.e0}\fi
-}%
\def\XINT_flpow_b #1#2[#3]#4#5%
{%
- \XINT_flpow_c {#4}{#5}{#2[#3]}{#1*\ifodd #5 1\else 0\fi}%
+ \XINT_flpow_loopI {#5}{#2[#3]}{\romannumeral0\XINTinfloatmul [#4]}%
+ {#1*\ifodd #5 1\else 0\fi}%
}%
-\def\XINT_flpow_c #1#2#3#4%
+\def\XINT_flpow_zero [#1]#2#3#4#5%
+% xint is not equipped to signal infinity, the 2^31 will provoke
+% deliberately a number too big and arithmetic overflow in \XINT_float_Xb
{%
- \XINT_flpow_loop {#1}{#2}{#3}{{#1}}\XINT_flpow_prd
- \xint_relax
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_relax {#4}%
+ \if #41\xint_afterfi {\xintError:DivisionByZero #5{1[2147483648]}}%
+ \else \xint_afterfi {#5{0[0]}}\fi
}%
-\def\XINT_flpow_loop #1#2#3%
+\def\XINT_flpow_loopI #1%
{%
- \ifnum #2 = 1
- \expandafter\XINT_flpow_loop_end
+ \ifnum #1=\xint_c_i\XINT_flpow_ItoIII\fi
+ \ifodd #1
+ \expandafter\XINT_flpow_loopI_odd
\else
- \xint_afterfi{\expandafter\XINT_flpow_loop_a
- \expandafter{\the\numexpr 2*(#2/2)-#2\expandafter }% b mod 2
- \expandafter{\the\numexpr #2-#2/2\expandafter }% [b/2]
- \expandafter{\romannumeral0\XINTinfloatmul [#1]{#3}{#3}}}%
+ \expandafter\XINT_flpow_loopI_even
\fi
- {#1}{{#3}}%
+ {#1}%
}%
-\def\XINT_flpow_loop_a #1#2#3#4%
+\def\XINT_flpow_ItoIII\fi #1\fi #2#3#4#5%
{%
- \ifnum #1 = 1
- \expandafter\XINT_flpow_loop
- \else
- \expandafter\XINT_flpow_loop_throwaway
- \fi
- {#4}{#2}{#3}%
+ \fi\expandafter\XINT_flpow_III\the\numexpr #5\relax #3%
+}%
+\def\XINT_flpow_loopI_even #1#2#3%
+{%
+ \expandafter\XINT_flpow_loopI\expandafter
+ {\the\numexpr #1/\xint_c_ii\expandafter}\expandafter
+ {#3{#2}{#2}}{#3}%
}%
-\def\XINT_flpow_loop_throwaway #1#2#3#4%
+\def\XINT_flpow_loopI_odd #1#2#3%
{%
- \XINT_flpow_loop {#1}{#2}{#3}%
+ \expandafter\XINT_flpow_loopII\expandafter
+ {\the\numexpr #1/\xint_c_ii-\xint_c_i\expandafter}\expandafter
+ {#3{#2}{#2}}{#3}{#2}%
}%
-\def\XINT_flpow_loop_end #1{\romannumeral0\XINT_rord_main {}\relax }%
-\def\XINT_flpow_prd #1#2%
+\def\XINT_flpow_loopII #1%
{%
- \XINT_flpow_prd_getnext {#2}{#1}%
+ \ifnum #1 = \xint_c_i\XINT_flpow_IItoIII\fi
+ \ifodd #1
+ \expandafter\XINT_flpow_loopII_odd
+ \else
+ \expandafter\XINT_flpow_loopII_even
+ \fi
+ {#1}%
}%
-\def\XINT_flpow_prd_getnext #1#2#3%
+\def\XINT_flpow_loopII_even #1#2#3%
{%
- \XINT_flpow_prd_checkiffinished #3\Z {#1}{#2}%
+ \expandafter\XINT_flpow_loopII\expandafter
+ {\the\numexpr #1/\xint_c_ii\expandafter}\expandafter
+ {#3{#2}{#2}}{#3}%
}%
-\def\XINT_flpow_prd_checkiffinished #1%
+\def\XINT_flpow_loopII_odd #1#2#3#4%
{%
- \xint_gob_til_relax #1\XINT_flpow_prd_end\relax
- \XINT_flpow_prd_compute #1%
+ \expandafter\XINT_flpow_loopII_odda\expandafter
+ {#3{#2}{#4}}{#1}{#2}{#3}%
}%
-\def\XINT_flpow_prd_compute #1\Z #2#3%
+\def\XINT_flpow_loopII_odda #1#2#3#4%
{%
- \expandafter\XINT_flpow_prd_getnext\expandafter
- {\romannumeral0\XINTinfloatmul [#3]{#1}{#2}}{#3}%
+ \expandafter\XINT_flpow_loopII\expandafter
+ {\the\numexpr #2/\xint_c_ii-\xint_c_i\expandafter}\expandafter
+ {#4{#3}{#3}}{#4}{#1}%
}%
-\def\XINT_flpow_prd_end\relax\XINT_flpow_prd_compute
- \relax\Z #1#2#3%
+\def\XINT_flpow_IItoIII\fi #1\fi #2#3#4#5#6%
{%
- \expandafter\XINT_flpow_conclude \the\numexpr #3\relax #1%
+ \fi\expandafter\XINT_flpow_III\the\numexpr #6\expandafter\relax
+ #4{#3}{#5}%
}%
-\def\XINT_flpow_conclude #1#2[#3]#4%
+\def\XINT_flpow_III #1#2[#3]#4%
{%
- \expandafter\XINT_flpow_conclude_really\expandafter
+ \expandafter\XINT_flpow_IIIend\expandafter
{\the\numexpr\if #41 -\fi#3\expandafter}%
\xint_UDzerofork
#4{{#2}}%
0{{1/#2}}%
\krof #1%
}%
-\def\XINT_flpow_conclude_really #1#2#3#4%
+\def\XINT_flpow_IIIend #1#2#3#4%
{%
\xint_UDzerofork
#3{#4{#2[#1]}}%
@@ -19777,13 +20867,14 @@ first place.
\krof
}%
% \end{macrocode}
-% \subsection{\csh{xintFloatPower}}
-% \lverb|1.07|
+% \subsection{\csh{xintFloatPower}, \csh{XINTinFloatPower}}
+% \lverb|1.07. The core loop has been re-organized in 1.09j for some slight
+% efficiency gain. |
% \begin{macrocode}
\def\xintFloatPower {\romannumeral0\xintfloatpower}%
\def\xintfloatpower #1{\XINT_flpower_chkopt \xintfloat #1\Z }%
\def\XINTinFloatPower {\romannumeral0\XINTinfloatpower}%
-\def\XINTinfloatpower #1{\XINT_flpower_chkopt \XINT_inFloat #1\Z }%
+\def\XINTinfloatpower #1{\XINT_flpower_chkopt \XINTinfloat #1\Z }%
\def\XINT_flpower_chkopt #1#2%
{%
\ifx [#2\expandafter\XINT_flpower_opt
@@ -19822,72 +20913,88 @@ first place.
{%
\expandafter\XINT_flpower_checkB_d \expandafter
{\the\numexpr \expandafter\xintLength\expandafter
- {\the\numexpr #1*20/3}+#1+#2+1}%
+ {\the\numexpr #1*20/\xint_c_iii }+#1+#2+\xint_c_i }%
}%
\def\XINT_flpower_checkB_d #1#2#3#4%
{%
\expandafter \XINT_flpower_a
- \romannumeral0\XINT_inFloat [#1]{#4}{#1}{#2}#3%
+ \romannumeral0\XINTinfloat [#1]{#4}{#1}{#2}#3%
}%
\def\XINT_flpower_a #1%
{%
\xint_UDzerominusfork
- #1-\XINT_flpower_zero
+ #1-\XINT_flpow_zero
0#1{\XINT_flpower_b 1}%
0-{\XINT_flpower_b 0#1}%
\krof
}%
-\def\XINT_flpower_zero [#1]#2#3#4#5%
+\def\XINT_flpower_b #1#2[#3]#4#5%
{%
- \if #41
- \xint_afterfi {\xintError:DivisionByZero\space 1.e2147483647}%
- \else \xint_afterfi { 0.e0}\fi
+ \XINT_flpower_loopI {#5}{#2[#3]}{\romannumeral0\XINTinfloatmul [#4]}%
+ {#1*\xintiiOdd {#5}}%
}%
-\def\XINT_flpower_b #1#2[#3]#4#5%
+\def\XINT_flpower_loopI #1%
{%
- \XINT_flpower_c {#4}{#5}{#2[#3]}{#1*\xintiiOdd {#5}}%
+ \if1\XINT_isOne {#1}\XINT_flpower_ItoIII\fi
+ \if1\xintiiOdd{#1}%
+ \expandafter\expandafter\expandafter\XINT_flpower_loopI_odd
+ \else
+ \expandafter\expandafter\expandafter\XINT_flpower_loopI_even
+ \fi
+ \expandafter {\romannumeral0\xinthalf{#1}}%
}%
-\def\XINT_flpower_c #1#2#3#4%
+\def\XINT_flpower_ItoIII\fi #1\fi\expandafter #2#3#4#5%
{%
- \XINT_flpower_loop {#1}{#2}{#3}{{#1}}\XINT_flpow_prd
- \xint_relax
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_relax {#4}%
+ \fi\expandafter\XINT_flpow_III \the\numexpr #5\relax #3%
+}%
+\def\XINT_flpower_loopI_even #1#2#3%
+{%
+ \expandafter\XINT_flpower_toI\expandafter {#3{#2}{#2}}{#1}{#3}%
}%
-\def\XINT_flpower_loop #1#2#3%
+\def\XINT_flpower_loopI_odd #1#2#3%
{%
- \if0\XINT_isOne {#2}\xint_afterfi
- {\expandafter\XINT_flpower_loop_x\expandafter
- {\romannumeral0\XINTinfloatmul [#1]{#3}{#3}}%
- {\romannumeral0\xintdivision {#2}{2}}%
- }%
- \else\expandafter\XINT_flpow_loop_end
- \fi
- {#1}{{#3}}%
+ \expandafter\XINT_flpower_toII\expandafter {#3{#2}{#2}}{#1}{#3}{#2}%
}%
-\def\XINT_flpower_loop_x #1#2{\expandafter\XINT_flpower_loop_a #2{#1}}%
-\def\XINT_flpower_loop_a #1#2#3#4%
+\def\XINT_flpower_toI #1#2{\XINT_flpower_loopI {#2}{#1}}%
+\def\XINT_flpower_toII #1#2{\XINT_flpower_loopII {#2}{#1}}%
+\def\XINT_flpower_loopII #1%
{%
- \ifnum #2 = 1
- \expandafter\XINT_flpower_loop
+ \if1\XINT_isOne {#1}\XINT_flpower_IItoIII\fi
+ \if1\xintiiOdd{#1}%
+ \expandafter\expandafter\expandafter\XINT_flpower_loopII_odd
\else
- \expandafter\XINT_flpower_loop_throwaway
+ \expandafter\expandafter\expandafter\XINT_flpower_loopII_even
\fi
- {#4}{#1}{#3}%
+ \expandafter {\romannumeral0\xinthalf{#1}}%
+}%
+\def\XINT_flpower_loopII_even #1#2#3%
+{%
+ \expandafter\XINT_flpower_toII\expandafter
+ {#3{#2}{#2}}{#1}{#3}%
}%
-\def\XINT_flpower_loop_throwaway #1#2#3#4%
+\def\XINT_flpower_loopII_odd #1#2#3#4%
{%
- \XINT_flpower_loop {#1}{#2}{#3}%
+ \expandafter\XINT_flpower_loopII_odda\expandafter
+ {#3{#2}{#4}}{#2}{#3}{#1}%
+}%
+\def\XINT_flpower_loopII_odda #1#2#3#4%
+{%
+ \expandafter\XINT_flpower_toII\expandafter
+ {#3{#2}{#2}}{#4}{#3}{#1}%
+}%
+\def\XINT_flpower_IItoIII\fi #1\fi\expandafter #2#3#4#5#6%
+{%
+ \fi\expandafter\XINT_flpow_III\the\numexpr #6\expandafter\relax
+ #4{#3}{#5}%
}%
% \end{macrocode}
-% \subsection{\csh{xintFloatSqrt}}
+% \subsection{\csh{xintFloatSqrt}, \csh{XINTinFloatSqrt}}
% \lverb|1.08|
% \begin{macrocode}
\def\xintFloatSqrt {\romannumeral0\xintfloatsqrt }%
\def\xintfloatsqrt #1{\XINT_flsqrt_chkopt \xintfloat #1\Z }%
\def\XINTinFloatSqrt {\romannumeral0\XINTinfloatsqrt }%
-\def\XINTinfloatsqrt #1{\XINT_flsqrt_chkopt \XINT_inFloat #1\Z }%
+\def\XINTinfloatsqrt #1{\XINT_flsqrt_chkopt \XINTinfloat #1\Z }%
\def\XINT_flsqrt_chkopt #1#2%
{%
\ifx [#2\expandafter\XINT_flsqrt_opt
@@ -19913,7 +21020,7 @@ first place.
\def\XINT_FL_sqrt_a #1#2%
{%
\expandafter\XINT_FL_sqrt_checkifzeroorneg
- \romannumeral0\XINT_inFloat [#1]{#2}%
+ \romannumeral0\XINTinfloat [#1]{#2}%
}%
\def\XINT_FL_sqrt_checkifzeroorneg #1%
{%
@@ -19923,8 +21030,8 @@ first place.
0-{\XINT_FL_sqrt_b #1}%
\krof
}%
-\def\XINT_FL_sqrt_iszero #1[#2]{0/1[0]}%
-\def\XINT_FL_sqrt_isneg #1[#2]{\xintError:RootOfNegative 0/1[0]}%
+\def\XINT_FL_sqrt_iszero #1[#2]{0[0]}%
+\def\XINT_FL_sqrt_isneg #1[#2]{\xintError:RootOfNegative 0[0]}%
\def\XINT_FL_sqrt_b #1[#2]%
{%
\ifodd #2
@@ -19943,15 +21050,14 @@ first place.
\expandafter\XINT_sqrt_a
\expandafter{\romannumeral0\xintlength {#2}}\XINT_flsqrt_big_d {#2}{#1}%
}%
-\def\XINT_flsqrt_big_d #1\or #2\fi #3%
+\def\XINT_flsqrt_big_d #1#2%
{%
- \fi
- \ifodd #3
- \xint_afterfi{\expandafter\XINT_flsqrt_big_eB}%
+ \ifodd #2
+ \expandafter\expandafter\expandafter\XINT_flsqrt_big_eB
\else
- \xint_afterfi{\expandafter\XINT_flsqrt_big_eA}%
+ \expandafter\expandafter\expandafter\XINT_flsqrt_big_eA
\fi
- \expandafter {\the\numexpr (#3-\xint_c_i)/\xint_c_ii }{#1}%
+ \expandafter {\the\numexpr (#2-\xint_c_i)/\xint_c_ii }{#1}%
}%
\def\XINT_flsqrt_big_eA #1#2#3%
{%
@@ -20062,6 +21168,157 @@ first place.
{\xintHalf{\xintiiQuo{\XINT_dsx_addzerosnofuss {#4}{#2}}{#3}}}}%
}%
\def\XINT_flsqrt_big_end_b #1#2{#2[#1]}%
+% \end{macrocode}
+% \subsection{\csh{XINTinFloatMaxof}}
+% \lverb|1.09a, for use by \xintNewFloatExpr. Name changed in 1.09h|
+% \begin{macrocode}
+\def\XINTinFloatMaxof {\romannumeral0\XINTinfloatmaxof }%
+\def\XINTinfloatmaxof #1{\expandafter\XINT_flmaxof_a\romannumeral-`0#1\relax }%
+\def\XINT_flmaxof_a #1{\expandafter\XINT_flmaxof_b
+ \romannumeral0\XINTinfloat [\XINTdigits]{#1}\Z }%
+\def\XINT_flmaxof_b #1\Z #2%
+ {\expandafter\XINT_flmaxof_c\romannumeral-`0#2\Z {#1}\Z}%
+\def\XINT_flmaxof_c #1%
+ {\xint_gob_til_relax #1\XINT_flmaxof_e\relax\XINT_flmaxof_d #1}%
+\def\XINT_flmaxof_d #1\Z
+ {\expandafter\XINT_flmaxof_b\romannumeral0\xintmax
+ {\XINTinFloat [\XINTdigits]{#1}}}%
+\def\XINT_flmaxof_e #1\Z #2\Z { #2}%
+% \end{macrocode}
+% \subsection{\csh{XINTinFloatMinof}}
+% \lverb|1.09a, for use by \xintNewFloatExpr. Name changed in 1.09h|
+% \begin{macrocode}
+\def\XINTinFloatMinof {\romannumeral0\XINTinfloatminof }%
+\def\XINTinfloatminof #1{\expandafter\XINT_flminof_a\romannumeral-`0#1\relax }%
+\def\XINT_flminof_a #1{\expandafter\XINT_flminof_b
+ \romannumeral0\XINTinfloat [\XINTdigits]{#1}\Z }%
+\def\XINT_flminof_b #1\Z #2%
+ {\expandafter\XINT_flminof_c\romannumeral-`0#2\Z {#1}\Z}%
+\def\XINT_flminof_c #1%
+ {\xint_gob_til_relax #1\XINT_flminof_e\relax\XINT_flminof_d #1}%
+\def\XINT_flminof_d #1\Z
+ {\expandafter\XINT_flminof_b\romannumeral0\xintmin
+ {\XINTinFloat [\XINTdigits]{#1}}}%
+\def\XINT_flminof_e #1\Z #2\Z { #2}%
+% \end{macrocode}
+% \subsection{\csh{xintRound:csv}}
+% \lverb|1.09a. For use by \xinttheiexpr.|
+% \begin{macrocode}
+\def\xintRound:csv #1{\expandafter\XINT_round:_a\romannumeral-`0#1,,^}%
+\def\XINT_round:_a {\XINT_round:_b {}}%
+\def\XINT_round:_b #1#2,%
+ {\expandafter\XINT_round:_c\romannumeral-`0#2,{#1}}%
+\def\XINT_round:_c #1{\if #1,\expandafter\XINT_:_f
+ \else\expandafter\XINT_round:_d\fi #1}%
+\def\XINT_round:_d #1,%
+ {\expandafter\XINT_round:_e\romannumeral0\xintiround 0{#1},}%
+\def\XINT_round:_e #1,#2{\XINT_round:_b {#2,#1}}%
+% \end{macrocode}
+% \subsection{\csh{xintFloat:csv}}
+% \lverb|1.09a. For use by \xintthefloatexpr.|
+% \begin{macrocode}
+\def\xintFloat:csv #1{\expandafter\XINT_float:_a\romannumeral-`0#1,,^}%
+\def\XINT_float:_a {\XINT_float:_b {}}%
+\def\XINT_float:_b #1#2,%
+ {\expandafter\XINT_float:_c\romannumeral-`0#2,{#1}}%
+\def\XINT_float:_c #1{\if #1,\expandafter\XINT_:_f
+ \else\expandafter\XINT_float:_d\fi #1}%
+\def\XINT_float:_d #1,%
+ {\expandafter\XINT_float:_e\romannumeral0\xintfloat {#1},}%
+\def\XINT_float:_e #1,#2{\XINT_float:_b {#2,#1}}%
+% \end{macrocode}
+% \subsection{\csh{xintSum:csv}}
+% \lverb|1.09a. For use by \xintexpr.|
+% \begin{macrocode}
+\def\xintSum:csv #1{\expandafter\XINT_sum:_a\romannumeral-`0#1,,^}%
+\def\XINT_sum:_a {\XINT_sum:_b {0/1[0]}}%
+\def\XINT_sum:_b #1#2,{\expandafter\XINT_sum:_c\romannumeral-`0#2,{#1}}%
+\def\XINT_sum:_c #1{\if #1,\expandafter\XINT_:_e
+ \else\expandafter\XINT_sum:_d\fi #1}%
+\def\XINT_sum:_d #1,#2{\expandafter\XINT_sum:_b\expandafter
+ {\romannumeral0\xintadd {#2}{#1}}}%
+% \end{macrocode}
+% \subsection{\csh{xintPrd:csv}}
+% \lverb|1.09a. For use by \xintexpr.|
+% \begin{macrocode}
+\def\xintPrd:csv #1{\expandafter\XINT_prd:_a\romannumeral-`0#1,,^}%
+\def\XINT_prd:_a {\XINT_prd:_b {1/1[0]}}%
+\def\XINT_prd:_b #1#2,{\expandafter\XINT_prd:_c\romannumeral-`0#2,{#1}}%
+\def\XINT_prd:_c #1{\if #1,\expandafter\XINT_:_e
+ \else\expandafter\XINT_prd:_d\fi #1}%
+\def\XINT_prd:_d #1,#2{\expandafter\XINT_prd:_b\expandafter
+ {\romannumeral0\xintmul {#2}{#1}}}%
+% \end{macrocode}
+% \subsection{\csh{xintMaxof:csv}}
+% \lverb|1.09a. For use by \xintexpr. Even with only one
+% argument, there does not seem to be really a motive for using \xintraw?|
+% \begin{macrocode}
+\def\xintMaxof:csv #1{\expandafter\XINT_maxof:_b\romannumeral-`0#1,,}%
+\def\XINT_maxof:_b #1,#2,{\expandafter\XINT_maxof:_c\romannumeral-`0#2,{#1},}%
+\def\XINT_maxof:_c #1{\if #1,\expandafter\XINT_of:_e
+ \else\expandafter\XINT_maxof:_d\fi #1}%
+\def\XINT_maxof:_d #1,{\expandafter\XINT_maxof:_b\romannumeral0\xintmax {#1}}%
+% \end{macrocode}
+% \subsection{\csh{xintMinof:csv}}
+% \lverb|1.09a. For use by \xintexpr.|
+% \begin{macrocode}
+\def\xintMinof:csv #1{\expandafter\XINT_minof:_b\romannumeral-`0#1,,}%
+\def\XINT_minof:_b #1,#2,{\expandafter\XINT_minof:_c\romannumeral-`0#2,{#1},}%
+\def\XINT_minof:_c #1{\if #1,\expandafter\XINT_of:_e
+ \else\expandafter\XINT_minof:_d\fi #1}%
+\def\XINT_minof:_d #1,{\expandafter\XINT_minof:_b\romannumeral0\xintmin {#1}}%
+% \end{macrocode}
+% \subsection{\csh{XINTinFloatMinof:csv}}
+% \lverb|1.09a. For use by \xintfloatexpr. Name changed in 1.09h|
+% \begin{macrocode}
+\def\XINTinFloatMinof:csv #1{\expandafter\XINT_flminof:_a\romannumeral-`0#1,,}%
+\def\XINT_flminof:_a #1,{\expandafter\XINT_flminof:_b
+ \romannumeral0\XINTinfloat [\XINTdigits]{#1},}%
+\def\XINT_flminof:_b #1,#2,%
+ {\expandafter\XINT_flminof:_c\romannumeral-`0#2,{#1},}%
+\def\XINT_flminof:_c #1{\if #1,\expandafter\XINT_of:_e
+ \else\expandafter\XINT_flminof:_d\fi #1}%
+\def\XINT_flminof:_d #1,%
+ {\expandafter\XINT_flminof:_b\romannumeral0\xintmin
+ {\XINTinFloat [\XINTdigits]{#1}}}%
+% \end{macrocode}
+% \subsection{\csh{XINTinFloatMaxof:csv}}
+% \lverb|1.09a. For use by \xintfloatexpr. Name changed in 1.09h|
+% \begin{macrocode}
+\def\XINTinFloatMaxof:csv #1{\expandafter\XINT_flmaxof:_a\romannumeral-`0#1,,}%
+\def\XINT_flmaxof:_a #1,{\expandafter\XINT_flmaxof:_b
+ \romannumeral0\XINTinfloat [\XINTdigits]{#1},}%
+\def\XINT_flmaxof:_b #1,#2,%
+ {\expandafter\XINT_flmaxof:_c\romannumeral-`0#2,{#1},}%
+\def\XINT_flmaxof:_c #1{\if #1,\expandafter\XINT_of:_e
+ \else\expandafter\XINT_flmaxof:_d\fi #1}%
+\def\XINT_flmaxof:_d #1,%
+ {\expandafter\XINT_flmaxof:_b\romannumeral0\xintmax
+ {\XINTinFloat [\XINTdigits]{#1}}}%
+% \end{macrocode}
+% \subsection{\csh{XINTinFloatSum:csv}}
+% \lverb|1.09a. For use by \xintfloatexpr. Renamed in 1.09h|
+% \begin{macrocode}
+\def\XINTinFloatSum:csv #1{\expandafter\XINT_floatsum:_a\romannumeral-`0#1,,^}%
+\def\XINT_floatsum:_a {\XINT_floatsum:_b {0[0]}}%
+\def\XINT_floatsum:_b #1#2,%
+ {\expandafter\XINT_floatsum:_c\romannumeral-`0#2,{#1}}%
+\def\XINT_floatsum:_c #1{\if #1,\expandafter\XINT_:_e
+ \else\expandafter\XINT_floatsum:_d\fi #1}%
+\def\XINT_floatsum:_d #1,#2{\expandafter\XINT_floatsum:_b\expandafter
+ {\romannumeral0\XINTinfloatadd {#2}{#1}}}%
+% \end{macrocode}
+% \subsection{\csh{XINTinFloatPrd:csv}}
+% \lverb|1.09a. For use by \xintfloatexpr. Renamed in 1.09h|
+% \begin{macrocode}
+\def\XINTinFloatPred:csv #1{\expandafter\XINT_floatprd:_a\romannumeral-`0#1,,^}%
+\def\XINT_floatprd:_a {\XINT_floatprd:_b {1[0]}}%
+\def\XINT_floatprd:_b #1#2,%
+ {\expandafter\XINT_floatprd:_c\romannumeral-`0#2,{#1}}%
+\def\XINT_floatprd:_c #1{\if #1,\expandafter\XINT_:_e
+ \else\expandafter\XINT_floatprd:_d\fi #1}%
+\def\XINT_floatprd:_d #1,#2{\expandafter\XINT_floatprd:_b\expandafter
+ {\romannumeral0\XINTinfloatmul {#2}{#1}}}%
\XINT_restorecatcodes_endinput%
% \end{macrocode}
%\catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11
@@ -20116,8 +21373,7 @@ first place.
\else
\ifx\x\relax % plain-TeX, first loading of xintseries.sty
\ifx\w\relax % but xintfrac.sty not yet loaded.
- \y{xintseries}{Package xintfrac is required}%
- \y{xintseries}{Will try \string\input\space xintfrac.sty}%
+ \y{xintseries}{now issuing \string\input\space xintfrac.sty}%
\def\z{\endgroup\input xintfrac.sty\relax}%
\fi
\else
@@ -20125,8 +21381,7 @@ first place.
\ifx\x\empty % LaTeX, first loading,
% variable is initialized, but \ProvidesPackage not yet seen
\ifx\w\relax % xintfrac.sty not yet loaded.
- \y{xintseries}{Package xintfrac is required}%
- \y{xintseries}{Will try \string\RequirePackage{xintfrac}}%
+ \y{xintseries}{now issuing \string\RequirePackage{xintfrac}}%
\def\z{\endgroup\RequirePackage{xintfrac}}%
\fi
\else
@@ -20175,7 +21430,7 @@ first place.
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintseries}%
- [2013/12/18 v1.09i Expandable partial sums with xint package (jfB)]%
+ [2014/01/09 v1.09j Expandable partial sums with xint package (jfB)]%
% \end{macrocode}
% \subsection{\csh{xintSeries}}
% \lverb|&
@@ -20653,8 +21908,7 @@ first place.
\else
\ifx\x\relax % plain-TeX, first loading of xintcfrac.sty
\ifx\w\relax % but xintfrac.sty not yet loaded.
- \y{xintcfrac}{Package xintfrac is required}%
- \y{xintcfrac}{Will try \string\input\space xintfrac.sty}%
+ \y{xintcfrac}{now issuing \string\input\space xintfrac.sty}%
\def\z{\endgroup\input xintfrac.sty\relax}%
\fi
\else
@@ -20662,8 +21916,7 @@ first place.
\ifx\x\empty % LaTeX, first loading,
% variable is initialized, but \ProvidesPackage not yet seen
\ifx\w\relax % xintfrac.sty not yet loaded.
- \y{xintcfrac}{Package xintfrac is required}%
- \y{xintcfrac}{Will try \string\RequirePackage{xintfrac}}%
+ \y{xintcfrac}{now issuing \string\RequirePackage{xintfrac}}%
\def\z{\endgroup\RequirePackage{xintfrac}}%
\fi
\else
@@ -20712,7 +21965,7 @@ first place.
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintcfrac}%
- [2013/12/18 v1.09i Expandable continued fractions with xint package (jfB)]%
+ [2014/01/09 v1.09j Expandable continued fractions with xint package (jfB)]%
% \end{macrocode}
% \subsection{\csh{xintCFrac}}
% \begin{macrocode}
@@ -21776,6 +23029,21 @@ first place.
% so unpacking with |\string| can be done in a completely escape char agnostic
% way.
%
+% Version |1.09j| |[2014/01/09]|extends the tacit multiplication to the
+% case of a sub |\xintexpr|-essions. Also, it now |\xint_protect|s the
+% result of the |\xintexpr| full expansions, thus, an |\xintexpr|
+% without |\xintthe| prefix can be used not only as the first item
+% within an ``|\fdef|'' as previously but also now anywhere within an
+% |\edef|. Five tokens are used to pack the computation result rather
+% than the possibly hundreds or thousands of digits of an |\xintthe|
+% unlocked result. I deliberately omit a second |\xint_protect| which,
+% however would be necessary if some macro |\.=digits/digits[digits]|
+% had acquired some expandable meaning elsewhere. But this seems not
+% that probable, and adding the protection would mean impacting
+% everything only to allow some crazy user which has loaded something
+% else than xint to do an |\edef|... the |\xintexpr| computations are
+% otherwise in no way affected if such control sequences have a meaning.
+%
% \localtableofcontents
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
@@ -21815,8 +23083,7 @@ first place.
\else
\ifx\x\relax % plain-TeX, first loading of xintexpr.sty
\ifx\w\relax % but xintfrac.sty not yet loaded.
- \y{xintexpr}{Package xintfrac is required}%
- \y{xintexpr}{Will try \string\input\space xintfrac.sty}%
+ \y{xintexpr}{now issuing \string\input\space xintfrac.sty}%
\def\z{\endgroup\input xintfrac.sty\relax}%
\fi
\else
@@ -21824,8 +23091,7 @@ first place.
\ifx\x\empty % LaTeX, first loading,
% variable is initialized, but \ProvidesPackage not yet seen
\ifx\w\relax % xintfrac.sty not yet loaded.
- \y{xintexpr}{Package xintfrac is required}%
- \y{xintexpr}{Will try \string\RequirePackage{xintfrac}}%
+ \y{xintexpr}{now issuing \string\RequirePackage{xintfrac}}%
\def\z{\endgroup\RequirePackage{xintfrac}}%
\fi
\else
@@ -21874,7 +23140,7 @@ first place.
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintexpr}%
- [2013/12/18 v1.09i Expandable expression parser (jfB)]%
+ [2014/01/09 v1.09j Expandable expression parser (jfB)]%
% \end{macrocode}
% \subsection{Encapsulation in pseudo cs names, helper macros}
% \lverb|1.09i uses .= for encapsulation, thus allowing \escapechar to be
@@ -21883,7 +23149,7 @@ first place.
% compensate a tiny bit the time penalty of `.=' viz `.' in unlocking... well
% not really, I guess.|
% \begin{macrocode}
-\def\xint_gob_til_! #1!{}% nota bene: ! is of catcode 11
+\def\xint_gob_til_! #1!{}% nota bene: this ! has catcode 11
\edef\XINT_expr_lock #1!%
{\noexpand\expandafter\space\noexpand\csname .=#1\noexpand\endcsname }%
\def\XINT_expr_unlock {\expandafter\XINT_expr_unlock_a\string }%
@@ -21901,15 +23167,28 @@ first place.
% point. Should perhaps issue a warning, but well, people can also read the
% documentation. Also 1.09i removes \xinttheeval.
%
-% 1.09i has re-organized the material here.|
-% \begin{macrocode}
-\def\XINT_expr_done {!\XINT_expr_usethe\XINT_expr_print }%
-\let\XINT_iiexpr_done \XINT_expr_done
-\def\XINT_iexpr_done {!\XINT_expr_usethe\XINT_iexpr_print }%
-\def\XINT_flexpr_done {!\XINT_expr_usethe\XINT_flexpr_print }%
-\def\XINT_boolexpr_done{!\XINT_expr_usethe\XINT_boolexpr_print }%
-\def\XINT_expr_usethe {use_xintthe!\xintError:use_xintthe! }%
-\def\xintthe #1{\romannumeral-`0\expandafter\xint_gobble_ii\romannumeral-`0#1}%
+% 1.09i has re-organized the material here.
+%
+% 1.09j modifies the mechanism of \XINT_expr_usethe and
+% \XINT_expr_print, etc... in order for \xintexpr-essions to be usable
+% within \edef'initions. I hesitated quite a bit with adding
+% \xint_protect in front of the \.=digits macros, which will in
+% 99.99999$% of use cases supposed all have \relax meaning; and it is a
+% bit of a pain, really, it is quite a pain to add these extra tokens
+% only for \edef contexts and for situations which will never occur...
+% well no damn'it let's *NOT* add this extra \xint_protect. Just one
+% before the printing macro (which can not be \protected, else \xintthe
+% could not work).|
+% \begin{macrocode}
+\def\xint_protect {\noexpand\xint_protect\noexpand }% 1.09j
+\def\XINT_expr_done {!\XINT_expr_usethe\xint_protect\XINT_expr_print }%
+\let\XINT_iiexpr_done \XINT_expr_done
+\def\XINT_iexpr_done {!\XINT_expr_usethe\xint_protect\XINT_iexpr_print }%
+\def\XINT_flexpr_done {!\XINT_expr_usethe\xint_protect\XINT_flexpr_print }%
+\def\XINT_boolexpr_done {!\XINT_expr_usethe\xint_protect\XINT_boolexpr_print }%
+\protected\def\XINT_expr_usethe #1#2#3% modified in 1.09j
+ {\xintError:missing_xintthe!\show#3missing xintthe (see log)!}%
+\def\xintthe #1{\romannumeral-`0\expandafter\xint_gobble_iii\romannumeral-`0#1}%
\let\XINT_expr_print \XINT_expr_unlock
\def\XINT_iexpr_print #1{\xintRound:csv {\XINT_expr_unlock #1}}%
\def\XINT_flexpr_print #1{\xintFloat:csv {\XINT_expr_unlock #1}}%
@@ -21924,19 +23203,19 @@ first place.
\def\xintiieval
{\expandafter\XINT_iiexpr_until_end_a\romannumeral-`0\XINT_expr_getnext }%
\def\xinttheexpr
- {\romannumeral-`0\expandafter\xint_gobble_ii\romannumeral0\xinteval }%
+ {\romannumeral-`0\expandafter\xint_gobble_iii\romannumeral0\xinteval }%
\def\xintthefloatexpr
- {\romannumeral-`0\expandafter\xint_gobble_ii\romannumeral0\xintfloateval }%
+ {\romannumeral-`0\expandafter\xint_gobble_iii\romannumeral0\xintfloateval }%
\def\xinttheiiexpr
- {\romannumeral-`0\expandafter\xint_gobble_ii\romannumeral0\xintiieval }%
+ {\romannumeral-`0\expandafter\xint_gobble_iii\romannumeral0\xintiieval }%
\def\xintiexpr {\romannumeral0\expandafter\expandafter\expandafter
- \XINT_iexpr_done \expandafter\xint_gobble_iii\romannumeral0\xinteval }%
+ \XINT_iexpr_done \expandafter\xint_gobble_iv\romannumeral0\xinteval }%
\def\xinttheiexpr {\romannumeral-`0\expandafter\expandafter\expandafter
- \XINT_iexpr_print\expandafter\xint_gobble_iii\romannumeral0\xinteval }%
+ \XINT_iexpr_print\expandafter\xint_gobble_iv\romannumeral0\xinteval }%
\def\xintboolexpr {\romannumeral0\expandafter\expandafter\expandafter
- \XINT_boolexpr_done \expandafter\xint_gobble_iii\romannumeral0\xinteval }%
+ \XINT_boolexpr_done \expandafter\xint_gobble_iv\romannumeral0\xinteval }%
\def\xinttheboolexpr {\romannumeral-`0\expandafter\expandafter\expandafter
- \XINT_boolexpr_print\expandafter\xint_gobble_iii\romannumeral0\xinteval }%
+ \XINT_boolexpr_print\expandafter\xint_gobble_iv\romannumeral0\xinteval }%
\let\xintnumexpr \xintiexpr % deprecated
\let\xintthenumexpr\xinttheiexpr % deprecated
% \end{macrocode}
@@ -22027,7 +23306,7 @@ first place.
}%
\def\XINT_expr_getnext_gotonetoken_wehope\Z #1%
{% screens out sub-expressions and \count or \dimen registers/variables
- \xint_gob_til_! #1\XINT_expr_subexpr !%
+ \xint_gob_til_! #1\XINT_expr_subexpr !% recall this ! has catcode 11
\ifcat\relax#1% \count or \numexpr etc... token or count, dimen, skip cs
\expandafter\XINT_expr_countdimenetc_fork
\else
@@ -22036,7 +23315,7 @@ first place.
\fi
#1%
}%
-\def\XINT_expr_subexpr !#1\fi {\expandafter\XINT_expr_getop\xint_gobble_iii }%
+\def\XINT_expr_subexpr !#1\fi !{\expandafter\XINT_expr_getop\xint_gobble_iii }%
\def\XINT_expr_countdimenetc_fork #1%
{%
\ifx\count#1\else\ifx#1\dimen\else\ifx#1\numexpr\else\ifx#1\dimexpr\else
@@ -22066,10 +23345,10 @@ first place.
{% The * is in truth catcode 12 #. For (hacking) use with \xintNewExpr.
\XINT_expr_sixwayfork
#1-.+*{\xint_c_xviii ({}}% back to until for oparen triggering
- (#1.+*-%
- (-#1+*{\XINT_expr_scandec_II.}%
- (-.#1*\XINT_expr_getnext%
- (-.+#1{\XINT_expr_scandec_II}%
+ (#1.+*{-}%
+ (-#1+*{\XINT_expr_scandec_II .}%
+ (-.#1*{\XINT_expr_getnext }%
+ (-.+#1{\XINT_expr_scandec_II }%
(-.+*{\XINT_expr_scan_dec_or_func #1}%
\krof
}}%
@@ -22122,7 +23401,10 @@ first place.
% _getop. 1.09i modifies \XINT_expr_scanintpart_a (splits _aa) and also
% \XINT_expr_scanfracpart_a in
% order for the tacit multiplication of \count's and \dimen's to be compatible
-% with escape-char=a digit|
+% with escape-char=a digit.
+%
+% 1.09j further extends to recognize an \xintexpr (or cousin) and then insert
+% automatically a * (done in \XINT_expr_getop).|
% \begin{macrocode}
\def\XINT_expr_scandec_I
{%
@@ -22135,11 +23417,12 @@ first place.
\XINT_expr_lock\romannumeral-`0\XINT_expr_scanfracpart_b
}%
\def\XINT_expr_scanintpart_a #1% Please no braced material: 123{FORBIDDEN}
-{%
+{% careful that ! has catcode letter... spaces needed after <cs>...
\ifcat #1\relax
- \expandafter !%
- \else \expandafter\expandafter\expandafter
- \XINT_expr_scanintpart_aa\expandafter\string
+ \expandafter !% stop number scan if \relax, \count, \numexpr, or
+ \else \xint_afterfi{\ifx !#1\expandafter !\else % also \xintexpr etc..
+ \expandafter\expandafter\expandafter
+ \XINT_expr_scanintpart_aa\expandafter\string\fi }%
\fi #1%
}%
\def\XINT_expr_scanintpart_aa #1%
@@ -22151,7 +23434,7 @@ first place.
\expandafter\expandafter\expandafter
\XINT_expr_scandec_transition
\else % gather what we got so far, leave catcode 12 #1 in stream
- \expandafter\expandafter\expandafter !% ! of catcode 11 ...
+ \expandafter\expandafter\expandafter !% ! of catcode 11, space needed
\fi
\fi
#1%
@@ -22169,9 +23452,10 @@ first place.
\def\XINT_expr_scanfracpart_a #1%
{%
\ifcat #1\relax
- \expandafter !%
- \else \expandafter\expandafter\expandafter
- \XINT_expr_scanfracpart_aa\expandafter\string
+ \expandafter !% stop number scan
+ \else \xint_afterfi{\ifx !#1\expandafter !\else
+ \expandafter\expandafter\expandafter
+ \XINT_expr_scanfracpart_aa\expandafter\string\fi }%
\fi #1%
}%
\def\XINT_expr_scanfracpart_aa #1%
@@ -22212,6 +23496,10 @@ first place.
%
% 1.09i allows \count's, \dimen's, \skip's with tacit multiplication.
%
+% 1.09j extends the mechanism of tacit multiplication to the case of a sub
+% xintexpression in its various variants. Careful that our ! has catcode 11 so
+% \ifx! would be a disaster...
+%
% |
% \begin{macrocode}
\def\XINT_expr_getop #1% this #1 is the current locked computed value
@@ -22224,10 +23512,14 @@ first place.
\ifcat #2\relax\expandafter\xint_firstoftwo
\else \expandafter\xint_secondoftwo
\fi
- {\ifx #2\relax\expandafter\XINT_expr_foundend\expandafter#1%
- \else
- \xint_afterfi{\XINT_expr_foundop *#1#2}%
- \fi }%
+ {\ifx #2\relax\expandafter\xint_firstofthree
+ \else\expandafter\xint_secondofthree % tacit multiplication
+ \fi }%
+ {\ifx !#2\expandafter\xint_secondofthree % tacit multiplication
+ \else\expandafter\xint_thirdofthree
+ \fi }%
+ {\XINT_expr_foundend #1}%
+ {\XINT_expr_foundop *#1#2}%
{\XINT_expr_foundop #2#1}%
}%
\def\XINT_expr_foundend {\xint_c_ \relax }% \relax is a place holder here.
@@ -23071,7 +24363,7 @@ first place.
Right bracket \] Circumflex \^ Underscore \_
Grave accent \` Left brace \{ Vertical bar \|
Right brace \} Tilde \~}
-\CheckSum {20743}
+\CheckSum {21191}
\makeatletter\check@checksum\makeatother
\Finale
%% End of file xint.dtx