% -*- coding: utf-8; time-stamp-format: "%02d-%02m-%:y at %02H:%02M:%02S %Z" -*- % This file: xint.dtx. Proudly produced by xint-dtxbuild.sh. % Extract all files via "etex xint.dtx" and do "make help" % or follow instructions from extracted README.md. %<*dtx> \def\xintdtxtimestamp {Time-stamp: <05-12-2017 at 19:31:43 CET>} % %<*drv> %% --------------------------------------------------------------- \def\xintdocdate {2017/12/05} \def\xintbndldate{2017/12/05} \def\xintbndlversion {1.2p} % %% README %% CHANGE LOG %% xint 1.2p %% 2017/12/05 % % Source: xint.dtx 1.2p 2017/12/05 (doc 2017/12/05) % Author: Jean-Francois Burnol % Info: Expandable operations on big integers, decimals, fractions % License: LPPL 1.3c % %<*!readme&!changes&!dohtmlsh&!dopdfsh&!makefile> %% --------------------------------------------------------------- %% The xint bundle 1.2p 2017/12/05 %% Copyright (C) 2013-2017 by Jean-Francois Burnol %%% xintkernel: Paraphernalia for the xint packages %%% xinttools: Expandable and non-expandable utilities %%% xintcore: Expandable arithmetic on big integers %%% xint: Expandable operations on big integers %%% xintfrac: Expandable operations on fractions %%% xintexpr: Expandable expression parser %%% xintbinhex: Expandable binary and hexadecimal conversions %%% xintgcd: Euclidean algorithm with xint package %%% xintseries: Expandable partial sums with xint package %%% xintcfrac: Expandable continued fractions with xint package %% --------------------------------------------------------------- % %<*dtx> \bgroup\catcode2 0 \catcode`\\ 12 ^^Biffalse % %<*readme>-------------------------------------------------------- This `README` is also available as `README.pdf` and `README.html`. Change log is to be found in `CHANGES.pdf` or `CHANGES.html`. The user manual is `xint.pdf`, and the commented source code is available as `sourcexint.pdf`. Aim === The basic aim is provide *expandable* computations on integers, fractions, and floating point numbers. For example \xinttheexpr reduce(37189719/183618963+11390170/17310720)^17\relax will evaluate exactly the fraction; the result has 462 characters (including the fraction slash.) One can also work with dummy variables: \xinttheexpr mul(add(x(x+1)(x+2), x=y..y+15), y=171286,98762,9296)\relax evaluates to `15979066346135829902328007959448563667099190784`. Float computations are possible at an adjustable precision (default 16). \xintDigits:=48;\xintthefloatexpr 123_456_789^1_000.5\relax ->3.63692761822782679930738270515740797370813691938e8095 But currently, only integer and half-integer exponents are allowed for the power operation in expressions and only the square-root operation is implemented besides the four arithmetic operations. Square-root and the four operations achieve correct rounding in the given arbitrary precision. Sub-units `xintcore`, `xint` and `xintfrac` provide the underlying macros, and `xintexpr` loads all of them and provides expandable parsers allowing computations such as the above (and more). Usage ===== It is possible to use the package with Plain (via `\input` anywhere) or with LaTeX (via `\usepackage` in the preamble). ## With LaTeX \usepackage{xint} % expandable arithmetic with big integers \usepackage{xintfrac} % decimal numbers, fractions, floats \usepackage{xintexpr} % expressions with infix operators Further packages: `xintbinhex`, `xintgcd`, `xintseries` and `xintcfrac`. Main dependencies are handled automatically. For example `xintexpr` automatically loads `xintfrac` which itself loads `xint`; but use of the `gcd` and `lcm` functions in expressions require explicit loading of `xintgcd`, and hexadecimal notation requires explicit loading of `xintbinhex`. Package `xintcore` is the subset of `xint` providing only the five operations on big integers: `\xintiiAdd`, `\xintiiMul`, ... It is (by default) loaded by the (LaTeX only) package [bnumexpr](http://www.ctan.org/pkg/bnumexpr) which provides a more light-weight expression parser handling only big integers, the four operations, the power operation and the factorial. There is also `xinttools` which is a separate package providing, among others, expandable and non-expandable loops such as `\xintFor`. ## With TeX One does for example: \input xintexpr.sty The packages may be loaded in any catcode context such that letters, digits, `\` and `%` have their standard catcodes. `xintcore.sty` and `xinttools.sty` both import `xintkernel.sty` which has the catcode handler and package identifier and defines a few utilities such as `\oodef`, `\fdef`, or `\xint_dothis/\xint_orthat`. Installation ============ ## Method A: using the package manager of your TeX distribution `xint` is included in [TeXLive](http://tug.org/texlive/) (hence also [MacTeX](http://tug.org/mactex/)) and [MikTeX](http://www.miktex.org/). There can be a few days of delay between apparition of a new version on [CTAN](http://www.ctan.org/pkg/xint) and availability via the distribution package manager. ## Method B: manual installation using `xint.tds.zip` and `unzip` Assumes a GNU/Linux-like system (or Mac OS X). 1. obtain `xint.tds.zip` from CTAN: 2. cd to the download repertory and issue: unzip xint.tds.zip -d where `` is a suitable TDS-compliant destination repertory. For example, with TeXLive: - Linux, standard access rights, hence sudo is needed, installation into the "local" tree: sudo unzip xint.tds.zip -d /usr/local/texlive/texmf-local sudo texhash /usr/local/texlive/texmf-local - Mac OS X, installation into user home folder (no sudo needed, and it is recommended to not have a ls-R file there, hence no texhash): unzip xint.tds.zip -d ~/Library/texmf ## Method C: manual installation using `Makefile` and `xint.dtx` The Makefile automatizes rebuilding from `xint.dtx` all documentation files as well as `xint.tds.zip`. It is for GNU/Linux-like (inc. Mac OS X) systems, with a teTeX like installation such as TeXLive. Furthermore the [Pandoc](http://johnmacfarlane.net/pandoc/) software is required. 1. obtain `xint.dtx` and `Makefile` from . 2. put them in an otherwise empty working repertory, run `make` or equivalently `make help` for further instructions. ## Method D: installation starting with only `xint.dtx` Run `"tex xint.dtx"` or `"etex xint.dtx"` to extract from `xint.dtx` all packages as well as these files: `README.md` : the current README with Markdown formatting. `CHANGES.md` : the changes across successive releases. `xint.tex` : used to generate `xint.pdf` via `"latex xint.tex"` (thrice) then `"dvipdfmx xint.dvi"`. It is also possible to compile `xint.tex` with `xelatex`, or with `pdflatex` (this latter option produces a bigger pdf). : For successful compilation, packages `newtxtt`, `newtxmath`, `etoc`, `mathastext` are needed. Inclusion of the source code is off by default, but the toggle can be set in `xint.tex`. : A third option is to generate `xint.pdf` via `xelatex xint.dtx` or `pdflatex xint.dtx`. Source code is then included by default (but some code comments in French use 8bit characters, hence for `xelatex` an a priori conversion of xint.dtx into utf-8 will give a better result). `Makefile.mk` : this is for UNIX-like systems. Note: this file is only produced with `"etex xint.dtx"`, not with `"tex xint.dtx"`. Rename it to `Makefile` and run `make` on the command line for further help. `doHTMLs.sh` and `doPDFs.sh` : these are scripts (for UNIX-like systems) which can be used to convert the `README.md` and `CHANGES.md` to HTML and PDF formats. They require [Pandoc](http://johnmacfarlane.net/pandoc/). `pandoctpl.latex` : a Pandoc template used by `doPDFs.sh`. Finishing the installation in a TDS hierarchy: - move the style files to `TDS:tex/generic/xint/` - `xint.dtx` goes to `TDS:source/generic/xint/` - the documentation (xint.pdf, README.md,...) goes to `TDS:doc/generic/xint/` Depending on the destination, it may then be necessary to refresh a filename database. License =======
Copyright (C) 2013-2017 by Jean-Francois Burnol This Work may be distributed and/or modified under the conditions of the LaTeX Project Public License version 1.3c. This version of this license is in > and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later. This Work has the LPPL maintenance status `author-maintained`. The Author of this Work is Jean-Francois Burnol. This Work consists of the source file xint.dtx and of its derived files: xintkernel.sty, xintcore.sty, xint.sty, xintfrac.sty, xintexpr.sty, xintbinhex.sty, xintgcd.sty, xintseries.sty, xintcfrac.sty, xinttools.sty, xint.ins, xint.tex, README, README.md, README.html, README.pdf, CHANGES.md, CHANGES.html, CHANGES.pdf, pandoctpl.latex, doHTMLs.sh, doPDFs.sh, xint.dvi, xint.pdf, Makefile.mk.
%
-------------------------------------------------------- %<*changes>------------------------------------------------------- `1.2p (2017/12/05)` ---- ### Incompatible changes - **xintgcd**: `\xintBezout{a}{b}`'s output consists of `{u}{v}{d}` with `u*a+v*b==d`, with `d` the GCD. Formerly it was `{a}{b}{u}{v}{d}`, and with `u*a-v*b==d`. - **xintgcd**: `\xintBezout{0}{0}` expands to `{0}{0}{0}`. Formerly (since `1.2l`) it raised `InvalidOperation`. - **xintcore**: `\xintiiMod` is now associated with floored division. The former meaning (associated with truncated division) is available as `\xintiiModTrunc`. - **xintfrac**: `\xintMod` is now associated with floored division. The former meaning is available as `\xintModTrunc`. - **xintexpr**: the ``//`` operator and its associated modulo ``'mod'`` (or ``/:``) now correspond to floored division, like the Python language `//`, `%`, and `divmod(x, y)`. Formerly they had been associated to truncated division. This is breaking change for operands of opposite signs. ### Improvements and new features - **xinttools**: `\xintListWithSep`, which had remained unchanged since its introduction at `1.04 (2013/04/25)`, was rewritten for increased speed. - **xintexpr**: `\xintdefvar`'s syntax is extended to allow simultaneous assignments. Examples: `\xintdefvar x1, x2, x3 := 1, 3**10, 3**20;` or `\xintdefiivar A, B := B, A 'mod' B;` for already defined variables `A` and `B`. - **xintexpr**: added `divmod()` to the built-in functions. It is associated with floored division, like the Python language `divmod()`. Related support macros added to **xintcore**, and **xintfrac**. ### Bug fixes - **xintgcd**: `\xintBezout{6}{3}` (for example) expanded to `{6}{3}{-0}{-1}{3}`, but the `-0` should have been `0`. - **xintgcd**: it still used macro `\xintiAbs` although the latter had been deprecated from **xintcore**. - **xintexpr**: in float expressions the `//` and `/:` (aka `'mod'`) operators did not round their operands to the float precision prior to computing with them, contrarily to other infix arithmetic operators and to the `mod(f,g)` function; thus, `mod(f,g)` and `f 'mod' g` were not completely equivalent. - various documentation fixes; in particular, the partial dependency of **xintcfrac** on **xinttools** had not been mentioned. `1.2o (2017/08/29)` ---- ### Incompatible changes - **xint**: `\xintAND`, `\xintOR`, ... and similar Boolean logic macros do not apply anymore `\xintNum` (or `\xintRaw` if **xintfrac** is loaded), to their arguments (often, from internal usage of `\xintSgn`), but only f-expand them (using e.g. `\xintiiSgn`). This is kept un-modified even if loading **xintfrac**. ### Deprecated Deprecated macros raise an error but, generally, then expand as in former releases. They will all get removed at some future release. - **xintcore**: `\xintiOpp`, `\xintiAbs`, `\xintiAdd`, `\xintiSub`, `\xintiMul`, `\xintiDivision`, `\xintiQuo`, `\xintiRem`, `\xintiDivRound`, `\xintiDivTrunc`, `\xintiMod`, `\xintiSqr`, `\xintiPow`, and `\xintiFac` are deprecated. Only the `ii`-named variants get defined. - **xintcore**: `\xintCmp` and `\xintSgn` are deprecated from **xintcore** (which only defines `\xintiiCmp` and `\xintiiSgn`) as they actually belong to **xintfrac**. - **xintcore**: `\xintiiFDg`, resp. `\xintiiLDg`, are renamed `\xintFDg`, resp. `\xintLDg`. Former denominations are deprecated. - **xint**: `\xintMON`, `\xintMMON`, `\xintiMax`, `\xintiMin`, `\xintiMaxof`, `\xintiMinof`, `\xintiSquareRoot`, `\xintiSqrt`, `\xintiSqrtR`, `\xintiBinomial`, and `\xintiPFactorial` are deprecated. Only `ii`-named variants get defined. - **xint**: `\xintEq`, `\xintGeq`, `\xintGt`, `\xintLt`, `\xintGtorEq`, `\xintLtorEq`, `\xintIsZero`, `\xintIsNotZero`, `\xintIsOne`, `\xintOdd`, `\xintEven`, `\xintifSgn`, `\xintifCmp`, `\xintifEq`, `\xintifGt`, `\xintifLt`, `\xintifZero`, `\xintifNotZero`, `\xintifOne`, `\xintifOdd`, are deprecated. These macros belong to **xintfrac**. Package **xint** defines only the `ii`-named variants. - **xint**: `\xintNeq` was renamed to `\xintNotEq` which however is only provided by **xintfrac**. Package **xint** defines `\xintiiNotEq`, and `\xintNeq` is deprecated. - **xint**: `\xintNot` was renamed to `\xintNOT`, former denomination is deprecated. See also item about Boolean logic macros in the *Incompatible Changes* section. `1.2n (2017/08/06)` ---- ### Incompatible changes - **xintbinhex** does not load package **xintcore** anymore, but only **xintkernel**. ### Improvements and new features - **xintbinhex** has only **xintkernel** as dependency. - Macros of **xintbinhex** have been improved for speed and increased maximal sizes of allowable inputs. `1.2m (2017/07/31)` ---- ### Incompatible changes - **xintbinhex**: the length of the input is now limited. The maximum size depends on the macro and ranges from about `4000` to about `19900` digits. - **xintbinhex**: `\xintCHexToBin` is now the variant of `\xintHexToBin` which does not remove leading binary zeroes: `N` hex-digits give on output exactly `4N` binary digits. ### Improvements and new features - **xintbinhex**: all macros have been rewritten using techniques from the 1.2 release (they had remained unmodified since `1.08` of `2013/06/07`.) The new macros are faster but limited to a few thousand digits. The `1.08` routines could handle tens of thousands of digits, but not in a reasonable time. ### Bug fixes - user manual: the `Changes` section wrongly stated at `1.2l` that the macros of **xintbinhex** had been made robust against non terminated input such as ``\number\mathcode`\-``. Unfortunately the author fell into the trap of believing his own documentation and he forgot to actually implement the change. Now done. - user manual: the PDF bookmarks were messed up. - **xint**, **xintfrac**: `\xintGeq`, `\xintMax`, `\xintMin`, suffered from some extra overhead. This was caused by use of some auxiliaries from the very early days which got redefined at some stage. This is fixed here with some additional efficiency improvements and pruning of old code. `1.2l (2017/07/26)` ---- ### Removed - `\xintiiSumExpr`, `\xintiiPrdExpr` (**xint**) and `\xintSumExpr`, `\xintPrdExpr` (**xintfrac**). They had not been formally deprecated, but had been left un-documented since `1.09d (2013/10/22)`. - internal macro `\xint_gob_til_xint_relax` removed. ### Improvements and new features - the underscore character `_` is accepted by the **xintexpr** parsers as a digit separator (the space character already could be used for improved readability of big numbers). It is not allowed as *first* character of a number, as it would then be mis-interpreted as the start of a possible variable name. - some refactoring in **xintcore** auxiliary routines and in `\xintiiSub` and `\xintiiCmp` for some small efficiency gains. - code comments in **xintcore** are better formatted, but remain sparse. - **xintcore**, **xint**, **xintfrac**, ... : some macros were not robust against arguments whose expansion looks forward for some termination (e.g. ``\number\mathcode`\-``), and particularly, most were fragile against inputs using non-terminated ``\numexpr`` (such as `\xintiiAdd{\the\numexpr1}{2}` or `\xintRaw{\numexpr1}`). This was not a bug per se, as the user manual did not claim such inputs were legal, but it was slightly inconvenient. Most macros (particularly those of **xintfrac**) have now been made robust against such inputs. Some macros from **xintcore** primarily destined to internal usage still accept only properly terminated arguments such as ``\the\mathcode`\-`` or ``\the\numexpr1\relax``. The situation with expressions is unchanged: syntax such as `\xintexpr \numexpr1+2\relax` is illegal as the ending `\relax` token will get swallowed by the `\numexpr`; but it is needed by the ``xintexpr``-ession parser, hence the parser will expand forward and presumably end with in an "illegal token" error, or provoke some low-level TeX error (N.B.: a closing brace `}` for example can not terminate an ``xintexpr``-ession, the parser must find a `\relax` token at some point). Thus there must be in this example a second `\relax`. - experimental code for error conditions; there is no complete user interface yet, it is done in preparation for next major release and is completely unstable and undocumented. ### Bug fixes - **xintbinhex**: since `1.2 (2015/10/10)`, `\xintHexToDec` was broken due to an undefined macro (it was in `xint.sty`, but the module by itself is supposedly dependent only upon `xintcore.sty`). - **xintgcd**: macro `\xintBezout` produced partially wrong output if one of its two arguments was zero. - **xintfrac**: the manual said one could use directly `\numexpr` compatible expressions in arithmetic macros (without even a `\numexpr` encapsulation) if they were expressed with up to 8 tokens. There was a bug if these 8 tokens evaluated to zero. The bug has been fixed, and up to 9 tokens are now accepted. But it is simpler to use `\the\numexpr` prefix and not to worry about the token count... The ending `\relax` is now un-needed. `1.2k (2017/01/06)` ---- ### Incompatible changes - macro `\xintFloat` which rounds its input to a floating point number does _not_ print anymore `10.0...0eN` to signal an upwards rounding to the next power of ten. The mantissa has in all cases except the zero input exactly one digit before the decimal mark. - some floating point computations may differ in the least significant digits, due to a change in the rounding algorithm applied to macro arguments expressed as fractions and to an improvement in precision regarding half-integer powers in expressions. See next. ### Improvements and new features - the initial rounding to the target precision `P` which is applied by the floating point macros from **xintfrac** to their arguments achieves the _exact (aka correct) rounding_ even for inputs which are fractions with more than `P+2` digits in their numerators and denominators (`>1`.) Hence the computed values depend only on the arguments as rational numbers and not upon their representatives. This is not relevant to _expressions_ (**xintexpr**), because the `\xintfloatexpr` parser sees there `/` as an operator and does not (apart from special constructs) get to manipulate fractions as such. - `\xintnewdummy` is public interface to a `1.2e` macro which serves to declare any given catcode 11 character as a dummy variable for expressions (**xintexpr**). This is useful for Unicode engines (the Latin letters being already all pre-declared as dummy variables.) - added `\xintiSqrtR`, there was only `\xintiiSqrtR` alongside `\xintiSqrt` and `\xintiiSqrt` (**xint**). - added non public `\xintLastItem:f:csv` to **xinttools** for faster `last()` function, and improved `\xintNewExpr` compatibility. Also `\xintFirstItem:f:csv`. ### Bug fixes - the `1.2f` half-integer powers computed within `\xintfloatexpr` had a silly rounding to the target precision just _before_ the final square-root extraction, thus possibly losing some precision. The `1.2k` implementation keeps guard digits for this final square root extraction. As for integer exponents, it is guaranteed that the computed value differs from the exact one by less than `0.52 ulp` (for inputs having at most `\xinttheDigits` digits.) - more regressions from `1.2i` were fixed: `\xintLen` (**xint**, **xintfrac**) and `\xintDouble` (**xintcore**) had forgotten that their argument was allowed to be negative. A regression test suite is now in place and is being slowly expanded to cover more macros. - `\xintiiSquareRoot{0}` now produces `{1}{1}`, which fits better the general documented behaviour of this macro than `11`. `1.2j (2016/12/22)` ---- ### Improvements and new features - **xinttools** and **xintexpr**: 1. slightly improves the speed of `\xintTrim`. 2. speed gains for the handlers of comma separated lists implementing Python-like slicing and item extraction. Relevant non (user) documented macros better documented in `sourcexint.pdf`. - significant documentations tweaks (inclusive of suppressing things!), and among them two beautiful hyperlinked tables with both horizontal and vertical rules which bring the documentation of the **xintexpr** syntax to a kind of awe-inspiring perfection... except that implementation of some math functions is still lacking. ### Bug fixes - fix two `1.2i` regressions caused by undefined macros (`\xintNthElt` in certain branches and `[list][N]` item extraction in certain cases.) The test files existed but were not executed prior to release. Automation in progress. `1.2i (2016/12/13)` ---- ### Incompatible changes - `\xintDecSplit` second argument must have no sign (former code replaced it with its absolute value, a sign now may cause an error.) ### Removed - deprecated macros `\xintifTrue`, `\xintifTrueFalse`, `\xintQuo`, `\xintRem`, `\xintquo`, `\xintrem`. ### Improvements and new features - **xintkernel**: `\xintLength` is faster. New macros: - `\xintLastItem` to fetch the last item from its argument, - `\romannumeral\xintgobble` for gobbling many (up to 531440) upstream braced items or tokens. - `\romannumeral\xintreplicate` which is copied over from the expl3 `\prg_replicate:nn` with some minor changes. - **xinttools**: general token list handling routines `\xintKeep`, `\xintTrim` and `\xintNthElt` are faster; but the novel `\xintTrim` can only remove up to a maximum of 531440 items. Also, `\xintFor` partially improves on some issues which are reported upon in the documentation. - some old macros have been rewritten entirely or partially using techniques which **xint** started using in release `1.2`: - **xintcore**: `\xintDouble`, `\xintHalf`, `\xintInc`, `\xintDec`, `\xintiiLDg`, `\xintDSR` (originally from **xint**), a novel `\xintDSRr`. - **xint**: `\xintDSH`, `\xintDSx`, `\xintDecSplit`, `\xintiiE`. - **xintfrac**: as a result of the above `\xintTrunc`, `\xintRound` and `\xintXTrunc` got faster. But the main improvement for them is with decimal inputs which formerly had not been treated separately from the general fraction case. Also, `\xintXTrunc` does not anymore create a dependency of **xintfrac** on **xinttools**. - the documentation has again been (slightly) re-organized; it has a new sub-section on the Miller-Rabin primality test, to illustrate some use of `\xintNewFunction` for recursive definitions. - the documentation has dropped the LaTeX "command" terminology (which had been used initially in 2013 for some forgotten reasons and should have been removed long ago) and uses only the more apt "macro", as after all, all of **xint** is about expansion of macros (plus the use of `\numexpr`). ### Bug fixes - `\xintDecSplitL` and `\xintDecSplitR` from **xint** produced their output in a spurious brace pair (bug introduced in `1.2f`). `1.2h (2016/11/20)` ---- ### Improvements and new features - new macro `\xintNewFunction` in **xintexpr** which allows to extend the parser syntax with functions in situations where `\xintdeffunc` is not usable (typically, because dummy variables are used over a not yet determined range of values because it depends on the variables). - after three years of strict obedience to `xint` prefix, now `\thexintexpr`, `\thexintiexpr`, `\thexintfloatexpr`, and `\thexintiiexpr` are provided as synonyms to `\xinttheexpr`, etc... ### Bug fixes - the `(cond)?{foo}{bar}` operator from **xintexpr** mis-behaved in certain circumstances (such as an empty `foo`). - the **xintexpr** `1.2f` `binomial` function (which uses `\xintiiBinomial` from **xint.sty** or `\xintFloatBinomial` from **xintfrac.sty**) deliberately raised an error for `binomial(x,y)` with `y<0` or `x:= expression ;` is now accepted. - documentation enhancements: the _Quick Sort_ section with its included code samples has been entirely re-written; the _Commands of the xintexpr package_ section has been extended and reviewed entirely. ### Bug fixes - in **xintfrac**: the `\xintFloatFac` from release `1.2` parsed its argument only through `\numexpr` but it should have used `\xintNum`. - in **xintexpr**: release `1.2d` had broken the recognition of sub-expressions immediately after variable names (with tacit multiplication). - in **xintexpr**: contrarily to what `1.2d` documentation said, tacit multiplication was not yet always done with enhanced precedence. Now yes. `1.2d (2015/11/18)` ---- ### Improvements and new features - the function definitions done by `\xintdeffunc` et al., as well as the macro declarations by `\xintNewExpr` et al. now have only local scope. - tacit multiplication applies to more cases, for example (x+y)z, and always ties more than standard * infix operator, e.g. x/2y is like x/(2*y). - some documentation enhancements, particularly in the chapter on xintexpr.sty, and also in the code source comments. ### Bug fixes - in **xintcore**: release `1.2c` had inadvertently broken the `\xintiiDivRound` macro. `1.2c (2015/11/16)` ---- ### Improvements and new features - macros `\xintdeffunc`, `\xintdefiifunc`, `\xintdeffloatfunc` and boolean `\ifxintverbose`. - on-going code improvements and documentation enhancements, but stopped in order to issue this bugfix release. ### Bug fixes - in **xintcore**: recent release `1.2` introduced a bug in the subtraction (happened when 00000001 was found under certain circumstances at certain mod 8 locations). `1.2b (2015/10/29)` ---- ### Bug fixes - in **xintcore**: recent release `1.2` introduced a bug in the division macros, causing a crash when the divisor started with 99999999 (it was attempted to use with 1+99999999 a subroutine expecting only 8-digits numbers). `1.2a (2015/10/19)` ---- ### Improvements and new features - added `\xintKeepUnbraced`, `\xintTrimUnbraced` (**xinttools**) and fixed documentation of `\xintKeep` and `\xintTrim` regarding brace stripping. - added `\xintiiMaxof/\xintiiMinof` (**xint**). - TeX hackers only: replaced all code uses of ``\romannumeral-`0`` by the quicker ``\romannumeral`&&@`` (`^` being used as letter, had to find another character usable with catcode 7). ### Bug fixes - in **xintexpr**: recent release `1.2` introduced a bad bug in the parsing of decimal numbers and as a result `\xinttheexpr 0.01\relax` expanded to `0` ! (sigh...) `1.2 (2015/10/10)` ---- ### Removed - the macros `\xintAdd`, `\xintSub`, `\xintMul`, `\xintMax`, `\xintMin`, `\xintMaxof`, `\xintMinof` are removed from package **xint**, and only exist in the versions from **xintfrac**. With only **xintcore** or **xint** loaded, one _must_ use `\xintiiAdd`, `\xintiiSub`, ..., or `\xintiAdd`, `\xintiSub`, etc... ### Improvements and new features - the basic arithmetic implemented in **xintcore** has been entirely rewritten. The mathematics remains the elementary school one, but the `TeX` implementation achieves higher speed (except, regarding addition/subtraction, for numbers up to about thirty digits), the gains becoming quite significant for numbers with hundreds of digits. - the inputs must have less than 19959 digits. But computations with thousands of digits take time. - a previously standing limitation of `\xintexpr`, `\xintiiexpr`, and of `\xintfloatexpr` to numbers of less than 5000 digits has been lifted. - a *qint* function is provided to help the parser gather huge integers in one-go, as an exception to its normal mode of operation which expands token by token. - `\xintFloatFac` macro for computing the factorials of integers as floating point numbers to a given precision. The `!` postfix operator inside `\xintfloatexpr` maps to this new macro rather than to the exact factorial as used by `\xintexpr` and `\xintiiexpr`. - there is more flexibility in the parsing done by the macros from **xintfrac** on fractional input: the decimal parts of both the numerator and the denominator may arise from a separate expansion via ``\romannumeral-`0``. Also the strict `A/B[N]` format is a bit relaxed: `N` may be anything understood by `\numexpr` (it could even be empty but that possibility has been removed by later `1.2f` release.) - on the other hand an isolated dot `.` is not legal syntax anymore inside the expression parsers: there must be digits either before or after. It remains legal input for the macros of **xintfrac**. - added `\ht`, `\dp`, `\wd`, `\fontcharht`, etc... to the tokens recognized by the parsers and expanded by `\number`. - an obscure bug in package **xintkernel** has been fixed, regarding the sanitization of catcodes: under certain circumstances (which could not occur in a normal `LaTeX` context), unusual catcodes could end up being propagated to the external world. - an effort at randomly shuffling around various pieces of the documentation has been done. `1.1c (2015/09/12)` ---- - bugfix regarding macro `\xintAssign` from **xinttools** which did not behave correctly in some circumstances (if there was a space before `\to`, in particular). - very minor code improvements, and correction of some issues regarding the source code formatting in `sourcexint.pdf`, and minor issues in `Makefile.mk`. `1.1b (2015/08/31)` ---- - bugfix: some macros needed by the integer division routine from **xintcore** had been left in **xint.sty** since release `1.1`. This for example broke the `\xintGCD` from **xintgcd** if package **xint** was not loaded. - Slight enhancements to the documentation, particularly in the `Read this first` section. `1.1a (2014/11/07)` ---- - fixed a bug which prevented `\xintNewExpr` from producing correctly working macros from a comma separated replacement text. - `\xintiiSqrtR` for rounded integer square root; former `\xintiiSqrt` already produced truncated integer square root; corresponding function `sqrtr` added to `\xintiiexpr..\relax` syntax. - use of straight quotes in the documentation for better legibility. - added `\xintiiIsOne`, `\xintiiifOne`, `\xintiiifCmp`, `\xintiiifEq`, `\xintiiifGt`, `\xintiiifLt`, `\xintiiifOdd`, `\xintiiCmp`, `\xintiiEq`, `\xintiiGt`, `\xintiiLt`, `\xintiiLtorEq`, `\xintiiGtorEq`, `\xintiiNeq`, mainly for efficiency of `\xintiiexpr`. - for the same reason, added `\xintiiGCD` and `\xintiiLCM`. - added the previously mentioned `ii` macros, and some others from `1.1`, to the user manual. But their main usage is internal to `\xintiiexpr`, to skip unnecessary overheads. - various typographical fixes throughout the documentation, and a bit of clean up of the code comments. Improved `\Factors` example of nested `subs`, `rseq`, `iter` in `\xintiiexpr`. `1.1 (2014/10/28)` ---- ### Incompatible changes - in `\xintiiexpr`, `/` does _rounded_ division, rather than the Euclidean division (for positive arguments, this is truncated division). The `//` operator does truncated division, - the `:` operator for three-way branching is gone, replaced with `??`, - `1e(3+5)` is now illegal. The number parser identifies `e` and `E` in the same way it does for the decimal mark, earlier versions treated `e` as `E` rather as infix operators of highest precedence, - the `add` and `mul` have a new syntax, old syntax is with `` `+` `` and `` `*` `` (left quotes mandatory), `sum` and `prd` are gone, - no more special treatment for encountered brace pairs `{..}` by the number scanner, `a/b[N]` notation can be used without use of braces (the `N` will end up as is in a `\numexpr`, it is not parsed by the `\xintexpr`-ession scanner), - in earlier releases, place holders for `\xintNewExpr` could either be denoted `#1`, `#2`, ... or also `$1`, `$2`, ... Only the usual `#` form is now accepted and the special cases previously treated via the second form are now managed via a `protect(...)` function. - **xintfrac**: `\xintFloor` and `\xintCeil` add a trailing `/1[0]` to their (integer) output. New `\xintiFloor` and `\xintiCeil` do not. ### Removed - `\xintnumexpr`, `\xintthenumexpr`, `\xintNewNumExpr`: use `\xintiexpr`, `\xinttheiexpr`, `\xintNewIExpr`. ### Deprecated - `\xintDivision`, `\xintQuo`, `\xintRem`: use `\xintiDivision`, `\xintiQuo`, `\xintiRem`. - `\xintMax`, `\xintMin`, `\xintAdd`, `\xintSub`, `\xintMul` (**xint**): their usage without **xintfrac** is deprecated; use `\xintiMax`, `\xintiMin`, `\xintiAdd`, `\xintiSub`, `\xintiMul`. - the `&` and `|` as Boolean operators in `xintexpr`-essions are deprecated in favour of `&&` and `||`. The single letter operators might be assigned some other meaning in some later release (bitwise operations, perhaps). Do not use them. ### Improvements and new features * new package **xintcore** has been split off **xint**. It contains the core arithmetic macros (it is loaded by LaTeX package **bnumexpr**), * neither **xint** nor **xintfrac** load **xinttools**. Only **xintexpr** does, * whenever some portion of code has been revised, often use has been made of the `\xint_dothis` and `\xint_orthat` pair of macros for expandably branching, * these tiny helpful macros, and a few others are in package **xintkernel** which contains also the catcode and loading order management code, initially inspired by code found in Heiko Oberdiek's packages, * the source code, which was suppressed from `xint.pdf` in release `1.09n`, is now compiled into a separate file `sourcexint.pdf`, * faster handling by `\xintAdd`, `\xintSub`, `\xintMul`, ... of the case where one of the arguments is zero, * the `\xintAdd` and `\xintSub` macros from package **xintfrac** check if one of the denominators is a multiple of the other, and only if this is not the case do they multiply the denominators. But systematic reduction would be too costly, * this naturally will be also the case for the `+` and `-` operations in `\xintexpr`, * **xint** added `\xintiiDivRound`, `\xintiiDivTrunc`, `\xintiiMod` for rounded and truncated division of big integers (next to `\xintiiQuo` and `\xintiiRem`), * with **xintfrac** loaded, the `\xintNum` macro does `\xintTTrunc` (which is truncation to an integer, same as `\xintiTrunc {0}`), * added `\xintMod` to **xintfrac** for modulo operation with fractional numbers, * added `\xintiFloor` and `\xintiCeil` to **xintfrac**, * `\xintiexpr`, `\xinttheiexpr` admit an optional argument within brackets `[d]`, they round the computation result (or results, if comma separated) to `d` digits after decimal mark, (the whole computation is done exactly, as in `xintexpr`), * `\xintfloatexpr`, `\xintthefloatexpr` similarly admit an optional argument which serves to keep only `d` digits of precision, getting rid of cumulated uncertainties in the last digits (the whole computation is done according to the precision set via `\xintDigits`), * `\xinttheexpr` and `\xintthefloatexpr` _pretty-print_ if possible, the former removing unit denominator or `[0]` brackets, the latter avoiding scientific notation if decimal notation is practical, * the `//` does truncated division and `/:` is the associated modulo, * multi-character operators `&&`, `||`, `==`, `<=`, `>=`, `!=`, `**`, * multi-letter infix binary words `'and'`, `'or'`, `'xor'`, `'mod'` (straight quotes mandatory), * functions `even`, `odd`, * `\xintdefvar A3:=3.1415;` for variable definitions (non expandable, naturally), usable in subsequent expressions; variable names may contain letters, digits, underscores. They should not start with a digit, the `@` is reserved, and single lowercase and uppercase Latin letters are predefined to work as dummy variables (see next), * generation of comma separated lists `a..b`, `a..[d]..b`, * Python syntax-like list extractors `[list][n:]`, `[list][:n]`, `[list][a:b]` allowing negative indices, but no optional step argument, and `[list][n]` (`n=0` for the number of items in the list), * functions `first`, `last`, `reversed`, * itemwise operations on comma separated lists `a*[list]`, etc.., possible on both sides `a*[list]^b`, and obeying the same precedence rules as with numbers, * `add` and `mul` must use a dummy variable: `add(x(x+1)(x-1), x=-10..10)`, * variable substitutions with `subs`: `subs(subs(add(x^2+y^2,x=1..y),y=t),t=20)`, * sequence generation using `seq` with a dummy variable: `seq(x^3, x=-10..10)`, * simple recursive lists with `rseq`, with `@` given the last value, `rseq(1;2@+1,i=1..10)`, * higher recursion with `rrseq`, `@1`, `@2`, `@3`, `@4`, and `@@(n)` for earlier values, up to `n=K` where `K` is the number of terms of the initial stretch `rrseq(0,1;@1+@2,i=2..100)`, * iteration with `iter` which is like `rrseq` but outputs only the last `K` terms, where `K` was the number of initial terms, * inside `seq`, `rseq`, `rrseq`, `iter`, possibility to use `omit`, `abort` and `break` to control termination, * `n++` potentially infinite index generation for `seq`, `rseq`, `rrseq`, and `iter`, it is advised to use `abort` or `break(..)` at some point, * the `add`, `mul`, `seq`, ... are nestable, * `\xintthecoords` converts a comma separated list of an even number of items to the format expected by the `TikZ` `coordinates` syntax, * completely new version `\xintNewExpr`, `protect` function to handle external macros. The dollar sign `$` for place holders is not accepted anymore, only the standard macro parameter `#`. Not all constructs are compatible with `\xintNewExpr`. % $ this docstripped line for emacs buffer fontification issues in doctex-mode ### Bug fixes - `\xintZapFirstSpaces` hence also `\xintZapSpaces` from package **xinttools** were buggy when used with an argument either empty or containing only space tokens. - `\xintiiexpr` did not strip leading zeroes, hence `\xinttheiiexpr 001+1\relax` did not obtain the expected result ... - `\xinttheexpr \xintiexpr 1.23\relax\relax` should have produced `1`, but it produced `1.23` - the catcode of `;` was not set at package launching time. - the `\XINTinFloatPrd:csv` macro name had a typo, hence `prd` was non-functional in `\xintfloatexpr`. `1.09n (2014/04/01)` ---- * the user manual does not include by default the source code anymore: the `\NoSourceCode` toggle in file `xint.tex` has to be set to 0 before compilation to get source code inclusion (later release `1.1` made source code available as `sourcexint.pdf`). * bug fix (**xinttools**) in `\XINT_nthelt_finish` (this bug was introduced in `1.09i` of `2013/12/18` and showed up when the index `N` was larger than the number of elements of the list). `1.09m (2014/02/26)` ---- * new in **xinttools**: `\xintKeep` keeps the first `N` or last `N` elements of a list (sequence of braced items); `\xintTrim` cuts out either the first `N` or the last `N` elements from a list. * new in **xintcfrac**: `\xintFGtoC` finds the initial partial quotients common to two numbers or fractions `f` and `g`; `\xintGGCFrac` is a clone of `\xintGCFrac` which however does not assume that the coefficients of the generalized continued fraction are numeric quantities. Some other minor changes. `1.09kb (2014/02/13)` ---- * bug fix (**xintexpr**): an aloof modification done by `1.09i` to `\xintNewExpr` had resulted in a spurious trailing space present in the outputs of all macros created by `\xintNewExpr`, making nesting of such macros impossible. * bug fix (**xinttools**): `\xintBreakFor` and `\xintBreakForAndDo` were buggy when used in the last iteration of an `\xintFor` loop. * bug fix (**xinttools**): `\xintSeq` from `1.09k` needed a `\chardef` which was missing from `xinttools.sty`, it was in `xint.sty`. `1.09k (2014/01/21)` ---- * inside `\xintexpr..\relax` (and its variants) tacit multiplication is implied when a number or operand is followed directly with an opening parenthesis, * the `"` for denoting (arbitrarily big) hexadecimal numbers is recognized by `\xintexpr` and its variants (package **xintbinhex** is required); a fractional hexadecimal part introduced by a dot `.` is allowed. * re-organization of the first sections of the user manual. * bug fix (**xinttools**, **xint**, ...): forgotten catcode check of `"` at loading time has been added. `1.09j (2014/01/09)` ---- * (**xint**) the core division routines have been re-written for some (limited) efficiency gain, more pronounced for small divisors. As a result the *computation of one thousand digits of $\pi$* is close to three times faster than with earlier releases. * some various other small improvements, particularly in the power routines. * (**xintfrac**) a macro `\xintXTrunc` is designed to produce thousands or even tens of thousands of digits of the decimal expansion of a fraction. Although completely expandable it has its use limited to inside an `\edef`, `\write`, `\message`, \dots. It can thus not be nested as argument to another package macro. * (**xintexpr**) the tacit multiplication done in `\xintexpr..\relax` on encountering a count register or variable, or a `\numexpr`, while scanning a (decimal) number, is extended to the case of a sub `\xintexpr`-ession. * `\xintexpr` can now be used in an `\edef` with no `\xintthe` prefix; it will execute completely the computation, and the error message about a missing `\xintthe` will be inhibited. Previously, in the absence of `\xintthe`, expansion could only be a full one (with ``\romannumeral-`0``), not a complete one (with `\edef`). Note that this differs from the behavior of the non-expandable `\numexpr`: `\the` or `\number` (or `\romannumeral`) are needed not only to print but also to trigger the computation, whereas `\xintthe` is mandatory only for the printing step. * the default behavior of `\xintAssign` is changed, it now does not do any further expansion beyond the initial full-expansion which provided the list of items to be assigned to macros. * bug fix (**xintfrac**): `1.09i` did an unexplainable change to `\XINT_infloat_zero` which broke the floating point routines for vanishing operands =:((( * bug fix: the `1.09i` `xint.ins` file produced a buggy `xint.tex` file. `1.09i (2013/12/18)` ---- * (**xintexpr**) `\xintiiexpr` is a variant of `\xintexpr` which is optimized to deal only with (long) integers, `/` does a euclidean quotient. * *deprecated*: `\xintnumexpr`, `\xintthenumexpr`, `\xintNewNumExpr` are renamed, respectively, `\xintiexpr`, `\xinttheiexpr`, `\xintNewIExpr`. The earlier denominations are kept but are to be removed at some point. * it is now possible within `\xintexpr...\relax` and its variants to use count, dimen, and skip registers or variables without explicit `\the/\number`: the parser inserts automatically `\number` and a tacit multiplication is implied when a register or variable immediately follows a number or fraction. Regarding dimensions and `\number`, see the further discussion in *Dimensions*. * (**xintfrac**) conditional `\xintifOne`; `\xintifTrueFalse` renamed to `\xintifTrueAelseB`; macros `\xintTFrac` (`fractional part`, mapped to function `frac` in `\xintexpr`-essions), `\xintFloatE`. * (**xinttools**) `\xintAssign` admits an optional argument to specify the expansion type to be used: `[]` (none, default), `[o]` (once), `[oo]` (twice), `[f]` (full), `[e]` (`\edef`),... to define the macros * **xinttools** defines `\odef`, `\oodef`, `\fdef` (if the names have already been assigned, it uses `\xintoodef` etc...). These tools are provided for the case one uses the package macros in a non-expandable context. `\oodef` expands twice the macro replacement text, and `\fdef` applies full expansion. They are useful in situations where one does not want a full `\edef`. `\fdef` appears to be faster than `\oodef` in almost all cases (with less than thousand digits in the result), and even faster than `\edef` for expanding the package macros when the result has a few dozens of digits. `\oodef` needs that expansion ends up in thousands of digits to become competitive with the other two. * some across the board slight efficiency improvement as a result of modifications of various types to *fork macros* and *branching conditionals* which are used internally. * bug fix (**xint**): `\xintAND` and `\xintOR` inserted a space token in some cases and did not expand as promised in two steps `:-((` (bug dating back to `1.09a` I think; this bug was without consequences when using `&` and `|` in `\xintexpr-essions`, it affected only the macro form). * bug fix (**xintcfrac**): `\xintFtoCCv` still ended fractions with the `[0]`'s which were supposed to have been removed since release `1.09b`. * *deprecated*: `\xintifTrueFalse`, `\xintifTrue`; use `\xintifTrueAelseB`. `1.09h (2013/11/28)` ---- * parts of the documentation have been re-written or re-organized, particularly the discussion of expansion issues and of input and output formats. * the expansion types of macro arguments are documented in the margin of the macro descriptions, with conventions mainly taken over from those in the `LaTeX3` documentation. * a dependency of **xinttools** on **xint** (inside `\xintSeq`) has been removed. * (**xintgcd**) `\xintTypesetEuclideAlgorithm` and `\xintTypesetBezoutAlgorithm` have been slightly modified (regarding indentation). * (**xint**) macros `xintiSum` and `xintiPrd` are renamed to `\xintiiSum` and `\xintiiPrd`. * (**xinttools**) a count register used in `1.09g` in the `\xintFor` loops for parsing purposes has been removed and replaced by use of a `\numexpr`. * the few uses of `\loop` have been replaced by `\xintloop/\xintiloop`. * all macros of **xinttools** for which it makes sense are now declared `\long`. `1.09g (2013/11/22)` ---- * a package **xinttools** is detached from **xint**, to make tools such as `\xintFor`, `\xintApplyUnbraced`, and `\xintiloop` available without the **xint** overhead. * expandable nestable loops `\xintloop` and `\xintiloop`. * bugfix: `\xintFor` and `\xintFor*` do not modify anymore the value of `\count 255`. `1.09f (2013/11/04)` ---- * (**xint**) `\xintZapFirstSpaces`, `\xintZapLastSpaces`, `\xintZapSpaces`, `\xintZapSpacesB`, for expandably stripping away leading and/or ending spaces. * `\xintCSVtoList` by default uses `\xintZapSpacesB` to strip away spaces around commas (or at the start and end of the comma separated list). * also the `\xintFor` loop will strip out all spaces around commas and at the start and the end of its list argument; and similarly for `\xintForpair`, `\xintForthree`, `\xintForfour`. * `\xintFor` *et al.* accept all macro parameters from `#1` to `#9`. * for reasons of inner coherence some macros previously with one extra `i` in their names (e.g. `\xintiMON`) now have a doubled `ii` (`\xintiiMON`) to indicate that they skip the overhead of parsing their inputs via `\xintNum`. Macros with a *single* `i` such as `\xintiAdd` are those which maintain the non-**xintfrac** output format for big integers, but do parse their inputs via `\xintNum` (since release `1.09a`). They too may have doubled-`i` variants for matters of programming optimization when working only with (big) integers and not fractions or decimal numbers. `1.09e (2013/10/29)` ---- * (**xint**) `\xintintegers`, `\xintdimensions`, `\xintrationals` for infinite `\xintFor` loops, interrupted with `\xintBreakFor` and `\xintBreakForAndDo`. * `\xintifForFirst`, `\xintifForLast` for the `\xintFor` and `\xintFor*` loops, * the `\xintFor` and `xintFor*` loops are now `\long`, the replacement text and the items may contain explicit `\par`'s. * conditionals `\xintifCmp`, `\xintifInt`, `\xintifOdd`. * bug fix (**xint**): the `\xintFor` loop (not `\xintFor*`) did not correctly detect an empty list. * bug fix (**xint**): `\xintiSqrt {0}` crashed. `:-((` * the documentation has been enriched with various additional examples, such as the *the quick sort algorithm illustrated* or the various ways of *computing prime numbers*. * the documentation explains with more details various expansion related issues, particularly in relation to conditionals. `1.09d (2013/10/22)` ---- * bug fix (**xint**): `\xintFor*` is modified to gracefully handle a space token (or more than one) located at the very end of its list argument (as the space before `\do` in `\xintFor* #1 in {{a}{b}{c}} \do {stuff}`; spaces at other locations were already harmless). Furthermore this new version _f-expands_ the un-braced list items. After `\def\x{{1}{2}}` and `\def\y{{a}\x {b}{c}\x }`, `\y` will appear to `\xintFor*` exactly as if it had been defined as `\def\y{{a}{1}{2}{b}{c}{1}{2}}`. * same bug fix for `\xintApplyInline`. `1.09c (2013/10/09)` ---- * (**xintexpr**) added `bool` and `togl` to the `\xintexpr` syntax; also added `\xintboolexpr` and `\xintifboolexpr`. * added `\xintNewNumExpr`. * the factorial `!` and branching `?`, `:`, operators (in `\xintexpr...\relax`) have now less precedence than a function name located just before, * (**xint**) `\xintFor` is a new type of loop, whose replacement text inserts the comma separated values or list items via macro parameters, rather than encapsulated in macros; the loops are nestable up to four levels (nine levels since `1.09f`) and their replacement texts are allowed to close groups as happens with the tabulation in alignments, * `\xintForpair`, `\xintForthree`, `\xintForfour` are experimental variants of `\xintFor`, * `\xintApplyInline` has been enhanced in order to be usable for generating rows (partially or completely) in an alignment, * command `\xintSeq` to generate (expandably) arithmetic sequences of (short) integers, * again various improvements and changes in the documentation. `1.09b (2013/10/03)` ---- * various improvements in the documentation, * more economical catcode management and re-loading handling, * removal of all those `[0]`'s previously forcefully added at the end of fractions by various macros of **xintcfrac**, * `\xintNthElt` with a negative index returns from the tail of the list, * macro `\xintPRaw` to have something like what `\xintFrac` does in math mode; i.e. a `\xintRaw` which does not print the denominator if it is one. `1.09a (2013/09/24)` ---- * (**xintexpr**) `\xintexpr..\relax` and `\xintfloatexpr..\relax` admit functions in their syntax, with comma separated values as arguments, among them `reduce, sqr, sqrt, abs, sgn, floor, ceil, quo, rem, round, trunc, float, gcd, lcm, max, min, sum, prd, add, mul, not, all, any, xor`. * comparison (`<`, `>`, `=`) and logical (`|`, `&`) operators. * the command `\xintthe` which converts `\xintexpr`essions into printable format (like `\the` with `\numexpr`) is more efficient, for example one can do `\xintthe\x` if `\x` was defined to be an `\xintexpr..\relax`: \def\x{\xintexpr 3^57\relax} \def\y{\xintexpr \x^(-2)\relax} \def\z{\xintexpr \y-3^-114\relax} \xintthe\z * `\xintnumexpr .. \relax` (now renamed `\xintiexpr`) is `\xintexpr round( .. ) \relax`. * `\xintNewExpr` now works with the standard macro parameter character `#`. * both regular `\xintexpr`-essions and commands defined by `\xintNewExpr` will work with comma separated lists of expressions, * commands `\xintFloor`, `\xintCeil`, `\xintMaxof`, `\xintMinof` (package **xintfrac**), `\xintGCDof`, `\xintLCM`, `\xintLCMof` (package **xintgcd**), `\xintifLt`, `\xintifGt`, `\xintifSgn`, `\xintANDof`, ... * The arithmetic macros from package **xint** now filter their operands via `\xintNum` which means that they may use directly count registers and `\numexpr`-essions without having to prefix them by `\the`. This is thus similar to the situation holding previously already when **xintfrac** was loaded. * a bug (**xintfrac**) introduced in `1.08b` made `\xintCmp` crash when one of its arguments was zero. `:-((` `1.08b (2013/06/14)` ---- * (**xintexpr**) Correction of a problem with spaces inside `\xintexpr`-essions. * (**xintfrac**) Additional improvements to the handling of floating point numbers. * section *Use of count registers* documenting how count registers may be directly used in arguments to the macros of **xintfrac**. `1.08a (2013/06/11)` ---- * (**xintfrac**) Improved efficiency of the basic conversion from exact fractions to floating point numbers, with ensuing speed gains especially for the power function macros `\xintFloatPow` and `\xintFloatPower`, * Better management by `\xintCmp`, `\xintMax`, `\xintMin` and `\xintGeq` of inputs having big powers of ten in them. * Macros for floating point numbers added to the **xintseries** package. `1.08 (2013/06/07)` ---- * (**xint** and **xintfrac**) Macros for extraction of square roots, for floating point numbers (`\xintFloatSqrt`), and integers (`\xintiSqrt`). * new package **xintbinhex** providing *conversion routines* to and from binary and hexadecimal bases. `1.07 (2013/05/25)` ---- * The **xintexpr** package is a new core constituent (which loads automatically **xintfrac** and **xint**) and implements the expandable expanding parser \xintexpr . . . \relax, and its variant \xintfloatexpr . . . \relax allowing on input formulas using the infix operators `+`, `-`, `*`, `/`, and `^`, and arbitrary levels of parenthesizing. Within a float expression the operations are executed according to the current value set by `\xintDigits`. Within an `\xintexpr`-ession the binary operators are computed exactly. To write the `\xintexpr` parser I benefited from the commented source of the `l3fp` parser; the `\xintexpr` parser has its own features and peculiarities. *See its documentation*. * The floating point precision `D` is set (this is a local assignment to a `\mathchar` variable) with `\xintDigits := D;` and queried with `\xinttheDigits`. It may be set to anything up to `32767`.[^1] The macro incarnations of the binary operations admit an optional argument which will replace pointwise `D`; this argument may exceed the `32767` bound. * The **xintfrac** macros now accept numbers written in scientific notation, the `\xintFloat` command serves to output its argument with a given number `D` of significant figures. The value of `D` is either given as optional argument to `\xintFloat` or set with `\xintDigits := D;`. The default value is `16`. [^1]: but values higher than 100 or 200 will presumably give too slow evaluations. `1.06b (2013/05/14)` ---- * Minor code and documentation improvements. Everywhere in the source code, a more modern underscore has replaced the @ sign. `1.06 (2013/05/07)` ---- * Some code improvements, particularly for macros of **xint** doing loops. * New utilities in **xint** for expandable manipulations of lists: \xintNthElt, \xintCSVtoList, \xintRevWithBraces * The macros did only a double expansion of their arguments. They now fully expand them (using ``\romannumeral-`0``). Furthermore, in the case of arguments constrained to obey the TeX bounds they will be inserted inside a `\numexpr..\relax`, hence completely expanded, one may use count registers, even infix arithmetic operations, etc... `1.05 (2013/05/01)` ---- Minor changes and additions to **xintfrac** and **xintcfrac**. `1.04 (2013/04/25)` ---- * New component **xintcfrac** devoted to continued fractions. * **xint**: faster division. * **xint**: added expandable macros `\xintListWithSep` and `\xintApply` to handle token lists. * **xintfrac**: added `\xintRound`. * **xintseries** has a new implementation of `\xintPowerSeries` based on a Horner scheme, and new macro `\xintRationalSeries`. Both to help deal with the *denominator buildup* plague. * `tex xint.dtx` extracts style files (no need for a `xint.ins`). * Bug fix (**xintfrac**): `\xintIrr {0}` crashed. `1.03 (2013/04/14)` ---- * New modules **xintfrac** (expandable operations on fractions) and **xintseries** (expandable partial sums with xint package). * Slightly improved division and faster multiplication (the best ordering of the arguments is chosen automatically). * Added illustration of Machin algorithm to the documentation. `1.0 (2013/03/28)` ---- Initial announcement: > The **xint** package implements with expandable TeX macros the basic arithmetic operations of addition, subtraction, multiplication and division, as applied to arbitrarily long numbers represented as chains of digits with an optional minus sign. > The **xintgcd** package provides implementations of the Euclidean algorithm and of its typesetting. > The packages may be used with Plain and with LaTeX. %------------------------------------------------------ %<*makefile>------------------------------------------------------ # This file: Makefile.mk (generated from xint.dtx) # Tested on Mac OS X Mavericks with GNU Make 3.81, # TeXLive 2014 and Pandoc 1.13.1. # Either download the master Makefile from # http://mirror.ctan.org/macros/generic/xint # or rename the present one as "Makefile". # Then run "make" or equivalently "make help" to # get instructions. Compilation of the complete # documentation requires Pandoc. # Note to myself: I wanted to use .RECIPEPREFIX = > but it is supported # only with GNU Make 3.82 and later. # this crazyness is to circumvent a problem with docstrip generation # of the Makefile; we do not want two empty lines becoming only one nullstring := define newline $(nullstring) endef # will speed-up a little, I think. newline := $(newline) define helptext ==== INSTRUCTIONS The Makefile is to automatize the extraction and compilation from xint.dtx of package files and documentation files, and for producing xint.tds.zip. It is for GNU/Linux like systems, with a teTeX like installation such as TeXLive. Tested on Mac OS X Mavericks with TL2014. For compiling the PDF files, packages newtx, newtxtt, etoc,... are used and should be up-to-date (as of 2014/10). Conversion to plain, html and pdf format of README.md and CHANGES.md (make PanPDF, make PanHTML) require Pandoc software. (tested with Pandoc 1.13.1). It is recommended to work with xint.dtx and Makefile in an otherwise initially empty temporary repertory. make help prints this help (using more). It will also have already extracted all files from xint.dtx. make helpless prints this help (using less). make xint.pdf extracts files and produces only xint.pdf, via latex+dvipdfmx. No Pandoc needed. make sourcexint.pdf extracts files and produces only sourcexint.pdf, via latex+dvipdfmx. No Pandoc needed. make PanPDF produces README.pdf and CHANGES.pdf, requires Pandoc. make PanHTML produces README.html and CHANGES.html, requires Pandoc. make doc produces all documentation. make all produces all documentation, and creates xint.tds.zip. make xint.tds.zip same as "make all" make cleanall removes all generated files ==== INSTALLING The following has been tested on a TeXLive installation: make installhome creates xint.tds.zip, and unzips it in (it assumes there is no ls-R file there) make installlocal creates xint.tds.zip, and unzips it in (and then does texhash ) IT MIGHT BE NEEDED TO RUN IT AS "sudo make installlocal" This depends on how the access rights are configured. In case of doubt run first "make doc" and then "make installlocal". If the latter fails, "sudo make installlocal". make uninstallhome removes all xint files and repertories from make uninstalllocal removes all xint files and repertories from (and then does texhash ) IT MIGHT BE NEEDED TO RUN IT AS "sudo make uninstalllocal" endef .PHONY: help helpless all extract doc PanPDF PanHTML clean cleanall\ installhome uninstallhome installlocal uninstalllocal # for printf with subst and \n, got it from # http://stackoverflow.com/a/5887751 # I could do the trick with := here, for \n substitution, but this would add # tiny overhead to all other operations of make help: @printf '$(subst $(newline),\n,$(helptext))' | more helpless: @printf '$(subst $(newline),\n,$(helptext))' | less # RM = rm -f JF_tmpdir := $(shell mktemp -d TEMP_XINT_XXX) TEXMF_local = $(shell kpsewhich -var-value TEXMFLOCAL) TEXMF_home = $(shell kpsewhich -var-value TEXMFHOME) packages = xintkernel.sty xintcore.sty xint.sty xintfrac.sty xintexpr.sty\ xintgcd.sty xintbinhex.sty xintseries.sty xintcfrac.sty\ xinttools.sty # Makefile.mk is not included in $(extracted). Its extraction rule is in # master Makefile file. We can not extract Makefile from xint.dtx via # docstrip, as .tex is always appended if a filename with no extension is # specified. If "make -f Makefile.mk" is run, Makefile.mk will not be # overwritten because tex xint.dtx does not extract it (etex xint.dtx does). extracted = $(packages) xint.tex xint.ins README.md CHANGES.md\ doHTMLs.sh doPDFs.sh pandoctpl.latex doc_pdf = README.pdf CHANGES.pdf doc_html = README.html CHANGES.html filesfortex = $(packages) filesforsource = xint.dtx xint.ins Makefile filesfordoc = xint.pdf sourcexint.pdf README $(doc_pdf) $(doc_html) auxiliaryfiles = xint.tex xint.dvi xint.aux xint.toc xint.log\ sourcexint.dvi sourcexint.aux sourcexint.toc sourcexint.log\ README.tex README.dvi README.aux README.toc README.out README.log\ CHANGES.tex CHANGES.dvi CHANGES.aux CHANGES.toc CHANGES.out CHANGES.log xint_cmd = latex -interaction=nonstopmode xint sourcexint_cmd = latex -interaction=nonstopmode -jobname=sourcexint\ "\chardef\dosourcexint=1 \input{xint}" all: $(extracted) doc xint.tds.zip @echo 'make all done.' extract: $(extracted) $(extracted): xint.dtx tex xint.dtx doc: xint.pdf sourcexint.pdf README PanPDF PanHTML @echo 'make doc done.' xint.pdf: xint.dtx xint.tex rm -f xint.aux xint.toc $(xint_cmd) $(xint_cmd) $(xint_cmd) dvipdfmx xint.dvi sourcexint.pdf: xint.dtx xint.tex rm -f sourcexint.aux sourcexint.toc $(sourcexint_cmd) $(sourcexint_cmd) $(sourcexint_cmd) dvipdfmx sourcexint.dvi README: README.md pandoc -t plain -o README README.md PanPDF: $(doc_pdf) $(doc_pdf): doPDFs.sh chmod u+x doPDFs.sh && ./doPDFs.sh PanHTML: $(doc_html) $(doc_html): doHTMLs.sh chmod u+x doHTMLs.sh && ./doHTMLs.sh xint.tds.zip: $(filesfordoc) $(filesforsource) $(filesfortex) rm -fr $(JF_tmpdir) mkdir -p $(JF_tmpdir)/doc/generic/xint mkdir -p $(JF_tmpdir)/source/generic/xint mkdir -p $(JF_tmpdir)/tex/generic/xint chmod -R ugo+rwx $(JF_tmpdir) cp -a $(filesfordoc) $(JF_tmpdir)/doc/generic/xint cp -a $(filesforsource) $(JF_tmpdir)/source/generic/xint cp -a $(filesfortex) $(JF_tmpdir)/tex/generic/xint cd $(JF_tmpdir); chmod -R ugo+r doc source tex umask 0022 && cd $(JF_tmpdir) &&\ zip -r xint.tds.zip doc source tex &&\ mv -f xint.tds.zip ../ rm -fr $(JF_tmpdir) @echo 'make xint.tds.zip done.' xint.zip: $(filesfordoc) $(filesforsource) $(filesfortex) xint.tds.zip mkdir -p $(JF_tmpdir)/xint chmod ugo+rwx $(JF_tmpdir)/xint cp -a $(filesfordoc) $(JF_tmpdir)/xint cp -a $(filesforsource) $(JF_tmpdir)/xint chmod -R ugo+r $(JF_tmpdir)/xint mv xint.tds.zip $(JF_tmpdir)/ umask 0022 && cd $(JF_tmpdir) && zip -r xint.zip xint.tds.zip xint mv $(JF_tmpdir)/xint.tds.zip ./ mv -f $(JF_tmpdir)/xint.zip ./ rm -fr $(JF_tmpdir) @echo 'make xint.zip done.' installhome: xint.tds.zip unzip xint.tds.zip -d $(TEXMF_home) uninstallhome: cd $(TEXMF_home) && rm -fr doc/generic/xint \ source/generic/xint \ tex/generic/xint # cf http://stackoverflow.com/a/1909390 # as kpsewhich is very slow (.5s) I want to evaluate once only. installlocal: xint.tds.zip $(eval $@_tmp := $(TEXMF_local)) unzip xint.tds.zip -d $($@_tmp) && texhash $($@_tmp) uninstalllocal: cd $(TEXMF_local) && rm -fr doc/generic/xint \ source/generic/xint \ tex/generic/xint && texhash . clean: rm -f $(auxiliaryfiles) cleanall: clean rm -f $(extracted) $(doc_pdf) $(doc_html)\ README xint.pdf sourcexint.pdf xint.tds.zip %$----------------------------------------------------- %<*pandoctpl>----------------------------------------------------- \newcommand{\tightlist}{% \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} $if(dvipdfmx)$ {\csname @for\endcsname\x:=hyperref,graphicx,color,xcolor\do {\PassOptionsToPackage{dvipdfmx}\x}} \PassOptionsToPackage{dvipdfmx-outline-open}{hyperref} \PassOptionsToPackage{dvipdfm}{geometry} $endif$ \documentclass[$papersize$,fontsize=$fontsize$]{scrartcl} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{newtxtext} \usepackage{newtxtt} \usepackage{newtxmath} \usepackage{upquote} % pour les \texttt venant de la conversion par pandoc des `...`: \begingroup\makeatletter \catcode`\'\active \catcode`\*\active \catcode`\`\active \@firstofone {\endgroup \def\dostraightquotesandstar{% textcomp package is loaded by newtxtext \let`\textasciigrave \let'\textquotesingle \edef*{\noexpand\raisebox{-.25\noexpand\height}{\string*}}% \catcode39\active % ' \catcode96\active % ` \catcode42\active }% * }% for \texttt, let's just forget about math and italic correction things \DeclareRobustCommand\texttt {\bgroup \dostraightquotesandstar\afterassignment\ttfamily\let\next=} $if(geometry)$ \usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry} $endif$ $if(tables)$ \usepackage{longtable,booktabs} $endif$ \usepackage[unicode=true,bookmarks]{hyperref} \hypersetup{breaklinks=true,% pdfauthor={Jean-Fran\c cois Burnol},% pdftitle={$title$ $author$ $date$},% colorlinks=true,% citecolor=$if(citecolor)$$citecolor$$else$blue$endif$,% urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$,% linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$,% pdfborder={0 0 0},% pdfstartview=FitH,% pdfpagemode=UseOutlines} %%\urlstyle{same} % don't use monospace font for urls \setlength{\parindent}{0pt} \setlength{\emergencystretch}{3em} % prevent overfull lines \usepackage{enumitem} %% reduce LaTeX's insane vertical spacing around verbatim blocks \setlength{\parskip}{\medskipamount} \setlist[trivlist]{topsep=0pt,partopsep=0pt,itemsep=0pt,parsep=0pt} $if(numbersections)$ \setcounter{secnumdepth}{5} $else$ \setcounter{secnumdepth}{0} $endif$ $if(etoc)$\usepackage{etoc}$endif$ \title{$title$} \author{$author$} \date{$date$} $for(header-includes)$ $header-includes$ $endfor$ \begin{document} $if(title)$ \maketitle $endif$ $for(include-before)$ $include-before$ $endfor$ $if(toc)$ \setcounter{tocdepth}{$toc-depth$} $if(etoc)$ \etocdefaultlines \etocmulticolstyle[$etoc$]{} $endif$ \tableofcontents $endif$ $body$ $for(include-after)$ $include-after$ $endfor$ \end{document} %----------------------------------------------------- %<*dohtmlsh>------------------------------------------------------ #! /bin/sh # produces README.html and CHANGES.html from README.md and CHANGES.md # tested with pandoc 1.13.1 pandoc -o README.html -s --toc -V highlighting-css=' body{margin-left : 10%; margin-right : 15%; margin-top: 4ex; font-size: 12pt;} pre {white-space: pre-wrap; } code {white-space: pre-wrap; } .mono {font-family: monospace;}' README.md pandoc -o CHANGES.html -s --toc -V highlighting-css=' body{margin-left : 10%; margin-right : 15%; margin-top: 4ex; font-size: 12pt;} pre {white-space: pre-wrap;} code {white-space: pre-wrap;} #TOC {float: right; position: relative; top: 100px; margin-bottom: 100px;}' CHANGES.md %------------------------------------------------------ %<*dopdfsh>------------------------------------------------------- #! /bin/sh # produces README.pdf and CHANGES.pdf from README.md and CHANGES.md # via latex+dvipdfmx and custom pandoc latex template pandoc -o README.tex --template=pandoctpl --toc -V papersize=a4paper -V fontsize=11pt -V dvipdfmx --variable=geometry:footskip=1cm,left=2.5cm,right=2.5cm,top=2cm,bottom=3cm -V etoc=1 README.md rm -f README.aux README.toc README.out latex -interaction=nonstopmode README latex -interaction=nonstopmode README latex -interaction=nonstopmode README dvipdfmx README.dvi pandoc -o CHANGES.tex --template=pandoctpl --toc -V 'toc-depth'=2 -V papersize=a4paper -V fontsize=11pt -V dvipdfmx --variable=geometry:footskip=1cm,left=2.5cm,right=2.5cm,top=2cm,bottom=3cm -V etoc=2 CHANGES.md rm -f CHANGES.aux CHANGES.toc CHANGES.out latex -interaction=nonstopmode CHANGES latex -interaction=nonstopmode CHANGES latex -interaction=nonstopmode CHANGES dvipdfmx CHANGES.dvi %------------------------------------------------------- %<*drv>----------------------------------------------------------- %% %% Run latex thrice on this file xint.tex then run dvipdfmx on %% xint.dvi to produce the documentation xint.pdf. Alternatively %% run xelatex or pdflatex thrice on xint.tex. %% \NeedsTeXFormat{LaTeX2e} \ProvidesFile{xint.tex}% [\xintbndldate\space v\xintbndlversion\space driver file for xint documentation (JFB)]% \PassOptionsToClass{a4paper,fontsize=10pt}{scrdoc} \chardef\NoSourceCode 1 % set it to 0 if source code inclusion desired \input xint.dtx %%% Local Variables: %%% mode: latex %%% End: %----------------------------------------------------------- %<*ins>----------------------------------------------------------- %% %% tex xint.ins extracts all package files from xint.dtx, as well as %% xint.tex, README.md, CHANGES.md, doPDFs.sh, doHTMLs.sh. %% %% etex xint.ins does the same plus extracts Makefile.mk. %% \input docstrip.tex \askforoverwritefalse \generate{\nopreamble\nopostamble \file{README.md}{\from{xint.dtx}{readme}} \file{CHANGES.md}{\from{xint.dtx}{changes}} \file{doHTMLs.sh}{\from{xint.dtx}{dohtmlsh}} \file{doPDFs.sh}{\from{xint.dtx}{dopdfsh}} \ifx\numexpr\undefined\else\catcode9 11 \file{Makefile.mk}{\from{xint.dtx}{makefile}}\fi \usepreamble\defaultpreamble \usepostamble\defaultpostamble \file{pandoctpl.latex}{\from{xint.dtx}{pandoctpl}} \file{xint.tex}{\from{xint.dtx}{drv}} \file{xintkernel.sty}{\from{xint.dtx}{xintkernel}} \file{xinttools.sty}{\from{xint.dtx}{xinttools}} \file{xintcore.sty}{\from{xint.dtx}{xintcore}} \file{xint.sty}{\from{xint.dtx}{xint}} \file{xintbinhex.sty}{\from{xint.dtx}{xintbinhex}} \file{xintgcd.sty}{\from{xint.dtx}{xintgcd}} \file{xintfrac.sty}{\from{xint.dtx}{xintfrac}} \file{xintseries.sty}{\from{xint.dtx}{xintseries}} \file{xintcfrac.sty}{\from{xint.dtx}{xintcfrac}} \file{xintexpr.sty}{\from{xint.dtx}{xintexpr}}} \catcode32=13\relax% active space \let =\space% \Msg{************************************************************************} \Msg{*} \Msg{* To finish the installation you have to move the following} \Msg{* files into a directory searched by TeX:} \Msg{*} \Msg{* xintkernel.sty} \Msg{* xintcore.sty} \Msg{* xint.sty} \Msg{* xintbinhex.sty} \Msg{* xintgcd.sty} \Msg{* xintfrac.sty} \Msg{* xintseries.sty} \Msg{* xintcfrac.sty} \Msg{* xintexpr.sty} \Msg{* xinttools.sty} \Msg{*} \Msg{* To produce the documentation run latex thrice on xint.tex} \Msg{* then dvipdfmx on xint.dvi. Edit xint.tex to get the code} \Msg{* source included.} \Msg{* dvipdfmx warnings may be ignored, but if the produced pdf} \Msg{* has font problems, run rather pdflatex on xint.tex} \Msg{*} \Msg{* Happy TeXing!} \Msg{*} \Msg{************************************************************************} \endbatchfile %----------------------------------------------------------- %<*dtx>----------------------------------------------------------- ^^Bfi^^Begroup \chardef\noetex 0 \ifx\numexpr\undefined\chardef\noetex 1 \fi \ifnum\noetex=1 \chardef\extractfiles 0 % extract files, then stop \else \ifx\ProvidesFile\undefined \chardef\extractfiles 0 % no LaTeX2e: etex, xetex, ... on xint.dtx \else \ifx\NoSourceCode\undefined % latex/pdflatex/xelatex on xint.dtx, we will extract all files \chardef\extractfiles 1 % 1 = extract and typeset, 2 = only typeset \chardef\NoSourceCode 0 % 0 = include source code, 1 = do not \NeedsTeXFormat{LaTeX2e}% \PassOptionsToClass{a4paper,fontsize=10pt}{scrdoc}% \else % latex/pdflatex/xelatex on xint.tex \chardef\extractfiles 2 % no extractions, but typeset % \NoSourceCode is set-up in xint.tex \fi \ProvidesFile{xint.dtx}[bundle source (\xintbndlversion, \xintbndldate) % and documentation (\xintdocdate)]% \fi \fi \ifnum\extractfiles<2 % extract files \def\MessageDeFin{\newlinechar10 \let\Msg\message \Msg{^^J}% \Msg{********************************************************************^^J}% \Msg{*^^J}% \Msg{* To finish the installation you have to move the following^^J}% \Msg{* files into a directory searched by TeX:^^J}% \Msg{*^^J}% \Msg{*\space\space\space\space xintkernel.sty^^J}% \Msg{*\space\space\space\space xintcore.sty^^J}% \Msg{*\space\space\space\space xint.sty^^J}% \Msg{*\space\space\space\space xintbinhex.sty^^J}% \Msg{*\space\space\space\space xintgcd.sty^^J}% \Msg{*\space\space\space\space xintfrac.sty^^J}% \Msg{*\space\space\space\space xintseries.sty^^J}% \Msg{*\space\space\space\space xintcfrac.sty^^J}% \Msg{*\space\space\space\space xintexpr.sty^^J}% \Msg{*\space\space\space\space xinttools.sty^^J}% \Msg{*^^J}% \Msg{* To produce the documentation run latex thrice on xint.tex^^J} \Msg{* then dvipdfmx on xint.dvi. Edit xint.tex to get the code^^J} \Msg{* source included.^^J} \Msg{* dvipdfmx warnings may be ignored, but if the produced pdf^^J} \Msg{* has font problems, run rather pdflatex on xint.tex^^J} \Msg{*^^J}% \Msg{* Happy TeXing!^^J}% \Msg{*^^J}% \Msg{********************************************************************^^J}% }% \begingroup \input docstrip.tex \askforoverwritefalse \catcode9 11 % do not kill TAB in producing Makefile.mk \generate{\nopreamble\nopostamble \file{README.md}{\from{xint.dtx}{readme}} \file{CHANGES.md}{\from{xint.dtx}{changes}} % pure tex will use ^^I notation for TAB character, don't want that. % there is a problem with xelatex, as it generates ^^I also. \ifnum\noetex=1 \else\ifx\XeTeXinterchartoks\undefined \file{Makefile.mk}{\from{xint.dtx}{makefile}}\fi\fi \file{doHTMLs.sh}{\from{xint.dtx}{dohtmlsh}} \file{doPDFs.sh}{\from{xint.dtx}{dopdfsh}} \usepreamble\defaultpreamble \usepostamble\defaultpostamble \file{pandoctpl.latex}{\from{xint.dtx}{pandoctpl}} \file{xint.ins}{\from{xint.dtx}{ins}} \file{xint.tex}{\from{xint.dtx}{drv}} \file{xintkernel.sty}{\from{xint.dtx}{xintkernel}} \file{xinttools.sty}{\from{xint.dtx}{xinttools}} \file{xintcore.sty}{\from{xint.dtx}{xintcore}} \file{xint.sty}{\from{xint.dtx}{xint}} \file{xintbinhex.sty}{\from{xint.dtx}{xintbinhex}} \file{xintgcd.sty}{\from{xint.dtx}{xintgcd}} \file{xintfrac.sty}{\from{xint.dtx}{xintfrac}} \file{xintseries.sty}{\from{xint.dtx}{xintseries}} \file{xintcfrac.sty}{\from{xint.dtx}{xintcfrac}} \file{xintexpr.sty}{\from{xint.dtx}{xintexpr}}} \endgroup \fi % end of file extraction (from etex/latex/pdflatex/... run on xint.dtx) \ifnum\extractfiles=0 % no LaTeX, files now extracted. Stop. \MessageDeFin\expandafter\end \fi % From this point on, run is necessarily with e-TeX. % Check if \MessageDeFin got defined, if yes put it at end of run. \ifdefined\MessageDeFin\AtEndDocument{\MessageDeFin}\fi %----------------------------------------------------------------- % -*- coding: utf-8; mode: latex -*- % \ifdefined\dosourcexint % this toggle is set from make sourcexint.pdf rule \chardef\NoSourceCode 0 \else \chardef\dosourcexint 0 \fi % default is to assume latex + dvipdfmx \chardef\Withdvipdfmx 1 \RequirePackage{ifpdf} \RequirePackage{ifxetex} \ifpdf \chardef\Withdvipdfmx 0 \fi \ifxetex\chardef\Withdvipdfmx 0 \fi \ifnum\Withdvipdfmx=1 \def\pgfsysdriver{pgfsys-dvipdfm.def} \documentclass [dvipdfm, dvipdfmx, dvipdfmx-outline-open]{scrdoc} \else \documentclass {scrdoc} \fi \PassOptionsToPackage{bookmarks=true}{hyperref} \ifnum\NoSourceCode=1 \OnlyDescription\fi \pagestyle{headings} \makeatletter \def\buggysectionmark #1{% KOMA 3.12 as released to CTAN December 2013 \if@twoside\expandafter\markboth\else\expandafter\markright\fi {\MakeMarkcase{\ifnumbered{section}{\sectionmarkformat\fi}{}#1}}{}} \ifx\buggysectionmark\sectionmark \def\sectionmark #1{% \if@twoside\expandafter\markboth\else\expandafter\markright\fi {\MakeMarkcase{\ifnumbered{section}{\sectionmarkformat}{}#1}}{}} \fi \makeatother \ifxetex \else \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} % 2016-02-28 % This is for use in pre-CTAN version of the dtx. Not needed for CTAN % xint.dtx. Again an annoying preamble-only restriction whose rationale % escape me. (The obelus serves to clean up the private sources from comments % of the type as this one before uploading to CTAN). % TS1 declarations loaded by newtxtt. % \DeclareUnicodeCharacter{00F7}{\textdiv} \def\PrivateObelus{\textdiv }% \AtBeginDocument{\DeclareUnicodeCharacter {00F7}{\PrivateObelus}}% % utilisé où ? (2016/12/08) \DeclareUnicodeCharacter {03B4}{\ensuremath{\delta}}% \fi \DeclareUnicodeCharacter{03BE}{\ensuremath{\xi}} \usepackage{multicol} \usepackage{geometry} \AtBeginDocument {\ttzfamily \newgeometry{textwidth=\dimexpr92\fontcharwd\font`X\relax, vscale=0.75}} \unless\ifnum\dosourcexint=1 \usepackage{xintexpr} \usepackage{xintbinhex} \usepackage{xintgcd} \usepackage{xintseries} \usepackage{xintcfrac} \usepackage{amsmath} % for use of \cfrac in the documentation \usepackage{pifont} % pour la hollow star \ding{73} \fi \usepackage{xinttools} \usepackage{enumitem} \usepackage{varioref} \usepackage{etoolbox} \usepackage{tocloft} \usepackage{etoc}[2013/10/16] % I need \etocdepthtag.toc %---- USE OF ETOC FOR THE TABLES OF CONTENTS \def\gobbletodot #1.{} \newif\ifinmanualmaintoc % 1 avril 2014 \ifnum\dosourcexint=0 \inmanualmaintoctrue \fi \def\sectioncouleur{{cyan}} \def\MARGEPAGENO {1.5em}% changera pour la partie implémentation \def\SKIPSECTIONINTERSPACE{\vskip\bigskipamount} \etocsetstyle{section}{} {\normalfont} {\etociffirst{}{\SKIPSECTIONINTERSPACE}% \rightskip \MARGEPAGENO\relax \parfillskip -\MARGEPAGENO\relax \bfseries \leftskip \leftmarginii \noindent\llap % \llap {\makebox[\leftmarginii][l]% et \leftmargini le 12/10/2014 {\expandafter\textcolor\sectioncouleur {\etocnumber}}}% \strut\etocname \mdseries\nobreak\leaders\etoctoclineleaders\hfill\nobreak\strut \makebox[\MARGEPAGENO][r]{\etocpage}\par \let\ETOCsectionnumber\etocthenumber }% {}% \newdimen\margegauchetoc \AtBeginDocument{\margegauchetoc \dimexpr 5\fontcharwd\font`X\relax} \makeatletter \etocsetstyle{subsection} {\begingroup\normalfont \setlength{\premulticols}{0pt}% \setlength{\multicolsep}{0pt}% \setlength{\columnsep}{\leftmarginii}% \setlength{\columnseprule}{.4pt}% n'influence pas séparation colonnes \parskip\z@skip \raggedcolumns \addvspace{\smallskipamount}% \begin{multicols}{2} \leftskip \margegauchetoc % 12 octobre 2014 \ifinmanualmaintoc \rightskip \MARGEPAGENO \else \rightskip \MARGEPAGENO plus 2em minus 1em \fi \parfillskip -\MARGEPAGENO\relax } {} {\noindent \etocifnumbered{\llap{\makebox[\margegauchetoc][l]{\ttzfamily\bfseries\etoclink {\ifinmanualmaintoc\expandafter\textcolor\sectioncouleur {\normalfont\bfseries\ETOCsectionnumber}\fi .\expandafter\gobbletodot\etocthenumber}}}}{\kern-\margegauchetoc}% \strut\etocname\nobreak \unless\ifinmanualmaintoc\leaders\etoctoclineleaders\fi \hfill\nobreak \strut\makebox[\MARGEPAGENO][r]{\small\etocpage}\endgraf } {\end{multicols}\endgroup\addvspace{\smallskipamount}}% \etocsetstyle{subsubsection} {\begingroup\normalfont\small \leftskip \dimexpr\leftmargini+1em\relax } {} {\noindent \llap{\makebox[\dimexpr\leftmargini+1em\relax][l]% {\ttzfamily\bfseries\etoclink {.\expandafter\gobbletodot\etocthenumber}}}% \strut\etocname\nobreak \leaders\etoctoclineleaders \hfill\nobreak \strut\makebox[\MARGEPAGENO][r]{\small\etocpage}\endgraf } {\endgroup }% \etocsetlevel{table}{6} \makeatother \addtocontents{toc}{\protect\hypersetup{hidelinks}} \usepackage[zerostyle=a,straightquotes,scaled=0.95]{newtxtt} \usepackage{newtxmath} \makeatletter \DeclareFontFamily{T1}{newtxttb}{\hyphenchar\font\m@ne} \DeclareFontShape{T1}{newtxttb}{m}{n}{ <-> s*[\newtxtt@scale]newtxttbq }{} \DeclareFontShape{T1}{newtxttb}{b}{n}{ <-> s*[\newtxtt@scale]newtxbttbq }{} \DeclareFontShape{T1}{newtxttb}{bx}{n}{ <-> ssub * newtxttb/b/n }{} \DeclareFontShape{T1}{newtxttb}{m}{sl}{ <-> s*[\newtxtt@scale]newtxttslbq }{} \DeclareFontShape{T1}{newtxttb}{m}{it}{ <-> ssub * newtxttb/m/sl }{} % Ajouté le 9 mars 2016 \DeclareFontShape{T1}{newtxttb}{m}{sc}{%cap & small cap <-> s*[\newtxtt@scale]newtxttscbq }{} \DeclareFontShape{T1}{newtxttb}{b}{sc}{%bold cap & small cap <-> s*[\newtxtt@scale]newtxbttscbq }{} \DeclareFontShape{T1}{newtxttb}{b}{sl}{%bold slanted <-> s*[\newtxtt@scale]newtxbttslbq }{} \DeclareFontShape{T1}{newtxttb}{b}{it}{%bold italic <-> ssub * newtxttb/b/sl% }{} \DeclareFontShape{T1}{newtxttb}{bx}{sc}{%bold extended cap & small cap <-> ssub * newtxttb/b/sc% }{} \DeclareFontShape{T1}{newtxttb}{bx}{sl}{%bold extended slanted <-> ssub * newtxttb/b/sl% }{} \DeclareFontShape{T1}{newtxttb}{bx}{it}{%bold extended italic <-> ssub * newtxttb/b/sl% }{} % Ajouté le 9 mars 2016 \DeclareEncodingSubset{TS1}{newtxttb}{0} \DeclareFontFamily{TS1}{newtxttb}{\hyphenchar\font\m@ne} \DeclareFontShape{TS1}{newtxttb}{m}{n}{%medium <-> s*[\newtxtt@scale]tcxtt% }{} \DeclareFontShape{TS1}{newtxttb}{m}{sc}{%cap & small cap <->ssub * newtxttb/m/n% }{} \DeclareFontShape{TS1}{newtxttb}{m}{sl}{%slanted <-> s*[\newtxtt@scale]tcxttsl% }{} \DeclareFontShape{TS1}{newtxttb}{m}{it}{%italic <->ssub * newtxttb/m/sl% }{} \DeclareFontShape{TS1}{newtxttb}{b}{n}{%bold <-> s*[\newtxtt@scale]tcxbtt% }{} \DeclareFontShape{TS1}{newtxttb}{b}{sc}{%bold cap & small cap <->ssub * newtxttb/b/n% }{} \DeclareFontShape{TS1}{newtxttb}{b}{sl}{%bold slanted <-> s*[\newtxtt@scale]tcxbttsl% }{} \DeclareFontShape{TS1}{newtxttb}{b}{it}{%bold italic <->ssub * newtxttb/b/sl% }{} \DeclareFontShape{TS1}{newtxttb}{bx}{n}{%bold extended <->ssub * newtxttb/b/n% }{} \DeclareFontShape{TS1}{newtxttb}{bx}{sc}{ %bold extended cap & small cap <->ssub * newtxttb/b/sc% }{} \DeclareFontShape{TS1}{newtxttb}{bx}{sl}{%bold extended slanted <->ssub * newtxttb/b/sl% }{} \DeclareFontShape{TS1}{newtxttb}{bx}{it}{%bold extended italic <->ssub * newtxttb/b/it% }{} \makeatother \newcommand\ttbfamily {\fontfamily{newtxttb}\selectfont } \def\digitstt #1{\begingroup\color[named]{OrangeRed}#1\endgroup} \let\dtt\digitstt \ifnum\dosourcexint=1 \else \renewcommand\familydefault\ttdefault \usepackage[noendash]{mathastext}% pas de endash dans newtxtt \fi \renewcommand\familydefault\sfdefault % <-- sans-serif in footnotes, TOC, % headers etc... \usepackage{xspace} \usepackage[dvipsnames]{xcolor} \usepackage{framed} \makeatletter \newenvironment{snugframed}{% \fboxsep \dimexpr2\fontcharwd\font`X\relax \advance\linewidth-2\fboxsep \advance\csname @totalleftmargin\endcsname \fboxsep \def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep \fbox{##1}\hskip-\fboxsep % There is no \@totalrightmargin, so: \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}% \MakeFramed {\advance\hsize-\width \@totalleftmargin\z@ \linewidth\hsize \@setminipage}% }{\par\unskip\@minipagefalse\endMakeFramed} \makeatother \definecolor{joli}{RGB}{225,95,0} \definecolor{JOLI}{RGB}{225,95,0} \definecolor{BLUE}{RGB}{0,0,255} \definecolor{niceone}{RGB}{38,128,192} \usepackage[para]{footmisc} \usepackage[english]{babel} \usepackage[autolanguage,np]{numprint} \AtBeginDocument{\npthousandsep{,\hskip .5pt plus .1pt minus .1pt}} \usepackage[pdfencoding=pdfdoc]{hyperref} \hypersetup{% linktoc=all,% breaklinks=true,% colorlinks=true,% urlcolor=niceone,% linkcolor=blue,% pdfauthor={Jean-Fran\c cois Burnol},% pdftitle={The xint bundle},% pdfsubject={Arithmetic with TeX},% pdfkeywords={Expansion, arithmetic, TeX},% pdfstartview=FitH,% pdfpagemode=UseOutlines} \usepackage{hypcap} \ifnum\dosourcexint=1 \hypersetup{pdftitle={The xint bundle source code}} \fi \usepackage{bookmark} \usepackage{picture} % permet d'utiliser des unités dans les dimensions de la % picture et dans \put \usepackage{graphicx} \usepackage{eso-pic} %---- \MyMarginNote: a simple macro for some margin notes with no fuss \makeatletter \def\MyMarginNote {\@ifnextchar[\@MyMarginNote{\@MyMarginNote[]}}% \let\inmarg\MyMarginNote \def\@MyMarginNote [#1]#2{\@bsphack \vadjust{\vskip-\dp\strutbox \smash{\hbox to 0pt {\color[named]{PineGreen}\normalfont\small \hsize 1.6cm\rightskip.5cm minus.5cm \hss\vtop{#2}\ $\to$#1\ }}% \vskip\dp\strutbox }\strut\@esphack} \def\MyMarginNoteWithBrace #1{\@bsphack \vadjust{\vskip-\dp\strutbox \smash{\hbox to 0pt {\color[named]{PineGreen}%\normalfont\small \hss #1\ $\bigg\{$\ }}% \vskip\dp\strutbox }\strut\@esphack} \def\IMPORTANT {\MyMarginNoteWithBrace {\raisebox{-.5\height}{\resizebox{2\width}{!}{\ding{43}}}}} \def\etype #1{\@bsphack \vadjust{\vskip-\dp\strutbox \smash{\hbox to 0pt {\hss\color[named]{PineGreen}% \itshape \xintListWithSep{\,}{#1}\ $\star$\quad }}% \vskip\dp\strutbox }\strut\@esphack} \def\retype #1{\@bsphack \vadjust{\vskip-\dp\strutbox \smash{\hbox to 0pt {\hss\color[named]{PineGreen}% \itshape \xintListWithSep{\,}{#1}\ \ding{73}\quad }}% \vskip\dp\strutbox }\strut\@esphack} \def\ntype #1{\@bsphack \vadjust{\vskip-\dp\strutbox \smash{\hbox to 0pt {\hss\color[named]{PineGreen}% \itshape \xintListWithSep{\,}{#1}\quad }}% \vskip\dp\strutbox }\strut\@esphack} %------------------------------------------------------------------------------- \def\Numf {{\vbox{\halign{\hfil##\hfil\cr \footnotesize \upshape Num\cr \noalign{\hrule height 0pt \vskip1pt\relax} \itshape f\cr}}}} \def\Ff {{\vbox{\halign{\hfil##\hfil\cr \footnotesize \upshape Frac\cr \noalign{\hrule height 0pt \vskip1pt\relax} \itshape f\cr}}}} \def\numx {{\vbox{\halign{\hfil##\hfil\cr \footnotesize \upshape num\cr \noalign{\hrule height 0pt \vskip1pt\relax} \itshape x\cr}}}} %------------------------------------------------------------------------------- \def\NewWith #1{\@bsphack \vadjust{\vskip-\dp\strutbox \smash{\hbox to 0pt {\hss\color[named]{PineGreen}% \normalfont\small \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent New with #1}\ }}% \vskip\dp\strutbox }\strut\@esphack} \def\CHANGED #1{\@bsphack \vadjust{\vskip-\dp\strutbox \smash{\hbox to 0pt {\hss\color[named]{Red}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent Changed at #1!}\ }}% \vskip\dp\strutbox }\strut\@esphack} \def\DEPRECATED #1{\@bsphack \vadjust{\vskip-\dp\strutbox \smash{\hbox to 0pt {\hss\color[named]{PineGreen}% \normalfont\small \hsize 2cm\rightskip.5cm minus.5cm \vtop{\noindent Deprecated! (#1)}\ }}% \vskip\dp\strutbox }\strut\@esphack} \def\CHANGEDf #1{\@bsphack \vadjust{\vskip-\dp\strutbox \smash{\hbox to 0pt {\hss\color[named]{PineGreen}% \normalfont\small \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent Changed (#1)}\ \kern\dimexpr\FrameSep+\FrameRule\relax}}% \vskip\dp\strutbox }\strut\@esphack} \def\NewWithf #1{\@bsphack \vadjust{\vskip-\dp\strutbox \smash{\hbox to 0pt {\hss\color[named]{PineGreen}% \normalfont\small \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent New with #1}\ \kern\dimexpr\FrameSep+\FrameRule\relax}}% \vskip\dp\strutbox }\strut\@esphack} \makeatother % \centeredline: OUR OWN LITTLE MACRO FOR CENTERING LINES % ======================================================= % 7 mars 2013 % ----------- % % This macro allows to conveniently center a line inside a paragraph and still % allow use therein of \verb or other macros changing catcodes. % A proposito, the \LaTeX \centerline uses \hsize and not \linewidth ! % (which in my humble opinion is bad) % Actually my \centeredline works nicely in list environments. % \ignorespaces ajouté le 9 juin 2013. % Note: \centeredline creates a group \makeatletter \newcommand*\centeredline {% \ifhmode \\\relax \def\centeredline@{\hss\egroup\hskip\z@skip\ignorespaces }% \else \def\centeredline@{\hss\egroup }% \fi \afterassignment\@centeredline \let\next=} \def\@centeredline {\hbox to \linewidth \bgroup \hss \bgroup \aftergroup\centeredline@ } \newif\ifinlefted \newcommand*\leftedline {% \ifhmode \\\relax \def\leftedline@{\hss\egroup\hskip\z@skip\ignorespaces }% \else \def\leftedline@{\hss\egroup }% \fi \afterassignment\@leftedline \let\next=} \def\@leftedline {\hbox to \linewidth \bgroup \inleftedtrue \everbatimeverypar \bgroup \aftergroup\leftedline@ } \makeatother % verbatim environments % ===================== % % June 2013, then October 2014. % ----------------------------- % \makeatletter \catcode`_ 11 % some of my verbatim environments do not make the space active (\lverb e.g.). Then % \do@noligs must be modified, \char`#1 must be followed by a space token, else, % the `#1 expansion will swallow one space. \def\do@noligs #1{% \catcode`#1\active \begingroup \lccode`~`#1\relax \lowercase{% \endgroup\def~{\leavevmode\kern\z@\char`#1 }}% } %--- \lowast \def\lowast{\raisebox{-.25\height}{*}} \catcode`* 13 \def\makestarlowast {\let*\lowast\catcode`\*\active}% \catcode`* 12 %--- for soft-wrapping. I will use discretionaries. \DeclareFontFamily{U}{MdSymbolC}{} \DeclareFontShape {U}{MdSymbolC}{m}{n}{<-> MdSymbolC-Regular}{} \newbox\SoftWrapIcon \colorlet {softwrapicon}{blue} \def\SetSoftWrapIcon{% \setbox\SoftWrapIcon\hb@xt@\z@ {\hb@xt@\fontdimen2\font {\hss{\color{softwrapicon}\usefont{U}{MdSymbolC}{m}{n}\char"97}\hss}% \hss}% } \AtBeginDocument {\SetSoftWrapIcon }% ttzfamily déjà fait %--- \MacroFont, and a \MicroFont % % Ne PAS mettre de changement de taille de police dans \MacroFont. \def\restoreMicroFont {\def\MicroFont {\ttbfamily\makestarlowast \ifinlefted\else\ifineverb\else\color[named]{Blue}\fi\fi}} \restoreMicroFont % Notice that \macrocode uses \macro@font which freezes \MacroFont % at \begin{document}. But doc.sty verbatim uses \MacroFont which is not % frozen. Comprenne qui pourra... \def\restoreMacroFont {\def\MacroFont {\ttbfamily \ifinlefted\else\ifineverb\else\color[named]{Blue}\fi\fi}} \restoreMacroFont %--- straight quotes, also in macrocode (2014/11/04) % % There is no hook in \macrocode after \dospecials, which is done *after* % \macro@font. Thus I will need to take the risk that some future evolution of % doc.sty (or perhaps scrdoc) invalidates the following. % % Note: in contrast, \MacroFont in \verbatim is done *after* \dospecials (but % before the space becomes active), thus I could use \MacroFont there. But as % there is no verbatim environment anymore in xint.dtx, I don't need to take % care of it. % % Actually, I should not at all rely on the doc class, I should do it all by % myself. As I don't use at all \DocInput (which caused me loads of problems % back then when I was trying to get a workflow satisfying my views on how % .dtx files should be structured), there is not much rationale for using the % doc class. % \def\macrocode{\macro@code \frenchspacing \@vobeyspaces \makestarlowast %\makequotesstraight \xmacro@code } % ---- a new \verb % Initially, June 2013, then Sep 9, 2014, and Oct 9-12 2014 % % Initial motivation was simply that doc.sty and related classes \verb % macro is with a hard-coded \ttfamily. There were further issues. % % 1. with |stuff with space|, paragraph reformatting in the Emacs/AUCTeX % buffer caused havoc. Thus I wanted to be able to have the input across % lines. % % 2. Hence I did not want to have spaces obeyed, as often the % reformatting added spaces at the beginning of a line. % % 3. Also I wanted to allow hyphenation on output, at least at some % locations. I did a first version which treated spaces, \, {, and } % specially. % % 4. at some point I wanted to add some colored background (I have % dropped that since due to pdf file size increase). % % 5. and also I got fed up from the non-compatibility with footnotes due % to catcode freeze. % % Because of 5. I opted for a \scantokens approach, hence for a macro % with delimited argument. Here is what I do now, this is compatible % with short verbs. \def\verb {% \relax \ifmmode\else\leavevmode\null\fi \bgroup \let\do\@makeother \dospecials \MicroFont % change font, color, catcode hooks, ... \catcode 32 10 \endlinechar 32 \@@jfverb }% % Note (Oct 12, 2014): in the improbable situation a newlinechar is % found in the ##1, \scantokens will convert this to an end of line in % its "write" phase, which will be then ignored in its "read" phase due % to \endlinechar-1. This also avoids possible creation of \par which % would defeat \@@jfverb@@. Thus it is good. \def\@@jfverb #1{% \ifcat\noexpand#1\noexpand~\catcode`#1\active\fi % No problem with the EOL for the line where the short verb delimiter stands. \def\next ##1#1{% \@vobeyspaces\everyeof{\relax}\endlinechar\m@ne \expandafter\@@jfverb_a\scantokens\expandafter{##1}}% % hack with \@empty to prevent brace stripping if catcodes have been % frozen earlier, like in footnotes. \next \@empty } % We don't want a \discretionary at the very start. % But then an empty argument is forbidden! \def\@@jfverb_a #1{#1\@@jfverb_b } \def\@@jfverb_b #1{\ifx\relax #1% \egroup \else % \penalty\z@, or rather (Oct 11, 2014) but I then adjust the textwidth % precisely: \discretionary{\copy\SoftWrapIcon}{}{}% #1\expandafter\@@jfverb_b\fi } \catcode`_ 8 \makeatother % --- \lverb % Définition de \lverb % Has become more complicated for 1.2l \makeatletter\catcode`_ 11 {\catcode32\active% \gdef\myobeyspaces{\catcode32\active\def {\leavevmode\kern\fontcharwd\font`X}}} \def\lverbpercent {\catcode32\active\lverbpercent_a}% \def\lverbpercent_a #1{% \if\XINT_sptoken\detokenize{#1}\xint_dothis{\catcode32 10 }\fi \if-\detokenize{#1}\xint_dothis{\par #1}\fi \if(\detokenize{#1}\xint_dothis{\par\bgroup\myobeyspaces\obeylines}\fi \if:\detokenize{#1}\xint_dothis{}\fi \if)\detokenize{#1}\xint_dothis{\egroup\everypar{\hskip-\parindent\everypar{}}}\fi \ifx#1\lverbpercent\xint_dothis{\catcode32 10 \par #1}\fi \xint_orthat{\catcode32 10 #1}% } \catcode`_ 8 \long\def\lverb {% \relax\par\smallskip\noindent\null \begingroup \bgroup \aftergroup\@@par \aftergroup\endgroup \aftergroup\medskip \let\do\do@noligs \verbatim@nolig@list \let\do\@makeother \dospecials \def\PrivateObelus{\par\noindent\textdiv}% \catcode32 10 \catcode`\& 14 \catcode`\$ 0 \catcode`\% \active \begingroup\lccode`\~`\%\lowercase{\endgroup\let~\lverbpercent}% \MicroFont % sera donc en couleur. \@lverb } \def\@lverb #1{\catcode`#1\active \lccode`\~`#1\lowercase{\let~\egroup}}% \makeatother %--- everbatim environment % October 13-14, 2014 % Verbatim with an \everypar hook, mainly to have background color, followed by % execution of the code \makeatletter \catcode`_ 11 \def\everbatimtop {\MacroFont\small } \let\everbatimbottom\relax \let\everbatimhook\relax \newif\ifineverb \def\everbatim {\s@everbatim\@everbatim } \@namedef{everbatim*}{\s@everbatim\expandafter\@everbatimx\expandafter {\the\newlinechar}} \def\everbatimeverypar{\strut {\color{yellow!5}\vrule\@width\linewidth }% \kern-\linewidth \kern\everbatimindent } \def\everbatimindent {\z@} % voir plus loin atbegindocument \def\endeverbatim {\if@newlist \leavevmode\fi\endtrivlist } \expandafter\let\csname endeverbatim*\endcsname \endeverbatim \def\s@everbatim {% \ineverbtrue \everbatimtop % put there size changes \topsep \z@skip \partopsep \z@skip \itemsep \z@skip \parsep \z@skip \parskip \z@skip \lineskip \z@skip \let\do\@makeother \dospecials \let\do\do@noligs \verbatim@nolig@list \makestarlowast \everbatimhook \trivlist\item\relax \leftskip \@totalleftmargin \rightskip \z@skip \parindent \z@ \parfillskip\@flushglue \parskip \z@skip \@@par \def\par{\leavevmode\null\@@par\pagebreak[1]}% \everypar\expandafter{\the\everypar \unpenalty \everbatimeverypar \everypar \expandafter{\the\everypar\everbatimeverypar}% }% \obeylines \@vobeyspaces } \begingroup \lccode`X 13 \catcode`X \active \lccode`Y `* % this is because of \makestarlowast. % I have to think whether this is useful: obviously if I were to provide % everbatim and everbatim* in a package I wouldn't do that. \catcode`Y \active \catcode`| 0 \catcode`[ 1 \catcode`] 2 \catcode`* 12 \catcode`{ 12 \catcode`} 12 |catcode`\\ 12 |lowercase[|endgroup% both freezes catcodes and converts X to active ^^M |def|@everbatim #1X#2\end{everbatim}% [#2|end[everbatim]|everbatimbottom ] |def|@everbatimx #1#2X#3\end{everbatimY}]% {#3\end{everbatim*}% \everbatimbottom \newlinechar 13 \everbatimxprehook \scantokens {#3}% \newlinechar #1\relax \everbatimxposthook }% % L'espace venant du endofline final mis par \scantokens sera inhibé si #3 se % termine par un % ou un \x, etc... \def\everbatimxprehook {\colorlet{everbsavedcolor}{.}\color[named]{OrangeRed}} \def\everbatimxposthook {\color{everbsavedcolor}} \ifpdf \def\everbatimxprehook {\pdfcolorstack\@pdfcolorstack push{0 1 0.5 0 k 0 1 0.5 0 K}\relax} \def\everbatimxposthook {\pdfcolorstack\@pdfcolorstack pop\relax} \else \ifxetex \def\everbatimxprehook {\special{color push cmyk 0 1 0.5 0}} \def\everbatimxposthook {\special{color pop}} \else \ifnum\Withdvipdfmx=1 \def\everbatimxprehook {\special{pdf:bcolor OrangeRed}} \def\everbatimxposthook {\special{pdf:ecolor}} \fi\fi\fi % --- \everb % Original was called \dverb and I did it in June 2013. % Then after doing everbatim, I transformed \dverb, now called \everb % for itself being as compatible as standard verbatim with list making % surrounding environments. % Supposed to be used as % \everb|@ this will be ignored % stuff % escape character: " % | not necessarily starting a line. % I chose @ as comment character, mainly for pretty-formatting of the % source, this can be changed by \everbhook. % " comme caractère d'échappement. Par exemple pour colorier des parties. \def\restoreeverbhook{\def\everbhook{% \def\"{\begingroup\catcode123 1 \catcode 125 2 \everbescape }% \catcode`\" 0 \catcode`\@ 14 }}\restoreeverbhook \def\everbescape #1;!{#1\endgroup } \def\everb {% \bgroup \let\everbatimhook\everbhook \s@everbatim \@everb } \def\@everb #1{\catcode`#1\active \lccode`\~`#1% \lowercase{\def~{\if@newlist \leavevmode\fi \endtrivlist \egroup \@doendpe \everbatimbottom }}% }% \catcode`_8 \makeatother %--- \csa, \csbxint, \csh, \csbh % dates back to earliest versions of this manual, but I changed things a bit % (back then for example @ was active throughout the document...) % The mark-up being in place, I only have to use it here. \DeclareRobustCommand\csa [1] {{\MicroFont\char92\endlinechar-1 \catcode`_ 11 \scantokens\expandafter{\detokenize{#1}}}} \DeclareRobustCommand\csbnolk [1] {{\MicroFont\char92\endlinechar-1 \scantokens\expandafter{\detokenize{#1}}}} \DeclareRobustCommand\csbxint [1] {\hyperref[\detokenize{xint#1}]% {{\ttzfamily\char92\mbox{xint}\-\endlinechar-1 \makestarlowast \scantokens\expandafter{\detokenize{#1}}}}} \DeclareRobustCommand\csb [1] {\hyperref[\detokenize{#1}]% {{\ttzfamily\char92 \endlinechar-1 \makestarlowast \scantokens\expandafter{\detokenize{#1}}}}} \newcommand\csh[1] {\texorpdfstring{\csa{#1}}{\textbackslash\detokenize{#1}}} \newcommand\csbh[1] {\texorpdfstring{\csbnolk{#1}}{\textbackslash\detokenize{#1}}} % --- \xintname, \xintnameimp etc... \xintForpair #1#2 in {(xintkernel,kernel), (xinttools,tools), (xintcore,core),(xint,xint),(xintbinhex,binhex),(xintgcd,gcd),% (xintfrac,frac),(xintseries,series),(xintcfrac,cfrac),(xintexpr,expr)} \do {% \expandafter\def\csname #1name\endcsname {\texorpdfstring {\hyperref[sec:#2]% {\relax{\color{joli}\ttzfamily #1}}} {#1}% \xspace }% \expandafter\def\csname #1nameimp\endcsname {\texorpdfstring {\hyperref[sec:#2imp]% {\relax{\color[named]{RoyalPurple}\ttzfamily #1}}} {#1}% \xspace }% }% %--- \printnumber \catcode`_ 11 \makeatletter \catcode`& 3 \def\allowsplits_a {\futurelet\printnumber_token\allowsplits_b }% \def\allowsplits_b{\ifx\printnumber_token\@sptoken\space\fi\allowsplits_c } \def\allowsplits_c #1{\ifx \xint_dothis\xint_gobble_i\fi \if ,#1\xint_dothis {\discretionary{\rlap,}{}{,}}\fi \xint_orthat{\discretionary {\copy\SoftWrapIcon}% {}% {}#1}\allowsplits_a }% \def\printnumber #1{\expandafter\allowsplits_a \romannumeral-`0#1&}% \hyphenpenalty \z@ \catcode`& 4 \makeatother \catcode`_ 8 %--- counts used in particular in the samples from the documentation of the % xintseries.sty package \newcount\cnta \newcount\cntb \newcount\cntc %--- \fexpan 22 octobre 2013 \newcommand\fexpan {\hyperref[ssec:expansions]{\textit{f}-expan}} \ifnum\dosourcexint=1 \else % Dependency graph done using TikZ (manually) \usepackage{tikz} \usetikzlibrary{shapes,arrows.meta} \fi \colorlet {codeboxbg}{yellow!10} \colorlet {codeboxframe}{black!30} \colorlet {execboxfringe}{black!10} \AtBeginDocument{% \leftmargini \dimexpr4\fontcharwd\font`X\relax \leftmarginii\dimexpr3\fontcharwd\font`X\relax \leftmarginiii \leftmarginii \leftmarginiv \leftmarginii \parindent\dimexpr2\fontcharwd\font`X\relax \leftmargin\leftmargini % pourquoi pas 0? % formerly everbatim indent was set to leftmargingi, reduce it (2017/08/26) % \edef\everbatimindent{\the\dimexpr\leftmargini\relax\space }% % setting it to \parindent does not work with \everb construct % \def\everbatimindent{\parindent}% \edef\everbatimindent{\the\dimexpr2\fontcharwd\font`X\relax\space}% \cftsubsecnumwidth 2\leftmarginii \cftsubsubsecnumwidth 2\leftmargini \cftsubsecindent 0pt \cftsubsubsecindent \cftsubsecnumwidth }% \frenchspacing \renewcommand\familydefault\sfdefault % Septembre 2015 \def\liiibigint{\href{http://latex-project.org/svnroot/experimental/trunk/l3trial/l3bigint}{l3bigint}} \makeatletter \def\fixmeaning {\expandafter\fix@meaning\meaning} \expandafter\edef\expandafter\fix@meaning \expandafter #\expandafter1\string\romannumeral#2#3% {#1\string\romannumeral`\string^\string^@} \makeatother \xintverbosetrue \newcommand\func[1]{\hyperlink{\detokenize{func-#1}}{#1}()} \newcommand\funcdesc[1]{\item[#1]\hypertarget{\detokenize{func-#1}}{}}% \newcommand\keyword[1]{\hyperlink{\detokenize{kwd-#1}}{#1}} \newcommand\keyworddesc[1]{\item[#1]\hypertarget{\detokenize{kwd-#1}}{}}% \let\prec\relax % sinon, c'est \mathchar"321E \newcommand\prec[1]{\hyperlink{\detokenize{prec-#1}}{#1}} \newcommand\precdesc[1]{\item[$#1$]\hypertarget{\detokenize{prec-$#1$}}{}}% % \ctexttt is a remnant of 1.09n manual, don't have time to get rid of it now. \newcommand\ctexttt [1]{\begingroup\color[named]{DarkOrchid}%\bfseries #1\endgroup} \begin{document}\thispagestyle{empty}% \ttzfamily already done \pdfbookmark[1]{Title page}{TOP} % \makeatletter % @ n'est plus actif dans dtx 1.1, ouf! {% \normalfont\Large\parindent0pt \parfillskip 0pt\relax \leftskip 2cm plus 1fil \rightskip 2cm plus 1fil \ifnum\dosourcexint=1 The \xintnameimp source code\par \else The \xintname bundle\par \fi } {\centering \textsc{Jean-Fran\c cois Burnol}\par \footnotesize jfbu (at) free (dot) fr\par Package version: \xintbndlversion\ (\xintbndldate); documentation date: \xintdocdate.\par {From source file \texttt{xint.dtx}. \xintdtxtimestamp.}\par } \medskip % Mercredi 08 octobre 2014 à 22:03:19 % Skips safely. \ifnum\dosourcexint=1 \catcode`+ 0 \catcode0 9 % n'importe quoi sauf 15 (car ^^@) \catcode`\\ 12 +expandafter+iffalse+fi \fi \etocsetlevel{toctobookmark}{6} % 9 octobre 2013, je fais des petits tricks. \etocsettocdepth {subsection} \renewcommand*{\etocbelowtocskip}{0pt} \renewcommand*{\etocinnertopsep}{0pt} \renewcommand*{\etoctoclineleaders} {\hbox{\normalfont\normalsize\hbox to 1ex {\hss.\hss}}} \etocmulticolstyle [1]{% \phantomsection\section* {Contents} \etoctoccontentsline*{toctobookmark}{Contents}{1}% } \etocsettagdepth {description}{subsection} \etocsettagdepth {macros}{none} \etocsettagdepth {implementation}{none} \tableofcontents \begingroup\makeatletter \etocsetlevel{table}{0} \etocsetstyle{table} {} {\normalfont} {%\SKIPSECTIONINTERSPACE \rightskip \MARGEPAGENO\relax \parfillskip -\MARGEPAGENO\relax \leftskip \z@skip \noindent\strut \etoclink{Table of \etocthename}% \nobreak\leaders\etoctoclineleaders\hfill\nobreak\strut \makebox[\MARGEPAGENO][r]{\etocpage}\par }% {}% \etocsettagdepth{description}{table} \etocsettagdepth{macros}{none} \etocsettagdepth{implementation}{none} \etocsettocstyle{}{} \medskip \tableofcontents \endgroup \renewcommand*\etocabovetocskip{\bigskipamount} \makeatletter \etocmulticolstyle [2]{\parskip\z@skip\raggedcolumns \setlength{\columnsep}{\leftmarginii}% \setlength{\columnseprule}{0pt}% }% \makeatother \etocsettagdepth {description}{none} \etocsettagdepth {macros} {section} \ifnum\NoSourceCode=1 \etocsettagdepth {implementation}{none} \else \etocsettagdepth {implementation}{section} \fi \tableofcontents \etocignoredepthtags \etocmulticolstyle [1]{% \phantomsection% \section* {Contents} \etoctoccontentsline*{toctobookmark}{Contents}{2}% } \inmanualmaintocfalse \clearpage % ---- % Fibonacci code % December 7, 2013. Expandably computing a big Fibonacci number % with the help of TeX+\numexpr+\xintexpr, (c) Jean-François Burnol \catcode`_ 11 % % ajouté 7 janvier 2014 au xint.dtx pour 1.07j. % % Le 17 janvier je me décide de simplifier l'algorithme car l'original ne tenait % pas compte de la relation toujours vraie A=B+C dans les matrices symétriques % utilisées en sous-main [[A,B],[B,C]]. % % la version ici est celle avec les * omis: car multiplication tacite devant les % sous-expressions depuis 1.09j, et aussi devant les parenthèses depuis 1.09k. % (pour tester) \def\Fibonacci #1{% \expandafter\Fibonacci_a\expandafter {\the\numexpr #1\expandafter}\expandafter {\romannumeral0\xintiieval 1\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiieval 1\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiieval 1\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiieval 0\relax}} % \def\Fibonacci_a #1{% \ifcase #1 \expandafter\Fibonacci_end_i \or \expandafter\Fibonacci_end_ii \else \ifodd #1 \expandafter\expandafter\expandafter\Fibonacci_b_ii \else \expandafter\expandafter\expandafter\Fibonacci_b_i \fi \fi {#1}% }% \def\Fibonacci_b_i #1#2#3{\expandafter\Fibonacci_a\expandafter {\the\numexpr #1/2\expandafter}\expandafter {\romannumeral0\xintiieval sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiieval (2#2-#3)#3\relax}% }% end of Fibonacci_b_i \def\Fibonacci_b_ii #1#2#3#4#5{\expandafter\Fibonacci_a\expandafter {\the\numexpr (#1-1)/2\expandafter}\expandafter {\romannumeral0\xintiieval sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiieval (2#2-#3)#3\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiieval #2#4+#3#5\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiieval #2#5+#3(#4-#5)\relax}% }% end of Fibonacci_b_ii \def\Fibonacci_end_i #1#2#3#4#5{\xintthe#5} \def\Fibonacci_end_ii #1#2#3#4#5{\xinttheiiexpr #2#5+#3(#4-#5)\relax} \catcode`_ 8 \def\Fibo #1.{\Fibonacci {#1}} % nice background added for 1.09j release, January 7, 2014. % superbe, non? moi très content! \def\specialprintone #1% {% \ifx #1\relax \else \makebox[877496sp]{#1}\hskip 0pt plus 2sp\relax \expandafter\specialprintone\fi }% \def\specialprintnumber #1% first ``fully'' expands its argument. {\expandafter\specialprintone \romannumeral-`0#1\relax }% \AddToShipoutPicture*{% \put(10.5cm,14.85cm) {\makebox(0,0) {\resizebox{17cm}{!}{\vbox {\hsize 8cm\Huge\baselineskip.8\baselineskip\color{black!10}% \specialprintnumber{F(1250)=}% \specialprintnumber{\Fibonacci{1250}}}\par}% }% }% } % Samedi 27 septembre 2014 à 16:04:52 \pdfbookmark[1]{Dependency graph}{DependencyGraph} % ligne allant de xinttools vers xintfrac, car il n'y a plus de dépendance % dans \xintXTrunc. \tikzstyle{block} = [rectangle, draw, fill=codeboxbg, fill opacity=0.5,% fill opacity Octobre 2014 draw=codeboxframe, line width=2pt, text width=6em, text centered, rounded corners, minimum height=4em] \tikzstyle{line} = [draw, line width=1pt, color=codeboxframe] \vspace*{\stretch{0.3333}} \begin{figure}[ht!] \phantomsection\label{dependencygraph} \centeredline{% \begin{tikzpicture}[node distance = 2.5cm] % Place nodes \node [block] (kernel) {\xintkernelname}; \node [left of=kernel] (A) {}; \node [right of=kernel] (B) {}; \node [block, below right of=B] (core) {\xintcorename}; \node [block, below left of=A] (tools) {\xinttoolsname}; \node [block, right of=core, xshift=1cm] (bnumexpr) {\href{http://www.ctan.org/pkg/bnumexpr}{bnumexpr}}; \node [block, below of=core] (xint) {\xintname}; \node [block, left of=xint, xshift=-.5cm] (gcd) {\xintgcdname}; \node [block, left of=gcd] (binhex) {\xintbinhexname}; \node [block, below of=xint] (frac) {\xintfracname}; \node [block, below of=frac, yshift=-.5cm] (expr) {\xintexprname}; \node [block, below right of=frac, xshift=1cm] (series) {\xintseriesname}; \node [block, right of=series] (cfrac) {\xintcfracname}; % Draw edges \path [line,-{Stealth[length=5mm]}] (kernel) -- (core); \path [line,-{Stealth[length=5mm]}] (kernel) -- (tools); \path [line,-{Stealth[length=5mm]}] (core) -- (bnumexpr); \path [line,-{Stealth[length=5mm]}] (core) to [out=180,in=90] (gcd.north); \path [line,-{Stealth[length=5mm]}] (kernel) -- (binhex); \path [line,-{Stealth[length=5mm]}] (core) -- (xint); \path [line,-{Stealth[length=5mm]}] (xint) -- (frac); \path [line,-{Stealth[length=5mm]}] (frac) -- (expr); \path [line,-{Stealth[length=5mm]}] (frac) to [out=0,in=90] (series.north); \path [line,-{Stealth[length=5mm]}] (frac) to [out=0,in=90] (cfrac.north); \path [line,dashed,-{Stealth[length=5mm]}] (binhex.south) -- (expr); \path [line,dashed,-{Stealth[length=5mm]}] (gcd.south) -- (expr); \path [line,dashed,-{Stealth[length=5mm]}] (tools) to [out=0, in=90] (gcd.north);% je dois positionner mieux mais pas le temps de lire 700 pages \path [line,dashed,-{Stealth[length=5mm]}] (tools.south west) to [out=270, in=225] (cfrac.south west);% je dois positionner mieux mais pas le temps de lire 700 pages \path [line,-{Stealth[length=5mm]}] (tools) to [out=270,in=180] (expr); \end{tikzpicture}}\bigskip \end{figure} \vspace{2\baselineskip} \begin{addmargin}{2cm} \normalfont\footnotesize Dependency graph for the \xintname bundle components: modules at the bottom \textbf{automatically} import modules at the top when connected by a continuous line. No module will be loaded twice, this is managed internally under Plain as well as \LaTeX. Dashed lines indicate a partial dependency, and to enable the corresponding functionalities of the lower module it is necessary to use the suitable |\usepackage| (\LaTeX) or |\input| (Plain \TeX.)\par Note: at |1.2n| \xintbinhexname has no dependency on \xintcorename anymore, it only loads \xintkernelname. The \href{http://ctan.org/pkg/bnumexpr}{bnumexpr} package is a separate package (\LaTeX{} only) by the author which uses (by default) \xintcorename as its mathematical engine.\par \end{addmargin} \vfill \clearpage \etocdepthtag.toc {description} \section{Read this first}\label{sec:quickintro} This section provides recommended reading on first discovering the package. \begin{addmargin}{1cm} \makeatletter \renewenvironment{description} {\list{}{\topsep\baselineskip\partopsep\z@skip \parsep\z@ \labelwidth\z@ \itemindent-\leftmargin \let\makelabel\descriptionlabel}} {\endlist} \makeatother %\noindent\null\par\kern-\baselineskip \leavevmode \begin{description} \item[\xinttoolsname] provides utilities of independent interest such as expandable and non-expandable loops. \xintgcdname and \xintcfracname have a partial dependency on it but it must be required by user explicitely. \xintexprname loads it automatically. \item[\xintcorename] provides expandable macros implementing addition, subtraction, multiplication, division, and power with arbitrarily long numbers. It is loaded automatically by \xintname, and also by \LaTeX\ package \href{http://ctan.org/pkg/bnumexpr}{bnumexpr} in its default configuration. \item[\xintname] extends \xintcorename with additional operations on big integers. It loads automatically \xintcorename. \item[\xintfracname] extends the scope of \xintname to decimal numbers, to numbers in scientific notation and also to fractions with arbitrarily long such numerators and denominators separated by a forward slash. It loads automatically \xintname. \item[\xintexprname] extends \xintfracname with expandable parsers doing algebra (either exact, float, or limited to big integers) on comma separated expressions using the standard infix notations and parentheses (or sub \xintexprname-essions). It implements tacit multiplication, functions with one or multiple arguments, Python-like slicing of lists, user-definable variables and user-definable functions, boolean two way or three way branching. Dummy variables can be used for summing or multiplying an expression over a range, or for more complicated iterative evaluations allowing \keyword{omit}, \keyword{abort}, and \keyword{break} keywords. It loads automatically \xintfracname (hence \xintname and \xintcorename) and \xinttoolsname. \end{description} Further modules: \begin{description} \item[\xintbinhexname] is for conversions to and from binary and hexadecimal bases. Support in \xintexprname of the \TeX\ |"| prefix for hexadecimal inputs requires this module to be loaded by user. \item[\xintgcdname] implements the Euclidean algorithm and its typesetting. The macro \csbxint{Irr} (hence the \xintexprname function \func{reduce}) is provided independently in \xintfracname. But usage of the \xintexprname \func{gcd} and \func{lcm} functions requires this module to be loaded by user. \item[\xintseriesname] provides some basic functionality for computing in an expandable manner partial sums of series and power series with fractional coefficients. \item[\xintcfracname] is provided to help with the computation and display of continued fractions. \end{description} \end{addmargin} \begin{framed} All macros from the \xintname packages doing computations are \emph{expandable}, and naturally also the parsers provided by \xintexprname. The reasonable range of use of the package arithmetics is with numbers of \emph{up to a few hundred digits.} % Release |1.2| % has significantly improved the speed of the basic operations for numbers % with more than $50$ digits, the speed gains getting better for bigger % numbers. Although numbers up to about \dtt{19950} digits are acceptable inputs, the package is not at his peak efficiency when confronted with such really big numbers having thousands of digits.\footnotemark \end{framed} \footnotetext{The maximal handled size for inputs to multiplication is \dtt{19959} digits. This limit is observed with the current default values of some parameters of the tex executable (input stack size at 5000, maximal expansion depth at 10000). Nesting of macros will reduce it and it is best to restrain numbers to at most \dtt{19900} digits. The output, as naturally is the case with multiplication, may exceed the bound.} \subsection{First examples} With |\usepackage{xintexpr}| if using \LaTeX, or |\input xintexpr.sty\relax| for other formats, you can do computations such as the following. \begin{description} \item[with floats:]\leavevmode\par \begin{everbatim*} \thexintfloatexpr 3.25^100/3.2^100, 2^1000000, sqrt(1000!), 10^-3.5\relax \end{everbatim*} \item[with fractions:]\leavevmode\par \begin{everbatim*} \thexintexpr reduce(add((-1)^(i-1)/i**2, i=1..25))\relax \end{everbatim*} \item[with integers:]\leavevmode\par \begin{everbatim*} \thexintiiexpr 3^159+2^234\relax \end{everbatim*} \end{description} Float computations are done by default with \dtt{16} digits of precision. This can be changed by a prior assignment to |\xintDigits|: \begin{everbatim*} % use braces (or a LaTeX environment) to limit the scope of the \xintDigits assignment {\xintDigits := 88;\thexintfloatexpr 3.25^100-3.2^100\relax}\par \end{everbatim*} We can even try daring things:\footnote{The \cs{printnumber} is not part of the package, see \autoref{ssec:printnumber}.} \begin{everbatim*} {\xintDigits:=500;\printnumber{\thexintfloatexpr sqrt(2)\relax}} \end{everbatim*} \medskip This is release \expandafter|\xintbndlversion|. \begin{enumerate} \item |exp|, |cos|, |sin|, etc... are \emph{yet to be implemented}, \item |NaN|, |+Infty|, |-Infty|, etc... are \emph{yet to be implemented}, \item powers work currently only with integral and half-integral exponents (but the latter only for float expressions), \item \xintname can handle numbers with thousands of digits, but execution times limit the practical range to a few hundreds (if many such computations are needed), \item computations in |\thexintexpr| and |\thexintiiexpr| are exact (except if using |sqrt|, naturally), \item fractions are not systematically reduced to smallest terms, use |reduce| function, \item for producing fixed point numbers with |d| digits after decimal mark, use (note the extra `|i|' in the parser name!) |\thexintiexpr [d] ...\relax|. This is actually essentially synonymous with |\thexintexpr round(..,d)\relax| (for |d=0|, |\thexintiexpr [0]| is the same as |\thexintiexpr| without optional argument, and is like |\thexintexpr round(..)\relax|). If truncation rather than rounding is needed use thus |\thexintexpr trunc(..,d)\relax| (and |\thexintexpr trunc(..)\relax| for truncation to integers), \item all three parsers allow some constructs with dummy variables as seen above; it is possible to define new functions or to declare variables for use in upcoming computations, \item |\thexintiiexpr| is slightly faster than |\thexintexpr|, but usually one can use the latter with no significant time penalty also for integer-only computations. \end{enumerate} All operations executed by the parsers are based on underlying macros from packages \xintfracname and \xintname which are loaded automatically by \xintexprname. With extra packages \xintbinhexname and \xintgcdname the parsers can handle hexadecimal notation on input (even fractional) and compute |gcd|'s or |lcm|'s of integers. All macros doing computations ultimately rely on (and reduce to) the |\numexpr| primitive from \eTeX{}. These \eTeX{} extensions date back to 1999 and are by default incorporated into the |pdftex| etc... executables from major modern \TeX{} installations since more than ten years now. Only the |tex| binary does not benefit from them, as it has to remain the original \textsc{D.~Knuth}'s software, but one can then use |etex| on the command line. PDF\TeX\ (in pdf or dvi output mode), Lua\TeX, Xe\TeX\ all include the \eTeX\ extensions. \subsection{Quick overview (expressions with \xintexprname)} This section gives a first few examples of using the expression parsers which are provided by package \xintexprname. Loading \xintexprname automatically also loads packages \xinttoolsname and \xintfracname. The latter loads \xintname which loads \xintcorename. All three provide the macros which ultimately do the computations associated in expressions with the various symbols like |+, *, ^, !| and functions such as |max, sqrt, gcd| (the latter requires explicit loading of \xintgcdname). The package \xinttoolsname does not handle computations but provides some useful utilities. \begin{framed} Release |1.2h| defines |\thexintexpr| as synonym to |\xinttheexpr|, |\thexintfloatexpr| as synonym of |\xintthefloatexpr|, etc... \end{framed} There are three expression parsers and two subsidiary ones. They all admit comma separated expressions, and will then output a comma separated list of results. \begin{itemize}[nosep] \item \csbxint{theiiexpr}| ... \relax| does exact computations \emph{only on integers.} The forward slash \dtt{/} does the \emph{rounded} integer division to match behaviour of |\the\numexpr /\relax|.\footnote{For floored integer division, see the \dtt{//} operator.} There are two square root extractors \func{sqrt} and \func{sqrtr} for truncated and rounded square roots. Scientific notation |6.02e23| is \emph{not} accepted on input, one needs to wrap it as |num(6.02e23)| which will convert to an integer notation \dtt{\printnumber{\xinttheiiexpr num(6.02e23)\relax}}. \item \csbxint{thefloatexpr}| ... \relax| does computations with a given precision \dtt{P}, as specified via a prior assignment |\xintDigits:=P;|. The default is \dtt{P=16} digits. An optional argument controls the precision for \emph{formatting the output} (this is not the precision of the computations themselves). The four basic operations and the square root realize \emph{correct rounding.}\footnote{when the inputs are already floating point numbers with at most |P|-digits mantissas.} \item \csbxint{theexpr}| ... \relax| handles integers, decimal numbers, numbers in scientific notation and fractions. The algebraic computations are done \emph{exactly.} The |sqrt| function is available and works according to the |\xintDigits| precision or according to its second optional argument. \end{itemize} \begin{framed} Currently, the sole available non-algebraic function is the square root extraction \func{sqrt}. It is allowed in |\xintexpr..\relax| but naturally can't return an \emph{exact} value, hence computes as if it was in |\xintfloatexpr..\relax|. The power operator |^| (equivalently |**|) works with integral exponents only in \csbxint{iiexpr} (non-negative) and \csbxint{expr} (negative exponents allowed, of course) and also with half-integral exponents in \csbxint{floatexpr} (it proceeds via an integral power followed by a square-root extraction). \end{framed} Two derived parsers: \begin{itemize}[nosep] \item \csbxint{theiexpr}| ... \relax| does all computations like |\xinttheexpr ... \relax| but rounds the result to the nearest integer. With an optional positive argument |[D]|, the rounding is to the nearest fixed point number with |D| digits after the decimal mark. \item \csbxint{theboolexpr}| ... \relax| does all computations like |\xinttheexpr ... \relax| but converts the result to $1$ if it is not zero (works also on comma separated expressions). See also the booleans \csbxint{ifboolexpr}, \csbxint{ifbooliiexpr}, \csbxint{ifboolfloatexpr} (which do not handle comma separated expressions). \end{itemize} Here is a (partial) list of the recognized symbols: \begin{itemize}[nosep] \item the comma (to separate distinct computations or arguments to a function), \item parentheses, \item infix operators |+|, |-|, |*|, |/|, |^| (or |**|), \item |//| does floored division\CHANGED{1.2p} and |/:| is associated modulo, \item branching operators |(x)?{x non zero}{x zero}|, |(x)??{x<0}{x=0}{x>0}|, \item boolean operators |!|, |&&| or |'and'|, \verb+||+ or |'or'|, \item comparison operators |=| (or |==|), |<|, |>|, |<=|, |>=|, |!=|, \item factorial post-fix operator |!|, \item |"| for hexadecimal input (uppercase only; package \xintbinhexname must be loaded additionally to \xintexprname), %\item |'| for octal input (\emph{not yet}), \item functions \xintFor #1 in {num, reduce, abs, sgn, frac, floor, ceil, sqr, sqrt, sqrtr, float, round, trunc, mod, quo, rem, max, min, |`+`|, |`*`|, not, all, any, xor, if, ifsgn, even, odd, first, last, reversed, bool, togl, factorial, binomial, pfactorial}\do {\func{#1}, } \item multi-arguments \func{gcd} and \func{lcm} are available if \xintgcdname is loaded, \item functions with dummy variables \xintFor #1 in {add, mul, seq, subs, rseq, iter, rrseq, iterr}\do {\func{#1}\xintifForLast{.}{, }} \end{itemize} See \autoref{xintexpr} for basic information and \autoref{sec:xintexprsyntax} for the built-in syntax elements. The normal mode of operation of the parsers is to unveil the parsed material token by token. This means that all elements may arise from expansion of encountered macros (or active characters). For example a closing parenthesis does not have to be immediately visible, it may arise later from expansion. This general behavior has exceptions, in particular constructs with dummy variables need immediately visible balanced parentheses and commas. The expansion stops only when the ending |\relax| has been found; it is then removed from the token stream, and the final computation result is inserted. Release |1.2| added the (pseudo) functions \func{qint}, \func{qfrac}, \func{qfloat} to allow swallowing in one-go all digits of a big number, fraction, or float, skipping the token by token expansion. \medskip Here is an example of a computation: \begin{everbatim*} \xinttheexpr (31.567^2 - 21.56*52)^3/13.52^5\relax \end{everbatim*}\newline This illustrates that |\xinttheexpr..\relax| does its computations \emph{exactly}. The same example as a floating point evaluation: \begin{everbatim*} \xintthefloatexpr (31.567^2 - 21.56*52)^3/13.52^5\relax \end{everbatim*} Again, all computations done by |\xinttheexpr..\relax| are completely exact. Thus, very quickly very big numbers are created (and computation times increase, not to say explode if one goes into handling numbers with thousands of digits). To compute something like |1.23456789^10000| it is thus better to opt for the floating point version: \begin{everbatim*} \xintthefloatexpr 1.23456789^10000\relax \end{everbatim*} \newline (we can deduce that the exact value has |80000+916=80916| digits). A bigger example (the scope of the assignment to |\xintDigits| is limited by the braces): \begin{everbatim*} {\xintDigits:=24; \xintthefloatexpr 1.23456789123456789^123456789\relax } \end{everbatim*} (<- notice the size of the power of ten: this surely largely exceeds your pocket calculator abilities). It is also possible to do some computer algebra like evaluations (only numerically though): \begin{everbatim*} \xinttheiiexpr add(i^5, i=100..200)\relax\par \noindent\xinttheexpr reduce(add(x/(x+1), x = 1000..1014))\relax \end{everbatim*} \newline Were it not for the \func{reduce} function, the latter fraction would not have been obtained in reduced terms: \begin{framed} By default, the basic operations on fractions are not followed in an automatic manner by reduction to smallest terms: |A/B| multiplied by |C/D| returns |AC/BD|, |A/B| added to |C/D| returns |(AD+BC)/BD| except if either |B| divides |D| or |D| divides |B|. \end{framed} Make sure to read \autoref{sec:expr}, \autoref{sec:xintexprsyntax} and \autoref{ssec:outputs}. \subsection{Printing big numbers on the page}\label{ssec:printnumber} When producing very long numbers there is the question of printing them on the page, without going beyond the page limits. In this document, I have most of the time made use of these macros (not provided by the package:) % \everb|@ \def\allowsplits #1{\ifx #1\relax \else #1\hskip 0pt plus 1pt\relax \expandafter\allowsplits\fi}% \def\printnumber #1{\expandafter\allowsplits \romannumeral-`0#1\relax }% % \printnumber thus first ``fully'' expands its argument. | It may be used like this: % \leftedline{|\printnumber {\xintiiQuo{\xintiiPow {2}{1000}}{\xintiiFac{100}}}|} % or as |\printnumber\mybiginteger| or |\printnumber{\mybiginteger}| if |\mybiginteger| was previously defined via a |\newcommand|, a |\def| or an |\edef|. An alternative is to suitably configure the thousand separator with the \href{http://ctan.org/pkg/numprint}{numprint} package (see \autoref{fn:np}. This will not allow linebreaks when used in math mode; I also tried \href{http://ctan.org/pkg/siunitx}{siunitx} but even in text mode could not get it to break numbers accross lines). Recently I became aware of the \href{http://ctan.org/pkg/seqsplit}{seqsplit} package% % \footnote{\url{http://ctan.org/pkg/seqsplit}} % which can be used to achieve this splitting accross lines, and does work in inline math mode (however it doesn't allow to separate digits by groups of three, for example).\par \subsection{Randomly chosen examples} Here are some examples of use of the package macros. The first one uses only the base module \xintname, the next one requires the \xintfracname package, which deals with decimal numbers, scientific numbers (lowercase \dtt{e}), and also fractions (it loads automatically \xintname). Then some examples with expressions, which require the \xintexprname package (it loads automatically \xintfracname). And finally some examples using \xintseriesname, \xintgcdname which are among the extra packages included in the \xintname distribution. The printing of the outputs will either use a custom |\printnumber| macro as described in the previous section, or sometimes the |\np| macro from the \href{http://www.ctan.org/pkg/numprint}{numprint} package (see \autoref{fn:np}). \begin{itemize} \item {$123456^{99}$: }\\ |\xintiiPow {123456}{99}|: \dtt{\printnumber{\xintiiPow {123456}{99}}} \item {1234/56789 with 1500 digits after the decimal point: }\\ |\xintTrunc {1500}{1234/56789}\dots|: \dtt{\printnumber {\xintTrunc {1500}{1234/56789}}\dots } \item {$0.99^{-100}$ with 200 (+1) digits after the decimal point.}\\ |\xinttheiexpr [201] .99^-100\relax|: \dtt{\printnumber{\xinttheiexpr [201] .99^-100\relax}}\\ Notice that this is rounded, hence we asked |\xinttheiexpr| for one additional digit. To get a truncated result with 200 digits after the decimal mark, we should have issued |\xinttheexpr trunc(.99^-100,200)\relax|, rather. \begin{snugframed} The fraction |0.99^-100|'s denominator is first evaluated \emph{exactly} (\emph{i.e.} the integer |99^100| is evaluated exactly and then used to divide the suitable power of ten to get the requested digits); for some longer inputs, such as for example |0.7123045678952^-243|, the exact evaluation before truncation would be costly, and it is more efficient to use floating point numbers: % \leftedline{|\xintDigits:=20; \np{\xintthefloatexpr .7123045678952^-243\relax}|}% % \leftedline{\xintDigits:=20;\dtt{\np{\xintthefloatexpr .7123045678952^-243\relax }}} % \xintDigits:=16;% % Side note: the exponent |-243| didn't have to be put inside parentheses, contrarily to what happens with some professional computational software. |;-)| % 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 \end{snugframed} \item {$200!$:}\\ |\xinttheiiexpr 200!\relax|: \dtt{\printnumber{\xinttheiiexpr 200!\relax}} \item {$2000!$ as a float. As \xintexprname does not handle |exp/log| so far, the computation is done internally without the Stirling formula, by repeated multiplications truncated suitably:}\\ |\xintDigits:=50;|\newline |\xintthefloatexpr 2000!\relax|: {\xintDigits:=50;\dtt{\printnumber{\xintthefloatexpr 2000!\relax}}} \item Just to show off (again), let's print 300 digits (after the decimal point) of the decimal expansion of $0.7^{-25}$:% % \footnote{the |\np| typesetting macro is from the |numprint| package.} % \begin{everbatim*} % % in the preamble: % \usepackage[english]{babel} % \usepackage[autolanguage,np]{numprint} % \npthousandsep{,\hskip 1pt plus .5pt minus .5pt} % \usepackage{xintexpr} % in the body: \np {\xinttheexpr trunc(.7^-25,300)\relax}\dots \end{everbatim*} This computation is with \csbxint{theexpr} from package \xintexprname, which allows to use standard infix notations and function names to access the package macros, such as here |trunc| which corresponds to the \xintfracname macro \csbxint{Trunc}. Regarding this computation, please keep in mind that \csbxint{theexpr} computes \emph{exactly} the result before truncating. As powers with fractions lead quickly to very big ones, it is good to know that \xintexprname also provides \csbxint{thefloatexpr} which does computations with floating point numbers. \item Computation of a Bézout identity with |7^200-3^200| and |2^200-1|: (with \xintgcdname)\par \begin{everbatim*} \xintAssign{\xinttheiiexpr 7^200-3^200\relax} {\xinttheiiexpr 2^200-1\relax}\to\A\B \xintAssign\xintBezout{\A}{\B}\to\U\V\D \printnumber\U${}\times(7^{200}-3^{200})+{}$\printnumber{\V}% ${}\times(2^{200}-1)=\D=\xinttheiiexpr \U*\A+\V*\B\relax$ \end{everbatim*} \item The Euclide algorithm applied to \np{22206980239027589097} and \np{8169486210102119257}: (with \xintgcdname)% % \footnote {this example is computed tremendously faster than the other ones, but we had to limit the space taken by the output hence picked up rather small big integers as input.}\par \noindent\begingroup\parskip0pt\relax |\xintTypesetEuclideAlgorithm {22206980239027589097}{8169486210102119257}|\par \dtt {\xintTypesetEuclideAlgorithm {22206980239027589097}{8169486210102119257}} \endgroup \smallskip \item $\sum_{n=1}^{500} (4n^2 - 9)^{-2}$ with each term rounded to twelve digits, and the sum to nine digits: \begin{everbatim*} \def\coeff #1{\xintiRound {12}{1/\xintiiSqr{\the\numexpr 4*#1*#1-9\relax }[0]}} \xintRound {9}{\xintiSeries {1}{500}{\coeff}[-12]} \end{everbatim*} The complete series, extended to infinity, has value $\frac{\pi^2}{144}-\frac1{162}={}$% \dtt{\np{0.06236607994583659534684445}\dots}\,% % \footnote{\label{fn:np}This number is typeset using the \href{http://www.ctan.org/pkg/numprint}{numprint} package, with |\npthousandsep{,\hskip 1pt plus .5pt minus .5pt}|. But the breaking across lines works only in text mode. The number itself was (of course...) computed initially with \xintname, with 30 digits of $\pi$ as input. See \hyperref[ssec:Machin]{{how {\xintname} may compute $\pi$ from scratch}}.} % I also used (this is a lengthier computation than the one above) \xintseriesname to evaluate the sum with \np{100000} terms, obtaining 16 correct decimal digits for the complete sum. The coefficient macro must be redefined to avoid a |\numexpr| overflow, as |\numexpr| inputs must not exceed $2^{31}-1$; my choice was: \everb|@ \def\coeff #1% {\xintiRound {22}{1/\xintiiSqr{\xintiiMul{\the\numexpr 2*#1-3\relax} {\the\numexpr 2*#1+3\relax}}[0]}} | \restoreMacroFont \edef\Temp {\xintFloatPow [24]{2}{999999999}} \item {Computation of $2^{\np{999999999}}$ with |24| significant figures:} % \leftedline{|\numprint{\xintFloatPow [24]{2}{999999999}}|} \leftedline{\dtt{\numprint{\Temp}}} % where the \href{http://www.ctan.org/pkg/numprint}{numprint} package was used (\autoref{fn:np}), directly in text mode (it can also naturally be used from inside math mode). \xintname provides a simple-minded \csbxint{Frac} typesetting macro,% % \footnote{Plain \TeX{} users of \xintname have \csbxint{FwOver}.} % which is math-mode only: % \leftedline{|$\xintFrac{\xintFloatPow [24]{2}{999999999}}$|} \leftedline{\dtt{$\xintFrac{\Temp}$}} % The exponent differs, but this is because |\xintFrac| does not use a decimal mark in the significand of the output. Admittedly most users will have the need of more powerful (and customizable) number formatting macros than |\xintFrac|. % \footnote{There should be a |\xintFloatFrac|, but it is lacking.} % We have already mentioned |\numprint| which is used above, there is also |\num| from package \href{http://www.ctan.org/pkg/siunitx}{siunitx}. The raw output from % \leftedline{\detokenize{\xintFloatPow[24]{2}{999999999}}} % is $\Temp$. \edef\x{\xintiiQuo{\xintiiPow {2}{1000}}{\xintiiFac{100}}} \edef\y{\xintLen{\x}} \item As an example of nesting package macros, let us consider the following code snippet within a file with filename |myfile.tex|: \everb|@ \newwrite\outstream \immediate\openout\outstream \jobname-out\relax \immediate\write\outstream {\xintiiQuo{\xintiiPow{2}{1000}}{\xintiiFac{100}}} % \immediate\closeout\outstream | \noindent The tex run creates a file |myfile-out.tex|, and then writes to it the quotient from the Euclidean division of $2^{1000}$ by $100!$. The number of digits is |\xintLen{\xintiiQuo{\xintiiPow{2}{1000}}{\xintiiFac{100}}}| which expands (in two steps) and tells us that $[2^{1000}/100!]$ has \dtt{\y} digits. This is not so many, let us print them here: \dtt{\printnumber\x}.% \end{itemize} \subsection {More examples, some quite elaborate, within this document} \label{sec:awesome} \begin{itemize} \item The utilities provided by \xinttoolsname (\autoref{sec:tools}), some completely expandable, others not, are of independent interest. Their use is illustrated through various examples: among those, it is shown in \autoref{ssec:quicksort} how to implement in a completely expandable way the \hyperref[ssec:quicksort]{Quick Sort algorithm} and also how to illustrate it graphically. Other examples include some dynamically constructed alignments with automatically computed prime number cells: one using a completely expandable prime test and \csbxint{ApplyUnbraced} (\autoref{ssec:primesI}), another one with \csbxint{For*} (\autoref{ssec:primesIII}). \item One has also a \hyperref[edefprimes]{computation of primes within an \csa{edef}} (\autoref{xintiloop}), with the help of \csbxint{iloop}. Also with \csbxint{iloop} an \hyperref[ssec:factorizationtable]{automatically generated table of factorizations} (\autoref{ssec:factorizationtable}). \item The code for the title page fun with Fibonacci numbers is given in \autoref{ssec:fibonacci} with \csbxint{For*} joining the game. \item The computations of \hyperref[ssec:Machin]{ $\pi$ and $\log 2$} (\autoref{ssec:Machin}) using \xintname and the computation of the \hyperref[ssec:e-convergents]{convergents of $e$} with the further help of the \xintcfracname package are among further examples. \item Also included, an \hyperlink{BrentSalamin}{expandable implementation of the Brent-Salamin algorithm} for evaluating $\pi$. \item The functionalities of \xintexprname are illustrated with various examples, found in locations such as in \autoref{xintdeffunc} and \hyperlink{ssec:dummies}{functions with dummy variables} and \autoref{ssec:moredummies}. \end{itemize} Almost all of the computational results interspersed throughout the documentation are not hard-coded in the source file of this document but are obtained via the expansion of the package macros during the \TeX{} run.% % \subsection{Installation instructions} \label{ssec:install} \xintname is made available under the \href{http://www.latex-project.org/lppl/lppl-1-3c.txt}{LaTeX Project Public License 1.3c}. It is included in the major \TeX\ distributions, thus there is probably no need for a custom install: just use the package manager to update if necessary \xintname to the latest version available. After installation, issuing in terminal |texdoc --list xint|, on installations with a |"texdoc"| or similar utility, will offer the choice to display one of the documentation files: |xint.pdf| (this file), |sourcexint.pdf| (source code), |README|, |README.pdf|, |README.html|, |CHANGES.pdf|, and |CHANGES.html|. For manual installation, follow the instructions from the |README| file which is to be found on \href{http://www.ctan.org/pkg/xint}{CTAN}; it is also available there in PDF and HTML formats. The simplest method proposed is to use the archive file \href{http://www.ctan.org/pkg/xint}{xint.tds.zip}, downloadable from the same location. The next simplest one is to make use of the |Makefile|, which is also downloadable from \href{http://mirror.ctan.org/macros/generic/xint}{CTAN}. This is for GNU/Linux systems and Mac OS X, and necessitates use of the command line. If for some reason you have |xint.dtx| but no internet access, you can recreate |Makefile| as a file with this name and the following contents: {\def\everbatimindent {0pt }% \begin{everbatim} include Makefile.mk Makefile.mk: xint.dtx ; etex xint.dtx \end{everbatim}} Then run |make| in a working repertory where there is |xint.dtx| and the file named |Makefile| and having only the two lines above. The |make| will extract the package files from |xint.dtx| and display some further instructions. If you have |xint.dtx|, no internet access and can not use the Makefile method: |etex xint.dtx| extracts all files and among them the |README| as a file with name |README.md|. Further help and options will be found therein. \subsection {Changes} This is release \expandafter|\xintbndlversion| of \expandafter|\xintbndldate|. |1.2p| has some breaking changes and improvements (see |CHANGES.html| for bug fixes): \begin{itemize}[nosep] \item \csbxint{Bezout}'s output is changed. \item \csbxint{iiMod} macro, the |/:| (aka |'mod'|) operators as well as the \func{mod} function, and the |//| operator, are now associated with the \emph{floored}, not the \emph{truncated} division. This is breaking change for operands of opposite signs. \item the venerable \csbxint{ListWithSep} macro got faster. \item new \func{divmod} function for the expression parsers. \item \csbxint{defvar} et al. were extended to allow simultaneous assignments. \end{itemize} |1.2o| did mass-deprecation of those macros which were so far defined by \xintcorename/\xintname to use automatically \csbxint{Num}; users of \xintfracname (or a fortiori \xintexprname) will see almost nothing of this, as \xintfracname does the proper definitions. See \autoref{ssec:coredeprecated}, \autoref{ssec:xintdeprecated}, and \autoref{ssec:xintdeprecatedNum} for details. |1.2n| removed the \xintbinhexname dependency upon \xintcorename: it now loads only \xintkernelname. At |1.2m| (again at |1.2n|) the macros of \xintbinhexname for conversion routines between binary, decimal, and hexadecimal bases have been entirely re-written. They are faster, the more so for long inputs. But they have the drawback of now limiting their input to a maximal length of a few thousands characters. Since |1.2l|, the underscore |_| is accepted inside the expression parsers as an ignored digit separator\footnote{The space character has already always been accepted in this rôle by the \xintexprname parsers, contrarily to the situation inside |\numexpr|.}, for long numbers: \begin{everbatim*} \xinttheiiexpr 123_456_789^3\relax\newline \xintthefloatexpr \xintexpr 123_456_789.1111_1111_1111^-3\relax \relax \end{everbatim*} It is not accepted in the arguments of the macros from \xintfracname or \xintname though, only in expressions from \xintexprname. Macro usage with non properly terminated inputs such as |\xintiiAdd{\the\numexpr1}{2}| caused crashes. This has been fixed at |1.2l|: the arithmetic macros of \xintcorename, the macros of \xintfracname, those of \xintgcdname, have been made robust against such inputs. Some routines of \xintcorename principally destined to internal usage such as \csbxint{Inc} remain incompatible though (to avoid adding some overhead; check |sourcexint.pdf| for details). See |CHANGES.html| or |CHANGES.pdf| for more information (either |texdoc --list xint| or on the internet via \href{http://mirrors.ctan.org/macros/generic/xint/CHANGES.html}{this link}.) \section{The syntax of \xintexprname expressions} \label{sec:xintexprsyntax} \localtableofcontents \subsection{Built-in operators and their precedences} % Dimanche 18 décembre 2016 % \@floatboxreset fait \reset@font=\normalfont et \normalsize % ancienne version utilisait \ttfamily et ne faisait pas \makestarlowast \def\MicroFont{\ttbfamily\makestarlowast\color[named]{DarkOrchid}} \makeatletter \def\@floatboxreset{\@setminipage}% faudra contrôler celui-là \makeatother \begin{table}[htbp]\ht\strutbox12pt\dp\strutbox5pt \capstart \centering\begin{tabular}{|c|p{.5\textwidth}|} \hline \multicolumn{2}{|p{.6\textwidth}|}{\prec{$\infty$}: at this top level the non-operator syntax elements whose parsing is always done prior to executing operators preceding them: \begin{itemize}[nosep] \item \hyperref[ssec:builtinfunctions]{built-in} or \hyperref[ssec:userfunctions]{user-defined} functions, \item \hyperref[ssec:uservariables]{variables}, \item and the intrinsic constituents of numbers: decimal mark |.|, |e| and |E| of scientific notation, hexadecimal prefix |"|. \end{itemize}\par\kern-\baselineskip\relax}% \\\hline\hline Precedence&``Operators'' at this level\strut\\ \hline \prec{$10$}& the factorial (postfix) operator |!| and the conditional branching operators |?| and |??|\strut\\\hline \prec{$=$}& the minus sign |-| as unary operator acquires the precedence level of the previous infix operator\strut\\\hline \prec{$9$}&the power |^|, |**| operators\strut\\\hline \prec{$8$}&the action of tacit multiplication\strut\\\hline \prec{$7$}&the multiplication, division, and modulo operators |*|, |/|, |//|, |/:| (aka |'mod'|)\strut \\\hline \prec{$6$}&the addition and subtraction |+|, |-|\strut\\\hline \prec{$5$}&the comparison operators |<|, |>|, |==|, |<=|, |>=|, |!=|\strut\\\hline \prec{$4$}&Boolean conjunction |&&| and its alias |'and'|\strut\\\hline \prec{$3$}&Boolean disjunction \verb+||+ and |'or'|, and |'xor'|; also the sequence generators |..|, |..[|, |]..|, and the Python slicer |:| have this precedence\strut\\\hline \prec{$2$}& the comma |,|\strut\\\hline \prec{$1$}& the parentheses |(|, |)|, list brackets |[|, |]|, semi-colon |;| in an \func{iter} or \func{rseq}\strut\\\hline\hline \multicolumn{2}{|p{.6\textwidth}|}{% \begin{itemize}[nosep] \item In case of equal precedence, the rule is left-associativity: the first encountered operation is executed first. \hyperref[ssec:tacit multiplication]{Tacit multiplication} has an elevated precedence level hence seemingly breaks left-associativity: |(1+2)/(3+4)(5+6)| is computed as |(1+2)/((3+4)*(5+6))| and |x/2y| is interpreted as |x/(2*y)| when using variables. \item List variants |^[|, |**[|, |]^|, |]**|, |*[|, |/[|, |]*|, |]/|, |+[|, |-[|, |]+|, |]-|, share the precedence level of their respective associated operators on numbers. \item There may be some evolution in future, perhaps to distinguish some of the constructs which currently share the same precedence or to make room for added syntax elements. \end{itemize} }\\\hline \end{tabular} \caption{Precedence levels} \label{tab:precedences} \etoctoccontentsline {table}{Precedence levels of operators in expressions} \end{table} The \autoref{tab:precedences} is hyperlinked to the more detailed discussion at each level. \begin{description}[parsep=0pt,align=left,itemindent=0pt, leftmargin=\leftmarginii, labelwidth=\leftmarginii, labelsep=0pt, labelindent=0pt, listparindent=\leftmarginiii] \precdesc{\infty} At this highest level of precedence, one finds: \begin{itemize}[parsep=0pt,align=left,itemindent=0pt, leftmargin=\leftmarginii, labelwidth=\leftmarginii, labelsep=0pt, labelindent=0pt, listparindent=\leftmarginiii] \item \hyperref[ssec:builtinfunctions]{functions} and \hyperref[ssec:uservariables]{variables}: we approximately describe the situation as saying they have highest precedence. Functions (even the logic functions \func{!} and \func{?} whose names consists of a single non-letter character) must be used with parentheses. These parentheses may arise from expansion after the function name is parsed (there are exceptions which are documented at the relevant locations.) \item the |.| as decimal mark; the number scanner treats it as an inherent, optional and unique component of a being formed number. One can do things such as % \leftedline{\restoreMicroFont|\xinttheexpr 0.^2+2^.0\relax|} % which is |0^2+2^0| and produces \dtt{\xinttheexpr 0.^2+2^.0\relax}. Since release |1.2| an isolated decimal mark |"."| is illegal input in |\xintexpr..\relax|, although it remains legal as argument to the macros of \xintfracname. \item the |e| and |E|, for scientific notation are intrinsic constituents of number denotations, like the decimal mark. \item the |"| for hexadecimal numbers: it is allowed only at locations where the parser expects to start forming a numeric operand, once encountered it triggers the hexadecimal scanner which looks for successive hexadecimal digits as usual skipping spaces and expanding forward everything; letters (only |ABCDEF|, not |abcdef|), an optional dot (allowed directly in front) and an optional (possibly empty) fractional part. The |"| functionality \fbox{requires to load package \xintbinhexname}.% % \begin{everbatim*} \xinttheexpr "FEDCBA9876543210\relax\newline \xinttheiexpr 16^5-("F75DE.0A8B9+"8A21.F5746+16^-5)\relax \end{everbatim*} \end{itemize} \precdesc{10} The postfix operators |!| and the branching conditionals |?|, |??|. \begin{description}[parsep=0pt,align=left,itemindent=0pt, leftmargin=\leftmarginii, labelwidth=\leftmarginii, labelsep=0pt, labelindent=0pt, listparindent=\leftmarginiii] \item[{\color[named]{DarkOrchid}!}] computes the factorial of an integer. \item[{\color[named]{DarkOrchid}?}] is used as |(stuff)?{yes}{no}|. It evaluates |stuff| and chooses the |yes| branch if the result is non-zero, else it executes |no|. After evaluation of |stuff| it acts as a macro with two mandatory arguments within braces, chooses the correct branch \emph{without evaluating the wrong one}. Once the braces are removed, the parser scans and expands the uncovered material so for example % \leftedline{|\xinttheiexpr (3>2)?{5+6}{7-1}2^3\relax|} % is legal and computes |5+62^3=|\dtt{\xinttheiexpr(3>2)?{5+(6}{7-(1}2^3)\relax}. It would be better practice to include here the |2^3| inside the branches. The contents of the branches may be arbitrary as long as once glued to what is next the syntax is respected: {|\xintexpr (3>2)?{5+(6}{7-(1}2^3)\relax| also works.} \item[{\color[named]{DarkOrchid}??}] is used as |(stuff)??{<0}{=0}{>0}|, where |stuff| is anything, its sign is evaluated and depending on the sign the correct branch is un-braced, the two others are discarded with no evaluation of their contents. The un-braced branch will then be parsed as usual. % \leftedline{|\def\x{0.33}\def\y{1/3}|} % \leftedline{|\xinttheexpr (\x-\y)??{sqrt}{0}{1/}(\y-\x)\relax|% \dtt{=\def\x{0.33}\def\y{1/3}% \xinttheexpr (\x-\y)??{sqrt}{0}{1/}(\y-\x)\relax }} % \end{description} \precdesc{=} The minus sign |-| as prefix unary operator inherits the precedence of the infix operator it follows. |\xintexpr -3-4*-5^-7\relax| evaluates as |(-3)-(4*(-(5^(-7))))| and |-3^-4*-5-7| as |(-((3^(-4))*(-5)))-7|. |2^-10| is perfectly accepted input, no need for parentheses \precdesc{9} The power operator |^|, or equivalently |**|. It is left associative: {\restoreMicroFont|\xinttheiexpr 2^2^3\relax|} evaluates to \xinttheiexpr 2^2^3\relax, not \xinttheiexpr 2^(2^3)\relax. See \csbxint{FloatPower} for additional information. Also at this level the list operators |^[|, |**[|, |]^|, and |]**|. \precdesc{8} see \hyperref[ssec:tacit multiplication]{Tacit multiplication}. \precdesc{7} Multiplication and division |*|, |/|. The division is left associative, too: % \begingroup\restoreMicroFont % |\xinttheiexpr 100/50/2\relax| evaluates to \xinttheiexpr 100/50/2\relax, not \xinttheiexpr 100/(50/2)\relax. % \endgroup Also the floored division |//| and its associated modulo |/:| (equivalently |'mod'|, quotes mandatory). Also at this level the list operators |*[|, |/[|, |]*| and |]/|. In an \csbxint{iiexpr}-ession, |/| does \emph{rounded} division, to behave like the |/| of |\numexpr|. Infix operators all at the same level of precedence are left-associative.\footnote{i.e. the first two operands are operated upon first.} Apply parentheses for disambiguation. \begin{everbatim*} \xinttheexpr 100000//13, 100000/:13, 100000 'mod' 13, trunc(100000/13,10), trunc(100000/:13/13,10)\relax \end{everbatim*} \precdesc{6} Addition and subtraction |+|, |-|. According to the rule above, |-| is left associative: % \begingroup\restoreMicroFont % |\xinttheiexpr 100-50-2\relax| evaluates to \xinttheiexpr 100-50-2\relax, not \xinttheiexpr 100-(50-2)\relax. % \endgroup Also the list operators |+[|, |-[|, |]+|, |]-| are at this precedence level. \precdesc{5} Comparison operators |<|, |>|, |=| (same as |==|), |<=|, |>=|, |!=| all at the same level of precedence, use parentheses for disambiguation. \precdesc{4} Conjunction (logical and) |&&| or equivalently |'and'| (quotes mandatory).% % \footnote{with releases earlier than |1.1|, only single character operators |&| and \verb+|+ were available, because the parser did not handle multi-character operators. Their usage in this rôle is now deprecated,\IMPORTANT{} and they may be assigned some new meaning in the future.} \precdesc{3} Inclusive disjunction (logical or) \verb+||+ and equivalently |'or'| (quotes mandatory). Also the |'xor'| operator (quotes mandatory) is at this level. Also the list generation operators |..|, |..[|, |]..| are at this level. Also the |:| for Python slicing of lists. \precdesc{2} The comma: {\restoreMicroFont with |\xinttheexpr 2^3,3^4,5^6\relax| one obtains as output \xinttheexpr 2^3,3^4,5^6\relax{}.}\footnote{The comma is really like a binary operator, which may be called ``join''. It has lowest precedence of all (apart the parentheses) because when it is encountered all postponed operations are executed in order to finalize its \emph{first} operand; only a new comma or a closing parenthesis or the end of the expression will finalize its \emph{second} operand.} \precdesc{1} The parentheses. The list outer brackets |[|, |]| share the same functional precedence as parentheses. The semi-colon |;| in an |iter| or |rseq| has the same precedence as a closing parenthesis.\footnote{It is not apt to describle the opening parenthesis as an operator, but the closing parenthesis is more closely like a postfix unary operator. It has lowest precedence because when it is encountered all postponed operations are executed to finalize its operand. The start of this operand was decided by the opening parenthesis.} \end{description} \restoreMicroFont \subsection{Built-in functions}\label{ssec:builtinfunctions} See \autoref{tab:functions} whose elements are hyperlinked to the corresponding definitions. Functions are at the same top level of priority. All functions even \func{?} and \func{!} require parentheses around their arguments. % Table of functions \begin{table}[htbp] \capstart \centering \xintAssignArray\xintCSVtoList{!, ?, |`*`|, |`+`|, abs, add, all, any, binomial, bool, ceil, divmod, even, factorial, first, float, floor, frac, gcd, if, ifsgn, iter, iterr, last, lcm, len, max, min, mod, mul, not, num, odd, pfactorial, qfloat, qfrac, qint, quo, reduce, rem, reversed, round, rrseq, rseq, seq, sgn, sqr, sqrt, sqrtr, subs, togl, trunc, xor} \to\Functions \cnta\Functions{0} % 49 \cntb\xinttheexpr ceil(\cnta/4)\relax\space \newcommand\builtinfunction[1]{\expandafter\expandafter\expandafter\func \expandafter\expandafter\expandafter{\Functions{#1}}}% \begin{tabular}{|*{4}{p{2.5cm}|}} \hline \xintFor* #1 in {\xintSeq{1}{\cntb}}\do {\builtinfunction{#1}& \builtinfunction{#1+\cntb}&% \builtinfunction{#1+2*\cntb}&% \ifnumgreater{#1+3*\cntb}{\cnta} {} {\builtinfunction{#1+3*\cntb}}% \\\hline}% \end{tabular} \caption{Functions (click on names)}\label{tab:functions} \etoctoccontentsline {table}{Functions in expressions} \end{table} Miscellaneous notes: \begin{itemize}[nosep] \item \func{gcd} and \func{lcm} require explicit loading of \xintgcdname,\IMPORTANT \item \func{togl} is provided for the case |etoolbox| package is loaded, \item \func{bool}, \func{togl} use delimited macros to fetch their argument and the closing parenthesis must be explicit, it can not arise from on the spot expansion. The same holds for \func{qint}, \func{qfrac}, \func{qfloat}. \item Also \hyperlink{ssec:dummies}{functions with dummy variables} use delimited macros for some tasks. See the relevant explanations there. \end{itemize} \begin{description}[parsep=0pt,align=left, leftmargin=0pt, itemindent=0pt, labelwidth=-\fontdimen2\font, labelsep=\fontdimen2\font, labelindent=0pt, % leftmargin+itemindent="labelindent"+labelwidth+labelsep % leftmargin=labelindent+labelwidth+labelsep* (enumitem) % Utiliser \mbox{} et non pas \noindent\par pour bon display % (enfin c'était nécessaire avant chgt dans keys ci-dessus, ai oublié ancien % attention que listparindent n'est apparemment pas hérité, faut le refaire listparindent=\leftmarginiii] \item[functions with a single (numeric) argument:]\mbox{} \begin{description}[listparindent=\leftmarginiii]% il faut le répéter! \funcdesc{num} truncates to the nearest integer (truncation towards zero). It has the same sign as |x|, except of course with |-1