diff options
author | Karl Berry <karl@freefriends.org> | 2017-08-01 21:38:49 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-08-01 21:38:49 +0000 |
commit | 9a9c1b6e2502a6a9c90e739c411de26012b9db2c (patch) | |
tree | b72c9fa43c71360ad6c0d3c8e1b86c2530273492 /Master/texmf-dist/source | |
parent | 7ba0b2e501e4b5d83a48295804d3570ef3407f8a (diff) |
xint (1aug17)
git-svn-id: svn://tug.org/texlive/trunk@44934 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r-- | Master/texmf-dist/source/generic/xint/xint.dtx | 1590 | ||||
-rw-r--r-- | Master/texmf-dist/source/generic/xint/xint.ins | 2 |
2 files changed, 827 insertions, 765 deletions
diff --git a/Master/texmf-dist/source/generic/xint/xint.dtx b/Master/texmf-dist/source/generic/xint/xint.dtx index 8e22f7797dd..0c3e58ba9cc 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: <26-07-2017 at 19:42:16 CEST>} +\def\xintdtxtimestamp {Time-stamp: <31-07-2017 at 22:49:40 CEST>} %</dtx> %<*drv> %% --------------------------------------------------------------- -\def\xintdocdate {2017/07/26} -\def\xintbndldate{2017/07/26} -\def\xintbndlversion {1.2l} +\def\xintdocdate {2017/07/31} +\def\xintbndldate{2017/07/31} +\def\xintbndlversion {1.2m} %</drv> %<readme>% README %<changes>% CHANGE LOG -%<readme|changes>% xint 1.2l -%<readme|changes>% 2017/07/26 +%<readme|changes>% xint 1.2m +%<readme|changes>% 2017/07/31 %<readme|changes> -%<readme|changes> Source: xint.dtx 1.2l 2017/07/26 (doc 2017/07/26) +%<readme|changes> Source: xint.dtx 1.2m 2017/07/31 (doc 2017/07/31) %<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.2l 2017/07/26 +%% The xint bundle 1.2m 2017/07/31 %% Copyright (C) 2013-2017 by Jean-Francois Burnol %<xintkernel>%% xintkernel: Paraphernalia for the xint packages %<xinttools>%% xinttools: Expandable and non-expandable utilities @@ -56,48 +56,56 @@ fractions, and floating point numbers. For example \xinttheexpr reduce(37189719/183618963+11390170/17310720)^17\relax -will evaluate exactly the fraction (the result has 462 characters -including the fraction slash). One can also work with dummy -variables: +will evaluate exactly the fraction; the result has 462 characters +(including the fraction slash.) One can also work with dummy variables: \xinttheexpr mul(add(x(x+1)(x+2), x=y..y+15), y=171286,98762,9296)\relax -(evaluates to `15979066346135829902328007959448563667099190784`.) +evaluates to `15979066346135829902328007959448563667099190784`. Float computations are possible at an adjustable precision (default 16). - \xintDigits:=48;\xintthefloatexpr 123456789^1000.5\relax + \xintDigits:=48;\xintthefloatexpr 123_456_789^1_000.5\relax ->3.63692761822782679930738270515740797370813691938e8095 -However, only integer and half-integer exponents are currently allowed. -The `sqrt` operation achieves correct rounding in arbitrary precision. - -It is possible to use the package with Plain as well as with LaTeX. +But currently, only integer and half-integer exponents are allowed for +the power operation in expressions and only the square-root operation is +implemented besides the four arithmetic operations. Square-root and the +four operations achieve correct rounding in the given arbitrary +precision. Sub-units `xintcore`, `xint` and `xintfrac` provide the underlying macros, and `xintexpr` loads all of them and provides expandable parsers allowing computations such as the above (and more). -A more light-weight (LaTeX only) package -[bnumexpr](http://www.ctan.org/pkg/bnumexpr) loads only `xintcore` and -provides a parser which handles only big integers, the four operations, -the power operation and the factorial. - Usage ===== +It is possible to use the package with Plain (via `\input` anywhere) or with +LaTeX (via `\usepackage` in the preamble). + ## With LaTeX \usepackage{xint} % expandable arithmetic with big integers \usepackage{xintfrac} % decimal numbers, fractions, floats \usepackage{xintexpr} % expressions with infix operators -Further packages: `xintbinhex`, `xintgcd`, `xintseries` and -`xintcfrac`. All dependencies are handled automatically. For example -`xintexpr` automatically loads `xintfrac` which itself loads `xint`. +Further packages: `xintbinhex`, `xintgcd`, `xintseries` and `xintcfrac`. + +Main dependencies are handled automatically. For example `xintexpr` +automatically loads `xintfrac` which itself loads `xint`; but use of the +`gcd` and `lcm` functions in expressions require explicit loading of +`xintgcd`, and hexadecimal notation requires explicit loading of +`xintbinhex`. + Package `xintcore` is the subset of `xint` providing only the five -operations on big integers: `\xintiiAdd`, `\xintiiMul`,\ ... +operations on big integers: `\xintiiAdd`, `\xintiiMul`,\ ... It is (by +default) loaded by the (LaTeX only) package +[bnumexpr](http://www.ctan.org/pkg/bnumexpr) which provides a more +light-weight expression parser handling only big integers, the four +operations, the power operation and the factorial. + There is also `xinttools` which is a separate package providing, among others, expandable and non-expandable loops such as `\xintFor`. @@ -107,9 +115,8 @@ One does for example: \input xintexpr.sty -All dependencies are handled automatically. The packages may -be loaded in any catcode context such that letters, digits, `\` and -`%` have their standard catcodes. +The packages may be loaded in any catcode context such that letters, +digits, `\` and `%` have their standard catcodes. `xintcore.sty` and `xinttools.sty` both import `xintkernel.sty` which has the catcode handler and package identifier and defines a @@ -243,6 +250,44 @@ Makefile.mk.</div> %</readme>-------------------------------------------------------- %<*changes>------------------------------------------------------- +`1.2m (2017/07/31)` +---- + +### Incompatible changes + + - **xintbinhex**: the length of the input is now limited. The maximum + size depends on the macro and ranges from about `4000` to about + `19900` digits. + + - **xintbinhex**: `\xintCHexToBin` is now the variant of + `\xintHexToBin` which does not remove leading binary zeroes: `N` + hex-digits give on output exactly `4N` binary digits. + +### Improvements and new features + + - **xintbinhex**: all macros have been rewritten using techniques from + the 1.2 release (they had remained unmodified since `1.08` of + `2013/06/07`.) The new macros are faster but limited to a few + thousand digits. The `1.08` routines could handle tens of thousands + of digits, but not in a reasonable time. + +### Bug fixes + + - user manual: the `Changes` section wrongly stated at `1.2l` that the + macros of **xintbinhex** had been made robust against non terminated + input such as ``\number\mathcode`\-``. Unfortunately the author fell + into the trap of believing his own documentation and he forgot to + actually implement the change. Now done. + + - user manual: the PDF bookmarks were messed up. + + - **xint**, **xintfrac**: `\xintGeq`, `\xintMax`, `\xintMin`, suffered + from some extra overhead. This was caused by use of some auxiliaries + from the very early days which got redefined at some stage. This is + fixed here with some additional efficiency improvements and pruning + of old code. + + `1.2l (2017/07/26)` ---- @@ -2144,7 +2189,7 @@ dvipdfmx CHANGES.dvi \def\SKIPSECTIONINTERSPACE{\vskip\bigskipamount} \etocsetstyle{section}{} {\normalfont} - {\SKIPSECTIONINTERSPACE + {\etociffirst{}{\SKIPSECTIONINTERSPACE}% \rightskip \MARGEPAGENO\relax \parfillskip -\MARGEPAGENO\relax \bfseries @@ -2990,7 +3035,7 @@ pdfpagemode=UseOutlines} {From source file \texttt{xint.dtx}. \xintdtxtimestamp.}\par } -\bigskip +\medskip % Mercredi 08 octobre 2014 à 22:03:19 % Skips safely. @@ -3017,21 +3062,6 @@ pdfpagemode=UseOutlines} \etocsettagdepth {macros}{none} \etocsettagdepth {implementation}{none} \tableofcontents -\renewcommand*\etocabovetocskip{\bigskipamount} -\makeatletter -\etocmulticolstyle [2]{\parskip\z@skip\raggedcolumns - \setlength{\columnsep}{\leftmarginii}% - \setlength{\columnseprule}{0pt}% -}% -\makeatother - \etocsettagdepth {description}{none} - \etocsettagdepth {macros} {section} -\ifnum\NoSourceCode=1 - \etocsettagdepth {implementation}{none} -\else - \etocsettagdepth {implementation}{section} -\fi -\tableofcontents \begingroup\makeatletter \etocsetlevel{table}{0} @@ -3042,7 +3072,7 @@ pdfpagemode=UseOutlines} \rightskip \MARGEPAGENO\relax \parfillskip -\MARGEPAGENO\relax \leftskip \z@skip - \noindent\strut Table of \etocname + \noindent\strut \etoclink{Table of \etocthename}% \nobreak\leaders\etoctoclineleaders\hfill\nobreak\strut \makebox[\MARGEPAGENO][r]{\etocpage}\par }% @@ -3051,10 +3081,26 @@ pdfpagemode=UseOutlines} \etocsettagdepth{macros}{none} \etocsettagdepth{implementation}{none} \etocsettocstyle{}{} -\smallskip +\medskip \tableofcontents \endgroup +\renewcommand*\etocabovetocskip{\bigskipamount} +\makeatletter +\etocmulticolstyle [2]{\parskip\z@skip\raggedcolumns + \setlength{\columnsep}{\leftmarginii}% + \setlength{\columnseprule}{0pt}% +}% +\makeatother + \etocsettagdepth {description}{none} + \etocsettagdepth {macros} {section} +\ifnum\NoSourceCode=1 + \etocsettagdepth {implementation}{none} +\else + \etocsettagdepth {implementation}{section} +\fi +\tableofcontents + \etocignoredepthtags \etocmulticolstyle [1]{% \phantomsection% \section* {Contents} @@ -3885,7 +3931,12 @@ This is release \expandafter|\xintbndlversion| of \expandafter|\xintbndldate|. -The underscore |_| is accepted inside the expression parsers as an ignored +The macros of \xintbinhexname for conversion routines between binary, decimal, +and hexadecimal bases have been entirely re-written. They are faster, the more +so for long inputs. But they have the drawback of now limiting their input to +a maximal length of a few thousands characters. + +Since |1.2l|, 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: @@ -3899,15 +3950,15 @@ 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). +|\xintiiAdd{\the\numexpr1}{2}| caused crashes. This has been fixed: the +arithmetic macros of \xintcorename, the macros of \xintfracname, those of +\xintgcdname, 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. +Some refactoring took place at |1.2l| in the sources of \xintcorename for some +efficiency gains, and improvements in the code comments. See |CHANGES.html| or |CHANGES.pdf| for more information (either |texdoc --list xint| or on the internet via @@ -3972,7 +4023,7 @@ See |CHANGES.html| or |CHANGES.pdf| for more information (either |texdoc \end{tabular} \caption{Precedence levels (click on levels)} \label{tab:precedences} -\addcontentsline {toc}{table}{Precedence levels of operators in expressions} +\etoctoccontentsline {table}{Precedence levels of operators in expressions} \end{table} The \autoref{tab:precedences} is hyperlinked to the more detailed discussion @@ -4194,7 +4245,7 @@ corresponding definitions. % \ifnumgreater{\cnta}{0}{\xintFor*#1in{\xintSeq[1]{\cnta}{4}}\do{&}\\\hline}{}% \end{tabular} \caption{Functions (click on names)}\label{tab:functions} -\addcontentsline{toc}{table}{Functions in expressions} +\etoctoccontentsline {table}{Functions in expressions} \end{table} Miscellaneous notes: @@ -5449,7 +5500,13 @@ variants: token. \item In particular, spaces between digits (and not only around infix operators or parentheses) do not stop |\xintiiexpr|, contrarily to the - situation with |numexpr|: |\the\numexpr 7 + 3 5\relax| expands (in one step) + situation with |numexpr|: |\the\numexpr 7 + 3 5\relax| expands (in one + step)% +% +\footnote {The |\numexpr| triggers continued expansion after the space + following the |3| to check if some operator like |+| is upstream. But + after having found the |5| it treats it as and end-marker.} +% 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 @@ -5458,20 +5515,25 @@ variants: \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 - expansion of |\numexpr| in an |\edef| occurs only if prefixed with |\the| - or |\number| (or |\romannumeral|, or the expression is included in a - bigger |\numexpr| which will be the one to have to be prefixed\dots .) - \item |\the\numexpr| or |\number\numexpr| expands in one step, but - |\xintthe\xintiiexpr| needs two steps. -\item |\numexpr -(1)\relax| is illegal. - But |\xintiiexpr -(1)\relax| is perfectly legal and gives the expected - result (what else ?). -\item |\numexpr 2\cnta\relax| is illegal, with |\cnta| a |\count|. But +\item Inside an |\edef|, an expression |\xintiiexpr...\relax| get fully + evaluated, whereas |\numexpr| without |\the| or |\number| prefix would not, + if not itself embedded in another |\the\numexpr| or similar context. +\item (ctd.) The private format to which |\xintiiexpr...\relax| (et al.) + evaluates needs |\xintthe| prefix to be printed on the page, or be used in + macros (expanding their argument.) The |\the| \TeX\ primitive prefix would + not work here. +\item (ctd.) As a synonym to |\xintthe\xintiiexpr| one can use |\xinttheiiexpr|, + or (since |1.2h|) |\thexintiiexpr|. +\item (ctd.) One can embed a |\numexpr...\relax| (with its |\relax|!) inside an + |\xintiiexpr...\relax| without |\the| or |\number|, but the reverse situation + requires use of |\xinthe|. +\item |\numexpr -(1)\relax| is illegal. But |\xintiiexpr -(1)\relax| is + perfectly legal and gives the expected result (what else ?). +\item |\numexpr 2\cnta\relax| is illegal (with |\cnta| a |\count| register.) But |\xintiiexpr 2\cnta\relax| is perfectly legal and will do the tacit multiplication. +\item |\the\numexpr| or |\number\numexpr| expands in one step, but + |\xintthe\xintiiexpr| or |\xinttheiiexpr| needs two steps. \end{itemize} \subsection{Chaining expressions for expandable algorithmics} @@ -13257,25 +13319,53 @@ principles are necessarily different due to the aim of achieving expandability. \localtableofcontents -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. Routines have not been modified since. +This package provides expandable conversions of arbitrarily big integers to +and from binary and hexadecimal. + +It was first included in the |1.08| (|2013/06/07|) release of \xintname. Its +routines remained un-modified until their complete rewrite at release |1.2m| +(|2017/07/31|). The new macros are faster, using techniques from the |1.2| +(|2015/10/10|) release of \xintcorename. But the inputs are now limited to a +few thousand characters (check next for the respective maxima, the values +given have a safety margin for nested contexts). The argument is first \fexpan ded. -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. +It may optionally have a unique leading minus sign (a plus sign is not +allowed), and leading zeroes. + +An input (possibly signed) with no leading zeroes is guaranteed to give an +output without leading zero, with the sole, deliberate, exception of +\csbxint{CHexToBin}: from |N| hexadecimal digits it produces |4N| binary +digits,\CHANGED{1.2m} hence possibly with up to three leading zeroes (if the +input had none.) + +Inputs with leading zeroes usually produce outputs with an unspecified, +case-dependent, number of leading zeroes (\csbxint{BinToHex} always uses the +minimal number of hexadecimal digits needed to represent the binary digits, +inclusive of leading zeroes if present.) -Input must not be within quotes or with |0b|, |0x|, |#x| or similar prefixes: -simply decimal, binary, or hexadecimal digits. +The macros\CHANGED{1.2m} converting from binary or decimal are robust against +non terminated inputs like |\the\numexpr 2+3| or |\the\mathcode`\-|. The macro +\csbxint{HexToDec} also but not \csbxint{HexToBin} and \csbxint{CHexToBin} +(anyway there are no primitive in (e)-\TeX\ to my knowledge which will +generate hexadecimal digits and may force expansion of next token). -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. +Hexadecimal digits |A..F| must be in uppercase. Category code for them on +input may be \emph{letter} or \emph{other}. On output they are of category +code \emph{letter}, and in uppercase. + +Low-level unrecoverable errors will happen if for example a supposedly binary +input contains other digits than |0| and |1|. Inputs can not start with a +|0b|, |0x|, |#x|, |"| or similar prefix: only digits/letters according to the +binary, decimal, or hexadecimal notation. + + +With this package loaded additionally to \xintexprname, hexadecimal input is +possible in expressions: simply by using the prefix |"|. Such hexadecimal +numbers may have a fractional part. Lowercase letters are allowed there. +Currently the |p| postfix notation from standard programming languages given a +power of two multiplicand is not implemented. % \clearpage @@ -13283,18 +13373,27 @@ uppercase. Converts from decimal to hexadecimal.\etype{f} +Input limited to |4000| digits (only a few more allowed) with standard \TeX\ +settings.\CHANGED{1.2m} + \texttt{\string\xintDecToHex \string{\printnumber{2718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003}\string}}\endgraf\noindent\dtt{->\printnumber{\xintDecToHex{2718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003}}} \subsection{\csbh{xintDecToBin}}\label{xintDecToBin} Converts from decimal to binary.\etype{f} +Input limited to |4000| digits (only a few more allowed) with standard \TeX\ +settings.\CHANGED{1.2m} + \texttt{\string\xintDecToBin \string{\printnumber{2718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003}\string}}\endgraf\noindent\dtt{->\printnumber{\xintDecToBin{2718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003}}} \subsection{\csbh{xintHexToDec}}\label{xintHexToDec} Converts from hexadecimal to decimal.\etype{f} +Input limited to about |5500| hexadecimal digits with standard \TeX\ +settings.\CHANGED{1.2m} + \texttt{\string\xintHexToDec \string{\printnumber{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}\string}}\endgraf\noindent \dtt{->\printnumber{\xintHexToDec{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}}} @@ -13303,6 +13402,9 @@ Converts from hexadecimal to decimal.\etype{f} Converts from binary to decimal.\etype{f} +Input limited to about |19950| binary digits with standard \TeX\ +settings.\CHANGED{1.2m} + \texttt{\string\xintBinToDec \string{\printnumber{100011010100100111001011111000110011010010100100110101001011100000101000111110111110100001010100000010111100100010100111000111110000010110001011111000100000110110001000111000100100010111010111011110010101101010111011000001011101100111000110100100111001011110100011011011100111001000110110001100000001100101001001101101011111100110111110110101100100100011000100000010100110001100011}\string}}\endgraf\noindent \dtt{->\printnumber{\xintBinToDec{100011010100100111001011111000110011010010100100110101001011100000101000111110111110100001010100000010111100100010100111000111110000010110001011111000100000110110001000111000100100010111010111011110010101101010111011000001011101100111000110100100111001011110100011011011100111001000110110001100000001100101001001101101011111100110111110110101100100100011000100000010100110001100011}}} @@ -13311,13 +13413,20 @@ Converts from binary to decimal.\etype{f} Converts from binary to hexadecimal.\etype{f} +Input limited to about |13300| binary digits with standard \TeX\ +settings.\CHANGED{1.2m} + \texttt{\string\xintBinToHex \string{\printnumber{100011010100100111001011111000110011010010100100110101001011100000101000111110111110100001010100000010111100100010100111000111110000010110001011111000100000110110001000111000100100010111010111011110010101101010111011000001011101100111000110100100111001011110100011011011100111001000110110001100000001100101001001101101011111100110111110110101100100100011000100000010100110001100011}\string}}\endgraf\noindent \dtt{->\printnumber{\xintBinToHex{100011010100100111001011111000110011010010100100110101001011100000101000111110111110100001010100000010111100100010100111000111110000010110001011111000100000110110001000111000100100010111010111011110010101101010111011000001011101100111000110100100111001011110100011011011100111001000110110001100000001100101001001101101011111100110111110110101100100100011000100000010100110001100011}}} \subsection{\csbh{xintHexToBin}}\label{xintHexToBin} -Converts from hexadecimal to binary.\etype{f} +Converts from hexadecimal to binary. Up to three leading zeroes of the output +are trimmed.\etype{f} + +Input limited to about |4950| hexadecimal digits with standard \TeX\ +settings.\CHANGED{1.2m} \texttt{\string\xintHexToBin \string{\printnumber{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}\string}}\endgraf\noindent @@ -13325,8 +13434,12 @@ Converts from hexadecimal to binary.\etype{f} \subsection{\csbh{xintCHexToBin}}\label{xintCHexToBin} -Also converts from hexadecimal to binary.\etype{f} Faster on inputs with at -least one hundred hexadecimal digits. +Converts from hexadecimal to binary.\etype{f} Same as \csbxint{HexToBin}, but +an input with |N| hexadecimal digits will give an output with exactly |4N| +binary digits, leading zeroes are not trimmed.\CHANGED{1.2m} + +Input limited to about |4950| hexadecimal digits with standard \TeX\ +settings. \texttt{\string\xintCHexToBin \string{\printnumber{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}\string}}\endgraf\noindent @@ -13490,7 +13603,7 @@ stage not immediately. \subsection{\csbh{xintSeries}}\label{xintSeries} \csa{xintSeries}|{A}{B}{\coeff}|\etype{\numx\numx\Ff} computes -$\sum_{\text{|n=A|}}^{\text{|n=B|}}|\coeff{n}|$. The initial and final indices +$\sum_{\text{|n=A|}}^{\text{|n=B|}}$|\coeff{n}|. The initial and final indices must obey the |\numexpr| constraint of expanding to numbers at most |2^31-1|. The |\coeff| macro must be a one-parameter \fexpan dable macro, taking on input an explicit number |n| and producing some number or fraction |\coeff{n}|; @@ -13623,7 +13736,7 @@ and that the sum of rounded terms fared a bit better. \noindent \csa{xintRationalSeries}|{A}{B}{f}{\ratio}|\etype{\numx\numx\Ff\Ff} -evaluates $\sum_{\text{|n=A|}}^{\text{|n=B|}}|F(n)|$, where |F(n)| is specified +evaluates $\sum_{\text{|n=A|}}^{\text{|n=B|}}$|F(n)|, where |F(n)| is specified indirectly via the data of |f=F(A)| and the one-parameter macro |\ratio| which must be such that |\macro{n}| expands to |F(n)/F(n-1)|. The name indicates that \csa{xintRationalSeries} was designed to be useful in the cases where @@ -13836,7 +13949,7 @@ needs a general calculus of special functions. This is why the package \csa{xintPowerSeries}|{A}{B}{\coeff}{f}|\etype{\numx\numx\Ff\Ff} evaluates the sum -$\sum_{\text{|n=A|}}^{\text{|n=B|}}|\coeff{n}|\cdot |f|^{\text{|n|}}$. The +$\sum_{\text{|n=A|}}^{\text{|n=B|}}$|\coeff{n}|${}\cdot |f|^{\text{|n|}}$. The initial and final indices are given to a |\numexpr| expression. The |\coeff| macro (which, as argument to \csa{xintPowerSeries} is expanded only at the time |\coeff{n}| is needed) should be defined as a one-parameter expandable macro, @@ -13940,7 +14053,7 @@ an expanding only context, doing |\edef\g{\f}| is no option, then \csa{xintFxPtPowerSeries}|{A}{B}{\coeff}{f}{D}|\etype{\numx\numx} computes -$\sum_{\text{|n=A|}}^{\text{|n=B|}}|\coeff{n}|\cdot |f|^{\,\text{|n|}}$ with each +$\sum_{\text{|n=A|}}^{\text{|n=B|}}$|\coeff{n}|${}\cdot |f|^{\,\text{|n|}}$ with each term of the series truncated to |D| digits\etype{\Ff\Ff\numx} after the decimal point. As usual, |A| and |B| are completely expanded through their inclusion in a @@ -14092,7 +14205,7 @@ release. \noindent\csa{xintFloatPowerSeries}|[P]{A}{B}{\coeff}{f}|% \ntype{{\upshape[\numx]}\numx\numx} computes -$\sum_{\text{|n=A|}}^{\text{|n=B|}}|\coeff{n}|\cdot |f|^{\,\text{|n|}}$ +$\sum_{\text{|n=A|}}^{\text{|n=B|}}$|\coeff{n}|${}\cdot |f|^{\,\text{|n|}}$ with a floating point precision given by the optional parameter |P| or by the current setting of |\xintDigits|.\etype{\Ff\Ff} @@ -15221,10 +15334,18 @@ $1$ or $-1$. % This is \expandafter|\xintbndlversion| of \expandafter|\xintbndldate|. % % \begin{itemize} +% \item Release |1.2m| of |2017/07/31| has rewritten entirely the +% \xintbinhexnameimp module. The new routines (in the style of the |1.2| +% from \xintcorenameimp) are faster (depending on the macro |1.5x--2.5x| +% faster at |100| digits, |5x--9x| times faster at |1000| digits) but they +% limit the maximal size of the inputs to a few thousand characters, from +% 4000 to about 19900 depending on the macro. The |1.08| routines could +% handle (slowly) tens of thousands of digits. +% % \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. +% |\xintiiCmp| got a rewrite. It should certainly use |\pdfstrcmp| for +% dramatic speed-up 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 @@ -15451,7 +15572,7 @@ $1$ or $-1$. \fi \XINT_providespackage \ProvidesPackage {xintkernel}% - [2017/07/26 1.2l Paraphernalia for the xint packages (JFB)]% + [2017/07/31 1.2m Paraphernalia for the xint packages (JFB)]% % \end{macrocode} % \subsection{Constants} % \begin{macrocode} @@ -16037,7 +16158,7 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xinttools}% - [2017/07/26 1.2l Expandable and non-expandable utilities (JFB)]% + [2017/07/31 1.2m 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.| @@ -17941,7 +18062,7 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xintcore}% - [2017/07/26 1.2l Expandable arithmetic on big integers (JFB)]% + [2017/07/31 1.2m 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 @@ -18543,11 +18664,15 @@ $1$ or $-1$. % \subsection{\csh{XINT_unsep_loop}} % % \lverb|This is used as -%( \the\numexpr0\XINT_unsep_loop (blocks of 1<8d>!)% +%( \the\numexpr0\XINT_unsep_loop (blocks of 1<8digits>!)% %: \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. +% It removes the 1's and !'s, and outputs the 8N digits with a 0 token as +% as prefix which will have to be cleaned out by caller. +% +% Actually it does not matter whether the blocks contain really 8 digits, all +% that matters is that they have 1 as first digit (and at most 9 digits after +% that to obey the TeX-\numexpr bound). % % 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. @@ -18571,6 +18696,33 @@ $1$ or $-1$. }% \def\XINT_unsep_clean 1{\relax}% % \end{macrocode} +% \subsection{\csh{XINT_unsepb_loop}} +% +% \lverb|This is used as +%( \the\numexpr0\XINT_unsepb_loop (blocks of digits with ! as separator)% +%: \xint_bye!2!3!4!5!6!7!8!9!\xint_bye\xint_c_i\relax +%) +% It removes the !'s and outputs the digits (being careful not to suppress +% leading zeroes) with a 0 prefix to remove later. Each block is allowed up to +% nine digits. +% +% This is the same as \XINT_unsep_loop except that the digits blocks have no +% 1-prefix. Used by \xintHexToDec of 1.2m.| +% \begin{macrocode} +\def\XINT_unsepb_loop #1!#2!#3!#4!#5!#6!#7!#8!#9!% +{% + \expandafter\XINT_unsep_clean + \the\numexpr 1#1\expandafter\XINT_unsep_clean + \the\numexpr 1#2\expandafter\XINT_unsep_clean + \the\numexpr 1#3\expandafter\XINT_unsep_clean + \the\numexpr 1#4\expandafter\XINT_unsep_clean + \the\numexpr 1#5\expandafter\XINT_unsep_clean + \the\numexpr 1#6\expandafter\XINT_unsep_clean + \the\numexpr 1#7\expandafter\XINT_unsep_clean + \the\numexpr 1#8\expandafter\XINT_unsep_clean + \the\numexpr 1#9\XINT_unsepb_loop +}% +% \end{macrocode} % \subsection{\csh{XINT_unsep_cuzsmall}} % % \lverb|This is used as @@ -18661,6 +18813,21 @@ $1$ or $-1$. \expandafter#1\xint_gob_til_one ##2##3##4##5##6##7##8% }}\XINT_zeroes_forviii_end{ }% % \end{macrocode} +% \subsection{\csh{XINT_zeroes_foriv}} +% \lverb|& +%( \romannumeral0\XINT_zeroes_foriv #1\R{0\R}{00\R}{000\R}% +%: \R{0\R}{00\R}{000\R}\R\W +%) +% Helper macro needed by 1.2m \xintHexToDec of xintbinhex.| +% \begin{macrocode} +\def\XINT_zeroes_foriv #1#2#3#4#5#6#7#8% +{% + \xint_gob_til_R #8\XINT_zeroes_foriv_end\R\XINT_zeroes_foriv +}% +\def\XINT_zeroes_foriv_end\R\XINT_zeroes_foriv #1#2\W + {\XINT_zeroes_foriv_done #1}% +\def\XINT_zeroes_foriv_done #1\R{ #1}% +% \end{macrocode} % \subsection{\csh{XINT_sepbyviii_Z}} % % \lverb|This is used as @@ -21227,7 +21394,7 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xint}% - [2017/07/26 1.2l Expandable operations on big integers (JFB)]% + [2017/07/31 1.2m Expandable operations on big integers (JFB)]% % \end{macrocode} % \subsection{More token management} % \begin{macrocode} @@ -21685,8 +21852,12 @@ $1$ or $-1$. % \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.| +% attention compare les **valeurs absolues** +% +% 1.2l made \xintiiGeq robust against non terminated items. +% +% 1.2l rewrote \xintiiCmp, but forgot to handle \xintiiGeq too. Done at 1.2m. +% | % \begin{macrocode} \def\xintGeq {\romannumeral0\xintgeq }% \def\xintgeq #1{\expandafter\XINT_geq\romannumeral0\xintnum{#1}\xint:}% @@ -21696,8 +21867,6 @@ $1$ or $-1$. {% \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\xint:#3% {% \expandafter\XINT_geq_fork\expandafter #1\romannumeral0\xintnum{#3}\xint:#2\xint: @@ -21721,198 +21890,98 @@ $1$ or $-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\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_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\xint:#2\X #3\xint: -{% - \expandafter\XINT_geq_checklengths - \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_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\xint:#2\xint: -{% - \ifnum #1=#2 - \expandafter\xint_firstoftwo - \else - \expandafter\xint_secondoftwo - \fi - \XINT_geq_aa {\XINT_geq_distinctlengths {#1}{#2}}% -}% -\def\XINT_geq_distinctlengths #1#2#3\W #4\W -{% - \ifnum #1>#2 - \expandafter\xint_firstoftwo - \else - \expandafter\xint_secondoftwo - \fi - { 1}{ 0}% -}% -\def\XINT_geq_aa {\expandafter\XINT_geq_w\the\numexpr\XINT_geq_a \xint_c_i }% -\def\XINT_geq_a #1!#2!#3!#4!#5\W #6!#7!#8!#9!% -{% - \XINT_geq_b #1!#6!#2!#7!#3!#8!#4!#9!#5\W -}% -\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\xint:% -}% -\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\xint:% -}% -\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\xint:% -}% -\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\xint:% -}% -\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\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\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\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\xint:#4\W -{% - \XINT_geq_k #1#2!% -}% -\def\XINT_geq_k #1#2\W -{% - \xint_UDzerofork - #1{-1\relax { 0}}% - 0{-1\relax { 1}}% - \krof -}% -\def\XINT_geq_w #1-1#2{#2}% +\def\XINT_geq_minusminus --{\XINT_geq_plusplus {}{}}% +\def\XINT_geq_plusplus + {\expandafter\XINT_geq_finish\romannumeral0\XINT_cmp_plusplus}% +\def\XINT_geq_finish #1{\if-#1\expandafter\XINT_geq_no + \else\expandafter\XINT_geq_yes\fi}% +\def\XINT_geq_no 1{ 0}% +\def\XINT_geq_yes { 1}% % \end{macrocode} % \subsection{\csh{xintiMax}, \csh{xintiiMax}} % \lverb|& -% 1.2 REMOVES \xintMax, \xintMin, \xintMaxof, \xintMinof.| +% At 1.2m, a long-standing bug was fixed: \xintiiMax had the overhead of +% applying \xintNum to its arguments due to use of a sub-macro of \xintGeq +% code to which this overhead was added at some point. +% +% And on this occasion I reduced even more number of times input is grabbed. +% | % \begin{macrocode} \def\xintiMax {\romannumeral0\xintimax }% \def\xintimax #1% {% - \expandafter\xint_max\expandafter {\romannumeral0\xintnum{#1}}% + \expandafter\xint_max\romannumeral0\xintnum{#1}\xint: }% -\def\xint_max #1#2% +\def\xint_max #1\xint:#2% {% - \expandafter\XINT_max_pre\expandafter {\romannumeral0\xintnum{#2}}{#1}% + \expandafter\XINT_max_fork\romannumeral0\xintnum{#2}\xint:#1\xint: }% \def\xintiiMax {\romannumeral0\xintiimax }% \def\xintiimax #1% {% - \expandafter\xint_iimax\expandafter {\romannumeral`&&@#1}% + \expandafter\xint_iimax \romannumeral`&&@#1\xint: }% -\def\xint_iimax #1#2% +\def\xint_iimax #1\xint:#2% {% - \expandafter\XINT_max_pre\expandafter {\romannumeral`&&@#2}{#1}% + \expandafter\XINT_max_fork\romannumeral`&&@#2\xint:#1\xint: }% -\def\XINT_max_pre #1#2{\XINT_max_fork #1\Z #2\Z {#2}{#1}}% -\def\XINT_Max #1#2{\romannumeral0\XINT_max_fork #2\Z #1\Z {#1}{#2}}% % \end{macrocode} % \lverb|& % #3#4 vient du *premier*, -% #1#2 vient du *second*| +% #1#2 vient du *second*. I have renamed the sub-macros at 1.2m because the +% terminology was quite counter-intuitive; there was no bug, but still.| % \begin{macrocode} -\def\XINT_max_fork #1#2\Z #3#4\Z +\def\XINT_max_fork #1#2\xint:#3#4\xint: {% \xint_UDsignsfork #1#3\XINT_max_minusminus % A < 0, B < 0 - #1-\XINT_max_minusplus % B < 0, A >= 0 - #3-\XINT_max_plusminus % A < 0, B >= 0 + #1-\XINT_max_plusminus % B < 0, A >= 0 + #3-\XINT_max_minusplus % A < 0, B >= 0 --{\xint_UDzerosfork #1#3\XINT_max_zerozero % A = B = 0 - #10\XINT_max_zeroplus % B = 0, A > 0 - #30\XINT_max_pluszero % A = 0, B > 0 + #10\XINT_max_pluszero % B = 0, A > 0 + #30\XINT_max_zeroplus % A = 0, B > 0 00\XINT_max_plusplus % A, B > 0 \krof }% \krof - {#2}{#4}#1#3% + #3#1#2\xint:#4\xint: + \expandafter\xint_firstoftwo_thenstop + \else + \expandafter\xint_secondoftwo_thenstop + \fi + {#3#4}{#1#2}% }% % \end{macrocode} % \lverb|& -% A = #4#2, B = #3#1| +% Refactored at 1.2m for avoiding grabbing arguments. Position of inputs +% shared with iiCmp and iiGeq code.| % \begin{macrocode} -\def\XINT_max_zerozero #1#2#3#4{\xint_firstoftwo_thenstop }% -\def\XINT_max_zeroplus #1#2#3#4{\xint_firstoftwo_thenstop }% -\def\XINT_max_pluszero #1#2#3#4{\xint_secondoftwo_thenstop }% -\def\XINT_max_minusplus #1#2#3#4{\xint_firstoftwo_thenstop }% -\def\XINT_max_plusminus #1#2#3#4{\xint_secondoftwo_thenstop }% -\def\XINT_max_plusplus #1#2#3#4% +\def\XINT_max_zerozero #1\fi{\xint_firstoftwo_thenstop }% +\def\XINT_max_zeroplus #1\fi{\xint_secondoftwo_thenstop }% +\def\XINT_max_pluszero #1\fi{\xint_firstoftwo_thenstop }% +\def\XINT_max_minusplus #1\fi{\xint_secondoftwo_thenstop }% +\def\XINT_max_plusminus #1\fi{\xint_firstoftwo_thenstop }% +\def\XINT_max_plusplus {% - \ifodd\XINT_Geq {#4#2}{#3#1} - \expandafter\xint_firstoftwo_thenstop - \else - \expandafter\xint_secondoftwo_thenstop - \fi + \if1\romannumeral0\XINT_geq_plusplus }% % \end{macrocode} -% \lverb+#3=-, #4=-, #1 = |B| = -B, #2 = |A| = -A+ +% \lverb+Premier des testés |A|=-A, second est |B|=-B. On veut le max(A,B), +% c'est donc A si |A|<|B| (ou |A|=|B|, mais peu importe alors). Donc on peut +% faire cela avec \unless. Simple.+ % \begin{macrocode} -\def\XINT_max_minusminus #1#2#3#4% +\def\XINT_max_minusminus --% {% - \ifodd\XINT_Geq {#1}{#2} - \expandafter\xint_firstoftwo_thenstop - \else - \expandafter\xint_secondoftwo_thenstop - \fi + \unless\if1\romannumeral0\XINT_geq_plusplus{}{}% }% % \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. % -% NOT compatible with empty list.| -% \lverb|1.2l made \xintiiMaxof robust against non terminated items.| +% NOT compatible with empty list. +% +% 1.2l made \xintiiMaxof robust against non terminated items.| % \begin{macrocode} \def\xintiMaxof {\romannumeral0\xintimaxof }% \def\xintimaxof #1{\expandafter\XINT_imaxof_a\romannumeral`&&@#1\xint:}% @@ -21943,75 +22012,65 @@ $1$ or $-1$. % \subsection{\csh{xintiMin}, \csh{xintiiMin}} % \lverb|\xintnum added New with 1.09a. I add \xintiiMin in 1.1 and mark as % deprecated \xintMin, renamed \xintiMin. \xintMin NOW REMOVED (1.2, as -% \xintMax, \xintMaxof), only provided by \xintfracnameimp.| +% \xintMax, \xintMaxof), only provided by \xintfracnameimp. +% +% At 1.2m, a long-standing bug was fixed: \xintiiMin had the overhead of +% applying \xintNum to its arguments due to use of a sub-macro of \xintGeq +% code to which this overhead was added at some point. +% +% And on this occasion I reduced even more number of times input is grabbed. +% | % \begin{macrocode} \def\xintiMin {\romannumeral0\xintimin }% \def\xintimin #1% {% - \expandafter\xint_min\expandafter {\romannumeral0\xintnum{#1}}% + \expandafter\xint_min\romannumeral0\xintnum{#1}\xint: }% -\def\xint_min #1#2% +\def\xint_min #1\xint:#2% {% - \expandafter\XINT_min_pre\expandafter {\romannumeral0\xintnum{#2}}{#1}% + \expandafter\XINT_min_fork\romannumeral0\xintnum{#2}\xint:#1\xint: }% \def\xintiiMin {\romannumeral0\xintiimin }% \def\xintiimin #1% {% - \expandafter\xint_iimin\expandafter {\romannumeral`&&@#1}% + \expandafter\xint_iimin \romannumeral`&&@#1\xint: }% -\def\xint_iimin #1#2% +\def\xint_iimin #1\xint:#2% {% - \expandafter\XINT_min_pre\expandafter {\romannumeral`&&@#2}{#1}% + \expandafter\XINT_min_fork\romannumeral`&&@#2\xint:#1\xint: }% -\def\XINT_min_pre #1#2{\XINT_min_fork #1\Z #2\Z {#2}{#1}}% -\def\XINT_Min #1#2{\romannumeral0\XINT_min_fork #2\Z #1\Z {#1}{#2}}% -% \end{macrocode} -% \lverb|& -% #3#4 vient du *premier*, -% #1#2 vient du *second*| -% \begin{macrocode} -\def\XINT_min_fork #1#2\Z #3#4\Z +\def\XINT_min_fork #1#2\xint:#3#4\xint: {% \xint_UDsignsfork #1#3\XINT_min_minusminus % A < 0, B < 0 - #1-\XINT_min_minusplus % B < 0, A >= 0 - #3-\XINT_min_plusminus % A < 0, B >= 0 + #1-\XINT_min_plusminus % B < 0, A >= 0 + #3-\XINT_min_minusplus % A < 0, B >= 0 --{\xint_UDzerosfork #1#3\XINT_min_zerozero % A = B = 0 - #10\XINT_min_zeroplus % B = 0, A > 0 - #30\XINT_min_pluszero % A = 0, B > 0 + #10\XINT_min_pluszero % B = 0, A > 0 + #30\XINT_min_zeroplus % A = 0, B > 0 00\XINT_min_plusplus % A, B > 0 \krof }% \krof - {#2}{#4}#1#3% -}% -% \end{macrocode} -% \lverb|& -% A = #4#2, B = #3#1| -% \begin{macrocode} -\def\XINT_min_zerozero #1#2#3#4{\xint_firstoftwo_thenstop }% -\def\XINT_min_zeroplus #1#2#3#4{\xint_secondoftwo_thenstop }% -\def\XINT_min_pluszero #1#2#3#4{\xint_firstoftwo_thenstop }% -\def\XINT_min_minusplus #1#2#3#4{\xint_secondoftwo_thenstop }% -\def\XINT_min_plusminus #1#2#3#4{\xint_firstoftwo_thenstop }% -\def\XINT_min_plusplus #1#2#3#4% -{% - \ifodd\XINT_Geq {#4#2}{#3#1} + #3#1#2\xint:#4\xint: \expandafter\xint_secondoftwo_thenstop \else \expandafter\xint_firstoftwo_thenstop \fi + {#3#4}{#1#2}% }% -% \end{macrocode} -% \lverb+#3=-, #4=-, #1 = |B| = -B, #2 = |A| = -A+ -% \begin{macrocode} -\def\XINT_min_minusminus #1#2#3#4% +\def\XINT_min_zerozero #1\fi{\xint_firstoftwo_thenstop }% +\def\XINT_min_zeroplus #1\fi{\xint_firstoftwo_thenstop }% +\def\XINT_min_pluszero #1\fi{\xint_secondoftwo_thenstop }% +\def\XINT_min_minusplus #1\fi{\xint_firstoftwo_thenstop }% +\def\XINT_min_plusminus #1\fi{\xint_secondoftwo_thenstop }% +\def\XINT_min_plusplus {% - \ifodd\XINT_Geq {#1}{#2} - \expandafter\xint_secondoftwo_thenstop - \else - \expandafter\xint_firstoftwo_thenstop - \fi + \if1\romannumeral0\XINT_geq_plusplus +}% +\def\XINT_min_minusminus --% +{% + \unless\if1\romannumeral0\XINT_geq_plusplus{}{}% }% % \end{macrocode} % \subsection{\csh{xintiMinof}, \csh{xintiiMinof}} @@ -23290,6 +23349,9 @@ $1$ or $-1$. % % The commenting is currently (\xintdocdate) very sparse. % +% The macros from |1.08| (|2013/06/07|) remained unchanged +% until their complete rewrite at |1.2m| (|2017/07/31|). +% % \subsection{Catcodes, \protect\eTeX{} and reload detection} % % The code for reload detection was initially copied from \textsc{Heiko @@ -23347,20 +23409,9 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xintbinhex}% - [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{ }% + [2017/07/31 1.2m Expandable binary and hexadecimal conversions (JFB)]% % \end{macrocode} % \subsection{Constants, etc...} -% \lverb!1.08! % \begin{macrocode} \newcount\xint_c_ii^xv \xint_c_ii^xv 32768 \newcount\xint_c_ii^xvi \xint_c_ii^xvi 65536 @@ -23368,59 +23419,40 @@ $1$ or $-1$. \def\XINT_tmpa #1{\ifx\relax#1\else \expandafter\edef\csname XINT_sdth_#1\endcsname {\ifcase #1 0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or - 8\or 9\or A\or B\or C\or D\or E\or F\fi}% + 8\or 9\or A\or B\or C\or D\or E\or F\else\space\fi}% \expandafter\XINT_tmpa\fi }% -\XINT_tmpa {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}\relax +\XINT_tmpa {-1}{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}\relax \def\XINT_tmpa #1{\ifx\relax#1\else \expandafter\edef\csname XINT_sdtb_#1\endcsname {\ifcase #1 0000\or 0001\or 0010\or 0011\or 0100\or 0101\or 0110\or 0111\or - 1000\or 1001\or 1010\or 1011\or 1100\or 1101\or 1110\or 1111\fi}% + 1000\or 1001\or 1010\or 1011\or 1100\or 1101\or 1110\or 1111\else\space\fi}% \expandafter\XINT_tmpa\fi }% -\XINT_tmpa {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}\relax +\XINT_tmpa {-1}{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}\relax \let\XINT_tmpa\relax -\expandafter\def\csname XINT_sbtd_0000\endcsname {0}% -\expandafter\def\csname XINT_sbtd_0001\endcsname {1}% -\expandafter\def\csname XINT_sbtd_0010\endcsname {2}% -\expandafter\def\csname XINT_sbtd_0011\endcsname {3}% -\expandafter\def\csname XINT_sbtd_0100\endcsname {4}% -\expandafter\def\csname XINT_sbtd_0101\endcsname {5}% -\expandafter\def\csname XINT_sbtd_0110\endcsname {6}% -\expandafter\def\csname XINT_sbtd_0111\endcsname {7}% -\expandafter\def\csname XINT_sbtd_1000\endcsname {8}% -\expandafter\def\csname XINT_sbtd_1001\endcsname {9}% -\expandafter\def\csname XINT_sbtd_1010\endcsname {10}% -\expandafter\def\csname XINT_sbtd_1011\endcsname {11}% -\expandafter\def\csname XINT_sbtd_1100\endcsname {12}% -\expandafter\def\csname XINT_sbtd_1101\endcsname {13}% -\expandafter\def\csname XINT_sbtd_1110\endcsname {14}% -\expandafter\def\csname XINT_sbtd_1111\endcsname {15}% -\expandafter\let\csname XINT_sbth_0000\expandafter\endcsname - \csname XINT_sbtd_0000\endcsname -\expandafter\let\csname XINT_sbth_0001\expandafter\endcsname - \csname XINT_sbtd_0001\endcsname -\expandafter\let\csname XINT_sbth_0010\expandafter\endcsname - \csname XINT_sbtd_0010\endcsname -\expandafter\let\csname XINT_sbth_0011\expandafter\endcsname - \csname XINT_sbtd_0011\endcsname -\expandafter\let\csname XINT_sbth_0100\expandafter\endcsname - \csname XINT_sbtd_0100\endcsname -\expandafter\let\csname XINT_sbth_0101\expandafter\endcsname - \csname XINT_sbtd_0101\endcsname -\expandafter\let\csname XINT_sbth_0110\expandafter\endcsname - \csname XINT_sbtd_0110\endcsname -\expandafter\let\csname XINT_sbth_0111\expandafter\endcsname - \csname XINT_sbtd_0111\endcsname -\expandafter\let\csname XINT_sbth_1000\expandafter\endcsname - \csname XINT_sbtd_1000\endcsname -\expandafter\let\csname XINT_sbth_1001\expandafter\endcsname - \csname XINT_sbtd_1001\endcsname +\expandafter\def\csname XINT_sbth_0000\endcsname {0}% +\expandafter\def\csname XINT_sbth_0001\endcsname {1}% +\expandafter\def\csname XINT_sbth_0010\endcsname {2}% +\expandafter\def\csname XINT_sbth_0011\endcsname {3}% +\expandafter\def\csname XINT_sbth_0100\endcsname {4}% +\expandafter\def\csname XINT_sbth_0101\endcsname {5}% +\expandafter\def\csname XINT_sbth_0110\endcsname {6}% +\expandafter\def\csname XINT_sbth_0111\endcsname {7}% +\expandafter\def\csname XINT_sbth_1000\endcsname {8}% +\expandafter\def\csname XINT_sbth_1001\endcsname {9}% +\expandafter\def\csname XINT_sbth_1010\endcsname {10}% +\expandafter\def\csname XINT_sbth_1011\endcsname {11}% +\expandafter\def\csname XINT_sbth_1100\endcsname {12}% +\expandafter\def\csname XINT_sbth_1101\endcsname {13}% +\expandafter\def\csname XINT_sbth_1110\endcsname {14}% +\expandafter\def\csname XINT_sbth_1111\endcsname {15}% \expandafter\def\csname XINT_sbth_1010\endcsname {A}% \expandafter\def\csname XINT_sbth_1011\endcsname {B}% \expandafter\def\csname XINT_sbth_1100\endcsname {C}% \expandafter\def\csname XINT_sbth_1101\endcsname {D}% \expandafter\def\csname XINT_sbth_1110\endcsname {E}% \expandafter\def\csname XINT_sbth_1111\endcsname {F}% +\let\XINT_sbth_none \empty \expandafter\def\csname XINT_shtb_0\endcsname {0000}% \expandafter\def\csname XINT_shtb_1\endcsname {0001}% \expandafter\def\csname XINT_shtb_2\endcsname {0010}% @@ -23437,545 +23469,573 @@ $1$ or $-1$. \def\XINT_shtb_D {1101}% \def\XINT_shtb_E {1110}% \def\XINT_shtb_F {1111}% -\def\XINT_shtb_G {}% -\def\XINT_smallhex #1% +\let\XINT_shtb_none \empty +\def\XINT_smallhex #1!% {% - \expandafter\XINT_smallhex_a\expandafter - {\the\numexpr (#1+\xint_c_viii)/\xint_c_xvi-\xint_c_i}{#1}% + \expandafter\XINT_smallhex_a + \the\numexpr (#1+\xint_c_viii)/\xint_c_xvi-\xint_c_i\xint:#1\xint: }% -\def\XINT_smallhex_a #1#2% +\def\XINT_smallhex_a #1\xint:#2\xint: {% \csname XINT_sdth_#1\expandafter\expandafter\expandafter\endcsname - \csname XINT_sdth_\the\numexpr #2-\xint_c_xvi*#1\endcsname + \csname XINT_sdth_\the\numexpr #2-\xint_c_xvi*#1\relax\expandafter\endcsname + \romannumeral`&&@% }% -\def\XINT_smallbin #1% +\def\XINT_smallbin #1!% {% - \expandafter\XINT_smallbin_a\expandafter - {\the\numexpr (#1+\xint_c_viii)/\xint_c_xvi-\xint_c_i}{#1}% + \expandafter\XINT_smallbin_a + \the\numexpr (#1+\xint_c_viii)/\xint_c_xvi-\xint_c_i\xint:#1\xint: }% -\def\XINT_smallbin_a #1#2% +\def\XINT_smallbin_a #1\xint:#2\xint: {% \csname XINT_sdtb_#1\expandafter\expandafter\expandafter\endcsname - \csname XINT_sdtb_\the\numexpr #2-\xint_c_xvi*#1\endcsname + \csname XINT_sdtb_\the\numexpr #2-\xint_c_xvi*#1\relax\expandafter\endcsname + \romannumeral`&&@% }% % \end{macrocode} -% \subsection{\csh{XINT_OQ}} -% \lverb|Moved with release 1.2 from xintcore 1.1 as it is used only here. -% Will be probably suppressed once I review the code of xintbinhex.| -% \begin{macrocode} -\def\XINT_OQ #1#2#3#4#5#6#7#8#9% -{% - \xint_gob_til_R #9\XINT_OQ_end_a\R\XINT_OQ {#9#8#7#6#5#4#3#2#1}% -}% -\def\XINT_OQ_end_a\R\XINT_OQ #1#2\Z -{% - \XINT_OQ_end_b #1\Z -}% -\def\XINT_OQ_end_b #1#2#3#4#5#6#7#8% -{% - \xint_gob_til_R - #8\XINT_OQ_end_viii - #7\XINT_OQ_end_vii - #6\XINT_OQ_end_vi - #5\XINT_OQ_end_v - #4\XINT_OQ_end_iv - #3\XINT_OQ_end_iii - #2\XINT_OQ_end_ii - \R\XINT_OQ_end_i - \Z #2#3#4#5#6#7#8% -}% -\def\XINT_OQ_end_viii #1\Z #2#3#4#5#6#7#8#9\Z { #9}% -\def\XINT_OQ_end_vii #1\Z #2#3#4#5#6#7#8#9\Z { #8#90000000}% -\def\XINT_OQ_end_vi #1\Z #2#3#4#5#6#7#8#9\Z { #7#8#9000000}% -\def\XINT_OQ_end_v #1\Z #2#3#4#5#6#7#8#9\Z { #6#7#8#900000}% -\def\XINT_OQ_end_iv #1\Z #2#3#4#5#6#7#8#9\Z { #5#6#7#8#90000}% -\def\XINT_OQ_end_iii #1\Z #2#3#4#5#6#7#8#9\Z { #4#5#6#7#8#9000}% -\def\XINT_OQ_end_ii #1\Z #2#3#4#5#6#7#8#9\Z { #3#4#5#6#7#8#900}% -\def\XINT_OQ_end_i \Z #1#2#3#4#5#6#7#8\Z { #1#2#3#4#5#6#7#80}% -% \end{macrocode} -% \subsection{\csh{xintDecToHex}, \csh{xintDecToBin}} -% \lverb!1.08! +% \subsection{\csh{xintDecToHex}} +% \lverb|Complete rewrite at 1.2m in the 1.2 style. +% +% Faster but currently limited at about 4007 decimal digits on input +% [expansion depth=10000]. +% +% 1.2m version robust against non terminated inputs. +% +% An input without leading zeroes gives an output without leading zeroes.| % \begin{macrocode} \def\xintDecToHex {\romannumeral0\xintdectohex }% \def\xintdectohex #1% - {\expandafter\XINT_dth_checkin\romannumeral`&&@#1\W\W\W\W \T}% +{% + \expandafter\XINT_dth_checkin\romannumeral`&&@#1\xint: +}% \def\XINT_dth_checkin #1% {% \xint_UDsignfork - #1\XINT_dth_N - -{\XINT_dth_P #1}% + #1\XINT_dth_neg + -{\XINT_dth_main #1}% \krof }% -\def\XINT_dth_N {\expandafter-\romannumeral0\XINT_dth_P }% -\def\XINT_dth_P {\expandafter\XINT_dth_III\romannumeral`&&@\XINT_dtbh_I {0.}}% -\def\xintDecToBin {\romannumeral0\xintdectobin }% -\def\xintdectobin #1% - {\expandafter\XINT_dtb_checkin\romannumeral`&&@#1\W\W\W\W \T }% -\def\XINT_dtb_checkin #1% +\def\XINT_dth_neg {\expandafter-\romannumeral0\XINT_dth_main}% +\def\XINT_dth_main #1\xint: {% - \xint_UDsignfork - #1\XINT_dtb_N - -{\XINT_dtb_P #1}% - \krof + \expandafter\XINT_dth_start + \romannumeral0\XINT_zeroes_foriv + #1\R{0\R}{00\R}{000\R}\R{0\R}{00\R}{000\R}\R\W + #1\xint_bye\xint_bye\XINT_dthb_final_a!2!3!4!5!6!7!8!9!\W }% -\def\XINT_dtb_N {\expandafter-\romannumeral0\XINT_dtb_P }% -\def\XINT_dtb_P {\expandafter\XINT_dtb_III\romannumeral`&&@\XINT_dtbh_I {0.}}% -\def\XINT_dtbh_I #1#2#3#4#5% +\def\XINT_dth_start #1#2#3#4#5% {% - \xint_gob_til_W #5\XINT_dtbh_II_a\W\XINT_dtbh_I_a {}{#2#3#4#5}#1\Z.% + \xint_bye#5\XINT_dth_small\xint_bye + \XINT_dth_start_a #1#2#3#4#5% }% -\def\XINT_dtbh_II_a\W\XINT_dtbh_I_a #1#2{\XINT_dtbh_II_b #2}% -\def\XINT_dtbh_II_b #1#2#3#4% +\def\XINT_dth_start_a #1#2#3#4#5% {% - \xint_gob_til_W - #1\XINT_dtbh_II_c - #2\XINT_dtbh_II_ci - #3\XINT_dtbh_II_cii - \W\XINT_dtbh_II_ciii #1#2#3#4% + \expandafter\XINT_dth_A\the\numexpr\XINT_dth_a + #1#2#3#4\XINT_dth_nextfour!2!3!4!5!6!7!8!9!\Z #5% }% -\def\XINT_dtbh_II_c \W\XINT_dtbh_II_ci - \W\XINT_dtbh_II_cii - \W\XINT_dtbh_II_ciii \W\W\W\W {{}}% -\def\XINT_dtbh_II_ci #1\XINT_dtbh_II_ciii #2\W\W\W - {\XINT_dtbh_II_d {}{#2}{0}}% -\def\XINT_dtbh_II_cii\W\XINT_dtbh_II_ciii #1#2\W\W - {\XINT_dtbh_II_d {}{#1#2}{00}}% -\def\XINT_dtbh_II_ciii #1#2#3\W - {\XINT_dtbh_II_d {}{#1#2#3}{000}}% -\def\XINT_dtbh_I_a #1#2#3.% +\def\XINT_dth_small\xint_bye\XINT_dth_start_a #1\xint_bye #2\W {% - \xint_gob_til_Z #3\XINT_dtbh_I_z\Z - \expandafter\XINT_dtbh_I_b\the\numexpr #2+#30000.{#1}% + \expandafter\XINT_dth_B_finish + \romannumeral`&&@\XINT_tofourhex#1!\space }% -\def\XINT_dtbh_I_b #1.% +\def\XINT_dth_a #1!#2!#3!#4!#5!#6!#7!#8!#9!% {% - \expandafter\XINT_dtbh_I_c\the\numexpr - (#1+\xint_c_ii^xv)/\xint_c_ii^xvi-\xint_c_i.#1.% + \expandafter\XINT_dth_update + \the\numexpr #1\expandafter\XINT_dth_update + \the\numexpr #2\expandafter\XINT_dth_update + \the\numexpr #3\expandafter\XINT_dth_update + \the\numexpr #4\expandafter\XINT_dth_update + \the\numexpr #5\expandafter\XINT_dth_update + \the\numexpr #6\expandafter\XINT_dth_update + \the\numexpr #7\expandafter\XINT_dth_update + \the\numexpr #8\expandafter\XINT_dth_update + \the\numexpr #9\XINT_dth_a +}% +\def\XINT_dth_nextfour #1\Z #2#3#4#5% +{% + #2#3#4#5!\relax\XINT_dth_nextfour!2!3!4!5!6!7!8!9!\Z }% -\def\XINT_dtbh_I_c #1.#2.% +\def\XINT_dth_update #1!% {% - \expandafter\XINT_dtbh_I_d\expandafter - {\the\numexpr #2-\xint_c_ii^xvi*#1}{#1}% + \expandafter\XINT_dth_update_a + \the\numexpr (#1+\xint_c_ii^xv)/\xint_c_ii^xvi-\xint_c_i\xint: + #1\xint:% }% -\def\XINT_dtbh_I_d #1#2#3{\XINT_dtbh_I_a {#3#1.}{#2}}% -\def\XINT_dtbh_I_z\Z\expandafter\XINT_dtbh_I_b\the\numexpr #1+#2.% +\def\XINT_dth_update_a #1\xint:#2\xint: {% - \ifnum #1=\xint_c_ \expandafter\XINT_dtbh_I_end_zb\fi - \XINT_dtbh_I_end_za {#1}% + 0000+#1\expandafter!\expandafter!\the\numexpr#2-#1*\xint_c_ii^xvi }% -\def\XINT_dtbh_I_end_za #1#2{\XINT_dtbh_I {#2#1.}}% -\def\XINT_dtbh_I_end_zb\XINT_dtbh_I_end_za #1#2{\XINT_dtbh_I {#2}}% -\def\XINT_dtbh_II_d #1#2#3#4.% +\def\XINT_dth_A #1!!% {% - \xint_gob_til_Z #4\XINT_dtbh_II_z\Z - \expandafter\XINT_dtbh_II_e\the\numexpr #2+#4#3.{#1}{#3}% + \ifnum #1>\xint_c_ \xint_dothis{\XINT_dth_again #1!}\fi + \xint_orthat{\XINT_dth_again}% }% -\def\XINT_dtbh_II_e #1.% +\def\XINT_dth_again #1\Z #2% {% - \expandafter\XINT_dtbh_II_f\the\numexpr - (#1+\xint_c_ii^xv)/\xint_c_ii^xvi-\xint_c_i.#1.% + \xint_bye #2\XINT_dth_B_a\xint_bye + \expandafter\XINT_dth_A\the\numexpr\XINT_dth_a #1\Z #2% }% -\def\XINT_dtbh_II_f #1.#2.% +\def\XINT_dth_B_a\xint_bye + \expandafter\XINT_dth_A\the\numexpr\XINT_dth_a #1\XINT_dth_nextfour #2\Z {% - \expandafter\XINT_dtbh_II_g\expandafter - {\the\numexpr #2-\xint_c_ii^xvi*#1}{#1}% + \expandafter\XINT_dth_B_finish\romannumeral`&&@\XINT_dth_B_c #1!% }% -\def\XINT_dtbh_II_g #1#2#3{\XINT_dtbh_II_d {#3#1.}{#2}}% -\def\XINT_dtbh_II_z\Z\expandafter\XINT_dtbh_II_e\the\numexpr #1+#2.% +\def\XINT_dth_B_c #1!#2!#3!#4!#5!#6!#7!#8!#9!% {% - \ifnum #1=\xint_c_ \expandafter\XINT_dtbh_II_end_zb\fi - \XINT_dtbh_II_end_za {#1}% + \XINT_tofourhex#1!% + \XINT_tofourhex#2!% + \XINT_tofourhex#3!% + \XINT_tofourhex#4!% + \XINT_tofourhex#5!% + \XINT_tofourhex#6!% + \XINT_tofourhex#7!% + \XINT_tofourhex#8!% + \XINT_tofourhex#9!% + \XINT_dth_B_c }% -\def\XINT_dtbh_II_end_za #1#2#3{{}#2#1.\Z.}% -\def\XINT_dtbh_II_end_zb\XINT_dtbh_II_end_za #1#2#3{{}#2\Z.}% -\def\XINT_dth_III #1#2.% +% attention ici mon #1 compte pour 4 chiffres hexa +\def\XINT_tofourhex #1!% {% - \xint_gob_til_Z #2\XINT_dth_end\Z - \expandafter\XINT_dth_III\expandafter - {\romannumeral`&&@\XINT_dth_small #2.#1}% + \expandafter\XINT_tofourhex_a + \the\numexpr (#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i\xint: #1\xint: }% -\def\XINT_dth_small #1.% +\def\XINT_tofourhex_a #1\xint: #2\xint: {% - \expandafter\XINT_smallhex\expandafter - {\the\numexpr (#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i\expandafter}% - \romannumeral`&&@\expandafter\XINT_smallhex\expandafter - {\the\numexpr - #1-((#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i)*\xint_c_ii^viii}% + \expandafter\XINT_tofourhex_b + \the\numexpr #2-\xint_c_ii^viii*#1\xint:#1\xint: }% -\def\XINT_dth_end\Z\expandafter\XINT_dth_III\expandafter #1#2\T +\def\XINT_tofourhex_b #1\xint: #2\xint: +{% + \XINT_smallhex #2!% + \XINT_smallhex #1!% +}% +\def\XINT_dthb_final_a #1\W{1)\relax \xint:\XINT_dthb_final_b\xint:\W}% +\def\XINT_dthb_final_b #1\W{1\relax \xint:\XINT_dthb_final_c\xint:\W}% +\def\XINT_dthb_final_c #1\W{-1)\relax \XINT_dthb_final_d\xint:\xint:\W}% +\def\XINT_dthb_final_d #1\W{\endcsname}% +% \end{macrocode} +% \lverb|We only clean-up up to 3 zero hexadecimal digits, as output was +% produced in chunks of 4 hex digits. If input had no leading zero, output +% will have none either. If input had many leading zeroes, output will have +% some number (unspecified, but a recipe can be given...) of leading zeroes... +% +% The coding is for varying a bit, I did not check if efficient, it does not +% matter.| +% \begin{macrocode} +\def\XINT_dth_B_finish #1#2#3% {% - \XINT_dth_end_b #1% + \unless\if#10\xint_dothis{ #1#2#3}\fi + \unless\if#20\xint_dothis{ #2#3}\fi + \unless\if#30\xint_dothis{ #3}\fi + \xint_orthat{ }% }% -\def\XINT_dth_end_b #1.{\XINT_dth_end_c }% -\def\XINT_dth_end_c #1{\xint_gob_til_zero #1\XINT_dth_end_d 0\space #1}% -\def\XINT_dth_end_d 0\space 0#1% +% \end{macrocode} +% \subsection{\csh{xintDecToBin}} +% \lverb|Complete rewrite at 1.2m in the 1.2 style. +% +% Much faster but currently limited at about 4007 decimal digits on input +% [expansion depth=10000] +% +% 1.2m version robust against non terminated inputs. +% +% An input without leading zeroes gives an output without leading zeroes. +% | +% \begin{macrocode} +\def\xintDecToBin {\romannumeral0\xintdectobin }% +\def\xintdectobin #1% {% - \xint_gob_til_zero #1\XINT_dth_end_e 0\space #1% + \expandafter\XINT_dtb_checkin\romannumeral`&&@#1\xint: }% -\def\XINT_dth_end_e 0\space 0#1% +\def\XINT_dtb_checkin #1% {% - \xint_gob_til_zero #1\XINT_dth_end_f 0\space #1% + \xint_UDsignfork + #1\XINT_dtb_neg + -{\XINT_dtb_main #1}% + \krof }% -\def\XINT_dth_end_f 0\space 0{ }% -\def\XINT_dtb_III #1#2.% +\def\XINT_dtb_neg {\expandafter-\romannumeral0\XINT_dtb_main}% +\def\XINT_dtb_main #1\xint: {% - \xint_gob_til_Z #2\XINT_dtb_end\Z - \expandafter\XINT_dtb_III\expandafter - {\romannumeral`&&@\XINT_dtb_small #2.#1}% + \expandafter\XINT_dtb_start + \romannumeral0\XINT_zeroes_foriv + #1\R{0\R}{00\R}{000\R}\R{0\R}{00\R}{000\R}\R\W + #1\xint_bye\xint_bye\XINT_dthb_final_a!2!3!4!5!6!7!8!9!\W }% -\def\XINT_dtb_small #1.% +\def\XINT_dtb_start #1#2#3#4#5% {% - \expandafter\XINT_smallbin\expandafter - {\the\numexpr (#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i\expandafter}% - \romannumeral`&&@\expandafter\XINT_smallbin\expandafter - {\the\numexpr - #1-((#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i)*\xint_c_ii^viii}% + \xint_bye#5\XINT_dtb_small\xint_bye + \XINT_dtb_start_a #1#2#3#4#5% }% -\def\XINT_dtb_end\Z\expandafter\XINT_dtb_III\expandafter #1#2\T +\def\XINT_dtb_start_a #1#2#3#4#5% {% - \XINT_dtb_end_b #1% + \expandafter\XINT_dtb_A\the\numexpr\XINT_dtb_a + #1#2#3#4\XINT_dtb_nextfour!2!3!4!5!6!7!8!9!\Z #5% }% -\def\XINT_dtb_end_b #1.{\XINT_dtb_end_c }% -\def\XINT_dtb_end_c #1#2#3#4#5#6#7#8% +\def\XINT_dtb_small\xint_bye\XINT_dtb_start_a #1\xint_bye #2\W {% - \expandafter\XINT_dtb_end_d\the\numexpr #1#2#3#4#5#6#7#8\relax + \expandafter\XINT_dtb_B_finish + \romannumeral`&&@\XINT_tosixteenbits#1!\space }% -\def\XINT_dtb_end_d#1{% -\def\XINT_dtb_end_d ##1##2##3##4##5##6##7##8##9% +\def\XINT_dtb_a #1!#2!#3!#4!#5!#6!#7!#8!#9!% {% - \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! -% \begin{macrocode} -\def\xintHexToDec {\romannumeral0\xinthextodec }% -\def\xinthextodec #1% - {\expandafter\XINT_htd_checkin\romannumeral`&&@#1\W\W\W\W \T }% -\def\XINT_htd_checkin #1% + \expandafter\XINT_dtb_update + \the\numexpr #1\expandafter\XINT_dtb_update + \the\numexpr #2\expandafter\XINT_dtb_update + \the\numexpr #3\expandafter\XINT_dtb_update + \the\numexpr #4\expandafter\XINT_dtb_update + \the\numexpr #5\expandafter\XINT_dtb_update + \the\numexpr #6\expandafter\XINT_dtb_update + \the\numexpr #7\expandafter\XINT_dtb_update + \the\numexpr #8\expandafter\XINT_dtb_update + \the\numexpr #9\XINT_dtb_a +}% +\def\XINT_dtb_nextfour #1\Z #2#3#4#5% {% - \xint_UDsignfork - #1\XINT_htd_neg - -{\XINT_htd_I {0000}#1}% - \krof + #2#3#4#5!\relax\XINT_dtb_nextfour!2!3!4!5!6!7!8!9!\Z }% -\def\XINT_htd_neg {\expandafter-\romannumeral0\XINT_htd_I {0000}}% -\def\XINT_htd_I #1#2#3#4#5% +\def\XINT_dtb_update #1!% {% - \xint_gob_til_W #5\XINT_htd_II_a\W - \XINT_htd_I_a {}{"#2#3#4#5}#1\Z\Z\Z\Z + \expandafter\XINT_dtb_update_a + \the\numexpr (#1+\xint_c_ii^xv)/\xint_c_ii^xvi-\xint_c_i\xint: + #1\xint:% }% -\def\XINT_htd_II_a \W\XINT_htd_I_a #1#2{\XINT_htd_II_b #2}% -\def\XINT_htd_II_b "#1#2#3#4% +\def\XINT_dtb_update_a #1\xint:#2\xint: {% - \xint_gob_til_W - #1\XINT_htd_II_c - #2\XINT_htd_II_ci - #3\XINT_htd_II_cii - \W\XINT_htd_II_ciii #1#2#3#4% + 0000+#1\expandafter!\expandafter!\the\numexpr#2-#1*\xint_c_ii^xvi }% -\def\XINT_htd_II_c \W\XINT_htd_II_ci - \W\XINT_htd_II_cii - \W\XINT_htd_II_ciii \W\W\W\W #1\Z\Z\Z\Z\T +\def\XINT_dtb_A #1!!% {% - \expandafter\xint_cleanupzeros_andstop - \romannumeral0\XINT_rord_main {}#1% - \xint: - \xint_bye\xint_bye\xint_bye\xint_bye - \xint_bye\xint_bye\xint_bye\xint_bye - \xint: + \ifnum #1>\xint_c_ \xint_dothis{\XINT_dtb_again #1!}\fi + \xint_orthat{\XINT_dtb_again}% }% -\def\XINT_htd_II_ci #1\XINT_htd_II_ciii - #2\W\W\W {\XINT_htd_II_d {}{"#2}{\xint_c_xvi}}% -\def\XINT_htd_II_cii\W\XINT_htd_II_ciii - #1#2\W\W {\XINT_htd_II_d {}{"#1#2}{\xint_c_ii^viii}}% -\def\XINT_htd_II_ciii #1#2#3\W {\XINT_htd_II_d {}{"#1#2#3}{\xint_c_ii^xii}}% -\def\XINT_htd_I_a #1#2#3#4#5#6% +\def\XINT_dtb_again #1\Z #2% {% - \xint_gob_til_Z #3\XINT_htd_I_end_a\Z - \expandafter\XINT_htd_I_b\the\numexpr - #2+\xint_c_ii^xvi*#6#5#4#3+\xint_c_x^ix\relax {#1}% + \xint_bye #2\XINT_dtb_B_a\xint_bye + \expandafter\XINT_dtb_A\the\numexpr\XINT_dtb_a #1\Z #2% }% -\def\XINT_htd_I_b 1#1#2#3#4#5#6#7#8#9{\XINT_htd_I_c {#1#2#3#4#5}{#9#8#7#6}}% -\def\XINT_htd_I_c #1#2#3{\XINT_htd_I_a {#3#2}{#1}}% -\def\XINT_htd_I_end_a\Z\expandafter\XINT_htd_I_b\the\numexpr #1+#2\relax +\def\XINT_dtb_B_a\xint_bye + \expandafter\XINT_dtb_A\the\numexpr\XINT_dtb_a #1\XINT_dtb_nextfour #2\Z {% - \expandafter\XINT_htd_I_end_b\the\numexpr \xint_c_x^v+#1\relax + \expandafter\XINT_dtb_B_finish\romannumeral`&&@\XINT_dtb_B_c #1!% }% -\def\XINT_htd_I_end_b 1#1#2#3#4#5% +\def\XINT_dtb_B_c #1!#2!#3!#4!#5!#6!#7!#8!#9!% {% - \xint_gob_til_zero #1\XINT_htd_I_end_bz0% - \XINT_htd_I_end_c #1#2#3#4#5% + \XINT_tosixteenbits#1!% + \XINT_tosixteenbits#2!% + \XINT_tosixteenbits#3!% + \XINT_tosixteenbits#4!% + \XINT_tosixteenbits#5!% + \XINT_tosixteenbits#6!% + \XINT_tosixteenbits#7!% + \XINT_tosixteenbits#8!% + \XINT_tosixteenbits#9!% + \XINT_dtb_B_c }% -\def\XINT_htd_I_end_c #1#2#3#4#5#6{\XINT_htd_I {#6#5#4#3#2#1000}}% -\def\XINT_htd_I_end_bz0\XINT_htd_I_end_c 0#1#2#3#4% +% attention ici mon #1 compte pour 4 chiffres hexa +\def\XINT_tosixteenbits #1!% {% - \xint_gob_til_zeros_iv #1#2#3#4\XINT_htd_I_end_bzz 0000% - \XINT_htd_I_end_D {#4#3#2#1}% + \expandafter\XINT_tosixteenbits_a + \the\numexpr (#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i\xint: #1\xint: }% -\def\XINT_htd_I_end_D #1#2{\XINT_htd_I {#2#1}}% -\def\XINT_htd_I_end_bzz 0000\XINT_htd_I_end_D #1{\XINT_htd_I }% -\def\XINT_htd_II_d #1#2#3#4#5#6#7% +\def\XINT_tosixteenbits_a #1\xint: #2\xint: {% - \xint_gob_til_Z #4\XINT_htd_II_end_a\Z - \expandafter\XINT_htd_II_e\the\numexpr - #2+#3*#7#6#5#4+\xint_c_x^viii\relax {#1}{#3}% + \expandafter\XINT_tosixteenbits_b + \the\numexpr #2-\xint_c_ii^viii*#1\xint:#1\xint: }% -\def\XINT_htd_II_e 1#1#2#3#4#5#6#7#8{\XINT_htd_II_f {#1#2#3#4}{#5#6#7#8}}% -\def\XINT_htd_II_f #1#2#3{\XINT_htd_II_d {#2#3}{#1}}% -\def\XINT_htd_II_end_a\Z\expandafter\XINT_htd_II_e - \the\numexpr #1+#2\relax #3#4\T +\def\XINT_tosixteenbits_b #1\xint: #2\xint: +{% + \XINT_smallbin #2!% + \XINT_smallbin #1!% +}% +\def\XINT_dtb_B_finish #1#2#3#4#5#6#7#8% {% - \XINT_htd_II_end_b #1#3% + \expandafter\XINT_dtb_B_finish_a\the\numexpr #1#2#3#4#5#6#7#8\relax }% -\def\XINT_htd_II_end_b#1{% -\def\XINT_htd_II_end_b ##1##2##3##4##5##6##7##8% +\def\XINT_dtb_B_finish_a #1{% +\def\XINT_dtb_B_finish_a ##1##2##3##4##5##6##7##8##9% {% - \expandafter#1\the\numexpr ##1##2##3##4##5##6##7##8\relax -}}\XINT_htd_II_end_b{ }% + \expandafter#1\the\numexpr ##1##2##3##4##5##6##7##8##9\relax +}}\XINT_dtb_B_finish_a { }% % \end{macrocode} -% \subsection{\csh{xintBinToDec}} -% \lverb!1.08! +% \subsection{\csh{xintHexToDec}} +% \lverb|Completely (and belatedly) rewritten at 1.2m in the 1.2 style. +% +% 1.2m version robust against non terminated inputs, but there is no primitive +% from TeX which may generate hexadecimal digits and provoke expansion ahead, +% afaik, except of course if decimal digits are treated as hexadecimal. This +% robustness is not on purpose but from need to expand argument and then grab +% it again. So we do it safely. +% +% Input should not have more than circa 5538 hexadecimal digits, else, TeX +% capacity exceeded [parameter stack size=10000] +% +% 1.2m version robust against non terminated inputs. +% +% An input without leading zeroes gives an output without leading zeroes. +% | % \begin{macrocode} -\def\xintBinToDec {\romannumeral0\xintbintodec }% -\def\xintbintodec #1{\expandafter\XINT_btd_checkin - \romannumeral`&&@#1\W\W\W\W\W\W\W\W \T }% -\def\XINT_btd_checkin #1% +\def\xintHexToDec {\romannumeral0\xinthextodec }% +\def\xinthextodec #1% +{% + \expandafter\XINT_htd_checkin\romannumeral`&&@#1\xint: +}% +\def\XINT_htd_checkin #1% {% \xint_UDsignfork - #1\XINT_btd_neg - -{\XINT_btd_I {000000}#1}% + #1\XINT_htd_neg + -{\XINT_htd_main #1}% \krof }% -\def\XINT_btd_neg {\expandafter-\romannumeral0\XINT_btd_I {000000}}% -\def\XINT_btd_I #1#2#3#4#5#6#7#8#9% +\def\XINT_htd_neg {\expandafter-\romannumeral0\XINT_htd_main}% +\def\XINT_htd_main #1\xint: {% - \xint_gob_til_W #9\XINT_btd_II_a {#2#3#4#5#6#7#8#9}\W - \XINT_btd_I_a {}{\csname XINT_sbtd_#2#3#4#5\endcsname*\xint_c_xvi+% - \csname XINT_sbtd_#6#7#8#9\endcsname}% - #1\Z\Z\Z\Z\Z\Z + \expandafter\XINT_htd_startb + \the\numexpr\expandafter\XINT_htd_starta + \romannumeral0\XINT_zeroes_foriv + #1\R{0\R}{00\R}{000\R}\R{0\R}{00\R}{000\R}\R\W + #1\xint_bye!2!3!4!5!6!7!8!9!\xint_bye\relax }% -\def\XINT_btd_II_a #1\W\XINT_btd_I_a #2#3{\XINT_btd_II_b #1}% -\def\XINT_btd_II_b #1#2#3#4#5#6#7#8% +\def\XINT_htd_starta #1#2#3#4{"#1#2#3#4+100000!}% +\def\XINT_htd_startb 1#1% {% - \xint_gob_til_W - #1\XINT_btd_II_c - #2\XINT_btd_II_ci - #3\XINT_btd_II_cii - #4\XINT_btd_II_ciii - #5\XINT_btd_II_civ - #6\XINT_btd_II_cv - #7\XINT_btd_II_cvi - \W\XINT_btd_II_cvii #1#2#3#4#5#6#7#8% + \if#10\expandafter\XINT_htd_startba\else + \expandafter\XINT_htd_startbb + \fi 1#1% }% -\def\XINT_btd_II_c #1\XINT_btd_II_cvii \W\W\W\W\W\W\W\W #2\Z\Z\Z\Z\Z\Z\T +\def\XINT_htd_startba 10#1!{\XINT_htd_again #1% + \xint_bye!2!3!4!5!6!7!8!9!\xint_bye\XINT_htd_nextfour}% +\def\XINT_htd_startbb 1#1#2!{\XINT_htd_again #1!#2% + \xint_bye!2!3!4!5!6!7!8!9!\xint_bye\XINT_htd_nextfour}% +\def\XINT_htd_again #1\XINT_htd_nextfour #2% {% - \expandafter\XINT_btd_II_c_end - \romannumeral0\XINT_rord_main {}#2% - \xint: - \xint_bye\xint_bye\xint_bye\xint_bye - \xint_bye\xint_bye\xint_bye\xint_bye - \xint: + \xint_bye #2\XINT_htd_end_a\xint_bye + \expandafter\XINT_htd_A\the\numexpr + \XINT_htd_a #1\XINT_htd_nextfour #2% }% -\def\XINT_btd_II_c_end#1{% -\def\XINT_btd_II_c_end ##1##2##3##4##5##6% +\def\XINT_htd_a #1!#2!#3!#4!#5!#6!#7!#8!#9!% {% - \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 - {\XINT_btd_II_d {}{\csname XINT_sbtd_00#2\endcsname }{\xint_c_iv }}% -\def\XINT_btd_II_ciii #1\XINT_btd_II_cvii #2\W\W\W\W\W - {\XINT_btd_II_d {}{\csname XINT_sbtd_0#2\endcsname }{\xint_c_viii }}% -\def\XINT_btd_II_civ #1\XINT_btd_II_cvii #2\W\W\W\W - {\XINT_btd_II_d {}{\csname XINT_sbtd_#2\endcsname}{\xint_c_xvi }}% -\def\XINT_btd_II_cv #1\XINT_btd_II_cvii #2#3#4#5#6\W\W\W + #1\expandafter\XINT_htd_update + \the\numexpr #2\expandafter\XINT_htd_update + \the\numexpr #3\expandafter\XINT_htd_update + \the\numexpr #4\expandafter\XINT_htd_update + \the\numexpr #5\expandafter\XINT_htd_update + \the\numexpr #6\expandafter\XINT_htd_update + \the\numexpr #7\expandafter\XINT_htd_update + \the\numexpr #8\expandafter\XINT_htd_update + \the\numexpr #9\expandafter\XINT_htd_update + \the\numexpr \XINT_htd_a +}% +\def\XINT_htd_nextfour #1#2#3#4% {% - \XINT_btd_II_d {}{\csname XINT_sbtd_#2#3#4#5\endcsname*\xint_c_ii+% - #6}{\xint_c_ii^v }% + *\xint_c_ii^xvi+"#1#2#3#4+\xint_c_x^ix\relax\xint_bye!% + 2!3!4!5!6!7!8!9!\xint_bye\XINT_htd_nextfour }% -\def\XINT_btd_II_cvi #1\XINT_btd_II_cvii #2#3#4#5#6#7\W\W +\def\XINT_htd_update 1#1#2#3#4#5#6!% {% - \XINT_btd_II_d {}{\csname XINT_sbtd_#2#3#4#5\endcsname*\xint_c_iv+% - \csname XINT_sbtd_00#6#7\endcsname}{\xint_c_ii^vi }% + *\xint_c_ii^xvi+#1#2#3#4#5+\xint_c_x^ix!#6!% }% -\def\XINT_btd_II_cvii #1#2#3#4#5#6#7\W +\def\XINT_htd_A 1#1% {% - \XINT_btd_II_d {}{\csname XINT_sbtd_#1#2#3#4\endcsname*\xint_c_viii+% - \csname XINT_sbtd_0#5#6#7\endcsname}{\xint_c_ii^vii }% + \if#10\expandafter\XINT_htd_Aa\else + \expandafter\XINT_htd_Ab + \fi 1#1% }% -\def\XINT_btd_II_d #1#2#3#4#5#6#7#8#9% +\def\XINT_htd_Aa 10#1#2#3#4#5!{\XINT_htd_again #1#2#3#4!#5!}% +\def\XINT_htd_Ab 1#1#2#3#4#5#6!{\XINT_htd_again #1!#2#3#4#5!#6!}% +% \end{macrocode} +% \lverb|\XINT_unsepb_loop is in xintcore. It removes the ! separators, the +% blocs of digits not being prefixed by 1; \XINT_unsep_loop on the other hand +% assumes 1 prefix on the digit blocks| +% \begin{macrocode} +\def\XINT_htd_end_a\xint_bye + \expandafter\XINT_htd_A\the\numexpr \XINT_htd_a #1\XINT_htd_nextfour {% - \xint_gob_til_Z #4\XINT_btd_II_end_a\Z - \expandafter\XINT_btd_II_e\the\numexpr - #2+(\xint_c_x^ix+#3*#9#8#7#6#5#4)\relax {#1}{#3}% + \expandafter\XINT_htd_end_b\the\numexpr0\XINT_unsepb_loop #1% }% -\def\XINT_btd_II_e 1#1#2#3#4#5#6#7#8#9{\XINT_btd_II_f {#1#2#3}{#4#5#6#7#8#9}}% -\def\XINT_btd_II_f #1#2#3{\XINT_btd_II_d {#2#3}{#1}}% -\def\XINT_btd_II_end_a\Z\expandafter\XINT_btd_II_e - \the\numexpr #1+(#2\relax #3#4\T +\def\XINT_htd_end_b #1{% +\def\XINT_htd_end_b ##1##2##3##4##5% + {\expandafter#1\the\numexpr ##1##2##3##4##5\relax}% +}\XINT_htd_end_b{ }% +% \end{macrocode} +% \subsection{\csh{xintBinToDec}} +% \lverb|Redone entirely for 1.2m. Starts by converting to hexadecimal +% first (but with unexpanded \XINT_sbth_xxxx macros). +% +% Maximal size of input around 19984 digits (expansion depth=10000). +% +% An input without leading zeroes gives an output without leading zeroes. +% +% 1.2m robust against non-terminated input.| +% \begin{macrocode} +\def\xintBinToDec {\romannumeral0\xintbintodec }% +\def\xintbintodec #1% {% - \XINT_btd_II_end_b #1#3% + \expandafter\XINT_btd_checkin\romannumeral`&&@#1\xint: }% -\def\XINT_btd_II_end_b#1{% -\def\XINT_btd_II_end_b ##1##2##3##4##5##6##7##8##9% +\def\XINT_btd_checkin #1% {% - \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_UDsignfork + #1\XINT_btd_N + -{\XINT_btd_main #1}% + \krof +}% +\def\XINT_btd_N {\expandafter-\romannumeral0\XINT_btd_main }% +\def\XINT_btd_main #1\xint: {% - \xint_gob_til_Z #3\XINT_btd_I_end_a\Z - \expandafter\XINT_btd_I_b\the\numexpr - #2+\xint_c_ii^viii*#8#7#6#5#4#3+\xint_c_x^ix\relax {#1}% + \expandafter\XINT_btd_htd + \csname\expandafter\XINT_btd_tohex + \romannumeral0\XINT_zeroes_foriv + #1\R{0\R}{00\R}{000\R}\R{0\R}{00\R}{000\R}\R\W + #1\XINT_btd_tohex_endcsname2345678\W }% -\def\XINT_btd_I_b 1#1#2#3#4#5#6#7#8#9{\XINT_btd_I_c {#1#2#3}{#9#8#7#6#5#4}}% -\def\XINT_btd_I_c #1#2#3{\XINT_btd_I_a {#3#2}{#1}}% -\def\XINT_btd_I_end_a\Z\expandafter\XINT_btd_I_b - \the\numexpr #1+\xint_c_ii^viii #2\relax +\def\XINT_btd_tohex #1#2#3#4#5#6#7#8% {% - \expandafter\XINT_btd_I_end_b\the\numexpr 1000+#1\relax + XINT_sbth_#1#2#3#4\expandafter\endcsname + \csname XINT_sbth_#5#6#7#8\expandafter\endcsname + \csname\XINT_btd_tohex }% -\def\XINT_btd_I_end_b 1#1#2#3% +\def\XINT_btd_tohex_endcsname#1\W{none\endcsname}% +\def\XINT_btd_htd #1\XINT_sbth_none {% - \xint_gob_til_zeros_iii #1#2#3\XINT_btd_I_end_bz 000% - \XINT_btd_I_end_c #1#2#3% + \expandafter\XINT_htd_startb + \the\numexpr\expandafter\XINT_htd_starta + \romannumeral0\XINT_zeroes_foriv + #1\R{0\R}{00\R}{000\R}\R{0\R}{00\R}{000\R}\R\W + #1\xint_bye!2!3!4!5!6!7!8!9!\xint_bye\relax }% -\def\XINT_btd_I_end_c #1#2#3#4{\XINT_btd_I {#4#3#2#1000}}% -\def\XINT_btd_I_end_bz 000\XINT_btd_I_end_c 000{\XINT_btd_I }% % \end{macrocode} % \subsection{\csh{xintBinToHex}} -% \lverb!1.08! +% \lverb|Complete rewrite for 1.2m. +% +% But input should not have more than about 13320 binary digits (expansion +% depth=10000). +% +% Size of output is ceil(size(input)/4), leading zeroes in output (inherited +% from the input) are not trimmed. +% +% An input without leading zeroes gives an output without leading zeroes. +% +% 1.2m robust against non-terminated input. +% | % \begin{macrocode} \def\xintBinToHex {\romannumeral0\xintbintohex }% \def\xintbintohex #1% {% - \expandafter\XINT_bth_checkin - \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 + \expandafter\XINT_bth_checkin\romannumeral`&&@#1\xint: }% \def\XINT_bth_checkin #1% {% \xint_UDsignfork #1\XINT_bth_N - -{\XINT_bth_P #1}% + -{\XINT_bth_main #1}% \krof }% -\def\XINT_bth_N {\expandafter-\romannumeral0\XINT_bth_P }% -\def\XINT_bth_P {\expandafter\XINT_bth_I\expandafter{\expandafter}% - \romannumeral0\XINT_OQ {}}% -\def\XINT_bth_I #1#2#3#4#5#6#7#8#9% +\def\XINT_bth_N {\expandafter-\romannumeral0\XINT_bth_main }% +\def\XINT_bth_main #1{% +\def\XINT_bth_main ##1\xint: {% - \xint_gob_til_W #9\XINT_bth_end_a\W - \expandafter\expandafter\expandafter - \XINT_bth_I - \expandafter\expandafter\expandafter - {\csname XINT_sbth_#9#8#7#6\expandafter\expandafter\expandafter\endcsname - \csname XINT_sbth_#5#4#3#2\endcsname #1}% -}% -\def\XINT_bth_end_a\W \expandafter\expandafter\expandafter - \XINT_bth_I \expandafter\expandafter\expandafter #1% -{% - \XINT_bth_end_b #1% -}% -\def\XINT_bth_end_b #1\endcsname #2\endcsname #3% + \expandafter\expandafter\expandafter#1% + \csname\expandafter\XINT_bth_tohex + \romannumeral0\XINT_zeroes_foriv + ##1\R{0\R}{00\R}{000\R}\R{0\R}{00\R}{000\R}\R\W + ##1\XINT_bth_tohex_endcsname2345678\W +}}\XINT_bth_main{ }% +\def\XINT_bth_tohex #1#2#3#4#5#6#7#8% {% - \xint_gob_til_zero #3\XINT_bth_end_z 0\space #3% + XINT_sbth_#1#2#3#4\expandafter\expandafter\expandafter\endcsname + \csname XINT_sbth_#5#6#7#8\expandafter\expandafter\expandafter\endcsname + \csname\XINT_bth_tohex }% -\def\XINT_bth_end_z0\space 0{ }% +\def\XINT_bth_tohex_endcsname#1\W{none\endcsname}% % \end{macrocode} % \subsection{\csh{xintHexToBin}} -% \lverb!1.08! +% \lverb|Completely rewritten for 1.2m. Limited to inputs of at most about +% 4994 hexadecimal digits [input stack size=5000]. +% +% Attention this macro is not robust against arguments expanding after +% themselves. +% +% Only up to three zeros are removed on front of output: if the input had a +% leading zero, there will be a leading zero (and then possibly 4n of them if +% inputs had more leading zeroes) on output.| % \begin{macrocode} \def\xintHexToBin {\romannumeral0\xinthextobin }% \def\xinthextobin #1% {% - \expandafter\XINT_htb_checkin\romannumeral`&&@#1GGGGGGGG\T + \expandafter\XINT_htb_checkin\romannumeral`&&@#1% + \xint_bye 23456789\xint_bye none\endcsname\relax }% \def\XINT_htb_checkin #1% {% \xint_UDsignfork #1\XINT_htb_N - -{\XINT_htb_P #1}% + -{\XINT_htb_main #1}% \krof }% -\def\XINT_htb_N {\expandafter-\romannumeral0\XINT_htb_P }% -\def\XINT_htb_P {\XINT_htb_I_a {}}% -\def\XINT_htb_I_a #1#2#3#4#5#6#7#8#9% -{% - \xint_gob_til_G #9\XINT_htb_II_a G% - \expandafter\expandafter\expandafter - \XINT_htb_I_b - \expandafter\expandafter\expandafter - {\csname XINT_shtb_#2\expandafter\expandafter\expandafter\endcsname - \csname XINT_shtb_#3\expandafter\expandafter\expandafter\endcsname - \csname XINT_shtb_#4\expandafter\expandafter\expandafter\endcsname - \csname XINT_shtb_#5\expandafter\expandafter\expandafter\endcsname - \csname XINT_shtb_#6\expandafter\expandafter\expandafter\endcsname - \csname XINT_shtb_#7\expandafter\expandafter\expandafter\endcsname - \csname XINT_shtb_#8\expandafter\expandafter\expandafter\endcsname - \csname XINT_shtb_#9\endcsname }{#1}% -}% -\def\XINT_htb_I_b #1#2{\XINT_htb_I_a {#2#1}}% -\def\XINT_htb_II_a G\expandafter\expandafter\expandafter\XINT_htb_I_b -{% - \expandafter\expandafter\expandafter \XINT_htb_II_b -}% -\def\XINT_htb_II_b #1#2#3\T -{% - \expandafter\XINT_num_cleanup - \the\numexpr\expandafter\XINT_num_loop #2#1% - \xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z -}% +\def\XINT_htb_N {\expandafter-\romannumeral0\XINT_htb_main }% +\def\XINT_htb_main {\expandafter\XINT_htb_cuz\the\numexpr\XINT_htb_loop}% +\def\XINT_htb_loop #1#2#3#4#5#6#7#8#9% +{% + 1\csname XINT_shtb_#1\endcsname + \csname XINT_shtb_#2\endcsname + \expandafter\XINT_unsep_clean + \the\numexpr1\csname XINT_shtb_#3\endcsname + \csname XINT_shtb_#4\endcsname + \expandafter\XINT_unsep_clean + \the\numexpr1\csname XINT_shtb_#5\endcsname + \csname XINT_shtb_#6\endcsname + \expandafter\XINT_unsep_clean + \the\numexpr1\csname XINT_shtb_#7\endcsname + \csname XINT_shtb_#8\endcsname + \expandafter\XINT_unsep_clean + \the\numexpr1\csname XINT_shtb_#9\endcsname + \XINT_htb_loop_a +}% +\def\XINT_htb_loop_a #1#2#3#4#5#6#7#8#9% +{% + \csname XINT_shtb_#1\endcsname + \expandafter\XINT_unsep_clean + \the\numexpr1\csname XINT_shtb_#2\endcsname + \csname XINT_shtb_#3\endcsname + \expandafter\XINT_unsep_clean + \the\numexpr1\csname XINT_shtb_#4\endcsname + \csname XINT_shtb_#5\endcsname + \expandafter\XINT_unsep_clean + \the\numexpr1\csname XINT_shtb_#6\endcsname + \csname XINT_shtb_#7\endcsname + \expandafter\XINT_unsep_clean + \the\numexpr1\csname XINT_shtb_#8\endcsname + \csname XINT_shtb_#9\endcsname + \expandafter\XINT_unsep_clean + \the\numexpr\XINT_htb_loop +}% +\def\XINT_htb_cuz #1{% +\def\XINT_htb_cuz 1##1##2##3##4% + {\expandafter#1\the\numexpr##1##2##3##4\relax}% +}\XINT_htb_cuz { }% % \end{macrocode} % \subsection{\csh{xintCHexToBin}} -% \lverb!1.08! +% \lverb|The 1.08 macro had same functionality as \xintHexToBin, and slightly +% different code, the 1.2m version has the same code as \xintHexToBin except +% that it does not remove leading zeros from output: if the input had N +% hexadecimal digits, the output will have exactly 4N binary digits.| % \begin{macrocode} \def\xintCHexToBin {\romannumeral0\xintchextobin }% \def\xintchextobin #1% {% \expandafter\XINT_chtb_checkin\romannumeral`&&@#1% - \R\R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W\W + \xint_bye 23456789\xint_bye none\endcsname\relax }% \def\XINT_chtb_checkin #1% {% \xint_UDsignfork #1\XINT_chtb_N - -{\XINT_chtb_P #1}% + -{\XINT_chtb_main #1}% \krof }% -\def\XINT_chtb_N {\expandafter-\romannumeral0\XINT_chtb_P }% -\def\XINT_chtb_P {\expandafter\XINT_chtb_I\expandafter{\expandafter}% - \romannumeral0\XINT_OQ {}}% -\def\XINT_chtb_I #1#2#3#4#5#6#7#8#9% -{% - \xint_gob_til_W #9\XINT_chtb_end_a\W - \expandafter\expandafter\expandafter - \XINT_chtb_I - \expandafter\expandafter\expandafter - {\csname XINT_shtb_#9\expandafter\expandafter\expandafter\endcsname - \csname XINT_shtb_#8\expandafter\expandafter\expandafter\endcsname - \csname XINT_shtb_#7\expandafter\expandafter\expandafter\endcsname - \csname XINT_shtb_#6\expandafter\expandafter\expandafter\endcsname - \csname XINT_shtb_#5\expandafter\expandafter\expandafter\endcsname - \csname XINT_shtb_#4\expandafter\expandafter\expandafter\endcsname - \csname XINT_shtb_#3\expandafter\expandafter\expandafter\endcsname - \csname XINT_shtb_#2\endcsname - #1}% -}% -\def\XINT_chtb_end_a\W\expandafter\expandafter\expandafter - \XINT_chtb_I\expandafter\expandafter\expandafter #1% -{% - \XINT_chtb_end_b #1% - \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 -{% - \expandafter\XINT_num_cleanup - \the\numexpr\expandafter\XINT_num_loop -}% +\def\XINT_chtb_N {\expandafter-\romannumeral0\XINT_chtb_main }% +\def\XINT_chtb_main + {\expandafter\xint_gobble_thenstop\the\numexpr\XINT_htb_loop}% \XINT_restorecatcodes_endinput% % \end{macrocode} % @@ -24060,7 +24120,7 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xintgcd}% - [2017/07/26 1.2l Euclide algorithm with xint package (JFB)]% + [2017/07/31 1.2m Euclide algorithm with xint package (JFB)]% % \end{macrocode} % \subsection{\csh{xintGCD}, \csh{xintiiGCD}} % \begin{macrocode} @@ -24727,7 +24787,7 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xintfrac}% - [2017/07/26 1.2l Expandable operations on fractions (JFB)]% + [2017/07/31 1.2m 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 @@ -26480,15 +26540,16 @@ $1$ or $-1$. }% \def\XINT_fgeq_Fd #1\Z #2#3% {% - \expandafter\XINT_fgeq_Fe\expandafter - {\romannumeral0\XINT_dsx_addzeros {#1}#3;}{#2}% + \expandafter\XINT_fgeq_Fe + \romannumeral0\XINT_dsx_addzeros {#1}#3;\xint:#2\xint: }% -\def\XINT_fgeq_Fe #1#2{\XINT_geq_pre {#2}{#1}}% +\def\XINT_fgeq_Fe #1\xint:#2#3\xint:{\XINT_geq_plusplus #2#1\xint:#3\xint:}% \def\XINT_fgeq_Fn #1\Z #2#3% {% - \expandafter\XINT_geq_pre\expandafter - {\romannumeral0\XINT_dsx_addzeros {#1}#2;}{#3}% + \expandafter\XINT_fgeq_Fo + \romannumeral0\XINT_dsx_addzeros {#1}#2;\xint:#3\xint: }% +\def\XINT_fgeq_Fo #1#2\xint:#3\xint:{\XINT_geq_plusplus #1#3\xint:#2\xint:}% % \end{macrocode} % \subsection{\csh{xintMax}} % \begin{macrocode} @@ -26632,9 +26693,9 @@ $1$ or $-1$. \krof #1#2% }% -\def\XINT_fcmp_zerozero #1#2#3#4{ 0}% 1.08b had some [ and ] here!!! -\def\XINT_fcmp_firstzero #1#2#3#4{ -1}% incredibly I never saw that until -\def\XINT_fcmp_secondzero #1#2#3#4{ 1}% preparing 1.09a. +\def\XINT_fcmp_zerozero #1#2#3#4{ 0}% +\def\XINT_fcmp_firstzero #1#2#3#4{ -1}% +\def\XINT_fcmp_secondzero #1#2#3#4{ 1}% \def\XINT_fcmp_pos #1#2#3#4% {% \XINT_fcmp_B #1#3#2#4% @@ -26666,15 +26727,16 @@ $1$ or $-1$. }% \def\XINT_fcmp_Fd #1\Z #2#3% {% - \expandafter\XINT_fcmp_Fe\expandafter - {\romannumeral0\XINT_dsx_addzeros {#1}#3;}{#2}% + \expandafter\XINT_fcmp_Fe + \romannumeral0\XINT_dsx_addzeros {#1}#3;\xint:#2\xint: }% -\def\XINT_fcmp_Fe #1#2{\xintiicmp {#2}{#1}}% +\def\XINT_fcmp_Fe #1\xint:#2#3\xint:{\XINT_cmp_plusplus #2#1\xint:#3\xint:}% \def\XINT_fcmp_Fn #1\Z #2#3% {% - \expandafter\xintiicmp\expandafter - {\romannumeral0\XINT_dsx_addzeros {#1}#2;}{#3}% + \expandafter\XINT_fcmp_Fo + \romannumeral0\XINT_dsx_addzeros {#1}#2;\xint:#3\xint: }% +\def\XINT_fcmp_Fo #1#2\xint:#3\xint:{\XINT_cmp_plusplus #1#3\xint:#2\xint:}% % \end{macrocode} % \subsection{\csh{xintAbs}} % \begin{macrocode} @@ -28714,7 +28776,7 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xintseries}% - [2017/07/26 1.2l Expandable partial sums with xint package (JFB)]% + [2017/07/31 1.2m Expandable partial sums with xint package (JFB)]% % \end{macrocode} % \subsection{\csh{xintSeries}} % \begin{macrocode} @@ -29212,7 +29274,7 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xintcfrac}% - [2017/07/26 1.2l Expandable continued fractions with xint package (JFB)]% + [2017/07/31 1.2m Expandable continued fractions with xint package (JFB)]% % \end{macrocode} % \subsection{\csh{xintCFrac}} % \begin{macrocode} @@ -30463,7 +30525,7 @@ $1$ or $-1$. % \begin{macrocode} \XINT_providespackage \ProvidesPackage{xintexpr}% - [2017/07/26 1.2l Expandable expression parser (JFB)]% + [2017/07/31 1.2m Expandable expression parser (JFB)]% \catcode`! 11 \let\XINT_Cmp \xintiiCmp % \end{macrocode} @@ -34464,10 +34526,10 @@ $1$ or $-1$. %<*dtx>----------------------------------------------------------- \iffalse % grep -c -e "^{%" xint*sty -xint.sty:196 -xintbinhex.sty:70 +xint.sty:178 +xintbinhex.sty:66 xintcfrac.sty:183 -xintcore.sty:278 +xintcore.sty:280 xintexpr.sty:168 xintfrac.sty:439 xintgcd.sty:50 @@ -34476,13 +34538,13 @@ xintseries.sty:48 xinttools.sty:138 \fi % grep -o "^{%" xint*sty | wc -l -\def\totala{ 1583} +\def\totala{ 1563} \iffalse % grep -c -e "^}%" xint*sty -xint.sty:195 -xintbinhex.sty:65 +xint.sty:177 +xintbinhex.sty:64 xintcfrac.sty:183 -xintcore.sty:275 +xintcore.sty:277 xintexpr.sty:199 xintfrac.sty:437 xintgcd.sty:52 @@ -34491,7 +34553,7 @@ xintseries.sty:48 xinttools.sty:137 \fi % grep -o "^}%" xint*sty | wc -l -\def\totalb{ 1605} +\def\totalb{ 1588} \DeleteShortVerb{\|} \def\mymacro #1{\mymacroaux #1} \def\mymacroaux #1#2{\strut \csname #1nameimp\endcsname:& \dtt{ #2.}\tabularnewline } @@ -34528,8 +34590,8 @@ xinttools.sty:137 Right bracket \] Circumflex \^ Underscore \_ Grave accent \` Left brace \{ Vertical bar \| Right brace \} Tilde \~} -\CheckSum {30931}% 30303 pour 1.2h, 30403 pour 1.2i, 30750 pour 1.2j, - % 30677 pour 1.2k +\CheckSum {30439}% 30303 pour 1.2h, 30403 pour 1.2i, 30750 pour 1.2j, + % 30677 pour 1.2k, 30931 pour 1.2l \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 9389268dca2..b405e1f602a 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.2l 2017/07/26 +%% The xint bundle 1.2m 2017/07/31 %% Copyright (C) 2013-2017 by Jean-Francois Burnol %% --------------------------------------------------------------- %% |