diff options
author | Karl Berry <karl@freefriends.org> | 2017-07-27 21:26:25 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-07-27 21:26:25 +0000 |
commit | fe6cc7d43e9608cb5bb2533480000837d7cf4827 (patch) | |
tree | 3098f2a8b1933b247a3aa7f6b58bb4e7dcca58f0 /Master/texmf-dist/source | |
parent | 654d2d2ad9ef4fc4de9cfd3b3d6038ef14ad4161 (diff) |
xint (27jul17)
git-svn-id: svn://tug.org/texlive/trunk@44900 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r-- | Master/texmf-dist/source/generic/xint/xint.dtx | 5869 | ||||
-rw-r--r-- | Master/texmf-dist/source/generic/xint/xint.ins | 2 |
2 files changed, 3248 insertions, 2623 deletions
diff --git a/Master/texmf-dist/source/generic/xint/xint.dtx b/Master/texmf-dist/source/generic/xint/xint.dtx index b41bba65760..8e22f7797dd 100644 --- a/Master/texmf-dist/source/generic/xint/xint.dtx +++ b/Master/texmf-dist/source/generic/xint/xint.dtx @@ -3,27 +3,27 @@ % Extract all files via "etex xint.dtx" and do "make help" % or follow instructions from extracted README.md. %<*dtx> -\def\xintdtxtimestamp {Time-stamp: <06-01-2017 at 22:41:03 CET>} +\def\xintdtxtimestamp {Time-stamp: <26-07-2017 at 19:42:16 CEST>} %</dtx> %<*drv> %% --------------------------------------------------------------- -\def\xintdocdate {2017/01/06} -\def\xintbndldate{2017/01/06} -\def\xintbndlversion {1.2k} +\def\xintdocdate {2017/07/26} +\def\xintbndldate{2017/07/26} +\def\xintbndlversion {1.2l} %</drv> %<readme>% README %<changes>% CHANGE LOG -%<readme|changes>% xint 1.2k -%<readme|changes>% 2017/01/06 +%<readme|changes>% xint 1.2l +%<readme|changes>% 2017/07/26 %<readme|changes> -%<readme|changes> Source: xint.dtx 1.2k 2017/01/06 (doc 2017/01/06) +%<readme|changes> Source: xint.dtx 1.2l 2017/07/26 (doc 2017/07/26) %<readme|changes> Author: Jean-Francois Burnol %<readme|changes> Info: Expandable operations on big integers, decimals, fractions %<readme|changes> License: LPPL 1.3c %<readme|changes> %<*!readme&!changes&!dohtmlsh&!dopdfsh&!makefile> %% --------------------------------------------------------------- -%% The xint bundle 1.2k 2017/01/06 +%% The xint bundle 1.2l 2017/07/26 %% Copyright (C) 2013-2017 by Jean-Francois Burnol %<xintkernel>%% xintkernel: Paraphernalia for the xint packages %<xinttools>%% xinttools: Expandable and non-expandable utilities @@ -68,7 +68,7 @@ Float computations are possible at an adjustable precision (default 16). \xintDigits:=48;\xintthefloatexpr 123456789^1000.5\relax ->3.63692761822782679930738270515740797370813691938e8095 - + However, only integer and half-integer exponents are currently allowed. The `sqrt` operation achieves correct rounding in arbitrary precision. @@ -243,6 +243,73 @@ Makefile.mk.</div> %</readme>-------------------------------------------------------- %<*changes>------------------------------------------------------- +`1.2l (2017/07/26)` +---- + +### Removed + + - `\xintiiSumExpr`, `\xintiiPrdExpr` (**xint**) and `\xintSumExpr`, + `\xintPrdExpr` (**xintfrac**). They had not been formally deprecated, + but had been left un-documented since `1.09d (2013/10/22)`. + +### Improvements and new features + + - the underscore character `_` is accepted by the **xintexpr** parsers + as a digit separator (the space character already could be used for + improved readability of big numbers). It is not allowed as *first* + character of a number, as it would then be mis-interpreted as the + start of a possible variable name. + + - some refactoring in **xintcore** auxiliary routines and in + `\xintiiSub` and `\xintiiCmp` for some small efficiency gains. + + - code comments in **xintcore** are better formatted, but remain + sparse. + + - **xintcore**, **xint**, **xintfrac**, ... : some macros were not + robust against arguments whose expansion looks forward for some + termination (e.g. ``\number\mathcode`\-``), and particularly, most + were fragile against inputs using non-terminated ``\numexpr`` (such + as `\xintiiAdd{\the\numexpr1}{2}` or `\xintRaw{\numexpr1}`). This was + not a bug per se, as the user manual did not claim such inputs were + legal, but it was slightly inconvenient. Most macros (particularly + those of **xintfrac**) have now been made robust against such inputs. + Some macros from **xintcore** primarily destined to internal usage + still accept only properly terminated arguments such as + ``\the\mathcode`\-<space>`` or ``\the\numexpr1\relax``. + + The situation with expressions is unchanged: syntax such as + `\xintexpr \numexpr1+2\relax` is illegal as the ending `\relax` token + will get swallowed by the `\numexpr`; but it is needed by the + ``xintexpr``-ession parser, hence the parser will expand forward and + presumably end with in an "illegal token" error, or provoke some + low-level TeX error (N.B.: a closing brace `}` for example can not + terminate an ``xintexpr``-ession, the parser must find a `\relax` + token at some point). Thus there must be in this example a second + `\relax`. + + - experimental code for error conditions; there is no complete user + interface yet, it is done in preparation for next major release and + is completely unstable and undocumented. + +### Bug fixes + + - **xintbinhex**: since `1.2 (2015/10/10)`, `\xintHexToDec` was + broken due to an undefined macro (it was in `xint.sty`, but the + module by itself is supposedly dependent only upon `xintcore.sty`). + + - **xintgcd**: macro `\xintBezout` produced partially wrong output if + one of its two arguments was zero. + + - **xintfrac**: the manual said one could use directly `\numexpr` + compatible expressions in arithmetic macros (without even a + `\numexpr` encapsulation) if they were expressed with up to 8 tokens. + There was a bug if these 8 tokens evaluated to zero. The bug has been + fixed, and up to 9 tokens are now accepted. But it is simpler to use + `\the\numexpr` prefix and not to worry about the token count... The + ending `\relax` is now un-needed. + + `1.2k (2017/01/06)` ---- @@ -333,13 +400,14 @@ Makefile.mk.</div> ### 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.) +### Removed + + - deprecated macros `\xintifTrue`, `\xintifTrueFalse`, `\xintQuo`, + `\xintRem`, `\xintquo`, `\xintrem`. + ### Improvements and new features - **xintkernel**: `\xintLength` is faster. New macros: @@ -632,6 +700,14 @@ Makefile.mk.</div> `1.2 (2015/10/10)` ---- +### Removed + + - the macros `\xintAdd`, `\xintSub`, `\xintMul`, `\xintMax`, + `\xintMin`, `\xintMaxof`, `\xintMinof` are removed from package + **xint**, and only exist in the versions from **xintfrac**. With only + **xintcore** or **xint** loaded, one _must_ use `\xintiiAdd`, + `\xintiiSub`, ..., or `\xintiAdd`, `\xintiSub`, etc... + ### Improvements and new features - the basic arithmetic implemented in **xintcore** has been entirely @@ -656,11 +732,6 @@ Makefile.mk.</div> inside `\xintfloatexpr` maps to this new macro rather than to the exact factorial as used by `\xintexpr` and `\xintiiexpr`. - - the macros `\xintAdd`, `\xintSub`, ..., now require package - **xintfrac**. With only **xintcore** or **xint** loaded, one _must_ - use `\xintiiAdd`, `\xintiiSub`, ..., or `\xintiAdd`, `\xintiSub`, - etc... - - there is more flexibility in the parsing done by the macros from **xintfrac** on fractional input: the decimal parts of both the numerator and the denominator may arise from a separate expansion via @@ -756,20 +827,34 @@ Makefile.mk.</div> `N` will end up as is in a `\numexpr`, it is not parsed by the `\xintexpr`-ession scanner), - - although `&` and `|` are still available as Boolean operators the - use of `&&` and `||` is strongly recommended. The single - letter operators might be assigned some other meaning in later releases - (bitwise operations, perhaps). Do not use them. - - in earlier releases, place holders for `\xintNewExpr` could either be denoted `#1`, `#2`, ... or also `$1`, `$2`, ... Only the usual `#` form is now accepted and the special cases previously treated via the second form are now managed via a `protect(...)` function. +### Removed + + - `\xintnumexpr`, `\xintthenumexpr`, `\xintNewNumExpr`: use + `\xintiexpr`, `\xinttheiexpr`, `\xintNewIExpr`. + +### Deprecated + + - `\xintDivision`, `\xintQuo`, `\xintRem`: use `\xintiDivision`, + `\xintiQuo`, `\xintiRem`. + + - `\xintMax`, `\xintMin`, `\xintAdd`, `\xintSub`, `\xintMul` + (**xint**): their usage without **xintfrac** is deprecated; use + `\xintiMax`, `\xintiMin`, `\xintiAdd`, `\xintiSub`, `\xintiMul`. + + - the `&` and `|` as Boolean operators in `xintexpr`-essions are + deprecated in favour of `&&` and `||`. The single letter operators + might be assigned some other meaning in some later release (bitwise + operations, perhaps). Do not use them. + ### Improvements and new features * new package **xintcore** has been split off **xint**. It contains the - core arithmetic macros. It is loaded by package **bnumexpr**, + core arithmetic macros (it is loaded by LaTeX package **bnumexpr**), * neither **xint** nor **xintfrac** load **xinttools**. Only **xintexpr** does, @@ -1009,9 +1094,9 @@ Makefile.mk.</div> optimized to deal only with (long) integers, `/` does a euclidean quotient. - * `\xintnumexpr`, `\xintthenumexpr`, `\xintNewNumExpr` are renamed, - respectively, `\xintiexpr`, `\xinttheiexpr`, `\xintNewIExpr`. The - earlier denominations are kept but to be removed at some point. + * *deprecated*: `\xintnumexpr`, `\xintthenumexpr`, `\xintNewNumExpr` are + renamed, respectively, `\xintiexpr`, `\xinttheiexpr`, `\xintNewIExpr`. The + earlier denominations are kept but are to be removed at some point. * it is now possible within `\xintexpr...\relax` and its variants to use count, dimen, and skip registers or variables without @@ -1056,6 +1141,8 @@ Makefile.mk.</div> the `[0]`'s which were supposed to have been removed since release `1.09b`. + * *deprecated*: `\xintifTrueFalse`, `\xintifTrue`; use `\xintifTrueAelseB`. + `1.09h (2013/11/28)` ---- @@ -1174,7 +1261,7 @@ Makefile.mk.</div> * (**xintexpr**) added `bool` and `togl` to the `\xintexpr` syntax; also added `\xintboolexpr` and `\xintifboolexpr`. - * added `\xintNewNumExpr` (now `\xintNewIExpr` and `\xintNewBoolExpr`), + * added `\xintNewNumExpr`. * the factorial `!` and branching `?`, `:`, operators (in `\xintexpr...\relax`) have now less precedence than a function @@ -2095,10 +2182,10 @@ dvipdfmx CHANGES.dvi } {} {\noindent - \llap{\makebox[\margegauchetoc][l]{\ttzfamily\bfseries\etoclink + \etocifnumbered{\llap{\makebox[\margegauchetoc][l]{\ttzfamily\bfseries\etoclink {\ifinmanualmaintoc\expandafter\textcolor\sectioncouleur {\normalfont\bfseries\ETOCsectionnumber}\fi - .\expandafter\gobbletodot\etocthenumber}}}% + .\expandafter\gobbletodot\etocthenumber}}}}{\kern-\margegauchetoc}% \strut\etocname\nobreak \unless\ifinmanualmaintoc\leaders\etoctoclineleaders\fi \hfill\nobreak @@ -2119,6 +2206,8 @@ dvipdfmx CHANGES.dvi \strut\makebox[\MARGEPAGENO][r]{\small\etocpage}\endgraf } {\endgroup }% +\etocsetlevel{table}{6} + \makeatother \addtocontents{toc}{\protect\hypersetup{hidelinks}} @@ -2150,25 +2239,25 @@ dvipdfmx CHANGES.dvi % Ajouté le 9 mars 2016 -\DeclareFontShape{T1}{newtxttb}{m}{sc}{ %cap & small cap +\DeclareFontShape{T1}{newtxttb}{m}{sc}{%cap & small cap <-> s*[\newtxtt@scale]newtxttscbq }{} -\DeclareFontShape{T1}{newtxttb}{b}{sc}{ %bold cap & small cap +\DeclareFontShape{T1}{newtxttb}{b}{sc}{%bold cap & small cap <-> s*[\newtxtt@scale]newtxbttscbq }{} -\DeclareFontShape{T1}{newtxttb}{b}{sl}{ %bold slanted +\DeclareFontShape{T1}{newtxttb}{b}{sl}{%bold slanted <-> s*[\newtxtt@scale]newtxbttslbq }{} -\DeclareFontShape{T1}{newtxttb}{b}{it}{ %bold italic +\DeclareFontShape{T1}{newtxttb}{b}{it}{%bold italic <-> ssub * newtxttb/b/sl% }{} -\DeclareFontShape{T1}{newtxttb}{bx}{sc}{ %bold extended cap & small cap +\DeclareFontShape{T1}{newtxttb}{bx}{sc}{%bold extended cap & small cap <-> ssub * newtxttb/b/sc% }{} -\DeclareFontShape{T1}{newtxttb}{bx}{sl}{ %bold extended slanted +\DeclareFontShape{T1}{newtxttb}{bx}{sl}{%bold extended slanted <-> ssub * newtxttb/b/sl% }{} -\DeclareFontShape{T1}{newtxttb}{bx}{it}{ %bold extended italic +\DeclareFontShape{T1}{newtxttb}{bx}{it}{%bold extended italic <-> ssub * newtxttb/b/sl% }{} @@ -2176,40 +2265,40 @@ dvipdfmx CHANGES.dvi \DeclareEncodingSubset{TS1}{newtxttb}{0} \DeclareFontFamily{TS1}{newtxttb}{\hyphenchar\font\m@ne} -\DeclareFontShape{TS1}{newtxttb}{m}{n}{ %medium +\DeclareFontShape{TS1}{newtxttb}{m}{n}{%medium <-> s*[\newtxtt@scale]tcxtt% }{} -\DeclareFontShape{TS1}{newtxttb}{m}{sc}{ %cap & small cap +\DeclareFontShape{TS1}{newtxttb}{m}{sc}{%cap & small cap <->ssub * newtxttb/m/n% }{} -\DeclareFontShape{TS1}{newtxttb}{m}{sl}{ %slanted +\DeclareFontShape{TS1}{newtxttb}{m}{sl}{%slanted <-> s*[\newtxtt@scale]tcxttsl% }{} -\DeclareFontShape{TS1}{newtxttb}{m}{it}{ %italic +\DeclareFontShape{TS1}{newtxttb}{m}{it}{%italic <->ssub * newtxttb/m/sl% }{} -\DeclareFontShape{TS1}{newtxttb}{b}{n}{ %bold +\DeclareFontShape{TS1}{newtxttb}{b}{n}{%bold <-> s*[\newtxtt@scale]tcxbtt% }{} -\DeclareFontShape{TS1}{newtxttb}{b}{sc}{ %bold cap & small cap +\DeclareFontShape{TS1}{newtxttb}{b}{sc}{%bold cap & small cap <->ssub * newtxttb/b/n% }{} -\DeclareFontShape{TS1}{newtxttb}{b}{sl}{ %bold slanted +\DeclareFontShape{TS1}{newtxttb}{b}{sl}{%bold slanted <-> s*[\newtxtt@scale]tcxbttsl% }{} -\DeclareFontShape{TS1}{newtxttb}{b}{it}{ %bold italic +\DeclareFontShape{TS1}{newtxttb}{b}{it}{%bold italic <->ssub * newtxttb/b/sl% }{} -\DeclareFontShape{TS1}{newtxttb}{bx}{n}{ %bold extended +\DeclareFontShape{TS1}{newtxttb}{bx}{n}{%bold extended <->ssub * newtxttb/b/n% }{} \DeclareFontShape{TS1}{newtxttb}{bx}{sc}{ %bold extended cap & small cap <->ssub * newtxttb/b/sc% }{} -\DeclareFontShape{TS1}{newtxttb}{bx}{sl}{ %bold extended slanted +\DeclareFontShape{TS1}{newtxttb}{bx}{sl}{%bold extended slanted <->ssub * newtxttb/b/sl% }{} -\DeclareFontShape{TS1}{newtxttb}{bx}{it}{ %bold extended italic +\DeclareFontShape{TS1}{newtxttb}{bx}{it}{%bold extended italic <->ssub * newtxttb/b/it% }{} @@ -2276,6 +2365,8 @@ pdfkeywords={Expansion, arithmetic, TeX},% pdfstartview=FitH,% pdfpagemode=UseOutlines} +\usepackage{hypcap} + \ifnum\dosourcexint=1 \hypersetup{pdftitle={The xint bundle source code}} \fi @@ -2577,7 +2668,21 @@ pdfpagemode=UseOutlines} % --- \lverb % Définition de \lverb -\makeatletter +% Has become more complicated for 1.2l +\makeatletter\catcode`_ 11 +{\catcode32\active% +\gdef\myobeyspaces{\catcode32\active\def {\leavevmode\kern\fontcharwd\font`X}}} +\def\lverbpercent {\catcode32\active\lverbpercent_a}% +\def\lverbpercent_a #1{% + \if\XINT_sptoken\detokenize{#1}\xint_dothis{\catcode32 10 }\fi + \if-\detokenize{#1}\xint_dothis{\par #1}\fi + \if(\detokenize{#1}\xint_dothis{\par\bgroup\myobeyspaces\obeylines}\fi + \if:\detokenize{#1}\xint_dothis{}\fi + \if)\detokenize{#1}\xint_dothis{\egroup\everypar{\hskip-\parindent\everypar{}}}\fi + \ifx#1\lverbpercent\xint_dothis{\catcode32 10 \par #1}\fi + \xint_orthat{\catcode32 10 #1}% +} +\catcode`_ 8 \long\def\lverb {% \relax\par\smallskip\noindent\null \begingroup @@ -2586,7 +2691,9 @@ pdfpagemode=UseOutlines} \let\do\do@noligs \verbatim@nolig@list \let\do\@makeother \dospecials \def\PrivateObelus{\par\noindent\textdiv}% - \catcode32 10 \catcode`\% 9 \catcode`\& 14 \catcode`\$ 0 + \catcode32 10 \catcode`\& 14 \catcode`\$ 0 + \catcode`\% \active + \begingroup\lccode`\~`\%\lowercase{\endgroup\let~\lverbpercent}% \MicroFont % sera donc en couleur. \@lverb } @@ -2926,6 +3033,28 @@ pdfpagemode=UseOutlines} \fi \tableofcontents +\begingroup\makeatletter +\etocsetlevel{table}{0} +\etocsetstyle{table} + {} + {\normalfont} + {%\SKIPSECTIONINTERSPACE + \rightskip \MARGEPAGENO\relax + \parfillskip -\MARGEPAGENO\relax + \leftskip \z@skip + \noindent\strut Table of \etocname + \nobreak\leaders\etoctoclineleaders\hfill\nobreak\strut + \makebox[\MARGEPAGENO][r]{\etocpage}\par + }% + {}% +\etocsettagdepth{description}{table} +\etocsettagdepth{macros}{none} +\etocsettagdepth{implementation}{none} +\etocsettocstyle{}{} +\smallskip +\tableofcontents +\endgroup + \etocignoredepthtags \etocmulticolstyle [1]{% \phantomsection% \section* {Contents} @@ -3701,9 +3830,6 @@ documentation are not hard-coded in the source file of this document but are obtained via the expansion of the package macros during the \TeX{} run.% % -\footnote{The CPU of my computer hates me for all those re-compilations - after changing a single letter in the \LaTeX{} source, which require each - time to do all the zillions of evaluations contained in this document\dots} @@ -3755,27 +3881,36 @@ file with name |README.md|. Further help and options will be found therein. This is release \expandafter|\xintbndlversion| of \expandafter|\xintbndldate|. -The \xintfracname floating point macros since |1.2f| round their arguments to -the target precision |P| before further processing. This rounding is now exact -(aka correct) in all cases, even with fractions having long numerators and -denominators. -This change has little influence on float expressions, as the -\csbxint{floatexpr} parser handles there the |/| symbol as an operator hence -it does not (except for special constructs) get to see fractions as such. -Half-integer powers |A^x| (only available in float expressions, not via -macros) proceed by an integer power and then a square-root extraction: the -|1.2f| implementation did the latter on an already rounded value, |1.2k| keeps -some of the guard digits to make the computed value |Z| closer to the exact -one: a difference of less than |0.52 ulp(Z)| is guaranteed in all cases. -Macro |\xintnewdummy| is made a public one, it serves to declare additional -letters as dummy variables in expressions. This is for Unicode engines, -mainly, as all Latin letters are already predefined to act as such. -See |CHANGES.html| or |CHANGES.pdf| for more (|texdoc --list xint| or on the -internet via +The underscore |_| is accepted inside the expression parsers as an ignored +digit separator\footnote{The space character has already always been accepted + in this rôle by the \xintexprname parsers, contrarily to the + situation inside |\numexpr|.}, for long numbers: +\begin{everbatim*} +\xinttheiiexpr 123_456_789^3\relax\newline +\xintthefloatexpr \xintexpr 123_456_789.1111_1111_1111^-3\relax \relax +\end{everbatim*} + +It is not accepted in the arguments of the macros +from \xintfracname or \xintname though, only in expressions from +\xintexprname. + +Macro usage with non properly terminated inputs such as +|\xintiiAdd{\the\numexpr1}{2}| or |\xintDecToHex{\number\mathcode`\-}| caused +crashes. This has been fixed: the arithmetic macros of \xintcorename, the +macros of \xintfracname, those of \xintgcdname and \xintbinhexname have been +made robust against such inputs. Some routines of \xintcorename principally +destined to internal usage such as \csbxint{Inc} remain incompatible though +(to avoid adding some overhead; check |sourcexint.pdf| for details). + +Some refactoring took place in the sources of \xintcorename for efficiency +gains. Some improvements in the user documentation and the code comments. + +See |CHANGES.html| or |CHANGES.pdf| for more information (either |texdoc +--list xint| or on the internet via \href{http://mirrors.ctan.org/macros/generic/xint/CHANGES.html}{this link}.) @@ -3813,29 +3948,31 @@ internet via \def\@floatboxreset{\@setminipage}% faudra contrôler celui-là \makeatother \begin{table}[htbp]\ht\strutbox12pt\dp\strutbox5pt +\capstart \centering\begin{tabular}{|c|p{.5\textwidth}|} \hline Precedence&``Operators'' at this level\strut\\ \hline\hline \mylink{$\infty$}& - functions and variables, decimal mark |.|, |e| and |E| of scientific notation, hexadecimal prefix |"|.\strut\\\hline + functions and variables, decimal mark |.|, |e| and |E| of scientific notation, hexadecimal prefix |"|\strut\\\hline \mylink{$10$}& postfix |!| (factorial) and conditional branching operators |?| and |??| \strut\\\hline \mylink{$=$}& minus sign |-| as unary operator acquires the - precedence level of the previous infix operator.\strut\\\hline - \mylink{$9$}&|^|, |**| and list operators |^[|, |**[|, |]^|, |]**|.\strut\\\hline - \mylink{$8$}&tacit multiplication.\strut\\\hline - \mylink{$7$}&|*|, |/|, and list operators |*[|, |/[|, |]*|, |]/|.\strut\\\hline - \mylink{$6$}&|+|, |-|, and list operators |+[|, |-[|, |]+|, |]-|.\strut\\\hline - \mylink{$5$}&|<|, |>|, |==| (or |=|), |<=|, |>=|, |!=|.\strut\\\hline - \mylink{$4$}&|&&| and its equivalent |'and'|.\strut\\\hline - \mylink{$3$}&\verb+||+, its equivalent |'or'|, and |'xor'|; also the - sequence generators |..|, |..[|, |]..|, and the Python slicer |:|.\strut\\\hline - \mylink{$2$}& the comma |,|.\strut\\\hline + precedence level of the previous infix operator\strut\\\hline + \mylink{$9$}&|^|, |**| and list operators |^[|, |**[|, |]^|, |]**|\strut\\\hline + \mylink{$8$}&tacit multiplication\strut\\\hline + \mylink{$7$}&|*|, |/|, |//|, |/:| (aka |'mod'|), and list operators |*[|, |/[|, |]*|, |]/|\strut\\\hline + \mylink{$6$}&|+|, |-|, and list operators |+[|, |-[|, |]+|, |]-|\strut\\\hline + \mylink{$5$}&|<|, |>|, |==| (or |=|), |<=|, |>=|, |!=|\strut\\\hline + \mylink{$4$}&|&&| and its equivalent |'and'|\strut\\\hline + \mylink{$3$}&\verb+||+ (aka |'or'|), and |'xor'|; also the + sequence generators |..|, |..[|, |]..|, and the Python slicer |:|\strut\\\hline + \mylink{$2$}& the comma |,|\strut\\\hline \mylink{$1$}& the parentheses |(|, |)|, list brackets |[|, |]|, and semi-colon |;| in an |iter| or - |rseq|.\strut\\\hline + |rseq|\strut\\\hline \end{tabular} - \caption{Precedence levels} + \caption{Precedence levels (click on levels)} \label{tab:precedences} +\addcontentsline {toc}{table}{Precedence levels of operators in expressions} \end{table} The \autoref{tab:precedences} is hyperlinked to the more detailed discussion @@ -3959,13 +4096,19 @@ when using variables. not \xinttheiexpr 100/(50/2)\relax. % \endgroup - Inside \csbxint{iiexpr}, |/| does \emph{rounded} division. + + Also the truncated division |//| and modulo |/:| (equivalently |'mod'|, + quotes mandatory). 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. + In an \csbxint{iiexpr}-ession, |/| does \emph{rounded} division, to behave + like the |/| of |\numexpr|. + + Infix operators all at the same level of precedence are + left-associative.\footnote{i.e. the first two operands are operated upon + first.} + Apply parentheses for disambiguation. \begin{everbatim*} \xinttheexpr 100000//13, 100000/:13, 100000 'mod' 13, trunc(100000/13,10), trunc(100000/:13/13,10)\relax @@ -4029,29 +4172,31 @@ when using variables. \subsection{Built-in functions} +See \autoref{tab:functions} whose elements are hyperlinked to the +corresponding definitions. + Functions are at the same top level of priority. All functions even |?| and |!| (as prefix) require parentheses around their arguments. \begin{table}[htbp] +\capstart \centering \cnta0 \begin{tabular}{|c|c|c|c|c|c|} \hline - \xintFor #1 in {abs, sgn, num, reduce, float, round, trunc, floor, ceil, - frac, sqr, sqrt, sqrtr, factorial, binomial, pfactorial, mod, quo, rem, gcd, - lcm, max, min, |`+`|, |`*`|, ?, !, not, all, any, xor, if, ifsgn, even, odd, - first, last, reversed, len, subs, add, mul, seq, rseq, iter, rrseq, iterr, - bool, togl, qint, qfrac, qfloat}\do + \xintFor #1 in {!, ?, |`*`|, |`+`|, abs, add, all, any, binomial, bool, + ceil, even, factorial, first, float, floor, frac, gcd, if, ifsgn, iter, + iterr, last, lcm, len, max, min, mod, mul, not, num, odd, pfactorial, + qfloat, qfrac, qint, quo, reduce, rem, reversed, round, rrseq, rseq, seq, + sgn, sqr, sqrt, sqrtr, subs, togl, trunc, xor}\do {\hyperlink{\detokenize{builtinfunc-#1}}{#1}\global\advance\cnta1 - \ifnumequal{\cnta}{6}{\global\cnta0 \\\hline}{&}}% - \ifnumgreater{\cnta}{0}{\xintFor*#1in{\xintSeq[1]{\cnta}{4}}\do{&}\\\hline}{}% + \ifnumequal{\cnta}{4}{\global\cnta0 \\\hline}{&}}% +% \ifnumgreater{\cnta}{0}{\xintFor*#1in{\xintSeq[1]{\cnta}{4}}\do{&}\\\hline}{}% \end{tabular} -\caption{Functions}\label{tab:functions} +\caption{Functions (click on names)}\label{tab:functions} +\addcontentsline{toc}{table}{Functions in expressions} \end{table} -See \autoref{tab:functions} whose elements are hyperlinked to the -corresponding definitions. - Miscellaneous notes: \begin{itemize}[nosep] \item \fbox{|gcd| and |lcm| require explicit loading of \xintgcdname}, @@ -4260,15 +4405,29 @@ Recall that this is NOT done automatically, for example when adding fractions. \end{description} \item[functions with one mandatory and a second but optional argument:]\mbox{} \begin{description}[listparindent=\leftmarginiii] - \myitem{round} Rounds to a fixed point number with the given number of digits - after the decimal mark. For example + \myitem{round} Rounds its first argument to a fixed point number, having a + number of digits + after decimal mark given by the second argument. For example |round(-2^9/3^5,12)=|\dtt{\xinttheexpr round(-2^9/3^5,12)\relax.} - \myitem{trunc} Truncates to a fixed point number with the given number of - digits after the decimal mark. For example + \myitem{trunc} Truncates its first argument to a fixed point number, having + a number of digits + after decimal mark given by the second argument. For example |trunc(-2^9/3^5,12)=|\dtt{\xinttheexpr trunc(-2^9/3^5,12)\relax.} - \myitem{float} Rounds to a floating point number with a mantissa having the given number of - digits. For example + \myitem{float} Rounds its first argument to a floating point number, with a + precision given by the second argument. |float(-2^9/3^5,12)=|\dtt{\xinttheexpr float(-2^9/3^5,12)\relax.} + + % AUCTeX EXTREMEMENT PENIBLE AVEC L'INDENTATION FORCEE SOUS M-q + + Note for this example and the earlier ones that when the surrounding + parser is \csbxint{floatexpr}|...\relax| the fraction first argument (here + |2^9/3^5|) will already have been computed as floating point number (with + numerator and denominator handled separately first), even before the + second argument is seen and a fortiori before the |round|, |trunc| or + |float| is executed. The general float precision is the one governing + these initial steps. To avoid that, use |\xintexpr2^9/3^5\relax| wrapper. + Then the rounding or truncation will be applied on the exact fraction. + \item[sqrt] in \csa{xintexpr}|...\relax| and \csa{xintfloatexpr}|...\relax| it achieves the precision given by the optional second argument. For legacy reasons the |sqrt| function in \csa{xintiiexpr} \emph{truncates} @@ -4790,13 +4949,27 @@ and let it be known to the parsers of \xintexprname. \end{everbatim*} Legal variable names are composed of letters, digits, |@| and |_| signs. -They can not start with a digit. They may start with |@| or |_|. Currently -|@|, |@1|, |@2|, |@3|, and |@4| are reserved because they have special -meanings for use in iterations. The |@@|, |@@@|, |@@@@| are also reserved but -are technically functions, not variables. Thus a user may possibly use |@@| as +\begin{itemize}[nosep] +\item the first character must not be a digit, +\item it may be a |@| or |_| but such variable names may be used either now or + in the future by \xintname for special purposes, hence should be avoided: + \begin{itemize}[nosep] + \item currently |@|, |@1|, |@2|, |@3|, and |@4| are reserved because they + have special meanings for use in iterations. + \item the |@@|, |@@@|, |@@@@| are also reserved but +are technically functions, not variables: a user may possibly define |@@| as a variable name, but if it is followed by parentheses, the function interpretation will be applied, rather than the variable interpretation followed by a tacit multiplication. + \item since 1.2l, the underscore |_| may be used as separator of digits in + long numbers. + Hence a variable whose name starts with it will not play well with the + mechanism of tacit multiplication of variables by numbers: the underscore + will be removed from input stream by the number scanner, thus creating + an undefined or wrong variable name, or none at all if the variable + name was an initial |_| followed by digits. + \end{itemize} +\end{itemize} |x_1x| is a licit variable name, as well as |x_1x_| and |x_1x_2| and |x_1x_2y| etc... hence we can not rely on tacit multiplication being applied to @@ -5280,7 +5453,11 @@ variants: to \dtt{\detokenize\expandafter{\the\numexpr 7 + 3 5\relax}\unskip}, whereas |\xintthe\xintiiexpr 7 + 3 5\relax| expands (in two steps) to \dtt{\detokenize\expandafter\expandafter\expandafter {\xintthe\xintiiexpr 7 - + 3 5\relax}}. + + 3 5\relax}}.% +% +\footnote {Since |1.2l| one can also use the underscore |_| to separate digits +for readability of long numbers.} + \item Inside an |\edef|, expressions |\xintiiexpr...\relax| get fully evaluated, but to a private format which needs the prefix \csbxint{the} to get printed or used as arguments to some macros; on the other hand @@ -6157,22 +6334,30 @@ register |\mycountA| or |\count 255| is admissible as numerator or also as denominator, with no need to be prefixed by |\the| or |\number|. It is possible to have as argument an algebraic expression as would be acceptable by a |\numexpr...\relax|, under this condition: \emph{each of the numerator and - denominator is expressed with at most \emph{eight} + denominator is expressed with at most \emph{nine} tokens}.% % -\footnote{Attention! there is no problem with a \LaTeX{} - \csa{value}\texttt{\{countername\}} if if comes first, but if it comes later - in the input it will not get expanded, and braces around the name will be - removed and chaos\IMPORTANT{} will ensue inside a \csa{numexpr}. One should - enclose the whole input in \csa{the}\csa{numexpr}|...|\csa{relax} in such - cases.} +\footnote{The |1.2k| and earlier versions manual claimed up to 8 + tokens, but low-level TeX error arose if the |\numexpr...\relax| occupied + exactly 8 tokens \emph{and} evaluated to zero. With |1.2l| and later, up to + 9 tokens are always safe and one may even drop the ending |\relax|. But + well, all these explanations are somewhat silly because prefixing by |\the| + or |\number| is always working with arbitrarily many tokens.} % -The slash for rounded division in a |\numexpr| should be written with +% +\footnote{Attention! in the \LaTeX{} context a + \csa{value}\texttt{\{countername\}} will behave ok only if it is first in + the input, if not it will not get expanded, and braces around the name will + be removed and chaos\IMPORTANT{} will ensue inside a \csa{numexpr}. One + should enclose the whole input in \csa{the}\csa{numexpr}|...|\csa{relax} in + such cases.} +% +Important: a slash for rounded division in a |\numexpr| should be written with braces |{/}| to not be confused with the \xintfracname delimiter between -numerator and denominator (braces will be removed internally). Example: +numerator and denominator (braces will be removed internally and the slash +will count for one token). Example: |\mycountA+\mycountB{/}17/1+\mycountA*\mycountB|, or |\count 0+\count -2{/}17/1+\count 0*\count 2|, but in the latter case the numerator has the -maximal allowed number of tokens (the braced slash counts for only one). +2{/}17/1+\count 0*\count 2|. % \leftedline{|\cnta 10 \cntb 35 \xintRaw {\cnta+\cntb{/}17/1+\cnta*\cntb}|\dtt{->\cnta 10 \cntb 35 \xintRaw @@ -6560,30 +6745,65 @@ others are more annoying as they may pass through unsignaled. \subsection{Error messages} -In situations such as division by zero, the package will insert in the -\TeX{} processing an undefined control sequence (we copy this method -from the |bigintcalc| package). This will trigger the writing to the log -of a message signaling an undefined control sequence. The name of the -control sequence is the message. The error is raised \emph{before} the -end of the expansion so as to not disturb further processing of the -token stream, after completion of the operation. Generally the problematic -operation will output a zero. Possible such error message control -sequences: +In situations such as division by zero, the \TeX{} run will be interrupted +with some error message. The user is asked to hit the RETURN key thrice, which +will display additional information.\CHANGED{1.2l} In non-interactive +|nonstopmode| the \TeX{} run goes on uninterrupted and the error data will be +found in the compilation log. + +Here is an example interactive run: +\begin{everbatim} +! Undefined control sequence. +<argument> \ ! / + DivisionByZero (hit <RET> thrice) +l.11 \xintiiDivision{123}{0} + +? +! Undefined control sequence. +<argument> \ ! / + Division of 123 by 0 +l.11 \xintiiDivision{123}{0} + +? +! Undefined control sequence. +<argument> \ ! / + next: {0}{0} +l.11 \xintiiDivision{123}{0} + +? +[1] (./temptest.aux) ) +Output written on temptest.dvi (1 page, 216 bytes). +Transcript written on temptest.log. +\end{everbatim} + +This is an experimental feature, which is in preparation for next major +release.% +% +\footnote{The related macros checking or resetting error flags are implemented + in embryonic form but no user interface is provided with |1.2l| release.} +% +For the good functioning of this the macro with the weird appearance +{\catcode`/ 11 \catcode`! 11 \catcode32 11 |\ ! /|} (yes, this is a single +control sequence) must be left undefined. I trust it will be |;-)|.% +% +\footnote{The implementation is cloned from \LaTeX3, the + {\catcode`/ 11 \catcode`! 11 \catcode32 11 |\ ! /|} was chosen for its + shortness.} + + +The expression parsers are at |1.2l| still using a slightly less evolved +method which lets \TeX{} display an undefined control sequence name giving +some indication of the underlying problem (we copied this method from the +|bigintcalc| package). The name of the control sequence is the message. +% The +% error is raised \emph{before} the end of the expansion so as to not disturb +% further processing of the token stream, after completion of the operation. +% Generally the problematic operation will output a zero. Possible such error +% message control sequences: \begin{multicols}{2}\parskip0pt\relax \begin{everbatim} -\xintError:ArrayIndexIsNegative -\xintError:ArrayIndexBeyondLimit -\xintError:FactorialOfNegative -\xintError:TooBigFactorial -\xintError:DivisionByZero -\xintError:NaN -\xintError:FractionRoundedToZero -\xintError:NotAnInteger -\xintError:ExponentTooBig -\xintError:RootOfNegative -\xintError:NoBezoutForZeros \xintError:ignored \xintError:removed \xintError:inserted @@ -6594,41 +6814,49 @@ sequences: \end{multicols} -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) or to use deprecated macros. +Some additional errors are raised when using deprecated macros (or trying to +invoke \csbxint{Add} with only \xintname.sty loaded for example.) \begin{multicols}{2}\parskip0pt\relax \begin{everbatim} -\Did_you_mean_iiAbs?or_load_xintfrac -\Did_you_mean_iiOpp?or_load_xintfrac -\Did_you_mean_iiAdd?or_load_xintfrac -\Did_you_mean_iiSub?or_load_xintfrac -\Did_you_mean_iiMul?or_load_xintfrac -\Did_you_mean_iiPow?or_load_xintfrac -\Did_you_mean_iiSqr?or_load_xintfrac -\Did_you_mean_iiMax?or_load_xintfrac -\Did_you_mean_iiMin?or_load_xintfrac -\Did_you_mean_iMaxof?or_load_xintfrac -\Did_you_mean_iMinof?or_load_xintfrac -\Did_you_mean_iiSum?or_load_xintfrac -\Did_you_mean_iiPrd?or_load_xintfrac -\Did_you_mean_iiPrdExpr?or_load_xintfrac -\Did_you_mean_iiSumExpr?or_load_xintfrac +\Did_you_mean_iiAbs?or_load_xintfrac! +\Did_you_mean_iiOpp?or_load_xintfrac! +\Did_you_mean_iiAdd?or_load_xintfrac! +\Did_you_mean_iiSub?or_load_xintfrac! +\Did_you_mean_iiMul?or_load_xintfrac! +\Did_you_mean_iiPow?or_load_xintfrac! +\Did_you_mean_iiSqr?or_load_xintfrac! +\Did_you_mean_iiMax?or_load_xintfrac! +\Did_you_mean_iiMin?or_load_xintfrac! +\Did_you_mean_iMaxof?or_load_xintfrac! +\Did_you_mean_iMinof?or_load_xintfrac! +\Did_you_mean_iiSum?or_load_xintfrac! +\Did_you_mean_iiPrd?or_load_xintfrac! \Removed!use_xintiQuo_or_xintiiQuo! \Removed!use_xintiRem_or_xintiiRem! \end{everbatim} \end{multicols} -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. - -Release |1.1| employs in some situations delimited macros and there is -the possibility in case of an ill-formed expression to end up beyond the -|\relax| end-marker. The errors inevitably arising could then lead to very -cryptic messages; but nothing unusual or especially traumatizing for the -daring experienced \TeX/\LaTeX\ user. +For such type of error sequences one should set |\errorcontextlines| to at +least |2| to get from \LaTeX\ more context. Errors occuring during the parsing +of |\xintexpr-essions| try to provide helpful information about the offending +token. But for the newer |1.2l| type of expandable error messages it is +already ok with |\errorcontextlines| left at its \LaTeX\ default. Future +releases of \xintname will presumably use only the newer method. + +Some constructs in \xintexprname-essions use delimited macros and there is +thus possibility in case of an ill-formed expression to end up beyond the +|\relax| end-marker. Such a situation can also occur from a non-terminated +|\numexpr|: +\begin{everbatim} +\xinttheexpr 3 + \numexpr 5+4\relax followed by some LaTeX code... +\end{everbatim} +as the |\numexpr| will swallow the |\relax| whose presence is mandatory for +|\xinttheexpr|, errors will inevitably arise and may +lead to very cryptic messages; but nothing unusual or especially traumatizing +for the daring experienced \TeX/\LaTeX\ user, whose has seen zillions of +un-helpful error messages already in her daily practice of +\TeX/\LaTeX.\footnote{not to mention the \LaTeX\ error messages used by + Emacs AUC\TeX\ mode also for Plain \TeX\ runs...} \subsection{Package namespace, catcodes} @@ -6675,6 +6903,8 @@ un-expandable action). other and letters have category code letter. Nothing else is assumed. \end{framed} +As pointed out in previous section the control sequence {\catcode`/ 11 + \catcode`! 11 \catcode32 11 |\ ! /|} must be left undefined. \subsection{Origins of the package} \label{ssec:origins} @@ -9429,59 +9659,71 @@ replacement text. % defines (without checking if something gets overwritten) the control sequences on the right of \csa{to} to expand to the successive tokens or braced items -found one after the other on the left of \csa{to}. It is not expandable. +located to the left of \csa{to}. \csa{xintAssign} is not an expandable macro. -A `full' expansion is first applied to the material in front of -\csa{xintAssign}, which may thus be a macro expanding to a list of braced items. +\fexpan sion is first applied to the material in front of \csa{xintAssign} +which is fetched as one argument if it is braced. Then the expansion of this +argument is examined and successive items are assigned to the macros following +|\to|. There must be exactly as many macros as items. No check is done. The +macro assignments are done with removal of one level of brace pairs from each +item. + +After the initial \fexpan sion, each assigned (brace-stripped) item will be +expanded according to the setting of the optional parameter. -\xintAssign \xintiiPow {7}{13}\to\SevenToThePowerThirteen +For example |\xintAssign [e]...| means that all assignments are done using +|\edef|. With |[f]| the assignments will be made using +\hyperref[fdef]{\ttfamily\char92fdef}. The default is simply to make the +definitions with |\def|, corresponding to an empty optional paramter |[]|. +Possibilities for the optional parameter are: |[], [g], [e], [x], [o], [go], +[oo], [goo], [f], [gf]|. For example |[oo]| means a double expansion. +\begin{everbatim*} \xintAssign \xintiiDivision{1000000000000}{133333333}\to\Q\R +\meaning\Q\newline +\meaning\R\newline +\xintAssign {{\xintiiDivision{1000000000000}{133333333}}}\to\X +\meaning\X\newline +\xintAssign [oo]{{\xintiiDivision{1000000000000}{133333333}}}\to\X +\meaning\X\newline +\xintAssign \xintiiPow{7}{13}\to\SevenToThePowerThirteen +\meaning\SevenToThePowerThirteen\par +\end{everbatim*} -Special case: if after this initial expansion no brace is found immediately -after \csa{xintAssign}, it is assumed that there is only one control sequence -following |\to|, and this control sequence is then defined via -|\def| to expand to the material between -\csa{xintAssign} and \csa{to}. Other types of expansions are specified through -an optional parameter to \csa{xintAssign}, see \emph{infra}. -% -\leftedline{|\xintAssign \xintiiDivision{1000000000000}{133333333}\to\Q\R|} -% -\leftedline{|\meaning\Q: |\dtt{\meaning\Q}, |\meaning\R:| - \dtt{\meaning\R}} % -% -\leftedline{|\xintAssign \xintiiPow - {7}{13}\to\SevenToThePowerThirteen|} -% -\leftedline{|\SevenToThePowerThirteen|\dtt{=\SevenToThePowerThirteen}} -% -\leftedline{(same as |\edef\SevenToThePowerThirteen{\xintiPow {7}{13}}|)} +Two special cases: +\begin{itemize}[nosep] +\item if after this initial expansion no brace is found immediately after + \csa{xintAssign}, it is assumed that there is only one control sequence + following |\to|, and this control sequence is then defined via |\def| (or + what is set-up by the optional parameter) to expand to the material between + \csa{xintAssign} and \csa{to}. +\item if the material between \csa{xintAssign} and |\to| is enclosed in two + brace pairs, the first brace pair is removed, then the \fexpan sion is + immediately stopped by the inner brace pair, hence \csa{xintAssign} now + finds a unique item and thus defines only a single macro to be this item, + which is now stripped of the second pair of braces. +\end{itemize} + + +\emph{Note:} prior to release |1.09j|, |\xintAssign| did an |\edef| by default +for each item assignment but it now does |\def| corresponding to no or empty +optional parameter. + +It is allowed for the successive braced items to be separated by spaces. They +are removed during the assignments. But if a single macro is defined (which +happens if the argument after \fexpan sion does not start with a brace), +naturally the scooped up material has all intervening spaces, as it is +considered a +single item. But an upfront initial space will have been absorbed by \fexpan +sion. +\begin{everbatim*} +\def\X{ {a} {b} {c} {d} }\def\Y { u {a} {b} {c} {d} } +\xintAssign\X\to\A\B\C\D +\xintAssign\Y\to\Z +\meaning\A, \meaning\B, \meaning\C, \meaning\D+++\newline +\meaning\Z+++\par +\end{everbatim*} +As usual successive space characters in input make for a single \TeX\ space token. -\noindent\csa{xintAssign} admits since |1.09i| an -optional parameter, for example |\xintAssign [e]...| or |\xintAssign [oo] -...|. With |[f]| for example the definitions of the macros initially on the -right of |\to| will be made with \hyperref[fdef]{\ttfamily\char92fdef} which -\fexpan ds the replacement text. The default is simply to make the -definitions with |\def|, corresponding to an empty optional paramter |[]|. -Possibilities: |[], [g], [e], [x], [o], [go], [oo], [goo], [f], [gf]|. - -In all cases, recall that |\xintAssign| starts with an \fexpan sion of what -comes next; this produces some list of tokens or braced items, and the -optional parameter only intervenes to decide the expansion type to be applied -then to each one of these items. - -\emph{Note:} prior to release |1.09j|, |\xintAssign| did an |\edef| by -default, but it now does |\def|. Use the optional parameter |[e]| to force use -of |\edef|. - -{\small \emph{Remark:} since |xinttools 1.1c|, \csa{xintAssign} is less picky - and a stray space right before the |\to| causes no surprises, and the - successive braced items may be separated by spaces, which will get - discarded. In case the contents up to |\to| did not start with a brace a - single macro is defined and it will contain the spaces. Contrarily to the - earlier version, there is no problem if such contents do contain braces - after the first non-brace token. -\par -} \subsection{\csbh{xintAssignArray}}\label{xintAssignArray} @@ -9506,16 +9748,14 @@ successive elements are \csa{myArray}|{1}|, \dots, \csa{myArray}|{M}|. \dtt{(\Bez3)${}\times{}$\Bez1${}-{}$(\Bez4)${}\times{}$\Bez2${}={}$\Bez5.} This macro is incompatible with expansion-only contexts. -\csa{xintAssignArray} admits now an optional -parameter, for example |\xintAssignArray [e]...|. This means that the -definitions of the macros will be made with |\edef|. The default is -|[]|, which makes the definitions with |\def|. Other possibilities: |[], -[o], [oo], [f]|. Contrarily to \csbxint{Assign} one can not use the |g| -here to make the definitions global. For this, one should rather do -|\xintAssignArray| within a group starting with |\globaldefs 1|. +\csa{xintAssignArray} admits an optional parameter, for example +|\xintAssignArray [e]| means that the definitions of the macros will be made +with |\edef|. The empty optional parameter (default) means that definitions +are done with |\def|. Other possibilities: |[], [o], [oo], [f]|. Contrarily to +\csbxint{Assign} one can not use the |g| here to make the definitions global. +For this, one should rather do |\xintAssignArray| within a group starting with +|\globaldefs 1|. -Note that prior to release |1.09j| each item (token or braced material) was -submitted to an |\edef|, but the default is now to use |\def|. \subsection{\csbh{xintDigitsOf}}\label{xintDigitsOf} @@ -9674,6 +9914,17 @@ The variant \csa{xintLDg}\etype{\Numf} uses |\xintNum|. \csa{xintiiAdd} skips the \csbxint{Num} overhead.\etype{ff} +\subsection{\csbh{xintCmp}, \csbh{xintiiCmp}} + +|\xintCmp|\n\m\etype{\Numf\Numf} returns \dtt{1} if |N>M|, \dtt{0} if |N=M|, +and \dtt{-1} if |N<M|. + +\csa{xintiiCmp} skips the \csbxint{Num} overhead.\etype{ff} + +\csbxint{Cmp} is re-defined by \xintfracname to accept fractions. + +|1.2l| has moved this macro from \xintname to \xintcorename. + \subsection{\csbh{xintiSub}, \csbh{xintiiSub}}\label{xintiSub}\label{xintiiSub} |\xintiSub|\n\m\etype{\Numf\Numf} computes the difference |N-M|. @@ -9891,29 +10142,22 @@ important background information. \subsection{\csbh{xintReverseDigits}} \label{xintReverseDigits} |\xintReverseDigits|\n\etype{f} will reverse the order of the digits of the -number, preserving an optional upfront minus sign. \csa{xintRev} is the former -denomination and is kept as an alias to it. Leading zeroes resulting from the -operation are not removed. Contrarily to \csbxint{ReverseOrder} this macro can -only be used with digits and it first expands its argument (but beware that -|-\x| will give an unexpected result as the minus sign immediately stops this -expansion; one can use |\xintiiOpp{\x}| as argument.) +number. \csa{xintRev} is the former +denomination and is kept as an alias. Leading zeroes resulting from the +operation are not removed. Contrarily to \csbxint{ReverseOrder} this macro +expands its argument; it is only usable with digit tokens. It does accept a +leading minus sign which is left upfront in output. -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|. \begingroup \begin{everbatim*} \fdef\x{\xintReverseDigits - {-98765432109876543210987654321098765432109876543210}}\meaning\x\par + {98765432109876543210987654321098765432109876543210}}\meaning\x\par \noindent\fdef\x{\xintReverseDigits {\xintReverseDigits - {-98765432109876543210987654321098765432109876543210}}}\meaning\x\par + {98765432109876543210987654321098765432109876543210}}}\meaning\x\par \end{everbatim*} \endgroup -Notice that the output in this case with its leading zero is not in the strict -integer format expected by the `|ii|' arithmetic macros. - \subsection{\csbh{xintLen}}\label{xintiLen} |\xintLen|\n\etype{\Numf} returns the length of the number, not counting the @@ -9939,14 +10183,18 @@ less than circa $2^{31}$, but this is a bit theoretical. \xinttoolsname. See also \csbxint{Length} from \xintkernelname for counting tokens (or rather braced groups), more generally. -\subsection{\csbh{xintCmp}, \csbh{xintiiCmp}} +\subsection{\csbh{xintCmp}, \csbh{xintiiCmp}}\label{xintiiCmp} |\xintCmp|\n\m\etype{\Numf\Numf} returns \dtt{1} if |N>M|, \dtt{0} if |N=M|, -and \dtt{-1} if |N<M|. Extended by \xintfracname to fractions (its output -naturally still being either |1|, |0|, or |-1|). +and \dtt{-1} if |N<M|. \csa{xintiiCmp} skips the \csbxint{Num} overhead.\etype{ff} +\csbxint{Cmp} is re-defined by \xintfracname to accept fractions. + +Since |1.2l| these macros are actually provided by package \xintcorename.sty +(which is loaded by \xintname). + \subsection{\csbh{xintEq}, \csbh{xintiiEq}}\label{xintEq} |\xintEq|\n\m\etype{\Numf\Numf} returns 1 if |N=M|, 0 otherwise. Extended @@ -10799,10 +11047,10 @@ This also puts the fraction\etype{\Ff} into its unique irreducible form: % This is faster than \csa{xintIrr} for fractions having some big common factor in the numerator and the denominator.\par -{\centering |\xintJrr {\xintiPow{\xintiiFac {15}}{3}/\xintiiPrdExpr -{\xintiiFac{10}}{\xintiiFac{30}}{\xintiiFac{5}}\relax }|\dtt{=% - \xintJrr {\xintiPow{\xintiiFac {15}}{3}/\xintiiPrdExpr -{\xintiiFac{10}}{\xintiiFac{30}}{\xintiiFac{5}}\relax }}\par} But to notice the +{\centering |\xintJrr {\xintiPow{\xintiiFac {15}}{3}/\xintiiPrd +{{\xintiiFac{10}}{\xintiiFac{30}}{\xintiiFac{5}}}}|\dtt{=% + \xintJrr {\xintiPow{\xintiiFac {15}}{3}/\xintiiPrd +{{\xintiiFac{10}}{\xintiiFac{30}}{\xintiiFac{5}}}}}\par} But to notice the difference one would need computations with much bigger numbers than in this example. Starting with release |1.08|, \csa{xintJrr} does not remove the trailing |/1| @@ -11274,7 +11522,7 @@ Within an \csbxint{iiexpr}|..\relax| the infix operator |^| is mapped to \csa{xintPow}. -\subsection{\csbh{xintSum}}\label{xintSum}\label{xintSumExpr} +\subsection{\csbh{xintSum}}\label{xintSum} This\etype{f{$\to$}{\lowast\Ff}} computes the sum of fractions. The output will now always be in the form |A/B[n]|. The original, for big integers only @@ -11286,7 +11534,7 @@ will now always be in the form |A/B[n]|. The original, for big integers only No simplification attempted. -\subsection{\csbh{xintPrd}}\label{xintPrd}\label{xintPrdExpr} +\subsection{\csbh{xintPrd}}\label{xintPrd} TThis\etype{f{$\to$}{\lowast\Ff}} computes the product of fractions. The output will now always be in the form |A/B[n]|. The original, for big integers only @@ -11517,8 +11765,6 @@ places or to the precision from |\xintDigits|. It then produces the sum |f'+g'|, correctly rounded to nearest with the same number of significant places. -See \autoref{ssec:floatingpoint} for more. - \subsection{\csbh{xintFloatSub}}\label{xintFloatSub} @@ -11528,8 +11774,6 @@ and |g| with their float approximations |f'| and |g'| to |P| significant places or to the precision from |\xintDigits|. It then produces the difference |f'-g'| correctly rounded to nearest |P|-float. -See \autoref{ssec:floatingpoint} for more. - \subsection{\csbh{xintFloatMul}}\label{xintFloatMul} @@ -11562,10 +11806,11 @@ the fraction |f'/g'| to nearest |P|-float. See \autoref{ssec:floatingpoint} for more. -Notice that if |f| and |g| are integers and one wants the fraction |f/g| -correctly rounded one should use \csbxint{Float}|[P]{f/g}| and not -|\xintFloatDiv [P]{f}{g}|, because the latter will first round |f| and |g| to -scientific numbers with mantissas of |P| digits. +Notice in the special situation with |f| and |g| integers that |\xintFloatDiv +[P]{f}{g}| will \emph{not necessarily} give the correct rounding of the +exact fraction |f/g|. Indeed the macro arguments are each first individually +rounded to |P| digits of precision. The correct syntax to get the correctly +rounded integer fraction |f/g| is \csbxint{Float}|[P]{f/g}|. \subsection{\csbh{xintFloatFac}}\label{xintFloatFac} @@ -13014,16 +13259,23 @@ principles are necessarily different due to the aim of achieving expandability. This package was first included in the |1.08| (|2013/06/07|) release of \xintname. It provides expandable conversions of arbitrarily big integers to and -from binary and hexadecimal. +from binary and hexadecimal. Routines have not been modified since. + +The argument is first \fexpan ded. -The argument is first \fexpan ded. It then may start with an optional minus -sign (unique, of category code other), followed with optional leading zeroes -(arbitrarily many, category code other) and then ``digits'' (hexadecimal -letters may be of category code letter or other, and must be -uppercased). The optional (unique) minus sign (plus sign is not allowed) is -kept in the output. Leading zeroes are allowed, and stripped. The -hexadecimal letters on output are of category code letter, and -uppercased. +It may optionally have a leading minus sign (explicit plus sign is not +allowed), then leading zeroes, then digits. Hexadecimal digits |A..F| must be +in uppercase. Category code for them on input may be \emph{letter} or +\emph{other}. The hexadecimal letters on output are of category code +\emph{letter}, and again in uppercase. + +Input must not be within quotes or with |0b|, |0x|, |#x| or similar prefixes: +simply decimal, binary, or hexadecimal digits. + +With this package loaded additionally to \xintexprname, hexadecimal input +becomes possible in expressions with the prefix |"|. Such hexadecimal numbers +may have an hexadecimal mark and fractional digits. The letters must be in +uppercase. % \clearpage @@ -13133,63 +13385,41 @@ macro, it is \fexpan ded first and must contain at least one item. \subsection{\csbh{xintBezout}}\label{xintBezout} -\xintAssign{{\xintBezout {10000}{1113}}}\to\X -\xintAssign {\xintBezout {10000}{1113}}\to\A\B\U\V\D - |\xintBezout|\n\m\etype{\Numf\Numf} returns five numbers |A|, |B|, |U|, |V|, |D| within braces. |A| is the first (expanded, as usual) input number, |B| the -second, |D| is the GCD, and \dtt{UA - VB = D}. % -% -\leftedline{|\xintAssign - {{\xintBezout {10000}{1113}}}\to\X|} % -% -\leftedline{|\meaning\X: - |\dtt{\meaning\X }.} -\noindent{|\xintAssign {\xintBezout {10000}{1113}}\to\A\B\U\V\D|}\\ -|\A: |\dtt{\A }, -|\B: |\dtt{\B }, -|\U: |\dtt{\U }, -|\V: |\dtt{\V }, -|\D: |\dtt{\D }.\\ +second, |D| is the GCD, and \dtt{UA - VB = D}. +\begin{everbatim*} +\xintAssign[oo]{{\xintBezout {10000}{1113}}}\to\X +\meaning\X\newline +\xintAssign {\xintBezout {10000}{1113}}\to\A\B\U\V\D +A: \meaning\A\newline +B: \meaning\B\newline +U: \meaning\U\newline +V: \meaning\V\newline +D: \meaning\D\par +\end{everbatim*} +For more than three years (from |1.09j 2014/01/09| to |1.2l| in 2017...) this +documentation looked strange (also in the next two sub-sections,) because +\csbxint{Assign} was modified at |1.09j| but the example above was missing the +now needed |[oo]| (or |[f]|, or |[e]|) hence |\X| was simply displayed as +|\xintBezout {10000}{1113}|. +\begin{everbatim*} \xintAssign {\xintBezout {123456789012345}{9876543210321}}\to\A\B\U\V\D -\noindent{|\xintAssign {\xintBezout {123456789012345}{9876543210321}}\to\A\B\U\V\D -|}\\ -|\A: |\dtt{\A }, -|\B: |\dtt{\B }, -|\U: |\dtt{\U }, -|\V: |\dtt{\V }, -|\D: |\dtt{\D }. +A: \meaning\A\newline +B: \meaning\B\newline +U: \meaning\U\newline +V: \meaning\V\newline +D: \meaning\D\par +\end{everbatim*} \subsection{\csbh{xintEuclideAlgorithm}}\label{xintEuclideAlgorithm} -\xintAssign {{\xintEuclideAlgorithm {10000}{1113}}}\to\X - -\def\restorebracecatcodes - {\catcode`\{=1 \catcode`\}=2 } - -\def\allowlistsplit - {\catcode`\{=12 \catcode`\}=12 \allowlistsplita } - -\def\allowlistsplitx {\futurelet\listnext\allowlistsplitxx } - -\def\allowlistsplitxx {\ifx\listnext\relax \restorebracecatcodes - \else \expandafter\allowlistsplitxxx \fi } -\begingroup -\catcode`\[=1 -\catcode`\]=2 -\catcode`\{=12 -\catcode`\}=12 -\gdef\allowlistsplita #1{[#1\allowlistsplitx {] -\gdef\allowlistsplitxxx {#1}% - [{#1}\hskip 0pt plus 1pt \allowlistsplitx ] -\endgroup - |\xintEuclideAlgorithm|\n\m\etype{\Numf\Numf} applies the Euclide algorithm -and keeps a copy of all quotients and remainders. % -% -\leftedline{|\xintAssign {{\xintEuclideAlgorithm {10000}{1113}}}\to\X|} - -|\meaning\X: |\dtt{\expandafter\allowlistsplit\meaning\X\relax .} +and keeps a copy of all quotients and remainders. +\begin{everbatim*} +\xintAssign [oo]{{\xintEuclideAlgorithm {10000}{1113}}}\to\X +\meaning\X +\end{everbatim*} The first token is the number of steps, the second is |N|, the third is the GCD, the fourth is |M| then the first quotient and @@ -13198,17 +13428,15 @@ final quotient and last (zero) remainder. \subsection{\csbh{xintBezoutAlgorithm}}\label{xintBezoutAlgorithm} -\xintAssign {{\xintBezoutAlgorithm {10000}{1113}}}\to\X - |\xintBezoutAlgorithm|\n\m\etype{\Numf\Numf} applies the Euclide algorithm and keeps a copy of all quotients and remainders. Furthermore it computes the entries of the successive products of the 2 by 2 matrices $\left(\vcenter{\halign {\,#&\,#\cr q & 1 \cr 1 & 0 \cr}}\right)$ formed from -the quotients arising in the algorithm. % -% -\leftedline{|\xintAssign {{\xintBezoutAlgorithm {10000}{1113}}}\to\X|} - -|\meaning\X: |\dtt{\expandafter\allowlistsplit\meaning\X \relax .} +the quotients arising in the algorithm. +\begin{everbatim*} +\xintAssign [oo]{{\xintBezoutAlgorithm {10000}{1113}}}\to\X +\printnumber{\meaning\X} +\end{everbatim*} The first token is the number of steps, the second is |N|, then |0|, |1|, the GCD, |M|, |1|, |0|, the first quotient, the first @@ -13334,8 +13562,8 @@ factor of \dtt{\xintNum {\xintDenominator\w/\xintDenominator\z}}. \def\coeff #1{\xintiTrunc {40} {\the\numexpr\ifodd #1 -2\else2\fi\relax/\the\numexpr 2*#1+1\relax [0]}}% - \csa{xintiSeries}|{A}{B}{\coeff}|\etype{\numx\numx f} computes - $\sum_{\text{|n=A|}}^{\text{|n=B|}}|\coeff{n}|$ where |\coeff{n}| +\csa{xintiSeries}|{A}{B}{\coeff}|\etype{\numx\numx f} computes + $\sum_{\text{|n=A|}}^{\text{|n=B|}}$|\coeff{n}| where |\coeff{n}| must \fexpan d to a (possibly long) integer in the strict format. \everb|@ \def\coeff #1{\xintiTrunc {40}{\xintMON{#1}/#1.5}}% @@ -14993,10 +15221,22 @@ $1$ or $-1$. % 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.2l| of |2017/07/26| refactored the subtraction and also +% |\xintiiCmp| got a rewrite. It should presumably use |\pdfstrcmp| and +% related PDF\TeX\ utilities, but I do not want to have to worry about +% multi-engine usage. +% +% Some utility routines in \xintcorenameimp manipulating blocks of eight +% digits and still in |O(N^2)| style have been re-written analogously to the +% |1.2i| version of macros such as |\xintInc|. Also |\xintiNum| was +% revisited. +% +% The arithmetic macros of \xintcorenameimp and all macros of +% \xintfracnameimp using |\XINT_infrac| were made compatible with arguments +% using non-delimited |\the\numexpr| or |\the\mathcode| etc... But +% |\xintiiAbs| and |\xintiiOpp| were not modified (to avoid some overhead) +% as well as routines such as |\xintInc| which are primarily for internal +% usage. % % \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 @@ -15028,6 +15268,11 @@ $1$ or $-1$. % % \end{itemize} % +% Some parts 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. +% % 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 @@ -15058,21 +15303,6 @@ $1$ or $-1$. % The method for catcodes was also initially directly inspired by these % packages. % -% Starting with version |1.06| of the package, also |`| must be -% catcode-protected, because we replace everywhere in the code the -% twice-expansion done with |\expandafter| by the systematic use of -% |\romannumeral-`0| (later with |1.2a 2015/10/19| this was replaced -% by a fancier |\romannumeral`&&@|, with |&| of catcode 7.) -% -% Starting with version |1.06b| I decide that I suffer from an indigestion of @ -% signs, so I replace them all with underscores |_|, \`a la \LaTeX 3. -% -% Release |1.09b| is more economical: some macros are defined already in -% |xint.sty| (now in |xintkernel.sty|) and re-used in other modules. All catcode -% changes have been unified and \csa{XINT_storecatcodes} will be used by each -% module to redefine |\XINT_restorecatcodes_endinput| in case catcodes have -% changed in-between the loading of |xint.sty| (now |xintkernel.sty|) and the -% module (not very probable but...). % \begin{macrocode} \begingroup\catcode61\catcode48\catcode32=10\relax% \catcode13=5 % ^^M @@ -15105,6 +15335,8 @@ $1$ or $-1$. \fi \fi \ifx\z\relax\else\expandafter\z\fi% +% \end{macrocode} +% \begin{macrocode} \def\PrepareCatcodes {% \endgroup @@ -15175,7 +15407,7 @@ $1$ or $-1$. \catcode36=3 % $ \catcode91=12 % [ \catcode93=12 % ] - \catcode33=12 % ! + \catcode33=12 % ! (xintexpr.sty will use catcode 11) \catcode64=11 % @ LETTER \catcode38=7 % & for \romannumeral`&&@ trick. \catcode124=12 % | @@ -15219,11 +15451,9 @@ $1$ or $-1$. \fi \XINT_providespackage \ProvidesPackage {xintkernel}% - [2017/01/06 1.2k Paraphernalia for the xint packages (JFB)]% + [2017/07/26 1.2l Paraphernalia for the xint packages (JFB)]% % \end{macrocode} % \subsection{Constants} -% |1.2| decides to move them to \xintkernelnameimp from \xintcorenameimp and -% \xintnameimp. The |\count|'s are left in their respective packages. % \begin{macrocode} \chardef\xint_c_ 0 \chardef\xint_c_i 1 @@ -15236,6 +15466,7 @@ $1$ or $-1$. \chardef\xint_c_viii 8 \chardef\xint_c_ix 9 \chardef\xint_c_x 10 +\chardef\xint_c_xii 12 \chardef\xint_c_xiv 14 \chardef\xint_c_xvi 16 \chardef\xint_c_xviii 18 @@ -15290,9 +15521,6 @@ $1$ or $-1$. % | % % \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 {}% @@ -15302,11 +15530,9 @@ $1$ or $-1$. \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}% @@ -15315,9 +15541,11 @@ $1$ or $-1$. \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 {}% +\let\xint:\char +\long\def\xint_gob_til_xint:#1\xint:{}% +\def\xint_bracedstopper{\xint:}% +\long\def\xint_gob_til_exclam #1!{}% +\long\def\xint_gob_til_sc #1;{}% % \end{macrocode} % \subsection{\csh{xint_afterfi}} % \begin{macrocode} @@ -15361,21 +15589,11 @@ $1$ or $-1$. % This is not really robust as it may switch the expansion order of macros, % and the \xint_zapspaces token might end up being fetched up by a macro. But % it is enough for our purposes, for example: -% $centeredline -% $bgroup\the\numexpr \xint_zapspaces 1 2 \xint_gobble_i\relax$egroup -% expands to 12, and not 12\relax. Imagine also: -% $centeredline -% $bgroup\the\numexpr 1 2\expandafter.\the\numexpr ...$egroup -% -% The spaces will stop the \numexpr, and the \expandafter will not be -% immediately executed. Thus we have to get rid of spaces in -% contexts where arguments are fetched by delimited macros and fed to -% \numexpr (or for any reason can contain spaces). I apply this corrective -% treatment so far only in $xintexprnameimp but perhaps I should in -% $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 ! +% $centeredline$bgroup\the\numexpr \xint_zapspaces 1 2 \xint_gobble_i\relax$egroup +% expands to 12, and not 12\relax. +% +% +% 1.2e adds \xint_zapspaces_o. Expansion of #1 should not gobble a space! % % Made long with 1.2i.| % \begin{macrocode} @@ -15396,35 +15614,38 @@ $1$ or $-1$. \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. Attention: removes braces. +% \lverb|\xintReverseOrder: does NOT expand its argument. % -% A faster reverse, but only usable with digits, is provided by -% \xintReverseDigits macro from 1.2 xintcore.sty. +% Attention: removes brace pairs. % -% 1.2g has (not user documented) \xintCSVReverse in xinttools.sty.| +% For digit tokens only a faster reverse macro is provided as +% \xintReverseDigits from 1.2 xintcore.sty. +% +% For comma separated items, 1.2g has (not user documented) \xintCSVReverse in +% xinttools.sty.| % \begin{macrocode} \def\xintReverseOrder {\romannumeral0\xintreverseorder }% \long\def\xintreverseorder #1% {% \XINT_rord_main {}#1% - \xint_relax + \xint: \xint_bye\xint_bye\xint_bye\xint_bye \xint_bye\xint_bye\xint_bye\xint_bye - \xint_relax + \xint: }% \long\def\XINT_rord_main #1#2#3#4#5#6#7#8#9% {% \xint_bye #9\XINT_rord_cleanup\xint_bye \XINT_rord_main {#9#8#7#6#5#4#3#2#1}% }% -\long\edef\XINT_rord_cleanup\xint_bye\XINT_rord_main #1#2\xint_relax +\def\XINT_rord_cleanup #1{% +\long\def\XINT_rord_cleanup\xint_bye\XINT_rord_main ##1##2\xint: {% - \noexpand\expandafter\space\noexpand\xint_gob_til_xint_relax #1% -}% + \expandafter#1\xint_gob_til_xint: ##1% +}}\XINT_rord_cleanup { }% % \end{macrocode} % \subsection{\csh{xintLength}} -% \lverb|\xintLength does not expand its argument. See \xintNthElt{0} from +% \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. @@ -15436,18 +15657,17 @@ $1$ or $-1$. \def\xintlength #1{\long\def\xintlength ##1% {% \expandafter#1\the\numexpr\XINT_length_loop - ##1\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax - \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v - \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye + ##1\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint: + \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v + \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye \relax }}\xintlength{ }% \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 + \xint_gob_til_xint: #9\XINT_length_finish_a\xint: \xint_c_ix+\XINT_length_loop }% -\def\XINT_length_finish_a\xint_relax\xint_c_ix+\XINT_length_loop +\def\XINT_length_finish_a\xint:\xint_c_ix+\XINT_length_loop #1#2#3#4#5#6#7#8#9% {% #9\xint_bye @@ -15455,22 +15675,22 @@ $1$ or $-1$. % \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. +% of braces removed in output. Does NOT expand its argument. % | % \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 + {\xint:\XINT_last_loop_enda}{\xint:\XINT_last_loop_endb}% + {\xint:\XINT_last_loop_endc}{\xint:\XINT_last_loop_endd}% + {\xint:\XINT_last_loop_ende}{\xint:\XINT_last_loop_endf}% + {\xint:\XINT_last_loop_endg}{\xint:\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_gob_til_xint: #9% + {#8}{#7}{#6}{#5}{#4}{#3}{#2}{#1}\xint: \XINT_last_loop {#9}.% }% \long\def\XINT_last_loop_enda #1#2\xint_bye{ #1}% @@ -15496,8 +15716,7 @@ $1$ or $-1$. \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 + \the\numexpr#1.#2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint: \xint_c_vii\xint_c_vi\xint_c_v\xint_c_iv \xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye.% }% @@ -15511,10 +15730,10 @@ $1$ or $-1$. \long\def\XINT_lengthupto_gt #1\xint_bye.{-0}% \long\def\XINT_lengthupto_loop #1.#2#3#4#5#6#7#8#9% {% - \xint_gob_til_xint_relax #9\XINT_lengthupto_finish_a\xint_relax + \xint_gob_til_xint: #9\XINT_lengthupto_finish_a\xint:% \expandafter\XINT_lengthupto_loop_a\the\numexpr #1-\xint_c_viii.% }% -\def\XINT_lengthupto_finish_a\xint_relax\expandafter\XINT_lengthupto_loop_a +\def\XINT_lengthupto_finish_a\xint:\expandafter\XINT_lengthupto_loop_a \the\numexpr #1-\xint_c_viii.#2#3#4#5#6#7#8#9% {% \expandafter\XINT_lengthupto_finish_b\the\numexpr #1-#9\xint_bye @@ -15717,10 +15936,30 @@ $1$ or $-1$. % extended range of output streams, in LuaTeX in particular.| % \begin{macrocode} \def\xintMessage #1#2#3{% - \immediate\write128{Package #1 #2: (on line \the\inputlineno)}% - \immediate\write128{\space\space\space\space#3}% + \immediate\write128{Package #1 #2: (on line \the\inputlineno)}% + \immediate\write128{\space\space\space\space#3}% }% \newif\ifxintverbose +% \end{macrocode} +% \subsection{(WIP) Expandable error message} +% \lverb|& +% Incorporated in 1.2l release, but really belongs to next major release. +% +% This is copied over from l3kernel code. I am using \ ! / control sequence +% though, which must be left undefined. \xintError: would be 6 letters more +% already. Utiliser \FPE: ? (mais ce n'est pas uniquement du « floating point ») +% +% Always used in context where expansion was launched by a +% \romannumeral0 or \romannumeral`^^@.| +% \begin{macrocode} +\def\XINT_expandableerror #1#2{% + \def\XINT_expandableerror ##1{% + \expandafter\expandafter\expandafter + \XINT_expandableerror_continue\xint_firstofone{#2#1##1#1}}% + \def\XINT_expandableerror_continue ##1#1##2#1{##1}% +}% +\begingroup\lccode`$ 32 \catcode`/ 11 \catcode`! 11 \catcode32 11 % +\lowercase{\endgroup\XINT_expandableerror$\ ! /}% \XINT_restorecatcodes_endinput% % \end{macrocode} % @@ -15798,7 +16037,7 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xinttools}% - [2017/01/06 1.2k Expandable and non-expandable utilities (JFB)]% + [2017/07/26 1.2l 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.| @@ -15817,7 +16056,7 @@ $1$ or $-1$. % \lverb|New with 1.06. Makes the expansion of its argument and then reverses % the resulting tokens or braced tokens, adding a pair of braces to each (thus, % maintaining it when it was already there.) The reason for -% \xint_relax, here and in other locations, is in case #1 expands to nothing, +% \xint:, here and in other locations, is in case #1 expands to nothing, % the \romannumeral-`0 must be stopped| % \begin{macrocode} \def\xintRevWithBraces {\romannumeral0\xintrevwithbraces }% @@ -15825,21 +16064,21 @@ $1$ or $-1$. \long\def\xintrevwithbraces #1% {% \expandafter\XINT_revwbr_loop\expandafter{\expandafter}% - \romannumeral`&&@#1\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye + \romannumeral`&&@#1\xint:\xint:\xint:\xint:% + \xint:\xint:\xint:\xint:\xint_bye }% \long\def\xintrevwithbracesnoexpand #1% {% \XINT_revwbr_loop {}% - #1\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\xint_bye + #1\xint:\xint:\xint:\xint:% + \xint:\xint:\xint:\xint:\xint_bye }% \long\def\XINT_revwbr_loop #1#2#3#4#5#6#7#8#9% {% - \xint_gob_til_xint_relax #9\XINT_revwbr_finish_a\xint_relax + \xint_gob_til_xint: #9\XINT_revwbr_finish_a\xint:% \XINT_revwbr_loop {{#9}{#8}{#7}{#6}{#5}{#4}{#3}{#2}#1}% }% -\long\def\XINT_revwbr_finish_a\xint_relax\XINT_revwbr_loop #1#2\xint_bye +\long\def\XINT_revwbr_finish_a\xint:\XINT_revwbr_loop #1#2\xint_bye {% \XINT_revwbr_finish_b #2\R\R\R\R\R\R\R\Z #1% }% @@ -15858,7 +16097,9 @@ $1$ or $-1$. % \end{macrocode} % \lverb|1.1c revisited this old code and improved upon the earlier endings.| % \begin{macrocode} -\edef\XINT_revwbr_finish_c #1#2\Z {\noexpand\expandafter\space #1}% +\def\XINT_revwbr_finish_c#1{% +\def\XINT_revwbr_finish_c##1##2\Z{\expandafter#1##1}% +}\XINT_revwbr_finish_c{ }% % \end{macrocode} % \subsection{\csh{xintZapFirstSpaces}} % \lverb|1.09f, written [2013/11/01]. Modified (2014/10/21) for release 1.1 to @@ -15867,13 +16108,9 @@ $1$ or $-1$. % the initial one. This macro does NOT expand its argument.| % \begin{macrocode} \def\xintZapFirstSpaces {\romannumeral0\xintzapfirstspaces }% -% \end{macrocode} -% \lverb|defined via an \edef in order to inject space tokens inside.| -% \begin{macrocode} -\long\edef\xintzapfirstspaces #1% - {\noexpand\XINT_zapbsp_a \space #1\xint_relax \space\space\xint_relax }% -\xint_firstofone {\long\edef\XINT_zapbsp_a #1 } %<- space token here -{% +\def\xintzapfirstspaces#1{\long +\def\xintzapfirstspaces ##1{\XINT_zapbsp_a #1##1\xint:#1#1\xint:}% +}\xintzapfirstspaces{ }% % \end{macrocode} % \lverb|If the original #1 started with a space, the grabbed #1 is empty. Thus % _again? will see #1=\xint_bye, and hand over control to _again which will loop @@ -15882,25 +16119,24 @@ $1$ or $-1$. % then an extract of the original #1, not empty and not starting with a space, % which contains what was up to the first <sp><sp> present in original #1, or, % if none preexisted, <sptoken> and all of #1 (possibly empty) plus an ending -% \xint_relax. The added initial space will stop later the \romannumeral0. No +% \xint:. The added initial space will stop later the \romannumeral0. No % brace stripping is possible. Control is handed over to \XINT_zapbsp_b which -% strips out the ending \xint_relax<sp><sp>\xint_relax| +% strips out the ending \xint:<sp><sp>\xint:| % \begin{macrocode} - \noexpand\XINT_zapbsp_again? #1\noexpand\xint_bye\noexpand\XINT_zapbsp_b #1\space\space -}% +\def\XINT_zapbsp_a#1{\long\def\XINT_zapbsp_a ##1#1#1{% + \XINT_zapbsp_again?##1\xint_bye\XINT_zapbsp_b ##1#1#1}% +}\XINT_zapbsp_a{ }% \long\def\XINT_zapbsp_again? #1{\xint_bye #1\XINT_zapbsp_again }% \xint_firstofone{\def\XINT_zapbsp_again\XINT_zapbsp_b} {\XINT_zapbsp_a }% -\long\def\XINT_zapbsp_b #1\xint_relax #2\xint_relax {#1}% +\long\def\XINT_zapbsp_b #1\xint:#2\xint:{#1}% % \end{macrocode} % \subsection{\csh{xintZapLastSpaces}} % \lverb+1.09f, written [2013/11/01]. + % \begin{macrocode} \def\xintZapLastSpaces {\romannumeral0\xintzaplastspaces }% -% \end{macrocode} -% \lverb|Next macro is defined via an \edef for the space tokens.| -% \begin{macrocode} -\long\edef\xintzaplastspaces #1{\noexpand\XINT_zapesp_a {}\noexpand\empty#1% - \space\space\noexpand\xint_bye\xint_relax}% +\def\xintzaplastspaces#1{\long +\def\xintzaplastspaces ##1{\XINT_zapesp_a {}\empty##1#1#1\xint_bye\xint:}% +}\xintzaplastspaces{ }% % \end{macrocode} % \lverb|The \empty from \xintzaplastspaces is to prevent brace removal in the % #2 below. The \expandafter chain removes it.| @@ -15911,12 +16147,12 @@ $1$ or $-1$. % \lverb|Notice again an \empty added here. This is in preparation for possibly looping % back to \XINT_zapesp_a. If the initial #1 had no <sp><sp>, the stuff however % will not loop, because #3 will already be <some spaces>\xint_bye. Notice -% that this macro fetches all way to the ending \xint_relax. This looks not +% that this macro fetches all way to the ending \xint:. This looks not % very efficient, but how often do we have to strip ending spaces from % something which also has inner stretches of _multiple_ space tokens ?;-). | % \begin{macrocode} -\long\def\XINT_zapesp_b #1#2#3\xint_relax - {\XINT_zapesp_end? #3\XINT_zapesp_e {#2#1}\empty #3\xint_relax }% +\long\def\XINT_zapesp_b #1#2#3\xint:% + {\XINT_zapesp_end? #3\XINT_zapesp_e {#2#1}\empty #3\xint:}% % \end{macrocode} % \lverb|When we have been over all possible <sp><sp> things, we reach the % ending space tokens, and #3 will be a bunch of spaces (possibly none) @@ -15930,12 +16166,14 @@ $1$ or $-1$. % \lverb|We are done. The #1 here has accumulated all the previous material, % and is stripped of its ending spaces, if any.| % \begin{macrocode} -\long\def\XINT_zapesp_end\XINT_zapesp_e #1#2\xint_relax { #1}% +\long\def\XINT_zapesp_end\XINT_zapesp_e #1#2\xint:{ #1}% % \end{macrocode} % \lverb|We haven't yet reached the end, so we need to re-inject two space % tokens after what we have gotten so far. Then we loop.| % \begin{macrocode} -\long\edef\XINT_zapesp_e #1{\noexpand \XINT_zapesp_a {#1\space\space}}% +\def\XINT_zapesp_e#1{% +\long\def\XINT_zapesp_e ##1{\XINT_zapesp_a {##1#1#1}}% +}\XINT_zapesp_e{ }% % \end{macrocode} % \subsection{\csh{xintZapSpaces}} % \lverb+1.09f, written [2013/11/01]. Modified for 1.1, 2014/10/21 as it has the @@ -15943,32 +16181,38 @@ $1$ or $-1$. % then \xintZapLastSpaces.+ % \begin{macrocode} \def\xintZapSpaces {\romannumeral0\xintzapspaces }% -\long\edef\xintzapspaces #1% like \xintZapFirstSpaces. - {\noexpand\XINT_zapsp_a \space #1\xint_relax \space\space\xint_relax }% -\xint_firstofone {\long\edef\XINT_zapsp_a #1 } % - {\noexpand\XINT_zapsp_again? #1\noexpand\xint_bye\noexpand\XINT_zapsp_b #1\space\space}% +\def\xintzapspaces#1{% +\long\def\xintzapspaces ##1% like \xintZapFirstSpaces. + {\XINT_zapsp_a #1##1\xint:#1#1\xint:}% +}\xintzapspaces{ }% +\def\XINT_zapsp_a#1{% +\long\def\XINT_zapsp_a ##1#1#1% + {\XINT_zapsp_again?##1\xint_bye\XINT_zapsp_b##1#1#1}% +}\XINT_zapsp_a{ }% \long\def\XINT_zapsp_again? #1{\xint_bye #1\XINT_zapsp_again }% \xint_firstofone{\def\XINT_zapsp_again\XINT_zapsp_b} {\XINT_zapsp_a }% \xint_firstofone{\def\XINT_zapsp_b} {\XINT_zapsp_c }% -\long\edef\XINT_zapsp_c #1\xint_relax #2\xint_relax {\noexpand\XINT_zapesp_a - {}\noexpand \empty #1\space\space\noexpand\xint_bye\xint_relax }% +\def\XINT_zapsp_c#1{% +\long\def\XINT_zapsp_c ##1\xint:##2\xint:% + {\XINT_zapesp_a{}\empty ##1#1#1\xint_bye\xint:}% +}\XINT_zapsp_c{ }% % \end{macrocode} % \subsection{\csh{xintZapSpacesB}} % \lverb+1.09f, written [2013/11/01]. Strips up to one pair of braces (but then % does not strip spaces inside).+ % \begin{macrocode} \def\xintZapSpacesB {\romannumeral0\xintzapspacesb }% -\long\def\xintzapspacesb #1{\XINT_zapspb_one? #1\xint_relax\xint_relax +\long\def\xintzapspacesb #1{\XINT_zapspb_one? #1\xint:\xint:% \xint_bye\xintzapspaces {#1}}% \long\def\XINT_zapspb_one? #1#2% - {\xint_gob_til_xint_relax #1\XINT_zapspb_onlyspaces\xint_relax - \xint_gob_til_xint_relax #2\XINT_zapspb_bracedorone\xint_relax + {\xint_gob_til_xint: #1\XINT_zapspb_onlyspaces\xint:% + \xint_gob_til_xint: #2\XINT_zapspb_bracedorone\xint:% \xint_bye {#1}}% -\def\XINT_zapspb_onlyspaces\xint_relax - \xint_gob_til_xint_relax\xint_relax\XINT_zapspb_bracedorone\xint_relax +\def\XINT_zapspb_onlyspaces\xint:% + \xint_gob_til_xint:\xint:\XINT_zapspb_bracedorone\xint:% \xint_bye #1\xint_bye\xintzapspaces #2{ }% -\long\def\XINT_zapspb_bracedorone\xint_relax - \xint_bye #1\xint_relax\xint_bye\xintzapspaces #2{ #1}% +\long\def\XINT_zapspb_bracedorone\xint:% + \xint_bye #1\xint:\xint_bye\xintzapspaces #2{ #1}% % \end{macrocode} % \subsection{\csh{xintCSVtoList}, \csh{xintCSVtoListNonStripped}} % \lverb|\xintCSVtoList transforms a,b,..,z into {a}{b}...{z}. The comma @@ -16102,8 +16346,7 @@ $1$ or $-1$. \long\def\XINT_nthelt_neg #1.#2% {% \expandafter\XINT_nthelt_neg_a\the\numexpr\xint_c_i+\XINT_length_loop - #2\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax + #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint: \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye -#1.#2\xint_bye @@ -16123,13 +16366,13 @@ $1$ or $-1$. {% \expandafter\XINT_nthelt_pos_done \romannumeral0\expandafter\XINT_trim_loop\the\numexpr#1-\xint_c_x.% - #2\xint_relax\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax + #2\xint:\xint:\xint:\xint:\xint:% + \xint:\xint:\xint:\xint:\xint:% \xint_bye }% \def\XINT_nthelt_pos_done #1{% \long\def\XINT_nthelt_pos_done ##1##2\xint_bye{% - \xint_gob_til_xint_relax##1\expandafter#1\xint_gobble_ii\xint_relax#1##1}% + \xint_gob_til_xint:##1\expandafter#1\xint_gobble_ii\xint:#1##1}% }\XINT_nthelt_pos_done{ }% % \end{macrocode} % \subsection{\csh{xintKeep}} @@ -16176,8 +16419,7 @@ $1$ or $-1$. {% \expandafter\XINT_keep_neg_a\the\numexpr #1-\numexpr\XINT_length_loop - #2\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax + #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint: \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye.#2% }% @@ -16193,8 +16435,7 @@ $1$ or $-1$. {% \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 + #1.#2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint: \xint_c_vii\xint_c_vi\xint_c_v\xint_c_iv \xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye.% -\xint_c_viii.{}#2\xint_bye% @@ -16256,8 +16497,7 @@ $1$ or $-1$. {% \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 + #1.#2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint: \xint_c_vii\xint_c_vi\xint_c_v\xint_c_iv \xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye.% -\xint_c_viii.{}#2\xint_bye% @@ -16327,8 +16567,7 @@ $1$ or $-1$. {% \expandafter\XINT_trim_neg_a\the\numexpr #1-\numexpr\XINT_length_loop - #2\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax + #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint: \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye .{}#2\xint_bye @@ -16340,7 +16579,9 @@ $1$ or $-1$. -\XINT_trim_trimall \krof }% -\edef\XINT_trim_trimall {\noexpand\expandafter\space\noexpand\xint_bye}% +\def\XINT_trim_trimall#1{% +\def\XINT_trim_trimall {\expandafter#1\xint_bye}% +}\XINT_trim_trimall{ }% % \end{macrocode} % \lverb|This branch doesn't pre-evaluate the length of the list argument. % Redone again for 1.2j, manages to trim nine by nine. Some non optimal @@ -16350,8 +16591,8 @@ $1$ or $-1$. {% \expandafter\XINT_trim_pos_done\expandafter\space \romannumeral0\expandafter\XINT_trim_loop\the\numexpr#1-\xint_c_ix.% - #2\xint_relax\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax + #2\xint:\xint:\xint:\xint:\xint:% + \xint:\xint:\xint:\xint:\xint:% \xint_bye }% \def\XINT_trim_loop #1#2.% @@ -16361,9 +16602,9 @@ $1$ or $-1$. }% \long\def\XINT_trim_loop_trimnine #1#2#3#4#5#6#7#8#9% {% - \xint_gob_til_xint_relax #9\XINT_trim_toofew\xint_relax-\xint_c_ix.% + \xint_gob_til_xint: #9\XINT_trim_toofew\xint:-\xint_c_ix.% }% -\def\XINT_trim_toofew\xint_relax{*\xint_c_}% +\def\XINT_trim_toofew\xint:{*\xint_c_}% \def\XINT_trim_finish#1{% \def\XINT_trim_finish-% \expandafter\XINT_trim_loop\the\numexpr-##1\XINT_trim_loop_trimnine @@ -16371,7 +16612,7 @@ $1$ or $-1$. \expandafter\expandafter\expandafter#1% \csname xint_gobble_\romannumeral\numexpr\xint_c_ix-##1\endcsname }}\XINT_trim_finish{ }% -\long\def\XINT_trim_pos_done #1\xint_relax #2\xint_bye {#1}% +\long\def\XINT_trim_pos_done #1\xint:#2\xint_bye {#1}% % \end{macrocode} % \subsection{\csh{xintTrimUnbraced}} % \lverb?1.2a. Modified in 1.2i like \xintTrim? @@ -16395,8 +16636,7 @@ $1$ or $-1$. {% \expandafter\XINT_trimunbr_neg_a\the\numexpr #1-\numexpr\XINT_length_loop - #2\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax + #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint: \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye .{}#2\xint_bye @@ -17032,7 +17272,7 @@ $1$ or $-1$. \long\def\XINT_assign_a #1\to {% \def\XINT_flet_macro{\XINT_assign_b}% - \expandafter\XINT_flet_zapsp\romannumeral`&&@#1\xint_relax\to + \expandafter\XINT_flet_zapsp\romannumeral`&&@#1\xint:\to }% \long\def\XINT_assign_b {% @@ -17041,14 +17281,14 @@ $1$ or $-1$. \else\expandafter\XINT_assign_f \fi }% -\long\def\XINT_assign_f #1\xint_relax\to #2% +\long\def\XINT_assign_f #1\xint:\to #2% {% \XINT_assign_def #2{#1}% }% \long\def\XINT_assign_c #1% {% \def\xint_temp {#1}% - \ifx\xint_temp\xint_brelax + \ifx\xint_temp\xint_bracedstopper \expandafter\XINT_assign_e \else \expandafter\XINT_assign_d @@ -17100,7 +17340,7 @@ $1$ or $-1$. \expandafter\def\expandafter\xint_arrayname\expandafter {\string #2}% \XINT_restoreescapechar \def\xint_itemcount {0}% - \expandafter\XINT_assignarray_loop \romannumeral`&&@#1\xint_relax + \expandafter\XINT_assignarray_loop \romannumeral`&&@#1\xint: \csname\xint_arrayname 00\expandafter\endcsname \csname\xint_arrayname 0\expandafter\endcsname \expandafter {\xint_arrayname}#2% @@ -17108,7 +17348,7 @@ $1$ or $-1$. \long\def\XINT_assignarray_loop #1% {% \def\xint_temp {#1}% - \ifx\xint_brelax\xint_temp + \ifx\xint_temp\xint_bracedstopper \expandafter\def\csname\xint_arrayname 0\expandafter\endcsname \expandafter{\the\numexpr\xint_itemcount}% \expandafter\expandafter\expandafter\XINT_assignarray_end @@ -17130,11 +17370,12 @@ $1$ or $-1$. \def #1##1% {% \ifnum ##1<\xint_c_ - \xint_afterfi {\xintError:ArrayIndexIsNegative\space }% + \xint_afterfi{\XINT_expandableerror{Array index negative: 0 > ##1} }% \else \xint_afterfi {% \ifnum ##1>#2 - \xint_afterfi {\xintError:ArrayIndexBeyondLimit\space }% + \xint_afterfi + {\XINT_expandableerror{Array index beyond range: ##1 > #2} }% \else\xint_afterfi {\expandafter\expandafter\expandafter\space\csname #3##1\endcsname}% \fi}% @@ -17223,8 +17464,8 @@ $1$ or $-1$. \def\xintlength:f:csv #1% {\long\def\xintlength:f:csv ##1{% \expandafter#1\the\numexpr\expandafter\XINT_length:f:csv_a - \romannumeral`&&@##1\xint_relax,\xint_relax,\xint_relax,\xint_relax,% - \xint_relax,\xint_relax,\xint_relax,\xint_relax,\xint_relax,% + \romannumeral`&&@##1\xint:,\xint:,\xint:,\xint:,% + \xint:,\xint:,\xint:,\xint:,\xint:,% \xint_c_ix,\xint_c_viii,\xint_c_vii,\xint_c_vi,% \xint_c_v,\xint_c_iv,\xint_c_iii,\xint_c_ii,\xint_c_i,\xint_bye \relax @@ -17234,15 +17475,15 @@ $1$ or $-1$. % \begin{macrocode} \long\def\XINT_length:f:csv_a #1% {% - \xint_gob_til_xint_relax #1\xint_c_\xint_bye\xint_relax + \xint_gob_til_xint: #1\xint_c_\xint_bye\xint:% \XINT_length:f:csv_loop #1% }% \long\def\XINT_length:f:csv_loop #1,#2,#3,#4,#5,#6,#7,#8,#9,% {% - \xint_gob_til_xint_relax #9\XINT_length:f:csv_finish\xint_relax + \xint_gob_til_xint: #9\XINT_length:f:csv_finish\xint:% \xint_c_ix+\XINT_length:f:csv_loop }% -\def\XINT_length:f:csv_finish\xint_relax\xint_c_ix+\XINT_length:f:csv_loop +\def\XINT_length:f:csv_finish\xint:\xint_c_ix+\XINT_length:f:csv_loop #1,#2,#3,#4,#5,#6,#7,#8,#9,{#9\xint_bye}% % \end{macrocode} % \subsubsection{\csh{xintLengthUpTo:f:csv}} @@ -17256,8 +17497,8 @@ $1$ or $-1$. {% \expandafter\XINT_lengthupto:f:csv_a \the\numexpr#1\expandafter.% - \romannumeral`&&@#2\xint_relax,\xint_relax,\xint_relax,\xint_relax,% - \xint_relax,\xint_relax,\xint_relax,\xint_relax,% + \romannumeral`&&@#2\xint:,\xint:,\xint:,\xint:,% + \xint:,\xint:,\xint:,\xint:,% \xint_c_viii,\xint_c_vii,\xint_c_vi,\xint_c_v,% \xint_c_iv,\xint_c_iii,\xint_c_ii,\xint_c_i,\xint_bye.% }% @@ -17266,10 +17507,10 @@ $1$ or $-1$. % \begin{macrocode} \long\def\XINT_lengthupto:f:csv_a #1.#2% {% - \xint_gob_til_xint_relax #2\XINT_lengthupto:f:csv_empty\xint_relax + \xint_gob_til_xint: #2\XINT_lengthupto:f:csv_empty\xint:% \XINT_lengthupto:f:csv_loop_b #1.#2% }% -\def\XINT_lengthupto:f:csv_empty\xint_relax +\def\XINT_lengthupto:f:csv_empty\xint:% \XINT_lengthupto:f:csv_loop_b #1.#2\xint_bye.{ #1}% \def\XINT_lengthupto:f:csv_loop_a #1% {% @@ -17281,10 +17522,10 @@ $1$ or $-1$. \long\def\XINT_lengthupto:f:csv_gt #1\xint_bye.{-0}% \long\def\XINT_lengthupto:f:csv_loop_b #1.#2,#3,#4,#5,#6,#7,#8,#9,% {% - \xint_gob_til_xint_relax #9\XINT_lengthupto:f:csv_finish_a\xint_relax + \xint_gob_til_xint: #9\XINT_lengthupto:f:csv_finish_a\xint:% \expandafter\XINT_lengthupto:f:csv_loop_a\the\numexpr #1-\xint_c_viii.% }% -\def\XINT_lengthupto:f:csv_finish_a\xint_relax +\def\XINT_lengthupto:f:csv_finish_a\xint: \expandafter\XINT_lengthupto:f:csv_loop_a \the\numexpr #1-\xint_c_viii.#2,#3,#4,#5,#6,#7,#8,#9,% {% @@ -17331,8 +17572,8 @@ $1$ or $-1$. \romannumeral0% \expandafter\XINT_keep:f:csv_neg_a\the\numexpr #1-\numexpr\XINT_length:f:csv_a - #2\xint_relax,\xint_relax,\xint_relax,\xint_relax,% - \xint_relax,\xint_relax,\xint_relax,\xint_relax,\xint_relax,% + #2\xint:,\xint:,\xint:,\xint:,% + \xint:,\xint:,\xint:,\xint:,\xint:,% \xint_c_ix,\xint_c_viii,\xint_c_vii,\xint_c_vi,% \xint_c_v,\xint_c_iv,\xint_c_iii,\xint_c_ii,\xint_c_i,\xint_bye .#2\xint_bye @@ -17361,8 +17602,8 @@ $1$ or $-1$. {% \expandafter\XINT_keep:f:csv_pos_fork \romannumeral0\XINT_lengthupto:f:csv_a - #1.#2\xint_relax,\xint_relax,\xint_relax,\xint_relax,% - \xint_relax,\xint_relax,\xint_relax,\xint_relax,% + #1.#2\xint:,\xint:,\xint:,\xint:,% + \xint:,\xint:,\xint:,\xint:,% \xint_c_viii,\xint_c_vii,\xint_c_vi,\xint_c_v,% \xint_c_iv,\xint_c_iii,\xint_c_ii,\xint_c_i,\xint_bye.% .#1.{}#2\xint_bye% @@ -17427,8 +17668,8 @@ $1$ or $-1$. {% \expandafter\XINT_trim:f:csv_neg_a\the\numexpr #1-\numexpr\XINT_length:f:csv_a - #2\xint_relax,\xint_relax,\xint_relax,\xint_relax,% - \xint_relax,\xint_relax,\xint_relax,\xint_relax,\xint_relax,% + #2\xint:,\xint:,\xint:,\xint:,% + \xint:,\xint:,\xint:,\xint:,\xint:,% \xint_c_ix,\xint_c_viii,\xint_c_vii,\xint_c_vi,% \xint_c_v,\xint_c_iv,\xint_c_iii,\xint_c_ii,\xint_c_i,\xint_bye .{}#2\xint_bye @@ -17446,8 +17687,8 @@ $1$ or $-1$. \expandafter\XINT_trim:f:csv_pos_done\expandafter,% \romannumeral0% \expandafter\XINT_trim:f:csv_loop\the\numexpr#1-\xint_c_ix.% - #2\xint_relax,\xint_relax,\xint_relax,\xint_relax,\xint_relax,% - \xint_relax,\xint_relax,\xint_relax,\xint_relax,\xint_relax\xint_bye + #2\xint:,\xint:,\xint:,\xint:,\xint:,% + \xint:,\xint:,\xint:,\xint:,\xint:\xint_bye }% \def\XINT_trim:f:csv_loop #1#2.% {% @@ -17456,9 +17697,9 @@ $1$ or $-1$. }% \long\def\XINT_trim:f:csv_loop_trimnine #1,#2,#3,#4,#5,#6,#7,#8,#9,% {% - \xint_gob_til_xint_relax #9\XINT_trim:f:csv_toofew\xint_relax-\xint_c_ix.% + \xint_gob_til_xint: #9\XINT_trim:f:csv_toofew\xint:-\xint_c_ix.% }% -\def\XINT_trim:f:csv_toofew\xint_relax{*\xint_c_}% +\def\XINT_trim:f:csv_toofew\xint:{*\xint_c_}% \def\XINT_trim:f:csv_finish-% \expandafter\XINT_trim:f:csv_loop\the\numexpr-#1\XINT_trim:f:csv_loop_trimnine {% @@ -17481,7 +17722,7 @@ $1$ or $-1$. \long\expandafter\def\csname XINT_trim:f:csv_finish8\endcsname #1,{ }% \expandafter\let\csname XINT_trim:f:csv_finish9\endcsname\space -\long\def\XINT_trim:f:csv_pos_done #1\xint_relax #2\xint_bye{#1}% +\long\def\XINT_trim:f:csv_pos_done #1\xint:#2\xint_bye{#1}% % \end{macrocode} % \subsubsection{\csh{xintNthEltPy:f:csv}} % \lverb|Counts like Python starting at zero. Last refactored with 1.2j. @@ -17505,8 +17746,8 @@ $1$ or $-1$. {% \expandafter\XINT_nthelt:f:csv_neg_fork \the\numexpr\XINT_length:f:csv_a - #2\xint_relax,\xint_relax,\xint_relax,\xint_relax,% - \xint_relax,\xint_relax,\xint_relax,\xint_relax,\xint_relax,% + #2\xint:,\xint:,\xint:,\xint:,% + \xint:,\xint:,\xint:,\xint:,\xint:,% \xint_c_ix,\xint_c_viii,\xint_c_vii,\xint_c_vi,% \xint_c_v,\xint_c_iv,\xint_c_iii,\xint_c_ii,\xint_c_i,\xint_bye -#1.#2,\xint_bye @@ -17524,23 +17765,23 @@ $1$ or $-1$. \expandafter\XINT_nthelt:f:csv_pos_done \romannumeral0% \expandafter\XINT_trim:f:csv_loop\the\numexpr#1-\xint_c_ix.% - #2\xint_relax,\xint_relax,\xint_relax,\xint_relax,\xint_relax,% - \xint_relax,\xint_relax,\xint_relax,\xint_relax,\xint_relax,\xint_bye + #2\xint:,\xint:,\xint:,\xint:,\xint:,% + \xint:,\xint:,\xint:,\xint:,\xint:,\xint_bye }% \def\XINT_nthelt:f:csv_pos_done #1{% \long\def\XINT_nthelt:f:csv_pos_done ##1,##2\xint_bye{% - \xint_gob_til_xint_relax##1\XINT_nthelt:f:csv_pos_cleanup\xint_relax#1##1}% + \xint_gob_til_xint:##1\XINT_nthelt:f:csv_pos_cleanup\xint:#1##1}% }\XINT_nthelt:f:csv_pos_done{ }% % \end{macrocode} % \lverb|This strange thing is in case the picked item was the last one, hence -% there was an ending \xint_relax (we could not put a comma earlier for +% there was an ending \xint: (we could not put a comma earlier for % matters of not confusing empty list with a singleton list), and we do this % here to activate brace-stripping of item as all other items may be % brace-stripped if picked. This is done for coherence. Of course, in the % context of the xintexpr.sty parsers, there are no braces in list items...| % \begin{macrocode} -\xint_firstofone{\long\def\XINT_nthelt:f:csv_pos_cleanup\xint_relax} % - #1\xint_relax{ #1}% +\xint_firstofone{\long\def\XINT_nthelt:f:csv_pos_cleanup\xint:} % + #1\xint:{ #1}% % \end{macrocode} % \subsubsection{\csh{xintReverse:f:csv}} % \lverb|1.2g. Contrarily to \xintReverseOrder from xintkernel.sty, this @@ -17552,23 +17793,23 @@ $1$ or $-1$. {% \expandafter\XINT_reverse:f:csv_loop \expandafter{\expandafter}\romannumeral`&&@#1,% - \xint_relax,% + \xint:,% \xint_bye,\xint_bye,\xint_bye,\xint_bye,% \xint_bye,\xint_bye,\xint_bye,\xint_bye,% - \xint_relax + \xint: }% \long\def\XINT_reverse:f:csv_loop #1#2,#3,#4,#5,#6,#7,#8,#9,% {% \xint_bye #9\XINT_reverse:f:csv_cleanup\xint_bye \XINT_reverse:f:csv_loop {,#9,#8,#7,#6,#5,#4,#3,#2#1}% }% -\long\def\XINT_reverse:f:csv_cleanup\xint_bye\XINT_reverse:f:csv_loop #1#2\xint_relax +\long\def\XINT_reverse:f:csv_cleanup\xint_bye\XINT_reverse:f:csv_loop #1#2\xint: {% \XINT_reverse:f:csv_finish #1% }% -\long\def\XINT_reverse:f:csv_finish #1\xint_relax,{ }% +\long\def\XINT_reverse:f:csv_finish #1\xint:,{ }% % \end{macrocode} -% \subsection{\csh{xintFirstItem:f:csv}} +% \subsubsection{\csh{xintFirstItem:f:csv}} % \lverb|Added with 1.2k for use by first() in % \xintexpr-essions, and some amount of compatibility with \xintNewExpr.| % \begin{macrocode} @@ -17579,7 +17820,7 @@ $1$ or $-1$. }% \long\def\XINT_first:f:csv_a #1,#2\xint_bye{ #1}% % \end{macrocode} -% \subsection{\csh{xintLastItem:f:csv}} +% \subsubsection{\csh{xintLastItem:f:csv}} % \lverb|Added with 1.2k, based on and sharing code with xintkernel's % \xintLastItem from 1.2i. Output empty if input empty. f-expands its argument % (hence first item, if not protected.) For use by last() in @@ -17590,15 +17831,15 @@ $1$ or $-1$. {% \expandafter\XINT_last:f:csv_loop\expandafter{\expandafter}\expandafter.% \romannumeral`&&@#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 + \xint:\XINT_last_loop_enda,\xint:\XINT_last_loop_endb,% + \xint:\XINT_last_loop_endc,\xint:\XINT_last_loop_endd,% + \xint:\XINT_last_loop_ende,\xint:\XINT_last_loop_endf,% + \xint:\XINT_last_loop_endg,\xint:\XINT_last_loop_endh,\xint_bye }% \long\def\XINT_last:f:csv_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_gob_til_xint: #9% + {#8}{#7}{#6}{#5}{#4}{#3}{#2}{#1}\xint: \XINT_last:f:csv_loop {#9}.% }% % \end{macrocode} @@ -17633,23 +17874,15 @@ $1$ or $-1$. % % \localtableofcontents % -% Got split off from \xintnameimp with release |1.1|, which also added -% the new macro |\xintiiDivRound|. +% Got split off from \xintnameimp with release |1.1|. % -% \begin{framed} % The core arithmetic routines have been entirely rewritten for release -% |1.2|. +% |1.2|. The |1.2i| and |1.2l| brought again some improvements. % % The commenting continues (\xintdocdate) to be very sparse: actually it got % worse than ever with release |1.2|. I will possibly add comments at a % later date, but for the time being the new routines are not commented at % all. -% \end{framed} -% -% Also, starting with |1.2|, |\xintAdd| etc... are defined only via -% \xintfracnameimp. Only |\xintiAdd| and |\xintiiAdd| (etc...) are provided -% via \xintcorenameimp. -% % % \subsection{Catcodes, \protect\eTeX{} and reload detection} % @@ -17708,7 +17941,143 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xintcore}% - [2017/01/06 1.2k Expandable arithmetic on big integers (JFB)]% + [2017/07/26 1.2l Expandable arithmetic on big integers (JFB)]% +% \end{macrocode} +% \subsection{(WIP!) Error conditions and exceptions} +% \lverb|As per the Mike Cowlishaw/IBM's General Decimal Arithmetic Specification +% +% http://speleotrove.com/decimal/decarith.html +% +% and the Python3 implementation in its Decimal module. +% +% Clamped, ConversionSyntax, DivisionByZero, DivisionImpossible, +% DivisionUndefined, Inexact, InsufficientStorage, InvalidContext, +% InvalidOperation, Overflow, Inexact, Rounded, Subnormal, +% Underflow. +% +% X3.274 rajoute LostDigits +% +% Python rajoute FloatOperation (et n'inclut pas InsufficientStorage) +% +% quote de decarith.pdf: +% The Clamped, Inexact, Rounded, and Subnormal conditions can coincide with +% each other or with other conditions. In these cases then any trap enabled +% for another condition takes precedence over (is handled before) all of +% these, any Subnormal trap takes precedence over Inexact, any Inexact trap +% takes precedence over Rounded, and any Rounded trap takes precedence over +% Clamped. +% +% WORK IN PROGRESS ! (1.2l, 2017/07/26) +% +% I follow the Python terminology: a trapped signal means it raises an +% exception which for us means an expandable error message with some possible +% user interaction. In this WIP +% state, the interaction is commented out. A non-trapped signal or condition +% would activate a (presumably silent) handler. +% +% Here, no signal-raising condition is "ignored" and all are "trapped" which +% means that error handlers are never activated, thus left in garbage state in +% the code. +% +% Various conditions can raise the same signal. +% +% Only signals, not conditions, raise Flags. +% +% If a signal is ignored it does not raise a Flag, but it activates the signal +% handler (by default now no signal is ignored.) +% +% If a signal is not ignored it raises a Flag and then if it is not trapped it +% activates the handler of the _condition_. +% +% If trapped (which is default now) an «exception» is raised, which means an +% expandable error message (I copied over the LaTeX3 code for expandable error +% messages, basically) +% interrupts the TeX run. In future, user input could +% be solicited, but currently this is commented out. +% +% For now macros to reset flags are done but without public interface nor +% documentation. +% +% Only four conditions are currently possibly encountered: +%- InvalidOperation +%- DivisionByZero +%- DivisionUndefined (which signals InvalidOperation) +%- Underflow +% +% I did it quickly, anyhow this will become more palpable when some of the +% Decimal Specification is actually implemented. The plan is to first do the +% X3.274 norm, then more complete implementation will follow... perhaps... +% | +% \begin{macrocode} +\csname XINT_Clamped_istrapped\endcsname +\csname XINT_ConversionSyntax_istrapped\endcsname +\csname XINT_DivisionByZero_istrapped\endcsname +\csname XINT_DivisionImpossible_istrapped\endcsname +\csname XINT_DivisionUndefined_istrapped\endcsname +\csname XINT_InvalidOperation_istrapped\endcsname +\csname XINT_Overflow_istrapped\endcsname +\csname XINT_Underflow_istrapped\endcsname +\catcode`- 11 +\def\XINT_ConversionSyntax-signal {{InvalidOperation}}% +\let\XINT_DivisionImpossible-signal\XINT_ConversionSyntax-signal +\let\XINT_DivisionUndefined-signal \XINT_ConversionSyntax-signal +\let\XINT_InvalidContext-signal \XINT_ConversionSyntax-signal +\catcode`- 12 +\def\XINT_signalcondition #1{\expandafter\XINT_signalcondition_a + \romannumeral0\ifcsname XINT_#1-signal\endcsname + \xint_dothis{\csname XINT_#1-signal\endcsname}% + \fi\xint_orthat{{#1}}{#1}}% +\def\XINT_signalcondition_a #1#2#3#4#5{% copied over from Python Decimal module +% #1=signal, #2=condition, #3=explanation for user, +% #4=context for error handlers, #5=used + \ifcsname XINT_#1_isignoredflag\endcsname + \xint_dothis{\csname XINT_#1.handler\endcsname {#4}}% + \fi + \expandafter\xint_gobble_i\csname XINT_#1Flag_ON\endcsname + \unless\ifcsname XINT_#1_istrapped\endcsname + \xint_dothis{\csname XINT_#2.handler\endcsname {#4}}% + \fi + \xint_orthat{% + % the flag raised is named after the signal #1, but we show condition #2 + \XINT_expandableerror{#2 (hit <RET> thrice)}% + \XINT_expandableerror{#3}% + \XINT_expandableerror{next: #5}% + % not for X3.274 + %\XINT_expandableerror{<RET>, or I\xintUse{...}<RET>, or I\xintCTRLC<RET>}% + \xint_firstofone_thenstop{#5}% + }% +}% +%% \let\xintUse\xint_firstofthree_thenstop % defined in xint.sty +\def\XINT_ifFlagRaised #1{% + \ifcsname XINT_#1Flag_ON\endcsname + \expandafter\xint_firstoftwo + \else + \expandafter\xint_secondoftwo + \fi}% +\def\XINT_resetFlag #1% + {\expandafter\let\csname XINT_#1Flag_ON\endcsname\XINT_undefined}% +\def\XINT_resetFlags {% WIP + \XINT_resetFlag{InvalidOperation}% also from DivisionUndefined + \XINT_resetFlag{DivisionByZero}% + \XINT_resetFlag{Underflow}% (\xintiiPow with negative exponent) + \XINT_resetFlag{Overflow}% not encountered so far in xint code 1.2l + % .. others .. +}% +%% NOT IMPLEMENTED! WORK IN PROGRESS! (ALL SIGNALS TRAPPED, NO HANDLERS USED) +\catcode`. 11 +\let\XINT_Clamped.handler\xint_firstofone % WIP +\def\XINT_InvalidOperation.handler#1{_NaN}% WIP +\def\XINT_ConversionSyntax.handler#1{_NaN}% WIP +\def\XINT_DivisionByZero.handler#1{_SignedInfinity(#1)}% WIP +\def\XINT_DivisionImpossible.handler#1{_NaN}% WIP +\def\XINT_DivisionUndefined.handler#1{_NaN}% WIP +\let\XINT_Inexact.handler\xint_firstofone % WIP +\def\XINT_InvalidContext.handler#1{_NaN}% WIP +\let\XINT_Rounded.handler\xint_firstofone % WIP +\let\XINT_Subnormal.handler\xint_firstofone% WIP +\def\XINT_Overflow.handler#1{_NaN}% WIP +\def\XINT_Underflow.handler#1{_NaN}% WIP +\catcode`. 12 % \end{macrocode} % \subsection{Counts for holding needed constants} % \begin{macrocode} @@ -17719,384 +18088,109 @@ $1$ or $-1$. \newcount\xint_c_x^viii_mone \xint_c_x^viii_mone 99999999 \newcount\xint_c_xii_e_viii \xint_c_xii_e_viii 1200000000 \newcount\xint_c_xi_e_viii_mone \xint_c_xi_e_viii_mone 1099999999 -\newcount\xint_c_xii_e_viii_mone\xint_c_xii_e_viii_mone 1199999999 % \end{macrocode} % \subsection{\csh{xintNum}} % \lverb|& -% For example \xintNum {----+-+++---+----000000000000003}$\ -% | -% \begin{macrocode} -\def\xintiNum {\romannumeral0\xintinum }% -\def\xintinum #1% -{% - \expandafter\XINT_num_loop - \romannumeral`&&@#1\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\Z -}% -\let\xintNum\xintiNum \let\xintnum\xintinum -\def\XINT_num #1% -{% - \XINT_num_loop #1\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\Z -}% -\def\XINT_num_loop #1#2#3#4#5#6#7#8% -{% - \xint_gob_til_xint_relax #8\XINT_num_end\xint_relax - \XINT_num_NumEight #1#2#3#4#5#6#7#8% -}% -\edef\XINT_num_end\xint_relax\XINT_num_NumEight #1\xint_relax #2\Z -{% - \noexpand\expandafter\space\noexpand\the\numexpr #1+\xint_c_\relax -}% -\def\XINT_num_NumEight #1#2#3#4#5#6#7#8% -{% - \ifnum \numexpr #1#2#3#4#5#6#7#8+\xint_c_= \xint_c_ - \xint_afterfi {\expandafter\XINT_num_keepsign_a - \the\numexpr #1#2#3#4#5#6#7#81\relax}% - \else - \xint_afterfi {\expandafter\XINT_num_finish - \the\numexpr #1#2#3#4#5#6#7#8\relax}% - \fi -}% -\def\XINT_num_keepsign_a #1% -{% - \xint_gob_til_one#1\XINT_num_gobacktoloop 1\XINT_num_keepsign_b -}% -\def\XINT_num_gobacktoloop 1\XINT_num_keepsign_b {\XINT_num_loop }% -\def\XINT_num_keepsign_b #1{\XINT_num_loop -}% -\def\XINT_num_finish #1\xint_relax #2\Z { #1}% -% \end{macrocode} -% \subsection{Zeroes} -% \lverb|Everything had to be changed for 1.2 as it does computations by -% blocks of eight digits rather than four. +% For example \xintNum {----+-+++---+----000000000000003} % -% Currently many macros are launched by a \romannumeral0. Perhaps I should -% have used \romannumeral and end expansion by \z@ (\xint_c_). +% Very old routine got completely rewritten for 1.2l. % -% \XINT_cuz_small removes leading zeroes from the first eight digits. Supposed -% to have been launched by a \romannumeral0. At least one digit is produced.| -% \begin{macrocode} -\edef\XINT_cuz_small #1#2#3#4#5#6#7#8% -{% - \noexpand\expandafter\space\noexpand\the\numexpr #1#2#3#4#5#6#7#8\relax -}% -% \end{macrocode} -% \lverb|This iterately removes all leading zeroes from a sequence of 8N -% digits ended by \R. +% New code uses \numexpr governed expansion and fixes some issues of former +% version particularly regarding inputs of the \numexpr...\relax type without +% \the or \number prefix, and/or possibly no terminating \relax. % -% Note 2015/11/28: with only four digits the gob_til_fourzeroes had proved -% in some old testing faster than \ifnum test. But with eight digits, the -% execution times are much closer, as I tested only now. Thus, one could as -% well use \ifnum test here. Besides the tests were not exactly for a -% situation like here where \XINT_cuz_z has two 00000000 blocks to grab.| -% \begin{macrocode} -\def\XINT_cuz #1#2#3#4#5#6#7#8#9% -{% - \xint_gob_til_R #9\XINT_cuz_e \R - \xint_gob_til_eightzeroes #1#2#3#4#5#6#7#8\XINT_cuz_z 00000000% - \XINT_cuz_done #1#2#3#4#5#6#7#8#9% -}% -\def\XINT_cuz_z 00000000\XINT_cuz_done 00000000{\XINT_cuz }% -\edef\XINT_cuz_done #1#2#3#4#5#6#7#8#9\R - {\noexpand\expandafter\space\noexpand\the\numexpr #1#2#3#4#5#6#7#8\relax #9}% -\edef\XINT_cuz_e\R #1\XINT_cuz_done #2\R - {\noexpand\expandafter\space\noexpand\the\numexpr #2\relax }% -% \end{macrocode} -% \lverb|This removes eight by eight leading zeroes from a sequence of 8N digits -% ended by \R. Thus, we still have 8N digits on output.| -% \begin{macrocode} -\def\XINT_cuz_byviii #1#2#3#4#5#6#7#8#9% -{% - \xint_gob_til_R #9\XINT_cuz_byviii_e \R - \xint_gob_til_eightzeroes #1#2#3#4#5#6#7#8\XINT_cuz_byviii_z 00000000% - \XINT_cuz_byviii_done #1#2#3#4#5#6#7#8#9% -}% -\def\XINT_cuz_byviii_z 00000000\XINT_cuz_byviii_done 00000000{\XINT_cuz_byviii}% -\def\XINT_cuz_byviii_done #1\R { #1}% -\def\XINT_cuz_byviii_e\R #1\XINT_cuz_byviii_done #2\R{ #2}% -% \end{macrocode} -% \subsection{Blocks of eight digits} -% \lverb|Lingua of release 1.2. +% \xintiNum{\numexpr 1}\foo in earlier versions caused premature expansion of +% \foo. % -% \romannumeral0\XINT_zeroes_forviii #1\R\R\R\R\R\R\R\R{10}0000001\W$newline -% produces a string of k 0's such that k+length(#1) is smallest bigger multiple -% of eight.| -% \begin{macrocode} -\def\XINT_zeroes_forviii #1#2#3#4#5#6#7#8% -{% - \xint_gob_til_R #8\XINT_zeroes_forviii_end\R\XINT_zeroes_forviii -}% -\edef\XINT_zeroes_forviii_end\R\XINT_zeroes_forviii #1#2#3#4#5#6#7#8#9\W -{% - \noexpand\expandafter\space\noexpand\xint_gob_til_one #2#3#4#5#6#7#8% -}% -% \end{macrocode} -% \lverb|This is used as$bgroup$obeyspaces$obeylines -% \the\numexpr1\XINT_rsepbyviii <8Ndigits>$% -% \XINT_rsepbyviii_end_A 2345678$% -% \XINT_rsepbyviii_end_B 2345678\relax UV$egroup -% -% $noindent -% and will produce 1<8digits>!1<8digits>.1<8digits>!... where the original -% digits are organized by eight, and the order inside successive pairs of -% blocks separated by ! has been reversed. The output ends with a final 1U. or -% 1V. The former happens when we had an even number of eight blocks, the -% latter an odd number: 1<8d>!1<8d>.1U. or 1<8d>!1<8d>.1<8d>.1V.| -% \begin{macrocode} -\def\XINT_rsepbyviii #1#2#3#4#5#6#7#8% -{% - \XINT_rsepbyviii_b {#1#2#3#4#5#6#7#8}% -}% -\def\XINT_rsepbyviii_b #1#2#3#4#5#6#7#8#9% -{% - #2#3#4#5#6#7#8#9\expandafter!\the\numexpr - 1#1\expandafter.\the\numexpr 1\XINT_rsepbyviii -}% -\def\XINT_rsepbyviii_end_B #1\relax #2#3{#2.}% -\def\XINT_rsepbyviii_end_A #11#2\expandafter #3\relax #4#5{#2.1#5.}% -% \end{macrocode} -% \lverb|This is used typically as$bgroup$obeyspaces$obeylines -% \romannumeral0\expandafter\XINT_sepandrev <8Ndigits>$% -% \XINT_rsepbyviii_end_A 2345678$% -% \XINT_rsepbyviii_end_B 2345678\relax UV\R.\R.\R.\R.\R.\R.\R.\R.\W$egroup +% \xintiNum{\the\numexpr 1} was ok, but a bit luckily so. % -% $noindent -% and will produce 1<8digits>!1<8digits>!1<8digits>!... where the blocks have -% been globally reversed. The UV here are only place holders to share same -% syntax as \XINT_sepandrev_andcount, they are gobbled (#2 in -% \XINT_sepandrev_done).| -% \begin{macrocode} -\def\XINT_sepandrev -{% - \expandafter\XINT_sepandrev_a\the\numexpr 1\XINT_rsepbyviii -}% -\def\XINT_sepandrev_a {\XINT_sepandrev_b {}}% -\def\XINT_sepandrev_b #1#2.#3.#4.#5.#6.#7.#8.#9.% -{% - \xint_gob_til_R #9\XINT_sepandrev_end\R - \XINT_sepandrev_b {#9!#8!#7!#6!#5!#4!#3!#2!#1}% -}% -\def\XINT_sepandrev_end\R\XINT_sepandrev_b #1#2\W {\XINT_sepandrev_done #1}% -\def\XINT_sepandrev_done #11#2!{ }% -% \end{macrocode} -% \lverb|This is used typically as$bgroup$obeyspaces$obeylines -% \romannumeral0\expandafter\XINT_sepandrev_andcount -% \the\numexpr1\XINT_rsepbyviii <8Ndigits>$% -% \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$egroup -% -% $noindent -% and will produce <length>.1<8digits>!1<8digits>!1<8digits>!... where the -% blocks have been globally reversed and <length> is the number of blocks.| +% Also, up to 1.2k inclusive, the macro fetched tokens eight by eight, and not +% nine by nine as is done now. I have no idea why. +% | % \begin{macrocode} -\def\XINT_sepandrev_andcount +\def\xintiNum {\romannumeral0\xintinum }% +\def\xintinum #1% {% - \expandafter\XINT_sepandrev_andcount_a\the\numexpr 1\XINT_rsepbyviii + \expandafter\XINT_num_cleanup\the\numexpr\expandafter\XINT_num_loop + \romannumeral`&&@#1\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z }% -\def\XINT_sepandrev_andcount_a {\XINT_sepandrev_andcount_b 0.{}}% -\def\XINT_sepandrev_andcount_b #1.#2#3.#4.#5.#6.#7.#8.#9.% +\let\xintNum\xintiNum \let\xintnum\xintinum +\def\XINT_num #1% {% - \xint_gob_til_R #9\XINT_sepandrev_andcount_end\R - \expandafter\XINT_sepandrev_andcount_b \the\numexpr #1+\xint_c_xiv.% - {#9!#8!#7!#6!#5!#4!#3!#2}% + \expandafter\XINT_num_cleanup\the\numexpr\XINT_num_loop + #1\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z }% -\def\XINT_sepandrev_andcount_end\R - \expandafter\XINT_sepandrev_andcount_b\the\numexpr #1+\xint_c_xiv.#2#3#4\W -{\expandafter\XINT_sepandrev_andcount_done\the\numexpr \xint_c_ii*#3+#1.#2}% -\edef\XINT_sepandrev_andcount_done #1.#21#3!% - {\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 -% -% 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 -% subtraction during \XINT_sub_out, in particular.| -% \begin{macrocode} -\def\XINT_unrevbyviii #11#2!1#3!1#4!1#5!1#6!1#7!1#8!1#9!% +\def\XINT_num_loop #1#2#3#4#5#6#7#8#9% {% - \xint_gob_til_R #9\XINT_unrevbyviii_a\R - \XINT_unrevbyviii {#9#8#7#6#5#4#3#2#1}% -}% -\edef\XINT_unrevbyviii_a\R\XINT_unrevbyviii #1#2\W - {\noexpand\expandafter\space - \noexpand\romannumeral`&&@\noexpand\xint_gob_til_Z #1}% + \xint_gob_til_xint: #9\XINT_num_end\xint: + #1#2#3#4#5#6#7#8#9% + \ifnum \numexpr #1#2#3#4#5#6#7#8#9+\xint_c_ = \xint_c_ % \end{macrocode} -% \lverb|Can work with shorter ending pattern: 1\Z!1\R!1\R!1\R!1\R!1\R!1\R!\W -% but the longer one of unrevbyviii is ok here too. Used currently (1.2) only -% by addition, now (1.2c) with long ending pattern. Does the final clean up of -% leading zeroes contrarily to general \XINT_unrevbyviii.| +% \lverb|& +% means that so far only signs encountered, (if syntax is legal) then possibly +% zeroes +% or a terminated or not terminated \numexpr evaluating to zero +% In that latter case a correct zero will be produced in the end. +% | % \begin{macrocode} -\def\XINT_smallunrevbyviii 1#1!1#2!1#3!1#4!1#5!1#6!1#7!1#8!#9\W% -{% - \expandafter\XINT_cuz_small\xint_gob_til_Z #8#7#6#5#4#3#2#1% -}% + \expandafter\XINT_num_loop + \else % \end{macrocode} -% \lverb|This is used as$bgroup$obeyspaces$obeylines -% \the\numexpr\XINT_sepbyviii_andcount <8Ndigits>$% -% \XINT_sepbyviii_end 2345678\relax -% \xint_c_vii!\xint_c_vi!\xint_c_v!\xint_c_iv!% -% \xint_c_iii!\xint_c_ii!\xint_c_i!\xint_c_\W $egroup -% -% $noindent -% It will produce 1<8d>!1<8d>!....1<8d>!1.<count of blocks>. Used by -% \XINT_div_prepare_g for \XINT_div_prepare_h.| +% \lverb|& +% non terminated \numexpr (with nine tokens total) are +% safe as after \fi, there is then \xint: +% | % \begin{macrocode} -\def\XINT_sepbyviii_andcount -{% - \expandafter\XINT_sepbyviii_andcount_a\the\numexpr\XINT_sepbyviii -}% -\def\XINT_sepbyviii #1#2#3#4#5#6#7#8% -{% - 1#1#2#3#4#5#6#7#8\expandafter!\the\numexpr\XINT_sepbyviii -}% -\def\XINT_sepbyviii_end #1\relax {\relax\XINT_sepbyviii_andcount_end!}% -\def\XINT_sepbyviii_andcount_a {\XINT_sepbyviii_andcount_b \xint_c_.}% -\def\XINT_sepbyviii_andcount_b #1.#2!#3!#4!#5!#6!#7!#8!#9!% -{% - #2\expandafter!\the\numexpr#3\expandafter!\the\numexpr#4\expandafter - !\the\numexpr#5\expandafter!\the\numexpr#6\expandafter!\the\numexpr - #7\expandafter!\the\numexpr#8\expandafter!\the\numexpr#9\expandafter!\the\numexpr - \expandafter\XINT_sepbyviii_andcount_b\the\numexpr #1+\xint_c_viii.% + \expandafter\relax + \fi }% -\def\XINT_sepbyviii_andcount_end #1\XINT_sepbyviii_andcount_b\the\numexpr - #2+\xint_c_viii.#3#4\W {\expandafter.\the\numexpr #2+#3.}% +\def\XINT_num_end\xint:#1\xint:{#1+\xint_c_\xint:}% empty input ok +\def\XINT_num_cleanup #1\xint:#2\Z { #1}% % \end{macrocode} -% \lverb|This is used as$newline -% \romannumeral0\XINT_rev_nounsep {}<blocks 1<8d>!>\R!\R!\R!\R!\R!\R!\R!\R!\W +% \subsection*{Routines handling integers as lists of token digits} +% \addcontentsline{toc}{subsection}{Routines handling integers as lists of token digits} +% \lverb|& +% Routines handling big integers which are lists of digit tokens with no +% special additional structure. The argument is only subjected to a +% \romannumeral`^^@ expansion when macros have "ii" in their names. % -% It reverses the blocks, keeping the 1's and ! separators. Used multiple -% 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!% -{% - \xint_gob_til_R #9\XINT_rev_nounsep_end\R - \XINT_rev_nounsep {#9!#8!#7!#6!#5!#4!#3!#2!#1}% -}% -\def\XINT_rev_nounsep_end\R\XINT_rev_nounsep #1#2\W {\XINT_rev_nounsep_done #1}% -\def\XINT_rev_nounsep_done #11{ 1}% -% \end{macrocode} -% \lverb|This is used as$newline -% \the\numexpr\XINT_sepbyviii_Z <8Ndigits>\XINT_sepbyviii_Z_end 2345678\relax +% Some +% routines do not accept non properly terminated inputs like "\the\numexpr1", +% or "\the\mathcode`\-", others do. % -% It produces 1<8d>!...1<8d>!1\Z!| -% \begin{macrocode} -\def\XINT_sepbyviii_Z #1#2#3#4#5#6#7#8% -{% - 1#1#2#3#4#5#6#7#8\expandafter!\the\numexpr\XINT_sepbyviii_Z -}% -\def\XINT_sepbyviii_Z_end #1\relax {\relax\Z!}% -% \end{macrocode} -% \lverb|This is used as$newline -% \romannumeral0\XINT_unsep_cuzsmall {}<blocks of 1<8d>!>1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W +% These routines or their sub-routines are mainly for internal usage. +% | % -% En fait le {} est optionnel, s'il est absent le premier #1 sera vide, tout -% simplement. It removes the 1's and !'s, and removes the leading zeroes *of -% the first block*. This could have been done with \numexpr and a \cleanup but -% would have restricted due to maximal expansion depth. Probably there where -% already O(N^2) macros, thus I decided that this one would be too.| -% \begin{macrocode} -\def\XINT_unsep_cuzsmall #11#2!1#3!1#4!1#5!1#6!1#7!1#8!1#9!% -{% - \xint_gob_til_R #9\XINT_unsep_cuzsmall_end\R - \XINT_unsep_cuzsmall {#1#2#3#4#5#6#7#8#9}% -}% -\def\XINT_unsep_cuzsmall_end\R - \XINT_unsep_cuzsmall #1{\XINT_unsep_cuzsmall_done #1}% -\def\XINT_unsep_cuzsmall_done #1\R #2\W{\XINT_cuz_small #1}% -\def\XINT_unsep_delim {1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W}% -% \end{macrocode} -% \lverb|This is used by division to remove separators from the produced -% quotient. The quotient is produced in the correct order. The routine will -% also remove leading zeroes. An extra intial block of 8 zeroes is possible -% and thus if present must be removed. Then the next eight digits must be -% cleaned of leading zeroes.| -% \begin{macrocode} -\def\XINT_div_unsepQ #11#2!1#3!1#4!1#5!1#6!1#7!1#8!1#9!% -{% - \xint_gob_til_R #9\XINT_div_unsepQ_end\R - \XINT_div_unsepQ {#1#2#3#4#5#6#7#8#9}% -}% -\def\XINT_div_unsepQ_end\R\XINT_div_unsepQ #1{\XINT_div_unsepQ_x #1}% -\def\XINT_div_unsepQ_x #1#2#3#4#5#6#7#8#9% -{% - \xint_gob_til_R #9\XINT_div_unsepQ_e \R - \xint_gob_til_eightzeroes #1#2#3#4#5#6#7#8\XINT_div_unsepQ_y 00000000% - \expandafter\XINT_div_unsepQ_done \the\numexpr #1#2#3#4#5#6#7#8.#9% -}% -\def\XINT_div_unsepQ_e\R\xint_gob_til_eightzeroes #1\XINT_div_unsepQ_y #2\W - {\the\numexpr #1\relax \Z}% -\def\XINT_div_unsepQ_y #1.#2\R #3\W{\XINT_cuz_small #2\Z}% -\def\XINT_div_unsepQ_done #1.#2\R #3\W { #1#2\Z}% -% \end{macrocode} -% \lverb|This is used by division to remove separators from the produced -% remainder. The remainder is here in correct order. It must be cleaned of -% leading zeroes, possibly all the way. Terminator was -% 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W| -% \begin{macrocode} -\def\XINT_div_unsepR #11#2!1#3!1#4!1#5!1#6!1#7!1#8!1#9!% -{% - \xint_gob_til_R #9\XINT_div_unsepR_end\R - \XINT_div_unsepR {#1#2#3#4#5#6#7#8#9}% -}% -\def\XINT_div_unsepR_end\R\XINT_div_unsepR #1{\XINT_div_unsepR_done #1}% -\def\XINT_div_unsepR_done #1\R #2\W {\XINT_cuz #1\R}% -% \end{macrocode} -% \subsection{\csh{xintReverseDigits}} -% \lverb|1.2.| +% \subsection{\csh{XINT_cuz_small}} +% \lverb|& +% \XINT_cuz_small removes leading zeroes from the first eight digits. Expands +% following \romannumeral0. At least one digit is produced.| % \begin{macrocode} -\def\XINT_microrevsep #1#2#3#4#5#6#7#8% -{% - 1#8#7#6#5#4#3#2#1\expandafter!\the\numexpr\XINT_microrevsep -}% -\def\XINT_microrevsep_end #1\W #2\expandafter #3\Z{#2!}% -\def\xintReverseDigits {\romannumeral0\xintreversedigits }% -\def\xintreversedigits #1{\expandafter\XINT_reversedigits\romannumeral`&&@#1\Z}% -\def\XINT_reversedigits #1% -{% - \xint_UDsignfork - #1{\expandafter-\romannumeral0\XINT_reversedigits_a}% - -{\XINT_reversedigits_a #1}% - \krof -}% -\def\XINT_reversedigits_a #1\Z +\def\XINT_cuz_small#1{% +\def\XINT_cuz_small ##1##2##3##4##5##6##7##8% {% - \expandafter\XINT_revdigits_a\the\numexpr\expandafter\XINT_microrevsep - \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 -}% -\def\XINT_revdigits_a {\XINT_revdigits_b {}}% -\def\XINT_revdigits_b #11#2!1#3!1#4!1#5!1#6!1#7!1#8!1#9!% -{% - \xint_gob_til_R #9\XINT_revdigits_end\R - \XINT_revdigits_b {#9#8#7#6#5#4#3#2#1}% -}% -\edef\XINT_revdigits_end\R\XINT_revdigits_b #1#2\W - {\noexpand\expandafter\space\noexpand\xint_gob_til_Z #1}% + \expandafter#1\the\numexpr ##1##2##3##4##5##6##7##8\relax +}}\XINT_cuz_small{ }% % \end{macrocode} % \subsection{\csh{xintSgn}, \csh{xintiiSgn}, \csh{XINT_Sgn}, \csh{XINT_cntSgn}} % \lverb|& -% xintfrac.sty will overwrite \xintsgn with use of \xintraw rather than -% \xintnum, naturally. -%| +% xintfrac.sty will rewrite \xintSgn to let it accept general input as recognized by +% xintfrac.sty macros +% +% 1.2l: \xintiiSgn made robust against non terminated input. +% | % \begin{macrocode} \def\xintiiSgn {\romannumeral0\xintiisgn }% \def\xintiisgn #1% {% - \expandafter\XINT_sgn \romannumeral`&&@#1\Z% + \expandafter\XINT_sgn \romannumeral`&&@#1\xint: }% \def\xintSgn {\romannumeral0\xintsgn }% \def\xintsgn #1% {% - \expandafter\XINT_sgn \romannumeral0\xintnum{#1}\Z% + \expandafter\XINT_sgn \romannumeral0\xintnum{#1}\xint: }% -\def\XINT_sgn #1#2\Z +\def\XINT_sgn #1#2\xint: {% \xint_UDzerominusfork #1-{ 0}% @@ -18104,7 +18198,7 @@ $1$ or $-1$. 0-{ 1}% \krof }% -\def\XINT_Sgn #1#2\Z +\def\XINT_Sgn #1#2\xint: {% \xint_UDzerominusfork #1-{0}% @@ -18112,7 +18206,7 @@ $1$ or $-1$. 0-{1}% \krof }% -\def\XINT_cntSgn #1#2\Z +\def\XINT_cntSgn #1#2\xint: {% \xint_UDzerominusfork #1-\xint_c_ @@ -18122,6 +18216,9 @@ $1$ or $-1$. }% % \end{macrocode} % \subsection{\csh{xintiOpp}, \csh{xintiiOpp}} +% \lverb|Attention, \xintiiOpp non robust against non terminated inputs. +% Reason is I don't want to have to grab a delimiter at the end, as everything +% happens "upfront".| % \begin{macrocode} \def\xintiiOpp {\romannumeral0\xintiiopp }% \def\xintiiopp #1% @@ -18144,6 +18241,7 @@ $1$ or $-1$. }% % \end{macrocode} % \subsection{\csh{xintiAbs}, \csh{xintiiAbs}} +% \lverb|Attention \xintiiAbs non robust against non terminated input.| % \begin{macrocode} \def\xintiiAbs {\romannumeral0\xintiiabs }% \def\xintiiabs #1% @@ -18164,18 +18262,22 @@ $1$ or $-1$. }% % \end{macrocode} % \subsection{\csh{xintFDg}, \csh{xintiiFDg}} +% \lverb|& +% FIRST DIGIT. +% +% 1.2l: \xintiiFDg made robust against non terminated input.| % \begin{macrocode} \def\xintiiFDg {\romannumeral0\xintiifdg }% \def\xintiifdg #1% {% - \expandafter\XINT_fdg \romannumeral`&&@#1\W\Z + \expandafter\XINT_fdg \romannumeral`&&@#1\xint:\Z }% \def\xintFDg {\romannumeral0\xintfdg }% \def\xintfdg #1% {% - \expandafter\XINT_fdg \romannumeral0\xintnum{#1}\W\Z + \expandafter\XINT_fdg \romannumeral0\xintnum{#1}\xint:\Z }% -\def\XINT_FDg #1{\romannumeral0\XINT_fdg #1\W\Z }% +\def\XINT_FDg #1{\romannumeral0\XINT_fdg #1\xint:\Z }% \def\XINT_fdg #1#2#3\Z {% \xint_UDzerominusfork @@ -18187,8 +18289,12 @@ $1$ or $-1$. % \end{macrocode} % \subsection{\csh{xintLDg}, \csh{xintiiLDg}} % \lverb|& -% Rewritten for 1.2i (2016/12/10). Surprisingly perhaps, faster than -% \xintLastItem despite the \numexpr operations. +% LAST DIGIT. +% +% Rewritten for 1.2i (2016/12/10). Surprisingly perhaps, it is faster than +% \xintLastItem from xintkernel.sty despite the \numexpr operations. +% +% Attention \xintiiLDg non robust against non terminated input. % | % \begin{macrocode} \def\xintLDg {\romannumeral0\xintldg }% @@ -18204,21 +18310,20 @@ $1$ or $-1$. -{\XINT_ldg#1}% \krof }% -\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 #1{% +\def\XINT_ldg ##1##2##3##4##5##6##7##8##9% + {\expandafter#1% + \the\numexpr##9##8##7##6##5##4##3##2##1*\xint_c_+\XINT_ldg_a##9}% +}\XINT_ldg{ }% \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...)! oh no... 1.2i simply forgot to handle negative numbers... and I -% made no testing. In fact I didn't remember if the macro was for non-negative -% input only. Looking at earlier code, no, it did handle negative inputs too. -% 1.2k has a regression test suite, which caught that.| +% \lverb|Attention \xintDouble non robust against non terminated input.| % \begin{macrocode} \def\xintDouble {\romannumeral0\xintdouble}% \def\xintdouble #1{\expandafter\XINT_dbl_fork\romannumeral`&&@#1% @@ -18231,14 +18336,16 @@ $1$ or $-1$. \krof #1% }% \def\XINT_dbl_neg-{\expandafter-\romannumeral0\XINT_dbl}% -\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 #1{% +\def\XINT_dbl ##1##2##3##4##5##6##7##8% + {\expandafter#1\the\numexpr##1##2##3##4##5##6##7##8\XINT_dbl_a}% +}\XINT_dbl{ }% \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.| +% \lverb|Attention \xintHalf non robust against non terminated input.| % \begin{macrocode} \def\xintHalf {\romannumeral0\xinthalf}% \def\xinthalf #1{\expandafter\XINT_half_fork\romannumeral`&&@#1% @@ -18252,20 +18359,22 @@ $1$ or $-1$. \krof #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 #1{% +\def\XINT_half ##1##2##3##4##5##6##7##8% + {\expandafter#1\the\numexpr(##1##2##3##4##5##6##7##8\XINT_half_a}% +}\XINT_half{ }% \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{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). +% \lverb|1.2i much delayed complete rewrite in 1.2 style. % % 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.| +% than 9 times 2500 = 22500 digits on input. +% +% Attention \xintInc non robust against non terminated input.| % \begin{macrocode} \def\xintInc {\romannumeral0\xintinc}% \def\xintinc #1{\expandafter\XINT_inc_fork\romannumeral`&&@#1% @@ -18279,15 +18388,19 @@ $1$ or $-1$. }% \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 #1{% +\def\XINT_inc ##1##2##3##4##5##6##7##8##9% + {\expandafter#1\the\numexpr##1##2##3##4##5##6##7##8##9\XINT_inc_a}% +}\XINT_inc{ }% \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.| +% bit more complicated than \xintInc because 2999999999 is too big for TeX. +% +% Attention \xintDec non robust against non terminated input.| % \begin{macrocode} \def\xintDec {\romannumeral0\xintdec}% \def\xintdec #1{\expandafter\XINT_dec_fork\romannumeral`&&@#1% @@ -18302,8 +18415,10 @@ $1$ or $-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 #1{% +\def\XINT_dec ##1##2##3##4##5##6##7##8##9% + {\expandafter#1\the\numexpr##1##2##3##4##5##6##7##8##9\XINT_dec_a}% +}\XINT_dec{ }% \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 @@ -18313,17 +18428,22 @@ $1$ or $-1$. % \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.| +% rewritten it long time ago. +% +% Attention \xintDSL non robust against non terminated input.| % \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#1{% +\def\XINT_dsl ##1{\xint_gob_til_zero ##1\xint_dsl_zero 0#1##1}% +}\XINT_dsl{ }% \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.| +% Limited to 22483 digits on input. +% +% Attention \xintDSR non robust against non terminated input.| % \begin{macrocode} \def\xintDSR{\romannumeral0\xintdsr}% \def\xintdsr #1{\expandafter\XINT_dsr_fork\romannumeral`&&@#1% @@ -18336,8 +18456,10 @@ $1$ or $-1$. \krof #1% }% \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 #1{% +\def\XINT_dsr ##1##2##3##4##5##6##7##8##9% + {\expandafter#1\the\numexpr(##1##2##3##4##5##6##7##8##9\XINT_dsr_a}% +}\XINT_dsr{ }% \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}% @@ -18347,7 +18469,10 @@ $1$ or $-1$. % \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!| +% This is about the first time I am happy that the division in \numexpr +% rounds! +% +% Attention \xintDSRr non robust against non terminated input.| % \begin{macrocode} \def\xintDSRr{\romannumeral0\xintdsrr}% \def\xintdsrr #1{\expandafter\XINT_dsrr_fork\romannumeral`&&@#1% @@ -18360,14 +18485,372 @@ $1$ or $-1$. \krof #1% }% \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 #1{% +\def\XINT_dsrr ##1##2##3##4##5##6##7##8##9% + {\expandafter#1\the\numexpr##1##2##3##4##5##6##7##8##9\XINT_dsrr_a}% +}\XINT_dsrr{ }% \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} +% \subsection*{Blocks of eight digits} +% \addcontentsline{toc}{subsection}{Blocks of eight digits} +% \lverb|The lingua of release 1.2.| +% +% \subsection{\csh{XINT_cuz}} +% \lverb|This (launched by \romannumeral0) iterately removes all leading +% zeroes from a sequence of 8N digits ended by \R. +% +% Rewritten for 1.2l, now uses \numexpr governed expansion and \ifnum test +% rather than delimited gobbling macros. +% +% Note 2015/11/28: with only four digits the gob_til_fourzeroes had proved +% in some old testing faster than \ifnum test. But with eight digits, the +% execution times are much closer, as I tested back then. +% | +% \begin{macrocode} +\def\XINT_cuz #1{% +\def\XINT_cuz {\expandafter#1\the\numexpr\XINT_cuz_loop}% +}\XINT_cuz{ }% +\def\XINT_cuz_loop #1#2#3#4#5#6#7#8#9% +{% + #1#2#3#4#5#6#7#8% + \xint_gob_til_R #9\XINT_cuz_hitend\R + \ifnum #1#2#3#4#5#6#7#8>\xint_c_ + \expandafter\XINT_cuz_cleantoend + \else\expandafter\XINT_cuz_loop + \fi #9% +}% +\def\XINT_cuz_hitend\R #1\R{\relax}% +\def\XINT_cuz_cleantoend #1\R{\relax #1}% +% \end{macrocode} +% \subsection{\csh{XINT_cuz_byviii}} +% \lverb|This removes eight by eight leading zeroes from a sequence of 8N digits +% ended by \R. Thus, we still have 8N digits on output. Expansion started by +% \romannumeral0 | +% \begin{macrocode} +\def\XINT_cuz_byviii #1#2#3#4#5#6#7#8#9% +{% + \xint_gob_til_R #9\XINT_cuz_byviii_e \R + \xint_gob_til_eightzeroes #1#2#3#4#5#6#7#8\XINT_cuz_byviii_z 00000000% + \XINT_cuz_byviii_done #1#2#3#4#5#6#7#8#9% +}% +\def\XINT_cuz_byviii_z 00000000\XINT_cuz_byviii_done 00000000{\XINT_cuz_byviii}% +\def\XINT_cuz_byviii_done #1\R { #1}% +\def\XINT_cuz_byviii_e\R #1\XINT_cuz_byviii_done #2\R{ #2}% +% \end{macrocode} +% \subsection{\csh{XINT_unsep_loop}} +% +% \lverb|This is used as +%( \the\numexpr0\XINT_unsep_loop (blocks of 1<8d>!)% +%: \xint_bye!2!3!4!5!6!7!8!9!\xint_bye\xint_c_i\relax +%) +% It removes the 1's and !'s, from the 8N digits and outputs them prefixed by +% a 0 token. +% +% Done at 1.2l for usage by other macros. The similar code in earlier releases +% was strangely in O(N^2) style, apparently to avoid some memory constraints. +% But these memory constraints related to \numexpr chaining seems to be in +% many places in xint code base. The 1.2l version is written in the 1.2i style +% of \xintInc etc... and is compatible with some 1! block without digits +% among the treated blocks, they will disappear.| +% \begin{macrocode} +\def\XINT_unsep_loop #1!#2!#3!#4!#5!#6!#7!#8!#9!% +{% + \expandafter\XINT_unsep_clean + \the\numexpr #1\expandafter\XINT_unsep_clean + \the\numexpr #2\expandafter\XINT_unsep_clean + \the\numexpr #3\expandafter\XINT_unsep_clean + \the\numexpr #4\expandafter\XINT_unsep_clean + \the\numexpr #5\expandafter\XINT_unsep_clean + \the\numexpr #6\expandafter\XINT_unsep_clean + \the\numexpr #7\expandafter\XINT_unsep_clean + \the\numexpr #8\expandafter\XINT_unsep_clean + \the\numexpr #9\XINT_unsep_loop +}% +\def\XINT_unsep_clean 1{\relax}% +% \end{macrocode} +% \subsection{\csh{XINT_unsep_cuzsmall}} +% +% \lverb|This is used as +%( \romannumeral0\XINT_unsep_cuzsmall (blocks of 1<8d>!)% +%: \xint_bye!2!3!4!5!6!7!8!9!\xint_bye\xint_c_i\relax +%) +% It removes the 1's and !'s, and removes the leading zeroes *of +% the first block*. +% +% Redone for 1.2l: the 1.2 variant was strangely in O(N^2) style.| +% \begin{macrocode} +\def\XINT_unsep_cuzsmall +{% + \expandafter\XINT_unsep_cuzsmall_x\the\numexpr0\XINT_unsep_loop +}% +\def\XINT_unsep_cuzsmall_x #1{% +\def\XINT_unsep_cuzsmall_x 0##1##2##3##4##5##6##7##8% +{% + \expandafter#1\the\numexpr ##1##2##3##4##5##6##7##8\relax +}}\XINT_unsep_cuzsmall_x{ }% +% \end{macrocode} +% \subsection{\csh{XINT_div_unsepQ}} +% +% \lverb|This is used by division to remove separators from the produced +% quotient. The quotient is produced in the correct order. The routine will +% also remove leading zeroes. An extra initial block of 8 zeroes is possible +% and thus if present must be removed. Then the next eight digits must be +% cleaned of leading zeroes. Attention that there might be a single +% block of 8 zeroes. Expansion launched by \romannumeral0. +% +% Rewritten for 1.2l in 1.2i style.| +% \begin{macrocode} +\def\XINT_div_unsepQ_delim {\xint_bye!2!3!4!5!6!7!8!9!\xint_bye\xint_c_i\relax\Z}% +\def\XINT_div_unsepQ +{% + \expandafter\XINT_div_unsepQ_x\the\numexpr0\XINT_unsep_loop +}% +\def\XINT_div_unsepQ_x #1{% +\def\XINT_div_unsepQ_x 0##1##2##3##4##5##6##7##8##9% +{% + \xint_gob_til_Z ##9\XINT_div_unsepQ_one\Z + \xint_gob_til_eightzeroes ##1##2##3##4##5##6##7##8\XINT_div_unsepQ_y 00000000% + \expandafter#1\the\numexpr ##1##2##3##4##5##6##7##8\relax ##9% +}}\XINT_div_unsepQ_x{ }% +\def\XINT_div_unsepQ_y #1{% +\def\XINT_div_unsepQ_y ##1\relax ##2##3##4##5##6##7##8##9% +{% + \expandafter#1\the\numexpr ##2##3##4##5##6##7##8##9\relax +}}\XINT_div_unsepQ_y{ }% +\def\XINT_div_unsepQ_one#1\expandafter{\expandafter}% +% \end{macrocode} +% \subsection{\csh{XINT_div_unsepR}} +% +% \lverb|This is used by division to remove separators from the produced +% remainder. The remainder is here in correct order. It must be cleaned of +% leading zeroes, possibly all the way. +% +% Also rewritten for 1.2l, the 1.2 version was O(N^2) style. +% +% Terminator \xint_bye!2!3!4!5!6!7!8!9!\xint_bye\xint_c_i\relax\R +% +% We have a need for something like \R because it is not guaranteed the thing +% is not actually zero.| +% \begin{macrocode} +\def\XINT_div_unsepR +{% + \expandafter\XINT_div_unsepR_x\the\numexpr0\XINT_unsep_loop +}% +\def\XINT_div_unsepR_x#1{% +\def\XINT_div_unsepR_x 0{\expandafter#1\the\numexpr\XINT_cuz_loop}% +}\XINT_div_unsepR_x{ }% +% \end{macrocode} +% \subsection{\csh{XINT_zeroes_forviii}} +% +% \lverb|& +%( \romannumeral0\XINT_zeroes_forviii #1\R\R\R\R\R\R\R\R{10}0000001\W +%) +% produces a string of k 0's such that k+length(#1) is smallest bigger multiple +% of eight.| +% \begin{macrocode} +\def\XINT_zeroes_forviii #1#2#3#4#5#6#7#8% +{% + \xint_gob_til_R #8\XINT_zeroes_forviii_end\R\XINT_zeroes_forviii +}% +\def\XINT_zeroes_forviii_end#1{% +\def\XINT_zeroes_forviii_end\R\XINT_zeroes_forviii ##1##2##3##4##5##6##7##8##9\W +{% + \expandafter#1\xint_gob_til_one ##2##3##4##5##6##7##8% +}}\XINT_zeroes_forviii_end{ }% +% \end{macrocode} +% \subsection{\csh{XINT_sepbyviii_Z}} +% +% \lverb|This is used as +%( \the\numexpr\XINT_sepbyviii_Z <8Ndigits>\XINT_sepbyviii_Z_end 2345678\relax +%) +% It produces 1<8d>!...1<8d>!1;! +% +% Prior to 1.2l it used \Z as terminator not the semi-colon (hence the name). +% The switch to ; was done at a time I thought perhaps I would use an internal +% format maintaining such 8 digits blocks, and this has to be compatible with +% the \csname...\endcsname encapsulation in \xintexpr parsers.| +% \begin{macrocode} +\def\XINT_sepbyviii_Z #1#2#3#4#5#6#7#8% +{% + 1#1#2#3#4#5#6#7#8\expandafter!\the\numexpr\XINT_sepbyviii_Z +}% +\def\XINT_sepbyviii_Z_end #1\relax {;!}% +% \end{macrocode} +% \subsection{\csh{XINT_sepbyviii_andcount}} +% +% \lverb|This is used as +%( \the\numexpr\XINT_sepbyviii_andcount <8Ndigits>$% +%: \XINT_sepbyviii_end 2345678\relax +%: \xint_c_vii!\xint_c_vi!\xint_c_v!\xint_c_iv!$% +%: \xint_c_iii!\xint_c_ii!\xint_c_i!\xint_c_\W +%) +% It will produce +%( 1<8d>!1<8d>!....1<8d>!1\xint:<count of blocks>\xint: +%) +% Used by +% \XINT_div_prepare_g for \XINT_div_prepare_h, and also by \xintiiCmp.| +% \begin{macrocode} +\def\XINT_sepbyviii_andcount +{% + \expandafter\XINT_sepbyviii_andcount_a\the\numexpr\XINT_sepbyviii +}% +\def\XINT_sepbyviii #1#2#3#4#5#6#7#8% +{% + 1#1#2#3#4#5#6#7#8\expandafter!\the\numexpr\XINT_sepbyviii +}% +\def\XINT_sepbyviii_end #1\relax {\relax\XINT_sepbyviii_andcount_end!}% +\def\XINT_sepbyviii_andcount_a {\XINT_sepbyviii_andcount_b \xint_c_\xint:}% +\def\XINT_sepbyviii_andcount_b #1\xint:#2!#3!#4!#5!#6!#7!#8!#9!% +{% + #2\expandafter!\the\numexpr#3\expandafter!\the\numexpr#4\expandafter + !\the\numexpr#5\expandafter!\the\numexpr#6\expandafter!\the\numexpr + #7\expandafter!\the\numexpr#8\expandafter!\the\numexpr#9\expandafter!\the\numexpr + \expandafter\XINT_sepbyviii_andcount_b\the\numexpr #1+\xint_c_viii\xint:% +}% +\def\XINT_sepbyviii_andcount_end #1\XINT_sepbyviii_andcount_b\the\numexpr + #2+\xint_c_viii\xint:#3#4\W {\expandafter\xint:\the\numexpr #2+#3\xint:}% +% \end{macrocode} +% \subsection{\csh{XINT_rsepbyviii}} +% +% \lverb|This is used as +%( \the\numexpr1\XINT_rsepbyviii <8Ndigits>$% +%: \XINT_rsepbyviii_end_A 2345678$% +%: \XINT_rsepbyviii_end_B 2345678\relax UV$% +%) +% and will produce +%( 1<8digits>!1<8digits>\xint:1<8digits>!... +%) +% where the original +% digits are organized by eight, and the order inside successive pairs of +% blocks separated by \xint: has been reversed. Output ends either in +% 1<8d>!1<8d>\xint:1U\xint: (even) or 1<8d>!1<8d>\xint:1V!1<8d>\xint: (odd) +% +% The U an V should be \numexpr1 stoppers (or will expand and be ended by !). +% This macro is currently (1.2..1.2l) exclusively used in combination with +% \XINT_sepandrev_andcount or \XINT_sepandrev. +% | +% \begin{macrocode} +\def\XINT_rsepbyviii #1#2#3#4#5#6#7#8% +{% + \XINT_rsepbyviii_b {#1#2#3#4#5#6#7#8}% +}% +\def\XINT_rsepbyviii_b #1#2#3#4#5#6#7#8#9% +{% + #2#3#4#5#6#7#8#9\expandafter!\the\numexpr + 1#1\expandafter\xint:\the\numexpr 1\XINT_rsepbyviii +}% +\def\XINT_rsepbyviii_end_B #1\relax #2#3{#2\xint:}% +\def\XINT_rsepbyviii_end_A #11#2\expandafter #3\relax #4#5{#5!1#2\xint:}% +% \end{macrocode} +% \subsection{\csh{XINT_sepandrev}} +% \lverb|This is used typically as +%( \romannumeral0\XINT_sepandrev <8Ndigits>$% +%: \XINT_rsepbyviii_end_A 2345678$% +%: \XINT_rsepbyviii_end_B 2345678\relax UV$% +%: \R\xint:\R\xint:\R\xint:\R\xint:\R\xint:\R\xint:\R\xint:\R\xint:\W +%) +% and will produce +%( 1<8digits>!1<8digits>!1<8digits>!... +%) +% where the blocks have +% been globally reversed. The UV here are only place holders (must be \numexpr1 +% stoppers) to share same +% syntax as \XINT_sepandrev_andcount, they are gobbled (#2 in \XINT_sepandrev_done).| +% \begin{macrocode} +\def\XINT_sepandrev +{% + \expandafter\XINT_sepandrev_a\the\numexpr 1\XINT_rsepbyviii +}% +\def\XINT_sepandrev_a {\XINT_sepandrev_b {}}% +\def\XINT_sepandrev_b #1#2\xint:#3\xint:#4\xint:#5\xint:#6\xint:#7\xint:#8\xint:#9\xint:% +{% + \xint_gob_til_R #9\XINT_sepandrev_end\R + \XINT_sepandrev_b {#9!#8!#7!#6!#5!#4!#3!#2!#1}% +}% +\def\XINT_sepandrev_end\R\XINT_sepandrev_b #1#2\W {\XINT_sepandrev_done #1}% +\def\XINT_sepandrev_done #11#2!{ }% +% \end{macrocode} +% \subsection{\csh{XINT_sepandrev_andcount}} +% \lverb|This is used typically as +%( \romannumeral0\XINT_sepandrev_andcount <8Ndigits>$% +%: \XINT_rsepbyviii_end_A 2345678$% +%: \XINT_rsepbyviii_end_B 2345678\relax\xint_c_ii\xint_c_i +%: \R\xint:\xint_c_xii \R\xint:\xint_c_x \R\xint:\xint_c_viii \R\xint:\xint_c_vi +%: \R\xint:\xint_c_iv \R\xint:\xint_c_ii \R\xint:\xint_c_\W +%) +% and will produce +%( <length>.1<8digits>!1<8digits>!1<8digits>!... +%) +% where the +% blocks have been globally reversed and <length> is the number of blocks.| +% \begin{macrocode} +\def\XINT_sepandrev_andcount +{% + \expandafter\XINT_sepandrev_andcount_a\the\numexpr 1\XINT_rsepbyviii +}% +\def\XINT_sepandrev_andcount_a {\XINT_sepandrev_andcount_b 0!{}}% +\def\XINT_sepandrev_andcount_b #1!#2#3\xint:#4\xint:#5\xint:#6\xint:#7\xint:#8\xint:#9\xint:% +{% + \xint_gob_til_R #9\XINT_sepandrev_andcount_end\R + \expandafter\XINT_sepandrev_andcount_b \the\numexpr #1+\xint_c_i!% + {#9!#8!#7!#6!#5!#4!#3!#2}% +}% +\def\XINT_sepandrev_andcount_end\R + \expandafter\XINT_sepandrev_andcount_b\the\numexpr #1+\xint_c_i!#2#3#4\W +{\expandafter\XINT_sepandrev_andcount_done\the\numexpr #3+\xint_c_xiv*#1!#2}% +\def\XINT_sepandrev_andcount_done#1{% +\def\XINT_sepandrev_andcount_done##1!##21##3!{\expandafter#1\the\numexpr##1-##3\xint:}% +}\XINT_sepandrev_andcount_done{ }% +% \end{macrocode} +% \subsection{\csh{XINT_rev_nounsep}} +% \lverb|This is used as +%( \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 the division algorithm. The inserted {} here is not optional.| +% \begin{macrocode} +\def\XINT_rev_nounsep #1#2!#3!#4!#5!#6!#7!#8!#9!% +{% + \xint_gob_til_R #9\XINT_rev_nounsep_end\R + \XINT_rev_nounsep {#9!#8!#7!#6!#5!#4!#3!#2!#1}% +}% +\def\XINT_rev_nounsep_end\R\XINT_rev_nounsep #1#2\W {\XINT_rev_nounsep_done #1}% +\def\XINT_rev_nounsep_done #11{ 1}% +% \end{macrocode} +% \subsection{\csh{XINT_unrevbyviii}} +% \lverb|Used as \romannumeral0\XINT_unrevbyviii 1<8d>!....1<8d>! terminated +% by +%( 1;!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). This +% mechanism is used by 1.2 subtraction (still true for 1.2l).| +% \begin{macrocode} +\def\XINT_unrevbyviii #11#2!1#3!1#4!1#5!1#6!1#7!1#8!1#9!% +{% + \xint_gob_til_R #9\XINT_unrevbyviii_a\R + \XINT_unrevbyviii {#9#8#7#6#5#4#3#2#1}% +}% +\def\XINT_unrevbyviii_a#1{% +\def\XINT_unrevbyviii_a\R\XINT_unrevbyviii ##1##2\W + {\expandafter#1\romannumeral`&&@\xint_gob_til_sc ##1}% +}\XINT_unrevbyviii_a{ }% +% \end{macrocode} +% \lverb|Can work with shorter ending pattern: 1;!1\R!1\R!1\R!1\R!1\R!1\R!\W +% but the longer one of unrevbyviii is ok here too. Used currently (1.2) only +% by addition, now (1.2c) with long ending pattern. Does the final clean up of +% leading zeroes contrarily to general \XINT_unrevbyviii.| +% \begin{macrocode} +\def\XINT_smallunrevbyviii 1#1!1#2!1#3!1#4!1#5!1#6!1#7!1#8!#9\W% +{% + \expandafter\XINT_cuz_small\xint_gob_til_sc #8#7#6#5#4#3#2#1% +}% +% \end{macrocode} +% \subsection*{Core arithmetic} +% \addcontentsline{toc}{subsection}{Core arithmetic} % \lverb|The four operations have been rewritten entirely for release 1.2. % The new routines works with separated blocks of eight digits. They all measure % first the lengths of the arguments, even addition and subtraction (this was @@ -18384,20 +18867,22 @@ $1$ or $-1$. % digits.| % % \subsection{\csbh{xintiAdd}, \csbh{xintiiAdd}} +% \lverb|1.2l: \xintiiAdd made robust against non terminated input.| % \begin{macrocode} \def\xintiAdd {\romannumeral0\xintiadd }% -\def\xintiadd #1{\expandafter\XINT_iadd\romannumeral0\xintnum{#1}\Z }% +\def\xintiadd #1{\expandafter\XINT_iadd\romannumeral0\xintnum{#1}\xint:}% \def\xintiiAdd {\romannumeral0\xintiiadd }% -\def\xintiiadd #1{\expandafter\XINT_iiadd\romannumeral`&&@#1\Z }% -\def\XINT_iiadd #1#2\Z #3% +\def\xintiiadd #1{\expandafter\XINT_iiadd\romannumeral`&&@#1\xint:}% +\def\XINT_iiadd #1#2\xint:#3% {% - \expandafter\XINT_add_nfork\expandafter #1\romannumeral`&&@#3\Z #2\Z + \expandafter\XINT_add_nfork\expandafter#1\romannumeral`&&@#3\xint:#2\xint: }% -\def\XINT_iadd #1#2\Z #3% +\def\XINT_iadd #1#2\xint:#3% {% - \expandafter\XINT_add_nfork\expandafter #1\romannumeral0\xintnum{#3}\Z #2\Z + \expandafter\XINT_add_nfork\expandafter + #1\romannumeral0\xintnum{#3}\xint:#2\xint: }% -\def\XINT_add_fork #1#2\Z #3\Z {\XINT_add_nfork #1#3\Z #2\Z}% +\def\XINT_add_fork #1#2\xint:#3\xint:{\XINT_add_nfork #1#3\xint:#2\xint:}% \def\XINT_add_nfork #1#2% {% \xint_UDzerofork @@ -18412,56 +18897,58 @@ $1$ or $-1$. --\XINT_add_plusplus \krof #1#2% }% -\def\XINT_add_firstiszero #1\krof 0#2#3\Z #4\Z { #2#3}% -\def\XINT_add_secondiszero #1\krof #20#3\Z #4\Z { #2#4}% +\def\XINT_add_firstiszero #1\krof 0#2#3\xint:#4\xint:{ #2#3}% +\def\XINT_add_secondiszero #1\krof #20#3\xint:#4\xint:{ #2#4}% \def\XINT_add_minusminus #1#2% {\expandafter-\romannumeral0\XINT_add_pp_a {}{}}% \def\XINT_add_minusplus #1#2{\XINT_sub_mm_a {}#2}% \def\XINT_add_plusminus #1#2% {\expandafter\XINT_opp\romannumeral0\XINT_sub_mm_a #1{}}% -\def\XINT_add_pp_a #1#2#3\Z +\def\XINT_add_pp_a #1#2#3\xint: {% \expandafter\XINT_add_pp_b \romannumeral0\expandafter\XINT_sepandrev_andcount \romannumeral0\XINT_zeroes_forviii #2#3\R\R\R\R\R\R\R\R{10}0000001\W #2#3\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 + \XINT_rsepbyviii_end_B 2345678\relax\xint_c_ii\xint_c_i + \R\xint:\xint_c_xii \R\xint:\xint_c_x \R\xint:\xint_c_viii \R\xint:\xint_c_vi + \R\xint:\xint_c_iv \R\xint:\xint_c_ii \R\xint:\xint_c_\W \X #1% }% \let\XINT_add_plusplus \XINT_add_pp_a -\def\XINT_add_pp_b #1.#2\X #3\Z +% \end{macrocode} +% \begin{macrocode} +\def\XINT_add_pp_b #1\xint:#2\X #3\xint: {% \expandafter\XINT_add_checklengths - \the\numexpr #1\expandafter.% + \the\numexpr #1\expandafter\xint:% \romannumeral0\expandafter\XINT_sepandrev_andcount \romannumeral0\XINT_zeroes_forviii #3\R\R\R\R\R\R\R\R{10}0000001\W #3\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 - 1\Z!1\Z!1\Z!1\Z!\W #21\Z!1\Z!1\Z!1\Z!\W + \XINT_rsepbyviii_end_B 2345678\relax\xint_c_ii\xint_c_i + \R\xint:\xint_c_xii \R\xint:\xint_c_x \R\xint:\xint_c_viii \R\xint:\xint_c_vi + \R\xint:\xint_c_iv \R\xint:\xint_c_ii \R\xint:\xint_c_\W + 1;!1;!1;!1;!\W #21;!1;!1;!1;!\W 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W }% % \end{macrocode} % \lverb|I keep #1.#2. to check if at most 6 + 6 base 10^8 digits which can be % treated faster for final reverse. But is this overhead at all useful ? | % \begin{macrocode} -\def\XINT_add_checklengths #1.#2.% +\def\XINT_add_checklengths #1\xint:#2\xint:% {% \ifnum #2>#1 \expandafter\XINT_add_exchange \else \expandafter\XINT_add_A \fi - #1.#2.% + #1\xint:#2\xint:% }% -\def\XINT_add_exchange #1.#2.#3\W #4\W +\def\XINT_add_exchange #1\xint:#2\xint:#3\W #4\W {% - \XINT_add_A #2.#1.#4\W #3\W + \XINT_add_A #2\xint:#1\xint:#4\W #3\W }% -\def\XINT_add_A #1.#2.% +\def\XINT_add_A #1\xint:#2\xint:% {% \ifnum #1>\xint_c_vi \expandafter\XINT_add_aa @@ -18475,105 +18962,247 @@ $1$ or $-1$. % \end{macrocode} % \lverb|2 as first token of #1 stands for "no carry", 3 will mean a carry (we % are adding 1<8digits> to 1<8digits>.) Version 1.2c has terminators of the -% shape 1\Z!, replacing the \Z! used in 1.2. +% shape 1;!, replacing the \Z! used in 1.2. % -% Call: \the\numexpr\XINT_add_a 2#11\Z!1\Z!1\Z!1\Z!\W #21\Z!1\Z!1\Z!1\Z!\W +% Call: \the\numexpr\XINT_add_a 2#11;!1;!1;!1;!\W #21;!1;!1;!1;!\W % where #1 and #2 are blocks of 1<8d>!, and #1 is at most as long as #2. This % last requirement is a bit annoying (if one wants to do recursive algorithms % but not have to check lengths), and I will probably remove it at some point. % % Output: blocks of 1<8d>! representing the addition, (least significant -% first), and a final 1\Z!. In recursive algotithm this 1\Z! terminator can +% first), and a final 1;!. In recursive algotithm this 1;! terminator can % thus conveniently be reused as part of input terminator (up to the length -% problem).| +% problem). +% +%| % \begin{macrocode} -\def\XINT_add_a #1!#2!#3!#4!#5\W #6!#7!#8!#9!% +\def\XINT_add_a #1!#2!#3!#4!#5\W + #6!#7!#8!#9!% {% - \XINT_add_b #1!#6!#2!#7!#3!#8!#4!#9!#5\W + \XINT_add_b + #1!#6!#2!#7!#3!#8!#4!#9!% + #5\W }% \def\XINT_add_b #11#2#3!#4!% {% - \xint_gob_til_Z #2\XINT_add_bi \Z - \expandafter\XINT_add_c\the\numexpr#1+1#2#3+#4-\xint_c_ii.% + \xint_gob_til_sc #2\XINT_add_bi ;% + \expandafter\XINT_add_c\the\numexpr#1+1#2#3+#4-\xint_c_ii\xint:% }% -\def\XINT_add_bi\Z\expandafter\XINT_add_c - \the\numexpr#1+#2+#3-\xint_c_ii.#4!#5!#6!#7!#8!#9!\W +\def\XINT_add_bi;\expandafter\XINT_add_c + \the\numexpr#1+#2+#3-\xint_c_ii\xint:#4!#5!#6!#7!#8!#9!\W {% \XINT_add_k #1#3!#5!#7!#9!% }% -\def\XINT_add_c #1#2.% +\def\XINT_add_c #1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_add_d #1% }% \def\XINT_add_d #11#2#3!#4!% {% - \xint_gob_til_Z #2\XINT_add_di \Z - \expandafter\XINT_add_e\the\numexpr#1+1#2#3+#4-\xint_c_ii.% + \xint_gob_til_sc #2\XINT_add_di ;% + \expandafter\XINT_add_e\the\numexpr#1+1#2#3+#4-\xint_c_ii\xint:% }% -\def\XINT_add_di\Z\expandafter\XINT_add_e - \the\numexpr#1+#2+#3-\xint_c_ii.#4!#5!#6!#7!#8\W +\def\XINT_add_di;\expandafter\XINT_add_e + \the\numexpr#1+#2+#3-\xint_c_ii\xint:#4!#5!#6!#7!#8\W {% \XINT_add_k #1#3!#5!#7!% }% -\def\XINT_add_e #1#2.% +\def\XINT_add_e #1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_add_f #1% }% \def\XINT_add_f #11#2#3!#4!% {% - \xint_gob_til_Z #2\XINT_add_fi \Z - \expandafter\XINT_add_g\the\numexpr#1+1#2#3+#4-\xint_c_ii.% + \xint_gob_til_sc #2\XINT_add_fi ;% + \expandafter\XINT_add_g\the\numexpr#1+1#2#3+#4-\xint_c_ii\xint:% }% -\def\XINT_add_fi\Z\expandafter\XINT_add_g - \the\numexpr#1+#2+#3-\xint_c_ii.#4!#5!#6\W +\def\XINT_add_fi;\expandafter\XINT_add_g + \the\numexpr#1+#2+#3-\xint_c_ii\xint:#4!#5!#6\W {% \XINT_add_k #1#3!#5!% }% -\def\XINT_add_g #1#2.% +\def\XINT_add_g #1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_add_h #1% }% \def\XINT_add_h #11#2#3!#4!% {% - \xint_gob_til_Z #2\XINT_add_hi \Z - \expandafter\XINT_add_i\the\numexpr#1+1#2#3+#4-\xint_c_ii.% + \xint_gob_til_sc #2\XINT_add_hi ;% + \expandafter\XINT_add_i\the\numexpr#1+1#2#3+#4-\xint_c_ii\xint:% }% -\def\XINT_add_hi\Z - \expandafter\XINT_add_i\the\numexpr#1+#2+#3-\xint_c_ii.#4\W +\def\XINT_add_hi;% + \expandafter\XINT_add_i\the\numexpr#1+#2+#3-\xint_c_ii\xint:#4\W {% \XINT_add_k #1#3!% }% -\def\XINT_add_i #1#2.% +\def\XINT_add_i #1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_add_a #1% }% +% \end{macrocode} +% \begin{macrocode} \def\XINT_add_k #1{\if #12\expandafter\XINT_add_ke\else\expandafter\XINT_add_l \fi}% -\def\XINT_add_ke #11\Z #2\W {\XINT_add_kf #11\Z!}% +\def\XINT_add_ke #11;#2\W {\XINT_add_kf #11;!}% \def\XINT_add_kf 1{1\relax }% -\def\XINT_add_l 1#1#2{\xint_gob_til_Z #1\XINT_add_lf \Z \XINT_add_m 1#1#2}% -\def\XINT_add_lf #1\W {1\relax 00000001!1\Z!}% -\def\XINT_add_m #1!{\expandafter\XINT_add_n\the\numexpr\xint_c_i+#1.}% -\def\XINT_add_n #1#2.{1#2\expandafter!\the\numexpr\XINT_add_o #1}% +\def\XINT_add_l 1#1#2{\xint_gob_til_sc #1\XINT_add_lf ;\XINT_add_m 1#1#2}% +\def\XINT_add_lf #1\W {1\relax 00000001!1;!}% +\def\XINT_add_m #1!{\expandafter\XINT_add_n\the\numexpr\xint_c_i+#1\xint:}% +\def\XINT_add_n #1#2\xint:{1#2\expandafter!\the\numexpr\XINT_add_o #1}% % \end{macrocode} % \lverb|Here 2 stands for "carry", and 1 for "no carry" (we have been adding % 1 to 1<8digits>.)| % \begin{macrocode} \def\XINT_add_o #1{\if #12\expandafter\XINT_add_l\else\expandafter\XINT_add_ke \fi}% % \end{macrocode} +% \subsection{\csh{xintCmp}, \csh{xintiiCmp}} +% \lverb|Moved from xint.sty to xintcore.sty and rewritten for 1.2l. +% +% 1.2l's \xintiiCmp is robust against non terminated input. +% | +% \begin{macrocode} +\def\xintCmp {\romannumeral0\xintcmp }% +\def\xintcmp #1{\expandafter\XINT_icmp\romannumeral0\xintnum{#1}\xint:}% +\def\xintiiCmp {\romannumeral0\xintiicmp }% +\def\xintiicmp #1{\expandafter\XINT_iicmp\romannumeral`&&@#1\xint:}% +\def\XINT_iicmp #1#2\xint:#3% +{% + \expandafter\XINT_cmp_nfork\expandafter #1\romannumeral`&&@#3\xint:#2\xint: +}% +\def\XINT_icmp #1#2\xint:#3% +{% + \expandafter\XINT_cmp_nfork\expandafter #1\romannumeral0\xintnum{#3}\xint:#2\xint: +}% +\def\XINT_cmp_nfork #1#2% +{% + \xint_UDzerofork + #1\XINT_cmp_firstiszero + #2\XINT_cmp_secondiszero + 0{}% + \krof + \xint_UDsignsfork + #1#2\XINT_cmp_minusminus + #1-\XINT_cmp_minusplus + #2-\XINT_cmp_plusminus + --\XINT_cmp_plusplus + \krof #1#2% +}% +\def\XINT_cmp_firstiszero #1\krof 0#2#3\xint:#4\xint: +{% + \xint_UDzerominusfork + #2-{ 0}% + 0#2{ 1}% + 0-{ -1}% + \krof +}% +\def\XINT_cmp_secondiszero #1\krof #20#3\xint:#4\xint: +{% + \xint_UDzerominusfork + #2-{ 0}% + 0#2{ -1}% + 0-{ 1}% + \krof +}% +\def\XINT_cmp_plusminus #1\xint:#2\xint:{ 1}% +\def\XINT_cmp_minusplus #1\xint:#2\xint:{ -1}% +\def\XINT_cmp_minusminus + --{\expandafter\XINT_opp\romannumeral0\XINT_cmp_plusplus {}{}}% +\def\XINT_cmp_plusplus #1#2#3\xint: +{% + \expandafter\XINT_cmp_pp + \the\numexpr\expandafter\XINT_sepbyviii_andcount + \romannumeral0\XINT_zeroes_forviii #2#3\R\R\R\R\R\R\R\R{10}0000001\W + #2#3\XINT_sepbyviii_end 2345678\relax + \xint_c_vii!\xint_c_vi!\xint_c_v!\xint_c_iv!% + \xint_c_iii!\xint_c_ii!\xint_c_i!\xint_c_\W + #1% +}% +\def\XINT_cmp_pp #1\xint:#2\xint:#3\xint: +{% + \expandafter\XINT_cmp_checklengths + \the\numexpr #2\expandafter\xint:% + \the\numexpr\expandafter\XINT_sepbyviii_andcount + \romannumeral0\XINT_zeroes_forviii #3\R\R\R\R\R\R\R\R{10}0000001\W + #3\XINT_sepbyviii_end 2345678\relax + \xint_c_vii!\xint_c_vi!\xint_c_v!\xint_c_iv!% + \xint_c_iii!\xint_c_ii!\xint_c_i!\xint_c_\W + #1;!1;!1;!1;!\W +}% +\def\XINT_cmp_checklengths #1\xint:#2\xint:#3\xint: +{% + \ifnum #1=#3 + \expandafter\xint_firstoftwo + \else + \expandafter\xint_secondoftwo + \fi + \XINT_cmp_a {\XINT_cmp_distinctlengths {#1}{#3}}#2;!1;!1;!1;!\W +}% +\def\XINT_cmp_distinctlengths #1#2#3\W #4\W +{% + \ifnum #1>#2 + \expandafter\xint_firstoftwo + \else + \expandafter\xint_secondoftwo + \fi + { -1}{ 1}% +}% +\def\XINT_cmp_a 1#1!1#2!1#3!1#4!#5\W 1#6!1#7!1#8!1#9!% +{% + \xint_gob_til_sc #1\XINT_cmp_equal ;% + \ifnum #1>#6 \XINT_cmp_gt\fi + \ifnum #1<#6 \XINT_cmp_lt\fi + \xint_gob_til_sc #2\XINT_cmp_equal ;% + \ifnum #2>#7 \XINT_cmp_gt\fi + \ifnum #2<#7 \XINT_cmp_lt\fi + \xint_gob_til_sc #3\XINT_cmp_equal ;% + \ifnum #3>#8 \XINT_cmp_gt\fi + \ifnum #3<#8 \XINT_cmp_lt\fi + \xint_gob_til_sc #4\XINT_cmp_equal ;% + \ifnum #4>#9 \XINT_cmp_gt\fi + \ifnum #4<#9 \XINT_cmp_lt\fi + \XINT_cmp_a #5\W +}% +\def\XINT_cmp_lt#1{\def\XINT_cmp_lt\fi ##1\W ##2\W {\fi#1-1}}\XINT_cmp_lt{ }% +\def\XINT_cmp_gt#1{\def\XINT_cmp_gt\fi ##1\W ##2\W {\fi#11}}\XINT_cmp_gt{ }% +\def\XINT_cmp_equal #1\W #2\W { 0}% +% \end{macrocode} % \subsection{\csh{xintiSub}, \csh{xintiiSub}} -% \lverb|Entirely rewritten for 1.2.| +% \lverb|Entirely rewritten for 1.2. +% +% Refactored at 1.2l. I was initially aiming at clinching some internal format +% of the type 1<8digits>!....1<8digits>! for chaining the arithmetic +% operations (as a preliminary step to decided upon some internal format for +% $xintfracnameimp macros), thus I wanted to uniformize delimiters in +% particular and have some core macros inputting and outputting such formats. +% But the way division is implemented makes it currently very hard to obtain a +% satisfactory solution. For subtraction I got there almost, but there was +% added overhead and, as the core sub-routine still assumed the shorter number +% will be positioned first, one would need to record the length also in the +% basic internal format, or add the overhead to not make assumption on which +% one is shorter. I thus but back-tracked my steps but in passing I improved +% the efficiency (probably) in the worst case branch. +% +% The other reason for backtracking was in relation with the decimal numbers. +% Having a core format in base 10^8 but ultimately the radix is actually 10 +% leads to complications. I could use radix 10^8 for \xintiiexpr only, but +% then I need to make it compatible with sub-\xintiiexpr in \xintexpr, etc... +% there are many issues of this type. +% +% I considered also an approach like in the 1.2l \xintiiCmp, but decided to +% stick with the method here for now.| % \begin{macrocode} \def\xintiiSub {\romannumeral0\xintiisub }% -\def\xintiisub #1{\expandafter\XINT_iisub\romannumeral`&&@#1\Z }% -\def\XINT_iisub #1#2\Z #3% +\def\xintiisub #1{\expandafter\XINT_iisub\romannumeral`&&@#1\xint:}% +\def\XINT_iisub #1#2\xint:#3% {% - \expandafter\XINT_sub_nfork\expandafter #1\romannumeral`&&@#3\Z #2\Z + \expandafter\XINT_sub_nfork\expandafter + #1\romannumeral`&&@#3\xint:#2\xint: }% -\def\xintiSub {\romannumeral0\xintisub }% -\def\xintisub #1{\expandafter\XINT_isub\romannumeral0\xintnum{#1}\Z }% -\def\XINT_isub #1#2\Z #3% +\def\xintiSub {\romannumeral0\xintisub }% +\def\xintisub #1{\expandafter\XINT_isub\romannumeral0\xintnum{#1}\xint:}% +\def\XINT_isub #1#2\xint:#3% {% - \expandafter\XINT_sub_nfork\expandafter #1\romannumeral0\xintnum{#3}\Z #2\Z + \expandafter\XINT_sub_nfork\expandafter + #1\romannumeral0\xintnum{#3}\xint:#2\xint: }% \def\XINT_sub_nfork #1#2% {% @@ -18589,38 +19218,43 @@ $1$ or $-1$. --\XINT_sub_plusplus \krof #1#2% }% -\def\XINT_sub_firstiszero #1\krof 0#2#3\Z #4\Z {\XINT_opp #2#3}% -\def\XINT_sub_secondiszero #1\krof #20#3\Z #4\Z { #2#4}% +\def\XINT_sub_firstiszero #1\krof 0#2#3\xint:#4\xint:{\XINT_opp #2#3}% +\def\XINT_sub_secondiszero #1\krof #20#3\xint:#4\xint:{ #2#4}% \def\XINT_sub_plusminus #1#2{\XINT_add_pp_a #1{}}% \def\XINT_sub_plusplus #1#2% {\expandafter\XINT_opp\romannumeral0\XINT_sub_mm_a #1#2}% \def\XINT_sub_minusplus #1#2% {\expandafter-\romannumeral0\XINT_add_pp_a {}#2}% \def\XINT_sub_minusminus #1#2{\XINT_sub_mm_a {}{}}% -\def\XINT_sub_mm_a #1#2#3\Z +% \end{macrocode} +% \begin{macrocode} +\def\XINT_sub_mm_a #1#2#3\xint: {% \expandafter\XINT_sub_mm_b \romannumeral0\expandafter\XINT_sepandrev_andcount \romannumeral0\XINT_zeroes_forviii #2#3\R\R\R\R\R\R\R\R{10}0000001\W #2#3\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 + \XINT_rsepbyviii_end_B 2345678\relax\xint_c_ii\xint_c_i + \R\xint:\xint_c_xii \R\xint:\xint_c_x \R\xint:\xint_c_viii \R\xint:\xint_c_vi + \R\xint:\xint_c_iv \R\xint:\xint_c_ii \R\xint:\xint_c_\W \X #1% }% -\def\XINT_sub_mm_b #1.#2\X #3\Z +\def\XINT_sub_mm_b #1\xint:#2\X #3\xint: {% \expandafter\XINT_sub_checklengths - \the\numexpr #1\expandafter.% + \the\numexpr #1\expandafter\xint:% \romannumeral0\expandafter\XINT_sepandrev_andcount \romannumeral0\XINT_zeroes_forviii #3\R\R\R\R\R\R\R\R{10}0000001\W #3\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 - \Z!\Z!\Z!\Z!\W #2\Z!\Z!\Z!\Z!\W + \XINT_rsepbyviii_end_B 2345678\relax\xint_c_ii\xint_c_i + \R\xint:\xint_c_xii \R\xint:\xint_c_x \R\xint:\xint_c_viii \R\xint:\xint_c_vi + \R\xint:\xint_c_iv \R\xint:\xint_c_ii \R\xint:\xint_c_\W + 1;!1;!1;!1;!\W + #21;!1;!1;!1;!\W + 1;!1\R!1\R!1\R!1\R!% + 1\R!1\R!1\R!1\R!\W }% -\def\XINT_sub_checklengths #1.#2.% +\def\XINT_sub_checklengths #1\xint:#2\xint:% {% \ifnum #2>#1 \expandafter\XINT_sub_exchange @@ -18632,142 +19266,133 @@ $1$ or $-1$. {% \expandafter\XINT_opp\romannumeral0\XINT_sub_aa #2\W #1\W }% -\def\XINT_sub_aa {\expandafter\XINT_sub_out\the\numexpr\XINT_sub_a \xint_c_i }% -% \end{macrocode} -% \lverb|The {} after \XINT_unrevbyviii could be removed, but attention then -% at \XINT_sub_startrescue which must be modified (no need for #1).| -% \begin{macrocode} -\def\XINT_sub_out #1\Z #2#3\W +\def\XINT_sub_aa {% - \if-#2\expandafter\XINT_sub_startrescue\fi - \expandafter\XINT_cuz_small - \romannumeral0\XINT_unrevbyviii {}#11\Z!1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W + \expandafter\XINT_sub_out\the\numexpr\XINT_sub_a\xint_c_i }% % \end{macrocode} +% \lverb|The post-processing (clean-up of zeros, or rescue of situation with +% A-B where actually B turns out bigger than A) will be done by a macro which +% depends on circumstances and will be initially last token before the +% reversion done by \XINT_unrevbyviii.| +% \begin{macrocode} +\def\XINT_sub_out {\XINT_unrevbyviii{}}% +% \end{macrocode} % \lverb|1 as first token of #1 stands for "no carry", 0 will mean a carry. % -% Call: \the\numexpr -% \XINT_sub_a 1#1\Z!\Z!\Z!\Z!\W #2\Z!\Z!\Z!\Z!\W where #1 and #2 -% are blocks of 1<8d>!, and #1 *must* be at most as long as #2. +%( Call: \the\numexpr +%: \XINT_sub_a 1#11;!1;!1;!1;!\W +%: #21;!1;!1;!1;!\W +%) +% where #1 and #2 +% are blocks of 1<8d>!, #1 (=B) *must* be at most as long as #2 (=A), +% (in radix 10^8) +% and the routine wants to compute #2-#1 = A - B % -% The routine wants to compute #2-#1. -% -% Notice that currently the terminators on input differ from those for -% addition. Also, currently (1.2f) the routine can not be called without final -% reversal and clean up of the result. +% 1.2l uses 1;! delimiters to match those of addition (and multiplication). +% But in the end I reverted the code branch which made it possible to chain +% such operations keeping internal format in 8 digits blocks throughout. % % \numexpr governed expansion stops with various possibilities: % -% 1. #1 was shorter (in number of 8 digits blocks) than #2. -% -% *1a There may be no carry in which case we end up with$\ -% 1<8d>!...1<8d>!\Z!\Z!\Z!\Z!\W -% -% If there is a carry things are more complicated. -% -% *1b If the first hit block of #2 is > 1 no problem we are like in the -% no-carry case. -% -% *1c If it is exactly 1 then we will have leading zeros; but there may be -% also before that arbitrarily many produced zeros, all these leading zeros -% will have to be cleaned up. This is done via ending the expansion with the -% shape -% -% 1<8d>!...1<8d>!1\XINT_cuz_byviii!\Z 0\W\R +%- Type Ia: #1 shorter than #2, no final carry +%- Type Ib: #1 shorter than #2, a final carry but next block of #2 > 1 +%- Type Ica: #1 shorter than #2, a final carry, next block of #2 is final and = 1 +%- Type Icb: as Ica except that 00000001 block from #2 was not final +%- Type Id: #1 shorter than #2, a final carry, next block of #2 = 0 +%- Type IIa: #1 same length as #2, turns out it was <= #2. +%- Type IIb: #1 same length as #2, but turned out > #2. % -% *1d If the block value is zero, subtraction produces 99999999 and goes on. -% This is the only situation where the carry can propagate. This case can -% never produce extra blocks of leading zeros but may well end up with an ending -% zero block. In this subcase, the \numexpr is then made to stop with a 1!. -% This 1! will disappear during final reverse. +% Various type of post actions are then needed: % -% 2a. #1 was of same length as #2, but <= #2. Then we end up expansion with$\ -% 1<8d>!...1<8d>!1\XINT_cuz_byviii!\Z 0\W\R$\ -% and the blocks will have to cleaned up of leading zeroes after reversal. +%- Ia: clean up of zeros in most significant block of 8 digits % -% 2b. #1 was of same length as #2, but > #2. Then we end up with blocks -% 1<8d>!...1<8d>! followed by -1\Z-\W +%- Ib: as Ia % -% Thus \XINT_sub_out examines the token after the first \Z, which may be ! or -% 0 or -. If ! or 0, \XINT_unrevbyviii will be executed (gobbling a possible -% final 1!), and followed in case 2a or 1c by \XINT_cuz_byviii (note the extra \R -% which terminates it), and then in both 1* and 2a by \XINT_cuz_small. +%- Ic: there may be significant blocks of 8 zeros to clean up from result. +% Only case Ica may have arbitrarily many of them, case Icb has only one such +% block. % -% If we were in 2b we proceed to \XINT_sub_startrescue which I will comment -% another day (the extra -1 at the end from -1\Z-\W will become a -1! and the -% - will serve in \XINT_sub_rescue_d as loop terminator). +%- Id: blocks of 99999999 may propagate and there might a be final zero block +% created which has to be cleaned up. % -% Currently (1.2f) we can not easily use these low level routines in a binary -% split approach due to the fact that first input must be at most as long as -% second but also because the final reversal is not in a common second stage, -% due to the separate treatment for case 2b. +%- IIa: arbitrarily many zeros might have to be removed. % -% For the record: subtraction was correct (I think) in xint releases up to -% 1.2, but 1.2 had a broken treatment of the 1d case. For example \xintiiSub -% {10000000112345678}{12345679} produced 99999999. This got fixed in 1.2c, but -% that fix broke the 1c case :((, for example \xintiiSub -% {10000000000000000}{9999999999999997} was now returning 000000003. Alas. +%- IIb: We wanted #2-#1 = - (#1-#2), but we got 10^{8N}+#2 -#1 = 10^{8N}-(#1-#2). +% We need to do the correction then we are as in IIa situation, except that +% final result can not be zero. % -% This was only realized later on 2016/02/29 (in fact it impacted -% \xintiiSqrt). Hopefully 1.2f got it right at last. | +% The 1.2l method for this correction is (presumably, testing takes lots of +% time, which I do not have) more efficient than in 1.2 release. | % \begin{macrocode} \def\XINT_sub_a #1!#2!#3!#4!#5\W #6!#7!#8!#9!% {% - \XINT_sub_b #1!#6!#2!#7!#3!#8!#4!#9!#5\W + \XINT_sub_b + #1!#6!#2!#7!#3!#8!#4!#9!% + #5\W }% -\def\XINT_sub_b #1#2#3!#4!% +% \end{macrocode} +% \lverb|As 1.2l code uses 1<8digits>! blocks one has to be careful with +% the carry digit 1 or 0: A #11#2#3 pattern would result into an empty #1 +% if the carry digit which is upfront is 1, rather than setting #1=1.| +% \begin{macrocode} +\def\XINT_sub_b #1#2#3#4!#5!% {% - \xint_gob_til_Z #2\XINT_sub_bi \Z - \expandafter\XINT_sub_c\the\numexpr#1+1#4-#3-\xint_c_i.% + \xint_gob_til_sc #3\XINT_sub_bi ;% + \expandafter\XINT_sub_c\the\numexpr#1+1#5-#3#4-\xint_c_i\xint:% }% -\def\XINT_sub_c 1#1#2.% +\def\XINT_sub_c 1#1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_sub_d #1% }% -\def\XINT_sub_d #1#2#3!#4!% +\def\XINT_sub_d #1#2#3#4!#5!% {% - \xint_gob_til_Z #2\XINT_sub_di \Z - \expandafter\XINT_sub_e\the\numexpr#1+1#4-#3-\xint_c_i.% + \xint_gob_til_sc #3\XINT_sub_di ;% + \expandafter\XINT_sub_e\the\numexpr#1+1#5-#3#4-\xint_c_i\xint: }% -\def\XINT_sub_e 1#1#2.% +\def\XINT_sub_e 1#1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_sub_f #1% }% -\def\XINT_sub_f #1#2#3!#4!% +\def\XINT_sub_f #1#2#3#4!#5!% {% - \xint_gob_til_Z #2\XINT_sub_fi \Z - \expandafter\XINT_sub_g\the\numexpr#1+1#4-#3-\xint_c_i.% + \xint_gob_til_sc #3\XINT_sub_fi ;% + \expandafter\XINT_sub_g\the\numexpr#1+1#5-#3#4-\xint_c_i\xint: }% -\def\XINT_sub_g 1#1#2.% +\def\XINT_sub_g 1#1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_sub_h #1% }% -\def\XINT_sub_h #1#2#3!#4!% +\def\XINT_sub_h #1#2#3#4!#5!% {% - \xint_gob_til_Z #2\XINT_sub_hi \Z - \expandafter\XINT_sub_i\the\numexpr#1+1#4-#3-\xint_c_i.% + \xint_gob_til_sc #3\XINT_sub_hi ;% + \expandafter\XINT_sub_i\the\numexpr#1+1#5-#3#4-\xint_c_i\xint: }% -\def\XINT_sub_i 1#1#2.% +\def\XINT_sub_i 1#1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_sub_a #1% }% -\def\XINT_sub_bi\Z - \expandafter\XINT_sub_c\the\numexpr#1+1#2-#3.#4!#5!#6!#7!#8!#9!\W +\def\XINT_sub_bi;% + \expandafter\XINT_sub_c\the\numexpr#1+1#2-#3\xint: + #4!#5!#6!#7!#8!#9!\W {% \XINT_sub_k #1#2!#5!#7!#9!% }% -\def\XINT_sub_di\Z - \expandafter\XINT_sub_e\the\numexpr#1+1#2-#3.#4!#5!#6!#7!#8\W +\def\XINT_sub_di;% + \expandafter\XINT_sub_e\the\numexpr#1+1#2-#3\xint: + #4!#5!#6!#7!#8\W {% \XINT_sub_k #1#2!#5!#7!% }% -\def\XINT_sub_fi\Z - \expandafter\XINT_sub_g\the\numexpr#1+1#2-#3.#4!#5!#6\W +\def\XINT_sub_fi;% + \expandafter\XINT_sub_g\the\numexpr#1+1#2-#3\xint: + #4!#5!#6\W {% \XINT_sub_k #1#2!#5!% }% -\def\XINT_sub_hi\Z - \expandafter\XINT_sub_i\the\numexpr#1+1#2-#3.#4\W +\def\XINT_sub_hi;% + \expandafter\XINT_sub_i\the\numexpr#1+1#2-#3\xint: + #4\W {% \XINT_sub_k #1#2!% }% @@ -18777,113 +19402,141 @@ $1$ or $-1$. % % If not, then we are certain that even if there is carry it will not % propagate beyond the end of A. But it may propagate far transforming chains -% of 00000000 into 99999999, and if it does go to the final block which is -% just 1<00000001>!, we will have those eight zeros to clean up. (but we have -% to be careful that if we encounter 1<00000001>! and this is not the final -% block, we should not make something silly either). -% -% There is the possibility that A has exactly one more <eight-digits> block -% than B and that this block is exactly 1. In that case there can be -% arbitrarily many leading zeros to clean up from A-B. This was done correctly -% up to 1.2b but got broken in 1.2c. Belatedly fixed in 1.2f. +% of 00000000 into 99999999, and if it does go to the final block which possibly is +% just 1<00000001>!, we will have those eight zeros to clean up. % -% If we have simultaneously reached the end of A, then if B was smaller there -% might be arbitrarily many zeroes to clean up, if it was larger, we will have -% to rescue the whole thing.| +% If A and B have the same length (in base 10^8) then arbitrarily many zeros +% might have to be cleaned up, and if A<B, the whole result will have to be +% complemented first.| % \begin{macrocode} -\def\XINT_sub_k #1#2% +\def\XINT_sub_k #1#2#3% {% - \xint_gob_til_Z #2\XINT_sub_p\Z \XINT_sub_l #1#2% + \xint_gob_til_sc #3\XINT_sub_p;\XINT_sub_l #1#2#3% }% -\def\XINT_sub_l #1{\xint_UDzerofork #1\XINT_sub_l_carry 0\XINT_sub_l_nocarry\krof}% -\def\XINT_sub_l_nocarry 1{1\relax }% +\def\XINT_sub_l #1% + {\xint_UDzerofork #1\XINT_sub_l_carry 0\XINT_sub_l_Ia\krof}% +\def\XINT_sub_l_Ia 1#1;!#2\W{1\relax#1;!1\XINT_sub_fix_none!}% +% \end{macrocode} +% \lverb| +% +% | +% \begin{macrocode} \def\XINT_sub_l_carry 1#1!{\ifcase #1 - \expandafter \XINT_sub_l_zeroa\or\expandafter\XINT_sub_l_one\else - \expandafter \XINT_sub_l_done\fi 1#1!}% -\def\XINT_sub_l_done {-\xint_c_i+}% -\def\XINT_sub_l_one 1#1!#2% + \expandafter \XINT_sub_l_Id + \or \expandafter \XINT_sub_l_Ic + \else\expandafter \XINT_sub_l_Ib\fi 1#1!}% +\def\XINT_sub_l_Ib #1;#2\W {-\xint_c_i+#1;!1\XINT_sub_fix_none!}% +\def\XINT_sub_l_Ic 1#1!1#2#3!#4;#5\W +{% + \xint_gob_til_sc #2\XINT_sub_l_Ica;% + 1\relax 00000000!1#2#3!#4;!1\XINT_sub_fix_none!% +}% +% \end{macrocode} +% \lverb|& +% We need to add some extra delimiters at the end for post-action by +% \XINT_num, so we first grab the material up to \W +% | +% \begin{macrocode} +\def\XINT_sub_l_Ica#1\W {% - \xint_gob_til_Z #2\XINT_sub_l_oneone\Z 1\relax 00000000!#2% + 1;!1\XINT_sub_fix_cuz!% + 1;!1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W + \xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z }% -\def\XINT_sub_l_oneone #1\W {1\relax \XINT_cuz_byviii!\Z 0\W\R }% -\def\XINT_sub_l_zeroa 1#1!{199999999\expandafter!\the\numexpr \XINT_sub_l_zerob }% -\def\XINT_sub_l_zerob 1#1!{\ifcase #1 - \expandafter \XINT_sub_l_zeroa\or\expandafter\XINT_sub_l_zone\else - \expandafter \XINT_sub_l_done\fi 1#1!}% -\def\XINT_sub_l_zone 1#1!#2% +\def\XINT_sub_l_Id 1#1!% + {199999999\expandafter!\the\numexpr \XINT_sub_l_Id_a}% +\def\XINT_sub_l_Id_a 1#1!{\ifcase #1 + \expandafter \XINT_sub_l_Id + \or \expandafter \XINT_sub_l_Id_b + \else\expandafter \XINT_sub_l_Ib\fi 1#1!}% +\def\XINT_sub_l_Id_b 1#1!1#2#3!#4;#5\W {% - \xint_gob_til_Z #2\XINT_sub_l_zoneone\Z 1\relax 00000000!#2% + \xint_gob_til_sc #2\XINT_sub_l_Ida;% + 1\relax 00000000!1#2#3!#4;!1\XINT_sub_fix_none!% }% -\def\XINT_sub_l_zoneone\Z 1\relax 00000000{1}% +\def\XINT_sub_l_Ida#1\XINT_sub_fix_none{1;!1\XINT_sub_fix_none!}% % \end{macrocode} -% \lverb|Here we are in the situation were the two inputs had the same length -% in base 10^8. If #1=0 we bitterly discover that first input was greater than -% second input despite having same length (in base 10^8). The \numexpr will -% expand beyond the -1 or 1. If #1=1 we had no carry but perhaps the result -% will have plenty of zeroes to clean-up. The result might even be simply zero.| +% \lverb|& +% This is the case where both operands have same 10^8-base length. +% +% We were handling A-B but perhaps B>A. The situation with A=B is also +% annoying because we then have to clean up all zeros but don't know where to +% stop (if A>B the first non-zero 8 digits block would tell use when). +% +% Here again we need to grab #3\W to position the actually used terminating +% delimiters. +% | % \begin{macrocode} -\def\XINT_sub_p\Z\XINT_sub_l #1#2\W +\def\XINT_sub_p;\XINT_sub_l #1#2\W #3\W {% \xint_UDzerofork - #1{-1\relax\Z -\W}% - 0{1\relax \XINT_cuz_byviii!\Z 0\W\R }% + #1{1;!1\XINT_sub_fix_neg!% + 1;!1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W + \xint_bye2345678\xint_bye1099999988\relax}% A - B, B > A + 0{1;!1\XINT_sub_fix_cuz!% + 1;!1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W}% \krof + \xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z }% % \end{macrocode} -% \lverb|We arrive here if #2-#1 concluded #1>#2 (both of the same length in -% base 10^8). To be commented. Here also before the \XINT_sub_rescue_finish -% there will be an ending 1! which will disappear only due to -% \XINT_unrevbyviii. The final \R is for \XINT_cuz.| +% \lverb|Routines for post-processing after reversal, and removal of +% separators. It is a matter of cleaning up zeros, and possibly in the bad +% case to take a complement before that.| % \begin{macrocode} -\def\XINT_sub_startrescue\expandafter\XINT_cuz_small - \romannumeral0\XINT_unrevbyviii #1#2\Z!#3\W -{% - \expandafter\XINT_sub_rescue_finish - \the\numexpr\XINT_sub_rescue_a #2!% - 1\Z!1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W \R -}% -\def\XINT_sub_rescue_finish - {\expandafter-\romannumeral0\expandafter\XINT_cuz\romannumeral0\XINT_unrevbyviii {}}% -\def\XINT_sub_rescue_a #1!% -{% - \expandafter\XINT_sub_rescue_c\the\numexpr \xint_c_xii_e_viii-#1.% -}% -\def\XINT_sub_rescue_c 1#1#2.% +\def\XINT_sub_fix_none;{\XINT_cuz_small}% +\def\XINT_sub_fix_cuz ;{\expandafter\XINT_num_cleanup\the\numexpr\XINT_num_loop}% +% \end{macrocode} +% \lverb|Case with A and B same number of digits in base 10^8 and B>A. +% +% 1.2l subtle chaining on the model of the 1.2i rewrite of \xintInc and +% similar routines. After taking complement, leading zeroes need to be +% cleaned up as in B<=A branch.| +% \begin{macrocode} +\def\XINT_sub_fix_neg;% {% - 1#2\expandafter!\the\numexpr\XINT_sub_rescue_d #1% + \expandafter-\romannumeral0\expandafter + \XINT_sub_comp_finish\the\numexpr\XINT_sub_comp_loop }% -\def\XINT_sub_rescue_d #1#2#3!% +\def\XINT_sub_comp_finish 0{\XINT_sub_fix_cuz;}% +\def\XINT_sub_comp_loop #1#2#3#4#5#6#7#8% {% - \xint_gob_til_minus #2\XINT_sub_rescue_z -% - \expandafter\XINT_sub_rescue_c\the\numexpr \xint_c_xii_e_viii_mone-#2#3+#1.% + \expandafter\XINT_sub_comp_clean + \the\numexpr \xint_c_xi_e_viii_mone-#1#2#3#4#5#6#7#8\XINT_sub_comp_loop }% -\def\XINT_sub_rescue_z #1.{1!}% +% \end{macrocode} +% \lverb|#1 = 0 signifie une retenue, #1 = 1 pas de retenue, ce qui ne peut +% arriver que tant qu'il n'y a que des zéros du côté non significatif. +% Lorsqu'on est revenu au début on a forcément une retenue.| +% \begin{macrocode} +\def\XINT_sub_comp_clean 1#1{+#1\relax}% % \end{macrocode} % \subsection{\csh{xintiMul}, \csh{xintiiMul}} -% \lverb|Completely rewritten for 1.2.| +% \lverb|Completely rewritten for 1.2. +% +% 1.2l: \xintiiMul made robust against non terminated input.| % \begin{macrocode} \def\xintiMul {\romannumeral0\xintimul }% \def\xintimul #1% {% - \expandafter\XINT_imul\romannumeral0\xintnum{#1}\Z + \expandafter\XINT_imul\romannumeral0\xintnum{#1}\xint: }% -\def\XINT_imul #1#2\Z #3% +\def\XINT_imul #1#2\xint:#3% {% - \expandafter\XINT_mul_nfork\expandafter #1\romannumeral0\xintnum{#3}\Z #2\Z + \expandafter\XINT_mul_nfork\expandafter #1\romannumeral0\xintnum{#3}\xint:#2\xint: }% \def\xintiiMul {\romannumeral0\xintiimul }% \def\xintiimul #1% {% - \expandafter\XINT_iimul\romannumeral`&&@#1\Z + \expandafter\XINT_iimul\romannumeral`&&@#1\xint: }% -\def\XINT_iimul #1#2\Z #3% +\def\XINT_iimul #1#2\xint:#3% {% - \expandafter\XINT_mul_nfork\expandafter #1\romannumeral`&&@#3\Z #2\Z + \expandafter\XINT_mul_nfork\expandafter #1\romannumeral`&&@#3\xint:#2\xint: }% % \end{macrocode} -% \lverb|I have changed the fork, and it complicates matters elsewhere.| +% \lverb|(1.2) I have changed the fork, and it complicates matters elsewhere.| % \begin{macrocode} -\def\XINT_mul_fork #1#2\Z #3\Z{\XINT_mul_nfork #1#3\Z #2\Z}% +\def\XINT_mul_fork #1#2\xint:#3\xint:{\XINT_mul_nfork #1#3\xint:#2\xint:}% \def\XINT_mul_nfork #1#2% {% \xint_UDzerofork @@ -18898,40 +19551,40 @@ $1$ or $-1$. --\XINT_mul_plusplus \krof #1#2% }% -\def\XINT_mul_zero #1\krof #2#3\Z #4\Z { 0}% +\def\XINT_mul_zero #1\krof #2#3\xint:#4\xint:{ 0}% \def\XINT_mul_minusminus #1#2{\XINT_mul_plusplus {}{}}% \def\XINT_mul_minusplus #1#2% {\expandafter-\romannumeral0\XINT_mul_plusplus {}#2}% \def\XINT_mul_plusminus #1#2% {\expandafter-\romannumeral0\XINT_mul_plusplus #1{}}% -\def\XINT_mul_plusplus #1#2#3\Z +\def\XINT_mul_plusplus #1#2#3\xint: {% \expandafter\XINT_mul_pre_b \romannumeral0\expandafter\XINT_sepandrev_andcount \romannumeral0\XINT_zeroes_forviii #2#3\R\R\R\R\R\R\R\R{10}0000001\W #2#3\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 + \XINT_rsepbyviii_end_B 2345678\relax\xint_c_ii\xint_c_i + \R\xint:\xint_c_xii \R\xint:\xint_c_x \R\xint:\xint_c_viii \R\xint:\xint_c_vi + \R\xint:\xint_c_iv \R\xint:\xint_c_ii \R\xint:\xint_c_\W \W #1% }% -\def\XINT_mul_pre_b #1.#2\W #3\Z +\def\XINT_mul_pre_b #1\xint:#2\W #3\xint: {% \expandafter\XINT_mul_checklengths - \the\numexpr #1\expandafter.% + \the\numexpr #1\expandafter\xint:% \romannumeral0\expandafter\XINT_sepandrev_andcount \romannumeral0\XINT_zeroes_forviii #3\R\R\R\R\R\R\R\R{10}0000001\W #3\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 - 1\Z!\W #21\Z!% + \XINT_rsepbyviii_end_B 2345678\relax\xint_c_ii\xint_c_i + \R\xint:\xint_c_xii \R\xint:\xint_c_x \R\xint:\xint_c_viii \R\xint:\xint_c_vi + \R\xint:\xint_c_iv \R\xint:\xint_c_ii \R\xint:\xint_c_\W + 1;!\W #21;!% 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W }% % \end{macrocode} % \lverb|Cooking recipe, 2015/10/05.| % \begin{macrocode} -\def\XINT_mul_checklengths #1.#2.% +\def\XINT_mul_checklengths #1\xint:#2\xint:% {% \ifnum #2=\xint_c_i\expandafter\XINT_mul_smallbyfirst\fi \ifnum #1=\xint_c_i\expandafter\XINT_mul_smallbysecond\fi @@ -18946,13 +19599,13 @@ $1$ or $-1$. \fi \XINT_mul_start }% -\def\XINT_mul_smallbyfirst #1\XINT_mul_start 1#2!1\Z!\W +\def\XINT_mul_smallbyfirst #1\XINT_mul_start 1#2!1;!\W {% \ifnum#2=\xint_c_i\expandafter\XINT_mul_oneisone\fi \ifnum#2<\xint_c_xxii\expandafter\XINT_mul_verysmall\fi \expandafter\XINT_mul_out\the\numexpr\XINT_smallmul 1#2!% }% -\def\XINT_mul_smallbysecond #1\XINT_mul_start #2\W 1#3!1\Z!% +\def\XINT_mul_smallbysecond #1\XINT_mul_start #2\W 1#3!1;!% {% \ifnum#3=\xint_c_i\expandafter\XINT_mul_oneisone\fi \ifnum#3<\xint_c_xxii\expandafter\XINT_mul_verysmall\fi @@ -18961,53 +19614,31 @@ $1$ or $-1$. \def\XINT_mul_oneisone #1!{\XINT_mul_out }% \def\XINT_mul_verysmall\expandafter\XINT_mul_out \the\numexpr\XINT_smallmul 1#1!% - {\expandafter\XINT_mul_out\the\numexpr\XINT_verysmallmul 0.#1!}% -\def\XINT_mul_exchange #1\XINT_mul_start #2\W #31\Z!% - {\fi\fi\XINT_mul_start #31\Z!\W #2}% + {\expandafter\XINT_mul_out\the\numexpr\XINT_verysmallmul 0\xint:#1!}% +\def\XINT_mul_exchange #1\XINT_mul_start #2\W #31;!% + {\fi\fi\XINT_mul_start #31;!\W #2}% % \end{macrocode} -% \lverb|1.2c: earlier version of addition had sometimes a final 1!, but not -% in all cases. Version 1.2c of \XINT_add_a always has an ending 1\Z!, which -% is thus expected by \XINT_mul_loop.| +% \lverb|& +% | % \begin{macrocode} \def\XINT_mul_start - {\expandafter\XINT_mul_out\the\numexpr\XINT_mul_loop 100000000!1\Z!\W}% + {\expandafter\XINT_mul_out\the\numexpr\XINT_mul_loop 100000000!1;!\W}% \def\XINT_mul_out {\expandafter\XINT_cuz_small\romannumeral0\XINT_unrevbyviii {}}% % \end{macrocode} -% \lverb|The 1.2 \XINT_mul_loop could *not* be called directly with a small -% multiplicand, due to problems caused in case the addition done in -% \XINT_mul_a produced only 1 block the second one being either empty or a 1! -% which had to be handled by \XINT_mul_loop and \XINT_mul_e. But -% \XINT_mul_loop was only called via \xintiiMul for arguments with at least 2 -% digits in base 10^8, thus no problem. But this made it annoying for -% \xintiiPow and \xintiiSqr which had to check if the intended multiplier had -% only 1 digit in base 10^8. It also made it annoying to create recursive -% algorithms which did multiplications maintaining the result reverses, for -% iterative use of output as input. -% -% Finally on 2015/11/14 during 1.2c preparation I modified the addition to -% *always* have the ending 1\Z!.\numexpr expands even through spaces to find -% operators and even something like 1<space>\Z will try to expand the \Z. Thus -% we have to not forget that #2 in \XINT_mul_e might be \Z! (a #2=1\Z! in -% \XINT_mul_a hence \XINT_add_a is no problem). Again this can only happen if -% we use \XINT_mul_loop directly with a small first argument (in place of -% smallmul). Anyway, now the routine \XINT_mul_loop can handle a small #2, -% with no black magic with delimiters and checking if #1 empty, although it -% never happens when called via \xintiiMul. -% -% The delimiting patterns for addition was changed to use 1\Z! to fit what is -% used on output (by necessity). -% -% Call: \the\numexpr \XINT_mul_loop 100000000!1\Z!\W #11\Z!\W #21\Z!$newline +% \lverb|& +% +%( Call: +%: \the\numexpr \XINT_mul_loop 100000000!1;!\W #11;!\W #21;! +%) % where #1 and #2 are (globally reversed) blocks 1<8d>!. Its is generally more -% efficient to have #1 as the shorter one, but a better recipe is implemented -% in \XINT_mul_checklengths which as executed earlier. One may call -% \XINT_mul_loop directly (but multiplication by zero will produce many -% 100000000! blocks on output). +% efficient if #1 is the shorter one, but a better recipe is implemented in +% \XINT_mul_checklengths. One may call \XINT_mul_loop directly (but +% multiplication by zero will produce many 100000000! blocks on output). % -% Ends after having produced: 1<8d>!....1<8d>!1\Z!. The most significant -% digit block is the last one. It can not be 100000000! except if naturally -% the loop was called with a zero operand. +% Ends after having produced: 1<8d>!....1<8d>!1;!. The last 8-digits block is +% significant one. It can not be 100000000! except if the loop was called with +% a zero operand. % % Thus \XINT_mul_loop can be conveniently called directly in recursive % routines, as the output terminator can serve as input terminator, we can @@ -19015,20 +19646,20 @@ $1$ or $-1$. % \begin{macrocode} \def\XINT_mul_loop #1\W #2\W 1#3!% {% - \xint_gob_til_Z #3\XINT_mul_e \Z + \xint_gob_til_sc #3\XINT_mul_e ;% \expandafter\XINT_mul_a\the\numexpr \XINT_smallmul 1#3!#2\W #1\W #2\W }% % \end{macrocode} -% \lverb|Each of #1 and #2 brings its 1\Z! for \XINT_add_a.| +% \lverb|Each of #1 and #2 brings its 1;! for \XINT_add_a.| % \begin{macrocode} \def\XINT_mul_a #1\W #2\W {% \expandafter\XINT_mul_b\the\numexpr - \XINT_add_a \xint_c_ii #21\Z!1\Z!1\Z!\W #11\Z!1\Z!1\Z!\W\W + \XINT_add_a \xint_c_ii #21;!1;!1;!\W #11;!1;!1;!\W\W }% \def\XINT_mul_b 1#1!{1#1\expandafter!\the\numexpr\XINT_mul_loop }% -\def\XINT_mul_e\Z #1\W 1#2\W #3\W {1\relax #2}% +\def\XINT_mul_e;#1\W 1#2\W #3\W {1\relax #2}% % \end{macrocode} % \lverb|1.2 small and mini multiplication in base 10^8 with carry. Used by % the main multiplication routines. But division, float factorial, etc.. have @@ -19040,63 +19671,63 @@ $1$ or $-1$. % new 8digits carry as argument. The \XINT_smallmul_a fetches a new 1<8d>! % block to multiply, and calls back \XINT_minimul_wc having stored the % multiplicand for re-use later. When the loop terminates, the final carry is -% checked for being nul, and in all cases the output is terminated by a 1\Z! +% checked for being nul, and in all cases the output is terminated by a 1;! % % Multiplication by zero will produce blocks of zeros.| % \begin{macrocode} -\def\XINT_minimulwc_a 1#1.#2.#3!#4#5#6#7#8.% +\def\XINT_minimulwc_a 1#1\xint:#2\xint:#3!#4#5#6#7#8\xint:% {% \expandafter\XINT_minimulwc_b - \the\numexpr \xint_c_x^ix+#1+#3*#8.#3*#4#5#6#7+#2*#8.#2*#4#5#6#7.% + \the\numexpr \xint_c_x^ix+#1+#3*#8\xint: + #3*#4#5#6#7+#2*#8\xint: + #2*#4#5#6#7\xint:% }% -\def\XINT_minimulwc_b 1#1#2#3#4#5#6.#7.% +\def\XINT_minimulwc_b 1#1#2#3#4#5#6\xint:#7\xint:% {% \expandafter\XINT_minimulwc_c - \the\numexpr \xint_c_x^ix+#1#2#3#4#5+#7.#6.% + \the\numexpr \xint_c_x^ix+#1#2#3#4#5+#7\xint:#6\xint:% }% -\def\XINT_minimulwc_c 1#1#2#3#4#5#6.#7.#8.% +\def\XINT_minimulwc_c 1#1#2#3#4#5#6\xint:#7\xint:#8\xint:% {% 1#6#7\expandafter!% \the\numexpr\expandafter\XINT_smallmul_a - \the\numexpr \xint_c_x^viii+#1#2#3#4#5+#8.% + \the\numexpr \xint_c_x^viii+#1#2#3#4#5+#8\xint:% }% -\def\XINT_smallmul 1#1#2#3#4#5!{\XINT_smallmul_a 100000000.#1#2#3#4.#5!}% -\def\XINT_smallmul_a #1.#2.#3!1#4!% +\def\XINT_smallmul 1#1#2#3#4#5!{\XINT_smallmul_a 100000000\xint:#1#2#3#4\xint:#5!}% +\def\XINT_smallmul_a #1\xint:#2\xint:#3!1#4!% {% - \xint_gob_til_Z #4\XINT_smallmul_e\Z - \XINT_minimulwc_a #1.#2.#3!#4.#2.#3!% + \xint_gob_til_sc #4\XINT_smallmul_e;% + \XINT_minimulwc_a #1\xint:#2\xint:#3!#4\xint:#2\xint:#3!% }% -\def\XINT_smallmul_e\Z\XINT_minimulwc_a 1#1.#2\Z #3!% - {\xint_gob_til_eightzeroes #1\XINT_smallmul_f 000000001\relax #1!1\Z!}% +\def\XINT_smallmul_e;\XINT_minimulwc_a 1#1\xint:#2;#3!% + {\xint_gob_til_eightzeroes #1\XINT_smallmul_f 000000001\relax #1!1;!}% \def\XINT_smallmul_f 000000001\relax 00000000!1{1\relax}% % \end{macrocode} -% \lverb|This is multiplication by 1 up to 21. Last time I checked it is never -% called with a wasteful multiplicand of 1. Here also always the output -% terminated by a 1\Z! and the last block of digits is not zero. I imagine -% multiplication by zero produces blocks of zeroes. Will check another day.| +% \lverb|& +% | % \begin{macrocode} -\def\XINT_verysmallmul #1.#2!1#3!% +\def\XINT_verysmallmul #1\xint:#2!1#3!% {% - \xint_gob_til_Z #3\XINT_verysmallmul_e\Z + \xint_gob_til_sc #3\XINT_verysmallmul_e;% \expandafter\XINT_verysmallmul_a - \the\numexpr #2*#3+#1.#2!% + \the\numexpr #2*#3+#1\xint:#2!% }% -\def\XINT_verysmallmul_e\Z\expandafter\XINT_verysmallmul_a\the\numexpr - #1+#2#3.#4!% -{\xint_gob_til_zero #2\XINT_verysmallmul_f 0\xint_c_x^viii+#2#3!1\Z!}% +\def\XINT_verysmallmul_e;\expandafter\XINT_verysmallmul_a\the\numexpr + #1+#2#3\xint:#4!% +{\xint_gob_til_zero #2\XINT_verysmallmul_f 0\xint_c_x^viii+#2#3!1;!}% \def\XINT_verysmallmul_f #1!1{1\relax}% -\def\XINT_verysmallmul_a #1#2.% +\def\XINT_verysmallmul_a #1#2\xint:% {% \unless\ifnum #1#2<\xint_c_x^ix \expandafter\XINT_verysmallmul_bi\else \expandafter\XINT_verysmallmul_bj\fi - \the\numexpr \xint_c_x^ix+#1#2.% + \the\numexpr \xint_c_x^ix+#1#2\xint:% }% \def\XINT_verysmallmul_bj{\expandafter\XINT_verysmallmul_cj }% -\def\XINT_verysmallmul_cj 1#1#2.% - {1#2\expandafter!\the\numexpr\XINT_verysmallmul #1.}% -\def\XINT_verysmallmul_bi\the\numexpr\xint_c_x^ix+#1#2#3.% - {1#3\expandafter!\the\numexpr\XINT_verysmallmul #1#2.}% +\def\XINT_verysmallmul_cj 1#1#2\xint:% + {1#2\expandafter!\the\numexpr\XINT_verysmallmul #1\xint:}% +\def\XINT_verysmallmul_bi\the\numexpr\xint_c_x^ix+#1#2#3\xint:% + {1#3\expandafter!\the\numexpr\XINT_verysmallmul #1#2\xint:}% % \end{macrocode} % \lverb|Used by division and by squaring, not by multiplication itself. % @@ -19104,400 +19735,21 @@ $1$ or $-1$. % format <4 high digits>.<4 low digits>!<8 digits>!, and on output % 1<8d>!1<8d>!, with least significant block first.| % \begin{macrocode} -\def\XINT_minimul_a #1.#2!#3#4#5#6#7!% +\def\XINT_minimul_a #1\xint:#2!#3#4#5#6#7!% {% \expandafter\XINT_minimul_b - \the\numexpr \xint_c_x^viii+#2*#7.#2*#3#4#5#6+#1*#7.#1*#3#4#5#6.% + \the\numexpr \xint_c_x^viii+#2*#7\xint:#2*#3#4#5#6+#1*#7\xint:#1*#3#4#5#6\xint:% }% -\def\XINT_minimul_b 1#1#2#3#4#5.#6.% +\def\XINT_minimul_b 1#1#2#3#4#5\xint:#6\xint:% {% \expandafter\XINT_minimul_c - \the\numexpr \xint_c_x^ix+#1#2#3#4+#6.#5.% + \the\numexpr \xint_c_x^ix+#1#2#3#4+#6\xint:#5\xint:% }% -\def\XINT_minimul_c 1#1#2#3#4#5#6.#7.#8.% +\def\XINT_minimul_c 1#1#2#3#4#5#6\xint:#7\xint:#8\xint:% {% 1#6#7\expandafter!\the\numexpr \xint_c_x^viii+#1#2#3#4#5+#8!% }% % \end{macrocode} -% \subsection{\csh{xintiSqr}, \csh{xintiiSqr}} -% \lverb|Rewritten for 1.2.| -% \begin{macrocode} -\def\xintiiSqr {\romannumeral0\xintiisqr }% -\def\xintiisqr #1% -{% - \expandafter\XINT_sqr\romannumeral0\xintiiabs{#1}\Z -}% -\def\xintiSqr {\romannumeral0\xintisqr }% -\def\xintisqr #1% -{% - \expandafter\XINT_sqr\romannumeral0\xintiabs{#1}\Z -}% -\def\XINT_sqr #1\Z -{% - \expandafter\XINT_sqr_a - \romannumeral0\expandafter\XINT_sepandrev_andcount - \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\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 - \Z -}% -% \end{macrocode} -% \lverb|1.2c \XINT_mul_loop can now be called directly even with small -% arguments, thus the following check is not anymore a necessity.| -% \begin{macrocode} -\def\XINT_sqr_a #1.% -{% - \ifnum #1=\xint_c_i \expandafter\XINT_sqr_small - \else\expandafter\XINT_sqr_start\fi -}% -\def\XINT_sqr_small 1#1#2#3#4#5!\Z -{% - \ifnum #1#2#3#4#5<46341 \expandafter\XINT_sqr_verysmall\fi - \expandafter\XINT_sqr_small_out - \the\numexpr\XINT_minimul_a #1#2#3#4.#5!#1#2#3#4#5!% -}% -\edef\XINT_sqr_verysmall - \expandafter\XINT_sqr_small_out\the\numexpr\XINT_minimul_a #1!#2!% - {\noexpand\expandafter\space\noexpand\the\numexpr #2*#2\relax}% -\def\XINT_sqr_small_out 1#1!1#2!% -{% - \XINT_cuz #2#1\R -}% -% \end{macrocode} -% \lverb|An ending 1\Z! is produced on output for \XINT_mul_loop and gets -% incorporated to the delimiter needed by the \XINT_unrevbyviii done by -% \XINT_mul_out.| -% \begin{macrocode} -\def\XINT_sqr_start #1\Z -{% - \expandafter\XINT_mul_out - \the\numexpr\XINT_mul_loop 100000000!1\Z!\W #11\Z!\W #11\Z!% - 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W -}% -% \end{macrocode} -% \subsection{\csh{xintiPow}, \csh{xintiiPow}} -% \lverb|& -% The exponent is not limited but with current default settings of tex memory, -% with xint 1.2, the maximal exponent for 2^N is N = 2^17 = 131072. -% -% 1.2f Modifies the initial steps: 1) in order to be able to let more easily -% \xintiPow use \xintNum on the exponent once xintfrac.sty is loaded; 2) also -% because I noticed it was not very well coded. And it did only a \numexpr on -% the exponent, contradicting the documentation related to the "i" convention -% in names.| -% \begin{macrocode} -\def\xintiiPow {\romannumeral0\xintiipow }% -\def\xintiipow #1#2% -{% - \expandafter\xint_pow\the\numexpr #2\expandafter.\romannumeral`&&@#1\Z% -}% -\def\xintiPow {\romannumeral0\xintipow }% -\def\xintipow #1#2% -{% - \expandafter\xint_pow\the\numexpr #2\expandafter.\romannumeral0\xintnum{#1}\Z% -}% -\def\xint_pow #1.#2%#3\Z -{% - \xint_UDzerominusfork - #2-\XINT_pow_AisZero - 0#2\XINT_pow_Aneg - 0-{\XINT_pow_Apos #2}% - \krof {#1}% -}% -\def\XINT_pow_AisZero #1#2\Z -{% - \ifcase\XINT_cntSgn #1\Z - \xint_afterfi { 1}% - \or - \xint_afterfi { 0}% - \else - \xint_afterfi {\xintError:DivisionByZero\space 0}% - \fi -}% -\def\XINT_pow_Aneg #1% -{% - \ifodd #1 - \expandafter\XINT_opp\romannumeral0% - \fi - \XINT_pow_Apos {}{#1}% -}% -\def\XINT_pow_Apos #1#2{\XINT_pow_Apos_a {#2}#1}% -\def\XINT_pow_Apos_a #1#2#3% -{% - \xint_gob_til_Z #3\XINT_pow_Apos_short\Z - \XINT_pow_AatleastTwo {#1}#2#3% -}% -\def\XINT_pow_Apos_short\Z\XINT_pow_AatleastTwo #1#2\Z -{% - \ifcase #2 - \xintError:thiscannothappen! - \or \expandafter\XINT_pow_AisOne - \else\expandafter\XINT_pow_AatleastTwo - \fi {#1}#2\Z -}% -\def\XINT_pow_AisOne #1\Z{ 1}% -\def\XINT_pow_AatleastTwo #1% -{% - \ifcase\XINT_cntSgn #1\Z - \expandafter\XINT_pow_BisZero - \or - \expandafter\XINT_pow_I_in - \else - \expandafter\XINT_pow_BisNegative - \fi - {#1}% -}% -\edef\XINT_pow_BisNegative #1\Z - {\noexpand\xintError:FractionRoundedToZero\space 0}% -\def\XINT_pow_BisZero #1\Z{ 1}% -% \end{macrocode} -% \lverb|B = #1 > 0, A = #2 > 1. Earlier code checked if size of B did not -% exceed a given limit (for example 131000).| -% \begin{macrocode} -\def\XINT_pow_I_in #1#2\Z -{% - \expandafter\XINT_pow_I_loop - \the\numexpr #1\expandafter.% - \romannumeral0\expandafter\XINT_sepandrev - \romannumeral0\XINT_zeroes_forviii #2\R\R\R\R\R\R\R\R{10}0000001\W - #2\XINT_rsepbyviii_end_A 2345678% - \XINT_rsepbyviii_end_B 2345678\relax XX% - \R.\R.\R.\R.\R.\R.\R.\R.\W 1\Z!\W - 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W -}% -\def\XINT_pow_I_loop #1.% -{% - \ifnum #1 = \xint_c_i\expandafter\XINT_pow_I_exit\fi - \ifodd #1 - \expandafter\XINT_pow_II_in - \else - \expandafter\XINT_pow_I_squareit - \fi #1.% -}% -\def\XINT_pow_I_exit \ifodd #1\fi #2.#3\W {\XINT_mul_out #3}% -% \end{macrocode} -% \lverb|The 1.2c \XINT_mul_loop can be called directly even with small -% arguments, hence the "butcheckifsmall" is not a necessity as it was earlier -% with 1.2. On 2^30, it does bring roughly a 40$char37 $space time gain -% though, and 30$char37 $space gain for 2^60. The overhead on big computations -% should be negligible.| -% \begin{macrocode} -\def\XINT_pow_I_squareit #1.#2\W% -{% - \expandafter\XINT_pow_I_loop - \the\numexpr #1/\xint_c_ii\expandafter.% - \the\numexpr\XINT_pow_mulbutcheckifsmall #2\W #2\W -}% -\def\XINT_pow_mulbutcheckifsmall #1!1#2% -{% - \xint_gob_til_Z #2\XINT_pow_mul_small\Z - \XINT_mul_loop 100000000!1\Z!\W #1!1#2% -}% -\def\XINT_pow_mul_small\Z \XINT_mul_loop 100000000!1\Z!\W 1#1!1\Z!\W -{% - \XINT_smallmul 1#1!% -}% -\def\XINT_pow_II_in #1.#2\W -{% - \expandafter\XINT_pow_II_loop - \the\numexpr #1/\xint_c_ii-\xint_c_i\expandafter.% - \the\numexpr\XINT_pow_mulbutcheckifsmall #2\W #2\W #2\W -}% -\def\XINT_pow_II_loop #1.% -{% - \ifnum #1 = \xint_c_i\expandafter\XINT_pow_II_exit\fi - \ifodd #1 - \expandafter\XINT_pow_II_odda - \else - \expandafter\XINT_pow_II_even - \fi #1.% -}% -\def\XINT_pow_II_exit\ifodd #1\fi #2.#3\W #4\W -{% - \expandafter\XINT_mul_out - \the\numexpr\XINT_pow_mulbutcheckifsmall #4\W #3% -}% -\def\XINT_pow_II_even #1.#2\W -{% - \expandafter\XINT_pow_II_loop - \the\numexpr #1/\xint_c_ii\expandafter.% - \the\numexpr\XINT_pow_mulbutcheckifsmall #2\W #2\W -}% -\def\XINT_pow_II_odda #1.#2\W #3\W -{% - \expandafter\XINT_pow_II_oddb - \the\numexpr #1/\xint_c_ii-\xint_c_i\expandafter.% - \the\numexpr\XINT_pow_mulbutcheckifsmall #3\W #2\W #2\W -}% -\def\XINT_pow_II_oddb #1.#2\W #3\W -{% - \expandafter\XINT_pow_II_loop - \the\numexpr #1\expandafter.% - \the\numexpr\XINT_pow_mulbutcheckifsmall #3\W #3\W #2\W -}% -% \end{macrocode} -% \subsection{\csh{xintiFac}, \csh{xintiiFac}} -% \lverb|Moved here from xint.sty with release 1.2 (to be usable by \bnumexpr). -% -% The routine has been partially rewritten with release 1.2 to exploit the new -% inner structure of multiplication. I impose an intrinsic limit of the -% argument at maximal value 9999 (1.2f sets it at 10000, there was no reason -% for 9999 and not 10000). Anyhow with current default settings of the -% etex memory and the current 1.2 routine (last commit: eada1b1), the maximal -% possible computation is 5971! (which has 19956 digits). Also, I add -% \xintiiFac which does only \romannumeral-`0 and not \numexpr on its -% argument. This is for a silly slight optimization of the \xintiiexpr (and -% \bnumexpr) parsers. If the argument is >=2^31 an arithmetic overflow will -% occur in the \ifnum. This is not as good as in the \numexpr, but well. -% -% 2015/11/14 added note on the implementation: we can roughly estimate for big -% n that we do n/2 multiplications alpha*X where alpha=(k+1)(k+2)<10^8 and -% X=k! has size of order k log(k), with k along a step 2 arithmetic sequence -% up to n. Each small multiplication should have a linear cost hence O(k -% log(k)) (as we maintain the reversed representation) hence a total cost of -% O(n^2 log(n)); on computing n! for n=100, 200, ..., 2000 I obtained a good -% fit (only roughly 20$char37 $space variation) of the computation time with -% the square of the length of n! -- to the extent that the big variability of -% \pdfelapsedtime allows to draw any conclusion -- I did not repeat the -% computations as many times as I should have. I currently do not quite -% understand why in this range it seems computation times are better fitted by -% O(n^2 log^2 n) than by O(n^2 log n). True, final reverse is O(N^2) with N of -% order n log n, but for this range of n's this is marginal (and I tested also -% with this final reverse skipped). -% -% On the other hand with an approach based on binary splitting n!=AB and -% A=[n/2]! each of A and B will be of size n/2 log(n), but xint schoolbook -% multiplication in TeX is worse than quadratic due to penalty when TeX needs -% to fetch arguments and it didn't seem promising. I didn't even test. Binary -% splitting is good when a fast multiplication is available. -% -% No wait! incredibly a very naive recursive implementation with five lines of -% code via a binary splitting approach with \xintiiMul is only about 1.6x--2x -% slower in the range N=200 to 2000 ! this seems to say that the reversing -% done by \xintiiMul both on input and for output is quite efficient. The best -% case seems to be around N=1000, hence multiplication of 500 digits numbers, -% after that the impact of over-quadratic computation time seems to show: for -% N=4000, the naive binary splitting approach is about 3.4x slower than the -% naive iterated small multiplications as here (naturally with sub-quadratic -% multiplication that would be otherwise). -% -% -% 2015/11/29 for 1.2f: no more a \xintFac, only \xintiFac/\xintiiFac. I could -% not go on like this with \xintFac/\xintiFac/\xintiiFac.| -% \begin{macrocode} -\def\xintiiFac {\romannumeral0\xintiifac }% -\def\xintiifac #1{\expandafter\XINT_fac_fork\the\numexpr#1.}% -\def\xintiFac {\romannumeral0\xintifac }% -\let\xintifac\xintiifac -% \end{macrocode} -% \lverb|Vieux style. Bon je modifie pour 1.2f. Le cas négatif devrait faire -% un 1/0 et créer un Inf.| -% \begin{macrocode} -\def\XINT_fac_fork #1#2.% -{% - \xint_UDzerominusfork - #1-\XINT_fac_zero - 0#1\XINT_fac_neg - 0-\XINT_fac_checksize - \krof #1#2.% -}% -\def\XINT_fac_zero #1.{ 1}% -\edef\XINT_fac_neg #1.{\noexpand\xintError:FactorialOfNegative\space 1}% -\def\XINT_fac_checksize #1.% -{% - \ifnum #1>\xint_c_x^iv - \xint_dothis{\expandafter\xintError:TooBigFactorial - \expandafter\space\expandafter 1\xint_gob_til_W }\fi - \ifnum #1>465 \xint_dothis{\XINT_fac_bigloop_a #1.}\fi - \ifnum #1>101 \xint_dothis{\XINT_fac_medloop_a #1.\XINT_mul_out}\fi - \xint_orthat{\XINT_fac_smallloop_a #1.\XINT_mul_out}% - 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W -}% -\def\XINT_fac_bigloop_a #1.% -{% - \expandafter\XINT_fac_bigloop_b \the\numexpr - #1+\xint_c_i-\xint_c_ii*((#1-464)/\xint_c_ii).#1.% -}% -\def\XINT_fac_bigloop_b #1.#2.% -{% - \expandafter\XINT_fac_medloop_a - \the\numexpr #1-\xint_c_i.{\XINT_fac_bigloop_loop #1.#2.}% -}% -\def\XINT_fac_bigloop_loop #1.#2.% -{% - \ifnum #1>#2 \expandafter\XINT_fac_bigloop_exit\fi - \expandafter\XINT_fac_bigloop_loop - \the\numexpr #1+\xint_c_ii\expandafter.% - \the\numexpr #2\expandafter.\the\numexpr\XINT_fac_bigloop_mul #1!% -}% -\def\XINT_fac_bigloop_exit #1!{\XINT_mul_out}% -\def\XINT_fac_bigloop_mul #1!% -{% - \expandafter\XINT_smallmul - \the\numexpr \xint_c_x^viii+#1*(#1+\xint_c_i)!% -}% -\def\XINT_fac_medloop_a #1.% -{% - \expandafter\XINT_fac_medloop_b - \the\numexpr #1+\xint_c_i-\xint_c_iii*((#1-100)/\xint_c_iii).#1.% -}% -\def\XINT_fac_medloop_b #1.#2.% -{% - \expandafter\XINT_fac_smallloop_a - \the\numexpr #1-\xint_c_i.{\XINT_fac_medloop_loop #1.#2.}% -}% -\def\XINT_fac_medloop_loop #1.#2.% -{% - \ifnum #1>#2 \expandafter\XINT_fac_loop_exit\fi - \expandafter\XINT_fac_medloop_loop - \the\numexpr #1+\xint_c_iii\expandafter.% - \the\numexpr #2\expandafter.\the\numexpr\XINT_fac_medloop_mul #1!% -}% -\def\XINT_fac_medloop_mul #1!% -{% - \expandafter\XINT_smallmul - \the\numexpr - \xint_c_x^viii+#1*(#1+\xint_c_i)*(#1+\xint_c_ii)!% -}% -\def\XINT_fac_smallloop_a #1.% -{% - \csname - XINT_fac_smallloop_\the\numexpr #1-\xint_c_iv*(#1/\xint_c_iv)\relax - \endcsname #1.% -}% -\expandafter\def\csname XINT_fac_smallloop_1\endcsname #1.% -{% - \XINT_fac_smallloop_loop 2.#1.100000001!1\Z!% -}% -\expandafter\def\csname XINT_fac_smallloop_-2\endcsname #1.% -{% - \XINT_fac_smallloop_loop 3.#1.100000002!1\Z!% -}% -\expandafter\def\csname XINT_fac_smallloop_-1\endcsname #1.% -{% - \XINT_fac_smallloop_loop 4.#1.100000006!1\Z!% -}% -\expandafter\def\csname XINT_fac_smallloop_0\endcsname #1.% -{% - \XINT_fac_smallloop_loop 5.#1.1000000024!1\Z!% -}% -\def\XINT_fac_smallloop_loop #1.#2.% -{% - \ifnum #1>#2 \expandafter\XINT_fac_loop_exit\fi - \expandafter\XINT_fac_smallloop_loop - \the\numexpr #1+\xint_c_iv\expandafter.% - \the\numexpr #2\expandafter.\the\numexpr\XINT_fac_smallloop_mul #1!% -}% -\def\XINT_fac_smallloop_mul #1!% -{% - \expandafter\XINT_smallmul - \the\numexpr - \xint_c_x^viii+#1*(#1+\xint_c_i)*(#1+\xint_c_ii)*(#1+\xint_c_iii)!% -}% -\def\XINT_fac_loop_exit #1!#2\Z!#3{#3#2\Z!}% -% \end{macrocode} % \subsection{\csh{xintiDivision}, \csh{xintiQuo}, \csh{xintiRem}, % \csh{xintiiDivision}, \csh{xintiiQuo}, \csh{xintiiRem}} % \lverb|Completely rewritten for 1.2. @@ -19518,12 +19770,8 @@ $1$ or $-1$. % parameters now need handle less such parameters. Thus, some rationale for % the way the code was structured has disappeared. % -% 1.2 2015/10/15 had a bad bug which got corrected in 1.2b of 2015/10/29: a -% divisor starting with 99999999xyz... would cause a failure, simply because -% it was attempted to use the \XINT_div_mini routine with a divisor of -% 1+99999999=100000000 having 9 digits. Fortunately the origin of the bug was -% easy to find out. Too bad that my obviously very deficient test files -% did not detect it.| +% +% 1.2l: \xintiiDivision et al. made robust against non terminated input.| % \begin{macrocode} \def\xintiiQuo {\romannumeral0\xintiiquo }% \def\xintiiRem {\romannumeral0\xintiirem }% @@ -19540,26 +19788,29 @@ $1$ or $-1$. % euclidienne de A par B: A=BQ+R, 0<= R < |B|.- % \begin{macrocode} \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% - \romannumeral0\xintnum{#3}\Z #2\Z }% +\def\xintidivision #1{\expandafter\XINT_idivision\romannumeral0\xintnum{#1}\xint:}% +\def\XINT_idivision #1#2\xint:#3{\expandafter\XINT_iidivision_a\expandafter #1% + \romannumeral0\xintnum{#3}\xint:#2\xint:}% \def\xintiiDivision {\romannumeral0\xintiidivision }% -\def\xintiidivision #1{\expandafter\XINT_iidivision \romannumeral`&&@#1\Z }% -\def\XINT_iidivision #1#2\Z #3{\expandafter\XINT_iidivision_a\expandafter #1% - \romannumeral`&&@#3\Z #2\Z }% +\def\xintiidivision #1{\expandafter\XINT_iidivision \romannumeral`&&@#1\xint:}% +\def\XINT_iidivision #1#2\xint:#3{\expandafter\XINT_iidivision_a\expandafter #1% + \romannumeral`&&@#3\xint:#2\xint:}% % \end{macrocode} % \lverb|On regarde les signes de A et de B.| % \begin{macrocode} \def\XINT_iidivision_a #1#2% #1 de A, #2 de B. {% - \if0#2\xint_dothis\XINT_iidivision_divbyzero\fi + \if0#2\xint_dothis{\XINT_iidivision_divbyzero #1#2}\fi \if0#1\xint_dothis\XINT_iidivision_aiszero\fi \if-#2\xint_dothis{\expandafter\XINT_iidivision_bneg \romannumeral0\XINT_iidivision_bpos #1}\fi \xint_orthat{\XINT_iidivision_bpos #1#2}% }% -\def\XINT_iidivision_divbyzero #1\Z #2\Z {\xintError:DivisionByZero{0}{0}}% -\def\XINT_iidivision_aiszero #1\Z #2\Z {{0}{0}}% +\def\XINT_iidivision_divbyzero#1#2#3\xint:#4\xint: + {\if0#1\xint_dothis{\XINT_signalcondition{DivisionUndefined}}\fi + \xint_orthat{\XINT_signalcondition{DivisionByZero}}% + {Division of #1#4 by #2#3}{}{{0}{0}}}% +\def\XINT_iidivision_aiszero #1\xint:#2\xint:{{0}{0}}% \def\XINT_iidivision_bneg #1% q->-q, r unchanged {\expandafter{\romannumeral0\XINT_opp #1}}% \def\XINT_iidivision_bpos #1% @@ -19578,11 +19829,11 @@ $1$ or $-1$. % négatif. Je n'ai pas fait beaucoup d'efforts pour être un minimum efficace % si A ou B n'est pas positif.| % \begin{macrocode} -\def\XINT_iidivision_apos #1#2\Z #3\Z{\XINT_div_prepare {#2}{#1#3}}% -\def\XINT_iidivision_aneg #1\Z #2\Z +\def\XINT_iidivision_apos #1#2\xint:#3\xint:{\XINT_div_prepare {#2}{#1#3}}% +\def\XINT_iidivision_aneg #1\xint:#2\xint: {\expandafter \XINT_iidivision_aneg_b\romannumeral0\XINT_div_prepare {#1}{#2}{#1}}% -\def\XINT_iidivision_aneg_b #1#2{\if0\XINT_Sgn #2\Z +\def\XINT_iidivision_aneg_b #1#2{\if0\XINT_Sgn #2\xint: \expandafter\XINT_iidivision_aneg_rzero \else \expandafter\XINT_iidivision_aneg_rpos @@ -19596,7 +19847,7 @@ $1$ or $-1$. \def\XINT_iidivision_aneg_end #1#2#3% {% \expandafter\xint_exchangetwo_keepbraces - \expandafter{\romannumeral0\XINT_sub_mm_a {}{}#3\Z #2\Z}{#1}% r-> b-r + \expandafter{\romannumeral0\XINT_sub_mm_a {}{}#3\xint:#2\xint:}{#1}% r-> b-r }% % \end{macrocode} % \lverb|Le diviseur B va être étendu par des zéros pour que sa longueur soit @@ -19645,7 +19896,7 @@ $1$ or $-1$. {% \expandafter\XINT_div_small_b \the\numexpr #1/\xint_c_ii\expandafter - .\the\numexpr \xint_c_x^viii+#1\expandafter!% + \xint:\the\numexpr \xint_c_x^viii+#1\expandafter!% \romannumeral0% \XINT_div_small_ba #2\R\R\R\R\R\R\R\R{10}0000001\W #2\XINT_sepbyviii_Z_end 2345678\relax @@ -19677,18 +19928,18 @@ $1$ or $-1$. \the\numexpr\expandafter\XINT_sepbyviii_Z \romannumeral0\XINT_zeroes_forviii #1\R #2\relax {{\XINT_div_dosmallsmall}{#1}}% -\def\XINT_div_dosmallsmall #1.1#2!#3% +\def\XINT_div_dosmallsmall #1\xint:1#2!#3% {% \expandafter\XINT_div_smallsmallend - \the\numexpr (#3+#1)/#2-\xint_c_i.#2.#3.% + \the\numexpr (#3+#1)/#2-\xint_c_i\xint:#2\xint:#3\xint:% }% -\def\XINT_div_smallsmallend #1.#2.#3.{\expandafter +\def\XINT_div_smallsmallend #1\xint:#2\xint:#3\xint:{\expandafter {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #3-#1*#2}}% % \end{macrocode} -% \lverb|Si A>=10^8, il est maintenant sous la forme 1<8d>!...1<8d>!1\Z! avec +% \lverb|Si A>=10^8, il est maintenant sous la forme 1<8d>!...1<8d>!1;! avec % plus significatifs en premier. Donc on poursuit par$newline % \expandafter\XINT_sdiv_out\the\numexpr\XINT_smalldivx_a -% x.1B!1<8d>!...1<8d>!1\Z! avec x =round(B/2), 1B=10^8+B.| +% x.1B!1<8d>!...1<8d>!1;! avec x =round(B/2), 1B=10^8+B.| % \begin{macrocode} \def\XINT_div_dosmalldiv {{\expandafter\XINT_sdiv_out\the\numexpr\XINT_smalldivx_a}}% @@ -19722,17 +19973,16 @@ $1$ or $-1$. {% \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 + \xint:\the\numexpr (#1#2#3#4#5#6#7#8+\xint_c_i)/\xint_c_ii\expandafter + \xint:\the\numexpr #1#2#3#4#5#6#7#8\expandafter + \xint:\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 + \XINT_rsepbyviii_end_B 2345678\relax\xint_c_ii\xint_c_i + \R\xint:\xint_c_xii \R\xint:\xint_c_x \R\xint:\xint_c_viii \R\xint:\xint_c_vi + \R\xint:\xint_c_iv \R\xint:\xint_c_ii \R\xint:\xint_c_\W \X }% -\def\XINT_div_prepare_g #1.#2.#3.#4.#5\X #6#7#8% +\def\XINT_div_prepare_g #1\xint:#2\xint:#3\xint:#4\xint:#5\X #6#7#8% {% \expandafter\XINT_div_prepare_h \the\numexpr\expandafter\XINT_sepbyviii_andcount @@ -19742,7 +19992,7 @@ $1$ or $-1$. \xint_c_iii!\xint_c_ii!\xint_c_i!\xint_c_\W {#1}{#2}{#3}{#4}{#5}{#6}% }% -\def\XINT_div_prepare_h #11.#2.#3#4#5#6%#7#8% +\def\XINT_div_prepare_h #11\xint:#2\xint:#3#4#5#6%#7#8% {% \XINT_div_start_a {#2}{#6}{#1}{#3}{#4}{#5}%{#7}{#8}% }% @@ -19765,23 +20015,23 @@ $1$ or $-1$. {% \expandafter\XINT_div_zeroQ_end \romannumeral0\XINT_unsep_cuzsmall - #31\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W .% + #3\xint_bye!2!3!4!5!6!7!8!9!\xint_bye\xint_c_i\relax\xint: }% -\def\XINT_div_zeroQ_end #1.#2% - {\expandafter{\expandafter0\expandafter}\XINT_div_cleanR #1#2.}% +\def\XINT_div_zeroQ_end #1\xint:#2% + {\expandafter{\expandafter0\expandafter}\XINT_div_cleanR #1#2\xint:}% % \end{macrocode} % \lverb|L, K, A, x',y,x, B, «c»->K.A.x{LK{x'y}x}B«c»| % \begin{macrocode} \def\XINT_div_start_b #1#2#3#4#5#6% {% \expandafter\XINT_div_finish\the\numexpr - \XINT_div_start_c {#2}.#3.{#6}{{#1}{#2}{{#4}{#5}}{#6}}% + \XINT_div_start_c {#2}\xint:#3\xint:{#6}{{#1}{#2}{{#4}{#5}}{#6}}% }% \def\XINT_div_finish {% \expandafter\XINT_div_finish_a \romannumeral`&&@\XINT_div_unsepQ }% -\def\XINT_div_finish_a #1\Z #2.{\XINT_div_finish_b #2.{#1}}% +\def\XINT_div_finish_a #1\Z #2\xint:{\XINT_div_finish_b #2\xint:{#1}}% % \end{macrocode} % \lverb|Ici ce sont routines de fin. Le reste déjà nettoyé. R.Q«c».| % \begin{macrocode} @@ -19794,12 +20044,12 @@ $1$ or $-1$. \fi #1% }% -\def\XINT_div_finish_bRzero 0.#1#2{{#1}{0}}% -\def\XINT_div_finish_bRpos #1.#2#3% +\def\XINT_div_finish_bRzero 0\xint:#1#2{{#1}{0}}% +\def\XINT_div_finish_bRpos #1\xint:#2#3% {% - \expandafter\xint_exchangetwo_keepbraces\XINT_div_cleanR #1#3.{#2}% + \expandafter\xint_exchangetwo_keepbraces\XINT_div_cleanR #1#3\xint:{#2}% }% -\def\XINT_div_cleanR #100000000.{{#1}}% +\def\XINT_div_cleanR #100000000\xint:{{#1}}% % \end{macrocode} % \lverb|Kalpha.A.x{LK{x'y}x}, B, «c», au début #2=alpha est vide. On fait une % boucle pour prendre K unités de A (on a au moins L égal à K) et les mettre @@ -19813,31 +20063,31 @@ $1$ or $-1$. \expandafter\XINT_div_start_cb \fi {#1}% }% -\def\XINT_div_start_ca #1#2.#3!#4!#5!#6!#7!#8!#9!% +\def\XINT_div_start_ca #1#2\xint:#3!#4!#5!#6!#7!#8!#9!% {% \expandafter\XINT_div_start_c\expandafter - {\the\numexpr #1-\xint_c_vii}#2#3!#4!#5!#6!#7!#8!#9!.% + {\the\numexpr #1-\xint_c_vii}#2#3!#4!#5!#6!#7!#8!#9!\xint:% }% \def\XINT_div_start_cb #1% {\csname XINT_div_start_c_\romannumeral\numexpr#1\endcsname}% -\def\XINT_div_start_c_i #1.#2!% - {\XINT_div_start_c_ #1#2!.}% -\def\XINT_div_start_c_ii #1.#2!#3!% - {\XINT_div_start_c_ #1#2!#3!.}% -\def\XINT_div_start_c_iii #1.#2!#3!#4!% - {\XINT_div_start_c_ #1#2!#3!#4!.}% -\def\XINT_div_start_c_iv #1.#2!#3!#4!#5!% - {\XINT_div_start_c_ #1#2!#3!#4!#5!.}% -\def\XINT_div_start_c_v #1.#2!#3!#4!#5!#6!% - {\XINT_div_start_c_ #1#2!#3!#4!#5!#6!.}% -\def\XINT_div_start_c_vi #1.#2!#3!#4!#5!#6!#7!% - {\XINT_div_start_c_ #1#2!#3!#4!#5!#6!#7!.}% +\def\XINT_div_start_c_i #1\xint:#2!% + {\XINT_div_start_c_ #1#2!\xint:}% +\def\XINT_div_start_c_ii #1\xint:#2!#3!% + {\XINT_div_start_c_ #1#2!#3!\xint:}% +\def\XINT_div_start_c_iii #1\xint:#2!#3!#4!% + {\XINT_div_start_c_ #1#2!#3!#4!\xint:}% +\def\XINT_div_start_c_iv #1\xint:#2!#3!#4!#5!% + {\XINT_div_start_c_ #1#2!#3!#4!#5!\xint:}% +\def\XINT_div_start_c_v #1\xint:#2!#3!#4!#5!#6!% + {\XINT_div_start_c_ #1#2!#3!#4!#5!#6!\xint:}% +\def\XINT_div_start_c_vi #1\xint:#2!#3!#4!#5!#6!#7!% + {\XINT_div_start_c_ #1#2!#3!#4!#5!#6!#7!\xint:}% % \end{macrocode} % \lverb|#1=a, #2=alpha (de longueur K, à l'endroit).#3=reste de A.#4=x, % #5={LK{x'y}x},#6=B,«c» -> a, x, alpha, B, {00000000}, L, K, {x'y},x, % alpha'=reste de A, B«c».| % \begin{macrocode} -\def\XINT_div_start_c_ 1#1!#2.#3.#4#5#6% +\def\XINT_div_start_c_ 1#1!#2\xint:#3\xint:#4#5#6% {% \XINT_div_I_a {#1}{#4}{1#1!#2}{#6}{00000000}#5{#3}{#6}% }% @@ -19847,7 +20097,7 @@ $1$ or $-1$. % \begin{macrocode} \def\XINT_div_I_a #1#2% {% - \expandafter\XINT_div_I_b\the\numexpr #1/#2.{#1}{#2}% + \expandafter\XINT_div_I_b\the\numexpr #1/#2\xint:{#1}{#2}% }% \def\XINT_div_I_b #1% {% @@ -19858,15 +20108,15 @@ $1$ or $-1$. % {x'y}, x, alpha', B«c» -> on lâche un q puis {alpha} L, K, {x'y}, x, % alpha', B«c».| % \begin{macrocode} -\def\XINT_div_I_czero 0\XINT_div_I_c 0.#1#2#3#4#5{1#5\XINT_div_I_g {#3}}% -\def\XINT_div_I_c #1.#2#3% +\def\XINT_div_I_czero 0\XINT_div_I_c 0\xint:#1#2#3#4#5{1#5\XINT_div_I_g {#3}}% +\def\XINT_div_I_c #1\xint:#2#3% {% - \expandafter\XINT_div_I_da\the\numexpr #2-#1*#3.#1.{#2}{#3}% + \expandafter\XINT_div_I_da\the\numexpr #2-#1*#3\xint:#1\xint:{#2}{#3}% }% % \end{macrocode} % \lverb|r.q.alpha, B, q0, L, K, {x'y}, x, alpha', B«c»| % \begin{macrocode} -\def\XINT_div_I_da #1.% +\def\XINT_div_I_da #1\xint:% {% \ifnum #1>\xint_c_ix \expandafter\XINT_div_I_dP @@ -19881,16 +20131,16 @@ $1$ or $-1$. % \end{macrocode} % \lverb|attention très mauvaises notations avec _b et _db.| % \begin{macrocode} -\def\XINT_div_I_dN #1.% +\def\XINT_div_I_dN #1\xint:% {% - \expandafter\XINT_div_I_b\the\numexpr #1-\xint_c_i.% + \expandafter\XINT_div_I_b\the\numexpr #1-\xint_c_i\xint:% }% -\def\XINT_div_I_db #1.#2#3#4#5% +\def\XINT_div_I_db #1\xint:#2#3#4#5% {% \expandafter\XINT_div_I_dc\expandafter #1% \romannumeral0\expandafter\XINT_div_sub\expandafter {\romannumeral0\XINT_rev_nounsep {}#4\R!\R!\R!\R!\R!\R!\R!\R!\W}% - {\the\numexpr\XINT_div_verysmallmul #1!#51\Z!}% + {\the\numexpr\XINT_div_verysmallmul #1!#51;!}% \Z {#4}{#5}% }% % \end{macrocode} @@ -19905,7 +20155,7 @@ $1$ or $-1$. \def\XINT_div_I_dd #1-\Z {% \if #11\expandafter\XINT_div_I_dz\fi - \expandafter\XINT_div_I_dP\the\numexpr #1-\xint_c_i.XX% + \expandafter\XINT_div_I_dP\the\numexpr #1-\xint_c_i\xint: XX% }% \def\XINT_div_I_dz #1XX#2#3#4% {% @@ -19916,12 +20166,12 @@ $1$ or $-1$. % \lverb|q.alpha, B, q0, L, K, {x'y},x, alpha'B«c» (q=0 has been intercepted) % -> 1nouveauq.nouvel alpha, L, K, {x'y}, x, alpha',B«c»| % \begin{macrocode} -\def\XINT_div_I_dP #1.#2#3#4#5#6% +\def\XINT_div_I_dP #1\xint:#2#3#4#5#6% {% 1#6+#1\expandafter\XINT_div_I_g\expandafter {\romannumeral0\expandafter\XINT_div_sub\expandafter {\romannumeral0\XINT_rev_nounsep {}#4\R!\R!\R!\R!\R!\R!\R!\R!\W}% - {\the\numexpr\XINT_div_verysmallmul #1!#51\Z!}% + {\the\numexpr\XINT_div_verysmallmul #1!#51;!}% }% }% % \end{macrocode} @@ -19939,26 +20189,27 @@ $1$ or $-1$. \else \expandafter\XINT_div_I_h \fi - {#4}#1.#6.{{#4}{#5}{#3}{#2}}{#7}% + {#4}#1\xint:#6\xint:{{#4}{#5}{#3}{#2}}{#7}% }% % \end{macrocode} % \lverb|{x'y}alpha.alpha'.{{x'y}xKL}B«c» -> Attention retour à l'envoyeur ici % par terminaison des \the\numexpr. On doit reprendre le Q déjà sorti, qui n'a % plus de séparateurs, ni de leading 1. Ensuite R sans leading zeros.«c»| % \begin{macrocode} -\def\XINT_div_exittofinish #1#2.#3.#4#5% +\def\XINT_div_exittofinish #1#2\xint:#3\xint:#4#5% {% - 1\expandafter\expandafter\expandafter!\expandafter\XINT_unsep_delim - \romannumeral0\XINT_div_unsepR #2#31\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W.% + 1\expandafter\expandafter\expandafter!\expandafter\XINT_div_unsepQ_delim + \romannumeral0\XINT_div_unsepR #2#3% + \xint_bye!2!3!4!5!6!7!8!9!\xint_bye\xint_c_i\relax\R\xint: }% % \end{macrocode} % \lverb|ATTENTION DESCRIPTION OBSOLÈTE. #1={x'y}alpha.#2!#3=reste de A. % #4={{x'y},x,K,L},#5=B,«c» devient {x'y},alpha sur K+4 chiffres.B, % {{x'y},x,K,L}, #6= nouvel alpha',B,«c»| % \begin{macrocode} -\def\XINT_div_I_h #1.#2!#3.#4#5% +\def\XINT_div_I_h #1\xint:#2!#3\xint:#4#5% {% - \XINT_div_II_b #1#2!.{#5}{#4}{#3}{#5}% + \XINT_div_II_b #1#2!\xint:{#5}{#4}{#3}{#5}% }% % \end{macrocode} % \lverb|{x'y}alpha.B, {{x'y},x,K,L}, nouveau alpha',B,«c»| @@ -19973,7 +20224,7 @@ $1$ or $-1$. % «c» -> {x'y}x,K,L (à diminuer de 4), {alpha sur % K}B{q1=00000000}{alpha'}B,«c»| % \begin{macrocode} -\def\XINT_div_II_skipc 00000000\XINT_div_II_c #1#2#3#4#5.#6#7% +\def\XINT_div_II_skipc 00000000\XINT_div_II_c #1#2#3#4#5\xint:#6#7% {% \XINT_div_II_k #7{#4!#5}{#6}{00000000}% }% @@ -19981,21 +20232,12 @@ $1$ or $-1$. % \lverb|x'ya->1qx'yalpha.B, {{x'y},x,K,L}, nouveau alpha',B, «c». En fait, % attention, ici #3 et #4 sont les 16 premiers chiffres du numérateur,sous la % forme blocs 1<8chiffres>. -% -% ATTENTION! -% -% 2015/10/29 :j'avais introduit un bug ici dans 1.2 2015/10/15, car -% \XINT_div_mini veut un diviseur de huit chiffres, or si le dénominateur B -% débute par x=99999999, on aura x'=100000000, d'où évidemment un bug. Bon il -% faut intercepter x'=100000000. -% -% I need to recognize x'=100000000 in some not too penalizing way. Anyway, -% will try to optimize some other day.| +% | % \begin{macrocode} \def\XINT_div_II_c #1#2#3#4% {% \expandafter\XINT_div_II_d\the\numexpr\XINT_div_xmini - #1.#2!#3!#4!{#1}{#2}#3!#4!% + #1\xint:#2!#3!#4!{#1}{#2}#3!#4!% }% \def\XINT_div_xmini #1% {% @@ -20012,19 +20254,19 @@ $1$ or $-1$. % \end{macrocode} % \lverb|x'=10^8 and we return #1=1<8digits>.| % \begin{macrocode} -\def\XINT_div_xmini_c 0\XINT_div_mini 100000000.50000000!#1!#2!{#1!}% +\def\XINT_div_xmini_c 0\XINT_div_mini 100000000\xint:50000000!#1!#2!{#1!}% % \end{macrocode} % \lverb|1 suivi de q1 sur huit chiffres! #2=x', #3=y, #4=alpha.#5=B, % {{x'y},x,K,L}, alpha', B, «c» --> nouvel alpha.x',y,B,q1,{{x'y},x,K,L}, % alpha', B, «c» | % \begin{macrocode} -\def\XINT_div_II_d 1#1#2#3#4#5!#6#7#8.#9% +\def\XINT_div_II_d 1#1#2#3#4#5!#6#7#8\xint:#9% {% \expandafter\XINT_div_II_e \romannumeral0\expandafter\XINT_div_sub\expandafter {\romannumeral0\XINT_rev_nounsep {}#8\R!\R!\R!\R!\R!\R!\R!\R!\W}% - {\the\numexpr\XINT_div_smallmul_a 100000000.#1#2#3#4.#5!#91\Z!}% - .{#6}{#7}{#9}{#1#2#3#4#5}% + {\the\numexpr\XINT_div_smallmul_a 100000000\xint:#1#2#3#4\xint:#5!#91;!}% + \xint:{#6}{#7}{#9}{#1#2#3#4#5}% }% % \end{macrocode} % \lverb|alpha.x',y,B,q1, {{x'y},x,K,L}, alpha', B, «c». Attention la @@ -20036,11 +20278,11 @@ $1$ or $-1$. \XINT_div_II_f 1#1!% }% % \end{macrocode} -% \lverb|100000000!alpha sur K chiffres.#2=x',#3=y,#4=B,#5=q1, #6={{x'y},x,K,L}, +% \lverb|100000000! alpha sur K chiffres.#2=x',#3=y,#4=B,#5=q1, #6={{x'y},x,K,L}, % #7=alpha',B«c» -> {x'y}x,K,L (à diminuer de 1), % {alpha sur K}B{q1}{alpha'}B«c»| % \begin{macrocode} -\def\XINT_div_II_skipf 00000000\XINT_div_II_f 100000000!#1.#2#3#4#5#6% +\def\XINT_div_II_skipf 00000000\XINT_div_II_f 100000000!#1\xint:#2#3#4#5#6% {% \XINT_div_II_k #6{#1}{#4}{#5}% }% @@ -20051,13 +20293,13 @@ $1$ or $-1$. % Here also we are dividing with x' which could be 10^8 in the exceptional % case x=99999999. Must intercept it before sending to \XINT_div_mini.| % \begin{macrocode} -\def\XINT_div_II_f #1!#2!#3.% +\def\XINT_div_II_f #1!#2!#3\xint:% {% \XINT_div_II_fa {#1!#2!}{#1!#2!#3}% }% \def\XINT_div_II_fa #1#2#3#4% {% - \expandafter\XINT_div_II_g \the\numexpr\XINT_div_xmini #3.#4!#1{#2}% + \expandafter\XINT_div_II_g \the\numexpr\XINT_div_xmini #3\xint:#4!#1{#2}% }% % \end{macrocode} % \lverb|#1=q, #2=alpha (K+4), #3=B, #4=q1, {{x'y},x,K,L}, alpha', BQ«c» @@ -20068,11 +20310,11 @@ $1$ or $-1$. {% \expandafter \XINT_div_II_h \the\numexpr 1#1#2#3#4#5+#8\expandafter\expandafter\expandafter - .\expandafter\expandafter\expandafter + \xint:\expandafter\expandafter\expandafter {\expandafter\xint_gob_til_exclam \romannumeral0\expandafter\XINT_div_sub\expandafter {\romannumeral0\XINT_rev_nounsep {}#6\R!\R!\R!\R!\R!\R!\R!\R!\W}% - {\the\numexpr\XINT_div_smallmul_a 100000000.#1#2#3#4.#5!#71\Z!}}% + {\the\numexpr\XINT_div_smallmul_a 100000000\xint:#1#2#3#4\xint:#5!#71;!}}% {#7}% }% % \end{macrocode} @@ -20080,7 +20322,7 @@ $1$ or $-1$. % #3=B, #4={{x'y},x,K,L} avec L à ajuster, alpha', BQ«c» % -> {x'y}x,K,L à diminuer de 1, {alpha}B{q}, alpha', BQ«c»| % \begin{macrocode} -\def\XINT_div_II_h 1#1.#2#3#4% +\def\XINT_div_II_h 1#1\xint:#2#3#4% {% \XINT_div_II_k #4{#2}{#3}{#1}% }% @@ -20091,9 +20333,9 @@ $1$ or $-1$. % \begin{macrocode} \def\XINT_div_II_k #1#2#3#4#5% {% - \expandafter\XINT_div_II_l \the\numexpr #4-\xint_c_i.{#3}#1{#2}#5.% + \expandafter\XINT_div_II_l \the\numexpr #4-\xint_c_i\xint:{#3}#1{#2}#5\xint:% }% -\def\XINT_div_II_l #1.#2#3#4#51#6!% +\def\XINT_div_II_l #1\xint:#2#3#4#51#6!% {% \XINT_div_II_m {{#1}{#2}{{#3}{#4}}{#5}}{#5}{#6}1#6!% }% @@ -20101,56 +20343,56 @@ $1$ or $-1$. % \lverb|{LK{x'y}x},x,a,alpha.B{q}alpha'B -> a, x, alpha, B, q, % L, K, {x'y}, x, alpha', B«c» | % \begin{macrocode} -\def\XINT_div_II_m #1#2#3#4.#5#6% +\def\XINT_div_II_m #1#2#3#4\xint:#5#6% {% \XINT_div_I_a {#3}{#2}{#4}{#5}{#6}#1% }% % \end{macrocode} % \lverb|This multiplication is exactly like \XINT_smallmul -- apart from not -% inserting an ending 1\Z! --, but keeps ever a vanishing ending carry.| +% inserting an ending 1;! --, but keeps ever a vanishing ending carry.| % \begin{macrocode} -\def\XINT_div_minimulwc_a 1#1.#2.#3!#4#5#6#7#8.% +\def\XINT_div_minimulwc_a 1#1\xint:#2\xint:#3!#4#5#6#7#8\xint:% {% \expandafter\XINT_div_minimulwc_b - \the\numexpr \xint_c_x^ix+#1+#3*#8.#3*#4#5#6#7+#2*#8.#2*#4#5#6#7.% + \the\numexpr \xint_c_x^ix+#1+#3*#8\xint:#3*#4#5#6#7+#2*#8\xint:#2*#4#5#6#7\xint:% }% -\def\XINT_div_minimulwc_b 1#1#2#3#4#5#6.#7.% +\def\XINT_div_minimulwc_b 1#1#2#3#4#5#6\xint:#7\xint:% {% \expandafter\XINT_div_minimulwc_c - \the\numexpr \xint_c_x^ix+#1#2#3#4#5+#7.#6.% + \the\numexpr \xint_c_x^ix+#1#2#3#4#5+#7\xint:#6\xint:% }% -\def\XINT_div_minimulwc_c 1#1#2#3#4#5#6.#7.#8.% +\def\XINT_div_minimulwc_c 1#1#2#3#4#5#6\xint:#7\xint:#8\xint:% {% 1#6#7\expandafter!% \the\numexpr\expandafter\XINT_div_smallmul_a - \the\numexpr \xint_c_x^viii+#1#2#3#4#5+#8.% + \the\numexpr \xint_c_x^viii+#1#2#3#4#5+#8\xint:% }% -\def\XINT_div_smallmul_a #1.#2.#3!1#4!% +\def\XINT_div_smallmul_a #1\xint:#2\xint:#3!1#4!% {% - \xint_gob_til_Z #4\XINT_div_smallmul_e\Z - \XINT_div_minimulwc_a #1.#2.#3!#4.#2.#3!% + \xint_gob_til_sc #4\XINT_div_smallmul_e;% + \XINT_div_minimulwc_a #1\xint:#2\xint:#3!#4\xint:#2\xint:#3!% }% -\def\XINT_div_smallmul_e\Z\XINT_div_minimulwc_a 1#1.#2\Z #3!{1\relax #1!}% +\def\XINT_div_smallmul_e;\XINT_div_minimulwc_a 1#1\xint:#2;#3!{1\relax #1!}% % \end{macrocode} % \lverb|Special very small multiplication for division. We only need to cater % for multiplicands from 1 to 9. The ending is different from standard -% verysmallmul, a zero carry is not suppressed. And no final 1\Z! is added. If +% verysmallmul, a zero carry is not suppressed. And no final 1;! is added. If % multiplicand is just 1 let's not forget to add the zero carry 100000000! at % the end.| % \begin{macrocode} \def\XINT_div_verysmallmul #1% - {\xint_gob_til_one #1\XINT_div_verysmallisone 1\XINT_div_verysmallmul_a 0.#1}% -\def\XINT_div_verysmallisone 1\XINT_div_verysmallmul_a 0.1!1#11\Z!% + {\xint_gob_til_one #1\XINT_div_verysmallisone 1\XINT_div_verysmallmul_a 0\xint:#1}% +\def\XINT_div_verysmallisone 1\XINT_div_verysmallmul_a 0\xint:1!1#11;!% {1\relax #1100000000!}% -\def\XINT_div_verysmallmul_a #1.#2!1#3!% +\def\XINT_div_verysmallmul_a #1\xint:#2!1#3!% {% - \xint_gob_til_Z #3\XINT_div_verysmallmul_e\Z + \xint_gob_til_sc #3\XINT_div_verysmallmul_e;% \expandafter\XINT_div_verysmallmul_b - \the\numexpr \xint_c_x^ix+#2*#3+#1.#2!% + \the\numexpr \xint_c_x^ix+#2*#3+#1\xint:#2!% }% -\def\XINT_div_verysmallmul_b 1#1#2.% - {1#2\expandafter!\the\numexpr\XINT_div_verysmallmul_a #1.}% -\def\XINT_div_verysmallmul_e\Z #1\Z +#2#3!{1\relax 0000000#2!}% +\def\XINT_div_verysmallmul_b 1#1#2\xint:% + {1#2\expandafter!\the\numexpr\XINT_div_verysmallmul_a #1\xint:}% +\def\XINT_div_verysmallmul_e;#1;+#2#3!{1\relax 0000000#2!}% % \end{macrocode} % \lverb|Special subtraction for division purposes. If the subtracted thing % turns out to be bigger, then just return a -. If not, then we must reverse @@ -20160,7 +20402,7 @@ $1$ or $-1$. {% \expandafter\XINT_div_sub_clean \the\numexpr\expandafter\XINT_div_sub_a\expandafter - 1#2\Z!\Z!\Z!\Z!\Z!\W #1\Z!\Z!\Z!\Z!\Z!\W + 1#2;!;!;!;!;!\W #1;!;!;!;!;!\W }% \def\XINT_div_sub_clean #1-#2#3\W {% @@ -20174,57 +20416,57 @@ $1$ or $-1$. }% \def\XINT_div_sub_b #1#2#3!#4!% {% - \xint_gob_til_Z #4\XINT_div_sub_bi \Z - \expandafter\XINT_div_sub_c\the\numexpr#1-#3+1#4-\xint_c_i.% + \xint_gob_til_sc #4\XINT_div_sub_bi ;% + \expandafter\XINT_div_sub_c\the\numexpr#1-#3+1#4-\xint_c_i\xint:% }% -\def\XINT_div_sub_c 1#1#2.% +\def\XINT_div_sub_c 1#1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_div_sub_d #1% }% \def\XINT_div_sub_d #1#2#3!#4!% {% - \xint_gob_til_Z #4\XINT_div_sub_di \Z - \expandafter\XINT_div_sub_e\the\numexpr#1-#3+1#4-\xint_c_i.% + \xint_gob_til_sc #4\XINT_div_sub_di ;% + \expandafter\XINT_div_sub_e\the\numexpr#1-#3+1#4-\xint_c_i\xint:% }% -\def\XINT_div_sub_e 1#1#2.% +\def\XINT_div_sub_e 1#1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_div_sub_f #1% }% \def\XINT_div_sub_f #1#2#3!#4!% {% - \xint_gob_til_Z #4\XINT_div_sub_fi \Z - \expandafter\XINT_div_sub_g\the\numexpr#1-#3+1#4-\xint_c_i.% + \xint_gob_til_sc #4\XINT_div_sub_fi ;% + \expandafter\XINT_div_sub_g\the\numexpr#1-#3+1#4-\xint_c_i\xint:% }% -\def\XINT_div_sub_g 1#1#2.% +\def\XINT_div_sub_g 1#1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_div_sub_h #1% }% \def\XINT_div_sub_h #1#2#3!#4!% {% - \xint_gob_til_Z #4\XINT_div_sub_hi \Z - \expandafter\XINT_div_sub_i\the\numexpr#1-#3+1#4-\xint_c_i.% + \xint_gob_til_sc #4\XINT_div_sub_hi ;% + \expandafter\XINT_div_sub_i\the\numexpr#1-#3+1#4-\xint_c_i\xint:% }% -\def\XINT_div_sub_i 1#1#2.% +\def\XINT_div_sub_i 1#1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_div_sub_a #1% }% -\def\XINT_div_sub_bi\Z - \expandafter\XINT_div_sub_c\the\numexpr#1-#2+#3.#4!#5!#6!#7!#8!#9!\Z !\W +\def\XINT_div_sub_bi;% + \expandafter\XINT_div_sub_c\the\numexpr#1-#2+#3\xint:#4!#5!#6!#7!#8!#9!;!\W {% \XINT_div_sub_l #1#2!#5!#7!#9!% }% -\def\XINT_div_sub_di\Z - \expandafter\XINT_div_sub_e\the\numexpr#1-#2+#3.#4!#5!#6!#7!#8\W +\def\XINT_div_sub_di;% + \expandafter\XINT_div_sub_e\the\numexpr#1-#2+#3\xint:#4!#5!#6!#7!#8\W {% \XINT_div_sub_l #1#2!#5!#7!% }% -\def\XINT_div_sub_fi\Z - \expandafter\XINT_div_sub_g\the\numexpr#1-#2+#3.#4!#5!#6\W +\def\XINT_div_sub_fi;% + \expandafter\XINT_div_sub_g\the\numexpr#1-#2+#3\xint:#4!#5!#6\W {% \XINT_div_sub_l #1#2!#5!% }% -\def\XINT_div_sub_hi\Z - \expandafter\XINT_div_sub_i\the\numexpr#1-#2+#3.#4\W +\def\XINT_div_sub_hi;% + \expandafter\XINT_div_sub_i\the\numexpr#1-#2+#3\xint:#4\W {% \XINT_div_sub_l #1#2!% }% @@ -20243,7 +20485,7 @@ $1$ or $-1$. % \lverb|Ici B<10^8 (et est >2). On % exécute$newline % \expandafter\XINT_sdiv_out\the\numexpr\XINT_smalldivx_a -% x.1B!1<8d>!...1<8d>!1\Z!$newline +% x.1B!1<8d>!...1<8d>!1;!$newline % avec x =round(B/2), 1B=10^8+B, et A déjà en % blocs 1<8d>! (non renversés). Le \the\numexpr\XINT_smalldivx_a va produire % Q\Z R\W avec un R<10^8, et un Q sous forme de blocs 1<8d>! terminé par 1! @@ -20252,18 +20494,19 @@ $1$ or $-1$. % % | % \begin{macrocode} -\def\XINT_sdiv_out #1\Z!#2!% +\def\XINT_sdiv_out #1;!#2!% {\expandafter - {\romannumeral0\XINT_unsep_cuzsmall#11\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W}% + {\romannumeral0\XINT_unsep_cuzsmall + #1\xint_bye!2!3!4!5!6!7!8!9!\xint_bye\xint_c_i\relax}% {#2}}% % \end{macrocode} % \lverb|La toute première étape fait la première division pour être sûr par % la suite d'avoir un premier bloc pour A qui sera < B.| % \begin{macrocode} -\def\XINT_smalldivx_a #1.1#2!1#3!% +\def\XINT_smalldivx_a #1\xint:1#2!1#3!% {% \expandafter\XINT_smalldivx_b - \the\numexpr (#3+#1)/#2-\xint_c_i!#1.#2!#3!% + \the\numexpr (#3+#1)/#2-\xint_c_i!#1\xint:#2!#3!% }% \def\XINT_smalldivx_b #1#2!% {% @@ -20271,62 +20514,57 @@ $1$ or $-1$. \xint_c_x^viii+#1#2\xint_afterfi{\expandafter!\the\numexpr}\fi \XINT_smalldiv_c #1#2!% }% -\def\XINT_smalldiv_c #1!#2.#3!#4!% +\def\XINT_smalldiv_c #1!#2\xint:#3!#4!% {% - \expandafter\XINT_smalldiv_d\the\numexpr #4-#1*#3!#2.#3!% + \expandafter\XINT_smalldiv_d\the\numexpr #4-#1*#3!#2\xint:#3!% }% % \end{macrocode} % \lverb|On va boucler ici: #1 est un reste, #2 est x.B (avec B sans le 1 mais % sur huit chiffres). #3#4 est le premier bloc qui reste de A. Si on a terminé -% avec A, alors #1 est le reste final. Le quotient lui est terminé par un 1!: -% ce 1! disparaîtra dans le nettoyage par \XINT_unsep_cuzsmall. Ce dernier, -% malgré le fait qu'on soit dans le bon ordre déjà fait une macro dans le -% style O(N^2) car sinon le nombre maximal de chiffres serait moitié moins à -% cause des nettoyages nécessaires après \numexpr. Je suis obligé de faire un -% nettoyage final car comme l'expansion est engendrée par \numexpr, elle me -% boufferait des leading zeros si je ne mettais pas un 1 devant chaque bloc en -% sortie de Q.| +% avec A, alors #1 est le reste final. Le quotient lui est terminé par un 1! +% ce 1! disparaîtra dans le nettoyage par \XINT_unsep_cuzsmall. +% | % \begin{macrocode} \def\XINT_smalldiv_d #1!#2!1#3#4!% {% - \xint_gob_til_Z #3\XINT_smalldiv_end \Z + \xint_gob_til_sc #3\XINT_smalldiv_end ;% \XINT_smalldiv_e #1!#2!1#3#4!% }% -\def\XINT_smalldiv_end\Z\XINT_smalldiv_e #1!#2!1\Z!{1!\Z!#1!}% +\def\XINT_smalldiv_end;\XINT_smalldiv_e #1!#2!1;!{1!;!#1!}% % \end{macrocode} % \lverb|Il est crucial que le reste #1 est < #3. J'ai documenté cette routine % dans le fichier où j'ai préparé 1.2, il faudra transférer ici. Il n'est pas % nécessaire pour cette routine que le diviseur B ait au moins 8 chiffres. % Mais il doit être < 10^8.| % \begin{macrocode} -\def\XINT_smalldiv_e #1!#2.#3!% +\def\XINT_smalldiv_e #1!#2\xint:#3!% {% \expandafter\XINT_smalldiv_f\the\numexpr - \xint_c_xi_e_viii_mone+#1*\xint_c_x^viii/#3!#2.#3!#1!% + \xint_c_xi_e_viii_mone+#1*\xint_c_x^viii/#3!#2\xint:#3!#1!% }% -\def\XINT_smalldiv_f 1#1#2#3#4#5#6!#7.#8!% +\def\XINT_smalldiv_f 1#1#2#3#4#5#6!#7\xint:#8!% {% \xint_gob_til_zero #1\XINT_smalldiv_fz 0% \expandafter\XINT_smalldiv_g - \the\numexpr\XINT_minimul_a #2#3#4#5.#6!#8!#2#3#4#5#6!#7.#8!% + \the\numexpr\XINT_minimul_a #2#3#4#5\xint:#6!#8!#2#3#4#5#6!#7\xint:#8!% }% \def\XINT_smalldiv_fz 0% \expandafter\XINT_smalldiv_g\the\numexpr\XINT_minimul_a - 9999.9999!#1!99999999!#2!0!1#3!% + 9999\xint:9999!#1!99999999!#2!0!1#3!% {% - \XINT_smalldiv_i .#3!\xint_c_!#2!% + \XINT_smalldiv_i \xint:#3!\xint_c_!#2!% }% \def\XINT_smalldiv_g 1#1!1#2!#3!#4!#5!#6!% {% - \expandafter\XINT_smalldiv_h\the\numexpr 1#6-#1.#2!#5!#3!#4!% + \expandafter\XINT_smalldiv_h\the\numexpr 1#6-#1\xint:#2!#5!#3!#4!% }% -\def\XINT_smalldiv_h 1#1#2.#3!#4!% +\def\XINT_smalldiv_h 1#1#2\xint:#3!#4!% {% - \expandafter\XINT_smalldiv_i\the\numexpr #4-#3+#1-\xint_c_i.#2!% + \expandafter\XINT_smalldiv_i\the\numexpr #4-#3+#1-\xint_c_i\xint:#2!% }% -\def\XINT_smalldiv_i #1.#2!#3!#4.#5!% +\def\XINT_smalldiv_i #1\xint:#2!#3!#4\xint:#5!% {% - \expandafter\XINT_smalldiv_j\the\numexpr (#1#2+#4)/#5-\xint_c_i!#3!#1#2!#4.#5!% + \expandafter\XINT_smalldiv_j\the\numexpr (#1#2+#4)/#5-\xint_c_i!#3!#1#2!#4\xint:#5!% }% \def\XINT_smalldiv_j #1!#2!% {% @@ -20336,9 +20574,9 @@ $1$ or $-1$. % \end{macrocode} % \lverb|On boucle vers \XINT_smalldiv_d.| % \begin{macrocode} -\def\XINT_smalldiv_k #1!#2!#3.#4!% +\def\XINT_smalldiv_k #1!#2!#3\xint:#4!% {% - \expandafter\XINT_smalldiv_d\the\numexpr #2-#1*#4!#3.#4!% + \expandafter\XINT_smalldiv_d\the\numexpr #2-#1*#4!#3\xint:#4!% }% % \end{macrocode} % \lverb|Cette routine fait la division euclidienne d'un nombre de seize @@ -20351,70 +20589,75 @@ $1$ or $-1$. % principale va utiliser ce quotient pour déterminer le "grand" reste, et le % petit reste ici ne nous serait d'à peu près aucune utilité. % -% ATTENTION UNIQUEMENT UTILISÉ POUR DES SITUATIONS OÙ IL EST GARANTI QUE X < C -% !! (et C au moins 10^7) le quotient euclidien de X*10^8+Y par C sera donc < +% ATTENTION UNIQUEMENT UTILISÉ POUR DES SITUATIONS OÙ IL EST GARANTI QUE X < +% C ! (et C au moins 10^7) le quotient euclidien de X*10^8+Y par C sera donc < % 10^8. Il sera renvoyé sous la forme 1<8chiffres>.| % \begin{macrocode} -\def\XINT_div_mini #1.#2!1#3!% +\def\XINT_div_mini #1\xint:#2!1#3!% {% \expandafter\XINT_div_mini_a\the\numexpr - \xint_c_xi_e_viii_mone+#3*\xint_c_x^viii/#1!#1.#2!#3!% + \xint_c_xi_e_viii_mone+#3*\xint_c_x^viii/#1!#1\xint:#2!#3!% }% % \end{macrocode} % \lverb|Note (2015/10/08). Attention à la différence dans l'ordre des % arguments avec ce que je vois en dans \XINT_smalldiv_f. Je ne me souviens % plus du tout s'il y a une raison quelconque.| % \begin{macrocode} -\def\XINT_div_mini_a 1#1#2#3#4#5#6!#7.#8!% +\def\XINT_div_mini_a 1#1#2#3#4#5#6!#7\xint:#8!% {% \xint_gob_til_zero #1\XINT_div_mini_w 0% \expandafter\XINT_div_mini_b - \the\numexpr\XINT_minimul_a #2#3#4#5.#6!#7!#2#3#4#5#6!#7.#8!% + \the\numexpr\XINT_minimul_a #2#3#4#5\xint:#6!#7!#2#3#4#5#6!#7\xint:#8!% }% \def\XINT_div_mini_w 0% \expandafter\XINT_div_mini_b\the\numexpr\XINT_minimul_a - 9999.9999!#1!99999999!#2.#3!00000000!#4!% + 9999\xint:9999!#1!99999999!#2\xint:#3!00000000!#4!% {% \xint_c_x^viii_mone+(#4+#3)/#2!% }% \def\XINT_div_mini_b 1#1!1#2!#3!#4!#5!#6!% {% \expandafter\XINT_div_mini_c - \the\numexpr 1#6-#1.#2!#5!#3!#4!% + \the\numexpr 1#6-#1\xint:#2!#5!#3!#4!% }% -\def\XINT_div_mini_c 1#1#2.#3!#4!% +\def\XINT_div_mini_c 1#1#2\xint:#3!#4!% {% \expandafter\XINT_div_mini_d - \the\numexpr #4-#3+#1-\xint_c_i.#2!% + \the\numexpr #4-#3+#1-\xint_c_i\xint:#2!% }% -\def\XINT_div_mini_d #1.#2!#3!#4.#5!% +\def\XINT_div_mini_d #1\xint:#2!#3!#4\xint:#5!% {% \xint_c_x^viii_mone+#3+(#1#2+#5)/#4!% }% % \end{macrocode} +% \subsection*{Derived arithmetic} +% \addcontentsline{toc}{subsection}{Derived arithmetic} % \subsection{\csh{xintiDivRound}, \csh{xintiiDivRound}} % \lverb|1.1, transferred from first release of bnumexpr. Rewritten for 1.2. -% Ending rewritten for 1.2i. (new \xintDSRr).| +% Ending rewritten for 1.2i. (new \xintDSRr). +% +% 1.2l: \xintiiDivRound made robust against non terminated input.| % \begin{macrocode} \def\xintiDivRound {\romannumeral0\xintidivround }% \def\xintidivround #1% - {\expandafter\XINT_idivround\romannumeral0\xintnum{#1}\Z }% + {\expandafter\XINT_idivround\romannumeral0\xintnum{#1}\xint:}% \def\xintiiDivRound {\romannumeral0\xintiidivround }% -\def\xintiidivround #1{\expandafter\XINT_iidivround \romannumeral`&&@#1\Z }% -\def\XINT_idivround #1#2\Z #3% +\def\xintiidivround #1{\expandafter\XINT_iidivround\romannumeral`&&@#1\xint:}% +\def\XINT_idivround #1#2\xint:#3% {\expandafter\XINT_iidivround_a\expandafter #1% - \romannumeral0\xintnum{#3}\Z #2\Z }% -\def\XINT_iidivround #1#2\Z #3% - {\expandafter\XINT_iidivround_a\expandafter #1\romannumeral`&&@#3\Z #2\Z }% + \romannumeral0\xintnum{#3}\xint:#2\xint:}% +\def\XINT_iidivround #1#2\xint:#3% + {\expandafter\XINT_iidivround_a\expandafter #1\romannumeral`&&@#3\xint:#2\xint:}% \def\XINT_iidivround_a #1#2% #1 de A, #2 de B. {% - \if0#2\xint_dothis\XINT_iidivround_divbyzero\fi + \if0#2\xint_dothis{\XINT_iidivround_divbyzero#1#2}\fi \if0#1\xint_dothis\XINT_iidivround_aiszero\fi \if-#2\xint_dothis{\XINT_iidivround_bneg #1}\fi \xint_orthat{\XINT_iidivround_bpos #1#2}% }% -\def\XINT_iidivround_divbyzero #1\Z #2\Z {\xintError:DivisionByZero\space 0}% -\def\XINT_iidivround_aiszero #1\Z #2\Z { 0}% +\def\XINT_iidivround_divbyzero #1#2#3\xint:#4\xint: + {\XINT_signalcondition{DivisionByZero}{Division of #1#4 by #2#3}{}{0}}% +\def\XINT_iidivround_aiszero #1\xint:#2\xint:{ 0}% \def\XINT_iidivround_bpos #1% {% \xint_UDsignfork @@ -20429,7 +20672,7 @@ $1$ or $-1$. -{\xintiiopp\XINT_iidivround_pos #1}% \krof }% -\def\XINT_iidivround_pos #1#2\Z #3\Z +\def\XINT_iidivround_pos #1#2\xint:#3\xint: {% \expandafter\expandafter\expandafter\XINT_dsrr \expandafter\xint_firstoftwo @@ -20438,16 +20681,17 @@ $1$ or $-1$. }% % \end{macrocode} % \subsection{\csh{xintiDivTrunc}, \csh{xintiiDivTrunc}} +% \lverb|1.2l: \xintiiDivTrunc made robust against non terminated input.| % \begin{macrocode} \def\xintiDivTrunc {\romannumeral0\xintidivtrunc }% -\def\xintidivtrunc #1{\expandafter\XINT_iidivtrunc\romannumeral0\xintnum{#1}\Z }% +\def\xintidivtrunc #1{\expandafter\XINT_iidivtrunc\romannumeral0\xintnum{#1}\xint:}% \def\xintiiDivTrunc {\romannumeral0\xintiidivtrunc }% -\def\xintiidivtrunc #1{\expandafter\XINT_iidivtrunc \romannumeral`&&@#1\Z }% -\def\XINT_iidivtrunc #1#2\Z #3{\expandafter\XINT_iidivtrunc_a\expandafter #1% - \romannumeral`&&@#3\Z #2\Z }% +\def\xintiidivtrunc #1{\expandafter\XINT_iidivtrunc\romannumeral`&&@#1\xint:}% +\def\XINT_iidivtrunc #1#2\xint:#3{\expandafter\XINT_iidivtrunc_a\expandafter #1% + \romannumeral`&&@#3\xint:#2\xint:}% \def\XINT_iidivtrunc_a #1#2% #1 de A, #2 de B. {% - \if0#2\xint_dothis\XINT_iidivround_divbyzero\fi + \if0#2\xint_dothis{\XINT_iidivround_divbyzero#1#2}\fi \if0#1\xint_dothis\XINT_iidivround_aiszero\fi \if-#2\xint_dothis{\XINT_iidivtrunc_bneg #1}\fi \xint_orthat{\XINT_iidivtrunc_bpos #1#2}% @@ -20466,21 +20710,21 @@ $1$ or $-1$. -{\xintiiopp\XINT_iidivtrunc_pos #1}% \krof }% -\def\XINT_iidivtrunc_pos #1#2\Z #3\Z% +\def\XINT_iidivtrunc_pos #1#2\xint:#3\xint: {\expandafter\xint_firstoftwo_thenstop \romannumeral0\XINT_div_prepare {#2}{#1#3}}% % \end{macrocode} % \subsection{\csh{xintiMod}, \csh{xintiiMod}} % \begin{macrocode} \def\xintiMod {\romannumeral0\xintimod }% -\def\xintimod #1{\expandafter\XINT_iimod\romannumeral0\xintnum{#1}\Z }% +\def\xintimod #1{\expandafter\XINT_iimod\romannumeral0\xintnum{#1}\xint:}% \def\xintiiMod {\romannumeral0\xintiimod }% -\def\xintiimod #1{\expandafter\XINT_iimod \romannumeral`&&@#1\Z }% -\def\XINT_iimod #1#2\Z #3{\expandafter\XINT_iimod_a\expandafter #1% - \romannumeral`&&@#3\Z #2\Z }% +\def\xintiimod #1{\expandafter\XINT_iimod\romannumeral`&&@#1\xint:}% +\def\XINT_iimod #1#2\xint:#3{\expandafter\XINT_iimod_a\expandafter #1% + \romannumeral`&&@#3\xint:#2\xint:}% \def\XINT_iimod_a #1#2% #1 de A, #2 de B. {% - \if0#2\xint_dothis\XINT_iidivround_divbyzero\fi + \if0#2\xint_dothis{\XINT_iidivround_divbyzero#1#2}\fi \if0#1\xint_dothis\XINT_iidivround_aiszero\fi \if-#2\xint_dothis{\XINT_iimod_bneg #1}\fi \xint_orthat{\XINT_iimod_bpos #1#2}% @@ -20499,11 +20743,408 @@ $1$ or $-1$. -{\XINT_iimod_pos #1}% \krof }% -\def\XINT_iimod_pos #1#2\Z #3\Z% +\def\XINT_iimod_pos #1#2\xint:#3\xint: {\expandafter\xint_secondoftwo_thenstop\romannumeral0\XINT_div_prepare {#2}{#1#3}}% % \end{macrocode} -% \subsection{``Load \xintfracnameimp'' macros} +% \subsection{\csh{xintiSqr}, \csh{xintiiSqr}} +% \lverb|1.2l: \xintiiSqr made robust against non terminated input.| +% \begin{macrocode} +\def\xintiiSqr {\romannumeral0\xintiisqr }% +\def\xintiisqr #1% +{% + \expandafter\XINT_sqr\romannumeral0\xintiiabs{#1}\xint: +}% +\def\xintiSqr {\romannumeral0\xintisqr }% +\def\xintisqr #1% +{% + \expandafter\XINT_sqr\romannumeral0\xintiabs{#1}\xint: +}% +\def\XINT_sqr #1\xint: +{% + \expandafter\XINT_sqr_a + \romannumeral0\expandafter\XINT_sepandrev_andcount + \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\xint_c_ii\xint_c_i + \R\xint:\xint_c_xii \R\xint:\xint_c_x \R\xint:\xint_c_viii \R\xint:\xint_c_vi + \R\xint:\xint_c_iv \R\xint:\xint_c_ii \R\xint:\xint_c_\W + \xint: +}% +% \end{macrocode} +% \lverb|1.2c \XINT_mul_loop can now be called directly even with small +% arguments, thus the following check is not anymore a necessity.| +% \begin{macrocode} +\def\XINT_sqr_a #1\xint: +{% + \ifnum #1=\xint_c_i \expandafter\XINT_sqr_small + \else\expandafter\XINT_sqr_start\fi +}% +\def\XINT_sqr_small 1#1#2#3#4#5!\xint: +{% + \ifnum #1#2#3#4#5<46341 \expandafter\XINT_sqr_verysmall\fi + \expandafter\XINT_sqr_small_out + \the\numexpr\XINT_minimul_a #1#2#3#4\xint:#5!#1#2#3#4#5!% +}% +\def\XINT_sqr_verysmall#1{% +\def\XINT_sqr_verysmall + \expandafter\XINT_sqr_small_out\the\numexpr\XINT_minimul_a ##1!##2!% + {\expandafter#1\the\numexpr ##2*##2\relax}% +}\XINT_sqr_verysmall{ }% +\def\XINT_sqr_small_out 1#1!1#2!% +{% + \XINT_cuz #2#1\R +}% +% \end{macrocode} +% \lverb|An ending 1;! is produced on output for \XINT_mul_loop and gets +% incorporated to the delimiter needed by the \XINT_unrevbyviii done by +% \XINT_mul_out.| +% \begin{macrocode} +\def\XINT_sqr_start #1\xint: +{% + \expandafter\XINT_mul_out + \the\numexpr\XINT_mul_loop + 100000000!1;!\W #11;!\W #11;!% + 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W +}% +% \end{macrocode} +% \subsection{\csh{xintiPow}, \csh{xintiiPow}} +% \lverb|& +% The exponent is not limited but with current default settings of tex memory, +% with xint 1.2, the maximal exponent for 2^N is N = 2^17 = 131072. +% +% 1.2f Modifies the initial steps: 1) in order to be able to let more easily +% \xintiPow use \xintNum on the exponent once xintfrac.sty is loaded; 2) also +% because I noticed it was not very well coded. And it did only a \numexpr on +% the exponent, contradicting the documentation related to the "i" convention +% in names. +% +% 1.2l: \xintiiPow made robust against non terminated input.| +% \begin{macrocode} +\def\xintiiPow {\romannumeral0\xintiipow }% +\def\xintiipow #1#2% +{% + \expandafter\xint_pow\the\numexpr #2\expandafter + .\romannumeral`&&@#1\xint: +}% +\def\xintiPow {\romannumeral0\xintipow }% +\def\xintipow #1#2% +{% + \expandafter\xint_pow\the\numexpr #2\expandafter + .\romannumeral0\xintnum{#1}\xint: +}% +\def\xint_pow #1.#2%#3\xint: +{% + \xint_UDzerominusfork + #2-\XINT_pow_AisZero + 0#2\XINT_pow_Aneg + 0-{\XINT_pow_Apos #2}% + \krof {#1}% +}% +\def\XINT_pow_AisZero #1#2\xint: +{% + \ifcase\XINT_cntSgn #1\xint: + \xint_afterfi { 1}% + \or + \xint_afterfi { 0}% + \else + \xint_afterfi + {\XINT_signalcondition{DivisionByZero}{Zero to power #1}{}{0}}% + \fi +}% +\def\XINT_pow_Aneg #1% +{% + \ifodd #1 + \expandafter\XINT_opp\romannumeral0% + \fi + \XINT_pow_Apos {}{#1}% +}% +\def\XINT_pow_Apos #1#2{\XINT_pow_Apos_a {#2}#1}% +\def\XINT_pow_Apos_a #1#2#3% +{% + \xint_gob_til_xint: #3\XINT_pow_Apos_short\xint: + \XINT_pow_AatleastTwo {#1}#2#3% +}% +\def\XINT_pow_Apos_short\xint:\XINT_pow_AatleastTwo #1#2\xint: +{% + \ifcase #2 + \xintError:thiscannothappen + \or \expandafter\XINT_pow_AisOne + \else\expandafter\XINT_pow_AatleastTwo + \fi {#1}#2\xint: +}% +\def\XINT_pow_AisOne #1\xint:{ 1}% +\def\XINT_pow_AatleastTwo #1% +{% + \ifcase\XINT_cntSgn #1\xint: + \expandafter\XINT_pow_BisZero + \or + \expandafter\XINT_pow_I_in + \else + \expandafter\XINT_pow_BisNegative + \fi + {#1}% +}% +\def\XINT_pow_BisNegative #1\xint:{\XINT_signalcondition{Underflow}{Inverse power + can not be represented by an integer}{}{0}}% +\def\XINT_pow_BisZero #1\xint:{ 1}% +% \end{macrocode} +% \lverb|B = #1 > 0, A = #2 > 1. Earlier code checked if size of B did not +% exceed a given limit (for example 131000).| +% \begin{macrocode} +\def\XINT_pow_I_in #1#2\xint: +{% + \expandafter\XINT_pow_I_loop + \the\numexpr #1\expandafter\xint:% + \romannumeral0\expandafter\XINT_sepandrev + \romannumeral0\XINT_zeroes_forviii #2\R\R\R\R\R\R\R\R{10}0000001\W + #2\XINT_rsepbyviii_end_A 2345678% + \XINT_rsepbyviii_end_B 2345678\relax XX% + \R\xint:\R\xint:\R\xint:\R\xint:\R\xint:\R\xint:\R\xint:\R\xint:\W + 1;!\W + 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W +}% +\def\XINT_pow_I_loop #1\xint:% +{% + \ifnum #1 = \xint_c_i\expandafter\XINT_pow_I_exit\fi + \ifodd #1 + \expandafter\XINT_pow_II_in + \else + \expandafter\XINT_pow_I_squareit + \fi #1\xint:% +}% +\def\XINT_pow_I_exit \ifodd #1\fi #2\xint:#3\W {\XINT_mul_out #3}% +% \end{macrocode} +% \lverb|The 1.2c \XINT_mul_loop can be called directly even with small +% arguments, hence the "butcheckifsmall" is not a necessity as it was earlier +% with 1.2. On 2^30, it does bring roughly a 40$char37 $space time gain +% though, and 30$char37 $space gain for 2^60. The overhead on big computations +% should be negligible.| +% \begin{macrocode} +\def\XINT_pow_I_squareit #1\xint:#2\W% +{% + \expandafter\XINT_pow_I_loop + \the\numexpr #1/\xint_c_ii\expandafter\xint:% + \the\numexpr\XINT_pow_mulbutcheckifsmall #2\W #2\W +}% +\def\XINT_pow_mulbutcheckifsmall #1!1#2% +{% + \xint_gob_til_sc #2\XINT_pow_mul_small;% + \XINT_mul_loop 100000000!1;!\W #1!1#2% +}% +\def\XINT_pow_mul_small;\XINT_mul_loop + 100000000!1;!\W 1#1!1;!\W +{% + \XINT_smallmul 1#1!% +}% +\def\XINT_pow_II_in #1\xint:#2\W +{% + \expandafter\XINT_pow_II_loop + \the\numexpr #1/\xint_c_ii-\xint_c_i\expandafter\xint:% + \the\numexpr\XINT_pow_mulbutcheckifsmall #2\W #2\W #2\W +}% +\def\XINT_pow_II_loop #1\xint:% +{% + \ifnum #1 = \xint_c_i\expandafter\XINT_pow_II_exit\fi + \ifodd #1 + \expandafter\XINT_pow_II_odda + \else + \expandafter\XINT_pow_II_even + \fi #1\xint:% +}% +\def\XINT_pow_II_exit\ifodd #1\fi #2\xint:#3\W #4\W +{% + \expandafter\XINT_mul_out + \the\numexpr\XINT_pow_mulbutcheckifsmall #4\W #3% +}% +\def\XINT_pow_II_even #1\xint:#2\W +{% + \expandafter\XINT_pow_II_loop + \the\numexpr #1/\xint_c_ii\expandafter\xint:% + \the\numexpr\XINT_pow_mulbutcheckifsmall #2\W #2\W +}% +\def\XINT_pow_II_odda #1\xint:#2\W #3\W +{% + \expandafter\XINT_pow_II_oddb + \the\numexpr #1/\xint_c_ii-\xint_c_i\expandafter\xint:% + \the\numexpr\XINT_pow_mulbutcheckifsmall #3\W #2\W #2\W +}% +\def\XINT_pow_II_oddb #1\xint:#2\W #3\W +{% + \expandafter\XINT_pow_II_loop + \the\numexpr #1\expandafter\xint:% + \the\numexpr\XINT_pow_mulbutcheckifsmall #3\W #3\W #2\W +}% +% \end{macrocode} +% \subsection{\csh{xintiFac}, \csh{xintiiFac}} +% \lverb|Moved here from xint.sty with release 1.2 (to be usable by \bnumexpr). +% +% Partially rewritten with release 1.2 to benefit from the inner format of the +% 1.2 multiplication. +% +% With current default settings of the etex memory and a.t.t.o.w (11/2015) the +% maximal possible computation is 5971! (which has 19956 digits). +% +% +% +% Note (end november 2015): I also tried out a quickly written recursive +% (binary split) implementation +% +%( \catcode`_ 11 +%: \catcode`^ 11 +%: \long\def\xint_firstofthree #1#2#3{#1}$% +%: \long\def\xint_secondofthree #1#2#3{#2}$% +%: \long\def\xint_thirdofthree #1#2#3{#3}$% +%: $% quickly written factorial using binary split recursive method +%: \def\tFac {\romannumeral-`0\tfac }$% +%: \def\tfac #1{\expandafter\XINT_mul_out +%: \romannumeral-`0\ufac {1}{#1}1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W}$% +%: \def\ufac #1#2{\ifcase\numexpr#2-#1\relax +%: \expandafter\xint_firstofthree +%: \or +%: \expandafter\xint_secondofthree +%: \else +%: \expandafter\xint_thirdofthree +%: \fi +%: {\the\numexpr\xint_c_x^viii+#1!1;!}$% +%: {\the\numexpr\xint_c_x^viii+#1*#2!1;!}$% +%: {\expandafter\vfac\the\numexpr (#1+#2)/\xint_c_ii.#1.#2.}$% +%: }$% +%: \def\vfac #1.#2.#3.$% +%: {$% +%: \expandafter +%: \wfac\expandafter +%: {\romannumeral-`0\expandafter +%: \ufac\expandafter{\the\numexpr #1+\xint_c_i}{#3}}$% +%: {\ufac {#2}{#1}}$% +%: }$% +%: \def\wfac #1#2{\expandafter\zfac\romannumeral-`0#2\W #1}$% +%: \def\zfac {\the\numexpr\XINT_mul_loop 100000000!1;!\W }$% core multiplication... +%: \catcode`_ 8 +%: \catcode`^ 7 +%) +% and I was quite surprised that it was only about 1.6x--2x slower in the range +% N=200 to 2000 than the \xintiiFac here which attempts to be smarter... +% +% Note (2017, 1.2l): I found out some code comment of mine that the code here +% should be more in the style of \xintiiBinomial, but I left matters +% untouched. +% +% +% | +% \begin{macrocode} +\def\xintiiFac {\romannumeral0\xintiifac }% +\def\xintiifac #1{\expandafter\XINT_fac_fork\the\numexpr#1.}% +\def\xintiFac {\romannumeral0\xintifac }% +\let\xintifac\xintiifac +\def\XINT_fac_fork #1#2.% +{% + \xint_UDzerominusfork + #1-\XINT_fac_zero + 0#1\XINT_fac_neg + 0-\XINT_fac_checksize + \krof #1#2.% +}% +\def\XINT_fac_zero #1.{ 1}% +\def\XINT_fac_neg #1.{\XINT_signalcondition{InvalidOperation}{Factorial of + negative: (#1)!}{}{0}}% +% \end{macrocode} +% \begin{macrocode} +\def\XINT_fac_checksize #1.% +{% + \ifnum #1>\xint_c_x^iv \xint_dothis{\XINT_fac_toobig #1.}\fi + \ifnum #1>465 \xint_dothis{\XINT_fac_bigloop_a #1.}\fi + \ifnum #1>101 \xint_dothis{\XINT_fac_medloop_a #1.\XINT_mul_out}\fi + \xint_orthat{\XINT_fac_smallloop_a #1.\XINT_mul_out}% + 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W +}% +\def\XINT_fac_toobig #1.#2\W{\XINT_signalcondition{InvalidOperation}{Factorial + of too big argument: #1 > 10000}{}{0}}% +\def\XINT_fac_bigloop_a #1.% +{% + \expandafter\XINT_fac_bigloop_b \the\numexpr + #1+\xint_c_i-\xint_c_ii*((#1-464)/\xint_c_ii).#1.% +}% +\def\XINT_fac_bigloop_b #1.#2.% +{% + \expandafter\XINT_fac_medloop_a + \the\numexpr #1-\xint_c_i.{\XINT_fac_bigloop_loop #1.#2.}% +}% +\def\XINT_fac_bigloop_loop #1.#2.% +{% + \ifnum #1>#2 \expandafter\XINT_fac_bigloop_exit\fi + \expandafter\XINT_fac_bigloop_loop + \the\numexpr #1+\xint_c_ii\expandafter.% + \the\numexpr #2\expandafter.\the\numexpr\XINT_fac_bigloop_mul #1!% +}% +\def\XINT_fac_bigloop_exit #1!{\XINT_mul_out}% +\def\XINT_fac_bigloop_mul #1!% +{% + \expandafter\XINT_smallmul + \the\numexpr \xint_c_x^viii+#1*(#1+\xint_c_i)!% +}% +\def\XINT_fac_medloop_a #1.% +{% + \expandafter\XINT_fac_medloop_b + \the\numexpr #1+\xint_c_i-\xint_c_iii*((#1-100)/\xint_c_iii).#1.% +}% +\def\XINT_fac_medloop_b #1.#2.% +{% + \expandafter\XINT_fac_smallloop_a + \the\numexpr #1-\xint_c_i.{\XINT_fac_medloop_loop #1.#2.}% +}% +\def\XINT_fac_medloop_loop #1.#2.% +{% + \ifnum #1>#2 \expandafter\XINT_fac_loop_exit\fi + \expandafter\XINT_fac_medloop_loop + \the\numexpr #1+\xint_c_iii\expandafter.% + \the\numexpr #2\expandafter.\the\numexpr\XINT_fac_medloop_mul #1!% +}% +\def\XINT_fac_medloop_mul #1!% +{% + \expandafter\XINT_smallmul + \the\numexpr + \xint_c_x^viii+#1*(#1+\xint_c_i)*(#1+\xint_c_ii)!% +}% +\def\XINT_fac_smallloop_a #1.% +{% + \csname + XINT_fac_smallloop_\the\numexpr #1-\xint_c_iv*(#1/\xint_c_iv)\relax + \endcsname #1.% +}% +\expandafter\def\csname XINT_fac_smallloop_1\endcsname #1.% +{% + \XINT_fac_smallloop_loop 2.#1.100000001!1;!% +}% +\expandafter\def\csname XINT_fac_smallloop_-2\endcsname #1.% +{% + \XINT_fac_smallloop_loop 3.#1.100000002!1;!% +}% +\expandafter\def\csname XINT_fac_smallloop_-1\endcsname #1.% +{% + \XINT_fac_smallloop_loop 4.#1.100000006!1;!% +}% +\expandafter\def\csname XINT_fac_smallloop_0\endcsname #1.% +{% + \XINT_fac_smallloop_loop 5.#1.1000000024!1;!% +}% +\def\XINT_fac_smallloop_loop #1.#2.% +{% + \ifnum #1>#2 \expandafter\XINT_fac_loop_exit\fi + \expandafter\XINT_fac_smallloop_loop + \the\numexpr #1+\xint_c_iv\expandafter.% + \the\numexpr #2\expandafter.\the\numexpr\XINT_fac_smallloop_mul #1!% +}% +\def\XINT_fac_smallloop_mul #1!% +{% + \expandafter\XINT_smallmul + \the\numexpr + \xint_c_x^viii+#1*(#1+\xint_c_i)*(#1+\xint_c_ii)*(#1+\xint_c_iii)!% +}% +\def\XINT_fac_loop_exit #1!#2;!#3{#3#2;!}% +% \end{macrocode} +% \subsection*{``Load \xintfracnameimp'' macros} +% \addcontentsline{toc}{subsection}{``Load \xintfracnameimp'' macros} % \lverb|Originally was used in \xintiiexpr. Transferred from xintfrac for 1.1.| % \begin{macrocode} \catcode`! 11 @@ -20516,6 +21157,7 @@ $1$ or $-1$. \def\xintSqr {\Did_you_mean_iiSqr?or_load_xintfrac!}% \def\xintQuo {\Removed!use_xintiQuo_or_xintiiQuo!}% \def\xintRem {\Removed!use_xintiRem_or_xintiiRem!}% +\catcode`! 12 \XINT_restorecatcodes_endinput% % \end{macrocode} % @@ -20585,7 +21227,7 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xint}% - [2017/01/06 1.2k Expandable operations on big integers (JFB)]% + [2017/07/26 1.2l Expandable operations on big integers (JFB)]% % \end{macrocode} % \subsection{More token management} % \begin{macrocode} @@ -20595,10 +21237,6 @@ $1$ or $-1$. \long\def\xint_firstofthree_thenstop #1#2#3{ #1}% 1.09i \long\def\xint_secondofthree_thenstop #1#2#3{ #2}% \long\def\xint_thirdofthree_thenstop #1#2#3{ #3}% -\edef\xint_cleanupzeros_andstop #1#2#3#4% -{% - \noexpand\expandafter\space\noexpand\the\numexpr #1#2#3#4\relax -}% % \end{macrocode} % \subsection{\csh{xintSgnFork}} % \lverb|Expandable three-way fork added in 1.07. The argument #1 must expand @@ -20633,40 +21271,70 @@ $1$ or $-1$. \unless\if#11\xint_dothis{ 0}\fi \xint_orthat{ 1}% }% -\def\XINT_isOne #1{\XINT_is_one#1XY}% -\def\XINT_is_one #1#2#3Y% +\def\XINT_isOne #1{\XINT_is_One#1XY}% +\def\XINT_is_One #1#2#3Y% {% \unless\if#2X\xint_dothis0\fi \unless\if#11\xint_dothis0\fi \xint_orthat1% }% % \end{macrocode} -% \subsection{\csh{xintRev}} +% \subsection{\csh{xintReverseDigits}} % \lverb|& -% \xintRev: expands fully its argument \romannumeral-`0, and checks the sign. -% However this last aspect does not appear like a very useful thing. And despite -% the fact that a special check is made for a sign, actually the input is not -% given to \xintnum, contrarily to \xintLen. This is all a bit incoherent. -% Should be fixed. +% 1.2. +% +% This puts digits in reverse order, not suppressing leading zeros +% after reverse. Despite lacking the "ii" in its name, it does not apply +% \xintNum to its argument (contrarily to \xintLen, this is not very coherent). +% +% 1.2l variant is robust against non terminated \the\numexpr input. % -% 1.2 has \xintReverseDigits and I thus make \xintRev an alias. Remarks above -% not addressed.| +% This macro is currently not used elsewhere in xint code. +% | % \begin{macrocode} +\def\xintReverseDigits {\romannumeral0\xintreversedigits }% +\def\xintreversedigits #1% +{% + \expandafter\XINT_revdigits\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\XINT_microrevsep_end\Z + 1\Z!1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W +}% +\def\XINT_revdigits #1% +{% + \xint_UDsignfork + #1{\expandafter-\romannumeral0\XINT_revdigits_a}% + -{\XINT_revdigits_a #1}% + \krof +}% +\def\XINT_revdigits_a +{% + \expandafter\XINT_revdigits_b\expandafter{\expandafter}% + \the\numexpr\XINT_microrevsep +}% +\def\XINT_microrevsep #1#2#3#4#5#6#7#8#9% +{% + 1#9#8#7#6#5#4#3#2#1\expandafter!\the\numexpr\XINT_microrevsep +}% +\def\XINT_microrevsep_end #1\W #2\expandafter #3\Z{\relax#2!}% +\def\XINT_revdigits_b #11#2!1#3!1#4!1#5!1#6!1#7!1#8!1#9!% +{% + \xint_gob_til_R #9\XINT_revdigits_end\R + \XINT_revdigits_b {#9#8#7#6#5#4#3#2#1}% +}% +\def\XINT_revdigits_end#1{% +\def\XINT_revdigits_end\R\XINT_revdigits_b ##1##2\W + {\expandafter#1\xint_gob_til_Z ##1}% +}\XINT_revdigits_end{ }% \let\xintRev\xintReverseDigits % \end{macrocode} % \subsection{\csh{xintLen}} % \lverb|\xintLen is ONLY for (possibly long) integers. Gets extended to -% fractions by xintfrac.sty. -% -% 2016/12/23. For no reason at all I botchered this venerable macro at the -% time of 1.2i release (I came here to update the pattern of the length loop -% which had been modified) and got tricked by \unexpanded which I used in an -% \edef to insert a space token and avoid having to put many \noexpand's. But -% this converted a #1 into a ##1 with deplorable effect that \xintLen{-1} -% outputted 3 and not 1 :(( awful. Also, I did another error in the \xintLen -% of xintfrac.sty, simply forgetting there to not count the sign. Too bad I -% become aware of this after having already released 1.2j. I know, regression -% suite is highest priority. Fixed in 1.2k. +% fractions by xintfrac.sty. It applies \xintNum to its argument. A minus sign +% is accepted and ignored. +% % | % \begin{macrocode} \def\xintLen {\romannumeral0\xintlen }% @@ -20674,8 +21342,7 @@ $1$ or $-1$. {% \expandafter#1\the\numexpr \expandafter\XINT_len_fork\romannumeral0\xintnum{##1}% - \xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax + \xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint: \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye\relax }}\xintlen{ }% @@ -20899,176 +21566,6 @@ $1$ or $-1$. \fi }% % \end{macrocode} -% \subsection{\csh{xintCmp}, \csh{xintiiCmp}} -% \lverb|Faster than doing the full subtraction.| -% \begin{macrocode} -\def\xintCmp {\romannumeral0\xintcmp }% -\def\xintcmp #1{\expandafter\XINT_icmp\romannumeral0\xintnum{#1}\Z }% -\def\xintiiCmp {\romannumeral0\xintiicmp }% -\def\xintiicmp #1{\expandafter\XINT_iicmp\romannumeral`&&@#1\Z }% -\def\XINT_iicmp #1#2\Z #3% -{% - \expandafter\XINT_cmp_nfork\expandafter #1\romannumeral`&&@#3\Z #2\Z -}% -\let\XINT_Cmp \xintiiCmp -\def\XINT_icmp #1#2\Z #3% -{% - \expandafter\XINT_cmp_nfork\expandafter #1\romannumeral0\xintnum{#3}\Z #2\Z -}% -\def\XINT_cmp_nfork #1#2% -{% - \xint_UDzerofork - #1\XINT_cmp_firstiszero - #2\XINT_cmp_secondiszero - 0{}% - \krof - \xint_UDsignsfork - #1#2\XINT_cmp_minusminus - #1-\XINT_cmp_minusplus - #2-\XINT_cmp_plusminus - --\XINT_cmp_plusplus - \krof #1#2% -}% -\def\XINT_cmp_firstiszero #1\krof 0#2#3\Z #4\Z -{% - \xint_UDzerominusfork - #2-{ 0}% - 0#2{ 1}% - 0-{ -1}% - \krof -}% -\def\XINT_cmp_secondiszero #1\krof #20#3\Z #4\Z -{% - \xint_UDzerominusfork - #2-{ 0}% - 0#2{ -1}% - 0-{ 1}% - \krof -}% -\def\XINT_cmp_plusminus #1\Z #2\Z{ 1}% -\def\XINT_cmp_minusplus #1\Z #2\Z{ -1}% -\def\XINT_cmp_minusminus - --{\expandafter\XINT_opp\romannumeral0\XINT_cmp_plusplus {}{}}% -\def\XINT_cmp_plusplus #1#2#3\Z -{% - \expandafter\XINT_cmp_pp - \romannumeral0\expandafter\XINT_sepandrev_andcount - \romannumeral0\XINT_zeroes_forviii #2#3\R\R\R\R\R\R\R\R{10}0000001\W - #2#3\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 #1% -}% -\def\XINT_cmp_pp #1.#2\X #3\Z -{% - \expandafter\XINT_cmp_checklengths - \the\numexpr #1\expandafter.% - \romannumeral0\expandafter\XINT_sepandrev_andcount - \romannumeral0\XINT_zeroes_forviii #3\R\R\R\R\R\R\R\R{10}0000001\W - #3\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 - \Z!\Z!\Z!\Z!\Z!\W #2\Z!\Z!\Z!\Z!\Z!\W -}% -\def\XINT_cmp_checklengths #1.#2.% -{% - \ifnum #1=#2 - \expandafter\xint_firstoftwo - \else - \expandafter\xint_secondoftwo - \fi - \XINT_cmp_aa {\XINT_cmp_distinctlengths {#1}{#2}}% -}% -\def\XINT_cmp_distinctlengths #1#2#3\W #4\W -{% - \ifnum #1>#2 - \expandafter\xint_firstoftwo - \else - \expandafter\xint_secondoftwo - \fi - { -1}{ 1}% -}% -\def\XINT_cmp_aa {\expandafter\XINT_cmp_w\the\numexpr\XINT_cmp_a \xint_c_i }% -\def\XINT_cmp_a #1!#2!#3!#4!#5\W #6!#7!#8!#9!% -{% - \XINT_cmp_b #1!#6!#2!#7!#3!#8!#4!#9!#5\W -}% -\def\XINT_cmp_b #1#2#3!#4!% -{% - \xint_gob_til_Z #2\XINT_cmp_bi \Z - \expandafter\XINT_cmp_c\the\numexpr#1+1#4-#3-\xint_c_i.% -}% -\def\XINT_cmp_c 1#1#2.% -{% - 1#2\expandafter!\the\numexpr\XINT_cmp_d #1% -}% -\def\XINT_cmp_d #1#2#3!#4!% -{% - \xint_gob_til_Z #2\XINT_cmp_di \Z - \expandafter\XINT_cmp_e\the\numexpr#1+1#4-#3-\xint_c_i.% -}% -\def\XINT_cmp_e 1#1#2.% -{% - 1#2\expandafter!\the\numexpr\XINT_cmp_f #1% -}% -\def\XINT_cmp_f #1#2#3!#4!% -{% - \xint_gob_til_Z #2\XINT_cmp_fi \Z - \expandafter\XINT_cmp_g\the\numexpr#1+1#4-#3-\xint_c_i.% -}% -\def\XINT_cmp_g 1#1#2.% -{% - 1#2\expandafter!\the\numexpr\XINT_cmp_h #1% -}% -\def\XINT_cmp_h #1#2#3!#4!% -{% - \xint_gob_til_Z #2\XINT_cmp_hi \Z - \expandafter\XINT_cmp_i\the\numexpr#1+1#4-#3-\xint_c_i.% -}% -\def\XINT_cmp_i 1#1#2.% -{% - 1#2\expandafter!\the\numexpr\XINT_cmp_a #1% -}% -\def\XINT_cmp_bi\Z - \expandafter\XINT_cmp_c\the\numexpr#1+1#2-#3.#4!#5!#6!#7!#8!#9!\Z !\W -{% - \XINT_cmp_k #1#2!#5!#7!#9!% -}% -\def\XINT_cmp_di\Z - \expandafter\XINT_cmp_e\the\numexpr#1+1#2-#3.#4!#5!#6!#7!#8\W -{% - \XINT_cmp_k #1#2!#5!#7!% -}% -\def\XINT_cmp_fi\Z - \expandafter\XINT_cmp_g\the\numexpr#1+1#2-#3.#4!#5!#6\W -{% - \XINT_cmp_k #1#2!#5!% -}% -\def\XINT_cmp_hi\Z - \expandafter\XINT_cmp_i\the\numexpr#1+1#2-#3.#4\W -{% - \XINT_cmp_k #1#2!% -}% -\def\XINT_cmp_k #1#2\W -{% - \xint_UDzerofork - #1{-1\relax \XINT_cmp_greater}% - 0{-1\relax \XINT_cmp_lessorequal}% - \krof -}% -\def\XINT_cmp_w #1-1#2{#2#11\Z!\W}% -\def\XINT_cmp_greater #1\Z!\W{ 1}% -\def\XINT_cmp_lessorequal 1#1!% - {\xint_gob_til_Z #1\XINT_cmp_equal\Z - \xint_gob_til_eightzeroes #1\XINT_cmp_continue 00000000% - \XINT_cmp_less }% -\def\XINT_cmp_less #1\W { -1}% -\def\XINT_cmp_continue 00000000\XINT_cmp_less {\XINT_cmp_lessorequal }% -\def\XINT_cmp_equal\Z\xint_gob_til_eightzeroes\Z\XINT_cmp_continue - 00000000\XINT_cmp_less\W { 0}% -% \end{macrocode} % \subsection{\csh{xintEq}, \csh{xintGt}, \csh{xintLt}} % \lverb|1.09a.| % \begin{macrocode} @@ -21137,66 +21634,73 @@ $1$ or $-1$. \xint_afterfi{ 0}\else\xint_afterfi{ 1}\fi }% % \end{macrocode} % \subsection{\csh{xintANDof}} -% \lverb|New with 1.09a. \xintANDof works also with an empty list.| +% \lverb|New with 1.09a. \xintANDof works also with an empty list. Empty items +% however are not accepted.| +% \lverb|1.2l made \xintANDof robust against non terminated items.| % \begin{macrocode} \def\xintANDof {\romannumeral0\xintandof }% -\def\xintandof #1{\expandafter\XINT_andof_a\romannumeral`&&@#1\relax }% -\def\XINT_andof_a #1{\expandafter\XINT_andof_b\romannumeral`&&@#1\Z }% +\def\xintandof #1{\expandafter\XINT_andof_a\romannumeral`&&@#1\xint:}% +\def\XINT_andof_a #1{\expandafter\XINT_andof_b\romannumeral`&&@#1!}% \def\XINT_andof_b #1% - {\xint_gob_til_relax #1\XINT_andof_e\relax\XINT_andof_c #1}% -\def\XINT_andof_c #1\Z + {\xint_gob_til_xint: #1\XINT_andof_e\xint:\XINT_andof_c #1}% +\def\XINT_andof_c #1!% {\xintifTrueAelseB {#1}{\XINT_andof_a}{\XINT_andof_no}}% -\def\XINT_andof_no #1\relax { 0}% -\def\XINT_andof_e #1\Z { 1}% +\def\XINT_andof_no #1\xint:{ 0}% +\def\XINT_andof_e #1!{ 1}% % \end{macrocode} % \subsection{\csh{xintORof}} -% \lverb|New with 1.09a. Works also with an empty list.| +% \lverb|New with 1.09a. Works also with an empty list. Empty items +% however are not accepted.| +% \lverb|1.2l made \xintORof robust against non terminated items.| % \begin{macrocode} \def\xintORof {\romannumeral0\xintorof }% -\def\xintorof #1{\expandafter\XINT_orof_a\romannumeral`&&@#1\relax }% -\def\XINT_orof_a #1{\expandafter\XINT_orof_b\romannumeral`&&@#1\Z }% +\def\xintorof #1{\expandafter\XINT_orof_a\romannumeral`&&@#1\xint:}% +\def\XINT_orof_a #1{\expandafter\XINT_orof_b\romannumeral`&&@#1!}% \def\XINT_orof_b #1% - {\xint_gob_til_relax #1\XINT_orof_e\relax\XINT_orof_c #1}% -\def\XINT_orof_c #1\Z + {\xint_gob_til_xint: #1\XINT_orof_e\xint:\XINT_orof_c #1}% +\def\XINT_orof_c #1!% {\xintifTrueAelseB {#1}{\XINT_orof_yes}{\XINT_orof_a}}% -\def\XINT_orof_yes #1\relax { 1}% -\def\XINT_orof_e #1\Z { 0}% +\def\XINT_orof_yes #1\xint:{ 1}% +\def\XINT_orof_e #1!{ 0}% % \end{macrocode} % \subsection{\csh{xintXORof}} -% \lverb|New with 1.09a. Works with an empty list, too. \XINT_xorof_c more -% efficient in 1.09i| +% \lverb|New with 1.09a. Works with an empty list, too. Empty items +% however are not accepted. \XINT_xorof_c more +% efficient in 1.09i.| +% \lverb|1.2l made \xintXORof robust against non terminated items.| % \begin{macrocode} \def\xintXORof {\romannumeral0\xintxorof }% \def\xintxorof #1{\expandafter\XINT_xorof_a\expandafter - 0\romannumeral`&&@#1\relax }% -\def\XINT_xorof_a #1#2{\expandafter\XINT_xorof_b\romannumeral`&&@#2\Z #1}% + 0\romannumeral`&&@#1\xint:}% +\def\XINT_xorof_a #1#2{\expandafter\XINT_xorof_b\romannumeral`&&@#2!#1}% \def\XINT_xorof_b #1% - {\xint_gob_til_relax #1\XINT_xorof_e\relax\XINT_xorof_c #1}% -\def\XINT_xorof_c #1\Z #2% + {\xint_gob_til_xint: #1\XINT_xorof_e\xint:\XINT_xorof_c #1}% +\def\XINT_xorof_c #1!#2% {\xintifTrueAelseB {#1}{\if #20\xint_afterfi{\XINT_xorof_a 1}% \else\xint_afterfi{\XINT_xorof_a 0}\fi}% {\XINT_xorof_a #2}% }% -\def\XINT_xorof_e #1\Z #2{ #2}% +\def\XINT_xorof_e #1!#2{ #2}% % \end{macrocode} % \subsection{\csh{xintGeq}, \csh{xintiiGeq}} % \lverb|& % PLUS GRAND OU ÉGAL % attention compare les **valeurs absolues**| +% \lverb|1.2l made \xintiiGeq robust against non terminated items.| % \begin{macrocode} \def\xintGeq {\romannumeral0\xintgeq }% -\def\xintgeq #1{\expandafter\XINT_geq\romannumeral0\xintnum{#1}\Z }% +\def\xintgeq #1{\expandafter\XINT_geq\romannumeral0\xintnum{#1}\xint:}% \def\xintiiGeq {\romannumeral0\xintiigeq }% -\def\xintiigeq #1{\expandafter\XINT_iigeq\romannumeral`&&@#1\Z }% -\def\XINT_iigeq #1#2\Z #3% +\def\xintiigeq #1{\expandafter\XINT_iigeq\romannumeral`&&@#1\xint:}% +\def\XINT_iigeq #1#2\xint:#3% {% - \expandafter\XINT_geq_fork\expandafter #1\romannumeral`&&@#3\Z #2\Z + \expandafter\XINT_geq_fork\expandafter #1\romannumeral`&&@#3\xint:#2\xint: }% \let\XINT_geq_pre \xintiigeq % TEMPORAIRE (oui, mais depuis quand ?) \let\XINT_Geq \xintGeq % TEMPORAIRE ATTENTION FAIT xintNum (et alors?) -\def\XINT_geq #1#2\Z #3% +\def\XINT_geq #1#2\xint:#3% {% - \expandafter\XINT_geq_fork\expandafter #1\romannumeral0\xintnum{#3}\Z #2\Z + \expandafter\XINT_geq_fork\expandafter #1\romannumeral0\xintnum{#3}\xint:#2\xint: }% \def\XINT_geq_fork #1#2% {% @@ -21212,37 +21716,37 @@ $1$ or $-1$. --\XINT_geq_plusplus \krof #1#2% }% -\def\XINT_geq_firstiszero #1\krof 0#2#3\Z #4\Z +\def\XINT_geq_firstiszero #1\krof 0#2#3\xint:#4\xint: {\xint_UDzerofork #2{ 1}0{ 0}\krof }% -\def\XINT_geq_secondiszero #1\krof #20#3\Z #4\Z { 1}% +\def\XINT_geq_secondiszero #1\krof #20#3\xint:#4\xint:{ 1}% \def\XINT_geq_plusminus #1-{\XINT_geq_plusplus #1{}}% \def\XINT_geq_minusplus -#1{\XINT_geq_plusplus {}#1}% \def\XINT_geq_minusminus --{\XINT_geq_plusplus {}{}}% -\def\XINT_geq_plusplus #1#2#3\Z #4\Z {\XINT_geq_pp #1#4\Z #2#3\Z }% -\def\XINT_geq_pp #1\Z +\def\XINT_geq_plusplus #1#2#3\xint:#4\xint:{\XINT_geq_pp #1#4\xint:#2#3\xint:}% +\def\XINT_geq_pp #1\xint: {% \expandafter\XINT_geq_pp_a \romannumeral0\expandafter\XINT_sepandrev_andcount \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\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 + \XINT_rsepbyviii_end_B 2345678\relax\xint_c_ii\xint_c_i + \R\xint:\xint_c_xii \R\xint:\xint_c_x \R\xint:\xint_c_viii \R\xint:\xint_c_vi + \R\xint:\xint_c_iv \R\xint:\xint_c_ii \R\xint:\xint_c_\W \X }% -\def\XINT_geq_pp_a #1.#2\X #3\Z +\def\XINT_geq_pp_a #1\xint:#2\X #3\xint: {% \expandafter\XINT_geq_checklengths - \the\numexpr #1\expandafter.% + \the\numexpr #1\expandafter\xint:% \romannumeral0\expandafter\XINT_sepandrev_andcount \romannumeral0\XINT_zeroes_forviii #3\R\R\R\R\R\R\R\R{10}0000001\W #3\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 + \XINT_rsepbyviii_end_B 2345678\relax\xint_c_ii\xint_c_i + \R\xint:\xint_c_xii \R\xint:\xint_c_x \R\xint:\xint_c_viii \R\xint:\xint_c_vi + \R\xint:\xint_c_iv \R\xint:\xint_c_ii \R\xint:\xint_c_\W \Z!\Z!\Z!\Z!\Z!\W #2\Z!\Z!\Z!\Z!\Z!\W }% -\def\XINT_geq_checklengths #1.#2.% +\def\XINT_geq_checklengths #1\xint:#2\xint: {% \ifnum #1=#2 \expandafter\xint_firstoftwo @@ -21268,56 +21772,56 @@ $1$ or $-1$. \def\XINT_geq_b #1#2#3!#4!% {% \xint_gob_til_Z #2\XINT_geq_bi \Z - \expandafter\XINT_geq_c\the\numexpr#1+1#4-#3-\xint_c_i.% + \expandafter\XINT_geq_c\the\numexpr#1+1#4-#3-\xint_c_i\xint:% }% -\def\XINT_geq_c 1#1#2.% +\def\XINT_geq_c 1#1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_geq_d #1% }% \def\XINT_geq_d #1#2#3!#4!% {% \xint_gob_til_Z #2\XINT_geq_di \Z - \expandafter\XINT_geq_e\the\numexpr#1+1#4-#3-\xint_c_i.% + \expandafter\XINT_geq_e\the\numexpr#1+1#4-#3-\xint_c_i\xint:% }% -\def\XINT_geq_e 1#1#2.% +\def\XINT_geq_e 1#1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_geq_f #1% }% \def\XINT_geq_f #1#2#3!#4!% {% \xint_gob_til_Z #2\XINT_geq_fi \Z - \expandafter\XINT_geq_g\the\numexpr#1+1#4-#3-\xint_c_i.% + \expandafter\XINT_geq_g\the\numexpr#1+1#4-#3-\xint_c_i\xint:% }% -\def\XINT_geq_g 1#1#2.% +\def\XINT_geq_g 1#1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_geq_h #1% }% \def\XINT_geq_h #1#2#3!#4!% {% \xint_gob_til_Z #2\XINT_geq_hi \Z - \expandafter\XINT_geq_i\the\numexpr#1+1#4-#3-\xint_c_i.% + \expandafter\XINT_geq_i\the\numexpr#1+1#4-#3-\xint_c_i\xint:% }% -\def\XINT_geq_i 1#1#2.% +\def\XINT_geq_i 1#1#2\xint:% {% 1#2\expandafter!\the\numexpr\XINT_geq_a #1% }% \def\XINT_geq_bi\Z - \expandafter\XINT_geq_c\the\numexpr#1+1#2-#3.#4!#5!#6!#7!#8!#9!\Z !\W + \expandafter\XINT_geq_c\the\numexpr#1+1#2-#3\xint:#4!#5!#6!#7!#8!#9!\Z !\W {% \XINT_geq_k #1#2!#5!#7!#9!% }% \def\XINT_geq_di\Z - \expandafter\XINT_geq_e\the\numexpr#1+1#2-#3.#4!#5!#6!#7!#8\W + \expandafter\XINT_geq_e\the\numexpr#1+1#2-#3\xint:#4!#5!#6!#7!#8\W {% \XINT_geq_k #1#2!#5!#7!% }% \def\XINT_geq_fi\Z - \expandafter\XINT_geq_g\the\numexpr#1+1#2-#3.#4!#5!#6\W + \expandafter\XINT_geq_g\the\numexpr#1+1#2-#3\xint:#4!#5!#6\W {% \XINT_geq_k #1#2!#5!% }% \def\XINT_geq_hi\Z - \expandafter\XINT_geq_i\the\numexpr#1+1#2-#3.#4\W + \expandafter\XINT_geq_i\the\numexpr#1+1#2-#3\xint:#4\W {% \XINT_geq_k #1#2!% }% @@ -21405,28 +21909,36 @@ $1$ or $-1$. % \end{macrocode} % \subsection{\csh{xintiMaxof}, \csh{xintiiMaxof}} % \lverb|New with 1.09a. 1.2 has NO MORE \xintMaxof, requires \xintfracname. -% 1.2a adds \xintiiMaxof, as \xintiiMaxof:csv is not public.| +% 1.2a adds \xintiiMaxof, as \xintiiMaxof:csv is not public. +% +% NOT compatible with empty list.| +% \lverb|1.2l made \xintiiMaxof robust against non terminated items.| % \begin{macrocode} \def\xintiMaxof {\romannumeral0\xintimaxof }% -\def\xintimaxof #1{\expandafter\XINT_imaxof_a\romannumeral`&&@#1\relax }% -\def\XINT_imaxof_a #1{\expandafter\XINT_imaxof_b\romannumeral0\xintnum{#1}\Z }% -\def\XINT_imaxof_b #1\Z #2% - {\expandafter\XINT_imaxof_c\romannumeral`&&@#2\Z {#1}\Z}% +\def\xintimaxof #1{\expandafter\XINT_imaxof_a\romannumeral`&&@#1\xint:}% +\def\XINT_imaxof_a +#1{\expandafter\XINT_imaxof_b\romannumeral0\xintnum{#1}!}% +% \end{macrocode} +% \lverb|No \xintnum on #2 which might be \xint:, of course. But if list not +% terminated the \xintNum will be done via \xintimax.| +% \begin{macrocode} +\def\XINT_imaxof_b #1!#2% + {\expandafter\XINT_imaxof_c\romannumeral`&&@#2!{#1}!}% \def\XINT_imaxof_c #1% - {\xint_gob_til_relax #1\XINT_imaxof_e\relax\XINT_imaxof_d #1}% -\def\XINT_imaxof_d #1\Z + {\xint_gob_til_xint: #1\XINT_imaxof_e\xint:\XINT_imaxof_d #1}% +\def\XINT_imaxof_d #1!% {\expandafter\XINT_imaxof_b\romannumeral0\xintimax {#1}}% -\def\XINT_imaxof_e #1\Z #2\Z { #2}% +\def\XINT_imaxof_e #1!#2!{ #2}% \def\xintiiMaxof {\romannumeral0\xintiimaxof }% -\def\xintiimaxof #1{\expandafter\XINT_iimaxof_a\romannumeral`&&@#1\relax }% -\def\XINT_iimaxof_a #1{\expandafter\XINT_iimaxof_b\romannumeral`&&@#1\Z }% -\def\XINT_iimaxof_b #1\Z #2% - {\expandafter\XINT_iimaxof_c\romannumeral`&&@#2\Z {#1}\Z}% +\def\xintiimaxof #1{\expandafter\XINT_iimaxof_a\romannumeral`&&@#1\xint:}% +\def\XINT_iimaxof_a #1{\expandafter\XINT_iimaxof_b\romannumeral`&&@#1!}% +\def\XINT_iimaxof_b #1!#2% + {\expandafter\XINT_iimaxof_c\romannumeral`&&@#2!{#1}!}% \def\XINT_iimaxof_c #1% - {\xint_gob_til_relax #1\XINT_iimaxof_e\relax\XINT_iimaxof_d #1}% -\def\XINT_iimaxof_d #1\Z + {\xint_gob_til_xint: #1\XINT_iimaxof_e\xint:\XINT_iimaxof_d #1}% +\def\XINT_iimaxof_d #1!% {\expandafter\XINT_iimaxof_b\romannumeral0\xintiimax {#1}}% -\def\XINT_iimaxof_e #1\Z #2\Z { #2}% +\def\XINT_iimaxof_e #1!#2!{ #2}% % \end{macrocode} % \subsection{\csh{xintiMin}, \csh{xintiiMin}} % \lverb|\xintnum added New with 1.09a. I add \xintiiMin in 1.1 and mark as @@ -21506,59 +22018,55 @@ $1$ or $-1$. % \lverb|1.09a. 1.2a adds \xintiiMinof which was lacking.| % \begin{macrocode} \def\xintiMinof {\romannumeral0\xintiminof }% -\def\xintiminof #1{\expandafter\XINT_iminof_a\romannumeral`&&@#1\relax }% -\def\XINT_iminof_a #1{\expandafter\XINT_iminof_b\romannumeral0\xintnum{#1}\Z }% -\def\XINT_iminof_b #1\Z #2% - {\expandafter\XINT_iminof_c\romannumeral`&&@#2\Z {#1}\Z}% +\def\xintiminof #1{\expandafter\XINT_iminof_a\romannumeral`&&@#1\xint:}% +\def\XINT_iminof_a #1{\expandafter\XINT_iminof_b\romannumeral0\xintnum{#1}!}% +\def\XINT_iminof_b #1!#2% + {\expandafter\XINT_iminof_c\romannumeral`&&@#2!{#1}!}% \def\XINT_iminof_c #1% - {\xint_gob_til_relax #1\XINT_iminof_e\relax\XINT_iminof_d #1}% -\def\XINT_iminof_d #1\Z + {\xint_gob_til_xint: #1\XINT_iminof_e\xint:\XINT_iminof_d #1}% +\def\XINT_iminof_d #1!% {\expandafter\XINT_iminof_b\romannumeral0\xintimin {#1}}% -\def\XINT_iminof_e #1\Z #2\Z { #2}% +\def\XINT_iminof_e #1!#2!{ #2}% \def\xintiiMinof {\romannumeral0\xintiiminof }% -\def\xintiiminof #1{\expandafter\XINT_iiminof_a\romannumeral`&&@#1\relax }% -\def\XINT_iiminof_a #1{\expandafter\XINT_iiminof_b\romannumeral`&&@#1\Z }% -\def\XINT_iiminof_b #1\Z #2% - {\expandafter\XINT_iiminof_c\romannumeral`&&@#2\Z {#1}\Z}% +\def\xintiiminof #1{\expandafter\XINT_iiminof_a\romannumeral`&&@#1\xint:}% +\def\XINT_iiminof_a #1{\expandafter\XINT_iiminof_b\romannumeral`&&@#1!}% +\def\XINT_iiminof_b #1!#2% + {\expandafter\XINT_iiminof_c\romannumeral`&&@#2!{#1}!}% \def\XINT_iiminof_c #1% - {\xint_gob_til_relax #1\XINT_iiminof_e\relax\XINT_iiminof_d #1}% -\def\XINT_iiminof_d #1\Z + {\xint_gob_til_xint: #1\XINT_iiminof_e\xint:\XINT_iiminof_d #1}% +\def\XINT_iiminof_d #1!% {\expandafter\XINT_iiminof_b\romannumeral0\xintiimin {#1}}% -\def\XINT_iiminof_e #1\Z #2\Z { #2}% +\def\XINT_iiminof_e #1!#2!{ #2}% % \end{macrocode} % \subsection{\csh{xintiiSum}} -% \lverb|\xintiiSum {{a}{b}...{z}}, \xintiiSumExpr {a}{b}...{z}\relax +% \lverb|\xintiiSum {{a}{b}...{z}} %| % \begin{macrocode} \def\xintiiSum {\romannumeral0\xintiisum }% -\def\xintiisum #1{\xintiisumexpr #1\relax }% -\def\xintiiSumExpr {\romannumeral0\xintiisumexpr }% -\def\xintiisumexpr {\expandafter\XINT_sumexpr\romannumeral`&&@}% +\def\xintiisum #1{\expandafter\XINT_sumexpr\romannumeral`&&@#1\xint:}% \def\XINT_sumexpr {\XINT_sum_loop_a 0\Z }% \def\XINT_sum_loop_a #1\Z #2% - {\expandafter\XINT_sum_loop_b \romannumeral`&&@#2\Z #1\Z \Z}% + {\expandafter\XINT_sum_loop_b \romannumeral`&&@#2\xint:#1\xint:\Z}% \def\XINT_sum_loop_b #1% - {\xint_gob_til_relax #1\XINT_sum_finished\relax\XINT_sum_loop_c #1}% + {\xint_gob_til_xint: #1\XINT_sum_finished\xint:\XINT_sum_loop_c #1}% \def\XINT_sum_loop_c {\expandafter\XINT_sum_loop_a\romannumeral0\XINT_add_fork }% -\def\XINT_sum_finished #1\Z #2\Z \Z { #2}% +\def\XINT_sum_finished\xint:\XINT_sum_loop_c\xint:\xint:#1\xint:\Z{ #1}% % \end{macrocode} % \subsection{\csh{xintiiPrd}} -% \lverb|\xintiiPrd {{a}...{z}}, \xintiiPrdExpr {a}...{z}\relax +% \lverb|\xintiiPrd {{a}...{z}} %| % \begin{macrocode} \def\xintiiPrd {\romannumeral0\xintiiprd }% -\def\xintiiprd #1{\xintiiprdexpr #1\relax }% -\def\xintiiPrdExpr {\romannumeral0\xintiiprdexpr }% -\def\xintiiprdexpr {\expandafter\XINT_prdexpr\romannumeral`&&@}% +\def\xintiiprd #1{\expandafter\XINT_prdexpr\romannumeral`&&@#1\xint:}% \def\XINT_prdexpr {\XINT_prod_loop_a 1\Z }% \def\XINT_prod_loop_a #1\Z #2% - {\expandafter\XINT_prod_loop_b \romannumeral`&&@#2\Z #1\Z \Z}% + {\expandafter\XINT_prod_loop_b\romannumeral`&&@#2\xint:#1\xint:\Z}% \def\XINT_prod_loop_b #1% - {\xint_gob_til_relax #1\XINT_prod_finished\relax\XINT_prod_loop_c #1}% + {\xint_gob_til_xint: #1\XINT_prod_finished\xint:\XINT_prod_loop_c #1}% \def\XINT_prod_loop_c {\expandafter\XINT_prod_loop_a\romannumeral0\XINT_mul_fork }% -\def\XINT_prod_finished\relax\XINT_prod_loop_c #1\Z #2\Z \Z { #2}% +\def\XINT_prod_finished\xint:\XINT_prod_loop_c\xint:\xint:#1\xint:\Z { #1}% % \end{macrocode} % \lverb|& % & @@ -21715,7 +22223,7 @@ $1$ or $-1$. % % Rewritten for 1.2i, this was old code. % -%! +% ! % \begin{macrocode} \def\xintDSx {\romannumeral0\xintdsx }% \def\xintdsx #1#2% @@ -21802,6 +22310,8 @@ $1$ or $-1$. % leading sign (+ or -). % % Entirely rewritten for 1.2i (2016/12/11). +% +% Attention: \xintDecSplit not robust against non terminated second argument. % ! % \begin{macrocode} \def\xintDecSplit {\romannumeral0\xintdecsplit }% @@ -21882,8 +22392,7 @@ $1$ or $-1$. {% \expandafter\XINT_split_fromright_a \the\numexpr#1-\numexpr\XINT_length_loop - #2\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax + #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint: \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye .#2\xint_bye @@ -21955,19 +22464,20 @@ $1$ or $-1$. \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}\xint_relax }% -\def\xintiisquareroot #1{\expandafter\XINT_sqrt_checkin\romannumeral`&&@#1\xint_relax }% + {\expandafter\XINT_sqrt_checkin\romannumeral0\xintnum{#1}\xint:}% +\def\xintiisquareroot #1{\expandafter\XINT_sqrt_checkin\romannumeral`&&@#1\xint:}% \def\XINT_sqrt_checkin #1% {% \xint_UDzerominusfork #1-\XINT_sqrt_iszero 0#1\XINT_sqrt_isneg - 0-{\XINT_sqrt #1}% - \krof + 0-\XINT_sqrt + \krof #1% }% -\def\XINT_sqrt_iszero #1\xint_relax {{1}{1}}% -\def\XINT_sqrt_isneg #1\xint_relax {\xintError:RootOfNegative{1}{1}}% -\def\XINT_sqrt #1\xint_relax +\def\XINT_sqrt_iszero #1\xint:{{1}{1}}% +\def\XINT_sqrt_isneg #1\xint:{\XINT_signalcondition{InvalidOperation}{square + root of negative: #1}{}{{0}{0}}}% +\def\XINT_sqrt #1\xint: {% \expandafter\XINT_sqrt_start\romannumeral0\xintlength {#1}.#1.% }% @@ -22222,7 +22732,7 @@ $1$ or $-1$. }% \def\XINT_sqrt_big_ke #1% {% - \if0\XINT_Sgn #1\Z + \if0\XINT_Sgn #1\xint: \expandafter \XINT_sqrt_big_end \else \expandafter \XINT_sqrt_big_kf \fi {#1}% @@ -22268,12 +22778,15 @@ $1$ or $-1$. % \begin{macrocode} \def\XINT_binom_fork #1#2.#3#4.#5#6.% {% - \if-#5\xint_dothis{\xintError:OutOfRangeBinomial\space 0}\fi + \if-#5\xint_dothis{\XINT_signalcondition{InvalidOperation}{Binomial with + negative first arg: #5#6}{}{0}}\fi \if-#1\xint_dothis{ 0}\fi \if-#3\xint_dothis{ 0}\fi \if0#1\xint_dothis{ 1}\fi \if0#3\xint_dothis{ 1}\fi - \ifnum #5#6>\xint_c_x^viii_mone\xint_dothis{\xintError:OutOfRangeBinomial\space 0}\fi + \ifnum #5#6>\xint_c_x^viii_mone\xint_dothis + {\XINT_signalcondition{InvalidOperation}{Binomial with too + large argument: 99999999 < #5#6}{}{0}}\fi \ifnum #1#2>#3#4 \xint_dothis{\XINT_binom_a #1#2.#3#4.}\fi \xint_orthat{\XINT_binom_a #3#4.#1#2.}% }% @@ -22282,12 +22795,12 @@ $1$ or $-1$. % quotient un terminateur 1!\Z!0!. On va procéder par petite multiplication % suivie par petite division. Donc ici on met le 1!\Z!0! pour amorcer. % -% Le 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W est le terminateur pour le +% Le \xint_bye!2!3!4!5!6!7!8!9!\xint_bye\xint_c_i\relax est le terminateur pour le % \XINT_unsep_cuzsmall final.| % \begin{macrocode} \def\XINT_binom_a #1.#2.% {% - \expandafter\XINT_binom_b\the\numexpr \xint_c_i+#1.1.#2.100000001!1!\Z!0!% + \expandafter\XINT_binom_b\the\numexpr \xint_c_i+#1.1.#2.100000001!1!;!0!% }% % \end{macrocode} % \lverb|y=x-k+1.j=1.k. On va évaluer par y/1*(y+1)/2*(y+2)/3 etc... On essaie @@ -22310,7 +22823,7 @@ $1$ or $-1$. }% % \end{macrocode} % \lverb|y.j.k. Au départ on avait x-k+1.1.k. Ensuite on a des blocs 1<8d>! -% donnant le résultat intermédiaire, dans l'ordre, et à la fin on a 1!1\Z!0!. +% donnant le résultat intermédiaire, dans l'ordre, et à la fin on a 1!1;!0!. % Dans smallloop on peut prendre 4 par 4.| % \begin{macrocode} \def\XINT_binom_smallloop #1.#2.#3.% @@ -22452,20 +22965,22 @@ $1$ or $-1$. \the\numexpr #2*(#2+\xint_c_i)*(#2+\xint_c_ii)*(#2+\xint_c_iii)\expandafter !\the\numexpr #1*(#1+\xint_c_i)*(#1+\xint_c_ii)*(#1+\xint_c_iii)!% }% -\def\XINT_binom_mul #1!#21!\Z!0!% +% \end{macrocode} +% \begin{macrocode} +\def\XINT_binom_mul #1!#21!;!0!% {% \expandafter\XINT_rev_nounsep\expandafter{\expandafter}% \the\numexpr\expandafter\XINT_smallmul \the\numexpr\xint_c_x^viii+#1\expandafter - !\romannumeral0\XINT_rev_nounsep {}1\Z!#2% + !\romannumeral0\XINT_rev_nounsep {}1;!#2% \R!\R!\R!\R!\R!\R!\R!\R!\W \R!\R!\R!\R!\R!\R!\R!\R!\W - 1\Z!% + 1;!% }% -\def\XINT_binom_div #1!1\Z!% +\def\XINT_binom_div #1!1;!% {% \expandafter\XINT_smalldivx_a - \the\numexpr #1/\xint_c_ii\expandafter.% + \the\numexpr #1/\xint_c_ii\expandafter\xint: \the\numexpr \xint_c_x^viii+#1!% }% % \end{macrocode} @@ -22507,8 +23022,10 @@ $1$ or $-1$. \the\numexpr\expandafter\XINT_binom_div\the\numexpr #2\expandafter !\romannumeral0\XINT_binom_mul #1!% }% -\def\XINT_binom_finish #1\Z!0!% - {\XINT_unsep_cuzsmall #11\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W }% +% \end{macrocode} +% \begin{macrocode} +\def\XINT_binom_finish #1;!0!% + {\XINT_unsep_cuzsmall #1\xint_bye!2!3!4!5!6!7!8!9!\xint_bye\xint_c_i\relax}% % \end{macrocode} % \lverb|Duplication de code seulement pour la boucle avec très % petits coeffs, mais en plus on fait au maximum des possibilités. (on @@ -22560,8 +23077,9 @@ $1$ or $-1$. \expandafter\XINT_binom_vsmallfinish \the\numexpr\XINT_binom_vsmallmuldiv #2!#1!% }% -\edef\XINT_binom_vsmallfinish 1#1!1!\Z!0!% - {\noexpand\expandafter\space\noexpand\the\numexpr #1\relax}% +\def\XINT_binom_vsmallfinish#1{% +\def\XINT_binom_vsmallfinish1##1!1!;!0!{\expandafter#1\the\numexpr##1\relax}% +}\XINT_binom_vsmallfinish{ }% % \end{macrocode} % \subsection{\csh{xintiiPFactorial}, \csh{xintiPFactorial}} % \lverb?2015/11/29 for 1.2f. Partial factorial pfac(a,b)=(a+1)...b, only for @@ -22594,7 +23112,9 @@ $1$ or $-1$. \ifnum #3#4>\xint_c_x^viii_mone\xint_dothis\XINT_pfac_outofrange\fi \xint_orthat \XINT_pfac_a #1#2.#3#4.% }% -\def\XINT_pfac_outofrange #1.#2.{\xintError:OutOfRangePFac\space 0}% +\def\XINT_pfac_outofrange #1.#2.% + {\XINT_signalcondition{InvalidOperation}{PFactorial with + too big second arg: 99999999 < #2}{}{0}}% \def\XINT_pfac_one #1.#2.{ 1}% \def\XINT_pfac_zero #1.#2.{ 0}% \def\XINT_pfac_neg -#1.-#2.% @@ -22607,7 +23127,7 @@ $1$ or $-1$. }% \def\XINT_pfac_a #1.#2.% {% - \expandafter\XINT_pfac_b\the\numexpr \xint_c_i+#1.#2.100000001!1\Z!% + \expandafter\XINT_pfac_b\the\numexpr \xint_c_i+#1.#2.100000001!1;!% 1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W }% \def\XINT_pfac_b #1.% @@ -22740,7 +23260,8 @@ $1$ or $-1$. {\expandafter\XINT_dsx_append\romannumeral\XINT_rep #1\endcsname 0.}% \def\XINT_iie_neg #1.#2;{ #2}% % \end{macrocode} -% \subsection{``Load \xintfracnameimp'' macros} +% \subsection*{``Load \xintfracnameimp'' macros} +% \addcontentsline{toc}{subsection}{``Load \xintfracnameimp'' macros} % \lverb|Originally was used in \xintiiexpr. Transferred from xintfrac for 1.1.| % \begin{macrocode} \catcode`! 11 @@ -22750,8 +23271,7 @@ $1$ or $-1$. \def\xintMinof {\Did_you_mean_iMinof?or_load_xintfrac!}% \def\xintSum {\Did_you_mean_iiSum?or_load_xintfrac!}% \def\xintPrd {\Did_you_mean_iiPrd?or_load_xintfrac!}% -\def\xintPrdExpr {\Did_you_mean_iiPrdExpr?or_load_xintfrac!}% -\def\xintSumExpr {\Did_you_mean_iiSumExpr?or_load_xintfrac!}% +\catcode`! 12 \XINT_restorecatcodes_endinput% % \end{macrocode} % @@ -22827,7 +23347,17 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xintbinhex}% - [2017/01/06 1.2k Expandable binary and hexadecimal conversions (JFB)]% + [2017/07/26 1.2l Expandable binary and hexadecimal conversions (JFB)]% +% \end{macrocode} +% \subsection{Antique helper macro} +% \lverb!At 1.2, it was left in xint.sty rather than being moved to +% xintcore.sty, thus breaking \xintHexToDec here.! +% \begin{macrocode} +\def\xint_cleanupzeros_andstop#1{% +\def\xint_cleanupzeros_andstop ##1##2##3##4% +{% + \expandafter#1\the\numexpr ##1##2##3##4\relax +}}\xint_cleanupzeros_andstop{ }% % \end{macrocode} % \subsection{Constants, etc...} % \lverb!1.08! @@ -23110,10 +23640,11 @@ $1$ or $-1$. {% \expandafter\XINT_dtb_end_d\the\numexpr #1#2#3#4#5#6#7#8\relax }% -\edef\XINT_dtb_end_d #1#2#3#4#5#6#7#8#9% +\def\XINT_dtb_end_d#1{% +\def\XINT_dtb_end_d ##1##2##3##4##5##6##7##8##9% {% - \noexpand\expandafter\space\noexpand\the\numexpr #1#2#3#4#5#6#7#8#9\relax -}% + \expandafter#1\the\numexpr ##1##2##3##4##5##6##7##8##9\relax +}}\XINT_dtb_end_d{ }% % \end{macrocode} % \subsection{\csh{xintHexToDec}} % \lverb!1.08! @@ -23149,10 +23680,10 @@ $1$ or $-1$. {% \expandafter\xint_cleanupzeros_andstop \romannumeral0\XINT_rord_main {}#1% - \xint_relax + \xint: \xint_bye\xint_bye\xint_bye\xint_bye \xint_bye\xint_bye\xint_bye\xint_bye - \xint_relax + \xint: }% \def\XINT_htd_II_ci #1\XINT_htd_II_ciii #2\W\W\W {\XINT_htd_II_d {}{"#2}{\xint_c_xvi}}% @@ -23197,10 +23728,11 @@ $1$ or $-1$. {% \XINT_htd_II_end_b #1#3% }% -\edef\XINT_htd_II_end_b #1#2#3#4#5#6#7#8% +\def\XINT_htd_II_end_b#1{% +\def\XINT_htd_II_end_b ##1##2##3##4##5##6##7##8% {% - \noexpand\expandafter\space\noexpand\the\numexpr #1#2#3#4#5#6#7#8\relax -}% + \expandafter#1\the\numexpr ##1##2##3##4##5##6##7##8\relax +}}\XINT_htd_II_end_b{ }% % \end{macrocode} % \subsection{\csh{xintBinToDec}} % \lverb!1.08! @@ -23240,15 +23772,16 @@ $1$ or $-1$. {% \expandafter\XINT_btd_II_c_end \romannumeral0\XINT_rord_main {}#2% - \xint_relax + \xint: \xint_bye\xint_bye\xint_bye\xint_bye \xint_bye\xint_bye\xint_bye\xint_bye - \xint_relax + \xint: }% -\edef\XINT_btd_II_c_end #1#2#3#4#5#6% +\def\XINT_btd_II_c_end#1{% +\def\XINT_btd_II_c_end ##1##2##3##4##5##6% {% - \noexpand\expandafter\space\noexpand\the\numexpr #1#2#3#4#5#6\relax -}% + \expandafter#1\the\numexpr ##1##2##3##4##5##6\relax +}}\XINT_btd_II_c_end{ }% \def\XINT_btd_II_ci #1\XINT_btd_II_cvii #2\W\W\W\W\W\W\W {\XINT_btd_II_d {}{#2}{\xint_c_ii }}% \def\XINT_btd_II_cii #1\XINT_btd_II_cvii #2\W\W\W\W\W\W @@ -23285,10 +23818,11 @@ $1$ or $-1$. {% \XINT_btd_II_end_b #1#3% }% -\edef\XINT_btd_II_end_b #1#2#3#4#5#6#7#8#9% +\def\XINT_btd_II_end_b#1{% +\def\XINT_btd_II_end_b ##1##2##3##4##5##6##7##8##9% {% - \noexpand\expandafter\space\noexpand\the\numexpr #1#2#3#4#5#6#7#8#9\relax -}% + \expandafter#1\the\numexpr ##1##2##3##4##5##6##7##8##9\relax +}}\XINT_btd_II_end_b{ }% \def\XINT_btd_I_a #1#2#3#4#5#6#7#8% {% \xint_gob_til_Z #3\XINT_btd_I_end_a\Z @@ -23317,10 +23851,9 @@ $1$ or $-1$. \def\xintbintohex #1% {% \expandafter\XINT_bth_checkin - \romannumeral0\expandafter\XINT_num_loop - \romannumeral`&&@#1\xint_relax\xint_relax - \xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\Z + \romannumeral0\expandafter\XINT_num_cleanup + \the\numexpr\expandafter\XINT_num_loop + \romannumeral`&&@#1\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z \R\R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W\W }% \def\XINT_bth_checkin #1% @@ -23392,9 +23925,9 @@ $1$ or $-1$. }% \def\XINT_htb_II_b #1#2#3\T {% - \XINT_num_loop #2#1% - \xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\Z + \expandafter\XINT_num_cleanup + \the\numexpr\expandafter\XINT_num_loop #2#1% + \xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z }% % \end{macrocode} % \subsection{\csh{xintCHexToBin}} @@ -23436,12 +23969,12 @@ $1$ or $-1$. \XINT_chtb_I\expandafter\expandafter\expandafter #1% {% \XINT_chtb_end_b #1% - \xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\Z + \xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z }% \def\XINT_chtb_end_b #1\W#2\W#3\W#4\W#5\W#6\W#7\W#8\W\endcsname {% - \XINT_num_loop + \expandafter\XINT_num_cleanup + \the\numexpr\expandafter\XINT_num_loop }% \XINT_restorecatcodes_endinput% % \end{macrocode} @@ -23527,7 +24060,7 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xintgcd}% - [2017/01/06 1.2k Euclide algorithm with xint package (JFB)]% + [2017/07/26 1.2l Euclide algorithm with xint package (JFB)]% % \end{macrocode} % \subsection{\csh{xintGCD}, \csh{xintiiGCD}} % \begin{macrocode} @@ -23566,9 +24099,9 @@ $1$ or $-1$. \def\XINT_gcd_BisZero #1#2{ #2}% \def\XINT_gcd_CheckRem #1#2\Z {% - \xint_gob_til_zero #1\xint_gcd_end0\XINT_gcd_loop {#1#2}% + \xint_gob_til_zero #1\XINT_gcd_end0\XINT_gcd_loop {#1#2}% }% -\def\xint_gcd_end0\XINT_gcd_loop #1#2{ #2}% +\def\XINT_gcd_end0\XINT_gcd_loop #1#2{ #2}% % \end{macrocode} % \lverb|#1=B, #2=A| % \begin{macrocode} @@ -23616,18 +24149,23 @@ $1$ or $-1$. \def\XINT_lcm_notzero #1#2#3{\xintiimul {#2}{\xintiiQuo{#3}{#1}}}% % \end{macrocode} % \subsection{\csh{xintBezout}} +% \lverb|& +% Produces {A}{B}{U}{V}{D} with UA-VB=D, D = PGCD(A,B) (positive). +% +% 1.2l raises InvalidOperation if both A and B vanish. +%| % \begin{macrocode} \def\xintBezout {\romannumeral0\xintbezout }% \def\xintbezout #1% {% - \expandafter\xint_bezout\expandafter {\romannumeral0\xintnum{#1}}% + \expandafter\XINT_bezout\expandafter {\romannumeral0\xintnum{#1}}% }% -\def\xint_bezout #1#2% +\def\XINT_bezout #1#2% {% \expandafter\XINT_bezout_fork \romannumeral0\xintnum{#2}\Z #1\Z }% % \end{macrocode} -% \lverb|#3#4 = A, #1#2=B| +% \lverb|#3#4 = A, #1#2=B. Micro improvement for 1.2l.| % \begin{macrocode} \def\XINT_bezout_fork #1#2\Z #3#4\Z {% @@ -23635,39 +24173,39 @@ $1$ or $-1$. #1#3\XINT_bezout_botharezero #10\XINT_bezout_secondiszero #30\XINT_bezout_firstiszero - 00{\xint_UDsignsfork + 00\xint_UDsignsfork + \krof #1#3\XINT_bezout_minusminus % A < 0, B < 0 #1-\XINT_bezout_minusplus % A > 0, B < 0 #3-\XINT_bezout_plusminus % A < 0, B > 0 --\XINT_bezout_plusplus % A > 0, B > 0 - \krof }% \krof {#2}{#4}#1#3{#3#4}{#1#2}% #1#2=B, #3#4=A }% -\edef\XINT_bezout_botharezero #1#2#3#4#5#6% -{% - \noexpand\xintError:NoBezoutForZeros\space {0}{0}{0}{0}{0}% -}% +\def\XINT_bezout_botharezero #1\krof#2#3#4#5#6#7% + {\XINT_signalcondition{InvalidOperation} + {No Bezout identity for 0 and 0}{}{{0}{0}{0}{0}{0}}}% % \end{macrocode} -% \lverb|& -% attention première entrée doit être ici (-1)^n donc 1$\ -% #4#2 = 0 = A, B = #3#1| +% \lverb|I stayed without looking at this file for perhaps three years and +% much to my dismay I realized in January 2017 that both \xintBezout{0}{B} and +% \xintBezout{A}{0} were completely buggy, due to a confusion about macro +% parameters I guess... and no testing ! I must have tested, I don't +% understand. (regression testing for xint was put in place only late 2016) +% +% Thus rewritten for 1.2l.| % \begin{macrocode} -\def\XINT_bezout_firstiszero #1#2#3#4#5#6% +\def\XINT_bezout_firstiszero #1\krof#2#3#4#5#6#7% {% \xint_UDsignfork - #3{ {0}{#3#1}{0}{1}{#1}}% - -{ {0}{#3#1}{0}{-1}{#1}}% + #4{{0}{#7}{0}{1}{#2}}% + -{{0}{#7}{0}{-1}{#7}}% \krof }% -% \end{macrocode} -% \lverb|#4#2 = A, B = #3#1 = 0| -% \begin{macrocode} -\def\XINT_bezout_secondiszero #1#2#3#4#5#6% +\def\XINT_bezout_secondiszero #1\krof#2#3#4#5#6#7% {% \xint_UDsignfork - #4{ {#4#2}{0}{-1}{0}{#2}}% - -{ {#4#2}{0}{1}{0}{#2}}% + #5{{#6}{0}{-1}{0}{#3}}% + -{{#6}{0}{1}{0}{#6}}% \krof }% % \end{macrocode} @@ -23687,10 +24225,11 @@ $1$ or $-1$. {% \expandafter\XINT_bezout_mm_postc\expandafter {#2}{#1}% }% -\edef\XINT_bezout_mm_postc #1#2#3#4#5% -{% - \space {#4}{#5}{#1}{#2}{#3}% -}% +% \end{macrocode} +% \lverb|I was using \edef to insert a space token upfront, where there is in +% fact no need for it ! Such ignorance is appalling ... | +% \begin{macrocode} +\def\XINT_bezout_mm_postc #1#2#3#4#5{{#4}{#5}{#1}{#2}{#3}}% % \end{macrocode} % \lverb|minusplus #4#2= A > 0, B < 0| % \begin{macrocode} @@ -23704,10 +24243,7 @@ $1$ or $-1$. \expandafter\XINT_bezout_mp_postb\expandafter {\romannumeral0\xintiiopp {#2}}{#1}% }% -\edef\XINT_bezout_mp_postb #1#2#3#4#5% -{% - \space {#4}{#5}{#2}{#1}{#3}% -}% +\def\XINT_bezout_mp_postb #1#2#3#4#5{{#4}{#5}{#2}{#1}{#3}}% % \end{macrocode} % \lverb|plusminus A < 0, B > 0| % \begin{macrocode} @@ -23721,10 +24257,7 @@ $1$ or $-1$. \expandafter \XINT_bezout_pm_postb \expandafter {\romannumeral0\xintiiopp{#1}}% }% -\edef\XINT_bezout_pm_postb #1#2#3#4#5% -{% - \space {#4}{#5}{#1}{#2}{#3}% -}% +\def\XINT_bezout_pm_postb #1#2#3#4#5{{#4}{#5}{#1}{#2}{#3}}% % \end{macrocode} % \lverb|plusplus| % \begin{macrocode} @@ -23736,10 +24269,7 @@ $1$ or $-1$. % \end{macrocode} % \lverb|la parité (-1)^N est en #1, et on la jette ici.| % \begin{macrocode} -\edef\XINT_bezout_pp_post #1#2#3#4#5% -{% - \space {#4}{#5}{#1}{#2}{#3}% -}% +\def\XINT_bezout_pp_post #1#2#3#4#5{{#4}{#5}{#1}{#2}{#3}}% % \end{macrocode} % \lverb|& % n = 0: 1BAalpha(0)beta(0)alpha(-1)beta(-1)$\ @@ -23749,8 +24279,7 @@ $1$ or $-1$. % \begin{macrocode} \def\XINT_bezout_loop_a #1#2#3% {% - \expandafter\XINT_bezout_loop_b - \expandafter{\the\numexpr -#1\expandafter }% + \expandafter\XINT_bezout_loop_b\the\numexpr -#1\expandafter.% \romannumeral0\XINT_div_prepare {#2}{#3}{#2}% }% % \end{macrocode} @@ -23761,11 +24290,11 @@ $1$ or $-1$. % De plus ce n'est plus (-1)^n que l'on veut mais n. (ou dans un autre ordre)$\ % {-(-1)^n}{q(n)}{r(n)}{r(n-1)}{alpha(n-1)}{beta(n-1)}{alpha(n-2)}{beta(n-2)}| % \begin{macrocode} -\def\XINT_bezout_loop_b #1#2#3#4#5#6#7#8% +\def\XINT_bezout_loop_b #1.#2#3#4#5#6#7#8% {% - \expandafter \XINT_bezout_loop_c \expandafter - {\romannumeral0\xintiiadd{\XINT_mul_fork #5\Z #2\Z}{#7}}% - {\romannumeral0\xintiiadd{\XINT_mul_fork #6\Z #2\Z}{#8}}% + \expandafter\XINT_bezout_loop_c\expandafter + {\romannumeral0\xintiiadd{\XINT_mul_fork #5\xint:#2\xint:}{#7}}% + {\romannumeral0\xintiiadd{\XINT_mul_fork #6\xint:#2\xint:}{#8}}% {#1}{#3}{#4}{#5}{#6}% }% % \end{macrocode} @@ -23773,8 +24302,7 @@ $1$ or $-1$. % \begin{macrocode} \def\XINT_bezout_loop_c #1#2% {% - \expandafter \XINT_bezout_loop_d \expandafter - {#2}{#1}% + \expandafter\XINT_bezout_loop_d\expandafter{#2}{#1}% }% % \end{macrocode} % \lverb|{beta(n)}{alpha(n)}{(-1)^(n+1)}{r(n)}{r(n-1)}{alpha(n-1)}{beta(n-1)}| @@ -23788,35 +24316,26 @@ $1$ or $-1$. % \begin{macrocode} \def\XINT_bezout_loop_e #1#2\Z {% - \xint_gob_til_zero #1\xint_bezout_loop_exit0\XINT_bezout_loop_f - {#1#2}% + \xint_gob_til_zero #1\XINT_bezout_loop_exit0\XINT_bezout_loop_f {#1#2}% }% % \end{macrocode} -% \lverb|{r(n)}{(-1)^(n+1)}{r(n-1)}{alpha(n)}{beta(n)}{alpha(n-1)}{beta(n-1)}| +% \lverb|{r(n)}{(-1)^(n+1)}{r(n-1)}{alpha(n)}{beta(n)}{alpha(n-1)}{beta(n-1)} +% ->{(-1)^(n+1)}{r(n)}{r(n-1)}{alpha(n)}{beta(n)}{alpha(n-1)}{beta(n-1)} +% et itération| % \begin{macrocode} \def\XINT_bezout_loop_f #1#2% {% \XINT_bezout_loop_a {#2}{#1}% }% -% \end{macrocode} -% \lverb|{(-1)^(n+1)}{r(n)}{r(n-1)}{alpha(n)}{beta(n)}{alpha(n-1)}{beta(n-1)} -% et itération| -% \begin{macrocode} -\def\xint_bezout_loop_exit0\XINT_bezout_loop_f #1#2% +\def\XINT_bezout_loop_exit0\XINT_bezout_loop_f #1#2% {% \ifcase #2 \or \expandafter\XINT_bezout_exiteven \else\expandafter\XINT_bezout_exitodd \fi }% -\edef\XINT_bezout_exiteven #1#2#3#4#5% -{% - \space {#5}{#4}{#1}% -}% -\edef\XINT_bezout_exitodd #1#2#3#4#5% -{% - \space {-#5}{-#4}{#1}% -}% +\def\XINT_bezout_exiteven #1#2#3#4#5{{#5}{#4}{#1}}% +\def\XINT_bezout_exitodd #1#2#3#4#5{{-#5}{-#4}{#1}}% % \end{macrocode} % \subsection{\csh{xintEuclideAlgorithm}} % \lverb|& @@ -23827,11 +24346,11 @@ $1$ or $-1$. \def\xintEuclideAlgorithm {\romannumeral0\xinteuclidealgorithm }% \def\xinteuclidealgorithm #1% {% - \expandafter \XINT_euc \expandafter{\romannumeral0\xintiabs {#1}}% + \expandafter\XINT_euc\expandafter{\romannumeral0\xintiabs {#1}}% }% \def\XINT_euc #1#2% {% - \expandafter\XINT_euc_fork \romannumeral0\xintiabs {#2}\Z #1\Z + \expandafter\XINT_euc_fork\romannumeral0\xintiabs {#2}\Z #1\Z }% % \end{macrocode} % \lverb|Ici #3#4=A, #1#2=B| @@ -23852,8 +24371,8 @@ $1$ or $-1$. % On va renvoyer:$\ % {N}{A}{D=r(n)}{B}{q1}{r1}{q2}{r2}{q3}{r3}....{qN}{rN=0}| % \begin{macrocode} -\def\XINT_euc_AisZero #1#2#3#4#5#6{ {1}{0}{#2}{#2}{0}{0}}% -\def\XINT_euc_BisZero #1#2#3#4#5#6{ {1}{0}{#3}{#3}{0}{0}}% +\def\XINT_euc_AisZero #1#2#3#4#5#6{{1}{0}{#2}{#2}{0}{0}}% +\def\XINT_euc_BisZero #1#2#3#4#5#6{{1}{0}{#3}{#3}{0}{0}}% % \end{macrocode} % \lverb|& % {n}{rn}{an}{{qn}{rn}}...{{A}{B}}{}\Z$\ @@ -23862,14 +24381,13 @@ $1$ or $-1$. % \begin{macrocode} \def\XINT_euc_a #1#2#3% {% - \expandafter\XINT_euc_b - \expandafter {\the\numexpr #1+1\expandafter }% + \expandafter\XINT_euc_b\the\numexpr #1+\xint_c_i\expandafter.% \romannumeral0\XINT_div_prepare {#2}{#3}{#2}% }% % \end{macrocode} % \lverb|{n+1}{q(n+1)}{r(n+1)}{rn}{{qn}{rn}}...| % \begin{macrocode} -\def\XINT_euc_b #1#2#3#4% +\def\XINT_euc_b #1.#2#3#4% {% \XINT_euc_c #3\Z {#1}{#3}{#4}{{#2}{#3}}% }% @@ -23879,7 +24397,7 @@ $1$ or $-1$. % \begin{macrocode} \def\XINT_euc_c #1#2\Z {% - \xint_gob_til_zero #1\xint_euc_end0\XINT_euc_a + \xint_gob_til_zero #1\XINT_euc_end0\XINT_euc_a }% % \end{macrocode} % \lverb|& @@ -23888,20 +24406,17 @@ $1$ or $-1$. % {n+1}{0}{r(n)}{{q(n+1)}{r(n+1)}}.....{{q1}{r1}}{{A}{B}}{}\Z$\ % On veut renvoyer: {N=n+1}{A}{D=r(n)}{B}{q1}{r1}{q2}{r2}{q3}{r3}....{qN}{rN=0}| % \begin{macrocode} -\def\xint_euc_end0\XINT_euc_a #1#2#3#4\Z% +\def\XINT_euc_end0\XINT_euc_a #1#2#3#4\Z% {% - \expandafter\xint_euc_end_ + \expandafter\XINT_euc_end_a \romannumeral0% \XINT_rord_main {}#4{{#1}{#3}}% - \xint_relax + \xint: \xint_bye\xint_bye\xint_bye\xint_bye \xint_bye\xint_bye\xint_bye\xint_bye - \xint_relax -}% -\edef\xint_euc_end_ #1#2#3% -{% - \space {#1}{#3}{#2}% + \xint: }% +\def\XINT_euc_end_a #1#2#3{{#1}{#3}{#2}}% % \end{macrocode} % \subsection{\csh{xintBezoutAlgorithm}} % \lverb|& @@ -23931,8 +24446,8 @@ $1$ or $-1$. \krof 0{#1#2}{#3#4}1001{{#3#4}{#1#2}}{}\Z }% -\def\XINT_bezalg_AisZero #1#2#3\Z{ {1}{0}{0}{1}{#2}{#2}{1}{0}{0}{0}{0}{1}}% -\def\XINT_bezalg_BisZero #1#2#3#4\Z{ {1}{0}{0}{1}{#3}{#3}{1}{0}{0}{0}{0}{1}}% +\def\XINT_bezalg_AisZero #1#2#3\Z{{1}{0}{0}{1}{#2}{#2}{1}{0}{0}{0}{0}{1}}% +\def\XINT_bezalg_BisZero #1#2#3#4\Z{{1}{0}{0}{1}{#3}{#3}{1}{0}{0}{0}{0}{1}}% % \end{macrocode} % \lverb|& % pour préparer l'étape n+1 il faut @@ -23942,15 +24457,14 @@ $1$ or $-1$. % \begin{macrocode} \def\XINT_bezalg_a #1#2#3% {% - \expandafter\XINT_bezalg_b - \expandafter {\the\numexpr #1+1\expandafter }% + \expandafter\XINT_bezalg_b\the\numexpr #1+\xint_c_i\expandafter.% \romannumeral0\XINT_div_prepare {#2}{#3}{#2}% }% % \end{macrocode} % \lverb|& % {n+1}{q(n+1)}{r(n+1)}{r(n)}{alpha(n)}{beta(n)}{alpha(n-1)}{beta(n-1)}...| % \begin{macrocode} -\def\XINT_bezalg_b #1#2#3#4#5#6#7#8% +\def\XINT_bezalg_b #1.#2#3#4#5#6#7#8% {% \expandafter\XINT_bezalg_c\expandafter {\romannumeral0\xintiiadd {\xintiiMul {#6}{#2}}{#8}}% @@ -23979,7 +24493,7 @@ $1$ or $-1$. % \begin{macrocode} \def\XINT_bezalg_e #1#2\Z {% - \xint_gob_til_zero #1\xint_bezalg_end0\XINT_bezalg_a + \xint_gob_til_zero #1\XINT_bezalg_end0\XINT_bezalg_a }% % \end{macrocode} % \lverb|& @@ -23990,15 +24504,15 @@ $1$ or $-1$. % {N}{A}{0}{1}{D=r(n)}{B}{1}{0}{q1}{r1}{alpha1=q1}{beta1=1}$\ % {q2}{r2}{alpha2}{beta2}....{qN}{rN=0}{alphaN=A/D}{betaN=B/D}| % \begin{macrocode} -\def\xint_bezalg_end0\XINT_bezalg_a #1#2#3#4#5#6#7#8\Z +\def\XINT_bezalg_end0\XINT_bezalg_a #1#2#3#4#5#6#7#8\Z {% - \expandafter\xint_bezalg_end_ + \expandafter\XINT_bezalg_end_a \romannumeral0% \XINT_rord_main {}#8{{#1}{#3}}% - \xint_relax + \xint: \xint_bye\xint_bye\xint_bye\xint_bye \xint_bye\xint_bye\xint_bye\xint_bye - \xint_relax + \xint: }% % \end{macrocode} % \lverb|& @@ -24008,31 +24522,30 @@ $1$ or $-1$. % {N}{A}{0}{1}{D=r(n)}{B}{1}{0}{q1}{r1}{alpha1=q1}{beta1=1}$\ % {q2}{r2}{alpha2}{beta2}....{qN}{rN=0}{alphaN=A/D}{betaN=B/D}| % \begin{macrocode} -\edef\xint_bezalg_end_ #1#2#3#4% -{% - \space {#1}{#3}{0}{1}{#2}{#4}{1}{0}% -}% +\def\XINT_bezalg_end_a #1#2#3#4{{#1}{#3}{0}{1}{#2}{#4}{1}{0}}% % \end{macrocode} % \subsection{\csh{xintGCDof}} +% \lverb|1.2l adds protection against items being non-terminated \the\numexpr...| % \begin{macrocode} \def\xintGCDof {\romannumeral0\xintgcdof }% -\def\xintgcdof #1{\expandafter\XINT_gcdof_a\romannumeral`&&@#1\relax }% -\def\XINT_gcdof_a #1{\expandafter\XINT_gcdof_b\romannumeral`&&@#1\Z }% -\def\XINT_gcdof_b #1\Z #2{\expandafter\XINT_gcdof_c\romannumeral`&&@#2\Z {#1}\Z}% -\def\XINT_gcdof_c #1{\xint_gob_til_relax #1\XINT_gcdof_e\relax\XINT_gcdof_d #1}% -\def\XINT_gcdof_d #1\Z {\expandafter\XINT_gcdof_b\romannumeral0\xintgcd {#1}}% -\def\XINT_gcdof_e #1\Z #2\Z { #2}% +\def\xintgcdof #1{\expandafter\XINT_gcdof_a\romannumeral`&&@#1\xint:}% +\def\XINT_gcdof_a #1{\expandafter\XINT_gcdof_b\romannumeral`&&@#1!}% +\def\XINT_gcdof_b #1!#2{\expandafter\XINT_gcdof_c\romannumeral`&&@#2!{#1}!}% +\def\XINT_gcdof_c #1{\xint_gob_til_xint: #1\XINT_gcdof_e\xint:\XINT_gcdof_d #1}% +\def\XINT_gcdof_d #1!{\expandafter\XINT_gcdof_b\romannumeral0\xintgcd {#1}}% +\def\XINT_gcdof_e #1!#2!{ #2}% % \end{macrocode} % \subsection{\csh{xintLCMof}} % \lverb|New with 1.09a| +% \lverb|1.2l adds protection against items being non-terminated \the\numexpr...| % \begin{macrocode} \def\xintLCMof {\romannumeral0\xintlcmof }% -\def\xintlcmof #1{\expandafter\XINT_lcmof_a\romannumeral`&&@#1\relax }% -\def\XINT_lcmof_a #1{\expandafter\XINT_lcmof_b\romannumeral`&&@#1\Z }% -\def\XINT_lcmof_b #1\Z #2{\expandafter\XINT_lcmof_c\romannumeral`&&@#2\Z {#1}\Z}% -\def\XINT_lcmof_c #1{\xint_gob_til_relax #1\XINT_lcmof_e\relax\XINT_lcmof_d #1}% -\def\XINT_lcmof_d #1\Z {\expandafter\XINT_lcmof_b\romannumeral0\xintlcm {#1}}% -\def\XINT_lcmof_e #1\Z #2\Z { #2}% +\def\xintlcmof #1{\expandafter\XINT_lcmof_a\romannumeral`&&@#1\xint:}% +\def\XINT_lcmof_a #1{\expandafter\XINT_lcmof_b\romannumeral`&&@#1!}% +\def\XINT_lcmof_b #1!#2{\expandafter\XINT_lcmof_c\romannumeral`&&@#2!{#1}!}% +\def\XINT_lcmof_c #1{\xint_gob_til_xint: #1\XINT_lcmof_e\xint:\XINT_lcmof_d #1}% +\def\XINT_lcmof_d #1!{\expandafter\XINT_lcmof_b\romannumeral0\xintlcm {#1}}% +\def\XINT_lcmof_e #1!#2!{ #2}% % \end{macrocode} % \subsection{\csh{xintTypesetEuclideAlgorithm}} % \lverb|& @@ -24214,7 +24727,7 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xintfrac}% - [2017/01/06 1.2k Expandable operations on fractions (JFB)]% + [2017/07/26 1.2l Expandable operations on fractions (JFB)]% % \end{macrocode} % \subsection{\csh{XINT_cntSgnFork}} % \lverb|1.09i. Used internally, #1 must expand to \m@ne, \z@, or \@ne or @@ -24243,8 +24756,7 @@ $1$ or $-1$. {% \expandafter#1% \the\numexpr \XINT_abs##1+% - \XINT_len_fork ##2##3\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax + \XINT_len_fork ##2##3\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint: \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye-\xint_c_i \relax @@ -24260,7 +24772,7 @@ $1$ or $-1$. % \begin{macrocode} \def\XINT_outfrac #1#2#3% {% - \ifcase\XINT_cntSgn #3\Z + \ifcase\XINT_cntSgn #3\xint: \expandafter \XINT_outfrac_divisionbyzero \or \expandafter \XINT_outfrac_P @@ -24269,14 +24781,14 @@ $1$ or $-1$. \fi {#2}{#3}[#1]% }% -\def\XINT_outfrac_divisionbyzero #1#2{\xintError:DivisionByZero\space #1/0}% -\edef\XINT_outfrac_P #1#2% +\def\XINT_outfrac_divisionbyzero #1#2% {% - \noexpand\if0\noexpand\XINT_Sgn #1\noexpand\Z - \noexpand\expandafter\noexpand\XINT_outfrac_Zero - \noexpand\fi - \space #1/#2% + \XINT_signalcondition{DivisionByZero}{Division of #1 by #2}{}{0/1[0]}% }% +\def\XINT_outfrac_P#1{% +\def\XINT_outfrac_P ##1##2% + {\if0\XINT_Sgn ##1\xint:\expandafter\XINT_outfrac_Zero\fi#1##1/##2}% +}\XINT_outfrac_P{ }% \def\XINT_outfrac_Zero #1[#2]{ 0/1[0]}% \def\XINT_outfrac_N #1#2% {% @@ -24351,18 +24863,25 @@ $1$ or $-1$. % allowing decimal digits and scientific part and possibly multiple leading % signs. % +% 1.2l fixes frailty of \XINT_infrac (hence basically of all xintfrac macros) +% respective to non terminated \numexpr input: \xintRaw{\the\numexpr1} for +% example. The issue was that \numexpr sees the / and expands what's next. +% But even \numexpr 1// for example creates an error, and to my mind this is +% a defect of \numexpr. It should be able to trace back and see that / was +% used as delimiter not as operator. Anyway, I thus fixed this problem +% belatedly here regarding \XINT_infrac. % | % \begin{macrocode} \def\XINT_inFrac {\romannumeral0\XINT_infrac }% \def\XINT_infrac #1% {% - \expandafter\XINT_infrac_fork\romannumeral`&&@#1/\XINT_W[\XINT_W\XINT_T + \expandafter\XINT_infrac_fork\romannumeral`&&@#1\xint:/\XINT_W[\XINT_W\XINT_T }% \def\XINT_infrac_fork #1[#2% {% \xint_UDXINTWfork - #2\XINT_frac_gen - \XINT_W\XINT_infrac_res_a % strict A[N] or A/B[N] input + #2\XINT_frac_gen % input has no brackets [N] + \XINT_W\XINT_infrac_res_a % there is some [N], must be strict A[N] or A/B[N] input \krof #1[#2% }% @@ -24370,12 +24889,15 @@ $1$ or $-1$. {% \xint_gob_til_zero #1\XINT_infrac_res_zero 0\XINT_infrac_res_b #1% }% +% \end{macrocode} +% \lverb|Note that input exponent is here ignored and forced to be zero.| +% \begin{macrocode} \def\XINT_infrac_res_zero 0\XINT_infrac_res_b #1\XINT_T {{0}{0}{1}}% \def\XINT_infrac_res_b #1/#2% {% \xint_UDXINTWfork - #2\XINT_infrac_res_ca - \XINT_W\XINT_infrac_res_cb + #2\XINT_infrac_res_ca % it was A[N] input + \XINT_W\XINT_infrac_res_cb % it was A/B[N] input \krof #1/#2% }% @@ -24384,11 +24906,11 @@ $1$ or $-1$. % 1.2f). As nobody reads xint documentation, no one will have noticed the % fleeting possibility.| % \begin{macrocode} -\def\XINT_infrac_res_ca #1[#2]/\XINT_W[\XINT_W\XINT_T +\def\XINT_infrac_res_ca #1[#2]\xint:/\XINT_W[\XINT_W\XINT_T {\expandafter{\the\numexpr #2}{#1}{1}}% \def\XINT_infrac_res_cb #1/#2[% {\expandafter\XINT_infrac_res_cc\romannumeral`&&@#2~#1[}% -\def\XINT_infrac_res_cc #1~#2[#3]/\XINT_W[\XINT_W\XINT_T +\def\XINT_infrac_res_cc #1~#2[#3]\xint:/\XINT_W[\XINT_W\XINT_T {\expandafter{\the\numexpr #3}{#2}{#1}}% % \end{macrocode} % \subsection{\csh{XINT_frac_gen}} @@ -24407,13 +24929,16 @@ $1$ or $-1$. \def\XINT_frac_gen #1/#2% {% \xint_UDXINTWfork - #2\XINT_frac_gen_A - \XINT_W\XINT_frac_gen_B + #2\XINT_frac_gen_A % there was no / + \XINT_W\XINT_frac_gen_B % there was a / \krof #1/#2% }% -\def\XINT_frac_gen_A #1/\XINT_W [\XINT_W {\XINT_frac_gen_C 0~1!#1ee.\XINT_W }% -\def\XINT_frac_gen_B #1/#2/\XINT_W[%\XINT_W +% \end{macrocode} +% \lverb|Note that #1 is only expanded so far up to decimal mark or "e".| +% \begin{macrocode} +\def\XINT_frac_gen_A #1\xint:/\XINT_W [\XINT_W {\XINT_frac_gen_C 0~1!#1ee.\XINT_W }% +\def\XINT_frac_gen_B #1/#2\xint:/\XINT_W[%\XINT_W {% \expandafter\XINT_frac_gen_Ba \romannumeral`&&@#2ee.\XINT_W\XINT_Z #1ee.%\XINT_W @@ -24432,12 +24957,13 @@ $1$ or $-1$. {% \expandafter\XINT_frac_gen_Bd\romannumeral`&&@#2.#1e% }% +% \end{macrocode} +% \begin{macrocode} \def\XINT_frac_gen_Bd #1.#2e#3e#4\XINT_Z {% \expandafter\XINT_frac_gen_C\the\numexpr #3-% \numexpr\XINT_length_loop - #1\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax + #1\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint: \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye ~#2#1!% @@ -24453,9 +24979,8 @@ $1$ or $-1$. \def\XINT_frac_gen_Ca #1~#2!#3e#4e#5\XINT_T {% \expandafter\XINT_frac_gen_F\the\numexpr #4-#1\expandafter - ~\romannumeral0\XINT_num_loop - #2\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\Z~#3~% + ~\romannumeral0\expandafter\XINT_num_cleanup\the\numexpr\XINT_num_loop + #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z~#3~% }% \def\XINT_frac_gen_Cb #1.#2e% {% @@ -24465,13 +24990,12 @@ $1$ or $-1$. {% \expandafter\XINT_frac_gen_F\the\numexpr #5-#2-% \numexpr\XINT_length_loop - #1\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax + #1\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint: \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\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 + \relax\expandafter~% + \romannumeral0\expandafter\XINT_num_cleanup\the\numexpr\XINT_num_loop + #3\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z ~#4#1~% }% \def\XINT_frac_gen_F #1~#2% @@ -24485,20 +25009,18 @@ $1$ or $-1$. \def\XINT_frac_gen_Gdivbyzero #1~~#2~% {% \expandafter\XINT_frac_gen_Gdivbyzero_a - \romannumeral0\XINT_num_loop - #2\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\Z~#1~% + \romannumeral0\expandafter\XINT_num_cleanup\the\numexpr\XINT_num_loop + #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z~#1~% }% \def\XINT_frac_gen_Gdivbyzero_a #1~#2~% {% - \xintError:DivisionByZero {#2}{#1}{0}% + \XINT_signalcondition{DivisionByZero}{Division of #1 by zero}{}{{#2}{#1}{0}}% }% \def\XINT_frac_gen_G #1#2#3~#4~#5~% {% \expandafter\XINT_frac_gen_Ga - \romannumeral0\XINT_num_loop - #1#5\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\Z~#3~{#2#4}% + \romannumeral0\expandafter\XINT_num_cleanup\the\numexpr\XINT_num_loop + #1#5\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z~#3~{#2#4}% }% \def\XINT_frac_gen_Ga #1#2~#3~% {% @@ -24514,10 +25036,10 @@ $1$ or $-1$. {% \expandafter\XINT_cuz_cnt_loop\expandafter {\expandafter}\romannumeral0\XINT_rord_main {}#1% - \xint_relax + \xint: \xint_bye\xint_bye\xint_bye\xint_bye \xint_bye\xint_bye\xint_bye\xint_bye - \xint_relax + \xint: \R\R\R\R\R\R\R\R\Z }% \def\XINT_cuz_cnt #1% @@ -24598,10 +25120,10 @@ $1$ or $-1$. {% \expandafter\space\expandafter {\romannumeral0\XINT_rord_main {}#2% - \xint_relax + \xint: \xint_bye\xint_bye\xint_bye\xint_bye \xint_bye\xint_bye\xint_bye\xint_bye - \xint_relax }{#1}% + \xint:}{#1}% }% % \end{macrocode} % \subsection{\csh{xintRaw}} @@ -24694,7 +25216,7 @@ $1$ or $-1$. }% \def\XINT_numer #1% {% - \ifcase\XINT_cntSgn #1\Z + \ifcase\XINT_cntSgn #1\xint: \expandafter\XINT_numer_B \or \expandafter\XINT_numer_A @@ -24923,8 +25445,14 @@ $1$ or $-1$. \krof {#3#4}{#1#2}{#3#4}{#1#2}% }% -\def\XINT_irr_indeterminate #1#2#3#4#5{\xintError:NaN\space 0/0}% -\def\XINT_irr_divisionbyzero #1#2#3#4#5{\xintError:DivisionByZero #5#2/0}% +\def\XINT_irr_indeterminate #1#2#3#4#5% +{% + \XINT_signalcondition{DivisionUndefined}{indeterminate: 0/0}{}{0/1}% +}% +\def\XINT_irr_divisionbyzero #1#2#3#4#5% +{% + \XINT_signalcondition{DivisionByZero}{vanishing denominator: #5#2/0}{}{0/1}% +}% \def\XINT_irr_zero #1#2#3#4#5{ 0/1}% changed in 1.08 \def\XINT_irr_loop_a #1#2% {% @@ -24996,8 +25524,14 @@ $1$ or $-1$. \krof {#3#4}{#1#2}1001% }% -\def\XINT_jrr_indeterminate #1#2#3#4#5#6#7{\xintError:NaN\space 0/0}% -\def\XINT_jrr_divisionbyzero #1#2#3#4#5#6#7{\xintError:DivisionByZero #7#2/0}% +\def\XINT_jrr_indeterminate #1#2#3#4#5#6#7% +{% + \XINT_signalcondition{DivisionUndefined}{indeterminate: 0/0}{}{0/1}% +}% +\def\XINT_jrr_divisionbyzero #1#2#3#4#5#6#7% +{% + \XINT_signalcondition{DivisionByZero}{Vanishing denominator: #7#2/0}{}{0/1}% +}% \def\XINT_jrr_zero #1#2#3#4#5#6#7{ 0/1}% changed in 1.08 \def\XINT_jrr_loop_a #1#2% {% @@ -25007,8 +25541,8 @@ $1$ or $-1$. \def\XINT_jrr_loop_b #1#2#3#4#5#6#7% {% \expandafter \XINT_jrr_loop_c \expandafter - {\romannumeral0\xintiiadd{\XINT_mul_fork #4\Z #1\Z}{#6}}% - {\romannumeral0\xintiiadd{\XINT_mul_fork #5\Z #1\Z}{#7}}% + {\romannumeral0\xintiiadd{\XINT_mul_fork #4\xint:#1\xint:}{#6}}% + {\romannumeral0\xintiiadd{\XINT_mul_fork #5\xint:#1\xint:}{#7}}% {#2}{#3}{#4}{#5}% }% \def\XINT_jrr_loop_c #1#2% @@ -25075,8 +25609,8 @@ $1$ or $-1$. }% \def\XINT_trunc_a #1#2#3#4.#5% {% - \if0\XINT_Sgn#2\Z\xint_dothis\XINT_trunc_zero\fi - \if1\XINT_is_one#3XY\xint_dothis\XINT_trunc_sp_b\fi + \if0\XINT_Sgn#2\xint:\xint_dothis\XINT_trunc_zero\fi + \if1\XINT_is_One#3XY\xint_dothis\XINT_trunc_sp_b\fi \xint_orthat\XINT_trunc_b #1+#4.{#2}{#3}#5#4.% }% \def\XINT_trunc_zero #1.#2.{ 0}% @@ -25115,8 +25649,7 @@ $1$ or $-1$. \expandafter\XINT_trunc_sp_Cc \romannumeral0\expandafter\XINT_split_fromright_a \the\numexpr#3-\numexpr\XINT_length_loop - #2\xint_relax\xint_relax\xint_relax\xint_relax - \xint_relax\xint_relax\xint_relax\xint_relax\xint_relax + #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint: \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye .#2\xint_bye2345678\xint_bye..#1% @@ -25213,8 +25746,8 @@ $1$ or $-1$. }% \def\XINT_round_a #1#2#3#4.% {% - \if0\XINT_Sgn#2\Z\xint_dothis\XINT_trunc_zero\fi - \if1\XINT_is_one#3XY\xint_dothis\XINT_trunc_sp_b\fi + \if0\XINT_Sgn#2\xint:\xint_dothis\XINT_trunc_zero\fi + \if1\XINT_is_One#3XY\xint_dothis\XINT_trunc_sp_b\fi \xint_orthat\XINT_trunc_b #1+#4.{#2}{#3}% }% \def\XINT_round_A{\expandafter\XINT_trunc_G\romannumeral0\XINT_round_B}% @@ -25258,7 +25791,8 @@ $1$ or $-1$. \def\XINT_xtrunc_zero #1#2]{0.\romannumeral\xintreplicate{#1}0}% \def\XINT_xtrunc_d #1#2#3/#4[#5]% {% - \XINT_xtrunc_prepare_a#4\R\R\R\R\R\R\R\R {10}0000001\W !{#4};{#5}{#2}{#1#3}% + \XINT_xtrunc_prepare_a#4\R\R\R\R\R\R\R\R {10}0000001\W + !{#4};{#5}{#2}{#1#3}% }% \def\XINT_xtrunc_prepare_a #1#2#3#4#5#6#7#8#9% {% @@ -25308,12 +25842,13 @@ $1$ or $-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!}% + \the\numexpr #1/\xint_c_ii\expandafter + .\the\numexpr \xint_c_x^viii+#1!}% }% \def\XINT_xtrunc_small_a #1.#2!#3% {% \expandafter\XINT_div_small_b\the\numexpr #1\expandafter - .\the\numexpr #2\expandafter!% + \xint:\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 }% @@ -25325,7 +25860,8 @@ $1$ or $-1$. }% \def\XINT_xtrunc_prepare_d #1#2#3#4#5#6#7#8#9% {% - \expandafter\XINT_xtrunc_prepare_e\xint_gob_til_dot #1#2#3#4#5#6#7#8#9!% + \expandafter\XINT_xtrunc_prepare_e + \xint_gob_til_dot #1#2#3#4#5#6#7#8#9!% }% \def\XINT_xtrunc_prepare_e #1!#2!#3#4% {% @@ -25336,14 +25872,13 @@ $1$ or $-1$. \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 + \xint:\the\numexpr (#1#2#3#4#5#6#7#8+\xint_c_i)/\xint_c_ii\expandafter + \xint:\the\numexpr #1#2#3#4#5#6#7#8\expandafter + \xint:\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 + \XINT_rsepbyviii_end_B 2345678\relax\xint_c_ii\xint_c_i + \R\xint:\xint_c_xii \R\xint:\xint_c_x \R\xint:\xint_c_viii \R\xint:\xint_c_vi + \R\xint:\xint_c_iv \R\xint:\xint_c_ii \R\xint:\xint_c_\W \X }% \def\XINT_xtrunc_prepare_g #1;{\XINT_xtrunc_e {#1}}% @@ -25353,15 +25888,15 @@ $1$ or $-1$. \expandafter\XINT_xtrunc_I \else \expandafter\XINT_xtrunc_II - \fi #2.{#1}% + \fi #2\xint:{#1}% }% -\def\XINT_xtrunc_I -#1.#2#3#4% +\def\XINT_xtrunc_I -#1\xint:#2#3#4% {% \expandafter\XINT_xtrunc_I_a\romannumeral0#2{#4}{#2}{#1}{#3}% }% \def\XINT_xtrunc_I_a #1#2#3#4#5% {% - \expandafter\XINT_xtrunc_I_b\the\numexpr #4-#5.#4.{#5}{#2}{#3}{#1}% + \expandafter\XINT_xtrunc_I_b\the\numexpr #4-#5\xint:#4\xint:{#5}{#2}{#3}{#1}% }% \def\XINT_xtrunc_I_b #1% {% @@ -25370,12 +25905,12 @@ $1$ or $-1$. -\XINT_xtrunc_IB_c \krof #1% }% -\def\XINT_xtrunc_IA_c -#1.#2.#3#4#5#6% +\def\XINT_xtrunc_IA_c -#1\xint:#2\xint:#3#4#5#6% {% \expandafter\XINT_xtrunc_IA_d - \the\numexpr#2-\xintLength{#6}.{#6}% + \the\numexpr#2-\xintLength{#6}\xint:{#6}% \expandafter\XINT_xtrunc_IA_xd - \the\numexpr (#1+\xint_c_ii^v)/\xint_c_ii^vi-\xint_c_i.#1.{#5}{#4}% + \the\numexpr (#1+\xint_c_ii^v)/\xint_c_ii^vi-\xint_c_i\xint:#1\xint:{#5}{#4}% }% \def\XINT_xtrunc_IA_d #1% {% @@ -25384,56 +25919,56 @@ $1$ or $-1$. -\XINT_xtrunc_IAB_e \krof #1% }% -\def\XINT_xtrunc_IAA_e -#1.#2% +\def\XINT_xtrunc_IAA_e -#1\xint:#2% {% \romannumeral0\XINT_split_fromleft #1.#2\xint_gobble_i\xint_bye2345678\xint_bye..% }% -\def\XINT_xtrunc_IAB_e #1.#2% +\def\XINT_xtrunc_IAB_e #1\xint:#2% {% 0.\romannumeral\XINT_rep#1\endcsname0#2% }% -\def\XINT_xtrunc_IA_xd #1.#2.% +\def\XINT_xtrunc_IA_xd #1\xint:#2\xint:% {% - \expandafter\XINT_xtrunc_IA_xe\the\numexpr #2-\xint_c_ii^vi*#1.#1.% + \expandafter\XINT_xtrunc_IA_xe\the\numexpr #2-\xint_c_ii^vi*#1\xint:#1\xint:% }% -\def\XINT_xtrunc_IA_xe #1.#2.#3#4% +\def\XINT_xtrunc_IA_xe #1\xint:#2\xint:#3#4% {% \XINT_xtrunc_loop {#2}{#4}{#3}{#1}% }% -\def\XINT_xtrunc_IB_c #1.#2.#3#4#5#6% +\def\XINT_xtrunc_IB_c #1\xint:#2\xint:#3#4#5#6% {% \expandafter\XINT_xtrunc_IB_d \romannumeral0\XINT_split_xfork #1.#6\xint_bye2345678\xint_bye..{#3}% }% \def\XINT_xtrunc_IB_d #1.#2.#3% {% - \expandafter\XINT_xtrunc_IA_d\the\numexpr#3-\xintLength {#1}.{#1}% + \expandafter\XINT_xtrunc_IA_d\the\numexpr#3-\xintLength {#1}\xint:{#1}% }% -\def\XINT_xtrunc_II #1.% +\def\XINT_xtrunc_II #1\xint:% {% - \expandafter\XINT_xtrunc_II_a\romannumeral\xintreplicate{#1}0.% + \expandafter\XINT_xtrunc_II_a\romannumeral\xintreplicate{#1}0\xint:% }% -\def\XINT_xtrunc_II_a #1.#2#3#4% +\def\XINT_xtrunc_II_a #1\xint:#2#3#4% {% \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}% + \the\numexpr (#3+\xint_c_ii^v)/\xint_c_ii^vi-\xint_c_i\expandafter\xint:% + \the\numexpr #3\expandafter\xint:\romannumeral0#2{#4#1}{#2}% }% -\def\XINT_xtrunc_II_b #1.#2.% +\def\XINT_xtrunc_II_b #1\xint:#2\xint:% {% - \expandafter\XINT_xtrunc_II_c\the\numexpr #2-\xint_c_ii^vi*#1.#1.% + \expandafter\XINT_xtrunc_II_c\the\numexpr #2-\xint_c_ii^vi*#1\xint:#1\xint:% }% -\def\XINT_xtrunc_II_c #1.#2.#3#4#5% +\def\XINT_xtrunc_II_c #1\xint:#2\xint:#3#4#5% {% #3.\XINT_xtrunc_loop {#2}{#4}{#5}{#1}% }% \def\XINT_xtrunc_loop #1% {% \ifnum #1=\xint_c_ \expandafter\XINT_xtrunc_transition\fi - \expandafter\XINT_xtrunc_loop_a\the\numexpr #1-\xint_c_i.% + \expandafter\XINT_xtrunc_loop_a\the\numexpr #1-\xint_c_i\xint:% }% -\def\XINT_xtrunc_loop_a #1.#2#3% +\def\XINT_xtrunc_loop_a #1\xint:#2#3% {% \expandafter\XINT_xtrunc_loop_b\romannumeral0#3% {#20000000000000000000000000000000000000000000000000000000000000000}% @@ -25445,7 +25980,7 @@ $1$ or $-1$. \XINT_xtrunc_loop {#3}{#2}% }% \def\XINT_xtrunc_transition - \expandafter\XINT_xtrunc_loop_a\the\numexpr #1.#2#3#4% + \expandafter\XINT_xtrunc_loop_a\the\numexpr #1\xint:#2#3#4% {% \ifnum #4=\xint_c_ \expandafter\xint_gobble_vi\fi \expandafter\XINT_xtrunc_finish\expandafter @@ -25465,11 +26000,11 @@ $1$ or $-1$. \expandafter\XINT_xtrunc_sp_I \else \expandafter\XINT_xtrunc_sp_II - \fi #1.% + \fi #1\xint:% }% -\def\XINT_xtrunc_sp_I -#1.#2#3% +\def\XINT_xtrunc_sp_I -#1\xint:#2#3% {% - \expandafter\XINT_xtrunc_sp_I_a\the\numexpr #1-#3.#1.{#3}{#2}% + \expandafter\XINT_xtrunc_sp_I_a\the\numexpr #1-#3\xint:#1\xint:{#3}{#2}% }% \def\XINT_xtrunc_sp_I_a #1% {% @@ -25478,10 +26013,10 @@ $1$ or $-1$. -\XINT_xtrunc_sp_IB_b \krof #1% }% -\def\XINT_xtrunc_sp_IA_b -#1.#2.#3#4% +\def\XINT_xtrunc_sp_IA_b -#1\xint:#2\xint:#3#4% {% \expandafter\XINT_xtrunc_sp_IA_c - \the\numexpr#2-\xintLength{#4}.{#4}\romannumeral\XINT_rep#1\endcsname0% + \the\numexpr#2-\xintLength{#4}\xint:{#4}\romannumeral\XINT_rep#1\endcsname0% }% \def\XINT_xtrunc_sp_IA_c #1% {% @@ -25490,25 +26025,25 @@ $1$ or $-1$. -\XINT_xtrunc_sp_IAB \krof #1% }% -\def\XINT_xtrunc_sp_IAA -#1.#2% +\def\XINT_xtrunc_sp_IAA -#1\xint:#2% {% \romannumeral0\XINT_split_fromleft #1.#2\xint_gobble_i\xint_bye2345678\xint_bye..% }% -\def\XINT_xtrunc_sp_IAB #1.#2% +\def\XINT_xtrunc_sp_IAB #1\xint:#2% {% 0.\romannumeral\XINT_rep#1\endcsname0#2% }% -\def\XINT_xtrunc_sp_IB_b #1.#2.#3#4% +\def\XINT_xtrunc_sp_IB_b #1\xint:#2\xint:#3#4% {% \expandafter\XINT_xtrunc_sp_IB_c \romannumeral0\XINT_split_xfork #1.#4\xint_bye2345678\xint_bye..{#3}% }% \def\XINT_xtrunc_sp_IB_c #1.#2.#3% {% - \expandafter\XINT_xtrunc_sp_IA_c\the\numexpr#3-\xintLength {#1}.{#1}% + \expandafter\XINT_xtrunc_sp_IA_c\the\numexpr#3-\xintLength {#1}\xint:{#1}% }% -\def\XINT_xtrunc_sp_II #1.#2#3% +\def\XINT_xtrunc_sp_II #1\xint:#2#3% {% #2\romannumeral\XINT_rep#1\endcsname0.\romannumeral\XINT_rep#3\endcsname0% }% @@ -25577,7 +26112,7 @@ $1$ or $-1$. }% \def\XINT_fadd_E #1#2% {% - \if0\XINT_Sgn #2\Z + \if0\XINT_Sgn #2\xint: \expandafter\XINT_fadd_F \else\expandafter\XINT_fadd_K \fi {#1}% @@ -25593,7 +26128,7 @@ $1$ or $-1$. }% \def\XINT_fadd_Ea #1#2% {% - \if0\XINT_Sgn #2\Z + \if0\XINT_Sgn #2\xint: \expandafter\XINT_fadd_Fa \else\expandafter\XINT_fadd_K \fi {#1}% @@ -25603,18 +26138,20 @@ $1$ or $-1$. \expandafter\XINT_fadd_G \romannumeral0\xintiiadd {\xintiiMul {#4}{#1}}{#5}/#3%[#6]% }% -\def\XINT_fadd_G #1{\if0#1\XINT_fadd_iszero\fi\space #1}% +\def\XINT_fadd_G #1{% +\def\XINT_fadd_G ##1{\if0##1\expandafter\XINT_fadd_iszero\fi#1##1}% +}\XINT_fadd_G{ }% \def\XINT_fadd_K #1#2#3#4#5% {% \expandafter\XINT_fadd_L \romannumeral0\xintiiadd {\xintiiMul {#2}{#5}}{\xintiiMul {#3}{#4}}.% {{#2}{#3}}% }% -\def\XINT_fadd_L #1{\if0#1\XINT_fadd_iszero\fi \XINT_fadd_M #1}% +\def\XINT_fadd_L #1{\if0#1\expandafter\XINT_fadd_iszero\fi\XINT_fadd_M #1}% \def\XINT_fadd_M #1.#2{\expandafter\XINT_fadd_N \expandafter {\romannumeral0\xintiimul #2}{#1}}% \def\XINT_fadd_N #1#2{ #2/#1}% -\edef\XINT_fadd_iszero\fi #1[#2]{\noexpand\fi\space 0/1[0]}% ou [#2] originel? +\def\XINT_fadd_iszero #1[#2]{ 0/1[0]}% ou [#2] originel? % \end{macrocode} % \subsection{\csh{xintSub}} % \begin{macrocode} @@ -25631,26 +26168,27 @@ $1$ or $-1$. \krof }% % \end{macrocode} % \subsection{\csh{xintSum}} +% \lverb|There was (not documented anymore since 1.09d, 2013/10/22) a macro +% \xintSumExpr, but it has been deleted at 1.2l. +% +% Empty items are not accepted by this macro.| % \begin{macrocode} \def\xintSum {\romannumeral0\xintsum }% -\def\xintsum #1{\xintsumexpr #1\relax }% -\def\xintSumExpr {\romannumeral0\xintsumexpr }% -\def\xintsumexpr {\expandafter\XINT_fsumexpr\romannumeral`&&@}% +\def\xintsum #1{\expandafter\XINT_fsumexpr\romannumeral`&&@#1\xint:}% \def\XINT_fsumexpr {\XINT_fsum_loop_a {0/1[0]}}% \def\XINT_fsum_loop_a #1#2% {% - \expandafter\XINT_fsum_loop_b \romannumeral`&&@#2\Z {#1}% + \expandafter\XINT_fsum_loop_b \romannumeral`&&@#2\xint:{#1}% }% \def\XINT_fsum_loop_b #1% {% - \xint_gob_til_relax #1\XINT_fsum_finished\relax - \XINT_fsum_loop_c #1% + \xint_gob_til_xint: #1\XINT_fsum_finished\xint:\XINT_fsum_loop_c #1% }% -\def\XINT_fsum_loop_c #1\Z #2% +\def\XINT_fsum_loop_c #1\xint:#2% {% \expandafter\XINT_fsum_loop_a\expandafter{\romannumeral0\xintadd {#2}{#1}}% }% -\def\XINT_fsum_finished #1\Z #2{ #2}% +\def\XINT_fsum_finished #1\xint:\xint:#2{ #2}% % \end{macrocode} % \subsection{\csh{xintMul}} % \begin{macrocode} @@ -25703,7 +26241,8 @@ $1$ or $-1$. % \begin{macrocode} \def\xintipow #1#2% {% - \expandafter\xint_pow\the\numexpr \xintNum{#2}\expandafter.\romannumeral0\xintnum{#1}\Z% + \expandafter\xint_pow\the\numexpr \xintNum{#2}\expandafter + .\romannumeral0\xintnum{#1}\xint: }% \def\xintPow {\romannumeral0\xintpow }% \def\xintpow #1% @@ -25777,26 +26316,26 @@ $1$ or $-1$. }% % \end{macrocode} % \subsection{\csh{xintPrd}} +% \lverb|There was (not documented anymore since 1.09d, 2013/10/22) a macro +% \xintPrdExpr, but it has been deleted at 1.2l +% | % \begin{macrocode} \def\xintPrd {\romannumeral0\xintprd }% -\def\xintprd #1{\xintprdexpr #1\relax }% -\def\xintPrdExpr {\romannumeral0\xintprdexpr }% -\def\xintprdexpr {\expandafter\XINT_fprdexpr \romannumeral`&&@}% +\def\xintprd #1{\expandafter\XINT_fprdexpr \romannumeral`&&@#1\xint:}% \def\XINT_fprdexpr {\XINT_fprod_loop_a {1/1[0]}}% \def\XINT_fprod_loop_a #1#2% {% - \expandafter\XINT_fprod_loop_b \romannumeral`&&@#2\Z {#1}% + \expandafter\XINT_fprod_loop_b \romannumeral`&&@#2\xint:{#1}% }% \def\XINT_fprod_loop_b #1% {% - \xint_gob_til_relax #1\XINT_fprod_finished\relax - \XINT_fprod_loop_c #1% + \xint_gob_til_xint: #1\XINT_fprod_finished\xint:\XINT_fprod_loop_c #1% }% -\def\XINT_fprod_loop_c #1\Z #2% +\def\XINT_fprod_loop_c #1\xint:#2% {% \expandafter\XINT_fprod_loop_a\expandafter{\romannumeral0\xintmul {#1}{#2}}% }% -\def\XINT_fprod_finished #1\Z #2{ #2}% +\def\XINT_fprod_finished#1\xint:\xint:#2{ #2}% % \end{macrocode} % \subsection{\csh{xintDiv}} % \begin{macrocode} @@ -25851,7 +26390,7 @@ $1$ or $-1$. {\expandafter\XINT_mod_b\expandafter #1\romannumeral0\xintraw{#3}#2.}% \def\XINT_mod_b #1#2% #1 de A, #2 de B. {% - \if0#2\xint_dothis\XINT_mod_divbyzero\fi + \if0#2\xint_dothis{\XINT_mod_divbyzero #1#2}\fi \if0#1\xint_dothis\XINT_mod_aiszero\fi \if-#2\xint_dothis{\XINT_mod_bneg #1}\fi \xint_orthat{\XINT_mod_bpos #1#2}% @@ -25870,7 +26409,10 @@ $1$ or $-1$. -{\XINT_mod_pos #1}% \krof }% -\def\XINT_mod_divbyzero #1.{\xintError:DivisionByZero\space 0/1[0]}% +\def\XINT_mod_divbyzero #1#2[#3]#4.% +{% + \XINT_signalcondition{DivisionByZero}{Division by #2[#3] of #1#4}{}{0/1[0]}% +}% \def\XINT_mod_aiszero #1.{ 0/1[0]}% \def\XINT_mod_pos #1#2/#3[#4]#5/#6[#7].% {% @@ -25890,7 +26432,7 @@ $1$ or $-1$. \def\xintisone #1{\expandafter\XINT_fracisone \romannumeral0\xintrawwithzeros{#1}\Z }% \def\XINT_fracisone #1/#2\Z - {\if0\XINT_Cmp {#1}{#2}\xint_afterfi{ 1}\else\xint_afterfi{ 0}\fi}% + {\if0\xintiiCmp {#1}{#2}\xint_afterfi{ 1}\else\xint_afterfi{ 0}\fi}% % \end{macrocode} % \subsection{\csh{xintGeq}} % \begin{macrocode} @@ -25926,7 +26468,7 @@ $1$ or $-1$. \def\XINT_fgeq_D #1#2#3% {% \expandafter\XINT_cntSgnFork\romannumeral`&&@\expandafter\XINT_cntSgn - \the\numexpr #2+\xintLength{#3}-\xintLength{#1}\relax\Z + \the\numexpr #2+\xintLength{#3}-\xintLength{#1}\relax\xint: { 0}{\XINT_fgeq_E #2\Z {#3}{#1}}{ 1}% }% \def\XINT_fgeq_E #1% @@ -25986,17 +26528,21 @@ $1$ or $-1$. }% % \end{macrocode} % \subsection{\csh{xintMaxof}} +% \lverb|1.2l protects \xintMaxof against items with non terminated +% \the\numexpr expressions. +% +% The macro is not compatible with an empty list.| % \begin{macrocode} \def\xintMaxof {\romannumeral0\xintmaxof }% -\def\xintmaxof #1{\expandafter\XINT_maxof_a\romannumeral`&&@#1\relax }% -\def\XINT_maxof_a #1{\expandafter\XINT_maxof_b\romannumeral0\xintraw{#1}\Z }% -\def\XINT_maxof_b #1\Z #2% - {\expandafter\XINT_maxof_c\romannumeral`&&@#2\Z {#1}\Z}% +\def\xintmaxof #1{\expandafter\XINT_maxof_a\romannumeral`&&@#1\xint:}% +\def\XINT_maxof_a #1{\expandafter\XINT_maxof_b\romannumeral0\xintraw{#1}!}% +\def\XINT_maxof_b #1!#2% + {\expandafter\XINT_maxof_c\romannumeral`&&@#2!{#1}!}% \def\XINT_maxof_c #1% - {\xint_gob_til_relax #1\XINT_maxof_e\relax\XINT_maxof_d #1}% -\def\XINT_maxof_d #1\Z + {\xint_gob_til_xint: #1\XINT_maxof_e\xint:\XINT_maxof_d #1}% +\def\XINT_maxof_d #1!% {\expandafter\XINT_maxof_b\romannumeral0\xintmax {#1}}% -\def\XINT_maxof_e #1\Z #2\Z { #2}% +\def\XINT_maxof_e #1!#2!{ #2}% % \end{macrocode} % \subsection{\csh{xintMin}} % \begin{macrocode} @@ -26036,21 +26582,25 @@ $1$ or $-1$. }% % \end{macrocode} % \subsection{\csh{xintMinof}} +% \lverb|1.2l protects \xintMinof against items with non terminated +% \the\numexpr expressions. +% +% The macro is not compatible with an empty list.| % \begin{macrocode} \def\xintMinof {\romannumeral0\xintminof }% -\def\xintminof #1{\expandafter\XINT_minof_a\romannumeral`&&@#1\relax }% -\def\XINT_minof_a #1{\expandafter\XINT_minof_b\romannumeral0\xintraw{#1}\Z }% -\def\XINT_minof_b #1\Z #2% - {\expandafter\XINT_minof_c\romannumeral`&&@#2\Z {#1}\Z}% +\def\xintminof #1{\expandafter\XINT_minof_a\romannumeral`&&@#1\xint:}% +\def\XINT_minof_a #1{\expandafter\XINT_minof_b\romannumeral0\xintraw{#1}!}% +\def\XINT_minof_b #1!#2% + {\expandafter\XINT_minof_c\romannumeral`&&@#2!{#1}!}% \def\XINT_minof_c #1% - {\xint_gob_til_relax #1\XINT_minof_e\relax\XINT_minof_d #1}% -\def\XINT_minof_d #1\Z + {\xint_gob_til_xint: #1\XINT_minof_e\xint:\XINT_minof_d #1}% +\def\XINT_minof_d #1!% {\expandafter\XINT_minof_b\romannumeral0\xintmin {#1}}% -\def\XINT_minof_e #1\Z #2\Z { #2}% +\def\XINT_minof_e #1!#2!{ #2}% % \end{macrocode} % \subsection{\csh{xintCmp}} % \begin{macrocode} -%\def\xintCmp {\romannumeral0\xintcmp }% +\def\xintCmp {\romannumeral0\xintcmp }% \def\xintcmp #1% {% \expandafter\XINT_fcmp\expandafter {\romannumeral0\xintraw {#1}}% @@ -26104,7 +26654,7 @@ $1$ or $-1$. \def\XINT_fcmp_D #1#2#3% {% \expandafter\XINT_cntSgnFork\romannumeral`&&@\expandafter\XINT_cntSgn - \the\numexpr #2+\xintLength{#3}-\xintLength{#1}\relax\Z + \the\numexpr #2+\xintLength{#3}-\xintLength{#1}\relax\xint: { -1}{\XINT_fcmp_E #2\Z {#3}{#1}}{ 1}% }% \def\XINT_fcmp_E #1% @@ -26139,7 +26689,7 @@ $1$ or $-1$. % \subsection{\csh{xintSgn}} % \begin{macrocode} \def\xintSgn {\romannumeral0\xintsgn }% -\def\xintsgn #1{\expandafter\XINT_sgn\romannumeral0\xintraw {#1}\Z }% +\def\xintsgn #1{\expandafter\XINT_sgn\romannumeral0\xintraw {#1}\xint:}% % \end{macrocode} % \subsection{Floating point macros} % @@ -26248,19 +26798,19 @@ $1$ or $-1$. % simply make now \xintFloat a wrapper of \XINTinFloat.| % \begin{macrocode} \def\xintFloat {\romannumeral0\xintfloat }% -\def\xintfloat #1{\XINT_float_chkopt #1\xint_relax }% +\def\xintfloat #1{\XINT_float_chkopt #1\xint:}% \def\XINT_float_chkopt #1% {% \ifx [#1\expandafter\XINT_float_opt \else\expandafter\XINT_float_noopt \fi #1% }% -\def\XINT_float_noopt #1\xint_relax +\def\XINT_float_noopt #1\xint:% {% \expandafter\XINT_float_post \romannumeral0\XINTinfloat[\XINTdigits]{#1}\XINTdigits.% }% -\def\XINT_float_opt [\xint_relax #1]% +\def\XINT_float_opt [\xint:#1]% {% \expandafter\XINT_float_opt_a\the\numexpr #1.% }% @@ -26358,7 +26908,7 @@ $1$ or $-1$. % \end{macrocode} % \lverb|micro boost au lieu d'utiliser \XINT_isOne{#4}, mais pas bon style.| % \begin{macrocode} - \if1\XINT_is_one#4XY% + \if1\XINT_is_One#4XY% \expandafter\XINT_infloat_sp \else\expandafter\XINT_infloat_fork \fi #3.{#1}{#2}{#4}% @@ -26669,19 +27219,19 @@ $1$ or $-1$. % | % \begin{macrocode} \def\xintPFloat {\romannumeral0\xintpfloat }% -\def\xintpfloat #1{\XINT_pfloat_chkopt #1\xint_relax }% +\def\xintpfloat #1{\XINT_pfloat_chkopt #1\xint:}% \def\XINT_pfloat_chkopt #1% {% \ifx [#1\expandafter\XINT_pfloat_opt \else\expandafter\XINT_pfloat_noopt \fi #1% }% -\def\XINT_pfloat_noopt #1\xint_relax +\def\XINT_pfloat_noopt #1\xint:% {% \expandafter\XINT_pfloat_a \romannumeral0\xintfloat [\XINTdigits]{#1};\XINTdigits.% }% -\def\XINT_pfloat_opt [\xint_relax #1]% +\def\XINT_pfloat_opt [\xint:#1]% {% \expandafter\XINT_pfloat_opt_a \the\numexpr #1.% }% @@ -26778,22 +27328,22 @@ $1$ or $-1$. %| % \begin{macrocode} \def\xintFloatAdd {\romannumeral0\xintfloatadd }% -\def\xintfloatadd #1{\XINT_fladd_chkopt \xintfloat #1\xint_relax }% +\def\xintfloatadd #1{\XINT_fladd_chkopt \xintfloat #1\xint:}% \def\XINTinFloatAdd {\romannumeral0\XINTinfloatadd }% -\def\XINTinfloatadd #1{\XINT_fladd_chkopt \XINTinfloatS #1\xint_relax }% +\def\XINTinfloatadd #1{\XINT_fladd_chkopt \XINTinfloatS #1\xint:}% \def\XINT_fladd_chkopt #1#2% {% \ifx [#2\expandafter\XINT_fladd_opt \else\expandafter\XINT_fladd_noopt \fi #1#2% }% -\def\XINT_fladd_noopt #1#2\xint_relax #3% +\def\XINT_fladd_noopt #1#2\xint:#3% {% #1[\XINTdigits]% {\expandafter\XINT_FL_add_a \romannumeral0\XINTinfloat[\XINTdigits]{#2}\XINTdigits.{#3}}% }% -\def\XINT_fladd_opt #1[\xint_relax #2]%#3#4% +\def\XINT_fladd_opt #1[\xint:#2]%#3#4% {% \expandafter\XINT_fladd_opt_a\the\numexpr #2.#1% }% @@ -26829,22 +27379,22 @@ $1$ or $-1$. % % \begin{macrocode} \def\xintFloatSub {\romannumeral0\xintfloatsub }% -\def\xintfloatsub #1{\XINT_flsub_chkopt \xintfloat #1\xint_relax }% +\def\xintfloatsub #1{\XINT_flsub_chkopt \xintfloat #1\xint:}% \def\XINTinFloatSub {\romannumeral0\XINTinfloatsub }% -\def\XINTinfloatsub #1{\XINT_flsub_chkopt \XINTinfloatS #1\xint_relax }% +\def\XINTinfloatsub #1{\XINT_flsub_chkopt \XINTinfloatS #1\xint:}% \def\XINT_flsub_chkopt #1#2% {% \ifx [#2\expandafter\XINT_flsub_opt \else\expandafter\XINT_flsub_noopt \fi #1#2% }% -\def\XINT_flsub_noopt #1#2\xint_relax #3% +\def\XINT_flsub_noopt #1#2\xint:#3% {% #1[\XINTdigits]% {\expandafter\XINT_FL_add_a \romannumeral0\XINTinfloat[\XINTdigits]{#2}\XINTdigits.{\xintOpp{#3}}}% }% -\def\XINT_flsub_opt #1[\xint_relax #2]%#3#4% +\def\XINT_flsub_opt #1[\xint:#2]%#3#4% {% \expandafter\XINT_flsub_opt_a\the\numexpr #2.#1% }% @@ -26868,22 +27418,22 @@ $1$ or $-1$. % one was amply enough).| % \begin{macrocode} \def\xintFloatMul {\romannumeral0\xintfloatmul }% -\def\xintfloatmul #1{\XINT_flmul_chkopt \xintfloat #1\xint_relax }% +\def\xintfloatmul #1{\XINT_flmul_chkopt \xintfloat #1\xint:}% \def\XINTinFloatMul {\romannumeral0\XINTinfloatmul }% -\def\XINTinfloatmul #1{\XINT_flmul_chkopt \XINTinfloatS #1\xint_relax }% +\def\XINTinfloatmul #1{\XINT_flmul_chkopt \XINTinfloatS #1\xint:}% \def\XINT_flmul_chkopt #1#2% {% \ifx [#2\expandafter\XINT_flmul_opt \else\expandafter\XINT_flmul_noopt \fi #1#2% }% -\def\XINT_flmul_noopt #1#2\xint_relax #3% +\def\XINT_flmul_noopt #1#2\xint:#3% {% #1[\XINTdigits]% {\expandafter\XINT_FL_mul_a \romannumeral0\XINTinfloatS[\XINTdigits]{#2}\XINTdigits.{#3}}% }% -\def\XINT_flmul_opt #1[\xint_relax #2]%#3#4% +\def\XINT_flmul_opt #1[\xint:#2]%#3#4% {% \expandafter\XINT_flmul_opt_a\the\numexpr #2.#1% }% @@ -26914,22 +27464,22 @@ $1$ or $-1$. % | % \begin{macrocode} \def\xintFloatDiv {\romannumeral0\xintfloatdiv }% -\def\xintfloatdiv #1{\XINT_fldiv_chkopt \xintfloat #1\xint_relax }% +\def\xintfloatdiv #1{\XINT_fldiv_chkopt \xintfloat #1\xint:}% \def\XINTinFloatDiv {\romannumeral0\XINTinfloatdiv }% -\def\XINTinfloatdiv #1{\XINT_fldiv_chkopt \XINTinfloatS #1\xint_relax }% +\def\XINTinfloatdiv #1{\XINT_fldiv_chkopt \XINTinfloatS #1\xint:}% \def\XINT_fldiv_chkopt #1#2% {% \ifx [#2\expandafter\XINT_fldiv_opt \else\expandafter\XINT_fldiv_noopt \fi #1#2% }% -\def\XINT_fldiv_noopt #1#2\xint_relax #3% +\def\XINT_fldiv_noopt #1#2\xint:#3% {% #1[\XINTdigits]% {\expandafter\XINT_FL_div_a \romannumeral0\XINTinfloatS[\XINTdigits]{#3}\XINTdigits.{#2}}% }% -\def\XINT_fldiv_opt #1[\xint_relax #2]%#3#4% +\def\XINT_fldiv_opt #1[\xint:#2]%#3#4% {% \expandafter\XINT_fldiv_opt_a\the\numexpr #2.#1% }% @@ -26960,9 +27510,9 @@ $1$ or $-1$. % | % \begin{macrocode} \def\xintFloatPow {\romannumeral0\xintfloatpow}% -\def\xintfloatpow #1{\XINT_flpow_chkopt \xintfloat #1\xint_relax }% +\def\xintfloatpow #1{\XINT_flpow_chkopt \xintfloat #1\xint:}% \def\XINTinFloatPow {\romannumeral0\XINTinfloatpow }% -\def\XINTinfloatpow #1{\XINT_flpow_chkopt \XINTinfloatS #1\xint_relax }% +\def\XINTinfloatpow #1{\XINT_flpow_chkopt \XINTinfloatS #1\xint:}% \def\XINT_flpow_chkopt #1#2% {% \ifx [#2\expandafter\XINT_flpow_opt @@ -26970,12 +27520,12 @@ $1$ or $-1$. \fi #1#2% }% -\def\XINT_flpow_noopt #1#2\xint_relax #3% +\def\XINT_flpow_noopt #1#2\xint:#3% {% \expandafter\XINT_flpow_checkB_a \the\numexpr #3.\XINTdigits.{#2}{#1[\XINTdigits]}% }% -\def\XINT_flpow_opt #1[\xint_relax #2]% +\def\XINT_flpow_opt #1[\xint:#2]% {% \expandafter\XINT_flpow_opt_a\the\numexpr #2.#1% }% @@ -26997,6 +27547,8 @@ $1$ or $-1$. \expandafter\XINT_flpow_checkB_c \the\numexpr\xintLength{#2}+\xint_c_iii.#3.#2.{#1}% }% +% \end{macrocode} +% \begin{macrocode} \def\XINT_flpow_checkB_c #1.#2.% {% \expandafter\XINT_flpow_checkB_d\the\numexpr#1+#2.#1.#2.% @@ -27025,8 +27577,10 @@ $1$ or $-1$. }% \def\XINT_flpow_zero #1[#2]#3#4#5#6% {% - \if 1#51\xint_afterfi {#6{0[0]}}\else - \xint_afterfi {\xintError:DivisionByZero #6{1[2147483648]}}\fi + #6{\if 1#51\xint_dothis {0[0]}\fi + \xint_orthat + {\XINT_signalcondition{DivisionByZero}{0 to the power #4}{}{0[0]}}% + }% }% \def\XINT_flpow_b #1#2[#3]#4#5% {% @@ -27156,9 +27710,9 @@ $1$ or $-1$. % | % \begin{macrocode} \def\xintFloatPower {\romannumeral0\xintfloatpower}% -\def\xintfloatpower #1{\XINT_flpower_chkopt \xintfloat #1\xint_relax }% +\def\xintfloatpower #1{\XINT_flpower_chkopt \xintfloat #1\xint:}% \def\XINTinFloatPower {\romannumeral0\XINTinfloatpower }% -\def\XINTinfloatpower #1{\XINT_flpower_chkopt \XINTinfloatS #1\xint_relax }% +\def\XINTinfloatpower #1{\XINT_flpower_chkopt \XINTinfloatS #1\xint:}% % \end{macrocode} % \lverb|First the special macro for use by the expression parser which checks % if one raises to an half-integer exponent. This is always with \XINTdigits @@ -27219,12 +27773,12 @@ $1$ or $-1$. \fi #1#2% }% -\def\XINT_flpower_noopt #1#2\xint_relax #3% +\def\XINT_flpower_noopt #1#2\xint:#3% {% \expandafter\XINT_flpower_checkB_a \romannumeral0\xintnum{#3}.\XINTdigits.{#2}{#1[\XINTdigits]}% }% -\def\XINT_flpower_opt #1[\xint_relax #2]% +\def\XINT_flpower_opt #1[\xint:#2]% {% \expandafter\XINT_flpower_opt_a\the\numexpr #2.#1% }% @@ -27342,9 +27896,9 @@ $1$ or $-1$. % \subsection{\csh{xintFloatFac}, \csh{XINTFloatFac}} % \begin{macrocode} \def\xintFloatFac {\romannumeral0\xintfloatfac}% -\def\xintfloatfac #1{\XINT_flfac_chkopt \xintfloat #1\xint_relax }% +\def\xintfloatfac #1{\XINT_flfac_chkopt \xintfloat #1\xint:}% \def\XINTinFloatFac {\romannumeral0\XINTinfloatfac }% -\def\XINTinfloatfac #1{\XINT_flfac_chkopt \XINTinfloat #1\xint_relax }% +\def\XINTinfloatfac #1{\XINT_flfac_chkopt \XINTinfloat #1\xint:}% \def\XINT_flfac_chkopt #1#2% {% \ifx [#2\expandafter\XINT_flfac_opt @@ -27352,12 +27906,12 @@ $1$ or $-1$. \fi #1#2% }% -\def\XINT_flfac_noopt #1#2\xint_relax +\def\XINT_flfac_noopt #1#2\xint: {% \expandafter\XINT_FL_fac_fork_a \the\numexpr \xintNum{#2}.\xint_c_i \XINTdigits\XINT_FL_fac_out{#1[\XINTdigits]}% }% -\def\XINT_flfac_opt #1[\xint_relax #2]% +\def\XINT_flfac_opt #1[\xint:#2]% {% \expandafter\XINT_flfac_opt_a\the\numexpr #2.#1% }% @@ -27377,7 +27931,11 @@ $1$ or $-1$. % \end{macrocode} % \lverb|1.2f XINT_FL_fac_isneg returns 0, earlier versions used 1 here.| % \begin{macrocode} -\def\XINT_FL_fac_isneg #1.#2#3#4#5{\expandafter\xintError:FactorialOfNegative #5{0[0]}}% +\def\XINT_FL_fac_isneg #1.#2#3#4#5% +{% + #5{\XINT_signalcondition{InvalidOperation} + {Factorial of negative: (-#1)!}{}{0[0]}}% +}% \def\XINT_FL_fac_fork_b #1.% {% \ifnum #1>\xint_c_x^viii_mone\xint_dothis\XINT_FL_fac_toobig\fi @@ -27387,7 +27945,11 @@ $1$ or $-1$. \xint_orthat\XINT_FL_fac_small #1.% }% -\def\XINT_FL_fac_toobig #1.#2#3#4#5{\expandafter\xintError:TooBigFactorial #5{1[0]}}% +\def\XINT_FL_fac_toobig #1.#2#3#4#5% +{% + #5{\XINT_signalcondition{InvalidOperation} + {Factorial of too big: (#1)!}{}{0[0]}}% +}% % \end{macrocode} % \lverb?Computations are done with Q blocks of eight digits. When a % multiplication has a carry, hence creates Q+1 blocks, the least significant @@ -27447,8 +28009,10 @@ $1$ or $-1$. }% \def\XINT_FL_fac_countdigits #1#2#3#4#5#6#7#8{\XINT_FL_fac_countdone }% \def\XINT_FL_fac_countdone #1#2\Z {#1}% -\def\XINT_FL_fac_out #1\Z![#2]#3{#3{\romannumeral0\XINT_mul_out - #1\Z!1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W [#2]}}% +\def\XINT_FL_fac_out #1;![#2]#3% + {#3{\romannumeral0\XINT_mul_out + #1;!1\R!1\R!1\R!1\R!% + 1\R!1\R!1\R!1\R!\W [#2]}}% \def\XINT_FL_fac_vbigloop_a #1.#2.% {% \XINT_FL_fac_bigloop_a \xint_c_x^iv.#2.% @@ -27532,15 +28096,16 @@ $1$ or $-1$. \def\XINT_FL_fac_addzeros #1.% {% \ifnum #1=\xint_c_viii \expandafter\XINT_FL_fac_addzeros_exit\fi - \expandafter\XINT_FL_fac_addzeros\the\numexpr #1-\xint_c_viii.100000000!% + \expandafter\XINT_FL_fac_addzeros + \the\numexpr #1-\xint_c_viii.100000000!% }% % \end{macrocode} % \lverb|We will manipulate by successive *small* multiplications Q blocks -% 1<8d>!, terminated by 1\Z!. We need a custom small multiplication which +% 1<8d>!, terminated by 1;!. We need a custom small multiplication which % tells us when it has create a new block, and the least significant one % should be dropped.| % \begin{macrocode} -\def\XINT_FL_fac_addzeros_exit #1.#2.#3#4{\XINT_FL_fac_smallloop_loop #3#21\Z![-#4]}% +\def\XINT_FL_fac_addzeros_exit #1.#2.#3#4{\XINT_FL_fac_smallloop_loop #3#21;![-#4]}% \def\XINT_FL_fac_smallloop_loop #1.#2.% {% \ifnum #1>#2 \expandafter\XINT_FL_fac_loop_exit\fi @@ -27560,7 +28125,7 @@ $1$ or $-1$. \def\XINT_FL_fac_mul_a #1-#2% {% \if#21\xint_afterfi{\expandafter\space\xint_gob_til_exclam}\else - \expandafter\space\fi #11\Z!% + \expandafter\space\fi #11;!% }% \def\XINT_FL_fac_minimulwc_a #1#2#3#4#5!#6#7#8#9% {% @@ -27569,18 +28134,18 @@ $1$ or $-1$. \def\XINT_FL_fac_minimulwc_b #1#2#3#4!#5% {% \expandafter\XINT_FL_fac_minimulwc_c - \the\numexpr \xint_c_x^ix+#5+#2*#4.{{#1}{#2}{#3}{#4}}% + \the\numexpr \xint_c_x^ix+#5+#2*#4!{{#1}{#2}{#3}{#4}}% }% -\def\XINT_FL_fac_minimulwc_c 1#1#2#3#4#5#6.#7% +\def\XINT_FL_fac_minimulwc_c 1#1#2#3#4#5#6!#7% {% \expandafter\XINT_FL_fac_minimulwc_d {#1#2#3#4#5}#7{#6}% }% \def\XINT_FL_fac_minimulwc_d #1#2#3#4#5% {% \expandafter\XINT_FL_fac_minimulwc_e - \the\numexpr \xint_c_x^ix+#1+#2*#5+#3*#4.{#2}{#4}% + \the\numexpr \xint_c_x^ix+#1+#2*#5+#3*#4!{#2}{#4}% }% -\def\XINT_FL_fac_minimulwc_e 1#1#2#3#4#5#6.#7#8#9% +\def\XINT_FL_fac_minimulwc_e 1#1#2#3#4#5#6!#7#8#9% {% 1#6#9\expandafter!% \the\numexpr\expandafter\XINT_FL_fac_smallmul @@ -27588,7 +28153,7 @@ $1$ or $-1$. }% \def\XINT_FL_fac_smallmul 1#1!#21#3!% {% - \xint_gob_til_Z #3\XINT_FL_fac_smallmul_end\Z + \xint_gob_til_sc #3\XINT_FL_fac_smallmul_end;% \XINT_FL_fac_minimulwc_a #2!#3!{#1}{#2}% }% % \end{macrocode} @@ -27600,7 +28165,7 @@ $1$ or $-1$. % (a \numexpr muste be stopped, and leaving a - as delimiter is good as it % will not arise earlier.)| % \begin{macrocode} -\def\XINT_FL_fac_smallmul_end\Z\XINT_FL_fac_minimulwc_a #1!\Z!#2#3[#4]% +\def\XINT_FL_fac_smallmul_end;\XINT_FL_fac_minimulwc_a #1!;!#2#3[#4]% {% \ifnum #2=\xint_c_ \expandafter\xint_firstoftwo\else @@ -27619,9 +28184,9 @@ $1$ or $-1$. % condition 0<=a<=b<10^8 is violated. Same as for \xintiiPFactorial.| % \begin{macrocode} \def\xintFloatPFactorial {\romannumeral0\xintfloatpfactorial}% -\def\xintfloatpfactorial #1{\XINT_flpfac_chkopt \xintfloat #1\xint_relax }% +\def\xintfloatpfactorial #1{\XINT_flpfac_chkopt \xintfloat #1\xint:}% \def\XINTinFloatPFactorial {\romannumeral0\XINTinfloatpfactorial }% -\def\XINTinfloatpfactorial #1{\XINT_flpfac_chkopt \XINTinfloat #1\xint_relax }% +\def\XINTinfloatpfactorial #1{\XINT_flpfac_chkopt \XINTinfloat #1\xint:}% \def\XINT_flpfac_chkopt #1#2% {% \ifx [#2\expandafter\XINT_flpfac_opt @@ -27629,13 +28194,13 @@ $1$ or $-1$. \fi #1#2% }% -\def\XINT_flpfac_noopt #1#2\xint_relax #3% +\def\XINT_flpfac_noopt #1#2\xint:#3% {% \expandafter\XINT_FL_pfac_fork \the\numexpr \xintNum{#2}\expandafter.% \the\numexpr \xintNum{#3}.\xint_c_i{\XINTdigits}{#1[\XINTdigits]}% }% -\def\XINT_flpfac_opt #1[\xint_relax #2]% +\def\XINT_flpfac_opt #1[\xint:#2]% {% \expandafter\XINT_flpfac_opt_b\the\numexpr #2.#1% }% @@ -27653,7 +28218,11 @@ $1$ or $-1$. \ifnum #3#4>\xint_c_x^viii_mone\xint_dothis\XINT_FL_pfac_outofrange\fi \xint_orthat \XINT_FL_pfac_increaseP #1#2.#3#4.% }% -\def\XINT_FL_pfac_outofrange #1.#2.#3#4#5{\xintError:OutOfRangePFac #5{0[0]}}% +\def\XINT_FL_pfac_outofrange #1.#2.#3#4#5% +{% + #5{\XINT_signalcondition{InvalidOperation} + {pfactorial second arg too big: 99999999 < #2}{}{0[0]}}% +}% \def\XINT_FL_pfac_one #1.#2.#3#4#5{#5{1[0]}}% \def\XINT_FL_pfac_zero #1.#2.#3#4#5{#5{0[0]}}% \def\XINT_FL_pfac_neg -#1.-#2.% @@ -27687,7 +28256,7 @@ $1$ or $-1$. {% \expandafter\XINT_FL_pfac_b\the\numexpr \xint_c_i+#2\expandafter.% \the\numexpr#3\expandafter.% - \romannumeral0\XINT_FL_pfac_addzeroes #1.100000001!1\Z![-#1]% + \romannumeral0\XINT_FL_pfac_addzeroes #1.100000001!1;![-#1]% }% \def\XINT_FL_pfac_addzeroes #1.% {% @@ -27822,21 +28391,21 @@ $1$ or $-1$. % integers.| % \begin{macrocode} \def\xintFloatBinomial {\romannumeral0\xintfloatbinomial}% -\def\xintfloatbinomial #1{\XINT_flbinom_chkopt \xintfloat #1\xint_relax }% +\def\xintfloatbinomial #1{\XINT_flbinom_chkopt \xintfloat #1\xint:}% \def\XINTinFloatBinomial {\romannumeral0\XINTinfloatbinomial }% -\def\XINTinfloatbinomial #1{\XINT_flbinom_chkopt \XINTinfloat #1\xint_relax }% +\def\XINTinfloatbinomial #1{\XINT_flbinom_chkopt \XINTinfloat #1\xint:}% \def\XINT_flbinom_chkopt #1#2% {% \ifx [#2\expandafter\XINT_flbinom_opt \else\expandafter\XINT_flbinom_noopt \fi #1#2% }% -\def\XINT_flbinom_noopt #1#2\xint_relax #3% +\def\XINT_flbinom_noopt #1#2\xint:#3% {% \expandafter\XINT_FL_binom_a \the\numexpr\xintNum{#2}\expandafter.\the\numexpr\xintNum{#3}.\XINTdigits.#1% }% -\def\XINT_flbinom_opt #1[\xint_relax #2]#3#4% +\def\XINT_flbinom_opt #1[\xint:#2]#3#4% {% \expandafter\XINT_FL_binom_a \the\numexpr\xintNum{#3}\expandafter.\the\numexpr\xintNum{#4}\expandafter.% @@ -27848,20 +28417,30 @@ $1$ or $-1$. }% \def\XINT_FL_binom_fork #1#2.#3#4.#5#6.% {% - \if-#5\xint_dothis \XINT_FL_binom_outofrange\fi + \if-#5\xint_dothis \XINT_FL_binom_neg\fi \if-#1\xint_dothis \XINT_FL_binom_zero\fi \if-#3\xint_dothis \XINT_FL_binom_zero\fi \if0#1\xint_dothis \XINT_FL_binom_one\fi \if0#3\xint_dothis \XINT_FL_binom_one\fi - \ifnum #5#6>\xint_c_x^viii_mone \xint_dothis\XINT_FL_binom_outofrange\fi + \ifnum #5#6>\xint_c_x^viii_mone \xint_dothis\XINT_FL_binom_toobig\fi \ifnum #1#2>#3#4 \xint_dothis\XINT_FL_binom_ab \fi \xint_orthat\XINT_FL_binom_aa #1#2.#3#4.#5#6.% }% -\def\XINT_FL_binom_outofrange #1.#2.#3.#4.#5% - {\xintError:OutOfRangeBinomial #5[#4]{0[0]}}% +\def\XINT_FL_binom_neg #1.#2.#3.#4.#5% +{% + #5[#4]{\XINT_signalcondition{InvalidOperation} + {binomial with first arg negative: #3}{}{0[0]}}% +}% +\def\XINT_FL_binom_toobig #1.#2.#3.#4.#5% +{% + #5[#4]{\XINT_signalcondition{InvalidOperation} + {binomial with first arg too big: 99999999 < #3}{}{0[0]}}% +}% \def\XINT_FL_binom_one #1.#2.#3.#4.#5{#5[#4]{1[0]}}% \def\XINT_FL_binom_zero #1.#2.#3.#4.#5{#5[#4]{0[0]}}% +% \end{macrocode} +% \begin{macrocode} \def\XINT_FL_binom_aa #1.#2.#3.#4.#5% {% #5[#4]{\xintDiv{\XINT_FL_pfac_increaseP @@ -27904,21 +28483,21 @@ $1$ or $-1$. % | % \begin{macrocode} \def\xintFloatSqrt {\romannumeral0\xintfloatsqrt }% -\def\xintfloatsqrt #1{\XINT_flsqrt_chkopt \xintfloat #1\xint_relax }% +\def\xintfloatsqrt #1{\XINT_flsqrt_chkopt \xintfloat #1\xint:}% \def\XINTinFloatSqrt {\romannumeral0\XINTinfloatsqrt }% -\def\XINTinfloatsqrt #1{\XINT_flsqrt_chkopt \XINTinfloat #1\xint_relax }% +\def\XINTinfloatsqrt #1{\XINT_flsqrt_chkopt \XINTinfloat #1\xint:}% \def\XINT_flsqrt_chkopt #1#2% {% \ifx [#2\expandafter\XINT_flsqrt_opt \else\expandafter\XINT_flsqrt_noopt \fi #1#2% }% -\def\XINT_flsqrt_noopt #1#2\xint_relax +\def\XINT_flsqrt_noopt #1#2\xint:% {% \expandafter\XINT_FL_sqrt_a \romannumeral0\XINTinfloat[\XINTdigits]{#2}\XINTdigits.#1% }% -\def\XINT_flsqrt_opt #1[\xint_relax #2]%#3% +\def\XINT_flsqrt_opt #1[\xint:#2]%#3% {% \expandafter\XINT_flsqrt_opt_a\the\numexpr #2.#1% }% @@ -27935,7 +28514,15 @@ $1$ or $-1$. \krof }%[ \def\XINT_FL_sqrt_iszero #1]#2.#3{#3[#2]{0[0]}}% -\def\XINT_FL_sqrt_isneg #1]#2.#3{\xintError:RootOfNegative #3[#2]{0[0]}}% +\def\XINT_FL_sqrt_isneg #1]#2.#3% +{% + #3[#2]{\XINT_signalcondition{InvalidOperation} + {Square root of negative: -#1]}{}{0[0]}}% +}% +% \end{macrocode} +%\lverb|& +% | +% \begin{macrocode} \def\XINT_FL_sqrt_pos #1[#2]#3.% {% \expandafter\XINT_flsqrt @@ -28002,19 +28589,19 @@ $1$ or $-1$. % | % \begin{macrocode} \def\xintFloatE {\romannumeral0\xintfloate }% -\def\xintfloate #1{\XINT_floate_chkopt #1\xint_relax }% +\def\xintfloate #1{\XINT_floate_chkopt #1\xint:}% \def\XINT_floate_chkopt #1% {% \ifx [#1\expandafter\XINT_floate_opt \else\expandafter\XINT_floate_noopt \fi #1% }% -\def\XINT_floate_noopt #1\xint_relax +\def\XINT_floate_noopt #1\xint:% {% \expandafter\XINT_floate_post \romannumeral0\XINTinfloat[\XINTdigits]{#1}\XINTdigits.% }% -\def\XINT_floate_opt [\xint_relax #1]% +\def\XINT_floate_opt [\xint:#1]% {% \expandafter\XINT_floate_opt_a\the\numexpr #1.% }% @@ -28127,7 +28714,7 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xintseries}% - [2017/01/06 1.2k Expandable partial sums with xint package (JFB)]% + [2017/07/26 1.2l Expandable partial sums with xint package (JFB)]% % \end{macrocode} % \subsection{\csh{xintSeries}} % \begin{macrocode} @@ -28438,7 +29025,7 @@ $1$ or $-1$. % just adapted the code to the case of floats.| % \begin{macrocode} \def\xintFloatPowerSeries {\romannumeral0\xintfloatpowerseries }% -\def\xintfloatpowerseries #1{\XINT_flpowseries_chkopt #1\xint_relax }% +\def\xintfloatpowerseries #1{\XINT_flpowseries_chkopt #1\xint:}% \def\XINT_flpowseries_chkopt #1% {% \ifx [#1\expandafter\XINT_flpowseries_opt @@ -28446,13 +29033,13 @@ $1$ or $-1$. \fi #1% }% -\def\XINT_flpowseries_noopt #1\xint_relax #2% +\def\XINT_flpowseries_noopt #1\xint:#2% {% \expandafter\XINT_flpowseries\expandafter {\the\numexpr #1\expandafter}\expandafter {\the\numexpr #2}\XINTdigits }% -\def\XINT_flpowseries_opt [\xint_relax #1]#2#3% +\def\XINT_flpowseries_opt [\xint:#1]#2#3% {% \expandafter\XINT_flpowseries\expandafter {\the\numexpr #2\expandafter}\expandafter @@ -28507,7 +29094,7 @@ $1$ or $-1$. % \lverb|1.08a| % \begin{macrocode} \def\xintFloatPowerSeriesX {\romannumeral0\xintfloatpowerseriesx }% -\def\xintfloatpowerseriesx #1{\XINT_flpowseriesx_chkopt #1\xint_relax }% +\def\xintfloatpowerseriesx #1{\XINT_flpowseriesx_chkopt #1\xint:}% \def\XINT_flpowseriesx_chkopt #1% {% \ifx [#1\expandafter\XINT_flpowseriesx_opt @@ -28515,13 +29102,13 @@ $1$ or $-1$. \fi #1% }% -\def\XINT_flpowseriesx_noopt #1\xint_relax #2% +\def\XINT_flpowseriesx_noopt #1\xint:#2% {% \expandafter\XINT_flpowseriesx\expandafter {\the\numexpr #1\expandafter}\expandafter {\the\numexpr #2}\XINTdigits }% -\def\XINT_flpowseriesx_opt [\xint_relax #1]#2#3% +\def\XINT_flpowseriesx_opt [\xint:#1]#2#3% {% \expandafter\XINT_flpowseriesx\expandafter {\the\numexpr #2\expandafter}\expandafter @@ -28625,25 +29212,25 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xintcfrac}% - [2017/01/06 1.2k Expandable continued fractions with xint package (JFB)]% + [2017/07/26 1.2l Expandable continued fractions with xint package (JFB)]% % \end{macrocode} % \subsection{\csh{xintCFrac}} % \begin{macrocode} \def\xintCFrac {\romannumeral0\xintcfrac }% \def\xintcfrac #1% {% - \XINT_cfrac_opt_a #1\xint_relax + \XINT_cfrac_opt_a #1\xint: }% \def\XINT_cfrac_opt_a #1% {% \ifx[#1\XINT_cfrac_opt_b\fi \XINT_cfrac_noopt #1% }% -\def\XINT_cfrac_noopt #1\xint_relax +\def\XINT_cfrac_noopt #1\xint: {% \expandafter\XINT_cfrac_A\romannumeral0\xintrawwithzeros {#1}\Z \relax\relax }% -\def\XINT_cfrac_opt_b\fi\XINT_cfrac_noopt [\xint_relax #1]% +\def\XINT_cfrac_opt_b\fi\XINT_cfrac_noopt [\xint:#1]% {% \fi\csname XINT_cfrac_opt#1\endcsname }% @@ -28707,30 +29294,30 @@ $1$ or $-1$. % \subsection{\csh{xintGCFrac}} % \begin{macrocode} \def\xintGCFrac {\romannumeral0\xintgcfrac }% -\def\xintgcfrac #1{\XINT_gcfrac_opt_a #1\xint_relax }% +\def\xintgcfrac #1{\XINT_gcfrac_opt_a #1\xint:}% \def\XINT_gcfrac_opt_a #1% {% \ifx[#1\XINT_gcfrac_opt_b\fi \XINT_gcfrac_noopt #1% }% -\def\XINT_gcfrac_noopt #1\xint_relax +\def\XINT_gcfrac_noopt #1\xint:% {% - \XINT_gcfrac #1+\xint_relax/\relax\relax + \XINT_gcfrac #1+!/\relax\relax }% -\def\XINT_gcfrac_opt_b\fi\XINT_gcfrac_noopt [\xint_relax #1]% +\def\XINT_gcfrac_opt_b\fi\XINT_gcfrac_noopt [\xint:#1]% {% \fi\csname XINT_gcfrac_opt#1\endcsname }% \def\XINT_gcfrac_optl #1% {% - \XINT_gcfrac #1+\xint_relax/\relax\hfill + \XINT_gcfrac #1+!/\relax\hfill }% \def\XINT_gcfrac_optc #1% {% - \XINT_gcfrac #1+\xint_relax/\relax\relax + \XINT_gcfrac #1+!/\relax\relax }% \def\XINT_gcfrac_optr #1% {% - \XINT_gcfrac #1+\xint_relax/\hfill\relax + \XINT_gcfrac #1+!/\hfill\relax }% \def\XINT_gcfrac {% @@ -28739,23 +29326,23 @@ $1$ or $-1$. \def\XINT_gcfrac_enter {\XINT_gcfrac_loop {}}% \def\XINT_gcfrac_loop #1#2+#3/% {% - \xint_gob_til_xint_relax #3\XINT_gcfrac_endloop\xint_relax + \xint_gob_til_exclam #3\XINT_gcfrac_endloop!% \XINT_gcfrac_loop {{#3}{#2}#1}% }% -\def\XINT_gcfrac_endloop\xint_relax\XINT_gcfrac_loop #1#2#3% +\def\XINT_gcfrac_endloop!\XINT_gcfrac_loop #1#2#3% {% - \XINT_gcfrac_T #2#3#1\xint_relax\xint_relax + \XINT_gcfrac_T #2#3#1!!% }% \def\XINT_gcfrac_T #1#2#3#4{\XINT_gcfrac_U #1#2{\xintFrac{#4}}}% \def\XINT_gcfrac_U #1#2#3#4#5% {% - \xint_gob_til_xint_relax #5\XINT_gcfrac_end\xint_relax\XINT_gcfrac_U + \xint_gob_til_exclam #5\XINT_gcfrac_end!\XINT_gcfrac_U #1#2{\xintFrac{#5}% \ifcase\xintSgn{#4} +\or+\else-\fi \cfrac{#1\xintFrac{\xintAbs{#4}}#2}{#3}}% }% -\def\XINT_gcfrac_end\xint_relax\XINT_gcfrac_U #1#2#3% +\def\XINT_gcfrac_end!\XINT_gcfrac_U #1#2#3% {% \XINT_gcfrac_end_b #3% }% @@ -28765,30 +29352,30 @@ $1$ or $-1$. % \lverb|New with 1.09m| % \begin{macrocode} \def\xintGGCFrac {\romannumeral0\xintggcfrac }% -\def\xintggcfrac #1{\XINT_ggcfrac_opt_a #1\xint_relax }% +\def\xintggcfrac #1{\XINT_ggcfrac_opt_a #1\xint:}% \def\XINT_ggcfrac_opt_a #1% {% \ifx[#1\XINT_ggcfrac_opt_b\fi \XINT_ggcfrac_noopt #1% }% -\def\XINT_ggcfrac_noopt #1\xint_relax +\def\XINT_ggcfrac_noopt #1\xint: {% - \XINT_ggcfrac #1+\xint_relax/\relax\relax + \XINT_ggcfrac #1+!/\relax\relax }% -\def\XINT_ggcfrac_opt_b\fi\XINT_ggcfrac_noopt [\xint_relax #1]% +\def\XINT_ggcfrac_opt_b\fi\XINT_ggcfrac_noopt [\xint:#1]% {% \fi\csname XINT_ggcfrac_opt#1\endcsname }% \def\XINT_ggcfrac_optl #1% {% - \XINT_ggcfrac #1+\xint_relax/\relax\hfill + \XINT_ggcfrac #1+!/\relax\hfill }% \def\XINT_ggcfrac_optc #1% {% - \XINT_ggcfrac #1+\xint_relax/\relax\relax + \XINT_ggcfrac #1+!/\relax\relax }% \def\XINT_ggcfrac_optr #1% {% - \XINT_ggcfrac #1+\xint_relax/\hfill\relax + \XINT_ggcfrac #1+!/\hfill\relax }% \def\XINT_ggcfrac {% @@ -28797,20 +29384,20 @@ $1$ or $-1$. \def\XINT_ggcfrac_enter {\XINT_ggcfrac_loop {}}% \def\XINT_ggcfrac_loop #1#2+#3/% {% - \xint_gob_til_xint_relax #3\XINT_ggcfrac_endloop\xint_relax + \xint_gob_til_exclam #3\XINT_ggcfrac_endloop!% \XINT_ggcfrac_loop {{#3}{#2}#1}% }% -\def\XINT_ggcfrac_endloop\xint_relax\XINT_ggcfrac_loop #1#2#3% +\def\XINT_ggcfrac_endloop!\XINT_ggcfrac_loop #1#2#3% {% - \XINT_ggcfrac_T #2#3#1\xint_relax\xint_relax + \XINT_ggcfrac_T #2#3#1!!% }% \def\XINT_ggcfrac_T #1#2#3#4{\XINT_ggcfrac_U #1#2{#4}}% \def\XINT_ggcfrac_U #1#2#3#4#5% {% - \xint_gob_til_xint_relax #5\XINT_ggcfrac_end\xint_relax\XINT_ggcfrac_U + \xint_gob_til_exclam #5\XINT_ggcfrac_end!\XINT_ggcfrac_U #1#2{#5+\cfrac{#1#4#2}{#3}}% }% -\def\XINT_ggcfrac_end\xint_relax\XINT_ggcfrac_U #1#2#3% +\def\XINT_ggcfrac_end!\XINT_ggcfrac_U #1#2#3% {% \XINT_ggcfrac_end_b #3% }% @@ -28823,17 +29410,17 @@ $1$ or $-1$. {% \expandafter\XINT_gctgcx_start\expandafter {\romannumeral`&&@#3}{#1}{#2}% }% -\def\XINT_gctgcx_start #1#2#3{\XINT_gctgcx_loop_a {}{#2}{#3}#1+\xint_relax/}% +\def\XINT_gctgcx_start #1#2#3{\XINT_gctgcx_loop_a {}{#2}{#3}#1+!/}% \def\XINT_gctgcx_loop_a #1#2#3#4+#5/% {% - \xint_gob_til_xint_relax #5\XINT_gctgcx_end\xint_relax + \xint_gob_til_exclam #5\XINT_gctgcx_end!% \XINT_gctgcx_loop_b {#1{#4}}{#2{#5}#3}{#2}{#3}% }% \def\XINT_gctgcx_loop_b #1#2% {% \XINT_gctgcx_loop_a {#1#2}% }% -\def\XINT_gctgcx_end\xint_relax\XINT_gctgcx_loop_b #1#2#3#4{ #1}% +\def\XINT_gctgcx_end!\XINT_gctgcx_loop_b #1#2#3#4{ #1}% % \end{macrocode} % \subsection{\csh{xintFtoCs}} % \lverb|Modified in 1.09m: a space is added after the inserted commas.| @@ -29062,12 +29649,12 @@ $1$ or $-1$. \def\xintCstoF {\romannumeral0\xintcstof }% \def\xintcstof #1% {% - \expandafter\XINT_ctf_prep \romannumeral0\xintcsvtolist{#1}\xint_relax + \expandafter\XINT_ctf_prep \romannumeral0\xintcsvtolist{#1}!% }% \def\xintCtoF {\romannumeral0\xintctof }% \def\xintctof #1% {% - \expandafter\XINT_ctf_prep \romannumeral`&&@#1\xint_relax + \expandafter\XINT_ctf_prep \romannumeral`&&@#1!% }% \def\XINT_ctf_prep {% @@ -29075,17 +29662,19 @@ $1$ or $-1$. }% \def\XINT_ctf_loop_a #1#2#3#4#5% {% - \xint_gob_til_xint_relax #5\XINT_ctf_end\xint_relax + \xint_gob_til_exclam #5\XINT_ctf_end!% \expandafter\XINT_ctf_loop_b \romannumeral0\xintrawwithzeros {#5}.{#1}{#2}{#3}{#4}% }% \def\XINT_ctf_loop_b #1/#2.#3#4#5#6% {% \expandafter\XINT_ctf_loop_c\expandafter - {\romannumeral0\XINT_mul_fork #2\Z #4\Z }% - {\romannumeral0\XINT_mul_fork #2\Z #3\Z }% - {\romannumeral0\xintiiadd {\XINT_mul_fork #2\Z #6\Z}{\XINT_mul_fork #1\Z #4\Z}}% - {\romannumeral0\xintiiadd {\XINT_mul_fork #2\Z #5\Z}{\XINT_mul_fork #1\Z #3\Z}}% + {\romannumeral0\XINT_mul_fork #2\xint:#4\xint:}% + {\romannumeral0\XINT_mul_fork #2\xint:#3\xint:}% + {\romannumeral0\xintiiadd {\XINT_mul_fork #2\xint:#6\xint:}% + {\XINT_mul_fork #1\xint:#4\xint:}}% + {\romannumeral0\xintiiadd {\XINT_mul_fork #2\xint:#5\xint:}% + {\XINT_mul_fork #1\xint:#3\xint:}}% }% \def\XINT_ctf_loop_c #1#2% {% @@ -29106,7 +29695,7 @@ $1$ or $-1$. \def\xintiCstoF {\romannumeral0\xinticstof }% \def\xinticstof #1% {% - \expandafter\XINT_icstf_prep \romannumeral`&&@#1,\xint_relax,% + \expandafter\XINT_icstf_prep \romannumeral`&&@#1,!,% }% \def\XINT_icstf_prep {% @@ -29114,15 +29703,15 @@ $1$ or $-1$. }% \def\XINT_icstf_loop_a #1#2#3#4#5,% {% - \xint_gob_til_xint_relax #5\XINT_icstf_end\xint_relax + \xint_gob_til_exclam #5\XINT_icstf_end!% \expandafter \XINT_icstf_loop_b \romannumeral`&&@#5.{#1}{#2}{#3}{#4}% }% \def\XINT_icstf_loop_b #1.#2#3#4#5% {% \expandafter\XINT_icstf_loop_c\expandafter - {\romannumeral0\xintiiadd {#5}{\XINT_mul_fork #1\Z #3\Z}}% - {\romannumeral0\xintiiadd {#4}{\XINT_mul_fork #1\Z #2\Z}}% + {\romannumeral0\xintiiadd {#5}{\XINT_mul_fork #1\xint:#3\xint:}}% + {\romannumeral0\xintiiadd {#4}{\XINT_mul_fork #1\xint:#2\xint:}}% {#2}{#3}% }% \def\XINT_icstf_loop_c #1#2% @@ -29136,7 +29725,7 @@ $1$ or $-1$. \def\xintGCtoF {\romannumeral0\xintgctof }% \def\xintgctof #1% {% - \expandafter\XINT_gctf_prep \romannumeral`&&@#1+\xint_relax/% + \expandafter\XINT_gctf_prep \romannumeral`&&@#1+!/% }% \def\XINT_gctf_prep {% @@ -29150,10 +29739,12 @@ $1$ or $-1$. \def\XINT_gctf_loop_b #1/#2.#3#4#5#6% {% \expandafter\XINT_gctf_loop_c\expandafter - {\romannumeral0\XINT_mul_fork #2\Z #4\Z }% - {\romannumeral0\XINT_mul_fork #2\Z #3\Z }% - {\romannumeral0\xintiiadd {\XINT_mul_fork #2\Z #6\Z}{\XINT_mul_fork #1\Z #4\Z}}% - {\romannumeral0\xintiiadd {\XINT_mul_fork #2\Z #5\Z}{\XINT_mul_fork #1\Z #3\Z}}% + {\romannumeral0\XINT_mul_fork #2\xint:#4\xint:}% + {\romannumeral0\XINT_mul_fork #2\xint:#3\xint:}% + {\romannumeral0\xintiiadd {\XINT_mul_fork #2\xint:#6\xint:}% + {\XINT_mul_fork #1\xint:#4\xint:}}% + {\romannumeral0\xintiiadd {\XINT_mul_fork #2\xint:#5\xint:}% + {\XINT_mul_fork #1\xint:#3\xint:}}% }% \def\XINT_gctf_loop_c #1#2% {% @@ -29169,17 +29760,17 @@ $1$ or $-1$. }% \def\XINT_gctf_loop_f #1#2/% {% - \xint_gob_til_xint_relax #2\XINT_gctf_end\xint_relax + \xint_gob_til_exclam #2\XINT_gctf_end!% \expandafter\XINT_gctf_loop_g \romannumeral0\xintrawwithzeros {#2}.#1% }% \def\XINT_gctf_loop_g #1/#2.#3#4#5#6% {% \expandafter\XINT_gctf_loop_h\expandafter - {\romannumeral0\XINT_mul_fork #1\Z #6\Z }% - {\romannumeral0\XINT_mul_fork #1\Z #5\Z }% - {\romannumeral0\XINT_mul_fork #2\Z #4\Z }% - {\romannumeral0\XINT_mul_fork #2\Z #3\Z }% + {\romannumeral0\XINT_mul_fork #1\xint:#6\xint:}% + {\romannumeral0\XINT_mul_fork #1\xint:#5\xint:}% + {\romannumeral0\XINT_mul_fork #2\xint:#4\xint:}% + {\romannumeral0\XINT_mul_fork #2\xint:#3\xint:}% }% \def\XINT_gctf_loop_h #1#2% {% @@ -29200,7 +29791,7 @@ $1$ or $-1$. \def\xintiGCtoF {\romannumeral0\xintigctof }% \def\xintigctof #1% {% - \expandafter\XINT_igctf_prep \romannumeral`&&@#1+\xint_relax/% + \expandafter\XINT_igctf_prep \romannumeral`&&@#1+!/% }% \def\XINT_igctf_prep {% @@ -29214,8 +29805,8 @@ $1$ or $-1$. \def\XINT_igctf_loop_b #1.#2#3#4#5% {% \expandafter\XINT_igctf_loop_c\expandafter - {\romannumeral0\xintiiadd {#5}{\XINT_mul_fork #1\Z #3\Z}}% - {\romannumeral0\xintiiadd {#4}{\XINT_mul_fork #1\Z #2\Z}}% + {\romannumeral0\xintiiadd {#5}{\XINT_mul_fork #1\xint:#3\xint:}}% + {\romannumeral0\xintiiadd {#4}{\XINT_mul_fork #1\xint:#2\xint:}}% {#2}{#3}% }% \def\XINT_igctf_loop_c #1#2% @@ -29224,15 +29815,15 @@ $1$ or $-1$. }% \def\XINT_igctf_loop_f #1#2#3#4/% {% - \xint_gob_til_xint_relax #4\XINT_igctf_end\xint_relax + \xint_gob_til_exclam #4\XINT_igctf_end!% \expandafter\XINT_igctf_loop_g \romannumeral`&&@#4.{#2}{#3}#1% }% \def\XINT_igctf_loop_g #1.#2#3% {% \expandafter\XINT_igctf_loop_h\expandafter - {\romannumeral0\XINT_mul_fork #1\Z #3\Z }% - {\romannumeral0\XINT_mul_fork #1\Z #2\Z }% + {\romannumeral0\XINT_mul_fork #1\xint:#3\xint:}% + {\romannumeral0\XINT_mul_fork #1\xint:#2\xint:}% }% \def\XINT_igctf_loop_h #1#2% {% @@ -29253,12 +29844,12 @@ $1$ or $-1$. \def\xintCstoCv {\romannumeral0\xintcstocv }% \def\xintcstocv #1% {% - \expandafter\XINT_ctcv_prep\romannumeral0\xintcsvtolist{#1}\xint_relax + \expandafter\XINT_ctcv_prep\romannumeral0\xintcsvtolist{#1}!% }% \def\xintCtoCv {\romannumeral0\xintctocv }% \def\xintctocv #1% {% - \expandafter\XINT_ctcv_prep\romannumeral`&&@#1\xint_relax + \expandafter\XINT_ctcv_prep\romannumeral`&&@#1!% }% \def\XINT_ctcv_prep {% @@ -29266,17 +29857,19 @@ $1$ or $-1$. }% \def\XINT_ctcv_loop_a #1#2#3#4#5#6% {% - \xint_gob_til_xint_relax #6\XINT_ctcv_end\xint_relax + \xint_gob_til_exclam #6\XINT_ctcv_end!% \expandafter\XINT_ctcv_loop_b \romannumeral0\xintrawwithzeros {#6}.{#2}{#3}{#4}{#5}{#1}% }% \def\XINT_ctcv_loop_b #1/#2.#3#4#5#6% {% \expandafter\XINT_ctcv_loop_c\expandafter - {\romannumeral0\XINT_mul_fork #2\Z #4\Z }% - {\romannumeral0\XINT_mul_fork #2\Z #3\Z }% - {\romannumeral0\xintiiadd {\XINT_mul_fork #2\Z #6\Z}{\XINT_mul_fork #1\Z #4\Z}}% - {\romannumeral0\xintiiadd {\XINT_mul_fork #2\Z #5\Z}{\XINT_mul_fork #1\Z #3\Z}}% + {\romannumeral0\XINT_mul_fork #2\xint:#4\xint:}% + {\romannumeral0\XINT_mul_fork #2\xint:#3\xint:}% + {\romannumeral0\xintiiadd {\XINT_mul_fork #2\xint:#6\xint:}% + {\XINT_mul_fork #1\xint:#4\xint:}}% + {\romannumeral0\xintiiadd {\XINT_mul_fork #2\xint:#5\xint:}% + {\XINT_mul_fork #1\xint:#3\xint:}}% }% \def\XINT_ctcv_loop_c #1#2% {% @@ -29303,7 +29896,7 @@ $1$ or $-1$. \def\xintiCstoCv {\romannumeral0\xinticstocv }% \def\xinticstocv #1% {% - \expandafter\XINT_icstcv_prep \romannumeral`&&@#1,\xint_relax,% + \expandafter\XINT_icstcv_prep \romannumeral`&&@#1,!,% }% \def\XINT_icstcv_prep {% @@ -29311,15 +29904,15 @@ $1$ or $-1$. }% \def\XINT_icstcv_loop_a #1#2#3#4#5#6,% {% - \xint_gob_til_xint_relax #6\XINT_icstcv_end\xint_relax + \xint_gob_til_exclam #6\XINT_icstcv_end!% \expandafter \XINT_icstcv_loop_b \romannumeral`&&@#6.{#2}{#3}{#4}{#5}{#1}% }% \def\XINT_icstcv_loop_b #1.#2#3#4#5% {% \expandafter\XINT_icstcv_loop_c\expandafter - {\romannumeral0\xintiiadd {#5}{\XINT_mul_fork #1\Z #3\Z}}% - {\romannumeral0\xintiiadd {#4}{\XINT_mul_fork #1\Z #2\Z}}% + {\romannumeral0\xintiiadd {#5}{\XINT_mul_fork #1\xint:#3\xint:}}% + {\romannumeral0\xintiiadd {#4}{\XINT_mul_fork #1\xint:#2\xint:}}% {{#2}{#3}}% }% \def\XINT_icstcv_loop_c #1#2% @@ -29339,7 +29932,7 @@ $1$ or $-1$. \def\xintGCtoCv {\romannumeral0\xintgctocv }% \def\xintgctocv #1% {% - \expandafter\XINT_gctcv_prep \romannumeral`&&@#1+\xint_relax/% + \expandafter\XINT_gctcv_prep \romannumeral`&&@#1+!/% }% \def\XINT_gctcv_prep {% @@ -29353,10 +29946,12 @@ $1$ or $-1$. \def\XINT_gctcv_loop_b #1/#2.#3#4#5#6% {% \expandafter\XINT_gctcv_loop_c\expandafter - {\romannumeral0\XINT_mul_fork #2\Z #4\Z }% - {\romannumeral0\XINT_mul_fork #2\Z #3\Z }% - {\romannumeral0\xintiiadd {\XINT_mul_fork #2\Z #6\Z}{\XINT_mul_fork #1\Z #4\Z}}% - {\romannumeral0\xintiiadd {\XINT_mul_fork #2\Z #5\Z}{\XINT_mul_fork #1\Z #3\Z}}% + {\romannumeral0\XINT_mul_fork #2\xint:#4\xint:}% + {\romannumeral0\XINT_mul_fork #2\xint:#3\xint:}% + {\romannumeral0\xintiiadd {\XINT_mul_fork #2\xint:#6\xint:}% + {\XINT_mul_fork #1\xint:#4\xint:}}% + {\romannumeral0\xintiiadd {\XINT_mul_fork #2\xint:#5\xint:}% + {\XINT_mul_fork #1\xint:#3\xint:}}% }% \def\XINT_gctcv_loop_c #1#2% {% @@ -29381,17 +29976,17 @@ $1$ or $-1$. }% \def\XINT_gctcv_loop_h #1#2#3/% {% - \xint_gob_til_xint_relax #3\XINT_gctcv_end\xint_relax + \xint_gob_til_exclam #3\XINT_gctcv_end!% \expandafter\XINT_gctcv_loop_i \romannumeral0\xintrawwithzeros {#3}.#2{#1}% }% \def\XINT_gctcv_loop_i #1/#2.#3#4#5#6% {% \expandafter\XINT_gctcv_loop_j\expandafter - {\romannumeral0\XINT_mul_fork #1\Z #6\Z }% - {\romannumeral0\XINT_mul_fork #1\Z #5\Z }% - {\romannumeral0\XINT_mul_fork #2\Z #4\Z }% - {\romannumeral0\XINT_mul_fork #2\Z #3\Z }% + {\romannumeral0\XINT_mul_fork #1\xint:#6\xint:}% + {\romannumeral0\XINT_mul_fork #1\xint:#5\xint:}% + {\romannumeral0\XINT_mul_fork #2\xint:#4\xint:}% + {\romannumeral0\XINT_mul_fork #2\xint:#3\xint:}% }% \def\XINT_gctcv_loop_j #1#2% {% @@ -29413,7 +30008,7 @@ $1$ or $-1$. \def\xintiGCtoCv {\romannumeral0\xintigctocv }% \def\xintigctocv #1% {% - \expandafter\XINT_igctcv_prep \romannumeral`&&@#1+\xint_relax/% + \expandafter\XINT_igctcv_prep \romannumeral`&&@#1+!/% }% \def\XINT_igctcv_prep {% @@ -29427,8 +30022,8 @@ $1$ or $-1$. \def\XINT_igctcv_loop_b #1.#2#3#4#5% {% \expandafter\XINT_igctcv_loop_c\expandafter - {\romannumeral0\xintiiadd {#5}{\XINT_mul_fork #1\Z #3\Z}}% - {\romannumeral0\xintiiadd {#4}{\XINT_mul_fork #1\Z #2\Z}}% + {\romannumeral0\xintiiadd {#5}{\XINT_mul_fork #1\xint:#3\xint:}}% + {\romannumeral0\xintiiadd {#4}{\XINT_mul_fork #1\xint:#2\xint:}}% {{#2}{#3}}% }% \def\XINT_igctcv_loop_c #1#2% @@ -29437,15 +30032,15 @@ $1$ or $-1$. }% \def\XINT_igctcv_loop_f #1#2#3#4/% {% - \xint_gob_til_xint_relax #4\XINT_igctcv_end_a\xint_relax + \xint_gob_til_exclam #4\XINT_igctcv_end_a!% \expandafter\XINT_igctcv_loop_g \romannumeral`&&@#4.#1#2{#3}% }% \def\XINT_igctcv_loop_g #1.#2#3#4#5% {% \expandafter\XINT_igctcv_loop_h\expandafter - {\romannumeral0\XINT_mul_fork #1\Z #5\Z }% - {\romannumeral0\XINT_mul_fork #1\Z #4\Z }% + {\romannumeral0\XINT_mul_fork #1\xint:#5\xint:}% + {\romannumeral0\XINT_mul_fork #1\xint:#4\xint:}% {{#2}{#3}}% }% \def\XINT_igctcv_loop_h #1#2% @@ -29682,28 +30277,28 @@ $1$ or $-1$. \def\xintCstoGC {\romannumeral0\xintcstogc }% \def\xintcstogc #1% {% - \expandafter\XINT_cstc_prep \romannumeral`&&@#1,\xint_relax,% + \expandafter\XINT_cstc_prep \romannumeral`&&@#1,!,% }% \def\XINT_cstc_prep #1,{\XINT_cstc_loop_a {{#1}}}% \def\XINT_cstc_loop_a #1#2,% {% - \xint_gob_til_xint_relax #2\XINT_cstc_end\xint_relax + \xint_gob_til_exclam #2\XINT_cstc_end!% \XINT_cstc_loop_b {#1}{#2}% }% \def\XINT_cstc_loop_b #1#2{\XINT_cstc_loop_a {#1+1/{#2}}}% -\def\XINT_cstc_end\xint_relax\XINT_cstc_loop_b #1#2{ #1}% +\def\XINT_cstc_end!\XINT_cstc_loop_b #1#2{ #1}% % \end{macrocode} % \subsection{\csh{xintGCtoGC}} % \begin{macrocode} \def\xintGCtoGC {\romannumeral0\xintgctogc }% \def\xintgctogc #1% {% - \expandafter\XINT_gctgc_start \romannumeral`&&@#1+\xint_relax/% + \expandafter\XINT_gctgc_start \romannumeral`&&@#1+!/% }% \def\XINT_gctgc_start {\XINT_gctgc_loop_a {}}% \def\XINT_gctgc_loop_a #1#2+#3/% {% - \xint_gob_til_xint_relax #3\XINT_gctgc_end\xint_relax + \xint_gob_til_exclam #3\XINT_gctgc_end!% \expandafter\XINT_gctgc_loop_b\expandafter {\romannumeral`&&@#2}{#3}{#1}% }% @@ -29716,7 +30311,7 @@ $1$ or $-1$. {% \XINT_gctgc_loop_a {#3{#2}+{#1}/}% }% -\def\XINT_gctgc_end\xint_relax\expandafter\XINT_gctgc_loop_b +\def\XINT_gctgc_end!\expandafter\XINT_gctgc_loop_b {% \expandafter\XINT_gctgc_end_b }% @@ -29863,11 +30458,14 @@ $1$ or $-1$. \XINTsetupcatcodes% % \end{macrocode} % \subsection{Package identification} +% \lverb|& +% | % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xintexpr}% - [2017/01/06 1.2k Expandable expression parser (JFB)]% + [2017/07/26 1.2l Expandable expression parser (JFB)]% \catcode`! 11 +\let\XINT_Cmp \xintiiCmp % \end{macrocode} % \subsection{Locking and unlocking} % \lverb|Some renaming and modifications here with release 1.2 to switch from @@ -29896,11 +30494,13 @@ $1$ or $-1$. % could probably be made faster by using techniques similar as the ones 1.2 % uses in xintcore.sty.| % \begin{macrocode} -\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 - {\noexpand\expandafter\space\noexpand\csname .=#1\endcsname }% -\edef\XINT_expr_lockit - #1{\noexpand\expandafter\space\noexpand\csname .=#1\endcsname }% +\def\xint_gob_til_! #1!{}% ! with catcode 11 +\def\XINT_expr_lockscan#1{% not used for decimal numbers in xintexpr 1.2 +\def\XINT_expr_lockscan##1!{\expandafter#1\csname .=##1\endcsname}% +}\XINT_expr_lockscan{ }% +\def\XINT_expr_lockit#1{% +\def\XINT_expr_lockit##1{\expandafter#1\csname .=##1\endcsname}% +}\XINT_expr_lockit{ }% \def\XINT_expr_unlock_hex_in #1% expanded inside \csname..\endcsname {\expandafter\XINT_expr_inhex\romannumeral`&&@\XINT_expr_unlock#1;}% \def\XINT_expr_inhex #1.#2#3;% expanded inside \csname..\endcsname @@ -30162,7 +30762,7 @@ $1$ or $-1$. \if ^#1\xint_dothis\XINT_:::_end\fi \xint_orthat\XINT_pfloat::_d #1}% \def\XINT_pfloat::_d #1,#2% - {\expandafter\XINT_pfloat::_e\romannumeral0\XINT_pfloat_opt [\xint_relax #2]{#1},{#2}}% + {\expandafter\XINT_pfloat::_e\romannumeral0\XINT_pfloat_opt [\xint:#2]{#1},{#2}}% \def\XINT_pfloat::_e #1,#2#3{\XINT_pfloat::_b {#2}{#3, #1}}% % \end{macrocode} % \subsection{\csh{XINT_expr_getnext}: fetching some number then an operator} @@ -30311,10 +30911,14 @@ $1$ or $-1$. % handing over back control to \XINT_expr_getop. Earlier we had to identify % the catcode 11 ! signaling a sub-expression here. With no \string applied % we can do it in \XINT_expr_getop. As a corollary of this displacement, -% parsing of big numbers should be a tiny bit faster now.| +% parsing of big numbers should be a tiny bit faster now. +% +% Extended for 1.2l to ignore underscore character _ if encountered within +% digits; so it can serve as separator for better readability.| % \begin{macrocode} \def\XINT_expr_scanint_c\string #1\XINT_expr_scanint_d {% + \if _#1\xint_dothis\XINT_expr_scanint_d\fi \if e#1\xint_dothis{[\the\numexpr0\XINT_expr_scanexp_a +}\fi \if E#1\xint_dothis{[\the\numexpr0\XINT_expr_scanexp_a +}\fi \if .#1\xint_dothis{\XINT_expr_startdec_a .}\fi @@ -30338,6 +30942,7 @@ $1$ or $-1$. \def\XINT_expr_gobz_scanint_endbycs#1#2\XINT_expr_scanint_d{0\endcsname #1}% \def\XINT_expr_gobz_scanint_c\string #1\XINT_expr_scanint_d {% + \if _#1\xint_dothis\XINT_expr_gobz_scanint_d\fi \if e#1\xint_dothis{0[\the\numexpr0\XINT_expr_scanexp_a +}\fi \if E#1\xint_dothis{0[\the\numexpr0\XINT_expr_scanexp_a +}\fi \if .#1\xint_dothis{\XINT_expr_gobz_startdec_a .}\fi @@ -30382,10 +30987,13 @@ $1$ or $-1$. }% \def\XINT_expr_scandec_c\string #1#2\the\numexpr#3-\xint_c_i.% {% + \if _#1\xint_dothis{\XINT_expr_scandec_d#3.}\fi \if e#1\xint_dothis{[\the\numexpr#3\XINT_expr_scanexp_a +}\fi \if E#1\xint_dothis{[\the\numexpr#3\XINT_expr_scanexp_a +}\fi \xint_orthat {[#3]\endcsname #1}% }% +% \end{macrocode} +% \begin{macrocode} \def\XINT_expr_gobz_scandec_b #1.#2% {% \ifcat \relax #2\expandafter\XINT_expr_gobz_scandec_endbycs\expandafter#2\fi @@ -30394,9 +31002,12 @@ $1$ or $-1$. {\expandafter\XINT_expr_gobz_scandec_b}% {\string#2\expandafter\XINT_expr_scandec_d}\the\numexpr#1-\xint_c_i.% }% +% \end{macrocode} +% \begin{macrocode} \def\XINT_expr_gobz_scandec_endbycs #1#2\xint_c_i.{0[0]\endcsname #1}% -\def\XINT_expr_gobz_scandec_c\if0#1#2\fi #3\xint_c_i.% +\def\XINT_expr_gobz_scandec_c\if0#1#2\fi #3\numexpr#4-\xint_c_i.% {% + \if _#1\xint_dothis{\XINT_expr_gobz_scandec_b #4.}\fi \if e#1\xint_dothis{0[\the\numexpr0\XINT_expr_scanexp_a +}\fi \if E#1\xint_dothis{0[\the\numexpr0\XINT_expr_scanexp_a +}\fi \xint_orthat {0[0]\endcsname #1}% @@ -30423,6 +31034,7 @@ $1$ or $-1$. }% \def\XINT_expr_scanexp_c\string #1\XINT_expr_scanexp_d {% + \if _#1\xint_dothis \XINT_expr_scanexp_d \fi \if +#1\xint_dothis {\XINT_expr_scanexp_a +}\fi \if -#1\xint_dothis {\XINT_expr_scanexp_a -}\fi \xint_orthat {]\endcsname #1}% @@ -30438,7 +31050,11 @@ $1$ or $-1$. {% \expandafter\XINT_expr_scanexp_bb\romannumeral`&&@#1% }% -\def\XINT_expr_scanexp_cb\string #1\XINT_expr_scanexp_db {]\endcsname #1}% +\def\XINT_expr_scanexp_cb\string #1\XINT_expr_scanexp_db +{% + \if _#1\xint_dothis\XINT_expr_scanexp_d\fi + \xint_orthat{]\endcsname #1}% +}% % \end{macrocode} % \subsubsection{Hexadecimal numbers} % \lverb|1.2d has moved most of the handling of tacit multiplication to @@ -30447,7 +31063,10 @@ $1$ or $-1$. % in \XINT_expr_scanhexI_a, because it is its higher precedence variant which % will is expected, to do the same as when a non-hexadecimal number prefixes a % sub-expression. Tacit multiplication in front of variable or function names -% will not work (because of this \string).| +% will not work (because of this \string). +% +% Extended for 1.2l to ignore underscore character _ if encountered within +% digits.| % \begin{macrocode} \def\XINT_expr_scanhex_I #1% #1=" {% @@ -30469,12 +31088,9 @@ $1$ or $-1$. 0\else1\fi\else0\fi\else1\fi\else0\fi 1% \expandafter\XINT_expr_scanhexI_b \else - \if .#1% - \expandafter\xint_firstoftwo - \else % gather what we got so far, leave catcode 12 #1 in stream - \expandafter\xint_secondoftwo - \fi - {\expandafter\XINT_expr_scanhex_transition}% + \if _#1\xint_dothis{\expandafter\XINT_expr_scanhexI_bgob}\fi + \if .#1\xint_dothis{\expandafter\XINT_expr_scanhex_transition}\fi + \xint_orthat % gather what we got so far, leave catcode 12 #1 in stream {\xint_afterfi {.>\endcsname\endcsname}}% \fi #1% @@ -30483,6 +31099,10 @@ $1$ or $-1$. {% #1\expandafter\XINT_expr_scanhexI_a\romannumeral`&&@#2% }% +\def\XINT_expr_scanhexI_bgob #1#2% +{% + \expandafter\XINT_expr_scanhexI_a\romannumeral`&&@#2% +}% \def\XINT_expr_scanhex_transition .#1% {% \expandafter.\expandafter.\expandafter @@ -30503,7 +31123,8 @@ $1$ or $-1$. 0\else1\fi\else0\fi\else1\fi\else0\fi 1% \expandafter\XINT_expr_scanhexII_b \else - \xint_afterfi {\endcsname\endcsname}% + \if _#1\xint_dothis{\expandafter\XINT_expr_scanhexII_bgob}\fi + \xint_orthat{\xint_afterfi {\endcsname\endcsname}}% \fi #1% }% @@ -30511,6 +31132,10 @@ $1$ or $-1$. {% #1\expandafter\XINT_expr_scanhexII_a\romannumeral`&&@#2% }% +\def\XINT_expr_scanhexII_bgob #1#2% +{% + \expandafter\XINT_expr_scanhexII_a\romannumeral`&&@#2% +}% % \end{macrocode} % \subsubsection{Parsing names of functions and variables} % \begin{macrocode} @@ -31206,8 +31831,7 @@ $1$ or $-1$. % by expression parser (as <digits><variable> is allowed by the syntax and does % tacit multiplication).| % \begin{macrocode} -\edef\XINT_expr_op_][: #1{\xint_c_ii \expandafter\noexpand - \csname XINT_expr_itself_][\endcsname #10\string :}% +\edef\XINT_expr_op_][: #1{\xint_c_ii\noexpand\XINT_expr_itself_][#10\string :}% \let\XINT_flexpr_op_][: \XINT_expr_op_][: \let\XINT_iiexpr_op_][: \XINT_expr_op_][: \catcode`[ 12 \catcode`] 12 @@ -33659,7 +34283,7 @@ $1$ or $-1$. \toks0 \expandafter{\the\toks0 \def\xintListSel:x:csv {~xintListSel:f:csv }% }% -\odef\XINT_expr_redefinemacros {\the\toks0}% Not \edef ! (subtle) +\odef\XINT_expr_redefinemacros {\the\toks0}% \def\XINT_expr_redefineprints {% \def\XINT_flexpr_noopt @@ -33840,34 +34464,34 @@ $1$ or $-1$. %<*dtx>----------------------------------------------------------- \iffalse % grep -c -e "^{%" xint*sty -xint.sty:215 -xintbinhex.sty:69 +xint.sty:196 +xintbinhex.sty:70 xintcfrac.sty:183 -xintcore.sty:273 -xintexpr.sty:165 -xintfrac.sty:428 -xintgcd.sty:59 +xintcore.sty:278 +xintexpr.sty:168 +xintfrac.sty:439 +xintgcd.sty:50 xintkernel.sty:13 xintseries.sty:48 -xinttools.sty:139 +xinttools.sty:138 \fi % grep -o "^{%" xint*sty | wc -l -\def\totala{ 1592} +\def\totala{ 1583} \iffalse % grep -c -e "^}%" xint*sty -xint.sty:214 -xintbinhex.sty:69 +xint.sty:195 +xintbinhex.sty:65 xintcfrac.sty:183 -xintcore.sty:273 -xintexpr.sty:196 -xintfrac.sty:426 -xintgcd.sty:61 +xintcore.sty:275 +xintexpr.sty:199 +xintfrac.sty:437 +xintgcd.sty:52 xintkernel.sty:14 xintseries.sty:48 -xinttools.sty:138 +xinttools.sty:137 \fi % grep -o "^}%" xint*sty | wc -l -\def\totalb{ 1622} +\def\totalb{ 1605} \DeleteShortVerb{\|} \def\mymacro #1{\mymacroaux #1} \def\mymacroaux #1#2{\strut \csname #1nameimp\endcsname:& \dtt{ #2.}\tabularnewline } @@ -33904,7 +34528,8 @@ xinttools.sty:138 Right bracket \] Circumflex \^ Underscore \_ Grave accent \` Left brace \{ Vertical bar \| Right brace \} Tilde \~} -\CheckSum {30677}% était 30303 pour 1.2h, 30403 pour 1.2i, 30750 pour 1.2j +\CheckSum {30931}% 30303 pour 1.2h, 30403 pour 1.2i, 30750 pour 1.2j, + % 30677 pour 1.2k \makeatletter\check@checksum\makeatother \Finale %% End of file xint.dtx diff --git a/Master/texmf-dist/source/generic/xint/xint.ins b/Master/texmf-dist/source/generic/xint/xint.ins index 8f6eefb7c91..9389268dca2 100644 --- a/Master/texmf-dist/source/generic/xint/xint.ins +++ b/Master/texmf-dist/source/generic/xint/xint.ins @@ -21,7 +21,7 @@ %% same distribution. (The sources need not necessarily be %% in the same archive or directory.) %% --------------------------------------------------------------- -%% The xint bundle 1.2k 2017/01/06 +%% The xint bundle 1.2l 2017/07/26 %% Copyright (C) 2013-2017 by Jean-Francois Burnol %% --------------------------------------------------------------- %% |