From 04fd1776023ee2133a059a5a7c0974705552be89 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 27 May 2013 05:00:41 +0000 Subject: xint update (5/27) git-svn-id: svn://tug.org/texlive/trunk@30723 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/generic/xint/README | 99 +- Master/texmf-dist/doc/generic/xint/xint.pdf | Bin 519270 -> 629272 bytes Master/texmf-dist/source/generic/xint/xint.dtx | 3618 +++++++++++++++++---- Master/texmf-dist/source/generic/xint/xint.ins | 5 +- Master/texmf-dist/tex/generic/xint/xint.sty | 51 +- Master/texmf-dist/tex/generic/xint/xintcfrac.sty | 57 +- Master/texmf-dist/tex/generic/xint/xintexpr.sty | 769 +++++ Master/texmf-dist/tex/generic/xint/xintfrac.sty | 743 ++++- Master/texmf-dist/tex/generic/xint/xintgcd.sty | 4 +- Master/texmf-dist/tex/generic/xint/xintseries.sty | 4 +- 10 files changed, 4664 insertions(+), 686 deletions(-) create mode 100644 Master/texmf-dist/tex/generic/xint/xintexpr.sty (limited to 'Master') diff --git a/Master/texmf-dist/doc/generic/xint/README b/Master/texmf-dist/doc/generic/xint/README index fa4d92bddcd..5e4fbff4adb 100644 --- a/Master/texmf-dist/doc/generic/xint/README +++ b/Master/texmf-dist/doc/generic/xint/README @@ -1,27 +1,34 @@ -%---------------------------------------------------------------- -% The xint bundle -% (base) xint.sty Expandable operations on long numbers -% xintgcd.sty Euclidean algorithm with xint package -% xintfrac.sty Expandable operations on fractions -% xintseries.sty Expandable partial sums with xint package -% xintcfrac.sty Expandable continued fractions with xint package -% Copyright (C) 2013 by Jean-Francois Burnol -% Version: v1.06b (2013/05/14) -%---------------------------------------------------------------- - -This work consists of the source file xint.dtx and of its derived files -xint.sty, xintgcd.sty, xintfrac.sty, xintseries.sty, xintcfrac.sty, -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 - version 1.3c of this license or (at your option) any later - version. This version of this license is in - http://www.latex-project.org/lppl/lppl-1-3c.txt - and the latest version of this license is in - http://www.latex-project.org/lppl.txt - and version 1.3 or later is part of all distributions of - LaTeX version 2005/12/01 or later. +The xint bundle +Release 1.07a (2013/05/26) +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 + 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) + +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). + + This work may be distributed and/or modified under the + conditions of the LaTeX Project Public License, either + version 1.3c of this license or (at your option) any later + version. This version of this license is in + http://www.latex-project.org/lppl/lppl-1-3c.txt + and the latest version of this license is in + http://www.latex-project.org/lppl.txt + and version 1.3 or later is part of all distributions of + LaTeX version 2005/12/01 or later. The author of this work is Jean-Francois Burnol . This work has the LPPL maintenance status `author-maintained'. @@ -30,38 +37,44 @@ Installation and Usage: ======================= Run tex or latex on xint.dtx. - -This will extract the style files xint.sty, xintgcd.sty, xintfrac.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 understand -\NeedsTeXFormat, but the style files will already have been extracted -by that time. + +This will extract the style files xint.sty, xintfrac.sty, xintexpr.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 +understand \NeedsTeXFormat, but the style files will already have been +extracted by that time. Alternatively, run tex or latex on xint.ins if available. To get xint.pdf run pdflatex thrice on xint.dtx xint.sty | + xintfrac.sty | + xintexpr.sty | --> TDS:tex/generic/xint/ xintgcd.sty | - xintfrac.sty | --> TDS:tex/generic/xint/ xintseries.sty | xintcfrac.sty | xint.dtx --> TDS:source/generic/xint/ xint.pdf --> TDS:doc/generic/xint/ - - It may be necessary to then refresh the TeX installation filename - database. + +It may be necessary to then refresh the TeX installation filename +database. Usage with LaTeX: \usepackage{xint} - \usepackage{xintgcd} (loads xint) - \usepackage{xintfrac} (loads xint) - \usepackage{xintseries} (loads xintfrac) - \usepackage{xintcfrac} (loads xintfrac) + \usepackage{xintfrac} (loads xint) + \usepackage{xintexpr} (loads xintfrac) + + \usepackage{xintgcd} (loads xint) + \usepackage{xintseries} (loads xintfrac) + \usepackage{xintcfrac} (loads xintfrac) Usage with TeX: \input xint.sty\relax - \input xintgcd.sty\relax (loads xint) - \input xintfrac.sty\relax (loads xint) - \input xintseries.sty\relax (loads xintfrac) - \input xintcfrac.sty\relax (loads xintfrac) + \input xintfrac.sty\relax (loads xint) + \input xintexpr.sty\relax (loads xintfrac) + + \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 index dc6f5d118e8..1d67e7e3ef2 100644 Binary files a/Master/texmf-dist/doc/generic/xint/xint.pdf and b/Master/texmf-dist/doc/generic/xint/xint.pdf differ diff --git a/Master/texmf-dist/source/generic/xint/xint.dtx b/Master/texmf-dist/source/generic/xint/xint.dtx index 34f86ef47b8..27b0f755918 100644 --- a/Master/texmf-dist/source/generic/xint/xint.dtx +++ b/Master/texmf-dist/source/generic/xint/xint.dtx @@ -1,10 +1,11 @@ % -*- coding: iso-latin-1; -*- -% This file: xint.dtx (1.06b, 2013/05/14) +% This file: xint.dtx (1.07a, 2013/05/26) % % Style files which will self-extract from xint.dtx: % (base) xint.sty Expandable operations on long numbers -% xintgcd.sty Euclidean algorithm with xint package % xintfrac.sty Expandable operations on fractions +% xintexpr.sty Expandable expression parser +% 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) @@ -12,9 +13,10 @@ % License % ======= % -% This work consists of the source file xint.dtx and of its derived files -% xint.sty, xintgcd.sty, xintfrac.sty, xintseries.sty, xintcfrac.sty, xint.ins -% and the documentation xint.pdf (or xint.dvi). +% 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). % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either @@ -34,20 +36,22 @@ % % Run tex or latex on xint.dtx. % -% This will extract the style files xint.sty, xintgcd.sty, xintfrac.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 understand -% \NeedsTeXFormat, but the style files will already have been extracted -% by that time. +% This will extract the style files xint.sty, xintfrac.sty, xintexpr.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 +% understand \NeedsTeXFormat, but the style files will already have been +% extracted by that time. % % Alternatively, run tex or latex on xint.ins if available. % % To get xint.pdf run pdflatex thrice on xint.dtx % % xint.sty | +% xintfrac.sty | +% xintexpr.sty | --> TDS:tex/generic/xint/ % xintgcd.sty | -% xintfrac.sty | --> TDS:tex/generic/xint/ % xintseries.sty | % xintcfrac.sty | % xint.dtx --> TDS:source/generic/xint/ @@ -57,32 +61,37 @@ % database. % % Usage with LaTeX: \usepackage{xint} -% \usepackage{xintgcd} % (loads xint) % \usepackage{xintfrac} % (loads xint) +% \usepackage{xintexpr} % (loads xintfrac) +% +% \usepackage{xintgcd} % (loads xint) % \usepackage{xintseries} % (loads xintfrac) % \usepackage{xintcfrac} % (loads xintfrac) % % Usage with TeX: \input xint.sty\relax -% \input xintgcd.sty\relax % (loads xint) % \input xintfrac.sty\relax % (loads xint) +% \input xintexpr.sty\relax % (loads xintfrac) +% +% \input xintgcd.sty\relax % (loads xint) % \input xintseries.sty\relax % (loads xintfrac) % \input xintcfrac.sty\relax % (loads xintfrac) % %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.06b of May 14, 2013) +%% The xint bundle (version 1.07a of May 26, 2013) %%% xint: Expandable operations on long numbers -%%% xintgcd: Euclidean algorithm with xint package %%% xintfrac: Expandable operations on fractions +%%% xintexpr: Expandable expression parser +%%% xintgcd: Euclidean algorithm with xint package %%% xintseries: Expandable partial sums with xint package %%% xintcfrac: Expandable continued fractions with xint package %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- %% %<*none> -\def\lasttimestamp{Time-stamp: <14-05-2013 22:00:09 CEST jfb>} -\def\pkgversion{1.06b} -\def\pkgdate{2013/05/14} +\def\lasttimestamp{Time-stamp: <26-05-2013 11:42:13 CEST jfb>} +\def\pkgversion{1.07a} +\def\pkgdate{2013/05/26} \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} @@ -97,7 +106,8 @@ \file{xintgcd.sty}{\from{xint.dtx}{xintgcd}} \file{xintfrac.sty}{\from{xint.dtx}{xintfrac}} \file{xintseries.sty}{\from{xint.dtx}{xintseries}} -\file{xintcfrac.sty}{\from{xint.dtx}{xintcfrac}}} +\file{xintcfrac.sty}{\from{xint.dtx}{xintcfrac}} +\file{xintexpr.sty}{\from{xint.dtx}{xintexpr}}} \endgroup \iffalse % @@ -118,7 +128,8 @@ \file{xintgcd.sty}{\from{xint.dtx}{xintgcd}} \file{xintfrac.sty}{\from{xint.dtx}{xintfrac}} \file{xintseries.sty}{\from{xint.dtx}{xintseries}} -\file{xintcfrac.sty}{\from{xint.dtx}{xintcfrac}}} +\file{xintcfrac.sty}{\from{xint.dtx}{xintcfrac}} +\file{xintexpr.sty}{\from{xint.dtx}{xintexpr}}} \endbatchfile %----------- end of .ins file ------------------------------------ % @@ -139,10 +150,7 @@ \usepackage[hscale=0.66,vscale=0.75]{geometry} -%% checking that dependencies are all-right -%\usepackage{xint} -%\usepackage{xintgcd} -%\usepackage{xintfrac} +\usepackage{xintexpr} \usepackage{xintgcd} \usepackage{xintseries} @@ -251,7 +259,7 @@ \usepackage[english]{babel} \usepackage[autolanguage,np]{numprint} \AtBeginDocument{ -\npthousandsep{,\hskip .16667em plus .01em minus .01em}} +\npthousandsep{,\hskip .05em plus .01em minus .01em}} \usepackage[pdfencoding=pdfdoc,bookmarks=true]{hyperref} @@ -268,6 +276,13 @@ 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{}} + + %---- OUR OWN LITTLE MACRO FOR CENTERING LINES \makeatletter % 7 mars 2013 @@ -349,7 +364,7 @@ pdfpagemode=UseOutlines} \bgroup \MicroFont \let\do\do@noligs \verbatim@nolig@list \let\do\@makeother \dospecials - \catcode32 10 \@jfverb + \catcode32 10 \catcode`\~ 0 \@jfverb } \def\@jfverb #1{\catcode`#1\active\lccode`\~`#1\lowercase{\let~\egroup}} % ATTENTION! @@ -435,7 +450,7 @@ pdfpagemode=UseOutlines} \xspace }% }% \xintApplyUnbraced\xintpackagenamedef - {{xint}{xintgcd}{xintfrac}{xintseries}{xintcfrac}} + {{xint}{xintgcd}{xintfrac}{xintseries}{xintcfrac}{xintexpr}} \frenchspacing @@ -454,6 +469,8 @@ pdfpagemode=UseOutlines} \newcount\cnta \newcount\cntb +\newcommand\lowast{\raisebox{-.25\height}{*}} +% to be used as ~lowast in my short verbs \begin{document} \thispagestyle{empty} @@ -464,8 +481,8 @@ pdfpagemode=UseOutlines} {\normalfont\Large\parindent0pt \parfillskip 0pt\relax \leftskip 2cm plus 1fil \rightskip 2cm plus 1fil - The \xintname bundle: \xintname, - \xintgcdname, \xintfracname, \xintseriesname and \xintcfracname.\par}% + The \xintname bundle: \xintname, \xintfracname, \xintexprname, + \xintgcdname, \xintseriesname and \xintcfracname.\par}% {\centering \textsc{Jean-François Burnol}\par \footnotesize \ttfamily @@ -480,33 +497,106 @@ pdfpagemode=UseOutlines} 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 \xintgcdname package provides implementations of the - Euclidean algorithm and of its typesetting. - - The \xintfracname package extends the scope of \xintname to - fractional numbers of arbitrary sizes ; \xintseriesname provides - some basic functionality for computing in an expandable manner - partial sums of series and power series with fractional - coefficients. And \xintcfracname deals with the computation of - continued fractions. - - The packages may be used with Plain and with \LaTeX. Most macros, and - all of those doing computations, work purely by expansion without - assignments, and may thus be used almost everywhere in \TeX{}. + sign. The \xintfracname package extends the scope of \xintname to + fractional numbers of arbitrary sizes. + + \xintexprname provides an expandable parser |\xintexpr . . . \relax| of + expressions constructed with decimal numbers, fractions, numbers in + scientific notation, the basic operations as infix operators, parentheses, + 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. + + Most macros, and all of those doing computations, work purely by expansion + without assignments, and may thus be used almost everywhere in \TeX{}. + + The packages may be used with any flavor of \TeX{} supporting the \eTeX{} + extensions. \LaTeX{} users will use |\usepackage| and others |\input| to + load the package components. \end{abstract} \tableofcontents -\section{Raison d'\^etre of these packages} +\section{Presentation} + +\subsection{Latest} + +Release |1.07| brings important additions: +\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 \xintexprname package is a new core constituent (which loads + automatically \xintfracname and \xintname) and implements the expandable + expanding parsers \centeredline{{\color{blue}|\xintexpr . . . \relax|}, + and its variant + {\color{blue}|\xintfloatexpr . . + . \relax|}} allowing on input formulas using the standard form with infix + operators |+|, |-|, |*|, |/|, and |^|, and arbitrary levels of + parenthesizing. Within a float expression the operations are executed + 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. + + +\subsection{Missing things} + + +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. + +% 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, + +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}. \subsection{Some examples} -The main 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 +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 - |etex| or |pdftex| executables presumably limit even more the possible - computations, not to mention the time taken by them.} + \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. } Here are some examples: @@ -518,19 +608,16 @@ Here are some examples: {1500}{1234/56789}}\dots {\color{magenta}&0.99^{-100}& with 200 digits after the decimal point:}\\ -{\color{blue}\csb{xintTrunc}|{200}{|\csb{xintPow}|{.99}{-100}}\dots|}: -\printnumber{\xintTrunc {200}{\xintPow {.99}{-100}}}\dots +{\color{blue}\csb{xintTrunc}|{200}{\xinttheexpr .99^-100\relax}\dots|}: +\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|\\ -\hspace*{2cm}|{\xintiSub {\xintiPow - {7}{200}}{\xintiPow{3}{200}}}|\\ -\hspace*{2cm}|{\xintiSub {\xintiPow {2}{200}}{1}}\to\A\B\U\V\D|% +\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 {\xintiSub {\xintiPow - {7}{200}}{\xintiPow{3}{200}}} -{\xintiSub {\xintiPow {2}{200}}{1}}\to\A\B\U\V\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 {\color{magenta}The Euclide algorithm applied to \np{179876541573} and @@ -551,7 +638,7 @@ infinity, has value $\frac{\pi^2}{144}-\frac1{162}={}$\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 .16667em plus .01em minus .01em}}}. But the breaking accross + \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 @@ -574,6 +661,7 @@ 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. + To see more of \xintname in action, jump to the {\color{niceone}\autoref{sec:series}} describing the commands of the \xintseriesname{} package, especially as illustrated with the @@ -587,6 +675,8 @@ 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 @@ -625,21 +715,6 @@ 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{Missing things} - -Currently \xintname does not provide `floating-point' operations. 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. - -The most blatantly lacking thing in the \xintname project is a decent input -parser, allowing to type in computations in a usual infix form such as, for -example |3*14+2.7^-2*5|. At this time, one has to type |\xintAdd {\xintMul - {3}{14}}{\xintMul{\xintPow{2.7}{-2}}{5}}|. Previous computation results can be -stored in macros and given as arguments to the package macros (see further on -for important aspects of this). - \subsection{Origins of the package} @@ -679,7 +754,7 @@ for \csa{numexpr} has ten digits). The present package is the result of this initial questioning. \begin{framed}\centering - \xintname requires the \eTeX{} \csa{numexpr} primitive. + \xintname requires the \eTeX{} extensions. \end{framed} @@ -725,7 +800,8 @@ 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}, 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 + 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 @@ -737,38 +813,54 @@ or as would allow to use it directly as |\printnumber\mynumber| with a |\mynumber| itself defined via a |\def| or |\newcommand|). -\def\x {\xintTrunc {300}{\xintPow{.7}{-25}}}% Just to show off, let's print 300 digits (after the decimal point) of -the decimal expansion of &0.7^{-25}&: -\centeredline{|\printnumber {\xintTrunc {300}{\xintPow{.7}{-25}}}\dots|} -\expandafter\printnumber\expandafter {\x}\dots - -This computation uses \xintfracname wich extends to fractions the basic -arithmetic operations defined for integers by \xintname. - - +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 + +This computation uses the macro \csb{xintTrunc} from package \xintfracname +wich extends to fractions the basic arithmetic operations defined for +integers by \xintname. It also uses \csb{xinttheexpr} from package +\xintexprname, which allows to use standard notations. Note that the +fraction |.7^-25| is first evaluated exactly; for some more complex inputs, +such as |.7123045678952^-243|, the exact evaluation before truncation would +be expensive, and (assuming one needs twenty digits) one +would rather use floating mode: +\centeredline{|\xintDigits:=20; + \np{\xintthefloatexpr .7123045678952^-243\relax}|}% +\xintDigits:=20;% +\centeredline{|.7123045678952^-243| = \texttt{\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 +% = 24: 0.634202211748841612732270 10^36 + +\xintDigits:=16; Important points, to be noted, related to the expansion of arguments: \begin{enumerate} -\item the macros expand `fully' their arguments,\vadjust{\vskip-\dp\strutbox - \hbox{\smash{\color{niceone}\llap{\strut\small CHANGED! (|1.06|)\ - $\to$\kern\parindent - }}}\vskip\dp\strutbox } this means that they expand the - first token seen (for each argument), then expand \strut{} again, etc..., - until - something un-expandable such as a\strut{} digit or a brace is hit - against.\footnote{the knowledgeable people will have recognized \texttt{\string\romannumeral-\string`0}} This - example \centeredline{|\def\x{12}\def\y{34}|% +\item the macros expand `fully' their arguments, this means that they expand + the first token seen (for each argument), then expand + \MyMarginNote{Changed in |1.06|}, etc..., until something un-expandable + such as a\strut{} digit or a brace is hit against.\footnote{the + knowledgeable people will have recognized + \texttt{\string\romannumeral-\string`0}} This example + \centeredline{|\def\x{98765}\def\y{43210}|% |\xintAdd {\x}{\x\y}|} is \emph{not} a legal construct, as the |\y| will - remain untouched by expansion and not get converted into the digits which are - expected by the - sub-routiunes of |\xintAdd|. It works here by sheer luck as the |\y| - gets expanded inside a |\numexpr|. But this would fail in general: if you need - a more complete (expandable...) expansion of your initial input, you should - use the \fbox{\csa{bigintcalcNum}} macro from the |bigintcalc| package. Or, - outside of an expandable-only context, just massage your inputs through - \csa{edef}'s. + remain untouched by expansion and not get converted into the digits which + are expected by the sub-routines of |\xintAdd|. It is a |\numexpr| + which will expand it and an arithmetic overflow will arise as |9876543210| + 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 + \endgroup \item Unfortunately, after |\def\x {12}|, one can not use just {\color{blue}|-\x|} as input to one of the package macros: the rules above @@ -776,6 +868,13 @@ Important points, to be noted, related to the expansion of arguments: hence do nothing. The only way is to use the \csb{xintOpp} macro, which replaces a number with its opposite. + \begingroup\slshape + Again, this is otherwise inside an \csb{xinttheexpr}-ession or + \csb{xintthefloatexpr}-ession. There,\MyMarginNote{New with |1.07|} the + minus sign may prefix macros which will expand to numbers (or parentheses + etc...) + \endgroup + \def\x {12}% \def\AplusBC #1#2#3{\xintAdd {#1}{\xintMul {#2}{#3}}}% @@ -809,16 +908,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{\aplusbc}[3]{\xintadd {#1}{\xintMul {#2}{#3}}}|\par - \hspace*{1cm}|\newcommand{\AplusBC}{\romannumeral0\aplusbc}|\par + \hspace*{1cm}|\newcommand~lowast{\aplusbc}[3]{\xintadd {#1}{\xintMul + {#2}{#3}}}|\par + \hspace*{1cm}|\newcommand~lowast{\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\myalgebra [6]{\xintmul {\AplusBC {#1}{#2}{#3}}{\AplusBC + |\newcommand~lowast\myalgebra [6]{\xintmul {\AplusBC {#1}{#2}{#3}}{\AplusBC {#4}{#5}{#6}}}|\par - |\newcommand\MyAlgebra {\romannumeral0\myalgebra}|\par + |\newcommand~lowast\MyAlgebra {\romannumeral0\myalgebra}|\par \end{enumerate} The |\romannumeral0| things above look like an invitation to hacker's @@ -827,16 +927,47 @@ there is no reason to follow these guidelines. Just chain arbitrarily the package macros, and the new ones will be completely expandable and usable one within the other. -\begin{framed} - {\color{niceone}New with |1.06|}: those macro arguments which are +Release |1.07| has the \csb{xintNewExpr} command\MyMarginNote{New with + |1.07|} which automatizes the creation of such expandable macros: +\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. -\end{framed} + |\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} -The arguments to most of the \xintname macros are of three types: +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 +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). + + +The numeric arguments to the bundle macros may be of various types, +extending in generality: + \begin{enumerate} \item `short' integers, \emph{i.e.} less than (or equal to) in absolute value \np{\xintiSub{\xintiPow {2}{31}}1}. I will refer to this as the `\TeX{}' or @@ -847,9 +978,9 @@ The arguments to most of the \xintname macros are of three types: 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 - macros. + macro. \item `long' integers, which are the bread and butter of the package commands. - They are signed integers with a practically illimited number of digits. + 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&). Some macros, such as addition when \xintfracname has not been loaded, do not @@ -860,7 +991,12 @@ The arguments to most of the \xintname macros are of three types: longish operation. \item `fractions': they become available after having loaded the \xintfracname package. Their format on input will be described next, a fraction has a - numerator, a forward slash and then a denominator. + numerator, a forward slash and then a denominator.\MyMarginNote{New with + |1.07|} It is now possible to use scientific notation, with a lowercase + |e| on input (an uppercase |E| is accepted inside the |\xintexpr|-essions). + The decimal mark must be a dot and not a comma. No separator for thousands + should be used on inputs, and except within |\xintexpr|-essions, spaces + should be avoided. \end{enumerate} \begin{framed} @@ -869,9 +1005,10 @@ The arguments to most of the \xintname macros are of three types: 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}\llap{\strut\small NEW WITH |1.06|\ - $\to$\kern\parindent - }}}\vskip\dp\strutbox } are allowed in arguments intrinsically + \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. \end{framed} @@ -879,16 +1016,12 @@ The arguments to most of the \xintname macros are of three types: \edef\z {\xintAdd {+--0367.8920280/-++278.289287}{-109.2882/+270.12898}} -The package macros first operate a `full' expansion\vadjust{\vskip-\dp\strutbox - \hbox{\smash{\color{niceone}\llap{\strut\small NEW WITH |1.06|\ $\to$\ - }}}\vskip\dp\strutbox } of their \strut{} arguments, as -explained above: only the first token is repeatedly expanded until no more is -possible. + The package macros first operate a `full' expansion\MyMarginNote{New with + |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\strut{} a \emph{complete one }\vadjust{\vskip-\dp\strutbox - \hbox{\smash{\color{niceone}\llap{\strut\small NEW WITH |1.06|\ $\to$\ - }}}\vskip\dp\strutbox } for those arguments which +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. @@ -905,7 +1038,7 @@ The allowed input formats for `long numbers' and `fractions' are: {+-+-+----++-++----0000000009876543210}}}% Note that |-0| is not legal input and will confuse \xintname (but not \csa{xintNum} which even accepts an empty input). -\item the relaxed format is when \xintfracname is loaded. Most macros are then +\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 @@ -918,6 +1051,12 @@ The allowed input formats for `long numbers' and `fractions' are: 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}}} \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 @@ -929,22 +1068,34 @@ 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}=|{\xintPow{-.3/+.7}{11}}}% +\centeredline{|\xintPow{-.3/.7}{11}=|\texttt{\xintPow{-.3/+.7}{11}}}% +\centeredline{|\xinttheexpr (-.3/.7)^11\relax=|\texttt{\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. Or one may have just one macro |\C| which +the numerators and denominators (thus, possibly with a `scientific' exponent +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. +expansion of |\A| and |245|. But, as explained already |123\A| is a no-go, +\emph{except inside an |\string\xintexpr|-ession of course}! +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}}} +\medskip Loading \xintfracname not only relaxes the format of the inputs; it also -modifies the format of the outputs: except when filtered through the -\csb{xintIrr} (and \csb{xintJrr}) or \csb{xintRaw} macros, a fraction is always -output in the |A/B[n]| form (which stands for &(A/B)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. +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. A macro \csb{xintFrac} is provided for the typesetting (math-mode only) of such a `raw' output. Of course, the @@ -952,9 +1103,8 @@ 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,\strut{}\vadjust{\vskip-\dp\strutbox - \hbox{\smash{\color{niceone}\llap{\strut\small IMPORTANT!\ $\to$\ - }}}\vskip\dp\strutbox } NEITHER the numerator NOR +|289072|, or |\A| if |\A| expands to |3[-4]|. However,\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). @@ -970,24 +1120,24 @@ 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 do not make the package switch to a (currently - non-existent) `floating-point' mode. The inputs, however long, are always - converted into an exact internal representation. + 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. \end{framed} -Generally speaking, there should be no spaces among the digits in the inputs. +Generally speaking, there should be no spaces among the digits in the inputs +(in arguments to the package macros). Although most would be harmless in most macros, there are some cases where spaces could break havoc. So the best is to avoid them entirely. -\edef\z {\xintSub {\xintMul {2.3}{\xintPow {5.6}{3}}} {17728/189.5}} - -It would certainly be nice to be able to input directly expressions such as -|2.3*5.6^3-17728/189.5|, but this is not possible. One must use, for -example: - \centeredline{|\xintSub {\xintMul {2.3}{\xintPow - {5.6}{3}}} {17728/189.5}|} or, an option in this case is: -\centeredline{|\xintAdd {\xintPrd {{2.3}{5.6}{5.6}{5.6}}}{-17728/189.5}|}% -%\centeredline{\texttt{=\z =\xintIrr\z =\xintTrunc {15}\z\dots}} +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 +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 @@ -1001,7 +1151,8 @@ this is not provided by the package. Arguments must be either within braces or a single control sequence. Note that |-| and |+| may serve only as unary operators, on \emph{explicit} -numbers. They can not serve to prefix macros evaluating to such numbers. +numbers. They can not serve to prefix macros evaluating to such numbers, +\emph{except inside an |\string\xintexpr|-ession.} \section{More on fractions} @@ -1037,9 +1188,12 @@ versions. They have less parsing overhead. -The macro \csb{xintRaw} prints the fraction in |A/B| form, the former trailing -|[n]| having been converted into explicit zeros either at the numerator or the -denominator. The |B| is printed even if it has value |1|. +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 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|. Conversely (sort of), the macro \csb{xintREZ} puts all powers of ten into the |[n]| (REZ stands for remove zeros). @@ -1113,11 +1267,12 @@ fraction an exact computation would have produced. 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{|(\xintTrunc {30}{\xintPow -% {1.01}{100}}=|\texttt{\xintTrunc {30}\z)}} \centeredline{|\xintiTrunc {0}{\xintPow{0.123}{-10}}=|\texttt{\xintiTrunc {0}{\xintPow{0.123}{-10}}}} +See also the documentation of \csb{xintRound}, \csb{xintiRound} and +\csb{xintFloat}. + \section{\csh{ifcase}, \csh{ifnum}, ... constructs} When using things such as |\ifcase \xintSgn{\A}| one has to leave @@ -1137,6 +1292,12 @@ 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. + + \section{Multiple outputs}\label{sec:outputs} Some macros have an output consisting of more than one number, each one is then @@ -1341,7 +1502,7 @@ control sequence is the message. The error is raised \emph{before} the end of the expansion so as to not disturb further processing of the token stream, after completion of the operation. Generally the problematic operation will output a zero. Possible such error message control -sequences: +sequences: \dverb|& \xintError:ArrayIndexIsNegative \xintError:ArrayIndexBeyondLimit @@ -1355,6 +1516,10 @@ sequences: \xintError:TooBigDecimalShift \xintError:TooBigDecimalSplit \xintError:NoBezoutForZeros +\xintError:ignored +\xintError:removed +\xintError:use_xintthe! +\xintError:inserted | \section{Common input errors when using the package macros} @@ -1364,49 +1529,58 @@ 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|. +\item using |-| to prefix some macro: |-\xintiSqr{35}/271|.\footnote{this 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 loading \xintfracname and using expressions previously producing integers - as numerators - or denominators: |\edef\x{\xintMul {3}{5}/\xintMul{7}{9}}|. The problem is - that 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. +\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 + 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. \end{itemize} \section{Package namespace} -Inner macros of \xintname, \xintgcdname, \xintfracname, \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.} 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, \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} \dverb|& Usage with LaTeX: \usepackage{xint} - \usepackage{xintgcd} % (loads xint) \usepackage{xintfrac} % (loads xint) + \usepackage{xintexpr} % (loads xintfrac) + + \usepackage{xintgcd} % (loads xint) \usepackage{xintseries} % (loads xintfrac) \usepackage{xintcfrac} % (loads xintfrac) Usage with TeX: \input xint.sty\relax - \input xintgcd.sty\relax % (loads xint) \input xintfrac.sty\relax % (loads xint) + \input xintexpr.sty\relax % (loads xintfrac) + + \input xintgcd.sty\relax % (loads xint) \input xintseries.sty\relax % (loads xintfrac) \input xintcfrac.sty\relax % (loads xintfrac) | @@ -1418,10 +1592,11 @@ 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 previous loading of \xintname, and will try to load it if this was -not already done. Similarly \xintseriesname and \xintcfracname do the -necessary loading of \xintfracname. +Furthermore, the packages \xintgcdname and \xintfracname will 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 +loaded twice. Also inspired from the \textsc{Heiko Oberdiek} packages we have included a complete catcode protection mecanism. The packages may be loaded in @@ -1431,12 +1606,18 @@ escape character, digits have category code other and letters have category code letter. Nothing else is assumed, and the previous configuration is restored after the loading of each one of the packages. -This is for the loading of the packages. For the actual use of the +This is for the loading of the packages. + +For the actual use of the macros, note that when feeding them with negative numbers the minus sign must have category code other, as is standard. Similarly the slash used for inputting fractions must be of category other, as usual. And the square brackets also must be of category code other, if used on -input. +input. The `e' of the scientific notation must be of category code letter. +All of that is relaxed when inside an +|\xintexpr|-ession (but arguments to macros which have been inserted in +the expression must obey the rules, as it is the macro and not the parser which +will get the tokens). In an |\xintexpr|-ession, the scientific `e' may be `E'. The components of the \xintname bundle presuppose that the usual \csa{space} and \csa{empty} macros are pre-defined, which is the case in @@ -1455,25 +1636,27 @@ compatible. \csa{xintTypesetBezoutAlgorithm} also uses the \dverb+& Run tex or latex on xint.dtx. -This will extract the style files xint.sty, xintgcd.sty, xintfrac.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 understand -\NeedsTeXFormat, but the style files will already have been extracted -by that time. +This will extract the style files xint.sty, xintfrac.sty, xintexpr.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 +understand \NeedsTeXFormat, but the style files will already have been +extracted by that time. Alternatively, run tex or latex on xint.ins if available. To get xint.pdf run pdflatex thrice on xint.dtx xint.sty | + xintfrac.sty | + xintexpr.sty | --> TDS:tex/generic/xint/ xintgcd.sty | - xintfrac.sty | --> TDS:tex/generic/xint/ xintseries.sty | xintcfrac.sty | xint.dtx --> TDS:source/generic/xint/ xint.pdf --> TDS:doc/generic/xint/ - + It may be necessary to then refresh the TeX installation filename database. + @@ -1617,8 +1800,8 @@ contiguous spaces are collapsed by the \TeX{} scanning into single spaces. }->|\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} -% The macro \csa{xintCSVtoListNoExpand} does the same job without the initial -% expansion. +The macro \csa{xintCSVtoListNoExpand} does the same job without the initial +expansion. \subsection{\csbh{xintNthElt}}\label{xintNthElt} @@ -1646,9 +1829,9 @@ future versions. \centeredline{|\xintNthElt {7}{\xintCSVtoList \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}}}} -% The macro -% \csa{xintNthEltNoExpand} does the same job without first expanding its -% second argument. +The macro +\csa{xintNthEltNoExpand} does the same job without first expanding its +second argument. \subsection{\csbh{xintListWithSep}}\label{xintListWithSep} @@ -1668,8 +1851,8 @@ top-level braced material constituting the \meta{list}. \centeredline{|\xintListWithSep{:}{\xintFac {20}}=|\texttt{\xintListWithSep{:}{\xintFac {20}}}} -% The macro \csa{xintListWithSepNoExpand} does the same -% job without the initial expansion. +The macro \csa{xintListWithSepNoExpand} does the same +job without the initial expansion. \subsection{\csbh{xintApply}}\label{xintApply} @@ -1693,9 +1876,9 @@ 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}}}} -% The macro -% \csa{xintApplyNoExpand} does the same job without the first initial expansion -% which gave the \meta{list} of braced tokens to which |\macro| is applied. +The macro +\csa{xintApplyNoExpand} does the same job without the first initial expansion +which gave the \meta{list} of braced tokens to which |\macro| is applied. \subsection{\csbh{xintApplyUnbraced}}\label{xintApplyUnbraced} @@ -1717,10 +1900,10 @@ $ $ $ $ \def\macro #1{\expandafter\def\csname myself#1\endcsname {#1}}$\ $null$ $ $ $ \xintApplyUnbraced\macro{{elta}{eltb}{eltc}}$\ $null$ $ $ $ \meaning\myselfelta:$ $ $meaning$myselfelta | -% The macro \csa{xintApplyUnbracedNoExpand} does the same job without the first -% initial expansion which gave the \meta{list} of braced tokens to which -% |\macro| -% is applied. +The macro \csa{xintApplyUnbracedNoExpand} does the same job without the first +initial expansion which gave the \meta{list} of braced tokens to which +|\macro| +is applied. \subsection{\csbh{xintAssign}}\label{xintAssign} @@ -1804,6 +1987,54 @@ division of the numerator by the denominator. \csa{xintSgn\n} returns 1 if the number is positive, 0 if it is zero and -1 if it is negative. Extended by \xintfracname to fractions. +\subsection{\csbh{xintSgnFork}}\label{xintSgnFork} +{\small New with release |1.07|.\par} + +\csa{xintSgnFork}\verb+{-1|0|1}+\marg{A}\marg{B}\marg{C} expandably +chooses to execute either the \meta{A}, \meta{B} or \meta{C} code, +depending on its first argument. This first argument should be anything +expanding to either |-1|, |0| or |1| (a count register should be +prefixed by |\the| and a |\numexpr...\relax| also should be prefixed by +|\the|). This utility is provided to help construct expandable macros +choosing depending on a condition which one of the package macros to +use, or which values to confer to their arguments. +\dverb(& +\def\myfunction #1% +% expands to |x+1| if x < -1, x-1 if x > 1, else 1 - x^2 +% rounded to two decimal places + {\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}}} +( + +\def\myfunction #1% + {\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}}} + +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 }}% +( + +\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 }}% + +\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|. \subsection{\csbh{xintOpp}}\label{xintiOpp} @@ -1831,11 +2062,12 @@ by \xintfracname to fractions. \csa{xintCmp\n\m} returns 1 if |N>M|, 0 if |N=M|, and -1 if |N0 @@ -4807,14 +5739,14 @@ first place. % expanded. Introduced with release 1.04| % \begin{macrocode} \def\xintApply {\romannumeral0\xintapply }% -% \def\xintApplyNoExpand {\romannumeral0\xintapplynoexpand }% +\def\xintApplyNoExpand {\romannumeral0\xintapplynoexpand }% \def\xintapply #1#2% {% \expandafter\XINT_apply\expandafter {\romannumeral-`0#2}% {#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{\romannumeral0\XINT_apply_loop_a {}{#1}#2\Z }% \def\XINT_apply_loop_a #1#2#3% {% \xint_gob_til_z #3\XINT_apply_end\Z @@ -4833,15 +5765,15 @@ first place. % having to do \gdef. The list is first expanded. Introduced with release 1.06b| % \begin{macrocode} \def\xintApplyUnbraced {\romannumeral0\xintapplyunbraced }% -% \def\xintApplyUnbracedNoExpand {\romannumeral0\xintapplyunbracednoexpand }% +\def\xintApplyUnbracedNoExpand {\romannumeral0\xintapplyunbracednoexpand }% \def\xintapplyunbraced #1#2% {% \expandafter\XINT_applyunbr\expandafter {\romannumeral-`0#2}% {#1}% }% \def\XINT_applyunbr #1#2{\XINT_applyunbr_loop_a {}{#2}#1\Z }% -% \def\xintapplyunbracednoexpand #1#2% -% {\romannumeral0\XINT_applyunbr_loop_a {}{#1}#2\Z }% +\def\xintapplyunbracednoexpand #1#2% + {\romannumeral0\XINT_applyunbr_loop_a {}{#1}#2\Z }% \def\XINT_applyunbr_loop_a #1#2#3% {% \xint_gob_til_z #3\XINT_applyunbr_end\Z @@ -5162,6 +6094,21 @@ first place. \krof }% % \end{macrocode} +% \subsection{\csh{xintSgnFork}} +% \lverb|& +% Expandable three-way fork added in 1.07. It is not used in the code but is +% provided for use inside the arguments to the package macros. The argument #1 +% must expand to -1,0 or 1. A \count should be put within a \numexpr..\relax.| +% \begin{macrocode} +\def\xintSgnFork {\romannumeral0\xintsgnfork }% +\def\xintsgnfork #1% +{% + \ifcase #1 \xint_afterfi{\expandafter\space\xint_secondofthree}% + \or\xint_afterfi{\expandafter\space\xint_thirdofthree}% + \else\xint_afterfi{\expandafter\space\xint_firstofthree}% + \fi +}% +% \end{macrocode} % \subsection{\csh{xintOpp}} % \begin{macrocode} \def\xintiOpp {\romannumeral0\xintiopp }% @@ -6888,7 +7835,7 @@ first place. % With release 1.05, rather than using \XINT_Length I opt finally for direct use % of \numexpr (which will throw a suitable number too big message), and to raise % the \xintError:$\ FactorialOfTooBigNumber for argument larger than 1000000 -% (rather than 1000000000). | +% (rather than 1000000000).| % \begin{macrocode} \def\xintFac {\romannumeral0\xintfac }% \def\xintfac #1% @@ -8031,7 +8978,16 @@ first place. % % Release 1.06 has a faster and more compactly coded \XINT_dsx_zeroloop. % Also, x is now given to a \numexpr. The earlier code should be then -% simplified, but I leave as is for the time being.+ +% simplified, but I leave as is for the time being. +% +% In 1.07, I decide to modify +% the coding of \XINT_dsx_zeroloop, to avoid +% impacting the input stack (which prevented doing truncation or rounding or +% float with more than eight times the size of input stack; 40000 = 8x5000 +% digits on my installation.) I think this was the only place in the code with +% such non tail recursion, as I recall being careful to avoid problems within +% the Factorial and Power routines, but I would need to check. Too tired now +% after having finished \xintexpr, \xintNewExpr, and \xintfloatexpr!+ % \begin{macrocode} \def\xintDSx {\romannumeral0\xintdsx }% \def\xintdsx #1#2% @@ -8060,7 +9016,7 @@ first place. \def\XINT_dsx_xisNeg_checkA_ #1#2\Z #3% {% \xint_gob_til_zero #1\XINT_dsx_xisNeg_Azero 0% - \XINT_dsx_xisNeg_checkx {#3}{#3}\Z {#1#2}% + \XINT_dsx_xisNeg_checkx {#3}{#3}{}\Z {#1#2}% }% \def\XINT_dsx_xisNeg_Azero #1\Z #2{ 0}% \def\XINT_dsx_xisNeg_checkx #1% @@ -8068,25 +9024,25 @@ first place. \ifnum #1>999999999 \xint_afterfi {\xintError:TooBigDecimalShift - \expandafter\space\expandafter 0\xint_gobble_iii }% + \expandafter\space\expandafter 0\xint_gobble_iv }% \else - \expandafter \XINT_dsx_zeroloop + \expandafter \XINT_dsx_zeroloop \fi }% -\def\XINT_dsx_zeroloop #1% +\def\XINT_dsx_zeroloop #1#2% {% \ifnum #1<9 \XINT_dsx_exita\fi \expandafter\XINT_dsx_zeroloop\expandafter - {\the\numexpr #1-8}00000000% + {\the\numexpr #1-8}{#200000000}% }% \def\XINT_dsx_exita\fi\expandafter\XINT_dsx_zeroloop {% \fi\expandafter\XINT_dsx_exitb }% -\def\XINT_dsx_exitb #1% +\def\XINT_dsx_exitb #1#2% {% \expandafter\expandafter\expandafter - \XINT_dsx_addzeros\csname xint_gobble_\romannumeral -#1\endcsname + \XINT_dsx_addzeros\csname xint_gobble_\romannumeral -#1\endcsname #2% }% \def\XINT_dsx_addzeros #1\Z #2{ #2#1}% \def\XINT_dsx_xisPos #1\Z #2% @@ -8496,7 +9452,7 @@ first place. \fi \expandafter\x\csname ver@xintgcd.sty\endcsname \ProvidesPackage{xintgcd}% - [2013/05/14 v1.06b Euclide algorithm with xint package (jfB)]% + [2013/05/26 v1.07a Euclide algorithm with xint package (jfB)]% % \end{macrocode} % \subsection{\csh{xintGCD}} % \begin{macrocode} @@ -9205,7 +10161,7 @@ first place. \fi \expandafter\x\csname ver@xintfrac.sty\endcsname \ProvidesPackage{xintfrac}% - [2013/05/14 v1.06b Expandable operations on fractions (jfB)]% + [2013/05/26 v1.07a Expandable operations on fractions (jfB)]% % \end{macrocode} % \subsection{\csh{xintLen}} % \begin{macrocode} @@ -9225,7 +10181,7 @@ first place. % 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, -% \xintJrr, \xintRaw)| +% \xintJrr, \xintRawWithZeros)| % \begin{macrocode} \def\XINT_outfrac #1#2#3% {% @@ -9258,6 +10214,8 @@ first place. }% % \end{macrocode} % \subsection{\csh{XINT\_inFrac}} +% \lverb|Extended in 1.07 to accept scientific notation on input. With lowercase +% e only. The \xintexpr parser does accept uppercase E also.| % \begin{macrocode} \def\XINT_inFrac {\romannumeral0\XINT_infrac }% \def\XINT_infrac #1% @@ -9294,37 +10252,60 @@ first place. \def\XINT_infrac_Zero #1\T { {0}{0}{1}}% % \end{macrocode} % \subsection{\csh{XINT\_frac}} +% \lverb|Extended in 1.07 to recognize and accept scientific notation both at +% the numerator and (possible) denominator. Only a lowercase e will do here, but +% uppercase E is possible within an \xintexpr..\relax | % \begin{macrocode} \def\XINT_frac #1/#2#3\Z {% \xint_UDwfork #2\dummy \XINT_frac_A - \W\dummy {\expandafter\XINT_frac_B \romannumeral-`0#2}% + \W\dummy {\expandafter\XINT_frac_U \romannumeral-`0#2}% + \krof + #3e\W\Z #1e\W\Z +}% +\def\XINT_frac_U #1e#2#3\Z +{% + \xint_UDwfork + #2\dummy \XINT_frac_Ua + \W\dummy {\XINT_frac_Ub #2}% \krof - #3.\W\Z #1.\W\Z + #3\Z #1\Z }% +\def\XINT_frac_Ua \Z #1/\W\Z {\XINT_frac_B #1.\W\Z {0}}% +\def\XINT_frac_Ub #1/\W e\W\Z #2\Z {\XINT_frac_B #2.\W\Z {#1}}% \def\XINT_frac_B #1.#2#3\Z {% \xint_UDwfork - #2\dummy \XINT_frac_Ba + #2\dummy \XINT_frac_Ba \W\dummy {\XINT_frac_Bb #2}% \krof #3\Z #1\Z }% -\def\XINT_frac_Bb #1/\W.\W\Z #2\Z +\def\XINT_frac_Ba \Z #1\Z {\XINT_frac_T {0}{#1}}% +\def\XINT_frac_Bb #1.\W\Z #2\Z {% - \expandafter \XINT_frac_C \expandafter + \expandafter \XINT_frac_T \expandafter {\romannumeral0\XINT_length {#1}}{#2#1}% }% -\def\XINT_frac_Ba \Z #1/\W\Z {\XINT_frac_C {0}{#1}}% -\def\XINT_frac_A .\W\Z {\XINT_frac_C {0}{1}}% -\def\XINT_frac_C #1#2#3.#4#5\Z +\def\XINT_frac_A e\W\Z {\XINT_frac_T {0}{1}{0}}% +\def\XINT_frac_T #1#2#3#4e#5#6\Z +{% + \xint_UDwfork + #5\dummy \XINT_frac_Ta + \W\dummy {\XINT_frac_Tb #5}% + \krof + #6\Z #4\Z {#1}{#2}{#3}% +}% +\def\XINT_frac_Ta \Z #1\Z {\XINT_frac_C #1.\W\Z {0}}% +\def\XINT_frac_Tb #1e\W\Z #2\Z {\XINT_frac_C #2.\W\Z {#1}}% +\def\XINT_frac_C #1.#2#3\Z {% \xint_UDwfork - #4\dummy \XINT_frac_Ca - \W\dummy {\XINT_frac_Cb #4}% + #2\dummy \XINT_frac_Ca + \W\dummy {\XINT_frac_Cb #2}% \krof - #5\Z #3\Z {#1}{#2}% + #3\Z #1\Z }% \def\XINT_frac_Ca \Z #1\Z {\XINT_frac_D {0}{#1}}% \def\XINT_frac_Cb #1.\W\Z #2\Z @@ -9332,14 +10313,14 @@ first place. \expandafter\XINT_frac_D\expandafter {\romannumeral0\XINT_length {#1}}{#2#1}% }% -\def\XINT_frac_D #1#2#3#4% +\def\XINT_frac_D #1#2#3#4#5#6% {% \expandafter \XINT_frac_E \expandafter - {\the\numexpr -#1+#3\expandafter}\expandafter + {\the\numexpr -#1+#3+#4-#6\expandafter}\expandafter {\romannumeral0\XINT_num_loop #2% \xint_relax\xint_relax\xint_relax\xint_relax \xint_relax\xint_relax\xint_relax\xint_relax\Z }% - {\romannumeral0\XINT_num_loop #4% + {\romannumeral0\XINT_num_loop #5% \xint_relax\xint_relax\xint_relax\xint_relax \xint_relax\xint_relax\xint_relax\xint_relax\Z }% }% @@ -9463,27 +10444,42 @@ first place. }% % \end{macrocode} % \subsection{\csh{xintRaw}} +% \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.| % \begin{macrocode} \def\xintRaw {\romannumeral0\xintraw }% -\def\xintraw +\def\xintraw {% \expandafter\XINT_raw\romannumeral0\XINT_infrac }% -\def\XINT_raw #1% +\def\XINT_raw #1#2#3{ #2/#3[#1]}% +% \end{macrocode} +% \subsection{\csh{xintRawWithZeros}} +% \lverb|& +% This was called \xintRaw in versions earlier than 1.07| +% \begin{macrocode} +\def\xintRawWithZeros {\romannumeral0\xintrawwithzeros }% +\def\xintrawwithzeros +{% + \expandafter\XINT_rawz\romannumeral0\XINT_infrac +}% +\def\XINT_rawz #1% {% \ifcase\XINT_Sgn {#1} - \expandafter\XINT_raw_Ba + \expandafter\XINT_rawz_Ba \or - \expandafter\XINT_raw_A + \expandafter\XINT_rawz_A \else - \expandafter\XINT_raw_Ba + \expandafter\XINT_rawz_Ba \fi {#1}% }% -\def\XINT_raw_A #1#2#3{\xint_dsh {#2}{-#1}/#3}% -\def\XINT_raw_Ba #1#2#3{\expandafter\XINT_raw_Bb +\def\XINT_rawz_A #1#2#3{\xint_dsh {#2}{-#1}/#3}% +\def\XINT_rawz_Ba #1#2#3{\expandafter\XINT_rawz_Bb \expandafter{\romannumeral0\xint_dsh {#3}{#1}}{#2}}% -\def\XINT_raw_Bb #1#2{ #2/#1}% +\def\XINT_rawz_Bb #1#2{ #2/#1}% % \end{macrocode} % \subsection{\csh{xintNumerator}} % \begin{macrocode} @@ -9677,16 +10673,42 @@ first place. }% \def\XINT_rez_E #1#2#3{ #3/#2[#1]}% % \end{macrocode} +% \subsection{\csh{xintE}} +% \lverb|added with with 1.07, together with support for `floats'. The fraction +% comes first here, contrarily to \xintTrunc and \xintRound.| +% \begin{macrocode} +\def\xintE {\romannumeral0\xinte }% +\def\xinte #1% +{% + \expandafter\XINT_e \romannumeral0\XINT_infrac {#1}% +}% +\def\XINT_e #1#2#3#4% +{% + \expandafter\XINT_e_end\expandafter{\the\numexpr #1+#4}{#2}{#3}% +}% +\def\xintfE {\romannumeral0\xintfe }% +\def\xintfe #1% +{% + \expandafter\XINT_fe \romannumeral0\XINT_infrac {#1}% +}% +\def\XINT_fe #1#2#3#4% +{% + \expandafter\XINT_e_end\expandafter{\the\numexpr #1+\xintNum{#4}}{#2}{#3}% +}% +\def\XINT_e_end #1#2#3{ #2/#3[#1]}% +\let\XINTinFloatfE\xintfE +% \end{macrocode} % \subsection{\csh{xintIrr}} % \lverb|& % 1.04 fixes a buggy \xintIrr {0}. -% 1.05 modifies the initial parsing and post-processing to use \xintraw and to +% 1.05 modifies the initial parsing and post-processing to use \xintrawwithzeros +% and to % more quickly deal with an input denominator equal to 1.| % \begin{macrocode} \def\xintIrr {\romannumeral0\xintirr }% \def\xintirr #1% {% - \expandafter\XINT_irr_start\romannumeral0\xintraw {#1}\Z + \expandafter\XINT_irr_start\romannumeral0\xintrawwithzeros {#1}\Z }% \def\XINT_irr_start #1#2/#3\Z {% @@ -9756,7 +10778,8 @@ first place. % \xintIrr, but raising an error when the input does not evaluate to an integer. % Usable with not too much overhead on integer input as \xintIrr % checks quickly for a denominator equal to 1 (which will be put there by the -% \XINT_infrac called by \xintraw). This way, macros such as \xintQuo can be +% \XINT_infrac called by \xintrawwithzeros). This way, macros such as \xintQuo +% can be % modified with minimal overhead to accept fractional input as long as it % evaluates to an integer. | % \begin{macrocode} @@ -9769,6 +10792,18 @@ first place. \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}}% +}% +% \end{macrocode} % \subsection{\csh{xintJrr}} % \lverb|& % Modified similarly as \xintIrr in release 1.05| @@ -9776,7 +10811,7 @@ first place. \def\xintJrr {\romannumeral0\xintjrr }% \def\xintjrr #1% {% - \expandafter\XINT_jrr_start\romannumeral0\xintraw {#1}\Z + \expandafter\XINT_jrr_start\romannumeral0\xintrawwithzeros {#1}\Z }% \def\XINT_jrr_start #1#2/#3\Z {% @@ -9838,7 +10873,7 @@ first place. % \end{macrocode} % \subsection{\csh{xintTrunc}, \csh{xintiTrunc}} % \lverb|& -% Modified in 1.06 to give the first argument to a \numexpr| +% Modified in 1.06 to give the first argument to a \numexpr.| % \begin{macrocode} \def\xintTrunc {\romannumeral0\xinttrunc }% \def\xintiTrunc {\romannumeral0\xintitrunc }% @@ -9938,12 +10973,12 @@ first place. \def\XINT_trunc_Hb #1#2#3% {% \expandafter #3\expandafter0\expandafter.% - \romannumeral0\XINT_dsx_zeroloop {#1}\Z {}#2% #1=-0 possible! + \romannumeral0\XINT_dsx_zeroloop {#1}{}\Z {}#2% #1=-0 possible! }% % \end{macrocode} % \subsection{\csh{xintRound}, \csh{xintiRound}} % \lverb|& -% Modified in 1.06 to give the first argument to a \numexpr| +% Modified in 1.06 to give the first argument to a \numexpr.| % \begin{macrocode} \def\xintRound {\romannumeral0\xintround }% \def\xintiRound {\romannumeral0\xintiround }% @@ -10010,15 +11045,259 @@ first place. \XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z \Z }% % \end{macrocode} -% \subsection{\csh{xintAdd}} +% \subsection{\csh{xintDigits}} % \begin{macrocode} -\def\xintAdd {\romannumeral0\xintadd }% -\def\xintadd #1% +\mathchardef\XINT_digits 16 +\def\xintDigits #1#2% + {\afterassignment \xint_gobble_i \mathchardef\XINT_digits=}% +\def\xinttheDigits {\number\XINT_digits }% +% \end{macrocode} +% \subsection{\csh{xintFloat}} +% \begin{macrocode} +\def\xintFloat {\romannumeral0\xintfloat }% +\def\xintfloat #1{\XINT_float_chkopt #1\Z }% +\def\XINT_float_chkopt #1% {% - \expandafter\xint_fadd\expandafter {\romannumeral0\XINT_infrac {#1}}% + \ifx #1[\expandafter\XINT_float_opt + \else\expandafter\XINT_float_noopt + \fi #1% }% -\def\xint_fadd #1#2{\expandafter\XINT_fadd_A\romannumeral0\XINT_infrac{#2}#1}% -\def\XINT_fadd_A #1#2#3#4% +\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}% +}% +\def\XINT_float_a #1#2% +{% + \expandafter\XINT_float_b \romannumeral0\XINT_infrac {#2}{#1}% +}% +\def\XINT_float_b #1#2#3% +{% + \XINT_float_fork #2\Z {#3}{#1}% +}% +\def\XINT_float_fork #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_float_zero + 0#1\dummy \XINT_float_N + 0-\dummy {\XINT_float_P #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 +{% + \expandafter\XINT_float_atleastone_c\romannumeral0\XINT_trunc_B +}% +\def\XINT_float_atleastone_c #1\Z #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}% +}% +\def\XINT_float_lessthanone_b #1#2#3% +{% + \expandafter\XINT_float_lessthanone_c + \romannumeral0\XINT_trunc_B {#1}{#3}{#2}% +}% +\def\XINT_float_lessthanone_c #1\Z #2% +{% + \expandafter\XINT_float_c\expandafter + {\expandafter-\romannumeral0\xintilen {\xintiSub {#1}{1}}}% +}% +\def\XINT_float_c #1#2#3#4% +{% + \expandafter\XINT_float_d\expandafter + {\the\numexpr #2-#1}{#3}{#4}e#1% +}% +\def\XINT_float_d +{% + \expandafter\XINT_float_round_B\romannumeral0\XINT_trunc_B +}% +\def\XINT_float_round_B #1#2\Z #3% +{% + \ifnum #1=9 + \xint_afterfi + {\romannumeral0\XINT_rord_main {}#1#2\XINT_float_round_S}% + \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 +}% +\def\XINT_float_round_D #1% +{% + \ifnum #1<5 + \expandafter\XINT_float_round_Da + \else + \expandafter\XINT_float_round_Db + \fi +}% +\def\XINT_float_round_Da #1\Z +{% + \expandafter\XINT_float_round_f + \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_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 +}% +\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 +}% +\def\XINT_float_round_g #1% +{% + \ifnum #1=1 \expandafter\XINT_float_round_h\fi + \space #1.% +}% +\def\XINT_float_round_h\space 1.0{ 10.}% +% \end{macrocode} +% \subsection{\csh{XINT\_inFloat}} +% \begin{macrocode} +\def\XINT_inFloat [#1]% +{% + \expandafter\XINT_infloat\expandafter {\the\numexpr #1}% +}% +\def\XINT_infloat #1#2% +{% + \expandafter\XINT_infloat_a \romannumeral0\XINT_infrac {#2}{#1}% +}% +\def\XINT_infloat_a #1#2#3% +{% + \XINT_infloat_fork #2\Z {#3}{#1}% +}% +\def\XINT_infloat_fork #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_infloat_zero + 0#1\dummy \XINT_infloat_N + 0-\dummy {\XINT_infloat_P #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% +{% + \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}% +}% +\def\XINT_infloat_d +{% + \expandafter\XINT_infloat_round_B\romannumeral0\XINT_trunc_B +}% +\def\XINT_infloat_round_B #1\Z #2% +{% + \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 +}% +\def\XINT_infloat_round_D #1% +{% + \ifnum #1<5 + \expandafter\XINT_infloat_round_Da + \else + \expandafter\XINT_infloat_round_Db + \fi +}% +\def\XINT_infloat_round_Da #1\Z +{% + \expandafter\XINT_infloat_round_f + \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 +}% +\def\XINT_infloat_round_Db #1\Z +{% + \expandafter\XINT_infloat_round_f + \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z \Z +}% +\def\XINT_infloat_round_f #1\Z #2#3% +{% + \expandafter\XINT_infloat_round_g\expandafter + {\the\numexpr #2-#3+1}{#1}% +}% +\def\XINT_infloat_round_g #1#2{#2[#1]}% +% \end{macrocode} +% \subsection{\csh{xintAdd}} +% \begin{macrocode} +\def\xintAdd {\romannumeral0\xintadd }% +\def\xintadd #1% +{% + \expandafter\xint_fadd\expandafter {\romannumeral0\XINT_infrac {#1}}% +}% +\def\xint_fadd #1#2{\expandafter\XINT_fadd_A\romannumeral0\XINT_infrac{#2}#1}% +\def\XINT_fadd_A #1#2#3#4% {% \ifnum #4 > #1 \xint_afterfi {\XINT_fadd_B {#1}}% @@ -10130,19 +11409,32 @@ first place. }% \def\xint_fsqr #1{\XINT_fmul_A #1#1}% % \end{macrocode} -% \subsection{\csh{xintPow}} +% \subsection{\csh{xintPow}, \csh{xintfPow}} % \lverb|& -% Modified in 1.06 to give the exponent to a \numexpr| +% Modified in 1.06 to give the exponent to a \numexpr.$\ +% With 1.07 and 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.| % \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 {% \xint_UDzerominusfork @@ -10245,6 +11537,42 @@ first place. {\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*.| +% \begin{macrocode} +\def\xintGeq {\romannumeral0\xintgeq }% +\def\xintgeq #1% +{% + \expandafter\xint_fgeq\expandafter {\romannumeral0\XINT_infrac {#1}}% +}% +\def\xint_fgeq #1#2% +{% + \expandafter\XINT_fgeq_A \romannumeral0\XINT_infrac {#2}#1% +}% +\def\XINT_fgeq_A #1#2#3#4% +{% + \ifnum #4 > #1 + \xint_afterfi {\XINT_fgeq_B {#1}}% + \else + \xint_afterfi {\XINT_fgeq_B {#4}}% + \fi + {#1}{#4}{#2}{#3}% +}% +\def\XINT_fgeq_B #1#2#3#4#5#6#7% +{% + \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}}}% +}% +\def\XINT_fgeq_C #1#2% +{% + \expandafter\XINT_geq_fork #2\Z #1\Z +}% +% \end{macrocode} % \subsection{\csh{xintMax}} % \begin{macrocode} \def\xintMax {\romannumeral0\xintmax }% @@ -10345,18 +11673,6 @@ first place. }% \def\xint_fsgn #1#2#3{\xintisgn {#2}}% % \end{macrocode} -% \subsection{\csh{xintGeq}} -% \begin{macrocode} -\def\xintGeq {\romannumeral0\xintgeq }% -\def\xintgeq #1% -{% - \expandafter\xint_xgeq\expandafter{\romannumeral0\xintnum {#1}}% -}% -\def\xint_xgeq #1#2% -{% - \expandafter\XINT_geq_fork\romannumeral0\xintnum {#2}\Z #1\Z -}% -% \end{macrocode} % \subsection{\csh{xintDivision},~\csh{xintQuo},~\csh{xintRem}} % \begin{macrocode} \def\xintDivision {\romannumeral0\xintdivision }% @@ -10414,95 +11730,472 @@ first place. \xint_afterfi{ 0}% \fi }% -\XINT_frac_restorecatcodes_endinput% % \end{macrocode} -%\catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11 -%\let\relax -%\def<*xintseries>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12 } -% -%<*xintseries> -% \section{Package \xintseriesname 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 \xintfracname package. -% -% The method for catcodes is slightly different, but still -% directly inspired by these packages. -% +% \subsection{\csh{xintFloatAdd}} % \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@xintseries.sty\endcsname - \expandafter\let\expandafter\w\csname ver@xintfrac.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{xintseries}{\numexpr not available, aborting input}% - \aftergroup\endinput - \else - \ifx\x\relax % plain-TeX, first loading of xintseries.sty - \ifx\w\relax % but xintfrac.sty not yet loaded. - \y{xintseries}{Package xintfrac is required}% - \y{xintseries}{Will try \string\input\space xintfrac.sty}% - \def\z{\endgroup\input xintfrac.sty\relax}% - \fi - \else - \def\empty {}% - \ifx\x\empty % LaTeX, first loading, - % variable is initialized, but \ProvidesPackage not yet seen - \ifx\w\relax % xintfrac.sty not yet loaded. - \y{xintseries}{Package xintfrac is required}% - \y{xintseries}{Will try \string\RequirePackage{xintfrac}}% - \def\z{\endgroup\RequirePackage{xintfrac}}% - \fi - \else - \y{xintseries}{I was already loaded, aborting input}% - \aftergroup\endinput - \fi - \fi - \fi -\z% +\def\xintFloatAdd {\romannumeral0\xintfloatadd }% +\def\xintfloatadd #1{\XINT_fladd_chkopt \xintfloat #1\Z }% +\def\XINTinFloatAdd {\romannumeral-`0\XINTinfloatadd }% +\def\XINTinfloatadd #1{\XINT_fladd_chkopt \XINT_inFloat #1\Z }% +\def\XINT_fladd_chkopt #1#2% +{% + \ifx #2[\expandafter\XINT_fladd_opt + \else\expandafter\XINT_fladd_noopt + \fi #1#2% +}% +\def\XINT_fladd_noopt #1#2\Z #3% +{% + #1[\XINT_digits]{\XINT_FL_Add {\XINT_digits+2}{#2}{#3}}% +}% +\def\XINT_fladd_opt #1[\Z #2]#3#4% +{% + #1[#2]{\XINT_FL_Add {#2+2}{#3}{#4}}% +}% +\def\XINT_FL_Add #1#2% +{% + \expandafter\XINT_FL_Add_a\expandafter{\the\numexpr #1\expandafter}% + \expandafter{\romannumeral-`0\XINT_inFloat [#1]{#2}}% +}% +\def\XINT_FL_Add_a #1#2#3% +{% + \expandafter\XINT_FL_Add_b\romannumeral-`0\XINT_inFloat [#1]{#3}#2{#1}% +}% +\def\XINT_FL_Add_b #1% +{% + \xint_gob_til_zero #1\XINT_FL_Add_zero 0\XINT_FL_Add_c #1% +}% +\def\XINT_FL_Add_c #1[#2]#3% +{% + \xint_gob_til_zero #3\XINT_FL_Add_zerobis 0\XINT_FL_Add_d #1[#2]#3% +}% +\def\XINT_FL_Add_d #1[#2]#3[#4]#5% +{% + \xintSgnFork {\ifnum \numexpr #2-#4-#5>1 \expandafter 1% + \else\ifnum \numexpr #4-#2-#5>1 + \xint_afterfi {\expandafter-\expandafter1}% + \else \expandafter\expandafter\expandafter0% + \fi + \fi}% + {#3[#4]}{\xintAdd {#1[#2]}{#3[#4]}}{#1[#2]}% +}% +\def\XINT_FL_Add_zero 0\XINT_FL_Add_c 0[0]#1[#2]#3{#1[#2]}% +\def\XINT_FL_Add_zerobis 0\XINT_FL_Add_d #1[#2]0[0]#3{#1[#2]}% % \end{macrocode} -% \subsection{Confirmation of \xintfracname loading} +% \subsection{\csh{xintFloatSub}} % \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}}% +\def\xintFloatSub {\romannumeral0\xintfloatsub }% +\def\xintfloatsub #1{\XINT_flsub_chkopt \xintfloat #1\Z }% +\def\XINTinFloatSub {\romannumeral-`0\XINTinfloatsub }% +\def\XINTinfloatsub #1{\XINT_flsub_chkopt \XINT_inFloat #1\Z }% +\def\XINT_flsub_chkopt #1#2% +{% + \ifx #2[\expandafter\XINT_flsub_opt + \else\expandafter\XINT_flsub_noopt + \fi #1#2% +}% +\def\XINT_flsub_noopt #1#2\Z #3% +{% + #1[\XINT_digits]{\XINT_FL_Add {\XINT_digits+2}{#2}{\xintOpp{#3}}}% +}% +\def\XINT_flsub_opt #1[\Z #2]#3#4% +{% + #1[#2]{\XINT_FL_Add {#2+2}{#3}{\xintOpp{#4}}}% +}% +% \end{macrocode} +% \subsection{\csh{xintFloatMul}} +% \begin{macrocode} +\def\xintFloatMul {\romannumeral0\xintfloatmul}% +\def\xintfloatmul #1{\XINT_flmul_chkopt \xintfloat #1\Z }% +\def\XINTinFloatMul {\romannumeral-`0\XINTinfloatmul }% +\def\XINTinfloatmul #1{\XINT_flmul_chkopt \XINT_inFloat #1\Z }% +\def\XINT_flmul_chkopt #1#2% +{% + \ifx #2[\expandafter\XINT_flmul_opt + \else\expandafter\XINT_flmul_noopt + \fi #1#2% +}% +\def\XINT_flmul_noopt #1#2\Z #3% +{% + #1[\XINT_digits]{\XINT_FL_Mul {\XINT_digits+2}{#2}{#3}}% +}% +\def\XINT_flmul_opt #1[\Z #2]#3#4% +{% + #1[#2]{\XINT_FL_Mul {#2+2}{#3}{#4}}% +}% +\def\XINT_FL_Mul #1#2% +{% + \expandafter\XINT_FL_Mul_a\expandafter{\the\numexpr #1\expandafter}% + \expandafter{\romannumeral-`0\XINT_inFloat [#1]{#2}}% +}% +\def\XINT_FL_Mul_a #1#2#3% +{% + \expandafter\XINT_FL_Mul_b\romannumeral-`0\XINT_inFloat [#1]{#3}#2% +}% +\def\XINT_FL_Mul_b #1[#2]#3[#4]{\xintE{\xintiMul {#1}{#3}}{#2+#4}}% +% \end{macrocode} +% \subsection{\csh{xintFloatDiv}} +% \begin{macrocode} +\def\xintFloatDiv {\romannumeral0\xintfloatdiv}% +\def\xintfloatdiv #1{\XINT_fldiv_chkopt \xintfloat #1\Z }% +\def\XINTinFloatDiv {\romannumeral-`0\XINTinfloatdiv }% +\def\XINTinfloatdiv #1{\XINT_fldiv_chkopt \XINT_inFloat #1\Z }% +\def\XINT_fldiv_chkopt #1#2% +{% + \ifx #2[\expandafter\XINT_fldiv_opt + \else\expandafter\XINT_fldiv_noopt + \fi #1#2% +}% +\def\XINT_fldiv_noopt #1#2\Z #3% +{% + #1[\XINT_digits]{\XINT_FL_Div {\XINT_digits+2}{#2}{#3}}% +}% +\def\XINT_fldiv_opt #1[\Z #2]#3#4% +{% + #1[#2]{\XINT_FL_Div {#2+2}{#3}{#4}}% +}% +\def\XINT_FL_Div #1#2% +{% + \expandafter\XINT_FL_Div_a\expandafter{\the\numexpr #1\expandafter}% + \expandafter{\romannumeral-`0\XINT_inFloat [#1]{#2}}% +}% +\def\XINT_FL_Div_a #1#2#3% +{% + \expandafter\XINT_FL_Div_b\romannumeral-`0\XINT_inFloat [#1]{#3}#2% +}% +\def\XINT_FL_Div_b #1[#2]#3[#4]{\xintE{#3/#1}{#4-#2}}% +% \end{macrocode} +% \subsection{\csh{xintFloatPow}} +% \begin{macrocode} +\def\xintFloatPow {\romannumeral0\xintfloatpow}% +\def\xintfloatpow #1{\XINT_flpow_chkopt \xintfloat #1\Z }% +\def\XINTinFloatPow {\romannumeral-`0\XINTinfloatpow }% +\def\XINTinfloatpow #1{\XINT_flpow_chkopt \XINT_inFloat #1\Z }% +\def\XINT_flpow_chkopt #1#2% +{% + \ifx #2[\expandafter\XINT_flpow_opt + \else\expandafter\XINT_flpow_noopt + \fi + #1#2% +}% +\def\XINT_flpow_noopt #1#2\Z #3% +{% + \expandafter\XINT_flpow_checkB_start\expandafter + {\the\numexpr #3\expandafter}\expandafter + {\the\numexpr \XINT_digits}{#2}{#1[\XINT_digits]}% +}% +\def\XINT_flpow_opt #1[\Z #2]#3#4% +{% + \expandafter\XINT_flpow_checkB_start\expandafter + {\the\numexpr #4\expandafter}\expandafter + {\the\numexpr #2}{#3}{#1[#2]}% +}% +\def\XINT_flpow_checkB_start #1{\XINT_flpow_checkB_a #1\Z }% +\def\XINT_flpow_checkB_a #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_flpow_BisZero + 0#1\dummy {\XINT_flpow_checkB_b 1}% + 0-\dummy {\XINT_flpow_checkB_b 0#1}% + \krof +}% +\def\XINT_flpow_BisZero \Z #1#2#3{#3{1/1[0]}}% +\def\XINT_flpow_checkB_b #1#2\Z #3% +{% + \expandafter\XINT_flpow_checkB_c \expandafter + {\romannumeral0\XINT_length{#2}}{#3}{#2}#1% +}% +\def\XINT_flpow_checkB_c #1#2% +{% + \expandafter\XINT_flpow_checkB_d \expandafter + {\the\numexpr \expandafter\XINT_Length\expandafter + {\the\numexpr #1*20/3}+#1+#2+1}% +}% +\def\XINT_flpow_checkB_d #1#2#3#4% +{% + \expandafter \XINT_flpow_a + \romannumeral-`0\XINT_inFloat [#1]{#4}{#1}{#2}#3% +}% +\def\XINT_flpow_a #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_flpow_zero + 0#1\dummy {\XINT_flpow_b 1}% + 0-\dummy {\XINT_flpow_b 0#1}% + \krof +}% +\def\XINT_flpow_zero [#1]#2#3#4#5% +{% + \if #41 \xint_afterfi {\xintError:DivisionByZero\space 1.e2147483647}% + \else \xint_afterfi { 0.e0}\fi +}% +\def\XINT_flpow_b #1#2[#3]#4#5% +{% + \XINT_flpow_c {#4}{#5}{#2[#3]}{#1*\ifodd #5 1\else 0\fi}% +}% +\def\XINT_flpow_c #1#2#3#4% +{% + \XINT_flpow_loop {#1}{#2}{#3}{{#1}}\XINT_flpow_prd + \xint_relax + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_relax {#4}% +}% +\def\XINT_flpow_loop #1#2#3% +{% + \ifnum #2 = 1 + \expandafter\XINT_flpow_loop_end + \else + \xint_afterfi{\expandafter\XINT_flpow_loop_a + \expandafter{\the\numexpr 2*(#2/2)-#2\expandafter }% b mod 2 + \expandafter{\the\numexpr #2-#2/2\expandafter }% [b/2] + \expandafter{\romannumeral-`0\XINTinfloatmul [#1]{#3}{#3}}}% + \fi + {#1}{{#3}}% +}% +\def\XINT_flpow_loop_a #1#2#3#4% +{% + \ifnum #1 = 1 + \expandafter\XINT_flpow_loop + \else + \expandafter\XINT_flpow_loop_throwaway + \fi + {#4}{#2}{#3}% +}% +\def\XINT_flpow_loop_throwaway #1#2#3#4% +{% + \XINT_flpow_loop {#1}{#2}{#3}% +}% +\def\XINT_flpow_loop_end #1{\romannumeral0\XINT_rord_main {}\relax }% +\def\XINT_flpow_prd #1#2% +{% + \XINT_flpow_prd_getnext {#2}{#1}% +}% +\def\XINT_flpow_prd_getnext #1#2#3% +{% + \XINT_flpow_prd_checkiffinished #3\Z {#1}{#2}% +}% +\def\XINT_flpow_prd_checkiffinished #1% +{% + \xint_gob_til_relax #1\XINT_flpow_prd_end\relax + \XINT_flpow_prd_compute #1% +}% +\def\XINT_flpow_prd_compute #1\Z #2#3% +{% + \expandafter\XINT_flpow_prd_getnext\expandafter + {\romannumeral-`0\XINTinfloatmul [#3]{#1}{#2}}{#3}% +}% +\def\XINT_flpow_prd_end\relax\XINT_flpow_prd_compute + \relax\Z #1#2#3% +{% + \expandafter\XINT_flpow_conclude \the\numexpr #3\relax #1% +}% +\def\XINT_flpow_conclude #1#2[#3]#4% +{% + \expandafter\XINT_flpow_conclude_really\expandafter + {\the\numexpr\if #41 -\fi#3\expandafter}% + \xint_UDzerofork + #4\dummy {{#2}}% + 0\dummy {{1/#2}}% + \krof #1% +}% +\def\XINT_flpow_conclude_really #1#2#3#4% +{% + \xint_UDzerofork + #3\dummy {#4{#2[#1]}}% + 0\dummy {#4{-#2[#1]}}% + \krof +}% +% \end{macrocode} +% \subsection{\csh{xintFloatPower}} +% \begin{macrocode} +\def\xintFloatPower {\romannumeral0\xintfloatpower}% +\def\xintfloatpower #1{\XINT_flpower_chkopt \xintfloat #1\Z }% +\def\XINTinFloatPower {\romannumeral-`0\XINTinfloatpower}% +\def\XINTinfloatpower #1{\XINT_flpower_chkopt \XINT_inFloat #1\Z }% +\def\XINT_flpower_chkopt #1#2% +{% + \ifx #2[\expandafter\XINT_flpower_opt + \else\expandafter\XINT_flpower_noopt + \fi + #1#2% +}% +\def\XINT_flpower_noopt #1#2\Z #3% +{% + \expandafter\XINT_flpower_checkB_start\expandafter + {\the\numexpr \XINT_digits\expandafter}\expandafter + {\romannumeral0\xintnum{#3}}{#2}{#1[\XINT_digits]}% +}% +\def\XINT_flpower_opt #1[\Z #2]#3#4% +{% + \expandafter\XINT_flpower_checkB_start\expandafter + {\the\numexpr #2\expandafter}\expandafter + {\romannumeral0\xintnum{#4}}{#3}{#1[#2]}% +}% +\def\XINT_flpower_checkB_start #1#2{\XINT_flpower_checkB_a #2\Z {#1}}% +\def\XINT_flpower_checkB_a #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_flpower_BisZero + 0#1\dummy {\XINT_flpower_checkB_b 1}% + 0-\dummy {\XINT_flpower_checkB_b 0#1}% + \krof +}% +\def\XINT_flpower_BisZero \Z #1#2#3{#3{1/1[0]}}% +\def\XINT_flpower_checkB_b #1#2\Z #3% +{% + \expandafter\XINT_flpower_checkB_c \expandafter + {\romannumeral0\XINT_length{#2}}{#3}{#2}#1% +}% +\def\XINT_flpower_checkB_c #1#2% +{% + \expandafter\XINT_flpower_checkB_d \expandafter + {\the\numexpr \expandafter\XINT_Length\expandafter + {\the\numexpr #1*20/3}+#1+#2+1}% +}% +\def\XINT_flpower_checkB_d #1#2#3#4% +{% + \expandafter \XINT_flpower_a + \romannumeral-`0\XINT_inFloat [#1]{#4}{#1}{#2}#3% +}% +\def\XINT_flpower_a #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_flpower_zero + 0#1\dummy {\XINT_flpower_b 1}% + 0-\dummy {\XINT_flpower_b 0#1}% + \krof +}% +\def\XINT_flpower_zero [#1]#2#3#4#5% +{% + \if #41 + \xint_afterfi {\xintError:DivisionByZero\space 1.e2147483647}% + \else \xint_afterfi { 0.e0}\fi +}% +\def\XINT_flpower_b #1#2[#3]#4#5% +{% + \XINT_flpower_c {#4}{#5}{#2[#3]}{#1*\xintOdd {#5}}% +}% +\def\XINT_flpower_c #1#2#3#4% +{% + \XINT_flpower_loop {#1}{#2}{#3}{{#1}}\XINT_flpow_prd + \xint_relax + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_relax {#4}% +}% +\def\XINT_flpower_loop #1#2#3% +{% + \ifcase\XINT_isOne {#2} + \xint_afterfi{\expandafter\XINT_flpower_loop_x\expandafter + {\romannumeral-`0\XINTinfloatmul [#1]{#3}{#3}}% + {\romannumeral0\xintdivision {#2}{2}}}% + \or \expandafter\XINT_flpow_loop_end + \fi + {#1}{{#3}}% +}% +\def\XINT_flpower_loop_x #1#2{\expandafter\XINT_flpower_loop_a #2{#1}}% +\def\XINT_flpower_loop_a #1#2#3#4% +{% + \ifnum #2 = 1 + \expandafter\XINT_flpower_loop + \else + \expandafter\XINT_flpower_loop_throwaway + \fi + {#4}{#1}{#3}% +}% +\def\XINT_flpower_loop_throwaway #1#2#3#4% +{% + \XINT_flpower_loop {#1}{#2}{#3}% +}% +\XINT_frac_restorecatcodes_endinput% +% \end{macrocode} +%\catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11 +%\let\relax +%\def<*xintseries>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12 } +% +%<*xintseries> +% \section{Package \xintseriesname 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 \xintfracname 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@xintseries.sty\endcsname + \expandafter\let\expandafter\w\csname ver@xintfrac.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{xintseries}{\numexpr not available, aborting input}% + \aftergroup\endinput + \else + \ifx\x\relax % plain-TeX, first loading of xintseries.sty + \ifx\w\relax % but xintfrac.sty not yet loaded. + \y{xintseries}{Package xintfrac is required}% + \y{xintseries}{Will try \string\input\space xintfrac.sty}% + \def\z{\endgroup\input xintfrac.sty\relax}% + \fi + \else + \def\empty {}% + \ifx\x\empty % LaTeX, first loading, + % variable is initialized, but \ProvidesPackage not yet seen + \ifx\w\relax % xintfrac.sty not yet loaded. + \y{xintseries}{Package xintfrac is required}% + \y{xintseries}{Will try \string\RequirePackage{xintfrac}}% + \def\z{\endgroup\RequirePackage{xintfrac}}% + \fi + \else + \y{xintseries}{I was already loaded, aborting input}% + \aftergroup\endinput + \fi + \fi + \fi +\z% +% \end{macrocode} +% \subsection{Confirmation of \xintfracname 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@xintfrac.sty\endcsname @@ -10588,7 +12281,7 @@ first place. \fi \expandafter\x\csname ver@xintseries.sty\endcsname \ProvidesPackage{xintseries}% - [2013/05/14 v1.06b Expandable partial sums with xint package (jfB)]% + [2013/05/26 v1.07a Expandable partial sums with xint package (jfB)]% % \end{macrocode} % \subsection{\csh{xintSeries}} % \lverb|& @@ -11090,7 +12783,7 @@ first place. \fi \expandafter\x\csname ver@xintcfrac.sty\endcsname \ProvidesPackage{xintcfrac}% - [2013/05/14 v1.06b Expandable continued fractions with xint package (jfB)]% + [2013/05/26 v1.07a Expandable continued fractions with xint package (jfB)]% % \end{macrocode} % \subsection{\csh{xintCFrac}} % \begin{macrocode} @@ -11105,7 +12798,7 @@ first place. }% \def\XINT_cfrac_noopt #1\Z {% - \expandafter\XINT_cfrac_A\romannumeral0\xintraw {#1}\Z + \expandafter\XINT_cfrac_A\romannumeral0\xintrawwithzeros {#1}\Z \relax\relax }% \def\XINT_cfrac_opt_b\fi\XINT_cfrac_noopt [\Z #1]% @@ -11114,17 +12807,17 @@ first place. }% \def\XINT_cfrac_optl #1% {% - \expandafter\XINT_cfrac_A\romannumeral0\xintraw {#1}\Z + \expandafter\XINT_cfrac_A\romannumeral0\xintrawwithzeros {#1}\Z \relax\hfill }% \def\XINT_cfrac_optc #1% {% - \expandafter\XINT_cfrac_A\romannumeral0\xintraw {#1}\Z + \expandafter\XINT_cfrac_A\romannumeral0\xintrawwithzeros {#1}\Z \relax\relax }% \def\XINT_cfrac_optr #1% {% - \expandafter\XINT_cfrac_A\romannumeral0\xintraw {#1}\Z + \expandafter\XINT_cfrac_A\romannumeral0\xintrawwithzeros {#1}\Z \hfill\relax }% \def\XINT_cfrac_A #1/#2\Z @@ -11172,10 +12865,7 @@ first place. % \subsection{\csh{xintGCFrac}} % \begin{macrocode} \def\xintGCFrac {\romannumeral0\xintgcfrac }% -\def\xintgcfrac #1% -{% - \XINT_gcfrac_opt_a #1\Z -}% +\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% @@ -11253,7 +12943,7 @@ first place. \def\xintFtoCs {\romannumeral0\xintftocs }% \def\xintftocs #1% {% - \expandafter\XINT_ftc_A\romannumeral0\xintraw {#1}\Z + \expandafter\XINT_ftc_A\romannumeral0\xintrawwithzeros {#1}\Z }% \def\XINT_ftc_A #1/#2\Z {% @@ -11292,7 +12982,7 @@ first place. \def\xintFtoCx {\romannumeral0\xintftocx }% \def\xintftocx #1#2% {% - \expandafter\XINT_ftcx_A\romannumeral0\xintraw {#2}\Z {#1}% + \expandafter\XINT_ftcx_A\romannumeral0\xintrawwithzeros {#2}\Z {#1}% }% \def\XINT_ftcx_A #1/#2\Z {% @@ -11336,12 +13026,12 @@ first place. \def\xintFtoCC {\romannumeral0\xintftocc }% \def\xintftocc #1% {% - \expandafter\XINT_ftcc_A\expandafter {\romannumeral0\xintraw {#1}}% + \expandafter\XINT_ftcc_A\expandafter {\romannumeral0\xintrawwithzeros {#1}}% }% \def\XINT_ftcc_A #1% {% \expandafter\XINT_ftcc_B - \romannumeral0\xintraw {\xintAdd {1/2[0]}{#1[0]}}\Z {#1[0]}% + \romannumeral0\xintrawwithzeros {\xintAdd {1/2[0]}{#1[0]}}\Z {#1[0]}% }% \def\XINT_ftcc_B #1/#2\Z {% @@ -11373,7 +13063,7 @@ first place. \def\XINT_ftcc_loop_a #1% {% \expandafter\XINT_ftcc_loop_b - \romannumeral0\xintraw {\xintAdd {1/2[0]}{#1}}\Z {#1}% + \romannumeral0\xintrawwithzeros {\xintAdd {1/2[0]}{#1}}\Z {#1}% }% \def\XINT_ftcc_loop_b #1/#2\Z {% @@ -11436,7 +13126,7 @@ first place. {% \xint_gob_til_w #5\XINT_cstf_end\W \expandafter\XINT_cstf_loop_b - \romannumeral0\xintraw {#5}.{#1}{#2}{#3}{#4}% + \romannumeral0\xintrawwithzeros {#5}.{#1}{#2}{#3}{#4}% }% \def\XINT_cstf_loop_b #1/#2.#3#4#5#6% {% @@ -11458,7 +13148,7 @@ first place. {% \expandafter\XINT_cstf_loop_a\expandafter{#2}#1% }% -\def\XINT_cstf_end #1.#2#3#4#5{\xintraw {#2/#3}[0]}% +\def\XINT_cstf_end #1.#2#3#4#5{\xintrawwithzeros {#2/#3}[0]}% % \end{macrocode} % \subsection{\csh{xintiCstoF}} % \begin{macrocode} @@ -11488,7 +13178,7 @@ first place. {% \expandafter\XINT_icstf_loop_a\expandafter {#2}{#1}% }% -\def\XINT_icstf_end#1.#2#3#4#5{\xintraw {#2/#3}[0]}% +\def\XINT_icstf_end#1.#2#3#4#5{\xintrawwithzeros {#2/#3}[0]}% % \end{macrocode} % \subsection{\csh{xintGCtoF}} % \begin{macrocode} @@ -11504,7 +13194,7 @@ first place. \def\XINT_gctf_loop_a #1#2#3#4#5+% {% \expandafter\XINT_gctf_loop_b - \romannumeral0\xintraw {#5}.{#1}{#2}{#3}{#4}% + \romannumeral0\xintrawwithzeros {#5}.{#1}{#2}{#3}{#4}% }% \def\XINT_gctf_loop_b #1/#2.#3#4#5#6% {% @@ -11530,7 +13220,7 @@ first place. {% \xint_gob_til_w #2\XINT_gctf_end\W \expandafter\XINT_gctf_loop_g - \romannumeral0\xintraw {#2}.#1% + \romannumeral0\xintrawwithzeros {#2}.#1% }% \def\XINT_gctf_loop_g #1/#2.#3#4#5#6% {% @@ -11552,7 +13242,7 @@ first place. {% \expandafter\XINT_gctf_loop_a\expandafter {#2}#1% }% -\def\XINT_gctf_end #1.#2#3#4#5{\xintraw {#2/#3}[0]}% +\def\XINT_gctf_end #1.#2#3#4#5{\xintrawwithzeros {#2/#3}[0]}% % \end{macrocode} % \subsection{\csh{xintiGCtoF}} % \begin{macrocode} @@ -11601,7 +13291,7 @@ first place. {% \XINT_igctf_loop_a {#3}{#4}{#1}{#2}% }% -\def\XINT_igctf_end #1.#2#3#4#5{\xintraw {#4/#5}[0]}% +\def\XINT_igctf_end #1.#2#3#4#5{\xintrawwithzeros {#4/#5}[0]}% % \end{macrocode} % \subsection{\csh{xintCstoCv}} % \begin{macrocode} @@ -11618,7 +13308,7 @@ first place. {% \xint_gob_til_w #6\XINT_cstcv_end\W \expandafter\XINT_cstcv_loop_b - \romannumeral0\xintraw {#6}.{#2}{#3}{#4}{#5}{#1}% + \romannumeral0\xintrawwithzeros {#6}.{#2}{#3}{#4}{#5}{#1}% }% \def\XINT_cstcv_loop_b #1/#2.#3#4#5#6% {% @@ -11643,7 +13333,7 @@ first place. \def\XINT_cstcv_loop_f #1#2#3#4#5% {% \expandafter\XINT_cstcv_loop_g\expandafter - {\romannumeral0\xintraw {#1/#2}}{#5}{#1}{#2}{#3}{#4}% + {\romannumeral0\xintrawwithzeros {#1/#2}}{#5}{#1}{#2}{#3}{#4}% }% \def\XINT_cstcv_loop_g #1#2{\XINT_cstcv_loop_a {#2{#1[0]}}}% \def\XINT_cstcv_end #1.#2#3#4#5#6{ #6}% @@ -11679,7 +13369,7 @@ first place. \def\XINT_icstcv_loop_d #1#2% {% \expandafter\XINT_icstcv_loop_e\expandafter - {\romannumeral0\xintraw {#1/#2}}{{#1}{#2}}% + {\romannumeral0\xintrawwithzeros {#1/#2}}{{#1}{#2}}% }% \def\XINT_icstcv_loop_e #1#2#3#4{\XINT_icstcv_loop_a {#4{#1[0]}}#2#3}% \def\XINT_icstcv_end #1.#2#3#4#5#6{ #6}% @@ -11698,7 +13388,7 @@ first place. \def\XINT_gctcv_loop_a #1#2#3#4#5#6+% {% \expandafter\XINT_gctcv_loop_b - \romannumeral0\xintraw {#6}.{#2}{#3}{#4}{#5}{#1}% + \romannumeral0\xintrawwithzeros {#6}.{#2}{#3}{#4}{#5}{#1}% }% \def\XINT_gctcv_loop_b #1/#2.#3#4#5#6% {% @@ -11723,7 +13413,7 @@ first place. \def\XINT_gctcv_loop_f #1#2% {% \expandafter\XINT_gctcv_loop_g\expandafter - {\romannumeral0\xintraw {#1/#2}}{{#1}{#2}}% + {\romannumeral0\xintrawwithzeros {#1/#2}}{{#1}{#2}}% }% \def\XINT_gctcv_loop_g #1#2#3#4% {% @@ -11733,7 +13423,7 @@ first place. {% \xint_gob_til_w #3\XINT_gctcv_end\W \expandafter\XINT_gctcv_loop_i - \romannumeral0\xintraw {#3}.#2{#1}% + \romannumeral0\xintrawwithzeros {#3}.#2{#1}% }% \def\XINT_gctcv_loop_i #1/#2.#3#4#5#6% {% @@ -11806,13 +13496,13 @@ first place. \def\XINT_igctcv_loop_k #1#2% {% \expandafter\XINT_igctcv_loop_l\expandafter - {\romannumeral0\xintraw {#1/#2}}% + {\romannumeral0\xintrawwithzeros {#1/#2}}% }% \def\XINT_igctcv_loop_l #1#2#3{\XINT_igctcv_loop_a {#3{#1[0]}}#2}% \def\XINT_igctcv_end_a #1.#2#3#4#5% {% \expandafter\XINT_igctcv_end_b\expandafter - {\romannumeral0\xintraw {#2/#3}}% + {\romannumeral0\xintrawwithzeros {#2/#3}}% }% \def\XINT_igctcv_end_b #1#2{ #2{#1[0]}}% % \end{macrocode} @@ -12049,9 +13739,813 @@ first place. \def\XINT_gctgc__end #1#2#3{ #3{#1}}% \XINT_cfrac_restorecatcodes_endinput% % \end{macrocode} -% \DeleteShortVerb{\|} -% \MakePercentComment +%\catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11 +%\let\relax +%\def<*xintexpr>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12 } % +%<*xintexpr> +% \section{Package \xintexprname implementation} +% +% 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. +% +% \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 \xintfracname 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@xintexpr.sty\endcsname + \expandafter\let\expandafter\w\csname ver@xintfrac.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{xintexpr}{\numexpr not available, aborting input}% + \aftergroup\endinput + \else + \ifx\x\relax % plain-TeX, first loading of xintexpr.sty + \ifx\w\relax % but xintfrac.sty not yet loaded. + \y{xintexpr}{Package xintfrac is required}% + \y{xintexpr}{Will try \string\input\space xintfrac.sty}% + \def\z{\endgroup\input xintfrac.sty\relax}% + \fi + \else + \def\empty {}% + \ifx\x\empty % LaTeX, first loading, + % variable is initialized, but \ProvidesPackage not yet seen + \ifx\w\relax % xintfrac.sty not yet loaded. + \y{xintexpr}{Package xintfrac is required}% + \y{xintexpr}{Will try \string\RequirePackage{xintfrac}}% + \def\z{\endgroup\RequirePackage{xintfrac}}% + \fi + \else + \y{xintexpr}{I was already loaded, aborting input}% + \aftergroup\endinput + \fi + \fi + \fi +\z% +% \end{macrocode} +% \subsection{Confirmation of \xintfracname 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@xintfrac.sty\endcsname + \ifx\w\relax % Plain TeX, user gave a file name at the prompt + \y{xintexpr}{Loading of package xintfrac failed, aborting input}% + \aftergroup\endinput + \fi + \ifx\w\empty % LaTeX, user gave a file name at the prompt + \y{xintexpr}{Loading of package xintfrac failed, aborting input}% + \aftergroup\endinput + \fi +\endgroup% +% \end{macrocode} +% \subsection{Catcodes} +% +% Perhaps catcodes have changed after the loading of \xintname and +% \xintfracname and prior to the current loading of \xintexprname, +% 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_expr_restorecatcodes_endinput + {% + \catcode94=\the\catcode94 % ^ + \catcode33=\the\catcode33 % ! + \catcode93=\the\catcode93 % ] + \catcode91=\the\catcode91 % [ + \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 + \catcode91=12 % [ + \catcode93=12 % ] + \catcode33=11 % ! + \catcode94=12 % ^ + }% +\x +% \end{macrocode} +% \subsection{Package identification} +% \begin{macrocode} +\begingroup + \catcode64=11 % @ + \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@xintexpr.sty\endcsname +\ProvidesPackage{xintexpr}% + [2013/05/26 v1.07a Expandable expression parser (jfB)]% +% \end{macrocode} +% \subsection{Constants, 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 +\def\XINT_expr_string {\expandafter\xint_gob_til_dot\string }% +\def\XINT_expr_unexpectedtoken {\xintError:ignored }% +% \end{macrocode} +% \subsection{\csh{xintexpr},~\csh{xinttheexpr},~\csh{xintthe}} +% \begin{macrocode} +\def\xintexpr {\romannumeral0\xinteval }% +\def\xinteval +{% + \expandafter\XINT_expr_until_end\romannumeral-`0% + \expandafter\XINT_expr_checkifprefix_ii\romannumeral-`0% + \XINT_expr_getnext +}% +\def\xinttheexpr {\romannumeral0\xinttheeval }% +\def\xinttheeval {\expandafter\XINT_expr_the\romannumeral0\xinteval }% +\def\XINT_expr_the #1#2#3{\xintraw{\XINT_expr_string #3}}% +\def\xintthe #1{\ifx#1\xintexpr \expandafter\xinttheexpr + \else\expandafter\xintthefloatexpr\fi}% +% \end{macrocode} +% \subsection{Parenthesized expressions} +% \begin{macrocode} +\def\XINT_expr_until_end #1% +{% + \ifcase#1% + \expandafter\xint_gobble_vi + \or + \expandafter\XINT_expr_extra_closing_paren + \fi + \expandafter\XINT_expr_until_end\romannumeral-`0% +}% +\def\XINT_expr_extra_closing_paren {\xintError:removed }% +\def\XINT_expr_endofexpr {!\XINT_illegaluse }% +\def\XINT_illegaluse + {Illegal_here_use_xintthe\xintError:use_xintthe!\xint_gobble_i }% +\def\XINT_expr_oparen +{% + \expandafter\XINT_expr_until_cparen\romannumeral-`0% + \expandafter\XINT_expr_checkifprefix_ii\romannumeral-`0% + \XINT_expr_getnext +}% +\def\XINT_expr_until_cparen #1% +{% + \ifcase#1% + \expandafter\XINT_expr_missing_cparen + \or + \else \xint_afterfi{\expandafter\XINT_expr_until_cparen\romannumeral-`0}% + \fi +}% +\def\XINT_expr_missing_cparen #1% +{% + \xintError:inserted \xint_c_ \XINT_expr_endofexpr +}% +% \end{macrocode} +% \subsection{Infix operators, minus as prefix, scientific notation} +% \begin{macrocode} +\def\xint_tmp_def #1#2#3% +{% + \expandafter\xint_tmp_do_defs + \csname XINT_expr_op_#1\expandafter\endcsname + \csname XINT_expr_until_#1\expandafter\endcsname + \csname XINT_expr_checkifprefix_#2\expandafter\endcsname + \csname XINT_expr_precedence_#1\expandafter\endcsname + \csname xint_c_#2\expandafter\endcsname + \csname xint#3\endcsname +}% +\def\xint_tmp_do_defs #1#2#3#4#5#6% +{% + \def #1##1% \XINT_expr_op_? + {% + \expandafter #2\expandafter ##1\romannumeral-`0\expandafter + #3\romannumeral-`0\XINT_expr_getnext + }% + \def #2##1##2##3##4% \XINT_expr_until_? + {% + \ifnum ##2>#5% + \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0##3##4}% + \else + \xint_afterfi + {\expandafter ##2\expandafter ##3% + \csname .#6{\XINT_expr_string ##1}{\XINT_expr_string ##4}\endcsname }% + \fi + }% + \global\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 e{v}{fE}% +\xint_tmp_def E{v}{fE}% +\def\xint_tmp_def #1% +{% + \expandafter\xint_tmp_do_defs + \csname XINT_expr_checkifprefix_#1\expandafter\endcsname + \csname XINT_expr_op_-#1\endcsname +}% +\def\xint_tmp_do_defs #1#2% +{% + \def #1##1% + {\xint_UDsignfork + ##1\dummy #2% + -\dummy ##1% + \krof }% +}% +\xint_tmp_def {ii}% +\xint_tmp_def {iii}% +\xint_tmp_def {iv}% +\xint_tmp_def {v}% +\def\xint_tmp_def #1% +{% + \expandafter\xint_tmp_do_defs + \csname XINT_expr_op_-#1\expandafter\endcsname + \csname XINT_expr_until_-#1\expandafter\endcsname + \csname XINT_expr_checkifprefix_#1\expandafter\endcsname + \csname xint_c_#1\endcsname +}% +\def\xint_tmp_do_defs #1#2#3#4% +{% + \def #1% \XINT_expr_op_-ii,iii,iv,v + {% + \expandafter #2\romannumeral-`0\expandafter + #3\romannumeral-`0\XINT_expr_getnext + }% + \def #2##1##2##3% \XINT_expr_until_-ii,iii,iv,v + {% + \ifnum ##1>#4% + \xint_afterfi {\expandafter #2\romannumeral-`0##2##3}% + \else + \xint_afterfi {\expandafter ##1\expandafter ##2% + \csname .\xintOpp{\XINT_expr_string ##3}\endcsname }% + \fi + }% +}% +\xint_tmp_def {ii}% +\xint_tmp_def {iii}% +\xint_tmp_def {iv}% +\xint_tmp_def {v}% +% \end{macrocode} +% \subsection{Get next infix operator or closing parenthesis or factorial or expression end} +% \begin{macrocode} +\def\XINT_expr_getop #1% +{% + \expandafter\XINT_expr_getop_a\expandafter #1\romannumeral-`0% +}% +\def\XINT_expr_getop_a #1#2% +{% + \ifcat #2\relax + \ifx #2\relax + \expandafter\expandafter\expandafter + \XINT_expr_foundendofexpr + \else + \XINT_expr_unexpectedtoken + \expandafter\expandafter\expandafter + \XINT_expr_getop + \fi + \else + \expandafter\XINT_expr_op_found\expandafter #2% + \fi + #1% +}% +\def\XINT_expr_foundendofexpr {\xint_c_ \XINT_expr_endofexpr }% +\def\XINT_expr_op_found #1% +{% + \ifcsname XINT_expr_precedence_\string #1\endcsname + \expandafter\xint_afterfi\expandafter + {\csname XINT_expr_precedence_\string #1\expandafter\endcsname + \csname XINT_expr_op_\string #1\endcsname }% + \else + \XINT_expr_unexpectedtoken + \expandafter\XINT_expr_getop + \fi +}% +\expandafter\let\csname XINT_expr_precedence_)\endcsname \xint_c_i +\expandafter\let\csname XINT_expr_op_)\endcsname\XINT_expr_getop +\def\xint_tmp_def +{% + \expandafter\xint_tmp_do_defs + \csname XINT_expr_precedence_!\expandafter\endcsname + \csname XINT_expr_op_!\endcsname +}% +\def\xint_tmp_do_defs #1#2% +{% + \def #1##1##2% + {\ifx ##1#2% + \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 }% + \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} +% \begin{macrocode} +\def\XINT_expr_getnext +{% + \expandafter\XINT_expr_getnext_checkforbraced_a\romannumeral-`0% +}% +\def\XINT_expr_getnext_checkforbraced_a #1% +{% + \XINT_expr_getnext_checkforbraced_b #1\W\Z {#1}% +}% +\def\XINT_expr_getnext_checkforbraced_b #1#2% +{% + \xint_UDwfork + #1\dummy \XINT_expr_getnext_emptybracepair + #2\dummy \XINT_expr_getnext_onetoken_perhaps + \W\dummy \XINT_expr_getnext_gotbracedstuff + \krof +}% +\def\XINT_expr_getnext_onetoken_perhaps\Z #1% +{% + \expandafter\XINT_expr_getnext_checkforbraced_c\expandafter + {\romannumeral-`0#1}% +}% +\def\XINT_expr_getnext_checkforbraced_c #1% +{% + \XINT_expr_getnext_checkforbraced_d #1\W\Z {#1}% +}% +\def\XINT_expr_getnext_checkforbraced_d #1#2% +{% + \xint_UDwfork + #1\dummy \XINT_expr_getnext_emptybracepair + #2\dummy \XINT_expr_getnext_onetoken_wehope + \W\dummy \XINT_expr_getnext_gotbracedstuff + \krof +}% +\def\XINT_expr_getnext_emptybracepair #1{\XINT_expr_getnext }% +\def\XINT_expr_getnext_gotbracedstuff #1\W\Z #2% +{% + \expandafter\XINT_expr_getop\csname .#2\endcsname +}% +\def\XINT_expr_getnext_onetoken_wehope\Z #1% +{% + \xint_gob_til_! #1\XINT_expr_subexpr !% + \expandafter\XINT_expr_getnext_onetoken_fork\string #1% +}% +\def\XINT_expr_subexpr !#1!{\expandafter\XINT_expr_getop\xint_gobble_i }% +\begingroup +\lccode`*=`_ +\lowercase{\endgroup +\def\XINT_expr_sixwayfork #1(-.+*\dummy #2#3\krof {#2}% +\def\XINT_expr_getnext_onetoken_fork #1% +{% + \XINT_expr_sixwayfork + #1-.+*\dummy \XINT_expr_oparen + (#1.+*\dummy -% + (-#1+*\dummy {\XINT_expr_scannum_start\XINT_expr_scannum_decpart_b.}% + (-.#1*\dummy \XINT_expr_getnext% + (-.+#1\dummy {\XINT_expr_scannum_start\XINT_expr_scannum_decpart_b*}% + (-.+*\dummy {\XINT_expr_scannum_check #1}% + \krof +}}% +\def\XINT_expr_scannum_check #1% +{% + \ifnum \xint_c_ix<1#1 + \expandafter\XINT_expr_scannum_start + \else + \xint_afterfi{\XINT_expr_unexpectedtoken + \expandafter\XINT_expr_getnext\xint_gobble_ii}% + \fi \XINT_expr_scannum_intpart_b #1% +}% +\def\XINT_expr_scannum_stopscan {!}% ! catcode 11 +\def\XINT_expr_gathernum #1!% ! with catcode 11 +{% + \expandafter\space\csname .#1\endcsname +}% +\def\XINT_expr_scannum_start #1% +{% + \expandafter\XINT_expr_getop + \romannumeral-`0\expandafter\XINT_expr_gathernum + \romannumeral-`0#1% +}% +\def\XINT_expr_scannum_intpart_a #1% +{% + \ifnum \xint_c_ix<1\string#1 + \expandafter\expandafter\expandafter + \XINT_expr_scannum_intpart_b + \expandafter\string + \else + \if #1.% + \expandafter\expandafter\expandafter + \XINT_expr_scannum_transition + \else + \expandafter\expandafter\expandafter + \XINT_expr_scannum_stopscan + \fi + \fi + #1% +}% +\def\XINT_expr_scannum_intpart_b #1% +{% + \expandafter #1\romannumeral-`0\expandafter + \XINT_expr_scannum_intpart_a\romannumeral-`0% +}% +\def\XINT_expr_scannum_transition #1% +{% + \expandafter.\romannumeral-`0\expandafter + \XINT_expr_scannum_decpart_a\romannumeral-`0% +}% +\def\XINT_expr_scannum_decpart_a #1% +{% + \ifnum \xint_c_ix<1\string#1 + \expandafter\expandafter\expandafter + \XINT_expr_scannum_decpart_b\expandafter\string + \else + \expandafter \XINT_expr_scannum_stopscan + \fi + #1% +}% +\def\XINT_expr_scannum_decpart_b #1% +{% + \expandafter #1\romannumeral-`0\expandafter + \XINT_expr_scannum_decpart_a\romannumeral-`0% +}% +% \end{macrocode} +% \subsection{\csh{xintfloatexpr},~\csh{xintthefloatexpr}} +% \begin{macrocode} +\def\xintfloatexpr {\romannumeral0\xintfloateval }% +\def\xintfloateval +{% + \expandafter\XINT_expr_until_end\romannumeral-`0% + \expandafter\XINT_flexpr_checkifprefix_ii\romannumeral-`0% + \XINT_flexpr_getnext +}% +\def\xintthefloatexpr {\romannumeral0\xintthefloateval }% +\def\xintthefloateval + {\expandafter\XINT_flexpr_the\romannumeral0\xintfloateval }% +\def\XINT_flexpr_the #1#2#3{\xintfloat{\XINT_expr_string #3}}% +\def\XINT_flexpr_oparen +{% + \expandafter\XINT_expr_until_cparen\romannumeral-`0% + \expandafter\XINT_flexpr_checkifprefix_ii\romannumeral-`0% + \XINT_flexpr_getnext +}% +\def\xint_tmp_def #1#2#3% +{% + \expandafter\xint_tmp_do_defs + \csname XINT_flexpr_op_#1\expandafter\endcsname + \csname XINT_flexpr_until_#1\expandafter\endcsname + \csname XINT_flexpr_checkifprefix_#2\expandafter\endcsname + \csname XINT_expr_precedence_#1\expandafter\endcsname + \csname xint_c_#2\expandafter\endcsname + \csname XINTinFloat#3\endcsname +}% +\def\xint_tmp_do_defs #1#2#3#4#5#6% +{% + \def #1##1% \XINT_flexpr_op_? + {% + \expandafter #2\expandafter ##1\romannumeral-`0\expandafter + #3\romannumeral-`0\XINT_flexpr_getnext + }% + \def #2##1##2##3##4% \XINT_flexpr_until_? + {% + \ifnum ##2>#5% + \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0##3##4}% + \else + \xint_afterfi + {\expandafter ##2\expandafter ##3% + \csname .#6{\XINT_expr_string ##1}% + {\XINT_expr_string ##4}\endcsname }% + \fi + }% +}% +\xint_tmp_def +{ii}{Add}% +\xint_tmp_def -{ii}{Sub}% +\xint_tmp_def *{iii}{Mul}% +\xint_tmp_def /{iii}{Div}% +\xint_tmp_def ^{iv}{Power}% +\xint_tmp_def e{v}{fE}% +\xint_tmp_def E{v}{fE}% +\def\xint_tmp_def #1% +{% + \expandafter\xint_tmp_do_defs + \csname XINT_flexpr_checkifprefix_#1\expandafter\endcsname + \csname XINT_flexpr_op_-#1\endcsname +}% +\def\xint_tmp_do_defs #1#2% +{% + \def #1##1% + {\xint_UDsignfork + ##1\dummy #2% + -\dummy ##1% + \krof }% +}% +\xint_tmp_def {ii}% +\xint_tmp_def {iii}% +\xint_tmp_def {iv}% +\xint_tmp_def {v}% +\def\xint_tmp_def #1% +{% + \expandafter\xint_tmp_do_defs + \csname XINT_flexpr_op_-#1\expandafter\endcsname + \csname XINT_expr_until_-#1\expandafter\endcsname + \csname XINT_flexpr_checkifprefix_#1\expandafter\endcsname + \csname xint_c_#1\endcsname +}% +\def\xint_tmp_do_defs #1#2#3#4% +{% + \def #1% \XINT_flexpr_op_-ii,iii,iv,v + {% + \expandafter #2\romannumeral-`0\expandafter + #3\romannumeral-`0\XINT_flexpr_getnext + }% +}% +\xint_tmp_def {ii}% +\xint_tmp_def {iii}% +\xint_tmp_def {iv}% +\xint_tmp_def {v}% +\let\xint_tmp_def\empty +\let\xint_tmp_do_defs\empty +\def\XINT_flexpr_getop #1% +{% + \expandafter\XINT_flexpr_getop_a\expandafter #1\romannumeral-`0% +}% +\def\XINT_flexpr_getop_a #1#2% +{% + \ifcat #2\relax + \ifx #2\relax + \expandafter\expandafter\expandafter + \XINT_expr_foundendofexpr + \else + \XINT_expr_unexpectedtoken + \expandafter\expandafter\expandafter + \XINT_flexpr_getop + \fi + \else + \expandafter\XINT_flexpr_op_found\expandafter #2% + \fi + #1% +}% +\def\XINT_flexpr_op_found #1% +{% + \ifcsname XINT_expr_precedence_\string #1\endcsname + \expandafter\xint_afterfi\expandafter + {\csname XINT_expr_precedence_\string #1\expandafter\endcsname + \csname XINT_flexpr_op_\string #1\endcsname }% + \else + \XINT_expr_unexpectedtoken + \expandafter\XINT_flexpr_getop + \fi +}% +\expandafter\let\csname XINT_flexpr_op_)\endcsname\XINT_flexpr_getop +\def\XINT_flexpr_getnext +{% + \expandafter\XINT_flexpr_getnext_checkforbraced_a\romannumeral-`0% +}% +\def\XINT_flexpr_getnext_checkforbraced_a #1% +{% + \XINT_flexpr_getnext_checkforbraced_b #1\W\Z {#1}% +}% +\def\XINT_flexpr_getnext_checkforbraced_b #1#2% +{% + \xint_UDwfork + #1\dummy \XINT_flexpr_getnext_emptybracepair + #2\dummy \XINT_flexpr_getnext_onetoken_perhaps + \W\dummy \XINT_flexpr_getnext_gotbracedstuff + \krof +}% +\def\XINT_flexpr_getnext_onetoken_perhaps\Z #1% +{% + \expandafter\XINT_flexpr_getnext_checkforbraced_c\expandafter + {\romannumeral-`0#1}% +}% +\def\XINT_flexpr_getnext_checkforbraced_c #1% +{% + \XINT_flexpr_getnext_checkforbraced_d #1\W\Z {#1}% +}% +\def\XINT_flexpr_getnext_checkforbraced_d #1#2% +{% + \xint_UDwfork + #1\dummy \XINT_flexpr_getnext_emptybracepair + #2\dummy \XINT_flexpr_getnext_onetoken_wehope + \W\dummy \XINT_flexpr_getnext_gotbracedstuff + \krof +}% +\def\XINT_flexpr_getnext_emptybracepair #1{\XINT_flexpr_getnext }% +\def\XINT_flexpr_getnext_gotbracedstuff #1\W\Z #2% +{% + \expandafter\XINT_flexpr_getop\csname .#2\endcsname +}% +\def\XINT_flexpr_getnext_onetoken_wehope\Z #1% +{% + \xint_gob_til_! #1\XINT_flexpr_subexpr !% + \expandafter\XINT_flexpr_getnext_onetoken_fork\string #1% +}% +\def\XINT_flexpr_subexpr !#1!{\expandafter\XINT_flexpr_getop\xint_gobble_i }% +\begingroup +\lccode`*=`_ +\lowercase{\endgroup +\def\XINT_flexpr_getnext_onetoken_fork #1% +{% + \XINT_expr_sixwayfork + #1-.+*\dummy \XINT_flexpr_oparen + (#1.+*\dummy -% + (-#1+*\dummy {\XINT_flexpr_scannum_start\XINT_expr_scannum_decpart_b.}% + (-.#1*\dummy \XINT_flexpr_getnext% + (-.+#1\dummy {\XINT_flexpr_scannum_start\XINT_expr_scannum_decpart_b*}% + (-.+*\dummy {\XINT_flexpr_scannum_check #1}% + \krof +}}% +\def\XINT_flexpr_scannum_check #1% +{% + \ifnum \xint_c_ix<1#1 + \expandafter\XINT_flexpr_scannum_start + \else + \xint_afterfi + {\XINT_expr_unexpectedtoken + \expandafter\XINT_flexpr_getnext\xint_gobble_ii}% + \fi \XINT_expr_scannum_intpart_b #1% +}% +\def\XINT_flexpr_scannum_start #1% +{% + \expandafter\XINT_flexpr_getop + \romannumeral-`0\expandafter\XINT_expr_gathernum + \romannumeral-`0#1% +}% +% \end{macrocode} +% \subsection{\csh{xintNewExpr}} +% \begin{macrocode} +\catcode`* 13 +\def\xintNewExpr #1[#2]#3% +{% + \begingroup + \ifcase #2\relax + \toks0 {\xdef #1}% + \or \toks0 {\xdef #1##1}% + \or \toks0 {\xdef #1##1##2}% + \or \toks0 {\xdef #1##1##2##3}% + \or \toks0 {\xdef #1##1##2##3##4}% + \or \toks0 {\xdef #1##1##2##3##4##5}% + \or \toks0 {\xdef #1##1##2##3##4##5##6}% + \or \toks0 {\xdef #1##1##2##3##4##5##6##7}% + \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8}% + \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8##9}% + \else + \immediate\write-1{Package xintexpr Error! illegal number of macro + parameters.}% + \fi + \def\xintAdd {:xintAdd}% + \def\xintSub {:xintSub}% + \def\xintMul {:xintMul}% + \def\xintDiv {:xintDiv}% + \def\xintfPow {:xintfPow}% + \def\xintfFac {:xintfFac}% + \def\xintOpp {:xintOpp}% + \def\xintfE {:xintfE}% + \def\xintraw { :romannumeral0:xintraw}% + \def\XINT_expr_the ##1##2##3% + {\expandafter\xintraw + \expandafter{\romannumeral-`0\XINT_expr_string ##3}}% + \lccode`\*=`: \lowercase {\def*}{!noexpand!}% + \catcode`: 13 + \endlinechar -1 + \everyeof {\noexpand }% + \edef\xintNewExprtmp + {\expandafter\scantokens + \expandafter{\romannumeral0\xinttheeval #3\relax}}% + \lccode`\*=`_ \lowercase {\def*}{####}% + \catcode`_ 13 \catcode`! 0 \catcode`: 11 + \the\toks0 {\expandafter\scantokens\expandafter{\xintNewExprtmp }}% +\endgroup +}% +% \end{macrocode} +% \subsection{\csh{xintNewFloatExpr}} +% \begin{macrocode} +\def\xintNewFloatExpr #1[#2]#3% +{% + \begingroup + \ifcase #2\relax + \toks0 {\xdef #1}% + \or \toks0 {\xdef #1##1}% + \or \toks0 {\xdef #1##1##2}% + \or \toks0 {\xdef #1##1##2##3}% + \or \toks0 {\xdef #1##1##2##3##4}% + \or \toks0 {\xdef #1##1##2##3##4##5}% + \or \toks0 {\xdef #1##1##2##3##4##5##6}% + \or \toks0 {\xdef #1##1##2##3##4##5##6##7}% + \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8}% + \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8##9}% + \else + \immediate\write-1{Package xintexpr Error! illegal number of macro + parameters.}% + \fi + \def\XINTinFloatAdd {:XINTinFloatAdd}% + \def\XINTinFloatSub {:XINTinFloatSub}% + \def\XINTinFloatMul {:XINTinFloatMul}% + \def\XINTinFloatDiv {:XINTinFloatDiv}% + \def\XINTinFloatPower {:XINTinFloatPower}% + \def\xintfFac {:xintfFac}% + \def\xintOpp {:xintOpp}% + \def\XINTinFloatfE {:XINTinFloatfE}% + \def\xintfloat { :romannumeral0:xintfloat}% + \def\XINT_flexpr_the ##1##2##3% + {\expandafter\xintfloat + \expandafter{\romannumeral-`0\XINT_expr_string ##3}}% + \lccode`\*=`: \lowercase {\def*}{!noexpand!}% + \catcode`: 13 + \endlinechar -1 + \everyeof {\noexpand }% + \edef\xintNewExprtmp + {\expandafter\scantokens + \expandafter{\romannumeral0\xintthefloateval #3\relax}}% + \lccode`\*=`_ \lowercase {\def*}{####}% + \catcode`_ 13 \catcode`! 0 \catcode`: 11 + \the\toks0 {\expandafter\scantokens\expandafter{\xintNewExprtmp }}% +\endgroup +}% +\XINT_expr_restorecatcodes_endinput% +% \end{macrocode} +% \DeleteShortVerb{\|} +% \MakePercentComment +% %<*none> \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 @@ -12069,7 +14563,7 @@ first place. Grave accent \` Left brace \{ Vertical bar \| Right brace \} Tilde \~} -\CheckSum{11444} +\CheckSum{13965} \makeatletter\check@checksum\makeatother \Finale %% diff --git a/Master/texmf-dist/source/generic/xint/xint.ins b/Master/texmf-dist/source/generic/xint/xint.ins index 24c8379d8bd..c2392102edb 100644 --- a/Master/texmf-dist/source/generic/xint/xint.ins +++ b/Master/texmf-dist/source/generic/xint/xint.ins @@ -1,6 +1,6 @@ %% %%---------------------------------------------------------------- -%% The xint bundle (version 1.06b of May 14, 2013) +%% The xint bundle (version 1.07a of May 26, 2013) %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- %% @@ -19,7 +19,8 @@ \file{xintgcd.sty}{\from{xint.dtx}{xintgcd}} \file{xintfrac.sty}{\from{xint.dtx}{xintfrac}} \file{xintseries.sty}{\from{xint.dtx}{xintseries}} -\file{xintcfrac.sty}{\from{xint.dtx}{xintcfrac}}} +\file{xintcfrac.sty}{\from{xint.dtx}{xintcfrac}} +\file{xintexpr.sty}{\from{xint.dtx}{xintexpr}}} \endbatchfile \endinput %% diff --git a/Master/texmf-dist/tex/generic/xint/xint.sty b/Master/texmf-dist/tex/generic/xint/xint.sty index c296158f940..b740ecda4a6 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.06b of May 14, 2013) +%% The xint bundle (version 1.07a of May 26, 2013) %% xint: Expandable operations on long numbers %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -138,7 +138,7 @@ \fi \expandafter\x\csname ver@xint.sty\endcsname \ProvidesPackage{xint}% - [2013/05/14 v1.06b Expandable operations on long numbers (jfB)]% + [2013/05/26 v1.07a Expandable operations on long numbers (jfB)]% \def\xint_gobble_ {}% \def\xint_gobble_i #1{}% \def\xint_gobble_ii #1#2{}% @@ -153,6 +153,9 @@ \def\xint_firstoftwo_andstop #1#2{ #1}% \def\xint_secondoftwo_andstop #1#2{ #2}% \def\xint_exchangetwo_keepbraces_andstop #1#2{ {#2}{#1}}% +\def\xint_firstofthree #1#2#3{#1}% +\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 {}% @@ -213,13 +216,13 @@ \def\xintRevWithBracesNoExpand {\romannumeral0\xintrevwithbracesnoexpand }% \def\xintrevwithbraces #1% {% - \expandafter\XINT_revwbr_loop % #1 empty ok + \expandafter\XINT_revwbr_loop\expandafter{\expandafter}% \romannumeral-`0#1\xint_relax\xint_relax\xint_relax\xint_relax \xint_relax\xint_relax\xint_relax\xint_relax\Z }% \def\xintrevwithbracesnoexpand #1% {% - \romannumeral0\XINT_revwbr_loop + \romannumeral0\XINT_revwbr_loop\expandafter{\expandafter}% #1\xint_relax\xint_relax\xint_relax\xint_relax \xint_relax\xint_relax\xint_relax\xint_relax\Z }% @@ -305,6 +308,7 @@ \def\XINT_length_finish_c #1#2\Z #3% {\expandafter\space\the\numexpr #3-#1\relax}% \def\xintCSVtoList {\romannumeral0\xintcsvtolist }% +\def\xintCSVtoListNoExpand {\romannumeral0\xintcsvtolistnoexpand }% \def\xintcsvtolist #1% {% \expandafter\XINT_csvtol_loop_a\expandafter @@ -312,6 +316,12 @@ ,\xint_undef,\xint_undef,\xint_undef,\xint_undef ,\xint_undef,\xint_undef,\xint_undef,\xint_undef,\Z }% +\def\xintcsvtolistnoexpand #1% +{% + \romannumeral0\XINT_csvtol_loop_a + {}#1,\xint_undef,\xint_undef,\xint_undef,\xint_undef + ,\xint_undef,\xint_undef,\xint_undef,\xint_undef,\Z +}% \def\XINT_csvtol_loop_a #1#2,#3,#4,#5,#6,#7,#8,#9,% {% \xint_gob_til_xint_undef #9\XINT_csvtol_finish_a\xint_undef @@ -348,9 +358,12 @@ \def\XINT_csvtol_finish_di #1#2#3#4#5#6#7#8#9% { #9{#1}{#2}{#3}{#4}{#5}{#6}{#7}}% \def\xintListWithSep {\romannumeral0\xintlistwithsep }% +\def\xintListWithSepNoExpand {\romannumeral0\xintlistwithsepnoexpand }% \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\XINT_lws_start #1#2% {% \xint_gob_til_z #2\XINT_lws_dont\Z @@ -365,11 +378,16 @@ \long\def\XINT_lws_loop_b #1#2{\XINT_lws_loop_a {#1#2}}% \long\def\XINT_lws_end\Z\XINT_lws_loop_b #1#2#3{ #1}% \def\xintNthElt {\romannumeral0\xintnthelt }% +\def\xintNthEltNoExpand {\romannumeral0\xintntheltnoexpand }% \def\xintnthelt #1#2% {% \expandafter\XINT_nthelt\expandafter {\romannumeral-`0#2}% {\numexpr #1\relax }% }% +\def\xintntheltnoexpand #1#2% +{% + \romannumeral0\XINT_nthelt {#2}{\numexpr #1\relax}% +}% \def\XINT_nthelt #1#2% {% \ifnum #2>0 @@ -407,12 +425,14 @@ \krof }% \def\xintApply {\romannumeral0\xintapply }% +\def\xintApplyNoExpand {\romannumeral0\xintapplynoexpand }% \def\xintapply #1#2% {% \expandafter\XINT_apply\expandafter {\romannumeral-`0#2}% {#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\XINT_apply_loop_a #1#2#3% {% \xint_gob_til_z #3\XINT_apply_end\Z @@ -423,12 +443,15 @@ \def\XINT_apply_loop_b #1#2{\XINT_apply_loop_a {#2{#1}}}% \def\XINT_apply_end\Z\expandafter\XINT_apply_loop_b\expandafter #1#2#3{ #2}% \def\xintApplyUnbraced {\romannumeral0\xintapplyunbraced }% +\def\xintApplyUnbracedNoExpand {\romannumeral0\xintapplyunbracednoexpand }% \def\xintapplyunbraced #1#2% {% \expandafter\XINT_applyunbr\expandafter {\romannumeral-`0#2}% {#1}% }% \def\XINT_applyunbr #1#2{\XINT_applyunbr_loop_a {}{#2}#1\Z }% +\def\xintapplyunbracednoexpand #1#2% + {\romannumeral0\XINT_applyunbr_loop_a {}{#1}#2\Z }% \def\XINT_applyunbr_loop_a #1#2#3% {% \xint_gob_til_z #3\XINT_applyunbr_end\Z @@ -680,6 +703,14 @@ 0-\dummy { 1}% \krof }% +\def\xintSgnFork {\romannumeral0\xintsgnfork }% +\def\xintsgnfork #1% +{% + \ifcase #1 \xint_afterfi{\expandafter\space\xint_secondofthree}% + \or\xint_afterfi{\expandafter\space\xint_thirdofthree}% + \else\xint_afterfi{\expandafter\space\xint_firstofthree}% + \fi +}% \def\xintiOpp {\romannumeral0\xintiopp }% \def\xintiopp #1% {% @@ -2953,7 +2984,7 @@ \def\XINT_dsx_xisNeg_checkA_ #1#2\Z #3% {% \xint_gob_til_zero #1\XINT_dsx_xisNeg_Azero 0% - \XINT_dsx_xisNeg_checkx {#3}{#3}\Z {#1#2}% + \XINT_dsx_xisNeg_checkx {#3}{#3}{}\Z {#1#2}% }% \def\XINT_dsx_xisNeg_Azero #1\Z #2{ 0}% \def\XINT_dsx_xisNeg_checkx #1% @@ -2961,25 +2992,25 @@ \ifnum #1>999999999 \xint_afterfi {\xintError:TooBigDecimalShift - \expandafter\space\expandafter 0\xint_gobble_iii }% + \expandafter\space\expandafter 0\xint_gobble_iv }% \else \expandafter \XINT_dsx_zeroloop \fi }% -\def\XINT_dsx_zeroloop #1% +\def\XINT_dsx_zeroloop #1#2% {% \ifnum #1<9 \XINT_dsx_exita\fi \expandafter\XINT_dsx_zeroloop\expandafter - {\the\numexpr #1-8}00000000% + {\the\numexpr #1-8}{#200000000}% }% \def\XINT_dsx_exita\fi\expandafter\XINT_dsx_zeroloop {% \fi\expandafter\XINT_dsx_exitb }% -\def\XINT_dsx_exitb #1% +\def\XINT_dsx_exitb #1#2% {% \expandafter\expandafter\expandafter - \XINT_dsx_addzeros\csname xint_gobble_\romannumeral -#1\endcsname + \XINT_dsx_addzeros\csname xint_gobble_\romannumeral -#1\endcsname #2% }% \def\XINT_dsx_addzeros #1\Z #2{ #2#1}% \def\XINT_dsx_xisPos #1\Z #2% diff --git a/Master/texmf-dist/tex/generic/xint/xintcfrac.sty b/Master/texmf-dist/tex/generic/xint/xintcfrac.sty index 7cbe6299ef0..561738a7b02 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.06b of May 14, 2013) +%% The xint bundle (version 1.07a of May 26, 2013) %% xintcfrac: Expandable continued fractions with xint package %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -164,7 +164,7 @@ \fi \expandafter\x\csname ver@xintcfrac.sty\endcsname \ProvidesPackage{xintcfrac}% - [2013/05/14 v1.06b Expandable continued fractions with xint package (jfB)]% + [2013/05/26 v1.07a Expandable continued fractions with xint package (jfB)]% \def\xintCFrac {\romannumeral0\xintcfrac }% \def\xintcfrac #1% {% @@ -176,7 +176,7 @@ }% \def\XINT_cfrac_noopt #1\Z {% - \expandafter\XINT_cfrac_A\romannumeral0\xintraw {#1}\Z + \expandafter\XINT_cfrac_A\romannumeral0\xintrawwithzeros {#1}\Z \relax\relax }% \def\XINT_cfrac_opt_b\fi\XINT_cfrac_noopt [\Z #1]% @@ -185,17 +185,17 @@ }% \def\XINT_cfrac_optl #1% {% - \expandafter\XINT_cfrac_A\romannumeral0\xintraw {#1}\Z + \expandafter\XINT_cfrac_A\romannumeral0\xintrawwithzeros {#1}\Z \relax\hfill }% \def\XINT_cfrac_optc #1% {% - \expandafter\XINT_cfrac_A\romannumeral0\xintraw {#1}\Z + \expandafter\XINT_cfrac_A\romannumeral0\xintrawwithzeros {#1}\Z \relax\relax }% \def\XINT_cfrac_optr #1% {% - \expandafter\XINT_cfrac_A\romannumeral0\xintraw {#1}\Z + \expandafter\XINT_cfrac_A\romannumeral0\xintrawwithzeros {#1}\Z \hfill\relax }% \def\XINT_cfrac_A #1/#2\Z @@ -240,10 +240,7 @@ }% \def\XINT_cfrac__end \Z+\cfrac#1#2{ #2}% \def\xintGCFrac {\romannumeral0\xintgcfrac }% -\def\xintgcfrac #1% -{% - \XINT_gcfrac_opt_a #1\Z -}% +\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% @@ -315,7 +312,7 @@ \def\xintFtoCs {\romannumeral0\xintftocs }% \def\xintftocs #1% {% - \expandafter\XINT_ftc_A\romannumeral0\xintraw {#1}\Z + \expandafter\XINT_ftc_A\romannumeral0\xintrawwithzeros {#1}\Z }% \def\XINT_ftc_A #1/#2\Z {% @@ -351,7 +348,7 @@ \def\xintFtoCx {\romannumeral0\xintftocx }% \def\xintftocx #1#2% {% - \expandafter\XINT_ftcx_A\romannumeral0\xintraw {#2}\Z {#1}% + \expandafter\XINT_ftcx_A\romannumeral0\xintrawwithzeros {#2}\Z {#1}% }% \def\XINT_ftcx_A #1/#2\Z {% @@ -389,12 +386,12 @@ \def\xintFtoCC {\romannumeral0\xintftocc }% \def\xintftocc #1% {% - \expandafter\XINT_ftcc_A\expandafter {\romannumeral0\xintraw {#1}}% + \expandafter\XINT_ftcc_A\expandafter {\romannumeral0\xintrawwithzeros {#1}}% }% \def\XINT_ftcc_A #1% {% \expandafter\XINT_ftcc_B - \romannumeral0\xintraw {\xintAdd {1/2[0]}{#1[0]}}\Z {#1[0]}% + \romannumeral0\xintrawwithzeros {\xintAdd {1/2[0]}{#1[0]}}\Z {#1[0]}% }% \def\XINT_ftcc_B #1/#2\Z {% @@ -426,7 +423,7 @@ \def\XINT_ftcc_loop_a #1% {% \expandafter\XINT_ftcc_loop_b - \romannumeral0\xintraw {\xintAdd {1/2[0]}{#1}}\Z {#1}% + \romannumeral0\xintrawwithzeros {\xintAdd {1/2[0]}{#1}}\Z {#1}% }% \def\XINT_ftcc_loop_b #1/#2\Z {% @@ -480,7 +477,7 @@ {% \xint_gob_til_w #5\XINT_cstf_end\W \expandafter\XINT_cstf_loop_b - \romannumeral0\xintraw {#5}.{#1}{#2}{#3}{#4}% + \romannumeral0\xintrawwithzeros {#5}.{#1}{#2}{#3}{#4}% }% \def\XINT_cstf_loop_b #1/#2.#3#4#5#6% {% @@ -502,7 +499,7 @@ {% \expandafter\XINT_cstf_loop_a\expandafter{#2}#1% }% -\def\XINT_cstf_end #1.#2#3#4#5{\xintraw {#2/#3}[0]}% +\def\XINT_cstf_end #1.#2#3#4#5{\xintrawwithzeros {#2/#3}[0]}% \def\xintiCstoF {\romannumeral0\xinticstof }% \def\xinticstof #1% {% @@ -529,7 +526,7 @@ {% \expandafter\XINT_icstf_loop_a\expandafter {#2}{#1}% }% -\def\XINT_icstf_end#1.#2#3#4#5{\xintraw {#2/#3}[0]}% +\def\XINT_icstf_end#1.#2#3#4#5{\xintrawwithzeros {#2/#3}[0]}% \def\xintGCtoF {\romannumeral0\xintgctof }% \def\xintgctof #1% {% @@ -542,7 +539,7 @@ \def\XINT_gctf_loop_a #1#2#3#4#5+% {% \expandafter\XINT_gctf_loop_b - \romannumeral0\xintraw {#5}.{#1}{#2}{#3}{#4}% + \romannumeral0\xintrawwithzeros {#5}.{#1}{#2}{#3}{#4}% }% \def\XINT_gctf_loop_b #1/#2.#3#4#5#6% {% @@ -568,7 +565,7 @@ {% \xint_gob_til_w #2\XINT_gctf_end\W \expandafter\XINT_gctf_loop_g - \romannumeral0\xintraw {#2}.#1% + \romannumeral0\xintrawwithzeros {#2}.#1% }% \def\XINT_gctf_loop_g #1/#2.#3#4#5#6% {% @@ -590,7 +587,7 @@ {% \expandafter\XINT_gctf_loop_a\expandafter {#2}#1% }% -\def\XINT_gctf_end #1.#2#3#4#5{\xintraw {#2/#3}[0]}% +\def\XINT_gctf_end #1.#2#3#4#5{\xintrawwithzeros {#2/#3}[0]}% \def\xintiGCtoF {\romannumeral0\xintigctof }% \def\xintigctof #1% {% @@ -636,7 +633,7 @@ {% \XINT_igctf_loop_a {#3}{#4}{#1}{#2}% }% -\def\XINT_igctf_end #1.#2#3#4#5{\xintraw {#4/#5}[0]}% +\def\XINT_igctf_end #1.#2#3#4#5{\xintrawwithzeros {#4/#5}[0]}% \def\xintCstoCv {\romannumeral0\xintcstocv }% \def\xintcstocv #1% {% @@ -650,7 +647,7 @@ {% \xint_gob_til_w #6\XINT_cstcv_end\W \expandafter\XINT_cstcv_loop_b - \romannumeral0\xintraw {#6}.{#2}{#3}{#4}{#5}{#1}% + \romannumeral0\xintrawwithzeros {#6}.{#2}{#3}{#4}{#5}{#1}% }% \def\XINT_cstcv_loop_b #1/#2.#3#4#5#6% {% @@ -675,7 +672,7 @@ \def\XINT_cstcv_loop_f #1#2#3#4#5% {% \expandafter\XINT_cstcv_loop_g\expandafter - {\romannumeral0\xintraw {#1/#2}}{#5}{#1}{#2}{#3}{#4}% + {\romannumeral0\xintrawwithzeros {#1/#2}}{#5}{#1}{#2}{#3}{#4}% }% \def\XINT_cstcv_loop_g #1#2{\XINT_cstcv_loop_a {#2{#1[0]}}}% \def\XINT_cstcv_end #1.#2#3#4#5#6{ #6}% @@ -708,7 +705,7 @@ \def\XINT_icstcv_loop_d #1#2% {% \expandafter\XINT_icstcv_loop_e\expandafter - {\romannumeral0\xintraw {#1/#2}}{{#1}{#2}}% + {\romannumeral0\xintrawwithzeros {#1/#2}}{{#1}{#2}}% }% \def\XINT_icstcv_loop_e #1#2#3#4{\XINT_icstcv_loop_a {#4{#1[0]}}#2#3}% \def\XINT_icstcv_end #1.#2#3#4#5#6{ #6}% @@ -724,7 +721,7 @@ \def\XINT_gctcv_loop_a #1#2#3#4#5#6+% {% \expandafter\XINT_gctcv_loop_b - \romannumeral0\xintraw {#6}.{#2}{#3}{#4}{#5}{#1}% + \romannumeral0\xintrawwithzeros {#6}.{#2}{#3}{#4}{#5}{#1}% }% \def\XINT_gctcv_loop_b #1/#2.#3#4#5#6% {% @@ -749,7 +746,7 @@ \def\XINT_gctcv_loop_f #1#2% {% \expandafter\XINT_gctcv_loop_g\expandafter - {\romannumeral0\xintraw {#1/#2}}{{#1}{#2}}% + {\romannumeral0\xintrawwithzeros {#1/#2}}{{#1}{#2}}% }% \def\XINT_gctcv_loop_g #1#2#3#4% {% @@ -759,7 +756,7 @@ {% \xint_gob_til_w #3\XINT_gctcv_end\W \expandafter\XINT_gctcv_loop_i - \romannumeral0\xintraw {#3}.#2{#1}% + \romannumeral0\xintrawwithzeros {#3}.#2{#1}% }% \def\XINT_gctcv_loop_i #1/#2.#3#4#5#6% {% @@ -829,13 +826,13 @@ \def\XINT_igctcv_loop_k #1#2% {% \expandafter\XINT_igctcv_loop_l\expandafter - {\romannumeral0\xintraw {#1/#2}}% + {\romannumeral0\xintrawwithzeros {#1/#2}}% }% \def\XINT_igctcv_loop_l #1#2#3{\XINT_igctcv_loop_a {#3{#1[0]}}#2}% \def\XINT_igctcv_end_a #1.#2#3#4#5% {% \expandafter\XINT_igctcv_end_b\expandafter - {\romannumeral0\xintraw {#2/#3}}% + {\romannumeral0\xintrawwithzeros {#2/#3}}% }% \def\XINT_igctcv_end_b #1#2{ #2{#1[0]}}% \def\xintCntoF {\romannumeral0\xintcntof }% diff --git a/Master/texmf-dist/tex/generic/xint/xintexpr.sty b/Master/texmf-dist/tex/generic/xint/xintexpr.sty new file mode 100644 index 00000000000..14fc53b418c --- /dev/null +++ b/Master/texmf-dist/tex/generic/xint/xintexpr.sty @@ -0,0 +1,769 @@ +%% +%% This is file `xintexpr.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% xint.dtx (with options: `xintexpr') +%% +%% IMPORTANT NOTICE: +%% +%% For the copyright see the source file. +%% +%% Any modified versions of this file must be renamed +%% with new filenames distinct from xintexpr.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.07a of May 26, 2013) +%% xintexpr: Expandable expression parser +%% 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@xintexpr.sty\endcsname + \expandafter\let\expandafter\w\csname ver@xintfrac.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{xintexpr}{\numexpr not available, aborting input}% + \aftergroup\endinput + \else + \ifx\x\relax % plain-TeX, first loading of xintexpr.sty + \ifx\w\relax % but xintfrac.sty not yet loaded. + \y{xintexpr}{Package xintfrac is required}% + \y{xintexpr}{Will try \string\input\space xintfrac.sty}% + \def\z{\endgroup\input xintfrac.sty\relax}% + \fi + \else + \def\empty {}% + \ifx\x\empty % LaTeX, first loading, + % variable is initialized, but \ProvidesPackage not yet seen + \ifx\w\relax % xintfrac.sty not yet loaded. + \y{xintexpr}{Package xintfrac is required}% + \y{xintexpr}{Will try \string\RequirePackage{xintfrac}}% + \def\z{\endgroup\RequirePackage{xintfrac}}% + \fi + \else + \y{xintexpr}{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@xintfrac.sty\endcsname + \ifx\w\relax % Plain TeX, user gave a file name at the prompt + \y{xintexpr}{Loading of package xintfrac failed, aborting input}% + \aftergroup\endinput + \fi + \ifx\w\empty % LaTeX, user gave a file name at the prompt + \y{xintexpr}{Loading of package xintfrac 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_expr_restorecatcodes_endinput + {% + \catcode94=\the\catcode94 % ^ + \catcode33=\the\catcode33 % ! + \catcode93=\the\catcode93 % ] + \catcode91=\the\catcode91 % [ + \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 + \catcode91=12 % [ + \catcode93=12 % ] + \catcode33=11 % ! + \catcode94=12 % ^ + }% +\x +\begingroup + \catcode64=11 % @ + \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@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 +\def\xint_gob_til_dot #1.{}% +\def\xint_gob_til_dot_andstop #1.{ }% +\def\xint_gob_til_! #1!{}% ! of catcode 11 +\def\XINT_expr_string {\expandafter\xint_gob_til_dot\string }% +\def\XINT_expr_unexpectedtoken {\xintError:ignored }% +\def\xintexpr {\romannumeral0\xinteval }% +\def\xinteval +{% + \expandafter\XINT_expr_until_end\romannumeral-`0% + \expandafter\XINT_expr_checkifprefix_ii\romannumeral-`0% + \XINT_expr_getnext +}% +\def\xinttheexpr {\romannumeral0\xinttheeval }% +\def\xinttheeval {\expandafter\XINT_expr_the\romannumeral0\xinteval }% +\def\XINT_expr_the #1#2#3{\xintraw{\XINT_expr_string #3}}% +\def\xintthe #1{\ifx#1\xintexpr \expandafter\xinttheexpr + \else\expandafter\xintthefloatexpr\fi}% +\def\XINT_expr_until_end #1% +{% + \ifcase#1% + \expandafter\xint_gobble_vi + \or + \expandafter\XINT_expr_extra_closing_paren + \fi + \expandafter\XINT_expr_until_end\romannumeral-`0% +}% +\def\XINT_expr_extra_closing_paren {\xintError:removed }% +\def\XINT_expr_endofexpr {!\XINT_illegaluse }% +\def\XINT_illegaluse + {Illegal_here_use_xintthe\xintError:use_xintthe!\xint_gobble_i }% +\def\XINT_expr_oparen +{% + \expandafter\XINT_expr_until_cparen\romannumeral-`0% + \expandafter\XINT_expr_checkifprefix_ii\romannumeral-`0% + \XINT_expr_getnext +}% +\def\XINT_expr_until_cparen #1% +{% + \ifcase#1% + \expandafter\XINT_expr_missing_cparen + \or + \else \xint_afterfi{\expandafter\XINT_expr_until_cparen\romannumeral-`0}% + \fi +}% +\def\XINT_expr_missing_cparen #1% +{% + \xintError:inserted \xint_c_ \XINT_expr_endofexpr +}% +\def\xint_tmp_def #1#2#3% +{% + \expandafter\xint_tmp_do_defs + \csname XINT_expr_op_#1\expandafter\endcsname + \csname XINT_expr_until_#1\expandafter\endcsname + \csname XINT_expr_checkifprefix_#2\expandafter\endcsname + \csname XINT_expr_precedence_#1\expandafter\endcsname + \csname xint_c_#2\expandafter\endcsname + \csname xint#3\endcsname +}% +\def\xint_tmp_do_defs #1#2#3#4#5#6% +{% + \def #1##1% \XINT_expr_op_? + {% + \expandafter #2\expandafter ##1\romannumeral-`0\expandafter + #3\romannumeral-`0\XINT_expr_getnext + }% + \def #2##1##2##3##4% \XINT_expr_until_? + {% + \ifnum ##2>#5% + \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0##3##4}% + \else + \xint_afterfi + {\expandafter ##2\expandafter ##3% + \csname .#6{\XINT_expr_string ##1}{\XINT_expr_string ##4}\endcsname }% + \fi + }% + \global\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 e{v}{fE}% +\xint_tmp_def E{v}{fE}% +\def\xint_tmp_def #1% +{% + \expandafter\xint_tmp_do_defs + \csname XINT_expr_checkifprefix_#1\expandafter\endcsname + \csname XINT_expr_op_-#1\endcsname +}% +\def\xint_tmp_do_defs #1#2% +{% + \def #1##1% + {\xint_UDsignfork + ##1\dummy #2% + -\dummy ##1% + \krof }% +}% +\xint_tmp_def {ii}% +\xint_tmp_def {iii}% +\xint_tmp_def {iv}% +\xint_tmp_def {v}% +\def\xint_tmp_def #1% +{% + \expandafter\xint_tmp_do_defs + \csname XINT_expr_op_-#1\expandafter\endcsname + \csname XINT_expr_until_-#1\expandafter\endcsname + \csname XINT_expr_checkifprefix_#1\expandafter\endcsname + \csname xint_c_#1\endcsname +}% +\def\xint_tmp_do_defs #1#2#3#4% +{% + \def #1% \XINT_expr_op_-ii,iii,iv,v + {% + \expandafter #2\romannumeral-`0\expandafter + #3\romannumeral-`0\XINT_expr_getnext + }% + \def #2##1##2##3% \XINT_expr_until_-ii,iii,iv,v + {% + \ifnum ##1>#4% + \xint_afterfi {\expandafter #2\romannumeral-`0##2##3}% + \else + \xint_afterfi {\expandafter ##1\expandafter ##2% + \csname .\xintOpp{\XINT_expr_string ##3}\endcsname }% + \fi + }% +}% +\xint_tmp_def {ii}% +\xint_tmp_def {iii}% +\xint_tmp_def {iv}% +\xint_tmp_def {v}% +\def\XINT_expr_getop #1% +{% + \expandafter\XINT_expr_getop_a\expandafter #1\romannumeral-`0% +}% +\def\XINT_expr_getop_a #1#2% +{% + \ifcat #2\relax + \ifx #2\relax + \expandafter\expandafter\expandafter + \XINT_expr_foundendofexpr + \else + \XINT_expr_unexpectedtoken + \expandafter\expandafter\expandafter + \XINT_expr_getop + \fi + \else + \expandafter\XINT_expr_op_found\expandafter #2% + \fi + #1% +}% +\def\XINT_expr_foundendofexpr {\xint_c_ \XINT_expr_endofexpr }% +\def\XINT_expr_op_found #1% +{% + \ifcsname XINT_expr_precedence_\string #1\endcsname + \expandafter\xint_afterfi\expandafter + {\csname XINT_expr_precedence_\string #1\expandafter\endcsname + \csname XINT_expr_op_\string #1\endcsname }% + \else + \XINT_expr_unexpectedtoken + \expandafter\XINT_expr_getop + \fi +}% +\expandafter\let\csname XINT_expr_precedence_)\endcsname \xint_c_i +\expandafter\let\csname XINT_expr_op_)\endcsname\XINT_expr_getop +\def\xint_tmp_def +{% + \expandafter\xint_tmp_do_defs + \csname XINT_expr_precedence_!\expandafter\endcsname + \csname XINT_expr_op_!\endcsname +}% +\def\xint_tmp_do_defs #1#2% +{% + \def #1##1##2% + {\ifx ##1#2% + \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 }% + \let#2\empty +}% +\xint_tmp_def +\def\XINT_expr_getnext +{% + \expandafter\XINT_expr_getnext_checkforbraced_a\romannumeral-`0% +}% +\def\XINT_expr_getnext_checkforbraced_a #1% +{% + \XINT_expr_getnext_checkforbraced_b #1\W\Z {#1}% +}% +\def\XINT_expr_getnext_checkforbraced_b #1#2% +{% + \xint_UDwfork + #1\dummy \XINT_expr_getnext_emptybracepair + #2\dummy \XINT_expr_getnext_onetoken_perhaps + \W\dummy \XINT_expr_getnext_gotbracedstuff + \krof +}% +\def\XINT_expr_getnext_onetoken_perhaps\Z #1% +{% + \expandafter\XINT_expr_getnext_checkforbraced_c\expandafter + {\romannumeral-`0#1}% +}% +\def\XINT_expr_getnext_checkforbraced_c #1% +{% + \XINT_expr_getnext_checkforbraced_d #1\W\Z {#1}% +}% +\def\XINT_expr_getnext_checkforbraced_d #1#2% +{% + \xint_UDwfork + #1\dummy \XINT_expr_getnext_emptybracepair + #2\dummy \XINT_expr_getnext_onetoken_wehope + \W\dummy \XINT_expr_getnext_gotbracedstuff + \krof +}% +\def\XINT_expr_getnext_emptybracepair #1{\XINT_expr_getnext }% +\def\XINT_expr_getnext_gotbracedstuff #1\W\Z #2% +{% + \expandafter\XINT_expr_getop\csname .#2\endcsname +}% +\def\XINT_expr_getnext_onetoken_wehope\Z #1% +{% + \xint_gob_til_! #1\XINT_expr_subexpr !% + \expandafter\XINT_expr_getnext_onetoken_fork\string #1% +}% +\def\XINT_expr_subexpr !#1!{\expandafter\XINT_expr_getop\xint_gobble_i }% +\begingroup +\lccode`*=`_ +\lowercase{\endgroup +\def\XINT_expr_sixwayfork #1(-.+*\dummy #2#3\krof {#2}% +\def\XINT_expr_getnext_onetoken_fork #1% +{% + \XINT_expr_sixwayfork + #1-.+*\dummy \XINT_expr_oparen + (#1.+*\dummy -% + (-#1+*\dummy {\XINT_expr_scannum_start\XINT_expr_scannum_decpart_b.}% + (-.#1*\dummy \XINT_expr_getnext% + (-.+#1\dummy {\XINT_expr_scannum_start\XINT_expr_scannum_decpart_b*}% + (-.+*\dummy {\XINT_expr_scannum_check #1}% + \krof +}}% +\def\XINT_expr_scannum_check #1% +{% + \ifnum \xint_c_ix<1#1 + \expandafter\XINT_expr_scannum_start + \else + \xint_afterfi{\XINT_expr_unexpectedtoken + \expandafter\XINT_expr_getnext\xint_gobble_ii}% + \fi \XINT_expr_scannum_intpart_b #1% +}% +\def\XINT_expr_scannum_stopscan {!}% ! catcode 11 +\def\XINT_expr_gathernum #1!% ! with catcode 11 +{% + \expandafter\space\csname .#1\endcsname +}% +\def\XINT_expr_scannum_start #1% +{% + \expandafter\XINT_expr_getop + \romannumeral-`0\expandafter\XINT_expr_gathernum + \romannumeral-`0#1% +}% +\def\XINT_expr_scannum_intpart_a #1% +{% + \ifnum \xint_c_ix<1\string#1 + \expandafter\expandafter\expandafter + \XINT_expr_scannum_intpart_b + \expandafter\string + \else + \if #1.% + \expandafter\expandafter\expandafter + \XINT_expr_scannum_transition + \else + \expandafter\expandafter\expandafter + \XINT_expr_scannum_stopscan + \fi + \fi + #1% +}% +\def\XINT_expr_scannum_intpart_b #1% +{% + \expandafter #1\romannumeral-`0\expandafter + \XINT_expr_scannum_intpart_a\romannumeral-`0% +}% +\def\XINT_expr_scannum_transition #1% +{% + \expandafter.\romannumeral-`0\expandafter + \XINT_expr_scannum_decpart_a\romannumeral-`0% +}% +\def\XINT_expr_scannum_decpart_a #1% +{% + \ifnum \xint_c_ix<1\string#1 + \expandafter\expandafter\expandafter + \XINT_expr_scannum_decpart_b\expandafter\string + \else + \expandafter \XINT_expr_scannum_stopscan + \fi + #1% +}% +\def\XINT_expr_scannum_decpart_b #1% +{% + \expandafter #1\romannumeral-`0\expandafter + \XINT_expr_scannum_decpart_a\romannumeral-`0% +}% +\def\xintfloatexpr {\romannumeral0\xintfloateval }% +\def\xintfloateval +{% + \expandafter\XINT_expr_until_end\romannumeral-`0% + \expandafter\XINT_flexpr_checkifprefix_ii\romannumeral-`0% + \XINT_flexpr_getnext +}% +\def\xintthefloatexpr {\romannumeral0\xintthefloateval }% +\def\xintthefloateval + {\expandafter\XINT_flexpr_the\romannumeral0\xintfloateval }% +\def\XINT_flexpr_the #1#2#3{\xintfloat{\XINT_expr_string #3}}% +\def\XINT_flexpr_oparen +{% + \expandafter\XINT_expr_until_cparen\romannumeral-`0% + \expandafter\XINT_flexpr_checkifprefix_ii\romannumeral-`0% + \XINT_flexpr_getnext +}% +\def\xint_tmp_def #1#2#3% +{% + \expandafter\xint_tmp_do_defs + \csname XINT_flexpr_op_#1\expandafter\endcsname + \csname XINT_flexpr_until_#1\expandafter\endcsname + \csname XINT_flexpr_checkifprefix_#2\expandafter\endcsname + \csname XINT_expr_precedence_#1\expandafter\endcsname + \csname xint_c_#2\expandafter\endcsname + \csname XINTinFloat#3\endcsname +}% +\def\xint_tmp_do_defs #1#2#3#4#5#6% +{% + \def #1##1% \XINT_flexpr_op_? + {% + \expandafter #2\expandafter ##1\romannumeral-`0\expandafter + #3\romannumeral-`0\XINT_flexpr_getnext + }% + \def #2##1##2##3##4% \XINT_flexpr_until_? + {% + \ifnum ##2>#5% + \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0##3##4}% + \else + \xint_afterfi + {\expandafter ##2\expandafter ##3% + \csname .#6{\XINT_expr_string ##1}% + {\XINT_expr_string ##4}\endcsname }% + \fi + }% +}% +\xint_tmp_def +{ii}{Add}% +\xint_tmp_def -{ii}{Sub}% +\xint_tmp_def *{iii}{Mul}% +\xint_tmp_def /{iii}{Div}% +\xint_tmp_def ^{iv}{Power}% +\xint_tmp_def e{v}{fE}% +\xint_tmp_def E{v}{fE}% +\def\xint_tmp_def #1% +{% + \expandafter\xint_tmp_do_defs + \csname XINT_flexpr_checkifprefix_#1\expandafter\endcsname + \csname XINT_flexpr_op_-#1\endcsname +}% +\def\xint_tmp_do_defs #1#2% +{% + \def #1##1% + {\xint_UDsignfork + ##1\dummy #2% + -\dummy ##1% + \krof }% +}% +\xint_tmp_def {ii}% +\xint_tmp_def {iii}% +\xint_tmp_def {iv}% +\xint_tmp_def {v}% +\def\xint_tmp_def #1% +{% + \expandafter\xint_tmp_do_defs + \csname XINT_flexpr_op_-#1\expandafter\endcsname + \csname XINT_expr_until_-#1\expandafter\endcsname + \csname XINT_flexpr_checkifprefix_#1\expandafter\endcsname + \csname xint_c_#1\endcsname +}% +\def\xint_tmp_do_defs #1#2#3#4% +{% + \def #1% \XINT_flexpr_op_-ii,iii,iv,v + {% + \expandafter #2\romannumeral-`0\expandafter + #3\romannumeral-`0\XINT_flexpr_getnext + }% +}% +\xint_tmp_def {ii}% +\xint_tmp_def {iii}% +\xint_tmp_def {iv}% +\xint_tmp_def {v}% +\let\xint_tmp_def\empty +\let\xint_tmp_do_defs\empty +\def\XINT_flexpr_getop #1% +{% + \expandafter\XINT_flexpr_getop_a\expandafter #1\romannumeral-`0% +}% +\def\XINT_flexpr_getop_a #1#2% +{% + \ifcat #2\relax + \ifx #2\relax + \expandafter\expandafter\expandafter + \XINT_expr_foundendofexpr + \else + \XINT_expr_unexpectedtoken + \expandafter\expandafter\expandafter + \XINT_flexpr_getop + \fi + \else + \expandafter\XINT_flexpr_op_found\expandafter #2% + \fi + #1% +}% +\def\XINT_flexpr_op_found #1% +{% + \ifcsname XINT_expr_precedence_\string #1\endcsname + \expandafter\xint_afterfi\expandafter + {\csname XINT_expr_precedence_\string #1\expandafter\endcsname + \csname XINT_flexpr_op_\string #1\endcsname }% + \else + \XINT_expr_unexpectedtoken + \expandafter\XINT_flexpr_getop + \fi +}% +\expandafter\let\csname XINT_flexpr_op_)\endcsname\XINT_flexpr_getop +\def\XINT_flexpr_getnext +{% + \expandafter\XINT_flexpr_getnext_checkforbraced_a\romannumeral-`0% +}% +\def\XINT_flexpr_getnext_checkforbraced_a #1% +{% + \XINT_flexpr_getnext_checkforbraced_b #1\W\Z {#1}% +}% +\def\XINT_flexpr_getnext_checkforbraced_b #1#2% +{% + \xint_UDwfork + #1\dummy \XINT_flexpr_getnext_emptybracepair + #2\dummy \XINT_flexpr_getnext_onetoken_perhaps + \W\dummy \XINT_flexpr_getnext_gotbracedstuff + \krof +}% +\def\XINT_flexpr_getnext_onetoken_perhaps\Z #1% +{% + \expandafter\XINT_flexpr_getnext_checkforbraced_c\expandafter + {\romannumeral-`0#1}% +}% +\def\XINT_flexpr_getnext_checkforbraced_c #1% +{% + \XINT_flexpr_getnext_checkforbraced_d #1\W\Z {#1}% +}% +\def\XINT_flexpr_getnext_checkforbraced_d #1#2% +{% + \xint_UDwfork + #1\dummy \XINT_flexpr_getnext_emptybracepair + #2\dummy \XINT_flexpr_getnext_onetoken_wehope + \W\dummy \XINT_flexpr_getnext_gotbracedstuff + \krof +}% +\def\XINT_flexpr_getnext_emptybracepair #1{\XINT_flexpr_getnext }% +\def\XINT_flexpr_getnext_gotbracedstuff #1\W\Z #2% +{% + \expandafter\XINT_flexpr_getop\csname .#2\endcsname +}% +\def\XINT_flexpr_getnext_onetoken_wehope\Z #1% +{% + \xint_gob_til_! #1\XINT_flexpr_subexpr !% + \expandafter\XINT_flexpr_getnext_onetoken_fork\string #1% +}% +\def\XINT_flexpr_subexpr !#1!{\expandafter\XINT_flexpr_getop\xint_gobble_i }% +\begingroup +\lccode`*=`_ +\lowercase{\endgroup +\def\XINT_flexpr_getnext_onetoken_fork #1% +{% + \XINT_expr_sixwayfork + #1-.+*\dummy \XINT_flexpr_oparen + (#1.+*\dummy -% + (-#1+*\dummy {\XINT_flexpr_scannum_start\XINT_expr_scannum_decpart_b.}% + (-.#1*\dummy \XINT_flexpr_getnext% + (-.+#1\dummy {\XINT_flexpr_scannum_start\XINT_expr_scannum_decpart_b*}% + (-.+*\dummy {\XINT_flexpr_scannum_check #1}% + \krof +}}% +\def\XINT_flexpr_scannum_check #1% +{% + \ifnum \xint_c_ix<1#1 + \expandafter\XINT_flexpr_scannum_start + \else + \xint_afterfi + {\XINT_expr_unexpectedtoken + \expandafter\XINT_flexpr_getnext\xint_gobble_ii}% + \fi \XINT_expr_scannum_intpart_b #1% +}% +\def\XINT_flexpr_scannum_start #1% +{% + \expandafter\XINT_flexpr_getop + \romannumeral-`0\expandafter\XINT_expr_gathernum + \romannumeral-`0#1% +}% +\catcode`* 13 +\def\xintNewExpr #1[#2]#3% +{% + \begingroup + \ifcase #2\relax + \toks0 {\xdef #1}% + \or \toks0 {\xdef #1##1}% + \or \toks0 {\xdef #1##1##2}% + \or \toks0 {\xdef #1##1##2##3}% + \or \toks0 {\xdef #1##1##2##3##4}% + \or \toks0 {\xdef #1##1##2##3##4##5}% + \or \toks0 {\xdef #1##1##2##3##4##5##6}% + \or \toks0 {\xdef #1##1##2##3##4##5##6##7}% + \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8}% + \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8##9}% + \else + \immediate\write-1{Package xintexpr Error! illegal number of macro + parameters.}% + \fi + \def\xintAdd {:xintAdd}% + \def\xintSub {:xintSub}% + \def\xintMul {:xintMul}% + \def\xintDiv {:xintDiv}% + \def\xintfPow {:xintfPow}% + \def\xintfFac {:xintfFac}% + \def\xintOpp {:xintOpp}% + \def\xintfE {:xintfE}% + \def\xintraw { :romannumeral0:xintraw}% + \def\XINT_expr_the ##1##2##3% + {\expandafter\xintraw + \expandafter{\romannumeral-`0\XINT_expr_string ##3}}% + \lccode`\*=`: \lowercase {\def*}{!noexpand!}% + \catcode`: 13 + \endlinechar -1 + \everyeof {\noexpand }% + \edef\xintNewExprtmp + {\expandafter\scantokens + \expandafter{\romannumeral0\xinttheeval #3\relax}}% + \lccode`\*=`_ \lowercase {\def*}{####}% + \catcode`_ 13 \catcode`! 0 \catcode`: 11 + \the\toks0 {\expandafter\scantokens\expandafter{\xintNewExprtmp }}% +\endgroup +}% +\def\xintNewFloatExpr #1[#2]#3% +{% + \begingroup + \ifcase #2\relax + \toks0 {\xdef #1}% + \or \toks0 {\xdef #1##1}% + \or \toks0 {\xdef #1##1##2}% + \or \toks0 {\xdef #1##1##2##3}% + \or \toks0 {\xdef #1##1##2##3##4}% + \or \toks0 {\xdef #1##1##2##3##4##5}% + \or \toks0 {\xdef #1##1##2##3##4##5##6}% + \or \toks0 {\xdef #1##1##2##3##4##5##6##7}% + \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8}% + \or \toks0 {\xdef #1##1##2##3##4##5##6##7##8##9}% + \else + \immediate\write-1{Package xintexpr Error! illegal number of macro + parameters.}% + \fi + \def\XINTinFloatAdd {:XINTinFloatAdd}% + \def\XINTinFloatSub {:XINTinFloatSub}% + \def\XINTinFloatMul {:XINTinFloatMul}% + \def\XINTinFloatDiv {:XINTinFloatDiv}% + \def\XINTinFloatPower {:XINTinFloatPower}% + \def\xintfFac {:xintfFac}% + \def\xintOpp {:xintOpp}% + \def\XINTinFloatfE {:XINTinFloatfE}% + \def\xintfloat { :romannumeral0:xintfloat}% + \def\XINT_flexpr_the ##1##2##3% + {\expandafter\xintfloat + \expandafter{\romannumeral-`0\XINT_expr_string ##3}}% + \lccode`\*=`: \lowercase {\def*}{!noexpand!}% + \catcode`: 13 + \endlinechar -1 + \everyeof {\noexpand }% + \edef\xintNewExprtmp + {\expandafter\scantokens + \expandafter{\romannumeral0\xintthefloateval #3\relax}}% + \lccode`\*=`_ \lowercase {\def*}{####}% + \catcode`_ 13 \catcode`! 0 \catcode`: 11 + \the\toks0 {\expandafter\scantokens\expandafter{\xintNewExprtmp }}% +\endgroup +}% +\XINT_expr_restorecatcodes_endinput% +\endinput +%% +%% End of file `xintexpr.sty'. diff --git a/Master/texmf-dist/tex/generic/xint/xintfrac.sty b/Master/texmf-dist/tex/generic/xint/xintfrac.sty index a63770ad592..a6678ac73c6 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.06b of May 14, 2013) +%% The xint bundle (version 1.07a of May 26, 2013) %% xintfrac: Expandable operations on fractions %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -166,7 +166,7 @@ \fi \expandafter\x\csname ver@xintfrac.sty\endcsname \ProvidesPackage{xintfrac}% - [2013/05/14 v1.06b Expandable operations on fractions (jfB)]% + [2013/05/26 v1.07a Expandable operations on fractions (jfB)]% \def\xintLen {\romannumeral0\xintlen }% \def\xintlen #1% {% @@ -243,32 +243,52 @@ {% \xint_UDwfork #2\dummy \XINT_frac_A - \W\dummy {\expandafter\XINT_frac_B \romannumeral-`0#2}% + \W\dummy {\expandafter\XINT_frac_U \romannumeral-`0#2}% \krof - #3.\W\Z #1.\W\Z + #3e\W\Z #1e\W\Z }% +\def\XINT_frac_U #1e#2#3\Z +{% + \xint_UDwfork + #2\dummy \XINT_frac_Ua + \W\dummy {\XINT_frac_Ub #2}% + \krof + #3\Z #1\Z +}% +\def\XINT_frac_Ua \Z #1/\W\Z {\XINT_frac_B #1.\W\Z {0}}% +\def\XINT_frac_Ub #1/\W e\W\Z #2\Z {\XINT_frac_B #2.\W\Z {#1}}% \def\XINT_frac_B #1.#2#3\Z {% \xint_UDwfork - #2\dummy \XINT_frac_Ba + #2\dummy \XINT_frac_Ba \W\dummy {\XINT_frac_Bb #2}% \krof #3\Z #1\Z }% -\def\XINT_frac_Bb #1/\W.\W\Z #2\Z +\def\XINT_frac_Ba \Z #1\Z {\XINT_frac_T {0}{#1}}% +\def\XINT_frac_Bb #1.\W\Z #2\Z {% - \expandafter \XINT_frac_C \expandafter + \expandafter \XINT_frac_T \expandafter {\romannumeral0\XINT_length {#1}}{#2#1}% }% -\def\XINT_frac_Ba \Z #1/\W\Z {\XINT_frac_C {0}{#1}}% -\def\XINT_frac_A .\W\Z {\XINT_frac_C {0}{1}}% -\def\XINT_frac_C #1#2#3.#4#5\Z +\def\XINT_frac_A e\W\Z {\XINT_frac_T {0}{1}{0}}% +\def\XINT_frac_T #1#2#3#4e#5#6\Z {% \xint_UDwfork - #4\dummy \XINT_frac_Ca - \W\dummy {\XINT_frac_Cb #4}% + #5\dummy \XINT_frac_Ta + \W\dummy {\XINT_frac_Tb #5}% \krof - #5\Z #3\Z {#1}{#2}% + #6\Z #4\Z {#1}{#2}{#3}% +}% +\def\XINT_frac_Ta \Z #1\Z {\XINT_frac_C #1.\W\Z {0}}% +\def\XINT_frac_Tb #1e\W\Z #2\Z {\XINT_frac_C #2.\W\Z {#1}}% +\def\XINT_frac_C #1.#2#3\Z +{% + \xint_UDwfork + #2\dummy \XINT_frac_Ca + \W\dummy {\XINT_frac_Cb #2}% + \krof + #3\Z #1\Z }% \def\XINT_frac_Ca \Z #1\Z {\XINT_frac_D {0}{#1}}% \def\XINT_frac_Cb #1.\W\Z #2\Z @@ -276,14 +296,14 @@ \expandafter\XINT_frac_D\expandafter {\romannumeral0\XINT_length {#1}}{#2#1}% }% -\def\XINT_frac_D #1#2#3#4% +\def\XINT_frac_D #1#2#3#4#5#6% {% \expandafter \XINT_frac_E \expandafter - {\the\numexpr -#1+#3\expandafter}\expandafter + {\the\numexpr -#1+#3+#4-#6\expandafter}\expandafter {\romannumeral0\XINT_num_loop #2% \xint_relax\xint_relax\xint_relax\xint_relax \xint_relax\xint_relax\xint_relax\xint_relax\Z }% - {\romannumeral0\XINT_num_loop #4% + {\romannumeral0\XINT_num_loop #5% \xint_relax\xint_relax\xint_relax\xint_relax \xint_relax\xint_relax\xint_relax\xint_relax\Z }% }% @@ -407,21 +427,27 @@ {% \expandafter\XINT_raw\romannumeral0\XINT_infrac }% -\def\XINT_raw #1% +\def\XINT_raw #1#2#3{ #2/#3[#1]}% +\def\xintRawWithZeros {\romannumeral0\xintrawwithzeros }% +\def\xintrawwithzeros +{% + \expandafter\XINT_rawz\romannumeral0\XINT_infrac +}% +\def\XINT_rawz #1% {% \ifcase\XINT_Sgn {#1} - \expandafter\XINT_raw_Ba + \expandafter\XINT_rawz_Ba \or - \expandafter\XINT_raw_A + \expandafter\XINT_rawz_A \else - \expandafter\XINT_raw_Ba + \expandafter\XINT_rawz_Ba \fi {#1}% }% -\def\XINT_raw_A #1#2#3{\xint_dsh {#2}{-#1}/#3}% -\def\XINT_raw_Ba #1#2#3{\expandafter\XINT_raw_Bb +\def\XINT_rawz_A #1#2#3{\xint_dsh {#2}{-#1}/#3}% +\def\XINT_rawz_Ba #1#2#3{\expandafter\XINT_rawz_Bb \expandafter{\romannumeral0\xint_dsh {#3}{#1}}{#2}}% -\def\XINT_raw_Bb #1#2{ #2/#1}% +\def\XINT_rawz_Bb #1#2{ #2/#1}% \def\xintNumerator {\romannumeral0\xintnumerator }% \def\xintnumerator {% @@ -593,10 +619,30 @@ {\the\numexpr #3+#4-#2}{#1}{#5}% }% \def\XINT_rez_E #1#2#3{ #3/#2[#1]}% +\def\xintE {\romannumeral0\xinte }% +\def\xinte #1% +{% + \expandafter\XINT_e \romannumeral0\XINT_infrac {#1}% +}% +\def\XINT_e #1#2#3#4% +{% + \expandafter\XINT_e_end\expandafter{\the\numexpr #1+#4}{#2}{#3}% +}% +\def\xintfE {\romannumeral0\xintfe }% +\def\xintfe #1% +{% + \expandafter\XINT_fe \romannumeral0\XINT_infrac {#1}% +}% +\def\XINT_fe #1#2#3#4% +{% + \expandafter\XINT_e_end\expandafter{\the\numexpr #1+\xintNum{#4}}{#2}{#3}% +}% +\def\XINT_e_end #1#2#3{ #2/#3[#1]}% +\let\XINTinFloatfE\xintfE \def\xintIrr {\romannumeral0\xintirr }% \def\xintirr #1% {% - \expandafter\XINT_irr_start\romannumeral0\xintraw {#1}\Z + \expandafter\XINT_irr_start\romannumeral0\xintrawwithzeros {#1}\Z }% \def\XINT_irr_start #1#2/#3\Z {% @@ -666,10 +712,15 @@ \xintError:NotAnInteger \space #1% }% +\def\xintfFac {\romannumeral0\xintffac }% +\def\xintffac #1% +{% + \expandafter\XINT_fac_fork\expandafter{\the\numexpr \xintNum{#1}}% +}% \def\xintJrr {\romannumeral0\xintjrr }% \def\xintjrr #1% {% - \expandafter\XINT_jrr_start\romannumeral0\xintraw {#1}\Z + \expandafter\XINT_jrr_start\romannumeral0\xintrawwithzeros {#1}\Z }% \def\XINT_jrr_start #1#2/#3\Z {% @@ -826,7 +877,7 @@ \def\XINT_trunc_Hb #1#2#3% {% \expandafter #3\expandafter0\expandafter.% - \romannumeral0\XINT_dsx_zeroloop {#1}\Z {}#2% #1=-0 possible! + \romannumeral0\XINT_dsx_zeroloop {#1}{}\Z {}#2% #1=-0 possible! }% \def\xintRound {\romannumeral0\xintround }% \def\xintiRound {\romannumeral0\xintiround }% @@ -892,6 +943,241 @@ {% \XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z \Z }% +\mathchardef\XINT_digits 16 +\def\xintDigits #1#2% + {\afterassignment \xint_gobble_i \mathchardef\XINT_digits=}% +\def\xinttheDigits {\number\XINT_digits }% +\def\xintFloat {\romannumeral0\xintfloat }% +\def\xintfloat #1{\XINT_float_chkopt #1\Z }% +\def\XINT_float_chkopt #1% +{% + \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}% +}% +\def\XINT_float_a #1#2% +{% + \expandafter\XINT_float_b \romannumeral0\XINT_infrac {#2}{#1}% +}% +\def\XINT_float_b #1#2#3% +{% + \XINT_float_fork #2\Z {#3}{#1}% +}% +\def\XINT_float_fork #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_float_zero + 0#1\dummy \XINT_float_N + 0-\dummy {\XINT_float_P #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 +{% + \expandafter\XINT_float_atleastone_c\romannumeral0\XINT_trunc_B +}% +\def\XINT_float_atleastone_c #1\Z #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}% +}% +\def\XINT_float_lessthanone_b #1#2#3% +{% + \expandafter\XINT_float_lessthanone_c + \romannumeral0\XINT_trunc_B {#1}{#3}{#2}% +}% +\def\XINT_float_lessthanone_c #1\Z #2% +{% + \expandafter\XINT_float_c\expandafter + {\expandafter-\romannumeral0\xintilen {\xintiSub {#1}{1}}}% +}% +\def\XINT_float_c #1#2#3#4% +{% + \expandafter\XINT_float_d\expandafter + {\the\numexpr #2-#1}{#3}{#4}e#1% +}% +\def\XINT_float_d +{% + \expandafter\XINT_float_round_B\romannumeral0\XINT_trunc_B +}% +\def\XINT_float_round_B #1#2\Z #3% +{% + \ifnum #1=9 + \xint_afterfi + {\romannumeral0\XINT_rord_main {}#1#2\XINT_float_round_S}% + \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 +}% +\def\XINT_float_round_D #1% +{% + \ifnum #1<5 + \expandafter\XINT_float_round_Da + \else + \expandafter\XINT_float_round_Db + \fi +}% +\def\XINT_float_round_Da #1\Z +{% + \expandafter\XINT_float_round_f + \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_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 +}% +\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 +}% +\def\XINT_float_round_g #1% +{% + \ifnum #1=1 \expandafter\XINT_float_round_h\fi + \space #1.% +}% +\def\XINT_float_round_h\space 1.0{ 10.}% +\def\XINT_inFloat [#1]% +{% + \expandafter\XINT_infloat\expandafter {\the\numexpr #1}% +}% +\def\XINT_infloat #1#2% +{% + \expandafter\XINT_infloat_a \romannumeral0\XINT_infrac {#2}{#1}% +}% +\def\XINT_infloat_a #1#2#3% +{% + \XINT_infloat_fork #2\Z {#3}{#1}% +}% +\def\XINT_infloat_fork #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_infloat_zero + 0#1\dummy \XINT_infloat_N + 0-\dummy {\XINT_infloat_P #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% +{% + \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}% +}% +\def\XINT_infloat_d +{% + \expandafter\XINT_infloat_round_B\romannumeral0\XINT_trunc_B +}% +\def\XINT_infloat_round_B #1\Z #2% +{% + \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 +}% +\def\XINT_infloat_round_D #1% +{% + \ifnum #1<5 + \expandafter\XINT_infloat_round_Da + \else + \expandafter\XINT_infloat_round_Db + \fi +}% +\def\XINT_infloat_round_Da #1\Z +{% + \expandafter\XINT_infloat_round_f + \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 +}% +\def\XINT_infloat_round_Db #1\Z +{% + \expandafter\XINT_infloat_round_f + \romannumeral0\XINT_addm_A 0{}1000\W\X\Y\Z #1000\W\X\Y\Z \Z +}% +\def\XINT_infloat_round_f #1\Z #2#3% +{% + \expandafter\XINT_infloat_round_g\expandafter + {\the\numexpr #2-#3+1}{#1}% +}% +\def\XINT_infloat_round_g #1#2{#2[#1]}% \def\xintAdd {\romannumeral0\xintadd }% \def\xintadd #1% {% @@ -1002,10 +1288,19 @@ {% \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 {% \xint_UDzerominusfork @@ -1098,6 +1393,34 @@ {\romannumeral0\xintimul {\xintDSH {\the\numexpr -#3+#1\relax}{#6}}{#5}}% {\romannumeral0\xintimul {#7}{\xintDSH {\the\numexpr -#2+#1\relax}{#4}}}% }% +\def\xintGeq {\romannumeral0\xintgeq }% +\def\xintgeq #1% +{% + \expandafter\xint_fgeq\expandafter {\romannumeral0\XINT_infrac {#1}}% +}% +\def\xint_fgeq #1#2% +{% + \expandafter\XINT_fgeq_A \romannumeral0\XINT_infrac {#2}#1% +}% +\def\XINT_fgeq_A #1#2#3#4% +{% + \ifnum #4 > #1 + \xint_afterfi {\XINT_fgeq_B {#1}}% + \else + \xint_afterfi {\XINT_fgeq_B {#4}}% + \fi + {#1}{#4}{#2}{#3}% +}% +\def\XINT_fgeq_B #1#2#3#4#5#6#7% +{% + \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}}}% +}% +\def\XINT_fgeq_C #1#2% +{% + \expandafter\XINT_geq_fork #2\Z #1\Z +}% \def\xintMax {\romannumeral0\xintmax }% \def\xintmax #1% {% @@ -1183,15 +1506,6 @@ \expandafter\xint_fsgn\romannumeral0\XINT_infrac {#1}% }% \def\xint_fsgn #1#2#3{\xintisgn {#2}}% -\def\xintGeq {\romannumeral0\xintgeq }% -\def\xintgeq #1% -{% - \expandafter\xint_xgeq\expandafter{\romannumeral0\xintnum {#1}}% -}% -\def\xint_xgeq #1#2% -{% - \expandafter\XINT_geq_fork\romannumeral0\xintnum {#2}\Z #1\Z -}% \def\xintDivision {\romannumeral0\xintdivision }% \def\xintdivision #1% {% @@ -1244,6 +1558,365 @@ \xint_afterfi{ 0}% \fi }% +\def\xintFloatAdd {\romannumeral0\xintfloatadd }% +\def\xintfloatadd #1{\XINT_fladd_chkopt \xintfloat #1\Z }% +\def\XINTinFloatAdd {\romannumeral-`0\XINTinfloatadd }% +\def\XINTinfloatadd #1{\XINT_fladd_chkopt \XINT_inFloat #1\Z }% +\def\XINT_fladd_chkopt #1#2% +{% + \ifx #2[\expandafter\XINT_fladd_opt + \else\expandafter\XINT_fladd_noopt + \fi #1#2% +}% +\def\XINT_fladd_noopt #1#2\Z #3% +{% + #1[\XINT_digits]{\XINT_FL_Add {\XINT_digits+2}{#2}{#3}}% +}% +\def\XINT_fladd_opt #1[\Z #2]#3#4% +{% + #1[#2]{\XINT_FL_Add {#2+2}{#3}{#4}}% +}% +\def\XINT_FL_Add #1#2% +{% + \expandafter\XINT_FL_Add_a\expandafter{\the\numexpr #1\expandafter}% + \expandafter{\romannumeral-`0\XINT_inFloat [#1]{#2}}% +}% +\def\XINT_FL_Add_a #1#2#3% +{% + \expandafter\XINT_FL_Add_b\romannumeral-`0\XINT_inFloat [#1]{#3}#2{#1}% +}% +\def\XINT_FL_Add_b #1% +{% + \xint_gob_til_zero #1\XINT_FL_Add_zero 0\XINT_FL_Add_c #1% +}% +\def\XINT_FL_Add_c #1[#2]#3% +{% + \xint_gob_til_zero #3\XINT_FL_Add_zerobis 0\XINT_FL_Add_d #1[#2]#3% +}% +\def\XINT_FL_Add_d #1[#2]#3[#4]#5% +{% + \xintSgnFork {\ifnum \numexpr #2-#4-#5>1 \expandafter 1% + \else\ifnum \numexpr #4-#2-#5>1 + \xint_afterfi {\expandafter-\expandafter1}% + \else \expandafter\expandafter\expandafter0% + \fi + \fi}% + {#3[#4]}{\xintAdd {#1[#2]}{#3[#4]}}{#1[#2]}% +}% +\def\XINT_FL_Add_zero 0\XINT_FL_Add_c 0[0]#1[#2]#3{#1[#2]}% +\def\XINT_FL_Add_zerobis 0\XINT_FL_Add_d #1[#2]0[0]#3{#1[#2]}% +\def\xintFloatSub {\romannumeral0\xintfloatsub }% +\def\xintfloatsub #1{\XINT_flsub_chkopt \xintfloat #1\Z }% +\def\XINTinFloatSub {\romannumeral-`0\XINTinfloatsub }% +\def\XINTinfloatsub #1{\XINT_flsub_chkopt \XINT_inFloat #1\Z }% +\def\XINT_flsub_chkopt #1#2% +{% + \ifx #2[\expandafter\XINT_flsub_opt + \else\expandafter\XINT_flsub_noopt + \fi #1#2% +}% +\def\XINT_flsub_noopt #1#2\Z #3% +{% + #1[\XINT_digits]{\XINT_FL_Add {\XINT_digits+2}{#2}{\xintOpp{#3}}}% +}% +\def\XINT_flsub_opt #1[\Z #2]#3#4% +{% + #1[#2]{\XINT_FL_Add {#2+2}{#3}{\xintOpp{#4}}}% +}% +\def\xintFloatMul {\romannumeral0\xintfloatmul}% +\def\xintfloatmul #1{\XINT_flmul_chkopt \xintfloat #1\Z }% +\def\XINTinFloatMul {\romannumeral-`0\XINTinfloatmul }% +\def\XINTinfloatmul #1{\XINT_flmul_chkopt \XINT_inFloat #1\Z }% +\def\XINT_flmul_chkopt #1#2% +{% + \ifx #2[\expandafter\XINT_flmul_opt + \else\expandafter\XINT_flmul_noopt + \fi #1#2% +}% +\def\XINT_flmul_noopt #1#2\Z #3% +{% + #1[\XINT_digits]{\XINT_FL_Mul {\XINT_digits+2}{#2}{#3}}% +}% +\def\XINT_flmul_opt #1[\Z #2]#3#4% +{% + #1[#2]{\XINT_FL_Mul {#2+2}{#3}{#4}}% +}% +\def\XINT_FL_Mul #1#2% +{% + \expandafter\XINT_FL_Mul_a\expandafter{\the\numexpr #1\expandafter}% + \expandafter{\romannumeral-`0\XINT_inFloat [#1]{#2}}% +}% +\def\XINT_FL_Mul_a #1#2#3% +{% + \expandafter\XINT_FL_Mul_b\romannumeral-`0\XINT_inFloat [#1]{#3}#2% +}% +\def\XINT_FL_Mul_b #1[#2]#3[#4]{\xintE{\xintiMul {#1}{#3}}{#2+#4}}% +\def\xintFloatDiv {\romannumeral0\xintfloatdiv}% +\def\xintfloatdiv #1{\XINT_fldiv_chkopt \xintfloat #1\Z }% +\def\XINTinFloatDiv {\romannumeral-`0\XINTinfloatdiv }% +\def\XINTinfloatdiv #1{\XINT_fldiv_chkopt \XINT_inFloat #1\Z }% +\def\XINT_fldiv_chkopt #1#2% +{% + \ifx #2[\expandafter\XINT_fldiv_opt + \else\expandafter\XINT_fldiv_noopt + \fi #1#2% +}% +\def\XINT_fldiv_noopt #1#2\Z #3% +{% + #1[\XINT_digits]{\XINT_FL_Div {\XINT_digits+2}{#2}{#3}}% +}% +\def\XINT_fldiv_opt #1[\Z #2]#3#4% +{% + #1[#2]{\XINT_FL_Div {#2+2}{#3}{#4}}% +}% +\def\XINT_FL_Div #1#2% +{% + \expandafter\XINT_FL_Div_a\expandafter{\the\numexpr #1\expandafter}% + \expandafter{\romannumeral-`0\XINT_inFloat [#1]{#2}}% +}% +\def\XINT_FL_Div_a #1#2#3% +{% + \expandafter\XINT_FL_Div_b\romannumeral-`0\XINT_inFloat [#1]{#3}#2% +}% +\def\XINT_FL_Div_b #1[#2]#3[#4]{\xintE{#3/#1}{#4-#2}}% +\def\xintFloatPow {\romannumeral0\xintfloatpow}% +\def\xintfloatpow #1{\XINT_flpow_chkopt \xintfloat #1\Z }% +\def\XINTinFloatPow {\romannumeral-`0\XINTinfloatpow }% +\def\XINTinfloatpow #1{\XINT_flpow_chkopt \XINT_inFloat #1\Z }% +\def\XINT_flpow_chkopt #1#2% +{% + \ifx #2[\expandafter\XINT_flpow_opt + \else\expandafter\XINT_flpow_noopt + \fi + #1#2% +}% +\def\XINT_flpow_noopt #1#2\Z #3% +{% + \expandafter\XINT_flpow_checkB_start\expandafter + {\the\numexpr #3\expandafter}\expandafter + {\the\numexpr \XINT_digits}{#2}{#1[\XINT_digits]}% +}% +\def\XINT_flpow_opt #1[\Z #2]#3#4% +{% + \expandafter\XINT_flpow_checkB_start\expandafter + {\the\numexpr #4\expandafter}\expandafter + {\the\numexpr #2}{#3}{#1[#2]}% +}% +\def\XINT_flpow_checkB_start #1{\XINT_flpow_checkB_a #1\Z }% +\def\XINT_flpow_checkB_a #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_flpow_BisZero + 0#1\dummy {\XINT_flpow_checkB_b 1}% + 0-\dummy {\XINT_flpow_checkB_b 0#1}% + \krof +}% +\def\XINT_flpow_BisZero \Z #1#2#3{#3{1/1[0]}}% +\def\XINT_flpow_checkB_b #1#2\Z #3% +{% + \expandafter\XINT_flpow_checkB_c \expandafter + {\romannumeral0\XINT_length{#2}}{#3}{#2}#1% +}% +\def\XINT_flpow_checkB_c #1#2% +{% + \expandafter\XINT_flpow_checkB_d \expandafter + {\the\numexpr \expandafter\XINT_Length\expandafter + {\the\numexpr #1*20/3}+#1+#2+1}% +}% +\def\XINT_flpow_checkB_d #1#2#3#4% +{% + \expandafter \XINT_flpow_a + \romannumeral-`0\XINT_inFloat [#1]{#4}{#1}{#2}#3% +}% +\def\XINT_flpow_a #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_flpow_zero + 0#1\dummy {\XINT_flpow_b 1}% + 0-\dummy {\XINT_flpow_b 0#1}% + \krof +}% +\def\XINT_flpow_zero [#1]#2#3#4#5% +{% + \if #41 \xint_afterfi {\xintError:DivisionByZero\space 1.e2147483647}% + \else \xint_afterfi { 0.e0}\fi +}% +\def\XINT_flpow_b #1#2[#3]#4#5% +{% + \XINT_flpow_c {#4}{#5}{#2[#3]}{#1*\ifodd #5 1\else 0\fi}% +}% +\def\XINT_flpow_c #1#2#3#4% +{% + \XINT_flpow_loop {#1}{#2}{#3}{{#1}}\XINT_flpow_prd + \xint_relax + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_relax {#4}% +}% +\def\XINT_flpow_loop #1#2#3% +{% + \ifnum #2 = 1 + \expandafter\XINT_flpow_loop_end + \else + \xint_afterfi{\expandafter\XINT_flpow_loop_a + \expandafter{\the\numexpr 2*(#2/2)-#2\expandafter }% b mod 2 + \expandafter{\the\numexpr #2-#2/2\expandafter }% [b/2] + \expandafter{\romannumeral-`0\XINTinfloatmul [#1]{#3}{#3}}}% + \fi + {#1}{{#3}}% +}% +\def\XINT_flpow_loop_a #1#2#3#4% +{% + \ifnum #1 = 1 + \expandafter\XINT_flpow_loop + \else + \expandafter\XINT_flpow_loop_throwaway + \fi + {#4}{#2}{#3}% +}% +\def\XINT_flpow_loop_throwaway #1#2#3#4% +{% + \XINT_flpow_loop {#1}{#2}{#3}% +}% +\def\XINT_flpow_loop_end #1{\romannumeral0\XINT_rord_main {}\relax }% +\def\XINT_flpow_prd #1#2% +{% + \XINT_flpow_prd_getnext {#2}{#1}% +}% +\def\XINT_flpow_prd_getnext #1#2#3% +{% + \XINT_flpow_prd_checkiffinished #3\Z {#1}{#2}% +}% +\def\XINT_flpow_prd_checkiffinished #1% +{% + \xint_gob_til_relax #1\XINT_flpow_prd_end\relax + \XINT_flpow_prd_compute #1% +}% +\def\XINT_flpow_prd_compute #1\Z #2#3% +{% + \expandafter\XINT_flpow_prd_getnext\expandafter + {\romannumeral-`0\XINTinfloatmul [#3]{#1}{#2}}{#3}% +}% +\def\XINT_flpow_prd_end\relax\XINT_flpow_prd_compute + \relax\Z #1#2#3% +{% + \expandafter\XINT_flpow_conclude \the\numexpr #3\relax #1% +}% +\def\XINT_flpow_conclude #1#2[#3]#4% +{% + \expandafter\XINT_flpow_conclude_really\expandafter + {\the\numexpr\if #41 -\fi#3\expandafter}% + \xint_UDzerofork + #4\dummy {{#2}}% + 0\dummy {{1/#2}}% + \krof #1% +}% +\def\XINT_flpow_conclude_really #1#2#3#4% +{% + \xint_UDzerofork + #3\dummy {#4{#2[#1]}}% + 0\dummy {#4{-#2[#1]}}% + \krof +}% +\def\xintFloatPower {\romannumeral0\xintfloatpower}% +\def\xintfloatpower #1{\XINT_flpower_chkopt \xintfloat #1\Z }% +\def\XINTinFloatPower {\romannumeral-`0\XINTinfloatpower}% +\def\XINTinfloatpower #1{\XINT_flpower_chkopt \XINT_inFloat #1\Z }% +\def\XINT_flpower_chkopt #1#2% +{% + \ifx #2[\expandafter\XINT_flpower_opt + \else\expandafter\XINT_flpower_noopt + \fi + #1#2% +}% +\def\XINT_flpower_noopt #1#2\Z #3% +{% + \expandafter\XINT_flpower_checkB_start\expandafter + {\the\numexpr \XINT_digits\expandafter}\expandafter + {\romannumeral0\xintnum{#3}}{#2}{#1[\XINT_digits]}% +}% +\def\XINT_flpower_opt #1[\Z #2]#3#4% +{% + \expandafter\XINT_flpower_checkB_start\expandafter + {\the\numexpr #2\expandafter}\expandafter + {\romannumeral0\xintnum{#4}}{#3}{#1[#2]}% +}% +\def\XINT_flpower_checkB_start #1#2{\XINT_flpower_checkB_a #2\Z {#1}}% +\def\XINT_flpower_checkB_a #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_flpower_BisZero + 0#1\dummy {\XINT_flpower_checkB_b 1}% + 0-\dummy {\XINT_flpower_checkB_b 0#1}% + \krof +}% +\def\XINT_flpower_BisZero \Z #1#2#3{#3{1/1[0]}}% +\def\XINT_flpower_checkB_b #1#2\Z #3% +{% + \expandafter\XINT_flpower_checkB_c \expandafter + {\romannumeral0\XINT_length{#2}}{#3}{#2}#1% +}% +\def\XINT_flpower_checkB_c #1#2% +{% + \expandafter\XINT_flpower_checkB_d \expandafter + {\the\numexpr \expandafter\XINT_Length\expandafter + {\the\numexpr #1*20/3}+#1+#2+1}% +}% +\def\XINT_flpower_checkB_d #1#2#3#4% +{% + \expandafter \XINT_flpower_a + \romannumeral-`0\XINT_inFloat [#1]{#4}{#1}{#2}#3% +}% +\def\XINT_flpower_a #1% +{% + \xint_UDzerominusfork + #1-\dummy \XINT_flpower_zero + 0#1\dummy {\XINT_flpower_b 1}% + 0-\dummy {\XINT_flpower_b 0#1}% + \krof +}% +\def\XINT_flpower_zero [#1]#2#3#4#5% +{% + \if #41 + \xint_afterfi {\xintError:DivisionByZero\space 1.e2147483647}% + \else \xint_afterfi { 0.e0}\fi +}% +\def\XINT_flpower_b #1#2[#3]#4#5% +{% + \XINT_flpower_c {#4}{#5}{#2[#3]}{#1*\xintOdd {#5}}% +}% +\def\XINT_flpower_c #1#2#3#4% +{% + \XINT_flpower_loop {#1}{#2}{#3}{{#1}}\XINT_flpow_prd + \xint_relax + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_undef\xint_undef\xint_undef\xint_undef + \xint_relax {#4}% +}% +\def\XINT_flpower_loop #1#2#3% +{% + \ifcase\XINT_isOne {#2} + \xint_afterfi{\expandafter\XINT_flpower_loop_x\expandafter + {\romannumeral-`0\XINTinfloatmul [#1]{#3}{#3}}% + {\romannumeral0\xintdivision {#2}{2}}}% + \or \expandafter\XINT_flpow_loop_end + \fi + {#1}{{#3}}% +}% +\def\XINT_flpower_loop_x #1#2{\expandafter\XINT_flpower_loop_a #2{#1}}% +\def\XINT_flpower_loop_a #1#2#3#4% +{% + \ifnum #2 = 1 + \expandafter\XINT_flpower_loop + \else + \expandafter\XINT_flpower_loop_throwaway + \fi + {#4}{#1}{#3}% +}% +\def\XINT_flpower_loop_throwaway #1#2#3#4% +{% + \XINT_flpower_loop {#1}{#2}{#3}% +}% \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 77bee301efe..702fa0c78a5 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.06b of May 14, 2013) +%% The xint bundle (version 1.07a of May 26, 2013) %% xintgcd: Euclidean algorithm with xint package %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -164,7 +164,7 @@ \fi \expandafter\x\csname ver@xintgcd.sty\endcsname \ProvidesPackage{xintgcd}% - [2013/05/14 v1.06b Euclide algorithm with xint package (jfB)]% + [2013/05/26 v1.07a 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 7d6c1bc0901..f1b6d882e85 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.06b of May 14, 2013) +%% The xint bundle (version 1.07a of May 26, 2013) %% xintseries: Expandable partial sums with xint package %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -164,7 +164,7 @@ \fi \expandafter\x\csname ver@xintseries.sty\endcsname \ProvidesPackage{xintseries}% - [2013/05/14 v1.06b Expandable partial sums with xint package (jfB)]% + [2013/05/26 v1.07a Expandable partial sums with xint package (jfB)]% \def\xintSeries {\romannumeral0\xintseries }% \def\xintseries #1#2% {% -- cgit v1.2.3