% -*- 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: <10-09-2019 at 22:59:27 CEST>} % %<*drv> %% --------------------------------------------------------------- \def\xintdocdate {2019/09/10} \def\xintbndldate{2019/09/10} \def\xintbndlversion {1.3f} % %% README %% CHANGE LOG %% xint 1.3f %% 2019/09/10 % % Source: xint.dtx 1.3f 2019/09/10 (doc 2019/09/10) % Author: Jean-Francois Burnol % Info: Expandable operations on big integers, decimals, fractions % License: LPPL 1.3f % %<*!readme&!changes&!dohtmlsh&!dopdfsh&!makefile> %% --------------------------------------------------------------- %% The xint bundle 1.3f 2019/09/10 %% Copyright (C) 2013-2019 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 %%% xinttrig: Trigonometry for the xintexpr package %%% xintlog: Logarithms and exponentials for xintexpr %% --------------------------------------------------------------- % %<*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 (as this example shows the underscore character can be used to separate visually digits, one can also use the space character for that purpose). Square-root and the four operations achieve correct rounding in the given arbitrary precision. Trigonometric functions (direct and inverse) are available with a maximal precision of 60 digits. Logarithms and exponentials are available using the [poormanlog](http://www.ctan.org/pkg/poormanlog) package which provides only 8 or 9 digits of precision. This will be increased in future. Usage ===== It is possible to use the package both with Plain (`\input xintexpr.sty`) or with LaTeX (`\usepackage{xintexpr}`). ## With LaTeX \usepackage{xint} % expandable arithmetic with big integers \usepackage{xintfrac} % decimal numbers, fractions, floats \usepackage{xinttools} % expandable and non expandable loops \usepackage{xintexpr} % expressions with infix operators The `xinttrig` and `xintlog` packages are loaded automatically by `xintexpr` and will refuse to be loaded directly. Further packages: `xintbinhex`, `xintgcd`, `xintseries` and `xintcfrac`. Main dependencies are handled automatically. For example `xintexpr` automatically loads `xinttools` and `xintfrac` (which itself loads `xint`). Hexadecimal input requires explicit loading of `xintbinhex`. Package `xintcore` is the subset of `xint` providing only the five operations on big integers: `\xintiiAdd`, `\xintiiMul`, ... The LaTeX package [bnumexpr](http://www.ctan.org/pkg/bnumexpr) defines a more light-weight parser of arithmetical expressions using big integers, which supports only the four operations, the modulo operation, the power operation, and the factorial. By default it uses the macros from `xintcore` but this can be customized. The LaTeX package [polexpr](http://www.ctan.org/pkg/polexpr) is based upon `xintexpr` and allows formal algebra with polynomials, and finding all real roots with arbitrary precision. ## With TeX One does for example: \input xintexpr.sty This will automatically load `xintfrac.sty`, `xinttrig.sty`, `xintlog.sty` and `xinttools.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`, `\xint_dothis/\xint_orthat`, or `\xintLength`. Since `1.3b`, `xintkernel.sty` also provides `\xintUniformDeviate` which is a wrapper of the engine `\pdfuniformdeviate` or `\uniformdeviate` done to guarantee more uniformity of the pseudo-random integers. 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. The [Latexmk](http://personal.psu.edu/jcc8/software/latexmk/) and [Pandoc](http://johnmacfarlane.net/pandoc/) softwares are required to build all the documentation. 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 `etex xint.dtx` to extract from `xint.dtx` all macro files as well as auxiliary files needed for building the documentation. Among them there is `Makefile.mk`. If you are on a GNU/Linux-type system, rename the file to `Makefile` and execute `make` on command line for further help. If you can't use `make` read the contents of the `Makefile` for instructions. 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-2019 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, xinttrig.sty, xintlog.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, and Makefile.mk.
%
-------------------------------------------------------- %<*changes>------------------------------------------------------- `1.3f (2019/09/10)` ---- ### Improvements and new features - **xintfrac**: `\xintDigits = P;` syntax (i.e. without a colon) is now accepted in addition to `\xintDigits := P;`. Document that the ending semi-colon can not be an active character and that it has always been allowed to use in its place a non-expanding token e.g. `\xintDigits := 32\relax`. Add `\xintSetDigits`. - **xintexpr**: add starred variants `\xintDigits*` and `\xintSetDigits*` which execute `\xintreloadxinttrig`. Revert 1.3e ban on usage of `\xinteval` et al. inside expressions by `\xintdeffunc`. And make them usable also inside macro definitions via `\xintNewExpr`. ### Bug fixes - **xintexpr**: fix bug preventing usage of `\xintdefefunc` to define a function without variables. Fix some issue with `\xintfloatexpr[D]..\relax` if used inside an expression parsed by `\xintdeffunc` et al. `1.3e (2019/04/05)` ---- ### Incompatible changes - (_reverted at 1.3f_) When defining functions, sub-expressions can only use the `\xint(float)expr...\relax` syntax. One can not use there the `\xint(float)eval` wrappers. ### Improvements and new features - The **xinttrig** library is automatically loaded by **xintexpr**. It provides direct and inverse trigonometrical functions using either degrees or radians with a precision of up to (a bit less than) 60 digits. It is for the most part implemented using high level user interface, but will probably get some optimizations in future (and perhaps extension to more digits). - The **xintlog** library is automatically loaded by **xintexpr**. It uses [poormanlog](http://ctan.org/pkg/poormanlog) to provide logarithms and exponentials with almost 9 digits of precision. Extended precision is for a future release. - **xintexpr**: `\xintdefefunc`, `\xintdeffloatefunc`, `\xintdefiiefunc` define functions which are not protected against expansion in the definition of other functions; refer to `xint.pdf` for the related explanations. Notice that whole area of `\xintdef(e)func`, `\xintNewExpr`, `\xintNewFunction` is complex and to be considered still as work in progress as it has a number of shortcomings. - **xintexpr**: `inv()`, `ilog10()`, `sfloat()`, behaviour of `qfloat()` slightly modified. - **xintexpr**: `\xintensuredummy`, `\xintrestorelettervar`. - The optional argument of `\xintfloatexpr` or `\xintfloateval` (it must be at start of braced argument) can be negative; it then means to trim (and round) from the output at float precision that many least significant digits. ### Bug fixes - Some bugfixes related to user functions with no variables at all; they were dysfunctional. `1.3d (2019/01/06)` ---- ### Incompatible changes - **xintexpr**: the `gcd()` and `lcm()` functions formerly converted their arguments to integers via `\xintNum`. They now handle general input with no such modification. - **xintexpr**: former `\xinteval`, `\xintieval`, `\xintiieval`, and `\xintfloateval` renamed to `\xintexpro`, `\xintiexpro`, `\xintiiexpro`, and `\xintfloatexpro`. ### Improvements and new features - **xintexpr**: the `gcd()` and `lcm()` multi-arguments functions have been refactored to handle general fractions. The dependency on **xintgcd** is removed. - **xintexpr**: three-way branching `\xintifsgnexpr`, `\xintifsgnfloatexpr`, `\xintifsgniiexpr` conditional macros. - **xintexpr**: `\xintunassignexprfunc`, `\xintunassigniiexprfunc`, `\xintunassignfloatexprfunc` to "undefine" functions. - **xintexpr**: `\xintunassignvar` really makes the (multi-letter) variable unknown (formerly, it only gave it value zero), - **xintexpr**: functions `isone()` and `isint()`. - **xintexpr**: `\xinteval`, `\xintieval`, `\xintiieval`, and `\xintfloateval` as synonyms to `\xinttheexpr...\relax` etc..., but with the (comma-separated) expression as a usual braced macro argument. ### Bug fixes - **xintcore**, **xintexpr** : division in `\xintiiexpr` was broken for a zero dividend and a one-digit divisor (e.g. ``0//7``) since `1.2p` due to a bug in `\xintiiDivMod` for such arguments. The bug was signaled (thanks to Kpym for report) and fixed shortly after `1.3c` release but I then completely forgot to upload a bugfix release to CTAN at that time, apologies for that. `1.3c (2018/06/17)` ---- ### Improvements and new features - **xintexpr**: with `\xintglobaldefstrue`, `\xintdefvar`, `\xintdeffunc`, `\xintNewExpr` et al. make definitions with global scope. - **xintexpr**: `qraw()` for fast input of (very many) comma separated numbers (in suitable raw format). - **xintexpr**: the colon in the `:=` part of the syntax for `\xintdefvar` and variants is now optional; and if present it may be an active character or have any (reasonable) catcode. - **xintexpr**: `\xintdefvar`, `\xintdeffunc` and their variants try to set the catcode of the semi-colon which delimits their arguments; of course this will not work if that catcode is already frozen. - `\xintUniformDeviate` is better documented and `sourcexint.pdf` is better hyperlinked and includes indices for the macros defined by each package. ### Bug fixes - **xintfrac**: since `1.3` release, it loaded **xintgcd** in contradiction to what the documentation says (hence also **xintexpr** loaded **xintgcd** automatically). There is no actual dependency so the loading is removed for now. `1.3b (2018/05/18)` ---- ### Improvements and new features All additions related to randomness are marked as work-in-progress. They require an engine providing the `\(pdf)uniformdeviate` primitive. - **xintkernel**: `\xintUniformDeviate`. - **xint**: `\xintRandomDigits`, `\xintXRandomDigits`, `\xintiiRandRange`, `\xintiiRandRangeAtoB`. - **xintfrac**: support macros (not public, mainly because internal format for floats is surely not final) for `random()` and `qrand()`. - **xintexpr**: `random()`, `qrand()`, and `randrange(A[, B])`. - **xintexpr**: when a function `foo()` is declared via `\xintdeffunc` (et al.) to be parameter-less, it can be used as `foo()`; formerly `foo(nil)` syntax was required. - The usual provision of user manual "improvements". `1.3a (2018/03/07)` ---- ### Removed - **xintcore**, **xint**, **xintfrac**: removal of the internal macros which were used at `1.2o` to add a deprecation mechanism; all deprecated macros have been removed at `1.3` so there was no reason to keep the code used for deprecating them. ### Improvements and new features - **xintexpr**: new conditionals `ifone()` and `ifint()`. - **xintfrac**: `\xintREZ` is faster on inputs having one hundred digits or more. - Added to the user manual mention of macros such as `\xintDivFloor`, `\xintMod`, `\xintModTrunc`, which had been left out so far. ### Bug fixes - **xintexpr**: the mechanism for adjunction to the expression parsers of user defined functions was refactored and improved at previous release `1.3`: in particular recursive definitions became possible. But an oversight made these recursive functions quite inefficient (to remain polite.) This release fixes the problem. `1.3 (2018/03/01)` ---- ### Incompatible changes - **xintcore**, **xint**, **xintfrac**: all macros deprecated at `1.2o` got removed. - **xintfrac**: addition and subtraction of `a/b` and `c/d` now use the l.c.m. of the denominators. Similarly the macro supporting the modulo operator `/:` uses a l.c.m. for the denominator of the result. - **xintexpr**: the addition, subtraction, modulo `/:`, and the `mod()` and `divmod()` functions produce generally smaller denominators (see previous item). - **xintexpr**: formerly, the internal macros which are internally associated to user-declared functions were using comma separated parameter texts. They now do not use such commas (their meanings, which may again change in future, are written for information to the log under `\xintverbosetrue`). ### Improvements and new features - **xintexpr**: user-defined functions may now be of a recursive nature. This was made possible by a refactoring of the `\xintNewExpr` mechanism. It became both leaner and more extensive than formerly. - **xintfrac**: new macros `\xintPIrr` and `\xintDecToString`. The latter is a backport of a `polexpr 0.4` utility, and it is to be considered unstable. - **xintexpr**: new function `preduce()` associated with `\xintPIrr`. `1.2q (2018/02/06)` ---- ### Improvements and new features - **xintexpr**: tacit multiplication extended to cases such as `3!4!5!` or `(1+2)3`. ### Bug fixes - **xintcore**: sadly, refactoring at `1.2l` of subtraction left an extra character in an inner macro causing breakage in some rare circumstances. This should not have escaped our test suite! `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) # Rename the file as Makefile, or keep is named as Makefile.mk # and download master Makefile from # http://mirror.ctan.org/macros/generic/xint # then run "make help" # Starting with xint 1.3c, uses Latexmk for easier compilation of # sourcexint.pdf as it includes indices. These indices for # source code were actually removed at 1.3e but usage of Latexmk # is maintained for the build (despite it being simpler now). # Originally tested on Mac OS X Mavericks with GNU Make 3.81, # TeXLive 2014 and Pandoc 1.13.1. # 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 xint.pdf, using latex and dvipdfmx. Uses Latexmk. No Pandoc needed. To get xint.pdf to include the source code and indices, refer to instructions in xint.tex. make sourcexint.pdf extracts files and produces sourcexint.pdf, using latex, makeindex and dvipdfmx. Uses Latexmk. 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 clean removes auxiliary files and repertories. make cleanall removes all files, leaving only xint.dtx (and Makefile). If no Makefile, use "etex xint.dtx" to regenerate Makefile.mk, rename it as Makefile and run "make help". ==== 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 xinttrig.sty xintlog.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 Makefile filesfordoc = xint.pdf sourcexint.pdf README $(doc_pdf) $(doc_html) auxiliaryfiles = xint.dvi xint.aux xint.toc xint.log\ sourcexint.dvi sourcexint.aux sourcexint.toc sourcexint.log\ README.dvi README.aux README.toc README.out README.log\ CHANGES.dvi CHANGES.aux CHANGES.toc CHANGES.out CHANGES.log xint_cmd = latexmk xint sourcexint_cmd = latexmk -jobname=sourcexint\ -latex='latex %O "\chardef\dosourcexint=1 \input{%S}"' xint.tex 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 $(xint_cmd) dvipdfmx xint.dvi sourcexint.pdf: xint.dtx xint.tex $(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 -fr auto/ TEMP*/ rm -f $(auxiliaryfiles)\ sourcexint.fls sourcexint.fdb_latexmk\ xint.fls xint.fdb_latexmk cleanall: clean rm -f $(extracted) $(doc_pdf) $(doc_html)\ README README.tex CHANGES.tex\ xint.pdf sourcexint.pdf xint.tds.zip xint.zip Makefile.mk %$----------------------------------------------------- %<*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>----------------------------------------------------------- %% %% To produce manually xint.pdf from xint.tex: %% - latex (thrice) then dvipdfmx, %% - or xelatex/pdflatex thrice. %% %% To produce manually sourcexint.pdf from xint.tex: %% latexmk -jobname=sourcexint\ %% -latex="latex %O \\\\chardef\\\\dosourcexint=1 \\\\input{%S}"\ %% xint.tex %% (quoting may differ, depending on the shell) %% dvipdfmx sourcexint.dvi %% %% It is naturally possible to replace latexmk by suitable latex %% and makeindex calls, but details are left out here. %% %% To get xint.pdf to include the source code and indices: %% - etex xint.dtx (this will regenerate this file), %% - replace 1 by 0 in \chardef line below, %% - make clean %% - make xint.pdf %% This will use latexmk. Without it execute latex thrice then dvipdfmx. \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 %%% TeX-PDF-from-DVI: "Dvipdfmx" %%% 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, .latexmkrc %% and xint-gind.ist %% %% `etex xint.ins' additionally extracts Makefile.mk, which is needed %% for building documentation using `make'. %% \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}} \file{xinttrig.sty}{\from{xint.dtx}{xinttrig}} \file{xintlog.sty}{\from{xint.dtx}{xintlog}}} \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{* xinttrig.sty} \Msg{* xintlog.sty} \Msg{* xinttools.sty} \Msg{*} \Msg{* To produce the user manual run latex thrice on xint.tex} \Msg{* then dvipdfmx on xint.dvi, or if your system allows,} \Msg{* execute `make xint.pdf' (this requires Latexmk).} \Msg{*} \Msg{* The commented source code is generated from executing} \Msg{* `make sourcexint.pdf' (this requires Latexmk; if not} \Msg{* available check the details in Makefile.mk and .latexmkrc)} \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{* \space\space\space\space xinttrig.sty^^J}% \Msg{* \space\space\space\space xintlog.sty^^J}% \Msg{*^^J}% \Msg{* To produce the user manual run latex thrice on xint.tex^^J}% \Msg{* then dvipdfmx on xint.dvi, or if your system allows,^^J}% \Msg{* execute `make xint.pdf' (this requires Latexmk).^^J}% \Msg{*^^J}% \Msg{* The commented source code is generated from executing^^J}% \Msg{* `make sourcexint.pdf' (this requires Latexmk; if not^^J}% \Msg{* available check the details in Makefile.mk and .latexmkrc)^^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}} \file{xinttrig.sty}{\from{xint.dtx}{xinttrig}} \file{xintlog.sty}{\from{xint.dtx}{xintlog}}} \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, fill-column: 78; -*- % \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 % Get rid of HARASSMENT by KOMA-Script \makeatletter \def\class@shoulddisablepackagewarning@list{tocloft.} \makeatother \ifnum\Withdvipdfmx=1 \def\pgfsysdriver{pgfsys-dvipdfm.def} \documentclass [dvipdfm, dvipdfmx, dvipdfmx-outline-open]{scrdoc} \else \documentclass {scrdoc} \fi % Revert change to \smash and other macros at LaTeX 2018/12/01 % https://github.com/latex3/latex2e/issues/108 \makeatletter \let\leavevmode@ifvmode\empty % for \smash in \NewWith etc... \makeatother % Remove from sectioning commands insertion of marks, because we % will do it ourself. \usepackage{etoolbox} \makeatletter \patchcmd{\@sect}% {\expandafter\csname#1mark\expandafter\endcsname\expandafter{\@currentheadentry}}% {}{}{} \patchcmd{\@sect}% {\expandafter\csname#1mark\expandafter\endcsname\expandafter{\@currentheadentry}}% {}{}{} \makeatother \PassOptionsToPackage{bookmarks=true}{hyperref} \ifnum\NoSourceCode=1 \OnlyDescription \fi % counts used in particular in the samples from the documentation of the % xintseries.sty package \newcount\cnta \newcount\cntb \newcount\cntc \pagestyle{headings} \ifxetex \else \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \DeclareUnicodeCharacter{03B4}{\ensuremath{\delta}}%δ \DeclareUnicodeCharacter{03BE}{\ensuremath{\xi}}%ξ \DeclareUnicodeCharacter{03C0}{\ensuremath{\pi}}%π \fi \usepackage{multicol} \usepackage{geometry} \AtBeginDocument {\ttzfamily % package newtxtt loaded in preamble \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 \cfrac usage \DeclareMathOperator{\sinc}{sinc} \usepackage{pifont}% for \ding{73} (hollow star) \fi \usepackage{xinttools} \usepackage{enumitem} \usepackage{varioref} \usepackage{xspace} \usepackage[para]{footmisc} \usepackage{picture} \usepackage{graphicx} \usepackage[english]{babel} \usepackage[autolanguage,np]{numprint} \AtBeginDocument{\npthousandsep{,\hskip .5pt plus .1pt minus .1pt}} \usepackage[dvipsnames]{xcolor} \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{eso-pic}% après xcolor sinon Option clash for package xcolor. \ifnum\dosourcexint=1 \else % Dependency graph done using TikZ (manually) \usepackage{tikz} \usetikzlibrary{shapes,arrows.meta} \fi \usepackage{framed} % SNUGFRAMED % ========== \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 % HYPERREF % ======== \usepackage[pdfencoding=unicode]{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} % FONTS % ===== \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 % This is with a slashed 0 like the original txtt. \newcommand\ttbfamily {\fontfamily{newtxttb}\selectfont } \ifnum\dosourcexint=1 \else \renewcommand\familydefault\ttdefault \usepackage[noendash]{mathastext}% pas de endash dans newtxtt \fi \frenchspacing % sans-serif in footnotes, TOC, titles, etc... \renewcommand\familydefault\sfdefault % TABLES OF CONTENTS % ================== \usepackage{tocloft} \usepackage{etoc} \def\gobbletodot #1.{} \newif\ifinmanualmaintoc \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 {\HOOKLOCALTOC.\expandafter\gobbletodot\etocthenumber}}}% \strut\etocname\nobreak \leaders\etoctoclineleaders \hfill\nobreak \strut\makebox[\MARGEPAGENO][r]{\small\etocpage}\endgraf } {\endgroup }% \let\HOOKLOCALTOC\empty% quick hack to get style I want in User defined functions \etocsetlevel{table}{6} \makeatother \addtocontents{toc}{\protect\hypersetup{hidelinks}} % ===================== % MISCELLANEOUS MARK-UP % ===================== \def\digitstt #1{\begingroup\color[named]{OrangeRed}#1\endgroup} \let\dtt\digitstt % \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} % \fexpan 22 octobre 2013 \newcommand\fexpan {\hyperref[ssec:expansions]{\textit{f}-expan}} % Septembre 2015 % Address updated to github repo's one, May 2018 \def\liiibigint {\href{https://github.com/latex3/latex3/tree/master/l3trial/l3bigint}{l3bigint}} % \fixmeaning \makeatletter \def\fixmeaning {\expandafter\fix@meaning\meaning} \expandafter\edef\expandafter\fix@meaning \expandafter #\expandafter1\string\romannumeral#2#3% {#1\string\romannumeral`\string^\string^@} \makeatother % Margin Notes % ============ \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#2{\@bsphack \vadjust{\vskip-\dp\strutbox \smash{\hbox to 0pt {\color[named]{PineGreen}%\normalfont\small \hss #1\ $\bigg\{$#2}}% \vskip\dp\strutbox }\strut\@esphack} \def\IMPORTANT {\MyMarginNoteWithBrace {\raisebox{-.5\height}{\resizebox{2\width}{!}{\ding{43}}}}{\ }} \def\IMPORTANTf {\MyMarginNoteWithBrace {\raisebox{-.5\height}{\resizebox{2\width}{!}{\ding{43}}}}% {\kern\dimexpr\FrameSep+\FrameRule\relax\ }} \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\bfseries \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\bfseries \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]{Red}% \normalfont\small\bfseries \hsize 1.5cm\rightskip.5cm minus.5cm \vtop{\noindent Changed at #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\bfseries \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 added June 9, 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@ } % \leftedline % =========== % 12 octobre 2014 \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 macros and 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 % \MacroFont and \MicroFont % ========================= \def\restoreMicroFont {\def\MicroFont {\ttbfamily\makestarlowast \ifinlefted\else\ifineverb\else\color[named]{Blue}\fi\fi}} \restoreMicroFont % Notice that \macrocode uses \macro@font which stores the \MacroFont meaning % in force at \begin{document}. But doc.sty's verbatim uses current \MacroFont % not the meaning at \begin{document}. Comprenne qui pourra... \def\restoreMacroFont {\def\MacroFont {\ttbfamily \ifinlefted\else\ifineverb\else\color[named]{Blue}\fi\fi}} \restoreMacroFont % \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 the input to accept linebreaks in % its contents. % % 2. Hence I did not want to have obeyed spaces obeyed, (Emacs reflowing % of paragraph in certain contexts often adds spaces at beginning of a line) % % 3. Also I wanted to allow hyphenated 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 \@ifstar{\@sverb}% \verb* is used in the index (obsolete: no indices at 1.3e), % leave it using ambient font {\MicroFont % used to change font (ttbfamily=slashed 0), color, % will make * active via \makestarlowast \catcode 32 10 \endlinechar 32 % allows to fetch across line breaks \frenchspacing % done globally in document \@@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 } % \SoftWrapIcon box for line-breaking using discretionaries % ========================================================= \DeclareFontFamily{U}{MdSymbolC}{} \DeclareFontShape {U}{MdSymbolC}{m}{n}{<-> MdSymbolC-Regular}{} \newbox\SoftWrapIcon \colorlet {softwrapicon}{blue} % Emacs/AUCTeX uses very strange comment-like highlighting for \usefont{U}... \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 \catcode`_ 8 \makeatother % everbatim environment % ===================== % October 13-14, 2014 % Verbatim with an \everypar hook, mainly to have background color, followed by % execution of the contents (not limited by a group-scope) \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 % \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 % Parameters for lists % ==================== \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 }% % ========== % Hyperlinks % ========== % \csa, \csbxint, \csh etc... % =========================== % These definitions in force both in manual and implementation part \DeclareRobustCommand\csa[1] {{\ttzfamily\char92\endlinechar-1 \makestarlowast \catcode`_ 12 \catcode`^ 12 \scantokens\expandafter{\detokenize{#1}}}} % csan: n means no backslash \DeclareRobustCommand\csan[1] {{\ttzfamily\endlinechar-1 \makestarlowast \catcode`_ 12 \catcode`^ 12 \scantokens\expandafter{\detokenize{#1}}}} \newcommand\csh[1] {\texorpdfstring{\csa{#1}}{\textbackslash\detokenize{#1}}} \newcommand\cshn[1] {\texorpdfstring{\csan{#1}}{\detokenize{#1}}} % \csh and \cshn will be redefined in implementation section \let\cshnolabel\csh \let\cshnnolabel\cshn % These definitions will be re-done for implementation part % Don't bother about underscore and caret for time being. \DeclareRobustCommand\csb [1] {\hyperref[\detokenize{#1}]% {{\char92 \endlinechar-1 \makestarlowast \scantokens\expandafter{\detokenize{#1}}}}} \DeclareRobustCommand\csbxint [1] {\hyperref[\detokenize{xint#1}]% {{\char92\mbox{xint}\-\endlinechar-1 \makestarlowast \scantokens\expandafter{\detokenize{#1}}}}} % \func, \funcdesc, \keyword, \keyworddesc, \prec, \precdesc % ========================================================== \newcommand\func[1]{\hyperlink{\detokenize{func-#1}}{#1}()} \newcommand\funcdesc[2][x]{\item[#2({#1})]\hypertarget{\detokenize{func-#2}}{}}% \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$}}{}}% \newcommand\var[1]{\hyperlink{\detokenize{var-#1}}{#1}} \newcommand\vardesc[1]{\item[#1]\hypertarget{\detokenize{var-#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),% (xinttrig, trig), (xintlog, log)} \do {% \expandafter\def\csname #1name\endcsname {\texorpdfstring {\hyperref[sec:#2]% {\relax{\color{joli}\MakeNameUp{#1}}}}% {#1}% \xspace }% \expandafter\def\csname #1nameimp\endcsname {\texorpdfstring {\hyperref[sec:#2imp]% {\relax{\color{blue}\MakeNameUp{#1}}}}% {#1}% \xspace }% }% \def\DOCxintfrontpage {\texorpdfstring {\hyperref[frontpage]{\relax{\color{joli}TOC}}}% {TOC}% \xspace }% \makeatletter \protected\def\MakeNameUp#1{% \ifcsname #1nameUp\endcsname \expandafter\@firstoftwo\else \expandafter\@secondoftwo \fi {\fbox{\textup{#1}}}{#1}} \makeatother % \RaisedLabel % ============ % Samedi 16 juin 2018 à 15:23:22 % trick to see header of target page % there is probably better way to use the already in place % anchor from \section, but no time to go into hyperref source \newcommand\RaisedLabel[2][6]{% \vspace*{-#1\baselineskip}% \begingroup \let\leavevmode\relax\phantomsection \label{#2}% \endgroup \vspace*{#1\baselineskip}% } % begin{document} % =============== % \ttzfamily done at begin document \begin{document}\thispagestyle{empty} \pdfbookmark[1]{Title page}{TOP} {% \normalfont\Large\parindent0pt \parfillskip 0pt\relax \leftskip 2cm plus 1fil \rightskip 2cm plus 1fil \ifnum\dosourcexint=1 The \xintnameimp source code\par \gdef\DOCxintfrontpage {\texorpdfstring {\hyperref[frontpage]{\relax{\color{blue}TOC}}}% {TOC}% \xspace }% \else The \xintname bundle\par \fi \RaisedLabel{frontpage} } {\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 % Vendredi 15 juin 2018 % Someone makes the comma active (not me! not sure if doc.sty or KOMA) and % this derails xspace.sty, in the headers, as it uses \scantokens on a list of % tokens, so it fails to recognize the commas which of course are of catcode12 \def\xintRunningHeader{{\catcode`,12\relax \DOCxintfrontpage, \xintkernelname, \xintcorename, \xintname, \xintfracname, \xintexprname, \xinttrigname, \xintlogname, \xintbinhexname, \xintgcdname, \xintseriesname, \xintcfracname, \xinttoolsname}} \markboth{\makebox[0pt]{\xintRunningHeader}}{\makebox[0pt]{\xintRunningHeader}} % Skips safely. \ifnum\dosourcexint=1 \catcode`+ 0 \catcode0 9 % n'importe quoi sauf 15 (car ^^@) \catcode`\\ 12 +expandafter+iffalse+fi \fi % \newcommand\TeXnote{\par\smallskip\textbf{\TeX hackers note: }} \etocsetlevel{toctobookmark}{6} \etocsetlevel{table}{2}% 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} \etocsettocdepth{subsection} \tableofcontents \renewcommand*\etocabovetocskip{\bigskipamount} \makeatletter \etocmulticolstyle [2]{\parskip\z@skip\raggedcolumns \setlength{\columnsep}{\leftmarginii}% \setlength{\columnseprule}{0pt}% }% \makeatother \etocsettagdepth {description}{none} \etocsettagdepth {macros} {section} \ifnum\NoSourceCode=1 \etocsettagdepth {implementation}{none} \else \etocsettagdepth {implementation}{section} \fi \tableofcontents \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. \def\Fibonacci #1{% \expandafter\Fibonacci_a\expandafter {\the\numexpr #1\expandafter}\expandafter {\romannumeral0\xintiiexpro 1\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro 1\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro 1\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro 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\xintiiexpro sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro (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\xintiiexpro sqr(#2)+sqr(#3)\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro (2#2-#3)#3\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro #2#4+#3#5\expandafter\relax\expandafter}\expandafter {\romannumeral0\xintiiexpro #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}} \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}% }% }% } \pdfbookmark[1]{Dependency graph}{DependencyGraph} \tikzstyle{block} = [rectangle, draw, fill=yellow!10, % fill opacity=0.5, draw=black!30, line width=2pt, text width=6em, text centered, rounded corners, minimum height=4em] \tikzstyle{line} = [draw, line width=1pt, color=black!30] \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{https://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=expr, yshift=-.5cm, xshift=2.25cm] (polexpr) {\href{https://ctan.org/pkg/polexpr}{polexpr}}; \node [block, below of=expr, yshift=-.5cm] (trig) {\xinttrigname}; \node [block, left of=trig] (log) {\xintlogname}; \node [block, left of=log, xshift=-1cm] (poormanlog) {\href{https://ctan.org/pkg/poormanlog}{poormanlog}}; \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]}] (expr) -- (polexpr); \path [line,{Stealth[length=5mm]}-{Stealth[length=5mm]}] (expr) -- (trig); \path [line,{Stealth[length=5mm]}-{Stealth[length=5mm]}] (expr) -- (log); \path [line,-{Stealth[length=5mm]}] (poormanlog) -- (log); \path [line,-{Stealth[length=5mm]}] (expr) -- (polexpr); \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); % at 1.3d gcd() and lcm() needs no support from xintgcd % \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 pointed to by arrows \textbf{automatically} import the modules originating the continuous line ended by an arrow. Dashed lines indicate a partial dependency, and to enable the corresponding functionalities of the lower module it is thus necessary to use a suitable |\usepackage| (\LaTeX) or |\input| (Plain \TeX.)\par \href{https://ctan.org/pkg/bnumexpr}{bnumexpr} is a separate (\LaTeX{} only) package by the author which uses (by default) \xintcorename as its mathematical engine. \href{https://ctan.org/pkg/polexpr}{polexpr} is a separate (\LaTeX{} only) package by the author which requires \xintexprname. \xinttrigname and \xintlogname are loaded automatically by \xintexprname; they will refuse to be loaded directly (but see \csbxint{reloadxinttrig}). \href{https://ctan.org/pkg/poormanlog}{poormanlog} is a \TeX{} and \LaTeX{} package by the author which is loaded automatically by \xintlogname. \par \end{addmargin} \vfill \clearpage \etocdepthtag.toc {description} \section{Read this first}\RaisedLabel{sec:quickintro} This section provides recommended reading on first discovering the package. This is release \expandafter|\xintbndlversion|. \begin{enumerate} \item \func{log}, \func{exp}, \func{log10}, \func{pow10}, \func{pow} are implemented via \href{http://ctan.org/pkg/poormanlog}{poormanlog}: this achieves only \dtt{8} or \dtt{9} digits of precision.... This situation is provisory, I simply was lacking the time. See \xintlogname. \item \func{sin}, \func{cos}, ..., \func{asin}, ... are implemented (using high level user interface), up to about \dtt{60} digits of precision, see \xinttrigname. \item |NaN|, |+Infty|, |-Infty|, etc... and a proper internal data structure for storing floating point numbers are \emph{yet to be implemented}. \item \xintname can handle numbers with thousands of digits, but execution times (and \hyperref[ssec:memory]{memory considerations}) limit the practical range to perhaps up to a few hundreds digits. \item Attention that exact operations with fractions do not reduce to lowest terms (additions and subtractions use |l.c.m.| of denominators), see \func{reduce}. \end{enumerate} \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. And \xinttrigname and \xintlogname since |1.3e|. \item[\xinttrigname] trigonometrical functions for \xintexprname, automatically loaded\NewWith{1.3e} by it, can not be used separately. \item[\xintlogname] logarithm, exponential, power functions for \xintexprname, automatically loaded\NewWith{1.3e} by it, can not be used separately. \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. Also the \xintexprname functions \func{gcd} and \func{lcm} are implemented directly so loading this module is not needed for them (since |1.3d|). \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.} 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*} \xintfloateval{3.25^100/3.2^100, 2^1000000, sqrt(1000!)}\newline \xintfloateval{[-1] sind(37), cosd(37)}\newline % trim off last digit (via rounding) \xintfloateval{[8] log10(12345678), pow10(0.1234)}\newline % only 8 or 9 digits! \xintfloateval{[8] pow(2,1/3)}\newline % only 8 or 9 digits! \xintfloateval{[8] log(10), exp(1)}\par % only 8 or 9 digits! \end{everbatim*} The \csbxint{floateval} macro using braces was introduced at |1.3d|. Formerly, one did: \begin{everbatim} \thexintfloatexpr 10^-3.5\relax\ or rather \xintthefloatexpr 10^-3.5\relax \end{everbatim} Most of the manual is couched using the \csbxint{theexpr}|...\relax| which is the original one from first release of \xintexprname. For powers with fractional exponents, see \hyperref[ssec:poormanloghack]{poormanloghack}. \item[with fractions:]\leavevmode\par Here is an example using a dummy a variable: \begin{everbatim*} $\sum_{i=1}^{25} (-1)^{i-1}\frac{1}{i^2} = \xintFrac{\xinteval{reduce(add((-1)^(i-1)/i**2, i=1..25))}}$ \end{everbatim*} \item[with integers:]\leavevmode\par \begin{everbatim*} \xintiieval{3^159+2^234}\newline \xintiieval{lcm(seq(n, n=100..110))}\par \end{everbatim*} \end{description} Float computations are done by default with \dtt{16} digits of precision. This can be changed via an assignment to |\xintDigits|: \begin{everbatim*} % use braces (or a LaTeX environment) to limit the scope of the \xintDigits assignment {\xintDigits := 88\relax \xintfloateval{3.25^100-3.2^100}}\par \end{everbatim*} Trigonometrical function need a reload after modifying the float precision, this is done by \csbxint{reloadxinttrig}. We can even try daring things:\footnote{The \cs{printnumber} is not part of the package, see \autoref{ssec:printnumber}.} \begin{everbatim*} {\xintDigits:=500\relax \printnumber{\xintfloateval{sqrt(2)}}} \end{everbatim*} All operations executed by the parsers are based on underlying macros from packages \xintfracname and \xintname which are loaded automatically by \xintexprname. With \xintbinhexname loaded the parsers can handle hexadecimal notation on (even fractional) input. 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. See \autoref{sec:xintexprsyntax} for a more detailed description, and perhaps read \autoref{ssec:threeparsers} before coming back here. 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 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} \begin{framed} Release |1.3d| defines \csbxint{eval}, \csbxint{ieval}, \csbxint{iieval}, \NewWithf{1.3d} and \csbxint{floateval} which use braces to delimit their arguments, which will be more familiar to \LaTeX\ users than the \csbxint{theexpr}|...\relax| syntax. For example: \begin{everbatim*} \xinteval{1+2+3}, \xintfloateval{111/123}, \xintfloateval{[3] 111/123} \end{everbatim*} This documentation however uses systematically |\xinttheexpr...\relax| or |\thexintexpr...\relax| syntax for legacy reasons. In this input syntax the |\relax| does not have to be physically present it may arise from pure expansion (see \autoref{sec:expr}). Notice that for the \csbxint{theiexpr} and \csbxint{thefloatexpr} parsers which admit an optional argument, this optional argument will have to be located \emph{inside} the braces when using |\xintieval| or |\xintfloateval| input syntax, as examplified above. The main reason is that it is sometimes useful to hide the square brackets, for example when using the |\num| macro from package \href{http://ctan.org/pkg/siunitx}{siunitx}. \end{framed} \begin{framed} The square root extraction \func{sqrt} is allowed in |\xintexpr..\relax| but naturally can't return an \emph{exact} value, it computes as if it was in |\xintfloatexpr..\relax|. The synonymous power operators |^| and |**| allow only integral exponents (non-negative in the integer only parser \csbxint{iiexpr}) in \csbxint{expr} and half-integral exponents in \csbxint{floatexpr}. Since |1.3e| fractional powers via the \func{pow} function are available, see \xintlogname.\NewWithf{1.3e} But they achieve currently only about \dtt{8} digits of precision. \end{framed} Here is a (partial) list of the recognized symbols: \begin{itemize} \item the comma (to separate distinct computations or arguments to a function), \item parentheses, \item \hyperref[tab:precedences]{operators}: \begin{itemize}[nosep] \item |+|, |-|, |*|, |/|, \item powers via |^| or equivalently |**|, see \xintlogname for allowing with them fractional exponents, \item |//| for floored division and |/:| its associated modulo, \item branching via |(x)?{x non zero}{x zero}| and |(x)??{x<0}{x=0}{x>0}| syntax, \item boolean logic |!|, |&&| or |'and'|, \verb+||+ or |'or'|, \item comparison operators |=| (or |==|), |<|, |>|, |<=|, |>=|, |!=|, \item factorial via the post-fix operator |!|. \end{itemize} \item the |"| is used to prefix hexadecimal input (uppercase, not lowercase); but package \xintbinhexname must be loaded additionally to \xintexprname), %\item |'| for octal input (\emph{not yet}), \item various \hyperref[tab:functions]{functions}: \begin{itemize}[nosep] \item rounding and truncating \func{round}, \func{trunc} to a given fixed point precision or with \func{float} to a given floating point precision, \item the square-root \func{sqrt} achieves correct rounding in arbitrary precision, \item the \func{binomial} and (also partial) \func{factorial}, \item \func{gcd} and \func{lcm} for general fractional operands, \item randomness related functions such as \func{random} and \func{randrange} for random floats or integers; they require that \TeX\ engine provides \csa{pdfuniformdeviate} or \csa{uniformdeviate} primitive, \item trigonometrical functions \xinttrigname, \item logarithm and exponential \xintlogname. \end{itemize} \item the capacity to work with dummy variables using functions or generators such as \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 a complete description. The normal mode of operation of the parsers is to unveil the parsed material token by token. This means (apart from some exceptions) that all tokens 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. However, this general behaviour has exceptions, in particular constructs with dummy variables need at some location 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. 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\relax \xintthefloatexpr 1.23456789123456789^123456789\relax } \end{everbatim*} (<- notice the size of the power of ten: this surely largely exceeds your pocket calculator abilities). Some examples with dummy variables: \begin{everbatim*} \xinttheiiexpr add(i^5, i=100..200)\relax\par \noindent\xinttheexpr add(x/(x+1), x = 1000..1014)\relax\par \noindent\xinttheexpr reduce(add(x/(x+1), x = 1000..1014))\relax \end{everbatim*} \newline In this example, the fraction obtained by addition was thus already irreducible, but this is not always the case: \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|, and |A/B| added to |C/D| uses |lcm(B, D)| as denominator.\CHANGEDf{1.3} \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} This section is now quite old... 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{https://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\relax \np{\xintthefloatexpr .7123045678952^-243\relax}|}% % \leftedline{\xintDigits:=20\relax \dtt{\np{\xintthefloatexpr .7123045678952^-243\relax }}} % \xintDigits:=16\relax % % 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\relax |\newline |\xintthefloatexpr 2000!\relax|: {\xintDigits:=50\relax \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{https://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{https://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{https://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 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 \autoref{ssec:PrimesIV} implements expandably the Miller-Rabin pseudo-primality test. \item The functionalities of \xintexprname are illustrated with various other examples, in \autoref{xintdeffunc}, \hyperlink{ssec:dummies}{Functions with dummy variables}, \autoref{ssec:moredummies} or \hyperref[sssec:recursive]{Recursive definitions}. \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{License and 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} and 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. The |README| files on \href{https://ctan.org/pkg/xint}{CTAN} explain how to proceed with a custom installation. On \TeX\ distributions with a |"texdoc"| or similar utility, \centeredline{|texdoc --list xint|} will offer to display one of those files: \begin{itemize}[nosep] \item |xint.pdf| (this file), \item |sourcexint.pdf| (source code), \item |README|, |README.pdf|, |README.html|, \item |CHANGES.pdf|, and |CHANGES.html|. \end{itemize} % For manual installation, follow the instructions from the |README| file which % is to be found on \href{https://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{https://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://mirrors.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 {Recent changes} This is release \expandafter|\xintbndlversion| of \expandafter|\xintbndldate|. For more information see |CHANGES.html|.\centeredline{Internet: \url{http://mirrors.ctan.org/macros/generic/xint/CHANGES.html}} The formatted source code is available in file |sourcexint.pdf|: \centeredline{|texdoc sourcexint|} \noindent\expandafter|\xintbndlversion| (\expandafter|\xintbndldate|): \begin{itemize}[nosep] \item Fix bug preventing usage of \csbxint{defefunc} to define a function with no variables. \item Fix bug with usage of |\xintfloatexpr[D]..\relax| inside the parsed expression for \csbxint{deffunc} and variants. \item Revert |1.3e| ban on usage of \csbxint{eval} et al. inside a function definition via \csbxint{deffunc} and variants. \item Macro definitions via \csbxint{NewExpr} now also allow \csbxint{eval} et al. within them. \item Add \csbxint{Digits}|=P;| syntax with no colon. \item Document that the ending semi-colon in \csbxint{Digits}|:=P;| must not be active, and that it has always been allowed to use any non-expanding token such as a dot or a |\relax| in its place. \item Add \csbxint{SetDigits} user interface. \item Add \csbxint{Digits*}|:=P;| and \csbxint{SetDigits*}|{P}| variants which execute \csbxint{reloadxinttrig}. \end{itemize} \noindent|1.3e| (|2019/04/05|): \begin{itemize}[nosep] \item An \xinttrigname library is automatically loaded by \xintexprname and provides direct and inverse trigonometrical functions using either degrees or radians (up to \dtt{60} digits). It is for the most part implemented using high level user interface, but will probably get some optimizations in future (and perhaps extension to more digits). \item An \xintlogname library is loaded automatically; it uses \href{http://ctan.org/pkg/poormanlog}{poormanlog} to provide logarithms and exponentials. Support for more digits is planned for the future: the \href{http://ctan.org/pkg/poormanlog}{poormanlog} support achieves only about \dtt{8} or \dtt{9} digits of precision. On the other hand the functions are fast. Perhaps we will keep the current functions achieving limited precision under some other names in future (they are amply precise enough for plots). \item Under the hood refactoring of \csbxint{NewExpr} related matters for support of user-defined functions; fixed bugs related to functions with no variables. Added \csbxint{defefunc}, \csbxint{deffloatefunc}, \csbxint{defiiefunc} and documented the ``protected'' nature of the functions defined by the original variants \csbxint{deffunc} et al. This whole area is complex and to be still considered work in progress. \item Breaking change (\emph{which got reverted at \texttt{1.3f}}):\CHANGED{1.3f} only the \csbxint{expr}|...\relax| syntax is accepted for sub-expressions when doing function definitions via \csbxint{deffunc} and \csbxint{defefunc} et al. One can not use \csbxint{eval}, \csbxint{ieval}, \csbxint{floateval} inside such definitions. \item \func{inv}, \func{ilog10}. \item \func{sfloat}, slight modification of behaviour of \func{qfloat}. \item \csbxint{ensuredummy}, \csbxint{restorelettervar}. \item the optional argument of \csbxint{floatexpr} can be negative, it then tells to round the result to a (rounded) float with a precision equal to \csbxint{theDigits} diminished by this argument. \end{itemize} % \noindent|1.3d| (|2019/01/06|): % \begin{itemize}[nosep] % \item \func{gcd} and \func{lcm} in \csbxint{expr}|...\relax| now handle % general arguments, without converting them to integers, % \item It is not needed anymore to load package \xintgcdname to benefit from % \func{gcd} and \func{lcm} in the parsers. % \item \csbxint{ifsgnexpr}, \csbxint{ifsgnfloatexpr}, \csbxint{ifsgniiexpr}. % \item \csbxint{unassignexprfunc} and variants for the other parsers. % \item \func{isone} and \func{isint}. % \item \csbxint{eval}, \csbxint{ieval}, \csbxint{iieval}, and % \csbxint{floateval}. Attention: these names were formerly used with some other % (barely documented) meanings, for which |\xintexpro|, |\xintiexpro|, % etc... are now used. % \item Sadly, in \csbxint{iiexpr}|...\relax| division with a zero dividend and % a one-digit divisor got broken at |1.2p|. Fixed. Thanks to \textsc{Kpym} for % report. Sorry for long delay in releasing the bugfix, which was done shortly % after |1.3c| release. % \end{itemize} \section{The syntax of \xintexprname expressions} \label{sec:xintexprsyntax} \localtableofcontents \subsection{The three parsers}\label{ssec:threeparsers} 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\relax |. 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 \func{sqrt} function is available and obeys either the |\xintDigits| precision or its second optional argument. \end{itemize} 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}, \csbxint{ifsgnexpr}, \csbxint{ifsgniiexpr}, \csbxint{ifsgnfloatexpr} (they do not handle comma separated expressions). \end{itemize} Release |1.3d| provides \csbxint{eval}, \csbxint{ieval}, \NewWith{1.3d} \csbxint{iieval}, \csbxint{floateval}. \subsection{Built-in operators and their precedences} \def\MicroFont{\ttbfamily\makestarlowast\color[named]{DarkOrchid}} \makeatletter \def\@floatboxreset{\@setminipage}% faudra contrôler celui-là \makeatother \begin{table}[htbp] \edef\restorehtdpstrutbox {\ht\strutbox\the\ht\strutbox\dp\strutbox\the\dp\strutbox} \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| is computed as |(1+2)/((3+4)*5)| 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}{\textbf{(table)} \protect\emph{Precedence levels of operators}} \restorehtdpstrutbox \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. Attention that the boolean equality test |==| must not follow directly such a |!| because the parser will handle |!=| as the boolean inequality test... the remaining |=| then causes a parsing error. It is even worse if one uses a single |=| following the |!| because no error arises but an un-intended interpretation. Use parentheses: |(3!)==10|. \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, acos, acosd, Arg, Argd, asin, asind, atan, atand, atan2, atan2d, binomial, bool, ceil, cos, cosd, cot, cotd, cotg, csc, cscd, divmod, even, exp, factorial, first, float, floor, frac, gcd, if, ifint, ifone, ifsgn, ilog10, isint, isone, iter, iterr, inv, last, lcm, len, log, log10, max, min, mod, mul, not, num, odd, pArg, pArgd, pfactorial, pow, pow10, preduce, qfloat, qfrac, qint, qrand, qraw, quo, random, randrange, reduce, rem, reversed, round, rrseq, rseq, sec, secd, seq, sgn, sin, sinc, sind, sqr, sqrt, sqrtr, subs, tan, tand, tg, togl, trunc, xor} \to\Functions \cnta\Functions{0} \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}{\textbf{(table)} \protect\emph{Functions in expressions}} \etocsetnexttocdepth{subsubsection} \localtableofcontents \end{table} Miscellaneous notes: \begin{itemize}[nosep] \item since release |1.3d| \func{gcd}\NewWith{1.3d} and \func{lcm} are extended to apply to fractions too, and they do NOT require the loading of \xintgcdname, \item The randomness related functions \func{random}, \func{qrand} and \func{randrange} require that the \TeX\ engine provides the \csa{uniformdeviate} or \csa{pdfuniformdeviate} primitive. This is currently the case for |pdftex|, |(u)ptex|, |luatex|, and will be for |xetex| starting with \TeX Live 2019.\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}, \func{qraw}, \func{random} and \func{qrand}. \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] \subsubsection{Functions with no argument} \begin{description} % [parsep=0pt,align=left, % leftmargin=0pt, itemindent=0pt, % labelwidth=-\fontdimen2\font, labelsep=\fontdimen2\font, labelindent=0pt, % listparindent=\leftmarginiii] \funcdesc[]{random} returns a random float |x| verifying |0 <= x < 1|. It obeys the prevailing precision as set by \csbxint{Digits}: i.e. with |P| being the precision the random float multiplied by |10^P| is an integer, uniformly distributed in the |0..10^P-1| range.\NewWith{1.3b} This description implies that if |x| turns out to be |<0.1| then its (normalized) mantissa has |P-1| digits and a trailing zero, if |x<0.01| it has |P-2| digits and two trailing zeros, etc... This is what is observed also with Python's |random()|, of course with |10| replaced there by radix |2|.% \begin{everbatim*} \pdfsetrandomseed 12345 \xintDigits:=37\relax \xintthefloatexpr random()\relax\newline \xintthefloatexpr random()\relax\par \end{everbatim*} \begin{framed} Due to the way \csbxint{expr}|...\relax| are handled (see \autoref{ssec:memory}), Monte-Carlo type simulations using expressions may relatively easily exhaust \TeX{} memory.\IMPORTANT\ If possible use \csbxint{NewFloatExpr} to construct from such expressions involving the \func{random} function macros not creating the memory impact which is described in \autoref{ssec:memory}. \end{framed} \funcdesc[]{qrand} returns a random float |0 <= x < 1| using \dtt{16} digits of precision (i.e. |10^{16}x| is an integer). This is provided when speed is a at premium as it is optimized for precision being precisely \dtt{16}.% \NewWith{1.3b} \begin{everbatim*} % still with 37 digits as prevailing float precision \xintthefloatexpr qrand(), random()\relax\newline \xintDigits:=16\relax \xintthefloatexpr qrand(), random()\relax\par \end{everbatim*} One can use both |qrand()| and |random()| inside the |\xintexpr| parser too. But inside the integer only |\xintiiexpr| parser they will cause some low-level error as soon as they get involved in any kind of computation as they use an internal format not recognized by the integer-only parser. See further \func{randrange}, which generates random integers. Currently there is no |uniform()| function% % \footnote{Because I am not sure how to handle rounding issues: should the computation proceed exactly and a rounding be done only at very end?} % but it can be created by user: \begin{everbatim*} \xintdeffloatfunc uniform(a, b):= a + (b-a)*random(); \romannumeral\xintreplicate{10}% {% \xintthefloatexpr uniform(123.45678, 123.45679)\relax\newline }% \end{everbatim*} \end{description} \subsubsection{Functions with a single (numeric) argument} \begin{description} % [parsep=0pt,align=left, % leftmargin=0pt, itemindent=0pt, % labelwidth=-\fontdimen2\font, labelsep=\fontdimen2\font, labelindent=0pt, % listparindent=\leftmarginiii] \funcdesc{num} truncates to the nearest integer (truncation towards zero). It has the same sign as |x|, except of course with |-1