diff options
author | Karl Berry <karl@freefriends.org> | 2013-06-27 16:31:25 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-06-27 16:31:25 +0000 |
commit | 82c37dcf73b52a88faef522a2f1a294351deea1a (patch) | |
tree | 4c0f4b7b3c5fb16b1b5e0b413fc1a800bc9eef35 | |
parent | eeeb860e63fdf6d8e9c0c18825a887aec80eed7e (diff) |
xint (16jun13)
git-svn-id: svn://tug.org/texlive/trunk@30978 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/generic/xint/README | 16 | ||||
-rw-r--r-- | Master/texmf-dist/doc/generic/xint/xint.pdf | bin | 629272 -> 770070 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/generic/xint/xint.dtx | 5750 | ||||
-rw-r--r-- | Master/texmf-dist/source/generic/xint/xint.ins | 9 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xint.sty | 933 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintbinhex.sty | 732 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintcfrac.sty | 75 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintexpr.sty | 59 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintfrac.sty | 858 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintgcd.sty | 7 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintseries.sty | 186 |
11 files changed, 6273 insertions, 2352 deletions
diff --git a/Master/texmf-dist/doc/generic/xint/README b/Master/texmf-dist/doc/generic/xint/README index 5e4fbff4adb..357fe2400e8 100644 --- a/Master/texmf-dist/doc/generic/xint/README +++ b/Master/texmf-dist/doc/generic/xint/README @@ -1,11 +1,12 @@ The xint bundle -Release 1.07a (2013/05/26) +Release 1.08b (2013/06/14). Documentation version: 2013/04/16. author: Jean-Francois Burnol Style files which will self-extract from xint.dtx: (base) xint.sty Expandable operations on long numbers xintfrac.sty Expandable operations on fractions xintexpr.sty Expandable expression parser + xintbinhex.sty Expandable binary and hexadecimal conversions xintgcd.sty Euclidean algorithm with xint package xintseries.sty Expandable partial sums with xint package xintcfrac.sty Expandable continued fractions with xint package @@ -16,9 +17,9 @@ License ======= This work consists of the source file xint.dtx and of its derived files: -xint.sty, xintgcd.sty, xintexpr.sty, -xintfrac.sty, xintseries.sty, xintcfrac.sty, -as well as xint.ins and the documentation xint.pdf (or xint.dvi). +xint.sty, xintfrac.sty, xintexpr.sty, xintbinhex.sty, xintgcd.sty, +xintseries.sty, xintcfrac.sty, as well as xint.ins and the documentation +xint.pdf (or xint.dvi). This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either @@ -39,7 +40,7 @@ Installation and Usage: Run tex or latex on xint.dtx. This will extract the style files xint.sty, xintfrac.sty, xintexpr.sty, -xintgcd.sty, xintseries.sty, xintcfrac.sty (and xint.ins). +xintbinhex.sty, xintgcd.sty, xintseries.sty, xintcfrac.sty (and xint.ins). Files with the same names and in the same repertory will be overwritten. The tex (not latex) run will stop with the complaint that it does not @@ -52,7 +53,8 @@ To get xint.pdf run pdflatex thrice on xint.dtx xint.sty | xintfrac.sty | - xintexpr.sty | --> TDS:tex/generic/xint/ + xintexpr.sty | + xintbinhex.sty | --> TDS:tex/generic/xint/ xintgcd.sty | xintseries.sty | xintcfrac.sty | @@ -66,6 +68,7 @@ Usage with LaTeX: \usepackage{xint} \usepackage{xintfrac} (loads xint) \usepackage{xintexpr} (loads xintfrac) + \usepackage{xintbinhex} (loads xint) \usepackage{xintgcd} (loads xint) \usepackage{xintseries} (loads xintfrac) \usepackage{xintcfrac} (loads xintfrac) @@ -74,6 +77,7 @@ Usage with TeX: \input xint.sty\relax \input xintfrac.sty\relax (loads xint) \input xintexpr.sty\relax (loads xintfrac) + \input xintbinhex.sty\relax (loads xint) \input xintgcd.sty\relax (loads xint) \input xintseries.sty\relax (loads xintfrac) \input xintcfrac.sty\relax (loads xintfrac) diff --git a/Master/texmf-dist/doc/generic/xint/xint.pdf b/Master/texmf-dist/doc/generic/xint/xint.pdf Binary files differindex 1d67e7e3ef2..b21ea8d18dd 100644 --- a/Master/texmf-dist/doc/generic/xint/xint.pdf +++ b/Master/texmf-dist/doc/generic/xint/xint.pdf diff --git a/Master/texmf-dist/source/generic/xint/xint.dtx b/Master/texmf-dist/source/generic/xint/xint.dtx index 27b0f755918..c232673fea1 100644 --- a/Master/texmf-dist/source/generic/xint/xint.dtx +++ b/Master/texmf-dist/source/generic/xint/xint.dtx @@ -1,21 +1,24 @@ % -*- coding: iso-latin-1; -*- -% This file: xint.dtx (1.07a, 2013/05/26) -% +% xint.dtx, 1.08b (2013/06/14) +% Copyright (C) 2013 by Jean-François Burnol % Style files which will self-extract from xint.dtx: % (base) xint.sty Expandable operations on long numbers % xintfrac.sty Expandable operations on fractions % xintexpr.sty Expandable expression parser +% xintbinhex.sty Expandable binary and hexadecimal conversions % xintgcd.sty Euclidean algorithm with xint package % xintseries.sty Expandable partial sums with xint package % xintcfrac.sty Expandable continued fractions with xint package -% May be used with Plain TeX (\input) or as LaTeX packages (\usepackage) -% +% To be used with Plain TeX (\input) or LaTeX (\usepackage) +%<*doc> +\def\lasttimestamp{Time-stamp: <16-06-2013 08:53:40 CEST *>} +%</doc> % License % ======= % % This work consists of the source file xint.dtx and of its derived files: -% xint.sty, xintgcd.sty, xintexpr.sty, -% xintfrac.sty, xintseries.sty, xintcfrac.sty, +% xint.sty, xintfrac.sty, xintexpr.sty, +% xintbinhex.sty, xintgcd.sty, xintseries.sty, xintcfrac.sty, % as well as xint.ins and the documentation xint.pdf (or xint.dvi). % % This work may be distributed and/or modified under the @@ -37,7 +40,7 @@ % Run tex or latex on xint.dtx. % % This will extract the style files xint.sty, xintfrac.sty, xintexpr.sty, -% xintgcd.sty, xintseries.sty, xintcfrac.sty (and xint.ins). +% xintbinhex.sty, xintgcd.sty, xintseries.sty, xintcfrac.sty (and xint.ins). % % Files with the same names and in the same repertory will be overwritten. % The tex (not latex) run will stop with the complaint that it does not @@ -50,7 +53,8 @@ % % xint.sty | % xintfrac.sty | -% xintexpr.sty | --> TDS:tex/generic/xint/ +% xintexpr.sty | +% xintbinhex.sty | --> TDS:tex/generic/xint/ % xintgcd.sty | % xintseries.sty | % xintcfrac.sty | @@ -64,6 +68,7 @@ % \usepackage{xintfrac} % (loads xint) % \usepackage{xintexpr} % (loads xintfrac) % +% \usepackage{xintbinhex} % (loads xint) % \usepackage{xintgcd} % (loads xint) % \usepackage{xintseries} % (loads xintfrac) % \usepackage{xintcfrac} % (loads xintfrac) @@ -72,26 +77,27 @@ % \input xintfrac.sty\relax % (loads xint) % \input xintexpr.sty\relax % (loads xintfrac) % +% \input xintbinhex.sty\relax % (loads xint) % \input xintgcd.sty\relax % (loads xint) % \input xintseries.sty\relax % (loads xintfrac) % \input xintcfrac.sty\relax % (loads xintfrac) % %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.07a of May 26, 2013) +%% The xint bundle (version 1.08b of June 14, 2013) %<xint>%% xint: Expandable operations on long numbers %<xintfrac>%% xintfrac: Expandable operations on fractions %<xintexpr>%% xintexpr: Expandable expression parser +%<xintbinhex>%% xintbinhex: Expandable binary and hexadecimal conversions %<xintgcd>%% xintgcd: Euclidean algorithm with xint package %<xintseries>%% xintseries: Expandable partial sums with xint package %<xintcfrac>%% xintcfrac: Expandable continued fractions with xint package %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- %% -%<*none> -\def\lasttimestamp{Time-stamp: <26-05-2013 11:42:13 CEST jfb>} -\def\pkgversion{1.07a} -\def\pkgdate{2013/05/26} +%<*doc> +\def\pkgversion{1.08b} +\def\pkgdate{2013/06/14} \def\striptimestamp #1 <#2 #3 #4 #5>{#2 at #3 #4} \def\getdocdate #1 <#2-#3-#4 #5>{#4/#3/#2} \edef\docdate{\expandafter\getdocdate\lasttimestamp} @@ -103,6 +109,7 @@ \file{xint.ins}{\from{xint.dtx}{ins}} \usepreamble\defaultpreamble \file{xint.sty}{\from{xint.dtx}{xint}} +\file{xintbinhex.sty}{\from{xint.dtx}{xintbinhex}} \file{xintgcd.sty}{\from{xint.dtx}{xintgcd}} \file{xintfrac.sty}{\from{xint.dtx}{xintfrac}} \file{xintseries.sty}{\from{xint.dtx}{xintseries}} @@ -110,21 +117,22 @@ \file{xintexpr.sty}{\from{xint.dtx}{xintexpr}}} \endgroup \iffalse -%</none> +%</doc> %<*ins> %----------- to .ins file ---------------------------------------- %% %% This is a generated file. Run tex or latex on this file to -%% extract xint.sty, xintgcd.sty, xintfrac.sty, xintseries.sty -%% and xintcfrac.sty from xint.dtx +%% extract xint.sty, xintfrac.sty, xintexpr.sty, xintbinhex.sty, +%% xintgcd.sty, xintseries.sty and xintcfrac.sty from xint.dtx %% -%% See xint.dtx for the statements of copyright and conditions of +%% See xint.dtx for the copyright and the conditions for %% distribution and/or modification of this work. %% \input docstrip.tex \askforoverwritefalse \generate{\usepreamble\defaultpreamble \file{xint.sty}{\from{xint.dtx}{xint}} +\file{xintbinhex.sty}{\from{xint.dtx}{xintbinhex}} \file{xintgcd.sty}{\from{xint.dtx}{xintgcd}} \file{xintfrac.sty}{\from{xint.dtx}{xintfrac}} \file{xintseries.sty}{\from{xint.dtx}{xintseries}} @@ -133,7 +141,7 @@ \endbatchfile %----------- end of .ins file ------------------------------------ %</ins> -%<*none> +%<*doc> \fi \NeedsTeXFormat{LaTeX2e} \ProvidesFile{xint.dtx}[bundle source and documentation (\dtxtimestamp)] @@ -147,11 +155,11 @@ \usepackage{multicol} %---- GEOMETRY WILL BE CHANGED FOR SOURCE CODE SECTIONS - \usepackage[hscale=0.66,vscale=0.75]{geometry} \usepackage{xintexpr} +\usepackage{xintbinhex} \usepackage{xintgcd} \usepackage{xintseries} \usepackage{xintcfrac} @@ -159,43 +167,87 @@ \usepackage{amsmath} % for \cfrac in the documentation \usepackage{etoc} -\makeatletter %---- CHANGING TOCDEPTH MIDWAY THROUGH THE MAIN TOC (1.04, 18 avril 2013) -\def\newtocdepth #1{\c@tocdepth #1 } % ainsi on modifie localement seulement -\def\toctransition {% - \addtocontents {toc}{\protect\newtocdepth {1}}% - \let\newtocdepth\@gobble +% je modifie le 27 mai car finalement j'ajoute des \localtableofcontents aux +% chapitres décrivant les commandes des packages, et je supprime ces +% sous-sections de la Table principale. OK, ça marche. Ok aussi pour les +% bookmarks du pdf. + +\makeatletter +\def\resettocdepthto #1{\c@tocdepth #1\relax }% +% ainsi on modifie localement seulement puisque cela sera vu seulement dans le +% scope du group de la (local) tableofcontents faite par etoc et hyperref ne me +% jouera pas de tour avec les bookmarks + +\def\SetInnerTocdepthTo #1{% + \addtocontents {toc}{\protect\resettocdepthto {#1}}% +}% + +\def\FutureTOCsDoNotObeyInnerTocdepth{% + \let\resettocdepthto\@gobble \etocmulticolstyle [1]{\subsection *{Contents}}% -} +}% +% parfait, modifs du 27 mai ok. -%---- USING ETOC FOR CUSTOM SUBSECTION STYLE (pour 1.04, 21 avril 2013) -% attention comme je crée un groupe pour les sous-sections, je dois donc faire -% attention de positionner \toctransition *après* le début de la section -% "implémentation de xint" +% ---- USING ETOC FOR CUSTOM SUBSECTION STYLE (pour 1.04, 21 avril 2013) +% attention comme je crée un groupe pour le typesetting dans les TOCs des +% sous-sections, je dois donc faire attention de positionner \toctransition +% juste après le début de la section "implémentation de xint", sinon il est dans +% le scope de la précédente sous-section et l'action sur \c@tocdepth sera +% annulée aussitôt. + +% 27 mai: la position, et la nature, de \toctransition modifiés car je ne mets +% plus les sous-sections des sections de «Commands» dans la Toc. + +% 8 juin: je change à nouveau le nom de \toctransition (cf au-dessus) \def\gobbletodot #1.{} \let\savedsectionline\l@section \etocsetstyle{section}{}{} {\savedsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}{}% + +% choix de style plus sophistiqué à partir de 1.08a \etocsetstyle{subsection} {\begingroup \setlength{\premulticols}{0pt} \setlength{\multicolsep}{0pt} - \setlength{\columnsep}{1.5em} - \begin{multicols}{2}}{} - {\noindent\makebox[1.5em][l] - {\ttfamily\expandafter\gobbletodot\etocthenumber}% - \etocname\leaders\etoctoclineleaders\hfill - {\normalfont\etocpage}\endgraf} - {\end{multicols}\endgroup}% + \setlength{\columnsep}{1em} + \setlength{\columnseprule}{.4pt} + \raggedcolumns % only added for 1.08a, I should have done it long time ago! + \begin{multicols}{2}% + \leftskip 2.3em\rightskip 0em\parfillskip 0em\relax + } + {} + {\noindent + \llap{\makebox[2.3em][l] + {\ttfamily\bfseries\etoclink + {.\expandafter\gobbletodot\etocthenumber}}}% + \strut + \etocname\leaders\etoctoclineleaders + \hfill \strut\makebox[1.5em][r]{\normalfont\small\etocpage}\endgraf } + {\end{multicols}\endgroup }% \makeatother -%--- TXFONTS, AND TXTT MADE SMALLER AND ALLOWING HYPHENATION +% 4 juin 2013 +% je me décide à utiliser les couleurs des liens via hyperref, mais je n'en veux +% pas (des couleurs) dans les TOCs (par contre je veux les liens évidemment). +% Idéalement j'aurais aimé pouvoir avoir pour les TOCs les liens sous la forme +% de rectangles mais je n'ai pas le temps de regarder si on peut dire à hyperref +% de faire cela. J'ai déterminé empiriquement qu'on peut tout-à-fait mettre +% \hypersetup{hidelinks} dans un groupe + +% à propos il faudrait une interface plus commode pour ce hook +% Mais c'est déjà bien qu'on ait ça! + +\def\etocaftertitlehook {\hypersetup{hidelinks}} + +%--- TXFONTS: TXTT WILL BE MADE SMALLER AND WILL ALLOW HYPHENATION \usepackage{txfonts} + % malheureusement, comme j'utilise des diacritiques dans mes % parties commentées, imprimées verbatim, je ne pourrai pas % utiliser dvipdfmx qui a un problème avec txtt @@ -247,6 +299,18 @@ <->ssub * txtt/bx/ui% }{} +% au bout d'un moment j'ai fini par être mal à l'aise avec le 0 de txtt, pour +% afficher les résultats des calculs faits pas xint. +% +% ***** Attention le - de cmtt est ÉPOUVANTABLE!***** bon, ça le disqualifie. +% le - de lmtt lui n'a PAS ce problème. Et lmtt, à sa taille naturelle, +% correspond bien à mon txtt réduit à 96%. Donc c'est très simple: + +\def\digitstt {\bgroup\fontfamily {lmtt}\selectfont\let\next=} + +% le nom de \digitstt n'est pas très bien choisi, mais bon il est en effet +% utilisé ici dans 95% des cas pour des nombres uniquement. + \usepackage{xspace} \usepackage{color} \usepackage{framed} @@ -255,19 +319,20 @@ \definecolor{JOLI}{RGB}{225,95,0} \definecolor{BLUE}{RGB}{0,0,255} \definecolor{niceone}{RGB}{38,128,192} +\definecolor{PineGreen}{cmyk}{0.92,0,0.59,0.25}% cf color.pro +\definecolor{Purple}{cmyk}{0.45,0.86,0,0} \usepackage[english]{babel} \usepackage[autolanguage,np]{numprint} -\AtBeginDocument{ -\npthousandsep{,\hskip .05em plus .01em minus .01em}} - +\AtBeginDocument{\npthousandsep{,\hskip .05em plus .01em minus .01em}} \usepackage[pdfencoding=pdfdoc,bookmarks=true]{hyperref} - \hypersetup{% linktoc=all,% breaklinks=true,% -hidelinks,% +colorlinks=true,% +urlcolor=niceone,% +linkcolor=blue,% pdfauthor={Jean-Fran\c cois Burnol},% pdftitle={The xint bundle},% pdfsubject={Arithmetic with TeX},% @@ -276,35 +341,51 @@ pdfstartview=FitH,% pdfpagemode=UseOutlines} -%---- a macro to manually have some margin note -\def\MyMarginNote #1{\vadjust{\vskip-\dp\strutbox - \hbox{\smash{\color{niceone}\normalfont\strut - \llap{\small #1\ $\to$\ - }}}\vskip\dp\strutbox }\strut{}} +%---- \MyMarginNote: a simple macro for some margin notes with no fuss +\makeatletter +\def\MyMarginNote {\@ifnextchar[\@MyMarginNote{\@MyMarginNote[]}}% +\def\@MyMarginNote [#1]#2{% + \vadjust{\vskip-\dp\strutbox + \smash{\hbox to 0pt + {\color{PineGreen}\normalfont\small + \hsize 1.5cm\rightskip.5cm minus.5cm + \hss\vtop{\noindent #2}\ $\to$#1\ }}% + \vskip\dp\strutbox }\strut{}} +\def\MyMarginNoteWithBrace #1{% + \vadjust{\vskip-\dp\strutbox + \smash{\hbox to 0pt + {\color{PineGreen}\normalfont\small + \hss #1\ $\Bigg\{$\ }}% + \vskip\dp\strutbox }\strut{}} +\def\IMPORTANT {\MyMarginNoteWithBrace {IMPORTANT!}} +\makeatother +%---- \centeredeline: OUR OWN LITTLE MACRO FOR CENTERING LINES -%---- OUR OWN LITTLE MACRO FOR CENTERING LINES -\makeatletter % 7 mars 2013 % This macro allows to conveniently center a line inside a paragraph and still % use therein \verb or other commands changing catcodes. % A proposito, the \LaTeX \centerline uses \hsize and not \linewidth ! % (which in my humble opinion is bad) +% \ignorespaces ajouté le 9 juin. Cela m'aurait évité des dizaines de % lorsque +% plusieurs \centeredline se suivent (car on reste en mode horizontal si on y +% est au début). + +\makeatletter \newcommand*\centeredline {% \ifhmode \\\relax - \def\centeredline@{\hss\egroup\hskip\z@skip }% + \def\centeredline@{\hss\egroup\hskip\z@skip\ignorespaces }% \else \def\centeredline@{\hss\egroup }% \fi \afterassignment\@centeredline \let\next=} \def\@centeredline -{\hbox to \linewidth \bgroup \hss \bgroup \aftergroup\centeredline@ } + {\hbox to \linewidth \bgroup \hss \bgroup \aftergroup\centeredline@ } \makeatother %---- MODIFIED \verb, and verbatim like `environments' FITS BETTER OUR USE OF IT -\makeatletter % le \verb de doc.sty est très chiant car il a retiré \verbatim@font pour mettre % un \ttfamily hard-coded à la place. [en fin de compte j'utilise dorénavant le % vocable \MicroFont plutôt que \verbatim@font] @@ -348,9 +429,16 @@ pdfpagemode=UseOutlines} % % Pour les verbatim dans la partie user manual, je fais une variante \dverb, qui % elle respecte les lignes, en utilisant \obeylines. -% +% +% 8 juin: dans \dverb et aussi dans les shortverb, & est commentaire et * +% est actif et fait \lowast (\makestarlowast). J'utilisais avant ~ comme +% caractère actif dans les shortverbs mais je n'en ai pas besoin finalement, +% c'est plus simple avec un * actif. +% \def\MicroFont {\ttfamily } \def\MacroFont {\ttfamily\baselineskip12pt\relax} +\makeatletter + % modif de \do@noligs: \char`#1} --> \char`#1 } \def\do@noligs #1% {% @@ -358,19 +446,23 @@ pdfpagemode=UseOutlines} \begingroup \lccode `\~=`#1\relax \lowercase {\endgroup \def ~{\leavevmode \kern \z@ \char `#1 }}% } +% \makestarlowast ajouté le 8 juin \def\verb {% \relax \ifmmode\hbox\else\leavevmode\null\fi \bgroup \MicroFont \let\do\do@noligs \verbatim@nolig@list \let\do\@makeother \dospecials - \catcode32 10 \catcode`\~ 0 \@jfverb + \catcode32 10 \makestarlowast \catcode`\& 14 \@jfverb } \def\@jfverb #1{\catcode`#1\active\lccode`\~`#1\lowercase{\let~\egroup}} % ATTENTION! % \def~{\\\relax} cause des problèmes infinis. Donc je vais simplement utiliser % dans les parties commentées du code $\ puisque $ a catcode 0. -% attention à [, donc $\$relax en un endroit. +% attention à [, donc $\$relax en un endroit. +% Le choix de $ est ok, car comme c'est dans des parties commentées, le mode +% docTeX de emacs ne fait pas de choses pénibles au-niveau de la coloration +% syntaxique. \long\def\lverb % pour utilisation dans la partie implémentation {% \relax\par\smallskip\noindent\null @@ -402,7 +494,7 @@ pdfpagemode=UseOutlines} \def\par{\@@par\leavevmode\null}% \let\do\do@noligs \verbatim@nolig@list \let\do\@makeother \dospecials - \catcode`\& 14 + \catcode`\& 14 \makestarlowast \aftergroup\vskip\aftergroup-\aftergroup\baselineskip \aftergroup\smallskip \aftergroup\noindent\aftergroup\ignorespaces @@ -412,9 +504,13 @@ pdfpagemode=UseOutlines} % Mais j'ai besoin d'un mode verbatim différent pour les nombres car je % ne veux pas passer en mode mathématique (que j'aime de moins en moins) et je % ne veux pas les 0 du txtt pour cela. Comme je n'utilise pas de tabulation, je -% vais prendre & +% vais prendre &. +% Hmm, finalement je supporte de moins en moins les chiffres du roman. J'ai un +% peu de mal à me mettre d'accord sur un style uni de présentation. +% Update 8 juin: finalement je me décide ici aussi pour utiliser lmtt +% Donc dans &..& c'est comme dans \digitstt. Très bien. \catcode`\& 13 -\def&{\begingroup +\def&{\begingroup\fontfamily{lmtt}\selectfont \let\do\@makeother\dospecials \catcode`\& 13 \@jfendshrtverb } @@ -422,14 +518,13 @@ pdfpagemode=UseOutlines} \makeatother % Note: il n'y a plus de \hyphenchar-1 dans le \DeclareFontFamily de t1txtt -% ATTENTION CEPENDANT À CE QUI SE PASSE EN CAS DE CHANGEMENT DE TAILLE +% MAIS ATTENTION CEPENDANT À CE QUI SE PASSE EN CAS DE CHANGEMENT DE TAILLE % 11 mai 2013: j'utilise dorénavant _ là où avant c'était @ \catcode`\_=11 \def\csa_aux #1{\ttfamily\hyphenchar\font45 \char`\\#1\endgroup } - -\def\csb_aux #1{\hyperref[#1]{\color{blue}\ttfamily +\def\csb_aux #1{\hyperref[#1]{\ttfamily \hyphenchar\font45 \char`\\#1}\endgroup } \DeclareRobustCommand\csa {\begingroup\catcode`\_=11 \csa_aux } @@ -439,19 +534,19 @@ pdfpagemode=UseOutlines} \newcommand\csh[1]{\texorpdfstring{\csa{#1}}{\textbackslash #1}} \newcommand\csbh[1]{\texorpdfstring{\csbnolk{#1}}{\textbackslash #1}} -\catcode`\_=8 - -\def\xintpackagenamedef #1% +\def\XINT_tmp_def #1% {% \expandafter\def\csname #1name\endcsname - {\texorpdfstring + {\texorpdfstring {{\color{joli}\ttfamily\hyphenchar\font45 \bfseries #1}} {#1}% - \xspace }% + \xspace }% }% -\xintApplyUnbraced\xintpackagenamedef - {{xint}{xintgcd}{xintfrac}{xintseries}{xintcfrac}{xintexpr}} +\xintApplyUnbraced\XINT_tmp_def + {{xint}{xintbinhex}{xintgcd}{xintfrac}{xintseries}{xintcfrac}{xintexpr}} +\let\XINT_tmp_def\empty +\catcode`\_=8 \frenchspacing \renewcommand\familydefault\sfdefault @@ -467,22 +562,28 @@ pdfpagemode=UseOutlines} {\expandafter\expandafter\expandafter \allowsplits #1\relax }% Expands twice before printing. +%--- counts used in particular in the samples from the documentation of the +% xintseries.sty package \newcount\cnta \newcount\cntb -\newcommand\lowast{\raisebox{-.25\height}{*}} -% to be used as ~lowast in my short verbs +\newcount\cntc -\begin{document} -\thispagestyle{empty} -\rmfamily +%--- printing (systematically) * in a lowered position in the various verbatim +% blocks using txtt. +\def\lowast{\raisebox{-.25\height}{*}} +\begingroup + \catcode`* 13 + \gdef\makestarlowast {\let*\lowast\catcode`\*\active}% +\endgroup +\begin{document}\thispagestyle{empty}\rmfamily \pdfbookmark[1]{Title page}{TOP} {\normalfont\Large\parindent0pt \parfillskip 0pt\relax \leftskip 2cm plus 1fil \rightskip 2cm plus 1fil The \xintname bundle: \xintname, \xintfracname, \xintexprname, - \xintgcdname, \xintseriesname and \xintcfracname.\par}% + \xintbinhexname, \xintgcdname, \xintseriesname and \xintcfracname.\par}% {\centering \textsc{Jean-François Burnol}\par \footnotesize \ttfamily @@ -493,12 +594,11 @@ pdfpagemode=UseOutlines} } \begin{abstract} - The \xintname package implements with expandable \TeX{} macros - the basic arithmetic operations of addition, subtraction, - multiplication and division, as applied to arbitrarily long - numbers represented as chains of digits with an optional minus - sign. The \xintfracname package extends the scope of \xintname to - fractional numbers of arbitrary sizes. + The \xintname package implements with expandable \TeX{} macros the basic + arithmetic operations of addition, subtraction, multiplication and division, + applied to arbitrarily long numbers represented as chains of digits with an + optional minus sign. The \xintfracname package extends the scope of \xintname + to fractional numbers with arbitrarily long numerators and denominators. \xintexprname provides an expandable parser |\xintexpr . . . \relax| of expressions constructed with decimal numbers, fractions, numbers in @@ -506,11 +606,12 @@ pdfpagemode=UseOutlines} sign prefixes, factorial symbol, and sub-expressions or macros expanding to the previous items. - \xintseriesname provides some basic functionality for computing in an - expandable manner partial sums of series and power series with fractional - coefficients. The \xintgcdname package provides implementations of the - Euclidean algorithm and of its typesetting. And \xintcfracname deals with - the computation of continued fractions. + The \xintbinhexname package is for conversions to and from binary and + hexadecimal bases, \xintseriesname provides some basic functionality for + computing in an expandable manner partial sums of series and power series with + fractional coefficients, \xintgcdname implements the Euclidean algorithm and + its typesetting, and \xintcfracname deals with the computation of continued + fractions. Most macros, and all of those doing computations, work purely by expansion without assignments, and may thus be used almost everywhere in \TeX{}. @@ -520,19 +621,55 @@ pdfpagemode=UseOutlines} load the package components. \end{abstract} +\setcounter{tocdepth}{2} + \tableofcontents +\FutureTOCsDoNotObeyInnerTocdepth + +\clearpage + \section{Presentation} -\subsection{Latest} +\subsection{Recent changes} -Release |1.07| brings important additions: +Release |1.08b|: +\begin{itemize} +\item Correction of a problem with spaces inside |\xintexpr|-essions. +\item Additional improvements to the handling of floating point numbers. +\item The macros of \xintfracname allow to use count registers in their + arguments in ways which were not previously documented. See + \hyperlink{useofcount}{Use of count registers}. +\end{itemize} + +\noindent Release |1.08a|: +\begin{itemize} +\item Improved efficiency of the basic conversion from exact + fractions to floating point numbers, + with ensuing speed gains especially for the power function macros + \csb{xintFloatPow} and \csb{xintFloatPower}, +\item Better management by the \xintfracname macros \csb{xintCmp}, + \csb{xintMax}, \csb{xintMin} and \csb{xintGeq} of inputs having big powers + of ten in them. +\item Macros for floating point numbers added to the \xintseriesname package. +\end{itemize} + +\noindent Release |1.08|: +\begin{itemize} +\item Extraction of square roots, for floating point numbers + (\csb{xintFloatSqrt}), and also in + a version adapted to integers (\csb{xintiSqrt}). +\item New package \xintbinhexname providing \hyperref[sec:combinhex]{conversion + routines} to and from binary and hexadecimal bases. +\end{itemize} + +\noindent Release |1.07|: \begin{itemize} -\item The \xintfracname macros now recognize numbers written in scientific - notation, and the \csb{xintFloat} command outputs its argument with a given - number |D| of significant figures. The value of |D| is either given as - optional argument to \csb{xintFloat} or set with |\xintDigits := D;|. The - default value is |16|. +\item The \xintfracname macros accept numbers written in scientific notation, + the \csb{xintFloat} command serves to output its argument with a given number + |D| of significant figures. The value of |D| is either given as optional + argument to \csb{xintFloat} or set with |\xintDigits := D;|. The default value + is |16|. \item The \xintexprname package is a new core constituent (which loads automatically \xintfracname and \xintname) and implements the expandable expanding parsers \centeredline{{\color{blue}|\xintexpr . . . \relax|}, @@ -544,105 +681,185 @@ Release |1.07| brings important additions: according to the current value of \csb{xintDigits}. Within an |\xintexpr|-ession the binary operators are computed exactly. \end{itemize} -Important aspects related to the use of |\xintexpr| and |\xintfloatexpr| are -explained in the documentation. In particular the above forms are usable as -sub-expressions but not directly printable; for this one has |\xinttheexpr| -and |\xintthefloatexpr|, or |\xintthe\xintexpr| and -|\xintthe\xintfloatexpr|. The floating point precision |D| is set (this is a -local assignment to a |\mathchar| variable) with -|\xintDigits := D;| and queried with |\xinttheDigits|. It may be set to anything up to - |32768|.\footnote{but values higher than 100 or 200 will - presumably give too - slow evaluations.} The macro incarnations of the binary operations admit an - optional argument which will replace pointwise |D|; this argument may - exceed the |32678| bound. +% The |\xintexpr..\relax| and |\xintfloatexpr..\relax| are usable as +% sub-expressions but not directly printable; for this one has |\xinttheexpr| +% and +% |\xintthefloatexpr|, or equivalently |\xintthe\xintexpr| and +% |\xintthe\xintfloatexpr|. +The floating point precision |D| is set (this is a +local assignment to a |\mathchar| variable) with |\xintDigits := D;| and queried +with |\xinttheDigits|. It may be set to anything up to |32767|.\footnote{but + values higher than 100 or 200 will presumably give too slow evaluations.} The +macro incarnations of the binary operations admit an optional argument which +will replace pointwise |D|; this argument may exceed the |32767| bound. + +To write the |\xintexpr| parser I benefited from the commented source of the +\LaTeX3 parser; the |\xintexpr| parser has its own features and peculiarities. +See \hyperref[sec:comexpr]{its documentation}. + +\subsection{Overview} + +The main characteristics are: +\begin{enumerate} +\item exact algebra on arbitrarily big numbers, integers as well as fractions, +\item floating point variants with user-chosen precision, +\item implemented via macros compatible with expansion-only + context. +\end{enumerate} -\subsection{Missing things} - +`Arbitrarily big': this means with less than + |2^31-1|\digitstt{=\number"7FFFFFFF} digits, as most of the macros will + have to compute the length of the inputs and these lengths must be treatable + as \TeX{} integers, which are at most \digitstt{\number "7FFFFFFF} + in absolute value. + This is a distant theoretical upper bound, +the true limitation is from the \emph{time} taken by the +expansion-compatible algorithms, this will be commented upon soon. + +As just recalled, ten-digits numbers starting with a &3& already exceed the +\TeX{} bound on integers; and \TeX{} does not have a native processing of +floating point numbers (multiplication by a decimal number of a dimension +register is allowed --- this is used for example by the +\href{http://www.ctan.org/tex-archive/graphics/pgf/base}{pgf} basic math +engine.) + +\TeX{} elementary operations on numbers are done via the non-expandable +\emph{advance, multiply, \emph{and} divide} assignments. This was changed with +\eTeX{}'s |\numexpr| which does expandable computations using standard infix +notations with \TeX{} integers. But \eTeX{} did not modify the \TeX{} bound on +acceptable integers, and did not add floating point support. + +The \href{http://www.ctan.org/pkg/bigintcalc}{bigintcalc} package by +\textsc{Heiko Oberdiek} provided expandable operations (using some of |\numexpr| +possibilities, when available) on arbitrarily big integers, beyond the \TeX{} +bound. The present package does this again, using more of |\numexpr| (\xintname +requires the \eTeX{} extensions) for higher speed, and also on fractions, not +only integers. Arbitrary precision floating points operations are a derivative, +and not the initial design goal.\footnote{currently (|v1.08|), the only + non-elementary operation implemented for floating point numbers is the + square-root extraction; furthermore no |NaN|'s nor error traps has been + implemented, only the notion of `scientific notation with a given number of + significant figures'.}${}^{\text{,\,}}$\footnote{multiplication of two floats + with |P=\string\xinttheDigits| digits is first done exactly then rounded to + |P| digits, rather than using a specially tailored multiplication for floating + point numbers which would be more efficient (it is a waste to evaluate fully + the multiplication result with |2P| or |2P-1| digits.)} + +The \LaTeX3 project has implemented +expandably floating-point computations with 16 significant figures +(\href{http://www.ctan.org/tex-archive/macros/latex/contrib/l3kernel}{l3fp}), +including special functions such as exp, log, sine and cosine. -Although the latest release now implements arbitrary precision -floating-point operations, and an expandable parser, it does not -implement yet a mathematical library, in particular fractional powers, -logarithm or trigonometric functions. +The \xintname package can be used for 24, 40, etc... significant figures but one +rather quickly (not much beyond 100 figures perhaps) hits against a `wall' +created by the constraint of expandability: currently, multiplying out two +one-hundred digits numbers takes circa 80 or 90 times longer than for two +ten-digits numbers, which is reasonable, but multiplying out two one-thousand +digits numbers takes more than 500 times longer than for two one hundred-digits +numbers. This shows that the algorithm is drifting from quadratic to cubic in +that range. On my laptop multiplication of two 1000-digits numbers takes some +seconds, so it can not be done routinely in a document.\footnote{without + entering + into too much technical details, the + source of this `wall' is that when dealing with two long operands, when one + wants to pick some digits from the second one, one has to jump above all + digits constituting the first one, which can not be stored away: expandability + forbids assignments to memory storage. One may envision some sophisticated + schemes, dealing with this problem in less naive ways, trying to move big + chunks of data higher up in the input stream and come back to it later, + etc...; but each `better' algorithm adds overhead for the smaller inputs. For + example, I have another version of addition which is twice faster on inputs + with 500 digits or more, but it is slightly less efficient for 50 digits or + less. This `wall' dissuaded me to look into implementing `intelligent' + multiplication which would be sub-quadratic in a model where storing and + retrieving from memory do not cost much.} + +The conclusion perhaps could be that it is in the end lucky that the speed gains +brought by \xintname for expandable operations on big numbers do open some +non-empty range of applicability in terms of the number of kept digits for +routine floating point operations. + +The second conclusion, somewhat depressing after all the hard work, is +that if one really wants to do computations with \emph{hundreds} of digits, one +should drop the expandability requirement. And indeed, as clearly +demonstrated long ago by the \href{http://www.ctan.org/pkg/pi}{pi + computing file} by \textsc{D. Roegel} one can program \TeX{} to +compute with many digits at a much higher speed than what \xintname +achieves: but, direct access to memory storage in one form or another +seems a necessity for this kind of speed and one has to renounce at the +complete expandability.\footnote{I could, naturally, be proven + wrong!}\,\footnote{The Lua\TeX{} project possibly makes endeavours + such as \xintname appear even more insane that they are, in truth.} -% It is doubtful that I will engage into writing such a thing as the window -% left open in terms of speed of computation from the constraint of -% expandability is rather narrow. Up to a few dozen digits of floating point -% precision perhaps, perhaps up to one hundred digits, but not much more (the -% package is usable for one-shot, expensive, computations, though). And the -% initial motivation was more into exact arithmetic operations with -% (reasonably) arbitrarily long numbers. -% Besides, +\subsection{Missing things} -The \LaTeX3 project has implemented expandably floating-point -computations with 16 significant figures -(\href{http://www.ctan.org/tex-archive/macros/latex/contrib/l3kernel}{\color{niceone}l3fp}), -including special functions such as exp, log, sine and cosine. -I have benefited from the commented source of the \LaTeX3 parser; the -|\xintexpr| parser has its own features and peculiarities. See -\hyperref[sec:comexpr]{\color{niceone}its documentation}. +`Arbitrary-precision' floating-point +operations are currently limited to the basic four operations, the power +function with integer exponent, and the extraction of square-roots. \subsection{Some examples} -The main initial goal is to allow computations with integers and fractions -of arbitrary sizes.\footnote{Here and elsewhere, ``arbitrarily big'' means - roughly numbers with numerators and denominators having strictly less than - 2\string^\string{31\string}=2147483648 digits. Memory constraints from the - \TeX{} engines presumably limit more the possible computations; but the - biggest constraint is the one of computation time, related to the - propriety of expandability. As explained in the text multiplying two one - thousand digits numbers is already expensive. On the other hand, floating - point computations are implemented with arbitrary precision, and one can - work comfortably with fifty digits of precision for example. } +The main initial goal is to allow computations with integers and fractions of +arbitrary sizes. + +Here are some examples. The first one uses only the base module \xintname, the +next two require the \xintfracname package, which deals with fractions. Then two +examples with the \xintgcdname package, one with the \xintseriesname package, +and finally a computation with a float. Some inputs are simplified by the use +of the \xintexprname package. -Here are some examples: +% There is also \xintcfracname for continued fractions computations. {\color{magenta}&123456^99&: }\\ -{\color{blue}\csb{xintiPow}|{123456}{99}|}: \printnumber{\xintiPow {123456}{99}} +{\color{Purple}\csa{xintiPow}|{123456}{99}|}: \digitstt{\printnumber{\xintiPow {123456}{99}}} {\color{magenta}1234/56789 with 1500 digits after the decimal point: }\\ -{\color{blue}\csb{xintTrunc}|{1500}{1234/56789}\dots|}: \printnumber {\xintTrunc - {1500}{1234/56789}}\dots +{\color{Purple}\csa{xintTrunc}|{1500}{1234/56789}\dots|}: +\digitstt{\printnumber {\xintTrunc {1500}{1234/56789}}\dots } {\color{magenta}&0.99^{-100}& with 200 digits after the decimal point:}\\ -{\color{blue}\csb{xintTrunc}|{200}{\xinttheexpr .99^-100\relax}\dots|}: -\printnumber{\xintTrunc {200}{\xinttheexpr .99^-100\relax}}\dots +{\color{Purple}\csa{xintTrunc}|{200}{\xinttheexpr .99^-100\relax}\dots|}: +\digitstt{\printnumber{\xintTrunc {200}{\xinttheexpr .99^-100\relax}}\dots } {\color{magenta}Computation of a Bezout identity with |7^200-3^200| and |2^200-1|:}\\ -{\color{blue}|\xintAssign\xintBezout|\\ +{\color{Purple}|\xintAssign\xintBezout|\\ \hspace*{2cm}|{\xintNum{\xinttheexpr 7^200-3^200\relax}}|\\ \hspace*{2cm}|{\xintNum{\xinttheexpr 2^200-1\relax}}\to\A\B\U\V\D|% \centeredline{|\U$\times$(7^200-3^200)+\xintiOpp\V$\times$(2^200-1)=\D|}}% \xintAssign\xintBezout {\xintNum{\xinttheexpr 7^200-3^200\relax}}{\xintNum{\xinttheexpr 2^200-1\relax}}\to\A\B\U\V\D -\printnumber\U$\times$(&7^200-3^200&)+\printnumber{\xintiOpp\V}$\times$(&2^200-1&)=\printnumber\D +\digitstt{\printnumber\U$\times$(&7^200-3^200&)+\printnumber{\xintiOpp\V}$\times$(&2^200-1&)=\printnumber\D } {\color{magenta}The Euclide algorithm applied to \np{179876541573} and \np{66172838904}:}\footnote{this example is computed tremendously faster than the other ones, but we had to limit the space taken by the output.}\\ -{\color{blue}|\xintTypesetEuclideAlgorithm {179876541573}{66172838904}|} +{\color{Purple}|\xintTypesetEuclideAlgorithm {179876541573}{66172838904}|} \xintTypesetEuclideAlgorithm {179876541573}{66172838904} \smallskip {\color{magenta}$\sum_{n=1}^{500} (4n^2 - 9)^{-2}$ with each term rounded to - twelve digits, and the sum to nine digits:} {\color{blue}% + twelve digits, and the sum to nine digits:} {\color{Purple}% |\def\coeff #1%|\\ | {\xintiRound {12}{1/\xintiSqr{\the\numexpr 4*#1*#1-9\relax }[0]}}|\\ |\xintRound {9}{\xintiSeries {1}{500}{\coeff}[-12]}|:} \def\coeff #1% -{\xintiRound {12}{1/\xintiSqr{\the\numexpr 4*#1*#1-9\relax }[0]}} \xintRound -{9}{\xintiSeries {1}{500}{\coeff}[-12]}\endgraf The complete series, extended to +{\xintiRound {12}{1/\xintiSqr{\the\numexpr 4*#1*#1-9\relax }[0]}} +\digitstt{\xintRound {9}{\xintiSeries {1}{500}{\coeff}[-12]}}\endgraf + +The complete series, extended to infinity, has value -$\frac{\pi^2}{144}-\frac1{162}={}$\np{0.06236607994583659534684445}\dots\,% +$\frac{\pi^2}{144}-\frac1{162}={}$% +\digitstt{\np{0.06236607994583659534684445}\dots}\,% \footnote{\label{fn:np}This number is typeset using the - \href{http://www.ctan.org/pkg/numprint}{\color{niceone}numprint} package, with - \texttt{\detokenize{\npthousandsep{,\hskip .05em plus .01em minus .01em}}}. But the breaking accross + \href{http://www.ctan.org/pkg/numprint}{numprint} package, with + \texttt{\detokenize{\npthousandsep{,\hskip .05em plus .01em minus .01em}}}. + But the breaking accross lines works only in text mode. The number itself was (of course...) computed initially with \xintname, with 30 digits of $\pi$ as input. See - \hyperref[ssec:Machin]{\color{niceone}{how \xintname may compute $\pi$ + \hyperref[ssec:Machin]{{how \xintname may compute $\pi$ from scratch}}.} I also used (this is a lengthier computation than the one above) \xintseriesname to evaluate the sum with \np{100000} terms, obtaining 16 @@ -650,24 +867,25 @@ correct decimal digits for the complete sum. The coefficient macro must be redefined to avoid a |\numexpr| overflow, as |\numexpr| inputs must not exceed &2^31-1&; my choice was: -{\color{blue}\dverb|& +{\color{Purple}\dverb|& \def\coeff #1% {\xintiRound {22}{1/\xintiSqr{\xintiMul{\the\numexpr 2*#1-3\relax} {\the\numexpr 2*#1+3\relax}}[0]}} -|} -The first example uses only the base module \xintname, the next two require -loading also the \xintfracname package, which deals with fractions. Then two -examples with the \xintgcdname package, and finally one with the -\xintseriesname package, for partial sums of series with fractional -coefficients. There is also \xintcfracname for continued fractions computations. +|}% + + +{\color{magenta}Computation of $2^{\np{999999999}}$ with |24| significant + figures:}\\ +{\color{Purple}|\xintFloatPow[24] {2}{999999999}|:} +\digitstt{\xintFloatPow[24] {2}{999999999}} To see more of \xintname in action, jump to the -{\color{niceone}\autoref{sec:series}} describing the commands of the +{\autoref{sec:series}} describing the commands of the \xintseriesname{} package, especially as illustrated with the -\hyperref[ssec:Machin]{\color{niceone}{traditional computations of $\pi$ +\hyperref[ssec:Machin]{{traditional computations of $\pi$ and $\log 2$}}, or also see the -{\color{niceone}\hyperlink{e-convergents}{computation of the convergents +{\hyperlink{e-convergents}{computation of the convergents of $e$}} made with the \xintcfracname package. Note that almost all of the computational results interspersed through the @@ -675,47 +893,6 @@ documentation are not hard-coded in the source of the document but just written there using the package macros, and were selected to not impact too much the compilation time. - - -\subsection{Expandability, (in)-efficiency} - -For some initially circumstantial reasons (related to the origins of the -package) all macros performing computations are -compatible with an expansion-only context. This programming constraint of -expandability weighs in a lot on the computation time as the macros may have to -shuffle around data containing hundreds of tokens: our current implementation -of addition doesn't even achieve linear computation time! - -For addition, I try to optimize things for the 50-500 digits range. I have a -variant of addition which is twice faster on numbers with 1000 digits, but it is -slower than the original for numbers with less than 200 digits, and adding to -the code a fork to choose what to do would mean overhead; besides it wouldn't be -that easy to use this variant of addition in the other routines such as -multiplication and division. And multiplication is anyhow too slow on numbers -with 1000 digits, even dividing the time by two would not be enough. - -Analogously to the not even linear addition, multiplication is worse than -quadratic. Same causes, same effects. It is about cubic in the 100-1000 -digits range: on my laptop, with release |1.04| of the bundle, squaring a -randomly chosen number with 200 digits takes about 4 hundredths of a -second, and squaring a 400 digits number about a quarter of a second. But -squaring a 500 digits number is about 1.9 times as costly as one with 400 -digits, and squaring a 1000 digits number is 8 times more expensive than for a -500 digits number (about 3.5 seconds). Implementation of a Gauss-Karatsuba -scheme for intelligent multiplication has not been attempted so far. This kind -of thing is motivating when one has instant memory access! - -As clearly demonstrated long ago by the -\href{http://www.ctan.org/pkg/pi}{\color{niceone}pi computing file} by -\textsc{D. Roegel} one can program \TeX{} to compute with many digits at a -much higher speed than what \xintname achieves: but, direct access to memory -storage in one form or another seems a necessity for this kind of speed -and one has to renounce at the -complete expandability.\footnote{I could, naturally, - be proven wrong!}\,\footnote{The Lua\TeX{} project possibly makes endeavours - such as \xintname appear even more insane that they are, in truth.} - - \subsection{Origins of the package} Package |bigintcalc| by \textsc{Heiko Oberdiek} already @@ -761,6 +938,8 @@ The present package is the result of this initial questioning. \section{Expansions} +\SetInnerTocdepthTo {1} + Except for some specific macros dealing with assignments or typesetting, the bundle macros all work in expansion-only context. For example, with the following code snippet within |myfile.tex|: @@ -783,7 +962,7 @@ They expand `fully' (the first token of) their arguments so that they can be arbitrarily chained. Hence \centeredline{% |\xintLen{\xintQuo{\xintPow{2}{1000}}{\xintFac{100}}}|} expands in two steps and tells us that &[2^{1000}/100!]& has {\y} digits. This is not so many, let us -print them here: \printnumber\x. +print them here: \digitstt{\printnumber\x}. For the sake of typesetting this documentation and not have big numbers extend into the margin and go beyond the page physical limits, I use @@ -798,17 +977,17 @@ these commands (not provided by the package): The |\printnumber| macro is not part of the package and would need additional thinking for more general use.\footnote{as explained in - \hyperref[fn:np]{\color{niceone}a previous footnote}, + \hyperref[fn:np]{a previous footnote}, the |numprint| package may also be used, in text mode only (as the thousand separator seemingly ends up typeset in a |\string\hbox| when in math mode).} It may be used as |\printnumber {\xintQuo{\xintPow {2}{1000}}{\xintFac{100}}}|, or as |\printnumber\mynumber| if the macro |\mynumber| was previously defined via an |\edef|, as for -example:\centeredline{ |\edef\mynumber {\|\texttt{xintQuo}|{\xintPow +example:\centeredline{ |\edef\mynumber {\xintQuo {\xintPow {2}{1000}}{\xintFac{100}}}|}% or as |\expandafter\printnumber\expandafter{\mynumber}|, if the macro |\mynumber| is - defined by a |\newcommand| or a |\def| (see below {\color{niceone}\autoref{item:xpxp}} for the + defined by a |\newcommand| or a |\def| (see below {\autoref{item:xpxp}} for the underlying expansion issue; adding four |\expandafter|'s to |\printnumber| would allow to use it directly as |\printnumber\mynumber| with a |\mynumber| itself defined via a |\def| or |\newcommand|). @@ -819,7 +998,7 @@ the decimal expansion of &0.7^{-25}&:\footnote{the |\string\np| typesetting macro is from the |numprint| package.} \centeredline{|\np {\xintTrunc {300}{\xinttheexpr .7^-25\relax}}\dots|} -\np {\xintTrunc {300}{\xinttheexpr .7^-25\relax}}\dots +\digitstt{\np {\xintTrunc {300}{\xinttheexpr .7^-25\relax}}\dots } This computation uses the macro \csb{xintTrunc} from package \xintfracname wich extends to fractions the basic arithmetic operations defined for @@ -832,8 +1011,8 @@ would rather use floating mode: \centeredline{|\xintDigits:=20; \np{\xintthefloatexpr .7123045678952^-243\relax}|}% \xintDigits:=20;% -\centeredline{|.7123045678952^-243| = \texttt{\np{\xintthefloatexpr - .7123045678952^-243\relax }}} +\centeredline{|.7123045678952^-243|${}\approx{}$% +\digitstt{\np{\xintthefloatexpr .7123045678952^-243\relax }}} % 6.342,022,117,488,416,127,3 10^35 % maple n'aime pas ^-243 il veut les parenthèses, bon et il donne, en Digits @@ -857,9 +1036,9 @@ Important points, to be noted, related to the expansion of arguments: exceeds the \TeX{} bounds. \begingroup\slshape - The |1.07| novelty\MyMarginNote{New with |1.07|} \csb{xinttheexpr} has brought a solution: here one - would write |\xinttheexpr \x+\x\y\relax|, or - |\xintAdd\x{\xinttheexpr\x\y\relax}|.\hfill + The |1.07| novelty\MyMarginNote{New with |1.07|} \csb{xinttheexpr} has brought + a solution: here one would write |\xinttheexpr \x+\x\y\relax|, or + |\xintAdd\x{\xinttheexpr\x\y\relax}|.\hfill \endgroup \item Unfortunately, after |\def\x {12}|, one can not use just @@ -887,7 +1066,7 @@ Important points, to be noted, related to the expansion of arguments: with the package release |1.06| allows to use this inside other package `primitives' or also similar macros: {|\xintAdd - {\AplusBC {1}{2}{3}}{4}|} does work and returns \texttt{\xintAdd + {\AplusBC {1}{2}{3}}{4}|} does work and returns \digitstt{\xintAdd {\AplusBC {1}{2}{3}}{4}}.\footnote{this strange thing is because this document uses \xintfracname, and we have printed the raw output of addition which is automatically a fraction.} @@ -908,17 +1087,17 @@ Important points, to be noted, related to the expansion of arguments: \hspace*{1cm}|\def\aplusbc #1#2#3{\xintadd {#1}{\xintMul {#2}{#3}}}|\par \hspace*{1cm}|\def\AplusBC {\romannumeral0\aplusbc}|\par Or, for people using the \LaTeX{} vocabulary:\par - \hspace*{1cm}|\newcommand~lowast{\aplusbc}[3]{\xintadd {#1}{\xintMul + \hspace*{1cm}|\newcommand*{\aplusbc}[3]{\xintadd {#1}{\xintMul {#2}{#3}}}|\par - \hspace*{1cm}|\newcommand~lowast{\AplusBC}{\romannumeral0\aplusbc}|\par + \hspace*{1cm}|\newcommand*{\AplusBC}{\romannumeral0\aplusbc}|\par This then allows further definitions of macros expanding in two steps only, such as:\par |\def\aplusbcsquared #1#2#3{\aplusbc {#1}{#2}{\xintSqr{#3}}}|\par |\def\AplusBCSquared {\romannumeral0\aplusbcsquared}|\par - |\newcommand~lowast\myalgebra [6]{\xintmul {\AplusBC {#1}{#2}{#3}}{\AplusBC + |\newcommand*\myalgebra [6]{\xintmul {\AplusBC {#1}{#2}{#3}}{\AplusBC {#4}{#5}{#6}}}|\par - |\newcommand~lowast\MyAlgebra {\romannumeral0\myalgebra}|\par + |\newcommand*\MyAlgebra {\romannumeral0\myalgebra}|\par \end{enumerate} The |\romannumeral0| things above look like an invitation to hacker's @@ -932,37 +1111,17 @@ Release |1.07| has the \csb{xintNewExpr} command\MyMarginNote{New with \centeredline{|\xintNewExpr\AplusBC[3]{_1+_2*_3}|} creates the |\AplusBC| macro doing the above and expanding in two expansion steps. - Those macro arguments \MyMarginNote{New with |1.06|} which are - intrinsically constrained to obey the \TeX{} bounds on integers (see the next - section) are now systematically fed to a |\numexpr|, hence they will be - subjected to a complete expansion, registers are allowed, and things such as - |\mycount+\myothercount*17| become admissible arguments. - - This applies to - the argument of the factorial function, the exponent in the power - function, the number of digits to truncate or round with, and in various - other cases. - - Note however that inside an |\xintexpr|-ession count registers for - the\MyMarginNote{New with |1.07|} exponent of the power function or the - argument of the factorial are not accepted (they are, if prefixed with - |\the|); on the other hand these arguments may be fractions, as long as - they turn out to be in truth integers after simplification. And the - exponent in the power function in floating expressions may even exceed the - \TeX{} bounds on integers. -\section {Inputs and outputs} +\section {Inputs and outputs}\label{sec:inputs} The core bundle constituents are \xintname, \xintfracname, \xintexprname, each one loading its predecessor. The base constituent \xintname only deals with integers, of arbitrary sizes, and apart from its macro \csb{xintNum}, the input format is rather strict. Then \xintfracname extends the scope to -fractions (automatically normalizing leading signs and zeros using -\csb{xintNum} for both numerator and denominator); numerators and +fractions: numerators and denominators are separated by a forward slash and may contain each an -optional fractional part after the decimal mark (which has to be a dot). -Now with |1.07| they also may each end with an optional scientific part (a -lowercase e followed by a signed integer). +optional fractional part after the decimal mark (which has to be a dot) and a +scientific part\MyMarginNote{New with |1.07|} (with a lower case |e|). The numeric arguments to the bundle macros may be of various types, @@ -975,14 +1134,19 @@ extending in generality: index something. It is also the case for the exponent in the power function and for the argument to the factorial function. The bounds have been (arbitrarily) lowered to \np{999999999} and \np{999999} respectively for the - latter cases. When the argument exceeds the \TeX{} bound (either positively or - negatively), an error will originate from a \csa{numexpr} expression and it - may sometimes be followed by a more specific error `message' from a package - macro. + latter cases.\footnote{the float power function limits the exponent to the + \TeX{} bound, not |999999999|, and it has a variant with no imposed limit on + the exponent; but the result of the computation must in all cases be + representable with a power of ten exponent obeying the \TeX{} bound.} When + the argument exceeds the \TeX{} bound (either positively or negatively), an + error will originate from a \csa{numexpr} expression and it may sometimes be + followed by a more specific error `message' from a package macro. \item `long' integers, which are the bread and butter of the package commands. They are signed integers with an illimited number of digits. Theoretically though, most of the macros require that the number of digits - itself be less than the \TeX-\csa{numexpr} bound (more precisely &2^31-9&). + itself be less than the \TeX-\csa{numexpr} bound.\footnote{and to be very + precise, less than the \TeX{} bound minus eight, due to the way the length + is evaluated.} Some macros, such as addition when \xintfracname has not been loaded, do not measure first the length of their arguments and could theoretically be used with `gigantic' integers with a larger number of digits. However memory @@ -1000,16 +1164,19 @@ extending in generality: \end{enumerate} \begin{framed} - \TeX{}'s count registers cannot serve directly as arguments to the package - macros - accepting `long numbers' or fractions on input: they must be prefixed by - |\the| or |\number|. The same for \csa{numexpr} expressions. However,\strut{} - count registers and |\numexpr| expressions\vadjust{\vskip-\dp\strutbox - \hbox{\smash{\color{niceone}\normalfont\strut - \llap{\small New with |1.06|\ $\to$\kern\parindent - }}}\vskip\dp\strutbox }\strut{} are - allowed in arguments intrinsically - constrained to obey the \TeX{} bounds. + With only package \xintname loaded \TeX{}'s count registers must be prefixed + by |\the| or |\number| inside the arguments to the package macros, except in + places (argument of the factorial, exponent of the power function, ...) where + the documentation of the macro says otherwise. + + With the macros\MyMarginNote[\kern\FrameSep\kern\FrameRule]{Not previously + documented} of \xintfracname (including those of \xintname extended to + fractions) a count register is \emph{accepted} on input, with no need to be + prefixed by |\the| or |\number|. + + Inside |\xinttheexpr...\relax|, count registers must again be prefixed by + |\the| or + |\number| (if they are not arguments to macros of \xintfracname). \end{framed} @@ -1020,10 +1187,10 @@ extending in generality: |1.06|} of their \strut{} arguments, as explained above: only the first token is repeatedly expanded until no more is possible. -On the other hand, this -expansion is a\MyMarginNote{New with |1.06|} for those arguments which -are constrained to obey the \TeX{} bounds on numbers, as they are systematically -inserted inside a |\numexpr...\relax| expression. + On the other hand, this expansion is a\MyMarginNote{New with |1.06|} complete + one for those arguments which are constrained to obey the \TeX{} bounds on + numbers, as they are systematically inserted inside a |\numexpr...\relax| + expression. The allowed input formats for `long numbers' and `fractions' are: @@ -1034,42 +1201,42 @@ The allowed input formats for `long numbers' and `fractions' are: There is a macro \csb{xintNum} which normalizes to this form an input having arbitrarily many minus and plus signs, followed by a string of zeros, then digits:\centeredline{|\xintNum - {+-+-+----++-++----00000000009876543210}|\texttt{=\xintNum + {+-+-+----++-++----00000000009876543210}|\digitstt{=\xintNum {+-+-+----++-++----0000000009876543210}}}% Note that |-0| is not legal input and will confuse \xintname (but not \csa{xintNum} which even accepts an empty input). -\item the extended format is when \xintfracname is loaded. Most macros are then - modified to accept inputs of the form |A/B| (or just |A|), where |A| and |B| - will be automatically given to the normalizing \csb{xintNum} macro. - Additionally, each of |A| and |B| may have an optional decimal point with - digits following it. Here is an example: \centeredline{|\xintAdd +\item the extended format is with \xintfracname is loaded: the macros are + extended from operating on integers to operating on fractions, which are input + as (or expand to) |A/B| (or just an integer |A|), where |A| and |B| will be + automatically given to the sign and zeros normalizing macro \csb{xintNum}. + Each of |A| and |B| may be decimal numbers: with a decimal point and + digits following it. Here is an example: \centeredline{|\xintAdd {+--0367.8920280/-++278.289287}{-109.2882/+270.12898}|}% - Incidentally this evaluates to - \centeredline{{=\z}}% - \centeredline{{=\xintIrr\z{} (irreducible)}}% - \centeredline{{=\xintTrunc {50}{\z}\dots}}% + Incidentally this evaluates to \centeredline{\digitstt{=\z}}% + \centeredline{\digitstt{=\xintIrr\z{} (irreducible)}}% + \centeredline{\digitstt{=\xintTrunc {50}{\z}\dots}}% where the second line was produced with |\xintIrr| and the next with |\xintTrunc {50}| to get fifty digits of the decimal expansion following the - decimal mark. -\item the more extended format comes with release |1.07| of \xintfracname. - Scientific notation is accepted on input both for the numerators and - denominators of fractions, and is produced on output by \csb{xintFloat}: - \centeredline{|\xintAdd{10.1e1}{101.010e3}=|\texttt{\xintAdd{10.1e1}{101.010e3}}}% - \centeredline{|\xintRaw{1.234e5/6.789e3}=|\texttt{\xintRaw{1.234e5/6.789e3}}}% - \centeredline{|\xintFloat[5]{1/66049}=|\texttt{\xintFloat[5]{1/66049}}} + decimal mark. Scientific notation\MyMarginNote{New with |1.07|} is accepted on + input both for the numerators and denominators of fractions, and is produced + on output by \csb{xintFloat}: \centeredline{|\xintAdd{10.1e1}{101.010e3}|% + \digitstt{=\xintAdd{10.1e1}{101.010e3}}}% + + \centeredline{|\xintRaw{1.234e5/6.789e3}|\digitstt{=\xintRaw{1.234e5/6.789e3}}}% + \centeredline{|\xintFloat[24]{1/66049}|\digitstt{=\xintFloat[24]{1/66049}}} \end{enumerate} Of course, even when \xintfracname is loaded, some macros can not treat -fractions on input. With release |1.05| they have, for the most part, been also -extended to accept the relaxed format as long as the denominator turns out to be -a divisor of the numerator (once the decimal points are suitably transformed -into powers of ten). For example it used to be the case with the earlier +fractions on input. Starting with release |1.05| most of them have also been +extended to accept the relaxed format on input as long as the fraction actually +represents an integer. For example it used to be the case with the earlier releases that |\xintQuo {100/2}{12/3}| would not work (the macro \csb{xintQuo} computes a euclidean quotient). It now does, because its arguments are in truth integers. A number can start directly with a decimal point: -\centeredline{|\xintPow{-.3/.7}{11}=|\texttt{\xintPow{-.3/+.7}{11}}}% -\centeredline{|\xinttheexpr (-.3/.7)^11\relax=|\texttt{\xinttheexpr (-.3/.7)^11\relax}} +\centeredline{|\xintPow{-.3/.7}{11}|\digitstt{=\xintPow{-.3/+.7}{11}}}% +\centeredline{|\xinttheexpr (-.3/.7)^11\relax|% + \digitstt{=\xinttheexpr (-.3/.7)^11\relax}} It is also licit to use |\A/\B| as input if each of |\A| and |\B| expands (in the sense previously described) to a ``decimal number'' as examplified above by the numerators and denominators (thus, possibly with a `scientific' exponent @@ -1077,25 +1244,95 @@ part, with a lowercase `e'). Or one may have just one macro |\C| which expands to such a ``fraction with optional decimal points'', or mixed things such as |\A 245/7.77|, where the numerator will be the concatenation of the expansion of |\A| and |245|. But, as explained already |123\A| is a no-go, -\emph{except inside an |\string\xintexpr|-ession of course}! +\emph{except inside an |\string\xintexpr|-ession}! Finally, after the decimal point there may be |eN| where |N| is a positive or negative number (obeying the \TeX{} bounds on integers).\MyMarginNote{New with |1.07|} This `|e|' part (which must be in lowercase, except inside |\xintexpr|-essions) may appear both at the numerator and at the denominator. \centeredline{|\xintRaw - {+--+1253.2782e++--3/---0087.123e---5}=|\texttt{\xintRaw + {+--+1253.2782e++--3/---0087.123e---5}|\digitstt{=\xintRaw {+--+1253.2782e++--3/---0087.123e---5}}} -\medskip - -Loading \xintfracname not only relaxes the format of the inputs; it also -modifies the format of the outputs: except when a fraction is filtered on output -by \csb{xintIrr} (and \csb{xintJrr}) or \csb{xintRawWithZeros}, or by the -truncation or rounding macros, it will always be in the |A/B[n]| form (which -stands for |(A/B)|$\times$|10^n|). The |A| and |B| may end in zeros (\emph{i.e}, -|n| does not represent all powers of ten), and will generally have a common -factor. The denominator |B| is always strictly positive. +\hypertarget{useofcount}{\paragraph{Use of count registers:}} when\MyMarginNote{New + documentation section (|1.08b|)} an argument +to a macro is said in the documentation to have to obey the \TeX{} bound, this +means that it is fed to a |\numexpr...\relax|, hence it is subjected to a +complete expansion which must delivers an integer, and count registers and even +algebraic expressions with them like +|\mycountA+\mycountB*17-\mycountC/12+\mycountD| are admissible arguments (the +slash stands here for the integer (rounded) division done by |\numexpr|). This +applies in particular to the number of digits to truncate or round with, to the +indices of a series partial sum, \dots + +With \xintfracname.sty loaded and for arguments of macros accepting fractions on +inputs, use\MyMarginNote{Not previously documented} of count +registers and even direct algebra with them is possible: a count 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 even possible to have +algebraic expressions, with the limitation (how to overcome it in complete +generality will be explained later) that each of the numerator and +denominator should be expressed with at most \emph{eight} tokens, and the +forward slash symbol must be protected by braces to be used inside the +|\numexpr| and not be interpreted as the fraction slash. Note that |\mycountA| +is +one token but |\count 255| is four tokens. 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). +\centeredline{|\cnta 10 \cntb 35 \xintRaw + {\cnta+\cntb{/}17/1+\cnta*\cntb}|\digitstt{->\cnta 10 \cntb 35 \xintRaw + {\cnta+\cntb{/}17/1+\cnta*\cntb}}} + +This possibility of using directly count registers and even algebraic expression +is only for arguments to macros of \xintfracname: inside |\xintexpr...\relax| +one can not use directly a count register, it must be prefixed by |\the| or +|\number|. And with only \xintname.sty is loaded, the \emph{only} macro allowing +the +above is \csb{xintNum}: +\centeredline{|\cnta 10 \cntb 100 \xintNum + {\cnta+\cntb+\cnta*\cntb}|\digitstt{->\cnta 10 \cntb 100 \xintNum + {\cnta+\cntb+\cnta*\cntb}}} +Note that |\cnta+\cntb+2*\cnta*\cntb| would be too long (it has nine tokens). +Using braces works: +\centeredline{|\cnta 10 \cntb 100 \xintNum + {\cnta+\cntb+{2*\cnta*\cntb}}|\digitstt{->\cnta 10 \cntb 100 \xintNum + {\cnta+\cntb+{2*\cnta*\cntb}}}} +The braces should be used for some sub-part of the expression, not for the +entire thing; alternatively, one can always use |\numexpr {arbitrarily long + expression}\relax| as input: +\dverb|& +\cnta 100 \cntb 10 \cntc 1 +\xintRaw {\numexpr {\cnta*\cnta+\cntb*\cntb+\cntc*\cntc+ + 2*\cnta*\cntb+2*\cnta*\cntc+2*\cntb*\cntc}\relax/% + \numexpr {\cnta*\cnta+\cntb*\cntb+\cntc*\cntc}\relax }| +\cnta 100 \cntb 10 \cntc 1 +\centeredline{\digitstt{\xintRaw {\numexpr {\cnta*\cnta+\cntb*\cntb+\cntc*\cntc+ + 2*\cnta*\cntb+2*\cnta*\cntc+2*\cntb*\cntc}\relax/% + \numexpr {\cnta*\cnta+\cntb*\cntb+\cntc*\cntc}\relax }}} + \begin{framed} + Macros expecting fractions may be fed with arbitrarily long + |\numexpr|-expressions by the trick of using + |\numexpr {long_expression}\relax| as numerator and/or denominator of the + argument to the macro. + + Macros expecting an + integer obeying the \TeX{} bound must to the contrary receive directly + |long_expression| as argument (or |\numexpr long_expression\relax|, but + this is redundant as it will be done by the macro itself.) + \end{framed} +This is a trick as the braces would not be accepted as regular +|\numexpr|-syntax: and indeed, they + are removed at some point in the processing. + +\paragraph {Outputs: } loading \xintfracname not only relaxes the format of the +inputs; it also modifies the format of the outputs: except when a fraction is +filtered on output by \csb{xintIrr} (and \csb{xintJrr}) or +\csb{xintRawWithZeros}, or by the truncation or rounding macros, it will always +be in the \fbox{|A/B[n]|} form (which stands for |(A/B)|$\times$|10^n|). The |A| and +|B| may end in zeros (\emph{i.e}, |n| does not represent all powers of ten), and +will generally have a common factor. The denominator |B| is always strictly +positive. A macro \csb{xintFrac} is provided for the typesetting (math-mode only) of such a `raw' output. Of course, the @@ -1103,13 +1340,13 @@ for the typesetting (math-mode only) of such a `raw' output. Of course, the Direct user input of things such as |16000/289072[17]| or |3[-4]| is authorized. It is even possible to use |\A/\B[17]| if |\A| expands to |16000| and |\B| to -|289072|, or |\A| if |\A| expands to |3[-4]|. However,\MyMarginNote{IMPORTANT!} +|289072|, or |\A| if |\A| expands to |3[-4]|. However,%\IMPORTANT{} +\MyMarginNote{Important! } NEITHER the numerator NOR the denominator may then have a decimal point. And, for this format, ONLY the numerator may carry a UNIQUE minus sign (and no superfluous leading zeros; and NO plus sign). - - The, more demanding, format with a power of ten represented by a number within +This format with a power of ten represented by a number within square brackets is the output format used by (almost all) \xintfracname macros dealing with fractions. It is allowed for user input but the parsing is minimal and it @@ -1120,9 +1357,9 @@ a UNIQUE minus sign (and no superfluous leading zeros; and NO plus sign). \begin{framed} All computations done by \xintfracname on fractions are exact. Inputs - containing decimal points or scientific parts do not make the package - switch to a `floating-point' mode. The inputs, however long, are always - converted into exact internal representations. + containing decimal points or scientific parts do not make the package switch + to a `floating-point' mode. The inputs, however long, are always converted + into exact internal representations. Floating point evaluations are done with special macros containing `Float' in their names, or inside |\xintthefloatexpr|-essions. @@ -1136,12 +1373,12 @@ where spaces could break havoc. So the best is to avoid them entirely. This is entirely otherwise inside an |\xintexpr|-ession, where spaces are expected to, as a general rule (with possible exceptions related to the allowed use of braces, see the -\hyperref[sec:comexpr]{\color{niceone}documentation}) be completely +\hyperref[sec:comexpr]{documentation}) be completely harmless, and even recommended for making the source more legible. Syntax such as |\xintMul\A\B| is accepted and equivalent\footnote{see however near the end of - \hyperref[sec:outputs]{\color{niceone}this later section} for the important + \hyperref[sec:ifcase]{this later section} for the important difference when used in contexts where \TeX{} expects a number, such as following an \csa{ifcase} or an \csa{ifnum}.} to |\xintMul {\A}{\B}|. Or course |\xintAdd\xintMul\A\B\C| does not work, the product operation must be put @@ -1169,8 +1406,7 @@ fractions on input,\footnote{of course, the power function does not accept a synonyms.}\,\footnote{and \csb{xintQuo}, \csb{xintRem}, \csb{xintDivision}, \csb{xintGeq}, \csb{xintFDg}, \csb{xintLDg}, \csb{xintOdd}, \csb{xintMON}, \csb{xintMMON} all accept a fractional input as long as it reduces to an - integer. Note that \csb{xintGeq} still only works on (non-negative) integers, - to compare fractions one must use \csb{xintCmp}.} and produce on output a + integer.} and produce on output a fractional number |f=A/B[n]| where |A| and |B| are integers, with |B| positive, and |n| is a signed ``small'' integer (\emph{i.e} less in absolute value than |2^{31}-9|). This represents |(A/B)| times |10^n|. The fraction |f| may be, and @@ -1188,9 +1424,8 @@ versions. They have less parsing overhead. -The macro \csb{xintRaw} prints\MyMarginNote{\parbox[t]{1.5cm}{Changed\\ in - |1.07|!!}} the fraction -directly from its internal representation in |a/b[n]| form. To convert +The macro \csb{xintRaw} prints\MyMarginNote{Changed in |1.07|} the fraction +directly from its internal representation in |A/B[n]| form. To convert the trailing |[n]| into explicit zeros either at the numerator or the denominator, use \csb{xintRawWithZeros}. In both cases the |B| is printed even if it has value |1|. @@ -1199,17 +1434,16 @@ Conversely (sort of), the macro \csb{xintREZ} puts all powers of ten into the |[n]| (REZ stands for remove zeros). Here also, the |B| is printed even if it has value |1|. -The macro \csb{xintIrr} reduces the fraction to its irreducible form -|C/D| (without a trailing |[0]|), and it prints only the |C| if -|D=1|. The macro \csb{xintNum} from \xintname is extended to act like -\csb{xintIrr} but additionally raises an error when the fraction -doesn't simplify to an integer. When one knows that necessarily the -result of a computation is an integer, and one wants to get rid of the -denominator and trailing |[n]|, one can thus use \csb{xintIrr} or -\csb{xintNum} (if the fraction has internally a denominator equal to 1, -this is quickly identified, there is little overhead; else, the -denominator will be discovered in the next step to be a divisor of the -numerator). +The macro \csb{xintIrr} reduces the fraction to its irreducible form |C/D| +(without a trailing |[0]|), and\MyMarginNote{Changed in |1.08|} it prints +the |D| even if |D=1|. + +The macro \csb{xintNum} from package \xintname is extended: it now does like +\csa{xintIrr}, raises an error if the fraction did not reduce to an integer, and +outputs the numerator. This macro +should be used when one knows that necessarily the result of a computation is an +integer, and one wants to get rid of its denominator |/1| which would be left by +\csa{xintIrr}. The macro \csb{xintTrunc}|{N}{f}| prints\footnote{`prints' does not at all mean @@ -1228,52 +1462,55 @@ verify that |N| is non-negative and strange things could happen with a negative |N|. Of course a negative |f| is no problem, needless to say. When the original fraction is negative and its truncation has only zeros, it is printed as |-0.0...0|, with |N| zeros following the decimal point: -\centeredline{|\xintTrunc {5}{\xintPow {-13}{-9}}=|\texttt{\xintTrunc +\centeredline{|\xintTrunc {5}{\xintPow {-13}{-9}}|\digitstt{=\xintTrunc {5}{\xintPow {-13}{-9}}}}% -\centeredline{|\xintTrunc {20}{\xintPow {-13}{-9}}=|\texttt{\xintTrunc +\centeredline{|\xintTrunc {20}{\xintPow {-13}{-9}}|\digitstt{=\xintTrunc {20}{\xintPow {-13}{-9}}}} The output always contains a decimal point (even for |N=0|) followed by |N| digits, except when the original fraction was zero. In that case the output is |0|, with no decimal point. \centeredline{|\xintTrunc - {10}{\xintSum {{1/2}{1/3}{1/5}{-31/30}}}=|% - \texttt{\xintTrunc {10}{\xintSum {{1/2}{1/3}{1/5}{-31/30}}}}} - -The output of \csb{xintTrunc} may of course serve as input to the other -macros. And this is almost necessary when summing hundreds of -terms of a series with fractional coefficients, as the exact -rational number quickly becomes quite big (when doing the sum from -|n=|1 to |n=|1000 of |1/n|, the raw denominator is &1000!&, which -has 2568 digits) ; but for less than fifty terms with small -denominators it is often possible to work with the exact -value without too much toll on the compilation time. - -The macro \csb{xintiTrunc}|{N}{f}| is like \csa{xintTrunc}|{N}{f}| -followed by multiplication by |10^N|. Thus, it outputs an integer -in a format acceptable by the integer-only macros. This is also -convenient when computing partial sums of series, with a fixed number of -digits after the decimal point: it is a bit -faster to sum with \csb{xintiSeries} the integers produced by -\csa{xintiTrunc}|{N}| than it is to use the general -\csb{xintSeries} on the decimal numbers produced by -\csa{xintTrunc}|{N}|. These latter macros belong to the \xintseriesname -package. - -Needless to say when using \csa{xintTrunc} or \csa{xintiTrunc} on -intermediate computations the ending digits of the final result -are, pending further analysis, only indications of those of the -fraction an exact computation would have produced. + {10}{\xintSum {{1/2}{1/3}{1/5}{-31/30}}}|% + \digitstt{=\xintTrunc {10}{\xintSum {{1/2}{1/3}{1/5}{-31/30}}}}} + +% The output of \csb{xintTrunc} may of course serve as input to the other +% macros. And this is almost necessary when summing hundreds of +% terms of a series with fractional coefficients, as the exact +% rational number quickly becomes quite big (when doing the sum from +% |n=|1 to |n=|1000 of |1/n|, the raw denominator is &1000!&, which +% has 2568 digits) ; but for less than fifty terms with small +% denominators it is often possible to work with the exact +% value without too much toll on the compilation time. + +% The macro \csb{xintiTrunc}|{N}{f}| is like \csa{xintTrunc}|{N}{f}| +% followed by multiplication by |10^N|. Thus, it outputs an integer +% in a format acceptable by the integer-only macros. This is also +% convenient when computing partial sums of series, with a fixed number of +% digits after the decimal point: it is a bit +% faster to sum with \csb{xintiSeries} the integers produced by +% \csa{xintiTrunc}|{N}| than it is to use the general +% \csb{xintSeries} on the decimal numbers produced by +% \csa{xintTrunc}|{N}|. These latter macros belong to the \xintseriesname +% package. + +% Needless to say when using \csa{xintTrunc} or \csa{xintiTrunc} on +% intermediate computations the ending digits of the final result +% are, pending further analysis, only indications of those of the +% fraction an exact computation would have produced. \edef\z {\xintPow {1.01}{100}} +The macro \csb{xintiTrunc}|{N}{f}| is like \csa{xintTrunc}|{N}{f}| +followed by multiplication by |10^N|. Thus, it outputs an integer +in a format acceptable by the integer-only macros. To get the integer part of the decimal expansion of |f|, use |\xintiTrunc{0}{f}|: \centeredline{|\xintiTrunc {0}{\xintPow - {1.01}{100}}=|\texttt{\xintiTrunc {0}\z}}% -\centeredline{|\xintiTrunc {0}{\xintPow{0.123}{-10}}=|\texttt{\xintiTrunc + {1.01}{100}}|\digitstt{=\xintiTrunc {0}\z}}% +\centeredline{|\xintiTrunc {0}{\xintPow{0.123}{-10}}|\digitstt{=\xintiTrunc {0}{\xintPow{0.123}{-10}}}} -See also the documentation of \csb{xintRound}, \csb{xintiRound} and +See also the documentations of \csb{xintRound}, \csb{xintiRound} and \csb{xintFloat}. -\section{\csh{ifcase}, \csh{ifnum}, ... constructs} +\section{\csh{ifcase}, \csh{ifnum}, ... constructs}\label{sec:ifcase} When using things such as |\ifcase \xintSgn{\A}| one has to leave a space after the closing brace for \TeX{} to @@ -1292,13 +1529,14 @@ With |\def\A{1}|: % \ifcase \xintSgn\A 0\or OK\else ERROR\fi\ % \ifcase \xintSgn{\A} 0\or OK\else ERROR\fi -Release |1.07| provides the expandable\MyMarginNote{New with |1.07|!} \csb{xintSgnFork} which chooses -one of three branches according to whether its argument expand to |-1|, -|0| or |1|. This, rather than the corresponding |\ifcase|, should be used -when such a fork is needed as argument to one of the package macros. +Release |1.07| provides the expandable\MyMarginNote{New with |1.07|} +\csb{xintSgnFork} which chooses one of three branches according to whether its +argument expand to |-1|, |0| or |1|. This, rather than the corresponding +|\ifcase|, should be used when such a fork is needed as argument to one of the +package macros. -\section{Multiple outputs}\label{sec:outputs} +\section{Multiple outputs}\label{sec:multout} Some macros have an output consisting of more than one number, each one is then within braces. Examples of multiple-output macros are \csb{xintDivision} which @@ -1330,25 +1568,26 @@ expandability. For example why not allow oneself the two definitions \centeredline{\csb{xintAssign}\csa{xintDivision}% |{\xintiPow {2}{1000}}{\xintFac{100}}|\csbnolk{to}|\A\B|} gives \xintAssign\xintDivision{\xintiPow {2}{1000}}{\xintFac{100}}\to\A\B -|\meaning\A|\texttt{: \expandafter\allowsplits\meaning\A\relax} and -|\meaning\B|\texttt{: \expandafter\allowsplits\meaning\B\relax}. +|\meaning\A|\digitstt{: \expandafter\allowsplits\meaning\A\relax} and +|\meaning\B|\digitstt{: \expandafter\allowsplits\meaning\B\relax}. Another example (which uses a macro from the \xintgcdname package): \centeredline{\csb{xintAssign}\csa{xintBezout}|{357}{323}|% \csbnolk{to}|\A\B\U\V\D|} is equivalent to setting |\A| to - \texttt{\tmpA}, |\B| to \texttt{\tmpB}, |\U| to \texttt{\tmpU}, - |\V| to \texttt{\tmpV}, and |\D| to \texttt{\tmpD}. And indeed - (\tmpU)$\times$\tmpA-(\tmpV)$\times$\tmpB= - \xintiSub{\xintiMul\tmpU\tmpA}{\xintiMul\tmpV\tmpB} + \digitstt{\tmpA}, |\B| to \digitstt{\tmpB}, |\U| to \digitstt{\tmpU}, + |\V| to \digitstt{\tmpV}, and |\D| to \digitstt{\tmpD}. And indeed + \digitstt{(\tmpU)$\times$\tmpA-(\tmpV)$\times$\tmpB$=$% + \xintiSub{\xintiMul\tmpU\tmpA}{\xintiMul\tmpV\tmpB}} is a Bezout Identity. - \xintAssign\xintBezout{3570902836026}{200467139463}\to\tmpA\tmpB\tmpU\tmpV\tmpD - \centeredline{\csb{xintAssign}\csa{xintBezout}|{3570902836026}{200467139463}|% - \csbnolk{to}|\A\B\U\V\D|} gives then |\U|\texttt{: - \expandafter\allowsplits\meaning\tmpU\relax}, |\V|\texttt{: - \expandafter\allowsplits\meaning\tmpV\relax} and |\D=|\texttt{\tmpD}. +\xintAssign\xintBezout{3570902836026}{200467139463}\to\tmpA\tmpB\tmpU\tmpV\tmpD +\centeredline{\csb{xintAssign}\csa{xintBezout}|{3570902836026}{200467139463}|% + \csbnolk{to}|\A\B\U\V\D|} gives then |\U|\digitstt{: + \expandafter\allowsplits\meaning\tmpU\relax}, + |\V|\digitstt{: + \expandafter\allowsplits\meaning\tmpV\relax} and |\D|\digitstt{=\tmpD}. When one does not know in advance the number of tokens, one can use \csa{xintAssignArray} or its synonym \csa{xintDigitsOf}: @@ -1360,11 +1599,10 @@ expandability. For example why not allow oneself the two definitions \csa{Out} is completely expandable (in two steps). As it wouldn't make much sense to allow indices exceeding the \TeX{} bounds, the macros created by \csb{xintAssignArray} put their argument inside a - \csa{numexpr},\vadjust{\vskip-\dp\strutbox - \hbox{\smash{\color{niceone}\llap{\strut\small CHANGED (1.06)!\ $\Bigg\{$\ - }}}\vskip\dp\strutbox } so it is completely\strut{} expanded and may be - a count register, not necessarily prefixed by |\the| or |\number|. Consider - the following code snippet: + \csa{numexpr},\MyMarginNoteWithBrace{Changed in |1.06|} + so it is completely expanded and +may be a count register, not necessarily prefixed by |\the| or |\number|. +Consider the following code snippet: \dverb+& \newcount\cnta \newcount\cntb @@ -1420,10 +1658,11 @@ define are already defined. In the example above, we deliberately broke all rules of complete expandability, but had we wanted to compute the sum of the digits, not the sum of the squares, we could just have written: -\centeredline{\csb{xintiSum}|{\xintiPow{2}{100}}=|\texttt{% +\centeredline{\csb{xintiSum}|{\xintiPow{2}{100}}|\digitstt{=% \xintiSum\z}} Indeed, \csa{xintiSum} is usually used as in \centeredline{% - \csb{xintiSum}|{{123}{-345}{\xintFac{7}}{\xintiOpp{\xintRem{3347}{591}}}}=|\texttt{% + \csb{xintiSum}|{{123}{-345}{\xintFac{7}}{\xintiOpp{\xintRem{3347}{591}}}}|% + \digitstt{=% \xintiSum{{123}{-345}{\xintFac{7}}{\xintiOpp{\xintRem{3347}{591}}}}}} but in the example above each digit of &2^{100}& is treated as would have been a summand enclosed within braces, due to the rules @@ -1453,15 +1692,12 @@ for typesetting: this is just an example of one way to do it. \section{Utilities for expandable manipulations} -The\vadjust{\vskip-\dp\strutbox - \hbox{\smash{\color{niceone}\llap{\strut\small EXTENDED (1.06)\ $\to$\ - }}}\vskip\dp\strutbox } package\strut{} now has more utilities to deal expandably with `lists of -things', which were treated un-expandably in the previous section with -\csa{xintAssign} and \csa{xintAssignArray}: \csb{xintRev}, -\csb{xintReverseOrder}, \csb{xintLen} and -\csb{xintLength} since the first release, \csb{xintApply} and -\csb{xintListWithSep} since |1.04|, \csb{xintRevWithBraces}, -\csb{xintCSVtoList}, \csb{xintNthElt} with |1.06|, and +The\MyMarginNote{Extended in |1.06|} package now has more utilities to deal +expandably with `lists of things', which were treated un-expandably in the +previous section with \csa{xintAssign} and \csa{xintAssignArray}: \csb{xintRev}, +\csb{xintReverseOrder}, \csb{xintLen} and \csb{xintLength} since the first +release, \csb{xintApply} and \csb{xintListWithSep} since |1.04|, +\csb{xintRevWithBraces}, \csb{xintCSVtoList}, \csb{xintNthElt} with |1.06|, and \csb{xintApplyUnbraced}, new with |1.06b|. \edef\z{\xintiPow {2}{100}} @@ -1515,6 +1751,7 @@ sequences: \xintError:ExponentTooBig \xintError:TooBigDecimalShift \xintError:TooBigDecimalSplit +\xintError:RootOfNegative \xintError:NoBezoutForZeros \xintError:ignored \xintError:removed @@ -1529,41 +1766,50 @@ sequences: Here is a list of common input errors. Some will cause compilation errors, others are more annoying as they may pass through unsignaled. \begin{itemize} -\item using |-| to prefix some macro: |-\xintiSqr{35}/271|.\footnote{this is +\item using |-| to prefix some macro: |-\xintiSqr{35}/271|.\footnote{to the + contrary, this \emph{is} allowed inside an |\string\xintexpr|-ession.} \item using one pair of braces too many |\xintIrr{{\xintiPow {3}{13}}/243}| (the computation goes through with no error signaled, but the result is completely wrong). -\item using |[]| and decimal points at the same time |1.5/3.5[2]|. -\item using |[]| with a sign in the denominator |3/-5[7]|. -\item using macros supposedly giving integers as numerators or - denominators: |\edef\x{|\allowbreak|\xintMul {3}{5}/\xintMul{7}{9}}|. The - problem is - that, with \xintfracname loaded, this expands to \texttt{\x} which is +\item using |[]| and decimal points at the same time |1.5/3.5[2]|, or with a + sign in the denominator |3/-5[7]|. The scientific notation has no such + restriction, the two inputs |1.5/-3.5e-2| and |-1.5e2/3.5| are equivalent: + |\xintRaw{1.5/-3.5e-2}|\digitstt{=\xintRaw{1.5/-3.5e-2}}, + |\xintRaw{-1.5e2/3.5}|\digitstt{=\xintRaw{-1.5e2/3.5}}. +\item specifying numerators and + denominators with macros producing fractions when \xintfracname is loaded: + |\edef\x{|\allowbreak|\xintMul {3}{5}/\xintMul{7}{9}}|. This expands to + \texttt{\x} which is invalid on input. Using this |\x| in a fraction macro will most certainly cause a compilation error, with its usual arcane and undecipherable - accompanying message. The fix here is to use rather |\xintiMul|, or - |\xinttheexpr 3*5\relax/\xinttheexpr 7*9\relax|. The more advanced among us - in mental power will have done the computations in their heads. + accompanying message. The fix here would be to use |\xintiMul|. The simpler + alternative with package \xintexprname: + |\xinttheexpr 3*5/(7*9)\relax|. +\item generally speaking, using in a context expecting an integer (possibly + restricted to the \TeX{} bound) a macro or expression which returns a + fraction: |\xinttheexpr 4/2\relax| outputs \digitstt{\xinttheexpr 4/2\relax}, + not &2&. Use |\xintNum {\xinttheexpr 4/2\relax}|. \end{itemize} \section{Package namespace} -Inner macros of \xintname, \xintfracname, \xintexprname, \xintgcdname, -\xintseriesname, and \xintcfracname{} all begin either with |\XINT_| or with -|\xint_|.\footnote{starting with release |1.06b| the style files use for - macro names a more modern underscore |\_| rather than the |@| sign. - Probability of a name clash with \LaTeX2e packages is now even closer to - nil, and with \LaTeX3 packages it is also close to nil as our control - sequences are all lacking the argument specifier part of \LaTeX3 function - names. A few macros starting with |\string\XINT| do not have the - underscore.} The package public commands all start with |\xint|. The major -forms have their initials capitalized, and lowercase forms, prefixed with -|\romannumeral0|, allow definitions of further macros expanding in only two -steps to their final outputs. Some other control sequences are used only as -delimiters, and left undefined, they may have been defined elsewhere, their -meaning doesn't matter and is not touched. +Inner macros of \xintname, \xintfracname, \xintexprname, +\xintbinhexname, \xintgcdname, \xintseriesname, and \xintcfracname{} all +begin either with |\XINT_| or with |\xint_|.\footnote{starting with + release |1.06b| the style files use for macro names a more modern + underscore |\_| rather than the |@| sign. Probability of a name clash + with \LaTeX2e packages is now even closer to nil, and with \LaTeX3 + packages it is also close to nil as our control sequences are all + lacking the argument specifier part of \LaTeX3 function names. A few + macros starting with |\string\XINT| do not have the underscore.} The +package public commands all start with |\xint|. The major forms have +their initials capitalized, and lowercase forms, prefixed with +|\romannumeral0|, allow definitions of further macros expanding in only +two steps to their final outputs. Some other control sequences are used +only as delimiters, and left undefined, they may have been defined +elsewhere, their meaning doesn't matter and is not touched. \section{Loading and usage} @@ -1572,6 +1818,7 @@ Usage with LaTeX: \usepackage{xint} \usepackage{xintfrac} % (loads xint) \usepackage{xintexpr} % (loads xintfrac) + \usepackage{xintbinhex} % (loads xint) \usepackage{xintgcd} % (loads xint) \usepackage{xintseries} % (loads xintfrac) \usepackage{xintcfrac} % (loads xintfrac) @@ -1580,6 +1827,7 @@ Usage with TeX: \input xint.sty\relax \input xintfrac.sty\relax % (loads xint) \input xintexpr.sty\relax % (loads xintfrac) + \input xintbinhex.sty\relax % (loads xint) \input xintgcd.sty\relax % (loads xint) \input xintseries.sty\relax % (loads xintfrac) \input xintcfrac.sty\relax % (loads xintfrac) @@ -1592,7 +1840,7 @@ executable |tex| can not be used, |etex| or |pdftex| (version |1.40| or later) or ..., must be invoked. -Furthermore, the packages \xintgcdname and \xintfracname will check for the +Furthermore, \xintfracname, \xintbinhexname, and \xintgcdname check for the previous loading of \xintname, and will try to load it if this was not already done. Similarly \xintseriesname, \xintcfracname and \xintexprname do the necessary loading of \xintfracname. Each package will refuse to be @@ -1637,7 +1885,7 @@ compatible. \csa{xintTypesetBezoutAlgorithm} also uses the Run tex or latex on xint.dtx. This will extract the style files xint.sty, xintfrac.sty, xintexpr.sty, -xintgcd.sty, xintseries.sty, xintcfrac.sty (and xint.ins). +xintbinhex.sty, xintgcd.sty, xintseries.sty, xintcfrac.sty (and xint.ins). Files with the same names and in the same repertory will be overwritten. The tex (not latex) run will stop with the complaint that it does not @@ -1650,7 +1898,8 @@ To get xint.pdf run pdflatex thrice on xint.dtx xint.sty | xintfrac.sty | - xintexpr.sty | --> TDS:tex/generic/xint/ + xintexpr.sty | + xintbinhex.sty | --> TDS:tex/generic/xint/ xintgcd.sty | xintseries.sty | xintcfrac.sty | @@ -1662,19 +1911,17 @@ database. + -\section{Commands of the \xintname package} +\section{Commands of the \xintname package}\label{sec:comxint} \def\n{\string{N\string}} \def\m{\string{M\string}} \def\x{\string{x\string}} -\texttt{\n} (or also \texttt{\m}) stands for a normalised number within braces -as described in the documentation, or for a control sequence expanding (in the -sense previously described) to such a number (without the braces!), or for a -control sequence within braces expanding to such a number, of for material -within braces which expands to such a number after repeated expansions of the -first token. A count register or \csa{numexpr} expression must thus come first -and be prefixed by |\the| or |\number|. +\texttt{\n} (or also \texttt{\m}) stands for a (long) number within braces with +one optional minus sign and no leading zeros, or for a control sequence possibly +within braces and expanding to such a number (without the braces!), or for +material within braces which expands to such a number after repeated expansions +of the first token. The letter \texttt{x} stands for something which will be inserted in-between a |\numexpr| and a |\relax|. It will thus be completely expanded and must give an @@ -1682,55 +1929,67 @@ integer obeying the \TeX{} bounds. Thus, it may be for example a count register, or itself a \csa{numexpr} expression, or just a number written explicitely with digits or something like |4*\count 255 + 17|, etc... +A count register or \csa{numexpr} expression, used as an argument to a macro +dealing with long integers, must be prefixed by |\the| or +|\number|. + Some of these macros are extended by \xintfracname to accept fractions on input, and, generally, to output a fraction. This will be mentioned and the original macro \csa{xintAbc} remains then available under the -name \csa{xintiAbc}. There are also macros such as \csa{xint\-Quo} or -\csa{xintNum} which are made to accept fractions on input, under the -condition that this fraction turns out to be an integer, but still do -produce pure integers without any forward slash mark nor trailing |[n]|. -Again the original is still available with an additional `i' in the -name, in case it is important to skip the parsing, but here the output -format is the same. See the \xintfracname -\hyperref[sec:comfrac]{\color{niceone}documentation} for more -information. +name \csa{xintiAbc}. + +\begin{framed} + For the macros extended by the loading of \xintfracname.sty, it is not + necessary anymore to prefix a count register with |\the|. See the previous + `\hyperlink{useofcount}{Use of count registers}' section. +\end{framed} +Some macros such as \csa{xintQuo} or \csa{xintNum} (which are among those made +to accept fractions on input when \xintfracname.sty is loaded) check that the +fraction is an integer in disguise. They still produce on output integers +without any forward slash mark nor trailing |[n]|. Again the original is still +available with an additional `i' in the name, in case it is important to skip +the parsing, but here the output format is the same. See the \xintfracname +\hyperref[sec:comfrac]{documentation} for more information. The integer-only macros are a bit more efficient, even for simple things such as determining the sign of a (long) number, as there is always some overhead due to -the parsing the fraction format on input; however except if one does thousands -of times the same computation with various inputs, there is no need in general -to employ the integer-only variants. The exception is when the context requires -that the macro returns a (possibly long) integer, with no forward slash nor -trailing |[n]|. This may be because they are used in \xintname macros which -remain strictly integer-only on input, such as \csb{xintDecSplit}, -or\vadjust{\vskip-\dp\strutbox \hbox{\smash{\color{niceone}\llap{\strut\small - IMPORTANT!\ $\Bigg\{$\ }}}\vskip\dp\strutbox } in\strut{} places where a -(short) number is expected by \TeX{} such as after an |\ifnum| or inside a -|\numexpr|. - +the parsing the fraction format on input. This overhead, when package +\xintfracname has been loaded and has modified the \xintname routines, usually +will not matter much, but there are contexts where obtaining\strut{} an integer +without +a forward slash nor trailing |[n]| is mandatory:\IMPORTANT{} +for example after an |\ifnum| or inside a +|\numexpr| (for `short' integers) or when used as argument to one of the package +macros which are stricly integer-only on input such as \csb{xintiSqrt}, or +\csb{xintDouble} or \csb{xintDecSplit}. A fraction which in disguise is an +integer can be stripped of the slash and trailing |[n]| using \csb{xintNum}. +\localtableofcontents \subsection{\csbh{xintRev}} \label{xintRev} \csa{xintRev\n} will revert the order of the digits of the number, keeping the optional sign. Leading zeros resulting from the operation are not removed (see the -\csa{xintNum} macro for this). As all other macros dealing with numbers it first -expands its argument (in the manner described, triggered by a -|\romannumeral-`0|). -\centeredline{|\xintRev{-123000}|\texttt{=\xintRev{-123000}}} -\centeredline{|\xintNum{\xintRev{-123000}}|\texttt{=\xintNum{\xintRev{-123000}}}} +\csa{xintNum} macro for this). As described early, this macro and all other +macros dealing with numbers first expand `fully' their arguments. +\centeredline{|\xintRev{-123000}|\digitstt{=\xintRev{-123000}}} +\centeredline{|\xintNum{\xintRev{-123000}}|% + \digitstt{=\xintNum{\xintRev{-123000}}}} \subsection{\csbh{xintReverseOrder}}\label{xintReverseOrder} \csa{xintReverseOrder}\marg{list} does not do any expansion of its argument and just reverses the order of the -tokens in the \meta{list}.\footnote{the argument is not a token list variable, just a - \meta{list} of tokens.} Brace pairs encountered are removed once and the enclosed +tokens in the \meta{list}.\footnote{the argument is not a token list variable, + just a + \meta{list} of tokens.} Brace pairs encountered are removed once and the +enclosed material does not get reverted. Spaces are gobbled. \centeredline{|\xintReverseOrder{\xintDigitsOf\xintiPow {2}{100}\to\Stuff}|} -\centeredline{gives: \ttfamily{\string\Stuff\string\to1002\string\xintiPow\string\xintDigitsOf}} +\centeredline{gives: + \ttfamily{\string\Stuff\string\to1002\string\xintiPow\string\xintDigitsOf}} \subsection{\csbh{xintRevWithBraces}}\label{xintRevWithBraces} @@ -1763,7 +2022,7 @@ does the same job without the initial expansion of its argument. \subsection{\csbh{xintLen}}\label{xintiLen} \csa{xintLen\n} returns the length of the number, not counting the sign. -\centeredline{|\xintLen{-12345678901234567890123456789}|\texttt +\centeredline{|\xintLen{-12345678901234567890123456789}|\digitstt {=\xintLen{-12345678901234567890123456789}}} Extended by \xintfracname to fractions: the length of |A/B[n]| is the length of |A| plus the length of |B| plus the absolute value of |n| and minus one (an integer input as |N| is @@ -1776,8 +2035,8 @@ less than circa &2^{31}&. \csa{xintLength}\marg{list} does not do any expansion of its argument and just counts how many tokens there are (possibly none). Things enclosed in braces count as one. \centeredline{|\xintLength {\xintiPow - {2}{100}}=|\texttt{\xintLength {\xintiPow{2}{100}}}} -\centeredline{${}\neq{}$|\xintLen {\xintiPow {2}{100}}=|\texttt{\xintLen + {2}{100}}|\digitstt{=\xintLength {\xintiPow{2}{100}}}} +\centeredline{${}\neq{}$|\xintLen {\xintiPow {2}{100}}|\digitstt{=\xintLen {\xintiPow{2}{100}}}} \subsection{\csbh{xintCSVtoList}}\label{xintCSVtoList} @@ -1797,8 +2056,9 @@ the space; prefixing a macro with |\space| stops preemptively the expansion and gobbles the space). Chains of contiguous spaces are collapsed by the \TeX{} scanning into single spaces. \centeredline{|\xintCSVtoList {1,2,a , b ,c d,x,y - }->|\makeatletter\texttt{\expandafter\strip@prefix\meaning\X}\makeatother} -\centeredline{|\def\y{a,b,c,d,e}\xintCSVtoList\y->|\makeatletter\texttt{\expandafter\strip@prefix\meaning\z}\makeatother} + }->|\makeatletter\digitstt{\expandafter\strip@prefix\meaning\X}\makeatother} +\centeredline{|\def\y{a,b,c,d,e}\xintCSVtoList\y->|% + \makeatletter\digitstt{\expandafter\strip@prefix\meaning\z}\makeatother} The macro \csa{xintCSVtoListNoExpand} does the same job without the initial expansion. @@ -1813,9 +2073,10 @@ expansion. \meta{list}, which may be a macro: it is first expanded (fully for the first tokens). The seeked element is returned with one pair of braces removed (if initially present). \centeredline{|\xintNthElt - {37}{\xintFac {100}}=|\texttt{\xintNthElt {37}{\xintFac {100}}}} is the + {37}{\xintFac {100}}|\digitstt{=\xintNthElt {37}{\xintFac {100}}}} is the thirty-seventh digit of &100!&. \centeredline{|\xintNthElt {10}{\xintFtoCv - {566827/208524}}=|\texttt{\xintNthElt {10}{\xintFtoCv {566827/208524}}}} is + {566827/208524}}|\digitstt{=\xintNthElt {10}{\xintFtoCv {566827/208524}}}} +is the tenth convergent of &566827/208524& (uses \xintcfracname package). If |x=0| or |x<0|, the macro returns the length of the expanded list: this is @@ -1824,10 +2085,10 @@ first token, and differs from \csb{xintLen} which is to be used on numbers or fractions only. The situation with |x| larger than the length of the list is kept silent, the macro then returns nothing; this will perhaps be modified in future versions. \centeredline{|\xintNthElt {7}{\xintCSVtoList - {1,2,3,4,5,6,7,8,9}}=|% - \texttt{\xintNthElt {7}{\xintCSVtoList {1,2,3,4,5,6,7,8,9}}}}% -\centeredline{|\xintNthElt {0}{\xintCSVtoList {1,2,3,4,5,6,7,8,9}}=|% - \texttt{\xintNthElt {0}{\xintCSVtoList {1,2,3,4,5,6,7,8,9}}}} + {1,2,3,4,5,6,7,8,9}}|% + \digitstt{=\xintNthElt {7}{\xintCSVtoList {1,2,3,4,5,6,7,8,9}}}}% +\centeredline{|\xintNthElt {0}{\xintCSVtoList {1,2,3,4,5,6,7,8,9}}|% + \digitstt{=\xintNthElt {0}{\xintCSVtoList {1,2,3,4,5,6,7,8,9}}}} The macro \csa{xintNthEltNoExpand} does the same job without first expanding its @@ -1849,7 +2110,7 @@ separator is used starting with at least two elements. Using an empty separator has the net effect of removing one-level of brace pairs from each ot the top-level braced material constituting the \meta{list}. \centeredline{|\xintListWithSep{:}{\xintFac - {20}}=|\texttt{\xintListWithSep{:}{\xintFac {20}}}} + {20}}|\digitstt{=\xintListWithSep{:}{\xintFac {20}}}} The macro \csa{xintListWithSepNoExpand} does the same job without the initial expansion. @@ -1874,7 +2135,7 @@ if the \meta{list} expands to some positive number, then each digit will be replaced by the result of applying |\macro| on it. \centeredline{|\def\macro #1{\the\numexpr 9-#1\relax}|} \centeredline{|\xintApply\macro{\xintFac - {20}}=|\texttt{\xintApply\macro{\xintFac {20}}}} + {20}}|\digitstt{=\xintApply\macro{\xintFac {20}}}} The macro \csa{xintApplyNoExpand} does the same job without the first initial expansion @@ -1926,10 +2187,10 @@ that there is only one control sequence to define and it is then defined to be the complete expansion of the entire material between \csa{xintAssign} and \csa{to}. \centeredline{|\xintAssign\xintDivision{1000000000000}{133333333}\to\Q\R|} -\centeredline{|\meaning\Q: |\texttt{\meaning\Q}, |\meaning\R: - |\texttt{\meaning\R}} \centeredline{|\xintAssign\xintiPow +\centeredline{|\meaning\Q: |\digitstt{\meaning\Q}, |\meaning\R: + |\digitstt{\meaning\R}} \centeredline{|\xintAssign\xintiPow {7}{13}\to\SevenToThePowerThirteen|} -\centeredline{|\SevenToThePowerThirteen=|\texttt{\SevenToThePowerThirteen}} +\centeredline{|\SevenToThePowerThirteen|\digitstt{=\SevenToThePowerThirteen}} Of course this macro and its cousins completely break usage in pure expansion contexts, as assignments are made via the @@ -1950,10 +2211,10 @@ full expansion of the `short' number \texttt{\x}, given to a thing, itself completely expanded. \csa{myArray}|{0}| returns the number |M| of elements of the array so that the successive elements are \csa{myArray}|{1}|, \dots, \csa{myArray}|{M}|. \centeredline{|\xintAssignArray\xintBezout - {1000}{113}\to\Bez|} will set |\Bez{0}| to \texttt{\Bez0}, |\Bez{1}| to -\texttt{\Bez1}, |\Bez{2}| to \texttt{\Bez2}, |\Bez{3}| to \texttt{\Bez3}, -|\Bez{4}| to \texttt{\Bez4}, and |\Bez{5}| to \texttt{\Bez5}: -(\Bez3)${}\times{}$\Bez1${}-{}$(\Bez4)${}\times{}$\Bez2${}={}$\Bez5. + {1000}{113}\to\Bez|} will set |\Bez{0}| to \digitstt{\Bez0}, |\Bez{1}| to +\digitstt{\Bez1}, |\Bez{2}| to \digitstt{\Bez2}, |\Bez{3}| to \digitstt{\Bez3}, +|\Bez{4}| to \digitstt{\Bez4}, and |\Bez{5}| to \digitstt{\Bez5}: +\digitstt{(\Bez3)${}\times{}$\Bez1${}-{}$(\Bez4)${}\times{}$\Bez2${}={}$\Bez5.} \subsection{\csbh{xintRelaxArray}}\label{xintRelaxArray} @@ -1975,11 +2236,11 @@ an array giving all the digits of a given number. \subsection{\csbh{xintNum}}\label{xintiNum} \csa{xintNum\n} removes chains of plus or minus signs, followed by zeros. -\centeredline{|\xintNum{+---++----+--000000000367941789479}|\texttt +\centeredline{|\xintNum{+---++----+--000000000367941789479}|\digitstt {=\xintNum{+---++----+--000000000367941789479}}} Extended by \xintfracname to accept also a fraction on input, as long as it reduces to an integer after division of the numerator by the denominator. -\centeredline{|\xintNum{123.48/-0.03}|\texttt{=\xintNum{123.48/-0.03}}} +\centeredline{|\xintNum{123.48/-0.03}|\digitstt{=\xintNum{123.48/-0.03}}} \subsection{\csbh{xintSgn}}\label{xintiSgn} @@ -2013,28 +2274,28 @@ use, or which values to confer to their arguments. {\xintRound {2}{\xintSgnFork {\xintSgnFork{\xintGeq{#1}{1}}{}{0}{\xintSgn{#1}}} {\xintSub{-1}{#1}}{\xintSub{1}{\xintSqr{#1}}}{\xintSub{#1}{1}}}}% -\xintListWithSep{,\,}{\xintApply\myfunction - {{-5/2}{-2}{-3/2}{-1}{-1/2}{0}{1/2}{1}{3/2}{2}{5/2}}} +\digitstt{\xintListWithSep{,\,}{\xintApply\myfunction + {{-5/2}{-2}{-3/2}{-1}{-1/2}{0}{1/2}{1}{3/2}{2}{5/2}}}} -Using an \xintexprname{}ession, one may simplify the coding: -\dverb(& +Using an \xintexprname-ession, one may simplify the coding: +\dverb*& \def\myfunction #1% expands to |x+1| if x < -1, x-1 if x > 1, else 1 - x^2 {\xintRound {2}{\xinttheexpr\xintSgnFork {\xintSgnFork{\xintGeq{#1}{1}}{}{0}{\xintSgn{#1}}} - { -#1 - 1 }{ 1 - #1^2 }{ #1 - 1} \relax }}% -( + { -#1 - 1 }{ 1 - (#1)^2 }{ #1 - 1 } \relax }}% +* \def\myfunction #1% expands to |x+1| if x < -1, x-1 if x > 1, else 1 - x^2 {\xintRound {2}{\xinttheexpr\xintSgnFork {\xintSgnFork{\xintGeq{#1}{1}}{}{0}{\xintSgn{#1}}} - { -#1 - 1 }{ #1^2 - 1 }{ #1 - 1} \relax }}% + { -#1 - 1 }{ 1 - (#1)^2 }{ #1 - 1 } \relax }}% -\xintListWithSep{,\,}{\xintApply\myfunction - {{-5/2}{-2}{-3/2}{-1}{-1/2}{0}{1/2}{1}{3/2}{2}{5/2}}} +\digitstt{\xintListWithSep{,\,}{\xintApply\myfunction + {{-5/2}{-2}{-3/2}{-1}{-1/2}{0}{1/2}{1}{3/2}{2}{5/2}}}} -See the \csb{xintNewExpr} section for how one can use formally the -\xintexprname parser to create automatically a -macro equivalent to the one we first wrote, not using |\xintthexpr|. +Notice the use of parentheses, with |#1=-1|, |1-#1^2| would give |1--1^2| which +evaluates to |2|. Or with |#1=3/2|, |1-#1^2| gives |1-3/2^2| which evaluates +inside an \xintexprname-ession to |1-3/4=1/4| not |1-9/4=-5/4|. \subsection{\csbh{xintOpp}}\label{xintiOpp} @@ -2064,24 +2325,24 @@ Extended by \xintfracname to fractions. \subsection{\csbh{xintGeq}}\label{xintiGeq} -\csa{xintGeq\n\m} returns 1 if the \emph{absolute value} of the first -number is at least equal to the absolute value of the second -number. If \verb+|N|<|M|+ it returns 0. Extended by \xintfracname to fractions -(new with |1.07|; beware that it compares \emph{absolute values}). +\csa{xintGeq\n\m} returns 1 if the \emph{absolute value} of the first number is +at least equal to the absolute value of the second number. If \verb+|N|<|M|+ it +returns 0. Extended by \xintfracname to fractions (starting with relaease +|1.07|). Please note that the macro compares \emph{absolute values}. \subsection{\csbh{xintMax}}\label{xintiMax} \csa{xintMax\n\m} returns the largest of the two in the sense of the order structure on the relative integers (\emph{i.e.} the right-most number if they are put on a line with positive numbers on the right): |\xintiMax -{-5}{-6}=|\texttt{\xintiMax{-5}{-6}}. Extended by \xintfracname to fractions. +{-5}{-6}|\digitstt{=\xintiMax{-5}{-6}}. Extended by \xintfracname to fractions. \subsection{\csbh{xintMin}}\label{xintiMin} \csa{xintMin\n\m} returns the smallest of the two in the sense of the order structure on the relative integers (\emph{i.e.} the left-most number if they are put on a line with positive numbers on the right): |\xintiMin -{-5}{-6}=|\texttt{\xintiMin{-5}{-6}}. Extended by \xintfracname to fractions. +{-5}{-6}|\digitstt{=\xintiMin{-5}{-6}}. Extended by \xintfracname to fractions. \subsection{\csbh{xintSum}}\label{xintiSum} @@ -2090,26 +2351,25 @@ expects to find a sequence of tokens (or braced material). Each is expanded (with the usual meaning), and the sum of all these numbers is returned. \centeredline{% - \csa{xintiSum}|{{123}{-98763450}{\xintFac{7}}{\xintiMul{3347}{591}}}=|\texttt{% - \xintiSum{{123}{-98763450}{\xintFac{7}}{\xintiMul{3347}{591}}}}} -\centeredline{\csa{xintiSum}|{1234567890}=|\texttt{% - \xintiSum{1234567890}}} + \csa{xintiSum}|{{123}{-98763450}{\xintFac{7}}{\xintiMul{3347}{591}}}|% + \digitstt{=\xintiSum{{123}{-98763450}{\xintFac{7}}{\xintiMul{3347}{591}}}}} +\centeredline{\csa{xintiSum}|{1234567890}|\digitstt{=\xintiSum{1234567890}}} An empty sum is no error and returns zero: |\xintiSum -{}=|\texttt{\xintiSum {}}. A sum with only one -term returns that number: |\xintiSum {{-1234}}=|\texttt{\xintiSum +{}|\digitstt{=\xintiSum {}}. A sum with only one +term returns that number: |\xintiSum {{-1234}}|\digitstt{=\xintiSum {{-1234}}}. Attention that |\xintiSum {-1234}| is not legal input and will make the \TeX{} run fail. On the other hand |\xintiSum -{1234}=|\texttt{\xintiSum{1234}}. Extended by \xintfracname +{1234}|\digitstt{=\xintiSum{1234}}. Extended by \xintfracname to fractions. \subsection{\csbh{xintSumExpr}}\label{xintiSumExpr} \csa{xintSumExpr}\meta{braced things}\csa{relax} is to what \csa{xintSum} -expands. The argument is then expanded (with the usual meaning) and should give a -list of braced quantities or macros, each one will be expanded in turn. +expands. The argument is then expanded (with the usual meaning) and should give +a list of braced quantities or macros, each one will be expanded in turn. \centeredline{% \csa{xintiSumExpr}| {123}{-98763450}|% - |{\xintFac{7}}{\xintiMul{3347}{591}}\relax=|\texttt{% + |{\xintFac{7}}{\xintiMul{3347}{591}}\relax|\digitstt{=% \xintiSumExpr {123}{-98763450}{\xintFac{7}}{\xintiMul{3347}{591}}\relax}} Note: I am not so happy with the name which seems to suggest that the @@ -2135,30 +2395,31 @@ Extended by \xintfracname to fractions. \subsection{\csbh{xintPrd}}\label{xintiPrd} -\csa{xintPrd}\marg{braced things} after expanding its argument -expects to find a sequence of tokens (or braced material). -Each is expanded (with the usual meaning), and the product of all these numbers is -returned. \centeredline{% - \csa{xintiPrd}|{{-9876}{\xintFac{7}}{\xintiMul{3347}{591}}}=|% - \texttt{% +\csa{xintPrd}\marg{braced things} after expanding its argument expects to find a +sequence of tokens (or braced material). Each is expanded (with the usual +meaning), and the product of all these numbers is returned. +\centeredline{% + \csa{xintiPrd}|{{-9876}{\xintFac{7}}{\xintiMul{3347}{591}}}|% + \digitstt{=% \xintiPrd{{-9876}{\xintFac{7}}{\xintiMul{3347}{591}}}}} -\centeredline{\csa{xintiPrd}|{123456789123456789}=|\texttt{% - \xintiPrd{123456789123456789}}} An empty product is no error -and returns 1: |\xintiPrd {}=|\texttt{\xintiPrd {}}. A product -reduced to a single term returns this number: |\xintiPrd -{{-1234}}=|\texttt{\xintiPrd {{-1234}}}. Attention that |\xintiPrd -{-1234}| is not legal input and will make the \TeX{} compilation -fail. On the other hand |\xintiPrd {1234}=|\texttt{\xintiPrd - {1234}}. -\centeredline{&2^{200}3^{100}7^{100}&} -\centeredline{=|\xintiPrd {{\xintiPow {2}{200}}{\xintiPow - {3}{100}}{\xintiPow {7}{100}}}|} -=\expandafter\expandafter\expandafter\allowsplits - \xintiPrd {{\xintiPow {2}{200}}{\xintiPow {3}{100}}{\xintiPow - {7}{100}}}\relax -\centeredline{=|\xintiPow {\xintiMul {\xintiPow {42}{9}}{43008}}{10}|} +\centeredline{\csa{xintiPrd}|{123456789123456789}|\digitstt{=% + \xintiPrd{123456789123456789}}} An empty product is no error and returns 1: +|\xintiPrd {}|\digitstt{=\xintiPrd {}}. A product reduced to a single term returns +this number: |\xintiPrd {{-1234}}|\digitstt{=\xintiPrd {{-1234}}}. Attention that +|\xintiPrd {-1234}| is not legal input and will make the \TeX{} compilation +fail. On the other hand |\xintiPrd {1234}|\digitstt{=\xintiPrd {1234}}. +\centeredline{$\displaystyle 2^{200}3^{100}7^{100}$} \centeredline{|=\xintiPrd + {{\xintiPow {2}{200}}{\xintiPow {3}{100}}{\xintiPow {7}{100}}}|} +% \digitstt{=\expandafter\expandafter\expandafter\allowsplits \xintiPrd +% {{\xintiPow {2}{200}}{\xintiPow {3}{100}}{\xintiPow {7}{100}}}\relax } +\digitstt{=\printnumber{\xintNum {\xinttheexpr 2^200*3^100*7^100\relax }}} +%\centeredline{|=\xintiPow {\xintiMul {\xintiPow {42}{9}}{43008}}{10}|} + Extended by \xintfracname to fractions. +With \xintexprname, the above would be coded simply as \centeredline{|\xintNum + {\xinttheexpr 2^200*3^100*7^100\relax }|} (\csa{xintNum} to print an integer, not a fraction). + % \printnumber{% % \xintPow {\xintMul {\xintPow {42}{9}}{43008}}{10}} @@ -2171,7 +2432,7 @@ Extended by \xintfracname to fractions. \csa{xintPrdExpr}\marg{argument}\csa{relax} is to what \csa{xintPrd} expands ; its argument is expanded (with the usual meaning) and should give a list of braced numbers or macros. Each will be expanded when it is its turn. -\centeredline{\csa{xintiPrdExpr}| 123456789123456789\relax=|\texttt{% +\centeredline{\csa{xintiPrdExpr}| 123456789123456789\relax|\digitstt{=% \xintiPrdExpr 123456789123456789\relax}} Note: I am not so happy with the name which seems to suggest that the @@ -2180,7 +2441,39 @@ in the future. Extended by \xintfracname to fractions. -\subsection{\csbh{xintFac}}\label{xintFac} +\subsection{\csbh{xintPow}}\label{xintiPow} + +\csa{xintPow\n\x} returns |N^x|. When |x| is zero, this is 1. If |N| is zero and +|x<0|, if \verb+|N|>1+ and |x<0| negative, or if \verb+|N|>1+ and |x>999999999|, +then an error is raised. |2^999999999| has \np{301029996} digits; each exact +multiplication of two one thousand digits numbers already takes a few seconds, +so needless to say this bound is completely irrealistic. Already |2^9999| has +\np{3010} digits,\footnote{on my laptop |\string\xintiPow \{2\}\{9999\}| + obtains all |3010| digits in about ten or eleven seconds. In contrast, the + float versions for + |8|, |16|, |24|, or even more significant figures, do their jobs in circa one + hundredth of a second (|1.08b|). This is done without |log|/|exp| which are + not (yet?) implemented in \xintfracname. The \LaTeX3 + \href{http://www.ctan.org/tex-archive/macros/latex/contrib/l3kernel}{l3fp} + does this with |log|/|exp| and is ten times faster (|16| figures only).} so I +should perhaps lower the bound to |99999|. + +Extended by \xintfracname to fractions (\csb{xintPow}) and also to floats +(\csb{xintFloatPow}). Of course, negative +exponents do not then cause errors anymore. The float version is able to deal +with things such as +|2^999999999| without any problem. For example +|\xintFloatPow[4]{2}{9999}|\digitstt{=\xintFloatPow[4]{2}{9999}} and +|\xintFloatPow[4]{2}{999999999}| +\digitstt{=\xintFloatPow[4]{2}{999999999}}. + +\begin{framed} + The macros described next are all integer-only on input. With \xintfracname + loaded their argument is filtered through \csb{xintNum} and may thus be + a fraction, as long as it is an integer in disguise. +\end{framed} + +\subsection{\csbh{xintFac}}\label{xintiFac} \csa{xintFac\x} returns the factorial. It is an error if the argument is negative or at least &10^6&. It is not recommended to @@ -2190,6 +2483,14 @@ must obey the \TeX{} bounds, but on the other hand may involve count registers and even arithmetic operations as it will be completely expanded inside a |\numexpr|. +With \xintfracname loaded, the macro also\MyMarginNote{Modified in |1.08b|} +accepts a fraction as argument, as long as this fraction turns out to be an +integer: |\xintFac {66/3}|\digitstt{=\xintFac {66/3}}. + +% the construct |\xintFac{\xintAdd {2}{3}}| will fail, +% use either |\xintFac{\xintiAdd {2}{3}}| or |\xintFac{\xintNum{\xintAdd +% {2}{3}}}|. + % temps obsolètes, mettre à jour % On my laptop &1000!& (2568 digits) % is computed in a little less than ten seconds, &2000!& (5736 @@ -2201,16 +2502,6 @@ and even arithmetic operations as it will be completely expanded inside a % digits). Not to mention &100000!& which, from the Stirling formula, % should have 456574 digits. -\subsection{\csbh{xintPow}}\label{xintiPow} - -\csa{xintPow\n\x} returns |N^x|. When |x| is zero, this is 1. Some -cases (|N| zero and |x| negative, \verb+|N|>1+ and |x| negative, -\verb+|N|>1+ and |x| at least &10^9&) make \xintname throw errors. - -Extended by \xintfracname to fractions. Of course, negative -exponents do not then cause errors anymore. - - \subsection{\csbh{xintDivision}}\label{xintDivision} \csa{xintDivision\n\m} returns |{quotient Q}{remainder R}|. This @@ -2238,6 +2529,7 @@ With \xintfracname loaded it accepts fractions on input, but they must be integers in disguise. + \subsection{\csbh{xintFDg}}\label{xintFDg} \csa{xintFDg\n} returns the first digit (most significant) of the @@ -2249,18 +2541,68 @@ decimal expansion. number is positive, this is the same as the remainder in the euclidean division by ten. -\subsection{\csbh{xintMON}, \csbh{xintMMON}}\label{xintiMON}\label{xintiMMON}\label{xintMON}\label{xintMMON} +\subsection{\csbh{xintMON}, \csbh{xintMMON}}\label{xintiMON}% +\label{xintiMMON}\label{xintMON}\label{xintMMON} {\small New in version |1.03|.\par} \csa{xintMON\n} returns |(-1)^N| and \csa{xintMMON\n} returns -|(-1)^{N-1}|. \centeredline{|\xintMON {-280914019374101929}=|\texttt{\xintMON +|(-1)^{N-1}|. \centeredline{|\xintMON {-280914019374101929}|\digitstt{=\xintMON {280914019374101929}}, |\xintMMON -{-280914019374101929}=|\texttt{\xintMMON {280914019374101929}}} +{-280914019374101929}|\digitstt{=\xintMMON {280914019374101929}}} \subsection{\csbh{xintOdd}}\label{xintOdd} \csa{xintOdd\n} is 1 if the number is odd and 0 otherwise. +\begin{framed} +The macros described next are strictly for integer-only arguments. If +\xintfracname is loaded, use \csb{xintNum} if necessary. +\end{framed} + + +\subsection{\csbh{xintiSqrt}, \csbh{xintiSquareRoot}}\label{xintiSqrt} +\label{xintiSquareRoot} +{\small New with |1.08|.\par} +\xintAssign\xintiSquareRoot {17000000000000000000000000}\to\A\B + +\noindent\csa{xintiSqrt\n} returns the largest integer whose square is +at most equal to |N|. +\centeredline{|\xintiSqrt {2000000000000000000000000000000000000}=|% +\digitstt{\xintiSqrt{2000000000000000000000000000000000000}}} +\centeredline{|\xintiSqrt {3000000000000000000000000000000000000}=|% +\digitstt{\xintiSqrt{3000000000000000000000000000000000000}}} +\centeredline{|\xintiSqrt {\xintDSH {-120}{2}}=|}% +\centeredline{\digitstt{\xintiSqrt {\xintDSH {-120}{2}}}} +\csa{xintiSquareRoot\n} returns |{M}{d}| with |d>0|, |M^2-d=N| and |M| +smallest (hence |=1+|\csa{xint\-iSqrt}|{N}|). +\centeredline{|\xintAssign\xintiSquareRoot + {17000000000000000000000000}\to\A\B|}% +\centeredline{|\xintiSub{\xintiSqr\A}\B=\A^2-\B|}% +\centeredline{\digitstt{\xintiSub{\xintiSqr\A}\B=\A\string^2-\B}} +A rational approximation to +$\sqrt{|N|}$ is $|M|-\frac{|d|}{|2M|}$ (this is a majorant and the error is at +most |1/2M|; if |N| is a perfect square |k^2| then |M=k+1| and this gives +|k+1/(2k+2)|, not |k|). + +Package \xintfracname has \csb{xintFloatSqrt} for square +roots of floating point numbers. + +\subsection{\csbh{xintInc}, \csbh{xintDec}} +\label{xintInc} +\label{xintDec} +{\small New with |1.08|.\par} + +\csa{xintInc\n} is |N+1| and \csa{xintDec\n} is |N-1|. These macros remain +integer-only, even with \xintfracname loaded. + +\subsection{\csbh{xintDouble}, \csbh{xintHalf}} +\label{xintDouble} +\label{xintHalf} +{\small New with |1.08|.\par} + +\csa{xintDouble\n} returns |2N| and \csa{xintHalf\n} is |N/2| rounded +towards zero. These macros remain integer-only, even with \xintfracname loaded. + \subsection{\csbh{xintDSL}}\label{xintDSL} \csa{xintDSL\n} is decimal shift left, \emph{i.e.} multiplication @@ -2268,12 +2610,9 @@ by ten. \subsection{\csbh{xintDSR}}\label{xintDSR} -\csa{xintDSR\n} is decimal shift right, \emph{i.e.} it removes the -last digit (keeping the sign). For a positive number, this is the -same as the quotient from the euclidean division by ten (of -course, done in a more efficient manner than via the general -division algorithm). For |N| from |-9| to |-1|, the macro returns -|0|. +\csa{xintDSR\n} is decimal shift right, \emph{i.e.} it removes the last digit +(keeping the sign), equivalently it is the closest integer to |N/10| when +starting at zero. \subsection{\csbh{xintDSH}}\label{xintDSH} @@ -2317,34 +2656,34 @@ simultaneously. \begin{flushleft} \xintAssign\xintDSx {-1}{-123456789}\to\M \noindent{|\xintAssign\xintDSx {-1}{-123456789}\to\M|}\\ - |\meaning\M: |\texttt{\meaning\M}.\\ + |\meaning\M: |\digitstt{\meaning\M}.\\ \xintAssign\xintDSx {-20}{1234567689}\to\M {|\xintAssign\xintDSx {-20}{123456789}\to\M|}\\ - |\meaning\M: |\texttt{\meaning\M}.\\ + |\meaning\M: |\digitstt{\meaning\M}.\\ \xintAssign\xintDSx{0}{-123004321}\to\Q\R {|\xintAssign\xintDSx {0}{-123004321}\to\Q\R|}\\ - \noindent|\meaning\Q: |\texttt{\meaning\Q}, |\meaning\R: - |\texttt{\meaning\R.}\\ - |\xintDSH {0}{-123004321}=|\texttt{\xintDSH {0}{-123004321}}, - |\xintDSHr {0}{-123004321}=|\texttt{\xintDSHr {0}{-123004321}}\\ + \noindent|\meaning\Q: |\digitstt{\meaning\Q}, |\meaning\R: + |\digitstt{\meaning\R.}\\ + |\xintDSH {0}{-123004321}|\digitstt{=\xintDSH {0}{-123004321}}, + |\xintDSHr {0}{-123004321}|\digitstt{=\xintDSHr {0}{-123004321}}\\ \xintAssign\xintDSx {6}{-123004321}\to\Q\R {|\xintAssign\xintDSx {6}{-123004321}\to\Q\R|}\\ - |\meaning\Q: |\texttt{\meaning\Q}, - |\meaning\R: |\texttt{\meaning\R.}\\ - |\xintDSH {6}{-123004321}=|\texttt{\xintDSH {6}{-123004321}}, - |\xintDSHr {6}{-123004321}=|\texttt{\xintDSHr {6}{-123004321}}\\ + |\meaning\Q: |\digitstt{\meaning\Q}, + |\meaning\R: |\digitstt{\meaning\R.}\\ + |\xintDSH {6}{-123004321}|\digitstt{=\xintDSH {6}{-123004321}}, + |\xintDSHr {6}{-123004321}|\digitstt{=\xintDSHr {6}{-123004321}}\\ \xintAssign\xintDSx {8}{-123004321}\to\Q\R {|\xintAssign\xintDSx {8}{-123004321}\to\Q\R|}\\ - |\meaning\Q: |\texttt{\meaning\Q}, - |\meaning\R: |\texttt{\meaning\R.} \\ - |\xintDSH {8}{-123004321}=|\texttt{\xintDSH {8}{-123004321}}, - |\xintDSHr {8}{-123004321}=|\texttt{\xintDSHr {8}{-123004321}}\\ + |\meaning\Q: |\digitstt{\meaning\Q}, + |\meaning\R: |\digitstt{\meaning\R.} \\ + |\xintDSH {8}{-123004321}|\digitstt{=\xintDSH {8}{-123004321}}, + |\xintDSHr {8}{-123004321}|\digitstt{=\xintDSHr {8}{-123004321}}\\ \xintAssign\xintDSx {9}{-123004321}\to\Q\R {|\xintAssign\xintDSx {9}{-123004321}\to\Q\R|}\\ - |\meaning\Q: |\texttt{\meaning\Q}, - |\meaning\R: |\texttt{\meaning\R.}\\ - |\xintDSH {9}{-123004321}=|\texttt{\xintDSH {9}{-123004321}}, - |\xintDSHr {9}{-123004321}=|\texttt{\xintDSHr {9}{-123004321}}\\ + |\meaning\Q: |\digitstt{\meaning\Q}, + |\meaning\R: |\digitstt{\meaning\R.}\\ + |\xintDSH {9}{-123004321}|\digitstt{=\xintDSH {9}{-123004321}}, + |\xintDSHr {9}{-123004321}|\digitstt{=\xintDSHr {9}{-123004321}}\\ \end{flushleft} \subsection{\csbh{xintDecSplit}}\label{xintDecSplit} @@ -2370,25 +2709,25 @@ of the first and second piece. \xintAssign\xintDecSplit {0}{-123004321}\to\L\R \centeredline{|\xintAssign\xintDecSplit {0}{-123004321}\to\L\R|} -\noindent|\meaning\L: |\texttt{\meaning\L}, |\meaning\R: |\texttt{\meaning\R.} +\noindent|\meaning\L: |\digitstt{\meaning\L}, |\meaning\R: |\digitstt{\meaning\R.} \xintAssign\xintDecSplit {5}{-123004321}\to\L\R \centeredline{|\xintAssign\xintDecSplit {5}{-123004321}\to\L\R|} -|\meaning\L: |\texttt{\meaning\L}, |\meaning\R: |\texttt{\meaning\R.} +|\meaning\L: |\digitstt{\meaning\L}, |\meaning\R: |\digitstt{\meaning\R.} \xintAssign\xintDecSplit {9}{-123004321}\to\L\R \centeredline{|\xintAssign\xintDecSplit {9}{-123004321}\to\L\R|} -|\meaning\L: |\texttt{\meaning\L}, |\meaning\R: |\texttt{\meaning\R.} +|\meaning\L: |\digitstt{\meaning\L}, |\meaning\R: |\digitstt{\meaning\R.} \xintAssign\xintDecSplit {10}{-123004321}\to\L\R \centeredline{|\xintAssign\xintDecSplit {10}{-123004321}\to\L\R|} -|\meaning\L: |\texttt{\meaning\L}, |\meaning\R: |\texttt{\meaning\R.} +|\meaning\L: |\digitstt{\meaning\L}, |\meaning\R: |\digitstt{\meaning\R.} \xintAssign\xintDecSplit {-5}{-12300004321}\to\L\R \centeredline{|\xintAssign\xintDecSplit {-5}{-12300004321}\to\L\R|} -|\meaning\L: |\texttt{\meaning\L}, |\meaning\R: |\texttt{\meaning\R.} +|\meaning\L: |\digitstt{\meaning\L}, |\meaning\R: |\digitstt{\meaning\R.} \xintAssign\xintDecSplit {-11}{-12300004321}\to\L\R \centeredline{|\xintAssign\xintDecSplit {-11}{-12300004321}\to\L\R|} -|\meaning\L: |\texttt{\meaning\L}, |\meaning\R: |\texttt{\meaning\R.} +|\meaning\L: |\digitstt{\meaning\L}, |\meaning\R: |\digitstt{\meaning\R.} \xintAssign\xintDecSplit {-15}{-12300004321}\to\L\R \centeredline{|\xintAssign\xintDecSplit {-15}{-12300004321}\to\L\R|} -|\meaning\L: |\texttt{\meaning\L}, |\meaning\R: |\texttt{\meaning\R.} +|\meaning\L: |\digitstt{\meaning\L}, |\meaning\R: |\digitstt{\meaning\R.} \subsection{\csbh{xintDecSplitL}}\label{xintDecSplitL} @@ -2401,26 +2740,49 @@ of \csa{xintDecSplit}. of \csa{xintDecSplit}. + \section{Commands of the \xintfracname package}\label{sec:comfrac} \def\x{\string{x\string}} This package was first included in release |1.03| of the \xintname bundle. The general rule of the bundle that each macro first expands (what comes first, -fully) each one of its arguments applies. As in the previous documentation, |x| -stands for something which will be internally embedded in a \csa{numexpr}, thus -completely expanded and then must deliver a number obeying the TeX{} bounds. It -may be a count register or something like |4*\count 255 + 17|, etc... +fully) each one of its arguments applies. + -|f| stands for a fraction (or a possibly `long' integer), or something which -expands to a fraction or a possibly long integer. See the earlier section on -fraction formats. +|f| stands for an integer or a fraction (see \autoref{sec:inputs} for the +accepted input formats) or something which expands to an integer or fraction. It +is possible to use in the numerator or the denominator of |f| count +registers\MyMarginNote{Not previously documented} and even expressions with +infix arithmetic operators, under some rules which are explained in the previous +\hyperlink{useofcount}{Use of count registers} section. + +As in the \hyperref[sec:comxint]{xint.sty} documentation, |x| +stands for something which will internally be embedded in a \csa{numexpr}. +It +may thus be a count register or something like |4*\count 255 + 17|, etc..., but +must expand to an integer obeying the \TeX{} bound. + +The fraction format on output is the scientific notation for the `float' macros, +and the |A/B[n]| format for all other fraction macros, with the exception of +\csb{xintTrunc}, {\color{blue}\string\xint\-Round} (which produce decimal +numbers) +and \csb{xintIrr}, \csb{xintJrr}, \csb{xintRawWithZeros} (which return an |A/B| +with no trailing |[n]|, even if |B| turns out to be |1|). Use \csb{xintNum} for +fractions a priori known to simplify to integers: |\xintNum {\xintAdd {2}{3}}| +gives \digitstt{\xintNum {\xintAdd {2}{3}}} whereas |\xintAdd {2}{3}| returns +\digitstt{\xintAdd {2}{3}}. Some macros (among them \csb{xintiTrunc}, +\csb{xintiRound}, and \csb{xintFac}) already produce integers on output. + + +\localtableofcontents \subsection{\csbh{xintLen}}\label{xintLen} The original macro is extended to accept a fraction on input. -\centeredline {|\xintLen {201710/298219}=|\texttt{\xintLen {201710/298219}}, -|\xintLen {1234/1}=|\texttt{\xintLen {1234/1}}, |\xintLen {1234}=|\texttt{\xintLen {1234}}} +\centeredline {|\xintLen {201710/298219}|\digitstt{=\xintLen {201710/298219}}, +|\xintLen {1234/1}|\digitstt{=\xintLen {1234/1}}, |\xintLen {1234}|% + \digitstt{=\xintLen {1234}}} \subsection{\csbh{xintRaw}}\label{xintRaw} @@ -2430,35 +2792,39 @@ The original macro is extended to accept a fraction on input. This macro `prints' the fraction |f| as it is received by the package after its parsing and -expansion, in a printable form |a/b[n]| equivalent to the internal -representation: the denominator |b| is always strictly positive and is +expansion, in a printable form |A/B[n]| equivalent to the internal +representation: the denominator |B| is always strictly positive and is printed even if it has value |1|. -\centeredline{|\xintRaw{\the\numexpr 571*987\relax.123/\the\numexpr - -201+59\relax}=|}% -\centeredline{\texttt{\xintRaw{\the\numexpr - 571*987\relax.123/\the\numexpr -201+59\relax}}} +\centeredline{|\xintRaw{\the\numexpr 571*987\relax.123e-10/\the\numexpr + -201+59\relax e-7}=|}% +\centeredline{\digitstt{\xintRaw{\the\numexpr + 571*987\relax.123e-10/\the\numexpr -201+59\relax e-7}}} + \subsection{\csbh{xintRawWithZeros}}\label{xintRawWithZeros} -{\small New name in |1.07|.\par} +{\small New name in |1.07| (former name |\xintRaw|).\par} -This macro (formerly known as \csa{xintRaw}) `prints' the +This macro `prints' the fraction |f| (after its parsing and expansion) in |A/B| form, with |A| as returned by \csa{xintNumerator}|{f}| and |B| as returned by \csa{xintDenominator}|{f}|. -\centeredline{|\xintRawWithZeros{\the\numexpr 571*987\relax.123/\the\numexpr - -201+59\relax}=|}% -\centeredline{\texttt{\xintRawWithZeros{\the\numexpr - 571*987\relax.123/\the\numexpr -201+59\relax}}} +\centeredline{|\xintRawWithZeros{\the\numexpr 571*987\relax.123e-10/\the\numexpr + -201+59\relax e-7}=|}% +\centeredline{\digitstt{\xintRawWithZeros{\the\numexpr + 571*987\relax.123e-10/\the\numexpr -201+59\relax e-7}}} \subsection{\csbh{xintNumerator}}\label{xintNumerator} This returns the numerator corresponding to the internal representation of a fraction, with positive powers of ten converted into zeros of this numerator: \centeredline{|\xintNumerator - {178000/25600000[17]}=|\texttt{\xintNumerator {178000/25600000[17]}}}% -\centeredline{|\xintNumerator {312.289001/20198.27}=|\texttt{\xintNumerator {312.289001/20198.27}}}% -\centeredline{|\xintNumerator {178.000/25600000}=|\texttt{\xintNumerator + {178000/25600000[17]}|\digitstt{=\xintNumerator {178000/25600000[17]}}} +\centeredline{|\xintNumerator {312.289001/20198.27}|% + \digitstt{=\xintNumerator {312.289001/20198.27}}} +\centeredline{|\xintNumerator {178000e-3/256e5}|\digitstt{=\xintNumerator + {178000e-3/256e5}}} +\centeredline{|\xintNumerator {178.000/25600000}|\digitstt{=\xintNumerator {178.000/25600000}}} As shown by the examples, no simplification of the input is done. For a result uniquely associated to the value of the fraction first apply \csa{xintIrr}. @@ -2468,9 +2834,12 @@ first apply \csa{xintIrr}. This returns the denominator corresponding to the internal representation of the fraction:\footnote{recall that the |[]| construct excludes presence of a decimal point.} \centeredline{|\xintDenominator - {178000/25600000[17]}=|\texttt{\xintDenominator {178000/25600000[17]}}}% -\centeredline{|\xintDenominator {312.289001/20198.27}=|\texttt{\xintDenominator {312.289001/20198.27}}}% -\centeredline{|\xintDenominator {178.000/25600000}=|\texttt{\xintDenominator + {178000/25600000[17]}|\digitstt{=\xintDenominator {178000/25600000[17]}}}% +\centeredline{|\xintDenominator {312.289001/20198.27}|% + \digitstt{=\xintDenominator {312.289001/20198.27}}} +\centeredline{|\xintDenominator {178000e-3/256e5}|\digitstt{=\xintDenominator + {178000e-3/256e5}}} +\centeredline{|\xintDenominator {178.000/25600000}|\digitstt{=\xintDenominator {178.000/25600000}}} As shown by the examples, no simplification of the input is done. The denominator looks wrong in the last example, but the numerator was tacitly multiplied by &1000& through the removal of the decimal @@ -2486,12 +2855,14 @@ fraction, internally represented as something equivalent to |A/B[n]| as |\frac when it has value one, the number being separated from the power of ten by a |\cdot|. |$\xintFrac {178.000/25600000}$| gives $\xintFrac {178.000/25600000}$, |$\xintFrac {178.000/1}$| gives $\xintFrac {178.000/1}$, |$\xintFrac -{3.5/5.7}$| gives $\xintFrac {3.5/5.7}$, and |$\xintFrac {\xintIrr - {\xintFac{10}/|\allowbreak|\xintiSqr{\xintFac {5}}}}$| gives $\xintFrac {\xintIrr - {\xintFac{10}/\xintiSqr{\xintFac {5}}}}$. As shown by the examples, +{3.5/5.7}$| gives $\xintFrac {3.5/5.7}$, and |$\xintFrac {\xintNum + {\xintFac{10}/|\allowbreak|\xintiSqr{\xintFac {5}}}}$| gives + $\xintFrac {\xintNum {\xintFac{10}/\xintiSqr{\xintFac {5}}}}$. +As shown by the examples, simplification of the input (apart from removing the decimal points and moving the minus sign to the numerator) is not done automatically and must be -the result of macros such as |\xintIrr| or |\xintREZ|. +the result of macros such as |\xintIrr|, |\xintREZ|, or |\xintNum| (for +fractions being in fact integers.) \subsection{\csbh{xintSignedFrac}}\label{xintSignedFrac} @@ -2509,8 +2880,8 @@ used for the fraction (in case the denominator is not one; and a pair of braces contains the |A\over B| part). |$\xintFwOver {178.000/25600000}$| gives $\xintFwOver {178.000/25600000}$, |$\xintFwOver {178.000/1}$| gives $\xintFwOver {178.000/1}$, |$\xintFwOver {3.5/5.7}$| gives $\xintFwOver {3.5/5.7}$, and -|$\xintFwOver {\xintIrr {\xintFac{10}/\xintiSqr{\xintFac {5}}}}$| gives -$\xintFwOver {\xintIrr {\xintFac{10}/\xintiSqr{\xintFac {5}}}}$. +|$\xintFwOver {\xintNum {\xintFac{10}/\xintiSqr{\xintFac {5}}}}$| gives +$\xintFwOver {\xintNum {\xintFac{10}/\xintiSqr{\xintFac {5}}}}$. \subsection{\csbh{xintSignedFwOver}}\label{xintSignedFwOver} @@ -2524,43 +2895,60 @@ front, not in the numerator. \subsection{\csbh{xintREZ}}\label{xintREZ} -This command normalizes a fraction by removing the powers of ten in its -numerator and denominator: |\xintREZ {178000/25600000[17]}=|\texttt{\xintREZ - {178000/25600000[17]}}. As shown by the example, it does not otherwise -simplify the fraction. +This command normalizes a fraction by removing the powers of ten from its +numerator and denominator: |\xintREZ {178000/25600000[17]}|\digitstt{=\xintREZ + {178000/25600000[17]}}, |\xintREZ +{1780000000000e30/2560000000000e15}|\digitstt{=\xintREZ +{1780000000000e30/2560000000000e15}}. As shown by the example, it does not +otherwise simplify the fraction. \subsection{\csbh{xintE}}\label{xintE} {\small New with |1.07|.} |\xintE {f}{x}| multiplies the fraction |f| by &10^x&. The \emph{second} -argument |x| must obey the \TeX{} bounds. It may be a count register. +argument |x| must obey the \TeX{} bounds. It may be a count register: |\count +255 123456789 \xintE {10}{\count 255}|\digitstt{->\count +255 123456789 \xintE {10}{\count 255}}. Be careful that for obvious reasons such +gigantic numbers should not be given to \csb{xintNum}, or added to something +with a widely different order of magnitude, as the package always works to get +the \emph{exact} result. There is \emph{no problem} using them for +\emph{float} operations:\centeredline{|\xintFloatAdd + {1e1234567890}{1}|\digitstt{=\xintFloatAdd {1e1234567890}{1}}} \subsection{\csbh{xintIrr}}\label{xintIrr} +{\small \color{red}MODIFIED IN |1.08|.\par} This puts the fraction into its unique irreducible form: \centeredline{|\xintIrr - {178.256/256.178}=|% - \texttt{\xintIrr {178.256/256.178}}${}=\xintFrac{\xintIrr + {178.256/256.178}|% + \digitstt{=\xintIrr {178.256/256.178}}${}=\xintFrac{\xintIrr {178.256/256.178}[0]}$}% Note that the current implementation does not cleverly first factor powers of 2 and 5, so input such as |\xintIrr {2/3[100]}| will make \xintfracname do the Euclidean division of |2|\raisebox{.5ex}{|.|}|10^{100}| by |3|, which is a bit stupid. - +Starting with release |1.08|, \csa{xintIrr} does not remove the trailing |/1| +when the output is an integer. This makes things easier for post-treatment by +user defined macros. So the output format is now \emph{always} |A/B| with |B>0|. +Use \csb{xintNum} rather than \csa{xintIrr} if it is known that the output is an +integer and the trailing |/1| is a nuisance. \subsection{\csbh{xintJrr}}\label{xintJrr} +{\small \color{red}MODIFIED IN |1.08|.\par} This also puts the fraction into its unique irreducible form: -\centeredline{|\xintJrr {178.256/256.178}=|% - \texttt{\xintJrr {178.256/256.178}}}% +\centeredline{|\xintJrr {178.256/256.178}|% + \digitstt{=\xintJrr {178.256/256.178}}}% This is faster than \csa{xintIrr} for fractions having some big common factor in the numerator and the denominator.\par {\centering |\xintJrr {\xintiPow{\xintFac {15}}{3}/\xintiPrdExpr -{\xintFac{10}}{\xintFac{30}}{\xintFac{5}}\relax }=|\texttt{% +{\xintFac{10}}{\xintFac{30}}{\xintFac{5}}\relax }|\digitstt{=% \xintJrr {\xintiPow{\xintFac {15}}{3}/\xintiPrdExpr {\xintFac{10}}{\xintFac{30}}{\xintFac{5}}\relax }}\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| +when the output is an integer. \subsection{\csbh{xintTrunc}}\label{xintTrunc} @@ -2571,31 +2959,31 @@ be non-negative. When |x=0|, the integer part of |f| results, with an ending decimal point. Only when |f| evaluates to zero does \csa{xintTrunc} not print a decimal point. When |f| is not zero, the sign is maintained in the output, also when the digits are all zero. \centeredline{|\xintTrunc - {16}{-803.2028/20905.298}=|\texttt{\xintTrunc {16}{-803.2028/20905.298}}}% -\centeredline{|\xintTrunc {20}{-803.2028/20905.298}=|\texttt{\xintTrunc + {16}{-803.2028/20905.298}|\digitstt{=\xintTrunc {16}{-803.2028/20905.298}}}% +\centeredline{|\xintTrunc {20}{-803.2028/20905.298}|\digitstt{=\xintTrunc {20}{-803.2028/20905.298}}}% -\centeredline{|\xintTrunc {10}{\xintPow {-11}{-11}}=|\texttt{\xintTrunc +\centeredline{|\xintTrunc {10}{\xintPow {-11}{-11}}|\digitstt{=\xintTrunc {10}{\xintPow {-11}{-11}}}}% -\centeredline{|\xintTrunc {12}{\xintPow {-11}{-11}}=|\texttt{\xintTrunc +\centeredline{|\xintTrunc {12}{\xintPow {-11}{-11}}|\digitstt{=\xintTrunc {12}{\xintPow {-11}{-11}}}}% -\centeredline{|\xintTrunc {12}{\xintAdd {-1/3}{3/9}}=|\texttt{\xintTrunc +\centeredline{|\xintTrunc {12}{\xintAdd {-1/3}{3/9}}|\digitstt{=\xintTrunc {12}{\xintAdd {-1/3}{3/9}}}} The digits printed are exact up to and including the last one. The identity |\xintTrunc {x}{-f}=-\xintTrunc {x}{f}| -holds.\footnote{this is just a notation; currently |-\string\macro| is not valid - input to any package macro, one must use - |\string\xintOpp\string{\string\macro\string}| or - |\string\xintiOpp\string{\string\macro\string}|.} +holds.\footnote{Recall that |-\string\macro| is not valid as argument to any + package macro, one must use |\string\xintOpp\string{\string\macro\string}| or + |\string\xintiOpp\string{\string\macro\string}|, except inside + |\string\xinttheexpr...\string\relax|.} \subsection{\csbh{xintiTrunc}}\label{xintiTrunc} \csa{xintiTrunc}|{x}{f}| returns the integer equal to |10^x| times what \csa{xintTrunc}|{x}{f}| would return. \centeredline{|\xintiTrunc - {16}{-803.2028/20905.298}=|\texttt{\xintiTrunc {16}{-803.2028/20905.298}}}% + {16}{-803.2028/20905.298}|\digitstt{=\xintiTrunc {16}{-803.2028/20905.298}}}% \centeredline{|\xintiTrunc - {10}{\xintPow {-11}{-11}}=|\texttt{\xintiTrunc + {10}{\xintPow {-11}{-11}}|\digitstt{=\xintiTrunc {10}{\xintPow {-11}{-11}}}}% \centeredline{|\xintiTrunc - {12}{\xintPow {-11}{-11}}=|\texttt{\xintiTrunc + {12}{\xintPow {-11}{-11}}|\digitstt{=\xintiTrunc {12}{\xintPow {-11}{-11}}}}% Differences between \csa{xintTrunc}|{0}{f}| and \csa{xintiTrunc}|{0}{f}|: the former cannot be used inside integer-only macros, and the latter @@ -2611,21 +2999,21 @@ fraction |f|, rounded to |x| digits precision after the decimal point. The argument |x| should be non-negative. Only when |f| evaluates exactly to zero does \csa{xintRound} return |0| without decimal point. When |f| is not zero, its sign is given in the output, also when the digits printed are all zero. -\centeredline{|\xintRound {16}{-803.2028/20905.298}=|\texttt{\xintRound +\centeredline{|\xintRound {16}{-803.2028/20905.298}|\digitstt{=\xintRound {16}{-803.2028/20905.298}}}% \centeredline{|\xintRound - {20}{-803.2028/20905.298}=|\texttt{\xintRound {20}{-803.2028/20905.298}}}% + {20}{-803.2028/20905.298}|\digitstt{=\xintRound {20}{-803.2028/20905.298}}}% \centeredline{|\xintRound - {10}{\xintPow {-11}{-11}}=|\texttt{\xintRound + {10}{\xintPow {-11}{-11}}|\digitstt{=\xintRound {10}{\xintPow {-11}{-11}}}}% \centeredline{|\xintRound - {12}{\xintPow {-11}{-11}}=|\texttt{\xintRound + {12}{\xintPow {-11}{-11}}|\digitstt{=\xintRound {12}{\xintPow {-11}{-11}}}}% -\centeredline{|\xintRound {12}{\xintAdd {-1/3}{3/9}}=|\texttt{\xintRound +\centeredline{|\xintRound {12}{\xintAdd {-1/3}{3/9}}|\digitstt{=\xintRound {12}{\xintAdd {-1/3}{3/9}}}} The identity |\xintRound {x}{-f}=-\xintRound {x}{f}| holds. And regarding -$(-11)^{-11}$ here is some more or its expansion: -\centeredline{\xintTrunc {50}{\xintPow {-11}{-11}}\dots} +$(-11)^{-11}$ here is some more of its expansion: +\centeredline{\digitstt{\xintTrunc {50}{\xintPow {-11}{-11}}\dots}} \subsection{\csbh{xintiRound}}\label{xintiRound} @@ -2633,8 +3021,8 @@ $(-11)^{-11}$ here is some more or its expansion: \csa{xintiRound}|{x}{f}| returns the integer equal to |10^x| times what \csa{xintRound}|{x}{f}| would return. \centeredline{|\xintiRound - {16}{-803.2028/20905.298}=|\texttt{\xintiRound {16}{-803.2028/20905.298}}}% -\centeredline{|\xintiRound {10}{\xintPow {-11}{-11}}=|\texttt{\xintiRound + {16}{-803.2028/20905.298}|\digitstt{=\xintiRound {16}{-803.2028/20905.298}}}% +\centeredline{|\xintiRound {10}{\xintPow {-11}{-11}}|\digitstt{=\xintiRound {10}{\xintPow {-11}{-11}}}}% Differences between \csa{xintRound}|{0}{f}| and \csa{xintiRound}|{0}{f}|: the former cannot be used inside integer-only macros, and the @@ -2647,7 +3035,7 @@ all superfluous leading zeros.) The syntax |\xintDigits := D;| (where spaces do not matter) assigns the value of |D| to the number of digits to be used by floating point -operations. The default is |16|. The maximal value is |32768|. The macro +operations. The default is |16|. The maximal value is |32767|. The macro |\xinttheDigits| serves to print the current value. \subsection{\csbh{xintFloat}}\label{xintFloat} @@ -2656,13 +3044,23 @@ operations. The default is |16|. The maximal value is |32768|. The macro The macro |\xintFloat [P]{f}| has an optional argument |P| which replaces the current value of |\xintDigits|. The (rounded truncation of the) fraction -|f| is then printed in scientific form, with |P| digits (the trailing zeros -are not trimmed; except when |f| vanishes then the printed value is |0.e0|) -a lowercase |e| and an integer |N|. The first digit is from |1| to |9|, it -is followed by a dot and |P-1| digits. In the exceptional case where the -rouding went to the next power of ten, the printed value is |10.0...0eN| -(with a sign, perhaps). -\centeredline{|\xintFloat[32]{1234567/7654321}=|\texttt{\xintFloat[32]{1234567/7654321}}} +|f| is then printed in scientific form, with |P| digits, +a lowercase |e| and an exponent |N|. The first digit is from |1| to |9|, it is +preceded by an optional minus sign and +is followed by a dot and |P-1| digits, the trailing zeros +are not trimmed. In the exceptional case where the +rounding went to the next power of ten, the output is |10.0...0eN| +(with a sign, perhaps). The sole exception is for a zero value, which then gets +output as |0.e0| (in an \csa{xintCmp} test it is the only possible output of +\csa{xintFloat} or one of the `Float' macros which will test positive for +equality with zero). +\centeredline{|\xintFloat[32]{1234567/7654321}|% + \digitstt{=\xintFloat[32]{1234567/7654321}}} +% \pdfresettimer +\centeredline{|\xintFloat[32]{1/\xintFac{100}}|% + \digitstt{=\xintFloat[32]{1/\xintFac{100}}}} +% \the\pdfelapsedtime +% 992: plus rapide que ce que j'aurais cru.. The argument to \csa{xintFloat} may be an |\xinttheexpr|-ession, like the other macros; only its final evaluation is submitted to \csa{xintFloat}: the @@ -2673,8 +3071,7 @@ mode. For this one must use |\xintthefloatexpr|. \subsection{\csbh{xintAdd}}\label{xintAdd} The original macro is extended to accept fractions on input. Its output will now -always be in the form |A/B[n]|. -The original is available as \csb{xintiAdd}. +always be in the form |A/B[n]|. The original is available as \csb{xintiAdd}. \subsection{\csbh{xintFloatAdd}}\label{xintFloatAdd} @@ -2737,45 +3134,111 @@ approximations, with 2 safety digits. It then divides exactly and outputs in float format with precision |P| (which is optional), or |\xintDigits| if |P| was absent, the result of this computation. + +\subsection{\csbh{xintFac}}\label{xintFac} +{\small Modified in |1.08b| (to allow fractions on input).\par} + +The original is extended to allow a fraction on input but this fraction |f| must +simplify to a integer |n| (non negative and at most |999999|, but already +|100000!| is prohibitively time-costly). On output |n!| +(no trailing |/1[0]|). The original macro +(which has less overhead) is still +available as \csb{xintiFac}. + \subsection{\csbh{xintPow}}\label{xintPow} -The original macro is extended to accept a fraction on input (the exponent must -be a signed integer of course). Its output will now always be in the form -|A/B[n]|. The original is available as \csb{xintiPow}. +\csa{xintPow}{|{f}{g}|}: the original macro is extended to accept fractions on +input. The output will now always be in the form +|A/B[n]| (even when the exponent vanishes: |\xintPow +{2/3}{0}|\digitstt{=\xintPow{2/3}{0}}). The original is available as +\csb{xintiPow}. + +% \xintDigits:= 3; + +The exponent is allowed\MyMarginNote{Changed in |1.08b|} to be input as a +fraction but it must simplify to an integer: |\xintPow +{2/3}{10/2}|\digitstt{=\xintPow {2/3}{10/2}}. This integer will be checked to +not exceed |999999999|; future releases will presumably lower this limit as +even much much smaller values already create gigantic numerators and +denominators which can not be computed exactly in a reasonable time. Indeed +|2^999999999| has \digitstt{\xintLen {\xintFloatPow [1]{2}{999999999}}} digits. + + + +% \xintDigits:= 16; \subsection{\csbh{xintFloatPow}}\label{xintFloatPow} +{\small New with |1.07|.\par} + +|\xintFloatPow [P]{f}{x}| uses either the optional argument |P| or the value of +|\xintDigits|. It computes a floating approximation to |f^x|. + +The exponent |x| will be fed to a |\numexpr|, hence count registers are accepted +on input for this |x|. And the absolute value \verb+|x|+ must obey the \TeX{} +bound. For larger exponents use the slightly slower routine \csb{xintFloatPower} +which allows the exponent to be a fraction simplifying to an integer and does +not limit its size. This slightly slower routine is the one to which |^| is +mapped inside |\xintthefloatexpr...\relax|. + + +The macro |\xintFloatPow| chooses dynamically an appropriate number of +digits for the intermediate computations, large enough to achieve the desired +accuracy (hopefully). + +\centeredline{|\xintFloatPow [8]{3.1415}{1234567890}|% + \digitstt{=\xintFloatPow [8]{3.1415}{1234567890}}} -{\small New with release |1.07|.\par} -|\xintFloatPow [P]{f}{x}| uses either the optional argument |P| or the value -of |\xintDigits|. It computes a floating approximation to |f^x|. The -exponent |x| must obey the \TeX{} bounds. Count registers are accepted on -input. Depending on the values of the asked for precision and the size of -|P|, |\xintFloatPow| chooses a number of digits for intermediate -computations, hopefully large enough to achieve in the end the desired -accuracy. \subsection{\csbh{xintFloatPower}}\label{xintFloatPower} +{\small New with |1.07|.\par} -{\small New with release |1.07|.\par} +\csa{xintFloatPower}|{f}{g}| computes a floating point value |f^g| where the +exponent |g| is not constrained to be at most the \TeX{} bound +\texttt{\number "7FFFFFFF}. It may even be a +fraction |A/B| but must simplify to an integer. +\centeredline{|\xintFloatPower [8]{1.000000000001}{1e12}|% + \digitstt{=\xintFloatPower [8]{1.000000000001}{1e12}}} +\centeredline{|\xintFloatPower [8]{3.1415}{3e9}|% + \digitstt{=\xintFloatPower [8]{3.1415}{3e9}}} +Note that |3e9>2^31|. But the number following |e| in the output must at any +rate obey the \TeX{} +\digitstt{\number"7FFFFFFF} bound. -This is a slightly slower variant of \csb{xintFloatPow} for which the -exponent |x| may exceed the \TeX{} bounds on integers. It may even be a -fraction |a/b| but must be an integer in disguise. However it can not be a -count register anymore (except if the count is prefixed by |\the|). -\centeredline{|\xintFloatPower [8]{1.00000000001}{1e11}=|\texttt{\xintFloatPower [8]{1.00000000001}{1e11}}} -This was for illustrative purposes as the previous computation takes already -about a seventh of a second on my laptop. -This is the function used by the |^| operator in an |\xintfloatexpr|. -\centeredline{|\xintthefloatexpr 12.5607^(144/3/(1.3-.5)-37)\relax=|\texttt{\xintthefloatexpr 12.5607^(144/3/(1.3-.5)-37)\relax}} -The parenthesized exponent must expand to an integer (here |23|). +Inside an |\xintfloatexpr|-ession, \csa{xintFloatPower} is the function to which +|^| is mapped. The exponent may then be something like |(144/3/(1.3-.5)-37)| +which is, in disguise, an integer. -The intermediate multiplications are done with a higher precision that -|\xintDigits| or the optional |P| argument within brackets, in order for the + +The intermediate multiplications are done with a higher precision than +|\xintDigits| or the optional |P| argument, in order for the final result to hopefully have the desired accuracy. -\subsection{\csbh{xintSum}, \csbh{xintSumExpr}}\label{xintSum}\label{xintSumExpr} +\subsection{\csbh{xintFloatSqrt}}\label{xintFloatSqrt} +{\small New with |1.08|.\par} + +\csa{xintFloatSqrt}|[P]{f}| computes a floating point approximation of +$\sqrt{|f|}$, either using the optional precision |P| or the value of +|\xintDigits|. The computation is done for a precision of at least 17 figures +(and the output is rounded if the asked-for precision was smaller). +\centeredline{|\xintFloatSqrt [50]{12.3456789e12}|}% +\centeredline{${}\approx{}$\digitstt{\xintFloatSqrt [50]{12.3456789e12}}}% +\centeredline{|\xintDigits:=50;\xintFloatSqrt {\xintFloatSqrt {2}}|}% +\centeredline{% + ${}\approx{}$\xintDigits:=50;\digitstt{\xintFloatSqrt {\xintFloatSqrt {2}}}} + +% maple: 0.351364182864446216166582311675807703715914271812431919843183 1O^7 +% 3.5136418286444621616658231167580770371591427181243e6 +% maple: 1.18920711500272106671749997056047591529297209246381741301900 +% 1.1892071150027210667174999705604759152929720924638e0 + + +\xintDigits:=16; + + +\subsection{\csbh{xintSum}, \csbh{xintSumExpr}}\label{xintSum}% le % inutile +\label{xintSumExpr} The original commands are extended to accept fractions on input and produce fractions on output. Their outputs will now always be in the form |A/B[n]|. The @@ -2785,30 +3248,50 @@ originals are available as \csa{xintiSum} and \csa{xintiSumExpr}. \subsection{\csbh{xintPrd}, \csbh{xintPrdExpr}}\label{xintPrd}\label{xintPrdExpr} The originals are extended to accept fractions on input and produce fractions on -output. Their outputs will now always be in the form |A/B[n]|. The -originals are available as \csa{xintiPrd} and \csa{xintiPrdExpr}. +output. Their outputs will now always be in the form |A/B[n]|. The originals are +available as \csa{xintiPrd} and \csa{xintiPrdExpr}. \subsection{\csbh{xintCmp}}\label{xintCmp} +{\small Rewritten in |1.08a|.\par} The macro is extended to fractions. Of course its output is still either |-1|, |0|, or |1| with no forward slash nor trailing |[n]|. The original, which skips the overhead of the fraction format parsing, is available as \csb{xintiCmp}. +For choosing branches according to the result of comparing |f| and |g|, the +following syntax is recommended: |\xintSgnFork{\xintCmp{f}{g}}{code for + f<g}{code for f=g}{code for f>g}|. + +Note that since release |1.08a| using this macro on inputs with large powers of +tens does not take a quasi-infinite time, contrarily to the earlier, somewhat +dumb version (the earlier version indirectly led to the creation of giant chains +of zeros in certain circumstances, causing a serious efficiency impact). + \subsection{\csbh{xintGeq}}\label{xintGeq} +{\small Rewritten in |1.08a|.\par} The macro is extended to fractions. The original, which skips the overhead of -the fraction format parsing, is available as \csb{xintiGeq} (strangely this -extended version was only provided with release |1.07|, contrarily to -\csa{xintMax}, \csa{xintMin}, \csa{xintCmp}). +the fraction format parsing, is available as \csb{xintiGeq}. Beware that the +comparison is on +the \emph{absolute values} of the fractions. Can be used as: +\verb+\xintSgnFork{\xintGeq{f}{g}}{}{code for |f|<|g|}{code for + |f|+$\geqslant$\verb+|g|}+ + + +Same improvements in |1.08a| as for +\csb{xintCmp}. \subsection{\csbh{xintMax}}\label{xintMax} +{\small Rewritten in |1.08a|.\par} The macro is extended to fractions. But now |\xintMax {2}{3}| returns -\texttt{\xintMax {2}{3}}. The original is available as -\csb{xintiMax}. +\digitstt{\xintMax {2}{3}}. The original is available as +\csb{xintiMax}. + \subsection{\csbh{xintMin}}\label{xintMin} +{\small Rewritten in |1.08a|.\par} The macro is extended to fractions. The original is available as \csb{xintiMin}. @@ -2816,8 +3299,8 @@ The macro is extended to fractions. The original is available as \subsection{\csbh{xintAbs}}\label{xintAbs} The macro is extended to fractions. The original is available as -\csb{xintiAbs}. Note that |\xintAbs {-2}=|\texttt{\xintAbs {-2}} whereas -|\xintiAbs {-2}=|\texttt{\xintiAbs {-2}}. +\csb{xintiAbs}. Note that |\xintAbs {-2}|\digitstt{=\xintAbs {-2}} whereas +|\xintiAbs {-2}|\digitstt{=\xintiAbs {-2}}. \subsection{\csbh{xintSgn}}\label{xintSgn} @@ -2829,9 +3312,10 @@ available as \csb{xintiSgn}. \subsection{\csbh{xintOpp}}\label{xintOpp} The macro is extended to fractions. The original is available as -\csb{xintiOpp}. Note that |\xintOpp {3}| now outputs \texttt{\xintOpp {3}}. +\csb{xintiOpp}. Note that |\xintOpp {3}| now outputs \digitstt{\xintOpp {3}}. -\subsection{\csbh{xintDivision}, \csbh{xint\-Quo}, \csbh{xint\-Rem}, \csbh{xintFDg}, \csbh{xintLDg}, \csbh{xintMON}, \csbh{xintMMON}} +\subsection{\csbh{xintDivision}, \csbh{xint\-Quo}, \csbh{xint\-Rem}, + \csbh{xintFDg}, \csbh{xintLDg}, \csbh{xintMON}, \csbh{xintMMON}, \csbh{xintOdd}} These macros are extended to accept a fraction on input if this fraction in fact reduces to an integer (if not an |\xintError:NotAnInteger| will @@ -2844,16 +3328,26 @@ in the accepted format for the inputs. The macro is extended to accept a fraction on input. But this fraction should reduce to an integer. If not an error will be raised. The original is available -as \csb{xintiNum}. +as \csb{xintiNum}. It is imprudent to apply \csa{xintNum} to numbers with a +large power of ten given either in scientific notation or with the |[n]| +notation, as the macro will add the necessary zeros to get an explicit +integer.\centeredline{|\xintNum {1e80}|} +\centeredline{\digitstt{\xintNum{1e80}}} -\section{Expandable expressions with the \xintexprname package}\label{sec:comexpr} + +\section{Expandable expressions with the \xintexprname package}% +\label{sec:comexpr} + +\SetInnerTocdepthTo {2} The \xintexprname package was first released with version |1.07| of the \xintname bundle. Loading this package automatically loads \xintfracname, hence also \xintname. +\localtableofcontents -\subsection{The \csbh{xintexpr} expressions}\label{xintexpr}\label{xinttheexpr}\label{xintthe} +\subsection{The \csbh{xintexpr} expressions}\label{xintexpr}% +\label{xinttheexpr}\label{xintthe} An \xintexprname{}ession is a construct @@ -2865,20 +3359,21 @@ contents during the scanning): \item integers or decimal numbers, such as |123.345|, or numbers in scientific notation |6.02e23| or |6.02E23| (or anything expanding to these things; a decimal number may start directly with a decimal point), -\item fractions |a/b|, or |a.b/c.d| or |a.beN/c.deM|, if they are to be treated - as one entity should then be parenthesized, \emph{e.g.} disambiguating |a/b^2| - from |(a/b)^2|, -\item fractions |a/b[n]| as produced on output by the macros of the +\item fractions |A/B|, or |a.b/c.d| or |a.beN/c.deM|, if they are to be treated + as one entity should then be parenthesized, \emph{e.g.} disambiguating |A/B^2| + from |(A/B)^2|, +\item fractions |A/B[n]| as produced on output by the macros of the \xintfracname package; they \emph{must} be enclosed in one pair of braces, for example |{13/35[3]}| or |{\x\y\z}| with |\x| expanding to |13/|, |\y| expanding to |35[| and |\z| expanding to |3]|, (\emph{note that using parentheses does not suffice, braces are required: the parser can not digest - directly square brackets. Material within braces \emph{must} - after complete expansion give something in the {\upshape|a/b[n]|} form. - Braces should not be used for numbers in scientific notation, or macros - expanding to something else than a fraction, etc..., but exclusively for - material expanding to an {\upshape|a/b[n]|}; of course braces also appear in - the completely other r\^ole of feeding macros with their parameters.}), + directly square brackets. Material within braces \emph{must} after complete + expansion give either an integer {\upshape|A|} or a fraction in + {\upshape|A/B|} or {\upshape|A/B[n]|} form; it is only in the latter case + that braces are mandatory. They should \emph{not} be used for material + expanding to a fraction in scientific notation, or something else than an + integer or fraction, etc... of course braces also appear in the completely + other r\^ole of feeding macros with their parameters.}), \item the standard binary operators, |+|, |-|, |*|, |/|, and |^| (the |**| notation for exponentiation is not recognized and will give an error), \item opening and closing parentheses, with arbitrary level of nesting, @@ -2898,20 +3393,21 @@ uses one of the two equivalent forms: \end{itemize} Both forms are equivalent and produce, always, a fraction in the standard -|a/b[n]| format (even when the result is an integer; as usual no automatic +|A/B[n]| format (even when the result is an integer; as usual no automatic simplification is done, and adding fractions multiplies all the denominators). \centeredline{|\xinttheexpr - 1+1/2!+1/3!+1/4!+1/5!\relax=|\texttt{\xinttheexpr1+1/2!+1/3!+1/4!+1/5!\relax}} + 1+1/2!+1/3!+1/4!+1/5!\relax|\digitstt{=\xinttheexpr1+1/2!+1/3!+1/4!+1/5!\relax}} One will usually post-process with |\xintIrr|, |\xintTrunc| or |\xintRound|, or |\xintFloat|, or |\xintNum| (when the output is known to be an integer) to get the result in the desired form. One may imagine some future version where the output format will be given as optional argument to |\xintexpr|. \centeredline{|\xintIrr{\xinttheexpr - 1+1/2!+1/3!+1/4!+1/5!\relax}=|\texttt{\xintIrr{\xinttheexpr1+1/2!+1/3!+1/4!+1/5!\relax}}} -\centeredline{|\xinttheexpr 1.99^-2 - 2.01^-2 \relax=|\texttt{\xinttheexpr + 1+1/2!+1/3!+1/4!+1/5!\relax}|% + \digitstt{=\xintIrr{\xinttheexpr1+1/2!+1/3!+1/4!+1/5!\relax}}} +\centeredline{|\xinttheexpr 1.99^-2 - 2.01^-2 \relax|\digitstt{=\xinttheexpr 1.99^-2 - 2.01^-2 \relax}} \centeredline{|\xintRound{10}{\xinttheexpr - 1.99^-2 - 2.01^-2 \relax}=|\texttt{\xintRound{10}{\xinttheexpr 1.99^-2 - + 1.99^-2 - 2.01^-2 \relax}|\digitstt{=\xintRound{10}{\xinttheexpr 1.99^-2 - 2.01^-2 \relax}}} \smallskip @@ -2925,7 +3421,7 @@ Again: numbers written in scientific notation, (or anything expanding to the previous things), \item fractions on input which contain the |[n]| part, or macros expanding to - some |a/b[n]| with the trailing |[n]| must be enclosed in + some |A/B[n]| with the trailing |[n]| must be enclosed in (precisely one) pair of braces to be parsable by the expression scanner,\footnote{the reason why the braced material should not be a number in scientific notation is that the `e' will become of catcode other and not be @@ -2938,11 +3434,11 @@ Again: \item sub-contents evaluating to fractions should be either \begin{enumerate} \item parenthesized,\footnote{recall that the parser does not produce - explicit fractions |a/b[n]|, hence the bracing rule does not + explicit fractions |A/B[n]|, hence the bracing rule does not apply to the result of the evaluation of the contents within parentheses; except of course if it was produced by some other means giving an - explicit |a/b[n]|, but then braces should have been used, not + explicit |A/B[n]|, but then braces should have been used, not parentheses.} \item a sub-expression |\xintexpr...\relax|, \item or braced (use of infix operators inside the braced material will have @@ -2954,7 +3450,7 @@ Again: \item an expression can not be given as argument to the other package macros, nor printed, for this one must use |\xinttheexpr...\relax| or |\xintthe\xintexpr...\relax|, -\item the output of these latter expressions is always in the |a/b[n]| +\item the output of these latter expressions is always in the |A/B[n]| form, and may serve as input to the other package macros accepting fractions, \item |\xinttheexpr...\relax| as a sub-constituent of an |\xintexpr...\relax| must be within some braces, else it should be written directly as @@ -2986,32 +3482,37 @@ decimal point. \subsection{Catcodes and spaces} -The |\xintexpr| is very agnostic regarding catcodes: digits, binary operators, -minus and plus signs as prefixes, parentheses, decimal point, may be -indifferently of catcode letter or other or subscript or superscript, ..., it -does not matter. Of course |+|, |-|, |*|, |/|, and |^| should not be active -as everything is expanded along the way. If |!| has been made active (done by -Babel for certain languages) then it should be prefixed with |\string| to serve -for the factorial; or the macro |\xintFac| may of course be used, preferably -within braces as this will avoid the subsequent slow scan digit by digit of its -expansion (other macros from the \xintfracname package generally \emph{must} be -used within a brace pair, as they expand to a fraction |a/b[n]| which can not be -directly parsed inside an \xintname{}expression; the |\xintFac| produces an -integer and braces are only optional, but preferable, as the scanner will -get the job done faster.) + +Spaces inside an |\xinttheexpr...\relax| should mostly be +innocuous\footnote{release |1.08b| fixes a bug in this context.} (if the +expression contains macros, then it is the macro which is responsible for +grabbing its arguments, so spaces within the arguments are presumably to be +avoided, as a general rule.). + +|\xintexpr| and |\xintthexpr| are very agnostic regarding catcodes: digits, +binary operators, minus and plus signs as prefixes, parentheses, decimal point, +may be indifferently of catcode letter or other or subscript or superscript, +..., it does not matter. Of course |+|, |-|, |*|, |/|, |^| or |!| should not be +active as everything is expanded along the way. If one of them (especially |!| +which is made active by Babel for certain languages) is active, it should be +prefixed with |\string|. In the case of the factorial, the macro |\xintFac| may +be used rather than the postfix |!|, preferably within braces as this will avoid +the subsequent slow scan digit by digit of its expansion (other macros from the +\xintfracname package generally \emph{must} be used within a brace pair, as they +expand to fractions |A/B[n]| with the trailing |[n]|; the |\xintFac| produces an +integer with no |[n]| and braces are only optional, but preferable, as the +scanner will get the job done faster.) Sub-material within braces is treated technically in a different manner, and depending on the macros used therein may be more sensitive to the catcode of the five operations (the minus sign as prefix in particular). Digits, slash, square brackets, sign, produced on output by an |\xinttheexpr| are all of catcode 12. -For the output of |\xintthefloatexp| digits, decimal dot, signs are of catcode +For the output of |\xintthefloatexpr| digits, decimal dot, signs are of catcode 12, and the `e' is of catcode 11. Note that if some macro is inserted in the expression it will expand and grab its arguments before the parser may get a chance to see them, so the situation -with catcodes and spaces is not as flexible within the macro arguments as it is -for top-level material (top-level here does not refer to the nesting of -parentheses). +with catcodes and spaces is not as flexible within the macro arguments. \subsection{Expandability} @@ -3132,21 +3633,24 @@ simpler examples: |\meaning\DET:|\printnumber{\meaning\DET}\endgraf -\centeredline{|\xintNum{\DET {1}{1}{1}{10}{-10}{5}{11}{-9}{6}}=|\texttt{\xintNum{\DET {1}{1}{1}{10}{-10}{5}{11}{-9}{6}}}}% -\centeredline{|\xintNum{\DET {1}{2}{3}{10}{0}{-10}{21}{2}{-17}}=|\texttt{\xintNum{\DET {1}{2}{3}{10}{0}{-10}{21}{2}{-17}}}} +\centeredline{|\xintNum{\DET {1}{1}{1}{10}{-10}{5}{11}{-9}{6}}|% + \digitstt{=\xintNum{\DET {1}{1}{1}{10}{-10}{5}{11}{-9}{6}}}}% +\centeredline{|\xintNum{\DET {1}{2}{3}{10}{0}{-10}{21}{2}{-17}}|% + \digitstt{=\xintNum{\DET {1}{2}{3}{10}{0}{-10}{21}{2}{-17}}}} \rmfamily \emph{Remark:} |\meaning| has been used within the argument to a |\printnumber| -command, to avoid going into the right margin, but this zaps all spaces which -are actually initially there in the macro definitions. Here is the raw output of +command, to avoid going into the right margin, but this zaps all spaces +originally in the output from |\meaning|. Here is as an illustration the raw +output of |\meaning| on the last example: \ttfamily \meaning\DET \rmfamily -So, |\printnumber| was used to facilitate the breaking accross lines. +This is why |\printnumber| was used, to have breaks across lines. \smallskip @@ -3226,7 +3730,7 @@ The principles were explained earlier: \end{enumerate} The produced macro |\myfunction| turns out to have meaning in this last case: -\texttt{\printnumber{\meaning\myfunction }} +\digitstt{\printnumber{\meaning\myfunction }} The reason why these created macros are made to start with |\romannumeral0\xintraw| is in order for them to expand in only two steps. Of @@ -3252,8 +3756,8 @@ following: we would discover that it would not compile, despite seemingly following the enunciated rules. I recall: \begin{enumerate}\setcounter{enumi}{4} -\item braced material, if not an argument to a macro, must correspond to the - evaluation of a fraction to |a/b[n]| form, and in particular it can not be +\item braced material, if not an argument to a macro, should correspond to the + evaluation of a fraction, and in particular it can not be used to produce an infix operator or an opening or closing parenthesis, etc... \end{enumerate} @@ -3266,7 +3770,7 @@ We could try then: | This time, |\xintNewExpr| works but the produced |\formula| has meaning \xintNewExpr\formula[3]{{_2:xintSgnFork{:xintSgn{_1}}+-*_3}}\endgraf -\noindent\texttt{\printnumber{\meaning\formula}}\endgraf +\noindent\digitstt{\printnumber{\meaning\formula}}\endgraf Clearly this macro will not work. We may try @@ -3276,7 +3780,7 @@ We may try | but this gives \xintNewExpr\formula[3]{{:xinttheexpr _2:xintSgnFork{:xintSgn{_1}}+-*_3:relax}}\endgraf -\noindent\texttt{\printnumber{\meaning\formula}} +\noindent\digitstt{\printnumber{\meaning\formula}} and there was no point whatsoever in it all, as what we want is to avoid the use of |\xintexpr|\dots so we end up having to do: @@ -3296,37 +3800,45 @@ useful on more complicated cases with a high level of nesting of macros. \subsection{\csbh{xintfloatexpr}, \csbh{xintthefloatexpr}}\label{xintfloatexpr}\label{xintthefloatexpr} -\csb{xintfloatexpr}|...\relax| is exactly like |\xintexpr| but the four -binary operations and the power function are implemented using -\csa{xintFloatAdd}, \csa{xintFloatSub}, \csa{xintFloatMul}, -\csa{xintFloatDiv} and \csa{xintFloatPower}. The number of digits is from -the current setting of |\xintDigits|. +\csb{xintfloatexpr}|...\relax| is exactly like |\xintexpr...\relax| but with the +four binary operations and the power function mapped to \csa{xintFloatAdd}, +\csa{xintFloatSub}, \csa{xintFloatMul}, \csa{xintFloatDiv} and +\csa{xintFloatPower}. The precision is from the current setting of +|\xintDigits| (it can not be given as an optional parameter). + +Currently, the factorial function hasn't yet a float version; so inside +|\xintthefloatexpr . . . \relax|, |n!| will be computed exactly. Perhaps this +will +be improved in a future release. \xintDigits:= 9; -Note that |1.000000001| and |(1+1e-9)| will not be equivalent with -|D=\xinttheDigits| set to nine or less. Indeed the addition implicit in -|1+1e-9| (and executed when the closing parenthesis is found) will provoke -the rounding to |1|. Whereas |1.000000001| is input as operand to the -elementary operations with |D+2| digits, and even more for the power function. +Note that |1.000000001| and |(1+1e-9)| will not be equivalent for +|D=\xinttheDigits| set to nine or less. Indeed the addition implicit in |1+1e-9| +(and executed when the closing parenthesis is found) will provoke the rounding +to |1|. Whereas |1.000000001|, when found as operand of one of the four +elementary operations is kept with |D+2| digits, and even more for the power +function. \centeredline{|\xintDigits:= 9; \xintthefloatexpr + (1+1e-9)-1\relax|\digitstt{=\xintthefloatexpr (1+1e-9)-1\relax}} \centeredline{|\xintDigits:= 9; \xintthefloatexpr - (1+1e-9)-1\relax=|\texttt{\xintthefloatexpr (1+1e-9)-1\relax}} -\centeredline{|\xintDigits:= 9; \xintthefloatexpr - 1.000000001-1\relax=|\texttt{\xintthefloatexpr 1.000000001-1\relax}} + 1.000000001-1\relax|\digitstt{=\xintthefloatexpr 1.000000001-1\relax}} For the fun of it:\xintDigits:=20; |\xintDigits:=20;|% -\centeredline{|\xintthefloatexpr (1+1e-7)^1e7\relax=|\texttt{\xintthefloatexpr (1+1e-7)^1e7\relax}} +\centeredline{|\xintthefloatexpr (1+1e-7)^1e7\relax|% + \digitstt{=\xintthefloatexpr (1+1e-7)^1e7\relax}} |\xintDigits:=36;|\xintDigits:=36; \centeredline{|\xintthefloatexpr ((1/13+1/121)*(1/179-1/173))/(1/19-1/18)\relax|} -\centeredline{\texttt{\xintthefloatexpr +\centeredline{\digitstt{\xintthefloatexpr ((1/13+1/121)*(1/179-1/173))/(1/19-1/18)\relax}} \centeredline{|\xintFloat{\xinttheexpr ((1/13+1/121)*(1/179-1/173))/(1/19-1/18)\relax}|} -\centeredline{\texttt{\xintFloat +\centeredline{\digitstt{\xintFloat {\xinttheexpr((1/13+1/121)*(1/179-1/173))/(1/19-1/18)\relax}}} +\xintDigits := 16; + The latter result is the rounding of the exact result. The previous one has rounding errors coming from the various roundings done for each sub-expression. It was a bit funny to discover that |maple|, configured with @@ -3343,28 +3855,42 @@ otherwise if one starts using the Power function. Then, |\xintthefloat| is often useful; and sometimes indispensable to achieve the (approximate) computation in reasonable time. -We can try some crazy things:\footnote{this evaluation takes a little more than - a - quarter of a second on my laptop. Recall the constraints of expandability.} +We can try some crazy things:\footnote{this evaluation takes a about a fifth of a second already on my laptop. Recall the constraints of expandability.} \centeredline{|\xintDigits:=12;\xintthefloatexpr 1.000000000000001^1e15\relax|} -\centeredline{\xintDigits:=12;\xintthefloatexpr 1.000000000000001^1e15\relax} +\centeredline{\xintDigits:=12;% +\digitstt{\xintthefloatexpr 1.000000000000001^1e15\relax}} Note that contrarily to some professional computing sofware which are our -concurrents on this market, the \texttt{\np{1.000000000000001}} wasn't rounded -to |1| despite the setting of \csa{xintDigits}; it would if we had input it as +concurrents on this market, the \digitstt{1.000000000000001} wasn't rounded +to |1| despite the setting of \csa{xintDigits}; it would have been if we had +input it as |(1+1e-15)|. -\xintDigits := 16; +% \xintDigits:=12; +% \pdfresettimer +% \edef\z{\xintthefloatexpr 1.000000000000001^1e15\relax}% +% \edef\temps{\the\pdfelapsedtime}% +% \xintRound {5}{\temps/65536}s\endgraf + + +\xintDigits := 16; % mais en fait \centeredline crée un groupe. + \subsection{\csbh{xintNewFloatExpr}}\label{xintNewFloatExpr} This is exactly like \csb{xintNewExpr} except that the created formulas are -set-up to use |\xintthefloatexpr|. The precision used will be the one +set-up to use |\xintthefloatexpr|. The precision used for numbers fetched as +parameters will be the one locally given by |\xintDigits| at the time of use of the created formulas, -not |\xintNewFloatExpr|. +not |\xintNewFloatExpr|. However, the numbers hard-wired in the original +expression will have been evaluated with the then current setting for +|\xintDigits|. + + + \xintDigits:= 16; -\subsection{\mbox{Technicalities~and~experimental~status}~ \allowbreak\null\hspace*{.5cm}} +\subsection{Technicalities and experimental status} As already mentioned \csa{xintNewExpr}|\myformula[n]| does not check the prior existence of a macro |\myformula|. And the number of parameters |n| given @@ -3376,11 +3902,11 @@ expansion-only context, as it creates a macro. The format of the output of |\xintexpr|\meta{stuff}|\relax| is a |!| (with catcode 11) followed by |\XINT_expr_illegaluse| which prints an error message in -the document and in the log file if it is executed, and next a token |\.a/b[n]| +the document and in the log file if it is executed, and next a token |\.A/B[n]| (which is a single control sequence: these are the famous things which may impact the hash-table). Using |\xinttheexpr| means zapping the first two things, and opening up the third token to access its name and get the result -|a/b[n]| of the evaluation of the expression. +|A/B[n]| of the evaluation of the expression. I decided to put all intermediate results (from each evaluation of an infix operators, or of a parenthesized subpart of the expression, or from application @@ -3407,7 +3933,7 @@ extraneous parentheses. I was greatly helped in my preparatory thinking, prior to producing such an expandable parser, by the commented source of the -\href{http://www.ctan.org/tex-archive/macros/latex/contrib/l3kernel}{\color{niceone}l3fp} +\href{http://www.ctan.org/tex-archive/macros/latex/contrib/l3kernel}{l3fp} package, specifically the |l3fp-parse.dtx| file. Also the source of the |calc| package was instructive, despite the fact that here for |\xintexpr| the principles are necessarily different due to the aim of achieving expandability. @@ -3417,20 +3943,103 @@ comments currently in my own code, the reason being that this a time-consuming task which should wait until the code has a rather certain more-or-less final form. +\section{Commands of the \xintbinhexname package}\label{sec:combinhex} + +\SetInnerTocdepthTo {1} + +This package was first included in the |1.08| release of \xintname. It +provides expandable conversions of arbitrarily long numbers +to and from binary and hexadecimal. + +The argument is first fully expanded. It then may start with an optional minus +sign (unique, of category code other), followed with optional leading zeros +(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 zeros are allowed, and stripped. The +hexadecimal letters on output are of category code letter, and +uppercased. + +% \clearpage + +\localtableofcontents + + + +\subsection{\csbh{xintDecToHex}}\label{xintDecToHex} + +Converts from decimal to hexadecimal. + +\texttt{\string\xintDecToHex \string{\printnumber{2718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003}\string}}\endgraf\noindent\digitstt{->\printnumber{\xintDecToHex{2718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003}}} + +\subsection{\csbh{xintDecToBin}}\label{xintDecToBin} + +Converts from decimal to binary. + +\texttt{\string\xintDecToBin \string{\printnumber{2718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003}\string}}\endgraf\noindent\digitstt{->\printnumber{\xintDecToBin{2718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003}}} + +\subsection{\csbh{xintHexToDec}}\label{xintHexToDec} + +Converts from hexadecimal to decimal. + +\texttt{\string\xintHexToDec + \string{\printnumber{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}\string}}\endgraf\noindent +\digitstt{->\printnumber{\xintHexToDec{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}}} + +\subsection{\csbh{xintBinToDec}}\label{xintBinToDec} + +Converts from binary to decimal. + +\texttt{\string\xintBinToDec + \string{\printnumber{100011010100100111001011111000110011010010100100110101001011100000101000111110111110100001010100000010111100100010100111000111110000010110001011111000100000110110001000111000100100010111010111011110010101101010111011000001011101100111000110100100111001011110100011011011100111001000110110001100000001100101001001101101011111100110111110110101100100100011000100000010100110001100011}\string}}\endgraf\noindent +\digitstt{->\printnumber{\xintBinToDec{100011010100100111001011111000110011010010100100110101001011100000101000111110111110100001010100000010111100100010100111000111110000010110001011111000100000110110001000111000100100010111010111011110010101101010111011000001011101100111000110100100111001011110100011011011100111001000110110001100000001100101001001101101011111100110111110110101100100100011000100000010100110001100011}}} + +\subsection{\csbh{xintBinToHex}}\label{xintBinToHex} + +Converts from binary to hexadecimal. + +\texttt{\string\xintBinToHex + \string{\printnumber{100011010100100111001011111000110011010010100100110101001011100000101000111110111110100001010100000010111100100010100111000111110000010110001011111000100000110110001000111000100100010111010111011110010101101010111011000001011101100111000110100100111001011110100011011011100111001000110110001100000001100101001001101101011111100110111110110101100100100011000100000010100110001100011}\string}}\endgraf\noindent +\digitstt{->\printnumber{\xintBinToHex{100011010100100111001011111000110011010010100100110101001011100000101000111110111110100001010100000010111100100010100111000111110000010110001011111000100000110110001000111000100100010111010111011110010101101010111011000001011101100111000110100100111001011110100011011011100111001000110110001100000001100101001001101101011111100110111110110101100100100011000100000010100110001100011}}} + +\subsection{\csbh{xintHexToBin}}\label{xintHexToBin} + +Converts from hexadecimal to binary. + +\texttt{\string\xintHexToBin + \string{\printnumber{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}\string}}\endgraf\noindent +\digitstt{->\printnumber{\xintHexToBin{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}}} + + +\subsection{\csbh{xintCHexToBin}}\label{xintCHexToBin} + +Also converts from hexadecimal to binary. Faster on inputs with at least +one hundred hexadecimal digits. + +\texttt{\string\xintCHexToBin + \string{\printnumber{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}\string}}\endgraf\noindent +\digitstt{->\printnumber{\xintCHexToBin{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}}} + \section{Commands of the \xintgcdname package} -This package was included in the original release |1.0| of the -\xintname bundle. + + +This package was included in the original release |1.0| of the \xintname bundle. +The numbers on input have only one optional minus sign and no leading zeros, as +is the rule with the macros of package \xintname. In case of need, macro +\csb{xintNum} can be used to normalize the inputs. + +\localtableofcontents \subsection{\csbh{xintGCD}}\label{xintGCD} \csa{xintGCD\n\m} computes the greatest common divisor. It is positive, except when both |N| and |M| vanish, in which case the macro returns zero. -\centeredline{\csa{xintGCD}|{10000}{1113}=|\texttt{\xintGCD{10000}{1113}}} -\centeredline{|\xintGCD{123456789012345}{9876543210321}=|\texttt +\centeredline{\csa{xintGCD}|{10000}{1113}|\digitstt{=\xintGCD{10000}{1113}}} +\centeredline{|\xintGCD{123456789012345}{9876543210321}=|\digitstt {\xintGCD{123456789012345}{9876543210321}}} \subsection{\csbh{xintBezout}}\label{xintBezout} @@ -3440,23 +4049,23 @@ returns zero. \csa{xintBezout\n\m} 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 \texttt{UA - VB = D}. +second, |D| is the GCD, and \digitstt{UA - VB = D}. \centeredline{|\xintAssign {{\xintBezout {10000}{1113}}}\to\X|} -\centeredline{|\meaning\X: |\texttt{\meaning\X }.} +\centeredline{|\meaning\X: |\digitstt{\meaning\X }.} \noindent{|\xintAssign {\xintBezout {10000}{1113}}\to\A\B\U\V\D|}\\ -|\A: |\texttt{\A }, -|\B: |\texttt{\B }, -|\U: |\texttt{\U }, -|\V: |\texttt{\V }, -|\D: |\texttt{\D }.\\ +|\A: |\digitstt{\A }, +|\B: |\digitstt{\B }, +|\U: |\digitstt{\U }, +|\V: |\digitstt{\V }, +|\D: |\digitstt{\D }.\\ \xintAssign {\xintBezout {123456789012345}{9876543210321}}\to\A\B\U\V\D \noindent{|\xintAssign {\xintBezout {123456789012345}{9876543210321}}\to\A\B\U\V\D |}\\ -|\A: |\texttt{\A }, -|\B: |\texttt{\B }, -|\U: |\texttt{\U }, -|\V: |\texttt{\V }, -|\D: |\texttt{\D }. +|\A: |\digitstt{\A }, +|\B: |\digitstt{\B }, +|\U: |\digitstt{\U }, +|\V: |\digitstt{\V }, +|\D: |\digitstt{\D }. \subsection{\csbh{xintEuclideAlgorithm}}\label{xintEuclideAlgorithm} @@ -3487,8 +4096,9 @@ second, |D| is the GCD, and \texttt{UA - VB = D}. keeps a copy of all quotients and remainders. \centeredline{|\xintAssign {{\xintEuclideAlgorithm {10000}{1113}}}\to\X|} -|\meaning\X: |\texttt{\expandafter\allowlistsplit\meaning\X - \relax }. +|\meaning\X: |\digitstt{\expandafter\allowlistsplit + \meaning\X\relax .} + 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 remainder, the second quotient and remainder, \dots until the @@ -3507,7 +4117,7 @@ $\left(\vcenter{\halign {\,#&\,#\cr q & 1 \cr 1 & 0 \cr}}\right)$ formed from the quotients arising in the algorithm. \centeredline{|\xintAssign {{\xintEuclideAlgorithm {10000}{1113}}}\to\X|} -|\meaning\X: |\texttt{\expandafter\allowlistsplit\meaning\X \relax}. +|\meaning\X: |\digitstt{\expandafter\allowlistsplit\meaning\X \relax .} 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 @@ -3516,7 +4126,8 @@ entry, and then these four things at each step until the end. \catcode`\& 13 -\subsection{\csbh{xintTypesetEuclideAlgorithm}}\label{xintTypesetEuclideAlgorithm} +\subsection{\csbh{xintTypesetEuclideAlgorithm}\allowbreak\null\hspace*{.25cm}}% +\label{xintTypesetEuclideAlgorithm} This macro is just an example of how to organize the data returned by \csa{xintEuclideAlgorithm}. Copy the source code to a new macro @@ -3526,7 +4137,8 @@ and modify it to what is needed. {123456789012345}{9876543210321} -\subsection{\csbh{xintTypesetBezoutAlgorithm}}\label{xintTypesetBezoutAlgorithm} +\subsection{\csbh{xintTypesetBezoutAlgorithm}}% +\label{xintTypesetBezoutAlgorithm} This macro is just an example of how to organize the data returned by \csa{xintBezoutAlgorithm}. Copy the source code to a new macro @@ -3545,24 +4157,27 @@ they may be count registers, etc... This package was first released with version |1.03| of the \xintname bundle. +% \clearpage + +\localtableofcontents + \subsection{\csbh{xintSeries}}\label{xintSeries} \def\coeff #1{\xintiMON{#1}/#1.5} % (-1)^n/(n+1/2) \edef\w {\xintSeries {0}{50}{\coeff}} \edef\z {\xintJrr {\w}[0]} -\csa{xintSeries}|{A}{B}{\coeff}| evaluates the sum of all values of the |\coeff -{n}| from |n=A| to and including |n=B|. The initial and final indices must obey -the |\numexpr| constraint of expanding to numbers at most |2^31-1|. The |\coeff| -macro (which, as argument to \csa{xintSeries} is expanded only at the -time of computing the successive |\coeff {n}|) should be defined as a -one-parameter fully expandable command, providing its output from an input being -an explicit number (string of digits, no need to make proviso for a count -register). -\dverb|& -\def\coeff #1{\xintiMON{#1}/#1.5} % (-1)^n/(n+1/2) +\csa{xintSeries}|{A}{B}{\coeff}| computes +$\sum_{\text{|n=A|}}^{\text{|n=B|}}|\coeff{n}|$. The initial and final indices +must obey the |\numexpr| constraint of expanding to numbers at most |2^31-1|. +The |\coeff| macro must be a +one-parameter fully expandable command, taking on input an explicit number |n| +and producing some fraction |\coeff{n}|; it is expanded at the time it is +needed. +\dverb|& +\def\coeff #1{\xintiMON{#1}/#1.5} % (-1)^n/(n+1/2) \edef\w {\xintSeries {0}{50}{\coeff}} % we want to re-use it -\edef\z {\xintJrr {\w}[0]} % the [0] for a microsecond gain. +\edef\z {\xintJrr {\w}[0]} % the [0] for a microsecond gain. % \xintJrr preferred to \xintIrr: a big common factor is suspected. % But numbers much bigger would be needed to show the greater efficiency. \[ \sum_{n=0}^{n=50} \frac{(-1)^n}{n+\frac12} = \xintFrac\z \] @@ -3572,7 +4187,7 @@ before action by |\xintJrr| the inner representation of the result has a denominator of |\xintLen {\xintDenominator\w}=|\xintLen {\xintDenominator\w} digits. This troubled me as &101!!& has only 81 digits: |\xintLen {\xintQuo {\xintFac {101}}{\xintiMul {\xintiPow - {2}{50}}{\xintFac{50}}}}=|\texttt{\xintLen {\xintQuo {\xintFac + {2}{50}}{\xintFac{50}}}}|\digitstt{=\xintLen {\xintQuo {\xintFac {101}}{\xintiMul {\xintiPow {2}{50}}{\xintFac{50}}}}}. The explanation lies in the too clever to be efficient |#1.5| trick. It leads to a silly extra &5^{51}& (which has \xintLen {\xintPow {5}{51}} @@ -3644,7 +4259,7 @@ digits) in the denominator. See the explanations in the next section. \begin{multicols}{3} \def\coeffleibnitz #1{\the\numexpr\ifodd #1 1\else-1\fi\relax/#1[0]} \cnta 1 \loop - \noindent\hbox to 2em{\hfil\texttt{\the\cnta.} }% + \noindent\hbox to 2em{\hfil\digitstt{\the\cnta.} }% \xintTrunc {12}{\xintSeries {1}{\cnta}{\coeffleibnitz}}\dots \endgraf \ifnum\cnta < 30 \advance\cnta 1 \repeat @@ -3655,14 +4270,11 @@ digits) in the denominator. See the explanations in the next section. \def\coeff #1{\xintiTrunc {40} {\the\numexpr\ifodd #1 -2\else2\fi\relax/\the\numexpr 2*#1+1\relax [0]}}% -\csa{xintiSeries}|{A}{B}{\coeff}| evaluates the sum of |\coeff -{n}| from |n=A| to and including |n=B|. The initial and final indices are given -to a |\numexpr| expression. The -|\coeff| macro (which, as argument to \csa{xintiSeries} is expanded only -at the time of computing |\coeff {n}|) should be defined as a -one-parameter fully expandable command, accepting on input an explicit number, -and returning a (long) integer in the format understood by the integer-only -\csa{xintiAdd}. + \csa{xintiSeries}|{A}{B}{\coeff}| computes + $\sum_{\text{|n=A|}}^{\text{|n=B|}}|\coeff{n}|$ where now |\coeff{n}| + \emph{must} expand to a (possibly long) integer, as is acceptable on input by + the + integer-only \csa{xintiAdd}. \dverb|& \def\coeff #1{\xintiTrunc {40}{\xintMON{#1}/#1.5}}% % better: @@ -3721,21 +4333,24 @@ estimated wrongly the 39th and 40th digits of the exact result\footnote{as \subsection{\csbh{xintRationalSeries}}\label{xintRationalSeries} -{\small New with release |1.04|.\par} - -\csa{xintRationalSeries}|{A}{B}{f}{\ratio}| evaluates the sum of -|F(n)|\footnote{the macro is designed to be useful when |F(n)/F(n-1)| is a - rational function of |n| but it may be used of course with any sort of general - term.} from |n=A| up to and including |n=B|, with the parameter |f| being (or -expanding to) the value |F(A)| and |\ratio| being a one-parameter expandable -command, accepting on input an explicit number |n| and producing after (full -iterated) expansion (of the first token) |F(n)/F(n-1)|. The initial and final -indices are given to a |\numexpr| expression. -\dverb|& -\def\ratio #1{2/#1[0]}% 2/n, comes from the series of exp(2) +{\small \hspace*{\parindent}New with release |1.04|.\par} + +\noindent \csa{xintRationalSeries}|{A}{B}{f}{\ratio}| 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 +|F(n)/F(n-1)| is a rational function of |n| but it may be anything expanding to +a fraction. The macro |\ratio| must be an expandable-only compatible command and +expand to its value after iterated full expansion of its first token. |A| and +|B| are fed to a |\numexpr| hence may be count registers or arithmetic +expressions built with such; they must obey the \TeX{} bound. The initial term +|f| may be a macro |\f|, it will be expanded to its value representing |F(A)|. + +\dverb|& +\def\ratio #1{2/#1[0]}% 2/n, to compute exp(2) \cnta 0 % previously declared count -\loop -\edef\z {\xintRationalSeries {0}{\cnta}{1}{\ratio }}% +\loop \edef\z {\xintRationalSeries {0}{\cnta}{1}{\ratio }}% \noindent$\sum_{n=0}^{\the\cnta} \frac{2^n}{n!}= \xintTrunc{12}\z\dots= \xintFrac\z=\xintFrac{\xintIrr\z}$\vtop to 5pt{}\endgraf @@ -3847,29 +4462,26 @@ $\sum_{n=\the\cnta}^{\the\numexpr 2*\cnta-1\relax} \frac{\the\cnta^n}{n!}/% \subsection{\csbh{xintRationalSeriesX}}\label{xintRationalSeriesX} -{\small New with release |1.04|.\par} +{\small \hspace*{\parindent}New with release |1.04|.\par} + +\noindent\csa{xintRationalSeriesX}|{A}{B}{\first}{\ratio}{\g}| is a parametrized +version of \csa{xintRationalSeries} where |\first| is turned into a one +parameter macro with |\first{\g}| giving |F(A,\g)| and |\ratio| is a two +parameters macro such that |\ratio{n}{\g}| gives |F(n,\g)/F(n-1,\g)|. The +parameter |\g| is evaluated only once at the beginning of the computation, and +can thus itself be the yet unevaluated result of a previous computation. -\csa{xintRationalSeriesX}|{A}{B}{\first}{\ratio}{\x}| evaluates the sum of -|F(n,x)| from |n=A| up to and including |n=B|, where |\x| expands to a fraction -|x|, |\first| is a one-parameter macro such that |\first{\x}| expands in two -steps at most to the first term |F(A,x)| of the series, and |\ratio| is a two -parameter macro such that |\ratio{\x}{n}| expands to the -ratio |F(n,x)/F(n-1,x)|. Hence, this is a parametrized version of -\csa{xintRationalSeries}, where the parameter |\x| is evaluated only once at the -beginning of the computation, and can thus itself be the yet unevaluated result -of a previous computation. - -Note the subtle differences between -\centeredline{|\xintRationalSeries {a}{b}{\first}{\ratio{\x}}|}% -\centeredline{|\xintRationalSeriesX {a}{b}{\first}{\ratio}{\x}|} -First the location of braces differ... then, in the first one -|\first| is a macro expanding to a fractional number, but in the |X| -one, it is a one-parameter macro which will use |\x|. The |\ratio| macro -is in both cases a two-parameters macro, the difference is that in the -|X| variant the |\x| will be evaluated at the very beginning whereas the -former variant replaces it by its evaluation each time it needs it -(which is bad if this evaluation is time-costly, but good if it just a big -explicit fraction encapsulated in a macro). +Let |\ratio| be such a two-parameters macro; note the subtle differences +between\centeredline{|\xintRationalSeries {A}{B}{\first}{\ratio{\g}}|} +\centeredline{and |\xintRationalSeriesX {A}{B}{\first}{\ratio}{\g}|.} First the +location of braces differ... then, in the former case |\first| is a +\emph{no-parameter} macro expanding to a fractional number, and in the latter, +it is a +\emph{one-parameter} macro which will use |\g|. Furthermore the |X| variant +will expand |\g| at the very beginning whereas the former non-|X| former variant +will evaluate it each time it needs it (which is bad if this +evaluation is time-costly, but good if |\g| is a big explicit fraction +encapsulated in a macro). The example will use the macro \csb{xintPowerSeries} which computes @@ -3926,19 +4538,19 @@ us print in full the raw fractions created by the operation illustrated above: \edef\z{\xintRationalSeriesX {0}{9}{\firstterm} {\ratioexp}{\xintPowerSeries{1}{10}{\coefflog}{1[-1]}}} -|E(L(1[-1]))=|\printnumber{\z} (length of numerator: +|E(L(1[-1]))=|\digitstt{\printnumber{\z}} (length of numerator: \xintLen {\xintNumerator \z}) \edef\z{\xintRationalSeriesX {0}{9}{\firstterm} {\ratioexp}{\xintPowerSeries{1}{10}{\coefflog}{12[-2]}}} -|E(L(12[-2]))=|\printnumber{\z} (length of numerator: +|E(L(12[-2]))=|\digitstt{\printnumber{\z}} (length of numerator: \xintLen {\xintNumerator \z}) \edef\z{\xintRationalSeriesX {0}{9}{\firstterm} {\ratioexp}{\xintPowerSeries{1}{10}{\coefflog}{123[-3]}}} -|E(L(123[-3]))=|\printnumber{\z} (length of numerator: +|E(L(123[-3]))=|\digitstt{\printnumber{\z}} (length of numerator: \xintLen {\xintNumerator \z}) @@ -3952,14 +4564,14 @@ other test cases: \edef\z{\xintRationalSeriesX {0}{9}{\firstterm} {\ratioexp}{\xintPowerSeries{1}{10}{\coefflog}{1/7}}} -|E(L(1/7))=|\printnumber{\z} (length of numerator: +|E(L(1/7))=|\digitstt{\printnumber{\z}} (length of numerator: \xintLen {\xintNumerator \z}; length of denominator: \xintLen {\xintDenominator \z}) \edef\z{\xintRationalSeriesX {0}{9}{\firstterm} {\ratioexp}{\xintPowerSeries{1}{10}{\coefflog}{1/71}}} -|E(L(1/71))=|\printnumber{\z} (length of numerator: +|E(L(1/71))=|\digitstt{\printnumber{\z}} (length of numerator: \xintLen {\xintNumerator \z}; length of denominator: \xintLen {\xintDenominator \z}) @@ -3967,7 +4579,7 @@ other test cases: \edef\z{\xintRationalSeriesX {0}{9}{\firstterm} {\ratioexp}{\xintPowerSeries{1}{10}{\coefflog}{1/712}}} -|E(L(1/712))=|\printnumber{\z} (length of numerator: +|E(L(1/712))=|\digitstt{\printnumber{\z}} (length of numerator: \xintLen {\xintNumerator \z}; length of denominator: \xintLen {\xintDenominator \z}) @@ -3978,11 +4590,12 @@ other test cases: For info the last fraction put into irreducible form still has 288 digits in its denominator.\footnote{putting this fraction in irreducible form takes more time than is typical of the other computations in this document; so exceptionally I - have hard-coded the 288 in the document source.} The first conclusion is that decimal numbers such as |0.123| (equivalently + have hard-coded the 288 in the document source.} Thus +decimal numbers such as |0.123| (equivalently |123[-3]|) give less computing intensive tasks than fractions such as |1/712|: in the case of decimal numbers the (raw) denominators originate in the coefficients of the series themselves, powers of ten of the input within -brackets being treated separately. The second conclusion is that even then the +brackets being treated separately. And even then the numerators will grow with the size of the input in a sort of linear way, the coefficient being given by the order of series: here 10 from the log and 9 from the exp, so 90. One more digit in the input means 90 more digits in the @@ -4000,34 +4613,37 @@ room for separate treatment or to give him/her some badge saying ``I left my stuff in storage box 357''. Hence, truncating the output (or better, rounding) is the only way to go if one -needs a general calculus of special functions. Floating point representation of -numbers is currently unimplemented in \xintname. But fixed point computations -are available via the commands \csb{xintTrunc} and \csb{xintRound}. +needs a general calculus of special functions. This is why the package +\xintseriesname provides, besides \csb{xintSeries}, \csb{xintRationalSeries}, or +\csb{xintPowerSeries} which compute \emph{exact} sums, also has +\csb{xintFxPtPowerSeries} for fixed-point computations. + +Update: release |1.08a| of \xintseriesname now includes a tentative naive +\csb{xintFloatPowerSeries}. \subsection{\csbh{xintPowerSeries}}\label{xintPowerSeries} -\csa{xintPowerSeries}|{A}{B}{\coeff}{x}| evaluates the sum of -|\coeff{n}|\raisebox{.5ex}{|.|}|x^n| from |n=A| up to and including |n=B|. The +\csa{xintPowerSeries}|{A}{B}{\coeff}{f}| evaluates the sum +$\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 (in the -now usual meaning) command, -accepting on input an explicit number. +|\coeff{n}| is needed) should be defined as a one-parameter expandable command, +its input will be an explicit number. -The |x| can be either a fraction directly input or a macro expanding to such a -fraction. It is actually more efficient to encapsulate an explicit fraction |x| -in such a macro (say |\x|), if it has big numerators and denominators (`big' +The |f| can be either a fraction directly input or a macro |\f| expanding to +such a fraction. It is actually more efficient to encapsulate an explicit +fraction |f| in such a macro, if it has big numerators and denominators (`big' means hundreds of digits) as it will then take less space in the processing until being (repeatedly) used. -This macro computes the \emph{exact} result (one can use it also for -polynomial evaluation). With release |1.04| the Horner scheme for -polynomial evaluation is used, this avoids a denominator build-up which -was plaguing the |1.03| version. \footnote{with powers |x\string^k|, - from |k=0| to |N|, a denominator |d| of |x| became - |d\string^\string{1+2+\dots+N\string}|, which is bad. With the |1.04| - method, the part of the denominator originating from |x| does not - accumulate to more than |d\string^N|. } +This macro computes the \emph{exact} result (one can use it also for polynomial +evaluation). Starting with release |1.04| a Horner scheme for polynomial +evaluation is used, which has the advantage to avoid a denominator build-up +which was plaguing the |1.03| version. \footnote{with powers |f\string^k|, from + |k=0| to |N|, a denominator |d| of |f| became + |d\string^\string{1+2+\dots+N\string}|, which is bad. With the |1.04| method, + the part of the denominator originating from |f| does not accumulate to more + than |d\string^N|. } \begin{framed} Note: as soon as the coefficients look like factorials, it is more efficient @@ -4038,39 +4654,39 @@ was plaguing the |1.03| version. \footnote{with powers |x\string^k|, \dverb|& \def\geom #1{1[0]} % the geometric series -\def\x {5/17[0]} +\def\f {5/17[0]} \[ \sum_{n=0}^{n=20} \Bigl(\frac 5{17}\Bigr)^n - =\xintFrac{\xintIrr{\xintPowerSeries {0}{20}{\geom}{\x}}} + =\xintFrac{\xintIrr{\xintPowerSeries {0}{20}{\geom}{\f}}} =\xintFrac{\xinttheexpr (17^21-5^21)/12/17^20\relax}\] | \def\geom #1{1[0]} % the geometric series -\def\x {5/17[0]} % +\def\f {5/17[0]} % \[ \sum_{n=0}^{n=20} \Bigl(\frac 5{17}\Bigr)^n - =\xintFrac{\xintIrr{\xintPowerSeries {0}{20}{\geom}{\x}}} + =\xintFrac{\xintIrr{\xintPowerSeries {0}{20}{\geom}{\f}}} =\xintFrac{\xinttheexpr (17^21-5^21)/12/17^20\relax}\] \dverb|& \def\coefflog #1{1/#1[0]}% 1/n -\def\x {1/2[0]}% +\def\f {1/2[0]}% \[ \log 2 \approx \sum_{n=1}^{20} \frac1{n\cdot 2^n} - = \xintFrac {\xintIrr {\xintPowerSeries {1}{20}{\coefflog}{\x}}}\] + = \xintFrac {\xintIrr {\xintPowerSeries {1}{20}{\coefflog}{\f}}}\] \[ \log 2 \approx \sum_{n=1}^{50} \frac1{n\cdot 2^n} - = \xintFrac {\xintIrr {\xintPowerSeries {1}{50}{\coefflog}{\x}}}\] + = \xintFrac {\xintIrr {\xintPowerSeries {1}{50}{\coefflog}{\f}}}\] | \def\coefflog #1{1/#1[0]} % 1/n -\def\x {1/2[0]}% +\def\f {1/2[0]}% \[ \log 2 \approx \sum_{n=1}^{20} \frac1{n\cdot 2^n} = \xintFrac {\xintIrr {\xintPowerSeries - {1}{20}{\coefflog}{\x}}}\] + {1}{20}{\coefflog}{\f}}}\] \[ \log 2 \approx \sum_{n=1}^{50} \frac1{n\cdot 2^n} - = \xintFrac {\xintIrr {\xintPowerSeries {1}{50}{\coefflog}{\x}}}\] + = \xintFrac {\xintIrr {\xintPowerSeries {1}{50}{\coefflog}{\f}}}\] \dverb|& \cnta 1 % previously declared count \loop % in this loop we recompute from scratch each partial sum! % we can afford that, as \xintPowerSeries is fast enough. \noindent\hbox to 2em{\hfil\texttt{\the\cnta.} }% \xintTrunc {12} - {\xintPowerSeries {1}{\cnta}{\coefflog}{\x}}\dots + {\xintPowerSeries {1}{\cnta}{\coefflog}{\f}}\dots \endgraf \ifnum \cnta < 30 \advance\cnta 1 \repeat | @@ -4080,7 +4696,7 @@ was plaguing the |1.03| version. \footnote{with powers |x\string^k|, \loop % in this loop we recompute from scratch each partial sum! % we can afford that, as \xintPowerSeries is fast enough. \noindent\hbox to 2em{\hfil\texttt{\the\cnta.} }% - \xintTrunc {12}{\xintPowerSeries {1}{\cnta}{\coefflog}{\x}}\dots + \xintTrunc {12}{\xintPowerSeries {1}{\cnta}{\coefflog}{\f}}\dots \endgraf \ifnum \cnta < 30 \advance\cnta 1 \repeat \end{multicols} @@ -4092,41 +4708,36 @@ was plaguing the |1.03| version. \footnote{with powers |x\string^k|, % else nothing is guaranteed to work (even if it could by sheer luck) % NOTE in passing this aspect of \numexpr: % **** \numexpr -(1)\relax does not work!!! **** -\def\x {1/25[0]}% 1/5^2 +\def\f {1/25[0]}% 1/5^2 \[\mathrm{Arctg}(\frac15)\approx \frac15\sum_{n=0}^{15} \frac{(-1)^n}{(2n+1)25^n} = \xintFrac{\xintIrr {\xintDiv - {\xintPowerSeries {0}{15}{\coeffarctg}{\x}}{5}}}\] + {\xintPowerSeries {0}{15}{\coeffarctg}{\f}}{5}}}\] | \def\coeffarctg #1{1/\the\numexpr\ifodd #1 -2*#1-1\else2*#1+1\fi\relax }% -\def\x {1/25[0]}% 1/5^2 +\def\f {1/25[0]}% 1/5^2 \[\mathrm{Arctg}(\frac15)\approx \frac15\sum_{n=0}^{15} \frac{(-1)^n}{(2n+1)25^n} = \xintFrac{\xintIrr {\xintDiv - {\xintPowerSeries {0}{15}{\coeffarctg}{\x}}{5}}}\] + {\xintPowerSeries {0}{15}{\coeffarctg}{\f}}{5}}}\] \subsection{\csbh{xintPowerSeriesX}}\label{xintPowerSeriesX} -{\small New with release |1.04|.\par} - -This is the same as \csb{xintPowerSeries} apart from the fact that the last -parameter (aka |x|), is first expanded before being then used. If the |x| -parameter is to be an explicit big fraction |f| with many (dozens) digits, -rather than using |f| directly it is slightly better to have some macro |\x| -|\def'|ined to expand to the explicit |f| and use \csb{xintPowerSeries}; but if -|f| has not yet been evaluated and will be the output of a complicated expansion -of some |\x|, and if, due to an expanding only context, an |\edef\z{\x}| is no -option, then \csa{xintPowerSeriesX} should be used with |\x| as last parameter. -This |\x| will be expanded (as usual) and then its (explicit) output will be -used. The reason why \csa{xintPowerSeries} doesn't do the same is that explicit -fractions with many (dozens) digits slow down a bit the processing as there is -some shuffling of tokens going on. With \csa{xintPowerSeriesX} the slowing down -in token shuffling due to a very big fraction will not be avoided, but the far -worse cost of re-doing each time the computations leading to such a fraction -will be. The constraints of expandability make it impossible to encapsulate the -result of this initial computation in a macro and have the best of both worlds. -\dverb|& -\def\ratioexp #1#2{\xintDiv {#1}{#2}}% x/n +{\small\hspace*{\parindent}New with release |1.04|.\par} + +\noindent This is the same as \csb{xintPowerSeries} apart from the fact that the +last +parameter |f| is expanded once and for all before being then used repeatedly. If +the |f| parameter is to be an explicit big fraction with many (dozens) digits, +rather than using it directly it is slightly better to have some macro +|\g| defined to expand to the explicit fraction and then use +\csb{xintPowerSeries} with |\g|; +but if |f| has not yet been evaluated and will be the output of a complicated +expansion of some |\f|, and if, due to an expanding only context, doing +|\edef\g{\f}| is no option, then \csa{xintPowerSeriesX} should be used with |\f| +as last parameter. +\dverb|& +\def\ratioexp #1#2{\xintDiv {#1}{#2}}% x/n % These are the (-1)^{n-1}/n of the log(1+h) series: \def\coefflog #1{\the\numexpr\ifodd #1 1\else-1\fi\relax/#1[0]}% % Let L(h) be the first 10 terms of the log(1+h) series and @@ -4164,35 +4775,33 @@ result of this initial computation in a macro and have the best of both worlds. \subsection{\csbh{xintFxPtPowerSeries}}\label{xintFxPtPowerSeries} -\csa{xintFxPtPowerSeries}|{A}{B}{\coeff}{x}{D}| computes the sum of -|\coeff{n}|\raisebox{.5ex}{|.|}|x^n| from |n=A| to |n=B| with each term of the -series truncated to |D| digits after the decimal point. As usual, |A| and |B| -are completely expanded through their inclusion in a |\numexpr| expression. -Regarding |D| it will be similarly be expanded each time it is used inside an -\csa{xintTrunc}. The one-parameter macro |\coeff| is similarly only expanded (in -the usual meaning) when it is used inside the computations. Idem for |x|. If |x| -itself is some complicated macro it is thus better to use the variant -\csb{xintFxPtPowerSeriesX} which expands it first and then uses the result of -that expansion. - -The current (|1.04|) implementation is: the first power |x^A| is +\csa{xintFxPtPowerSeries}|{A}{B}{\coeff}{f}{D}| computes +$\sum_{\text{|n=A|}}^{\text{|n=B|}}|\coeff{n}|\cdot |f|^{\,\text{|n|}}$ with each + term of the series truncated to |D| digits after the decimal point. As + usual, |A| and |B| are completely expanded through their inclusion in a + |\numexpr| expression. Regarding |D| it will be similarly be expanded each + time it is used inside an \csa{xintTrunc}. The one-parameter macro |\coeff| + is similarly expanded at the time it is used inside the + computations. Idem for |f|. If |f| itself is some complicated macro it is + thus better to use the variant \csb{xintFxPtPowerSeriesX} which expands it + first and then uses the result of that expansion. + +The current (|1.04|) implementation is: the first power |f^A| is computed exactly, then \emph{truncated}. Then each successive power is obtained from the previous one by multiplication by the exact value of -|x|, and truncated. And |\coeff{n}|\raisebox{.5ex}{|.|}|x^n| is obtained +|f|, and truncated. And |\coeff{n}|\raisebox{.5ex}{|.|}|f^n| is obtained from that by multiplying by |\coeff{n}| (untruncated) and then truncating. Finally the sum is computed exactly. Apart from that \csa{xintFxPtPowerSeries} (where |FxPt| means `fixed-point') is like \csa{xintPowerSeries}. -There should be a variant for things of the -type $\sum c_n \frac {x^n}{n!}$ to avoid having to compute the factorial -from scratch at each coefficient, the same way \csa{xintFxPtPowerSeries} -does not compute |x^n| from scratch at each |n|. Perhaps in the next package -release. +There should be a variant for things of the type $\sum c_n \frac {f^n}{n!}$ to +avoid having to compute the factorial from scratch at each coefficient, the same +way \csa{xintFxPtPowerSeries} does not compute |f^n| from scratch at each |n|. +Perhaps in the next package release. \def\coeffexp #1{1/\xintFac {#1}[0]}% [0] for faster parsing -\def\x {-1/2[0]}% -\def\ApproxExp #1#2{\xintFxPtPowerSeries {0}{#1}{\coeffexp}{\x}{#2}}% +\def\f {-1/2[0]}% \newcount\cnta \setlength{\multicolsep}{0pt} @@ -4201,18 +4810,17 @@ release. \centeredline{$e^{-\frac12}\approx{}$}]% \cnta 0 \noindent\loop -$\ApproxExp {\cnta}{20}$\\ +$\xintFxPtPowerSeries {0}{\cnta}{\coeffexp}{\f}{20}$\\ \ifnum\cnta<19 \advance\cnta 1 \repeat\par \end{multicols} \dverb|& \def\coeffexp #1{1/\xintFac {#1}[0]}% 1/n! -\def\x {-1/2[0]}% [0] for faster input parsing -\def\ApproxExp #1#2{\xintFxPtPowerSeries {0}{#1}{\coeffexp}{\x}{#2}}% +\def\f {-1/2[0]}% [0] for faster input parsing \cnta 0 % previously declared \count register \noindent\loop -$\ApproxExp {\cnta}{20}$\\ % truncates 20 digits after decimal point +$\xintFxPtPowerSeries {0}{\cnta}{\coeffexp}{\f}{20}$\\ \ifnum\cnta<19 \advance\cnta 1 \repeat\par % One should **not** trust the final digits, as the potential truncation % errors of up to 10^{-20} per term accumulate and never disappear! (the @@ -4220,17 +4828,17 @@ $\ApproxExp {\cnta}{20}$\\ % truncates 20 digits after decimal point % confirm that the last two digits (of our evaluation of the nineteenth % partial sum) are wrong via the evaluation with more digits: | -\centeredline{|\xintFxPtPowerSeries {0}{19}{\coeffexp}{\x}{25}=| -\xintFxPtPowerSeries {0}{19}{\coeffexp}{\x}{25}} +\centeredline{|\xintFxPtPowerSeries {0}{19}{\coeffexp}{\f}{25}=| +\digitstt{\xintFxPtPowerSeries {0}{19}{\coeffexp}{\f}{25}}} \texttt{\hyphenchar\font45 } -\edef\z{\xintIrr {\xintPowerSeries {0}{19}{\coeffexp}{\x}}} +\edef\z{\xintIrr {\xintPowerSeries {0}{19}{\coeffexp}{\f}}} It is no difficulty for \xintfracname to compute exactly, with the help of \csa{xintPowerSeries}, the nineteenth partial sum, and to then give (the start of) its exact decimal expansion: -\centeredline{|\xintPowerSeries {0}{19}{\coeffexp}{\x}| ${}= +\centeredline{|\xintPowerSeries {0}{19}{\coeffexp}{\f}| ${}= \displaystyle\xintFrac{\z}$% \vphantom{\vrule height 20pt depth 12pt}}% \centeredline{${}=\xintTrunc {30}{\z}\dots$} Thus, one should always @@ -4243,18 +4851,19 @@ of digits possibly of dubious significance. \subsection{\csbh{xintFxPtPowerSeriesX}}\label{xintFxPtPowerSeriesX} -{\small New with release |1.04|.\par} +{\small\hspace*{\parindent}New with release |1.04|.\par} -\csa{xintFxPtPowerSeriesX}|{A}{B}{\coeff}{\x}{D}| computes, exactly as +\noindent\csa{xintFxPtPowerSeriesX}|{A}{B}{\coeff}{\f}{D}| computes, exactly as \csa{xintFxPtPowerSeries}, the sum of -|\coeff{n}|\raisebox{.5ex}{|.|}|\x^n| from |n=A| to |n=B| with each term +|\coeff{n}|\raisebox{.5ex}{|.|}|\f^n| from |n=A| to |n=B| with each term of the series being \emph{truncated} to |D| digits after the decimal -point. The sole difference is that |\x| is first expanded and it +point. The sole difference is that |\f| is first expanded and it is the result of this which is used in the computations. % Let us illustrate this on the computation of |(1+y)^{5/3}| where % |1+y=(1+x)^{3/5}| and each of the two binomial series is evaluated with ten -% terms, the results being computed with |8| digits after the decimal point, and &|x|<1/10&. +% terms, the results being computed with |8| digits after the decimal point, and +% &|f|<1/10&. Let us illustrate this on the numerical exploration of the identity @@ -4286,10 +4895,10 @@ more precisely than, say circa 5 digits after the decimal points. \begin{multicols}2 \loop \noindent \hbox to 2.5cm {\hss\texttt{D(\the\cnta/100): }}% -\xintAdd {\xintFxPtPowerSeriesX {1}{10}{\coefflog}{\the\cnta [-2]}{5}} +\digitstt{\xintAdd {\xintFxPtPowerSeriesX {1}{10}{\coefflog}{\the\cnta [-2]}{5}} {\xintFxPtPowerSeriesX {1}{10}{\coefflog} {\xintFxPtPowerSeriesX {1}{10}{\coeffalt}{\the\cnta [-2]}{5}} - {5}}\endgraf + {5}}}\endgraf \ifnum\cnta < 49 \advance\cnta 7 \repeat \end{multicols} @@ -4317,13 +4926,13 @@ to the next evaluation. \begin{multicols}2 \loop \noindent \hbox to 2.5cm {\hss\texttt{D(\the\cnta/100): }}% -\xintRound{4} +\digitstt{\xintRound{4} {\xintAdd {\xintFxPtPowerSeriesX {1}{15}{\coefflog}{\the\cnta [-2]}{6}} {\xintFxPtPowerSeriesX {1}{15}{\coefflog} {\xintRound {4}{\xintFxPtPowerSeriesX {1}{15}{\coeffalt} {\the\cnta [-2]}{6}}} {6}}% - }\endgraf + }}\endgraf \ifnum\cnta < 49 \advance\cnta 7 \repeat \end{multicols} @@ -4341,6 +4950,52 @@ better, rounding, at a given number |D'<D| of digits. Maybe for the next release. +\subsection{\csbh{xintFloatPowerSeries}}\label{xintFloatPowerSeries} + +{\small\hspace*{\parindent}New with |1.08a|.\par} + +\noindent\csa{xintFloatPowerSeries}|[P]{A}{B}{\coeff}{f}| computes +$\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|. + +In the current, preliminary, version, no attempt has been made to try to +guarantee to the final result the precision |P|. Rather, |P| is used for all +intermediate floating point evaluations. So +rounding errors will make some of the last printed digits invalid. The +operations done are first the evaluation of |f^A| using \csa{xintFloatPow}, then +each successive power is obtained from this first one by multiplication by |f| +using \csa{xintFloatMul}, then again with \csa{xintFloatMul} this is multiplied +with |\coeff{n}|, and the sum is done adding one term at a time with +\csa{xintFloatAdd}. To sum up, this is just the naive transformation of +\csa{xintFxPtPowerSeries} from fixed point to floating point. + +\def\coefflog #1{\the\numexpr\ifodd#1 1\else-1\fi\relax/#1[0]}% + +\dverb+& +\def\coefflog #1{\the\numexpr\ifodd#1 1\else-1\fi\relax/#1[0]}% +\xintFloatPowerSeries [8]{1}{30}{\coefflog}{-1/2[0]}+ +\centeredline{\digitstt{\xintFloatPowerSeries [8]{1}{30}{\coefflog}{-1/2[0]}}} + +\subsection{\csbh{xintFloatPowerSeriesX}}\label{xintFloatPowerSeriesX} + +{\small\hspace*{\parindent}New with |1.08a|.\par} + +\noindent\csa{xintFloatPowerSeriesX}|[P]{A}{B}{\coeff}{f}| is like +\csa{xintFloatPowerSeries} with the difference that |f| is +expanded once and for all at the start of the computation, thus allowing +efficient chaining of such series evaluations. +\def\coefflog #1{\the\numexpr\ifodd#1 1\else-1\fi\relax/#1[0]}% + +\dverb+& +\def\coeffexp #1{1/\xintFac {#1}[0]}% 1/n! (exact, not float) +\def\coefflog #1{\the\numexpr\ifodd#1 1\else-1\fi\relax/#1[0]}% +\xintFloatPowerSeriesX [8]{0}{30}{\coeffexp} + {\xintFloatPowerSeries [8]{1}{30}{\coefflog}{-1/2[0]}}+ +\centeredline{\digitstt{\xintFloatPowerSeriesX [8]{0}{30}{\coeffexp} + {\xintFloatPowerSeries [8]{1}{30}{\coefflog}{-1/2[0]}}}} + \subsection{Computing \texorpdfstring{$\log 2$}{log(2)} and \texorpdfstring{$\pi$}{pi}}\label{ssec:Machin} @@ -4351,7 +5006,7 @@ make them difficult!) computations of the first digits of the decimal expansion of the familiar constants $\log 2$ and $\pi$. Let us start with $\log 2$. We will get it from this formula (which is -left as an exercise): \centeredline{\texttt{log(2)=-2\,log(1-13/256)-% +left as an exercise): \centeredline{\digitstt{log(2)=-2\,log(1-13/256)-% 5\,log(1-1/9)}}% The number of terms to be kept in the log series, for a desired precision of |10^{-D}| was roughly estimated without much theoretical @@ -4367,7 +5022,7 @@ desired precision to validate the earlier result. Then we tried with \csa{xintFxPtPowerSeries}: this is worthwile only for |D|'s at least 50, as the exact evaluations are faster (with these -short-length |x|'s) for a lower +short-length |f|'s) for a lower number of digits. And as expected the degradation in the quality of approximation was in this range of the order of two or three digits. This meant roughly that the 3+1=4 ending digits were wrong. Again, we ended @@ -4426,9 +5081,11 @@ correct exact truncated one. }% }% -\noindent $\log 2 \approx \LogTwo {60}\dots$\endgraf -\noindent\phantom{$\log 2$}${}\approx{}$\printnumber{\LogTwo {65}}\dots\endgraf -\noindent\phantom{$\log 2$}${}\approx{}$\printnumber{\LogTwo {70}}\dots\endgraf +\noindent $\log 2 \approx {}$\digitstt{\LogTwo {60}\dots}\endgraf +\noindent\phantom{$\log 2$}${}\approx{}$\digitstt{\printnumber{\LogTwo + {65}}\dots}\endgraf +\noindent\phantom{$\log 2$}${}\approx{}$\digitstt{\printnumber{\LogTwo + {70}}\dots}\endgraf Here is the code doing an exact evaluation of the partial sums. We have added a |+1| to the number of digits for estimating the number of terms @@ -4455,17 +5112,16 @@ higher than |100| it is more efficient to use the code using }% | -Let us turn now to Pi, computed with the Machin formula. Again the -numbers of terms to keep in the two |arctg| series were roughly estimated, -and some experimentations showed that removing the last three -digits was enough (at least for |D=0-100| range). And the -algorithm does print the correct digits when used with |D=1000| (to be -convinced of that one needs to run it for |D=1000| and again, say for -|D=1010|.) A theoretical analysis could help confirm that this algorithm -always gets better than |10^{-D}| precision, but again, strings of zeros or nines -encountered in the decimal expansion may falsify the ending digits, -nines may be zeros (and the last non-nine one should be increased) and -zeros may be nine (and the last non-zero one should be decreased). +Let us turn now to Pi, computed with the Machin formula. Again the numbers of +terms to keep in the two |arctg| series were roughly estimated, and some +experimentations showed that removing the last three digits was enough (at least +for |D=0-100| range). And the algorithm does print the correct digits when used +with |D=1000| (to be convinced of that one needs to run it for |D=1000| and +again, say for |D=1010|.) A theoretical analysis could help confirm that this +algorithm always gets better than |10^{-D}| precision, but again, strings of +zeros or nines encountered in the decimal expansion may falsify the ending +digits, nines may be zeros (and the last non-nine one should be increased) and +zeros may be nine (and the last non-zero one should be decreased). \dverb|& % pi = 16 Arctg(1/5) - 4 Arctg(1/239) (John Machin's formula) \def\coeffarctg #1{\the\numexpr\ifodd#1 -1\else1\fi\relax/% @@ -4571,7 +5227,7 @@ Let us use this variant for a loop showing the build-up of digits: \begin{multicols}{2} \cnta 0 % previously declared \count register \loop \noindent - \centeredline{\MachinBis{\cnta}}% + \centeredline{\digitstt{\MachinBis{\cnta}}}% \ifnum\cnta < 30 \advance\cnta 1 \repeat \end{multicols} @@ -4587,10 +5243,10 @@ compile: \immediate\closeout\outfile | This will create a file with the correct first 1000 digits of $\pi$ -after the decimal point. On my laptop (a 2012 model) this took about 44 +after the decimal point. On my laptop (a 2012 model) this took about 42 seconds last time I tried (and for 200 digits it is less than 1 second). As mentioned in the introduction, the file -\href{http://www.ctan.org/pkg/pi}{\color{niceone}pi.tex} by \textsc{D. +\href{http://www.ctan.org/pkg/pi}{pi.tex} by \textsc{D. Roegel} shows that orders of magnitude faster computations are possible within \TeX{}, but recall our constraints of complete expandability and be merciful, please. @@ -4602,13 +5258,8 @@ expandability and be merciful, please. % \edef\temps{\the\pdfelapsedtime} % \immediate\closeout\outfile -% \temps: \xintQuo\temps{\xintiMul{60}{65536}} minutes, -% \xintQuo{\xintRem\temps{\xintiMul{60}{65536}}}{65536} secondes et -% \xintiRound {2}{\xintRem\temps{65536}/65536} centiemes de secondes +% \temps: \xintRound {2}{\temps/65536} secondes -% 2882370: 0 minutes, 43 secondes et 98 centiemes de secondes - -% je l'ai déjà fait en 42 secondes... \textbf{Why truncating rather than rounding?} One of our main competitors on the market of scientific computing, a canadian product (not @@ -4625,8 +5276,8 @@ less; true, but this is a negligeable effect per summand compared to the additional cost for this term of having been truncated at |D+1| then rounded). Rounding is the way to go when setting up algorithms to evaluate functions destined to be composed one after the other: exact -algebraic operations with many summands and an |x| variable which is a -fraction are costly and create an even bigger fraction; replacing |x| +algebraic operations with many summands and an |f| variable which is a +fraction are costly and create an even bigger fraction; replacing |f| with a reasonable rounding, and rounding the result, is necessary to allow arbitrary chaining. @@ -4636,11 +5287,16 @@ decimal expansion, so we truncate and compute more terms until the earlier result gets validated. Finally if we do want the rounding we can always do it on a value computed with |D+1| truncation. +%% \clearpage \section{Commands of the \xintcfracname package} This package was first included in release |1.04| of the \xintname bundle. + +\localtableofcontents + + \subsection{Package overview} A \emph{simple} continued fraction has coefficients @@ -4695,7 +5351,8 @@ It uses the macro \csb{xintGCtoF} to convert a generalized fraction from the A simple continued fraction is a special case of a generalized continued fraction and may be input as such to macros expecting the `inline format', for example |-7+1/6+1/19+1/1+1/33|. There is a simpler comma separated format: -\centeredline{|\xintFrac{\xintCstoF{-7,6,19,1,33}}=\xintCFrac{\xintCstoF{-7,6,19,1,33}}|} +\centeredline{|\xintFrac{\xintCstoF{-7,6,19,1,33}}=& + \xintCFrac{\xintCstoF{-7,6,19,1,33}}|} \[ \xintFrac{\xintCstoF{-7,6,19,1,33}}=\xintCFrac{\xintCstoF{-7,6,19,1,33}}\] This comma separated format may also be used with fractions among the coefficients: @@ -4722,37 +5379,40 @@ ones \csb{xintApply} and \csb{xintListWithSep}. As a shortcut to using \csa{xintFtoCx} with separator |1+/|, there is \csb{xintFtoGC}: \centeredline{|2721/1001=\xintFtoGC {2721/1001}|}% -\centeredline{\texttt{2721/1001=\xintFtoGC {2721/1001}}} +\centeredline{\digitstt{2721/1001=\xintFtoGC {2721/1001}}} Let us compare in that case with the output of \csb{xintFtoCC}: \centeredline{|2721/1001=\xintFtoCC {2721/1001}|}% -\centeredline{\texttt{2721/1001=\xintFtoCC {2721/1001}}} +\centeredline{\digitstt{2721/1001=\xintFtoCC {2721/1001}}} The `|\printnumber|' macro which we use to print long numbers can also be useful on long continued fractions. \centeredline{|\printnumber{\xintFtoCC {35037018906350720204351049/%|}% \centeredline{|244241737886197404558180}}|}% -\texttt{\printnumber{\xintFtoCC {35037018906350720204351049/244241737886197404558180}}}. +\digitstt{\printnumber{\xintFtoCC {35037018906350720204351049/244241737886197404558180}}}. If we apply \csb{xintGCtoF} to this generalized continued fraction, we discover that the original fraction was reducible: \centeredline{|\xintGCtoF - {143+1/2+...+-1/9}=|\texttt{\xintGCtoF{143+1/2+1/5+-1/4+-1/4+-1/4+-1/3+1/2+1/2+1/6+-1/22+1/2+1/10+-1/5+-1/11+-1/3+1/4+-1/2+1/2+1/4+-1/2+1/23+1/3+1/8+-1/6+-1/9}}} + {143+1/2+...+-1/9}|\digitstt{=\xintGCtoF{143+1/2+1/5+-1/4+-1/4+-1/4+-1/3+1/2+1/2+1/6+-1/22+1/2+1/10+-1/5+-1/11+-1/3+1/4+-1/2+1/2+1/4+-1/2+1/23+1/3+1/8+-1/6+-1/9}}} \def\mymacro #1{$\xintFrac{#1}=[\xintFtoCs{#1}]$\vtop to 6pt{}} +\begingroup +\catcode`^\active +\def^#1^{\hbox{\fontfamily{lmtt}\selectfont #1}}% \catcode`\& 4 When a generalized continued fraction is built with integers, and numerators are only |1|'s or |-1|'s, the produced fraction is irreducible. And if we compute it again with the last sub-fraction omitted we get another irreducible fraction related to the bigger one by a Bezout identity. Doing this here we get: -\centeredline{|\xintGCtoF {143+1/2+...+-1/6}=|\texttt{\xintGCtoF{143+1/2+1/5+-1/4+-1/4+-1/4+-1/3+1/2+1/2+1/6+-1/22+1/2+1/10+-1/5+-1/11+-1/3+1/4+-1/2+1/2+1/4+-1/2+1/23+1/3+1/8+-1/6}}} +\centeredline{|\xintGCtoF {143+1/2+...+-1/6}|\digitstt{=\xintGCtoF{143+1/2+1/5+-1/4+-1/4+-1/4+-1/3+1/2+1/2+1/6+-1/22+1/2+1/10+-1/5+-1/11+-1/3+1/4+-1/2+1/2+1/4+-1/2+1/23+1/3+1/8+-1/6}}} and indeed: \[ \begin{vmatrix} - 2897319801297630107 & 328124887710626729\\ - 20197107104701740 & 2287346221788023 - \end{vmatrix} = \texttt{\xintiSub {\xintiMul {2897319801297630107}{2287346221788023}}{\xintiMul{20197107104701740}{328124887710626729}}}\] + ^2897319801297630107^ & ^328124887710626729^\\ + ^20197107104701740^ & ^2287346221788023^ + \end{vmatrix} = \digitstt{\xintiSub {\xintiMul {2897319801297630107}{2287346221788023}}{\xintiMul{20197107104701740}{328124887710626729}}}\] -\catcode`\& 13 +\endgroup More generally the various fractions obtained from the truncation of a continued fraction to its initial terms are called the convergents. The @@ -4878,7 +5538,7 @@ the convergents of Euler's number $e$. \cnta 0 \def\mymacro #1{\advance\cnta by 1 \noindent - \hbox to 3em {\hfil\small\texttt{\the\cnta.} }% + \hbox to 3em {\hfil\small\digitstt{\the\cnta.} }% $\xintTrunc {30}{\xintAdd {1[0]}{#1}}\dots= \xintFrac{\xintAdd {1[0]}{#1}}$}% \xintListWithSep{\vtop to 6pt{}\vbox to 12pt{}\par} @@ -4905,7 +5565,7 @@ and the 200th convergent is obtained ten times faster). \dverb|& \edef\z {\xintCntoF {199}{\cn}}% \begingroup\parindent 0pt \leftskip 2.5cm -\indent\llap {Numerator = }\printnumber{\xintNumerator\z}\par +\indent\llap {Numerator = }{\printnumber{\xintNumerator\z}\par \indent\llap {Denominator = }\printnumber{\xintDenominator\z}\par \indent\llap {Expansion = }\printnumber{\xintTrunc{268}\z}\dots \par\endgroup @@ -4914,9 +5574,10 @@ and the 200th convergent is obtained ten times faster). \edef\z {\xintCntoF {199}{\cn}}% \begingroup\parindent 0pt \leftskip 2.5cm -\indent\llap {Numerator = }\printnumber{\xintNumerator\z}\par -\indent\llap {Denominator = }\printnumber{\xintDenominator\z}\par -\indent\llap {Expansion = }\printnumber{\xintTrunc{268}\z}\dots\par\endgroup +\indent\llap {Numerator = }\digitstt{\printnumber{\xintNumerator\z}}\par +\indent\llap {Denominator = }\digitstt{\printnumber{\xintDenominator\z}}\par +\indent\llap + {Expansion = }\digitstt{\printnumber{\xintTrunc{268}\z}\dots}\par\endgroup One can also use a centered continued fraction: we get more digits but there are also more computations as the numerators may be either @@ -4955,7 +5616,8 @@ pair of braces, and separated with the help of |sepa| and |sepb|. Thus \centeredline{|\xintGCtoGCx :;{1+2/3+4/5+6/7}| gives \xintGCtoGCx :;{1+2/3+4/5+6/7}} Plain \TeX{}+|amstex| users may be interested in:\par \noindent|$$\xintGCtoGCx {+\cfrac}{\\}{a+b/...}\endcfrac$$|\par -\noindent|$$\xintGCtoGCx {+\cfrac\xintFwOver}{\\\xintFwOver}{a+b/...}\endcfrac$$|\par +\noindent +|$$\xintGCtoGCx {+\cfrac\xintFwOver}{\\\xintFwOver}{a+b/...}\endcfrac$$|\par \subsection{\csbh{xintFtoCs}}\label{xintFtoCs} @@ -5042,9 +5704,9 @@ convergents have then no reason to be the real convergents of the final fraction). When the coefficients are integers, the convergents are irreducible fractions, but otherwise it is of course not necessarily the case. \centeredline{|\xintListWithSep:{\xintCstoCv{1,2,3,4,5,6}}|}% -\centeredline{\texttt{\xintListWithSep:{\xintCstoCv{1,2,3,4,5,6}}}} +\centeredline{\digitstt{\xintListWithSep:{\xintCstoCv{1,2,3,4,5,6}}}} \centeredline{|\xintListWithSep:{\xintCstoCv{1,1/2,1/3,1/4,1/5,1/6}}|}% -\centeredline{\texttt{\xintListWithSep:{\xintCstoCv{1,1/2,1/3,1/4,1/5,1/6}}}} I +\centeredline{\digitstt{\xintListWithSep:{\xintCstoCv{1,1/2,1/3,1/4,1/5,1/6}}}} I know that these |[0]| are a bit annoying\footnote{and the awful truth is that it is added forcefully by \csa{xintCstoCv} at the last step\dots } but this is the way \xintfracname likes to reception fractions: this format is best for @@ -5123,7 +5785,7 @@ The values of the coefficients, as returned by |\macro| do not have to be positive, nor integers, and it is thus not necessarily the case that the original |c(j)| are the true coefficients of the final |f|. \centeredline{% |\def\macro #1{\the\numexpr 1+#1*#1\relax}\xintCntoF {5}{\macro}|}% -\centeredline{\xintCntoF {5}{\macro}} +\centeredline{\digitstt{\xintCntoF {5}{\macro}}} \subsection{\csbh{xintGCntoF}}\label{xintGCntoF} @@ -5150,8 +5812,8 @@ fraction. The previous display was obtained with: corresponding coefficients, from |n=0| to |n=N|. The |N| is given to a |\numexpr|. \centeredline{% -|\def\macro #1{\the\numexpr 1+#1*#1\relax}\xintCntoCs {5}{\macro}|}% -\centeredline{\xintCntoCs {5}{\macro}}% +|\def\macro #1{\the\numexpr 1+#1*#1\relax}|}% +\centeredline{|\xintCntoCs {5}{\macro}|\digitstt{->\xintCntoCs {5}{\macro}}}% \centeredline{|\[\xintFrac{\xintCntoF {5}{\macro}}=\xintCFrac{\xintCntoF {5}{\macro}}\]|}% \[ \xintFrac{\xintCntoF @@ -5171,9 +5833,9 @@ fractions. \centeredline{% |\def\macro #1{\the\numexpr\ifodd#1 -1-#1\else1+#1\fi\relax/%|}% \centeredline{|\the\numexpr 1+#1*#1\relax}|}% -\centeredline{|\edef\x{\xintCntoGC {5}{\macro}}\texttt{\meaning\x}|}% +\centeredline{|\edef\x{\xintCntoGC {5}{\macro}}\meaning\x|}% +\centeredline{\edef\x{\xintCntoGC {5}{\macro}}\digitstt{\meaning\x}}% \centeredline{|\[\xintGCFrac{\xintCntoGC {5}{\macro}}\]|}% -\centeredline{\edef\x{\xintCntoGC {5}{\macro}}\texttt{\meaning\x}} \[\xintGCFrac{\xintCntoGC {5}{\macro}}\] \subsection{\csbh{xintGCntoGC}}\label{xintGCntoGC} @@ -5185,15 +5847,14 @@ are enclosed into added pairs of braces, and may thus be fractions. \dverb|& \def\an #1{\the\numexpr #1*#1*#1+1\relax}% \def\bn #1{\the\numexpr \xintiMON{#1}*(#1+1)\relax}% -\texttt{\xintGCntoGC {5}{\an}{\bn}}% - ${}=\xintGCFrac {\xintGCntoGC {5}{\an}{\bn}} - = \displaystyle\xintFrac {\xintGCntoF {5}{\an}{\bn}}$\par +$\xintGCntoGC {5}{\an}{\bn}}=\xintGCFrac {\xintGCntoGC {5}{\an}{\bn}} + = \displaystyle\xintFrac {\xintGCntoF {5}{\an}{\bn}}$\par | \def\an #1{\the\numexpr #1*#1*#1+1\relax}% \def\bn #1{\the\numexpr \xintiMON{#1}*(#1+1)\relax}% -\noindent\texttt{\xintGCntoGC {5}{\an}{\bn}}% - ${}=\xintGCFrac {\xintGCntoGC {5}{\an}{\bn}} - = \displaystyle\xintFrac {\xintGCntoF{5}{\an}{\bn}}$\par +$\xintGCntoGC {5}{\an}{\bn}=\xintGCFrac {\xintGCntoGC {5}{\an}{\bn}} + = \displaystyle\xintFrac {\xintGCntoF {5}{\an}{\bn}}$\par + \subsection{\csbh{xintiCstoF},~\csbh{xintiGCtoF},~\csbh{xint\-iCstoCv},~\csbh{xintiGCtoCv}}\label{xintiCstoF} @@ -5215,11 +5876,11 @@ of the same type, each expanded coefficient being enclosed withing braces. \dverb|& \edef\x {\xintGCtoGC {1+\xintPow{1.5}{3}/{1/7}+{-3/5}/\xintFac {6}+\xintCstoF {2,-7,-5}/16}} -\texttt{\meaning\x} +\meaning\x | \edef\x {\xintGCtoGC {1+\xintPow{1.5}{3}/{1/7}+{-3/5}/\xintFac {6}+\xintCstoF {2,-7,-5}/16}} -\texttt{\meaning\x} +\digitstt{\meaning\x} To be honest I have, it seems, forgotten why I wrote this macro in the first place. @@ -5238,16 +5899,16 @@ first place. \MakePercentIgnore % % \catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11 -% \let</none>\relax +% \let</doc>\relax % \def<*xint>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12 } % -%</none> +%</doc> %<*xint> % \section {Package \xintname implementation} % % The commenting of the macros is currently (\docdate) very sparse. % -% \toctransition +% % \localtableofcontents % \subsection{Catcodes, \protect\eTeX{} and reload detection} % @@ -5258,17 +5919,15 @@ first place. % slightly differently. |1.05| adds a |\relax| near the end of % |\XINT_restorecatcodes_endinput|. Plain TeX users following the doc % instruction to do |\input xint.sty\relax| were anyhow protected from any side -% effect. I didn't realize earlier that the |\endinput| would not have had the -% effect of stopping the scanning from the last |\the\catcode61|. +% effect. I did not realize earlier that the |\endinput| would not stop \TeX{}'s +% scan for a number which was initiated by the last |\the\catcode|. % % Starting with version |1.06| of the package, also |`| must be sanitized, % because we replace everywhere in the code the twice-expansion done with % |\expandafter| by the systematic use of |\romannumeral-`0|. % % 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. As this -% change makes it a bit more difficult to access the few private macros which -% were mentioned in the user documentation, I renamed them with only letters. +% signs, so I replace them all with underscores |_|, \`a la \LaTeX 3. % % \begin{macrocode} \begingroup\catcode61\catcode48\catcode32=10\relax% @@ -5311,6 +5970,7 @@ first place. \endgroup \edef\XINT_restorecatcodes_endinput {% + \catcode94=\the\catcode94 % ^ \catcode96=\the\catcode96 % ` \catcode47=\the\catcode47 % / \catcode41=\the\catcode41 % ) @@ -5355,6 +6015,7 @@ first place. \catcode41=12 % ) \catcode47=12 % / \catcode96=12 % ` + \catcode94=11 % ^ }% \XINT_setcatcodes }% @@ -5388,9 +6049,9 @@ first place. \fi \expandafter\x\csname ver@xint.sty\endcsname \ProvidesPackage{xint}% - [2013/05/26 v1.07a Expandable operations on long numbers (jfB)]% + [2013/06/14 v1.08b Expandable operations on long numbers (jfB)]% % \end{macrocode} -% \subsection{Token management macros} +% \subsection{Token management, constants} % \begin{macrocode} \def\xint_gobble_ {}% \def\xint_gobble_i #1{}% @@ -5410,12 +6071,14 @@ first place. \def\xint_secondofthree #1#2#3{#2}% \def\xint_thirdofthree #1#2#3{#3}% \def\xint_minus_andstop { -}% -\def\xint_gob_til_r #1\R {}% -\def\xint_gob_til_w #1\W {}% -\def\xint_gob_til_z #1\Z {}% +\def\xint_gob_til_R #1\R {}% +\def\xint_gob_til_W #1\W {}% +\def\xint_gob_til_Z #1\Z {}% \def\xint_gob_til_zero #10{}% \def\xint_gob_til_one #11{}% -\def\xint_gob_til_zeros_iv #10000{}% +\def\xint_gob_til_G #1G{}% +\def\xint_gob_til_zeros_iii #1000{}% +\def\xint_gob_til_zeros_iv #10000{}% \def\xint_gob_til_relax #1\relax {}% \def\xint_gob_til_xint_undef #1\xint_undef {}% \def\xint_gob_til_xint_relax #1\xint_relax {}% @@ -5429,6 +6092,16 @@ first place. \def\xint_afterfi #1#2\fi {\fi #1}% \let\xint_relax\relax \def\xint_braced_xint_relax {\xint_relax }% +\chardef\xint_c_ 0 +\chardef\xint_c_i 1 +\chardef\xint_c_ii 2 +\chardef\xint_c_iii 3 +\chardef\xint_c_iv 4 +\chardef\xint_c_v 5 +\chardef\xint_c_viii 8 +\chardef\xint_c_ix 9 +\chardef\xint_c_x 10 +\newcount\xint_c_x^viii \xint_c_x^viii 100000000 % \end{macrocode} % \subsection{\csh{xintRev}, \csh{xintReverseOrder}} % \lverb|& @@ -5479,7 +6152,8 @@ first place. % maintaining it when it was already there.)$\ % hmm, at some point when I was cleaning up the code towards 1.07, I have % accidentally removed the {} which must be after\XINT_revwbr_loop. -% Corrected for 1.07a +% Corrected for 1.07a. Damn'it all the `noexpand` things in 1.07a were buggy, +% this was caused by a frivolous midnight de-commenting-out. Fixed for 1.08. % | % \begin{macrocode} \def\xintRevWithBraces {\romannumeral0\xintrevwithbraces }% @@ -5492,7 +6166,7 @@ first place. }% \def\xintrevwithbracesnoexpand #1% {% - \romannumeral0\XINT_revwbr_loop\expandafter{\expandafter}% + \XINT_revwbr_loop {}% #1\xint_relax\xint_relax\xint_relax\xint_relax \xint_relax\xint_relax\xint_relax\xint_relax\Z }% @@ -5507,7 +6181,7 @@ first place. }% \def\XINT_revwbr_finish_b #1#2#3#4#5#6#7#8\Z {% - \xint_gob_til_r + \xint_gob_til_R #1\XINT_revwbr_finish_c 8% #2\XINT_revwbr_finish_c 7% #3\XINT_revwbr_finish_c 6% @@ -5573,7 +6247,7 @@ first place. }% \def\XINT_length_finish_b #1#2#3#4#5#6#7#8\Z {% - \xint_gob_til_w + \xint_gob_til_W #1\XINT_length_finish_c 8% #2\XINT_length_finish_c 7% #3\XINT_length_finish_c 6% @@ -5604,7 +6278,7 @@ first place. }% \def\xintcsvtolistnoexpand #1% {% - \romannumeral0\XINT_csvtol_loop_a + \XINT_csvtol_loop_a {}#1,\xint_undef,\xint_undef,\xint_undef,\xint_undef ,\xint_undef,\xint_undef,\xint_undef,\xint_undef,\Z }% @@ -5620,7 +6294,7 @@ first place. }% \def\XINT_csvtol_finish_b #1,#2,#3,#4,#5,#6,#7,#8\Z {% - \xint_gob_til_r + \xint_gob_til_R #1\XINT_csvtol_finish_c 8% #2\XINT_csvtol_finish_c 7% #3\XINT_csvtol_finish_c 6% @@ -5659,17 +6333,16 @@ first place. \long\def\xintlistwithsep #1#2% {\expandafter\XINT_lws\expandafter {\romannumeral-`0#2}{#1}}% \long\def\XINT_lws #1#2{\XINT_lws_start {#2}#1\Z }% -\long\def\xintlistwithsepnoexpand #1#2% - {\romannumeral0\XINT_lws_start {#1}#2\Z }% +\long\def\xintlistwithsepnoexpand #1#2{\XINT_lws_start {#1}#2\Z }% \long\def\XINT_lws_start #1#2% {% - \xint_gob_til_z #2\XINT_lws_dont\Z + \xint_gob_til_Z #2\XINT_lws_dont\Z \XINT_lws_loop_a {#2}{#1}% }% \long\def\XINT_lws_dont\Z\XINT_lws_loop_a #1#2{ }% \long\def\XINT_lws_loop_a #1#2#3% {% - \xint_gob_til_z #3\XINT_lws_end\Z + \xint_gob_til_Z #3\XINT_lws_end\Z \XINT_lws_loop_b {#1}{#2#3}{#2}% }% \long\def\XINT_lws_loop_b #1#2{\XINT_lws_loop_a {#1#2}}% @@ -5693,11 +6366,11 @@ first place. }% \def\xintntheltnoexpand #1#2% {% - \romannumeral0\XINT_nthelt {#2}{\numexpr #1\relax}% + \XINT_nthelt {#2}{\numexpr #1\relax}% }% \def\XINT_nthelt #1#2% {% - \ifnum #2>0 + \ifnum #2>\xint_c_ \xint_afterfi {\XINT_nthelt_loop_a {#2}}% \else \xint_afterfi {\XINT_length_loop {0}}% @@ -5706,7 +6379,7 @@ first place. }% \def\XINT_nthelt_loop_a #1% {% - \ifnum #1>8 + \ifnum #1>\xint_c_viii \expandafter\XINT_nthelt_loop_b \else \expandafter\XINT_nthelt_getit @@ -5746,10 +6419,10 @@ first place. {#1}% }% \def\XINT_apply #1#2{\XINT_apply_loop_a {}{#2}#1\Z }% -\def\xintapplynoexpand #1#2{\romannumeral0\XINT_apply_loop_a {}{#1}#2\Z }% +\def\xintapplynoexpand #1#2{\XINT_apply_loop_a {}{#1}#2\Z }% \def\XINT_apply_loop_a #1#2#3% {% - \xint_gob_til_z #3\XINT_apply_end\Z + \xint_gob_til_Z #3\XINT_apply_end\Z \expandafter \XINT_apply_loop_b \expandafter {\romannumeral-`0#2{#3}}{#1}{#2}% @@ -5773,10 +6446,10 @@ first place. }% \def\XINT_applyunbr #1#2{\XINT_applyunbr_loop_a {}{#2}#1\Z }% \def\xintapplyunbracednoexpand #1#2% - {\romannumeral0\XINT_applyunbr_loop_a {}{#1}#2\Z }% + {\XINT_applyunbr_loop_a {}{#1}#2\Z }% \def\XINT_applyunbr_loop_a #1#2#3% {% - \xint_gob_til_z #3\XINT_applyunbr_end\Z + \xint_gob_til_Z #3\XINT_applyunbr_end\Z \expandafter\XINT_applyunbr_loop_b \expandafter {\romannumeral-`0#2{#3}}{#1}{#2}% }% @@ -5901,7 +6574,7 @@ first place. \xint_afterfi {\xintError:ArrayIndexIsNegative\space 0}% \else \xint_afterfi {% - \ifnum ##1> #2 + \ifnum ##1>#2 \xint_afterfi {\xintError:ArrayIndexBeyondLimit\space 0}% \else \xint_afterfi @@ -5924,7 +6597,7 @@ first place. % \begin{macrocode} \def\XINT_RQ #1#2#3#4#5#6#7#8#9% {% - \xint_gob_til_r #9\XINT_RQ_end_a\R\XINT_RQ {#9#8#7#6#5#4#3#2#1}% + \xint_gob_til_R #9\XINT_RQ_end_a\R\XINT_RQ {#9#8#7#6#5#4#3#2#1}% }% \def\XINT_RQ_end_a\R\XINT_RQ #1#2\Z {% @@ -5932,7 +6605,7 @@ first place. }% \def\XINT_RQ_end_b #1#2#3#4#5#6#7#8% {% - \xint_gob_til_r + \xint_gob_til_R #8\XINT_RQ_end_viii #7\XINT_RQ_end_vii #6\XINT_RQ_end_vi @@ -5951,6 +6624,62 @@ first place. \def\XINT_RQ_end_iii #1\Z #2#3#4#5#6#7#8#9\Z { #4#5#6#7#8#9000}% \def\XINT_RQ_end_ii #1\Z #2#3#4#5#6#7#8#9\Z { #3#4#5#6#7#8#900}% \def\XINT_RQ_end_i \Z #1#2#3#4#5#6#7#8\Z { #1#2#3#4#5#6#7#80}% +\def\XINT_SQ #1#2#3#4#5#6#7#8% +{% + \xint_gob_til_R #8\XINT_SQ_end_a\R\XINT_SQ {#8#7#6#5#4#3#2#1}% +}% +\def\XINT_SQ_end_a\R\XINT_SQ #1#2\Z +{% + \XINT_SQ_end_b #1\Z +}% +\def\XINT_SQ_end_b #1#2#3#4#5#6#7% +{% + \xint_gob_til_R + #7\XINT_SQ_end_vii + #6\XINT_SQ_end_vi + #5\XINT_SQ_end_v + #4\XINT_SQ_end_iv + #3\XINT_SQ_end_iii + #2\XINT_SQ_end_ii + \R\XINT_SQ_end_i + \Z #2#3#4#5#6#7% +}% +\def\XINT_SQ_end_vii #1\Z #2#3#4#5#6#7#8\Z { #8}% +\def\XINT_SQ_end_vi #1\Z #2#3#4#5#6#7#8\Z { #7#8000000}% +\def\XINT_SQ_end_v #1\Z #2#3#4#5#6#7#8\Z { #6#7#800000}% +\def\XINT_SQ_end_iv #1\Z #2#3#4#5#6#7#8\Z { #5#6#7#80000}% +\def\XINT_SQ_end_iii #1\Z #2#3#4#5#6#7#8\Z { #4#5#6#7#8000}% +\def\XINT_SQ_end_ii #1\Z #2#3#4#5#6#7#8\Z { #3#4#5#6#7#800}% +\def\XINT_SQ_end_i \Z #1#2#3#4#5#6#7\Z { #1#2#3#4#5#6#70}% +\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{XINT\_cuz}} % \begin{macrocode} @@ -5986,8 +6715,8 @@ first place. }% \def\XINT_cuz_loop #1#2#3#4#5#6#7#8% {% - \xint_gob_til_w #8\xint_cuz_end_a\W - \xint_gob_til_z #8\xint_cuz_end_A\Z + \xint_gob_til_W #8\xint_cuz_end_a\W + \xint_gob_til_Z #8\xint_cuz_end_A\Z \XINT_cuz_check_a {#1#2#3#4#5#6#7#8}% }% \def\xint_cuz_end_a #1\XINT_cuz_check_a #2% @@ -6018,12 +6747,12 @@ first place. \def\XINT_isone #1#2% {% \xint_gob_til_one #1\XINT_isone_b 1% - \expandafter\space\expandafter 0\xint_gob_til_z #2% + \expandafter\space\expandafter 0\xint_gob_til_Z #2% }% -\def\XINT_isone_b #1\xint_gob_til_z #2% +\def\XINT_isone_b #1\xint_gob_til_Z #2% {% - \xint_gob_til_w #2\XINT_isone_yes \W - \expandafter\space\expandafter 0\xint_gob_til_z + \xint_gob_til_W #2\XINT_isone_yes \W + \expandafter\space\expandafter 0\xint_gob_til_Z }% \def\XINT_isone_yes #1\Z { 1}% % \end{macrocode} @@ -6178,7 +6907,7 @@ first place. % \begin{macrocode} \def\XINT_add_A #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_add_az\W + \xint_gob_til_W #3\xint_add_az\W \XINT_add_AB #1{#3#4#5#6}{#2}% }% \def\xint_add_az\W\XINT_add_AB #1#2% @@ -6193,7 +6922,7 @@ first place. % \begin{macrocode} \def\XINT_add_AB #1#2#3#4\W\X\Y\Z #5#6#7#8% {% - \xint_gob_til_w #5\xint_add_bz\W + \xint_gob_til_W #5\xint_add_bz\W \XINT_add_ABE #1#2{#8#7#6#5}{#3}#4\W\X\Y\Z }% \def\XINT_add_ABE #1#2#3#4#5#6% @@ -6242,7 +6971,7 @@ first place. }% \def\XINT_add_C #1#2#3#4#5% {% - \xint_gob_til_w #2\xint_add_cz\W + \xint_gob_til_W #2\xint_add_cz\W \XINT_add_CD {#5#4#3#2}{#1}% }% \def\XINT_add_CD #1% @@ -6266,7 +6995,7 @@ first place. % \begin{macrocode} \def\XINT_addr_A #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_addr_az\W + \xint_gob_til_W #3\xint_addr_az\W \XINT_addr_B #1{#3#4#5#6}{#2}% }% \def\xint_addr_az\W\XINT_addr_B #1#2% @@ -6275,7 +7004,7 @@ first place. }% \def\XINT_addr_B #1#2#3#4\W\X\Y\Z #5#6#7#8% {% - \xint_gob_til_w #5\xint_addr_bz\W + \xint_gob_til_W #5\xint_addr_bz\W \XINT_addr_E #1#2{#8#7#6#5}{#3}#4\W\X\Y\Z }% \def\XINT_addr_E #1#2#3#4#5#6% @@ -6301,7 +7030,7 @@ first place. \def\xint_addr_AC_nocarry 0\XINT_addr_C #1#2\W\X\Y\Z { #1#2}% \def\XINT_addr_C #1#2#3#4#5% {% - \xint_gob_til_w #2\xint_addr_cz\W + \xint_gob_til_W #2\xint_addr_cz\W \XINT_addr_D {#5#4#3#2}{#1}% }% \def\XINT_addr_D #1% @@ -6320,7 +7049,7 @@ first place. % \begin{macrocode} \def\XINT_addm_A #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_addm_az\W + \xint_gob_til_W #3\xint_addm_az\W \XINT_addm_AB #1{#3#4#5#6}{#2}% }% \def\xint_addm_az\W\XINT_addm_AB #1#2% @@ -6357,7 +7086,7 @@ first place. }% \def\XINT_addm_C #1#2#3#4#5% {% - \xint_gob_til_w + \xint_gob_til_W #5\xint_addm_cw #4\xint_addm_cx #3\xint_addm_cy @@ -6421,7 +7150,7 @@ first place. % \begin{macrocode} \def\XINT_addp_A #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_addp_az\W + \xint_gob_til_W #3\xint_addp_az\W \XINT_addp_AB #1{#3#4#5#6}{#2}% }% \def\xint_addp_az\W\XINT_addp_AB #1#2% @@ -6450,7 +7179,7 @@ first place. }% \def\XINT_addp_C #1#2#3#4#5% {% - \xint_gob_til_w + \xint_gob_til_W #5\xint_addp_cw #4\xint_addp_cx #3\xint_addp_cy @@ -6471,7 +7200,7 @@ first place. #3\xint_addp_cz \W\XINT_addp_CD {% - \expandafter\XINT_addp_CDw\the\numexpr 1+10#1#2#3\relax + \expandafter\XINT_addp_CDw\the\numexpr \xint_c_i+10#1#2#3\relax }% \def\XINT_addp_CDw #1#2#3#4#5#6% {% @@ -6485,7 +7214,7 @@ first place. #2\xint_addp_cz \W\XINT_addp_CD {% - \expandafter\XINT_addp_CDx\the\numexpr 1+100#1#2\relax + \expandafter\XINT_addp_CDx\the\numexpr \xint_c_i+100#1#2\relax }% \def\XINT_addp_CDx #1#2#3#4#5#6% {% @@ -6494,11 +7223,9 @@ first place. }% \def\XINT_addp_endDx_zeros 0000\XINT_addp_endDx 0000#1\Y\Z{ #1}% \def\XINT_addp_endDx #1#2#3#4#5\Y\Z{ #5#4#3#2#1}% -\def\xint_addp_cy - #1\xint_addp_cz - \W\XINT_addp_CD +\def\xint_addp_cy #1\xint_addp_cz\W\XINT_addp_CD {% - \expandafter\XINT_addp_CDy\the\numexpr 1+1000#1\relax + \expandafter\XINT_addp_CDy\the\numexpr \xint_c_i+1000#1\relax }% \def\XINT_addp_CDy #1#2#3#4#5#6% {% @@ -6510,7 +7237,7 @@ first place. \def\xint_addp_cz\W\XINT_addp_CD #1#2{ #21000}% \def\XINT_addp_F #1#2#3#4#5% {% - \xint_gob_til_w + \xint_gob_til_W #5\xint_addp_Gw #4\xint_addp_Gx #3\xint_addp_Gy @@ -6611,10 +7338,10 @@ first place. }% \def\XINT_add_pre #1% {% - \expandafter\XINT_add__pre\expandafter + \expandafter\XINT_add_pre_b\expandafter {\romannumeral0\XINT_RQ {}#1\R\R\R\R\R\R\R\R\Z }% }% -\def\XINT_add__pre #1#2% +\def\XINT_add_pre_b #1#2% {% \expandafter\XINT_add_A \expandafter0\expandafter{\expandafter}% @@ -6680,10 +7407,10 @@ first place. \def\xint_sub_pm #1\XINT_add_pre #2#3{ -#2}% \def\XINT_sub_pre #1% {% - \expandafter\XINT_sub__pre\expandafter + \expandafter\XINT_sub_pre_b\expandafter {\romannumeral0\XINT_RQ {}#1\R\R\R\R\R\R\R\R\Z }% }% -\def\XINT_sub__pre #1#2% +\def\XINT_sub_pre_b #1#2% {% \expandafter\XINT_sub_A \expandafter1\expandafter{\expandafter}% @@ -6701,13 +7428,13 @@ first place. % \begin{macrocode} \def\XINT_sub_A #1#2#3\W\X\Y\Z #4#5#6#7% {% - \xint_gob_til_w + \xint_gob_til_W #4\xint_sub_az \W\XINT_sub_B #1{#4#5#6#7}{#2}#3\W\X\Y\Z }% \def\XINT_sub_B #1#2#3#4#5#6#7% {% - \xint_gob_til_w + \xint_gob_til_W #4\xint_sub_bz \W\XINT_sub_onestep #1#2{#7#6#5#4}{#3}% }% @@ -6720,7 +7447,7 @@ first place. % \begin{macrocode} \def\XINT_sub_onestep #1#2#3#4#5#6% {% - \expandafter\XINT_sub_backtoA\the\numexpr 11#5#4#3#2-#6+#1-1\relax.% + \expandafter\XINT_sub_backtoA\the\numexpr 11#5#4#3#2-#6+#1-\xint_c_i\relax.% }% % \end{macrocode} % \lverb|ON PRODUIT LE RÉSULTAT DANS LE BON ORDRE| @@ -6752,13 +7479,13 @@ first place. }% \def\XINT_sub_C #1#2#3#4#5% {% - \xint_gob_til_w + \xint_gob_til_W #2\xint_sub_cz \W\XINT_sub_AC_onestep {#5#4#3#2}{#1}% }% \def\XINT_sub_AC_onestep #1% {% - \expandafter\XINT_sub_backtoC\the\numexpr 11#1-1\relax.% + \expandafter\XINT_sub_backtoC\the\numexpr 11#1-\xint_c_i\relax.% }% \def\XINT_sub_backtoC #1#2#3.#4% {% @@ -6786,7 +7513,7 @@ first place. }% \def\xint_sub_az\W\XINT_sub_B #1#2#3#4#5#6#7% {% - \xint_gob_til_w + \xint_gob_til_W #4\xint_sub_ez \W\XINT_sub_Eenter #1{#3}#4#5#6#7% }% @@ -6807,7 +7534,7 @@ first place. }% \def\XINT_sub_E #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_sub_F\W + \xint_gob_til_W #3\xint_sub_F\W \XINT_sub_Eonestep #1{#6#5#4#3}{#2}% }% \def\XINT_sub_Eonestep #1#2% @@ -6830,12 +7557,12 @@ first place. \def\XINT_sub_DD {\expandafter\xint_minus_andstop\romannumeral0\XINT_sub_D }% \def\XINT_sub_Fdec #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_sub_Fdec_finish\W + \xint_gob_til_W #3\xint_sub_Fdec_finish\W \XINT_sub_Fdec_onestep #1{#6#5#4#3}{#2}% }% \def\XINT_sub_Fdec_onestep #1#2% {% - \expandafter\XINT_sub_backtoFdec\the\numexpr 11#2+#1-1\relax.% + \expandafter\XINT_sub_backtoFdec\the\numexpr 11#2+#1-\xint_c_i\relax.% }% \def\XINT_sub_backtoFdec #1#2#3.#4% {% @@ -6847,7 +7574,7 @@ first place. }% \def\XINT_sub_Finc #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_sub_Finc_finish\W + \xint_gob_til_W #3\xint_sub_Finc_finish\W \XINT_sub_Finc_onestep #1{#6#5#4#3}{#2}% }% \def\XINT_sub_Finc_onestep #1#2% @@ -6887,7 +7614,7 @@ first place. }% \def\XINT_sub_KK #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_sub_KK_finish\W + \xint_gob_til_W #3\xint_sub_KK_finish\W \XINT_sub_KK_onestep #1{#6#5#4#3}{#2}% }% \def\XINT_sub_KK_onestep #1#2% @@ -6954,10 +7681,10 @@ first place. }% \def\XINT_cmp_pre #1% {% - \expandafter\XINT_cmp__pre\expandafter + \expandafter\XINT_cmp_pre_b\expandafter {\romannumeral0\XINT_RQ {}#1\R\R\R\R\R\R\R\R\Z }% }% -\def\XINT_cmp__pre #1#2% +\def\XINT_cmp_pre_b #1#2% {% \expandafter\XINT_cmp_A \expandafter1\expandafter{\expandafter}% @@ -6976,17 +7703,17 @@ first place. % \begin{macrocode} \def\XINT_cmp_A #1#2#3\W\X\Y\Z #4#5#6#7% {% - \xint_gob_til_w #4\xint_cmp_az\W + \xint_gob_til_W #4\xint_cmp_az\W \XINT_cmp_B #1{#4#5#6#7}{#2}#3\W\X\Y\Z }% \def\XINT_cmp_B #1#2#3#4#5#6#7% {% - \xint_gob_til_w#4\xint_cmp_bz\W + \xint_gob_til_W#4\xint_cmp_bz\W \XINT_cmp_onestep #1#2{#7#6#5#4}{#3}% }% \def\XINT_cmp_onestep #1#2#3#4#5#6% {% - \expandafter\XINT_cmp_backtoA\the\numexpr 11#5#4#3#2-#6+#1-1\relax.% + \expandafter\XINT_cmp_backtoA\the\numexpr 11#5#4#3#2-#6+#1-\xint_c_i\relax.% }% \def\XINT_cmp_backtoA #1#2#3.#4% {% @@ -6995,7 +7722,7 @@ first place. \def\xint_cmp_bz\W\XINT_cmp_onestep #1\Z { 1}% \def\xint_cmp_az\W\XINT_cmp_B #1#2#3#4#5#6#7% {% - \xint_gob_til_w #4\xint_cmp_ez\W + \xint_gob_til_W #4\xint_cmp_ez\W \XINT_cmp_Eenter #1{#3}#4#5#6#7% }% \def\XINT_cmp_Eenter #1\Z { -1}% @@ -7014,7 +7741,7 @@ first place. }% \def\XINT_OneIfPositive_main #1#2#3#4% {% - \xint_gob_til_z #4\xint_OneIfPositive_terminated\Z + \xint_gob_til_Z #4\xint_OneIfPositive_terminated\Z \XINT_OneIfPositive_onestep #1#2#3#4% }% \def\xint_OneIfPositive_terminated\Z\XINT_OneIfPositive_onestep\W\X\Y\Z { 0}% @@ -7074,10 +7801,10 @@ first place. \def\XINT_geq_plusminus #1#2#3#4{\XINT_geq_pre {#2}{#3#1}}% \def\XINT_geq_pre #1% {% - \expandafter\XINT_geq__pre\expandafter + \expandafter\XINT_geq_pre_b\expandafter {\romannumeral0\XINT_RQ {}#1\R\R\R\R\R\R\R\R\Z }% }% -\def\XINT_geq__pre #1#2% +\def\XINT_geq_pre_b #1#2% {% \expandafter\XINT_geq_A \expandafter1\expandafter{\expandafter}% @@ -7096,17 +7823,17 @@ first place. % \begin{macrocode} \def\XINT_geq_A #1#2#3\W\X\Y\Z #4#5#6#7% {% - \xint_gob_til_w #4\xint_geq_az\W + \xint_gob_til_W #4\xint_geq_az\W \XINT_geq_B #1{#4#5#6#7}{#2}#3\W\X\Y\Z }% \def\XINT_geq_B #1#2#3#4#5#6#7% {% - \xint_gob_til_w #4\xint_geq_bz\W + \xint_gob_til_W #4\xint_geq_bz\W \XINT_geq_onestep #1#2{#7#6#5#4}{#3}% }% \def\XINT_geq_onestep #1#2#3#4#5#6% {% - \expandafter\XINT_geq_backtoA\the\numexpr 11#5#4#3#2-#6+#1-1\relax.% + \expandafter\XINT_geq_backtoA\the\numexpr 11#5#4#3#2-#6+#1-\xint_c_i\relax.% }% \def\XINT_geq_backtoA #1#2#3.#4% {% @@ -7115,7 +7842,7 @@ first place. \def\xint_geq_bz\W\XINT_geq_onestep #1\W\X\Y\Z { 1}% \def\xint_geq_az\W\XINT_geq_B #1#2#3#4#5#6#7% {% - \xint_gob_til_w #4\xint_geq_ez\W + \xint_gob_til_W #4\xint_geq_ez\W \XINT_geq_Eenter #1% }% \def\XINT_geq_Eenter #1\W\X\Y\Z { 0}% @@ -7130,7 +7857,9 @@ first place. % \subsection{\csh{xintMax}} % \lverb|& % The rationale is that it is more efficient than using \xintCmp. -% 1.03 makes the code a tiny bit slower but easier to re-use for fractions. | +% 1.03 makes the code a tiny bit slower but easier to re-use for fractions. +% Note: actually since 1.08a code for fractions does not all reduce to these +% entry points, so perhaps I should revert the changes made in 1.03.| % \begin{macrocode} \def\xintiMax {\romannumeral0\xintimax }% \def\xintimax #1% @@ -7384,10 +8113,10 @@ first place. }% \def\XINT_mul_choice_b #1#2% {% - \ifnum #1<5 + \ifnum #1<\xint_c_v \expandafter\XINT_mul_choice_littlebyfirst \else - \ifnum #2<5 + \ifnum #2<\xint_c_v \expandafter\expandafter\expandafter\XINT_mul_choice_littlebysecond \else \expandafter\expandafter\expandafter\XINT_mul_choice_compare @@ -7418,7 +8147,7 @@ first place. }% \def\XINT_mul_choice_i #1#2% {% - \ifnum #1<\numexpr\ifcase \numexpr (#2-3)/4\relax + \ifnum #1<\numexpr\ifcase \numexpr (#2-\xint_c_iii)/\xint_c_iv\relax \or 330\or 168\or 109\or 80\or 66\or 52\else 0\fi\relax \expandafter\XINT_mul_choice_same \else @@ -7427,7 +8156,7 @@ first place. }% \def\XINT_mul_choice_ii #1#2% {% - \ifnum #2<\numexpr\ifcase \numexpr (#1-3)/4\relax + \ifnum #2<\numexpr\ifcase \numexpr (#1-\xint_c_iii)/\xint_c_iv\relax \or 330\or 168\or 109\or 80\or 66\or 52\else 0\fi\relax \expandafter\XINT_mul_choice_permute \else @@ -7438,13 +8167,13 @@ first place. {% \expandafter\XINT_mul_enter \romannumeral0\XINT_RQ {}#1\R\R\R\R\R\R\R\R\Z - \W\X\Y\Z #2\W\X\Y\Z + \Z\Z\Z\Z #2\W\W\W\W }% \def\XINT_mul_choice_permute #1#2% {% \expandafter\XINT_mul_enter \romannumeral0\XINT_RQ {}#2\R\R\R\R\R\R\R\R\Z - \W\X\Y\Z #1\W\X\Y\Z + \Z\Z\Z\Z #1\W\W\W\W }% % \end{macrocode} % \lverb|& @@ -7456,7 +8185,7 @@ first place. % \begin{macrocode} \def\XINT_mul_Ar #1#2#3#4#5#6% {% - \xint_gob_til_z #6\xint_mul_br\Z\XINT_mul_Br #1{#6#5#4#3}{#2}% + \xint_gob_til_Z #6\xint_mul_br\Z\XINT_mul_Br #1{#6#5#4#3}{#2}% }% \def\xint_mul_br\Z\XINT_mul_Br #1#2% {% @@ -7498,11 +8227,11 @@ first place. \def\XINT_mul_Mr_one #1#2#3#4\Z\Z\Z\Z { #4}% \def\XINT_mul_Nr #1#2#3#4#5#6#7% {% - \xint_gob_til_z #4\xint_mul_pr\Z\XINT_mul_Pr {#1}{#3}{#7#6#5#4}{#2}{#3}% + \xint_gob_til_Z #4\xint_mul_pr\Z\XINT_mul_Pr {#1}{#3}{#7#6#5#4}{#2}{#3}% }% \def\XINT_mul_Pr #1#2#3% {% - \expandafter\XINT_mul_Lr\the\numexpr 10000#1+#2*#3\relax + \expandafter\XINT_mul_Lr\the\numexpr \xint_c_x^viii+#1+#2*#3\relax }% \def\XINT_mul_Lr 1#1#2#3#4#5#6#7#8#9% {% @@ -7545,11 +8274,11 @@ first place. }% \def\XINT_mul_N #1#2#3#4#5#6#7% {% - \xint_gob_til_z #4\xint_mul_p\Z\XINT_mul_P {#1}{#3}{#7#6#5#4}{#2}{#3}% + \xint_gob_til_Z #4\xint_mul_p\Z\XINT_mul_P {#1}{#3}{#7#6#5#4}{#2}{#3}% }% \def\XINT_mul_P #1#2#3% {% - \expandafter\XINT_mul_L\the\numexpr 10000#1+#2*#3\relax + \expandafter\XINT_mul_L\the\numexpr \xint_c_x^viii+#1+#2*#3\relax }% \def\XINT_mul_L 1#1#2#3#4#5#6#7#8#9% {% @@ -7566,66 +8295,74 @@ first place. % \end{macrocode} % \lverb|& % Routine de multiplication principale -% délimiteur \W\X\Y\Z$\ +% (attention délimiteurs modifiés pour 1.08)$\ % Le résultat partiel est toujours maintenu avec significatif à % droite et il a un nombre multiple de 4 de chiffres$\ -% \romannumeral0\XINT_mul_enter <N1>\W\X\Y\Z <N2>\W\X\Y\Z$\ +% \romannumeral0\XINT_mul_enter <N1>\Z\Z\Z\Z <N2>\W\W\W\W$\ % avec <N1> *renversé*, *longueur 4n* (zéros éventuellement ajoutés % au-delà du chiffre le plus significatif) % et <N2> dans l'ordre *normal*, et pas forcément longueur 4n. -% pas de signes| -% \begin{macrocode} -\def\XINT_mul_enter #1\W\X\Y\Z #2#3#4#5% +% pas de signes.$\ +% Pour 1.08: dans \XINT_mul_enter et les modifs de 1.03 +% qui filtrent les courts, on pourrait croire que le +% second opérande a au moins quatre chiffres; mais le problème c'est que +% ceci est appelé par \XINT_sqr. Et de plus \XINT_sqr est utilisé dans +% la nouvelle routine d'extraction de racine carrée: je ne veux pas +% rajouter l'overhead à \XINT_sqr de voir si a longueur est au moins 4. +% Dilemme donc. Il ne semble pas y avoir d'autres accès +% directs (celui de big fac n'est pas un problème). J'ai presque été +% tenté de faire du 5x4, mais si on veut maintenir les résultats +% intermédiaires sur 4n, il y a des complications. Par ailleurs, +% je modifie aussi un petit peu la façon de coder la suite, compte tenu +% du style que j'ai développé ultérieurement. Attention terminaison +% modifiée pour le deuxième opérande.| +% \begin{macrocode} +\def\XINT_mul_enter #1\Z\Z\Z\Z #2#3#4#5% {% - \xint_gob_til_w - #5\xint_mul_enterw - #4\xint_mul_enterx - #3\xint_mul_entery - #2\xint_mul_enterz - \W\XINT_mul_start {#2#3#4#5}#1\W\X\Y\Z + \xint_gob_til_W #5\XINT_mul_exit_a\W + \XINT_mul_start {#2#3#4#5}#1\Z\Z\Z\Z }% -\def\xint_mul_enterw - #1\xint_mul_enterx - #2\xint_mul_entery - #3\xint_mul_enterz - \W\XINT_mul_start #4#5\W\X\Y\Z \X\Y\Z +\def\XINT_mul_exit_a\W\XINT_mul_start #1% {% - \XINT_mul_M {#3#2#1}#5\Z\Z\Z\Z + \XINT_mul_exit_b #1% }% -\def\xint_mul_enterx - #1\xint_mul_entery - #2\xint_mul_enterz - \W\XINT_mul_start #3#4\W\X\Y\Z \Y\Z +\def\XINT_mul_exit_b #1#2#3#4% {% - \XINT_mul_M {#2#1}#4\Z\Z\Z\Z + \xint_gob_til_W + #2\XINT_mul_exit_ci + #3\XINT_mul_exit_cii + \W\XINT_mul_exit_ciii #1#2#3#4% }% -\def\xint_mul_entery - #1\xint_mul_enterz - \W\XINT_mul_start #2#3\W\X\Y\Z \Z +\def\XINT_mul_exit_ciii #1\W #2\Z\Z\Z\Z \W\W\W {% - \XINT_mul_M {#1}#3\Z\Z\Z\Z + \XINT_mul_M {#1}#2\Z\Z\Z\Z }% -\def\XINT_mul_start #1#2\W\X\Y\Z +\def\XINT_mul_exit_cii\W\XINT_mul_exit_ciii #1\W\W #2\Z\Z\Z\Z \W\W +{% + \XINT_mul_M {#1}#2\Z\Z\Z\Z +}% +\def\XINT_mul_exit_ci\W\XINT_mul_exit_cii + \W\XINT_mul_exit_ciii #1\W\W\W #2\Z\Z\Z\Z \W +{% + \XINT_mul_M {#1}#2\Z\Z\Z\Z +}% +\def\XINT_mul_start #1#2\Z\Z\Z\Z {% \expandafter\XINT_mul_main\expandafter - {\romannumeral0\XINT_mul_Mr {#1}#2\Z\Z\Z\Z}#2\W\X\Y\Z + {\romannumeral0\XINT_mul_Mr {#1}#2\Z\Z\Z\Z}#2\Z\Z\Z\Z }% -\def\XINT_mul_main #1#2\W\X\Y\Z #3#4#5#6% +\def\XINT_mul_main #1#2\Z\Z\Z\Z #3#4#5#6% {% - \xint_gob_til_w - #6\xint_mul_mainw - #5\xint_mul_mainx - #4\xint_mul_mainy - #3\xint_mul_mainz - \W\XINT_mul_compute {#1}{#3#4#5#6}#2\W\X\Y\Z + \xint_gob_til_W #6\XINT_mul_finish_a\W + \XINT_mul_compute {#3#4#5#6}{#1}#2\Z\Z\Z\Z }% -\def\XINT_mul_compute #1#2#3\W\X\Y\Z +\def\XINT_mul_compute #1#2#3\Z\Z\Z\Z {% \expandafter\XINT_mul_main\expandafter {\romannumeral0\expandafter \XINT_mul_Ar\expandafter0\expandafter{\expandafter}% - \romannumeral0\XINT_mul_Mr {#2}#3\Z\Z\Z\Z - \W\X\Y\Z 0000#1\W\X\Y\Z }#3\W\X\Y\Z + \romannumeral0\XINT_mul_Mr {#1}#3\Z\Z\Z\Z + \W\X\Y\Z 0000#2\W\X\Y\Z }#3\Z\Z\Z\Z }% % \end{macrocode} % \lverb|& @@ -7635,132 +8372,125 @@ first place. % dernière addition a fourni le résultat à l'envers, il faut donc encore le % renverser. | % \begin{macrocode} -\def\xint_mul_mainw - #1\xint_mul_mainx - #2\xint_mul_mainy - #3\xint_mul_mainz - \W\XINT_mul_compute #4#5#6\W\X\Y\Z \X\Y\Z +\def\XINT_mul_finish_a\W\XINT_mul_compute #1% {% - \expandafter\XINT_addm_A \expandafter0\expandafter{\expandafter}% - \romannumeral0% - \XINT_mul_Mr {#3#2#1}#6\Z\Z\Z\Z - \W\X\Y\Z 000#4\W\X\Y\Z + \XINT_mul_finish_b #1% }% -\def\xint_mul_mainx - #1\xint_mul_mainy - #2\xint_mul_mainz - \W\XINT_mul_compute #3#4#5\W\X\Y\Z \Y\Z +\def\XINT_mul_finish_b #1#2#3#4% {% - \expandafter\XINT_addm_A\expandafter - 0\expandafter{\expandafter}% - \romannumeral0\XINT_mul_Mr {#2#1}#5\Z\Z\Z\Z - \W\X\Y\Z 00#3\W\X\Y\Z + \xint_gob_til_W + #1\XINT_mul_finish_c + #2\XINT_mul_finish_ci + #3\XINT_mul_finish_cii + \W\XINT_mul_finish_ciii #1#2#3#4% }% -\def\xint_mul_mainy - #1\xint_mul_mainz - \W\XINT_mul_compute #2#3#4\W\X\Y\Z \Z +\def\XINT_mul_finish_ciii #1\W #2#3\Z\Z\Z\Z \W\W\W {% - \expandafter\XINT_addm_A\expandafter - 0\expandafter{\expandafter}% - \romannumeral0\XINT_mul_Mr {#1}#4\Z\Z\Z\Z - \W\X\Y\Z 0#2\W\X\Y\Z + \expandafter\XINT_addm_A\expandafter0\expandafter{\expandafter}% + \romannumeral0\XINT_mul_Mr {#1}#3\Z\Z\Z\Z \W\X\Y\Z 000#2\W\X\Y\Z }% -\def\xint_mul_mainz\W\XINT_mul_compute #1#2#3\W\X\Y\Z +\def\XINT_mul_finish_cii + \W\XINT_mul_finish_ciii #1\W\W #2#3\Z\Z\Z\Z \W\W {% - \expandafter\xint_cleanupzeros_andstop\romannumeral0\XINT_rev{#1}% + \expandafter\XINT_addm_A\expandafter0\expandafter{\expandafter}% + \romannumeral0\XINT_mul_Mr {#1}#3\Z\Z\Z\Z \W\X\Y\Z 00#2\W\X\Y\Z +}% +\def\XINT_mul_finish_ci #1\XINT_mul_finish_ciii #2\W\W\W #3#4\Z\Z\Z\Z \W +{% + \expandafter\XINT_addm_A\expandafter0\expandafter{\expandafter}% + \romannumeral0\XINT_mul_Mr {#2}#4\Z\Z\Z\Z \W\X\Y\Z 0#3\W\X\Y\Z +}% +\def\XINT_mul_finish_c #1\XINT_mul_finish_ciii \W\W\W\W #2#3\Z\Z\Z\Z +{% + \expandafter\xint_cleanupzeros_andstop\romannumeral0\XINT_rev{#2}% }% % \end{macrocode} % \lverb|& % Variante de la Multiplication$\ -% \romannumeral0\XINT_mulr_enter <N1>\W\X\Y\Z <N2>\W\X\Y\Z$\ +% \romannumeral0\XINT_mulr_enter <N1>\Z\Z\Z\Z <N2>\W\W\W\W $\ % Ici <N1> est à l'envers sur 4n, et <N2> est à l'endroit, pas sur 4n, comme % dans \XINT_mul_enter, mais le résultat est lui-même fourni *à l'envers*, sur % *4n* (en faisant attention de ne pas avoir 0000 à la fin).$\ -% Utilisé par le calcul des puissances et aussi par la division.| +% Utilisé par le calcul des puissances. J'ai modifié dans 1.08 sur le +% modèle de la nouvelle version de \XINT_mul_enter. Je pourrais économiser des +% macros et fusionner \XINT_mul_enter et \XINT_mulr_enter. Une autre fois.| % \begin{macrocode} -\def\XINT_mulr_enter #1\W\X\Y\Z #2#3#4#5% +\def\XINT_mulr_enter #1\Z\Z\Z\Z #2#3#4#5% {% - \xint_gob_til_w - #5\xint_mulr_enterw - #4\xint_mulr_enterx - #3\xint_mulr_entery - #2\xint_mulr_enterz - \W\XINT_mulr_start {#2#3#4#5}#1\W\X\Y\Z + \xint_gob_til_W #5\XINT_mulr_exit_a\W + \XINT_mulr_start {#2#3#4#5}#1\Z\Z\Z\Z }% -\def\xint_mulr_enterw - #1\xint_mulr_enterx - #2\xint_mulr_entery - #3\xint_mulr_enterz - \W\XINT_mulr_start #4#5\W\X\Y\Z \X\Y\Z +\def\XINT_mulr_exit_a\W\XINT_mulr_start #1% {% - \XINT_mul_Mr {#3#2#1}#5\Z\Z\Z\Z + \XINT_mulr_exit_b #1% }% -\def\xint_mulr_enterx - #1\xint_mulr_entery - #2\xint_mulr_enterz - \W\XINT_mulr_start #3#4\W\X\Y\Z \Y\Z +\def\XINT_mulr_exit_b #1#2#3#4% {% - \XINT_mul_Mr {#2#1}#4\Z\Z\Z\Z + \xint_gob_til_W + #2\XINT_mulr_exit_ci + #3\XINT_mulr_exit_cii + \W\XINT_mulr_exit_ciii #1#2#3#4% }% -\def\xint_mulr_entery - #1\xint_mulr_enterz - \W\XINT_mulr_start #2#3\W\X\Y\Z \Z +\def\XINT_mulr_exit_ciii #1\W #2\Z\Z\Z\Z \W\W\W {% - \XINT_mul_Mr {#1}#3\Z\Z\Z\Z + \XINT_mul_Mr {#1}#2\Z\Z\Z\Z }% -\def\XINT_mulr_start #1#2\W\X\Y\Z +\def\XINT_mulr_exit_cii\W\XINT_mulr_exit_ciii #1\W\W #2\Z\Z\Z\Z \W\W +{% + \XINT_mul_Mr {#1}#2\Z\Z\Z\Z +}% +\def\XINT_mulr_exit_ci\W\XINT_mulr_exit_cii + \W\XINT_mulr_exit_ciii #1\W\W\W #2\Z\Z\Z\Z \W +{% + \XINT_mul_Mr {#1}#2\Z\Z\Z\Z +}% +\def\XINT_mulr_start #1#2\Z\Z\Z\Z {% \expandafter\XINT_mulr_main\expandafter - {\romannumeral0\XINT_mul_Mr {#1}#2\Z\Z\Z\Z }#2\W\X\Y\Z + {\romannumeral0\XINT_mul_Mr {#1}#2\Z\Z\Z\Z}#2\Z\Z\Z\Z }% -\def\XINT_mulr_main #1#2\W\X\Y\Z #3#4#5#6% +\def\XINT_mulr_main #1#2\Z\Z\Z\Z #3#4#5#6% {% - \xint_gob_til_w - #6\xint_mulr_mainw - #5\xint_mulr_mainx - #4\xint_mulr_mainy - #3\xint_mulr_mainz - \W\XINT_mulr_compute {#1}{#3#4#5#6}#2\W\X\Y\Z + \xint_gob_til_W #6\XINT_mulr_finish_a\W + \XINT_mulr_compute {#3#4#5#6}{#1}#2\Z\Z\Z\Z }% -\def\XINT_mulr_compute #1#2#3\W\X\Y\Z +\def\XINT_mulr_compute #1#2#3\Z\Z\Z\Z {% \expandafter\XINT_mulr_main\expandafter {\romannumeral0\expandafter - \XINT_mul_Ar \expandafter0\expandafter{\expandafter}% - \romannumeral0\XINT_mul_Mr {#2}#3\Z\Z\Z\Z \W\X\Y\Z 0000#1\W\X\Y\Z - }#3\W\X\Y\Z -}% -\def\xint_mulr_mainw - #1\xint_mulr_mainx - #2\xint_mulr_mainy - #3\xint_mulr_mainz - \W\XINT_mulr_compute #4#5#6\W\X\Y\Z \X\Y\Z -{% - \expandafter\XINT_addp_A - \expandafter0\expandafter{\expandafter}% - \romannumeral0\XINT_mul_Mr {#3#2#1}#6\Z\Z\Z\Z - \W\X\Y\Z 000#4\W\X\Y\Z -}% -\def\xint_mulr_mainx - #1\xint_mulr_mainy - #2\xint_mulr_mainz - \W\XINT_mulr_compute #3#4#5\W\X\Y\Z \Y\Z -{% - \expandafter\XINT_addp_A - \expandafter0\expandafter{\expandafter}% - \romannumeral0\XINT_mul_Mr {#2#1}#5\Z\Z\Z\Z - \W\X\Y\Z 00#3\W\X\Y\Z -}% -\def\xint_mulr_mainy - #1\xint_mulr_mainz - \W\XINT_mulr_compute #2#3#4\W\X\Y\Z \Z -{% - \expandafter\XINT_addp_A - \expandafter0\expandafter{\expandafter}% - \romannumeral0\XINT_mul_Mr {#1}#4\Z\Z\Z\Z - \W\X\Y\Z 0#2\W\X\Y\Z -}% -\def\xint_mulr_mainz\W\XINT_mulr_compute #1#2#3\W\X\Y\Z { #1}% + \XINT_mul_Ar\expandafter0\expandafter{\expandafter}% + \romannumeral0\XINT_mul_Mr {#1}#3\Z\Z\Z\Z + \W\X\Y\Z 0000#2\W\X\Y\Z }#3\Z\Z\Z\Z +}% +\def\XINT_mulr_finish_a\W\XINT_mulr_compute #1% +{% + \XINT_mulr_finish_b #1% +}% +\def\XINT_mulr_finish_b #1#2#3#4% +{% + \xint_gob_til_W + #1\XINT_mulr_finish_c + #2\XINT_mulr_finish_ci + #3\XINT_mulr_finish_cii + \W\XINT_mulr_finish_ciii #1#2#3#4% +}% +\def\XINT_mulr_finish_ciii #1\W #2#3\Z\Z\Z\Z \W\W\W +{% + \expandafter\XINT_addp_A\expandafter0\expandafter{\expandafter}% + \romannumeral0\XINT_mul_Mr {#1}#3\Z\Z\Z\Z \W\X\Y\Z 000#2\W\X\Y\Z +}% +\def\XINT_mulr_finish_cii + \W\XINT_mulr_finish_ciii #1\W\W #2#3\Z\Z\Z\Z \W\W +{% + \expandafter\XINT_addp_A\expandafter0\expandafter{\expandafter}% + \romannumeral0\XINT_mul_Mr {#1}#3\Z\Z\Z\Z \W\X\Y\Z 00#2\W\X\Y\Z +}% +\def\XINT_mulr_finish_ci #1\XINT_mulr_finish_ciii #2\W\W\W #3#4\Z\Z\Z\Z \W +{% + \expandafter\XINT_addp_A\expandafter0\expandafter{\expandafter}% + \romannumeral0\XINT_mul_Mr {#2}#4\Z\Z\Z\Z \W\X\Y\Z 0#3\W\X\Y\Z +}% +\def\XINT_mulr_finish_c #1\XINT_mulr_finish_ciii \W\W\W\W #2#3\Z\Z\Z\Z { #2}% % \end{macrocode} % \subsection{\csh{xintSqr}} % \begin{macrocode} @@ -7771,11 +8501,11 @@ first place. }% \let\xintSqr\xintiSqr \let\xintsqr\xintisqr \def\XINT_sqr #1% -{% +{% \expandafter\XINT_mul_enter \romannumeral0% \XINT_RQ {}#1\R\R\R\R\R\R\R\R\Z - \W\X\Y\Z #1\W\X\Y\Z + \Z\Z\Z\Z #1\W\W\W\W }% % \end{macrocode} % \subsection{\csh{xintPrd}, \csh{xintPrdExpr}} @@ -7837,11 +8567,12 @@ first place. % the \xintError:$\ FactorialOfTooBigNumber for argument larger than 1000000 % (rather than 1000000000).| % \begin{macrocode} -\def\xintFac {\romannumeral0\xintfac }% -\def\xintfac #1% +\def\xintiFac {\romannumeral0\xintifac }% +\def\xintifac #1% {% \expandafter\XINT_fac_fork\expandafter{\the\numexpr #1}% }% +\let\xintFac\xintiFac \let\xintfac\xintifac \def\XINT_fac_fork #1% {% \ifcase\XINT_Sgn {#1} @@ -7892,7 +8623,7 @@ first place. \expandafter\XINT_fac_bigcompute_loop\expandafter {\expandafter\XINT_mul_enter \romannumeral0\XINT_RQ {}#2\R\R\R\R\R\R\R\R\Z - \W\X\Y\Z #1\W\X\Y\Z }% + \Z\Z\Z\Z #1\W\W\W\W }% }% \def\XINT_fac_bigcompute_end #1#2#3#4#5% {% @@ -8001,7 +8732,7 @@ first place. \ifcase\XINT_Sgn {#1} \expandafter\XINT_pow_BisZero \or - \expandafter\XINT_pow_checkBlength + \expandafter\XINT_pow_checkBsize \else \expandafter\XINT_pow_BisNegative \fi @@ -8016,7 +8747,7 @@ first place. % of \numexpr [to generate an error message if the exponent is too large] % 1.06: \numexpr was already used above.| % \begin{macrocode} -\def\XINT_pow_checkBlength #1#2% +\def\XINT_pow_checkBsize #1#2% {% \ifnum #1>999999999 \expandafter\XINT_pow_BtooBig @@ -8093,7 +8824,7 @@ first place. \def\XINT_pow_pprod_compute #1\Z #2% {% \expandafter\XINT_pow_pprod_getnext\expandafter - {\romannumeral0\XINT_mulr_enter #2\W\X\Y\Z #1\W\X\Y\Z}% + {\romannumeral0\XINT_mulr_enter #2\Z\Z\Z\Z #1\W\W\W\W }% }% \def\XINT_pow_pprod_end\relax\XINT_pow_pprod_compute #1\Z #2% {% @@ -8210,7 +8941,7 @@ first place. \def\XINT_div_AisNegative_posrem #1% {% \expandafter \XINT_div_AisNegative_posrem_b \expandafter - {\romannumeral0\xintiopp{\xintiAdd {#1}{1}}}% + {\romannumeral0\xintiopp{\xintInc {#1}}}% }% \def\XINT_div_AisNegative_posrem_b #1#2#3% {% @@ -8249,7 +8980,8 @@ first place. \def\XINT_div_prepareB_BisOne #1#2#3#4#5{ {#5}{0}}% \def\XINT_div_prepareB_a #1% {% - \expandafter\XINT_div_prepareB_c\expandafter{\the\numexpr 4*((#1+1)/4)}{#1}% + \expandafter\XINT_div_prepareB_c\expandafter + {\the\numexpr \xint_c_iv*((#1+\xint_c_i)/\xint_c_iv)}{#1}% }% % \end{macrocode} % \lverb|& @@ -8421,11 +9153,11 @@ first place. % \begin{macrocode} \def\XINT_div_final_da #1% {% - \ifnum #1>9 + \ifnum #1>\xint_c_ix \expandafter\XINT_div_final_dP \else \xint_afterfi - {\ifnum #1<0 + {\ifnum #1<\xint_c_ \expandafter\XINT_div_final_dN \else \expandafter\XINT_div_final_db @@ -8434,7 +9166,7 @@ first place. }% \def\XINT_div_final_dN #1% {% - \expandafter\XINT_div_final_dP\the\numexpr #1-1\relax + \expandafter\XINT_div_final_dP\the\numexpr #1-\xint_c_i\relax }% \def\XINT_div_final_dP #1#2#3#4#5% q,A,Q,L,B (puis c) {% @@ -8452,8 +9184,9 @@ first place. }% \def\XINT_div_final_dc #1#2% {% - \ifnum\XINT_Sgn{#1}<0 - \xint_afterfi {\expandafter\XINT_div_final_dP\the\numexpr #2-1\relax}% + \ifnum\XINT_Sgn{#1}<\xint_c_ + \xint_afterfi + {\expandafter\XINT_div_final_dP\the\numexpr #2-\xint_c_i\relax}% \else \xint_afterfi {\XINT_div_final_e {#1}#2}% \fi }% @@ -8500,9 +9233,9 @@ first place. }% \def\XINT_div_body_d #1#2#3#4#5#6% {% - \ifnum #1 > 0 + \ifnum #1 >\xint_c_ \expandafter\XINT_div_body_d - \expandafter{\the\numexpr #1-4\expandafter }% + \expandafter{\the\numexpr #1-\xint_c_iv\expandafter }% \else \expandafter\XINT_div_body_e \fi @@ -8519,7 +9252,7 @@ first place. \def\XINT_div_body_f #1#2#3#4#5#6#7#8% {% \expandafter\XINT_div_body_gg - \the\numexpr (#1+(#5+1)/2)/(#5+1)+99999\relax + \the\numexpr (#1+(#5+\xint_c_i)/\xint_c_ii)/(#5+\xint_c_i)+99999\relax {#8}{#2}{#8}{#4}{#5}{#3}{#6}{#7}{#8}% }% % \end{macrocode} @@ -8561,7 +9294,7 @@ first place. % \begin{macrocode} \def\XINT_div_body_h #1#2#3#4#5#6#7#8#9\Z {% - \ifnum #1#2#3#4>0 + \ifnum #1#2#3#4>\xint_c_ \xint_afterfi{\XINT_div_body_i {#1#2#3#4#5#6#7#8}}% \else \expandafter\XINT_div_body_k @@ -8596,18 +9329,18 @@ first place. \def\XINT_div_body_l #1#2#3#4#5#6#7% {% \expandafter\XINT_div_body_m - \the\numexpr 100000000+#2\relax {#6}{#3}{#7}{#1#5}{#4}% + \the\numexpr \xint_c_x^viii+#2\relax {#6}{#3}{#7}{#1#5}{#4}% }% % \end{macrocode} % \lverb|& % chiffres de q, Q, K, L, A'=nouveau A, x, B, c| % \begin{macrocode} -\def\XINT_div_body_m #1#2#3#4#5#6#7#8#9% +\def\XINT_div_body_m 1#1#2#3#4#5#6#7#8% {% - \ifnum #2#3#4#5>0 - \xint_afterfi {\XINT_div_body_n {#9#8#7#6#5#4#3#2}}% + \ifnum #1#2#3#4>\xint_c_ + \xint_afterfi {\XINT_div_body_n {#8#7#6#5#4#3#2#1}}% \else - \xint_afterfi {\XINT_div_body_n {#9#8#7#6}}% + \xint_afterfi {\XINT_div_body_n {#8#7#6#5}}% \fi }% % \end{macrocode} @@ -8635,7 +9368,7 @@ first place. {% \ifnum #1 > #2 \xint_afterfi - {\ifnum #4#5#6#7 > 0 + {\ifnum #4#5#6#7 > \xint_c_ \expandafter\XINT_div_body_q \else \expandafter\XINT_div_body_repeatp @@ -8690,30 +9423,31 @@ first place. % \begin{macrocode} \def\XINT_div_sub_xpxp #1% {% - \expandafter \XINT_div_sub_xpxp_ \expandafter{#1}% + \expandafter \XINT_div_sub_xpxp_a \expandafter{#1}% }% -\def\XINT_div_sub_xpxp_ #1#2% +\def\XINT_div_sub_xpxp_a #1#2% {% - \expandafter\expandafter\expandafter\XINT_div_sub_xpxp__ + \expandafter\expandafter\expandafter\XINT_div_sub_xpxp_b #2\W\X\Y\Z #1\W\X\Y\Z }% -\def\XINT_div_sub_xpxp__ +\def\XINT_div_sub_xpxp_b {% \XINT_div_sub_A 1{}% }% \def\XINT_div_sub_A #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_div_sub_az\W + \xint_gob_til_W #3\xint_div_sub_az\W \XINT_div_sub_B #1{#3#4#5#6}{#2}% }% \def\XINT_div_sub_B #1#2#3#4\W\X\Y\Z #5#6#7#8% {% - \xint_gob_til_w #5\xint_div_sub_bz\W + \xint_gob_til_W #5\xint_div_sub_bz\W \XINT_div_sub_onestep #1#2{#8#7#6#5}{#3}#4\W\X\Y\Z }% \def\XINT_div_sub_onestep #1#2#3#4#5#6% {% - \expandafter\XINT_div_sub_backtoA\the\numexpr 11#5#4#3#2-#6+#1-1\relax.% + \expandafter\XINT_div_sub_backtoA + \the\numexpr 11#5#4#3#2-#6+#1-\xint_c_i\relax.% }% \def\XINT_div_sub_backtoA #1#2#3.#4% {% @@ -8740,12 +9474,12 @@ first place. }% \def\XINT_div_sub_C #1#2#3#4#5% {% - \xint_gob_til_w #2\xint_div_sub_cz\W + \xint_gob_til_W #2\xint_div_sub_cz\W \XINT_div_sub_AC_onestep {#5#4#3#2}{#1}% }% \def\XINT_div_sub_AC_onestep #1% {% - \expandafter\XINT_div_sub_backtoC\the\numexpr 11#1-1\relax.% + \expandafter\XINT_div_sub_backtoC\the\numexpr 11#1-\xint_c_i\relax.% }% \def\XINT_div_sub_backtoC #1#2#3.#4% {% @@ -8843,8 +9577,7 @@ first place. % \subsection{\csh{xintOdd}} % \lverb|& % ODDNESS. 1.05 defines \xintiOdd, so \xintOdd can be modified by -% xintfrac -% to parse through \xintNum.| +% xintfrac to parse through \xintNum.| % \begin{macrocode} \def\xintiOdd {\romannumeral0\xintiodd }% \def\xintiodd #1% @@ -8898,7 +9631,7 @@ first place. }% \def\XINT_dsr_b #1#2#3\Z {% - \xint_gob_til_w #2\xint_dsr_onedigit\W + \xint_gob_til_W #2\xint_dsr_onedigit\W \xint_minus #2\xint_dsr_onedigit-% \expandafter\XINT_dsr_removew \romannumeral0\XINT_rev {#2#3}% @@ -9069,7 +9802,7 @@ first place. }% \def\XINT_dsx_AisNeg_checkiffirstempty #1% {% - \xint_gob_til_z #1\XINT_dsx_AisNeg_finish_zero\Z + \xint_gob_til_Z #1\XINT_dsx_AisNeg_finish_zero\Z \XINT_dsx_AisNeg_finish_notzero #1% }% \def\XINT_dsx_AisNeg_finish_zero\Z @@ -9184,7 +9917,7 @@ first place. \def\XINT_split_fromleft_eight #1#2#3#4#5#6#7#8#9{#9{#1#2#3#4#5#6#7#8#9}}% \def\XINT_split_fromleft_loop_perhaps #1#2% {% - \xint_gob_til_w #2\XINT_split_fromleft_toofar\W + \xint_gob_til_W #2\XINT_split_fromleft_toofar\W \XINT_split_fromleft_loop {#1}% }% \def\XINT_split_fromleft_toofar\W\XINT_split_fromleft_loop #1#2#3\Z @@ -9216,7 +9949,7 @@ first place. {\XINT_split_fromleft_checkiftoofar #8{#1#2#3#4#5#6#7#8}}% \def\XINT_split_fromleft_checkiftoofar #1#2#3\W #4\Z {% - \xint_gob_til_w #1\XINT_split_fromleft_wenttoofar\W + \xint_gob_til_W #1\XINT_split_fromleft_wenttoofar\W \space {#2}{#3}% }% \def\XINT_split_fromleft_wenttoofar\W\space #1% @@ -9242,7 +9975,7 @@ first place. \def\XINT_split_fromright_eight #1#2#3#4#5#6#7#8#9{#9{#9#8#7#6#5#4#3#2#1}}% \def\XINT_split_fromright_loop_perhaps #1#2% {% - \xint_gob_til_w #2\XINT_split_fromright_toofar\W + \xint_gob_til_W #2\XINT_split_fromright_toofar\W \XINT_split_fromright_loop {#1}% }% \def\XINT_split_fromright_toofar\W\XINT_split_fromright_loop #1#2#3\Z { {}}% @@ -9273,17 +10006,1171 @@ first place. {\XINT_split_fromright_checkiftoofar #8{#8#7#6#5#4#3#2#1}}% \def\XINT_split_fromright_checkiftoofar #1% {% - \xint_gob_til_w #1\XINT_split_fromright_wenttoofar\W + \xint_gob_til_W #1\XINT_split_fromright_wenttoofar\W \XINT_split_fromright_endsplit_ }% \def\XINT_split_fromright_wenttoofar\W\XINT_split_fromright_endsplit_ #1\Z #2% { {}{#2}}% +% \end{macrocode} +% \subsection{\csh{xintDouble}} +% \lverb!v1.08! +% \begin{macrocode} +\def\xintDouble {\romannumeral0\xintdouble }% +\def\xintdouble #1% +{% + \expandafter\XINT_dbl\romannumeral-`0#1% + \R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W +}% +\def\XINT_dbl #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_dbl_zero + 0#1\dummy \XINT_dbl_neg + 0-\dummy {\XINT_dbl_pos #1}% + \krof +}% +\def\XINT_dbl_zero #1\Z \W\W\W\W\W\W\W { 0}% +\def\XINT_dbl_neg + {\expandafter\xint_minus_andstop\romannumeral0\XINT_dbl_pos }% +\def\XINT_dbl_pos +{% + \expandafter\XINT_dbl_a \expandafter{\expandafter}\expandafter 0% + \romannumeral0\XINT_SQ {}% +}% +\def\XINT_dbl_a #1#2#3#4#5#6#7#8#9% +{% + \xint_gob_til_W #9\XINT_dbl_end_a\W + \expandafter\XINT_dbl_b + \the\numexpr \xint_c_x^viii+#2+\xint_c_ii*#9#8#7#6#5#4#3\relax {#1}% +}% +\def\XINT_dbl_b 1#1#2#3#4#5#6#7#8#9% +{% + \XINT_dbl_a {#2#3#4#5#6#7#8#9}{#1}% +}% +\def\XINT_dbl_end_a #1+#2+#3\relax #4% +{% + \expandafter\XINT_dbl_end_b #2#4% +}% +\def\XINT_dbl_end_b #1#2#3#4#5#6#7#8% +{% + \expandafter\space\the\numexpr #1#2#3#4#5#6#7#8\relax +}% +% \end{macrocode} +% \subsection{\csh{xintHalf}} +% \lverb!v1.08! +% \begin{macrocode} +\def\xintHalf {\romannumeral0\xinthalf }% +\def\xinthalf #1% +{% + \expandafter\XINT_half\romannumeral-`0#1% + \R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W +}% +\def\XINT_half #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_half_zero + 0#1\dummy \XINT_half_neg + 0-\dummy {\XINT_half_pos #1}% + \krof +}% +\def\XINT_half_zero #1\Z \W\W\W\W\W\W\W { 0}% +\def\XINT_half_neg {\expandafter\XINT_opp\romannumeral0\XINT_half_pos }% +\def\XINT_half_pos {\expandafter\XINT_half_a\romannumeral0\XINT_SQ {}}% +\def\XINT_half_a #1#2#3#4#5#6#7#8% +{% + \xint_gob_til_W #8\XINT_half_dont\W + \expandafter\XINT_half_b + \the\numexpr \xint_c_x^viii+\xint_c_v*#7#6#5#4#3#2#1\relax #8% +}% +\def\XINT_half_dont\W\expandafter\XINT_half_b + \the\numexpr \xint_c_x^viii+\xint_c_v*#1#2#3#4#5#6#7\relax \W\W\W\W\W\W\W +{% + \expandafter\space + \the\numexpr (#1#2#3#4#5#6#7+\xint_c_i)/\xint_c_ii-\xint_c_i \relax +}% +\def\XINT_half_b 1#1#2#3#4#5#6#7#8% +{% + \XINT_half_c {#2#3#4#5#6#7}{#1}% +}% +\def\XINT_half_c #1#2#3#4#5#6#7#8#9% +{% + \xint_gob_til_W #3\XINT_half_end_a #2\W + \expandafter\XINT_half_d + \the\numexpr \xint_c_x^viii+\xint_c_v*#9#8#7#6#5#4#3+#2\relax {#1}% +}% +\def\XINT_half_d 1#1#2#3#4#5#6#7#8#9% +{% + \XINT_half_c {#2#3#4#5#6#7#8#9}{#1}% +}% +\def\XINT_half_end_a #1\W #2\relax #3% +{% + \xint_gob_til_zero #1\XINT_half_end_b 0\space #1#3% +}% +\def\XINT_half_end_b 0\space 0#1#2#3#4#5#6#7% +{% + \expandafter\space\the\numexpr #1#2#3#4#5#6#7\relax +}% +% \end{macrocode} +% \subsection{\csh{xintDec}} +% \lverb!v1.08! +% \begin{macrocode} +\def\xintDec {\romannumeral0\xintdec }% +\def\xintdec #1% +{% + \expandafter\XINT_dec\romannumeral-`0#1% + \R\R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W\W +}% +\def\XINT_dec #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_dec_zero + 0#1\dummy \XINT_dec_neg + 0-\dummy {\XINT_dec_pos #1}% + \krof +}% +\def\XINT_dec_zero #1\W\W\W\W\W\W\W\W { -1}% +\def\XINT_dec_neg + {\expandafter\xint_minus_andstop\romannumeral0\XINT_inc_pos }% +\def\XINT_dec_pos +{% + \expandafter\XINT_dec_a \expandafter{\expandafter}% + \romannumeral0\XINT_OQ {}% +}% +\def\XINT_dec_a #1#2#3#4#5#6#7#8#9% +{% + \expandafter\XINT_dec_b + \the\numexpr 11#9#8#7#6#5#4#3#2-\xint_c_i\relax {#1}% +}% +\def\XINT_dec_b 1#1% +{% + \xint_gob_til_one #1\XINT_dec_A 1\XINT_dec_c +}% +\def\XINT_dec_c #1#2#3#4#5#6#7#8#9{\XINT_dec_a {#1#2#3#4#5#6#7#8#9}}% +\def\XINT_dec_A 1\XINT_dec_c #1#2#3#4#5#6#7#8#9% + {\XINT_dec_B {#1#2#3#4#5#6#7#8#9}}% +\def\XINT_dec_B #1#2\W\W\W\W\W\W\W\W +{% + \expandafter\XINT_dec_cleanup + \romannumeral0\XINT_rord_main {}#2% + \xint_relax + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_relax + #1% +}% +\def\XINT_dec_cleanup #1#2#3#4#5#6#7#8% +{\expandafter\space\the\numexpr #1#2#3#4#5#6#7#8\relax }% +% \end{macrocode} +% \subsection{\csh{xintInc}} +% \lverb!v1.08! +% \begin{macrocode} +\def\xintInc {\romannumeral0\xintinc }% +\def\xintinc #1% +{% + \expandafter\XINT_inc\romannumeral-`0#1% + \R\R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W\W +}% +\def\XINT_inc #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_inc_zero + 0#1\dummy \XINT_inc_neg + 0-\dummy {\XINT_inc_pos #1}% + \krof +}% +\def\XINT_inc_zero #1\W\W\W\W\W\W\W\W { 1}% +\def\XINT_inc_neg {\expandafter\XINT_opp\romannumeral0\XINT_dec_pos }% +\def\XINT_inc_pos +{% + \expandafter\XINT_inc_a \expandafter{\expandafter}% + \romannumeral0\XINT_OQ {}% +}% +\def\XINT_inc_a #1#2#3#4#5#6#7#8#9% +{% + \xint_gob_til_W #9\XINT_inc_end\W + \expandafter\XINT_inc_b + \the\numexpr 10#9#8#7#6#5#4#3#2+\xint_c_i\relax {#1}% +}% +\def\XINT_inc_b 1#1% +{% + \xint_gob_til_zero #1\XINT_inc_A 0\XINT_inc_c +}% +\def\XINT_inc_c #1#2#3#4#5#6#7#8#9{\XINT_inc_a {#1#2#3#4#5#6#7#8#9}}% +\def\XINT_inc_A 0\XINT_inc_c #1#2#3#4#5#6#7#8#9% + {\XINT_dec_B {#1#2#3#4#5#6#7#8#9}}% +\def\XINT_inc_end\W #1\relax #2{ 1#2}% +% \end{macrocode} +% \subsection{\csh{xintiSqrt}, \csh{xintiSquareRoot}} +% \lverb!v1.08! +% \begin{macrocode} +\def\XINT_dsx_addzerosnofuss #1{\XINT_dsx_zeroloop {#1}{}\Z }% +\def\xintiSqrt {\romannumeral0\xintisqrt }% +\def\xintisqrt + {\expandafter\XINT_sqrt_post\romannumeral0\xintisquareroot }% +\def\XINT_sqrt_post #1#2{\XINT_dec_pos #1\R\R\R\R\R\R\R\R\Z + \W\W\W\W\W\W\W\W }% +\def\xintiSquareRoot {\romannumeral0\xintisquareroot }% +\def\xintisquareroot #1% + {\expandafter\XINT_sqrt_checkin\romannumeral-`0#1\Z}% +\def\XINT_sqrt_checkin #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_sqrt_iszero + 0#1\dummy \XINT_sqrt_isneg + 0-\dummy {\XINT_sqrt #1}% + \krof +}% +\def\XINT_sqrt_iszero #1\Z { 0}% +\def\XINT_sqrt_isneg #1\Z {\xintError:RootOfNegative\space 0}% +\def\XINT_sqrt #1\Z +{% + \expandafter\XINT_sqrt_start\expandafter + {\romannumeral0\XINT_length {#1}}{#1}% +}% +\def\XINT_sqrt_start #1% +{% + \ifnum #1<\xint_c_x + \expandafter\XINT_sqrt_small_a + \else + \expandafter\XINT_sqrt_big_a + \fi + {#1}% +}% +\def\XINT_sqrt_small_a #1{\XINT_sqrt_a {#1}\XINT_sqrt_small_d }% +\def\XINT_sqrt_big_a #1{\XINT_sqrt_a {#1}\XINT_sqrt_big_d }% +\def\XINT_sqrt_a #1% +{% + \ifodd #1 + \expandafter\XINT_sqrt_bB + \else + \expandafter\XINT_sqrt_bA + \fi + {#1}% +}% +\def\XINT_sqrt_bA #1#2#3% +{% + \XINT_sqrt_bA_b #3\Z #2{#1}{#3}% +}% +\def\XINT_sqrt_bA_b #1#2#3\Z +{% + \XINT_sqrt_c {#1#2}% +}% +\def\XINT_sqrt_bB #1#2#3% +{% + \XINT_sqrt_bB_b #3\Z #2{#1}{#3}% +}% +\def\XINT_sqrt_bB_b #1#2\Z +{% + \XINT_sqrt_c #1% +}% +\def\XINT_sqrt_c #1#2% +{% + \expandafter #2% + \ifcase #1 + \or 2\or 2\or 2\or 3\or 3\or 3\or 3\or 3\or %3+5 + 4\or 4\or 4\or 4\or 4\or 4\or 4\or %+7 + 5\or 5\or 5\or 5\or 5\or 5\or 5\or 5\or 5\or %+9 + 6\or 6\or 6\or 6\or 6\or 6\or 6\or 6\or 6\or 6\or 6\or %+11 + 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or %+13 + 8\or 8\or 8\or 8\or 8\or 8\or 8\or + 8\or 8\or 8\or 8\or 8\or 8\or 8\or 8\or %+15 + 9\or 9\or 9\or 9\or 9\or 9\or 9\or 9\or + 9\or 9\or 9\or 9\or 9\or 9\or 9\or 9\or 9\or %+17 + 10\or 10\or 10\or 10\or 10\or 10\or 10\or 10\or 10\or + 10\or 10\or 10\or 10\or 10\or 10\or 10\or 10\or 10\or 10\or\fi %+19 +}% +\def\XINT_sqrt_small_d #1\or #2\fi #3% +{% + \fi + \expandafter\XINT_sqrt_small_de + \ifcase \numexpr #3/\xint_c_ii-\xint_c_i\relax + {}% + \or + 0% + \or + {00}% + \or + {000}% + \or + {0000}% + \or + \fi {#1}% +}% +\def\XINT_sqrt_small_de #1\or #2\fi #3% +{% + \fi\XINT_sqrt_small_e {#3#1}% +}% +\def\XINT_sqrt_small_e #1#2% +{% + \expandafter\XINT_sqrt_small_f\expandafter {\the\numexpr #1*#1-#2}{#1}% +}% +\def\XINT_sqrt_small_f #1#2% +{% + \expandafter\XINT_sqrt_small_g\expandafter + {\the\numexpr ((#1+#2)/(\xint_c_ii*#2))-\xint_c_i}{#1}{#2}% +}% +\def\XINT_sqrt_small_g #1% +{% + \ifnum #1>\xint_c_ + \expandafter\XINT_sqrt_small_h + \else + \expandafter\XINT_sqrt_small_end + \fi + {#1}% +}% +\def\XINT_sqrt_small_h #1#2#3% +{% + \expandafter\XINT_sqrt_small_f\expandafter + {\the\numexpr #2-\xint_c_ii*#1*#3+#1*#1\expandafter}\expandafter + {\the\numexpr #3-#1}% +}% +\def\XINT_sqrt_small_end #1#2#3{ {#3}{#2}}% +\def\XINT_sqrt_big_d #1\or #2\fi #3% +{% + \fi + \ifodd #3 + \xint_afterfi{\expandafter\XINT_sqrt_big_eB}% + \else + \xint_afterfi{\expandafter\XINT_sqrt_big_eA}% + \fi + \expandafter{\the\numexpr #3/\xint_c_ii }{#1}% +}% +\def\XINT_sqrt_big_eA #1#2#3% +{% + \XINT_sqrt_big_eA_a #3\Z {#2}{#1}{#3}% +}% +\def\XINT_sqrt_big_eA_a #1#2#3#4#5#6#7#8#9\Z +{% + \XINT_sqrt_big_eA_b {#1#2#3#4#5#6#7#8}% +}% +\def\XINT_sqrt_big_eA_b #1#2% +{% + \expandafter\XINT_sqrt_big_f + \romannumeral0\XINT_sqrt_small_e {#2000}{#1}{#1}% +}% +\def\XINT_sqrt_big_eB #1#2#3% +{% + \XINT_sqrt_big_eB_a #3\Z {#2}{#1}{#3}% +}% +\def\XINT_sqrt_big_eB_a #1#2#3#4#5#6#7#8#9% +{% + \XINT_sqrt_big_eB_b {#1#2#3#4#5#6#7#8#9}% +}% +\def\XINT_sqrt_big_eB_b #1#2\Z #3% +{% + \expandafter\XINT_sqrt_big_f + \romannumeral0\XINT_sqrt_small_e {#30000}{#1}{#1}% +}% +\def\XINT_sqrt_big_f #1#2#3#4% +{% + \expandafter\XINT_sqrt_big_f_a\expandafter + {\the\numexpr #2+#3\expandafter}\expandafter + {\romannumeral-`0\XINT_dsx_addzerosnofuss + {\numexpr #4-\xint_c_iv\relax}{#1}}{#4}% +}% +\def\XINT_sqrt_big_f_a #1#2#3#4% +{% + \expandafter\XINT_sqrt_big_g\expandafter + {\romannumeral0\xintisub + {\XINT_dsx_addzerosnofuss + {\numexpr \xint_c_ii*#3-\xint_c_viii\relax}{#1}}{#4}}% + {#2}{#3}% +}% +\def\XINT_sqrt_big_g #1#2% +{% + \expandafter\XINT_sqrt_big_j + \romannumeral0\xintidivision{#1} + {\romannumeral0\XINT_dbl_pos #2\R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W }{#2}% +}% +\def\XINT_sqrt_big_j #1% +{% + \ifcase\XINT_Sgn {#1} + \expandafter \XINT_sqrt_big_end + \or \expandafter \XINT_sqrt_big_k + \fi {#1}% +}% +\def\XINT_sqrt_big_k #1#2#3% +{% + \expandafter\XINT_sqrt_big_l\expandafter + {\romannumeral0\xintisub {#3}{#1}}% + {\romannumeral0\xintiadd {#2}{\xintiSqr {#1}}}% +}% +\def\XINT_sqrt_big_l #1#2% +{% + \expandafter\XINT_sqrt_big_g\expandafter + {#2}{#1}% +}% +\def\XINT_sqrt_big_end #1#2#3#4{ {#3}{#2}}% \XINT_restorecatcodes_endinput% % \end{macrocode} %\catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11 %\let</xint>\relax -%\def<*xintgcd>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12 } +%\def<*xintbinhex>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12 } %</xint> +%<*xintbinhex> +% \section{Package \xintbinhexname implementation} +% +% The commenting is currently (\docdate) very sparse. +% +% \localtableofcontents +% \subsection{Catcodes, \protect\eTeX{} and reload detection} +% +% The code for reload detection is copied from \textsc{Heiko +% Oberdiek}'s packages, and adapted here to check for previous +% loading of the master \xintname package. +% +% The method for catcodes is slightly different, but still +% directly inspired by these packages. +% +% \begin{macrocode} +\begingroup\catcode61\catcode48\catcode32=10\relax% + \catcode13=5 % ^^M + \endlinechar=13 % + \catcode123=1 % { + \catcode125=2 % } + \catcode64=11 % @ + \catcode35=6 % # + \catcode44=12 % , + \catcode45=12 % - + \catcode46=12 % . + \catcode58=12 % : + \def\space { }% + \let\z\endgroup + \expandafter\let\expandafter\x\csname ver@xintbinhex.sty\endcsname + \expandafter\let\expandafter\w\csname ver@xint.sty\endcsname + \expandafter + \ifx\csname PackageInfo\endcsname\relax + \def\y#1#2{\immediate\write-1{Package #1 Info: #2.}}% + \else + \def\y#1#2{\PackageInfo{#1}{#2}}% + \fi + \expandafter + \ifx\csname numexpr\endcsname\relax + \y{xintbinhex}{\numexpr not available, aborting input}% + \aftergroup\endinput + \else + \ifx\x\relax % plain-TeX, first loading of xintbinhex.sty + \ifx\w\relax % but xint.sty not yet loaded. + \y{xintbinhex}{Package xint is required}% + \y{xintbinhex}{Will try \string\input\space xint.sty}% + \def\z{\endgroup\input xint.sty\relax}% + \fi + \else + \def\empty {}% + \ifx\x\empty % LaTeX, first loading, + % variable is initialized, but \ProvidesPackage not yet seen + \ifx\w\relax % xint.sty not yet loaded. + \y{xintbinhex}{Package xint is required}% + \y{xintbinhex}{Will try \string\RequirePackage{xint}}% + \def\z{\endgroup\RequirePackage{xint}}% + \fi + \else + \y{xintbinhex}{I was already loaded, aborting input}% + \aftergroup\endinput + \fi + \fi + \fi +\z% +% \end{macrocode} +% \subsection{Confirmation of \xintname loading} +% \begin{macrocode} +\begingroup\catcode61\catcode48\catcode32=10\relax% + \catcode13=5 % ^^M + \endlinechar=13 % + \catcode123=1 % { + \catcode125=2 % } + \catcode64=11 % @ + \catcode35=6 % # + \catcode44=12 % , + \catcode45=12 % - + \catcode46=12 % . + \catcode58=12 % : + \expandafter + \ifx\csname PackageInfo\endcsname\relax + \def\y#1#2{\immediate\write-1{Package #1 Info: #2.}}% + \else + \def\y#1#2{\PackageInfo{#1}{#2}}% + \fi + \def\empty {}% + \expandafter\let\expandafter\w\csname ver@xint.sty\endcsname + \ifx\w\relax % Plain TeX, user gave a file name at the prompt + \y{xintbinhex}{Loading of package xint failed, aborting input}% + \aftergroup\endinput + \fi + \ifx\w\empty % LaTeX, user gave a file name at the prompt + \y{xintbinhex}{Loading of package xint failed, aborting input}% + \aftergroup\endinput + \fi +\endgroup% +% \end{macrocode} +% \subsection{Catcodes} +% +% Perhaps catcodes have changed after the loading of \xintname +% and prior to the current loading of \xintbinhexname, so we can not employ +% the |\XINT_restorecatcodes_endinput| in this style file. But +% there is no problem using |\XINT_setcatcodes|. +% +% \begin{macrocode} +\begingroup\catcode61\catcode48\catcode32=10\relax% + \catcode13=5 % ^^M + \endlinechar=13 % + \catcode123=1 % { + \catcode125=2 % } + \catcode95=11 % _ + \def\x + {% + \endgroup + \edef\XINT_binhex_restorecatcodes_endinput + {% + \catcode94=\the\catcode94 % ^ + \catcode96=\the\catcode96 % ` + \catcode47=\the\catcode47 % / + \catcode41=\the\catcode41 % ) + \catcode40=\the\catcode40 % ( + \catcode42=\the\catcode42 % * + \catcode43=\the\catcode43 % + + \catcode62=\the\catcode62 % > + \catcode60=\the\catcode60 % < + \catcode58=\the\catcode58 % : + \catcode46=\the\catcode46 % . + \catcode45=\the\catcode45 % - + \catcode44=\the\catcode44 % , + \catcode35=\the\catcode35 % # + \catcode95=\the\catcode95 % _ + \catcode125=\the\catcode125 % } + \catcode123=\the\catcode123 % { + \endlinechar=\the\endlinechar + \catcode13=\the\catcode13 % ^^M + \catcode32=\the\catcode32 % + \catcode61=\the\catcode61\relax % = + \noexpand\endinput + }% + \XINT_setcatcodes % defined in xint.sty + }% +\x +% \end{macrocode} +% \subsection{Package identification} +% \begin{macrocode} +\begingroup + \catcode64=11 % @ + \catcode91=12 % [ + \catcode93=12 % ] + \catcode58=12 % : + \expandafter\ifx\csname ProvidesPackage\endcsname\relax + \def\x#1#2#3[#4]{\endgroup + \immediate\write-1{Package: #3 #4}% + \xdef#1{#4}% + }% + \else + \def\x#1#2[#3]{\endgroup + #2[{#3}]% + \ifx#1\@undefined + \xdef#1{#3}% + \fi + \ifx#1\relax + \xdef#1{#3}% + \fi + }% + \fi +\expandafter\x\csname ver@xintbinhex.sty\endcsname +\ProvidesPackage{xintbinhex}% + [2013/06/14 v1.08b Expandable binary and hexadecimal conversions (jfB)]% +% \end{macrocode} +% \subsection{Constants, etc...} +% \lverb!v1.08! +% \begin{macrocode} +\chardef\xint_c_xvi 16 +\chardef\xint_c_ii^v 32 +\chardef\xint_c_ii^vi 64 +\chardef\xint_c_ii^vii 128 +\mathchardef\xint_c_ii^viii 256 +\mathchardef\xint_c_ii^xii 4096 +\newcount\xint_c_ii^xv \xint_c_ii^xv 32768 +\newcount\xint_c_ii^xvi \xint_c_ii^xvi 65536 +\newcount\xint_c_x^v \xint_c_x^v 100000 +\newcount\xint_c_x^ix \xint_c_x^ix 1000000000 +\def\XINT_tmp_def #1{% + \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}}% +\xintApplyUnbraced\XINT_tmp_def + {{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}}% +\def\XINT_tmp_def #1{% + \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}}% +\xintApplyUnbraced\XINT_tmp_def + {{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}}% +\let\XINT_tmp_def\empty +\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_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}% +\expandafter\def\csname XINT_shtb_0\endcsname {0000}% +\expandafter\def\csname XINT_shtb_1\endcsname {0001}% +\expandafter\def\csname XINT_shtb_2\endcsname {0010}% +\expandafter\def\csname XINT_shtb_3\endcsname {0011}% +\expandafter\def\csname XINT_shtb_4\endcsname {0100}% +\expandafter\def\csname XINT_shtb_5\endcsname {0101}% +\expandafter\def\csname XINT_shtb_6\endcsname {0110}% +\expandafter\def\csname XINT_shtb_7\endcsname {0111}% +\expandafter\def\csname XINT_shtb_8\endcsname {1000}% +\expandafter\def\csname XINT_shtb_9\endcsname {1001}% +\def\XINT_shtb_A {1010}% +\def\XINT_shtb_B {1011}% +\def\XINT_shtb_C {1100}% +\def\XINT_shtb_D {1101}% +\def\XINT_shtb_E {1110}% +\def\XINT_shtb_F {1111}% +\def\XINT_shtb_G {}% +\def\XINT_smallhex #1% +{% + \expandafter\XINT_smallhex_a\expandafter + {\the\numexpr (#1+\xint_c_viii)/\xint_c_xvi-\xint_c_i}{#1}% +}% +\def\XINT_smallhex_a #1#2% +{% + \csname XINT_sdth_#1\expandafter\expandafter\expandafter\endcsname + \csname XINT_sdth_\the\numexpr #2-\xint_c_xvi*#1\endcsname +}% +\def\XINT_smallbin #1% +{% + \expandafter\XINT_smallbin_a\expandafter + {\the\numexpr (#1+\xint_c_viii)/\xint_c_xvi-\xint_c_i}{#1}% +}% +\def\XINT_smallbin_a #1#2% +{% + \csname XINT_sdtb_#1\expandafter\expandafter\expandafter\endcsname + \csname XINT_sdtb_\the\numexpr #2-\xint_c_xvi*#1\endcsname +}% +% \end{macrocode} +% \subsection{\csh{xintDecToHex}, \csh{xintDecToBin}} +% \lverb!v1.08! +% \begin{macrocode} +\def\xintDecToHex {\romannumeral0\xintdectohex }% +\def\xintdectohex #1% + {\expandafter\XINT_dth_checkin\romannumeral-`0#1\W\W\W\W \T}% +\def\XINT_dth_checkin #1% +{% + \xint_UDsignfork + #1\dummy \XINT_dth_N + -\dummy {\XINT_dth_P #1}% + \krof +}% +\def\XINT_dth_N {\expandafter\xint_minus_andstop\romannumeral0\XINT_dth_P }% +\def\XINT_dth_P {\expandafter\XINT_dth_III\romannumeral-`0\XINT_dtbh_I {0.}}% +\def\xintDecToBin {\romannumeral0\xintdectobin }% +\def\xintdectobin #1% + {\expandafter\XINT_dtb_checkin\romannumeral-`0#1\W\W\W\W \T }% +\def\XINT_dtb_checkin #1% +{% + \xint_UDsignfork + #1\dummy \XINT_dtb_N + -\dummy {\XINT_dtb_P #1}% + \krof +}% +\def\XINT_dtb_N {\expandafter\xint_minus_andstop\romannumeral0\XINT_dtb_P }% +\def\XINT_dtb_P {\expandafter\XINT_dtb_III\romannumeral-`0\XINT_dtbh_I {0.}}% +\def\XINT_dtbh_I #1#2#3#4#5% +{% + \xint_gob_til_W #5\XINT_dtbh_II_a\W\XINT_dtbh_I_a {}{#2#3#4#5}#1\Z.% +}% +\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% +{% + \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% +}% +\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.% +{% + \xint_gob_til_Z #3\XINT_dtbh_I_z\Z + \expandafter\XINT_dtbh_I_b\the\numexpr #2+#30000.{#1}% +}% +\def\XINT_dtbh_I_b #1.% +{% + \expandafter\XINT_dtbh_I_c\the\numexpr + (#1+\xint_c_ii^xv)/\xint_c_ii^xvi-\xint_c_i.#1.% +}% +\def\XINT_dtbh_I_c #1.#2.% +{% + \expandafter\XINT_dtbh_I_d\expandafter + {\the\numexpr #2-\xint_c_ii^xvi*#1}{#1}% +}% +\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.% +{% + \ifnum #1=\xint_c_ \expandafter\XINT_dtbh_I_end_zb\fi + \XINT_dtbh_I_end_za {#1}% +}% +\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.% +{% + \xint_gob_til_Z #4\XINT_dtbh_II_z\Z + \expandafter\XINT_dtbh_II_e\the\numexpr #2+#4#3.{#1}{#3}% +}% +\def\XINT_dtbh_II_e #1.% +{% + \expandafter\XINT_dtbh_II_f\the\numexpr + (#1+\xint_c_ii^xv)/\xint_c_ii^xvi-\xint_c_i.#1.% +}% +\def\XINT_dtbh_II_f #1.#2.% +{% + \expandafter\XINT_dtbh_II_g\expandafter + {\the\numexpr #2-\xint_c_ii^xvi*#1}{#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.% +{% + \ifnum #1=\xint_c_ \expandafter\XINT_dtbh_II_end_zb\fi + \XINT_dtbh_II_end_za {#1}% +}% +\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.% +{% + \xint_gob_til_Z #2\XINT_dth_end\Z + \expandafter\XINT_dth_III\expandafter + {\romannumeral-`0\XINT_dth_small #2.#1}% +}% +\def\XINT_dth_small #1.% +{% + \expandafter\XINT_smallhex\expandafter + {\the\numexpr (#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i\expandafter}% + \romannumeral-`0\expandafter\XINT_smallhex\expandafter + {\the\numexpr + #1-((#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i)*\xint_c_ii^viii}% +}% +\def\XINT_dth_end\Z\expandafter\XINT_dth_III\expandafter #1#2\T +{% + \XINT_dth_end_b #1% +}% +\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% +{% + \xint_gob_til_zero #1\XINT_dth_end_e 0\space #1% +}% +\def\XINT_dth_end_e 0\space 0#1% +{% + \xint_gob_til_zero #1\XINT_dth_end_f 0\space #1% +}% +\def\XINT_dth_end_f 0\space 0{ }% +\def\XINT_dtb_III #1#2.% +{% + \xint_gob_til_Z #2\XINT_dtb_end\Z + \expandafter\XINT_dtb_III\expandafter + {\romannumeral-`0\XINT_dtb_small #2.#1}% +}% +\def\XINT_dtb_small #1.% +{% + \expandafter\XINT_smallbin\expandafter + {\the\numexpr (#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i\expandafter}% + \romannumeral-`0\expandafter\XINT_smallbin\expandafter + {\the\numexpr + #1-((#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i)*\xint_c_ii^viii}% +}% +\def\XINT_dtb_end\Z\expandafter\XINT_dtb_III\expandafter #1#2\T +{% + \XINT_dtb_end_b #1% +}% +\def\XINT_dtb_end_b #1.{\XINT_dtb_end_c }% +\def\XINT_dtb_end_c #1#2#3#4#5#6#7#8% +{% + \expandafter\XINT_dtb_end_d\the\numexpr #1#2#3#4#5#6#7#8\relax +}% +\def\XINT_dtb_end_d #1#2#3#4#5#6#7#8#9% +{% + \expandafter\space\the\numexpr #1#2#3#4#5#6#7#8#9\relax +}% +% \end{macrocode} +% \subsection{\csh{xintHexToDec}} +% \lverb!v1.08! +% \begin{macrocode} +\def\xintHexToDec {\romannumeral0\xinthextodec }% +\def\xinthextodec #1% + {\expandafter\XINT_htd_checkin\romannumeral-`0#1\W\W\W\W \T }% +\def\XINT_htd_checkin #1% +{% + \xint_UDsignfork + #1\dummy \XINT_htd_neg + -\dummy {\XINT_htd_I {0000}#1}% + \krof +}% +\def\XINT_htd_neg {\expandafter\xint_minus_andstop + \romannumeral0\XINT_htd_I {0000}}% +\def\XINT_htd_I #1#2#3#4#5% +{% + \xint_gob_til_W #5\XINT_htd_II_a\W + \XINT_htd_I_a {}{"#2#3#4#5}#1\Z\Z\Z\Z +}% +\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% +{% + \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% +}% +\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 +{% + \expandafter\xint_cleanupzeros_andstop + \romannumeral0\XINT_rord_main {}#1% + \xint_relax + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_relax +}% +\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% +{% + \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}% +}% +\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 +{% + \expandafter\XINT_htd_I_end_b\the\numexpr \xint_c_x^v+#1\relax +}% +\def\XINT_htd_I_end_b 1#1#2#3#4#5% +{% + \xint_gob_til_zero #1\XINT_htd_I_end_bz0% + \XINT_htd_I_end_c #1#2#3#4#5% +}% +\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% +{% + \xint_gob_til_zeros_iv #1#2#3#4\XINT_htd_I_end_bzz 0000% + \XINT_htd_I_end_D {#4#3#2#1}% +}% +\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% +{% + \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}% +}% +\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 +{% + \XINT_htd_II_end_b #1#3% +}% +\def\XINT_htd_II_end_b #1#2#3#4#5#6#7#8% +{% + \expandafter\space\the\numexpr #1#2#3#4#5#6#7#8\relax +}% +% \end{macrocode} +% \subsection{\csh{xintBinToDec}} +% \lverb!v1.08! +% \begin{macrocode} +\def\xintBinToDec {\romannumeral0\xintbintodec }% +\def\xintbintodec #1{\expandafter\XINT_btd_checkin + \romannumeral-`0#1\W\W\W\W\W\W\W\W \T }% +\def\XINT_btd_checkin #1% +{% + \xint_UDsignfork + #1\dummy \XINT_btd_neg + -\dummy {\XINT_btd_I {000000}#1}% + \krof +}% +\def\XINT_btd_neg {\expandafter\xint_minus_andstop + \romannumeral0\XINT_btd_I {000000}}% +\def\XINT_btd_I #1#2#3#4#5#6#7#8#9% +{% + \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 +}% +\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% +{% + \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% +}% +\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 +{% + \expandafter\XINT_btd_II_c_end + \romannumeral0\XINT_rord_main {}#2% + \xint_relax + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_relax +}% +\def\XINT_btd_II_c_end #1#2#3#4#5#6% +{% + \expandafter\space\the\numexpr #1#2#3#4#5#6\relax +}% +\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 +{% + \XINT_btd_II_d {}{\csname XINT_sbtd_#2#3#4#5\endcsname*\xint_c_ii+% + #6}{\xint_c_ii^v }% +}% +\def\XINT_btd_II_cvi #1\XINT_btd_II_cvii #2#3#4#5#6#7\W\W +{% + \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 }% +}% +\def\XINT_btd_II_cvii #1#2#3#4#5#6#7\W +{% + \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 }% +}% +\def\XINT_btd_II_d #1#2#3#4#5#6#7#8#9% +{% + \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}% +}% +\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 +{% + \XINT_btd_II_end_b #1#3% +}% +\def\XINT_btd_II_end_b #1#2#3#4#5#6#7#8#9% +{% + \expandafter\space\the\numexpr #1#2#3#4#5#6#7#8#9\relax +}% +\def\XINT_btd_I_a #1#2#3#4#5#6#7#8% +{% + \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}% +}% +\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 +{% + \expandafter\XINT_btd_I_end_b\the\numexpr 1000+#1\relax +}% +\def\XINT_btd_I_end_b 1#1#2#3% +{% + \xint_gob_til_zeros_iii #1#2#3\XINT_btd_I_end_bz 000% + \XINT_btd_I_end_c #1#2#3% +}% +\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!v1.08! +% \begin{macrocode} +\def\xintBinToHex {\romannumeral0\xintbintohex }% +\def\xintbintohex #1% +{% + \expandafter\XINT_bth_checkin + \romannumeral0\expandafter\XINT_num_loop + \romannumeral-`0#1\xint_relax\xint_relax + \xint_relax\xint_relax + \xint_relax\xint_relax\xint_relax\xint_relax\Z + \R\R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W\W +}% +\def\XINT_bth_checkin #1% +{% + \xint_UDsignfork + #1\dummy \XINT_bth_N + -\dummy {\XINT_bth_P #1}% + \krof +}% +\def\XINT_bth_N {\expandafter\xint_minus_andstop\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% +{% + \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% +{% + \xint_gob_til_zero #3\XINT_bth_end_z 0\space #3% +}% +\def\XINT_bth_end_z0\space 0{ }% +% \end{macrocode} +% \subsection{\csh{xintHexToBin}} +% \lverb!v1.08! +% \begin{macrocode} +\def\xintHexToBin {\romannumeral0\xinthextobin }% +\def\xinthextobin #1% +{% + \expandafter\XINT_htb_checkin\romannumeral-`0#1GGGGGGGG\T +}% +\def\XINT_htb_checkin #1% +{% + \xint_UDsignfork + #1\dummy \XINT_htb_N + -\dummy {\XINT_htb_P #1}% + \krof +}% +\def\XINT_htb_N {\expandafter\xint_minus_andstop\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 +{% + \XINT_num_loop #2#1% + \xint_relax\xint_relax\xint_relax\xint_relax + \xint_relax\xint_relax\xint_relax\xint_relax\Z +}% +% \end{macrocode} +% \subsection{\csh{xintCHexToBin}} +% \lverb!v1.08! +% \begin{macrocode} +\def\xintCHexToBin {\romannumeral0\xintchextobin }% +\def\xintchextobin #1% +{% + \expandafter\XINT_chtb_checkin\romannumeral-`0#1% + \R\R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W\W +}% +\def\XINT_chtb_checkin #1% +{% + \xint_UDsignfork + #1\dummy \XINT_chtb_N + -\dummy {\XINT_chtb_P #1}% + \krof +}% +\def\XINT_chtb_N {\expandafter\xint_minus_andstop\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_relax\xint_relax\xint_relax\xint_relax + \xint_relax\xint_relax\xint_relax\xint_relax\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 +}% +\XINT_binhex_restorecatcodes_endinput% +% \end{macrocode} +%\catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11 +%\let</xintbinhex>\relax +%\def<*xintgcd>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12 } +%</xintbinhex> %<*xintgcd> % \section{Package \xintgcdname implementation} % @@ -9400,6 +11287,7 @@ first place. \edef\XINT_gcd_restorecatcodes_endinput {% \catcode36=\the\catcode36 % $ + \catcode94=\the\catcode94 % ^ \catcode96=\the\catcode96 % ` \catcode47=\the\catcode47 % / \catcode41=\the\catcode41 % ) @@ -9422,7 +11310,7 @@ first place. \catcode61=\the\catcode61\relax % = \noexpand\endinput }% - \XINT_setcatcodes + \XINT_setcatcodes % defined in xint.sty \catcode36=3 % $ }% \x @@ -9452,7 +11340,7 @@ first place. \fi \expandafter\x\csname ver@xintgcd.sty\endcsname \ProvidesPackage{xintgcd}% - [2013/05/26 v1.07a Euclide algorithm with xint package (jfB)]% + [2013/06/14 v1.08b Euclide algorithm with xint package (jfB)]% % \end{macrocode} % \subsection{\csh{xintGCD}} % \begin{macrocode} @@ -10106,9 +11994,9 @@ first place. \endgroup \edef\XINT_frac_restorecatcodes_endinput {% - \catcode94=\the\catcode94 % ^ \catcode93=\the\catcode93 % ] \catcode91=\the\catcode91 % [ + \catcode94=\the\catcode94 % ^ \catcode96=\the\catcode96 % ` \catcode47=\the\catcode47 % / \catcode41=\the\catcode41 % ) @@ -10131,10 +12019,9 @@ first place. \catcode61=\the\catcode61\relax % = \noexpand\endinput }% - \XINT_setcatcodes + \XINT_setcatcodes % defined in xint.sty \catcode91=12 % [ \catcode93=12 % ] - \catcode94=7 % ^ }% \x % \end{macrocode} @@ -10161,7 +12048,11 @@ first place. \fi \expandafter\x\csname ver@xintfrac.sty\endcsname \ProvidesPackage{xintfrac}% - [2013/05/26 v1.07a Expandable operations on fractions (jfB)]% + [2013/06/14 v1.08b Expandable operations on fractions (jfB)]% +\chardef\xint_c_vi 6 +\chardef\xint_c_vii 7 +\chardef\xint_c_xviii 18 +\mathchardef\xint_c_x^iv 10000 % \end{macrocode} % \subsection{\csh{xintLen}} % \begin{macrocode} @@ -10176,11 +12067,43 @@ first place. \the\numexpr -1+\XINT_Abs {#1}+\XINT_Len {#2}+\XINT_Len {#3}\relax }% % \end{macrocode} +% \subsection{\csh{XINT\_lenrord\_loop}} +% \begin{macrocode} +\def\XINT_lenrord_loop #1#2#3#4#5#6#7#8#9% +{% faire \romannumeral-`0\XINT_lenrord_loop 0{}#1\Z\W\W\W\W\W\W\W\Z + \xint_gob_til_W #9\XINT_lenrord_W\W + \expandafter\XINT_lenrord_loop\expandafter + {\the\numexpr #1+7}{#9#8#7#6#5#4#3#2}% +}% +\def\XINT_lenrord_W\W\expandafter\XINT_lenrord_loop\expandafter #1#2#3\Z +{% + \expandafter\XINT_lenrord_X\expandafter {#1}#2\Z +}% +\def\XINT_lenrord_X #1#2\Z +{% + \XINT_lenrord_Y #2\R\R\R\R\R\R\T {#1}% +}% +\def\XINT_lenrord_Y #1#2#3#4#5#6#7#8\T +{% + \xint_gob_til_W + #7\XINT_lenrord_Z \xint_c_viii + #6\XINT_lenrord_Z \xint_c_vii + #5\XINT_lenrord_Z \xint_c_vi + #4\XINT_lenrord_Z \xint_c_v + #3\XINT_lenrord_Z \xint_c_iv + #2\XINT_lenrord_Z \xint_c_iii + \W\XINT_lenrord_Z \xint_c_ii \Z +}% +\def\XINT_lenrord_Z #1#2\Z #3% retourne: {longueur}renverse\Z +{% + \expandafter{\the\numexpr #3-#1\relax}% +}% +% \end{macrocode} % \subsection{\csh{XINT\_outfrac}} % \lverb|& % 1.06a version now outputs 0/1[0] and not 0[0] in case of zero. More generally % all macros have been checked in xintfrac, xintseries, xintcfrac, to make sure -% the output format for fractions was always a/b[n]. (except of course \xintIrr, +% the output format for fractions was always A/B[n]. (except of course \xintIrr, % \xintJrr, \xintRawWithZeros)| % \begin{macrocode} \def\XINT_outfrac #1#2#3% @@ -10365,7 +12288,7 @@ first place. }% \def\XINT_cuz_cnt_loop #1#2#3#4#5#6#7#8#9% {% - \xint_gob_til_r #9\XINT_cuz_cnt_toofara \R + \xint_gob_til_R #9\XINT_cuz_cnt_toofara \R \expandafter\XINT_cuz_cnt_checka\expandafter {\the\numexpr #1+8\relax}{#2#3#4#5#6#7#8#9}% }% @@ -10377,7 +12300,7 @@ first place. \def\XINT_cuz_cnt_toofarb #1#2\Z {\XINT_cuz_cnt_toofarc #2\Z {#1}}% \def\XINT_cuz_cnt_toofarc #1#2#3#4#5#6#7#8% {% - \xint_gob_til_r #2\XINT_cuz_cnt_toofard 7% + \xint_gob_til_R #2\XINT_cuz_cnt_toofard 7% #3\XINT_cuz_cnt_toofard 6% #4\XINT_cuz_cnt_toofard 5% #5\XINT_cuz_cnt_toofard 4% @@ -10394,7 +12317,7 @@ first place. }% \def\XINT_cuz_cnt_toofare #1#2#3#4#5#6#7#8% {% - \xint_gob_til_r #2\XINT_cuz_cnt_stopc 1% + \xint_gob_til_R #2\XINT_cuz_cnt_stopc 1% #3\XINT_cuz_cnt_stopc 2% #4\XINT_cuz_cnt_stopc 3% #5\XINT_cuz_cnt_stopc 4% @@ -10409,7 +12332,7 @@ first place. }% \def\XINT_cuz_cnt_checkb #1% {% - \xint_gob_til_zero #1\expandafter\XINT_cuz_cnt_loop\xint_gob_til_z + \xint_gob_til_zero #1\expandafter\XINT_cuz_cnt_loop\xint_gob_til_Z 0\XINT_cuz_cnt_stopa #1% }% \def\XINT_cuz_cnt_stopa #1\Z @@ -10418,7 +12341,7 @@ first place. }% \def\XINT_cuz_cnt_stopb #1#2#3#4#5#6#7#8#9% {% - \xint_gob_til_r #2\XINT_cuz_cnt_stopc 1% + \xint_gob_til_R #2\XINT_cuz_cnt_stopc 1% #3\XINT_cuz_cnt_stopc 2% #4\XINT_cuz_cnt_stopc 3% #5\XINT_cuz_cnt_stopc 4% @@ -10447,7 +12370,7 @@ first place. % \lverb|& % 1.07: this macro simply prints in a user readable form the fraction after its % initial scanning. Useful when put inside braces in an \xintexpr, when the -% input is not yet in the a/b[n] form.| +% input is not yet in the A/B[n] form.| % \begin{macrocode} \def\xintRaw {\romannumeral0\xintraw }% \def\xintraw @@ -10528,14 +12451,15 @@ first place. \def\xintFrac {\romannumeral0\xintfrac }% \def\xintfrac #1% {% - \expandafter\XINT__frac_A\romannumeral0\XINT_infrac {#1}% + \expandafter\XINT_fracfrac_A\romannumeral0\XINT_infrac {#1}% }% -\def\XINT__frac_A #1{\XINT__frac_B #1\Z }% -\def\XINT__frac_B #1#2\Z +\def\XINT_fracfrac_A #1{\XINT_fracfrac_B #1\Z }% +\catcode`^=7 +\def\XINT_fracfrac_B #1#2\Z {% - \xint_gob_til_zero #1\XINT__frac_C 0\XINT__frac_D {10^{#1#2}}% + \xint_gob_til_zero #1\XINT_fracfrac_C 0\XINT_fracfrac_D {10^{#1#2}}% }% -\def\XINT__frac_C #1#2#3#4#5% +\def\XINT_fracfrac_C #1#2#3#4#5% {% \ifcase\XINT_isOne {#5} \or \xint_afterfi {\expandafter\xint_firstoftwo_andstop\xint_gobble_ii }% @@ -10543,15 +12467,15 @@ first place. \space \frac {#4}{#5}% }% -\def\XINT__frac_D #1#2#3% +\def\XINT_fracfrac_D #1#2#3% {% \ifcase\XINT_isOne {#3} - \or \XINT__frac_E + \or \XINT_fracfrac_E \fi \space \frac {#2}{#3}#1% }% -\def\XINT__frac_E \fi #1#2#3#4{\fi \space #3\cdot }% +\def\XINT_fracfrac_E \fi #1#2#3#4{\fi \space #3\cdot }% % \end{macrocode} % \subsection{\csh{xintSignedFrac}} % \begin{macrocode} @@ -10573,7 +12497,7 @@ first place. }% \def\XINT_sgnfrac_P #1\Z #2% {% - \XINT__frac_A {#2}{#1}% + \XINT_fracfrac_A {#2}{#1}% }% \def\XINT_sgnfrac_N {% @@ -10592,6 +12516,7 @@ first place. {% \xint_gob_til_zero #1\XINT_fwover_C 0\XINT_fwover_D {10^{#1#2}}% }% +\catcode`^=11 \def\XINT_fwover_C #1#2#3#4#5% {% \ifcase\XINT_isOne {#5} @@ -10703,7 +12628,8 @@ first place. % 1.04 fixes a buggy \xintIrr {0}. % 1.05 modifies the initial parsing and post-processing to use \xintrawwithzeros % and to -% more quickly deal with an input denominator equal to 1.| +% more quickly deal with an input denominator equal to 1. 1.08 version does +% not remove a /1 denominator.| % \begin{macrocode} \def\xintIrr {\romannumeral0\xintirr }% \def\xintirr #1% @@ -10723,7 +12649,7 @@ first place. \fi #2\Z {#3}% }% -\def\XINT_irr_denomisone #1\Z #2{ #1}% +\def\XINT_irr_denomisone #1\Z #2{ #1/1}% changed in 1.08 \def\XINT_irr_negative #1\Z #2{\XINT_irr_D #1\Z #2\Z \xint_minus_andstop}% \def\XINT_irr_nonneg #1\Z #2{\XINT_irr_D #1\Z #2\Z \space}% \def\XINT_irr_D #1#2\Z #3#4\Z @@ -10738,7 +12664,7 @@ first place. }% \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_zero #1#2#3#4#5{ 0}% +\def\XINT_irr_zero #1#2#3#4#5{ 0/1}% changed in 1.08 \def\XINT_irr_loop_a #1#2% {% \expandafter\XINT_irr_loop_d @@ -10762,14 +12688,7 @@ first place. {% \expandafter\XINT_irr_finish\expandafter {#2}{#1}% }% -\def\XINT_irr_finish #1#2#3% -{% - \ifcase\XINT_isOne {#2} - \xint_afterfi {#3#1/#2}% - \or - \xint_afterfi {#3#1}% - \fi -}% +\def\XINT_irr_finish #1#2#3{#3#1/#2}% changed in 1.08 % \end{macrocode} % \subsection{\csh{xintNum}} % \lverb|& @@ -10784,29 +12703,18 @@ first place. % evaluates to an integer. | % \begin{macrocode} \def\xintNum {\romannumeral0\xintnum }% -\def\xintnum #1{\expandafter\XINT_intcheck\romannumeral0\xintirr {#1}/\W\Z }% -\def\XINT_intcheck #1/#2#3\Z +\def\xintnum #1{\expandafter\XINT_intcheck\romannumeral0\xintirr {#1}\Z }% +\def\XINT_intcheck #1/#2\Z {% - \xint_gob_til_w #2\xint_gobble_ii\W - \xintError:NotAnInteger - \space #1% -}% -% \end{macrocode} -% \subsection{\csh{xintfFac}} -% \lverb|done in 1.07, the \xintexpr scanner may want to apply \xintFac -% to a fraction, but using \xintNum as here means count registers are -% not allowed -% anymore; to maintain this feature from previous versions I had to duplicate.| -% \begin{macrocode} -\def\xintfFac {\romannumeral0\xintffac }% -\def\xintffac #1% -{% - \expandafter\XINT_fac_fork\expandafter{\the\numexpr \xintNum{#1}}% + \ifcase\XINT_isOne {#2} + \xintError:NotAnInteger + \fi\space #1% }% % \end{macrocode} % \subsection{\csh{xintJrr}} % \lverb|& -% Modified similarly as \xintIrr in release 1.05| +% Modified similarly as \xintIrr in release 1.05. 1.08 version does +% not remove a /1 denominator.| % \begin{macrocode} \def\xintJrr {\romannumeral0\xintjrr }% \def\xintjrr #1% @@ -10826,7 +12734,7 @@ first place. \fi #2\Z {#3}% }% -\def\XINT_jrr_denomisone #1\Z #2{ #1}% +\def\XINT_jrr_denomisone #1\Z #2{ #1/1}% changed in 1.08 \def\XINT_jrr_negative #1\Z #2{\XINT_jrr_D #1\Z #2\Z \xint_minus_andstop }% \def\XINT_jrr_nonneg #1\Z #2{\XINT_jrr_D #1\Z #2\Z \space}% \def\XINT_jrr_D #1#2\Z #3#4\Z @@ -10841,7 +12749,7 @@ first place. }% \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_zero #1#2#3#4#5#6#7{ 0}% +\def\XINT_jrr_zero #1#2#3#4#5#6#7{ 0/1}% changed in 1.08 \def\XINT_jrr_loop_a #1#2% {% \expandafter\XINT_jrr_loop_b @@ -11024,7 +12932,7 @@ first place. }% \def\XINT_round_Daa #1% {% - \xint_gob_til_z #1\XINT_round_Daz\Z \XINT_round_Da #1% + \xint_gob_til_Z #1\XINT_round_Daz\Z \XINT_round_Da #1% }% \def\XINT_round_Daz\Z \XINT_round_Da \Z { 0\Z }% \def\XINT_round_Da #1\Z @@ -11037,7 +12945,7 @@ first place. }% \def\XINT_round_Dba #1% {% - \xint_gob_til_z #1\XINT_round_Dbz\Z \XINT_round_Db #1% + \xint_gob_til_Z #1\XINT_round_Dbz\Z \XINT_round_Db #1% }% \def\XINT_round_Dbz\Z \XINT_round_Db \Z { 1\Z }% \def\XINT_round_Db #1\Z @@ -11053,241 +12961,280 @@ first place. \def\xinttheDigits {\number\XINT_digits }% % \end{macrocode} % \subsection{\csh{xintFloat}} +% \lverb|1.07. Completely re-written in 1.08a, with spectacular speed +% gains. The earlier version was seriously silly when dealing with +% inputs having a big power of ten. Again some modifications in 1.08b +% for a better treatment of cases with long explicit numerators or +% denominators. | % \begin{macrocode} \def\xintFloat {\romannumeral0\xintfloat }% \def\xintfloat #1{\XINT_float_chkopt #1\Z }% \def\XINT_float_chkopt #1% {% - \ifx #1[\expandafter\XINT_float_opt + \ifx [#1\expandafter\XINT_float_opt \else\expandafter\XINT_float_noopt \fi #1% }% -\def\XINT_float_noopt #1\Z +\def\XINT_float_noopt #1\Z {% - \XINT_float_a \XINT_digits {#1}% + \expandafter\XINT_float_a\expandafter\XINT_digits + \romannumeral0\XINT_infrac {#1}\XINT_float_Q }% -\def\XINT_float_opt [\Z #1]% +\def\XINT_float_opt [\Z #1]#2% {% - \expandafter\XINT_float_a\expandafter {\the\numexpr #1}% + \expandafter\XINT_float_a\expandafter + {\the\numexpr #1\expandafter}% + \romannumeral0\XINT_infrac {#2}\XINT_float_Q }% -\def\XINT_float_a #1#2% +\def\XINT_float_a #1#2#3% #1=P, #2=n, #3=A, #4=B {% - \expandafter\XINT_float_b \romannumeral0\XINT_infrac {#2}{#1}% -}% -\def\XINT_float_b #1#2#3% -{% - \XINT_float_fork #2\Z {#3}{#1}% + \XINT_float_fork #3\Z {#1}{#2}% #1 = precision, #2=n }% \def\XINT_float_fork #1% {% \xint_UDzerominusfork #1-\dummy \XINT_float_zero - 0#1\dummy \XINT_float_N - 0-\dummy {\XINT_float_P #1}% + 0#1\dummy \XINT_float_J + 0-\dummy {\XINT_float_K #1}% \krof }% -\def\XINT_float_zero \Z #1#2#3{ 0.e0}% -\def\XINT_float_N {\expandafter\xint_minus_andstop\romannumeral0\XINT_float_P }% -\def\XINT_float_P #1\Z #2#3#4% +\def\XINT_float_zero #1\Z #2#3#4#5{ 0.e0}% +\def\XINT_float_J {\expandafter\xint_minus_andstop\romannumeral0\XINT_float_K }% +\def\XINT_float_K #1\Z #2% #1=A, #2=P, #3=n, #4=B {% - \ifcase \romannumeral0\XINT_fgeq_A 011{#3}{#1}{#2} - \expandafter\XINT_float_lessthanone_a - \or\expandafter\XINT_float_atleastone_b - \fi {#3}{#1}{#2}{#3+#4}{#1}{#2}% + \expandafter\XINT_float_L\expandafter + {\the\numexpr\xintLength{#1}\expandafter}\expandafter + {\the\numexpr #2+\xint_c_ii}{#1}{#2}% }% -\def\XINT_float_atleastone_b +\def\XINT_float_L #1#2% {% - \expandafter\XINT_float_atleastone_c\romannumeral0\XINT_trunc_B -}% -\def\XINT_float_atleastone_c #1\Z #2% + \ifnum #1>#2 + \expandafter\XINT_float_Ma + \else + \expandafter\XINT_float_Mc + \fi {#1}{#2}% +}% +\def\XINT_float_Ma #1#2#3% {% - \expandafter\XINT_float_c\expandafter - {\romannumeral0\xintisub {\xintLength{#1}}{1}}% + \expandafter\XINT_float_Mb\expandafter + {\the\numexpr #1-#2\expandafter}\expandafter + {\expandafter\xint_firstoftwo + \romannumeral0\XINT_split_fromleft_loop {#2}{}#3\W\W\W\W\W\W\W\W\Z + }{#2}% }% -\def\XINT_float_lessthanone_a #1% +\def\XINT_float_Mb #1#2#3#4#5#6% #2=A', #3=P+2, #4=P, #5=n, #6=B {% - \expandafter\XINT_float_lessthanone_b\expandafter - {\the\numexpr -#1}% -}% -\def\XINT_float_lessthanone_b #1#2#3% + \expandafter\XINT_float_N\expandafter + {\the\numexpr\xintLength{#6}\expandafter}\expandafter + {\the\numexpr #3\expandafter}\expandafter + {\the\numexpr #1+#5}% + {#6}{#3}{#2}{#4}% +}% long de B, P+2, n', B, |A'|=P+2, A', P +\def\XINT_float_Mc #1#2#3#4#5#6% {% - \expandafter\XINT_float_lessthanone_c - \romannumeral0\XINT_trunc_B {#1}{#3}{#2}% -}% -\def\XINT_float_lessthanone_c #1\Z #2% + \expandafter\XINT_float_N\expandafter + {\romannumeral0\XINT_length{#6}}{#2}{#5}{#6}{#1}{#3}{#4}% +}% long de B, P+2, n, B, |A|, A, P +\def\XINT_float_N #1#2% +{% + \ifnum #1>#2 + \expandafter\XINT_float_O + \else + \expandafter\XINT_float_P + \fi {#1}{#2}% +}% +\def\XINT_float_O #1#2#3#4% {% - \expandafter\XINT_float_c\expandafter - {\expandafter-\romannumeral0\xintilen {\xintiSub {#1}{1}}}% + \expandafter\XINT_float_P\expandafter + {\the\numexpr #2\expandafter}\expandafter + {\the\numexpr #2\expandafter}\expandafter + {\the\numexpr #3-#1+#2\expandafter}\expandafter + {\expandafter\xint_firstoftwo + \romannumeral0\XINT_split_fromleft_loop {#2}{}#4\W\W\W\W\W\W\W\W\Z + }% +}% |B|,P+2,n,B,|A|,A,P +\def\XINT_float_P #1#2#3#4#5#6#7#8% +{% + \expandafter #8\expandafter {\the\numexpr #1-#5+#2-\xint_c_i}% + {#6}{#4}{#7}{#3}% +}% |B|-|A|+P+1,A,B,P,n +\def\XINT_float_Q #1% +{% + \ifnum #1<\xint_c_ + \expandafter\XINT_float_Ri + \else + \expandafter\XINT_float_Rii + \fi {#1}% }% -\def\XINT_float_c #1#2#3#4% +\def\XINT_float_Ri #1#2#3% {% - \expandafter\XINT_float_d\expandafter - {\the\numexpr #2-#1}{#3}{#4}e#1% + \expandafter\XINT_float_Sa + \romannumeral0\xintiquo {#2}% + {\romannumeral-`0\XINT_dsx_addzerosnofuss {-#1}{#3}}\Z {#1}% }% -\def\XINT_float_d +\def\XINT_float_Rii #1#2#3% {% - \expandafter\XINT_float_round_B\romannumeral0\XINT_trunc_B + \expandafter\XINT_float_Sa + \romannumeral0\xintiquo + {\romannumeral-`0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}\Z {#1}% }% -\def\XINT_float_round_B #1#2\Z #3% +\def\XINT_float_Sa #1% {% - \ifnum #1=9 - \xint_afterfi - {\romannumeral0\XINT_rord_main {}#1#2\XINT_float_round_S}% + \if #19% + \xint_afterfi {\XINT_float_Sb\XINT_float_Wb }% \else - \xint_afterfi - {\romannumeral0\XINT_rord_main {}#1#2\XINT_float_round_D}% - \fi - \xint_relax - \xint_undef\xint_undef\xint_undef\xint_undef - \xint_undef\xint_undef\xint_undef\xint_undef - \xint_relax - \Z + \xint_afterfi {\XINT_float_Sb\XINT_float_Wa }% + \fi #1% }% -\def\XINT_float_round_D #1% +\def\XINT_float_Sb #1#2\Z #3#4% {% - \ifnum #1<5 - \expandafter\XINT_float_round_Da + \expandafter\XINT_float_T\expandafter + {\the\numexpr #4+\xint_c_i\expandafter}% + \romannumeral-`0\XINT_lenrord_loop 0{}#2\Z\W\W\W\W\W\W\W\Z #1{#3}{#4}% +}% +\def\XINT_float_T #1#2#3% +{% + \ifnum #2>#1 + \xint_afterfi{\XINT_float_U\XINT_float_Xb}% \else - \expandafter\XINT_float_round_Db + \xint_afterfi{\XINT_float_U\XINT_float_Xa #3}% \fi }% -\def\XINT_float_round_Da #1\Z +\def\XINT_float_U #1#2% {% - \expandafter\XINT_float_round_f - \romannumeral0\XINT_rord_main {}#1% + \ifnum #2<\xint_c_v + \expandafter\XINT_float_Va + \else + \expandafter\XINT_float_Vb + \fi #1% +}% +\def\XINT_float_Va #1#2\Z #3% +{% + \expandafter#1% + \romannumeral0\expandafter\XINT_float_Wa + \romannumeral0\XINT_rord_main {}#2% \xint_relax \xint_undef\xint_undef\xint_undef\xint_undef \xint_undef\xint_undef\xint_undef\xint_undef - \xint_relax + \xint_relax \Z }% -\def\XINT_float_round_Db #1\Z +\def\XINT_float_Vb #1#2\Z #3% {% - \expandafter\XINT_float_round_f - \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z + \expandafter #1% + \romannumeral0\expandafter #3% + \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #2000\W\X\Y\Z \Z }% -\def\XINT_float_round_f #1{ #1.}% -\def\XINT_float_round_S #1% +\def\XINT_float_Wa #1{ #1.}% +\def\XINT_float_Wb #1#2% + {\if #11\xint_afterfi{ 10.}\else\xint_afterfi{ #1.#2}\fi }% +\def\XINT_float_Xa #1\Z #2#3#4% {% - \ifnum #1<5 - \expandafter\XINT_float_round_Da - \else - \expandafter\XINT_float_round_Sb - \fi -}% -\def\XINT_float_round_Sb #1\Z -{% - \expandafter\XINT_float_round_g - \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z + \expandafter\XINT_float_Y\expandafter + {\the\numexpr #3+#4-#2}{#1}% }% -\def\XINT_float_round_g #1% +\def\XINT_float_Xb #1\Z #2#3#4% {% - \ifnum #1=1 \expandafter\XINT_float_round_h\fi - \space #1.% + \expandafter\XINT_float_Y\expandafter + {\the\numexpr #3+#4+\xint_c_i-#2}{#1}% }% -\def\XINT_float_round_h\space 1.0{ 10.}% +\def\XINT_float_Y #1#2{ #2e#1}% % \end{macrocode} % \subsection{\csh{XINT\_inFloat}} +% \lverb|1.07. Completely rewritten in 1.08a for immensely greater efficiency +% when the +% power of ten is big: previous version had some very serious bottlenecks +% arising from the creation of long strings of zeros, which made things such as +% 2^999999 completely impossible, but now even 2^999999999 with 24 significant +% digits is no problem! Again (slightly) improved in 1.08b. | % \begin{macrocode} -\def\XINT_inFloat [#1]% +\def\XINT_inFloat [#1]#2% {% - \expandafter\XINT_infloat\expandafter {\the\numexpr #1}% + \expandafter\XINT_infloat_a\expandafter + {\the\numexpr #1\expandafter}% + \romannumeral0\XINT_infrac {#2}\XINT_infloat_Q }% -\def\XINT_infloat #1#2% +\def\XINT_infloat_a #1#2#3% #1=P, #2=n, #3=A, #4=B {% - \expandafter\XINT_infloat_a \romannumeral0\XINT_infrac {#2}{#1}% -}% -\def\XINT_infloat_a #1#2#3% -{% - \XINT_infloat_fork #2\Z {#3}{#1}% + \XINT_infloat_fork #3\Z {#1}{#2}% #1 = precision, #2=n }% \def\XINT_infloat_fork #1% {% \xint_UDzerominusfork #1-\dummy \XINT_infloat_zero - 0#1\dummy \XINT_infloat_N - 0-\dummy {\XINT_infloat_P #1}% + 0#1\dummy \XINT_infloat_J + 0-\dummy {\XINT_float_K #1}% \krof }% -\def\XINT_infloat_zero\Z #1#2#3{0[0]}% -\def\XINT_infloat_N {\expandafter-\romannumeral-`0\XINT_infloat_P }% -\def\XINT_infloat_P #1\Z #2#3#4% +\def\XINT_infloat_zero #1\Z #2#3#4#5{0[0]}% +\def\XINT_infloat_J {\expandafter-\romannumeral-`0\XINT_float_K }% +\def\XINT_infloat_Q #1% {% - \ifcase \romannumeral0\XINT_fgeq_A 011{#3}{#1}{#2} - \expandafter\XINT_infloat_lessthanone_a - \or\expandafter\XINT_infloat_atleastone_b - \fi {#3}{#1}{#2}{#3+#4}{#1}{#2}{#4}% + \ifnum #1<\xint_c_ + \expandafter\XINT_infloat_Ri + \else + \expandafter\XINT_infloat_Rii + \fi {#1}% }% -\def\XINT_infloat_atleastone_b -{% - \expandafter\XINT_infloat_atleastone_c\romannumeral0\XINT_trunc_B -}% -\def\XINT_infloat_atleastone_c #1\Z #2% +\def\XINT_infloat_Ri #1#2#3% {% - \expandafter\XINT_infloat_c\expandafter - {\romannumeral0\xintisub {\xintLength{#1}}{1}}% + \expandafter\XINT_infloat_S\expandafter + {\romannumeral0\xintiquo {#2}% + {\romannumeral-`0\XINT_dsx_addzerosnofuss {-#1}{#3}}}{#1}% }% -\def\XINT_infloat_lessthanone_a #1% -{% - \expandafter\XINT_infloat_lessthanone_b\expandafter - {\the\numexpr -#1}% -}% -\def\XINT_infloat_lessthanone_b #1#2#3% +\def\XINT_infloat_Rii #1#2#3% {% - \expandafter\XINT_infloat_lessthanone_c - \romannumeral0\XINT_trunc_B {#1}{#3}{#2}% -}% -\def\XINT_infloat_lessthanone_c #1\Z #2% -{% - \expandafter\XINT_infloat_c\expandafter - {\expandafter-\romannumeral0\xintilen {\xintiSub {#1}{1}}}% -}% -\def\XINT_infloat_c #1#2#3#4% -{% - \expandafter\XINT_infloat_d\expandafter - {\the\numexpr #2-#1}{#3}{#4}{#1}% + \expandafter\XINT_infloat_S\expandafter + {\romannumeral0\xintiquo + {\romannumeral-`0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}}{#1}% }% -\def\XINT_infloat_d +\def\XINT_infloat_S #1#2#3% {% - \expandafter\XINT_infloat_round_B\romannumeral0\XINT_trunc_B + \expandafter\XINT_infloat_T\expandafter + {\the\numexpr #3+\xint_c_i\expandafter}% + \romannumeral-`0\XINT_lenrord_loop 0{}#1\Z\W\W\W\W\W\W\W\Z + {#2}% }% -\def\XINT_infloat_round_B #1\Z #2% +\def\XINT_infloat_T #1#2#3% {% - \expandafter\XINT_infloat_round_D - \romannumeral0\XINT_rord_main {}#1% - \xint_relax - \xint_undef\xint_undef\xint_undef\xint_undef - \xint_undef\xint_undef\xint_undef\xint_undef - \xint_relax - \Z + \ifnum #2>#1 + \xint_afterfi{\XINT_infloat_U\XINT_infloat_Wb}% + \else + \xint_afterfi{\XINT_infloat_U\XINT_infloat_Wa #3}% + \fi }% -\def\XINT_infloat_round_D #1% +\def\XINT_infloat_U #1#2% {% - \ifnum #1<5 - \expandafter\XINT_infloat_round_Da + \ifnum #2<\xint_c_v + \expandafter\XINT_infloat_Va \else - \expandafter\XINT_infloat_round_Db - \fi + \expandafter\XINT_infloat_Vb + \fi #1% }% -\def\XINT_infloat_round_Da #1\Z +\def\XINT_infloat_Va #1#2\Z {% - \expandafter\XINT_infloat_round_f - \romannumeral0\XINT_rord_main {}#1% + \expandafter#1% + \romannumeral0\XINT_rord_main {}#2% \xint_relax \xint_undef\xint_undef\xint_undef\xint_undef \xint_undef\xint_undef\xint_undef\xint_undef \xint_relax \Z }% -\def\XINT_infloat_round_Db #1\Z +\def\XINT_infloat_Vb #1#2\Z {% - \expandafter\XINT_infloat_round_f - \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z \Z + \expandafter #1% + \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #2000\W\X\Y\Z \Z }% -\def\XINT_infloat_round_f #1\Z #2#3% +\def\XINT_infloat_Wa #1\Z #2#3% {% - \expandafter\XINT_infloat_round_g\expandafter - {\the\numexpr #2-#3+1}{#1}% + \expandafter\XINT_infloat_X\expandafter + {\the\numexpr #3+\xint_c_i-#2}{#1}% }% -\def\XINT_infloat_round_g #1#2{#2[#1]}% +\def\XINT_infloat_Wb #1\Z #2#3% +{% + \expandafter\XINT_infloat_X\expandafter + {\the\numexpr #3+\xint_c_ii-#2}{#1}% +}% +\def\XINT_infloat_X #1#2{ #2[#1]}% % \end{macrocode} % \subsection{\csh{xintAdd}} % \begin{macrocode} @@ -11409,30 +13356,24 @@ first place. }% \def\xint_fsqr #1{\XINT_fmul_A #1#1}% % \end{macrocode} -% \subsection{\csh{xintPow}, \csh{xintfPow}} +% \subsection{\csh{xintPow}} % \lverb|& % Modified in 1.06 to give the exponent to a \numexpr.$\ -% With 1.07 and the \xintexpr parser, we need something allowing -% fractions evaluating to integers for the exponent; adding \xintNum -% does this but makes using count registers again impossible. So I have -% to duplicate.| +% With 1.07 and for use within the \xintexpr parser, we must allow +% fractions (which are integers in disguise) as input to the exponent, so we +% must have a variant which uses \xintNum and not only \numexpr +% for normalizing the input. Hence the \xintfPow here. 1.08b: well actually I +% think that with xintfrac.sty loaded the exponent should always be allowed to +% be a fraction giving an integer. So I do as for \xintFac, and remove here the +% duplicated. The \xintexpr can thus use directly \xintPow.| % \begin{macrocode} \def\xintPow {\romannumeral0\xintpow }% \def\xintpow #1% {% \expandafter\xint_fpow\expandafter {\romannumeral0\XINT_infrac {#1}}% }% -\def\xintfPow {\romannumeral0\xintfpow }% -\def\xintfpow #1% -{% - \expandafter\xint_ffpow\expandafter {\romannumeral0\XINT_infrac {#1}}% -}% \def\xint_fpow #1#2% {% - \expandafter\XINT_fpow_fork\the\numexpr #2\relax\Z #1% -}% -\def\xint_ffpow #1#2% -{% \expandafter\XINT_fpow_fork\the\numexpr \xintNum{#2}\relax\Z #1% }% \def\XINT_fpow_fork #1#2\Z @@ -11468,6 +13409,20 @@ first place. }% \def\XINT_fpow_pos_B #1#2{\XINT_outfrac {#2}{#1}}% % \end{macrocode} +% \subsection{\csh{xintFac}} +% \lverb|1.07: to be used by the \xintexpr scanner which needs to be able to +% apply \xintFac +% to a fraction which is an integer in disguise; so we use \xintNum and not only +% \numexpr. Je modifie cela dans 1.08b, au lieu d'avoir un \xintfFac +% spécialement pour \xintexpr, tout simplement j'étends \xintFac comme les +% autres macros, pour qu'elle utilise \xintNum. | +% \begin{macrocode} +\def\xintFac {\romannumeral0\xintfac }% +\def\xintfac #1% +{% + \expandafter\XINT_fac_fork\expandafter{\the\numexpr \xintNum{#1}}% +}% +% \end{macrocode} % \subsection{\csh{xintPrd}, \csh{xintPrdExpr}} % \begin{macrocode} \def\xintPrd {\romannumeral0\xintprd }% @@ -11513,127 +13468,222 @@ first place. }% \def\XINT_fdiv_C #1#2{\XINT_outfrac {#2}{#1}}% % \end{macrocode} -% \subsection{\csh{xintCmp}} -% \begin{macrocode} -\def\xintCmp {\romannumeral0\xintcmp }% -\def\xintcmp #1% -{% - \expandafter\xint_fcmp\expandafter {\romannumeral0\XINT_infrac {#1}}% -}% -\def\xint_fcmp #1#2{\expandafter\XINT_fcmp_A\romannumeral0\XINT_infrac {#2}#1}% -\def\XINT_fcmp_A #1#2#3#4% -{% - \ifnum #4 > #1 - \xint_afterfi {\XINT_fcmp_B {#1}}% - \else - \xint_afterfi {\XINT_fcmp_B {#4}}% - \fi - {#1}{#4}{#2}{#3}% -}% -\def\XINT_fcmp_B #1#2#3#4#5#6#7% -{% - \xinticmp - {\romannumeral0\xintimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% - {\romannumeral0\xintimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% -}% -% \end{macrocode} % \subsection{\csh{xintGeq}} % \lverb|& -% This extension to fractions was added only with release 1.07, don't know why I -% did not do it in the same go as \xintMax, \xintMin, \xintCmp. Beware that -% like the original it -% compares only the *absolute values*.| +% Rewritten completely in 1.08a to be less dumb when comparing fractions having +% big powers of tens.| % \begin{macrocode} \def\xintGeq {\romannumeral0\xintgeq }% \def\xintgeq #1% {% - \expandafter\xint_fgeq\expandafter {\romannumeral0\XINT_infrac {#1}}% + \expandafter\xint_fgeq\expandafter {\romannumeral0\xintabs {#1}}% }% \def\xint_fgeq #1#2% {% - \expandafter\XINT_fgeq_A \romannumeral0\XINT_infrac {#2}#1% + \expandafter\XINT_fgeq_A \romannumeral0\xintabs {#2}#1% }% -\def\XINT_fgeq_A #1#2#3#4% +\def\XINT_fgeq_A #1% {% - \ifnum #4 > #1 - \xint_afterfi {\XINT_fgeq_B {#1}}% - \else - \xint_afterfi {\XINT_fgeq_B {#4}}% - \fi - {#1}{#4}{#2}{#3}% + \xint_gob_til_zero #1\XINT_fgeq_Zii 0% + \XINT_fgeq_B #1% }% -\def\XINT_fgeq_B #1#2#3#4#5#6#7% +\def\XINT_fgeq_Zii 0\XINT_fgeq_B #1[#2]#3[#4]{ 1}% +\def\XINT_fgeq_B #1/#2[#3]#4#5/#6[#7]% {% + \xint_gob_til_zero #4\XINT_fgeq_Zi 0% \expandafter\XINT_fgeq_C\expandafter - {\romannumeral0\xintimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% - {\romannumeral0\xintimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% + {\the\numexpr #7-#3\expandafter}\expandafter + {\romannumeral0\xintimul {#4#5}{#2}}% + {\romannumeral0\xintimul {#6}{#1}}% +}% +\def\XINT_fgeq_Zi 0#1#2#3#4#5#6#7{ 0}% +\def\XINT_fgeq_C #1#2#3% +{% + \expandafter\XINT_fgeq_D\expandafter + {#3}{#1}{#2}% }% -\def\XINT_fgeq_C #1#2% +\def\XINT_fgeq_D #1#2#3% {% - \expandafter\XINT_geq_fork #2\Z #1\Z + \xintSgnFork + {\xintiSgn{\the\numexpr #2+\xintLength{#3}-\xintLength{#1}\relax}}% + { 0}{\XINT_fgeq_E #2\Z {#3}{#1}}{ 1}% +}% +\def\XINT_fgeq_E #1% +{% + \xint_UDsignfork + #1\dummy \XINT_fgeq_Fd + -\dummy {\XINT_fgeq_Fn #1}% + \krof +}% +\def\XINT_fgeq_Fd #1\Z #2#3% +{% + \expandafter\XINT_fgeq_Fe\expandafter + {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#3}}{#2}% +}% +\def\XINT_fgeq_Fe #1#2{\XINT_geq_pre {#2}{#1}}% +\def\XINT_fgeq_Fn #1\Z #2#3% +{% + \expandafter\XINT_geq_pre\expandafter + {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}% }% % \end{macrocode} % \subsection{\csh{xintMax}} +% \lverb|& +% Rewritten completely in 1.08a.| % \begin{macrocode} \def\xintMax {\romannumeral0\xintmax }% \def\xintmax #1% {% - \expandafter\xint_fmax\expandafter {\romannumeral0\XINT_infrac {#1}}% + \expandafter\xint_fmax\expandafter {\romannumeral0\xintraw {#1}}% }% -\def\xint_fmax #1#2{\expandafter\XINT_outfrac - \romannumeral0\expandafter\XINT_fmax_A - \romannumeral0\XINT_infrac {#2}#1}% -\def\XINT_fmax_A #1#2#3#4#5#6% +\def\xint_fmax #1#2% {% - \ifnum #4 > #1 - \xint_afterfi {\XINT_fmax_B {#1}}% - \else - \xint_afterfi {\XINT_fmax_B {#4}}% - \fi - {#1}{#4}{#2}{#3}{#5}{#6}{{#4}{#5}{#6}}{{#1}{#2}{#3}}% + \expandafter\XINT_fmax_A\romannumeral0\xintraw {#2}#1% }% -\def\XINT_fmax_B #1#2#3#4#5#6#7% +\def\XINT_fmax_A #1#2/#3[#4]#5#6/#7[#8]% {% - \expandafter\XINT_fmax_C\expandafter - {\romannumeral0\xintimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% - {\romannumeral0\xintimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% + \xint_UDsignsfork + #1#5\dummy \XINT_fmax_minusminus + -#5\dummy \XINT_fmax_firstneg + #1-\dummy \XINT_fmax_secondneg + --\dummy \XINT_fmax_nonneg_a + \krof + #1#5{#2/#3[#4]}{#6/#7[#8]}% }% -\def\XINT_fmax_C #1#2% +\def\XINT_fmax_minusminus --% + {\expandafter\xint_minus_andstop\romannumeral0\XINT_fmin_nonneg_b }% +\def\XINT_fmax_firstneg #1-#2#3{ #1#2}% +\def\XINT_fmax_secondneg -#1#2#3{ #1#3}% +\def\XINT_fmax_nonneg_a #1#2#3#4% {% - \expandafter\XINT_max_fork #2\Z #1\Z + \XINT_fmax_nonneg_b {#1#3}{#2#4}% +}% +\def\XINT_fmax_nonneg_b #1#2% +{% + \ifcase\romannumeral0\XINT_fgeq_A #1#2 + \xint_afterfi{ #1}% + \or \xint_afterfi{ #2}% + \fi }% % \end{macrocode} % \subsection{\csh{xintMin}} +% \lverb|& +% Rewritten completely in 1.08a.| % \begin{macrocode} \def\xintMin {\romannumeral0\xintmin }% \def\xintmin #1% {% - \expandafter\xint_fmin\expandafter {\romannumeral0\XINT_infrac {#1}}% + \expandafter\xint_fmin\expandafter {\romannumeral0\xintraw {#1}}% }% \def\xint_fmin #1#2% {% - \expandafter\XINT_outfrac - \romannumeral0\expandafter\XINT_fmin_A - \romannumeral0\XINT_infrac {#2}#1% + \expandafter\XINT_fmin_A\romannumeral0\xintraw {#2}#1% }% -\def\XINT_fmin_A #1#2#3#4#5#6% +\def\XINT_fmin_A #1#2/#3[#4]#5#6/#7[#8]% {% - \ifnum #4 > #1 - \xint_afterfi {\XINT_fmin_B {#1}}% - \else - \xint_afterfi {\XINT_fmin_B {#4}}% + \xint_UDsignsfork + #1#5\dummy \XINT_fmin_minusminus + -#5\dummy \XINT_fmin_firstneg + #1-\dummy \XINT_fmin_secondneg + --\dummy \XINT_fmin_nonneg_a + \krof + #1#5{#2/#3[#4]}{#6/#7[#8]}% +}% +\def\XINT_fmin_minusminus --% + {\expandafter\xint_minus_andstop\romannumeral0\XINT_fmax_nonneg_b }% +\def\XINT_fmin_firstneg #1-#2#3{ -#3}% +\def\XINT_fmin_secondneg -#1#2#3{ -#2}% +\def\XINT_fmin_nonneg_a #1#2#3#4% +{% + \XINT_fmin_nonneg_b {#1#3}{#2#4}% +}% +\def\XINT_fmin_nonneg_b #1#2% +{% + \ifcase\romannumeral0\XINT_fgeq_A #1#2 + \xint_afterfi{ #2}% + \or \xint_afterfi{ #1}% \fi - {#1}{#4}{#2}{#3}{#5}{#6}{{#4}{#5}{#6}}{{#1}{#2}{#3}}% }% -\def\XINT_fmin_B #1#2#3#4#5#6#7% +% \end{macrocode} +% \subsection{\csh{xintCmp}} +% \lverb|& +% Rewritten completely in 1.08a to be less dumb when comparing fractions having +% big powers of tens.| +% \begin{macrocode} +\def\xintCmp {\romannumeral0\xintcmp }% +\def\xintcmp #1% {% - \expandafter\XINT_fmin_C\expandafter - {\romannumeral0\xintimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% - {\romannumeral0\xintimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% + \expandafter\xint_fcmp\expandafter {\romannumeral0\xintraw {#1}}% +}% +\def\xint_fcmp #1#2% +{% + \expandafter\XINT_fcmp_A\romannumeral0\xintraw {#2}#1% +}% +\def\XINT_fcmp_A #1#2/#3[#4]#5#6/#7[#8]% +{% + \xint_UDsignsfork + #1#5\dummy \XINT_fcmp_minusminus + -#5\dummy \XINT_fcmp_firstneg + #1-\dummy \XINT_fcmp_secondneg + --\dummy \XINT_fcmp_nonneg_a + \krof + #1#5{#2/#3[#4]}{#6/#7[#8]}% +}% +\def\XINT_fcmp_minusminus --#1#2{\XINT_fcmp_B #2#1}% +\def\XINT_fcmp_firstneg #1-#2#3{ -1}% +\def\XINT_fcmp_secondneg -#1#2#3{ 1}% +\def\XINT_fcmp_nonneg_a #1#2% +{% + \xint_UDzerosfork + #1#2\dummy \XINT_fcmp_zerozero + 0#2\dummy \XINT_fcmp_firstzero + #10\dummy \XINT_fcmp_secondzero + 00\dummy \XINT_fcmp_pos + \krof + #1#2% +}% +\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% +}% +\def\XINT_fcmp_B #1/#2[#3]#4/#5[#6]% +{% + \expandafter\XINT_fcmp_C\expandafter + {\the\numexpr #6-#3\expandafter}\expandafter + {\romannumeral0\xintimul {#4}{#2}}% + {\romannumeral0\xintimul {#5}{#1}}% +}% +\def\XINT_fcmp_C #1#2#3% +{% + \expandafter\XINT_fcmp_D\expandafter + {#3}{#1}{#2}% }% -\def\XINT_fmin_C #1#2% +\def\XINT_fcmp_D #1#2#3% {% - \expandafter\XINT_min_fork #2\Z #1\Z + \xintSgnFork + {\xintiSgn{\the\numexpr #2+\xintLength{#3}-\xintLength{#1}\relax}}% + { -1}{\XINT_fcmp_E #2\Z {#3}{#1}}{ 1}% +}% +\def\XINT_fcmp_E #1% +{% + \xint_UDsignfork + #1\dummy \XINT_fcmp_Fd + -\dummy {\XINT_fcmp_Fn #1}% + \krof +}% +\def\XINT_fcmp_Fd #1\Z #2#3% +{% + \expandafter\XINT_fcmp_Fe\expandafter + {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#3}}{#2}% +}% +\def\XINT_fcmp_Fe #1#2{\XINT_cmp_pre {#2}{#1}}% +\def\XINT_fcmp_Fn #1\Z #2#3% +{% + \expandafter\XINT_cmp_pre\expandafter + {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}% }% % \end{macrocode} % \subsection{\csh{xintAbs}} @@ -11732,6 +13782,7 @@ first place. }% % \end{macrocode} % \subsection{\csh{xintFloatAdd}} +% \lverb|1.07| % \begin{macrocode} \def\xintFloatAdd {\romannumeral0\xintfloatadd }% \def\xintfloatadd #1{\XINT_fladd_chkopt \xintfloat #1\Z }% @@ -11739,7 +13790,7 @@ first place. \def\XINTinfloatadd #1{\XINT_fladd_chkopt \XINT_inFloat #1\Z }% \def\XINT_fladd_chkopt #1#2% {% - \ifx #2[\expandafter\XINT_fladd_opt + \ifx [#2\expandafter\XINT_fladd_opt \else\expandafter\XINT_fladd_noopt \fi #1#2% }% @@ -11782,6 +13833,7 @@ first place. \def\XINT_FL_Add_zerobis 0\XINT_FL_Add_d #1[#2]0[0]#3{#1[#2]}% % \end{macrocode} % \subsection{\csh{xintFloatSub}} +% \lverb|1.07| % \begin{macrocode} \def\xintFloatSub {\romannumeral0\xintfloatsub }% \def\xintfloatsub #1{\XINT_flsub_chkopt \xintfloat #1\Z }% @@ -11789,7 +13841,7 @@ first place. \def\XINTinfloatsub #1{\XINT_flsub_chkopt \XINT_inFloat #1\Z }% \def\XINT_flsub_chkopt #1#2% {% - \ifx #2[\expandafter\XINT_flsub_opt + \ifx [#2\expandafter\XINT_flsub_opt \else\expandafter\XINT_flsub_noopt \fi #1#2% }% @@ -11803,6 +13855,7 @@ first place. }% % \end{macrocode} % \subsection{\csh{xintFloatMul}} +% \lverb|1.07| % \begin{macrocode} \def\xintFloatMul {\romannumeral0\xintfloatmul}% \def\xintfloatmul #1{\XINT_flmul_chkopt \xintfloat #1\Z }% @@ -11810,7 +13863,7 @@ first place. \def\XINTinfloatmul #1{\XINT_flmul_chkopt \XINT_inFloat #1\Z }% \def\XINT_flmul_chkopt #1#2% {% - \ifx #2[\expandafter\XINT_flmul_opt + \ifx [#2\expandafter\XINT_flmul_opt \else\expandafter\XINT_flmul_noopt \fi #1#2% }% @@ -11834,6 +13887,7 @@ first place. \def\XINT_FL_Mul_b #1[#2]#3[#4]{\xintE{\xintiMul {#1}{#3}}{#2+#4}}% % \end{macrocode} % \subsection{\csh{xintFloatDiv}} +% \lverb|1.07| % \begin{macrocode} \def\xintFloatDiv {\romannumeral0\xintfloatdiv}% \def\xintfloatdiv #1{\XINT_fldiv_chkopt \xintfloat #1\Z }% @@ -11841,7 +13895,7 @@ first place. \def\XINTinfloatdiv #1{\XINT_fldiv_chkopt \XINT_inFloat #1\Z }% \def\XINT_fldiv_chkopt #1#2% {% - \ifx #2[\expandafter\XINT_fldiv_opt + \ifx [#2\expandafter\XINT_fldiv_opt \else\expandafter\XINT_fldiv_noopt \fi #1#2% }% @@ -11865,6 +13919,7 @@ first place. \def\XINT_FL_Div_b #1[#2]#3[#4]{\xintE{#3/#1}{#4-#2}}% % \end{macrocode} % \subsection{\csh{xintFloatPow}} +% \lverb|1.07| % \begin{macrocode} \def\xintFloatPow {\romannumeral0\xintfloatpow}% \def\xintfloatpow #1{\XINT_flpow_chkopt \xintfloat #1\Z }% @@ -11872,7 +13927,7 @@ first place. \def\XINTinfloatpow #1{\XINT_flpow_chkopt \XINT_inFloat #1\Z }% \def\XINT_flpow_chkopt #1#2% {% - \ifx #2[\expandafter\XINT_flpow_opt + \ifx [#2\expandafter\XINT_flpow_opt \else\expandafter\XINT_flpow_noopt \fi #1#2% @@ -12007,6 +14062,7 @@ first place. }% % \end{macrocode} % \subsection{\csh{xintFloatPower}} +% \lverb|1.07| % \begin{macrocode} \def\xintFloatPower {\romannumeral0\xintfloatpower}% \def\xintfloatpower #1{\XINT_flpower_chkopt \xintfloat #1\Z }% @@ -12014,7 +14070,7 @@ first place. \def\XINTinfloatpower #1{\XINT_flpower_chkopt \XINT_inFloat #1\Z }% \def\XINT_flpower_chkopt #1#2% {% - \ifx #2[\expandafter\XINT_flpower_opt + \ifx [#2\expandafter\XINT_flpower_opt \else\expandafter\XINT_flpower_noopt \fi #1#2% @@ -12107,6 +14163,188 @@ first place. {% \XINT_flpower_loop {#1}{#2}{#3}% }% +% \end{macrocode} +% \subsection{\csh{xintFloatSqrt}} +% \lverb|1.08| +% \begin{macrocode} +\def\xintFloatSqrt {\romannumeral0\xintfloatsqrt }% +\def\xintfloatsqrt #1{\XINT_flsqrt_chkopt \xintfloat #1\Z }% +\def\XINTinFloatSqrt {\romannumeral-`0\XINTinfloatsqrt }% +\def\XINTinfloatsqrt #1{\XINT_flsqrt_chkopt \XINT_inFloat #1\Z }% +\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\Z +{% + #1[\XINT_digits]{\XINT_FL_sqrt \XINT_digits {#2}}% +}% +\def\XINT_flsqrt_opt #1[\Z #2]#3% +{% + #1[#2]{\XINT_FL_sqrt {#2}{#3}}% +}% +\def\XINT_FL_sqrt #1% +{% + \ifnum\numexpr #1<\xint_c_xviii + \xint_afterfi {\XINT_FL_sqrt_a\xint_c_xviii}% + \else + \xint_afterfi {\XINT_FL_sqrt_a {#1+\xint_c_i}}% + \fi +}% +\def\XINT_FL_sqrt_a #1#2% +{% + \expandafter\XINT_FL_sqrt_checkifzeroorneg + \romannumeral-`0\XINT_inFloat [#1]{#2}% +}% +\def\XINT_FL_sqrt_checkifzeroorneg #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_FL_sqrt_iszero + 0#1\dummy \XINT_FL_sqrt_isneg + 0-\dummy {\XINT_FL_sqrt_b #1}% + \krof +}% +\def\XINT_FL_sqrt_iszero #1[#2]{0[0]}% +\def\XINT_FL_sqrt_isneg #1[#2]{\xintError:RootOfNegative 0[0]}% +\def\XINT_FL_sqrt_b #1[#2]% +{% + \ifodd #2 + \xint_afterfi{\XINT_FL_sqrt_c 01}% + \else + \xint_afterfi{\XINT_FL_sqrt_c {}0}% + \fi + {#1}{#2}% +}% +\def\XINT_FL_sqrt_c #1#2#3#4% +{% + \expandafter\XINT_flsqrt\expandafter {\the\numexpr #4-#2}{#3#1}% +}% +\def\XINT_flsqrt #1#2% +{% + \expandafter\XINT_sqrt_a + \expandafter{\romannumeral0\XINT_length {#2}}\XINT_flsqrt_big_d {#2}{#1}% +}% +\def\XINT_flsqrt_big_d #1\or #2\fi #3% +{% + \fi + \ifodd #3 + \xint_afterfi{\expandafter\XINT_flsqrt_big_eB}% + \else + \xint_afterfi{\expandafter\XINT_flsqrt_big_eA}% + \fi + \expandafter {\the\numexpr (#3-\xint_c_i)/\xint_c_ii }{#1}% +}% +\def\XINT_flsqrt_big_eA #1#2#3% +{% + \XINT_flsqrt_big_eA_a #3\Z {#2}{#1}{#3}% +}% +\def\XINT_flsqrt_big_eA_a #1#2#3#4#5#6#7#8#9\Z +{% + \XINT_flsqrt_big_eA_b {#1#2#3#4#5#6#7#8}% +}% +\def\XINT_flsqrt_big_eA_b #1#2% +{% + \expandafter\XINT_flsqrt_big_f + \romannumeral0\XINT_flsqrt_small_e {#2001}{#1}% +}% +\def\XINT_flsqrt_big_eB #1#2#3% +{% + \XINT_flsqrt_big_eB_a #3\Z {#2}{#1}{#3}% +}% +\def\XINT_flsqrt_big_eB_a #1#2#3#4#5#6#7#8#9% +{% + \XINT_flsqrt_big_eB_b {#1#2#3#4#5#6#7#8#9}% +}% +\def\XINT_flsqrt_big_eB_b #1#2\Z #3% +{% + \expandafter\XINT_flsqrt_big_f + \romannumeral0\XINT_flsqrt_small_e {#30001}{#1}% +}% +\def\XINT_flsqrt_small_e #1#2% +{% + \expandafter\XINT_flsqrt_small_f\expandafter + {\the\numexpr #1*#1-#2-\xint_c_i}{#1}% +}% +\def\XINT_flsqrt_small_f #1#2% +{% + \expandafter\XINT_flsqrt_small_g\expandafter + {\the\numexpr (#1+#2)/(2*#2)-\xint_c_i }{#1}{#2}% +}% +\def\XINT_flsqrt_small_g #1% +{% + \ifnum #1>\xint_c_ + \expandafter\XINT_flsqrt_small_h + \else + \expandafter\XINT_flsqrt_small_end + \fi + {#1}% +}% +\def\XINT_flsqrt_small_h #1#2#3% +{% + \expandafter\XINT_flsqrt_small_f\expandafter + {\the\numexpr #2-\xint_c_ii*#1*#3+#1*#1\expandafter}\expandafter + {\the\numexpr #3-#1}% +}% +\def\XINT_flsqrt_small_end #1#2#3% +{% + \expandafter\space\expandafter + {\the\numexpr \xint_c_i+#3*\xint_c_x^iv- + (#2*\xint_c_x^iv+#3)/(\xint_c_ii*#3)}% +}% +\def\XINT_flsqrt_big_f #1% +{% + \expandafter\XINT_flsqrt_big_fa\expandafter + {\romannumeral0\xintisqr {#1}}{#1}% +}% +\def\XINT_flsqrt_big_fa #1#2#3#4% +{% + \expandafter\XINT_flsqrt_big_fb\expandafter + {\romannumeral-`0\XINT_dsx_addzerosnofuss + {\numexpr #3-\xint_c_viii\relax}{#2}}% + {\romannumeral0\xintisub + {\XINT_dsx_addzerosnofuss + {\numexpr \xint_c_ii*(#3-\xint_c_viii)\relax}{#1}}{#4}}% + {#3}% +}% +\def\XINT_flsqrt_big_fb #1#2% +{% + \expandafter\XINT_flsqrt_big_g\expandafter {#2}{#1}% +}% +\def\XINT_flsqrt_big_g #1#2% +{% + \expandafter\XINT_flsqrt_big_j + \romannumeral0\xintidivision + {#1}{\romannumeral0\XINT_dbl_pos #2\R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W }{#2}% +}% +\def\XINT_flsqrt_big_j #1% +{% + \ifcase\XINT_Sgn {#1} + \expandafter \XINT_flsqrt_big_end_a + \or \expandafter \XINT_flsqrt_big_k + \fi {#1}% +}% +\def\XINT_flsqrt_big_k #1#2#3% +{% + \expandafter\XINT_flsqrt_big_l\expandafter + {\romannumeral0\XINT_sub_pre {#3}{#1}}% + {\romannumeral0\xintiadd {#2}{\romannumeral0\XINT_sqr {#1}}}% +}% +\def\XINT_flsqrt_big_l #1#2% +{% + \expandafter\XINT_flsqrt_big_g\expandafter + {#2}{#1}% +}% +\def\XINT_flsqrt_big_end_a #1#2#3#4#5% +{% + \expandafter\XINT_flsqrt_big_end_b\expandafter + {\the\numexpr -#4+#5/\xint_c_ii\expandafter}\expandafter + {\romannumeral0\xintisub + {\XINT_dsx_addzerosnofuss {#4}{#3}}% + {\xintHalf{\xintiQuo{\XINT_dsx_addzerosnofuss {#4}{#2}}{#3}}}}% +}% +\def\XINT_flsqrt_big_end_b #1#2{#2[#1]}% \XINT_frac_restorecatcodes_endinput% % \end{macrocode} %\catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11 @@ -12230,6 +14468,7 @@ first place. {% \catcode93=\the\catcode93 % ] \catcode91=\the\catcode91 % [ + \catcode94=\the\catcode94 % ^ \catcode96=\the\catcode96 % ` \catcode47=\the\catcode47 % / \catcode41=\the\catcode41 % ) @@ -12252,7 +14491,7 @@ first place. \catcode61=\the\catcode61\relax % = \noexpand\endinput }% - \XINT_setcatcodes + \XINT_setcatcodes % defined in xint.sty \catcode91=12 % [ \catcode93=12 % ] }% @@ -12281,23 +14520,21 @@ first place. \fi \expandafter\x\csname ver@xintseries.sty\endcsname \ProvidesPackage{xintseries}% - [2013/05/26 v1.07a Expandable partial sums with xint package (jfB)]% + [2013/06/14 v1.08b Expandable partial sums with xint package (jfB)]% % \end{macrocode} % \subsection{\csh{xintSeries}} % \lverb|& % Modified in 1.06 to give the indices first to a \numexpr rather than expanding -% twice. I just use \the\numexpr and maintain the previous code after that.| +% twice. I just use \the\numexpr and maintain the previous code after that. +% 1.08a adds the forgotten optimization following that previous change.| % \begin{macrocode} \def\xintSeries {\romannumeral0\xintseries }% \def\xintseries #1#2% {% - \expandafter\XINT_series_i\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_series\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_series_i #1#2% -{% - \expandafter\XINT_series_ii\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_series_ii #1#2#3% +\def\XINT_series #1#2#3% {% \ifnum #2<#1 \xint_afterfi { 0/1[0]}% @@ -12321,18 +14558,16 @@ first place. % \subsection{\csh{xintiSeries}} % \lverb|& % Modified in 1.06 to give the indices first to a \numexpr rather than expanding -% twice. I just use \the\numexpr and maintain the previous code after that.| +% twice. I just use \the\numexpr and maintain the previous code after that. +% 1.08a adds the forgotten optimization following that previous change.| % \begin{macrocode} \def\xintiSeries {\romannumeral0\xintiseries }% \def\xintiseries #1#2% {% - \expandafter\XINT_iseries_i\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_iseries_i #1#2% -{% - \expandafter\XINT_iseries_ii\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_iseries\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_iseries_ii #1#2#3% +\def\XINT_iseries #1#2#3% {% \ifnum #2<#1 \xint_afterfi { 0}% @@ -12360,18 +14595,16 @@ first place. % cures the denominator problem and drastically improves the efficiency % of the macro. % Modified in 1.06 to give the indices first to a \numexpr rather than expanding -% twice. I just use \the\numexpr and maintain the previous code after that.| +% twice. I just use \the\numexpr and maintain the previous code after that. +% 1.08a adds the forgotten optimization following that previous change.| % \begin{macrocode} \def\xintPowerSeries {\romannumeral0\xintpowerseries }% \def\xintpowerseries #1#2% {% - \expandafter\XINT_powseries_i\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_powseries_i #1#2% -{% - \expandafter\XINT_powseries_ii\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_powseries\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_powseries_ii #1#2#3#4% +\def\XINT_powseries #1#2#3#4% {% \ifnum #2<#1 \xint_afterfi { 0/1[0]}% @@ -12405,18 +14638,16 @@ first place. % \lverb|& % Same as \xintPowerSeries except for the initial expansion of the x parameter. % Modified in 1.06 to give the indices first to a \numexpr rather than expanding -% twice. I just use \the\numexpr and maintain the previous code after that.| +% twice. I just use \the\numexpr and maintain the previous code after that. +% 1.08a adds the forgotten optimization following that previous change.| % \begin{macrocode} \def\xintPowerSeriesX {\romannumeral0\xintpowerseriesx }% \def\xintpowerseriesx #1#2% {% - \expandafter\XINT_powseriesx_i\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_powseriesx\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_powseriesx_i #1#2% -{% - \expandafter\XINT_powseriesx_ii\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_powseriesx_ii #1#2#3#4% +\def\XINT_powseriesx #1#2#3#4% {% \ifnum #2<#1 \xint_afterfi { 0/1[0]}% @@ -12441,18 +14672,16 @@ first place. % inaccessible to \xintSeries. % #1=a, #2=b, #3=F(a), #4=ratio function % Modified in 1.06 to give the indices first to a \numexpr rather than expanding -% twice. I just use \the\numexpr and maintain the previous code after that.| +% twice. I just use \the\numexpr and maintain the previous code after that. +% 1.08a adds the forgotten optimization following that previous change.| % \begin{macrocode} \def\xintRationalSeries {\romannumeral0\xintratseries }% \def\xintratseries #1#2% {% - \expandafter\XINT_ratseries_i\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_ratseries_i #1#2% -{% - \expandafter\XINT_ratseries_ii\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_ratseries\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_ratseries_ii #1#2#3#4% +\def\XINT_ratseries #1#2#3#4% {% \ifnum #2<#1 \xint_afterfi { 0/1[0]}% @@ -12489,18 +14718,16 @@ first place. % resulting from this which is used then throughout. The initial term F(a,x) % must be defined as one-parameter macro which will be given x. % Modified in 1.06 to give the indices first to a \numexpr rather than expanding -% twice. I just use \the\numexpr and maintain the previous code after that.| +% twice. I just use \the\numexpr and maintain the previous code after that. +% 1.08a adds the forgotten optimization following that previous change.| % \begin{macrocode} \def\xintRationalSeriesX {\romannumeral0\xintratseriesx }% \def\xintratseriesx #1#2% {% - \expandafter\XINT_ratseriesx_i\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_ratseriesx_i #1#2% -{% - \expandafter\XINT_ratseriesx_ii\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_ratseriesx\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_ratseriesx_ii #1#2#3#4#5% +\def\XINT_ratseriesx #1#2#3#4#5% {% \ifnum #2<#1 \xint_afterfi { 0/1[0]}% @@ -12521,18 +14748,16 @@ first place. % I am not two happy with this piece of code. Will make it more economical % another day. % Modified in 1.06 to give the indices first to a \numexpr rather than expanding -% twice. I just use \the\numexpr and maintain the previous code after that.| +% twice. I just use \the\numexpr and maintain the previous code after that. +% 1.08a: forgot last time some optimization from the change to \numexpr.| % \begin{macrocode} \def\xintFxPtPowerSeries {\romannumeral0\xintfxptpowerseries }% \def\xintfxptpowerseries #1#2% {% - \expandafter\XINT_fppowseries_i\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_fppowseries_i #1#2% -{% - \expandafter\XINT_fppowseries_ii\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_fppowseries\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_fppowseries_ii #1#2#3#4#5% +\def\XINT_fppowseries #1#2#3#4#5% {% \ifnum #2<#1 \xint_afterfi { 0}% @@ -12548,7 +14773,7 @@ first place. {% \ifnum #4>#2 \else\XINT_fppowseries_dont_i \fi \expandafter\XINT_fppowseries_loop_i\expandafter - {\the\numexpr #2+1\expandafter}\expandafter + {\the\numexpr #2+\xint_c_i\expandafter}\expandafter {\romannumeral0\xintitrunc {#6}{\xintMul {#5{#2}}{#1}}}% {#1}{#3}{#4}{#5}{#6}% }% @@ -12565,7 +14790,7 @@ first place. \def\XINT_fppowseries_loop_ii #1#2#3#4#5#6#7% {% \expandafter\XINT_fppowseries_loop_i\expandafter - {\the\numexpr #2+1\expandafter}\expandafter + {\the\numexpr #2+\xint_c_i\expandafter}\expandafter {\romannumeral0\xintiadd {#4}{\xintiTrunc {#7}{\xintMul {#6{#2}}{#1}}}}% {#1}{#3}{#5}{#6}{#7}% }% @@ -12581,18 +14806,16 @@ first place. % \lverb|& % a,b,coeff,x,D$\ % Modified in 1.06 to give the indices first to a \numexpr rather than expanding -% twice. I just use \the\numexpr and maintain the previous code after that.| +% twice. I just use \the\numexpr and maintain the previous code after that. +% 1.08a adds the forgotten optimization following that previous change.| % \begin{macrocode} \def\xintFxPtPowerSeriesX {\romannumeral0\xintfxptpowerseriesx }% \def\xintfxptpowerseriesx #1#2% {% - \expandafter\XINT_fppowseriesx_i\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_fppowseriesx\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_fppowseriesx_i #1#2% -{% - \expandafter\XINT_fppowseriesx_ii\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_fppowseriesx_ii #1#2#3#4#5% +\def\XINT_fppowseriesx #1#2#3#4#5% {% \ifnum #2<#1 \xint_afterfi { 0}% @@ -12609,6 +14832,118 @@ first place. {\romannumeral0\xinttrunc {#5}{\xintPow {#1}{#2}}}% {#2}{#1}{#3}{#4}{#5}% }% +% \end{macrocode} +% \subsection{\csh{xintFloatPowerSeries}} +% \lverb|1.08a. I still have to re-visit \xintFxPtPowerSeries; temporarily I +% just adapted the code to the case of floats.| +% \begin{macrocode} +\def\xintFloatPowerSeries {\romannumeral0\xintfloatpowerseries }% +\def\xintfloatpowerseries #1{\XINT_flpowseries_chkopt #1\Z }% +\def\XINT_flpowseries_chkopt #1% +{% + \ifx [#1\expandafter\XINT_flpowseries_opt + \else\expandafter\XINT_flpowseries_noopt + \fi + #1% +}% +\def\XINT_flpowseries_noopt #1\Z #2% +{% + \expandafter\XINT_flpowseries\expandafter + {\the\numexpr #1\expandafter}\expandafter + {\the\numexpr #2}\XINT_digits +}% +\def\XINT_flpowseries_opt [\Z #1]#2#3% +{% + \expandafter\XINT_flpowseries\expandafter + {\the\numexpr #2\expandafter}\expandafter + {\the\numexpr #3\expandafter}{\the\numexpr #1}% +}% +\def\XINT_flpowseries #1#2#3#4#5% +{% + \ifnum #2<#1 + \xint_afterfi { 0.e0}% + \else + \xint_afterfi + {\expandafter\XINT_flpowseries_loop_pre\expandafter + {\romannumeral-`0\XINTinfloatpow [#3]{#5}{#1}}% + {#1}{#5}{#2}{#4}{#3}% + }% + \fi +}% +\def\XINT_flpowseries_loop_pre #1#2#3#4#5#6% +{% + \ifnum #4>#2 \else\XINT_flpowseries_dont_i \fi + \expandafter\XINT_flpowseries_loop_i\expandafter + {\the\numexpr #2+\xint_c_i\expandafter}\expandafter + {\romannumeral-`0\XINTinfloatmul [#6]{#5{#2}}{#1}}% + {#1}{#3}{#4}{#5}{#6}% +}% +\def\XINT_flpowseries_dont_i \fi\expandafter\XINT_flpowseries_loop_i + {\fi \expandafter\XINT_flpowseries_dont_ii }% +\def\XINT_flpowseries_dont_ii #1#2#3#4#5#6#7{\xintfloat [#7]{#2}}% +\def\XINT_flpowseries_loop_i #1#2#3#4#5#6#7% +{% + \ifnum #5>#1 \else \XINT_flpowseries_exit_i \fi + \expandafter\XINT_flpowseries_loop_ii\expandafter + {\romannumeral-`0\XINTinfloatmul [#7]{#3}{#4}}% + {#1}{#4}{#2}{#5}{#6}{#7}% +}% +\def\XINT_flpowseries_loop_ii #1#2#3#4#5#6#7% +{% + \expandafter\XINT_flpowseries_loop_i\expandafter + {\the\numexpr #2+\xint_c_i\expandafter}\expandafter + {\romannumeral-`0\XINTinfloatadd [#7]{#4}% + {\XINTinfloatmul [#7]{#6{#2}}{#1}}}% + {#1}{#3}{#5}{#6}{#7}% +}% +\def\XINT_flpowseries_exit_i\fi\expandafter\XINT_flpowseries_loop_ii + {\fi \expandafter\XINT_flpowseries_exit_ii }% +\def\XINT_flpowseries_exit_ii #1#2#3#4#5#6#7% +{% + \xintfloatadd [#7]{#4}{\XINTinfloatmul [#7]{#6{#2}}{#1}}% +}% +% \end{macrocode} +% \subsection{\csh{xintFloatPowerSeriesX}} +% \lverb|1.08a| +% \begin{macrocode} +\def\xintFloatPowerSeriesX {\romannumeral0\xintfloatpowerseriesx }% +\def\xintfloatpowerseriesx #1{\XINT_flpowseriesx_chkopt #1\Z }% +\def\XINT_flpowseriesx_chkopt #1% +{% + \ifx [#1\expandafter\XINT_flpowseriesx_opt + \else\expandafter\XINT_flpowseriesx_noopt + \fi + #1% +}% +\def\XINT_flpowseriesx_noopt #1\Z #2% +{% + \expandafter\XINT_flpowseriesx\expandafter + {\the\numexpr #1\expandafter}\expandafter + {\the\numexpr #2}\XINT_digits +}% +\def\XINT_flpowseriesx_opt [\Z #1]#2#3% +{% + \expandafter\XINT_flpowseriesx\expandafter + {\the\numexpr #2\expandafter}\expandafter + {\the\numexpr #3\expandafter}{\the\numexpr #1}% +}% +\def\XINT_flpowseriesx #1#2#3#4#5% +{% + \ifnum #2<#1 + \xint_afterfi { 0.e0}% + \else + \xint_afterfi + {\expandafter \XINT_flpowseriesx_pre \expandafter + {\romannumeral-`0#5}{#1}{#2}{#4}{#3}% + }% + \fi +}% +\def\XINT_flpowseriesx_pre #1#2#3#4#5% +{% + \expandafter\XINT_flpowseries_loop_pre\expandafter + {\romannumeral-`0\XINTinfloatpow [#5]{#1}{#2}}% + {#2}{#1}{#3}{#4}{#5}% +}% \XINT_series_restorecatcodes_endinput% % \end{macrocode} %\catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11 @@ -12732,6 +15067,7 @@ first place. {% \catcode93=\the\catcode93 % ] \catcode91=\the\catcode91 % [ + \catcode94=\the\catcode94 % ^ \catcode96=\the\catcode96 % ` \catcode47=\the\catcode47 % / \catcode41=\the\catcode41 % ) @@ -12754,7 +15090,7 @@ first place. \catcode61=\the\catcode61\relax % = \noexpand\endinput }% - \XINT_setcatcodes + \XINT_setcatcodes % defined in xint.sty \catcode91=12 % [ \catcode93=12 % ] }% @@ -12783,7 +15119,7 @@ first place. \fi \expandafter\x\csname ver@xintcfrac.sty\endcsname \ProvidesPackage{xintcfrac}% - [2013/05/26 v1.07a Expandable continued fractions with xint package (jfB)]% + [2013/06/14 v1.08b Expandable continued fractions with xint package (jfB)]% % \end{macrocode} % \subsection{\csh{xintCFrac}} % \begin{macrocode} @@ -12794,7 +15130,7 @@ first place. }% \def\XINT_cfrac_opt_a #1% {% - \ifx#1[\XINT_cfrac_opt_b\fi \XINT_cfrac_noopt #1% + \ifx[#1\XINT_cfrac_opt_b\fi \XINT_cfrac_noopt #1% }% \def\XINT_cfrac_noopt #1\Z {% @@ -12854,13 +15190,13 @@ first place. {\XINT_cfrac_T #5#6{#2}#4\Z }% \def\XINT_cfrac_T #1#2#3#4% {% - \xint_gob_til_z #4\XINT_cfrac_end\Z\XINT_cfrac_T #1#2{#4+\cfrac{#11#2}{#3}}% + \xint_gob_til_Z #4\XINT_cfrac_end\Z\XINT_cfrac_T #1#2{#4+\cfrac{#11#2}{#3}}% }% \def\XINT_cfrac_end\Z\XINT_cfrac_T #1#2#3% {% - \XINT_cfrac__end #3% + \XINT_cfrac_end_b #3% }% -\def\XINT_cfrac__end \Z+\cfrac#1#2{ #2}% +\def\XINT_cfrac_end_b \Z+\cfrac#1#2{ #2}% % \end{macrocode} % \subsection{\csh{xintGCFrac}} % \begin{macrocode} @@ -12868,7 +15204,7 @@ first place. \def\xintgcfrac #1{\XINT_gcfrac_opt_a #1\Z }% \def\XINT_gcfrac_opt_a #1% {% - \ifx#1[\XINT_gcfrac_opt_b\fi \XINT_gcfrac_noopt #1% + \ifx[#1\XINT_gcfrac_opt_b\fi \XINT_gcfrac_noopt #1% }% \def\XINT_gcfrac_noopt #1\Z {% @@ -12897,7 +15233,7 @@ first place. \def\XINT_gcfrac_enter {\XINT_gcfrac_loop {}}% \def\XINT_gcfrac_loop #1#2+#3/% {% - \xint_gob_til_w #3\XINT_gcfrac_endloop\W + \xint_gob_til_W #3\XINT_gcfrac_endloop\W \XINT_gcfrac_loop {{#3}{#2}#1}% }% \def\XINT_gcfrac_endloop\W\XINT_gcfrac_loop #1#2#3% @@ -12907,7 +15243,7 @@ first place. \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_z #5\XINT_gcfrac_end\Z\XINT_gcfrac_U + \xint_gob_til_Z #5\XINT_gcfrac_end\Z\XINT_gcfrac_U #1#2{\xintFrac{#5}% \ifcase\xintSgn{#4} +\or+\else-\fi @@ -12915,9 +15251,9 @@ first place. }% \def\XINT_gcfrac_end\Z\XINT_gcfrac_U #1#2#3% {% - \XINT_gcfrac__end #3% + \XINT_gcfrac_end_b #3% }% -\def\XINT_gcfrac__end #1\cfrac#2#3{ #3}% +\def\XINT_gcfrac_end_b #1\cfrac#2#3{ #3}% % \end{macrocode} % \subsection{\csh{xintGCtoGCx}} % \begin{macrocode} @@ -12929,7 +15265,7 @@ first place. \def\XINT_gctgcx_start #1#2#3{\XINT_gctgcx_loop_a {}{#2}{#3}#1+\W/}% \def\XINT_gctgcx_loop_a #1#2#3#4+#5/% {% - \xint_gob_til_w #5\XINT_gctgcx_end\W + \xint_gob_til_W #5\XINT_gctgcx_end\W \XINT_gctgcx_loop_b {#1{#4}}{#2{#5}#3}{#2}{#3}% }% \def\XINT_gctgcx_loop_b #1#2% @@ -13124,7 +15460,7 @@ first place. }% \def\XINT_cstf_loop_a #1#2#3#4#5,% {% - \xint_gob_til_w #5\XINT_cstf_end\W + \xint_gob_til_W #5\XINT_cstf_end\W \expandafter\XINT_cstf_loop_b \romannumeral0\xintrawwithzeros {#5}.{#1}{#2}{#3}{#4}% }% @@ -13163,7 +15499,7 @@ first place. }% \def\XINT_icstf_loop_a #1#2#3#4#5,% {% - \xint_gob_til_w #5\XINT_icstf_end\W + \xint_gob_til_W #5\XINT_icstf_end\W \expandafter \XINT_icstf_loop_b \romannumeral-`0#5.{#1}{#2}{#3}{#4}% }% @@ -13218,7 +15554,7 @@ first place. }% \def\XINT_gctf_loop_f #1#2/% {% - \xint_gob_til_w #2\XINT_gctf_end\W + \xint_gob_til_W #2\XINT_gctf_end\W \expandafter\XINT_gctf_loop_g \romannumeral0\xintrawwithzeros {#2}.#1% }% @@ -13273,7 +15609,7 @@ first place. }% \def\XINT_igctf_loop_f #1#2#3#4/% {% - \xint_gob_til_w #4\XINT_igctf_end\W + \xint_gob_til_W #4\XINT_igctf_end\W \expandafter\XINT_igctf_loop_g \romannumeral-`0#4.{#2}{#3}#1% }% @@ -13306,7 +15642,7 @@ first place. }% \def\XINT_cstcv_loop_a #1#2#3#4#5#6,% {% - \xint_gob_til_w #6\XINT_cstcv_end\W + \xint_gob_til_W #6\XINT_cstcv_end\W \expandafter\XINT_cstcv_loop_b \romannumeral0\xintrawwithzeros {#6}.{#2}{#3}{#4}{#5}{#1}% }% @@ -13351,7 +15687,7 @@ first place. }% \def\XINT_icstcv_loop_a #1#2#3#4#5#6,% {% - \xint_gob_til_w #6\XINT_icstcv_end\W + \xint_gob_til_W #6\XINT_icstcv_end\W \expandafter \XINT_icstcv_loop_b \romannumeral-`0#6.{#2}{#3}{#4}{#5}{#1}% }% @@ -13421,7 +15757,7 @@ first place. }% \def\XINT_gctcv_loop_h #1#2#3/% {% - \xint_gob_til_w #3\XINT_gctcv_end\W + \xint_gob_til_W #3\XINT_gctcv_end\W \expandafter\XINT_gctcv_loop_i \romannumeral0\xintrawwithzeros {#3}.#2{#1}% }% @@ -13477,7 +15813,7 @@ first place. }% \def\XINT_igctcv_loop_f #1#2#3#4/% {% - \xint_gob_til_w #4\XINT_igctcv_end_a\W + \xint_gob_til_W #4\XINT_igctcv_end_a\W \expandafter\XINT_igctcv_loop_g \romannumeral-`0#4.#1#2{#3}% }% @@ -13518,13 +15854,13 @@ first place. }% \def\XINT_cntf #1#2% {% - \ifnum #1>0 + \ifnum #1>\xint_c_ \xint_afterfi {\expandafter\XINT_cntf_loop\expandafter {\the\numexpr #1-1\expandafter}\expandafter {\romannumeral-`0#2{#1}}{#2}}% \else \xint_afterfi - {\ifnum #1=0 + {\ifnum #1=\xint_c_ \xint_afterfi {\expandafter\space \romannumeral-`0#2{0}}% \else \xint_afterfi { 0/1[0]}% \fi}% @@ -13532,7 +15868,7 @@ first place. }% \def\XINT_cntf_loop #1#2#3% {% - \ifnum #1>0 \else \XINT_cntf_exit \fi + \ifnum #1>\xint_c_ \else \XINT_cntf_exit \fi \expandafter\XINT_cntf_loop\expandafter {\the\numexpr #1-1\expandafter }\expandafter {\romannumeral0\xintadd {\xintDiv {1[0]}{#2}}{#3{#1}}}% @@ -13557,13 +15893,13 @@ first place. }% \def\XINT_gcntf #1#2#3% {% - \ifnum #1>0 + \ifnum #1>\xint_c_ \xint_afterfi {\expandafter\XINT_gcntf_loop\expandafter {\the\numexpr #1-1\expandafter}\expandafter {\romannumeral-`0#2{#1}}{#2}{#3}}% \else \xint_afterfi - {\ifnum #1=0 + {\ifnum #1=\xint_c_ \xint_afterfi {\expandafter\space\romannumeral-`0#2{0}}% \else \xint_afterfi { 0/1[0]}% \fi}% @@ -13571,7 +15907,7 @@ first place. }% \def\XINT_gcntf_loop #1#2#3#4% {% - \ifnum #1>0 \else \XINT_gcntf_exit \fi + \ifnum #1>\xint_c_ \else \XINT_gcntf_exit \fi \expandafter\XINT_gcntf_loop\expandafter {\the\numexpr #1-1\expandafter }\expandafter {\romannumeral0\xintadd {\xintDiv {#4{#1}}{#2}}{#3{#1}}}% @@ -13615,9 +15951,9 @@ first place. \expandafter\XINT_cntcs_loop\expandafter #1\expandafter #2#3% {% - \fi\XINT_cntcs__exit #2% + \fi\XINT_cntcs_exit_b #2% }% -\def\XINT_cntcs__exit #1,{ }% +\def\XINT_cntcs_exit_b #1,{ }% % \end{macrocode} % \subsection{\csh{xintCntoGC}} % \lverb|& @@ -13650,9 +15986,9 @@ first place. \expandafter\XINT_cntgc_loop\expandafter #1\expandafter #2#3% {% - \fi\XINT_cntgc__exit #2% + \fi\XINT_cntgc_exit_b #2% }% -\def\XINT_cntgc__exit #1+1/{ }% +\def\XINT_cntgc_exit_b #1+1/{ }% % \end{macrocode} % \subsection{\csh{xintGCntoGC}} % \lverb|& @@ -13689,9 +16025,9 @@ first place. \def\XINT_gcntgc_exit \fi \expandafter\XINT_gcntgc_loop_b\expandafter #1#2#3#4#5% {% - \fi\XINT_gcntgc__exit #1% + \fi\XINT_gcntgc_exit_b #1% }% -\def\XINT_gcntgc__exit #1/{ }% +\def\XINT_gcntgc_exit_b #1/{ }% % \end{macrocode} % \subsection{\csh{xintCstoGC}} % \begin{macrocode} @@ -13703,7 +16039,7 @@ first place. \def\XINT_cstc_prep #1,{\XINT_cstc_loop_a {{#1}}}% \def\XINT_cstc_loop_a #1#2,% {% - \xint_gob_til_w #2\XINT_cstc_end\W + \xint_gob_til_W #2\XINT_cstc_end\W \XINT_cstc_loop_b {#1}{#2}% }% \def\XINT_cstc_loop_b #1#2{\XINT_cstc_loop_a {#1+1/{#2}}}% @@ -13719,7 +16055,7 @@ first place. \def\XINT_gctgc_start {\XINT_gctgc_loop_a {}}% \def\XINT_gctgc_loop_a #1#2+#3/% {% - \xint_gob_til_w #3\XINT_gctgc_end\W + \xint_gob_til_W #3\XINT_gctgc_end\W \expandafter\XINT_gctgc_loop_b\expandafter {\romannumeral-`0#2}{#3}{#1}% }% @@ -13734,9 +16070,9 @@ first place. }% \def\XINT_gctgc_end\W\expandafter\XINT_gctgc_loop_b {% - \expandafter\XINT_gctgc__end + \expandafter\XINT_gctgc_end_b }% -\def\XINT_gctgc__end #1#2#3{ #3{#1}}% +\def\XINT_gctgc_end_b #1#2#3{ #3{#1}}% \XINT_cfrac_restorecatcodes_endinput% % \end{macrocode} %\catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11 @@ -13748,8 +16084,26 @@ first place. % % The commenting is currently (\docdate) very sparse. I was greatly helped in % the task of writing this expandable parser by the comments provided in -% |l3fp-parse.dtx|. Clearly some ressemblance with the |l3fp| code will be -% noticed, but there are some essential differences too. +% |l3fp-parse.dtx|. One will recognize in particular the idea of the `until' +% macros; but I have not looked into the actual |l3fp| code beyond the very +% useful comments provided in its documentation. My main hurdle was that my data +% has no a priori bound on its size; this led me to experiment with a technique +% of storing and retrieving data expandably as \emph{names} of control +% sequences. Also brace pairs have a special rôle related to the parsing of +% |A/B[n]| fractions; this is \emph{experimental} and perhaps I will opt for +% another solution at a later stage, +% for example one where such fractions should be user-prefixed by some marker, +% for example |!| (which could not be confused there with its other use as +% postfix symbol for the factorial function). There are thus some essential +% differences of principle with the |l3fp| workplan. Of course, my task was +% on the other hand simplified by the fact that I do not implement boolean +% operators nor function names. To circumvent the potential hash-table impact I +% have provided the macro creators |\xintNewExpr| and |\xintNewFloatExpr|. +% +% Version |1.08b| tries to correct a problem originating in the attempt to +% attribute a special rôle to braces: expansion could be stopped by space +% tokens, as various macros tried to expand without grabbing what came next. +% They now have a doubled |\romannumeral-`0|. % % \localtableofcontents % \subsection{Catcodes, \protect\eTeX{} and reload detection} @@ -13861,10 +16215,10 @@ first place. \endgroup \edef\XINT_expr_restorecatcodes_endinput {% - \catcode94=\the\catcode94 % ^ \catcode33=\the\catcode33 % ! \catcode93=\the\catcode93 % ] \catcode91=\the\catcode91 % [ + \catcode94=\the\catcode94 % ^ \catcode96=\the\catcode96 % ` \catcode47=\the\catcode47 % / \catcode41=\the\catcode41 % ) @@ -13887,11 +16241,10 @@ first place. \catcode61=\the\catcode61\relax % = \noexpand\endinput }% - \XINT_setcatcodes + \XINT_setcatcodes % defined in xint.sty \catcode91=12 % [ \catcode93=12 % ] \catcode33=11 % ! - \catcode94=12 % ^ }% \x % \end{macrocode} @@ -13918,17 +16271,10 @@ first place. \fi \expandafter\x\csname ver@xintexpr.sty\endcsname \ProvidesPackage{xintexpr}% - [2013/05/26 v1.07a Expandable expression parser (jfB)]% + [2013/06/14 v1.08b Expandable expression parser (jfB)]% % \end{macrocode} -% \subsection{Constants, helper macros...} +% \subsection{Helper macros} % \begin{macrocode} -\chardef\xint_c_ 0 -\chardef\xint_c_i 1 -\chardef\xint_c_ii 2 -\chardef\xint_c_iii 3 -\chardef\xint_c_iv 4 -\chardef\xint_c_v 5 -\chardef\xint_c_ix 9 \def\xint_gob_til_dot #1.{}% \def\xint_gob_til_dot_andstop #1.{ }% \def\xint_gob_til_! #1!{}% ! of catcode 11 @@ -13959,7 +16305,7 @@ first place. \or \expandafter\XINT_expr_extra_closing_paren \fi - \expandafter\XINT_expr_until_end\romannumeral-`0% + \expandafter\XINT_expr_until_end\romannumeral-`0\romannumeral-`0% }% \def\XINT_expr_extra_closing_paren {\xintError:removed }% \def\XINT_expr_endofexpr {!\XINT_illegaluse }% @@ -13976,7 +16322,8 @@ first place. \ifcase#1% \expandafter\XINT_expr_missing_cparen \or - \else \xint_afterfi{\expandafter\XINT_expr_until_cparen\romannumeral-`0}% + \else \xint_afterfi + {\expandafter\XINT_expr_until_cparen\romannumeral-`0\romannumeral-`0}% \fi }% \def\XINT_expr_missing_cparen #1% @@ -14013,13 +16360,13 @@ first place. \csname .#6{\XINT_expr_string ##1}{\XINT_expr_string ##4}\endcsname }% \fi }% - \global\let #4#5% + \let #4#5% }% \xint_tmp_def +{ii}{Add}% \xint_tmp_def -{ii}{Sub}% \xint_tmp_def *{iii}{Mul}% \xint_tmp_def /{iii}{Div}% -\xint_tmp_def ^{iv}{fPow}% +\xint_tmp_def ^{iv}{Pow}% \xint_tmp_def e{v}{fE}% \xint_tmp_def E{v}{fE}% \def\xint_tmp_def #1% @@ -14070,11 +16417,16 @@ first place. \xint_tmp_def {iv}% \xint_tmp_def {v}% % \end{macrocode} -% \subsection{Get next infix operator or closing parenthesis or factorial or expression end} +% \subsection{Get next infix operator or closing parenthesis or factorial or +% expression end} +% \lverb|June 14 (1.08b): I add here a second \romannumeral-`0, as in +% \XINT_expr_getnext and other macros which are trying to expand the next token +% but without grabbing it.| % \begin{macrocode} \def\XINT_expr_getop #1% {% - \expandafter\XINT_expr_getop_a\expandafter #1\romannumeral-`0% + \expandafter\XINT_expr_getop_a\expandafter #1% + \romannumeral-`0\romannumeral-`0% }% \def\XINT_expr_getop_a #1#2% {% @@ -14119,17 +16471,27 @@ first place. \expandafter\xint_firstoftwo \else\expandafter\xint_secondoftwo \fi{\expandafter\XINT_expr_getop}{\expandafter\XINT_flexpr_getop}% - \csname .\xintfFac{\XINT_expr_string ##2}/1[0]\endcsname }% + \csname .\xintFac{\XINT_expr_string ##2}/1[0]\endcsname }% \let#2\empty }% \xint_tmp_def % \end{macrocode} % \subsection{Get next opening parenthesis or minus prefix or decimal number or % braced fraction or sub-xintexpression} +% \lverb|June 14: 1.08b adds a second \romannumeral-`0 to \XINT_expr_getnext in +% an attempt to solve a problem with space tokens stopping the \romannumeral +% and thus preventing expansion of the following token. For example: 1+ +% \the\cnta caused a problem, as `\the' was not expanded. I did not define +% \XINT_expr_getnext as a macro with parameter (which would have cured +% preventively this), precisely to try to recognize brace pairs. The second +% \romannumeral-`0 is added here for the same reason in other places: +% \XINT_expr_scannum_intpart_b, \XINT_expr_scannum_transition, +% \XINT_expr_scannum_decpart_b, and \XINT_expr_getop.| % \begin{macrocode} \def\XINT_expr_getnext {% - \expandafter\XINT_expr_getnext_checkforbraced_a\romannumeral-`0% + \expandafter\XINT_expr_getnext_checkforbraced_a + \romannumeral-`0\romannumeral-`0% }% \def\XINT_expr_getnext_checkforbraced_a #1% {% @@ -14226,12 +16588,12 @@ first place. \def\XINT_expr_scannum_intpart_b #1% {% \expandafter #1\romannumeral-`0\expandafter - \XINT_expr_scannum_intpart_a\romannumeral-`0% + \XINT_expr_scannum_intpart_a\romannumeral-`0\romannumeral-`0% }% \def\XINT_expr_scannum_transition #1% {% \expandafter.\romannumeral-`0\expandafter - \XINT_expr_scannum_decpart_a\romannumeral-`0% + \XINT_expr_scannum_decpart_a\romannumeral-`0\romannumeral-`0% }% \def\XINT_expr_scannum_decpart_a #1% {% @@ -14246,10 +16608,12 @@ first place. \def\XINT_expr_scannum_decpart_b #1% {% \expandafter #1\romannumeral-`0\expandafter - \XINT_expr_scannum_decpart_a\romannumeral-`0% + \XINT_expr_scannum_decpart_a\romannumeral-`0\romannumeral-`0% }% % \end{macrocode} % \subsection{\csh{xintfloatexpr},~\csh{xintthefloatexpr}} +% \lverb|1.08b: various doublings of \romannumeral-`0 to avoid some +% expansion/space token problems| % \begin{macrocode} \def\xintfloatexpr {\romannumeral0\xintfloateval }% \def\xintfloateval @@ -14346,7 +16710,8 @@ first place. \let\xint_tmp_do_defs\empty \def\XINT_flexpr_getop #1% {% - \expandafter\XINT_flexpr_getop_a\expandafter #1\romannumeral-`0% + \expandafter\XINT_flexpr_getop_a\expandafter #1% + \romannumeral-`0\romannumeral-`0% }% \def\XINT_flexpr_getop_a #1#2% {% @@ -14378,7 +16743,8 @@ first place. \expandafter\let\csname XINT_flexpr_op_)\endcsname\XINT_flexpr_getop \def\XINT_flexpr_getnext {% - \expandafter\XINT_flexpr_getnext_checkforbraced_a\romannumeral-`0% + \expandafter\XINT_flexpr_getnext_checkforbraced_a + \romannumeral-`0\romannumeral-`0% }% \def\XINT_flexpr_getnext_checkforbraced_a #1% {% @@ -14476,8 +16842,8 @@ first place. \def\xintSub {:xintSub}% \def\xintMul {:xintMul}% \def\xintDiv {:xintDiv}% - \def\xintfPow {:xintfPow}% - \def\xintfFac {:xintfFac}% + \def\xintPow {:xintPow}% + \def\xintFac {:xintFac}% \def\xintOpp {:xintOpp}% \def\xintfE {:xintfE}% \def\xintraw { :romannumeral0:xintraw}% @@ -14489,11 +16855,11 @@ first place. \endlinechar -1 \everyeof {\noexpand }% \edef\xintNewExprtmp - {\expandafter\scantokens + {\scantokens \expandafter{\romannumeral0\xinttheeval #3\relax}}% \lccode`\*=`_ \lowercase {\def*}{####}% \catcode`_ 13 \catcode`! 0 \catcode`: 11 - \the\toks0 {\expandafter\scantokens\expandafter{\xintNewExprtmp }}% + \the\toks0 {\scantokens\expandafter{\xintNewExprtmp }}% \endgroup }% % \end{macrocode} @@ -14522,7 +16888,7 @@ first place. \def\XINTinFloatMul {:XINTinFloatMul}% \def\XINTinFloatDiv {:XINTinFloatDiv}% \def\XINTinFloatPower {:XINTinFloatPower}% - \def\xintfFac {:xintfFac}% + \def\xintFac {:xintFac}% \def\xintOpp {:xintOpp}% \def\XINTinFloatfE {:XINTinFloatfE}% \def\xintfloat { :romannumeral0:xintfloat}% @@ -14534,11 +16900,11 @@ first place. \endlinechar -1 \everyeof {\noexpand }% \edef\xintNewExprtmp - {\expandafter\scantokens + {\scantokens \expandafter{\romannumeral0\xintthefloateval #3\relax}}% \lccode`\*=`_ \lowercase {\def*}{####}% \catcode`_ 13 \catcode`! 0 \catcode`: 11 - \the\toks0 {\expandafter\scantokens\expandafter{\xintNewExprtmp }}% + \the\toks0 {\scantokens\expandafter{\xintNewExprtmp }}% \endgroup }% \XINT_expr_restorecatcodes_endinput% @@ -14546,7 +16912,7 @@ first place. % \DeleteShortVerb{\|} % \MakePercentComment %</xintexpr> -%<*none> +%<*doc> \CharacterTable {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z @@ -14562,10 +16928,8 @@ first place. Right bracket \] Circumflex \^ Underscore \_ Grave accent \` Left brace \{ Vertical bar \| Right brace \} Tilde \~} - -\CheckSum{13965} +\CheckSum{17408} \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 c2392102edb..22554e24c0d 100644 --- a/Master/texmf-dist/source/generic/xint/xint.ins +++ b/Master/texmf-dist/source/generic/xint/xint.ins @@ -1,21 +1,22 @@ %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.07a of May 26, 2013) +%% The xint bundle (version 1.08b of June 14, 2013) %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- %% %% %% This is a generated file. Run tex or latex on this file to -%% extract xint.sty, xintgcd.sty, xintfrac.sty, xintseries.sty -%% and xintcfrac.sty from xint.dtx +%% extract xint.sty, xintfrac.sty, xintexpr.sty, xintbinhex.sty, +%% xintgcd.sty, xintseries.sty and xintcfrac.sty from xint.dtx %% -%% See xint.dtx for the statements of copyright and conditions of +%% See xint.dtx for the copyright and the conditions for %% distribution and/or modification of this work. %% \input docstrip.tex \askforoverwritefalse \generate{\usepreamble\defaultpreamble \file{xint.sty}{\from{xint.dtx}{xint}} +\file{xintbinhex.sty}{\from{xint.dtx}{xintbinhex}} \file{xintgcd.sty}{\from{xint.dtx}{xintgcd}} \file{xintfrac.sty}{\from{xint.dtx}{xintfrac}} \file{xintseries.sty}{\from{xint.dtx}{xintseries}} diff --git a/Master/texmf-dist/tex/generic/xint/xint.sty b/Master/texmf-dist/tex/generic/xint/xint.sty index b740ecda4a6..21911c686ee 100644 --- a/Master/texmf-dist/tex/generic/xint/xint.sty +++ b/Master/texmf-dist/tex/generic/xint/xint.sty @@ -22,7 +22,7 @@ %% in the same archive or directory.) %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.07a of May 26, 2013) +%% The xint bundle (version 1.08b of June 14, 2013) %% xint: Expandable operations on long numbers %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -67,6 +67,7 @@ \endgroup \edef\XINT_restorecatcodes_endinput {% + \catcode94=\the\catcode94 % ^ \catcode96=\the\catcode96 % ` \catcode47=\the\catcode47 % / \catcode41=\the\catcode41 % ) @@ -111,6 +112,7 @@ \catcode41=12 % ) \catcode47=12 % / \catcode96=12 % ` + \catcode94=11 % ^ }% \XINT_setcatcodes }% @@ -138,7 +140,7 @@ \fi \expandafter\x\csname ver@xint.sty\endcsname \ProvidesPackage{xint}% - [2013/05/26 v1.07a Expandable operations on long numbers (jfB)]% + [2013/06/14 v1.08b Expandable operations on long numbers (jfB)]% \def\xint_gobble_ {}% \def\xint_gobble_i #1{}% \def\xint_gobble_ii #1#2{}% @@ -157,12 +159,14 @@ \def\xint_secondofthree #1#2#3{#2}% \def\xint_thirdofthree #1#2#3{#3}% \def\xint_minus_andstop { -}% -\def\xint_gob_til_r #1\R {}% -\def\xint_gob_til_w #1\W {}% -\def\xint_gob_til_z #1\Z {}% +\def\xint_gob_til_R #1\R {}% +\def\xint_gob_til_W #1\W {}% +\def\xint_gob_til_Z #1\Z {}% \def\xint_gob_til_zero #10{}% \def\xint_gob_til_one #11{}% -\def\xint_gob_til_zeros_iv #10000{}% +\def\xint_gob_til_G #1G{}% +\def\xint_gob_til_zeros_iii #1000{}% +\def\xint_gob_til_zeros_iv #10000{}% \def\xint_gob_til_relax #1\relax {}% \def\xint_gob_til_xint_undef #1\xint_undef {}% \def\xint_gob_til_xint_relax #1\xint_relax {}% @@ -176,6 +180,16 @@ \def\xint_afterfi #1#2\fi {\fi #1}% \let\xint_relax\relax \def\xint_braced_xint_relax {\xint_relax }% +\chardef\xint_c_ 0 +\chardef\xint_c_i 1 +\chardef\xint_c_ii 2 +\chardef\xint_c_iii 3 +\chardef\xint_c_iv 4 +\chardef\xint_c_v 5 +\chardef\xint_c_viii 8 +\chardef\xint_c_ix 9 +\chardef\xint_c_x 10 +\newcount\xint_c_x^viii \xint_c_x^viii 100000000 \def\xintRev {\romannumeral0\xintrev }% \def\xintrev #1% {% @@ -222,7 +236,7 @@ }% \def\xintrevwithbracesnoexpand #1% {% - \romannumeral0\XINT_revwbr_loop\expandafter{\expandafter}% + \XINT_revwbr_loop {}% #1\xint_relax\xint_relax\xint_relax\xint_relax \xint_relax\xint_relax\xint_relax\xint_relax\Z }% @@ -237,7 +251,7 @@ }% \def\XINT_revwbr_finish_b #1#2#3#4#5#6#7#8\Z {% - \xint_gob_til_r + \xint_gob_til_R #1\XINT_revwbr_finish_c 8% #2\XINT_revwbr_finish_c 7% #3\XINT_revwbr_finish_c 6% @@ -295,7 +309,7 @@ }% \def\XINT_length_finish_b #1#2#3#4#5#6#7#8\Z {% - \xint_gob_til_w + \xint_gob_til_W #1\XINT_length_finish_c 8% #2\XINT_length_finish_c 7% #3\XINT_length_finish_c 6% @@ -318,7 +332,7 @@ }% \def\xintcsvtolistnoexpand #1% {% - \romannumeral0\XINT_csvtol_loop_a + \XINT_csvtol_loop_a {}#1,\xint_undef,\xint_undef,\xint_undef,\xint_undef ,\xint_undef,\xint_undef,\xint_undef,\xint_undef,\Z }% @@ -334,7 +348,7 @@ }% \def\XINT_csvtol_finish_b #1,#2,#3,#4,#5,#6,#7,#8\Z {% - \xint_gob_til_r + \xint_gob_til_R #1\XINT_csvtol_finish_c 8% #2\XINT_csvtol_finish_c 7% #3\XINT_csvtol_finish_c 6% @@ -362,17 +376,16 @@ \long\def\xintlistwithsep #1#2% {\expandafter\XINT_lws\expandafter {\romannumeral-`0#2}{#1}}% \long\def\XINT_lws #1#2{\XINT_lws_start {#2}#1\Z }% -\long\def\xintlistwithsepnoexpand #1#2% - {\romannumeral0\XINT_lws_start {#1}#2\Z }% +\long\def\xintlistwithsepnoexpand #1#2{\XINT_lws_start {#1}#2\Z }% \long\def\XINT_lws_start #1#2% {% - \xint_gob_til_z #2\XINT_lws_dont\Z + \xint_gob_til_Z #2\XINT_lws_dont\Z \XINT_lws_loop_a {#2}{#1}% }% \long\def\XINT_lws_dont\Z\XINT_lws_loop_a #1#2{ }% \long\def\XINT_lws_loop_a #1#2#3% {% - \xint_gob_til_z #3\XINT_lws_end\Z + \xint_gob_til_Z #3\XINT_lws_end\Z \XINT_lws_loop_b {#1}{#2#3}{#2}% }% \long\def\XINT_lws_loop_b #1#2{\XINT_lws_loop_a {#1#2}}% @@ -386,11 +399,11 @@ }% \def\xintntheltnoexpand #1#2% {% - \romannumeral0\XINT_nthelt {#2}{\numexpr #1\relax}% + \XINT_nthelt {#2}{\numexpr #1\relax}% }% \def\XINT_nthelt #1#2% {% - \ifnum #2>0 + \ifnum #2>\xint_c_ \xint_afterfi {\XINT_nthelt_loop_a {#2}}% \else \xint_afterfi {\XINT_length_loop {0}}% @@ -399,7 +412,7 @@ }% \def\XINT_nthelt_loop_a #1% {% - \ifnum #1>8 + \ifnum #1>\xint_c_viii \expandafter\XINT_nthelt_loop_b \else \expandafter\XINT_nthelt_getit @@ -432,10 +445,10 @@ {#1}% }% \def\XINT_apply #1#2{\XINT_apply_loop_a {}{#2}#1\Z }% -\def\xintapplynoexpand #1#2{\romannumeral0\XINT_apply_loop_a {}{#1}#2\Z }% +\def\xintapplynoexpand #1#2{\XINT_apply_loop_a {}{#1}#2\Z }% \def\XINT_apply_loop_a #1#2#3% {% - \xint_gob_til_z #3\XINT_apply_end\Z + \xint_gob_til_Z #3\XINT_apply_end\Z \expandafter \XINT_apply_loop_b \expandafter {\romannumeral-`0#2{#3}}{#1}{#2}% @@ -451,10 +464,10 @@ }% \def\XINT_applyunbr #1#2{\XINT_applyunbr_loop_a {}{#2}#1\Z }% \def\xintapplyunbracednoexpand #1#2% - {\romannumeral0\XINT_applyunbr_loop_a {}{#1}#2\Z }% + {\XINT_applyunbr_loop_a {}{#1}#2\Z }% \def\XINT_applyunbr_loop_a #1#2#3% {% - \xint_gob_til_z #3\XINT_applyunbr_end\Z + \xint_gob_til_Z #3\XINT_applyunbr_end\Z \expandafter\XINT_applyunbr_loop_b \expandafter {\romannumeral-`0#2{#3}}{#1}{#2}% }% @@ -551,7 +564,7 @@ \xint_afterfi {\xintError:ArrayIndexIsNegative\space 0}% \else \xint_afterfi {% - \ifnum ##1> #2 + \ifnum ##1>#2 \xint_afterfi {\xintError:ArrayIndexBeyondLimit\space 0}% \else \xint_afterfi @@ -564,7 +577,7 @@ \let\xintDigitsOf\xintAssignArray \def\XINT_RQ #1#2#3#4#5#6#7#8#9% {% - \xint_gob_til_r #9\XINT_RQ_end_a\R\XINT_RQ {#9#8#7#6#5#4#3#2#1}% + \xint_gob_til_R #9\XINT_RQ_end_a\R\XINT_RQ {#9#8#7#6#5#4#3#2#1}% }% \def\XINT_RQ_end_a\R\XINT_RQ #1#2\Z {% @@ -572,7 +585,7 @@ }% \def\XINT_RQ_end_b #1#2#3#4#5#6#7#8% {% - \xint_gob_til_r + \xint_gob_til_R #8\XINT_RQ_end_viii #7\XINT_RQ_end_vii #6\XINT_RQ_end_vi @@ -591,6 +604,62 @@ \def\XINT_RQ_end_iii #1\Z #2#3#4#5#6#7#8#9\Z { #4#5#6#7#8#9000}% \def\XINT_RQ_end_ii #1\Z #2#3#4#5#6#7#8#9\Z { #3#4#5#6#7#8#900}% \def\XINT_RQ_end_i \Z #1#2#3#4#5#6#7#8\Z { #1#2#3#4#5#6#7#80}% +\def\XINT_SQ #1#2#3#4#5#6#7#8% +{% + \xint_gob_til_R #8\XINT_SQ_end_a\R\XINT_SQ {#8#7#6#5#4#3#2#1}% +}% +\def\XINT_SQ_end_a\R\XINT_SQ #1#2\Z +{% + \XINT_SQ_end_b #1\Z +}% +\def\XINT_SQ_end_b #1#2#3#4#5#6#7% +{% + \xint_gob_til_R + #7\XINT_SQ_end_vii + #6\XINT_SQ_end_vi + #5\XINT_SQ_end_v + #4\XINT_SQ_end_iv + #3\XINT_SQ_end_iii + #2\XINT_SQ_end_ii + \R\XINT_SQ_end_i + \Z #2#3#4#5#6#7% +}% +\def\XINT_SQ_end_vii #1\Z #2#3#4#5#6#7#8\Z { #8}% +\def\XINT_SQ_end_vi #1\Z #2#3#4#5#6#7#8\Z { #7#8000000}% +\def\XINT_SQ_end_v #1\Z #2#3#4#5#6#7#8\Z { #6#7#800000}% +\def\XINT_SQ_end_iv #1\Z #2#3#4#5#6#7#8\Z { #5#6#7#80000}% +\def\XINT_SQ_end_iii #1\Z #2#3#4#5#6#7#8\Z { #4#5#6#7#8000}% +\def\XINT_SQ_end_ii #1\Z #2#3#4#5#6#7#8\Z { #3#4#5#6#7#800}% +\def\XINT_SQ_end_i \Z #1#2#3#4#5#6#7\Z { #1#2#3#4#5#6#70}% +\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}% \def\xint_cleanupzeros_andstop #1#2#3#4% {% \expandafter\space\the\numexpr #1#2#3#4\relax @@ -614,8 +683,8 @@ }% \def\XINT_cuz_loop #1#2#3#4#5#6#7#8% {% - \xint_gob_til_w #8\xint_cuz_end_a\W - \xint_gob_til_z #8\xint_cuz_end_A\Z + \xint_gob_til_W #8\xint_cuz_end_a\W + \xint_gob_til_Z #8\xint_cuz_end_A\Z \XINT_cuz_check_a {#1#2#3#4#5#6#7#8}% }% \def\xint_cuz_end_a #1\XINT_cuz_check_a #2% @@ -641,12 +710,12 @@ \def\XINT_isone #1#2% {% \xint_gob_til_one #1\XINT_isone_b 1% - \expandafter\space\expandafter 0\xint_gob_til_z #2% + \expandafter\space\expandafter 0\xint_gob_til_Z #2% }% -\def\XINT_isone_b #1\xint_gob_til_z #2% +\def\XINT_isone_b #1\xint_gob_til_Z #2% {% - \xint_gob_til_w #2\XINT_isone_yes \W - \expandafter\space\expandafter 0\xint_gob_til_z + \xint_gob_til_W #2\XINT_isone_yes \W + \expandafter\space\expandafter 0\xint_gob_til_Z }% \def\XINT_isone_yes #1\Z { 1}% \def\xintiNum {\romannumeral0\xintinum }% @@ -742,7 +811,7 @@ }% \def\XINT_add_A #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_add_az\W + \xint_gob_til_W #3\xint_add_az\W \XINT_add_AB #1{#3#4#5#6}{#2}% }% \def\xint_add_az\W\XINT_add_AB #1#2% @@ -751,7 +820,7 @@ }% \def\XINT_add_AB #1#2#3#4\W\X\Y\Z #5#6#7#8% {% - \xint_gob_til_w #5\xint_add_bz\W + \xint_gob_til_W #5\xint_add_bz\W \XINT_add_ABE #1#2{#8#7#6#5}{#3}#4\W\X\Y\Z }% \def\XINT_add_ABE #1#2#3#4#5#6% @@ -788,7 +857,7 @@ }% \def\XINT_add_C #1#2#3#4#5% {% - \xint_gob_til_w #2\xint_add_cz\W + \xint_gob_til_W #2\xint_add_cz\W \XINT_add_CD {#5#4#3#2}{#1}% }% \def\XINT_add_CD #1% @@ -798,7 +867,7 @@ \def\xint_add_cz\W\XINT_add_CD #1#2{ 1#2}% \def\XINT_addr_A #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_addr_az\W + \xint_gob_til_W #3\xint_addr_az\W \XINT_addr_B #1{#3#4#5#6}{#2}% }% \def\xint_addr_az\W\XINT_addr_B #1#2% @@ -807,7 +876,7 @@ }% \def\XINT_addr_B #1#2#3#4\W\X\Y\Z #5#6#7#8% {% - \xint_gob_til_w #5\xint_addr_bz\W + \xint_gob_til_W #5\xint_addr_bz\W \XINT_addr_E #1#2{#8#7#6#5}{#3}#4\W\X\Y\Z }% \def\XINT_addr_E #1#2#3#4#5#6% @@ -833,7 +902,7 @@ \def\xint_addr_AC_nocarry 0\XINT_addr_C #1#2\W\X\Y\Z { #1#2}% \def\XINT_addr_C #1#2#3#4#5% {% - \xint_gob_til_w #2\xint_addr_cz\W + \xint_gob_til_W #2\xint_addr_cz\W \XINT_addr_D {#5#4#3#2}{#1}% }% \def\XINT_addr_D #1% @@ -843,7 +912,7 @@ \def\xint_addr_cz\W\XINT_addr_D #1#2{ #21000}% \def\XINT_addm_A #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_addm_az\W + \xint_gob_til_W #3\xint_addm_az\W \XINT_addm_AB #1{#3#4#5#6}{#2}% }% \def\xint_addm_az\W\XINT_addm_AB #1#2% @@ -880,7 +949,7 @@ }% \def\XINT_addm_C #1#2#3#4#5% {% - \xint_gob_til_w + \xint_gob_til_W #5\xint_addm_cw #4\xint_addm_cx #3\xint_addm_cy @@ -933,7 +1002,7 @@ {\expandafter\space\the\numexpr #1#2#3#4#5\relax}% \def\XINT_addp_A #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_addp_az\W + \xint_gob_til_W #3\xint_addp_az\W \XINT_addp_AB #1{#3#4#5#6}{#2}% }% \def\xint_addp_az\W\XINT_addp_AB #1#2% @@ -962,7 +1031,7 @@ }% \def\XINT_addp_C #1#2#3#4#5% {% - \xint_gob_til_w + \xint_gob_til_W #5\xint_addp_cw #4\xint_addp_cx #3\xint_addp_cy @@ -983,7 +1052,7 @@ #3\xint_addp_cz \W\XINT_addp_CD {% - \expandafter\XINT_addp_CDw\the\numexpr 1+10#1#2#3\relax + \expandafter\XINT_addp_CDw\the\numexpr \xint_c_i+10#1#2#3\relax }% \def\XINT_addp_CDw #1#2#3#4#5#6% {% @@ -997,7 +1066,7 @@ #2\xint_addp_cz \W\XINT_addp_CD {% - \expandafter\XINT_addp_CDx\the\numexpr 1+100#1#2\relax + \expandafter\XINT_addp_CDx\the\numexpr \xint_c_i+100#1#2\relax }% \def\XINT_addp_CDx #1#2#3#4#5#6% {% @@ -1006,11 +1075,9 @@ }% \def\XINT_addp_endDx_zeros 0000\XINT_addp_endDx 0000#1\Y\Z{ #1}% \def\XINT_addp_endDx #1#2#3#4#5\Y\Z{ #5#4#3#2#1}% -\def\xint_addp_cy - #1\xint_addp_cz - \W\XINT_addp_CD +\def\xint_addp_cy #1\xint_addp_cz\W\XINT_addp_CD {% - \expandafter\XINT_addp_CDy\the\numexpr 1+1000#1\relax + \expandafter\XINT_addp_CDy\the\numexpr \xint_c_i+1000#1\relax }% \def\XINT_addp_CDy #1#2#3#4#5#6% {% @@ -1022,7 +1089,7 @@ \def\xint_addp_cz\W\XINT_addp_CD #1#2{ #21000}% \def\XINT_addp_F #1#2#3#4#5% {% - \xint_gob_til_w + \xint_gob_til_W #5\xint_addp_Gw #4\xint_addp_Gx #3\xint_addp_Gy @@ -1112,10 +1179,10 @@ }% \def\XINT_add_pre #1% {% - \expandafter\XINT_add__pre\expandafter + \expandafter\XINT_add_pre_b\expandafter {\romannumeral0\XINT_RQ {}#1\R\R\R\R\R\R\R\R\Z }% }% -\def\XINT_add__pre #1#2% +\def\XINT_add_pre_b #1#2% {% \expandafter\XINT_add_A \expandafter0\expandafter{\expandafter}% @@ -1171,10 +1238,10 @@ \def\xint_sub_pm #1\XINT_add_pre #2#3{ -#2}% \def\XINT_sub_pre #1% {% - \expandafter\XINT_sub__pre\expandafter + \expandafter\XINT_sub_pre_b\expandafter {\romannumeral0\XINT_RQ {}#1\R\R\R\R\R\R\R\R\Z }% }% -\def\XINT_sub__pre #1#2% +\def\XINT_sub_pre_b #1#2% {% \expandafter\XINT_sub_A \expandafter1\expandafter{\expandafter}% @@ -1183,19 +1250,19 @@ }% \def\XINT_sub_A #1#2#3\W\X\Y\Z #4#5#6#7% {% - \xint_gob_til_w + \xint_gob_til_W #4\xint_sub_az \W\XINT_sub_B #1{#4#5#6#7}{#2}#3\W\X\Y\Z }% \def\XINT_sub_B #1#2#3#4#5#6#7% {% - \xint_gob_til_w + \xint_gob_til_W #4\xint_sub_bz \W\XINT_sub_onestep #1#2{#7#6#5#4}{#3}% }% \def\XINT_sub_onestep #1#2#3#4#5#6% {% - \expandafter\XINT_sub_backtoA\the\numexpr 11#5#4#3#2-#6+#1-1\relax.% + \expandafter\XINT_sub_backtoA\the\numexpr 11#5#4#3#2-#6+#1-\xint_c_i\relax.% }% \def\XINT_sub_backtoA #1#2#3.#4% {% @@ -1224,13 +1291,13 @@ }% \def\XINT_sub_C #1#2#3#4#5% {% - \xint_gob_til_w + \xint_gob_til_W #2\xint_sub_cz \W\XINT_sub_AC_onestep {#5#4#3#2}{#1}% }% \def\XINT_sub_AC_onestep #1% {% - \expandafter\XINT_sub_backtoC\the\numexpr 11#1-1\relax.% + \expandafter\XINT_sub_backtoC\the\numexpr 11#1-\xint_c_i\relax.% }% \def\XINT_sub_backtoC #1#2#3.#4% {% @@ -1258,7 +1325,7 @@ }% \def\xint_sub_az\W\XINT_sub_B #1#2#3#4#5#6#7% {% - \xint_gob_til_w + \xint_gob_til_W #4\xint_sub_ez \W\XINT_sub_Eenter #1{#3}#4#5#6#7% }% @@ -1276,7 +1343,7 @@ }% \def\XINT_sub_E #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_sub_F\W + \xint_gob_til_W #3\xint_sub_F\W \XINT_sub_Eonestep #1{#6#5#4#3}{#2}% }% \def\XINT_sub_Eonestep #1#2% @@ -1299,12 +1366,12 @@ \def\XINT_sub_DD {\expandafter\xint_minus_andstop\romannumeral0\XINT_sub_D }% \def\XINT_sub_Fdec #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_sub_Fdec_finish\W + \xint_gob_til_W #3\xint_sub_Fdec_finish\W \XINT_sub_Fdec_onestep #1{#6#5#4#3}{#2}% }% \def\XINT_sub_Fdec_onestep #1#2% {% - \expandafter\XINT_sub_backtoFdec\the\numexpr 11#2+#1-1\relax.% + \expandafter\XINT_sub_backtoFdec\the\numexpr 11#2+#1-\xint_c_i\relax.% }% \def\XINT_sub_backtoFdec #1#2#3.#4% {% @@ -1316,7 +1383,7 @@ }% \def\XINT_sub_Finc #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_sub_Finc_finish\W + \xint_gob_til_W #3\xint_sub_Finc_finish\W \XINT_sub_Finc_onestep #1{#6#5#4#3}{#2}% }% \def\XINT_sub_Finc_onestep #1#2% @@ -1356,7 +1423,7 @@ }% \def\XINT_sub_KK #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_sub_KK_finish\W + \xint_gob_til_W #3\xint_sub_KK_finish\W \XINT_sub_KK_onestep #1{#6#5#4#3}{#2}% }% \def\XINT_sub_KK_onestep #1#2% @@ -1413,10 +1480,10 @@ }% \def\XINT_cmp_pre #1% {% - \expandafter\XINT_cmp__pre\expandafter + \expandafter\XINT_cmp_pre_b\expandafter {\romannumeral0\XINT_RQ {}#1\R\R\R\R\R\R\R\R\Z }% }% -\def\XINT_cmp__pre #1#2% +\def\XINT_cmp_pre_b #1#2% {% \expandafter\XINT_cmp_A \expandafter1\expandafter{\expandafter}% @@ -1425,17 +1492,17 @@ }% \def\XINT_cmp_A #1#2#3\W\X\Y\Z #4#5#6#7% {% - \xint_gob_til_w #4\xint_cmp_az\W + \xint_gob_til_W #4\xint_cmp_az\W \XINT_cmp_B #1{#4#5#6#7}{#2}#3\W\X\Y\Z }% \def\XINT_cmp_B #1#2#3#4#5#6#7% {% - \xint_gob_til_w#4\xint_cmp_bz\W + \xint_gob_til_W#4\xint_cmp_bz\W \XINT_cmp_onestep #1#2{#7#6#5#4}{#3}% }% \def\XINT_cmp_onestep #1#2#3#4#5#6% {% - \expandafter\XINT_cmp_backtoA\the\numexpr 11#5#4#3#2-#6+#1-1\relax.% + \expandafter\XINT_cmp_backtoA\the\numexpr 11#5#4#3#2-#6+#1-\xint_c_i\relax.% }% \def\XINT_cmp_backtoA #1#2#3.#4% {% @@ -1444,7 +1511,7 @@ \def\xint_cmp_bz\W\XINT_cmp_onestep #1\Z { 1}% \def\xint_cmp_az\W\XINT_cmp_B #1#2#3#4#5#6#7% {% - \xint_gob_til_w #4\xint_cmp_ez\W + \xint_gob_til_W #4\xint_cmp_ez\W \XINT_cmp_Eenter #1{#3}#4#5#6#7% }% \def\XINT_cmp_Eenter #1\Z { -1}% @@ -1463,7 +1530,7 @@ }% \def\XINT_OneIfPositive_main #1#2#3#4% {% - \xint_gob_til_z #4\xint_OneIfPositive_terminated\Z + \xint_gob_til_Z #4\xint_OneIfPositive_terminated\Z \XINT_OneIfPositive_onestep #1#2#3#4% }% \def\xint_OneIfPositive_terminated\Z\XINT_OneIfPositive_onestep\W\X\Y\Z { 0}% @@ -1512,10 +1579,10 @@ \def\XINT_geq_plusminus #1#2#3#4{\XINT_geq_pre {#2}{#3#1}}% \def\XINT_geq_pre #1% {% - \expandafter\XINT_geq__pre\expandafter + \expandafter\XINT_geq_pre_b\expandafter {\romannumeral0\XINT_RQ {}#1\R\R\R\R\R\R\R\R\Z }% }% -\def\XINT_geq__pre #1#2% +\def\XINT_geq_pre_b #1#2% {% \expandafter\XINT_geq_A \expandafter1\expandafter{\expandafter}% @@ -1524,17 +1591,17 @@ }% \def\XINT_geq_A #1#2#3\W\X\Y\Z #4#5#6#7% {% - \xint_gob_til_w #4\xint_geq_az\W + \xint_gob_til_W #4\xint_geq_az\W \XINT_geq_B #1{#4#5#6#7}{#2}#3\W\X\Y\Z }% \def\XINT_geq_B #1#2#3#4#5#6#7% {% - \xint_gob_til_w #4\xint_geq_bz\W + \xint_gob_til_W #4\xint_geq_bz\W \XINT_geq_onestep #1#2{#7#6#5#4}{#3}% }% \def\XINT_geq_onestep #1#2#3#4#5#6% {% - \expandafter\XINT_geq_backtoA\the\numexpr 11#5#4#3#2-#6+#1-1\relax.% + \expandafter\XINT_geq_backtoA\the\numexpr 11#5#4#3#2-#6+#1-\xint_c_i\relax.% }% \def\XINT_geq_backtoA #1#2#3.#4% {% @@ -1543,7 +1610,7 @@ \def\xint_geq_bz\W\XINT_geq_onestep #1\W\X\Y\Z { 1}% \def\xint_geq_az\W\XINT_geq_B #1#2#3#4#5#6#7% {% - \xint_gob_til_w #4\xint_geq_ez\W + \xint_gob_til_W #4\xint_geq_ez\W \XINT_geq_Eenter #1% }% \def\XINT_geq_Eenter #1\W\X\Y\Z { 0}% @@ -1751,10 +1818,10 @@ }% \def\XINT_mul_choice_b #1#2% {% - \ifnum #1<5 + \ifnum #1<\xint_c_v \expandafter\XINT_mul_choice_littlebyfirst \else - \ifnum #2<5 + \ifnum #2<\xint_c_v \expandafter\expandafter\expandafter\XINT_mul_choice_littlebysecond \else \expandafter\expandafter\expandafter\XINT_mul_choice_compare @@ -1785,7 +1852,7 @@ }% \def\XINT_mul_choice_i #1#2% {% - \ifnum #1<\numexpr\ifcase \numexpr (#2-3)/4\relax + \ifnum #1<\numexpr\ifcase \numexpr (#2-\xint_c_iii)/\xint_c_iv\relax \or 330\or 168\or 109\or 80\or 66\or 52\else 0\fi\relax \expandafter\XINT_mul_choice_same \else @@ -1794,7 +1861,7 @@ }% \def\XINT_mul_choice_ii #1#2% {% - \ifnum #2<\numexpr\ifcase \numexpr (#1-3)/4\relax + \ifnum #2<\numexpr\ifcase \numexpr (#1-\xint_c_iii)/\xint_c_iv\relax \or 330\or 168\or 109\or 80\or 66\or 52\else 0\fi\relax \expandafter\XINT_mul_choice_permute \else @@ -1805,17 +1872,17 @@ {% \expandafter\XINT_mul_enter \romannumeral0\XINT_RQ {}#1\R\R\R\R\R\R\R\R\Z - \W\X\Y\Z #2\W\X\Y\Z + \Z\Z\Z\Z #2\W\W\W\W }% \def\XINT_mul_choice_permute #1#2% {% \expandafter\XINT_mul_enter \romannumeral0\XINT_RQ {}#2\R\R\R\R\R\R\R\R\Z - \W\X\Y\Z #1\W\X\Y\Z + \Z\Z\Z\Z #1\W\W\W\W }% \def\XINT_mul_Ar #1#2#3#4#5#6% {% - \xint_gob_til_z #6\xint_mul_br\Z\XINT_mul_Br #1{#6#5#4#3}{#2}% + \xint_gob_til_Z #6\xint_mul_br\Z\XINT_mul_Br #1{#6#5#4#3}{#2}% }% \def\xint_mul_br\Z\XINT_mul_Br #1#2% {% @@ -1849,11 +1916,11 @@ \def\XINT_mul_Mr_one #1#2#3#4\Z\Z\Z\Z { #4}% \def\XINT_mul_Nr #1#2#3#4#5#6#7% {% - \xint_gob_til_z #4\xint_mul_pr\Z\XINT_mul_Pr {#1}{#3}{#7#6#5#4}{#2}{#3}% + \xint_gob_til_Z #4\xint_mul_pr\Z\XINT_mul_Pr {#1}{#3}{#7#6#5#4}{#2}{#3}% }% \def\XINT_mul_Pr #1#2#3% {% - \expandafter\XINT_mul_Lr\the\numexpr 10000#1+#2*#3\relax + \expandafter\XINT_mul_Lr\the\numexpr \xint_c_x^viii+#1+#2*#3\relax }% \def\XINT_mul_Lr 1#1#2#3#4#5#6#7#8#9% {% @@ -1888,11 +1955,11 @@ }% \def\XINT_mul_N #1#2#3#4#5#6#7% {% - \xint_gob_til_z #4\xint_mul_p\Z\XINT_mul_P {#1}{#3}{#7#6#5#4}{#2}{#3}% + \xint_gob_til_Z #4\xint_mul_p\Z\XINT_mul_P {#1}{#3}{#7#6#5#4}{#2}{#3}% }% \def\XINT_mul_P #1#2#3% {% - \expandafter\XINT_mul_L\the\numexpr 10000#1+#2*#3\relax + \expandafter\XINT_mul_L\the\numexpr \xint_c_x^viii+#1+#2*#3\relax }% \def\XINT_mul_L 1#1#2#3#4#5#6#7#8#9% {% @@ -1906,175 +1973,161 @@ {% \expandafter\space\the\numexpr #1#2#3#4#5#6#7#8\relax }% -\def\XINT_mul_enter #1\W\X\Y\Z #2#3#4#5% +\def\XINT_mul_enter #1\Z\Z\Z\Z #2#3#4#5% +{% + \xint_gob_til_W #5\XINT_mul_exit_a\W + \XINT_mul_start {#2#3#4#5}#1\Z\Z\Z\Z +}% +\def\XINT_mul_exit_a\W\XINT_mul_start #1% +{% + \XINT_mul_exit_b #1% +}% +\def\XINT_mul_exit_b #1#2#3#4% {% - \xint_gob_til_w - #5\xint_mul_enterw - #4\xint_mul_enterx - #3\xint_mul_entery - #2\xint_mul_enterz - \W\XINT_mul_start {#2#3#4#5}#1\W\X\Y\Z + \xint_gob_til_W + #2\XINT_mul_exit_ci + #3\XINT_mul_exit_cii + \W\XINT_mul_exit_ciii #1#2#3#4% }% -\def\xint_mul_enterw - #1\xint_mul_enterx - #2\xint_mul_entery - #3\xint_mul_enterz - \W\XINT_mul_start #4#5\W\X\Y\Z \X\Y\Z +\def\XINT_mul_exit_ciii #1\W #2\Z\Z\Z\Z \W\W\W {% - \XINT_mul_M {#3#2#1}#5\Z\Z\Z\Z + \XINT_mul_M {#1}#2\Z\Z\Z\Z }% -\def\xint_mul_enterx - #1\xint_mul_entery - #2\xint_mul_enterz - \W\XINT_mul_start #3#4\W\X\Y\Z \Y\Z +\def\XINT_mul_exit_cii\W\XINT_mul_exit_ciii #1\W\W #2\Z\Z\Z\Z \W\W {% - \XINT_mul_M {#2#1}#4\Z\Z\Z\Z + \XINT_mul_M {#1}#2\Z\Z\Z\Z }% -\def\xint_mul_entery - #1\xint_mul_enterz - \W\XINT_mul_start #2#3\W\X\Y\Z \Z +\def\XINT_mul_exit_ci\W\XINT_mul_exit_cii + \W\XINT_mul_exit_ciii #1\W\W\W #2\Z\Z\Z\Z \W {% - \XINT_mul_M {#1}#3\Z\Z\Z\Z + \XINT_mul_M {#1}#2\Z\Z\Z\Z }% -\def\XINT_mul_start #1#2\W\X\Y\Z +\def\XINT_mul_start #1#2\Z\Z\Z\Z {% \expandafter\XINT_mul_main\expandafter - {\romannumeral0\XINT_mul_Mr {#1}#2\Z\Z\Z\Z}#2\W\X\Y\Z + {\romannumeral0\XINT_mul_Mr {#1}#2\Z\Z\Z\Z}#2\Z\Z\Z\Z }% -\def\XINT_mul_main #1#2\W\X\Y\Z #3#4#5#6% +\def\XINT_mul_main #1#2\Z\Z\Z\Z #3#4#5#6% {% - \xint_gob_til_w - #6\xint_mul_mainw - #5\xint_mul_mainx - #4\xint_mul_mainy - #3\xint_mul_mainz - \W\XINT_mul_compute {#1}{#3#4#5#6}#2\W\X\Y\Z + \xint_gob_til_W #6\XINT_mul_finish_a\W + \XINT_mul_compute {#3#4#5#6}{#1}#2\Z\Z\Z\Z }% -\def\XINT_mul_compute #1#2#3\W\X\Y\Z +\def\XINT_mul_compute #1#2#3\Z\Z\Z\Z {% \expandafter\XINT_mul_main\expandafter {\romannumeral0\expandafter \XINT_mul_Ar\expandafter0\expandafter{\expandafter}% - \romannumeral0\XINT_mul_Mr {#2}#3\Z\Z\Z\Z - \W\X\Y\Z 0000#1\W\X\Y\Z }#3\W\X\Y\Z + \romannumeral0\XINT_mul_Mr {#1}#3\Z\Z\Z\Z + \W\X\Y\Z 0000#2\W\X\Y\Z }#3\Z\Z\Z\Z }% -\def\xint_mul_mainw - #1\xint_mul_mainx - #2\xint_mul_mainy - #3\xint_mul_mainz - \W\XINT_mul_compute #4#5#6\W\X\Y\Z \X\Y\Z +\def\XINT_mul_finish_a\W\XINT_mul_compute #1% {% - \expandafter\XINT_addm_A \expandafter0\expandafter{\expandafter}% - \romannumeral0% - \XINT_mul_Mr {#3#2#1}#6\Z\Z\Z\Z - \W\X\Y\Z 000#4\W\X\Y\Z + \XINT_mul_finish_b #1% +}% +\def\XINT_mul_finish_b #1#2#3#4% +{% + \xint_gob_til_W + #1\XINT_mul_finish_c + #2\XINT_mul_finish_ci + #3\XINT_mul_finish_cii + \W\XINT_mul_finish_ciii #1#2#3#4% +}% +\def\XINT_mul_finish_ciii #1\W #2#3\Z\Z\Z\Z \W\W\W +{% + \expandafter\XINT_addm_A\expandafter0\expandafter{\expandafter}% + \romannumeral0\XINT_mul_Mr {#1}#3\Z\Z\Z\Z \W\X\Y\Z 000#2\W\X\Y\Z }% -\def\xint_mul_mainx - #1\xint_mul_mainy - #2\xint_mul_mainz - \W\XINT_mul_compute #3#4#5\W\X\Y\Z \Y\Z +\def\XINT_mul_finish_cii + \W\XINT_mul_finish_ciii #1\W\W #2#3\Z\Z\Z\Z \W\W {% - \expandafter\XINT_addm_A\expandafter - 0\expandafter{\expandafter}% - \romannumeral0\XINT_mul_Mr {#2#1}#5\Z\Z\Z\Z - \W\X\Y\Z 00#3\W\X\Y\Z + \expandafter\XINT_addm_A\expandafter0\expandafter{\expandafter}% + \romannumeral0\XINT_mul_Mr {#1}#3\Z\Z\Z\Z \W\X\Y\Z 00#2\W\X\Y\Z }% -\def\xint_mul_mainy - #1\xint_mul_mainz - \W\XINT_mul_compute #2#3#4\W\X\Y\Z \Z +\def\XINT_mul_finish_ci #1\XINT_mul_finish_ciii #2\W\W\W #3#4\Z\Z\Z\Z \W {% - \expandafter\XINT_addm_A\expandafter - 0\expandafter{\expandafter}% - \romannumeral0\XINT_mul_Mr {#1}#4\Z\Z\Z\Z - \W\X\Y\Z 0#2\W\X\Y\Z + \expandafter\XINT_addm_A\expandafter0\expandafter{\expandafter}% + \romannumeral0\XINT_mul_Mr {#2}#4\Z\Z\Z\Z \W\X\Y\Z 0#3\W\X\Y\Z }% -\def\xint_mul_mainz\W\XINT_mul_compute #1#2#3\W\X\Y\Z +\def\XINT_mul_finish_c #1\XINT_mul_finish_ciii \W\W\W\W #2#3\Z\Z\Z\Z {% - \expandafter\xint_cleanupzeros_andstop\romannumeral0\XINT_rev{#1}% + \expandafter\xint_cleanupzeros_andstop\romannumeral0\XINT_rev{#2}% }% -\def\XINT_mulr_enter #1\W\X\Y\Z #2#3#4#5% +\def\XINT_mulr_enter #1\Z\Z\Z\Z #2#3#4#5% {% - \xint_gob_til_w - #5\xint_mulr_enterw - #4\xint_mulr_enterx - #3\xint_mulr_entery - #2\xint_mulr_enterz - \W\XINT_mulr_start {#2#3#4#5}#1\W\X\Y\Z + \xint_gob_til_W #5\XINT_mulr_exit_a\W + \XINT_mulr_start {#2#3#4#5}#1\Z\Z\Z\Z }% -\def\xint_mulr_enterw - #1\xint_mulr_enterx - #2\xint_mulr_entery - #3\xint_mulr_enterz - \W\XINT_mulr_start #4#5\W\X\Y\Z \X\Y\Z +\def\XINT_mulr_exit_a\W\XINT_mulr_start #1% {% - \XINT_mul_Mr {#3#2#1}#5\Z\Z\Z\Z + \XINT_mulr_exit_b #1% }% -\def\xint_mulr_enterx - #1\xint_mulr_entery - #2\xint_mulr_enterz - \W\XINT_mulr_start #3#4\W\X\Y\Z \Y\Z +\def\XINT_mulr_exit_b #1#2#3#4% {% - \XINT_mul_Mr {#2#1}#4\Z\Z\Z\Z + \xint_gob_til_W + #2\XINT_mulr_exit_ci + #3\XINT_mulr_exit_cii + \W\XINT_mulr_exit_ciii #1#2#3#4% }% -\def\xint_mulr_entery - #1\xint_mulr_enterz - \W\XINT_mulr_start #2#3\W\X\Y\Z \Z +\def\XINT_mulr_exit_ciii #1\W #2\Z\Z\Z\Z \W\W\W {% - \XINT_mul_Mr {#1}#3\Z\Z\Z\Z + \XINT_mul_Mr {#1}#2\Z\Z\Z\Z }% -\def\XINT_mulr_start #1#2\W\X\Y\Z +\def\XINT_mulr_exit_cii\W\XINT_mulr_exit_ciii #1\W\W #2\Z\Z\Z\Z \W\W +{% + \XINT_mul_Mr {#1}#2\Z\Z\Z\Z +}% +\def\XINT_mulr_exit_ci\W\XINT_mulr_exit_cii + \W\XINT_mulr_exit_ciii #1\W\W\W #2\Z\Z\Z\Z \W +{% + \XINT_mul_Mr {#1}#2\Z\Z\Z\Z +}% +\def\XINT_mulr_start #1#2\Z\Z\Z\Z {% \expandafter\XINT_mulr_main\expandafter - {\romannumeral0\XINT_mul_Mr {#1}#2\Z\Z\Z\Z }#2\W\X\Y\Z + {\romannumeral0\XINT_mul_Mr {#1}#2\Z\Z\Z\Z}#2\Z\Z\Z\Z }% -\def\XINT_mulr_main #1#2\W\X\Y\Z #3#4#5#6% +\def\XINT_mulr_main #1#2\Z\Z\Z\Z #3#4#5#6% {% - \xint_gob_til_w - #6\xint_mulr_mainw - #5\xint_mulr_mainx - #4\xint_mulr_mainy - #3\xint_mulr_mainz - \W\XINT_mulr_compute {#1}{#3#4#5#6}#2\W\X\Y\Z + \xint_gob_til_W #6\XINT_mulr_finish_a\W + \XINT_mulr_compute {#3#4#5#6}{#1}#2\Z\Z\Z\Z }% -\def\XINT_mulr_compute #1#2#3\W\X\Y\Z +\def\XINT_mulr_compute #1#2#3\Z\Z\Z\Z {% \expandafter\XINT_mulr_main\expandafter {\romannumeral0\expandafter - \XINT_mul_Ar \expandafter0\expandafter{\expandafter}% - \romannumeral0\XINT_mul_Mr {#2}#3\Z\Z\Z\Z \W\X\Y\Z 0000#1\W\X\Y\Z - }#3\W\X\Y\Z -}% -\def\xint_mulr_mainw - #1\xint_mulr_mainx - #2\xint_mulr_mainy - #3\xint_mulr_mainz - \W\XINT_mulr_compute #4#5#6\W\X\Y\Z \X\Y\Z -{% - \expandafter\XINT_addp_A - \expandafter0\expandafter{\expandafter}% - \romannumeral0\XINT_mul_Mr {#3#2#1}#6\Z\Z\Z\Z - \W\X\Y\Z 000#4\W\X\Y\Z -}% -\def\xint_mulr_mainx - #1\xint_mulr_mainy - #2\xint_mulr_mainz - \W\XINT_mulr_compute #3#4#5\W\X\Y\Z \Y\Z -{% - \expandafter\XINT_addp_A - \expandafter0\expandafter{\expandafter}% - \romannumeral0\XINT_mul_Mr {#2#1}#5\Z\Z\Z\Z - \W\X\Y\Z 00#3\W\X\Y\Z -}% -\def\xint_mulr_mainy - #1\xint_mulr_mainz - \W\XINT_mulr_compute #2#3#4\W\X\Y\Z \Z -{% - \expandafter\XINT_addp_A - \expandafter0\expandafter{\expandafter}% - \romannumeral0\XINT_mul_Mr {#1}#4\Z\Z\Z\Z - \W\X\Y\Z 0#2\W\X\Y\Z -}% -\def\xint_mulr_mainz\W\XINT_mulr_compute #1#2#3\W\X\Y\Z { #1}% + \XINT_mul_Ar\expandafter0\expandafter{\expandafter}% + \romannumeral0\XINT_mul_Mr {#1}#3\Z\Z\Z\Z + \W\X\Y\Z 0000#2\W\X\Y\Z }#3\Z\Z\Z\Z +}% +\def\XINT_mulr_finish_a\W\XINT_mulr_compute #1% +{% + \XINT_mulr_finish_b #1% +}% +\def\XINT_mulr_finish_b #1#2#3#4% +{% + \xint_gob_til_W + #1\XINT_mulr_finish_c + #2\XINT_mulr_finish_ci + #3\XINT_mulr_finish_cii + \W\XINT_mulr_finish_ciii #1#2#3#4% +}% +\def\XINT_mulr_finish_ciii #1\W #2#3\Z\Z\Z\Z \W\W\W +{% + \expandafter\XINT_addp_A\expandafter0\expandafter{\expandafter}% + \romannumeral0\XINT_mul_Mr {#1}#3\Z\Z\Z\Z \W\X\Y\Z 000#2\W\X\Y\Z +}% +\def\XINT_mulr_finish_cii + \W\XINT_mulr_finish_ciii #1\W\W #2#3\Z\Z\Z\Z \W\W +{% + \expandafter\XINT_addp_A\expandafter0\expandafter{\expandafter}% + \romannumeral0\XINT_mul_Mr {#1}#3\Z\Z\Z\Z \W\X\Y\Z 00#2\W\X\Y\Z +}% +\def\XINT_mulr_finish_ci #1\XINT_mulr_finish_ciii #2\W\W\W #3#4\Z\Z\Z\Z \W +{% + \expandafter\XINT_addp_A\expandafter0\expandafter{\expandafter}% + \romannumeral0\XINT_mul_Mr {#2}#4\Z\Z\Z\Z \W\X\Y\Z 0#3\W\X\Y\Z +}% +\def\XINT_mulr_finish_c #1\XINT_mulr_finish_ciii \W\W\W\W #2#3\Z\Z\Z\Z { #2}% \def\xintiSqr {\romannumeral0\xintisqr }% \def\xintisqr #1% {% @@ -2086,7 +2139,7 @@ \expandafter\XINT_mul_enter \romannumeral0% \XINT_RQ {}#1\R\R\R\R\R\R\R\R\Z - \W\X\Y\Z #1\W\X\Y\Z + \Z\Z\Z\Z #1\W\W\W\W }% \def\xintiPrd {\romannumeral0\xintiprd }% \def\xintiprd #1{\xintiprdexpr #1\relax }% @@ -2111,11 +2164,12 @@ \expandafter\XINT_prod_loop_a\romannumeral0\XINT_mul_fork }% \def\XINT_prod_finished #1\Z #2\Z \Z { #2}% -\def\xintFac {\romannumeral0\xintfac }% -\def\xintfac #1% +\def\xintiFac {\romannumeral0\xintifac }% +\def\xintifac #1% {% \expandafter\XINT_fac_fork\expandafter{\the\numexpr #1}% }% +\let\xintFac\xintiFac \let\xintfac\xintifac \def\XINT_fac_fork #1% {% \ifcase\XINT_Sgn {#1} @@ -2166,7 +2220,7 @@ \expandafter\XINT_fac_bigcompute_loop\expandafter {\expandafter\XINT_mul_enter \romannumeral0\XINT_RQ {}#2\R\R\R\R\R\R\R\R\Z - \W\X\Y\Z #1\W\X\Y\Z }% + \Z\Z\Z\Z #1\W\W\W\W }% }% \def\XINT_fac_bigcompute_end #1#2#3#4#5% {% @@ -2253,7 +2307,7 @@ \ifcase\XINT_Sgn {#1} \expandafter\XINT_pow_BisZero \or - \expandafter\XINT_pow_checkBlength + \expandafter\XINT_pow_checkBsize \else \expandafter\XINT_pow_BisNegative \fi @@ -2261,7 +2315,7 @@ }% \def\XINT_pow_BisNegative #1#2{\xintError:FractionRoundedToZero\space 0}% \def\XINT_pow_BisZero #1#2{ 1}% -\def\XINT_pow_checkBlength #1#2% +\def\XINT_pow_checkBsize #1#2% {% \ifnum #1>999999999 \expandafter\XINT_pow_BtooBig @@ -2328,7 +2382,7 @@ \def\XINT_pow_pprod_compute #1\Z #2% {% \expandafter\XINT_pow_pprod_getnext\expandafter - {\romannumeral0\XINT_mulr_enter #2\W\X\Y\Z #1\W\X\Y\Z}% + {\romannumeral0\XINT_mulr_enter #2\Z\Z\Z\Z #1\W\W\W\W }% }% \def\XINT_pow_pprod_end\relax\XINT_pow_pprod_compute #1\Z #2% {% @@ -2404,7 +2458,7 @@ \def\XINT_div_AisNegative_posrem #1% {% \expandafter \XINT_div_AisNegative_posrem_b \expandafter - {\romannumeral0\xintiopp{\xintiAdd {#1}{1}}}% + {\romannumeral0\xintiopp{\xintInc {#1}}}% }% \def\XINT_div_AisNegative_posrem_b #1#2#3% {% @@ -2436,7 +2490,8 @@ \def\XINT_div_prepareB_BisOne #1#2#3#4#5{ {#5}{0}}% \def\XINT_div_prepareB_a #1% {% - \expandafter\XINT_div_prepareB_c\expandafter{\the\numexpr 4*((#1+1)/4)}{#1}% + \expandafter\XINT_div_prepareB_c\expandafter + {\the\numexpr \xint_c_iv*((#1+\xint_c_i)/\xint_c_iv)}{#1}% }% \def\XINT_div_prepareB_c #1#2% {% @@ -2545,11 +2600,11 @@ }% \def\XINT_div_final_da #1% {% - \ifnum #1>9 + \ifnum #1>\xint_c_ix \expandafter\XINT_div_final_dP \else \xint_afterfi - {\ifnum #1<0 + {\ifnum #1<\xint_c_ \expandafter\XINT_div_final_dN \else \expandafter\XINT_div_final_db @@ -2558,7 +2613,7 @@ }% \def\XINT_div_final_dN #1% {% - \expandafter\XINT_div_final_dP\the\numexpr #1-1\relax + \expandafter\XINT_div_final_dP\the\numexpr #1-\xint_c_i\relax }% \def\XINT_div_final_dP #1#2#3#4#5% q,A,Q,L,B (puis c) {% @@ -2576,8 +2631,9 @@ }% \def\XINT_div_final_dc #1#2% {% - \ifnum\XINT_Sgn{#1}<0 - \xint_afterfi {\expandafter\XINT_div_final_dP\the\numexpr #2-1\relax}% + \ifnum\XINT_Sgn{#1}<\xint_c_ + \xint_afterfi + {\expandafter\XINT_div_final_dP\the\numexpr #2-\xint_c_i\relax}% \else \xint_afterfi {\XINT_div_final_e {#1}#2}% \fi }% @@ -2615,9 +2671,9 @@ }% \def\XINT_div_body_d #1#2#3#4#5#6% {% - \ifnum #1 > 0 + \ifnum #1 >\xint_c_ \expandafter\XINT_div_body_d - \expandafter{\the\numexpr #1-4\expandafter }% + \expandafter{\the\numexpr #1-\xint_c_iv\expandafter }% \else \expandafter\XINT_div_body_e \fi @@ -2630,7 +2686,7 @@ \def\XINT_div_body_f #1#2#3#4#5#6#7#8% {% \expandafter\XINT_div_body_gg - \the\numexpr (#1+(#5+1)/2)/(#5+1)+99999\relax + \the\numexpr (#1+(#5+\xint_c_i)/\xint_c_ii)/(#5+\xint_c_i)+99999\relax {#8}{#2}{#8}{#4}{#5}{#3}{#6}{#7}{#8}% }% \def\XINT_div_body_gg #1#2#3#4#5#6% @@ -2664,7 +2720,7 @@ }% \def\XINT_div_body_h #1#2#3#4#5#6#7#8#9\Z {% - \ifnum #1#2#3#4>0 + \ifnum #1#2#3#4>\xint_c_ \xint_afterfi{\XINT_div_body_i {#1#2#3#4#5#6#7#8}}% \else \expandafter\XINT_div_body_k @@ -2691,14 +2747,14 @@ \def\XINT_div_body_l #1#2#3#4#5#6#7% {% \expandafter\XINT_div_body_m - \the\numexpr 100000000+#2\relax {#6}{#3}{#7}{#1#5}{#4}% + \the\numexpr \xint_c_x^viii+#2\relax {#6}{#3}{#7}{#1#5}{#4}% }% -\def\XINT_div_body_m #1#2#3#4#5#6#7#8#9% +\def\XINT_div_body_m 1#1#2#3#4#5#6#7#8% {% - \ifnum #2#3#4#5>0 - \xint_afterfi {\XINT_div_body_n {#9#8#7#6#5#4#3#2}}% + \ifnum #1#2#3#4>\xint_c_ + \xint_afterfi {\XINT_div_body_n {#8#7#6#5#4#3#2#1}}% \else - \xint_afterfi {\XINT_div_body_n {#9#8#7#6}}% + \xint_afterfi {\XINT_div_body_n {#8#7#6#5}}% \fi }% \def\XINT_div_body_n #1#2% @@ -2714,7 +2770,7 @@ {% \ifnum #1 > #2 \xint_afterfi - {\ifnum #4#5#6#7 > 0 + {\ifnum #4#5#6#7 > \xint_c_ \expandafter\XINT_div_body_q \else \expandafter\XINT_div_body_repeatp @@ -2742,30 +2798,31 @@ }% \def\XINT_div_sub_xpxp #1% {% - \expandafter \XINT_div_sub_xpxp_ \expandafter{#1}% + \expandafter \XINT_div_sub_xpxp_a \expandafter{#1}% }% -\def\XINT_div_sub_xpxp_ #1#2% +\def\XINT_div_sub_xpxp_a #1#2% {% - \expandafter\expandafter\expandafter\XINT_div_sub_xpxp__ + \expandafter\expandafter\expandafter\XINT_div_sub_xpxp_b #2\W\X\Y\Z #1\W\X\Y\Z }% -\def\XINT_div_sub_xpxp__ +\def\XINT_div_sub_xpxp_b {% \XINT_div_sub_A 1{}% }% \def\XINT_div_sub_A #1#2#3#4#5#6% {% - \xint_gob_til_w #3\xint_div_sub_az\W + \xint_gob_til_W #3\xint_div_sub_az\W \XINT_div_sub_B #1{#3#4#5#6}{#2}% }% \def\XINT_div_sub_B #1#2#3#4\W\X\Y\Z #5#6#7#8% {% - \xint_gob_til_w #5\xint_div_sub_bz\W + \xint_gob_til_W #5\xint_div_sub_bz\W \XINT_div_sub_onestep #1#2{#8#7#6#5}{#3}#4\W\X\Y\Z }% \def\XINT_div_sub_onestep #1#2#3#4#5#6% {% - \expandafter\XINT_div_sub_backtoA\the\numexpr 11#5#4#3#2-#6+#1-1\relax.% + \expandafter\XINT_div_sub_backtoA + \the\numexpr 11#5#4#3#2-#6+#1-\xint_c_i\relax.% }% \def\XINT_div_sub_backtoA #1#2#3.#4% {% @@ -2792,12 +2849,12 @@ }% \def\XINT_div_sub_C #1#2#3#4#5% {% - \xint_gob_til_w #2\xint_div_sub_cz\W + \xint_gob_til_W #2\xint_div_sub_cz\W \XINT_div_sub_AC_onestep {#5#4#3#2}{#1}% }% \def\XINT_div_sub_AC_onestep #1% {% - \expandafter\XINT_div_sub_backtoC\the\numexpr 11#1-1\relax.% + \expandafter\XINT_div_sub_backtoC\the\numexpr 11#1-\xint_c_i\relax.% }% \def\XINT_div_sub_backtoC #1#2#3.#4% {% @@ -2909,7 +2966,7 @@ }% \def\XINT_dsr_b #1#2#3\Z {% - \xint_gob_til_w #2\xint_dsr_onedigit\W + \xint_gob_til_W #2\xint_dsr_onedigit\W \xint_minus #2\xint_dsr_onedigit-% \expandafter\XINT_dsr_removew \romannumeral0\XINT_rev {#2#3}% @@ -3037,7 +3094,7 @@ }% \def\XINT_dsx_AisNeg_checkiffirstempty #1% {% - \xint_gob_til_z #1\XINT_dsx_AisNeg_finish_zero\Z + \xint_gob_til_Z #1\XINT_dsx_AisNeg_finish_zero\Z \XINT_dsx_AisNeg_finish_notzero #1% }% \def\XINT_dsx_AisNeg_finish_zero\Z @@ -3127,7 +3184,7 @@ \def\XINT_split_fromleft_eight #1#2#3#4#5#6#7#8#9{#9{#1#2#3#4#5#6#7#8#9}}% \def\XINT_split_fromleft_loop_perhaps #1#2% {% - \xint_gob_til_w #2\XINT_split_fromleft_toofar\W + \xint_gob_til_W #2\XINT_split_fromleft_toofar\W \XINT_split_fromleft_loop {#1}% }% \def\XINT_split_fromleft_toofar\W\XINT_split_fromleft_loop #1#2#3\Z @@ -3159,7 +3216,7 @@ {\XINT_split_fromleft_checkiftoofar #8{#1#2#3#4#5#6#7#8}}% \def\XINT_split_fromleft_checkiftoofar #1#2#3\W #4\Z {% - \xint_gob_til_w #1\XINT_split_fromleft_wenttoofar\W + \xint_gob_til_W #1\XINT_split_fromleft_wenttoofar\W \space {#2}{#3}% }% \def\XINT_split_fromleft_wenttoofar\W\space #1% @@ -3185,7 +3242,7 @@ \def\XINT_split_fromright_eight #1#2#3#4#5#6#7#8#9{#9{#9#8#7#6#5#4#3#2#1}}% \def\XINT_split_fromright_loop_perhaps #1#2% {% - \xint_gob_til_w #2\XINT_split_fromright_toofar\W + \xint_gob_til_W #2\XINT_split_fromright_toofar\W \XINT_split_fromright_loop {#1}% }% \def\XINT_split_fromright_toofar\W\XINT_split_fromright_loop #1#2#3\Z { {}}% @@ -3216,11 +3273,381 @@ {\XINT_split_fromright_checkiftoofar #8{#8#7#6#5#4#3#2#1}}% \def\XINT_split_fromright_checkiftoofar #1% {% - \xint_gob_til_w #1\XINT_split_fromright_wenttoofar\W + \xint_gob_til_W #1\XINT_split_fromright_wenttoofar\W \XINT_split_fromright_endsplit_ }% \def\XINT_split_fromright_wenttoofar\W\XINT_split_fromright_endsplit_ #1\Z #2% { {}{#2}}% +\def\xintDouble {\romannumeral0\xintdouble }% +\def\xintdouble #1% +{% + \expandafter\XINT_dbl\romannumeral-`0#1% + \R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W +}% +\def\XINT_dbl #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_dbl_zero + 0#1\dummy \XINT_dbl_neg + 0-\dummy {\XINT_dbl_pos #1}% + \krof +}% +\def\XINT_dbl_zero #1\Z \W\W\W\W\W\W\W { 0}% +\def\XINT_dbl_neg + {\expandafter\xint_minus_andstop\romannumeral0\XINT_dbl_pos }% +\def\XINT_dbl_pos +{% + \expandafter\XINT_dbl_a \expandafter{\expandafter}\expandafter 0% + \romannumeral0\XINT_SQ {}% +}% +\def\XINT_dbl_a #1#2#3#4#5#6#7#8#9% +{% + \xint_gob_til_W #9\XINT_dbl_end_a\W + \expandafter\XINT_dbl_b + \the\numexpr \xint_c_x^viii+#2+\xint_c_ii*#9#8#7#6#5#4#3\relax {#1}% +}% +\def\XINT_dbl_b 1#1#2#3#4#5#6#7#8#9% +{% + \XINT_dbl_a {#2#3#4#5#6#7#8#9}{#1}% +}% +\def\XINT_dbl_end_a #1+#2+#3\relax #4% +{% + \expandafter\XINT_dbl_end_b #2#4% +}% +\def\XINT_dbl_end_b #1#2#3#4#5#6#7#8% +{% + \expandafter\space\the\numexpr #1#2#3#4#5#6#7#8\relax +}% +\def\xintHalf {\romannumeral0\xinthalf }% +\def\xinthalf #1% +{% + \expandafter\XINT_half\romannumeral-`0#1% + \R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W +}% +\def\XINT_half #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_half_zero + 0#1\dummy \XINT_half_neg + 0-\dummy {\XINT_half_pos #1}% + \krof +}% +\def\XINT_half_zero #1\Z \W\W\W\W\W\W\W { 0}% +\def\XINT_half_neg {\expandafter\XINT_opp\romannumeral0\XINT_half_pos }% +\def\XINT_half_pos {\expandafter\XINT_half_a\romannumeral0\XINT_SQ {}}% +\def\XINT_half_a #1#2#3#4#5#6#7#8% +{% + \xint_gob_til_W #8\XINT_half_dont\W + \expandafter\XINT_half_b + \the\numexpr \xint_c_x^viii+\xint_c_v*#7#6#5#4#3#2#1\relax #8% +}% +\def\XINT_half_dont\W\expandafter\XINT_half_b + \the\numexpr \xint_c_x^viii+\xint_c_v*#1#2#3#4#5#6#7\relax \W\W\W\W\W\W\W +{% + \expandafter\space + \the\numexpr (#1#2#3#4#5#6#7+\xint_c_i)/\xint_c_ii-\xint_c_i \relax +}% +\def\XINT_half_b 1#1#2#3#4#5#6#7#8% +{% + \XINT_half_c {#2#3#4#5#6#7}{#1}% +}% +\def\XINT_half_c #1#2#3#4#5#6#7#8#9% +{% + \xint_gob_til_W #3\XINT_half_end_a #2\W + \expandafter\XINT_half_d + \the\numexpr \xint_c_x^viii+\xint_c_v*#9#8#7#6#5#4#3+#2\relax {#1}% +}% +\def\XINT_half_d 1#1#2#3#4#5#6#7#8#9% +{% + \XINT_half_c {#2#3#4#5#6#7#8#9}{#1}% +}% +\def\XINT_half_end_a #1\W #2\relax #3% +{% + \xint_gob_til_zero #1\XINT_half_end_b 0\space #1#3% +}% +\def\XINT_half_end_b 0\space 0#1#2#3#4#5#6#7% +{% + \expandafter\space\the\numexpr #1#2#3#4#5#6#7\relax +}% +\def\xintDec {\romannumeral0\xintdec }% +\def\xintdec #1% +{% + \expandafter\XINT_dec\romannumeral-`0#1% + \R\R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W\W +}% +\def\XINT_dec #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_dec_zero + 0#1\dummy \XINT_dec_neg + 0-\dummy {\XINT_dec_pos #1}% + \krof +}% +\def\XINT_dec_zero #1\W\W\W\W\W\W\W\W { -1}% +\def\XINT_dec_neg + {\expandafter\xint_minus_andstop\romannumeral0\XINT_inc_pos }% +\def\XINT_dec_pos +{% + \expandafter\XINT_dec_a \expandafter{\expandafter}% + \romannumeral0\XINT_OQ {}% +}% +\def\XINT_dec_a #1#2#3#4#5#6#7#8#9% +{% + \expandafter\XINT_dec_b + \the\numexpr 11#9#8#7#6#5#4#3#2-\xint_c_i\relax {#1}% +}% +\def\XINT_dec_b 1#1% +{% + \xint_gob_til_one #1\XINT_dec_A 1\XINT_dec_c +}% +\def\XINT_dec_c #1#2#3#4#5#6#7#8#9{\XINT_dec_a {#1#2#3#4#5#6#7#8#9}}% +\def\XINT_dec_A 1\XINT_dec_c #1#2#3#4#5#6#7#8#9% + {\XINT_dec_B {#1#2#3#4#5#6#7#8#9}}% +\def\XINT_dec_B #1#2\W\W\W\W\W\W\W\W +{% + \expandafter\XINT_dec_cleanup + \romannumeral0\XINT_rord_main {}#2% + \xint_relax + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_relax + #1% +}% +\def\XINT_dec_cleanup #1#2#3#4#5#6#7#8% +{\expandafter\space\the\numexpr #1#2#3#4#5#6#7#8\relax }% +\def\xintInc {\romannumeral0\xintinc }% +\def\xintinc #1% +{% + \expandafter\XINT_inc\romannumeral-`0#1% + \R\R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W\W +}% +\def\XINT_inc #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_inc_zero + 0#1\dummy \XINT_inc_neg + 0-\dummy {\XINT_inc_pos #1}% + \krof +}% +\def\XINT_inc_zero #1\W\W\W\W\W\W\W\W { 1}% +\def\XINT_inc_neg {\expandafter\XINT_opp\romannumeral0\XINT_dec_pos }% +\def\XINT_inc_pos +{% + \expandafter\XINT_inc_a \expandafter{\expandafter}% + \romannumeral0\XINT_OQ {}% +}% +\def\XINT_inc_a #1#2#3#4#5#6#7#8#9% +{% + \xint_gob_til_W #9\XINT_inc_end\W + \expandafter\XINT_inc_b + \the\numexpr 10#9#8#7#6#5#4#3#2+\xint_c_i\relax {#1}% +}% +\def\XINT_inc_b 1#1% +{% + \xint_gob_til_zero #1\XINT_inc_A 0\XINT_inc_c +}% +\def\XINT_inc_c #1#2#3#4#5#6#7#8#9{\XINT_inc_a {#1#2#3#4#5#6#7#8#9}}% +\def\XINT_inc_A 0\XINT_inc_c #1#2#3#4#5#6#7#8#9% + {\XINT_dec_B {#1#2#3#4#5#6#7#8#9}}% +\def\XINT_inc_end\W #1\relax #2{ 1#2}% +\def\XINT_dsx_addzerosnofuss #1{\XINT_dsx_zeroloop {#1}{}\Z }% +\def\xintiSqrt {\romannumeral0\xintisqrt }% +\def\xintisqrt + {\expandafter\XINT_sqrt_post\romannumeral0\xintisquareroot }% +\def\XINT_sqrt_post #1#2{\XINT_dec_pos #1\R\R\R\R\R\R\R\R\Z + \W\W\W\W\W\W\W\W }% +\def\xintiSquareRoot {\romannumeral0\xintisquareroot }% +\def\xintisquareroot #1% + {\expandafter\XINT_sqrt_checkin\romannumeral-`0#1\Z}% +\def\XINT_sqrt_checkin #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_sqrt_iszero + 0#1\dummy \XINT_sqrt_isneg + 0-\dummy {\XINT_sqrt #1}% + \krof +}% +\def\XINT_sqrt_iszero #1\Z { 0}% +\def\XINT_sqrt_isneg #1\Z {\xintError:RootOfNegative\space 0}% +\def\XINT_sqrt #1\Z +{% + \expandafter\XINT_sqrt_start\expandafter + {\romannumeral0\XINT_length {#1}}{#1}% +}% +\def\XINT_sqrt_start #1% +{% + \ifnum #1<\xint_c_x + \expandafter\XINT_sqrt_small_a + \else + \expandafter\XINT_sqrt_big_a + \fi + {#1}% +}% +\def\XINT_sqrt_small_a #1{\XINT_sqrt_a {#1}\XINT_sqrt_small_d }% +\def\XINT_sqrt_big_a #1{\XINT_sqrt_a {#1}\XINT_sqrt_big_d }% +\def\XINT_sqrt_a #1% +{% + \ifodd #1 + \expandafter\XINT_sqrt_bB + \else + \expandafter\XINT_sqrt_bA + \fi + {#1}% +}% +\def\XINT_sqrt_bA #1#2#3% +{% + \XINT_sqrt_bA_b #3\Z #2{#1}{#3}% +}% +\def\XINT_sqrt_bA_b #1#2#3\Z +{% + \XINT_sqrt_c {#1#2}% +}% +\def\XINT_sqrt_bB #1#2#3% +{% + \XINT_sqrt_bB_b #3\Z #2{#1}{#3}% +}% +\def\XINT_sqrt_bB_b #1#2\Z +{% + \XINT_sqrt_c #1% +}% +\def\XINT_sqrt_c #1#2% +{% + \expandafter #2% + \ifcase #1 + \or 2\or 2\or 2\or 3\or 3\or 3\or 3\or 3\or %3+5 + 4\or 4\or 4\or 4\or 4\or 4\or 4\or %+7 + 5\or 5\or 5\or 5\or 5\or 5\or 5\or 5\or 5\or %+9 + 6\or 6\or 6\or 6\or 6\or 6\or 6\or 6\or 6\or 6\or 6\or %+11 + 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or 7\or %+13 + 8\or 8\or 8\or 8\or 8\or 8\or 8\or + 8\or 8\or 8\or 8\or 8\or 8\or 8\or 8\or %+15 + 9\or 9\or 9\or 9\or 9\or 9\or 9\or 9\or + 9\or 9\or 9\or 9\or 9\or 9\or 9\or 9\or 9\or %+17 + 10\or 10\or 10\or 10\or 10\or 10\or 10\or 10\or 10\or + 10\or 10\or 10\or 10\or 10\or 10\or 10\or 10\or 10\or 10\or\fi %+19 +}% +\def\XINT_sqrt_small_d #1\or #2\fi #3% +{% + \fi + \expandafter\XINT_sqrt_small_de + \ifcase \numexpr #3/\xint_c_ii-\xint_c_i\relax + {}% + \or + 0% + \or + {00}% + \or + {000}% + \or + {0000}% + \or + \fi {#1}% +}% +\def\XINT_sqrt_small_de #1\or #2\fi #3% +{% + \fi\XINT_sqrt_small_e {#3#1}% +}% +\def\XINT_sqrt_small_e #1#2% +{% + \expandafter\XINT_sqrt_small_f\expandafter {\the\numexpr #1*#1-#2}{#1}% +}% +\def\XINT_sqrt_small_f #1#2% +{% + \expandafter\XINT_sqrt_small_g\expandafter + {\the\numexpr ((#1+#2)/(\xint_c_ii*#2))-\xint_c_i}{#1}{#2}% +}% +\def\XINT_sqrt_small_g #1% +{% + \ifnum #1>\xint_c_ + \expandafter\XINT_sqrt_small_h + \else + \expandafter\XINT_sqrt_small_end + \fi + {#1}% +}% +\def\XINT_sqrt_small_h #1#2#3% +{% + \expandafter\XINT_sqrt_small_f\expandafter + {\the\numexpr #2-\xint_c_ii*#1*#3+#1*#1\expandafter}\expandafter + {\the\numexpr #3-#1}% +}% +\def\XINT_sqrt_small_end #1#2#3{ {#3}{#2}}% +\def\XINT_sqrt_big_d #1\or #2\fi #3% +{% + \fi + \ifodd #3 + \xint_afterfi{\expandafter\XINT_sqrt_big_eB}% + \else + \xint_afterfi{\expandafter\XINT_sqrt_big_eA}% + \fi + \expandafter{\the\numexpr #3/\xint_c_ii }{#1}% +}% +\def\XINT_sqrt_big_eA #1#2#3% +{% + \XINT_sqrt_big_eA_a #3\Z {#2}{#1}{#3}% +}% +\def\XINT_sqrt_big_eA_a #1#2#3#4#5#6#7#8#9\Z +{% + \XINT_sqrt_big_eA_b {#1#2#3#4#5#6#7#8}% +}% +\def\XINT_sqrt_big_eA_b #1#2% +{% + \expandafter\XINT_sqrt_big_f + \romannumeral0\XINT_sqrt_small_e {#2000}{#1}{#1}% +}% +\def\XINT_sqrt_big_eB #1#2#3% +{% + \XINT_sqrt_big_eB_a #3\Z {#2}{#1}{#3}% +}% +\def\XINT_sqrt_big_eB_a #1#2#3#4#5#6#7#8#9% +{% + \XINT_sqrt_big_eB_b {#1#2#3#4#5#6#7#8#9}% +}% +\def\XINT_sqrt_big_eB_b #1#2\Z #3% +{% + \expandafter\XINT_sqrt_big_f + \romannumeral0\XINT_sqrt_small_e {#30000}{#1}{#1}% +}% +\def\XINT_sqrt_big_f #1#2#3#4% +{% + \expandafter\XINT_sqrt_big_f_a\expandafter + {\the\numexpr #2+#3\expandafter}\expandafter + {\romannumeral-`0\XINT_dsx_addzerosnofuss + {\numexpr #4-\xint_c_iv\relax}{#1}}{#4}% +}% +\def\XINT_sqrt_big_f_a #1#2#3#4% +{% + \expandafter\XINT_sqrt_big_g\expandafter + {\romannumeral0\xintisub + {\XINT_dsx_addzerosnofuss + {\numexpr \xint_c_ii*#3-\xint_c_viii\relax}{#1}}{#4}}% + {#2}{#3}% +}% +\def\XINT_sqrt_big_g #1#2% +{% + \expandafter\XINT_sqrt_big_j + \romannumeral0\xintidivision{#1} + {\romannumeral0\XINT_dbl_pos #2\R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W }{#2}% +}% +\def\XINT_sqrt_big_j #1% +{% + \ifcase\XINT_Sgn {#1} + \expandafter \XINT_sqrt_big_end + \or \expandafter \XINT_sqrt_big_k + \fi {#1}% +}% +\def\XINT_sqrt_big_k #1#2#3% +{% + \expandafter\XINT_sqrt_big_l\expandafter + {\romannumeral0\xintisub {#3}{#1}}% + {\romannumeral0\xintiadd {#2}{\xintiSqr {#1}}}% +}% +\def\XINT_sqrt_big_l #1#2% +{% + \expandafter\XINT_sqrt_big_g\expandafter + {#2}{#1}% +}% +\def\XINT_sqrt_big_end #1#2#3#4{ {#3}{#2}}% \XINT_restorecatcodes_endinput% \endinput %% diff --git a/Master/texmf-dist/tex/generic/xint/xintbinhex.sty b/Master/texmf-dist/tex/generic/xint/xintbinhex.sty new file mode 100644 index 00000000000..d023151c236 --- /dev/null +++ b/Master/texmf-dist/tex/generic/xint/xintbinhex.sty @@ -0,0 +1,732 @@ +%% +%% This is file `xintbinhex.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% xint.dtx (with options: `xintbinhex') +%% +%% IMPORTANT NOTICE: +%% +%% For the copyright see the source file. +%% +%% Any modified versions of this file must be renamed +%% with new filenames distinct from xintbinhex.sty. +%% +%% For distribution of the original source see the terms +%% for copying and modification in the file xint.dtx. +%% +%% This generated file may be distributed as long as the +%% original source files, as listed above, are part of the +%% same distribution. (The sources need not necessarily be +%% in the same archive or directory.) +%% +%%---------------------------------------------------------------- +%% The xint bundle (version 1.08b of June 14, 2013) +%% xintbinhex: Expandable binary and hexadecimal conversions +%% Copyright (C) 2013 by Jean-Francois Burnol +%%---------------------------------------------------------------- +%% +\begingroup\catcode61\catcode48\catcode32=10\relax% + \catcode13=5 % ^^M + \endlinechar=13 % + \catcode123=1 % { + \catcode125=2 % } + \catcode64=11 % @ + \catcode35=6 % # + \catcode44=12 % , + \catcode45=12 % - + \catcode46=12 % . + \catcode58=12 % : + \def\space { }% + \let\z\endgroup + \expandafter\let\expandafter\x\csname ver@xintbinhex.sty\endcsname + \expandafter\let\expandafter\w\csname ver@xint.sty\endcsname + \expandafter + \ifx\csname PackageInfo\endcsname\relax + \def\y#1#2{\immediate\write-1{Package #1 Info: #2.}}% + \else + \def\y#1#2{\PackageInfo{#1}{#2}}% + \fi + \expandafter + \ifx\csname numexpr\endcsname\relax + \y{xintbinhex}{\numexpr not available, aborting input}% + \aftergroup\endinput + \else + \ifx\x\relax % plain-TeX, first loading of xintbinhex.sty + \ifx\w\relax % but xint.sty not yet loaded. + \y{xintbinhex}{Package xint is required}% + \y{xintbinhex}{Will try \string\input\space xint.sty}% + \def\z{\endgroup\input xint.sty\relax}% + \fi + \else + \def\empty {}% + \ifx\x\empty % LaTeX, first loading, + % variable is initialized, but \ProvidesPackage not yet seen + \ifx\w\relax % xint.sty not yet loaded. + \y{xintbinhex}{Package xint is required}% + \y{xintbinhex}{Will try \string\RequirePackage{xint}}% + \def\z{\endgroup\RequirePackage{xint}}% + \fi + \else + \y{xintbinhex}{I was already loaded, aborting input}% + \aftergroup\endinput + \fi + \fi + \fi +\z% +\begingroup\catcode61\catcode48\catcode32=10\relax% + \catcode13=5 % ^^M + \endlinechar=13 % + \catcode123=1 % { + \catcode125=2 % } + \catcode64=11 % @ + \catcode35=6 % # + \catcode44=12 % , + \catcode45=12 % - + \catcode46=12 % . + \catcode58=12 % : + \expandafter + \ifx\csname PackageInfo\endcsname\relax + \def\y#1#2{\immediate\write-1{Package #1 Info: #2.}}% + \else + \def\y#1#2{\PackageInfo{#1}{#2}}% + \fi + \def\empty {}% + \expandafter\let\expandafter\w\csname ver@xint.sty\endcsname + \ifx\w\relax % Plain TeX, user gave a file name at the prompt + \y{xintbinhex}{Loading of package xint failed, aborting input}% + \aftergroup\endinput + \fi + \ifx\w\empty % LaTeX, user gave a file name at the prompt + \y{xintbinhex}{Loading of package xint failed, aborting input}% + \aftergroup\endinput + \fi +\endgroup% +\begingroup\catcode61\catcode48\catcode32=10\relax% + \catcode13=5 % ^^M + \endlinechar=13 % + \catcode123=1 % { + \catcode125=2 % } + \catcode95=11 % _ + \def\x + {% + \endgroup + \edef\XINT_binhex_restorecatcodes_endinput + {% + \catcode94=\the\catcode94 % ^ + \catcode96=\the\catcode96 % ` + \catcode47=\the\catcode47 % / + \catcode41=\the\catcode41 % ) + \catcode40=\the\catcode40 % ( + \catcode42=\the\catcode42 % * + \catcode43=\the\catcode43 % + + \catcode62=\the\catcode62 % > + \catcode60=\the\catcode60 % < + \catcode58=\the\catcode58 % : + \catcode46=\the\catcode46 % . + \catcode45=\the\catcode45 % - + \catcode44=\the\catcode44 % , + \catcode35=\the\catcode35 % # + \catcode95=\the\catcode95 % _ + \catcode125=\the\catcode125 % } + \catcode123=\the\catcode123 % { + \endlinechar=\the\endlinechar + \catcode13=\the\catcode13 % ^^M + \catcode32=\the\catcode32 % + \catcode61=\the\catcode61\relax % = + \noexpand\endinput + }% + \XINT_setcatcodes % defined in xint.sty + }% +\x +\begingroup + \catcode64=11 % @ + \catcode91=12 % [ + \catcode93=12 % ] + \catcode58=12 % : + \expandafter\ifx\csname ProvidesPackage\endcsname\relax + \def\x#1#2#3[#4]{\endgroup + \immediate\write-1{Package: #3 #4}% + \xdef#1{#4}% + }% + \else + \def\x#1#2[#3]{\endgroup + #2[{#3}]% + \ifx#1\@undefined + \xdef#1{#3}% + \fi + \ifx#1\relax + \xdef#1{#3}% + \fi + }% + \fi +\expandafter\x\csname ver@xintbinhex.sty\endcsname +\ProvidesPackage{xintbinhex}% + [2013/06/14 v1.08b Expandable binary and hexadecimal conversions (jfB)]% +\chardef\xint_c_xvi 16 +\chardef\xint_c_ii^v 32 +\chardef\xint_c_ii^vi 64 +\chardef\xint_c_ii^vii 128 +\mathchardef\xint_c_ii^viii 256 +\mathchardef\xint_c_ii^xii 4096 +\newcount\xint_c_ii^xv \xint_c_ii^xv 32768 +\newcount\xint_c_ii^xvi \xint_c_ii^xvi 65536 +\newcount\xint_c_x^v \xint_c_x^v 100000 +\newcount\xint_c_x^ix \xint_c_x^ix 1000000000 +\def\XINT_tmp_def #1{% + \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}}% +\xintApplyUnbraced\XINT_tmp_def + {{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}}% +\def\XINT_tmp_def #1{% + \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}}% +\xintApplyUnbraced\XINT_tmp_def + {{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}}% +\let\XINT_tmp_def\empty +\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_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}% +\expandafter\def\csname XINT_shtb_0\endcsname {0000}% +\expandafter\def\csname XINT_shtb_1\endcsname {0001}% +\expandafter\def\csname XINT_shtb_2\endcsname {0010}% +\expandafter\def\csname XINT_shtb_3\endcsname {0011}% +\expandafter\def\csname XINT_shtb_4\endcsname {0100}% +\expandafter\def\csname XINT_shtb_5\endcsname {0101}% +\expandafter\def\csname XINT_shtb_6\endcsname {0110}% +\expandafter\def\csname XINT_shtb_7\endcsname {0111}% +\expandafter\def\csname XINT_shtb_8\endcsname {1000}% +\expandafter\def\csname XINT_shtb_9\endcsname {1001}% +\def\XINT_shtb_A {1010}% +\def\XINT_shtb_B {1011}% +\def\XINT_shtb_C {1100}% +\def\XINT_shtb_D {1101}% +\def\XINT_shtb_E {1110}% +\def\XINT_shtb_F {1111}% +\def\XINT_shtb_G {}% +\def\XINT_smallhex #1% +{% + \expandafter\XINT_smallhex_a\expandafter + {\the\numexpr (#1+\xint_c_viii)/\xint_c_xvi-\xint_c_i}{#1}% +}% +\def\XINT_smallhex_a #1#2% +{% + \csname XINT_sdth_#1\expandafter\expandafter\expandafter\endcsname + \csname XINT_sdth_\the\numexpr #2-\xint_c_xvi*#1\endcsname +}% +\def\XINT_smallbin #1% +{% + \expandafter\XINT_smallbin_a\expandafter + {\the\numexpr (#1+\xint_c_viii)/\xint_c_xvi-\xint_c_i}{#1}% +}% +\def\XINT_smallbin_a #1#2% +{% + \csname XINT_sdtb_#1\expandafter\expandafter\expandafter\endcsname + \csname XINT_sdtb_\the\numexpr #2-\xint_c_xvi*#1\endcsname +}% +\def\xintDecToHex {\romannumeral0\xintdectohex }% +\def\xintdectohex #1% + {\expandafter\XINT_dth_checkin\romannumeral-`0#1\W\W\W\W \T}% +\def\XINT_dth_checkin #1% +{% + \xint_UDsignfork + #1\dummy \XINT_dth_N + -\dummy {\XINT_dth_P #1}% + \krof +}% +\def\XINT_dth_N {\expandafter\xint_minus_andstop\romannumeral0\XINT_dth_P }% +\def\XINT_dth_P {\expandafter\XINT_dth_III\romannumeral-`0\XINT_dtbh_I {0.}}% +\def\xintDecToBin {\romannumeral0\xintdectobin }% +\def\xintdectobin #1% + {\expandafter\XINT_dtb_checkin\romannumeral-`0#1\W\W\W\W \T }% +\def\XINT_dtb_checkin #1% +{% + \xint_UDsignfork + #1\dummy \XINT_dtb_N + -\dummy {\XINT_dtb_P #1}% + \krof +}% +\def\XINT_dtb_N {\expandafter\xint_minus_andstop\romannumeral0\XINT_dtb_P }% +\def\XINT_dtb_P {\expandafter\XINT_dtb_III\romannumeral-`0\XINT_dtbh_I {0.}}% +\def\XINT_dtbh_I #1#2#3#4#5% +{% + \xint_gob_til_W #5\XINT_dtbh_II_a\W\XINT_dtbh_I_a {}{#2#3#4#5}#1\Z.% +}% +\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% +{% + \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% +}% +\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.% +{% + \xint_gob_til_Z #3\XINT_dtbh_I_z\Z + \expandafter\XINT_dtbh_I_b\the\numexpr #2+#30000.{#1}% +}% +\def\XINT_dtbh_I_b #1.% +{% + \expandafter\XINT_dtbh_I_c\the\numexpr + (#1+\xint_c_ii^xv)/\xint_c_ii^xvi-\xint_c_i.#1.% +}% +\def\XINT_dtbh_I_c #1.#2.% +{% + \expandafter\XINT_dtbh_I_d\expandafter + {\the\numexpr #2-\xint_c_ii^xvi*#1}{#1}% +}% +\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.% +{% + \ifnum #1=\xint_c_ \expandafter\XINT_dtbh_I_end_zb\fi + \XINT_dtbh_I_end_za {#1}% +}% +\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.% +{% + \xint_gob_til_Z #4\XINT_dtbh_II_z\Z + \expandafter\XINT_dtbh_II_e\the\numexpr #2+#4#3.{#1}{#3}% +}% +\def\XINT_dtbh_II_e #1.% +{% + \expandafter\XINT_dtbh_II_f\the\numexpr + (#1+\xint_c_ii^xv)/\xint_c_ii^xvi-\xint_c_i.#1.% +}% +\def\XINT_dtbh_II_f #1.#2.% +{% + \expandafter\XINT_dtbh_II_g\expandafter + {\the\numexpr #2-\xint_c_ii^xvi*#1}{#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.% +{% + \ifnum #1=\xint_c_ \expandafter\XINT_dtbh_II_end_zb\fi + \XINT_dtbh_II_end_za {#1}% +}% +\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.% +{% + \xint_gob_til_Z #2\XINT_dth_end\Z + \expandafter\XINT_dth_III\expandafter + {\romannumeral-`0\XINT_dth_small #2.#1}% +}% +\def\XINT_dth_small #1.% +{% + \expandafter\XINT_smallhex\expandafter + {\the\numexpr (#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i\expandafter}% + \romannumeral-`0\expandafter\XINT_smallhex\expandafter + {\the\numexpr + #1-((#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i)*\xint_c_ii^viii}% +}% +\def\XINT_dth_end\Z\expandafter\XINT_dth_III\expandafter #1#2\T +{% + \XINT_dth_end_b #1% +}% +\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% +{% + \xint_gob_til_zero #1\XINT_dth_end_e 0\space #1% +}% +\def\XINT_dth_end_e 0\space 0#1% +{% + \xint_gob_til_zero #1\XINT_dth_end_f 0\space #1% +}% +\def\XINT_dth_end_f 0\space 0{ }% +\def\XINT_dtb_III #1#2.% +{% + \xint_gob_til_Z #2\XINT_dtb_end\Z + \expandafter\XINT_dtb_III\expandafter + {\romannumeral-`0\XINT_dtb_small #2.#1}% +}% +\def\XINT_dtb_small #1.% +{% + \expandafter\XINT_smallbin\expandafter + {\the\numexpr (#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i\expandafter}% + \romannumeral-`0\expandafter\XINT_smallbin\expandafter + {\the\numexpr + #1-((#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i)*\xint_c_ii^viii}% +}% +\def\XINT_dtb_end\Z\expandafter\XINT_dtb_III\expandafter #1#2\T +{% + \XINT_dtb_end_b #1% +}% +\def\XINT_dtb_end_b #1.{\XINT_dtb_end_c }% +\def\XINT_dtb_end_c #1#2#3#4#5#6#7#8% +{% + \expandafter\XINT_dtb_end_d\the\numexpr #1#2#3#4#5#6#7#8\relax +}% +\def\XINT_dtb_end_d #1#2#3#4#5#6#7#8#9% +{% + \expandafter\space\the\numexpr #1#2#3#4#5#6#7#8#9\relax +}% +\def\xintHexToDec {\romannumeral0\xinthextodec }% +\def\xinthextodec #1% + {\expandafter\XINT_htd_checkin\romannumeral-`0#1\W\W\W\W \T }% +\def\XINT_htd_checkin #1% +{% + \xint_UDsignfork + #1\dummy \XINT_htd_neg + -\dummy {\XINT_htd_I {0000}#1}% + \krof +}% +\def\XINT_htd_neg {\expandafter\xint_minus_andstop + \romannumeral0\XINT_htd_I {0000}}% +\def\XINT_htd_I #1#2#3#4#5% +{% + \xint_gob_til_W #5\XINT_htd_II_a\W + \XINT_htd_I_a {}{"#2#3#4#5}#1\Z\Z\Z\Z +}% +\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% +{% + \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% +}% +\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 +{% + \expandafter\xint_cleanupzeros_andstop + \romannumeral0\XINT_rord_main {}#1% + \xint_relax + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_relax +}% +\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% +{% + \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}% +}% +\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 +{% + \expandafter\XINT_htd_I_end_b\the\numexpr \xint_c_x^v+#1\relax +}% +\def\XINT_htd_I_end_b 1#1#2#3#4#5% +{% + \xint_gob_til_zero #1\XINT_htd_I_end_bz0% + \XINT_htd_I_end_c #1#2#3#4#5% +}% +\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% +{% + \xint_gob_til_zeros_iv #1#2#3#4\XINT_htd_I_end_bzz 0000% + \XINT_htd_I_end_D {#4#3#2#1}% +}% +\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% +{% + \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}% +}% +\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 +{% + \XINT_htd_II_end_b #1#3% +}% +\def\XINT_htd_II_end_b #1#2#3#4#5#6#7#8% +{% + \expandafter\space\the\numexpr #1#2#3#4#5#6#7#8\relax +}% +\def\xintBinToDec {\romannumeral0\xintbintodec }% +\def\xintbintodec #1{\expandafter\XINT_btd_checkin + \romannumeral-`0#1\W\W\W\W\W\W\W\W \T }% +\def\XINT_btd_checkin #1% +{% + \xint_UDsignfork + #1\dummy \XINT_btd_neg + -\dummy {\XINT_btd_I {000000}#1}% + \krof +}% +\def\XINT_btd_neg {\expandafter\xint_minus_andstop + \romannumeral0\XINT_btd_I {000000}}% +\def\XINT_btd_I #1#2#3#4#5#6#7#8#9% +{% + \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 +}% +\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% +{% + \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% +}% +\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 +{% + \expandafter\XINT_btd_II_c_end + \romannumeral0\XINT_rord_main {}#2% + \xint_relax + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_relax +}% +\def\XINT_btd_II_c_end #1#2#3#4#5#6% +{% + \expandafter\space\the\numexpr #1#2#3#4#5#6\relax +}% +\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 +{% + \XINT_btd_II_d {}{\csname XINT_sbtd_#2#3#4#5\endcsname*\xint_c_ii+% + #6}{\xint_c_ii^v }% +}% +\def\XINT_btd_II_cvi #1\XINT_btd_II_cvii #2#3#4#5#6#7\W\W +{% + \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 }% +}% +\def\XINT_btd_II_cvii #1#2#3#4#5#6#7\W +{% + \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 }% +}% +\def\XINT_btd_II_d #1#2#3#4#5#6#7#8#9% +{% + \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}% +}% +\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 +{% + \XINT_btd_II_end_b #1#3% +}% +\def\XINT_btd_II_end_b #1#2#3#4#5#6#7#8#9% +{% + \expandafter\space\the\numexpr #1#2#3#4#5#6#7#8#9\relax +}% +\def\XINT_btd_I_a #1#2#3#4#5#6#7#8% +{% + \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}% +}% +\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 +{% + \expandafter\XINT_btd_I_end_b\the\numexpr 1000+#1\relax +}% +\def\XINT_btd_I_end_b 1#1#2#3% +{% + \xint_gob_til_zeros_iii #1#2#3\XINT_btd_I_end_bz 000% + \XINT_btd_I_end_c #1#2#3% +}% +\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 }% +\def\xintBinToHex {\romannumeral0\xintbintohex }% +\def\xintbintohex #1% +{% + \expandafter\XINT_bth_checkin + \romannumeral0\expandafter\XINT_num_loop + \romannumeral-`0#1\xint_relax\xint_relax + \xint_relax\xint_relax + \xint_relax\xint_relax\xint_relax\xint_relax\Z + \R\R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W\W +}% +\def\XINT_bth_checkin #1% +{% + \xint_UDsignfork + #1\dummy \XINT_bth_N + -\dummy {\XINT_bth_P #1}% + \krof +}% +\def\XINT_bth_N {\expandafter\xint_minus_andstop\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% +{% + \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% +{% + \xint_gob_til_zero #3\XINT_bth_end_z 0\space #3% +}% +\def\XINT_bth_end_z0\space 0{ }% +\def\xintHexToBin {\romannumeral0\xinthextobin }% +\def\xinthextobin #1% +{% + \expandafter\XINT_htb_checkin\romannumeral-`0#1GGGGGGGG\T +}% +\def\XINT_htb_checkin #1% +{% + \xint_UDsignfork + #1\dummy \XINT_htb_N + -\dummy {\XINT_htb_P #1}% + \krof +}% +\def\XINT_htb_N {\expandafter\xint_minus_andstop\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 +{% + \XINT_num_loop #2#1% + \xint_relax\xint_relax\xint_relax\xint_relax + \xint_relax\xint_relax\xint_relax\xint_relax\Z +}% +\def\xintCHexToBin {\romannumeral0\xintchextobin }% +\def\xintchextobin #1% +{% + \expandafter\XINT_chtb_checkin\romannumeral-`0#1% + \R\R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W\W +}% +\def\XINT_chtb_checkin #1% +{% + \xint_UDsignfork + #1\dummy \XINT_chtb_N + -\dummy {\XINT_chtb_P #1}% + \krof +}% +\def\XINT_chtb_N {\expandafter\xint_minus_andstop\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_relax\xint_relax\xint_relax\xint_relax + \xint_relax\xint_relax\xint_relax\xint_relax\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 +}% +\XINT_binhex_restorecatcodes_endinput% +\endinput +%% +%% End of file `xintbinhex.sty'. diff --git a/Master/texmf-dist/tex/generic/xint/xintcfrac.sty b/Master/texmf-dist/tex/generic/xint/xintcfrac.sty index 561738a7b02..87eabb785ed 100644 --- a/Master/texmf-dist/tex/generic/xint/xintcfrac.sty +++ b/Master/texmf-dist/tex/generic/xint/xintcfrac.sty @@ -22,7 +22,7 @@ %% in the same archive or directory.) %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.07a of May 26, 2013) +%% The xint bundle (version 1.08b of June 14, 2013) %% xintcfrac: Expandable continued fractions with xint package %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -116,6 +116,7 @@ {% \catcode93=\the\catcode93 % ] \catcode91=\the\catcode91 % [ + \catcode94=\the\catcode94 % ^ \catcode96=\the\catcode96 % ` \catcode47=\the\catcode47 % / \catcode41=\the\catcode41 % ) @@ -138,7 +139,7 @@ \catcode61=\the\catcode61\relax % = \noexpand\endinput }% - \XINT_setcatcodes + \XINT_setcatcodes % defined in xint.sty \catcode91=12 % [ \catcode93=12 % ] }% @@ -164,7 +165,7 @@ \fi \expandafter\x\csname ver@xintcfrac.sty\endcsname \ProvidesPackage{xintcfrac}% - [2013/05/26 v1.07a Expandable continued fractions with xint package (jfB)]% + [2013/06/14 v1.08b Expandable continued fractions with xint package (jfB)]% \def\xintCFrac {\romannumeral0\xintcfrac }% \def\xintcfrac #1% {% @@ -172,7 +173,7 @@ }% \def\XINT_cfrac_opt_a #1% {% - \ifx#1[\XINT_cfrac_opt_b\fi \XINT_cfrac_noopt #1% + \ifx[#1\XINT_cfrac_opt_b\fi \XINT_cfrac_noopt #1% }% \def\XINT_cfrac_noopt #1\Z {% @@ -232,18 +233,18 @@ {\XINT_cfrac_T #5#6{#2}#4\Z }% \def\XINT_cfrac_T #1#2#3#4% {% - \xint_gob_til_z #4\XINT_cfrac_end\Z\XINT_cfrac_T #1#2{#4+\cfrac{#11#2}{#3}}% + \xint_gob_til_Z #4\XINT_cfrac_end\Z\XINT_cfrac_T #1#2{#4+\cfrac{#11#2}{#3}}% }% \def\XINT_cfrac_end\Z\XINT_cfrac_T #1#2#3% {% - \XINT_cfrac__end #3% + \XINT_cfrac_end_b #3% }% -\def\XINT_cfrac__end \Z+\cfrac#1#2{ #2}% +\def\XINT_cfrac_end_b \Z+\cfrac#1#2{ #2}% \def\xintGCFrac {\romannumeral0\xintgcfrac }% \def\xintgcfrac #1{\XINT_gcfrac_opt_a #1\Z }% \def\XINT_gcfrac_opt_a #1% {% - \ifx#1[\XINT_gcfrac_opt_b\fi \XINT_gcfrac_noopt #1% + \ifx[#1\XINT_gcfrac_opt_b\fi \XINT_gcfrac_noopt #1% }% \def\XINT_gcfrac_noopt #1\Z {% @@ -272,7 +273,7 @@ \def\XINT_gcfrac_enter {\XINT_gcfrac_loop {}}% \def\XINT_gcfrac_loop #1#2+#3/% {% - \xint_gob_til_w #3\XINT_gcfrac_endloop\W + \xint_gob_til_W #3\XINT_gcfrac_endloop\W \XINT_gcfrac_loop {{#3}{#2}#1}% }% \def\XINT_gcfrac_endloop\W\XINT_gcfrac_loop #1#2#3% @@ -282,7 +283,7 @@ \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_z #5\XINT_gcfrac_end\Z\XINT_gcfrac_U + \xint_gob_til_Z #5\XINT_gcfrac_end\Z\XINT_gcfrac_U #1#2{\xintFrac{#5}% \ifcase\xintSgn{#4} +\or+\else-\fi @@ -290,9 +291,9 @@ }% \def\XINT_gcfrac_end\Z\XINT_gcfrac_U #1#2#3% {% - \XINT_gcfrac__end #3% + \XINT_gcfrac_end_b #3% }% -\def\XINT_gcfrac__end #1\cfrac#2#3{ #3}% +\def\XINT_gcfrac_end_b #1\cfrac#2#3{ #3}% \def\xintGCtoGCx {\romannumeral0\xintgctogcx }% \def\xintgctogcx #1#2#3% {% @@ -301,7 +302,7 @@ \def\XINT_gctgcx_start #1#2#3{\XINT_gctgcx_loop_a {}{#2}{#3}#1+\W/}% \def\XINT_gctgcx_loop_a #1#2#3#4+#5/% {% - \xint_gob_til_w #5\XINT_gctgcx_end\W + \xint_gob_til_W #5\XINT_gctgcx_end\W \XINT_gctgcx_loop_b {#1{#4}}{#2{#5}#3}{#2}{#3}% }% \def\XINT_gctgcx_loop_b #1#2% @@ -475,7 +476,7 @@ }% \def\XINT_cstf_loop_a #1#2#3#4#5,% {% - \xint_gob_til_w #5\XINT_cstf_end\W + \xint_gob_til_W #5\XINT_cstf_end\W \expandafter\XINT_cstf_loop_b \romannumeral0\xintrawwithzeros {#5}.{#1}{#2}{#3}{#4}% }% @@ -511,7 +512,7 @@ }% \def\XINT_icstf_loop_a #1#2#3#4#5,% {% - \xint_gob_til_w #5\XINT_icstf_end\W + \xint_gob_til_W #5\XINT_icstf_end\W \expandafter \XINT_icstf_loop_b \romannumeral-`0#5.{#1}{#2}{#3}{#4}% }% @@ -563,7 +564,7 @@ }% \def\XINT_gctf_loop_f #1#2/% {% - \xint_gob_til_w #2\XINT_gctf_end\W + \xint_gob_til_W #2\XINT_gctf_end\W \expandafter\XINT_gctf_loop_g \romannumeral0\xintrawwithzeros {#2}.#1% }% @@ -615,7 +616,7 @@ }% \def\XINT_igctf_loop_f #1#2#3#4/% {% - \xint_gob_til_w #4\XINT_igctf_end\W + \xint_gob_til_W #4\XINT_igctf_end\W \expandafter\XINT_igctf_loop_g \romannumeral-`0#4.{#2}{#3}#1% }% @@ -645,7 +646,7 @@ }% \def\XINT_cstcv_loop_a #1#2#3#4#5#6,% {% - \xint_gob_til_w #6\XINT_cstcv_end\W + \xint_gob_til_W #6\XINT_cstcv_end\W \expandafter\XINT_cstcv_loop_b \romannumeral0\xintrawwithzeros {#6}.{#2}{#3}{#4}{#5}{#1}% }% @@ -687,7 +688,7 @@ }% \def\XINT_icstcv_loop_a #1#2#3#4#5#6,% {% - \xint_gob_til_w #6\XINT_icstcv_end\W + \xint_gob_til_W #6\XINT_icstcv_end\W \expandafter \XINT_icstcv_loop_b \romannumeral-`0#6.{#2}{#3}{#4}{#5}{#1}% }% @@ -754,7 +755,7 @@ }% \def\XINT_gctcv_loop_h #1#2#3/% {% - \xint_gob_til_w #3\XINT_gctcv_end\W + \xint_gob_til_W #3\XINT_gctcv_end\W \expandafter\XINT_gctcv_loop_i \romannumeral0\xintrawwithzeros {#3}.#2{#1}% }% @@ -807,7 +808,7 @@ }% \def\XINT_igctcv_loop_f #1#2#3#4/% {% - \xint_gob_til_w #4\XINT_igctcv_end_a\W + \xint_gob_til_W #4\XINT_igctcv_end_a\W \expandafter\XINT_igctcv_loop_g \romannumeral-`0#4.#1#2{#3}% }% @@ -842,13 +843,13 @@ }% \def\XINT_cntf #1#2% {% - \ifnum #1>0 + \ifnum #1>\xint_c_ \xint_afterfi {\expandafter\XINT_cntf_loop\expandafter {\the\numexpr #1-1\expandafter}\expandafter {\romannumeral-`0#2{#1}}{#2}}% \else \xint_afterfi - {\ifnum #1=0 + {\ifnum #1=\xint_c_ \xint_afterfi {\expandafter\space \romannumeral-`0#2{0}}% \else \xint_afterfi { 0/1[0]}% \fi}% @@ -856,7 +857,7 @@ }% \def\XINT_cntf_loop #1#2#3% {% - \ifnum #1>0 \else \XINT_cntf_exit \fi + \ifnum #1>\xint_c_ \else \XINT_cntf_exit \fi \expandafter\XINT_cntf_loop\expandafter {\the\numexpr #1-1\expandafter }\expandafter {\romannumeral0\xintadd {\xintDiv {1[0]}{#2}}{#3{#1}}}% @@ -875,13 +876,13 @@ }% \def\XINT_gcntf #1#2#3% {% - \ifnum #1>0 + \ifnum #1>\xint_c_ \xint_afterfi {\expandafter\XINT_gcntf_loop\expandafter {\the\numexpr #1-1\expandafter}\expandafter {\romannumeral-`0#2{#1}}{#2}{#3}}% \else \xint_afterfi - {\ifnum #1=0 + {\ifnum #1=\xint_c_ \xint_afterfi {\expandafter\space\romannumeral-`0#2{0}}% \else \xint_afterfi { 0/1[0]}% \fi}% @@ -889,7 +890,7 @@ }% \def\XINT_gcntf_loop #1#2#3#4% {% - \ifnum #1>0 \else \XINT_gcntf_exit \fi + \ifnum #1>\xint_c_ \else \XINT_gcntf_exit \fi \expandafter\XINT_gcntf_loop\expandafter {\the\numexpr #1-1\expandafter }\expandafter {\romannumeral0\xintadd {\xintDiv {#4{#1}}{#2}}{#3{#1}}}% @@ -927,9 +928,9 @@ \expandafter\XINT_cntcs_loop\expandafter #1\expandafter #2#3% {% - \fi\XINT_cntcs__exit #2% + \fi\XINT_cntcs_exit_b #2% }% -\def\XINT_cntcs__exit #1,{ }% +\def\XINT_cntcs_exit_b #1,{ }% \def\xintCntoGC {\romannumeral0\xintcntogc }% \def\xintcntogc #1% {% @@ -956,9 +957,9 @@ \expandafter\XINT_cntgc_loop\expandafter #1\expandafter #2#3% {% - \fi\XINT_cntgc__exit #2% + \fi\XINT_cntgc_exit_b #2% }% -\def\XINT_cntgc__exit #1+1/{ }% +\def\XINT_cntgc_exit_b #1+1/{ }% \def\xintGCntoGC {\romannumeral0\xintgcntogc }% \def\xintgcntogc #1% {% @@ -989,9 +990,9 @@ \def\XINT_gcntgc_exit \fi \expandafter\XINT_gcntgc_loop_b\expandafter #1#2#3#4#5% {% - \fi\XINT_gcntgc__exit #1% + \fi\XINT_gcntgc_exit_b #1% }% -\def\XINT_gcntgc__exit #1/{ }% +\def\XINT_gcntgc_exit_b #1/{ }% \def\xintCstoGC {\romannumeral0\xintcstogc }% \def\xintcstogc #1% {% @@ -1000,7 +1001,7 @@ \def\XINT_cstc_prep #1,{\XINT_cstc_loop_a {{#1}}}% \def\XINT_cstc_loop_a #1#2,% {% - \xint_gob_til_w #2\XINT_cstc_end\W + \xint_gob_til_W #2\XINT_cstc_end\W \XINT_cstc_loop_b {#1}{#2}% }% \def\XINT_cstc_loop_b #1#2{\XINT_cstc_loop_a {#1+1/{#2}}}% @@ -1013,7 +1014,7 @@ \def\XINT_gctgc_start {\XINT_gctgc_loop_a {}}% \def\XINT_gctgc_loop_a #1#2+#3/% {% - \xint_gob_til_w #3\XINT_gctgc_end\W + \xint_gob_til_W #3\XINT_gctgc_end\W \expandafter\XINT_gctgc_loop_b\expandafter {\romannumeral-`0#2}{#3}{#1}% }% @@ -1028,9 +1029,9 @@ }% \def\XINT_gctgc_end\W\expandafter\XINT_gctgc_loop_b {% - \expandafter\XINT_gctgc__end + \expandafter\XINT_gctgc_end_b }% -\def\XINT_gctgc__end #1#2#3{ #3{#1}}% +\def\XINT_gctgc_end_b #1#2#3{ #3{#1}}% \XINT_cfrac_restorecatcodes_endinput% \endinput %% diff --git a/Master/texmf-dist/tex/generic/xint/xintexpr.sty b/Master/texmf-dist/tex/generic/xint/xintexpr.sty index 14fc53b418c..45378ace18a 100644 --- a/Master/texmf-dist/tex/generic/xint/xintexpr.sty +++ b/Master/texmf-dist/tex/generic/xint/xintexpr.sty @@ -22,7 +22,7 @@ %% in the same archive or directory.) %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.07a of May 26, 2013) +%% The xint bundle (version 1.08b of June 14, 2013) %% xintexpr: Expandable expression parser %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -114,10 +114,10 @@ \endgroup \edef\XINT_expr_restorecatcodes_endinput {% - \catcode94=\the\catcode94 % ^ \catcode33=\the\catcode33 % ! \catcode93=\the\catcode93 % ] \catcode91=\the\catcode91 % [ + \catcode94=\the\catcode94 % ^ \catcode96=\the\catcode96 % ` \catcode47=\the\catcode47 % / \catcode41=\the\catcode41 % ) @@ -140,11 +140,10 @@ \catcode61=\the\catcode61\relax % = \noexpand\endinput }% - \XINT_setcatcodes + \XINT_setcatcodes % defined in xint.sty \catcode91=12 % [ \catcode93=12 % ] \catcode33=11 % ! - \catcode94=12 % ^ }% \x \begingroup @@ -168,14 +167,7 @@ \fi \expandafter\x\csname ver@xintexpr.sty\endcsname \ProvidesPackage{xintexpr}% - [2013/05/26 v1.07a Expandable expression parser (jfB)]% -\chardef\xint_c_ 0 -\chardef\xint_c_i 1 -\chardef\xint_c_ii 2 -\chardef\xint_c_iii 3 -\chardef\xint_c_iv 4 -\chardef\xint_c_v 5 -\chardef\xint_c_ix 9 + [2013/06/14 v1.08b Expandable expression parser (jfB)]% \def\xint_gob_til_dot #1.{}% \def\xint_gob_til_dot_andstop #1.{ }% \def\xint_gob_til_! #1!{}% ! of catcode 11 @@ -200,7 +192,7 @@ \or \expandafter\XINT_expr_extra_closing_paren \fi - \expandafter\XINT_expr_until_end\romannumeral-`0% + \expandafter\XINT_expr_until_end\romannumeral-`0\romannumeral-`0% }% \def\XINT_expr_extra_closing_paren {\xintError:removed }% \def\XINT_expr_endofexpr {!\XINT_illegaluse }% @@ -217,7 +209,8 @@ \ifcase#1% \expandafter\XINT_expr_missing_cparen \or - \else \xint_afterfi{\expandafter\XINT_expr_until_cparen\romannumeral-`0}% + \else \xint_afterfi + {\expandafter\XINT_expr_until_cparen\romannumeral-`0\romannumeral-`0}% \fi }% \def\XINT_expr_missing_cparen #1% @@ -251,13 +244,13 @@ \csname .#6{\XINT_expr_string ##1}{\XINT_expr_string ##4}\endcsname }% \fi }% - \global\let #4#5% + \let #4#5% }% \xint_tmp_def +{ii}{Add}% \xint_tmp_def -{ii}{Sub}% \xint_tmp_def *{iii}{Mul}% \xint_tmp_def /{iii}{Div}% -\xint_tmp_def ^{iv}{fPow}% +\xint_tmp_def ^{iv}{Pow}% \xint_tmp_def e{v}{fE}% \xint_tmp_def E{v}{fE}% \def\xint_tmp_def #1% @@ -309,7 +302,8 @@ \xint_tmp_def {v}% \def\XINT_expr_getop #1% {% - \expandafter\XINT_expr_getop_a\expandafter #1\romannumeral-`0% + \expandafter\XINT_expr_getop_a\expandafter #1% + \romannumeral-`0\romannumeral-`0% }% \def\XINT_expr_getop_a #1#2% {% @@ -354,13 +348,14 @@ \expandafter\xint_firstoftwo \else\expandafter\xint_secondoftwo \fi{\expandafter\XINT_expr_getop}{\expandafter\XINT_flexpr_getop}% - \csname .\xintfFac{\XINT_expr_string ##2}/1[0]\endcsname }% + \csname .\xintFac{\XINT_expr_string ##2}/1[0]\endcsname }% \let#2\empty }% \xint_tmp_def \def\XINT_expr_getnext {% - \expandafter\XINT_expr_getnext_checkforbraced_a\romannumeral-`0% + \expandafter\XINT_expr_getnext_checkforbraced_a + \romannumeral-`0\romannumeral-`0% }% \def\XINT_expr_getnext_checkforbraced_a #1% {% @@ -457,12 +452,12 @@ \def\XINT_expr_scannum_intpart_b #1% {% \expandafter #1\romannumeral-`0\expandafter - \XINT_expr_scannum_intpart_a\romannumeral-`0% + \XINT_expr_scannum_intpart_a\romannumeral-`0\romannumeral-`0% }% \def\XINT_expr_scannum_transition #1% {% \expandafter.\romannumeral-`0\expandafter - \XINT_expr_scannum_decpart_a\romannumeral-`0% + \XINT_expr_scannum_decpart_a\romannumeral-`0\romannumeral-`0% }% \def\XINT_expr_scannum_decpart_a #1% {% @@ -477,7 +472,7 @@ \def\XINT_expr_scannum_decpart_b #1% {% \expandafter #1\romannumeral-`0\expandafter - \XINT_expr_scannum_decpart_a\romannumeral-`0% + \XINT_expr_scannum_decpart_a\romannumeral-`0\romannumeral-`0% }% \def\xintfloatexpr {\romannumeral0\xintfloateval }% \def\xintfloateval @@ -574,7 +569,8 @@ \let\xint_tmp_do_defs\empty \def\XINT_flexpr_getop #1% {% - \expandafter\XINT_flexpr_getop_a\expandafter #1\romannumeral-`0% + \expandafter\XINT_flexpr_getop_a\expandafter #1% + \romannumeral-`0\romannumeral-`0% }% \def\XINT_flexpr_getop_a #1#2% {% @@ -606,7 +602,8 @@ \expandafter\let\csname XINT_flexpr_op_)\endcsname\XINT_flexpr_getop \def\XINT_flexpr_getnext {% - \expandafter\XINT_flexpr_getnext_checkforbraced_a\romannumeral-`0% + \expandafter\XINT_flexpr_getnext_checkforbraced_a + \romannumeral-`0\romannumeral-`0% }% \def\XINT_flexpr_getnext_checkforbraced_a #1% {% @@ -701,8 +698,8 @@ \def\xintSub {:xintSub}% \def\xintMul {:xintMul}% \def\xintDiv {:xintDiv}% - \def\xintfPow {:xintfPow}% - \def\xintfFac {:xintfFac}% + \def\xintPow {:xintPow}% + \def\xintFac {:xintFac}% \def\xintOpp {:xintOpp}% \def\xintfE {:xintfE}% \def\xintraw { :romannumeral0:xintraw}% @@ -714,11 +711,11 @@ \endlinechar -1 \everyeof {\noexpand }% \edef\xintNewExprtmp - {\expandafter\scantokens + {\scantokens \expandafter{\romannumeral0\xinttheeval #3\relax}}% \lccode`\*=`_ \lowercase {\def*}{####}% \catcode`_ 13 \catcode`! 0 \catcode`: 11 - \the\toks0 {\expandafter\scantokens\expandafter{\xintNewExprtmp }}% + \the\toks0 {\scantokens\expandafter{\xintNewExprtmp }}% \endgroup }% \def\xintNewFloatExpr #1[#2]#3% @@ -744,7 +741,7 @@ \def\XINTinFloatMul {:XINTinFloatMul}% \def\XINTinFloatDiv {:XINTinFloatDiv}% \def\XINTinFloatPower {:XINTinFloatPower}% - \def\xintfFac {:xintfFac}% + \def\xintFac {:xintFac}% \def\xintOpp {:xintOpp}% \def\XINTinFloatfE {:XINTinFloatfE}% \def\xintfloat { :romannumeral0:xintfloat}% @@ -756,11 +753,11 @@ \endlinechar -1 \everyeof {\noexpand }% \edef\xintNewExprtmp - {\expandafter\scantokens + {\scantokens \expandafter{\romannumeral0\xintthefloateval #3\relax}}% \lccode`\*=`_ \lowercase {\def*}{####}% \catcode`_ 13 \catcode`! 0 \catcode`: 11 - \the\toks0 {\expandafter\scantokens\expandafter{\xintNewExprtmp }}% + \the\toks0 {\scantokens\expandafter{\xintNewExprtmp }}% \endgroup }% \XINT_expr_restorecatcodes_endinput% diff --git a/Master/texmf-dist/tex/generic/xint/xintfrac.sty b/Master/texmf-dist/tex/generic/xint/xintfrac.sty index a6678ac73c6..162aa549471 100644 --- a/Master/texmf-dist/tex/generic/xint/xintfrac.sty +++ b/Master/texmf-dist/tex/generic/xint/xintfrac.sty @@ -22,7 +22,7 @@ %% in the same archive or directory.) %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.07a of May 26, 2013) +%% The xint bundle (version 1.08b of June 14, 2013) %% xintfrac: Expandable operations on fractions %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -114,9 +114,9 @@ \endgroup \edef\XINT_frac_restorecatcodes_endinput {% - \catcode94=\the\catcode94 % ^ \catcode93=\the\catcode93 % ] \catcode91=\the\catcode91 % [ + \catcode94=\the\catcode94 % ^ \catcode96=\the\catcode96 % ` \catcode47=\the\catcode47 % / \catcode41=\the\catcode41 % ) @@ -139,10 +139,9 @@ \catcode61=\the\catcode61\relax % = \noexpand\endinput }% - \XINT_setcatcodes + \XINT_setcatcodes % defined in xint.sty \catcode91=12 % [ \catcode93=12 % ] - \catcode94=7 % ^ }% \x \begingroup @@ -166,7 +165,11 @@ \fi \expandafter\x\csname ver@xintfrac.sty\endcsname \ProvidesPackage{xintfrac}% - [2013/05/26 v1.07a Expandable operations on fractions (jfB)]% + [2013/06/14 v1.08b Expandable operations on fractions (jfB)]% +\chardef\xint_c_vi 6 +\chardef\xint_c_vii 7 +\chardef\xint_c_xviii 18 +\mathchardef\xint_c_x^iv 10000 \def\xintLen {\romannumeral0\xintlen }% \def\xintlen #1% {% @@ -177,6 +180,35 @@ \expandafter\space \the\numexpr -1+\XINT_Abs {#1}+\XINT_Len {#2}+\XINT_Len {#3}\relax }% +\def\XINT_lenrord_loop #1#2#3#4#5#6#7#8#9% +{% faire \romannumeral-`0\XINT_lenrord_loop 0{}#1\Z\W\W\W\W\W\W\W\Z + \xint_gob_til_W #9\XINT_lenrord_W\W + \expandafter\XINT_lenrord_loop\expandafter + {\the\numexpr #1+7}{#9#8#7#6#5#4#3#2}% +}% +\def\XINT_lenrord_W\W\expandafter\XINT_lenrord_loop\expandafter #1#2#3\Z +{% + \expandafter\XINT_lenrord_X\expandafter {#1}#2\Z +}% +\def\XINT_lenrord_X #1#2\Z +{% + \XINT_lenrord_Y #2\R\R\R\R\R\R\T {#1}% +}% +\def\XINT_lenrord_Y #1#2#3#4#5#6#7#8\T +{% + \xint_gob_til_W + #7\XINT_lenrord_Z \xint_c_viii + #6\XINT_lenrord_Z \xint_c_vii + #5\XINT_lenrord_Z \xint_c_vi + #4\XINT_lenrord_Z \xint_c_v + #3\XINT_lenrord_Z \xint_c_iv + #2\XINT_lenrord_Z \xint_c_iii + \W\XINT_lenrord_Z \xint_c_ii \Z +}% +\def\XINT_lenrord_Z #1#2\Z #3% retourne: {longueur}renverse\Z +{% + \expandafter{\the\numexpr #3-#1\relax}% +}% \def\XINT_outfrac #1#2#3% {% \ifcase\XINT_Sgn{#3} @@ -345,7 +377,7 @@ }% \def\XINT_cuz_cnt_loop #1#2#3#4#5#6#7#8#9% {% - \xint_gob_til_r #9\XINT_cuz_cnt_toofara \R + \xint_gob_til_R #9\XINT_cuz_cnt_toofara \R \expandafter\XINT_cuz_cnt_checka\expandafter {\the\numexpr #1+8\relax}{#2#3#4#5#6#7#8#9}% }% @@ -357,7 +389,7 @@ \def\XINT_cuz_cnt_toofarb #1#2\Z {\XINT_cuz_cnt_toofarc #2\Z {#1}}% \def\XINT_cuz_cnt_toofarc #1#2#3#4#5#6#7#8% {% - \xint_gob_til_r #2\XINT_cuz_cnt_toofard 7% + \xint_gob_til_R #2\XINT_cuz_cnt_toofard 7% #3\XINT_cuz_cnt_toofard 6% #4\XINT_cuz_cnt_toofard 5% #5\XINT_cuz_cnt_toofard 4% @@ -374,7 +406,7 @@ }% \def\XINT_cuz_cnt_toofare #1#2#3#4#5#6#7#8% {% - \xint_gob_til_r #2\XINT_cuz_cnt_stopc 1% + \xint_gob_til_R #2\XINT_cuz_cnt_stopc 1% #3\XINT_cuz_cnt_stopc 2% #4\XINT_cuz_cnt_stopc 3% #5\XINT_cuz_cnt_stopc 4% @@ -389,7 +421,7 @@ }% \def\XINT_cuz_cnt_checkb #1% {% - \xint_gob_til_zero #1\expandafter\XINT_cuz_cnt_loop\xint_gob_til_z + \xint_gob_til_zero #1\expandafter\XINT_cuz_cnt_loop\xint_gob_til_Z 0\XINT_cuz_cnt_stopa #1% }% \def\XINT_cuz_cnt_stopa #1\Z @@ -398,7 +430,7 @@ }% \def\XINT_cuz_cnt_stopb #1#2#3#4#5#6#7#8#9% {% - \xint_gob_til_r #2\XINT_cuz_cnt_stopc 1% + \xint_gob_til_R #2\XINT_cuz_cnt_stopc 1% #3\XINT_cuz_cnt_stopc 2% #4\XINT_cuz_cnt_stopc 3% #5\XINT_cuz_cnt_stopc 4% @@ -487,14 +519,15 @@ \def\xintFrac {\romannumeral0\xintfrac }% \def\xintfrac #1% {% - \expandafter\XINT__frac_A\romannumeral0\XINT_infrac {#1}% + \expandafter\XINT_fracfrac_A\romannumeral0\XINT_infrac {#1}% }% -\def\XINT__frac_A #1{\XINT__frac_B #1\Z }% -\def\XINT__frac_B #1#2\Z +\def\XINT_fracfrac_A #1{\XINT_fracfrac_B #1\Z }% +\catcode`^=7 +\def\XINT_fracfrac_B #1#2\Z {% - \xint_gob_til_zero #1\XINT__frac_C 0\XINT__frac_D {10^{#1#2}}% + \xint_gob_til_zero #1\XINT_fracfrac_C 0\XINT_fracfrac_D {10^{#1#2}}% }% -\def\XINT__frac_C #1#2#3#4#5% +\def\XINT_fracfrac_C #1#2#3#4#5% {% \ifcase\XINT_isOne {#5} \or \xint_afterfi {\expandafter\xint_firstoftwo_andstop\xint_gobble_ii }% @@ -502,15 +535,15 @@ \space \frac {#4}{#5}% }% -\def\XINT__frac_D #1#2#3% +\def\XINT_fracfrac_D #1#2#3% {% \ifcase\XINT_isOne {#3} - \or \XINT__frac_E + \or \XINT_fracfrac_E \fi \space \frac {#2}{#3}#1% }% -\def\XINT__frac_E \fi #1#2#3#4{\fi \space #3\cdot }% +\def\XINT_fracfrac_E \fi #1#2#3#4{\fi \space #3\cdot }% \def\xintSignedFrac {\romannumeral0\xintsignedfrac }% \def\xintsignedfrac #1% {% @@ -529,7 +562,7 @@ }% \def\XINT_sgnfrac_P #1\Z #2% {% - \XINT__frac_A {#2}{#1}% + \XINT_fracfrac_A {#2}{#1}% }% \def\XINT_sgnfrac_N {% @@ -545,6 +578,7 @@ {% \xint_gob_til_zero #1\XINT_fwover_C 0\XINT_fwover_D {10^{#1#2}}% }% +\catcode`^=11 \def\XINT_fwover_C #1#2#3#4#5% {% \ifcase\XINT_isOne {#5} @@ -657,7 +691,7 @@ \fi #2\Z {#3}% }% -\def\XINT_irr_denomisone #1\Z #2{ #1}% +\def\XINT_irr_denomisone #1\Z #2{ #1/1}% changed in 1.08 \def\XINT_irr_negative #1\Z #2{\XINT_irr_D #1\Z #2\Z \xint_minus_andstop}% \def\XINT_irr_nonneg #1\Z #2{\XINT_irr_D #1\Z #2\Z \space}% \def\XINT_irr_D #1#2\Z #3#4\Z @@ -672,7 +706,7 @@ }% \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_zero #1#2#3#4#5{ 0}% +\def\XINT_irr_zero #1#2#3#4#5{ 0/1}% changed in 1.08 \def\XINT_irr_loop_a #1#2% {% \expandafter\XINT_irr_loop_d @@ -696,26 +730,14 @@ {% \expandafter\XINT_irr_finish\expandafter {#2}{#1}% }% -\def\XINT_irr_finish #1#2#3% -{% - \ifcase\XINT_isOne {#2} - \xint_afterfi {#3#1/#2}% - \or - \xint_afterfi {#3#1}% - \fi -}% +\def\XINT_irr_finish #1#2#3{#3#1/#2}% changed in 1.08 \def\xintNum {\romannumeral0\xintnum }% -\def\xintnum #1{\expandafter\XINT_intcheck\romannumeral0\xintirr {#1}/\W\Z }% -\def\XINT_intcheck #1/#2#3\Z -{% - \xint_gob_til_w #2\xint_gobble_ii\W - \xintError:NotAnInteger - \space #1% -}% -\def\xintfFac {\romannumeral0\xintffac }% -\def\xintffac #1% +\def\xintnum #1{\expandafter\XINT_intcheck\romannumeral0\xintirr {#1}\Z }% +\def\XINT_intcheck #1/#2\Z {% - \expandafter\XINT_fac_fork\expandafter{\the\numexpr \xintNum{#1}}% + \ifcase\XINT_isOne {#2} + \xintError:NotAnInteger + \fi\space #1% }% \def\xintJrr {\romannumeral0\xintjrr }% \def\xintjrr #1% @@ -735,7 +757,7 @@ \fi #2\Z {#3}% }% -\def\XINT_jrr_denomisone #1\Z #2{ #1}% +\def\XINT_jrr_denomisone #1\Z #2{ #1/1}% changed in 1.08 \def\XINT_jrr_negative #1\Z #2{\XINT_jrr_D #1\Z #2\Z \xint_minus_andstop }% \def\XINT_jrr_nonneg #1\Z #2{\XINT_jrr_D #1\Z #2\Z \space}% \def\XINT_jrr_D #1#2\Z #3#4\Z @@ -750,7 +772,7 @@ }% \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_zero #1#2#3#4#5#6#7{ 0}% +\def\XINT_jrr_zero #1#2#3#4#5#6#7{ 0/1}% changed in 1.08 \def\XINT_jrr_loop_a #1#2% {% \expandafter\XINT_jrr_loop_b @@ -923,7 +945,7 @@ }% \def\XINT_round_Daa #1% {% - \xint_gob_til_z #1\XINT_round_Daz\Z \XINT_round_Da #1% + \xint_gob_til_Z #1\XINT_round_Daz\Z \XINT_round_Da #1% }% \def\XINT_round_Daz\Z \XINT_round_Da \Z { 0\Z }% \def\XINT_round_Da #1\Z @@ -936,7 +958,7 @@ }% \def\XINT_round_Dba #1% {% - \xint_gob_til_z #1\XINT_round_Dbz\Z \XINT_round_Db #1% + \xint_gob_til_Z #1\XINT_round_Dbz\Z \XINT_round_Db #1% }% \def\XINT_round_Dbz\Z \XINT_round_Db \Z { 1\Z }% \def\XINT_round_Db #1\Z @@ -951,233 +973,261 @@ \def\xintfloat #1{\XINT_float_chkopt #1\Z }% \def\XINT_float_chkopt #1% {% - \ifx #1[\expandafter\XINT_float_opt + \ifx [#1\expandafter\XINT_float_opt \else\expandafter\XINT_float_noopt \fi #1% }% \def\XINT_float_noopt #1\Z {% - \XINT_float_a \XINT_digits {#1}% -}% -\def\XINT_float_opt [\Z #1]% -{% - \expandafter\XINT_float_a\expandafter {\the\numexpr #1}% + \expandafter\XINT_float_a\expandafter\XINT_digits + \romannumeral0\XINT_infrac {#1}\XINT_float_Q }% -\def\XINT_float_a #1#2% +\def\XINT_float_opt [\Z #1]#2% {% - \expandafter\XINT_float_b \romannumeral0\XINT_infrac {#2}{#1}% + \expandafter\XINT_float_a\expandafter + {\the\numexpr #1\expandafter}% + \romannumeral0\XINT_infrac {#2}\XINT_float_Q }% -\def\XINT_float_b #1#2#3% +\def\XINT_float_a #1#2#3% #1=P, #2=n, #3=A, #4=B {% - \XINT_float_fork #2\Z {#3}{#1}% + \XINT_float_fork #3\Z {#1}{#2}% #1 = precision, #2=n }% \def\XINT_float_fork #1% {% \xint_UDzerominusfork #1-\dummy \XINT_float_zero - 0#1\dummy \XINT_float_N - 0-\dummy {\XINT_float_P #1}% + 0#1\dummy \XINT_float_J + 0-\dummy {\XINT_float_K #1}% \krof }% -\def\XINT_float_zero \Z #1#2#3{ 0.e0}% -\def\XINT_float_N {\expandafter\xint_minus_andstop\romannumeral0\XINT_float_P }% -\def\XINT_float_P #1\Z #2#3#4% -{% - \ifcase \romannumeral0\XINT_fgeq_A 011{#3}{#1}{#2} - \expandafter\XINT_float_lessthanone_a - \or\expandafter\XINT_float_atleastone_b - \fi {#3}{#1}{#2}{#3+#4}{#1}{#2}% -}% -\def\XINT_float_atleastone_b +\def\XINT_float_zero #1\Z #2#3#4#5{ 0.e0}% +\def\XINT_float_J {\expandafter\xint_minus_andstop\romannumeral0\XINT_float_K }% +\def\XINT_float_K #1\Z #2% #1=A, #2=P, #3=n, #4=B {% - \expandafter\XINT_float_atleastone_c\romannumeral0\XINT_trunc_B + \expandafter\XINT_float_L\expandafter + {\the\numexpr\xintLength{#1}\expandafter}\expandafter + {\the\numexpr #2+\xint_c_ii}{#1}{#2}% }% -\def\XINT_float_atleastone_c #1\Z #2% +\def\XINT_float_L #1#2% {% - \expandafter\XINT_float_c\expandafter - {\romannumeral0\xintisub {\xintLength{#1}}{1}}% -}% -\def\XINT_float_lessthanone_a #1% -{% - \expandafter\XINT_float_lessthanone_b\expandafter - {\the\numexpr -#1}% + \ifnum #1>#2 + \expandafter\XINT_float_Ma + \else + \expandafter\XINT_float_Mc + \fi {#1}{#2}% +}% +\def\XINT_float_Ma #1#2#3% +{% + \expandafter\XINT_float_Mb\expandafter + {\the\numexpr #1-#2\expandafter}\expandafter + {\expandafter\xint_firstoftwo + \romannumeral0\XINT_split_fromleft_loop {#2}{}#3\W\W\W\W\W\W\W\W\Z + }{#2}% +}% +\def\XINT_float_Mb #1#2#3#4#5#6% #2=A', #3=P+2, #4=P, #5=n, #6=B +{% + \expandafter\XINT_float_N\expandafter + {\the\numexpr\xintLength{#6}\expandafter}\expandafter + {\the\numexpr #3\expandafter}\expandafter + {\the\numexpr #1+#5}% + {#6}{#3}{#2}{#4}% +}% long de B, P+2, n', B, |A'|=P+2, A', P +\def\XINT_float_Mc #1#2#3#4#5#6% +{% + \expandafter\XINT_float_N\expandafter + {\romannumeral0\XINT_length{#6}}{#2}{#5}{#6}{#1}{#3}{#4}% +}% long de B, P+2, n, B, |A|, A, P +\def\XINT_float_N #1#2% +{% + \ifnum #1>#2 + \expandafter\XINT_float_O + \else + \expandafter\XINT_float_P + \fi {#1}{#2}% +}% +\def\XINT_float_O #1#2#3#4% +{% + \expandafter\XINT_float_P\expandafter + {\the\numexpr #2\expandafter}\expandafter + {\the\numexpr #2\expandafter}\expandafter + {\the\numexpr #3-#1+#2\expandafter}\expandafter + {\expandafter\xint_firstoftwo + \romannumeral0\XINT_split_fromleft_loop {#2}{}#4\W\W\W\W\W\W\W\W\Z + }% +}% |B|,P+2,n,B,|A|,A,P +\def\XINT_float_P #1#2#3#4#5#6#7#8% +{% + \expandafter #8\expandafter {\the\numexpr #1-#5+#2-\xint_c_i}% + {#6}{#4}{#7}{#3}% +}% |B|-|A|+P+1,A,B,P,n +\def\XINT_float_Q #1% +{% + \ifnum #1<\xint_c_ + \expandafter\XINT_float_Ri + \else + \expandafter\XINT_float_Rii + \fi {#1}% }% -\def\XINT_float_lessthanone_b #1#2#3% +\def\XINT_float_Ri #1#2#3% {% - \expandafter\XINT_float_lessthanone_c - \romannumeral0\XINT_trunc_B {#1}{#3}{#2}% + \expandafter\XINT_float_Sa + \romannumeral0\xintiquo {#2}% + {\romannumeral-`0\XINT_dsx_addzerosnofuss {-#1}{#3}}\Z {#1}% }% -\def\XINT_float_lessthanone_c #1\Z #2% +\def\XINT_float_Rii #1#2#3% {% - \expandafter\XINT_float_c\expandafter - {\expandafter-\romannumeral0\xintilen {\xintiSub {#1}{1}}}% + \expandafter\XINT_float_Sa + \romannumeral0\xintiquo + {\romannumeral-`0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}\Z {#1}% }% -\def\XINT_float_c #1#2#3#4% +\def\XINT_float_Sa #1% {% - \expandafter\XINT_float_d\expandafter - {\the\numexpr #2-#1}{#3}{#4}e#1% + \if #19% + \xint_afterfi {\XINT_float_Sb\XINT_float_Wb }% + \else + \xint_afterfi {\XINT_float_Sb\XINT_float_Wa }% + \fi #1% }% -\def\XINT_float_d +\def\XINT_float_Sb #1#2\Z #3#4% {% - \expandafter\XINT_float_round_B\romannumeral0\XINT_trunc_B + \expandafter\XINT_float_T\expandafter + {\the\numexpr #4+\xint_c_i\expandafter}% + \romannumeral-`0\XINT_lenrord_loop 0{}#2\Z\W\W\W\W\W\W\W\Z #1{#3}{#4}% }% -\def\XINT_float_round_B #1#2\Z #3% +\def\XINT_float_T #1#2#3% {% - \ifnum #1=9 - \xint_afterfi - {\romannumeral0\XINT_rord_main {}#1#2\XINT_float_round_S}% + \ifnum #2>#1 + \xint_afterfi{\XINT_float_U\XINT_float_Xb}% \else - \xint_afterfi - {\romannumeral0\XINT_rord_main {}#1#2\XINT_float_round_D}% + \xint_afterfi{\XINT_float_U\XINT_float_Xa #3}% \fi - \xint_relax - \xint_undef\xint_undef\xint_undef\xint_undef - \xint_undef\xint_undef\xint_undef\xint_undef - \xint_relax - \Z }% -\def\XINT_float_round_D #1% +\def\XINT_float_U #1#2% {% - \ifnum #1<5 - \expandafter\XINT_float_round_Da + \ifnum #2<\xint_c_v + \expandafter\XINT_float_Va \else - \expandafter\XINT_float_round_Db - \fi + \expandafter\XINT_float_Vb + \fi #1% }% -\def\XINT_float_round_Da #1\Z +\def\XINT_float_Va #1#2\Z #3% {% - \expandafter\XINT_float_round_f - \romannumeral0\XINT_rord_main {}#1% + \expandafter#1% + \romannumeral0\expandafter\XINT_float_Wa + \romannumeral0\XINT_rord_main {}#2% \xint_relax \xint_undef\xint_undef\xint_undef\xint_undef \xint_undef\xint_undef\xint_undef\xint_undef - \xint_relax -}% -\def\XINT_float_round_Db #1\Z -{% - \expandafter\XINT_float_round_f - \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z -}% -\def\XINT_float_round_f #1{ #1.}% -\def\XINT_float_round_S #1% -{% - \ifnum #1<5 - \expandafter\XINT_float_round_Da - \else - \expandafter\XINT_float_round_Sb - \fi + \xint_relax \Z }% -\def\XINT_float_round_Sb #1\Z +\def\XINT_float_Vb #1#2\Z #3% {% - \expandafter\XINT_float_round_g - \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z + \expandafter #1% + \romannumeral0\expandafter #3% + \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #2000\W\X\Y\Z \Z }% -\def\XINT_float_round_g #1% +\def\XINT_float_Wa #1{ #1.}% +\def\XINT_float_Wb #1#2% + {\if #11\xint_afterfi{ 10.}\else\xint_afterfi{ #1.#2}\fi }% +\def\XINT_float_Xa #1\Z #2#3#4% {% - \ifnum #1=1 \expandafter\XINT_float_round_h\fi - \space #1.% + \expandafter\XINT_float_Y\expandafter + {\the\numexpr #3+#4-#2}{#1}% }% -\def\XINT_float_round_h\space 1.0{ 10.}% -\def\XINT_inFloat [#1]% +\def\XINT_float_Xb #1\Z #2#3#4% {% - \expandafter\XINT_infloat\expandafter {\the\numexpr #1}% + \expandafter\XINT_float_Y\expandafter + {\the\numexpr #3+#4+\xint_c_i-#2}{#1}% }% -\def\XINT_infloat #1#2% +\def\XINT_float_Y #1#2{ #2e#1}% +\def\XINT_inFloat [#1]#2% {% - \expandafter\XINT_infloat_a \romannumeral0\XINT_infrac {#2}{#1}% + \expandafter\XINT_infloat_a\expandafter + {\the\numexpr #1\expandafter}% + \romannumeral0\XINT_infrac {#2}\XINT_infloat_Q }% -\def\XINT_infloat_a #1#2#3% +\def\XINT_infloat_a #1#2#3% #1=P, #2=n, #3=A, #4=B {% - \XINT_infloat_fork #2\Z {#3}{#1}% + \XINT_infloat_fork #3\Z {#1}{#2}% #1 = precision, #2=n }% \def\XINT_infloat_fork #1% {% \xint_UDzerominusfork #1-\dummy \XINT_infloat_zero - 0#1\dummy \XINT_infloat_N - 0-\dummy {\XINT_infloat_P #1}% + 0#1\dummy \XINT_infloat_J + 0-\dummy {\XINT_float_K #1}% \krof }% -\def\XINT_infloat_zero\Z #1#2#3{0[0]}% -\def\XINT_infloat_N {\expandafter-\romannumeral-`0\XINT_infloat_P }% -\def\XINT_infloat_P #1\Z #2#3#4% -{% - \ifcase \romannumeral0\XINT_fgeq_A 011{#3}{#1}{#2} - \expandafter\XINT_infloat_lessthanone_a - \or\expandafter\XINT_infloat_atleastone_b - \fi {#3}{#1}{#2}{#3+#4}{#1}{#2}{#4}% -}% -\def\XINT_infloat_atleastone_b -{% - \expandafter\XINT_infloat_atleastone_c\romannumeral0\XINT_trunc_B -}% -\def\XINT_infloat_atleastone_c #1\Z #2% -{% - \expandafter\XINT_infloat_c\expandafter - {\romannumeral0\xintisub {\xintLength{#1}}{1}}% -}% -\def\XINT_infloat_lessthanone_a #1% -{% - \expandafter\XINT_infloat_lessthanone_b\expandafter - {\the\numexpr -#1}% -}% -\def\XINT_infloat_lessthanone_b #1#2#3% +\def\XINT_infloat_zero #1\Z #2#3#4#5{0[0]}% +\def\XINT_infloat_J {\expandafter-\romannumeral-`0\XINT_float_K }% +\def\XINT_infloat_Q #1% {% - \expandafter\XINT_infloat_lessthanone_c - \romannumeral0\XINT_trunc_B {#1}{#3}{#2}% + \ifnum #1<\xint_c_ + \expandafter\XINT_infloat_Ri + \else + \expandafter\XINT_infloat_Rii + \fi {#1}% }% -\def\XINT_infloat_lessthanone_c #1\Z #2% +\def\XINT_infloat_Ri #1#2#3% {% - \expandafter\XINT_infloat_c\expandafter - {\expandafter-\romannumeral0\xintilen {\xintiSub {#1}{1}}}% + \expandafter\XINT_infloat_S\expandafter + {\romannumeral0\xintiquo {#2}% + {\romannumeral-`0\XINT_dsx_addzerosnofuss {-#1}{#3}}}{#1}% }% -\def\XINT_infloat_c #1#2#3#4% +\def\XINT_infloat_Rii #1#2#3% {% - \expandafter\XINT_infloat_d\expandafter - {\the\numexpr #2-#1}{#3}{#4}{#1}% + \expandafter\XINT_infloat_S\expandafter + {\romannumeral0\xintiquo + {\romannumeral-`0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}}{#1}% }% -\def\XINT_infloat_d +\def\XINT_infloat_S #1#2#3% {% - \expandafter\XINT_infloat_round_B\romannumeral0\XINT_trunc_B + \expandafter\XINT_infloat_T\expandafter + {\the\numexpr #3+\xint_c_i\expandafter}% + \romannumeral-`0\XINT_lenrord_loop 0{}#1\Z\W\W\W\W\W\W\W\Z + {#2}% }% -\def\XINT_infloat_round_B #1\Z #2% +\def\XINT_infloat_T #1#2#3% {% - \expandafter\XINT_infloat_round_D - \romannumeral0\XINT_rord_main {}#1% - \xint_relax - \xint_undef\xint_undef\xint_undef\xint_undef - \xint_undef\xint_undef\xint_undef\xint_undef - \xint_relax - \Z + \ifnum #2>#1 + \xint_afterfi{\XINT_infloat_U\XINT_infloat_Wb}% + \else + \xint_afterfi{\XINT_infloat_U\XINT_infloat_Wa #3}% + \fi }% -\def\XINT_infloat_round_D #1% +\def\XINT_infloat_U #1#2% {% - \ifnum #1<5 - \expandafter\XINT_infloat_round_Da + \ifnum #2<\xint_c_v + \expandafter\XINT_infloat_Va \else - \expandafter\XINT_infloat_round_Db - \fi + \expandafter\XINT_infloat_Vb + \fi #1% }% -\def\XINT_infloat_round_Da #1\Z +\def\XINT_infloat_Va #1#2\Z {% - \expandafter\XINT_infloat_round_f - \romannumeral0\XINT_rord_main {}#1% + \expandafter#1% + \romannumeral0\XINT_rord_main {}#2% \xint_relax \xint_undef\xint_undef\xint_undef\xint_undef \xint_undef\xint_undef\xint_undef\xint_undef \xint_relax \Z }% -\def\XINT_infloat_round_Db #1\Z +\def\XINT_infloat_Vb #1#2\Z +{% + \expandafter #1% + \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #2000\W\X\Y\Z \Z +}% +\def\XINT_infloat_Wa #1\Z #2#3% {% - \expandafter\XINT_infloat_round_f - \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z \Z + \expandafter\XINT_infloat_X\expandafter + {\the\numexpr #3+\xint_c_i-#2}{#1}% }% -\def\XINT_infloat_round_f #1\Z #2#3% +\def\XINT_infloat_Wb #1\Z #2#3% {% - \expandafter\XINT_infloat_round_g\expandafter - {\the\numexpr #2-#3+1}{#1}% + \expandafter\XINT_infloat_X\expandafter + {\the\numexpr #3+\xint_c_ii-#2}{#1}% }% -\def\XINT_infloat_round_g #1#2{#2[#1]}% +\def\XINT_infloat_X #1#2{ #2[#1]}% \def\xintAdd {\romannumeral0\xintadd }% \def\xintadd #1% {% @@ -1288,17 +1338,8 @@ {% \expandafter\xint_fpow\expandafter {\romannumeral0\XINT_infrac {#1}}% }% -\def\xintfPow {\romannumeral0\xintfpow }% -\def\xintfpow #1% -{% - \expandafter\xint_ffpow\expandafter {\romannumeral0\XINT_infrac {#1}}% -}% \def\xint_fpow #1#2% {% - \expandafter\XINT_fpow_fork\the\numexpr #2\relax\Z #1% -}% -\def\xint_ffpow #1#2% -{% \expandafter\XINT_fpow_fork\the\numexpr \xintNum{#2}\relax\Z #1% }% \def\XINT_fpow_fork #1#2\Z @@ -1333,6 +1374,11 @@ \expandafter\XINT_fpow_pos_B\expandafter {#3}{#1}{#2}% }% \def\XINT_fpow_pos_B #1#2{\XINT_outfrac {#2}{#1}}% +\def\xintFac {\romannumeral0\xintfac }% +\def\xintfac #1% +{% + \expandafter\XINT_fac_fork\expandafter{\the\numexpr \xintNum{#1}}% +}% \def\xintPrd {\romannumeral0\xintprd }% \def\xintprd #1{\xintprdexpr #1\relax }% \def\xintPrdExpr {\romannumeral0\xintprdexpr }% @@ -1372,111 +1418,201 @@ \expandafter{#3}{#1}{#2}% }% \def\XINT_fdiv_C #1#2{\XINT_outfrac {#2}{#1}}% -\def\xintCmp {\romannumeral0\xintcmp }% -\def\xintcmp #1% +\def\xintGeq {\romannumeral0\xintgeq }% +\def\xintgeq #1% {% - \expandafter\xint_fcmp\expandafter {\romannumeral0\XINT_infrac {#1}}% + \expandafter\xint_fgeq\expandafter {\romannumeral0\xintabs {#1}}% }% -\def\xint_fcmp #1#2{\expandafter\XINT_fcmp_A\romannumeral0\XINT_infrac {#2}#1}% -\def\XINT_fcmp_A #1#2#3#4% +\def\xint_fgeq #1#2% {% - \ifnum #4 > #1 - \xint_afterfi {\XINT_fcmp_B {#1}}% - \else - \xint_afterfi {\XINT_fcmp_B {#4}}% - \fi - {#1}{#4}{#2}{#3}% + \expandafter\XINT_fgeq_A \romannumeral0\xintabs {#2}#1% }% -\def\XINT_fcmp_B #1#2#3#4#5#6#7% +\def\XINT_fgeq_A #1% {% - \xinticmp - {\romannumeral0\xintimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% - {\romannumeral0\xintimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% + \xint_gob_til_zero #1\XINT_fgeq_Zii 0% + \XINT_fgeq_B #1% }% -\def\xintGeq {\romannumeral0\xintgeq }% -\def\xintgeq #1% +\def\XINT_fgeq_Zii 0\XINT_fgeq_B #1[#2]#3[#4]{ 1}% +\def\XINT_fgeq_B #1/#2[#3]#4#5/#6[#7]% {% - \expandafter\xint_fgeq\expandafter {\romannumeral0\XINT_infrac {#1}}% + \xint_gob_til_zero #4\XINT_fgeq_Zi 0% + \expandafter\XINT_fgeq_C\expandafter + {\the\numexpr #7-#3\expandafter}\expandafter + {\romannumeral0\xintimul {#4#5}{#2}}% + {\romannumeral0\xintimul {#6}{#1}}% }% -\def\xint_fgeq #1#2% +\def\XINT_fgeq_Zi 0#1#2#3#4#5#6#7{ 0}% +\def\XINT_fgeq_C #1#2#3% {% - \expandafter\XINT_fgeq_A \romannumeral0\XINT_infrac {#2}#1% + \expandafter\XINT_fgeq_D\expandafter + {#3}{#1}{#2}% }% -\def\XINT_fgeq_A #1#2#3#4% +\def\XINT_fgeq_D #1#2#3% {% - \ifnum #4 > #1 - \xint_afterfi {\XINT_fgeq_B {#1}}% - \else - \xint_afterfi {\XINT_fgeq_B {#4}}% - \fi - {#1}{#4}{#2}{#3}% + \xintSgnFork + {\xintiSgn{\the\numexpr #2+\xintLength{#3}-\xintLength{#1}\relax}}% + { 0}{\XINT_fgeq_E #2\Z {#3}{#1}}{ 1}% }% -\def\XINT_fgeq_B #1#2#3#4#5#6#7% +\def\XINT_fgeq_E #1% {% - \expandafter\XINT_fgeq_C\expandafter - {\romannumeral0\xintimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% - {\romannumeral0\xintimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% + \xint_UDsignfork + #1\dummy \XINT_fgeq_Fd + -\dummy {\XINT_fgeq_Fn #1}% + \krof }% -\def\XINT_fgeq_C #1#2% +\def\XINT_fgeq_Fd #1\Z #2#3% {% - \expandafter\XINT_geq_fork #2\Z #1\Z + \expandafter\XINT_fgeq_Fe\expandafter + {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#3}}{#2}% +}% +\def\XINT_fgeq_Fe #1#2{\XINT_geq_pre {#2}{#1}}% +\def\XINT_fgeq_Fn #1\Z #2#3% +{% + \expandafter\XINT_geq_pre\expandafter + {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}% }% \def\xintMax {\romannumeral0\xintmax }% \def\xintmax #1% {% - \expandafter\xint_fmax\expandafter {\romannumeral0\XINT_infrac {#1}}% + \expandafter\xint_fmax\expandafter {\romannumeral0\xintraw {#1}}% }% -\def\xint_fmax #1#2{\expandafter\XINT_outfrac - \romannumeral0\expandafter\XINT_fmax_A - \romannumeral0\XINT_infrac {#2}#1}% -\def\XINT_fmax_A #1#2#3#4#5#6% +\def\xint_fmax #1#2% {% - \ifnum #4 > #1 - \xint_afterfi {\XINT_fmax_B {#1}}% - \else - \xint_afterfi {\XINT_fmax_B {#4}}% - \fi - {#1}{#4}{#2}{#3}{#5}{#6}{{#4}{#5}{#6}}{{#1}{#2}{#3}}% + \expandafter\XINT_fmax_A\romannumeral0\xintraw {#2}#1% }% -\def\XINT_fmax_B #1#2#3#4#5#6#7% +\def\XINT_fmax_A #1#2/#3[#4]#5#6/#7[#8]% {% - \expandafter\XINT_fmax_C\expandafter - {\romannumeral0\xintimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% - {\romannumeral0\xintimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% + \xint_UDsignsfork + #1#5\dummy \XINT_fmax_minusminus + -#5\dummy \XINT_fmax_firstneg + #1-\dummy \XINT_fmax_secondneg + --\dummy \XINT_fmax_nonneg_a + \krof + #1#5{#2/#3[#4]}{#6/#7[#8]}% }% -\def\XINT_fmax_C #1#2% +\def\XINT_fmax_minusminus --% + {\expandafter\xint_minus_andstop\romannumeral0\XINT_fmin_nonneg_b }% +\def\XINT_fmax_firstneg #1-#2#3{ #1#2}% +\def\XINT_fmax_secondneg -#1#2#3{ #1#3}% +\def\XINT_fmax_nonneg_a #1#2#3#4% {% - \expandafter\XINT_max_fork #2\Z #1\Z + \XINT_fmax_nonneg_b {#1#3}{#2#4}% +}% +\def\XINT_fmax_nonneg_b #1#2% +{% + \ifcase\romannumeral0\XINT_fgeq_A #1#2 + \xint_afterfi{ #1}% + \or \xint_afterfi{ #2}% + \fi }% \def\xintMin {\romannumeral0\xintmin }% \def\xintmin #1% {% - \expandafter\xint_fmin\expandafter {\romannumeral0\XINT_infrac {#1}}% + \expandafter\xint_fmin\expandafter {\romannumeral0\xintraw {#1}}% }% \def\xint_fmin #1#2% {% - \expandafter\XINT_outfrac - \romannumeral0\expandafter\XINT_fmin_A - \romannumeral0\XINT_infrac {#2}#1% + \expandafter\XINT_fmin_A\romannumeral0\xintraw {#2}#1% }% -\def\XINT_fmin_A #1#2#3#4#5#6% +\def\XINT_fmin_A #1#2/#3[#4]#5#6/#7[#8]% {% - \ifnum #4 > #1 - \xint_afterfi {\XINT_fmin_B {#1}}% - \else - \xint_afterfi {\XINT_fmin_B {#4}}% + \xint_UDsignsfork + #1#5\dummy \XINT_fmin_minusminus + -#5\dummy \XINT_fmin_firstneg + #1-\dummy \XINT_fmin_secondneg + --\dummy \XINT_fmin_nonneg_a + \krof + #1#5{#2/#3[#4]}{#6/#7[#8]}% +}% +\def\XINT_fmin_minusminus --% + {\expandafter\xint_minus_andstop\romannumeral0\XINT_fmax_nonneg_b }% +\def\XINT_fmin_firstneg #1-#2#3{ -#3}% +\def\XINT_fmin_secondneg -#1#2#3{ -#2}% +\def\XINT_fmin_nonneg_a #1#2#3#4% +{% + \XINT_fmin_nonneg_b {#1#3}{#2#4}% +}% +\def\XINT_fmin_nonneg_b #1#2% +{% + \ifcase\romannumeral0\XINT_fgeq_A #1#2 + \xint_afterfi{ #2}% + \or \xint_afterfi{ #1}% \fi - {#1}{#4}{#2}{#3}{#5}{#6}{{#4}{#5}{#6}}{{#1}{#2}{#3}}% }% -\def\XINT_fmin_B #1#2#3#4#5#6#7% +\def\xintCmp {\romannumeral0\xintcmp }% +\def\xintcmp #1% {% - \expandafter\XINT_fmin_C\expandafter - {\romannumeral0\xintimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% - {\romannumeral0\xintimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% + \expandafter\xint_fcmp\expandafter {\romannumeral0\xintraw {#1}}% +}% +\def\xint_fcmp #1#2% +{% + \expandafter\XINT_fcmp_A\romannumeral0\xintraw {#2}#1% +}% +\def\XINT_fcmp_A #1#2/#3[#4]#5#6/#7[#8]% +{% + \xint_UDsignsfork + #1#5\dummy \XINT_fcmp_minusminus + -#5\dummy \XINT_fcmp_firstneg + #1-\dummy \XINT_fcmp_secondneg + --\dummy \XINT_fcmp_nonneg_a + \krof + #1#5{#2/#3[#4]}{#6/#7[#8]}% }% -\def\XINT_fmin_C #1#2% +\def\XINT_fcmp_minusminus --#1#2{\XINT_fcmp_B #2#1}% +\def\XINT_fcmp_firstneg #1-#2#3{ -1}% +\def\XINT_fcmp_secondneg -#1#2#3{ 1}% +\def\XINT_fcmp_nonneg_a #1#2% {% - \expandafter\XINT_min_fork #2\Z #1\Z + \xint_UDzerosfork + #1#2\dummy \XINT_fcmp_zerozero + 0#2\dummy \XINT_fcmp_firstzero + #10\dummy \XINT_fcmp_secondzero + 00\dummy \XINT_fcmp_pos + \krof + #1#2% +}% +\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% +}% +\def\XINT_fcmp_B #1/#2[#3]#4/#5[#6]% +{% + \expandafter\XINT_fcmp_C\expandafter + {\the\numexpr #6-#3\expandafter}\expandafter + {\romannumeral0\xintimul {#4}{#2}}% + {\romannumeral0\xintimul {#5}{#1}}% +}% +\def\XINT_fcmp_C #1#2#3% +{% + \expandafter\XINT_fcmp_D\expandafter + {#3}{#1}{#2}% +}% +\def\XINT_fcmp_D #1#2#3% +{% + \xintSgnFork + {\xintiSgn{\the\numexpr #2+\xintLength{#3}-\xintLength{#1}\relax}}% + { -1}{\XINT_fcmp_E #2\Z {#3}{#1}}{ 1}% +}% +\def\XINT_fcmp_E #1% +{% + \xint_UDsignfork + #1\dummy \XINT_fcmp_Fd + -\dummy {\XINT_fcmp_Fn #1}% + \krof +}% +\def\XINT_fcmp_Fd #1\Z #2#3% +{% + \expandafter\XINT_fcmp_Fe\expandafter + {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#3}}{#2}% +}% +\def\XINT_fcmp_Fe #1#2{\XINT_cmp_pre {#2}{#1}}% +\def\XINT_fcmp_Fn #1\Z #2#3% +{% + \expandafter\XINT_cmp_pre\expandafter + {\romannumeral0\XINT_dsx_addzerosnofuss {#1}{#2}}{#3}% }% \def\xintAbs {\romannumeral0\xintabs }% \def\xintabs #1% @@ -1564,7 +1700,7 @@ \def\XINTinfloatadd #1{\XINT_fladd_chkopt \XINT_inFloat #1\Z }% \def\XINT_fladd_chkopt #1#2% {% - \ifx #2[\expandafter\XINT_fladd_opt + \ifx [#2\expandafter\XINT_fladd_opt \else\expandafter\XINT_fladd_noopt \fi #1#2% }% @@ -1611,7 +1747,7 @@ \def\XINTinfloatsub #1{\XINT_flsub_chkopt \XINT_inFloat #1\Z }% \def\XINT_flsub_chkopt #1#2% {% - \ifx #2[\expandafter\XINT_flsub_opt + \ifx [#2\expandafter\XINT_flsub_opt \else\expandafter\XINT_flsub_noopt \fi #1#2% }% @@ -1629,7 +1765,7 @@ \def\XINTinfloatmul #1{\XINT_flmul_chkopt \XINT_inFloat #1\Z }% \def\XINT_flmul_chkopt #1#2% {% - \ifx #2[\expandafter\XINT_flmul_opt + \ifx [#2\expandafter\XINT_flmul_opt \else\expandafter\XINT_flmul_noopt \fi #1#2% }% @@ -1657,7 +1793,7 @@ \def\XINTinfloatdiv #1{\XINT_fldiv_chkopt \XINT_inFloat #1\Z }% \def\XINT_fldiv_chkopt #1#2% {% - \ifx #2[\expandafter\XINT_fldiv_opt + \ifx [#2\expandafter\XINT_fldiv_opt \else\expandafter\XINT_fldiv_noopt \fi #1#2% }% @@ -1685,7 +1821,7 @@ \def\XINTinfloatpow #1{\XINT_flpow_chkopt \XINT_inFloat #1\Z }% \def\XINT_flpow_chkopt #1#2% {% - \ifx #2[\expandafter\XINT_flpow_opt + \ifx [#2\expandafter\XINT_flpow_opt \else\expandafter\XINT_flpow_noopt \fi #1#2% @@ -1824,7 +1960,7 @@ \def\XINTinfloatpower #1{\XINT_flpower_chkopt \XINT_inFloat #1\Z }% \def\XINT_flpower_chkopt #1#2% {% - \ifx #2[\expandafter\XINT_flpower_opt + \ifx [#2\expandafter\XINT_flpower_opt \else\expandafter\XINT_flpower_noopt \fi #1#2% @@ -1917,6 +2053,184 @@ {% \XINT_flpower_loop {#1}{#2}{#3}% }% +\def\xintFloatSqrt {\romannumeral0\xintfloatsqrt }% +\def\xintfloatsqrt #1{\XINT_flsqrt_chkopt \xintfloat #1\Z }% +\def\XINTinFloatSqrt {\romannumeral-`0\XINTinfloatsqrt }% +\def\XINTinfloatsqrt #1{\XINT_flsqrt_chkopt \XINT_inFloat #1\Z }% +\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\Z +{% + #1[\XINT_digits]{\XINT_FL_sqrt \XINT_digits {#2}}% +}% +\def\XINT_flsqrt_opt #1[\Z #2]#3% +{% + #1[#2]{\XINT_FL_sqrt {#2}{#3}}% +}% +\def\XINT_FL_sqrt #1% +{% + \ifnum\numexpr #1<\xint_c_xviii + \xint_afterfi {\XINT_FL_sqrt_a\xint_c_xviii}% + \else + \xint_afterfi {\XINT_FL_sqrt_a {#1+\xint_c_i}}% + \fi +}% +\def\XINT_FL_sqrt_a #1#2% +{% + \expandafter\XINT_FL_sqrt_checkifzeroorneg + \romannumeral-`0\XINT_inFloat [#1]{#2}% +}% +\def\XINT_FL_sqrt_checkifzeroorneg #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_FL_sqrt_iszero + 0#1\dummy \XINT_FL_sqrt_isneg + 0-\dummy {\XINT_FL_sqrt_b #1}% + \krof +}% +\def\XINT_FL_sqrt_iszero #1[#2]{0[0]}% +\def\XINT_FL_sqrt_isneg #1[#2]{\xintError:RootOfNegative 0[0]}% +\def\XINT_FL_sqrt_b #1[#2]% +{% + \ifodd #2 + \xint_afterfi{\XINT_FL_sqrt_c 01}% + \else + \xint_afterfi{\XINT_FL_sqrt_c {}0}% + \fi + {#1}{#2}% +}% +\def\XINT_FL_sqrt_c #1#2#3#4% +{% + \expandafter\XINT_flsqrt\expandafter {\the\numexpr #4-#2}{#3#1}% +}% +\def\XINT_flsqrt #1#2% +{% + \expandafter\XINT_sqrt_a + \expandafter{\romannumeral0\XINT_length {#2}}\XINT_flsqrt_big_d {#2}{#1}% +}% +\def\XINT_flsqrt_big_d #1\or #2\fi #3% +{% + \fi + \ifodd #3 + \xint_afterfi{\expandafter\XINT_flsqrt_big_eB}% + \else + \xint_afterfi{\expandafter\XINT_flsqrt_big_eA}% + \fi + \expandafter {\the\numexpr (#3-\xint_c_i)/\xint_c_ii }{#1}% +}% +\def\XINT_flsqrt_big_eA #1#2#3% +{% + \XINT_flsqrt_big_eA_a #3\Z {#2}{#1}{#3}% +}% +\def\XINT_flsqrt_big_eA_a #1#2#3#4#5#6#7#8#9\Z +{% + \XINT_flsqrt_big_eA_b {#1#2#3#4#5#6#7#8}% +}% +\def\XINT_flsqrt_big_eA_b #1#2% +{% + \expandafter\XINT_flsqrt_big_f + \romannumeral0\XINT_flsqrt_small_e {#2001}{#1}% +}% +\def\XINT_flsqrt_big_eB #1#2#3% +{% + \XINT_flsqrt_big_eB_a #3\Z {#2}{#1}{#3}% +}% +\def\XINT_flsqrt_big_eB_a #1#2#3#4#5#6#7#8#9% +{% + \XINT_flsqrt_big_eB_b {#1#2#3#4#5#6#7#8#9}% +}% +\def\XINT_flsqrt_big_eB_b #1#2\Z #3% +{% + \expandafter\XINT_flsqrt_big_f + \romannumeral0\XINT_flsqrt_small_e {#30001}{#1}% +}% +\def\XINT_flsqrt_small_e #1#2% +{% + \expandafter\XINT_flsqrt_small_f\expandafter + {\the\numexpr #1*#1-#2-\xint_c_i}{#1}% +}% +\def\XINT_flsqrt_small_f #1#2% +{% + \expandafter\XINT_flsqrt_small_g\expandafter + {\the\numexpr (#1+#2)/(2*#2)-\xint_c_i }{#1}{#2}% +}% +\def\XINT_flsqrt_small_g #1% +{% + \ifnum #1>\xint_c_ + \expandafter\XINT_flsqrt_small_h + \else + \expandafter\XINT_flsqrt_small_end + \fi + {#1}% +}% +\def\XINT_flsqrt_small_h #1#2#3% +{% + \expandafter\XINT_flsqrt_small_f\expandafter + {\the\numexpr #2-\xint_c_ii*#1*#3+#1*#1\expandafter}\expandafter + {\the\numexpr #3-#1}% +}% +\def\XINT_flsqrt_small_end #1#2#3% +{% + \expandafter\space\expandafter + {\the\numexpr \xint_c_i+#3*\xint_c_x^iv- + (#2*\xint_c_x^iv+#3)/(\xint_c_ii*#3)}% +}% +\def\XINT_flsqrt_big_f #1% +{% + \expandafter\XINT_flsqrt_big_fa\expandafter + {\romannumeral0\xintisqr {#1}}{#1}% +}% +\def\XINT_flsqrt_big_fa #1#2#3#4% +{% + \expandafter\XINT_flsqrt_big_fb\expandafter + {\romannumeral-`0\XINT_dsx_addzerosnofuss + {\numexpr #3-\xint_c_viii\relax}{#2}}% + {\romannumeral0\xintisub + {\XINT_dsx_addzerosnofuss + {\numexpr \xint_c_ii*(#3-\xint_c_viii)\relax}{#1}}{#4}}% + {#3}% +}% +\def\XINT_flsqrt_big_fb #1#2% +{% + \expandafter\XINT_flsqrt_big_g\expandafter {#2}{#1}% +}% +\def\XINT_flsqrt_big_g #1#2% +{% + \expandafter\XINT_flsqrt_big_j + \romannumeral0\xintidivision + {#1}{\romannumeral0\XINT_dbl_pos #2\R\R\R\R\R\R\R\Z \W\W\W\W\W\W\W }{#2}% +}% +\def\XINT_flsqrt_big_j #1% +{% + \ifcase\XINT_Sgn {#1} + \expandafter \XINT_flsqrt_big_end_a + \or \expandafter \XINT_flsqrt_big_k + \fi {#1}% +}% +\def\XINT_flsqrt_big_k #1#2#3% +{% + \expandafter\XINT_flsqrt_big_l\expandafter + {\romannumeral0\XINT_sub_pre {#3}{#1}}% + {\romannumeral0\xintiadd {#2}{\romannumeral0\XINT_sqr {#1}}}% +}% +\def\XINT_flsqrt_big_l #1#2% +{% + \expandafter\XINT_flsqrt_big_g\expandafter + {#2}{#1}% +}% +\def\XINT_flsqrt_big_end_a #1#2#3#4#5% +{% + \expandafter\XINT_flsqrt_big_end_b\expandafter + {\the\numexpr -#4+#5/\xint_c_ii\expandafter}\expandafter + {\romannumeral0\xintisub + {\XINT_dsx_addzerosnofuss {#4}{#3}}% + {\xintHalf{\xintiQuo{\XINT_dsx_addzerosnofuss {#4}{#2}}{#3}}}}% +}% +\def\XINT_flsqrt_big_end_b #1#2{#2[#1]}% \XINT_frac_restorecatcodes_endinput% \endinput %% diff --git a/Master/texmf-dist/tex/generic/xint/xintgcd.sty b/Master/texmf-dist/tex/generic/xint/xintgcd.sty index 702fa0c78a5..467e62a9925 100644 --- a/Master/texmf-dist/tex/generic/xint/xintgcd.sty +++ b/Master/texmf-dist/tex/generic/xint/xintgcd.sty @@ -22,7 +22,7 @@ %% in the same archive or directory.) %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.07a of May 26, 2013) +%% The xint bundle (version 1.08b of June 14, 2013) %% xintgcd: Euclidean algorithm with xint package %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -115,6 +115,7 @@ \edef\XINT_gcd_restorecatcodes_endinput {% \catcode36=\the\catcode36 % $ + \catcode94=\the\catcode94 % ^ \catcode96=\the\catcode96 % ` \catcode47=\the\catcode47 % / \catcode41=\the\catcode41 % ) @@ -137,7 +138,7 @@ \catcode61=\the\catcode61\relax % = \noexpand\endinput }% - \XINT_setcatcodes + \XINT_setcatcodes % defined in xint.sty \catcode36=3 % $ }% \x @@ -164,7 +165,7 @@ \fi \expandafter\x\csname ver@xintgcd.sty\endcsname \ProvidesPackage{xintgcd}% - [2013/05/26 v1.07a Euclide algorithm with xint package (jfB)]% + [2013/06/14 v1.08b Euclide algorithm with xint package (jfB)]% \def\xintGCD {\romannumeral0\xintgcd }% \def\xintgcd #1% {% diff --git a/Master/texmf-dist/tex/generic/xint/xintseries.sty b/Master/texmf-dist/tex/generic/xint/xintseries.sty index f1b6d882e85..2a63f12eb29 100644 --- a/Master/texmf-dist/tex/generic/xint/xintseries.sty +++ b/Master/texmf-dist/tex/generic/xint/xintseries.sty @@ -22,7 +22,7 @@ %% in the same archive or directory.) %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.07a of May 26, 2013) +%% The xint bundle (version 1.08b of June 14, 2013) %% xintseries: Expandable partial sums with xint package %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -116,6 +116,7 @@ {% \catcode93=\the\catcode93 % ] \catcode91=\the\catcode91 % [ + \catcode94=\the\catcode94 % ^ \catcode96=\the\catcode96 % ` \catcode47=\the\catcode47 % / \catcode41=\the\catcode41 % ) @@ -138,7 +139,7 @@ \catcode61=\the\catcode61\relax % = \noexpand\endinput }% - \XINT_setcatcodes + \XINT_setcatcodes % defined in xint.sty \catcode91=12 % [ \catcode93=12 % ] }% @@ -164,17 +165,14 @@ \fi \expandafter\x\csname ver@xintseries.sty\endcsname \ProvidesPackage{xintseries}% - [2013/05/26 v1.07a Expandable partial sums with xint package (jfB)]% + [2013/06/14 v1.08b Expandable partial sums with xint package (jfB)]% \def\xintSeries {\romannumeral0\xintseries }% \def\xintseries #1#2% {% - \expandafter\XINT_series_i\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_series\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_series_i #1#2% -{% - \expandafter\XINT_series_ii\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_series_ii #1#2#3% +\def\XINT_series #1#2#3% {% \ifnum #2<#1 \xint_afterfi { 0/1[0]}% @@ -197,13 +195,10 @@ \def\xintiSeries {\romannumeral0\xintiseries }% \def\xintiseries #1#2% {% - \expandafter\XINT_iseries_i\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_iseries_i #1#2% -{% - \expandafter\XINT_iseries_ii\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_iseries\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_iseries_ii #1#2#3% +\def\XINT_iseries #1#2#3% {% \ifnum #2<#1 \xint_afterfi { 0}% @@ -226,13 +221,10 @@ \def\xintPowerSeries {\romannumeral0\xintpowerseries }% \def\xintpowerseries #1#2% {% - \expandafter\XINT_powseries_i\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_powseries\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_powseries_i #1#2% -{% - \expandafter\XINT_powseries_ii\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_powseries_ii #1#2#3#4% +\def\XINT_powseries #1#2#3#4% {% \ifnum #2<#1 \xint_afterfi { 0/1[0]}% @@ -264,13 +256,10 @@ \def\xintPowerSeriesX {\romannumeral0\xintpowerseriesx }% \def\xintpowerseriesx #1#2% {% - \expandafter\XINT_powseriesx_i\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_powseriesx_i #1#2% -{% - \expandafter\XINT_powseriesx_ii\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_powseriesx\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_powseriesx_ii #1#2#3#4% +\def\XINT_powseriesx #1#2#3#4% {% \ifnum #2<#1 \xint_afterfi { 0/1[0]}% @@ -288,13 +277,10 @@ \def\xintRationalSeries {\romannumeral0\xintratseries }% \def\xintratseries #1#2% {% - \expandafter\XINT_ratseries_i\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_ratseries\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_ratseries_i #1#2% -{% - \expandafter\XINT_ratseries_ii\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_ratseries_ii #1#2#3#4% +\def\XINT_ratseries #1#2#3#4% {% \ifnum #2<#1 \xint_afterfi { 0/1[0]}% @@ -325,13 +311,10 @@ \def\xintRationalSeriesX {\romannumeral0\xintratseriesx }% \def\xintratseriesx #1#2% {% - \expandafter\XINT_ratseriesx_i\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_ratseriesx_i #1#2% -{% - \expandafter\XINT_ratseriesx_ii\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_ratseriesx\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_ratseriesx_ii #1#2#3#4#5% +\def\XINT_ratseriesx #1#2#3#4#5% {% \ifnum #2<#1 \xint_afterfi { 0/1[0]}% @@ -349,13 +332,10 @@ \def\xintFxPtPowerSeries {\romannumeral0\xintfxptpowerseries }% \def\xintfxptpowerseries #1#2% {% - \expandafter\XINT_fppowseries_i\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_fppowseries\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_fppowseries_i #1#2% -{% - \expandafter\XINT_fppowseries_ii\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_fppowseries_ii #1#2#3#4#5% +\def\XINT_fppowseries #1#2#3#4#5% {% \ifnum #2<#1 \xint_afterfi { 0}% @@ -371,7 +351,7 @@ {% \ifnum #4>#2 \else\XINT_fppowseries_dont_i \fi \expandafter\XINT_fppowseries_loop_i\expandafter - {\the\numexpr #2+1\expandafter}\expandafter + {\the\numexpr #2+\xint_c_i\expandafter}\expandafter {\romannumeral0\xintitrunc {#6}{\xintMul {#5{#2}}{#1}}}% {#1}{#3}{#4}{#5}{#6}% }% @@ -388,7 +368,7 @@ \def\XINT_fppowseries_loop_ii #1#2#3#4#5#6#7% {% \expandafter\XINT_fppowseries_loop_i\expandafter - {\the\numexpr #2+1\expandafter}\expandafter + {\the\numexpr #2+\xint_c_i\expandafter}\expandafter {\romannumeral0\xintiadd {#4}{\xintiTrunc {#7}{\xintMul {#6{#2}}{#1}}}}% {#1}{#3}{#5}{#6}{#7}% }% @@ -402,13 +382,10 @@ \def\xintFxPtPowerSeriesX {\romannumeral0\xintfxptpowerseriesx }% \def\xintfxptpowerseriesx #1#2% {% - \expandafter\XINT_fppowseriesx_i\expandafter {\the\numexpr #2}{#1}% + \expandafter\XINT_fppowseriesx\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% }% -\def\XINT_fppowseriesx_i #1#2% -{% - \expandafter\XINT_fppowseriesx_ii\expandafter {\the\numexpr #2}{#1}% -}% -\def\XINT_fppowseriesx_ii #1#2#3#4#5% +\def\XINT_fppowseriesx #1#2#3#4#5% {% \ifnum #2<#1 \xint_afterfi { 0}% @@ -425,6 +402,109 @@ {\romannumeral0\xinttrunc {#5}{\xintPow {#1}{#2}}}% {#2}{#1}{#3}{#4}{#5}% }% +\def\xintFloatPowerSeries {\romannumeral0\xintfloatpowerseries }% +\def\xintfloatpowerseries #1{\XINT_flpowseries_chkopt #1\Z }% +\def\XINT_flpowseries_chkopt #1% +{% + \ifx [#1\expandafter\XINT_flpowseries_opt + \else\expandafter\XINT_flpowseries_noopt + \fi + #1% +}% +\def\XINT_flpowseries_noopt #1\Z #2% +{% + \expandafter\XINT_flpowseries\expandafter + {\the\numexpr #1\expandafter}\expandafter + {\the\numexpr #2}\XINT_digits +}% +\def\XINT_flpowseries_opt [\Z #1]#2#3% +{% + \expandafter\XINT_flpowseries\expandafter + {\the\numexpr #2\expandafter}\expandafter + {\the\numexpr #3\expandafter}{\the\numexpr #1}% +}% +\def\XINT_flpowseries #1#2#3#4#5% +{% + \ifnum #2<#1 + \xint_afterfi { 0.e0}% + \else + \xint_afterfi + {\expandafter\XINT_flpowseries_loop_pre\expandafter + {\romannumeral-`0\XINTinfloatpow [#3]{#5}{#1}}% + {#1}{#5}{#2}{#4}{#3}% + }% + \fi +}% +\def\XINT_flpowseries_loop_pre #1#2#3#4#5#6% +{% + \ifnum #4>#2 \else\XINT_flpowseries_dont_i \fi + \expandafter\XINT_flpowseries_loop_i\expandafter + {\the\numexpr #2+\xint_c_i\expandafter}\expandafter + {\romannumeral-`0\XINTinfloatmul [#6]{#5{#2}}{#1}}% + {#1}{#3}{#4}{#5}{#6}% +}% +\def\XINT_flpowseries_dont_i \fi\expandafter\XINT_flpowseries_loop_i + {\fi \expandafter\XINT_flpowseries_dont_ii }% +\def\XINT_flpowseries_dont_ii #1#2#3#4#5#6#7{\xintfloat [#7]{#2}}% +\def\XINT_flpowseries_loop_i #1#2#3#4#5#6#7% +{% + \ifnum #5>#1 \else \XINT_flpowseries_exit_i \fi + \expandafter\XINT_flpowseries_loop_ii\expandafter + {\romannumeral-`0\XINTinfloatmul [#7]{#3}{#4}}% + {#1}{#4}{#2}{#5}{#6}{#7}% +}% +\def\XINT_flpowseries_loop_ii #1#2#3#4#5#6#7% +{% + \expandafter\XINT_flpowseries_loop_i\expandafter + {\the\numexpr #2+\xint_c_i\expandafter}\expandafter + {\romannumeral-`0\XINTinfloatadd [#7]{#4}% + {\XINTinfloatmul [#7]{#6{#2}}{#1}}}% + {#1}{#3}{#5}{#6}{#7}% +}% +\def\XINT_flpowseries_exit_i\fi\expandafter\XINT_flpowseries_loop_ii + {\fi \expandafter\XINT_flpowseries_exit_ii }% +\def\XINT_flpowseries_exit_ii #1#2#3#4#5#6#7% +{% + \xintfloatadd [#7]{#4}{\XINTinfloatmul [#7]{#6{#2}}{#1}}% +}% +\def\xintFloatPowerSeriesX {\romannumeral0\xintfloatpowerseriesx }% +\def\xintfloatpowerseriesx #1{\XINT_flpowseriesx_chkopt #1\Z }% +\def\XINT_flpowseriesx_chkopt #1% +{% + \ifx [#1\expandafter\XINT_flpowseriesx_opt + \else\expandafter\XINT_flpowseriesx_noopt + \fi + #1% +}% +\def\XINT_flpowseriesx_noopt #1\Z #2% +{% + \expandafter\XINT_flpowseriesx\expandafter + {\the\numexpr #1\expandafter}\expandafter + {\the\numexpr #2}\XINT_digits +}% +\def\XINT_flpowseriesx_opt [\Z #1]#2#3% +{% + \expandafter\XINT_flpowseriesx\expandafter + {\the\numexpr #2\expandafter}\expandafter + {\the\numexpr #3\expandafter}{\the\numexpr #1}% +}% +\def\XINT_flpowseriesx #1#2#3#4#5% +{% + \ifnum #2<#1 + \xint_afterfi { 0.e0}% + \else + \xint_afterfi + {\expandafter \XINT_flpowseriesx_pre \expandafter + {\romannumeral-`0#5}{#1}{#2}{#4}{#3}% + }% + \fi +}% +\def\XINT_flpowseriesx_pre #1#2#3#4#5% +{% + \expandafter\XINT_flpowseries_loop_pre\expandafter + {\romannumeral-`0\XINTinfloatpow [#5]{#1}{#2}}% + {#2}{#1}{#3}{#4}{#5}% +}% \XINT_series_restorecatcodes_endinput% \endinput %% |