texlive[42698] Master/texmf-dist: xint (13dec16)
commits+karl at tug.org
commits+karl at tug.org
Tue Dec 13 23:25:04 CET 2016
Revision: 42698
http://tug.org/svn/texlive?view=revision&revision=42698
Author: karl
Date: 2016-12-13 23:25:04 +0100 (Tue, 13 Dec 2016)
Log Message:
-----------
xint (13dec16)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/generic/xint/CHANGES.html
trunk/Master/texmf-dist/doc/generic/xint/CHANGES.pdf
trunk/Master/texmf-dist/doc/generic/xint/README
trunk/Master/texmf-dist/doc/generic/xint/README.html
trunk/Master/texmf-dist/doc/generic/xint/README.pdf
trunk/Master/texmf-dist/doc/generic/xint/sourcexint.pdf
trunk/Master/texmf-dist/doc/generic/xint/xint.pdf
trunk/Master/texmf-dist/source/generic/xint/xint.dtx
trunk/Master/texmf-dist/source/generic/xint/xint.ins
trunk/Master/texmf-dist/tex/generic/xint/xint.sty
trunk/Master/texmf-dist/tex/generic/xint/xintbinhex.sty
trunk/Master/texmf-dist/tex/generic/xint/xintcfrac.sty
trunk/Master/texmf-dist/tex/generic/xint/xintcore.sty
trunk/Master/texmf-dist/tex/generic/xint/xintexpr.sty
trunk/Master/texmf-dist/tex/generic/xint/xintfrac.sty
trunk/Master/texmf-dist/tex/generic/xint/xintgcd.sty
trunk/Master/texmf-dist/tex/generic/xint/xintkernel.sty
trunk/Master/texmf-dist/tex/generic/xint/xintseries.sty
trunk/Master/texmf-dist/tex/generic/xint/xinttools.sty
Modified: trunk/Master/texmf-dist/doc/generic/xint/CHANGES.html
===================================================================
--- trunk/Master/texmf-dist/doc/generic/xint/CHANGES.html 2016-12-13 22:24:48 UTC (rev 42697)
+++ trunk/Master/texmf-dist/doc/generic/xint/CHANGES.html 2016-12-13 22:25:04 UTC (rev 42698)
@@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
- <meta name="author" content="xint 1.2h" />
+ <meta name="author" content="xint 1.2i" />
<title>CHANGE LOG</title>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
@@ -17,46 +17,51 @@
<body>
<div id="header">
<h1 class="title">CHANGE LOG</h1>
-<h2 class="author">xint 1.2h</h2>
-<h3 class="date">2016/11/20</h3>
+<h2 class="author">xint 1.2i</h2>
+<h3 class="date">2016/12/13</h3>
</div>
<div id="TOC">
<ul>
-<li><a href="#h-20161120"><code>1.2h (2016/11/20)</code></a><ul>
+<li><a href="#i-20161213"><code>1.2i (2016/12/13)</code></a><ul>
+<li><a href="#incompatible-changes">Incompatible changes</a></li>
<li><a href="#improvements-and-new-features">Improvements and new features</a></li>
<li><a href="#bug-fixes">Bug fixes</a></li>
</ul></li>
-<li><a href="#g-20160319"><code>1.2g (2016/03/19)</code></a><ul>
-<li><a href="#incompatible-changes">Incompatible changes</a></li>
+<li><a href="#h-20161120"><code>1.2h (2016/11/20)</code></a><ul>
<li><a href="#improvements-and-new-features-1">Improvements and new features</a></li>
+<li><a href="#bug-fixes-1">Bug fixes</a></li>
</ul></li>
-<li><a href="#f-20160312"><code>1.2f (2016/03/12)</code></a><ul>
+<li><a href="#g-20160319"><code>1.2g (2016/03/19)</code></a><ul>
<li><a href="#incompatible-changes-1">Incompatible changes</a></li>
-<li><a href="#bug-fixes-1">Bug fixes</a></li>
<li><a href="#improvements-and-new-features-2">Improvements and new features</a></li>
</ul></li>
-<li><a href="#e-20151122"><code>1.2e (2015/11/22)</code></a><ul>
+<li><a href="#f-20160312"><code>1.2f (2016/03/12)</code></a><ul>
+<li><a href="#incompatible-changes-2">Incompatible changes</a></li>
<li><a href="#bug-fixes-2">Bug fixes</a></li>
<li><a href="#improvements-and-new-features-3">Improvements and new features</a></li>
</ul></li>
-<li><a href="#d-20151118"><code>1.2d (2015/11/18)</code></a><ul>
+<li><a href="#e-20151122"><code>1.2e (2015/11/22)</code></a><ul>
<li><a href="#bug-fixes-3">Bug fixes</a></li>
<li><a href="#improvements-and-new-features-4">Improvements and new features</a></li>
</ul></li>
-<li><a href="#c-20151116"><code>1.2c (2015/11/16)</code></a><ul>
+<li><a href="#d-20151118"><code>1.2d (2015/11/18)</code></a><ul>
<li><a href="#bug-fixes-4">Bug fixes</a></li>
<li><a href="#improvements-and-new-features-5">Improvements and new features</a></li>
</ul></li>
-<li><a href="#b-20151029"><code>1.2b (2015/10/29)</code></a><ul>
+<li><a href="#c-20151116"><code>1.2c (2015/11/16)</code></a><ul>
<li><a href="#bug-fixes-5">Bug fixes</a></li>
+<li><a href="#improvements-and-new-features-6">Improvements and new features</a></li>
</ul></li>
-<li><a href="#a-20151019"><code>1.2a (2015/10/19)</code></a><ul>
+<li><a href="#b-20151029"><code>1.2b (2015/10/29)</code></a><ul>
<li><a href="#bug-fixes-6">Bug fixes</a></li>
-<li><a href="#improvements-and-new-features-6">Improvements and new features</a></li>
</ul></li>
-<li><a href="#section"><code>1.2 (2015/10/10)</code></a><ul>
+<li><a href="#a-20151019"><code>1.2a (2015/10/19)</code></a><ul>
+<li><a href="#bug-fixes-7">Bug fixes</a></li>
<li><a href="#improvements-and-new-features-7">Improvements and new features</a></li>
</ul></li>
+<li><a href="#section"><code>1.2 (2015/10/10)</code></a><ul>
+<li><a href="#improvements-and-new-features-8">Improvements and new features</a></li>
+</ul></li>
<li><a href="#c-20150912"><code>1.1c (2015/09/12)</code></a></li>
<li><a href="#b-20150831"><code>1.1b (2015/08/31)</code></a></li>
<li><a href="#a-20141107"><code>1.1a (2014/11/07)</code></a></li>
@@ -87,17 +92,46 @@
<li><a href="#section-8"><code>1.0 (2013/03/28)</code></a></li>
</ul>
</div>
-<pre><code>Source: xint.dtx 1.2h 2016/11/20 (doc 2016/11/20)
+<pre><code>Source: xint.dtx 1.2i 2016/12/13 (doc 2016/12/13)
Author: Jean-Francois Burnol
Info: Expandable operations on big integers, decimals, fractions
License: LPPL 1.3c</code></pre>
-<h2 id="h-20161120"><code>1.2h (2016/11/20)</code></h2>
+<h2 id="i-20161213"><code>1.2i (2016/12/13)</code></h2>
+<h3 id="incompatible-changes">Incompatible changes</h3>
+<ul>
+<li><p>some macros which had been marked as deprecated are removed (they are available under different names): <code>\xintifTrue</code>, <code>\xintifTrueFalse</code>, <code>\xintQuo</code>, <code>\xintRem</code>, <code>\xintquo</code>, <code>\xintrem</code>.</p></li>
+<li><p><code>\xintDecSplit</code> second argument must have no sign (former code replaced it with its absolute value, a sign now may cause an error.)</p></li>
+</ul>
<h3 id="improvements-and-new-features">Improvements and new features</h3>
<ul>
+<li><p><strong>xintkernel</strong>: <code>\xintLength</code> is faster. New macros:</p>
+<ul>
+<li><p><code>\xintLastItem</code> to fetch the last item from its argument,</p></li>
+<li><p><code>\romannumeral\xintgobble</code> for gobbling many (up to 531440) upstream braced items or tokens.</p></li>
+<li><p><code>\romannumeral\xintreplicate</code> which is copied over from the expl3 <code>\prg_replicate:nn</code> with some minor changes.</p></li>
+</ul></li>
+<li><p><strong>xinttools</strong>: general token list handling routines <code>\xintKeep</code>, <code>\xintTrim</code> and <code>\xintNthElt</code> are faster; but the novel <code>\xintTrim</code> can only remove up to a maximum of 531440 items.</p>
+<p>Also, <code>\xintFor</code> partially improves on some issues which are reported upon in the documentation.</p></li>
+<li><p>some old macros have been rewritten entirely or partially using techniques which <strong>xint</strong> started using in release <code>1.2</code>:</p>
+<ul>
+<li><p><strong>xintcore</strong>: <code>\xintDouble</code>, <code>\xintHalf</code>, <code>\xintInc</code>, <code>\xintDec</code>, <code>\xintiiLDg</code>, <code>\xintDSR</code> (originally from <strong>xint</strong>), a novel <code>\xintDSRr</code>.</p></li>
+<li><p><strong>xint</strong>: <code>\xintDSH</code>, <code>\xintDSx</code>, <code>\xintDecSplit</code>, <code>\xintiiE</code>.</p></li>
+<li><p><strong>xintfrac</strong>: as a result of the above <code>\xintTrunc</code>, <code>\xintRound</code> and <code>\xintXTrunc</code> got faster. But the main improvement for them is with decimal inputs which formerly had not been treated separately from the general fraction case. Also, <code>\xintXTrunc</code> does not anymore create a dependency of <strong>xintfrac</strong> on <strong>xinttools</strong>.</p></li>
+</ul></li>
+<li><p>the documentation has again been (slightly) re-organized; it has a new sub-section on the Miller-Rabin primality test, to illustrate some use of <code>\xintNewFunction</code> for recursive definitions.</p></li>
+<li><p>the documentation has dropped the LaTeX "command" terminology (which had been used initially in 2013 for some forgotten reasons and should have been removed long ago) and uses only the more apt "macro", as after all, all of <strong>xint</strong> is about expansion of macros (plus the use of <code>\numexpr</code>).</p></li>
+</ul>
+<h3 id="bug-fixes">Bug fixes</h3>
+<ul>
+<li><code>\xintDecSplitL</code> and <code>\xintDecSplitR</code> from <strong>xint</strong> produced their output in a spurious brace pair (bug introduced in <code>1.2f</code>).</li>
+</ul>
+<h2 id="h-20161120"><code>1.2h (2016/11/20)</code></h2>
+<h3 id="improvements-and-new-features-1">Improvements and new features</h3>
+<ul>
<li><p>new macro <code>\xintNewFunction</code> in <strong>xintexpr</strong> which allows to extend the parser syntax with functions in situations where <code>\xintdeffunc</code> is not usable (typically, because dummy variables are used over a not yet determined range of values because it depends on the variables).</p></li>
<li><p>after three years of strict obedience to <code>xint</code> prefix, now <code>\thexintexpr</code>, <code>\thexintiexpr</code>, <code>\thexintfloatexpr</code>, and <code>\thexintiiexpr</code> are provided as synonyms to <code>\xinttheexpr</code>, etc...</p></li>
</ul>
-<h3 id="bug-fixes">Bug fixes</h3>
+<h3 id="bug-fixes-1">Bug fixes</h3>
<ul>
<li><p>the <code>(cond)?{foo}{bar}</code> operator from <strong>xintexpr</strong> mis-behaved in certain circumstances (such as an empty <code>foo</code>).</p></li>
<li><p>the <strong>xintexpr</strong> <code>1.2f</code> <code>binomial</code> function (which uses <code>\xintiiBinomial</code> from <strong>xint.sty</strong> or <code>\xintFloatBinomial</code> from <strong>xintfrac.sty</strong>) deliberately raised an error for <code>binomial(x,y)</code> with <code>y<0</code> or <code>x<y</code>. This was unfortunate, and it now simply evaluates to zero in such cases.</p></li>
@@ -105,12 +139,12 @@
<li><p>the <code>add</code> and <code>mul</code> from <strong>xintexpr</strong>, which work with dummy variables since <code>1.1</code>, raised an error since <code>1.2c 2015/11/16</code> when the dummy variable was given an empty range (or list) of values, rather than producing respectively <code>0</code> and <code>1</code> as formerly.</p></li>
</ul>
<h2 id="g-20160319"><code>1.2g (2016/03/19)</code></h2>
-<h3 id="incompatible-changes">Incompatible changes</h3>
+<h3 id="incompatible-changes-1">Incompatible changes</h3>
<ul>
<li><p>inside expressions, list item selector <code>[L][n]</code> counts starting at zero, not at one. This is more coherent with <code>[L][a:b]</code> which was already exactly like in Python since its introduction. A function len(L) replaces earlier <code>[L][0]</code>.</p></li>
<li><p>former <code>iter</code> keyword now called <code>iterr</code>. Indeed it matched with <code>rrseq</code>, the new <code>iter</code> (which was somehow missing from <code>1.1</code>) is the one matching <code>rseq</code>. Allows to iterate more easily with a "list" variable.</p></li>
</ul>
-<h3 id="improvements-and-new-features-1">Improvements and new features</h3>
+<h3 id="improvements-and-new-features-2">Improvements and new features</h3>
<ul>
<li><p>in <strong>xintexpr.sty</strong>: list selectors <code>[L][n]</code> and <code>[L][a:b]</code> are more efficient: the earlier <code>1.1</code> routines did back and forth conversions from comma separated values to braced tokens, the <code>1.2g</code> routines use macros from <strong>xinttools.sty</strong> handling directly the encountered lists of comma separated values.</p></li>
<li><p>in <strong>xinttools.sty</strong>: slight improvements in the efficiency of the <code>\xintNthElt</code>, <code>\xintKeep</code>, <code>\xintTrim</code> routines and new routines handling directly comma separated values. The latter are not included in the user manual (they are not <code>\long</code>, they don't make efforts to preserve some braces, do not worry about spaces, all those worries being irrelevant to the use in expressions for list selectors).</p></li>
@@ -119,17 +153,17 @@
<li><p>the syntax of expressions is described in a devoted chapter of the documentation; an example shows how to implement (expandably) the Brent-Salamin algorithm for computation of Pi using <code>iter</code> in a float expression.</p></li>
</ul>
<h2 id="f-20160312"><code>1.2f (2016/03/12)</code></h2>
-<h3 id="incompatible-changes-1">Incompatible changes</h3>
+<h3 id="incompatible-changes-2">Incompatible changes</h3>
<ul>
<li>no more <code>\xintFac</code> macro but <code>\xintiFac/\xintiiFac/\xintFloatFac</code>.</li>
</ul>
-<h3 id="bug-fixes-1">Bug fixes</h3>
+<h3 id="bug-fixes-2">Bug fixes</h3>
<ul>
<li><p>squaring macro <code>\xintSqr</code> from <strong>xintfrac.sty</strong> was broken due to a misspelled sub-macro name. Dates back to <code>1.1</code> release of <code>2014/10/28</code> <code>:-((</code>.</p></li>
<li><p><code>1.2c</code>'s fix to the subtraction bug from <code>1.2</code> introduced another bug, which in some cases could create leading zeroes in the output, or even worse. This could invalidate other routines using subtractions, like <code>\xintiiSquareRoot</code>.</p></li>
<li><p>the comparison operators were not recognized by <code>\xintNewIIExpr</code> and <code>\xintdefiifunc</code> constructs.</p></li>
</ul>
-<h3 id="improvements-and-new-features-2">Improvements and new features</h3>
+<h3 id="improvements-and-new-features-3">Improvements and new features</h3>
<ul>
<li><p>functions <code>binomial</code>, <code>pfactorial</code> and <code>factorial</code> in both integer and float versions.</p></li>
<li><p>macros <code>\xintiiBinomial</code>, <code>\xintiiPFactorial</code> (<strong>xint.sty</strong>) and <code>\xintFloatBinomial</code>, <code>\xintFloatPFactorial</code> (<strong>xintfrac.sty</strong>). Improvements to <code>\xintFloatFac</code>.</p></li>
@@ -144,13 +178,13 @@
<li><p>renewed desperate efforts at improving the documentation by random shuffling of sections and well thought additions; cuts were considered and even performed.</p></li>
</ul>
<h2 id="e-20151122"><code>1.2e (2015/11/22)</code></h2>
-<h3 id="bug-fixes-2">Bug fixes</h3>
+<h3 id="bug-fixes-3">Bug fixes</h3>
<ul>
<li><p>in <strong>xintfrac</strong>: the <code>\xintFloatFac</code> from release <code>1.2</code> parsed its argument only through <code>\numexpr</code> but it should have used <code>\xintNum</code>.</p></li>
<li><p>in <strong>xintexpr</strong>: release <code>1.2d</code> had broken the recognition of sub-expressions immediately after variable names (with tacit multiplication).</p></li>
<li><p>in <strong>xintexpr</strong>: contrarily to what <code>1.2d</code> documentation said, tacit multiplication was not yet always done with enhanced precedence. Now yes.</p></li>
</ul>
-<h3 id="improvements-and-new-features-3">Improvements and new features</h3>
+<h3 id="improvements-and-new-features-4">Improvements and new features</h3>
<ul>
<li><p>macro <code>\xintunassignvar</code>.</p></li>
<li><p>slight modifications of the logged messages in case of <code>\xintverbosetrue</code>.</p></li>
@@ -158,11 +192,11 @@
<li><p>documentation enhancements: the <em>Quick Sort</em> section with its included code samples has been entirely re-written; the <em>Commands of the xintexpr package</em> section has been extended and reviewed entirely.</p></li>
</ul>
<h2 id="d-20151118"><code>1.2d (2015/11/18)</code></h2>
-<h3 id="bug-fixes-3">Bug fixes</h3>
+<h3 id="bug-fixes-4">Bug fixes</h3>
<ul>
<li>in <strong>xintcore</strong>: release <code>1.2c</code> had inadvertently broken the <code>\xintiiDivRound</code> macro.</li>
</ul>
-<h3 id="improvements-and-new-features-4">Improvements and new features</h3>
+<h3 id="improvements-and-new-features-5">Improvements and new features</h3>
<ul>
<li><p>the function definitions done by <code>\xintdeffunc</code> et al., as well as the macro declarations by <code>\xintNewExpr</code> et al. now have only local scope.</p></li>
<li><p>tacit multiplication applies to more cases, for example (x+y)z, and always ties more than standard * infix operator, e.g. x/2y is like x/(2*y).</p></li>
@@ -169,26 +203,26 @@
<li><p>some documentation enhancements, particularly in the chapter on xintexpr.sty, and also in the code source comments.</p></li>
</ul>
<h2 id="c-20151116"><code>1.2c (2015/11/16)</code></h2>
-<h3 id="bug-fixes-4">Bug fixes</h3>
+<h3 id="bug-fixes-5">Bug fixes</h3>
<ul>
<li>in <strong>xintcore</strong>: recent release <code>1.2</code> introduced a bug in the subtraction (happened when 00000001 was found under certain circumstances at certain mod 8 locations).</li>
</ul>
-<h3 id="improvements-and-new-features-5">Improvements and new features</h3>
+<h3 id="improvements-and-new-features-6">Improvements and new features</h3>
<ul>
<li><p>macros <code>\xintdeffunc</code>, <code>\xintdefiifunc</code>, <code>\xintdeffloatfunc</code> and boolean <code>\ifxintverbose</code>.</p></li>
<li><p>on-going code improvements and documentation enhancements, but stopped in order to issue this bugfix release.</p></li>
</ul>
<h2 id="b-20151029"><code>1.2b (2015/10/29)</code></h2>
-<h3 id="bug-fixes-5">Bug fixes</h3>
+<h3 id="bug-fixes-6">Bug fixes</h3>
<ul>
<li>in <strong>xintcore</strong>: recent release <code>1.2</code> introduced a bug in the division macros, causing a crash when the divisor started with 99999999 (it was attempted to use with 1+99999999 a subroutine expecting only 8-digits numbers).</li>
</ul>
<h2 id="a-20151019"><code>1.2a (2015/10/19)</code></h2>
-<h3 id="bug-fixes-6">Bug fixes</h3>
+<h3 id="bug-fixes-7">Bug fixes</h3>
<ul>
<li>in <strong>xintexpr</strong>: recent release <code>1.2</code> introduced a bad bug in the parsing of decimal numbers and as a result <code>\xinttheexpr 0.01\relax</code> expanded to <code>0</code> ! (sigh...)</li>
</ul>
-<h3 id="improvements-and-new-features-6">Improvements and new features</h3>
+<h3 id="improvements-and-new-features-7">Improvements and new features</h3>
<ul>
<li><p>added <code>\xintKeepUnbraced</code>, <code>\xintTrimUnbraced</code> (<strong>xinttools</strong>) and fixed documentation of <code>\xintKeep</code> and <code>\xintTrim</code> regarding brace stripping.</p></li>
<li><p>added <code>\xintiiMaxof/\xintiiMinof</code> (<strong>xint</strong>).</p></li>
@@ -195,7 +229,7 @@
<li><p>TeX hackers only: replaced all code uses of <code>\romannumeral-`0</code> by the quicker <code>\romannumeral`&&@</code> (<code>^</code> being used as letter, had to find another character usable with catcode 7).</p></li>
</ul>
<h2 id="section"><code>1.2 (2015/10/10)</code></h2>
-<h3 id="improvements-and-new-features-7">Improvements and new features</h3>
+<h3 id="improvements-and-new-features-8">Improvements and new features</h3>
<ul>
<li><p>the basic arithmetic implemented in <strong>xintcore</strong> has been entirely rewritten. The mathematics remains the elementary school one, but the <code>TeX</code> implementation achieves higher speed (except, regarding addition/subtraction, for numbers up to about thirty digits), the gains becoming quite significant for numbers with hundreds of digits.</p></li>
<li><p>the inputs must have less than 19959 digits. But computations with thousands of digits take time.</p></li>
Modified: trunk/Master/texmf-dist/doc/generic/xint/CHANGES.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/generic/xint/README
===================================================================
--- trunk/Master/texmf-dist/doc/generic/xint/README 2016-12-13 22:24:48 UTC (rev 42697)
+++ trunk/Master/texmf-dist/doc/generic/xint/README 2016-12-13 22:25:04 UTC (rev 42698)
@@ -1,4 +1,4 @@
- Source: xint.dtx 1.2h 2016/11/20 (doc 2016/11/20)
+ Source: xint.dtx 1.2i 2016/12/13 (doc 2016/12/13)
Author: Jean-Francois Burnol
Info: Expandable operations on big integers, decimals, fractions
License: LPPL 1.3c
@@ -31,20 +31,22 @@
\xintthefloatexpr 123456789^1000.5\relax
-Mathematical functions (apart from sqrt which achieves correct rounding
-in arbitrary precision) are yet to be implemented.
+However, only integer and half-integer exponents are currently allowed:
+only the sqrt is implemented for floating point numbers. It achieves
+correct rounding in arbitrary precision.
It is possible to use the package with Plain as well as with LaTeX.
Sub-units xintcore, xint and xintfrac provide the underlying macros, and
xintexpr loads all of them and provides expandable parsers allowing
-computations such as the above (and more). A more light-weight package
-bnumexpr (LaTeX only) loads only xintcore and provides a parser which
-handles only big integers, the four operations, the power operation and
-the factorial (1.2).
+computations such as the above (and more).
+A more light-weight (LaTeX only) package bnumexpr loads only xintcore
+and provides a parser which handles only big integers, the four
+operations, the power operation and the factorial.
+
USAGE
@@ -69,9 +71,9 @@
\input xintexpr.sty
-Again, all dependencies are handled automatically. The packages may be
-loaded in any catcode context such that letters, digits, \ and % have
-their standard catcodes.
+All dependencies are handled automatically. The packages may be loaded
+in any catcode context such that letters, digits, \ and % have their
+standard catcodes.
xintcore.sty and xinttools.sty both import xintkernel.sty which has the
catcode handler and package identifier and defines a few utilities such
Modified: trunk/Master/texmf-dist/doc/generic/xint/README.html
===================================================================
--- trunk/Master/texmf-dist/doc/generic/xint/README.html 2016-12-13 22:24:48 UTC (rev 42697)
+++ trunk/Master/texmf-dist/doc/generic/xint/README.html 2016-12-13 22:25:04 UTC (rev 42698)
@@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
- <meta name="author" content="xint 1.2h" />
+ <meta name="author" content="xint 1.2i" />
<title>README</title>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
@@ -17,8 +17,8 @@
<body>
<div id="header">
<h1 class="title">README</h1>
-<h2 class="author">xint 1.2h</h2>
-<h3 class="date">2016/11/20</h3>
+<h2 class="author">xint 1.2i</h2>
+<h3 class="date">2016/12/13</h3>
</div>
<div id="TOC">
<ul>
@@ -36,7 +36,7 @@
<li><a href="#license">License</a></li>
</ul>
</div>
-<pre><code>Source: xint.dtx 1.2h 2016/11/20 (doc 2016/11/20)
+<pre><code>Source: xint.dtx 1.2i 2016/12/13 (doc 2016/12/13)
Author: Jean-Francois Burnol
Info: Expandable operations on big integers, decimals, fractions
License: LPPL 1.3c</code></pre>
@@ -51,9 +51,10 @@
<p>(evaluates to <code>15979066346135829902328007959448563667099190784</code>.)</p>
<p>Float computations are possible at an adjustable precision (default 16).</p>
<pre><code>\xintthefloatexpr 123456789^1000.5\relax</code></pre>
-<p>Mathematical functions (apart from <code>sqrt</code> which achieves correct rounding in arbitrary precision) are yet to be implemented.</p>
+<p>However, only integer and half-integer exponents are currently allowed: only the <code>sqrt</code> is implemented for floating point numbers. It achieves correct rounding in arbitrary precision.</p>
<p>It is possible to use the package with Plain as well as with LaTeX.</p>
-<p>Sub-units <code>xintcore</code>, <code>xint</code> and <code>xintfrac</code> provide the underlying macros, and <code>xintexpr</code> loads all of them and provides expandable parsers allowing computations such as the above (and more). A more light-weight package <a href="http://www.ctan.org/pkg/bnumexpr">bnumexpr</a> (LaTeX only) loads only <code>xintcore</code> and provides a parser which handles only big integers, the four operations, the power operation and the factorial (1.2).</p>
+<p>Sub-units <code>xintcore</code>, <code>xint</code> and <code>xintfrac</code> provide the underlying macros, and <code>xintexpr</code> loads all of them and provides expandable parsers allowing computations such as the above (and more).</p>
+<p>A more light-weight (LaTeX only) package <a href="http://www.ctan.org/pkg/bnumexpr">bnumexpr</a> loads only <code>xintcore</code> and provides a parser which handles only big integers, the four operations, the power operation and the factorial.</p>
<h1 id="usage">Usage</h1>
<h2 id="with-latex">With LaTeX</h2>
<pre><code>\usepackage{xint} % expandable arithmetic with big integers
@@ -63,7 +64,7 @@
<h2 id="with-tex">With TeX</h2>
<p>One does for example:</p>
<pre><code>\input xintexpr.sty</code></pre>
-<p>Again, all dependencies are handled automatically. The packages may be loaded in any catcode context such that letters, digits, <code>\</code> and <code>%</code> have their standard catcodes.</p>
+<p>All dependencies are handled automatically. The packages may be loaded in any catcode context such that letters, digits, <code>\</code> and <code>%</code> have their standard catcodes.</p>
<p><code>xintcore.sty</code> and <code>xinttools.sty</code> both import <code>xintkernel.sty</code> which has the catcode handler and package identifier and defines a few utilities such as <code>\oodef</code>, <code>\fdef</code>, or <code>\xint_dothis/\xint_orthat</code>.</p>
<h1 id="installation">Installation</h1>
<h2 id="method-a-using-the-package-manager-of-your-tex-distribution">Method A: using the package manager of your TeX distribution</h2>
Modified: trunk/Master/texmf-dist/doc/generic/xint/README.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/generic/xint/sourcexint.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/generic/xint/xint.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/generic/xint/xint.dtx
===================================================================
--- trunk/Master/texmf-dist/source/generic/xint/xint.dtx 2016-12-13 22:24:48 UTC (rev 42697)
+++ trunk/Master/texmf-dist/source/generic/xint/xint.dtx 2016-12-13 22:25:04 UTC (rev 42698)
@@ -3,20 +3,20 @@
% Extract all files via "etex xint.dtx" and do "make help"
% or follow instructions from extracted README.md.
%<*dtx>
-\def\xintdtxtimestamp {Time-stamp: <20-11-2016 at 22:43:58 CET>}
+\def\xintdtxtimestamp {Time-stamp: <13-12-2016 at 12:22:08 CET>}
%</dtx>
%<*drv>
%% ---------------------------------------------------------------
-\def\xintdocdate {2016/11/20}
-\def\xintbndldate{2016/11/20}
-\def\xintbndlversion {1.2h}
+\def\xintdocdate {2016/12/13}
+\def\xintbndldate{2016/12/13}
+\def\xintbndlversion {1.2i}
%</drv>
%<readme>% README
%<changes>% CHANGE LOG
-%<readme|changes>% xint 1.2h
-%<readme|changes>% 2016/11/20
+%<readme|changes>% xint 1.2i
+%<readme|changes>% 2016/12/13
%<readme|changes>
-%<readme|changes> Source: xint.dtx 1.2h 2016/11/20 (doc 2016/11/20)
+%<readme|changes> Source: xint.dtx 1.2i 2016/12/13 (doc 2016/12/13)
%<readme|changes> Author: Jean-Francois Burnol
%<readme|changes> Info: Expandable operations on big integers, decimals, fractions
%<readme|changes> License: LPPL 1.3c
@@ -23,7 +23,7 @@
%<readme|changes>
%<*!readme&!changes&!dohtmlsh&!dopdfsh&!makefile>
%% ---------------------------------------------------------------
-%% The xint bundle 1.2h 2016/11/20
+%% The xint bundle 1.2i 2016/12/13
%% Copyright (C) 2013-2016 by Jean-Francois Burnol
%<xintkernel>%% xintkernel: Paraphernalia for the xint packages
%<xinttools>%% xinttools: Expandable and non-expandable utilities
@@ -68,19 +68,22 @@
\xintthefloatexpr 123456789^1000.5\relax
-Mathematical functions (apart from `sqrt` which achieves correct
-rounding in arbitrary precision) are yet to be implemented.
+However, only integer and half-integer exponents are currently allowed:
+only the `sqrt` is implemented for floating point numbers. It achieves
+correct rounding in arbitrary precision.
It is possible to use the package with Plain as well as with LaTeX.
Sub-units `xintcore`, `xint` and `xintfrac` provide the underlying
macros, and `xintexpr` loads all of them and provides expandable
-parsers allowing computations such as the above (and more). A more
-light-weight package [bnumexpr](http://www.ctan.org/pkg/bnumexpr)
-(LaTeX only) loads only `xintcore` and provides a parser which
-handles only big integers, the four operations, the power operation
-and the factorial (1.2).
+parsers allowing computations such as the above (and more).
+A more light-weight (LaTeX only) package
+[bnumexpr](http://www.ctan.org/pkg/bnumexpr) loads only `xintcore` and
+provides a parser which handles only big integers, the four operations,
+the power operation and the factorial.
+
+
Usage
=====
@@ -104,7 +107,7 @@
\input xintexpr.sty
-Again, all dependencies are handled automatically. The packages may
+All dependencies are handled automatically. The packages may
be loaded in any catcode context such that letters, digits, `\` and
`%` have their standard catcodes.
@@ -240,6 +243,68 @@
%</readme>--------------------------------------------------------
%<*changes>-------------------------------------------------------
+`1.2i (2016/12/13)`
+----
+
+### Incompatible changes
+
+ - some macros which had been marked as deprecated are removed (they are
+ available under different names): `\xintifTrue`, `\xintifTrueFalse`,
+ `\xintQuo`, `\xintRem`, `\xintquo`, `\xintrem`.
+
+ - `\xintDecSplit` second argument must have no sign (former code
+ replaced it with its absolute value, a sign now may cause an error.)
+
+### Improvements and new features
+
+ - **xintkernel**: `\xintLength` is faster. New macros:
+
+ - `\xintLastItem` to fetch the last item from its argument,
+
+ - `\romannumeral\xintgobble` for gobbling many (up to 531440)
+ upstream braced items or tokens.
+
+ - `\romannumeral\xintreplicate` which is copied over from the expl3
+ `\prg_replicate:nn` with some minor changes.
+
+ - **xinttools**: general token list handling routines `\xintKeep`,
+ `\xintTrim` and `\xintNthElt` are faster; but the novel `\xintTrim`
+ can only remove up to a maximum of 531440 items.
+
+
+ Also, `\xintFor` partially improves on some issues which are
+ reported upon in the documentation.
+
+ - some old macros have been rewritten entirely or partially using
+ techniques which **xint** started using in release `1.2`:
+
+ - **xintcore**: `\xintDouble`, `\xintHalf`, `\xintInc`, `\xintDec`,
+ `\xintiiLDg`, `\xintDSR` (originally from **xint**), a novel
+ `\xintDSRr`.
+
+ - **xint**: `\xintDSH`, `\xintDSx`, `\xintDecSplit`, `\xintiiE`.
+
+ - **xintfrac**: as a result of the above `\xintTrunc`, `\xintRound`
+ and `\xintXTrunc` got faster. But the main improvement for them is
+ with decimal inputs which formerly had not been treated separately
+ from the general fraction case. Also, `\xintXTrunc` does not
+ anymore create a dependency of **xintfrac** on **xinttools**.
+
+ - the documentation has again been (slightly) re-organized; it has a
+ new sub-section on the Miller-Rabin primality test, to illustrate
+ some use of `\xintNewFunction` for recursive definitions.
+
+ - the documentation has dropped the LaTeX "command" terminology (which
+ had been used initially in 2013 for some forgotten reasons and should
+ have been removed long ago) and uses only the more apt "macro", as
+ after all, all of **xint** is about expansion of macros (plus the use
+ of `\numexpr`).
+
+### Bug fixes
+
+ - `\xintDecSplitL` and `\xintDecSplitR` from **xint** produced their
+ output in a spurious brace pair (bug introduced in `1.2f`).
+
`1.2h (2016/11/20)`
----
@@ -378,7 +443,7 @@
- (TeXperts only) the macros defined (internally) from `\xintdeffunc` et al.
constructs do not incorporate an initial `\romannumeral` anymore.
-
+
- renewed desperate efforts at improving the documentation by random
shuffling of sections and well thought additions; cuts were considered and
even performed.
@@ -1492,6 +1557,8 @@
README xint.pdf sourcexint.pdf xint.tds.zip
%</makefile>$-----------------------------------------------------
%<*pandoctpl>-----------------------------------------------------
+\newcommand{\tightlist}{%
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
$if(dvipdfmx)$
{\csname @for\endcsname\x:=hyperref,graphicx,color,xcolor\do
{\PassOptionsToPackage{dvipdfmx}\x}}
@@ -1855,6 +1922,7 @@
% \DeclareUnicodeCharacter{00F7}{\textdiv}
\def\PrivateObelus{\textdiv }%
\AtBeginDocument{\DeclareUnicodeCharacter {00F7}{\PrivateObelus}}%
+% utilisé où ? (2016/12/08)
\DeclareUnicodeCharacter {03B4}{\ensuremath{\delta}}%
\fi
@@ -1900,15 +1968,16 @@
\def\MARGEPAGENO {1.5em}% changera pour la partie implémentation
+\def\SKIPSECTIONINTERSPACE{\vskip\bigskipamount}
\etocsetstyle{section}{}
{\normalfont}
- {\kern\bigskipamount
+ {\SKIPSECTIONINTERSPACE
\rightskip \MARGEPAGENO\relax
\parfillskip -\MARGEPAGENO\relax
\bfseries
- \leftskip \leftmargini
+ \leftskip \leftmarginii
\noindent\llap % \llap
- {\makebox[\leftmargini][l]% et \leftmargini le 12/10/2014
+ {\makebox[\leftmarginii][l]% et \leftmargini le 12/10/2014
{\expandafter\textcolor\sectioncouleur {\etocnumber}}}%
\strut\etocname
\mdseries\nobreak\leaders\etoctoclineleaders\hfill\nobreak\strut
@@ -2071,7 +2140,7 @@
\ifnum\dosourcexint=1
\else
\renewcommand\familydefault\ttdefault
-\usepackage[noendash]{mathastext}% pas de endahs dans newtxtt
+\usepackage[noendash]{mathastext}% pas de endash dans newtxtt
\fi
\renewcommand\familydefault\sfdefault % <-- sans-serif in footnotes, TOC,
% headers etc...
@@ -2196,6 +2265,24 @@
\vtop{\noindent Changed (#1)}\ }}%
\vskip\dp\strutbox }\strut\@esphack}
+\def\CHANGEDf #1{\@bsphack
+ \vadjust{\vskip-\dp\strutbox
+ \smash{\hbox to 0pt {\hss\color[named]{PineGreen}%
+ \normalfont\small
+ \hsize 1.5cm\rightskip.5cm minus.5cm
+ \vtop{\noindent Changed (#1)}\
+ \kern\dimexpr\FrameSep+\FrameRule\relax}}%
+ \vskip\dp\strutbox }\strut\@esphack}
+
+\def\NewWithf #1{\@bsphack
+ \vadjust{\vskip-\dp\strutbox
+ \smash{\hbox to 0pt {\hss\color[named]{PineGreen}%
+ \normalfont\small
+ \hsize 1.5cm\rightskip.5cm minus.5cm
+ \vtop{\noindent New with #1}\
+ \kern\dimexpr\FrameSep+\FrameRule\relax}}%
+ \vskip\dp\strutbox }\strut\@esphack}
+
\makeatother
% \centeredline: OUR OWN LITTLE MACRO FOR CENTERING LINES
@@ -2205,7 +2292,7 @@
% -----------
%
% This macro allows to conveniently center a line inside a paragraph and still
-% allow use therein of \verb or other commands changing catcodes.
+% allow use therein of \verb or other macros changing catcodes.
% A proposito, the \LaTeX \centerline uses \hsize and not \linewidth !
% (which in my humble opinion is bad)
@@ -2337,7 +2424,7 @@
% Initially, June 2013, then Sep 9, 2014, and Oct 9-12 2014
%
% Initial motivation was simply that doc.sty and related classes \verb
-% command is with a hard-coded \ttfamily. There were further issues.
+% macro is with a hard-coded \ttfamily. There were further issues.
%
% 1. with |stuff with space|, paragraph reformatting in the Emacs/AUCTeX
% buffer caused havoc. Thus I wanted to be able to have the input across
@@ -2641,13 +2728,13 @@
\newcount\cntc
%--- \fexpan 22 octobre 2013
-\newcommand\fexpan {\textit{f}-expan}
+\newcommand\fexpan {\hyperref[ssec:expansions]{\textit{f}-expan}}
\ifnum\dosourcexint=1
\else
% Dependency graph done using TikZ (manually)
\usepackage{tikz}
- \usetikzlibrary{shapes,arrows}
+ \usetikzlibrary{shapes,arrows.meta}
\fi
\colorlet {codeboxbg}{yellow!10}
@@ -2733,7 +2820,7 @@
\etoctoccontentsline*{toctobookmark}{Contents}{1}%
}
\etocsettagdepth {description}{subsection}
- \etocsettagdepth {commands} {none}
+ \etocsettagdepth {macros}{none}
\etocsettagdepth {implementation}{none}
\tableofcontents
\renewcommand*\etocabovetocskip{\bigskipamount}
@@ -2744,7 +2831,7 @@
}%
\makeatother
\etocsettagdepth {description}{none}
- \etocsettagdepth {commands} {section}
+ \etocsettagdepth {macros} {section}
\ifnum\NoSourceCode=1
\etocsettagdepth {implementation}{none}
\else
@@ -2842,6 +2929,10 @@
\pdfbookmark[1]{Dependency graph}{DependencyGraph}
+
+% ligne allant de xinttools vers xintfrac, car il n'y a plus de dépendance
+% dans \xintXTrunc.
+
\tikzstyle{block} = [rectangle, draw,
fill=codeboxbg,
fill opacity=0.5,% fill opacity Octobre 2014
@@ -2871,21 +2962,21 @@
\node [block, below right of=frac, xshift=1cm] (cfrac) {\xintcfracname};
\node [block, right of=cfrac] (series) {\xintseriesname};
% Draw edges
- \path [line] (kernel) -- (core);
- \path [line] (kernel) -- (tools);
- \path [line] (core) -- (bnumexpr);
- \path [line] (core) -- (gcd.north);
- \path [line] (core) -- (binhex.north);
- \path [line] (core) -- (xint);
- \path [line] (xint) -- (frac);
- \path [line] (frac) -- (expr);
- \path [line] (frac) -- (series.north);
- \path [line] (frac) -- (cfrac.north);
- \path [line,dashed] (binhex.south) -- (expr);
- \path [line,dashed] (gcd.south) -- (expr);
- \path [line,dashed] (tools) -- (gcd);
- \path [line,dashed] (tools) to [out=270,in=180] (frac);
- \path [line] (tools) to [out=270,in=180] (expr);
+ \path [line,-{Stealth[length=5mm]}] (kernel) -- (core);
+ \path [line,-{Stealth[length=5mm]}] (kernel) -- (tools);
+ \path [line,-{Stealth[length=5mm]}] (core) -- (bnumexpr);
+ \path [line,-{Stealth[length=5mm]}] (core) to [out=180,in=90] (gcd.north);
+ \path [line,-{Stealth[length=5mm]}] (core) to [out=180,in=90] (binhex.north);
+ \path [line,-{Stealth[length=5mm]}] (core) -- (xint);
+ \path [line,-{Stealth[length=5mm]}] (xint) -- (frac);
+ \path [line,-{Stealth[length=5mm]}] (frac) -- (expr);
+ \path [line,-{Stealth[length=5mm]}] (frac) to [out=0,in=90] (series.north);
+ \path [line,-{Stealth[length=5mm]}] (frac) to [out=0,in=90] (cfrac.north);
+ \path [line,dashed,-{Stealth[length=5mm]}] (binhex.south) -- (expr);
+ \path [line,dashed,-{Stealth[length=5mm]}] (gcd.south) -- (expr);
+ \path [line,dashed,-{Stealth[length=5mm]}] (tools) -- (gcd);
+% \path [line,dashed,-{Stealth[length=5mm]}] (tools) to [out=270,in=180] (frac);
+ \path [line,-{Stealth[length=5mm]}] (tools) to [out=270,in=180] (expr);
\end{tikzpicture}}\bigskip
\end{figure}
@@ -2893,15 +2984,20 @@
\begin{addmargin}{2cm}
\normalfont\footnotesize Dependency graph for the
- \xintname bundle components: modules at the bottom import modules at the
+ \xintname bundle components: modules at the bottom \textbf{automatically}
+ import modules at the
top when connected by a continuous line. No module will be loaded twice,
this is managed internally under Plain as well as \LaTeX. Dashed lines
indicate a partial dependency, and to enable the corresponding
- functionalities of the lower module it is necessary for the user to issue
- the suitable |\usepackage{top_module}| in the
- preamble (or |\input top_module.sty\relax| in Plain
- \TeX). The \href{http://ctan.org/pkg/bnumexpr}{bnumexpr} package is a
- separate package (\LaTeX{} only) by the author.\par
+ functionalities of the lower module it is necessary to use
+ the suitable |\usepackage| (\LaTeX) or |\input| (Plain \TeX.)\par
+
+ Notice that since |1.2i| the macro \csbxint{XTrunc} does not cause a
+ partial dependency of \xintfracname on \xinttoolsname anymore.\par
+
+ The \href{http://ctan.org/pkg/bnumexpr}{bnumexpr} package is a
+ separate package (\LaTeX{} only) by the author which uses (by default)
+ \xintcorename as its mathematical engine.\par
\end{addmargin}
\vfill
@@ -2995,7 +3091,7 @@
\footnotetext{The maximal handled size for inputs to multiplication is
\dtt{19959} digits. This limit is observed with the current default values
- of some parameters of the tex executable (input save stack size at 5000,
+ of some parameters of the tex executable (input stack size at 5000,
maximal expansion depth at 10000). Nesting of macros will reduce it and it
is best to restrain numbers to at most \dtt{19900} digits. The output, as
naturally is the case with multiplication, may exceed the bound.}
@@ -3280,7 +3376,7 @@
which are among the extra packages included in the \xintname distribution.
The printing of the outputs will either use a custom |\printnumber| macro as
-described in the previous section, or sometimes the |\np| command from the
+described in the previous section, or sometimes the |\np| macro from the
\href{http://www.ctan.org/pkg/numprint}{numprint} package (see
\autoref{fn:np}).
@@ -3507,9 +3603,6 @@
an \hyperlink{BrentSalamin}{expandable implementation of the Brent-Salamin
algorithm} for evaluating $\pi$.
-\item There is also an
- example of an \hyperref[xintXTrunc]{interactive session}, where results
- are output to the log or to a file.
\item The functionalities of \xintexprname are illustrated with various
examples, and in locations such as in \autoref{xintdeffunc} and
@@ -3574,18 +3667,16 @@
\subsection {Changes}
The detailed cumulative change log since the initial release is in files
-|CHANGES.html| (also available on \href{http://ctan.org}{CTAN} via
-\href{http://mirrors.ctan.org/macros/generic/xint/CHANGES.html}{this link})
-and |CHANGES.pdf|.
+|CHANGES.html| (available on internet via
+\href{http://mirrors.ctan.org/macros/generic/xint/CHANGES.html}{this link}).
+You can also access it as well as |CHANGES.pdf| locally from typing |texdoc -l
+xint| on the command line.
-In a command line console, issue |texdoc --list xint| to access them.
+This is release \expandafter|\xintbndlversion| of \expandafter|\xintbndldate|.
+It principally brings across-the-board speed improvements to under the hood
+auxiliary routines, see |CHANGES.html| or |CHANGES.pdf| for more.
-It is also possible to extract them from the source |xint.dtx|: |etex
-xint.dtx| in a working repertory which will extract a |CHANGES.md| file with
-Markdown syntax. On a unix-like system you can then run |make -f Makefile.mk
-CHANGES.html| to get the |html| version (requires |pandoc|).
-
-The last major release is |1.2 (2015/10/10)|. It came with a complete rewrite
+The last major release was |1.2 (2015/10/10)|. It came with a complete rewrite
of the core arithmetic routines. The efficiency for numbers with less than
$20$ or $30$ digits was slightly compromised (for addition/subtraction) but it
got increased for bigger numbers. For multiplication and division the gains were
@@ -3595,8 +3686,7 @@
Among subsequent evolution, we mention here some changes with |1.2f
(2016/03/12)| regarding floating point numbers:
-
-\begin{enumerate}[noitemsep]
+\begin{enumerate}[nosep]
\item functions |factorial|, |binomial|, |pfactorial|.
\item more precise discussion of floating point issues in
\autoref{ssec:floatingpoint}, but the coverage by
@@ -3612,12 +3702,13 @@
\end{enumerate}
+
\section{The syntax of \xintexprname expressions}
\label{sec:xintexprsyntax}
\localtableofcontents
-\subsection{Infix and other operators and their precedence levels}
+\subsection{Precedence levels}
% \ctexttt is a remnant of 1.09n manual, don't have time to get rid of it now.
\newcommand\ctexttt [1]{\begingroup\color[named]{DarkOrchid}%\bfseries
#1\endgroup}
@@ -3624,14 +3715,34 @@
We go through the various syntax elements from highest to lowest precedence.
+Strictly speaking we should speak of precedence only for operators (binary or
+postfix unary).
-\begin{itemize}[parsep=0pt, labelwidth=\leftmarginii,
- itemindent=0pt, listparindent=\leftmarginiii,
- leftmargin=\leftmarginii]
-\item Functions share the highest precedence.
+Functions and variables may arise only when the parser expect to start
+building a number (but see the section
+\hyperref[ssec:tacit multiplication]{Tacit multiplication} next about what
+happens when the parser has \emph{already started} building a number.) We
+approximately describe the situation as saying they have highest precedence,
+because they put the parser in a state of immediate attention. When the name
+is terminated (hopefully by an opening parenthesis -- which may arise from
+expansion -- in the case of a function)
+the parser will check if the name is the one of a function or of a variable.
+Note: there may be some evolution in future, perhaps to distinguish some of
+the constructs which currently share the same precedence (e.g. there are many
+things at the same level \textbf{3}).
-\item \def\MicroFont{\color[named]{DarkOrchid}\ttfamily}The
+In case of equal precedence, the general rule is left-associativity (i.e.
+earlier encountered operators are executed first).
+
+\begin{description}[parsep=0pt,align=left,itemindent=0pt,
+ leftmargin=\leftmarginii, labelwidth=\leftmarginii, labelsep=0pt,
+ labelindent=0pt, listparindent=\leftmarginiii]
+
+\item[$\infty$] Functions and variables are all at the same highest
+ precedence.
+
+\item[$\infty$]\def\MicroFont{\color[named]{DarkOrchid}\ttfamily}The
|.| as decimal mark; the number scanner treats it as an inherent,
optional and unique component of a being formed number. One can do
things such as
@@ -3640,16 +3751,17 @@
%
which is |0^2+2^0| and produces \dtt{\xinttheexpr 0.^2+2^.0\relax}.
- However a single dot |"."| as in |\xinttheexpr .^2\relax| is now illegal
- input.\IMPORTANT
+ Since release |1.2|\IMPORTANT\ an isolated decimal mark |"."| such as in
+ |\xinttheexpr .^2\relax| is illegal input.\footnote{A sole decimal mark is
+ still valid as argument to macros from package \xintfracname.}
-\item The |e| and |E| for scientific notation. They are parsed
+\item[$\infty$] The |e| and |E| for scientific notation. They are parsed
like the decimal mark is.
\begingroup
\restoreMicroFont |1e3^2| is \dtt{\xinttheexpr 1e3^2\relax}
\endgroup
-\item The |"| for hexadecimal numbers: it is treated with highest
+\item[$\infty$] The |"| for hexadecimal numbers: it is treated with highest
priority, allowed only at locations where the parser expects to start
forming a numeric operand, once encountered it triggers the
hexadecimal scanner which looks for successive hexadecimal digits (as
@@ -3665,8 +3777,11 @@
\restoreMicroFont |"A*"A^"A| is \dtt{\xinttheexpr "A*"A^"A\relax}.
\endgroup
-\item The postfix operators \ctexttt{!} and the branching conditionals \ctexttt{?, ??}.
- \begin{description}
+\item[10] The postfix operators \ctexttt{!} and the branching conditionals \ctexttt{?, ??}.
+ \begin{description}[parsep=0pt,align=left,itemindent=0pt,
+ leftmargin=\leftmarginii, labelwidth=\leftmarginii, labelsep=0pt,
+ labelindent=0pt, listparindent=\leftmarginiii]
+
\item[{\color[named]{DarkOrchid}!}] computes the factorial of an integer.
\item[{\color[named]{DarkOrchid}?}] is used as |(cond)?{yes}{no}|. It
@@ -3692,7 +3807,7 @@
Prior to |1.2h|, inputs such as |(cond)?{?(x)}{bar}| were misinterpreted
as involving the |??| operator and the work-around was to write |(cond)?{
- ?(x)}{bar}|, with an extra space. This is unneeded now.\NewWith{1.2h}
+ ?(x)}{bar}|, with an extra space. This is unneeded now.\CHANGED{1.2h}
Also |(cond)?{\foo}{bar}| led to premature expansion of |\foo| and gain
the fix was to insert an extra space. This has been corrected. Note though
that the input |(cond)?{?}{!}(x)| will still confuse the parser but
@@ -3713,7 +3828,7 @@
%
\end{description}
-\item The minus sign |-| as prefix unary operator inherits the precedence of
+\item[=] The minus sign |-| as prefix unary operator inherits the precedence of
the infix operator it follows. With things such as |5+------2*3|, the
\xintexprname parsers don't try to be efficient: once |2*3| is evaluated the
opposite function will be applied the necessary number of times. On the other
@@ -3720,7 +3835,7 @@
hand the plus sign |+| as prefix unary operator as in, for example
|5-++++++2*3|, is immediately gobbled.
-\item The power operator |^|, or |**|. It is left associative:
+\item[9] The power operator |^|, or |**|. It is left associative:
{\restoreMicroFont|\xinttheiexpr 2^2^3\relax|} evaluates to \xinttheiexpr
2^2^3\relax, not \xinttheiexpr 2^(2^3)\relax. Note that if the float
precision is too low, iterated powers within |\xintfloatexpr..\relax| may
@@ -3744,7 +3859,9 @@
%
\endgroup
-\item Multiplication and division \raisebox{-.3\height}{|*|}, |/|. The
+ Also at this level the list operators |^[|, |**[|, |]^|, and |]**|.
+
+\item[7] Multiplication and division \raisebox{-.3\height}{|*|}, |/|. The
division is left associative, too:
%
\begingroup\restoreMicroFont
@@ -3753,23 +3870,22 @@
not \xinttheiexpr 100/(50/2)\relax.
%
\endgroup
- Inside \csbxint{iiexpr}, |/| does \emph{rounded} division.
+ Inside \csbxint{iiexpr}, |/| does \emph{rounded} division. Tacit
+ multiplication (see \autoref{ssec:tacit multiplication}) has an elevated
+ precedence level \textbf{8}.
-\item Truncated division |//| and modulo |/:| (equivalently |'mod'|, quotes
- mandatory) are at the same level of priority than multiplication and
- division, thus left-associative with them. Apply parentheses for
- disambiguation.
+ Also at this level the list operators |*[|, |/[|, |]*| and |]/|.
+
+ Also the truncated division |//| and modulo |/:| (equivalently |'mod'|,
+ quotes mandatory). Operators all at the same level of precedence are
+ left-associative. Apply parentheses for disambiguation.
\begin{everbatim*}
\xinttheexpr 100000//13, 100000/:13, 100000 'mod' 13, trunc(100000/13,10),
trunc(100000/:13/13,10)\relax
\end{everbatim*}
-\item The list itemwise operators |*[|, |/[|, |^[|, |**[|, |]*|, |]/|, |]^|,
- |]**| are at the same precedence level as, respectively, |*| and |/| or |^|
- and |**|.
-
-\item Addition and subtraction |+|, |-|. Again, |-| is left
- associative:
+\item[6] Addition and subtraction |+|, |-|. According to the rule above, |-|
+ is left associative:
%
\begingroup\restoreMicroFont
%
@@ -3778,32 +3894,40 @@
%
\endgroup
-\item The list itemwise operators |+[|, |-[|, |]+|, |]-|, are at
- the same precedence level as |+| and |-|,
+ Also the list operators |+[|, |-[|, |]+|, |]-| are at this precedence level.
-\item Comparison operators |<|, |>|, |=| (same as |==|), |<=|, |>=|, |!=| all
+\item[5] Comparison operators |<|, |>|, |=| (same as |==|), |<=|, |>=|, |!=| all
at the same level of precedence, use parentheses for disambiguation.
-\item Conjunction (logical and): |&&| or equivalently
+\item[4] Conjunction (logical and): |&&| or equivalently
|'and'| (quotes mandatory).
-\item Inclusive disjunction (logical or): \verb+||+
+\item[3] Inclusive disjunction (logical or): \verb+||+
and equivalently |'or'| (quotes mandatory).
-\item XOR: |'xor'| with mandatory quotes is at the same level of precedence
- as \verb+||+.
+ Also the |'xor'| operator (quotes mandatory) is at this level.
-\item The list generation operators |..|, |..[|, |]..| are at the same
- (low) precedence level as the \verb+||+ operator of logical disjunction.
+ Also the list generation operators |..|, |..[|, |]..| are at this level.
-\item The comma:
-\restoreMicroFont with |\xinttheexpr 2^3,3^4,5^6\relax|
-one obtains as output \xinttheexpr 2^3,3^4,5^6\relax{}.
+ Also the |:| for Python slicing of lists.
-\item The parentheses. The list outer brackets |[|, |]| share the same
+\item[2] The comma: \restoreMicroFont with |\xinttheexpr 2^3,3^4,5^6\relax|
+ one obtains as output \xinttheexpr 2^3,3^4,5^6\relax{}.\footnote{The comma
+ is really like a binary operator, which may be called ``join''. It has
+ lowest precedence of all (apart the parentheses) because when it is
+ encountered all postponed operations are executed in order to finalize its
+ \emph{first} operand; only a new comma or a closing parenthesis or the end
+ of the expression will finalize its \emph{second} operand.}
+
+\item[1] The parentheses. The list outer brackets |[|, |]| share the same
functional precedence as parentheses. The semi-colon |;| in an |iter| or
- |rseq| has the same precedence as a closing parenthesis.
-\end{itemize}
+ |rseq| has the same precedence as a closing parenthesis.\footnote{It is not
+ apt to describle the opening parenthesis as an operator, but the closing
+ parenthesis is more closely like a postfix unary operator. It has lowest
+ precedence because when it is encountered all postponed operations are
+ executed to finalize its operand. The start of this operand was decided by
+ the opening parenthesis.}
+\end{description}
\subsection{Tacit multiplication}
@@ -3842,6 +3966,7 @@
\begin{everbatim*}
\xinttheexpr (1+2)/(3+4)(5+6), 2/x(10), 2/10x, 3/y\xintiiexpr 5+6\relax, 1/x(y)\relax
\end{everbatim*}
+\end{framed}
Note that |y\xinttheiiexpr 5+6\relax| would have tried to use a variable
with name |y11| rather than doing |y*11|: tacit multiplication works only
@@ -3848,12 +3973,12 @@
in front of sub-\csbxint{expr}essions, not in front of
\csbxint{theexpr}essions which are unlocked into explicit digits.
- These examples above redeclared the |x| and |y| which thus can not be used as
- dummy variables anymore (but see \csbxint{unassignvar}); as this happened
- inside a \LaTeX{} environment (for the frame), they will have
- recovered their meanings after the frame. In the meantime we use letter
- |z| for the next example. Here is an expression whose meaning is
- completely modified by the ``tie more'' property of tacit multiplication:\IMPORTANT
+
+Here is an expression whose meaning is
+ completely modified by the ``tie more'' property of tacit multiplication:
+
+%\IMPORTANT
+
\begin{everbatim}
\xintdeffunc e(z):=1+z(1+z/2(1+z/3(1+z/4)));
\end{everbatim}
@@ -3872,10 +3997,8 @@
not} apply in front of digits: |(1+1)5| is not legal. But
|subs((1+1)x,x=5)| is, because in that case a variable is following the
closing parenthesis.
-\end{framed}
-
\subsection{Predefined functions}
Functions are at the same top level of priority. All functions even
@@ -3900,7 +4023,7 @@
closing parenthesis which thus must be explicit, not arising from
expansion.
- The same holds for |qint|, |qfrac|, |qfloat|.\NewWith{1.2}
+ The same holds for |qint|, |qfrac|, |qfloat|.\NewWithf{1.2}
\end{snugframed}
\begin{description}[parsep=0pt,% pas le temps de regarder labelwidth=\leftmarginiii,
@@ -3957,8 +4080,8 @@
|\xintfloatexpr| this is the floating point square root, and there is an
optional second argument for the precision.
\item[sqrtr] in |\xintiiexpr| only, rounded square root.
- \item[factorial] factorial function, same as previously
- available post-fix |!| operator. When used in |\xintexpr| or
+ \item[factorial] factorial function (like the
+ post-fix |!| operator.) When used in |\xintexpr| or
|\xintfloatexpr| there is an optional second argument. See discussion later.
\item[?] |?(x)| is the truth value, $1$ if non zero, $0$ if zero. Must use parentheses.
\item[!] |!(x)| is logical not, $0$ if non zero, $1$ if zero. Must use parentheses.
@@ -4104,9 +4227,10 @@
\begin{everbatim*}
\xinttheexpr seq(pfactorial(20, i), i=20..30)\relax
\end{everbatim*}
-The arguments must (expand to) short integers. See \autoref{xintiiPFactorial}
-for the behaviour if the arguments are negative.\CHANGED{1.2h}
+The arguments must (expand to) short integers. See \autoref{xintiiPFactorial}\CHANGED{1.2h}
+for the behaviour if the arguments are negative.
+
\end{description}
\item[the if conditional (twofold way)]
@@ -4167,30 +4291,31 @@
\subsection{Constructs with dummy variables}
\label{ssec:dummies}
-% \begin{snugframed}
- The ``functions'' \xintFor #1 in {add, mul, seq, subs, rseq, iter, rrseq,
- iterr} \do {\ctexttt{#1}\xintifForLast{}{, }} use some delimited
- macros to fetch the |,<letter>| part, checking the correct balance of
- parentheses, and allowing nesting. The |<letter>| (lowercase or
- uppercase) will be followed by a |=| sign and then a comma separated
- list of values or a list expression such as |a..b|, or both, which will
- be treated in the normal manner to provide the values which will be in
- succession assigned to the |<letter>|. This |<letter>| must not have
- been assigned a value before via \csa{xintdefvar}.
+The ``functions'' \xintFor #1 in {add, mul, seq, subs, rseq, iter, rrseq,
+ iterr} \do {\ctexttt{#1}\xintifForLast{}{, }} use delimited macros to
+identify the |,<letter>=| part.\footnote{In the current implementation any
+ token can be used rather than a |=|. What is looked for is a comma followed
+ by two tokens, the first one will be the |<letter>|.} This is done in a way
+allowing nesting via correctly balanced parentheses. The |<letter>| must not
+have been assigned a value before via \csa{xintdefvar}.
+
+This |,<letter>=| must be visible when the parser has finished absorbing the
+function name and the opening parenthesis. For |rseq|, |iter|, |rrseq| and
+|iterr| this is delayed to after the parser has assimilated a starting part
+delimited by a semi-colon; this mandatory segment may be generated entirely by
+expansion and the |,<letter>=| may appear during this expansion.
- The functions |rseq|, |iter|, |rrseq| and |iterr| have an additional
- mandatory initial comma separated list which is separated by a
- semi-colon from the expression to evaluate iteratively. This portion up
- to and including the semi-colon may arise entirely from expansion
- (contrarily to the |,<letter>=| part discussed above).
+After |,<letter>=|, the expansion and parsing will generate a list of values
+(for example from an |a..b| specification, there may be multiple ones
+themselves separated by commas). After this step is complete the parser will
+know the values which will be assigned to |<letter>|, with |i++| syntax
+offering a special variant.
- |seq|, |rseq|, |iter|, |rrseq|, |iterr| but
- not |add|, |mul|, |subs| admit the |omit|, |abort|, and |break(..)|
- keywords, possibly but not necessarily in combination with a potentially
- infinite list generated by a |n++| expression.
- They may be nested.
-% \end{snugframed}
+|seq|, |rseq|, |iter|, |rrseq|, |iterr| but not |add|, |mul|, |subs| admit the
+|omit|, |abort|, and |break(..)| keywords. In the case of a potentially
+infinite list generated by a |<letter>++| expression, use of |abort| or
+|break()| is mandatory, naturally.
@@ -4531,7 +4656,7 @@
\end{everbatim*}
The mechanism for functions is identical with the one underlying the
-\csbxint{NewExpr} command. A function once declared is a first class citizen,
+\csbxint{NewExpr} macro. A function once declared is a first class citizen,
its expression is entirely parsed and converted into a big nested \fexpan
dable macro. When used its action is via this defined macro. For example
\begin{everbatim*}
@@ -4550,7 +4675,7 @@
}{1}}{#1}}{2}}{1}}{#1}}{1}
\end{everbatim}
-This has the same limitations as the \csbxint{NewExpr} command. The main one
+This has the same limitations as the \csbxint{NewExpr} macro. The main one
is that dummy variables are usable only to the extent that their values are
numerical. For example |\xintdeffunc f(x):=add(i^2,i=1..x);| is not possible.
See \autoref{sssec:limitations} and the next subsection.
@@ -4634,8 +4759,6 @@
\xinttheexpr add(f*(f+f), f= 1..10)\relax % f is used as variable, not as a function.
\end{everbatim*}
-
-
\subsection{\csbh{xintNewFunction}}
\label{xintNewFunction}
@@ -4651,6 +4774,10 @@
\xinttheexpr seq(foo(0, 3, j), j= 1..10)\relax
\end{everbatim*}
+A notable aspect is that this syntax allows to make recursive definitions,
+contrarily (currently) to \csbxint{deffunc}. See \autoref{ssec:PrimesIV} for
+an example.
+
However this construct is only syntactic sugar to benefit from functional
notation. Each time the function |foo| will be encountered the corresponding
expression will be inserted as a sub-expression (of the same type as the
@@ -4665,10 +4792,10 @@
\end{everbatim}
This is thus very different from a function defined via |\xintdeffunc| which
-immediately expands to some (possibly very complicated) nesting of various
-macro calls, short-circuiting the parser. But (see \autoref{sssec:limitations})
-it is not currently possible to define a |foo| function like the one above via
-|\xintdeffunc|.
+expands to some (possibly very complicated) nesting of various macro calls,
+which were determined at the time of the function definition. But (see
+\autoref{sssec:limitations}) it is not currently possible to define a |foo|
+function like the one above via |\xintdeffunc|.
One can declare a function |foo| with |[0]| arguments but it must be used
as |foo(nil)|, as |foo()| with no argument would generate an error.
@@ -4865,12 +4992,245 @@
\item The \csbxint{the} prefix should not be applied to a sub
|\xintiiexpr|ession, as this forces the parsers to gather again one by one
the corresponding digits.
-\item Also worth mentioning is the fact that |\numexpr -(1)\relax| is illegal.
+\item |\numexpr -(1)\relax| is illegal.
But |\xintiiexpr -(1)\relax| is perfectly legal and gives the expected
result (what else ?).
+\item |\numexpr 2\cnta\relax| is illegal, with |\cnta| a |\count|. But
+ |\xintiiexpr 2\cnta\relax| is perfectly legal and will do the tacit
+ multiplication.
\end{itemize}
+\subsection{Chaining expressions for expandable algorithmics}
+\label{ssec:fibonacci}
+We will see in this section how to chain |\xintexpr|-essions with
+|\expandafter|'s, like it is possible with |\numexpr|. For this it is
+convenient to use |\romannumeral0\xinteval| which is the once-expanded form of
+|\xintexpr|, as we can then chain using only one |\expandafter| each time.
+
+For example, here is the code employed
+on the title page to compute (expandably, of course!) the 1250th Fibonacci
+number:
+
+\begin{everbatim*}
+\catcode`_ 11
+\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 1\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval 0\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 are omitted from the next macros, tacit multiplications
+\def\Fibonacci_b_i #1#2#3{\expandafter\Fibonacci_a\expandafter
+ {\the\numexpr #1/2\expandafter}\expandafter
+ {\romannumeral0\xintiieval sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval (2#2-#3)#3\relax}%
+}% end of Fibonacci_b_i
+\def\Fibonacci_b_ii #1#2#3#4#5{\expandafter\Fibonacci_a\expandafter
+ {\the\numexpr (#1-1)/2\expandafter}\expandafter
+ {\romannumeral0\xintiieval sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval (2#2-#3)#3\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval #2#4+#3#5\expandafter\relax\expandafter}\expandafter
+ {\romannumeral0\xintiieval #2#5+#3(#4-#5)\relax}%
+}% end of Fibonacci_b_ii
+% code as used on title page:
+%\def\Fibonacci_end_i #1#2#3#4#5{\xintthe#5}
+%\def\Fibonacci_end_ii #1#2#3#4#5{\xinttheiiexpr #2#5+#3(#4-#5)\relax}
+% new definitions:
+\def\Fibonacci_end_i #1#2#3#4#5{{#4}{#5}}% {F(N+1)}{F(N)} in \xintexpr format
+\def\Fibonacci_end_ii #1#2#3#4#5%
+ {\expandafter
+ {\romannumeral0\xintiieval #2#4+#3#5\expandafter\relax
+ \expandafter}\expandafter
+ {\romannumeral0\xintiieval #2#5+#3(#4-#5)\relax}}% idem.
+% \FibonacciN returns F(N) (in encapsulated format: needs \xintthe for printing)
+\def\FibonacciN {\expandafter\xint_secondoftwo\romannumeral-`0\Fibonacci }%
+\catcode`_ 8
+\end{everbatim*}
+
+
+The macro |\Fibonacci| produces not one specific value |F(N)| but a pair of
+successive values |{F(N)}{F(N+1)}| which can then serve as starting point of
+another routine devoted to compute a whole sequence |F(N), F(N+1),
+F(N+2),....|. Each of |F(N)| and |F(N+1)| is kept in the encapsulated internal
+\xintexprname format.
+
+|\FibonacciN| produces the single |F(N)|. It also keeps it in the private
+format; thus printing it will need the |\xintthe| prefix.
+
+\begingroup\footnotesize\sffamily\baselineskip 10pt
+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}).
+%
+\begin{everbatim}
+\def\Fibo #1.{\xintthe\FibonacciN {#1}}%
+\message{\xintiloop [0+1] \expandafter\Fibo\xintiloopindex.,
+ \ifnum\xintiloopindex<49 \repeat \xintthe\FibonacciN{50}.}
+\end{everbatim}
+\endgroup
+
+The way we use |\expandafter|'s to chain successive |\xintiieval| evaluations
+is exactly analogous to what is possible with |\numexpr|. The various
+|\romannumeral0\xintiieval| could very well all have been |\xintiiexpr|'s but
+then we would have needed |\expandafter\expandafter\expandafter| each
+time.
+
+\begin{framed}
+ There is a difference though: |\numexpr| does \emph{NOT} expand inside an
+ |\edef|, and to force its expansion we must prefix it with |\the| or
+ |\number| or |\romannumeral| or another |\numexpr| which is itself prefixed,
+ etc\dots.
+
+ But |\xintexpr|, |\xintiexpr|, ..., expand fully in an |\edef|, with the
+ completely expanded
+ result encapsulated in a private format.
+
+ Using |\xintthe| as prefix is necessary to print the result (like |\the| or
+ |\number| in the case of |\numexpr|), but it is not necessary to get the
+ computation done (contrarily to the situation with |\numexpr|).
+\end{framed}
+
+
+Our |\Fibonacci| expands completely under \fexpan sion, so we can use
+\hyperref[fdef]{\ttfamily\char92fdef} rather than |\edef| in a situation such
+as
+%
+\leftedline {|\fdef \X {\FibonacciN {100}}|}
+%
+but it is usually about as efficient to employ |\edef|. And if we want
+%
+\leftedline{|\edef \Y {(\FibonacciN{100},\FibonacciN{200})}|,}
+%
+then |\edef| is necessary.
+
+Allright, so let's now give the code to generate |{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
+\everb|@
+\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
+|
+\endgroup
+
+This |\FibonacciSeq| macro is
+completely expandable but it is not \fexpan dable.
+
+This is not a problem in the next example which uses \csbxint{For*} as the
+latter applies repeatedly full expansion to what comes next each time it
+fetches an item from its list argument. Thus \csbxint{For*} still manages to
+generate the list via iterated full expansion.
+
+
+\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 &
+ \xintiRem{\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 &
+ \xintiRem{\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 &
+ \xintiRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{index}\cr }}%
+}}%
+%
+\centeredline{Some Fibonacci numbers together with their residues modulo
+ |F(30)|\dtt{=\xintthe\Fibxxx}}
+\end{figure*}
+
+\begingroup\footnotesize\baselineskip10pt
+\everb|@
+\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 &
+ \xintiRem{\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 &
+ \xintiRem{\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 &
+ \xintiRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{index}\cr }}%
+}%
+|
+\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 |;-)|.
+
\section{The \xintname bundle}
@@ -4915,8 +5275,8 @@
possibilities, when available) on arbitrarily big integers, beyond the \TeX{}
bound.%
%
-\footnote{This package does not provide a parser of expressions on big
- integers like \csbxint{iiexpr}|...\relax|. One can use package
+\footnote{The package \href{http://www.ctan.org/pkg/bigintcalc}{bigintcalc}
+ does not provide a parser of expressions. One can use package
\href{http://ctan.org/pkg/bnumexpr}{bnumexpr} to associate the |bigintcalc|
macros with an expression parser.}
%
@@ -5056,6 +5416,7 @@
other hand |\xintFloat [50000]{1}| does work (slowly..), but there isn't much
one can do afterwards with it...\par}
+
More reasonably, working with significands of $24$, $32$, $48$, $64$, or even
$80$ digits is well within the reach of the package.
@@ -5255,81 +5616,6 @@
\subsection{Expansion matters}
-\subsubsection{Generalities about expandability in \TeX}
-
-\TeX{} is a macro language, and ``expansion'' is thus a crucial aspect, which
-will be quite unfamiliar to most everyone with standard knowledge of the usual
-programming languages. The whole of \xintname is about \emph{expandably}
-implementing arithmetic computations. What does that mean ?
-
-\LaTeX{} users are familiar with counters, and its command |\setcounter|. The
-first argument is the name of the counter, the second argument is a number (in
-the TeX sense of being acceptable in |\count| assignments), or more generally
-something which will expand to a number. For example:
-\begin{everbatim}
-\newcounter{Foo}
-\newcommand{\Bar}{17}
-\setcounter{Foo}{\Bar}
-\addtocounter{Foo}{\Bar}
-\arabic{Foo}
-\end{everbatim}
-works and produces |34|. But imagine we have some macro |\Double| which
-accepts a numerical string of digits, and outputs its double as a string of
-digits (or perhaps some count with this value). Can we do this:
-\begin{everbatim}
-\setcounter{Foo}{\Double{\Bar}} ?
-\end{everbatim}
-The answer depends on the \emph{expandability} of |\Double|. Perhaps |\Double|
-will do a |\newcommand| internally? or perhaps it used the \TeX{} primitives
-|\advance| or |\multiply|? then it is \emph{not} expandable in this
-context where \TeX{} is seeking to do a number assignment (which is
-to what the \LaTeX{} |\setcounter| boils down in the end). This does not mean
-that expansion does not apply, but something completely different: expansion
-produces ``tokens'' which \TeX{} does not accept in such a context of
-assigning a value to a |\count|.
-
-Some users of \LaTeX{} know about the \TeX{} primitive |\edef|. Another way to
-test expandability of |\Double| is to try |\edef\test{\Double{\Bar}}|: the
-criterion is that |\Double| will expand, do its stuff, and clean up everything
-and only leave the result of its action on |\Bar|. Thus typically if |\Double|
-does a |\newcommand| (or rather a |\def|), then this will not be the case. The
-|\newcommand| or |\def| simply does \emph{not} get executed inside an |\edef|!
-This is not completely equivalent to the earlier context, because when \TeX{}
-seeks to build a number it has additional special constructs, like |"| to
-prefix hexadecimal inputs, and thus the behavior is not exactly the same in an
-|\edef|, but I am just trying to give a gist here of what happens.
-
-The little paradox is that \TeX{} from the start always required expandability
-when doing assignments to count registers, or dimen registers, ..., but basic
-arithmetic was provided via |\advance|, |\multiply|, and |\divide| primitives
-which are \emph{not} expandable.%
-%
-\footnote{This is not to say that expandable arithmetic was not possible, it
- is possible and has been done via the recording of the carries of digit
- arithmetic in many macros and usage of some tools provided by the \TeX{}
- language, but this is very cumbersome and slow (even in the \TeX{}
- context).}
-%
-For example, something like
-\begin{everbatim}
-\setcounter{Foo}{\count0=\Bar\relax \multiply\count0 by 2
- \advance\count0 by 15 \the\count0 }
-\end{everbatim}
-although not creating errors produces only non-sense.
-
-Since 1999, \eTeX{} has extended \TeX{} with expandable arithmetic. Thus
-nowadays%
-%
-\footnote{I do not discuss here the \href{http://www.ctan.org/pkg/calc}{calc}
- package. It does surgery inside |\setcounter| to make
- |\setcounter{Foo}{2*\Bar+15}| possible, but its parser is not expandable and
- is functional only inside macros |calc| knows about.} one would simply do
-\begin{everbatim}
-\setcounter{Foo}{\numexpr 2*\Bar+15\relax}
-\end{everbatim}
-But we can not do, for example, |98765*67890| inside |\numexpr|, because the
-result \xintiiMul{98765}{67890} exceeds the \TeX{} bound of \number"7FFFFFFF.
-
\subsubsection{Full expansion of the first token}
\label{ssec:expansions}
@@ -5337,22 +5623,15 @@
arbitrarily large numbers. Each basic operation is thus done via a macro:
\csbxint{iiAdd}, \csbxint{iiSub}, \csbxint{iiMul}, \csbxint{iiDivision}. In
order to handle more complex operations, it must be possible to nest these
-macros.%
+macros.
%
-\footnote{Actually this would not be really needed if the goal was only
-to implement the parsing of expressions: as the expression is scanned from
-left to right, there is only at any given time one operation to be done, hence
-it is not really absolutely mandatory for the macros implementing the basic
-operations to be nestable. This is however the path followed initially by
-\xintname.}
-%
-But we saw already that an expandable macro can not do a |\newcommand| or
-|\def|, and it can't do either an |\edef|. But the macro must expand its
-arguments to find the digits it is supposed to manipulate. \TeX{} provides a
-tool to do the job of (expandable !) repeated expansion of the first token
-found until hitting something non expandable, such as a digit, a |\def| token,
-a brace, a |\count| token, etc... is found. A space token also will stop the
-expansion (and be swallowed, contrarily to the non-expandable tokens).
+An expandable macro can not execute a |\def| or an |\edef|. But the macro must
+expand its arguments to find the digits it is supposed to manipulate. \TeX{}
+provides a tool to do the job of (expandable !) repeated expansion of the
+first token found until hitting something non expandable, such as a digit, a
+|\def| token, a brace, a |\count| token, etc... is found. A space token also
+will stop the expansion (and be swallowed, contrarily to the non-expandable
+tokens).
By convention in this manual \fexpan sion (``full expansion'' or ``full first
expansion'') will be this \TeX{} process of expanding repeatedly the first
@@ -5478,7 +5757,7 @@
arbitrarily the package macros, and the new ones will be completely expandable
and usable one within the other.
-Since release |1.07| the \csbxint{NewExpr} command automatizes the creation of
+Since release |1.07| the \csbxint{NewExpr} macro automatizes the creation of
such expandable macros:
%
\leftedline{|\xintNewExpr\AplusBC[3]{#1+#2*#3}|}
@@ -5536,8 +5815,7 @@
\subsection{No declaration of variables for macros}
- There is no notion of a \emph{declaration of a variable}, which would be
- needed to use the arithmetic macros.%
+ There is no notion of a \emph{declaration of a variable}.
To do a computation and assign its result to some macro |\z|, the user will employ the |\def|, |\edef|, or |\newcommand| (in \LaTeX)
as usual, keeping in mind that two expansion steps are needed, thus |\edef|
@@ -5758,7 +6036,7 @@
\begin{framed}
The fraction handling macros from \xintfracname are called \csbxint{Add},
\csbxint{Sub}, \csbxint{Mul}, etc... they are \emph{not} defined in the
- absence of \xintfracname.\MyMarginNote[\kern\dimexpr\FrameSep+\FrameRule\relax]{Changed!}
+ absence of \xintfracname.
They produce on output a fractional number |f=A/B[n]| (which stands for
|(A/B)|$\times$|10^n|) where |A| and |B| are integers, with |B| positive,
@@ -5774,7 +6052,7 @@
\begin{itemize}
\item A macro \csbxint{Frac} is provided for the typesetting (math-mode
- only) of such a `raw' output. The command \csbxint{Frac} is not accepted as
+ only) of such a `raw' output. The macro \csbxint{Frac} is not accepted as
input to the package macros, it is for typesetting only (in math mode).
\item \csbxint{Raw} prints the fraction directly as its internal
@@ -5914,7 +6192,7 @@
components are lost.
For \LaTeX{} users: a length is a \meta{glue} variable, prefixing a
-length command defined by \csa{newlength} with \csa{number} will thus discard
+length macro 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.
@@ -6064,8 +6342,16 @@
{\xintFtoCCv{543564351/508000000}}\do {\dtt{\printnumber{#1}}\xintifForLast{.}{, }} We do
recover the $1238/1157$ therein!
+Note: here is how \TeX\ converts |abc.xyz...<unit>|. First the decimal is
+\emph{rounded} to the nearest integral multiple of |1/65536|, say |X/65536|.
+The |<unit>| is associated to a ratio |N/D|, which represents |<unit>/pt|. For
+the Didot point the ratio is indeed |1238/1157|. \TeX\ \emph{truncates} the
+fraction |XN/D| to an integer |M|. The dimension is represented by |M sp|. For
+additional details see
+\url{http://tex.stackexchange.com/questions/338297/why-pdf-file-cannot-be-reproduced/338510#338510}.
+
\subsection{\csh{ifcase}, \csh{ifnum}, ... constructs}\label{sec:ifcase}
When using things such as |\ifcase \xintSgn{\A}| one has to make sure to leave
@@ -6107,75 +6393,89 @@
\footnote{\url{http://www.ctan.org/pkg/etoolbox}}
package.
-\subsection{Expandable implementations of mathematical algorithms}
+\subsection{When expandability is too much}
-It is possible to chain |\xintexpr|-essions with |\expandafter|'s, like experts
-do with |\numexpr| to compute multiple things at once. See
-\autoref{ssec:fibonacci} for an example devoted to Fibonacci numbers (this
-section provides the code which was used on the title page for the
-\dtt{$F(1250)$} evaluation.) Notice that the $47$th Fibonacci number is
-\dtt{\Fibonacci {47}} thus already too big for \TeX{} and \eTeX{}.
+Let's use the macros of \autoref{ssec:fibonacci} related to Fibonacci numbers.
+Notice that the $47$th Fibonacci number is \dtt{\xintthe\FibonacciN {47}} thus
+already too big for \TeX{} and \eTeX{}.
-The |\Fibonacci| macro found in \autoref{ssec:fibonacci} is completely
-expandable, (it is even \fexpan dable in the sense previously explained) hence
-can be used for example within |\message| to write to the log and terminal.
+The |\FibonacciN| macro found in \autoref{ssec:fibonacci} is completely
+expandable, it is even \fexpan dable. We need a wrapper with |\xintthe|
+prefix
+\begin{everbatim*}
+\def\theFibonacciN{\xintthe\FibonacciN}
+\end{everbatim*}
+to print in the document or to use within |\message| (or \LaTeX\ |typeout|) to
+write to the log and terminal.
+
\begingroup
- \def\A {1859}\def\B {1573}
- \edef\C {\xintiiGCD\A\B}
- \edef\X {\Fibonacci\A}
- \edef\Y {\Fibonacci\B}
+ \def\A {1859} \def\B {1573}
+ \edef\X {\theFibonacciN\A} \edef\Y {\theFibonacciN\B}
+ \edef\GCDAB {\xintiiGCD\A\B}\edef\Z {\theFibonacciN\GCDAB}
+ \edef\GCDXY{\xintiiGCD\X\Y}
+ The |\xintthe| prefix also allows its use it as argument to the \xintname
+ macros: for example if we are interested in knowing how many digits
+ $F(1250)$ has, it suffices to issue |\xintLen {\theFibonacciN {1250}}|
+ (which expands to \dtt{\xintLen {\theFibonacciN {1250}}}). Or if we want to
+ check the formula $gcd(F(1859),F(1573))=F(gcd(1859,1573))=F(143)$, we only
+ need%
%
-Also, one can thus use it as argument to the \xintname macros: for example if
-we are interested in knowing how many digits $F(1250)$ has, it suffices to
-issue |\xintLen {\Fibonacci {1250}}| (which expands to \dtt{\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{xintiiGCD} macro is provided by the \xintgcdname package.}
%
-\leftedline{|$\xintiiGCD{\Fibonacci{1859}}{\Fibonacci{1573}}=\Fibonacci{\xintiiGCD{1859}{1573}}$|}
+\begin{everbatim}
+$\xintiiGCD{\theFibonacciN{1859}}{\theFibonacciN{1573}}=%
+ \theFibonacciN{\xintiiGCD{1859}{1573}}$
+\end{everbatim}
%
-which outputs:
+which produces:
%
-\leftedline{$\dtt{\xintiiGCD{\X}{\Y}}=\dtt{\Fibonacci{\C}}$}
+\leftedline{$\dtt{\xintiiGCD{\X}{\Y}}=\dtt{\theFibonacciN{\GCDAB}}$}
-The |\Fibonacci| macro expanded its |\xintiiGCD{1859}{1573}| argument via the
+The |\theFibonacciN| macro expanded its |\xintiiGCD{1859}{1573}| argument via the
services of |\numexpr|: this step allows only things obeying the \TeX{} bound,
naturally! (but \dtt{F(\xintiiPow2{31}}) would be rather big anyhow...).
-In practice, whenever one typesets things, one has left the expansion only
-contexts; hence there is no objection to, on the contrary it is recommended,
-assign the result of earlier computations to macros via an |\edef| (or an
-|\fdef|, see \ref{fdef}), for later use. The above could thus be coded
+This is very convenient but of course it repeats the complete evaluation each
+time it is done. In practice, it is often useful to store the result of such
+evaluations in macros. Any |\edef| will break expandability, but if the goal
+is at some point to print something to the |dvi| or |pdf| output, and not only
+to the |log| file, then expandability has to be broken one day or another!
+
+Hence, in practice, if we want to print in the document some computation
+results, we can proceed like this and avoid having to repeat identical
+evaluations:
\begin{everbatim}
\begingroup
- \def\A {1859} \def\B {1573} \edef\C {\xintiiGCD\A\B}
- \edef\X {\Fibonacci\A} \edef\Y {\Fibonacci\B}
+ \def\A {1859} \def\B {1573}
+ \edef\X {\theFibonacciN\A} \edef\Y {\theFibonacciN\B}
+ \edef\GCDAB {\xintiiGCD\A\B}\edef\Z {\theFibonacciN\GCDAB}
+ \edef\GCDXY{\xintiiGCD\X\Y}
The identity $\gcd(F(\A),F(\B))=F(\gcd(\A,\B))$ can be checked via evaluation
of both sides: $\gcd(F(\A),F(\B))=\gcd(\printnumber\X,\printnumber\Y)=
-\printnumber{\xintiiGCD\X\Y} = F(\gcd(\A,\B))$.\par
- % some further computations involving \A, \B, \C, \X, \Y
+\printnumber{\GCDXY} = F(\gcd(\A,\B)) = F(\GCDAB) =\printnumber\Z$.\par
+ % some further computations involving \A, \B, \X, \Y
\endgroup % closing the group removes assignments to \A, \B, ...
-% or choose longer names less susceptible to overwriting something. Note that there
-% is no LaTeX \newecommand which would be to \edef like \newcommand is to \def
+% or choose longer names less susceptible to overwrite something.
+% Note: there is no LaTeX \newecommand which would be to \edef like \newcommand is to \def
\end{everbatim}
The identity $\gcd(F(\A),F(\B))=F(\gcd(\A,\B))$ can be checked via evaluation
-of both sides:
-$\gcd(F(\A),F(\B))=\gcd(\dtt{\printnumber\X{\normalcolor,}\printnumber\Y})=
-\dtt{\printnumber{\xintiiGCD\X\Y}} = F(\C) = F(\gcd(\A,\B))$.\par
+of both sides: $\gcd(F(\A),F(\B))=\gcd(\printnumber\X,\printnumber\Y)=
+\printnumber{\GCDXY} = F(\gcd(\A,\B)) = F(\GCDAB) =\printnumber\Z$.\par
+\endgroup
+One may legitimately ask the author: why expandability
+to such extremes, for things such as big fractions or floating point numbers
+(even continued fractions...) which anyhow can not be used directly within
+\TeX's primitives such as |\ifnum|? Why insist on a concept
+which is foreign to the vast majority of \TeX\ users and even programmers?
-\endgroup
-One may thus legitimately ask the author: why expandability to such extremes,
-for things such as big fractions or floating point numbers (even
-continued fractions...) which anyhow can not be used directly
-within \TeX's primitives such as |\ifnum|? the answer is that the author
-chose, seemingly, at some point back in his past to waste from then on his time
-on such useless things!
+I have no answer: it made definitely sense at the start of \xintname (see
+\autoref{ssec:origins}) and once started I could not stop.
+
\subsection{Possible syntax errors to avoid}
\edef\x{\xintMul {3}{5}/\xintMul{7}{9}}
@@ -6246,7 +6546,7 @@
There are now a few more if for example one attempts to use |\xintAdd| without
having loaded \xintfracname (with only \xintname loaded, only |\xintiAdd| and
-|\xintiiAdd| are legal).\MyMarginNote{Changed!}
+|\xintiiAdd| are legal) or to use deprecated macros.
\begin{multicols}{2}\parskip0pt\relax
\begin{everbatim}
\Did_you_mean_iiAbs?or_load_xintfrac
@@ -6264,10 +6564,12 @@
\Did_you_mean_iiPrd?or_load_xintfrac
\Did_you_mean_iiPrdExpr?or_load_xintfrac
\Did_you_mean_iiSumExpr?or_load_xintfrac
+\Removed!use_xintiQuo_or_xintiiQuo!
+\Removed!use_xintiRem_or_xintiiRem!
\end{everbatim}
\end{multicols}
-Don't forget to set |\errorcontextlines| to at least |2| to get from \LaTeX\
+One should set |\errorcontextlines| to at least |2| to get from \LaTeX\
more meaningful error messages. Errors occuring during the parsing of
|\xintexpr-essions| try to provide helpful information about the offending
token.
@@ -6322,6 +6624,7 @@
\subsection{Origins of the package}
+\label{ssec:origins}
|2013/03/28.| Package |bigintcalc| by \textsc{Heiko Oberdiek} already
provides expandable arithmetic operations on ``big integers'',
@@ -6392,7 +6695,8 @@
\section{Some utilities from the \xinttoolsname package}
This is a first overview. Many examples combining these utilities with the
-arithmetic macros of \xintname are to be found in \autoref{sec:tools}.
+arithmetic macros of \xintname are to be found in \autoref{sec:tools}. See
+also \autoref{sec:examples}.
\subsection{Assignments}\label{sec:assign}
@@ -6519,24 +6823,1059 @@
As part of the \hyperref[sec:tools]{utilities} coming with the \xinttoolsname
package, there is a new kind of for loop, \csbxint{For}. Check it out
-(\autoref{xintFor}).
+(\autoref{xintFor} and also in next section).
\subsection{A new kind of expandable loop}
Also included in \xinttoolsname, \csbxint{iloop} is an expandable loop giving
access to an iteration index, without using count registers which would break
-expandability. Check it out (\autoref{xintiloop}).
+expandability. Check it out (\autoref{xintiloop} and also in next section).
+\section {Additional examples using \xinttoolsname or \xintexprname or both}
+\label{sec:examples}
-\etocdepthtag.toc {commands}
+Actually, recall that \xintexprname.sty automatically loads \xinttoolsname.sty.
+
+\subsection{Completely expandable prime test}
+\label{ssec:primesI}
+
+Let us now construct a completely expandable macro which returns $1$ if its
+given input is prime and $0$ if not:
+\everb|@
+\def\remainder #1#2{\the\numexpr #1-(#1/#2)*#2\relax }
+\def\IsPrime #1%
+ {\xintANDof {\xintApply {\remainder {#1}}{\xintSeq {2}{\xintiSqrt{#1}}}}}
+|
+
+This uses \csbxint{iSqrt} and assumes its input is at least $5$. Rather than
+\xintname's own \csbxint{iRem} we used a quicker |\numexpr| expression as we
+are dealing with short integers. Also we used \csbxint{ANDof} which will
+return $1$ only if all the items are non-zero. The macro is a bit
+silly with an even input, ok, let's enhance it to detect an even input:
+\everb|@
+\def\IsPrime #1%
+ {\xintifOdd {#1}
+ {\xintANDof % odd case
+ {\xintApply {\remainder {#1}}
+ {\xintSeq [2]{3}{\xintiSqrt{#1}}}%
+ }%
+ }
+ {\xintifEq {#1}{2}{1}{0}}%
+ }
+|
+
+We used the \xintname expandable tests (on big integers or fractions)
+in order for |\IsPrime| to be \fexpan dable.
+
+Our integers are short, but without |\expandafter|'s with
+|\@firstoftwo|, % @ n'est plus actif dans le dtx 1.1 !
+or some other related techniques,
+direct use of |\ifnum..\fi| tests is dangerous. So to make the macro more
+efficient we are going to use the expandable tests provided by the package
+\href{http://ctan.org/pkg/etoolbox}{etoolbox}%
+%
+\footnote{\url{http://ctan.org/pkg/etoolbox}}.
+%
+The macro becomes:
+%
+\everb|@
+\def\IsPrime #1%
+ {\ifnumodd {#1}
+ {\xintANDof % odd case
+ {\xintApply {\remainder {#1}}{\xintSeq [2]{3}{\xintiSqrt{#1}}}}}
+ {\ifnumequal {#1}{2}{1}{0}}}
+|
+
+In the odd case however we have to assume the integer is at least $7$, as
+|\xintSeq| generates an empty list if |#1=3| or |5|, and |\xintANDof| returns
+$1$ when supplied an empty list. Let us ease up a bit |\xintANDof|'s work by
+letting it work on only $0$'s and $1$'s. We could use:
+%
+\everb|@
+\def\IsNotDivisibleBy #1#2%
+ {\ifnum\numexpr #1-(#1/#2)*#2=0 \expandafter 0\else \expandafter1\fi}
+|
+\noindent
+where the |\expandafter|'s are crucial for this macro to be \fexpan dable and
+hence work within the applied \csbxint{ANDof}. Anyhow, now that we have loaded
+\href{http://ctan.org/pkg/etoolbox}{etoolbox}, we might as well use:
+%
+\everb|@
+\newcommand{\IsNotDivisibleBy}[2]{\ifnumequal{#1-(#1/#2)*#2}{0}{0}{1}}
+|
+\noindent
+Let us enhance our prime macro to work also on the small primes:
+\everb|@
+\newcommand{\IsPrime}[1] % returns 1 if #1 is prime, and 0 if not
+ {\ifnumodd {#1}
+ {\ifnumless {#1}{8}
+ {\ifnumequal{#1}{1}{0}{1}}% 3,5,7 are primes
+ {\xintANDof
+ {\xintApply
+ { \IsNotDivisibleBy {#1}}{\xintSeq [2]{3}{\xintiSqrt{#1}}}}%
+ }}% END OF THE ODD BRANCH
+ {\ifnumequal {#1}{2}{1}{0}}% EVEN BRANCH
+}
+|
+
+The input is still assumed positive. There is a deliberate blank before
+\csa{IsNotDivisibleBy} to use this feature of \csbxint{Apply}: a space stops the
+expansion of the applied macro (and disappears). This expansion will be done by
+\csbxint{ANDof}, which has been designed to skip everything as soon as it finds
+a false (i.e. zero) input. This way, the efficiency is considerably improved.
+
+We did generate via the \csbxint{Seq} too many potential divisors though. Later
+sections give two variants: one with \csbxint{iloop} (\autoref{ssec:primesII})
+which is still expandable and another one (\autoref{ssec:primesIII}) which is a
+close variant of the |\IsPrime| code above but with the \csbxint{For} loop, thus
+breaking expandability. The \hyperref[ssec:primesII]{xintiloop variant} does not
+first evaluate the integer square root, the \hyperref[ssec:primesIII]{xintFor
+ variant} still does. I did not compare their efficiencies.
+
+
+Let us construct with this expandable primality test a table of the prime
+numbers up to $1000$. We need to count how many we have in order to know how
+many tab stops one shoud add in the last row.%
+%
+\footnote{although a tabular row may have less tabs than in the
+ preamble, there is a problem with the \char`\|\space\space vertical
+ rule, if one does that.}
+%
+There is some subtlety for this
+last row. Turns out to be better to insert a |\\| only when we know for sure we
+are starting a new row; this is how we have designed the |\OneCell| macro. And
+for the last row, there are many ways, we use again |\xintApplyUnbraced| but
+with a macro which gobbles its argument and replaces it with a tabulation
+character. The \csbxint{For*} macro would be more elegant here.
+%
+\everb?@
+\newcounter{primecount}
+\newcounter{cellcount}
+\newcommand{\NbOfColumns}{13}
+\newcommand{\OneCell}[1]{%
+ \ifnumequal{\IsPrime{#1}}{1}
+ {\stepcounter{primecount}
+ \ifnumequal{\value{cellcount}}{\NbOfColumns}
+ {\\\setcounter{cellcount}{1}#1}
+ {&\stepcounter{cellcount}#1}%
+ } % was prime
+ {}% not a prime, nothing to do
+}
+\newcommand{\OneTab}[1]{&}
+\begin{tabular}{|*{\NbOfColumns}{r}|}
+\hline
+2 \setcounter{cellcount}{1}\setcounter{primecount}{1}%
+ \xintApplyUnbraced \OneCell {\xintSeq [2]{3}{999}}%
+ \xintApplyUnbraced \OneTab
+ {\xintSeq [1]{1}{\the\numexpr\NbOfColumns-\value{cellcount}\relax}}%
+ \\
+\hline
+\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
+cells (which doesn't happen here but would with a number of columns dividing
+$168$).
+%
+\newcommand{\IsNotDivisibleBy}[2]{\ifnumequal{#1-(#1/#2)*#2}{0}{0}{1}}
+
+\newcommand{\IsPrime}[1]
+ {\ifnumodd {#1}
+ {\ifnumless {#1}{8}
+ {\ifnumequal{#1}{1}{0}{1}}% 3,5,7 are primes
+ {\xintANDof
+ {\xintApply
+ { \IsNotDivisibleBy {#1}}{\xintSeq [2]{3}{\xintiSqrt{#1}}}}%
+ }}% END OF THE ODD BRANCH
+ {\ifnumequal {#1}{2}{1}{0}}% EVEN BRANCH
+}
+
+\newcounter{primecount}
+\newcounter{cellcount}
+\newcommand{\NbOfColumns}{13}
+\newcommand{\OneCell}[1]
+ {\ifnumequal{\IsPrime{#1}}{1}
+ {\stepcounter{primecount}
+ \ifnumequal{\value{cellcount}}{\NbOfColumns}
+ {\\\setcounter{cellcount}{1}#1}
+ {&\stepcounter{cellcount}#1}%
+ } % was prime
+ {}% not a prime nothing to do
+}
+\newcommand{\OneTab}[1]{&}
+\begin{figure*}[ht!]
+ \centering
+ \phantomsection\label{primesupto1000}
+ \begin{tabular}{|*{\NbOfColumns}{r}|}
+ \hline
+ 2\setcounter{cellcount}{1}\setcounter{primecount}{1}%
+ \xintApplyUnbraced \OneCell {\xintSeq [2]{3}{999}}%
+ \xintApplyUnbraced \OneTab
+ {\xintSeq [1]{1}{\the\numexpr\NbOfColumns-\value{cellcount}\relax}}%
+ \\
+ \hline
+ \end{tabular}
+\smallskip
+\centeredline{There are \arabic{primecount} prime numbers up to 1000.}
+\end{figure*}
+
+\subsection{Another completely expandable prime test}
+\label{ssec:primesII}
+
+The |\IsPrime| macro from \autoref{ssec:primesI} checked expandably if a (short)
+integer was prime, here is a partial rewrite using \csbxint{iloop}. We use the
+|etoolbox| expandable conditionals for convenience, but not everywhere as
+|\xintiloopindex| can not be evaluated while being braced. This is also the
+reason why |\xintbreakiloopanddo| is delimited, and the next macro
+|\SmallestFactor| which returns the smallest prime factor examplifies that. One
+could write more efficient completely expandable routines, the aim here was only
+to illustrate use of the general purpose \csbxint{iloop}. A little table giving
+the first values of |\SmallestFactor| follows, its coding uses \csbxint{For},
+which is described later; none of this uses count registers.
+%
+
+
+\begin{everbatim*}
+\let\IsPrime\undefined \let\SmallestFactor\undefined % clean up possible previous mess
+\newcommand{\IsPrime}[1] % returns 1 if #1 is prime, and 0 if not
+ {\ifnumodd {#1}
+ {\ifnumless {#1}{8}
+ {\ifnumequal{#1}{1}{0}{1}}% 3,5,7 are primes
+ {\if
+ \xintiloop [3+2]
+ \ifnum#1<\numexpr\xintiloopindex*\xintiloopindex\relax
+ \expandafter\xintbreakiloopanddo\expandafter1\expandafter.%
+ \fi
+ \ifnum#1=\numexpr (#1/\xintiloopindex)*\xintiloopindex\relax
+ \else
+ \repeat 00\expandafter0\else\expandafter1\fi
+ }%
+ }% END OF THE ODD BRANCH
+ {\ifnumequal {#1}{2}{1}{0}}% EVEN BRANCH
+}%
+\catcode`_ 11
+\newcommand{\SmallestFactor}[1] % returns the smallest prime factor of #1>1
+ {\ifnumodd {#1}
+ {\ifnumless {#1}{8}
+ {#1}% 3,5,7 are primes
+ {\xintiloop [3+2]
+ \ifnum#1<\numexpr\xintiloopindex*\xintiloopindex\relax
+ \xint_afterfi{\xintbreakiloopanddo#1.}%
+ \fi
+ \ifnum#1=\numexpr (#1/\xintiloopindex)*\xintiloopindex\relax
+ \xint_afterfi{\expandafter\xintbreakiloopanddo\xintiloopindex.}%
+ \fi
+ \iftrue\repeat
+ }%
+ }% END OF THE ODD BRANCH
+ {2}% EVEN BRANCH
+}%
+\catcode`_ 8
+{\centering
+ \begin{tabular}{|c|*{10}c|}
+ \hline
+ \xintFor #1 in {0,1,2,3,4,5,6,7,8,9}\do {&\bfseries #1}\\
+ \hline
+ \bfseries 0&--&--&2&3&2&5&2&7&2&3\\
+ \xintFor #1 in {1,2,3,4,5,6,7,8,9}\do
+ {\bfseries #1%
+ \xintFor #2 in {0,1,2,3,4,5,6,7,8,9}\do
+ {&\SmallestFactor{#1#2}}\\}%
+ \hline
+ \end{tabular}\par
+}
+\end{everbatim*}
+
+\subsection{Miller-Rabin Pseudo-Primality expandably}
+\label{ssec:PrimesIV}
+
+This section is based on my \url{http://tex.stackexchange.com/a/165008} post.
+But I have modified it to use \csbxint{NewFunction} which is available since
+|1.2i|. This is good opportunity to illustrate how \csbxint{NewFunction} can be
+used to define a recursive function (here modular exponentiation.)
+
+The |isPseudoPrime(n)| is usable in \csbxint{iiexpr}-essions and establishes
+if its (positive) argument is a Miller-Rabin PseudoPrime to the bases $2, 3,
+5, 7, 11, 13, 17$. If this is true and $n<341550071728321$ (which has 15
+digits) then $n$ really is a prime number.
+
+Similarly $n=3825123056546413051$ (19 digits) is the smallest composite number
+which is a strong pseudo prime for bases $2, 3, 5, 7, 11, 13, 17, 19$ and
+$23$. It is easy to extend the code below to include these additional tests
+(we could make the list of tested bases an argument too, now that I think
+about it.)
+
+For more information see
+ \centeredline{\url{https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test#Deterministic_variants_of_the_test}}
+ and
+\centeredline{\url{http://primes.utm.edu/prove/prove2_3.html}}
+
+In particular, according to \textsc{Jaeschke} \emph{On strong pseudoprimes to
+ several bases,} Math. Comp., 61 (1993) 915-926, if $n < 4,759,123,141$ it is
+enough to establish Rabin-Miller pseudo-primality to bases $a = 2, 7, 61$ to
+prove that $n$ is prime. This range is enough for \TeX\ numbers and we could
+then write a very fast expandable primality test for such numbers using only
+|\numexpr|. Left as an exercise\dots
+
+\begin{everbatim*}
+% I -------------------------------- Modular Exponentiation
+% #1=x, #2=m, #3=N, compute x^m modulo N (with m non negative)
+% We will always use it with 1< x < N hence we skip an initial reduction modulo N.
+
+% We can not use \xintdefiifunction for such recursive definition but
+% \xintNewFunction succeeds!
+\xintNewFunction{powmod}[3]{% x = #1, m = #2, n = #3
+ (#2)?
+ % m non zero (assume positive), and look if m=1
+ {(#2=1)?{#1/:#3}
+ {odd(#2)?{(#1*sqr(powmod(#1,#2//2,#3)))/:#3}
+ {sqr(powmod(#1,#2//2,#3))/:#3}}}
+ % m is zero, return 1
+ {1}}
+
+% See http://tex.stackexchange.com/a/165008 for a (probably faster) macro-only approach
+% not using \xintexpr.
+
+% II ------------------------------ Miller-Rabin compositeness witness
+
+% n=2^k m + 1 with m odd and k at least 1
+
+% Choose 1<x<n.
+% compute y=x^m modulo n
+% if equals 1 we can't say anything
+% if equals n-1 we can't say anything
+% else put j=1, and
+% compute repeatedly the square, incrementing j by 1 each time,
+% thus always we have y^{2^{j-1}}
+% -> if at some point n-1 mod n found, we can't say anything and break out
+% -> if however we never find n-1 mod n before reaching
+% z=y^{2^{k-1}} with j=k
+% we then have z^2=x^{n-1}.
+ % Suppose z is not -1 mod n. If z^2 is 1 mod n, then n can be prime only if
+ % z is 1 mod n, and we can go back up, until initial y, and we have already
+ % excluded y=1. Thus if z is not -1 mod n and z^2 is 1 then n is not prime.
+ % But if z^2 is not 1, then n is not prime by Fermat. Hence (z not -1 mod n)
+ % implies (n is composite). (Miller test)
+
+% let's use again xintexpr indecipherable (except to author) syntax. Of course
+% doing it with macros only would be faster.
+
+% Here \xintdefiifunction is not usable because not compatible with iter, break, ...
+% but \xintNewFunction comes to the rescue.
+
+\xintNewFunction{isCompositeWitness}[4]{% x=#1, n=#2, m=#3, k=#4
+ subs((y==1)?{0}
+ {iter(y;(j=#4)?{break(!(@==#2-1))}
+ {(@==#2-1)?{break(0)}{sqr(@)/:#2}},j=1++)}
+ ,y=powmod(#1,#3,#2))}
+
+% III ------------------------------------- Strong Pseudo Primes
+
+% cf
+% http://oeis.org/A014233
+% <http://mathworld.wolfram.com/Rabin-MillerStrongPseudoprimeTest.html>
+% <http://mathworld.wolfram.com/StrongPseudoprime.html>
+
+% check if positive integer <49 si a prime.
+% 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47
+\def\IsVerySmallPrime #1%
+ {\ifnum#1=1 \xintdothis0\fi
+ \ifnum#1=2 \xintdothis1\fi
+ \ifnum#1=3 \xintdothis1\fi
+ \ifnum#1=5 \xintdothis1\fi
+ \ifnum#1=\numexpr (#1/2)*2\relax\xintdothis0\fi
+ \ifnum#1=\numexpr (#1/3)*3\relax\xintdothis0\fi
+ \ifnum#1=\numexpr (#1/5)*5\relax\xintdothis0\fi
+ \xintorthat 1}
+
+\xintNewFunction{isPseudoPrime}[1]{% n = #1
+ (#1<49)?% use ? syntax to evaluate only what is needed
+ {\IsVerySmallPrime{\xintthe#1}}% macro needs to be fed with #1 unlocked.
+ {(even(#1))?
+ {0}
+ {subs(%
+ % L expands to two values m, k hence isCompositeWitness does get
+ % its four variables x, n, m, k
+ isCompositeWitness(2, #1, L)?
+ {0}%
+ {isCompositeWitness(3, #1, L)?
+ {0}%
+ {isCompositeWitness(5, #1, L)?
+ {0}%
+ {isCompositeWitness(7, #1, L)?
+ {0}%
+% above enough for N<3215031751 hence all TeX numbers
+ {isCompositeWitness(11, #1, L)?
+ {0}%
+% above enough for N<2152302898747, hence all 12-digits numbers
+ {isCompositeWitness(13, #1, L)?
+ {0}%
+% above enough for N<3474749660383
+ {isCompositeWitness(17, #1, L)?
+ {0}%
+% above enough for N<341550071728321
+ {1}%
+ }% not needed to comment-out end of lines spaces inside
+ }% \xintexpr but this is too much of a habit for me with TeX!
+ }% I left some after the ? characters.
+ }%
+ }%
+ }% this computes (m, k) such that n = 2^k m + 1, m odd, k>=1
+ , L=iter(#1//2;(even(@))?{@//2}{break(@,k)},k=1++))%
+ }%
+ }%
+}
+
+% if needed:
+%\def\IsPseudoPrime #1{\xinttheiiexpr isPseudoPrime(#1)\relax}
+
+\noindent The smallest prime number at least equal to 3141592653589 is
+\xinttheiiexpr
+ seq(isPseudoPrime(3141592653589+n)?
+ {break(3141592653589+n)}{omit}, n=0++)\relax.
+% we could not use 3141592653589++ syntax because it works only with TeX numbers
+\par
+\end{everbatim*}
+
+
+
+
+
+\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
+here, just handling the row index, the row contents being almost entirely
+produced via a macro |\factorize|. The factorizing macro does not use
+|\xintiloop| as it didn't appear to be the convenient tool. As |\factorize| will
+have to be used on |\xintiloopindex|, it has been defined as a delimited macro.
+
+To spare some fractions of a second in the compilation time of this document
+(which has many many other things to do), \number"7FFFFFED{} and
+\number"7FFFFFFF, which turn out to be prime numbers, are not given to
+|factorize| but just typeset directly; this illustrates use of
+\csbxint{iloopskiptonext}.
+
+The code next generates a \hyperref[floatfactorize]{table} which has
+been made into a float appearing \vpageref{floatfactorize}. Here is now
+the code for factorization; the conditionals use the package provided
+|\xint_firstoftwo| and |\xint_secondoftwo|, one could have employed
+rather \LaTeX{}'s own |\@firstoftwo| and |\@secondoftwo|, or, simpler
+still in \LaTeX{} context, the |\ifnumequal|, |\ifnumless| \dots,
+utilities from the package |etoolbox| which do exactly that under the
+hood. Only \TeX{} acceptable numbers are treated here, but it would be
+easy to make a translation and use the \xintname macros, thus extending
+the scope to big numbers; naturally up to a cost in speed.
+
+The reason for some strange looking expressions is to avoid arithmetic overflow.
+
+\begin{everbatim*}
+\catcode`_ 11
+\def\abortfactorize #1\xint_secondoftwo\fi #2#3{\fi}
+
+\def\factorize #1.{\ifnum#1=1 \abortfactorize\fi
+ \ifnum\numexpr #1-2=\numexpr ((#1/2)-1)*2\relax
+ \expandafter\xint_firstoftwo
+ \else\expandafter\xint_secondoftwo
+ \fi
+ {2&\expandafter\factorize\the\numexpr#1/2.}%
+ {\factorize_b #1.3.}}%
+
+\def\factorize_b #1.#2.{\ifnum#1=1 \abortfactorize\fi
+ \ifnum\numexpr #1-(#2-1)*#2<#2
+ #1\abortfactorize
+ \fi
+ \ifnum \numexpr #1-#2=\numexpr ((#1/#2)-1)*#2\relax
+ \expandafter\xint_firstoftwo
+ \else\expandafter\xint_secondoftwo
+ \fi
+ {#2&\expandafter\factorize_b\the\numexpr#1/#2.#2.}%
+ {\expandafter\factorize_b\the\numexpr #1\expandafter.%
+ \the\numexpr #2+2.}}%
+\catcode`_ 8
+\begin{figure*}[ht!]
+\centering\phantomsection\label{floatfactorize}\normalcolor
+\tabskip1ex
+\centeredline{\vbox{\halign {\hfil\strut#\hfil&&\hfil#\hfil\cr\noalign{\hrule}
+ \xintiloop ["7FFFFFE0+1]
+ \expandafter\bfseries\xintiloopindex &
+ \ifnum\xintiloopindex="7FFFFFED
+ \number"7FFFFFED\cr\noalign{\hrule}
+ \expandafter\xintiloopskiptonext
+ \fi
+ \expandafter\factorize\xintiloopindex.\cr\noalign{\hrule}
+ \ifnum\xintiloopindex<"7FFFFFFE
+ \repeat
+ \bfseries \number"7FFFFFFF&\number "7FFFFFFF\cr\noalign{\hrule}
+}}}
+\centeredline{A table of factorizations}
+\end{figure*}
+\end{everbatim*}
+
+\subsection{Another table of primes}
+\label{ssec:primesIII}
+
+As a further example, let us dynamically generate a tabular with the first $50$
+prime numbers after $12345$. First we need a macro to test if a (short) number
+is prime. Such a completely expandable macro was given in \autoref{ssec:primesI},
+here we consider a variant which will be slightly more efficient. This new
+|\IsPrime| has two parameters. The first one is a macro which it redefines to
+expand to the result of the primality test applied to the second argument. For
+convenience we use the \href{http://ctan.org/pkg/etoolbox}{etoolbox} wrappers to
+various |\ifnum| tests, although here there isn't anymore the constraint of
+complete expandability (but using explicit |\if..\fi| in tabulars has its
+quirks); equivalent tests are provided by \xintname, but they have some overhead
+as they are able to deal with arbitrarily big integers.
+
+\def\IsPrime #1#2%
+{\edef\TheNumber {\the\numexpr #2}% positive integer
+ \ifnumodd {\TheNumber}
+ {\ifnumgreater {\TheNumber}{1}
+ {\edef\ItsSquareRoot{\xintiSqrt \TheNumber}%
+ \xintFor ##1 in {\xintintegers [3+2]}\do
+ {\ifnumgreater {##1}{\ItsSquareRoot}
+ {\def#1{1}\xintBreakFor}
+ {}%
+ \ifnumequal {\TheNumber}{(\TheNumber/##1)*##1}
+ {\def#1{0}\xintBreakFor }
+ {}%
+ }}
+ {\def#1{0}}}% 1 is not prime
+ {\ifnumequal {\TheNumber}{2}{\def#1{1}}{\def#1{0}}}%
+}%
+
+\everb|@
+\def\IsPrime #1#2% """color[named]{PineGreen}#1=\Result, #2=tested number (assumed >0).;!
+{\edef\TheNumber {\the\numexpr #2}%"""color[named]{PineGreen} hence #2 may be a count or \numexpr.;!
+ \ifnumodd {\TheNumber}
+ {\ifnumgreater {\TheNumber}{1}
+ {\edef\ItsSquareRoot{\xintiSqrt \TheNumber}%
+ \xintFor """color{red}##1;! in {"""color{red}\xintintegers;! [3+2]}\do
+ {\ifnumgreater {"""color{red}##1;!}{\ItsSquareRoot} """color[named]{PineGreen}% "textcolor{red}{##1} is a \numexpr.;!
+ {\def#1{1}\xintBreakFor}
+ {}%
+ \ifnumequal {\TheNumber}{(\TheNumber/##1)*##1}
+ {\def#1{0}\xintBreakFor }
+ {}%
+ }}
+ {\def#1{0}}}% 1 is not prime
+ {\ifnumequal {\TheNumber}{2}{\def#1{1}}{\def#1{0}}}%
+}
+|
+
+
+As we used \csbxint{For} inside a macro we had to double the |#| in its |#1|
+parameter. Here is now the code which creates the prime table (the table has
+been put in a \hyperref[primes]{float}, which should be found on page
+\pageref{primes}):
+
+\everb?@
+\newcounter{primecount}
+\newcounter{cellcount}
+\begin{figure*}[ht!]
+ \centering
+ \begin{tabular}{|*{7}c|}
+ \hline
+ \setcounter{primecount}{0}\setcounter{cellcount}{0}%
+ \xintFor """color{red}#1;! in {"""color{red}\xintintegers;! [12345+2]} \do
+"""color[named]{PineGreen}% "textcolor{red}{#1} is a \numexpr.;!
+ {\IsPrime\Result{#1}%
+ \ifnumgreater{\Result}{0}
+ {\stepcounter{primecount}%
+ \stepcounter{cellcount}%
+ \ifnumequal {\value{cellcount}}{7}
+ {"""color{red}\the#1;! \\\setcounter{cellcount}{0}}
+ {"""color{red}\the#1;! &}}
+ {}%
+ \ifnumequal {\value{primecount}}{50}
+ {\xintBreakForAndDo
+ {\multicolumn {6}{l|}{These are the first 50 primes after 12345.}\\}}
+ {}%
+ }\hline
+\end{tabular}
+\end{figure*}
+?
+
+\begin{figure*}[ht!]
+ \centering\phantomsection\label{primes}
+ \begin{tabular}{|*{7}c|}
+ \hline
+ \setcounter{primecount}{0}\setcounter{cellcount}{0}%
+ \xintFor #1 in {\xintintegers [12345+2]} \do
+ {\IsPrime\Result{#1}%
+ \ifnumgreater{\Result}{0}
+ {\stepcounter{primecount}%
+ \stepcounter{cellcount}%
+ \ifnumequal {\value{cellcount}}{7}
+ {\the#1 \\\setcounter{cellcount}{0}}
+ {\the#1 &}}
+ {}%
+ \ifnumequal {\value{primecount}}{50}
+ {\xintBreakForAndDo
+ {\multicolumn {6}{l|}{These are the first 50 primes after 12345.}\\}}
+ {}%
+ }\hline
+\end{tabular}
+\end{figure*}
+
+\subsection{Factorizing again}
+\label{ssec:factorize}
+
+Here is an \fexpan dable macro which computes the factors of an integer. It
+uses the \xintname macros only.
+\begin{everbatim*}
+\catcode`\@ 11
+\let\factorize\relax
+\newcommand\Factorize [1]
+ {\romannumeral0\expandafter\factorize\expandafter{\romannumeral-`0#1}}%
+\newcommand\factorize [1]{\xintiiifOne{#1}{ 1}{\factors at a #1.{#1};}}%
+\def\factors at a #1.{\xintiiifOdd{#1}
+ {\factors at c 3.#1.}%
+ {\expandafter\factors at b \expandafter1\expandafter.\romannumeral0\xinthalf{#1}.}}%
+\def\factors at b #1.#2.{\xintiiifOne{#2}
+ {\factors at end {2, #1}}%
+ {\xintiiifOdd{#2}{\factors at c 3.#2.{2, #1}}%
+ {\expandafter\factors at b \the\numexpr #1+\@ne\expandafter.%
+ \romannumeral0\xinthalf{#2}.}}%
+}%
+\def\factors at c #1.#2.{%
+ \expandafter\factors at d\romannumeral0\xintiidivision {#2}{#1}{#1}{#2}%
+}%
+\def\factors at d #1#2#3#4{\xintiiifNotZero{#2}
+ {\xintiiifGt{#3}{#1}
+ {\factors at end {#4, 1}}% ultimate quotient is a prime with power 1
+ {\expandafter\factors at c\the\numexpr #3+\tw at .#4.}}%
+ {\factors at e 1.#3.#1.}%
+}%
+\def\factors at e #1.#2.#3.{\xintiiifOne{#3}
+ {\factors at end {#2, #1}}%
+ {\expandafter\factors at f\romannumeral0\xintiidivision {#3}{#2}{#1}{#2}{#3}}%
+}%
+\def\factors at f #1#2#3#4#5{\xintiiifNotZero{#2}
+ {\expandafter\factors at c\the\numexpr #4+\tw at .#5.{#4, #3}}%
+ {\expandafter\factors at e\the\numexpr #3+\@ne.#4.#1.}%
+}%
+\def\factors at end #1;{\xintlistwithsep{, }{\xintRevWithBraces {#1}}}%
+\catcode`@ 12
+\end{everbatim*}
+The macro will be acceptably efficient only with numbers having somewhat small
+prime factors.
+\begin{everbatim}
+\Factorize{16246355912554185673266068721806243461403654781833}
+\end{everbatim}
+\begingroup\fdef\Z
+{\Factorize{16246355912554185673266068721806243461403654781833}}
+\noindent{\small\dtt{\Z}}
+
+
+It puts a little stress on the input save stack in order
+not be bothered with previously gathered things.\footnote{2015/11/18 I have
+ not revisited this code for a long time, and perhaps I could improve it now
+ with some new techniques.}
+
+Its output is a comma separated list with the number first, then its prime
+factors with multiplicity. Let's produce something prettier:
+\begin{everbatim*}
+\catcode`_ 11
+\def\ShowFactors #1{\expandafter\ShowFactors_a\romannumeral-`0\Factorize{#1},\relax,\relax,}
+\def\ShowFactors_a #1,{#1=\ShowFactors_b}
+\def\ShowFactors_b #1,#2,{\if\relax#1\else#1^{#2}\expandafter\ShowFactors_b\fi}
+\catcode`_ 8
+\end{everbatim*}
+\begin{everbatim}
+$$\ShowFactors{16246355912554185673266068721806243461403654781833}$$
+\end{everbatim}
+$$\csname ShowFactors_a\expandafter\endcsname\Z,\relax,\relax,$$
+\endgroup
+
+If we only considered small integers, we could write pure |\numexpr| methods
+which would be very much faster (especially if we had a table of small primes
+prepared first) but still ridiculously slow compared to any non expandable
+implementation, not to mention use of programming languages directly accessing
+the CPU registers\dots
+
+\subsection{The Quick Sort algorithm illustrated}\label{ssec:quicksort}
+
+First a completely expandable macro which sorts a comma separated list of
+numbers.%
+%
+\footnote{The code in earlier versions of this manual handled inputs composed
+ of braced items. I have switched to comma separated inputs on the occasion
+ of \url{http://tex.stackexchange.com/a/273084}. The version here is like
+ |code 3| on \url{http://tex.stackexchange.com} (which is about |3x| faster
+ than the earlier code it replaced in this manual) with a modification to
+ make it more efficient if the data has many repeated values.
+
+ A faster routine (for sorting hundreds of values) is provided as |code 6| at
+ the link mentioned in the footnote, it is based on Merge Sort, but limited
+ to inputs which one can handle as \TeX{} dimensions.%
+
+ This |code 6| could be extended to handle more general numbers, as
+ acceptable by \xintfracname. I have also written a non expandable version,
+ which is even faster, but this matters really only when handling hundreds or
+ rather thousands of values.}
+%
+
+The |\QSx| macro expands its list argument, which may thus be a macro; its
+comma separated items must expand to integers or decimal numbers or fractions
+or scientific notation as acceptable to \xintfracname, but if an item is
+itself some (expandable) macro, this macro will be expanded each time the item
+is considered in a comparison test! This is actually good if the macro expands
+in one step to the digits, and there are many many digits, but bad if the macro
+needs to do many computations. Thus |\QSx| should be used with either explicit
+numbers or with items being macros expanding in one step to the numbers
+(particularly if these numbers are very big).
+
+If the interest is only in \TeX{} integers, then one should replace the
+|\xintifCmp| macro with a suitable conditional, possibly helped by tools such as
+|\ifnumgreater|, |\ifnumequal| and |\ifnumless| from
+\href{http://ctan.org/pkg/etoolbox}{etoolbox} (\LaTeX{} only; I didn't see a
+direct equivalent to |\xintifCmp|.) Or, if we are dealing with decimal numbers
+with at most four+four digits, then one should use suitable |\ifdim| tests.
+Naturally this will boost consequently the speed, from having skipped all the
+overhead in parsing fractions and scientific numbers as are acceptable by
+\xintfracname macros, and subsequent treatment.
+
+\begin{everbatim*}
+% THE QUICK SORT ALGORITHM EXPANDABLY
+% \usepackage{xintfrac} in the preamble (latex)
+\makeatletter
+% use extra safe delimiters
+\catcode`! 3 \catcode`? 3
+\def\QSx {\romannumeral0\qsx }%
+% first we check if empty list (else \qsx at finish will not find a comma)
+\def\qsx #1{\expandafter\qsx at a\romannumeral-`0#1,!,?}%
+\def\qsx at a #1{\ifx,#1\expandafter\qsx at abort\else
+ \expandafter\qsx at start\fi #1}%
+\def\qsx at abort #1?{ }%
+\def\qsx at start {\expandafter\qsx at finish\romannumeral0\qsx at b,}%
+\def\qsx at finish ,#1{ #1}%
+%
+% we check if empty of single and if not pick up the first as Pivot:
+\def\qsx at b ,#1#2,#3{\ifx?#3\xintdothis\qsx at empty\fi
+ \ifx!#3\xintdothis\qsx at single\fi
+ \xintorthat\qsx at separate {#1#2}{}{}{#1#2}#3}%
+\def\qsx at empty #1#2#3#4#5{ }%
+\def\qsx at single #1#2#3#4#5?{, #4}%
+\def\qsx at separate #1#2#3#4#5#6,%
+{%
+ \ifx!#5\expandafter\qsx at separate@done\fi
+ \xintifCmp {#5#6}{#4}%
+ \qsx at separate@appendtosmaller
+ \qsx at separate@appendtoequal
+ \qsx at separate@appendtogreater {#5#6}{#1}{#2}{#3}{#4}%
+}%
+%
+\def\qsx at separate@appendtoequal #1#2{\qsx at separate {#2,#1}}%
+\def\qsx at separate@appendtogreater #1#2#3{\qsx at separate {#2}{#3,#1}}%
+\def\qsx at separate@appendtosmaller #1#2#3#4{\qsx at separate {#2}{#3}{#4,#1}}%
+%
+\def\qsx at separate@done\xintifCmp #1%
+ \qsx at separate@appendtosmaller
+ \qsx at separate@appendtoequal
+ \qsx at separate@appendtogreater #2#3#4#5#6#7?%
+{%
+ \expandafter\qsx at f\expandafter {\romannumeral0\qsx at b #4,!,?}{\qsx at b #5,!,?}{#3}%
+}%
+%
+\def\qsx at f #1#2#3{#2, #3#1}%
+%
+\catcode`! 12 \catcode`? 12
+\makeatother
+
+% EXAMPLE
+\begingroup
+\edef\z {\QSx {1.0, 0.5, 0.3, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
+ 1.3, 1.1, 0.7, 1.6, 0.6, 0.9, 0.8, 0.2, 0.1, 1.9}}
+\meaning\z
+
+\def\a {3.123456789123456789}\def\b {3.123456789123456788}
+\def\c {3.123456789123456790}\def\d {3.123456789123456787}
+\oodef\z {\QSx { \a, \b, \c, \d}}%
+% The space before \a to let it not be expanded during the conversion from CSV
+% values to List. The \oodef expands exactly twice (via a bunch of \expandafter's)
+\meaning\z
+\endgroup
+\end{everbatim*} (the spaces after \string\d, etc... come from the use of the
+|\meaning| primitive.)
+
+The choice of pivot as first element is bad if the list is already almost
+sorted. Let's add a variant which will pick up the pivot index randomly. The
+previous routine worked also internally with comma separated lists, but for a
+change this one will use internally lists of braced items (the initial
+conversion via \csbxint{CSVtoList} handles all potential spurious space
+problems).
+
+\unless\ifxetex % pour tester compilation de xint.dtx avec xetex qui n'a pas
+ % \pdfuniformedeviate
+\begin{everbatim*}
+% QuickSort expandably on comma separated values with random choice of pivots
+% ====> Requires availability of \pdfuniformdeviate <====
+% \usepackage{xintfrac, xinttools} in preamble
+\makeatletter
+\def\QSx {\romannumeral0\qsx }% This is a f-expandable macro.
+% This converts from comma separated values on input and back on output.
+% **** NOTE: these steps (and the other ones too, actually) are costly if input
+% has thousands of items.
+\def\qsx #1{\xintlistwithsep{, }%
+ {\expandafter\qsx at sort@a\expandafter{\romannumeral0\xintcsvtolist{#1}}}}%
+%
+% we check if empty or single or double and if not pick up the first as Pivot:
+\def\qsx at sort@a #1%
+ {\expandafter\qsx at sort@b\expandafter{\romannumeral0\xintlength{#1}}{#1}}%
+\def\qsx at sort@b #1{\ifcase #1
+ \expandafter\qsx at sort@empty
+ \or\expandafter\qsx at sort@single
+ \or\expandafter\qsx at sort@double
+ \else\expandafter\qsx at sort@c\fi {#1}}%
+\def\qsx at sort@empty #1#2{ }%
+\def\qsx at sort@single #1#2{#2}%
+\catcode`_ 11
+\def\qsx at sort@double #1#2{\xintifGt #2{\xint_exchangetwo_keepbraces}{}#2}%
+\catcode`_ 8
+\def\qsx at sort@c #1#2{%
+ \expandafter\qsx at sort@sep at a\expandafter
+ {\romannumeral0\xintnthelt{\pdfuniformdeviate #1+\@ne}{#2}}#2?}%
+\def\qsx at sort@sep at a #1{\qsx at sort@sep at loop {}{}{}{#1}}%
+\def\qsx at sort@sep at loop #1#2#3#4#5%
+{%
+ \ifx?#5\expandafter\qsx at sort@sep at done\fi
+ \xintifCmp {#5}{#4}%
+ \qsx at sort@sep at appendtosmaller
+ \qsx at sort@sep at appendtoequal
+ \qsx at sort@sep at appendtogreater {#5}{#1}{#2}{#3}{#4}%
+}%
+%
+\def\qsx at sort@sep at appendtoequal #1#2{\qsx at sort@sep at loop {#2{#1}}}%
+\def\qsx at sort@sep at appendtogreater #1#2#3{\qsx at sort@sep at loop {#2}{#3{#1}}}%
+\def\qsx at sort@sep at appendtosmaller #1#2#3#4{\qsx at sort@sep at loop {#2}{#3}{#4{#1}}}%
+%
+\def\qsx at sort@sep at done\xintifCmp #1%
+ \qsx at sort@sep at appendtosmaller
+ \qsx at sort@sep at appendtoequal
+ \qsx at sort@sep at appendtogreater #2#3#4#5#6%
+{%
+ \expandafter\qsx at sort@recurse\expandafter
+ {\romannumeral0\qsx at sort@a {#4}}{\qsx at sort@a {#5}}{#3}%
+}%
+%
+\def\qsx at sort@recurse #1#2#3{#2#3#1}%
+%
+\makeatother
+
+% EXAMPLES
+\begingroup
+\edef\z {\QSx {1.0, 0.5, 0.3, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
+ 1.3, 1.1, 0.7, 1.6, 0.6, 0.9, 0.8, 0.2, 0.1, 1.9}}
+\meaning\z
+
+\def\a {3.123456789123456789}\def\b {3.123456789123456788}
+\def\c {3.123456789123456790}\def\d {3.123456789123456787}
+\oodef\z {\QSx { \a, \b, \c, \d}}%
+% The space before \a to let it not be expanded during the conversion from CSV
+% values to List. The \oodef expands exactly twice (via a bunch of \expandafter's)
+\meaning\z
+
+\def\somenumbers{%
+3997.6421, 8809.9358, 1805.4976, 5673.6478, 3179.1328, 1425.4503, 4417.7691,
+2166.9040, 9279.7159, 3797.6992, 8057.1926, 2971.9166, 9372.2699, 9128.4052,
+1228.0931, 3859.5459, 8561.7670, 2949.6929, 3512.1873, 1698.3952, 5282.9359,
+1055.2154, 8760.8428, 7543.6015, 4934.4302, 7526.2729, 6246.0052, 9512.4667,
+7423.1124, 5601.8436, 4433.5361, 9970.4849, 1519.3302, 7944.4953, 4910.7662,
+3679.1515, 8167.6824, 2644.4325, 8239.4799, 4595.1908, 1560.2458, 6098.9677,
+3116.3850, 9130.5298, 3236.2895, 3177.6830, 5373.1193, 5118.4922, 2743.8513,
+8008.5975, 4189.2614, 1883.2764, 9090.9641, 2625.5400, 2899.3257, 9157.1094,
+8048.4216, 3875.6233, 5684.3375, 8399.4277, 4528.5308, 6926.7729, 6941.6278,
+9745.4137, 1875.1205, 2755.0443, 9161.1524, 9491.1593, 8857.3519, 4290.0451,
+2382.4218, 3678.2963, 5647.0379, 1528.7301, 2627.8957, 9007.9860, 1988.5417,
+2405.1911, 5065.8063, 5856.2141, 8989.8105, 9349.7840, 9970.3013, 8105.4062,
+3041.7779, 5058.0480, 8165.0721, 9637.7196, 1795.0894, 7275.3838, 5997.0429,
+7562.6481, 8084.0163, 3481.6319, 8078.8512, 2983.7624, 3925.4026, 4931.5812,
+1323.1517, 6253.0945}%
+
+\oodef\z {\QSx \somenumbers}%
+\hsize 87\fontcharwd\font`0 \setbox0\hbox{\kern\fontcharwd\font`0}%
+\lccode`~=32 \lowercase{\def~}{\discretionary{}{}{\copy0}}\catcode32 13
+\noindent\ \ \ \scantokens\expandafter{\meaning\z}\par
+\endgroup
+\end{everbatim*}
+\fi % fin de si pas xetex
+
+All these examples were with numbers which may have been handled via |\ifdim|
+tests rather than \csbxint{ifCmp} from \xintfracname ; naturally that would
+have been faster. For a yet faster routine (based however on the Merge Sort
+and using the |\pdfescapestring| PDF\TeX{} primitive) see |code 6| at
+\url{http://tex.stackexchange.com/a/273084}.
+
+We then turn to a graphical illustration of the algorithm.%
+%
+\footnote{I have rewritten the routine to do only once (and not thrice) the
+ needed calls to \csa{xintifCmp}, up to the price of one additional |\edef|,
+ although due to the context execution time on our side is not an issue and
+ moreover is anyhow overwhelmed by the TikZ's activities. Simultaneously I
+ have updated the code \url{http://tex.stackexchange.com/a/142634/4686}. The
+ variant with the choice of pivot on the right has more overhead: the reason
+ is simply that we do not convert the data into an array, but maintain a list
+ of tokens with self-reorganizing delimiters.}
+%
+For simplicity the pivot is always chosen as the first list item. Then we also
+give a variant which picks up the last item as pivot.
+\begin{everbatim*}
+% in LaTeX preamble:
+% \usepackage{xintfrac, xinttools}
+% \usepackage{color}
+% or, when using Plain TeX:
+% \input xintfrac.sty \input xinttools.sty
+% \input color.tex
+%
+% Color definitions
+\definecolor{LEFT}{RGB}{216,195,88}
+\definecolor{RIGHT}{RGB}{208,231,153}
+\definecolor{INERT}{RGB}{199,200,194}
+\definecolor{INERTpiv}{RGB}{237,237,237}
+\definecolor{PIVOT}{RGB}{109,8,57}
+% Start of macro defintions
+\makeatletter
+% \catcode`? 3 % a bit too paranoid. Normal ? will do.
+%
+% argument will never be empty
+\def\QS at cmp@a #1{\QS at cmp@b #1??}%
+\def\QS at cmp@b #1{\noexpand\QS at sep@A\@ne{#1}\QS at cmp@d {#1}}%
+\def\QS at cmp@d #1#2{\ifx ?#2\expandafter\QS at cmp@done\fi
+ \xintifCmp {#1}{#2}\tw@\@ne\z@{#2}\QS at cmp@d {#1}}%
+\def\QS at cmp@done #1?{?}%
+%
+\def\QS at sep@A #1?{\QSLr\QS at sep@L #1\thr@@?#1\thr@@?#1\thr@@?}%
+\def\QS at sep@L #1#2{\ifcase #1{#2}\or\or\else\expandafter\QS at sep@I at start\fi \QS at sep@L}%
+\def\QS at sep@I at start\QS at sep@L {\noexpand\empty?\QSIr\QS at sep@I}%
+\def\QS at sep@I #1#2{\ifcase#1\or{#2}\or\else\expandafter\QS at sep@R at start\fi\QS at sep@I}%
+\def\QS at sep@R at start\QS at sep@I {\noexpand\empty?\QSRr\QS at sep@R}%
+\def\QS at sep@R #1#2{\ifcase#1\or\or{#2}\else\expandafter\QS at sep@done\fi\QS at sep@R}%
+\def\QS at sep@done\QS at sep@R {\noexpand\empty?}%
+%
+\def\QS at loop {%
+ \xintloop
+ % pivot phase
+ \def\QS at pivotcount{0}%
+ \let\QSLr\DecoLEFTwithPivot \let\QSIr \DecoINERT
+ \let\QSRr\DecoRIGHTwithPivot \let\QSIrr\DecoINERT
+ \centerline{\QS at list}%
+ % sorting phase
+ \ifnum\QS at pivotcount>\z@
+ \def\QSLr {\QS at cmp@a}\def\QSRr {\QS at cmp@a}%
+ \def\QSIr {\QSIrr}\let\QSIrr\relax
+ \edef\QS at list{\QS at list}% compare
+ \let\QSLr\relax\let\QSRr\relax\let\QSIr\relax
+ \edef\QS at list{\QS at list}% separate
+ \def\QSLr ##1##2?{\ifx\empty##1\else\noexpand \QSLr {{##1}##2}\fi}%
+ \def\QSIr ##1##2?{\ifx\empty##1\else\noexpand \QSIr {{##1}##2}\fi}%
+ \def\QSRr ##1##2?{\ifx\empty##1\else\noexpand \QSRr {{##1}##2}\fi}%
+ \edef\QS at list{\QS at list}% gather
+ \let\QSLr\DecoLEFT \let\QSRr\DecoRIGHT
+ \let\QSIr\DecoINERTwithPivot \let\QSIrr\DecoINERT
+ \centerline{\QS at list}%
+ \repeat }%
+%
+% \xintFor* loops handle gracefully empty lists.
+\def\DecoLEFT #1{\xintFor* ##1 in {#1} \do {\colorbox{LEFT}{##1}}}%
+\def\DecoINERT #1{\xintFor* ##1 in {#1} \do {\colorbox{INERT}{##1}}}%
+\def\DecoRIGHT #1{\xintFor* ##1 in {#1} \do {\colorbox{RIGHT}{##1}}}%
+\def\DecoPivot #1{\begingroup\color{PIVOT}\advance\fboxsep-\fboxrule\fbox{#1}\endgroup}%
+%
+\def\DecoLEFTwithPivot #1{\xdef\QS at pivotcount{\the\numexpr\QS at pivotcount+\@ne}%
+ \xintFor* ##1 in {#1} \do
+ {\xintifForFirst {\DecoPivot {##1}}{\colorbox{LEFT}{##1}}}}%
+\def\DecoINERTwithPivot #1{\xdef\QS at pivotcount{\the\numexpr\QS at pivotcount+\@ne}%
+ \xintFor* ##1 in {#1} \do
+ {\xintifForFirst {\colorbox{INERTpiv}{##1}}{\colorbox{INERT}{##1}}}}%
+\def\DecoRIGHTwithPivot #1{\xdef\QS at pivotcount{\the\numexpr\QS at pivotcount+\@ne}%
+ \xintFor* ##1 in {#1} \do
+ {\xintifForFirst {\DecoPivot {##1}}{\colorbox{RIGHT}{##1}}}}%
+%
+\def\QuickSort #1{% warning: not compatible with empty #1.
+ % initialize, doing conversion from comma separated values to a list of braced items
+ \edef\QS at list{\noexpand\QSRr{\xintCSVtoList{#1}}}% many \edef's are to follow anyhow
+% earlier I did a first drawing of the list, here with the color of RIGHT elements,
+% but the color should have been for example white, anyway I drop this first line
+ %\let\QSRr\DecoRIGHT
+ %\par\centerline{\QS at list}%
+%
+ % loop as many times as needed
+ \QS at loop }%
+%
+% \catcode`? 12 % in case we had used a funny ? as delimiter.
+\makeatother
+%% End of macro definitions.
+%% Start of Example
+\begingroup\offinterlineskip
+\small
+% \QuickSort {1.0, 0.5, 0.3, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
+% 1.3, 1.1, 0.7, 1.6, 0.6, 0.9, 0.8, 0.2, 0.1, 1.9}
+% \medskip
+% with repeated values
+\QuickSort {1.0, 0.5, 0.3, 0.8, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
+ 1.3, 1.1, 0.7, 0.3, 1.6, 0.6, 0.3, 0.8, 0.2, 0.8, 0.7, 1.2}
+\endgroup
+\end{everbatim*}
+
+Here is the variant which always picks the pivot as the rightmost element.
+
+\begin{everbatim*}
+\makeatletter
+%
+\def\QS at cmp@a #1{\noexpand\QS at sep@A\expandafter\QS at cmp@d\expandafter
+ {\romannumeral0\xintnthelt{-1}{#1}}#1??}%
+%
+\def\DecoLEFTwithPivot #1{\xdef\QS at pivotcount{\the\numexpr\QS at pivotcount+\@ne}%
+ \xintFor* ##1 in {#1} \do
+ {\xintifForLast {\DecoPivot {##1}}{\colorbox{LEFT}{##1}}}}
+\def\DecoINERTwithPivot #1{\xdef\QS at pivotcount{\the\numexpr\QS at pivotcount+\@ne}%
+ \xintFor* ##1 in {#1} \do
+ {\xintifForLast {\colorbox{INERTpiv}{##1}}{\colorbox{INERT}{##1}}}}
+\def\DecoRIGHTwithPivot #1{\xdef\QS at pivotcount{\the\numexpr\QS at pivotcount+\@ne}%
+ \xintFor* ##1 in {#1} \do
+ {\xintifForLast {\DecoPivot {##1}}{\colorbox{RIGHT}{##1}}}}
+\def\QuickSort #1{%
+ % initialize, doing conversion from comma separated values to a list of braced items
+ \edef\QS at list{\noexpand\QSLr {\xintCSVtoList{#1}}}% many \edef's are to follow anyhow
+ %
+ % loop as many times as needed
+ \QS at loop }%
+\makeatother
+\begingroup\offinterlineskip
+\small
+% \QuickSort {1.0, 0.5, 0.3, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
+% 1.3, 1.1, 0.7, 1.6, 0.6, 0.9, 0.8, 0.2, 0.1, 1.9}
+% \medskip
+% with repeated values
+\QuickSort {1.0, 0.5, 0.3, 0.8, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
+ 1.3, 1.1, 0.7, 0.3, 1.6, 0.6, 0.3, 0.8, 0.2, 0.8, 0.7, 1.2}
+\endgroup
+\end{everbatim*}
+
+The choice of the first or last item as pivot is not a good one as nearly
+ordered lists will take quadratic time. But for explaining the algorithm via a
+graphical interpretation, it is not that bad. If one wanted to pick up the
+pivot randomly, the routine would have to be substantially rewritten: in
+particular the |\Deco..withPivot| macros need to know where the pivot is, and
+currently this is implemented by using either |\xintifForFirst| or
+|\xintifForLast|.
+
+\etocdepthtag.toc {macros}
\addtocontents{toc}{\gdef\string\sectioncouleur{{joli}}}
-
+\addtocontents{toc}{\gdef\string\SKIPSECTIONINTERSPACE{\kern\smallskipamount}}
\renewcommand{\etocaftertochook}{\addvspace{\bigskipamount}}
\clearpage
-\section{Commands of the \xintkernelname package}
+\section{Macros of the \xintkernelname package}
\label{sec:kernel}
\localtableofcontents
@@ -6599,15 +7938,15 @@
\leftedline{gives:
\ttfamily{\string\Stuff\string\to1002\string\xintiPow\string\xintDigitsOf}}
-\subsection{\csbh{xintLength}}\label{xintLength}
+\subsection{\csbh{xintLength}}
+\label{xintLength}
-\csa{xintLength}\marg{list}\etype{n} does not do \emph{any} expansion of its
-argument and just counts how many tokens there are (possibly none). So to use
-it to count things in the replacement text of a macro one should do
-|\expandafter\xintLength\expandafter{\x}|. One may also use it inside macros
-as |\xintLength{#1}|. Things enclosed in braces count as one. Blanks between
-tokens are not counted. See \csbxint{NthElt}|{0}| (from \xinttoolsname) for a
-variant which first \fexpan ds its argument.
+\csa{xintLength}\marg{list}\etype{n} counts how many tokens (or braced items)
+there are (possibly none). It does no expansion of its argument, so to use it
+to count things in the replacement text of a macro |\x| one should do
+|\expandafter\xintLength\expandafter{\x}|. Blanks between items are not
+counted. See also \csbxint{NthElt}|{0}| (from \xinttoolsname)
+which first \fexpan ds its argument and then applies the same code.
%
\leftedline{|\xintLength {\xintiPow {2}{100}}|\dtt{=\xintLength
{\xintiPow{2}{100}}}}
@@ -6615,8 +7954,64 @@
\leftedline{${}\neq{}$|\xintLen {\xintiPow {2}{100}}|\dtt{=\xintLen
{\xintiPow{2}{100}}}}
+\subsection{\csbh{xintLastItem}}
+\label{xintLastItem}
+
+\csa{xintLastItem}\marg{list}\etype{n} returns the last item (unbraced) of its
+argument. If the list has no items the output is empty.\NewWith{1.2i}
+
+It does no expansion, which should be obtained via suitable |\expandafter|'s.
+See also \csbxint{NthElt}|{-1}| from \xinttoolsname which obtains the same
+result (but with another code) after having however \fexpan ded its
+argument first.
+
+\subsection{\csbh{xintreplicate}}
+\label{xintreplicate}
+
+\csa{romannumeral}\csa{xintreplicate}|{x}|\marg{stuff}\etype{\numx n} is simply
+copied over from \LaTeX3's |\prg_replicate:nn| with some minor changes.%
+%
+\footnote{I started with the code from Joseph \textsc{Wright}'s answer to \url{http://tex.stackexchange.com/questions/16189/repeat-command-n-times}.}
+It\NewWith{1.2i}
+does not do any expansion of its second argument but inserts it in the upcoming
+token stream precisely |x| times. Using it with a negative |x| raises no error
+and does nothing.%
+%
+\footnote{This behavior may change in future.}
+
+Note that expansion must be triggered by a |\romannumeral|.
+
+
+\subsection{\csbh{xintgobble}}
+\label{xintgobble}
+\label{xintgobbleexpand}
+
+\csa{romannumeral}\csa{xintgobble}|{x}|\etype{\numx} is a Gobbling macro
+written in the spirit of \LaTeX3's |\prg_replicate:nn| (which I cloned as
+\csbxint{replicate}.)\NewWith{1.2i} It gobbles |x| tokens upstream, with |x| allowed to be
+as large as \dtt{531440}. Don't use it with |x<0|.
+
+
+Note that expansion must be triggered by a |\romannumeral|.
+
+\csbxint{gobble} looks as if it must be related to \csbxint{Trim} from
+\xinttoolsname, but the latter uses different code (using directly
+\csbxint{gobble} is not possible because one must make sure not to gobble more
+than the number of available items; and counting available items first is an
+overhead which \csbxint{Trim} avoids.) It is rather\csbxint{Keep} with a
+negative first argument which hands over to \csbxint{gobble} (because in that
+case it is needed to count anyhow beforehand the number of items, hence
+\csbxint{gobble} can then be used safely.)
+
+I wrote an \csa{xintcount} in the same spirit as \csa{xintreplicate} and
+\csa{xintgobble}. But it needs to be counting hundreds of tokens to be worth
+its salt compared to \csbxint{Length}.
+
+
\clearpage
-\section{Commands of the \xinttoolsname package}
+\section{Macros of the \xinttoolsname package}
+
+
\label{sec:tools}
\localtableofcontents
@@ -6787,7 +8182,7 @@
convention in this manual simply a succession of tokens, where each braced thing
will count as one item (``items'' are defined according to the rules of \TeX{}
for fetching undelimited parameters of a macro, which are exactly the same rules
-as for \LaTeX{} and command arguments [they are the same things]). The word
+as for \LaTeX{} and macro arguments [they are the same things]). The word
`list' in `comma separated list of items' has its usual linguistic meaning,
and then an ``item'' is what is delimited by commas.
@@ -6929,10 +8324,12 @@
\def\macro #1{\the\numexpr 9-#1\relax}
-\csa{xintNthElt\x}\marg{list}\etype{\numx f} gets (expandably) the |x|th braced
-item of the \meta{list}. An unbraced item token will be returned as is. The list
-itself may be a macro which is first \fexpan ded.
+\csa{xintNthElt\x}\marg{list}\etype{\numx f} gets (expandably) the |x|th
+item of the \meta{list}. A braced item will lose one level of brace
+pairs. The token list is first \fexpan ded.
+Items are counted starting at one.
+
\leftedline{|\xintNthElt {3}{{agh}\u{zzz}\v{Z}}| is
\texttt{\xintNthElt {3}{{agh}\u{zzz}\v{Z}}}}
%
@@ -6970,6 +8367,7 @@
\csbxint{Len} which is to be used only on integers or fractions.
If |x<0|, the macro returns the \verb+|x|+th element from the end of the list.
+Thus for example |x=-1| will fetch the last item of the list.
%
\leftedline {|\xintNthElt {-5}{{{agh}}\u{zzz}\v{Z}}| is
\texttt{\expandafter\expandafter\expandafter \detokenize
@@ -6979,28 +8377,29 @@
first expanding the list argument: |\xintNthEltNoExpand {-4}{\u\v\w T\x\y\z}| is
\xintNthEltNoExpand {-4}{\a\b\c\u\v\w T\x\y\z}.
-In cases where |x| is larger (in absolute value) than the length of the list
-then |\xintNthElt| returns nothing.
+If |x| is strictly larger (in absolute value) than the length of the list
+then |\xintNthElt| produces empty contents.
\subsection{\csbh{xintKeep}}\label{xintKeep}
-\csa{xintKeep\x}\marg{list}\etype{\numx f} expands the token list argument and
-returns a new list containing only the first |x| items. If |x<0| the macro
-returns the last \verb+|x|+ elements (in the same order as in the initial
-list). If \verb+|x|+ equals or exceeds the length of the list, the list (as
-arising from expansion of the second argument) is returned. For |x=0| the
-empty list is returned.
+\csa{xintKeep\x}\marg{list}\etype{\numx f} expands the token list argument |L|
+and produces a new list, depending on the value of |x|:
+\begin{itemize}[nosep]
+\item if |x>0|, the new list contains the first |x| items from |L| (counting
+ starts at one.) \emph{Each
+ such item will be output within a brace pair.} Use \csbxint{KeepUnbraced} is
+ this is not desired. This means that if the list item was braced to start
+ with, there is no modification, but if it was a token without braces,
+ then it acquires them.
+\item if |x>=length(L)|, the new list is the old one with all its items now
+ braced.
+\item if |x=0| the empty list is returned.
+\item if |x<0| the last \verb+|x|+ elements compose the output in the same
+ order as in the initial list; as the macro proceeds by removing head items
+ the kept items end up in output as they were in input: no added braces.
+\item if |x<=-length(L)| the output is identical with the input.
+\end{itemize}
-If |x>0| the (non space) items from the original end up braced in the
-output: if one later wants to remove all brace pairs (either added to a naked
-token, or initially present), one may use \csbxint {ListWithSep} with an empty
-separator.
-
-On the other hand, if |x<0| the macro acts by suppressing items from the head
-of the list, and no brace pairs are added to the kept elements from the tail
-(originally present ones are not removed).\MyMarginNote{\noindent Description
- corrected in 1.2a doc}
-
\csa{xintKeepNoExpand} does the same without first \fexpan ding its list
argument.
%
@@ -7011,16 +8410,23 @@
\noindent\fdef\test {\xintKeep {7}{123456789}}\meaning\test\par
\noindent\fdef\test {\xintKeep {-7}{123456789}}\meaning\test\par
\end{everbatim*}
-%
+
\subsection{\csbh{xintKeepUnbraced}}\label{xintKeepUnbraced}
-Sames as \csbxint{Keep} but no brace pairs are added around the kept items
-from the head of the list. Each item will lose one level of brace pairs. For
-|x<0| is not different from \csbxint{Keep}.\NewWith{1.2a}
+Same as \csbxint{Keep} but no brace pairs are added around the kept items from
+the head of the list in the case |x>0|: each such item will lose one level of
+braces. Thus, to remove braces from all items of the list, one can use
+\csbxint{KeepUnbraced} with its first argument larger than the length of the
+list; the same is obtained from \csbxint{ListWithSep}|{}|\marg{list}. But the
+new list will then have generally many more items than the original ones,
+corresponding to the unbraced original items.
-\csa{xintKeepUnbracedNoExpand} does the same without first \fexpan ding its list
-argument.
+For |x<0| the macro is no different from \csbxint{Keep}. Hence the name is a
+bit misleading because brace removal will happen only if |x>0|.
+
+\csa{xintKeepUnbracedNoExpand} does the same without first \fexpan ding
+its list argument.
%
\begin{everbatim*}
\fdef\test {\xintKeepUnbraced {10}{\xintSeq {1}{100}}}\meaning\test\par
@@ -7033,11 +8439,17 @@
\subsection{\csbh{xintTrim}}\label{xintTrim}
\csa{xintTrim\x}\marg{list}\etype{\numx f} expands the list argument and
-gobbles its first |x| elements. The remaining ones are left as they are (no
-brace pairs added). If |x<0| the macro gobbles the last \verb+|x|+
-elements, and the kept elements from the head of the list end up braced in the
-output. If \verb+|x|+ equals or exceeds the length
-of the list, the empty list is returned. For |x=0| the full list is returned.
+gobbles its first |x| elements.
+\begin{itemize}[nosep]
+\item if |x>0|, the first |x| items from |L| are gobbled. The remaining items
+ are not modified.
+\item if |x>=length(L)|, the returned list is empty.
+\item if |x=0| the original list is returned (with no added braces.)
+\item if |x<0| the last \verb+|x|+ items of the list are removed. \emph{The
+ head items end up braced in the output.} Use \csbxint{TrimUnbraced} if
+ this is not desired.
+\item if |x<=-length(L)| the output is empty.
+\end{itemize}
\csa{xintTrimNoExpand} does the same without first \fexpan ding its list
argument.
@@ -7053,7 +8465,9 @@
Same as \csbxint{Trim} but in case of a negative |x| (cutting items from
the tail), the kept items from the head are not enclosed in brace pairs. They
-will lose one level of braces.\NewWith{1.2a}
+will lose one level of braces. The name is a bit misleading
+because when |x>0| there is no brace-stripping done on the kept items, because
+the macro works simply by gobbling the head ones.
\csa{xintTrimUnbracedNoExpand} does the same without first \fexpan ding its list
argument.
@@ -7071,19 +8485,20 @@
\def\macro #1{\the\numexpr 9-#1\relax}
-\csa{xintListWithSep}|{sep}|\marg{list}\etype{nf} inserts the given separator
-|sep| in-between all items of the given list of braced items: this separator may
-be a macro (or multiple tokens) but will not be expanded. The second argument
-also may be itself a macro: it is \fexpan ded. Applying \csa{xintListWithSep}
-removes the braces from the list items (for example |{1}{2}{3}| turns into
-\dtt{\xintListWithSep,{123}} via |\xintListWithSep{,}{{1}{2}{3}}|). An
-empty input gives an empty output, a singleton gives a singleton, the separator
-is used starting with at least two elements. Using an empty separator has the
-net effect of unbracing the braced items constituting the \meta{list} (in such
-cases the new list may thus be longer than the original).
+\csa{xintListWithSep}|{sep}|\marg{list}\etype{nf} inserts the separator |sep|
+in-between all items of the given list. The items will be unbraced. The
+separator may be a macro but will not be pre-expanded. The list argument is
+\fexpan ded.
+\begin{everbatim*}
+\edef\foo {\xintListWithSep{,}{{1}{2}{3}}}\meaning\foo\newline
+\edef\foo {\xintListWithSep{:}{\xintiiFac{20}}}\meaning\foo\par
+\end{everbatim*}
+An empty input gives an empty output, a singleton gives a singleton, and the
+separator is used starting with at least two elements. Using an empty
+separator has the net effect of unbracing the braced items constituting the
+\meta{list} (then the new list will generally have many more ``items'' than
+the original one).
%
-\leftedline{|\xintListWithSep{:}{\xintiiFac
- {20}}|\dtt{=\xintListWithSep{:}{\xintiiFac {20}}}}
The macro \csa{xintListWithSepNoExpand}\etype{nn} does the same
job without the initial expansion.
@@ -7094,7 +8509,7 @@
\def\macro #1{\the\numexpr 9-#1\relax}
\csa{xintApply}|{\macro}|\marg{list}\etype{ff} expandably applies the one
-parameter command |\macro| to each item in the \meta{list} given as second
+parameter macro |\macro| to each item in the \meta{list} given as second
argument and returns a new list with these outputs: each item is given one after
the other as parameter to |\macro| which is expanded at that time (as usual,
\emph{i.e.} fully for what comes first), the results are braced and output
@@ -7113,7 +8528,7 @@
The \meta{list} may
itself be some macro expanding (in the previously described way) to the list of
-tokens to which the command |\macro| will be applied. For example, if the
+tokens to which the macro |\macro| will be applied. For example, if the
\meta{list} expands to some positive number, then each digit will be replaced by
the result of applying |\macro| on it. %
%
@@ -7186,193 +8601,7 @@
efficiently) and does not stress the input save stack.
-\subsection{Completely expandable prime test}\label{ssec:primesI}
-Let us now construct a completely expandable macro which returns $1$ if its
-given input is prime and $0$ if not:
-\everb|@
-\def\remainder #1#2{\the\numexpr #1-(#1/#2)*#2\relax }
-\def\IsPrime #1%
- {\xintANDof {\xintApply {\remainder {#1}}{\xintSeq {2}{\xintiSqrt{#1}}}}}
-|
-
-This uses \csbxint{iSqrt} and assumes its input is at least $5$. Rather than
-\xintname's own \csbxint{iRem} we used a quicker |\numexpr| expression as we
-are dealing with short integers. Also we used \csbxint{ANDof} which will
-return $1$ only if all the items are non-zero. The macro is a bit
-silly with an even input, ok, let's enhance it to detect an even input:
-\everb|@
-\def\IsPrime #1%
- {\xintifOdd {#1}
- {\xintANDof % odd case
- {\xintApply {\remainder {#1}}
- {\xintSeq [2]{3}{\xintiSqrt{#1}}}%
- }%
- }
- {\xintifEq {#1}{2}{1}{0}}%
- }
-|
-
-We used the \xintname provided expandable tests (on big integers or fractions)
-in oder for |\IsPrime| to be \fexpan dable.
-
-Our integers are short, but without |\expandafter|'s with
-|\@firstoftwo|, % @ n'est plus actif dans le dtx 1.1 !
-or some other related techniques,
-direct use of |\ifnum..\fi| tests is dangerous. So to make the macro more
-efficient we are going to use the expandable tests provided by the package
-\href{http://ctan.org/pkg/etoolbox}{etoolbox}%
-%
-\footnote{\url{http://ctan.org/pkg/etoolbox}}.
-%
-The macro becomes:
-%
-\everb|@
-\def\IsPrime #1%
- {\ifnumodd {#1}
- {\xintANDof % odd case
- {\xintApply {\remainder {#1}}{\xintSeq [2]{3}{\xintiSqrt{#1}}}}}
- {\ifnumequal {#1}{2}{1}{0}}}
-|
-
-In the odd case however we have to assume the integer is at least $7$, as
-|\xintSeq| generates an empty list if |#1=3| or |5|, and |\xintANDof| returns
-$1$ when supplied an empty list. Let us ease up a bit |\xintANDof|'s work by
-letting it work on only $0$'s and $1$'s. We could use:
-%
-\everb|@
-\def\IsNotDivisibleBy #1#2%
- {\ifnum\numexpr #1-(#1/#2)*#2=0 \expandafter 0\else \expandafter1\fi}
-|
-\noindent
-where the |\expandafter|'s are crucial for this macro to be \fexpan dable and
-hence work within the applied \csbxint{ANDof}. Anyhow, now that we have loaded
-\href{http://ctan.org/pkg/etoolbox}{etoolbox}, we might as well use:
-%
-\everb|@
-\newcommand{\IsNotDivisibleBy}[2]{\ifnumequal{#1-(#1/#2)*#2}{0}{0}{1}}
-|
-\noindent
-Let us enhance our prime macro to work also on the small primes:
-\everb|@
-\newcommand{\IsPrime}[1] % returns 1 if #1 is prime, and 0 if not
- {\ifnumodd {#1}
- {\ifnumless {#1}{8}
- {\ifnumequal{#1}{1}{0}{1}}% 3,5,7 are primes
- {\xintANDof
- {\xintApply
- { \IsNotDivisibleBy {#1}}{\xintSeq [2]{3}{\xintiSqrt{#1}}}}%
- }}% END OF THE ODD BRANCH
- {\ifnumequal {#1}{2}{1}{0}}% EVEN BRANCH
-}
-|
-
-The input is still assumed positive. There is a deliberate blank before
-\csa{IsNotDivisibleBy} to use this feature of \csbxint{Apply}: a space stops the
-expansion of the applied macro (and disappears). This expansion will be done by
-\csbxint{ANDof}, which has been designed to skip everything as soon as it finds
-a false (i.e. zero) input. This way, the efficiency is considerably improved.
-
-We did generate via the \csbxint{Seq} too many potential divisors though. Later
-sections give two variants: one with \csbxint{iloop} (\autoref{ssec:primesII})
-which is still expandable and another one (\autoref{ssec:primesIII}) which is a
-close variant of the |\IsPrime| code above but with the \csbxint{For} loop, thus
-breaking expandability. The \hyperref[ssec:primesII]{xintiloop variant} does not
-first evaluate the integer square root, the \hyperref[ssec:primesIII]{xintFor
- variant} still does. I did not compare their efficiencies.
-
-
-Let us construct with this expandable primality test a table of the prime
-numbers up to $1000$. We need to count how many we have in order to know how
-many tab stops one shoud add in the last row.%
-%
-\footnote{although a tabular row may have less tabs than in the
- preamble, there is a problem with the \char`\|\space\space vertical
- rule, if one does that.}
-%
-There is some subtlety for this
-last row. Turns out to be better to insert a |\\| only when we know for sure we
-are starting a new row; this is how we have designed the |\OneCell| macro. And
-for the last row, there are many ways, we use again |\xintApplyUnbraced| but
-with a macro which gobbles its argument and replaces it with a tabulation
-character. The \csbxint{For*} macro would be more elegant here.
-%
-\everb?@
-\newcounter{primecount}
-\newcounter{cellcount}
-\newcommand{\NbOfColumns}{13}
-\newcommand{\OneCell}[1]{%
- \ifnumequal{\IsPrime{#1}}{1}
- {\stepcounter{primecount}
- \ifnumequal{\value{cellcount}}{\NbOfColumns}
- {\\\setcounter{cellcount}{1}#1}
- {&\stepcounter{cellcount}#1}%
- } % was prime
- {}% not a prime, nothing to do
-}
-\newcommand{\OneTab}[1]{&}
-\begin{tabular}{|*{\NbOfColumns}{r}|}
-\hline
-2 \setcounter{cellcount}{1}\setcounter{primecount}{1}%
- \xintApplyUnbraced \OneCell {\xintSeq [2]{3}{999}}%
- \xintApplyUnbraced \OneTab
- {\xintSeq [1]{1}{\the\numexpr\NbOfColumns-\value{cellcount}\relax}}%
- \\
-\hline
-\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
-cells (which doesn't happen here but would with a number of columns dividing
-$168$).
-%
-\newcommand{\IsNotDivisibleBy}[2]{\ifnumequal{#1-(#1/#2)*#2}{0}{0}{1}}
-
-\newcommand{\IsPrime}[1]
- {\ifnumodd {#1}
- {\ifnumless {#1}{8}
- {\ifnumequal{#1}{1}{0}{1}}% 3,5,7 are primes
- {\xintANDof
- {\xintApply
- { \IsNotDivisibleBy {#1}}{\xintSeq [2]{3}{\xintiSqrt{#1}}}}%
- }}% END OF THE ODD BRANCH
- {\ifnumequal {#1}{2}{1}{0}}% EVEN BRANCH
-}
-
-\newcounter{primecount}
-\newcounter{cellcount}
-\newcommand{\NbOfColumns}{13}
-\newcommand{\OneCell}[1]
- {\ifnumequal{\IsPrime{#1}}{1}
- {\stepcounter{primecount}
- \ifnumequal{\value{cellcount}}{\NbOfColumns}
- {\\\setcounter{cellcount}{1}#1}
- {&\stepcounter{cellcount}#1}%
- } % was prime
- {}% not a prime nothing to do
-}
-\newcommand{\OneTab}[1]{&}
-\begin{figure*}[ht!]
- \centering
- \phantomsection\label{primesupto1000}
- \begin{tabular}{|*{\NbOfColumns}{r}|}
- \hline
- 2\setcounter{cellcount}{1}\setcounter{primecount}{1}%
- \xintApplyUnbraced \OneCell {\xintSeq [2]{3}{999}}%
- \xintApplyUnbraced \OneTab
- {\xintSeq [1]{1}{\the\numexpr\NbOfColumns-\value{cellcount}\relax}}%
- \\
- \hline
- \end{tabular}
-\smallskip
-\centeredline{There are \arabic{primecount} prime numbers up to 1000.}
-\end{figure*}
-
\subsection{\csbh{xintloop}, \csbh{xintbreakloop}, \csbh{xintbreakloopanddo}, \csbh{xintloopskiptonext}}
\label{xintloop}
\label{xintbreakloop}
@@ -7383,7 +8612,7 @@
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.
+macros 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
@@ -7681,145 +8910,6 @@
\ifnum\xintiloopindex<30 \repeat }
\end{everbatim}
-
-\subsection{Another completely expandable prime test}\label{ssec:primesII}
-
-The |\IsPrime| macro from \autoref{ssec:primesI} checked expandably if a (short)
-integer was prime, here is a partial rewrite using \csbxint{iloop}. We use the
-|etoolbox| expandable conditionals for convenience, but not everywhere as
-|\xintiloopindex| can not be evaluated while being braced. This is also the
-reason why |\xintbreakiloopanddo| is delimited, and the next macro
-|\SmallestFactor| which returns the smallest prime factor examplifies that. One
-could write more efficient completely expandable routines, the aim here was only
-to illustrate use of the general purpose \csbxint{iloop}. A little table giving
-the first values of |\SmallestFactor| follows, its coding uses \csbxint{For},
-which is described later; none of this uses count registers.
-%
-
-
-\begin{everbatim*}
-\let\IsPrime\undefined \let\SmallestFactor\undefined % clean up possible previous mess
-\newcommand{\IsPrime}[1] % returns 1 if #1 is prime, and 0 if not
- {\ifnumodd {#1}
- {\ifnumless {#1}{8}
- {\ifnumequal{#1}{1}{0}{1}}% 3,5,7 are primes
- {\if
- \xintiloop [3+2]
- \ifnum#1<\numexpr\xintiloopindex*\xintiloopindex\relax
- \expandafter\xintbreakiloopanddo\expandafter1\expandafter.%
- \fi
- \ifnum#1=\numexpr (#1/\xintiloopindex)*\xintiloopindex\relax
- \else
- \repeat 00\expandafter0\else\expandafter1\fi
- }%
- }% END OF THE ODD BRANCH
- {\ifnumequal {#1}{2}{1}{0}}% EVEN BRANCH
-}%
-\catcode`_ 11
-\newcommand{\SmallestFactor}[1] % returns the smallest prime factor of #1>1
- {\ifnumodd {#1}
- {\ifnumless {#1}{8}
- {#1}% 3,5,7 are primes
- {\xintiloop [3+2]
- \ifnum#1<\numexpr\xintiloopindex*\xintiloopindex\relax
- \xint_afterfi{\xintbreakiloopanddo#1.}%
- \fi
- \ifnum#1=\numexpr (#1/\xintiloopindex)*\xintiloopindex\relax
- \xint_afterfi{\expandafter\xintbreakiloopanddo\xintiloopindex.}%
- \fi
- \iftrue\repeat
- }%
- }% END OF THE ODD BRANCH
- {2}% EVEN BRANCH
-}%
-\catcode`_ 8
-{\centering
- \begin{tabular}{|c|*{10}c|}
- \hline
- \xintFor #1 in {0,1,2,3,4,5,6,7,8,9}\do {&\bfseries #1}\\
- \hline
- \bfseries 0&--&--&2&3&2&5&2&7&2&3\\
- \xintFor #1 in {1,2,3,4,5,6,7,8,9}\do
- {\bfseries #1%
- \xintFor #2 in {0,1,2,3,4,5,6,7,8,9}\do
- {&\SmallestFactor{#1#2}}\\}%
- \hline
- \end{tabular}\par
-}
-\end{everbatim*}
-
-\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
-here, just handling the row index, the row contents being almost entirely
-produced via a macro |\factorize|. The factorizing macro does not use
-|\xintiloop| as it didn't appear to be the convenient tool. As |\factorize| will
-have to be used on |\xintiloopindex|, it has been defined as a delimited macro.
-
-To spare some fractions of a second in the compilation time of this document
-(which has many many other things to do), \number"7FFFFFED{} and
-\number"7FFFFFFF, which turn out to be prime numbers, are not given to
-|factorize| but just typeset directly; this illustrates use of
-\csbxint{iloopskiptonext}.
-
-The code next generates a \hyperref[floatfactorize]{table} which has
-been made into a float appearing \vpageref{floatfactorize}. Here is now
-the code for factorization; the conditionals use the package provided
-|\xint_firstoftwo| and |\xint_secondoftwo|, one could have employed
-rather \LaTeX{}'s own |\@firstoftwo| and |\@secondoftwo|, or, simpler
-still in \LaTeX{} context, the |\ifnumequal|, |\ifnumless| \dots,
-utilities from the package |etoolbox| which do exactly that under the
-hood. Only \TeX{} acceptable numbers are treated here, but it would be
-easy to make a translation and use the \xintname macros, thus extending
-the scope to big numbers; naturally up to a cost in speed.
-
-The reason for some strange looking expressions is to avoid arithmetic overflow.
-
-\begin{everbatim*}
-\catcode`_ 11
-\def\abortfactorize #1\xint_secondoftwo\fi #2#3{\fi}
-
-\def\factorize #1.{\ifnum#1=1 \abortfactorize\fi
- \ifnum\numexpr #1-2=\numexpr ((#1/2)-1)*2\relax
- \expandafter\xint_firstoftwo
- \else\expandafter\xint_secondoftwo
- \fi
- {2&\expandafter\factorize\the\numexpr#1/2.}%
- {\factorize_b #1.3.}}%
-
-\def\factorize_b #1.#2.{\ifnum#1=1 \abortfactorize\fi
- \ifnum\numexpr #1-(#2-1)*#2<#2
- #1\abortfactorize
- \fi
- \ifnum \numexpr #1-#2=\numexpr ((#1/#2)-1)*#2\relax
- \expandafter\xint_firstoftwo
- \else\expandafter\xint_secondoftwo
- \fi
- {#2&\expandafter\factorize_b\the\numexpr#1/#2.#2.}%
- {\expandafter\factorize_b\the\numexpr #1\expandafter.%
- \the\numexpr #2+2.}}%
-\catcode`_ 8
-\begin{figure*}[ht!]
-\centering\phantomsection\label{floatfactorize}\normalcolor
-\tabskip1ex
-\centeredline{\vbox{\halign {\hfil\strut#\hfil&&\hfil#\hfil\cr\noalign{\hrule}
- \xintiloop ["7FFFFFE0+1]
- \expandafter\bfseries\xintiloopindex &
- \ifnum\xintiloopindex="7FFFFFED
- \number"7FFFFFED\cr\noalign{\hrule}
- \expandafter\xintiloopskiptonext
- \fi
- \expandafter\factorize\xintiloopindex.\cr\noalign{\hrule}
- \ifnum\xintiloopindex<"7FFFFFFE
- \repeat
- \bfseries \number"7FFFFFFF&\number "7FFFFFFF\cr\noalign{\hrule}
-}}}
-\centeredline{A table of factorizations}
-\end{figure*}
-\end{everbatim*}
-
\begin{framed}
The next utilities are not compatible with expansion-only context.
\end{framed}
@@ -7915,8 +9005,9 @@
\subsection{\csbh{xintFor}, \csbh{xintFor*}}\label{xintFor}\label{xintFor*}
-\csbxint{For}\ntype{on} is a new kind of for loop. Rather than using macros
-for encapsulating list items, its behavior is more like a macro with parameters:
+\csbxint{For}\ntype{on} is a new kind of for loop.\footnote{first introduced
+ with \xintname |1.09c| of |2013/10/09|.} Rather than using macros
+for encapsulating list items, its behavior is like a macro with parameters:
|#1|, |#2|, \dots, |#9| are used to represent the items for up to nine levels of
nested loops. Here is an example:
%
@@ -7935,90 +9026,111 @@
separated list and the replacement text.
\begin{framed}
- A macro |\macro| whose definition uses internally an \csbxint{For} loop may be
- used inside another \csbxint{For} loop even if the two loops both use the same
- macro parameter. Note: the loop definition inside |\macro| must double
- the character |#| as is the general rule in \TeX{} with definitions done
- inside macros.
+ \TeX nical notes:
- The macros \csa{xintFor} and \csa{xintFor*} are not expandable, one can not
- use them inside an |\edef|. But they may be used inside alignments (such as a
- \LaTeX{} |tabular|), as will be shown in examples.
-\end{framed}
+\begin{itemize}
+ \item The |#1| is replaced in the iterated-over text exactly as in general
+ \TeX\ macros or \LaTeX\ commands. This spares the user quite a few
+ |\expandafter|'s or other tricks needed with loops which have the
+ values encapsulated in macros, like \LaTeX's |\@for| and |\@tfor|.
-The spaces between the various declarative elements are all optional;
-furthermore spaces around the commas or at the start and end of the list
-argument are allowed, they will be removed. If an item must contain itself
-commas, it should be braced to prevent these commas from being misinterpreted as
-list separator. These braces will be removed during processing. The list
-argument may be a macro |\MyList| expanding in one step to the comma separated
-list (if it has no arguments, it does not have to be braced). It
-will be expanded (only once) to reveal its comma separated items for processing,
-comma separated items will not be expanded before being fed into the replacement
-text as |#1|, or |#2|, etc\dots, only leading and trailing spaces are removed.
+ \item \csa{xintFor} (and \csa{xintFor*}) isn't purely expandable: one can
+ not use it inside an |\edef|. But it may be used, as will be shown in
+ examples, in some contexts such as \LaTeX's |tabular| which are usually
+ hostile to non-expandable loops.
+
+ \item \csa{xintFor} (and \csa{xintFor*}) does some assignments prior to
+ executing each iteration of the replacement text, but it acts purely
+ expandably after the last iteration, hence if for example the replacement
+ text ends with a |\\|, the loop can be used insided a tabular and be
+ followed by a |\hline| without creating the dreaded ``|Misplaced
+ \noalign|'' error.
-A starred variant \csbxint{For*}\ntype{{\lowast f}n} deals with lists of braced
-items, rather than comma separated items. It has also a distinct expansion
-policy, which is detailed below.
+ \item It does not create groups.
-Contrarily to what happens in loops where the item is represented by a macro,
-here it is truly exactly as when defining (in \LaTeX{}) a ``command'' with
-parameters |#1|, etc... This may avoid the user quite a few troubles with
-|\expandafter|s or other |\edef/\noexpand|s which one encounters at times when
-trying to do things with \LaTeX's {\makeatother|\@for|} or other loops
-which encapsulate the item in a macro expanding to that item.
+ \item It makes no global assignments.
-\begin{framed}
- The non-starred variant \csbxint{For} deals with comma separated values
- (\emph{spaces before and after the commas are removed}) and the comma
- separated list may be a macro which is only expanded once (to prevent
- expansion of the first item |\x| in a list directly input as |\x,\y,...| it
- should be input as |{\x},\y,..| or |<space>\x,\y,..|, naturally all of that
- within the mandatory braces of the \csa{xintFor \#n in \{list\}} syntax). The
- items are not expanded, if the input is |<stuff>,\x,<stuff>| then |#1| will be
- at some point |\x| not its expansion (and not either a macro with |\x| as
- replacement text, just the token |\x|). Input such as |<stuff>,,<stuff>|
- creates an empty |#1|, the iteration is not skipped. An empty list does lead
- to the use of the replacement text, once, with an empty |#1| (or |#n|). Except
- if the entire list is represented as a single macro with no parameters,
- \fbox{it must be braced.}
-\end{framed}
+ \item The iterated replacement text may close a group which was opened even
+ before the start of the loop (typical example being with |&| in
+ alignments).
+\begin{everbatim*}
+\begin{tabular}{rccccc}
+ \hline
+ \xintFor #1 in {A, B, C} \do {%
+ #1:\xintFor #2 in {a, b, c, d, e} \do {&($ #2 \to #1 $)}\\ }%
+ \hline
+\end{tabular}
+\end{everbatim*}
+
+ \item There is no facility provided which would give access to a count of
+ the number of iterations as it is technically not easy to do so it in a
+ way working with nested loops while maintaining the ``expandable after
+ done'' property; something in the spirit of \csbxint{iloopindex} is
+ possible but this approach would bring its own limitations and
+ complications. Hence the user is invited to update her own count or
+ \LaTeX{} counter or macro at each iteration, if needed.
-\begin{framed}
- The starred variant \csbxint{For*} deals with token lists (\emph{spaces
- between braced items or single tokens are not significant}) and
- \hyperref[ssec:expansions]{\fexpan ds} each \emph{unbraced} list item. This
- makes it easy to simulate concatenation of various list macros |\x|, |\y|, ...
- If |\x| expands to |{1}{2}{3}| and |\y| expands to |{4}{5}{6}| then |{\x\y}|
- as argument to |\xintFor*| has the same effect as |{{1}{2}{3}{4}{5}{6}}|%
- \stepcounter{footnote}%
- \makeatletter\hbox {\@textsuperscript {\normalfont \thefootnote
- }}\makeatother. Spaces at the start, end, or in-between items are gobbled
- (but naturally not the spaces which may be inside \emph{braced} items). Except
- if the list argument is a single macro with no parameters, \fbox{it must be
- braced.} Each item which is not braced will be fully expanded (as the |\x|
- and |\y| in the example above). An empty list leads to an empty result.
+ \item A |\macro| whose definition uses internally an \csbxint{For} loop
+ may be used inside another \csbxint{For} loop even if the two loops both
+ use the same macro parameter. The loop definition inside |\macro|
+ must use |##| as is the general rule for definitions done inside macros.
+
+ \item \csbxint{For} is for comma separated values and \csbxint{For*} for
+ lists of braced items; their respective expansion policies differ. They
+ are described later.
+\end{itemize}
+\unskip
\end{framed}
-\begingroup\makeatletter
-\def\@footnotetext #1{\insert\footins {\reset at font \footnotesize \interlinepenalty \interfootnotelinepenalty \splittopskip \footnotesep \splitmaxdepth \dp \strutbox \floatingpenalty \@MM \hsize \columnwidth \@parboxrestore \color at begingroup \@makefntext {\rule \z@ \footnotesep \ignorespaces #1\@finalstrut \strutbox }\color at endgroup }}
-\addtocounter{footnote}{-1}
-\edef\@thefnmark {\thefootnote}
-\@footnotetext{braces around single token items
- are optional so this is the same as \texttt{\{123456\}}.}
-\endgroup
-\addtocounter{Hfootnote}{1}
-The macro \csbxint{Seq} which generates arithmetic sequences may only be used
-with \csbxint{For*} (numbers from output of |\xintSeq| are braced, not separated
-by commas). %
-%
-\leftedline{|\xintFor* #1 in {\xintSeq [+2]{-7}{+2}}\do {stuff
- with #1}|} will have |#1=-7,-5,-3,-1, and 1|. The |#1| as issued from the
-list produced by \csbxint{Seq} is the litteral representation as would be
-produced by |\arabic| on a \LaTeX{} counter, it is not a count register. When
-used in |\ifnum| tests or other contexts where \TeX{} looks for a number it
-should thus be postfixed with |\relax| or |\space|.
+Regarding \csbxint{For}:
+\begin{itemize}[nosep, listparindent=\leftmarginiii]
+\item the spaces between the various declarative elements are all optional,
+\item in the list of comma separated values, spaces around the commas or at
+ the start and end are ignored,
+\item if an item must contain itself its own commas, then it should
+ be braced, and the braces will be removed before feeding the iterated-over
+ text,
+\item the list may be a macro, it is expanded only once,
+\item items are not pre-expanded. The first item should be braced or start
+ with a space if the list is explicit and the item should not be
+ pre-expanded,
+\item empty items give empty |#1|'s in the replacement text, they are not
+ skipped,
+\item an empty list executes once the replacement text with an empty parameter
+ value,
+\item the list, if not a macro, \fbox{must be braced.}
+\end{itemize}
+Regarding \csbxint{For*}:\ntype{{\lowast f}n}
+\begin{itemize}[nosep, listparindent=\leftmarginiii]
+\item it handles lists of braced items (or naked tokens),
+\item it \hyperref[ssec:expansions]{\fexpan ds} the list,
+\item and more generally it \hyperref[ssec:expansions]{\fexpan ds} each naked
+ token encountered
+ before assigning the |#1| values (gobbling spaces in the process);
+ this
+ makes it easy to simulate concatenation of multiple lists|\x|, |\y|:
+ if |\x| expands to |{1}{2}{3}| and |\y| expands to |{4}{5}{6}| then |{\x\y}|
+ as argument to |\xintFor*| has the same effect as |{{1}{2}{3}{4}{5}{6}}|.
+
+ For a further illustration see the use of |\xintFor*| at the end of
+ \autoref{ssec:fibonacci}.
+\item spaces at the start, end, or in-between items are gobbled (but naturally
+ not the spaces inside \emph{braced} items),
+\item except if the list argument is a macro (with no parameters), \fbox{it
+ must be braced.},
+\item an empty list leads to an empty result.
+\end{itemize}
+
+The macro \csbxint{Seq} which generates arithmetic sequences is to be used
+with \csbxint{For*} as its output consists of successive braced numbers (given
+as digit tokens).
+\begin{everbatim*}
+\xintFor* #1 in {\xintSeq [+2]{-7}{+2}}\do {stuff
+ with #1\xintifForLast{\par}{\newline}}
+\end{everbatim*}
+
+
When nesting \csa{xintFor*} loops, using \csa{xintSeq} in the inner loops is
inefficient, as the arithmetic sequence will be re-created each time. A more
efficient style is:
@@ -8032,28 +9144,10 @@
This is a general remark applying for any nesting of loops, one should avoid
recreating the inner lists of arguments at each iteration of the outer loop.
-However, in the example above, if the |.. some other macros ..| part
-closes a group which was opened before the |\edef\innersequence|, then
-this definition will be lost. An alternative to |\edef|, also efficient,
-exists when dealing with arithmetic sequences: it is to use the
-\csbxint{integers} keyword (described later) which simulates infinite
-arithmetic sequences; the loops will then be terminated via a test |#1|
-(or |#2| etc\dots) and subsequent use of \csbxint{BreakFor}.
-The \csbxint{For} loops are not completely expandable; but they may be nested
-and used inside alignments or other contexts where the replacement text closes
-groups. Here is an example (still using \LaTeX's tabular):
-\begin{everbatim*}
-\begin{tabular}{rccccc}
- \xintFor #7 in {A,B,C} \do {%
- #7:\xintFor* #3 in {abcde} \do {&($ #3 \to #7 $)}\\ }%
-\end{tabular}
-\end{everbatim*}
-
-When
-inserted inside a macro for later execution the |#| characters must be
-doubled.%
+When the loop is defined inside a macro for later execution the |#| characters
+must be doubled.%
%
\footnote{sometimes what seems to be a macro argument isn't really; in
\csa{raisebox\{1cm\}\{}\csa{xintFor \#1 in \{a,b,c\} }\csa{do
@@ -8075,32 +9169,11 @@
of |\xintFor| defines a macro with parameters, the macro character |#| must be
doubled.
-It is licit to use inside an \csbxint{For} a |\macro| which itself has
-been defined to use internally some other \csbxint{For}. The same macro
-parameter |#1| can be used with no conflict (as mentioned above, in the
-definition of |\macro| the |#| used in the \csbxint{For} declaration must be
-doubled, as is the general rule in \TeX{} with things defined inside other
-things).
-The iterated commands as well as the list items are allowed to contain explicit
-|\par| tokens. Neither \csbxint{For} nor \csbxint{For*} create groups. The
-effect is like piling up the iterated commands with each time |#1| (or |#2| ...)
-replaced by an item of the list. However, contrarily to the completely
-expandable \csbxint{ApplyUnbraced}, but similarly to the non completely
-expandable \csbxint{ApplyInline} each iteration is executed first before looking
-at the next |#1|%
-%
-\footnote{to be completely honest, both \csbxint{For} and
- \csbxint{For*} initially scoop up both the list and the iterated
- commands; \csbxint{For} scoops up a second time the entire comma
- separated list in order to feed it to \csbxint{CSVtoList}. The starred
- variant \csbxint{For*} which does not need this step will thus be a
- bit faster on equivalent inputs.}
-%
-(and
-the starred variant \csbxint{For*} keeps on expanding each unbraced item it
-finds, gobbling spaces).
+The iterated macros as well as the list items are allowed to contain explicit
+|\par| tokens.
+
\subsection{\csbh{xintifForFirst}, \csbh{xintifForLast}}
\label{xintifForFirst}\label{xintifForLast}
@@ -8112,24 +9185,33 @@
\csbxint{For}
or \csbxint{For*} loop is currently in its first, respectively last, iteration.
-Designed to work as expected under nesting. Don't forget an empty brace pair
-|{}| if a branch is to do nothing. May be used multiple times in the replacement
-text of the loop.
+Designed to work as expected under nesting (but see frame next.) Don't forget
+an empty brace pair |{}| if a branch is to do nothing. May be used multiple
+times in the replacement text of the loop.
-There is no such thing as an iteration counter provided by the \csa{xintFor}
-loops; the user is invited to define if needed his own count register or
-\LaTeX{} counter, for example with a suitable |\stepcounter| inside the
-replacement text of the loop to update it.
+\begin{framed}
+ \noindent Pay attention to these implementation features:
+ \begin{itemize}[nosep, listparindent=\leftmarginiii]
+ \item \emph{if an inner \csbxint{For} loop is positioned before the
+ \csb{xintifForFirst} or \csb{xintifForLast} of the outer loop it will
+ contaminate their settings. This applies also naturally if the inner loop
+ arises from the expansion of some macro located before the outer
+ conditionals.}
-\begin{framed}
- It is a known feature of these conditionals that they cease to function if
- put at a location of the |\xintFor| replacement text which has closed a
- group, for example in the last cell of an alignment created by the loop,
- assuming the replacement text of the |\xintFor| loop creates a row. The
- conditional must be used before the first cell is closed. This is not likely
- to change in future versions. It is not an intrinsic limitation as the
- branches of the conditional can be the complete rows, inclusive of all |&|'s
- and the tabular newline |\\|.
+ One fix is to make sure that the outer conditionals are expanded before the
+ inner loop is executed, e.g. this will be the case if the inner loop is
+ located inside one of the branches of the conditional.
+
+ Another approach is to enclose, if feasible, the inner loop in a group of
+ its own.
+ \item \emph{if the replacement text closes a group (e.g. from a |&| inside an
+ alignment), the conditionals will lose their ascribed meanings and end up
+ possibly undefined, depending whether there is some outer loop whose
+ execution started before the opening of the group.}
+
+ The fix is to arrange things so that the conditionals are expanded
+ before \TeX\ encounters the closing-group token.
+ \end{itemize}
\end{framed}
\subsection{ \csbh{xintBreakFor}, \csbh{xintBreakForAndDo}}
@@ -8136,29 +9218,17 @@
\label{xintBreakFor}\label{xintBreakForAndDo}
One may immediately terminate an \csbxint{For} or \csbxint{For*} loop with
-\csbxint{BreakFor}. As the criterion for breaking will be decided on a
-basis of some test, it is recommended to use for this test the syntax of
-\href{http://ctan.org/pkg/ifthen}{ifthen}%
-%
-\footnote{\url{http://ctan.org/pkg/ifthen}}
-%
-or
-\href{http://ctan.org/pkg/etoolbox}{etoolbox}%
-%
-\footnote{\url{http://ctan.org/pkg/etoolbox}}
-%
-or the \xintname own conditionals, rather than one of the various
-|\if...\fi| of \TeX{}. Else (and this is without even mentioning all the various
-pecularities of the
-|\if...\fi| constructs), one has to carefully move the break after the closing
-of
-the conditional, typically with |\expandafter\xintBreakFor\fi|.%
-%
-\footnote{the difficulties here are similar to those mentioned in
- \autoref{sec:ifcase}, although less severe, as complete expandability
- is not to be maintained; hence the allowed use of
- \href{http://ctan.org/pkg/ifthen}{ifthen}.}
+\csbxint{BreakFor}.
+\begin{framed}
+ As it acts by clearing up all the rest of the replacement text when
+ encountered, it will not work from inside some |\if...\fi| without
+ suitable |\expandafter| or swapping technique.
+
+ Also it can't be used from inside braces as from there it can't see the end
+ of the replacement text.
+\end{framed}
+
There is also \csbxint{BreakForAndDo}. Both are illustrated by various examples
in the next section which is devoted to ``forever'' loops.
@@ -8194,7 +9264,7 @@
run through the arithmetic sequence of dimensions with initial value
|start| and increment |delta|. Default values: |start=0pt|, |delta=1pt|; if
the optional argument is present it must contain both of them, and they may
-be explicit specifications, or macros, or dimen registers, or length commands
+be explicit specifications, or macros, or dimen registers, or length macros
in \LaTeX{} (the stretch and shrink components will be discarded). The |#1|
will be |\dimexpr <opt sign><digits>sp\relax|, from which one can get the
litteral (approximate) representation in points via |\the#1|. So |#1| can be
@@ -8266,356 +9336,7 @@
printing of fixed points numbers should be dealt with via dedicated packages
such as |numprint| or |siunitx|.\par
-\subsection{Another table of primes}\label{ssec:primesIII}
-As a further example, let us dynamically generate a tabular with the first $50$
-prime numbers after $12345$. First we need a macro to test if a (short) number
-is prime. Such a completely expandable macro was given in \autoref{xintSeq},
-here we consider a variant which will be slightly more efficient. This new
-|\IsPrime| has two parameters. The first one is a macro which it redefines to
-expand to the result of the primality test applied to the second argument. For
-convenience we use the \href{http://ctan.org/pkg/etoolbox}{etoolbox} wrappers to
-various |\ifnum| tests, although here there isn't anymore the constraint of
-complete expandability (but using explicit |\if..\fi| in tabulars has its
-quirks); equivalent tests are provided by \xintname, but they have some overhead
-as they are able to deal with arbitrarily big integers.
-
-\def\IsPrime #1#2%
-{\edef\TheNumber {\the\numexpr #2}% positive integer
- \ifnumodd {\TheNumber}
- {\ifnumgreater {\TheNumber}{1}
- {\edef\ItsSquareRoot{\xintiSqrt \TheNumber}%
- \xintFor ##1 in {\xintintegers [3+2]}\do
- {\ifnumgreater {##1}{\ItsSquareRoot}
- {\def#1{1}\xintBreakFor}
- {}%
- \ifnumequal {\TheNumber}{(\TheNumber/##1)*##1}
- {\def#1{0}\xintBreakFor }
- {}%
- }}
- {\def#1{0}}}% 1 is not prime
- {\ifnumequal {\TheNumber}{2}{\def#1{1}}{\def#1{0}}}%
-}%
-
-\everb|@
-\def\IsPrime #1#2% """color[named]{PineGreen}#1=\Result, #2=tested number (assumed >0).;!
-{\edef\TheNumber {\the\numexpr #2}%"""color[named]{PineGreen} hence #2 may be a count or \numexpr.;!
- \ifnumodd {\TheNumber}
- {\ifnumgreater {\TheNumber}{1}
- {\edef\ItsSquareRoot{\xintiSqrt \TheNumber}%
- \xintFor """color{red}##1;! in {"""color{red}\xintintegers;! [3+2]}\do
- {\ifnumgreater {"""color{red}##1;!}{\ItsSquareRoot} """color[named]{PineGreen}% "textcolor{red}{##1} is a \numexpr.;!
- {\def#1{1}\xintBreakFor}
- {}%
- \ifnumequal {\TheNumber}{(\TheNumber/##1)*##1}
- {\def#1{0}\xintBreakFor }
- {}%
- }}
- {\def#1{0}}}% 1 is not prime
- {\ifnumequal {\TheNumber}{2}{\def#1{1}}{\def#1{0}}}%
-}
-|
-
-
-As we used \csbxint{For} inside a macro we had to double the |#| in its |#1|
-parameter. Here is now the code which creates the prime table (the table has
-been put in a \hyperref[primes]{float}, which should be found on page
-\pageref{primes}):
-
-\everb?@
-\newcounter{primecount}
-\newcounter{cellcount}
-\begin{figure*}[ht!]
- \centering
- \begin{tabular}{|*{7}c|}
- \hline
- \setcounter{primecount}{0}\setcounter{cellcount}{0}%
- \xintFor """color{red}#1;! in {"""color{red}\xintintegers;! [12345+2]} \do
-"""color[named]{PineGreen}% "textcolor{red}{#1} is a \numexpr.;!
- {\IsPrime\Result{#1}%
- \ifnumgreater{\Result}{0}
- {\stepcounter{primecount}%
- \stepcounter{cellcount}%
- \ifnumequal {\value{cellcount}}{7}
- {"""color{red}\the#1;! \\\setcounter{cellcount}{0}}
- {"""color{red}\the#1;! &}}
- {}%
- \ifnumequal {\value{primecount}}{50}
- {\xintBreakForAndDo
- {\multicolumn {6}{l|}{These are the first 50 primes after 12345.}\\}}
- {}%
- }\hline
-\end{tabular}
-\end{figure*}
-?
-
-\begin{figure*}[ht!]
- \centering\phantomsection\label{primes}
- \begin{tabular}{|*{7}c|}
- \hline
- \setcounter{primecount}{0}\setcounter{cellcount}{0}%
- \xintFor #1 in {\xintintegers [12345+2]} \do
- {\IsPrime\Result{#1}%
- \ifnumgreater{\Result}{0}
- {\stepcounter{primecount}%
- \stepcounter{cellcount}%
- \ifnumequal {\value{cellcount}}{7}
- {\the#1 \\\setcounter{cellcount}{0}}
- {\the#1 &}}
- {}%
- \ifnumequal {\value{primecount}}{50}
- {\xintBreakForAndDo
- {\multicolumn {6}{l|}{These are the first 50 primes after 12345.}\\}}
- {}%
- }\hline
-\end{tabular}
-\end{figure*}
-
-\subsection{Some arithmetic with Fibonacci numbers}
-\label{ssec:fibonacci}
-
-Here is the code employed on the title page to compute (expandably, of
-course!) the 1250th Fibonacci number:
-
-\begin{everbatim*}
-\catcode`_ 11
-\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 1\expandafter\relax\expandafter}\expandafter
- {\romannumeral0\xintiieval 0\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 are omitted from the next macros, tacit multiplications
-\def\Fibonacci_b_i #1#2#3{\expandafter\Fibonacci_a\expandafter
- {\the\numexpr #1/2\expandafter}\expandafter
- {\romannumeral0\xintiieval sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter
- {\romannumeral0\xintiieval (2#2-#3)#3\relax}%
-}% end of Fibonacci_b_i
-\def\Fibonacci_b_ii #1#2#3#4#5{\expandafter\Fibonacci_a\expandafter
- {\the\numexpr (#1-1)/2\expandafter}\expandafter
- {\romannumeral0\xintiieval sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter
- {\romannumeral0\xintiieval (2#2-#3)#3\expandafter\relax\expandafter}\expandafter
- {\romannumeral0\xintiieval #2#4+#3#5\expandafter\relax\expandafter}\expandafter
- {\romannumeral0\xintiieval #2#5+#3(#4-#5)\relax}%
-}% end of Fibonacci_b_ii
-% code as used on title page:
-%\def\Fibonacci_end_i #1#2#3#4#5{\xintthe#5}
-%\def\Fibonacci_end_ii #1#2#3#4#5{\xinttheiiexpr #2#5+#3(#4-#5)\relax}
-% new definitions:
-\def\Fibonacci_end_i #1#2#3#4#5{{#4}{#5}}% {F(N+1)}{F(N)} in \xintexpr format
-\def\Fibonacci_end_ii #1#2#3#4#5%
- {\expandafter
- {\romannumeral0\xintiieval #2#4+#3#5\expandafter\relax
- \expandafter}\expandafter
- {\romannumeral0\xintiieval #2#5+#3(#4-#5)\relax}}% idem.
-% \FibonacciN returns F(N) (in encapsulated format: needs \xintthe for printing)
-\def\FibonacciN {\expandafter\xint_secondoftwo\romannumeral-`0\Fibonacci }%
-\catcode`_ 8
-\end{everbatim*}
-
-
-I have modified the ending: we 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
-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}).
-%
-\begin{everbatim}
-\def\Fibo #1.{\xintthe\FibonacciN {#1}}%
-\message{\xintiloop [0+1] \expandafter\Fibo\xintiloopindex.,
- \ifnum\xintiloopindex<49 \repeat \xintthe\FibonacciN{50}.}
-\end{everbatim}
-\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.}
-
-Our |\Fibonacci| expands completely under \fexpan sion,
-so we can use \hyperref[fdef]{\ttfamily\char92fdef} rather than |\edef| in a
-situation such as %
-\leftedline {|\fdef \X {\FibonacciN {100}}|} but for the
-reasons explained above, it is as efficient to employ |\edef|. And if we want
-%
-\leftedline{|\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
-\everb|@
-\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
-|
-\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 &
- \xintiRem{\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 &
- \xintiRem{\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 &
- \xintiRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{index}\cr }}%
-}}%
-%
-\centeredline{Some Fibonacci numbers together with their residues modulo
- |F(30)|\dtt{=\xintthe\Fibxxx}}
-\end{figure*}
-
-\begingroup\footnotesize\baselineskip10pt
-\everb|@
-\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 &
- \xintiRem{\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 &
- \xintiRem{\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 &
- \xintiRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{index}\cr }}%
-}%
-|
-\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}
The syntax\ntype{on} is illustrated in this
@@ -8633,14 +9354,21 @@
\end{tabular}\\}
\end{everbatim*}
-Only |#1#2|, |#2#3|, |#3#4|, \dots, |#8#9| are valid (no error check
-is done on the input syntax, |#1#3| or similar all end up in errors).
-One can nest with \csbxint{For}, for disjoint sets of macro parameters. There is
-also \csa{xintForthree} (from |#1#2#3| to |#7#8#9|) and \csa{xintForfour} (from
-|#1#2#3#4| to |#6#7#8#9|). |\par| tokens are accepted in both the comma
-separated list and the replacement text.
+\csbxint{Forpair} must be followed by either |#1#2|, |#2#3|, |#3#4|, \dots, or
+|#8#9| with |#1| usable as an alias for |#1#2|, |#2| as alias for |#2#3|,
+etc \dots\ and similarly for \csbxint{Forthree} (using |#1#2#3| or simply
+|#1|, |#2#3#4| or simply |#2|, \dots) and \csbxint{Forfour} (with |#1#2#3#4|
+etc\dots).
+Nesting works as long as the macro parameters are distinct among |#1|, |#2|,
+..., |#9|. A macro which expands to an \csa{xintFor} or a
+\csa{xintFor(pair,three,four)} can be used in another one with no constraint
+about using distinct macro parameters.
+|\par| tokens are accepted in both the comma separated list and the
+replacement text.
+
+
\subsection{\csbh{xintAssign}}\label{xintAssign}
\csa{xintAssign}\meta{braced things}\csa{to}%
@@ -8757,375 +9485,9 @@
\csa{xintAssignArray} with \csa{myArray} as array macro.
-\subsection{The Quick Sort algorithm illustrated}\label{ssec:quicksort}
-First a completely expandable macro which sorts a comma separated list of
-numbers.%
-%
-\footnote{The code in earlier versions of this manual handled inputs composed
- of braced items. I have switched to comma separated inputs on the occasion
- of \url{http://tex.stackexchange.com/a/273084}. The version here is like
- |code 3| on \url{http://tex.stackexchange.com} (which is about |3x| faster
- than the earlier code it replaced in this manual) with a modification to
- make it more efficient if the data has many repeated values.
-
- A faster routine (for sorting hundreds of values) is provided as |code 6| at
- the link mentioned in the footnote, it is based on Merge Sort, but limited
- to inputs which one can handle as \TeX{} dimensions.%
-
- This |code 6| could be extended to handle more general numbers, as
- acceptable by \xintfracname. I have also written a non expandable version,
- which is even faster, but this matters really only when handling hundreds or
- rather thousands of values.}
-%
-
-The |\QSx| macro expands its list argument, which may thus be a macro; its
-comma separated items must expand to integers or decimal numbers or fractions
-or scientific notation as acceptable to \xintfracname, but if an item is
-itself some (expandable) macro, this macro will be expanded each time the item
-is considered in a comparison test! This is actually good if the macro expands
-in one step to the digits, and there are many many digits, but bad if the macro
-needs to do many computations. Thus |\QSx| should be used with either explicit
-numbers or with items being macros expanding in one step to the numbers
-(particularly if these numbers are very big).
-
-If the interest is only in \TeX{} integers, then one should replace the
-|\xintifCmp| macro with a suitable conditional, possibly helped by tools such as
-|\ifnumgreater|, |\ifnumequal| and |\ifnumless| from
-\href{http://ctan.org/pkg/etoolbox}{etoolbox} (\LaTeX{} only; I didn't see a
-direct equivalent to |\xintifCmp|.) Or, if we are dealing with decimal numbers
-with at most four+four digits, then one should use suitable |\ifdim| tests.
-Naturally this will boost consequently the speed, from having skipped all the
-overhead in parsing fractions and scientific numbers as are acceptable by
-\xintfracname macros, and subsequent treatment.
-
-\begin{everbatim*}
-% THE QUICK SORT ALGORITHM EXPANDABLY
-% \usepackage{xintfrac} in the preamble (latex)
-\makeatletter
-% use extra safe delimiters
-\catcode`! 3 \catcode`? 3
-\def\QSx {\romannumeral0\qsx }%
-% first we check if empty list (else \qsx at finish will not find a comma)
-\def\qsx #1{\expandafter\qsx at a\romannumeral-`0#1,!,?}%
-\def\qsx at a #1{\ifx,#1\expandafter\qsx at abort\else
- \expandafter\qsx at start\fi #1}%
-\def\qsx at abort #1?{ }%
-\def\qsx at start {\expandafter\qsx at finish\romannumeral0\qsx at b,}%
-\def\qsx at finish ,#1{ #1}%
-%
-% we check if empty of single and if not pick up the first as Pivot:
-\def\qsx at b ,#1#2,#3{\ifx?#3\xintdothis\qsx at empty\fi
- \ifx!#3\xintdothis\qsx at single\fi
- \xintorthat\qsx at separate {#1#2}{}{}{#1#2}#3}%
-\def\qsx at empty #1#2#3#4#5{ }%
-\def\qsx at single #1#2#3#4#5?{, #4}%
-\def\qsx at separate #1#2#3#4#5#6,%
-{%
- \ifx!#5\expandafter\qsx at separate@done\fi
- \xintifCmp {#5#6}{#4}%
- \qsx at separate@appendtosmaller
- \qsx at separate@appendtoequal
- \qsx at separate@appendtogreater {#5#6}{#1}{#2}{#3}{#4}%
-}%
-%
-\def\qsx at separate@appendtoequal #1#2{\qsx at separate {#2,#1}}%
-\def\qsx at separate@appendtogreater #1#2#3{\qsx at separate {#2}{#3,#1}}%
-\def\qsx at separate@appendtosmaller #1#2#3#4{\qsx at separate {#2}{#3}{#4,#1}}%
-%
-\def\qsx at separate@done\xintifCmp #1%
- \qsx at separate@appendtosmaller
- \qsx at separate@appendtoequal
- \qsx at separate@appendtogreater #2#3#4#5#6#7?%
-{%
- \expandafter\qsx at f\expandafter {\romannumeral0\qsx at b #4,!,?}{\qsx at b #5,!,?}{#3}%
-}%
-%
-\def\qsx at f #1#2#3{#2, #3#1}%
-%
-\catcode`! 12 \catcode`? 12
-\makeatother
-
-% EXAMPLE
-\begingroup
-\edef\z {\QSx {1.0, 0.5, 0.3, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
- 1.3, 1.1, 0.7, 1.6, 0.6, 0.9, 0.8, 0.2, 0.1, 1.9}}
-\meaning\z
-
-\def\a {3.123456789123456789}\def\b {3.123456789123456788}
-\def\c {3.123456789123456790}\def\d {3.123456789123456787}
-\oodef\z {\QSx { \a, \b, \c, \d}}%
-% The space before \a to let it not be expanded during the conversion from CSV
-% values to List. The \oodef expands exactly twice (via a bunch of \expandafter's)
-\meaning\z
-\endgroup
-\end{everbatim*} (the spaces after \string\d, etc... come from the use of the
-|\meaning| primitive.)
-
-The choice of pivot as first element is bad if the list is already almost
-sorted. Let's add a variant which will pick up the pivot index randomly. The
-previous routine worked also internally with comma separated lists, but for a
-change this one will use internally lists of braced items (the initial
-conversion via \csbxint{CSVtoList} handles all potential spurious space
-problems).
-
-\unless\ifxetex % pour tester compilation de xint.dtx avec xetex qui n'a pas
- % \pdfuniformedeviate
-\begin{everbatim*}
-% QuickSort expandably on comma separated values with random choice of pivots
-% ====> Requires availability of \pdfuniformdeviate <====
-% \usepackage{xintfrac, xinttools} in preamble
-\makeatletter
-\def\QSx {\romannumeral0\qsx }% This is a f-expandable macro.
-% This converts from comma separated values on input and back on output.
-% **** NOTE: these steps (and the other ones too, actually) are costly if input
-% has thousands of items.
-\def\qsx #1{\xintlistwithsep{, }%
- {\expandafter\qsx at sort@a\expandafter{\romannumeral0\xintcsvtolist{#1}}}}%
-%
-% we check if empty or single or double and if not pick up the first as Pivot:
-\def\qsx at sort@a #1%
- {\expandafter\qsx at sort@b\expandafter{\romannumeral0\xintlength{#1}}{#1}}%
-\def\qsx at sort@b #1{\ifcase #1
- \expandafter\qsx at sort@empty
- \or\expandafter\qsx at sort@single
- \or\expandafter\qsx at sort@double
- \else\expandafter\qsx at sort@c\fi {#1}}%
-\def\qsx at sort@empty #1#2{ }%
-\def\qsx at sort@single #1#2{#2}%
-\catcode`_ 11
-\def\qsx at sort@double #1#2{\xintifGt #2{\xint_exchangetwo_keepbraces}{}#2}%
-\catcode`_ 8
-\def\qsx at sort@c #1#2{%
- \expandafter\qsx at sort@sep at a\expandafter
- {\romannumeral0\xintnthelt{\pdfuniformdeviate #1+\@ne}{#2}}#2?}%
-\def\qsx at sort@sep at a #1{\qsx at sort@sep at loop {}{}{}{#1}}%
-\def\qsx at sort@sep at loop #1#2#3#4#5%
-{%
- \ifx?#5\expandafter\qsx at sort@sep at done\fi
- \xintifCmp {#5}{#4}%
- \qsx at sort@sep at appendtosmaller
- \qsx at sort@sep at appendtoequal
- \qsx at sort@sep at appendtogreater {#5}{#1}{#2}{#3}{#4}%
-}%
-%
-\def\qsx at sort@sep at appendtoequal #1#2{\qsx at sort@sep at loop {#2{#1}}}%
-\def\qsx at sort@sep at appendtogreater #1#2#3{\qsx at sort@sep at loop {#2}{#3{#1}}}%
-\def\qsx at sort@sep at appendtosmaller #1#2#3#4{\qsx at sort@sep at loop {#2}{#3}{#4{#1}}}%
-%
-\def\qsx at sort@sep at done\xintifCmp #1%
- \qsx at sort@sep at appendtosmaller
- \qsx at sort@sep at appendtoequal
- \qsx at sort@sep at appendtogreater #2#3#4#5#6%
-{%
- \expandafter\qsx at sort@recurse\expandafter
- {\romannumeral0\qsx at sort@a {#4}}{\qsx at sort@a {#5}}{#3}%
-}%
-%
-\def\qsx at sort@recurse #1#2#3{#2#3#1}%
-%
-\makeatother
-
-% EXAMPLES
-\begingroup
-\edef\z {\QSx {1.0, 0.5, 0.3, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
- 1.3, 1.1, 0.7, 1.6, 0.6, 0.9, 0.8, 0.2, 0.1, 1.9}}
-\meaning\z
-
-\def\a {3.123456789123456789}\def\b {3.123456789123456788}
-\def\c {3.123456789123456790}\def\d {3.123456789123456787}
-\oodef\z {\QSx { \a, \b, \c, \d}}%
-% The space before \a to let it not be expanded during the conversion from CSV
-% values to List. The \oodef expands exactly twice (via a bunch of \expandafter's)
-\meaning\z
-
-\def\somenumbers{%
-3997.6421, 8809.9358, 1805.4976, 5673.6478, 3179.1328, 1425.4503, 4417.7691,
-2166.9040, 9279.7159, 3797.6992, 8057.1926, 2971.9166, 9372.2699, 9128.4052,
-1228.0931, 3859.5459, 8561.7670, 2949.6929, 3512.1873, 1698.3952, 5282.9359,
-1055.2154, 8760.8428, 7543.6015, 4934.4302, 7526.2729, 6246.0052, 9512.4667,
-7423.1124, 5601.8436, 4433.5361, 9970.4849, 1519.3302, 7944.4953, 4910.7662,
-3679.1515, 8167.6824, 2644.4325, 8239.4799, 4595.1908, 1560.2458, 6098.9677,
-3116.3850, 9130.5298, 3236.2895, 3177.6830, 5373.1193, 5118.4922, 2743.8513,
-8008.5975, 4189.2614, 1883.2764, 9090.9641, 2625.5400, 2899.3257, 9157.1094,
-8048.4216, 3875.6233, 5684.3375, 8399.4277, 4528.5308, 6926.7729, 6941.6278,
-9745.4137, 1875.1205, 2755.0443, 9161.1524, 9491.1593, 8857.3519, 4290.0451,
-2382.4218, 3678.2963, 5647.0379, 1528.7301, 2627.8957, 9007.9860, 1988.5417,
-2405.1911, 5065.8063, 5856.2141, 8989.8105, 9349.7840, 9970.3013, 8105.4062,
-3041.7779, 5058.0480, 8165.0721, 9637.7196, 1795.0894, 7275.3838, 5997.0429,
-7562.6481, 8084.0163, 3481.6319, 8078.8512, 2983.7624, 3925.4026, 4931.5812,
-1323.1517, 6253.0945}%
-
-\oodef\z {\QSx \somenumbers}%
-\hsize 87\fontcharwd\font`0 \setbox0\hbox{\kern\fontcharwd\font`0}%
-\lccode`~=32 \lowercase{\def~}{\discretionary{}{}{\copy0}}\catcode32 13
-\noindent\ \ \ \scantokens\expandafter{\meaning\z}\par
-\endgroup
-\end{everbatim*}
-\fi % fin de si pas xetex
-
-All these examples were with numbers which may have been handled via |\ifdim|
-tests rather than \csbxint{ifCmp} from \xintfracname ; naturally that would
-have been faster. For a yet faster routine (based however on the Merge Sort
-and using the |\pdfescapestring| PDF\TeX{} primitive) see |code 6| at
-\url{http://tex.stackexchange.com/a/273084}.
-
-We then turn to a graphical illustration of the algorithm.%
-%
-\footnote{I have rewritten the routine to do only once (and not thrice) the
- needed calls to \csa{xintifCmp}, up to the price of one additional |\edef|,
- although due to the context execution time on our side is not an issue and
- moreover is anyhow overwhelmed by the TikZ's activities. Simultaneously I
- have updated the code \url{http://tex.stackexchange.com/a/142634/4686}. The
- variant with the choice of pivot on the right has more overhead: the reason
- is simply that we do not convert the data into an array, but maintain a list
- of tokens with self-reorganizing delimiters.}
-%
-For simplicity the pivot is always chosen as the first list item. Then we also
-give a variant which picks up the last item as pivot.
-\begin{everbatim*}
-% in LaTeX preamble:
-% \usepackage{xintfrac, xinttools}
-% \usepackage{color}
-% or, when using Plain TeX:
-% \input xintfrac.sty \input xinttools.sty
-% \input color.tex
-%
-% Color definitions
-\definecolor{LEFT}{RGB}{216,195,88}
-\definecolor{RIGHT}{RGB}{208,231,153}
-\definecolor{INERT}{RGB}{199,200,194}
-\definecolor{INERTpiv}{RGB}{237,237,237}
-\definecolor{PIVOT}{RGB}{109,8,57}
-% Start of macro defintions
-\makeatletter
-% \catcode`? 3 % a bit too paranoid. Normal ? will do.
-%
-% argument will never be empty
-\def\QS at cmp@a #1{\QS at cmp@b #1??}%
-\def\QS at cmp@b #1{\noexpand\QS at sep@A\@ne{#1}\QS at cmp@d {#1}}%
-\def\QS at cmp@d #1#2{\ifx ?#2\expandafter\QS at cmp@done\fi
- \xintifCmp {#1}{#2}\tw@\@ne\z@{#2}\QS at cmp@d {#1}}%
-\def\QS at cmp@done #1?{?}%
-%
-\def\QS at sep@A #1?{\QSLr\QS at sep@L #1\thr@@?#1\thr@@?#1\thr@@?}%
-\def\QS at sep@L #1#2{\ifcase #1{#2}\or\or\else\expandafter\QS at sep@I at start\fi \QS at sep@L}%
-\def\QS at sep@I at start\QS at sep@L {\noexpand\empty?\QSIr\QS at sep@I}%
-\def\QS at sep@I #1#2{\ifcase#1\or{#2}\or\else\expandafter\QS at sep@R at start\fi\QS at sep@I}%
-\def\QS at sep@R at start\QS at sep@I {\noexpand\empty?\QSRr\QS at sep@R}%
-\def\QS at sep@R #1#2{\ifcase#1\or\or{#2}\else\expandafter\QS at sep@done\fi\QS at sep@R}%
-\def\QS at sep@done\QS at sep@R {\noexpand\empty?}%
-%
-\def\QS at loop {%
- \xintloop
- % pivot phase
- \def\QS at pivotcount{0}%
- \let\QSLr\DecoLEFTwithPivot \let\QSIr \DecoINERT
- \let\QSRr\DecoRIGHTwithPivot \let\QSIrr\DecoINERT
- \centerline{\QS at list}%
- % sorting phase
- \ifnum\QS at pivotcount>\z@
- \def\QSLr {\QS at cmp@a}\def\QSRr {\QS at cmp@a}%
- \def\QSIr {\QSIrr}\let\QSIrr\relax
- \edef\QS at list{\QS at list}% compare
- \let\QSLr\relax\let\QSRr\relax\let\QSIr\relax
- \edef\QS at list{\QS at list}% separate
- \def\QSLr ##1##2?{\ifx\empty##1\else\noexpand \QSLr {{##1}##2}\fi}%
- \def\QSIr ##1##2?{\ifx\empty##1\else\noexpand \QSIr {{##1}##2}\fi}%
- \def\QSRr ##1##2?{\ifx\empty##1\else\noexpand \QSRr {{##1}##2}\fi}%
- \edef\QS at list{\QS at list}% gather
- \let\QSLr\DecoLEFT \let\QSRr\DecoRIGHT
- \let\QSIr\DecoINERTwithPivot \let\QSIrr\DecoINERT
- \centerline{\QS at list}%
- \repeat }%
-%
-% \xintFor* loops handle gracefully empty lists.
-\def\DecoLEFT #1{\xintFor* ##1 in {#1} \do {\colorbox{LEFT}{##1}}}%
-\def\DecoINERT #1{\xintFor* ##1 in {#1} \do {\colorbox{INERT}{##1}}}%
-\def\DecoRIGHT #1{\xintFor* ##1 in {#1} \do {\colorbox{RIGHT}{##1}}}%
-\def\DecoPivot #1{\begingroup\color{PIVOT}\advance\fboxsep-\fboxrule\fbox{#1}\endgroup}%
-%
-\def\DecoLEFTwithPivot #1{\xdef\QS at pivotcount{\the\numexpr\QS at pivotcount+\@ne}%
- \xintFor* ##1 in {#1} \do
- {\xintifForFirst {\DecoPivot {##1}}{\colorbox{LEFT}{##1}}}}%
-\def\DecoINERTwithPivot #1{\xdef\QS at pivotcount{\the\numexpr\QS at pivotcount+\@ne}%
- \xintFor* ##1 in {#1} \do
- {\xintifForFirst {\colorbox{INERTpiv}{##1}}{\colorbox{INERT}{##1}}}}%
-\def\DecoRIGHTwithPivot #1{\xdef\QS at pivotcount{\the\numexpr\QS at pivotcount+\@ne}%
- \xintFor* ##1 in {#1} \do
- {\xintifForFirst {\DecoPivot {##1}}{\colorbox{RIGHT}{##1}}}}%
-%
-\def\QuickSort #1{% warning: not compatible with empty #1.
- % initialize, doing conversion from comma separated values to a list of braced items
- \edef\QS at list{\noexpand\QSRr{\xintCSVtoList{#1}}}% many \edef's are to follow anyhow
-% earlier I did a first drawing of the list, here with the color of RIGHT elements,
-% but the color should have been for example white, anyway I drop this first line
- %\let\QSRr\DecoRIGHT
- %\par\centerline{\QS at list}%
-%
- % loop as many times as needed
- \QS at loop }%
-%
-% \catcode`? 12 % in case we had used a funny ? as delimiter.
-\makeatother
-%% End of macro definitions.
-%% Start of Example
-\begingroup\offinterlineskip
-\small
-% \QuickSort {1.0, 0.5, 0.3, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
-% 1.3, 1.1, 0.7, 1.6, 0.6, 0.9, 0.8, 0.2, 0.1, 1.9}
-% \medskip
-% with repeated values
-\QuickSort {1.0, 0.5, 0.3, 0.8, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
- 1.3, 1.1, 0.7, 0.3, 1.6, 0.6, 0.3, 0.8, 0.2, 0.8, 0.7, 1.2}
-\endgroup
-\end{everbatim*}
-
-Here is the variant which always picks the pivot as the rightmost element.
-
-\begin{everbatim*}
-\makeatletter
-%
-\def\QS at cmp@a #1{\noexpand\QS at sep@A\expandafter\QS at cmp@d\expandafter
- {\romannumeral0\xintnthelt{-1}{#1}}#1??}%
-%
-\def\DecoLEFTwithPivot #1{\xdef\QS at pivotcount{\the\numexpr\QS at pivotcount+\@ne}%
- \xintFor* ##1 in {#1} \do
- {\xintifForLast {\DecoPivot {##1}}{\colorbox{LEFT}{##1}}}}
-\def\DecoINERTwithPivot #1{\xdef\QS at pivotcount{\the\numexpr\QS at pivotcount+\@ne}%
- \xintFor* ##1 in {#1} \do
- {\xintifForLast {\colorbox{INERTpiv}{##1}}{\colorbox{INERT}{##1}}}}
-\def\DecoRIGHTwithPivot #1{\xdef\QS at pivotcount{\the\numexpr\QS at pivotcount+\@ne}%
- \xintFor* ##1 in {#1} \do
- {\xintifForLast {\DecoPivot {##1}}{\colorbox{RIGHT}{##1}}}}
-\def\QuickSort #1{%
- % initialize, doing conversion from comma separated values to a list of braced items
- \edef\QS at list{\noexpand\QSLr {\xintCSVtoList{#1}}}% many \edef's are to follow anyhow
- %
- % loop as many times as needed
- \QS at loop }%
-\makeatother
-\begingroup\offinterlineskip
-\small
-% \QuickSort {1.0, 0.5, 0.3, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
-% 1.3, 1.1, 0.7, 1.6, 0.6, 0.9, 0.8, 0.2, 0.1, 1.9}
-% \medskip
-% with repeated values
-\QuickSort {1.0, 0.5, 0.3, 0.8, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
- 1.3, 1.1, 0.7, 0.3, 1.6, 0.6, 0.3, 0.8, 0.2, 0.8, 0.7, 1.2}
-\endgroup
-\end{everbatim*}
-
-The choice of the first or last item as pivot is not a good one as nearly
-ordered lists will take quadratic time. But for explaining the algorithm via a
-graphical interpretation, it is not that bad. If one wanted to pick up the
-pivot randomly, the routine would have to be substantially rewritten: in
-particular the |\Deco..withPivot| macros need to know where the pivot is, and
-currently this is implemented by using either |\xintifForFirst| or
-|\xintifForLast|.
-
\clearpage
-\section{Commands of the \xintcorename package}
+\section{Macros of the \xintcorename package}
\label{sec:core}
\localtableofcontents
@@ -9180,20 +9542,13 @@
\hyperref[sec:useofcount]{Use of count} section.
\begin{framed}
- Earlier releases of \xintcorename also provided macros |\xintAdd|,
- |\xintMul|,\dots as synonyms to |\xintiAdd|, |\xintiMul|,\dots, destined to
- be re-defined by \xintfracname.\IMPORTANT{} It was announced some time ago
- that their usage was deprecated, because the output formats depended on
- whether \xintfracname was loaded or not. They now have been \fbox{removed.}
- \MyMarginNote[\kern\dimexpr\FrameSep+\FrameRule\relax]{Changed}
-
- The macros \csbxint{iAdd}, \csbxint{iMul}, \dots, or \csbxint{iiAdd},
- \csbxint{iiMul}, \dots which come with \xintcorename are guaranteed to
- always output an integer without a trailing |/B[n]|. The latter have the
- lesser overhead, and the former do not complain, if \xintfracname is loaded,
- even if used with true fractions, as they will then truncate their arguments
- to integers. But their output format remains unmodified: integers with no
- fraction slash nor |[N]| thingy.
+ The macros \csbxint{iAdd}, \csbxint{iMul}, \dots, respectively
+ \csbxint{iiAdd}, \csbxint{iiMul}, \dots from \xintcorename are guaranteed to
+ always output an integer without a trailing |/B| or |[N]|. The |ii| macros
+ have the lesser overhead; the |i| macros can be used (if \xintfracname is
+ loaded), with fractions, as they will truncate their arguments to integers.
+ But their output format remains unmodified: integers with no fraction slash
+ nor |[N]|.
\end{framed}
The {\color[named]{PineGreen}$\star$}'s in the margin are there to remind of
@@ -9247,24 +9602,11 @@
|\xintiiLDg|\n\etype{f} returns the least significant digit. When the number
is positive, this is the same as the remainder in the euclidean division by
-ten. It skips the overhead of parsing via \csbxint{Num}. The variant
-\csa{xintLDg}\etype{\Numf} uses |\xintNum| and gets extended by \xintfracname.
+ten. It skips the overhead of parsing via \csbxint{Num}. Rewritten with
+|1.2i|.
-\subsection{\csbh{xintDouble}, \csbh{xintHalf}}
-\label{xintDouble}
-\label{xintHalf}
+The variant \csa{xintLDg}\etype{\Numf} uses |\xintNum|.
-|\xintDouble|\n\etype{f} returns |2N| and |\xintHalf|\n is |N/2| rounded
-towards zero. These macros remain integer-only, even with \xintfracname loaded.
-
-\subsection{\csbh{xintInc}, \csbh{xintDec}}
-\label{xintInc}
-\label{xintDec}
-
-|\xintInc|\n\etype{f} is |N+1| and |\xintDec|\n{} is |N-1|. These macros
-remain integer-only, even with \xintfracname loaded. They skip the overhead
-of parsing via \csbxint{Num}.
-
\subsection{\csbh{xintiAdd}, \csbh{xintiiAdd}}\label{xintiAdd}\label{xintiiAdd}
|\xintiAdd|\n\m\etype{\Numf\Numf} returns the sum of the two numbers.
@@ -9363,10 +9705,7 @@
if |N| vanishes) and returns |{0}{0}|. It skips the overhead of parsing via
\csbxint{Num}.
-|\xintiDivision|\etype{\Numf\Numf} submits its arguments to \csbxint{Num} and
-is extended by \xintfracname to accept fractions on input, which it truncates
-first, and is not to be confused with the \xintfracname macro \csbxint{Div}
-which divides one fraction by another.
+|\xintiDivision|\etype{\Numf\Numf} submits its arguments to \csbxint{Num}.
\subsection{\csbh{xintiQuo}, \csbh{xintiiQuo}}\label{xintiQuo}\label{xintiiQuo}
@@ -9373,39 +9712,26 @@
|\xintiiQuo|\n\m\etype{ff} returns the quotient from the euclidean division.
It skips the overhead of parsing via \csbxint{Num}.
-|\xintiQuo|\etype{\Numf\Numf} submits its arguments to \csbxint{Num} and
-is extended by \xintfracname to accept fractions on input, which it truncates
-first.
+|\xintiQuo|\etype{\Numf\Numf} submits its arguments to \csbxint{Num}.
-Note: |\xintQuo| is the former name of |\xintiQuo|. Its use is deprecated.
-
-
\subsection{\csbh{xintiRem}, \csbh{xintiiRem}}\label{xintiRem}\label{xintiiRem}
|\xintiiRem|\n\m\etype{ff} returns the remainder from the euclidean
division. It skips the overhead of parsing via \csbxint{Num}.
-|\xintiRem|\etype{\Numf\Numf} submits its arguments to \csbxint{Num} and
-is extended by \xintfracname to accept fractions on input, which it truncates
-first.
+|\xintiRem|\etype{\Numf\Numf} submits its arguments to \csbxint{Num}.
-Note: |\xintRem| is the former name of |\xintiRem|. Its use is deprecated.
-
-
\subsection{\csbh{xintiDivRound}, \csbh{xintiiDivRound}}
\label{xintiDivRound}\label{xintiiDivRound}
|\xintiiDivRound|\n\m\etype{ff} returns the rounded value of the algebraic
-quotient $N/M$ of two big integers. The rounding of half integers is towards
-the nearest integer of bigger absolute value. The macro skips the overhead of
-parsing via \csbxint{Num}. The rounding is away from zero.
+quotient $N/M$ of two big integers. The rounding is ``away from zero.'' The
+macro skips the overhead of parsing via \csbxint{Num}.
\begin{everbatim*}
\xintiiDivRound {100}{3}, \xintiiDivRound {101}{3}
\end{everbatim*}
-|\xintiDivRound|\etype{\Numf\Numf} submits its arguments to \csbxint{Num}. It
-is extended by \xintfracname to accept fractions on input, which it truncates
-first before computing the rounded quotient.
+|\xintiDivRound|\etype{\Numf\Numf} submits its arguments to \csbxint{Num}.
\subsection{\csbh{xintiDivTrunc}, \csbh{xintiiDivTrunc}}
\label{xintiDivTrunc}\label{xintiiDivTrunc}
@@ -9417,7 +9743,7 @@
$\xintiiQuo {1000}{-57}, \xintiiDivRound {1000}{-57}, \xintiiDivTrunc {1000}{-57}$
\end{everbatim*}
-|\xintiDivTrunc|\etype{\Numf\Numf} submits first its arguments to \csbxint{Num}.
+|\xintiDivTrunc|\etype{\Numf\Numf} submits its arguments to \csbxint{Num}.
\subsection{\csbh{xintiMod}, \csbh{xintiiMod}}
\label{xintiMod}\label{xintiiMod}
@@ -9430,10 +9756,49 @@
\xintiiRem {-1000}{57}, \xintiiMod {-1000}{57}$
\end{everbatim*}
-|\xintiMod|\etype{\Numf\Numf} submits first its arguments to \csbxint{Num}.
+|\xintiMod|\etype{\Numf\Numf} submits its arguments to \csbxint{Num}.
+\begin{framed}
+ For legacy reasons the macros next do not have |ii| in their names but they
+ behave in the corresponding way, \emph{i.e.} their
+ argument must be a (long) integer in the strict format or a macro \fexpan
+ ding to such digit tokens.
+\end{framed}
+
+\subsection{\csbh{xintDouble}, \csbh{xintHalf}}
+\label{xintDouble}
+\label{xintHalf}
+
+|\xintDouble|\n\etype{f} computes |2N| and |\xintHalf|\n{} computes |N/2|
+truncated towards zero. Rewritten for |1.2i|.
+
+\subsection{\csbh{xintInc}, \csbh{xintDec}}
+\label{xintInc}
+\label{xintDec}
+
+|\xintInc|\n\etype{f} evaluates to |N+1| and |\xintDec|\n{} to |N-1|.
+Rewritten for |1.2i|.
+
+\subsection{\csbh{xintDSL}}\label{xintDSL}
+
+|\xintDSL|\n\etype{f} is decimal shift left, \emph{i.e.} multiplication by
+ten. Rewritten with |1.2i| and moved from \xintname to \xintcorename.
+
+\subsection{\csbh{xintDSR}}\label{xintDSR}
+
+|\xintDSR|\n\etype{f} is truncated decimal shift right, \emph{i.e.} it is the
+truncation of |N/10| towards zero. Rewritten with |1.2i| and moved from
+\xintname to \xintcorename.
+
+\subsection{\csbh{xintDSRr}}\label{xintDSRr}
+
+|\xintDSRr|\n\etype{f} is rounded decimal shift right, \emph{i.e.} it is the
+rounding of |N/10| away from zero. It is needed in \xintcorename for use by
+\csbxint{iiDivRound}.\NewWith {1.2i}
+
+
\clearpage
-\section{Commands of the \xintname package}
+\section{Macros of the \xintname package}
\label{sec:xint}
\begin{framed}
@@ -9465,7 +9830,7 @@
|-\x| will give an unexpected result as the minus sign immediately stops this
expansion; one can use |\xintiiOpp{\x}| as argument.)
-This command has been rewritten for |1.2| and is faster for very long inputs.
+This macro has been rewritten for |1.2| and is faster for very long inputs.
It is (almost) not used internally by the \xintcorename code, but the use
of related routines explains to some extent the higher speed of release |1.2|.
@@ -9775,11 +10140,8 @@
nn} is a synonym for \csbxint{ifNotZero}.
{\small
-\noindent 1. with |1.09i|, the synonyms |\xintifTrueFalse| and |\xintifTrue| are
- deprecated
- and will be removed in next release.\par
-\noindent 2. These macros have no lowercase versions, use |\xintifzero|,
-|\xintifnotzero|.\par }
+ \noindent These macros have no lowercase versions, use |\xintifzero|,
+ |\xintifnotzero|.\par }
\csa{xintifFalseAelseB}\marg{N}\marg{false branch}\marg{true branch}\etype{\Numf
nn} is a synonym for \csbxint{ifZero}.
@@ -9827,7 +10189,7 @@
The macros described next are all integer-only on input. Those with |ii| in
their names skip the \csbxint{Num} parsing. The others, with \xintfracname
loaded, can have fractions as arguments, which will get truncated to
- integers via \csbxint{TTrunc}. On output, the macros here always produce
+ integers via \csbxint{TTrunc}. On output, these macros always produce
integers (with no |/B[N]|).
\end{framed}
@@ -9906,10 +10268,12 @@
them to an integer.
When |x<0| an out-of-range error is raised. Else, if |y<0| or if |x<y| the macro
-evaluates to \dtt{\xintiiBinomial{1}{-1}}.\CHANGED{1.2h}
+evaluates to \dtt{\xintiiBinomial{1}{-1}}\CHANGED{1.2h} (it was a bit
+unfortunate that the |1.2f| version deliberately raised an out-of-range error
+for the cases |y<0| and |y>x|, with a positive |x|.)
\begin{framed}
- The (theoretically) allowable range is $0\leqslant y \leqslant x\leqslant99999999$.
+ The allowable range is $0\leqslant x\leqslant99999999$.
\end{framed}
% Thus the maximal computable value is ${9999 \choose 5000}$ which turns out
% to have \dtt{3008} digits.
@@ -9964,7 +10328,7 @@
\label{xintiiPFactorial}
|\xintiiPFactorial{a}{b}|\etype{\numx\numx} computes the partial factorial
-|(a+1)(a+2)...b|.
+|(a+1)(a+2)...b|. For |a=b| the product is considered empty hence returns |1|.
|\xintiPFactorial| is originally a synonym.\NewWith{1.2f}
With \xintfracname loaded it applies
@@ -9972,28 +10336,34 @@
them to an integer.
\begin{framed}
- The (theoretically) allowable range is $0\leqslant a \leqslant
- b\leqslant99999999$. If |a=b| the value is |1|.
+ The allowed range with |1.2f| was $0\leqslant a \leqslant b\leqslant99999999$.
+ It was a bit unfortunate with
+ |1.2f| that the code deliberately raised an error if this condition
+ was not obeyed by the arguments.
+
+ Starting with |1.2h|, $-100000000\leqslant a, b\leqslant99999999$ is
+ accepted.\CHANGEDf{1.2h}
+ The
+ rule is to interpret the formula as the product of the
+ $j$'s such that $a<j\leqslant b$, hence in particular if $a\geqslant b$ the
+ product is empty and the macro evaluates to |1|.
+
+ Only for $0\leqslant a\leqslant b$ is the behaviour to be considered
+ stable. For $a>b$ or negative arguments, the definitive rules have not yet
+ been fixed.
+
\begin{everbatim*}
\xintiiPFactorial {100}{130}
\end{everbatim*}
\end{framed}
-It was a bit unfortunate with
-|1.2f| that the code deliberately raised an error if the condition
-|0<=a<=b<10^8| was violated. The rule now\CHANGED{1.2h} with |1.2h|is to
-interpret it as the product of the |j| for |a<j<=b|, hence if |a>=b|, it
-returns |1| because of an empty product. But only for the range |0<= a <= b <
-10^8| is it to be considered that the behaviour is fixed and will not change
-in the future.
+This theoretical range allows computations whose result values would have more
+than the roughly 19950 digits that the arithmetics of \xintname can handle. In
+such cases, the computation will end up in a low-level \TeX{} error after a
+long time.
- This theoretical range includes values with more than the
- roughly 19950 digits that the arithmetics of \xintname can handle. In such
- cases, the computation will end up in a low-level \TeX{} error after a
- long time.
-
%
The |pfactorial| function is available in the \xintexprname parsers.
\begin{everbatim*}
@@ -10014,22 +10384,10 @@
\begin{framed}
- The macros described next are strictly for integer-only arguments. These
- arguments are \emph{not} filtered via \csbxint{Num}. The macros are not
- usable with fractions, even with \xintfracname loaded.
+ The macros described next are strictly for integer-only arguments (which get
+ only \fexpan ded, not filtered via \csbxint{Num}.)
\end{framed}
-\subsection{\csbh{xintDSL}}\label{xintDSL}
-
-|\xintDSL|\n\etype{f} is decimal shift left, \emph{i.e.} multiplication by
-ten.
-
-\subsection{\csbh{xintDSR}}\label{xintDSR}
-
-|\xintDSR|\n\etype{f} is decimal shift right, \emph{i.e.} it removes the last
-digit (keeping the sign), equivalently it is the closest integer to |N/10| when
-starting at zero.
-
\subsection{\csbh{xintDSH}}\label{xintDSH}
|\xintDSH|\x\n\etype{\numx f} is parametrized decimal shift. When |x| is
@@ -10065,82 +10423,34 @@
braces. So |Q| is |\xintDSH|\x\n, and |R| is |\xintDSHr|\x\n, but computed
simultaneously.
- \xintAssign\xintDSx {-1}{-123456789}\to\M
-\leftedline{|\xintAssign\xintDSx {-1}{-123456789}\to\M|}
-\leftedline{|\meaning\M: |\dtt{\meaning\M}.}
- \xintAssign\xintDSx {-20}{1234567689}\to\M
-\leftedline{|\xintAssign\xintDSx {-20}{123456789}\to\M|}
-\leftedline{|\meaning\M: |\dtt{\meaning\M}.}
- \xintAssign\xintDSx{0}{-123004321}\to\Q\R
-\leftedline{|\xintAssign\xintDSx {0}{-123004321}\to\Q\R|}
-\leftedline{|\meaning\Q: |\dtt{\meaning\Q}, |\meaning\R:|\dtt{\meaning\R.}}
-\leftedline{|\xintDSH {0}{-123004321}|\dtt{=\xintDSH {0}{-123004321}},
-|\xintDSHr {0}{-123004321}|\dtt{=\xintDSHr {0}{-123004321}}}
- \xintAssign\xintDSx {6}{-123004321}\to\Q\R
-\leftedline{|\xintAssign\xintDSx {6}{-123004321}\to\Q\R|}
-\leftedline{|\meaning\Q: |\dtt{\meaning\Q},|\meaning\R: |\dtt{\meaning\R.}}
-\leftedline{|\xintDSH {6}{-123004321}|\dtt{=\xintDSH {6}{-123004321}},
-|\xintDSHr {6}{-123004321}|\dtt{=\xintDSHr {6}{-123004321}}}
- \xintAssign\xintDSx {8}{-123004321}\to\Q\R
-\leftedline{|\xintAssign\xintDSx {8}{-123004321}\to\Q\R|}
-\leftedline{|\meaning\Q: |\dtt{\meaning\Q},|\meaning\R: |\dtt{\meaning\R.}}
-\leftedline{|\xintDSH {8}{-123004321}|\dtt{=\xintDSH {8}{-123004321}},
-|\xintDSHr {8}{-123004321}|\dtt{=\xintDSHr {8}{-123004321}}}
- \xintAssign\xintDSx {9}{-123004321}\to\Q\R
-\leftedline{|\xintAssign\xintDSx {9}{-123004321}\to\Q\R|}
-\leftedline{|\meaning\Q: |\dtt{\meaning\Q},|\meaning\R: |\dtt{\meaning\R.}}
-\leftedline{|\xintDSH {9}{-123004321}|\dtt{=\xintDSH {9}{-123004321}},
-|\xintDSHr {9}{-123004321}|\dtt{=\xintDSHr {9}{-123004321}}}
+\subsection{\csbh{xintDecSplit}, \csbh{xintDecSplitL}, \csbh{xintDecSplitR}}
+\label{xintDecSplit}
+\label{xintDecSplitL}
+\label{xintDecSplitR}
-\subsection{\csbh{xintDecSplit}}\label{xintDecSplit}
-
-
|\xintDecSplit|\x\n\etype{\numx f} cuts the number into two pieces (each one
-within a pair of enclosing braces). First the sign if present is \emph{removed}.
-Then, for |x| positive or null, the second piece contains the |x| least
-significant digits (\emph{empty} if |x=0|) and the first piece the remaining
-digits (\emph{empty} when |x| equals or exceeds the length of |N|). Leading
-zeroes in the second piece are not removed. When |x| is negative the first piece
-contains the \verb+|x|+ most significant digits and the second piece the
-remaining digits (\emph{empty} if $|x|$ equals or exceeds the length of |N|).
-Leading zeroes in this second piece are not removed. So the absolute value of the
-original number is always the concatenation of the first and second piece.
+within a pair of enclosing braces) |{L}{R}| where the decimal writing of |N|
+is the concatenation |LR|.
-{\footnotesize This macro's behavior for |N| non-negative is final and will not
- change. I am still hesitant about what to do with the sign of a
- negative |N|.\par}
+For |x| positive or null, |R| coincides with the |x| least
+significant digits and is \emph{empty} if |x=0|. If |x| equals or
+exceeds the length of |N| the first piece |L| is empty.
-\xintAssign\xintDecSplit {0}{-123004321}\to\L\R
-\leftedline{|\xintAssign\xintDecSplit {0}{-123004321}\to\L\R|}
-\leftedline{|\meaning\L: |\dtt{\meaning\L}, |\meaning\R: |\dtt{\meaning\R.}}
-\xintAssign\xintDecSplit {5}{-123004321}\to\L\R
-\leftedline{|\xintAssign\xintDecSplit {5}{-123004321}\to\L\R|}
-\leftedline{|\meaning\L: |\dtt{\meaning\L}, |\meaning\R: |\dtt{\meaning\R.}}
-\xintAssign\xintDecSplit {9}{-123004321}\to\L\R
-\leftedline{|\xintAssign\xintDecSplit {9}{-123004321}\to\L\R|}
-\leftedline{|\meaning\L: |\dtt{\meaning\L}, |\meaning\R: |\dtt{\meaning\R.}}
-\xintAssign\xintDecSplit {10}{-123004321}\to\L\R
-\leftedline{|\xintAssign\xintDecSplit {10}{-123004321}\to\L\R|}
-\leftedline{|\meaning\L: |\dtt{\meaning\L}, |\meaning\R: |\dtt{\meaning\R.}}
-\xintAssign\xintDecSplit {-5}{-12300004321}\to\L\R
-\leftedline{|\xintAssign\xintDecSplit {-5}{-12300004321}\to\L\R|}
-\leftedline{|\meaning\L: |\dtt{\meaning\L}, |\meaning\R: |\dtt{\meaning\R.}}
-\xintAssign\xintDecSplit {-11}{-12300004321}\to\L\R
-\leftedline{|\xintAssign\xintDecSplit {-11}{-12300004321}\to\L\R|}
-\leftedline{|\meaning\L: |\dtt{\meaning\L}, |\meaning\R: |\dtt{\meaning\R.}}
-\xintAssign\xintDecSplit {-15}{-12300004321}\to\L\R
-\leftedline{|\xintAssign\xintDecSplit {-15}{-12300004321}\to\L\R|}
-\leftedline{|\meaning\L: |\dtt{\meaning\L}, |\meaning\R: |\dtt{\meaning\R.}}
+When |x| is negative the first piece |L| contains the ($-x$) most
+significant digits and the second piece the remaining ones. Hence |R| is
+\emph{empty} if $|x|$ equals or exceeds the length of |N|.
-\subsection{\csbh{xintDecSplitL}}\label{xintDecSplitL}
+{\footnotesize Breaking change with |1.2i|: formerly |N<0| was replaced by its
+ absolute value. Now, a sign (positive or negative) will create an error.
+ The N must consists only of digit tokens (after \fexpan sion). Leading
+ zeroes are allowed.\par}
-|\xintDecSplitL|\x\n\etype{\numx f} returns the first piece after the action
-of \csa{xintDecSplit}.
-\subsection{\csbh{xintDecSplitR}}\label{xintDecSplitR}
+|\xintDecSplitL|\x\n\etype{\numx f} returns the first piece (unbraced) from
+the \csa{xintDecSplit} output.
-|\xintDecSplitR|\x\n\etype{\numx f} returns the second piece after the action
-of \csa{xintDecSplit}.
+|\xintDecSplitR|\x\n\etype{\numx f} returns the second piece (unbraced) from
+the \csa{xintDecSplit} output.
\subsection{\csbh{xintiiE}}\label{xintiiE}
@@ -10149,10 +10459,11 @@
\xintiiE {123}{89}
\end{everbatim*}
+
%\pagebreak
\clearpage
-\section{Commands of the \xintfracname package}
+\section{Macros of the \xintfracname package}
\label{sec:frac}
\begin{framed}
@@ -10207,10 +10518,6 @@
Some macros (such as \csbxint{iTrunc}, \csbxint{iRound}, and \csbxint{iFac})
always produce integers on output.
-The macro \csbxint{XTrunc} uses \csbxint{iloop} from package \xinttoolsname,
-hence there is a partial dependency of \xintfracname on
-\xinttoolsname,\IMPORTANT{} and the latter must be required explicitely by the
-user intending to use \csbxint{XTrunc}.
Refer to \autoref{ssec:floatingpoint} for general background information on
how floating point numbers and evaluations are implemented.
@@ -10218,7 +10525,6 @@
\subsection{\csbh{xintNum}}\label{xintNum}
The macro\etype{f} from \xintname is made a synonym to \csbxint{TTrunc}.%
-%(\textcolor[named]{PineGreen}{Changed!})
\footnote{In earlier releases than
|1.1|, \csbxint{Num} did \csbxint{Irr} and then complained if the
denominator was not |1|, else, it silently removed the denominator.}
@@ -10340,7 +10646,7 @@
\subsection{\csbh{xintREZ}}\label{xintREZ}
-This command\etype{\Ff} normalizes a fraction by removing the powers of ten from
+This macro\etype{\Ff} normalizes a fraction by removing the powers of ten from
its numerator and denominator: %
%
\leftedline{|\xintREZ
@@ -10352,7 +10658,7 @@
\subsection{\csbh{xintFrac}}\label{xintFrac}
-This is a \LaTeX{} only command,\etype{\Ff} to be used in math mode only. It
+This is a \LaTeX{} only macro,\etype{\Ff} to be used in math mode only. It
will print a fraction, internally represented as something equivalent to
|A/B[n]| as |\frac {A}{B}10^n|. The power of ten is omitted when |n=0|, the
denominator is omitted when it has value one, the number being separated from
@@ -10438,14 +10744,42 @@
\subsection{\csbh{xintTrunc}}\label{xintTrunc}
\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.
+then the first |x| digits of the decimal expansion of the fraction |f|, except
+when the fraction is (or evaluates to) zero, then it simply prints \dtt{0}
+(with no dot).
-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...$.
+\begin{framed}
+ The argument |x| must be non-negative, the behavior is currently undefined
+ when |x<0| and will provoke errors.
+\end{framed}
+
+Except when the input is (or evaluates to) exactly zero, the output contains
+exactly |x| digits after the decimal mark, thus the output may be
+\dtt{0.00...0} or \dtt{-0.00...0}, indicating that the original fraction was
+positive, respectively negative.
+
+\begin{framed}
+ \textbf{Warning:} \emph{it is not yet decided is this behavior is
+ definitive.}
+
+ Currently \xintfracname has no notion of a positive zero or a negative zero.
+ Hence transitivity of \csbxint{Trunc} is broken for the case where the first
+ truncation gives on output \dtt{0.00...0} or \dtt{-0.00...0}: a second
+ truncation to less digits will then output \dtt{0}, whereas if it had been
+ applied directly to the initial input it would have produced \dtt{0.00...0}
+ or respectively \dtt{-0.00...0} (with less zeros).
+
+ If \xintfracname distinguished zero, positive zero, and
+ negative zero it would be possible to maintain transitivity.
+
+ The problem would also be fixed, even without distinguishing a negative zero
+ on input, if \csbxint{Trunc} always produced \dtt{0.00...0} (with no sign)
+ when the mathematical result is zero, discarding the information on original
+ input being positive, zero, or negative.
+
+ I have multiple times hesitated about what to do and must postpone again
+ final decision.
+\end{framed}
%
\leftedline{|\xintTrunc
{16}{-803.2028/20905.298}|\dtt{=\xintTrunc {16}{-803.2028/20905.298}}}
@@ -10463,6 +10797,11 @@
{12}{\xintAdd {-1/3}{3/9}}}} The digits printed are exact up to and
including the last one.
+The macro is more efficient since |1.2i| in the case where the |{f}| argument
+is already a decimal number, and not a general fraction, as it avoids doing
+then a division by a possibly big power of ten, replacing it by use of
+\csbxint{DecSplit}.
+
\subsection{\csbh{xintiTrunc}}\label{xintiTrunc}
\csa{xintiTrunc}|{x}{f}|\etype{\numx\Ff} returns the integer equal to |10^x|
@@ -10491,117 +10830,165 @@
\subsection{\csbh{xintXTrunc}}\label{xintXTrunc}
-\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).
+\csa{xintXTrunc}|{x}{f}|\retype{\numx\Ff} is similar to \csbxint{Trunc} with
+the following important differences:
+\begin{itemize}[nosep]
+\item it is completely expandable but not
+\fexpan dable, as is indicated by the hollow star in the margin,
+\item hence it can not be used as argument to the other package macros, but as
+ it \fexpan ds its |{f}| argument, it accepts arguments expressed with other
+ \xintfracname macros,
+\item it requires |x>0|,
+\item contrarily to \csbxint{Trunc} the number of digits on output is not
+ limited to about \dtt{19950} and may go well beyond \dtt{100000} (this is
+ mainly useful for outputting a decimal expansion to a file),
+\item when the mathematical result is zero, it always prints it as
+ \dtt{0.00...0} or \dtt{-0.00...0} with |x| zeros after the decimal mark.
+\end{itemize}
-\begin{framed}
- To use \csa{xintXTrunc} the user must load \xinttoolsname, additionally to
- \xintfracname. The interactive session below does not show this because it
- was done at a time when \xintname (hence also \xintfracname) automatically
- loaded \xinttoolsname. This is not the case anymore. \csa{xintXTrunc} is the
- sole dependency of \xintfracname on \xinttoolsname.
-\end{framed}
-%
+\textbf{Warning:}
+transitivity is broken too (see discussion of \csbxint{Trunc}), due to the
+sign in the last item. Hence \emph{the definitive policy is yet to be fixed.}
+
+Transitivity is here in the sense of using a first |\edef| and then a second
+one, because it is not possible to nest \csb{xintXTrunc} directly as argument
+to itself. Besides, although the number of digits on output isn't limited,
+nevertheless |x| should be less than about |19970| when the number of digits
+of the input (assuming it is expressed as a decimal number) is even bigger:
+|\xintXTrunc{30000}{\Z}| after |\edef\Z{\xintXTrunc{60000}{1/66049}| raises an
+error in contrast with a direct |\xintXTrunc{30000}{1/66049}|. But
+|\xintXTrunc{30000}{123.456789}| works, because here the number of digits
+originally present is smaller than what is asked for, thus the routine only
+has to add trailing zeros, and this has no limitation (apart from \TeX\ main
+memory).
+
+
+\csbxint{XTrunc} will expand fully in an |\edef| or a |\write| (|\message|,
+|\wlog|, \dots) or in an \csbxint{expr}-ession, or as list argument to
+\csbxint{For*}.
+
+
+Here is an example session where the
+user checks that the decimal expansion of $1/66049=1/257^2$ has the maximal
+period length $257*256=65792$ (this period length must be a divisor of
+$\phi(66049)$ and to check it is the maximal one it is enough to show that
+neither $32896$ nor $256$ are periods.)
+
\begingroup\small
\everb|@
-xxx:_xint $ etex -jobname worksheet-66049
-This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
+$ rlwrap etex -jobname worksheet-66049
+This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=etex)
restricted \write18 enabled.
-**\relax
+**xintfrac.sty
entering extended mode
+(/usr/local/texlive/2016/texmf-dist/tex/generic/xint/xintfrac.sty
+(/usr/local/texlive/2016/texmf-dist/tex/generic/xint/xint.sty
+(/usr/local/texlive/2016/texmf-dist/tex/generic/xint/xintcore.sty
+(/usr/local/texlive/2016/texmf-dist/tex/generic/xint/xintkernel.sty))))
+*% we load xinttools for \xintKeep, etc... \xintXTrunc itself has no more
-*\input xintfrac.sty
-(./xintfrac.sty (./xint.sty (./xinttools.sty)))
-*\message{\xintTrunc {100}{1/71}}% Warming up!
+*% any dependency on xinttools.sty since 1.2i
-0.01408450704225352112676056338028169014084507042253521126760563380281690140845
-07042253521126760563380
-*\message{\xintTrunc {350}{1/71}}% period is 35
+*\input xinttools.sty
+(/usr/local/texlive/2016/texmf-dist/tex/generic/xint/xinttools.sty)
+*\def\m#1;{\message{#1}}
-0.01408450704225352112676056338028169014084507042253521126760563380281690140845
-0704225352112676056338028169014084507042253521126760563380281690140845070422535
-2112676056338028169014084507042253521126760563380281690140845070422535211267605
-6338028169014084507042253521126760563380281690140845070422535211267605633802816
-901408450704225352112676056338028169
-*\edef\Z {\xintXTrunc {65792}{1/66049}}% getting serious...
+*\m \the\numexpr 257*257\relax;
+66049
+*\m \the\numexpr 257*256\relax;
+65792
+*% Thus 1/66049 will have a period length dividing 65792.
-*\def\trim 0.{}\oodef\Z {\expandafter\trim\Z}% removing 0.
+*% Let us first check it is indeed periodical.
-*\edef\W {\xintXTrunc {131584}{1/66049}}% a few seconds
+*\edef\Z{\xintXTrunc{66000}{1/66049}}
-*\oodef\W {\expandafter\trim\W}
+*% Let's display the first decimal digits.
-*\oodef\ZZ {\expandafter\Z\Z}% doubling the period
+*\m \xintXTrunc{208}{\Z};
-*\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
+6538630410755651107511090251177156353616254598858423
+*% let's now fetch the trailing digits
+*\m \xintKeep{65792-66000}{\Z};% 208 trailing digits
+
+0000151402746445820527184363124347075655952398976517434026253236233705279413768
+5657617829187421459825281230601523111629244954503474693030931581098881133703765
+38630410755651107511090251177156353616254598858423
+*% yes they match! we now check that 65792/2 and 65792/257=256 aren't periods.
+
+*\m \xintXTrunc{256}{\Z};
+
0.00001514027464458205271843631243470756559523989765174340262532362337052794137
6856576178291874214598252812306015231116292449545034746930309315810988811337037
6538630410755651107511090251177156353616254598858423291798513225029902042423049
-5541189117170585474420505
-*\edef\X {\xintXTrunc {257*128}{1/66049}}% infix here ok, less than 8 tokens
+554118911717058547442
+*\m \xintXTrunc{256+256}{\Z};
-*\oodef\X {\expandafter\trim\X}% we now have the first 257*128 digits
+0.00001514027464458205271843631243470756559523989765174340262532362337052794137
+6856576178291874214598252812306015231116292449545034746930309315810988811337037
+6538630410755651107511090251177156353616254598858423291798513225029902042423049
+5541189117170585474420505987978621932201850141561567926842192917379521264515738
+3154930430438008145467758785144362518736089872670290239064936637950612424109373
+3440324607488379839210283274538600130206361943405653378552286938485064119063119
+8049932625777831609865402958409665551333
+*% now with 65792/2=32896. Problem: we can't do \xintXTrunc{32896+100}{\Z}
-*\oodef\XX {\expandafter\X\X}% was 257*128 a period?
+*% but only direct \xintXTrunc{32896+100}{1/66049}. Anyway we want to nest it
-*\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)}
+*% hence let's do it all with (slower) \xintKeep, \xintKeepUnbraced.
-*\oodef\ZA {\xintNum {\Z}}% we remove the 0000, or we could use next \xintiMul
+*\m \xintKeep {-100}{\xintKeepUnbraced{2+65792/2+100}{\Z}};
-*\immediate\write-1 {10\string^65792-1=\xintiiMul {\ZA}{66049}}
+9999848597253554179472815636875652924344047601023482565973746763766294720586231
+434238217081257854017
+*% This confirms 32896 isn't a period length.
-*% This was slow :( I should write a multiplication, still completely
+*% To conclude let's write the 66000 digits to the log.
-*% expandable, but not f-expandable, which could be much faster on such cases.
+*\wlog{\Z}
+*% We want always more digits:
+
+*\wlog{\xintXTrunc{150000}{1/66049}}
+
*\bye
-No pages of output.
-Transcript written on worksheet-66049.log.
-xxx:_xint $
|
-\endgroup
+\endgroup % $ à cause de fontification de AUCTeX.
+The acute observer will have noticed that there is something funny when one
+compares the first digits with those after the middle-period:
+\begin{everbatim}
+0000151402746445820527184363124347075655952398976517434026253236233705279413768...
+9999848597253554179472815636875652924344047601023482565973746763766294720586231...
+\end{everbatim}
+Mathematical exercise: can you explain why the two indeed add to |9999...9999|?
+You can try your hands at this simpler one:
+\begin{everbatim*}
+1/49=\xintTrunc{42+5}{1/49}...\newline
+\xintTrim{2}{\xintTrunc{21}{1/49}}\newline
+\xintKeep{-21}{\xintTrunc{42}{1/49}}
+\end{everbatim*}
+
+This was again an example of the type |1/N| with |N| the square of a prime.
+One can also find counter-examples within this class: |1/31^2| and |1/37^2|
+have an odd period length (|465| and respectively |111|) hence they can not
+exhibit the symmetry.
+
\begin{framed}
- The |\xintiiMul {\ZA}{66049}| above can sadly \emph{not} be executed with
- \xintname 1.2, due to the new limitation to at most about $19950$ digits for
- multiplication. On the other hand |\edef\W {\xintXTrunc {131584}{1/66049}}|
- produces the $131584$ digits four times faster. The macro \csbxint{XTrunc}
- has not yet been adapted to the new integer model underlying the 1.2
- \xintcorename macros, and perhaps some future improvements are possible. So
- far it only benefits from a faster division routine, in that specific case
- for a divisor having more than four but less than nine digits.
+ Mathematical challenge: prove generally that if the period length of the
+ decimal expansion of |1/p^r| (with |p| a prime distinct from |2| and |5| and
+ |r| a positive exponent) is even, then the above symmetry applies.
\end{framed}
-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 |\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
- |\xintXTrunc|, especially for the case of a negative |N|. Doing these
- things with \TeX{} is an effort. Besides an |\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 |\xintexpr|
- context where things are expanded inside |\csname..\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$.
+Releases earlier than |1.2i| created a dependency of \xintfracname on
+\xinttoolsname only for this macro, this dependency does not exist anymore.
+
\subsection{\csbh{xintRound}}\label{xintRound}
@@ -11118,8 +11505,9 @@
binomial coefficients with either \csa{xinttheDigits} or |P| digits of
precision.\NewWith{1.2f}
-When |x<0| an out-of-range error is raised. Else, if |y<0| or if |x<y| the macro
-evaluates to \dtt{\xintFloatBinomial{1}{-1}}.\CHANGED{1.2h}
+When |x<0| an out-of-range error is raised. Else (this was changed in |1.2h|,
+see \autoref{xintiiBinomial}), if |y<0| or if |x<y| the macro
+evaluates to \dtt{\xintFloatBinomial{1}{-1}}.
The exact theoretical value differs from the calculated one |Y| by an absolute
error strictly less than |0.6 ulp(Y)|.
@@ -11180,15 +11568,16 @@
computes the product |(x+1)...y|.
The inputs |x| and |y| must evaluate to non-negative integers less in absolute
-value than
-$10^8$.\NewWith{1.2f}
+value than $10^8$. For |x=y| the product is considered empty hence the
+returned value is |1|.\NewWith{1.2f}
It was a bit unfortunate with |1.2f| that the code deliberately raised an
error if the condition |0<=x<=y<10^8| was violated. See
-\autoref{xintiiPFactorial} for the now prevailing rules.\CHANGED{1.2h} Only
-for the range |0<= x <= y < 10^8| is it to be considered that the behaviour is
-fixed and will not change in the future.
+\autoref{xintiiPFactorial} for the now prevailing rules.\CHANGED{1.2h}
+But only for the range |0<=x<=y<10^8| is it to be considered that the
+behaviour is fixed and will not change in the future.
+
The exact theoretical value differs from the calculated one |Y| by an absolute
error strictly less than |0.6 ulp(Y)|.
@@ -11254,7 +11643,7 @@
Again, $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.\footnote{The printing of the result was done
- via the |\numprint| command from the \url{http://ctan.org/pkg/numprint}
+ via the |\numprint| macro from the \url{http://ctan.org/pkg/numprint}
package.}
Inside an |\xintfloatexpr|-ession, \csa{xintFloatPower} is the function to
@@ -11342,7 +11731,7 @@
%\etocdepthtag.toc {xintexpr}
\clearpage
-\section{Commands of the \xintexprname package}%
+\section{Macros of the \xintexprname package}%
\label{sec:expr}
\localtableofcontents
@@ -11480,7 +11869,7 @@
part, and/or scientific notation (except for \csbxint{iiexpr} which only
admits big integers). All variants work with comma separated expressions. On
output each comma will be followed by a space. A decimal number must have
- digits either before or after the decimal mark.%\MyMarginNote{Changed!}
+ digits either before or after the decimal mark.
\item as everything gets expanded, the characters |.|, |+|, |-|, |*|, |/|, |^|,
|!|, |&|, \verb+|+, |?|, |:|, |<|, |>|, |=|, |(|, |)|, |"|, |]|, |[|, |@|
@@ -11488,7 +11877,7 @@
example, the French language in |Babel| system, for pdf\LaTeX, activates |!|,
|?|, |;| and |:|. Turn off the activity before the expressions.
- Alternatively the command \csbxint{exprSafeCatcodes} resets all
+ Alternatively the macro \csbxint{exprSafeCatcodes} resets all
characters potentially needed by \csbxint{expr} to their standard catcodes
and \csbxint{exprRestoreCatcodes} restores the status prevailing at the time
of the previous \csa{xintexprSafeCatcodes}.
@@ -11717,6 +12106,7 @@
\hyperlink{BrentSalamin}{Brent-Salamin algorithm implementation} for a much
saner example.}
%
+
\xintexprname has minimal tools and
is obstinate about doing everything expandably! We are hampered by absence of a
notion of ``nuple''. The algorithm divides |N| by |2| until no more possible,
@@ -11752,65 +12142,18 @@
confusing to the parser.)
\end{snugframed}
-For comparison, here is an \fexpan dable macro expanding to the same result,
-but coded directly with the \xintname macros. Here |#1| can not be itself an
-expression, naturally. But at least we let |\Factorize| \fexpan d its
-argument.
-\begin{everbatim}
-\makeatletter
-\newcommand\Factorize [1]
- {\romannumeral0\expandafter\factorize\expandafter{\romannumeral-`0#1}}%
-\newcommand\factorize [1]{\xintiiifOne{#1}{ 1}{\factors at a #1.{#1};}}%
-\def\factors at a #1.{\xintiiifOdd{#1}
- {\factors at c 3.#1.}%
- {\expandafter\factors at b \expandafter1\expandafter.\romannumeral0\xinthalf{#1}.}}%
-\def\factors at b #1.#2.{\xintiiifOne{#2}
- {\factors at end {2, #1}}%
- {\xintiiifOdd{#2}{\factors at c 3.#2.{2, #1}}%
- {\expandafter\factors at b \the\numexpr #1+\@ne\expandafter.%
- \romannumeral0\xinthalf{#2}.}}%
-}%
-\def\factors at c #1.#2.{%
- \expandafter\factors at d\romannumeral0\xintiidivision {#2}{#1}{#1}{#2}%
-}%
-\def\factors at d #1#2#3#4{\xintiiifNotZero{#2}
- {\xintiiifGt{#3}{#1}
- {\factors at end {#4, 1}}% ultimate quotient is a prime with power 1
- {\expandafter\factors at c\the\numexpr #3+\tw at .#4.}}%
- {\factors at e 1.#3.#1.}%
-}%
-\def\factors at e #1.#2.#3.{\xintiiifOne{#3}
- {\factors at end {#2, #1}}%
- {\expandafter\factors at f\romannumeral0\xintiidivision {#3}{#2}{#1}{#2}{#3}}%
-}%
-\def\factors at f #1#2#3#4#5{\xintiiifNotZero{#2}
- {\expandafter\factors at c\the\numexpr #4+\tw at .#5.{#4, #3}}%
- {\expandafter\factors at e\the\numexpr #3+\@ne.#4.#1.}%
-}%
-\def\factors at end #1;{\xintlistwithsep{, }{\xintRevWithBraces {#1}}}%
-\makeatother
-\end{everbatim}
-
-
-The macro |\Factorize| puts a little stress on the input save stack in order
-not be bothered with previously gathered things. I timed it to be about seven
-times faster than |\Factors| in test cases such as
+See \autoref{ssec:factorize} for a routine |\Factorize| written directly with
+\xintname macros. Last time I checked |\Factors| was about seven times slower
+than |\Factorize| in test cases such as
|16246355912554185673266068721806243461403654781833| and others. Among the
-various things explaining the speed-up, there is fact that we step by
-increments of two, not one, and also that we divide only once, obtaining
-quotient and remainder in one go. These two things already make for a speed-up
-factor of about four. Thus, our earlier |\Factors| was not completely
-inefficient, and was quite easier to come up with than
-|\Factorize|.\footnote{2015/11/18 I have not revisited this code for a long
- time, and perhaps I could improve it now with some new techniques.}
+various things explaining the speed difference, there is fact that the
+|\Factorize| algorithm step by increments of two, not one, and also it divides
+only once, obtaining quotient and remainder in one go. These two things
+already make for a speed-up factor of about four. Thus, |\Factors| is not
+completely inefficient in comparison, and was quite easier to come up with
+than |\Factorize|.
-If we only considered small integers, we could write pure |\numexpr| methods
-which would be very much faster (especially if we had a table of small primes
-prepared first) but still ridiculously slow compared to any non expandable
-implementation, not to mention use of programming languages directly accessing
-the CPU registers\dots
-
-\subsection{The \csbh{xintthecoords} command}
+\subsection{The \csbh{xintthecoords} macro}
\label{xintthecoords}
It converts a comma separated list into the format for list of coordinates as
@@ -11909,7 +12252,7 @@
\subsubsection{\csbh{xintexprSafeCatcodes}}
\label{xintexprSafeCatcodes}
-This command sets the catcodes of the relevant characters to safe values. This
+This macro sets the catcodes of the relevant characters to safe values. This
is used internally by \csbxint{NewExpr} (restoring the catcodes on exit),
hence \csa{xintNewExpr} does not have to be protected against active
characters.
@@ -12029,7 +12372,7 @@
Most certainly, there will be a a few dozens formulae at most, but they will
be used again and again with varying inputs.
-With the \csbxint{NewExpr} command, it is possible to convert once and
+With the \csbxint{NewExpr} macro, 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
@@ -12040,16 +12383,15 @@
Notice that since |1.2c| the \csbxint{deffunc} construct allows an alternative
to \csa{xintNewExpr} whose syntax uses arbitrary letters rather than macro
-parameters |#1|, |#2|, .... The declared function must still be used inside an
-expression, thus the |\csname...\endcsname| problem is not completely
-eliminated, but the computation it realizes will need only as many |\csname|'s
-as there are arguments to the function and will create only one more to store
-the result of the evaluation.
+parameters |#1|, |#2|, ..., |#9|. The declared function must still be used
+inside an expression, but its use will need only as many |\csname|'s as were
+needed for the function arguments plus one more for encapsulating the function
+result.
-\subsection{The \csbh{xintNewExpr} command}
+\subsection{The \csbh{xintNewExpr} macro}
\label{xintNewExpr}
-The command is used as:
+The macro is used as:
%
\leftedline{|\xintNewExpr{\myformula}[n]|\marg{stuff}, where}
\begin{itemize}
@@ -12296,7 +12638,7 @@
\subsubsection{External macros and \csbh{NewExpr}; the protect function}
\label{sssec:protect}
-For macros within such a created \xintname-formula command, there
+For macros within such a created \xintname-formula macro, there
are two cases:
\begin{itemize}
\item the macro does not involve the numbered parameters in its arguments: it
@@ -12393,7 +12735,7 @@
but only |\xintexpr|, so this restriction on the \csa{xintNewExpr} syntax
isn't really one.
-\subsection{The \csbh{xintNewFunction} command}
+\subsection{The \csbh{xintNewFunction} macro}
See \autoref{xintNewFunction} for its documentation.\NewWith{1.2h}
@@ -12750,7 +13092,7 @@
\clearpage
-\section{Commands of the \xintbinhexname package}
+\section{Macros of the \xintbinhexname package}
\label{sec:binhex}
\localtableofcontents
@@ -12824,7 +13166,7 @@
\dtt{->\printnumber{\xintCHexToBin{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}}}
\clearpage
-\section{Commands of the \xintgcdname package}
+\section{Macros of the \xintgcdname package}
\label{sec:gcd}
\localtableofcontents
@@ -12982,7 +13324,7 @@
\xintTypesetBezoutAlgorithm {10000}{1113}
\clearpage
-\section{Commands of the \xintseriesname package}
+\section{Macros of the \xintseriesname package}
\label{sec:series}
\localtableofcontents
@@ -13007,7 +13349,7 @@
\csa{xintSeries}|{A}{B}{\coeff}|\etype{\numx\numx\Ff} computes
$\sum_{\text{|n=A|}}^{\text{|n=B|}}|\coeff{n}|$. The initial and final indices
must obey the |\numexpr| constraint of expanding to numbers at most |2^31-1|.
-The |\coeff| macro must be a one-parameter \fexpan dable command, taking on
+The |\coeff| macro must be a one-parameter \fexpan dable macro, taking on
input an explicit number |n| and producing some number or fraction |\coeff{n}|;
it is expanded at the time it is
needed.%
@@ -13143,7 +13485,7 @@
must be such that |\macro{n}| expands to |F(n)/F(n-1)|. The name indicates that
\csa{xintRationalSeries} was designed to be useful in the cases where
|F(n)/F(n-1)| is a rational function of |n| but it may be anything expanding to
-a fraction. The macro |\ratio| must be an expandable-only compatible command and
+a fraction. The macro |\ratio| must be an expandable-only compatible macro and
expand to its value after iterated full expansion of its first token. |A| and
|B| are fed to a |\numexpr| hence may be count registers or arithmetic
expressions built with such; they must obey the \TeX{} bound. The initial term
@@ -13181,7 +13523,7 @@
a macro with two parameters: |\def\ratioexp
#1#2{\xintDiv{#1}{#2}}|\texttt{\%}| x/n: x=#1, n=#2|.
Then, if |\x| expands to some fraction |x|, the
-command %
+macro %
%
\leftedline{|\xintRationalSeries {0}{b}{1}{\ratioexp{\x}}|}
will compute $\sum_{n=0}^{n=b} x^n/n!$:\par
@@ -13354,7 +13696,7 @@
$\sum_{\text{|n=A|}}^{\text{|n=B|}}|\coeff{n}|\cdot |f|^{\text{|n|}}$. The
initial and final indices are given to a |\numexpr| expression. The |\coeff|
macro (which, as argument to \csa{xintPowerSeries} is expanded only at the time
-|\coeff{n}| is needed) should be defined as a one-parameter expandable command,
+|\coeff{n}| is needed) should be defined as a one-parameter expandable macro,
its input will be an explicit number.
The |f| can be either a fraction directly input or a macro |\f| expanding to
@@ -13597,7 +13939,7 @@
with which it was computed, as the last are to be considered garbage.
Rather, one should keep from the output only some smaller number of
digits. This will make further computations faster and not less precise.
-I guess there should be some command to do this final truncating, or
+I guess there should be some macro to do this final truncating, or
better, rounding, at a given number |D'<D| of digits. Maybe for the next
release.
@@ -13859,7 +14201,7 @@
|
This will log the first 1000 digits of $\pi$ after the decimal point. On my
-laptop (a 2012 model) this took about $5.6$ seconds last time I tried.%
+laptop (a 2012 model) this took about $5.05$ seconds last time I tried.%
%
\footnote{With \texttt{1.09i} and earlier \xintname, this used to be \dtt{42}
seconds; starting with \texttt{1.09j}, and prior to \texttt{1.2}, it was
@@ -13870,25 +14212,26 @@
\footnote{With |\xintDigits:=1001;|, the non-optimized implementation with the
|iter| of \xintexprname fame using the
\hyperlink{BrentSalamin}{Brent-Salamin algorithm}, took, last time I tried
- (1.2g), about \dtt{7.4} seconds on my laptop (the last two digits were
- wrong, which is ok as they serve as guard digits), and for obtaining about
- \dtt{500} digits, it was of \dtt{1.6}s. This is not bad, taking into account
- that the syntax is almost free rolling speech, contrarily to the code above
- for the Machin formula computation; we would like to use the quadratically
- convergent Brent-Salamin algorithm for more digits, but with such
- computations with numbers of one thousand digits we are beyond the border of
- the reasonable range for \xintname. Innocent people not knowing what it
- means to compute with \TeX, and with the extra constraint of expandability
- will wonder why this is at least thousands of times slower than with any
- other language (with a little Python program using the |Decimal| library, I
- timed the Brent-Salamin algorithm to \dtt{4.4ms} for about |1000| digits and
- \dtt{1.14ms} for |500| digits.) I will just say that for example digits are
- represented and manipulated via their ascii-code ! all computations must
- convert from ascii-code to cpu words; furthermore nothing can be stored
- away. And there is no memory storage with |O(1)| time access... if
- expandability is to be verified.}
+ (1.2i), about \dtt{7} seconds on my laptop (the last two digits were wrong,
+ which is ok as they serve as guard digits), and for obtaining about
+ \dtt{500} digits, it was about \dtt{1.7}s. This is not bad, taking into
+ account that the syntax is almost free rolling speech, contrarily to the
+ code above for the Machin formula computation; we would like to use the
+ quadratically convergent Brent-Salamin algorithm for more digits, but with
+ such computations with numbers of one thousand digits we are beyond the
+ border of the reasonable range for \xintname. Innocent people not knowing
+ what it means to compute with \TeX, and with the extra constraint of
+ expandability will wonder why this is at least thousands of times slower
+ than with any other language (with a little Python program using the
+ |Decimal| library, I timed the Brent-Salamin algorithm to \dtt{4.4ms} for
+ about |1000| digits and \dtt{1.14ms} for |500| digits.) I will just say that
+ for example digits are represented and manipulated via their ascii-code !
+ all computations must convert from ascii-code to cpu words; furthermore
+ nothing can be stored away. And there is no memory storage with |O(1)| time
+ access... if expandability is to be verified.}
%
+
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
@@ -13922,7 +14265,7 @@
always do it on a value computed with |D+1| truncation.
\clearpage
-\section{Commands of the \xintcfracname package}
+\section{Macros of the \xintcfracname package}
\label{sec:cfrac}
\localtableofcontents
@@ -13972,7 +14315,7 @@
\begin{everbatim*}
\[ \xintFrac {208341/66317}=\xintCFrac {208341/66317}\]%
\end{everbatim*}
-But it is the command \csbxint{CFrac} which did all the work of \emph{computing}
+But it is the macro \csbxint{CFrac} which did all the work of \emph{computing}
the continued fraction \emph{and} using |\cfrac| from |amsmath| to typeset
it.
@@ -13992,7 +14335,7 @@
=\xintCFrac {915286/188421}\]
\end{everbatim*}
-The command \csbxint{GCFrac}, contrarily to
+The macro \csbxint{GCFrac}, contrarily to
\csbxint{CFrac}, does not compute anything, it just typesets starting from a
generalized continued fraction in inline format, which in this example
was input literally. We also used \csa{xintCFrac}
@@ -14034,7 +14377,7 @@
\begin{everbatim*}
\[-7,6,19,1,33\to\xintFrac{\xintCstoF{-7,6,19,1,33}}=\xintCFrac{\xintCstoF{-7,6,19,1,33}}\]
\end{everbatim*}
-The command \csbxint{FtoCs} produces from a fraction |f| the comma separated
+The macro \csbxint{FtoCs} produces from a fraction |f| the comma separated
list of its coefficients.
\begin{everbatim*}
\[\xintFrac{1084483/398959}=[\xintFtoCs{1084483/398959}]\]
@@ -14103,7 +14446,7 @@
\endgroup
The various fractions obtained from the truncation of a continued fraction to
-its initial terms are called the convergents. The commands of \xintcfracname
+its initial terms are called the convergents. The macros of \xintcfracname
such as \csbxint{FtoCv}, \csbxint{FtoCCv}, and others which compute such
convergents, return them as a list of braced items, with no separator (as does
\csbxint {FtoC} for the partial quotients). Here is an example:
@@ -14222,7 +14565,7 @@
Numerators and denominators are made arguments to the \csbxint{Frac}
macro. This allows them to be themselves fractions or anything \fexpan
dable giving numbers or fractions, but also means however that they can
-not be arbitrary material, they can not contain color changing commands
+not be arbitrary material, they can not contain color changing macros
for example. One of the reasons is that \csa{xintGCFrac} tries to
determine the signs of the numerators and chooses accordingly to use
$+$ or $-$.
@@ -14670,7 +15013,7 @@
%
\centeredline{|sourcexint.pdf|,}
%
- which should be among the candidates proposed by |texdoc --list xint|. To
+ which will open in a PDF viewer via |texdoc sourcexint.pdf|. To
produce a single file including both the user documentation and the
source code, run |tex xint.dtx| to generate |xint.tex| (if not already
available), then edit |xint.tex| to set the |\NoSourceCode| toggle to |0|,
@@ -14735,34 +15078,47 @@
% This is \expandafter|\xintbndlversion| of \expandafter|\xintbndldate|.
%
% \begin{itemize}
+% \item Some portions of the code still date back to the initial release, and
+% at that time I was learning my trade in expandable TeX macro programming.
+% At some point in the future, I will have to re-examine the older parts of
+% the code.
+%
+% \item Release |1.2i| of |2016/12/13| has rewritten some legacy macros like
+% |\xintDSR| or |\xintDecSplit| in the style of the techniques of |1.2|. But
+% this means also that they are now limited to about \dtt{22480} digits for
+% the former and \dtt{19970} digits for the latter (this is with the input
+% stack size at \dtt{5000} and the maximal expansion depth at \dtt{10000}.)
+% This is not really an issue from the point of view of calling macros (such
+% as |\xintTrunc|, |\xintRound|), because they usually had since |1.2| their
+% own limitation at about \dtt{19970} digits from other code parts (such as
+% division.) The macro |\xintXTrunc| (which is not f-expandable however) can
+% produce tens of thousands of digits and it escapes these limitations. Old
+% macros such as |\xintLength| are not limited either (incidentally it got a
+% lifting in |1.2i|.) The macros from \xinttoolsnameimp (|\xintKeep|,
+% |\xintTrim|, |\xintNthElt|) also are not limited (but slower.)
+%
% \item Release |1.2| of |2015/10/10| has entirely rewritten the core
% arithmetic routines in \xintcorenameimp. Many macros benefit indirectly
% from the faster core routines. The new model is yet to be extended to
% other portions of the code: for example the routines of \xintbinhexnameimp
% could be made faster for very big inputs if they adopted some techniques
-% from the implementation of the basic arithmetic routines.
+% from the implementation of the basic arithmetic routines. The parser of
+% \xintexprnameimp is faster and does not have a limit at |5000| digits per
+% number anymore.
%
-% The parser of \xintexprnameimp is also faster at gathering digits and does
-% not have a limit at |5000| digits per number anymore.
-%
% \item Extensive changes in release |1.1| of |2014/10/28| were located in
% \xintexprnameimp. Also with that release, packages \xintkernelnameimp and
% \xintcorenameimp were extracted from \xinttoolsnameimp and \xintnameimp,
% and |\xintAdd| was modified to not multiply denominators blindly.
%
-% \xinttoolsnameimp is not loaded anymore by \xintnameimp, nor by
-% \xintfracnameimp. It is loaded by \xintexprnameimp.
% \end{itemize}
%
-% Large portions of the code date back to the initial release, and at that
-% time I was learning my trade in expandable TeX macro programming. At some
-% point in the future, I will have to re-examine the older parts of the code.
+% Warning: pay attention when looking at the code to the catcode configuration
+% as found in |\XINT_setcatcodes|. Additional temporary configuration is used
+% at some locations. For example |!| is of catcode letter in \xintexprnameimp
+% and there are locations with funny catcodes e.g. using some letters with the
+% math shift catcode.
%
-% Warning: pay attention to the catcode configuration which is found in
-% |\XINT_setcatcodes|. The code has additional temporary configuration
-% at some locations. For example |!| is of catcode letter in \xintexprnameimp.
-%
-% \clearpage
% \section {Package \xintkernelnameimp implementation}
% \label{sec:kernelimp}
%
@@ -14776,6 +15132,8 @@
%
% First appeared as a separate package with release |1.1|.
%
+% |1.2i| adds \csa{xintreplicate}, \csa{xintgobble} and \csa{xintLengthUpTo}.
+%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
% The code for reload detection was initially copied from \textsc{Heiko
@@ -14944,7 +15302,7 @@
\fi
\XINT_providespackage
\ProvidesPackage {xintkernel}%
- [2016/11/20 1.2h Paraphernalia for the xint packages (JFB)]%
+ [2016/12/13 1.2i Paraphernalia for the xint packages (JFB)]%
% \end{macrocode}
% \subsection{Constants}
% |1.2| decides to move them to \xintkernelnameimp from \xintcorenameimp and
@@ -14993,7 +15351,7 @@
\let\XINT_tmpa\relax \let\XINT_tmpb\relax
\ifdefined\space\else\def\space { }\fi
\ifdefined\empty\else\def\empty {}\fi
-\long\def\xint_gobble_ {}%
+\let\xint_gobble_\empty
\long\def\xint_gobble_i #1{}%
\long\def\xint_gobble_ii #1#2{}%
\long\def\xint_gobble_iii #1#2#3{}%
@@ -15009,44 +15367,37 @@
\long\def\xint_firstofone_thenstop #1{ #1}%
\long\def\xint_firstoftwo_thenstop #1#2{ #1}%
\long\def\xint_secondoftwo_thenstop #1#2{ #2}%
-\def\xint_exchangetwo_keepbraces #1#2{{#2}{#1}}%
+\long\def\xint_exchangetwo_keepbraces #1#2{{#2}{#1}}%
% \end{macrocode}
% \lverb|&
-% It has taken me three years to realize that \romannumeral0 was stopped by a
-% minus sign with no side effect. I had here$newline
-% \def\xint_minus_thenstop { -}%$newline
-% but obviously it has no real utility !
-%
-% I had already started recently removing spaces in front of braces when I
-% spotted them in the old code ... but that story of the minus sign is really
-% strange. I knew it for a long time but never bothered looking back.
-% I had 35 uses in the code. Removed by 1.2g.
% |
%
% \subsection{``gob til'' macros and UD style fork}
% Some moved here from \xintcorenameimp by release |1.2|.
+%
+% |1.2i| finally makes all gobbling macros long.
% \begin{macrocode}
\long\def\xint_gob_til_R #1\R {}%
\long\def\xint_gob_til_W #1\W {}%
\long\def\xint_gob_til_Z #1\Z {}%
-\def\xint_gob_til_zero #10{}%
-\def\xint_gob_til_one #11{}%
-\def\xint_gob_til_zeros_iii #1000{}%
-\def\xint_gob_til_zeros_iv #10000{}%
-\def\xint_gob_til_eightzeroes #100000000{}%
-\def\xint_gob_til_exclam #1!{}% catcode 12 exclam
-\def\xint_gob_til_dot #1.{}%
-\def\xint_gob_til_G #1G{}%
-\def\xint_gob_til_minus #1-{}%
-\def\xint_gob_til_relax #1\relax {}%
-\def\xint_UDzerominusfork #10-#2#3\krof {#2}%
-\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}%
-\def\xint_UDXINTWfork #1\XINT_W#2#3\krof {#2}%
-\def\xint_UDzerosfork #100#2#3\krof {#2}%
-\def\xint_UDonezerofork #110#2#3\krof {#2}%
-\def\xint_UDsignsfork #1--#2#3\krof {#2}%
+\long\def\xint_gob_til_zero #10{}%
+\long\def\xint_gob_til_one #11{}%
+\long\def\xint_gob_til_zeros_iii #1000{}%
+\long\def\xint_gob_til_zeros_iv #10000{}%
+\long\def\xint_gob_til_eightzeroes #100000000{}%
+\long\def\xint_gob_til_exclam #1!{}% catcode 12 exclam
+\long\def\xint_gob_til_dot #1.{}%
+\long\def\xint_gob_til_G #1G{}%
+\long\def\xint_gob_til_minus #1-{}%
+\long\def\xint_gob_til_relax #1\relax {}%
+\long\def\xint_UDzerominusfork #10-#2#3\krof {#2}%
+\long\def\xint_UDzerofork #10#2#3\krof {#2}%
+\long\def\xint_UDsignfork #1-#2#3\krof {#2}%
+\long\def\xint_UDwfork #1\W#2#3\krof {#2}%
+\long\def\xint_UDXINTWfork #1\XINT_W#2#3\krof {#2}%
+\long\def\xint_UDzerosfork #100#2#3\krof {#2}%
+\long\def\xint_UDonezerofork #110#2#3\krof {#2}%
+\long\def\xint_UDsignsfork #1--#2#3\krof {#2}%
\let\xint_relax\relax
\def\xint_brelax {\xint_relax }%
\long\def\xint_gob_til_xint_relax #1\xint_relax {}%
@@ -15055,9 +15406,13 @@
% \begin{macrocode}
\long\def\xint_afterfi #1#2\fi {\fi #1}%
% \end{macrocode}
-% \subsection{\csh{xint_bye}}
+% \subsection{\csh{xint_bye}, \csh{xint_Bye}}
+% \lverb|\xint_Bye is new with 1.2i for \xintDSRr and \xintRound. Also
+% \xint_bye_thenstop.|
% \begin{macrocode}
\long\def\xint_bye #1\xint_bye {}%
+\long\def\xint_Bye #1\xint_bye {}%
+\long\def\xint_bye_thenstop #1\xint_bye { }%
% \end{macrocode}
% \subsection{\csh{xintdothis}, \csh{xintorthat}}
% \lverb|New with 1.1. Public names without underscores with 1.2. Used as
@@ -15103,10 +15458,12 @@
% $xintfracnameimp too. As said above, perhaps the zapspaces should force
% expansion too, but I leave it standing.
%
-% 1.2e adds \xint_zapspaces_o. Expansion of #1 should not gobble a space ! |
+% 1.2e adds \xint_zapspaces_o. Expansion of #1 should not gobble a space !
+%
+% Made long with 1.2i.|
% \begin{macrocode}
-\def\xint_zapspaces #1 #2{#1#2\xint_zapspaces }% 1.1
-\def\xint_zapspaces_o #1{\expandafter\xint_zapspaces#1 \xint_gobble_i}%
+\long\def\xint_zapspaces #1 #2{#1#2\xint_zapspaces }% 1.1
+\long\def\xint_zapspaces_o #1{\expandafter\xint_zapspaces#1 \xint_gobble_i}%
% \end{macrocode}
% \subsection{\csh{odef}, \csh{oodef}, \csh{fdef}}
% \lverb|May be prefixed with \global. No parameter text.|
@@ -15115,18 +15472,19 @@
\def\xintoodef #1{\expandafter\expandafter\expandafter\def
\expandafter\expandafter\expandafter#1%
\expandafter\expandafter\expandafter }%
-\def\xintfdef #1#2{\expandafter\def\expandafter#1\expandafter
- {\romannumeral`&&@#2}}%
+\def\xintfdef #1#2%
+ {\expandafter\def\expandafter#1\expandafter{\romannumeral`&&@#2}}%
\ifdefined\odef\else\let\odef\xintodef\fi
\ifdefined\oodef\else\let\oodef\xintoodef\fi
\ifdefined\fdef\else\let\fdef\xintfdef\fi
% \end{macrocode}
% \subsection{\csh{xintReverseOrder}}
-% \lverb|\xintReverseOrder: does NOT expand its argument. Thus one must use
-% some \expandafter if argument is a macro. A faster reverse, but only
-% applicable to (many) digit tokens has been provided with
-% \csh{xintReverseDigits} from 1.2 xintcore.
+% \lverb|\xintReverseOrder: does not expand its argument. Thus one must use
+% some \expandafter if argument is a macro. Attention: removes braces.
%
+% A faster reverse, but only usable with digits, is provided by
+% \csh{xintReverseDigits} macro from 1.2 xintcore.sty.
+%
% 1.2g has (not user documented) \xintCSVReverse in xinttools.sty.|
% \begin{macrocode}
\def\xintReverseOrder {\romannumeral0\xintreverseorder }%
@@ -15149,42 +15507,288 @@
}%
% \end{macrocode}
% \subsection{\csh{xintLength}}
-% \lverb|\xintLength does NOT expand its argument.
+% \lverb|\xintLength does not expand its argument. See \xintNthElt{0} from
+% xinttools.sty which f-expands its argument.
%
-% 1.2g has (not user documented) \xintCSVLength in xinttools.sty.|
+% 1.2g has (not user documented) \xintCSVLength in xinttools.sty.
+%
+% 1.2i has rewritten this venerable macro. New code is about 40$% faster
+% across all lengths.|
% \begin{macrocode}
\def\xintLength {\romannumeral0\xintlength }%
-\long\def\xintlength #1%
+\long\edef\xintlength #1%
{%
- \XINT_length_loop
- 0.#1\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ \noexpand\expandafter\space
+ \noexpand\the\numexpr\xint_c_ix\noexpand\XINT_length_loop
+ #1\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\noexpand\xint_bye
+ \relax
}%
-\long\def\XINT_length_loop #1.#2#3#4#5#6#7#8#9%
+\long\def\XINT_length_loop #1#2#3#4#5#6#7#8#9%
{%
\xint_gob_til_xint_relax #9\XINT_length_finish_a\xint_relax
- \expandafter\XINT_length_loop\the\numexpr #1+\xint_c_viii.%
+ +\xint_c_ix\XINT_length_loop
}%
-\def\XINT_length_finish_a\xint_relax\expandafter\XINT_length_loop
- \the\numexpr #1+\xint_c_viii.#2\xint_bye
+\def\XINT_length_finish_a\xint_relax+\xint_c_ix\XINT_length_loop
+ #1#2#3#4#5#6#7#8#9%
{%
- \XINT_length_finish_b #2\W\W\W\W\W\W\W\Z {#1}%
+ -#9\xint_bye
}%
-\def\XINT_length_finish_b #1#2#3#4#5#6#7#8\Z
+% \end{macrocode}
+% \subsection{\csh{xintLastItem}}
+% \lverb|New with 1.2i (2016/12/10). Output empty if input empty. One level
+% of braces removed in output.
+% |
+% \begin{macrocode}
+\def\xintLastItem {\romannumeral0\xintlastitem }%
+\long\def\xintlastitem #1%
{%
+ \XINT_last_loop {}.#1%
+ {\xint_relax\XINT_last_loop_enda}{\xint_relax\XINT_last_loop_endb}%
+ {\xint_relax\XINT_last_loop_endc}{\xint_relax\XINT_last_loop_endd}%
+ {\xint_relax\XINT_last_loop_ende}{\xint_relax\XINT_last_loop_endf}%
+ {\xint_relax\XINT_last_loop_endg}{\xint_relax\XINT_last_loop_endh}\xint_bye
+}%
+\long\def\XINT_last_loop #1.#2#3#4#5#6#7#8#9%
+{%
+ \xint_gob_til_xint_relax #9%
+ {#8}{#7}{#6}{#5}{#4}{#3}{#2}{#1}\xint_relax
+ \XINT_last_loop {#9}.%
+}%
+\long\def\XINT_last_loop_enda #1#2\xint_bye{ #1}%
+\long\def\XINT_last_loop_endb #1#2#3\xint_bye{ #2}%
+\long\def\XINT_last_loop_endc #1#2#3#4\xint_bye{ #3}%
+\long\def\XINT_last_loop_endd #1#2#3#4#5\xint_bye{ #4}%
+\long\def\XINT_last_loop_ende #1#2#3#4#5#6\xint_bye{ #5}%
+\long\def\XINT_last_loop_endf #1#2#3#4#5#6#7\xint_bye{ #6}%
+\long\def\XINT_last_loop_endg #1#2#3#4#5#6#7#8\xint_bye{ #7}%
+\long\def\XINT_last_loop_endh #1#2#3#4#5#6#7#8#9\xint_bye{ #8}%
+% \end{macrocode}
+% \subsection{\csh{xintLengthUpTo}}
+% \lverb|1.2i for use by \xintKeep and \xintTrim.
+%
+% \xintLengthUpTo{N}{L} produces -0 if length(L)>N, else it returns
+% N-length(L). Hence subtracting it from N always computes min(N,length(L)).|
+% \begin{macrocode}
+\def\xintLengthUpTo {\romannumeral0\xintlengthupto}%
+\long\def\xintlengthupto #1#2%
+{%
+ \expandafter\XINT_lengthupto_loop
+ \the\numexpr#1.#2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+}%
+\def\XINT_lengthupto_loop #1%
+{%
+ \xint_UDsignfork #1\XINT_lengthupto_gt-{\XINT_lengthupto_loop_a#1}\krof
+}%
+\long\def\XINT_lengthupto_gt #1\xint_bye{-0}%
+\long\def\XINT_lengthupto_loop_a #1.#2#3#4#5#6#7#8#9%
+{%
+ \xint_gob_til_xint_relax #9\XINT_lengthupto_finish_a\xint_relax
+ \expandafter\XINT_lengthupto_loop\the\numexpr #1-\xint_c_viii.%
+}%
+\def\XINT_lengthupto_finish_a\xint_relax\expandafter\XINT_lengthupto_loop
+ \the\numexpr #1-\xint_c_viii.#2\xint_bye
+{%
+ \XINT_lengthupto_finish_b #2\W\W\W\W\W\W\W\Z {#1}%
+}%
+\def\XINT_lengthupto_finish_b #1#2#3#4#5#6#7#8\Z
+{%
\xint_gob_til_W
- #1\XINT_length_finish_c \xint_c_
- #2\XINT_length_finish_c \xint_c_i
- #3\XINT_length_finish_c \xint_c_ii
- #4\XINT_length_finish_c \xint_c_iii
- #5\XINT_length_finish_c \xint_c_iv
- #6\XINT_length_finish_c \xint_c_v
- #7\XINT_length_finish_c \xint_c_vi
- \W\XINT_length_finish_c \xint_c_vii\Z
+ #1\XINT_lengthupto_finish_c \xint_c_
+ #2\XINT_lengthupto_finish_c \xint_c_i
+ #3\XINT_lengthupto_finish_c \xint_c_ii
+ #4\XINT_lengthupto_finish_c \xint_c_iii
+ #5\XINT_lengthupto_finish_c \xint_c_iv
+ #6\XINT_lengthupto_finish_c \xint_c_v
+ #7\XINT_lengthupto_finish_c \xint_c_vi
+ \W\XINT_lengthupto_finish_c \xint_c_vii\Z
}%
-\edef\XINT_length_finish_c #1#2\Z #3%
- {\noexpand\expandafter\space\noexpand\the\numexpr #3+#1\relax}%
+\def\XINT_lengthupto_finish_c #1#2\Z #3%
+ {\ifnum #1>#3 \xint_dothis{-0}\fi
+ \xint_orthat{\expandafter\space\the\numexpr#3-#1\relax}}%
% \end{macrocode}
+% \subsection{\csh{xintreplicate}}
+% \lverb|Added with 1.2i. This is cloned from \prg_replicate:nn from expl3, see Joseph's post
+% at
+% $centeredline{$catcode125=2 http://tex.stackexchange.com/questions/16189/repeat-command-n-times}
+% I
+% posted there an alternative not using the chained \csname's but it is a bit
+% less efficient (except perhaps for thousands of repetitions). Notice that
+% the code in Joseph's post is inefficient when input #1 is negative. The
+% variant here filters it out upfront, at the time when #1=0 is also handled.
+%
+% Expansion must be triggered by a \romannumeral.|
+% \begin{macrocode}
+\def\xintreplicate#1%
+ {\expandafter\XINT_replicate\the\numexpr#1\endcsname}%
+\def\XINT_replicate #1{\xint_UDsignfork
+ #1\XINT_rep_neg
+ -\XINT_rep
+ \krof #1}%
+\long\def\XINT_rep_neg #1\endcsname #2{\xint_c_}%
+\def\XINT_rep #1{\csname XINT_rep_f#1\XINT_rep_a}%
+\def\XINT_rep_a #1{\csname XINT_rep_#1\XINT_rep_a}%
+\def\XINT_rep_\XINT_rep_a{\endcsname}%
+\long\expandafter\def\csname XINT_rep_0\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}}%
+\long\expandafter\def\csname XINT_rep_1\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1}%
+\long\expandafter\def\csname XINT_rep_2\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1}%
+\long\expandafter\def\csname XINT_rep_3\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1}%
+\long\expandafter\def\csname XINT_rep_4\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_5\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_6\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_7\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_8\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_9\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_f0\endcsname #1%
+ {\xint_c_}%
+\long\expandafter\def\csname XINT_rep_f1\endcsname #1%
+ {\xint_c_ #1}%
+\long\expandafter\def\csname XINT_rep_f2\endcsname #1%
+ {\xint_c_ #1#1}%
+\long\expandafter\def\csname XINT_rep_f3\endcsname #1%
+ {\xint_c_ #1#1#1}%
+\long\expandafter\def\csname XINT_rep_f4\endcsname #1%
+ {\xint_c_ #1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_f5\endcsname #1%
+ {\xint_c_ #1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_f6\endcsname #1%
+ {\xint_c_ #1#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_f7\endcsname #1%
+ {\xint_c_ #1#1#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_f8\endcsname #1%
+ {\xint_c_ #1#1#1#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_f9\endcsname #1%
+ {\xint_c_ #1#1#1#1#1#1#1#1#1}%
+% \end{macrocode}
+% \subsection{\csh{xintgobble}}
+% \lverb|Added with 1.2i.
+% I hesitated about allowing as many as 9^6-1=531440 tokens to gobble, but
+% 9^5-1=59058 is too low for playing with long decimal expansions.
+%
+% Like for \xintreplicate, a \romannumeral is needed to trigger expansion.
+%
+% I wrote in a similar spirit an \xintcount. But it proved slower than the
+% upgraded 1.2i \xintLength in all the range up to thousands of tokens.|
+% \begin{macrocode}
+\def\xintgobble #1%
+ {\csname xint_c_\expandafter\XINT_gobble_a\the\numexpr#1.0}%
+\def\XINT_gobble #1.{\csname xint_c_\XINT_gobble_a #1.0}%
+\def\XINT_gobble_a #1{\xint_gob_til_zero#1\XINT_gobble_d0\XINT_gobble_b#1}%
+\def\XINT_gobble_b #1.#2%
+ {\expandafter\XINT_gobble_c
+ \the\numexpr (#1+\xint_c_v)/\xint_c_ix-\xint_c_i\expandafter.%
+ \the\numexpr #2+\xint_c_i.#1.}%
+\def\XINT_gobble_c #1.#2.#3.%
+ {\csname XINT_g#2\the\numexpr#3-\xint_c_ix*#1\relax\XINT_gobble_a #1.#2}%
+\def\XINT_gobble_d0\XINT_gobble_b0.#1{\endcsname}%
+\expandafter\let\csname XINT_g10\endcsname\endcsname
+\long\expandafter\def\csname XINT_g11\endcsname#1{\endcsname}%
+\long\expandafter\def\csname XINT_g12\endcsname#1#2{\endcsname}%
+\long\expandafter\def\csname XINT_g13\endcsname#1#2#3{\endcsname}%
+\long\expandafter\def\csname XINT_g14\endcsname#1#2#3#4{\endcsname}%
+\long\expandafter\def\csname XINT_g15\endcsname#1#2#3#4#5{\endcsname}%
+\long\expandafter\def\csname XINT_g16\endcsname#1#2#3#4#5#6{\endcsname}%
+\long\expandafter\def\csname XINT_g17\endcsname#1#2#3#4#5#6#7{\endcsname}%
+\long\expandafter\def\csname XINT_g18\endcsname#1#2#3#4#5#6#7#8{\endcsname}%
+\expandafter\let\csname XINT_g20\endcsname\endcsname
+\long\expandafter\def\csname XINT_g21\endcsname #1#2#3#4#5#6#7#8#9%
+ {\endcsname}%
+\long\expandafter\edef\csname XINT_g22\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g21\endcsname}%
+\long\expandafter\edef\csname XINT_g23\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g22\endcsname}%
+\long\expandafter\edef\csname XINT_g24\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g23\endcsname}%
+\long\expandafter\edef\csname XINT_g25\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g24\endcsname}%
+\long\expandafter\edef\csname XINT_g26\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g25\endcsname}%
+\long\expandafter\edef\csname XINT_g27\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g26\endcsname}%
+\long\expandafter\edef\csname XINT_g28\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g27\endcsname}%
+\expandafter\let\csname XINT_g30\endcsname\endcsname
+\long\expandafter\edef\csname XINT_g31\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g28\endcsname}%
+\long\expandafter\edef\csname XINT_g32\endcsname #1#2#3#4#5#6#7#8#9%
+ {\noexpand\csname XINT_g31\expandafter\noexpand\csname XINT_g28\endcsname}%
+\long\expandafter\edef\csname XINT_g33\endcsname #1#2#3#4#5#6#7#8#9%
+ {\noexpand\csname XINT_g32\expandafter\noexpand\csname XINT_g28\endcsname}%
+\long\expandafter\edef\csname XINT_g34\endcsname #1#2#3#4#5#6#7#8#9%
+ {\noexpand\csname XINT_g33\expandafter\noexpand\csname XINT_g28\endcsname}%
+\long\expandafter\edef\csname XINT_g35\endcsname #1#2#3#4#5#6#7#8#9%
+ {\noexpand\csname XINT_g34\expandafter\noexpand\csname XINT_g28\endcsname}%
+\long\expandafter\edef\csname XINT_g36\endcsname #1#2#3#4#5#6#7#8#9%
+ {\noexpand\csname XINT_g35\expandafter\noexpand\csname XINT_g28\endcsname}%
+\long\expandafter\edef\csname XINT_g37\endcsname #1#2#3#4#5#6#7#8#9%
+ {\noexpand\csname XINT_g36\expandafter\noexpand\csname XINT_g28\endcsname}%
+\long\expandafter\edef\csname XINT_g38\endcsname #1#2#3#4#5#6#7#8#9%
+ {\noexpand\csname XINT_g37\expandafter\noexpand\csname XINT_g28\endcsname}%
+\expandafter\let\csname XINT_g40\endcsname\endcsname
+\expandafter\edef\csname XINT_g41\endcsname
+ {\noexpand\csname XINT_g38\expandafter\noexpand\csname XINT_g31\endcsname}%
+\expandafter\edef\csname XINT_g42\endcsname
+ {\noexpand\csname XINT_g41\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\edef\csname XINT_g43\endcsname
+ {\noexpand\csname XINT_g42\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\edef\csname XINT_g44\endcsname
+ {\noexpand\csname XINT_g43\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\edef\csname XINT_g45\endcsname
+ {\noexpand\csname XINT_g44\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\edef\csname XINT_g46\endcsname
+ {\noexpand\csname XINT_g45\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\edef\csname XINT_g47\endcsname
+ {\noexpand\csname XINT_g46\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\edef\csname XINT_g48\endcsname
+ {\noexpand\csname XINT_g47\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\let\csname XINT_g50\endcsname\endcsname
+\expandafter\edef\csname XINT_g51\endcsname
+ {\noexpand\csname XINT_g48\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\edef\csname XINT_g52\endcsname
+ {\noexpand\csname XINT_g51\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\edef\csname XINT_g53\endcsname
+ {\noexpand\csname XINT_g52\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\edef\csname XINT_g54\endcsname
+ {\noexpand\csname XINT_g53\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\edef\csname XINT_g55\endcsname
+ {\noexpand\csname XINT_g54\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\edef\csname XINT_g56\endcsname
+ {\noexpand\csname XINT_g55\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\edef\csname XINT_g57\endcsname
+ {\noexpand\csname XINT_g56\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\edef\csname XINT_g58\endcsname
+ {\noexpand\csname XINT_g57\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\let\csname XINT_g60\endcsname\endcsname
+\expandafter\edef\csname XINT_g61\endcsname
+ {\noexpand\csname XINT_g58\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\edef\csname XINT_g62\endcsname
+ {\noexpand\csname XINT_g61\expandafter\noexpand\csname XINT_g61\endcsname}%
+\expandafter\edef\csname XINT_g63\endcsname
+ {\noexpand\csname XINT_g62\expandafter\noexpand\csname XINT_g61\endcsname}%
+\expandafter\edef\csname XINT_g64\endcsname
+ {\noexpand\csname XINT_g63\expandafter\noexpand\csname XINT_g61\endcsname}%
+\expandafter\edef\csname XINT_g65\endcsname
+ {\noexpand\csname XINT_g64\expandafter\noexpand\csname XINT_g61\endcsname}%
+\expandafter\edef\csname XINT_g66\endcsname
+ {\noexpand\csname XINT_g65\expandafter\noexpand\csname XINT_g61\endcsname}%
+\expandafter\edef\csname XINT_g67\endcsname
+ {\noexpand\csname XINT_g66\expandafter\noexpand\csname XINT_g61\endcsname}%
+\expandafter\edef\csname XINT_g68\endcsname
+ {\noexpand\csname XINT_g67\expandafter\noexpand\csname XINT_g61\endcsname}%
+% \end{macrocode}
% \subsection{\csh{xintMessage}, \csh{ifxintverbose}}
% \lverb|1.2c added it for use by \xintdefvar and \xintdeffunc of xintexpr.
% 1.2e uses \write128 rather than \write16 for compatibility with future
@@ -15272,7 +15876,7 @@
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xinttools}%
- [2016/11/20 1.2h Expandable and non-expandable utilities (JFB)]%
+ [2016/12/13 1.2i Expandable and non-expandable utilities (JFB)]%
% \end{macrocode}
% \lverb|\XINT_toks is used in macros such as \xintFor. It is not used
% elsewhere in the xint bundle.|
@@ -15561,8 +16165,6 @@
% When i is out of range, an empty value is returned.
%
%
-% 1.2g does some changes possibly improving a bit the speed of token
-% shuffling here (particularly when the first argument is negative).
%
% ?
% \begin{macrocode}
@@ -15574,8 +16176,8 @@
\def\XINT_nthelt_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_nthelt_zero }%
- 0#1{\XINT_nthelt_neg }%
+ #1-\XINT_nthelt_zero
+ 0#1\XINT_nthelt_neg
0-{\XINT_nthelt_pos #1}%
\krof
}%
@@ -15582,81 +16184,76 @@
\def\XINT_nthelt_zero .{\xintlength }%
\long\def\XINT_nthelt_neg #1.#2%
{%
- \expandafter\XINT_nthelt_neg_a\the\numexpr
- \XINT_length_loop
- 0.#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye +\xint_c_i -#1.%
- #2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ \expandafter\XINT_nthelt_neg_a\the\numexpr\xint_c_x\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ -#1.#2\xint_bye
}%
\def\XINT_nthelt_neg_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_nthelt_none }%
- 0#1{\XINT_nthelt_none }%
- 0-{\XINT_nthelt_loop_a #1}%
+ #1-\xint_byeandstop
+ 0#1\xint_byeandstop
+ 0-{}%
\krof
+ \expandafter\XINT_nthelt_neg_b
+ \romannumeral\expandafter\XINT_gobble\the\numexpr-\xint_c_i+#1%
}%
-\long\def\XINT_nthelt_none #1\xint_bye{ }%
+\long\def\XINT_nthelt_neg_b #1#2\xint_bye{ #1}%
\long\def\XINT_nthelt_pos #1.#2%
{%
- \XINT_nthelt_loop_a #1.%
+ \expandafter\XINT_nthelt_loop\the\numexpr\xint_c_ix-#1.%
#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
}%
-\def\XINT_nthelt_loop_a #1.%
+\def\XINT_nthelt_loop #1%
{%
- \ifnum #1>\xint_c_viii
- \expandafter\XINT_nthelt_loop_b
- \else
- \expandafter\XINT_nthelt_getit
- \fi #1.%
+ \xint_UDsignfork
+ #1\XINT_nthelt_loop_a
+ -{\XINT_nthelt_getit #1}%
+ \krof
}%
-\long\def\XINT_nthelt_loop_b #1.#2#3#4#5#6#7#8#9%
+\long\def\XINT_nthelt_loop_a #1.#2#3#4#5#6#7#8#9%
{%
- \xint_gob_til_xint_relax #9\XINT_nthelt_none\xint_relax
- \expandafter\XINT_nthelt_loop_a\the\numexpr #1-\xint_c_viii.%
+ \xint_gob_til_xint_relax #9\xint_byeandstop\xint_relax
+ \expandafter\XINT_nthelt_loop\the\numexpr\xint_c_viii-#1.%
}%
\def\XINT_nthelt_getit #1.%
{%
\expandafter\expandafter\expandafter\XINT_nthelt_finish
- \csname xint_gobble_\romannumeral\numexpr#1-\xint_c_i\endcsname
+ \csname xint_gobble_\romannumeral\numexpr\xint_c_viii-#1\endcsname
}%
\long\edef\XINT_nthelt_finish #1#2\xint_bye
{\noexpand\xint_gob_til_xint_relax #1\noexpand\expandafter\space
- \noexpand\xint_gobble_ii\xint_relax\space #1}%
+ \noexpand\xint_gobble_ii\xint_relax\space #1}%
% \end{macrocode}
% \subsection{\csh{xintKeep}}
-% \lverb?&
+% \lverb@&
%
% First included in release 1.09m.
%
-% \xintKeep {i}{stuff f-expanding to {a}{b}...{z}} (or `tokens' abcd...z, but
-% each naked token ends up braced in the output, if 0<i<length of token list)
-% returns (in two expansion steps) the first i items from the list, which
-% is first f-expanded. The i is expanded inside \numexpr. The variant
-% \xintKeepNoExpand does not expand the list argument.
+% \xintKeep{i}{L} f-expands its second argument L. It then grabs the first i
+% items from L and discards the rest.
%
-% With 0<i<length, each item ends up *braced* in the output.
+% ATTENTION: **each such kept item is returned inside a brace pair**
+% Use \xintKeepUnbraced to avoid that.
%
-% With i = 0, the empty sequence is returned.
+% For i equal or larger to the number N of items in (expanded) L, the full L
+% is returned (with braced items). For i=0, the macro returns an empty output.
+% For i<0, the macro discards the first N-|i| items. No brace pairs added to
+% the remaining items. For i is less or equal to -N, the full L is returned
+% (with no braces added.)
%
-% With |i| equal to or bigger than the length of the (f-expanded) list,
-% the full list is returned, with no braces added to items.
+% \xintKeepNoExpand does not expand the L argument.
%
-% With -length<i<0, the last |i| items are returned (in the same order as in
-% the original list) AND BRACES ARE NOT ADDED IF NOT ORIGINALLY PRESENT.
%
-% 1.2a belatedly corrects the description of what this macro does for i<0 !
%
-% I have this nagging feeling I should read this code which might be much
-% improvable upon, but I just don't have time now (2015/10/19).
-%
-% Some cosmetic code improvements for 1.2g, to minimize token handling. And
-% the ending (_finish) which was temporary has finally been redone, fleeting
-% thoughts of alternative keep escaping me and I was a bit reluctant to the
-% method followed in the end, but still probably better than the older one.
-% ?
+% Prior to 1.2i the code proceeded along a loop with no pre-computation of
+% the length of L, for the i>0 case. The faster 1.2i version takes advantage
+% of novel \xintLengthUpTo from xintkernel.sty.
+% @
% \begin{macrocode}
\def\xintKeep {\romannumeral0\xintkeep }%
\def\xintKeepNoExpand {\romannumeral0\xintkeepnoexpand }%
@@ -15666,8 +16263,8 @@
\def\XINT_keep_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_keep_keepnone }%
- 0#1{\XINT_keep_neg }%
+ #1-\XINT_keep_keepnone
+ 0#1\XINT_keep_neg
0-{\XINT_keep_pos #1}%
\krof
}%
@@ -15675,92 +16272,65 @@
\long\def\XINT_keep_neg #1.#2%
{%
\expandafter\XINT_keep_neg_a\the\numexpr
- \XINT_length_loop
- 0.#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye -#1.%
- #2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ #1-\numexpr\xint_c_ix\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye.#2%
}%
\def\XINT_keep_neg_a #1%
{%
- \xint_UDzerominusfork
- #1-{\XINT_keep_keepall }%
- 0#1{\XINT_keep_keepall }%
- 0-{\XINT_trim_loop_a #1}%
+ \xint_UDsignfork
+ #1{\expandafter\space\romannumeral\XINT_gobble}%
+ -\XINT_keep_keepall
\krof
}%
-\def\XINT_keep_keepall #1.{\XINT_keep_keepall_a \space}%
-\def\XINT_keep_keepall_a #1\xint_relax #2\xint_bye {#1}%
+\def\XINT_keep_keepall #1.{ }%
\long\def\XINT_keep_pos #1.#2%
{%
- \XINT_keep_loop_a #1.%
- {}#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_bye
+ \expandafter\XINT_keep_loop
+ \the\numexpr#1-\XINT_lengthupto_loop
+ #1.#2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ -\xint_c_viii.{}#2\xint_bye%
}%
-\def\XINT_keep_loop_a #1.%
+\def\XINT_keep_loop #1#2.%
{%
- \ifnum #1>\xint_c_vi
- \expandafter\XINT_keep_loop_b
- \else
- \expandafter\XINT_keep_finish
- \fi
- #1.%
+ \xint_gob_til_minus#1\XINT_keep_loop_end-%
+ \expandafter\XINT_keep_loop
+ \the\numexpr#1#2-\xint_c_viii\expandafter.\XINT_keep_loop_pickeight
}%
-\long\def\XINT_keep_loop_b #1.#2#3#4#5#6#7#8#9%
-{%
- \xint_gob_til_xint_relax #9\XINT_keep_enda\xint_relax
- \expandafter\XINT_keep_loop_c\the\numexpr #1-\xint_c_vii.%
- {{#3}{#4}{#5}{#6}{#7}{#8}{#9}}{#2}%
-}%
-\long\def\XINT_keep_loop_c #1.#2#3{\XINT_keep_loop_a #1.{#3#2}}%
-\long\def\XINT_keep_enda #1.#2#3#4\xint_bye
-{%
- \XINT_keep_endb #4\W\W\W\W\W\W\Z #2{#3}%
-}%
-\def\XINT_keep_endb #1#2#3#4#5#6#7\Z
-{%
- \xint_gob_til_W
- #1\XINT_keep_endc_
- #2\XINT_keep_endc_i
- #3\XINT_keep_endc_ii
- #4\XINT_keep_endc_iii
- #5\XINT_keep_endc_iv
- #6\XINT_keep_endc_v
- \W\XINT_keep_endc_vi\Z
-}%
-\long\def\XINT_keep_endc_ #1\Z #2#3#4#5#6#7#8#9{ #9}%
-\long\def\XINT_keep_endc_i #1\Z #2#3#4#5#6#7#8#9{#9{#2}}%
-\long\def\XINT_keep_endc_ii #1\Z #2#3#4#5#6#7#8#9{#9{#2}{#3}}%
-\long\def\XINT_keep_endc_iii #1\Z #2#3#4#5#6#7#8#9{#9{#2}{#3}{#4}}%
-\long\def\XINT_keep_endc_iv #1\Z #2#3#4#5#6#7#8#9{#9{#2}{#3}{#4}{#5}}%
-\long\def\XINT_keep_endc_v #1\Z #2#3#4#5#6#7#8#9{#9{#2}{#3}{#4}{#5}{#6}}%
-\long\def\XINT_keep_endc_vi\Z #1#2#3#4#5#6#7#8{#8{#1}{#2}{#3}{#4}{#5}{#6}}%
-\long\def\XINT_keep_finish #1.#2#3#4#5#6#7#8#9\xint_bye
-{%
- \XINT_keep_finish_a #1.%
- #3\xint_c_ #4\xint_c_i #5\xint_c_ii #6\xint_c_iii #7\xint_c_iv
- #8\xint_c_v\xint_relax\xint_c_vi\xint_bye
- {#3}{#4}{#5}{#6}{#7}{#8}\xint_bye {#2}%
-}%
-\long\def\XINT_keep_finish_a #1.#2\xint_relax #3#4\xint_bye
-{%
- \csname XINT_keep_finish_b\romannumeral\ifnum#1>#3#3\else#1\fi\endcsname
-}%
-\long\def\XINT_keep_finish_b #1\xint_bye #2{ #2}%
-\long\def\XINT_keep_finish_bi #1#2\xint_bye #3{#3{#1}}%
-\long\def\XINT_keep_finish_bii #1#2#3\xint_bye #4{#4{#1}{#2}}%
-\long\def\XINT_keep_finish_biii#1#2#3#4\xint_bye #5{#5{#1}{#2}{#3}}%
-\long\def\XINT_keep_finish_biv #1#2#3#4#5\xint_bye #6{#6{#1}{#2}{#3}{#4}}%
-\long\def\XINT_keep_finish_bv #1#2#3#4#5#6\xint_bye #7{#7{#1}{#2}{#3}{#4}{#5}}%
-\long\def\XINT_keep_finish_bvi #1\xint_bye #2{#2#1}%
+\long\def\XINT_keep_loop_pickeight
+ #1#2#3#4#5#6#7#8#9{{#1{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}}}%
+\def\XINT_keep_loop_end-\expandafter\XINT_keep_loop
+ \the\numexpr-#1-\xint_c_viii\expandafter.\XINT_keep_loop_pickeight
+ {\csname XINT_keep_end#1\endcsname}%
+\long\expandafter\def\csname XINT_keep_end1\endcsname
+ #1#2#3#4#5#6#7#8#9\xint_bye { #1{#2}{#3}{#4}{#5}{#6}{#7}{#8}}%
+\long\expandafter\def\csname XINT_keep_end2\endcsname
+ #1#2#3#4#5#6#7#8\xint_bye { #1{#2}{#3}{#4}{#5}{#6}{#7}}%
+\long\expandafter\def\csname XINT_keep_end3\endcsname
+ #1#2#3#4#5#6#7\xint_bye { #1{#2}{#3}{#4}{#5}{#6}}%
+\long\expandafter\def\csname XINT_keep_end4\endcsname
+ #1#2#3#4#5#6\xint_bye { #1{#2}{#3}{#4}{#5}}%
+\long\expandafter\def\csname XINT_keep_end5\endcsname
+ #1#2#3#4#5\xint_bye { #1{#2}{#3}{#4}}%
+\long\expandafter\def\csname XINT_keep_end6\endcsname
+ #1#2#3#4\xint_bye { #1{#2}{#3}}%
+\long\expandafter\def\csname XINT_keep_end7\endcsname
+ #1#2#3\xint_bye { #1{#2}}%
+\long\expandafter\def\csname XINT_keep_end8\endcsname
+ #1#2\xint_bye { #1}%
% \end{macrocode}
% \subsection{\csh{xintKeepUnbraced}}
% \lverb?1.2a. Same as \xintKeep but will *not* add (or maintain) brace pairs
-% around the kept items upfront.
+% around the kept items when length(L)>i>0.
%
-% There was actually a bug as \xintkeepunbracednoexpand was never defined,
-% rather it is \xintkeepnoexpand which got re-defined... belatedly corrected
-% for 1.2g?
+% The name may cause a mis-understanding: for i<0, (i.e. keeping only
+% trailing items), there is no brace removal at all happening.
+%
+% Modified for 1.2i like \xintKeep.
+% ?
% \begin{macrocode}
\def\xintKeepUnbraced {\romannumeral0\xintkeepunbraced }%
\def\xintKeepUnbracedNoExpand {\romannumeral0\xintkeepunbracednoexpand }%
@@ -15772,74 +16342,46 @@
\def\XINT_keepunbr_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_keep_keepnone }%
- 0#1{\XINT_keep_neg }%
+ #1-\XINT_keep_keepnone
+ 0#1\XINT_keep_neg
0-{\XINT_keepunbr_pos #1}%
\krof
}%
\long\def\XINT_keepunbr_pos #1.#2%
{%
- \XINT_keepunbr_loop_a #1.%
- {}#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_bye
+ \expandafter\XINT_keepunbr_loop
+ \the\numexpr#1-\XINT_lengthupto_loop
+ #1.#2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ -\xint_c_viii.{}#2\xint_bye%
}%
-\def\XINT_keepunbr_loop_a #1.%
+\def\XINT_keepunbr_loop #1#2.%
{%
- \ifnum #1>\xint_c_vi
- \expandafter\XINT_keepunbr_loop_b
- \else
- \expandafter\XINT_keepunbr_finish
- \fi
- #1.%
+ \xint_gob_til_minus#1\XINT_keepunbr_loop_end-%
+ \expandafter\XINT_keepunbr_loop
+ \the\numexpr#1#2-\xint_c_viii\expandafter.\XINT_keepunbr_loop_pickeight
}%
-\long\def\XINT_keepunbr_loop_b #1.#2#3#4#5#6#7#8#9%
-{%
- \xint_gob_til_xint_relax #9\XINT_keepunbr_enda\xint_relax
- \expandafter\XINT_keepunbr_loop_c\the\numexpr #1-\xint_c_vii.%
- {#3}{#4}{#5}{#6}{#7}{#8}{#9}.{#2}%
-}%
-\long\def\XINT_keepunbr_loop_c #1.#2#3#4#5#6#7#8.#9%
- {\XINT_keepunbr_loop_a #1.{#9#2#3#4#5#6#7#8}}%
-\long\def\XINT_keepunbr_enda #1.#2.#3#4\xint_bye
-{%
- \XINT_keepunbr_endb #4\W\W\W\W\W\W\Z #2{#3}%
-}%
-\def\XINT_keepunbr_endb #1#2#3#4#5#6#7\Z
-{%
- \xint_gob_til_W
- #1\XINT_keepunbr_endc_
- #2\XINT_keepunbr_endc_i
- #3\XINT_keepunbr_endc_ii
- #4\XINT_keepunbr_endc_iii
- #5\XINT_keepunbr_endc_iv
- #6\XINT_keepunbr_endc_v
- \W\XINT_keepunbr_endc_vi\Z
-}%
-\long\def\XINT_keepunbr_endc_ #1\Z #2#3#4#5#6#7#8#9{ #9}%
-\long\def\XINT_keepunbr_endc_i #1\Z #2#3#4#5#6#7#8#9{ #9#2}%
-\long\def\XINT_keepunbr_endc_ii #1\Z #2#3#4#5#6#7#8#9{ #9#2#3}%
-\long\def\XINT_keepunbr_endc_iii #1\Z #2#3#4#5#6#7#8#9{ #9#2#3#4}%
-\long\def\XINT_keepunbr_endc_iv #1\Z #2#3#4#5#6#7#8#9{ #9#2#3#4#5}%
-\long\def\XINT_keepunbr_endc_v #1\Z #2#3#4#5#6#7#8#9{ #9#2#3#4#5#6}%
-\long\def\XINT_keepunbr_endc_vi\Z #1#2#3#4#5#6#7#8{ #8#1#2#3#4#5#6}%
-\long\def\XINT_keepunbr_finish #1.#2#3#4#5#6#7#8#9\xint_bye
-{%
- \XINT_keepunbr_finish_a #1.%
- #3\xint_c_ #4\xint_c_i #5\xint_c_ii #6\xint_c_iii #7\xint_c_iv
- #8\xint_c_v\xint_relax\xint_c_vi\xint_bye
- {#3}{#4}{#5}{#6}{#7}{#8}\xint_bye {#2}%
-}%
-\long\def\XINT_keepunbr_finish_a #1.#2\xint_relax #3#4\xint_bye
-{%
- \csname XINT_keepunbr_finish_b\romannumeral\ifnum#1>#3#3\else#1\fi\endcsname
-}%
-\long\def\XINT_keepunbr_finish_b #1\xint_bye #2{ #2}%
-\long\def\XINT_keepunbr_finish_bi #1#2\xint_bye #3{ #3#1}%
-\long\def\XINT_keepunbr_finish_bii #1#2#3\xint_bye #4{ #4#1#2}%
-\long\def\XINT_keepunbr_finish_biii#1#2#3#4\xint_bye #5{ #5#1#2#3}%
-\long\def\XINT_keepunbr_finish_biv #1#2#3#4#5\xint_bye #6{ #6#1#2#3#4}%
-\long\def\XINT_keepunbr_finish_bv #1#2#3#4#5#6\xint_bye #7{ #7#1#2#3#4#5}%
-\long\def\XINT_keepunbr_finish_bvi #1#2#3#4#5#6\xint_bye #7{ #7#1#2#3#4#5#6}%
+\long\def\XINT_keepunbr_loop_pickeight
+ #1#2#3#4#5#6#7#8#9{{#1#2#3#4#5#6#7#8#9}}%
+\def\XINT_keepunbr_loop_end-\expandafter\XINT_keepunbr_loop
+ \the\numexpr-#1-\xint_c_viii\expandafter.\XINT_keepunbr_loop_pickeight
+ {\csname XINT_keepunbr_end#1\endcsname}%
+\long\expandafter\def\csname XINT_keepunbr_end1\endcsname
+ #1#2#3#4#5#6#7#8#9\xint_bye { #1#2#3#4#5#6#7#8}%
+\long\expandafter\def\csname XINT_keepunbr_end2\endcsname
+ #1#2#3#4#5#6#7#8\xint_bye { #1#2#3#4#5#6#7}%
+\long\expandafter\def\csname XINT_keepunbr_end3\endcsname
+ #1#2#3#4#5#6#7\xint_bye { #1#2#3#4#5#6}%
+\long\expandafter\def\csname XINT_keepunbr_end4\endcsname
+ #1#2#3#4#5#6\xint_bye { #1#2#3#4#5}%
+\long\expandafter\def\csname XINT_keepunbr_end5\endcsname
+ #1#2#3#4#5\xint_bye { #1#2#3#4}%
+\long\expandafter\def\csname XINT_keepunbr_end6\endcsname
+ #1#2#3#4\xint_bye { #1#2#3}%
+\long\expandafter\def\csname XINT_keepunbr_end7\endcsname
+ #1#2#3\xint_bye { #1#2}%
+\long\expandafter\def\csname XINT_keepunbr_end8\endcsname
+ #1#2\xint_bye { #1}%
% \end{macrocode}
% \subsection{\csh{xintTrim}}
% \lverb?&
@@ -15846,24 +16388,17 @@
%
% First included in release 1.09m.
%
-% \xintTrim {i}{stuff f-expanding to {a}{b}...{z}} (or `tokens' abcd...z)
-% returns (in two expansion steps) the sequence with the first i elements
-% omitted. The list is first f-expanded. The i is expanded inside \numexpr.
-% Variant \xintTrimNoExpand does not expand the list argument.
+% \xintTrim{i}{L} f-expands its second argument L. It then removes the first i
+% items from L and keeps the rest. For i equal or larger to the number N of
+% items in (expanded) L, the macro returns an empty output. For i=0, the
+% original (expanded) L is returned. For i<0, the macro proceeds from the
+% tail. It thus removes the last |i| items, i.e. it keeps the first N-|i|
+% items. For |i|>= N, the empty list is returned.
%
-% With i = 0, the original (expanded) list is returned.
+% \xintTrimNoExpand does not expand the L argument.
%
-% With i<0, the last |i| items are suppressed. In that case the kept elements
-% (coming form the head) will be braced on output.
-%
-% With i>0, the fist |i| items are suppressed: the remaining ones are left as
-% is with no added brace pairs.
-%
-% With |i| equal to or bigger than the length of the (f-expanded) list,
-% the empty list is returned.
-%
-% Cosmetic code improvements (which naturally did cost me time, nothing is
-% easy with TeX) for 1.2g to speed up some aspects of token processing.
+% Speed improvements for 1.2i mainly for i<0 branch (which hands over to
+% \xintKeep).
% ?
% \begin{macrocode}
\def\xintTrim {\romannumeral0\xinttrim }%
@@ -15874,8 +16409,8 @@
\def\XINT_trim_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_trim_trimnone }%
- 0#1{\XINT_trim_neg }%
+ #1-\XINT_trim_trimnone
+ 0#1\XINT_trim_neg
0-{\XINT_trim_pos #1}%
\krof
}%
@@ -15883,57 +16418,52 @@
\long\def\XINT_trim_neg #1.#2%
{%
\expandafter\XINT_trim_neg_a\the\numexpr
- \XINT_length_loop
- 0.#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye -#1.%
- {}#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_bye
+ #1-\numexpr\xint_c_ix\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ .{}#2\xint_bye
}%
\def\XINT_trim_neg_a #1%
{%
- \xint_UDzerominusfork
- #1-{\XINT_trim_trimall }%
- 0#1{\XINT_trim_trimall }%
- 0-{\XINT_keep_loop_a #1}%
+ \xint_UDsignfork
+ #1{\expandafter\XINT_keep_loop\the\numexpr-\xint_c_viii+}%
+ -\XINT_trim_trimall
\krof
}%
-\long\def\XINT_trim_trimall #1\xint_bye { }%
+\edef\XINT_trim_trimall {\noexpand\expandafter\space\noexpand\xint_bye}%
+% \end{macrocode}
+% \lverb|This branch doesn't pre-evaluate the length of the list argument.|
+% \begin{macrocode}
\long\def\XINT_trim_pos #1.#2%
{%
- \XINT_trim_loop_a #1.%
+ \expandafter\XINT_trim_loop\the\numexpr#1-\xint_c_viii.%
#2\xint_relax\xint_relax\xint_relax\xint_relax
\xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
}%
-\def\XINT_trim_loop_a #1.%
+\def\XINT_trim_loop #1%
{%
- \ifnum #1>\xint_c_vii
- \expandafter\XINT_trim_loop_b
- \else
- \expandafter\XINT_trim_finish
- \fi
- #1.%
+ \xint_UDsignfork
+ #1\XINT_trim_finish
+ -\XINT_trim_loop_a
+ \krof #1%
}%
-\long\def\XINT_trim_loop_b #1.#2#3#4#5#6#7#8#9%
+\long\def\XINT_trim_loop_a #1.#2#3#4#5#6#7#8#9%
{%
- \xint_gob_til_xint_relax #9\XINT_trim_silentend\xint_relax
- \expandafter\XINT_trim_loop_a\the\numexpr #1-\xint_c_viii.%
+ \xint_gob_til_xint_relax #9\xint_bye_thenstop\xint_relax
+ \expandafter\XINT_trim_loop\the\numexpr#1-\xint_c_viii.%
}%
-\def\XINT_trim_silentend #1\xint_bye { }%
-\def\XINT_trim_finish #1.%
+\def\XINT_trim_finish -#1.%
{%
\expandafter\expandafter\expandafter\XINT_trim_finish_a
- \expandafter\expandafter\expandafter\space % avoids brace removal
- \csname xint_gobble_\romannumeral#1\endcsname
+ \expandafter\expandafter\expandafter\space
+ \csname xint_gobble_\romannumeral\numexpr\xint_c_viii-#1\endcsname
}%
\long\def\XINT_trim_finish_a #1\xint_relax #2\xint_bye {#1}%
% \end{macrocode}
% \subsection{\csh{xintTrimUnbraced}}
-% \lverb?1.2a
-%
-% Missing long for \xinttrimunbraced added belatedly with 1.2g, which also
-% modifies a bit the coding style, to match new versions of \xintKeep and
-% \xintTrim.
-% ?
+% \lverb?1.2a. Modified in 1.2i like \xintTrim?
% \begin{macrocode}
\def\xintTrimUnbraced {\romannumeral0\xinttrimunbraced }%
\def\xintTrimUnbracedNoExpand {\romannumeral0\xinttrimunbracednoexpand }%
@@ -15945,8 +16475,8 @@
\def\XINT_trimunbr_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_trim_trimnone }%
- 0#1{\XINT_trimunbr_neg }%
+ #1-\XINT_trim_trimnone
+ 0#1\XINT_trimunbr_neg
0-{\XINT_trim_pos #1}%
\krof
}%
@@ -15953,18 +16483,18 @@
\long\def\XINT_trimunbr_neg #1.#2%
{%
\expandafter\XINT_trimunbr_neg_a\the\numexpr
- \XINT_length_loop
- 0.#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye -#1.%
- {}#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_bye
+ #1-\numexpr\xint_c_ix\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ .{}#2\xint_bye
}%
\def\XINT_trimunbr_neg_a #1%
{%
- \xint_UDzerominusfork
- #1-{\XINT_trim_trimall }%
- 0#1{\XINT_trim_trimall }%
- 0-{\XINT_keepunbr_loop_a #1}%
+ \xint_UDsignfork
+ #1{\expandafter\XINT_keepunbr_loop\the\numexpr-\xint_c_viii+}%
+ -\XINT_trim_trimall
\krof
}%
% \end{macrocode}
@@ -16281,7 +16811,9 @@
% there.
%
% 1.09f rewrites (2013/11/03) the code which now allows all macro parameters
-% from #1 to #9 in \xintFor, \xintFor*, and \XINT_forever.|
+% from #1 to #9 in \xintFor, \xintFor*, and \XINT_forever.
+% 1.2i: slightly more robust \xintifForFirst/Last in case of nesting.
+% |
% \begin{macrocode}
\def\XINT_tmpa #1#2{\ifnum #2<#1 \xint_afterfi {{#########2}}\fi}%
\def\XINT_tmpb #1#2{\ifnum #1<#2 \xint_afterfi {{#########2}}\fi}%
@@ -16296,6 +16828,7 @@
\long\def\xintBreakFor #1Z{}%
\long\def\xintBreakForAndDo #1#2Z{#1}%
\def\xintFor {\let\xintifForFirst\xint_firstoftwo
+ \let\xintifForLast\xint_secondoftwo
\futurelet\XINT_token\XINT_for_ifstar }%
\def\XINT_for_ifstar {\ifx\XINT_token*\expandafter\XINT_forx
\else\expandafter\XINT_for \fi }%
@@ -16356,7 +16889,8 @@
\XINT_toks {{#3}}%
\long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
\the\XINT_toks \csname XINT_for_right#1\endcsname }%
- \XINT_toks {\XINT_x\let\xintifForFirst\xint_secondoftwo\XINT_for_d #1{#2}}%
+ \XINT_toks {\XINT_x\let\xintifForFirst\xint_secondoftwo
+ \let\xintifForLast\xint_secondoftwo\XINT_for_d #1{#2}}%
\futurelet\XINT_token\XINT_for_last?
}%
\long\def\XINT_forx_d #1#2#3%
@@ -16365,16 +16899,20 @@
\XINT_toks {{#3}}%
\long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
\the\XINT_toks \csname XINT_for_right#1\endcsname }%
- \XINT_toks {\XINT_x\let\xintifForFirst\xint_secondoftwo\XINT_forx_d #1{#2}}%
+ \XINT_toks {\XINT_x\let\xintifForFirst\xint_secondoftwo
+ \let\xintifForLast\xint_secondoftwo\XINT_forx_d #1{#2}}%
\XINT_xflet\XINT_for_last?
}%
\def\XINT_for_last?
{%
- \let\xintifForLast\xint_secondoftwo
- \ifx\XINT_token Z\let\xintifForLast\xint_firstoftwo
- \xint_afterfi{\xintBreakForAndDo{\XINT_x\xint_gobble_i Z}}\fi
- \the\XINT_toks
+ \ifx\XINT_token Z\expandafter\XINT_for_last?yes\fi
+ \the\XINT_toks
}%
+\def\XINT_for_last?yes
+{%
+ \let\xintifForLast\xint_firstoftwo
+ \xintBreakForAndDo{\XINT_x\xint_gobble_i Z}%
+}%
% \end{macrocode}
% \subsection{\csh{XINT_forever}, \csh{xintintegers}, \csh{xintdimensions}, \csh{xintrationals}}
% \lverb|New with 1.09e. But this used inadvertently \xintiadd/\xintimul which
@@ -16473,6 +17011,7 @@
\the\XINT_toks \csname XINT_for_right#1\endcsname }%
\XINT_x
\let\xintifForFirst\xint_secondoftwo
+ \let\xintifForLast\xint_secondoftwo
\expandafter\XINT_forever_d\expandafter #1\romannumeral`&&@#4{#2}{#3}#4{#5}%
}%
% \end{macrocode}
@@ -16484,12 +17023,16 @@
% anymore.
%
% [2013/11/03] 1.09f: \xintForpair extended to accept #1#2, #2#3 etc... up to
-% #8#9, \xintForthree, #1#2#3 up to #7#8#9, \xintForfour id. |
+% #8#9, \xintForthree, #1#2#3 up to #7#8#9, \xintForfour id.
+%
+% 1.2i: slightly more robust \xintifForFirst/Last in case of nesting.
+% |
% \begin{macrocode}
\catcode`j 3
\long\def\xintForpair #1#2#3in#4#5#6%
{%
\let\xintifForFirst\xint_firstoftwo
+ \let\xintifForLast\xint_secondoftwo
\XINT_toks {\XINT_forpair_d #2{#6}}%
\expandafter\the\expandafter\XINT_toks #4jZ%
}%
@@ -16499,18 +17042,16 @@
\XINT_toks \expandafter{\romannumeral0\xintcsvtolist{ #4}}%
\long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
\the\XINT_toks \csname XINT_for_right\the\numexpr#1+\xint_c_i\endcsname}%
+ \ifx #5j\expandafter\XINT_for_last?yes\fi
+ \XINT_x
+ \let\xintifForFirst\xint_secondoftwo
\let\xintifForLast\xint_secondoftwo
- \ifx #5j\expandafter\xint_firstoftwo
- \else\expandafter\xint_secondoftwo
- \fi
- {\let\xintifForLast\xint_firstoftwo
- \xintBreakForAndDo {\XINT_x \xint_gobble_i Z}}%
- \XINT_x
- \let\xintifForFirst\xint_secondoftwo\XINT_forpair_d #1{#2}%
+ \XINT_forpair_d #1{#2}%
}%
\long\def\xintForthree #1#2#3in#4#5#6%
{%
\let\xintifForFirst\xint_firstoftwo
+ \let\xintifForLast\xint_secondoftwo
\XINT_toks {\XINT_forthree_d #2{#6}}%
\expandafter\the\expandafter\XINT_toks #4jZ%
}%
@@ -16520,18 +17061,16 @@
\XINT_toks \expandafter{\romannumeral0\xintcsvtolist{ #4}}%
\long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
\the\XINT_toks \csname XINT_for_right\the\numexpr#1+\xint_c_ii\endcsname}%
+ \ifx #5j\expandafter\XINT_for_last?yes\fi
+ \XINT_x
+ \let\xintifForFirst\xint_secondoftwo
\let\xintifForLast\xint_secondoftwo
- \ifx #5j\expandafter\xint_firstoftwo
- \else\expandafter\xint_secondoftwo
- \fi
- {\let\xintifForLast\xint_firstoftwo
- \xintBreakForAndDo {\XINT_x \xint_gobble_i Z}}%
- \XINT_x
- \let\xintifForFirst\xint_secondoftwo\XINT_forthree_d #1{#2}%
+ \XINT_forthree_d #1{#2}%
}%
\long\def\xintForfour #1#2#3in#4#5#6%
{%
\let\xintifForFirst\xint_firstoftwo
+ \let\xintifForLast\xint_secondoftwo
\XINT_toks {\XINT_forfour_d #2{#6}}%
\expandafter\the\expandafter\XINT_toks #4jZ%
}%
@@ -16541,14 +17080,11 @@
\XINT_toks \expandafter{\romannumeral0\xintcsvtolist{ #4}}%
\long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
\the\XINT_toks \csname XINT_for_right\the\numexpr#1+\xint_c_iii\endcsname}%
+ \ifx #5j\expandafter\XINT_for_last?yes\fi
+ \XINT_x
+ \let\xintifForFirst\xint_secondoftwo
\let\xintifForLast\xint_secondoftwo
- \ifx #5j\expandafter\xint_firstoftwo
- \else\expandafter\xint_secondoftwo
- \fi
- {\let\xintifForLast\xint_firstoftwo
- \xintBreakForAndDo {\XINT_x \xint_gobble_i Z}}%
- \XINT_x
- \let\xintifForFirst\xint_secondoftwo\XINT_forfour_d #1{#2}%
+ \XINT_forfour_d #1{#2}%
}%
\catcode`Z 11
\catcode`j 11
@@ -16760,10 +17296,9 @@
}%
\def\XINT_trim:f:csv_loop_b #1.#2,#3,#4,#5,#6,#7,#8,#9,%
{%
- \xint_gob_til_xint_relax #9\XINT_trim:f:csv_silentend\xint_relax
+ \xint_gob_til_xint_relax #9\xint_bye_thenstop\xint_relax
\expandafter\XINT_trim:f:csv_loop_a\the\numexpr #1-\xint_c_viii.%
}%
-\def\XINT_trim:f:csv_silentend #1\xint_bye { }%
\def\XINT_trim:f:csv_finish #1.%
{%
\expandafter\XINT_trim:f:csv_finish_a
@@ -16793,12 +17328,11 @@
\def\XINT_keep:f:csv_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_keep:f:csv_zero }%
- 0#1{\XINT_keep:f:csv_neg }%
+ #1-\xint_bye_thenstop
+ 0#1\XINT_keep:f:csv_neg
0-{\XINT_keep:f:csv_pos #1}%
\krof
}%
-\def\XINT_keep:f:csv_zero .#1\xint_bye{ }%
\def\XINT_keep:f:csv_neg #1.#2\xint_relax%
{%
\expandafter\XINT_keep:f:csv_neg_b
@@ -16885,12 +17419,11 @@
\def\XINT_nthelt:f:csv_neg_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_nthelt:f:csv_none }%
- 0#1{\XINT_nthelt:f:csv_none }%
+ #1-\xint_bye_thenstop
+ 0#1\xint_bye_thenstop
0-{\XINT_nthelt:f:csv_loop_a #1}%
\krof
}%
-\def\XINT_nthelt:f:csv_none #1\xint_bye { }%
\long\def\XINT_nthelt:f:csv_pos #1.#2%
{%
\expandafter\XINT_nthelt:f:csv_loop_a\the\numexpr #1+\xint_c_i\expandafter.%
@@ -17092,7 +17625,7 @@
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintcore}%
- [2016/11/20 1.2h Expandable arithmetic on big integers (JFB)]%
+ [2016/12/13 1.2i Expandable arithmetic on big integers (JFB)]%
% \end{macrocode}
% \subsection{Counts for holding needed constants}
% \begin{macrocode}
@@ -17293,7 +17826,7 @@
{\noexpand\expandafter\space\noexpand\the\numexpr #1-#3.}%
% \end{macrocode}
% \lverb|Used as \romannumeral0\XINT_unrevbyviii 1<8d>!....1<8d>! terminated
-% by$newline 1\Z!1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W.
+% by$newline 1\Z!1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W
%
% The \romannumeral in unrevbyviii_a is for special effects (expand some token
% which was put as 1<token>! at the end of the original blocks). Used by
@@ -17318,7 +17851,6 @@
\expandafter\XINT_cuz_small\xint_gob_til_Z #8#7#6#5#4#3#2#1%
}%
% \end{macrocode}
-% \subsection{Blocks of eight, for needs of 1.2 \csh{xintiiDivision}.}
% \lverb|This is used as$bgroup$obeyspaces$obeylines
% \the\numexpr\XINT_sepbyviii_andcount <8Ndigits>$%
% \XINT_sepbyviii_end 2345678\relax
@@ -17349,12 +17881,11 @@
\def\XINT_sepbyviii_andcount_end #1\XINT_sepbyviii_andcount_b\the\numexpr
#2+\xint_c_viii.#3#4\W {\expandafter.\the\numexpr #2+#3.}%
% \end{macrocode}
-% \subsection{Blocks of eight, for needs of 1.2 \csh{xintiiDivision}.}
% \lverb|This is used as$newline
% \romannumeral0\XINT_rev_nounsep {}<blocks 1<8d>!>\R!\R!\R!\R!\R!\R!\R!\R!\W
%
% It reverses the blocks, keeping the 1's and ! separators. Used multiple
-% times in division algorithm. The inserted {} here is *not* optional.
+% times in the division algorithm. The inserted {} here is *not* optional.
% Attention does not make disappear a 1!.|
% \begin{macrocode}
\def\XINT_rev_nounsep #1#2!#3!#4!#5!#6!#7!#8!#9!%
@@ -17432,7 +17963,7 @@
\def\XINT_div_unsepR_done #1\R #2\W {\XINT_cuz #1\R}%
% \end{macrocode}
% \subsection{\csh{xintReverseDigits}}
-% \lverb|1.2. Needed now by \xintLDg.|
+% \lverb|1.2.|
% \begin{macrocode}
\def\XINT_microrevsep #1#2#3#4#5#6#7#8%
{%
@@ -17541,7 +18072,6 @@
{%
\expandafter\XINT_abs \romannumeral0\xintnum{#1}%
}%
-\def\XINT_Abs #1{\romannumeral0\XINT_abs #1}%
\def\XINT_abs #1%
{%
\xint_UDsignfork
@@ -17573,156 +18103,175 @@
}%
% \end{macrocode}
% \subsection{\csh{xintLDg}, \csh{xintiiLDg}}
+% \lverb|&
+% Rewritten for 1.2i (2016/12/10). Surprisingly perhaps, faster than
+% \xintLastItem despite the \numexpr operations.
+% |
% \begin{macrocode}
-\def\xintLDg {\romannumeral0\xintldg }%
-\def\xintldg #1{\xintiildg {\xintNum{#1}}}%
+\def\xintLDg {\romannumeral0\xintldg }%
+\def\xintldg #1{\expandafter\XINT_ldg_fork\romannumeral0\xintnum{#1}%
+ \XINT_ldg_c{}{}{}{}{}{}{}{}\xint_bye\relax}%
\def\xintiiLDg {\romannumeral0\xintiildg }%
-\def\xintiildg #1%
+\def\xintiildg #1{\expandafter\XINT_ldg_fork\romannumeral`&&@#1%
+ \XINT_ldg_c{}{}{}{}{}{}{}{}\xint_bye\relax}%
+\def\XINT_ldg_fork #1%
{%
- \expandafter\XINT_ldg_done\romannumeral0%
- \expandafter\XINT_revdigits_a\the\numexpr\expandafter\XINT_microrevsep
- \romannumeral0\expandafter\XINT_abs
- \romannumeral`&&@#1{\XINT_microrevsep_end\W}\XINT_microrevsep_end
- \XINT_microrevsep_end\XINT_microrevsep_end
- \XINT_microrevsep_end\XINT_microrevsep_end
- \XINT_microrevsep_end\XINT_microrevsep_end\Z
- 1\Z!1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W
- \Z
+ \xint_UDsignfork
+ #1\XINT_ldg
+ -{\XINT_ldg#1}%
+ \krof
}%
-\def\XINT_ldg_done #1#2\Z { #1}%
+\edef\XINT_ldg #1#2#3#4#5#6#7#8#9%
+ {\noexpand\expandafter\space
+ \noexpand\the\numexpr#9#8#7#6#5#4#3#2#1*\xint_c_+\noexpand\XINT_ldg_a#9}%
+\def\XINT_ldg_a#1#2{\XINT_ldg_cbye#2\XINT_ldg_d#1\XINT_ldg_c\XINT_ldg_b#2}%
+\def\XINT_ldg_b#1#2#3#4#5#6#7#8#9{#9#8#7#6#5#4#3#2#1*\xint_c_+\XINT_ldg_a#9}%
+\def\XINT_ldg_c #1#2\xint_bye{#1}%
+\def\XINT_ldg_cbye #1\XINT_ldg_c{}%
+\def\XINT_ldg_d#1#2\xint_bye{#1}%
% \end{macrocode}
% \subsection{\csh{xintDouble}}
+% \lverb|1.08. Rewritten for 1.2. Again rewritten for 1.2i (one year
+% later...)!|
% \begin{macrocode}
-\def\xintDouble {\romannumeral0\xintdouble }%
-\def\xintdouble #1%
+\def\xintDouble {\romannumeral0\xintdouble}%
+\def\xintdouble #1{\expandafter\XINT_dbl\romannumeral`&&@#1%
+ \xint_bye2345678\xint_bye*\xint_c_ii\relax}%
+\def\XINT_dbl #1#2#3#4#5#6#7#8%
+ {\expandafter\space\the\numexpr#1#2#3#4#5#6#7#8\XINT_dbl_a}%
+\def\XINT_dbl_a #1#2#3#4#5#6#7#8%
+ {\expandafter\XINT_dbl_e\the\numexpr 1#1#2#3#4#5#6#7#8\XINT_dbl_a}%
+\def\XINT_dbl_e#1{*\xint_c_ii\if#13+\xint_c_i\fi\relax}%
+% \end{macrocode}
+% \subsection{\csh{xintHalf}}
+% \lverb|1.08. Rewritten for 1.2. Again rewritten for 1.2i.|
+% \begin{macrocode}
+\def\xintHalf {\romannumeral0\xinthalf}%
+\def\xinthalf #1{\expandafter\XINT_half_fork\romannumeral`&&@#1%
+ \xint_bye\xint_Bye345678\xint_bye
+ *\xint_c_v+\xint_c_v)/\xint_c_x-\xint_c_i\relax}%
+\def\XINT_half_fork #1%
{%
- \expandafter\XINT_dbl\romannumeral`&&@#1\Z
-}%
-\def\XINT_dbl #1%
-{%
- \xint_UDzerominusfork
- #1-\XINT_dbl_zero
- 0#1\XINT_dbl_neg
- 0-{\XINT_dbl_pos #1}%
+ \xint_UDsignfork
+ #1\XINT_half_neg
+ -{\XINT_half #1}%
\krof
}%
-\def\XINT_dbl_zero #1\Z { 0}%
-\def\XINT_dbl_neg
- {\expandafter-\romannumeral0\XINT_dbl_pos }%
-\def\XINT_dbl_pos #1\Z
-{%
- \expandafter\XINT_dbl_pos_aa
- \romannumeral0\expandafter\XINT_sepandrev
- \romannumeral0\XINT_zeroes_forviii #1\R\R\R\R\R\R\R\R{10}0000001\W
- #1\XINT_rsepbyviii_end_A 2345678%
- \XINT_rsepbyviii_end_B 2345678\relax XX%
- \R.\R.\R.\R.\R.\R.\R.\R.\W 1\Z!%
- 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W
-}%
-\def\XINT_dbl_pos_aa
-{%
- \expandafter\XINT_mul_out\the\numexpr\XINT_verysmallmul 0.2!%
-}%
+\def\XINT_half_neg{\xintiiopp\XINT_half}%
+\def\XINT_half #1#2#3#4#5#6#7#8%
+ {\expandafter\space\the\numexpr(#1#2#3#4#5#6#7#8\XINT_half_a}%
+\def\XINT_half_a#1{\xint_Bye#1\xint_bye\XINT_half_b#1}%
+\def\XINT_half_b #1#2#3#4#5#6#7#8%
+ {\expandafter\XINT_half_e\the\numexpr(1#1#2#3#4#5#6#7#8\XINT_half_a}%
+\def\XINT_half_e#1{*\xint_c_v+#1-\xint_c_v)\relax}%
% \end{macrocode}
-% \subsection{\csh{xintHalf}}
+% \subsection{\csh{xintInc}}
+% \lverb|1.2i much delayed complete rewrite in 1.2 style. I should have
+% done that at the time of 1.2 release (I modified \xintInc at that time but
+% wasn't very lucid after all the work done on 1.2).
+%
+% As we take 9 by 9 with the input save stack at 5000 this allows a bit less
+% than 9 times 2500 = 22500 digits on input.|
% \begin{macrocode}
-\def\xintHalf {\romannumeral0\xinthalf }%
-\def\xinthalf #1%
+\def\xintInc {\romannumeral0\xintinc}%
+\def\xintinc #1{\expandafter\XINT_inc_fork\romannumeral`&&@#1%
+ \xint_bye23456789\xint_bye+\xint_c_i\relax}%
+\def\XINT_inc_fork #1%
{%
- \expandafter\XINT_half\romannumeral`&&@#1\Z
-}%
-\def\XINT_half #1%
-{%
- \xint_UDzerominusfork
- #1-\XINT_half_zero
- 0#1\XINT_half_neg
- 0-{\XINT_half_pos #1}%
+ \xint_UDsignfork
+ #1\XINT_inc_neg
+ -{\XINT_inc #1}%
\krof
}%
-\def\XINT_half_zero #1\Z { 0}%
-\def\XINT_half_neg {\expandafter\XINT_opp\romannumeral0\XINT_half_pos }%
-\def\XINT_half_pos #1\Z
-{%
- \expandafter\XINT_half_pos_a
- \romannumeral0\expandafter\XINT_sepandrev
- \romannumeral0\XINT_zeroes_forviii #1\R\R\R\R\R\R\R\R{10}0000001\W
- #1\XINT_rsepbyviii_end_A 2345678%
- \XINT_rsepbyviii_end_B 2345678\relax XX%
- \R.\R.\R.\R.\R.\R.\R.\R.\W
- 1\Z!%
- 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W
-}%
-\def\XINT_half_pos_a
- {\expandafter\XINT_half_pos_b\the\numexpr\XINT_verysmallmul 0.5!}%
-\def\XINT_half_pos_b 1#1#2#3#4#5#6#7#8!1#9%
-{%
- \xint_gob_til_Z #9\XINT_half_small \Z
- \XINT_mul_out 1#1#2#3#4#5#6#7!1#9%
-}%
-\edef\XINT_half_small \Z\XINT_mul_out 1#1!#2\W
-{%
- \noexpand\expandafter\space\noexpand\the\numexpr #1\relax
-}%
+\def\XINT_inc_neg #1\xint_bye#2\relax
+ {\xintiiopp\XINT_dec #1\XINT_dec_bye234567890\xint_bye}%
+\def\XINT_inc #1#2#3#4#5#6#7#8#9%
+ {\expandafter\space\the\numexpr#1#2#3#4#5#6#7#8#9\XINT_inc_a}%
+\def\XINT_inc_a #1#2#3#4#5#6#7#8#9%
+ {\expandafter\XINT_inc_e\the\numexpr 1#1#2#3#4#5#6#7#8#9\XINT_inc_a}%
+\def\XINT_inc_e#1{\if#12+\xint_c_i\fi\relax}%
% \end{macrocode}
% \subsection{\csh{xintDec}}
+% \lverb|1.2i much delayed complete rewrite in the 1.2 style. Things are a
+% bit more complicated than \xintInc because 2999999999 is too big for TeX.|
% \begin{macrocode}
-\def\xintDec {\romannumeral0\xintdec }%
-\def\xintdec #1%
+\def\xintDec {\romannumeral0\xintdec}%
+\def\xintdec #1{\expandafter\XINT_dec_fork\romannumeral`&&@#1%
+ \XINT_dec_bye234567890\xint_bye}%
+\def\XINT_dec_fork #1%
{%
- \expandafter\XINT_dec\romannumeral`&&@#1\Z
+ \xint_UDsignfork
+ #1\XINT_dec_neg
+ -{\XINT_dec #1}%
+ \krof
}%
-\def\XINT_dec #1%
+\def\XINT_dec_neg #1\XINT_dec_bye#2\xint_bye
+ {\expandafter-%
+ \romannumeral0\XINT_inc #1\xint_bye23456789\xint_bye+\xint_c_i\relax}%
+\def\XINT_dec #1#2#3#4#5#6#7#8#9%
+ {\expandafter\space\the\numexpr#1#2#3#4#5#6#7#8#9\XINT_dec_a}%
+\def\XINT_dec_a #1#2#3#4#5#6#7#8#9%
+ {\expandafter\XINT_dec_e\the\numexpr 1#1#2#3#4#5#6#7#8#9\XINT_dec_a}%
+\def\XINT_dec_bye #1\XINT_dec_a#2#3\xint_bye
+ {\if#20-\xint_c_ii\relax+\else-\fi\xint_c_i\relax}%
+\def\XINT_dec_e#1{\unless\if#11\xint_dothis{-\xint_c_i#1}\fi\xint_orthat\relax}%
+% \end{macrocode}
+% \subsection{\csh{xintDSL}}
+% \lverb|DECIMAL SHIFT LEFT (=MULTIPLICATION PAR 10). Rewritten for 1.2i.
+% This was very old code... I never came back to it, but I should have
+% rewritten it long time ago.|
+% \begin{macrocode}
+\def\xintDSL {\romannumeral0\xintdsl }%
+\def\xintdsl #1{\expandafter\XINT_dsl\romannumeral`&&@#10}%
+\edef\XINT_dsl #1%
+ {\noexpand\xint_gob_til_zero #1\noexpand\xint_dsl_zero 0\space #1}%
+\def\xint_dsl_zero 0 0{ }%
+% \end{macrocode}
+% \subsection{\csh{xintDSR}}
+% \lverb|Decimal shift right, truncates towards zero. Rewritten for 1.2i.
+% Limited to 22483 digits on input.|
+% \begin{macrocode}
+\def\xintDSR{\romannumeral0\xintdsr}%
+\def\xintdsr #1{\expandafter\XINT_dsr_fork\romannumeral`&&@#1%
+ \xint_bye\xint_Bye3456789\xint_bye+\xint_c_v)/\xint_c_x-\xint_c_i\relax}%
+\def\XINT_dsr_fork #1%
{%
- \xint_UDzerominusfork
- #1-\XINT_dec_zero
- 0#1\XINT_dec_neg
- 0-{\XINT_dec_pos #1}%
+ \xint_UDsignfork
+ #1\XINT_dsr_neg
+ -{\XINT_dsr #1}%
\krof
}%
-\def\XINT_dec_zero #1\Z {-1}%
-\def\XINT_dec_neg
- {\expandafter-\romannumeral0\XINT_inc_pos }%
-\def\XINT_dec_pos #1\Z
-{%
- \expandafter\XINT_dec_pos_aa
- \romannumeral0\expandafter\XINT_sepandrev
- \romannumeral0\XINT_zeroes_forviii #1\R\R\R\R\R\R\R\R{10}0000001\W
- #1\XINT_rsepbyviii_end_A 2345678%
- \XINT_rsepbyviii_end_B 2345678\relax XX%
- \R.\R.\R.\R.\R.\R.\R.\R.\W
- \Z!\Z!\Z!\Z!\W
-}%
-\def\XINT_dec_pos_aa {\XINT_sub_aa 100000001!\Z!\Z!\Z!\Z!\W }%
+\def\XINT_dsr_neg{\xintiiopp\XINT_dsr}%
+\def\XINT_dsr #1#2#3#4#5#6#7#8#9%
+ {\expandafter\space\the\numexpr(#1#2#3#4#5#6#7#8#9\XINT_dsr_a}%
+\def\XINT_dsr_a#1{\xint_Bye#1\xint_bye\XINT_dsr_b#1}%
+\def\XINT_dsr_b #1#2#3#4#5#6#7#8#9%
+ {\expandafter\XINT_dsr_e\the\numexpr(1#1#2#3#4#5#6#7#8#9\XINT_dsr_a}%
+\def\XINT_dsr_e #1{)\relax}%
% \end{macrocode}
-% \subsection{\csh{xintInc}}
+% \subsection{\csh{xintDSRr}}
+% \lverb|New with 1.2i. Decimal shift right, rounds away from zero; done in
+% the 1.2 spirit (with much delay, sorry). Used by \xintRound, \xintDivRound.
+%
+% This is about the first time I am happy that the division in \numexpr rounds!|
% \begin{macrocode}
-\def\xintInc {\romannumeral0\xintinc }%
-\def\xintinc #1%
+\def\xintDSRr{\romannumeral0\xintdsrr}%
+\def\xintdsrr #1{\expandafter\XINT_dsrr_fork\romannumeral`&&@#1%
+ \xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax}%
+\def\XINT_dsrr_fork #1%
{%
- \expandafter\XINT_inc\romannumeral`&&@#1\Z
-}%
-\def\XINT_inc #1%
-{%
- \xint_UDzerominusfork
- #1-\XINT_inc_zero
- 0#1\XINT_inc_neg
- 0-{\XINT_inc_pos #1}%
+ \xint_UDsignfork
+ #1\XINT_dsrr_neg
+ -{\XINT_dsrr #1}%
\krof
}%
-\def\XINT_inc_zero #1\Z { 1}%
-\def\XINT_inc_neg {\expandafter\XINT_opp\romannumeral0\XINT_dec_pos }%
-\def\XINT_inc_pos #1\Z
-{%
- \expandafter\XINT_inc_pos_aa
- \romannumeral0\expandafter\XINT_sepandrev
- \romannumeral0\XINT_zeroes_forviii #1\R\R\R\R\R\R\R\R{10}0000001\W
- #1\XINT_rsepbyviii_end_A 2345678%
- \XINT_rsepbyviii_end_B 2345678\relax XX%
- \R.\R.\R.\R.\R.\R.\R.\R.\W
- 1\Z!1\Z!1\Z!1\Z!\W
- 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W
-}%
-\def\XINT_inc_pos_aa {\XINT_add_aa 100000001!1\Z!1\Z!1\Z!1\Z!\W }%
+\def\XINT_dsrr_neg{\xintiiopp\XINT_dsrr}%
+\def\XINT_dsrr #1#2#3#4#5#6#7#8#9%
+ {\expandafter\space\the\numexpr#1#2#3#4#5#6#7#8#9\XINT_dsrr_a}%
+\def\XINT_dsrr_a#1{\xint_Bye#1\xint_bye\XINT_dsrr_b#1}%
+\def\XINT_dsrr_b #1#2#3#4#5#6#7#8#9%
+ {\expandafter\XINT_dsrr_e\the\numexpr1#1#2#3#4#5#6#7#8#9\XINT_dsrr_a}%
+\let\XINT_dsrr_e\XINT_inc_e
% \end{macrocode}
% \subsection{Core arithmetic}
% \lverb|The four operations have been rewritten entirely for release 1.2.
@@ -18890,8 +19439,8 @@
\def\xintiRem {\romannumeral0\xintirem }%
\def\xintiquo {\expandafter\xint_firstoftwo_thenstop\romannumeral0\xintidivision }%
\def\xintirem {\expandafter\xint_secondoftwo_thenstop\romannumeral0\xintidivision }%
-\let\xintQuo\xintiQuo\let\xintquo\xintiquo % deprecated
-\let\xintRem\xintiRem\let\xintrem\xintirem % deprecated
+%%\let\xintQuo\xintiQuo\let\xintquo\xintiquo % now removed
+%%\let\xintRem\xintiRem\let\xintrem\xintirem % now removed
% \end{macrocode}
% \lverb-#1 = A, #2 = B. On calcule le quotient et le reste dans la division
% euclidienne de A par B: A=BQ+R, 0<= R < |B|.-
@@ -18985,11 +19534,13 @@
\def\XINT_div_BisTwo #1#2%
{%
\expandafter\expandafter\expandafter\XINT_div_BisTwo_a
- \ifodd\xintLDg{#2} \expandafter1\else \expandafter0\fi {#2}%
+ \ifodd\xintiiLDg{#2} \expandafter1\else \expandafter0\fi {#2}%
}%
\def\XINT_div_BisTwo_a #1#2%
{%
- \expandafter{\romannumeral0\xinthalf {#2}}{#1}%
+ \expandafter{\romannumeral0\XINT_half
+ #2\xint_bye\xint_Bye345678\xint_bye
+ *\xint_c_v+\xint_c_v)/\xint_c_x-\xint_c_i\relax}{#1}%
}%
% \end{macrocode}
% \lverb|B a au plus huit chiffres et est au moins 3. On va l'utiliser
@@ -19748,7 +20299,8 @@
}%
% \end{macrocode}
% \subsection{\csh{xintiDivRound}, \csh{xintiiDivRound}}
-% \lverb|1.1, transferred from first release of bnumexpr. Rewritten for 1.2.|
+% \lverb|1.1, transferred from first release of bnumexpr. Rewritten for 1.2.
+% Ending rewritten for 1.2i. (new \xintDSRr).|
% \begin{macrocode}
\def\xintiDivRound {\romannumeral0\xintidivround }%
\def\xintidivround #1%
@@ -19785,54 +20337,12 @@
}%
\def\XINT_iidivround_pos #1#2\Z #3\Z
{%
- \expandafter\XINT_iidivround_pos_a
+ \expandafter\expandafter\expandafter\XINT_dsrr
+ \expandafter\xint_firstoftwo
\romannumeral0\XINT_div_prepare {#2}{#1#30}%
+ \xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax
}%
% \end{macrocode}
-% \lverb|The 1.2c interface to addition changed, the \Z's are now 1\Z's here.
-% Will have to come back here for improvements. The 1\Z!1\Z!1\Z!1\Z!\W are for
-% the addition which is done if rounding up.|
-% \begin{macrocode}
-\def\XINT_iidivround_pos_a #1#2%
-{%
- \expandafter\XINT_iidivround_pos_b
- \romannumeral0\expandafter\XINT_sepandrev
- \romannumeral0\XINT_zeroes_forviii #1\R\R\R\R\R\R\R\R{10}0000001\W
- #1\XINT_rsepbyviii_end_A 2345678\XINT_rsepbyviii_end_B 2345678\relax XX%
- \R.\R.\R.\R.\R.\R.\R.\R.\W
- 1\Z!1\Z!1\Z!1\Z!\W\R
-}%
-\def\XINT_iidivround_pos_b 1#1#2#3#4#5#6#7#8!1#9%
-{%
- \xint_gob_til_Z #9\XINT_iidivround_small\Z
- \ifnum #8>\xint_c_iv
- \expandafter\XINT_iidivround_pos_up
- \else \expandafter\XINT_iidivround_pos_finish
- \fi
- 1#1#2#3#4#5#6#70!1#9%
-}%
-\def\XINT_iidivround_pos_up
-{%
- \expandafter\XINT_iidivround_pos_finish
- \the\numexpr\XINT_add_a\xint_c_ii 100000010!1\Z!1\Z!1\Z!1\Z!\W
-}%
-\def\XINT_iidivround_pos_finish #10!#21\Z!#3\R
-{%
- \expandafter\XINT_cuz_small\romannumeral0\XINT_unrevbyviii {}%
- #1!#21\Z!1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W
-}%
-\def\XINT_iidivround_small\Z\ifnum #1>#2\fi 1#30!#4\W\R
-{%
- \ifnum #1>\xint_c_iv
- \expandafter\XINT_iidivround_small_up
- \else \expandafter\XINT_iidivround_small_trunc
- \fi {#3}%
-}%
-\edef\XINT_iidivround_small_up #1%
- {\noexpand\expandafter\space\noexpand\the\numexpr #1+\xint_c_i\relax }%
-\edef\XINT_iidivround_small_trunc #1%
- {\noexpand\expandafter\space\noexpand\the\numexpr #1\relax }%
-% \end{macrocode}
% \subsection{\csh{xintiDivTrunc}, \csh{xintiiDivTrunc}}
% \begin{macrocode}
\def\xintiDivTrunc {\romannumeral0\xintidivtrunc }%
@@ -19910,6 +20420,8 @@
\def\xintMul {\Did_you_mean_iiMul?or_load_xintfrac!}%
\def\xintPow {\Did_you_mean_iiPow?or_load_xintfrac!}%
\def\xintSqr {\Did_you_mean_iiSqr?or_load_xintfrac!}%
+\def\xintQuo {\Removed!use_xintiQuo_or_xintiiQuo!}%
+\def\xintRem {\Removed!use_xintiRem_or_xintiiRem!}%
\XINT_restorecatcodes_endinput%
% \end{macrocode}
%
@@ -19979,7 +20491,7 @@
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xint}%
- [2016/11/20 1.2h Expandable operations on big integers (JFB)]%
+ [2016/12/13 1.2i Expandable operations on big integers (JFB)]%
% \end{macrocode}
% \subsection{More token management}
% \begin{macrocode}
@@ -20011,13 +20523,16 @@
% \lverb|Added in 1.03. 1.09a defines \xintIsOne. 1.1a adds \xintiiIsOne.
%
% \XINT_isOne rewritten for 1.2g. Works with expanded strict integers,
-% positive or negative.|
+% positive or negative.
+%
+%
+%
+%|
% \begin{macrocode}
-\def\xintiiIsOne {\romannumeral0\xintiiisone }%
+\def\xintiiIsOne {\romannumeral0\xintiiisone }%
\def\xintiiisone #1{\expandafter\XINT_isone\romannumeral`&&@#1XY}%
\def\xintIsOne {\romannumeral0\xintisone }%
-\def\xintisone #1{\expandafter\XINT_isone\romannumeral0\xintnum{#1}XY}%
-\def\XINT_isOne #1{\romannumeral0\XINT_isone #1XY}%
+\def\xintisone #1{\expandafter\XINT_isone\romannumeral0\xintnum{#1}XY}%
\def\XINT_isone #1#2#3Y%
{%
\unless\if#2X\xint_dothis{ 0}\fi
@@ -20024,6 +20539,13 @@
\unless\if#11\xint_dothis{ 0}\fi
\xint_orthat{ 1}%
}%
+\def\XINT_isOne #1{\XINT_iSone#1XY}%
+\def\XINT_iSone #1#2#3Y%
+{%
+ \unless\if#2X\xint_dothis0\fi
+ \unless\if#11\xint_dothis0\fi
+ \xint_orthat1%
+}%
% \end{macrocode}
% \subsection{\csh{xintRev}}
% \lverb|&
@@ -20047,22 +20569,16 @@
{%
\expandafter\XINT_len_fork
\romannumeral0\xintnum{#1}\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye\relax
}%
-\def\XINT_Len #1% variant which does not expand via \xintnum.
+\edef\XINT_len_fork #1%
{%
- \romannumeral0\XINT_len_fork
- #1\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ \noexpand\expandafter\space
+ \unexpanded{\the\numexpr\xint_c_ix\expandafter
+ \XINT_length_loop\xint_UDsignfork#1{}-{#1}\krof}%
}%
-\def\XINT_len_fork #1%
-{%
- \expandafter\XINT_length_loop
- \xint_UDsignfork
- #1{0.}%
- -{0.#1}%
- \krof
-}%
% \end{macrocode}
% \subsection{\csh{xintBool}, \csh{xintToggle}}
% \lverb|1.09c|
@@ -20166,13 +20682,12 @@
}%
% \end{macrocode}
% \subsection{\csh{xintifTrueAelseB}, \csh{xintifFalseAelseB}}
-% \lverb|1.09i. Warning, \xintifTrueFalse, \xintifTrue deprecated, to be
-% removed|
+% \lverb|1.09i. 1.2i has removed deprecated \xintifTrueFalse, \xintifTrue.|
% \begin{macrocode}
\let\xintifTrueAelseB\xintifNotZero
\let\xintifFalseAelseB\xintifZero
-\let\xintifTrue\xintifNotZero
-\let\xintifTrueFalse\xintifNotZero
+%%\let\xintifTrue\xintifNotZero % now removed
+%%\let\xintifTrueFalse\xintifNotZero % now removed
% \end{macrocode}
% \subsection{\csh{xintifCmp}, \csh{xintiiifCmp}}
% \lverb|1.09e
@@ -20946,9 +21461,10 @@
% -----------------------------------------------------------------$\
% -----------------------------------------------------------------$\
% DECIMAL OPERATIONS: FIRST DIGIT, LASTDIGIT, (<- moved to xintcore
-% because xintiiLDg need by division macros)
+% because xintiiLDg needed by division macros)
% ODDNESS,
-% MULTIPLICATION BY TEN, QUOTIENT BY TEN, QUOTIENT OR
+% MULTIPLICATION BY TEN, QUOTIENT BY TEN, (moved to xintcore 1.2i)
+% QUOTIENT OR
% MULTIPLICATION BY POWER OF TEN, SPLIT OPERATION.|
% \subsection{\csh{xintMON}, \csh{xintMMON}, \csh{xintiiMON}, \csh{xintiiMMON}}
% \lverb|&
@@ -20957,7 +21473,7 @@
\def\xintiiMON {\romannumeral0\xintiimon }%
\def\xintiimon #1%
{%
- \ifodd\xintiiLDg {#1}
+ \ifodd\xintiiLDg {#1} %<- intentional space
\xint_afterfi{ -1}%
\else
\xint_afterfi{ 1}%
@@ -20966,7 +21482,7 @@
\def\xintiiMMON {\romannumeral0\xintiimmon }%
\def\xintiimmon #1%
{%
- \ifodd\xintiiLDg {#1}
+ \ifodd\xintiiLDg {#1} %<- intentional space
\xint_afterfi{ 1}%
\else
\xint_afterfi{ -1}%
@@ -20975,7 +21491,7 @@
\def\xintMON {\romannumeral0\xintmon }%
\def\xintmon #1%
{%
- \ifodd\xintLDg {#1}
+ \ifodd\xintLDg {#1} %<- intentional space
\xint_afterfi{ -1}%
\else
\xint_afterfi{ 1}%
@@ -20984,7 +21500,7 @@
\def\xintMMON {\romannumeral0\xintmmon }%
\def\xintmmon #1%
{%
- \ifodd\xintLDg {#1}
+ \ifodd\xintLDg {#1} %<- intentional space
\xint_afterfi{ 1}%
\else
\xint_afterfi{ -1}%
@@ -20996,7 +21512,7 @@
\def\xintiiOdd {\romannumeral0\xintiiodd }%
\def\xintiiodd #1%
{%
- \ifodd\xintiiLDg{#1}
+ \ifodd\xintiiLDg{#1} %<- intentional space
\xint_afterfi{ 1}%
\else
\xint_afterfi{ 0}%
@@ -21005,7 +21521,7 @@
\def\xintiiEven {\romannumeral0\xintiieven }%
\def\xintiieven #1%
{%
- \ifodd\xintiiLDg{#1}
+ \ifodd\xintiiLDg{#1} %<- intentional space
\xint_afterfi{ 0}%
\else
\xint_afterfi{ 1}%
@@ -21014,7 +21530,7 @@
\def\xintOdd {\romannumeral0\xintodd }%
\def\xintodd #1%
{%
- \ifodd\xintLDg{#1}
+ \ifodd\xintLDg{#1} %<- intentional space
\xint_afterfi{ 1}%
\else
\xint_afterfi{ 0}%
@@ -21023,7 +21539,7 @@
\def\xintEven {\romannumeral0\xinteven }%
\def\xinteven #1%
{%
- \ifodd\xintLDg{#1}
+ \ifodd\xintLDg{#1} %<- intentional space
\xint_afterfi{ 0}%
\else
\xint_afterfi{ 1}%
@@ -21030,61 +21546,25 @@
\fi
}%
% \end{macrocode}
-% \subsection{\csh{xintDSL}}
-% \lverb|DECIMAL SHIFT LEFT (=MULTIPLICATION PAR 10)|
-% \begin{macrocode}
-\def\xintDSL {\romannumeral0\xintdsl }%
-\def\xintdsl #1%
-{%
- \expandafter\XINT_dsl \romannumeral`&&@#1\Z
-}%
-\def\XINT_DSL #1{\romannumeral0\XINT_dsl #1\Z }%
-\def\XINT_dsl #1%
-{%
- \xint_gob_til_zero #1\xint_dsl_zero 0\XINT_dsl_ #1%
-}%
-\def\xint_dsl_zero 0\XINT_dsl_ 0#1\Z { 0}%
-\def\XINT_dsl_ #1\Z { #10}%
-% \end{macrocode}
-% \subsection{\csh{xintDSR}}
-% \lverb|DECIMAL SHIFT RIGHT (=DIVISION PAR 10).
-% |
-% \begin{macrocode}
-\def\xintDSR {\romannumeral0\xintdsr }%
-\def\xintdsr #1%
-{%
- \expandafter\XINT_dsr_a\expandafter {\romannumeral`&&@#1}\W\Z
-}%
-\def\XINT_DSR #1{\romannumeral0\XINT_dsr_a {#1}\W\Z }%
-\def\XINT_dsr_a
-{%
- \expandafter\XINT_dsr_b\romannumeral0\xintreverseorder
-}%
-\def\XINT_dsr_b #1#2#3\Z
-{%
- \xint_gob_til_W #2\xint_dsr_onedigit\W
- \xint_gob_til_minus #2\xint_dsr_onedigit-%
- \expandafter\XINT_dsr_removew
- \romannumeral0\xintreverseorder {#2#3}%
-}%
-\def\xint_dsr_onedigit #1\xintreverseorder #2{ 0}%
-\def\XINT_dsr_removew #1\W { }%
-% \end{macrocode}
% \subsection{\csh{xintDSH}, \csh{xintDSHr}}
-% \lverb+DECIMAL SHIFTS \xintDSH {x}{A}$\
+% \lverb!DECIMAL SHIFTS \xintDSH {x}{A}$\
% si x <= 0, fait A -> A.10^(|x|).
% 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).
-% +
+%
+% Badly named macros.
+%
+% Rewritten for 1.2i, this was old code and \xintDSx has changed interface.
+% !
% \begin{macrocode}
\def\xintDSHr {\romannumeral0\xintdshr }%
-\def\xintdshr #1%
+\def\xintdshr #1#2%
{%
- \expandafter\XINT_dshr_checkxpositive \the\numexpr #1\relax\Z
+ \expandafter\XINT_dshr_fork\the\numexpr#1\expandafter.\romannumeral`&&@#2;%
}%
-\def\XINT_dshr_checkxpositive #1%
+\def\XINT_dshr_fork #1%
{%
\xint_UDzerominusfork
0#1\XINT_dshr_xzeroorneg
@@ -21092,37 +21572,32 @@
0-\XINT_dshr_xpositive
\krof #1%
}%
-\def\XINT_dshr_xzeroorneg #1\Z #2{ 0}%
-\def\XINT_dshr_xpositive #1\Z
+\def\XINT_dshr_xzeroorneg #1;{ 0}%
+\def\XINT_dshr_xpositive
{%
- \expandafter\xint_secondoftwo_thenstop\romannumeral0\xintdsx {#1}%
+ \expandafter\xint_secondoftwo_thenstop\romannumeral0\XINT_dsx_xisPos
}%
\def\xintDSH {\romannumeral0\xintdsh }%
\def\xintdsh #1#2%
{%
- \expandafter\xint_dsh\expandafter {\romannumeral`&&@#2}{#1}%
+ \expandafter\XINT_dsh_fork\the\numexpr#1\expandafter.\romannumeral`&&@#2;%
}%
-\def\xint_dsh #1#2%
+\def\XINT_dsh_fork #1%
{%
- \expandafter\XINT_dsh_checksignx \the\numexpr #2\relax\Z {#1}%
-}%
-\def\XINT_dsh_checksignx #1%
-{%
\xint_UDzerominusfork
#1-\XINT_dsh_xiszero
- 0#1\XINT_dsx_xisNeg_checkA % on passe direct dans DSx
+ 0#1\XINT_dsx_xisNeg_checkA
0-{\XINT_dsh_xisPos #1}%
\krof
}%
-\def\XINT_dsh_xiszero #1\Z #2{ #2}%
-\def\XINT_dsh_xisPos #1\Z #2%
+\def\XINT_dsh_xiszero #1.#2;{ #2}%
+\def\XINT_dsh_xisPos
{%
- \expandafter\xint_firstoftwo_thenstop
- \romannumeral0\XINT_dsx_checksignA #2\Z {#1}% via DSx
+ \expandafter\xint_firstoftwo_thenstop\romannumeral0\XINT_dsx_xisPos
}%
% \end{macrocode}
% \subsection{\csh{xintDSx}}
-% \lverb+&
+% \lverb!&
% --> Attention le cas x=0 est traité dans la même catégorie que x > 0 <--$\
% si x < 0, fait A -> A.10^(|x|)$\
% si x >= 0, et A >=0, fait A -> {quo(A,10^(x))}{rem(A,10^(x))}$\
@@ -21134,30 +21609,17 @@
% où il faut prendre le signe plus si Q est positif ou nul et le signe moins si
% Q est strictement négatif.
%
-% December 4, 2015: As the new techniques of the 1.2 release limit the basic
-% arithmetic to less than about 20000 digits, I should again consider a faster
-% dsx_loop possibly impacting the input save stack impacting style; preserving
-% a special routine if really needed for \xintXTrunc or the other concerned
-% routines (if \xintXTrunc really needs it, which I have to check.)
+% Rewritten for 1.2i, this was old code.
%
-% 2016/03/12: this is old code. 1.2f has removed the part of it which
-% checked the size of x parameter.
-%
-% +
+%!
% \begin{macrocode}
\def\xintDSx {\romannumeral0\xintdsx }%
\def\xintdsx #1#2%
{%
- \expandafter\xint_dsx\expandafter {\romannumeral`&&@#2}{#1}%
+ \expandafter\XINT_dsx_fork\the\numexpr#1\expandafter.\romannumeral`&&@#2;%
}%
-\def\xint_dsx #1#2%
+\def\XINT_dsx_fork #1%
{%
- \expandafter\XINT_dsx_checksignx \the\numexpr #2\relax\Z {#1}%
-}%
-\def\XINT_DSx #1#2{\romannumeral0\XINT_dsx_checksignx #1\Z {#2}}%
-\def\XINT_dsx #1#2{\XINT_dsx_checksignx #1\Z {#2}}%
-\def\XINT_dsx_checksignx #1%
-{%
\xint_UDzerominusfork
#1-\XINT_dsx_xisZero
0#1\XINT_dsx_xisNeg_checkA
@@ -21164,48 +21626,31 @@
0-{\XINT_dsx_xisPos #1}%
\krof
}%
-\def\XINT_dsx_xisZero #1\Z #2{{#2}{0}}% attention comme x > 0
-\def\XINT_dsx_xisNeg_checkA #1\Z #2%
+\def\XINT_dsx_xisZero #1.#2;{{#2}{0}}%
+\def\XINT_dsx_xisNeg_checkA #1.#2%
{%
- \XINT_dsx_xisNeg_checkA_ #2\Z {#1}%
+ \xint_gob_til_zero #2\XINT_dsx_xisNeg_Azero 0%
+ \expandafter\XINT_dsx_append\romannumeral\XINT_rep #1\endcsname 0.#2%
}%
-\def\XINT_dsx_xisNeg_checkA_ #1#2\Z #3%
+\def\XINT_dsx_xisNeg_Azero #1;{ 0}%
+\def\XINT_dsx_addzeros #1%
+ {\expandafter\XINT_dsx_append\romannumeral\XINT_rep#1\endcsname0.}%
+\def\XINT_dsx_addzerosnofuss #1%
+ {\expandafter\XINT_dsx_append\romannumeral\xintreplicate{#1}0.}%
+\def\XINT_dsx_append #1.#2;{ #2#1}%
+\def\XINT_dsx_xisPos #1.#2%
{%
- \xint_gob_til_zero #1\XINT_dsx_xisNeg_Azero 0%
- \XINT_dsx_zeroloop #3.{}\Z {#1#2}%
-}%
-\def\XINT_dsx_xisNeg_Azero #1\Z #2{ 0}%
-\def\XINT_dsx_addzerosnofuss #1{\XINT_dsx_zeroloop #1.{}\Z }%
-\def\XINT_dsx_zeroloop #1.#2%
-{%
- \ifnum #1<\xint_c_ix \expandafter\XINT_dsx_exita\fi
- \expandafter\XINT_dsx_zeroloop\the\numexpr #1-\xint_c_viii.{#200000000}%
-}%
-\def\XINT_dsx_exita
- \expandafter\XINT_dsx_zeroloop\the\numexpr #1-\xint_c_viii.#2%
-{%
- \expandafter\expandafter\expandafter
- \XINT_dsx_addzeros\csname xint_gobble_\expandafter
- \romannumeral\numexpr \xint_c_viii-(#1)\endcsname #2%
-}%
-\def\XINT_dsx_addzeros #1\Z #2{ #2#1}%
-\def\XINT_dsx_xisPos #1\Z #2%
-{%
- \XINT_dsx_checksignA #2\Z {#1}%
-}%
-\def\XINT_dsx_checksignA #1%
-{%
\xint_UDzerominusfork
- #1-\XINT_dsx_AisZero
- 0#1\XINT_dsx_AisNeg
- 0-{\XINT_dsx_AisPos #1}%
- \krof
+ #2-\XINT_dsx_AisZero
+ 0#2\XINT_dsx_AisNeg
+ 0-\XINT_dsx_AisPos
+ \krof #1.#2%
}%
-\def\XINT_dsx_AisZero #1\Z #2{{0}{0}}%
-\def\XINT_dsx_AisNeg #1\Z #2%
+\def\XINT_dsx_AisZero #1;{{0}{0}}%
+\def\XINT_dsx_AisNeg #1.-#2;%
{%
\expandafter\XINT_dsx_AisNeg_checkiffirstempty
- \romannumeral0\XINT_split_xfork #2.#1\W\W\W\W\W\W\W\W\Z
+ \romannumeral0\XINT_split_xfork #1.#2\xint_bye2345678\xint_bye..%
}%
\def\XINT_dsx_AisNeg_checkiffirstempty #1%
{%
@@ -21222,10 +21667,10 @@
\expandafter\XINT_dsx_end
\expandafter {\romannumeral0\XINT_num {#2}}{-#1}%
}%
-\def\XINT_dsx_AisPos #1\Z #2%
+\def\XINT_dsx_AisPos #1.#2;%
{%
\expandafter\XINT_dsx_AisPos_finish
- \romannumeral0\XINT_split_xfork #2.#1\W\W\W\W\W\W\W\W\Z
+ \romannumeral0\XINT_split_xfork #1.#2\xint_bye2345678\xint_bye..%
}%
\def\XINT_dsx_AisPos_finish #1.#2.%
{%
@@ -21238,21 +21683,21 @@
% \subsection{\csh{xintDecSplit}, \csh{xintDecSplitL}, \csh{xintDecSplitR}}
% \lverb!DECIMAL SPLIT
%
-% The macro \xintDecSplit {x}{A} first replaces A with |A| (*)
-% This macro cuts the number into two pieces L and R. The concatenation LR
-% always reproduces |A|, and R may be empty or have leading zeros. The
-% position of the cut is specified by the first argument x. If x is zero or
-% positive the cut location is x slots to the left of the right end of the
+% The macro \xintDecSplit {x}{A} cuts A which is composed of digits (leading
+% zeroes ok, but no sign) (*) into two (each possibly empty) pieces L and R.
+% The concatenation LR always reproduces A.
+%
+% The position of the cut is specified by the first argument x. If x is zero
+% or positive the cut location is x slots to the left of the right end of the
% number. If x becomes equal to or larger than the length of the number then L
% becomes empty. If x is negative the location of the cut is |x| slots to the
% right of the left end of the number.
%
-% (*) warning: this may change in a future version. Only the behavior
-% for A non-negative is guaranteed to remain the same.
+% (*) versions earlier than 1.2i first replaced A with its absolute value.
+% This is not the case anymore. This macro should NOT be used for A with a
+% leading sign (+ or -).
%
-% 2016/03/12: this is old code. 1.2f has removed the part of it which
-% checked the size of x parameter.
-%
+% Entirely rewritten for 1.2i (2016/12/11).
% !
% \begin{macrocode}
\def\xintDecSplit {\romannumeral0\xintdecsplit }%
@@ -21260,7 +21705,8 @@
{%
\expandafter\XINT_split_finish
\romannumeral0\expandafter\XINT_split_xfork
- \the\numexpr #1\expandafter.\romannumeral0\xintiiabs {#2}\W\W\W\W\W\W\W\W\Z
+ \the\numexpr #1\expandafter.\romannumeral`&&@#2%
+ \xint_bye2345678\xint_bye..%
}%
\def\xintDecSplitL {\romannumeral0\xintdecsplitl }%
\def\xintdecsplitl #1#2%
@@ -21267,7 +21713,8 @@
{%
\expandafter\XINT_splitl_finish
\romannumeral0\expandafter\XINT_split_xfork
- \the\numexpr #1\expandafter.\romannumeral0\xintiiabs {#2}\W\W\W\W\W\W\W\W\Z
+ \the\numexpr #1\expandafter.\romannumeral`&&@#2%
+ \xint_bye2345678\xint_bye..%
}%
\def\xintDecSplitR {\romannumeral0\xintdecsplitr }%
\def\xintdecsplitr #1#2%
@@ -21274,11 +21721,12 @@
{%
\expandafter\XINT_splitr_finish
\romannumeral0\expandafter\XINT_split_xfork
- \the\numexpr #1\expandafter.\romannumeral0\xintiiabs {#2}\W\W\W\W\W\W\W\W\Z
+ \the\numexpr #1\expandafter.\romannumeral`&&@#2%
+ \xint_bye2345678\xint_bye..%
}%
\def\XINT_split_finish #1.#2.{{#1}{#2}}%
-\def\XINT_splitl_finish #1.#2.{{#1}}%
-\def\XINT_splitr_finish #1.#2.{{#2}}%
+\def\XINT_splitl_finish #1.#2.{ #1}%
+\def\XINT_splitr_finish #1.#2.{ #2}%
\def\XINT_split_xfork #1%
{%
\xint_UDzerominusfork
@@ -21287,108 +21735,63 @@
0-{\XINT_split_fromright #1}%
\krof
}%
-\def\XINT_split_zerosplit #1.#2\W\W\W\W\W\W\W\W\Z{ #2..}%
-\def\XINT_split_fromleft #1.%#2\W\W\W\W\W\W\W\W\Z
+\def\XINT_split_zerosplit .#1\xint_bye#2\xint_bye..{ #1..}%
+\def\XINT_split_fromleft
+ {\expandafter\XINT_split_fromleft_a\the\numexpr\xint_c_viii-}%
+\def\XINT_split_fromleft_a #1%
{%
- \XINT_split_fromleft_loop #1.{}%#2\W\W\W\W\W\W\W\W\Z
+ \xint_UDsignfork
+ #1\XINT_split_fromleft_b
+ -{\XINT_split_fromleft_end_a #1}%
+ \krof
}%
-\def\XINT_split_fromleft_loop #1.%
+\def\XINT_split_fromleft_b #1.#2#3#4#5#6#7#8#9%
{%
- \ifnum #1<\xint_c_viii\expandafter\XINT_split_fromleft_exita\fi
- \expandafter\XINT_split_fromleft_loop_perhaps
- \the\numexpr #1-\xint_c_viii\expandafter.\XINT_split_fromleft_eight
+ \expandafter\XINT_split_fromleft_clean
+ \the\numexpr1#2#3#4#5#6#7#8#9\expandafter
+ \XINT_split_fromleft_a\the\numexpr\xint_c_viii-#1.%
}%
-\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%
+\def\XINT_split_fromleft_end_a #1.%
{%
- \xint_gob_til_W #2\XINT_split_fromleft_toofar\W
- \XINT_split_fromleft_loop #1.%
+ \expandafter\XINT_split_fromleft_clean
+ \the\numexpr1\csname XINT_split_fromleft_end#1\endcsname
}%
-\def\XINT_split_fromleft_toofar\W\XINT_split_fromleft_loop #1.#2#3\Z
+\def\XINT_split_fromleft_clean 1{ }%
+\expandafter\def\csname XINT_split_fromleft_end7\endcsname #1%
+ {#1\XINT_split_fromleft_end_b}%
+\expandafter\def\csname XINT_split_fromleft_end6\endcsname #1#2%
+ {#1#2\XINT_split_fromleft_end_b}%
+\expandafter\def\csname XINT_split_fromleft_end5\endcsname #1#2#3%
+ {#1#2#3\XINT_split_fromleft_end_b}%
+\expandafter\def\csname XINT_split_fromleft_end4\endcsname #1#2#3#4%
+ {#1#2#3#4\XINT_split_fromleft_end_b}%
+\expandafter\def\csname XINT_split_fromleft_end3\endcsname #1#2#3#4#5%
+ {#1#2#3#4#5\XINT_split_fromleft_end_b}%
+\expandafter\def\csname XINT_split_fromleft_end2\endcsname #1#2#3#4#5#6%
+ {#1#2#3#4#5#6\XINT_split_fromleft_end_b}%
+\expandafter\def\csname XINT_split_fromleft_end1\endcsname #1#2#3#4#5#6#7%
+ {#1#2#3#4#5#6#7\XINT_split_fromleft_end_b}%
+\expandafter\def\csname XINT_split_fromleft_end0\endcsname #1#2#3#4#5#6#7#8%
+ {#1#2#3#4#5#6#7#8\XINT_split_fromleft_end_b}%
+\def\XINT_split_fromleft_end_b #1\xint_bye#2\xint_bye.{.#1}% puis .
+\def\XINT_split_fromright #1.#2\xint_bye
{%
- \XINT_split_fromleft_toofar_b #2\Z
+ \expandafter\XINT_split_fromright_a
+ \the\numexpr#1-\numexpr\xint_c_ix\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ .#2\xint_bye
}%
-\def\XINT_split_fromleft_toofar_b #1\W #2\Z { #1..}%
-\def\XINT_split_fromleft_exita
- \expandafter\XINT_split_fromleft_loop_perhaps
- \the\numexpr #1-\xint_c_viii\expandafter.\XINT_split_fromleft_eight
+\def\XINT_split_fromright_a #1%
{%
- \csname XINT_split_fromleft_endsplit_\romannumeral #1\endcsname
+ \xint_UDsignfork
+ #1\XINT_split_fromleft
+ -\XINT_split_fromright_Lempty
+ \krof
}%
-\def\XINT_split_fromleft_endsplit_ #1#2\W #3\Z { #1.#2.}%
-\def\XINT_split_fromleft_endsplit_i #1#2%
- {\XINT_split_fromleft_checkiftoofar #2{#1#2}}%
-\def\XINT_split_fromleft_endsplit_ii #1#2#3%
- {\XINT_split_fromleft_checkiftoofar #3{#1#2#3}}%
-\def\XINT_split_fromleft_endsplit_iii #1#2#3#4%
- {\XINT_split_fromleft_checkiftoofar #4{#1#2#3#4}}%
-\def\XINT_split_fromleft_endsplit_iv #1#2#3#4#5%
- {\XINT_split_fromleft_checkiftoofar #5{#1#2#3#4#5}}%
-\def\XINT_split_fromleft_endsplit_v #1#2#3#4#5#6%
- {\XINT_split_fromleft_checkiftoofar #6{#1#2#3#4#5#6}}%
-\def\XINT_split_fromleft_endsplit_vi #1#2#3#4#5#6#7%
- {\XINT_split_fromleft_checkiftoofar #7{#1#2#3#4#5#6#7}}%
-\def\XINT_split_fromleft_endsplit_vii #1#2#3#4#5#6#7#8%
- {\XINT_split_fromleft_checkiftoofar #8{#1#2#3#4#5#6#7#8}}%
-\def\XINT_split_fromleft_checkiftoofar #1#2#3\W #4\Z
-{%
- \xint_gob_til_W #1\XINT_split_fromleft_wenttoofar\W \space#2.#3.%
-}%
-\def\XINT_split_fromleft_wenttoofar\W\space #1.%
-{%
- \XINT_split_fromleft_wenttoofar_b #1\Z
-}%
-\def\XINT_split_fromleft_wenttoofar_b #1\W #2\Z { #1.}%
-\def\XINT_split_fromright #1.#2\W\W\W\W\W\W\W\W\Z
-{%
- \expandafter\XINT_split_fromright_loop
- \the\numexpr #1\expandafter.\expandafter{\expandafter}%
- \romannumeral0\xintreverseorder{#2}\W\W\W\W\W\W\W\W\Z #2.%
-}%
-\def\XINT_split_fromright_loop #1.%
-{%
- \ifnum #1<\xint_c_viii\expandafter\XINT_split_fromright_exita\fi
- \expandafter\XINT_split_fromright_loop_perhaps
- \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%
-{%
- \xint_gob_til_W #2\XINT_split_fromright_toofar\W
- \XINT_split_fromright_loop #1.%
-}%
-\def\XINT_split_fromright_toofar\W\XINT_split_fromright_loop #1\Z {.}%
-\def\XINT_split_fromright_exita
- \expandafter\XINT_split_fromright_loop_perhaps
- \the\numexpr #1-\xint_c_viii\expandafter.\XINT_split_fromright_eight
-{%
- \csname XINT_split_fromright_endsplit_\romannumeral #1\endcsname
-}%
-\def\XINT_split_fromright_endsplit_ #1#2\W #3\Z #4.%
-{%
- \xintreverseorder {#2}.#1.%
-}%
-\def\XINT_split_fromright_endsplit_i #1#2%
- {\XINT_split_fromright_checkiftoofar #2{#2#1}}%
-\def\XINT_split_fromright_endsplit_ii #1#2#3%
- {\XINT_split_fromright_checkiftoofar #3{#3#2#1}}%
-\def\XINT_split_fromright_endsplit_iii #1#2#3#4%
- {\XINT_split_fromright_checkiftoofar #4{#4#3#2#1}}%
-\def\XINT_split_fromright_endsplit_iv #1#2#3#4#5%
- {\XINT_split_fromright_checkiftoofar #5{#5#4#3#2#1}}%
-\def\XINT_split_fromright_endsplit_v #1#2#3#4#5#6%
- {\XINT_split_fromright_checkiftoofar #6{#6#5#4#3#2#1}}%
-\def\XINT_split_fromright_endsplit_vi #1#2#3#4#5#6#7%
- {\XINT_split_fromright_checkiftoofar #7{#7#6#5#4#3#2#1}}%
-\def\XINT_split_fromright_endsplit_vii #1#2#3#4#5#6#7#8%
- {\XINT_split_fromright_checkiftoofar #8{#8#7#6#5#4#3#2#1}}%
-\def\XINT_split_fromright_checkiftoofar #1%
-{%
- \xint_gob_til_W #1\XINT_split_fromright_wenttoofar\W
- \XINT_split_fromright_endsplit_
-}%
-\def\XINT_split_fromright_wenttoofar\W
- \XINT_split_fromright_endsplit_ #1\Z {.}%
+\def\XINT_split_fromright_Lempty #1.#2\xint_bye#3..{.#2.}%
% \end{macrocode}
% \subsection{\csh{xintiiSqrt}, \csh{xintiiSqrtR}, \csh{xintiiSquareRoot}}
% \lverb|First done with 1.08.
@@ -21420,6 +21823,8 @@
% 1.2f also modifies \xintFloatSqrt in xintfrac.sty which now has more
% code in common with here and benefits from the same speed improvements.
%
+% Attention to impact here of some 1.2i changes to macros (\xintDSx,
+% \xintDecSplit and their interfaces).
% |
%
% \begin{macrocode}
@@ -21431,16 +21836,17 @@
\def\xintisqrt {\expandafter\XINT_sqrt_post\romannumeral0\xintisquareroot }%
\def\xintiisqrt {\expandafter\XINT_sqrt_post\romannumeral0\xintiisquareroot }%
\def\xintiisqrtr {\expandafter\XINT_sqrtr_post\romannumeral0\xintiisquareroot }%
-\def\XINT_sqrt_post #1#2{\XINT_dec_pos #1\Z }%
+\def\XINT_sqrt_post #1#2{\XINT_dec #1\XINT_dec_bye234567890\xint_bye}%
% \end{macrocode}
% \lverb|N = (#1)^2 - #2 avec #1 le plus petit possible et #2>0 (hence #2<2*#1).
% (#1-.5)^2=#1^2-#1+.25=N+#2-#1+.25. Si 0<#2<#1, <= N-0.75<N, donc rounded->#1
% si #2>=#1, (#1-.5)^2>=N+.25>N, donc rounded->#1-1.|
% \begin{macrocode}
-\def\XINT_sqrtr_post #1#2{\xintiiifLt {#2}{#1}{ #1}{\XINT_dec_pos #1\Z}}%
+\def\XINT_sqrtr_post #1#2{\xintiiifLt {#2}{#1}%
+ { #1}{\XINT_dec #1\XINT_dec_bye234567890\xint_bye}}%
\def\xintisquareroot #1%
- {\expandafter\XINT_sqrt_checkin\romannumeral0\xintnum{#1}\Z }%
-\def\xintiisquareroot #1{\expandafter\XINT_sqrt_checkin\romannumeral`&&@#1\Z }%
+ {\expandafter\XINT_sqrt_checkin\romannumeral0\xintnum{#1}\xint_relax }%
+\def\xintiisquareroot #1{\expandafter\XINT_sqrt_checkin\romannumeral`&&@#1\xint_relax }%
\def\XINT_sqrt_checkin #1%
{%
\xint_UDzerominusfork
@@ -21449,9 +21855,9 @@
0-{\XINT_sqrt #1}%
\krof
}%
-\def\XINT_sqrt_iszero #1\Z { 11}%
-\edef\XINT_sqrt_isneg #1\Z {\noexpand\xintError:RootOfNegative\space 11}%
-\def\XINT_sqrt #1\Z
+\def\XINT_sqrt_iszero #1\xint_relax { 11}%
+\edef\XINT_sqrt_isneg #1\xint_relax {\noexpand\xintError:RootOfNegative\space 11}%
+\def\XINT_sqrt #1\xint_relax
{%
\expandafter\XINT_sqrt_start\romannumeral0\xintlength {#1}.#1.%
}%
@@ -21639,13 +22045,13 @@
}%
\def\XINT_sqrt_big_gi #1.%
{%
- \expandafter\XINT_sqrt_big_gj
- \romannumeral0\XINT_dsx_addzerosnofuss{#1}{}.#1.%
+ \expandafter\XINT_sqrt_big_gj\romannumeral\xintreplicate{#1}0.#1.%
}%
\def\XINT_sqrt_big_gj #1.#2.#3.#4.#5.%
{%
\expandafter\XINT_sqrt_big_gk
- \romannumeral0\xintiidivision {#4#1}{\XINT_dbl_pos #5\Z}.%
+ \romannumeral0\xintiidivision {#4#1}%
+ {\XINT_dbl #5\xint_bye2345678\xint_bye*\xint_c_ii\relax}.%
#1.#5.#2.#3.%
}%
\def\XINT_sqrt_big_gk #1#2.#3.#4.%
@@ -21661,8 +22067,7 @@
\def\XINT_sqrt_big_gm #1.#2.#3.#4.#5.%
{%
\expandafter\XINT_sqrt_big_gn
- \romannumeral0\expandafter\XINT_split_fromleft_loop
- \the\numexpr\xint_c_ii*#3.{}#5\W\W\W\W\W\W\W\W\Z
+ \romannumeral0\XINT_split_fromleft\xint_c_ii*#3.#5\xint_bye2345678\xint_bye..%
#1.#2.#3.#4.%
}%
\def\XINT_sqrt_big_gn #1.#2.#3.#4.#5.#6.%
@@ -21675,9 +22080,9 @@
\def\XINT_sqrt_big_ka #1.#2.#3.#4.%
{%
\expandafter\XINT_sqrt_big_kb
- \romannumeral0\XINT_dsx_addzerosnofuss {#1}{#3}.%
+ \romannumeral0\XINT_dsx_addzeros {#1}#3;.%
\romannumeral0\xintiisub
- {\XINT_dsx_addzerosnofuss {\numexpr\xint_c_ii*#1}{#2}}%
+ {\XINT_dsx_addzerosnofuss {\xint_c_ii*#1}#2;}%
{\xintiNum{#4}}.%
}%
\def\XINT_sqrt_big_kb #1.#2.%
@@ -21692,7 +22097,8 @@
\def\XINT_sqrt_big_kz 0.#1.%
{%
\expandafter\XINT_sqrt_big_kend
- \romannumeral0\xintinc{\XINT_dbl_pos #1\Z}.#1.%
+ \romannumeral0%
+ \xintinc{\XINT_dbl#1\xint_bye2345678\xint_bye*\xint_c_ii\relax}.#1.%
}%
\def\XINT_sqrt_big_kend #1.#2.%
{%
@@ -21701,7 +22107,8 @@
\def\XINT_sqrt_big_kloop #1.#2.%
{%
\expandafter\XINT_sqrt_big_ke
- \romannumeral0\xintiidivision{#1}{\romannumeral0\XINT_dbl_pos #2\Z}{#2}%
+ \romannumeral0\xintiidivision{#1}%
+ {\romannumeral0\XINT_dbl #2\xint_bye2345678\xint_bye*\xint_c_ii\relax}{#2}%
}%
\def\XINT_sqrt_big_ke #1%
{%
@@ -22205,13 +22612,23 @@
}%
% \end{macrocode}
% \subsection{\csh{xintiiE}}
-% \lverb|Originally was used in \xintiiexpr. Transferred from xintfrac for 1.1.|
+% \lverb|Originally was used in \xintiiexpr. Transferred from xintfrac for
+% 1.1.
+% Code rewritten for 1.2i.|
% \begin{macrocode}
\def\xintiiE {\romannumeral0\xintiie }% used in \xintMod.
\def\xintiie #1#2%
- {\expandafter\XINT_iie\the\numexpr #2\expandafter.\expandafter{\romannumeral`&&@#1}}%
-\def\XINT_iie #1.#2{\ifnum#1>\xint_c_ \xint_dothis{\xint_dsh {#2}{-#1}}\fi
- \xint_orthat{ #2}}%
+ {\expandafter\XINT_iie_fork\the\numexpr #2\expandafter.\romannumeral`&&@#1;}%
+\def\XINT_iie_fork #1%
+{%
+ \xint_UDsignfork
+ #1\XINT_iie_neg
+ -\XINT_iie_a
+ \krof #1%
+}%
+\def\XINT_iie_a #1.%
+ {\expandafter\XINT_dsx_append\romannumeral\XINT_rep #1\endcsname 0.}%
+\def\XINT_iie_neg #1.#2;{ #2}%
% \end{macrocode}
% \subsection{``Load \xintfracnameimp'' macros}
% \lverb|Originally was used in \xintiiexpr. Transferred from xintfrac for 1.1.|
@@ -22300,7 +22717,7 @@
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintbinhex}%
- [2016/11/20 1.2h Expandable binary and hexadecimal conversions (JFB)]%
+ [2016/12/13 1.2i Expandable binary and hexadecimal conversions (JFB)]%
% \end{macrocode}
% \subsection{Constants, etc...}
% \lverb!1.08!
@@ -23000,7 +23417,7 @@
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintgcd}%
- [2016/11/20 1.2h Euclide algorithm with xint package (JFB)]%
+ [2016/12/13 1.2i Euclide algorithm with xint package (JFB)]%
% \end{macrocode}
% \subsection{\csh{xintGCD}, \csh{xintiiGCD}}
% \begin{macrocode}
@@ -23687,7 +24104,7 @@
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintfrac}%
- [2016/11/20 1.2h Expandable operations on fractions (JFB)]%
+ [2016/12/13 1.2i Expandable operations on fractions (JFB)]%
% \end{macrocode}
% \subsection{\csh{XINT_cntSgnFork}}
% \lverb|1.09i. Used internally, #1 must expand to \m at ne, \z@, or \@ne or
@@ -23703,7 +24120,7 @@
% \end{macrocode}
% \subsection{\csh{xintLen}}
% \lverb|The used formula is disputable, the idea is that A/1 and A should have
-% same length.|
+% same length. Venerable code rewritten for 1.2i. |
% \begin{macrocode}
\def\xintLen {\romannumeral0\xintlen }%
\def\xintlen #1%
@@ -23713,43 +24130,15 @@
\def\XINT_flen #1#2#3%
{%
\expandafter\space
- \the\numexpr -1+\XINT_Abs {#1}+\XINT_Len {#2}+\XINT_Len {#3}\relax
+ \the\numexpr \XINT_abs#1+\xint_c_viii
+ \XINT_length_loop
+ #2#3\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ \relax
}%
% \end{macrocode}
-% \subsection{\csh{XINT_lenrord_loop}}
-% \lverb|& attention que & est comment dans mes \lverb
-% Faire \romannumeral`$&$&@\XINT_lenrord_loop 0.{}foobar\Z\W\W\W\W\W\W\W\Z, et
-% en sortie on aura : longueur.raboof\Z. C'est une vieille routine, employée
-% uniquement par \xintFloat et \XINTinFloat, et uniquement pour des chiffres.
-% Donc j'ai plus rapide maintenant mais elle n'est utilisée que pour des
-% choses assez courtes, alors à voir.|
-% \begin{macrocode}
-\def\XINT_lenrord_loop #1.#2#3#4#5#6#7#8#9%
-{%
- \xint_gob_til_W #9\XINT_lenrord_W\W
- \expandafter\XINT_lenrord_loop\the\numexpr #1+\xint_c_vii.{#9#8#7#6#5#4#3#2}%
-}%
-\def\XINT_lenrord_W\W\expandafter\XINT_lenrord_loop #1.#2#3\Z
-{%
- \expandafter\XINT_lenrord_X #1.#2\Z
-}%
-\def\XINT_lenrord_X #1.#2\Z
-{%
- \XINT_lenrord_Y #2\R\R\R\R\R\R\T {#1}%
-}%
-\def\XINT_lenrord_Y #1#2#3#4#5#6#7#8\T
-{%
- \xint_gob_til_W
- #7\XINT_lenrord_Z \xint_c_viii
- #6\XINT_lenrord_Z \xint_c_vii
- #5\XINT_lenrord_Z \xint_c_vi
- #4\XINT_lenrord_Z \xint_c_v
- #3\XINT_lenrord_Z \xint_c_iv
- #2\XINT_lenrord_Z \xint_c_iii
- \W\XINT_lenrord_Z \xint_c_ii \Z
-}%
-\def\XINT_lenrord_Z #1#2\Z #3{\the\numexpr #3-#1.}%
-% \end{macrocode}
% \subsection{\csh{XINT_outfrac}}
% \lverb|&
% Months later (2014/10/22): perhaps I should document what this macro does
@@ -23789,7 +24178,11 @@
}%
% \end{macrocode}
% \subsection{\csh{XINT_inFrac}}
-% \lverb|Extended in 1.07 to accept scientific notation on input. With lowercase
+% \lverb|&
+% Parses fraction, scientific notation, etc... and produces {n}{A}{B}
+% corresponding to A/B times 10^n. No reduction to smallest terms.
+%
+% Extended in 1.07 to accept scientific notation on input. With lowercase
% e only. The \xintexpr parser does accept uppercase E also. Ah, by the way,
% perhaps I should at least say what this macro does? (belated addition
% 2014/10/22...), before I forget! It prepares the fraction in the internal
@@ -23928,20 +24321,15 @@
{%
\expandafter\XINT_frac_gen_Bd\romannumeral`&&@#2.#1e%
}%
-% \end{macrocode}
-% \lverb|Here in \XINT_frac_gen_Bd, the 1.2 rewrite of \XINT_infrac did
-% \the\numexpr0#3-, but if #3 is a \count for example this was bad (although
-% such inputs never have been explicitely allowed in the doc). And why this 0?
-% to handle empty #3? But empty #3 was fine here. Another bug of 1.2 ! Fixed
-% in 1.2f. Same in \XINT_frac_gen_Bb above, with the difference however that
-% an empty #2 there indeed had to be handled properly.|
-% \begin{macrocode}
\def\XINT_frac_gen_Bd #1.#2e#3e#4\XINT_Z
{%
- \expandafter\XINT_frac_gen_C\the\numexpr #3-\romannumeral0\expandafter
- \XINT_length_loop
- 0.#1\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye~#2#1!%
+ \expandafter\XINT_frac_gen_C\the\numexpr #3-%
+ \numexpr\xint_c_ix\XINT_length_loop
+ #1\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ ~#2#1!%
}%
\def\XINT_frac_gen_C #1!#2.#3%
{%
@@ -23965,10 +24353,12 @@
\def\XINT_frac_gen_Cc #1.#2~#3!#4e#5e#6\XINT_T
{%
\expandafter\XINT_frac_gen_F\the\numexpr #5-#2-%
- \romannumeral0\XINT_length_loop
- 0.#1\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye\expandafter
- ~\romannumeral0\XINT_num_loop
+ \numexpr\xint_c_ix\XINT_length_loop
+ #1\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ \relax\expandafter~\romannumeral0\XINT_num_loop
#3\xint_relax\xint_relax\xint_relax\xint_relax
\xint_relax\xint_relax\xint_relax\xint_relax\Z
~#4#1~%
@@ -24103,101 +24493,6 @@
\xint_relax }{#1}%
}%
% \end{macrocode}
-% \subsection{\csh{XINT_addm_A}}
-% \lverb|This is a routine from xintcore 1.0x, which is now only needed by
-% \xintFloat, \XINTinFloat and \xintRound, for the time being.|
-% \begin{macrocode}
-\def\XINT_addm_A #1#2#3#4#5#6%
-{%
- \xint_gob_til_W #3\XINT_addm_az\W
- \XINT_addm_AB #1{#3#4#5#6}{#2}%
-}%
-\def\XINT_addm_az\W\XINT_addm_AB #1#2%
-{%
- \XINT_addm_AC_checkcarry #1%
-}%
-\def\XINT_addm_AB #1#2#3#4\W\X\Y\Z #5#6#7#8%
-{%
- \XINT_addm_ABE #1#2{#8#7#6#5}{#3}#4\W\X\Y\Z
-}%
-\def\XINT_addm_ABE #1#2#3#4#5#6%
-{%
- \expandafter\XINT_addm_ABEA\the\numexpr #1+10#5#4#3#2+#6.%
-}%
-\def\XINT_addm_ABEA #1#2#3.#4%
-{%
- \XINT_addm_A #2{#3#4}%
-}%
-\def\XINT_addm_AC_checkcarry #1%
-{%
- \xint_gob_til_zero #1\XINT_addm_AC_nocarry 0\XINT_addm_C
-}%
-\def\XINT_addm_AC_nocarry 0\XINT_addm_C #1#2\W\X\Y\Z
-{%
- \expandafter
- \xint_cleanupzeros_andstop
- \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_addm_C #1#2#3#4#5%
-{%
- \xint_gob_til_W
- #5\XINT_addm_cw
- #4\XINT_addm_cx
- #3\XINT_addm_cy
- #2\XINT_addm_cz
- \W\XINT_addm_CD {#5#4#3#2}{#1}%
-}%
-\def\XINT_addm_CD #1%
-{%
- \expandafter\XINT_addm_CC\the\numexpr 1+10#1.%
-}%
-\def\XINT_addm_CC #1#2#3.#4%
-{%
- \XINT_addm_AC_checkcarry #2{#3#4}%
-}%
-\def\XINT_addm_cw
- #1\XINT_addm_cx
- #2\XINT_addm_cy
- #3\XINT_addm_cz
- \W\XINT_addm_CD
-{%
- \expandafter\XINT_addm_CDw\the\numexpr 1+#1#2#3.%
-}%
-\def\XINT_addm_CDw #1.#2#3\X\Y\Z
-{%
- \XINT_addm_end #1#3%
-}%
-\def\XINT_addm_cx
- #1\XINT_addm_cy
- #2\XINT_addm_cz
- \W\XINT_addm_CD
-{%
- \expandafter\XINT_addm_CDx\the\numexpr 1+#1#2.%
-}%
-\def\XINT_addm_CDx #1.#2#3\Y\Z
-{%
- \XINT_addm_end #1#3%
-}%
-\def\XINT_addm_cy
- #1\XINT_addm_cz
- \W\XINT_addm_CD
-{%
- \expandafter\XINT_addm_CDy\the\numexpr 1+#1.%
-}%
-\def\XINT_addm_CDy #1.#2#3\Z
-{%
- \XINT_addm_end #1#3%
-}%
-\def\XINT_addm_cz\W\XINT_addm_CD #1#2#3{\XINT_addm_end #1#3}%
-\edef\XINT_addm_end #1#2#3#4#5%
- {\noexpand\expandafter\space\noexpand\the\numexpr #1#2#3#4#5\relax}%
-% \end{macrocode}
% \subsection{\csh{xintRaw}}
% \lverb|&
% 1.07: this macro simply prints in a user readable form the fraction after its
@@ -24243,22 +24538,20 @@
\def\xintRawWithZeros {\romannumeral0\xintrawwithzeros }%
\def\xintrawwithzeros
{%
- \expandafter\XINT_rawz\romannumeral0\XINT_infrac
+ \expandafter\XINT_rawz_fork\romannumeral0\XINT_infrac
}%
-\def\XINT_rawz #1%
+\def\XINT_rawz_fork #1%
{%
- \ifcase\XINT_cntSgn #1\Z
+ \ifnum#1<\xint_c_
\expandafter\XINT_rawz_Ba
- \or
+ \else
\expandafter\XINT_rawz_A
- \else
- \expandafter\XINT_rawz_Ba
\fi
- {#1}%
+ #1.%
}%
-\def\XINT_rawz_A #1#2#3{\xint_dsh {#2}{-#1}/#3}%
-\def\XINT_rawz_Ba #1#2#3{\expandafter\XINT_rawz_Bb
- \expandafter{\romannumeral0\xint_dsh {#3}{#1}}{#2}}%
+\def\XINT_rawz_A #1.#2#3{\XINT_dsx_addzeros{#1}#2;/#3}%
+\def\XINT_rawz_Ba -#1.#2#3{\expandafter\XINT_rawz_Bb
+ \expandafter{\romannumeral0\XINT_dsx_addzeros{#1}#3;}{#2}}%
\def\XINT_rawz_Bb #1#2{ #2/#1}%
% \end{macrocode}
% \subsection{\csh{xintFloor}, \csh{xintiFloor}}
@@ -24299,7 +24592,7 @@
\fi
{#1}%
}%
-\def\XINT_numer_A #1#2#3{\xint_dsh {#2}{-#1}}%
+\def\XINT_numer_A #1#2#3{\XINT_dsx_addzeros{#1}#2;}%
\def\XINT_numer_B #1#2#3{ #2}%
% \end{macrocode}
% \subsection{\csh{xintDenominator}}
@@ -24307,21 +24600,19 @@
\def\xintDenominator {\romannumeral0\xintdenominator }%
\def\xintdenominator
{%
- \expandafter\XINT_denom\romannumeral0\XINT_infrac
+ \expandafter\XINT_denom_fork\romannumeral0\XINT_infrac
}%
-\def\XINT_denom #1%
+\def\XINT_denom_fork #1%
{%
- \ifcase\XINT_cntSgn #1\Z
+ \ifnum#1<\xint_c_
\expandafter\XINT_denom_B
- \or
+ \else
\expandafter\XINT_denom_A
- \else
- \expandafter\XINT_denom_B
\fi
- {#1}%
+ #1.%
}%
-\def\XINT_denom_A #1#2#3{ #3}%
-\def\XINT_denom_B #1#2#3{\xint_dsh {#3}{#1}}%
+\def\XINT_denom_A #1.#2#3{ #3}%
+\def\XINT_denom_B -#1.#2#3{\XINT_dsx_addzeros{#1}#3;}%
% \end{macrocode}
% \subsection{\csh{xintFrac}}
% \lverb|Useless typesetting macro.|
@@ -24650,84 +24941,119 @@
\romannumeral0\xintiirem{#1}{#2}\Z {0}{#2}}%
% \end{macrocode}
% \subsection{\csh{xintTrunc}, \csh{xintiTrunc}}
+% \lverb|&
+% 1.2i release notes: ever since its inception this macro was stupid for a
+% decimal input: it did not handle it separately from the general fraction
+% case A/B[N] with B>1, hence ended up doing divisions by powers of ten. But
+% this meant that nesting \xintTrunc with itself was very inefficient.
+%
+% 1.2i version is better. However it still handles B>1, N<0 via adding zeros
+% to B and dividing with this extended B. A possibly more efficient approach
+% is implemented in \xintXTrunc, but its logic is more complicated, the code
+% is quite longer and making it f-expandable would not shorten it... I decided
+% for the time being to not complicate things here.
+% |
% \begin{macrocode}
\def\xintTrunc {\romannumeral0\xinttrunc }%
-\def\xintiTrunc {\romannumeral0\xintitrunc }%
-\def\xinttrunc #1%
+\def\xintiTrunc {\romannumeral0\xintitrunc}%
+\def\xinttrunc #1{\expandafter\XINT_trunc\the\numexpr#1.\XINT_trunc_G}%
+\def\xintitrunc #1{\expandafter\XINT_trunc\the\numexpr#1.\XINT_itrunc_G}%
+\def\XINT_trunc #1.#2#3%
{%
- \expandafter\XINT_trunc\expandafter {\the\numexpr #1}%
+ \expandafter\XINT_trunc_a\romannumeral0\XINT_infrac{#3}#1.#2%
}%
-\def\XINT_trunc #1#2%
+\def\XINT_trunc_a #1#2#3#4.#5%
{%
- \expandafter\XINT_trunc_G
- \romannumeral0\expandafter\XINT_trunc_A
- \romannumeral0\XINT_infrac {#2}{#1}{#1}%
+ \if0\XINT_Sgn#2\Z\xint_dothis\XINT_trunc_zero\fi
+ \if1\XINT_iSone#3XY\xint_dothis\XINT_trunc_sp_b\fi
+ \xint_orthat\XINT_trunc_b #1+#4.{#2}{#3}#5#4.%
}%
-\def\xintitrunc #1%
+\def\XINT_trunc_zero #1.#2.{ 0}%
+\def\XINT_trunc_b {\expandafter\XINT_trunc_B\the\numexpr}%
+\def\XINT_trunc_sp_b {\expandafter\XINT_trunc_sp_B\the\numexpr}%
+\def\XINT_trunc_B #1%
{%
- \expandafter\XINT_itrunc\expandafter {\the\numexpr #1}%
+ \xint_UDsignfork
+ #1\XINT_trunc_C
+ -\XINT_trunc_D
+ \krof #1%
}%
-\def\XINT_itrunc #1#2%
+\def\XINT_trunc_sp_B #1%
{%
- \expandafter\XINT_itrunc_G
- \romannumeral0\expandafter\XINT_trunc_A
- \romannumeral0\XINT_infrac {#2}{#1}{#1}%
+ \xint_UDsignfork
+ #1\XINT_trunc_sp_C
+ -\XINT_trunc_sp_D
+ \krof #1%
}%
-\def\XINT_trunc_A #1#2#3#4%
+\def\XINT_trunc_C -#1.#2#3%
{%
- \expandafter\XINT_trunc_checkifzero
- \expandafter{\the\numexpr #1+#4}#2\Z {#3}%
+ \expandafter\XINT_trunc_CE
+ \romannumeral0\XINT_dsx_addzeros{#1}#3;.{#2}%
}%
-\def\XINT_trunc_checkifzero #1#2#3\Z
+\def\XINT_trunc_CE #1.#2{\XINT_trunc_E #2.{#1}}%
+\def\XINT_trunc_sp_C -#1.#2#3{\XINT_trunc_sp_Ca #2.#1.}%
+\def\XINT_trunc_sp_Ca #1%
{%
- \xint_gob_til_zero #2\XINT_trunc_iszero0\XINT_trunc_B {#1}{#2#3}%
+ \xint_UDsignfork
+ #1{\XINT_trunc_sp_Cb -}%
+ -{\XINT_trunc_sp_Cb \space#1}%
+ \krof
}%
-\def\XINT_trunc_iszero0\XINT_trunc_B #1#2#3{ 0\Z 0}%
-\def\XINT_trunc_B #1%
+\def\XINT_trunc_sp_Cb #1#2.#3.%
{%
- \ifcase\XINT_cntSgn #1\Z
- \expandafter\XINT_trunc_D
- \or
- \expandafter\XINT_trunc_D
- \else
- \expandafter\XINT_trunc_C
- \fi
- {#1}%
+ \expandafter\XINT_trunc_sp_Cc
+ \romannumeral0\expandafter\XINT_split_fromright_a
+ \the\numexpr#3-\numexpr\xint_c_ix\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ .#2\xint_bye2345678\xint_bye..#1%
}%
-\def\XINT_trunc_C #1#2#3%
+\def\XINT_trunc_sp_Cc #1%
{%
- \expandafter\XINT_trunc_CE\expandafter
- {\romannumeral0\XINT_dsx_zeroloop -#1.{}\Z {#3}}{#2}%
+ \if.#1\xint_dothis{\XINT_trunc_sp_Cd 0.}\fi
+ \xint_orthat {\XINT_trunc_sp_Cd #1}%
}%
-\def\XINT_trunc_CE #1#2{\XINT_trunc_E #2.{#1}}%
-\def\XINT_trunc_D #1#2%
+\def\XINT_trunc_sp_Cd #1.#2.#3%
{%
+ \XINT_trunc_sp_F #3#1.%
+}%
+\def\XINT_trunc_D #1.#2%
+{%
\expandafter\XINT_trunc_E
- \romannumeral0\XINT_dsx_zeroloop #1.{}\Z {#2}.%
+ \romannumeral0\XINT_dsx_addzeros {#1}#2;.%
}%
+\def\XINT_trunc_sp_D #1.#2#3%
+{%
+ \expandafter\XINT_trunc_sp_E
+ \romannumeral0\XINT_dsx_addzeros {#1}#2;.%
+}%
\def\XINT_trunc_E #1%
{%
\xint_UDsignfork
- #1\XINT_trunc_Fneg
- -{\XINT_trunc_Fpos #1}%
+ #1{\XINT_trunc_F -}%
+ -{\XINT_trunc_F \space#1}%
\krof
}%
-\def\XINT_trunc_Fneg #1.#2{\expandafter\xint_firstoftwo_thenstop
- \romannumeral0\XINT_div_prepare {#2}{#1}\Z -}%
-\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%
+\def\XINT_trunc_sp_E #1%
{%
- \xint_gob_til_zero #1\XINT_trunc_zero 0#3#1#2%
+ \xint_UDsignfork
+ #1{\XINT_trunc_sp_F -}%
+ -{\XINT_trunc_sp_F\space#1}%
+ \krof
}%
-\def\XINT_trunc_zero 0#1#20{ 0}%
-\def\XINT_trunc_G #1\Z #2#3%
+\def\XINT_trunc_F #1#2.#3#4%
+ {\expandafter#4\romannumeral`&&@\expandafter\xint_firstoftwo
+ \romannumeral0\XINT_div_prepare {#3}{#2}.#1}%
+\def\XINT_trunc_sp_F #1#2.#3{#3#2.#1}%
+\def\XINT_itrunc_G #1#2.#3#4.{\if#10\xint_dothis{ 0}\fi\xint_orthat{#3#1}#2}%
+\def\XINT_trunc_G #1.#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%
+ \expandafter\XINT_trunc_H
+ \the\numexpr\romannumeral0\xintlength {#1}-#3.#3.{#1}#2%
}%
-\def\XINT_trunc_H #1#2%
+\def\XINT_trunc_H #1.#2.%
{%
\ifnum #1 > \xint_c_
\xint_afterfi {\XINT_trunc_Ha {#2}}%
@@ -24735,33 +25061,21 @@
\xint_afterfi {\XINT_trunc_Hb {-#1}}% -0,--1,--2, ....
\fi
}%
-\def\XINT_trunc_Ha
-{%
- \expandafter\XINT_trunc_Haa\romannumeral0\xintdecsplit
-}%
-\def\XINT_trunc_Haa #1#2#3%
-{%
- #3#1.#2%
-}%
+\def\XINT_trunc_Ha{\expandafter\XINT_trunc_Haa\romannumeral0\xintdecsplit}%
+\def\XINT_trunc_Haa #1#2#3{#3#1.#2}%
\def\XINT_trunc_Hb #1#2#3%
{%
\expandafter #3\expandafter0\expandafter.%
- \romannumeral0\XINT_dsx_zeroloop #1.{}\Z {}#2% #1=-0 autoris\'e !
+ \romannumeral\xintreplicate{#1}0#2%
}%
% \end{macrocode}
% \subsection{\csh{xintTTrunc}}
-% \lverb|1.1, a tiny bit more efficient than doing \xintiTrunc0. I map \xintNum
-% to it, and I use it in \xintexpr for various things. Faster I guess than the
-% \xintiFloor.|
+% \lverb|1.1. Modified in 1.2i, it does simply \xintiTrunc0 with no
+% shortcut (the latter having been modified)
+%|
% \begin{macrocode}
\def\xintTTrunc {\romannumeral0\xintttrunc }%
-\def\xintttrunc #1%
-{%
- \expandafter\XINT_itrunc_G
- \romannumeral0\expandafter\XINT_ttrunc_A
- \romannumeral0\XINT_infrac {#1}0% this last 0 to let \XINT_itrunc_G be happy
-}%
-\def\XINT_ttrunc_A #1#2#3{\XINT_trunc_checkifzero {#1}#2\Z {#3}}%
+\def\xintttrunc {\xintitrunc\xint_c_}%
% \end{macrocode}
% \subsection{\csh{xintNum}}
% \begin{macrocode}
@@ -24769,364 +25083,324 @@
\let\xintnum \xintttrunc
% \end{macrocode}
% \subsection{\csh{xintRound}, \csh{xintiRound}}
+% \lverb|Modified in 1.2i.
+%
+% It benefits first of all from the faster \xintTrunc, particularly when the
+% input is already a decimal number (denominator B=1).
+%
+% And the rounding is now done in 1.2 style (with much delay, sorry), like of
+% the rewritten \xintInc and \xintDec.|
% \begin{macrocode}
-\def\xintRound {\romannumeral0\xintround }%
+\def\xintRound {\romannumeral0\xintround }%
\def\xintiRound {\romannumeral0\xintiround }%
-\def\xintround #1%
+\def\xintround #1{\expandafter\XINT_round\the\numexpr #1.\XINT_round_A}%
+\def\xintiround #1{\expandafter\XINT_round\the\numexpr #1.\XINT_iround_A}%
+\def\XINT_round #1.{\expandafter\XINT_round_aa\the\numexpr #1+\xint_c_i.#1.}%
+\def\XINT_round_aa #1.#2.#3#4%
{%
- \expandafter\XINT_round\expandafter {\the\numexpr #1}%
+ \expandafter\XINT_round_a\romannumeral0\XINT_infrac{#4}#1.#3#2.%
}%
-\def\XINT_round
+\def\XINT_round_a #1#2#3#4.%
{%
- \expandafter\XINT_trunc_G\romannumeral0\XINT_round_A
+ \if0\XINT_Sgn#2\Z\xint_dothis\XINT_trunc_zero\fi
+ \if1\XINT_iSone#3XY\xint_dothis\XINT_trunc_sp_b\fi
+ \xint_orthat\XINT_trunc_b #1+#4.{#2}{#3}%
}%
-\def\xintiround #1%
+\def\XINT_round_A{\expandafter\XINT_trunc_G\romannumeral0\XINT_round_B}%
+\def\XINT_iround_A{\expandafter\XINT_itrunc_G\romannumeral0\XINT_round_B}%
+\def\XINT_round_B #1.%
+ {\XINT_dsrr #1\xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax.}%
+% \end{macrocode}
+% \subsection{\csh{xintXTrunc}}
+% \lverb at 1.09j [2014/01/06] This is completely expandable but not f-expandable.
+% Rewritten for 1.2i (2016/12/04):
+%
+% - no more use of \xintiloop from xinttools.sty
+% (replaced by \xintreplicate... from xintkernel.sty),
+%
+% - no more use in 0>N>-D case of a dummy control sequence name via
+% \csname...\endcsname
+%
+% - handles better the case of an input already a decimal number
+%
+% Need to transfer code comments into public dtx.
+% @
+% \begin{macrocode}
+\def\xintXTrunc #1%#2%
{%
- \expandafter\XINT_iround\expandafter {\the\numexpr #1}%
+ \expandafter\XINT_xtrunc_a
+ \the\numexpr #1\expandafter.\romannumeral0\xintraw
}%
-\def\XINT_iround
+\def\XINT_xtrunc_a #1.% ?? faire autre chose
{%
- \expandafter\XINT_itrunc_G\romannumeral0\XINT_round_A
+ \expandafter\XINT_xtrunc_b\the\numexpr\ifnum#1<\xint_c_i \xint_c_i-\fi #1.%
}%
-\def\XINT_round_A #1#2%
+\def\XINT_xtrunc_b #1.#2{\XINT_xtrunc_c #2{#1}}%
+\def\XINT_xtrunc_c #1%
{%
- \expandafter\XINT_round_B
- \romannumeral0\expandafter\XINT_trunc_A
- \romannumeral0\XINT_infrac {#2}{#1+\xint_c_i}{#1}%
-}%
-\def\XINT_round_B #1\Z
+ \xint_UDzerominusfork
+ #1-\XINT_xtrunc_zero
+ 0#1{-\XINT_xtrunc_d {}}%
+ 0-{\XINT_xtrunc_d #1}%
+ \krof
+}%[
+\def\XINT_xtrunc_zero #1#2]{0.\romannumeral\xintreplicate{#1}0}%
+\def\XINT_xtrunc_d #1#2#3/#4[#5]%
{%
- \expandafter\XINT_round_C
- \romannumeral0\XINT_rord_main {}#1%
- \xint_relax
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_relax
- \Z
+ \XINT_xtrunc_prepare_a#4\R\R\R\R\R\R\R\R {10}0000001\W !{#4};{#5}{#2}{#1#3}%
}%
-\def\XINT_round_C #1%
+\def\XINT_xtrunc_prepare_a #1#2#3#4#5#6#7#8#9%
{%
- \ifnum #1<\xint_c_v
- \expandafter\XINT_round_Daa
- \else
- \expandafter\XINT_round_Dba
- \fi
+ \xint_gob_til_R #9\XINT_xtrunc_prepare_small\R
+ \XINT_xtrunc_prepare_b #9%
}%
-\def\XINT_round_Daa #1%
+\def\XINT_xtrunc_prepare_small\R #1!#2;%
{%
- \xint_gob_til_Z #1\XINT_round_Daz\Z \XINT_round_Da #1%
+ \ifcase #2
+ \or\expandafter\XINT_xtrunc_BisOne
+ \or\expandafter\XINT_xtrunc_BisTwo
+ \or
+ \or\expandafter\XINT_xtrunc_BisFour
+ \or\expandafter\XINT_xtrunc_BisFive
+ \or
+ \or
+ \or\expandafter\XINT_xtrunc_BisEight
+ \fi\XINT_xtrunc_BisSmall {#2}%
}%
-\def\XINT_round_Daz\Z \XINT_round_Da \Z { 0\Z }%
-\def\XINT_round_Da #1\Z
+\def\XINT_xtrunc_BisOne\XINT_xtrunc_BisSmall #1#2#3#4%
+ {\XINT_xtrunc_sp_e {#2}{#4}{#3}}%
+\def\XINT_xtrunc_BisTwo\XINT_xtrunc_BisSmall #1#2#3#4%
{%
- \XINT_rord_main {}#1%
- \xint_relax
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_relax \Z
+ \expandafter\XINT_xtrunc_sp_e\expandafter
+ {\the\numexpr #2-\xint_c_i\expandafter}\expandafter
+ {\romannumeral0\xintiimul 5{#4}}{#3}%
}%
-\def\XINT_round_Dba #1%
+\def\XINT_xtrunc_BisFour\XINT_xtrunc_BisSmall #1#2#3#4%
{%
- \xint_gob_til_Z #1\XINT_round_Dbz\Z \XINT_round_Db #1%
+ \expandafter\XINT_xtrunc_sp_e\expandafter
+ {\the\numexpr #2-\xint_c_ii\expandafter}\expandafter
+ {\romannumeral0\xintiimul {25}{#4}}{#3}%
}%
-\def\XINT_round_Dbz\Z \XINT_round_Db \Z { 1\Z }%
-\def\XINT_round_Db #1\Z
+\def\XINT_xtrunc_BisFive\XINT_xtrunc_BisSmall #1#2#3#4%
{%
- \XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z \Z
+ \expandafter\XINT_xtrunc_sp_e\expandafter
+ {\the\numexpr #2-\xint_c_i\expandafter}\expandafter
+ {\romannumeral0\xintdouble {#4}}{#3}%
}%
-% \end{macrocode}
-% \subsection{\csh{xintXTrunc}}
-% \lverb at 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 things
-% and I even do an \xintnum to ensure a 0 if something comes out empty from
-% \xintDecSplit).
-%
-% [2015/10/04] Although the explanations above are extremely clear, there are
-% just too complicated for me to be now able to understand them fully. I
-% miraculously managed to do the minimal changes (all happens between
-% \XINT_xtrunc_Q and \XINT_xtrunc_Pa) in order for \xintXTrunc to use the 1.2
-% division routine. Seems to work. But some thought should be given to how to
-% adapt \xintXTrunc for it to better use the abilities and characteristics of
-% the new division routines in xincore.@
-% \begin{macrocode}
-\def\xintXTrunc #1#2%
+\def\XINT_xtrunc_BisEight\XINT_xtrunc_BisSmall #1#2#3#4%
{%
- \expandafter\XINT_xtrunc_a\expandafter
- {\the\numexpr #1\expandafter}\romannumeral0\xintraw {#2}%
+ \expandafter\XINT_xtrunc_sp_e\expandafter
+ {\the\numexpr #2-\xint_c_iii\expandafter}\expandafter
+ {\romannumeral0\xintiimul {125}{#4}}{#3}%
}%
-\def\XINT_xtrunc_a #1%
+\def\XINT_xtrunc_BisSmall #1%
{%
- \expandafter\XINT_xtrunc_b\expandafter
- {\the\numexpr\ifnum#1<\xint_c_i \xint_c_i-\fi #1}%
+ \expandafter\XINT_xtrunc_e\expandafter
+ {\expandafter\XINT_xtrunc_small_a
+ \the\numexpr #1/\xint_c_ii\expandafter.\the\numexpr \xint_c_x^viii+#1!}%
}%
-\def\XINT_xtrunc_b #1%
+\def\XINT_xtrunc_small_a #1.#2!#3%
{%
- \expandafter\XINT_xtrunc_c\expandafter
- {\the\numexpr (#1+\xint_c_ii^v)/\xint_c_ii^vi-\xint_c_i}{#1}%
+ \expandafter\XINT_div_small_b\the\numexpr #1\expandafter
+ .\the\numexpr #2\expandafter!%
+ \romannumeral0\XINT_div_small_ba #3\R\R\R\R\R\R\R\R{10}0000001\W
+ #3\XINT_sepbyviii_Z_end 2345678\relax
}%
-\def\XINT_xtrunc_c #1#2%
+\def\XINT_xtrunc_prepare_b
+ {\expandafter\XINT_xtrunc_prepare_c\romannumeral0\XINT_zeroes_forviii }%
+\def\XINT_xtrunc_prepare_c #1!%
{%
- \expandafter\XINT_xtrunc_d\expandafter
- {\the\numexpr #2-\xint_c_ii^vi*#1}{#1}{#2}%
+ \XINT_xtrunc_prepare_d #1.00000000!{#1}%
}%
-\def\XINT_xtrunc_d #1#2#3#4/#5[#6]%
+\def\XINT_xtrunc_prepare_d #1#2#3#4#5#6#7#8#9%
{%
- \XINT_xtrunc_e #4.{#6}{#5}{#3}{#2}{#1}%
+ \expandafter\XINT_xtrunc_prepare_e\xint_gob_til_dot #1#2#3#4#5#6#7#8#9!%
}%
-% \end{macrocode}
-% \lverb+#1=numerator.#2=N,#3=B,#4=D,#5=Blocs,#6=extra+
-% \begin{macrocode}
-\def\XINT_xtrunc_e #1%
+\def\XINT_xtrunc_prepare_e #1!#2!#3#4%
{%
- \xint_UDzerominusfork
- #1-\XINT_xtrunc_zero
- 0#1\XINT_xtrunc_N
- 0-{\XINT_xtrunc_P #1}%
- \krof
+ \XINT_xtrunc_prepare_f #4#3\X {#1}{#3}%
}%
-\def\XINT_xtrunc_zero .#1#2#3#4#5%
+\def\XINT_xtrunc_prepare_f #1#2#3#4#5#6#7#8#9\X
{%
- 0.\romannumeral0\expandafter\XINT_dsx_zeroloop
- \the\numexpr #5.{}\Z {}%
- \xintiloop [#4+-1]
- \ifnum \xintiloopindex>\xint_c_
- 0000000000000000000000000000000000000000000000000000000000000000%
- \repeat
+ \expandafter\XINT_xtrunc_prepare_g\expandafter
+ \XINT_div_prepare_g
+ \the\numexpr #1#2#3#4#5#6#7#8+\xint_c_i\expandafter
+ .\the\numexpr (#1#2#3#4#5#6#7#8+\xint_c_i)/\xint_c_ii\expandafter
+ .\the\numexpr #1#2#3#4#5#6#7#8\expandafter
+ .\romannumeral0\XINT_sepandrev_andcount
+ #1#2#3#4#5#6#7#8#9\XINT_rsepbyviii_end_A 2345678%
+ \XINT_rsepbyviii_end_B 2345678%
+ \relax\xint_c_ii\xint_c_iii
+ \R.\xint_c_vi\R.\xint_c_v\R.\xint_c_iv\R.\xint_c_iii
+ \R.\xint_c_ii\R.\xint_c_i\R.\xint_c_\W
+ \X
}%
-\def\XINT_xtrunc_N {-\XINT_xtrunc_P }%
-\def\XINT_xtrunc_P #1.#2%
+\def\XINT_xtrunc_prepare_g #1;{\XINT_xtrunc_e {#1}}%
+\def\XINT_xtrunc_e #1#2%
{%
\ifnum #2<\xint_c_
- \expandafter\XINT_xtrunc_negN_Q
+ \expandafter\XINT_xtrunc_I
\else
- \expandafter\XINT_xtrunc_Q
- \fi {#2}{#1}.%
+ \expandafter\XINT_xtrunc_II
+ \fi #2.{#1}%
}%
-\def\XINT_xtrunc_negN_Q #1#2.#3#4#5#6%
+\def\XINT_xtrunc_I -#1.#2#3#4%
{%
- \expandafter\XINT_xtrunc_negN_R
- \romannumeral0\XINT_div_prepare {#3}{#2}{#3}{#1}{#4}%
+ \expandafter\XINT_xtrunc_I_a\romannumeral0#2{#4}{#2}{#1}{#3}%
}%
-% \end{macrocode}
-% \lverb+#1=Q, #2=R, #3=B, #4=N<0, #5=D+
-% \begin{macrocode}
-\def\XINT_xtrunc_negN_R #1#2#3#4#5%
+\def\XINT_xtrunc_I_a #1#2#3#4#5%
{%
- \expandafter\XINT_xtrunc_negN_S\expandafter
- {\the\numexpr -#4}{#5}{#2}{#3}{#1}%
+ \expandafter\XINT_xtrunc_I_b\the\numexpr #4-#5.#4.{#5}{#2}{#3}{#1}%
}%
-\def\XINT_xtrunc_negN_S #1#2%
+\def\XINT_xtrunc_I_b #1%
{%
- \expandafter\XINT_xtrunc_negN_T\expandafter
- {\the\numexpr #2-#1}{#1}{#2}%
+ \xint_UDsignfork
+ #1\XINT_xtrunc_IA_c
+ -\XINT_xtrunc_IB_c
+ \krof #1%
}%
-\def\XINT_xtrunc_negN_T #1%
+\def\XINT_xtrunc_IA_c -#1.#2.#3#4#5#6%
{%
- \ifnum \xint_c_<#1
- \expandafter\XINT_xtrunc_negNA
- \else
- \expandafter\XINT_xtrunc_negNW
- \fi {#1}%
+ \expandafter\XINT_xtrunc_IA_d
+ \the\numexpr#2-\xintLength{#6}.{#6}%
+ \expandafter\XINT_xtrunc_IA_xd
+ \the\numexpr (#1+\xint_c_ii^v)/\xint_c_ii^vi-\xint_c_i.#1.{#5}{#4}%
}%
-% \end{macrocode}
-% \lverb+#1=D-|N|>0, #2=|N|, #3=D, #4=R, #5=B, #6=Q+
-% \begin{macrocode}
-\def\XINT_xtrunc_unlock #10.{ }%
-\def\XINT_xtrunc_negNA #1#2#3#4#5#6%
+\def\XINT_xtrunc_IA_d #1%
{%
- \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}%
+ \xint_UDsignfork
+ #1\XINT_xtrunc_IAA_e
+ -\XINT_xtrunc_IAB_e
+ \krof #1%
}%
-\def\XINT_xtrunc_negNB #1#2#3{\XINT_xtrunc_negNC {#2}{#3}#1}%
-\def\XINT_xtrunc_negNC #1%
+\def\XINT_xtrunc_IAA_e -#1.#2%
{%
- \ifnum \xint_c_ < #1
- \expandafter\XINT_xtrunc_negNDa
- \else
- \expandafter\XINT_xtrunc_negNE
- \fi {#1}%
+ \romannumeral0\XINT_split_fromleft
+ #1.#2\xint_gobble_i\xint_bye2345678\xint_bye..%
}%
-\def\XINT_xtrunc_negNDa #1#2%
+\def\XINT_xtrunc_IAB_e #1.#2%
{%
- \expandafter\XINT_xtrunc_negNDb%
- \romannumeral0\XINT_split_fromleft_loop #1.{}#2\W\W\W\W\W\W\W\W\Z
+ 0.\romannumeral\XINT_rep#1\endcsname0#2%
}%
-\def\XINT_xtrunc_negNDb #1.#2.{#1.#2}%
-\def\XINT_xtrunc_negNE #1#2%
+\def\XINT_xtrunc_IA_xd #1.#2.%
{%
- 0.\romannumeral0\XINT_dsx_zeroloop -#1.{}\Z {}#2%
+ \expandafter\XINT_xtrunc_IA_xe\the\numexpr #2-\xint_c_ii^vi*#1.#1.%
}%
-% \end{macrocode}
-% \lverb+#1=D-|N|<=0, #2=|N|, #3=D, #4=R, #5=B, #6=Q+
-% \begin{macrocode}
-\def\XINT_xtrunc_negNW #1#2#3#4#5#6%
+\def\XINT_xtrunc_IA_xe #1.#2.#3#4%
{%
- \expandafter\XINT_xtrunc_negNX\expandafter
- {\romannumeral0\xintnum{\xintDecSplitL {-#1}{#6}}}{#3}%
+ \XINT_xtrunc_loop {#2}{#4}{#3}{#1}%
}%
-\def\XINT_xtrunc_negNX #1#2%
+\def\XINT_xtrunc_IB_c #1.#2.#3#4#5#6%
{%
- \expandafter\XINT_xtrunc_negNC\expandafter
- {\the\numexpr\xintLength {#1}-#2}{#1}%
+ \expandafter\XINT_xtrunc_IB_d
+ \romannumeral0\XINT_split_xfork #1.#6\xint_bye2345678\xint_bye..{#3}%
}%
-\def\XINT_xtrunc_BisOne #1#2#3#4#5#6#7%
+\def\XINT_xtrunc_IB_d #1.#2.#3%
{%
- #5.\romannumeral0\expandafter\XINT_dsx_zeroloop
- \the\numexpr #7.{}\Z {}%
- \xintiloop [#6+-1]
- \ifnum \xintiloopindex>\xint_c_
- 0000000000000000000000000000000000000000000000000000000000000000%
- \repeat
+ \expandafter\XINT_xtrunc_IA_d\the\numexpr#3-\xintLength {#1}.{#1}%
}%
-\def\XINT_xtrunc_BisTwo #1#2#3#4#5#6#7%
+\def\XINT_xtrunc_II #1.%
{%
- \xintHalf {#5}.\ifodd\xintiiLDg{#5} 5\else 0\fi
- \romannumeral0\expandafter\XINT_dsx_zeroloop
- \the\numexpr #7-\xint_c_i.{}\Z {}%
- \xintiloop [#6+-1]
- \ifnum \xintiloopindex>\xint_c_
- 0000000000000000000000000000000000000000000000000000000000000000%
- \repeat
+ \expandafter\XINT_xtrunc_II_a\romannumeral\xintreplicate{#1}0.%
}%
-\def\XINT_xtrunc_Q #1%
+\def\XINT_xtrunc_II_a #1.#2#3#4%
{%
- \expandafter\XINT_xtrunc_prepare
- \romannumeral0\XINT_dsx_zeroloop #1.{}\Z
+ \expandafter\XINT_xtrunc_II_b
+ \the\numexpr (#3+\xint_c_ii^v)/\xint_c_ii^vi-\xint_c_i\expandafter.%
+ \the\numexpr #3\expandafter.\romannumeral0#2{#4#1}{#2}%
}%
-\def\XINT_xtrunc_prepare #1.#2#3%
+\def\XINT_xtrunc_II_b #1.#2.%
{%
- \expandafter\XINT_xtrunc_Pa\expandafter
- {\romannumeral0%
- \XINT_xtrunc_prepare_a #2\R\R\R\R\R\R\R\R {10}0000001\W !{#2}}{#1}%
+ \expandafter\XINT_xtrunc_II_c\the\numexpr #2-\xint_c_ii^vi*#1.#1.%
}%
-\def\XINT_xtrunc_prepare_a #1#2#3#4#5#6#7#8#9%
+\def\XINT_xtrunc_II_c #1.#2.#3#4#5%
{%
- \xint_gob_til_R #9\XINT_xtrunc_prepare_small\R
- \XINT_xtrunc_prepare_b #9%
+ #3.\XINT_xtrunc_loop {#2}{#4}{#5}{#1}%
}%
-\def\XINT_xtrunc_prepare_small\R #1!#2%
+\def\XINT_xtrunc_loop #1%
{%
- \ifcase #2
- \or\xint_afterfi{ \XINT_div_BisOne}%
- \or\xint_afterfi{ \XINT_div_BisTwo}%
- \else\expandafter\XINT_xtrunc_small_aa
- \fi {#2}%
+ \ifnum #1=\xint_c_ \expandafter\XINT_xtrunc_transition\fi
+ \expandafter\XINT_xtrunc_loop_a\the\numexpr #1-\xint_c_i.%
}%
-\def\XINT_xtrunc_small_aa #1%
+\def\XINT_xtrunc_loop_a #1.#2#3%
{%
- \expandafter\space\expandafter\XINT_xtrunc_small_a
- \the\numexpr #1/\xint_c_ii\expandafter
- .\the\numexpr \xint_c_x^viii+#1!%
+ \expandafter\XINT_xtrunc_loop_b\romannumeral0#3%
+ {#20000000000000000000000000000000000000000000000000000000000000000}%
+ {#1}{#3}%
}%
-\def\XINT_xtrunc_small_a #1.#2!#3%
+\def\XINT_xtrunc_loop_b #1#2#3%
{%
- \expandafter\XINT_div_small_b\the\numexpr #1\expandafter
- .\the\numexpr #2\expandafter!%
- \romannumeral0\XINT_div_small_ba #3\R\R\R\R\R\R\R\R{10}0000001\W
- #3\XINT_sepbyviii_Z_end 2345678\relax
+ \romannumeral\xintreplicate{\xint_c_ii^vi-\xintLength{#1}}0#1%
+ \XINT_xtrunc_loop {#3}{#2}%
}%
-\def\XINT_xtrunc_prepare_b
- {\expandafter\XINT_xtrunc_prepare_c\romannumeral0\XINT_zeroes_forviii }%
-\def\XINT_xtrunc_prepare_c #1!%
+\def\XINT_xtrunc_transition
+ \expandafter\XINT_xtrunc_loop_a\the\numexpr #1.#2#3#4%
{%
- \XINT_xtrunc_prepare_d #1.00000000!{#1}%
+ \ifnum #4=\xint_c_ \expandafter\xint_gobble_vi\fi
+ \expandafter\XINT_xtrunc_finish\expandafter
+ {\romannumeral0\XINT_dsx_addzeros{#4}#2;}{#3}{#4}%
}%
-\def\XINT_xtrunc_prepare_d #1#2#3#4#5#6#7#8#9%
+\def\XINT_xtrunc_finish #1#2%
{%
- \expandafter\XINT_xtrunc_prepare_e\xint_gob_til_dot #1#2#3#4#5#6#7#8#9!%
+ \expandafter\XINT_xtrunc_finish_a\romannumeral0#2{#1}%
}%
-\def\XINT_xtrunc_prepare_e #1!#2!#3#4%
+\def\XINT_xtrunc_finish_a #1#2#3%
{%
- \XINT_xtrunc_prepare_f #4#3\X {#1}{#3}%
+ \romannumeral\xintreplicate{#3-\xintLength{#1}}0#1%
}%
-\def\XINT_xtrunc_prepare_f #1#2#3#4#5#6#7#8#9\X
+\def\XINT_xtrunc_sp_e #1%
{%
- \expandafter\space\expandafter\XINT_div_prepare_g
- \the\numexpr #1#2#3#4#5#6#7#8+\xint_c_i\expandafter
- .\the\numexpr (#1#2#3#4#5#6#7#8+\xint_c_i)/\xint_c_ii\expandafter
- .\the\numexpr #1#2#3#4#5#6#7#8\expandafter
- .\romannumeral0\XINT_sepandrev_andcount
- #1#2#3#4#5#6#7#8#9\XINT_rsepbyviii_end_A 2345678%
- \XINT_rsepbyviii_end_B 2345678%
- \relax\xint_c_ii\xint_c_iii
- \R.\xint_c_vi\R.\xint_c_v\R.\xint_c_iv\R.\xint_c_iii
- \R.\xint_c_ii\R.\xint_c_i\R.\xint_c_\W
- \X
+ \ifnum #1<\xint_c_
+ \expandafter\XINT_xtrunc_sp_I
+ \else
+ \expandafter\XINT_xtrunc_sp_II
+ \fi #1.%
}%
-\def\XINT_xtrunc_Pa #1#2%
+\def\XINT_xtrunc_sp_I -#1.#2#3%
{%
- \expandafter\XINT_xtrunc_Pb\romannumeral0#1{#2}{#1}%
+ \expandafter\XINT_xtrunc_sp_I_a\the\numexpr #1-#3.#1.{#3}{#2}%
}%
-\def\XINT_xtrunc_Pb #1#2#3#4{#1.\XINT_xtrunc_A {#4}{#2}{#3}}%
-\def\XINT_xtrunc_A #1%
+\def\XINT_xtrunc_sp_I_a #1%
{%
- \unless\ifnum #1>\xint_c_ \XINT_xtrunc_transition\fi
- \expandafter\XINT_xtrunc_B\expandafter{\the\numexpr #1-\xint_c_i}%
+ \xint_UDsignfork
+ #1\XINT_xtrunc_sp_IA_b
+ -\XINT_xtrunc_sp_IB_b
+ \krof #1%
}%
-\def\XINT_xtrunc_B #1#2#3%
+\def\XINT_xtrunc_sp_IA_b -#1.#2.#3#4%
{%
- \expandafter\XINT_xtrunc_D\romannumeral0#3%
- {#20000000000000000000000000000000000000000000000000000000000000000}%
- {#1}{#3}%
+ \expandafter\XINT_xtrunc_sp_IA_c
+ \the\numexpr#2-\xintLength{#4}.{#4}\romannumeral\XINT_rep#1\endcsname0%
}%
-\def\XINT_xtrunc_D #1#2#3%
+\def\XINT_xtrunc_sp_IA_c #1%
{%
- \romannumeral0\expandafter\XINT_dsx_zeroloop
- \the\numexpr \xint_c_ii^vi-\xintLength{#1}.{}\Z {}#1%
- \XINT_xtrunc_A {#3}{#2}%
+ \xint_UDsignfork
+ #1\XINT_xtrunc_sp_IAA
+ -\XINT_xtrunc_sp_IAB
+ \krof #1%
}%
-\def\XINT_xtrunc_transition\fi
- \expandafter\XINT_xtrunc_B\expandafter #1#2#3#4%
+\def\XINT_xtrunc_sp_IAA -#1.#2%
{%
- \fi
- \ifnum #4=\xint_c_ \XINT_xtrunc_abort\fi
- \expandafter\XINT_xtrunc_x\expandafter
- {\romannumeral0\XINT_dsx_zeroloop #4.{}\Z {#2}}{#3}{#4}%
+ \romannumeral0\XINT_split_fromleft
+ #1.#2\xint_gobble_i\xint_bye2345678\xint_bye..%
}%
-\def\XINT_xtrunc_x #1#2%
+\def\XINT_xtrunc_sp_IAB #1.#2%
{%
- \expandafter\XINT_xtrunc_y\romannumeral0#2{#1}%
+ 0.\romannumeral\XINT_rep#1\endcsname0#2%
}%
-\def\XINT_xtrunc_y #1#2#3%
+\def\XINT_xtrunc_sp_IB_b #1.#2.#3#4%
{%
- \romannumeral0\expandafter\XINT_dsx_zeroloop
- \the\numexpr #3-\xintLength{#1}.{}\Z {}#1%
+ \expandafter\XINT_xtrunc_sp_IB_c
+ \romannumeral0\XINT_split_xfork #1.#4\xint_bye2345678\xint_bye..{#3}%
}%
-\def\XINT_xtrunc_abort\fi\expandafter\XINT_xtrunc_x\expandafter #1#2#3{\fi}%
+\def\XINT_xtrunc_sp_IB_c #1.#2.#3%
+{%
+ \expandafter\XINT_xtrunc_sp_IA_c\the\numexpr#3-\xintLength {#1}.{#1}%
+}%
+\def\XINT_xtrunc_sp_II #1.#2#3%
+{%
+ #2\romannumeral\XINT_rep#1\endcsname0.\romannumeral\XINT_rep#3\endcsname0%
+}%
% \end{macrocode}
% \subsection{\csh{xintDigits}}
% \lverb|The mathchardef used to be called \XINT_digits, but for reasons
@@ -25150,29 +25424,27 @@
\def\XINT_fadd_Bzero #1]#2#3#4{ #3/#4[#2]}%
\def\XINT_fadd_c #1/#2[#3]#4%
{%
- \expandafter\XINT_fadd_Aa\expandafter{\the\numexpr #4-#3}{#3}{#4}{#1}{#2}%
+ \expandafter\XINT_fadd_Aa\the\numexpr #4-#3.{#3}{#4}{#1}{#2}%
}%
\def\XINT_fadd_Aa #1%
{%
- \ifcase\XINT_cntSgn #1\Z
- \expandafter\XINT_fadd_B
- \or
- \expandafter \XINT_fadd_Ba
- \else
- \expandafter \XINT_fadd_Bb
- \fi {#1}%
+ \xint_UDzerominusfork
+ #1-\XINT_fadd_B
+ 0#1\XINT_fadd_Bb
+ 0-\XINT_fadd_Ba
+ \krof #1%
}%
-\def\XINT_fadd_B #1#2#3#4#5#6#7{\XINT_fadd_C {#4}{#5}{#7}{#6}[#3]}%
-\def\XINT_fadd_Ba #1#2#3#4#5#6#7%
+\def\XINT_fadd_B #1.#2#3#4#5#6#7{\XINT_fadd_C {#4}{#5}{#7}{#6}[#3]}%
+\def\XINT_fadd_Ba #1.#2#3#4#5#6#7%
{%
\expandafter\XINT_fadd_C\expandafter
- {\romannumeral0\XINT_dsx_zeroloop #1.{}\Z {#6}}%
+ {\romannumeral0\XINT_dsx_addzeros {#1}#6;}%
{#7}{#5}{#4}[#2]%
}%
-\def\XINT_fadd_Bb #1#2#3#4#5#6#7%
+\def\XINT_fadd_Bb -#1.#2#3#4#5#6#7%
{%
\expandafter\XINT_fadd_C\expandafter
- {\romannumeral0\XINT_dsx_zeroloop -#1.{}\Z {#4}}%
+ {\romannumeral0\XINT_dsx_addzeros {#1}#4;}%
{#5}{#7}{#6}[#3]%
}%
\def\XINT_fadd_C #1#2#3%
@@ -25559,13 +25831,13 @@
\def\XINT_fgeq_Fd #1\Z #2#3%
{%
\expandafter\XINT_fgeq_Fe\expandafter
- {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#3}}{#2}%
+ {\romannumeral0\XINT_dsx_addzeros {#1}#3;}{#2}%
}%
\def\XINT_fgeq_Fe #1#2{\XINT_geq_pre {#2}{#1}}%
\def\XINT_fgeq_Fn #1\Z #2#3%
{%
\expandafter\XINT_geq_pre\expandafter
- {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}%
+ {\romannumeral0\XINT_dsx_addzeros {#1}#2;}{#3}%
}%
% \end{macrocode}
% \subsection{\csh{xintMax}}
@@ -25737,13 +26009,13 @@
\def\XINT_fcmp_Fd #1\Z #2#3%
{%
\expandafter\XINT_fcmp_Fe\expandafter
- {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#3}}{#2}%
+ {\romannumeral0\XINT_dsx_addzeros {#1}#3;}{#2}%
}%
\def\XINT_fcmp_Fe #1#2{\xintiicmp {#2}{#1}}%
\def\XINT_fcmp_Fn #1\Z #2#3%
{%
\expandafter\xintiicmp\expandafter
- {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}%
+ {\romannumeral0\XINT_dsx_addzeros {#1}#2;}{#3}%
}%
% \end{macrocode}
% \subsection{\csh{xintAbs}}
@@ -25832,7 +26104,7 @@
% never-used branch. And it tries to handle more swiftly the case of inputs
% which are not fractions. (improved again in 1.2g)
%
-% This routine uses old macros \XINT_addm_a and \XINT_lenrord_loop. This could
+% This routine uses old macros \XINT_addm_A and \XINT_lenrord_loop. This could
% now be penalizing for P exceeding a few dozens, compared to doing it the 1.2
% way.
%
@@ -25858,7 +26130,9 @@
% 1.2g has also re-written both \xintFloat and \XINTinFloat start code to
% intercept more quickly and more satisfactorily B=1 case.
%
-% |
+% 1.2i simplifies code via use of \xintDSRr. No more use of
+% \XINT_lenrord_loop and of \XINT_addm_A, which have now been deleted from the
+% xint sources. |
% \begin{macrocode}
\def\xintFloat {\romannumeral0\xintfloat }%
\def\xintfloat #1{\XINT_float_chkopt #1\xint_relax }%
@@ -25889,7 +26163,7 @@
% \begin{macrocode}
\def\XINT_float_a #1.#2#3#4%
{%
- \if\romannumeral0\XINT_isone#4XY1\expandafter\XINT_float_sp
+ \if1\XINT_iSone#4XY\expandafter\XINT_float_sp
\else\expandafter\XINT_float_fork\fi #3.{#1}{#2}{#4}%
}%
% \end{macrocode}
@@ -25927,58 +26201,33 @@
{%
\expandafter\XINT_float_sp_done
\the\numexpr #4-#1+#3-\xint_c_i\expandafter.%
- \romannumeral0\XINT_dsx_addzerosnofuss {#1}{#2};%
+ \romannumeral0\XINT_dsx_addzeros {#1}#2;;%
}%
\def\XINT_float_sp_done #1.#2#3;{ #2.#3e#1}%
\def\XINT_float_sp_c #1.#2%
{%
\if #29\xint_dothis {\XINT_float_sp_d\XINT_float_Wb }\fi
- \xint_orthat {\XINT_float_sp_d\XINT_float_sp_Wa }#1.#2%
+ \xint_orthat {\XINT_float_sp_d\XINT_float_Wa }#1.#2%
}%
\def\XINT_float_sp_d #1#2.#3.#4.#5.%
{%
\expandafter\XINT_float_sp_e
\the\numexpr #5+#2+#4-\xint_c_i\expandafter.%
- \romannumeral0\expandafter\XINT_split_fromleft_loop
- \the\numexpr #4+\xint_c_i.{}#3\W\W\W\W\W\W\W\W\Z #1%
+ \romannumeral0\XINT_split_fromleft
+ (\xint_c_i+#4).#3\xint_bye2345678\xint_bye..#1%
}%
% \end{macrocode}
-% \lverb|Still using old Reverse routine because presumably we are handling
-% numbers up to a few dozens digits. But a faster \xintReverseDigits is
-% available. No time now.
+% \lverb|1.2i uses the \xintDSRr quick \numexpr loop for faster treatment.
+%
% #1=exposant final.#2=P+1chiffres de A.#3=junk.#4=\XINT_float_Wb ou
-% \XINT_float_sp_Wa
+% \XINT_float_Wa
% |
% \begin{macrocode}
-\def\XINT_float_sp_e #1.#2.#3.%
+\def\XINT_float_sp_e #1.#2.#3.#4%
{%
- \expandafter\XINT_float_sp_f
- \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.%
+ \expandafter#4\romannumeral0\XINT_dsrr#2%
+ \xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax e#1%
}%
-\def\XINT_float_sp_f #1%
-{%
- \ifnum #1<\xint_c_v
- \expandafter\XINT_float_sp_ga\else\expandafter\XINT_float_sp_h\fi
-}%
-\def\XINT_float_sp_ga #1;#2.#3%
-{%
- \expandafter\XINT_float_sp_Wa
- \romannumeral0\XINT_rord_main {}#1%
- \xint_relax
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_relax e#2%
-}%
-\def\XINT_float_sp_h #1;#2.#3%
-{%
- \expandafter#3%
- \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z e#2%
-}%
-\def\XINT_float_sp_Wa #1{ #1.}%
% \end{macrocode}
%\lverb?A.{P}{n}{B}\XINT_float_Q avec B qui est >1, donc A=0 exclu.
% ?
@@ -26016,8 +26265,7 @@
{%
\expandafter\XINT_float_MatoN
\the\numexpr #1-#2\expandafter.%
- \romannumeral0\XINT_split_fromleft_loop #2.{}#3\W\W\W\W\W\W\W\W\Z
- {#2}%
+ \romannumeral0\XINT_split_fromleft#2.#3\xint_bye2345678\xint_bye..{#2}%
}%
% \end{macrocode}
% \lverb?|A|-(P+2).{A'=P+2 premiers chiffres de
@@ -26040,11 +26288,10 @@
\romannumeral0\xintlength{#6}.#5.#2.{#6}{#1}{#3}{#4}%
}%
% \end{macrocode}
-% \lverb?Ce qu'on a fait avec A on le fait maintenant avec B. Mais on va
-% repérer B=1 avant de faire une division.$newline
+% \lverb?Ce qu'on a fait avec A on le fait maintenant avec B.
% En entrée: |B|.n'.P+2.{B}{|A'|}{A'}{P}\XINT_float_Q
%
-% 1.2g has already filtered out the case B=1.?
+% 1.2g has already filtered out the case B=1. We compare length |B| to P+2.?
% \begin{macrocode}
\def\XINT_float_N #1.#2.#3.%
{%
@@ -26062,7 +26309,7 @@
{%
\expandafter\XINT_float_NaP
\the\numexpr #2-#1+#3\expandafter.%
- \romannumeral0\XINT_split_fromleft_loop #3.{}#4\W\W\W\W\W\W\W\W\Z {#3}%
+ \romannumeral0\XINT_split_fromleft#3.#4\xint_bye2345678\xint_bye..{#3}%
}%
% \end{macrocode}
% \lverb?n''=n'-(|B|-(P+2)).{B'}.{junk}.{P+2}->0.P+2.n''.P+2.{B'}?
@@ -26092,7 +26339,7 @@
\def\XINT_float_Q #1.#2#3%
{%
\expandafter\XINT_float_Sa
- \romannumeral0\xintiiquo{\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}\Z {#1}%
+ \romannumeral0\xintiiquo{\XINT_dsx_addzeros {#1}#2;}{#3}\Z {#1}%
}%
% \end{macrocode}
% \lverb?On a Q\Z {|B|-|A|+P+1}{P}{n}. Comme Q = trunc (A/B 1O^x),
@@ -26108,67 +26355,48 @@
\xint_orthat {\XINT_float_Sb\XINT_float_Wa }#1%
}%
% \end{macrocode}
-% \lverb?En entrée \XINT_float_W(a ou b) Q\Z {|B|-|A|+P+1}{P}{n}. On va
-% renverser Q en comptant sa longueur L = P+1 ou P+2 au passage. Pour le
-% moment avec la vieille routine \XINT_lenrord_loop mais il faudra voir si je
-% modifie cela.?
+% \lverb?En entrée \XINT_float_W(a ou b) Q\Z {|B|-|A|+P+1}{P}{n}.
+%
+% Refait pour 1.2i, plus de reverse, mais emploi de \xintDSRr. Mais on doit
+% savoir si Q est de longueur L=P+1 ou P+2.
+%
+% #1=Wa ou Wb, #2=Q, #3=|B|-|A|+P+1, #4=P, #5=n. On va calculer L-P.?
% \begin{macrocode}
\def\XINT_float_Sb #1#2\Z #3#4%
{%
\expandafter\XINT_float_T
- \the\numexpr #4+\xint_c_i\expandafter.%
- \romannumeral`&&@\XINT_lenrord_loop 0.{}#2\Z\W\W\W\W\W\W\W\Z #1{#3}{#4}%
+ \the\numexpr\xint_c_ix\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye-#4.%
+ {#2}#1{#3}{#4}%
}%
% \end{macrocode}
-% \lverb?Si L>P+1, c'est que L=P+2, on laisse tomber le chiffre le moins
-% significatif de Q. En sortie on a \token Q à l'envers\Z \token
-% {|B|-|A|+P+1}{P}{n}?
+% \lverb?Si L>P+1, c'est que L=P+2. On partira en Ub puis Xb. Sinon Ua puis Xa
+% En sortie on a {Q}\token {|B|-|A|+P+1}{P}{n}?
% \begin{macrocode}
-\def\XINT_float_T #1.#2.#3%
+\def\XINT_float_T #1.%
{%
- \ifnum #2>#1 \xint_dothis{\XINT_float_U\XINT_float_Xb}\fi
- \xint_orthat{\XINT_float_U\XINT_float_Xa #3}%
+ \if2#1\expandafter\XINT_float_Ub\else\expandafter\XINT_float_Ua\fi
}%
-\def\XINT_float_U #1#2%
+\def\XINT_float_Ua #1#2%
{%
- \ifnum #2<\xint_c_v
- \expandafter\XINT_float_Va
- \else
- \expandafter\XINT_float_Vb
- \fi #1%
+ \expandafter\XINT_float_Xa
+ \romannumeral0\expandafter#2%
+ \romannumeral0\XINT_dsrr
+ #1\xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax;%
}%
-% \end{macrocode}
-% \lverb?Chiffre moins significatif de Q est <5. Suffit de tronquer. On va
-% ensuite embrayer soit sur \XINT_float_Xa si on avait P+1 chiffres, soit sur
-% \XINT_float_Xb si on en avait P+2. Dans ce cas de troncation, on n'a pas à
-% se préoccuper d'un arrondi éventuel vers le haut vers une puissance de dix,
-% donc le #3 est ici remplacé par \XINT_float_Wa.?
-% \begin{macrocode}
-\def\XINT_float_Va #1#2\Z #3%
+\def\XINT_float_Ub #1#2%
{%
- \expandafter#1%
- \romannumeral0\expandafter\XINT_float_Wa
- \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 \Z
+ \expandafter\XINT_float_Xb
+ \romannumeral0\expandafter#2%
+ \romannumeral0\expandafter\XINT_dsrr
+ \romannumeral0\XINT_dsr
+ #1\xint_bye\xint_Bye3456789\xint_bye+\xint_c_v)/\xint_c_x-\xint_c_i\relax
+ \xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax;%
}%
% \end{macrocode}
-% \lverb?Chiffre moins significatif de Q est au moins 5. Faut aussi ajouter 1.
-% On utilise la vieille routine d'addition spéciale \XINT_addm_A qui renvoie
-% son résultat à l'endroit. De plus on doit ensuite vérifier si l'arrondi
-% s'est fait vers la puissance de 10 supérieure. Cela ne peut se produire que
-% si le premier chiffre était 9, donc dans ce cas on a #3=\XINT_float_Wb,
-% sinon on a #3=\XINT_float_Wa.?
-% \begin{macrocode}
-\def\XINT_float_Vb #1#2\Z #3%
-{%
- \expandafter #1%
- \romannumeral0\expandafter #3%
- \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #2000\W\X\Y\Z \Z
-}%
-% \end{macrocode}
% \lverb|Wa insère la virgule. Wb regarde si on a arrondi vers le haut vers
% une puissance de 10. Il n'est exécuté que si le premier chiffre était un 9,
% donc il regarde si maintenant le premier chiffre est devenu un 1. Est-il sûr
@@ -26181,15 +26409,15 @@
\def\XINT_float_Wb #1#2{\if #11\xint_dothis{ 10.}\fi\xint_orthat{ #1.#2}}%
% \end{macrocode}
% \lverb?Il faut faire l'ajustement final de n. On doit regrabber notre
-% mantisse, maintenant avec sa virgule. On a {|B|-|A|+P+1}{P}{n} après le \Z.
+% mantisse, maintenant avec sa virgule. On a {|B|-|A|+P+1}{P}{n} après le ;
% On exécute _Xb si le quotient produit avait P+2 chifffres. On n'a pas à
% faire d'ajustement en cas d'arrondi vers un 10.00...0.?
% \begin{macrocode}
-\def\XINT_float_Xa #1\Z #2#3#4%
+\def\XINT_float_Xa #1;#2#3#4%
{%
\expandafter\XINT_float_Y\the\numexpr #3+#4-#2.{#1}%
}%
-\def\XINT_float_Xb #1\Z #2#3#4%
+\def\XINT_float_Xb #1;#2#3#4%
{%
\expandafter\XINT_float_Y\the\numexpr #3+#4+\xint_c_i-#2.{#1}%
}%
@@ -26236,6 +26464,9 @@
% 2016/03/19.
% 1.2g uses non-patched \XINT_infrac but then immediately filters out
% all denominator=1 cases (only the A[N] cases were identified by 1.2f).
+%
+% 2016/12/11.
+% 1.2i simplifies the coding via use of \xintDSRr.
%|
% \begin{macrocode}
\def\XINTinFloat {\romannumeral0\XINTinfloat }%
@@ -26245,11 +26476,11 @@
{\if #1!\xint_dothis\XINT_infloat_clean_a\fi\xint_orthat{ }#1}%
\def\XINT_infloat_clean_a !#1.#2[#3]%
{%
- \expandafter\XINT_infloat_sp_done
+ \expandafter\XINT_infloat_done
\the\numexpr #3-#1\expandafter.%
- \romannumeral0\XINT_dsx_addzerosnofuss {#1}{#2};%
+ \romannumeral0\XINT_dsx_addzeros {#1}#2;;%
}%
-\def\XINT_infloat_sp_done #1.#2;{ #2[#1]}%
+\def\XINT_infloat_done #1.#2;{ #2[#1]}%
\def\XINTinFloatS {\romannumeral0\XINTinfloatS}%
\def\XINTinfloatS
{\expandafter\XINT_infloatS_clean\romannumeral0\XINT_infloat}%
@@ -26263,7 +26494,7 @@
}%
\def\XINT_infloat_a #1.#2#3#4%
{%
- \if\romannumeral0\XINT_isone#4XY1\expandafter\XINT_infloat_sp
+ \if1\XINT_iSone#4XY\expandafter\XINT_infloat_sp
\else\expandafter\XINT_float_fork\fi #3.{#1}{#2}{#4}%
}%
% \end{macrocode}
@@ -26304,54 +26535,27 @@
\def\XINT_infloat_sp_c #1.#2%
{%
\if #29\xint_dothis {\XINT_infloat_sp_d\XINT_infloat_Wb }\fi
- \xint_orthat {\XINT_infloat_sp_d\xint_c_ }#1.#2%
+ \xint_orthat {\XINT_infloat_sp_d .}#1.#2%
}%
\def\XINT_infloat_sp_d #1#2.#3.#4.%#5.%
{%
\expandafter\XINT_infloat_sp_e
- \romannumeral0\expandafter\XINT_split_fromleft_loop
- \the\numexpr #4+\xint_c_i.{}#3\W\W\W\W\W\W\W\W\Z #1#2.%
+ \romannumeral0\XINT_split_fromleft
+ (\xint_c_i+#4).#3\xint_bye2345678\xint_bye..#1#2.%
}%
% \end{macrocode}
-% \lverb|Still using old Reverse routine because presumably we are handling
-% numbers up to a few dozens digits. But a faster \xintReverseDigits is
-% available. No time now.
-%
-% #1=first P+1 digits of A, #2=junk|
+% \lverb|#1=first P+1 digits of A, #2=junk, #3=\XINT_infloat_Wb ou «.»,
+% #4=L-P, #5=N. Exposant final sera N+L-P ou N+L-P+1. Le +1 dans le cas où on
+% il y a eu arrondi vers la puissance de 10 supérieure. On récupère le +1
+% par #3 éventuellement. C'est le #3 qui met un «.» pour terminer le
+% \numexpr.|
% \begin{macrocode}
-\def\XINT_infloat_sp_e #1.#2.%
+\def\XINT_infloat_sp_e #1.#2.#3#4.#5.%
{%
- \expandafter\XINT_infloat_sp_f
- \romannumeral0\XINT_rord_main {}#1%
- \xint_relax
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_relax ;%
+ \expandafter\XINT_infloat_done
+ \the\numexpr#4+#5\expandafter#3\romannumeral0\XINT_dsrr
+ #1\xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax;%
}%
-\def\XINT_infloat_sp_f #1%
-{%
- \ifnum #1<\xint_c_v
- \expandafter\XINT_infloat_sp_ga\else\expandafter\XINT_infloat_sp_h\fi
-}%
-\def\XINT_infloat_sp_ga #1;#2#3.#4.%
-{%
- \expandafter\XINT_infloat_sp_done\the\numexpr #3+#4\expandafter.%
- \romannumeral0\XINT_rord_main {}#1%
- \xint_relax
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_relax ;%
-}%
-\def\XINT_infloat_sp_h #1;#2%
-{%
- \expandafter\XINT_infloat_sp_i
- \romannumeral0\expandafter#2%
- \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z;%
-}%
-\def\XINT_infloat_sp_i #1#2;#3.#4.%
-{%
- \expandafter\XINT_infloat_sp_done\the\numexpr #1+#3+#4.#2;%
-}%
% \end{macrocode}
% \lverb|General branch handling A/B possibly with [N] or scientific notation
% inputs.
@@ -26361,59 +26565,57 @@
\def\XINT_infloat_Q #1.#2#3%
{%
\expandafter\XINT_infloat_Sa
- \romannumeral0\xintiiquo{\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}\Z {#1}%
+ \romannumeral0\xintiiquo{\XINT_dsx_addzeros {#1}#2;}{#3}\Z {#1}%
}%
\def\XINT_infloat_Sa #1%
{%
\if #19\xint_dothis {\XINT_infloat_Sb\XINT_infloat_Wb }\fi
- \xint_orthat {\XINT_infloat_Sb\xint_c_ }#1%
+ \xint_orthat {\XINT_infloat_Sb .}#1%
}%
+% \lverb?Refait pour 1.2i: calcul de longueur, puis \xintDSRr.
+%
+% En entrée \XINT_infloat_Wb ou «.» Q\Z {|B|-|A|+P+1}{P}{n}. On
+% commence par évaluer longueur de Q -P pour savoir si 1 ou 2. Plus besoin de
+% P après. L'exposant final sera 1+n-(|B|-|A|+P+1) ou 2+n-(|B|-|A|+P+1).
+% modulo ajustement avec encore un +1 éventuel de Wb.
+% ?
\def\XINT_infloat_Sb #1#2\Z #3#4%
{%
\expandafter\XINT_infloat_T
- \the\numexpr #4+\xint_c_i\expandafter.%
- \romannumeral`&&@\XINT_lenrord_loop 0.{}#2\Z\W\W\W\W\W\W\W\Z #1{#3}%
+ \the\numexpr\xint_c_ix\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye-#4.%
+ {#2}#1{#3}%
}%
-\def\XINT_infloat_T #1.#2.#3%
+% \end{macrocode}
+% \lverb?Si L>P+1, c'est que L=P+2. Dans ce cas exposant final sera
+% 2+n-(|B|-|A|+P+1) tandis que c'est 1+n-(|B|-|A|+P+1) dans le premier cas.
+% Dans les deux ajustement éventuel par un +1 pouvant venir de Wb.?
+% \begin{macrocode}
+\def\XINT_infloat_T #1.%
{%
- \ifnum #2>#1 \xint_dothis{\XINT_infloat_U\XINT_infloat_Xb}\fi
- \xint_orthat{\XINT_infloat_U\XINT_infloat_Xa #3}%
+ \if2#1\expandafter\XINT_infloat_Ub\else\expandafter\XINT_infloat_Ua\fi
}%
-\def\XINT_infloat_U #1#2%
+\def\XINT_infloat_Ua #1#2#3#4%
{%
- \ifnum #2<\xint_c_v
- \expandafter\XINT_infloat_Va
- \else
- \expandafter\XINT_infloat_Vb
- \fi #1%
+ \expandafter\XINT_infloat_done
+ \the\numexpr\xint_c_i+#4-#3\romannumeral0\expandafter#2%
+ \romannumeral0\XINT_dsrr
+ #1\xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax;%
}%
-\def\XINT_infloat_Va #1#2\Z #3%
+\def\XINT_infloat_Ub #1#2#3#4%
{%
- \expandafter#1%
- \romannumeral0\expandafter\xint_c_
- \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 \Z
+ \expandafter\XINT_infloat_done
+ \the\numexpr\xint_c_ii+#4-#3\romannumeral0\expandafter#2%
+ \romannumeral0\expandafter\XINT_dsrr
+ \romannumeral0\XINT_dsr
+ #1\xint_bye\xint_Bye3456789\xint_bye+\xint_c_v)/\xint_c_x-\xint_c_i\relax
+ \xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax;%
}%
-\def\XINT_infloat_Vb #1#2\Z #3%
-{%
- \expandafter #1%
- \romannumeral0\expandafter #3%
- \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #2000\W\X\Y\Z \Z
-}%
\def\XINT_infloat_Wb #1#2%
- {\if #11\xint_dothis{\xint_c_i1}\fi\xint_orthat{\xint_c_#1#2}}%
-\def\XINT_infloat_Xa #1#2\Z #3#4%
-{%
- \expandafter\XINT_infloat_Y\the\numexpr #1+\xint_c_i+#4-#3.{#2}%
-}%
-\def\XINT_infloat_Xb #1#2\Z #3#4%
-{%
- \expandafter\XINT_infloat_Y\the\numexpr #1+\xint_c_ii+#4-#3.{#2}%
-}%
-\def\XINT_infloat_Y #1.#2{ #2[#1]}%
+ {\if #11\xint_dothis{+\xint_c_i.1}\fi\xint_orthat{.#1#2}}%
% \end{macrocode}
% \subsection{\csh{xintPFloat}}
% \lverb|1.1. This is a prettifying printing macro for floats.
@@ -26763,7 +26965,7 @@
\def\XINT_flpow_aa #1[#2]#3%
{%
\expandafter\XINT_flpow_ab\the\numexpr #2-#3\expandafter.%
- \romannumeral0\XINT_dsx_addzerosnofuss {#3}{}.#1.%
+ \romannumeral\XINT_rep #3\endcsname0.#1.%
}%
\def\XINT_flpow_ab #1.#2.#3.{\XINT_flpow_a #3#2[#1]}%
\def\XINT_flpow_a #1%
@@ -26786,8 +26988,8 @@
\def\XINT_flpow_truncate #1.#2.#3.%
{%
\expandafter\XINT_flpow_truncate_a
- \romannumeral0\XINT_split_fromleft_loop #3.{}#2\W\W\W\W\W\W\W\W\Z
- #1.#3.%
+ \romannumeral0\XINT_split_fromleft
+ #3.#2\xint_bye2345678\xint_bye..#1.#3.%
}%
\def\XINT_flpow_truncate_a #1.#2.#3.{#3+\xintLength{#2}.#1.}%
\def\XINT_flpow_loopI #1.%
@@ -26968,7 +27170,7 @@
\def\XINT_flpower_aa #1[#2]#3%
{%
\expandafter\XINT_flpower_ab\the\numexpr #2-#3\expandafter.%
- \romannumeral0\XINT_dsx_addzerosnofuss {#3}{}.#1.%
+ \romannumeral\XINT_rep #3\endcsname0.#1.%
}%
\def\XINT_flpower_ab #1.#2.#3.{\XINT_flpower_a #3#2[#1]}%
\def\XINT_flpower_a #1%
@@ -26988,7 +27190,9 @@
\if1\XINT_isOne {#1}\xint_dothis\XINT_flpower_ItoIII\fi
\if1\xintiiOdd {#1}\xint_dothis{\expandafter\XINT_flpower_loopI_odd}\fi
\xint_orthat{\expandafter\XINT_flpower_loopI_even}%
- \romannumeral0\xinthalf{#1}.%
+ \romannumeral0\XINT_half
+ #1\xint_bye\xint_Bye345678\xint_bye
+ *\xint_c_v+\xint_c_v)/\xint_c_x-\xint_c_i\relax.%
}%
\def\XINT_flpower_ItoIII #1.#2.#3.#4.#5%
{%
@@ -27014,7 +27218,8 @@
\if1\XINT_isOne{#1}\xint_dothis\XINT_flpower_IItoIII\fi
\if1\xintiiOdd{#1}\xint_dothis{\expandafter\XINT_flpower_loopII_odd}\fi
\xint_orthat{\expandafter\XINT_flpower_loopII_even}%
- \romannumeral0\xinthalf{#1}.%
+ \romannumeral0\XINT_half#1\xint_bye\xint_Bye345678\xint_bye
+ *\xint_c_v+\xint_c_v)/\xint_c_x-\xint_c_i\relax.%
}%
\def\XINT_flpower_loopII_even #1.#2.#3.#4.%
{%
@@ -27661,13 +27866,14 @@
{%
\expandafter\XINT_flsqrt_c
\romannumeral0\xintiisub
- {\XINT_dsx_addzerosnofuss {#1}{#2}}%
- {\xintiiDivRound{\XINT_dsx_addzerosnofuss {#1}{#3}}{\XINT_dbl_pos#2\Z}}.%
+ {\XINT_dsx_addzeros {#1}#2;}%
+ {\xintiiDivRound{\XINT_dsx_addzeros {#1}#3;}%
+ {\XINT_dbl#2\xint_bye2345678\xint_bye*\xint_c_ii\relax}}.%
}%
\def\XINT_flsqrt_c #1.#2.%
{%
- \expandafter\XINT_flsqrt_d
- \romannumeral0\XINT_split_fromleft_loop #2.{}#1\W\W\W\W\W\W\W\W\Z
+ \expandafter\XINT_flsqrt_d
+ \romannumeral0\XINT_split_fromleft#2.#1\xint_bye2345678\xint_bye..%
}%
\def\XINT_flsqrt_d #1.#2#3.%
{%
@@ -27809,7 +28015,7 @@
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintseries}%
- [2016/11/20 1.2h Expandable partial sums with xint package (JFB)]%
+ [2016/12/13 1.2i Expandable partial sums with xint package (JFB)]%
% \end{macrocode}
% \subsection{\csh{xintSeries}}
% \begin{macrocode}
@@ -28307,7 +28513,7 @@
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintcfrac}%
- [2016/11/20 1.2h Expandable continued fractions with xint package (JFB)]%
+ [2016/12/13 1.2i Expandable continued fractions with xint package (JFB)]%
% \end{macrocode}
% \subsection{\csh{xintCFrac}}
% \begin{macrocode}
@@ -29548,7 +29754,7 @@
% \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintexpr}%
- [2016/11/20 1.2h Expandable expression parser (JFB)]%
+ [2016/12/13 1.2i Expandable expression parser (JFB)]%
\catcode`! 11
% \end{macrocode}
% \subsection{Locking and unlocking}
@@ -33401,34 +33607,34 @@
%<*dtx>-----------------------------------------------------------
\iffalse
% grep -c -e "^{%" xint*sty
-xint.sty:233
+xint.sty:215
xintbinhex.sty:69
xintcfrac.sty:183
-xintcore.sty:287
+xintcore.sty:272
xintexpr.sty:147
-xintfrac.sty:463
+xintfrac.sty:433
xintgcd.sty:59
-xintkernel.sty:7
+xintkernel.sty:13
xintseries.sty:48
-xinttools.sty:147
+xinttools.sty:138
\fi
% grep -o "^{%" xint*sty | wc -l
-\def\totala{ 1643}
+\def\totala{ 1577}
\iffalse
% grep -c -e "^}%" xint*sty
-xint.sty:233
+xint.sty:215
xintbinhex.sty:69
xintcfrac.sty:183
-xintcore.sty:287
+xintcore.sty:272
xintexpr.sty:178
-xintfrac.sty:463
+xintfrac.sty:433
xintgcd.sty:61
-xintkernel.sty:9
+xintkernel.sty:15
xintseries.sty:48
-xinttools.sty:147
+xinttools.sty:138
\fi
% grep -o "^}%" xint*sty | wc -l
-\def\totalb{ 1678}
+\def\totalb{ 1612}
\DeleteShortVerb{\|}
\def\mymacro #1{\mymacroaux #1}
\def\mymacroaux #1#2{\strut \csname #1nameimp\endcsname:& \dtt{ #2.}\tabularnewline }
@@ -33465,7 +33671,7 @@
Right bracket \] Circumflex \^ Underscore \_
Grave accent \` Left brace \{ Vertical bar \|
Right brace \} Tilde \~}
-\CheckSum {30303}%
+\CheckSum {30403}% était 30303 pour 1.2h
\makeatletter\check at checksum\makeatother
\Finale
%% End of file xint.dtx
Modified: trunk/Master/texmf-dist/source/generic/xint/xint.ins
===================================================================
--- trunk/Master/texmf-dist/source/generic/xint/xint.ins 2016-12-13 22:24:48 UTC (rev 42697)
+++ trunk/Master/texmf-dist/source/generic/xint/xint.ins 2016-12-13 22:25:04 UTC (rev 42698)
@@ -21,7 +21,7 @@
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% ---------------------------------------------------------------
-%% The xint bundle 1.2h 2016/11/20
+%% The xint bundle 1.2i 2016/12/13
%% Copyright (C) 2013-2016 by Jean-Francois Burnol
%% ---------------------------------------------------------------
%%
Modified: trunk/Master/texmf-dist/tex/generic/xint/xint.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/xint/xint.sty 2016-12-13 22:24:48 UTC (rev 42697)
+++ trunk/Master/texmf-dist/tex/generic/xint/xint.sty 2016-12-13 22:25:04 UTC (rev 42698)
@@ -21,7 +21,7 @@
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% ---------------------------------------------------------------
-%% The xint bundle 1.2h 2016/11/20
+%% The xint bundle 1.2i 2016/12/13
%% Copyright (C) 2013-2016 by Jean-Francois Burnol
%% xint: Expandable operations on big integers
%% ---------------------------------------------------------------
@@ -70,7 +70,7 @@
\XINTsetupcatcodes% defined in xintkernel.sty (loaded by xintcore.sty)
\XINT_providespackage
\ProvidesPackage{xint}%
- [2016/11/20 1.2h Expandable operations on big integers (JFB)]%
+ [2016/12/13 1.2i Expandable operations on big integers (JFB)]%
\long\def\xint_firstofthree #1#2#3{#1}%
\long\def\xint_secondofthree #1#2#3{#2}%
\long\def\xint_thirdofthree #1#2#3{#3}%
@@ -89,11 +89,10 @@
\else\expandafter\xint_firstofthree_thenstop
\fi
}%
-\def\xintiiIsOne {\romannumeral0\xintiiisone }%
+\def\xintiiIsOne {\romannumeral0\xintiiisone }%
\def\xintiiisone #1{\expandafter\XINT_isone\romannumeral`&&@#1XY}%
\def\xintIsOne {\romannumeral0\xintisone }%
-\def\xintisone #1{\expandafter\XINT_isone\romannumeral0\xintnum{#1}XY}%
-\def\XINT_isOne #1{\romannumeral0\XINT_isone #1XY}%
+\def\xintisone #1{\expandafter\XINT_isone\romannumeral0\xintnum{#1}XY}%
\def\XINT_isone #1#2#3Y%
{%
\unless\if#2X\xint_dothis{ 0}\fi
@@ -100,6 +99,13 @@
\unless\if#11\xint_dothis{ 0}\fi
\xint_orthat{ 1}%
}%
+\def\XINT_isOne #1{\XINT_iSone#1XY}%
+\def\XINT_iSone #1#2#3Y%
+{%
+ \unless\if#2X\xint_dothis0\fi
+ \unless\if#11\xint_dothis0\fi
+ \xint_orthat1%
+}%
\let\xintRev\xintReverseDigits
\def\xintLen {\romannumeral0\xintlen }%
\def\xintlen #1%
@@ -106,22 +112,16 @@
{%
\expandafter\XINT_len_fork
\romannumeral0\xintnum{#1}\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye\relax
}%
-\def\XINT_Len #1% variant which does not expand via \xintnum.
+\edef\XINT_len_fork #1%
{%
- \romannumeral0\XINT_len_fork
- #1\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ \noexpand\expandafter\space
+ \unexpanded{\the\numexpr\xint_c_ix\expandafter
+ \XINT_length_loop\xint_UDsignfork#1{}-{#1}\krof}%
}%
-\def\XINT_len_fork #1%
-{%
- \expandafter\XINT_length_loop
- \xint_UDsignfork
- #1{0.}%
- -{0.#1}%
- \krof
-}%
\def\xintBool #1{\romannumeral`&&@%
\csname if#1\endcsname\expandafter1\else\expandafter0\fi }%
\def\xintToggle #1{\romannumeral`&&@\iftoggle{#1}{1}{0}}%
@@ -199,8 +199,8 @@
}%
\let\xintifTrueAelseB\xintifNotZero
\let\xintifFalseAelseB\xintifZero
-\let\xintifTrue\xintifNotZero
-\let\xintifTrueFalse\xintifNotZero
+%%\let\xintifTrue\xintifNotZero % now removed
+%%\let\xintifTrueFalse\xintifNotZero % now removed
\def\xintifCmp {\romannumeral0\xintifcmp }%
\def\xintifcmp #1#2%
{%
@@ -841,7 +841,7 @@
\def\xintiiMON {\romannumeral0\xintiimon }%
\def\xintiimon #1%
{%
- \ifodd\xintiiLDg {#1}
+ \ifodd\xintiiLDg {#1} %<- intentional space
\xint_afterfi{ -1}%
\else
\xint_afterfi{ 1}%
@@ -850,7 +850,7 @@
\def\xintiiMMON {\romannumeral0\xintiimmon }%
\def\xintiimmon #1%
{%
- \ifodd\xintiiLDg {#1}
+ \ifodd\xintiiLDg {#1} %<- intentional space
\xint_afterfi{ 1}%
\else
\xint_afterfi{ -1}%
@@ -859,7 +859,7 @@
\def\xintMON {\romannumeral0\xintmon }%
\def\xintmon #1%
{%
- \ifodd\xintLDg {#1}
+ \ifodd\xintLDg {#1} %<- intentional space
\xint_afterfi{ -1}%
\else
\xint_afterfi{ 1}%
@@ -868,7 +868,7 @@
\def\xintMMON {\romannumeral0\xintmmon }%
\def\xintmmon #1%
{%
- \ifodd\xintLDg {#1}
+ \ifodd\xintLDg {#1} %<- intentional space
\xint_afterfi{ 1}%
\else
\xint_afterfi{ -1}%
@@ -877,7 +877,7 @@
\def\xintiiOdd {\romannumeral0\xintiiodd }%
\def\xintiiodd #1%
{%
- \ifodd\xintiiLDg{#1}
+ \ifodd\xintiiLDg{#1} %<- intentional space
\xint_afterfi{ 1}%
\else
\xint_afterfi{ 0}%
@@ -886,7 +886,7 @@
\def\xintiiEven {\romannumeral0\xintiieven }%
\def\xintiieven #1%
{%
- \ifodd\xintiiLDg{#1}
+ \ifodd\xintiiLDg{#1} %<- intentional space
\xint_afterfi{ 0}%
\else
\xint_afterfi{ 1}%
@@ -895,7 +895,7 @@
\def\xintOdd {\romannumeral0\xintodd }%
\def\xintodd #1%
{%
- \ifodd\xintLDg{#1}
+ \ifodd\xintLDg{#1} %<- intentional space
\xint_afterfi{ 1}%
\else
\xint_afterfi{ 0}%
@@ -904,49 +904,18 @@
\def\xintEven {\romannumeral0\xinteven }%
\def\xinteven #1%
{%
- \ifodd\xintLDg{#1}
+ \ifodd\xintLDg{#1} %<- intentional space
\xint_afterfi{ 0}%
\else
\xint_afterfi{ 1}%
\fi
}%
-\def\xintDSL {\romannumeral0\xintdsl }%
-\def\xintdsl #1%
-{%
- \expandafter\XINT_dsl \romannumeral`&&@#1\Z
-}%
-\def\XINT_DSL #1{\romannumeral0\XINT_dsl #1\Z }%
-\def\XINT_dsl #1%
-{%
- \xint_gob_til_zero #1\xint_dsl_zero 0\XINT_dsl_ #1%
-}%
-\def\xint_dsl_zero 0\XINT_dsl_ 0#1\Z { 0}%
-\def\XINT_dsl_ #1\Z { #10}%
-\def\xintDSR {\romannumeral0\xintdsr }%
-\def\xintdsr #1%
-{%
- \expandafter\XINT_dsr_a\expandafter {\romannumeral`&&@#1}\W\Z
-}%
-\def\XINT_DSR #1{\romannumeral0\XINT_dsr_a {#1}\W\Z }%
-\def\XINT_dsr_a
-{%
- \expandafter\XINT_dsr_b\romannumeral0\xintreverseorder
-}%
-\def\XINT_dsr_b #1#2#3\Z
-{%
- \xint_gob_til_W #2\xint_dsr_onedigit\W
- \xint_gob_til_minus #2\xint_dsr_onedigit-%
- \expandafter\XINT_dsr_removew
- \romannumeral0\xintreverseorder {#2#3}%
-}%
-\def\xint_dsr_onedigit #1\xintreverseorder #2{ 0}%
-\def\XINT_dsr_removew #1\W { }%
\def\xintDSHr {\romannumeral0\xintdshr }%
-\def\xintdshr #1%
+\def\xintdshr #1#2%
{%
- \expandafter\XINT_dshr_checkxpositive \the\numexpr #1\relax\Z
+ \expandafter\XINT_dshr_fork\the\numexpr#1\expandafter.\romannumeral`&&@#2;%
}%
-\def\XINT_dshr_checkxpositive #1%
+\def\XINT_dshr_fork #1%
{%
\xint_UDzerominusfork
0#1\XINT_dshr_xzeroorneg
@@ -954,47 +923,36 @@
0-\XINT_dshr_xpositive
\krof #1%
}%
-\def\XINT_dshr_xzeroorneg #1\Z #2{ 0}%
-\def\XINT_dshr_xpositive #1\Z
+\def\XINT_dshr_xzeroorneg #1;{ 0}%
+\def\XINT_dshr_xpositive
{%
- \expandafter\xint_secondoftwo_thenstop\romannumeral0\xintdsx {#1}%
+ \expandafter\xint_secondoftwo_thenstop\romannumeral0\XINT_dsx_xisPos
}%
\def\xintDSH {\romannumeral0\xintdsh }%
\def\xintdsh #1#2%
{%
- \expandafter\xint_dsh\expandafter {\romannumeral`&&@#2}{#1}%
+ \expandafter\XINT_dsh_fork\the\numexpr#1\expandafter.\romannumeral`&&@#2;%
}%
-\def\xint_dsh #1#2%
+\def\XINT_dsh_fork #1%
{%
- \expandafter\XINT_dsh_checksignx \the\numexpr #2\relax\Z {#1}%
-}%
-\def\XINT_dsh_checksignx #1%
-{%
\xint_UDzerominusfork
#1-\XINT_dsh_xiszero
- 0#1\XINT_dsx_xisNeg_checkA % on passe direct dans DSx
+ 0#1\XINT_dsx_xisNeg_checkA
0-{\XINT_dsh_xisPos #1}%
\krof
}%
-\def\XINT_dsh_xiszero #1\Z #2{ #2}%
-\def\XINT_dsh_xisPos #1\Z #2%
+\def\XINT_dsh_xiszero #1.#2;{ #2}%
+\def\XINT_dsh_xisPos
{%
- \expandafter\xint_firstoftwo_thenstop
- \romannumeral0\XINT_dsx_checksignA #2\Z {#1}% via DSx
+ \expandafter\xint_firstoftwo_thenstop\romannumeral0\XINT_dsx_xisPos
}%
\def\xintDSx {\romannumeral0\xintdsx }%
\def\xintdsx #1#2%
{%
- \expandafter\xint_dsx\expandafter {\romannumeral`&&@#2}{#1}%
+ \expandafter\XINT_dsx_fork\the\numexpr#1\expandafter.\romannumeral`&&@#2;%
}%
-\def\xint_dsx #1#2%
+\def\XINT_dsx_fork #1%
{%
- \expandafter\XINT_dsx_checksignx \the\numexpr #2\relax\Z {#1}%
-}%
-\def\XINT_DSx #1#2{\romannumeral0\XINT_dsx_checksignx #1\Z {#2}}%
-\def\XINT_dsx #1#2{\XINT_dsx_checksignx #1\Z {#2}}%
-\def\XINT_dsx_checksignx #1%
-{%
\xint_UDzerominusfork
#1-\XINT_dsx_xisZero
0#1\XINT_dsx_xisNeg_checkA
@@ -1001,48 +959,31 @@
0-{\XINT_dsx_xisPos #1}%
\krof
}%
-\def\XINT_dsx_xisZero #1\Z #2{{#2}{0}}% attention comme x > 0
-\def\XINT_dsx_xisNeg_checkA #1\Z #2%
+\def\XINT_dsx_xisZero #1.#2;{{#2}{0}}%
+\def\XINT_dsx_xisNeg_checkA #1.#2%
{%
- \XINT_dsx_xisNeg_checkA_ #2\Z {#1}%
+ \xint_gob_til_zero #2\XINT_dsx_xisNeg_Azero 0%
+ \expandafter\XINT_dsx_append\romannumeral\XINT_rep #1\endcsname 0.#2%
}%
-\def\XINT_dsx_xisNeg_checkA_ #1#2\Z #3%
+\def\XINT_dsx_xisNeg_Azero #1;{ 0}%
+\def\XINT_dsx_addzeros #1%
+ {\expandafter\XINT_dsx_append\romannumeral\XINT_rep#1\endcsname0.}%
+\def\XINT_dsx_addzerosnofuss #1%
+ {\expandafter\XINT_dsx_append\romannumeral\xintreplicate{#1}0.}%
+\def\XINT_dsx_append #1.#2;{ #2#1}%
+\def\XINT_dsx_xisPos #1.#2%
{%
- \xint_gob_til_zero #1\XINT_dsx_xisNeg_Azero 0%
- \XINT_dsx_zeroloop #3.{}\Z {#1#2}%
-}%
-\def\XINT_dsx_xisNeg_Azero #1\Z #2{ 0}%
-\def\XINT_dsx_addzerosnofuss #1{\XINT_dsx_zeroloop #1.{}\Z }%
-\def\XINT_dsx_zeroloop #1.#2%
-{%
- \ifnum #1<\xint_c_ix \expandafter\XINT_dsx_exita\fi
- \expandafter\XINT_dsx_zeroloop\the\numexpr #1-\xint_c_viii.{#200000000}%
-}%
-\def\XINT_dsx_exita
- \expandafter\XINT_dsx_zeroloop\the\numexpr #1-\xint_c_viii.#2%
-{%
- \expandafter\expandafter\expandafter
- \XINT_dsx_addzeros\csname xint_gobble_\expandafter
- \romannumeral\numexpr \xint_c_viii-(#1)\endcsname #2%
-}%
-\def\XINT_dsx_addzeros #1\Z #2{ #2#1}%
-\def\XINT_dsx_xisPos #1\Z #2%
-{%
- \XINT_dsx_checksignA #2\Z {#1}%
-}%
-\def\XINT_dsx_checksignA #1%
-{%
\xint_UDzerominusfork
- #1-\XINT_dsx_AisZero
- 0#1\XINT_dsx_AisNeg
- 0-{\XINT_dsx_AisPos #1}%
- \krof
+ #2-\XINT_dsx_AisZero
+ 0#2\XINT_dsx_AisNeg
+ 0-\XINT_dsx_AisPos
+ \krof #1.#2%
}%
-\def\XINT_dsx_AisZero #1\Z #2{{0}{0}}%
-\def\XINT_dsx_AisNeg #1\Z #2%
+\def\XINT_dsx_AisZero #1;{{0}{0}}%
+\def\XINT_dsx_AisNeg #1.-#2;%
{%
\expandafter\XINT_dsx_AisNeg_checkiffirstempty
- \romannumeral0\XINT_split_xfork #2.#1\W\W\W\W\W\W\W\W\Z
+ \romannumeral0\XINT_split_xfork #1.#2\xint_bye2345678\xint_bye..%
}%
\def\XINT_dsx_AisNeg_checkiffirstempty #1%
{%
@@ -1059,10 +1000,10 @@
\expandafter\XINT_dsx_end
\expandafter {\romannumeral0\XINT_num {#2}}{-#1}%
}%
-\def\XINT_dsx_AisPos #1\Z #2%
+\def\XINT_dsx_AisPos #1.#2;%
{%
\expandafter\XINT_dsx_AisPos_finish
- \romannumeral0\XINT_split_xfork #2.#1\W\W\W\W\W\W\W\W\Z
+ \romannumeral0\XINT_split_xfork #1.#2\xint_bye2345678\xint_bye..%
}%
\def\XINT_dsx_AisPos_finish #1.#2.%
{%
@@ -1076,7 +1017,8 @@
{%
\expandafter\XINT_split_finish
\romannumeral0\expandafter\XINT_split_xfork
- \the\numexpr #1\expandafter.\romannumeral0\xintiiabs {#2}\W\W\W\W\W\W\W\W\Z
+ \the\numexpr #1\expandafter.\romannumeral`&&@#2%
+ \xint_bye2345678\xint_bye..%
}%
\def\xintDecSplitL {\romannumeral0\xintdecsplitl }%
\def\xintdecsplitl #1#2%
@@ -1083,7 +1025,8 @@
{%
\expandafter\XINT_splitl_finish
\romannumeral0\expandafter\XINT_split_xfork
- \the\numexpr #1\expandafter.\romannumeral0\xintiiabs {#2}\W\W\W\W\W\W\W\W\Z
+ \the\numexpr #1\expandafter.\romannumeral`&&@#2%
+ \xint_bye2345678\xint_bye..%
}%
\def\xintDecSplitR {\romannumeral0\xintdecsplitr }%
\def\xintdecsplitr #1#2%
@@ -1090,11 +1033,12 @@
{%
\expandafter\XINT_splitr_finish
\romannumeral0\expandafter\XINT_split_xfork
- \the\numexpr #1\expandafter.\romannumeral0\xintiiabs {#2}\W\W\W\W\W\W\W\W\Z
+ \the\numexpr #1\expandafter.\romannumeral`&&@#2%
+ \xint_bye2345678\xint_bye..%
}%
\def\XINT_split_finish #1.#2.{{#1}{#2}}%
-\def\XINT_splitl_finish #1.#2.{{#1}}%
-\def\XINT_splitr_finish #1.#2.{{#2}}%
+\def\XINT_splitl_finish #1.#2.{ #1}%
+\def\XINT_splitr_finish #1.#2.{ #2}%
\def\XINT_split_xfork #1%
{%
\xint_UDzerominusfork
@@ -1103,108 +1047,63 @@
0-{\XINT_split_fromright #1}%
\krof
}%
-\def\XINT_split_zerosplit #1.#2\W\W\W\W\W\W\W\W\Z{ #2..}%
-\def\XINT_split_fromleft #1.%#2\W\W\W\W\W\W\W\W\Z
+\def\XINT_split_zerosplit .#1\xint_bye#2\xint_bye..{ #1..}%
+\def\XINT_split_fromleft
+ {\expandafter\XINT_split_fromleft_a\the\numexpr\xint_c_viii-}%
+\def\XINT_split_fromleft_a #1%
{%
- \XINT_split_fromleft_loop #1.{}%#2\W\W\W\W\W\W\W\W\Z
+ \xint_UDsignfork
+ #1\XINT_split_fromleft_b
+ -{\XINT_split_fromleft_end_a #1}%
+ \krof
}%
-\def\XINT_split_fromleft_loop #1.%
+\def\XINT_split_fromleft_b #1.#2#3#4#5#6#7#8#9%
{%
- \ifnum #1<\xint_c_viii\expandafter\XINT_split_fromleft_exita\fi
- \expandafter\XINT_split_fromleft_loop_perhaps
- \the\numexpr #1-\xint_c_viii\expandafter.\XINT_split_fromleft_eight
+ \expandafter\XINT_split_fromleft_clean
+ \the\numexpr1#2#3#4#5#6#7#8#9\expandafter
+ \XINT_split_fromleft_a\the\numexpr\xint_c_viii-#1.%
}%
-\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%
+\def\XINT_split_fromleft_end_a #1.%
{%
- \xint_gob_til_W #2\XINT_split_fromleft_toofar\W
- \XINT_split_fromleft_loop #1.%
+ \expandafter\XINT_split_fromleft_clean
+ \the\numexpr1\csname XINT_split_fromleft_end#1\endcsname
}%
-\def\XINT_split_fromleft_toofar\W\XINT_split_fromleft_loop #1.#2#3\Z
+\def\XINT_split_fromleft_clean 1{ }%
+\expandafter\def\csname XINT_split_fromleft_end7\endcsname #1%
+ {#1\XINT_split_fromleft_end_b}%
+\expandafter\def\csname XINT_split_fromleft_end6\endcsname #1#2%
+ {#1#2\XINT_split_fromleft_end_b}%
+\expandafter\def\csname XINT_split_fromleft_end5\endcsname #1#2#3%
+ {#1#2#3\XINT_split_fromleft_end_b}%
+\expandafter\def\csname XINT_split_fromleft_end4\endcsname #1#2#3#4%
+ {#1#2#3#4\XINT_split_fromleft_end_b}%
+\expandafter\def\csname XINT_split_fromleft_end3\endcsname #1#2#3#4#5%
+ {#1#2#3#4#5\XINT_split_fromleft_end_b}%
+\expandafter\def\csname XINT_split_fromleft_end2\endcsname #1#2#3#4#5#6%
+ {#1#2#3#4#5#6\XINT_split_fromleft_end_b}%
+\expandafter\def\csname XINT_split_fromleft_end1\endcsname #1#2#3#4#5#6#7%
+ {#1#2#3#4#5#6#7\XINT_split_fromleft_end_b}%
+\expandafter\def\csname XINT_split_fromleft_end0\endcsname #1#2#3#4#5#6#7#8%
+ {#1#2#3#4#5#6#7#8\XINT_split_fromleft_end_b}%
+\def\XINT_split_fromleft_end_b #1\xint_bye#2\xint_bye.{.#1}% puis .
+\def\XINT_split_fromright #1.#2\xint_bye
{%
- \XINT_split_fromleft_toofar_b #2\Z
+ \expandafter\XINT_split_fromright_a
+ \the\numexpr#1-\numexpr\xint_c_ix\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ .#2\xint_bye
}%
-\def\XINT_split_fromleft_toofar_b #1\W #2\Z { #1..}%
-\def\XINT_split_fromleft_exita
- \expandafter\XINT_split_fromleft_loop_perhaps
- \the\numexpr #1-\xint_c_viii\expandafter.\XINT_split_fromleft_eight
+\def\XINT_split_fromright_a #1%
{%
- \csname XINT_split_fromleft_endsplit_\romannumeral #1\endcsname
+ \xint_UDsignfork
+ #1\XINT_split_fromleft
+ -\XINT_split_fromright_Lempty
+ \krof
}%
-\def\XINT_split_fromleft_endsplit_ #1#2\W #3\Z { #1.#2.}%
-\def\XINT_split_fromleft_endsplit_i #1#2%
- {\XINT_split_fromleft_checkiftoofar #2{#1#2}}%
-\def\XINT_split_fromleft_endsplit_ii #1#2#3%
- {\XINT_split_fromleft_checkiftoofar #3{#1#2#3}}%
-\def\XINT_split_fromleft_endsplit_iii #1#2#3#4%
- {\XINT_split_fromleft_checkiftoofar #4{#1#2#3#4}}%
-\def\XINT_split_fromleft_endsplit_iv #1#2#3#4#5%
- {\XINT_split_fromleft_checkiftoofar #5{#1#2#3#4#5}}%
-\def\XINT_split_fromleft_endsplit_v #1#2#3#4#5#6%
- {\XINT_split_fromleft_checkiftoofar #6{#1#2#3#4#5#6}}%
-\def\XINT_split_fromleft_endsplit_vi #1#2#3#4#5#6#7%
- {\XINT_split_fromleft_checkiftoofar #7{#1#2#3#4#5#6#7}}%
-\def\XINT_split_fromleft_endsplit_vii #1#2#3#4#5#6#7#8%
- {\XINT_split_fromleft_checkiftoofar #8{#1#2#3#4#5#6#7#8}}%
-\def\XINT_split_fromleft_checkiftoofar #1#2#3\W #4\Z
-{%
- \xint_gob_til_W #1\XINT_split_fromleft_wenttoofar\W \space#2.#3.%
-}%
-\def\XINT_split_fromleft_wenttoofar\W\space #1.%
-{%
- \XINT_split_fromleft_wenttoofar_b #1\Z
-}%
-\def\XINT_split_fromleft_wenttoofar_b #1\W #2\Z { #1.}%
-\def\XINT_split_fromright #1.#2\W\W\W\W\W\W\W\W\Z
-{%
- \expandafter\XINT_split_fromright_loop
- \the\numexpr #1\expandafter.\expandafter{\expandafter}%
- \romannumeral0\xintreverseorder{#2}\W\W\W\W\W\W\W\W\Z #2.%
-}%
-\def\XINT_split_fromright_loop #1.%
-{%
- \ifnum #1<\xint_c_viii\expandafter\XINT_split_fromright_exita\fi
- \expandafter\XINT_split_fromright_loop_perhaps
- \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%
-{%
- \xint_gob_til_W #2\XINT_split_fromright_toofar\W
- \XINT_split_fromright_loop #1.%
-}%
-\def\XINT_split_fromright_toofar\W\XINT_split_fromright_loop #1\Z {.}%
-\def\XINT_split_fromright_exita
- \expandafter\XINT_split_fromright_loop_perhaps
- \the\numexpr #1-\xint_c_viii\expandafter.\XINT_split_fromright_eight
-{%
- \csname XINT_split_fromright_endsplit_\romannumeral #1\endcsname
-}%
-\def\XINT_split_fromright_endsplit_ #1#2\W #3\Z #4.%
-{%
- \xintreverseorder {#2}.#1.%
-}%
-\def\XINT_split_fromright_endsplit_i #1#2%
- {\XINT_split_fromright_checkiftoofar #2{#2#1}}%
-\def\XINT_split_fromright_endsplit_ii #1#2#3%
- {\XINT_split_fromright_checkiftoofar #3{#3#2#1}}%
-\def\XINT_split_fromright_endsplit_iii #1#2#3#4%
- {\XINT_split_fromright_checkiftoofar #4{#4#3#2#1}}%
-\def\XINT_split_fromright_endsplit_iv #1#2#3#4#5%
- {\XINT_split_fromright_checkiftoofar #5{#5#4#3#2#1}}%
-\def\XINT_split_fromright_endsplit_v #1#2#3#4#5#6%
- {\XINT_split_fromright_checkiftoofar #6{#6#5#4#3#2#1}}%
-\def\XINT_split_fromright_endsplit_vi #1#2#3#4#5#6#7%
- {\XINT_split_fromright_checkiftoofar #7{#7#6#5#4#3#2#1}}%
-\def\XINT_split_fromright_endsplit_vii #1#2#3#4#5#6#7#8%
- {\XINT_split_fromright_checkiftoofar #8{#8#7#6#5#4#3#2#1}}%
-\def\XINT_split_fromright_checkiftoofar #1%
-{%
- \xint_gob_til_W #1\XINT_split_fromright_wenttoofar\W
- \XINT_split_fromright_endsplit_
-}%
-\def\XINT_split_fromright_wenttoofar\W
- \XINT_split_fromright_endsplit_ #1\Z {.}%
+\def\XINT_split_fromright_Lempty #1.#2\xint_bye#3..{.#2.}%
\def\xintiiSqrt {\romannumeral0\xintiisqrt }%
\def\xintiiSqrtR {\romannumeral0\xintiisqrtr }%
\def\xintiiSquareRoot {\romannumeral0\xintiisquareroot }%
@@ -1213,11 +1112,12 @@
\def\xintisqrt {\expandafter\XINT_sqrt_post\romannumeral0\xintisquareroot }%
\def\xintiisqrt {\expandafter\XINT_sqrt_post\romannumeral0\xintiisquareroot }%
\def\xintiisqrtr {\expandafter\XINT_sqrtr_post\romannumeral0\xintiisquareroot }%
-\def\XINT_sqrt_post #1#2{\XINT_dec_pos #1\Z }%
-\def\XINT_sqrtr_post #1#2{\xintiiifLt {#2}{#1}{ #1}{\XINT_dec_pos #1\Z}}%
+\def\XINT_sqrt_post #1#2{\XINT_dec #1\XINT_dec_bye234567890\xint_bye}%
+\def\XINT_sqrtr_post #1#2{\xintiiifLt {#2}{#1}%
+ { #1}{\XINT_dec #1\XINT_dec_bye234567890\xint_bye}}%
\def\xintisquareroot #1%
- {\expandafter\XINT_sqrt_checkin\romannumeral0\xintnum{#1}\Z }%
-\def\xintiisquareroot #1{\expandafter\XINT_sqrt_checkin\romannumeral`&&@#1\Z }%
+ {\expandafter\XINT_sqrt_checkin\romannumeral0\xintnum{#1}\xint_relax }%
+\def\xintiisquareroot #1{\expandafter\XINT_sqrt_checkin\romannumeral`&&@#1\xint_relax }%
\def\XINT_sqrt_checkin #1%
{%
\xint_UDzerominusfork
@@ -1226,9 +1126,9 @@
0-{\XINT_sqrt #1}%
\krof
}%
-\def\XINT_sqrt_iszero #1\Z { 11}%
-\edef\XINT_sqrt_isneg #1\Z {\noexpand\xintError:RootOfNegative\space 11}%
-\def\XINT_sqrt #1\Z
+\def\XINT_sqrt_iszero #1\xint_relax { 11}%
+\edef\XINT_sqrt_isneg #1\xint_relax {\noexpand\xintError:RootOfNegative\space 11}%
+\def\XINT_sqrt #1\xint_relax
{%
\expandafter\XINT_sqrt_start\romannumeral0\xintlength {#1}.#1.%
}%
@@ -1415,13 +1315,13 @@
}%
\def\XINT_sqrt_big_gi #1.%
{%
- \expandafter\XINT_sqrt_big_gj
- \romannumeral0\XINT_dsx_addzerosnofuss{#1}{}.#1.%
+ \expandafter\XINT_sqrt_big_gj\romannumeral\xintreplicate{#1}0.#1.%
}%
\def\XINT_sqrt_big_gj #1.#2.#3.#4.#5.%
{%
\expandafter\XINT_sqrt_big_gk
- \romannumeral0\xintiidivision {#4#1}{\XINT_dbl_pos #5\Z}.%
+ \romannumeral0\xintiidivision {#4#1}%
+ {\XINT_dbl #5\xint_bye2345678\xint_bye*\xint_c_ii\relax}.%
#1.#5.#2.#3.%
}%
\def\XINT_sqrt_big_gk #1#2.#3.#4.%
@@ -1437,8 +1337,7 @@
\def\XINT_sqrt_big_gm #1.#2.#3.#4.#5.%
{%
\expandafter\XINT_sqrt_big_gn
- \romannumeral0\expandafter\XINT_split_fromleft_loop
- \the\numexpr\xint_c_ii*#3.{}#5\W\W\W\W\W\W\W\W\Z
+ \romannumeral0\XINT_split_fromleft\xint_c_ii*#3.#5\xint_bye2345678\xint_bye..%
#1.#2.#3.#4.%
}%
\def\XINT_sqrt_big_gn #1.#2.#3.#4.#5.#6.%
@@ -1451,9 +1350,9 @@
\def\XINT_sqrt_big_ka #1.#2.#3.#4.%
{%
\expandafter\XINT_sqrt_big_kb
- \romannumeral0\XINT_dsx_addzerosnofuss {#1}{#3}.%
+ \romannumeral0\XINT_dsx_addzeros {#1}#3;.%
\romannumeral0\xintiisub
- {\XINT_dsx_addzerosnofuss {\numexpr\xint_c_ii*#1}{#2}}%
+ {\XINT_dsx_addzerosnofuss {\xint_c_ii*#1}#2;}%
{\xintiNum{#4}}.%
}%
\def\XINT_sqrt_big_kb #1.#2.%
@@ -1468,7 +1367,8 @@
\def\XINT_sqrt_big_kz 0.#1.%
{%
\expandafter\XINT_sqrt_big_kend
- \romannumeral0\xintinc{\XINT_dbl_pos #1\Z}.#1.%
+ \romannumeral0%
+ \xintinc{\XINT_dbl#1\xint_bye2345678\xint_bye*\xint_c_ii\relax}.#1.%
}%
\def\XINT_sqrt_big_kend #1.#2.%
{%
@@ -1477,7 +1377,8 @@
\def\XINT_sqrt_big_kloop #1.#2.%
{%
\expandafter\XINT_sqrt_big_ke
- \romannumeral0\xintiidivision{#1}{\romannumeral0\XINT_dbl_pos #2\Z}{#2}%
+ \romannumeral0\xintiidivision{#1}%
+ {\romannumeral0\XINT_dbl #2\xint_bye2345678\xint_bye*\xint_c_ii\relax}{#2}%
}%
\def\XINT_sqrt_big_ke #1%
{%
@@ -1887,9 +1788,17 @@
}%
\def\xintiiE {\romannumeral0\xintiie }% used in \xintMod.
\def\xintiie #1#2%
- {\expandafter\XINT_iie\the\numexpr #2\expandafter.\expandafter{\romannumeral`&&@#1}}%
-\def\XINT_iie #1.#2{\ifnum#1>\xint_c_ \xint_dothis{\xint_dsh {#2}{-#1}}\fi
- \xint_orthat{ #2}}%
+ {\expandafter\XINT_iie_fork\the\numexpr #2\expandafter.\romannumeral`&&@#1;}%
+\def\XINT_iie_fork #1%
+{%
+ \xint_UDsignfork
+ #1\XINT_iie_neg
+ -\XINT_iie_a
+ \krof #1%
+}%
+\def\XINT_iie_a #1.%
+ {\expandafter\XINT_dsx_append\romannumeral\XINT_rep #1\endcsname 0.}%
+\def\XINT_iie_neg #1.#2;{ #2}%
\catcode`! 11
\def\xintMax {\Did_you_mean_iiMax?or_load_xintfrac!}%
\def\xintMin {\Did_you_mean_iiMin?or_load_xintfrac!}%
Modified: trunk/Master/texmf-dist/tex/generic/xint/xintbinhex.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/xint/xintbinhex.sty 2016-12-13 22:24:48 UTC (rev 42697)
+++ trunk/Master/texmf-dist/tex/generic/xint/xintbinhex.sty 2016-12-13 22:25:04 UTC (rev 42698)
@@ -21,7 +21,7 @@
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% ---------------------------------------------------------------
-%% The xint bundle 1.2h 2016/11/20
+%% The xint bundle 1.2i 2016/12/13
%% Copyright (C) 2013-2016 by Jean-Francois Burnol
%% xintbinhex: Expandable binary and hexadecimal conversions
%% ---------------------------------------------------------------
@@ -70,7 +70,7 @@
\XINTsetupcatcodes% defined in xintkernel.sty
\XINT_providespackage
\ProvidesPackage{xintbinhex}%
- [2016/11/20 1.2h Expandable binary and hexadecimal conversions (JFB)]%
+ [2016/12/13 1.2i Expandable binary and hexadecimal conversions (JFB)]%
\newcount\xint_c_ii^xv \xint_c_ii^xv 32768
\newcount\xint_c_ii^xvi \xint_c_ii^xvi 65536
\newcount\xint_c_x^v \xint_c_x^v 100000
Modified: trunk/Master/texmf-dist/tex/generic/xint/xintcfrac.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/xint/xintcfrac.sty 2016-12-13 22:24:48 UTC (rev 42697)
+++ trunk/Master/texmf-dist/tex/generic/xint/xintcfrac.sty 2016-12-13 22:25:04 UTC (rev 42698)
@@ -21,7 +21,7 @@
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% ---------------------------------------------------------------
-%% The xint bundle 1.2h 2016/11/20
+%% The xint bundle 1.2i 2016/12/13
%% Copyright (C) 2013-2016 by Jean-Francois Burnol
%% xintcfrac: Expandable continued fractions with xint package
%% ---------------------------------------------------------------
@@ -70,7 +70,7 @@
\XINTsetupcatcodes% defined in xintkernel.sty
\XINT_providespackage
\ProvidesPackage{xintcfrac}%
- [2016/11/20 1.2h Expandable continued fractions with xint package (JFB)]%
+ [2016/12/13 1.2i Expandable continued fractions with xint package (JFB)]%
\def\xintCFrac {\romannumeral0\xintcfrac }%
\def\xintcfrac #1%
{%
Modified: trunk/Master/texmf-dist/tex/generic/xint/xintcore.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/xint/xintcore.sty 2016-12-13 22:24:48 UTC (rev 42697)
+++ trunk/Master/texmf-dist/tex/generic/xint/xintcore.sty 2016-12-13 22:25:04 UTC (rev 42698)
@@ -21,7 +21,7 @@
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% ---------------------------------------------------------------
-%% The xint bundle 1.2h 2016/11/20
+%% The xint bundle 1.2i 2016/12/13
%% Copyright (C) 2013-2016 by Jean-Francois Burnol
%% xintcore: Expandable arithmetic on big integers
%% ---------------------------------------------------------------
@@ -70,7 +70,7 @@
\XINTsetupcatcodes% defined in xintkernel.sty
\XINT_providespackage
\ProvidesPackage{xintcore}%
- [2016/11/20 1.2h Expandable arithmetic on big integers (JFB)]%
+ [2016/12/13 1.2i Expandable arithmetic on big integers (JFB)]%
\ifdefined\m at ne\let\xint_c_mone\m at ne
\else\csname newcount\endcsname\xint_c_mone \xint_c_mone -1 \fi
\newcount\xint_c_x^viii \xint_c_x^viii 100000000
@@ -358,7 +358,6 @@
{%
\expandafter\XINT_abs \romannumeral0\xintnum{#1}%
}%
-\def\XINT_Abs #1{\romannumeral0\XINT_abs #1}%
\def\XINT_abs #1%
{%
\xint_UDsignfork
@@ -385,143 +384,129 @@
0-{ #1}% positive
\krof
}%
-\def\xintLDg {\romannumeral0\xintldg }%
-\def\xintldg #1{\xintiildg {\xintNum{#1}}}%
+\def\xintLDg {\romannumeral0\xintldg }%
+\def\xintldg #1{\expandafter\XINT_ldg_fork\romannumeral0\xintnum{#1}%
+ \XINT_ldg_c{}{}{}{}{}{}{}{}\xint_bye\relax}%
\def\xintiiLDg {\romannumeral0\xintiildg }%
-\def\xintiildg #1%
+\def\xintiildg #1{\expandafter\XINT_ldg_fork\romannumeral`&&@#1%
+ \XINT_ldg_c{}{}{}{}{}{}{}{}\xint_bye\relax}%
+\def\XINT_ldg_fork #1%
{%
- \expandafter\XINT_ldg_done\romannumeral0%
- \expandafter\XINT_revdigits_a\the\numexpr\expandafter\XINT_microrevsep
- \romannumeral0\expandafter\XINT_abs
- \romannumeral`&&@#1{\XINT_microrevsep_end\W}\XINT_microrevsep_end
- \XINT_microrevsep_end\XINT_microrevsep_end
- \XINT_microrevsep_end\XINT_microrevsep_end
- \XINT_microrevsep_end\XINT_microrevsep_end\Z
- 1\Z!1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W
- \Z
+ \xint_UDsignfork
+ #1\XINT_ldg
+ -{\XINT_ldg#1}%
+ \krof
}%
-\def\XINT_ldg_done #1#2\Z { #1}%
-\def\xintDouble {\romannumeral0\xintdouble }%
-\def\xintdouble #1%
+\edef\XINT_ldg #1#2#3#4#5#6#7#8#9%
+ {\noexpand\expandafter\space
+ \noexpand\the\numexpr#9#8#7#6#5#4#3#2#1*\xint_c_+\noexpand\XINT_ldg_a#9}%
+\def\XINT_ldg_a#1#2{\XINT_ldg_cbye#2\XINT_ldg_d#1\XINT_ldg_c\XINT_ldg_b#2}%
+\def\XINT_ldg_b#1#2#3#4#5#6#7#8#9{#9#8#7#6#5#4#3#2#1*\xint_c_+\XINT_ldg_a#9}%
+\def\XINT_ldg_c #1#2\xint_bye{#1}%
+\def\XINT_ldg_cbye #1\XINT_ldg_c{}%
+\def\XINT_ldg_d#1#2\xint_bye{#1}%
+\def\xintDouble {\romannumeral0\xintdouble}%
+\def\xintdouble #1{\expandafter\XINT_dbl\romannumeral`&&@#1%
+ \xint_bye2345678\xint_bye*\xint_c_ii\relax}%
+\def\XINT_dbl #1#2#3#4#5#6#7#8%
+ {\expandafter\space\the\numexpr#1#2#3#4#5#6#7#8\XINT_dbl_a}%
+\def\XINT_dbl_a #1#2#3#4#5#6#7#8%
+ {\expandafter\XINT_dbl_e\the\numexpr 1#1#2#3#4#5#6#7#8\XINT_dbl_a}%
+\def\XINT_dbl_e#1{*\xint_c_ii\if#13+\xint_c_i\fi\relax}%
+\def\xintHalf {\romannumeral0\xinthalf}%
+\def\xinthalf #1{\expandafter\XINT_half_fork\romannumeral`&&@#1%
+ \xint_bye\xint_Bye345678\xint_bye
+ *\xint_c_v+\xint_c_v)/\xint_c_x-\xint_c_i\relax}%
+\def\XINT_half_fork #1%
{%
- \expandafter\XINT_dbl\romannumeral`&&@#1\Z
+ \xint_UDsignfork
+ #1\XINT_half_neg
+ -{\XINT_half #1}%
+ \krof
}%
-\def\XINT_dbl #1%
+\def\XINT_half_neg{\xintiiopp\XINT_half}%
+\def\XINT_half #1#2#3#4#5#6#7#8%
+ {\expandafter\space\the\numexpr(#1#2#3#4#5#6#7#8\XINT_half_a}%
+\def\XINT_half_a#1{\xint_Bye#1\xint_bye\XINT_half_b#1}%
+\def\XINT_half_b #1#2#3#4#5#6#7#8%
+ {\expandafter\XINT_half_e\the\numexpr(1#1#2#3#4#5#6#7#8\XINT_half_a}%
+\def\XINT_half_e#1{*\xint_c_v+#1-\xint_c_v)\relax}%
+\def\xintInc {\romannumeral0\xintinc}%
+\def\xintinc #1{\expandafter\XINT_inc_fork\romannumeral`&&@#1%
+ \xint_bye23456789\xint_bye+\xint_c_i\relax}%
+\def\XINT_inc_fork #1%
{%
- \xint_UDzerominusfork
- #1-\XINT_dbl_zero
- 0#1\XINT_dbl_neg
- 0-{\XINT_dbl_pos #1}%
+ \xint_UDsignfork
+ #1\XINT_inc_neg
+ -{\XINT_inc #1}%
\krof
}%
-\def\XINT_dbl_zero #1\Z { 0}%
-\def\XINT_dbl_neg
- {\expandafter-\romannumeral0\XINT_dbl_pos }%
-\def\XINT_dbl_pos #1\Z
+\def\XINT_inc_neg #1\xint_bye#2\relax
+ {\xintiiopp\XINT_dec #1\XINT_dec_bye234567890\xint_bye}%
+\def\XINT_inc #1#2#3#4#5#6#7#8#9%
+ {\expandafter\space\the\numexpr#1#2#3#4#5#6#7#8#9\XINT_inc_a}%
+\def\XINT_inc_a #1#2#3#4#5#6#7#8#9%
+ {\expandafter\XINT_inc_e\the\numexpr 1#1#2#3#4#5#6#7#8#9\XINT_inc_a}%
+\def\XINT_inc_e#1{\if#12+\xint_c_i\fi\relax}%
+\def\xintDec {\romannumeral0\xintdec}%
+\def\xintdec #1{\expandafter\XINT_dec_fork\romannumeral`&&@#1%
+ \XINT_dec_bye234567890\xint_bye}%
+\def\XINT_dec_fork #1%
{%
- \expandafter\XINT_dbl_pos_aa
- \romannumeral0\expandafter\XINT_sepandrev
- \romannumeral0\XINT_zeroes_forviii #1\R\R\R\R\R\R\R\R{10}0000001\W
- #1\XINT_rsepbyviii_end_A 2345678%
- \XINT_rsepbyviii_end_B 2345678\relax XX%
- \R.\R.\R.\R.\R.\R.\R.\R.\W 1\Z!%
- 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W
-}%
-\def\XINT_dbl_pos_aa
-{%
- \expandafter\XINT_mul_out\the\numexpr\XINT_verysmallmul 0.2!%
-}%
-\def\xintHalf {\romannumeral0\xinthalf }%
-\def\xinthalf #1%
-{%
- \expandafter\XINT_half\romannumeral`&&@#1\Z
-}%
-\def\XINT_half #1%
-{%
- \xint_UDzerominusfork
- #1-\XINT_half_zero
- 0#1\XINT_half_neg
- 0-{\XINT_half_pos #1}%
+ \xint_UDsignfork
+ #1\XINT_dec_neg
+ -{\XINT_dec #1}%
\krof
}%
-\def\XINT_half_zero #1\Z { 0}%
-\def\XINT_half_neg {\expandafter\XINT_opp\romannumeral0\XINT_half_pos }%
-\def\XINT_half_pos #1\Z
+\def\XINT_dec_neg #1\XINT_dec_bye#2\xint_bye
+ {\expandafter-%
+ \romannumeral0\XINT_inc #1\xint_bye23456789\xint_bye+\xint_c_i\relax}%
+\def\XINT_dec #1#2#3#4#5#6#7#8#9%
+ {\expandafter\space\the\numexpr#1#2#3#4#5#6#7#8#9\XINT_dec_a}%
+\def\XINT_dec_a #1#2#3#4#5#6#7#8#9%
+ {\expandafter\XINT_dec_e\the\numexpr 1#1#2#3#4#5#6#7#8#9\XINT_dec_a}%
+\def\XINT_dec_bye #1\XINT_dec_a#2#3\xint_bye
+ {\if#20-\xint_c_ii\relax+\else-\fi\xint_c_i\relax}%
+\def\XINT_dec_e#1{\unless\if#11\xint_dothis{-\xint_c_i#1}\fi\xint_orthat\relax}%
+\def\xintDSL {\romannumeral0\xintdsl }%
+\def\xintdsl #1{\expandafter\XINT_dsl\romannumeral`&&@#10}%
+\edef\XINT_dsl #1%
+ {\noexpand\xint_gob_til_zero #1\noexpand\xint_dsl_zero 0\space #1}%
+\def\xint_dsl_zero 0 0{ }%
+\def\xintDSR{\romannumeral0\xintdsr}%
+\def\xintdsr #1{\expandafter\XINT_dsr_fork\romannumeral`&&@#1%
+ \xint_bye\xint_Bye3456789\xint_bye+\xint_c_v)/\xint_c_x-\xint_c_i\relax}%
+\def\XINT_dsr_fork #1%
{%
- \expandafter\XINT_half_pos_a
- \romannumeral0\expandafter\XINT_sepandrev
- \romannumeral0\XINT_zeroes_forviii #1\R\R\R\R\R\R\R\R{10}0000001\W
- #1\XINT_rsepbyviii_end_A 2345678%
- \XINT_rsepbyviii_end_B 2345678\relax XX%
- \R.\R.\R.\R.\R.\R.\R.\R.\W
- 1\Z!%
- 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W
-}%
-\def\XINT_half_pos_a
- {\expandafter\XINT_half_pos_b\the\numexpr\XINT_verysmallmul 0.5!}%
-\def\XINT_half_pos_b 1#1#2#3#4#5#6#7#8!1#9%
-{%
- \xint_gob_til_Z #9\XINT_half_small \Z
- \XINT_mul_out 1#1#2#3#4#5#6#7!1#9%
-}%
-\edef\XINT_half_small \Z\XINT_mul_out 1#1!#2\W
-{%
- \noexpand\expandafter\space\noexpand\the\numexpr #1\relax
-}%
-\def\xintDec {\romannumeral0\xintdec }%
-\def\xintdec #1%
-{%
- \expandafter\XINT_dec\romannumeral`&&@#1\Z
-}%
-\def\XINT_dec #1%
-{%
- \xint_UDzerominusfork
- #1-\XINT_dec_zero
- 0#1\XINT_dec_neg
- 0-{\XINT_dec_pos #1}%
+ \xint_UDsignfork
+ #1\XINT_dsr_neg
+ -{\XINT_dsr #1}%
\krof
}%
-\def\XINT_dec_zero #1\Z {-1}%
-\def\XINT_dec_neg
- {\expandafter-\romannumeral0\XINT_inc_pos }%
-\def\XINT_dec_pos #1\Z
+\def\XINT_dsr_neg{\xintiiopp\XINT_dsr}%
+\def\XINT_dsr #1#2#3#4#5#6#7#8#9%
+ {\expandafter\space\the\numexpr(#1#2#3#4#5#6#7#8#9\XINT_dsr_a}%
+\def\XINT_dsr_a#1{\xint_Bye#1\xint_bye\XINT_dsr_b#1}%
+\def\XINT_dsr_b #1#2#3#4#5#6#7#8#9%
+ {\expandafter\XINT_dsr_e\the\numexpr(1#1#2#3#4#5#6#7#8#9\XINT_dsr_a}%
+\def\XINT_dsr_e #1{)\relax}%
+\def\xintDSRr{\romannumeral0\xintdsrr}%
+\def\xintdsrr #1{\expandafter\XINT_dsrr_fork\romannumeral`&&@#1%
+ \xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax}%
+\def\XINT_dsrr_fork #1%
{%
- \expandafter\XINT_dec_pos_aa
- \romannumeral0\expandafter\XINT_sepandrev
- \romannumeral0\XINT_zeroes_forviii #1\R\R\R\R\R\R\R\R{10}0000001\W
- #1\XINT_rsepbyviii_end_A 2345678%
- \XINT_rsepbyviii_end_B 2345678\relax XX%
- \R.\R.\R.\R.\R.\R.\R.\R.\W
- \Z!\Z!\Z!\Z!\W
-}%
-\def\XINT_dec_pos_aa {\XINT_sub_aa 100000001!\Z!\Z!\Z!\Z!\W }%
-\def\xintInc {\romannumeral0\xintinc }%
-\def\xintinc #1%
-{%
- \expandafter\XINT_inc\romannumeral`&&@#1\Z
-}%
-\def\XINT_inc #1%
-{%
- \xint_UDzerominusfork
- #1-\XINT_inc_zero
- 0#1\XINT_inc_neg
- 0-{\XINT_inc_pos #1}%
+ \xint_UDsignfork
+ #1\XINT_dsrr_neg
+ -{\XINT_dsrr #1}%
\krof
}%
-\def\XINT_inc_zero #1\Z { 1}%
-\def\XINT_inc_neg {\expandafter\XINT_opp\romannumeral0\XINT_dec_pos }%
-\def\XINT_inc_pos #1\Z
-{%
- \expandafter\XINT_inc_pos_aa
- \romannumeral0\expandafter\XINT_sepandrev
- \romannumeral0\XINT_zeroes_forviii #1\R\R\R\R\R\R\R\R{10}0000001\W
- #1\XINT_rsepbyviii_end_A 2345678%
- \XINT_rsepbyviii_end_B 2345678\relax XX%
- \R.\R.\R.\R.\R.\R.\R.\R.\W
- 1\Z!1\Z!1\Z!1\Z!\W
- 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W
-}%
-\def\XINT_inc_pos_aa {\XINT_add_aa 100000001!1\Z!1\Z!1\Z!1\Z!\W }%
+\def\XINT_dsrr_neg{\xintiiopp\XINT_dsrr}%
+\def\XINT_dsrr #1#2#3#4#5#6#7#8#9%
+ {\expandafter\space\the\numexpr#1#2#3#4#5#6#7#8#9\XINT_dsrr_a}%
+\def\XINT_dsrr_a#1{\xint_Bye#1\xint_bye\XINT_dsrr_b#1}%
+\def\XINT_dsrr_b #1#2#3#4#5#6#7#8#9%
+ {\expandafter\XINT_dsrr_e\the\numexpr1#1#2#3#4#5#6#7#8#9\XINT_dsrr_a}%
+\let\XINT_dsrr_e\XINT_inc_e
\def\xintiAdd {\romannumeral0\xintiadd }%
\def\xintiadd #1{\expandafter\XINT_iadd\romannumeral0\xintnum{#1}\Z }%
\def\xintiiAdd {\romannumeral0\xintiiadd }%
@@ -1334,8 +1319,8 @@
\def\xintiRem {\romannumeral0\xintirem }%
\def\xintiquo {\expandafter\xint_firstoftwo_thenstop\romannumeral0\xintidivision }%
\def\xintirem {\expandafter\xint_secondoftwo_thenstop\romannumeral0\xintidivision }%
-\let\xintQuo\xintiQuo\let\xintquo\xintiquo % deprecated
-\let\xintRem\xintiRem\let\xintrem\xintirem % deprecated
+%%\let\xintQuo\xintiQuo\let\xintquo\xintiquo % now removed
+%%\let\xintRem\xintiRem\let\xintrem\xintirem % now removed
\def\xintiDivision {\romannumeral0\xintidivision }%
\def\xintidivision #1{\expandafter\XINT_idivision\romannumeral0\xintnum{#1}\Z }%
\def\XINT_idivision #1#2\Z #3{\expandafter\XINT_iidivision_a\expandafter #1%
@@ -1404,11 +1389,13 @@
\def\XINT_div_BisTwo #1#2%
{%
\expandafter\expandafter\expandafter\XINT_div_BisTwo_a
- \ifodd\xintLDg{#2} \expandafter1\else \expandafter0\fi {#2}%
+ \ifodd\xintiiLDg{#2} \expandafter1\else \expandafter0\fi {#2}%
}%
\def\XINT_div_BisTwo_a #1#2%
{%
- \expandafter{\romannumeral0\xinthalf {#2}}{#1}%
+ \expandafter{\romannumeral0\XINT_half
+ #2\xint_bye\xint_Bye345678\xint_bye
+ *\xint_c_v+\xint_c_v)/\xint_c_x-\xint_c_i\relax}{#1}%
}%
\def\XINT_div_small_a #1#2%
{%
@@ -1962,48 +1949,11 @@
}%
\def\XINT_iidivround_pos #1#2\Z #3\Z
{%
- \expandafter\XINT_iidivround_pos_a
+ \expandafter\expandafter\expandafter\XINT_dsrr
+ \expandafter\xint_firstoftwo
\romannumeral0\XINT_div_prepare {#2}{#1#30}%
+ \xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax
}%
-\def\XINT_iidivround_pos_a #1#2%
-{%
- \expandafter\XINT_iidivround_pos_b
- \romannumeral0\expandafter\XINT_sepandrev
- \romannumeral0\XINT_zeroes_forviii #1\R\R\R\R\R\R\R\R{10}0000001\W
- #1\XINT_rsepbyviii_end_A 2345678\XINT_rsepbyviii_end_B 2345678\relax XX%
- \R.\R.\R.\R.\R.\R.\R.\R.\W
- 1\Z!1\Z!1\Z!1\Z!\W\R
-}%
-\def\XINT_iidivround_pos_b 1#1#2#3#4#5#6#7#8!1#9%
-{%
- \xint_gob_til_Z #9\XINT_iidivround_small\Z
- \ifnum #8>\xint_c_iv
- \expandafter\XINT_iidivround_pos_up
- \else \expandafter\XINT_iidivround_pos_finish
- \fi
- 1#1#2#3#4#5#6#70!1#9%
-}%
-\def\XINT_iidivround_pos_up
-{%
- \expandafter\XINT_iidivround_pos_finish
- \the\numexpr\XINT_add_a\xint_c_ii 100000010!1\Z!1\Z!1\Z!1\Z!\W
-}%
-\def\XINT_iidivround_pos_finish #10!#21\Z!#3\R
-{%
- \expandafter\XINT_cuz_small\romannumeral0\XINT_unrevbyviii {}%
- #1!#21\Z!1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W
-}%
-\def\XINT_iidivround_small\Z\ifnum #1>#2\fi 1#30!#4\W\R
-{%
- \ifnum #1>\xint_c_iv
- \expandafter\XINT_iidivround_small_up
- \else \expandafter\XINT_iidivround_small_trunc
- \fi {#3}%
-}%
-\edef\XINT_iidivround_small_up #1%
- {\noexpand\expandafter\space\noexpand\the\numexpr #1+\xint_c_i\relax }%
-\edef\XINT_iidivround_small_trunc #1%
- {\noexpand\expandafter\space\noexpand\the\numexpr #1\relax }%
\def\xintiDivTrunc {\romannumeral0\xintidivtrunc }%
\def\xintidivtrunc #1{\expandafter\XINT_iidivtrunc\romannumeral0\xintnum{#1}\Z }%
\def\xintiiDivTrunc {\romannumeral0\xintiidivtrunc }%
@@ -2072,6 +2022,8 @@
\def\xintMul {\Did_you_mean_iiMul?or_load_xintfrac!}%
\def\xintPow {\Did_you_mean_iiPow?or_load_xintfrac!}%
\def\xintSqr {\Did_you_mean_iiSqr?or_load_xintfrac!}%
+\def\xintQuo {\Removed!use_xintiQuo_or_xintiiQuo!}%
+\def\xintRem {\Removed!use_xintiRem_or_xintiiRem!}%
\XINT_restorecatcodes_endinput%
\endinput
%%
Modified: trunk/Master/texmf-dist/tex/generic/xint/xintexpr.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/xint/xintexpr.sty 2016-12-13 22:24:48 UTC (rev 42697)
+++ trunk/Master/texmf-dist/tex/generic/xint/xintexpr.sty 2016-12-13 22:25:04 UTC (rev 42698)
@@ -21,7 +21,7 @@
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% ---------------------------------------------------------------
-%% The xint bundle 1.2h 2016/11/20
+%% The xint bundle 1.2i 2016/12/13
%% Copyright (C) 2013-2016 by Jean-Francois Burnol
%% xintexpr: Expandable expression parser
%% ---------------------------------------------------------------
@@ -81,7 +81,7 @@
\XINTsetupcatcodes%
\XINT_providespackage
\ProvidesPackage{xintexpr}%
- [2016/11/20 1.2h Expandable expression parser (JFB)]%
+ [2016/12/13 1.2i Expandable expression parser (JFB)]%
\catcode`! 11
\def\xint_gob_til_! #1!{}% catcode 11 ! default in xintexpr.sty code.
\edef\XINT_expr_lockscan#1!% not used for decimal numbers in xintexpr 1.2
Modified: trunk/Master/texmf-dist/tex/generic/xint/xintfrac.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/xint/xintfrac.sty 2016-12-13 22:24:48 UTC (rev 42697)
+++ trunk/Master/texmf-dist/tex/generic/xint/xintfrac.sty 2016-12-13 22:25:04 UTC (rev 42698)
@@ -21,7 +21,7 @@
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% ---------------------------------------------------------------
-%% The xint bundle 1.2h 2016/11/20
+%% The xint bundle 1.2i 2016/12/13
%% Copyright (C) 2013-2016 by Jean-Francois Burnol
%% xintfrac: Expandable operations on fractions
%% ---------------------------------------------------------------
@@ -70,7 +70,7 @@
\XINTsetupcatcodes% defined in xintkernel.sty
\XINT_providespackage
\ProvidesPackage{xintfrac}%
- [2016/11/20 1.2h Expandable operations on fractions (JFB)]%
+ [2016/12/13 1.2i Expandable operations on fractions (JFB)]%
\def\XINT_cntSgnFork #1%
{%
\ifcase #1\expandafter\xint_secondofthree
@@ -86,33 +86,14 @@
\def\XINT_flen #1#2#3%
{%
\expandafter\space
- \the\numexpr -1+\XINT_Abs {#1}+\XINT_Len {#2}+\XINT_Len {#3}\relax
+ \the\numexpr \XINT_abs#1+\xint_c_viii
+ \XINT_length_loop
+ #2#3\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ \relax
}%
-\def\XINT_lenrord_loop #1.#2#3#4#5#6#7#8#9%
-{%
- \xint_gob_til_W #9\XINT_lenrord_W\W
- \expandafter\XINT_lenrord_loop\the\numexpr #1+\xint_c_vii.{#9#8#7#6#5#4#3#2}%
-}%
-\def\XINT_lenrord_W\W\expandafter\XINT_lenrord_loop #1.#2#3\Z
-{%
- \expandafter\XINT_lenrord_X #1.#2\Z
-}%
-\def\XINT_lenrord_X #1.#2\Z
-{%
- \XINT_lenrord_Y #2\R\R\R\R\R\R\T {#1}%
-}%
-\def\XINT_lenrord_Y #1#2#3#4#5#6#7#8\T
-{%
- \xint_gob_til_W
- #7\XINT_lenrord_Z \xint_c_viii
- #6\XINT_lenrord_Z \xint_c_vii
- #5\XINT_lenrord_Z \xint_c_vi
- #4\XINT_lenrord_Z \xint_c_v
- #3\XINT_lenrord_Z \xint_c_iv
- #2\XINT_lenrord_Z \xint_c_iii
- \W\XINT_lenrord_Z \xint_c_ii \Z
-}%
-\def\XINT_lenrord_Z #1#2\Z #3{\the\numexpr #3-#1.}%
\def\XINT_outfrac #1#2#3%
{%
\ifcase\XINT_cntSgn #3\Z
@@ -204,10 +185,13 @@
}%
\def\XINT_frac_gen_Bd #1.#2e#3e#4\XINT_Z
{%
- \expandafter\XINT_frac_gen_C\the\numexpr #3-\romannumeral0\expandafter
- \XINT_length_loop
- 0.#1\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye~#2#1!%
+ \expandafter\XINT_frac_gen_C\the\numexpr #3-%
+ \numexpr\xint_c_ix\XINT_length_loop
+ #1\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ ~#2#1!%
}%
\def\XINT_frac_gen_C #1!#2.#3%
{%
@@ -231,10 +215,12 @@
\def\XINT_frac_gen_Cc #1.#2~#3!#4e#5e#6\XINT_T
{%
\expandafter\XINT_frac_gen_F\the\numexpr #5-#2-%
- \romannumeral0\XINT_length_loop
- 0.#1\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye\expandafter
- ~\romannumeral0\XINT_num_loop
+ \numexpr\xint_c_ix\XINT_length_loop
+ #1\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ \relax\expandafter~\romannumeral0\XINT_num_loop
#3\xint_relax\xint_relax\xint_relax\xint_relax
\xint_relax\xint_relax\xint_relax\xint_relax\Z
~#4#1~%
@@ -364,96 +350,6 @@
\xint_bye\xint_bye\xint_bye\xint_bye
\xint_relax }{#1}%
}%
-\def\XINT_addm_A #1#2#3#4#5#6%
-{%
- \xint_gob_til_W #3\XINT_addm_az\W
- \XINT_addm_AB #1{#3#4#5#6}{#2}%
-}%
-\def\XINT_addm_az\W\XINT_addm_AB #1#2%
-{%
- \XINT_addm_AC_checkcarry #1%
-}%
-\def\XINT_addm_AB #1#2#3#4\W\X\Y\Z #5#6#7#8%
-{%
- \XINT_addm_ABE #1#2{#8#7#6#5}{#3}#4\W\X\Y\Z
-}%
-\def\XINT_addm_ABE #1#2#3#4#5#6%
-{%
- \expandafter\XINT_addm_ABEA\the\numexpr #1+10#5#4#3#2+#6.%
-}%
-\def\XINT_addm_ABEA #1#2#3.#4%
-{%
- \XINT_addm_A #2{#3#4}%
-}%
-\def\XINT_addm_AC_checkcarry #1%
-{%
- \xint_gob_til_zero #1\XINT_addm_AC_nocarry 0\XINT_addm_C
-}%
-\def\XINT_addm_AC_nocarry 0\XINT_addm_C #1#2\W\X\Y\Z
-{%
- \expandafter
- \xint_cleanupzeros_andstop
- \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_addm_C #1#2#3#4#5%
-{%
- \xint_gob_til_W
- #5\XINT_addm_cw
- #4\XINT_addm_cx
- #3\XINT_addm_cy
- #2\XINT_addm_cz
- \W\XINT_addm_CD {#5#4#3#2}{#1}%
-}%
-\def\XINT_addm_CD #1%
-{%
- \expandafter\XINT_addm_CC\the\numexpr 1+10#1.%
-}%
-\def\XINT_addm_CC #1#2#3.#4%
-{%
- \XINT_addm_AC_checkcarry #2{#3#4}%
-}%
-\def\XINT_addm_cw
- #1\XINT_addm_cx
- #2\XINT_addm_cy
- #3\XINT_addm_cz
- \W\XINT_addm_CD
-{%
- \expandafter\XINT_addm_CDw\the\numexpr 1+#1#2#3.%
-}%
-\def\XINT_addm_CDw #1.#2#3\X\Y\Z
-{%
- \XINT_addm_end #1#3%
-}%
-\def\XINT_addm_cx
- #1\XINT_addm_cy
- #2\XINT_addm_cz
- \W\XINT_addm_CD
-{%
- \expandafter\XINT_addm_CDx\the\numexpr 1+#1#2.%
-}%
-\def\XINT_addm_CDx #1.#2#3\Y\Z
-{%
- \XINT_addm_end #1#3%
-}%
-\def\XINT_addm_cy
- #1\XINT_addm_cz
- \W\XINT_addm_CD
-{%
- \expandafter\XINT_addm_CDy\the\numexpr 1+#1.%
-}%
-\def\XINT_addm_CDy #1.#2#3\Z
-{%
- \XINT_addm_end #1#3%
-}%
-\def\XINT_addm_cz\W\XINT_addm_CD #1#2#3{\XINT_addm_end #1#3}%
-\edef\XINT_addm_end #1#2#3#4#5%
- {\noexpand\expandafter\space\noexpand\the\numexpr #1#2#3#4#5\relax}%
\def\xintRaw {\romannumeral0\xintraw }%
\def\xintraw
{%
@@ -484,22 +380,20 @@
\def\xintRawWithZeros {\romannumeral0\xintrawwithzeros }%
\def\xintrawwithzeros
{%
- \expandafter\XINT_rawz\romannumeral0\XINT_infrac
+ \expandafter\XINT_rawz_fork\romannumeral0\XINT_infrac
}%
-\def\XINT_rawz #1%
+\def\XINT_rawz_fork #1%
{%
- \ifcase\XINT_cntSgn #1\Z
+ \ifnum#1<\xint_c_
\expandafter\XINT_rawz_Ba
- \or
+ \else
\expandafter\XINT_rawz_A
- \else
- \expandafter\XINT_rawz_Ba
\fi
- {#1}%
+ #1.%
}%
-\def\XINT_rawz_A #1#2#3{\xint_dsh {#2}{-#1}/#3}%
-\def\XINT_rawz_Ba #1#2#3{\expandafter\XINT_rawz_Bb
- \expandafter{\romannumeral0\xint_dsh {#3}{#1}}{#2}}%
+\def\XINT_rawz_A #1.#2#3{\XINT_dsx_addzeros{#1}#2;/#3}%
+\def\XINT_rawz_Ba -#1.#2#3{\expandafter\XINT_rawz_Bb
+ \expandafter{\romannumeral0\XINT_dsx_addzeros{#1}#3;}{#2}}%
\def\XINT_rawz_Bb #1#2{ #2/#1}%
\def\xintFloor {\romannumeral0\xintfloor }%
\def\xintfloor #1% devrais-je faire \xintREZ?
@@ -528,26 +422,24 @@
\fi
{#1}%
}%
-\def\XINT_numer_A #1#2#3{\xint_dsh {#2}{-#1}}%
+\def\XINT_numer_A #1#2#3{\XINT_dsx_addzeros{#1}#2;}%
\def\XINT_numer_B #1#2#3{ #2}%
\def\xintDenominator {\romannumeral0\xintdenominator }%
\def\xintdenominator
{%
- \expandafter\XINT_denom\romannumeral0\XINT_infrac
+ \expandafter\XINT_denom_fork\romannumeral0\XINT_infrac
}%
-\def\XINT_denom #1%
+\def\XINT_denom_fork #1%
{%
- \ifcase\XINT_cntSgn #1\Z
+ \ifnum#1<\xint_c_
\expandafter\XINT_denom_B
- \or
+ \else
\expandafter\XINT_denom_A
- \else
- \expandafter\XINT_denom_B
\fi
- {#1}%
+ #1.%
}%
-\def\XINT_denom_A #1#2#3{ #3}%
-\def\XINT_denom_B #1#2#3{\xint_dsh {#3}{#1}}%
+\def\XINT_denom_A #1.#2#3{ #3}%
+\def\XINT_denom_B -#1.#2#3{\XINT_dsx_addzeros{#1}#3;}%
\def\xintFrac {\romannumeral0\xintfrac }%
\def\xintfrac #1%
{%
@@ -832,82 +724,105 @@
\def\XINT_tfrac_P #1/#2\Z {\expandafter\XINT_rez_AB
\romannumeral0\xintiirem{#1}{#2}\Z {0}{#2}}%
\def\xintTrunc {\romannumeral0\xinttrunc }%
-\def\xintiTrunc {\romannumeral0\xintitrunc }%
-\def\xinttrunc #1%
+\def\xintiTrunc {\romannumeral0\xintitrunc}%
+\def\xinttrunc #1{\expandafter\XINT_trunc\the\numexpr#1.\XINT_trunc_G}%
+\def\xintitrunc #1{\expandafter\XINT_trunc\the\numexpr#1.\XINT_itrunc_G}%
+\def\XINT_trunc #1.#2#3%
{%
- \expandafter\XINT_trunc\expandafter {\the\numexpr #1}%
+ \expandafter\XINT_trunc_a\romannumeral0\XINT_infrac{#3}#1.#2%
}%
-\def\XINT_trunc #1#2%
+\def\XINT_trunc_a #1#2#3#4.#5%
{%
- \expandafter\XINT_trunc_G
- \romannumeral0\expandafter\XINT_trunc_A
- \romannumeral0\XINT_infrac {#2}{#1}{#1}%
+ \if0\XINT_Sgn#2\Z\xint_dothis\XINT_trunc_zero\fi
+ \if1\XINT_iSone#3XY\xint_dothis\XINT_trunc_sp_b\fi
+ \xint_orthat\XINT_trunc_b #1+#4.{#2}{#3}#5#4.%
}%
-\def\xintitrunc #1%
+\def\XINT_trunc_zero #1.#2.{ 0}%
+\def\XINT_trunc_b {\expandafter\XINT_trunc_B\the\numexpr}%
+\def\XINT_trunc_sp_b {\expandafter\XINT_trunc_sp_B\the\numexpr}%
+\def\XINT_trunc_B #1%
{%
- \expandafter\XINT_itrunc\expandafter {\the\numexpr #1}%
+ \xint_UDsignfork
+ #1\XINT_trunc_C
+ -\XINT_trunc_D
+ \krof #1%
}%
-\def\XINT_itrunc #1#2%
+\def\XINT_trunc_sp_B #1%
{%
- \expandafter\XINT_itrunc_G
- \romannumeral0\expandafter\XINT_trunc_A
- \romannumeral0\XINT_infrac {#2}{#1}{#1}%
+ \xint_UDsignfork
+ #1\XINT_trunc_sp_C
+ -\XINT_trunc_sp_D
+ \krof #1%
}%
-\def\XINT_trunc_A #1#2#3#4%
+\def\XINT_trunc_C -#1.#2#3%
{%
- \expandafter\XINT_trunc_checkifzero
- \expandafter{\the\numexpr #1+#4}#2\Z {#3}%
+ \expandafter\XINT_trunc_CE
+ \romannumeral0\XINT_dsx_addzeros{#1}#3;.{#2}%
}%
-\def\XINT_trunc_checkifzero #1#2#3\Z
+\def\XINT_trunc_CE #1.#2{\XINT_trunc_E #2.{#1}}%
+\def\XINT_trunc_sp_C -#1.#2#3{\XINT_trunc_sp_Ca #2.#1.}%
+\def\XINT_trunc_sp_Ca #1%
{%
- \xint_gob_til_zero #2\XINT_trunc_iszero0\XINT_trunc_B {#1}{#2#3}%
+ \xint_UDsignfork
+ #1{\XINT_trunc_sp_Cb -}%
+ -{\XINT_trunc_sp_Cb \space#1}%
+ \krof
}%
-\def\XINT_trunc_iszero0\XINT_trunc_B #1#2#3{ 0\Z 0}%
-\def\XINT_trunc_B #1%
+\def\XINT_trunc_sp_Cb #1#2.#3.%
{%
- \ifcase\XINT_cntSgn #1\Z
- \expandafter\XINT_trunc_D
- \or
- \expandafter\XINT_trunc_D
- \else
- \expandafter\XINT_trunc_C
- \fi
- {#1}%
+ \expandafter\XINT_trunc_sp_Cc
+ \romannumeral0\expandafter\XINT_split_fromright_a
+ \the\numexpr#3-\numexpr\xint_c_ix\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ .#2\xint_bye2345678\xint_bye..#1%
}%
-\def\XINT_trunc_C #1#2#3%
+\def\XINT_trunc_sp_Cc #1%
{%
- \expandafter\XINT_trunc_CE\expandafter
- {\romannumeral0\XINT_dsx_zeroloop -#1.{}\Z {#3}}{#2}%
+ \if.#1\xint_dothis{\XINT_trunc_sp_Cd 0.}\fi
+ \xint_orthat {\XINT_trunc_sp_Cd #1}%
}%
-\def\XINT_trunc_CE #1#2{\XINT_trunc_E #2.{#1}}%
-\def\XINT_trunc_D #1#2%
+\def\XINT_trunc_sp_Cd #1.#2.#3%
{%
+ \XINT_trunc_sp_F #3#1.%
+}%
+\def\XINT_trunc_D #1.#2%
+{%
\expandafter\XINT_trunc_E
- \romannumeral0\XINT_dsx_zeroloop #1.{}\Z {#2}.%
+ \romannumeral0\XINT_dsx_addzeros {#1}#2;.%
}%
+\def\XINT_trunc_sp_D #1.#2#3%
+{%
+ \expandafter\XINT_trunc_sp_E
+ \romannumeral0\XINT_dsx_addzeros {#1}#2;.%
+}%
\def\XINT_trunc_E #1%
{%
\xint_UDsignfork
- #1\XINT_trunc_Fneg
- -{\XINT_trunc_Fpos #1}%
+ #1{\XINT_trunc_F -}%
+ -{\XINT_trunc_F \space#1}%
\krof
}%
-\def\XINT_trunc_Fneg #1.#2{\expandafter\xint_firstoftwo_thenstop
- \romannumeral0\XINT_div_prepare {#2}{#1}\Z -}%
-\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%
+\def\XINT_trunc_sp_E #1%
{%
- \xint_gob_til_zero #1\XINT_trunc_zero 0#3#1#2%
+ \xint_UDsignfork
+ #1{\XINT_trunc_sp_F -}%
+ -{\XINT_trunc_sp_F\space#1}%
+ \krof
}%
-\def\XINT_trunc_zero 0#1#20{ 0}%
-\def\XINT_trunc_G #1\Z #2#3%
+\def\XINT_trunc_F #1#2.#3#4%
+ {\expandafter#4\romannumeral`&&@\expandafter\xint_firstoftwo
+ \romannumeral0\XINT_div_prepare {#3}{#2}.#1}%
+\def\XINT_trunc_sp_F #1#2.#3{#3#2.#1}%
+\def\XINT_itrunc_G #1#2.#3#4.{\if#10\xint_dothis{ 0}\fi\xint_orthat{#3#1}#2}%
+\def\XINT_trunc_G #1.#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%
+ \expandafter\XINT_trunc_H
+ \the\numexpr\romannumeral0\xintlength {#1}-#3.#3.{#1}#2%
}%
-\def\XINT_trunc_H #1#2%
+\def\XINT_trunc_H #1.#2.%
{%
\ifnum #1 > \xint_c_
\xint_afterfi {\XINT_trunc_Ha {#2}}%
@@ -915,329 +830,311 @@
\xint_afterfi {\XINT_trunc_Hb {-#1}}% -0,--1,--2, ....
\fi
}%
-\def\XINT_trunc_Ha
-{%
- \expandafter\XINT_trunc_Haa\romannumeral0\xintdecsplit
-}%
-\def\XINT_trunc_Haa #1#2#3%
-{%
- #3#1.#2%
-}%
+\def\XINT_trunc_Ha{\expandafter\XINT_trunc_Haa\romannumeral0\xintdecsplit}%
+\def\XINT_trunc_Haa #1#2#3{#3#1.#2}%
\def\XINT_trunc_Hb #1#2#3%
{%
\expandafter #3\expandafter0\expandafter.%
- \romannumeral0\XINT_dsx_zeroloop #1.{}\Z {}#2% #1=-0 autoris\'e !
+ \romannumeral\xintreplicate{#1}0#2%
}%
\def\xintTTrunc {\romannumeral0\xintttrunc }%
-\def\xintttrunc #1%
-{%
- \expandafter\XINT_itrunc_G
- \romannumeral0\expandafter\XINT_ttrunc_A
- \romannumeral0\XINT_infrac {#1}0% this last 0 to let \XINT_itrunc_G be happy
-}%
-\def\XINT_ttrunc_A #1#2#3{\XINT_trunc_checkifzero {#1}#2\Z {#3}}%
+\def\xintttrunc {\xintitrunc\xint_c_}%
\let\xintNum \xintTTrunc
\let\xintnum \xintttrunc
-\def\xintRound {\romannumeral0\xintround }%
+\def\xintRound {\romannumeral0\xintround }%
\def\xintiRound {\romannumeral0\xintiround }%
-\def\xintround #1%
+\def\xintround #1{\expandafter\XINT_round\the\numexpr #1.\XINT_round_A}%
+\def\xintiround #1{\expandafter\XINT_round\the\numexpr #1.\XINT_iround_A}%
+\def\XINT_round #1.{\expandafter\XINT_round_aa\the\numexpr #1+\xint_c_i.#1.}%
+\def\XINT_round_aa #1.#2.#3#4%
{%
- \expandafter\XINT_round\expandafter {\the\numexpr #1}%
+ \expandafter\XINT_round_a\romannumeral0\XINT_infrac{#4}#1.#3#2.%
}%
-\def\XINT_round
+\def\XINT_round_a #1#2#3#4.%
{%
- \expandafter\XINT_trunc_G\romannumeral0\XINT_round_A
+ \if0\XINT_Sgn#2\Z\xint_dothis\XINT_trunc_zero\fi
+ \if1\XINT_iSone#3XY\xint_dothis\XINT_trunc_sp_b\fi
+ \xint_orthat\XINT_trunc_b #1+#4.{#2}{#3}%
}%
-\def\xintiround #1%
+\def\XINT_round_A{\expandafter\XINT_trunc_G\romannumeral0\XINT_round_B}%
+\def\XINT_iround_A{\expandafter\XINT_itrunc_G\romannumeral0\XINT_round_B}%
+\def\XINT_round_B #1.%
+ {\XINT_dsrr #1\xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax.}%
+\def\xintXTrunc #1%#2%
{%
- \expandafter\XINT_iround\expandafter {\the\numexpr #1}%
+ \expandafter\XINT_xtrunc_a
+ \the\numexpr #1\expandafter.\romannumeral0\xintraw
}%
-\def\XINT_iround
+\def\XINT_xtrunc_a #1.% ?? faire autre chose
{%
- \expandafter\XINT_itrunc_G\romannumeral0\XINT_round_A
+ \expandafter\XINT_xtrunc_b\the\numexpr\ifnum#1<\xint_c_i \xint_c_i-\fi #1.%
}%
-\def\XINT_round_A #1#2%
+\def\XINT_xtrunc_b #1.#2{\XINT_xtrunc_c #2{#1}}%
+\def\XINT_xtrunc_c #1%
{%
- \expandafter\XINT_round_B
- \romannumeral0\expandafter\XINT_trunc_A
- \romannumeral0\XINT_infrac {#2}{#1+\xint_c_i}{#1}%
-}%
-\def\XINT_round_B #1\Z
+ \xint_UDzerominusfork
+ #1-\XINT_xtrunc_zero
+ 0#1{-\XINT_xtrunc_d {}}%
+ 0-{\XINT_xtrunc_d #1}%
+ \krof
+}%[
+\def\XINT_xtrunc_zero #1#2]{0.\romannumeral\xintreplicate{#1}0}%
+\def\XINT_xtrunc_d #1#2#3/#4[#5]%
{%
- \expandafter\XINT_round_C
- \romannumeral0\XINT_rord_main {}#1%
- \xint_relax
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_relax
- \Z
+ \XINT_xtrunc_prepare_a#4\R\R\R\R\R\R\R\R {10}0000001\W !{#4};{#5}{#2}{#1#3}%
}%
-\def\XINT_round_C #1%
+\def\XINT_xtrunc_prepare_a #1#2#3#4#5#6#7#8#9%
{%
- \ifnum #1<\xint_c_v
- \expandafter\XINT_round_Daa
- \else
- \expandafter\XINT_round_Dba
- \fi
+ \xint_gob_til_R #9\XINT_xtrunc_prepare_small\R
+ \XINT_xtrunc_prepare_b #9%
}%
-\def\XINT_round_Daa #1%
+\def\XINT_xtrunc_prepare_small\R #1!#2;%
{%
- \xint_gob_til_Z #1\XINT_round_Daz\Z \XINT_round_Da #1%
+ \ifcase #2
+ \or\expandafter\XINT_xtrunc_BisOne
+ \or\expandafter\XINT_xtrunc_BisTwo
+ \or
+ \or\expandafter\XINT_xtrunc_BisFour
+ \or\expandafter\XINT_xtrunc_BisFive
+ \or
+ \or
+ \or\expandafter\XINT_xtrunc_BisEight
+ \fi\XINT_xtrunc_BisSmall {#2}%
}%
-\def\XINT_round_Daz\Z \XINT_round_Da \Z { 0\Z }%
-\def\XINT_round_Da #1\Z
+\def\XINT_xtrunc_BisOne\XINT_xtrunc_BisSmall #1#2#3#4%
+ {\XINT_xtrunc_sp_e {#2}{#4}{#3}}%
+\def\XINT_xtrunc_BisTwo\XINT_xtrunc_BisSmall #1#2#3#4%
{%
- \XINT_rord_main {}#1%
- \xint_relax
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_relax \Z
+ \expandafter\XINT_xtrunc_sp_e\expandafter
+ {\the\numexpr #2-\xint_c_i\expandafter}\expandafter
+ {\romannumeral0\xintiimul 5{#4}}{#3}%
}%
-\def\XINT_round_Dba #1%
+\def\XINT_xtrunc_BisFour\XINT_xtrunc_BisSmall #1#2#3#4%
{%
- \xint_gob_til_Z #1\XINT_round_Dbz\Z \XINT_round_Db #1%
+ \expandafter\XINT_xtrunc_sp_e\expandafter
+ {\the\numexpr #2-\xint_c_ii\expandafter}\expandafter
+ {\romannumeral0\xintiimul {25}{#4}}{#3}%
}%
-\def\XINT_round_Dbz\Z \XINT_round_Db \Z { 1\Z }%
-\def\XINT_round_Db #1\Z
+\def\XINT_xtrunc_BisFive\XINT_xtrunc_BisSmall #1#2#3#4%
{%
- \XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z \Z
+ \expandafter\XINT_xtrunc_sp_e\expandafter
+ {\the\numexpr #2-\xint_c_i\expandafter}\expandafter
+ {\romannumeral0\xintdouble {#4}}{#3}%
}%
-\def\xintXTrunc #1#2%
+\def\XINT_xtrunc_BisEight\XINT_xtrunc_BisSmall #1#2#3#4%
{%
- \expandafter\XINT_xtrunc_a\expandafter
- {\the\numexpr #1\expandafter}\romannumeral0\xintraw {#2}%
+ \expandafter\XINT_xtrunc_sp_e\expandafter
+ {\the\numexpr #2-\xint_c_iii\expandafter}\expandafter
+ {\romannumeral0\xintiimul {125}{#4}}{#3}%
}%
-\def\XINT_xtrunc_a #1%
+\def\XINT_xtrunc_BisSmall #1%
{%
- \expandafter\XINT_xtrunc_b\expandafter
- {\the\numexpr\ifnum#1<\xint_c_i \xint_c_i-\fi #1}%
+ \expandafter\XINT_xtrunc_e\expandafter
+ {\expandafter\XINT_xtrunc_small_a
+ \the\numexpr #1/\xint_c_ii\expandafter.\the\numexpr \xint_c_x^viii+#1!}%
}%
-\def\XINT_xtrunc_b #1%
+\def\XINT_xtrunc_small_a #1.#2!#3%
{%
- \expandafter\XINT_xtrunc_c\expandafter
- {\the\numexpr (#1+\xint_c_ii^v)/\xint_c_ii^vi-\xint_c_i}{#1}%
+ \expandafter\XINT_div_small_b\the\numexpr #1\expandafter
+ .\the\numexpr #2\expandafter!%
+ \romannumeral0\XINT_div_small_ba #3\R\R\R\R\R\R\R\R{10}0000001\W
+ #3\XINT_sepbyviii_Z_end 2345678\relax
}%
-\def\XINT_xtrunc_c #1#2%
+\def\XINT_xtrunc_prepare_b
+ {\expandafter\XINT_xtrunc_prepare_c\romannumeral0\XINT_zeroes_forviii }%
+\def\XINT_xtrunc_prepare_c #1!%
{%
- \expandafter\XINT_xtrunc_d\expandafter
- {\the\numexpr #2-\xint_c_ii^vi*#1}{#1}{#2}%
+ \XINT_xtrunc_prepare_d #1.00000000!{#1}%
}%
-\def\XINT_xtrunc_d #1#2#3#4/#5[#6]%
+\def\XINT_xtrunc_prepare_d #1#2#3#4#5#6#7#8#9%
{%
- \XINT_xtrunc_e #4.{#6}{#5}{#3}{#2}{#1}%
+ \expandafter\XINT_xtrunc_prepare_e\xint_gob_til_dot #1#2#3#4#5#6#7#8#9!%
}%
-\def\XINT_xtrunc_e #1%
+\def\XINT_xtrunc_prepare_e #1!#2!#3#4%
{%
- \xint_UDzerominusfork
- #1-\XINT_xtrunc_zero
- 0#1\XINT_xtrunc_N
- 0-{\XINT_xtrunc_P #1}%
- \krof
+ \XINT_xtrunc_prepare_f #4#3\X {#1}{#3}%
}%
-\def\XINT_xtrunc_zero .#1#2#3#4#5%
+\def\XINT_xtrunc_prepare_f #1#2#3#4#5#6#7#8#9\X
{%
- 0.\romannumeral0\expandafter\XINT_dsx_zeroloop
- \the\numexpr #5.{}\Z {}%
- \xintiloop [#4+-1]
- \ifnum \xintiloopindex>\xint_c_
- 0000000000000000000000000000000000000000000000000000000000000000%
- \repeat
+ \expandafter\XINT_xtrunc_prepare_g\expandafter
+ \XINT_div_prepare_g
+ \the\numexpr #1#2#3#4#5#6#7#8+\xint_c_i\expandafter
+ .\the\numexpr (#1#2#3#4#5#6#7#8+\xint_c_i)/\xint_c_ii\expandafter
+ .\the\numexpr #1#2#3#4#5#6#7#8\expandafter
+ .\romannumeral0\XINT_sepandrev_andcount
+ #1#2#3#4#5#6#7#8#9\XINT_rsepbyviii_end_A 2345678%
+ \XINT_rsepbyviii_end_B 2345678%
+ \relax\xint_c_ii\xint_c_iii
+ \R.\xint_c_vi\R.\xint_c_v\R.\xint_c_iv\R.\xint_c_iii
+ \R.\xint_c_ii\R.\xint_c_i\R.\xint_c_\W
+ \X
}%
-\def\XINT_xtrunc_N {-\XINT_xtrunc_P }%
-\def\XINT_xtrunc_P #1.#2%
+\def\XINT_xtrunc_prepare_g #1;{\XINT_xtrunc_e {#1}}%
+\def\XINT_xtrunc_e #1#2%
{%
\ifnum #2<\xint_c_
- \expandafter\XINT_xtrunc_negN_Q
+ \expandafter\XINT_xtrunc_I
\else
- \expandafter\XINT_xtrunc_Q
- \fi {#2}{#1}.%
+ \expandafter\XINT_xtrunc_II
+ \fi #2.{#1}%
}%
-\def\XINT_xtrunc_negN_Q #1#2.#3#4#5#6%
+\def\XINT_xtrunc_I -#1.#2#3#4%
{%
- \expandafter\XINT_xtrunc_negN_R
- \romannumeral0\XINT_div_prepare {#3}{#2}{#3}{#1}{#4}%
+ \expandafter\XINT_xtrunc_I_a\romannumeral0#2{#4}{#2}{#1}{#3}%
}%
-\def\XINT_xtrunc_negN_R #1#2#3#4#5%
+\def\XINT_xtrunc_I_a #1#2#3#4#5%
{%
- \expandafter\XINT_xtrunc_negN_S\expandafter
- {\the\numexpr -#4}{#5}{#2}{#3}{#1}%
+ \expandafter\XINT_xtrunc_I_b\the\numexpr #4-#5.#4.{#5}{#2}{#3}{#1}%
}%
-\def\XINT_xtrunc_negN_S #1#2%
+\def\XINT_xtrunc_I_b #1%
{%
- \expandafter\XINT_xtrunc_negN_T\expandafter
- {\the\numexpr #2-#1}{#1}{#2}%
+ \xint_UDsignfork
+ #1\XINT_xtrunc_IA_c
+ -\XINT_xtrunc_IB_c
+ \krof #1%
}%
-\def\XINT_xtrunc_negN_T #1%
+\def\XINT_xtrunc_IA_c -#1.#2.#3#4#5#6%
{%
- \ifnum \xint_c_<#1
- \expandafter\XINT_xtrunc_negNA
- \else
- \expandafter\XINT_xtrunc_negNW
- \fi {#1}%
+ \expandafter\XINT_xtrunc_IA_d
+ \the\numexpr#2-\xintLength{#6}.{#6}%
+ \expandafter\XINT_xtrunc_IA_xd
+ \the\numexpr (#1+\xint_c_ii^v)/\xint_c_ii^vi-\xint_c_i.#1.{#5}{#4}%
}%
-\def\XINT_xtrunc_unlock #10.{ }%
-\def\XINT_xtrunc_negNA #1#2#3#4#5#6%
+\def\XINT_xtrunc_IA_d #1%
{%
- \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}%
+ \xint_UDsignfork
+ #1\XINT_xtrunc_IAA_e
+ -\XINT_xtrunc_IAB_e
+ \krof #1%
}%
-\def\XINT_xtrunc_negNB #1#2#3{\XINT_xtrunc_negNC {#2}{#3}#1}%
-\def\XINT_xtrunc_negNC #1%
+\def\XINT_xtrunc_IAA_e -#1.#2%
{%
- \ifnum \xint_c_ < #1
- \expandafter\XINT_xtrunc_negNDa
- \else
- \expandafter\XINT_xtrunc_negNE
- \fi {#1}%
+ \romannumeral0\XINT_split_fromleft
+ #1.#2\xint_gobble_i\xint_bye2345678\xint_bye..%
}%
-\def\XINT_xtrunc_negNDa #1#2%
+\def\XINT_xtrunc_IAB_e #1.#2%
{%
- \expandafter\XINT_xtrunc_negNDb%
- \romannumeral0\XINT_split_fromleft_loop #1.{}#2\W\W\W\W\W\W\W\W\Z
+ 0.\romannumeral\XINT_rep#1\endcsname0#2%
}%
-\def\XINT_xtrunc_negNDb #1.#2.{#1.#2}%
-\def\XINT_xtrunc_negNE #1#2%
+\def\XINT_xtrunc_IA_xd #1.#2.%
{%
- 0.\romannumeral0\XINT_dsx_zeroloop -#1.{}\Z {}#2%
+ \expandafter\XINT_xtrunc_IA_xe\the\numexpr #2-\xint_c_ii^vi*#1.#1.%
}%
-\def\XINT_xtrunc_negNW #1#2#3#4#5#6%
+\def\XINT_xtrunc_IA_xe #1.#2.#3#4%
{%
- \expandafter\XINT_xtrunc_negNX\expandafter
- {\romannumeral0\xintnum{\xintDecSplitL {-#1}{#6}}}{#3}%
+ \XINT_xtrunc_loop {#2}{#4}{#3}{#1}%
}%
-\def\XINT_xtrunc_negNX #1#2%
+\def\XINT_xtrunc_IB_c #1.#2.#3#4#5#6%
{%
- \expandafter\XINT_xtrunc_negNC\expandafter
- {\the\numexpr\xintLength {#1}-#2}{#1}%
+ \expandafter\XINT_xtrunc_IB_d
+ \romannumeral0\XINT_split_xfork #1.#6\xint_bye2345678\xint_bye..{#3}%
}%
-\def\XINT_xtrunc_BisOne #1#2#3#4#5#6#7%
+\def\XINT_xtrunc_IB_d #1.#2.#3%
{%
- #5.\romannumeral0\expandafter\XINT_dsx_zeroloop
- \the\numexpr #7.{}\Z {}%
- \xintiloop [#6+-1]
- \ifnum \xintiloopindex>\xint_c_
- 0000000000000000000000000000000000000000000000000000000000000000%
- \repeat
+ \expandafter\XINT_xtrunc_IA_d\the\numexpr#3-\xintLength {#1}.{#1}%
}%
-\def\XINT_xtrunc_BisTwo #1#2#3#4#5#6#7%
+\def\XINT_xtrunc_II #1.%
{%
- \xintHalf {#5}.\ifodd\xintiiLDg{#5} 5\else 0\fi
- \romannumeral0\expandafter\XINT_dsx_zeroloop
- \the\numexpr #7-\xint_c_i.{}\Z {}%
- \xintiloop [#6+-1]
- \ifnum \xintiloopindex>\xint_c_
- 0000000000000000000000000000000000000000000000000000000000000000%
- \repeat
+ \expandafter\XINT_xtrunc_II_a\romannumeral\xintreplicate{#1}0.%
}%
-\def\XINT_xtrunc_Q #1%
+\def\XINT_xtrunc_II_a #1.#2#3#4%
{%
- \expandafter\XINT_xtrunc_prepare
- \romannumeral0\XINT_dsx_zeroloop #1.{}\Z
+ \expandafter\XINT_xtrunc_II_b
+ \the\numexpr (#3+\xint_c_ii^v)/\xint_c_ii^vi-\xint_c_i\expandafter.%
+ \the\numexpr #3\expandafter.\romannumeral0#2{#4#1}{#2}%
}%
-\def\XINT_xtrunc_prepare #1.#2#3%
+\def\XINT_xtrunc_II_b #1.#2.%
{%
- \expandafter\XINT_xtrunc_Pa\expandafter
- {\romannumeral0%
- \XINT_xtrunc_prepare_a #2\R\R\R\R\R\R\R\R {10}0000001\W !{#2}}{#1}%
+ \expandafter\XINT_xtrunc_II_c\the\numexpr #2-\xint_c_ii^vi*#1.#1.%
}%
-\def\XINT_xtrunc_prepare_a #1#2#3#4#5#6#7#8#9%
+\def\XINT_xtrunc_II_c #1.#2.#3#4#5%
{%
- \xint_gob_til_R #9\XINT_xtrunc_prepare_small\R
- \XINT_xtrunc_prepare_b #9%
+ #3.\XINT_xtrunc_loop {#2}{#4}{#5}{#1}%
}%
-\def\XINT_xtrunc_prepare_small\R #1!#2%
+\def\XINT_xtrunc_loop #1%
{%
- \ifcase #2
- \or\xint_afterfi{ \XINT_div_BisOne}%
- \or\xint_afterfi{ \XINT_div_BisTwo}%
- \else\expandafter\XINT_xtrunc_small_aa
- \fi {#2}%
+ \ifnum #1=\xint_c_ \expandafter\XINT_xtrunc_transition\fi
+ \expandafter\XINT_xtrunc_loop_a\the\numexpr #1-\xint_c_i.%
}%
-\def\XINT_xtrunc_small_aa #1%
+\def\XINT_xtrunc_loop_a #1.#2#3%
{%
- \expandafter\space\expandafter\XINT_xtrunc_small_a
- \the\numexpr #1/\xint_c_ii\expandafter
- .\the\numexpr \xint_c_x^viii+#1!%
+ \expandafter\XINT_xtrunc_loop_b\romannumeral0#3%
+ {#20000000000000000000000000000000000000000000000000000000000000000}%
+ {#1}{#3}%
}%
-\def\XINT_xtrunc_small_a #1.#2!#3%
+\def\XINT_xtrunc_loop_b #1#2#3%
{%
- \expandafter\XINT_div_small_b\the\numexpr #1\expandafter
- .\the\numexpr #2\expandafter!%
- \romannumeral0\XINT_div_small_ba #3\R\R\R\R\R\R\R\R{10}0000001\W
- #3\XINT_sepbyviii_Z_end 2345678\relax
+ \romannumeral\xintreplicate{\xint_c_ii^vi-\xintLength{#1}}0#1%
+ \XINT_xtrunc_loop {#3}{#2}%
}%
-\def\XINT_xtrunc_prepare_b
- {\expandafter\XINT_xtrunc_prepare_c\romannumeral0\XINT_zeroes_forviii }%
-\def\XINT_xtrunc_prepare_c #1!%
+\def\XINT_xtrunc_transition
+ \expandafter\XINT_xtrunc_loop_a\the\numexpr #1.#2#3#4%
{%
- \XINT_xtrunc_prepare_d #1.00000000!{#1}%
+ \ifnum #4=\xint_c_ \expandafter\xint_gobble_vi\fi
+ \expandafter\XINT_xtrunc_finish\expandafter
+ {\romannumeral0\XINT_dsx_addzeros{#4}#2;}{#3}{#4}%
}%
-\def\XINT_xtrunc_prepare_d #1#2#3#4#5#6#7#8#9%
+\def\XINT_xtrunc_finish #1#2%
{%
- \expandafter\XINT_xtrunc_prepare_e\xint_gob_til_dot #1#2#3#4#5#6#7#8#9!%
+ \expandafter\XINT_xtrunc_finish_a\romannumeral0#2{#1}%
}%
-\def\XINT_xtrunc_prepare_e #1!#2!#3#4%
+\def\XINT_xtrunc_finish_a #1#2#3%
{%
- \XINT_xtrunc_prepare_f #4#3\X {#1}{#3}%
+ \romannumeral\xintreplicate{#3-\xintLength{#1}}0#1%
}%
-\def\XINT_xtrunc_prepare_f #1#2#3#4#5#6#7#8#9\X
+\def\XINT_xtrunc_sp_e #1%
{%
- \expandafter\space\expandafter\XINT_div_prepare_g
- \the\numexpr #1#2#3#4#5#6#7#8+\xint_c_i\expandafter
- .\the\numexpr (#1#2#3#4#5#6#7#8+\xint_c_i)/\xint_c_ii\expandafter
- .\the\numexpr #1#2#3#4#5#6#7#8\expandafter
- .\romannumeral0\XINT_sepandrev_andcount
- #1#2#3#4#5#6#7#8#9\XINT_rsepbyviii_end_A 2345678%
- \XINT_rsepbyviii_end_B 2345678%
- \relax\xint_c_ii\xint_c_iii
- \R.\xint_c_vi\R.\xint_c_v\R.\xint_c_iv\R.\xint_c_iii
- \R.\xint_c_ii\R.\xint_c_i\R.\xint_c_\W
- \X
+ \ifnum #1<\xint_c_
+ \expandafter\XINT_xtrunc_sp_I
+ \else
+ \expandafter\XINT_xtrunc_sp_II
+ \fi #1.%
}%
-\def\XINT_xtrunc_Pa #1#2%
+\def\XINT_xtrunc_sp_I -#1.#2#3%
{%
- \expandafter\XINT_xtrunc_Pb\romannumeral0#1{#2}{#1}%
+ \expandafter\XINT_xtrunc_sp_I_a\the\numexpr #1-#3.#1.{#3}{#2}%
}%
-\def\XINT_xtrunc_Pb #1#2#3#4{#1.\XINT_xtrunc_A {#4}{#2}{#3}}%
-\def\XINT_xtrunc_A #1%
+\def\XINT_xtrunc_sp_I_a #1%
{%
- \unless\ifnum #1>\xint_c_ \XINT_xtrunc_transition\fi
- \expandafter\XINT_xtrunc_B\expandafter{\the\numexpr #1-\xint_c_i}%
+ \xint_UDsignfork
+ #1\XINT_xtrunc_sp_IA_b
+ -\XINT_xtrunc_sp_IB_b
+ \krof #1%
}%
-\def\XINT_xtrunc_B #1#2#3%
+\def\XINT_xtrunc_sp_IA_b -#1.#2.#3#4%
{%
- \expandafter\XINT_xtrunc_D\romannumeral0#3%
- {#20000000000000000000000000000000000000000000000000000000000000000}%
- {#1}{#3}%
+ \expandafter\XINT_xtrunc_sp_IA_c
+ \the\numexpr#2-\xintLength{#4}.{#4}\romannumeral\XINT_rep#1\endcsname0%
}%
-\def\XINT_xtrunc_D #1#2#3%
+\def\XINT_xtrunc_sp_IA_c #1%
{%
- \romannumeral0\expandafter\XINT_dsx_zeroloop
- \the\numexpr \xint_c_ii^vi-\xintLength{#1}.{}\Z {}#1%
- \XINT_xtrunc_A {#3}{#2}%
+ \xint_UDsignfork
+ #1\XINT_xtrunc_sp_IAA
+ -\XINT_xtrunc_sp_IAB
+ \krof #1%
}%
-\def\XINT_xtrunc_transition\fi
- \expandafter\XINT_xtrunc_B\expandafter #1#2#3#4%
+\def\XINT_xtrunc_sp_IAA -#1.#2%
{%
- \fi
- \ifnum #4=\xint_c_ \XINT_xtrunc_abort\fi
- \expandafter\XINT_xtrunc_x\expandafter
- {\romannumeral0\XINT_dsx_zeroloop #4.{}\Z {#2}}{#3}{#4}%
+ \romannumeral0\XINT_split_fromleft
+ #1.#2\xint_gobble_i\xint_bye2345678\xint_bye..%
}%
-\def\XINT_xtrunc_x #1#2%
+\def\XINT_xtrunc_sp_IAB #1.#2%
{%
- \expandafter\XINT_xtrunc_y\romannumeral0#2{#1}%
+ 0.\romannumeral\XINT_rep#1\endcsname0#2%
}%
-\def\XINT_xtrunc_y #1#2#3%
+\def\XINT_xtrunc_sp_IB_b #1.#2.#3#4%
{%
- \romannumeral0\expandafter\XINT_dsx_zeroloop
- \the\numexpr #3-\xintLength{#1}.{}\Z {}#1%
+ \expandafter\XINT_xtrunc_sp_IB_c
+ \romannumeral0\XINT_split_xfork #1.#4\xint_bye2345678\xint_bye..{#3}%
}%
-\def\XINT_xtrunc_abort\fi\expandafter\XINT_xtrunc_x\expandafter #1#2#3{\fi}%
+\def\XINT_xtrunc_sp_IB_c #1.#2.#3%
+{%
+ \expandafter\XINT_xtrunc_sp_IA_c\the\numexpr#3-\xintLength {#1}.{#1}%
+}%
+\def\XINT_xtrunc_sp_II #1.#2#3%
+{%
+ #2\romannumeral\XINT_rep#1\endcsname0.\romannumeral\XINT_rep#3\endcsname0%
+}%
\mathchardef\XINTdigits 16
\def\xintDigits #1#2%
{\afterassignment \xint_gobble_i \mathchardef\XINTdigits=}%
@@ -1252,29 +1149,27 @@
\def\XINT_fadd_Bzero #1]#2#3#4{ #3/#4[#2]}%
\def\XINT_fadd_c #1/#2[#3]#4%
{%
- \expandafter\XINT_fadd_Aa\expandafter{\the\numexpr #4-#3}{#3}{#4}{#1}{#2}%
+ \expandafter\XINT_fadd_Aa\the\numexpr #4-#3.{#3}{#4}{#1}{#2}%
}%
\def\XINT_fadd_Aa #1%
{%
- \ifcase\XINT_cntSgn #1\Z
- \expandafter\XINT_fadd_B
- \or
- \expandafter \XINT_fadd_Ba
- \else
- \expandafter \XINT_fadd_Bb
- \fi {#1}%
+ \xint_UDzerominusfork
+ #1-\XINT_fadd_B
+ 0#1\XINT_fadd_Bb
+ 0-\XINT_fadd_Ba
+ \krof #1%
}%
-\def\XINT_fadd_B #1#2#3#4#5#6#7{\XINT_fadd_C {#4}{#5}{#7}{#6}[#3]}%
-\def\XINT_fadd_Ba #1#2#3#4#5#6#7%
+\def\XINT_fadd_B #1.#2#3#4#5#6#7{\XINT_fadd_C {#4}{#5}{#7}{#6}[#3]}%
+\def\XINT_fadd_Ba #1.#2#3#4#5#6#7%
{%
\expandafter\XINT_fadd_C\expandafter
- {\romannumeral0\XINT_dsx_zeroloop #1.{}\Z {#6}}%
+ {\romannumeral0\XINT_dsx_addzeros {#1}#6;}%
{#7}{#5}{#4}[#2]%
}%
-\def\XINT_fadd_Bb #1#2#3#4#5#6#7%
+\def\XINT_fadd_Bb -#1.#2#3#4#5#6#7%
{%
\expandafter\XINT_fadd_C\expandafter
- {\romannumeral0\XINT_dsx_zeroloop -#1.{}\Z {#4}}%
+ {\romannumeral0\XINT_dsx_addzeros {#1}#4;}%
{#5}{#7}{#6}[#3]%
}%
\def\XINT_fadd_C #1#2#3%
@@ -1579,13 +1474,13 @@
\def\XINT_fgeq_Fd #1\Z #2#3%
{%
\expandafter\XINT_fgeq_Fe\expandafter
- {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#3}}{#2}%
+ {\romannumeral0\XINT_dsx_addzeros {#1}#3;}{#2}%
}%
\def\XINT_fgeq_Fe #1#2{\XINT_geq_pre {#2}{#1}}%
\def\XINT_fgeq_Fn #1\Z #2#3%
{%
\expandafter\XINT_geq_pre\expandafter
- {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}%
+ {\romannumeral0\XINT_dsx_addzeros {#1}#2;}{#3}%
}%
\def\xintMax {\romannumeral0\xintmax }%
\def\xintmax #1%
@@ -1741,13 +1636,13 @@
\def\XINT_fcmp_Fd #1\Z #2#3%
{%
\expandafter\XINT_fcmp_Fe\expandafter
- {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#3}}{#2}%
+ {\romannumeral0\XINT_dsx_addzeros {#1}#3;}{#2}%
}%
\def\XINT_fcmp_Fe #1#2{\xintiicmp {#2}{#1}}%
\def\XINT_fcmp_Fn #1\Z #2#3%
{%
\expandafter\xintiicmp\expandafter
- {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}%
+ {\romannumeral0\XINT_dsx_addzeros {#1}#2;}{#3}%
}%
\def\xintAbs {\romannumeral0\xintabs }%
\def\xintabs #1{\expandafter\XINT_abs\romannumeral0\xintraw {#1}}%
@@ -1775,7 +1670,7 @@
}%
\def\XINT_float_a #1.#2#3#4%
{%
- \if\romannumeral0\XINT_isone#4XY1\expandafter\XINT_float_sp
+ \if1\XINT_iSone#4XY\expandafter\XINT_float_sp
\else\expandafter\XINT_float_fork\fi #3.{#1}{#2}{#4}%
}%
\def\XINT_float_sp #1%
@@ -1808,50 +1703,26 @@
{%
\expandafter\XINT_float_sp_done
\the\numexpr #4-#1+#3-\xint_c_i\expandafter.%
- \romannumeral0\XINT_dsx_addzerosnofuss {#1}{#2};%
+ \romannumeral0\XINT_dsx_addzeros {#1}#2;;%
}%
\def\XINT_float_sp_done #1.#2#3;{ #2.#3e#1}%
\def\XINT_float_sp_c #1.#2%
{%
\if #29\xint_dothis {\XINT_float_sp_d\XINT_float_Wb }\fi
- \xint_orthat {\XINT_float_sp_d\XINT_float_sp_Wa }#1.#2%
+ \xint_orthat {\XINT_float_sp_d\XINT_float_Wa }#1.#2%
}%
\def\XINT_float_sp_d #1#2.#3.#4.#5.%
{%
\expandafter\XINT_float_sp_e
\the\numexpr #5+#2+#4-\xint_c_i\expandafter.%
- \romannumeral0\expandafter\XINT_split_fromleft_loop
- \the\numexpr #4+\xint_c_i.{}#3\W\W\W\W\W\W\W\W\Z #1%
+ \romannumeral0\XINT_split_fromleft
+ (\xint_c_i+#4).#3\xint_bye2345678\xint_bye..#1%
}%
-\def\XINT_float_sp_e #1.#2.#3.%
+\def\XINT_float_sp_e #1.#2.#3.#4%
{%
- \expandafter\XINT_float_sp_f
- \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.%
+ \expandafter#4\romannumeral0\XINT_dsrr#2%
+ \xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax e#1%
}%
-\def\XINT_float_sp_f #1%
-{%
- \ifnum #1<\xint_c_v
- \expandafter\XINT_float_sp_ga\else\expandafter\XINT_float_sp_h\fi
-}%
-\def\XINT_float_sp_ga #1;#2.#3%
-{%
- \expandafter\XINT_float_sp_Wa
- \romannumeral0\XINT_rord_main {}#1%
- \xint_relax
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_relax e#2%
-}%
-\def\XINT_float_sp_h #1;#2.#3%
-{%
- \expandafter#3%
- \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z e#2%
-}%
-\def\XINT_float_sp_Wa #1{ #1.}%
\def\XINT_float_fork #1%
{%
\xint_UDsignfork
@@ -1877,8 +1748,7 @@
{%
\expandafter\XINT_float_MatoN
\the\numexpr #1-#2\expandafter.%
- \romannumeral0\XINT_split_fromleft_loop #2.{}#3\W\W\W\W\W\W\W\W\Z
- {#2}%
+ \romannumeral0\XINT_split_fromleft#2.#3\xint_bye2345678\xint_bye..{#2}%
}%
\def\XINT_float_MatoN #1.#2.#3.#4#5#6#7%
{%
@@ -1902,7 +1772,7 @@
{%
\expandafter\XINT_float_NaP
\the\numexpr #2-#1+#3\expandafter.%
- \romannumeral0\XINT_split_fromleft_loop #3.{}#4\W\W\W\W\W\W\W\W\Z {#3}%
+ \romannumeral0\XINT_split_fromleft#3.#4\xint_bye2345678\xint_bye..{#3}%
}%
\def\XINT_float_NaP #1.#2.#3.#4{\XINT_float_P #4.#1.#4.{#2}}%
\def\XINT_float_P #1.#2.#3.#4#5#6#7#8%
@@ -1912,7 +1782,7 @@
\def\XINT_float_Q #1.#2#3%
{%
\expandafter\XINT_float_Sa
- \romannumeral0\xintiiquo{\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}\Z {#1}%
+ \romannumeral0\xintiiquo{\XINT_dsx_addzeros {#1}#2;}{#3}\Z {#1}%
}%
\def\XINT_float_Sa #1%
{%
@@ -1922,45 +1792,40 @@
\def\XINT_float_Sb #1#2\Z #3#4%
{%
\expandafter\XINT_float_T
- \the\numexpr #4+\xint_c_i\expandafter.%
- \romannumeral`&&@\XINT_lenrord_loop 0.{}#2\Z\W\W\W\W\W\W\W\Z #1{#3}{#4}%
+ \the\numexpr\xint_c_ix\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye-#4.%
+ {#2}#1{#3}{#4}%
}%
-\def\XINT_float_T #1.#2.#3%
+\def\XINT_float_T #1.%
{%
- \ifnum #2>#1 \xint_dothis{\XINT_float_U\XINT_float_Xb}\fi
- \xint_orthat{\XINT_float_U\XINT_float_Xa #3}%
+ \if2#1\expandafter\XINT_float_Ub\else\expandafter\XINT_float_Ua\fi
}%
-\def\XINT_float_U #1#2%
+\def\XINT_float_Ua #1#2%
{%
- \ifnum #2<\xint_c_v
- \expandafter\XINT_float_Va
- \else
- \expandafter\XINT_float_Vb
- \fi #1%
+ \expandafter\XINT_float_Xa
+ \romannumeral0\expandafter#2%
+ \romannumeral0\XINT_dsrr
+ #1\xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax;%
}%
-\def\XINT_float_Va #1#2\Z #3%
+\def\XINT_float_Ub #1#2%
{%
- \expandafter#1%
- \romannumeral0\expandafter\XINT_float_Wa
- \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 \Z
+ \expandafter\XINT_float_Xb
+ \romannumeral0\expandafter#2%
+ \romannumeral0\expandafter\XINT_dsrr
+ \romannumeral0\XINT_dsr
+ #1\xint_bye\xint_Bye3456789\xint_bye+\xint_c_v)/\xint_c_x-\xint_c_i\relax
+ \xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax;%
}%
-\def\XINT_float_Vb #1#2\Z #3%
-{%
- \expandafter #1%
- \romannumeral0\expandafter #3%
- \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #2000\W\X\Y\Z \Z
-}%
\def\XINT_float_Wa #1{ #1.}%
\def\XINT_float_Wb #1#2{\if #11\xint_dothis{ 10.}\fi\xint_orthat{ #1.#2}}%
-\def\XINT_float_Xa #1\Z #2#3#4%
+\def\XINT_float_Xa #1;#2#3#4%
{%
\expandafter\XINT_float_Y\the\numexpr #3+#4-#2.{#1}%
}%
-\def\XINT_float_Xb #1\Z #2#3#4%
+\def\XINT_float_Xb #1;#2#3#4%
{%
\expandafter\XINT_float_Y\the\numexpr #3+#4+\xint_c_i-#2.{#1}%
}%
@@ -1972,11 +1837,11 @@
{\if #1!\xint_dothis\XINT_infloat_clean_a\fi\xint_orthat{ }#1}%
\def\XINT_infloat_clean_a !#1.#2[#3]%
{%
- \expandafter\XINT_infloat_sp_done
+ \expandafter\XINT_infloat_done
\the\numexpr #3-#1\expandafter.%
- \romannumeral0\XINT_dsx_addzerosnofuss {#1}{#2};%
+ \romannumeral0\XINT_dsx_addzeros {#1}#2;;%
}%
-\def\XINT_infloat_sp_done #1.#2;{ #2[#1]}%
+\def\XINT_infloat_done #1.#2;{ #2[#1]}%
\def\XINTinFloatS {\romannumeral0\XINTinfloatS}%
\def\XINTinfloatS
{\expandafter\XINT_infloatS_clean\romannumeral0\XINT_infloat}%
@@ -1990,7 +1855,7 @@
}%
\def\XINT_infloat_a #1.#2#3#4%
{%
- \if\romannumeral0\XINT_isone#4XY1\expandafter\XINT_infloat_sp
+ \if1\XINT_iSone#4XY\expandafter\XINT_infloat_sp
\else\expandafter\XINT_float_fork\fi #3.{#1}{#2}{#4}%
}%
\def\XINT_infloat_sp #1%
@@ -2024,103 +1889,62 @@
\def\XINT_infloat_sp_c #1.#2%
{%
\if #29\xint_dothis {\XINT_infloat_sp_d\XINT_infloat_Wb }\fi
- \xint_orthat {\XINT_infloat_sp_d\xint_c_ }#1.#2%
+ \xint_orthat {\XINT_infloat_sp_d .}#1.#2%
}%
\def\XINT_infloat_sp_d #1#2.#3.#4.%#5.%
{%
\expandafter\XINT_infloat_sp_e
- \romannumeral0\expandafter\XINT_split_fromleft_loop
- \the\numexpr #4+\xint_c_i.{}#3\W\W\W\W\W\W\W\W\Z #1#2.%
+ \romannumeral0\XINT_split_fromleft
+ (\xint_c_i+#4).#3\xint_bye2345678\xint_bye..#1#2.%
}%
-\def\XINT_infloat_sp_e #1.#2.%
+\def\XINT_infloat_sp_e #1.#2.#3#4.#5.%
{%
- \expandafter\XINT_infloat_sp_f
- \romannumeral0\XINT_rord_main {}#1%
- \xint_relax
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_relax ;%
+ \expandafter\XINT_infloat_done
+ \the\numexpr#4+#5\expandafter#3\romannumeral0\XINT_dsrr
+ #1\xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax;%
}%
-\def\XINT_infloat_sp_f #1%
-{%
- \ifnum #1<\xint_c_v
- \expandafter\XINT_infloat_sp_ga\else\expandafter\XINT_infloat_sp_h\fi
-}%
-\def\XINT_infloat_sp_ga #1;#2#3.#4.%
-{%
- \expandafter\XINT_infloat_sp_done\the\numexpr #3+#4\expandafter.%
- \romannumeral0\XINT_rord_main {}#1%
- \xint_relax
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_bye\xint_bye\xint_bye\xint_bye
- \xint_relax ;%
-}%
-\def\XINT_infloat_sp_h #1;#2%
-{%
- \expandafter\XINT_infloat_sp_i
- \romannumeral0\expandafter#2%
- \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z;%
-}%
-\def\XINT_infloat_sp_i #1#2;#3.#4.%
-{%
- \expandafter\XINT_infloat_sp_done\the\numexpr #1+#3+#4.#2;%
-}%
\def\XINT_infloat_Q #1.#2#3%
{%
\expandafter\XINT_infloat_Sa
- \romannumeral0\xintiiquo{\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}\Z {#1}%
+ \romannumeral0\xintiiquo{\XINT_dsx_addzeros {#1}#2;}{#3}\Z {#1}%
}%
\def\XINT_infloat_Sa #1%
{%
\if #19\xint_dothis {\XINT_infloat_Sb\XINT_infloat_Wb }\fi
- \xint_orthat {\XINT_infloat_Sb\xint_c_ }#1%
+ \xint_orthat {\XINT_infloat_Sb .}#1%
}%
\def\XINT_infloat_Sb #1#2\Z #3#4%
{%
\expandafter\XINT_infloat_T
- \the\numexpr #4+\xint_c_i\expandafter.%
- \romannumeral`&&@\XINT_lenrord_loop 0.{}#2\Z\W\W\W\W\W\W\W\Z #1{#3}%
+ \the\numexpr\xint_c_ix\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye-#4.%
+ {#2}#1{#3}%
}%
-\def\XINT_infloat_T #1.#2.#3%
+\def\XINT_infloat_T #1.%
{%
- \ifnum #2>#1 \xint_dothis{\XINT_infloat_U\XINT_infloat_Xb}\fi
- \xint_orthat{\XINT_infloat_U\XINT_infloat_Xa #3}%
+ \if2#1\expandafter\XINT_infloat_Ub\else\expandafter\XINT_infloat_Ua\fi
}%
-\def\XINT_infloat_U #1#2%
+\def\XINT_infloat_Ua #1#2#3#4%
{%
- \ifnum #2<\xint_c_v
- \expandafter\XINT_infloat_Va
- \else
- \expandafter\XINT_infloat_Vb
- \fi #1%
+ \expandafter\XINT_infloat_done
+ \the\numexpr\xint_c_i+#4-#3\romannumeral0\expandafter#2%
+ \romannumeral0\XINT_dsrr
+ #1\xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax;%
}%
-\def\XINT_infloat_Va #1#2\Z #3%
+\def\XINT_infloat_Ub #1#2#3#4%
{%
- \expandafter#1%
- \romannumeral0\expandafter\xint_c_
- \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 \Z
+ \expandafter\XINT_infloat_done
+ \the\numexpr\xint_c_ii+#4-#3\romannumeral0\expandafter#2%
+ \romannumeral0\expandafter\XINT_dsrr
+ \romannumeral0\XINT_dsr
+ #1\xint_bye\xint_Bye3456789\xint_bye+\xint_c_v)/\xint_c_x-\xint_c_i\relax
+ \xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax;%
}%
-\def\XINT_infloat_Vb #1#2\Z #3%
-{%
- \expandafter #1%
- \romannumeral0\expandafter #3%
- \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #2000\W\X\Y\Z \Z
-}%
\def\XINT_infloat_Wb #1#2%
- {\if #11\xint_dothis{\xint_c_i1}\fi\xint_orthat{\xint_c_#1#2}}%
-\def\XINT_infloat_Xa #1#2\Z #3#4%
-{%
- \expandafter\XINT_infloat_Y\the\numexpr #1+\xint_c_i+#4-#3.{#2}%
-}%
-\def\XINT_infloat_Xb #1#2\Z #3#4%
-{%
- \expandafter\XINT_infloat_Y\the\numexpr #1+\xint_c_ii+#4-#3.{#2}%
-}%
-\def\XINT_infloat_Y #1.#2{ #2[#1]}%
+ {\if #11\xint_dothis{+\xint_c_i.1}\fi\xint_orthat{.#1#2}}%
\def\xintPFloat {\romannumeral0\xintpfloat }%
\def\xintpfloat #1{\XINT_pfloat_chkopt #1\xint_relax }%
\def\XINT_pfloat_chkopt #1%
@@ -2370,7 +2194,7 @@
\def\XINT_flpow_aa #1[#2]#3%
{%
\expandafter\XINT_flpow_ab\the\numexpr #2-#3\expandafter.%
- \romannumeral0\XINT_dsx_addzerosnofuss {#3}{}.#1.%
+ \romannumeral\XINT_rep #3\endcsname0.#1.%
}%
\def\XINT_flpow_ab #1.#2.#3.{\XINT_flpow_a #3#2[#1]}%
\def\XINT_flpow_a #1%
@@ -2393,8 +2217,8 @@
\def\XINT_flpow_truncate #1.#2.#3.%
{%
\expandafter\XINT_flpow_truncate_a
- \romannumeral0\XINT_split_fromleft_loop #3.{}#2\W\W\W\W\W\W\W\W\Z
- #1.#3.%
+ \romannumeral0\XINT_split_fromleft
+ #3.#2\xint_bye2345678\xint_bye..#1.#3.%
}%
\def\XINT_flpow_truncate_a #1.#2.#3.{#3+\xintLength{#2}.#1.}%
\def\XINT_flpow_loopI #1.%
@@ -2552,7 +2376,7 @@
\def\XINT_flpower_aa #1[#2]#3%
{%
\expandafter\XINT_flpower_ab\the\numexpr #2-#3\expandafter.%
- \romannumeral0\XINT_dsx_addzerosnofuss {#3}{}.#1.%
+ \romannumeral\XINT_rep #3\endcsname0.#1.%
}%
\def\XINT_flpower_ab #1.#2.#3.{\XINT_flpower_a #3#2[#1]}%
\def\XINT_flpower_a #1%
@@ -2572,7 +2396,9 @@
\if1\XINT_isOne {#1}\xint_dothis\XINT_flpower_ItoIII\fi
\if1\xintiiOdd {#1}\xint_dothis{\expandafter\XINT_flpower_loopI_odd}\fi
\xint_orthat{\expandafter\XINT_flpower_loopI_even}%
- \romannumeral0\xinthalf{#1}.%
+ \romannumeral0\XINT_half
+ #1\xint_bye\xint_Bye345678\xint_bye
+ *\xint_c_v+\xint_c_v)/\xint_c_x-\xint_c_i\relax.%
}%
\def\XINT_flpower_ItoIII #1.#2.#3.#4.#5%
{%
@@ -2598,7 +2424,8 @@
\if1\XINT_isOne{#1}\xint_dothis\XINT_flpower_IItoIII\fi
\if1\xintiiOdd{#1}\xint_dothis{\expandafter\XINT_flpower_loopII_odd}\fi
\xint_orthat{\expandafter\XINT_flpower_loopII_even}%
- \romannumeral0\xinthalf{#1}.%
+ \romannumeral0\XINT_half#1\xint_bye\xint_Bye345678\xint_bye
+ *\xint_c_v+\xint_c_v)/\xint_c_x-\xint_c_i\relax.%
}%
\def\XINT_flpower_loopII_even #1.#2.#3.#4.%
{%
@@ -3125,13 +2952,14 @@
{%
\expandafter\XINT_flsqrt_c
\romannumeral0\xintiisub
- {\XINT_dsx_addzerosnofuss {#1}{#2}}%
- {\xintiiDivRound{\XINT_dsx_addzerosnofuss {#1}{#3}}{\XINT_dbl_pos#2\Z}}.%
+ {\XINT_dsx_addzeros {#1}#2;}%
+ {\xintiiDivRound{\XINT_dsx_addzeros {#1}#3;}%
+ {\XINT_dbl#2\xint_bye2345678\xint_bye*\xint_c_ii\relax}}.%
}%
\def\XINT_flsqrt_c #1.#2.%
{%
\expandafter\XINT_flsqrt_d
- \romannumeral0\XINT_split_fromleft_loop #2.{}#1\W\W\W\W\W\W\W\W\Z
+ \romannumeral0\XINT_split_fromleft#2.#1\xint_bye2345678\xint_bye..%
}%
\def\XINT_flsqrt_d #1.#2#3.%
{%
Modified: trunk/Master/texmf-dist/tex/generic/xint/xintgcd.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/xint/xintgcd.sty 2016-12-13 22:24:48 UTC (rev 42697)
+++ trunk/Master/texmf-dist/tex/generic/xint/xintgcd.sty 2016-12-13 22:25:04 UTC (rev 42698)
@@ -21,7 +21,7 @@
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% ---------------------------------------------------------------
-%% The xint bundle 1.2h 2016/11/20
+%% The xint bundle 1.2i 2016/12/13
%% Copyright (C) 2013-2016 by Jean-Francois Burnol
%% xintgcd: Euclidean algorithm with xint package
%% ---------------------------------------------------------------
@@ -70,7 +70,7 @@
\XINTsetupcatcodes% defined in xintkernel.sty
\XINT_providespackage
\ProvidesPackage{xintgcd}%
- [2016/11/20 1.2h Euclide algorithm with xint package (JFB)]%
+ [2016/12/13 1.2i Euclide algorithm with xint package (JFB)]%
\def\xintGCD {\romannumeral0\xintgcd }%
\def\xintgcd #1%
{%
Modified: trunk/Master/texmf-dist/tex/generic/xint/xintkernel.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/xint/xintkernel.sty 2016-12-13 22:24:48 UTC (rev 42697)
+++ trunk/Master/texmf-dist/tex/generic/xint/xintkernel.sty 2016-12-13 22:25:04 UTC (rev 42698)
@@ -21,7 +21,7 @@
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% ---------------------------------------------------------------
-%% The xint bundle 1.2h 2016/11/20
+%% The xint bundle 1.2i 2016/12/13
%% Copyright (C) 2013-2016 by Jean-Francois Burnol
%% xintkernel: Paraphernalia for the xint packages
%% ---------------------------------------------------------------
@@ -156,7 +156,7 @@
\fi
\XINT_providespackage
\ProvidesPackage {xintkernel}%
- [2016/11/20 1.2h Paraphernalia for the xint packages (JFB)]%
+ [2016/12/13 1.2i Paraphernalia for the xint packages (JFB)]%
\chardef\xint_c_ 0
\chardef\xint_c_i 1
\chardef\xint_c_ii 2
@@ -197,7 +197,7 @@
\let\XINT_tmpa\relax \let\XINT_tmpb\relax
\ifdefined\space\else\def\space { }\fi
\ifdefined\empty\else\def\empty {}\fi
-\long\def\xint_gobble_ {}%
+\let\xint_gobble_\empty
\long\def\xint_gobble_i #1{}%
\long\def\xint_gobble_ii #1#2{}%
\long\def\xint_gobble_iii #1#2#3{}%
@@ -213,45 +213,47 @@
\long\def\xint_firstofone_thenstop #1{ #1}%
\long\def\xint_firstoftwo_thenstop #1#2{ #1}%
\long\def\xint_secondoftwo_thenstop #1#2{ #2}%
-\def\xint_exchangetwo_keepbraces #1#2{{#2}{#1}}%
+\long\def\xint_exchangetwo_keepbraces #1#2{{#2}{#1}}%
\long\def\xint_gob_til_R #1\R {}%
\long\def\xint_gob_til_W #1\W {}%
\long\def\xint_gob_til_Z #1\Z {}%
-\def\xint_gob_til_zero #10{}%
-\def\xint_gob_til_one #11{}%
-\def\xint_gob_til_zeros_iii #1000{}%
-\def\xint_gob_til_zeros_iv #10000{}%
-\def\xint_gob_til_eightzeroes #100000000{}%
-\def\xint_gob_til_exclam #1!{}% catcode 12 exclam
-\def\xint_gob_til_dot #1.{}%
-\def\xint_gob_til_G #1G{}%
-\def\xint_gob_til_minus #1-{}%
-\def\xint_gob_til_relax #1\relax {}%
-\def\xint_UDzerominusfork #10-#2#3\krof {#2}%
-\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}%
-\def\xint_UDXINTWfork #1\XINT_W#2#3\krof {#2}%
-\def\xint_UDzerosfork #100#2#3\krof {#2}%
-\def\xint_UDonezerofork #110#2#3\krof {#2}%
-\def\xint_UDsignsfork #1--#2#3\krof {#2}%
+\long\def\xint_gob_til_zero #10{}%
+\long\def\xint_gob_til_one #11{}%
+\long\def\xint_gob_til_zeros_iii #1000{}%
+\long\def\xint_gob_til_zeros_iv #10000{}%
+\long\def\xint_gob_til_eightzeroes #100000000{}%
+\long\def\xint_gob_til_exclam #1!{}% catcode 12 exclam
+\long\def\xint_gob_til_dot #1.{}%
+\long\def\xint_gob_til_G #1G{}%
+\long\def\xint_gob_til_minus #1-{}%
+\long\def\xint_gob_til_relax #1\relax {}%
+\long\def\xint_UDzerominusfork #10-#2#3\krof {#2}%
+\long\def\xint_UDzerofork #10#2#3\krof {#2}%
+\long\def\xint_UDsignfork #1-#2#3\krof {#2}%
+\long\def\xint_UDwfork #1\W#2#3\krof {#2}%
+\long\def\xint_UDXINTWfork #1\XINT_W#2#3\krof {#2}%
+\long\def\xint_UDzerosfork #100#2#3\krof {#2}%
+\long\def\xint_UDonezerofork #110#2#3\krof {#2}%
+\long\def\xint_UDsignsfork #1--#2#3\krof {#2}%
\let\xint_relax\relax
\def\xint_brelax {\xint_relax }%
\long\def\xint_gob_til_xint_relax #1\xint_relax {}%
\long\def\xint_afterfi #1#2\fi {\fi #1}%
\long\def\xint_bye #1\xint_bye {}%
+\long\def\xint_Bye #1\xint_bye {}%
+\long\def\xint_bye_thenstop #1\xint_bye { }%
\long\def\xint_dothis #1#2\xint_orthat #3{\fi #1}% 1.1
\let\xint_orthat \xint_firstofone
\long\def\xintdothis #1#2\xintorthat #3{\fi #1}%
\let\xintorthat \xint_firstofone
-\def\xint_zapspaces #1 #2{#1#2\xint_zapspaces }% 1.1
-\def\xint_zapspaces_o #1{\expandafter\xint_zapspaces#1 \xint_gobble_i}%
+\long\def\xint_zapspaces #1 #2{#1#2\xint_zapspaces }% 1.1
+\long\def\xint_zapspaces_o #1{\expandafter\xint_zapspaces#1 \xint_gobble_i}%
\def\xintodef #1{\expandafter\def\expandafter#1\expandafter }%
\def\xintoodef #1{\expandafter\expandafter\expandafter\def
\expandafter\expandafter\expandafter#1%
\expandafter\expandafter\expandafter }%
-\def\xintfdef #1#2{\expandafter\def\expandafter#1\expandafter
- {\romannumeral`&&@#2}}%
+\def\xintfdef #1#2%
+ {\expandafter\def\expandafter#1\expandafter{\romannumeral`&&@#2}}%
\ifdefined\odef\else\let\odef\xintodef\fi
\ifdefined\oodef\else\let\oodef\xintoodef\fi
\ifdefined\fdef\else\let\fdef\xintfdef\fi
@@ -274,36 +276,241 @@
\noexpand\expandafter\space\noexpand\xint_gob_til_xint_relax #1%
}%
\def\xintLength {\romannumeral0\xintlength }%
-\long\def\xintlength #1%
+\long\edef\xintlength #1%
{%
- \XINT_length_loop
- 0.#1\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ \noexpand\expandafter\space
+ \noexpand\the\numexpr\xint_c_ix\noexpand\XINT_length_loop
+ #1\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\noexpand\xint_bye
+ \relax
}%
-\long\def\XINT_length_loop #1.#2#3#4#5#6#7#8#9%
+\long\def\XINT_length_loop #1#2#3#4#5#6#7#8#9%
{%
\xint_gob_til_xint_relax #9\XINT_length_finish_a\xint_relax
- \expandafter\XINT_length_loop\the\numexpr #1+\xint_c_viii.%
+ +\xint_c_ix\XINT_length_loop
}%
-\def\XINT_length_finish_a\xint_relax\expandafter\XINT_length_loop
- \the\numexpr #1+\xint_c_viii.#2\xint_bye
+\def\XINT_length_finish_a\xint_relax+\xint_c_ix\XINT_length_loop
+ #1#2#3#4#5#6#7#8#9%
{%
- \XINT_length_finish_b #2\W\W\W\W\W\W\W\Z {#1}%
+ -#9\xint_bye
}%
-\def\XINT_length_finish_b #1#2#3#4#5#6#7#8\Z
+\def\xintLastItem {\romannumeral0\xintlastitem }%
+\long\def\xintlastitem #1%
{%
+ \XINT_last_loop {}.#1%
+ {\xint_relax\XINT_last_loop_enda}{\xint_relax\XINT_last_loop_endb}%
+ {\xint_relax\XINT_last_loop_endc}{\xint_relax\XINT_last_loop_endd}%
+ {\xint_relax\XINT_last_loop_ende}{\xint_relax\XINT_last_loop_endf}%
+ {\xint_relax\XINT_last_loop_endg}{\xint_relax\XINT_last_loop_endh}\xint_bye
+}%
+\long\def\XINT_last_loop #1.#2#3#4#5#6#7#8#9%
+{%
+ \xint_gob_til_xint_relax #9%
+ {#8}{#7}{#6}{#5}{#4}{#3}{#2}{#1}\xint_relax
+ \XINT_last_loop {#9}.%
+}%
+\long\def\XINT_last_loop_enda #1#2\xint_bye{ #1}%
+\long\def\XINT_last_loop_endb #1#2#3\xint_bye{ #2}%
+\long\def\XINT_last_loop_endc #1#2#3#4\xint_bye{ #3}%
+\long\def\XINT_last_loop_endd #1#2#3#4#5\xint_bye{ #4}%
+\long\def\XINT_last_loop_ende #1#2#3#4#5#6\xint_bye{ #5}%
+\long\def\XINT_last_loop_endf #1#2#3#4#5#6#7\xint_bye{ #6}%
+\long\def\XINT_last_loop_endg #1#2#3#4#5#6#7#8\xint_bye{ #7}%
+\long\def\XINT_last_loop_endh #1#2#3#4#5#6#7#8#9\xint_bye{ #8}%
+\def\xintLengthUpTo {\romannumeral0\xintlengthupto}%
+\long\def\xintlengthupto #1#2%
+{%
+ \expandafter\XINT_lengthupto_loop
+ \the\numexpr#1.#2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+}%
+\def\XINT_lengthupto_loop #1%
+{%
+ \xint_UDsignfork #1\XINT_lengthupto_gt-{\XINT_lengthupto_loop_a#1}\krof
+}%
+\long\def\XINT_lengthupto_gt #1\xint_bye{-0}%
+\long\def\XINT_lengthupto_loop_a #1.#2#3#4#5#6#7#8#9%
+{%
+ \xint_gob_til_xint_relax #9\XINT_lengthupto_finish_a\xint_relax
+ \expandafter\XINT_lengthupto_loop\the\numexpr #1-\xint_c_viii.%
+}%
+\def\XINT_lengthupto_finish_a\xint_relax\expandafter\XINT_lengthupto_loop
+ \the\numexpr #1-\xint_c_viii.#2\xint_bye
+{%
+ \XINT_lengthupto_finish_b #2\W\W\W\W\W\W\W\Z {#1}%
+}%
+\def\XINT_lengthupto_finish_b #1#2#3#4#5#6#7#8\Z
+{%
\xint_gob_til_W
- #1\XINT_length_finish_c \xint_c_
- #2\XINT_length_finish_c \xint_c_i
- #3\XINT_length_finish_c \xint_c_ii
- #4\XINT_length_finish_c \xint_c_iii
- #5\XINT_length_finish_c \xint_c_iv
- #6\XINT_length_finish_c \xint_c_v
- #7\XINT_length_finish_c \xint_c_vi
- \W\XINT_length_finish_c \xint_c_vii\Z
+ #1\XINT_lengthupto_finish_c \xint_c_
+ #2\XINT_lengthupto_finish_c \xint_c_i
+ #3\XINT_lengthupto_finish_c \xint_c_ii
+ #4\XINT_lengthupto_finish_c \xint_c_iii
+ #5\XINT_lengthupto_finish_c \xint_c_iv
+ #6\XINT_lengthupto_finish_c \xint_c_v
+ #7\XINT_lengthupto_finish_c \xint_c_vi
+ \W\XINT_lengthupto_finish_c \xint_c_vii\Z
}%
-\edef\XINT_length_finish_c #1#2\Z #3%
- {\noexpand\expandafter\space\noexpand\the\numexpr #3+#1\relax}%
+\def\XINT_lengthupto_finish_c #1#2\Z #3%
+ {\ifnum #1>#3 \xint_dothis{-0}\fi
+ \xint_orthat{\expandafter\space\the\numexpr#3-#1\relax}}%
+\def\xintreplicate#1%
+ {\expandafter\XINT_replicate\the\numexpr#1\endcsname}%
+\def\XINT_replicate #1{\xint_UDsignfork
+ #1\XINT_rep_neg
+ -\XINT_rep
+ \krof #1}%
+\long\def\XINT_rep_neg #1\endcsname #2{\xint_c_}%
+\def\XINT_rep #1{\csname XINT_rep_f#1\XINT_rep_a}%
+\def\XINT_rep_a #1{\csname XINT_rep_#1\XINT_rep_a}%
+\def\XINT_rep_\XINT_rep_a{\endcsname}%
+\long\expandafter\def\csname XINT_rep_0\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}}%
+\long\expandafter\def\csname XINT_rep_1\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1}%
+\long\expandafter\def\csname XINT_rep_2\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1}%
+\long\expandafter\def\csname XINT_rep_3\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1}%
+\long\expandafter\def\csname XINT_rep_4\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_5\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_6\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_7\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_8\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_9\endcsname #1%
+ {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_f0\endcsname #1%
+ {\xint_c_}%
+\long\expandafter\def\csname XINT_rep_f1\endcsname #1%
+ {\xint_c_ #1}%
+\long\expandafter\def\csname XINT_rep_f2\endcsname #1%
+ {\xint_c_ #1#1}%
+\long\expandafter\def\csname XINT_rep_f3\endcsname #1%
+ {\xint_c_ #1#1#1}%
+\long\expandafter\def\csname XINT_rep_f4\endcsname #1%
+ {\xint_c_ #1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_f5\endcsname #1%
+ {\xint_c_ #1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_f6\endcsname #1%
+ {\xint_c_ #1#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_f7\endcsname #1%
+ {\xint_c_ #1#1#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_f8\endcsname #1%
+ {\xint_c_ #1#1#1#1#1#1#1#1}%
+\long\expandafter\def\csname XINT_rep_f9\endcsname #1%
+ {\xint_c_ #1#1#1#1#1#1#1#1#1}%
+\def\xintgobble #1%
+ {\csname xint_c_\expandafter\XINT_gobble_a\the\numexpr#1.0}%
+\def\XINT_gobble #1.{\csname xint_c_\XINT_gobble_a #1.0}%
+\def\XINT_gobble_a #1{\xint_gob_til_zero#1\XINT_gobble_d0\XINT_gobble_b#1}%
+\def\XINT_gobble_b #1.#2%
+ {\expandafter\XINT_gobble_c
+ \the\numexpr (#1+\xint_c_v)/\xint_c_ix-\xint_c_i\expandafter.%
+ \the\numexpr #2+\xint_c_i.#1.}%
+\def\XINT_gobble_c #1.#2.#3.%
+ {\csname XINT_g#2\the\numexpr#3-\xint_c_ix*#1\relax\XINT_gobble_a #1.#2}%
+\def\XINT_gobble_d0\XINT_gobble_b0.#1{\endcsname}%
+\expandafter\let\csname XINT_g10\endcsname\endcsname
+\long\expandafter\def\csname XINT_g11\endcsname#1{\endcsname}%
+\long\expandafter\def\csname XINT_g12\endcsname#1#2{\endcsname}%
+\long\expandafter\def\csname XINT_g13\endcsname#1#2#3{\endcsname}%
+\long\expandafter\def\csname XINT_g14\endcsname#1#2#3#4{\endcsname}%
+\long\expandafter\def\csname XINT_g15\endcsname#1#2#3#4#5{\endcsname}%
+\long\expandafter\def\csname XINT_g16\endcsname#1#2#3#4#5#6{\endcsname}%
+\long\expandafter\def\csname XINT_g17\endcsname#1#2#3#4#5#6#7{\endcsname}%
+\long\expandafter\def\csname XINT_g18\endcsname#1#2#3#4#5#6#7#8{\endcsname}%
+\expandafter\let\csname XINT_g20\endcsname\endcsname
+\long\expandafter\def\csname XINT_g21\endcsname #1#2#3#4#5#6#7#8#9%
+ {\endcsname}%
+\long\expandafter\edef\csname XINT_g22\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g21\endcsname}%
+\long\expandafter\edef\csname XINT_g23\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g22\endcsname}%
+\long\expandafter\edef\csname XINT_g24\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g23\endcsname}%
+\long\expandafter\edef\csname XINT_g25\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g24\endcsname}%
+\long\expandafter\edef\csname XINT_g26\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g25\endcsname}%
+\long\expandafter\edef\csname XINT_g27\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g26\endcsname}%
+\long\expandafter\edef\csname XINT_g28\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g27\endcsname}%
+\expandafter\let\csname XINT_g30\endcsname\endcsname
+\long\expandafter\edef\csname XINT_g31\endcsname #1#2#3#4#5#6#7#8#9%
+ {\expandafter\noexpand\csname XINT_g28\endcsname}%
+\long\expandafter\edef\csname XINT_g32\endcsname #1#2#3#4#5#6#7#8#9%
+ {\noexpand\csname XINT_g31\expandafter\noexpand\csname XINT_g28\endcsname}%
+\long\expandafter\edef\csname XINT_g33\endcsname #1#2#3#4#5#6#7#8#9%
+ {\noexpand\csname XINT_g32\expandafter\noexpand\csname XINT_g28\endcsname}%
+\long\expandafter\edef\csname XINT_g34\endcsname #1#2#3#4#5#6#7#8#9%
+ {\noexpand\csname XINT_g33\expandafter\noexpand\csname XINT_g28\endcsname}%
+\long\expandafter\edef\csname XINT_g35\endcsname #1#2#3#4#5#6#7#8#9%
+ {\noexpand\csname XINT_g34\expandafter\noexpand\csname XINT_g28\endcsname}%
+\long\expandafter\edef\csname XINT_g36\endcsname #1#2#3#4#5#6#7#8#9%
+ {\noexpand\csname XINT_g35\expandafter\noexpand\csname XINT_g28\endcsname}%
+\long\expandafter\edef\csname XINT_g37\endcsname #1#2#3#4#5#6#7#8#9%
+ {\noexpand\csname XINT_g36\expandafter\noexpand\csname XINT_g28\endcsname}%
+\long\expandafter\edef\csname XINT_g38\endcsname #1#2#3#4#5#6#7#8#9%
+ {\noexpand\csname XINT_g37\expandafter\noexpand\csname XINT_g28\endcsname}%
+\expandafter\let\csname XINT_g40\endcsname\endcsname
+\expandafter\edef\csname XINT_g41\endcsname
+ {\noexpand\csname XINT_g38\expandafter\noexpand\csname XINT_g31\endcsname}%
+\expandafter\edef\csname XINT_g42\endcsname
+ {\noexpand\csname XINT_g41\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\edef\csname XINT_g43\endcsname
+ {\noexpand\csname XINT_g42\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\edef\csname XINT_g44\endcsname
+ {\noexpand\csname XINT_g43\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\edef\csname XINT_g45\endcsname
+ {\noexpand\csname XINT_g44\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\edef\csname XINT_g46\endcsname
+ {\noexpand\csname XINT_g45\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\edef\csname XINT_g47\endcsname
+ {\noexpand\csname XINT_g46\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\edef\csname XINT_g48\endcsname
+ {\noexpand\csname XINT_g47\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\let\csname XINT_g50\endcsname\endcsname
+\expandafter\edef\csname XINT_g51\endcsname
+ {\noexpand\csname XINT_g48\expandafter\noexpand\csname XINT_g41\endcsname}%
+\expandafter\edef\csname XINT_g52\endcsname
+ {\noexpand\csname XINT_g51\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\edef\csname XINT_g53\endcsname
+ {\noexpand\csname XINT_g52\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\edef\csname XINT_g54\endcsname
+ {\noexpand\csname XINT_g53\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\edef\csname XINT_g55\endcsname
+ {\noexpand\csname XINT_g54\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\edef\csname XINT_g56\endcsname
+ {\noexpand\csname XINT_g55\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\edef\csname XINT_g57\endcsname
+ {\noexpand\csname XINT_g56\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\edef\csname XINT_g58\endcsname
+ {\noexpand\csname XINT_g57\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\let\csname XINT_g60\endcsname\endcsname
+\expandafter\edef\csname XINT_g61\endcsname
+ {\noexpand\csname XINT_g58\expandafter\noexpand\csname XINT_g51\endcsname}%
+\expandafter\edef\csname XINT_g62\endcsname
+ {\noexpand\csname XINT_g61\expandafter\noexpand\csname XINT_g61\endcsname}%
+\expandafter\edef\csname XINT_g63\endcsname
+ {\noexpand\csname XINT_g62\expandafter\noexpand\csname XINT_g61\endcsname}%
+\expandafter\edef\csname XINT_g64\endcsname
+ {\noexpand\csname XINT_g63\expandafter\noexpand\csname XINT_g61\endcsname}%
+\expandafter\edef\csname XINT_g65\endcsname
+ {\noexpand\csname XINT_g64\expandafter\noexpand\csname XINT_g61\endcsname}%
+\expandafter\edef\csname XINT_g66\endcsname
+ {\noexpand\csname XINT_g65\expandafter\noexpand\csname XINT_g61\endcsname}%
+\expandafter\edef\csname XINT_g67\endcsname
+ {\noexpand\csname XINT_g66\expandafter\noexpand\csname XINT_g61\endcsname}%
+\expandafter\edef\csname XINT_g68\endcsname
+ {\noexpand\csname XINT_g67\expandafter\noexpand\csname XINT_g61\endcsname}%
\def\xintMessage #1#2#3{%
\immediate\write128{Package #1 #2: (on line \the\inputlineno)}%
\immediate\write128{\space\space\space\space#3}%
Modified: trunk/Master/texmf-dist/tex/generic/xint/xintseries.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/xint/xintseries.sty 2016-12-13 22:24:48 UTC (rev 42697)
+++ trunk/Master/texmf-dist/tex/generic/xint/xintseries.sty 2016-12-13 22:25:04 UTC (rev 42698)
@@ -21,7 +21,7 @@
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% ---------------------------------------------------------------
-%% The xint bundle 1.2h 2016/11/20
+%% The xint bundle 1.2i 2016/12/13
%% Copyright (C) 2013-2016 by Jean-Francois Burnol
%% xintseries: Expandable partial sums with xint package
%% ---------------------------------------------------------------
@@ -70,7 +70,7 @@
\XINTsetupcatcodes% defined in xintkernel.sty
\XINT_providespackage
\ProvidesPackage{xintseries}%
- [2016/11/20 1.2h Expandable partial sums with xint package (JFB)]%
+ [2016/12/13 1.2i Expandable partial sums with xint package (JFB)]%
\def\xintSeries {\romannumeral0\xintseries }%
\def\xintseries #1#2%
{%
Modified: trunk/Master/texmf-dist/tex/generic/xint/xinttools.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/xint/xinttools.sty 2016-12-13 22:24:48 UTC (rev 42697)
+++ trunk/Master/texmf-dist/tex/generic/xint/xinttools.sty 2016-12-13 22:25:04 UTC (rev 42698)
@@ -21,7 +21,7 @@
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% ---------------------------------------------------------------
-%% The xint bundle 1.2h 2016/11/20
+%% The xint bundle 1.2i 2016/12/13
%% Copyright (C) 2013-2016 by Jean-Francois Burnol
%% xinttools: Expandable and non-expandable utilities
%% ---------------------------------------------------------------
@@ -70,7 +70,7 @@
\XINTsetupcatcodes% defined in xintkernel.sty
\XINT_providespackage
\ProvidesPackage{xinttools}%
- [2016/11/20 1.2h Expandable and non-expandable utilities (JFB)]%
+ [2016/12/13 1.2i Expandable and non-expandable utilities (JFB)]%
\newtoks\XINT_toks
\xint_firstofone{\let\XINT_sptoken= } %<- space here!
\def\xintgodef {\global\xintodef }%
@@ -237,8 +237,8 @@
\def\XINT_nthelt_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_nthelt_zero }%
- 0#1{\XINT_nthelt_neg }%
+ #1-\XINT_nthelt_zero
+ 0#1\XINT_nthelt_neg
0-{\XINT_nthelt_pos #1}%
\krof
}%
@@ -245,49 +245,50 @@
\def\XINT_nthelt_zero .{\xintlength }%
\long\def\XINT_nthelt_neg #1.#2%
{%
- \expandafter\XINT_nthelt_neg_a\the\numexpr
- \XINT_length_loop
- 0.#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye +\xint_c_i -#1.%
- #2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ \expandafter\XINT_nthelt_neg_a\the\numexpr\xint_c_x\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ -#1.#2\xint_bye
}%
\def\XINT_nthelt_neg_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_nthelt_none }%
- 0#1{\XINT_nthelt_none }%
- 0-{\XINT_nthelt_loop_a #1}%
+ #1-\xint_byeandstop
+ 0#1\xint_byeandstop
+ 0-{}%
\krof
+ \expandafter\XINT_nthelt_neg_b
+ \romannumeral\expandafter\XINT_gobble\the\numexpr-\xint_c_i+#1%
}%
-\long\def\XINT_nthelt_none #1\xint_bye{ }%
+\long\def\XINT_nthelt_neg_b #1#2\xint_bye{ #1}%
\long\def\XINT_nthelt_pos #1.#2%
{%
- \XINT_nthelt_loop_a #1.%
+ \expandafter\XINT_nthelt_loop\the\numexpr\xint_c_ix-#1.%
#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
}%
-\def\XINT_nthelt_loop_a #1.%
+\def\XINT_nthelt_loop #1%
{%
- \ifnum #1>\xint_c_viii
- \expandafter\XINT_nthelt_loop_b
- \else
- \expandafter\XINT_nthelt_getit
- \fi #1.%
+ \xint_UDsignfork
+ #1\XINT_nthelt_loop_a
+ -{\XINT_nthelt_getit #1}%
+ \krof
}%
-\long\def\XINT_nthelt_loop_b #1.#2#3#4#5#6#7#8#9%
+\long\def\XINT_nthelt_loop_a #1.#2#3#4#5#6#7#8#9%
{%
- \xint_gob_til_xint_relax #9\XINT_nthelt_none\xint_relax
- \expandafter\XINT_nthelt_loop_a\the\numexpr #1-\xint_c_viii.%
+ \xint_gob_til_xint_relax #9\xint_byeandstop\xint_relax
+ \expandafter\XINT_nthelt_loop\the\numexpr\xint_c_viii-#1.%
}%
\def\XINT_nthelt_getit #1.%
{%
\expandafter\expandafter\expandafter\XINT_nthelt_finish
- \csname xint_gobble_\romannumeral\numexpr#1-\xint_c_i\endcsname
+ \csname xint_gobble_\romannumeral\numexpr\xint_c_viii-#1\endcsname
}%
\long\edef\XINT_nthelt_finish #1#2\xint_bye
{\noexpand\xint_gob_til_xint_relax #1\noexpand\expandafter\space
- \noexpand\xint_gobble_ii\xint_relax\space #1}%
+ \noexpand\xint_gobble_ii\xint_relax\space #1}%
\def\xintKeep {\romannumeral0\xintkeep }%
\def\xintKeepNoExpand {\romannumeral0\xintkeepnoexpand }%
\long\def\xintkeep #1#2{\expandafter\XINT_keep_a\the\numexpr #1\expandafter.%
@@ -296,8 +297,8 @@
\def\XINT_keep_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_keep_keepnone }%
- 0#1{\XINT_keep_neg }%
+ #1-\XINT_keep_keepnone
+ 0#1\XINT_keep_neg
0-{\XINT_keep_pos #1}%
\krof
}%
@@ -305,84 +306,55 @@
\long\def\XINT_keep_neg #1.#2%
{%
\expandafter\XINT_keep_neg_a\the\numexpr
- \XINT_length_loop
- 0.#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye -#1.%
- #2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ #1-\numexpr\xint_c_ix\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye.#2%
}%
\def\XINT_keep_neg_a #1%
{%
- \xint_UDzerominusfork
- #1-{\XINT_keep_keepall }%
- 0#1{\XINT_keep_keepall }%
- 0-{\XINT_trim_loop_a #1}%
+ \xint_UDsignfork
+ #1{\expandafter\space\romannumeral\XINT_gobble}%
+ -\XINT_keep_keepall
\krof
}%
-\def\XINT_keep_keepall #1.{\XINT_keep_keepall_a \space}%
-\def\XINT_keep_keepall_a #1\xint_relax #2\xint_bye {#1}%
+\def\XINT_keep_keepall #1.{ }%
\long\def\XINT_keep_pos #1.#2%
{%
- \XINT_keep_loop_a #1.%
- {}#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_bye
+ \expandafter\XINT_keep_loop
+ \the\numexpr#1-\XINT_lengthupto_loop
+ #1.#2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ -\xint_c_viii.{}#2\xint_bye%
}%
-\def\XINT_keep_loop_a #1.%
+\def\XINT_keep_loop #1#2.%
{%
- \ifnum #1>\xint_c_vi
- \expandafter\XINT_keep_loop_b
- \else
- \expandafter\XINT_keep_finish
- \fi
- #1.%
+ \xint_gob_til_minus#1\XINT_keep_loop_end-%
+ \expandafter\XINT_keep_loop
+ \the\numexpr#1#2-\xint_c_viii\expandafter.\XINT_keep_loop_pickeight
}%
-\long\def\XINT_keep_loop_b #1.#2#3#4#5#6#7#8#9%
-{%
- \xint_gob_til_xint_relax #9\XINT_keep_enda\xint_relax
- \expandafter\XINT_keep_loop_c\the\numexpr #1-\xint_c_vii.%
- {{#3}{#4}{#5}{#6}{#7}{#8}{#9}}{#2}%
-}%
-\long\def\XINT_keep_loop_c #1.#2#3{\XINT_keep_loop_a #1.{#3#2}}%
-\long\def\XINT_keep_enda #1.#2#3#4\xint_bye
-{%
- \XINT_keep_endb #4\W\W\W\W\W\W\Z #2{#3}%
-}%
-\def\XINT_keep_endb #1#2#3#4#5#6#7\Z
-{%
- \xint_gob_til_W
- #1\XINT_keep_endc_
- #2\XINT_keep_endc_i
- #3\XINT_keep_endc_ii
- #4\XINT_keep_endc_iii
- #5\XINT_keep_endc_iv
- #6\XINT_keep_endc_v
- \W\XINT_keep_endc_vi\Z
-}%
-\long\def\XINT_keep_endc_ #1\Z #2#3#4#5#6#7#8#9{ #9}%
-\long\def\XINT_keep_endc_i #1\Z #2#3#4#5#6#7#8#9{#9{#2}}%
-\long\def\XINT_keep_endc_ii #1\Z #2#3#4#5#6#7#8#9{#9{#2}{#3}}%
-\long\def\XINT_keep_endc_iii #1\Z #2#3#4#5#6#7#8#9{#9{#2}{#3}{#4}}%
-\long\def\XINT_keep_endc_iv #1\Z #2#3#4#5#6#7#8#9{#9{#2}{#3}{#4}{#5}}%
-\long\def\XINT_keep_endc_v #1\Z #2#3#4#5#6#7#8#9{#9{#2}{#3}{#4}{#5}{#6}}%
-\long\def\XINT_keep_endc_vi\Z #1#2#3#4#5#6#7#8{#8{#1}{#2}{#3}{#4}{#5}{#6}}%
-\long\def\XINT_keep_finish #1.#2#3#4#5#6#7#8#9\xint_bye
-{%
- \XINT_keep_finish_a #1.%
- #3\xint_c_ #4\xint_c_i #5\xint_c_ii #6\xint_c_iii #7\xint_c_iv
- #8\xint_c_v\xint_relax\xint_c_vi\xint_bye
- {#3}{#4}{#5}{#6}{#7}{#8}\xint_bye {#2}%
-}%
-\long\def\XINT_keep_finish_a #1.#2\xint_relax #3#4\xint_bye
-{%
- \csname XINT_keep_finish_b\romannumeral\ifnum#1>#3#3\else#1\fi\endcsname
-}%
-\long\def\XINT_keep_finish_b #1\xint_bye #2{ #2}%
-\long\def\XINT_keep_finish_bi #1#2\xint_bye #3{#3{#1}}%
-\long\def\XINT_keep_finish_bii #1#2#3\xint_bye #4{#4{#1}{#2}}%
-\long\def\XINT_keep_finish_biii#1#2#3#4\xint_bye #5{#5{#1}{#2}{#3}}%
-\long\def\XINT_keep_finish_biv #1#2#3#4#5\xint_bye #6{#6{#1}{#2}{#3}{#4}}%
-\long\def\XINT_keep_finish_bv #1#2#3#4#5#6\xint_bye #7{#7{#1}{#2}{#3}{#4}{#5}}%
-\long\def\XINT_keep_finish_bvi #1\xint_bye #2{#2#1}%
+\long\def\XINT_keep_loop_pickeight
+ #1#2#3#4#5#6#7#8#9{{#1{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}}}%
+\def\XINT_keep_loop_end-\expandafter\XINT_keep_loop
+ \the\numexpr-#1-\xint_c_viii\expandafter.\XINT_keep_loop_pickeight
+ {\csname XINT_keep_end#1\endcsname}%
+\long\expandafter\def\csname XINT_keep_end1\endcsname
+ #1#2#3#4#5#6#7#8#9\xint_bye { #1{#2}{#3}{#4}{#5}{#6}{#7}{#8}}%
+\long\expandafter\def\csname XINT_keep_end2\endcsname
+ #1#2#3#4#5#6#7#8\xint_bye { #1{#2}{#3}{#4}{#5}{#6}{#7}}%
+\long\expandafter\def\csname XINT_keep_end3\endcsname
+ #1#2#3#4#5#6#7\xint_bye { #1{#2}{#3}{#4}{#5}{#6}}%
+\long\expandafter\def\csname XINT_keep_end4\endcsname
+ #1#2#3#4#5#6\xint_bye { #1{#2}{#3}{#4}{#5}}%
+\long\expandafter\def\csname XINT_keep_end5\endcsname
+ #1#2#3#4#5\xint_bye { #1{#2}{#3}{#4}}%
+\long\expandafter\def\csname XINT_keep_end6\endcsname
+ #1#2#3#4\xint_bye { #1{#2}{#3}}%
+\long\expandafter\def\csname XINT_keep_end7\endcsname
+ #1#2#3\xint_bye { #1{#2}}%
+\long\expandafter\def\csname XINT_keep_end8\endcsname
+ #1#2\xint_bye { #1}%
\def\xintKeepUnbraced {\romannumeral0\xintkeepunbraced }%
\def\xintKeepUnbracedNoExpand {\romannumeral0\xintkeepunbracednoexpand }%
\long\def\xintkeepunbraced #1#2%
@@ -393,74 +365,46 @@
\def\XINT_keepunbr_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_keep_keepnone }%
- 0#1{\XINT_keep_neg }%
+ #1-\XINT_keep_keepnone
+ 0#1\XINT_keep_neg
0-{\XINT_keepunbr_pos #1}%
\krof
}%
\long\def\XINT_keepunbr_pos #1.#2%
{%
- \XINT_keepunbr_loop_a #1.%
- {}#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_bye
+ \expandafter\XINT_keepunbr_loop
+ \the\numexpr#1-\XINT_lengthupto_loop
+ #1.#2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
+ -\xint_c_viii.{}#2\xint_bye%
}%
-\def\XINT_keepunbr_loop_a #1.%
+\def\XINT_keepunbr_loop #1#2.%
{%
- \ifnum #1>\xint_c_vi
- \expandafter\XINT_keepunbr_loop_b
- \else
- \expandafter\XINT_keepunbr_finish
- \fi
- #1.%
+ \xint_gob_til_minus#1\XINT_keepunbr_loop_end-%
+ \expandafter\XINT_keepunbr_loop
+ \the\numexpr#1#2-\xint_c_viii\expandafter.\XINT_keepunbr_loop_pickeight
}%
-\long\def\XINT_keepunbr_loop_b #1.#2#3#4#5#6#7#8#9%
-{%
- \xint_gob_til_xint_relax #9\XINT_keepunbr_enda\xint_relax
- \expandafter\XINT_keepunbr_loop_c\the\numexpr #1-\xint_c_vii.%
- {#3}{#4}{#5}{#6}{#7}{#8}{#9}.{#2}%
-}%
-\long\def\XINT_keepunbr_loop_c #1.#2#3#4#5#6#7#8.#9%
- {\XINT_keepunbr_loop_a #1.{#9#2#3#4#5#6#7#8}}%
-\long\def\XINT_keepunbr_enda #1.#2.#3#4\xint_bye
-{%
- \XINT_keepunbr_endb #4\W\W\W\W\W\W\Z #2{#3}%
-}%
-\def\XINT_keepunbr_endb #1#2#3#4#5#6#7\Z
-{%
- \xint_gob_til_W
- #1\XINT_keepunbr_endc_
- #2\XINT_keepunbr_endc_i
- #3\XINT_keepunbr_endc_ii
- #4\XINT_keepunbr_endc_iii
- #5\XINT_keepunbr_endc_iv
- #6\XINT_keepunbr_endc_v
- \W\XINT_keepunbr_endc_vi\Z
-}%
-\long\def\XINT_keepunbr_endc_ #1\Z #2#3#4#5#6#7#8#9{ #9}%
-\long\def\XINT_keepunbr_endc_i #1\Z #2#3#4#5#6#7#8#9{ #9#2}%
-\long\def\XINT_keepunbr_endc_ii #1\Z #2#3#4#5#6#7#8#9{ #9#2#3}%
-\long\def\XINT_keepunbr_endc_iii #1\Z #2#3#4#5#6#7#8#9{ #9#2#3#4}%
-\long\def\XINT_keepunbr_endc_iv #1\Z #2#3#4#5#6#7#8#9{ #9#2#3#4#5}%
-\long\def\XINT_keepunbr_endc_v #1\Z #2#3#4#5#6#7#8#9{ #9#2#3#4#5#6}%
-\long\def\XINT_keepunbr_endc_vi\Z #1#2#3#4#5#6#7#8{ #8#1#2#3#4#5#6}%
-\long\def\XINT_keepunbr_finish #1.#2#3#4#5#6#7#8#9\xint_bye
-{%
- \XINT_keepunbr_finish_a #1.%
- #3\xint_c_ #4\xint_c_i #5\xint_c_ii #6\xint_c_iii #7\xint_c_iv
- #8\xint_c_v\xint_relax\xint_c_vi\xint_bye
- {#3}{#4}{#5}{#6}{#7}{#8}\xint_bye {#2}%
-}%
-\long\def\XINT_keepunbr_finish_a #1.#2\xint_relax #3#4\xint_bye
-{%
- \csname XINT_keepunbr_finish_b\romannumeral\ifnum#1>#3#3\else#1\fi\endcsname
-}%
-\long\def\XINT_keepunbr_finish_b #1\xint_bye #2{ #2}%
-\long\def\XINT_keepunbr_finish_bi #1#2\xint_bye #3{ #3#1}%
-\long\def\XINT_keepunbr_finish_bii #1#2#3\xint_bye #4{ #4#1#2}%
-\long\def\XINT_keepunbr_finish_biii#1#2#3#4\xint_bye #5{ #5#1#2#3}%
-\long\def\XINT_keepunbr_finish_biv #1#2#3#4#5\xint_bye #6{ #6#1#2#3#4}%
-\long\def\XINT_keepunbr_finish_bv #1#2#3#4#5#6\xint_bye #7{ #7#1#2#3#4#5}%
-\long\def\XINT_keepunbr_finish_bvi #1#2#3#4#5#6\xint_bye #7{ #7#1#2#3#4#5#6}%
+\long\def\XINT_keepunbr_loop_pickeight
+ #1#2#3#4#5#6#7#8#9{{#1#2#3#4#5#6#7#8#9}}%
+\def\XINT_keepunbr_loop_end-\expandafter\XINT_keepunbr_loop
+ \the\numexpr-#1-\xint_c_viii\expandafter.\XINT_keepunbr_loop_pickeight
+ {\csname XINT_keepunbr_end#1\endcsname}%
+\long\expandafter\def\csname XINT_keepunbr_end1\endcsname
+ #1#2#3#4#5#6#7#8#9\xint_bye { #1#2#3#4#5#6#7#8}%
+\long\expandafter\def\csname XINT_keepunbr_end2\endcsname
+ #1#2#3#4#5#6#7#8\xint_bye { #1#2#3#4#5#6#7}%
+\long\expandafter\def\csname XINT_keepunbr_end3\endcsname
+ #1#2#3#4#5#6#7\xint_bye { #1#2#3#4#5#6}%
+\long\expandafter\def\csname XINT_keepunbr_end4\endcsname
+ #1#2#3#4#5#6\xint_bye { #1#2#3#4#5}%
+\long\expandafter\def\csname XINT_keepunbr_end5\endcsname
+ #1#2#3#4#5\xint_bye { #1#2#3#4}%
+\long\expandafter\def\csname XINT_keepunbr_end6\endcsname
+ #1#2#3#4\xint_bye { #1#2#3}%
+\long\expandafter\def\csname XINT_keepunbr_end7\endcsname
+ #1#2#3\xint_bye { #1#2}%
+\long\expandafter\def\csname XINT_keepunbr_end8\endcsname
+ #1#2\xint_bye { #1}%
\def\xintTrim {\romannumeral0\xinttrim }%
\def\xintTrimNoExpand {\romannumeral0\xinttrimnoexpand }%
\long\def\xinttrim #1#2{\expandafter\XINT_trim_a\the\numexpr #1\expandafter.%
@@ -469,8 +413,8 @@
\def\XINT_trim_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_trim_trimnone }%
- 0#1{\XINT_trim_neg }%
+ #1-\XINT_trim_trimnone
+ 0#1\XINT_trim_neg
0-{\XINT_trim_pos #1}%
\krof
}%
@@ -478,47 +422,44 @@
\long\def\XINT_trim_neg #1.#2%
{%
\expandafter\XINT_trim_neg_a\the\numexpr
- \XINT_length_loop
- 0.#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye -#1.%
- {}#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_bye
+ #1-\numexpr\xint_c_ix\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ .{}#2\xint_bye
}%
\def\XINT_trim_neg_a #1%
{%
- \xint_UDzerominusfork
- #1-{\XINT_trim_trimall }%
- 0#1{\XINT_trim_trimall }%
- 0-{\XINT_keep_loop_a #1}%
+ \xint_UDsignfork
+ #1{\expandafter\XINT_keep_loop\the\numexpr-\xint_c_viii+}%
+ -\XINT_trim_trimall
\krof
}%
-\long\def\XINT_trim_trimall #1\xint_bye { }%
+\edef\XINT_trim_trimall {\noexpand\expandafter\space\noexpand\xint_bye}%
\long\def\XINT_trim_pos #1.#2%
{%
- \XINT_trim_loop_a #1.%
+ \expandafter\XINT_trim_loop\the\numexpr#1-\xint_c_viii.%
#2\xint_relax\xint_relax\xint_relax\xint_relax
\xint_relax\xint_relax\xint_relax\xint_relax\xint_bye
}%
-\def\XINT_trim_loop_a #1.%
+\def\XINT_trim_loop #1%
{%
- \ifnum #1>\xint_c_vii
- \expandafter\XINT_trim_loop_b
- \else
- \expandafter\XINT_trim_finish
- \fi
- #1.%
+ \xint_UDsignfork
+ #1\XINT_trim_finish
+ -\XINT_trim_loop_a
+ \krof #1%
}%
-\long\def\XINT_trim_loop_b #1.#2#3#4#5#6#7#8#9%
+\long\def\XINT_trim_loop_a #1.#2#3#4#5#6#7#8#9%
{%
- \xint_gob_til_xint_relax #9\XINT_trim_silentend\xint_relax
- \expandafter\XINT_trim_loop_a\the\numexpr #1-\xint_c_viii.%
+ \xint_gob_til_xint_relax #9\xint_bye_thenstop\xint_relax
+ \expandafter\XINT_trim_loop\the\numexpr#1-\xint_c_viii.%
}%
-\def\XINT_trim_silentend #1\xint_bye { }%
-\def\XINT_trim_finish #1.%
+\def\XINT_trim_finish -#1.%
{%
\expandafter\expandafter\expandafter\XINT_trim_finish_a
- \expandafter\expandafter\expandafter\space % avoids brace removal
- \csname xint_gobble_\romannumeral#1\endcsname
+ \expandafter\expandafter\expandafter\space
+ \csname xint_gobble_\romannumeral\numexpr\xint_c_viii-#1\endcsname
}%
\long\def\XINT_trim_finish_a #1\xint_relax #2\xint_bye {#1}%
\def\xintTrimUnbraced {\romannumeral0\xinttrimunbraced }%
@@ -531,8 +472,8 @@
\def\XINT_trimunbr_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_trim_trimnone }%
- 0#1{\XINT_trimunbr_neg }%
+ #1-\XINT_trim_trimnone
+ 0#1\XINT_trimunbr_neg
0-{\XINT_trim_pos #1}%
\krof
}%
@@ -539,18 +480,18 @@
\long\def\XINT_trimunbr_neg #1.#2%
{%
\expandafter\XINT_trimunbr_neg_a\the\numexpr
- \XINT_length_loop
- 0.#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye -#1.%
- {}#2\xint_relax\xint_relax\xint_relax\xint_relax
- \xint_relax\xint_relax\xint_relax\xint_bye
+ #1-\numexpr\xint_c_ix\XINT_length_loop
+ #2\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax
+ \xint_c_i\xint_c_ii\xint_c_iii\xint_c_iv
+ \xint_c_v\xint_c_vi\xint_c_vii\xint_c_viii\xint_c_ix\xint_bye
+ .{}#2\xint_bye
}%
\def\XINT_trimunbr_neg_a #1%
{%
- \xint_UDzerominusfork
- #1-{\XINT_trim_trimall }%
- 0#1{\XINT_trim_trimall }%
- 0-{\XINT_keepunbr_loop_a #1}%
+ \xint_UDsignfork
+ #1{\expandafter\XINT_keepunbr_loop\the\numexpr-\xint_c_viii+}%
+ -\XINT_trim_trimall
\krof
}%
\def\xintApply {\romannumeral0\xintapply }%
@@ -813,6 +754,7 @@
\long\def\xintBreakFor #1Z{}%
\long\def\xintBreakForAndDo #1#2Z{#1}%
\def\xintFor {\let\xintifForFirst\xint_firstoftwo
+ \let\xintifForLast\xint_secondoftwo
\futurelet\XINT_token\XINT_for_ifstar }%
\def\XINT_for_ifstar {\ifx\XINT_token*\expandafter\XINT_forx
\else\expandafter\XINT_for \fi }%
@@ -873,7 +815,8 @@
\XINT_toks {{#3}}%
\long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
\the\XINT_toks \csname XINT_for_right#1\endcsname }%
- \XINT_toks {\XINT_x\let\xintifForFirst\xint_secondoftwo\XINT_for_d #1{#2}}%
+ \XINT_toks {\XINT_x\let\xintifForFirst\xint_secondoftwo
+ \let\xintifForLast\xint_secondoftwo\XINT_for_d #1{#2}}%
\futurelet\XINT_token\XINT_for_last?
}%
\long\def\XINT_forx_d #1#2#3%
@@ -882,16 +825,20 @@
\XINT_toks {{#3}}%
\long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
\the\XINT_toks \csname XINT_for_right#1\endcsname }%
- \XINT_toks {\XINT_x\let\xintifForFirst\xint_secondoftwo\XINT_forx_d #1{#2}}%
+ \XINT_toks {\XINT_x\let\xintifForFirst\xint_secondoftwo
+ \let\xintifForLast\xint_secondoftwo\XINT_forx_d #1{#2}}%
\XINT_xflet\XINT_for_last?
}%
\def\XINT_for_last?
{%
- \let\xintifForLast\xint_secondoftwo
- \ifx\XINT_token Z\let\xintifForLast\xint_firstoftwo
- \xint_afterfi{\xintBreakForAndDo{\XINT_x\xint_gobble_i Z}}\fi
- \the\XINT_toks
+ \ifx\XINT_token Z\expandafter\XINT_for_last?yes\fi
+ \the\XINT_toks
}%
+\def\XINT_for_last?yes
+{%
+ \let\xintifForLast\xint_firstoftwo
+ \xintBreakForAndDo{\XINT_x\xint_gobble_i Z}%
+}%
\catcode`U 3
\catcode`D 3
\catcode`V 3
@@ -980,6 +927,7 @@
\the\XINT_toks \csname XINT_for_right#1\endcsname }%
\XINT_x
\let\xintifForFirst\xint_secondoftwo
+ \let\xintifForLast\xint_secondoftwo
\expandafter\XINT_forever_d\expandafter #1\romannumeral`&&@#4{#2}{#3}#4{#5}%
}%
\catcode`j 3
@@ -986,6 +934,7 @@
\long\def\xintForpair #1#2#3in#4#5#6%
{%
\let\xintifForFirst\xint_firstoftwo
+ \let\xintifForLast\xint_secondoftwo
\XINT_toks {\XINT_forpair_d #2{#6}}%
\expandafter\the\expandafter\XINT_toks #4jZ%
}%
@@ -995,18 +944,16 @@
\XINT_toks \expandafter{\romannumeral0\xintcsvtolist{ #4}}%
\long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
\the\XINT_toks \csname XINT_for_right\the\numexpr#1+\xint_c_i\endcsname}%
+ \ifx #5j\expandafter\XINT_for_last?yes\fi
+ \XINT_x
+ \let\xintifForFirst\xint_secondoftwo
\let\xintifForLast\xint_secondoftwo
- \ifx #5j\expandafter\xint_firstoftwo
- \else\expandafter\xint_secondoftwo
- \fi
- {\let\xintifForLast\xint_firstoftwo
- \xintBreakForAndDo {\XINT_x \xint_gobble_i Z}}%
- \XINT_x
- \let\xintifForFirst\xint_secondoftwo\XINT_forpair_d #1{#2}%
+ \XINT_forpair_d #1{#2}%
}%
\long\def\xintForthree #1#2#3in#4#5#6%
{%
\let\xintifForFirst\xint_firstoftwo
+ \let\xintifForLast\xint_secondoftwo
\XINT_toks {\XINT_forthree_d #2{#6}}%
\expandafter\the\expandafter\XINT_toks #4jZ%
}%
@@ -1016,18 +963,16 @@
\XINT_toks \expandafter{\romannumeral0\xintcsvtolist{ #4}}%
\long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
\the\XINT_toks \csname XINT_for_right\the\numexpr#1+\xint_c_ii\endcsname}%
+ \ifx #5j\expandafter\XINT_for_last?yes\fi
+ \XINT_x
+ \let\xintifForFirst\xint_secondoftwo
\let\xintifForLast\xint_secondoftwo
- \ifx #5j\expandafter\xint_firstoftwo
- \else\expandafter\xint_secondoftwo
- \fi
- {\let\xintifForLast\xint_firstoftwo
- \xintBreakForAndDo {\XINT_x \xint_gobble_i Z}}%
- \XINT_x
- \let\xintifForFirst\xint_secondoftwo\XINT_forthree_d #1{#2}%
+ \XINT_forthree_d #1{#2}%
}%
\long\def\xintForfour #1#2#3in#4#5#6%
{%
\let\xintifForFirst\xint_firstoftwo
+ \let\xintifForLast\xint_secondoftwo
\XINT_toks {\XINT_forfour_d #2{#6}}%
\expandafter\the\expandafter\XINT_toks #4jZ%
}%
@@ -1037,14 +982,11 @@
\XINT_toks \expandafter{\romannumeral0\xintcsvtolist{ #4}}%
\long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
\the\XINT_toks \csname XINT_for_right\the\numexpr#1+\xint_c_iii\endcsname}%
+ \ifx #5j\expandafter\XINT_for_last?yes\fi
+ \XINT_x
+ \let\xintifForFirst\xint_secondoftwo
\let\xintifForLast\xint_secondoftwo
- \ifx #5j\expandafter\xint_firstoftwo
- \else\expandafter\xint_secondoftwo
- \fi
- {\let\xintifForLast\xint_firstoftwo
- \xintBreakForAndDo {\XINT_x \xint_gobble_i Z}}%
- \XINT_x
- \let\xintifForFirst\xint_secondoftwo\XINT_forfour_d #1{#2}%
+ \XINT_forfour_d #1{#2}%
}%
\catcode`Z 11
\catcode`j 11
@@ -1221,10 +1163,9 @@
}%
\def\XINT_trim:f:csv_loop_b #1.#2,#3,#4,#5,#6,#7,#8,#9,%
{%
- \xint_gob_til_xint_relax #9\XINT_trim:f:csv_silentend\xint_relax
+ \xint_gob_til_xint_relax #9\xint_bye_thenstop\xint_relax
\expandafter\XINT_trim:f:csv_loop_a\the\numexpr #1-\xint_c_viii.%
}%
-\def\XINT_trim:f:csv_silentend #1\xint_bye { }%
\def\XINT_trim:f:csv_finish #1.%
{%
\expandafter\XINT_trim:f:csv_finish_a
@@ -1249,12 +1190,11 @@
\def\XINT_keep:f:csv_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_keep:f:csv_zero }%
- 0#1{\XINT_keep:f:csv_neg }%
+ #1-\xint_bye_thenstop
+ 0#1\XINT_keep:f:csv_neg
0-{\XINT_keep:f:csv_pos #1}%
\krof
}%
-\def\XINT_keep:f:csv_zero .#1\xint_bye{ }%
\def\XINT_keep:f:csv_neg #1.#2\xint_relax%
{%
\expandafter\XINT_keep:f:csv_neg_b
@@ -1336,12 +1276,11 @@
\def\XINT_nthelt:f:csv_neg_a #1%
{%
\xint_UDzerominusfork
- #1-{\XINT_nthelt:f:csv_none }%
- 0#1{\XINT_nthelt:f:csv_none }%
+ #1-\xint_bye_thenstop
+ 0#1\xint_bye_thenstop
0-{\XINT_nthelt:f:csv_loop_a #1}%
\krof
}%
-\def\XINT_nthelt:f:csv_none #1\xint_bye { }%
\long\def\XINT_nthelt:f:csv_pos #1.#2%
{%
\expandafter\XINT_nthelt:f:csv_loop_a\the\numexpr #1+\xint_c_i\expandafter.%
More information about the tex-live-commits
mailing list