% -*- coding: utf-8; time-stamp-format: "%02d-%02m-%:y at %02H:%02M:%02S %Z" -*-
% This file: xint-calx.dtx. Proudly produced by xint-dtxbuild.sh.
% Run etex on this file to extract all xint*sty files.
%<*dtx>
\def\xintdtxtimestamp {Time-stamp: <05-11-2026 at 13:36:23 CET>}
%</dtx>
%
% To build xint-calx.pdf (with both user manual and commented source code),
% the recommended way is:
%
%  - step 1: etex xint-calx.dtx (stop here if you only need the xint*sty files)
%  - step 2: make --file=Makefile.mk xint-calx.pdf
% 
% The above step 2 requires make + latexmk and uses latex + dvipdfmx.
%
% Other make targets are
% - xintmanual.pdf (contains only the user documentation)
% - xintsource.pdf (contains only the commented source code)
%
% Alternative for building xint-calx.pdf (and extracting the xint*sty files):
%
%     Direct runs of pdflatex, xelatex or lualatex on xint-calx.dtx,
%     or (better) of latexmk -pdf (or -pdfxe, -pdflua) on xint-calx.dtx.
%
% (if using xelatex, it must be with -8bit option for extracted Makefile.mk
%  to be valid, but this has no impact on the xint*sty files and xint-calx.pdf).
%
%<*xintmandrv|xintsrcdrv|xintalldrv>
%% ---------------------------------------------------------------
\def\calxbndldate{2026/11/01}
\def\calxbndlversion{2.0a1}
\let\xintbndldate\calxbndldate
\let\xintbndlversion\calxbndlversion
%</xintmandrv|xintsrcdrv|xintalldrv>
%<*!makefile>
%% ---------------------------------------------------------------
%% The xint bundle 2.0 2026/10/22
%% Copyright (C) 2013-2022, 2025, 2026 Jean-Francois Burnol
%<xint>%% xint: Expandable operations on big integers
%<xintbinhex>%% xintbinhex: Expandable radix conversions (2, 8, 10, and 16)
%<xintcfrac>%% xintcfrac: Expandable continued fractions with xint package
%<xintcore>%% xintcore: Expandable arithmetic on big integers
%<xintexpr>%% xintexpr: Expandable fp, bigint and fraction expression parsers
%<xintfrac>%% xintfrac: Expandable operations on fractions
%<xintgcd>%% xintgcd: Euclidean algorithm with xint package
%<xintkernel>%% xintkernel: Paraphernalia for the xint packages
%<xintseries>%% xintseries: Expandable partial sums with xint package
%<xinttools>%% xinttools: Expandable and non-expandable utilities
%<calx>%% calx: Expandable fp and bigint expression parsers
%<calxcore>%% calxcore: Expandable arithmetic on big integers
%<calxfp>%% calxfp: Floating point unit P1 to P100
%<calxint>%% calxint: Expandable operations on big integers
%<calxlog>%% calxlog: log, exp, etc for xintexpr/calx
%<calxtrig>%% calxtrig: sin, cos, etc for xintexpr/calx
%% ---------------------------------------------------------------
%</!makefile>
%<*dtx>
\bgroup\catcode2 0 \catcode`\\ 12 ^^Biffalse
%</dtx>
%<*dates>-------------------------------------------------------
`2.0a1 (2026/11/01)`
`1.4q (2026/10/31)`
`1.4p (2026/03/01)`
`1.4o (2025/09/06)`
`1.4n (2025/09/05)`
`1.4m (2022/06/10)`
`1.4l (2022/05/29)`
`1.4k (2022/05/18)`
`1.4j (2021/07/13)`
`1.4i (2021/06/11)`
`1.4h (2021/05/27)`
`1.4g (2021/05/25)`
`1.4f (2021/05/10)`
`1.4e (2021/05/05)`
`1.4d (2021/03/29)`
`1.4c (2021/02/20)`
`1.4b (2020/02/25)`
`1.4a (2020/02/19)`
`1.4 (2020/01/31)`
`1.3f (2019/09/10)`
`1.3e (2019/04/05)`
`1.3d (2019/01/06)`
`1.3c (2018/06/17)`
`1.3b (2018/05/18)`
`1.3a (2018/03/07)`
`1.3 (2018/03/01)`
`1.2q (2018/02/06)`
`1.2p (2017/12/05)`
`1.2o (2017/08/29)`
`1.2n (2017/08/06)`
`1.2m (2017/07/31)`
`1.2l (2017/07/26)`
`1.2k (2017/01/06)`
`1.2j (2016/12/22)`
`1.2i (2016/12/13)`
`1.2h (2016/11/20)`
`1.2g (2016/03/19)`
`1.2f (2016/03/12)`
`1.2e (2015/11/22)`
`1.2d (2015/11/18)`
`1.2c (2015/11/16)`
`1.2b (2015/10/29)`
`1.2a (2015/10/19)`
`1.2 (2015/10/10)`
`1.1c (2015/09/12)`
`1.1b (2015/08/31)`
`1.1a (2014/11/07)`
`1.1 (2014/10/28)`
`1.09n (2014/04/01)`
`1.09m (2014/02/26)`
`1.09kb (2014/02/13)`
`1.09k (2014/01/21)`
`1.09j (2014/01/09)`
`1.09i (2013/12/18)`
`1.09h (2013/11/28)`
`1.09g (2013/11/22)`
`1.09f (2013/11/04)`
`1.09e (2013/10/29)`
`1.09d (2013/10/22)`
`1.09c (2013/10/09)`
`1.09b (2013/10/03)`
`1.09a (2013/09/24)`
`1.08b (2013/06/14)`
`1.08a (2013/06/11)`
`1.08 (2013/06/07)`
`1.07 (2013/05/25)`
`1.06b (2013/05/14)`
`1.06 (2013/05/07)`
`1.05 (2013/05/01)`
`1.04 (2013/04/25)`
`1.03 (2013/04/14)`
`1.0 (2013/03/28)`
%</dates>------------------------------------------------------
%<*makefile>------------------------------------------------------
# This file: Makefile.mk (generated from xint-calx.dtx)
# "make --file=Makefile.mk help"

# The 1.4p CTAN zip does not include an xint.tds.zip anymore
# But the Makefile recipe is kept here in case of need.
# A copy of README.md is not included in xint-calx.dtx anymore.

# The 1.4n CTAN zip includes an xintchanges.md but no CHANGES.html
# anymore.  The xintchanges.md is not extracted from the dtx but
# kept separate.

# The 1.4n CTAN zip does not ship with a commodity Makefile anymore,
# use -f Makefile.mk as above or rename it to Makefile.
# Also it does not include CHANGES.html.  It can be build via make
# or checked at https://jfbu.github.io/xint/CHANGES.html.

# With 1.4n also, sourcexint.pdf got renamed into xintsource.pdf
# and xint.pdf became what was called xint-all.pdf, i.e. (as was also
# the case originally) it contains both user manual and documented
# source code.  This allows to benefit from hyperlinks between the two,
# which were added already in 2022.

# Starting with xint 1.3c, Latexmk is used for easier compilation of
# sourcexint.pdf as the latter then included indices. These indices
# got removed at 1.3e but usage of Latexmk is maintained for the build.

# 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

It is recommended to work with xint-calx.dtx and Makefile moved to some
otherwise empty temporary repertory.

make help
    Display this help using the more pager.

make helpless
    Display this help using the less pager.

make doc
    Produce all documentation, requires Latexmk and Pandoc.

make all
    Produce all documentation, then creates xint.tds.zip.

make xint.tds.zip
    Same as "make all"

make xintmanual.pdf
    Extract files and produce xintmanual.pdf (user manual),
    using latex and dvipdfmx.  This requires Latexmk.

make xintsource.pdf
    Extract files and produce xintsource.pdf (source code),
    using latex and dvipdfmx.  This requires Latexmk.

make xint-calx.pdf
    Extract files and produce xint-calx.pdf (manual + code),
    using latex and dvipdfmx.  This requires Latexmk.

make CHANGES.html
    This requires Pandoc.

make clean
    Remove auxiliary files and repertories.

make cleanmore
    Remove also PDFs and ZIP archives and a few more.

==== INSTALLING

The following has been tested on a TeXLive installation:

make installhome
    Create xint.tds.zip, and unzip it in <TEXMFHOME>

make installlocal
    Create xint.tds.zip, unzip it in <TEXMFLOCAL>
        and then does texhash <TEXMFLOCAL>

    Depending on access rights "sudo make installlocal"
    might be needed. In case of doubt run first "make doc"
    then "make installlocal". If the latter fails, then
    try "sudo make installlocal".

make uninstallhome
    Remove all xint files and repertories from <TEXMFHOME>

make uninstalllocal
    Remove all xint files and repertories from <TEXMFLOCAL>
        and then does texhash <TEXMFLOCAL>

    Might need "sudo".

endef

# Quelques difficultés à trouver le bon choix de ' ou " et de \#
# et l'utilisation des \ en fins de ligne pour que ça fonctionne.
highlighting-css = '    body{margin: 0; margin-left : 10%; margin-right : 15%; margin-top: 4ex; font-size: 20px; font-family: serif; max-width: 100%; padding: 0; }\
    pre  {white-space: pre-wrap;}\
    code {white-space: pre-wrap;}\
    a:link { color: blue; }\
    a:visited { color: green; }\
    a:hover { text-decoration: underline; color: hotpink }\
    a:active { color: brown; }\
    \#TOC {float: right; position: relative; top: 100px; margin-bottom: 100px; margin-left: 20px;}'



.PHONY: help helpless all doc clean cleanmore\
        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\
           calxcore.sty calxint.sty calxfp.sty calx.sty\
           calxlog.tex calxlogdata.tex calxtrig.tex calxtrigdata.tex
# Makefile.mk n'est pas mis dans $(extrated) pour éviter des messages
# de make.  Les sty (aussi extraits) sont dans $(packages).
extracted  = xintmanual.tex xintsource.tex xint-calx.tex xint-dates.txt
filesfortex    = $(packages)
filesforsource = xint-calx.dtx
filesfordoc    = xint-calx.pdf README.md xintchanges.md
auxiliaryfiles = xintmanual.dvi xintmanual.aux xintmanual.toc xintmanual.log\
     xintsource.dvi xintsource.aux xintsource.toc xintsource.log\
     xint-calx.dvi xint-calx.aux xint-calx.toc xint-calx.log

all: $(packages) $(extracted) doc xint-calx.tds.zip
	@echo 'make all done.'

$(packages): xint-calx.dtx
	etex xint-calx.dtx

$(extracted): xint-calx.dtx
	etex xint-calx.dtx

doc: xintmanual.pdf xintsource.pdf CHANGES.html
	@echo 'make doc done.'

xintmanual.pdf: xint-calx.dtx xintmanual.tex
	latexmk xintmanual.tex
	dvipdfmx xintmanual.dvi

xintsource.pdf: xint-calx.dtx xintsource.tex
	latexmk xintsource.tex
	dvipdfmx xintsource.dvi

xint-calx.pdf: xint-calx.dtx xint-calx.tex
	latexmk xint-calx.tex
	dvipdfmx xint-calx.dvi

CHANGES.html: xintchanges.md
	pandoc -o CHANGES.html -s --toc -V highlighting-css=$(highlighting-css) xintchanges.md

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)
	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
	umask 0022 && cd $(JF_tmpdir) && zip -r xint.zip xint
	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/ .auto/ TEMP*/
	rm -f $(auxiliaryfiles)\
	  xintmanual.fls xintmanual.fdb_latexmk\
	  xintsource.fls xintsource.fdb_latexmk\
	  xint-calx.fls xint-calx.fdb_latexmk

# 1.4p does not remove xintmanual.pdf and xintsource.pdf
# because cleanmore is used at home for building zip for CTAN
# and it does not include them anyhow.
cleanmore: clean
	rm -f xint-calx.pdf xint.tds.zip xint.zip
%</makefile>$-----------------------------------------------------
%<*xintmandrv>-----------------------------------------------------------
%% To extract files:
%%   etex xint-calx.dtx
%%
%% Then execute:
%%   make --file=Makefile.mk xintmanual.pdf
%%
%% Alternative for build without `make':
%%   latexmk xintmanual.tex
%%   dvipdfmx xintmanual.dvi
%%
%% One can also tell latexmk to use pdflatex, lualatex or xelatex.
%% Or use one of them directly enough times on xintmanual.tex.
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{xintmanual.tex}%
[\xintbndldate\space v\xintbndlversion\space xint documentation (JFB)]%
\PassOptionsToClass{a4paper,fontsize=10pt}{scrartcl}
\chardef\NoSourceCode 1
\input xint-calx.dtx
%%% Local Variables:
%%% mode: latex
%%% TeX-PDF-from-DVI: "Dvipdfmx"
%%% End:
%</xintmandrv>-----------------------------------------------------------
%<*xintsrcdrv>-----------------------------------------------------------
%% To extract files:
%%   etex xint-calx.dtx
%%
%% Then execute:
%%   make --file=Makefile.mk xintsource.pdf
%%
%% Alternative for build without `make':
%%   latexmk xintsource.tex
%%   dvipdfmx xintsource.dvi
%%
%% One can also tell latexmk to use pdflatex, lualatex or xelatex.
%% Or use one of them directly enough times on xintsource.tex.
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{xintsource.tex}%
[\xintbndldate\space v\xintbndlversion\space xint commented code (JFB)]%
\PassOptionsToClass{a4paper,fontsize=10pt}{scrartcl}
\chardef\NoSourceCode=0\chardef\doxintsource=1
\input xint-calx.dtx
%%% Local Variables:
%%% mode: latex
%%% TeX-PDF-from-DVI: "Dvipdfmx"
%%% End:
%</xintsrcdrv>-----------------------------------------------------------
%<*xintalldrv>-----------------------------------------------------------
%% To extract files: (but this is probably already done as you read this)
%%   etex xint-calx.dtx
%%
%% Then execute:
%%   make --file=Makefile.mk xint-calx.pdf
%% to obtain a PDF containing both user manual and source code.
%%
%% Alternative for build without `make':
%%
%%   latexmk xint-calx.tex
%%   dvipdfmx xint-calx.dvi
%%
%% One can also use pdflatex/lualatex/xelatex directly on xint-calx.tex,
%% (or better latexmk with suitable engine option).
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{xint-calx.tex}%
[\xintbndldate\space v\xintbndlversion\space xint user plus source doc (JFB)]%
\PassOptionsToClass{a4paper,fontsize=10pt}{scrartcl}
\chardef\NoSourceCode=0
\input xint-calx.dtx
%%% Local Variables:
%%% mode: latex
%%% TeX-PDF-from-DVI: "Dvipdfmx"
%%% End:
%</xintalldrv>-----------------------------------------------------------
%<*dtx>-----------------------------------------------------------
^^Bfi^^Begroup
\chardef\noetex 0
\ifx\numexpr\undefined\chardef\noetex 1 \fi
% changed 2021/05/30: do not extract files at all if not using etex
\ifnum\noetex=1 \chardef\extractfiles 3 % no extract, no typeset
\else
  \ifx\PassOptionsToClass\undefined
      \chardef\extractfiles 0 % no LaTeX2e: probably etex, xetex, ... on xint-calx.dtx
  \else
      \ifx\NoSourceCode\undefined
        % latex/pdflatex/xelatex/lualatex on xint-calx.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}{scrartcl}%
      \else
        % latex/pdflatex/xelatex/lualatex on xint{manual,source,}.tex
        \chardef\extractfiles 2 % no extractions, but typeset
      \fi
    \ProvidesFile{xint-calx.dtx}[Source of the xint-calx bundle
                            \xintbndlversion \xintbndldate]%
  \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 calxcore.sty^^J}%
\Msg{* \space\space\space\space calxint.sty^^J}%
\Msg{* \space\space\space\space calxfp.sty^^J}%
\Msg{* \space\space\space\space calx.sty^^J}%
\Msg{* \space\space\space\space calxlog.tex^^J}%
\Msg{* \space\space\space\space calxlogdata.tex^^J}%
\Msg{* \space\space\space\space calxtrig.tex^^J}%
\Msg{* \space\space\space\space calxtrigdata.tex^^J}%
\Msg{*^^J}%
\Msg{* Rename Makefile.mk to Makefile if the latter is absent^^J}%
\Msg{*     (or use --file=Makefile.mk option of "make")^^J}%
\Msg{* then "make xint-calx.pdf" builds a PDF including both the user manual^^J}%
\Msg{* and the commented source code.^^J}%
\Msg{*^^J}%
\Msg{* Building with "make" requires "Latexmk".^^J}%
\Msg{* The target "CHANGES.html" requires "Pandoc".^^J}%
\Msg{*^^J}%
\Msg{* Instructions for building without "make" are in file xint-calx.tex.^^J}%
\Msg{*^^J}%
\Msg{* Happy TeXing!^^J}%
\Msg{*^^J}%
\Msg{********************************************************************^^J}%
}%
\ifx\XeTeXinterchartoks\undefined\else
  \expandafter\def\expandafter\MessageDeFin\expandafter{\MessageDeFin
\Msg{* ATTENTION! extraction with xetex must be made with -8bit option.^^J}%
\Msg{* Extracted file Makefile.mk is invalid if this was not the case.^^J}%
\Msg{********************************************************************^^J}%
}%
\fi
\begingroup
    \input docstrip.tex
    \askforoverwritefalse
    \catcode9 11 % do not kill TAB in producing Makefile.mk
    \generate{\nopreamble\nopostamble
    % 1.4p of September 2025 omits including README.md in dtx
    % 1.4n of September 2025 omits including (renamed) CHANGES.md in dtx
    \file{xint-dates.txt}{\from{xint-calx.dtx}{dates}}
    % pure tex will use ^^I notation for TAB character, don't want that.
    % anyway, since 2021/05/30, tex xint-calx.dtx has been made a no-op.
    % there is a problem with xelatex, it generates ^^I if not with -8bit
    \file{Makefile.mk}{\from{xint-calx.dtx}{makefile}}
    \usepreamble\defaultpreamble
    \usepostamble\defaultpostamble
    \file{xintmanual.tex}{\from{xint-calx.dtx}{xintmandrv}}
    \file{xintsource.tex}{\from{xint-calx.dtx}{xintsrcdrv}}
    \file{xint-calx.tex}{\from{xint-calx.dtx}{xintalldrv}}
    \file{xintkernel.sty}{\from{xint-calx.dtx}{xintkernel}}
    \file{xinttools.sty}{\from{xint-calx.dtx}{xinttools}}
    \file{xintcore.sty}{\from{xint-calx.dtx}{xintcore}}
    \file{xint.sty}{\from{xint-calx.dtx}{xint}}
    \file{xintbinhex.sty}{\from{xint-calx.dtx}{xintbinhex}}
    \file{xintgcd.sty}{\from{xint-calx.dtx}{xintgcd}}
    \file{xintfrac.sty}{\from{xint-calx.dtx}{xintfrac}}
    \file{xintseries.sty}{\from{xint-calx.dtx}{xintseries}}
    \file{xintcfrac.sty}{\from{xint-calx.dtx}{xintcfrac}}
    \file{xintexpr.sty}{\from{xint-calx.dtx}{xintexpr}}
    \file{calxcore.sty}{\from{xint-calx.dtx}{calxcore}}
    \file{calxint.sty}{\from{xint-calx.dtx}{calxint}}
    \file{calxfp.sty}{\from{xint-calx.dtx}{calxfp}}
    \file{calx.sty}{\from{xint-calx.dtx}{calx}}
    \file{calxlog.tex}{\from{xint-calx.dtx}{calxlog}}
    \file{calxlogdata.tex}{\from{xint-calx.dtx}{calxlogdata}}
    \file{calxtrig.tex}{\from{xint-calx.dtx}{calxtrig}}
    \file{calxtrigdata.tex}{\from{xint-calx.dtx}{calxtrigdata}}}
\endgroup
\fi % end of file extraction (from etex/latex/pdflatex/... run on xint-calx.dtx)
\ifnum\extractfiles=0 % no LaTeX, files now extracted. Stop.
  \MessageDeFin\expandafter\end
\fi
\ifnum\extractfiles=1 % direct run on xint-calx.dtx
  \expandafter\def\expandafter\MessageDeFin\expandafter{\MessageDeFin
\Msg{* Direct (*)latex run on xint-calx.dtx: repeat as necessary.            *^^J}%
\Msg{********************************************************************^^J}%
}%
\fi
\ifnum\extractfiles=3 %
  \newlinechar10
\errhelp{Extraction must be done via an engine with e-TeX extensions.^^J%
         Please try again, using etex rather.^^J%
         (and if with xetex, you must use -8bit option).}%
\errmessage{Extraction aborted (must be done with etex)}%
\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
%-----------------------------------------------------------------
%
\tracinglostchars3
\makeatletter
% counts used in particular in the samples from the documentation of the
% xintseries.sty package
\newcount\cnta
\newcount\cntb
\newcount\cntc

\ifdefined\doxintsource
    \chardef\NoSourceCode 0
\else
    \chardef\doxintsource 0
\fi
% \doxintsource=1 means producing only source code.
%                 It is set in xintsource.tex.  Prior to 1.4l it was
%                 set in the call with latexmk + \input syntax.
%
% \doxintsource=0 and \NoSourceCode=1 : include only user doc
% \doxintsource=0 and \NoSourceCode=0 : combine user doc and source code
% \doxintsource=1 and \NoSourceCode=1 : never happens but would mean to do
% nothing!

% default is to assume latex + dvipdfmx
\chardef\Withdvipdfmx 1

\RequirePackage{iftex}

\ifpdf  \chardef\Withdvipdfmx 0 \fi
\ifxetex\chardef\Withdvipdfmx 0 \fi

% 2019/09/10
% Get rid of HARASSMENT by KOMA-Script
% Must be located before \documentclass
\def\class@shoulddisablepackagewarning@list{tocloft.}

\ifnum\Withdvipdfmx=1
\def\pgfsysdriver{pgfsys-dvipdfm.def}
\documentclass [dvipdfm, dvipdfmx]{scrartcl}
\else
\documentclass {scrartcl}
\fi

%%% START OF CUSTOM doc.sty LOADING (May 21, 2022)
%
% For some legacy reason (because I started like this and it
% worked to my satisfaction) I had used scrdoc.cls all those
% years, without in fact needing most of its features.
%
% It loads ltxdoc class, from which again I need very little.  On
% testing May 20, 2022 the upcoming LaTeX 2022-06-01 I had some
% problems with ltxdoc not having suitable interface for rolling
% back to doc=V2.
%
% I did experiment with indices for xintsource.pdf from 2018 to
% 2019 but it made the build process significantly lengthier,
% created heavy-sized PDF, had various issues in my context
% (possibly the kind of issues doc V3 addresses about indexing
% non-macro things, hyperlinks,...), and these indices basically
% had not any real use as PDF search proves efficient enough,
% and the structures of local tables of contents makes for
% agreeable enough navigation via the input mark-up using
% sectioning commands.
%
% Thus it turns out I need very little of doc.sty, and almost
% nothing of ltxdoc.cls and scrdoc.cls.
%
% Let's load the doc=V2 version to avoid having to work around
% hypdoc loading interfering with my use of hyperref and as said
% above I don't need the hyperlinked cross-referencing as I have
% it via my own mark-up to a sufficiently good enough extent,
% and this holds for many many years. And I will not now change
% my mark-up.
\ifdefined\IfFormatAtLeastTF
  \IfFormatAtLeastTF{2022/06/01}%
  {%
    \IfFileExists{doc-2021-06-01.sty}%
     {\usepackage{doc}[=v2]}%
% Why on earth do I lose my time doing this?
     {\GenericError
          {(xint build doc)\@spaces}%
          {xint build error: %
      Your LaTeX installation seems to be broken, format is\MessageBreak
      2022-06-01 or later but `doc' package in its `v2' version\MessageBreak
      seems to not be available. \space Will try with `doc' but if\MessageBreak
      its `v3' is used there will be an option clash error\MessageBreak
      regarding hyperref.}%
          {}%
          {Please make sure `doc' package matches your LaTeX format.}%
      \usepackage{doc}%
     }%
  }%
  {\usepackage{doc}}%
\else
\usepackage{doc}
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MACROS OF doc.sty WILL BE HACKED (2022/06/06) FOR THE IMPLEMENTATION PART
%
% First we want to turn CodelineNo into a real LaTeX counter
% This will spare defining an extra counter for the hyperlinks with \hyperref
\begingroup\let\newcount\@gobble\@definecounter{CodelineNo}\endgroup
%%% Next line is not needed because \theCodelineNo already got that definition
%%% from doc-2021-06-01.sty, and \@definecounter does not overwrite it.
% \def\theCodelineNo{\reset@font\scriptsize\arabic{CodelineNo}}
% But as we will reset CodelineNo at each style file we need some unique id
\def\theHCodelineNo{\the\value{section}.\the\value{CodelineNo}}
% This is all for now.
% The further hacks are to be found after the \StopEventually (i.e. a few
% thousands lines down from here if you don't have access to the private
% sources, which is probably the case if you are not the author).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% As explained above I was formerly using scrdoc hence ltxdoc indirectly.
% Let's emulate here the little I appear to need from ltxdoc.cls and
% srcdoc.cls.
%
\AtBeginDocument{\MakeShortVerb{\|}}
\DeclareFontShape{OT1}{cmtt}{bx}{n}{<-> ssub * cmtt/m/n}{}
\DeclareFontFamily{OMS}{cmtt}{\skewchar\font 48}  % '60
\DeclareFontShape{OMS}{cmtt}{m}{n}{<-> ssub * cmsy/m/n}{}
\DeclareFontShape{OMS}{cmtt}{bx}{n}{<-> ssub * cmsy/b/n}{}
\DeclareFontShape{OT1}{cmss}{m}{it}{<->ssub*cmss/m/sl}{}
\ifnum\NoSourceCode=1
  \OnlyDescription
\fi
\CodelineNumbered
\EnableCrossrefs  % but this will be hacked
% \setcounter{StandardModuleDepth}{1} % we don't use this mechanism currently
\def\cmd#1{\cs{\expandafter\cmd@to@cs\string#1}}
\def\cmd@to@cs#1#2{\char\number`#2\relax}
% Here I am loading doc=v2 but formerly I was using ltxdoc via scrdoc
% which I dropped at release 1.4l (2022-05-29) and without much
% thinking I had kept this.
\DeclareRobustCommand\cs[1]{\texttt{\bslash#1}}
% As I may have the * active, or macro names with _ or ^, I should
% add \detokenize.  But see below for a redefinition anyhow.
%
% More urgent is that I am also using hyperref and this definition gives wrong
% bookmarks if \cs is used in section titles.  As I had very very few usags of
% \cs in the whole of xint.dtx, it took me a while to realize the problem
% here.  Turns out that doc=v3 by default loads hypdoc which includes this
% configuation for hyperref compatibility:
\AtBeginDocument{%
\pdfstringdefDisableCommands{\def\cs#1{\textbackslash\detokenize{#1}}}%
}%
% As I have not loaded hyperref yet I must delay it to AtBeginDocument.
% Late May, early June 2022 I added to my custom \verb automated detection
% of potential hyperlinks.  So I decided to replace \cs ltxdoc definition
% by suitable \verb usage.  It is not important to be efficient here,
% I can leave some \expandafter, in fact there are a handful of uses.
\DeclareRobustCommand\cs[1]{\expandafter\verb\expandafter~\bslash#1~}
% As my \verb does a verbatimizing \scantokens  I don't need to worry
% here about active characters but I need in the PDF string, hence
% the \detokenize above.
\providecommand\marg[1]{%
  {\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}}
\providecommand\oarg[1]{%
  {\ttfamily[}\meta{#1}{\ttfamily]}}
\providecommand\parg[1]{%
  {\ttfamily(}\meta{#1}{\ttfamily)}}
% \@addtoreset{CodelineNo}{part}% No need for this here
% \def\partname{File}% \partname is "fixed" somewhere further down anyhow
% No need for this, anyhow I don't build the indices (I did in 2018-2019 only).
% \gdef\codeline@wrindex#1{\if@filesw
%       \begingroup
%         \let\protect\noexpand
%         \immediate\write\@indexfile
%             {\string\indexentry{#1}%
%             {\filesep\number\c@CodelineNo}}%
%       \endgroup\fi}
% \let\filesep\@empty

% There is very little we seem to need from the scrdoc extras: page geometry
% is set by geometry package and a4paper option from xint.tex file.  So it
% seems I only need the hologo loading:
\usepackage{hologo}
\DeclareRobustCommand*{\eTeX}{\hologo{eTeX}}%
\DeclareRobustCommand*{\PDFTeX}{PDF\TeX{}}%
\DeclareRobustCommand*{\LuaTeX}{\hologo{LuaTeX}}%
\DeclareRobustCommand*{\XeTeX}{\hologo{XeTeX}}%
%
%%% end of ltxdoc+srcdoc emulation. See after \StopEventually for doc.sty hacks.

% Remove from sectioning commands insertion of marks, because we
% will do it ourself.
\usepackage{etoolbox}
% At scrartcl 2026/02/02 v3.49.2
% (LaTeX 2025-11-01, hyperref 2026-01-29 v7.01p the patch below has to be applied
% to \scr@sect not to \@sect.
\patchcmd{\scr@sect}%
    {\expandafter\csname#1mark\expandafter\endcsname\expandafter{\@currentheadentry}}%
    {}{}{\Error@CouldNotApplyFirstPatch@sect}
\patchcmd{\scr@sect}%
    {\expandafter\csname#1mark\expandafter\endcsname\expandafter{\@currentheadentry}}%
    {}{}{\Error@CouldNotApplySecondPatch@sect}

% This one now needed too, Jeudi 30 janvier 2020 
% \expandafter \ifx \csname #1mark\endcsname \@gobble \@mkboth {}{}\else
% \csname #1mark\expandafter \endcsname \expandafter {\@currentheadentry }\fi
% \@gobble est long donc simplement
\def\partmark #1{}%
  


\pagestyle{headings}

\iftutex % ensure lualatex or xelatex can be used to build the pdf
         % xinttools is not yet loaded hence the \AtBeginDocument
% 1.4p fixes a bug where formerly \lccode`~=\lccode`#1 was used
% which failed with ≠.  It also adds the ± which apparently was
% overlooked and the © (which however does not make it to public pdf).
\AtBeginDocument{%
  \xintForpair #1#2 in {(δ, \delta), (ξ, \xi), (π, \pi),
                        (≠, \neq), (±, \pm),
                        (α, \alpha), (τ, \tau), (λ, \lambda), (ν, \nu)}
  \do{\catcode`#1\active
      \begingroup\lccode`~=`#1
                 \lowercase{\endgroup\def~}{\ensuremath{#2}}%
     }%
  \catcode`©\active
  \begingroup\lccode`~=`©
             \lowercase{\endgroup\def~}{(c)}%

}%
\else
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
% (2016/03/02): \delta utilisé dans les commentaires de la division de xint.sty
% (2017/01/03): \xi pour doc \xintnewdummy
% (2019/03/31): \pi utilisé dans mes commentaires de xinttrig.sty
% (2019/04/24): \neq utilisé dans un commentaire de xintlog.sty
% (2025/08/30): \alpha, \tau, \lambda, \nu pour doc \xintnewdummy
% As we now (2025/08/30) load lgrmath (farther below), we have to delay this
% to at begin document.
% (2026/03/01): [1.4p] Problems with ± et © which did not exist earlier or which
%               I had overlooked but show since perhaps 2024 (≠ was already handled).
% For some reason which I have forgotten, this must be done at \begin{document}
\AtBeginDocument{%
  \DeclareUnicodeCharacter{03B4}{\ensuremath{\delta}}%  δ
  \DeclareUnicodeCharacter{03BE}{\ensuremath{\xi}}%     ξ
  \DeclareUnicodeCharacter{03C0}{\ensuremath{\pi}}%     π
  \DeclareUnicodeCharacter{2260}{\ensuremath{\neq}}%    ≠
  \DeclareUnicodeCharacter{03B1}{\ensuremath{\alpha}}%  α
  \DeclareUnicodeCharacter{03C4}{\ensuremath{\tau}}%    τ
  \DeclareUnicodeCharacter{03BB}{\ensuremath{\lambda}}% λ
  \DeclareUnicodeCharacter{03BD}{\ensuremath{\nu}}%     ν
  \DeclareUnicodeCharacter{B1}{\ensuremath{\pm}}%       ±
% This happens only in some code comments which do not make it
% to the public xint-all.pdf anyhow, so I do not waste effort on this.
% or use fall-back font.
  \DeclareUnicodeCharacter{A9}{(c)}%      ©
}
\fi

\usepackage{multicol}
\usepackage[head=3\baselineskip]{geometry}
\AtBeginDocument {\ttzfamily % package newtxtt is loaded in preamble
                  \newgeometry{textwidth=\dimexpr92\fontcharwd\font`X\relax,
                               vscale=0.75}}

\unless\ifnum\doxintsource=1
\usepackage{xintexpr}
% \usepackage{xintbinhex}% done automatically since 1.4n
\usepackage{xintgcd}
\usepackage{xintseries}
\usepackage{xintcfrac}
\usepackage{amsmath}% for \cfrac usage
\DeclareMathOperator{\sinc}{sinc}
\fi
\usepackage{pifont}% for \ding{73} (hollow star)

% needed also for build of xintsource.pdf
\usepackage{xinttools}

\usepackage{enumitem}
\usepackage{varioref}
\usepackage{xspace}
\usepackage[para]{footmisc}
%\usepackage{picture}% obsolèté par LaTeX 2025-11-01
\usepackage{graphicx}

\usepackage[english]{babel}
% 2022/06/05
% \usepackage{csquotes}
\def\myenquote#1{{\sffamily\textquotedblleft}#1{\sffamily\textquotedblright}}

% 2022/05/24, commenting out this at it appears to not be used anywhere now.
% \usepackage[autolanguage,np]{numprint}
% \AtBeginDocument{\npthousandsep{,\hskip .5pt plus .1pt minus .1pt}}

% But surprisingly it is via numprint that I was loading array package
% whose extended syntax for tabular preambles is required!
\usepackage{array}

\usepackage[dvipsnames,svgnames]{xcolor}
%%% DEFINITIONS OF COLORS USED IN DOCUMENT


% color for the \xintname, \xintexprname, etc macros
\definecolor{xintnamecolor}{RGB}{228,57,0}
\colorlet{XINTNAMECOLOR}{xintnamecolor}

% color for their analogs \xintnameimp, etc... in implementation part
\colorlet{xintnameimpcolor}{blue}
\colorlet{XINTNAMEIMPCOLOR}{xintnameimpcolor}

% colors for hyperref
\definecolor{xinturlcolor}{RGB}{38,128,192}
\colorlet{xintlinkcolor}{blue}





% colors for custom \verb and everbatim/everbatim* environments
%
% the commented-out legacy colors used in xint.pdf for many years up to
% xint 1.4j (2021/07/13) (I should retrieve since when exactly)
%
% \colorlet{verbcolor}{jfbrown}
% \colorlet{verbsoftwrapiconcolor}{blue}
% \colorlet{everbatimfgcolor}{Brown}
% \colorlet{everbatimbgcolor}{yellow!5}
% \colorlet{everbatimxfgcolor}{OrangeRed}
%
% https://contrast-ratio.com/#rgb%28165%2C100%2C10%29-on-white
% says the contrast ratio on white is 4.74 and I do see the contrast
% is less strong than
% for the DarkBlue/Beige and Maroon/White combinations seen below
% \colorlet{verbcolor}{jfbrown}
% I will simply use also Maroon
\colorlet{verbcolor}{Maroon}
\colorlet{digitsttcolor}{verbcolor}
\colorlet{verbsoftwrapiconcolor}{DarkBlue}
\colorlet{everbatimfgcolor}{DarkBlue}
%
% According to
% https://contrast-ratio.com/#rgb%2811%2C35%2C139%29-on-rgb%28245%2C244%2C220%29
% the DarkBlue on Beige
% gives a contrast-ratio of 11.58 which confirmed my intuition it is not bad
% "Passes AAA level for any size text and AA for user interface components and
% graphical objects"
%
% memo: with Apple ColorPicker it seems one needs to select "sRVB" (I guess
% "sRGB" in English) for values matching xcolor RGB input or the above html
% page rgb(R,G,B) input, also this did not work
% 100%, most probably due to the window transparency by default on my mac?
\colorlet{everbatimbgcolor}{Beige}
%
% https://contrast-ratio.com/#rgb%28128%2C31%2C19%29-on-white
% gives 9.89 contrast ratio which is a bit less but still AAA
\colorlet{everbatimxfgcolor}{Maroon}
%

% colors for margin notes
\colorlet{marginnotecolor}{PineGreen}
\colorlet{marginwarningcolor}{Red}

% colors for toc
\colorlet{tocstylesectioncolor}{cyan}
\colorlet{tocstylesectionimpcolor}{RoyalPurple}
\colorlet{tocstylebundlesectioncolor}{xintnamecolor}

% colors for macro code and comments
\colorlet{privatecommentcolor}{cyan}
\colorlet{macrocodecommentcolor}{gray}
\colorlet{macrocodenewmacrocolor}{verbcolor}
\colorlet{macrocodelinktouserdoccolor}{xintnamecolor}% and bold face
\colorlet{macrocodelinktosectioncolor}{DarkBlue}% and bold face
\colorlet{macrocodelinktocodelinecolor}{DarkBlue}
\colorlet{macrocodenoncscolor}{Green}

% colors for the implementation part and the modified macrocode macros
% are to be found after \StopEventually

\usepackage{eso-pic}% après xcolor sinon Option clash for package xcolor.

\ifnum\doxintsource=1
\else
% Dependency graph done using TikZ (manually)
  \usepackage{tikz}
  \usetikzlibrary{shapes,arrows.meta}
\fi

\usepackage{framed}
%\usepackage{colorframed}
% SNUGFRAMED
% ==========

\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}

% HYPERREF
% ========

\usepackage{hyperref}
% 2022/06/10 reduce clutter in console and log output, there are already
% enough messages telling we have to execute latex once more
\catcode`_ 11
\def\perhapshyperref[#1]{\ifcsname r@#1\endcsname \xint_afterfi{\hyperref[#1]}\fi}
\catcode`_ 8

\hypersetup{%
linktoc=all,%
breaklinks=true,%
colorlinks=true,%
urlcolor=xinturlcolor,%
linkcolor=xintlinkcolor,%
pdfauthor={Jean-Fran\c cois Burnol},%
pdftitle={The xintexpr and allied packages},%
pdfsubject={Arithmetic with TeX},%
pdfkeywords={Expansion, arithmetic, TeX},%
pdfstartview=FitH,%
pdfpagemode=UseNone,%
}

\usepackage{hypcap}

\ifnum\doxintsource=1
\hypersetup{pdftitle={The xintexpr and allied packages source code}}
\fi

\usepackage{bookmark}

% This is for having similarly named labels to get hyperlinks either to the
% user documentation or to the implementation part. From source mark-up with
% \csbxint, \csbXINT, \csb, or automated ones from |...| and the custom \verb
% However in the user manual I have so far (2022/06/11) used manually typed-in
% \label's in contrast to the almost exclusively automated ones of the implementation
% part.  So for time being I keep an empty prefix here in place of something
% reasonable such as usr-.
\let\xintdoclabelprefix\empty
\def\xintimplabelprefix{src-}

% used by \csbxint etc...
\let\xintlabelprefix\xintdoclabelprefix

% FONTS
% =====

\usepackage[zerostyle=d,straightquotes,scaled=0.95]{newtxtt}
\usepackage{newtxmath}
\input ts1newtxttz.fd

% Update at 1.4p.
% In ts1newtxttz.fd 2024/03/03 reference to newtcxttz are made
% presumably tc = text companion but the fonts do not exist. I
% need this for a few characters © ("A9), ≠ (U2260) and ± ("B1).
% Formerly I needed it for \textasciigrave, but the straightquotes
% option solved that.  The problematic characters are handled
% at begin document, see above, at the \iftutex conditional.






  \renewcommand\familydefault\ttdefault
  \usepackage[noendash]{mathastext}% pas de endash dans newtxtt

% A (somewhat surprising a priori, at least to me) effect of 
% \DeclareFontEncoding{LGR}{}{} (which loads lgrenc.dfu) is that
% it redeclares all UTF-8 Greek ! So for example ξ will expand to \textxi.
% So we delayed our own \DeclareUnicodeCharacter's to \begin{document}
  \usepackage[style=up,font=cmss]{lgrmath}

% 2024/01/15: upstream update by Michael Sharpe to newtxtt,
% in particular a shorter "extra space" for the nomono font
% I thus try again with \nonfrenchspacing.
% \frenchspacing
% sans-serif in footnotes, TOC, titles, etc...
\renewcommand\familydefault\sfdefault

% TABLES OF CONTENTS
% ==================

% Attention @ is letter
\usepackage{tocloft}
\usepackage{etoc}
\let\orig@etoctoclineleaders\etoctoclineleaders

\def\gobbletodot #1.{}

\newif\ifinmanualmaintoc
\ifnum\doxintsource=0
    \inmanualmaintoctrue
\fi
\def\tocstylesectionbracedcolor{{tocstylesectioncolor}}
\def\tocstyleMARGEPAGENO {1.5em}% changera pour la partie implémentation


\def\tocstylesectionVSKIP{\vskip\bigskipamount}
\etocsetstyle{section}{}
     {\normalfont}
     {\etociffirst{}{\tocstylesectionVSKIP}%
         \rightskip    \tocstyleMARGEPAGENO\relax
         \parfillskip -\tocstyleMARGEPAGENO\relax
      \bfseries
         \leftskip \leftmarginii
      \noindent\llap            %  \llap
      {\makebox[\leftmarginii][l]%  et \leftmargini le 12/10/2014
               {\expandafter\textcolor\tocstylesectionbracedcolor{\etocnumber}}}%
      \strut\etocname
      \mdseries\nobreak\leaders\etoctoclineleaders\hfill\nobreak\strut
                             \makebox[\tocstyleMARGEPAGENO][r]{\etocpage}\par
      \let\ETOCsectionnumber\etocthenumber
      }%
     {}%

\newdimen\tocstyleLEFTMARGIN
\AtBeginDocument{\tocstyleLEFTMARGIN \dimexpr 5\fontcharwd\font`X\relax}
\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  \tocstyleLEFTMARGIN % 12 octobre 2014
     \ifinmanualmaintoc
        \rightskip \tocstyleMARGEPAGENO
     \else
        \rightskip \tocstyleMARGEPAGENO plus 2em minus 1em
     \fi
     \parfillskip -\tocstyleMARGEPAGENO\relax
    }
    {}
    {\noindent
     \etocifnumbered{\llap{\makebox[\tocstyleLEFTMARGIN][l]{\ttzfamily\bfseries\etoclink
             {\ifinmanualmaintoc\expandafter\textcolor\tocstylesectionbracedcolor
               {\normalfont\bfseries\ETOCsectionnumber}\fi
              .\expandafter\gobbletodot\etocthenumber}}}}{\kern-\tocstyleLEFTMARGIN}%
     \strut\etocname\nobreak
     \unless\ifinmanualmaintoc\leaders\etoctoclineleaders\fi
     \hfill\nobreak
     \strut\makebox[\tocstyleMARGEPAGENO][r]{\small\etocpage}\endgraf }
    {\end{multicols}\endgroup
    }%

\etocsetstyle{subsubsection}
    {\begingroup\normalfont\small
     \leftskip\dimexpr\leftmargini+1em\relax
    }
    {}
    {\noindent
     \llap{\makebox[\dimexpr\leftmargini+1em\relax][l]%
           {\ttzfamily\bfseries\etoclink
                    {\tocstylesubsubsectionHOOK.\expandafter\gobbletodot\etocthenumber}}}%
     \strut\etocname\nobreak
     \leaders\etoctoclineleaders
     \hfill\nobreak
     \strut\makebox[\tocstyleMARGEPAGENO][r]{\small\etocpage}\endgraf
    }
    {\endgroup }%

% 2018/02/28
% quick hack to get style I want in "User defined functions" section of manual
\let\tocstylesubsubsectionHOOK\empty
\etocsetlevel{xinttable}{6}% formerly "table" was used, but forbidden since
                           % etoc 1.2 of 2023/10/01

\addtocontents{toc}{\protect\hypersetup{hidelinks}}

% =====================
% MISCELLANEOUS MARK-UP
% =====================


\def\digitstt #1{\begingroup\color{digitsttcolor}#1\endgroup}
\let\dtt\digitstt

% \fexpan 22 octobre 2013
\newcommand\fexpan {\perhapshyperref[ssec:expansions]{\textit{f}-expan}}
% \xexpan ajouté 28 mai 2022
\newcommand\xexpan {\perhapshyperref[ssec:expansions]{\textit{x}-expan}}
% Septembre 2015
% Address updated to github repo's one, May 2018
% They did s/master/main/ already a few years back, May 2022
\def\liiibigint
   {\href{https://github.com/latex3/latex3/tree/main/l3trial/l3bigint}{l3bigint}}

% May 2022
\def\liiistrformat
%   {\href{https://github.com/latex3/latex3/tree/main/l3experimental/l3str}{l3str}}
   {\href{https://ctan.org/pkg/l3experimental}{l3str-format}}
%\def\liiistrformatnew
%   {\href{https://github.com/latex3/latex3/tree/main/l3trial/l3str-format-new}{l3str-format-new}}


% Margin Notes
% ============

% Nothing here can be used in vertical mode directly.

\def\MyMarginNote {\@ifnextchar[\@MyMarginNote{\@MyMarginNote[]}}%
\let\inmarg\MyMarginNote
% \smash needs \hbox here since LaTeX 2018/12/01
%  https://github.com/latex3/latex2e/issues/108
\def\@MyMarginNote [#1]#2{\@bsphack
    \vadjust{\vskip-\dp\strutbox
             \hbox{\smash{\hbox to 0pt
                       {\color{marginnotecolor}\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
             \hbox{\smash{\hbox to 0pt
                       {\color{marginnotecolor}%\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\ }}
\newcommand\cautionsign[1][10pt]{%
    \resizebox{!}{#1}{\ooalign{$\mathcolor{red}{\triangle}$\cr
    \kern2.07pt{\raise0.75pt\hbox{\resizebox{!}{3pt}{!}}}}}%
}
\def\etype #1{\@bsphack
    \vadjust{\vskip-\dp\strutbox
             \hbox{\smash{\hbox to 0pt {\hss\color{marginnotecolor}%
                    \itshape \xintListWithSep{\,}{#1}\ $\star$\quad }}}%
             \vskip\dp\strutbox
            }\strut\@esphack}
\def\xtype #1{\@bsphack
    \vadjust{\vskip-\dp\strutbox
             \hbox{\smash{\hbox to 0pt {\hss\color{marginnotecolor}%
                    \itshape \xintListWithSep{\,}{#1}\ \ding{73}\quad }}}%
             \vskip\dp\strutbox }\strut\@esphack}
\def\ntype #1{\@bsphack
    \vadjust{\vskip-\dp\strutbox
             \hbox{\smash{\hbox to 0pt {\hss\color{marginnotecolor}%
                    \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
             \hbox{\smash{\hbox to 0pt {\hss\color{marginnotecolor}%
                        \normalfont\small\bfseries
                        \hsize 1.7cm\rightskip.7cm minus.5cm
                        \vtop{\noindent NEW WITH #1}\ }}}%
             \vskip\dp\strutbox }\strut\@esphack}
%
\def\CHANGED #1{\@bsphack
    \vadjust{\vskip-\dp\strutbox
             \hbox{\smash{\hbox to 0pt {\hss\color{marginwarningcolor}%
                        \normalfont\small\bfseries
                        \hsize 1.7cm\rightskip.7cm minus.5cm
                        \vtop{\noindent CHANGED AT #1!}\ }}}%
             \vskip\dp\strutbox }\strut\@esphack}

\def\DNU#1{\@bsphack
    \vadjust{\vskip-\dp\strutbox
             \hbox{\smash{\hbox to 0pt {\hss\color{marginwarningcolor}%
                        \normalfont\small\bfseries
                        \hsize 1.7cm\rightskip.7cm minus.5cm
                        \vtop{\noindent DO NOT USE! #1}\ }}}%
             \vskip\dp\strutbox }\strut\@esphack}

\def\UNSTABLE#1{\@bsphack
    \vadjust{\vskip-\dp\strutbox
             \hbox{\smash{\hbox to 0pt {\hss\color{marginwarningcolor}%
                        \normalfont\small\bfseries
                        \hsize 1.7cm\rightskip.7cm minus.5cm
                        \vtop{\noindent UNSTABLE! #1}\ }}}%
             \vskip\dp\strutbox }\strut\@esphack}

\def\unstable#1{\@bsphack
    \vadjust{\vskip-\dp\strutbox
             \hbox{\smash{\hbox to 0pt {\hss\color{marginwarningcolor}%
                        \normalfont\small\bfseries
                        \hsize 1.7cm\rightskip.7cm minus.5cm
                        \vtop{\noindent Unstable? #1}\ }}}%
             \vskip\dp\strutbox }\strut\@esphack}

\def\DEPRECATED #1{\@bsphack
    \vadjust{\vskip-\dp\strutbox
             \hbox{\smash{\hbox to 0pt {\hss\color{marginnotecolor}%
                        \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
             \hbox{\smash{\hbox to 0pt {\hss\color{marginwarningcolor}%
                        \normalfont\small\bfseries
                        \hsize 1.7cm\rightskip.7cm 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
             \hbox{\smash{\hbox to 0pt {\hss\color{marginnotecolor}%
                        \normalfont\small\bfseries
                        \hsize 1.7cm\rightskip.7cm minus.5cm
                        \vtop{\noindent NEW WITH #1}\ 
              \kern\dimexpr\FrameSep+\FrameRule\relax}}}%
             \vskip\dp\strutbox }\strut\@esphack}


% \centeredline: OUR OWN LITTLE MACRO FOR CENTERING LINES
% =======================================================

% 7 mars 2013
% Note (2020): now a package
\usepackage{centeredline}

% \leftedline
% ===========

% 12 octobre 2014

% Note (2020): somewhat obsoleted for many years by my usage of
% everbatim and everbatim* environments.

\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@ }

% verbatim macros and environments
% ================================
%
% June 2013, then October 2014.
% -----------------------------
%
\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



% \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\verbcolorcmd{\color{verbcolor}}
\def\verbsoftwrapiconcolorcmd{\color{verbsoftwrapiconcolor}}

\def\restoreMicroFont {\def\MicroFont {\ttfamily\makestarlowast
    \ifinlefted\else\verbcolorcmd\fi
}}
\restoreMicroFont

\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 (\ttfamily), color,
                      % will make * active via \makestarlowast
           \catcode 32 10 \endlinechar 32 % allows to fetch across line breaks
           \frenchspacing % since 2024/01/15 not 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{%
% 2022/06/04
% automated hyperlink detection
% - \detokenize needed due to * \active from \makestarlowast in \MicroFont
% - gobbling first char rather than checking if it is backslash
%   (and there is an \@empty first so gobbling two tokens)
% mark-up using \csbxint is better way as it allow hyphenation after xint
% Usage of \xintlabelprefix to modify behaviour in implementation part.
% This will NOT WORK if the catcodes were already frozen...
   \ifcsname r@\xintlabelprefix\detokenize\expandafter{\xint_gobble_ii##1}\endcsname
       \hyperref[\xintlabelprefix\detokenize\expandafter{\xint_gobble_ii##1}]{##1}%
       \egroup
   \else
% this will add \discretionary's for wrapping at end of line
            \@vobeyspaces\everyeof{\relax}\endlinechar\m@ne
            \expandafter\@@jfverb_a\scantokens\expandafter{##1}%
   \fi}%
% 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\SoftWrapIconA}{\copy\SoftWrapIconB}{}%
        #1\expandafter\@@jfverb_b\fi
}


\DeclareFontFamily{U}{MdSymbolC}{}
\DeclareFontShape {U}{MdSymbolC}{m}{n}{<-> MdSymbolC-Regular}{}
\newbox\SoftWrapIconA
\newbox\SoftWrapIconB

\usepackage{accsupp}
\def\SetSoftWrapIcons{%
    \setbox\SoftWrapIconA\hb@xt@\z@
    {\kern-1ex
     \smash{\lower5pt
         \hbox{%
\BeginAccSupp{ActualText={}}%
         \verbsoftwrapiconcolorcmd\usefont{U}{MdSymbolC}{m}{n}\char 154
\EndAccSupp{}%
         }%
     }%
     \hss}%
    \setbox\SoftWrapIconB\hb@xt@\z@
    {\hss
     \smash{%\lower1.5pt
         \hbox{%
\BeginAccSupp{ActualText={}}%
         \verbsoftwrapiconcolorcmd\usefont{U}{MdSymbolC}{m}{n}\char 48
\EndAccSupp{}%
         }%
     }%
     \kern.5ex}%
   }

\AtBeginDocument {\SetSoftWrapIcons }% ok car ttzfamily déjà fait

\catcode`_ 8

% everbatim environment
% =====================

\def\restoreMacroFont {\def\MacroFont {\ttfamily
    \ifinlefted\else\color{everbatimfgcolor}\fi
}}
\restoreMacroFont
% 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...

% 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)

\catcode`_ 11

\def\everbatim {\s@everbatim\@everbatim}
\@namedef{everbatim*}{\s@everbatim\@everbatimx}

% Note: one can not use everbatim inside itself or everbatim* inside itself
\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
       \@topsepadd \z@skip
       \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
}
% 27 mai 2022, plus de \small
\def\everbatimtop {\MacroFont }%
\let\everbatimhook\empty
\def\everbatimeverypar{\strut
                   {\color{everbatimbgcolor}\vrule\@width\linewidth }%
                   \kern-\linewidth
                   \kern\everbatimindent }
\def\everbatimindent {\z@}% voir plus loin atbegindocument

\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 #1X#2\end{everbatimY}]%
  {#2\end{everbatim*}%
% No group here: this allows executed code to make macro
% definitions which may reused in later uses of everbatim.
% refactored 2022/01/11, rather than passing \newlinechar value
% as was done formerly via everbatim* (see above) and fetching it here as #1 
% it is thus assumed executed contents do not terminate a scope
     \edef\everbatimrestorenewlinechar{\newlinechar\the\newlinechar\relax}%
     \newlinechar 13
% refactored 2022/01/11 to fix a \parskip issue
% attention, \parskip thus set to zero for execution of contents
% reason: avoid extra space if everbatim* is in an \item of a list
% between verbatim and output of execution, if it starts a paragraph
% a \vskip-\parskip approach (cf former \everbatimundoparskip)
% would be no good in case contents create a display
     \edef\everbatimrestoreparskip{\parskip\the\parskip\relax}%
     \parskip\z@skip
% execution of the contents (expected to be LaTeX code...)
     \everbatimxprehook
     \scantokens {#2}%
     \everbatimrestorenewlinechar
     \everbatimrestoreparskip
     \everbatimxposthook
% input after \end{everbatim*} on same line in source is allowed
}%
% L'espace venant du endofline final mis par \scantokens sera inhibé si #2 se
% termine par un % ou un \x, etc...

\let\everbatimbottom\empty

\def\endeverbatim{\if@newlist \leavevmode\fi\endtrivlist}
\@namedef{endeverbatim*}{\endeverbatim}

% There is an issue with how to inhibit the \parskip if execution
% of contents generate a paragraph.  Because the design is aimed at
% keeping output close to verbatim input.
% Even in a document with zero \parskip overall, the \parskip will possibly
% be reset to some annoying high value e.g. if we are in an \item of a list
% environment.
% In this documentation, many usage of everbatim* are indeed inside such
% \item's.  The former (2020) approach was to do:
% \@namedef{endeverbatim*}{\endeverbatim\aftergroup\everbatimundoparskip}
% \def\everbatimundoparskip{\vbox{}\kern-\baselineskip\kern-\parskip\leavevmode}
% but it had its problems if executed contents start a display, with
% not enough vertical whitespace then
% Also if source had two everbatim* environments one after the other,
% the first one not producing any ouput, this caused overlap.
% The new approach (Feb 2022) is much simpler and avoids these problems.


% These definitions are provisory and get overwritten below in order
% to avoid color stack overflow problems with latex + dvipdfmx, and xelatex
\def\everbatimxprehook {\colorlet{everbsavedcolor}{.}%
                        \color{everbatimxfgcolor}}%
\def\everbatimxposthook{\color{everbsavedcolor}}
% actual definitions:
{\sbox0{\color{everbatimxfgcolor}\xdef\@tempa{\current@color}}}
\ifpdf
 \ifluatex
   \edef\everbatimxprehook
       {\pdfextension colorstack\noexpand\@pdfcolorstack push{\@tempa}\relax}
   \def\everbatimxposthook
       {\pdfextension colorstack\@pdfcolorstack pop\relax}
 \else
   \edef\everbatimxprehook
      {\pdfcolorstack\noexpand\@pdfcolorstack push{\@tempa}\relax}
   \def\everbatimxposthook{\pdfcolorstack\@pdfcolorstack pop\relax}
 \fi
\else
% Le 24 juin 2021 je vérifie que ceci est encore nécessaire avex xelatex
% (sinon color leak de OrangeRed à partir de la page 97 dans la doc)
% et aussi pour dvipdfmx (sinon color stack overflow au moment de la page 98
% lors du passage par dvipdfmx)
  \ifxetex
   \edef\everbatimxprehook{\special{color push \@tempa}}
   \def\everbatimxposthook{\special{color pop}}
  \else
    \ifnum\Withdvipdfmx=1
     \edef\everbatimxprehook{\special{color push \@tempa}}
     \def\everbatimxposthook{\special{color pop}}
    \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.
% Le "" redonne à { et } leurs catcodes normaux mais attention c'est
% alors à utiliser avec un terminateur ;! pour la partie concernée
\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


% \printnumber
% ============

\catcode`_ 11
\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 &#1\xint_dothis\xint_gobble_i\fi
                    \if ,#1\xint_dothis {\discretionary{\rlap,}{}{,}}\fi
                    \xint_orthat{\discretionary
                           {\copy\SoftWrapIconA}%
                           {\copy\SoftWrapIconB}%
                           {}#1}\allowsplits_a }%

\def\printnumber #1{\expandafter\allowsplits_a \romannumeral-`0#1&}%
\hyphenpenalty \z@

\catcode`& 4
\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...
% ===========================

% The underscore and caret things are for 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}}}}
% For some legacy reasons rather than doing:
% \pdfstringdefDisableCommands{%
%    \def\csa#1{\textbackslash\detokenize{#1}}%
%    \def\csan#1{\detokenize{#1}}%
% }%
% I defined years ago variants for usage within section titles.  These
% variants will get redefined in implementation section to automatically
% insert \label's and use \csa and \csan.  Here in user manual, they simply
% use \csa or \csan, but are careful to do \texorpdfstring.
\newcommand\csh[1]
    {\texorpdfstring{\csa{#1}}{\textbackslash\detokenize{#1}}}
% This one is actually never used inside the user manual, only encountered
% in the implementation part.
\newcommand\cshn[1]
    {\texorpdfstring{\csan{#1}}{\detokenize{#1}}}
% Let's preserve these meanings for when I will want to use them in sections
% of the implementation part but not insert labels.
\let\cshnolabel\csh
\let\cshnnolabel\cshn
% 2022/06/10
% If producing xint-all.pdf add hyperlinks from user documentation
% to source code.  Should have I used some superscript? Less trouble
% and less work intensive for TeX I guess than the centered align.
% \def\myalign@vbox#1{\leavevmode\vbox{\baselineskip\z@skip \lineskip.75ex%
%                    \ialign{\hfil##\hfil\crcr#1\crcr}}}
% %%\def\oalign#1{\leavevmode\vtop{\baselineskip\z@skip \lineskip.25ex%
% %% \ialign{##\crcr#1\crcr}}}
% \myalign@vbox{\hyperref[\xintimplabelprefix\detokenize{#1}]{\usebox\codelinkbox}\cr
%               \csa{#1}}%
% 2026/03/01
% Less vertical separation (0.35ex not 0.75ex)
\def\myalign@vbox#1{%\leavevmode
    \vbox{% \@tempboxa is not used by \smash... and I hope \hyperref too
    \kern.15ex % added 2026/03/01
    \baselineskip\z@skip\lineskip.35ex\relax
    \sbox\@tempboxa{\csa{#1}}%
    \hbox to\wd\@tempboxa{\hss
                 \hyperref[\xintimplabelprefix\detokenize{#1}]{\usebox\codelinkbox}%
                \hss}%
    \box\@tempboxa }%
}%

\newsavebox\codelinkbox
% \familydefault already configured
% trying to add some \vphantom{X} has no impact it seems on the 
% size of the clickable area (tested with Skim and Preview on mac os)
% so using \small not \footnotesize
\sbox\codelinkbox{\color{macrocodelinktosectioncolor}%
                    \normalfont\small\itshape code}
% For 1.4p I rmove the \smash
% \def\cswithsourcelink#1{\smash{\myalign@vbox{#1}}}%
\def\cswithsourcelink#1{\myalign@vbox{#1}}%
% the references should exist on second LaTeX pass
% and we don't want complications in tables of contents
\def\csperhapswithlink#1{\ifx\thepage\relax\csa{#1}\else
        \ifcsname r@\xintimplabelprefix\detokenize{#1}\endcsname
          \cswithsourcelink{#1}%
        \else
          \csa{#1}%
        \fi\fi
}
\ifnum\doxintsource=0 \ifnum\NoSourceCode=0
  \renewcommand\csh[1]
     {\texorpdfstring
       {\csperhapswithlink{#1}}
       {\textbackslash\detokenize{#1}}%
      }
  % \renewcommand\cshn[1]
  % but it is used nowhere in user manual
\fi\fi

% The "b" is there originally for "blue" in fact, from the hyperlink.
\DeclareRobustCommand\csb [1]
        {\perhapshyperref[\xintlabelprefix\detokenize{#1}]%
          {{\char92 \endlinechar-1
              \makestarlowast \catcode`_ 12 \catcode`^ 12
                 \scantokens\expandafter{\detokenize{#1}}}}}
\DeclareRobustCommand\csbn[1]
        {\perhapshyperref[\xintlabelprefix\detokenize{#1}]%
          {{\endlinechar-1
              \makestarlowast \catcode`_ 12 \catcode`^ 12
                 \scantokens\expandafter{\detokenize{#1}}}}}
\DeclareRobustCommand\csbxint[1]
        {\perhapshyperref[\xintlabelprefix\detokenize{xint#1}]%
          {{\char92\mbox{xint}\-\endlinechar-1
              \makestarlowast \catcode`_ 12 \catcode`^ 12
                 \scantokens\expandafter{\detokenize{#1}}}}}
\DeclareRobustCommand\csbXINT[1]
        {\perhapshyperref[\xintlabelprefix\detokenize{XINT#1}]%
          {{\char92\mbox{XINT}\-\endlinechar-1
              \makestarlowast \catcode`_ 12 \catcode`^ 12
                 \scantokens\expandafter{\detokenize{#1}}}}}

% 2022/06/08, I finally add this
% although this is is not immediately useful as I have interiorized for years
% not to use \csbxint et al. in section titles...
\pdfstringdefDisableCommands{%
    \let\csb\cs % \cs already in DisableCommands, I hope its redefinition is done
                % first, well yes one has to chase \ltx@GlobalAppendToMacro
                % all the way to ltxcmds...
    \let\csbn\detokenize
    \def\csbxint#1{\textbackslash xint\detokenize{#1}}%
    \def\csbXINT#1{\textbackslash XINT\detokenize{#1}}%
}%

% \func, \funcdesc, \keyword, \keyworddesc, \prec, \precdesc, \oper, \operdesc
% ============================================================================

\NewDocumentCommand{\func}{m}{\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[\texttt{#1}]\hypertarget{\detokenize{prec-#1}}{}\leavevmode}%

%\let\var\relax % défini par koma-script-source-doc que scrdoc
                % utilise avec LaTeX 2022/06/01
                % mais finalement je n'utilise plus scrdoc/ltxdoc
                % mais doc directement.
\newcommand\var[1]{\hyperlink{\detokenize{var-#1}}{#1}}
\newcommand\vardesc[1]{\item[#1]\hypertarget{\detokenize{var-#1}}{}}%

\newcommand\oper[1]{\hyperlink{\detokenize{oper-#1}}{#1}}
\newcommand\operdesc[1]{\item[\texttt{#1}]\hypertarget{\detokenize{oper-#1}}{}}%


% \xintname, \xintnameimp etc...
% ==============================



\xintForpair #1#2 in
{(kernel,kernel),
 (tools,tools),
 (core,core),(,xint),(binhex,binhex),(gcd,gcd),%
 (frac,frac),(series,series),(cfrac,cfrac),(expr,expr),%
 (trig, trig), (log, log)}
\do
{%
 \expandafter\def\csname xint#1name\endcsname
   {\texorpdfstring
                  {\perhapshyperref[sec:#2]%
                     {{\color{xintnamecolor}\MakeNameUp
                                                  {\mbox{xint}\-#1}
                                                  {xint#1}%
                             }%
                     }%
                  }%
                  {xint#1}%
    \xspace }%
 \expandafter\def\csname xint#1nameimp\endcsname
   {\texorpdfstring
                  {\perhapshyperref[sec:#2imp]%
                    {{\color{xintnameimpcolor}\MakeNameUp
                                                    {\mbox{xint}\-#1}
                                                    {xint#1}%
                           }%
                    }%
                  }%
                  {xint#1}%
    \xspace }%
}%

\xintForpair #1#2 in
{(,), (core,core), (int,int), (fp,fp),
 (trig,trig), (trigdata, trigdata),
 (log,log), (logdata, logdata)}
\do
{%
 \expandafter\def\csname calx#1name\endcsname
   {\texorpdfstring
                  {\perhapshyperref[sec:calx#2]%
                     {{\color{xintnamecolor}\MakeNameUp
                                                  {\mbox{calx}\-#1}
                                                  {calx#1}%
                             }%
                     }%
                  }%
                  {calx#1}%
    \xspace }%
 \expandafter\def\csname calx#1nameimp\endcsname
   {\texorpdfstring
                  {\perhapshyperref[sec:calx#2imp]%
                    {{\color{xintnameimpcolor}\MakeNameUp
                                                    {\mbox{calx}\-#1}
                                                    {calx#1}%
                           }%
                    }%
                  }%
                  {calx#1}%
    \xspace }%
}%

\def\xintbundlename
   {\texorpdfstring
                  {\perhapshyperref[sec:bundle]%
                     {{\color{xintnamecolor}\MakeNameUp
                                                  {\mbox{xint} bundle}
                                                  {xintbundle}%
                             }%
                     }%
                  }%
                  {xint bundle}%
    \xspace }%

\def\calxbundlename
   {\texorpdfstring
                  {\perhapshyperref[sec:bundle]%
                     {{\color{xintnamecolor}\MakeNameUp
                                                  {\mbox{calx} bundle}
                                                  {calxbundle}%
                             }%
                     }%
                  }%
                  {calx bundle}%
    \xspace }%


\gdef\DOCxintfrontpage
   {\perhapshyperref[frontpage]{{\color{xintnamecolor}TOC}}}%
\ifnum\doxintsource=1
% xintsource.pdf
   \gdef\DOCxintfrontpage
        {\perhapshyperref[frontpage]{{\color{xintnameimpcolor}TOC}}}%
    \gdef\DOCcalxfrontpage
        {\perhapshyperref[frontpage]{{\color{xintnameimpcolor}TOC}}}%
\else
\ifnum\NoSourceCode=0
% xint-all.pdf
% Not using \hypersetup with linkcolor because a few pages are with 
% a TOC à cheval on two pages, and my eTOCs are configured to do
% \hypersetup{hidelinks}
 \protected\def\DOCxintfrontpage
   {\smash{\vbox{\hbox{\perhapshyperref[partiii]{{\color{xintnameimpcolor}TOC}}}%
          \kern1ex
          \hbox{\perhapshyperref[frontpage]{{\color{xintnamecolor}TOC}}}}}}%
\fi\fi

\protected\def\MakeNameUp#1#2{%
  \ifcsname #2nameUp\endcsname
    \expandafter\@firstoftwo\else
    \expandafter\@secondoftwo
  \fi
% \ifinheader 2020/01/30
  {\ifinheader\fbox{\textup{#1}}\else#1\fi}%
  {#1}%
}
\newif\ifinheader
% doit être protégé
\protected\def\inheadertrue{\let\ifinheader\iftrue}

% \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}%
}
% It seems I need this for a bookmark in xint-all.pdf
% reaching the top of the page where Part III starts
% 2022/06/10
\newcommand\RaisedTarget[2][6]{%
\vspace*{-#1\baselineskip}%
\hypertarget{#2}{}%
\vspace*{#1\baselineskip}%
}

% 31 janvier 2020
% 2022/06/10 no need for \texorpdfstring here

 \def\DOCxintexprintro
   {\perhapshyperref[part:1]{{\color{xintnamecolor}%
                                    \MakeNameUp{Start here}%
                                               {Start here}%
                              }%
                      }%
    }%

 \def\DOCxintexprmacros
   {\perhapshyperref[sec:oldxintexpr]{{\color{xintnamecolor}%
                                      \MakeNameUp{xintexpr (old doc)}%
                                                 {xintexpr (old doc)}%
                                }%
                               }%
    }%

 \def\DOCexamples
   {\perhapshyperref[sec:examples]{{\color{xintnamecolor}%
                                   \MakeNameUp{Examples}{Examples}%
                             }%
                            }%
    }%

% 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
% Update Friday, June 25 2021
% I finally take the time to go to the root of this: the culprit is everbatim
% when its output crosses pagebreaks, but the same of course happens with
% verbatim.
% I opened ticket https://github.com/latex3/latex2e/issues/600
\def\xintRunningHeader{{\inheadertrue\catcode`,12\relax
          \DOCxintfrontpage,
          \DOCxintexprintro,
          \xintexprname,
          \DOCxintexprmacros,
          \calxtrigname,
          \calxlogname,
          \xinttoolsname,
          \DOCexamples,
          \xintbundlename}}

% MEMO: the \markboth must be done after \begin{document}.  Else it appears to
%       work, but actually the hyperlinks are missing.  This is due to
%       \perhapshyperref (see above) needing the .aux file to have been read to
%       find the label.
% \markboth{\makebox[0pt]{\xintRunningHeader}}{\makebox[0pt]{\xintRunningHeader}}

% 18 mai 2019, turned into an environment 27 mai 2022
\newenvironment{TeXnote}{\par\small\medskip\noindent\textbf{\TeX-hackers note:
  }}{\par\medskip}

\DeclareRobustCommand\ctanpackage[1]{\href{https://ctan.org/pkg/#1}{#1}}
\etocsetlevel{toctobookmark}{6}

\makeatother
% begin{document}
% ===============
% \ttzfamily done at begin document

\begin{document}\thispagestyle{empty}
\markboth{\makebox[0pt]{\xintRunningHeader}}{\makebox[0pt]{\xintRunningHeader}}

\pdfbookmark[1]{Title page}{TOP}
\def\partname{Part}
\addto\captionsenglish{\def\partname{Part}}


\ifnum\doxintsource=1
\noindent\begin{minipage}[t][8\baselineskip][c]{\linewidth}
 \normalfont\Huge
 \centering
 The \calxnameimp, \xintexprnameimp and allied packages source code\par
\else
 \begingroup
 \normalfont\Huge
 \centering
 The \calxname, \xintexprname and allied packages\par
 \endgroup
\fi
\RaisedLabel{frontpage}

\normalsize\ttzfamily
{\centering
  \textsc{Jean-Fran\c cois Burnol}\par
  \footnotesize
  jfbu (at) free (dot) fr\par
  Package version: \xintbndlversion\ (\xintbndldate).\par
  {From source file \texttt{xint-calx.dtx}. \xintdtxtimestamp.}\par
}

\ifnum\doxintsource=1
\end{minipage}
\else
\medskip
\fi
% Skips safely.
\ifnum\doxintsource=1
\catcode`+ 0 \catcode0 9 % n'importe quoi sauf 15 (car ^^@)
\catcode`\\ 12
+expandafter+iffalse+fi
\fi
%
\makeatletter


\etocsetlevel{xinttable}{2}%  subsection

\let\orig@etoctoclineleaders\etoctoclineleaders
\def\etoctoclineleaders
    {\hbox{\normalfont\normalsize\hbox to 1ex {\hss.\hss}}}
\def\etocbelowtocskip{\z@skip}
\def\etocinnertopsep{\z@skip}

\etocsettocstyle{}{}
\etocsettagdepth {part1A}{subsection}% style de subsection défini dans preamble
\etocsettagdepth {part1B}{section}% style de section aussi
\etocsettagdepth {macros}{none}
\etocsettagdepth {implementation}{none}

\etocsettocdepth{subsection}
%% Legacy etoc style for part, with an improvement to get "Part"
%% hyperlinked
%% Also some hack to let the TOC of xint-all.pdf fit on one page
%% `part': (modified 2026/11/04 pour que ça s'applique aussi à xint-manual.pdf)
\etocsetstyle{part}
  {\ifnum\doxintsource=0 
     \def\etocabovetocskip{\z@skip}%
     \def\etocsepminusone{\bigskipamount}%
     \def\etocsepzero{\medskipamount}%
     \def\tocstylesectionVSKIP{\vskip\smallskipamount}%
   \fi
   \addpenalty\@M\etocskipfirstprefix}
  {\addpenalty\@secpenalty}
  {%
   \begingroup
   \etocfontminusone
   \addvspace{\etocsepminusone}%
   \parindent \z@
   \leftskip  \etocminusoneleftmargin
   \rightskip \etocminusonerightmargin
   \parfillskip \@flushglue
   % original from etoc :
   %\vbox{\etocifnumbered{\etocpartname\enspace\etocnumber.\quad}{}...}
   \vbox{\etocifnumbered{\etoclink{\etocpartname\enspace\etocthenumber.}\quad}{}%
         \etocname
         \baselineskip\etocbaselinespreadminusone\baselineskip
         \par}%
   \addpenalty\@M
   \addvspace{\etocsepzero}%
   \endgroup}
  {}%

% THIS IS THE FIRST HALF OF THE TOC ON PAGE 1
\tableofcontents


% May 23 2022, some hack to replace the \etocmulticolstyle and
% have same output except that Part line will use full line width
%
% Formerly I used this but the Part was then folded...
% \etocmulticolstyle [2]{\parskip\z@skip%\raggedcolumns
%     \setlength{\columnsep}{\leftmarginii}%
%     \setlength{\columnseprule}{0pt}%
% }%
%
\etocsetstyle{part}% @minusone in etoc.sty
  {\if1\ifnum\doxintsource=1 0\fi\ifnum\NoSourceCode=1 0\fi1% xint-all.pdf
     \def\etocabovetocskip{\z@skip}%
     \def\etocsepminusone{\bigskipamount}%
     \def\etocsepzero{\medskipamount}%
   \fi
   \addpenalty\@M\etocskipfirstprefix}
% May 23, 2022
% Small hack to configure to our taste the TOC for the pdf combining
% the user manual and the source code.  We want a Part III in the TOC,
% and the sections of Part II with a multicols.  We can not open the
% multicols in the `part' style and have it closed in the 4th argument
% of \etocsettyle, as it needs to be closed when Part III will be
% typeset.  Thanks to \etocskipfirstprefix we can simply close it
% in the "EtocPrefix", this \end{multicols} will be skipped for the
% first one.
%
% However, as this closes a group we will use \etocglobaldefs for this
% toc else \etocname, etc... would not have the good meanings.  I think
% there must be some hack like this in etoc manual.
  {\end{multicols}%
   \addpenalty\@secpenalty
   }
  {%
   % \kern and not \vskip to avoid multicolumn balncing columns
   \def\tocstylesectionVSKIP{\kern\smallskipamount}%
   \if1\ifnum\doxintsource=1 0\fi\ifnum\NoSourceCode=1 0\fi1%
       % xint-all.pdf only
       % quite a challenge to get everything on single page, but not too cramped...
       \def\tocstylesectionVSKIP{\kern.75\smallskipamount}%
   \fi
   \begingroup     % adapted from etoc.sty default Part style
   \etocfontminusone
   \addvspace{\etocsepminusone}%
   \parindent \z@
   \leftskip  \etocminusoneleftmargin
   \rightskip \etocminusonerightmargin
   \parfillskip \@flushglue
   % \etoclink is handy else only the number get hyperlinked
   \vbox{\etocifnumbered{\etoclink{\etocpartname\enspace\etocthenumber.\quad}}{}\etocname
         \baselineskip\etocbaselinespreadminusone\baselineskip
         \par}%
   \addpenalty\@M\addvspace{\etocsepzero}%
   \endgroup
   % now emulate what \etocmulticolstyle would have set-up
     \let\etocoldpar\par% surely fishy by now but I am copying from
                        % how \etocsettocstyle is used by \etocmulticolstyle
     \addvspace{\etocabovetocskip}% configured below
     \multicolpretolerance\etocmulticolpretolerance
     \multicoltolerance\etocmulticoltolerance
     \setlength{\columnsep}{\etoccolumnsep}%
     \setlength{\multicolsep}{\etocmulticolsep}%
     \begin{multicols}{2}[\parskip\z@skip%\raggedcolumns
                          \setlength{\columnsep}{\leftmarginii}%
                          \setlength{\columnseprule}{0pt}%
                          \etocoldpar
                          %\addvspace{\etocinnertopsep}
                          \addvspace{\etocabovetocskip}]%
     }%
     {\end{multicols}
     }%

% this macro is defined by etoc for use in its own display styles
% like the one from \etocmulticolstyle. We use it manually above.
\renewcommand*\etocabovetocskip{\bigskipamount}
\makeatother

   \etocsettagdepth {part1A}{none}
   \etocsettagdepth {part1B}{none}
   \etocsettagdepth {macros}     {section}
\ifnum\doxintsource=1    % xintsource.pdf
   \etocsettagdepth {implementation}{section}
\else
   \ifnum\NoSourceCode=1 % xint.pdf
     \etocsettagdepth {implementation}{part}
   \else                 % xint-calx.pdf
     \etocsettagdepth {implementation}{part}
   \fi
\fi
% THIS IS THE SECOND HALF OF THE TOC ON PAGE 1, WITH PARTS II AND III
\etocglobaldefs
\tableofcontents
\etoclocaldefs


\etocignoredepthtags
% 30 juillet 2025, simplification du contrôle espacement après TOCs
\makeatletter
\def\etocabovetocskip{\z@skip}
\makeatother
\def\etocbelowtocskip{\bigskipamount}
\etocmulticolstyle [1]{%
    \phantomsection% \section* {Contents}
    \etoctoccontentsline*{toctobookmark}{Contents}{2}%
}

\inmanualmaintocfalse

\clearpage

% ----
% Fibonacci code
%
% The first version was done on
% December 7, 2013. Expandably computing a big Fibonacci number
% with the help of TeX+\numexpr+\xintexpr, © Jean-François Burnol
%
% The code was redone on September 22 (and 27) 2025, after the
% 1.4o release, so for 1.4p release.
% Less multiplications.
% First convert to binary with the help of \xintDecToBin.
% This second version though requires positive argument.
%
% Transferred from bnumexpr.dtx with \xintiiexpr replacing \bnumexpr,
% comments in sync on Sep. 27.
% (MEMO: we are already here in the document body but a catcode active
% semi-colon from babel-french for example is not here a problem).
\makeatletter
\newcommand\Fibonacci[1]{%
    \expandafter\Fibo@start
    \romannumeral0\xintdectobin{\the\numexpr#1\relax};%
}
% To chain \xintiiexpr's easily we use the once-expanded form which is
% \romannumeral0\xintiiexpro.  We could also have used \expanded and \xintiieval
% calls, that would have been simpler but old habits die hard.
%
% Gobble the first digit which is 1 (this is where we could have tested for a
% negative or zero input).  Prepare encapsulated 1 and 0.  Then repeatedly
% dispatch according to binary digits (which are strategically located at end
% of input stream to optimize), or the semicolon which signals completion.
%
% We use \csname-governed branching (because it is cool).  We could have
% used some \if test or even an \ifcase with an {-1} at end, or any other
% of the many possibilities opened up by TeX syntax.
\def\Fibo@start 1#1{%
    \csname Fibo@#1\expandafter\endcsname
        \romannumeral0\xintiiexpro 1\expandafter\relax\expandafter;%
        \romannumeral0\xintiiexpro 0\relax;%
}
\@namedef{Fibo@0}#1;#2;#3{%
    \csname Fibo@#3\expandafter\endcsname
       \romannumeral0\xintiiexpro (#1+2*#2)*#1\expandafter\relax\expandafter;%
       \romannumeral0\xintiiexpro #1*#1+#2*#2\relax;%
}
\@namedef{Fibo@1}#1;#2;#3{%
    \csname Fibo@#3\expandafter\endcsname
        \romannumeral0\xintiiexpro 2*(#1+#2)*#1+#2*#2\expandafter\relax\expandafter;%
        \romannumeral0\xintiiexpro (#1+2*#2)*#1\relax;%
}
% #1 is F_N (and #2 is F_{N-1}) but in need of unpacking.
\@namedef{Fibo@;}#1;#2;{\xintthe#1}
\makeatother

\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 }%

% Updated september 9, 2025, 11 years and 8 months after initial
% version, to add a nice legend at bottom right and print F_{1250}
% at top left.  I don't think many people had understood that the
% displayed digits were those of the 1250th Fibonacci number...
%
\AddToShipoutPicture*{%
    \put(10.5cm,14.85cm)
    {\edef\z{\Fibonacci{1250}}%
     \makebox(0,0)
      {\resizebox{17cm}{!}{%
        \vbox{\hsize 8cm\Huge
         \baselineskip.8\baselineskip
         \color{black!15}%
         \makebox[6\dimexpr877496sp\relax][l]{$F_{1250}={}$}%
         \hskip0pt plus12sp\relax
         \specialprintnumber{\z}% <-- careful no space token here
         \parbox[c]{5.5\fontcharwd\font`0 }% 5 cm is a bit too narrow for text
                   {\color{black}\tiny
                    \raggedright The $1250^{th}$ Fibonacci number has
                    \expandafter\xintLength\expandafter{\z} digits.\par}%
          \kern-0.5\fontcharwd\font`0
         \par
        }%
                          }% arg of \resizebox
     }%
    }%
}


\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.1666}}

\begin{figure}[ht!]
  \phantomsection\label{dependencygraph}
\centeredline{%
\begin{tikzpicture}
    % Main calx column
    \node [block] (kernel) at (-2.8,0) {\xintkernelname};
    \node [block] (calxcore) at (-2.8,-2.2) {\calxcorename};
    \node [block] (calxint) at (-2.8,-4.35) {\calxintname};
    \node [block] (calxfp) at (-2.8,-6.5) {\calxfpname};
    \node [block] (calx) at (-2.8,-8.65) {\calxname};

    % Shared dependencies
    \node [block] (tools) at (3.8,-.5) {\xinttoolsname};
    \node [block] (binhex) at (7.3,-.5) {\xintbinhexname};

    % Legacy column
    \node [block] (xcore) at (2.1,-2.55) {\xintcorename};
    \node [block] (xint) at (2.1,-4.7) {\xintname};
    \node [block] (frac) at (2.1,-6.85) {\xintfracname};
    \node [block] (expr) at (2.1,-9) {\xintexprname};

    % Auxiliary xint packages
    \node [block] (bnumexpr) at (7.3,-2.55)
        {\ctanpackage{bnumexpr}};
    \node [block] (gcd) at (7.3,-4.7) {\xintgcdname};
    \node [block] (series) at (7.3,-6.85) {\xintseriesname};
    \node [block] (cfrac) at (7.3,-8.45) {\xintcfracname};

    % External packages
    \node [block] (zeck) at (7.3,-10.7)
        {\ctanpackage{zeckendorf}};
    \node [block] (session) at (2.1,-13.5)
        {rlwrap etex \ctanpackage{xintsession}};
    \node [block] (polexpr) at (7.3,-13.5)
        {\ctanpackage{polexpr}};

    % Main calx chain
    \path [line,-{Stealth[length=5mm]}] (kernel) -- (calxcore);
    \path [line,-{Stealth[length=5mm]}] (calxcore) -- (calxint);
    \path [line,-{Stealth[length=5mm]}] (calxint) -- (calxfp);
    \path [line,-{Stealth[length=5mm]}] (calxfp) -- (calx);

    % Dependencies on xintkernel
    \path [line,-{Stealth[length=5mm]}]
        (kernel.east) -- (tools.west);

    % xintkernel -> xintbinhex: clear xintcore from above
    \path [line,-{Stealth[length=5mm]}]
        (kernel.east) to[out=-65,in=180] (-.9,-1.55)
        -- (5.5,-1.55)
        to[out=0,in=230] (binhex.south west);

    % xinttools -> calx: diagonal entry at top-left corner
    \path [line,rounded corners=4pt,-{Stealth[length=5mm]}]
        (tools.north) -- (3.8,2.1) -- (-4.5,2.1)
        -- (-4.5,-7.45) -- (calx.north west);

    % xintbinhex -> calx: horizontal arrival at west
    \path [line,rounded corners=9pt,-{Stealth[length=5mm]}]
        (binhex.north) --
        (7.3,2.9) --
        (-5.2,2.9) --
        (-5.2,-8.65) --
        (calx.west);

    % Bridges from calx to legacy packages
    \path [line,-{Stealth[length=5mm]}] (calxcore) -- (xcore);
    \path [line,-{Stealth[length=5mm]}] (calxint) -- (xint);
    \path [line,-{Stealth[length=5mm]}] (calxfp) -- (frac);
    \path [line,-{Stealth[length=5mm]}] (calx) -- (expr);

    % Legacy chain
    \path [line,-{Stealth[length=5mm]}] (xcore) -- (xint);
    \path [line,-{Stealth[length=5mm]}] (xint) -- (frac);
    \path [line,-{Stealth[length=5mm]}] (frac) -- (expr);

    % bnumexpr dependencies
    \path [line,-{Stealth[length=5mm]}] (xcore) -- (bnumexpr);
    \path [line,-{Stealth[length=5mm]}]
        (binhex.south) -- (bnumexpr.north);

    % xintgcd, xintseries, xintcfrac
    \path [line,-{Stealth[length=5mm]}] (xint) -- (gcd);
    \path [line,-{Stealth[length=5mm]}] (frac) -- (series);
    \path [line,-{Stealth[length=5mm]}]
        (frac.south east) to [out=-35,in=180] (cfrac.west);

    % Additional xinttools dependencies
    \path [line,-{Stealth[length=5mm]}]
        (tools.south east) to [out=-65,in=135] (gcd.north west);
    \path [line,-{Stealth[length=5mm]}]
        (tools.south) to [out=-90,in=155] (cfrac.north west);

    % External packages
    \path [line,-{Stealth[length=5mm]}] (expr) -- (zeck);
    \path [line,-{Stealth[length=5mm]}] (expr) -- (session);
    \path [line,-{Stealth[length=5mm]}] (expr) -- (polexpr);
    \path [line,-{Stealth[length=5mm]}] (polexpr) -- (session);
\end{tikzpicture}}\bigskip
\end{figure}

% \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 of=kernel] (core) {\xintcorename};
%     \node [block, right of=core, xshift=1cm] (binhex) {\xintbinhexname};
%     \node [block, left of=core, xshift=-2.5cm]  (tools) {\xinttoolsname};
%     \node [block, below of=core] (xint) {\xintname};
%     \node [block, right of=xint, xshift=1cm]  (bnumexpr) {\ctanpackage{bnumexpr}};
%     \node [block, left of=xint, xshift=-0.5cm] (gcd) {\xintgcdname};
%     \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) {\ctanpackage{polexpr}};
%     \node [block, below of=polexpr] (session) {rlwrap etex \ctanpackage{xintsession}};
%     \node [block, right of=expr, xshift=3cm] (zeck) {\ctanpackage{zeckendorf}};
%     \node [block, below of=expr, yshift=-.5cm] (trig) {\xinttrigname};
%     \node [block, left of=trig] (log) {\xintlogname};
%     \node [block, left of=log, xshift=-1cm] (poormanlog) {\ctanpackage{poormanlog}};
%     \node [block, below of=gcd, yshift=1cm] (cfrac) {\xintcfracname};
%     \node [block, below of=cfrac, yshift=1cm] (series) {\xintseriesname};
%     % Draw edges
%     \path [line,-{Stealth[length=5mm]}] (kernel) -- (core);
%     \path [line,-{Stealth[length=5mm]}] (kernel) -- (tools);
%     \path [line,-{Stealth[length=5mm]}] (kernel) -- (binhex);
%     \path [line,-{Stealth[length=5mm]}] (core) -- (bnumexpr);
%     \path [line,-{Stealth[length=5mm]}] (binhex) -- (bnumexpr);
%     \path [line,-{Stealth[length=5mm]}] (core) -- (xint);
%     \path [line,-{Stealth[length=5mm]}] (xint) -- (frac);
%     \path [line,-{Stealth[length=5mm]}] (xint) -- (gcd);
%     \path [line,-{Stealth[length=5mm]}] (frac) -- (expr);
%     \path [line,-{Stealth[length=5mm]}] (frac) -- (series);
%     \path [line,-{Stealth[length=5mm]}] (frac) -- (cfrac);
%     \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]}] (expr) -- (session);
%     \path [line,-{Stealth[length=5mm]}] (expr) -- (zeck);
%     \path [line,-{Stealth[length=5mm]}] (polexpr) -- (session);
%     \path [line,-{Stealth[length=5mm]}] (trig.south) to [out=-90,in=180] (session.west);
%     \path [line,-{Stealth[length=5mm]}] (log.south)  to [out=-90,in=180] (session.west);
% % at 1.4n, xintbinhex is automatically loaded by xintexpr, no more "dashed"
%     \path [line,-{Stealth[length=5mm]}] (binhex.south east) to [out=-45,in=15] (expr);
% % at 1.4 xintgcd loads xinttools
%     \path [line,-{Stealth[length=5mm]}] (tools.south west) to [out=-90,in=180](gcd.west);
% % at 1.4n, xintcfrac loads xinttools automatically
%     \path [line,-{Stealth[length=5mm]}] (tools.south west) to [out=-90,in=180](cfrac.west);
%     \path [line,-{Stealth[length=5mm]}] (tools.south west) to [out=-90,in=180] (expr.west);
%   \end{tikzpicture}}\bigskip
% \end{figure}

%\vspace{\baselineskip}

\begin{addmargin}{1.5cm}
\normalfont\footnotesize Dependency graph for the
    \xintbundlename components.
%
    Modules pointed to by arrows \textbf{automatically}
    import the module from which the arrow originates.
    \calxcorename, \calxintname and \calxfpname provide no user interface
    at all. DO NOT USE THEM DIRECTLY.

    \ctanpackage{bnumexpr} is a \LaTeX{}
    package by the author which uses (by default)
    \xintcorename as its mathematical engine. To use it under Plain e\TeX{}
    issue first |\input miniltx.tex| then |\input bnumexpr.sty|.

    \ctanpackage{zeckendorf} can be used with Plain \eTeX{} or with \LaTeX{}
    and also directly on the command line.  It enriches the \csbxint{eval}
    interface with tools related to Fibonacci numbers and the Bergman
    $\phi$-representation.

    \ctanpackage{polexpr} handles definitions and algebraic operatione on
    one-variable polynomials, as well as root localization to arbitrary
    precision. It works both with Plain \TeX\ and with \LaTeX.


    \ctanpackage{xintsession} is invoked on the command line as |etex
    xintsession| (or, much better if available: |rlwrap etex xintsession|).
\par
\end{addmargin}
\vfill

\clearpage
\etocdepthtag.toc {part1A}

\csname Start herenameUp\endcsname
\part{The \calxname and \xintexprname packages}
\RaisedLabel[12]{part:1}

\etocsetnexttocdepth{section}
\localtableofcontents

\section{The \calxname package}
\label{sec:calxcore}
\label{sec:calxint}
\label{sec:calxfp}
\label{sec:calx}

\localtableofcontents

\begin{framed}
 \textsc{Jürgen Gilg}'s interest into what he called
    {|"XINT"|} was instrumental in keeping the author motivated
    over the years.
%
    We exchanged on many topics extending beyond \TeX{} and often reacted
    similarly to private and public events.  I knew he was a very kind
    and devoted person, who took care of the needs of others prior to
    his own, although he never mentioned it.
%
    Jürgen suffered a sudden, unexpected, and deadly stroke in
    May 2022.  I will miss his friendship profoundly.
\end{framed}

\begin{framed}
The advent of \xintexprname 2.0, also known as \calxname, is almost entirely
backward compatible.  There are a few breaking changes and probably not
all of them are properly documented for the \dtt{2.0a1} release.  
\end{framed}

\subsection{Usage}

Loading:
\begin{everbatim}
\usepackage{calx}% with LaTeX
\input calx.sty\relax with other e-TeX formats.
\end{everbatim}

Example:
\begin{everbatim*}
$2^{200}=\calxinteval{2^200}$%  \calxinteval and \xintiieval are the same thing.

\noindent % \calxeval and \xintfloateval are the same thing.
$(\ln(3), \pi)\approx (\calxeval{ln(3), Pi})$

\xintDigits:= 32\relax % or \xintSetDigits{32}
\noindent % with 32 digits (hence, here, 31 decimal places).
$(\ln(3), \pi) \approx (\calxeval{ln(3), Pi})$

\xintDigits:= 16\relax % back to default setting
\end{everbatim*}

You can set the floating point precision up to \dtt{100}. For tips on
how to let \TeX{} print such long numeric output without overflowing
into the right margin, please search for |\printnumber| in the legacy
manual (which is actually the bulk of this PDF).

Note: loading \xintexprname automatically loads \calxname.  So
legacy documents automatically benefit from the speed-up and
higher accuracy.

\subsection{What is \calxname?}

It is the new arithmetic unit (floating point and big integers) of
\xintexprname at release 2.0. It is a complete rewrite of thousands of
lines of code, and addition of thousands more%
%
\footnote{Roughly the whole codebase has increased by 50\%. If one loads
  only \calxname, the "size" is increased only about 25\% compared with
  what applied with 1.4 series \xintexprname, due to \calxname not
  providing the support for fractions.},
%
which was done in October 2026 (and took the whole month to get
completed) by (mainly) Claude Opus 5.5, and ChatGPT 6. This was under
the training, guidance and general supervision by an anonymous human
assistant to Professor Burnol.

NOTA BENE: \emph{the anonymous assistant checked only very little of the
  produced code and was each time horrified by what he saw.}  He tried
to fix a few obvious sub-optimalities and to get the AI assistants to
learn from him (which he thought they had, but no), with little success.
Much remains to be done at time of the \texttt{2.0a1} release for
cleaning up the code. But it works.

% 2.0a1
% xintkernel 715 (162)
% xinttools 1625 (378)
% xintbinhex 828 (164)
% calxcore 2275 (607)
% calxint 2521 (619)
% calxfp 2879 (693)
% calx 5264 (1556)
% calxlog 3233 (555)
% calxlogdata 1488 (470)
% calxtrig 3644 (656)
% calxtrigdata 1228 (536)
% TOTAL: 
% 715 +1625 +828 +2275 +2521 +2879 +5264 +3233 +1488 +3644 +1228 = 25700
% 162 + 378 + 164 + 607 + 619 + 693 + 1556 + 555 + 470 + 656 + 536 = 6396
% ----
% 1.4o
% xintkernel 701 (160)
% xinttools 1625 (376)
% xintcore 2104 (525)
% xint 1611 (405)
% xintbinhex 783 (157)
% xintgcd 366 (63)
% xintfrac 3683 (988)
% xintseries 384 (66)
% xintcfrac 1038 (257)
% xintexpr 4788 (1407)
% xinttrig 869 (68)
% xintlog 1395 (123)
% TOTAL:
% 701 + 1625 + 2104 + 1611 + 783 + 366 + 3683 + 384 + 1038 + 4788 + 869 + 1395 = 19347
% 160 + 376 + 525 + 405 + 157 + 63 + 988 + 66 + 257 + 1407 + 68 + 123 = 4595
% --- 2.0a1
% xintkernel 715 (162)
% xinttools 1625 (378)
% xintbinhex 828 (164)
% xintcore 443 (153)
% xint 772 (249)
% xintfrac 2805 (780)
% xintexpr 667 (152)
% xintgcd 366 (63)
% xintseries 384 (66)
% xintcfrac 1038 (257)

The whole process was much more difficult and lengthy than originally
envisioned. It reached the limits of what the anonymous assistant was
willing to devote to an open source project with no financial
gratification (especially when on a few occasions the human did buy some
additional credits on top of the basic monthly subscription).  However
it was seen as an escape from the Apocalypse of July-August-September
2026 which completely changed the field of interest of the
anonymous assistant: mathematics.  Its sociology is going to
change for the worse very quickly and irremediably now.

Contrarily to \xintexprname, \calxname loads \emph{none} of \xintcorename,
\xintname, \xintfracname.  \textbf{It does not handle fractions}. For this you
must load \xintexprname package for its |\xinteval| evaluator.

For mathematical functions the target accuracy was set at a maximal
error of \texttt{0.005ulp}. This means roughly that correct rounding is
achieved in \dtt{99.5\%} of the cases (because at distance
\texttt{0.005ulp} from a tie, there is \dtt{50\%} chance to be wrongly
rounded).  It seems that trigonometry actually achieved ten times better
results, which may be modified in next relase to increase speed.  For
example for \dtt{4872} cases involvoing \func{log}, \func{exp},
\func{log1p}, \func{expm1}, only \dtt{21} were not correctly rounded and
the error was then \texttt{1ulp}.  Among \dtt{20300} trigonometrical
evaluations \dtt{19} were not correctly rounded, and \dtt{18} among them
were for \dtt{$P\leq8$}.

The \dtt{$P=8$} mode has an about ten times degraded target accuracy,
speed being the priority. (The core on arithmetic operations has not
yet been optimized for \dtt{$P=8$}, it probably shares some overhead
with the general precision case).


\subsection{Timing comparisons versus \cs{fpeval} for \func{sin},
  \func{ln}, \func{exp}, \dots}
\label{sec:calx-speed}


% Build-time comparison of \calxname 2.0a1 and LaTeX3 floating point evaluation.
% The first run writes \jobname-benchmark.tex; subsequent runs reuse it.
% Delete that file to remeasure after changing the code, engine or machine.

\def\CalxBenchmarkExprSin{sin(1.2345678)}
\def\CalxBenchmarkExprCos{cos(1.2345678)}
\def\CalxBenchmarkExprTan{tan(1.2345678)}
\def\CalxBenchmarkExprAsin{asin(0.56784321)}
\def\CalxBenchmarkExprAcos{acos(0.56784321)}
\def\CalxBenchmarkExprAtan{atan(1.2345678)}
\def\CalxBenchmarkExprLog{ln(2.3456789)}
\def\CalxBenchmarkExprExp{exp(1.2345678)}
\def\CalxBenchmarkExprPowI{12.3456^78.9012}
\def\CalxBenchmarkExprPowG{1.23456^789.012}
\newcommand\CalxBenchmarkLabel[1]{%
  \texttt{\detokenize\expandafter{#1}}}

% Only the l3benchmark interface needs expl3 syntax.
\ExplSyntaxOn
\fp_gset:Nn \g_benchmark_duration_target_fp { 0.025 }
\cs_new_protected:Npn \CalxBenchmarkMeasure #1
  {
    \benchmark_silent:n {#1}
    \xdef\CalxBenchmarkLastTime{\fp_to_decimal:N \g_benchmark_time_fp}
  }
\ExplSyntaxOff

% Benchmark raw timings are ordinary macros named
% \calxDocumentBenchmarkRaw@<expression>@<precision> (accessed via \csname).
% The reference timing has the name calxDocumentBenchmarkRaw@unit.
\def\CalxBenchmarkOne#1#2{%
  \CalxBenchmarkMeasure{\edef\calxDocumentBenchmarkSink{\fpeval{#2}}}%
  \expandafter\xdef\csname calxDocumentBenchmarkRaw@#1@fp\endcsname
    {\CalxBenchmarkLastTime}%
  \xintFor ##1 in {8,16,32}\do{%
    \begingroup
      \xintDigits=##1\relax
      \CalxBenchmarkMeasure{\edef\calxDocumentBenchmarkSink{\calxeval{#2}}}%
      \expandafter\xdef\csname calxDocumentBenchmarkRaw@#1@p##1\endcsname
        {\CalxBenchmarkLastTime}%
    \endgroup
  }%
}

\def\DOTIMINGS{%
  \def\CalxBenchmarkSum{0}%
  \xintFor ##1 in {1,2,3,4,5}\do{%
    \CalxBenchmarkMeasure{\edef\calxDocumentBenchmarkSink{\fpeval{sin(1)}}}%
    \edef\CalxBenchmarkSum
      {\xintfloateval{\CalxBenchmarkSum+\CalxBenchmarkLastTime}}%
  }%
  \expandafter\xdef\csname calxDocumentBenchmarkRaw@unit\endcsname
    {\xintfloateval{\CalxBenchmarkSum/5}}%
  \xintForpair ##1##2 in
    {(sin,Sin),(cos,Cos),(tan,Tan),(asin,Asin),(acos,Acos),
     (atan,Atan),(log,Log),(exp,Exp),(powi,PowI),(powg,PowG)}\do{%
    \CalxBenchmarkOne{##1}{\csname CalxBenchmarkExpr##2\endcsname}%
  }%
}

% Cache the raw per-evaluation times, not the displayed rounded ratios.
\newwrite\CalxBenchmarkStream
\def\CalxBenchmarkWriteRaw#1{%
  \immediate\write\CalxBenchmarkStream{%
    \string\expandafter\string\gdef
    \string\csname\space calxDocumentBenchmarkRaw@#1\string\endcsname
    {\csname calxDocumentBenchmarkRaw@#1\endcsname}}%
}
\def\CalxBenchmarkSaveResults{%
  \immediate\openout\CalxBenchmarkStream=\jobname-benchmark.tex\relax
  \CalxBenchmarkWriteRaw{unit}%
  \xintFor ##1 in {sin,cos,tan,asin,acos,atan,log,exp,powi,powg}\do{%
    \xintFor ##2 in {fp,p8,p16,p32}\do{%
      \CalxBenchmarkWriteRaw{##1@##2}%
    }%
  }%
  \immediate\closeout\CalxBenchmarkStream
}

% All seven displayed columns are rounded with \xintieval[2].
\def\CalxBenchmarkPrepareTable{%
  \xintFor ##1 in {sin,cos,tan,asin,acos,atan,log,exp,powi,powg}\do{%
    \expandafter\xdef\csname calxDocumentBenchmarkRatio@##1@fp\endcsname{%
      \xintieval[2]{%
        \csname calxDocumentBenchmarkRaw@##1@fp\endcsname/
        \csname calxDocumentBenchmarkRaw@unit\endcsname}}%
    \xintFor ##2 in {p8,p16,p32}\do{%
      \expandafter\xdef\csname calxDocumentBenchmarkRatio@##1@##2units\endcsname{%
        \xintieval[2]{%
          \csname calxDocumentBenchmarkRaw@##1@##2\endcsname/
          \csname calxDocumentBenchmarkRaw@unit\endcsname}}%
      \expandafter\xdef\csname calxDocumentBenchmarkRatio@##1@##2\endcsname{%
        \xintieval[2]{%
          \csname calxDocumentBenchmarkRaw@##1@##2\endcsname/
          \csname calxDocumentBenchmarkRaw@##1@fp\endcsname}}%
    }%
  }%
}
\def\CalxBenchmarkCell#1#2{\csname calxDocumentBenchmarkRatio@#1@#2\endcsname}

The \autoref{tab:timings} compares |\fpeval| with |\calxeval| used at precision
settings P=8, 16 and 32 (P is the value set by \csbxint{SetDigits}).  The
average evaluation time of |\fpeval{sin(1)}| is used as a time unit for
the entries in the |\fpeval| columns.
The |\calxeval| columns show the ratios of \calxname timings with those of
|\fpeval|. Thus, a value below one indicates that \calxname is faster, and a
value above one that it is slower.  All measurements include expansion of the
expression and assignment of its result to a macro via |\edef|.  In
particular they include the overhead of the respective parsers gathering
the input and printing the output.

\IfFileExists{\jobname-benchmark.tex}
  {\input{\jobname-benchmark.tex}}
  {\typeout{******** No benchmark file, doing it myself ********}%
   \DOTIMINGS
   \CalxBenchmarkSaveResults}
\CalxBenchmarkPrepareTable

\begin{table}[htbp]
\capstart
\centering
\setlength{\tabcolsep}{2pt}%
%\begin{tabular}{|l||c|cc||cc||cc|}
\begin{tabular}{|l||c|c||c||c|}
\hline
% Expression
& |\fpeval| 
% & \multicolumn{2}{c||}{\texttt{\string\calxeval} (P=16)} 
% & \multicolumn{2}{c||}{\texttt{\string\calxeval} (P=8)} 
% & \multicolumn{2}{c|}{\texttt{\string\calxeval} (P=32)}
& \texttt{\string\calxeval} (P=16)
& \texttt{\string\calxeval} (P=8) 
& \texttt{\string\calxeval} (P=32)
\\
& \begin{tabular}{c}sin(1)\\[-.5\jot]units\end{tabular}
%& \begin{tabular}{c}sin(1)\\[-.5\jot]units\end{tabular}
& \begin{tabular}{c}timing ratio to\\[-.5\jot]\texttt{\string\fpeval}\end{tabular}
%& \begin{tabular}{c}sin(1)\\[-.5\jot]units\end{tabular}
& \begin{tabular}{c}timing ratio to\\[-.5\jot]\texttt{\string\fpeval}\end{tabular}
%& \begin{tabular}{c}sin(1)\\[-.5\jot]units\end{tabular}
& \begin{tabular}{c}timing ratio to\\[-.5\jot]\texttt{\string\fpeval}\end{tabular}
\\
\hline
\CalxBenchmarkLabel{\CalxBenchmarkExprSin}       & \CalxBenchmarkCell{sin}{fp}
%& \CalxBenchmarkCell{sin}{p16units}
& \CalxBenchmarkCell{sin}{p16}
%& \CalxBenchmarkCell{sin}{p8units}
& \CalxBenchmarkCell{sin}{p8}
%& \CalxBenchmarkCell{sin}{p32units}
& \CalxBenchmarkCell{sin}{p32} 
\\
\CalxBenchmarkLabel{\CalxBenchmarkExprCos}       & \CalxBenchmarkCell{cos}{fp}
%& \CalxBenchmarkCell{cos}{p16units}
& \CalxBenchmarkCell{cos}{p16}
%& \CalxBenchmarkCell{cos}{p8units}
& \CalxBenchmarkCell{cos}{p8}
%& \CalxBenchmarkCell{cos}{p32units}
& \CalxBenchmarkCell{cos}{p32} 
\\
\CalxBenchmarkLabel{\CalxBenchmarkExprTan}       & \CalxBenchmarkCell{tan}{fp}
%& \CalxBenchmarkCell{tan}{p16units}
& \CalxBenchmarkCell{tan}{p16}
%& \CalxBenchmarkCell{tan}{p8units}
& \CalxBenchmarkCell{tan}{p8}
%& \CalxBenchmarkCell{tan}{p32units}
& \CalxBenchmarkCell{tan}{p32} 
\\
\CalxBenchmarkLabel{\CalxBenchmarkExprAsin}    & \CalxBenchmarkCell{asin}{fp}
%& \CalxBenchmarkCell{asin}{p16units}
& \CalxBenchmarkCell{asin}{p16}
%& \CalxBenchmarkCell{asin}{p8units}
& \CalxBenchmarkCell{asin}{p8}
%& \CalxBenchmarkCell{asin}{p32units}
& \CalxBenchmarkCell{asin}{p32} 
\\
\CalxBenchmarkLabel{\CalxBenchmarkExprAcos}    & \CalxBenchmarkCell{acos}{fp}
%& \CalxBenchmarkCell{acos}{p16units}
& \CalxBenchmarkCell{acos}{p16}
%& \CalxBenchmarkCell{acos}{p8units}
& \CalxBenchmarkCell{acos}{p8}
%& \CalxBenchmarkCell{acos}{p32units}
& \CalxBenchmarkCell{acos}{p32} 
\\
\CalxBenchmarkLabel{\CalxBenchmarkExprAtan}     & \CalxBenchmarkCell{atan}{fp}
%& \CalxBenchmarkCell{atan}{p16units}
& \CalxBenchmarkCell{atan}{p16}
%& \CalxBenchmarkCell{atan}{p8units}
& \CalxBenchmarkCell{atan}{p8}
%& \CalxBenchmarkCell{atan}{p32units}
& \CalxBenchmarkCell{atan}{p32}
\\ 
\CalxBenchmarkLabel{\CalxBenchmarkExprLog}  & \CalxBenchmarkCell{log}{fp}
%& \CalxBenchmarkCell{log}{p16units}
& \CalxBenchmarkCell{log}{p16}
%& \CalxBenchmarkCell{log}{p8units}
& \CalxBenchmarkCell{log}{p8}
%& \CalxBenchmarkCell{log}{p32units}
& \CalxBenchmarkCell{log}{p32}
\\ 
\CalxBenchmarkLabel{\CalxBenchmarkExprExp}       & \CalxBenchmarkCell{exp}{fp}
%& \CalxBenchmarkCell{exp}{p16units}
& \CalxBenchmarkCell{exp}{p16}
%& \CalxBenchmarkCell{exp}{p8units}
& \CalxBenchmarkCell{exp}{p8}
%& \CalxBenchmarkCell{exp}{p32units}
& \CalxBenchmarkCell{exp}{p32}
\\ 
\CalxBenchmarkLabel{\CalxBenchmarkExprPowI} & \CalxBenchmarkCell{powi}{fp}
%& \CalxBenchmarkCell{powi}{p16units}
& \CalxBenchmarkCell{powi}{p16}
%& \CalxBenchmarkCell{powi}{p8units}
& \CalxBenchmarkCell{powi}{p8}
%& \CalxBenchmarkCell{powi}{p32units}
& \CalxBenchmarkCell{powi}{p32}
\\ 
\CalxBenchmarkLabel{\CalxBenchmarkExprPowG} & \CalxBenchmarkCell{powg}{fp}
%& \CalxBenchmarkCell{powg}{p16units}
& \CalxBenchmarkCell{powg}{p16}
%& \CalxBenchmarkCell{powg}{p8units}
& \CalxBenchmarkCell{powg}{p8}
%& \CalxBenchmarkCell{powg}{p32units}
& \CalxBenchmarkCell{powg}{p32}
\\
\hline
\end{tabular}
\caption{Timings}\label{tab:timings}
\end{table}

The given values are indicative, variations of a few percent are
typically observed whenever launching again the tests.  The \dtt{$P=8$}
precision is often enough for plots, perhaps a future release will
include some interface to use the \calxname floating point engine in
TikZ/pgf or PSTricks, but for now there is only \csbxint{thecoords} and
\csbxint{thespaceseparated} (check the legacy xint user manual).

\emph{The gap for \texttt{atan()} between P=8 and P=16 may be a sign of some
serious sub-optimatlity in the current implementation.  This may be addressed,
if ever, at a next release.}


\subsection{User interface}

The user interface is reduced to:
\begin{itemize}
\item |\calxeval| or its legacy alias \csbxint{floateval}: a parser
      of floating point expressions at a given arbitrary precision P which
      can be any integer from 1 to 100 and is set by \csbxint{SetDigits}.
      For details of the available syntax elements see the legacy
      \xintexprname manual.
      Trigonometry and logarithm/exponential/powers are all
      available (the legacy maximal precision was 62).
\item |\calxinteval| or its legacy alias \csbxint{iieval}: handles
      arbitrarily large integers. Refer to the legacy \xintexprname
      manual.
    \item The interface to set the floating point precision via
      \csbxint{SetDigits}\marg{P} or equivalently
      \csbxint{Digits}|=|\meta{P}|\relax|. Their starred variants are
      now aliases to the non-starred ones.  Modifying the precision does
      not trigger a reload of the scientific libraries: they adjust
      automatically with no reloading needed.  The only overhead is the
      re-assignment of the trigonometrical constants documented in the
      legacy manual, such as \texttt{Pi}.  The legacy scientific
      libraries |xintlog.sty| and |xinttrig.sty| are gone, replaced by the
      \calxname ones.
\item The legacy \xintexprname interface to define functions and
  variables: \csbxint{NewFunction}, \csbxint{deffloatfunc}, \csbxint{deffloatvar},
  \csbxint{defiifunc}, \csbxint{defiivar}.
\item Things such as \csbxint{globaldefstrue}, \csbxint{verbosetrue},
      \csbxint{thecoords}, and a few others.
    \item |\calxsetup| which is described in the next section devoted to
      the handling of condition signals.
\end{itemize}

The packages \xintkernelname, \xintbinhexname, and \xinttoolsname are loaded automatically.

Loading \xintexprname does not modify anything to \calxname interface
and functionalities. It adds to it the \csbxint{eval} parser (together
with \csbxint{deffunc}, \csbxint{defvar}) and loads all of
\xintcorename, \xintname, and \xintfracname.  The macro interface of the
latter is unchanged but arithmetic internals are remapped to the
\calxname substratum.  Some undocumented at user level macros of
\xintfracname having to do with floating point numbers are gone.

The \texttt{2.0a1} release has a few breaking changes (behavior and
availability of \func{qfloat} and \func{qfrac} come to mind) which may
not have been documented in time.  The code comments are very likely
either outdated or barely legible.

\subsection{Arithmetic signals, exceptional results and error handling}
\label{sec:calx-signals}
\etocsetnexttocdepth{subsubsection}
\localtableofcontents

\textbf{Summary:}  \emph{an arithmetic condition is not necessarily a \TeX\ error.  In fact,
by default \calxname~\texttt{2.0a1} in case of division by zero returns a
non-finite result (\textbf{NaN}, \textbf{+Infinity}, or \textbf{-Infinity})
while the compilation continues: \emph{more generally, all arithmetic traps
  are disabled initially}.}

A \emph{trap} raises an error message and causes
\TeX{} to consider that a build error has arisen; applications which prefer
active traps may enable them individually one-by-one or globally.

The codebase was already done by Professor Burnol in 2017 but was left
then in a state where all error conditions are trapped, i.e.\@ do
trigger \TeX{} errors.

\begin{framed}
  The whole signal-handler system, described next, is available only for
  arithmetic with |\calxeval| (aka \csbxint{floateval}, i.e.\@ floating
  point calculations) and |\calxinteval| (aka \csbxint{iieval}, i.e.\@
  big integers calculations).  The legacy evaluator \csbxint{eval} (which
  handles fractions but also authorizes the mathematical functions) does not
  support the special values \texttt{NaN}, \texttt{+Infinity} and
  \texttt{-Infinity} as arithmetic operands.  Note that the fact that
  \csbxint{eval} authorizes mathematical functions such as \func{sin} and
  \func{exp} should not be abused: any multiplication of two such creates
  mantissas twice as big, obviously.
\end{framed}

\subsubsection{Default: division by zero without a \TeX\ error}

The following code does not interrupt the compilation:
\begin{everbatim*}
\calxresetflags
\edef\result{\calxeval{1/0}}
% \result expands to +Infinity
\calxifflagraised{DivisionByZero}
  {Division by zero occurred.}
  {No division by zero occurred.} The result is \result.
\end{everbatim*}

Similarly |\calxeval{-1/0}| produces \dtt{\calxeval{-1/0}}.

The calculation raises the \texttt{DivisionByZero} flag and returns
\texttt{+Infinity}.  Since \calxname has no signed zero, division of a nonzero
numerator by zero uses the numerator's sign to determine the infinity.  For
|\calxeval{0/0}|, the result is instead \texttt{NaN}; this is the
\texttt{DivisionUndefined} condition, which raises the
\texttt{InvalidOperation} flag rather than \texttt{DivisionByZero}.

A flag is raised when the expression is actually expanded, as in the
|\edef| above.  Merely storing an unevaluated expression via |\def|
or, in \LaTeX, |\newcommand|, does not raise a flag.

To make division by zero a \TeX\ error, enable its trap:
\begin{everbatim}
\calxsetup{DivisionByZero.trap=true}
\end{everbatim}
A trapped condition emits an expandable \TeX\ error and returns the
operation's trap value.  To restore the default behavior, use:
\begin{everbatim}
\calxsetup{DivisionByZero.trap=false}
\end{everbatim}

\subsubsection{Exceptional values and their printed forms}

The expression parsers |\calxeval| and |\calxinteval| recognize
\texttt{NaN} and \texttt{Infinity} as reserved constants.  A negative infinity
can be written \texttt{-Infinity}.  Thus, the following expressions all yield
a non-finite result, without necessarily raising a new signal:
\begin{everbatim*}
\calxeval{NaN, Infinity, -Infinity}
\end{everbatim*}

In particular, using a special constant is not the same as signalling
an arithmetic condition.

An application which prefers \texttt{NaN} for division by zero such as
\texttt{1/0} can
replace the default handler.  The handler receives the numerator's sign
as its argument; it may ignore it and emi the internal marker for
\texttt{NaN}, which is \texttt{I?}.
\begin{everbatim}
\def\calxDivisionByZeroAsNaN#1{I?}
\calxsetup{DivisionByZero.handler=\calxDivisionByZeroAsNaN}
\edef\result{\calxeval{1/0}}
% \result expands to NaN (which is the printed form of I?)
\end{everbatim}
Overflow independently retains its default results,
\texttt{+Infinity} and \texttt{-Infinity}.

\emph{Note that the internal markers for the non-finite values differ
from the user interface ones \texttt{NaN}, \texttt{+Infinity} and
\texttt{-Infinity}:
they are respecitevly \texttt{I?}, \texttt{I+}, \texttt{I-}. These
internal notations are \emph{only} to be used in defining handlers as above.}

\subsubsection{Testing an expression for a non-finite result}

The expandable predicate \csbxint{ifNonFinitefloatexpr} takes a
floating-point expression followed by two branches:
\begin{everbatim}
\xintifNonFinitefloatexpr{<expression>}{<non-finite>}{<finite>}
\end{everbatim}
It evaluates the expression once and selects the first branch when its
\emph{internal result} is \texttt{I?}, \texttt{I+} or \texttt{I-}.
The second branch is selected for a finite result.  For example:
\begin{everbatim*}
\xintifNonFinitefloatexpr{1/0}{YES}{NO}% YES
\xintifNonFinitefloatexpr{NaN}{YES}{NO}% YES
\xintifNonFinitefloatexpr{Infinity}{YES}{NO}% YES
\xintifNonFinitefloatexpr{sin(1)}{YES}{NO}% NO
\end{everbatim*}
This predicate examines the computed value, not the signal flags or its
printed spelling.  Evaluating an expression inside this test can itself
raise signal flags.

\subsubsection{Testing signals after a calculation}

If the calculation has already been performed, use the expandable
predicate shown below to check the flags for invalid operations,
division by zero and overflow:
\begin{everbatim}
\xintifNonFiniteSignalled{<yes>}{<no>}
\end{everbatim}
For example:
\begin{everbatim*}
\calxresetflags
\edef\result{\calxeval{1/0}}
\xintifNonFiniteSignalled
  {A non-finite condition was signalled}
  {No non-finite condition was signalled}
\end{everbatim*}

This test does not re-evaluate an expression and does not inspect
|\result|.  A handler may return a finite value while leaving a signal
flag raised; conversely, a literal \texttt{NaN} or \texttt{Infinity} need not
raise a flag.  Flags persist until cleared within their scope (e.g.\@ \LaTeX{}
environments), so use |\calxresetflags| before a calculation when only
its newly raised conditions are of interest.

\subsubsection{Signals, flags, traps and handlers}

There are eight signals:
\begin{everbatim}
Clamped          DivisionByZero  Inexact       InvalidOperation
Overflow         Rounded         Subnormal     Underflow
\end{everbatim}
Each has a flag and an independently configurable trap.  No arithmetic
trap is enabled by default.

Five additional conditions use the \texttt{InvalidOperation} flag and
trap:
\begin{everbatim}
ConversionSyntax    DivisionImpossible  DivisionUndefined
InvalidContext      ControversialOperation
\end{everbatim}
They each have individually configurable handlers.

Flags are inspected and cleared with the following commands:
\begin{everbatim}
\calxifflagraised{InvalidOperation}{<yes>}{<no>}
\calxresetflag{InvalidOperation}
\calxresetflags
\end{everbatim}
The flag test is expandable; the reset commands are assignments and are
not expandable.  Flags are local to \TeX\ groups.  Examine flags raised
inside a group before leaving it.  Reset commands obey the prevailing
\csbxint{globaldefs} setting, as do assignments by |\calxsetup|.

The default handlers for \texttt{InvalidOperation} and its subordinate
conditions return internal \texttt{I?}; the
\texttt{DivisionByZero} and \texttt{Overflow} handlers return
\texttt{I+} or \texttt{I-}, according to the sign.
The default handlers for \texttt{Clamped}, \texttt{Inexact},
\texttt{Rounded}, \texttt{Subnormal} and \texttt{Underflow}
leave the computed result unchanged.

Traps and handlers are configured with |\calxsetup|:
\begin{everbatim}
\calxsetup{InvalidOperation.trap=true}
\calxsetup{Overflow.trap=false}
\calxsetup{ControversialOperation.handler=\myHandler}
\end{everbatim}
The value of a \texttt{.handler} key is a single control sequence
denoting an expandable one-argument handler.  An unknown setup key or
invalid trap value is a configuration error and is reported by \TeX,
regardless of the arithmetic-trap settings.



\section {Introduction to the rest of this manual (which is the legacy 1.4 documentation)}
\localtableofcontents

\subsection{This documentation}

Whenever you see
\textcolor{macrocodelinktosectioncolor}{\textbf{\textit{code}}} above
some control sequence \textbf{\string\foo}, it is an hyperlink to its
coding in the second part of this document. You should find there,
near your landing point, the control sequence
\textcolor{macrocodelinktouserdoccolor}{\textbf{\string\foo}} in orange:
this is a hyperlink to go back to its documentation in the user manual
part.  Within the source code, other colored control sequences should
link back to the location of first definition.

And throughout the user manual part, blue color such as \csbxint{eval}
signals an hyperlink to the documentation of the macro.  You can try it
now.

\subsection{Compatible engines and formats}

The components of the \xintbundlename can be used indifferently with
Plain \TeX{} (and other formats, as mentioned next) or with \LaTeX{}.
The sole difference being that with the latter the loading must be done
by \cs{usepackage} whereas with any non-\LaTeX{} format it has to be via
\cs{input} (using |.sty| filename extension, not |.tex|).

The engine can be PDF\TeX, Xe\TeX, or Lua\TeX.

With release |1.4n| you can also use the packages with Con\TeX t (only
latest one, with LuaMeta\TeX{} engine), and Op\TeX.

You can't use the \xintbundlename with Knuth's original |tex| binary,
because its functionalities require \cs{numexpr} and other e-\TeX{}
extensions as well as the more recent \cs{expanded} engine primitive
(and \cs{pdfstrcomp} or \cs{strcmp}).

\xintexprname will be probably the main entry point, and it actually
automatically loads most other components.  The aim of \xintexprname is
to provide expandable parsers of numerical expressions, either floating
point numbers or fractions.

\subsection{Usage}

Here is an example:
\begin{everbatim*}
\xintfloateval{cos(3Pi/17)*sin(1)^0.123 + log(3.42e5)}
\end{everbatim*}

You can get the result with more digits:
\begingroup
\begin{everbatim*}
\xintSetDigits*{32}
\xintfloateval{cos(3Pi/17)*sin(1)^0.123 + log(3.42e5)}
\end{everbatim*}
\endgroup

\noindent And with still more digits (the |[-2]| rounds away the two least
significant ones):
\begingroup
\begin{everbatim*}
\xintSetDigits*{62}
\xintfloateval[-2]{cos(3Pi/17)*sin(1)^0.123 + log(3.42e5)}
\end{everbatim*}
\endgroup

Here is now an example with fractions:
\begin{everbatim*}
\xinteval{reduce(add(1/i^3, i=1..25))}
\end{everbatim*}

And two examples with large integers:
\begin{everbatim*}
$2^{1000}=\printnumber{\xinteval{2^1000}}$.\newline
$100!^3=\printnumber{\xintiieval{100!^3}}$.
\end{everbatim*}

The \hyperref[ssec:printnumber]{\string\printnumber} utility to wrap
very long output is not part of the package. It is documented in
\autoref{ssec:printnumber} next.

The table of \hyperref[tab:functions]{built-in functions}
and the one of \hyperref[tab:precedences]{built-in operators}
will give a quick overview of the available syntax.


\subsection{\ctanpackage{xintsession}}

The simplest way\footnote{I am assuming here in the displayed example a
  Unixen system, i.e. Mac OS or Linux, adapt to your environment.} to
test the syntax is to work interactively on the command line (this
feature is available since April 2021, the version of
\ctanpackage{xintsession} used here is |1.3a|).  Beware though that
ill-formed inputs will trigger \TeX{} famously antiquated error handling,
from which it is hard to recover, altough hitting |S| may sometimes
miraculously bring you back to the \ctanpackage{xintsession} prompt.
\begin{everbatim}
rlwrap etex xintsession
[...welcome banner...]
  Magic words: `&pause' (or `;'), `&help', `&bye',
               `&exact', `&fp', `&int', `&pol'.

  \jobname is xintsession
  Transcript will go to log and to xintsession-210609_12h00.tex
Starting in exact mode (floating point evaluations use 16 digits)
>>> 2^100;
@_1     1267650600228229401496703205376
>>> cos(1);
@_2     0.5403023058681397
>>> &fp=32
(/usr/local/texlive/2021/texmf-dist/tex/generic/xint/xintlog.sty)
(/usr/local/texlive/2021/texmf-dist/tex/generic/xint/xinttrig.sty)
fp mode (log and trig reloaded at Digits=32)
>>> cos(1);
@_3     0.54030230586813971740093660744298
>>> 3^1000;
@_4     1.3220708194808066368904552597521e477
>>> &exact
exact mode (floating point evaluations use 32 digits)
>>> 3^1000;

@_5     13220708194808066368904552597521443659654220327521481676649203682268285
9734670489954077831385060806196390977769687258235595095458210061891186534272525
7953674027620225198320803878014774228964841274390400117588618041128947815623094
4380615661730540866744905061781254803444055470543970388958174653682549161362208
3026856377858229022841639830788789691855640408489893760937324217184635993869551
6765018940588109060426089671438864102814350385648747165832010614366132173102768
902855220001
>>> &bye
Did I say something wrong?
Session transcript written on xintsession-210609_12h00.tex
 )
No pages of output.
Transcript written on xintsession.log.
\end{everbatim}


\subsection{\ctanpackage{zeckendorf}}

This package enriches the \csbxint{eval} interface with tools related
to Fibonacci numbers and Bergman $\phi$-representation.  In particular,
it implements the Knuth Fibonacci multiplication.  It can be used
either as a \LaTeX{} package, or with Plain \eTeX{}, or also on the
command line via \verb+rlwrap etex zeckendorf+.


\subsection{\ctanpackage{polexpr}}

The package \ctanpackage{polexpr} enriches the \csbxint{eval} syntax
(but not the one of \csbxint{floateval}) with a polynomial type with
associated constructor |pol([c0,c1,...])|, and polynomial specific
functions such as |polgcd(pol1, pol2, ...)|.

Full usage of polynomials (and algebraic notations |c_0 + c_1 x + c_2
x^2 + ...| for input and also output) goes through a dedicated |\poldef|
parser which is based upon \csbxint{defvar}/\csbxint{deffunc} and is a
necessary step to then access via a dedicated macro interface operations
such as identifying all rational roots and isolating all real roots to
arbitrary precision.

The simplest manner to experiment with \ctanpackage{polexpr} is via the
|&pol| mode of \ctanpackage{xintsession}.

\subsection{\ctanpackage{bnumexpr}}

This \LaTeX{} package loads \xintcorename and \xintbinhexname and
provides \cs{bnumeval} which is a scaled-down \csbxint{iieval} (omitting
support for nested structures, functions, variables, boolean branching,
etc...).  It can be used with Plain e\TeX, thanks to
\ctanpackage{miniltx}.  For this, use |\input miniltx.tex| followed by
|\input bnumexpr.sty| (remark: \ctanpackage{miniltx} is not needed for
\xintexprname).


\cs{bnumeval} is thus a boosted \cs{inteval} which addition of support
for arbitrarily large integers, powers with |**| and |^|, rounded
division with |/|, floored division with |//| and associated modulo
|/:|, factorials via |!| postfix operator, comma separated multi-item
expressions.

It also supports as \csbxint{iieval} does the |'|, |"|, |0b|, |0o| and
|0x| input prefixes and the optional arguments |[b]|, |[o]|, or |[h]|.

Further, it provides an interface (which does not exist with
\xintexprname) to let all operations be done by macros of one's own
choosing, as replacement for some or all of the operations by default
implemented via the help of \xintcorename and \xintbinhexname.  It even
makes it possible to add to the syntax extra infix or postfix operators
and to modify the precedence levels of those already defined.


\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 a ``|\printnumber|'' macro,  which is not provided by
  the package.  A primitive form would be:
\everb|@
\def\allowsplits #1{\ifx #1\relax \else #1\hskip 0pt plus 1pt\relax
                    \allowbreak
                    \expandafter\allowsplits\fi}%
\def\printnumber #1{\expandafter\allowsplits \romannumeral-`0#1\relax }%
|

This macro triggers ``\fexpan sion'' of its argument (and indeed
\csbxint{eval} and friends expand completely under such trigger), then
it goes through the computation result character by character inserting
some stretchable glue in-between them.  The |\allowbreak|'s (which is
known both to Plain \TeX{} and to \LaTeX{} and perhaps other formats,
else use |\penalty0\relax|) are here only for the case of usage in
inline math mode (they are ineffective in display math mode).  The
actual |\printnumber| used for building this documentation is a more
sophisticated variant (never used in math mode), which handles comma
separated lists without gobbling spaces and prints continuation symbols
at line endings.

\subsection{Repository}

It is at \url{https://github.com/jfbu/xint}.  At this stage, it does not
serve for real-time development but only proposes all actual successive
\href{https://ctan.org}{CTAN} releases since 2013.  Use it to report
issues.  Don't forget to include |@jfbu| in the ticket else I will not
be pinged.

A front page at \url{https://jfbu.github.io/xint} provides, in addition
to the present |xint.pdf| and to |README.md| a file |CHANGES.html|,
which contains the complete list of changes relevant to user level
since the initial release of the package:
%
\centeredline{\url{https://jfbu.github.io/xint/CHANGES.html}}

Its version |xintchanges.md| in Markdown format is included in the 
\href{https://ctan.org/pkg/xint}{CTAN} upload,
%
\centeredline{|texdoc xintchanges.md|}

Warning: I don't have the time to maintain perfectly such large
documentation.  It combines old documentation which never really got
updated and may be locally obsolete with more recent stuff mostly
written on occasion of the |1.4| release of January 2020 and the |1.4e|
one of May 2021, and the intervening changes might also have made some
of it not completely accurate, despite my best efforts.

\subsection{License and installation instructions}

\label{ssec:install}

The \xintbundlename components are made available under the
\href{http://www.latex-project.org/lppl/lppl-1-3c.txt}{LaTeX Project
  Public License 1.3c}.

They are available at \href{https://ctan.org/pkg/xint}{CTAN}. They are
included in all major \TeX\ distributions, thus there is probably no
need for a custom install: just use the package manager to update from
time to time to latest version.

\clearpage
\expandafter\let\csname Start herenameUp\endcsname\undefined
\csname xintexprnameUp\endcsname
\section{Syntax reference and user guide}
\RaisedLabel{sec:expr}

\localtableofcontents

\subsection{Introduction: the three-parsers way}


\begin{framed}
  \textbf{WARNING:} this documentation goes sometimes into too much
  details, and does need some improvements.  But there is no time for
  that at |1.4n|.  Although people do not believe me when I say that,
  there is ample intellectual reward in actually reading the documentation,
  and it would be nice if at least, at last someone on Earth did,
  once (as \textsc{Jürgen Gilg} some years back).
\end{framed}

\xintexprname provides three numerical expression parsers corresponding to
these three respective tasks:
\begin{description}[noitemsep]
\item[\csa{xintfloateval}:] evaluations with floating point numbers; the default precision is with 16 digits, it can be set via  \csbxint{SetDigits*},
\item[\csa{xinteval}:] exact evaluations with fractions, decimal fixed point numbers, numbers
  in scientific notation, with no size limitation,
\item[\csa{xintiieval}:] evaluations allowing only integers with no size limitation.
\end{description}

% They are designed to be compatible with expansion only context.  All
% computations ultimately rely on (and reduce to) usage of the |\numexpr|
% primitive from \eTeX{}%
% %
% \footnote{It can handle only integers, and they must be at most
% $2^{31}-1={}$\dtt{\the\numexpr"7FFFFFFF\relax}. Thus some work has to be done
% to handle arbitrarily big integers or arbitrary float precision.}.
% %
% These \eTeX{} extensions date
% back to 1999 and are by default incorporated into the |pdftex|
% etc...\@{} executables from major modern \TeX{} installations for more than
% fifteen years now.

The interface is:
\begin{itemize}

\item \csbxint{floateval}\oarg{Q}\marg{expression} does floating point
  computations with a given precision, which defaults to |16|. The precision
  |P| can be set using \csbxint{Digits*}|:=P\relax| or \csbxint{SetDigits*}|{P}|
  syntaxes.

  Its optional argument |[Q]|, if present, means to do a \emph{final} float
  rounding to a mantissa of |Q| digits (this thus makes sense only if
  |Q<P|).

  A negative |Q| is allowed and means to round to |P+Q| digits only.

  Prior to |1.4k| the optional argument \oarg{Q} had to be located
  \emph{within} the braces at the start of the expression.  The legacy
  syntax is and will keep being allowed.



  The infix operator \oper{/} will compute the correct rounding of the exact
  fraction. The operator \oper{//} is floored division and \oper{/:} is its
  associated modulo (see also \func{divmod}).
\begin{everbatim*}
\begingroup
\xintDigits:=64\relax
\xintfloateval{sqrt(3)}
\endgroup 
\end{everbatim*}

  The four basic operations and the square root achieve \emph{correct
    rounding.}\footnote{when the inputs are already floating point numbers
    with at most |P|-digits mantissas.}

  On output, \csbxint{floateval} uses \csbxint{PFloat} for each numeric
  leaf. This can be modified (cf.\@{} \csbxint{floatexprPrintOne}).

\item \csbxint{eval}\marg{expression} handles integers, decimal numbers,
  numbers in scientific notation and fractions. The algebraic computations are
  done \emph{exactly}, and in particular \oper{/} simply constructs
  fractions. Use \oper{//} for floored division.
\begin{everbatim*}
\xinteval{add(x/(x+1), x = 1000..1014)}\par
\end{everbatim*}
The output in this specific example came out irreducible.  In general one needs
a \func{reduce} wrapper for an irreducible output:
\begin{everbatim*}
\[\xinteval{subs((y,reduce(y)), y = mul(x/1000, x = 10..[10]..90))}\]
\end{everbatim*}


Arbitrarily long numbers are allowed in the input. The space character
(contrarily to the situation inside |\numexpr|) and also the underscore
character (as allowed in Python too) can serve to separate groups of digits
for better readability.  But the package currently provides no macros to let
the output be formatted with such separators.
\begin{everbatim*}
\xinteval{123_456_789_012^5}
\end{everbatim*}

Hexadecimal,\NewWith{1.4n} octal and binary (with fractional part allowed) can be
input using suitable prefixes: respectively |"| or |0x|, |'| or |0o|,
and |0b|:
\begin{everbatim*}
\xinteval{0b111111111111.111111111111}
\end{everbatim*}

\item \csbxint{ieval}\oarg{D}\marg{expression} is the same parser as
  \csbxint{eval}, i.e. accepts the same inputs and does all computations
  exactly in the same manner, but it then rounds its final result to the
  nearest integer, or, in case there is an optional argument |[D]|, to:
  \begin{itemize}
  \item if |D>0|: the nearest fixed point number with |D| digits after the
    decimal mark,
  \item if |D=0|: the nearest integer (as for \csbxint{ieval} with no optional argument),
  \item if |D<0|: the rounded quotient by |10^(-D)|.
  \end{itemize}
  
  The optional argument \oarg{D} can also be located
  \emph{within} the braces at the start of the expression (this was actually
  the legacy syntax until |1.4k|).

\item \csbxint{iieval}\marg{expression} executes computations \emph{on (big)
    integers only.} It is (only slightly) faster than \csbxint{eval} for
  the same expression.

  Attention: the forward slash \oper{/} does the \emph{rounded} integer
  division to match behaviour of |\numexpr|. The \oper{//} operator does
  floored division as in \csbxint{eval}. The \oper{/:} is the associated
  modulo operator (we could easily let the catcode 12 |%|
  character be an alias, but using such an unusual percent character
  would be a bit cumbersome in a \TeX{} workflow, if only for matters of
  syntax highlighting in \TeX-aware text editors).
\begin{everbatim*}
% add the i^5 only if i is a multiple of 7
\xintiieval{add((i/:7)?{omit}{i^5}, i=1000..1020)}
\end{everbatim*}

  An\NewWith{1.4n} optional argument |[h]|, |[o]|, or |[b]| says to convert the output
  to hexadecimal, octal or binary:
\begin{everbatim*}
\xintiieval[h]{3^100}
\end{everbatim*}

\end{itemize}

% The user can define variables and functions. Definition of functions is either
% per parser (\csbxint{deffunc}, \csbxint{deffloatfunc}, ...), but there are
% some restrictions, or generic (\csbxint{NewFunction}) but the latter is only
% syntactic sugar for function-like disguise of a \TeX{} macro having not done
% any pre-parsing.

\begin{framed}
  Please note:
  \begin{itemize}[noitemsep]
  \item If you find that \csbxint{floateval} is too much of a mouthful,
    you can create an alias named, for example, |\fpeval|.  Oops, no,
    that is \LaTeX3 very efficient floating point engine (for 16 decimal
    digits of precision). It is faster than \csbxint{floateval} due to
    the excellent coding and algorithms it employs, but also for reasons
    having to do in part with the fact that \xintname initially was
    created to handle big integers only, and support for arbitrary
    precision floating point was added on top of that, via some
    expedients which have never been refactored, yet.
  \item Although \csbxint{eval} manipulates arbitrarily long integers or
    fractions it also accepts scientific notation on input, as well as
    all the mathematical functions (evaluated using the prevailing
    digits precision), and (depending on customization) can thus produce
    also scientific notation on output. But be careful that for example
    a multiplication will then automatically roughly double the number
    of digits in general (some operations avoid extending mantissas,
    so short mantissas may remain short).
  \item So far, individual operations and the printing routine of
    \csbxint{eval} do not automatically reduce fractions to their lowest
    terms.
  \end{itemize}
\end{framed}

There is a core syntax:
\begin{itemize}[nosep]
  \item \csbxint{expr}\meta{expression}|\relax|,
  \item \csbxint{iexpr}\meta{expression}|\relax|,
  \item \csbxint{iiexpr}\meta{expression}|\relax|,
  \item \csbxint{floatexpr}\meta{expression}|\relax|,
  \item \csbxint{boolexpr}\meta{expression}|\relax|.
\end{itemize}
\csbxint{boolexpr}\meta{expression}|\relax| does all computations like
\csbxint{expr} then converts all (non-empty) leaves%
%
\footnote{Currently, empty leaves are output using \csbxint{exprEmptyItem},
  i.e.\@{} default to \dtt{\xintexprEmptyItem}. This may change.}
%
to |true| or |false| (cf.\@{} \csbxint{boolexprPrintOne}). There is no
|\xintbooleval|.\CHANGED{1.4m}\footnote{This was |True| and |False| prior
  to |1.4m|.}

Formerly the \csbxint{expr}|...\relax| legacy syntax had to be prefixed
by |\xintthe| if in typesetting context, else an error was raised
(deliberately).  The |\xintthe| prefix was made optional at |1.4|.

In an |\edef| these constructs expand to some braced nested data, all
computations having been completely done, which is prefixed with some
|\protected| \myenquote{typesetter} macros.

In an |\edef|, \csbxint{eval} (in contrast to \csbxint{expr}), or
\csbxint{floateval} (in contrast to \csbxint{floatexpr}) expand the
\myenquote{typesetting macros} and the final complete expansion consists of
explicit digits and other characters such as those of scientific
notation or square brackets.%
%
\footnote{\csbxint{eval} and \csbxint{expr} both expand completely in exactly
  two steps. And \csbxint{expr} expands fully under \fexpan sion (of the
  |\romannumeral0| or |-`0| type). As per \csbxint{eval} attention that it may
  expand to nothing, then naturally \fexpan sion propagates to tokens
  following up in the input stream.}

In \LaTeX\ it is possible to use the core syntax
\csbxint{expr}\meta{expression}|\relax| also in so-called moving arguments,
because when written out to a file the final expansion outcome uses only
standard catcodes and thus will get retokenized and expand as expected if
it has been written to an external file which is then reloaded.

One needs \csbxint{eval} et al.\@{} only if one really wants the final digits
(and other characters), for example in a context where \TeX{} expects a number
or a dimension.

As alternative to \csbxint{eval}\marg{expression}, an equivalent is
\csbxint{the}\csbxint{expr}\meta{expression}|\relax|. Similarly \csbxint{the}
can prefix all other core parsers. And one can also use \csbxint{theexpr} as
shortcut for \csbxint{the}\csbxint{expr}.

Doing exact computations with fractions leads very quickly to very big results
(and furthermore one needs to use explicitly the |reduce()| function to
convert the fractions into smallest terms). Thus most probably what you want
is \csbxint{floateval} and \csbxint{floatexpr}.


\subsection{Output customization}

\subsubsection{\csh{xintfloatexprPrintOne} et al{.} for numerical values}
\label{xintexprEmptyItem}
\label{xintexprPrintOne}
\label{xintiiexprPrintOne}
\label{xintiiexprPrintOneHex}
\label{xintiiexprPrintOneOct}
\label{xintiiexprPrintOneBin}
\label{xintiexprPrintOne}
\label{xintfloatexprPrintOne}
\label{xintboolexprPrintOne}

The package provides only minimal facilities for formatting the output
from \csbxint{eval} or \csbxint{floateval} or\dots.  And this output may
well consist of comma separated values, even nested ones with, by
default, square brackets. First we explain how to influence the handling
of individual \myenquote{leaves}.

Here are the default definitions to this effect:
\begin{everbatim}
\def\xintexprEmptyItem{[]}                               % (all parsers)
\def\xintexprPrintOne  #1{\xintFracToSci{#1}}            % \xinteval
\def\xintiexprPrintOne #1{\xintDecToString{#1}}          % \xintieval
\def\xintiiexprPrintOne#1{#1}                            % \xintiieval
\def\xintfloatexprPrintOne [#1]#2{\xintPFloat[#1]{#2}}   % \xintfloateval
\def\xintboolexprPrintOne#1{\xintiiifNotZero{#1}{true}{false}}
\end{everbatim}
They can be re-defined to one's wishes.  If configured to do anything
non expandable they must be |\protected|. \LaTeX\ users will want to use
|\RenewDocumentCommand| for this.
\begin{TeXnote}
  \begin{itemize}
  \item Actually, the defaults are more done in the style
\begin{everbatim}
\let\xintexprPrintOne\xintFracToSci
\end{everbatim}
    thus sparing grabbing the argument |#1|. And one can do
\begin{everbatim}
\def\xintexprPrintOne{\xintFracToSci}
\end{everbatim}
    too.
  \item |\xintexprPrintOne| defaults in truth to some private variant of
    \csbxint{FracToSci} with exactly the same output but able to understand
    only certain limited types of inputs as used internally.
  \item |\xintiiexprPrintOne| is used with \csbxint{iieval}.  But it
    gets replaced with |\xintiiexprPrintOneHex|,
    |\xintiiexprPrintOneOct|, or |\xintiiexprPrintOneOct| if the
    optional argument |[h]|, |[o]|, or |[b]| is used.\NewWith{1.4n}  These macros
    default to respectively \csbxint{DecToHex}, \csbxint{DecToOct} and
    \csbxint{DecToBin}.
  \item |\xintfloatexprPrintOne| defaults in fact to a private variant of
    \csbxint{PFloat} which assumes the optional argument |[P]| is present as
    it will be the case always in this context.  This optional argument
    |[P]| is the optional argument |[Q]| of \csbxint{floateval} (or
    |Digits+Q| if |Q<0|).
  \item The typesetter for \csbxint{iiexpr} simply prints ``as is'', but this
    may change in future, if some internal format is used requiring a
    conversion step.
  \end{itemize}
\end{TeXnote}

Here is a possibly not up-to-date list of macros of interest, whose
documentations you might consider reading (the first two require math
mode):
\begin{itemize}[nosep]
\item \csbxint{TeXFromSci},
\item \csbxint{TeXFrac},
\item \csbxint{DecToString},
\item \csbxint{PRaw},
\item \csbxint{FracToSci},
\item \csbxint{FracToDecimal},
\item \csbxint{PFloat},
\item and \csbxint{FloatToDecimal}.
\end{itemize}
Naming scheme, as one can see, has been pretty much incoherent, apologies.

Among packages providing macros formatting numeric values, there are
\ctanpackage{numprint} and its macro |\np| (or |\numprint| without the
option |np|), and \ctanpackage{siunitx}
and its |\num|, and possibly more packages not known to the author.%
%
\footnote{There does not seems to be yet a \LaTeX\ user level interface to the
  \liiistrformat\ package, part of |l3experimental|, which provides an
  implementation of the Python |format| function.}
%
These macros are suitable in combination with \csbxint{Float} as in the
example below to customize the \csbxint{floateval} output.
% 27 mai 2022, en effet \num{1/7} ne marche pas et \numprint{1/7} non plus
Numerical output from \csbxint{eval} is more challenging as
individual values may naturally contain the |/| character for fractions which the
above mentioned packages will not know how to handle, as far as I know.


Here an example, with \LaTeX{} and |\num| from \ctanpackage{siunitx}:
\begin{everbatim}
\RenewDocummentCommand\xintfloatexprPrintOne{o m}{\num{\xintFloat[#1]{#2}}}
\end{everbatim}
We could have used here simply |\def| with delimited parameters |[#1]#2| because:
\begin{itemize}[nosep]
\item the optional argument will always be present at time of use,
\item |\num| is a |\protected| macro.
\end{itemize}
Note that when using only |\def| for the definition, the argument of |\num|
is getting to be expanded first, but |\num| would have done that anyhow.

With \ctanpackage{numprint}, one can similarly do:
\begin{everbatim}
\RenewDocumentCommand\xintfloatexprPrintOne{o m}{\numprint{\xintPFloat[#1]{#2}}}
\end{everbatim}
This used \csbxint{PFloat} rather than \csbxint{Float} as with |\num|.
This is because (in my limited testing) |\numprint| with not silently
remove a zero scientific exponent but it will typeset it, for example as
$1.5\cdot10^0$.  So we use our own \csbxint{PFloat} poor man
\myenquote{prettifier}.

Maybe you want to use a macro which is unable to have
|\xintPFloat[#1]{#2}| as argument because it needs to see only a number
in scientific notation and nothing else.  If that macro is |\protected|,
do the definition with |\def|.  It it is not |\protected| and not
purely expandable either, one can do this:
\begin{everbatim}
\protected\def\myfoo{\foo}%<<<--- with options perhaps
\def\xintfloatexprPrintOne[#1]#2{\myfoo{\xintPFloat[#1]{#2}}}
\end{everbatim}
Then when |\myfoo| finally expands, its argument has been expanded already.


The current behaviour of \csbxint{floateval} corresponds to this set-up:
\begin{everbatim}
\def\xintfloatexprPrintOne [#1]#2{\xintPFloat[#1]{#2}}
\end{everbatim}
and to this default configuration of \csbxint{PFloat}:
\begin{everbatim}
\def\xintPFloatE{e}
\def\xintPFloatZero{0}
\def\xintPFloatIntSuffix{}
\def\xintPFloatLengthOneSuffix{}
\def\xintPFloatNoSciEmax{5}
\def\xintPFloatNoSciEmin{-4}
\def\xintPFloatMinTrimmed{4}
\end{everbatim}

With the custom replacement
\begin{everbatim}
\def\xintfloatexprPrintOne{\xintFloatToDecimal}
\end{everbatim}
the \csbxint{floateval} output will use decimal fixed point notation,
i.e.\@{} no scientific exponents, and as many zeros as are needed (but no
more, as trailing zeros will be removed from the significant digits).
Here is an example comparing outputs from the
default configuration and custom ones:
\begingroup % DÉBUT DU GROUPE POUR DES EXEMPLES
\begin{everbatim*}
\xintfloateval{exp(-32.456)/2000} (default, i.e. PFloat)\newline
\def\xintfloatexprPrintOne{\xintFloatToDecimal}%
\xintfloateval{exp(-32.456)/2000} (FloatToDecimal)\newline
\def\xintfloatexprPrintOne[#1]#2{\xintTeXFromSci{\xintFloat[#1]{#2}}}%
$\xintfloateval{exp(-32.456)/2000}$ (TeXFromSci on Float)\par % math mode required
\end{everbatim*}

Some examples showing now the effect of sensible customizations on \csbxint{eval}:
\begin{everbatim*}
\xinteval{exp(-32.456)/2000} (default, i.e. FracToSci)\newline
\def\xintexprPrintOne{\xintFracToDecimal}%
\xinteval{exp(-32.456)/2000} (FracToDecimal)\newline
\def\xintexprPrintOne#1{\xintTeXFromSci{\xintFracToSci{#1}}}%
$\xinteval{exp(-32.456)/2000}$ (TexFromSci on FracToSci)\par  % math mode required
\end{everbatim*}
Notice that the |/2000| denominator remains ``as is'' in the
output, in conformity with the documented behaviour of
\csbxint{FracToSci} in the first example and of \csbxint{FracToDecimal}
for the second example.  This has not changed since |1.4| (the handling
of the numerator part has changed at |1.4e| and again slightly at
|1.4k|, the zero value being now always printed as \dtt{0} and not
\dtt{0} or \dtt{0.0} depending on the input) but is to be considered
unstable and undecided so far.

A slightly more costly typesetter could be for example:
\begin{everbatim}
\def\xintexprPrintOne#1{\xintDecToStringREZ{\xintIrr{#1}}}
\end{everbatim}
Then
\begin{itemize}[nosep]
\item the fraction (inclusive of its power of ten part) will be reduced
  to lowest terms (see \csbxint{Irr}),
\item next the trailing zeros will be moved as an exponent (positive or
  negative) to the numerator,
\item this numerator with a power of ten part will be printed in decimal
  fixed point notation, with as few zeros as are needed,
\item and finally the denominator |B|, which has been trimmed of trailing
  zeros, will be printed as |/B| or not at all if |B=1|.
\end{itemize}
With the
use case above:
\begin{everbatim*}
\def\xintexprPrintOne#1{\xintDecToStringREZ{\xintIrr{#1}}}
\xinteval{exp(-32.456)/2000}\par
\end{everbatim*}
This trailing |/2| is somewhat of a pain, but as documented and
mentioned already \csbxint{DecToStringREZ} currently has not been
educated to identify its presence and handle it. Slightly faster (see
\csbxint{PIrr}) is
\begin{everbatim}
\def\xintexprPrintOne#1{\xintDecToStringREZ{\xintPIrr{#1}}}
\end{everbatim}
which with the used example produces the same output.

One can also consider this for math mode:
\begin{everbatim*}
\def\xintexprPrintOne#1{\xintTeXFromSci{\xintDecToStringREZ{\xintIrr{#1}}}}
$\xinteval{exp(-32.456)/2000}$\par
\end{everbatim*}
See our hesitations about what \csbxint{TeXFromSci} should do with
denominators.

\begin{TeXnote}
  One can hope that in future \csbxint{DecToString} will identify
  denominators being products of only two's and five's, but even then of
  course \csbxint{TeXFromSci} will have to decide how to handle other
  denominators.
\end{TeXnote}

\endgroup % FIN DU GROUPE POUR LES EXEMPLES
 

\begin{TeXnote}
  The macro used as customization of \csbxint{exprPrintOne} (whose default is
  a private variant of \csbxint{FracToSci} with exactly same output) must
  understand the internal \xintfracname format |A/B[N]|, but with the |/B| and
  |[N]| parts being only optional.  This is not a problem when using for this
  task (nested) macros of \xintfracname, as they of course accept such
  inputs as argument and in fact much more general ones.

  In particular one can benefit from \csbxint{Raw}, or \csbxint{RawBraced}, to
  convert the argument into a well defined shape (|A/B[N]| for the former and
  |{N}{A}{B}| for the latter) and then work from there.

  The macro used by \csbxint{floatexprPrintOne} has the guarantee that the
  |[P]| will be always present at expansion time.

  The customization should be compatible with being exposed to |\expanded|
  (which is like expansion in an |\edef|), either from being completely
  expandable or at the opposite from being |\protected|. \LaTeX2e commands
  defined via |\newcommand| as macros with one optional parameter are not
  compatible with this requirement.

  Attention! The interface requirements described above for the macros
  customizing the behaviours of \csbxint{exprPrintOne} and
  \csbxint{floatexprPrintOne} may change at any release... as they
  depend on some internal structures and it is not certain backwards
  compatiblity will be maintained systematically in case of evolution.
\end{TeXnote}

\subsubsection{\csh{xintthealign} for output of general oples}
\label{xintthealign}

With \csbxint{thealign} one can get nested data use a \TeX{} alignment in the
output.  Here is an example :
\begin{everbatim*}
\xintthealign\xintexpr ndseq(1/(i+j), i = 1..10; j=1..10)\relax
\end{everbatim*}
Attention, this \csa{xintthealign} must be a prefix to \csbxint{expr},
or \csbxint{floatexpr} etc..., but there will be low-level \TeX\ errors
if it is used to prefix \csbxint{eval} et al. or \csbxint{theexpr} et al.

It is possible to customize the behaviour of |\xintthealign|.  For example:
\begin{everbatim}
\protected\def\xintexpralignbegin       {\halign\bgroup\tabskip2ex\hfil##&&##\hfil\cr}%
\def\xintexpralignend                   {\crcr\egroup}% removed \protected at 1.4c
\protected\def\xintexpralignlinesep     {,\cr}% separates "lines"
\protected\def\xintexpralignleftsep     {&}% at left of first item in a "line"
                                           % (after "left bracket")
\protected\def\xintexpraligninnersep    {,&}% at the left of non-first items
\protected\def\xintexpralignrightsep    {&}% at right of last item in a "line"
                                           % (before "right bracket")
\protected\def\xintexpralignleftbracket {[}%
\protected\def\xintexpralignrightbracket{]}%
\end{everbatim}
The above definitions use |\protected| with no strong reason, as the
replacement tokens are not expanding anyhow, but the idea is that this
allows to execute a computation via an |\edef| and later one can change
the meaning of the auxiliary macros depending on what one wants to do
with the expansion result.

\begin{TeXnote}
  \csa{xintexpralignend} is expanded once, after the body has been submitted
  to exhaustive expansion (|\expanded| induced), and prior to the expansion of
  \csa{xintexpralignbegin}.
\end{TeXnote}

Although we will try to keep stable the way \myenquote{regular arrays} as in the
above example are rendered by default,\UNSTABLE{} the |\xintthealign|
macro (and its associated customizability) is to be considered
work-in-progress and may experience breaking changes.

Use for example this for outputting to a file or a terminal:%
%
{\catcode`^ 12
\footnote{With the |xetex| engine this will need its |-8bit| option else
  the |^^J| in |\xintexpralignlinesep| will be printed literally instead
  of being converted into a line separator in the file or terminal output.}}
\begin{everbatim}
% Better here without \protected.
% We assume here \newlinechar has the LaTeX setting.
\def\xintexpralignbegin       {}%
\def\xintexpralignend         {}%
\def\xintexpralignlinesep     {,^^J}% separates "lines"
\def\xintexpralignleftsep     { }% at left of first item in a "line" (after brackets)
\def\xintexpraligninnersep    {, }% at the left of non-first items
\def\xintexpralignrightsep    { }% at right of last item in a "line" (before brackets)
\def\xintexpralignleftbracket {[}%
\def\xintexpralignrightbracket{]}%
\end{everbatim}

In the \LaTeX{} example next using a |pmatrix| environment, |\noexpand|
rather than |\protected| is used.  This environment will not break
across pages, contrarily to the display produced by the default
\csbxint{thealign} configuration which uses \TeX{}'s |\halign|.
%\kern10\baselineskip
%\hbox{Big empty space here}
%\kern-11\baselineskip
\begin{everbatim*}
\[
\def\xintexpralignbegin       {\begin{pmatrix}}%
\def\xintexpralignend         {\end{pmatrix}}%
\def\xintexpralignlinesep     {\noexpand\\}% needed to counteract an internal \expanded
\def\xintexpraligninnersep    {&}%
\let\xintexpralignleftbracket\empty  \let\xintexpralignleftsep\empty
\let\xintexpralignrightbracket\empty \let\xintexpralignrightsep\empty
% by default amsmath matrices can have 10 columns at most
% (cf amsmath documentation for what to do to allow more)
l.c.m.=\xintthealign\xintiiexpr  ndmap(lcm, 1..12; 1..10)\relax
\]
\end{everbatim*}

\subsection{Built-in operators and their precedences}



The parser implements precedence rules based on concepts which are summarized
below (only for binary infix operators):
\begin{itemize}[noitemsep]
\item an infix operator has two associated precedence levels, say |L| for left
  and
  |R| for right,
\item the parser proceeds from left to right, pausing each time it has found a
  new number and an operator following it,
\item the parser compares the left-precedence |L| of the new found operator to
  the right-precedence |R_last| of the last delayed operation (which already
  has one argument and would like to know if it can use the new found one): if
  |L| is at most equal to it, the delayed operation is now executed, else the
  new-found operation is kept around to be executed first, once it will have
  gathered its arguments, of which only one is known at this stage.
\end{itemize}
This means for example in the case of the multiplication \oper{\lowast} and the
division operators \oper{/}, \oper{//}, \oper{/:} that they are parsed in a
left-associative way because they all share the same (left and right)
precedence level. This is the case with the analogous operators from the
Python language, as well.

At |1.4g| the power operators were changed to act in a right associative
way. Again, this matches the behaviour of e.g.\@{} Python:%
\begin{everbatim*}
\xinteval{2^-3^4}
\end{everbatim*}


\makeatletter
\def\@floatboxreset{\@setminipage}% faudra contrôler celui-là
\makeatother
\begin{table}[p]
\edef\Ampersand{\string&}%
\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 syntax elements whose
    execution
    is done prior to 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 the \oper{\empty\lowast} unpacking operator,
    \item intrinsic constituents of numbers: decimal mark \oper{\strut.},
      \oper{e} and \oper{E} of scientific notation, hexadecimal prefix
      \oper{"}.
    \end{itemize}\par}%
  \\\hline\hline
   Precedence&``Operators'' at this level\strut\\
  \hline
  \prec{20}& postfix \oper{!} and branching \oper{?}, \oper{??} operators\strut\\\hline
%
  \prec{-}& minus sign as unary operator inherits the right-\hskip0pt precedence of
  the infix operator it follows, if that precedence is higher than the one of
  binary \oper{+} and \oper{-}, else it inherits the latter\strut\\\hline
%
  \prec{18} (17)& \oper{\string^} and \oper{\lowast\lowast} are synonymous;
  they act in a right-associative way (\textcolor[named]{Red}{\bfseries Changed at 1.4g!})\strut\\\hline
%
  \prec{16} (14)& \hyperref[ssec:tacit multiplication]{Tacit
    multiplication} has an elevated (left) precedence\strut\\\hline
%
  \prec{14}& \oper{\lowast}, \oper{/}, \oper{//} (floored division), 
               and \oper{/:} (associated modulo, alias
               \oper{'mod'})\strut\\\hline
%
  \prec{12}& \oper{+}, \oper{-}\strut\\\hline
%
  \prec{10}& \oper{<}, \oper{>}, \oper{==}, \oper{<=}, \oper{>=},
               \oper{!=} (they can be chained)\strut\\\hline
%
  \prec{8}& Boolean conjunction \oper{\Ampersand\Ampersand} and
              its alias \oper{'and'}\strut\\\hline
%
  \prec{6}& Boolean disjunction \oper{\string|\string|} and
              its alias \oper{'or'}. Also \oper{'xor'} and
              \oper{\strut..}, \oper{..[},
              \oper{{]..}}, and \oper{:} have
              this precedence\strut\\\hline
%
  \prec{4}& the brackets for slicers and extractors \oper{\empty[},
              \oper{\empty]}\strut\\\hline
%
  \prec{3}& the comma \oper{,}\strut\\\hline
%
  \prec{2}& the bracketers \oper{[}, \oper{]} construct nestable \myenquote{arrays}\strut\\\hline
%
  \prec{1}& the parentheses \oper{(}, \oper{)}, and the semi-colon
              \oper{;} in \func{iter}, \func{rseq}, and further structures\strut\\\hline
%
\hline
%
  \multicolumn{2}{|p{.6\textwidth}|}{%
    \begin{itemize}[nosep]
    \item Binary operators have a left and a right precedence, which for
      most coincide. The right precedence is indicated within parentheses.
    \item 
\hyperref[ssec:tacit multiplication]{Tacit multiplication} has an elevated
left precedence level: |(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.
    \end{itemize}
}\\\hline
  \end{tabular}
  \caption{Precedence levels}
  \label{tab:precedences}
\etoctoccontentsline {xinttable}{\protect\emph{Table of precedence levels of operators}}
\restorehtdpstrutbox
\end{table}

The entries of \autoref{tab:precedences} are hyperlinked to the more detailed
discussion at each level. In these entries the number within parentheses
indicates the right-\hskip0pt precedence, if it differs from the left.

\begin{description}
%[parsep=0pt, listparindent=\leftmarginiii]
% [parsep=0pt,align=left,itemindent=0pt,
%   leftmargin=\leftmarginii, labelwidth=\leftmarginii, labelsep=0pt,
%   labelindent=0pt, listparindent=\leftmarginiii]
\edef\Ampersand{\string&}%

\precdesc{$\infty$} At this highest level of precedence, one finds:
\begin{description}
\item[{\hyperref[ssec:builtinfunctions]{functions} and
       \hyperref[ssec:uservariables]{variables}}]
  Functions (even the logic functions
  \func{!} and \func{?} whose names consist 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.)

  \operdesc{\empty\lowast} Python-like \myenquote{unpacking} prefix operator. Sometimes one
  needs to use it as function |*()| (but I can't find an example right now)
  but most of the time parentheses are unneeded.

  \operdesc{\strut.} is decimal mark; the number scanner treats it as an inherent,
  optional and unique component of a being formed number.
  |\xintexpr 0.^2+2^.0\relax| is interpreted as |0^2+2^0| and
  thus produces \dtt{\xintexpr 0.^2+2^.0\relax}.

  Since release |1.2| an isolated decimal mark is illegal
  input in the \xintexprname parsers (it remains legal as argument to the
  macros of \xintfracname).

  \operdesc{e} scientific notation.

  \operdesc{E} scientific notation. For output, see \csbxint{PFloatE}.

  \operdesc{"} prefix for hexadecimal input. Only uppercase letters, and
  one optional |.| separating integer and fractional hexadecimal parts.

\begin{everbatim*}
\xintexpr "FEDCBA9876543210\relax\newline
\xintexpr ".FEDCBA9876543210\relax\newline
\xintexpr 16^5-("F75DE.0A8B9+"8A21.F5746+16^-5)\relax
\end{everbatim*}

  It is possible that in future the |"| prefix could be dropped in favour of
  |0x| prefix.  This would free |"| to be used for input of \myenquote{string}-like
  entities.
\end{description}


\precdesc{20}
  The postfix operators |!| and the branching conditionals |?|, |??|.
\begin{description}
  \operdesc{!} computes the factorial of an integer.

  \operdesc{?} 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.}

  \operdesc{??} 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{-} As unary operator, the minus sign inherits as precedence the
  minimum of |12| (which is the precedence for addition and subtraction) and
  of the (right-) precedence of the operators preceding it (if any).
\begin{everbatim*}
\xintexpr -3-4*-5^-7, (-3)-(4*(-(5^(-7))))\relax\newline
\xintexpr -3^-4*-5-7, (-((3^(-4))*(-5)))-7\relax\newline
|2^-10| gives \xintexpr 2^-10\relax\space
\end{everbatim*}and is thus perfectly legal, no need for parentheses.

  The |+| character as prefix unary operator is simply ignored during
  input parsing.

\precdesc{18}
\begin{description}
\operdesc{\string^}
\operdesc{\lowast\lowast} Both compute powers. They act in a right associative
way.
\begin{everbatim*}
\xintiiexpr 2^3^4\relax
\end{everbatim*}
\end{description}
% et:
% *2^-3^-4;
% (@_1)    0.991479137495678
% *2**-3**-4;
% (@_2)    0.991479137495678
% Python:
% >>> 2**-3**-4;
% 0.9914791374956781

\precdesc{16} see \hyperref[ssec:tacit multiplication]{Tacit multiplication}.

\precdesc{14}
\begin{description}
\operdesc{\lowast} multiplication

\operdesc{/} division:
  \begin{itemize}
  \item in \csbxint{eval}: exact division in the field of rational numbers (not
    automatically reduced to lowest terms),
  \item in \csbxint{floateval}: correct rounding of the exact division; the two
    operands are, if necessary, float-rounded before the fraction is
    evaluated and rounded (to obtain the correcty rounded |A/B|
    without prior rounding of |A| and |B| see \func{qfloat}),
  \item in \csbxint{iieval}: for compatibility with the legacy behaviour of
    |/| in |\numexpr|, it rounds the exact fraction \emph{with half-integers
      going towards the infinity of the same sign}.
   \end{itemize}
   The division is left-associative. Example:
\begin{everbatim*}
\xintexpr reduce(100/50/2)\relax
\end{everbatim*}

\operdesc{//} floored division (and thus produces an integer, see
   \func{divmod} for details)

\operdesc{/:} the associated modulo (see \func{divmod} and \func{mod})

   Left-associativity applies to the division operators:
\begin{everbatim*}
\xintexpr 100000/:13, 100000 'mod' 13\relax, \xintexpr 100000/:13/13\relax
\end{everbatim*}
 
   Nothing special needs to be done in contexts such as \LaTeX3
   |\ExplSyntaxOn| where |:| is of catcode letter, but if |:| is an
   active character one needs to use input such as |/\string :|
   (or replace it with usage of the function \func{mod}).

   Bulky workarounds such as |/\string :| are \fbox{\emph{unneeded}} if activation
   is due to Babel.\NewWith{1.4n}  See also \csbxint{exprSafeCatcodes} and
   a framed note found in \autoref{xintexpr}.

   \operdesc{'mod'} is same as \oper{/:}. 

   \fbox{Attention:}\IMPORTANTf{} with \ctanpackage{polexpr} loaded, which
   allows |'| in variable and function names, |'mod'| can not follow
   a variable name. Add parentheses around the variable, or use |/:|.

\end{description}

\precdesc{12}
\begin{description}
\operdesc{+} addition

\operdesc{-} subtraction. According to the general left-associativity rule in
case of equal precedence, it is
  left associative:
\begin{everbatim*}
\xintiiexpr 100-50-2\relax
\end{everbatim*}
\end{description}

\precdesc{10} Comparison operators are (as in Python) all at the same level of
precedence, use parentheses for disambiguation.
  \begin{description}
  \operdesc{<} |a<b| evaluates to \dtt{1} if the strict inequality holds to \dtt{0}
  if not.

  \operdesc{>} |a>b| evaluates to \dtt{1} if the strict inequality holds to \dtt{0}
  if not.

  \operdesc{==} |a==b| evaluates to \dtt{1} if equality holds to \dtt{0}
  if not.

  \operdesc{<=} |a<=b| evaluates to \dtt{1} if left hand side is at most equal
  to right hand side, to \dtt{0}
  if not.

  \operdesc{>=} |a>=b| evaluates to \dtt{1} if left hand side is at least equal
  to right hand side, to \dtt{0}
  if not.

  \operdesc{!=} |a!=b| evaluates to \dtt{1} if they differ, to \dtt{0}
  if not.
  \end{description}

  Comparisons can be chained arbitrarily, e.g., |x < y <= z !=
  t| is equivalent to |x < y 'and' y <= z 'and' z != t| (and also to |all(x<y,
  y<=z, z!=t)|), except that if |y| and |z| involve computations, they
  are evaluated only once.  Currently there is no short-circuit here, i.e.\@
  even if some intermediate comparison turns out false (in fact |0|), all the
  remaining conditionals will still be evaluated.

\begin{everbatim*}
\xintifboolexpr{1<=2!=3<4>1}{true}{\error},
\xintifboolexpr{1<=2>=3<4>1}{\error}{false},
\xintifboolexpr{3 != 3! == 6 != 4! == 24}{true}{\error}
\end{everbatim*}

\precdesc{8}
\begin{description}
  \operdesc{\Ampersand\Ampersand} logical conjunction. Evaluates to \dtt{1} if
  both sides are non-zero, to \dtt{0} if not.

  \operdesc{'and'} same as \verb+&&+.  See
  also the \func{all} multi-arguments function. 

  \fbox{Attention:}\IMPORTANTf{} with \ctanpackage{polexpr} loaded, which
  allows |'| in variable and function names, |'and'| can not follow
  a variable name. Add then parentheses around the variable name.

  \begin{snugframed}
    \noindent\centeredline{\xintReplicate{17}{\cautionsign[20pt]}\IMPORTANTf}

    The character |&| has a special meaning to \TeX{} inside alignments
    (this includes \LaTeX's |tabulars| and all similar environments).
    As soon as \TeX{} considers that the cell typesetting starts, it
    switches to a mode where as soon as it sees a |&|, even if it was
    originally nested into some macros, \TeX{} will complain if it is
    not a cell delimiter (possibly via some mysterious unrelated error
    such as \emph{Missing number, treated as zero}).  This issue used to
    apply to \LaTeX's floating point engine as well see
    \url{https://github.com/latex3/latex2e/issues/1958}.  \xintexprname
    users have a number of work-arounds:
    \begin{itemize}[nosep]
    \item Use |'and'|,
    \item or define some token |\edef\myAND{\string&\string&}| and use it,
    \item or use the \func{any} function.
    \end{itemize}
    For package authors creating macros with no control where they can
    end up being used, it is best to avoid |&&|.  Use one of the above
    work-arounds.  Read the above caveat about |'and'| though.

    For time being (March 4, 2026), upper-management has decided not to
    apply a similar fix as was done in the \LaTeX{} kernel (see above
    GitHub issue).  If such a fix was applied (up to the prize of some
    very small overhead), upper-management would not have the pleasure
    to write this advisory notice and show they care.
  \end{snugframed}
\end{description}

\precdesc{6}
\begin{description}
  \operdesc{\string|\string|} logical (inclusive) disjunction. Evaluates to
  \dtt{1} if one or both sides are non-zero, to \dtt{0} if not.

  \operdesc{'or'} same as as \verb+||+. See also the \func{any} multi-arguments
  function.  

  \fbox{Attention:}\IMPORTANTf{} with \ctanpackage{polexpr} loaded, which
  allows |'| in variable and function names, |'or'| can not follow
  a variable name. Add parentheses around the variable, or use \verb=||=.

  \operdesc{'xor'} logical (exclusive) disjunction. 

  \fbox{Attention:}\IMPORTANTf{} with \ctanpackage{polexpr} loaded, which
  allows |'| in variable and function names, |'xor'| can not follow a variable
  name. Add parentheses around the variable, or use the \func{xor} function syntax.

  \operdesc{\strut..}
  \operdesc{..[}
  \operdesc{{]..}} Syntax for arithmetic
  progressions. See \autoref{ssec:arithseq}.

  \operdesc{:} This is a separator involved in |[a:b]| Python-like slicing syntax.
\end{description}

\precdesc{4} 
\begin{description}
  \operdesc{\empty[}
  \operdesc{\empty]}
  Involved in Python-like slicing |[a:b]| and extracting |[N]| syntax. And its
  extension à la NumPy |[a:b,N,c:d,...,:]|. Ellipsis |...| is not yet implemented.
  The \myenquote{step} parameter as in |[a:b:step]| is not yet implemented.
\end{description}

\precdesc{3} 
\begin{description}
  \operdesc{,}
  The comma separates expressions (or function arguments).%
%
  \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.}
%
\begin{everbatim*}
\xintiiexpr 2^3,3^4,5^6\relax
\end{everbatim*}
\end{description}

\precdesc{2}
\begin{description}
  \operdesc{[}
  \operdesc{]} The bracketers construct nestable \myenquote{array-like}
  structures. Arbitrary (heterogeneous) nesting is allowed. For output related
  matters see \csbxint{thealign} (its usage is optional, without it rendering
  is \myenquote{one-dimensional}). Output shape of non-homogeneous arrays is to
  be considered unstable at this time.
\end{description}

\precdesc{1}
\begin{description}
  \operdesc{(}
  \operdesc{)}
  The parentheses serve as mandatory part of the syntax for functions, and to
  disambiguate precedences.%
%
    \footnote{It is not apt to describle the
    opening parenthesis as an operator, but the closing parenthesis is analogous
    to a postfix unary operator. It has lowest precedence which means
    that when it is encountered all postponed operations are executed to finalize
    its operand. The start of this operand was decided by the opening
    parenthesis.}
%
  They do not construct any nested structure.

  \operdesc{;} The semi-colon as involved as part of the syntax of \func{iter},
  \func{rseq}, \func{ndseq}, \func{ndmap} has the same
  precedence as a closing parenthesis.
\end{description}

\item[|\relax|] This is the expression terminator for \csbxint{expr} et al.
  It may arise from expansion during the parsing itself. As alternative to
  \csbxint{expr} (et al.) use
  \csbxint{eval} (et al.) which have the usual macro interface (with one mandatory
  argument).
\end{description}

The |;| also serves as syntax terminator for \csbxint{defvar} and
\csbxint{deffunc}.  It can in this rôle not arise from expansion as the
expression body up to it is fetched by a delimited macro.  But this is done in
a way which does not require any specific hiding for inner semi-colons as
involved in the syntax of \func{iter}, etc...

\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}[btp]
  \capstart
  \centering
\xintAssignArray\xintCSVtoList{!, ?, `\lowast`, `+`,
Arg,
Argd,
abs,
acos,
acosd,
acosh,
acoth,
acsc,
acsch,
add,
all,
any,
arccos,
arccsc,
arcsec,
arcsin,
arctg,
argch,
argcoth,
argcsch,
argsech,
argsh,
argth,
asec,
asech,
asin,
asind,
asinh,
atan,
atan2,
atan2d,
atand,
atanh,
binomial,
bool,
ceil,
ch,
cos,
cosd,
cosh,
cot,
cotd,
cotg,
coth,
csc,
cscd,
csch,
divmod,
even,
exp,
expm1,
factorial,
first,
flat,
float,
float\string_dgt,
floor,
frac,
gcd,
if,
ifint,
ifone,
ifsgn,
ilog10,
inv,
iquo,
irem,
isint,
isone,
iter,
iterr,
last,
lcm,
len,
ln,
log,
log10,
log1p,
max,
min,
mod,
mul,
ndfillraw,
ndmap,
ndseq,
not,
num,
nuple,
odd,
pArg,
pArgd,
pfactorial,
pow,
pow10,
preduce,
qfloat,
qfrac,
qint,
qrand,
qraw,
random,
randrange,
rbit,
reduce,
reversed,
round,
rrseq,
rseq,
sec,
secd,
sech,
seq,
sgn,
sh,
sin,
sinc,
sind,
sinh,
sqr,
sqrt,
sqrtr,
subs,
subsm,
subsn,
tan,
tand,
tanh,
tg,
th,
togl,
trunc,
unpack,
xor,
zip
}
\to\Functions
  \cnta\Functions{0} 
  \cntb\xinttheexpr ceil(\cnta/7)\relax\space
\newcommand\builtinfunction[1]{\expandafter\expandafter\expandafter\func
    \expandafter\expandafter\expandafter{\Functions{#1}}}%
\centeredline{\begin{tabular}{|*{7}{p{2cm}|}}
  \hline
  \xintFor* #1 in {\xintSeq{1}{\cntb}}\do
    {\builtinfunction{#1}&
     \builtinfunction{#1+\cntb}&%
     \builtinfunction{#1+2*\cntb}&%
     \builtinfunction{#1+3*\cntb}&%
     \builtinfunction{#1+4*\cntb}&%
     \builtinfunction{#1+5*\cntb}&%
     \ifnumgreater{#1+6*\cntb}{\cnta}
          {}
          {\builtinfunction{#1+6*\cntb}}%
     \\\hline}%
\end{tabular}}
\caption{Functions (click on names)}\label{tab:functions}
\etoctoccontentsline {xinttable}{\protect\emph{Table of functions in expressions}}
\etocsetnexttocdepth{subsubsection}
\localtableofcontents
\end{table}


Miscellaneous notes:
\begin{itemize}[nosep]
    \item since release |1.3d| \func{gcd} and \func{lcm} are extended to apply
      to fractions too, and 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 primitive
      is abstracted into \csa{xinttexuniformdeviate}, but the functions
      use a wrapper \csbxint{UniformDeviate} which provides more randomness.

    \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.

    \item Functions may be called with \emph{oples} as arguments as long as
       the total length is the number of arguments the function expects.
    \end{itemize}

\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.

  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*}
  \xintsetrandomseed 12345
  \xintDigits:=37\relax
  \xintthefloatexpr random()\relax\newline
  \xintthefloatexpr random()\relax\par
\end{everbatim*}

  \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}.%
  
\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*}

  \funcdesc[]{rbit} returns a random |0| or |1|.
  
\end{description}

\subsubsection{Functions with one argument}

\begin{framed}
  The trigonometric and exponential functions are not included here.  See the
  \calxtrigname and \calxlogname chapters.
\end{framed}

\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<x<1| as then |num(x)| is
  zero.
\begin{everbatim*}
\xinttheexpr num(3.1415^20), num(1e20)\relax
\end{everbatim*}
  The output is an explicit integer with as many zeros are as necessary. Even
  in float expressions, there will be an intermediate stage where all needed digits
  are there, but then the integer is immediately reparsed as a float to the target
  precision, either because some operation applies to it, or from the output
  routine of \csbxint{floatexpr} if it stood there alone. Hence,
  inserting something like |num(1e10000)| is costly as it really creates ten
  thousand zeros, even though later the whole thing becomes a float again. On
  the other hand naturally |1e10000| without |num()| would be simply parsed as
  a floating point number and would cause no specific overhead.

  \funcdesc{frac} fractional part.
  For all numbers |x=num(x)+frac(x)|, and |frac(x)| has the same sign as |x|
  except when |x| is an integer, as then |frac(x)| vanishes.
\begin{everbatim*}
\xintthefloatexpr frac(-355/113), frac(-1129.218921791279)\relax
\end{everbatim*}

  \funcdesc{reduce} reduces a fraction to smallest terms
\begin{everbatim*}
\xinttheexpr reduce(50!/20!/20!/10!)\relax
\end{everbatim*}

Recall that this is NOT done automatically, for example when adding fractions.
  \funcdesc{preduce} internally, fractions may have some power of ten part
  (for example when they got input in scientific notation). This function
  ignores the decimal part when doing the reduction. See \csbxint{PIrr}.
\begin{everbatim*}
\xinttheexpr preduce(10e7/2), reduce(10e7/2)\relax
\end{everbatim*}

  \funcdesc{abs} absolute value
  \funcdesc{sgn} sign. See also \csbxint{ifsgnexpr}.
  \funcdesc{inv} inverse.
  \funcdesc{floor} floor function.
  \funcdesc{ceil}  ceil function.
  \funcdesc{sqr}   square.
\item[ilog10(x)]\hypertarget{func:ilog10-ii}
   in |\xintiiexpr| the integer exponent $a$ such that $10^a\leq
  \mathrm{abs}(x)< 10^{a+1}$; returns (this may evolve in future)
  \dtt{\xintiieval{ilog10(0)}} if $x$ vanishes (i.e.\@{} \dtt{0x7fff8000}).
\begin{everbatim*}
\xintiieval{ilog10(1), ilog10(-1234567), ilog10(-123456789123456789), ilog10(2**31)}\par
\end{everbatim*}
  See \func{ilog10} for the behaviour in \csbxint{expr}-essions.
  \item[sqrt(x)]\hypertarget{func:sqrt-ii}
    in |\xintiiexpr|, truncated square root; in |\xintexpr| or
    |\xintfloatexpr| this is the floating point square root, and there is an
    optional second argument for the precision. See \func{sqrt}.
  \funcdesc{sqrtr} available \emph{only} in |\xintiiexpr|, rounded square root.
  \item[factorial(x)]\hypertarget{func:factorial-ii} factorial function (like the
    post-fix \oper{!} operator.) When used in |\xintexpr| or
    |\xintfloatexpr| there is an optional second argument. See \func{factorial}.
  \funcdesc{?} is the truth value, $1$ if non zero, $0$ if zero. Must use parentheses.
  \funcdesc{!} is logical not, $0$ if non zero, $1$ if zero. Must use parentheses.
  \funcdesc{not} logical not.
  \funcdesc{even} is the evenness of the truncation |num(x)|.
\begin{everbatim*}
\xintthefloatexpr [3] seq((x,even(x)), x=-5/2..[1/3]..+5/2)\relax
\end{everbatim*}

  \funcdesc{odd} is the oddness of the truncation |num(x)|.
\begin{everbatim*}
\xintthefloatexpr [3] seq((x,odd(x)), x=-5/2..[1/3]..+5/2)\relax
\end{everbatim*}

  \funcdesc{isint} evaluates to 1 if |x| is an integer, to 0 if
  not. See \func{ifint}.
\begin{everbatim*}
$\xinttheexpr -5/3..[1/3]..+5/3\relax
\rightarrow \xinttheexpr seq(isint(x), x=-5/3..[1/3]..+5/3)\relax$
\end{everbatim*}

  \funcdesc{isone} evaluates to 1 if |x| is 1, to 0 if not.
See \func{ifone}.
\begin{everbatim*}
$\xintthefloatexpr subs(((x-1)/x, x/x, (x+1)/x), x=2**30)\relax
\rightarrow
\xintthefloatexpr seq(isone(y), y=subs(((x-1)/x, x/x, (x+1)/x), x=2**30))\relax$
\end{everbatim*}

  \funcdesc{qint} belongs with \func{qfrac}, \func{qfloat}, \func{qraw} to a
  special category and it may have been an error to start documenting them.
  In particular \func{qraw} is basically a "DO NOT USE" interface.
  \begin{enumerate}[nolistsep]
  \item They require the closing parenthesis of their argument to be
    immediately visible, it can not arise from expansion.
  \item They grab the argument and store it directly; the format must be
    compatible with what is expected at macro level.
  \item And in particular the argument can not be a variable, it has to be
    numerical.
  \end{enumerate}

  \func{qint} achieves the same result as |num|, but the argument is grabbed
  as a whole without expansion and handed over to the
  \csbxint{iNum} macro. The |q| stands for ``quick'', and |qint| is thought
  out for use in \csbxint{iiexpr}|...\relax| with integers having dozens of
  digits.

    Testing (from eons ago) showed that using |qint()| starts getting advantageous for inputs
    having more (or \fexpan ding to more) than circa \dtt{20} explicit digits.
    But for hundreds of digits the input gain becomes a negligible
    proportion of (for example) the cost of a multiplication.

  Leading signs and then
  zeroes will be handled appropriately but spaces will not be systematically
  stripped. They should cause no harm and will be removed as soon as the
  number is used with one of the basic operators. This input mode \emph{does
    not accept decimal part or scientific part}.
\begin{everbatim}
\def\x{....many many many ... digits}\def\y{....also many many many digits...}
\xinttheiiexpr qint(\x)*qint(\y)+qint(\y)^2\relax\par
\end{everbatim}

  \funcdesc{qfrac} accepts fractions. \textbf{BREAKING
    CHANGE:}\CHANGED{2.0a1} if used in \csbxint{floateval} or
  \csbxint{iieval} the argument MUST be of the type \dtt{A/B} with
  \emph{strict} integers \dtt{A} and \dtt{B} with no leading zeros or
  signs, only \dtt{A} may have a minus sign (in short \dtt{A/B[0]} must
  be \xintfracname "raw format").  \textbf{ONLY} if used within
  \csbxint{eval} will it be parsed as done in general by the
  \xintfracname macros.

  As per \func{qfloat}, if |qfrac()| is used within an
  |\xintiiexpr|-ession, it must be hidden inside functions such
  as \func{round} or \func{trunc} which then produce integers acceptable
  to the integer-only parser.

  We mention that \func{qfrac} has nothing to do
  do with the similarly named function \func{frac} (sigh...).

  \funcdesc{qfloat} main aim is to be able to input a fraction \dtt{A/B}
  to \csbxint{floateval} and have it correctly rounded without prior
  separate rounding of numerator and denominator. This can also be
  achieved by nesting a sub |\xintexpr A/B\relax|, which though has a bit
  of overhead and is not available if only \calxname is
  loaded.\CHANGED{2.0a1} \textbf{BREAKING CHANGE:}\CHANGED{2.0a1} it is
  \textbf{not} recognized anymore in \csbxint{iieval}. And within
  \csbxint{floateval} the only recognized input formats are \dtt{A},
  \dtt{A[N]}, \dtt{A/B}, and \dtt{A/B[N]}.  As per \csbxint{eval}, there
  its argument can be anything parsed on input generally speaking by the
  \xintfracname macros, as for \func{qfloat}.

  Let us give two examples. The next
  computations done with \dtt{16} digits of precision do not give the
  same result:
\begin{everbatim*}
\calxeval{qfloat(12345678123456785001/12345678123456784999)}${}\neq{}$%
\calxeval{12345678123456785001/12345678123456784999}\newline
\calxeval{1234567812345679/1234567812345678}${}\neq{}$%
\calxeval{\xintexpr 12345678123456785001/12345678123456784999\relax}\newline
\end{everbatim*}%
    because the second is equivalent to the third, whereas the
    first one is equivalent to the fourth one.


    \funcdesc{float\string_dgt} is like \func{float} and avoids \func{float}'s
    check whether it used with its second optional argument. This is useful
    in the context of converting function definitions done via
    \csbxint{deffunc} (see explanations there) to functions usable in
    \csbxint{floateval}.

    \funcdesc{nuple} is currently same as |[...]|.\DNU{(1.4)} Reserved for
    possible alternative meaning in future.
\begin{everbatim*}
\xinteval{nuple(1,2,3)}
\end{everbatim*}

   \funcdesc{unpack} is alternative for |*| unpacking operator.
\begin{everbatim*}
\xinteval{unpack([1,2,3])}
\end{everbatim*}

   \funcdesc[ople]{flat} removes all nesting to produce a
   (non-bracketed) ople having the same leaves (some possibly empty) but
   located at depth 1.
\begin{everbatim*}
\xinteval{flat([[[[1,[],3],[4,[[[5,6,[]],[8,9],[[],11]],12],[13,14]]], [[],16]]], [])}
\end{everbatim*}

   I almost\unstable{} delayed indefinitely release because I was hesitating
   on the name: perhaps better with |flattened()|, but long names add
   (negligible, but still) overhead compared to short names. For this reason,
   consider that name may change.


\end{description}

\subsubsection{Functions with an alphanumeric argument}

\begin{description}
% [parsep=0pt,align=left,
%    leftmargin=0pt, itemindent=0pt,
%    labelwidth=-\fontdimen2\font, labelsep=\fontdimen2\font, labelindent=0pt,
%    listparindent=\leftmarginiii]

\funcdesc[name]{bool} 
    returns
    $1$ if the \TeX{} conditional |\ifname| would act as |\iftrue| and
    $0$ otherwise. This works with conditionals defined by |\newif| (in
    \TeX{} or \LaTeX{}) or with primitive conditionals such as
    |\ifmmode|. For example:
    %
    \leftedline{|\xintifboolexpr{25*4-if(bool(mmode),100,75)}{YES}{NO}|}
    %
    will return $\xintifboolexpr{25*4-if(bool(mmode),100,75)}{YES}{NO}$
    if executed in math mode (the computation is then $100-100=0$) and
    \xintifboolexpr{25*4-if(bool(mmode),100,75)}{YES}{NO} if not (the
    \func{if} conditional is described below; the
    \csbxint{ifboolexpr} test automatically encapsulates its first
    argument in an |\xintexpr| and follows the first branch if the
    result is non-zero (see \autoref{xintifboolexpr})).

    The alternative syntax |25*4-\ifmmode100\else75\fi| could have been
    used here, the usefulness of |bool(name)| lies in the availability
    in the |\xintexpr| syntax of the logic operators of conjunction
    |&&|, inclusive disjunction \verb+||+, negation |!| (or |not|), of
    the multi-operands functions |all|, |any|, |xor|, of the two
    branching operators |if| and |ifsgn| (see also |?| and |??|), which
    allow arbitrarily complicated combinations of various |bool(name)|.
\funcdesc[name]{togl} 
    returns $1$
    if the \LaTeX{} package \ctanpackage{etoolbox}%
    %
    %
%
\footnote{\url{https://ctan.org/pkg/etoolbox}}
    %
    has been used to define a toggle named |name|, and this toggle is
    currently set to |true|. Using |togl| in an |\xintexpr..\relax|
    without having loaded
    \ctanpackage{etoolbox} will result in an
    error from |\iftoggle| being a non-defined macro. If |etoolbox| is
    loaded but |togl| is used on a name not recognized by |etoolbox|
    the error message will be of the type ``ERROR: Missing |\endcsname|
    inserted.'', with further information saying that |\protect| should
    have not been encountered (this |\protect| comes from the expansion
    of the non-expandable |etoolbox| error message).

    When |bool| or |togl| is encountered by the |\xintexpr| parser, the
    argument enclosed in a parenthesis pair is expanded as usual from
    left to right, token by token, until the closing parenthesis is
    found, but everything is taken literally, no computations are
    performed. For example |togl(2+3)| will test the value of a toggle
    declared to |etoolbox| with name |2+3|, and not |5|. Spaces are
    gobbled in this process. It is impossible to use |togl| on such
    names containing spaces, but |\iftoggle{name with spaces}{1}{0}|
    will work, naturally, as its expansion will pre-empt the
    |\xintexpr| scanner.

    There isn't in |\xintexpr...| a |test| function available analogous
    to the |test{\ifsometest}| construct from the |etoolbox| package;
    but any \emph{expandable} |\ifsometest| can be inserted directly in
    an |\xintexpr|-ession as |\ifsometest10| (or |\ifsometest{1}{0}|),
    for example |if(\ifsometest{1}{0},YES,NO)| (see the |if| operator
    below) works.

    A straight |\ifsometest{YES}{NO}| would do the same more
    efficiently, the point of |\ifsometest10| is to allow arbitrary
    boolean combinations using the (described later) \verb+&&+ and
    \verb+||+ logic operators:
    \verb+\ifsometest10 && \ifsomeothertest10 || \ifsomethirdtest10+,
    etc... |YES| or |NO| above stand for material compatible with the
    |\xintexpr| parser syntax.

    See  also \csbxint{ifboolexpr}, in this context.
\end{description}

\subsubsection{Functions with one mandatory and a second but optional argument}

\begin{description}
% [parsep=0pt,align=left,
%    leftmargin=0pt, itemindent=0pt,
%    labelwidth=-\fontdimen2\font, labelsep=\fontdimen2\font, labelindent=0pt,
%    listparindent=\leftmarginiii]

  \funcdesc[{x[, n]}]{round} Rounds its first argument to an integer multiple
  of |10^(-n)| (i.e. it \emph{quantizes}). The case of negative |n| is new with
  |1.4a|. Positive |n| corresponds to conversion to a fixed point number with
  |n| digits after decimal mark.
\begin{everbatim*}
\xinteval{round(-2^30/3^5,12), round(-2^30/3^5,-3)}
\end{everbatim*}
  \funcdesc[{x[, n]}]{trunc} Truncates its first argument to an integer
  multiple of |10^(-n)|. The case of negative |n| is new with
  |1.4a|.
\begin{everbatim*}
\xinteval{trunc(-2^30/3^5,12), trunc(-2^30/3^5,-3)}
\end{everbatim*}

  \funcdesc[{x[, n]}]{float} Rounds its first argument to a floating point number, with a
  precision given by the second argument, which must be positive.
\begin{everbatim*}
\xinteval{float(-2^30/3^5,12), float(-2^30/3^5, 1)}
\end{everbatim*}

  % AUCTeX EXTREMEMENT PENIBLE AVEC L'INDENTATION FORCEE SOUS M-q

    For this example and earlier ones if the parser had been
    \csbxint{floateval}, not \csbxint{eval}, the first argument (here
    |2^30/3^5|) would already have been computed as floating point number with
    numerator and denominator rounded separately first to the prevailing
    precision. To avoid that, use |\xintexpr...\relax| wrapper.
    Then the rounding or truncation will be applied to an exact fraction.

    \funcdesc[{x[, n]}]{sfloat} It is the same as \func{float},
    but in case of a short (non-fractional) input it gets stored internally
    without adding zeros to make the mantissa have the \csbxint{theDigits}
    length. One may wonder then what is the utility of \func{sfloat}? See for
    an example of use the documentation of \csbxint{deffunc}. Notice however
    that this is a bit experimental and may evolve in future when \xintname
    gets a proper internal data structure for floating point numbers. The
    non-normalized format is useful for multiplication or division, but float
    additions and subtractions usually convert their arguments to a normalized
    mantissa.

    \funcdesc[{x[, n]}]{ilog10} If there is an optional argument |n|, returns the (relative) integer $a$ such that $10^a\leq
    \mathrm{abs}(float(x, n)) < 10^{a+1}$. In absence of the
    optional argument:
    \begin{itemize}[nosep]
    \item in \csbxint{expr}, it returns the exponent $a$ such that $10^a\leq
    \mathrm{abs}(x) < 10^{a+1}$.
     \item in \csbxint{floatexpr}, the input is first rounded to
       \csbxint{theDigits} float precision, then the exponent $a$ is evaluated. 
    \end{itemize}
\begin{everbatim*}
\xintfloateval{ilog10(99999999/10000000, 8), ilog10(-999999995/100000000, 8),
                                             ilog10(-999999995/100000000, 9)}\newline
\xinteval{ilog10(-999999995/100000000), ilog10(-999999995/100000000, 8)}
\end{everbatim*}

    If the input vanishes the function outputs
    \dtt{\xinteval{ilog10(0)}} (i.e.\@{} |-0x7fff8000| which is near the
    minimal TeX number |-0x7fffffff|). This is also subject to change.

    The \hyperlink{func:ilog10-ii}{integer-only} variant for \csbxint{iiexpr}
    admits no optional argument.

  \funcdesc[{x[, n]}]{sqrt} in \csa{xintexpr}|...\relax| and \csa{xintfloatexpr}|...\relax|
    it achieves the precision given by the optional second argument. For
    legacy reasons the |sqrt| function in \csa{xintiiexpr} \emph{truncates}
    (to an integer), whereas |sqrt| in \csa{xintfloatexpr}|...\relax| (and in
    \csa{xintexpr}|...\relax| which borrows it) \emph{rounds} (in the sense of
    floating numbers). There is |sqrtr| in \csa{xintiiexpr} for
    \emph{rounding} to nearest integer.
\begin{everbatim*}
\xinttheexpr sqrt(2,31)\relax\ and \xinttheiiexpr sqrt(num(2e60))\relax
\end{everbatim*}

    There is an \hyperlink{func:sqrt-ii}{integer only} variant for
    \csbxint{iiexpr}.

  \funcdesc[{x[, n]}]{factorial} when the second optional argument is made
    use of inside \csa{xintexpr}|...\relax|, this switches to the use of the
    float version, rather than the exact one.
\begin{everbatim*}
\xinttheexpr factorial (100,32)\relax, {\xintDigits:=32\relax \xintthefloatexpr
                                           factorial (100)\relax}\newline
\xinttheexpr factorial (50)\relax\newline
\xinttheexpr factorial (50, 32)\relax
\end{everbatim*}

    The \hyperlink{func:factorial-ii}{integer only variant} of course has no
    optional second argument.

  \funcdesc[{A[, B]}]{randrange} when used with a single argument |A| returns a random
    integer |0 <= x < A|, and when used with two arguments |A| and |B| returns
    a random integer |A <= x < B|. As in Python it is an \myenquote{empty range} error
    in first case if |A| is zero or negative and in second case if |B <= A|.
    
    Attention that the arguments are first converted to integers using
    \csbxint{Num} (i.e.\@{} truncated towards zero).

    The function can be used in all three parsers. Of course the size is not
    limited (but in the float parser, the integer will be rounded if involved
    in any operation).
\begin{everbatim*}
  \xintsetrandomseed 12345
  \xinttheiiexpr randrange(10**20)\relax\newline
  \xinttheiiexpr randrange(1234*10**16, 1235*10**16)\relax\newline
  \printnumber{\xinttheiiexpr randrange(10**199,10**200)\relax}\par
\end{everbatim*}
    For the support macros see \csbxint{RandomDigits}, \csbxint{iiRandRange},
    \csbxint{iiRandRangeAtoB}. For some details regarding how \xintname
    uses the engine provided generator of pseudo-random numbers, see
    \csbxint{UniformDeviate}.

  \end{description}

\subsubsection{Functions with two arguments}

\begin{framed}
  The \func{atan2} and related trigonometric functions are documented in
  the \calxtrigname chapter.
\end{framed}

\begin{description}
% [parsep=0pt,align=left,
%    leftmargin=0pt, itemindent=0pt,
%    labelwidth=-\fontdimen2\font, labelsep=\fontdimen2\font, labelindent=0pt,
%    listparindent=\leftmarginiii]

  \funcdesc[m, n]{iquo} Only available in |\xintiiexpr/\xintiieval|
  context.  Computes the Euclidean quotient.  Matches with the remainder
  defined in next item. See \csbxint{iiQuo}.

  \funcdesc[m, n]{irem} Only available in |\xintiiexpr/\xintiieval|
  context.  Computes the Euclidean remainder.  Attention that, following
  mathematical definition, it is always non-negative.  See \csbxint{iiRem}.

  \funcdesc[f, g]{mod} computes |f - g*floor(f/g)|. Hence its output is a
  general fraction or floating point number or integer depending on the
  used parser. If non-zero, it has the same sign as |g|.

  Prior to |1.2p| it computed |f - g*trunc(f/g)|.

  The \oper{/:} and \oper{'mod'} infix operators are both mapped to the same underlying
  macro as this |mod(f, g)| function. At |1.3| this macro produces smaller
  denominators when handling fractions than formerly.
\begin{everbatim*}
\xinttheexpr mod(11/7,1/13), reduce(((11/7)//(1/13))*1/13+mod(11/7,1/13)),
mod(11/7,1/13)- (11/7)/:(1/13), (11/7)//(1/13)\relax\newline
\xintthefloatexpr mod(11/7,1/13)\relax\par
\end{everbatim*}

  Attention: the precedence rules mean that |29/5 /: 3/5| is handled like
  |((29/5)/:3)/5|. This is coherent with behaviour of Python language for
  example:
\begin{everbatim}
>>> 29/5 % 3/5, 11/3 % 17/19, 11/57
(0.5599999999999999, 0.19298245614035087, 0.19298245614035087)
>>> (29/5) % (3/5), (11/3) % (17/19), 5/57
(0.4, 0.08771929824561386, 0.08771929824561403)
\end{everbatim}
  For comparison (observe on the last lines how |\xintfloatexpr| is more accurate than
  Python!):
\begin{everbatim*}
\noindent\xinttheexpr 29/5 /: 3/5, 11/3 /: 17/19\relax\newline
         \xinttheexpr (29/5) /: (3/5), (11/3) /: (17/19)\relax\newline
         \xintthefloatexpr 29/5 /: 3/5, 11/3 /: 17/19, 11/57\relax\newline
         \xintthefloatexpr (29/5) /: (3/5), (11/3) /: (17/19), 5/57\relax\newline
         5/57 = \xinttheexpr trunc(5/57, 20)\relax\dots\newline
\end{everbatim*}%
  Regarding some details of behaviour in |\xintfloatexpr|, see discussion of
  |divmod| function next.

  \funcdesc[f, g]{divmod} computes the two mathematical values |floor(f/g)| and
  |mod(f,g)=f - g*floor(f/g)| and produces them as a bracketed
  pair
  in
  other terms it is analogous to the Python |divmod| function. Its output is
  equivalent to using |f//g, f/:g| but its implementation avoids doing twice
  the needed division.

  In |\xintfloatexpr...\relax| the modulo is rounded to the prevailing
  precision. The quotient is like in the other parsers an exact integer. It
  will be rounded as soon as it is used in further operations, or via the global
  output routine of |\xintfloatexpr|. \emph{Those examples behave as in |1.3f|
  because assignments to multiple variables tacitly unpack if this is
  necessary.}
\begin{everbatim*}
\xintdefvar Q, R := divmod(3.7, 1.2);%
\xinttheexpr Q, R, 1.2Q + R\relax\newline
\xintdefiivar Q, R := divmod(100, 17);%
\xinttheiiexpr Q, R, 17Q + R\relax\newline
\xintdeffloatvar Q, R := divmod(100, 17e-20);%
\xintthefloatexpr Q, R, 17e-20 * Q + R\relax\newline
% show Q exactly, although defined as float it can be used in iiexpr:
\xinttheiiexpr Q\relax\ (we see it has more than 16 digits)\par
\xintunassignvar{Q}\xintunassignvar{R}%
\end{everbatim*}
  Again: |f//g| or the first item output by |divmod(f, g)| is an integer |q|
  which when computed inside |\xintfloatexpr..\relax| is not yet rounded to
  the prevailing float precision; the second item |f-q*g| is the rounding to
  float precision of the exact mathematical value evaluated with this exact
  |q|. \emph{This behaviour may change in future major release;\IMPORTANT{}
    perhaps |q| will be rounded and |f-q*g| will correspond to usage of this
    rounded |q|.}

  As |\xintfloatexpr| rounds its global result, or rounds operands at
  each arithmetic operation, it requires special circumstances to show that
  the |q| is produced unrounded. Either as in the above example or this one
  with comparison operators:
\begin{everbatim*}
\xintDigits := 4\relax
\xintthefloatexpr if(12345678//23==537000, 1, 0), 12345678//23\relax\newline
\xintthefloatexpr if(float(12345678//23)==537000, 1, 0)\relax\par
\xintDigits := 16\relax
\end{everbatim*}
  In the first line, the comparison is done with
  |floor(12350000/23)|\dtt{=\xinttheiiexpr12350000/23\relax} (notice in
  passing that |12345678//23| was evaluated as |12350000//23| because the
  operands are first rounded to \dtt{4} digits of floating point precision), hence the conditional
  takes the "False" branch. In the second line the |float| forces rounding of
  the output to \dtt{4} digits, and the conditional takes the "True" branch.

% pour mémoire, Python :
% >>> divmod(100,17e-20)
% (5.88235294117647e+20, 1.4756182441723705e-19)
% mais faudra voir avec le module Decimal

  This example shows also that comparison operators in
  |\xintfloatexpr..\relax| act on unrounded operands.

  \funcdesc[x, y]{binomial} computes binomial coefficients.
  It returns zero if |y<0| or |x<y| and raises an error if |x<0| (or if
  |x>99999999|.)
\begin{everbatim*}
\xinttheexpr seq(binomial(20, i), i=0..20)\relax
\end{everbatim*}
\begin{everbatim*}
\printnumber{\xintthefloatexpr seq(binomial(100, 50+i), i=-5..+5)\relax}%
\end{everbatim*}

The arguments must be (expand to) short integers.
  \funcdesc[a, b]{pfactorial} computes partial factorials i.e.\@
    |pfactorial(a,b)| evaluates the product |(a+1)...b|.
\begin{everbatim*}
\xinttheexpr seq(pfactorial(20, i), i=20..30)\relax
\end{everbatim*}

The arguments must (expand to) short integers. See \autoref{xintiiPFactorial}
for the behaviour if the arguments are negative.

\funcdesc[\TeX-macro, n-uple]{ndfillraw} The second argument is |[N1, N2, ...,
Nk]|.  The construct fills an |N1xN2x...xNk| hyperrectangular
nested list by evaluating the given |macro| as many times as needed.  The
expansion result goes directly into internal data and must thus comply with
what is expected internally for an individual numeric leaf (at |1.4|,
\xintfracname raw format worked for |\xintexpr| or |\xintfloatexpr|, but not
|\xintiiexpr|, and this may have changed since).\DNU{} This is an experimental
function serving to generate either constant or random arrays.  Attention that
%
% BORDEL \textbf{\sffamily...} NON, {\bfseries\sffamily ...} NON
% LaTeX Font Warning: Font shape `T1/cmss/b/n' undefined
% (Font)              using `T1/cmss/m/n' instead on input line 1826.
%
% ceci est ok {\fontseries{bx}\sffamily\TeX-macro}
% https://github.com/latex3/latex2e/issues/277
{\fontseries{bx}\sffamily \TeX-macro}
stands here for any expandable \TeX{}
\emph{macro}, and an |\xintexpr|-ession at this location thus requires an
explicit |\xinteval| wrapping.
\end{description}

\subsubsection{Functions with 3 or 4 arguments}

\begin{description}
% [parsep=0pt,align=left,
%    leftmargin=0pt, itemindent=0pt,
%    labelwidth=-\fontdimen2\font, labelsep=\fontdimen2\font, labelindent=0pt,
%    listparindent=\leftmarginiii]

  \funcdesc[cond,yes,no]{if} (twofold-way conditional)\mbox{}

    checks if |cond| is true or false and takes the corresponding
    branch. Any non zero number or fraction is logical true. The zero
    value is logical false. Both ``branches'' are evaluated (they are
    not really branches but just numbers). See also the \oper{?} operator.

  \funcdesc[x,yes,no]{ifint} (twofold-way conditional)\mbox{}

    checks if |x| is an integer and in that case chooses the ``yes'' branch.%
    
    See also \func{isint}.

  \funcdesc[x,yes,no]{ifone} (twofold-way conditional)\mbox{}

    checks if |x| is equal to one and in that case chooses the ``yes'' branch.%
    
    Slightly more efficient than |if(x==1,..,..)|.  See also \func{isone}.

  \funcdesc[cond,<0,=0,>0]{ifsgn} (threefold-way conditional)\mbox{}

    checks the sign of |cond| and
    proceeds correspondingly. All three are evaluated. See also the \oper{??}
    operator.

  \end{description}

\subsubsection{Functions with an arbitrary number of arguments}

The functions \func{all}, \func{any}, \func{xor},
\func{`+`},
\func{`\lowast`},
\func{max}, \func{min}, \func{gcd}, \func{lcm}, \func{first}, \func{last},
\func{reversed} and \func{len} work both with \myenquote{open} and \myenquote{packed} lists (aka |nutples|).

Since |1.4|, when used with a single argument which is a |nutple|, it is automatically unpacked.
But from |1.4| to |1.4h| these functions could not be used with a single numeric argument: either they had at least two arguments, or only one and it had to be a |nutple|.  At |1.4i| it is again possible to use them with a lone numeric argument.

  In the specific case of \func{reversed} with a |nutple| argument the output is then repacked so that
  the output is a |nutple| if and only if the input was one (the reversal does
  not propagate to deeper nested |nutple|'s, it applies only at depth one).

\begin{description}
% [parsep=0pt,align=left,
%    leftmargin=0pt, itemindent=0pt,
%    labelwidth=-\fontdimen2\font, labelsep=\fontdimen2\font, labelindent=0pt,
%    listparindent=\leftmarginiii]

  \funcdesc[stuff]{qraw} It\DNU{} injects directly tokens to represent
  internally numerical data.  Will break at any release modifying the internal
  data format specifications (which are not always documented).

\funcdesc[x, y, ...]{all} inserts a logical |AND| in-between its arguments and evaluates the
resulting logical assertion (as with all functions, all arguments are
evaluated).
\begin{everbatim*}
\xinteval{all(1,1,1), all([1,0,1]), all([1,1,1])}
\end{everbatim*}

\funcdesc[x, y, ...]{any} inserts a logical |OR| in-between its arguments and evaluates the
resulting logical assertion,
\begin{everbatim*}
\xinteval{any(0,0,0), any([1,0,1]), any([0,0,0])}
\end{everbatim*}

\funcdesc[x, y, ...]{xor} inserts a logical |XOR| in-between its arguments and evaluates
the resulting logical assertion,
\begin{everbatim*}
\xinteval{xor(1,1,1), xor([1,0,1]), xor([1,1,1])}
\end{everbatim*}

\funcdesc[x, y, ...]{`+`} adds (left ticks mandatory):
\begin{everbatim*}
\xinttheexpr `+`(1,3,19), `+`(1**2,3**2,sqr(19)), `+`([1**2,3**2,sqr(19)])\relax
\end{everbatim*}

\funcdesc[x, y, ...]{`\lowast`} multiplies (left ticks mandatory):
\begin{everbatim*}
\xinttheexpr `*`(1,3,19), `*`(1^2,3^2,19^2), `*`([1^2,3^2,19^2])\relax
\end{everbatim*}

\funcdesc[x, y, ...]{max} maximum of the (arbitrarily many) arguments,
\begin{everbatim*}
\xinttheexpr max(1,3,19), min([1,3,19])\relax
\end{everbatim*}

\funcdesc[x, y, ...]{min} minimum of the (arbitrarily many) arguments,
\begin{everbatim*}
\xinttheexpr min(1,3,19), min([1,3,19])\relax
\end{everbatim*}

\funcdesc[x, y, ...]{gcd} computes the positive generator of the fractional
ideal of rational numbers $x\mathbb Z + y\mathbb Z + ... \subset \mathbb
Q$.  Since |1.4d| the output is always in lowest terms.

This example shows how to reduce an n-uple to its primitive part:
\begin{everbatim*}
\xinteval{gcd(7/300, 11/150, 13/60)}\newline
$(7/300, 11/150, 13/60)\to
(\xinteval{subsn(seq(reduce(x/D), x = L), D=gcd(L); L=7/300, 11/150, 13/60)})$\newline
\xintexpr gcd([7/300, 11/150, 13/60])\relax\par
\end{everbatim*}
MEMO
Perhaps a future release will provide a |primpart()| function as built-in
functionality.

In case of strict integers, using a |\xintiiexpr...\relax| wrapper is
advantageous as the integer-only |gcd()| is more efficient.
%
% ceci semble encore à peu près exact à 1.4d :
% (about |6X|) than the one accepting general fractional inputs. 
%
As \csbxint{iiexpr} accepts only strict integers, doing this may require
wrapping the argument in \func{num}.

\funcdesc[x, y, ...]{lcm} computes the positive generator of the
fractional ideal of rational numbers $x\mathbb Z \cap y\mathbb Z \cap ...
\subset \mathbb Q$.
\begin{everbatim*}
\xinttheexpr lcm([7/300, 11/150, 13/60])\relax
\end{everbatim*}
As for \func{gcd}, since |1.4d| the output is always in lowest terms.
% Memo 1.4d: This
% function got (I did not tests extensively) a |4X| speed gain for inputs being
% only integers
For strict integers it is slightly advantageous to use a sub
\csbxint{iiexpr}-ession.
%
% je disais à 1.4:
%  (about |9X|) than the one accepting general fractional inputs.
% mais à 1.4d c'est seulement 2X : le lcm pour les fractions
% a quadruplé sa vitesse !
%

\funcdesc[x, y, ...]{first} first item of the list or nutple argument:
\begin{everbatim*}
\xintiiexpr first([last(-7..3), [58, 97..105]])\relax
\end{everbatim*}
\funcdesc[x, y, ...]{last} last item of the list or nutple argument:
\begin{everbatim*}
\xintiiexpr last([-7..3, 58, first(97..105)])\relax
\end{everbatim*}
\funcdesc[x, y, ...]{reversed} reverses the order of the comma separated list
or inside a nutple:
\begin{everbatim*}
\xintiieval{reversed(reversed(1..5), reversed([1..5]))}
\end{everbatim*}

The above is correct as \xintexprname functions may produce oples and this is
the case here.
\funcdesc[x, y, ...]{len} computes the number of items in a comma separated
  list or inside a nutple (at first level only: it is not a counter of leaves).
\begin{everbatim*}
\xinttheiiexpr len(37.5), len(1..50, [101..150], 1001..1050), len([1..10])\relax
\end{everbatim*}

   \funcdesc[\lowast nutples]{zip} behaves similarly to
   the Python function of the same name: i.e. it produces \emph{an ople of nutples,
   where the i-th nutple contains the i-th element from each of the argument
   nutples. The ople ends when the shortest input nutple is exhausted.
   With a single nutple argument, it returns an ople of 1-nutples.
   With no arguments, it returns the empty ople.}

   As there is no exact match in \xintexprname of the concept of \myenquote{iterator} object,%
%
\footnote{%
Speaking of iterators, I have some ideas about this: as \csbxint{expr} does not
have the global expression in its hands it is difficult to organize globally
expandably the idea of iterator, but locally via syntax like the one for
\func{seq} this is feasible. When one thinks about it, \func{seq} is closely related
to the iterator idea.}
%
   there is a significant difference here that (for example) the |zip(x,x,x)|
   Python idiom to cluster the iterator |x| into successive chunks of length 3
   does not apply. Consider for this reason even the name of the function as
   work-in-progress, susceptible to change.\unstable{}
\begin{everbatim*}
\xintiieval{zip([1..9], [0, 1, 2], [11..29], [111..139])}
\end{everbatim*}

   See also \csbxint{thespaceseparated} for some possible usage in combination with \func{flat}.

  \end{description}

\subsubsection{Functions requiring dummy variables}
\hypertarget{ssec:dummies}{}

The pseudo-functions \xintFor #1 in {subs, seq, subsm, subsn, iter, add, mul,
  rseq, iterr, rrseq, iterr, ndseq, ndmap, ndfillraw} \do
{\func{#1}\xintifForLast{}{, }} use delimited macros for some tasks:
\begin{itemize}
\item for all of them, whenever a |<varname>=| chunk must be parsed into a
  (non-assigned) variable name, then the equal sign must be visible,
\item and if the syntax is with |,<varname>=| the initial comma also must be
  visible (spaces do not matter),
\item for all of them but \func{ndmap} and \func{ndfillraw} the final closing
  parenthesis must be visible.
\end{itemize}
Although delimited macros involving commas are used to locate |,<varname=|
this is done in a way silently ignoring commas located inside correctly
balanced parentheses. Thus, as the examples will show, nesting works as
expected.

The semi-colons involved in the syntax may arise from expansion alone. For
\func{rseq}, \func{iter}, \func{rrseq} and \func{iterr} the |,<varname>=| part
may also be created from the expansion which will generate the initial comma
separated values delimited by a semi-colon.

Prior to |1.4|, semi-colons needed to be braced or otherwise hidden when
located in an expression parsed by \csbxint{defvar} or
\csbxint{deffunc}, to not be confused with the expression
terminator.

\func{seq}, \func{rseq}, \func{iter}, \func{rrseq},
\func{iterr} and also \func{add}, \func{mul}, but not \func{subs} admit the
\keyword{omit}, \keyword{abort}, and \func{break} keywords. This is a
new feature at |1.4| for \func{add} and \func{mul}.

In the case
of a potentially infinite list generated by the |<integer>++| syntax, use of
\keyword{abort} or of \func{break} is mandatory, naturally.

All lowercase and uppercase Latin letters are pre-configured for usage as
dummy variables. In Unicode engines one can use \csbxint{newdummy} to turn any
letter into a usable dummy variable.

And since |1.4|, \csbxint{newdummy} works (in all engines) to
turn a multi-letter word into a dummy variable.  In the descriptions,
|varname| stands for such a dummy variable, either single-letter or word.

\begin{description}
% [parsep=0pt,align=left,
%    leftmargin=0pt, itemindent=0pt,
%    labelwidth=-\fontdimen2\font, labelsep=\fontdimen2\font, labelindent=0pt,
%    listparindent=\leftmarginiii]
\funcdesc[expr, varname=comma separated values]{subs} for variable substitution.
\begin{everbatim*}
\xinttheexpr subs(subs(seq(x*z,x=1..10),z=y^2),y=10)\relax\newline
\end{everbatim*}%
Attention that |xz| generates an error, one must use explicitely |x*z|, else
the parser expects a variable with name |xz|.

\func{subs} is useful when defining macros for which some argument will be
used more than once but may itself be a complicated expression or macro, and
should be evaluated only once, for matters of efficiency. But \func{subs} is
helpless in function definitions: all places where a variable is substituted
will receive the complete recipe to compute the variable, rather than evaluate
only once.

One should rather define auxiliary functions to compute intermediate
results. Or one can use \func{seq}.  See the documentation of
\csbxint{deffunc}.

\funcdesc[expr, varname=comma separated values]{add} addition
\begin{everbatim*}
\xintiiexpr add(x^3,x=1..20), add(x(x+1), x=1,3,19)\relax\newline
\xintiiexpr add(x^3, x = 1..[2]..20)\relax\newline         % add only odd cubes
\xintiiexpr add((odd(x))?{x^3}{omit}, x = 1..20)\relax\par % add only odd cubes
\end{everbatim*}

At |1.4| (fixed at |1.4a|), the keywords \keyword{omit} (as in
example above), \keyword{abort} and \func{break} are allowed.
The meaning of \func{break} is specific: its argument serves as last
operand for the addition, not as ultimate value.
\begin{everbatim*}
\xintiiexpr add((x>10)?{break(1000)}{x}, x = 1..15)\relax
\end{everbatim*}

The |@| special variable holds the so-far accumulated value. Initially its
value is zero.
\begin{everbatim*}
\xintiiexpr add(1 + @, i=1..10)\relax % iterates x <- 2x+1
\end{everbatim*}

See \func{`+`} for syntax simply adding items of a
list without usage of a dummy variable.

\funcdesc[expr, varname=comma separated values]{mul} multiplication
\begin{everbatim*}
\xintiiexpr mul(x^2, x = 1, 3, 19, 37..50)\relax
\end{everbatim*}

The |@| special variable holds the so-far accumulated value. Initially its
value is one.

At |1.4| (fixed at |1.4a|), the keywords \keyword{omit},
\keyword{abort} and \func{break} are allowed.  The meaning of \func{break} is
specific: its argument serves as last operand for the multiplication, not as
ultimate value.
\begin{everbatim*}
\xintiieval{mul((i==100)?{break(i^4)}{i}, i = 98, 99, 100)}
\end{everbatim*}
 
See \func{`\lowast`} for syntax without a dummy variable.

\funcdesc[expr, varname=comma separated valuesvalues]{seq} comma separated values generated according to a formula
\begin{everbatim*}
\xintiiexpr seq(x(x+1)(x+2)(x+3),x=1..10), `*`(seq(3x+2,x=1..10))\relax
\end{everbatim*}
\begin{everbatim*}
\smallskip
\leavevmode\vbox{\xintthealign\xintiiexpr [seq([seq(i^2+j^2, i=0..j)], j=0..10)]\relax}
\end{everbatim*}

\funcdesc[initial value; expr, varname=comma separated values]{rseq} recursive sequence, |@| for the previous value.
\begin{everbatim*}
\printnumber {\xintthefloatexpr subs(rseq (1; @/2+y/2@, i=1..10),y=1000)\relax }\newline
\end{everbatim*}%
  Attention: in the example above |y/2@| is interpreted as
  |y/(2*@)|.\IMPORTANT{} With versions |1.2c| or earlier it would have been
  interpreted as |(y/2)*@|.

In case the initial stretch is a comma separated list, |@| refers at the first
iteration to the whole list. Use parentheses at each iteration to maintain
this ``nuple''. For example:
\begin{everbatim*}
\printnumber{\xintthefloatexpr rseq(1,10^6;
             (sqrt(@[0]*@[1]),(@[0]+@[1])/2), i=1..7)\relax }
\end{everbatim*}

Prior to |1.4| the above example had to be written with |[@]|. This is still
possible (|@| stands for an ople with two items, bracketing then extracting is
like extracting directly), but it is leaner to drop the extra \myenquote{packing}.

\funcdesc[initial value; expr, varname=comma separated values]{iter} is exactly like |rseq|, except that it only prints
  the last iteration.


\hypertarget{BrentSalamin}{}
  |iter()| is convenient to handle compactly higher order iterations.
  We can illustrate its use with an expandable (!)
  implementation of the Brent-Salamin algorithm for the computation of $\pi$:
\begin{everbatim*}
\xintDigits:= 87\relax % we target 84 digits, and use 3 guard digits
\xintdeffloatfunc BS(a, b, t, p):= 0.5*(a+b), sqrt(a*b), t-p*sqr(a-b),
                                                        \xintiiexpr 2p\relax;
\xinteval
{trunc(% I feel truncation is better than rounding to display decimals of π
  \xintfloatexpr
    iter(1, sqrt(0.5), 1, 1; % initial values
% this 43 is 84/2 + 1
      (@[0]-@[1]<2e-43)?% stopping criteria; takes into account that the
                            % exit computation (break() argument) doubles
                            % number of exact digits (roughly) 
      {break(sqr(@[0]+@[1])/@[2])}      % ... do final computation,
      {BS(@)}, % else do iteration
       i=1++)  % This generates infinite iteration. The i is not used.
  \relax
% this 83 is 84 - 1 (there is a digit known to be 3 actually, before decimal mark)
 , 83)% closing parenthesis of trunc()
}...% some dots following end of \xinteval argument
\xintDigits:=16\relax
\end{everbatim*}\newline
  You can try with |\xintDigits:=1004\relax| and |2e-501| in place of
  |\xintDigits:=87\relax| and |2e-43|, but be patient for some seconds
  for the result. Of course don't truncate the final
  result to only \dtt{83} fractional decimal digits but \dtt{1000}...\@
  and better to wrap the whole thing in |\message| or
  |\immediate\write128| or |\edef| because it will then run in the right margin.

  Prior to |1.4| the above example had to use notation such as |[@][0]|; this
  would still work but |@[0]| is leaner.

\funcdesc[initial values; expr, varname=comma separated values]{rrseq} recursive sequence with multiple initial terms. Say, there are
  |K| of them. Then |@1|, ..., |@4| and then |@@(n)| up to |n=K| refer to the
  last |K| values. Notice the difference with |rseq()| for which |@| refers to
  a list of items in case the initial value is a list and not a single item.%
%
\footnote{Prior to |1.4|, one could use |@| in |rrseq()| and |iterr()| as an
  alias to |@1|. This undocumented feature is dropped and |@| will break |rrseq()| and |iterr()|.}
%
  Using |rrseq()| with |@1| etc...\@{} accessors may be perhaps a bit
  more efficient than using |rseq()| with a list as staring value and
  constructs such as |@[0]|, |@[1]| (or rather |@[-1]|, |@[-2]| to
  mimick what |@1|, |@2|, |@3|, |@4| and |@@(integer)| do in |rrseq()|.
\begin{everbatim*}
\xinttheiiexpr rrseq(0,1; @1+@2, i=2..30)\relax
\end{everbatim*}
\begin{everbatim*}
\xinttheiiexpr rseq(1; 2@, i=1..10)\relax
\end{everbatim*}
\begin{everbatim*}
\xinttheiiexpr rseq(1; 2@+1, i=1..10)\relax
\end{everbatim*}
\begin{everbatim*}
\xinttheiiexpr rseq(2; @(@+1)/2, i=1..5)\relax
\end{everbatim*}

\begin{everbatim*}
\xinttheiiexpr rrseq(0,1,2,3,4,5; @1+@2+@3+@4+@@(5)+@@(6), i=1..20)\relax
\end{everbatim*}

I implemented an |Rseq| which at all times keeps the memory of \emph{all}
previous items, but decided to drop it as the package was becoming big.

\funcdesc[initial values; expr, varname=comma separated values]{iterr} same as |rrseq| but does not print any value until the last |K|.
\begin{everbatim*}
\xinttheiiexpr iterr(0,1; @1+@2, i=2..5, 6..10)\relax
% the iterated over list is allowed to have disjoint defining parts.
\end{everbatim*}

\funcdesc[expr, var1=value1; var2=value2; ....; varN=valueN{[;]}]{subsm}
Simultaneous
substitutions. The assigned values must not involve the
variables. An optional final
semi-colon is allowed.
\begin{everbatim*}
\xintiieval{subsm(x+2y+3z+4t, x=1; y=10; z=100; t=1000;)}
\end{everbatim*}

\funcdesc[expr, var1=value1; var2=value2; ....; varN=valueN{[;]}]{subsn}
Simultaneous
substitutions. The assigned values may involve all variables
located further to its right. An optional final
semi-colon is allowed.
\begin{everbatim*}
\xintiieval{subsn(x+y+z+t, x=20y; y=20z; z=20t; t=1)}
\end{everbatim*}

\funcdesc[function, values1; values2; ....; valuesN{[;]}]{ndmap}
%
Construction of a nested list (a priori having |N| dimensions) from function
values. The function must be an |N|-variable function (or a function accepting
arbitrarily many arguments), but it is not constrained to produce only scalar
values.  Only in the latter case is the output really an |N|-dimensional
\myenquote{|ndlist|} type object.  An optional final semi-colon in the input before the
closing parenthesis is
allowed.
\begin{everbatim*}
\xintdeffunc foo(a,b,c,d) = a+b+c+d;
\begin{multicols}{2}
\xintthealign\xintexpr ndmap(foo, 1000,2000,3000; 100,200,300; 10,20,30; 1,2,3)\relax
\end{multicols}
\end{everbatim*}

\funcdesc[expr, var1=values1; var2=values2; ....; varN = valuesN{[;]}]{ndseq}
%
Constructs a nested list (a priori having |N| dimensions) from
substitutions in an expression involving |N| (dummy) variables.  The
expression is not constrained to produce only scalar values.  Only in the
latter case is the output really an |N|-dimensional \myenquote{|ndlist|} type object.
An optional final semi-colon in the input before the closing parenthesis is
allowed.
\begin{everbatim*}
\begin{multicols}{2}
\xintthealign\xintexpr ndseq(a+b+c+d, a=1000,2000,3000; b=100,200,300;
                                                        c=10,20,30; d=1,2,3;)\relax
\end{multicols}% in case of page break, this makes amusing zigzag rendering
\end{everbatim*}

\end{description}

Recursions may be nested, with |@@@(n)| giving access to the values of the
outer recursion\dots and there is even |@@@@(n)| to access the outer outer
recursion but I never tried it!

The following keywords are recognized:
\begin{description}
  \keyworddesc{abort} it is a pseudo-variable which indicates to stop here and now.

  \keyworddesc{omit} it is a pseudo-variable which says to omit this value and
  go to next one.

  \funcdesc[stuff]{break} says to abort and insert |stuff| as last value.

  \keyworddesc{<integer>++} serves to generate a potentially infinite list. In
  conjunction with an \keyword{abort} or \func{break} this is often
  more efficient than iterating over a pre-established list of values.
\begin{everbatim*}
\xinttheiiexpr iter(1;(@>10^40)?{break(@)}{2@},i=1++)\relax
\end{everbatim*}
is the smallest power of 2 with at least fourty one digits.

The |i=<integer>++| syntax (any letter is allowed in place of |i|) works only
in the form |<letter>=<integer>++|, something like |x=10,17,30++| is not
legal. The |<integer>| must be a \TeX-allowable integer.
\begin{everbatim*}
First Fibonacci number at least |2^31| and its index
% we use iterr to refer via @1 and @2 to the previous and previous to previous.
\xinttheiiexpr iterr(0,1; (@1>=2^31)?{break(@1, i)}{@2+@1}, i=1++)\relax
\end{everbatim*}%
. If one also wants the previous Fibonacci number one only has to use |break(@2,
@1, i)| in the above example.
\end{description}


\subsection{Generators of arithmetic progressions}
\label{ssec:arithseq}

\begin{itemize}
  \item |a..b| constructs the \textbf{small} integers from the ceil $\lceil
    a\rceil$ to the floor
    $\lfloor b\rfloor$ (possibly a decreasing sequence): one has to be careful
    if using this for algorithms that |1..0| for example is not empty or |1|
    but expands to |1, 0|. Again, |a..b| \emph{can not} be used with |a| and
    |b| greater than $2^{31}-1$. Also, only about at most \dtt{5000} integers
    can be generated (this depends upon some \TeX{} memory settings).

    The |..| has lower precedence than the arithmetic operations.
\begin{everbatim*}
\xintexpr 1.5+0.4..2.3+1.1\relax; \xintexpr 1.9..3.4\relax; \xintexpr 2..3\relax
\end{everbatim*}

    The step of replacing $a$ by its ceil and $b$ by its floor is a kind of
    silly overhead, but $a$ and $b$ are allowed to be themselves the result
    of computations and there is no notion of \myenquote{int} type in \csbxint{eval}.
    The solution is, when $a$ and $b$ are given explicit integers to
    temporarily switch to the \csbxint{iiexpr} parser:
\begin{everbatim*}
\xintexpr \xintiiexpr 1..10\relax\relax
\end{everbatim*}

    On the other hand integers from |\xintexpr 1..10\relax| are already in
    raw \xintfracname format for example |3/1[0]| which speeds up their usage
    in the macros internally involved in computations...\@{} thus perhaps what one
    gains on one side is lost on the other side.

  \item |a..[d]..b| generates \myenquote{real} numbers along arithmetic progression
    of reason |d|. It does
    \emph{not} replace |a| by its ceil, nor |b| by its floor. The generated
    list is empty if |b-a| and |d| are of opposite signs; if |d=0| or if |a=b|
    the list expands to single element |a|.
\begin{everbatim*}
\xintexpr 1.5..[1.01]..11.23\relax
\end{everbatim*}

     At |1.4|, this generator behaves in \csbxint{floatexpr} exactly as in
     \csbxint{expr}, i.e.\@{} \emph{exactly}. This is breaking
     change.
\begin{everbatim*}
\xintDigits:=6;
\xintexpr\xintfloatexpr 100..[1.23456]..110\relax\relax
\xintDigits:=16;
\end{everbatim*}

     This demonstration embedded the float expression in the exact parser only
     to avoid the rounding to the prevailing precision on output, thus we can
     see that internally additions are done exactly and not with 
     \dtt{6} digits mantissas (in this example).
\end{itemize}

\subsection{Python slicing and indexing of one-di\-men\-sional sequences}
\label{ssec:lists}

We denote here by \emph{list} or \emph{sequence} a general \emph{ople}, either
given as a variable or explicitly. \emph{In the former case the parentheses are
optional}.%
%
\footnote{Even for an \myenquote{open list}, if it is given as a \emph{variable} then the indexing or slicing will not apply to its last item but to itself as an entity.}

\begin{itemize}
\item |(list)[n]| returns the |n+1|th item if |n>=0|. If |n<0| it enumerates
  items from the tail. Items are numbered as in Python, the
  first element corresponding to |n=0|.
\begin{everbatim*}
\xintexpr (0..10)[6], (0..10)[-1], (0..10)[23*18-22*19]\relax
\end{everbatim*}

This also works for singleton \emph{oples} which are in fact a \emph{number}:
\begin{everbatim*}
\xintexpr (7)[0], (7)[-1], 9, (7)[-2], 9\relax
\end{everbatim*}

In the example above the parentheses serve to disambiguate from the raw
\xintfracname format such as |7[-1]| which, although discouraged, is accepted
on input. And we used a trick to show that |(7)[-2]| returns |nil|.

The behaviour changes for singleton \emph{oples} which are not
\emph{numbers}. They are thus \emph{nutples}, or equivalently they are the
bracketing (bracing, packing) of another \emph{ople}. In this case, the meaning
of the syntax for item indexing is, as in Python, item
\emph{extraction}:

\begin{everbatim*}
\xintexpr [0,1,2,3,4,5][2], [0,1,2,3,4,5][-3]\relax\newline
\xintexpr [0,[1,2,3,4,5],6][1][-1]\relax
\end{everbatim*}

  \item |(list)[:n]| produces the first |n| elements if |n>0|, or suppresses
    the last \verb+|n|+ elements if |n<0|.
\begin{everbatim*}
\xintiiexpr (0..10)[:6]\relax\ and \xintiiexpr (0..10)[:-6]\relax
\end{everbatim*}

As above, the meaning change for \emph{nutples} and fits with expectations
from Python regarding its sequence types:
\begin{everbatim*}
\xintiiexpr [0..10][:6]\relax\ and \xintiiexpr [0..10][:-6]\relax
\end{everbatim*}

 \item |(list)[n:]| suppresses the first |n| elements if |n>0|, or extracts
    the last \verb+|n|+ elements if |n<0|.
\begin{everbatim*}
\xintiiexpr (0..10)[6:]\relax\ and \xintiiexpr (0..10)[-6:]\relax
\end{everbatim*}

As above, the meaning change for \emph{nutples} and fit with expectations
from Python with \emph{tuple} or \emph{list} types:
\begin{everbatim*}
\xintiiexpr [0..10][6:]\relax\ and \xintiiexpr [0..10][-6:]\relax
\end{everbatim*}

\item Finally, |(list)[a:b]| also works according to the Python ``slicing''
  rules (inclusive of negative indices). Notice though that stepping is
  currently not supported.
\begin{everbatim*}
\xinttheiiexpr (1..20)[6:13]\relax\ = \xinttheiiexpr (1..20)[6-20:13-20]\relax
\newline
\xinttheiiexpr [1..20][6:13]\relax\ = \xinttheiiexpr [1..20][6-20:13-20]\relax
\end{everbatim*}

\item It is naturally possible to execute such slicing operations one after
  the other (the syntax is simplified compared to before |1.4|):
\begin{everbatim*}
\xintexpr (1..50)[13:37][10:-10]\relax\newline
\xintexpr (1..50)[13:37][10:-10][-1]\relax
\end{everbatim*}
\end{itemize}


\subsection{NumPy like nested slicing and indexing for arbitrary oples and nutples}

I will give one illustrative example and refer to the NumPy documentation for
more.

Notice though that our interpretation of the syntax is more general than
NumPy's concepts (of basic slicing/indexing):
\begin{itemize}
\item slicing and itemizing apply also to non-bracketed objects i.e.\@{} \emph{oples},
\item the leaves do not have to be all at the same depth,
\item there are never any out-of-range index errors: out-of-range indices
  are silently ignored.
\end{itemize}

\begin{everbatim*}
\begin{multicols}{3}
\xintdefvar myArray = ndseq(a+b+c, a=100,200,300; b=40,50,60; c=7,8,9);
myArray = \xintthealign\xintexpr myArray\relax
\columnbreak
mySubArray = \xintthealign\xintexpr myArray[0:2,0:2,0:2]\relax
myExtractedSubArray = \xintthealign\xintexpr myArray[0:2,0:2,0:2][0]\relax
\columnbreak
myExtractedSubArray = \xintthealign\xintexpr myArray[0:2,0:2,0:2][0,1]\relax
\noindent
firstExtractedScalar = \xintexpr myArray[0:2,0:2,0:2][0,1,0]\relax\newline
secondExtractedScalar = \xintexpr myArray[0,1,0]\relax\par
\end{multicols}
\end{everbatim*}

As said before, \emph{stepping} is not yet implemented. Also the NumPy
extension to Python for item selection (i.e.\@{} via a |tuple| of comma separated
indices) is not yet implemented.

\subsection{Tacit multiplication}
\label{ssec:tacit multiplication}

Tacit multiplication (insertion of a |*|) applies when the parser is currently
either scanning the digits of a number (or its decimal part or scientific
part, or hexadecimal input), or is looking for an infix operator, and:
\begin{enumerate}[nosep, label=(\arabic*.)]
\item \relax\emph{encounters a count or dimen or skip register or variable or an
  \eTeX{} expression,} or
\item \emph{encounters a sub-\csa{xintexpr}ession}, or
\item \emph{encounters an opening parenthesis}, or
\item \emph{encounters a
  letter (which is interpreted as signaling the start of either a variable or
  a function name)}, or
\item (of course, only when in state "looking for an operator") \emph{encounters a digit}.
\end{enumerate}

\begin{framed}
  \centeredline{\textcolor{Red}{\textbf{!!!!ATTENTION!!!!}}}

  Explicit digits prefixing a variable, or a function, whose name starts with
  an |e| or |E| will trap the parser into trying to build a number in
  scientific notation. So the |*| must be explicitly inserted.

\begin{everbatim}
\xintdefiivar e := (2a+4b+6d+N)/:7;%
\xintdefiivar f := (c+11d+22*e)//451;% 22e would raise errors
\end{everbatim}

  I don't think I will fix this anytime soon...
\end{framed}

\begin{framed}
    For example, if |x, y, z| are variables all three of |(x+y)z|, |x(y+z)|,
    |(x+y)(x+z)| will create a tacit multiplication.

    Furthermore starting with release
    |1.2e|, %\MyMarginNote[\kern\dimexpr\FrameSep+\FrameRule\relax]{Changed}
    whenever tacit multiplication is applied, in all cases it \emph{always}
    ``ties'' more\IMPORTANT{} than normal multiplication or division, but
    still less than power. Thus |x/2y| is interpreted as |x/(2y)| and
    similarly for |x/2max(3,5)| but |x^2y| is still interpreted as |(x^2)*y|
    and |2n!| as |2*n!|.

\begin{everbatim*}
\xintdefvar x:=30;\xintdefvar y:=5;%
\xinttheexpr (x+y)x, x/2y, x^2y, x!, 2x!, x/2max(x,y)\relax
\end{everbatim*}

    Since |1.2q| tacit multiplication is triggered also in cases such as
    |(1+2)5| or |10!20!30!|.

\begin{everbatim*}
\xinttheexpr (10+7)5, 4!4!, add(i, i=1..10)10, max(x, y)100\relax
\end{everbatim*}

    The ``tie more'' rule applies to all cases of tacit multiplication. It
    impacts only situations with a division operator as the last seen
    operator, as multiplication is mathematically associative.
\begin{everbatim*}
\xinttheexpr 1/(3)5, (1+2)/(3+4)(5+6), 2/x(10), 2/10x,
                                 3/y\xintiiexpr 5+6\relax, 1/x(y)\relax\
differ from\newline\xinttheexpr 1/3*5, (1+2)/(3+4)*(5+6), 2/x*(10), 2/10*x,
                                3/y*\xintiiexpr 5+6\relax, 1/x*(y)\relax\par
\end{everbatim*}
\end{framed}

    Note that |y|\csbxint{theiiexpr}| 5+6\relax| would have tried to use a variable
    with name |y11| rather than doing |y*11|: tacit multiplication works only
    in front of sub-\csbxint{expr}essions, not in front of
    \csbxint{theexpr}essions which are unlocked into explicit digits.


Here is an expression whose meaning is
    completely modified by the ``tie more'' property of tacit multiplication:


\begin{everbatim}
\xintdeffunc e(z):=1+z(1+z/2(1+z/3(1+z/4)));
\end{everbatim}
will be parsed as
\begin{everbatim}
\xintdeffunc e(z):=1+z*(1+z/(2*(1+z/(3*(1+z/4)))));
\end{everbatim}
which is not at all the presumably hoped for:
\begin{everbatim}
\xintdeffunc e(z):=1+z*(1+(z/2)*(1+(z/3)*(1+(z/4))));
\end{everbatim}
% This case can be handled this way:
% \begin{everbatim}
% \xintdeffunc e(z):=(((z/4+1)z/3+1)z/2+1)z+1;
% \end{everbatim}


\subsection{User defined variables}
\label{ssec:uservariables}
\label{xintdefvar}
\label{xintdefiivar}
\label{xintdeffloatvar}

Since release |1.1| it is possible to make an assignment to a variable name
and let it be known to the parsers of \xintexprname. Since |1.2p| simultaneous
assignments are possible. Since |1.4| simultaneous assignments are possible with
a right-hand-side being a \texttt{nutple} which will be automatically unpacked.
\begin{everbatim*}
\xintdefvar myPi:=3.141592653589793238462643;%
$myPi = \xinteval{myPi}$\newline % (there is already built-in Pi variable)
\xintdefvar x_1, x_2, x_3 := 10, 20, 30;%
$x_1 = \xinteval{x_1}, x_2 = \xinteval{x_2}, x_3 = \xinteval{x_3}$\newline
\xintdefvar x_1, x_2, x_3 := [100, 200, 300];%
$x_1 = \xinteval{x_1}, x_2 = \xinteval{x_2}, x_3 = \xinteval{x_3}$\par
\end{everbatim*}


Simultaneous assignments with more variables than values do not
raise an error but simply set the extra variables to the \dtt{nil} value.
\begin{everbatim*}
\xintdefiivar a, b, c := [1, 2];% will be automatically unpacked
The value of a is \xinteval{a}, the one of b is \xinteval{b} and
the one of c is \xinteval{c}.
\end{everbatim*}
\begin{everbatim*}
\xintdefiivar a, b, c := 314;%
The value of a is \xinteval{a}, the one of b is \xinteval{b} and
the one of c is \xinteval{c}.
\end{everbatim*}

Notice that \dtt{nil} variables must be used with caution as they break
arithmetic operations if used as operands to them. And they are not the same
as the \dtt{None} variables, which can also be input as |[]|.

Simultaneous assignments with less variables than values do not
raise an error but set the last variable to be the ople concatenating the
remaining values.
\begin{everbatim*}
\xintdefiivar seq := 1..10;%
\xintdefiivar a, seq := seq;%
\xintdefiivar b, seq := seq;%
\xintdefiivar c, d, seq := seq;%
The value of a is \xinteval{a}, the one of b is \xinteval{b}, the one of c is \xinteval{c},
the one of d is \xinteval{d}, the one of seq is \xinteval{seq}.
\end{everbatim*}

In the above we define a variable |seq| but there is a built-in
function \func{seq}.  It is indeed allowed to use the same name for both a
variable and a function.%
%
\footnote{But until a bugfix added at release |1.4i|, some built-in function
  names (those implementing syntax with dummy variables, and the so-called
  \myenquote{pseudo}-functions) were fragile under such overloading.}
But for safety we will unassign |seq| now:
\begin{everbatim*}
\xintunassignvar{a}\xintunassignvar{b}\xintunassignvar{c}\xintunassignvar{d}%
\xintunassignvar{seq}%
\end{everbatim*}%
Single letter names |a..z| and |A..Z| are pre-declared by the package for use
as a special type of variables called ``dummy variables''.  Unnassigning them
restores this initial meaning.  See further \csbxint{unassignvar} and
\csbxint{newdummy}.  Since |1.4| even assigned variables can be used in the
call signatures of function declarations.

Regarding the manipulation of an \myenquote{open list} as above, there is no way
to obtain with only one use of the variable both its last item and the
reduction of the variable to its truncated self. One can do rather:
\begin{everbatim*}
\xintdefiivar mylist := 1..10;%
\xintdefiivar z, mylist := last(mylist), mylist[:-1];%
The value of z is \xinteval{z} and mylist is now \xinteval{mylist}.\par
\end{everbatim*}
This uses twice |mylist| and is about the same as doing it in two steps:
\begin{everbatim*}
\xintdefiivar w := last(mylist);%
\xintdefiivar mylist := mylist[:-1];%
The value of w is \xinteval{w} and mylist is now \xinteval{mylist}.%
\xintunassignvar{z}\xintunassignvar{w}\xintunassignvar{mylist}\par
\end{everbatim*}

It is recommended generally speaking to work with \myenquote{closed (i.e. bracketed)
lists} because only them and numbers can be arguments to functions (but see
\csbxint{deffunc} and the notion of variadic last argument).  For more on the
Python-like slicing used above see \autoref{ssec:lists} and
\autoref{sssec:opleslicing}.  For more information relative to variables
versus arguments see \autoref{sssec:funcargs}.
 
\begin{itemize}[noitemsep]
\item For catcodes issues (particularly, for the semi-colon used to delimit
  the fetched expression), see the discussion of \csbxint{exprSafeCatcodes} and some comments in the section documenting \csbxint{deffunc}.
\item 
  Both syntaxes |\xintdefvar foo := <expr>;| and |\xintdefvar foo = <expr>;|
  are accepted.
\item 
  Spaces in the variable name or around the equal sign are removed and are
  immaterial.
\item 
  The variable names are expanded in an |\edef| (and stripped of spaces).
Example:
\begin{everbatim}
\xintdefvar x\xintListWithSep{, x}{\xintSeq{0}{10}} := seq(2**i, i = 0..10);%
\end{everbatim}
This defines |x0|, |x1|, \dots, |x10| for future usage.
\end{itemize}

Legal variable names are composed of letters, digits, |_| and |@| and
characters.  A variable name must start with a letter. Variable names starting
with a |@| or |_| are reserved for internal usage.%
%
\footnote{The process of variable declaration does not check that these rules
  are met, and breakage will arise on use, if rules are not followed. For
  example, prior to |1.4g|, using a variable (illegally)
  declared with a name starting with a (normal, catcode 8) |_| triggered an
  infinite loop.}

As |x_1x_2| or even |x_1x| are licit variable names, and as the parser does
not trace back its steps, input syntax must be |x_1*x_2| if the aim is to
multiply such variables.

Using \csa{xintdefvar}, \csa{xintdefiivar}, or \csa{xintdeffloatvar} means
that the variable value will be computed using respectively \csa{xintexpr},
\csa{xintiiexpr} or \csa{xintfloatexpr}. It can then be used in all three
parsers, as long as the parser understands the format. Currently this means
that variables using \csa{xintdefvar} or \csa{xintdeffloatvar} can be used
freely either with \csa{xintexpr} or \csa{xintfloatexpr} but not with
\csa{xintiiexpr}, and variables defined via \csa{xintdefiivar} can be used in
all parsers.

When defining a variable with \csa{xintdeffloatvar} it (or
generally speaking its numerical leaves) is rounded to \csbxint{theDigits}
precision.  So the variable holds the same value as would be printed via
\csbxint{floateval} for the same computation.

Prior to |1.4e|, this was the case only if the variable definition actually
involved some computation.

However the \csbxint{floatexpr}|..\relax| wrapper by itself induces no rounding.  If
it is encountered in the typesetting flow, the print-out will be rounded to
\csbxint{theDigits} precision, but this is an effet of behaving like
\csbxint{floateval} in this context.
\begin{everbatim*}
% Since 1.4e, \xintdeffloatvar always rounds (to \xinttheDigits)
\xintdeffloatvar e:=2.7182818284590452353602874713526624977572470936999595749669676;%
1) \xintexpr  e\relax\newline  % shows the recorded value: it is rounded
2) \xintfloatexpr   % when used in typesetting flow, acts like \xintfloateval:
    2.7182818284590452353602874713526624977572470936999595749669676
\relax\newline   % the print-out is rounded.
3) \xintexpr 
  \xintfloatexpr
    2.7182818284590452353602874713526624977572470936999595749669676
  \relax
\relax\newline
%
% but we can see via the \xintexpr wrapper all the digits were there rounding
% can be forced using an extra 0+, the float() function, or the [D] option.
% tidbit: comparison operators do not pre-round, so 1.2345678 is not same as
% (1.2345678+0) in low precision.
%
\begingroup\xintDigits:=4;%
4) \xintifboolfloatexpr{1.2345 == 1.23456}
   {\error}{Different! Comparisons do not pre-round to Digits precision.}\newline
5) \xintifboolfloatexpr{1.2345 == 1.2345 + 0}
   {\error}{Different! Right hand side rounded from operation,
                       left hand side not rounded.}\par
\endgroup
\end{everbatim*}

% not so exciting example
% In the next examples we examine the effect of cumulated float operations on
% rounding errors:
% \begin{everbatim*}
% \xintdefvar       e_1:=add(1/i!, i=0..10);% exact sum
% \xintdeffloatvar  e_2:=add(1/i!, i=0..10);% float sum
% \xintthefloatexpr e_1, e_2\relax\newline
% \xintdefvar       e_3:=e_1+add(1/i!, i=11..20);% exact sum
% \xintdeffloatvar  e_4:=e_2+add(1/i!, i=11..20);% float sum
% \xintthefloatexpr e_3, e_4\relax\newline
% \xintdeffloatvar e:=2.7182818284590452353602874713526624977572470936999595749669676;%
% \xintDigits:=24\relax 
% \xintthefloatexpr[16] e, e^1000, e^1000000\relax (e rounded to 24 digits first)\newline
% \xintDigits:=16\relax 
% \xintthefloatexpr     e, e^1000, e^1000000\relax (e rounded to 16 digits first)\par
% \end{everbatim*}

After issuing \csbxint{verbosetrue} the values of defined variables are
written out to the log (and terminal). As in this example:
\begin{everbatim}
Package xintexpr Info: (on line 1)
    Variable myPi defined with value {3141592653589793238462643[-24]}.
Package xintexpr Info: (on line 2)
    Variable x_1 defined with value {10}.
Package xintexpr Info: (on line 2)
    Variable x_2 defined with value {20}.
Package xintexpr Info: (on line 2)
    Variable x_3 defined with value {30}.
Package xintexpr Info: (on line 3)
    Variable List defined with value {0}{1}{3}{6}{10}{15}{21}{28}{36}{45}{55}
.
Package xintexpr Info: (on line 4)
    Variable Nuple defined with value {{0}{1}{9}{36}{100}{225}{441}{784}{1296
}{2025}{3025}}.
Package xintexpr Info: (on line 5)
    Variable FourthPowers defined with value {{0}{1}{81}{1296}{10000}{50625}{
194481}{614656}{1679616}{4100625}{9150625}}.
\end{everbatim}

\subsubsection{\csh{xintunassignvar}}
\label{xintunassignvar}

\csa{xintunassignvar}\marg{variable} will make the \meta{variable} un-assigned.
For example in the previous section we used
\begin{everbatim}
\xintdeffloatvar e := ...some value...;
\end{everbatim}
To undo one either waits for the current scope (e.g.\@ a \LaTeX{}
environment) to expire or the impatient does:
\begin{everbatim*}
\xintunassignvar{e}
\end{everbatim*}

In this special case\IMPORTANT{} of using \csa{xintunassignvar} with a
single \meta{letter} the effect is actually to let 
the \meta{letter} recover the meaning of a dummy variable (i.e.\@ it is
the same as using \csbxint{newdummy} documented in the next section):
\begin{everbatim*}
% overwriting a dummy letter
\xintdefvar i := 3;%
\xinteval{i^3} is as expected but |\xinteval{add(i,i=1..10)}| computes 
\xinteval{add(i,i=1..10)} because "i" has the fixed value 3.\newline
\xintunassignvar{i}% back to normal
After |\xintunassignvar{i}|
|\xinteval{add(i,i=..10)}| is evluated with "i" acting as a dummy variable
and thus outputs \xinteval{add(i,i=1..10)}.\par
\end{everbatim*}

Under \csbxint{globaldefstrue} regime the effect of \csa{xintunassignvar} is
of global scope.

\subsubsection{\csh{xintnewdummy}}
\label{xintnewdummy}


Any catcode 11 character can serve as a dummy variable, via this declaration:
\begin{everbatim}
\xintnewdummy{<letter>}% the <letter> must be of catcode letter!
\end{everbatim}
For example with Lua\TeX\ or Xe\TeX\ the following works:
\begin{everbatim}
% Requires a Unicode engine
\xintnewdummy{ξ}
\xinteval{add(ξ, ξ=1..10)}
\end{everbatim}

Starting with |1.4|, it is allowed to use \csa{xintnewdummy} to define
``dummy variables'' having names with more than one letter.  They can
then be used as expected:
\begin{everbatim}
% Requires a Unicode engine
\xintnewdummy{ατλν}
\xintdeffunc test(ατλν) = sqr(1 + ατλν);
\xinteval{seq(test(ατλν), ατλν = 0..10)}
\end{everbatim}

Remark regarding Op\TeX: it is a format using Lua\TeX, but non ascii
letters have catcode ``other''.  So for the above example to compile
with |optex|, the catcodes need to be set to ``letter'' beforehand:
\begin{everbatim}
% Requires a Unicode engine
% next line is required if with OpTeX (only):
\xintFor* #1 in {ατλν}\do{\catcode`#1=11 }
\xintnewdummy{ατλν}
\xintdeffunc test(ατλν) = sqr(1 + ατλν);
\xinteval{seq(test(ατλν), ατλν = 0..10)}
\end{everbatim}

Under \csbxint{globaldefstrue} regime the effect of \csa{xintnewdummy} is
of global scope.

\subsubsection{\csh{xintensuredummy}, \csh{xintrestorevariable}}
\label{xintensuredummy}
\label{xintrestorevariable}

Use
\begin{everbatim}
\xintensuredummy{<character>}
...
... code using the (catcode 11) character as a dummy variable
...
\xintrestorevariable{<character>}
\end{everbatim}
if other parts need the letter as an assigned variable name. For example
\calxtrigname being written at high level needs a few genuine dummy variables,
and it uses \csbxint{ensuredummy} to be certain everything is ok.

\subsection{User defined functions}
\label{ssec:userfunctions}
\def\tocstylesubsubsectionHOOK#1#2#3{}
\etocsetnexttocdepth{subsubsection}
\localtableofcontents
\let\tocstylesubsubsectionHOOK\empty


\subsubsection{\csh{xintdeffunc}}
\label{xintdeffunc}

Here is an example:
\begin{everbatim*}
\xintdeffunc
    Rump(x,y):=1335 y^6/4 + x^2 (11 x^2 y^2 - y^6 - 121 y^4 - 2) + 11 y^8/2 + x/2y;
\end{everbatim*}(notice the numerous tacit multiplications in this expression;
and that |x/2y| is interpreted as |x/(2y)|.)

\begin{framed}
  \begin{itemize}
  \item The ending semi-colon is allowed to be of active catcode, as
    |\xintdeffunc| temporarily resets catcodes via
    \csbxint{exprSafeCatcodes} before parsing the expression.

    But this will fail if the whole thing is inside a macro
    definition. Then the used semi-colon must be the standard one.

    In the case of a \LaTeX{} document using Babel, and a language such
    as French which makes the semi-colon active, it is still the
    standard one inside the preamble, so there is no problem there.

    For a macro definition done inside the document body, which, as I
    understand, is sin, almost evil, either turn off locally the
    activation (|\string;| will not work because \csbxint{deffunc} uses
    delimited macros to fetch all the way to the semi-colon), or define
    in the preamble |\MyDefFunc{#1}| to do |\xintdeffunc #1;| and use
    that in the |\newcommand\foo| inside the document body.

  \item Semi-colons used inside the expression need not be hidden inside
    braces. (new with |1.4|)
  \item The colon before the equal sign is optional and its (reasonable)
    catcode does not matter.
  \end{itemize}
\end{framed}

Here are a few important items (bookmark this for reading again later once you
have gained experience in using this interface...):
\begin{itemize}
\item  The function names are composed of letters, digits, underscores or |@|
  signs. A function name must start with a letter. It may be a single letter
  (see \autoref{sssec:overload}).
\item The variable names used in the function signature may be multi-letter
  words. It is also allowed for them to already be in use for previously
  declared variables. Their meanings will get restored for usage after the
  function declaration.
\item A function can be declared with at most nine arguments. It can be declared as a
  function with no arguments.
\item If in the function declaration the last argument is
  prefixed by |*|, it stands for a |nutple| which will gather all arguments of
  the function call beyond the first positional ones. See \autoref{sssec:funcargs}
  for additional explanations on such \myenquote{variadic} arguments.
\item Recursive definitions are possible; for them to not generate error or
  fall in infinite loops, the use of the short-circuit conditionals |?| and
  |??| is \emph{mandatory}.
\item If a function is used in another definition it will check if it is
  applied to numerical arguments and if this is the case will expand
  fully.
\item The previous item has an exception for functions with no arguments; they
  never expand immediately in other function definitions (else they would be
  almost like variables). This provides a way to define functions with
  parameters: simply let their definition use some functions with no arguments.
\item A function declared via \csbxint{deffunc} remains \fbox{unknown} to
  \csbxint{floatexpr} (or \csbxint{floateval}). See \csbxint{deffloatfunc},
  \csbxint{defiifunc}. One can use the same formula in a new definition, but
  if one wants the expansion to execute in a parser independent way, one can
  transfer a function with scalar values like this:
\begin{everbatim}
\xintdeffloatfunc foo(x) := float_dgt(\xintexpr foo(x)\relax);
\end{everbatim}
  The \func{float\string_dgt} wrapper (which was renamed at
  |1.4e|) is in order for the float variant to produce an already-rounded
  value, possibly speeding-up usage if used as input for other
  functions. Using \func{float} here would work the same but the produced
  function would incorporate a routine to check (at time of use, because at
  time of definition it is impossible to tell what will be the case) if it is
  applied to one or two arguments.

\item And in the reverse direction one can do:
\begin{everbatim}
\xintdeffunc bar(x) := \xintfloatexpr bar(float(x))\relax;
\end{everbatim}
  With this the transplanted float-function will expand in \csbxint{expr} as
  it would have in \csbxint{floatexpr}, i.e.\@{} using float operations; this is
  different from declaring the function again with the same expression as used
  for the original, as it would have then been parsed with a mapping of infix
  operators to the macros doing the exact operations, not the floating point
  ones.

  The inner \func{float} above is not mandatory but recommended: the macro
  associated to the user float function |bar(x)| may use many times its
  argument |x| and does not worry about rounding it, because its expectation
  is that it is already rounded; but in \csbxint{expr} that value could very
  well be a fraction |19/13| and its float rounding will be done again by each
  float macro receiving it as argument; with a \func{float} used as above this
  will have already been done once and the ulterior roundings are faster: they
  have nothing to do apart from realizing that they have nothing to do.... One
  can also use \func{sfloat}, this would serve to nothing for the |19/13| case
  but would possibly for a short integer input involved in multiplications.

  Here it is not needed to use \func{float\string_dgt}, because it will be
  identified at time of definition that \func{float} is used without optional
  argument.

  An external \func{float\string_dgt} could be added but is not a priori
  necessary, except perhaps if the |bar()| function has been defined at a low
  level using support macros producing output with garbage extra digits, which
  usually would be rounded out in input to other float functions.

\end{itemize}


A function once declared is a first class citizen, its
expression is entirely parsed and converted into a big nested \fexpan dable
macro. 

When used its action is via this defined macro. For example
\begin{everbatim*}
\xintdeffunc
     e(z):=(((((((((z/10+1)z/9+1)z/8+1)z/7+1)z/6+1)z/5+1)z/4+1)z/3+1)z/2+1)z+1;
\end{everbatim*}
creates a macro whose meaning one can find in the log file, after
\csbxint{verbosetrue}. Here it is (it has at |1.4| an extra external brace pair
compared to what happened with earlier releases):
\begin{everbatim}
    Function e for \xintexpr parser associated to \XINT_expr_userfunc_e with me
aning macro:#1->{\xintAdd {\xintMul {\xintAdd {\xintDiv {\xintMul {\xintAdd {\x
intDiv {\xintMul {\xintAdd {\xintDiv {\xintMul {\xintAdd {\xintDiv {\xintMul {\
xintAdd {\xintDiv {\xintMul {\xintAdd {\xintDiv {\xintMul {\xintAdd {\xintDiv {
\xintMul {\xintAdd {\xintDiv {\xintMul {\xintAdd {\xintDiv {#1}{10}}{1}}{#1}}{9
}}{1}}{#1}}{8}}{1}}{#1}}{7}}{1}}{#1}}{6}}{1}}{#1}}{5}}{1}}{#1}}{4}}{1}}{#1}}{3}
}{1}}{#1}}{2}}{1}}{#1}}{1}}
\end{everbatim}

The above is not entirely true. At |1.4|, \csbxint{deffunc} is
more powerful and digests more of the syntax but it may have to store it in
such a way that usage will be done via a sub-expression: hence it is not the
case that the original expression has been \emph{entirely} parsed. See
\csbxint{NewFunction} for related discussion.

The main difficulty of \csbxint{deffunc} is with the pseudo-functions
\func{seq}, \func{iter}, etc..., which admit the keywords \keyword{omit},
\keyword{abort}, \func{break}. We have no alternative for them, if the
iterated over values are not entirely numerical than to postpone expansion,
but this means simply storing for later a possibly big sub-expression.

At |1.4| we did some obstinate work to make this working but:
\begin{itemize}
\item this means that the stored function body has not been entirely parsed,
  parsing will happen on the fly at each execution for small or large bits,
\item there remains a main stumbling-block. If the variables used in the
  function declaration are used only in the iterated over values or the
  initial values, then the mechanism may work. If however they are used not
  only in those values iterated over but directly in the expression which the
  generators map to the iterated over values, then it will break
  certainly. Indeed at this stage the variables are simply names, and it is
  impossible to transfer the mechanism which converts these names into
  numerical arguments for delayed usage by the declared function. Except if
  one is ready to basically freeze the entire thing; which then is not any
  different at all than using \csbxint{NewFunction}.
\end{itemize}

Conclusion: if some \csbxint{deffunc} break, check if it does not fit the
above criterion before reporting...\@{} and recall \csbxint{NewFunction} is your
friend. It has the big advantage of declaring a function for all parsers
simultaneously!

A special note on \func{subs}: it is and has always been hopeless in \csbxint{deffunc}
context. All it does (if it works at all) after being malaxed by
\csbxint{deffunc} is to copy over at the indicated places the \emph{recipe} to
compute something. Thus at every location where that something is needed it will be
evaluated from scratch again. Yes, this is disappointing. But...\@{} on the other
hand the more general \func{seq} does work, or pretends to work. Let me
illustrate to make thinks clear. We start with this:
\begin{everbatim*}
\xintverbosetrue
\xintdeffunc foo(x,y,z) = subs(S + S^2, S = x+y+z);
\xintdeffunc bar(x,y,z) = seq(S + S^2, S = x+y+z);
\xintexpr foo(100,10,1), bar(100,10,1)\relax
\xintverbosefalse
\end{everbatim*}

It produces in the log:
\begin{everbatim}
Package xintexpr Info: (on line 2)
    Function foo for \xintexpr parser associated to \XINT_expr_userfunc_foo wit
h meaning macro:#1#2#3->{\xintAdd {\xintAdd {\xintAdd {#1}{#2}}{#3}}{\xintPow {
\xintAdd {\xintAdd {#1}{#2}}{#3}}{2}}}
Package xintexpr Info: (on line 3)
    Function bar for \xintexpr parser associated to \XINT_expr_userfunc_bar wit
h meaning macro:#1#2#3->\expanded \bgroup \expanded {\unexpanded {\XINT_expr_se
q:_b {\xintbareeval S + S^2\relax !S}}{\xintAdd {\xintAdd {#1}{#2}}{#3}}^}
\end{everbatim}
Even without understanding all details one sees that in the first case the
|\xintAdd {\xintAdd {#1}{#2}}{#3}}| appears twice, and in the second case only
once.  But in the second case we have a yet to evaluate expression. So the
second approach is not much different in its effect than using the more
simple-minded \csbxint{NewFunction}. Besides one gets a feeling why the
function arguments can not appear in the expression but only in the iterated
over values, because there is no way to understand what |x|, |y|, |z| are
supposed to mean without adding extra structure showing they map to |#1|,
|#2|, |#3|.

The above remarks apply to \func{subsm} and \func{subsn}. Even if they do work
in \csbxint{deffunc} context (warning, testing at |1.4| release has remained
minimal), they will not bring added efficiency if the substituted values are
to be used multiple times. They may still be useful to visually simplify the
input of a big expression by expressing it in terms of smaller constituents.

Another workaround if one wants genuine (not \myenquote{macro}-) functions for some
expression where the same thing is used multiple times is to define helper
functions computing the intermediate data. One can see illustrations of this
in the code source of \calxtrigname (or in the matrix multiplication example
at the end of this chapter).

\subsubsection{\csh{xintdefiifunc}}
\label{xintdefiifunc}

With \csbxint{deffunc} the created function is known by the \csbxint{expr}
parser only. 
For usage in the \csbxint{iiexpr} parser, it is required to use
\csa{xintdefiifunc}.

\subsubsection{\csh{xintdeffloatfunc}}
\label{xintdeffloatfunc}

With \csbxint{deffunc} the created function is known by the \csbxint{expr}
parser only. For usage in the \csbxint{floatexpr} parser, it is required to use
\csa{xintdeffloatfunc}.

Note: the optional argument |[Q]| accepted by \csbxint{floatexpr} does not
work with \csbxint{deffloatfunc}. It is still possible to wrap the expression
in |float(expression,Q)|, if it evaluates to a scalar.

\subsubsection{\csh{xintdefufunc}, \csh{xintdefiiufunc}, \csh{xintdeffloatufunc}}
\label{xintdefufunc}
\label{xintdefiiufunc}
\label{xintdeffloatufunc}

This allows to define so-called \myenquote{Universal functions}. This is terminology
borrowed from |NumPy|.

Here is an example:
\begin{everbatim*}
\xintdefiivar Array = ndmap(lcm, 1..5; 1..10; 1..10);
Array = \xintthealign\xintiiexpr Array\relax
\xintdefiiufunc foo(x) = x^3;
\begin{figure}[htbp]
\caption{Output of a universal function acting on an array}\label{fig:ufunc}
\centeredline{$\vcenter{\xintthealign\xintiiexpr foo(Array)\relax}$}
\end{figure}
See \autopageref{fig:ufunc} for the output.
\end{everbatim*}

The function can be applied to any nested strucure:
\begin{everbatim*}
\xintiiexpr foo([1, [2, [3, [4, [5, 6, 7, 8, 9, 10]]]]])\relax
\end{everbatim*}

It must be defined as function acting on scalars, but its value type is not constrained.
\begin{everbatim*}
\xintdefiivar Array = [1..10];
\xintdefiiufunc foo(x) = [1..x];
\xintthealign\xintiiexpr foo(Array)\relax
\end{everbatim*}

It is even allowed to produce oples and act on oples:
\begin{everbatim*}
\xintdefiivar Ople = 1..10;
\xintdefiiufunc bar(x) = x, x^2, x^3;
\xintiiexpr bar(Ople)\relax
\end{everbatim*}


\subsubsection{Using the same name for both a variable and a function}
\label{sssec:overload}

It is licit to overload a variable name (all Latin letters are predefined as
dummy variables) with a function name and vice versa. The parsers will decide
from the context if the function or variable interpretation must be used
(dropping various cases of tacit multiplication as normally applied).
\begin{everbatim*}
\xintdefiifunc f(x):=x^3;
\xinttheiiexpr add(f(f),f=100..120)\relax\newline
\xintdeffunc f(x,y):=x^2+y^2;
\xinttheexpr mul(f(f(f,f),f(f,f)),f=1..10)\relax
\xintunassigniiexprfunc{f}\xintunassignexprfunc{f}%
\end{everbatim*}

\subsubsection{\csh{xintunassignexprfunc}, \csh{xintunassigniiexprfunc},
  \csh{xintunassignfloatexprfunc}}
\label{xintunassignexprfunc}
\label{xintunassigniiexprfunc}
\label{xintunassignfloatexprfunc}

Function names can be unassigned via \csa{xintunassignexprfunc}\marg{name},
\csa{xintunassigniiexprfunc}\marg{name}, and
\csa{xintunassignfloatexprfunc}\marg{name}.
\begin{everbatim*}
\xintunassignexprfunc{e}
\xintunassignexprfunc{f}
\end{everbatim*}

Warning: no check is done to avoid undefining built-in functions...

\subsubsection{\csh{ifxintverbose} conditional}
\label{xintverbosetrue}
\label{xintverbosefalse}
\label{ifxintverbose}

With |\xintverbosetrue| the meanings of the
functions (or rather their associated macros) will be written to the log. For
example the |Rump| declaration above generates this in the log file:
\begin{everbatim}
    Function Rump for \xintexpr parser associated to \XINT_expr_userfunc_Rump w
ith meaning macro:#1#2->{\xintAdd {\xintAdd {\xintAdd {\xintDiv {\xintMul {1335
}{\xintPow {#2}{6}}}{4}}{\xintMul {\xintPow {#1}{2}}{\xintSub {\xintSub {\xintS
ub {\xintMul {11}{\xintMul {\xintPow {#1}{2}}{\xintPow {#2}{2}}}}{\xintPow {#2}
{6}}}{\xintMul {121}{\xintPow {#2}{4}}}}{2}}}}{\xintDiv {\xintMul {11}{\xintPow
 {#2}{8}}}{2}}}{\xintDiv {#1}{\xintMul {2}{#2}}}}
\end{everbatim}

\begin{framed}
  The meanings written out to the log for more complicated functions may
  sometimes use the same character at different locations but with different
  catcodes.\IMPORTANTf

  It may thus be impossible to retokenize it (even after having removed the
  extra spaces from the added line breaks).

  This is in contrast with variable values which are always output in the log
  in the benign way, using digits, braces and some characters of catcode 12.
\end{framed}

\subsubsection{\csh{ifxintglobaldefs} conditional}
\label{xintglobaldefstrue}
\label{xintglobaldefsfalse}
\label{ifxintglobaldefs}

If true user defined variables (\csbxint{defvar}, ...) and functions
(\csbxint{deffunc}, ..., \csbxint{NewFunction}) for the expression parsers, as
well as macros obtained via \csbxint{NewExpr} et al.\@{} have global scope. If
false (default) they have local scope.

\subsubsection{\csh{xintNewFunction}}
\label{xintNewFunction}

This is syntactic sugar which allows to use notation of functions for what is
nothing more in disguise than a \TeX{} macro. Here is an example:
\begin{everbatim*}
\xintNewFunction {foo}[3]{add(mul(x+i, i=#1..#2),x=1..#3)}
\end{everbatim*}

We now have a genuine function |foo()| of three variables which can
be used in \emph{all three parsers}.
\begin{everbatim*}
\xintexpr seq(foo(0, 3, j), j= 1..10)\relax
\end{everbatim*}

Each time the created \myenquote{macro-function} |foo()| will be encountered the
corresponding replacement text will get inserted as a sub-expression (of the
same type as the surrounding one), the macro parameters having been replaced
with the (already evaluated) function arguments, and the parser \emph{will
  then have to parse the expression.} It is very much like a macro
substitution, but with parentheses and comma separated arguments (which can be
arbitrary expressions themselves).

It differs fundamentally from \csbxint{deffunc} as it realizes no pre-parsing
whatsoever of the associated sub-expression; using it shortens the input but
not the parsing time (which however is most of the time negligible compared to
actual numerical computations).  Use it for syntax which \csbxint{deffunc}
does not parse successfully.


\subsection{Examples of user defined functions}

\subsubsection{Example with vectors and matrices}
\label{sssec:csv}

Suppose we want to manipulate 3-dimensional vectors, which will be represented
as |nutples| of length 3. And let's add a bit of matrix algebra.
\begin{everbatim*}
\xintdeffunc dprod(V, W) := V[0]*W[0] + V[1]*W[1] + V[2]*W[2];
\xintdeffunc cprod(V, W) := [V[1]*W[2] - V[2]*W[1],
                             V[2]*W[0] - V[0]*W[2],
                             V[0]*W[1] - V[1]*W[0]];
\xintdeffunc Det3(U, V, W) := dprod(cprod(U, V), W);
\xintdeffunc DetMat(M) = Det3(*M);
\xintdeffunc RowMat(U, V, W) := [U, V, W];
\xintdeffunc ColMat(U, V, W) := [[U[0], V[0], W[0]],
                                 [U[1], V[1], W[1]],
                                 [U[2], V[2], W[2]]];
\xintdeffunc MatMul(A, B) := 
 [[A[0,0]*B[0,0]+A[0,1]*B[1,0]+A[0,2]*B[2,0],
   A[0,0]*B[0,1]+A[0,1]*B[1,1]+A[0,2]*B[2,1],
   A[0,0]*B[0,2]+A[0,1]*B[1,2]+A[0,2]*B[2,2]],
  [A[1,0]*B[0,0]+A[1,1]*B[1,0]+A[1,2]*B[2,0],
   A[1,0]*B[0,1]+A[1,1]*B[1,1]+A[1,2]*B[2,1],
   A[1,0]*B[0,2]+A[1,1]*B[1,2]+A[1,2]*B[2,2]],
  [A[2,0]*B[0,0]+A[2,1]*B[1,0]+A[2,2]*B[2,0],
   A[2,0]*B[0,1]+A[2,1]*B[1,1]+A[2,2]*B[2,1],
   A[2,0]*B[0,2]+A[2,1]*B[1,2]+A[2,2]*B[2,2]]];

\xintdefvar vec1, vec2, vec3 := [1, 1, 1], [1, 1/2, 1/4], [1, 1/3, 1/9];
\xintdefvar mat1 = RowMat(vec1, vec2, vec3);
\xintdefvar mat2 = ColMat(vec1, vec2, vec3);
\xintdefvar mat12 = MatMul(mat1,mat2);
\xintdefvar mat21 = MatMul(mat2,mat1);
Some computations (|align| executes multiple times hence we pre-computed!):
\begin{align*}
   M_1      &= \vcenter{\xintthealign \xintexpr mat1\relax}&&\qquad
   M_2 . M_1 = \vcenter{\xintthealign \xintexpr mat21\relax}\\[3\jot]
   M_2      &= \vcenter{\xintthealign \xintexpr mat2\relax}&&\qquad
   M_1 . M_2 = \vcenter{\xintthealign \xintexpr mat12\relax}
\end{align*}
$$
   \det(M_1)     = \xinteval{DetMat(mat1)},\quad
   \det(M_1.M_2) = \xinteval{reduce(DetMat(mat12))},\quad
   \det(M_2.M_1) = \xinteval{reduce(DetMat(mat21))}
$$
\end{everbatim*}%
For some hair-raising experience check the \csbxint{verbosetrue} output in the
log...\@{} here is an alternative with two (three, counting |dprod()|) helper
functions:
\begin{everbatim*}
% annoying that Tr also starts Trace, but Spur is available
% well Sp also starts Spectrum. Big problems.
\xintdeffunc Tr(M) := 
     [[M[0,0], M[1,0], M[2,0]],
      [M[0,1], M[1,1], M[2,1]],
      [M[0,2], M[1,2], M[2,2]]];

\xintdeffunc MatMul_a(r1, r2, r3, c1, c2, c3) :=
     [[dprod(r1, c1), dprod(r1, c2), dprod(r1, c3)],
      [dprod(r2, c1), dprod(r2, c2), dprod(r2, c3)],
      [dprod(r3, c1), dprod(r3, c2), dprod(r3, c3)]];

\xintdeffunc MatMul(A, B) := MatMul_a(*A, *Tr(B));
\end{everbatim*}

And once we have the transpose and the scalar product of vectors, we can
simply use \func{ndmap} for a lean syntax (this would extend to arbitrary
dimension):
\begin{everbatim*}
\xintdeffunc MatMul(A, B) = ndmap(dprod, *A; *Tr(B));
\xintdefvar mat1212 = MatMul(mat12, mat12);
\begingroup
\def\xintexprPrintOne       #1{\xintTeXFrac{#1}}%
\def\xintexpralignbegin       {\begin{pmatrix}}%
\def\xintexpralignend         {\end{pmatrix}}%
\def\xintexpralignlinesep     {\noexpand\\[2\jot]}% counteract an internal \expanded
\def\xintexpraligninnersep    {&}%
\let\xintexpralignleftbracket\empty  \let\xintexpralignleftsep\empty
\let\xintexpralignrightbracket\empty \let\xintexpralignrightsep\empty
$$ \xintthealign \xintexpr mat1\relax \cdot \xintthealign \xintexpr mat2\relax \cdot
   \xintthealign \xintexpr mat1\relax \cdot \xintthealign \xintexpr mat2\relax =
   \xintthealign \xintexpr mat12\relax ^2 = \xintthealign \xintexpr mat1212\relax$$
$$ \det(M_1\cdot M_2 \cdot M_1 \cdot M_2) = \xinteval{reduce(DetMat(mat1212))}$$
\endgroup
\end{everbatim*}

\subsubsection{Example with the \textsc{Rump} test}
\label{sssec:Rump}

Let's try out our |Rump()| function:
\begin{everbatim*}
\xinttheexpr Rump(77617,33096)\relax.
\end{everbatim*}
Nothing problematic for an \emph{exact} evaluation, naturally!

Thus to test the \textsc{Rump} polynomial (it is not quite a polynomial with
its |x/2y| final term) with floats, we \emph{must} also
declare |Rump| as a function to be used there:
\begin{everbatim*}
\xintdeffloatfunc
    Rump(x,y):=333.75 y^6 + x^2 (11 x^2 y^2 - y^6 - 121 y^4 - 2) + 5.5 y^8 + x/2y;
\end{everbatim*}

The numbers are scanned with the current precision, hence as here it is
\dtt{16}, they are scanned exactly in this case. We can then vary the
precision for the evaluation.
\begin{everbatim*}
\def\CR{\cr}
\halign
{\tabskip1ex
\hfil\bfseries#&\xintDigits:=\xintiloopindex\relax
                \xintthefloatexpr Rump(77617,33096)#\cr
\xintiloop [8+1]
\xintiloopindex &\relax\CR
\ifnum\xintiloopindex<40 \repeat
}
\end{everbatim*}

\subsubsection{Examples of recursive definitions}
\label{sssec:recursive}

Recursive definitions \emph{require} using the short-circuit branching
operators.
\begin{everbatim*}
\xintdeffunc GCD(a,b):=(b)?{GCD(b,a/:b)}{a};
\end{everbatim*}
This of course is the Euclide algorithm: it will be here applied to variables
which may be fractions. For example:
\begin{everbatim*}
\xinttheexpr GCD(385/102, 605/238)\relax
\end{everbatim*}

There is already a built-in \func{gcd} (which
accepts arbitrarily many arguments):
\begin{everbatim*}
\xinttheexpr gcd(385/102, 605/238)\relax
\end{everbatim*}

Our second example is modular exponentiation:
\begin{everbatim*}
\xintdefiifunc powmod_a(x, m, n) :=
       isone(m)?
           % m=1, return x modulo n
           {   x /: n  }
           % m > 1 test if odd or even and do recursive call
           {   odd(m)? {  x*sqr(powmod_a(x, m//2, n)) /: n }
                       {    sqr(powmod_a(x, m//2, n)) /: n }
            }
         ;
\xintdefiifunc powmod(x, m, n) := (m)?{powmod_a(x, m, n)}{1};
\end{everbatim*}
I have made the definition here for the |\xintiiexpr| parser; we could do the
same for the |\xintexpr|-parser (but its usage with big powers would quickly
create big denominators, think |powmod(1/2, 1000, 1)| for example.)
\begin{everbatim*}
\xinttheiiexpr seq(powmod(x, 1000, 128), x=9, 11, 13, 15, 17, 19, 21)\relax\par
\end{everbatim*}
The function assumes the exponent is non-negative (the Python |pow| behaved
the same until |3.8| release), but zealous users will add the necessary code for negative
exponents, after having defined another function for modular inverse!

If function |A| needs function |B| which needs function |A| start by giving to
|B| some dummy definition, define |A|, then define |B| properly. TODO: add
some example here...

\subsection {Links to some (old) 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}
% ça va sans dire
% 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{Oples and nutples: the \texttt{1.4} terminology}
\label{oples}

\emph{Skip this on first reading, else you will never start using the
  package.} \fbox{SKIP THIS!} (understood?)

In this section I will describe a mathematical terminology which models
how the parser handles the input syntax with numbers, commas, and brackets,
and how it maps internally to \TeX\ specific concept, particularly braces and
macro arguments.

\etocsetnexttocdepth{subsubsection}
\localtableofcontents

\subsubsection{Base terminology}

We start with a set $\mathcal{A}$ of \emph{atoms}, which represent numeric
data. In \TeX{} syntax such \emph{atoms} are always braced, more precisely,
currently they look like
%
\centeredline{\dtt{\{raw format within \TeX{} braces\}}}
%
The \TeX{} braces are not set-theoretical braces here, they are simply used
for \TeX nical reasons (one could imagine using rather some terminator token,
but ultimately support macros for built-in and user defined functions rely on
\TeX\ macros with undelimited parameters, at least so far).

Our category $\mathcal{C}$ of \myenquote{oples} is the smallest collection of
\emph{totally ordered finite sets} verifying these properties:
\begin{enumerate}
\item The empty set \dtt{$\emptyset$} is an \emph{ople}, i.e.\@{} it belongs to
  $\mathcal{C}$.
\item Each singleton set \dtt{$\{O\}$} whose element \dtt{$O$} is either an
  \emph{atom} $a\in\mathcal{A}$ or an \emph{ople} qualifies as an \emph{ople}.
\item $\mathcal{C}$ is stable by concatenation.
\end{enumerate}

Notes:
\begin{itemize}
\item 
We refer to the empty set \dtt{$\emptyset$} via the variable \emph{nil}.%
%
\footnote{There is
actually a built-in variable with this name. At |1.4|, |\xintexpr\relax| is
legal and also generates the \emph{nil}.}

\item It is convenient to accept the empty set as being also an
  \emph{atom}.  If this is done, then we may refer to the original
  \emph{atoms} (elements of $\mathcal{A}$) as \emph{non empty numerical data}.

\item
Concatenation is represented in the syntax by the
comma. Thus repeated commas are like only one and |nil| is a neutral element.

\item A singleton \emph{ople} \dtt{$\{a\}$} whose single element is a
  (non-empty) \emph{atom} is called a \emph{number}.%
%
  \footnote{This has to be taken in a general sense, for example with
    \ctanpackage{polexpr}, polynomials are represented by such \myenquote{numbers}.}
%

\item
The operation of constructing \dtt{$\{O\}$} from the \emph{ople} \dtt{$O$} is
called \emph{bracing} (set theory, \TeX), or \emph{bracketing} (\xintexprname
input syntax, Python |lists|), or \emph{packing} (as a reverse to Python's
unpacking of sequence type objects).  In the expression input syntax it
corresponds to enclosing \dtt{$O$} within square brackets: \dtt{$[O]$}.

\item A braced \emph{ople} is called a \emph{nutple}. Among them \dtt{\{nil\}}
  (aka $\{\emptyset\}$) is a bit special. It is called the \emph{none-ple}.%
%
  \footnote{Prior to version |1.4j| of this documentation it was called the
    \emph{not-ple}.}
%
It is not \dtt{nil}.%
%
\footnote{There is (experimental) a pre-defined \myenquote{\dtt{None}} variable which
  stands for the \emph{none-ple}. It can also be input as |[]|.}
\end{itemize}

Each \emph{ople} has a \emph{length} which is its cardinality as set. The
singleton |oples| are called \emph{one-ples}. There are thus two types of
\emph{one-ples}:
\begin{itemize}
\item \emph{numbers} \dtt{$\{a\}$}, $a \in \mathcal{A}$,
\item \emph{nutples} \dtt{$\{O\}$}, $O \in \mathcal{C}$.
\end{itemize}

If we consider the empty set |nil| on the same footing as |atoms|, the two
types have only one common object which is the \emph{none-ple}.  As a rule
arithmetic operations will either break or silently convert the \emph{none-ple}
to the zero value:
\begin{everbatim*}
\xinteval{3+[], 5^[], 10*[]}
\end{everbatim*}.
But attention that \csbxint{iieval} in contrast to \csbxint{eval} is broken by
such inputs.

\subsubsection{Items (and sub-items) versus elements}

In order to illustrate these concepts, let us consider how one should
interpret notation such as |3,5,7,9| when it arises in an
\csbxint{expr}|ession|:
\begin{description}
\item[tempting vocabulary:] Each of |3|, |5|, |7|, and |9| is an \emph{item}, or
  \emph{element} of the (comma separated) \emph{list}. In other terms we have
  here a list with 4 items.
\item[rigorous vocabulary:] each one of |3|, |5|, |7|, |9| stands for an
  \emph{ople} (of the \emph{one-ple} type) and |3,5,7,9| stands for their \emph{concatenation}.
\end{description}
It is important to understand that in an \csbxint{expr}|ession|, there is no
difference between |3,5,7| and |3,,,,5,,,,,,,,,7|.  So the view of the comma
as separator is misleading.  In other terms, the comma is NOT a separator but
the (associative) operator of concatenation of totally ordered sets, and the
number |3| for example represents a (singleton) set.

If we want to refer to |3| or |5| or |7| or |9| as \myenquote{the items of the
(open) list |3,5,7,9|} (and probably this documentation already has such
utterances, due to legacy reasons from the pre-|1.4| internal model), we
\emph{must} realize that this clashes with using the word \emph{item} as
synonymous to \emph{element} in the set-theoretical sense.

To repeat, any ople \dtt{$O$} is a finite totally ordered set: if not the empty
set, it has \emph{elements} \dtt{$a_1$}, \dots, \dtt{$a_k$}, and the above means that
its \emph{items} are the singleton oples (aka one-ples) \dtt{$I_1=\{a_1\}$},
\dots, \dtt{$I_k=\{a_k\}$}.  Each \dtt{$a_j$} may be an |atom|, then
\dtt{$I_j$} is a |number|, or \dtt{$a_j$} is an |ople| (possibly the empty set), then
\dtt{$I_j$} is a |nutple| whose depth is one more than the one of the ople
\dtt{$a_j$}.

Thus we can refer to \myenquote{items} but must then understand they are not \myenquote{elements}:
\myenquote{items} are \myenquote{singleton sub-sets}. The cardinality (aka length) of an ople is
also the number of its
items.  It would be tempting to use the terminology \myenquote{sub-item} to keep in mind they are \myenquote{sub-sets}
but this would again create confusion: a |nutple| has only one item which is
itself; and we need some terminology to refer to the individual numbers in the
|nutple| given in input as |[1,2,3]| for example.  It is natural to refer to
|1|, |2|, |3| as \myenquote{sub-items} of |[1,2,3]| as the latter may be an \myenquote{item} (it
is in particular an \myenquote{item} of itself, the unique one at that).

We distinguish the |oples| of length zero (there is only one, the empty set)
or at least two as those which can never be an \myenquote{item}.  Those of length one,
the |one-ples|, are exactly those which can be \myenquote{items}.  Among them some may
have \myenquote{sub-items}, they are the |nutples| with the exception of the |none-ple|.
And the others do not have \myenquote{sub-items}, they are the |numbers| and the |none-ple| (whose input syntax is
either |[]| or the variable |None|).%
%
\footnote{%
A note on the \csbxint{verbosetrue} regime: for a variable defined to be
|3,5,7,9|, it will say that its value is |{3}{5}{7}{9}|, because it does not
keep the external set-theoretical braces.  The braces here are only \TeX{}
braces, and |{3}| is an |atom|.  The |number| would be |{{3}}| with the
external braces being set-theoretical and also used internally as \TeX{}
braces.  From the four numbers |{{3}}|, ..., |{{9}}| concatenation gives
|{{3}{5}{7}{9}}|, which is the |ople| |3,5,7,9|.  But the log view drops
deliberately the external braces.  If the variable is defined to be the
|nutple| |[3,5,7,9]|, then the log view will be |{{3}{5}{7}{9}}| (up to
details on how exactly the numeric quantities are coded) and the actual
internal \TeX{} entity will be |{{{3}{5}{7}{9}}}|, where the two external
layers of braces are both set-theoretical and \TeX nical braces.}


\subsubsection{Oples as trees}

We say that the empty set |nil| and \emph{atoms} are \emph{leaves}.

We associate with any \emph{ople} a tree. The root is the ople. In the case of
the |nil| ople, there is nothing else than the root, which we then consider
also a \emph{leaf}. Else the children at top level are the successive
\emph{elements} (not \myenquote{items}!) of the ople.%
%
\footnote{\label{fn:alttree}%
  We could also consider a tree for which the children of the root node would
  be its items and recursively; in that case the leaves would be |numbers| and
  possibly the |None|. The tree of the |nil| would be the empty tree, the tree
  of |None| would have a single node and no edges.  Such a tree would match
  the input syntax (of course applying the rule that iterated commas are like
  only one).  The tree which is described in this section matches more
  directly the internal syntax, hence is more useful to the author, who is
  also the sole reader who extracts some benefit from reading this
  documentation once in a while.}
%
Among the elements some are \emph{atoms} giving \emph{leaves} of the tree,
others are \emph{nutples} which in turn have children.  In the special case of
the \emph{none-ple} we consider it has a child, which is the empty set and this
is why we consider the empty set |nil| to be also a potential \emph{leaf}. We
then proceed recursively.  We thus obtain from the root \emph{ople} a tree
whose vertices are either \emph{oples} or \emph{leaves}. Only the empty set
|nil| is both a \emph{leaf} and an \emph{ople}.

Considering the empty set |nil| as an \emph{atom} fits with the \xintexprname
internal implementation based on \TeX: |nil| is an empty pair of braces |{}|,
whereas an \emph{atom} is a braced representation of a numeric value using
digits and other characters. We construct \emph{oples} by putting one after
the other such constituents and bracing them, and then repeating the process
recursively.

It has also an impact on the definition of the \emph{depth} (a.k.a as
\emph{maximal dimension}) of an \emph{ople}. For example the \emph{ople}
$\{\emptyset A_1A_2\}$ with three elements, among them the empty set and two
atoms is said to have depth $1$, or to have maximal dimension $1$. And
$\{\{\emptyset\}A_1A_2\}$ is of depth $2$ because it has a leaf (the empty
set) which is a child of a child of the \emph{ople}. NumPy \emph{ndarrays}
have a more restricted structure for example
$\{\{A_{00}A_{01}\}\{A_{10}A_{11}\}\}$ is a $2$-dimensional array, where all
leaves are at the same depth. When slicing empties the array from its atoms,
NumPy keeps the shape information but prints the array as $[]$. This will not
be the case with \xintexprname, which has no other way to indicate the shape
than display it.
\begin{everbatim*}
\xinteval{[[],[]]}
\end{everbatim*}
\begin{everbatim*}
\xinteval{[[0,1],[10,11]][:,2:]}
\end{everbatim*}

\subsubsection{Ople slicing and indexing}
\label{sssec:opleslicing}

\myenquote{Set-theoretical} slicing of an \emph{ople} means replacing it with one of its
subsets.  This applies also if it is a \emph{number}.  Then it can be sliced
only to itself or to the empty set (indeed it has only one element, which is
an atom).  Similarly the \emph{none-ple} can only be sliced to give itself or
the empty set.  And more generally a \emph{nutple} is a singleton so also can
only be set-sliced to either the empty set or itself.

\xintexprname extends \myenquote{Python-like} slicing to act on \emph{oples}:
\begin{itemize}[nosep]
\item if they are not \emph{nutples} set-theoretical slicing applies,
\item if they are \emph{nutples} (only case having a one-to-one
  correspondence in Python) then the slicing happens \emph{within brackets}:
  i.e.\@{} the \emph{nutple} is unpacked then the set-theoretical slicing is
  applied, then the result is \emph{repacked} to produce a new \emph{nutple}.
\end{itemize}
With these conventions the \emph{none-ple} for example is invariant under
slicing: unpacking it gives the empty set, which has only the empty set as
subset and repacking gives back the \emph{none-ple}. Slicing a general
\emph{nutple} returns a \emph{nutple} but now of course in general distinct
from the first one.

The input syntax for Python slicing is to postfix a variable or a
parenthesized ople with |[a:b]|.  See \autoref{ssec:lists} for more.  There
are never any out-of-range errors when slicing or indexing.  All operations
are licit and resolved by the |nil|, a.k.a. empty set.

\myenquote{Set-theoretical} item indexing of an \emph{ople} means reducing it to a
subset which is a singleton. It is thus a special case of set-theoretical
slicing (which is the general process of selecting a subset as replacement of
a set).

\xintexprname extends \myenquote{Python-like} indexing to act on \emph{oples}:
\begin{itemize}[nosep]
\item if they are not \emph{nutples} set-theoretical item indexing applies,
\item if they are \emph{nutples} (only case having a one-to-one
  correspondence in Python) then the meaning becomes \emph{extracting}: i.e.\@
  the \emph{nutple} is unpacked then the set-theoretical indexing is applied,
  but the result is \emph{not repacked}.
\end{itemize}
For example when applied to the \emph{none-ple} we always obtain
the |nil|. Whereas as we saw slicing the \emph{none-ple} always gives back the
\emph{none-ple}. Indexing is denoted in the syntax by postfixing by |[N]|. Thus
for \emph{nutples} (which are analogous to Python objects), there is genuine
difference between the |[N]| extractor and the |[N:N+1]| slicer. But for
\emph{oples} which are either |nil|, a \emph{number}, or of length at least 2,
there is no difference.

\subsubsection{Nested slicing of oples}

Nested slicing is a concept from NumPy, which is extended by \xintexprname to
trees of varying depths. We have a chain of slicers and extractors. I will
describe only the case of slicers and letting them act on a |nutple|. The
first slicer gives back a new |nutple|.  The second slicer will be applied to
each of one of its remaining elements.  However some of them may be
\emph{atoms} or the empty set.  In the NumPy context all leaves are at the
same depth thus this can happen only when we have reached beyond the last
dimension (axis). This is not permitted by NumPy and generates an error.
\xintexprname does not generate an error. But any attempt to slice an
\emph{atom} or the empty set (as element of its container) removes it. Recall
we call them \emph{leaves}. We can not slice leaves. We can only slice
non-leaf elements: such items are necessarily |nutples|.  The procedure then
applies recursively.

If we handle an extractor rather than a slicer, the procedure is similar: we
can not extract out of an \emph{atom} or the empty set. They are thus
removed. Else we have a |nutple|. It is thus unpacked and replaced by the
selected element. This element may be an atom or the empty set and any further
slicer or extractor will remove them, or it is a |nutple| and the procedure
applies with the next slicer/extractor.

\xintexprname allows to apply such a |[a:b,c:d,N,e:f,...]| chain of
slicing/extracting also to an \emph{ople}, which is not a \emph{nutple}. We
simply apply the first step as has been described previously and successive
steps will only get applied to either \emph{nutples} or \emph{leaves}, the
latter getting silently removed by any attempted operation.

\subsubsection{Function arguments versus variables}
\label{sssec:funcargs}

In a function declaration with \csbxint{deffunc}, the call signature is parsed
as a comma separated list, so here it is not true that repeated commas are
like only one: repeated commas are not allowed and will break the function
declaration.

When \xintexprname parses a function call, it first constructs the ople which
is delimited by the opening and closing parentheses, then it applies the
function body, after having mapped the successive items (not the elements) of
the parsed ople to the variables appearing in the function call
signature.  Hence the arguments in the call signature stand for |one-ples|
(i.e.\@{} either |numbers| or |nutples|).

Let me explain why we can not define a function |foo(A,B)| of two oples: the
function call will evaluate as an ople what is enclosed within the
parentheses.  It is then impossible in general to split this uniquely into two
oples |A| and |B|, except if for example we know a priori the length of |A|.
We could imagine defining a declarative interface for a |foo(A,B)| with |A|
preset to have \dtt{37} items or at least a pre-defined number of items but
this is extraneous layer for a functionality no-one will use.

The alternative would be to consider that declaring |foo(A,B)| means |A| will
pick-up always the first item and |B| all the remaining ones, and thus will be
an ople; here, there are some \TeX nical implementation reasons which have
dissuaded the author to do this.

In its place, a special syntax |foo(A,*B)| for the declaration of the function
is available.  It means that |B| stands for the |nutple| which
receives as items all arguments in the function call beyond the first one
already assigned to |A|.

More generally, the last positional argument in a function declaration can
have the form |*|\meta{argname}.  This then means that \meta{argname}
represents a |nutple| which will receive as items all arguments in the
function call remaining after the earlier positional arguments have been
assigned.  The declared function body is free to again use the syntax
|*|\meta{argname} which will unpack it and thus produce the ople concatenating
all such optional arguments.

With \csbxint{defvar} one can define a variable with value an |ople| of
arbitrary cardinality.  Such a variable can be used in a function call, it
will then occupy the place of as many arguments as its cardinality (which is
its number of elements, hence of its associated items).  For example if
function |foo| was declared as a function of 5 arguments |f(a,b,c,d,e)| it is
legitimate to use it as |f(A,B)| if |A| is an ople-valued variable of length
three and |B| of length two.  The actual arguments |a,b,c,d,e| will be made to
match the three items of |A| and the two items of |B|.

\subsubsection{Final words on leaves}

In case things were too clear, let's try to add a bit of confusion with an
extra word on \emph{leaves}. When we discuss informally (particularly to
compare with NumPy) an input such as
\begin{everbatim}
[[1, 2], [3, 4]]
\end{everbatim}
we may well refer to |1|, |2|, |3|, and |4| as being \myenquote{the leaves of the 2d
array}.  But obviously we have here numbers and previously we explained that a
number is not a \emph{leaf}, its \emph{atom} is.  Well, the point here is that
we must make a difference between the input form as above and the actual
constructed \emph{ople} the parser will obtain out of it.  In the input we do
have numbers.  The comma is a \emph{concatenator}, it is not a separator for
enumeration! The \emph{ople} which corresponds to it has a \TeX{}
representation like this:
\begin{everbatim}
{{{1}{2}}{{3}{4}}}
\end{everbatim}
where we don't have the \emph{numbers} anymore (which would look like |{{1}}|,
|{{2}}|, ...)  but numeric \emph{atoms} |{1}|, |{2}|, |{3}|, |{4}| where the
braces are \TeX{} braces and \textbf{not} set-theoretical braces (the other
braces are both). Hence we should see the above as the |ople|
$\{\{A_{00}A_{01}\}\{A_{10}A_{11}\}\}$ with atoms $A_{00}=\{1\}$, ..., being the
\emph{leaves} of the tree associated to (or which is) the \emph{ople}.

Numbers may be called the \emph{leaves} of the \textbf{input}, but once
parsed, the input becomes an \emph{ople} which is
(morally) a tree whose leaves are \emph{atoms} (and the empty set).
This discussion can also be revisited with footnote 
%%\footref{fn:alttree}
\ref{fn:alttree} in mind.

\subsubsection{Farewell, thanks for your visit!}

I hope this is clear to everyone.  If not, maybe time to say this section is
not needed to understand almost all of the manual, but I needed to
write it to be able to maintain in future my own software.


\subsection{Expansion (for geeks only)}

As mentioned already, the parsers are compatible with expansion-only
context.

Also, they expand the expression piece by piece: the normal mode of operation
of the parsers is to unveil the parsed material token by token.  Unveiling is
a process combining space swallowing, brace removal (one level generally), and
\fexpan sion.

For example a closing parenthesis after some function arguments does not have
to be immediately visible, it and the arguments themselves may arise from
\fexpan sion (applied before grabbing each successive token).  Even the ending
|\relax| may arise from expansion. Even though the \csbxint{eval} user
interface means that the package has at some point the entire expression in
its hands, it immediately re-inserts it into token stream with an additional
postfixed |\relax| and from this point on has lost any ways (a simple-minded
delimited macro won't do because the expression is allowed to contain
sub-\csbxint{expr}essions, even nested) to manipulate formally again the whole
thing; it can only re-discover it one token at a time.

This general behaviour (which allows much more freedom in assembling
expressions than is usually the case with familiar programming languages such
as Python, although admittedly that freedom will prove useful only to
power-\TeX users and possibly does not have that many significant use cases)
has significative exceptions. These exceptions are mostly related to
\myenquote{pseudo}-functions. A \myenquote{pseudo}-function will grab some of its arguments via
delimited macros. For example |subs(expr1,x=expr2)| needs to see the comma,
equal sign and closing parenthesis. But it has mechanisms to allow |expr1| and
|expr2| to possess their own commas and parentheses.

Inner semi-colons on the other hand currently always can originate from expansion.
Defining functions or variables requires a visible semi-colon acting as
delimiter of the expression, but inner semi-colons do not need to be
hidden within braces or macros.

The expansion stops only when the ending |\relax| has been found
(it is then removed from the token stream).

For catcode related matters see \csbxint{exprSafeCatcodes}.

A word of warning on the bracketed optional argument of respectively
\csbxint{floatexpr} and \csbxint{iexpr}. When defining macros which will hand
over some argument to one of these two parsers, the argument may potentially
start with a left square bracket |[| (e.g. argument could be |[1, 2, 3]|) and
this will break the parser. The fix is to use in the macro definition
|\xintfloatexpr\empty|. This extra |\empty| token will prevent the parser
from thinking there is an optional argument and it will then disappear during
expansion.

\begin{footnotesize}
  If comparing to other languages able to handle floating point numbers or big
  integers, such as Python, one should take into account that what the \xintname
  packages manipulate are streams of ascii bytes, one per digit. At no time
  (due to expandability) is it possible to store intermediate results in an
  arithmetic CPU register; each elementary operation via |\the\numexpr| will
  output digit tokens (hence as many bytes), not things such as handles to
  memory locations where some numbers are stored as memory words. The process
  can never put aside things but can only possibly permute them with upcoming
  tokens, to use them later, or, via combinations of |\expanded| and
  |\unexpanded| or some other more antiquated means grab some tokens and shift
  the expansion to some distant locations to later come back. The process is a
  never-ending one-dimensional one...\par
\end{footnotesize}

\subsection{Known bugs/features (last updated at \texttt{1.4n})}

\begin{description}

% probable wont-fix
\item[{\cs{xinteval}\char`\{\cs{xintLength}\char`\{\cs{par}\cs{par}\cs{par}\char`\}\char`\}} complains about a Runaway argument:]\mbox{}

  |\xintLength{\par\par\par}| has no issue as
  |\xintLength| is a |\long| macro but this is not the case of
  |\xinteval|.  Most macros of a non arithmetic nature in
  \xintkernelname and \xinttoolsname are declared |\long| but
  absolutely none in \xintexprname, and its dependencies \xintname, etc...
%
  As a remark in passing, I could not use the \LaTeX{} |\item| directly:%
%
  \footnote{For those who wonder my custom |\verb| employs a
    |\scantokens| approach, so it can be used in the argument of a
    macro, for example \verb+\footnote{\verb|\verb|}+.}
%
\begin{everbatim}
Runaway argument?
{|\xinteval {\xintLength {
! Paragraph ended before \@item was complete.
<to be read again> 
                   \par 
l.4434 \item[{|\xinteval{\xintLength{\par
                                         \par\par}| complains about a Runawa...
\end{everbatim}
  This is the reason I guess why everything is a priori |\long| in the
  \LaTeX3 interface except if asked for otherwise (as far as I know).

  Although most macros are dealing with inputs which can only be with digits
  and some other character tokens, it would still be quite some work to
  chase all top-level ones.  Besides, in pratice, it does help better locate
  ill-formed input.


\item[|if(100>0,(100,125),(100,128))| breaks my code:]
%
  This is a feature. This is a syntax error, as the comma serves to contatenate
  "oples" (see \autoref{oples}), and parentheses do not create analogs of
  "tuples", so this input is parsed the same as
\begin{everbatim}
    if(100>0,100,125,100,128) 
\end{everbatim}
  which is an error as \func{if} requires exactly three arguments, not
  five. Use:
\begin{everbatim}
    if(100>0,[100,125],[100,128]) 
\end{everbatim}
  which will expand to the "tuple" |[100,125]|.


\item[{\cs{xintdeffunc} |foo(x):= gcd((x>0)?{[x,125]}{[x,128]});|
    creates a broken function:}]
% 
  Bug. Normally \func{gcd} (and other
  multi-arguments functions) work both with open lists of arguments or
  bracketed lists ("nutples") and the above syntax would work perfectly fine
  in numerical context.  But the presence of the \oper{?} breaks in
  \csbxint{deffunc} context the flexibility of \func{gcd}. 

   Currently working alternatives:
\begin{everbatim}
\xintdeffunc foo(x) := gcd(if(x>0, [x,125], [x,128]));
\xintdeffunc foo(x) := if(x>0, gcd(x,125), gcd(x,128));
\xintdeffunc foo(x) := if(x>0, gcd([x,125]), gcd([x,128]));
\xintdeffunc foo(x) := gcd((x>0)?{x,125}{x,128});
\xintdeffunc foo(x) := (x>0)?{gcd(x,125)}{gcd(x,128)};
\xintdeffunc foo(x) := (x>0)?{gcd([x,125])}{gcd([x,128])};
\end{everbatim}
   The same problem will arise with an \oper{??} nested inside \func{gcd} or
   similar functions, in an \csbxint{deffunc}.

\item[{\cs{xinteval}|{0^-.5}| says "0 raised to power -1"}]
%
  Feature. Half integer exponents are handled via a square-root extraction, so
  here \xintexprname wanted to first raise \dtt{0} to power \dtt{-1}, as
  reported.

\item[{Comparison operator |==| crashes with nutples}]
%
   Not yet implemented...

\item[{I liked the ``broadcasting'' |[1..10]^10| syntax, but it
     was removed at 1.4}]
%
   Patience...\@{} |seq(x^10,x=1..10)| is alternative (add external |[..]| to get
   a nutple).

\item[{|1e\numexpr5+2\relax| crashes}]
%
   Not clear yet if bug or feature.
   The syntax accepted in the scientific part is limited, and failure
   is expected: hitting a |\numexpr|
   when parsing a number triggers insertion of a tacit multiplication and then
   |1e| is missing the scientific exponent. The same happens with |1e(2+3)|.
   Use syntax such as |1e\the\numexpr5+2\relax|, or |1e\xinteval{5+2}|
   (although here this relies on output format of |\xinteval| using integer
   notation with no decoration in this case).

\item[{|seq(1e-i,i=1..5)| crashes}]
%
   Not clear if bug or feature. Use |seq(1e\xinteval{-i},i=1..5)| or, as a
   possibly faster way |seq(1e\xintiieval{-i},i=\xintiiexpr1..5\relax)|.

\item[{\keyword{omit}/\keyword{abort} if nested and not last in the sub-expression cause a crash}]
%
   For example |seq(subs((i)?{i}{abort},t=i)+10, i=-2, -1, 0, 1)| crashes, due
   to the presence of the |+10|.  This is a longstanding limitation, applying
   ever since |omit/abort| were added to the syntax at |1.1|.  Even without
   the |+10| the nested case was broken by a |1.4| regression and got fixed
   only at |1.4h|.  The non-nested case |seq((i)?{i}{abort}+10, i=-2, -1, 0,
   1)| works and the \myenquote{must be last in expression if nested} limitation is
   currently considered a feature.

\item[{|\xintdeffunc X(a,k)= add(n^k, n=1..a);| creates a broken function:}]
%
  Bug. Sadly \csbxint{deffunc} has problems.  When it does not work, use
  \csbxint{NewFunction} to define the function. Examples:
\begin{everbatim*}
\xintNewFunction{myX}[2]{add(n^#2, n=1..#1)}\xinteval{myX(10,7)}\newline
\xintNewFunction{myY}[2]{mul(1 - j/#1, j=1..#2-1)}\xintfloateval{myY(10,10)}
\end{everbatim*}

\item[{|seq([i,i^2], i=1..10)| crashes with Ooops, looks like we are missing a
    ]. Aborting!}]
%
  Bug.  The cause is that the square brackets do not hide the comma from
  |seq()| parsing.  Contrarily to what happens with parentheses, there
  is no balancing mechanism for square brackets.  Work-arounds: either
  use an extra pair of parentheses |seq(([i,i^2]), ...)| or hide the
  inner comma within braces |seq([i{,}i^2], ...)|.

\item[{|subs([x,x^2],x=3);| crashes with  Ooops, looks like we are missing a ].  Aborting!}]
%
  Bug. Same cause as previous one.  Workaround: use parentheses
  |subs(([x,x^2]),x=3| or curly braces |subs({[x,x^2]},x=3|.
\begin{everbatim*}
\xinteval{subs({[x^10,x^20,x^30]}, x=17)}
\end{everbatim*}

\item[{|seq([x,2x,3x],x=3..5);| crashes with Ooops, looks like we are
    missing a ].  Aborting!}]
%
Bug. Same cause as previous one. The
  workaround is again to use braces to hide the inner commas.
\begin{everbatim*}
\xinteval{seq({[x^10,x^20,x^30]}, x=1, 2, 3)}
\end{everbatim*}

\item[{%
       \settowidth{\dimen0}{we are missing a ]. Aborting!}%
       \makebox[\the\dimen0][l]
       {\parbox[b]{\linewidth}
        {|iter([1,10^6];[sqrt(@[0]*@[1]),(@[0]+@[1])/2], i=1..7)|
         also complains with Ooops, looks like we are missing a ].  Aborting!}%
       }%
      }]
%
Bug.  Turns out that braces would not do the job here, but parentheses do work:
\begingroup\xintSetDigits{32}%
\begin{everbatim*}
% 32 digits and 8 iterations v------ parentheses added ------v 
\xintfloateval{iter([1,10^6];([sqrt(@[0]*@[1]),(@[0]+@[1])/2]), i=1..8)}
\end{everbatim*}
\endgroup
\end{description}


More bugs are known to the author and many more no doubt exist.

\clearpage
\etocdepthtag.toc {part1B}

\let\xintexprnameUp\undefined
\csname xintexpr (old doc)nameUp\endcsname
\section{The macros of \xintexprname (ancient documentation, mostly)}%
\RaisedLabel{sec:oldxintexpr}

\localtableofcontents

\subsection{Introduction}

The \xintexprname package was first released with version |1.07|
(|2013/05/25|) of the \xintbundlename. It was substantially enhanced with
release |1.1| from |2014/10/28|.

The |1.4| release from |2020/01/31| maintains the same general architecture
but needed adapting all the code base for the switch from |\csname| to
|\expanded| techniques. On this occasion the mechanism for defining functions
was substantially strengthened.  The parser core mechanisms were improved too.

The package loads automatically \xintfracname and \xinttoolsname.

This section should be trimmed to contain only information not
already covered in \autoref{sec:expr}.

\subsection{The \csh{xintexpr} expressions}
\label{xintexpr}
\label{xinttheexpr}
\label{xintthe}

An \xintexprname{}ession is a construct
\csbxint{expr}\meta{expandable\_expression}|\relax|\etype{x} where the
expandable expression is read and completely expanded from left to right.

An |\xintexpr...\relax| \emph{must} end in a |\relax| (which will be absorbed).
Contrarily to a |\numexpr| expression, it is printable as is without a prefix
|\the| or |\number| (don't use them with |\xintexpr| this will raise an
error).

But one can use |\xintthe| prefix if one does need the explicit digits and
other characters as in the final typesetted result.

As an alternative and equivalent syntax to
\begin{everbatim}
\xintexpr round(<expression>, D)\relax
\end{everbatim}
there is
\begin{everbatim}
\xintiexpr [D] <expression> \relax
\end{everbatim}
For |D>0| this produces a decimal number with |D| figures after the decimal
mark, which is the rounding of the expression. For |D=0| the rounding to an
integer is produced. For |D<0| (and this was changed at |1.4f|), the rounded
quotient of the expression by \verb=1e|D|= is produced.
\begin{itemize}
\item the expression may contain arbitrarily many levels of nested parenthesized
  sub-expressions,
\item the expression may contain explicitely or from a macro expansion a
  sub-expression |\xintexpr...\relax|, which itself may contain a
  sub-expressions etc\dots
\item to let sub-contents evaluate as a sub-unit it should thus be either
   \begin{enumerate}
   \item parenthesized,
   \item or a sub-expression |\xintexpr...\relax|.
   \end{enumerate}
 \item to use an expression as argument to macros from \xintfracname,
   or more generally to macros which expand their arguments, one must use the
   |\xinttheexpr...\relax| or |\xintthe\xintexpr...\relax| forms.
 \item one should not use |\xintthe\xintexpr...\relax| as a sub-constituent of
   another expression but only the
   |\xintexpr...\relax| form which is more efficient in this context.
 \item each \xintexprname{}ession, whether prefixed or not with |\xintthe|, is
   completely expandable and obtains its result in two expansion steps.
\end{itemize}

The information now following is possibly in need of updates.

\begin{itemize}[parsep=0pt, labelwidth=\leftmarginii,
  itemindent=0pt, listparindent=\leftmarginiii, leftmargin=\leftmarginii]
\item An expression is built the standard way with opening and closing
  parentheses, infix operators, and (big) numbers, with possibly a fractional
  part, and/or scientific notation (except for \csbxint{iiexpr} which only
  admits big integers). All variants work with comma separated expressions. On
  output each comma will be followed by a space. A decimal number must have
  digits either before or after the decimal mark.

\item As everything gets expanded, the characters |.|, |+|, |-|, |*|, |/|, |^|,
  |!|, |&|, \verb+|+, |?|, |:|, |<|, |>|, |=|, |(|, |)|, |"|, |]|, |[|, |@|
  and the comma |,| should not (if used in the expression) be active.

  \begin{snugframed}
    \begin{itemize}[nosep]
    \item Babel-activated\NewWithf{1.4n} characters (for example |!|,
      |?|, |;| and |:| with French) are not a problem.
    \item If the character is active due to some other mechanism, prefix it with
  |\string|.
\item A few syntax elements involving the comma, the equal      sign and the
  closing parenthesis are implemented using delimited macros.  They are
  not allowed to be catcode active (even via Babel) and |\string| will
  not work.  Use then \csbxint{exprSafeCatcodes}, see next.
    \end{itemize}
  \end{snugframed}

  One can use \csbxint{exprSafeCatcodes} to reset all
  characters potentially needed by \csbxint{expr} to their standard catcodes
  and \csbxint{exprRestoreCatcodes} then restores the former status.

  Note that this is what \csbxint{defvar} and \csbxint{deffunc} do automatically.
  Expandable \csbxint{floateval} et al. can't do that.

\item Count registers and |\numexpr|-essions are accepted (LaTeX{}'s counters
  can be inserted using |\value|) natively without |\the| or |\number| as
  prefix. Also dimen registers and control sequences, skip registers and
  control sequences (\LaTeX{}'s lengths), |\dimexpr|-essions,
  |\glueexpr|-essions are automatically unpacked using |\number|, discarding
  the stretch and shrink components and giving the dimension value in |sp|
  units ($1/65536$th of a \TeX{} point). Furthermore, tacit multiplication is
  implied, when the (count or dimen or glue) register or variable, or the
  (|\numexpr| or |\dimexpr| or |\glueexpr|) expression is immediately prefixed
  by a (decimal) number. See \autoref{ssec:tacit multiplication} for the complete rules
  of tacit multiplication.\IMPORTANT

\item With a macro |\x| defined like this:
  %
  \leftedline{|\def\x {\xintexpr \a + \b \relax}| or |\edef\x {\xintexpr
      \a+\b\relax}|}
  %
  one may then do |\xintthe\x|, either for printing the result on the page or
  to use it in some other macros expanding their arguments. The |\edef| does
  the computation immediately but keeps it in a protected form.
  Naturally, the |\edef| is only possible if |\a| and |\b| are already
  defined. With both approaches the |\x| can be inserted in other expressions,
  as for example (assuming naturally as we use an |\edef| that in the
  `yet-to-be computed' case the |\a| and |\b| now have some suitable meaning):
  %
  \leftedline {|\edef\y {\xintexpr \x^3\relax}|}

\item There is also \csbxint{boolexpr}| ... \relax| and
  \csbxint{theboolexpr}| ... \relax|.

\item  See also
  \csbxint{ifboolexpr} (\autoref{xintifboolexpr}) and the
  \func{bool} and \func{togl} functions
  in \autoref{sec:expr}. Here is an example. Well in fact the
  example ended up using only \csbxint{boolexpr} so it 
  was modified to use \csbxint{ifboolexpr}.
\catcode`| 12 %
\begin{everbatim*}
\xintdeffunc A(p,q,r) =  p && (q || r) ;
\xintdeffunc B(p,q,r) =  p || (q && r) ;
\xintdeffunc C(p,q,r) =  xor(p, q, r)  ;

\centeredline{\normalcolor
\begin{tabular}{ccrclcl}
        \xintFor* #1 in  {{False}{True}} \do {%
        \xintFor* #2 in  {{False}{True}} \do {%
        \xintFor* #3 in  {{False}{True}} \do {%
    #1 &AND &(#2 &OR  &#3)&is&\textcolor[named]{OrangeRed}
                              {\xintifboolexpr{A(#1,#2,#3)}{true}{false}}\\
    #1 &OR  &(#2 &AND &#3)&is&\textcolor[named]{OrangeRed}
                              {\xintifboolexpr{B(#1,#2,#3)}{yes}{no}}\\
    #1 &XOR & #2 &XOR &#3 &is&\textcolor[named]{OrangeRed}
                              {\xintifboolexpr{C(#1,#2,#3)}{oui}{non}}\\
}}}
\end{tabular}%
}
\end{everbatim*}\catcode`| 13

\item See also \csbxint{ifsgnexpr}.

\item There is  \csbxint{floatexpr}| ... \relax| where the algebra is done
  in floating point approximation (also for each intermediate result). Use the
  syntax |\xintDigits:=N\relax| to set the precision. Default: $16$ digits.
  %
  \leftedline{|\xintthefloatexpr 2^100000\relax:| \dtt{\xintthefloatexpr
      2^100000\relax }}
  %
  The square-root operation can be used in |\xintexpr|, it is computed
  as a float with the precision set by |\xintDigits| or by the optional
  second argument:
  %
\begin{everbatim*}
\xinttheexpr sqrt(2,60)\relax\newline
Here the [60] is to avoid truncation to |\xinttheDigits| of precision on output.
\newline
\printnumber{\xintthefloatexpr [60] sqrt(2,60)\relax}
\end{everbatim*}

  Floats are quickly indispensable when using the power function, as exact
  results will easily have hundreds, even thousands of digits.
  %
\begin{everbatim*}
\xintDigits:=48\relax \xintthefloatexpr 2^100000\relax
\end{everbatim*}

  Only integer and (in |\xintfloatexpr...\relax|) half-integer exponents are
  allowed.

\item if one uses \emph{macros} within |\xintexpr..\relax| one should
  obviously take into account that the parser will \emph{not} see the macro
  arguments, hence one cannot use the syntax there, except if the arguments
  are themselves wrapped as |\xinttheexpr...\relax| and assuming the macro
  \fexpan ds these arguments.
\end{itemize}
\subsection{\texorpdfstring{\texttt{\protect\string\numexpr}}{\textbackslash
    numexpr} or \texorpdfstring{\texttt{\protect\string\dimexpr}}{\textbackslash
    dimexpr} expressions, count and dimension registers and variables}
\label{ssec:countinexpr}

Count registers, count control sequences, dimen registers, dimen control
sequences (like |\parindent|), skips and skip control sequences, |\numexpr|,
|\dimexpr|, |\glueexpr|, |\fontdimen| can be inserted directly, they will be
unpacked using |\number| which gives the internal value in terms of scaled
points for the dimensional variables: $1$\,|pt|${}=65536$\,|sp| (stretch and
shrink components are thus discarded).

Tacit multiplication (see \autoref{ssec:tacit multiplication}) is implied,
when a number or decimal number prefixes such a register or control sequence.
\LaTeX{} lengths are skip control sequences and \LaTeX{} counters should be
inserted using |\value|.

Release |1.2| of the |\xintexpr| parser also recognizes and prefixes with
|\number| the |\ht|, |\dp|, and |\wd| \TeX{} primitives as well as the
|\fontcharht|, |\fontcharwd|, |\fontchardp| and |\fontcharic| \eTeX{}
primitives.

In the case of numbered registers like |\count255| or |\dimen0| (or |\ht0|),
the resulting digits will be re-parsed, so for example |\count255 0| is like
|100| if |\the\count255| would give |10|. The same happens with inputs such
as |\fontdimen6\font|. And |\numexpr 35+52\relax| will be exactly as if |87|
as been encountered by the parser, thus more digits may follow: |\numexpr
35+52\relax 000| is like |87000|. If a new |\numexpr| follows, it is treated
as what would happen when |\xintexpr| scans a number and finds a non-digit: it
does a tacit multiplication.
\begin{everbatim*}
\xinttheexpr \numexpr 351+877\relax\numexpr 1000-125\relax\relax{} is the same
as \xinttheexpr 1228*875\relax.
\end{everbatim*}

Control sequences however (such as |\parindent|) are picked up as a whole by
|\xintexpr|, and the numbers they define cannot be extended extra digits, a
syntax error is raised if the parser finds digits rather than a legal
operation after such a control sequence.

A token list variable must be prefixed by |\the|, it will not be unpacked
automatically (the parser will actually try |\number|, and thus fail). Do not
use |\the| but only |\number| with a dimen or skip, as the |\xintexpr| parser
doesn't understand |pt| and its presence is a syntax error. To use a dimension
expressed in terms of points or other \TeX{} recognized units, incorporate it in
|\dimexpr...\relax|.

Regarding how dimensional expressions are converted by \TeX{} into scaled points
see also \autoref{sec:Dimensions}.

\subsection{Catcodes and spaces}

The main problems are caused by active characters, because \csbxint{expr} et
al.\@{} expand forward whatever comes from token stream; they apply |\string|
only in a second step.  For example the catcode of |&| from |&&| Boolean
disjunction is not really important as long as it is not active, or comment,
or escape...\@{} or brace...\@{} or ignored...\@{} in brief, as long as it is reasonable,
and in particular whether |@| is of catcode letter or other does not matter.

It is always possible to insert manually the |\string| in the expression
before a problematic (but reasonable) character catcode, or even to use
|\detokenize| for a big chunk.  

\subsubsection{\csh{xintexprSafeCatcodes}}
\label{xintexprSafeCatcodes}

Some problems with active characters can be resolved on the fly by prefixing
them by |\string| but some aspects of the parsing done by \csbxint{expr}
involves delimited macros which need the comma, equality sign and closing
parenthesis to have their standard catcodes.

So \csbxint{exprSafeCatcodes} is provided as a utility to set in one go
catcodes of many characters to \csbxint{expr}-safely compatible values. This
is a non-expandable step as it changes catcodes.
%  This is used
% internally by \csbxint{NewExpr} (restoring the catcodes on exit), hence it
% does not have to be protected against active characters when used at
% top-level.

\csbxint{defvar}, \csbxint{deffunc}, et al., use it, and then they restore
catcodes to the prior state via \csbxint{exprRestoreCatcodes}.

% As \csbxint{NewExpr} and \csbxint{deffunc} and variants use internally some
% |\scantokens|, they will (reasonably) succeed in sanitizing catcodes in the
% expressions, even if all is from the replacement text of some macro whose
% definition was done under some special catcode regime.

% \csbxint{deffunc} is more lenient than \csbxint{defvar} regarding catcodes of
% characters in expression bodies as it does some |\scantokens| which will reset
% compatible catcodes.

% Even if used in a context where catcodes are already set, \csbxint{deffunc},
% \csbxint{defvar} and variants ignore completely the colon in |:=| so it can
% have any (reasonable) catcode. Moreover it is optional.

% The semi-colon in the syntax of \csbxint{Digits} is no real problem either
% (cf. \csbxint{Digits} documentation).

\subsubsection{\csh{xintexprRestoreCatcodes}}
\label{xintexprRestoreCatcodes}

Restores the catcodes to the state prevailing at the time of the last executed
\csbxint{exprSafeCatcodes} (if located at the same \LaTeX\ environment or
\TeX\ grouping level).

Prior to |1.4k|, in a situation like the following:
\begin{everbatim}
\xintexprSafeCatcodes
....stuff possibly changing catcodes
\xintexprSafeCatcodes
....stuff possibly changing catcodes
\xintexprSafeCatcodes
....stuff possibly changing catcodes
\xintexprRestoreCatcodes
\end{everbatim}
On exit, the catcodes recovered their status as prior to the \emph{first}
\csbxint{exprSafeCatcodes}.  Since |1.4k|, they are set to what they were
prior to the \emph{last} \csbxint{exprSafeCatcodes}, i.e. the mechanism is now
similar to a ``last in, first out'' stack.

Note that no global assignments are made so the behaviour can be modified
by usage of \TeX\ groups or \LaTeX\ environments: e.g. if an
\csbxint{exprSafeCatcodes} is issued inside a \LaTeX\ environment it does not
have to be paired by \csbxint{exprRestoreCatcodes} explicitly, the catcode
scope is limited by the environment.

\bigskip

Spaces inside an |\xinttheexpr...\relax| should mostly be
innocuous (except inside macro arguments).

|\xintexpr| and |\xinttheexpr| are for the most part agnostic regarding
catcodes,
but the characters
% |+|, |-|, |*|, |/|, |^|, |!|, |&|, \verb+|+, |?|, |:|, |<|, |>|,
%|=|, |(|, |)|, |"|, |[|, |]|, |;|, 
in the expression should not be \myenquote{active} (except on purpose)
as everything is expanded along the way, and |\xintexpr| will choke on
typesetting related commands.  One can (in almost all cases) use
|\string| to prefix a problematic character.

\begin{snugframed}
Babel-activated\NewWithf{1.4n} characters are not a problem.
\end{snugframed}

Digits, slash, square brackets, minus sign, in the output from an
|\xinttheexpr| are all of catcode 12. For |\xintthefloatexpr| the `e' in the
output has its standard catcode ``letter''.

\subsection{Expandability, \csh{xintexpro}}

As is the case with all other package macros |\xintexpr| \fexpan ds (in two
steps) to its final (somewhat protected) result; and |\xinttheexpr| \fexpan ds
(in two steps) to the chain of digits (and possibly minus sign |-|, decimal
mark |.|, fraction slash |/|, scientific |e|, square brackets |[|, |]|)
representing the result.

The once expanded |\xintexpr| is |\romannumeral0\xintexpro|.  And there
are similarly |\xintiexpro| |\xintiiexpro| and |\xintfloatexpro|.  For an
example see \autoref{ssec:fibonacci}.

An expression can only be legally terminated by a |\relax| token, which
will be absorbed.  This token may arose from expansion, it does not have
to be immediately visible.

It is quite possible to nest expressions among themselves; for example, if one
needs inside an |\xintiiexpr...\relax| to do some computations with fractions,
rounding the final result to an integer, one just has to insert
|\xintiexpr...\relax|. The functioning of the infix operators will not be in
the least affected from the fact that the outer ``environment'' is the
|\xintiiexpr| one.


\subsection{\csh{xintDigits*}, \csh{xintSetDigits*}}
\label{xintDigits*}
\label{xintSetDigits*}

These starred variants of \csbxint{Digits} and \csbxint{SetDigits} are
only aliases\CHANGED{2.0a1} to the non-starred versions.

\subsection{\csh{xintiexpr}, \csh{xinttheiexpr}}
\label{xintiexpr}\label{xinttheiexpr}

Equivalent\etype{x} to doing |\xintexpr round(...)\relax| (more precisely,
|round| is applied to each leaf item of the |ople| independently of its
depth).

Intermediate calculations are exact, only the final output gets
rounded. Half integers are rounded towards $+\infty$ for positive
numbers and towards $-\infty$ for negative ones.

An optional parameter |D| within brackets, immediately after |\xintiexpr| is
allowed: it instructs (for |D>0|) the expression to do its final rounding to
the nearest value with that many digits after the decimal mark, i.e.\@
|\xintiexpr [D] <expression>\relax| is equivalent (in case of a single
expression) to |\xintexpr round(<expression>, D)\relax|.

|\xintiexpr [0] ...| is the same as |\xintiexpr ...| and rounds to an integer.

The case of negative |D| gives quantization to an integer multiple of
\dtt{1e-D}. This was modified at |1.4f| and the produced value
is now the rounded quotient by \dtt{1e-D} (i.e. no trailing zeros nor
scientific exponent in the output).

If truncation rather than rounding is needed on can use |\xintexpr
trunc(...)\relax| for truncation to an integer or |\xintexpr
trunc(...,D)\relax| for quantization to an integer multiple or \dtt{1eD} (if
|D>0|, for |D<0| the analog would be |trunc((...)/1e-D)|).  But
this works only for a single scalar value.

\begin{framed}
  When defining a macro doing something such as |\xintiexpr #1\relax|,
  it is recommended to rather use |\xintiexpr\empty #1\relax|, as the
  |#1| may start with  a |[| which without the |\empty| would be
  interpreted by |\xintiexpr| as the start of the optional |[D]|.
\end{framed}

\subsection{\csh{xintiiexpr}, \csh{xinttheiiexpr}}
\label{xintiiexpr}\label{xinttheiiexpr}

This variant\etype{x} does not know fractions. It deals almost only with long
integers. Comma separated lists of expressions are allowed.

\begin{framed}
  It maps |/| to the \emph{rounded} quotient. The operator
  |//| is, like in |\xintexpr...\relax|, mapped to \emph{truncated} division.
  The Euclidean quotient (which for positive operands is like the truncated
  quotient) was, prior to release |1.1|, associated to |/|. The function
  |quo(a,b)| can still be employed.
\end{framed}

The \csbxint{iiexpr}-essions use the `ii' macros for addition, subtraction,
multiplication, power, square, sums, products, Euclidean quotient and
remainder.

The \func{floor} and \func{ceil} functions are available in this integer
only parser, with arguments allowed to be decimal numbers.  But for
example |floor(5/3)| returns the perhaps counter intuitive value |2|,
because |/| does the rounded division to an integer.  To force the
parser to allow fractions and not interpret |/| as integer-only
operator, uses \func{qfrac} as in the examples below.

Also \func{round} and \func{trunc} are allowed in
\csbxint{iiexpr}-essions: they are mapped to \csbxint{iRound} and
\csbxint{iTrunc} which explains how they behave with respect to their
optional second argument.
\begin{everbatim*}
\xinttheiiexpr 5/3, round(5/3,3), trunc(5/3,3),
\relax{} do the integer division
%
\xinttheiiexpr 5/3,  round(qfrac(5/3),3), trunc(qfrac(5/3),3), floor(qfrac(5/3)),
ceil(qfrac(5/3))\relax{} work!
\end{everbatim*}
% trunc(\xintDiv {5}{3},3), % NOT ALLOWED WITH xint-calx 2.0
% trunc(\xintRaw {5/3},3)%    NOT ALLOWED WITH xint-calx 2.0

\begin{framed}
Scientific notation is perfectly legitimate if it
defines an integer:\NewWithf{2.0}
\begin{everbatim*}
\xintiieval{1e20}
\xintiieval{100000000e-4}
\end{everbatim*}
No need to use  |num()|.

On the other hand the \xintfracname "raw" format such as
|5/3[0]| \textbf{is no longer supported} for input in \csbxint{iieval},
even as first argument to |trunc()| or |round()|.
\end{framed}


The |reduce| function is not available and will raise an error. The |frac|
function also. The |sqrt| function is mapped to \csbxint{iiSqrt} which gives
a truncated square root. The |sqrtr| function is mapped to \csbxint{iiSqrtR}
which gives a rounded square root.

One can use the Float macros if one is careful to use |num|, or |round|
etc\dots on their output.

\begin{everbatim*}
\xinttheiiexpr \xintFloatSqrt [20]{2},
               \xintFloatSqrt [20]{3}\relax % no operations
\end{everbatim*}
The above went through because no actual operations were carried out.  But it
is dangerous because the ``printer'' for \csbxint{theiiexpr} could choke on
such values.  By default however it does nothing.

In the next example there will be an addition.  So we firt apply |round| to
get integers (the second argument of |round| and |trunc| tells how many digits
from after the decimal mark one should keep.)
\begin{everbatim*}
\xinttheiiexpr round(\xintFloatSqrt [20]{2},19) +
               round(\xintFloatSqrt [20]{3},19)\relax
\end{everbatim*}

The whole point of \csbxint{iiexpr} is to gain some speed in
\emph{integer-only} algorithms, and the above explanations related to how to
nevertheless use fractions therein are a bit peripheral. We observed
(2013/12/18) of the order of $30$\% speed gain when dealing with numbers with
circa one hundred digits (1.2: this info may be obsolete).


\subsection{\csh{xintboolexpr}, \csh{xinttheboolexpr}}
\label{xintboolexpr}\label{xinttheboolexpr}

Equivalent\etype{x} to doing |\xintexpr ...\relax| and returning |true| if the
result does not vanish, and |false| if the result is zero. As |\xintexpr|, this
can be used on comma separated lists of expressions, and even bracketed lists.

It can be customized, one only needs to modify the following:
\begin{everbatim}
\def\xintboolexprPrintOne#1{\xintiiifNotZero{#1}{true}{talse}}%
\end{everbatim}
Not only are |true| and |false| usable in input, also |True| and |False| are
pre-declared variables.

There is quirk in case it is used as a sub-expression: the boolean
expression needs at least one logic operation else the value is not
standardized to |1| or |0|, for example we get from
\begin{everbatim*}
\xinttheexpr \xintboolexpr 1.23\relax\relax\newline
\end{everbatim*}which is to be compared with
\begin{everbatim*}
\xinttheboolexpr 1.23\relax
\end{everbatim*}

% A related issue existed with
% |\xinttheexpr \xintiexpr 1.23\relax\relax|, which was fixed with |1.1|
% release, and I decided back then not to add the needed overhead also to the
% |\xintboolexpr| context, as one only needs to use |?(1.23)| for example or
% involve the |1.23| in any logic operation like |1.23 'and' 3.45|, or involve
% the |\xintboolexpr ..\relax | itself with any logical operation, contrarily to
% the sub-|\xintiexpr| case where |\xinttheexpr 1+\xintiexpr 1.23\relax\relax|
% did behave contrarily to expectations until |1.1|.


\subsection{\csh{xintfloatexpr},
  \csh{xintthefloatexpr}}
\label{xintfloatexpr}\label{xintthefloatexpr}

\csbxint{floatexpr}|...\relax|\etype{x} is a variant of
|\xintexpr...\relax| which does floating point operations.

The target precision for the computation is from the
current setting of |\xintDigits|. Comma separated lists of expressions are
allowed.

An optional parameter within brackets |[Q]| is allowed at the very start
of the expression:
\begin{itemize}
\item if positive it instructs the macro to round the result to that
  many digits of precision. It thus makes sense to employ it only if
  this parameter is less than the \csbxint{theDigits} precision.
\item if negative it means to trim off that many digits (of course, in
  the sense of rounding the values to shorter mantissas). Don't use it
  to trim all digits (or more than all)!
\end{itemize}

Since |1.2f| all float operations first round their arguments; a parsed number
is not rounded prior to its use as operand to such a float operation.

|\xintDigits:=36\relax|\xintDigits:=36\relax 
%
\leftedline{|\xintthefloatexpr
  (1/13+1/121)*(1/179-1/173)/(1/19-1/18)\relax|}
%
\leftedline{\dtt{\xintthefloatexpr
  (1/13+1/121)*(1/179-1/173)/(1/19-1/18)\relax}}
% 0.00564487459334466559166166079096852897
%
\leftedline{|\xintthefloatexpr\xintexpr
  (1/13+1/121)*(1/179-1/173)/(1/19-1/18)\relax\relax|}
%
\leftedline{\dtt{\xintthefloatexpr\xintexpr
  (1/13+1/121)*(1/179-1/173)/(1/19-1/18)\relax\relax}}

\xintDigits := 16;

The latter is the rounding of the exact result. The former one has
its last three digits wrong due to the cumulative effect of rounding errors
in the intermediate computations, as compared to exact evaluations.




I recall here from \autoref{ssec:floatingpoint} that with release |1.2f| the
float macros for addition, subtraction, multiplication and division round
their arguments first to |P| significant places with |P| the asked-for
precision of the output; and similarly the power macros and the
square root macro. This does not modify anything for computations with
arguments having at most |P| significant places already.

\begin{framed}
  When defining a macro doing something such as |\xintfloatexpr #1\relax|,
  it is recommended to rather use |\xintfloatexpr\empty #1\relax|, as the
  |#1| may start with  a |[| which without the |\empty| would be
  interpreted by |\xintfloatexpr| as the start of the optional |[Q]|.
\end{framed}

\subsection{\csh{xinteval}, \csh{xintieval}, \csh{xintiieval},
  \csh{xintfloateval}}
\label{xinteval}\label{xintieval}\label{xintiieval}\label{xintfloateval}

\csbxint{eval}\etype{x} is an \fexpan dable macro which is basically
defined in such a way that |\xinteval|\marg{expression} behaves like
\csbxint{theexpr}\marg{expression}|\relax|.  It expands completely in
two steps and delivers its output using digits, the dot |.| as decimal
separator, the letter |e| for scientific notation, the slash |/| for
fractions, as well as commas in case of multi-items expression and
square brackets |[| and |]| for nesting.

\csbxint{ieval}\etype{x} is similarly related to \csbxint{theiexpr}. It
admits an optional argument |[D]| which may be located in the expected
location from conventions of \LaTeX2e macros with optional argument, but
had been long constrained (until |1.4k|) to be inside the braces at the
start of the expression.
\begin{everbatim*}
\xintieval[7]{355/113} = \xintieval{[7]355/113}
\end{everbatim*}
\begin{framed}
  When defining a macro doing something such as |\xintieval{#1}|,
  it is recommended to rather use |\xintieval{\empty #1}|, as the
  |#1| may start with  a |[| which without the |\empty| would be
  interpreted by |\xintieval| as the start of the optional |[D]|.
\end{framed}

\csbxint{iieval}\etype{x} is similarly related to \csbxint{theiiexpr}.
% \begin{everbatim*}
% \xintiieval{add(x^2, x = 100..110), add(x^3, x = 100..110)}
% \end{everbatim*}

\csbxint{floateval}\etype{x} is similarly related to
\csbxint{thefloatexpr}.  It admits an optional argument |[Q]| which
may be located either outside (since |1.4k|) or inside the braces.
\begin{everbatim*}
\xintfloateval [7]{355/113} = \xintfloateval{[7] 355/113}
\end{everbatim*}

When negative, the optional argument tells how many digits to remove
from the prevailing precision:
\begin{everbatim*}
\xintfloateval[-2]{355/113}=
\xintfloateval{[-2]355/113} has \xinttheDigits\ minus 2 digits.
\end{everbatim*}

\begin{framed}
  When defining a macro doing something such as |\xintfloateval{#1}|,
  it is recommended to rather use |\xintfloateval{\empty #1}|, as the
  |#1| may start with  a |[| which without the |\empty| would be
  interpreted by |\xintfloateval| as the start of the optional |[Q]|.
\end{framed}


\subsection{Using an expression parser within another one}

This was already illustrated before. In the following:
\begin{everbatim*}
\xintfloatexpr \xintexpr add(1/i, i=1234..1243)\relax ^100\relax
\end{everbatim*},
the inner sum is computed exactly. Then it will be rounded to |\xinttheDigits|
significant digits, and then its power will be evaluated as a float operation.
One should avoid the "|\xintthe|" parsers in inner positions as this induces
digit by digit parsing of the inner computation result by the outer parser.
Here is the same computation done with floats all the way:
\begin{everbatim*}
\xintfloatexpr add(1/i, i=1234..1243)^100\relax
\end{everbatim*}

Not surprisingly this differs from the previous one which was exact until
raising to the |100|th power.

The fact that the inner expression occurs inside a bigger one has nil
influence on its behaviour. There is the limitation though that the outputs
from \csbxint{expr} and \csbxint{floatexpr} can not be used directly in
\csbxint{theiiexpr} integer-only parser. But one can do:
\begin{everbatim*}
\xintiiexpr round(\xintfloatexpr 3.14^10\relax)\relax % or trunc
\end{everbatim*}


\subsection{The \csh{xintthecoords} macro}
\label{xintthecoords}

It converts (in two expansion steps) the expansion result of
\csbxint{floatexpr} (or \csbxint{expr} or \csbxint{iiexpr}) into the |(a, b)
(c, d) ...| format for list of coordinates as expected by the |TikZ|
|coordinates| syntax.

For use in the following way:
\centeredline{coordinates \{\csbxint{thecoords}\csbxint{floatexpr} ... \csa{relax}\}}
or rather perhaps (pay attention with the doubled \csa{relax})
\centeredline{coordinates \{\csbxint{thecoords}\csbxint{iexpr}[5]\csbxint{floatexpr} ... \csa{relax}\csa{relax}\}}
but attention, do NOT use it with \csbxint{thefloatexpr} only with \csbxint{floatexpr}.

The syntax with \csbxint{iexpr} and a rounding argument |[N]|
immediately following it is to make sure that TikZ's parser only gets some
decimal numbers with a |N| decimal places.  Without it, i.e.\@ with only
\csbxint{floatexpr} (and possibly some float rounding optional argument |[P]|),
TikZ could receive numbers in scientific notation (but attow I don't recall
if that is a problem and I don't have time available to test).

TODO: donner un exemple plus joli.

\begin{everbatim*}
\begin{figure}[htbp]
\centering\begin{tikzpicture}[scale=10]\xintDigits:=8\relax 
  \clip (-1.1,-.25) rectangle (.3,.25);
  \draw [blue] (-1.1,0)--(1,0);
  \draw [blue] (0,-1)--(0,+1);
  \draw [red] plot[smooth] coordinates {%
%%% \xintthecoords converts output of next expression into the
%%%            (x1, y1) (x2, y2) ... 
%%% format
    \xintthecoords\xintfloatexpr
%%%    This syntax -1+[0..4]/2 is currenty dropped at xint 1.4
%%%    seq((x^2-1,mul(x-t,t=-1+[0..4]/2)),x=-1.2..[0.1]..+1.2)\relax
%%%    Use this:
    seq((x^2-1,mul(x-t,t=seq(-1+u/2, u=0..4))),x=-1.2..[0.1]..+1.2)
    \relax
     };
\end{tikzpicture}
\caption{Coordinates with \csbxint{thecoords}.}
\end{figure}
\end{everbatim*}

% Notice: if x goes not take exactly value 1 or -1, the origin appears slightly
% off the curve, not MY fault!!!
It is currently undecided how \csa{xintthecoords} should handle bracketed
data.\UNSTABLE{} Currently, it (or |TikZ|) will break it the input contains
nested structures. One can use it with \func{flat} which removes all nesting.
And in combination with \func{zip} it is easy to plot data given by some
mechanism in separate
lists of x- and y-coordinates (see an example in next section)

\subsection{The \csh{xintthespaceseparated} macro}
\label{xintthespaceseparated}

It converts (in two expansion steps) the expansion result of
\csbxint{floatexpr} (or \csbxint{expr} or \csbxint{iiexpr}) into the space
separated format suitable for usage with |PS-Tricks| |\listplot| macro.

Here is for example some syntax (the replacement text of |\foo|, which is used
here only to show that indeed complete expansion is attained in two steps)
which can be used as argument to |\listplot|. Using 4 fractional decimal
digits is sufficient when unit is the centimeter (it gives a fixed point
precision of one micron, amply enough for plots...).
\begin{everbatim*}
\oodef\foo{%
\xintthespaceseparated
\xintiexpr[4]\xintfloatexpr seq((i, log10(i)), i=1..[0.5]..10)\relax\relax
}\meaning\foo
\end{everbatim*}

Here we don't really need the inner |\xintfloatexpr...\relax| because the
\func{log10} function works the same in the exact parser |\xintexpr| but in
general this is recommended.

It is currently undecided how \csa{xintthespaceseparated} should handle
bracketed data.\UNSTABLE{} Currently, it (or |\listplot|) will break if the
input contains nested structures. One can use it with \func{flat} which
removes all nesting. And in combination with \func{zip} it is easy to plot
data given by some mechanism in separate lists of x- and y-coordinates.

\begin{everbatim*}
% let's imagine we have something like this
\def\Xcoordinates{1, 3, 5, 7, 9}
\def\Ycoordinates{1, 9, 25, 49, 81}
% then:
|\xintthespaceseparated\xintexpr flat(zip([\Xcoordinates], [\Ycoordinates]))\relax|
is suitable to use as argument to |\listplot|, as it expands to
\xintthespaceseparated\xintexpr flat(zip([\Xcoordinates], [\Ycoordinates]))\relax
\end{everbatim*}

\subsection{\csh{xintifboolexpr}, \csh{xintifboolfloatexpr}, \csh{xintifbooliiexpr}}
\label{xintifboolexpr}
\label{xintifboolfloatexpr}
\label{xintifbooliiexpr}

\csa{xintifboolexpr}\marg{expr}\marg{YES}\marg{NO}\etype{xnn} does
\csbxint{theexpr}<expr>|\relax| and then executes the \meta{YES} or the
\meta{NO} branch depending on whether the outcome was non-zero or zero. Thus
one can read \emph{if bool expr} as meaning \emph{if not zero}:
\centeredline{if \meta{expr}-ession does not vanish do \meta{YES} else do
  \meta{NO}}

The expression is not limited to using only comparison operators and Boolean
logic (|<|, |>|, |==|, |!=|, |&&|, \verb+||+, \func{all}, \func{any},
\func{xor}, \func{bool}, \func{togl}, ...), it can be the most general
computation.

\csa{xintifboolfloatexpr}\marg{expr}\marg{YES}\marg{NO}\etype{xnn} does
\csbxint{thefloatexpr}\meta{expr}|\relax| and then executes the \meta{YES} or the
\meta{NO} branch depending on whether the outcome was non zero or zero.

\csa{xintifbooliiexpr}\marg{expr}\marg{YES}\marg{NO}\etype{xnn} does
\csbxint{theiiexpr}\meta{expr}|\relax| and then executes the \meta{YES} or the
\meta{NO} branch depending on whether the outcome was non zero or zero.

The expression argument must be a single one, comma separated sub-expressions
will cause low-level errors.

\subsection{\csh{xintifsgnexpr}, \csh{xintifsgnfloatexpr}, \csh{xintifsgniiexpr}}
\label{xintifsgnexpr}
\label{xintifsgnfloatexpr}
\label{xintifsgniiexpr}

\csa{xintifsgnexpr}\marg{expr}\marg{<0}\marg{=0}\marg{>0}\etype{xnnn} evaluates
the \csbxint{expr}ession and chooses the branch corresponding to its sign.

\csa{xintifsgnfloatexpr}\marg{expr}\marg{<0}\marg{=0}\marg{>0}\etype{xnnn} evaluates
the \csbxint{floatexpr}ession and chooses the branch corresponding to its sign.

\csa{xintifsgniiexpr}\marg{expr}\marg{<0}\marg{=0}\marg{>0}\etype{xnnn} evaluates
the \csbxint{iiexpr}ession and chooses the branch corresponding to its sign.

The expression argument must be a single one, comma separated sub-expressions
will cause low-level errors.

\subsection{The \csh{xintNewExpr}, \csh{xintNewIIExpr},
  \csh{xintNewFloatExpr}, \csh{xintNewIExpr},  and \csh{xintNewBoolExpr}
  macros}
\label{xintNewExpr}
\label{xintNewIIExpr}
\label{xintNewFloatExpr}
\label{xintNewIExpr}
\label{xintNewBoolExpr}

\csbxint{NewExpr} macro is used as:
%
\leftedline{|\xintNewExpr{\myformula}[n]|\marg{stuff}, where}
\begin{itemize}
\item \meta{stuff} will be inserted inside |\xinttheexpr . . . \relax|,
\item |n| is an integer between zero and nine, inclusive, which is the number
  of parameters of |\myformula|,
\item the placeholders |#1|, |#2|, ..., |#n| are used inside \meta{stuff} in
  their usual r\^ole,%
%
\catcode`# 12
\footnote{if \csa{xintNewExpr} is used inside a macro,
    the |#|'s must be doubled as usual.}
  \footnote{the |#|'s will in pratice have their usual
    catcode, but  category code other |#|'s are accepted too.}
\catcode`# 6
%
\item the |[n]| is \emph{mandatory}, even for |n=0|.%
\footnote{there is some use for \csa{xintNewExpr}|[0]| compared to an
    \csa{edef} as \csa{xintNewExpr} has some built-in catcode protection.}
\item the macro |\myformula| is defined without checking if it already exists,
  \LaTeX{} users might prefer to do first |\newcommand*\myformula {}| to get a
  reasonable error message in case |\myformula| already exists,
\item the protection against active characters is done automatically (as long
  as the whole thing has not already been fetched as a macro argument and
  the catcodes correspondingly already frozen).
\end{itemize}

It (if it succeeds) will be a completely expandable macro entirely built-up using |\xintAdd|,
|\xintSub|, |\xintMul|, |\xintDiv|, |\xintPow|, etc\dots as corresponds to the
expression written with the infix operators.
Macros created by |\xintNewExpr| can thus be nested.

\begin{everbatim*}
    \xintNewFloatExpr \FA [2]{(#1+#2)^10}
    \xintNewFloatExpr \FB [2]{sqrt(#1*#2)}
\begin{enumerate}[nosep]
    \item \FA {5}{5}
    \item \FB {30}{10}
    \item \FA {\FB {30}{10}}{\FB {40}{20}}
\end{enumerate}
\end{everbatim*}

The documentation is much shortened here because \csbxint{NewExpr} and \csbxint{deffunc}
are very much related one with the other.

\begin{framed}
  ATTENTION!

  The original spirit of \csbxint{NewExpr} was to define a (possibly very big)
  macro using only \xintfracname, and this means in particular that it must be
  used only with arguments compatible with the \xintfracname input
  format.\IMPORTANTf

  Thus an |\xintexpr| declared variable has no chance to work, it must be
  wrapped explicitly in |\xinteval{...}| to be fetched as argument to a macro
  constructed by \csbxint{NewExpr}.
\end{framed}

They share essentially the same limitations.

Notice though that \csbxint{NewFloatExpr} accepts and recognizes the optional
argument |[Q]| of \csbxint{floatexpr}, contrarily to \csbxint{deffloatfunc}.
Use an |\empty| in case the contents are not known in advance.


Historical note: prior to |1.4|, \xintexprname used a |\csname..\endcsname|
encapsulation technique which impacted the string pool memory. The
\csbxint{NewExpr} was designed as a method to pre-parse the expression and
produce one single, gigantic, nested usage of the relevant \xintfracname
macros. This way, only those macros were expanded which had nil impact on the
\TeX{} string pool.

Later on it was found that this mechanism could be employed to define
functions. Basically underneath |98%| of \csbxint{NewExpr} and
\csbxint{deffunc} are using the same shared code.

\xintDigits:= 16\relax 

\subsection{Analogies and differences of \csh{xintiiexpr} with \csh{numexpr}}

\csbxint{iiexpr}|..\relax| is a parser of expressions knowing only (big)
integers. There are, besides the enlarged range of allowable inputs, some
important differences of syntax between |\numexpr| and |\xintiiexpr| and
variants:
\begin{itemize}
\item Contrarily to |\numexpr|, the |\xintiiexpr| parser will stop expanding
  only after having encountered (and swallowed) a \emph{mandatory} |\relax|
  token.
\item In particular, spaces between digits (and not only around infix
  operators or parentheses) do not stop |\xintiiexpr|, contrarily to the
  situation with |numexpr|: |\the\numexpr 7 + 3 5\relax| expands (in one
  step)%
%
\footnote {The |\numexpr| triggers continued expansion after the space
    following the |3| to check if some operator like |+| is upstream. But
    after having found the |5| it treats it as and end-marker.}
%
  to \dtt{\detokenize\expandafter{\the\numexpr 7 + 3 5\relax}\unskip}, whereas
  |\xintthe\xintiiexpr 7 + 3 5\relax| expands (in two steps) to
  \dtt{\detokenize\expandafter\expandafter\expandafter {\xintthe\xintiiexpr 7
      + 3 5\relax}}.%
%
\footnote {Since |1.2l| one can also use the underscore |_| to separate digits
for readability of long numbers.}

\item Inside an |\edef|, an expression |\xintiiexpr...\relax| get fully
  evaluated, whereas |\numexpr| without |\the| or |\number| prefix would not,
  if not itself embedded in another |\the\numexpr| or similar context.
\item (ctd.) The private format to which |\xintiiexpr...\relax| (et al.)
  evaluates may use |\xintthe| prefix to turn into explicit digits,
  (for example in arguments to some macros which expand their arguments). The |\the| \TeX\ primitive prefix would
  not work here.
\item (ctd.) One can embed a |\numexpr...\relax| (with its |\relax|!) inside an
  |\xintiiexpr...\relax| without |\the| or |\number|, but the reverse situation
  requires usage of |\xintthe| or \csbxint{eval} user interface,
\item |\the\numexpr -(1)\relax| is illegal.  In contrast |\xinttheiiexpr -(1)\relax| is
  perfectly legal and gives the expected result (what else ?).
\item |\the\numexpr 2+-(1+1)\relax| is illegal.  In contrast
  |\xinttheiiexpr 2+-(1+1)\relax| is legal.
\item |\the\numexpr 2\cnta\relax| is illegal (with |\cnta| a |\count| register.)
  In contrast
  |\xinttheiiexpr 2\cnta\relax| is perfectly legal and will do the tacit
  multiplication.
\item |\the\numexpr| or |\number\numexpr| expands in one step, but
  |\xintthe\xintiiexpr| or |\xinttheiiexpr| needs two steps.
\end{itemize}

\subsection{Chaining expressions for expandable algorithmics}
\label{ssec:fibonacci}

We will see in this section how to chain |\xintexpr|-essions with
|\expandafter|'s, like it is possible with |\numexpr|. For this it is
convenient to use |\romannumeral0\xintexpro| which is the once-expanded form of
|\xintexpr|, as we can then chain using only one |\expandafter| each time.

The background of page 2 of this document displays the 1250\textup{th}
Fibonacci number.  For its computation the following |\FibonacciN| macro
(or rather a very close variant) was used, which takes as input a
positive integer |N| (we did not add an overhead for |N| negative or
zero).  It depends on another macro, called |\FibonacciPair| which
outputs \dtt{$F_{N}$} and \dtt{$F_{N-1}$} one after the other both inside
braces.

A technicality is that the Fibonacci numbers are left in a private
format which needs |\xintthe| to resolve to digit tokens.  But the
output of |\FibonacciN| can also be used directly in the typesetting
phase.

As per the algorithm it is based upon the quadratic relations which
allow to go from $(F_n,F_{n-1})$ to either $(F_{2n}, F_{2n-1})$
(operation of type A) or to $(F_{2n+1}, F_{2n})$ (operation of type B).
We first convert $n$ into binary base, and read the digits from most
significant to least significant applying each time either type A or
type B.  Each one of type A or B will cost only 3 multiplications and a
bunch of additions, which of course are done using \csbxint{iiexpr}.  In
total the algorithm costs (because $3\log_2 10\approx 10$) about $10L$
multiplications (doubling is not counted as a multiplication) where $L$
is the number of decimal digits of $N$ (of course the cost of each
multiplication increases with the length of operands).
\begin{everbatim*}
\makeatletter
\newcommand\FibonacciPair[1]{%
    \expandafter\Fibo@start
    \romannumeral0\xintdectobin{\the\numexpr#1\relax};%
}
% To chain \xintiiexpr's easily we use the once-expanded form which is
% \romannumeral0\xintiiexpro.  We could also have used \expanded and \xintiieval
% calls, that would have been simpler but old habits die hard.
%
% Gobble the first digit which is 1 (this is where we could have tested for a
% negative or zero input).  Prepare encapsulated 1 and 0.  Then repeatedly
% dispatch according to binary digits (which are strategically located at end
% of input stream to optimize), or the semicolon which signals completion.
%
% We use \csname-governed branching (because it is cool).  We could have
% used some \if test or even an \ifcase with an {-1} at end, or any other
% of the many possibilities opened up by TeX syntax.
\def\Fibo@start 1#1{%
    \csname Fibo@#1\expandafter\endcsname
        \romannumeral0\xintiiexpro 1\expandafter\relax\expandafter;%
        \romannumeral0\xintiiexpro 0\relax;%
}
\@namedef{Fibo@0}#1;#2;#3{%
    \csname Fibo@#3\expandafter\endcsname
       \romannumeral0\xintiiexpro (#1+2*#2)*#1\expandafter\relax\expandafter;%
       \romannumeral0\xintiiexpro #1*#1+#2*#2\relax;%
}
\@namedef{Fibo@1}#1;#2;#3{%
    \csname Fibo@#3\expandafter\endcsname
        \romannumeral0\xintiiexpro 2*(#1+#2)*#1+#2*#2\expandafter\relax\expandafter;%
        \romannumeral0\xintiiexpro (#1+2*#2)*#1\relax;%
}
% #1 is F_N (and #2 is F_{N-1}) and both are in need of unpacking.
% #1 is F_N (and #2 is F_{N-1}) and both in need of unpacking.
\@namedef{Fibo@;}#1;#2;{{#1}{#2}}

\newcommand\FibonacciN{\expandafter\@firstoftwo\romannumeral0\FibonacciPair}
\makeatother
\end{everbatim*}

\begingroup\footnotesize\sffamily\baselineskip 10pt
Here a code snippet which
checks the routine via a \string\message\ of the first $50$ Fibonacci
numbers (this is not an efficient way to generate a sequence of such
numbers, it is only for validating \csa{FibonacciN}).
%
\begin{everbatim}
\def\Fibo #1.{\xintthe\FibonacciN {#1}}%
\message{\xintiloop [1+1] \expandafter\Fibo\xintiloopindex.,
                          \ifnum\xintiloopindex<49 \repeat \xintthe\FibonacciN{50}.}
\end{everbatim}
\endgroup

The way we use |\expandafter|'s to chain successive |\xintiiexpro| evaluations
is exactly analogous to what is possible with |\numexpr|. The various
|\romannumeral0\xintiiexpro| could very well all have been |\xintiiexpr|'s but
then we would have needed |\expandafter\expandafter\expandafter| each
time.

\begin{framed}
  There is a difference though: |\numexpr| does \emph{NOT} expand inside an
  |\edef|, and to force its expansion we must prefix it with |\the| or
  |\number| or |\romannumeral| or another |\numexpr| which is itself prefixed,
  etc\dots.

  But |\xintexpr|, |\xintiexpr|, ..., expand fully in an |\edef|, with the
  completely expanded
  result encapsulated in a private format.

  Using |\xintthe| as prefix is necessary to print the result (like |\the| or
  |\number| in the case of |\numexpr|), but it is not necessary to get the
  computation done (contrarily to the situation with |\numexpr|).
\end{framed}

Our |\Fibonacci| expands completely under \fexpan sion, so we can use
\hyperref[fdef]{\ttfamily\char92fdef} rather than |\edef| in a situation such
as
%
\leftedline {|\fdef \X {\FibonacciN {100}}|\;,}
%
but it is usually about as efficient to employ |\edef|. And if we want
%
\leftedline{|\edef \Y {(\FibonacciN{100},\FibonacciN{200})}|\;,}
%
then |\edef| is necessary.

% slightly refactored pour 1.4p doc (use of @ rather than _, less braces, so
% less \expandafter's, only keeping one integer along)
Allright, so let's now give the code%
%
\footnote{Coding\NewWith{1.4p} for \cs{FibonacciPair} and \cs{FibonacciSeq} was improved at |1.4p| after ten years kept unchanged...}
% 
to generate |{F(N)}{F(N+1)}{F(N+2)}...|,
using |\FibonacciPair| for the first two and then using the standard recursion
|F(N+2)=F(N+1)+F(N)|:
\begin{everbatim*}
\makeatletter
\newcommand\FibonacciSeq[2]{%#1=starting index, #2>#1=ending index
    \expandafter\Fibonacci@Seq
    \the\numexpr #1\expandafter.\the\numexpr #2.%
}%
% The #1+1 is because \FibonacciPair{N} expands to {F_{N}}{F_{N-1}},
% so here we will have {F_{A+1}}{F_{A}} as starting point.
% We want up to {F_B}.  If B=A+1 there will be nothing to do.
\def\Fibonacci@Seq #1.#2.{%
    \expandafter\Fibonacci@Seq@loop
    \the\numexpr #2-#1-1\expandafter.\romannumeral0\FibonacciPair{#1+1}%
}%
% Now leave in stream one coefficient, test if we have reached B
% and until then apply standard Fibonacci recursion.
\def\Fibonacci@Seq@loop #1.#2#3{% standard Fibonacci recursion
    {#3}\ifnum #1=\z@ \expandafter\Fibonacci@Seq@end\fi
    \expandafter\Fibonacci@Seq@loop
    \the\numexpr #1-1\expandafter.\expandafter
        {\romannumeral0\xintiiexpro #2+#3\relax}{#2}%
}%
\def\Fibonacci@Seq@end#1\expandafter.\expandafter#2{}%
\makeatother
\end{everbatim*}
Again, let's repeat that here the braced values require |\xintthe| to expand
to digit tokens in an |\edef| (but not for typesetting).

%\typeout{\FibonacciSeq{1}{10}}
\ifnum\expanded{\noexpand\xintLength{\FibonacciSeq{1}{10}}}=10
\else\ERROR\fi
% MEMO: \xintLastItem removes braces. But actually \xintthe
% also.  I hesitated to keep it but this could be used case.
% ATTENTION THAT \xintLastItem does NO expansion of its argument.
\ifnum\xintthe\expanded{\noexpand\xintLastItem{\FibonacciSeq{5}{11}}}=89
\else\ERROR\fi

This |\FibonacciSeq| macro is
completely expandable but it is not \fexpan dable.

This is not a problem in the next example which uses \csbxint{For*} as the
latter applies repeatedly full expansion to what comes next each time it
fetches an item from its list argument. Thus \csbxint{For*} still manages to
generate the list via iterated full expansion.


\begin{figure*}[ht!]
  \phantomsection\label{fibonacci}
  \newcounter{myindex}
  \fdef\Fibxxx{\FibonacciN {30}}%
  \setcounter{myindex}{30}%
\centeredline{\tabskip 1ex
\vbox{\halign{\bfseries#.\hfil&#\hfil &\hfil #\cr
  \xintFor* #1 in {\FibonacciSeq {30}{59}}\do
  {\themyindex &\xintthe#1 &
    \xintiiRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{myindex}\cr }}%
}\vrule
\vbox{\halign{\bfseries#.\hfil&#\hfil &\hfil #\cr
  \xintFor* #1 in {\FibonacciSeq {60}{89}}\do
  {\themyindex &\xintthe#1 &
    \xintiiRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{myindex}\cr }}%
}\vrule
\vbox{\halign{\bfseries#.\hfil&#\hfil &\hfil #\cr
  \xintFor* #1 in {\FibonacciSeq {90}{119}}\do
  {\themyindex &\xintthe#1 &
   \xintiiRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{myindex}\cr }}%
}}%
%
\centeredline{Some Fibonacci numbers together with their residues modulo
  |F(30)|\dtt{=\xintthe\Fibxxx}}
\end{figure*}

\begingroup
\def\everbhook{\catcode`@ 14 }%
% à propos après donc de nombreuses années j'ai fait finalement
% un bug report https://github.com/latex3/latex2e/issues/823
\everb|@
\newcounter{myindex}% not "index", which would overwrite theindex environment!
% (many have probably been bitten by this trap)
\tabskip 1ex
  \fdef\Fibxxx{\FibonacciN {30}}%
  \setcounter{myindex}{30}%
\vbox{\halign{\bfseries#.\hfil&#\hfil &\hfil #\cr
  \xintFor* #1 in {\FibonacciSeq {30}{59}}\do
  {\themyindex &\xintthe#1 &
    \xintiiRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{myindex}\cr }}%
}\vrule
\vbox{\halign{\bfseries#.\hfil&#\hfil &\hfil #\cr
  \xintFor* #1 in {\FibonacciSeq {60}{89}}\do
  {\themyindex &\xintthe#1 &
    \xintiiRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{myindex}\cr }}%
}\vrule
\vbox{\halign{\bfseries#.\hfil&#\hfil &\hfil #\cr
  \xintFor* #1 in {\FibonacciSeq {90}{119}}\do
  {\themyindex &\xintthe#1 &
   \xintiiRem{\xintthe#1}{\xintthe\Fibxxx}\stepcounter{myindex}\cr }}%
}%
|
\endgroup

This produces the Fibonacci numbers from |F(30)| to |F(119)|, and
computes also  all the
congruence classes modulo |F(30)|.  The output has
been put in a \hyperref[fibonacci]{float}, which appears
\vpageref[above]{fibonacci}. I leave to the mathematically inclined
readers the task to explain the visible patterns\dots |;-)|.

\subsection{When expandability is too much}

Let's use the macros of \autoref{ssec:fibonacci} related to Fibonacci numbers.
Notice that the $47$th Fibonacci number is \dtt{\xintthe\FibonacciN {47}} thus
already too big for \TeX{} and \eTeX{}.


The |\FibonacciN| macro found in \autoref{ssec:fibonacci} is completely
expandable, it is even \fexpan dable. We need a wrapper with |\xintthe|
prefix
\begin{everbatim*}
\def\theFibonacciN{\xintthe\FibonacciN}
\end{everbatim*}
to print in the document or to use within |\message| (or \LaTeX\ |typeout|) to
write to the log and terminal.

\begingroup
  \def\A {1859}  \def\B {1573}
  \edef\X {\theFibonacciN\A}  \edef\Y {\theFibonacciN\B}
  \edef\GCDAB {\xintiiGCD\A\B}\edef\Z {\theFibonacciN\GCDAB}
  \edef\GCDXY{\xintiiGCD\X\Y}

  The |\xintthe| prefix also allows its use it as argument to the \xintname
  macros: for example if we are interested in knowing how many digits
  $F(1250)$ has, it suffices to issue |\xintLen {\theFibonacciN {1250}}|
  (which expands to \dtt{\xintLen {\theFibonacciN {1250}}}). Or if we want to
  check the formula $gcd(F(1859),F(1573))=F(gcd(1859,1573))=F(143)$, we only
  need%
%
\footnote{The
  \csa{xintiiGCD} macro is provided by both the \xintgcdname package (since
  |1.0|) and by the \xintname package (since |1.3d|).}
%
\begin{everbatim}
$\xintiiGCD{\theFibonacciN{1859}}{\theFibonacciN{1573}}=%
 \theFibonacciN{\xintiiGCD{1859}{1573}}$
\end{everbatim}
%
which produces:
%
\leftedline{$\dtt{\xintiiGCD{\X}{\Y}}=\dtt{\theFibonacciN{\GCDAB}}$}

The |\theFibonacciN| macro expanded its |\xintiiGCD{1859}{1573}| argument via the
services of |\numexpr|: this step allows only things obeying the \TeX{} bound,
naturally! (but \dtt{F(\xintiiPow2{31}}) would be rather big anyhow...).

This is very convenient but of course it repeats the complete evaluation each
time it is done. In practice, it is often useful to store the result of such
evaluations in macros. Any |\edef| will break expandability, but if the goal
is at some point to print something to the |dvi| or |pdf| output, and not only
to the |log| file, then expandability has to be broken one day or another!

Hence, in practice, if we want to print in the document some computation
results, we can proceed like this and avoid having to repeat identical
evaluations:
\begin{everbatim}
\begingroup
  \def\A {1859}  \def\B {1573}
  \edef\X {\theFibonacciN\A}  \edef\Y {\theFibonacciN\B}
  \edef\GCDAB {\xintiiGCD\A\B}\edef\Z {\theFibonacciN\GCDAB}
  \edef\GCDXY{\xintiiGCD\X\Y}
The identity $\gcd(F(\A),F(\B))=F(\gcd(\A,\B))$ can be checked via evaluation
of both sides: $\gcd(F(\A),F(\B))=\gcd(\printnumber\X,\printnumber\Y)=
\printnumber{\GCDXY} = F(\gcd(\A,\B)) = F(\GCDAB) =\printnumber\Z$.\par
          % some further computations involving \A, \B, \X, \Y
\endgroup % closing the group removes assignments to \A, \B, ...
% or choose longer names less susceptible to overwrite something.
% Note: there is no LaTeX \newecommand which would be to \edef like
% \newcommand is to \def
\end{everbatim}
The identity $\gcd(F(\A),F(\B))=F(\gcd(\A,\B))$ can be checked via evaluation
of both sides: $\gcd(F(\A),F(\B))=\gcd(\printnumber\X,\printnumber\Y)=
\printnumber{\GCDXY} = F(\gcd(\A,\B)) = F(\GCDAB) =\printnumber\Z$.\par
\endgroup

One may legitimately ask the author: why expandability
to such extremes, for things such as big fractions or floating point numbers
(even continued fractions...) which anyhow can not be used directly within
\TeX's primitives such as |\ifnum|? Why insist on a concept
which is foreign to the vast majority of \TeX\ users and even programmers?

I have no answer: it made definitely sense at the start of \xintname (see
\autoref{ssec:origins}) and once started I could not stop.


\subsection{Acknowledgements (2013/05/25)}

I was greatly helped in my preparatory thinking, prior to producing such an
expandable parser, by the commented source of the
\href{https://ctan.org/pkg/l3kernel}{l3fp} package, specifically the
|l3fp-parse.dtx| file (in the version of April-May 2013; I think there was in
particular a text called ``roadmap'' which was helpful). Also the source of the
|calc| package was instructive, despite the fact that here for |\xintexpr| the
principles are necessarily different due to the aim of achieving expandability.

\clearpage
\expandafter\let\csname xintexpr (old doc)nameUp\endcsname\undefined
\csname calxtrignameUp\endcsname

\section{The \calxtrigname.tex library}
\RaisedLabel{sec:calxtrig}

\localtableofcontents

\subsection{Introduction}

This library (not to be loaded directly by user)
 provides trigonometric functions for use within
\csbxint{floateval} (and \csbxint{eval}), up to a maximal accuracy of
\dtt{100} floating point digits\NewWith{2.0a1}.

This first version supporting trigonoometry was release |1.3e|
(|2019/04/05|) of \xintexprname.  It was completely rewrittent at
|2.0a1|.  It now supports precisions up to \dtt{100}, is faster and more
accurate.  It defines no user level macro.

% At |1.4e| (|2021/05/05|) the accuracy of the trailing digits was significantly
% increased.%
% %
% \footnote{Prior to 2021, the high-level user interface was used to
%   define the functions and intermediate operations were done without
%   guard digits. As a result the last two digits were most of the time
%   off, at least the last one.}

% Release |1.4p| adds the aliases \func{arcsin}, \func{arccos} and \func{arctg},
% and the reciprocal functions \func{acsc} and \func{asec} with aliases
% \func{arccsc} and \func{arcsec}.

At \csbxint{theDigits} set to \dtt{8} (or less), the computations are
targeting a slightly degraded accuracy (roughly at 8 digits, only about
95\% of values are correctly rounded, compared to 99.5\% for |P>8|.  In
both cases the error is never more tha 1ulp.  Actually the |2.0a1| implementation
appears to be excessively precise so the indicated percentage of correct rounding
is actually very conservative.

\textbf{Acknowledgements:} I finally decided to release some such functions
under friendly pressure of Jürgen \textsc{Gilg} and Thomas \textsc{Ossig}, let
them both be thanked here.

Jürgen passed away in 2022. I will miss our friendship which was born and grew
from numerous and regular exchanges on topics not limited to this package or
even the \TeX\ world. Let's now continue to \myenquote{take care and keep motivated}!

\subsection{\csh{xintreloadxinttrig}}\label{xintreloadxinttrig}

This macro does nothing. It is there only for bacward compatibility
with documents done with \xintexprname prior to |2.0|.

\subsection{Constants}

They are left free to use, or modified, or \csbxint{unassignvar}'d,
as this will have no impact whatsoever on the functions.  They
are provided as backward compatible convenience.

\begin{description}
\vardesc{twoPi} what could that be?
\vardesc{threePiover2} 
\vardesc{Pi}
\vardesc{Piover2}
\vardesc{oneRadian} this is one radian in degrees: $180/\pi$
\vardesc{oneDegree} this is one degree in radian: $\pi/180$
\end{description}

\subsection{Functions}

\subsubsection{Direct trigonometry}

With the variable in radians:

\begin{description}
\funcdesc{sin} sine
\funcdesc{cos} cosine
\funcdesc{tan} tangent
\funcdesc{tg}  tangent
\funcdesc{cot} cotangent
\funcdesc{cotg} cotangent
\funcdesc{sec} secant
\funcdesc{csc} cosecant
\funcdesc{sinc} $\sinc(x) = \sin(x)/x$
\end{description}

Some have variants handling an input in degrees:

\begin{description}
\funcdesc{sind} sine
\funcdesc{cosd} cosine
\funcdesc{tand} tangent
\funcdesc{cotd} cotangent
\funcdesc{secd} secant
\funcdesc{cscd} cosecant
\end{description}

\subsubsection{Inverse trigonometry}

With the value in radians:

\begin{description}
\funcdesc{asin} arcsine
\funcdesc{arcsin} arcsine
\funcdesc{acsc} arccosecant
\funcdesc{arccsc} arccosecant
\funcdesc{acos} arccosine
\funcdesc{arccos} arccosine
\funcdesc{asec} arcsecant
\funcdesc{arcsec} arcsecant
\funcdesc{atan} arctangent
\funcdesc{arctg} arctangent
\funcdesc[x, y]{Arg} the main branch of the argument of the complex number
|x+iy|, from $-\pi$ (excluded) to $\pi$ (included). As the output is rounded
-\var{Pi} (its value) is a possible return value.
\funcdesc[x, y]{pArg} the branch of the argument of the complex number
|x+iy| with values going from $0$ (included) to $2\pi$ (excluded). Inherent
rounding makes \var{twoPi} (value) a possible return value.
\funcdesc[y, x]{atan2} is |Arg(x, y)|. Note the reversal of the arguments,
this seems to be the most frequently encountered convention across languages.
\end{description}

With the value in degrees:

\begin{description}
\funcdesc{asind} arcsine
\funcdesc{acosd} arccosine
\funcdesc{atand} arctangent
\funcdesc[x, y]{Argd} the main branch of the argument of the complex number
|x+iy|, from $-180$ (excluded) to $180$ (included). Inherent rounding of
output can cause |-180|
to be returned.
\funcdesc[x, y]{pArgd} the branch of the argument of the complex number
|x+iy| with values going from $0$ (included) to $360$ (excluded). Inherent rounding of
output can cause |360| to be returned.
\funcdesc[y, x]{atan2d} is |Argd(x, y)|. Note the reversal of the arguments,
this seems to be the most frequently encountered convention across languages.
\end{description}

\subsubsection{Conversion functions (optional definitions left to user
  decision)}

Python provides functions |degrees()| and |radians()|. But as most of the
\calxname functions are already defined for the two units, I felt this was
not really needed. It is a oneliner to add them:
\begin{everbatim}
\xintdeffloatfunc radians(x) := x * oneDegree;
\xintdeffloatfunc degrees(x) := x * oneRadian;
\end{everbatim}

\subsection{Important implementation notes}
\label{ssec:trignotes}

\begin{itemize}
\item Floating point numbers with large exponents are integers and are
  multiples of \dtt{1000}; hence modulo \dtt{360} all such ``angles''
  are integer multiples of \dtt{280} degrees, i.e.\@ are modulo
  \dtt{360} among the integer multiples of \dtt{40} degrees, which means
  that there are \emph{only 10 such angles}.  Needless to say,
  considering usage of the |sind()| and |cosd()| functions with such
  large floating point numbers is \textbf{meaningless}, or at least
  \textbf{illusory} (contrarily to say compute a square, a square-root,
  or a multiplication). This is the author's opinion, and you will have
  a very hard time making me change my mind.  A floating point number
  represents a range of real numbers, and large floating point numbers
  represent thus each a range encompassing multiple consecutive batches
  of \dtt{360} degrees, there is no way you can seriously think that one
  can give a meaning to the \func{sind} or \func{cosd} then apart from
  their averabe value which is zero (same for \func{sin} and
  \func{cos}).
% PROBABLY NOT TRUE AT 2.0 TO BE CHECKED
% \item Regarding |sin()| and |cos()|, \xinttrigname converts their argument to
%   degrees by multiplication by (pre-rounded) $180/\pi$, then does range
%   reduction modulo $360$ and finally goes back to radians in the appropriate
%   octants to use usual Taylor series (roughly said). For large floats, the
%   output value will thus be one of |sind(40n)|, |cosd(40n)|, |n=0..8|. If the
%   unit in the last place of original variable was for example \dtt{1e9} the
%   final result means nothing at all: the unit in the last place interval
%   extends above possibly astronomical numbers of intervals of length $2\pi$.

%   This intrinsic problem is not a by-product of conversion problems to and
%   from degrees, it is an in-built inadequacy of the concept of floating point
%   numbers to provide meaning to evaluating trigonometrical functions. The
%   argument should be treated as a uniformly distributed random variable modulo
%   $2\pi$, and the sine and cosine values should be random variables realizing
%   the value distribution of these mathematical functions. Clearly this adds
%   some (rather severe) implementation complications such as deciding how to
%   make the transition to randomness. Too lazy for that.

%   Opting for a random value also raises the question of how to deal with
%   multiple such evaluations at the same argument in a single expression. I
%   would argue again that as it is evil to consider meaningless quantities, it
%   is not a problem if new compilations give different results, or even single
%   compilation gives different results in various parts of the same formula,
%   that's the whole point of randomness! As said already, I got too lazy to
%   consider seriously implementing such a non-standard philosophy, despite its
%   compelling soundness.
% \item Did I say the implementation was done at very high level (for the most
%   part), hence has ample room for optimization? This is particularly the case
%   for the handling of small inputs by functions such as sine or arcsine.
\end{itemize}

\subsection{Some example evaluations}

\noindent
\begin{everbatim*}
\xintDigits* := 48\relax
Digits at \xinttheDigits:\newline
$sind(17)\approx\xintfloateval{sind(17)}$\newline
$cosd(17)\approx\xintfloateval{cosd(17)}$\newline
$tand(17)\approx\xintfloateval{tand(17)}$\newline
$sind(43)\approx\xintfloateval{sind(43)}$\newline
$cosd(43)\approx\xintfloateval{cosd(43)}$\newline
$tand(43)\approx\xintfloateval{tand(43)}$\newline
$asind(0.3)\approx\xintfloateval{asind(0.3)}$\newline
$acosd(0.3)\approx\xintfloateval{acosd(0.3)}$\newline
$atand(3)\approx\xintfloateval{atand(3)}$\newline
$tan(atan(7))\approx\xintfloateval{tan(atan(7))}$\newline
$asind(sind(25))\approx\xintfloateval{asind(sind(25))}$\par\medskip
\noindent\xintDigits* := 24\relax
Digits at \xinttheDigits:\newline
$sind(17)\approx\xintfloateval{sind(17)}$\newline
$cosd(17)\approx\xintfloateval{cosd(17)}$\newline
$tand(17)\approx\xintfloateval{tand(17)}$\newline
$sind(43)\approx\xintfloateval{sind(43)}$\newline
$cosd(43)\approx\xintfloateval{cosd(43)}$\newline
$tand(43)\approx\xintfloateval{tand(43)}$\newline
$asind(0.3)\approx\xintfloateval{asind(0.3)}$\newline
$acosd(0.3)\approx\xintfloateval{acosd(0.3)}$\newline
$atand(3)\approx\xintfloateval{atand(3)}$\newline
$tan(atan(7))\approx\xintfloateval{tan(atan(7))}$\newline
$asind(sind(25))\approx\xintfloateval{asind(sind(25))}$\par
\xintDigits* := 16\relax
\end{everbatim*}

\clearpage
\let\calxtrignameUp\undefined
\csname calxlognameUp\endcsname
\def\n{|{N}|}
\def\m{|{M}|}
\def\x{|{x}|}

\section{The \calxlogname.tex library}
\RaisedLabel{sec:calxlog}

\localtableofcontents

\subsection{Introduction}

This package provides logarithms, exponentials and fractional powers for
use within \csbxint{floateval} (and \csbxint{eval}).

The first release of \xintexprname supporting logarithms and
exponentials was |1.3e| (|2019/04/05|). It is automatically loaded by
\xintexprname.  Since |2.0a1| |2026/11/01| the maximal supported precision
is of \dtt{100} digits.

The \func{ln} alias, \func{expm1}, \func{log1p}, hyperbolic functions,
and their reciprocals were added at release |1.4p| (March 2026).

At \csbxint{theDigits} set to \dtt{8} (or less), the computations are
targeting a slighlty degraded accuracy (roughly at 8 digits, only about
95\% of values are correctly rounded, compared to 99.5\% for |P>8|.  In
both cases the error is never more tha 1ulp.

% TODO: OBSOLETE FIX THAT
% \begin{TeXnote}
%   For example, with \csbxint{Digits*} set to |8|, |log10(1.0011871)| is
%   produced as |5.15245e-4| which stands for |0.000515245| having \dtt{9}
%   correct decimal places in the \emph{fixed-point} sense, but only
%   \dtt{6} correct digits in the \emph{floating point} sense.  The
%   situation is even worse with |log()| as it applies a conversion factor
%   and does not remove the trailing junk digits (absent from the |log10()|
%   output).

%   For plotting though, such defects are usually not important, and
%   there is some real speed benefits from using \csbxint{Digits*} set
%   at |8| rather than its default of |16|.

%   Nevertheless the author has some intention to revisit and improve the
%   code in future, stop bootstrapping \xintlogname via
%   \ctanpackage{poormanlog} and get computations with \csbxint{Digits*}
%   set to |8| also achieve floating point accuracy, at an equivalent or
%   even improved speed compared with the current code.
% \end{TeXnote}

\subsection{\csh{xintreloadxintlog}}\label{xintreloadxintlog}

This is a no-op, provided only for backward compatibility.

\subsection{Functions}

\begin{description}
\funcdesc{log10} logarithm in base 10

\funcdesc{pow10} fractional powers of 10

\funcdesc{log} natural logarithm

\funcdesc{ln} natural logarithm

\funcdesc{log1p} computes |log(1+x)|

\funcdesc{exp} exponential function

\funcdesc{expm1} computes |e^x-1|

\funcdesc[x, y]{pow} computes $x^y$ via the formula |pow(y*log(x))|.
The exponent |y| is not rounded to the target floating point precision
beforehand, but to this target precision plus 14.  It does not have to
be, if integer, at most the \TeX{} bound for integers (which is
\dtt{\xintiieval{"7FFFFFFF}}). But the output must have a decimal
exponent obeying this bound (with some safety margin)
\begin{everbatim*}
\calxeval{3^3350214776, 2^5309964787}

\calxeval{3^3350214776/2^5309964787}
\end{everbatim*}

Inside the \csbxint{eval} evaluator, and if the exponent is integer,  and
if it is anticipated that
the output will not exceed (or will only slightly exceed) \dtt{10000} digits
(separately for numerator and denominator), then the power is computed \emph{exactly}.
To compute exactly higher powers than |2^9999| or |9^9999| or |99^5000| or
|999^3333|, etc..., use \csbxint{iieval}.  See \csbxint{iiPow} for related
comments if you don't want to melt your CPU.


\funcdesc{sinh} hyperbolic sine
\funcdesc{sh} hyperbolic sine
\funcdesc{cosh} hyperbolic cosine
\funcdesc{ch} hyperbolic cosine
\funcdesc{tanh} hyperbolic tangent
\funcdesc{th} hyperbolic tangent
\funcdesc{coth} hyperbolic cotangent
\funcdesc{sech} hyperbolic secant
\funcdesc{csch} hyperbolic cosecant
\funcdesc{asinh} reciprocal of hyperbolic sine
\funcdesc{argsh} reciprocal of hyperbolic sine
\funcdesc{acosh} reciprocal of hyperbolic cosine
\funcdesc{argch} reciprocal of hyperbolic cosine
\funcdesc{atanh} reciprocal of hyperbolic tangent
\funcdesc{argth} reciprocal of hyperbolic tangent
\funcdesc{acoth} reciprocal of hyperbolic cotangent
\funcdesc{argcoth} reciprocal of hyperbolic cotangent
\funcdesc{asech} reciprocal of hyperbolic secant
\funcdesc{argsech} reciprocal of hyperbolic secant
\funcdesc{acsch} reciprocal of hyperbolic cosecant
\funcdesc{argcsch} reciprocal of hyperbolic cosecant

\end{description}

\begin{everbatim*}
\xintDigits:=24\relax
\noindent\xintfloateval{ln(2), exp(1)}\newline
\xintfloateval{2^(1/3), 2^10000}\newline
\xintfloateval{sinh(1), cosh(1), tanh(1)}\newline
\xintfloateval{sh(1), ch(1), th(1)}
\end{everbatim*}

\xintDigits:=16;

\pdfstringdefDisableCommands{\let\cs\empty}

% TODO Check what is still true at 2.0 release
% \subsection{Some information on how powers are computed}

% For powers |a^b| or |a**b| in \csbxint{floateval} the following rules apply:
% \begin{enumerate}[noitemsep]
% \item a check is made if exponent is integer or half-integer,
% \item if this is the case legacy \csbxint{FloatPower} (combined with
%   \csbxint{FloatSqrt} for half-integer case)
%   are used to evaluate the power (and |a| can be negative if exponent is
%   integer),
% \item else the power is computed as |pow10(b*log10(a))| (but keeping some
%   extra digits in intermediate evaluations; in particular |b| is not
%   float-rounded, but |a| is).
% \end{enumerate}
% The reason is that the log/exp approach loses accuracy for very big
% exponents (say for exponents of the order of \dtt{100000000} or more). Here is
% an example of a precise computation with a very large exponent (\dtt{\xintiieval{12^16}}):
% \begin{everbatim*}
% $\xintTeXFromSci{\xintfloateval{1.00000001^\xintiiexpr 12^16\relax}}$\newline
% \xintDigits:=48;%\xintreloadxintlog is not done as log10/pow10 will not be used
% $\xintTeXFromSci{\xintfloateval{1.00000001^12^16}}$\newline
% \xintDigits:=64;%\xintreloadxintlog is not done as log10/pow10 will not be used
% $\xintTeXFromSci{\xintfloateval{1.00000001^12^16}}$\newline
% \xintDigits:=80;%\xintreloadxintlog is not done as log10/pow10 will not be used
% $\xintTeXFromSci{\xintfloateval{1.00000001^12^16}}$
% \xintDigits:=16;%
% \end{everbatim*}

% Notes:
% \begin{itemize}[noitemsep]
% \item in the case with \dtt{16} digits precision, we ensured |12^16| got
%   computed exactly with all its \dtt{18} digits and was not rounded to only
%   \dtt{16} digits (and confirmation is that the result matches the second one
%   at \dtt{48} digits),
% \item the |1.4g| right associativity
%   of powers is taken into account to drop parentheses.
% \end{itemize}

% As the legacy \csbxint{FloatPower} and \csbxint{FloatSqrt} work in arbitrary
% precision, the result for integer or half-integer exponents is produced with a
% full-size mantissa, even if |Digits| is more than \dtt{62} (as is examplified
% above).

% In the |10^(b*log10(a))| branch the mantissa size is limited to the minimum of
% |Digits| and of \dtt{64}. Its last digits will start being wrong if |b|
% becomes about (in absolute value) \dtt{100000000}. If you really need to
% compute powers with exponents that large or larger, it is recommended to
% decompose the exponent as a sum of the nearest integer or half-integer and a
% fractional part and express the power as a product. This is not done
% automatically as it would add some overhead in general for some a priori very
% rare use cases.

% And recall that the decimal exponents of final and
% intermediate results should obey the \TeX\ bound for integers anyhow, i.e. be
% at most (in absolute value) \dtt{\number"7FFFFFFF}, add some safety margin...

% In \csbxint{eval}, this is as in \csbxint{floateval} but for one difference: integer
% exponents will trigger an exact evaluation, as long as:
% \begin{itemize}
% \item the exponent absolute value is at most \dtt{9999},
% \item it is evaluated a priori, based on the length of the input, that the
%   output will have at most \dtt{10000} digits (or only a bit more), separately
%   for numerator and denominator.
% \end{itemize}
% The check for integralness of exponent is not on its mathematical value
% but on its internal representation, for speed. So |6/3| is not recognized as
% being an integer exponent in \csbxint{eval}; but in \csbxint{floateval}, the
% |6/3| will have been computed and recognized as |2|. Also |2.00| or |200e-2|
% is recognized as an integer in both parsers. Similar remarks apply to
% half-integer case.

% OBSOLETE

% If |Digits| is at most \dtt{8}, logarithms are computed faster but
% with less accuracy; internally, using \dtt{9} \emph{fixed
%   point fractional digits}.  And powers |a^b| lose accuracy in
% last digits quickly as |b| rises.  Here is what was observed
% with some random tests:
% \begin{itemize}[noitemsep]
% \item for |b| neither integer nor half-integer and |1<b<10|, 
%   roughly \dtt{8} correct digits for between \dtt{80}\% and \dtt{90}\% of
%   cases and in the remaining cases only a \dtt{1ulp} error.
% \item for |b| neither integer nor half-integer and |10^e<b<10^(e+1)|,
%   roughly \dtt{8-e} digits are correct for about
%   \dtt{90}\% of cases and there is a one unit error in the last of
%   those digits in the remaining cases.
% \end{itemize}
% To maintain higher accuracy, split the input as |a^n a^h| with |n|
% integer or half-integer nearest to |b|. After having considered (and
% implemented) the method, decision was made to not incorporate it as it
% would induce serious overhead generally speaking. The |a^b| with
% fractional exponent |b| such that |abs(b)<10| are currently computed
% with at most \dtt{1ulp} error in the vast majority of cases it seems,
% which is largely precise enough for plots, and then speed matters
% most. Larger exponents can be handled (since |1.4f|) via manually
% implementing the splitting trick, as described above.

% The documentation of the legacy macro \csbxint{FloatPower} (which is used for
% powers with integer and half-integer exponents) explains it has a guaranteed
% error bound of |0.52ulp|, in arbitrary precision.  Generally speaking, the
% math functions added at |1.4e| target even smaller errors (but only up to
% \dtt{62} digits), something of the order of |0.505ulp|, and in practice they
% seem to achieve even better than \dtt{99\%} of correct rounding probability
% (at least in their natural ranges, and it varies according to the value of
% |Digits|).  Perhaps in future I will re-examine whether it is worthwile to
% increase a bit the theoretical accuracy of \csbxint{FloatPower}, as I have not
% had the time to really measure systematically its pratical accuracy, all
% anecdotical evidence showing it is good.

\clearpage
\let\calxlognameUp\undefined
\csname xinttoolsnameUp\endcsname
\def\n{|{N}|}
\def\m{|{M}|}
\def\x{|{x}|}
\section{Macros of the \xinttoolsname package}
\RaisedLabel{sec:tools}

\localtableofcontents

\subsection{Introduction}

These utilities used to be provided within the \xintname package; since |1.09g|
(|2013/11/22|) they have been moved to an independently usable package
\xinttoolsname, which has none of the \xintname facilities regarding big
numbers. Whenever relevant release |1.09h| has made the macros |\long| so they
accept |\par| tokens on input.

The completely expandable utilities (up to \csbxint{iloop}) are documented
first, then the non expandable utilities.

\autoref{sec:examples}
gives additional (some quite dated) examples of use of macros of this package.

\xinttoolsname is automatically loaded by \xintexprname.

\subsection{\csh{xintRevWithBraces}}\label{xintRevWithBraces}

%{\small New in release |1.06|.\par}

\edef\X{\xintRevWithBraces{12345}}
\edef\y{\xintRevWithBraces\X}
\expandafter\def\expandafter\w\expandafter
     {\romannumeral0\xintrevwithbraces{{\A}{\B}{\C}{\D}{\E}}}

%
\csa{xintRevWithBraces}\marg{list}\etype{f} first does the \fexpan sion of its
argument then it reverses the order of the tokens, or braced material, it
encounters, maintaining existing braces and adding a brace pair around each
naked token encountered. Space tokens (in-between top level braces or naked
tokens) are gobbled. This macro is mainly thought out for use on a \meta{list}
of such braced material; with such a list as argument the \fexpan sion will only
hit against the first opening brace, hence do nothing, and the braced stuff may
thus be macros one does not want to expand.
%
\leftedline{|\edef\x{\xintRevWithBraces{12345}}|}
%
\leftedline{|\meaning\x:|\dtt{\meaning\X}}
%
\leftedline{|\edef\y{\xintRevWithBraces\x}|}
%
\leftedline{|\meaning\y:|\dtt{\meaning\y}}
%
The examples above could be defined with |\edef|'s because the braced material
did not contain macros. Alternatively:
%
\leftedline{|\expandafter\def\expandafter\w\expandafter|}
%
\leftedline{|{\romannumeral0\xintrevwithbraces{{\A}{\B}{\C}{\D}{\E}}}|}
%
\leftedline{|\meaning\w:|\dtt{\meaning\w}}
%
The macro \csa{xintReverseWithBracesNoExpand}\etype{n} does the same job
without the initial expansion of its argument.


\subsection{\csh{xintZapFirstSpaces}, \csh{xintZapLastSpaces}, \csh{xintZapSpaces}, \csh{xintZapSpacesB}}
\label{xintZapFirstSpaces}
\label{xintZapLastSpaces}
\label{xintZapSpaces}
\label{xintZapSpacesB}
%{\small New with release |1.09f|.\par}

\csa{xintZapFirstSpaces}\marg{stuff}\etype{n} does not do \emph{any} expansion
of its argument, nor brace removal of any sort, nor does it alter \meta{stuff}
in anyway apart from stripping away all \emph{leading} spaces.

This macro will be mostly of interest to programmers who will know what I will
now be talking about. \emph{The essential points, naturally, are the complete
  expandability and the fact that no brace removal nor any other alteration is
  done to the input.}

\TeX's input scanner already converts consecutive blanks into single space
tokens, but |\xintZapFirstSpaces| handles successfully also inputs with
consecutive multiple space tokens.
However, it is assumed that \meta{stuff} does not contain (except inside braced
sub-material) space tokens of character code distinct from $32$.

It expands in two steps, and if the goal is to apply it to the
expansion text of |\x| to define |\y|, then one can do:
|\odef\y{\romannumeral0\expandafter\xintzapfirstspaces\expandafter{\x}}|
(one can also define a wrapper macro to |\xintZapFirstSpaces| in order to
expand once the argument first, but \xinttoolsname not being a programming
layer, it provides no \myenquote{Generate Variants} facilities). 

Other use case: inside a macro which received a parameter |#1|, one can do
|\oodef\x{\xintZapFirstSpaces {#1}}|, or, if |#1|, after leading spaces have
been stripped can accept |\edef| expansion, one can do
|\edef\x{\xintZapFirstSpaces{#1}}|.

\begingroup
\def\x {  \a {  \X } {  \b  \Y }  }
%
\leftedline{|\xintZapFirstSpaces {  \a {  \X } {  \b  \Y }  }->|%
\dtt{\color{magenta}{}\expandafter\detokenize\expandafter
{\romannumeral0\expandafter\xintzapfirstspaces\expandafter{\x}}}+++}
\endgroup

\medskip

\noindent\csbxint{ZapLastSpaces}\marg{stuff}\etype{n}  does not do \emph{any} expansion of
its argument, nor brace removal of any sort, nor does it alter \meta{stuff} in
anyway apart from stripping away all \emph{ending} spaces. The same remarks as
for \csbxint{ZapFirstSpaces} apply.

\begingroup
\def\x {  \a {  \X } {  \b  \Y }  }
%
\leftedline{|\xintZapLastSpaces {  \a {  \X } {  \b  \Y }  }->|%
\dtt{\color{magenta}{}\expandafter\detokenize\expandafter
{\romannumeral0\expandafter\xintzaplastspaces\expandafter{\x}}}+++}
\endgroup

\medskip

\noindent\csbxint{ZapSpaces}\marg{stuff}\etype{n}  does not do \emph{any}
expansion of its
argument, nor brace removal of any sort, nor does it alter \meta{stuff} in
anyway apart from stripping away all \emph{leading} and all \emph{ending}
spaces. The same remarks as for \csbxint{ZapFirstSpaces} apply.

\begingroup
\def\x {  \a {  \X } {  \b  \Y }  }
%
\leftedline{|\xintZapSpaces {  \a {  \X } {  \b  \Y }  }->|%
\dtt{\color{magenta}{}\expandafter\detokenize\expandafter
{\romannumeral0\expandafter\xintzapspaces\expandafter{\x}}}+++}
\endgroup

\medskip

\noindent\csbxint{ZapSpacesB}\marg{stuff}\etype{n}  does not do \emph{any}
expansion of
its argument, nor does it alter \meta{stuff} in anyway apart from stripping away
all leading and all ending spaces and possibly removing one level of braces if
\meta{stuff} had the shape |<spaces>{braced}<spaces>|. The same remarks as for
\csbxint{ZapFirstSpaces} apply.

\begingroup
\def\x {  \a {  \X } {  \b  \Y }  }
%
\leftedline{|\xintZapSpacesB {  \a {  \X } {  \b  \Y }  }->|%
\dtt{\color{magenta}{}\expandafter\detokenize\expandafter
{\romannumeral0\expandafter\xintzapspacesb\expandafter{\x}}}+++}
\def\x {  { \a {  \X } {  \b  \Y } }  }
%
\leftedline{|\xintZapSpacesB {  { \a {  \X } {  \b  \Y } }  }->|%
\dtt{\color{magenta}{}\expandafter\detokenize\expandafter
{\romannumeral0\expandafter\xintzapspacesb\expandafter{\x}}}+++}
\endgroup
 The spaces here at the start and end of the output come from the braced
 material, and are not removed (one would need a second application for that;
 recall though that the \xintname zapping macros do not expand their argument).

\subsection{\csh{xintCSVtoList}}
\label{xintCSVtoList}
\label{xintCSVtoListNoExpand}


\csa{xintCSVtoList}|{a,b,c...,z}|\etype{f}  returns |{a}{b}{c}...{z}|. A
\emph{list} is by
convention in this manual simply a succession of tokens, where each braced thing
will count as one item (``items'' are defined according to the rules of \TeX{}
for fetching undelimited parameters of a macro, which are exactly the same rules
as for \LaTeX{} and macro arguments [they are the same things]). The word
`list' in `comma separated list of items' has its usual linguistic meaning,
and then an ``item'' is what is delimited by commas.

So \csa{xintCSVtoList} takes on input a `comma separated list of items' and
converts it into a `\TeX{} list of braced items'. The argument to
|\xintCSVtoList| may be a macro: it will first be
\hyperref[ssec:expansions]{\fexpan ded}. Hence the item before the first comma,
if it is itself a macro, will be expanded which may or may not be a good thing.
A space inserted at the start of the first item serves to stop that expansion
(and disappears). The macro \csbxint{CSVtoListNoExpand}\etype{n} does the same
job without
the initial expansion of the list argument.

Apart from that no expansion of the items is done and the list items may thus be
completely arbitrary (and even contain perilous stuff such as unmatched |\if|
and |\fi| tokens).

Contiguous spaces and tab characters, are collapsed by \TeX{}
into single spaces. All such spaces around commas%
%
\footnote{and multiple space tokens are not a problem; but those at the
  top level (not hidden inside braces) \emph{must} be of character code
  |32|.}
%
\fbox{are removed}, as well as
the spaces at the start and the spaces at the end of the list.%
%
\footnote{let us recall that this is all done completely expandably...
  There is absolutely no alteration of any sort of the item apart from
  the stripping of initial and final space tokens (of character code
  |32|) and brace removal if and only if the item apart from intial and
  final spaces (or more generally multiple |char 32| space tokens) is
  braced.}
%
The items may contain explicit |\par|'s or
empty lines (converted by the \TeX{} input parsing into |\par| tokens).

\begingroup

\edef\X{\xintCSVtoList { 1 ,{ 2 , 3 , 4 , 5 }, a , {b,T} U , { c , d } , { {x ,
        y} } }}

%
\leftedline{|\xintCSVtoList { 1 ,{ 2 , 3 , 4 , 5 }, a , {b,T} U , { c , d } ,
    { {x , y} } }|}
%
\leftedline{|->|%
{\makeatletter\dtt{\expandafter\strip@prefix\meaning\X}}}

One sees on this example how braces protect commas from
sub-lists to be perceived as delimiters of the top list. Braces around an entire
item are removed, even when surrounded by spaces before and/or after. Braces for
sub-parts of an item are not removed.

We observe also that there is a slight difference regarding the brace stripping
of an item: if the braces were not surrounded by spaces, also the initial and
final (but no other) spaces of the \emph{enclosed} material are removed. This is
the only situation where spaces protected by braces are nevertheless removed.

From the rules above: for an empty argument (only spaces, no braces, no comma)
the output is
\dtt{\expandafter\detokenize\expandafter{\romannumeral0\xintcsvtolist { }}}
(a list with one empty item),
for ``|<opt. spaces>{}<opt.
spaces>|'' the output is
\dtt{\expandafter\detokenize\expandafter
   {\romannumeral0\xintcsvtolist { {} }}}
(again a list with one empty item, the braces were removed),
for ``|{ }|'' the output is
\dtt{\expandafter\detokenize\expandafter
 {\romannumeral0\xintcsvtolist {{ }}}}
(again a list with one empty item, the braces were removed and then
the inner space was removed),
for ``| { }|'' the output is
\dtt{\expandafter\detokenize\expandafter
{\romannumeral0\xintcsvtolist { { }}}} (again a list with one empty item, the initial space served only to stop the expansion, so this was like ``|{ }|'' as input, the braces were removed and the inner space was stripped),
for ``\texttt{\ \{\ \ \}\ }'' the output is
\dtt{\expandafter\detokenize\expandafter
{\romannumeral0\xintcsvtolist { {  } }}} (this time the ending space of the first
item meant that after brace removal the inner spaces were kept; recall though
that \TeX{} collapses on input consecutive blanks into one space token),
for ``|,|'' the output consists of two consecutive
empty items
\dtt{\expandafter\detokenize\expandafter{\romannumeral0\xintcsvtolist
    {,}}}. Recall that on output everything is braced, a |{}| is an ``empty''
item.
%
Most of the above is mainly irrelevant for every day use, apart perhaps from the
fact to be noted that an empty input does not give an empty output but a
one-empty-item list (it is as if an ending comma was always added at the end of
the input).

\def\y { \a,\b,\c,\d,\e}
\expandafter\def\expandafter\Y\expandafter{\romannumeral0\xintcsvtolist{\y}}
\def\t {{\if},\ifnum,\ifx,\ifdim,\ifcat,\ifmmode}
\expandafter\def\expandafter\T\expandafter{\romannumeral0\xintcsvtolist{\t}}

%
\leftedline{|\def\y{ \a,\b,\c,\d,\e} \xintCSVtoList\y->|%
  {\makeatletter\dtt{\expandafter\strip@prefix\meaning\Y}}}
%
\leftedline{|\def\t {{\if},\ifnum,\ifx,\ifdim,\ifcat,\ifmmode}|}
%
\leftedline
{|\xintCSVtoList\t->|\makeatletter\dtt{\expandafter\strip@prefix\meaning\T}}
%
The results above were automatically displayed using \TeX's primitive
\csa{meaning}, which adds a space after each control sequence name. These spaces
are not in the actual braced items of the produced lists. The first items |\a|
and |\if| were either preceded by a space or braced to prevent expansion. The
macro \csa{xintCSVtoListNoExpand} would have done the same job without the
initial expansion of the list argument, hence no need for such protection but if
|\y| is defined as |\def\y{\a,\b,\c,\d,\e}| we then must do:
%
\leftedline{|\expandafter\xintCSVtoListNoExpand\expandafter {\y}|} Else, we
may have direct use: %
%
\leftedline{|\xintCSVtoListNoExpand
 {\if,\ifnum,\ifx,\ifdim,\ifcat,\ifmmode}|}
%
\leftedline{|->|\dtt{\expandafter\detokenize\expandafter
    {\romannumeral0\xintcsvtolistnoexpand
      {\if,\ifnum,\ifx,\ifdim,\ifcat,\ifmmode}}}}
%
Again these spaces are an artefact from the use in the source of the document of
\csa{meaning} (or rather here, \csa{detokenize}) to display the result of using
\csa{xintCSVtoListNoExpand} (which is done for real in this document
source).

For the similar conversion from comma separated list to braced items list, but
without removal of spaces around the commas, there is
\csa{xintCSVtoListNonStripped}\etype{f} and
\csa{xintCSVtoListNonStrippedNoExpand}\etype{n}.

\endgroup

\subsection{\csh{xintNthElt}}\label{xintNthElt}


\def\macro #1{\the\numexpr 9-#1\relax}

\csa{xintNthElt\x}\marg{list}\etype{\numx f} gets (expandably) the |x|th
item of the \meta{list}. A braced item will lose one level of brace
pairs. The token list is first \fexpan ded.

Items are counted starting at one.

\leftedline{|\xintNthElt {3}{{agh}\u{zzz}\v{Z}}| is
    \texttt{\xintNthElt {3}{{agh}\u{zzz}\v{Z}}}}
%
\leftedline{|\xintNthElt {3}{{agh}\u{{zzz}}\v{Z}}| is
    \texttt{\expandafter\expandafter\expandafter
      \detokenize\expandafter\expandafter\expandafter {\xintNthElt
        {3}{{agh}\u{{zzz}}\v{Z}}}}}
%
\leftedline{|\xintNthElt {2}{{agh}\u{{zzz}}\v{Z}}| is
    \texttt{\expandafter\expandafter\expandafter
      \detokenize\expandafter\expandafter\expandafter {\xintNthElt
        {2}{{agh}\u{{zzz}}\v{Z}}}}}
%
\leftedline{|\xintNthElt {37}{\xintiiFac {100}}|\dtt{=\xintNthElt
      {37}{\xintiiFac {100}}} is the thirty-seventh digit of $100!$.}
%
\leftedline{|\xintNthElt {10}{\xintFtoCv
      {566827/208524}}|\dtt{=\xintNthElt {10}{\xintFtoCv
        {566827/208524}}}}
\leftedline{is the tenth convergent of $566827/208524$ (uses \xintcfracname
  package).}
%
\leftedline{|\xintNthElt {7}{\xintCSVtoList {1,2,3,4,5,6,7,8,9}}|%
    \dtt{=\xintNthElt {7}{\xintCSVtoList {1,2,3,4,5,6,7,8,9}}}}
%
\leftedline{|\xintNthElt {0}{\xintCSVtoList {1,2,3,4,5,6,7,8,9}}|%
    \dtt{=\xintNthElt {0}{\xintCSVtoList {1,2,3,4,5,6,7,8,9}}}}
%
\leftedline{|\xintNthElt {-3}{\xintCSVtoList {1,2,3,4,5,6,7,8,9}}|%
    \dtt{=\xintNthElt {-3}{\xintCSVtoList {1,2,3,4,5,6,7,8,9}}}}

If |x=0|,
the macro returns the \emph{length} of the expanded list: this is not equivalent
to \csbxint{Length} which does no pre-expansion. And it is different from
\csbxint{Len} which is to be used only on integers or fractions.

If |x<0|, the macro returns the \verb+|x|+th element from the end of the list.
Thus for example |x=-1| will fetch the last item of the list.
%
\leftedline {|\xintNthElt {-5}{{{agh}}\u{zzz}\v{Z}}| is
  \texttt{\expandafter\expandafter\expandafter \detokenize
  \expandafter\expandafter\expandafter{\xintNthElt {-5}{{{agh}}\u{zzz}\v{Z}}}}}

The macro \csa{xintNthEltNoExpand}\etype{\numx n} does the same job but without
first expanding the list argument: |\xintNthEltNoExpand {-4}{\u\v\w T\x\y\z}| is
\xintNthEltNoExpand {-4}{\a\b\c\u\v\w T\x\y\z}.

If |x| is strictly larger (in absolute value) than the length of the list
then |\xintNthElt| produces empty contents.

\subsection{\csh{xintNthOnePy}}
\label{xintNthOnePy}

\csa{xintNthOnePy\x}\marg{list}\etype{\numx f} gets (expandably) the |x|th
item of the \meta{list}, adding a brace pair if there wasn't one.

Attention, items are counted starting at zero. For negative index, behaves
as \csbxint{NthElt}.

If the index is out of range, the empty output is returned. If the input list
was empty (had no items) the empty output is returned.

\subsection{\csh{xintKeep}}\label{xintKeep}

\csa{xintKeep\x}\marg{list}\etype{\numx f} expands the token list argument |L|
and produces a new list, depending on the value of |x|:
\begin{itemize}[nosep]
\item if |x>0|, the new list contains the first |x| items from |L| (counting
  starts at one.) \emph{Each
    such item will be output within a brace pair.} Use \csbxint{KeepUnbraced} if
  this is not desired. This means that if the list item was braced to start
  with, there is no modification, but if it was a token without braces,
  then it acquires them.
\item if |x>=length(L)|, the new list is the old one with all its items now
  braced.
\item if |x=0| the empty list is returned.
\item if |x<0| the last \verb+|x|+ elements compose the output in the same
  order as in the initial list; as the macro proceeds by removing head items
  the kept items end up in output as they were in input: no added braces.
\item if |x<=-length(L)| the output is identical with the input.
\end{itemize}

\csa{xintKeepNoExpand} does the same without first \fexpan ding its list
argument.
%
\begin{everbatim*}
\fdef\test {\xintKeep {17}{\xintKeep {-69}{\xintSeq {1}{100}}}}\meaning\test\par
\noindent\fdef\test {\xintKeep {7}{{1}{2}{3}{4}{5}{6}{7}{8}{9}}}\meaning\test\par
\noindent\fdef\test {\xintKeep {-7}{{1}{2}{3}{4}{5}{6}{7}{8}{9}}}\meaning\test\par
\noindent\fdef\test {\xintKeep {7}{123456789}}\meaning\test\par
\noindent\fdef\test {\xintKeep {-7}{123456789}}\meaning\test\par
\end{everbatim*}


\subsection{\csh{xintKeepUnbraced}}\label{xintKeepUnbraced}

Same as \csbxint{Keep} but no brace pairs are added around the kept items from
the head of the list in the case |x>0|: each such item will lose one level of
braces. Thus, to remove braces from all items of the list, one can use
\csbxint{KeepUnbraced} with its first argument larger than the length of the
list; the same is obtained from \csbxint{ListWithSep}|{}|\marg{list}. But the
new list will then have generally many more items than the original ones,
corresponding to the unbraced original items.

For |x<0| the macro is no different from \csbxint{Keep}. Hence the name is a
bit misleading because brace removal will happen only if |x>0|.

\csa{xintKeepUnbracedNoExpand} does the same without first \fexpan ding
its list argument.
%
\begin{everbatim*}
\fdef\test {\xintKeepUnbraced {10}{\xintSeq {1}{100}}}\meaning\test\par
\noindent\fdef\test {\xintKeepUnbraced {7}{{1}{2}{3}{4}{5}{6}{7}{8}{9}}}%
         \meaning\test\par
\noindent\fdef\test {\xintKeepUnbraced {-7}{{1}{2}{3}{4}{5}{6}{7}{8}{9}}}%
         \meaning\test\par
\noindent\fdef\test {\xintKeepUnbraced {7}{123456789}}\meaning\test\par
\noindent\fdef\test {\xintKeepUnbraced {-7}{123456789}}\meaning\test\par
\end{everbatim*}

\subsection{\csh{xintTrim}}\label{xintTrim}

\csa{xintTrim\x}\marg{list}\etype{\numx f} expands the list argument and
gobbles its first |x| elements.
\begin{itemize}[nosep]
\item if |x>0|, the first |x| items from |L| are gobbled. The remaining items
  are not modified.
\item if |x>=length(L)|, the returned list is empty.
\item if |x=0| the original list is returned (with no added braces.)
\item if |x<0| the last \verb+|x|+ items of the list are removed. \emph{The
    head items end up braced in the output.} Use \csbxint{TrimUnbraced} if
  this is not desired.
\item if |x<=-length(L)| the output is empty.
\end{itemize}

\csa{xintTrimNoExpand} does the same without first \fexpan ding its list
argument.
\begin{everbatim*}
\fdef\test {\xintTrim {17}{\xintTrim {-69}{\xintSeq {1}{100}}}}\meaning\test\par
\noindent\fdef\test {\xintTrim {7}{{1}{2}{3}{4}{5}{6}{7}{8}{9}}}\meaning\test\par
\noindent\fdef\test {\xintTrim {-7}{{1}{2}{3}{4}{5}{6}{7}{8}{9}}}\meaning\test\par
\noindent\fdef\test {\xintTrim {7}{123456789}}\meaning\test\par
\noindent\fdef\test {\xintTrim {-7}{123456789}}\meaning\test\par
\end{everbatim*}

\subsection{\csh{xintTrimUnbraced}}\label{xintTrimUnbraced}

Same as \csbxint{Trim} but in case of a negative |x| (cutting items from
the tail), the kept items from the head are not enclosed in brace pairs. They
will lose one level of braces. The name is a bit misleading
because when |x>0| there is no brace-stripping done on the kept items, because
the macro works simply by gobbling the head ones.

\csa{xintTrimUnbracedNoExpand} does the same without first \fexpan ding its list
argument.

\begin{everbatim*}
\fdef\test {\xintTrimUnbraced {-90}{\xintSeq {1}{100}}}\meaning\test\par
\noindent\fdef\test {\xintTrimUnbraced {7}{{1}{2}{3}{4}{5}{6}{7}{8}{9}}}%
         \meaning\test\par
\noindent\fdef\test {\xintTrimUnbraced {-7}{{1}{2}{3}{4}{5}{6}{7}{8}{9}}}%
         \meaning\test\par
\noindent\fdef\test {\xintTrimUnbraced {7}{123456789}}\meaning\test\par
\noindent\fdef\test {\xintTrimUnbraced {-7}{123456789}}\meaning\test\par
\end{everbatim*}

\subsection{\csh{xintListWithSep}}\label{xintListWithSep}


\def\macro #1{\the\numexpr 9-#1\relax}

\csa{xintListWithSep}\marg{sep}\marg{list}\etype{nf} inserts the separator
\meta{sep} in-between all items of the given list of braced items (or
individual tokens). The items are fetched as does \TeX\ with undelimited macro
arguments, thus they end up unbraced in output. If the \meta{list} is only one
(or multiple) space tokens, the output is empty.

The list argument \meta{list} gets \fexpan ded first (thus if it is a macro
whose contents are braced items, the first opening brace stops the expansion,
and it is as if the macro had been expanded once.) The separator \meta{sep} is
not pre-expanded, it ends up as is in the output (if the \meta{list} contained
at least two items.)

The variant \csa{xintListWithSepNoExpand}\etype{nn} does the same
job without the initial expansion of the \meta{list} argument.
\begin{everbatim*}
\edef\foo{\xintListWithSep{, }{123456789{10}{11}{12}}}\meaning\foo\newline
\edef\foo{\xintListWithSep{:}{\xintiiFac{20}}}\meaning\foo\newline
\oodef\FOO{\xintListWithSepNoExpand{\FOO}{\bat\baz\biz\buz}}\meaning\FOO\newline
% a braced item or a space stops the f-expansion:
\oodef\foo{\xintListWithSep{\FOO}{{\bat}\baz\biz\buz}}\meaning\foo\newline
\oodef\foo{\xintListWithSep{\FOO}{ \bat\baz\biz\buz}}\meaning\foo\par
\end{everbatim*}

\subsection{\csh{xintApply}}\label{xintApply}


\def\macro #1{\the\numexpr 9-#1\relax}

\csa{xintApply}|{\macro}|\marg{list}\etype{ff} expandably applies the one
parameter macro |\macro| to each item in the \meta{list} given as second
argument and returns a new list with these outputs: each item is given one after
the other as parameter to |\macro| which is expanded at that time (as usual,
\emph{i.e.\@} fully for what comes first), the results are braced and output
together as a succession of braced items (if |\macro| is defined to start with a
space, the space will be gobbled and the |\macro| will not be expanded; it is
allowed to have its own arguments, the list items serve as last arguments to
|\macro|). Hence |\xintApply{\macro}{{1}{2}{3}}| returns
|{\macro{1}}{\macro{2}}{\macro{3}}| where all instances of |\macro| have been
already \fexpan ded.

Trick: |{\macro}| is perfectly allowed to be |{\macro{17}}| if |\macro|
is actually a macro with \emph{two} arguments.  It will thus be expanded
with the first one being always here |{17}|.

Being expandable, |\xintApply| is useful for example inside alignments where
implicit groups make standard loops constructs usually fail. In such situation
it is often not wished that the new list elements be braced, see
\csbxint{ApplyUnbraced}. The |\macro| does not have to be expandable:
|\xintApply| will try to expand it, the expansion may remain partial.

The \meta{list} may
itself be some macro expanding (in the previously described way) to the list of
tokens to which the macro |\macro| will be applied. For example, if the
\meta{list} expands to some positive number, then each digit will be replaced by
the result of applying |\macro| on it. %
%
\leftedline{|\def\macro #1{\the\numexpr
    9-#1\relax}|} %
%
\leftedline{|\xintApply\macro{\xintiiFac
 {20}}|\dtt{=\xintApply\macro{\xintiiFac {20}}}}

The macro \csa{xintApplyNoExpand}\etype{fn} does the same job without the first
initial expansion which gave the \meta{list} of braced tokens to which |\macro|
is applied.

\subsection{\csh{xintApplyUnbraced}}\label{xintApplyUnbraced}


\csa{xintApplyUnbraced}|{\macro}|\marg{list}\etype{ff} is like \csbxint{Apply}.
The difference is that after having expanded its list argument, and applied
|\macro| in turn to each item from the list, it reassembles the outputs without
enclosing them in braces. The net effect is the same as doing
%
\leftedline{|\xintListWithSep {}{\xintApply {\macro}|\marg{list}|}|} This is
useful for preparing a macro which will itself define some other macros or make
assignments, as the scope will not be limited by brace pairs.
%
\begin{everbatim*}
\def\macro #1{\expandafter\def\csname myself#1\endcsname {#1}}
\xintApplyUnbraced\macro{{elta}{eltb}{eltc}}
\begin{enumerate}[nosep,label=(\arabic{*})]
\item \meaning\myselfelta
\item \meaning\myselfeltb
\item \meaning\myselfeltc
\end{enumerate}
\end{everbatim*}

%
The macro \csa{xintApplyUnbracedNoExpand}\etype{fn} does the same job without
the first initial expansion which gave the \meta{list} of braced tokens to which
|\macro| is applied.

\subsection{\csh{xintSeq}}\label{xintSeq}

\csa{xintSeq}|[d]{x}{y}|\etype{{{\upshape[\numx]}}\numx\numx} generates
expandably |{x}{x+d}...| up to and possibly including |{y}| if |d>0| or down
to and including |{y}| if |d<0|. Naturally |{y}| is omitted if |y-x| is not a
multiple of |d|. If |d=0| the macro returns |{x}|. If |y-x| and |d| have
opposite signs, the macro returns nothing. If the optional argument |d| is
omitted it is taken to be the sign of |y-x|. Hence |\xintSeq {1}{0}| is not
empty but |{1}{0}|. But |\xintSeq [1]{1}{0}| is empty.


The arguments |x| and |y| are expanded inside a |\numexpr| so they may be
count registers or a \LaTeX{} |\value{countername}|, or arithmetic with such
things.

%
\begin{everbatim*}
\xintListWithSep{,\hskip2pt plus 1pt minus 1pt }{\xintSeq {12}{-25}}
\end{everbatim*}
%
\begin{everbatim*}
\xintiiSum{\xintSeq [3]{1}{1000}}
\end{everbatim*}

When the macro is used without the optional argument |d|, it can only generate
up to about $5000$ numbers\IMPORTANT, the precise value depends upon some
\TeX{} memory parameter (input save stack).

With the optional argument |d| the macro proceeds differently (but less
efficiently) and does not stress the input save stack.



\subsection{\csh{xintloop}, \csh{xintbreakloop}, \csh{xintbreakloopanddo}, \csh{xintloopskiptonext}}
\label{xintloop}
\label{xintbreakloop}
\label{xintbreakloopanddo}
\label{xintloopskiptonext}

|\xintloop|\meta{stuff}|\if<test>...\repeat|\xtype{} is an expandable loop
compatible with nesting. However to break out of the loop one almost always need
some un-expandable step. The cousin \csbxint{iloop} is \csbxint{loop} with an
embedded expandable mechanism allowing to exit from the loop. The iterated
macros may contain |\par| tokens or empty lines.

If a sub-loop is to be used all the material from the start of the main loop and
up to the end of the entire subloop should be braced; these braces will be
removed and do not create a group. The simplest to allow the nesting of one or
more sub-loops is to brace everything between \csa{xintloop} and \csa{repeat},
being careful not to leave a space between the closing brace and |\repeat|.

As this loop and \csbxint{iloop} will primarily be of interest to experienced
\TeX{} macro programmers, my description will assume that the user is
knowledgeable enough. Some examples in this document will be perhaps more
illustrative than my attemps at explanation of use.

One can abort the loop with \csbxint{breakloop}; this should not be used inside
the final test, and one should expand the |\fi| from the corresponding test
before. One has also \csbxint{breakloopanddo} whose first argument will be
inserted in the token stream after the loop; one may need a macro such as
|\xint_afterfi| to move the whole thing after the |\fi|, as a simple
|\expandafter| will not be enough.

One will usually employ some count registers to manage the exit test from the
loop; this breaks expandability, see \csbxint{iloop} for an expandable integer
indexed loop. Use in alignments will be complicated by the fact that cells
create groups, and also from the fact that any encountered unexpandable material
will cause the \TeX{} input scanner to insert |\endtemplate| on each encountered
|&| or |\cr|; thus |\xintbreakloop| may not work as expected, but the situation
can be resolved via |\xint_firstofone{&}| or use of |\TAB| with |\def\TAB{&}|.
It is thus simpler for alignments to use rather than \csbxint{loop} either the
expandable \csbxint{ApplyUnbraced} or the non-expandable but alignment
compatible \csbxint{ApplyInline}, \csbxint{For} or \csbxint{For*}.

As an example, let us suppose we have two macros |\A|\marg{i}\marg{j} and
|\B|\marg{i}\marg{j} behaving like (small) integer valued matrix entries, and we
want to define a macro |\C|\marg{i}\marg{j} giving the matrix product (|i| and
|j| may be count registers). We will assume that |\A[I]| expands to the number
of rows, |\A[J]| to the number of columns and want the produced |\C| to act in
the same manner. The code is very dispendious in use of |\count| registers, not
optimized in any way, not made very robust (the defined macro can not have the
same name as the first two matrices for example), we just wanted to quickly
illustrate use of the nesting capabilities of |\xintloop|.%
%
\footnote{for a more sophisticated implementation of matrix
  multiplication, inclusive of determinants, inverses, and display
  utilities, with entries big integers or decimal numbers or even
  fractions see some code online posted
  from
  November 11, 2013.}
%


\begin{everbatim*}
\newcount\rowmax   \newcount\colmax   \newcount\summax
\newcount\rowindex \newcount\colindex \newcount\sumindex
\newcount\tmpcount
\makeatletter
\def\MatrixMultiplication #1#2#3{%
    \rowmax #1[I]\relax
    \colmax #2[J]\relax
    \summax #1[J]\relax
    \rowindex 1
    \xintloop % loop over row index i
    {\colindex 1
     \xintloop % loop over col index k
     {\tmpcount 0
      \sumindex 1
      \xintloop % loop over intermediate index j
      \advance\tmpcount \numexpr #1\rowindex\sumindex*#2\sumindex\colindex\relax
      \ifnum\sumindex<\summax
         \advance\sumindex 1
      \repeat }%
     \expandafter\edef\csname\string#3{\the\rowindex.\the\colindex}\endcsname
      {\the\tmpcount}%
     \ifnum\colindex<\colmax
         \advance\colindex 1
     \repeat }%
    \ifnum\rowindex<\rowmax
    \advance\rowindex 1
    \repeat
    \expandafter\edef\csname\string#3{I}\endcsname{\the\rowmax}%
    \expandafter\edef\csname\string#3{J}\endcsname{\the\colmax}%
    \def #3##1{\ifx[##1\expandafter\Matrix@helper@size
                    \else\expandafter\Matrix@helper@entry\fi #3{##1}}%
}%
\def\Matrix@helper@size #1#2#3]{\csname\string#1{#3}\endcsname }%
\def\Matrix@helper@entry #1#2#3%
   {\csname\string#1{\the\numexpr#2.\the\numexpr#3}\endcsname }%
\def\A #1{\ifx[#1\expandafter\A@size
            \else\expandafter\A@entry\fi {#1}}%
\def\A@size #1#2]{\ifx I#23\else4\fi}% 3rows, 4columns
\def\A@entry #1#2{\the\numexpr #1+#2-1\relax}% not pre-computed...
\def\B #1{\ifx[#1\expandafter\B@size
            \else\expandafter\B@entry\fi {#1}}%
\def\B@size #1#2]{\ifx I#24\else3\fi}% 4rows, 3columns
\def\B@entry #1#2{\the\numexpr #1-#2\relax}% not pre-computed...
\makeatother
\MatrixMultiplication\A\B\C \MatrixMultiplication\C\C\D
\MatrixMultiplication\C\D\E \MatrixMultiplication\C\E\F
\begin{multicols}2
  \[\begin{pmatrix}
    \A11&\A12&\A13&\A14\\
    \A21&\A22&\A23&\A24\\
    \A31&\A32&\A33&\A34
  \end{pmatrix}
  \times
  \begin{pmatrix}
    \B11&\B12&\B13\\
    \B21&\B22&\B23\\
    \B31&\B32&\B33\\
    \B41&\B42&\B43
  \end{pmatrix}
  =
  \begin{pmatrix}
    \C11&\C12&\C13\\
    \C21&\C22&\C23\\
    \C31&\C32&\C33
  \end{pmatrix}\]
  \[\begin{pmatrix}
    \C11&\C12&\C13\\
    \C21&\C22&\C23\\
    \C31&\C32&\C33
  \end{pmatrix}^2 = \begin{pmatrix}
    \D11&\D12&\D13\\
    \D21&\D22&\D23\\
    \D31&\D32&\D33
  \end{pmatrix}\]
  \[\begin{pmatrix}
    \C11&\C12&\C13\\
    \C21&\C22&\C23\\
    \C31&\C32&\C33
  \end{pmatrix}^3 = \begin{pmatrix}
    \E11&\E12&\E13\\
    \E21&\E22&\E23\\
    \E31&\E32&\E33
  \end{pmatrix}\]
  \[\begin{pmatrix}
    \C11&\C12&\C13\\
    \C21&\C22&\C23\\
    \C31&\C32&\C33
  \end{pmatrix}^4 = \begin{pmatrix}
    \F11&\F12&\F13\\
    \F21&\F22&\F23\\
    \F31&\F32&\F33
  \end{pmatrix}\]
\end{multicols}
\end{everbatim*}


\subsection{\csh{xintiloop}, \csh{xintiloopindex}, \csh{xintouteriloopindex},
  \csh{xintbreakiloop}, \csh{xintbreakiloopanddo}, \csh{xintiloopskiptonext},
\csh{xintiloopskipandredo}}
\label{xintiloop}
\label{xintbreakiloop}
\label{xintbreakiloopanddo}
\label{xintiloopskiptonext}
\label{xintiloopskipandredo}
\label{xintiloopindex}
\label{xintouteriloopindex}

\csa{xintiloop}|[start+delta]|\meta{stuff}|\if<test> ... \repeat|\xtype{} is a
completely expandable nestable loop. complete expandability depends naturally on
the actual iterated contents, and complete expansion will not be achievable
under a sole \fexpan sion, as is indicated by the hollow star in the margin;
thus the loop can be used inside an |\edef| but not inside arguments to the
package macros. It can be used inside an |\xintexpr..\relax|. The
|[start+delta]| is mandatory, not optional.

This loop benefits via \csbxint{iloopindex} to (a limited access to) the integer
index of the iteration. The starting value |start| (which may be a |\count|) and
increment |delta| (\emph{id.}) are mandatory arguments. A space after the
closing square bracket is not significant, it will be ignored. Spaces inside the
square brackets will also be ignored as the two arguments are first given to a
|\numexpr...\relax|. Empty lines and explicit |\par| tokens are accepted.

As with \csbxint{loop}, this tool will mostly be of interest to advanced users.
For nesting, one puts inside braces all the
material from the start (immediately after |[start+delta]|) and up to and
inclusive of the inner loop, these braces will be removed and do not create a
loop. In case of nesting, \csbxint{outeriloopindex} gives access to the index of
the outer loop. If needed one could write on its model a macro giving access to
the index of the outer outer loop (or even to the |nth| outer loop).

The \csa{xintiloopindex} and \csa{xintouteriloopindex} can not be used inside
braces, and generally speaking this means they should be expanded first when
given as argument to a macro, and that this macro receives them as delimited
arguments, not braced ones. Or, but naturally this will break expandability, one
can assign the value of \csa{xintiloopindex} to some |\count|. Both
\csa{xintiloopindex} and \csa{xintouteriloopindex} extend to the litteral
representation of the index, thus in |\ifnum| tests, if it comes last one has to
correctly end the macro with a |\space|, or encapsulate it in a
|\numexpr..\relax|.

When the repeat-test of the loop is, for example, |\ifnum\xintiloopindex<10
\repeat|, this means that the last iteration will be with |\xintiloopindex=10|
(assuming |delta=1|). There is also |\ifnum\xintiloopindex=10 \else\repeat| to
get the last iteration to be the one with |\xintiloopindex=10|.

One has \csbxint{breakiloop} and \csbxint{breakiloopanddo} to abort the loop.
The syntax of |\xintbreakiloopanddo| is a bit surprising, the sequence of tokens
to be executed after breaking the loop is not within braces but is delimited by
a dot as in:
%
\leftedline{|\xintbreakiloopanddo <afterloop>.etc.. etc... \repeat|}
%
The reason is that one may wish to use the then current value of
|\xintiloopindex| in |<afterloop>| but it can't be within braces at the time it
is evaluated. However, it is not that easy as |\xintiloopindex| must be expanded
before, so one ends up with code like this:
%
\leftedline
{|\expandafter\xintbreakiloopanddo\expandafter\macro\xintiloopindex.%|}
%
\leftedline{|etc.. etc.. \repeat|}
%
As moreover the |\fi| from the test leading to the decision of breaking out of
the loop must be cleared out of the way, the above should be
a branch of an expandable conditional test, else one needs something such
as:
%
\leftedline
{|\xint_afterfi{\expandafter\xintbreakiloopanddo\expandafter\macro\xintiloopindex.}%|}
%
\leftedline{|\fi etc..etc.. \repeat|}

There is \csbxint{iloopskiptonext} to abort the current iteration and skip to
the next, \hyperref[xintiloopskipandredo]{\ttfamily\hyphenchar\font45 \char92
  xintiloopskip\-and\-redo} to skip to the end of the current iteration and redo
it with the same value of the index (something else will have to change for this
not to become an eternal loop\dots ).

Inside alignments, if the looped-over text contains a |&| or a |\cr|, any
un-expandable material before a \csbxint{iloopindex} will make it fail because
of |\endtemplate|; in such cases one can always either replace |&| by a macro
expanding to it or replace it by a suitable |\firstofone{&}|, and similarly for
|\cr|.

\phantomsection\label{edefprimes}
As an example, let us construct an |\edef\z{...}| which will define |\z| to be a
list of prime numbers:
\begin{everbatim*}
\begingroup
\edef\z
{\xintiloop [10001+2]
  {\xintiloop [3+2]
   \ifnum\xintouteriloopindex<\numexpr\xintiloopindex*\xintiloopindex\relax
          \xintouteriloopindex,
          \expandafter\xintbreakiloop
   \fi
   \ifnum\xintouteriloopindex=\numexpr
        (\xintouteriloopindex/\xintiloopindex)*\xintiloopindex\relax
   \else
   \repeat
  }% no space here
 \ifnum \xintiloopindex < 10999 \repeat }%
\meaning\z\endgroup
\end{everbatim*}and we should have taken
some steps to not have a trailing comma, but
the point was to show that one can do that in an |\edef|\,! See also
\autoref{ssec:primesII} which extracts from this code its way of testing
primality.

Let us create an alignment where each row will contain all divisors of its
first entry.
Here is the output, thus obtained without any count register:
\begin{everbatim*}
\begin{multicols}2
\tabskip1ex \normalcolor
\halign{&\hfil#\hfil\cr
    \xintiloop [1+1]
    {\expandafter\bfseries\xintiloopindex &
     \xintiloop [1+1]
     \ifnum\xintouteriloopindex=\numexpr
           (\xintouteriloopindex/\xintiloopindex)*\xintiloopindex\relax
     \xintiloopindex&\fi
     \ifnum\xintiloopindex<\xintouteriloopindex\space % CRUCIAL \space HERE
     \repeat \cr }%
    \ifnum\xintiloopindex<30
    \repeat
}
\end{multicols}
\end{everbatim*}
We wanted this first entry in bold face, but |\bfseries| leads to
unexpandable tokens, so the |\expandafter| was necessary for |\xintiloopindex|
and |\xintouteriloopindex| not to be confronted with a hard to digest
|\endtemplate|. An alternative way of coding:
%
\begin{everbatim}
\tabskip1ex
\def\firstofone #1{#1}%
\halign{&\hfil#\hfil\cr
  \xintiloop [1+1]
    {\bfseries\xintiloopindex\firstofone{&}%
    \xintiloop [1+1] \ifnum\xintouteriloopindex=\numexpr
    (\xintouteriloopindex/\xintiloopindex)*\xintiloopindex\relax
    \xintiloopindex\firstofone{&}\fi
    \ifnum\xintiloopindex<\xintouteriloopindex\space % \space is CRUCIAL
    \repeat \firstofone{\cr}}%
  \ifnum\xintiloopindex<30 \repeat }
\end{everbatim}

\begin{framed}
  The next utilities are not compatible with expansion-only context.
\end{framed}

\subsection{\csh{xintApplyInline}}\label{xintApplyInline}


\csa{xintApplyInline}|{\macro}|\marg{list}\ntype{o{\lowast f}} works non
expandably. It applies the one-parameter |\macro| to the first element of the
expanded list (|\macro| may have itself some arguments, the list item will be
appended as last argument), and is then re-inserted in the input stream after
the tokens resulting from this first expansion of |\macro|. The next item is
then handled.

This is to be used in situations where one needs to do some repetitive
things. It is not expandable and can not be completely expanded inside a
macro definition, to prepare material for later execution, contrarily to what
\csbxint{Apply} or \csbxint{ApplyUnbraced} achieve.

\begin{everbatim*}
\def\Macro #1{\advance\cnta #1 , \the\cnta}
\cnta 0
0\xintApplyInline\Macro {3141592653}.
\end{everbatim*}
The first argument |\macro| does not have to be an expandable macro.

\csa{xintApplyInline} submits its second, token list parameter to an
\hyperref[ssec:expansions]{\fexpan
sion}. Then, each \emph{unbraced} item will also be \fexpan ded. This provides
an easy way to insert one list inside another. \emph{Braced} items are not
expanded. Spaces in-between items are gobbled (as well as those at the start
or the end of the list), but not the spaces \emph{inside} the braced items.

\csa{xintApplyInline}, despite being non-expandable, does survive to
contexts where the executed |\macro| closes groups, as happens inside
alignments with the tabulation character |&|.
This tabular provides an example:\par
\begin{everbatim*}
\centerline{\normalcolor\begin{tabular}{ccc}
     $N$ & $N^2$ & $N^3$ \\ \hline
     \def\Row #1{ #1 & \xintiiSqr {#1} & \xintiiPow {#1}{3} \\ \hline }%
     \xintApplyInline \Row {\xintCSVtoList{17,28,39,50,61}}
\end{tabular}}\medskip
\end{everbatim*}

We see that despite the fact that the first encountered tabulation character in
the first row close a group and thus erases |\Row| from \TeX's memory,
|\xintApplyInline| knows how to deal with this.

Using \csbxint{ApplyUnbraced} is an alternative: the difference is that
this would have prepared all rows first and only put them back into the
token stream once they are all assembled, whereas with |\xintApplyInline|
each row is constructed and immediately fed back into the token stream: when
one does things with numbers having hundreds of digits, one learns that
keeping on hold and shuffling around hundreds of tokens has an impact on
\TeX{}'s speed (make this ``thousands of tokens'' for the impact to be
noticeable).

One may nest various |\xintApplyInline|'s. For example (see the
\hyperref[float]{table} \vpageref{float}):\par
\begin{everbatim*}
\begin{figure*}[ht!]
  \centering\phantomsection\label{float}
  \def\Row #1{#1:\xintApplyInline {\Item {#1}}{0123456789}\\ }%
  \def\Item #1#2{&\xintiiPow {#1}{#2}}%
  \centeredline {\begin{tabular}{ccccccccccc} &0&1&2&3&4&5&6&7&8&9\\ \hline
      \xintApplyInline \Row {0123456789}
    \end{tabular}}
\end{figure*}
\end{everbatim*}

One could not move the definition of |\Item| inside the tabular,
as it would get lost after the first |&|. But this
works:
\everb|@
\begin{tabular}{ccccccccccc}
    &0&1&2&3&4&5&6&7&8&9\\ \hline
    \def\Row #1{#1:\xintApplyInline {&\xintiiPow {#1}}{0123456789}\\ }%
    \xintApplyInline \Row {0123456789}
\end{tabular}
|

A limitation is that, contrarily to what one may have expected, the
|\macro| for an |\xintApplyInline| can not be used to define
the |\macro| for a nested sub-|\xintApplyInline|. For example,
this does not work:\par
\everb|@
  \def\Row #1{#1:\def\Item ##1{&\xintiiPow {#1}{##1}}%
                 \xintApplyInline \Item {0123456789}\\ }%
  \xintApplyInline \Row {0123456789} % does not work
|
\noindent But see \csbxint{For}.

\subsection{\csh{xintFor}, \csh{xintFor*}}\label{xintFor}\label{xintFor*}

\csbxint{For}\ntype{on} is a new kind of for loop.\footnote{first introduced
  with \xintname |1.09c| of |2013/10/09|.} Rather than using macros
for encapsulating list items, its behaviour is like a macro with parameters:
|#1|, |#2|, \dots, |#9| are used to represent the items for up to nine levels of
nested loops. Here is an example:
%
\everb|@
\xintFor #9 in {1,2,3} \do {%
  \xintFor #1 in {4,5,6} \do {%
    \xintFor #3 in {7,8,9} \do {%
      \xintFor #2 in {10,11,12} \do {%
      $$#9\times#1\times#3\times#2=\xintiiPrd{{#1}{#2}{#3}{#9}}$$}}}}
|
\noindent This example illustrates that one does not have to use |#1| as the
first one:
the order is arbitrary. But each level of nesting should have its specific macro
parameter. Nine levels of nesting is presumably overkill, but I did not know
where it was reasonable to stop. |\par| tokens are accepted in both the comma
separated list and the replacement text.

\begin{framed}
  \TeX nical notes:

\begin{itemize}
  \item The |#1| is replaced in the iterated-over text exactly as in general
    \TeX\ macros or \LaTeX\ commands. This spares the user quite a few
    |\expandafter|'s or other tricks needed with loops which have the
    values encapsulated in macros, like \LaTeX's |\@for| and |\@tfor|.

  \item \csa{xintFor} (and \csa{xintFor*}) isn't purely expandable: one can
    not use it inside an |\edef|. But it may be used, as will be shown in
    examples, in some contexts such as \LaTeX's |tabular| which are usually
    hostile to non-expandable loops.
  
  \item \csa{xintFor} (and \csa{xintFor*}) does some assignments prior to
    executing each iteration of the replacement text, but it acts purely
    expandably after the last iteration, hence if for example the replacement
    text ends with a |\\|, the loop can be used insided a tabular and be
    followed by a |\hline| without creating the dreaded ``|Misplaced
    \noalign|'' error.

  \item As stated in previous item the first iteration follows some
    non-expandable internal dealings. This means for example that in \LaTeX{},
    one can not inject a |\multicolumn| in the first iteration. Sometimes one
    way work around this by injecting father |&\multicolumn| or |\\
    \multicolumn|.

  \item It does not create groups.

  \item It makes no global assignments.

  \item The iterated replacement text may close a group which was opened even
    before the start of the loop (typical example being with |&| in
    alignments).
\begin{everbatim*}
\begin{tabular}{rccccc}
    \hline
    \xintFor #1 in {A, B, C} \do {%
      #1:\xintFor #2 in {a, b, c, d, e} \do {&($ #2 \to #1 $)}\\ }%
    \hline
\end{tabular}
\end{everbatim*}
  
  \item There is no facility provided which would give access to a count of
    the number of iterations as it is technically not easy to do so it in a
    way working with nested loops while maintaining the ``expandable after
    done'' property; something in the spirit of \csbxint{iloopindex} is
    possible but this approach would bring its own limitations and
    complications. Hence the user is invited to update her own count or
    \LaTeX{} counter or macro at each iteration, if needed.

  \item A |\macro| whose definition uses internally an \csbxint{For} loop
    may be used inside another \csbxint{For} loop even if the two loops both
    use the same macro parameter. The loop definition inside |\macro|
    must use |##| as is the general rule for definitions done inside macros.

  \item \csbxint{For} is for comma separated values and \csbxint{For*} for
    lists of braced items; their respective expansion policies differ. They
    are described later.
\end{itemize}
\unskip
\end{framed}

\noindent Regarding \csbxint{For}:
\begin{itemize}[nosep, listparindent=\leftmarginiii]
\item the spaces between the various declarative elements are all optional,
\item in the list of comma separated values,  spaces around the commas or at
  the start and end are ignored,
\item if an item must contain itself its own commas, then it should
  be braced, and the braces will be removed before feeding the iterated-over
  text,
\item the list may be a macro, it is expanded only once,
\item items are not pre-expanded. The first item should be braced or start
  with a space if the list is explicit and the item should not be
  pre-expanded,
\item empty items give empty |#1|'s in the replacement text, they are not
  skipped,
\item an empty list executes once the replacement text with an empty parameter
  value,
\item the list, if not a macro, \fbox{must be braced.}
\end{itemize}

\noindent Regarding \csbxint{For*}:\ntype{{\lowast f}n}
\begin{itemize}[nosep, listparindent=\leftmarginiii]
\item it handles lists of braced items (or naked tokens),
\item it \hyperref[ssec:expansions]{\fexpan ds} the list,
\item and more generally it \hyperref[ssec:expansions]{\fexpan ds} each naked
  token encountered 
  before assigning the |#1| values (gobbling spaces in the process);
  this
  makes it easy to simulate concatenation of multiple lists|\x|, |\y|:
  if |\x| expands to |{1}{2}{3}| and |\y| expands to |{4}{5}{6}| then |{\x\y}|
  as argument to |\xintFor*| has the same effect as |{{1}{2}{3}{4}{5}{6}}|.

  For a further illustration see the use of |\xintFor*| at the end of
  \autoref{ssec:fibonacci}.
\item spaces at the start, end, or in-between items are gobbled (but naturally
  not the spaces inside \emph{braced} items),
\item except if the list argument is a macro (with no parameters), \fbox{it
    must be braced.},
\item an empty list leads to an empty result.
\end{itemize}

The macro \csbxint{Seq} which generates arithmetic sequences is to be used
with \csbxint{For*} as its output consists of successive braced numbers (given
as digit tokens).
\begin{everbatim*}
\xintFor* #1 in {\xintSeq [+2]{-7}{+2}}\do {stuff
    with #1\xintifForLast{\par}{\newline}}
\end{everbatim*}


When nesting \csa{xintFor*} loops, using \csa{xintSeq} in the inner loops is
inefficient, as the arithmetic sequence will be re-created each time. A more
efficient style is:
%
\begin{everbatim}
    \edef\innersequence {\xintSeq[+2]{-50}{50}}%
    \xintFor* #1 in {\xintSeq {13}{27}} \do
        {\xintFor* #2 in \innersequence \do {stuff with #1 and #2}%
         .. some other macros .. }
\end{everbatim}

This is a general remark applying for any nesting of loops, one should avoid
recreating the inner lists of arguments at each iteration of the outer loop.


When the loop is defined inside a macro for later execution the |#| characters
must be doubled.%
%
\footnote{sometimes what seems to be a macro argument isn't really; in
  \csa{raisebox\{1cm\}\{}\csa{xintFor \#1 in \{a,b,c\} }\csa{do
    \{\#1\}\}} no doubling should be done.}
%
For example:
%
\begin{everbatim*}
\def\T{\def\z {}%
  \xintFor* ##1 in {{u}{v}{w}} \do {%
    \xintFor ##2 in {x,y,z} \do {%
      \expandafter\def\expandafter\z\expandafter {\z\sep (##1,##2)} }%
  }%
}%
\T\def\sep {\def\sep{, }}\z
\end{everbatim*}

Similarly when the replacement text
of |\xintFor| defines a macro with parameters, the macro character |#| must be
doubled.


The iterated macros as well as the list items are allowed to contain explicit
|\par| tokens.


\subsection{\csh{xintifForFirst}, \csh{xintifForLast}}
\label{xintifForFirst}\label{xintifForLast}

\csbxint{ifForFirst}\,\texttt{\{YES branch\}\{NO branch\}}\etype{nn}
 and \csbxint{ifForLast}\,\texttt{\{YES
  branch\}\hskip 0pt plus 0.2em \{NO branch\}}\etype{nn} execute the |YES| or
|NO| branch
if the
\csbxint{For}
or \csbxint{For*} loop is currently in its first, respectively last, iteration.

Designed to work as expected under nesting (but see frame next.) Don't forget
an empty brace pair |{}| if a branch is to do nothing. May be used multiple
times in the replacement text of the loop.

\begin{framed}
  \noindent Pay attention to these implementation features:
  \begin{itemize}[nosep, listparindent=\leftmarginiii]
  \item \emph{if an inner \csbxint{For} loop is positioned before the
    \csb{xintifForFirst} or \csb{xintifForLast} of the outer loop it will
    contaminate their settings. This applies also naturally if the inner loop
    arises from the expansion of some macro located before the outer
    conditionals.}

    One fix is to make sure that the outer conditionals are expanded before the
    inner loop is executed, e.g. this will be the case if the inner loop is
    located inside one of the branches of the conditional.

    Another approach is to enclose, if feasible, the inner loop in a group of
    its own.
  \item \emph{if the replacement text closes a group (e.g. from a |&| inside an
    alignment), the conditionals will lose their ascribed meanings and end up
    possibly undefined, depending whether there is some outer loop whose
    execution started before the opening of the group.}

    The fix is to arrange things so that the conditionals are expanded
    before \TeX\ encounters the closing-group token.
  \end{itemize}
\end{framed}

\subsection{ \csh{xintBreakFor}, \csh{xintBreakForAndDo}}
\label{xintBreakFor}\label{xintBreakForAndDo}

One may immediately terminate an \csbxint{For} or \csbxint{For*} loop with
\csbxint{BreakFor}.

\begin{framed}
  As it acts by clearing up all the rest of the replacement text when
  encountered, it will not work from inside some |\if...\fi| without
  suitable |\expandafter| or swapping technique.

  Also it can't be used from inside braces as from there it can't see the end
  of the replacement text.
\end{framed}

There is also \csbxint{BreakForAndDo}. Both are illustrated by various examples
in the next section which is devoted to ``forever'' loops.

\subsection{\csh{xintintegers}, \csh{xintdimensions}, \csh{xintrationals}}
\label{xintegers}\label{xintintegers}
\label{xintdimensions}\label{xintrationals}

If the list argument to \csbxint{For} (or \csbxint{For*}, both are equivalent in
this context) is \csbxint{integers} (equivalently \csbxint{egers}) or more
generally \csbxint{integers}|[||start|\allowbreak|+|\allowbreak|delta||]|
(\emph{the whole within braces}!)%
%
\footnote{the |start+delta| optional specification may have extra spaces
  around the plus sign of near the square brackets, such spaces are
  removed. The same applies with \csa{xintdimensions} and
  \csa{xintrationals}.},
%
then \csbxint{For} does an infinite iteration where
|#1| (or |#2|, \dots, |#9|) will run through the arithmetic sequence of (short)
integers with initial value |start| and increment |delta| (default values:
|start=1|, |delta=1|; if the optional argument is present it must contains both
of them, and they may be explicit integers, or macros or count registers). The
|#1| (or |#2|, \dots, |#9|) will stand for |\numexpr <opt sign><digits>\relax|,
and the litteral representation as a string of digits can thus be obtained as
\fbox{\csa{the\#1}} or |\number#1|. Such a |#1| can be used in an |\ifnum| test
with no need to be postfixed with a space or a |\relax| and one should
\emph{not} add them.

If the list argument is \csbxint{dimensions} or more generally
\csbxint{dimensions}|[||start|\allowbreak|+|\allowbreak|delta||]|  (\emph{within
  braces}!), then
\csbxint{For} does an infinite iteration where |#1| (or |#2|, \dots, |#9|) will
run through the arithmetic sequence of dimensions with initial value
|start| and increment |delta|. Default values: |start=0pt|, |delta=1pt|; if
the optional argument is present it must contain both of them, and they may
be explicit specifications, or macros, or dimen registers, or length macros
in \LaTeX{} (the stretch and shrink components will be discarded). The |#1|
will be |\dimexpr <opt sign><digits>sp\relax|, from which one can get the
litteral (approximate) representation in points via |\the#1|. So |#1| can be
used anywhere \TeX{} expects a dimension (and there is no need in conditionals
to insert a |\relax|, and one should \emph{not} do it), and to print its value
one uses \fbox{\csa{the\#1}}. The chosen representation guarantees exact
incrementation with no rounding errors accumulating from converting into
points at each step.






If the list argument to \csbxint{For} (or \csbxint{For*}) is \csbxint{rationals}
or more generally
\csbxint{rationals}|[||start|\allowbreak|+|\allowbreak|delta||]| (\emph{within
  braces}!), then \csbxint{For} does an infinite iteration where |#1| (or |#2|,
\dots, |#9|) will run through the arithmetic sequence of \xintfracname fractions
with initial value |start| and increment |delta| (default values: |start=1/1|,
|delta=1/1|). This loop works \emph{only with \xintfracname loaded}. if the
optional argument is present it must contain both of them, and they may be given
in any of the formats recognized by \xintfracname (fractions, decimal
numbers, numbers in scientific notations, numerators and denominators in
scientific notation, etc...) , or as macros or count registers (if they are
short integers). The |#1| (or |#2|, \dots, |#9|) will be an |a/b| fraction
(without a |[n]| part), where
the denominator |b| is the product of the denominators of
|start| and |delta| (for reasons of speed |#1| is not reduced to irreducible
form, and for another reason explained later  |start| and |delta| are not put
either into irreducible form; the input may use explicitely \csa{xintIrr} to
achieve that).
\begin{everbatim*}
\begingroup\small
\noindent\parbox{\dimexpr\linewidth-3em}{\color[named]{OrangeRed}%
\xintFor #1 in {\xintrationals [10/21+1/21]} \do
{#1=\xintifInt {#1}
    {\textcolor{blue}{\xintTrunc{10}{#1}}}
    {\xintTrunc{10}{#1}}% display in blue if an integer
    \xintifGt {#1}{1.123}{\xintBreakFor}{, }%
  }}
\endgroup\smallskip
\end{everbatim*}

\smallskip The example above confirms that computations are done exactly, and
illustrates that the two initial (reduced) denominators are not multiplied when
they are found to be equal.  It is thus recommended to input |start| and |delta|
with a common smallest possible denominator, or as fixed point numbers with the
same numbers of digits after the decimal mark;  and this is also the reason why
|start| and |delta| are not by default made irreducible. As internally the
computations are done with numerators and denominators completely expanded, one
should be careful not to input numbers in scientific notation with exponents in
the hundreds, as they will get converted into as many zeroes.

\begin{everbatim*}
\noindent\parbox{\dimexpr.7\linewidth}{\raggedright
\xintFor #1 in {\xintrationals [0.000+0.125]} \do
{\edef\tmp{\xintTrunc{3}{#1}}%
 \xintifInt {#1}
    {\textcolor{blue}{\tmp}}
    {\tmp}%
    \xintifGt {#1}{2}{\xintBreakFor}{, }%
  }}\smallskip
\end{everbatim*}

We see here that \csbxint{Trunc} outputs (deliberately) zero as $0$, not (here)
$0.000$, the idea being not to lose the information that the truncated thing was
truly zero. Perhaps this behaviour should be changed? or made optional? Anyhow
printing of fixed points numbers should be dealt with via dedicated packages
such as |numprint| or |siunitx|.\par


\subsection{\csh{xintForpair}, \csh{xintForthree}, \csh{xintForfour}}\label{xintForpair}\label{xintForthree}\label{xintForfour}

The syntax\ntype{on} is illustrated in this
example. The notation is the usual one for |n|-uples, with parentheses and
commas. Spaces around commas and parentheses are ignored.
%
\begin{everbatim*}
{\centering\begin{tabular}{cccc}
    \xintForpair #1#2 in { ( A , a ) , ( B , b ) , ( C , c ) } \do {%
      \xintForpair #3#4 in { ( X , x ) , ( Y , y ) , ( Z , z ) } \do {%
        $\Biggl($\begin{tabular}{cc}
          -#1- & -#3-\\
          -#4- & -#2-\\
        \end{tabular}$\Biggr)$&}\\\noalign{\vskip1\jot}}%
\end{tabular}\\}
\end{everbatim*}

\csbxint{Forpair} must be followed by either |#1#2|, |#2#3|, |#3#4|, \dots, or
|#8#9| with |#1| usable as an alias for |#1#2|, |#2| as alias for |#2#3|,
etc \dots\ and similarly for \csbxint{Forthree} (using |#1#2#3| or simply
|#1|, |#2#3#4| or simply |#2|, \dots) and \csbxint{Forfour} (with |#1#2#3#4|
etc\dots).

Nesting works as long as the macro parameters are distinct among |#1|, |#2|,
..., |#9|. A macro which expands to an \csa{xintFor} or a
\csa{xintFor(pair,three,four)} can be used in another one with no constraint
about using distinct macro parameters.

|\par| tokens are accepted in both the comma separated list and the
replacement text.


\subsection{\csh{xintAssign}}\label{xintAssign}

\csa{xintAssign}\meta{braced things}\csa{to}%
\meta{as many cs as they are things} %\ntype{{(f$\to$\lowast [x)}{\lowast N}}
%
defines (without checking if something gets overwritten) the control sequences
on the right of \csa{to} to expand to the successive tokens or braced items
located to the left of \csa{to}. \csa{xintAssign} is not an expandable macro.

\fexpan sion is first applied to the material in front of \csa{xintAssign}
which is fetched as one argument if it is braced. Then the expansion of this
argument is examined and successive items are assigned to the macros following
|\to|. There must be exactly as many macros as items. No check is done. The
macro assignments are done with removal of one level of brace pairs from each
item.

After the initial \fexpan sion, each assigned (brace-stripped) item will be
expanded according to the setting of the optional parameter.

For example |\xintAssign [e]...| means that all assignments are done using
|\edef|. With |[f]| the assignments will be made using
\hyperref[fdef]{\ttfamily\char92fdef}. The default is simply to make the
definitions with |\def|, corresponding to an empty optional paramter |[]|.
Possibilities for the optional parameter are: |[], [g], [e], [x], [o], [go],
[oo], [goo], [f], [gf]|. For example |[oo]| means a double expansion.
\begin{everbatim*}
\xintAssign \xintiiDivision{1000000000000}{133333333}\to\Q\R
\meaning\Q\newline
\meaning\R\newline
\xintAssign {{\xintiiDivision{1000000000000}{133333333}}}\to\X
\meaning\X\newline
\xintAssign [oo]{{\xintiiDivision{1000000000000}{133333333}}}\to\X
\meaning\X\newline
\xintAssign \xintiiPow{7}{13}\to\SevenToThePowerThirteen
\meaning\SevenToThePowerThirteen\par
\end{everbatim*}

Two special cases:
\begin{itemize}[nosep]
\item if after this initial expansion no brace is found immediately after
  \csa{xintAssign}, it is assumed that there is only one control sequence
  following |\to|, and this control sequence is then defined via |\def| (or
  what is set-up by the optional parameter) to expand to the material between
  \csa{xintAssign} and \csa{to}.
\item if the material between \csa{xintAssign} and |\to| is enclosed in two
  brace pairs, the first brace pair is removed, then the \fexpan sion is
  immediately stopped by the inner brace pair, hence \csa{xintAssign} now
  finds a unique item and thus defines only a single macro to be this item,
  which is now stripped of the second pair of braces.
\end{itemize}


\emph{Note:} prior to release |1.09j|, |\xintAssign| did an |\edef| by default
for each item assignment but it now does |\def| corresponding to no or empty
optional parameter.

It is allowed for the successive braced items to be separated by spaces. They
are removed during the assignments. But if a single macro is defined (which
happens if the argument after \fexpan sion does not start with a brace),
naturally the scooped up material has all intervening spaces, as it is
considered a
single item. But an upfront initial space will have been absorbed by \fexpan
sion.
\begin{everbatim*}
\def\X{ {a}  {b} {c}   {d} }\def\Y { u {a}  {b} {c}   {d} }
\xintAssign\X\to\A\B\C\D
\xintAssign\Y\to\Z
\meaning\A, \meaning\B, \meaning\C, \meaning\D+++\newline
\meaning\Z+++\par
\end{everbatim*}
As usual successive space characters in input make for a single \TeX\ space token.


\subsection{\csh{xintAssignArray}}\label{xintAssignArray}

\xintAssignArray \xintBezout {1000}{113}\to\Bez

\csa{xintAssignArray}\meta{braced things}\csa{to}\csa{myArray}
%
%\ntype{{(f$\to$\lowast x)}N}
%
first expands fully what comes immediately after |\xintAssignArray| and
expects to find a list of braced things |{A}{B}...| (or tokens). It then
defines \csa{myArray} as a macro with one parameter, such that \csa{myArray\x}
expands to give the |x|th braced thing of this original
list (the argument \texttt{\x} itself is fed to a |\numexpr| by |\myArray|,
and |\myArray| expands in two steps to its output). With |0| as parameter,
\csa{myArray}|{0}| returns the number |M| of elements of the array so that the
successive elements are \csa{myArray}|{1}|, \dots, \csa{myArray}|{M}|.
%
\leftedline{|\xintAssignArray \xintBezout {1000}{113}\to\Bez|} will set
|\Bez{0}| to \dtt{\Bez0}, |\Bez{1}| to \dtt{\Bez1}, |\Bez{2}| to
\dtt{\Bez2}, and |\Bez{3}| to \dtt{\Bez3}:
\dtt{$\Bez1\times1000+\Bez2\times113=\Bez3$.}
This macro is incompatible with expansion-only contexts.

\csa{xintAssignArray} admits an optional parameter, for example
|\xintAssignArray [e]| means that the definitions of the macros will be made
with |\edef|. The empty optional parameter (default) means that definitions
are done with |\def|. Other possibilities: |[], [o], [oo], [f]|. Contrarily to
\csbxint{Assign} one can not use the |g| here to make the definitions global.
For this, one should rather do |\xintAssignArray| within a group starting with
|\globaldefs 1|.


\subsection{\csh{xintDigitsOf}}\label{xintDigitsOf}

This is a synonym for \csbxint{AssignArray},\ntype{fN} to be used to define
an array giving all the digits of a given (positive, else the minus sign will
be treated as first item) number.
\begingroup\xintDigitsOf\xintiiPow {7}{500}\to\digits
%
\leftedline{|\xintDigitsOf\xintiiPow {7}{500}\to\digits|}
\noindent $7^{500}$ has |\digits{0}=|\digits{0} digits, and the 123rd among them
(starting from the most significant) is
|\digits{123}=|\digits{123}.
\endgroup

\subsection{\csh{xintRelaxArray}}\label{xintRelaxArray}

\csa{xintRelaxArray}\csa{myArray} %\ntype{N}
%
(globally) sets to \csa{relax} all macros which were defined by the previous
\csa{xintAssignArray} with \csa{myArray} as array macro.

\clearpage
\let\xinttoolsnameUp\undefined
\def\n{|{N}|}
\def\m{|{M}|}
\def\x{|{x}|}

\csname ExamplesnameUp\endcsname
\section {Additional (old) examples with \xinttoolsname or \xintexprname or both}
\RaisedLabel{sec:examples}

\localtableofcontents

\subsection{Introduction}

Note: \xintexprname.sty automatically loads \xinttoolsname.sty.

The examples given here start to feel dated and are currently in need of some
rewrite to better illustrate newer features of the package.

\subsection{More examples with dummy variables}
\label{ssec:moredummies}

These examples were first added to this manual at the time of the |1.1|
release (|2014/10/29|).

\begin{everbatim*}
Prime numbers are always cool
\xinttheiiexpr seq((seq((subs((x/:m)?{(m*m>x)?{1}{0}}{-1},m=2n+1))
                        ??{break(0)}{omit}{break(1)},n=1++))?{x}{omit},
               x=10001..[2]..10200)\relax
\end{everbatim*}

The syntax in this last example may look a bit involved (...\@{} and it is so I
admit). First |x/:m| computes |x modulo m| (this is the modulo with respect to
floored division). The |(x)?{yes}{no}| construct checks if |x| (which
\emph{must} be within parentheses) is true or false, i.e.\@{} non zero or zero. It
then executes either the |yes| or the |no| branch, the non chosen branch is
\emph{not} evaluated. Thus if |m| divides |x| we are in the second (``false'')
branch. This gives a |-1|. This |-1| is the argument to a |??| branch which is
of the type |(y)??{y<0}{y=0}{y>0}|, thus here the |y<0|, i.e.\@, |break(0)| is
chosen. This |0| is thus given to another |?| which consequently chooses
|omit|, hence the number is not kept in the list. The numbers which survive
are the prime numbers.

\begin{everbatim*}
The first Fibonacci number beyond |2^64|, |2^64|, and the index are respectively
\xinttheiiexpr subs(iterr(0,1;(@1>N)?{break(@1,N,i)}{@1+@2},i=1++),N=2^64)\relax.
\end{everbatim*}

% A006877 In the `3x+1' problem, these values for the starting value set new
% records for number of steps to reach 1. (Formerly M0748) 14 1, 2, 3, 6, 7,
% 9, 18, 25, 27, 54, 73, 97, 129, 171, 231, 313, 327, 649, 703, 871, 1161,
% 2223, 2463, 2919, 3711, 6171, 10971, 13255, 17647, 23529, 26623, 34239,
% 35655, 52527, 77031, 106239, 142587, 156159, 216367, 230631, 410011, 511935,
% 626331, 837799

One more recursion:
\begin{everbatim*}
\def\syr #1{\xinttheiiexpr
            rseq(#1; (@<=1)?{break(i)}{odd(@)?{3@+1}{@//2}},i=0++)\relax}
The 3x+1 problem: \syr{231}\par
\end{everbatim*}

OK, a final one:%
\begin{everbatim*}
\def\syrMax #1{\xintiiexpr iterr(#1,#1;even(i)?
                                       {(@2<=1)?{break(@1,i//2)}
                                                {odd(@2)?{3@2+1}{@2//2}}}
                                       {(@1>@2)?{@1}{@2}},i=0++)\relax }
With initial value 1161, the maximal intermediate value and the number of steps
needed to reach 1 are respectively \syrMax{1161}.\par
\end{everbatim*}

Look at the
  \hyperlink{BrentSalamin}{Brent-Salamin algorithm implementation} for a more
  interesting recursion.

% \begin{everbatim*}
% \newcommand\Factors [1]{\xinttheiiexpr
%     subs(seq((i/:3=1)?{omit}{[L][i]},i=0..len(L)-1),
%     L=rseq(#1;(p^2>[@][0])?{([@][0]>1)?{break(1,[@][0],1)}{abort}}
%                           {(([@][0])/:p)?{omit}
%     {iter(([@][0])//p; (@/:p)?{break(@,p,e)}{@//p},e=1++)}},p=2++))\relax }
% \Factors {41^4*59^2*29^3*13^5*17^8*29^2*59^4*37^6}
% \end{everbatim*}

% This might look a bit scary, I admit.%
% %
% \footnote{Look at the
%   \hyperlink{BrentSalamin}{Brent-Salamin algorithm implementation} for a much
%   saner example.} 
% %

% \xintexprname has minimal tools and
% is obstinate about doing everything expandably! We are hampered by absence of a
% notion of ``nuple''. The algorithm divides |N| by |2| until no more possible,
% then by |3|, then by |4| (which is silly), then by |5|, then by |6| (silly
% again), \dots.

% The variable |L=rseq(#1;...)| expands, if one follows the steps, to a comma
% separated list starting with the initial (evaluated) |N=#1| and then
% pseudo-triplets where the first item is |N| trimmed of small primes, the
% second item is the last prime divisor found, and the third item is its
% exponent in original |N|.

% The algorithm needs to keep handy the last computed quotient by prime powers,
% hence all of them, but at the very end it will be cleaner to get rid of them
% (this corresponds to the first line in the code above). This is achieved in a
% cumbersome inefficient way; indeed each item extraction |[L][i]| is costly: it
% is not like accessing an array stored in memory, due to expandability, nothing
% can be stored in memory! Nevertheless, this step could be done here in a far
% less inefficient manner if there was a variant of |seq| which, in the spirit
% of \csbxint{iloopindex}, would know how many steps it had been through so far.
% This is a feature to be added to |\xintexpr|! (as well as a |++| construct
% allowing a non unit step).

% Notice that in |iter(([@][0])//p;| the |@| refers to the previous triplet (or
% in the first step to |N|), but the latter |@| showing up in |(@/:p)?| refers
% to the previous value computed by |iter|.

% \begin{snugframed}
%   Parentheses are essential in |..([y][0])| else the parser will see |..[| and
%   end up in ultimate confusion, and also in |([@][0])/:p| else the parser will
%   see the itemwise operator |]/| on lists and again be very confused (I could
%   implement a |]/:| on lists, but in this situation this would also be very
%   confusing to the parser.)
% \end{snugframed}

% See \autoref{ssec:factorize} for a routine |\Factorize| written directly with
% \xintname macros. Last time I checked |\Factors| was about seven times slower
% than |\Factorize| in test cases such as
% |16246355912554185673266068721806243461403654781833| and others. Among the
% various things explaining the speed difference, there is fact that the
% |\Factorize| algorithm step by increments of two, not one, and also it divides
% only once, obtaining quotient and remainder in one go. These two things
% already make for a speed-up factor of about four. Thus, |\Factors| is not
% completely inefficient in comparison, and was quite easier to come up with
% than |\Factorize|.

\subsection{Completely expandable prime test}
\label{ssec:primesI}

Let us now construct a completely expandable macro which returns $1$ if its
given input is prime and $0$ if not:
\everb|@
\def\remainder #1#2{\the\numexpr #1-(#1/#2)*#2\relax }
\def\IsPrime #1%
 {\xintANDof {\xintApply {\remainder {#1}}{\xintSeq {2}{\xintiiSqrt{#1}}}}}
|

This uses \csbxint{iiSqrt} and assumes its input is at least $5$. Rather than
\xintname's own \csbxint{iiRem} we used a quicker |\numexpr| expression as we
are dealing with short integers. Also we used \csbxint{ANDof} which will
return $1$ only if all the items are non-zero. The macro is a bit
silly with an even input, ok, let's enhance it to detect an even input:
\everb|@
\def\IsPrime #1%
   {\xintiiifOdd {#1}
        {\xintANDof % odd case
            {\xintApply {\remainder {#1}}
                        {\xintSeq [2]{3}{\xintiiSqrt{#1}}}%
            }%
        }
        {\xintifEq {#1}{2}{1}{0}}%
   }
|

We used the \xintname expandable tests (on big integers or fractions)
in order for |\IsPrime| to be \fexpan dable.

Our integers are short, but without |\expandafter|'s with
|\@firstoftwo|, % @ n'est plus actif dans le dtx 1.1 !
or some other related techniques,
direct use of |\ifnum..\fi| tests is dangerous. So to make the macro more
efficient we are going to use the expandable tests provided by the package
\href{http://ctan.org/pkg/etoolbox}{etoolbox}%
%
\footnote{\url{http://ctan.org/pkg/etoolbox}}.
%
The macro becomes:
%
\everb|@
\def\IsPrime #1%
   {\ifnumodd {#1}
    {\xintANDof % odd case
     {\xintApply {\remainder {#1}}{\xintSeq [2]{3}{\xintiiSqrt{#1}}}}}
    {\ifnumequal {#1}{2}{1}{0}}}
|

In the odd case however we have to assume the integer is at least $7$, as
|\xintSeq| generates an empty list if |#1=3| or |5|, and |\xintANDof| returns
$1$ when supplied an empty list. Let us ease up a bit |\xintANDof|'s work by
letting it work on only $0$'s and $1$'s. We could use:
%
\everb|@
\def\IsNotDivisibleBy #1#2%
  {\ifnum\numexpr #1-(#1/#2)*#2=0 \expandafter 0\else \expandafter1\fi}
|
\noindent
where the |\expandafter|'s are crucial for this macro to be \fexpan dable and
hence work within the applied \csbxint{ANDof}. Anyhow, now that we have loaded
\href{http://ctan.org/pkg/etoolbox}{etoolbox}, we might as well use:
%
\everb|@
\newcommand{\IsNotDivisibleBy}[2]{\ifnumequal{#1-(#1/#2)*#2}{0}{0}{1}}
|
\noindent
Let us enhance our prime macro to work also on the small primes:
\everb|@
\newcommand{\IsPrime}[1] % returns 1 if #1 is prime, and 0 if not
  {\ifnumodd {#1}
    {\ifnumless {#1}{8}
      {\ifnumequal{#1}{1}{0}{1}}% 3,5,7 are primes
      {\xintANDof
         {\xintApply
        { \IsNotDivisibleBy {#1}}{\xintSeq [2]{3}{\xintiiSqrt{#1}}}}%
        }}% END OF THE ODD BRANCH
    {\ifnumequal {#1}{2}{1}{0}}% EVEN BRANCH
}
|

The input is still assumed positive. There is a deliberate blank before
\csa{IsNotDivisibleBy} to use this feature of \csbxint{Apply}: a space stops the
expansion of the applied macro (and disappears). This expansion will be done by
\csbxint{ANDof}, which has been designed to skip everything as soon as it finds
a false (i.e.\@{} zero) input. This way, the efficiency is considerably improved.

We did generate via the \csbxint{Seq} too many potential divisors though. Later
sections give two variants: one with \csbxint{iloop} (\autoref{ssec:primesII})
which is still expandable and another one (\autoref{ssec:primesIII}) which is a
close variant of the |\IsPrime| code above but with the \csbxint{For} loop, thus
breaking expandability. The \hyperref[ssec:primesII]{xintiloop variant} does not
first evaluate the integer square root, the \hyperref[ssec:primesIII]{xintFor
  variant} still does. I did not compare their efficiencies.


Let us construct with this expandable primality test a table of the prime
numbers up to $1000$. We need to count how many we have in order to know how
many tab stops one shoud add in the last row.%
%
\footnote{although a tabular row may have less tabs than in the
  preamble, there is a problem with the \char`\|\space\space vertical
  rule, if one does that.}
%
There is some subtlety for this
last row. Turns out to be better to insert a |\\| only when we know for sure we
are starting a new row; this is how we have designed the |\OneCell| macro. And
for the last row, there are many ways, we use again |\xintApplyUnbraced| but
with a macro which gobbles its argument and replaces it with a tabulation
character. The \csbxint{For*} macro would be more elegant here.
%
\everb?@
\newcounter{primecount}
\newcounter{cellcount}
\newcommand{\NbOfColumns}{13}
\newcommand{\OneCell}[1]{%
    \ifnumequal{\IsPrime{#1}}{1}
     {\stepcounter{primecount}
      \ifnumequal{\value{cellcount}}{\NbOfColumns}
       {\\\setcounter{cellcount}{1}#1}
       {&\stepcounter{cellcount}#1}%
     } % was prime
  {}% not a prime, nothing to do
}
\newcommand{\OneTab}[1]{&}
\begin{tabular}{|*{\NbOfColumns}{r}|}
\hline
2  \setcounter{cellcount}{1}\setcounter{primecount}{1}%
   \xintApplyUnbraced \OneCell {\xintSeq [2]{3}{999}}%
   \xintApplyUnbraced \OneTab
      {\xintSeq [1]{1}{\the\numexpr\NbOfColumns-\value{cellcount}\relax}}%
    \\
\hline
\end{tabular}
There are \arabic{primecount} prime numbers up to 1000.
?

The table has been put in \hyperref[primesupto1000]{float} which appears
\vpageref{primesupto1000}.
We had to be careful to use in the last row \csbxint{Seq} with its optional
argument |[1]| so as to not generate a decreasing sequence from |1| to |0|, but
really an empty sequence in case the row turns out to already have all its
cells (which doesn't happen here but would with a number of columns dividing
$168$).
%
\newcommand{\IsNotDivisibleBy}[2]{\ifnumequal{#1-(#1/#2)*#2}{0}{0}{1}}

\newcommand{\IsPrime}[1]
   {\ifnumodd {#1}
        {\ifnumless {#1}{8}
          {\ifnumequal{#1}{1}{0}{1}}% 3,5,7 are primes
          {\xintANDof
             {\xintApply
                { \IsNotDivisibleBy {#1}}{\xintSeq [2]{3}{\xintiiSqrt{#1}}}}%
            }}% END OF THE ODD BRANCH
        {\ifnumequal {#1}{2}{1}{0}}% EVEN BRANCH
}

\newcounter{primecount}
\newcounter{cellcount}
\newcommand{\NbOfColumns}{13}
\newcommand{\OneCell}[1]
     {\ifnumequal{\IsPrime{#1}}{1}
        {\stepcounter{primecount}
         \ifnumequal{\value{cellcount}}{\NbOfColumns}
            {\\\setcounter{cellcount}{1}#1}
            {&\stepcounter{cellcount}#1}%
        } % was prime
        {}% not a prime nothing to do
}
\newcommand{\OneTab}[1]{&}
\begin{figure*}[ht!]
  \centering
  \phantomsection\label{primesupto1000}
  \begin{tabular}{|*{\NbOfColumns}{r}|}
    \hline
    2\setcounter{cellcount}{1}\setcounter{primecount}{1}%
    \xintApplyUnbraced \OneCell {\xintSeq [2]{3}{999}}%
    \xintApplyUnbraced \OneTab
    {\xintSeq [1]{1}{\the\numexpr\NbOfColumns-\value{cellcount}\relax}}%
    \\
    \hline
  \end{tabular}
\smallskip
\centeredline{There are \arabic{primecount} prime numbers up to 1000.}
\end{figure*}

\subsection{Another completely expandable prime test}
\label{ssec:primesII}

The |\IsPrime| macro from \autoref{ssec:primesI} checked expandably if a (short)
integer was prime, here is a partial rewrite using \csbxint{iloop}. We use the
|etoolbox| expandable conditionals for convenience, but not everywhere as
|\xintiloopindex| can not be evaluated while being braced. This is also the
reason why |\xintbreakiloopanddo| is delimited, and the next macro
|\SmallestFactor| which returns the smallest prime factor examplifies that. One
could write more efficient completely expandable routines, the aim here was only
to illustrate use of the general purpose \csbxint{iloop}. A little table giving
the first values of |\SmallestFactor| follows, its coding uses \csbxint{For},
which is described later; none of this uses count registers.
%


\begin{everbatim*}
% clean up possible left-over mess from previous examples
\let\IsPrime\undefined \let\SmallestFactor\undefined
\newcommand{\IsPrime}[1] % returns 1 if #1 is prime, and 0 if not
  {\ifnumodd {#1}
    {\ifnumless {#1}{8}
      {\ifnumequal{#1}{1}{0}{1}}% 3,5,7 are primes
      {\if
       \xintiloop [3+2]
       \ifnum#1<\numexpr\xintiloopindex*\xintiloopindex\relax
           \expandafter\xintbreakiloopanddo\expandafter1\expandafter.%
       \fi
       \ifnum#1=\numexpr (#1/\xintiloopindex)*\xintiloopindex\relax
       \else
       \repeat 00\expandafter0\else\expandafter1\fi
      }%
    }% END OF THE ODD BRANCH
    {\ifnumequal {#1}{2}{1}{0}}% EVEN BRANCH
}%
\catcode`_ 11
\newcommand{\SmallestFactor}[1] % returns the smallest prime factor of #1>1
  {\ifnumodd {#1}
    {\ifnumless {#1}{8}
      {#1}% 3,5,7 are primes
      {\xintiloop [3+2]
       \ifnum#1<\numexpr\xintiloopindex*\xintiloopindex\relax
           \xint_afterfi{\xintbreakiloopanddo#1.}%
       \fi
       \ifnum#1=\numexpr (#1/\xintiloopindex)*\xintiloopindex\relax
           \xint_afterfi{\expandafter\xintbreakiloopanddo\xintiloopindex.}%
       \fi
       \iftrue\repeat
      }%
     }% END OF THE ODD BRANCH
   {2}% EVEN BRANCH
}%
\catcode`_ 8
{\centering
  \begin{tabular}{|c|*{10}c|}
    \hline
    \xintFor #1 in {0,1,2,3,4,5,6,7,8,9}\do {&\bfseries #1}\\
    \hline
    \bfseries 0&--&--&2&3&2&5&2&7&2&3\\
    \xintFor #1 in {1,2,3,4,5,6,7,8,9}\do
    {\bfseries #1%
      \xintFor #2 in {0,1,2,3,4,5,6,7,8,9}\do
      {&\SmallestFactor{#1#2}}\\}%
    \hline
  \end{tabular}\par
}
\end{everbatim*}

\subsection{Miller-Rabin Pseudo-Primality expandably}
\label{ssec:PrimesIV}


% At the time of writing, the code at the link above is still the version from
% April 2016 and it needed some hacks to get recursive (pseudo)-functions
% defined. Since |1.2h| of |2016/11/20| there is \csbxint{NewFunction} which
% allows us here to avoid such internal hacking.

% And since |1.3| of |2018/03/01|, it is possible to use \csbxint{defiifunc}
% also for recursive definitions, so we use it here, but we can benefit from it
% only for modular exponentiation as the rest of the code uses |iter| or |break|
% statements which are not yet compatible with \csbxint{defiifunc}.

The |isPseudoPrime(n)| is usable in \csbxint{iiexpr}-essions and establishes
if its (positive) argument is a Miller-Rabin PseudoPrime to the bases $2, 3,
5, 7, 11, 13, 17$. If this is true and $n<341550071728321$ (which has 15
digits) then $n$ really is a prime number.

Similarly $n=3825123056546413051$ (19 digits) is the smallest composite number
which is a strong pseudo prime for bases $2, 3, 5, 7, 11, 13, 17, 19$ and
$23$. It is easy to extend the code below to include these additional tests
(we could make the list of tested bases an argument too, now that I think
about it.)

For more information see
  \centeredline{\url{https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test#Deterministic_variants_of_the_test}}
  and
\centeredline{\url{http://primes.utm.edu/prove/prove2_3.html}}

In particular, according to \textsc{Jaeschke} \emph{On strong pseudoprimes to
  several bases,} Math. Comp., 61 (1993) 915-926, if $n < 4,759,123,141$ it is
enough to establish Rabin-Miller pseudo-primality to bases $a = 2, 7, 61$ to
prove that $n$ is prime. This range is enough for \TeX\ numbers and we could
then write a very fast expandable primality test for such numbers using only
|\numexpr|. Left as an exercise\dots

\begin{everbatim*}
% I -------------------------------- Modular Exponentiation
% Computes x^m modulo n (with m non negative).
% We will always use it with 1 < x < n
%
% With xint 1.4 we should use ? and ?? (although in the case at hand ifsgn()
% and if() would be ok but I should not say that).
%
\xintdefiifunc powmod_a(x, m, n) :=
       isone(m)?
           % m=1, return x modulo n
           {   x /: n  }
           % m > 1 test if odd or even and do recursive call
           {   odd(m)? {  x*sqr(powmod_a(x, m//2, n)) /: n }
                       {    sqr(powmod_a(x, m//2, n)) /: n }
            }
         ;
\xintdefiifunc powmod(x, m, n) := (m)?{powmod_a(x, m, n)}{1};

%% Syntax used before xint 1.4:
% \xintdefiifunc powmod_a(x, m, n) :=
%        ifone(m,
%            % m=1, return x modulo n
%               x /: n,
%            % m > 1 test if odd or even and do recursive call
%               if(odd(m), (x*sqr(powmod_a(x, m//2, n))) /: n,
%                             sqr(powmod_a(x, m//2, n))  /: n
%                 )
%          );
% \xintdefiifunc powmod(x, m, n) := if(m, powmod_a(x, m, n), 1);

% II ------------------------------ Miller-Rabin compositeness witness

% n=2^k m + 1 with m odd and k at least 1

% Choose 1<x<n.
% compute y=x^m modulo n
% if equals 1 we can't say anything
% if equals n-1 we can't say anything
% else put j=1, and
% compute repeatedly the square, incrementing j by 1 each time,
% thus always we have y^{2^{j-1}}
%   -> if at some point n-1 mod n found, we can't say anything and break out
%   -> if however we never find n-1 mod n before reaching
%        z=y^{2^{k-1}} with j=k
%        we then have z^2=x^{n-1}.
    % Suppose z is not -1 mod n. If z^2 is 1 mod n, then n can be prime only if
    % z is 1 mod n, and we can go back up, until initial y, and we have already
    % excluded y=1. Thus if z is not -1 mod n and z^2 is 1 then n is not prime.
    % But if z^2 is not 1, then n is not prime by Fermat. Hence (z not -1 mod n)
    % implies (n is composite). (Miller test)

% let's use again xintexpr indecipherable (except to author) syntax. Of course
% doing it with macros only would be faster.

% Here \xintdefiifunc is not usable because not compatible with iter, break, ... 
% but \xintNewFunction comes to the rescue.

\xintNewFunction{isCompositeWitness}[4]{% x=#1, n=#2, m=#3, k=#4
   subs((y==1)?{0}
         {iter(y;(j==#4)?{break(!(@==#2-1))}
                        {(@==#2-1)?{break(0)}{sqr(@)/:#2}},j=1++)}
         ,y=powmod(#1,#3,#2))}

% added note (2018/03/07) it is possible in the above that m=#3 is never
% zero, so we should rather call powmod_a for a small gain, but I don't
% have time to re-read the code comments and settle this.
 
% III ------------------------------------- Strong Pseudo Primes

% cf
%  http://oeis.org/A014233
%     <http://mathworld.wolfram.com/Rabin-MillerStrongPseudoprimeTest.html>
%     <http://mathworld.wolfram.com/StrongPseudoprime.html>

% check if positive integer <49 si a prime.
% 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47
\def\IsVerySmallPrime #1%
    {\ifnum#1=1 \xintdothis0\fi
     \ifnum#1=2 \xintdothis1\fi
     \ifnum#1=3 \xintdothis1\fi
     \ifnum#1=5 \xintdothis1\fi
     \ifnum#1=\numexpr (#1/2)*2\relax\xintdothis0\fi
     \ifnum#1=\numexpr (#1/3)*3\relax\xintdothis0\fi
     \ifnum#1=\numexpr (#1/5)*5\relax\xintdothis0\fi
     \xintorthat 1}

\xintNewFunction{isPseudoPrime}[1]{% n = #1
     (#1<49)?% use ? syntax to evaluate only what is needed
% prior to 1.4 we had \xintthe#1 here but the actual tokens represented
% by this #1 when isPseudoPrime() function expands have changed and 
% the correct way is now \xintiieval{#1} to hand over explicit digits to
% the \IsVerySmallPrime macro.
       {\IsVerySmallPrime{\xintiieval{#1}}}
       {(even(#1))?
        {0}
        {subs(%
         % L expands to two values m, k hence isCompositeWitness does get
         % its four variables x, n, m, k
         isCompositeWitness(2, #1, L)?
          {0}%
          {isCompositeWitness(3, #1, L)?
           {0}%
           {isCompositeWitness(5, #1, L)?
            {0}%
            {isCompositeWitness(7, #1, L)?
             {0}%
% above enough for N<3215031751 hence all TeX numbers
             {isCompositeWitness(11, #1, L)?
              {0}%
% above enough for N<2152302898747, hence all 12-digits numbers
              {isCompositeWitness(13, #1, L)?
               {0}%
% above enough for N<3474749660383
               {isCompositeWitness(17, #1, L)?
                {0}%
% above enough for N<341550071728321
                {1}%
               }% not needed to comment-out end of lines spaces inside
              }%  \xintexpr but this is too much of a habit for me with TeX!
             }%   I left some after the ? characters.
            }%
           }%
          }% this computes (m, k) such that n = 2^k m + 1, m odd, k>=1
          , L=iter(#1//2;(even(@))?{@//2}{break(@,k)},k=1++))%
         }%
        }%
}

% if needed:
%\def\IsPseudoPrime #1{\xinttheiiexpr isPseudoPrime(#1)\relax}

\noindent The smallest prime number at least equal to 3141592653589 is
\xintiiexpr 
   seq(isPseudoPrime(3141592653589+n)?
                    {break(3141592653589+n)}{omit}, n=0++)\relax.
% we could not use 3141592653589++ syntax because it works only with TeX numbers
\par
\end{everbatim*}





\subsection{A table of factorizations}
\label{ssec:factorizationtable}

As one more example with \csbxint{iloop} let us use an alignment to display the
factorization of some numbers. The loop will actually only play a minor r\^ole
here, just handling the row index, the row contents being almost entirely
produced via a macro |\factorize|. The factorizing macro does not use
|\xintiloop| as it didn't appear to be the convenient tool. As |\factorize| will
have to be used on |\xintiloopindex|, it has been defined as a delimited macro.

To spare some fractions of a second in the compilation time of this document
(which has many many other things to do), \number"7FFFFFED{} and
\number"7FFFFFFF, which turn out to be prime numbers, are not given to
|factorize| but just typeset directly; this illustrates use of
\csbxint{iloopskiptonext}.

The code next generates a \hyperref[floatfactorize]{table} which has
been made into a float appearing \vpageref{floatfactorize}. Here is now
the code for factorization; the conditionals use the package provided
|\xint_firstoftwo| and |\xint_secondoftwo|, one could have employed
rather \LaTeX{}'s own |\@firstoftwo| and |\@secondoftwo|, or, simpler
still in \LaTeX{} context, the |\ifnumequal|, |\ifnumless| \dots,
utilities from the package |etoolbox| which do exactly that under the
hood. Only \TeX{} acceptable numbers are treated here, but it would be
easy to make a translation and use the \xintname macros, thus extending
the scope to big numbers; naturally up to a cost in speed.

The reason for some strange looking expressions is to avoid arithmetic overflow.

\begin{everbatim*}
\catcode`_ 11
\def\abortfactorize #1\xint_secondoftwo\fi #2#3{\fi}

\def\factorize #1.{\ifnum#1=1 \abortfactorize\fi
          \ifnum\numexpr #1-2=\numexpr ((#1/2)-1)*2\relax
               \expandafter\xint_firstoftwo
          \else\expandafter\xint_secondoftwo
          \fi
         {2&\expandafter\factorize\the\numexpr#1/2.}%
         {\factorize_b #1.3.}}%

\def\factorize_b #1.#2.{\ifnum#1=1 \abortfactorize\fi
         \ifnum\numexpr #1-(#2-1)*#2<#2
                 #1\abortfactorize
         \fi
         \ifnum \numexpr #1-#2=\numexpr ((#1/#2)-1)*#2\relax
              \expandafter\xint_firstoftwo
         \else\expandafter\xint_secondoftwo
         \fi
         {#2&\expandafter\factorize_b\the\numexpr#1/#2.#2.}%
         {\expandafter\factorize_b\the\numexpr #1\expandafter.%
                                  \the\numexpr #2+2.}}%
\catcode`_ 8
\begin{figure*}[ht!]
\centering\phantomsection\label{floatfactorize}\normalcolor
\tabskip1ex
\centeredline{\vbox{\halign {\hfil\strut#\hfil&&\hfil#\hfil\cr\noalign{\hrule}
         \xintiloop ["7FFFFFE0+1]
         \expandafter\bfseries\xintiloopindex &
         \ifnum\xintiloopindex="7FFFFFED
              \number"7FFFFFED\cr\noalign{\hrule}
         \expandafter\xintiloopskiptonext
         \fi
         \expandafter\factorize\xintiloopindex.\cr\noalign{\hrule}
         \ifnum\xintiloopindex<"7FFFFFFE
         \repeat
         \bfseries \number"7FFFFFFF&\number "7FFFFFFF\cr\noalign{\hrule}
}}}
\centeredline{A table of factorizations}
\end{figure*}
\end{everbatim*}

\subsection{Another table of primes}
\label{ssec:primesIII}

As a further example, let us dynamically generate a tabular with the first $50$
prime numbers after $12345$. First we need a macro to test if a (short) number
is prime. Such a completely expandable macro was given in \autoref{ssec:primesI},
here we consider a variant which will be slightly more efficient. This new
|\IsPrime| has two parameters. The first one is a macro which it redefines to
expand to the result of the primality test applied to the second argument. For
convenience we use the \href{http://ctan.org/pkg/etoolbox}{etoolbox} wrappers to
various |\ifnum| tests, although here there isn't anymore the constraint of
complete expandability (but using explicit |\if..\fi| in tabulars has its
quirks); equivalent tests are provided by \xintname, but they have some overhead
as they are able to deal with arbitrarily big integers.

\def\IsPrime #1#2%
{\edef\TheNumber {\the\numexpr #2}% positive integer
 \ifnumodd {\TheNumber}
 {\ifnumgreater {\TheNumber}{1}
  {\edef\ItsSquareRoot{\xintiiSqrt \TheNumber}%
    \xintFor ##1 in {\xintintegers [3+2]}\do
    {\ifnumgreater {##1}{\ItsSquareRoot}
               {\def#1{1}\xintBreakFor}
               {}%
     \ifnumequal {\TheNumber}{(\TheNumber/##1)*##1}
                 {\def#1{0}\xintBreakFor }
                 {}%
    }}
  {\def#1{0}}}% 1 is not prime
 {\ifnumequal {\TheNumber}{2}{\def#1{1}}{\def#1{0}}}%
}%

\everb|@
\def\IsPrime #1#2% """color[named]{PineGreen}#1=\Result, #2=tested number (assumed >0).;!
{\edef\TheNumber {\the\numexpr #2}%"""color[named]{PineGreen} hence #2 may be a count or \numexpr.;!
 \ifnumodd {\TheNumber}
 {\ifnumgreater {\TheNumber}{1}
  {\edef\ItsSquareRoot{\xintiiSqrt \TheNumber}%
    \xintFor """color{red}##1;! in {"""color{red}\xintintegers;! [3+2]}\do
    {\ifnumgreater {"""color{red}##1;!}{\ItsSquareRoot} """color[named]{PineGreen}% "textcolor{red}{##1} is a \numexpr.;!
               {\def#1{1}\xintBreakFor}
               {}%
     \ifnumequal {\TheNumber}{(\TheNumber/##1)*##1}
                 {\def#1{0}\xintBreakFor }
                 {}%
    }}
  {\def#1{0}}}% 1 is not prime
 {\ifnumequal {\TheNumber}{2}{\def#1{1}}{\def#1{0}}}%
}
|

As we used \csbxint{For} inside a macro we had to double the |#| in its |#1|
parameter. Here is now the code which creates the prime table (the table has
been put in a \hyperref[primes]{float}, which should be found on page
\pageref{primes}):

\everb?@
\newcounter{primecount}
\newcounter{cellcount}
\begin{figure*}[ht!]
  \centering
  \begin{tabular}{|*{7}c|}
  \hline
  \setcounter{primecount}{0}\setcounter{cellcount}{0}%
  \xintFor """color{red}#1;! in {"""color{red}\xintintegers;! [12345+2]} \do
"""color[named]{PineGreen}% "textcolor{red}{#1} is a \numexpr.;!
  {\IsPrime\Result{#1}%
   \ifnumgreater{\Result}{0}
   {\stepcounter{primecount}%
    \stepcounter{cellcount}%
    \ifnumequal {\value{cellcount}}{7}
       {"""color{red}\the#1;! \\\setcounter{cellcount}{0}}
       {"""color{red}\the#1;! &}}
   {}%
    \ifnumequal {\value{primecount}}{50}
     {\xintBreakForAndDo
      {\multicolumn {6}{l|}{These are the first 50 primes after 12345.}\\}}
     {}%
  }\hline
\end{tabular}
\end{figure*}
?

\begin{figure*}[ht!]
  \centering\phantomsection\label{primes}
  \begin{tabular}{|*{7}c|}
  \hline
  \setcounter{primecount}{0}\setcounter{cellcount}{0}%
  \xintFor #1 in {\xintintegers [12345+2]} \do
  {\IsPrime\Result{#1}%
   \ifnumgreater{\Result}{0}
   {\stepcounter{primecount}%
    \stepcounter{cellcount}%
    \ifnumequal {\value{cellcount}}{7}
       {\the#1 \\\setcounter{cellcount}{0}}
       {\the#1 &}}
   {}%
    \ifnumequal {\value{primecount}}{50}
     {\xintBreakForAndDo
      {\multicolumn {6}{l|}{These are the first 50 primes after 12345.}\\}}
     {}%
  }\hline
\end{tabular}
\end{figure*}

\subsection{Factorizing again}
\label{ssec:factorize}

Here is an \fexpan dable macro which computes the factors of an integer. It
uses the \xintname macros only.
\begin{everbatim*}
\catcode`\@ 11
\let\factorize\relax
\newcommand\Factorize [1]
      {\romannumeral0\expandafter\factorize\expandafter{\romannumeral-`0#1}}%
\newcommand\factorize [1]{\xintiiifOne{#1}{ 1}{\factors@a #1.{#1};}}%
\def\factors@a #1.{\xintiiifOdd{#1}
   {\factors@c 3.#1.}%
   {\expandafter\factors@b \expandafter1\expandafter.\romannumeral0\xinthalf{#1}.}}%
\def\factors@b #1.#2.{\xintiiifOne{#2}
   {\factors@end {2, #1}}%
   {\xintiiifOdd{#2}{\factors@c 3.#2.{2, #1}}%
                     {\expandafter\factors@b \the\numexpr #1+\@ne\expandafter.%
                         \romannumeral0\xinthalf{#2}.}}%
}%
\def\factors@c #1.#2.{%
    \expandafter\factors@d\romannumeral0\xintiidivision {#2}{#1}{#1}{#2}%
}%
\def\factors@d #1#2#3#4{\xintiiifNotZero{#2}
   {\xintiiifGt{#3}{#1}
        {\factors@end {#4, 1}}% ultimate quotient is a prime with power 1
        {\expandafter\factors@c\the\numexpr #3+\tw@.#4.}}%
   {\factors@e 1.#3.#1.}%
}%
\def\factors@e #1.#2.#3.{\xintiiifOne{#3}
   {\factors@end {#2, #1}}%
   {\expandafter\factors@f\romannumeral0\xintiidivision {#3}{#2}{#1}{#2}{#3}}%
}%
\def\factors@f #1#2#3#4#5{\xintiiifNotZero{#2}
   {\expandafter\factors@c\the\numexpr #4+\tw@.#5.{#4, #3}}%
   {\expandafter\factors@e\the\numexpr #3+\@ne.#4.#1.}%
}%
\def\factors@end #1;{\xintlistwithsep{, }{\xintRevWithBraces {#1}}}%
\catcode`@ 12
\end{everbatim*}
The macro will be acceptably efficient only with numbers having somewhat small
prime factors.
\begin{everbatim}
\Factorize{16246355912554185673266068721806243461403654781833}
\end{everbatim}
\begingroup\fdef\Z
{\Factorize{16246355912554185673266068721806243461403654781833}}
\noindent{\small\dtt{\Z}}


It puts a little stress on the input save stack in order
not be bothered with previously gathered things.\footnote{2015/11/18 I have
  not revisited this code for a long time, and perhaps I could improve it now
  with some new techniques.}

Its output is a comma separated list with the number first, then its prime
factors with multiplicity. Let's produce something prettier:
\begin{everbatim*}
\catcode`_ 11
\def\ShowFactors #1{\expandafter
                    \ShowFactors_a\romannumeral-`0\Factorize{#1},\relax,\relax,}
\def\ShowFactors_a #1,{#1=\ShowFactors_b}
\def\ShowFactors_b #1,#2,{\if\relax#1\else#1^{#2}\expandafter\ShowFactors_b\fi}
\catcode`_ 8
\end{everbatim*}
\begin{everbatim}
$$\ShowFactors{16246355912554185673266068721806243461403654781833}$$
\end{everbatim}
$$\csname ShowFactors_a\expandafter\endcsname\Z,\relax,\relax,$$
\endgroup

If we only considered small integers, we could write pure |\numexpr| methods
which would be very much faster (especially if we had a table of small primes
prepared first) but still ridiculously slow compared to any non expandable
implementation, not to mention use of programming languages directly accessing
the CPU registers\dots

\subsection{The Quick Sort algorithm illustrated}\label{ssec:quicksort}

First a completely expandable macro which sorts a comma separated list of
numbers.%
%
\footnote{The code in earlier versions of this manual handled inputs composed
  of braced items. I have switched to comma separated inputs on the occasion
  of (link removed) 
  The version here is like
  |code 3| on 
  (link removed) (which is about |3x| faster
  than the earlier code it replaced in this manual) with a modification to
  make it more efficient if the data has many repeated values.

  A faster routine (for sorting hundreds of values) is provided as |code 6| at
  the link mentioned in the footnote, it is based on Merge Sort, but limited
  to inputs which one can handle as \TeX{} dimensions.%

  This |code 6| could be extended to handle more general numbers, as
  acceptable by \xintfracname. I have also written a non expandable version,
  which is even faster, but this matters really only when handling hundreds or
  rather thousands of values.}
%

The |\QSx| macro expands its list argument, which may thus be a macro; its
comma separated items must expand to integers or decimal numbers or fractions
or scientific notation as acceptable to \xintfracname, but if an item is
itself some (expandable) macro, this macro will be expanded each time the item
is considered in a comparison test! This is actually good if the macro expands
in one step to the digits, and there are many many digits, but bad if the macro
needs to do many computations. Thus |\QSx| should be used with either explicit
numbers or with items being macros expanding in one step to the numbers
(particularly if these numbers are very big).

If the interest is only in \TeX{} integers, then one should replace the
|\xintifCmp| macro with a suitable conditional, possibly helped by tools such as
|\ifnumgreater|, |\ifnumequal| and |\ifnumless| from
\href{http://ctan.org/pkg/etoolbox}{etoolbox} (\LaTeX{} only; I didn't see a
direct equivalent to |\xintifCmp|.) Or, if we are dealing with decimal numbers
with at most four+four digits, then one should use suitable |\ifdim| tests.
Naturally this will boost consequently the speed, from having skipped all the
overhead in parsing fractions and scientific numbers as are acceptable by
\xintfracname macros, and subsequent treatment.

\begin{everbatim*}
% THE QUICK SORT ALGORITHM EXPANDABLY
% \usepackage{xintfrac} in the preamble (latex)
\makeatletter
% use extra safe delimiters
\catcode`! 3 \catcode`? 3
\def\QSx {\romannumeral0\qsx }%
% first we check if empty list (else \qsx@finish will not find a comma)
\def\qsx   #1{\expandafter\qsx@a\romannumeral-`0#1,!,?}%
\def\qsx@a #1{\ifx,#1\expandafter\qsx@abort\else
                     \expandafter\qsx@start\fi #1}%
\def\qsx@abort #1?{ }%
\def\qsx@start {\expandafter\qsx@finish\romannumeral0\qsx@b,}%
\def\qsx@finish ,#1{ #1}%
%
% we check if empty of single and if not pick up the first as Pivot:
\def\qsx@b ,#1#2,#3{\ifx?#3\xintdothis\qsx@empty\fi
                    \ifx!#3\xintdothis\qsx@single\fi
                    \xintorthat\qsx@separate {#1#2}{}{}{#1#2}#3}%
\def\qsx@empty  #1#2#3#4#5{ }%
\def\qsx@single #1#2#3#4#5?{, #4}%
\def\qsx@separate #1#2#3#4#5#6,%
{%
    \ifx!#5\expandafter\qsx@separate@done\fi
    \xintifCmp {#5#6}{#4}%
          \qsx@separate@appendtosmaller
          \qsx@separate@appendtoequal
          \qsx@separate@appendtogreater {#5#6}{#1}{#2}{#3}{#4}%
}%
%
\def\qsx@separate@appendtoequal   #1#2{\qsx@separate {#2,#1}}%
\def\qsx@separate@appendtogreater #1#2#3{\qsx@separate {#2}{#3,#1}}%
\def\qsx@separate@appendtosmaller #1#2#3#4{\qsx@separate {#2}{#3}{#4,#1}}%
%
\def\qsx@separate@done\xintifCmp #1%
          \qsx@separate@appendtosmaller
          \qsx@separate@appendtoequal
          \qsx@separate@appendtogreater #2#3#4#5#6#7?%
{%
    \expandafter\qsx@f\expandafter {\romannumeral0\qsx@b #4,!,?}{\qsx@b #5,!,?}{#3}%
}%
%
\def\qsx@f #1#2#3{#2, #3#1}%
%
\catcode`! 12 \catcode`? 12
\makeatother

% EXAMPLE
\begingroup
\edef\z {\QSx {1.0, 0.5, 0.3, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
               1.3, 1.1, 0.7, 1.6, 0.6, 0.9, 0.8, 0.2, 0.1, 1.9}}
\meaning\z

\def\a {3.123456789123456789}\def\b {3.123456789123456788}
\def\c {3.123456789123456790}\def\d {3.123456789123456787}
\oodef\z {\QSx { \a, \b, \c, \d}}%
% The space before \a to let it not be expanded during the conversion from CSV
% values to List. The \oodef expands exactly twice (via a bunch of \expandafter's)
\meaning\z
\endgroup
\end{everbatim*} (the spaces after \string\d, etc...\@{} come from the use of the
|\meaning| primitive.)

The choice of pivot as first element is bad if the list is already almost
sorted. Let's add a variant which will pick up the pivot index randomly. The
previous routine worked also internally with comma separated lists, but for a
change this one will use internally lists of braced items (the initial
conversion via \csbxint{CSVtoList} handles all potential spurious space
problems).

\begin{everbatim*}
% QuickSort expandably on comma separated values with random choice of pivots
% \usepackage{xintfrac, xinttools} in preamble
\makeatletter
\def\QSx {\romannumeral0\qsx }% This is a f-expandable macro.
% This converts from comma separated values on input and back on output.
% **** NOTE: these steps (and the other ones too, actually) are costly if input
%            has thousands of items.
\def\qsx #1{\xintlistwithsep{, }%
            {\expandafter\qsx@sort@a\expandafter{\romannumeral0\xintcsvtolist{#1}}}}%
%
% we check if empty or single or double and if not pick up the first as Pivot:
\def\qsx@sort@a #1%
    {\expandafter\qsx@sort@b\expandafter{\romannumeral0\xintlength{#1}}{#1}}%
\def\qsx@sort@b #1{\ifcase #1
                      \expandafter\qsx@sort@empty
                      \or\expandafter\qsx@sort@single
                      \or\expandafter\qsx@sort@double
                      \else\expandafter\qsx@sort@c\fi {#1}}%
\def\qsx@sort@empty  #1#2{ }%
\def\qsx@sort@single #1#2{#2}%
\catcode`_ 11
\def\qsx@sort@double #1#2{\xintifGt #2{\xint_exchangetwo_keepbraces}{}#2}%
\catcode`_ 8
\def\qsx@sort@c      #1#2{%
    \expandafter\qsx@sort@sep@a\expandafter
                {\romannumeral0\xintnthelt{\xintUniformDeviate #1+\@ne}{#2}}#2?}%
\def\qsx@sort@sep@a #1{\qsx@sort@sep@loop {}{}{}{#1}}%
\def\qsx@sort@sep@loop #1#2#3#4#5%
{%
    \ifx?#5\expandafter\qsx@sort@sep@done\fi
    \xintifCmp {#5}{#4}%
          \qsx@sort@sep@appendtosmaller
          \qsx@sort@sep@appendtoequal
          \qsx@sort@sep@appendtogreater {#5}{#1}{#2}{#3}{#4}%
}%
%
\def\qsx@sort@sep@appendtoequal   #1#2{\qsx@sort@sep@loop {#2{#1}}}%
\def\qsx@sort@sep@appendtogreater #1#2#3{\qsx@sort@sep@loop {#2}{#3{#1}}}%
\def\qsx@sort@sep@appendtosmaller #1#2#3#4{\qsx@sort@sep@loop {#2}{#3}{#4{#1}}}%
%
\def\qsx@sort@sep@done\xintifCmp #1%
          \qsx@sort@sep@appendtosmaller
          \qsx@sort@sep@appendtoequal
          \qsx@sort@sep@appendtogreater #2#3#4#5#6%
{%
    \expandafter\qsx@sort@recurse\expandafter
               {\romannumeral0\qsx@sort@a {#4}}{\qsx@sort@a {#5}}{#3}%
}%
%
\def\qsx@sort@recurse #1#2#3{#2#3#1}%
%
\makeatother

% EXAMPLES
\begingroup
\edef\z {\QSx {1.0, 0.5, 0.3, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
               1.3, 1.1, 0.7, 1.6, 0.6, 0.9, 0.8, 0.2, 0.1, 1.9}}
\meaning\z

\def\a {3.123456789123456789}\def\b {3.123456789123456788}
\def\c {3.123456789123456790}\def\d {3.123456789123456787}
\oodef\z {\QSx { \a, \b, \c, \d}}%
% The space before \a to let it not be expanded during the conversion from CSV
% values to List. The \oodef expands exactly twice (via a bunch of \expandafter's)
\meaning\z

\def\somenumbers{%
3997.6421, 8809.9358, 1805.4976, 5673.6478, 3179.1328, 1425.4503, 4417.7691,
2166.9040, 9279.7159, 3797.6992, 8057.1926, 2971.9166, 9372.2699, 9128.4052,
1228.0931, 3859.5459, 8561.7670, 2949.6929, 3512.1873, 1698.3952, 5282.9359,
1055.2154, 8760.8428, 7543.6015, 4934.4302, 7526.2729, 6246.0052, 9512.4667,
7423.1124, 5601.8436, 4433.5361, 9970.4849, 1519.3302, 7944.4953, 4910.7662,
3679.1515, 8167.6824, 2644.4325, 8239.4799, 4595.1908, 1560.2458, 6098.9677,
3116.3850, 9130.5298, 3236.2895, 3177.6830, 5373.1193, 5118.4922, 2743.8513,
8008.5975, 4189.2614, 1883.2764, 9090.9641, 2625.5400, 2899.3257, 9157.1094,
8048.4216, 3875.6233, 5684.3375, 8399.4277, 4528.5308, 6926.7729, 6941.6278,
9745.4137, 1875.1205, 2755.0443, 9161.1524, 9491.1593, 8857.3519, 4290.0451,
2382.4218, 3678.2963, 5647.0379, 1528.7301, 2627.8957, 9007.9860, 1988.5417,
2405.1911, 5065.8063, 5856.2141, 8989.8105, 9349.7840, 9970.3013, 8105.4062,
3041.7779, 5058.0480, 8165.0721, 9637.7196, 1795.0894, 7275.3838, 5997.0429,
7562.6481, 8084.0163, 3481.6319, 8078.8512, 2983.7624, 3925.4026, 4931.5812,
1323.1517, 6253.0945}%

\oodef\z {\QSx \somenumbers}% produced as a comma+space separated list
% black magic as workaround to the shrinkability of spaces in last line...
\hsize 87\fontcharwd\font`0
\lccode`~=32
\lowercase{\def~}{\discretionary{}{}{\kern\fontcharwd\font`0}}\catcode32 13
\noindent\phantom{00}\scantokens\expandafter{\meaning\z}\par
\endgroup
\end{everbatim*}


All the previous examples were with numbers which could have been handled via
|\ifdim| tests rather than the \csbxint{ifCmp} macro from \xintfracname; using
|\ifdim| tests would naturally be faster. Even faster routine is |code 6| at
(link removed) which uses |\pdfescapestring| and a
Merge Sort algorithm.

We then turn to a graphical illustration of the algorithm.%
%
\footnote{I have rewritten (2015/11/21) the routine to do only once (and not thrice) the
  needed calls to \csa{xintifCmp}, up to the price of one additional |\edef|,
  although due to the context execution time on our side is not an issue and
  moreover is anyhow overwhelmed by the TikZ's activities. Simultaneously I
  have updated the code.
  The
  variant with the choice of pivot on the right has more overhead: the reason
  is simply that we do not convert the data into an array, but maintain a list
  of tokens with self-reorganizing delimiters.}
%
For simplicity the pivot is always chosen as the first list item. Then we also
give a variant which picks up the last item as pivot.
\begin{everbatim*}
% in LaTeX preamble:
% \usepackage{xintfrac, xinttools}
% \usepackage{color}
% or, when using Plain TeX:
% \input xintfrac.sty \input xinttools.sty
% \input color.tex
%
% Color definitions
\definecolor{LEFT}{RGB}{216,195,88}
\definecolor{RIGHT}{RGB}{208,231,153}
\definecolor{INERT}{RGB}{199,200,194}
\definecolor{INERTpiv}{RGB}{237,237,237}
\definecolor{PIVOT}{RGB}{109,8,57}
% Start of macro defintions
\makeatletter
% \catcode`? 3 % a bit too paranoid. Normal ? will do.
%
% argument will never be empty
\def\QS@cmp@a    #1{\QS@cmp@b  #1??}%
\def\QS@cmp@b    #1{\noexpand\QS@sep@A\@ne{#1}\QS@cmp@d {#1}}%
\def\QS@cmp@d    #1#2{\ifx ?#2\expandafter\QS@cmp@done\fi
                      \xintifCmp {#1}{#2}\tw@\@ne\z@{#2}\QS@cmp@d {#1}}%
\def\QS@cmp@done #1?{?}%
%
\def\QS@sep@A #1?{\QSLr\QS@sep@L #1\thr@@?#1\thr@@?#1\thr@@?}%
\def\QS@sep@L #1#2{\ifcase #1{#2}\or\or\else
                                          \expandafter\QS@sep@I@start\fi \QS@sep@L}%
\def\QS@sep@I@start\QS@sep@L {\noexpand\empty?\QSIr\QS@sep@I}%
\def\QS@sep@I #1#2{\ifcase#1\or{#2}\or\else\expandafter\QS@sep@R@start\fi\QS@sep@I}%
\def\QS@sep@R@start\QS@sep@I {\noexpand\empty?\QSRr\QS@sep@R}%
\def\QS@sep@R #1#2{\ifcase#1\or\or{#2}\else\expandafter\QS@sep@done\fi\QS@sep@R}%
\def\QS@sep@done\QS@sep@R {\noexpand\empty?}%
%
\def\QS@loop {%
    \xintloop
    % pivot phase
    \def\QS@pivotcount{0}%
    \let\QSLr\DecoLEFTwithPivot  \let\QSIr \DecoINERT
    \let\QSRr\DecoRIGHTwithPivot \let\QSIrr\DecoINERT
    \centerline{\QS@list}%
    % sorting phase
    \ifnum\QS@pivotcount>\z@
            \def\QSLr {\QS@cmp@a}\def\QSRr {\QS@cmp@a}%
            \def\QSIr {\QSIrr}\let\QSIrr\relax
                \edef\QS@list{\QS@list}% compare
            \let\QSLr\relax\let\QSRr\relax\let\QSIr\relax
                \edef\QS@list{\QS@list}% separate
            \def\QSLr ##1##2?{\ifx\empty##1\else\noexpand \QSLr {{##1}##2}\fi}%
            \def\QSIr ##1##2?{\ifx\empty##1\else\noexpand \QSIr {{##1}##2}\fi}%
            \def\QSRr ##1##2?{\ifx\empty##1\else\noexpand \QSRr {{##1}##2}\fi}%
                \edef\QS@list{\QS@list}% gather
            \let\QSLr\DecoLEFT \let\QSRr\DecoRIGHT
            \let\QSIr\DecoINERTwithPivot \let\QSIrr\DecoINERT
            \centerline{\QS@list}%
    \repeat }%
%
% \xintFor* loops handle gracefully empty lists.
\def\DecoLEFT  #1{\xintFor* ##1 in {#1} \do {\colorbox{LEFT}{##1}}}%
\def\DecoINERT #1{\xintFor* ##1 in {#1} \do {\colorbox{INERT}{##1}}}%
\def\DecoRIGHT #1{\xintFor* ##1 in {#1} \do {\colorbox{RIGHT}{##1}}}%
\def\DecoPivot #1{\begingroup
                    \color{PIVOT}\advance\fboxsep-\fboxrule\fbox{#1}\endgroup}%
%
\def\DecoLEFTwithPivot #1{\xdef\QS@pivotcount{\the\numexpr\QS@pivotcount+\@ne}%
    \xintFor* ##1 in {#1} \do
        {\xintifForFirst {\DecoPivot {##1}}{\colorbox{LEFT}{##1}}}}%
\def\DecoINERTwithPivot #1{\xdef\QS@pivotcount{\the\numexpr\QS@pivotcount+\@ne}%
    \xintFor* ##1 in {#1} \do
        {\xintifForFirst {\colorbox{INERTpiv}{##1}}{\colorbox{INERT}{##1}}}}%
\def\DecoRIGHTwithPivot #1{\xdef\QS@pivotcount{\the\numexpr\QS@pivotcount+\@ne}%
    \xintFor* ##1 in {#1}  \do
        {\xintifForFirst {\DecoPivot {##1}}{\colorbox{RIGHT}{##1}}}}%
%
\def\QuickSort #1{% warning: not compatible with empty #1.
    % initialize, doing conversion from comma separated values
    % to a list of braced items
    \edef\QS@list{\noexpand\QSRr{\xintCSVtoList{#1}}}%
    % may \edef's are to follow anyhow
% earlier I did a first drawing of the list, here with the color of RIGHT elements,
% but the color should have been for example white, anyway I drop this first line
    %\let\QSRr\DecoRIGHT
    %\par\centerline{\QS@list}%
%
    % loop as many times as needed
    \QS@loop }%
%
% \catcode`? 12 % in case we had used a funny ? as delimiter.
\makeatother
%% End of macro definitions.
%% Start of Example
\begingroup\offinterlineskip
\small
% \QuickSort {1.0, 0.5, 0.3, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
%                1.3, 1.1, 0.7, 1.6, 0.6, 0.9, 0.8, 0.2, 0.1, 1.9}
% \medskip
% with repeated values
\QuickSort {1.0, 0.5, 0.3, 0.8, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
               1.3, 1.1, 0.7, 0.3, 1.6, 0.6, 0.3, 0.8, 0.2, 0.8, 0.7, 1.2}
\endgroup
\end{everbatim*}

Here is the variant which always picks the pivot as the rightmost element.

\begin{everbatim*}
\makeatletter
%
\def\QS@cmp@a #1{\noexpand\QS@sep@A\expandafter\QS@cmp@d\expandafter
                 {\romannumeral0\xintnthelt{-1}{#1}}#1??}%
%
\def\DecoLEFTwithPivot #1{\xdef\QS@pivotcount{\the\numexpr\QS@pivotcount+\@ne}%
    \xintFor* ##1 in {#1} \do
        {\xintifForLast {\DecoPivot {##1}}{\colorbox{LEFT}{##1}}}}
\def\DecoINERTwithPivot #1{\xdef\QS@pivotcount{\the\numexpr\QS@pivotcount+\@ne}%
    \xintFor* ##1 in {#1} \do
        {\xintifForLast {\colorbox{INERTpiv}{##1}}{\colorbox{INERT}{##1}}}}
\def\DecoRIGHTwithPivot #1{\xdef\QS@pivotcount{\the\numexpr\QS@pivotcount+\@ne}%
    \xintFor* ##1 in {#1}  \do
        {\xintifForLast {\DecoPivot {##1}}{\colorbox{RIGHT}{##1}}}}
\def\QuickSort #1{%
    % initialize, doing conversion from comma separated values
    % to a list of braced items
    \edef\QS@list{\noexpand\QSLr {\xintCSVtoList{#1}}}%
    % many \edef's are to follow anyhow
    %
    % loop as many times as needed
    \QS@loop }%
\makeatother
\begingroup\offinterlineskip
\small
% \QuickSort {1.0, 0.5, 0.3, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
%                1.3, 1.1, 0.7, 1.6, 0.6, 0.9, 0.8, 0.2, 0.1, 1.9}
% \medskip
% with repeated values
\QuickSort {1.0, 0.5, 0.3, 0.8, 1.5, 1.8, 2.0, 1.7, 0.4, 1.2, 1.4,
               1.3, 1.1, 0.7, 0.3, 1.6, 0.6, 0.3, 0.8, 0.2, 0.8, 0.7, 1.2}
\endgroup
\end{everbatim*}

The choice of the first or last item as pivot is not a good one as nearly
ordered lists will take quadratic time. But for explaining the algorithm via a
graphical interpretation, it is not that bad. If one wanted to pick up the
pivot randomly, the routine would have to be substantially rewritten: in
particular the |\Deco..withPivot| macros need to know where the pivot is, and
currently this is implemented by using either |\xintifForFirst| or
|\xintifForLast|.

\clearpage

\expandafter\let\csname ExamplesnameUp\endcsname\undefined

\csname xintbundlenameUp\endcsname

\def\xintRunningHeader{{\inheadertrue\catcode`,12\relax
          \DOCxintfrontpage,
          \xintbundlename,
          \xintkernelname,
          \xintcorename,
          \xintname,
          \xintfracname,
          \xintbinhexname,
          \xintgcdname,
          \xintseriesname,
          \xintcfracname}}
\markboth{\makebox[0pt]{\xintRunningHeader}}{\makebox[0pt]{\xintRunningHeader}}

\etocdepthtag.toc {macros}
\addtocontents{toc}{\gdef\string\tocstylesectionbracedcolor{{tocstylebundlesectioncolor}}}

\part{The macro layer for expandable computations: \xintcorename, \xintname,
  \xintfracname, and some extras}
\RaisedLabel[15]{sec:bundle}


\begin{framed}
  WARNING !

  The documentation is getting old, and is in need of rewrites for many
  sections, particularly for examples.

  We do try to keep updated the description of macros
  provided by the packages.
\end{framed}

\etocsetnexttocdepth{section}
\localtableofcontents

\section{Introduction: the \xintbundlename}

\localtableofcontents

\subsection{Characteristics}

\begin{framed}
  The main characteristics are:
  \begin{enumerate}
  \item exact algebra on ``big numbers'', integers as well as
    fractions,
  \item floating point variants with user-chosen precision,
  \item the computational macros are compatible with expansion-only context,
  \item the bundle comes with parsers (integer-only, or handling fractions, or
    doing floating point computations) of infix operations implementing
    beyond infix operations extra features such as dummy variables.
  \end{enumerate}


  Since |1.2| ``big numbers'' must have less than about \dtt{19950} digits:
  the maximal number of digits for addition is at \dtt{19968} digits, and it
  is \dtt{19959} for multiplication. The reasonable range of use of the
  package is with numbers of up to a few hundred digits.\footnotemark

  \TeX\ does not know off-hand how to print on the page such very long
  numbers, see \autoref{ssec:printnumber}.
\end{framed}
\footnotetext{For example multiplication of integers having from \dtt{50} to
  \dtt{100} digits takes roughly of the order of the millisecond on a 2012
  desktop computer. I compared this to using Python3: using timeit module on a
  wrapper defined as |return w*z| with random integers of \dtt{100} digits, I
  observe on the same computer a computation time of roughly $4.10^{-7}$s per
  call. And with |return str(w*z)| then this becomes more like $16.10^{-7}$s
  per call. And with |return str(int(W)*int(Z))| where |W| and |Z| are
  strings, this becomes about $26.10^{-7}$s (I am deliberately ignoring
  Python's Decimal module here...) Anyway, my sentence from earlier version of
  this documentation: \emph{this is, I guess, at least about 1000 times slower
    than what can be expected with any reasonable programming language,} is
  about right. I then added: \emph{nevertheless as compilation of a typical
    \LaTeX\ document already takes of the order of seconds and even dozens of
    seconds for long ones, this leaves room for reasonably many computations
    via \xintexprname or via direct use of the macros of
    \xintname/\xintfracname.}}

Integers with only $10$ digits and starting with a $3$ already exceed the
\TeX{} bound; and \TeX{} does not have a native processing of floating point
numbers (multiplication by a decimal number of a dimension register is allowed
--- this is used for example by the
\href{http://mirrors.ctan.org/graphics/pgf/base}{pgf} basic math engine.)

\TeX{} elementary operations on numbers are done via the non-expandable
\emph{\char92advance, \char92multiply, \emph{and} \char92divide} assignments.
This was changed with \eTeX{}'s |\numexpr| which does expandable computations
using standard infix notations with \TeX{} integers. But \eTeX{} did not
modify the \TeX{} bound on acceptable integers, and did not add floating point
support.

The \ctanpackage{bigintcalc} package by
\textsc{Heiko Oberdiek} provided expandable macros (using some of |\numexpr|
possibilities, when available) on arbitrarily big integers, beyond the \TeX{}
bound. It does not provide an expression parser.%
%
\footnote{One can currently use package
  \ctanpackage{bnumexpr} to associate the |bigintcalc|
  macros with an expression parser. This may be unavailable in future if
  |bnumexpr| becomes more tightly associated with future evolutions or
  variants of \xintcorename.  EDIT: still possible as of \ctanpackage{bnumexpr}
  |1.6| |2025/09/01|.}
%
\xintname did it again using more of |\numexpr| for higher speed, and in a
later evolution added handling of exact fractions, of scientific numbers, and
an expression parser. Arbitrary precision floating points operations were
added as a derivative, and not part of the initial design goal.

The concept of signed infinities, signed zeroes, |NaN|'s, error
traps\dots,\footnote{The latter exist as work-in-progress for some time in the
  source code.} have not been implemented, only the notion of `scientific
notation with a given number of significant figures'.%
%
\footnote{Multiplication of two floats with |P=\xinttheDigits| digits is
  first done exactly then rounded to |P| digits, rather than using a
  specially tailored multiplication for floating point numbers which
  would be more efficient (it is a waste to evaluate fully the
  multiplication result with |2P| or |2P-1| digits.)}

The \LaTeX3 project has implemented expandably floating-point computations with
\dtt{16} significant figures
(\href{https://ctan.org/pkg/l3kernel}{l3fp}), including
functions such as exp, log, sine and cosine.\footnote{at the time of writing (2014/10/28) the
  \href{https://ctan.org/pkg/l3kernel}{l3fp} (exactly represented) floating
  point numbers have their exponents limited to $\pm$\dtt{9999}.}
%

More directly related to the \xintbundlename there is the \liiibigint{}
package, also devoted to big integers and in development a.t.t.o.w (2015/10/09,
no division yet). It is part of the experimental trunk of the
\href{http://latex-project.org}{\LaTeX3 Project} and provides an expression
parser for expandable arithmetic with big integers. Its author Bruno
\textsc{Le Floch} succeeded brilliantly into implementing expandably the
Karatsuba multiplication algorithm and he achieves \emph{sub-quadratic growth
  for the computation time}. This shows up very clearly with numbers having
thousands of digits, up to the maximum which a.t.t.o.w is at $8192$ digits.


The \liiibigint{} multiplication from late |2015| is observed to be roughly
|3x--4x| faster than the one from \csbxint{iiexpr} in the range of \dtt{4000}
to \dtt{5000} digits integers, and isn't far from being |9x| faster at
\dtt{8000} digits. On the other hand \csbxint{iiexpr}'s multiplication is
found to be on average roughly |2.5x| faster than \liiibigint's for numbers up
to \dtt{100} digits and the two packages achieve about the same speed at
\dtt{900} digits: but each such multiplication of numbers of \dtt{900} digits
costs about one or two tenths of a second on a 2012 desktop computer, whereas
the order of magnitude is rather the |ms| for numbers with \dtt{50--100}
digits.\footnote{I have tested this again on |2016/12/19|, but the macros have
  not changed on the \liiibigint{} side and barely on the \xintcorename side,
  hence I got again the same results\dots}

Even with the superior \liiibigint{} Karatsuba multiplication it takes about
|3.5s| on this 2012 desktop computer for a single multiplication of two
\dtt{5000}-digits numbers. Hence it is not possible to do routinely such
computations in a document. I have long been thinking that without the
expandability constraint much higher speeds could be achieved, but perhaps I
have not given enough thought to sustain that optimistic stance.\footnote{The
  \ctanpackage{apnum} package implements
  (non-expandably) arbitrary precision fixed point algebra and (v1.6)
  functions exp, log, sqrt, the trigonometrical direct and inverse functions.}

I remain of the opinion that if one really wants to do computations with
\emph{thousands} of digits, one should drop the expandability requirement.
Indeed, as clearly demonstrated long ago by the
\href{https://ctan.org/pkg/pi}{pi computing file} by \textsc{D. Roegel} one
can program \TeX{} to compute with many digits at a much higher speed than
what \xintname achieves: but, direct access to memory storage in one form or
another seems a necessity for this kind of speed and one has to renounce at
the complete expandability.%
%
\footnote{The Lua\TeX{} project possibly makes endeavours such as \xintname
  appear even more insane that they are, in truth: \xintname is able to handle
  fast enough computations involving numbers with less than one hundred digits
  and brings this to all engines.}

\subsection{Floating point evaluations}
\label{ssec:floatingpoint}

\begin{framed}
  WARNING: THIS PART OF THE DOCUMENTATION IS IN DIRE NEED OF BEING 
  REVISED AND MAY BE EVEN MORE BADLY OBSOLETE THAN THE REST OF THIS DOCUMENTATION.
\end{framed}

Floating point macros are provided by package \xintfracname to work with a
given arbitrary precision |P|. The default value is $P=16$ meaning that the
significands of the produced (non-zero) numbers have \dtt{16} decimal digits.
The syntax to set the precision to |P| is
%
\centeredline{|\xintDigits:=P\relax|}
%
The value is local to the group or environment (if using \LaTeX). To query the
current value use \csbxint{theDigits}.

Most floating point macros accept an optional first argument |[P]| which then
sets the target precision and replaces the |\xintDigits| assigned value (the
|[P]| must be repeated if the arguments are themselves \xintfracname macros
with arguments of their own.) In this section |P| refers to the prevailing
|\xinttheDigits| float precision or to the target precision set in this way as
an optional argument.

\csbxint{floatexpr}|[Q]...\relax| also admits an optional argument |[Q]| but
it has an altogether different meaning: the computations are always done with
the prevailing |\xinttheDigits| precision and the optional argument |Q| is
used for the final rounding. This makes sense only if |Q<\xinttheDigits| and
is intended to clean up the result from dubious last digits (when |Q<0| it
indicates rather by how many digits one should reduce the mantissa lengths via a
final rounding).


 




\begin{framed}
  The |IEEE 754|\footnotemark\ requirement of \emph{correct rounding} for
  addition, subtraction, multiplication, division and square root is achieved
  (in arbitrary precision) by the macros of \xintfracname hence also by the
  infix operators |+|, |-|, |*|, |/|.

    This means that for operands given with at most |P| significant digits
    (and arbitrary exponents) the output coincides exactly with the rounding
    of the exact theoretical result (barring overflow or underflow).


{\footnotesize Due to a typographical oversight, this documentation
    (up to |1.2j|) adjoined |^| and |**| to the above list of
    infix operators. But as
    is explained in \autoref{xintFloatPower}, what is guaranteed regarding
    integer powers is an error of at most |0.52ulp|, not the correct rounding.
    Half-integer powers are computed as square roots of integer powers.\par }%

  The rounding mode is ``round to nearest, ties away from zero''.
  It is not customizable.

  Currently \xintfracname has no notion of |NaN|s or signed infinities or signed
  zeroes, but this is intended for the future.
\end{framed}
%
\footnotetext{The |IEEE 754-1985| standard was for hardware implementations of
  binary floating-point arithmetic with a specific value for the precision
  ($24$ bits for single precision, $53$ bits for double precision). The newer
  {\texttt{IEEE 754-2008}}
  (\url{https://en.wikipedia.org/wiki/IEEE_floating_point}) normalizes five
  basic formats, three binaries and two decimals ($16$ and $34$ decimal
  digits) and discusses extended formats with higher precision. These
  standards are only indirectly relevant to libraries like \xintname dealing
  with arbitrary precision.%
}


Since release
|1.2f|, square root extraction achieves correct rounding in arbitrary
precision.



The maximal floating point decimal exponent is currently
\dtt{\number"7FFFFFFF} which is the maximal number handled by \TeX. The
minimal exponent is its opposite. But this means that overflow or underflow
are detected only via low-level |\numexpr| arithmetic overflows which are
basically un-recoverable. Besides there are some border effects as the
routines need to add or subtract lengths of numbers from exponents, possibly
triggering the low-level overflows. In the future not only the Precision but
also the maximal and minimal exponents |Emin| and |Emax| will be specifiable
by the user.

Since |1.2f|, the float macros round their inputs to the target precision |P|
before further processing. Formerly, the initial rounding was done to |P+2|
digits (and at least |P+3| for the power operation.)

The more ambitious model would be for the computing macros to obey the
intrinsic precision of their inputs, i.e.\@{} to compute the correct rounding to
|P| digits of the exact mathematical result corresponding to inputs allowed to
have their own higher precision.%
%
\footnote{The |MPFR| library
  \url{http://www.mpfr.org/} implements this but it does not know fractions!}
%
This would be feasible by \xintfracname which after all knows how to compute
exactly, but I have for the time being decided that for reasons of efficiency,
the chosen model is the one of rounding inputs to the target precision first.

The float macros of \xintfracname have to handle inputs which
not only may have much more digits than the target float precision, but may
even be fractions: in a way this means infinite precision.

From releases |1.08a| to |1.2j| a fraction input $AeM/BeN$ had its numerator
and denominator $A$ and $B$ truncated to |Q+2| digits of precision, then the
substituted fraction was correctly rounded to |Q| digits of precision (usually
with |Q| set to |P+2|) and then the operation was implemented on such rounded
inputs. But this meant that two fractions representing the same rational
number could end up being rounded differently (with a difference of one unit
in the last place), if it had numerators and denominators with at least |Q+3|
digits.

Starting with release |1.2k| a fractional input $AeM/BeN$ is handled
intrinsically: the fraction, independently of its representation $AeM/BeN$, is
\emph{correctly rounded} to |P| digits during the input parsing. Hence the
output depends only on its arguments as mathematical fractions and not on
their representatives as quotients.

Notice that in float expressions, the |/| is treated as operator, and is
applied to arguments which are generally already |P|-floats, hence the above
discussion becomes relevant in this context only for the special input form
|qfloat(A/B)| or when using a sub-expression |\xintexpr A/B\relax| embedded in
the float expression with |A| or |B| having more digits than the prevailing
float precision |P|.






\subsection{Expansion matters}

\subsubsection{Full expansion of the first token}
\label{ssec:expansions}

The whole business of \xintname is to build upon |\numexpr| and handle
arbitrarily large numbers. Each basic operation is thus done via a macro:
\csbxint{iiAdd}, \csbxint{iiSub}, \csbxint{iiMul}, \csbxint{iiDivision}. In
order to handle more complex operations, it must be possible to nest these
macros.
%
An expandable macro can not execute a |\def| or an |\edef|. But the macro must
expand its arguments to find the digits it is supposed to manipulate. \TeX{}
provides a tool to do the job of (expandable !) repeated expansion of the
first token found until hitting something non expandable, such as a digit, a
|\def| token, a brace, a |\count| token, etc...\@{} is found. A space token also
will stop the expansion (and be swallowed, contrarily to the non-expandable
tokens).

By convention in this manual \fexpan sion (``full expansion'' or ``full first
expansion'') will be this \TeX{} process of expanding repeatedly the first
token seen. For those familiar with \LaTeX3 (which is not used by \xintname)
this is what is called in its documentation full expansion, whereas expansion
inside |\edef| would be described I think as ``exhaustive'' expansion
and will be referred too in this manual as \xexpan sion.

Most of the package macros, and all those dealing with computations%
%
\footnote{except \csbxint{XTrunc}.},
%
are expandable in the strong sense that they expand to their final result via
this \fexpan sion. This will be signaled in their descriptions via a
\etype{}star in the margin.

These macros not only have this property of \fexpan dability, they all begin
by first applying \fexpan sion to their arguments. Again from \LaTeX3's
conventions this will be signaled by a%
%
\ntype{{\setbox0 \hbox{\Ff}\hbox to \wd0 {\hss f\hss}}}
%
margin annotation next to the description of the arguments.

\subsubsection{Summary of important expandability aspects}

\begin{enumerate}
\item the macros \fexpan d their arguments, this means that they expand the
  first token seen (for each argument), then expand, etc..., until something
  un-expandable such as a\strut{} digit or a brace is hit against. This
  example
%
  \leftedline{|\def\x{98765}\def\y{43210}| |\xintiiAdd {\x}{\x\y}|}
%
  is \emph{not} a legal construct, as the |\y| will remain untouched by
  expansion and not get converted into the digits which are expected by the
  sub-routines of |\xintiiAdd|. It is a |\numexpr| which will expand it and an
  arithmetic overflow will arise as |9876543210| exceeds the \TeX{} bounds.
  The same would hold for |\xintAdd|.

  \begingroup\slshape
  To the contrary \csbxint{theiiexpr} and others have no issues with
  things such as |\xinttheiiexpr \x+\x\y\relax|.\hfill
  \endgroup

\item\label{fn:expansions} using |\if...\fi| constructs \emph{inside} the
  package macro arguments requires suitably mastering \TeX niques
  (|\expandafter|'s and/or swapping techniques) to ensure that the \fexpan sion
  will indeed absorb the \csa{else} or closing \csa{fi}, else some error will
  arise in further processing. Therefore it is highly recommended to use the
  package provided conditionals such as \csbxint{ifEq}, \csbxint{ifGt},
  \csbxint{ifSgn},\dots\ or, for \LaTeX{} users and when dealing
  with short integers the
  \ctanpackage{etoolbox}%
%
\footnote{\url{https://ctan.org/pkg/etoolbox}}
  expandable conditionals (for small integers only) such as \texttt{\char92
    ifnumequal}, \texttt{\char92 ifnumgreater}, \dots . Use of
  \emph{non-expandable} things such as \csa{ifthenelse} is impossible inside the
  arguments of \xintname macros.

  \begingroup\slshape
  One can use naive |\if..\fi| things inside an \csbxint{theexpr}-ession
  and cousins,  as long as the test is
  expandable, for example\upshape
%
\leftedline{|\xinttheiexpr\ifnum3>2 143\else 33\fi
  0^2\relax|$\to$\dtt{\xinttheiexpr \ifnum3>2 143\else 33\fi 0^2\relax
    =1430\char`\^2}}
%
  \endgroup

\item after the definition |\def\x {12}|, one can not use
  {\color{blue}|-\x|} as input to one of the package macros: the \fexpan sion
  will act only on the minus sign, hence do nothing. The only way is to use the
  \csbxint{Opp} macro (or \csbxint{iiOpp} which is integer only)
  which obtains the opposite of a given number.

  \begingroup\slshape
  Again, this is otherwise inside an \csbxint{theexpr}-ession or
  \csbxint{thefloatexpr}-ession. There, the
  minus sign may prefix macros which will expand to numbers (or parentheses
  etc...)
  \endgroup

\def\x {12}%
\def\AplusBC #1#2#3{\xintAdd {#1}{\xintMul {#2}{#3}}}%

\item \label{item:xpxp} With the definition
%
\leftedline{|\def\AplusBC #1#2#3{\xintAdd {#1}{\xintMul {#2}{#3}}}|}
%
one obtains an
  expandable macro producing the expected result, not in two, but rather in
  three steps: a first expansion is consumed by the macro expanding to its
  definition. As the package macros expand their arguments until no more is
  possible (regarding what comes first), this |\AplusBC| may be used inside
  them: {|\xintAdd {\AplusBC {1}{2}{3}}{4}|} does work and returns
  \dtt{\xintAdd {\AplusBC {1}{2}{3}}{4}}.

  If, for some reason, it is important to create a macro expanding in two steps
  to its final value, one may either do:
%
\smallskip
%
\leftedline {|\def\AplusBC #1#2#3{\romannumeral-`0\xintAdd {#1}{\xintMul
      {#2}{#3}}}|}
%
or use the \emph{lowercase} form of \csa{xintAdd}:
%
\smallskip
%
\leftedline {|\def\AplusBC #1#2#3{\romannumeral0\xintadd {#1}{\xintMul
      {#2}{#3}}}|}

  and then \csa{AplusBC} will share the same properties as do the
  other \xintname `primitive' macros.

\item
The |\romannumeral0| and |\romannumeral-`0| things above look like an invitation
to hacker's territory; if it is not important that the macro expands in two
steps only, there is no reason to follow these guidelines. Just chain
arbitrarily the package macros, and the new ones will be completely expandable
and usable one within the other.

Since release |1.07| the \csbxint{NewExpr} macro automatizes the creation of
such expandable macros:
%
\leftedline{|\xintNewExpr\AplusBC[3]{#1+#2*#3}|}
%
creates the |\AplusBC| macro doing the above and expanding in two expansion
steps.

\item In the expression parsers of \xintexprname such as
  \csbxint{expr}|..\relax|, \csbxint{floatexpr}|..\relax| the contents are
  expanded completely from left to right until the ending |\relax| is found
  and swallowed, and spaces and even (to some extent) catcodes do not matter.

\item For all variants, prefixing with \csbxint{the} allows to print the
  result or use it in other contexts. Shortcuts \csbxint{theexpr},
  \csbxint{thefloatexpr}, \csbxint{theiiexpr}, \dots\ are available.

\end{enumerate}

\subsection {Input formats for macros}\label{ssec:inputs}

Macros can have different types of arguments (we do not consider here the
\csbxint{expr}-parsers but only the macros of
\xintcorename/\xintname/\xintfracname). In a macro description, a
margin annotation signals what is the argument type.
\begin{enumerate}
\item \TeX\ integers\ntype{\numx} are handled inside a |\numexpr..\relax|
  hence may be count registers or variables. Beware that |-(1+1)| is not legal
  and raises an error, but |0-(1+1)| is. Also |2\cnta| with |\cnta| a |\count|
  isn't legal. Integers must be kept less than \dtt{\number "7FFFFFFF} in
  absolute value, although the \emph{scaling} operation |(a*b)/c| computes the
  intermediate product with twice as many bits.

  The slash |/| does a \fbox{rounded} division which is a fact of life of
  |\numexpr| which I have found very annoying in at least nine cases out of
  ten, not to say ninety-nine cases out of one hundred. Besides, it is at odds
  with \TeX's |\divide| which does a truncated division (non-expandably).

  But to follow-suit |/| also does rounded integer division in
  \csbxint{iiexpr}|..\relax|, and the operator |//| does there the truncated
  division.

\item the strict format\ntype{f} applies to macros handling big integers but
  only \fexpan ding their arguments. After this \fexpan sion the input should
  be a string of digits, optionally preceded by a unique minus sign. The first
  digit can be zero only if it is the only digit. A plus sign is not accepted.
  |-0| is not legal in the strict format. Macros of \xintname with a double
  |ii| require this `strict' format for the inputs.

\item the extended integer format\ntype{\Numf} applies when the macro parses
  its arguments via \csbxint{Num}. The input may then have arbitrarily many
  leading minus and plus signs, followed by leading zeroes, and further
  digits. With \xintfracname loaded, \csbxint{Num} is extended to
  accept fractions and its action is to truncate them to integers.

\item the fraction input format\ntype{\Ff} applies to the arguments of
  \xintfracname macros handling genuine fractions. It allows two types
  of inputs: general and restricted. The restricted type is parsed faster,
  but...\@{} is restricted.
  \begin{description}
  \item[general:] inputs of the shape |A.BeC/D.EeF|. Example:
\begin{everbatim*}
\noindent\xintRaw{+--0367.8920280e17/-++278.289287e-15}\newline
\xintRaw{+--+1253.2782e++--3/---0087.123e---5}\par
\end{everbatim*}
    The input parser does not reduce fractions to smallest terms.
    Here are the rules of this general fraction format:
    \begin{itemize}
    \item everything is optional, absent numbers are treated as zero, here are
      some extreme cases:
\begin{everbatim*}
\xintRaw{}, \xintRaw{.}, \xintRaw{./1.e}, \xintRaw{-.e}, \xintRaw{e/-1}
\end{everbatim*}
    \item |AB| and |DE| may start with pluses and minuses, then leading
      zeroes, then digits.
    \item |C| and |F| will be given to |\numexpr| and can be anything
      recognized as such and not provoking arithmetic overflow (the lengths of
      |B| and |E| will also intervene to build the final exponent naturally
      which must obey the \TeX{} bound).
    \item the |/|, |.| (numerator and/or denominator) and |e|
      (numerator and/or denominator) are all optional components.
    \item each of |A|, |B|, |C|, |D|, |E| and |F| may arise from \fexpan sion
      of a macro.
    \item the whole thing may arise from \fexpan sion, however the |/|, |.|,
      and |e| should all come from this initial expansion. The |e| of
      scientific notation is mandatorily lowercased.
    \end{itemize}
  \item[restricted:] inputs either of the shape |A[N]| or |A/B[N]|, which
    represents the fraction |A/B| times |10^N|. The whole thing or
    each of |A|, |B|, |N| (but then not |/| or |[|) may arise from \fexpan
    sion, |A| (after expansion) \emph{must} have a unique optional minus sign
    and no leading zeroes, |B| (after expansion) if present \emph{must} be a
    positive integer with no signs and no leading zeroes, |[N]| if present
     will be given to |\numexpr|. Any deviation from the rules above will
     result in errors.
  \end{description}
  Notice that |*|, |+| and |-| contrarily to the |/| (which is treated simply
  as a kind of delimiter) are not acceptable within arguments of this
  type\ntype{\Ff} (see \autoref{sec:useofcount}
   for some exceptions to this.)
\end{enumerate}

Generally speaking, there should be no spaces among the digits in the inputs
(in arguments to the package macros). Although most would be harmless in most
macros, there are some cases where spaces could break havoc.%
\footnote{The \csbxint{Num} macro does not remove spaces between digits beyond
  the first non zero ones; however this should not really alter the subsequent
  functioning of the arithmetic macros, and besides, since \xintcorename 1.2
  there is an initial parsing of the entire number, during which spaces will
  be gobbled. However I have not done a complete review of the legacy code to
  be certain of all possibilities after |1.2| release. One thing to be aware
  of is that \csa{numexpr} stops on spaces between digits (although it
  provokes an expansion to see if an infix operator follows); the exponent for
  \csbxint{iiPow} or the argument of the factorial \csbxint{iiFac} are only
  subjected to such a \csa{numexpr} (there are a few other macros with such
  input types in \xintname). If the input is given as, say |1 2\x| where
  \csa{x} is a macro, the macro \csa{x} will not be expanded by the
  \csa{numexpr}, and this will surely cause problems afterwards. Perhaps a
  later \xintname will force \csa{numexpr} to expand beyond spaces, but I
  decided that was not really worth the effort. Another immediate cause of
  problems is an input of the type |\xintiiAdd{<space>\x}{\y}|, because the
  space will stop the initial expansion; this will most certainly cause an
  arithmetic overflow later when the \csa{x} will be expanded in a
  \csa{numexpr}. Thus in conclusion, damages due to spaces are unlikely if
  only explicit digits are involved in the inputs, or arguments are single
  macros with no preceding space.}
So the best is to avoid them entirely.

This is entirely otherwise inside an |\xintexpr|-ession, where spaces are
ignored (except when they occur inside arguments to some macros, thus
escaping the |\xintexpr| parser). See the \autoref{sec:expr}.

There are also some slighly more obscure expansion types: in particular, the
\csbxint{ApplyInline} and \csbxint{For*} macros from \xinttoolsname apply a
special iterated \fexpan sion, which gobbles spaces, to the non-braced items
(braced items are submitted to no expansion because the opening brace stops
it) coming from their list argument; this is denoted by a special
symbol\ntype{{\lowast f}} in the margin. Some other macros such as
\csbxint{Sum} from \xintfracname first do an \fexpan sion, then treat each
found (braced or not) item (skipping spaces between such items) via the
general fraction input parsing, this is signaled as
here\ntype{f{$\to$}{\lowast\Ff}} in the margin where the signification of the
\lowast{} is thus a bit different from the previous case.

A few macros from \xinttoolsname do not expand, or expand only once their
argument\ntype{n{{\color{black}\upshape, resp.}} o}. This is also
signaled in the margin with notations \`a la \LaTeX3.


\subsection{Output formats of macros}
\label{ssec:outputs}

We do not consider here the \csbxint{expr}-parsers but only the macros from \xintcorename, \xintname and \xintfracname. Macros of other
components of the bundle may have their own output formats, for example for
continuous fractions with \xintcfracname.
There are mainly three types of outputs:%

\begin{itemize}[nosep,listparindent=\leftmarginiii]
\item arithmetic macros from \xintcorename/\xintname deliver integers
 in the strict format as described in the previous section.
\item arithmetic macros from \xintfracname produce on output the strict
fraction format |A/B[N]|, which stands for |(A/B)|$\times$|10^N|, where |A|
and |B| are integers, |B| is positive, and |N| is a ``short'' integer. The
output is not reduced to smallest terms. The |A| and |B| may end with zeroes
(\emph{i.e}, |N| does not represent all powers of ten). The denominator |B| is
always strictly positive. There is no |+| sign. The |-| is always first if
present (i.e.\@{} the denominator on output is always positive.) The output will
be expressed as such a fraction even if the inputs are both integers and the
mathematical result is an integer. The |B=1| is not removed.%
%
\footnote{refer to the documentation of \csbxint{PRaw} for an alternative.}
\item macros from \xintfracname having |Float| in their names deliver a number
  in the scientific notation as described in the documentation of
  \csbxint{Float}.

  The exception is \csbxint{PFloat} which does some customizable pretty
  printing of the result.
\end{itemize}

\subsection{Count registers and variables}\label{sec:useofcount}

Inside |\xintexpr..\relax| and its variants, a count register or count control
sequence is automatically unpacked using |\number|, with tacit multiplication:
|1.23\counta| is like |1.23*\number\counta|. There
is a subtle difference between count \emph{registers} and count
\emph{variables}. In |1.23*\counta| the unpacked |\counta| variable defines a
complete operand thus |1.23*\counta 7| is a syntax error. But |1.23*\count0|
just replaces |\count0| by |\number\count0| hence |1.23*\count0 7| is like
|1.23*57| if |\count0| contains the integer value |5|.

Regarding now the package macros, there is first the case of arguments having to
be short integers: this means that they are fed to a |\numexpr...\relax|, hence
submitted to a \emph{complete expansion} which must deliver an integer, and
count registers and even algebraic expressions with them like
|\mycountA+\mycountB*17-\mycountC/12+\mycountD| are admissible arguments (the
slash stands here for the rounded integer division done by |\numexpr|). This
applies in particular to the number of digits to truncate or round with, to the
indices of a series partial sum, \dots

The macros allowing the extended format for long numbers or dealing with
fractions will \emph{to some extent} allow the direct use of count
registers and even infix algebra inside their arguments: a count
register |\mycountA| or |\count 255| is admissible as numerator or also as
denominator, with no need to be prefixed by |\the| or |\number|. It is possible
to have as argument an algebraic expression as would be acceptable by a
|\numexpr...\relax|, under this condition: \emph{each of the numerator and
  denominator is expressed with at most \emph{nine}
  tokens}.%
%
\footnote{The |1.2k| and earlier versions manual claimed up to 8
  tokens, but low-level TeX error arose if the |\numexpr...\relax| occupied
  exactly 8 tokens \emph{and} evaluated to zero. With |1.2l| and later, up to
  9 tokens are always safe and one may even drop the ending |\relax|. But
  well, all these explanations are somewhat silly because prefixing by |\the|
  or |\number| is always working with arbitrarily many tokens.}
%
%
\footnote{Attention! in the \LaTeX{} context a
  \csa{value}\texttt{\{countername\}} will behave ok only if it is first in
  the input, if not it will not get expanded, and braces around the name will
  be removed and chaos\IMPORTANT{} will ensue inside a \csa{numexpr}. One
  should enclose the whole input in \csa{the}\csa{numexpr}|...|\csa{relax} in
  such cases.}
%
Important: a slash for rounded division in a |\numexpr| should be written with
braces |{/}| to not be confused with the \xintfracname delimiter between
numerator and denominator (braces will be removed internally and the slash
will count for one token). Example:
|\mycountA+\mycountB{/}17/1+\mycountA*\mycountB|, or |\count 0+\count
2{/}17/1+\count 0*\count 2|.
%
\leftedline{|\cnta 10 \cntb 35 \xintRaw
  {\cnta+\cntb{/}17/1+\cnta*\cntb}|\dtt{->\cnta 10 \cntb 35 \xintRaw
    {\cnta+\cntb{/}17/1+\cnta*\cntb}}}
%
For longer algebraic expressions using
count registers, there are two possibilities:
\begin{enumerate}[nosep]
\item let the numerator and the denominator be presented as |\the\numexpr...\relax|,
\item or as |\numexpr {...}\relax| (the braces are removed during processing;
  they are not legal for |\numexpr...\relax| syntax.)
\end{enumerate}
\everb|@
\cnta 100 \cntb 10 \cntc 1
\xintPRaw {\numexpr {\cnta*\cnta+\cntb*\cntb+\cntc*\cntc+
                    2*\cnta*\cntb+2*\cnta*\cntc+2*\cntb*\cntc}\relax/%
          \numexpr {\cnta*\cnta+\cntb*\cntb+\cntc*\cntc}\relax }
|
\cnta 100 \cntb 10 \cntc 1
%
\leftedline{\dtt{\xintPRaw {\numexpr
      {\cnta*\cnta+\cntb*\cntb+\cntc*\cntc+
                    2*\cnta*\cntb+2*\cnta*\cntc+2*\cntb*\cntc}\relax/%
          \numexpr {\cnta*\cnta+\cntb*\cntb+\cntc*\cntc}\relax }}}

\subsection{Dimension registers and variables}
\label{sec:Dimensions}

\meta{dimen} variables can be converted into (short) integers suitable for the
\xintname macros by prefixing them with |\number|. This transforms a dimension
into an explicit short integer which is its value in terms of the |sp| unit
($1/65536$\,|pt|).
When |\number| is applied to a \meta{glue} variable, the stretch and shrink
components are lost.

For \LaTeX{} users: a length is a \meta{glue} variable, prefixing a
length macro defined by \csa{newlength} with \csa{number} will thus discard
the |plus| and |minus| glue components and return the dimension component as
described above, and usable in the \xintbundlename macros.

This conversion is done automatically inside an
|\xintexpr|-essions, with tacit multiplication implied if prefixed by some
(integral or decimal) number.

One may thus compute areas or volumes with no limitations, in units of |sp^2|
respectively |sp^3|, do arithmetic with them, compare them, etc..., and possibly
express some final result back in another unit, with the suitable conversion
factor and a rounding to a given number of decimal places.

A \hyperref[tableofdimensions]{table of dimensions} illustrates that the
internal values used by \TeX{} do not correspond always to the closest
rounding. For example a millimeter exact value in terms of |sp| units is
\dtt{72.27/10/2.54*65536=\xinttheexpr trunc(72.27/10/2.54*65536,3)\relax ...}
and \TeX{} uses internally \dtt{\number\dimexpr 1mm\relax}|sp| (\TeX{}
truncates to get an integral multiple of the |sp| unit; see at the end of this
section the exact rules applied internally by \TeX).

\begin{figure*}[ht!]
\phantomsection\label{tableofdimensions}
\begingroup\let\ignorespaces\empty
           \let\unskip\empty
           \def\T{\expandafter\TT\number\dimexpr}
           \def\TT#1!{\gdef\tempT{#1}}
           \def\E{\expandafter\expandafter\expandafter
                  \EE\xintexpr reduce(}
           \def\EE#1!{\gdef\tempE{#1}}
\centeredline{\begin{tabular}{%
                >{\bfseries\strut}c%
                c%
                >{\E}c<{)\relax!}@{}%
                >{\xintthe\tempE}r@{${}={}$}%
                >{\xinttheexpr trunc(\tempE,3)\relax...}l%
                >{\T}c<{!}@{}%
                >{\tempT}r%
                >{\xinttheexpr round(100*(\tempT-\tempE)/\tempE,4)\relax\%}c}
   \hline
   Unit&%
   definition&%
   \omit &%
   \multicolumn{2}{c}{Exact value in \texttt{sp} units\strut}&%
   \omit &%
   \omit\parbox{2cm}{\centering\strut\TeX's value in \texttt{sp} units\strut}&%
   \omit\parbox{2cm}{\centering\strut Relative error\strut}\\\hline
  cm&0.01 m&72.27/2.54*65536&&&1cm&&\\
  mm&0.001 m&72.27/10/2.54*65536&&&1mm&&\\
  in&2.54 cm&72.27*65536&&&1in&&\\
  pc&12 pt&12*65536&&&1pc&&\\
  pt&1/72.27 in&65536&&&1pt&&\\
  bp&1/72 in&72.27*65536/72&&&1bp&&\\
  \omit\hfil\llap{3}bp\strut\hfil&1/24 in&72.27*65536/24&&&3bp&&\\
  \omit\hfil\llap{12}bp\strut\hfil&1/6 in&72.27*65536/6&&&12bp&&\\
  \omit\hfil\llap{72}bp\strut\hfil&1 in&72.27*65536&&&72bp&&\\
  dd&1238/1157 pt&1238/1157*65536&&&1dd&&\\
  \omit\hfil\llap{11}dd\strut\hfil&11*1238/1157 pt&11*1238/1157*65536&&&11dd&&\\
  \omit\hfil\llap{12}dd\strut\hfil&12*1238/1157 pt&12*1238/1157*65536&&&12dd&&\\
  sp&1/65536 pt&1&&&1sp&&\\\hline
  \multicolumn{8}{c}{\bfseries\large\TeX{} \strut dimensions}\\\hline
\end{tabular}}
\endgroup
\end{figure*}

There is something quite amusing with the Didot point. According to the \TeX
Book, $1157$\,|dd|=$1238$\,|pt|. The actual internal value of $1$\,|dd| in \TeX{} is $70124$\,|sp|. We can use \xintcfracname to display the list of
centered convergents of the fraction $70124/65536$:
%
\leftedline{|\xintListWithSep{, }{\xintFtoCCv{70124/65536}}|}
%
\xintFor* #1 in {\xintFtoCCv{70124/65536}}\do {$\printnumber{#1}$, }%
and we don't find
$1238/1157$ therein, but another approximant $1452/1357$!

And indeed multiplying $70124/65536$ by $1157$, and respectively $1357$, we find
the approximations (wait for more, later):
%
\leftedline{``$1157$\,|dd|''\dtt{=\xinttheexpr trunc(1157\dimexpr
    1dd\relax/\dimexpr 1pt\relax,12)\relax}\dots|pt|}
%
\leftedline{``$1357$\,|dd|''\dtt{=\xinttheexpr trunc(1357\dimexpr
    1dd\relax/\dimexpr 1pt\relax,12)\relax}\dots|pt|}
%
and we seemingly discover that $1357$\,|dd|=$1452$\,|pt| is \emph{far more
  accurate} than
the \TeX Book formula $1157$\,|dd|=$1238$\,|pt|~!
The formula to compute $N$\,|dd| was
%
\leftedline{|\xinttheexpr trunc(N\dimexpr 1dd\relax/\dimexpr
  1pt\relax,12)\relax}|}
%

What's the catch? The catch is that \TeX{} \emph{does not} compute $1157$\,|dd|
like we just did:%
%
\leftedline{$1157$\,|dd|=|\number\dimexpr 1157dd\relax/65536|%
      \dtt{=\xintTrunc{12}{\number\dimexpr 1157dd\relax/65536}}\dots|pt|}
%
\leftedline{$1357$\,|dd|=|\number\dimexpr 1357dd\relax/65536|%
      \dtt{=\xintTrunc{12}{\number\dimexpr 1357dd\relax/65536}}\dots|pt|}
%
We thus discover that \TeX{} (or rather here, e-\TeX{}, but one can check that
this works the same in \TeX82), uses  $1238/1157$ as a conversion
factor (and necessarily intermediate computations simulate higher precision
than a priori available with  integers less than $2^{31}$ or rather $2^{30}$ for
dimensions). Hence the $1452/1357$ ratio is irrelevant, an artefact
of the rounding (or rather, as we see, truncating) for one |dd| to be
expressed as an integral number of |sp|'s.

Let us now
use |\xintexpr| to compute the value of the Didot point in millimeters, if
the above rule is exactly verified:
%
\leftedline{|\xinttheexpr
 trunc(1238/1157*25.4/72.27,12)\relax|%
  \dtt{=\xinttheexpr trunc(1238/1157*25.4/72.27,12)\relax}|...mm|}
%
This fits very well with the possible values of the Didot point as listed in
the
\href{http://en.wikipedia.org/wiki/Point_%28typography%29#Didot}{Wikipedia Article}.
%
The value $0.376065$\,|mm| is said to be \emph{the traditional value in
  European printers' offices}. So the $1157$\,|dd|=$1238$\,|pt| rule refers to
this Didot point, or more precisely to the \emph{conversion factor} to be used
between this Didot and \TeX{} points.

The actual value in millimeters of exactly one Didot point as implemented in
\TeX{} is
%
\leftedline {|\xinttheexpr trunc(\dimexpr
  1dd\relax/65536/72.27*25.4,12)\relax|}
%
\leftedline{\dtt{=\xinttheexpr trunc(\dimexpr
    1dd\relax/65536/72.27*25.4,12)\relax}|...mm|}
%
The difference of circa $5$\AA\ is arguably tiny!

% 543564351/508000000

By the way the \emph{European printers' offices \emph{(dixit Wikipedia)}
  Didot} is thus exactly
%
\leftedline{|\xinttheexpr reduce(.376065/(25.4/72.27))\relax|%
   \dtt{=\xinttheexpr reduce(.376065/(25.4/72.27))\relax}\,|pt|}
%
and the centered convergents of this fraction are \xintFor* #1 in
{\xintFtoCCv{543564351/508000000}}\do {\dtt{\printnumber{#1}}\xintifForLast{.}{, }} We do
recover the $1238/1157$ therein!

\begin{framed}
  Here is how \TeX\ converts |abc.xyz...<unit>|. First the decimal is
  \emph{rounded} to the nearest integral multiple of |1/65536|, say |X/65536|.
  The |<unit>| is associated to a ratio |N/D|, which represents |<unit>/pt|.
  For the Didot point the ratio is indeed |1238/1157|. \TeX\ \emph{truncates}
  the fraction |XN/D| to an integer |M|. The dimension is represented by |M
  sp|.

\end{framed}


\subsection{\csh{ifcase}, \csh{ifnum}, \texorpdfstring{...\@}{...} constructs}\label{sec:ifcase}

When using things such as |\ifcase \xintSgn{\A}| one has to make sure to leave
a space after the closing brace for \TeX{} to
stop its scanning for a number: once \TeX{} has finished expanding
|\xintSgn{\A}| and has so far obtained either |1|, |0|, or |-1|, a
space (or something `unexpandable') must stop it looking for more
digits. Using |\ifcase\xintSgn\A| without the braces is very dangerous,
because the blanks (including the end of line) following |\A| will be
skipped and not serve to stop the number which |\ifcase| is looking for.
%
\begin{everbatim*}
\begin{enumerate}[nosep]\def\A{1}
\item \ifcase \xintSgn\A 0\or OK\else ERROR\fi
\item \ifcase \xintSgn\A\space 0\or OK\else ERROR\fi
\item \ifcase \xintSgn{\A} 0\or OK\else ERROR\fi
\end{enumerate}
\end{everbatim*}

In order to use successfully |\if...\fi| constructions either as arguments to
the \xintbundlename expandable macros, or when building up a completely
expandable macro of one's own, one needs some \TeX nical expertise (see also
\autoref{fn:expansions} on page~\pageref{fn:expansions}).

It is thus much to be recommended to use the expandable branching macros,
provided by \xintfracname succh as \csbxint{ifSgn}, \csbxint{ifZero},
\csbxint{ifOne}, \csbxint{ifNotZero}, \csbxint{ifTrueAelseB}, \csbxint{ifCmp},
\csbxint{ifGt}, \csbxint{ifLt}, \csbxint{ifEq},
\csbxint{ifInt}... See their respective documentations. All these conditionals
always have either two or three branches, and empty brace pairs |{}| for
unused branches should not be forgotten.

If these tests are to be applied to standard \TeX{} short integers, it is more
efficient to use (under \LaTeX{}) the equivalent conditional tests from the
\ctanpackage{etoolbox}%
%
\footnote{\url{https://ctan.org/pkg/etoolbox}}
package.

\subsection{No variable declarations are needed}

  There is no notion of a \emph{declaration of a variable}.

  To do a computation and assign its result to some macro |\z|, the user will employ the |\def|, |\edef|, or |\newcommand| (in \LaTeX)
  as usual, keeping in mind that two expansion steps are needed, thus |\edef|
  is initially the main tool:
%
\begin{everbatim*}
\def\x{1729728} \def\y{352827927} \edef\z{\xintiiMul {\x}{\y}}
\meaning\z
\end{everbatim*}

As an alternative to |\edef| the package provides |\oodef| which expands
exactly twice the replacement text, and |\fdef| which applies \fexpan sion to
the replacement text during the definition.
\begin{everbatim*}
\def\x{1729728}\def\y{352827927}
\oodef\w {\xintiiMul\x\y} \fdef\z{\xintiiMul {\x}{\y}}
\meaning\w, \meaning\z
\end{everbatim*}

In practice |\oodef| is slower than |\edef|, except for computations ending in
very big final replacement texts (thousands of digits). On the other hand
|\fdef|\IMPORTANT{} appears to be slightly faster than |\edef| already in the
case of expansions leading to only a few dozen digits.

\xintexprname does provide an interface to declare and assign values to
identifiers which can then be used in expressions: \autoref{xintdefvar}.


\subsection{Possible syntax errors to avoid}

\edef\x{\xintMul {3}{5}/\xintMul{7}{9}}

Here is a list of imaginable input errors. Some will cause compilation errors,
others are more annoying as they may pass through unsignaled.
\begin{itemize}
\item using |-| to prefix some macro: |-\xintiiSqr{35}/271|.%
%
\footnote{to the
    contrary, this \emph{is}
    allowed inside an |\xintexpr|-ession.}
\item using one pair of braces too many |\xintIrr{{\xintiiPow {3}{13}}/243}| (the
  computation goes through with no error signaled, but the result is completely
  wrong).
\item things like |\xintiiAdd { \x}{\y}| as the space will cause \csa{x} to be
  expanded later, most probably within a |\numexpr| thus provoking possibly an
  arithmetic overflow.
\item using |[]| and decimal points at the same time |1.5/3.5[2]|, or with a
  sign in the denominator |3/-5[7]|. The scientific notation has no such
  restriction, the two inputs |1.5/-3.5e-2| and |-1.5e2/3.5| are equivalent:
  |\xintRaw{1.5/-3.5e-2}|\dtt{=\xintRaw{1.5/-3.5e-2}},
  |\xintRaw{-1.5e2/3.5}|\dtt{=\xintRaw{-1.5e2/3.5}}.
\item generally speaking, using in a context expecting an integer (possibly
  restricted to the \TeX{} bound) a macro or expression which returns a
  fraction: |\xinttheexpr 4/2\relax| outputs \dtt{\xinttheexpr 4/2\relax},
  not $2$. Use |\xintNum {\xinttheexpr 4/2\relax}| or |\xinttheiexpr 4/2\relax|
  (which rounds the result to the nearest integer, here, the result is already
  an integer) or |\xinttheiiexpr 4/2\relax|. Or, divide in your head |4| by
  |2| and insert the result directly in the \TeX{} source.
\end{itemize}

\subsection{Error messages}

In situations such as division by zero, the \TeX{} run will be interrupted
with some error message.  It conveys some short information on
the cause of the problem,%
%
\footnote{The wording of these messages has been last modified at |1.4m|.\CHANGED{1.4m}}
%
then an optimistic statement about a possible
recovery if the user (in interactive mode) simply hits the |<return>| key.
%
In non-interactive (|nonstopmode|) the \TeX{} run goes on uninterrupted and
the error data will be found in the compilation log.  Often, \xintname will
fall-back to using a zero value.  This is still an experimental feature.%
%
\footnote{Customizable handlers, error traps, error flags are implemented
  in embryonic form but without user interface since |1.2l| release.  This is
  not ready yet.}
%
\footnote{The |1.4g| new formatting implementation benefited from a May 2021
  thread at the \LaTeX3 site where expandable error messages were discussed,
  with in particular contributions of |@blefloch| and |@Skillmon|.}


The encouragements will be slightly better formatted if the run is with
\LaTeX\ compared to Plain \eTeX: Plain by default does not set the
|\newlinechar| which allows to issue linebreaks in messages at chosen
locations.  In the examples here, \ctanpackage{xintsession} is used, and it
loads \xintname in a way activating the nicer |\newlinechar| formatted
messages, even though it runs (a priori, but not necessarily) under Plain
\eTeX.
\begin{everbatim}
>>> 1/0;
Runaway argument?
! xint error: Division by zero: 1/0.
! Paragraph ended before \xint<...> is done, but will resume:
  hit <return> at the ? prompt to try fixing the error above
  which has been encountered before expansion was complete.
<to be read again> 
                   \par 
...
l.602 \xintsession
                  \endinput%^^M
? 
@_1     0
>>> (-1)^3.2;
Runaway argument?
! xint error: Fractional power 32/1[-1] of negative -1[0].
! Paragraph ended before \xint<...> is done, but will resume:
  hit <return> at the ? prompt to try fixing the error above
  which has been encountered before expansion was complete.
<to be read again> 
                   \par 
...
l.602 \xintsession
                  \endinput%^^M
? 
@_2     0
>>> cos 1);
Runaway argument?
! xint error: `cos1' unknown, say `Isome_var' or I use 0.
! Paragraph ended before \xint<...> is done, but will resume:
  hit <return> at the ? prompt to try fixing the error above
  which has been encountered before expansion was complete.
<to be read again> 
                   \par 
...
l.602 \xintsession
                  \endinput%^^M
? 
Runaway argument?
! xint error: Extra ) removed. Hit <return>, fingers crossed.
! Paragraph ended before \xint<...> is done, but will resume:
  hit <return> at the ? prompt to try fixing the error above
  which has been encountered before expansion was complete.
<to be read again> 
                   \par 
...
l.602 \xintsession
                  \endinput%^^M
? 
@_3     0
>>> 3=4;
Runaway argument?
! xint error: Expected an operator but got `='. Ignoring.
! Paragraph ended before \xint<...> is done, but will resume:
  hit <return> at the ? prompt to try fixing the error above
  which has been encountered before expansion was complete.
<to be read again> 
                   \par 
...
l.602 \xintsession
                  \endinput%^^M
? 
@_4     12
>>> &bye
\end{everbatim}

In the last example, tacit multiplication was applied as \xintexprname was
looking for an operator, got some invalid input and then a number.

Some constructs in \xintexprname-essions use delimited macros and there is
thus possibility in case of an ill-formed expression to end up beyond the
|\relax| end-marker. Such a situation can also occur from |\relax| being
swallowed by a non-terminated
|\numexpr|:
\begin{everbatim}
\xintexpr 3 + \numexpr 5+4\relax followed by some LaTeX code...
\end{everbatim}
The correct input is
\begin{everbatim}
\xintexpr 3 + \numexpr 5+4\relax\relax
\end{everbatim}
But people in their right mind will have done
\begin{everbatim}
\xintexpr 3 + 5 + 4\relax
\end{everbatim}
A few will have done the computation in their heads.

In such cases low-level errors will arise and may
lead to very cryptic messages; but nothing unusual or especially traumatizing
for the daring experienced \TeX/\LaTeX\ user, whose has seen zillions of
un-helpful error messages already in her daily practice of
\TeX/\LaTeX.


\subsection{Package namespace, catcodes}


This section reviews (probably with some omissions) important
miscellany regarding control sequence names and catcode matters and is
basically in its entirety a 
\begin{TeXnote}
\begin{itemize}
\item The bundle packages
  force the |\space| and |\empty|
  control sequences into having their default meanings as in Plain \TeX{} or
  \LaTeX2e formats.
\item Private macros (or internally used |\count| registers, and one private
  |\toks|) have names starting with |\xint_| or |\XINT_|.  Some, for legacy or
  technical reasons, have |\xint| or |\XINT| prefix with no underscore.
\item All public macros have their names starting with |\xint| except for:
    the \xintkernelname provided \hyperref[odef]{|\odef|},
    \hyperref[oodef]{|\oodef|}, \hyperref[fdef]{|\fdef|}.  If macros with
    these names already exist \xinttoolsname will not overwrite them. Their
    meanings are also available under the names \csbxint{odef}, \csbxint{oodef},
    etc...

\item For the \xintfracname macros to be able to parse their inputs, standard
  catcodes in the argument are assumed for the digits (of course), the plus
  and minus signs, the dot, the letter |e|, the forward slash, the square
  brackets.  Spaces should be avoided although they may go unnoticed
  sometimes.

\item For the \xintexprname expressions there is more leeway: the digit
  tokens must have their standard catcodes, the letters must have their
  standard catcodes for variable and function names to be recognized,
  but other characters may mostly have unusual (but not extreme like
  catcode zero or one) catcodes.  Active characters will be
  expanded and should usually be prefixed with |\string|.  But,
  if activated via Babel\NewWith{1.4n} this is not needed.

  A few syntax elements are implemented via delimited macros. So the
  comma, the equal sign and the closing parenthesis must have their
  normal catcodes for these syntax elements to work. |\string| won't do.

  Spaces are gobbled.  The |e| of scientific notation may be |E| on
  input, \xintfracname macros on the other hand will not recognize the
  |E|.

\item
  \csbxint{defvar} and \csbxint{deffunc} as they use automatically
  \csbxint{exprSafeCatcodes} and \csbxint{exprRestoreCatcodes} to temporarily
  set catcodes to safe values.

\item \csbxint{exprSafeCatcodes} and \csbxint{exprRestoreCatcodes} can be
  employed at user level too.

\item
At loading time the
  catcode configuration may be arbitrary as long as it satisfies the following
  requirements:
  \begin{itemize}[nosep]
  \item \dtt{\%} has its normal category code,
  \item \dtt{\char92} has its normal category code,
  \item Latin letters have their normal category code "letter",
  \item Digits have their normal category code "other".
  \end{itemize}
  Nothing more is assumed, for example |{| and |}| may have unusual catcodes
  at package loading time. This will be admittedly unusual especially in
  \LaTeX\ as |\usepackage{xintexpr}| would then have had to be replaced by
  something such as |\usepackage<xintexpr>|...

\item Loading the packages causes no insertion of space tokens.

\item The previous two items also apply to usage of \csbxint{reloadxintlog}
  and of \csbxint{reloadxinttrig}.
\end{itemize}
\end{TeXnote}

\subsection{Origins of the package}
\label{ssec:origins}

|2013/03/28.| Package |bigintcalc| by \textsc{Heiko Oberdiek} already
provides expandable arithmetic operations on \myenquote{big integers}, i.e. integers
beyond the \TeX\ bound $2^{31}-1$, so why another%
%
\footnote{this section was written before the \xintfracname package; the
  author is not aware of another package allowing expandable
  computations with arbitrarily big fractions.}
%
one?

I got started on this in early March 2013, via a thread on the
|c.t.tex| usenet group, where \textsc{Ulrich D\,i\,e\,z} used the
previously cited package together with a macro (|\ReverseOrder|)
which I had contributed to another thread.%
%
\footnote{the \csa{ReverseOrder} could be avoided in that circumstance,
  but it does play a crucial r\^ole here.}
%
What I had learned in this
other thread thanks to interaction with \textsc{Ulrich D\,i\,e\,z} and
\textsc{GL} on expandable manipulations of tokens motivated me to
try my hands at addition and multiplication.

I wrote macros \csa{bigMul} and \csa{bigAdd} which I posted to the
newsgroup; they appeared to work comparatively fast. These first
versions did not use the \eTeX{} \csa{numexpr} primitive, they worked
one digit at a time, having previously stored carry-arithmetic in
1200 macros.

I noticed that the |bigintcalc| package used \csa{numexpr}
if available, but (as far as I could tell) not
to do computations many digits at a time. Using \csa{numexpr} for
one digit at a time for \csa{bigAdd} and \csa{bigMul} slowed them
a tiny bit but avoided cluttering \TeX{} memory with the 1200
macros storing pre-computed digit arithmetic. I wondered if some speed
could be gained by using \csa{numexpr} to do four digits at a time
for elementary multiplications (as the maximal admissible number
for \csa{numexpr} has ten digits).

|2013/04/14|.\@{} This initial \xintname was followed by \xintfracname which
handled exactly fractions and decimal numbers.

|2013/05/25|.\@{} Later came \xintexprname and at the same time \xintfracname got
extended to handle floating point numbers.

|2013/11/22|.\@{} Later, \xinttoolsname was detached.

|2014/10/28|.\@{} Release |1.1| significantly extended the \xintexprname parsers.

|2015/10/10|.\@{} Release |1.2| rewrote the core integer routines which had
remained essentially unmodified, apart from a slight improvement of division
early 2014.

This |1.2| release also got its impulse from a fast
``reversing'' macro, which I wrote after my interest got awakened again as a
result of correspondence with Bruno \textsc{Le Floch} during September 2015:
this new reverse uses a \TeX nique which \emph{requires} the tokens to be
digits. I wrote a routine which works (expandably) in quasi-linear time, but a
less fancy |O(N^2)| variant which I developed concurrently proved to be faster
all the way up to perhaps $7000$ digits, thus I dropped the quasi-linear one.
The less fancy variant has the advantage that \xintname can handle numbers
with more than $19900$ digits (but not much more than $19950$). This is with
the current common values of the input save stack and maximal expansion depth:
$5000$ and $10000$ respectively.

\clearpage
\let\xintbundlenameUp\undefined
\csname xintkernelnameUp\endcsname
\section{Macros of the \xintkernelname package}
\RaisedLabel{sec:kernel}

\localtableofcontents

\subsection{Introduction}

The \xintkernelname package contains mainly the common code base for handling
the load-order of the bundle packages, the management of catcodes at loading
time, definition of common constants and macro utilities which are used
throughout the code etc ...\@{} it is automatically loaded by all packages of the
bundle.

It provides a few macros possibly useful in other contexts.

\subsection{\csh{odef}, \csh{oodef}, \csh{fdef}}
\label{odef}
\label{oodef}
\label{fdef}
\label{xintodef}
\label{xintoodef}
\label{xintfdef}

\csa{oodef}|\controlsequence {<stuff>}| does
\everb|@
    \expandafter\expandafter\expandafter\def
    \expandafter\expandafter\expandafter\controlsequence
    \expandafter\expandafter\expandafter{<stuff>}
|

This works only for a single
|\controlsequence|, with no parameter text, even without parameters. An
alternative would be:
\everb|@
\def\oodef #1#{\def\oodefparametertext{#1}%
               \expandafter\expandafter\expandafter\expandafter
               \expandafter\expandafter\expandafter\def
               \expandafter\expandafter\expandafter\oodefparametertext
               \expandafter\expandafter\expandafter }
|

\noindent
but it does not allow |\global| as prefix, and, besides, would have anyhow its
use (almost) limited to parameter texts without macro parameter tokens
(except if the expanded thing does not see them, or is designed to deal with
them).

There is a similar macro |\odef| with only one expansion of the replacement text
|<stuff>|, and |\fdef| which expands fully |<stuff>| using |\romannumeral-`0|.

They can be prefixed with |\global|. It appears than |\fdef| is generally a bit
faster than |\edef| when expanding macros from the \xintbundlename, when the
result has a few dozens of digits. |\oodef| needs thousands of digits it seems
to become competitive.

\xintkernelname will not define these macros if the control sequence names
already exist.  It provides them always under the names |\xintodef|,
|\xintoodef| and |\xintfdef| respectively.

\subsection{\csh{xintReverseOrder}}\label{xintReverseOrder}

\csa{xintReverseOrder}\marg{list}\etype{n} does not do any expansion of its
argument and just reverses the order of the tokens in the \meta{list}. Braces
are removed once and the enclosed material, now unbraced, does not get
reversed. Unprotected spaces (of any character code) are gobbled.
%
\leftedline{|\xintReverseOrder{\xintDigitsOf\xintiiPow {2}{100}\to\Stuff}|}
%
\leftedline{gives:
  \ttfamily{\string\Stuff\string\to1002\string\xintiiPow\string\xintDigitsOf}}

\xinttoolsname provides a variant \csbxint{RevWithBraces} which keeps brace
pairs in the output, and \fexpan ds its input first.

For inputs consisting only digit tokens, see \csbxint{ReverseDigits} from
\xintname.

\subsection{\csh{xintLength}}
\label{xintLength}

\csa{xintLength}\marg{list}\etype{n} counts how many tokens (or braced items)
there are (possibly none). It does no expansion of its argument, so to use it
to count things in the replacement text of a macro |\x| one should do
|\expandafter\xintLength\expandafter{\x}|. Blanks between items are not
counted. See also \csbxint{NthElt}|{0}| (from \xinttoolsname) 
which first \fexpan ds its argument and then applies the same code.
%
\leftedline{|\xintLength {\xintiiPow {2}{100}}|\dtt{=\xintLength
    {\xintiiPow{2}{100}}}}
%
\leftedline{${}\neq{}$|\xintLen {\xintiiPow {2}{100}}|\dtt{=\xintLen
    {\xintiiPow{2}{100}}}}

The maximal input size is limited by \TeX{} main memory (it seems to be
about half of the \TeX Live |main_memory| setting from file |texmf.cnf|.
Because \TeX{} main memory is also where the used format is stored, as
well as all additional defined macros, it will for example be
higher if compiling with |etex| (PDF\TeX{} in dvi mode) than with
|pdftex|. Testing expansion inside an |\edef| with |etex| the author
obtained with \TeX Live 2025 a limit of \dtt{2492667} tokens with |1.4n|.

\subsection{\csh{xintFirstItem}}
\label{xintFirstItem}

\csa{xintFirstItem}\marg{list}\etype{n} returns the first item of its
argument, one pair of braces removed. If the list has no items the output is
empty.

It does no expansion. For this and the next similar ones, see
|xintsource.pdf| for comments on limitations.

\subsection{\csh{xintLastItem}}
\label{xintLastItem}

Added at |1.2i|.

\csa{xintLastItem}\marg{list}\etype{n} returns the last item
of its argument, one pair of braces removed. If the list has no items the
output is empty.

It does no expansion, which should be obtained via suitable |\expandafter|'s.
See also \csbxint{NthElt}|{-1}| from \xinttoolsname which obtains the same
result (but with another code) after having however \fexpan ded its
argument first.

\subsection{\csh{xintFirstOne}}
\label{xintFirstOne}

\csa{xintFirstOne}\marg{list}\etype{n} returns the first item as a braced
item. i.e.\@{} if it was braced the braces are kept, else the braces are added.
It looks like using \csbxint{FirstItem} within braces, but the difference is
when the input was empty. Then the output is empty.

It does no expansion, which should be obtained via suitable |\expandafter|'s.

\subsection{\csh{xintLastOne}}
\label{xintLastOne}

\csa{xintLastOne}\marg{list}\etype{n} returns the last item as a braced
item. i.e.\@{} if it was braced the braces are kept, else the braces are added.
It looks like using \csbxint{LastItem} within braces, but the
difference is when the input was empty. Then the output is empty.

It does no expansion, which should be obtained via suitable |\expandafter|'s.

\subsection{\csh{xintReplicate}, \csh{xintreplicate}}
\label{xintreplicate}
\label{xintReplicate}

\csa{romannumeral}\csa{xintreplicate}|{x}|\marg{stuff}\etype{\numx n} is simply
copied over from \LaTeX3's |\prg_replicate:nn| with some minor changes.%
%
\footnote{I started with the code from Joseph \textsc{Wright}
available on an online site.}

And \csa{xintReplicate}|{x}| integrates the
\csa{romannumeral} prefix.

It
does not do any expansion of its second argument but inserts it in the upcoming
token stream precisely |x| times. Using it with a negative |x| raises no error
and does nothing.%
%
\footnote{This behaviour may change in future.}


 
\subsection{\csh{xintGobble}, \csh{xintgobble}}
\label{xintgobble}
\label{xintGobble}

\csa{romannumeral}\csa{xintgobble}|{x}|\etype{\numx} is a Gobbling macro
written in the spirit of \LaTeX3's |\prg_replicate:nn| (which I cloned as
\csbxint{replicate}.) It gobbles |x| tokens upstream, with |x| allowed to be
as large as \dtt{531440}. Don't use it with |x<0|.

And \csa{xintGobble}|{x}| integrates the \csa{romannumeral}.


\csbxint{gobble} looks as if it must be related to \csbxint{Trim} from
\xinttoolsname, but the latter uses different code (using directly
\csbxint{gobble} is not possible because one must make sure not to gobble more
than the number of available items; and counting available items first is an
overhead which \csbxint{Trim} avoids.) It is rather\csbxint{Keep} with a
negative first argument which hands over to \csbxint{gobble} (because in that
case it is needed to count anyhow beforehand the number of items, hence
\csbxint{gobble} can then be used safely.)

I wrote an \csa{xintcount} in the same spirit as \csa{xintreplicate} and
\csa{xintgobble}. But it needs to be counting hundreds of tokens to be worth
its salt compared to \csbxint{Length}.

\subsection{(WIP) \csh{xintUniformDeviate}}
\label{xintUniformDeviate}

\csa{xintUniformDeviate}|{x}|\etype{\numx} is based upon the engine
primitive, which is |\pdfuniformdeviate| with \PDFTeX{}, and
|\uniformdeviate| with \LuaTeX{} and \XeTeX{}. A common name for that
primitive is |\xinttexuniformdeviate|.  But \csbxint{UniformDeviate} is,
was will be explained designed to work around some features/limitations.

The argument is expanded in |\numexpr| and the macro itself needs two
expansion steps. It produces like the engine primitive an integer (digit
tokens) with minimal value \dtt{0} and maximal one \dtt{x-1} if |x| is
positive, or minimal value \dtt{x+1} and maximal value \dtt{0} if |x| is
negative. For the discussion next, |x| is supposed positive as this
avoids having to insert absolute values in formulas.

The underlying engine primitive (thus, |\xinttexuniformdeviate|)
accesses a random number generator (RNG) originally embedded into
MetaPost and described in \emph{The Art of Computer Programming,
  Vol. 2}.  During discussions with Bruno Le Floch in May 2018, when he
was adding to \LaTeX3 interface for randomness, the author became aware
of some limitations, some of them surprising, in the randomness of the
numbers produced by this RNG.  For example, the values produced by
|\pdfuniformdeviate 201326592| and reduction modulo three are in the
proportion |1:1:2|, not |1:1:1|.

Let's count how many 0's, 1's, and 2's we get from reducing modulo 3 the
output of |\xinttexuniformdeviate 201326592|.
\begin{everbatim*}
\xintsetrandomseed 87654321
\def\A{0}\def\B{0}\def\C{0}
\xintReplicate{504}{\ifcase\xinteval{(\xinttexuniformdeviate 201326592)/:3}
  \edef\A{\the\numexpr\A+1}\or
  \edef\B{\the\numexpr\B+1}\or
  \edef\C{\the\numexpr\C+1}\fi
}
We found \A{} 0's, \B{} 1's and \C{} 2's among 504 trials.
\end{everbatim*}

In contrast, here is what happens if using \csbxint{UniformDeviate}:
\begin{everbatim*}
\xintsetrandomseed 87654321
\def\A{0}\def\B{0}\def\C{0}
\xintReplicate{504}{\ifcase\xinteval{\xintUniformDeviate{201326592}/:3}
  \edef\A{\the\numexpr\A+1}\or
  \edef\B{\the\numexpr\B+1}\or
  \edef\C{\the\numexpr\C+1}\fi
}
We found \A{} 0's, \B{} 1's and \C{} 2's among 504 trials.
\end{everbatim*}

\begin{TeXnote}
The RNG works with 28-bits integers. To output a supposedly uniform
random integer in a given range \dtt{0..x-1}, it first produces a
supposedly uniform integer in the range \dtt{0..$2^{28}-1$} (where
\dtt{$2^{28}=268435456$}) then rescales (with rounding) to the target
range.
%
Note that with \dtt{$x=2^{29}$} this means in particular that all produced
``random numbers'' in the \dtt{0..x-1} range will be even...

But even with \dtt{$x=2^{28}$} there are some more serious defects of
the RNG: two seeds sharing the same low |k| bits generate sequences of
28-bits integers which are identical one-to-one modulo |2^k|! In
particular after setting the seed, there are only 2 distinct sequences
for the parity bits for the integers generated by |\pdfuniformdeviate
268435456| (or rather with |\xinttexuniformdeviate| if with another
engine than |pdftex|).

Let's define the non-uniformity of |\pdfuniformdeviate x| to be the
maximum, taken over all |y|'s from \dtt{0} to |x-1|, of $\string|x\times
\mathrm{Prob}($|\pdfuniformdeviate x|${}=y) - 1\string|$.  For a general
|x|, the engine primitive guarantees only a \dtt{$x/2^{28}$} relative
non-uniformity for the outputs of |\pdfuniformdeviate x|.

\csbxint{UniformDeviate} improves this by a factor of
\dtt{|2^{28}=|\number"10000000}: \emph{the relative non-uniformity now
  is guaranteed to be bounded above by \fbox{\dtt{$x/2^{56}$}}}.  With
such a small non-uniformity, modulo phenomena as mentioned earlier are
not observable in reasonable computing time.

%
% These estimates assume that the engine RNG underlying stream of
%   28-bits integers can be considered uniform; it is known that the
%   parity bits of these 28-bits integers have a period of |55(2^{55}-1)| and
%   that after that many draws the count of 1s has only an excess of 55 compared
%   to the count of 0s, so the scale seems to be an intrinsic non-uniformity of
%   |2^{-55}| but it is not obvious if it applies to much shorter ranges. At any
%   rate we assumed that the non-uniformity for |x| a power of two less than
%   |2^{28}| is negligible in comparison to |2^{-28}|. Bigger powers of 2
%   produce only even integers because the output is rescaled by
%   factor |x/2^{28}|!
%

The implementation of \csbxint{UniformDeviate} consumes exactly 5
calls to the engine primitive at each execution; the improved |x/2^{56}|
non-uniformity could be obtained with only 2 calls, but paranoïa about the
phenonemon of seeds with common bits has led me to accept the overhead of
using the 7 high bits of 4 random 28-bits integers, rather than one single
28-bits integer, or two, or three.

Timings indicate that one \csbxint{UniformDeviate} has a time cost about 13
times the one for one call to the engine primitive (and not only 5, as the
extra arithmetic expressions add overhead which is more costly than the
primitive itself). Except if the code using the pseudo-random number is very
short, this time penalty will prove in practice much less severe (and this is
one important reason why we opted for obtaining 28bits via the 7 high bits of
4 successive pseudo random numbers from the engine primitive).

For example
let's raise 100 times a random integer in the \dtt{0..99999999} range to the tenth power:%
%
\InputIfFileExists{JFBUORDI}{}{}%
\ifdefined\JFBUORDI
\footnote{%
          \if0\xintstrcmp{IMAC}{\JFBUORDI}Timings done during dvi build on a
          computer with a |2.8GHz| %
          %quadri-core
          cpu, old but still kicking, and with a locally compiled |latex| binary.\else
          \if0\xintstrcmp{MBA}{\JFBUORDI}Timings done during dvi build on a
          computer with a |2GHz| %
          %dual-core
          cpu, old but still kicking, and with a locally compiled |latex| binary.\else
          \if0\xintstrcmp{MBA-M4}{\JFBUORDI}Timings done during dvi build on an Apple laptop with M4 architecture.\else
          \if0\xintstrcmp{MINI}{\JFBUORDI}Timings done during dvi build on an Apple desktop with M4 Pro architecture.\else
          DOCUMENTATION SEEMINGLY BUILT NOT ON AN AUTHOR-OWNED SYSTEM, BUT \string\JFBUORDI\space IS DEFINED, WEIRD!\fi\fi\fi\fi
}
\else
\footnote{These timings are done during a build on a computer not belonging to the author.}
\fi
%
\begin{everbatim*}
\xintsetrandomseed 12345678
\xintresettimer
\xintReplicate{100}{\edef\foo{\xintiiPow{\xintUniformDeviate{100000000}}{10}}}%
\xinttheseconds s (if using \string\xintUniformDeviate)\newline
\xintsetrandomseed 12345678
\xintresettimer
\xintReplicate{100}{\edef\foo{\xintiiPow{\xinttexuniformdeviate 100000000}{10}}}%
\xinttheseconds s (if using \string\xinttexuniformdeviate)\par
\end{everbatim*}

The macros \csbxint{RandomDigits} or \csbxint{iiRandRange}, and their
variants, as well as the supporting macros for \func{random} generate random
decimal digits eight by eight as if using
\csbxint{UniformDeviate}|{100000000}|, but via a direct optimized call made
possibly by the range being a power of 10.
\end{TeXnote}

\clearpage
\let\xintkernelnameUp\undefined
\csname xintcorenameUp\endcsname
\def\n{|{N}|}
\def\m{|{M}|}
\def\x{|{x}|}
\section{Macros of the \xintcorename package}
\RaisedLabel{sec:core}

\localtableofcontents

\subsection{Introduction}

Package \xintcorename is automatically loaded by \xintname.

\xintcorename provides for big integers the four basic arithmetic operations
(addition, subtraction, multiplication, division), as well as powers and
factorials.

In the descriptions of the macros \texttt{\n} and \texttt{\m} stand
for (big) integers or macros \hyperref[ssec:expansions]{\fexpan ding} to
such big integers in strict format as described in \autoref{ssec:inputs}.

All macros require strict integer format on input and produce
strict integer format on output, except:\IMPORTANT
\begin{itemize}[nosep]
\item \csbxint{iNum} which converts to strict integer format an input in
  \emph{extended} integer format, i.e.\@{} admitting multiple leading plus or
  minus signs, then possibly leading zeroes, then digits,
\item and \csbxint{Num} which is an alias for the former, which gets redefined by
  \xintfracname to accept more generally also decimal numbers or fractions as
  input and which truncates them to integers.
\end{itemize}

The |ii| in the names of the macros such as \csbxint{iiAdd} serves to stress
that they accept only strict integers as input (this is signaled by the margin
annotation \textcolor[named]{PineGreen}{\emph{f}}), or macros \fexpan ding to
such strict format (big) integers and that they produce strict integers as
output.

Other macros, such as \csbxint{Double}, lack the |ii|, but this is only a
legacy of the history of the package and they have the same requirements for
input and format of output as the |ii|-macros.

The letter \texttt{x} (with margin annotation
\smash{\textcolor[named]{PineGreen}{\numx}}) stands for an argument which will
be handled embedded in |\numexpr..\relax|. It will thus be completely expanded
and must give an integer obeying the \TeX{} bounds. See also
\autoref{sec:useofcount}. This is the case for the argument of \csbxint{iiFac}
or the exponent argument of \csbxint{iiPow}.

The {\color[named]{PineGreen}$\star$}'s in the margin are there to remind of
the complete expandability, even \fexpan dability of the macros, as discussed
in \autoref{ssec:expansions}.

\autoref{tab:maxsizes} summarizes the maximal allowed sizes for the four
operations.  The first column is the tested macro (it is expanded in an
\csa{edef}; if deeper nested, the maximal admissible input sizes may
actually prove lower than stated).  The second column gives
the maximal |N| such that the macro does not raise an error on both
inputs having |N| digits (for division,
the used test divisors had |N/4|, |N/2| and |3N/4| digits).

These maximal |N|'s depend on the values of \TeX\ parameters such as
input stack size and expansion depth.  The last column gives the \TeX\
parameter cited in the error message when trying with |N+1| digits.

The table was last updated in July 2025, using |1.4m 2022/06/10| and
TeXLive 2025 default settings which are: input stack size at
\dtt{10000}, expansion depth at \dtt{10000}, parameter stack size at
\dtt{20000}.


\begin{table}[htbp]
\capstart
  \centering
\def\E#1#2!{\edef\F{\the\numexpr(#1-\xintLength{#2})/2}%
          \relax\romannumeral\xintreplicate{\F}{ }#2%
          \romannumeral\xintreplicate{#1-\F-\xintLength{#2}}{ }\relax}%
% non satisfactory because depends on #1 oddness, but well. Temporary destined
% to stay...
\begin{tabular}{r>{\E{19}}c<{!}r}
  \hline
  &Max\ length\ of\ inputs&Limiting factor\\
  \csbxint{iiAdd}&26648&expansion depth=10000\\
  \csbxint{iiSub}&26632&expansion depth=10000\\
  \csbxint{iiMul}&13320&expansion depth=10000\\
  \csbxint{iiDivision}&26609&expansion depth=10000\\
  \hline
\end{tabular}
\caption{Maximal sizes of inputs (using TeXLive 2025) for core arithmetic}\label{tab:maxsizes}
\end{table}

\subsection{\csh{xintiNum}}\label{xintiNum}

|\xintiNum|\n\etype{f} removes chains of plus or minus signs, followed by
zeroes.
\begin{everbatim*}
\xintiNum{+---++----+--000000000367941789479}
\end{everbatim*}

\subsection{\csh{xintDouble}}\label{xintDouble}

|\xintDouble|\n\etype{f} computes |2N|.

\subsection{\csh{xintHalf}}\label{xintHalf}

|\xintHalf|\n\etype{f} computes |N/2|
truncated towards zero.

\subsection{\csh{xintInc}}\label{xintInc}

|\xintInc|\n\etype{f} evaluates |N+1|.

\subsection{\csh{xintDec}}\label{xintDec}

|\xintDec|\n\etype{f} evaluates |N-1|.

\subsection{\csh{xintDSL}}\label{xintDSL}

|\xintDSL|\n\etype{f} is decimal shift left, \emph{i.e.\@} multiplication by
ten.

\subsection{\csh{xintDSR}}\label{xintDSR}

|\xintDSR|\n\etype{f} is truncated decimal shift right, \emph{i.e.\@} it is the
truncation of |N/10| towards zero.

\subsection{\csh{xintDSRr}}\label{xintDSRr}

|\xintDSRr|\n\etype{f} is rounded decimal shift right, \emph{i.e.\@} it is the
rounding of |N/10| away from zero. It is needed in \xintcorename for use by
\csbxint{iiDivRound}.

\subsection{\csh{xintFDg}}\label{xintFDg}

|\xintFDg|\n\etype{f} outputs the first digit (most significant) of the
number.

\subsection{\csh{xintLDg}}\label{xintLDg}

|\xintLDg|\n\etype{f} outputs the least significant digit. When the number
is positive, this is the same as the remainder in the Euclidean division by
ten.

\subsection{\csh{xintiiSgn}}\label{xintiiSgn}

|\xintiiSgn|\n\etype{f} returns 1 if the number is positive, 0 if it is zero
and -1 if it is negative.

\subsection{\csh{xintiiOpp}}\label{xintiiOpp}

|\xintiiOpp|\n\etype{f} outputs the opposite |-N| of the number |N|.

Important note: an input such as |-\foo| is not legal, generally speaking, as
argument to the macros of the \xintbundlename (except, naturally in
\csbxint{expr}-essions). The reason is that the minus sign stops the \fexpan
sion done during parsing of the inputs. One must use the syntax
|\xintiiOpp{\foo}| if one wants to pass |-\foo| as
argument to other macros.

\subsection{\csh{xintiiAbs}}\label{xintiiAbs}

|\xintiiAbs|\n\etype{f} outputs the absolute value of the number.

\subsection{\csh{xintiiAdd}}\label{xintiiAdd}

|\xintiiAdd|\n\m\etype{ff} computes the sum of the two (big) integers.

\subsection{\csh{xintiiCmp}}\label{xintiiCmp}

|\xintiiCmp|\n\m\etype{ff} produces \dtt{1} if |N>M|, \dtt{0} if |N=M|,
and \dtt{-1} if |N<M|.

At |1.2l| this macro was moved from package \xintname to \xintcorename.

\subsection{\csh{xintiiSub}}\label{xintiiSub}

|\xintiiSub|\n\m\etype{ff} computes the difference |N-M|.

\subsection{\csh{xintiiMul}}\label{xintiiMul}

|\xintiiMul|\n\m\etype{ff} computes the product of two (big) integers.

\subsection{\csh{xintiiSqr}}\label{xintiiSqr}

|\xintiiSqr|\n\etype{f} produces the square.

\subsection{\csh{xintiiPow}}\label{xintiiPow}

|\xintiiPow|\n\x\etype{f\numx} computes |N^x|. For |x=0|, this is 1. For |N=0|
and |x<0|, or if \verb+|N|>1+ and |x<0|, an error is raised. There will also
be an error if |x| exceeds the maximal \eTeX{} number \dtt{\number"7FFFFFFF},
but the real limit for exponents comes from either the computation time or the
settings of some \TeX\ memory parameters.

Generally speaking the computation will end in an error if the output goes
beyond what addition could accept on input, i.e.\@ (with \TeX Live 2025 default
settings) has more than about \dtt{26600} digits.

For example the maximal power of $2$ which \csbxint{iiPow} is able to compute
(with \TeX Live 2025 default memory parameters) is $2^{88470}$ which has
\dtt{26633} digits.  I.e.\@ |\edef\z{\xintiiPow{2}{88470}}| succeeds (if you
are patient enough to wait) but |\edef\z{\xintiiPow{2}{88471}}| fails.

\subsection{\csh{xintiiFac}}\label{xintiiFac}

|\xintiiFac|\x\etype{\numx} computes the factorial.

  The (theoretically) allowable range is $0\leqslant x\leqslant10000$.

  However the maximal possible computation depends on the values of some memory
  parameters of the \eTeX{} executable:
  with \xintcorename at |1.4m| and using \TeX Live 2025, the maximal
  (within an |\edef|) computable one is \dtt{7712!}\@ which has
  \dtt{26631} decimal digits.
  With the input stack size set at 10000, the limiting factor here is the
  expansion depth at 10000.




The \func{factorial} function, or equivalently \func{!} as post-fix operator is
available in the three parsers:
\begin{everbatim*}
\xinttheiiexpr factorial(30)\relax\par
\printnumber{\xinteval{200!}}\par
\end{everbatim*}
Within \csbxint{floateval}, the macro \csbxint{FloatFac} from package \xintfracname is used.
\begin{everbatim*}
\xintfloateval{200!}\par
\end{everbatim*}
\begin{everbatim*}
\xintfloateval{2000!}\par
\end{everbatim*}
See its documentation for more.



\subsection{\csh{xintiiDivision}}\label{xintiiDivision}


|\xintiiDivision|\m\n\etype{ff} produces |{quotient}{remainder}|, in the sense
of (mathematical) Euclidean division: |M = QN + R|,
|0|${}\leq{}$\verb+R < |N|+. So the remainder is always non-negative and the
formula |M = QN + R| always holds independently of the signs of |N| or |M|.
Division by zero is an error (even if |M| vanishes) and returns |{0}{0}|.

\subsection{\csh{xintiiQuo}}\label{xintiiQuo}

|\xintiiQuo|\m\n\etype{ff} computes the quotient from the Euclidean division.

\subsection{\csh{xintiiRem}}\label{xintiiRem}

|\xintiiRem|\m\n\etype{ff} computes the remainder from the Euclidean
division.

\subsection{\csh{xintiiDivRound}}\label{xintiiDivRound}

|\xintiiDivRound|\m\n\etype{ff} returns the rounded value of the algebraic
quotient $M/N$ of two big integers. The rounding is ``away from zero.''
\begin{everbatim*}
\xintiiDivRound {100}{3}, \xintiiDivRound {101}{3}
\end{everbatim*}

\subsection{\csh{xintiiDivTrunc}}\label{xintiiDivTrunc}

|\xintiiDivTrunc|\m\n\etype{ff} computes $trunc(M/N)$. For positive arguments
$M,N>0$ it is the same as the Euclidean quotient \csbxint{iiQuo}.
\begin{everbatim*}
\xintiiQuo{1000}{57} (Euclidean), \xintiiDivTrunc{1000}{57} (truncated),
\xintiiDivRound{1000}{57} (rounded)\newline
\xintiiQuo{-1000}{57}, \xintiiDivTrunc{-1000}{57} (t), \xintiiDivRound{-1000}{57} (r)
\newline
\xintiiQuo{1000}{-57}, \xintiiDivTrunc{1000}{-57} (t), \xintiiDivRound{1000}{-57} (r)
\newline
\xintiiQuo{-1000}{-57}, \xintiiDivTrunc{-1000}{-57} (t), \xintiiDivRound{-1000}{-57} (r)
\par
\end{everbatim*}

\subsection{\csh{xintiiDivFloor}}\label{xintiiDivFloor}

|\xintiiDivFloor|\m\n\etype{ff} computes $floor(M/N)$. For positive divisor
$N>0$ and arbitrary dividend $M$ it is the same as the Euclidean quotient
\csbxint{iiQuo}.
\begin{everbatim*}
\xintiiQuo{1000}{57} (Euclidean), \xintiiDivFloor{1000}{57} (floored)\newline
\xintiiQuo{-1000}{57}, \xintiiDivFloor{-1000}{57}\newline
\xintiiQuo{1000}{-57}, \xintiiDivFloor{1000}{-57}\newline
\xintiiQuo{-1000}{-57}, \xintiiDivFloor{-1000}{-57}\par
\end{everbatim*}

\subsection{\csh{xintiiMod}}\label{xintiiMod}

|\xintiiMod|\m\n\etype{ff} computes $M - N*floor(M/N)$. For positive divisor
$N>0$ and arbitrary dividend $M$ it is the same as the Euclidean remainder
\csbxint{iiRem}.

Formerly, this macro computed $M - N*trunc(M/N)$. The former meaning is
retained as \csa{xintiiModTrunc}.
\begin{everbatim*}
\xintiiRem {1000}{57} (Euclidean), \xintiiMod {1000}{57} (floored),
\xintiiModTrunc {1000}{57} (truncated)\newline
\xintiiRem {-1000}{57}, \xintiiMod {-1000}{57}, \xintiiModTrunc {-1000}{57}\newline
\xintiiRem {1000}{-57}, \xintiiMod {1000}{-57}, \xintiiModTrunc {1000}{-57}\newline
\xintiiRem {-1000}{-57}, \xintiiMod {-1000}{-57}, \xintiiModTrunc {-1000}{-57}\par
\end{everbatim*}

\subsection{\csh{xintNum}}\label{xintNum}

|\xintNum|\etype{f} is originally an alias for \csbxint{iNum}. But with
\xintfracname loaded its meaning is \hyperref[xintNumFrac]{modified} to accept
more general inputs. It then becomes an alias to \csbxint{TTrunc} which
truncates the general input to an integer in strict format.

\clearpage
\let\xintcorenameUp\undefined
\csname xintnameUp\endcsname
\def\n{|{N}|}
\def\m{|{M}|}
\def\x{|{x}|}
\section{Macros of the \xintname package}
\RaisedLabel{sec:xint}

\etocsetnexttocdepth{subsubsection}
\localtableofcontents

\subsection{Introduction}

This package loads automatically \xintcorename (and \xintkernelname) hence
all macros described in \autoref{sec:core} are still available.

This is \texttt{\xintbndlversion} of
\texttt{\xintbndldate}.

Version |1.0| was released |2013/03/28|.
Since |1.1 2014/10/28| the core arithmetic macros have been moved to a separate
package \xintcorename, which is automatically loaded by \xintname.
Only the \csbxint{iiSum}, \csbxint{iiPrd}, \csbxint{iiSquareRoot},
\csbxint{iiSqrt}, \csbxint{iiSqrtR},
\csbxint{iiPFactorial}, \csbxint{iiBinomial} genuinely add to the arithmetic
macros from \xintcorename. (\csbxint{iiFac} which computes factorials is
already in \xintcorename.)

With the exception of \csbxint{Len}, of the \myenquote{Boolean logic macros} (see
next paragraphs) all macros require inputs being integers in strict format, see \autoref{ssec:inputs}.%
%
\footnote{of
course for conditionals such as \csbxint{iiifCmp} this constraint applies only
to the first two arguments.}
%
The |ii| in the macro names is here as a reminder of that fact. The output is
an integer in strict format, or a pair of two braced such integers for
\csbxint{iiSquareRoot}, with the exception of \csbxint{iiE} which may produce
strings of zero's if its first argument is zero.

Macros \csbxint{DecSplit} and \csbxint{ReverseDigits} are non-arithmetic and
have their own specific rules.

For all macros described here for which it makes sense, package \xintfracname
defines a similar one without |ii| in its name. This will handle more general
inputs: decimal, scientific numbers, fractions. The |ii| macros provided here
by \xintname can be nested inside macros of \xintfracname but the opposite
does not apply, because the output format of the \xintfracname macros, even
for representing integers, is not understood by the |ii| macros. The \myenquote{Boolean
macros} \csbxint{AND} etc...\@{} are exceptions though, they work fine if served
as inputs some \xintfracname output, despite doing only \fexpan
sion. Prior to |1.2o|, these macros did apply the \csbxint{Num}
or the more general \xintfracname general parsing, but this overhead was
deemed superfluous as it serves only to handle hand-written input and is not
needed if the input is obtained as a nested chain of \xintfracname macros for
example.

Prior to release |1.2o|, \xintname defined additional macros which applied
\csbxint{Num} to their input arguments. All these macros were deprecated at
|1.2o| and have been removed at |1.3|.

At |1.3d| macros \csbxint{iiGCD} and \csbxint{iiLCM} from package \xintgcdname
are also available from loading \xintname only. They are support macros for
the (multi-arguments) functions \func{gcd} and \func{lcm} in \csbxint{iiexpr}.

See \autoref{ssec:expansions} for the significance of the
\textcolor[named]{PineGreen}{\Numf}, \textcolor[named]{PineGreen}{\emph{f}},
\textcolor[named]{PineGreen}{\numx} and \textcolor[named]{PineGreen}{$\star$}
margin annotations.





\subsection{\csh{xintiLen}}\label{xintiLen}

|\xintiLen|\n\etype{\Numf} returns the length of the number, after its parsing
via \csbxint{iNum}. The count does not include the sign.
\begin{everbatim*}
\xintiLen{-12345678901234567890123456789}
\end{everbatim*}

Prior to |1.2o|, the package defined only \csbxint{Len}, which is extended by
\xintfracname to fractions or decimal numbers, hence acquires a bit more
overhead then.

\subsection{\csh{xintReverseDigits}} \label{xintReverseDigits}

\the\dp\strutbox, \the\ht\strutbox, \the\baselineskip

|\xintReverseDigits|\n\etype{f} will reverse the order of the digits of the
number. \csa{xintRev} is the former denomination and is kept as an alias.
Leading zeroes resulting from the operation are not removed. Contrarily to
\csbxint{ReverseOrder} this macro \fexpan ds its argument; it is only usable
with digit tokens. It does \emph{not} apply \csbxint{Num} to its argument (so
this must be done explicitely if the argument is an integer produced from some
\xintfracname macros). It does accept a leading minus sign which will be left
upfront in the output.

\begingroup
\begin{everbatim*}
\oodef\x{\xintReverseDigits
  {98765432109876543210987654321098765432109876543210}}\meaning\x\par
\noindent\oodef\x{\xintReverseDigits {\xintReverseDigits
  {98765432109876543210987654321098765432109876543210}}}\meaning\x\par
\end{everbatim*}
\endgroup

\subsection{\csh{xintDecSplit}}
\label{xintDecSplit}

|\xintDecSplit|\x\n\etype{\numx f} cuts the |N| (a list of digits) into two
pieces |L| and |R|: it outputs |{L}{R}| where the original |N|
is the concatenation |LR|. These two pieces are decided according to |x|:
\begin{itemize}[nosep]
\item for |x>0|, |R| coincides with the |x| least significant digits. If |x|
  equals or exceeds the length of |N| the first piece |L| will thus be
  \emph{empty},
\item for |x=0|, |R| is empty, and |L| is all of |N|,
\item for |x<0|, the first piece |L| consists of the \verb+|x|+ most
  significant digits and the second piece |R| gets the remaining ones. If |x|
  equals or exceeds the length of |N| the second piece |R| will thus be
  \emph{empty}.
\end{itemize}

This macro provides public interface to some functionality which is primarily
of internal interest. It operates only (after \fexpan sion) on ``strings'' of
digits tokens: leading zeroes are allowed but a leading sign (even a minus
sign) will provoke an error.

Breaking change with |1.2i|: formerly |N<0| was replaced by its
  absolute value. Now, a sign (positive or negative) will create an error.


\subsection{\csh{xintDecSplitL}, \csh{xintDecSplitR}}
\label{xintDecSplitL}
\label{xintDecSplitR}

|\xintDecSplitL|\x\n\etype{\numx f} returns the first piece (unbraced) from
the \csa{xintDecSplit} output.

\noindent|\xintDecSplitR|\x\n\etype{\numx f} returns the second piece
(unbraced) from the \csa{xintDecSplit} output.

\subsection{\csh{xintiiE}}\label{xintiiE}

|\xintiiE|\n\x\etype{f\numx } serves to extend |N| with |x| zeroes. The
parameter |x| must be non-negative. The same output would be obtained via
\csbxint{DSH}|{-x}{N}|, except for |N=0|, as |\xintDSH{-x}{N}| multiplies |N|
by |10^x| hence produces |0| if |N=0| whereas
|\xintiiE{0}{x}| produces |x+1| zeros.
\begin{everbatim*}
\xintiiE {0}{91}\par
\end{everbatim*}

\subsection{\csh{xintDSH}}\label{xintDSH}

|\xintDSH|\x\n\etype{\numx f} is parametrized decimal shift. When |x| is
negative, it is like iterating \csbxint{DSL} \verb+|x|+ times (\emph{i.e.\@}
multiplication by $10^{-x}$). When |x| positive, it is like iterating
\csbxint{DSR} |x| times (and is more efficient), and for a non-negative |N|
this is thus the same as the quotient from the Euclidean division by |10^x|.

\subsection{\csh{xintDSHr}, \csh{xintDSx}}\label{xintDSHr}\label{xintDSx}

|\xintDSHr|\x\n\etype{\numx f} expects |x| to be zero or positive and it
returns then a value |R| which is correlated to the value |Q| returned by
\csbxint{DSH}\x\n{} in the following manner:
\begin{itemize}
\item if |N| is
  positive or zero, |Q| and |R| are the quotient and remainder in
  the Euclidean division by |10^x| (obtained in a more efficient
  manner than using \csa{xintiiDivision}),
\item if |N| is negative let
  |Q1| and |R1| be the quotient and remainder in the Euclidean
  division by |10^x| of the absolute value of |N|. If |Q1|
  does not vanish, then |Q=-Q1| and |R=R1|. If |Q1| vanishes, then
  |Q=0| and |R=-R1|.
\item for |x=0|, |Q=N| and |R=0|.
\end{itemize}
So one has |N = 10^x Q + R| if |Q| turns out to be zero or
positive, and |N = 10^x Q - R| if |Q| turns out to be negative,
which is exactly the case when |N| is at most |-10^x|.

|\xintDSx|\x\n\etype{\numx f} for |x| negative is exactly as
|\xintDSH|\x\n, \emph{i.e.\@} multiplication by $10^{-\text{|x|}}$. For |x| zero or
positive it returns the two numbers |{Q}{R}| described above, each one within
braces. So |Q| is |\xintDSH|\x\n, and |R| is |\xintDSHr|\x\n, but computed
simultaneously.

\subsection{\csh{xintiiEq}}\label{xintiiEq}

|\xintiiEq|\n\m\etype{ff} returns 1 if |N=M|, 0 otherwise.

\subsection{\csh{xintiiNotEq}}\label{xintiiNotEq}

|\xintiiNotEq|\n\m\etype{ff} returns 0 if |N=M|, 1 otherwise.

\subsection{\csh{xintiiGeq}}\label{xintiiGeq}

|\xintiiGeq|\n\m\etype{ff} returns 1 if the \emph{absolute value}
of the first number is at least equal to the absolute value of the second
number. If \verb+|N|<|M|+ it returns 0.

Important: the macro compares \emph{absolute values}.

\subsection{\csh{xintiiGt}}\label{xintiiGt}

|\xintiiGt|\n\m\etype{ff} returns 1 if |N|$>$|M|, 0 otherwise.

\subsection{\csh{xintiiLt}}\label{xintiiLt}

|\xintiiLt|\n\m\etype{ff} returns 1 if |N|$<$|M|, 0 otherwise.

\subsection{\csh{xintiiGtorEq}}\label{xintiiGtorEq}

|\xintiiGtorEq|\n\m\etype{ff} returns 1 if |N|$\geqslant$|M|, 0 otherwise.
Extended by \xintfracname to fractions.

\subsection{\csh{xintiiLtorEq}}\label{xintiiLtorEq}

|\xintiiLtorEq|\n\m\etype{ff} returns 1 if |N|$\leqslant$|M|, 0 otherwise.

\subsection{\csh{xintiiIsZero}}\label{xintiiIsZero}

|\xintiiIsZero|\n\etype{f} returns 1 if |N=0|, 0 otherwise.

\subsection{\csh{xintiiIsNotZero}}\label{xintiiIsNotZero}

|\xintiiIsNotZero|\n\etype{f} returns 1 if |N!=0|, 0 otherwise.

\subsection{\csh{xintiiIsOne}}\label{xintiiIsOne}

|\xintiiIsOne|\n\etype{f} returns 1 if |N=1|, 0 otherwise.

\subsection{\csh{xintiiOdd}}\label{xintiiOdd}

|\xintiiOdd|\n\etype{f} is 1 if the number is odd and 0 otherwise.

\subsection{\csh{xintiiEven}}\label{xintiiEven}

|\xintiiEven|\n\etype{f} is 1 if the number is even and 0 otherwise.

\subsection{\csh{xintiiMON}}\label{xintiiMON}

|\xintiiMON|\n\etype{f} computes |(-1)^N|.
\begin{everbatim*}
\xintiiMON {-280914019374101929}
\end{everbatim*}

\subsection{\csh{xintiiMMON}}\label{xintiiMMON}

|\xintiiMMON|\n\etype{f} computes |(-1)^{N-1}|.
\begin{everbatim*}
\xintiiMMON {280914019374101929}
\end{everbatim*}

\subsection{\csh{xintiiifSgn}}\label{xintiiifSgn}

\csh{xintiiifSgn}\marg{N}\marg{A}\marg{B}\marg{C}\etype{fnnn} executes either
the \meta{A}, \meta{B} or \meta{C} code, depending on its first argument being
respectively negative, zero, or positive.

\subsection{\csh{xintiiifZero}}\label{xintiiifZero}

\csa{xintiiifZero}\marg{N}\marg{IsZero}\marg{IsNotZero}\etype{fnn} expandably
checks if the first mandatory argument |N| (a number, possibly a fraction if
\xintfracname is loaded, or a macro expanding to one such) is zero or not. It
then either executes the first or the second branch.

Beware that both branches must be present.

\subsection{\csh{xintiiifNotZero}}\label{xintiiifNotZero}

\csa{xintiiifNotZero}\marg{N}\marg{IsNotZero}\marg{IsZero}\etype{fnn}
expandably checks if the first mandatory argument |N| is not
zero or is zero. It then either executes the first or the second branch.

Beware that both branches must be present.

\subsection{\csh{xintiiifOne}}\label{xintiiifOne}

\csa{xintiiifOne}\marg{N}\marg{IsOne}\marg{IsNotOne}\etype{fnn} expandably
checks if the first mandatory argument |N| is one or not one. It
then either executes the first or the second branch. Beware that both branches
must be present.

\subsection{\csh{xintiiifCmp}}\label{xintiiifCmp}

\csa{xintiiifCmp}\marg{A}\marg{B}\marg{A<B}\marg{A=B}\marg{A>B}\etype{ffnnn}
compares its first two arguments and chooses accordingly the correct branch.

\subsection{\csh{xintiiifEq}}\label{xintiiifEq}

\csa{xintiiifEq}\marg{A}\marg{B}\marg{A=B}\marg{not(A=B)}\etype{ffnn} checks
equality of its two first arguments and executes the corresponding branch.

\subsection{\csh{xintiiifGt}}\label{xintiiifGt}

\csa{xintiiifGt}\marg{A}\marg{B}\marg{A>B}\marg{not(A>B)}\etype{ffnn}
checks if $A>B$ and executes the corresponding branch.

\subsection{\csh{xintiiifLt}}\label{xintiiifLt}

\csa{xintiiifLt}\marg{A}\marg{B}\marg{A<B}\marg{not(A<B)}\etype{ffnn}
checks if $A<B$ and executes the corresponding branch.

\subsection{\csh{xintiiifOdd}}\label{xintiiifOdd}

\csa{xintiiifOdd}\marg{A}\marg{A odd}\marg{A even}\etype{fnn} checks if $A$ is
and odd integer and executes the corresponding branch.

\subsection{\csh{xintiiSum}}\label{xintiiSum}

\csa{xintiiSum}\marg{braced things}\etype{{\lowast f}} after expanding its
argument expects to find a sequence of tokens (or braced material). Each is
\fexpan ded, and the sum of all these numbers is returned.
\begin{everbatim*}
\xintiiSum{{123}{-98763450}{\xintiiFac{7}}{\xintiiMul{3347}{591}}}\newline
\xintiiSum{1234567890}\newline
\xintiiSum{1234}\newline
\xintiiSum{}
\end{everbatim*}

A sum with only one term returns that
number: |\xintiiSum {{-1234}}|\dtt{=\xintiiSum {{-1234}}}.
Attention that |\xintiiSum {-1234}| is not legal input and would make the
\TeX{} run fail.

\subsection{\csh{xintiiPrd}}\label{xintiiPrd}

\csa{xintiiPrd}\marg{braced things}\etype{{\lowast f}} after expanding its
argument expects to find a sequence of (of braced items or unbraced
single tokens). Each is
expanded (with the usual meaning), and the product of all these numbers is
returned.
\begin{everbatim*}
\xintiiPrd{{-9876}{\xintiiFac{7}}{\xintiiMul{3347}{591}}}\newline
\xintiiPrd{123456789123456789}\newline
\xintiiPrd {1234}\newline
\xintiiPrd{}
\end{everbatim*}

Attention that |\xintiiPrd {-1234}| is not legal input and would make the \TeX{}
compilation fail.
\begin{everbatim*}
$2^{200}3^{100}7^{100}=\printnumber
       {\xintiiPrd {{\xintiiPow {2}{200}}{\xintiiPow {3}{100}}{\xintiiPow {7}{100}}}}$
\end{everbatim*}

With \xintexprname, the syntax is the natural one:
\begin{everbatim*}
$2^{200}3^{100}7^{100}=\printnumber{\xinttheiiexpr 2^200 * 3^100 * 7^100\relax}$
\end{everbatim*}

\subsection{\csh{xintiiSquareRoot}}
\label{xintiiSquareRoot}

|\xintiiSquareRoot|\n\etype{f} returns two braced integers |{M}{d}| which
satisfy |d>0| and |M^2-d=N| with
|M| the smallest (hence if |N=k^2| is a perfect square then |M=k+1|, |d=2k+1|).

\begin{everbatim*}
\xintAssign\xintiiSquareRoot {17000000000000000000000000}\to\A\B
\xintiiSub{\xintiiSqr\A}\B=\A\string^2-\B
\end{everbatim*}

A rational approximation to $\sqrt{\text{|N|}}$ is
$\text{|M|}-\frac{\text{|d|}}{\text{|2M|}}$ which is a majorant and the error
is at most |1/2M| (if |N| is a perfect square |k^2| this gives |k+1/(2k+2)|,
not |k|.)

Package \xintfracname has \csbxint{FloatSqrt} for square roots of floating
point numbers.

\subsection{\csh{xintiiSqrt}, \csh{xintiiSqrtR}}
\label{xintiiSqrt}\label{xintiiSqrtR}

\noindent|\xintiiSqrt|\n\ computes the largest integer whose square
is at most equal to |N|.\etype{f} |\xintiiSqrtR| 
produces the rounded, not truncated, square root.\etype{f}
\begin{everbatim*}
\begin{itemize}[nosep]
\item \xintiiSqrt  {3000000000000000000000000000000000000}
\item \xintiiSqrtR {3000000000000000000000000000000000000}
\item \xintiiSqrt  {\xintiiE {3}{100}}
\end{itemize}
\end{everbatim*}

\subsection{\csh{xintiiBinomial}}\label{xintiiBinomial}

|\xintiiBinomial{x}{y}|\etype{\numx\numx} computes binomial coefficients.

If |x<0| an out-of-range error is raised. Else, if |y<0| or if |x<y| the macro
evaluates to \dtt{\xintiiBinomial{1}{-1}}.


%\begin{framed}
  The allowable range is $0\leqslant x\leqslant99999999$.
%\end{framed}
  % Thus the maximal computable value is ${9999 \choose 5000}$ which turns out
  % to have \dtt{3008} digits.
  But this theoretical range includes binomial coefficients with more than the
  roughly 19950 digits that the arithmetics of \xintname can handle. In such
  cases, the computation will end up in a low-level \TeX{} error after a
  long time.

%
It turns out that ${65000 \choose 32500}$ has \dtt{19565} digits and
${64000 \choose 32000}$ has \dtt{19264} digits. The latter can be evaluated
(this takes a long long time) but presumably not the former (I didn't try).
Reasonable feasible evaluations are with binomial coefficients not exceeding
about one thousand digits.


%
The |binomial| function is available in the \xintexprname parsers.
\begin{everbatim*}
\xinttheiiexpr seq(binomial(100,i), i=47..53)\relax
\end{everbatim*}

See \csbxint{FloatBinomial} from package \xintfracname for the float variant,
used in \csbxint{floatexpr}.


In order to
evaluate binomial coefficients ${x \choose y}$ with $x>99999999$, or even
$x\geqslant 2^{31}$, but $y$ is not too large, one may use an ad hoc function
definition such as:
\begin{everbatim*}
\xintdeffunc mybigbinomial(x,y):=`*`(x-y+1..[1]..x)//y!;%
%                            without [1], x would have been limited to < 2^31
\printnumber{\xinttheexpr mybigbinomial(98765432109876543210,10)\relax}
\end{everbatim*}


To get this functionality in macro form, one can do:
\begin{everbatim*}
\xintNewIIExpr\MyBigBinomial [2]{`*`(#1-#2+1..[1]..#1)//#2!}
\printnumber{\MyBigBinomial {98765432109876543210}{10}}
\end{everbatim*}

As we used \csa{xintNewIIExpr}, this macro will only accept strict integers.
Had we used \csa{xintNewExpr} the |\MyBigBinomial| would have accepted general
fractions or decimal numbers, and computed the product at the numerator
without truncating them to integers; but the factorial at the denominator
would truncate its argument.

\subsection{\csh{xintiiPFactorial}}\label{xintiiPFactorial}

|\xintiiPFactorial{a}{b}|\etype{\numx\numx} computes the partial factorial
|(a+1)(a+2)...b|. For |a=b| the product is considered empty hence returns |1|.

%\begin{framed}
  The allowed range
%
%
%
  is $-100000000\leqslant a, b\leqslant99999999$.
  The
  rule is to interpret the formula as the product of the
  $j$'s such that $a<j\leqslant b$, hence in particular if $a\geqslant b$ the
  product is empty and the macro evaluates to |1|.

  Only for $0\leqslant a\leqslant b$ is the behaviour to be considered
  stable. For $a>b$ or negative arguments, the definitive rules have not yet
  been fixed.

\begin{everbatim*}
\xintiiPFactorial {100}{130}
\end{everbatim*}
%\end{framed}

This theoretical range allows computations whose result values would have more
than the roughly 19950 digits that the arithmetics of \xintname can handle. In
such cases, the computation will end up in a low-level \TeX{} error after a
long time.

The |pfactorial| function is available in the \xintexprname parsers.
\begin{everbatim*}
\xinttheiiexpr pfactorial(100,130)\relax
\end{everbatim*}

See \csbxint{FloatPFactorial} from package \xintfracname for the float
variant, used in \csbxint{floatexpr}.


In case values are needed with $b>99999999$, or even $b\geqslant 2^{31}$, but
$b-a$ is not too large, one may use an ad hoc function definition such as:
\begin{everbatim*}
\xintdeffunc mybigpfac(a,b):=`*`(a+1..[1]..b);%
%                            without [1], b would have been limited to < 2^31
\printnumber{\xinttheexpr mybigpfac(98765432100,98765432120)\relax}
\end{everbatim*}

\subsection{\csh{xintiiMax}}\label{xintiiMax}

|\xintiiMax|\n\m\etype{ff} returns the largest of the two in the sense
of the order structure on the relative integers (\emph{i.e.\@} the right-most
number if they are put on a line with positive numbers on the right):
|\xintiiMax {-5}{-6}|\dtt{=\xintiiMax{-5}{-6}}.

\subsection{\csh{xintiiMin}}\label{xintiiMin}

|\xintiiMin|\n\m\etype{ff} returns the smallest of the two in the sense of the
order structure on the relative integers (\emph{i.e.\@} the left-most number if
they are put on a line with positive numbers on the right): |\xintiiMin
{-5}{-6}|\dtt{=\xintiiMin{-5}{-6}}.

\subsection{\csh{xintiiMaxof}}\label{xintiiMaxof}

\csa{xintiiMaxof}|{{a}{b}{c}...}|\etype{f{$\to$}\lowast f} returns the
maximum. The list argument may be a macro, it is \fexpan ded first.

\subsection{\csh{xintiiMinof}}\label{xintiiMinof}

\csa{xintiiMinof}|{{a}{b}{c}...}|\etype{f{$\to$}\lowast f} returns the
minimum. The list argument may be a macro, it is \fexpan ded first.

\subsection{\csh{xintifTrueAelseB}}
\label{xintifTrueAelseB}

\csa{xintifTrueAelseB}\marg{f}\marg{true branch}\marg{false branch}\etype{fnn}
is a synonym for \csbxint{iiifNotZero}.

{\small
  \noindent |\xintiiifnotzero| is lowercase companion macro.\par }

Note 1: as it does only \fexpan sion on its argument it fails with inputs such
as |--0|. But with \xintfracname loaded, it does work fine if nested with
other \xintfracname macros, because the output format of such macros is fine
as input to \csbxint{iiifNotZero}. This remark applies to all other \myenquote{Boolean
logic} macros next.

Note 2: prior to |1.2o| this macro was using \csbxint{ifNotZero} which applies
\csbxint{Num} to its argument (or gets redefined by \xintfracname to handle
general decimal numbers or fractions). Hence it would have
worked with input such as |--0|. But it was decided at |1.2o| that the
overhead was not worth it. The same remark applies to the other \myenquote{Boolean
logic} type macros next.

\subsection{\csh{xintifFalseAelseB}}
\label{xintifFalseAelseB}

\csa{xintifFalseAelseB}\marg{f}\marg{false branch}\marg{true
  branch}\etype{fnn} is a synonym for \csbxint{iiifZero}.

{\small
  \noindent |\xintiiifzero| is lowercase companion macro.\par }

\subsection{\csh{xintNOT}}\label{xintNOT}

\csa{xintNOT}\etype{f} is a synonym for \csa{xintiiIsZero}.

{\small |\xintiiiszero| serves as lowercase companion macro.\par}

\subsection{\csh{xintAND}}\label{xintAND}

|\xintAND{f}{g}|\etype{ff} returns \dtt{1} if |f!=0| and |g!=0| and \dtt{0}
otherwise.

\subsection{\csh{xintOR}}\label{xintOR}

|\xintOR{f}{g}|\etype{ff} returns \dtt{1} if |f!=0| or |g!=0| and \dtt{0}
otherwise.

\subsection{\csh{xintXOR}}\label{xintXOR}

|\xintXOR{f}{g}|\etype{ff} returns \dtt{1} if exactly one of |f| or |g|
is true (i.e.\@{} non-zero), else \dtt{0}.

\subsection{\csh{xintANDof}}\label{xintANDof}

\csa{xintANDof}|{{a}{b}{c}...}|\etype{f{$\to$}\lowast f} returns \dtt{1} if
all are true (i.e.\@{} non zero) and \dtt{0} otherwise. The list argument may be a
macro, it (or rather its first token) is \fexpan ded first to deliver its
items.

\subsection{\csh{xintORof}}\label{xintORof}

\csa{xintORof}|{{a}{b}{c}...}|\etype{f{$\to$}\lowast f} returns \dtt{1} if at
least one is true (i.e.\@{} does not vanish), else it produces \dtt{0}. The list
argument may be a macro, it is \fexpan ded first.

\subsection{\csh{xintXORof}}\label{xintXORof}

\csa{xintXORof}|{{a}{b}{c}...}|\etype{f{$\to$}\lowast f} returns \dtt{1} if an
odd number of them are true (i.e.\@{} do not vanish), else it produces \dtt{0}.
The list argument may be a macro, it is \fexpan ded first.

\subsection{\csh{xintiiGCD}}
\label{xintiiGCD}

|\xintiiGCD|\n\m\etype{ff} computes the greatest common divisor. It is
positive, except when both |N| and |M| vanish, in which case the macro returns
zero.
%
\leftedline{\csa{xintiiGCD}|{10000}{1113}|\dtt{=\xintiiGCD{10000}{1113}}}
%
\leftedline{|\xintiiGCD{123456789012345}{9876543210321}=|\dtt
  {\xintiiGCD{123456789012345}{9876543210321}}}

At |1.3d|, this macro (which is used by the \func{gcd} function in
\csbxint{iiexpr}) was copied over to \xintname, thus removing a partial
dependency of \xintexprname on \xintgcdname.

At |1.4| \xintgcdname requires \xintname and the latter is thus the one
providing the macro.

\subsection{\csh{xintiiLCM}}
\label{xintiiLCM}

|\xintiiLCM|\n\m\etype{ff} computes the least common multiple. It is positive,
except if one of |N| or |M| vanish, in which case the macro returns zero.
%
\leftedline{\csa{xintiiLCM}|{10000}{1113}|\dtt{=\xintiiLCM{10000}{1113}}}
%
\leftedline{|\xintiiLCM{123456789012345}{9876543210321}=|\dtt
  {\xintiiLCM{123456789012345}{9876543210321}}}

At |1.3d|, this macro (which is used by the \func{lcm} function in
\csbxint{iiexpr}) was copied over to \xintname, thus removing a partial
dependency of \xintexprname on \xintgcdname.

At |1.4| \xintgcdname requires \xintname and the latter is thus the one
providing the macro.

\subsection{\csh{xintiiGCDof}}\label{xintiiGCDof}

\csa{xintiiGCDof}|{{a}{b}{c}...}|\etype{f{$\to$}{\lowast f}} computes the
greatest common divisor of the integers |a|, |b|, \dots{}. It is a support
macro for the |gcd()| function of the \csbxint{iiexpr} parser.

It replaces the \csbxint{GCDof} which was formerly provided by \xintgcdname
and is now available via \xintfracname in a version handling also
fractions.


\subsection{\csh{xintiiLCMof}}\label{xintiiLCMof}

\csa{xintiiLCMof}|{{a}{b}{c}...}|\etype{f{$\to$}{\lowast f}} computes the
least common multiple of the integers |a|, |b|, \dots{}. It is a support
macro for the |lcm()| function of the \csbxint{iiexpr} parser.

It replaces the \csbxint{LCMof} which was formerly provided by \xintgcdname
and is now available via \xintfracname in a version handling also
fractions.

\subsection{\csh{xintLen}}\label{xintLen}

|\xintLen|\etype{\Numf} is originally an alias for \csbxint{iLen}. But with
\xintfracname loaded its meaning is \hyperref[xintLenFrac]{modified} to accept
more general inputs.

\subsection{(WIP) \csh{xintRandomDigits}}\label{xintRandomDigits}

\begin{framed}
  All randomness related macros are Work-In-Progress: implementation and user
  interface may change. They work only if the \TeX\ engine provides the
  \csa{uniformdeviate} or \csa{pdfuniformdeviate} primitive. See
  \csbxint{UniformDeviate} for additional information.
\end{framed}

|\xintRandomDigits{N}|\etype{\numx} expands in two steps to |N| random decimal
digits. The argument must be non-negative and is limited by \TeX\ memory
parameters.
On \TeX Live 2018 with input save stack size at \dtt{5000} the
maximal allowed |N| is at most \dtt{19984} (tested within a |\write| to an
auxiliary file, the macro context may cause a reduced maximum).
\begin{everbatim*}
\xintsetrandomseed 271828182
\xintRandomDigits{92}
\end{everbatim*}

\begin{TeXnote}
  the digits are produced eight by eight by the same method which would result
  from \csbxint{UniformDeviate}|{100000000}| but with less overhead.
\end{TeXnote}

% \subsection{\csh{\xintOneRandomDigit}}\label{xintOneRandomDigit}

\subsection{(WIP) \csh{xintXRandomDigits}}\label{xintXRandomDigits}

|\xintXRandomDigits{N}|\xtype{\numx} expands under exhaustive expansion
(|\edef|, |\write|, |\csname| ...) to |N| random decimal
digits. The argument must be non-negative.
For example:
\begin{everbatim}
\newwrite\out
\immediate\openout\out=\jobname-out.txt
\immediate\write\out{\xintXRandomDigits{4500000}}
\immediate\closeout\out
\end{everbatim}
creates a \dtt{4500001} bytes file (it ends with a line feed character).
Trying with \dtt{5000000} raises this error:
\begin{everbatim}
Runaway text?
588875947168511582764514135070217555354479805240439407753451354223283\ETC.
! TeX capacity exceeded, sorry [main memory size=5000000].
<inserted text> 666515098
                         
l.15 ...ate\write\out{\xintXRandomDigits{5000000}}
                                                  
No pages of output.
Transcript written on temp.log.
\end{everbatim}
This can be lifted by increasing the \TeX\ memory settings (installation
dependent).

\begin{TeXnote}
  the digits are produced eight by eight by the same method which would result
  from \csbxint{UniformDeviate}|{100000000}| but with less overhead.
\end{TeXnote}

\subsection{(WIP) \csh{xintiiRandRange}}\label{xintiiRandRange}

|\xintiiRandRange{A}|\etype{f} expands to a random (big) integer |N|
such that |0<=N<A|. It is a supporting macro for \func{randrange}. As with
Python's function of the same name, it is an error if |A<=0|.
\begin{everbatim*}
\xintsetrandomseed 271828314
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\newline
\xintiiRandRange{\xintNum{1e40}}\newline
\xintsetrandomseed 271828314
\xinttheiiexpr randrange(num(1e40))\relax\newline
% bare 1e40 not understood by \xintiiexpr
\xintsetrandomseed 271828314
\xinttheexpr randrange(1e40)\relax
\end{everbatim*}

Of course, keeping in mind that the set of seeds is of cardinality |2^{28}|,
randomness is a bit illusory here say with |A=10^N|, |N>8|, if we proceed
immediately after having set the seed. If we add some entropy in any way, then
it is slightly more credible; but I think that for each seed the period is
something like |2^{27}(2^{55}-1)55|,%
%
\footnote{Compare the result of exercise 3.2.2-30 in TAOCP, vol II.}
%
so we expect at most about |2^{110}55|
``points in time'', and this is already small compared to the |10^40|
from example above. Thus already we are very far from being intrinsically
able to generate all numbers with forty digits as random numbers, and this
makes the previous section about usage of \csbxint{XRandomDigits} to generate
millions of digits a bit comical...

\begin{TeXnote}
  the digits are produced eight by eight by the same method which would result
  from \csbxint{UniformDeviate}|{100000000}| but with less overhead.
\end{TeXnote}

\subsection{(WIP) \csh{xintiiRandRangeAtoB}}\label{xintiiRandRangeAtoB}

|\xintiiRandRangeAtoB{A}{B}|\etype{ff} expands to a random (big) integer |N|
such that |A<=N<B|. It is a supporting macro for \func{randrange}. As with
Python's function of the same name, it is an error if |B<=A|.
\begin{everbatim*}
\xintsetrandomseed 271828314
12345678911111111111111111111\newline
\xintiiRandRangeAtoB{12345678911111111111111111111}{12345678922222222222222222222}%
\newline
\xintsetrandomseed 271828314
\def\test{%
\xinttheiiexpr
            randrange(12345678911111111111111111111,12345678922222222222222222222)
\relax}%
\romannumeral\xintreplicate{10}{\test\newline}%
12345678922222222222222222222
\end{everbatim*}

\begin{TeXnote}
  the digits are produced eight by eight by the same method which would result
  from \csbxint{UniformDeviate}|{100000000}| but with less overhead.
\end{TeXnote}

\clearpage
\let\xintnameUp\undefined
\csname xintfracnameUp\endcsname
\def\n{|{N}|}
\def\m{|{M}|}
\def\x{|{x}|}
\section{Macros of the \xintfracname package}
\RaisedLabel{sec:frac}

\localtableofcontents

\subsection{Introduction}

First version of this package was in release |1.03| (|2013/04/14|) of the
\xintbundlename.

At release |1.3| (|2018/02/28|) the behaviour of \csbxint{Add} (and of
\csbxint{Sub}) was modified: when adding |a/b| and |c/d| they
will use always the least common multiple of the denominators. This helps
limit the build-up of denominators, but the author still hesitates if the
fraction should be reduced to smallest terms. The current method allows (for
example when multiplying two polynomials) to keep a well-predictable
denominator among various terms, even though some may be reducible.

\xintfracname loads automatically \xintcorename and \xintname and inherits
their macro definitions. Only these two are redefined:
\hyperref[xintNumFrac]{\string\xintNum} and
\hyperref[xintLenFrac]{\string\xintLen}. As explained in \autoref{ssec:inputs}
and \autoref{ssec:outputs} the interchange format for the \xintfracname
macros, i.e.\@{} |A/B[N]|, is not understood by the |ii|-named macros of
\xintcorename/\xintname which expect the so-called strict integer format.
Hence, to use such an |ii|-macro with an output from an \xintfracname macro,
an extra \csbxint{Num} wrapper is required. But macros already defined by
\xintfracname cover most use cases hence this should be a rarely needed.

In the macro descriptions, the variable |f|\ntype{\Ff} and the margin
indicator stand for the \xintfracname input format for integers, scientific
numbers, and fractions as described in \autoref{ssec:inputs}.

As in the \hyperref[sec:xint]{xint.sty} documentation, |x|\ntype{\numx} stands
for something which internally will be handled in a \csa{numexpr}. It may thus
be an expression as understood by \csa{numexpr} but its evaluation and
intermediate steps must obey the \TeX\ bound.

The output format for most macros is the |A/B[N]| format but naturally the
float macros use the scientific notation on output. And some macros are
special, for example \csbxint{Trunc} produces decimal numbers, \csbxint{Irr}
produces an |A/B| with no |[N]|, \csbxint{iTrunc} and \csbxint{iRound} produce
integers without trailing |[N]| either, etc\dots

At |1.4g|, old legacy typesetting macros |\xintFrac|, |\xintSignedFrac|,
|\xintFwOver| and |\xintSignedFwOver| were renamed into \csbxint{TeXFrac},
\csbxint{TeXsignedFrac}, \csbxint{TeXOver}, \csbxint{TeXsignedOver}.  The old
names will raise errors\CHANGED{1.4m} and will be removed completely soon.

\subsection{\csh{xintTeXFromSci}}\label{xintTeXFromSci}

Experimental.\xtype{} This typesetting math-mode-only macro expects an input
which is already in, or will expand to, decimal or scientific
notation. A trailing |/B| is accepted and will be handled
differently according to whether it follows some scientific exponent |eN|
part or not.

It was formerly |\xintTeXfromSci|.  Old name deprecated at |1.4l|.  Also it used
to be \fexpan dable but is now only \xexpan dable.  Use |\expanded| if
needed.

This macro can be used as a typesetting wrapper for \csbxint{eval} or
\csbxint{floateval} output: it expects its input (after expansion) to
have been already \myenquote{prettified} for example via the removal of trailing
zeros, usage of fixed point notation if scientific exponent is small,
etc\dots\
%
It simply transforms the |e<exponent>| part, if actually present, into
|\cdot 10^{exponent}|.  A fractional part |/B| if found in the expansion
of the input must be last and will be tranformed into |\cdot B^{-1}| if
there was a scientific part, else the output will be using |\frac{A}{B}|
(or the \TeX\ equivalent in place of |\frac|) with |A| the numerator.

\begin{TeXnote}
  \begin{itemize}
  \item I am hesitating whether the |\frac{A}{B}| branch choice should
    require |A| to be an integer, or will also, as currently, be done
    with |A| being a number in decimal notation.  Please advise.
  \item The package does:
\begin{everbatim}
\ifdefined\frac
  \protected\def\xintTeXFromScifracmacro#1#2{\frac{#2}{#1}}%
\else
  \protected\def\xintTeXFromScifracmacro#1#2{{#2\over#1}}%
\fi
\end{everbatim}
    Customize as desired.  Notice the interversion of arguments.
  \end{itemize}
\end{TeXnote}

Example:
\begin{everbatim*}
$\xintTeXFromSci{\xintfloateval{1.1^10000/5}}$,
$\xintTeXFromSci{\xinteval{1.1^10000/5}}$\par
\end{everbatim*}

The above examples are in the case of a single numerical value.  To
handle more complex outputs from \csbxint{eval} or \csbxint{floateval}
one will need to proceed via a redefinition of
\csbxint{floatexprPrintOne} and/or \csbxint{exprPrintOne} like this:
\begin{everbatim*}
\[\def\xintfloatexprPrintOne[#1]#2{\xintTeXFromSci{\xintPFloat[#1]{#2}}}
  \xintfloateval[10]{2^100, 3^100, 13^100}\]
\end{everbatim*}
\par\vskip-\belowdisplayskip
\begin{everbatim*}
\[\def\xintexprPrintOne#1{\xintTeXFromSci{\xintFracToSci{#1}}}
  \xinteval{sqrt(2^101,60), 355/113, 6.02e23/1000}\]
\end{everbatim*}% attention à l'espace TeX est en mode horizontal après display
This will however make then impossible, due to the added \TeX\ mark-up in the
output, the nesting of \csbxint{floateval}/\csbxint{eval} inside one another.
The core \csbxint{expr}|...\relax| syntax remains usable and is anyhow the
recommended way for such nesting as it is more efficient.

Some similar effect is also possible without \csbxint{TeXFromSci},
simply by a customization of \csbxint{PFloatE} like this:
\begin{everbatim*}
\begingroup
\def\xintPFloatE#1.{\cdot10^{#1}.}%
$\xintfloateval{1.1^10000/5}$, $\xinteval{1.1^10000/5}$
\endgroup\newline
\end{everbatim*}%
This method is simpler-minded but will leave the trailing |/B|'s \myenquote{as
is}, even if the numerator has no scientific exponent part.  The
presence of extra \TeX\ mark-up in the output has the consequences
on nesting which were mentioned above.

\subsection{\csh{xintTeXFrac}}\label{xintTeXFrac}

This is a typesetting \LaTeX{} only macro\etype{\Ff}, math mode only as it
expands to |\frac{A}{B}10^n| for an input which ends up parsed into raw
format |A/B[n]|.

If the denominator |B| is \dtt{1}, the output is |A\cdot 10^n|. If the
exponent |n| is \dtt{0}, the |[\cdot]10^n| part is omitted.
\begin{everbatim*}
$\xintTeXFrac {178.000/25600000}$, $\xintTeXFrac {178.000/1}$,
$\xintTeXFrac {3.5/5.7}$\newline
\end{everbatim*}%
The input, if in a fraction form, is not simplified in any way, except for
transforming numerator and denominator into integers, separating a power of
ten part.  Macros such as \csbxint{Irr}, \csbxint{PIrr}, \csbxint{REZ} can be
inserted to wrap the input and help simplify it.  The minus sign ends up in
the numerator.

It is the new name since |1.4g| of |\xintFrac|.  The old name now raises
a \TeX{} error.\CHANGED{1.4m}

\subsection{\csh{xintTeXsignedFrac}}\label{xintTeXsignedFrac}


This is as \csbxint{TeXFrac}\etype{\Ff} except that a negative fraction has the
sign ending up in front, not in the numerator.
\begin{everbatim*}
$\xintTeXFrac {-355/113}=\xintTeXsignedFrac {-355/113}$\newline
\end{everbatim*}%
It is the new name since |1.4g| of |\xintSignedFrac|.  The old name now raises
a \TeX{} error.\CHANGED{1.4m}

\subsection{\csh{xintTeXOver}}\label{xintTeXOver}

This does the same as \csa{xintTeXFrac}\etype{\Ff} except that the \csa{over}
primitive is used for the fraction (in case the denominator is not one; and a
pair of braces contains the |A\over B| part).
\begin{everbatim*}
$\xintTeXOver {178.000/25600000}$, $\xintTeXOver {178.000/1}$,
$\xintTeXOver {3.5/5.7}$\newline
\end{everbatim*}%
It is the new name since |1.4g| of |\xintFwOver|.  The old name now raises
a \TeX{} error.\CHANGED{1.4m}

\subsection{\csh{xintTeXsignedOver}}\label{xintTeXsignedOver}

This is as \csbxint{TeXOver}\etype{\Ff} except that a negative fraction has the
sign put in front, not in the numerator.
\begin{everbatim*}
$\xintTeXOver{-355/113}=\xintTeXsignedOver{-355/113}$\newline
\end{everbatim*}%
It is the new name since |1.4g| of |\xintSignedFwOver|.  The old name now raises
a \TeX{} error.\CHANGED{1.4m}

\subsection{\csh{xintLen}}\label{xintLenFrac}

The \csbxint{Len} macro\etype{\Ff} from \xintname is extended to accept a fraction
on input: the length of |A/B[n]| is the length of |A| plus the length of |B|
plus the absolute value of |n| and minus one (an integer input as |N| is
internally represented in a form equivalent to |N/1[0]| so the minus one means
that the extended \csa{xintLen} behaves the same as the original for
integers).
\begin{everbatim*}
\xintLen{201710/298219}=\xintLen{201710}+\xintLen{298219}-1\newline
\xintLen{1234/1}=\xintLen{1234}=\xintLen{1234[0]}=\xintiLen{1234}\newline
\xintLen{-1e3/5.425} (\xintRaw {-1e3/5.425})\par
\end{everbatim*}
The length is computed on the |A/B[n]| which would have been returned by
\csbxint{Raw}, as illustrated by the last example above.

|\xintLen| is only for use with such (scientific) numbers or fractions. See
also \csbxint{NthElt} from \xinttoolsname. See also \csbxint{Length} (which
however does not expand its argument) from \xintkernelname for counting more
general tokens (or rather braced items).

\subsection{\csh{xintNum}}\label{xintNumFrac}

The \csbxint{Num} \etype{\Ff} from \xintname is transformed into a synonym to
\csbxint{TTrunc}.

Attention that for example |\xintNum{1e100000}| expands to the needed
\dtt{100001} digits...

The original \hyperref[xintiNum]{\string\xintNum} from \xintcorename which
does not understand the fraction slash or the scientific notation is still
available under the name \csbxint{iNum}.

\subsection{\csh{xintRaw}}\label{xintRaw}

This macro `prints' the\etype{\Ff}
fraction |f| as it is received by the package after its parsing and
expansion, in a form |A/B[N]| equivalent to the internal
representation: the denominator |B| is always strictly positive and is
printed even if it has value |1|.
\begin{everbatim*}
\xintRaw{\the\numexpr 571*987\relax.123e-10/\the\numexpr-201+59\relax e-7}
\end{everbatim*}

No simplification is done, not even of common zeroes between numerator and
denominator:
\begin{everbatim*}
\xintRaw {178000/25600000}
\end{everbatim*}

\subsection{\csh{xintRawBraced}}\label{xintRawBraced}

This macro expands and parses its input\etype{\Ff} |f| as all
\xintfracname macros and produces as output |{N}{A}{B}| (with \TeX\
braces) where \csbxint{Raw} would have returned |A/B[N]|.

\subsection{\csh{xintNumerator}}\label{xintNumerator}

The input data\etype{\Ff} is parsed as if by \csbxint{Raw} into |A/B[N]|
and then |A| is returned if |N<=0|, or |A| extended by |N| zeroes if |N>0|.
\begin{everbatim*}
\xintNumerator {178000/25600000[17]}\newline
\xintNumerator {312.289001/20198.27}\newline
\xintNumerator {178000e-3/256e5}\newline
\xintNumerator {178.000/25600000}
\end{everbatim*}

\subsection{\csh{xintDenominator}}\label{xintDenominator}

The input data\etype{\Ff} is parsed as if by \csbxint{Raw} into |A/B[N]|
and then |B| is returned if |N>0|, or |B| extended by \verb+|N|+ zeroes if |N<=0|.
\begin{everbatim*}
\xintDenominator {178000/25600000[17]}\newline
\xintDenominator {312.289001/20198.27}\newline
\xintDenominator {178000e-3/256e5}\newline
\xintDenominator {178.000/25600000}
\end{everbatim*}

\subsection{\csh{xintRawWithZeros}}\label{xintRawWithZeros}

This macro parses the input\etype{\Ff} and outputs |A'/B'|, with |A'|
as would be returned by \csa{xintNumerator}|{f}| and |B'| as would be returned by
\csa{xintDenominator}|{f}|.
\begin{everbatim*}
\xintRawWithZeros{178000/25600000[17]}\newline
\xintRawWithZeros{312.289001/20198.27}\newline
\xintRawWithZeros{178000e-3/256e5}\newline
\xintRawWithZeros{178.000/25600000}\newline
\xintRawWithZeros{\the\numexpr 571*987\relax.123e-10/\the\numexpr-201+59\relax e-7}
\end{everbatim*}

\subsection{\csh{xintREZ}}\label{xintREZ}

The input\etype{\Ff} is first parsed into |A/B[N]| as by \csbxint{Raw}, then
trailing zeroes of |A| and |B| are suppressed and |N| is accordingly adjusted.
\begin{everbatim*}
\xintREZ {178000/25600000[17]}
\end{everbatim*}


\subsection{\csh{xintIrr}}\label{xintIrr}

This puts the fraction\etype{\Ff} into its unique irreducible form:
\begin{everbatim*}
\xintIrr {178.256/256.1780}, \xintIrr {178000/25600000[17]}
\end{everbatim*}

The current implementation does not cleverly first factor powers of
2 and 5, and |\xintIrr {2/3[100]}| will execute the
Euclidean division of |2|\raisebox{.5ex}{|.|}|10^{100}| by |3|, which is a bit
stupid as it could have known that the \dtt{100} trailing zeros can not bring
any divisibility by \dtt{3}.

Starting with release |1.08|, \csa{xintIrr} does not remove the trailing |/1|
when the output is an integer. This was deemed better for various (questionable?)
reasons, anyway the output format is since \emph{always} |A/B| with |B>0|, even
in cases where it turns out that |B=1|.
Use \csbxint{PRaw} on top of \csa{xintIrr} if it is needed to get rid of such a
trailing |/1|.

\subsection{\csh{xintPIrr}}\label{xintPIrr}

This puts the fraction\etype{\Ff} into irreducible form,
\emph{keeping as is the
  decimal part} |[N]| from raw internal |A/B[N]| format.
(|P| stands here for \emph{Partial})
\begin{everbatim*}
\xintPIrr {178.256/256.1780}, \xintPIrr {178000/25600000[17]}
\end{everbatim*}

Notice that the output always has the ending |[N]|, which is exactly the
opposite of \csbxint{Irr}'s behaviour. The interest of this macro is mainly in
handling fractions which somehow acquired a big |[N]| (perhaps from input in
scientific notation) and for which the reduced fraction would have a very
large number of digits. This large number of digits can considerably slow-down
computations done afterwards.

For example package \href{http://ctan.org/pkg/polexpr}{polexpr} uses
\csa{xintPIrr} when differentiating a polynomial, or in setting up a Sturm
chain for localization of the real roots of a polynomial. This is relevant to
polynomials whose coefficients were input in decimal notation, as this
automatically creates internally some |[N]|. Keeping and combining those
|[N]|'s during computations significantly increases their speed.

\subsection{\csh{xintJrr}}\label{xintJrr}

This also puts the fraction\etype{\Ff} into its unique irreducible form:
\begin{everbatim*}
\xintJrr {178.256/256.178}
\end{everbatim*}

This is (supposedly, not tested for ages) faster than \csa{xintIrr} for
fractions having some big common factor in the numerator and the denominator.
\begin{everbatim*}
\xintJrr {\xintiiPow{\xintiiFac {15}}{3}/%
              \xintiiPrd{{\xintiiFac{10}}{\xintiiFac{30}}{\xintiiFac{5}}}}
\end{everbatim*}

But to notice the difference one would need computations with much bigger
numbers than in this example. As \csbxint{Irr}, \csa{xintJrr} does not remove
the trailing |/1| from a fraction reduced to an integer.

\subsection{\csh{xintPRaw}}\label{xintPRaw}

|PRaw|\etype{\Ff} stands for ``pretty raw''. It does like \csbxint{Raw} apart
from removing the |[N]| part if |N=0| and removing the |B| if |B=1|.
\begin{everbatim*}
\xintPRaw {123e10/321e10}, \xintPRaw {123e9/321e10}, \xintPRaw {\xintIrr{861/123}}
\end{everbatim*}

\subsection{\csh{xintDecToStringREZ}}\label{xintDecToStringREZ}

\csa{xintDecToStringREZ}\etype{\Ff} uses fixed point (decimal) notation
for the output.  The |REZ| means that it trims (REmoves) trailing Zeros.  The name
is a bit strange, because it its not limited to
\emph{decimal numbers} but accepts the same kind of inputs as most other
\xintfracname macros.  The parsing of this input transforms it first
into an internal format having a numerator |A|, a denominator |B| and a
power of ten exponent |N|, standing for the fraction |A/B| times
\dtt{10} to the power |N|.  Then the following recipe applies:
\begin{itemize}[noitemsep]
\item the zero value is printed as \dtt{\xintDecToStringREZ{0}} (no decimal point).
\item trailing zeros of |A| and |B| are removed and |N| is adjusted,
\item if the new |B| is not \dtt{1}, it will appear in the output as |/B|,
\item fixed point decimal notation is used for |AeN|:
  \begin{itemize}[noitemsep]
  \item if |N| is non-negative, the output is an integer with |N| trailing
    zeros (and no decimal mark)
  \item if |N| is negative a decimal point is used, and if |AeN| is less than
    one in absolute value, output will start with \dtt{0.} (i.e. a decimal mark).
  \end{itemize}
\end{itemize}
The following should be noted:
\begin{enumerate}[noitemsep]
\item the fraction |AeN/B| or even |A/B| is not pre-reduced into lowest terms,
\item the macro does not check if |B| contains only powers of \dtt{2} and
  \dtt{5}, so |1/2| is printed as \dtt{\xintDecToString{1/2}}, not as \dtt{0.5}.
\end{enumerate}
The definitive behaviour remains to be decided regarding these last two points.
\begin{everbatim*}
\xintDecToStringREZ{0}, \xintDecToStringREZ{1/2}, \xintDecToStringREZ{0.5000}\newline
\xintDecToStringREZ{1.23456789e5}, \xintDecToStringREZ {1.23456789e-3}\newline
\xintDecToStringREZ{12345e-1}, \xintDecToStringREZ {12345e-2},
\xintDecToStringREZ{12345e-3}\newline
\xintDecToStringREZ{12345e-4}, \xintDecToStringREZ {12345e-5},
\xintDecToStringREZ{12345e-6}\newline
\xintDecToStringREZ{1.234567890000e12}, \xintDecToStringREZ{1.23456000e-5/10}\newline
\xintDecToStringREZ{70/14} % is not reduced to lowest terms
\end{everbatim*}

See \csbxint{FloatToDecimal} for a variant which first rounds the input
to some given number of significant digits.

\subsection{\csh{xintDecToString}}\label{xintDecToString}

\csa{xintDecToString}\etype{\Ff} uses fixed point notation for the output.
Is behaviour remains
somewhat undecided in so far as whether it should identify inputs
which correspond to decimal numbers (i.e. fractions with only powers of
two and five in their denominator, once reduced to lowest terms).

As with \csbxint{DecToStringREZ}, the name is a bit strange as inputs are in no
way limited to decimal numbers but are of the most general type accepted by
the \xintfracname macros.

It is the same macro as \csbxint{DecToStringREZ} except that it does not
remove trailing zeros, in fact \csbxint{DecToStringREZ}|{f}| is defined as
\csbxint{DecToString}|{|\csbxint{REZ}|{f}}|.

\begin{everbatim*}
\xintDecToString{0}, \xintDecToString{1/2}, \xintDecToString{0.5000}\newline
\xintDecToString{1.23456789e5}, \xintDecToString {1.23456789e-3}\newline
\xintDecToString{12345e-1}, \xintDecToString {12345e-2}, \xintDecToString{12345e-3}%
\newline
\xintDecToString{12345e-4}, \xintDecToString {12345e-5}, \xintDecToString{12345e-6}%
\newline
\xintDecToString{1.234567890000e12}, \xintDecToString{1.23456000e-5/10}\newline
\xintDecToString{70/14}
\end{everbatim*}

Since |1.4e|, \csbxint{DecToString} is the default for
\csbxint{iexprPrintOne}, which governs the \csbxint{ieval} output format: in
this use case there is never a |/B| fractional part and the output is always
either an integer (if \csbxint{ieval} was used without optional argument) or a
decimal string
\begin{everbatim}
\def\xintiexprPrintOne{\xintDecToString}
\end{everbatim}

Any replacement of \csbxint{DecToString} as the expansion of
\csbxint{iexprPrintOne} should obey the following blueprint:
\begin{itemize}[noitemsep]
\item to\xtype{} be expandable, but not necessarily \fexpan dable,
\item to accept on input |A| or |A[N]|.
\end{itemize}

\subsection{\csh{xintFracToSci}}\label{xintFracToSci}

\csa{xintFracToSci}\etype{\Ff} was initially at |1.4| a private macro
which served as default customization of \csbxint{exprPrintOne} and,
despite being documented in the user manual, was not supposed to be used
at user level (not being \fexpan dable it could not be nested within
macros of \xintfracname, and besides accepted a limited range of
inputs).

It has been upgraded at |1.4l| to behave like all other \xintfracname
macros.

Here is what it does:
\begin{itemize}[noitemsep,nosep]
\item it first parses the input like any other \xintfracname macro and
  convert it into the ``raw'' |A/B[N]| format,
\item it then produces this output: |A/B| if |N=0| (and |/B| is omitted
  if not |1|), and for |N| not zero, the
  output numerator will be |AeN| written in scientific notation exactly like it
  would by \csbxint{PFloat} but without of course prior rounding to a
  given number of digits; the trailing zeros in the
  significand will be removed always (the \csbxint{PFloatMinTrimmed}
  configuration is ignored).  Then this value in scientific notation (or
  in decimal fixed point notation if the scientific exponent is in the
  \csbxint{PFloatNoSciEmin} to \csbxint{PFloatNoSciEmax} range) will be
  attached to a trailing denominator |/B| (omitted if it is |/1|).
\end{itemize}
Please note:
\begin{itemize}
\item there is no reduction of the fraction |A/B| to lowest terms,
\item trailing zeros in the integer denominator |B| are not moved and
  incorporated into the final scientific exponent,
\item no attempt is made to check if |B| is a product of only |2|'s and
  |5|'s and thus could be integrated into some pure decimal notation for
  the numerator or at least its significand.
\end{itemize}
Changes of \csbxint{PFloat} at |1.4k| have an impact here.
In particular the zero value will give \dtt{0} whether the input was
some |0|, |0e-5|, |0/3|, |0.00|, etc\dots, whereas at |1.4e| it would
have been \dtt{0.0} for cases triggering some \csbxint{PFloat}
subroutine.

The general blueprint is still to be considered \emph{unstable}.

The output routine of \csbxint{eval} is customizable via redefining
\csbxint{exprPrintOne} whose current default is (equivalent to):
\begin{everbatim}
\def\xintexprPrintOne{\xintFracToSci}
\end{everbatim}

\subsection{\csh{xintFracToDecimal}}
\label{xintFracToDecimal}

\csa{xintFracToDecimal}\etype{\Ff} is a variant of \csbxint{FracToSci} which
differs from it in so far as it outputs a numerator using decimal notation,
i.e. with as many zeros as are needed (and no more) and no scientific
exponent.  The denominator goes through ``as is'' except if it is |1|, then it
is omitted.

In other terms its behaviour is currently intermediate between
\csbxint{DecToString} and \csbxint{DecToStringREZ}, as it does not
remove trailing zeros of the denominator.  Consider its behaviour as
\emph{unstable}.

It can be used to customize \csbxint{exprPrintOne}:
\begin{everbatim}
\def\xintexprPrintOne{\xintFracToDecimal}
\end{everbatim}

It was initially at |1.4k| a private macro which served as an alternative to
\csb{xintFracToSci} default customization of \csbxint{exprPrintOne} and,
despite being documented in the user manual, was not supposed to be used at
user level (not being \fexpan dable it could not be nested within macros of
\xintfracname, and besides accepted a limited range of inputs).

It has been upgraded at |1.4l| to behave like all other \xintfracname
macros.


\subsection{\csh{xintTrunc}}\label{xintTrunc}

\csa{xintTrunc}|{x}{f}|\etype{\numx\Ff} returns the start of the decimal
expansion of the fraction |f|, truncated to:
\begin{itemize}
\item if |x>0|, |x| digits after the decimal mark,
\item if |x=0|, an integer,
\item if |x<0|, an integer multiple of |10^{-x}| (in scientific notation).
\end{itemize}
The output is the sole digit token \dtt{0} if and only if the input was exactly
zero; else it contains always either a decimal mark (even if |x=0|) or a
scientific part and it conserves the sign of |f| (even if the truncated value
represents the zero value).

Truncation is done towards zero.
\begin{everbatim*}
\begin{multicols}{2}
  \noindent\xintFor* #1 in {\xintSeq[-1]{7}{-14}}:{\xintTrunc{#1}{-11e12/7}\newline}%
  \xintTrunc{10}{1e-11}\newline \xintTrunc{10}{1/65536}\par
\end{multicols}
\end{everbatim*}

\begin{framed}
  \textbf{Warning:} \emph{it is not yet decided is the current behaviour is
    definitive.}

  Currently \xintfracname has no notion of a positive zero or a negative zero.
  Hence transitivity of \csbxint{Trunc} is broken for the case where the first
  truncation gives on output \dtt{0.00...0} or \dtt{-0.00...0}: a second
  truncation to less digits will then output \dtt{0}, whereas if it had been
  applied directly to the initial input it would have produced \dtt{0.00...0}
  or respectively \dtt{-0.00...0} (with less zeros after decimal mark).

  If \xintfracname distinguished zero, positive zero, and
  negative zero then it would be possible to maintain transitivity.

  The problem would also be fixed, even without distinguishing a negative zero
  on input, if \csbxint{Trunc} always produced \dtt{0.00...0} (with no sign)
  when the mathematical result is zero, discarding the information on original
  input being positive, zero, or negative.

  I have multiple times hesitated about what to do and must postpone again
  final decision.
\end{framed}

\subsection{\csh{xintXTrunc}}\label{xintXTrunc}


\csa{xintXTrunc}|{x}{f}|\xtype{\numx\Ff} is similar to \csbxint{Trunc} with
the following important differences:
\begin{itemize}[nosep]
\item it is completely expandable but not
\fexpan dable, as is indicated by the hollow star in the margin,
\item hence it can not be used as argument to the other package macros, but as
  it \fexpan ds its |{f}| argument, it accepts arguments expressed with other
  \xintfracname macros,
\item it requires |x>0|,
\item contrarily to \csbxint{Trunc} the number of digits on output is not
  limited to about \dtt{19950} and may go well beyond \dtt{100000} (this is
  mainly useful for outputting a decimal expansion to a file),
\item when the mathematical result is zero, it always prints it as
  \dtt{0.00...0} or \dtt{-0.00...0} with |x| zeros after the decimal mark.
\end{itemize}

\textbf{Warning:} 
transitivity is broken too (see discussion of \csbxint{Trunc}), due to the
sign in the last item. Hence \emph{the definitive policy is yet to be fixed.}

Transitivity is here in the sense of using a first |\edef| and then a second
one, because it is not possible to nest \csb{xintXTrunc} directly as argument
to itself. Besides, although the number of digits on output isn't limited,
nevertheless |x| should be less than about |19970| when the number of digits
of the input (assuming it is expressed as a decimal number) is even bigger:
|\xintXTrunc{30000}{\Z}| after |\edef\Z{\xintXTrunc{60000}{1/66049}| raises an
error in contrast with a direct |\xintXTrunc{30000}{1/66049}|. But
|\xintXTrunc{30000}{123.456789}| works, because here the number of digits
originally present is smaller than what is asked for, thus the routine only
has to add trailing zeros, and this has no limitation (apart from \TeX\ main
memory).

\csbxint{XTrunc} will expand fully in an |\edef| or a |\write| (|\message|,
|\wlog|, \dots) or in an \csbxint{expr}-ession, or as list argument to
\csbxint{For*}.

Here is an example session where the
user checks that the decimal expansion of $1/66049=1/257^2$ has the maximal
period length $257*256=65792$ (this period length must be a divisor of
$\phi(66049)$ and to check it is the maximal one it is enough to show that
neither $32896$ nor $256$ are periods.)

\begingroup\small
\everb|@
$ rlwrap etex -jobname worksheet-66049
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=etex)
 restricted \write18 enabled.
**xintfrac.sty
entering extended mode
(/usr/local/texlive/2016/texmf-dist/tex/generic/xint/xintfrac.sty
(/usr/local/texlive/2016/texmf-dist/tex/generic/xint/xint.sty
(/usr/local/texlive/2016/texmf-dist/tex/generic/xint/xintcore.sty
(/usr/local/texlive/2016/texmf-dist/tex/generic/xint/xintkernel.sty))))
*% we load xinttools for \xintKeep, etc... \xintXTrunc itself has no more

*% any dependency on xinttools.sty since 1.2i

*\input xinttools.sty
(/usr/local/texlive/2016/texmf-dist/tex/generic/xint/xinttools.sty)
*\def\m#1;{\message{#1}}

*\m \the\numexpr 257*257\relax;
66049
*\m \the\numexpr 257*256\relax;
65792
*% Thus 1/66049 will have a period length dividing 65792.

*% Let us first check it is indeed periodical.

*\edef\Z{\xintXTrunc{66000}{1/66049}}

*% Let's display the first decimal digits.

*\m \xintXTrunc{208}{\Z};

0.00001514027464458205271843631243470756559523989765174340262532362337052794137
6856576178291874214598252812306015231116292449545034746930309315810988811337037
6538630410755651107511090251177156353616254598858423
*% let's now fetch the trailing digits

*\m \xintKeep{65792-66000}{\Z};% 208 trailing digits

0000151402746445820527184363124347075655952398976517434026253236233705279413768
5657617829187421459825281230601523111629244954503474693030931581098881133703765
38630410755651107511090251177156353616254598858423
*% yes they match! we now check that 65792/2 and 65792/257=256 aren't periods.

*\m \xintXTrunc{256}{\Z};

0.00001514027464458205271843631243470756559523989765174340262532362337052794137
6856576178291874214598252812306015231116292449545034746930309315810988811337037
6538630410755651107511090251177156353616254598858423291798513225029902042423049
554118911717058547442
*\m \xintXTrunc{256+256}{\Z};

0.00001514027464458205271843631243470756559523989765174340262532362337052794137
6856576178291874214598252812306015231116292449545034746930309315810988811337037
6538630410755651107511090251177156353616254598858423291798513225029902042423049
5541189117170585474420505987978621932201850141561567926842192917379521264515738
3154930430438008145467758785144362518736089872670290239064936637950612424109373
3440324607488379839210283274538600130206361943405653378552286938485064119063119
8049932625777831609865402958409665551333
*% now with 65792/2=32896. Problem: we can't do \xintXTrunc{32896+100}{\Z}

*% but only direct \xintXTrunc{32896+100}{1/66049}. Anyway we want to nest it

*% hence let's do it all with (slower) \xintKeep, \xintKeepUnbraced.

*\m \xintKeep {-100}{\xintKeepUnbraced{2+65792/2+100}{\Z}};

9999848597253554179472815636875652924344047601023482565973746763766294720586231
434238217081257854017
*% This confirms 32896 isn't a period length.

*% To conclude let's write the 66000 digits to the log.

*\wlog{\Z}

*% We want always more digits:

*\wlog{\xintXTrunc{150000}{1/66049}}

*\bye
|
\endgroup % $ à cause de fontification de AUCTeX.

The acute observer will have noticed that there is something funny when one
compares the first digits with those after the middle-period:
\begin{everbatim}
0000151402746445820527184363124347075655952398976517434026253236233705279413768...
9999848597253554179472815636875652924344047601023482565973746763766294720586231...
\end{everbatim}
Mathematical exercise: can you explain why the two indeed add to |9999...9999|?

You can try your hands at this simpler one:
\begin{everbatim*}
1/49=\xintTrunc{42+5}{1/49}...\newline
\xintTrim{2}{\xintTrunc{21}{1/49}}\newline
\xintKeep{-21}{\xintTrunc{42}{1/49}}
\end{everbatim*}

This was again an example of the type |1/N| with |N| the square of a prime.
One can also find counter-examples within this class: |1/31^2| and |1/37^2|
have an odd period length (|465| and respectively |111|) hence they can not
exhibit the symmetry.

\begin{framed}
  Mathematical challenge: prove generally that if the period length of the
  decimal expansion of |1/p^r| (with |p| a prime distinct from |2| and |5| and
  |r| a positive exponent) is even, then the previously observed symmetry
  about the two halves of the period adding to a string of nine's applies.
\end{framed}



\subsection{\csh{xintTFrac}}\label{xintTFrac}

\csa{xintTFrac}|{f}|\etype{\Ff} returns the fractional part,
|f=trunc(f)+frac(f)|. Thus if |f<0|, then |-1<frac(f)<=0| and if |f>0| one has
|0<= frac(f)<1|. The |T| stands for `Trunc', and there should exist also
similar macros associated respectively with `Round', `Floor', and `Ceil', each
type of rounding to an integer deserving arguably to be associated with a
fractional ``modulo''. By sheer laziness, the package currently implements
only the ``modulo'' associated with `Truncation'. Other types of modulo may be
obtained more cumbersomely via a combination of the rounding with a subsequent
subtraction from |f|.

Notice that the result is filtered through \csbxint{REZ}, and will thus be of
the form |A/B[N]|, where neither |A| nor |B| has trailing zeros. But the
output fraction is not reduced to smallest terms.

The function call in expressions (\csbxint{expr}, \csbxint{floatexpr}) is
|frac|. Inside |\xintexpr..\relax|, the function |frac| is mapped to
\csa{xintTFrac}. Inside |\xintfloatexpr..\relax|, |frac| first applies
\csa{xintTFrac} to its argument (which may be an exact fraction with more
digits than the floating point precision) and only in a second stage makes the
conversion to a floating point number with the precision as set by |\xintDigits|
(default is \dtt{16}).
\begin{everbatim*}
\xintTFrac {1235/97}, \xintTFrac {-1235/97}\newline
\xintTFrac {1235.973}, \xintTFrac {-1235.973}\newline
\xintTFrac {1.122435727e5}\par
\end{everbatim*}

\subsection{\csh{xintRound}}\label{xintRound}

\csa{xintRound}|{x}{f}|\etype{\numx\Ff} returns the start of the decimal
expansion of the fraction |f|, rounded to:
\begin{itemize}
\item if |x>0|, |x| digits after the decimal mark,
\item if |x=0|, an integer,
\item if |x<0|, an integer multiple of |10^{-x}| (in scientific notation).
\end{itemize}
The output is the sole digit token \dtt{0} if and only if the input was
exactly zero; else it contains always either a decimal mark (even if |x=0|) or
a scientific part and it conserves the sign of |f| (even if the rounded value
represents the zero value).
\begin{everbatim*}
\begin{multicols}{2}
  \noindent\xintFor* #1 in {\xintSeq[-1]{7}{-14}}:{\xintRound{#1}{-11e12/7}\newline}%
  \xintRound{10}{1e-11}\newline \xintRound{10}{1/65536}\newline
\end{multicols}
\end{everbatim*}%
Rounding is done with half-way numbers going towards infinity of
the same sign.

\subsection{\csh{xintFloor}}\label{xintFloor}

|\xintFloor {f}|\etype{\Ff} returns the largest relative integer |N| with
|N|${}\leqslant{}$|f|.
\begin{everbatim*}
\xintFloor {-2.13}, \xintFloor {-2}, \xintFloor {2.13}
\end{everbatim*}
Note the trailing |[0]|, see \csbxint{iFloor} if it is not desired.

\subsection{\csh{xintCeil}}\label{xintCeil}

|\xintCeil {f}|\etype{\Ff} returns the smallest relative integer |N| with
|N|${}>{}$|f|.
\begin{everbatim*}
\xintCeil {-2.13}, \xintCeil {-2}, \xintCeil {2.13}
\end{everbatim*}

\subsection{\csh{xintiTrunc}}\label{xintiTrunc}

\csa{xintiTrunc}|{x}{f}|\etype{\numx\Ff} returns the integer equal to |10^x|
times what \csa{xintTrunc}|{x}{f}| would produce. Attention that leading zeros
are automatically removed: the output is in strict integer format.
\begin{everbatim*}
\begin{multicols}{2}
  \noindent\xintFor* #1 in {\xintSeq[-1]{7}{-14}}:{\xintiTrunc{#1}{-11e12/7}\newline}%
  \xintiTrunc{10}{1e-11}\newline \xintiTrunc{10}{1/65536}\par
\end{multicols}
\end{everbatim*}

\subsection{\csh{xintTTrunc}}\label{xintTTrunc}

\csa{xintTTrunc}|{f}|\etype{\Ff} truncates to an integer (truncation towards
zero). This is the same as |\xintiTrunc {0}{f}| and also the same as
\csbxint{Num}.

\subsection{\csh{xintiRound}}\label{xintiRound}

\csa{xintiRound}|{x}{f}|\etype{\numx\Ff} returns the integer equal to |10^x|
times what \csa{xintRound}|{x}{f}| would return. The output has no leading
zeroes, it is always in strict integer format.
\begin{everbatim*}
\begin{multicols}{2}
  \noindent\xintFor* #1 in {\xintSeq[-1]{7}{-14}}:{\xintiRound{#1}{-11e12/7}\newline}%
  \xintiRound{10}{1e-11}\newline \xintiRound{10}{1/65536}\par
\end{multicols}
\end{everbatim*}

\subsection{\csh{xintiFloor}}\label{xintiFloor}

|\xintiFloor {f}|\etype{\Ff} does the same as \csbxint{Floor} but without the
trailing |/1[0]|.
\begin{everbatim*}
\xintiFloor {-2.13}, \xintiFloor {-2}, \xintiFloor {2.13}
\end{everbatim*}

\subsection{\csh{xintiCeil}}\label{xintiCeil}

|\xintiCeil {f}|\etype{\Ff} does the same as \csbxint{Ceil} but its output is
without the |/1[0]|.
\begin{everbatim*}
\xintiCeil {-2.13}, \xintiCeil {-2}, \xintiCeil {2.13}
\end{everbatim*}

\subsection{\csh{xintE}}\label{xintE}

|\xintE {f}{x}|\etype{\Ff\numx} multiplies the fraction |f| by $10^x$. The
\emph{second} argument |x| must obey the \TeX{} bounds. Example:
\begin{everbatim*}
\count 255 123456789 \xintE {10}{\count 255}
\end{everbatim*}
Don't feed this example to \csbxint{Num}!

\subsection{\csh{xintCmp}}\label{xintCmp}

This\etype{\Ff\Ff} compares two fractions |F| and |G| and produces
|-1|, |0|, or |1| according to |F<G|, |F=G|, |F>G|.

For choosing branches according to the result of comparing |f| and |g|, see
\csbxint{ifCmp}.

\subsection{\csh{xintEq}}\label{xintEq}

|\xintEq{f}{g}|\etype{\Ff\Ff} returns 1 if |f=g|, 0 otherwise.

\subsection{\csh{xintNotEq}}\label{xintNotEq}

|\xintNotEq{f}{g}|\etype{\Ff\Ff} returns 0 if |f=g|, 1 otherwise.

\subsection{\csh{xintGeq}}\label{xintGeq}

This\etype{\Ff\Ff} compares the \emph{absolute values} of two
fractions.
|\xintGeq{f}{g}| outputs |1| if {\catcode`| 12 $|f|\geqslant|g|$} and |0|
if not.

Important: the macro compares \emph{absolute values}.

\subsection{\csh{xintGt}}\label{xintGt}

|\xintGt{f}{g}|\etype{\Ff\Ff} returns \dtt{1} if |f|$>$|g|, \dtt{0} otherwise.

\subsection{\csh{xintLt}}\label{xintLt}

|\xintLt{f}{g}|\etype{\Ff\Ff} returns \dtt{1} if |f|$<$|g|, \dtt{0} otherwise.

\subsection{\csh{xintGtorEq}}\label{xintGtorEq}

|\xintGtorEq{f}{g}|\etype{\Ff\Ff} returns \dtt{1} if |f|$\geqslant$|g|, \dtt{0} otherwise.
Extended by \xintfracname to fractions.

\subsection{\csh{xintLtorEq}}\label{xintLtorEq}

|\xintLtorEq{f}{g}|\etype{\Ff\Ff} returns \dtt{1} if |f|$\leqslant$|g|, \dtt{0} otherwise.

\subsection{\csh{xintIsZero}}\label{xintIsZero}

|\xintIsZero{f}|\etype{f} returns \dtt{1} if |f=0|, \dtt{0} otherwise.

\subsection{\csh{xintIsNotZero}}\label{xintIsNotZero}

|\xintIsNotZero{f}|\etype{f} returns \dtt{1} if |f!=0|, \dtt{0} otherwise.

\subsection{\csh{xintIsOne}}\label{xintIsOne}

|\xintIsOne{f}|\etype{f} returns \dtt{1} if |f=1|, \dtt{0} otherwise.

\subsection{\csh{xintOdd}}\label{xintOdd}

|\xintOdd{f}|\etype{f} returns \dtt{1} if the integer obtained by truncation is
odd, and \dtt{0} otherwise.

\subsection{\csh{xintEven}}\label{xintEven}

|\xintEven{f}|\etype{f} returns \dtt{1} if the integer obtained by truncation is
even, and \dtt{0} otherwise.

\subsection{\csh{xintifSgn}}\label{xintifSgn}

\csh{xintifSgn}\marg{f}\marg{A}\marg{B}\marg{C}\etype{\Ff nnn} executes either the
\meta{A}, \meta{B} or \meta{C} code, depending on its first argument being
respectively negative, zero, or positive.

\subsection{\csh{xintifZero}}\label{xintifZero}

\csa{xintifZero}\marg{f}\marg{IsZero}\marg{IsNotZero}\etype{\Ff nn} expandably
checks if the first mandatory argument |N| (a number, possibly a fraction if
\xintfracname is loaded, or a macro expanding to one such) is zero or not. It
then either executes the first or the second branch.

Beware that both branches must be present.

\subsection{\csh{xintifNotZero}}\label{xintifNotZero}

\csa{xintifNotZero}\marg{N}\marg{IsNotZero}\marg{IsZero}\etype{\Ff nn}
expandably checks if the first mandatory argument |f| is not
zero or is zero. It then either executes the first or the second branch.

Beware that both branches must be present.

\subsection{\csh{xintifOne}}\label{xintifOne}

\csa{xintifOne}\marg{N}\marg{IsOne}\marg{IsNotOne}\etype{\Ff nn} expandably
checks if the first mandatory argument |f| is one or not one. It
then either executes the first or the second branch. Beware that both branches
must be present.

\subsection{\csh{xintifOdd}}\label{xintifOdd}

\csa{xintifOdd}\marg{N}\marg{odd}\marg{not odd}\etype{\Ff nn} expandably
checks if the first mandatory argument |f|, after truncation to an integer, is
odd or even. It then executes accordingly the first or the second branch.
Beware that both branches must be present.

\subsection{\csh{xintifCmp}}\label{xintifCmp}

\csa{xintifCmp}\marg{f}\marg{g}\marg{if f<g}\marg{if f=g}\marg{if
  f>g}\etype{\Ff\Ff nnn} compares its first two arguments and chooses accordingly
the correct branch.

\subsection{\csh{xintifEq}}\label{xintifEq}

\csa{xintifEq}\marg{f}\marg{g}\marg{YES}\marg{NO}\etype{\Ff\Ff nn} checks
equality of its two first arguments and executes accordingly the |YES| or the
|NO| branch.

\subsection{\csh{xintifGt}}\label{xintifGt}

\csa{xintifGt}\marg{f}\marg{g}\marg{YES}\marg{NO}\etype{\Ff\Ff nn}
checks if $f>g$ and in that case executes the |YES| branch.

\subsection{\csh{xintifLt}}\label{xintifLt}

\csa{xintifLt}\marg{f}\marg{g}\marg{YES}\marg{NO}\etype{\Ff\Ff nn}
checks if $f<g$ and in that case executes the |YES| branch.

\subsection{\csh{xintifInt}}\label{xintifInt}

\csa{xintifInt}|{f}{YES branch}{NO branch}|\etype{\Ff nn} expandably chooses
the |YES| branch if |f| reveals itself after expansion and simplification to
be an integer.

\subsection{\csh{xintSgn}}\label{xintSgn}

The sign of a fraction.\etype{\Ff}

\subsection{\csh{xintSignBit}}\label{xintSignBit}

Expands to \dtt{1} for negative input, to \dtt{0} else.\etype{\Ff}

Added at |1.4l|.

\subsection{\csh{xintOpp}}\label{xintOpp}

The opposite of a fraction.\etype{\Ff}
Note that |\xintOpp {3}| produces \dtt{\xintOpp
  {3}} whereas |\xintiiOpp {3}| produces \dtt{\xintiiOpp {3}}.

\subsection{\csh{xintAbs}}\label{xintAbs}

The absolute value\etype{\Ff}. Note that |\xintAbs {-2}|\dtt{=\xintAbs {-2}}
where |\xintiiAbs {-2}| outputs \dtt{=\xintiiAbs {-2}}.

\subsection{\csh{xintAdd}}\label{xintAdd}

Computes the addition\etype{\Ff\Ff} of two fractions.

Since |1.3| always uses the least common multiple of the
denominators.

\subsection{\csh{xintSub}}\label{xintSub}

Computes the difference\etype{\Ff\Ff} of two fractions (|\xintSub{F}{G}|
computes |F-G|).

Since |1.3| always uses the least common multiple of the
denominators.

\subsection{\csh{xintMul}}\label{xintMul}

Computes the product\etype{\Ff\Ff} of two fractions.

Output is not reduced to smallest terms.

\subsection{\csh{xintDiv}}\label{xintDiv}

Computes the quotient \etype{\Ff\Ff} of two fractions.
(|\xintDiv{F}{G}| computes |F/G|).

Output is not reduced to smallest terms.

\subsection{\csh{xintDivFloor}}
\label{xintDivFloor}

Computes the quotient \etype{\Ff\Ff} of two arguments then apply floor
function to get an integer (in strict format). This macro was defined at |1.1|
(but was left not documented until |1.3a|...) and changed at |1.2p|, formerly
it appended |/1[0]| to output.
\begin{everbatim*}
\xintDivFloor{-170/3}{23/2}
\end{everbatim*}

\subsection{\csh{xintMod}}
\label{xintMod}

Computes the remainder associated to the floored division\etype{\Ff\Ff}
\csbxint{DivFloor}. Prior to |1.2p| the meaning was the one of
\csbxint{ModTrunc}. Was left undocumented until |1.3a|.
\begin{everbatim*}
\xintMod{-170/3}{23/2}
\end{everbatim*}

Modified at |1.3| to use a l.c.m. for the denominator of the result.


\subsection{\csh{xintDivMod}}
\label{xintDivMod}

Computes both the floored division and the remainder\etype{\Ff\Ff}
\csbxint{DivFloor}. New at |1.2p| and documented at |1.3a|.
\begin{everbatim*}
\oodef\foo{\xintDivMod{-170/3}{23/2}}\meaning\foo
\end{everbatim*}

\subsection{\csh{xintDivTrunc}}
\label{xintDivTrunc}

Computes the quotient \etype{\Ff\Ff} of two arguments then 
truncates to an integer  (in strict format).
\begin{everbatim*}
\xintDivTrunc{-170/3}{23/2}
\end{everbatim*}

\subsection{\csh{xintModTrunc}}
\label{xintModTrunc}

Computes the remainder\etype{\Ff\Ff} associated with the truncated division of
two arguments. Prior to |1.2p| it was named \csbxint{Mod}, but the latter then
got associated with floored division.
\begin{everbatim*}
\xintModTrunc{-170/3}{23/2}
\end{everbatim*}

Modified at |1.3| to use a l.c.m. for the denominator of the result.


\subsection{\csh{xintDivRound}}
\label{xintDivRound}

Computes the quotient \etype{\Ff\Ff} of the two arguments then rounds to an
integer (in strict format).
\begin{everbatim*}
\xintDivRound{-170/3}{23/2}
\end{everbatim*}

\subsection{\csh{xintSqr}}\label{xintSqr}

Computes the square\etype{\Ff} of one fraction.

\subsection{\csh{xintPow}}\label{xintPow}

\csa{xintPow}{|{f}{x}|}:\etype{\Ff\Numf} computes |f^x| with |f| a fraction
and the exponent |x| possibly also, but if only \xintfracname is loaded it
will be truncated to an integer.

At |1.4e| the behaviour of the macro is enhanced if
\xintexprname is loaded, as it then becomes the support macro for powers
|a^b|, |a**b| (and the \func{pow} function) in \csbxint{eval}: it now
handles also non-integer exponents.  Also, if the exponent is an integer, it
checks a priori if an exact evaluation
would produce more than about \dtt{10000} digits and then does in its place a
floating point evaluation.

The check whether the exponent is integer is not on the mathematical value but
on the format (for reasons of efficiency). So |4/2| will not be recognized as
integer and it will thus trigger usage of the floating point evaluations;
however |2.0| will be recognized as an integer, as of course |2|.

Still under the condition that \xintexprname is loaded, if the exponent
is considered an integer it is then checked if
\begin{enumerate}[nosep]
\item it is less than \dtt{10000} (in absolute value),
\item and the output will contain less than
\dtt{10000} digits separately for numerator and denominator.
\end{enumerate}
If both conditions true, then the power is computed \emph{exactly}.
Else it is computed as by \csbxint{FloatPower} (but the output uses raw
|A[N]| format not scientific notation). Use \csbxint{iiPow} (on integers
only, not fractions) for exact powers with larger exponents.

Before version \dtt{2.0} of \xintexprname, half-integers were also identified and
then the power was computed by combining suitably \csbxint{FloatPower}
with \csbxint{FloatSqrt}.\CHANGED{2.0a1} This has been removed.

Within an \csbxint{iiexpr}|..\relax| the infix operators |^| and |**|
are mapped to \csbxint{iiPow} and powers are always computed exactly
even if they would produce more than \dtt{10000} digits and melt your
CPU; within an \csbxint{expr}-ession |^| and |**| and the \func{pow}
function are mapped to \csbxint{Pow} as described here.

\subsection{\csh{xintFac}}\label{xintFac}

This is a convenience variant of \csbxint{iiFac} which applies \csbxint{Num}
to its argument\etype{\Numf}. Notice however that the output will have a trailing
|[0]| according to the \xintfracname format for integers.

\subsection{\csh{xintBinomial}}\label{xintBinomial}

This is a convenience variant of \csbxint{iiBinomial} which applies
\csbxint{Num} to its arguments\etype{\Numf\Numf}. Notice however that the
output will have a trailing |[0]| according to the \xintfracname format for
integers.

\subsection{\csh{xintPFactorial}}\label{xintPFactorial}

This is a convenience variant of \csbxint{iiPFactorial} which applies
\csbxint{Num} to its arguments\etype{\Numf\Numf}. Notice however that the
output will have a trailing |[0]| according to the \xintfracname format for
integers.

\subsection{\csh{xintMax}}\label{xintMax}

The maximum of two fractions.\etype{\Ff\Ff} Beware that |\xintMax {2}{3}|
produces \dtt{\xintMax {2}{3}}. The original, for use with
integers only with no need of normalization, is available as \csbxint{iiMax}:
|\xintiiMax {2}{3}=|\dtt{\xintiiMax {2}{3}}.\etype{ff}

\begin{everbatim*}
\xintMax {2.5}{7.2}
\end{everbatim*}

\subsection{\csh{xintMin}}\label{xintMin}

The minimum of two fractions.\etype{\Ff\Ff} Beware that |\xintMin {2}{3}|
produces \dtt{\xintMin {2}{3}}. The original, for use with 
integers only with no need of normalization, is available as \csbxint{iiMin}:
|\xintiiMin {2}{3}=|\dtt{\xintiiMin {2}{3}}.\etype{ff}

\begin{everbatim*}
\xintMin {2.5}{7.2}
\end{everbatim*}

\subsection{\csh{xintMaxof}}\label{xintMaxof}

The maximum of any number of fractions, each within braces, and the whole
thing within braces. \etype{f{$\to$}{\lowast\Ff}}

\begin{everbatim*}
\xintMaxof {{1.23}{1.2299}{1.2301}} and \xintMaxof {{-1.23}{-1.2299}{-1.2301}}
\end{everbatim*}

\subsection{\csh{xintMinof}}\label{xintMinof}

The minimum of any number of fractions, each within braces, and the whole
thing within braces. \etype{f{$\to$}{\lowast\Ff}}

\begin{everbatim*}
\xintMinof {{1.23}{1.2299}{1.2301}} and \xintMinof {{-1.23}{-1.2299}{-1.2301}}
\end{everbatim*}

\subsection{\csh{xintSum}}\label{xintSum}

This\etype{f{$\to$}{\lowast\Ff}} computes the sum of fractions. The output
will now always be in the form |A/B[n]|. The original, for big integers only
(in strict format), is available as \csa{xintiiSum}.

\begin{everbatim*}
\xintSum {{1282/2196921}{-281710/291927}{4028/28612}}
\end{everbatim*}

No simplification attempted.

\subsection{\csh{xintPrd}}\label{xintPrd}

TThis\etype{f{$\to$}{\lowast\Ff}} computes the product of fractions. The output
will now always be in the form |A/B[n]|. The original, for big integers only
(in strict format), is available as \csa{xintiiPrd}.

\begin{everbatim*}
\xintPrd {{1282/2196921}{-281710/291927}{4028/28612}}
\end{everbatim*}

No simplification attempted.

\begin{everbatim*}
$\xintIsOne {21921379213/21921379213}\neq
 \xintIsOne {1.00000000000000000000000000000001}$
\end{everbatim*}

\subsection{\csh{xintGCD}}\label{xintGCD}

The greatest common divisor of its two arguments, which are possibly
\emph{fractions}.\etype{\Ff\Ff}

Prior to |1.4| a macro of the same name existed in \xintgcdname. But
it truncated its two arguments to integers via \csbxint{Num}.

See \csbxint{iiGCD} for the integer only variant.

\subsection{\csh{xintLCM}}\label{xintLCM}

The least common multiple of its two arguments, which are possibly
\emph{fractions}.\etype{\Ff\Ff}

Prior to |1.4| a macro of the same name existed in \xintgcdname. But
it truncated its two arguments to integers via \csbxint{Num}.

See \csbxint{iiLCM} for the integer only variant.

\subsection{\csh{xintGCDof}}\label{xintGCDof}

\csa{xintGCDof}|{{a}{b}{c}...}|\etype{f{$\to$}{\lowast\Ff}} computes the
greatest common divisor of |a|, |b|, \dots{}. The arguments are allowed to be
\emph{fractions}: the macro produces the non-negative generator of the
fractional ideal they generate. The list argument may be a macro as it is
\fexpan ded first. If all arguments vanish, then also the output.

Prior to |1.4| a macro of the same name existed in \xintgcdname. But
it truncated all its arguments to integers via \csbxint{Num} and then
proceeded with integer only computations.

See \csbxint{iiGCDof} for the integer only variant.

% Semble encore vrai à 1.4d
% Mais je n'ai testé que sur un exemple...
% (which is about |6X| faster than this one for integer arguments).

\subsection{\csh{xintLCMof}}\label{xintLCMof}

\csa{xintLCMof}|{{a}{b}{c}...}|\etype{f{$\to$}{\lowast\Ff}} computes the least
common multiple of |a|, |b|, \dots{}.  The arguments are allowed to be
\emph{fractions}: the macro produces the non-negative generator of the
intersection of the corresponding fractional ideals. The list argument may be
a macro, it is \fexpan ded first. If one of the item vanishes, then also the
output.

Prior to |1.4| a macro of the same name existed in \xintgcdname. But
it truncated all its arguments to integers via \csbxint{Num}.

See \csbxint{iiLCMof} for the integer only variant.

% Avant 1.4d on avait ceci :
% (which is about |9X| faster han this one for integer arguments).
% mais à 1.4d le lcm des fractions est environ 4X fois plus efficace,
% en ce qui concerne son emploi avec des entiers (testé sur un seul exemple)
% donc le gain de faire \xintiiexpr n'est plus que 2X !

\subsection{\csh{xintDigits}, \csh{xinttheDigits}}
\label{xintDigits}
\label{xinttheDigits}

The syntax |\xintDigits := N;| or (recommended) |\xintDigits := N\relax|
assigns the value of |N| to the number of digits to be used by floating
point operations (this uses internally a |\mathchardef| assignement, and
|N| stands for (or expands to) a legal \TeX\ number). The default is
|16|. The maximal value is |32767|.

Accepted syntax includes also |\xintDigits = N;| or |\xintDigits =
N\relax|, i.e.\@{} the colon before the equality sign is optional.

Spaces do not matter as long as they do not occur in-between digits:
\begin{everbatim*}
\xintDigits := 24\relax\xinttheDigits, %
\xintDigits:=36  \relax\xinttheDigits, %
\xintDigits:= 16 \relax and \xinttheDigits.
\end{everbatim*}

As shown above |\xinttheDigits|\etype{} expands to the stored value.


% It has always been the case that an active colon |:| was allowed.

An ending active semi-colon |;| is \emph{not} compatible: it can and
will cause low-level \TeX{} errors.  This is why the alternative syntax
\begin{everbatim}
\xintDigits:= N\relax
\end{everbatim}
is recommended (with or without the semi-colon).  This is hopefully the
syntax now in use in most examples from the documentation.


%  This
% restriction always applied, but never got properly documented prior to
% |1.3f| release... It is possible to use |\string;| but then there can not be
% any space separating it from the digits.

Actually, any non-expanding token can be used in place of the
|\relax|. This non-expanding ending token (for example a full stop) will
get removed from the token stream.
\begin{everbatim*}
\xintDigits  = 24\def\xinttheDigits, % only for showing it works! don't do that!
\xintDigits := 36.\xinttheDigits,    % one can use a dot in place of semi-colon
\xintDigits  = 16\relax and \xinttheDigits.\par % with \relax, even better
\end{everbatim*}

\subsection{\csh{xintSetDigits}}
\label{xintSetDigits}

To be used as |\xintSetDigits|\marg{expression}\ntype{\numx} where the
expression will be fed to |\numexpr|. It is a shortcut for doing
|\xintDigits := \numexpr|\meta{expression}|\relax \relax|.
\begin{everbatim*}
\xintSetDigits{1+2+3+4+5}The value is now \xinttheDigits.
\xintSetDigits{2*8}The value is now \xinttheDigits.\par
\end{everbatim*}

\subsection{\csh{xintFloat}}
\label{xintFloat}
\label{xintFloatZero}


The macro |\xintFloat [P]{f}|\etype{{\upshape[\numx]}\Ff} has an optional
argument |P| which replaces the current value of |\xinttheDigits|. The
fraction |f| is then printed in scientific notation with a rounding to |P| digits.

That is, on output: the first digit is from |1| to |9|, it is possibly
prefixed by a minus sign and is followed by a dot and |P-1| digits, then a
lower case |e| and an exponent |N|. The trailing zeroes are not trimmed.

\begin{framed}
  There is one exception to the general description: the zero value, which
  gets output as \dtt{\xintFloat{0}}. This was changed at
  |1.4k|, until then it was using \dtt{0.e0} as output. Customize via
  \csh{xintFloatZero} whose default definition is:
\begin{everbatim}
\def\xintFloatZero{0.0e0}
\end{everbatim}
\end{framed}

Starting with |1.2k|, when the input is a fraction |AeN/BeM|
the output always is the \emph{correct rounding} to |P| digits. Formerly, this
was guaranteed only when |A| and |B| had at most |P+2| digits, or when |B| was
|1| and |A| was arbitrary, but in other cases it was only guaranteed that the
difference between the original fraction and the rounding was at most
\dtt{0.6} unit in the last place (of the output), hence the output could
differ in the last digit (and earlier ones in case of chains of zeros or
nines) from the correct rounding.

Also: for releases |1.2j| and earlier, in the special case when
|A/B| ended up being rounded up to the next power of ten, the output was with
a mantissa of the shape |10.0...0eN|. However, this worked only for |B=1| or
when both |A| and |B| had at most |P+2| digits, because the detection of the
rounding-up to next power of ten was done not on original |A/B| but on an
approximation |A'/B'|, and it could happen that |A'/B'| was itself being
rounded \emph{down} to a power of ten which however was a rounding \emph{up}
of original |A/B|. With the |1.2j| refactoring which achieves correct rounding
in all cases, it was decided not to add to the code the extra overhead of
detecting with 100\% fiability the rounding up to next power of ten (such
overhead would necessitate alterations of the algorithm and as a result we
would end up with a slightly less efficient one; it would make sense in a
model where inputs have their intrinsic precisions which is obeyed by the
implementation of the basic operations, but currently the design decision for
the floating point macros is that when the target precision is |P| the inputs
are rounded first to |P| digits before further processing.)
\begin{everbatim*}
{\def\x{99999999999999994999999999999999/99999999999999999999999999999999}%
\xintFor #1 in {13, 14, 15, 16, 17, 18, 19, 47, 48, 49, 50, 79, 80, 81}
\do{#1: \xintFloat[#1]{\x}\xintifForLast{\par}{\newline}}}%
\end{everbatim*}
As an aside, which is illustrated by the above, rounding is not
transitive in the number of kept digits.
\begin{everbatim*}
{\def\x{137893789173289739179317/13890138013801398}%
\xintFor* #1 in {\xintSeq{4}{20}}
\do{#1: \xintFloat[#1]{\x}\newline}}%
\xintFloat{5/9999999999999999}\newline
\xintFloat[32]{5/9999999999999999}\newline
\xintFloat[48]{5/9999999999999999}\par
\end{everbatim*}



\subsection{\csh{xintFloatBraced}}
\label{xintFloatBraced}

The experimental macro
|\xintFloatBraced[P]{f}|\etype{{\upshape[\numx]}\Ff} does like
\csbxint{Float} but its output consists of three \TeX-braced groups
\centeredline{\marg{sign bit}\marg{scientific exponent}\marg{full width
    mantissa with decimal point}} It is provided for users
knowing how to pick one or the other of these constituents from usage
of auxiliary macros. Or one can use \csbxint{Assign}:
\begin{everbatim*}
\begingroup
\xintAssign\xintFloatBraced[7]{-3.1234e-14}\to\A\B\C
\string\A\ has meaning \meaning\A\newline
\string\B\ has meaning \meaning\B\newline
\string\C\ has meaning \meaning\C\par
\endgroup
\end{everbatim*}
Some aspects are undecided:
\begin{itemize}[noitemsep]
\item should the first item be rather |-1|, |0|, or |1|? or |-|, nothing, nothing?
\item in case of zero value the output ignores \csbxint{FloatZero}, it
  uses a zero exponent and full width fractional mantissa \dtt{\csname
    xint_gobble_ii\expandafter\endcsname\romannumeral0\xintfloatbraced{0}}
  (here no |[P]| and \csbxint{theDigits} has value
  \dtt{\xinttheDigits}), should it be otherwise?
\item should the mantissa be without the decimal separator ? should it
  incorporate the sign ?
\item in case the mantissa is without separator, should the exponent be biased to match it?
\end{itemize}

\subsection{\csh{xintFloatToDecimal}}
\label{xintFloatToDecimal}

|\xintFloatToDecimal [P]{f}|\etype{{\upshape[\numx]}\Ff} does float rounding
on input like \csbxint{Float} then outputs the number using decimal notation,
i.e. with as many zeros as are needed (and no more) and no scientific
exponent.

In other terms it behaves (and is essentially defined) as:
\begin{everbatim}
\xintDecToStringREZ{\xintFloat[optional P]{<input>}}
\end{everbatim}
Examples:
\begin{everbatim*}
\xintFloatToDecimal{6.02e23}\newline
\xintFloatToDecimal{6.02000000000000e23}\newline
\xintFloatToDecimal[20]{1/7e10}\newline
\xintFloatToDecimal[30]{1/7e10}
\end{everbatim*}

See \csbxint{DecToString}.

\subsection{\csh{xintPFloat}}
\label{xintPFloat}

|\xintPFloat [P]{f}|\etype{{\upshape[\numx]}\Ff} is like \csbxint{Float} but
``pretty-prints'' the output.

This macro was initially added at |1.1| as a (very primitive) "prettifying
printer" for floating point number, and was then somewhat influenced by Maple,
for example the zero value was printed as "\dtt{0.}". Then at |1.4e| there was
breaking change and the rules became somewhat similar to observed Python
behaviour: mantissas trimmed of trailing zeros (whether or not scientific
notation was used in the output) and integers printed with a trailing
"\dtt{.0}", in particular the zero value was printed as "\dtt{0.0}".

|1.4k| brought some breaking changes, which are reversible
via customizing macros:
\begin{itemize}
\item Integers (when scientific notation is dropped according to
  criteria mentioned next) without a "\dtt{.0}"
  suffix.
\item Same for the zero value, now "\dtt{\xintPFloat{0}}".
\item Significands are trimmed of trailing zeros only if that removes at least
  \dtt{4} zeros. The rationale is that automatic removal of trailing zeros
  (which was influenced at |1.4e| from practice with Python in interactive
  mode) proves annoying visually with aligned values in tables, as this
  creates voids, so we want to do this only when really the
  presence of trailing zeros is not some kind of numerical fluke.
\end{itemize}
These changes impact the \csbxint{floateval} output as
\csbxint{floatexprPrintOne} defaults to using \csbxint{PFloat}.

\begin{framed}
  In\IMPORTANTf\ this documentation ``trailing zeros'' refers not to how
  the input looked like, but
  to the corresponding mantissa of width |P| or \csbxint{theDigits}.
\end{framed}


The default rules are thus now:
\begin{enumerate}[nolistsep]
\item The input is float-rounded to either |Digits| or the optional argument.
\item zero is printed as \dtt{\xintPFloat{0}}.
\item \dtt{x.yz...eN} is printed in decimal fixed point if
  $-4\leq\text{|N|}\leq+5$ else it is printed in scientific notation.
\item Trailing zeros of the mantissa are trimmed if, and only if there are at least \dtt{4}
  of them.
\item In case of fixed point output format, and the value is an integer, the
  integer is printed  with no decimal mark.
\item In case of scientific notation output format, and the mantissa has only
  one digit, no decimal mark is used.
\end{enumerate}

% The old rules were:
% \begin{enumerate}[nosep]
% \item The input is float-rounded to either |Digits| or the optional argument,
% \item zero is printed as \dtt{0.},
% \item \dtt{x.yz...eN} is printed ``as is'' if the exponent |N| is at least
%   \dtt{6} or at most \dtt{-6},
% \item else fixed point decimal notation is used,
% \item and there is no trimming of trailing zeroes.
% \end{enumerate}

\begingroup\color{everbatimxfgcolor}
\begin{multicols}2
\def\test #1{\item #1${}\to{}$\xintPFloat{#1}}%
\string\xintDigits\ at \xinttheDigits
\begin{itemize}[nosep,font=\normalcolor]
\test {0}
\test {1.2340000e-7}\test {1.2340000e-6}\test {1.2340000e-5}\test {1.2340000e-4}
\test {1.2340000e-3}\test {1.2340000e-2}\test {1.2340000e-1}
\test {1.2340000e0}\test {1.2340000e1}\test {1.2340000e2}\test {1.2340000e3}
\test {1.2340000e4}\test {1.2340000e5}\test {1.2340000e6}\test {1.2340000e7}
\test {1e-7/7}\test {1e-6/7}\test {1e-5/7}\test {1e-4/7}
\test {1e-3/7}\test {1e-2/7}\test {1e-1/7}
\test {1e0/7}\test {1e1/7}\test {1e2/7}\test {1e3/7}
\test {1e4/7}\test {1e5/7}\test {1e6/7}\test {1e7/7}
\end{itemize}
\end{multicols}
\endgroup

\subsubsection{Customizing macros of \csh{xintPFloat}}
\label{xintPFloatE}
\label{xintPFloatZero}
\label{xintPFloatIntSuffix}
\label{xintPFloatLengthOneSuffix}
\label{xintPFloatNoSciEmin}
\label{xintPFloatNoSciEmax}
\label{xintPFloatMinTrimmed}

A number of macros allow to customize the behaviour of \csbxint{PFloat}:
\begin{itemize}
\item \csa{xintPFloatE} allows to modify the separator of the
  scientific notation. Here is its default:
%
  \footnote{For \TeX perts: it is allowed to define
    \csa{xintPFloatE} as a macro which grabs the exponent as an argument
    delimited by a dot, and produces \fexpan dably an output also delimited by
    a dot (which gets removed via further internal processing).}
%
\begin{everbatim}
\def\xintPFloatE{e}
\end{everbatim}

\item \csa{xintPFloatZero} says how to print the zero value.
  The default:
\begin{everbatim}
\def\xintPFloatZero{0}
\end{everbatim}

\item \csa{xintPFloatIntSuffix} is postfixed to integer values
  (when scientific notation is not used).  Its default at |1.4k| is to add
  nothing.  It replaces the formerly hard-coded "\dtt{.0}" from |1.4e| (prior
  to that trailing zeros from the full significand of |P| or
  \csbxint{theDigits} digits were not trimmed).
\begin{everbatim}
\def\xintPFloatIntSuffix{}
\end{everbatim}

\item \csa{xintPFloatLengthOneSuffix} is postfixed to trimmed
  mantissas having only one digit, when scientific notation is used.  Its
  default at |1.4k| is to add nothing.  It replaces formerly hard-coded
  "\dtt{.0}".
\begin{everbatim}
\def\xintPFloatLengthOneSuffix{}
\end{everbatim}

\item \csa{xintPFloatNoSciEmax} is the maximal scientific exponent
  which will trigger use of decimal fixed point notation and
  \csa{xintPFloatNoSciEmin} is the minimal one.  Their defaults at |1.4k| are the
  same as the formerly hard-coded behaviour from |1.4e|:
\begin{everbatim}
\def\xintPFloatNoSciEmax{5}
\def\xintPFloatNoSciEmin{-4}
\end{everbatim}
  For example (with the package default width of \dtt{16} digits for mantissas
  of floating point numbers):
\begin{everbatim*}
\begingroup
\def\xintPFloatNoSciEmin{-20}
\xintPFloat{1e-19/7}\newline
\xintPFloat{1e-20/7}\par
\def\xintPFloatNoSciEmax{19}
\xintPFloat{1e20/7}\newline
\xintPFloat{1e21/7}\par
\endgroup
\end{everbatim*}

\item \csa{xintPFloatMinTrimmed} is the minimal number
of trailing zeros which have to be present to activate actual trimming.
The default definition is:
\begin{everbatim}
\def\xintPFloatMinTrimmed{4}
\end{everbatim}
Defining it to expand to \dtt{-1} or \dtt{0} will enable the trimming of
trailing zeros always, and setting it to a value at least equal to |P|
(or \csbxint{theDigits} if no |[P]|) will prevent it
altogether.

This setting is ignored for the case of an integer value, if the
criteria for using fixed point notation are met, and for the case of a
one-digit mantissa in scientific notation.

\end{itemize}

To mimick approximately the Python behaviour in interactive sessions,
one can use the following configuration:
\begin{everbatim}
\def\xintPFloatZero{0.0}%
\def\xintPFloatIntSuffix{.0}%
\def\xintPFloatLengthOneSuffix{.0}%
\def\xintPFloatNoSciEmax{15}%
\def\xintPFloatNoSciEmin{-4}%
\def\xintPFloatMinTrimmed{-1}%
\end{everbatim}
\begingroup\color{everbatimxfgcolor}
\def\xintPFloatZero{0.0}%
\def\xintPFloatIntSuffix{.0}%
\def\xintPFloatLengthOneSuffix{.0}%
\def\xintPFloatNoSciEmax{15}%
\def\xintPFloatNoSciEmin{-4}%
\def\xintPFloatMinTrimmed{-1}%
\def\test#1{#1${}\to{}$\xintPFloat{#1}\newline}%
\test{0.}
\test{1234.}
\test{6e100}
\test{1234567812345678.12345678}
\test{12345678123456781.2345678}
\test{12345678.12340}
\test{12345678.123400}
\test{0.1234567812345678}
\test{0.00012345678123456785}
\test{0.000012345678123456785}\par
\endgroup
%
The above using the default \csbxint{Digits} setting of \dtt{16} digits.
This can not naturally match exactly CPython which uses internally radix
|2| not |10|, and has (by default) mantissas with \dtt{53=1+52} bits.

Same, but playing with \ctanpackage{xintsession} in its |&fp| mode:
\begin{everbatim}
>>> &fp
fp mode (16 digits)
>>> \\def\xintPFloatZero{0.0}
(executing \\def\xintPFloatZero {0.0} in background)
)
Runaway argument?
def\xintPFloatZero {0.0}\message {
}\xs_fetch_aa \endinput 
! File ended while scanning use of \\.
<inserted text> 
                \par 
<*> xintsession^^M
                  
? S
OK, entering \scrollmode...

*\xintsession

  You are back to the xintexpr interactive session!
  (current mode: fp (Digits=16), with Digits=16)

  ">>> " means central computing is waiting for input
  "... " means that multi-line input continues.  Use `;' to terminate it.

  Say `&bye' at any time to terminate the session and the TeX run.
>>> \def\xintPFloatZero{0.0}
(executing \def \xintPFloatZero {0.0} in background)

>>> \def\xintPFloatIntSuffix{.0}\def\xintPFloatLengthOneSuffix{.0}

(executing \def \xintPFloatIntSuffix {.0}\def \xintPFloatLengthOneSuffix {.0} i
n background)

>>> \def\xintPFloatNoSciEmax{15}\def\xintPFloatNoSciEmin{-4}

(executing \def \xintPFloatNoSciEmax {15}\def \xintPFloatNoSciEmin {-4} in back
ground)

>>> \def\xintPFloatMinTrimmed{-1}
(executing \def \xintPFloatMinTrimmed {-1} in background)

>>> 0., 1234., 6e100;
@_1     0.0, 1234.0, 6.0e100
>>> 1234567812345678.12345678;
@_2     1234567812345678.0
>>> 12345678123456781.2345678;
@_3     1.234567812345678e16
>>> 12345678.12340;
@_4     12345678.1234
>>> 12345678.123400;
@_5     12345678.1234
>>> 0.1234567812345678;
@_6     0.1234567812345678
>>> 0.00012345678123456785;
@_7     0.0001234567812345679
>>> 0.000012345678123456785;
@_8     1.234567812345679e-5
>>> &bye
\end{everbatim}
This is with version |0.4alpha (2021-11-01)| of
\ctanpackage{xintsession}.  Probably some ``magic'' shortcuts will be
added in future to its interface for this kind of tasks, in place of 
the |\def|. 

% \subsection{\csh{xintFloatE}}\label{xintFloatE}
% %! {\small New with |1.097|.}

% |\xintFloatE [P]{f}{x}|\etype{{\upshape[\numx]}\Ff\numx} multiplies the input
% |f| by $10^x$, and
% converts it to float format according to the optional first argument or current
% value of |\xinttheDigits|.
% \begin{everbatim*}
% \xintFloatE {1.23e37}{53}
% \end{everbatim*}

% There is since |1.4b| an unfortunate proximity in name with \csbxint{PFloatE}
% despite the two things having absolutely nothing in common.

\subsection{\csh{xintFloatAdd}}\label{xintFloatAdd}


|\xintFloatAdd [P]{f}{g}|\etype{{\upshape[\numx]}\Ff\Ff} first replaces |f|
and |g| with their float approximations |f'| and |g'| to |P| significant
places or to the precision from |\xintDigits|. It then produces
the sum |f'+g'|, correctly rounded to nearest with the same number of
significant places.


\subsection{\csh{xintFloatSub}}\label{xintFloatSub}


|\xintFloatSub [P]{f}{g}|\etype{{\upshape[\numx]}\Ff\Ff} first replaces |f|
and |g| with their float approximations |f'| and |g'| to |P| significant
places or to the precision from |\xintDigits|. It then produces
the difference |f'-g'| correctly rounded to nearest |P|-float.


\subsection{\csh{xintFloatMul}}\label{xintFloatMul}


|\xintFloatMul [P]{f}{g}|\etype{{\upshape[\numx]}\Ff\Ff} first replaces |f|
and |g| with their float approximations |f'| and |g'| to |P| (or
|\xinttheDigits|) significant places. It then correctly rounds
the product |f'*g'| to nearest |P|-float.

See \autoref{ssec:floatingpoint} for more.

\begin{framed}
  It is high time the author improved this algorithm to avoid computing
  an exact product of up to |2P| digits, only to discard roughly half of
  them when rounding to |P| digits!

  This issue\NewWithf{2.0a1} has been partly addressed for multiplication
  in \csbxint{floateval} (aka |\calxeval|), which uses
  specialized truncated-product algorithms at certain precisions.
  For larger precisions, however, the full product is still computed
  before rounding. This will need some improvements in the future.
\end{framed}

\subsection{\csh{xintFloatDiv}}\label{xintFloatDiv}


|\xintFloatDiv [P]{f}{g}|\etype{{\upshape[\numx]}\Ff\Ff} first replaces |f|
and |g| with their float approximations |f'| and |g'| to |P| (or
|\xinttheDigits|) significant places. It then correctly rounds
the fraction |f'/g'| to nearest |P|-float.

See \autoref{ssec:floatingpoint} for more.

Notice in the special situation with |f| and |g| integers that |\xintFloatDiv
[P]{f}{g}| will \emph{not necessarily} give the correct rounding of the
exact fraction |f/g|. Indeed the macro arguments are each first individually
rounded to |P| digits of precision. The correct syntax to get the correctly
rounded integer fraction |f/g| is \csbxint{Float}|[P]{f/g}|.

\subsection{\csh{xintFloatPow}}\label{xintFloatPow}

|\xintFloatPow [P]{f}{x}|\etype{{\upshape[\numx]}\Ff\numx} uses either the
optional argument |P| or in its absence the value of |\xinttheDigits|. It
computes a floating approximation to |f^x|.

The exponent |x| will be handed over to a |\numexpr|, hence count registers are
accepted on input for this |x|. And the absolute value \verb+|x|+ must obey the
\TeX{} bound.

The argument |f| is first rounded to |P| significant figures to give
|f'|. The output |Z| is such that the exact |f'^x| differs from
|Z| by an absolute error less than |0.52 ulp(Z)|.
\begin{everbatim*}
\xintFloatPow {3.1415}{1234567890}
\end{everbatim*}

\subsection{\csh{xintFloatPower}}\label{xintFloatPower}

\csa{xintFloatPower}|[P]{f}{g}|\etype{{\upshape[\numx]}\Ff\Numf} computes a
floating point value |f^g| where the exponent |g| is not constrained to be at
most the \TeX{} bound \dtt{\number "7FFFFFFF}. It may even be a fraction
|A/B| but will be truncated to an integer. The exponent of the
\emph{output} however \emph{must} at any rate obey the \TeX{} bound.

The argument |f| is first rounded to |P| significant figures to give
|f'|. The output |Z| is such that the exact |f'^g| differs from
|Z| by an absolute error less than |0.52 ulp(Z)|.

Prior to \dtt{2.0a1} this macro was used in \csbxint{floateval} for
|f**g| (or \func{pow}) when the exponent |g| was recognized as an
integer. This is no longer the case: the |exp(g*log(f))| route is used
by \csbxint{floateval} even if |g| is an integer.\CHANGED{2.0a1}

The internal implementation remains in use by \csbxint{eval} for
\emph{integer} exponents when an exact computation would produce more
than about \dtt{10000} digits in the numerator or denominator, or when
the absolute value of the exponent is at least \dtt{10000}. See
\csbxint{Pow}.  It is explained there that the recognition of an integer
exponent by \csbxint{eval} is based on its input format, not on its
mathematical value.

The integer exponent |g| may have more than |P| (or \csbxint{theDigits})
digits, it is handled exactly. And as said above its absolute value may
exceed the \TeX\ bound.

Compare the following example (where the exponent is larger than the \TeX{} bound)
\begin{everbatim*}
\xintFloatPower {3.1415}{3703703670}
\end{everbatim*}
\newline
with Python's built-in floating-point arithmetic:
\begin{everbatim}
>>> 3.1415**3703703670
Traceback (most recent call last):
  File "<python-input-3>", line 1, in <module>
    3.1415**3703703670
    ~~~~~~^^~~~~~~~~~~
OverflowError: (34, 'Result too large')
\end{everbatim}

% Notice that this is a bound on the distance from
% |f'^g| to |Z|, where |f'| is the rounded value of the original input |f|; 
% the distance from |f^g| to |Z| can be much worse if |g| is very
% large. Roughly, when |g| is negligible compared to |10^P|, we get an extra
% difference of up to about |50g ulp(Z)| which completely dwarfs the |0.52
% ulp(Z)|. Thus, if |f| has strictly more than |P| digits, then the computation
% must be done with an elevated working precision |P'|. For example with
% |g=1000| we should use |P'=P+6| to achieve a total error at worst slightly
% bigger than |0.55 ulp(Z)| after the final rounding from |P'| to |P| digits to
% get |Z|.

% Examples:%
% %
% \footnote{|\np| is formatting macro from the \url{http://ctan.org/pkg/numprint}
%   package.}
% %
% \begin{everbatim*}
% \np{\xintFloatPower [8]{3.1415}{3e9}}\newline% Notice that 3e9>2^31
% \np{\xintFloatPower [48]{1.1547}{\xintiiPow {2}{35}}}\newline
% \end{everbatim*}%
% $2^{35}=\xintiiPow {2}{35}$ exceeds \TeX's bound, but what
% counts is the exponent of the result which, while dangerously close to
% $2^{31}$ is not quite there yet.

% With expressions:
% \begin{everbatim*}
% {\xintDigits:=48\relax \np{\xintthefloatexpr 1.1547^2^35\relax}}
% \end{everbatim*}

% There is a subtlety here that the |2^35| will be evaluated as a floating point
% number but fortunately it only has \dtt{11} digits, hence the final evaluation
% is done with a correct exponent. It would have been safer, and also more
% efficient to code the above rather as:
% \begin{everbatim}
% \xintthefloatexpr 1.1547^\xintiiexpr 2^35\relax\relax
% \end{everbatim}

% Here is an example with
% |12^16| as exponent, which has $18$ digits (\dtt{={\xintiiPow{12}{16}}}).
% \begin{everbatim*}
% {\xintDigits:=12\relax \np{\xintthefloatexpr (1+1e-8)^\xintiiexpr 12^16\relax\relax}}\newline
% \np{\xintthefloatexpr (1+1e-8)^\xintiiexpr 12^16\relax\relax}\newline
% {\xintDigits:=27\relax \np{\xintthefloatexpr (1+1e-8)^12^16\relax}}\newline
% {\xintDigits:=48\relax \np{\xintthefloatexpr (1+1e-8)^12^16\relax}}
% \end{everbatim*}

% There is an important difference between |\xintFloatPower[Q]{X}{Y}| and
% |\xintthefloatexpr[Q] X^Y\relax|: in the former case the computation is done
% with |Q| digits or precision,%
% %
% \footnote{if |X| and |Y| themselves stand for some
% floating point macros with arguments, their respective evaluations obey the
% precision |\xinttheDigits| or as set optionally in the macro calls
% themselves.}
% %
% whereas with \csbxint{thefloatexpr}|[Q]| the evaluation of the
% expression proceeds with |\xinttheDigits| digits of precision, and the final
% result is then rounded to |Q| digits: thus this makes real sense only if used
% with |Q<\xinttheDigits|.

\subsection{\csh{xintFloatSqrt}}\label{xintFloatSqrt}

\csa{xintFloatSqrt}|[P]{f}|\etype{{\upshape[\numx]}\Ff} computes a floating
point approximation of $\sqrt{\text{|f|}}$, either using the optional precision |P| or
the value of |\xinttheDigits|.

More precisely since |1.2f| the macro achieves so-called \emph{correct
  rounding}:\IMPORTANT{} the produced value is the rounding to |P| significant
places of the abstract exact value, \emph{if the input has itself at most |P|
  digits} (and an arbitrary exponent).
\begin{everbatim*}
\xintFloatSqrt [89]{10}\newline
\xintFloatSqrt [89]{100}\newline
\xintFloatSqrt [89]{123456789}\par
\end{everbatim*}

And now some tests to check that correct rounding applies correctly (sic):
\begin{everbatim*}
The argument has 16 digits, hence escapes initial rounding:\newline
\xintFloatSqrt {5625000075000001}\newline
This one gets rounded hence same value is computed:\newline
\xintFloatSqrt {5625000075000001.4}\newline
but actual value is more like:\newline
\xintFloatSqrt [24]{5625000075000001.4}\newline
\xintFloatSqrt [32]{5625000075000001.4}\newline
The argument has 48 digits, hence escapes initial rounding:\newline
\xintFloatSqrt [48]{562500000000000000000000750000000000000000000001}\newline
\xintFloatSqrt [64]{562500000000000000000000750000000000000000000001}\newline
\xintFloatSqrt [80]{562500000000000000000000750000000000000000000001}\newline
\end{everbatim*}
(we observe in passing illustrations that rounding to nearest is not
transitive.)\par






\subsection{\csh{xintFloatFac}}\label{xintFloatFac}

\csa{xintFloatFac}|[P]{f}|\etype{{\upshape[\numx]}\Numf} returns the
factorial with either \csa{xinttheDigits} or |P| digits of precision.



The exact theoretical value differs from the calculated one |Y| by an absolute
error strictly less than |0.6 ulp(Y)|.

\begin{everbatim*}
$1000!\approx{}$\xintFloatFac [30]{1000}
\end{everbatim*}
The computation proceeds via doing explicitely the product.%
%
\footnote{An approach based upon the Stirling formula could not be
done at time of implementation because of lack of exponential and
logarithm.  This is now supported.  So perhaps
at some point in future Gamma function will be implemented.}
%

The maximal allowed argument is $99999999$, but already $100000!$ currently
takes, for \dtt{16} digits of precision, a few seconds on my laptop (it
returns \dtt{2.824229407960348e456573}).

The |factorial| function is available in \csbxint{floatexpr}:
\begin{everbatim*}
\xintthefloatexpr factorial(1000)\relax % same as 1000!
\end{everbatim*}

\subsection{\csh{xintFloatBinomial}}\label{xintFloatBinomial}

\csa{xintFloatBinomial}|[P]{x}{y}|\etype{{\upshape[\numx]}\Numf\Numf} computes
binomial coefficients with either \csa{xinttheDigits} or |P| digits of
precision.

When |x<0| an out-of-range error is raised. Else if |y<0| or if |x<y| the
macro evaluates to \dtt{\xintFloatBinomial{1}{-1}}.
The exact theoretical value differs from the calculated one |Y| by an absolute
error strictly less than |0.6 ulp(Y)|.

\begin{everbatim*}
${3000\choose 1500}\approx{}$\xintFloatBinomial [24]{3000}{1500}
\end{everbatim*}

% \begin{everbatim*}
% ${9999\choose 5000}\approx{}$\xintFloatBinomial [24]{9999}{5000}
% \end{everbatim*}

% 2015/11/28
% 7.95895131766219474168799e3007
% aparté: (testé avec Maple 16, 2015/11/28)
% > binomial (9999.,5000.);
%                                               3008
%                              0.795895131768 10
%
% > Digits:=32;
%                                  Digits := 32
%
% > binomial (9999.,5000.);
%                                               3008
%                              0.795895131768 10
% apparemment le binomial de Maple ne sait pas calculer avec plus de
% précision!
% et son dernier chiffre est faux! Pourtant GAMMA(9999.) fonctionne. Sauf si
% je n'ai pas compris quelque chose il me semble donc que le binomial de Maple
% est bogué...binomial(100.,50.); marche lui et binomial(4999.,2000.); aussi,
% bon clairement on a un bug de Maple ! oui binomial(8999.,5000.); ainsi que
% binomial(10999.,5000.); fonctionnent avec Digits:=32 mais **pas**
% binomial(9999.,5000.)... binomial(10000.,5000.); et binomial(9998.,5000.);
% sont OK. Est-ce qu'on gagne quelque chose pour un bug report ?
% > binomial(9999.,5000.);
%                                               3008
%                              0.795895131768 10
% > binomial(10000.,5000.);
%                                                          3009
%                   0.1591790263532438948337597273641521 10
% > binomial(9998.,5000.);
%                                                          3008
%                   0.3979077671466477799149739359402922 10
% en plus je lui demande 32 chiffres et il m'en sort 34.

The associated function in \csbxint{floatexpr} is \func{binomial}:
\begin{everbatim*}
\xintthefloatexpr binomial(3000,1500)\relax
\end{everbatim*}

The computation is based on the formula |(x-y+1)...x/y!| (here one arranges
|y<=x-y| naturally).


\subsection{\csh{xintFloatPFactorial}}\label{xintFloatPFactorial}

\csa{xintFloatPFactorial}|[P]{x}{y}|\etype{{\upshape[\numx]}\Numf\Numf}
computes the product |(x+1)...y|.




The arguments must be integers (they are expanded inside |\numexpr|)
and the allowed range is $-100000000\leqslant x, y\leqslant99999999$. If
$x\geqslant y$ the product is considered empty hence returns one (as a
floating point value).
See also \csbxint{iiPFactorial}.


The exact theoretical value differs from the calculated one |Y| by an absolute
error strictly less than |0.6 ulp(Y)|.

The associated function in \csbxint{floatexpr} is \func{pfactorial}:
\begin{everbatim*}
\xintthefloatexpr pfactorial(2500,5000)\relax
\end{everbatim*}

\xintDigits:=16\relax 


\clearpage
\let\xintfracnameUp\undefined
\csname xintbinhexnameUp\endcsname
\def\n{|{N}|}
\def\m{|{M}|}
\def\x{|{x}|}
\section{Macros of the \xintbinhexname package}
\RaisedLabel{sec:binhex}

\localtableofcontents

\subsection{Introduction}

This package provides expandable conversions of (big) integers between
the hexadecimal, decimal, octal (since |1.4n|) and binary bases.

First version of this package was in the |1.08| (|2013/06/07|) release
of \xintname. Its routines remained unmodified until their complete
rewrite at release |1.2m| (|2017/07/31|). Macros became faster, but the
inputs got limited to a few thousand digits, whereas the |1.08| versions
could handle (slowly...) tens of thousands of digits.  At |1.4n| some
internals were refactored to use the \cs{expanded} primitive (which was
not available in 2017).\NewWith{1.4n}  The maximal sizes got increased, see
\autoref{ssec:binhexsizes}.  More significant probably, the octal radix
was added to the ones covered.

|1.4p| added \csbxint{LowerHex} and \csbxint{UpperHex}.\NewWith{1.4p}


For each provided conversion macro, its argument is first \fexpan
ded. This expansion is supposed to give a sequence of digits, with
perhaps a (unique) leading minus sign, which gets prepended to output
(note that \csbxint{DecToHex}|{-0}| thus expands to \dtt{\xintDecToHex{-0}}).

Let's insist that inputs can not start (after expansion) with a |0b|,
|0o|, |0x|, |#x|, |"|, |'|, or similar prefix notation: they must
consist only of digits as fitting to the binary, octal, decimal, or
hexadecimal radix.  Situation is different if using \xintexprname-essions,
see \autoref{ssec:exprbinhex} next.

Low-level unrecoverable errors will occur if for
example an octal input contains the decimal digit |8|.

Hexadecimal digits in input must be uppercased. Category codes for
them may be indifferently \emph{letter} or \emph{other}. In output they
are of category \emph{letter} (and uppercased).

Leading zeroes in the input are allowed, and depending on the macro may
show up or not in the output.  Note in particular:
\begin{itemize}[noitemsep]
\item Inputs with no leading zeros give outputs with no leading zeros.

\item All rules have (deliberate) exceptions, check the docs of
  \csbxint{CHexToBin} and
  \csbxint{COctToBin} which are variants of \csbxint{HexToBin} and
  \csbxint{OctToBin}.

\item Outputs (if non vanishing) from \csbxint{DecToHex} or \csbxint{DecToOct}
  have no leading zeros whether or not the inputs had some.

\item \csbxint{BinToHex} and \csbxint{BinToOct} always use the minimal number of
  hexadecimal resp.\@ octal digits as needed to represent the original binary digits,
  inclusive of their leading zeroes. For example
  \csbxint{BinToHex}|{0000001}| outputs \dtt{\xintBinToHex{0000001}} and
  \csbxint{BinToOct}|{0000001}| outputs \dtt{\xintBinToOct{0000001}}.
\end{itemize}


\subsection{\xintexprname-essions}
\label{ssec:exprbinhex}

Inside \xintexprname-essions,\NewWith{1.4n} hexadecimal can be input
using either |"| or |0x| prefixes, octal using either |'| or |0o|, and
binary using |0b|.  Prior to |1.4n| only |"| was implemented and it was
needed to load \xintbinhexname additionally to \xintexprname.  This is
now done automatically.

Hexadecimal letters must be uppercased.  In both of \csbxint{eval} and
\csbxint{floateval} a ``fractional part'' after the full stop as
separator is allowed for all three bases.  Here is an example using the
three non-decimal bases:
\begin{everbatim*}
\xinteval{subsm({x, y, x==y}, x="FF.FF * '777.777 * 0b11111.11111;
                              y=(16^2-16^-2)(8^3-8^-3)(2^5-2^-5);)}
\end{everbatim*}

The
|p| postfix notation from some programming languages, which stands for
an extra power of two, is however not implemented so far.

With \csbxint{iieval}\NewWith{1.4n}, which handles only integers, there
is an optional parameter |[h]|, |[o]|, or |[b]| for automatic conversion
of the output (this works also with comma separated inputs and even
nested bracketed inputs).  Here is an example illustrating the new
more condensed syntax:
\begin{everbatim*}
\xintiieval[b]{0b1011100101001110 * 0b111100011}
\end{everbatim*}

Compare with how one would have had to input it prior to |1.4n|:
\begin{everbatim*}
\xintDecToBin{\xintiieval{\xintBinToDec{1011100101001110}*\xintBinToDec{111100011}}}
\end{everbatim*}

Note that if while parsing an octal number the digits |8| or |9| is
encountered, this does not trigger un error but terminates the octal
input fetched so far and inserts a tacit multiplication.  Same for
binary input if encountering a digit other than |0| or |1|.


\subsection{\csh{xintHexToDec}}\label{xintHexToDec}

Converts from hexadecimal to decimal.\etype{f}

\texttt{\string\xintHexToDec
  \string{\printnumber{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}\string}}\endgraf\noindent
\dtt{->\printnumber{\xintHexToDec{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}}}

\subsection{\csh{xintHexToOct}}\label{xintHexToOct}

Converts from hexadecimal to octal.\etype{f}

\mbox{}\NewWith{1.4n}%
\texttt{\string\xintHexToOct
  \string{\printnumber{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}\string}}\endgraf\noindent
\dtt{->\printnumber{\xintHexToOct{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}}}

\subsection{\csh{xintHexToBin}}\label{xintHexToBin}

Converts from hexadecimal to binary. Up to three leading zeroes of the binary output
are trimmed.\etype{f}

\texttt{\string\xintHexToBin
  \string{\printnumber{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}\string}}\endgraf\noindent
\dtt{->\printnumber{\xintHexToBin{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}}}

\subsection{\csh{xintCHexToBin}}\label{xintCHexToBin}

Converts from hexadecimal to binary.\etype{f} Same as \csbxint{HexToBin}, but
an input with |N| hexadecimal digits will give an output with exactly |4N|
binary digits, leading zeroes are not trimmed.

\texttt{\string\xintCHexToBin
  \string{\printnumber{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}\string}}\endgraf\noindent
\dtt{->\printnumber{\xintCHexToBin{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F46DCE46C6032936BF37DAC918814C63}}}

This can be combined with \csbxint{BinToHex} for round-trips preserving
leading zeroes for |4N| binary digits numbers, whereas using
\csbxint{HexToBin} gives reproducing round-trips only for |4N| binary numbers
numbers not starting with |0000|.
\begin{everbatim*}
\xintBinToHex{0001111}\par
\end{everbatim*}
Chaining, we end up with 4N-3 digits, as three binary zeroes are trimmed:
\begin{everbatim*}
\xintHexToBin{\xintBinToHex{0001111}}\par
\end{everbatim*}
But the next will always reproduce the initial input zero-filled to length 4N:
\begin{everbatim*}
\xintCHexToBin{\xintBinToHex{0001111}}\par
\end{everbatim*}
Another example (visible space characters manually inserted):\newline
$000000001111101001010001\xrightarrow{\text{\string\xintBinToHex}}%$
\xintBinToHex{000000001111101001010001}\xrightarrow{\text{\string\xintHexToBin\hphantom{X}}}
\text{\textvisiblespace\textvisiblespace\textvisiblespace}
\xintHexToBin{\xintBinToHex{000000001111101001010001}}$\newline%$
$000000001111101001010001\xrightarrow{\text{\string\xintBinToHex}}%$
\xintBinToHex{000000001111101001010001}\xrightarrow{\text{\string\xintCHexToBin}}
\xintCHexToBin{\xintBinToHex{000000001111101001010001}}$%$
\par

\subsection{\csh{xintDecToHex}}\label{xintDecToHex}

Converts from decimal to hexadecimal.\etype{f}

\texttt{\string\xintDecToHex \string{\printnumber{2718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003}\string}}\endgraf\noindent\dtt{->\printnumber{\xintDecToHex{2718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003}}}

\subsection{\csh{xintDecToOct}}\label{xintDecToOct}

Converts from decimal to octal.\etype{f}

\mbox{}\NewWith{1.4n}\texttt{\string\xintDecToOct \string{\printnumber{2718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003}\string}}\endgraf\noindent\dtt{->\printnumber{\xintDecToOct{2718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003}}}

\subsection{\csh{xintDecToBin}}\label{xintDecToBin}

Converts from decimal to binary.\etype{f}

\texttt{\string\xintDecToBin \string{\printnumber{2718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003}\string}}\endgraf\noindent\dtt{->\printnumber{\xintDecToBin{2718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003}}}

\subsection{\csh{xintOctToHex}}\label{xintOctToHex}

Converts from octal to hexadecimal.\etype{f}

\mbox{}\NewWith{1.4n}%
\texttt{\string\xintOctToHex
  \string{\printnumber{4324471370632244651340507676412402744247076026137040661070442727362552730135470644713643334710661401451155374676654443040246143}\string}}\endgraf\noindent
\dtt{->\printnumber{\xintOctToHex{4324471370632244651340507676412402744247076026137040661070442727362552730135470644713643334710661401451155374676654443040246143}}}

\subsection{\csh{xintOctToDec}}\label{xintOctToDec}

Converts from octal to decimal.\etype{f}

\mbox{}\NewWith{1.4n}%
\texttt{\string\xintOctToDec
  \string{\printnumber{4324471370632244651340507676412402744247076026137040661070442727362552730135470644713643334710661401451155374676654443040246143}\string}}\endgraf\noindent
\dtt{->\printnumber{\xintOctToDec{4324471370632244651340507676412402744247076026137040661070442727362552730135470644713643334710661401451155374676654443040246143}}}

\subsection{\csh{xintOctToBin}}\label{xintOctToBin}

Converts from octal to binary.\etype{f} Up to two leading zeroes of the
binary output are trimmed.

\mbox{}\NewWith{1.4n}%
\texttt{\string\xintOctToBin
  \string{\printnumber{14324471370632244651340507676412402744247076026137040661070442727362552730135470644713643334710661401451155374676654443040246143}\string}}\endgraf\noindent
\dtt{->\printnumber{\xintOctToBin{14324471370632244651340507676412402744247076026137040661070442727362552730135470644713643334710661401451155374676654443040246143}}}

\subsection{\csh{xintCOctToBin}}\label{xintCOctToBin}

Converts from octal to binary.\etype{f}

Same as \csbxint{OctToBin}, except that an input with |N|
octal digits will give an output with exactly |3N| binary digits,
leading zeroes are not trimmed.

\mbox{}\NewWith{1.4n}%
\texttt{\string\xintCOctToBin
  \string{\printnumber{14324471370632244651340507676412402744247076026137040661070442727362552730135470644713643334710661401451155374676654443040246143}\string}}\endgraf\noindent
\dtt{->\printnumber{\xintCOctToBin{14324471370632244651340507676412402744247076026137040661070442727362552730135470644713643334710661401451155374676654443040246143}}}

\subsection{\csh{xintBinToHex}}\label{xintBinToHex}

Converts from binary to hexadecimal.\etype{f}

The input is first extended if need-be by leading zeros in order to have
|4N| binary digits, then the output will have |N| hexadecimal digits
(thus, if the input did not have a leading zero, the output will not either).

\texttt{\string\xintBinToHex
  \string{\printnumber{100011010100100111001011111000110011010010100100110101001011100000101000111110111110100001010100000010111100100010100111000111110000010110001011111000100000110110001000111000100100010111010111011110010101101010111011000001011101100111000110100100111001011110100011011011100111001000110110001100000001100101001001101101011111100110111110110101100100100011000100000010100110001100011}\string}}\endgraf\noindent
\dtt{->\printnumber{\xintBinToHex{100011010100100111001011111000110011010010100100110101001011100000101000111110111110100001010100000010111100100010100111000111110000010110001011111000100000110110001000111000100100010111010111011110010101101010111011000001011101100111000110100100111001011110100011011011100111001000110110001100000001100101001001101101011111100110111110110101100100100011000100000010100110001100011}}}

\subsection{\csh{xintBinToDec}}\label{xintBinToDec}

Converts from binary to decimal.\etype{f}

\texttt{\string\xintBinToDec
  \string{\printnumber{100011010100100111001011111000110011010010100100110101001011100000101000111110111110100001010100000010111100100010100111000111110000010110001011111000100000110110001000111000100100010111010111011110010101101010111011000001011101100111000110100100111001011110100011011011100111001000110110001100000001100101001001101101011111100110111110110101100100100011000100000010100110001100011}\string}}\endgraf\noindent
\dtt{->\printnumber{\xintBinToDec{100011010100100111001011111000110011010010100100110101001011100000101000111110111110100001010100000010111100100010100111000111110000010110001011111000100000110110001000111000100100010111010111011110010101101010111011000001011101100111000110100100111001011110100011011011100111001000110110001100000001100101001001101101011111100110111110110101100100100011000100000010100110001100011}}}

\subsection{\csh{xintBinToOct}}\label{xintBinToOct}

Converts from binary to octal.\etype{f}

The input is first extended if need-be by leading zeros in order to have
|3N| binary digits, then the output will have |N| octal digits
(thus, if the input did not have a leading zero, the output will not either).

\mbox{}\NewWith{1.4n}%
\texttt{\string\xintBinToOct
  \string{\printnumber{100011010100100111001011111000110011010010100100110101001011100000101000111110111110100001010100000010111100100010100111000111110000010110001011111000100000110110001000111000100100010111010111011110010101101010111011000001011101100111000110100100111001011110100011011011100111001000110110001100000001100101001001101101011111100110111110110101100100100011000100000010100110001100011}\string}}\endgraf\noindent
\dtt{->\printnumber{\xintBinToOct{100011010100100111001011111000110011010010100100110101001011100000101000111110111110100001010100000010111100100010100111000111110000010110001011111000100000110110001000111000100100010111010111011110010101101010111011000001011101100111000110100100111001011110100011011011100111001000110110001100000001100101001001101101011111100110111110110101100100100011000100000010100110001100011}}}

\subsection{\csh{xintLowerHex}}\label{xintLowerHex}

The output\etype{f} is the lowercase version of the input (which can be
with mixed case).  An empty input is allowed.\NewWith{1.4p}  Letters on input can be of
catcode \emph{letter} or \emph{other}. Letters in output are of catcode
\emph{letter}.
\begin{everbatim*}
\xintLowerHex{11A9397C66949A97051F7D0A817914E3E0B17C41B11C48BAEF2B5760BB38D272F}\newline
\xintLowerHex{\xintDecToHex{12379813738877118345}}
\end{everbatim*}

As it \fexpan ds its argument, you can as shown above use it to wrap usage
of one of the package macros converting to hexadecimal.

\subsection{\csh{xintUpperHex}}\label{xintUpperHex}

The output\etype{f} is the uppercase version of the input (which can be
with mixed case).  An empty input is allowed.\NewWith{1.4p} Letters on input can be of
catcode \emph{letter} or \emph{other}. Letters in output are of catcode
\emph{letter}.
\begin{everbatim*}
\xintUpperHex{11a9397c66949a97051f7d0a817914e3e0b17c41b11c48baef2b5760bb38d272f}\newline
\xintHexToDec{\xintUpperHex{abcdef0123456789}}
\end{everbatim*}

As shown above, use it to wrap the argument of \csbxint{HexToDec} if for
example some lowercase, or mixed case, hexadecimal input needs to get
converted to decimal.

\subsection{Maximal sizes of inputs}\label{ssec:binhexsizes}

\autoref{tab:binhexsizes} recapitulates the maximal allowed sizes, as
found out with the \TeX{} installation of the author.  The tests are done
putting the macro inside an \cs{edef} and compiling with the |etex| binary.

The value in the second column is the maximal |N| such that the macro
does not raise an error on an input with |N| digits (if nested in
another macro, the maximal input size may become lower than stated).
The third column gives the corresponding maximal size of the output.

These maximal sizes depend on \TeX\ parameters such as input stack size,
expansion depth, and parameter stack size.  The fourth column gives the
\TeX\ parameter cited in the error message when trying with |N+1|
digits.  When the limiting parameter is the main memory size, the upper
limits depend on external factors such as how many macros are loaded in
\TeX{} memory (for example they would be lower in a \LaTeX{} document or
if \xintexprname is loaded), so they are here given simply as
indications.  They are so large anyhow that basically in practice, this
means no real limitation.

Regarding the conversions to and from decimal radix, they allow a more
limited range, but are still able to handle inputs with ten thousand
digits, one can thus consider in practice that their size limitations
are also only of theoretical interest.

\medskip
\begingroup
\makeatletter\def\@captype{table}\capstart
  \centering
\begin{tabular}{rrrr}
  \hline
  &Max\ length\ of\ input&->\ length\ of\ output&Limiting factor\\
\csbxint{DecToHex}&16042&13323&expansion depth=10000\\
\csbxint{DecToOct}&15040&16654&expansion depth=10000\\
\csbxint{DecToBin}&16042&53291&expansion depth=10000\\
\csbxint{HexToDec}&11072&13333&expansion depth=10000\\
\csbxint{OctToDec}&14763&13333&expansion depth=10000\\
\csbxint{BinToDec}&44290&13333&expansion depth=10000\\
\csbxint{HexToOct}&553514&738019&main memory size=5000000\\
\csbxint{HexToBin}&553514&\the\numexpr4*553514\relax&main memory size=5000000\\
\csbxint{OctToHex}&711660&533745&main memory size=5000000\\
\csbxint{OctToBin}&711660&2134980&main memory size=5000000\\
\csbxint{BinToHex}&1992650&498163&main memory size=5000000\\
\csbxint{BinToOct}&1868109&622703&main memory size=5000000\\
%\csbxint{CHexToBin}&553513&2214052&main memory size=5000000.\\
%\csbxint{COctToBin}&711660&2134980&main memory size=5000000.\\
  \hline
\end{tabular}
\captionof{table}{Maximal sizes for \xintbinhexname 1.4n macros with TeXLive 2025}\label{tab:binhexsizes}
\endgroup

% \medskip

% These sizes are larger (and very significantly so for the |bin<->hex|
% conversions) than with the previous release.  For comparison
% \autoref{tab:binhexsizes14m} was computed using |1.4m 2022/06/10| and
% TeXLive 2025 with its default memory settings which are: input stack
% size at \dtt{10000}, expansion depth at \dtt{10000}, parameter stack
% size at \dtt{20000}.  The previous last update to that table in this
% documentation had been done using \xintbinhexname |1.2n| and TeXLive
% 2021, the input stack size was only at \dtt{5000} and it was then the
% limiting factor in all cases and the maximal input sizes in 2021 were
% (in almost all cases) about half of the displayed values.

% %! (except for
% %! \csbxint{HexToDec} maximal input size which was at \dtt{8298} digits).

% \medskip
% \begingroup
% \makeatletter\def\@captype{table}\capstart
%   \centering
% \begin{tabular}{rrrr}
%   \hline
%   &Max\ length\ of\ input&->\ length\ of\ output&Limiting factor\\
%   \csbxint{DecToHex}&12035&9995&input stack size=10000\\
%   \csbxint{DecToBin}&12035&39980&input stack size=10000\\
%   \csbxint{HexToDec}&11072&13333&expansion depth=10000\\
%   \csbxint{BinToDec}&39984&12037&expansion depth=10000\\
%   \csbxint{HexToBin}&9996&39984&expansion depth=10000\\
% %  \csbxint{CHexToBin}&9996&39984&expansion depth=10000\\
%   \csbxint{BinToHex}&39984&9996&expansion depth=10000\\
%   \hline
% \end{tabular}
% \captionof{table}{Maximal sizes for \xintbinhexname 1.4m 2022/06/10,
%                   but with TeXLive 2025 memory settings}\label{tab:binhexsizes14m}
% \endgroup

\clearpage
\let\xintbinhexnameUp\undefined
\csname xintgcdnameUp\endcsname
\def\n{|{N}|}
\def\m{|{M}|}
\def\x{|{x}|}
\section{Macros of the \xintgcdname package}
\RaisedLabel{sec:gcd}

\localtableofcontents

\subsection{Introduction}

This package was included in the original release |1.0| (|2013/03/28|) of the
\xintbundlename.



At |1.3d| macros \csbxint{iiGCD} and \csbxint{iiLCM} are copied over to
\xintname, hence \func{gcd} and \func{lcm} functions in \csbxint{iiexpr} were
available simply from loading only \xintexprname, and the \xintgcdname dependency
got removed.

\begin{framed}
From |1.1| to |1.3f| the package loaded only \xintcorename,
not \xintname and neither \xinttoolsname.

But at |1.4| it loads automatically both \xintname and \xinttoolsname (the
latter being a requirement since |1.09h| of the \csbxint{TypesetEuclideAlgorithm} and
\csbxint{TypesetBezoutAlgorithm} macros).

The macros \csbxint{iiGCD} and \csbxint{iiLCM} got relocated into
\xintname. \IMPORTANTf The macros \csbxint{GCD}, \csbxint{LCM},
\csbxint{GCDof}, and \csbxint{LCMof} are \emph{removed}:
\xintfracname provides under these names more powerful macros handling
general fractions and not only integers.
\end{framed}

\subsection{\csh{xintBezout}}\label{xintBezout}

|\xintBezout|\n\m\etype{\Numf\Numf} returns three numbers |U|, |V|,
|D| within braces where |D| is the (non-negative) GCD, and \dtt{UN + VM = D}.
\begin{everbatim*}
\oodef\X{\xintBezout {10000}{1113}}\meaning\X\par
\xintAssign {\xintBezout {10000}{1113}}\to\U\V\D
U: \meaning\U, V: \meaning\V, D: \meaning\D\par
AU+BV: \xinttheiiexpr 10000*\U+1113*\V\relax\par
\noindent\oodef\X{\xintBezout {123456789012345}{9876543210321}}\meaning\X\par
\xintAssign \X\to\U\V\D
U: \meaning\U, V: \meaning\V, D: \meaning\D\par
AU+BV: \xinttheiiexpr 123456789012345*\U+9876543210321*\V\relax
\end{everbatim*}

\subsection{\csh{xintEuclideAlgorithm}}\label{xintEuclideAlgorithm}

|\xintEuclideAlgorithm|\n\m\etype{\Numf\Numf} applies the Euclide algorithm
and keeps a copy of all quotients and remainders.
\begin{everbatim*}
\edef\X{\xintEuclideAlgorithm {10000}{1113}}\meaning\X
\end{everbatim*}

The first item is the number of steps, the second is |N|, the
third is the GCD, the fourth is |M| then the first quotient and
remainder, the second quotient and remainder, \dots until the
final quotient and last (zero) remainder.

\subsection{\csh{xintBezoutAlgorithm}}\label{xintBezoutAlgorithm}

|\xintBezoutAlgorithm|\n\m\etype{\Numf\Numf} applies the Euclide algorithm
and keeps a copy of all quotients and remainders. Furthermore it computes the
entries of the successive products of the 2 by 2 matrices
$\left(\vcenter{\halign {\,#&\,#\cr q & 1 \cr 1 & 0 \cr}}\right)$ formed from
the quotients arising in the algorithm.
\begin{everbatim*}
\edef\X{\xintBezoutAlgorithm {10000}{1113}}\printnumber{\meaning\X}
\end{everbatim*}

The first item is the number of steps, the second is |N|, then
|0|, |1|, the GCD, |M|, |1|, |0|, the first quotient, the first
remainder, the top left entry of the first matrix, the bottom left
entry, and then these four things at each step until the end.

\subsection{\csh{xintTypesetEuclideAlgorithm}}\label{xintTypesetEuclideAlgorithm}

This macro is just an example of how to organize the data returned by
\csa{xintEuclideAlgorithm}.\ntype{\Numf\Numf} Copy the source code to a new
macro and modify it to what is needed.

\leftedline{|\xintTypesetEuclideAlgorithm {123456789012345}{9876543210321}|}
\xintTypesetEuclideAlgorithm {123456789012345}{9876543210321}

\subsection{\csh{xintTypesetBezoutAlgorithm}}%
\label{xintTypesetBezoutAlgorithm}

This macro is just an example of how to organize the data returned by
\csa{xintBezoutAlgorithm}.\ntype{\Numf\Numf} Copy the source code to a new
macro and modify it to what is needed.

\leftedline{|\xintTypesetBezoutAlgorithm {10000}{1113}|}
\xintTypesetBezoutAlgorithm {10000}{1113}

\clearpage
\let\xintgcdnameUp\undefined
\csname xintseriesnameUp\endcsname
\def\n{|{N}|}
\def\m{|{M}|}
\def\x{|{x}|}
\section{Macros of the \xintseriesname package}
\RaisedLabel{sec:series}

\localtableofcontents

\subsection{Introduction}

This package was first released with version |1.03| (|2013/04/14|) of the
\xintbundlename.

The \Ff{} expansion type of various macro arguments is only a \Numf{} if only
\xintname but not \xintfracname is loaded. The macro \csbxint{iSeries} is
special and expects summing big integers obeying the strict format, even if
\xintfracname is loaded.

The arguments serving as indices are of the \numx{} expansion type.

In some cases one or two of the macro arguments are only expanded at a later
stage not immediately.

\begin{framed}
  Since |1.3|, \csbxint{Add} and \csbxint{Sub} use systematically the least
  common multiple of the denominators. Some of the comments in this chapter
  refer to the earlier situation where often the denominators were simply
  multiplied together. \emph{They have yet to be updated to reflect the new
    situation brought by the |1.3| release.} Some of these comments may now be
  off-synced from the actual computation results and thus may be wrong.
\end{framed}
%% \clearpage

\subsection{\csh{xintSeries}}\label{xintSeries}

\csa{xintSeries}|{A}{B}{\coeff}|\etype{\numx\numx\Ff} computes
$\sum_{\text{|n=A|}}^{\text{|n=B|}}$|\coeff{n}|. The initial and final indices
must obey the |\numexpr| constraint of expanding to numbers at most |2^31-1|.
The |\coeff| macro must be a one-parameter \fexpan dable macro, taking on
input an explicit number |n| and producing some number or fraction |\coeff{n}|;
it is expanded at the time it is
needed.%
%

\begin{everbatim*}
\def\coeff #1{\xintiiMON{#1}/#1.5} % (-1)^n/(n+1/2)
\fdef\w {\xintSeries {0}{50}{\coeff}} % we want to re-use it
\fdef\z {\xintJrr {\w}[0]} % the [0] for a microsecond gain.
% \xintJrr preferred to \xintIrr: a big common factor is suspected.
% But numbers much bigger would be needed to show the greater efficiency.
\[ \sum_{n=0}^{n=50} \frac{(-1)^n}{n+\frac12} = \xintTeXFrac\z \]
\end{everbatim*}

The definition of |\coeff| as |\xintiiMON{#1}/#1.5| is quite suboptimal. It
allows |#1| to be a big integer, but anyhow only small integers are accepted
as initial and final indices (they are of the \numx{} type). Second, when the
\xintfracname parser sees the |#1.5| it will remove the dot hence create a
denominator with one digit more. For example |1/3.5| turns internally into
|10/35| whereas it would be more efficient to have |2/7|. For info here is the
non-reduced |\w|:
\[\xintTeXFrac\w\]
It would have been bigger still in releases earlier than |1.1|: now, the
\xintfracname \csbxint{Add} routine does not multiply blindly denominators
anymore, it checks if one is a multiple of the other. However it does not
practice systematic reduction to lowest terms.

A more efficient way to code |\coeff| is illustrated next.
\begin{everbatim*}
\def\coeff #1{\the\numexpr\ifodd #1 -2\else2\fi\relax/\the\numexpr 2*#1+1\relax [0]}%
% The [0] in \coeff is a tiny optimization: in its presence the \xintfracname parser
% sees something which is already in internal format.
\fdef\w {\xintSeries {0}{50}{\coeff}}
\[\sum_{n=0}^{n=50} \frac{(-1)^n}{n+\frac12}=\xintTeXFrac\w\]
\end{everbatim*}
The reduced form |\z| as displayed above only differs from this one by a
factor of \dtt{\xintNum {\xintDenominator\w/\xintDenominator\z}}.

\setlength{\columnsep}{0pt}
\everb|@
\def\coeffleibnitz #1{\the\numexpr\ifodd #1 1\else-1\fi\relax/#1[0]}
\cnta 1
\loop
% in this loop we recompute from scratch each partial sum!
% we can afford that, as \xintSeries is fast enough.
\noindent\hbox to 2em{\hfil\texttt{\the\cnta.} }%
         \xintTrunc {12}{\xintSeries {1}{\cnta}{\coeffleibnitz}}\dots
\endgraf
\ifnum\cnta < 30 \advance\cnta 1 \repeat
|

\begin{multicols}{3}
  \def\coeffleibnitz #1{\the\numexpr\ifodd #1 1\else-1\fi\relax/#1[0]} \cnta 1
  \loop
  \noindent\hbox to 2em{\hfil\dtt{\the\cnta.} }%
  \xintTrunc {12}{\xintSeries {1}{\cnta}{\coeffleibnitz}}\dots
    \endgraf
    \ifnum\cnta < 30 \advance\cnta 1 \repeat
\end{multicols}

\subsection{\csh{xintiSeries}}\label{xintiSeries}

\def\coeff #1{\xintiTrunc {40}
   {\the\numexpr\ifodd #1 -2\else2\fi\relax/\the\numexpr 2*#1+1\relax [0]}}%

\csa{xintiSeries}|{A}{B}{\coeff}|\etype{\numx\numx f} computes
 $\sum_{\text{|n=A|}}^{\text{|n=B|}}$|\coeff{n}| where |\coeff{n}|
 must \fexpan d to a (possibly long) integer in the strict format.
\everb|@
\def\coeff #1{\xintiTrunc {40}{\xintiiMON{#1}/#1.5}}%
% better:
\def\coeff #1{\xintiTrunc {40}
   {\the\numexpr 2*\xintiiMON{#1}\relax/\the\numexpr 2*#1+1\relax [0]}}%
% better still:
\def\coeff #1{\xintiTrunc {40}
 {\the\numexpr\ifodd #1 -2\else2\fi\relax/\the\numexpr 2*#1+1\relax [0]}}%
% (-1)^n/(n+1/2) times 10^40, truncated to an integer.
\[ \sum_{n=0}^{n=50} \frac{(-1)^n}{n+\frac12} \approx
        \xintTrunc {40}{\xintiSeries {0}{50}{\coeff}[-40]}\dots\]
|

\[ \sum_{n=0}^{n=50} \frac{(-1)^n}{n+\frac12} \approx \xintTrunc
{40}{\xintiSeries {0}{50}{\coeff}[-40]}\]

We should have cut out at
least the last two digits: truncating errors originating with the first
coefficients of the sum will never go away, and each truncation
introduces an uncertainty in the last digit, so as we have 40 terms, we
should trash the last two digits, or at least round at 38 digits. It is
interesting to compare with the computation where rounding rather than
truncation is used, and with the decimal
expansion of the exactly computed partial sum of the series:
\everb|@
\def\coeff #1{\xintiRound {40} % rounding at 40
  {\the\numexpr\ifodd #1 -2\else2\fi\relax/\the\numexpr 2*#1+1\relax [0]}}%
% (-1)^n/(n+1/2) times 10^40, rounded to an integer.
\[ \sum_{n=0}^{n=50} \frac{(-1)^n}{n+\frac12} \approx
        \xintTrunc {40}{\xintiSeries {0}{50}{\coeff}[-40]}\]
\def\exactcoeff #1%
  {\the\numexpr\ifodd #1 -2\else2\fi\relax/\the\numexpr 2*#1+1\relax [0]}%
\[ \sum_{n=0}^{n=50} \frac{(-1)^n}{n+\frac12}
   = \xintTrunc {50}{\xintSeries {0}{50}{\exactcoeff}}\dots\]
|

\def\coeff #1{\xintiRound {40}
   {\the\numexpr\ifodd #1 -2\else2\fi\relax/\the\numexpr 2*#1+1\relax [0]}}%
% (-1)^n/(n+1/2) times 10^40, rounded to an integer.
\[ \sum_{n=0}^{n=50} \frac{(-1)^n}{n+\frac12} \approx
        \xintTrunc {40}{\xintiSeries {0}{50}{\coeff}[-40]}\]
\def\exactcoeff #1%
  {\the\numexpr\ifodd #1 -2\else2\fi\relax/\the\numexpr 2*#1+1\relax [0]}%
\[ \sum_{n=0}^{n=50} \frac{(-1)^n}{n+\frac12}
   = \xintTrunc {50}{\xintSeries {0}{50}{\exactcoeff}}\dots\]
This shows indeed that our sum of truncated terms
estimated wrongly the 39th and 40th digits of the exact result%
%
\footnote{as the series is alternating, we can roughly expect an error
  of $\sqrt{40}$ and the last two digits are off by 4 units, which is
  not contradictory to our expectations.}
%
and that the sum of rounded terms fared a bit better.

\subsection{\csh{xintRationalSeries}}\label{xintRationalSeries}


\noindent \csa{xintRationalSeries}|{A}{B}{f}{\ratio}|\etype{\numx\numx\Ff\Ff}
evaluates $\sum_{\text{|n=A|}}^{\text{|n=B|}}$|F(n)|, where |F(n)| is specified
indirectly via the data of |f=F(A)| and the one-parameter macro |\ratio| which
must be such that |\macro{n}| expands to |F(n)/F(n-1)|. The name indicates that
\csa{xintRationalSeries} was designed to be useful in the cases where
|F(n)/F(n-1)| is a rational function of |n| but it may be anything expanding to
a fraction. The macro |\ratio| must be an expandable-only compatible macro and
expand to its value after iterated full expansion of its first item. |A| and
|B| are fed to a |\numexpr| hence may be count registers or arithmetic
expressions built with such; they must obey the \TeX{} bound. The initial term
|f| may be a macro |\f|, it will be expanded to its value representing |F(A)|.

\begin{everbatim*}
\def\ratio #1{2/#1[0]}% 2/n, to compute exp(2)
\cnta 0 % previously declared count
\begin{quote}
\loop \fdef\z {\xintRationalSeries {0}{\cnta}{1}{\ratio }}%
\noindent$\sum_{n=0}^{\the\cnta} \frac{2^n}{n!}=
           \xintTrunc{12}\z\dots=
           \xintTeXFrac\z=\xintTeXFrac{\xintIrr\z}$\vtop to 5pt{}\par
\ifnum\cnta<20 \advance\cnta 1 \repeat
\end{quote}
\end{everbatim*}

\begin{everbatim*}
\def\ratio #1{-1/#1[0]}% -1/n, comes from the series of exp(-1)
\cnta 0 % previously declared count
\begin{quote}
\loop
\fdef\z {\xintRationalSeries {0}{\cnta}{1}{\ratio }}%
\noindent$\sum_{n=0}^{\the\cnta} \frac{(-1)^n}{n!}=
  \xintTrunc{20}\z\dots=\xintTeXFrac{\z}=\xintTeXFrac{\xintIrr\z}$%
         \vtop to 5pt{}\par
\ifnum\cnta<20 \advance\cnta 1 \repeat
\end{quote}
\end{everbatim*}


 \def\ratioexp #1#2{\xintDiv{#1}{#2}}% #1/#2

\medskip We can incorporate an indeterminate if we define |\ratio| to be
a macro with two parameters: |\def\ratioexp
  #1#2{\xintDiv{#1}{#2}}|\texttt{\%}| x/n: x=#1, n=#2|.
Then, if |\x| expands to some fraction |x|, the
macro %
%
\leftedline{|\xintRationalSeries {0}{b}{1}{\ratioexp{\x}}|}
will compute $\sum_{n=0}^{n=b} x^n/n!$:\par
\begin{everbatim*}
\cnta 0
\def\ratioexp #1#2{\xintDiv{#1}{#2}}% #1/#2
\loop
\noindent
$\sum_{n=0}^{\the\cnta} (.57)^n/n! = \xintTrunc {50}
     {\xintRationalSeries {0}{\cnta}{1}{\ratioexp{.57}}}\dots$
     \vtop to 5pt {}\endgraf
\ifnum\cnta<50 \advance\cnta 10 \repeat
\end{everbatim*}

Observe that in this last example the |x| was directly inserted; if it
had been a more complicated explicit fraction it would have been
worthwile to use |\ratioexp\x| with |\x| defined to expand to its value.
In the further situation where this fraction |x| is not explicit but
itself defined via a complicated, and time-costly, formula, it should be
noted that \csa{xintRationalSeries} will do again the evaluation of |\x|
for each term of the partial sum. The easiest is thus when |x| can be
defined as an |\edef|. If however, you are in an expandable-only context
and cannot store in a macro like |\x| the value to be used, a variant of
\csa{xintRationalSeries} is needed which will first evaluate this |\x| and then
use this result without recomputing it. This is \csbxint{RationalSeriesX},
documented next.

Here is a slightly more complicated evaluation:
\begin{everbatim*}
\cnta 1
\begin{multicols}{2}
\loop \fdef\z {\xintRationalSeries
                   {\cnta}
                   {2*\cnta-1}
                   {\xintiiPow {\the\cnta}{\cnta}/\xintiiFac{\cnta}}
                   {\ratioexp{\the\cnta}}}%
\fdef\w {\xintRationalSeries {0}{2*\cnta-1}{1}{\ratioexp{\the\cnta}}}%
\noindent
$\sum_{n=\the\cnta}^{\the\numexpr 2*\cnta-1\relax} \frac{\the\cnta^n}{n!}/%
          \sum_{n=0}^{\the\numexpr 2*\cnta-1\relax} \frac{\the\cnta^n}{n!} =
          \xintTrunc{8}{\xintDiv\z\w}\dots$ \vtop to 5pt{}\endgraf
\ifnum\cnta<20 \advance\cnta 1 \repeat
\end{multicols}
\end{everbatim*}


\subsection{\csh{xintRationalSeriesX}}\label{xintRationalSeriesX}


\noindent\csa{xintRationalSeriesX}|{A}{B}{\first}{\ratio}{\g}|%
\etype{\numx\numx\Ff\Ff f} is a parametrized version of \csa{xintRationalSeries}
where |\first| is now a one-parameter macro such that |\first{\g}| gives the
initial term and |\ratio| is a two-parameter macro such that |\ratio{n}{\g}|
represents the ratio of one term to the previous one. The parameter |\g| is
evaluated only once at the beginning of the computation, and can thus itself be
the yet unevaluated result of a previous computation.

Let |\ratio| be such a two-parameter macro; note the subtle differences
between%
%
\leftedline{|\xintRationalSeries {A}{B}{\first}{\ratio{\g}}|}
%
\leftedline{and |\xintRationalSeriesX {A}{B}{\first}{\ratio}{\g}|.} First the
location of braces differ...\@{} then, in the former case |\first| is a
\emph{no-parameter} macro expanding to a fractional number, and in the latter,
it is a
\emph{one-parameter} macro which will use |\g|. Furthermore the |X| variant
will expand |\g| at the very beginning whereas the former non-|X| former variant
will evaluate it each time it needs it (which is bad if this
evaluation is time-costly, but good if |\g| is a big explicit fraction
encapsulated in a macro).

The example will use the macro \csbxint{PowerSeries} which computes
efficiently exact partial sums of power series, and is discussed in the
next section.
\begin{everbatim*}
\def\firstterm #1{1[0]}% first term of the exponential series
% although it is the constant 1, here it must be defined as a
% one-parameter macro. Next comes the ratio function for exp:
\def\ratioexp  #1#2{\xintDiv {#1}{#2}}% x/n
% These are the (-1)^{n-1}/n of the log(1+h) series:
\def\coefflog #1{\the\numexpr\ifodd #1 1\else-1\fi\relax/#1[0]}%
% Let L(h) be the first 10 terms of the log(1+h) series and
% let E(t) be the first 10 terms of the exp(t) series.
% The following computes E(L(a/10)) for a=1,...,12.
\begin{multicols}{3}\raggedcolumns
\cnta 0
\loop
\noindent\xintTrunc {18}{%
     \xintRationalSeriesX {0}{9}{\firstterm}{\ratioexp}
         {\xintPowerSeries{1}{10}{\coefflog}{\the\cnta[-1]}}}\dots
\endgraf
\ifnum\cnta < 12 \advance \cnta 1 \repeat
\end{multicols}
\end{everbatim*}


These completely exact operations rapidly create numbers with many digits. Let
us print in full the raw fractions created by the operation illustrated above:

\fdef\z{\xintRationalSeriesX {0}{9}{\firstterm}
{\ratioexp}{\xintPowerSeries{1}{10}{\coefflog}{1[-1]}}}

|E(L(1[-1]))=|\dtt{\printnumber{\z}} (length of numerator:
\xintLen {\xintNumerator \z})

\fdef\z{\xintRationalSeriesX {0}{9}{\firstterm}
{\ratioexp}{\xintPowerSeries{1}{10}{\coefflog}{12[-2]}}}

|E(L(12[-2]))=|\dtt{\printnumber{\z}} (length of numerator:
\xintLen {\xintNumerator \z})

\fdef\z{\xintRationalSeriesX {0}{9}{\firstterm}
{\ratioexp}{\xintPowerSeries{1}{10}{\coefflog}{123[-3]}}}

|E(L(123[-3]))=|\dtt{\printnumber{\z}} (length of numerator:
\xintLen {\xintNumerator \z})

We see that the denominators here remain the same, as our input only had various
powers of ten as denominators, and \xintfracname efficiently assemble (some
only, as we can see) powers of ten. Notice that 1 more digit in an input
denominator seems to mean 90 more in the raw output. We can check that with some
other test cases:

\fdef\z{\xintRationalSeriesX {0}{9}{\firstterm}
{\ratioexp}{\xintPowerSeries{1}{10}{\coefflog}{1/7}}}

|E(L(1/7))=|\dtt{\printnumber{\z}} (length of numerator:
\xintLen {\xintNumerator \z}; length of denominator:
\xintLen {\xintDenominator \z})

\fdef\z{\xintRationalSeriesX {0}{9}{\firstterm}
{\ratioexp}{\xintPowerSeries{1}{10}{\coefflog}{1/71}}}

|E(L(1/71))=|\dtt{\printnumber{\z}} (length of numerator:
\xintLen {\xintNumerator \z}; length of denominator:
\xintLen {\xintDenominator \z})

\fdef\z{\xintRationalSeriesX {0}{9}{\firstterm}
{\ratioexp}{\xintPowerSeries{1}{10}{\coefflog}{1/712}}}

|E(L(1/712))=|\dtt{\printnumber{\z}} (length of numerator:
\xintLen {\xintNumerator \z}; length of denominator:
\xintLen {\xintDenominator \z})


Thus
decimal numbers such as |0.123| (equivalently
|123[-3]|) give less computing intensive tasks than fractions such as |1/712|:
in the case of decimal numbers the (raw) denominators originate in the
coefficients of the series themselves, powers of ten of the input within
brackets being treated separately. And even then the
numerators will grow with the size of the input in a sort of linear way, the
coefficient being given by the order of series: here 10 from the log and 9 from
the exp, so 90. One more digit in the input means 90 more digits in the
numerator of the output: obviously we can not go on composing such partial sums
of series and hope that \xintname will joyfully do all at the speed of light!

Hence, truncating the output (or better, rounding) is the only way to go if one
needs a general calculus of special functions. This is why the package
\xintseriesname provides, besides \csbxint{Series}, \csbxint{RationalSeries}, or
\csbxint{PowerSeries} which compute \emph{exact} sums,
\csbxint{FxPtPowerSeries} for fixed-point computations and a (tentative naive)
\csbxint{FloatPowerSeries}.

\subsection{\csh{xintPowerSeries}}\label{xintPowerSeries}

\csa{xintPowerSeries}|{A}{B}{\coeff}{f}|\etype{\numx\numx\Ff\Ff}
evaluates the sum
$\sum_{\text{|n=A|}}^{\text{|n=B|}}$|\coeff{n}|${}\cdot \text{|f|}^{\text{|n|}}$. The
initial and final indices are given to a |\numexpr| expression. The |\coeff|
macro (which, as argument to \csa{xintPowerSeries} is expanded only at the time
|\coeff{n}| is needed) should be defined as a one-parameter expandable macro,
its input will be an explicit number.

The |f| can be either a fraction directly input or a macro |\f| expanding to
such a fraction. It is actually more efficient to encapsulate an explicit
fraction |f| in such a macro, if it has big numerators and denominators (`big'
means hundreds of digits) as it will then take less space in the processing
until being (repeatedly) used.

This macro computes the \emph{exact} result (one can use it also for
polynomial evaluation), using a Horner scheme which helps avoiding a
denominator build-up (this problem however,  even if using a naive additive
approach, is much less acute since release |1.1| and its new policy regarding
\csbxint{Add}).

\begin{everbatim*}
\def\geom #1{1[0]} % the geometric series
\def\f {5/17[0]}
\[ \sum_{n=0}^{n=20} \Bigl(\frac 5{17}\Bigr)^n
 =\xintTeXFrac{\xintIrr{\xintPowerSeries {0}{20}{\geom}{\f}}}
 =\xintTeXFrac{\xinttheexpr (17^21-5^21)/12/17^20\relax}\]
\end{everbatim*}

\begin{everbatim*}
\def\coefflog #1{1/#1[0]}% 1/n
\def\f {1/2[0]}%
\[ \log 2 \approx \sum_{n=1}^{20} \frac1{n\cdot 2^n}
    = \xintTeXFrac {\xintIrr {\xintPowerSeries {1}{20}{\coefflog}{\f}}}\]
\[ \log 2 \approx \sum_{n=1}^{50} \frac1{n\cdot 2^n}
    = \xintTeXFrac {\xintIrr {\xintPowerSeries {1}{50}{\coefflog}{\f}}}\]
\end{everbatim*}


\begin{everbatim*}
\setlength{\columnsep}{0pt}
\begin{multicols}{3}
\cnta 1 % previously declared count
\loop   % in this loop we recompute from scratch each partial sum!
% we can afford that, as \xintPowerSeries is fast enough.
\noindent\hbox to 2em{\hfil\texttt{\the\cnta.} }%
         \xintTrunc {12}
             {\xintPowerSeries {1}{\cnta}{\coefflog}{\f}}\dots
\endgraf
\ifnum \cnta < 30 \advance\cnta 1 \repeat
\end{multicols}
\end{everbatim*}


\begin{everbatim*}
\def\coeffarctg  #1{1/\the\numexpr\ifodd #1 -2*#1-1\else2*#1+1\fi\relax }%
% the above gives (-1)^n/(2n+1). The sign being in the denominator,
%             **** no [0] should be added ****,
% else nothing is guaranteed to work (even if it could by sheer luck)
% Notice in passing this aspect of \numexpr:
%         ****  \numexpr -(1)\relax is ilegal !!! ****
\def\f {1/25[0]}% 1/5^2
\[\mathrm{Arctg}(\frac15)\approx \frac15\sum_{n=0}^{15} \frac{(-1)^n}{(2n+1)25^n}
= \xintTeXFrac{\xintIrr {\xintDiv {\xintPowerSeries {0}{15}{\coeffarctg}{\f}}{5}}}\]
\end{everbatim*}


\subsection{\csh{xintPowerSeriesX}}\label{xintPowerSeriesX}

%{\small\hspace*{\parindent}New with release |1.04|.\par}

\noindent This is the same as \csbxint{PowerSeries}\ntype{\numx\numx\Ff\Ff}
apart
from the fact that the last parameter |f| is expanded once and for all before
being then used repeatedly. If the |f| parameter is to be an explicit big
fraction with many (dozens) digits, rather than using it directly it is slightly
better to have some macro |\g| defined to expand to the explicit fraction and
then use \csbxint{PowerSeries} with |\g|; but if |f| has not yet been evaluated
and will be the output of a complicated expansion of some |\f|, and if, due to
an expanding only context, doing |\edef\g{\f}| is no option, then
\csa{xintPowerSeriesX} should be used with |\f| as last parameter.
%
\begin{everbatim*}
\def\ratioexp #1#2{\xintDiv {#1}{#2}}% x/n
% These are the (-1)^{n-1}/n of the log(1+h) series:
\def\coefflog #1{\the\numexpr\ifodd #1 1\else-1\fi\relax/#1[0]}%
% Let L(h) be the first 10 terms of the log(1+h) series and
% let E(t) be the first 10 terms of the exp(t) series.
% The following computes L(E(a/10)-1) for a=1,..., 12.
\begin{multicols}{3}\raggedcolumns
\cnta 1
\loop
\noindent\xintTrunc {18}{%
   \xintPowerSeriesX {1}{10}{\coefflog}
  {\xintSub
      {\xintRationalSeries {0}{9}{1[0]}{\ratioexp{\the\cnta[-1]}}}
      {1}}}\dots
\endgraf
\ifnum\cnta < 12 \advance \cnta 1 \repeat
\end{multicols}
\end{everbatim*}


\subsection{\csh{xintFxPtPowerSeries}}\label{xintFxPtPowerSeries}

\csa{xintFxPtPowerSeries}|{A}{B}{\coeff}{f}{D}|\etype{\numx\numx}
computes
$\sum_{\text{|n=A|}}^{\text{|n=B|}}$|\coeff{n}|${}\cdot \text{|f|}^{\,\text{|n|}}$ with each
    term of the series truncated to |D| digits\etype{\Ff\Ff\numx}
 after the decimal point. As
    usual, |A| and |B| are completely expanded through their inclusion in a
    |\numexpr| expression. Regarding |D| it will be similarly be expanded each
    time it is used inside an \csa{xintTrunc}. The one-parameter macro |\coeff|
    is similarly  expanded at the time it is used inside the
    computations. Idem for |f|. If |f| itself is some complicated macro it is
    thus better to use the variant \csbxint{FxPtPowerSeriesX} which expands it
    first and then uses the result of that expansion.

The current (|1.04|) implementation is: the first power |f^A| is
computed exactly, then \emph{truncated}. Then each successive power is
obtained from the previous one by multiplication by the exact value of
|f|, and truncated. And |\coeff{n}|\raisebox{.5ex}{|.|}|f^n| is obtained
from that by multiplying by |\coeff{n}| (untruncated) and then
truncating. Finally the sum is computed exactly. Apart from that
\csa{xintFxPtPowerSeries} (where |FxPt| means `fixed-point') is like
\csa{xintPowerSeries}.

There should be a variant for things of the type $\sum c_n \frac {f^n}{n!}$ to
avoid having to compute the factorial from scratch at each coefficient, the same
way \csa{xintFxPtPowerSeries} does not compute |f^n| from scratch at each |n|.
Perhaps in the next package release.

\def\coeffexp #1{1/\xintiiFac {#1}[0]}% [0] for faster parsing
\def\f {-1/2[0]}%
\newcount\cnta

\edef\foo{\the\multicolsep}
\setlength{\multicolsep}{0pt}

\begin{multicols}{3}[%
\centeredline{$e^{-\frac12}\approx{}$}]%
\cnta 0
\noindent\loop
$\xintFxPtPowerSeries {0}{\cnta}{\coeffexp}{\f}{20}$\\
\ifnum\cnta<19
\advance\cnta 1
\repeat\par
\end{multicols}
\multicolsep\foo\relax

\everb|@
\def\coeffexp #1{1/\xintiiFac {#1}[0]}% 1/n!
\def\f {-1/2[0]}% [0] for faster input parsing
\cnta 0 % previously declared \count register
\noindent\loop
$\xintFxPtPowerSeries {0}{\cnta}{\coeffexp}{\f}{20}$\\
\ifnum\cnta<19 \advance\cnta 1 \repeat\par
|


%
\leftedline{|\xintFxPtPowerSeries {0}{19}{\coeffexp}{\f}{25}=|
\dtt{\xintFxPtPowerSeries {0}{19}{\coeffexp}{\f}{25}}}
\fdef\z{\xintIrr {\xintPowerSeries {0}{19}{\coeffexp}{\f}}}
%

\texttt{\hyphenchar\font45 }%
It is no difficulty for \xintfracname to compute exactly, with the help
of \csa{xintPowerSeries}, the nineteenth partial sum, and to then give
(the start of) its exact decimal expansion:
%
\leftedline{|\xintPowerSeries {0}{19}{\coeffexp}{\f}| ${}=
  \displaystyle\xintTeXFrac{\z}$%
  \vphantom{\vrule height 20pt depth 12pt}}%
%
\leftedline{${}=\xintTrunc {30}{\z}\dots$} Thus, one should always
estimate a priori how many ending digits are not reliable: if there are
|N| terms and |N| has |k| digits, then digits up to but excluding the
last |k| may usually be trusted. If we are optimistic and the series is
alternating we may even replace |N| with $\sqrt{\text{|N|}}$ to get the number |k|
of digits possibly of dubious significance.

\subsection{\csh{xintFxPtPowerSeriesX}}\label{xintFxPtPowerSeriesX}


\noindent\csa{xintFxPtPowerSeriesX}|{A}{B}{\coeff}{\f}{D}|%
\ntype{\numx\numx}
computes, exactly as
\csa{xintFxPtPowerSeries}, the sum of
|\coeff{n}|\raisebox{.5ex}{|.|}|\f^n|\etype{\Ff\Ff\numx} from |n=A| to |n=B| with each term
of the series being \emph{truncated} to |D| digits after the decimal
point. The sole difference is that |\f| is first expanded and it
is the result of this which is used in the computations.


Let us illustrate this on the numerical exploration of the identity
%
\leftedline{|log(1+x) = -log(1/(1+x))|}
%
Let |L(h)=log(1+h)|, and |D(h)=L(h)+L(-h/(1+h))|. Theoretically thus,
|D(h)=0| but we shall evaluate |L(h)| and |-h/(1+h)| keeping only 10
terms of their respective series. We will assume $\text{|h|}<0.5$. With only
ten terms kept in the power series we do not have quite 3 digits
precision as $2^{10}=1024$. So it wouldn't make sense to evaluate things
more precisely than, say circa 5 digits after the decimal points.
\begin{everbatim*}
\cnta 0
\def\coefflog #1{\the\numexpr\ifodd#1 1\else-1\fi\relax/#1[0]}% (-1)^{n-1}/n
\def\coeffalt #1{\the\numexpr\ifodd#1 -1\else1\fi\relax [0]}%   (-1)^n
\begin{multicols}2
\loop
\noindent \hbox to 2.5cm {\hss\texttt{D(\the\cnta/100): }}%
\xintAdd {\xintFxPtPowerSeriesX {1}{10}{\coefflog}{\the\cnta [-2]}{5}}
         {\xintFxPtPowerSeriesX {1}{10}{\coefflog}
             {\xintFxPtPowerSeriesX {1}{10}{\coeffalt}{\the\cnta [-2]}{5}}
          {5}}\endgraf
\ifnum\cnta < 49 \advance\cnta 7 \repeat
\end{multicols}
\end{everbatim*}


Let's say we evaluate functions on |[-1/2,+1/2]| with values more or less also
in |[-1/2,+1/2]| and we want to keep 4 digits of precision. So, roughly we need
at least 14 terms in series like the geometric or log series. Let's make this
15. Then it doesn't make sense to compute intermediate summands with more than 6
digits precision. So we compute with 6 digits
precision but return only 4 digits (rounded) after the decimal point.
This result with 4 post-decimal points precision is then used as input
to the next evaluation.
\begin{everbatim*}
\begin{multicols}2
\loop
\noindent \hbox to 2.5cm {\hss\texttt{D(\the\cnta/100): }}%
\dtt{\xintRound{4}
 {\xintAdd {\xintFxPtPowerSeriesX {1}{15}{\coefflog}{\the\cnta [-2]}{6}}
           {\xintFxPtPowerSeriesX {1}{15}{\coefflog}
                  {\xintRound {4}{\xintFxPtPowerSeriesX {1}{15}{\coeffalt}
                                 {\the\cnta [-2]}{6}}}
            {6}}%
 }}\endgraf
\ifnum\cnta < 49 \advance\cnta 7 \repeat
\end{multicols}
\end{everbatim*}

Not bad... I have cheated a bit: the `four-digits precise' numeric
evaluations were left unrounded in the final addition. However the inner
rounding to four digits worked fine and made the next step faster than
it would have been with longer inputs. The morale is that one should not
use the raw results of \csa{xintFxPtPowerSeriesX} with the |D| digits
with which it was computed, as the last are to be considered garbage.
Rather, one should keep from the output only some smaller number of
digits. This will make further computations faster and not less precise.
I guess there should be some macro to do this final truncating, or
better, rounding, at a given number |D'<D| of digits. Maybe for the next
release.

\subsection{\csh{xintFloatPowerSeries}}\label{xintFloatPowerSeries}


\noindent\csa{xintFloatPowerSeries}|[P]{A}{B}{\coeff}{f}|%
\ntype{{\upshape[\numx]}\numx\numx}
 computes
$\sum_{\text{|n=A|}}^{\text{|n=B|}}$|\coeff{n}|${}\cdot \text{|f|}^{\,\text{|n|}}$
with a floating point
precision given by the optional parameter |P| or by the current setting of
|\xintDigits|.\etype{\Ff\Ff}

In the current, preliminary, version, no attempt has been made to try to
guarantee to the final result the precision |P|. Rather, |P| is used for all
intermediate floating point evaluations. So
rounding errors will make some of the last printed digits invalid. The
operations done are first the evaluation of |f^A| using \csa{xintFloatPow}, then
each successive power is obtained from this first one by multiplication by |f|
using \csa{xintFloatMul}, then again with \csa{xintFloatMul} this is multiplied
with |\coeff{n}|, and the sum is done adding one term at a time with
\csa{xintFloatAdd}. To sum up, this is just the naive transformation of
\csa{xintFxPtPowerSeries} from fixed point to floating point.

\def\coefflog #1{\the\numexpr\ifodd#1 1\else-1\fi\relax/#1[0]}%

\everb+@
\def\coefflog #1{\the\numexpr\ifodd#1 1\else-1\fi\relax/#1[0]}%
\xintFloatPowerSeries [8]{1}{30}{\coefflog}{-1/2[0]}
+

%
\leftedline{\dtt{\xintFloatPowerSeries [8]{1}{30}{\coefflog}{-1/2[0]}}}

\subsection{\csh{xintFloatPowerSeriesX}}\label{xintFloatPowerSeriesX}


\noindent\csa{xintFloatPowerSeriesX}|[P]{A}{B}{\coeff}{f}|%
\ntype{{\upshape[\numx]}\numx\numx}
is like
\csa{xintFloatPowerSeries} with the difference that |f| is
expanded once\etype{\Ff\Ff}
and for all at the start of the computation, thus allowing
efficient chaining of such series evaluations.
\def\coefflog #1{\the\numexpr\ifodd#1 1\else-1\fi\relax/#1[0]}%

\everb+@
\def\coeffexp #1{1/\xintiiFac {#1}[0]}% 1/n! (exact, not float)
\def\coefflog #1{\the\numexpr\ifodd#1 1\else-1\fi\relax/#1[0]}%
\xintFloatPowerSeriesX [8]{0}{30}{\coeffexp}
    {\xintFloatPowerSeries [8]{1}{30}{\coefflog}{-1/2[0]}}
+

%
\leftedline{\dtt{\xintFloatPowerSeriesX [8]{0}{30}{\coeffexp}
    {\xintFloatPowerSeries [8]{1}{30}{\coefflog}{-1/2[0]}}}}

\subsection{Computing \texorpdfstring{$\log 2$}{log(2)} and \texorpdfstring{$\pi$}{pi}}\label{ssec:Machin}

In this final section, the use of \csbxint{FxPtPowerSeries} (and
\csbxint{PowerSeries}) will be
illustrated on the (expandable...\@{} why make things simple when it is so easy to
make them difficult!) computations of the first digits of the decimal expansion
of the familiar constants $\log 2$ and $\pi$.

Let us start with $\log 2$. We will get it from this formula (which is
left as an exercise): %
%
\leftedline{\dtt{log(2)=-2\,log(1-13/256)-%
 5\,log(1-1/9)}}
%
The number of terms to be kept in the log series, for a desired
precision of |10^{-D}| was roughly estimated without much theoretical
analysis. Computing exactly the partial sums with \csa{xintPowerSeries}
and then printing the truncated values, from |D=0| up to |D=100| showed
that it worked in terms of quality of the approximation. Because of
possible strings of zeroes or nines in the exact decimal expansion (in
the present case of $\log 2$, strings of zeroes around the fourtieth and
the sixtieth decimals), this
does not mean though that all digits printed were always exact. In
the end one always end up having to compute at some higher level of
desired precision to validate the earlier result.

Then we tried with \csa{xintFxPtPowerSeries}: this is worthwile only for
|D|'s at least 50, as the exact evaluations are faster (with these
short-length |f|'s) for a lower
number of digits. And as expected the degradation in the quality of
approximation was in this range of the order of two or three digits.
This meant roughly that the 3+1=4 ending digits were wrong. Again, we ended
up having to compute with five more digits and compare with the earlier
value to validate it. We use truncation rather than rounding because our
goal is not to obtain the correct rounded decimal expansion but the
correct exact truncated one.

% 693147180559945309417232121458176568075500134360255254120680009493

\begin{everbatim*}
\def\coefflog #1{1/#1[0]}% 1/n
\def\xa {13/256[0]}%  we will compute log(1-13/256)
\def\xb {1/9[0]}%     we will compute log(1-1/9)
\def\LogTwo #1{%
  %  get log(2)=-2log(1-13/256)- 5log(1-1/9)
  \romannumeral0\expandafter\logtwo
  % number of terms for 1/9:
  \the\numexpr #1*150/143\expandafter.%
  % number of Terms for 13/256:
  \the\numexpr #1*100/129\expandafter.%
  % We print #1 digits, but we know the ending ones are garbage
  % Use \numexpr to allow a \count as #1
  \the\numexpr #1.%
}%
\def\logtwo #1.#2.#3.{%
  % #1=nb of terms for 1/9,
  % #2=nb of terms for 13/256,
  % #3=nb of digits for computations, also used for printing
  \xinttrunc {#3}% will terminate the \romannumeral0
  {\xintAdd
   {\xintMul {2}{\xintFxPtPowerSeries {1}{#2}{\coefflog}{\xa}{#3}}}
   {\xintMul {5}{\xintFxPtPowerSeries {1}{#1}{\coefflog}{\xb}{#3}}}%
  }%
}%
\noindent $\log 2 \approx \LogTwo {60}\dots$\endgraf
\noindent\phantom{$\log 2$}${}\approx{}$\printnumber{\LogTwo {65}}\dots\endgraf
\noindent\phantom{$\log 2$}${}\approx{}$\printnumber{\LogTwo {70}}\dots\endgraf
\end{everbatim*}

Here is the code doing an exact evaluation of the partial sums. We have
added a |+1| to the number of digits for estimating the number of terms
to keep from the log series: we experimented that this gets exactly the
first |D| digits, for all values from |D=0| to |D=100|, except in one
case (|D=40|) where the last digit is wrong. For values of |D|
higher than |100| it is more efficient to use the code using
\csa{xintFxPtPowerSeries}.
\everb|@
\def\coefflog #1{1/#1[0]}% 1/n
\def\xa {13/256[0]}%  we will compute log(1-13/256)
\def\xb {1/9[0]}%     we will compute log(1-1/9)
\def\LogTwo #1{% get log(2)=-2log(1-13/256)- 5log(1-1/9)
  \romannumeral0\expandafter\logtwo
  \the\numexpr (#1+1)*150/143\expandafter.%
  \the\numexpr (#1+1)*100/129\expandafter.%
  \the\numexpr #1.%
}%
\def\logtwo #1.#2.#3.{% #3=nb of digits for truncating an EXACT partial sum
  \xinttrunc {#3}% will terminate the \romannumeral0
    {\xintAdd
      {\xintMul {2}{\xintPowerSeries {1}{#2}{\coefflog}{\xa}}}
      {\xintMul {5}{\xintPowerSeries {1}{#1}{\coefflog}{\xb}}}%
    }%
}%
|

Let us turn now to Pi, computed with the Machin formula (but see also the
approach via the \hyperlink{BrentSalamin}{Brent-Salamin algorithm} with
\csa{xintfloatexpr}) Again the numbers of terms to keep in the two |arctg|
series were roughly estimated, and some experimentations showed that removing
the last three digits was enough (at least for |D=0-100| range). And the
algorithm does print the correct digits when used with |D=1000| (to be
convinced of that one needs to run it for |D=1000| and again, say for
|D=1010|.) A theoretical analysis could help confirm that this algorithm
always gets better than |10^{-D}| precision, but again, strings of zeroes or
nines encountered in the decimal expansion may falsify the ending digits,
nines may be zeroes (and the last non-nine one should be increased) and zeroes
may be nine (and the last non-zero one should be decreased).

\hypertarget{MachinCode}{}
\begin{everbatim*}
\def\coeffarctg #1{\the\numexpr\ifodd#1 -1\else1\fi\relax
                   /\the\numexpr 2*#1+1\relax [0]}%
%\def\coeffarctg #1{\romannumeral0\xintmon{#1}/\the\numexpr 2*#1+1\relax }%
\def\xa {1/25[0]}%      1/5^2, the [0] for faster parsing
\def\xb {1/57121[0]}% 1/239^2, the [0] for faster parsing
\def\Machin #1{% #1 may be a count register
  \romannumeral0\expandafter\machin
  % number of terms for arctg(1/5):
  \the\numexpr (#1+3)*5/7\expandafter.%
  % number of terms for arctg(1/239):
  \the\numexpr (#1+3)*10/45\expandafter.%
  % do the computations with 3 additional digits:
  \the\numexpr #1+3\expandafter.%
  % allow #1 to be a count register:
  \the\numexpr #1.%
}%
\def\machin #1.#2.#3.#4.{%
  \xinttrunc {#4}% will terminate the \romannumeral0
  {\xintSub
    {\xintMul {16/5}{\xintFxPtPowerSeries {0}{#1}{\coeffarctg}{\xa}{#3}}}
    {\xintMul{4/239}{\xintFxPtPowerSeries {0}{#2}{\coeffarctg}{\xb}{#3}}}%
  }%
}%
\begin{framed}
  \[ \pi = \Machin{60}\dots \]
\end{framed}
\end{everbatim*}

Here is a variant|\MachinBis|,
which evaluates the partial sums \emph{exactly} using
\csa{xintPowerSeries}, before their final truncation. No need for a
``|+3|'' then.
\begin{everbatim*}
\def\MachinBis #1{% #1 may be a count register,
  % the final result will be truncated to #1 digits post decimal point
  \romannumeral0\expandafter\machinbis
  % number of terms for arctg(1/5):
  \the\numexpr #1*5/7\expandafter.%
  % number of terms for arctg(1/239):
  \the\numexpr #1*10/45\expandafter.%
  % allow #1 to be a count register:
  \the\numexpr #1.%
}%
\def\machinbis #1.#2.#3.{%
  \xinttrunc {#3}% will terminate the \romannumeral0
   {\xintSub
     {\xintMul {16/5}{\xintPowerSeries {0}{#1}{\coeffarctg}{\xa}}}
     {\xintMul{4/239}{\xintPowerSeries {0}{#2}{\coeffarctg}{\xb}}}%
   }%
}%
\end{everbatim*}

Let us use this variant for a loop showing the build-up of digits:
\begin{everbatim*}
\begin{multicols}{2}
  \cnta 0 % previously declared \count register
  \loop \noindent
        \centeredline{\dtt{\MachinBis{\cnta}}}%
  \ifnum\cnta < 30
  \advance\cnta 1 \repeat
\end{multicols}
\end{everbatim*}

\hypertarget{Machin1000}{}
%
You want more digits and have some time? Save the following to a file,
it is the \hyperlink{MachinCode}{|\Machin|} code.  Compile with |etex|
(or |pdftex| or |xetex| or |luatex|):
%
\everb|@
% Compile with e-TeX extensions enabled (etex, pdftex, ...)
\input xintfrac.sty
\input xintseries.sty
% pi = 16 Arctg(1/5) - 4 Arctg(1/239) (John Machin's formula)
\def\coeffarctg #1{\the\numexpr\ifodd#1 -1\else1\fi\relax
                   /\the\numexpr 2*#1+1\relax [0]}%
\def\xa {1/25[0]}%
\def\xb {1/57121[0]}%
\def\Machin #1{%
  \romannumeral0\expandafter\machin
  \the\numexpr (#1+3)*5/7\expandafter.%
  \the\numexpr (#1+3)*10/45\expandafter.%
  \the\numexpr #1+3\expandafter.%
  \the\numexpr #1.%
}%
\def\machin #1.#2.#3.#4.{%
  \xinttrunc {#4}% will terminate the \romannumeral0
    {\xintSub
      {\xintMul {16/5}{\xintFxPtPowerSeries {0}{#1}{\coeffarctg}{\xa}{#3}}}
      {\xintMul{4/239}{\xintFxPtPowerSeries {0}{#2}{\coeffarctg}{\xb}{#3}}}%
    }%
}%
\xintresettimer
\edef\Z {\Machin {1000}}
\edef\W {\xinttheseconds}
\immediate\write128{1000 places of pi via Machin formula (took \W s):}
\immediate\write128{\Z}
\bye
|

This will log the first 1000 digits of $\pi$ after the decimal point. On my
laptop (a 2012 model) this took about $5.05$ seconds last time I tried.%
%
\footnote{With \texttt{1.09i} and earlier \xintname, this used to be \dtt{42}
  seconds; starting with \texttt{1.09j}, and prior to \texttt{1.2}, it was
  \dtt{16} seconds (this was probably due to a more efficient division with
  denominators at most $9999$). The |1.2| \xintcorename achieved a further
  gain at \dtt{5.6} seconds.}
%
\footnote{With |\xintDigits:=1001\relax|, the non-optimized implementation with the
  |iter| of \xintexprname fame using the
  \hyperlink{BrentSalamin}{Brent-Salamin algorithm}, took, last time I tried
  (1.2i), about \dtt{7} seconds on my laptop (the last two digits were wrong,
  which is ok as they serve as guard digits), and for obtaining about
  \dtt{500} digits, it was about \dtt{1.7}s. This is not bad, taking into
  account that the syntax is almost free rolling speech, contrarily to the
  code above for the Machin formula computation; we would like to use the
  quadratically convergent Brent-Salamin algorithm for more digits, but with
  such computations with numbers of one thousand digits we are beyond the
  border of the reasonable range for \xintname. Innocent people not knowing
  what it means to compute with \TeX, and with the extra constraint of
  expandability will wonder why this is at least thousands of times slower
  than with any other language (with a little Python program using the
  |Decimal| library, I timed the Brent-Salamin algorithm to \dtt{4.4ms} for
  about |1000| digits and \dtt{1.14ms} for |500| digits.) I will just say that
  for example digits are represented and manipulated via their ascii-code !
  all computations must convert from ascii-code to cpu words; furthermore
  nothing can be stored away. And there is no memory storage with |O(1)| time
  access...\@{} if expandability is to be verified.}
%


As mentioned in the
introduction, the file \href{https://ctan.org/pkg/pi}{pi.tex} by \textsc{D.
  Roegel} shows that orders of magnitude faster computations are possible within
\TeX{}, but recall our constraints of complete expandability and be merciful,
please.

\textbf{Why truncating rather than rounding?} One of our main competitors
on the market of scientific computing, a canadian product (not
encumbered with expandability constraints, and having barely ever heard
of \TeX{} ;-), prints numbers rounded in the last digit. Why didn't we
follow suit in the macros \csa{xintFxPtPowerSeries} and
\csa{xintFxPtPowerSeriesX}? To round at |D| digits, and excluding a
rewrite or cloning of the division algorithm which anyhow would add to
it some overhead in its final steps, \xintfracname needs to truncate at
|D+1|, then round. And rounding loses information! So, with more time
spent, we obtain a worst result than the one truncated at |D+1| (one
could imagine that additions and so on, done with only |D| digits, cost
less; true, but this is a negligeable effect per summand compared to the
additional cost for this term of having been truncated at |D+1| then
rounded). Rounding is the way to go when setting up algorithms to
evaluate functions destined to be composed one after the other: exact
algebraic operations with many summands and an |f| variable which is a
fraction are costly and create an even bigger fraction; replacing |f|
with a reasonable rounding, and rounding the result, is necessary to
allow arbitrary chaining.

But, for the
computation of a single constant, we are really interested in the exact
decimal expansion, so we truncate and compute more terms until the
earlier result gets validated. Finally if we do want the rounding we can
always do it on a value computed with |D+1| truncation.

\clearpage
\let\xintseriesnameUp\undefined
\csname xintcfracnameUp\endcsname
\def\n{|{N}|}
\def\m{|{M}|}
\def\x{|{x}|}
\section{Macros of the \xintcfracname package}
\RaisedLabel{sec:cfrac}

\localtableofcontents

\subsection{Introduction}

First version of this package was included in release |1.04| (|2013/04/25|) of the
\xintbundlename. It was kept almost unchanged until |1.09m| of |2014/02/26|
which brought some new macros: \csbxint{FtoC}, \csbxint{CtoF}, \csbxint{CtoCv},
dealing with sequences of braced partial quotients rather than comma separated
ones, \csbxint{FGtoC} which is to produce ``guaranteed'' coefficients of some
real number known approximately, and \csbxint{GGCFrac} for displaying arbitrary
material as a continued fraction; also, some changes to existing macros:
\csbxint{FtoCs} and \csbxint{CntoCs} insert spaces after the commas,
\csbxint{CstoF} and \csbxint{CstoCv} authorize spaces in the input also before
the commas.

\csbxint{CstoF} and \csbxint{CstoCv} create a partial dependency on
\xinttoolsname as they use its \csbxint{CSVtoList}.  Starting at |1.4n|
the loading of \xinttoolsname is done automatically, formerly it was up
to user to do it.

% This section contains:
% \begin{enumerate}
% \item an \hyperref[ssec:cfracoverview]{overview} of the package functionalities,
% \item a description of each one of the package macros,
% \item further illustration of their use via the study of the
%   \hyperref[ssec:e-convergents]{convergents of $e$}.
% \end{enumerate}

\subsection{Package overview}\label{ssec:cfracoverview}

The package computes partial quotients and convergents of a fraction, or
conversely start from coefficients and obtain the corresponding fraction; three
macros \csbxint {CFrac}, \csbxint {GCFrac} and \csbxint {GGCFrac} are
for typesetting, the others
can be nested (if applicable) or see their outputs further processed by other
macros from the \xintbundlename, particularly the macros of \xinttoolsname
dealing with sequences of braced items or comma separated lists.

A \emph{simple} continued fraction has coefficients
|[c0,c1,...,cN]| (usually called partial quotients, but I
dislike this entrenched terminology), where |c0| is a positive or
negative integer and the others are positive integers.

Typesetting is usually done via the |amsmath| macro |\cfrac|:
\begin{everbatim*}
\[ c_0 + \cfrac{1}{c_1+\cfrac1{c_2+\cfrac1{c_3+\cfrac1{\ddots}}}}\]
\end{everbatim*}

Here is a concrete example:
\begin{everbatim*}
\[ \xintTeXFrac {208341/66317}=\xintCFrac {208341/66317}\]%
\end{everbatim*}
But it is the macro \csbxint{CFrac} which did all the work of \emph{computing}
the continued fraction \emph{and} using |\cfrac| from |amsmath| to typeset
it.

A \emph{generalized} continued fraction has the same structure but the
numerators are not restricted to be $1$, and numbers used in the continued
fraction may be arbitrary, also fractions, irrationals, complex,
indeterminates.%
%
\footnote{\xintcfracname may be used with indeterminates,
  for basic conversions from one inline format to another, but not for
  actual computations. See \csbxint{GGCFrac}.}
%
The \emph{centered} continued fraction is an
example:
\begin{everbatim*}
\[ \xintTeXFrac {915286/188421}=\xintGCFrac {5+-1/7+1/39+-1/53+-1/13}
  =\xintCFrac {915286/188421}\]
\end{everbatim*}

The macro \csbxint{GCFrac}, contrarily to
\csbxint{CFrac}, does not compute anything, it just typesets starting from a
generalized continued fraction in inline format, which in this example
was input literally.  We also used \csa{xintCFrac}
for comparison of the two types of continued fractions.

To let \TeX{} compute the centered continued fraction of |f| there is
\csbxint{FtoCC}:
\begin{everbatim*}
\[\xintTeXFrac {915286/188421}\to\xintFtoCC {915286/188421}\]
\end{everbatim*}
The package macros are expandable and may be nested (naturally \csa{xintCFrac}
and \csa{xintGCFrac} must be at the top level, as they deal with typesetting).
\begin{everbatim*}
\[\xintGCFrac {\xintFtoCC{915286/188421}}\]
\end{everbatim*}

The `inline' format expected on input by \csbxint{GCFrac} is
%
\leftedline{$a_0+b_0/a_1+b_1/a_2+b_2/a_3+\cdots+b_{n-2}/a_{n-1}+b_{n-1}/a_n$}
%
Fractions among the coefficients are allowed but they must be enclosed
within braces. Signed integers may be left without braces (but the |+|
signs are mandatory). No spaces are allowed around the plus and fraction
symbols. The coefficients may themselves be macros, as long as these
macros are \fexpan dable.
\begin{everbatim*}
\[ \xintTeXFrac{\xintGCtoF {1+-1/57+\xintPow {-3}{7}/\xintiiQuo {132}{25}}}
    = \xintGCFrac {1+-1/57+\xintPow {-3}{7}/\xintiiQuo {132}{25}}\]
\end{everbatim*}
To compute the actual fraction one has \csbxint{GCtoF}:
\begin{everbatim*}
\[\xintTeXFrac{\xintGCtoF {1+-1/57+\xintPow {-3}{7}/\xintiiQuo {132}{25}}}\]
\end{everbatim*}
For non-numeric input  there is \csbxint{GGCFrac}.
\begin{everbatim*}
\[\xintGGCFrac {a_0+b_0/a_1+b_1/a_2+b_2/\ddots+\ddots/a_{n-1}+b_{n-1}/a_n}\]
\end{everbatim*}
For regular continued fractions, there is a simpler comma separated format:
\begin{everbatim*}
\[-7,6,19,1,33\to\xintTeXFrac{\xintCstoF{-7,6,19,1,33}}=
                 \xintCFrac{\xintCstoF{-7,6,19,1,33}}\]
\end{everbatim*}
The macro \csbxint{FtoCs} produces from a fraction |f| the comma separated
list of its coefficients.
\begin{everbatim*}
\[\xintTeXFrac{1084483/398959}=[\xintFtoCs{1084483/398959}]\]
\end{everbatim*}
If one prefers other separators, one can use the two arguments macros
\csbxint{FtoCx} whose first argument is the separator (which may consist of more
than one token) which is to be used.
\begin{everbatim*}
\[\xintTeXFrac{2721/1001}=\xintFtoCx {+1/(}{2721/1001})\cdots)\]
\end{everbatim*}
This allows under Plain  \TeX{} with |amstex| to obtain the same effect
as with \LaTeX{}+|\amsmath|+\csbxint{CFrac}:
%
\leftedline{|$$\xintTeXOver{2721/1001}=\xintFtoCx {+\cfrac1\\ }{2721/1001}\endcfrac$$|}

As a shortcut to \csa{xintFtoCx} with separator |1+/|, there is
\csbxint{FtoGC}:
\begin{everbatim*}
2721/1001=\xintFtoGC {2721/1001}
\end{everbatim*}
Let us compare in that case with the output of \csbxint{FtoCC}:
\begin{everbatim*}
2721/1001=\xintFtoCC {2721/1001}
\end{everbatim*}
To obtain the coefficients as a sequence of braced numbers, there is
\csbxint{FtoC} (this is a shortcut for |\xintFtoCx {}|). This list
(sequence) may then be manipulated using the various macros of \xinttoolsname
such as the non-expandable macro \csbxint{AssignArray} or the expandable
\csbxint{Apply} and \csbxint{ListWithSep}.

Conversely to go from such a sequence of braced coefficients to the
corresponding fraction there is \csbxint{CtoF}.

The `|\printnumber|' (\autoref{ssec:printnumber}) macro which we use in this
document to print long numbers can also be useful on long continued fractions.
%
\begin{everbatim*}
\printnumber{\xintFtoCC {35037018906350720204351049/244241737886197404558180}}
\end{everbatim*}
%
If we apply \csbxint{GCtoF} to this generalized continued fraction, we
discover that the original fraction was reducible:
%
\leftedline{|\xintGCtoF
  {143+1/2+...+-1/9}|\dtt{=\xintGCtoF{143+1/2+1/5+-1/4+-1/4+-1/4+-1/3+1/2+1/2+1/6+-1/22+1/2+1/10+-1/5+-1/11+-1/3+1/4+-1/2+1/2+1/4+-1/2+1/23+1/3+1/8+-1/6+-1/9}}}

\def\mymacro #1{$\xintTeXFrac{#1}=[\xintFtoCs{#1}]$\vtop to 6pt{}}

\begingroup
\catcode`^\active
\def^#1^{\hbox{#1}}%

When a generalized continued fraction is built with integers, and
numerators are only |1|'s or |-1|'s, the produced fraction is
irreducible. And if we compute it again with the last sub-fraction
omitted we get another irreducible fraction related to the bigger one by
a Bézout identity. Doing this here we get:
%
\leftedline{|\xintGCtoF {143+1/2+...+-1/6}|\dtt{=\xintGCtoF{143+1/2+1/5+-1/4+-1/4+-1/4+-1/3+1/2+1/2+1/6+-1/22+1/2+1/10+-1/5+-1/11+-1/3+1/4+-1/2+1/2+1/4+-1/2+1/23+1/3+1/8+-1/6}}}
and indeed:
\[\begin{vmatrix}
    ^2897319801297630107^ & ^328124887710626729^\\
      ^20197107104701740^ & ^2287346221788023^
   \end{vmatrix} = \mbox{\dtt{\xintiiSub {\xintiiMul {2897319801297630107}{2287346221788023}}{\xintiiMul{20197107104701740}{328124887710626729}}}}\]

\endgroup

The various fractions obtained from the truncation of a continued fraction to
its initial terms are called the convergents. The macros of \xintcfracname
such as \csbxint{FtoCv}, \csbxint{FtoCCv}, and others which compute such
convergents, return them as a list of braced items, with no separator (as does
\csbxint {FtoC} for the partial quotients). Here is an example:

\begin{everbatim*}
\[\xintTeXFrac{915286/188421}\to
  \xintListWithSep{,}{\xintApply\xintTeXFrac{\xintFtoCv{915286/188421}}}\]
\end{everbatim*}
\begin{everbatim*}
\[\xintTeXFrac{915286/188421}\to
  \xintListWithSep{,}{\xintApply\xintTeXFrac{\xintFtoCCv{915286/188421}}}\]
\end{everbatim*}
%
We thus see that the `centered convergents' obtained with \csbxint{FtoCCv} are
among the fuller list of convergents as returned by \csbxint{FtoCv}.

Here is a more complicated use of \csa{xintApply}
and \csa{xintListWithSep}. We first define a macro which will be applied to each
convergent:%
%
\leftedline{|\newcommand{\mymacro}[1]{$\xintTeXFrac{#1}=[\xintFtoCs{#1}]$\vtop to 6pt{}}|}
%
Next, we use the following code:
%
\leftedline{|$\xintTeXFrac{49171/18089}\to{}$|}
%
\leftedline{|\xintListWithSep {,
  }{\xintApply{\mymacro}{\xintFtoCv{49171/18089}}}|}
It produces:\par
\noindent$ \xintTeXFrac{49171/18089}\to {}$\xintListWithSep {,
  }{\xintApply{\mymacro}{\xintFtoCv{49171/18089}}}.

The macro \csbxint{CntoF} allows to specify the coefficients as a function given
by a one-parameter macro. The produced values do not have to be integers.
\begin{everbatim*}
\def\cn #1{\xintiiPow {2}{#1}}% 2^n
  \[\xintTeXFrac{\xintCntoF {6}{\cn}}=\xintCFrac [l]{\xintCntoF {6}{\cn}}\]
\end{everbatim*}

Notice  the use of the optional argument |[l]| to \csa{xintCFrac}. Other
possibilities are |[r]| and (default) |[c]|.
\begin{everbatim*}
\def\cn #1{\xintPow {2}{-#1}}%
  \[\xintTeXFrac{\xintCntoF {6}{\cn}}=\xintGCFrac [r]{\xintCntoGC {6}{\cn}}=
      [\xintFtoCs {\xintCntoF {6}{\cn}}]\]
\end{everbatim*}
We used \csbxint{CntoGC} as we wanted to display also the continued fraction and
not only the fraction returned by \csa{xintCntoF}.

There are also \csbxint{GCntoF} and \csbxint{GCntoGC} which allow the same for
generalized fractions. An initial portion of a generalized continued
fraction for $\pi$ is obtained like this
\begin{everbatim*}
\def\an #1{\the\numexpr 2*#1+1\relax }%
\def\bn #1{\the\numexpr (#1+1)*(#1+1)\relax }%
\[\xintTeXFrac{\xintDiv {4}{\xintGCntoF {5}{\an}{\bn}}} =
        \cfrac{4}{\xintGCFrac{\xintGCntoGC {5}{\an}{\bn}}} =
                  \xintTrunc {10}{\xintDiv {4}{\xintGCntoF {5}{\an}{\bn}}}\dots\]
\end{everbatim*}

We see that the quality of approximation is not fantastic compared to the simple
continued fraction of $\pi$ with about as many terms:
\begin{everbatim*}
\[\xintTeXFrac{\xintCstoF{3,7,15,1,292,1,1}}=
             \xintGCFrac{3+1/7+1/15+1/1+1/292+1/1+1/1}=
                       \xintTrunc{10}{\xintCstoF{3,7,15,1,292,1,1}}\dots\]
\end{everbatim*}

When studying the continued fraction of some real number, there is always
some doubt about how many terms are valid, when computed starting from some
approximation. If $f\leqslant x\leqslant g$ and $f, g$ both have the
same first $K$ partial quotients, then $x$ also has the same first $K$ quotients
and convergents. The macro \csbxint{FGtoC} outputs as a sequence of braced items
the common partial quotients of its two arguments. We can thus use it to produce
a sure list of valid convergents of $\pi$ for example, starting from some proven
lower and upper bound:
\begin{everbatim*}
$$\pi\to [\xintListWithSep{,}
         {\xintFGtoC {3.14159265358979323}{3.14159265358979324}}, \dots]$$
\noindent$\pi\to\xintListWithSep{,\allowbreak\;}
   {\xintApply{\xintTeXFrac}
   {\xintCtoCv{\xintFGtoC {3.14159265358979323}{3.14159265358979324}}}}, \dots$
\end{everbatim*}


\subsection{\csh{xintCFrac}}\label{xintCFrac}

\csa{xintCFrac}|{f}|\ntype{\Ff} is a math-mode only, \LaTeX{} with |amsmath|
only, macro which first computes then displays with the help of |\cfrac| the
simple continued fraction corresponding to the given fraction. It admits an
optional argument which may be |[l]|, |[r]| or (the default) |[c]| to specify
the location of the one's in the numerators of the sub-fractions.
This macro is \fexpan dable in the sense that it prepares expandably
the whole expression with the multiple |\cfrac|'s, but it is not completely
expandable naturally as |\cfrac| isn't.

\subsection{\csh{xintGCFrac}}\label{xintGCFrac}

\csa{xintGCFrac}|{a+b/c+d/e+f/g+h/...+x/y}|\ntype{f} uses similarly |\cfrac|
to prepare the typesetting with the |amsmath| |\cfrac| (\LaTeX{}) of a
generalized continued fraction given in inline format (or as macro which
will \fexpan d to it). It admits the
same optional argument as \csa{xintCFrac}. Plain \TeX{} with |amstex|
users, see \csbxint{GCtoGCx}.
\begin{everbatim*}
\[\xintGCFrac {1+\xintPow{1.5}{3}/{1/7}+{-3/5}/\xintiiFac {6}}\]
\end{everbatim*}
This is mostly a typesetting macro, although it does trigger the
expansion of the coefficients. See \csbxint{GCtoF} if you are impatient
to see this specific fraction computed.

It admits an optional argument within square brackets which may be
either |[l]|, |[c]| or |[r]|. Default is |[c]| (numerators are centered).

Numerators and denominators are made arguments to the \csbxint{TeXFrac}
macro. This allows them to be themselves fractions or anything \fexpan
dable giving numbers or fractions, but also means however that they can
not be arbitrary material, they can not contain color changing macros
for example. One of the reasons is that \csa{xintGCFrac} tries to
determine the signs of the numerators and chooses accordingly to use
$+$ or $-$.

\subsection{\csh{xintGGCFrac}}\label{xintGGCFrac}

\csa{xintGGCFrac}|{a+b/c+d/e+f/g+h/...+x/y}|\ntype{f} is a clone of
\csbxint{GCFrac}, hence again \LaTeX{} specific with package
|amsmath|.
It does not assume the coefficients to be numbers as understood by
\xintfracname. The macro can be used for displaying arbitrary content as
a continued fraction with |\cfrac|, using only plus signs though. Note
though that it will first \fexpan d its argument, which may be thus be
one of the \xintcfracname macros producing a (general) continued
fraction in inline format, see \csbxint{FtoCx} for an example. If this
expansion is not wished, it is enough to start the argument with a
space.
\begin{everbatim*}
\[\xintGGCFrac {1+q/1+q^2/1+q^3/1+q^4/1+q^5/\ddots}\]
\end{everbatim*}

\subsection{\csh{xintGCtoGCx}}\label{xintGCtoGCx}
%{\small New with release |1.05|.\par}

\csa{xintGCtoGCx}|{sepa}{sepb}{a+b/c+d/e+f/...+x/y}|\etype{nnf} returns the list
of the coefficients of the generalized continued fraction of |f|, each one
within a pair of braces, and separated with the help of |sepa| and |sepb|. Thus
%
\leftedline{|\xintGCtoGCx :;{1+2/3+4/5+6/7}| gives \xintGCtoGCx
  :;{1+2/3+4/5+6/7}}
%
The following can be used byt Plain \TeX{}+|amstex| users to obtain an
output similar as the ones produced by \csbxint{GCFrac} and
\csbxint{GGCFrac}:\par
\everb|@
$$\xintGCtoGCx {+\cfrac}{\\}{a+b/...}\endcfrac$$
$$\xintGCtoGCx {+\cfrac\xintTeXOver}{\\\xintTeXOver}{a+b/...}\endcfrac$$
|

\subsection{\csh{xintFtoC}}\label{xintFtoC}

\csa{xintFtoC}|{f}|\etype{\Ff} computes the
coefficients of the simple continued fraction of |f| and returns them as a list
(sequence) of braced items.

\begin{everbatim*}
\fdef\test{\xintFtoC{-5262046/89233}}\texttt{\meaning\test}
\end{everbatim*}

\subsection{\csh{xintFtoCs}}\label{xintFtoCs}

\csa{xintFtoCs}|{f}|\etype{\Ff} returns the comma separated list of the
coefficients of the simple continued fraction of |f|. Notice that starting with
|1.09m| a space follows each comma (mainly for usage in text mode, as in math
mode spaces are produced in the typeset output by \TeX{} itself).
\begin{everbatim*}
\[ \xintTeXsignedFrac{-5262046/89233} \to [\xintFtoCs{-5262046/89233}]\]
\end{everbatim*}

\subsection{\csh{xintFtoCx}}\label{xintFtoCx}

\csa{xintFtoCx}|{sep}{f}|\etype{n\Ff} returns the list of the
coefficients of the simple continued fraction of |f| separated with the
help of |sep|, which may be anything (and is kept unexpanded). For
example, with Plain \TeX{} and |amstex|,
%
\leftedline{|$$\xintFtoCx {+\cfrac1\\ }{-5262046/89233}\endcfrac$$|}
%
will display the continued fraction using
|\cfrac|. Each coefficient is inside a brace pair \hbox{|{ }|}, allowing
a macro to end the separator and fetch it as argument,
for example, again with Plain \TeX{} and |amstex|:
\everb|@
  \def\highlight #1{\ifnum #1>200 \textcolor{red}{#1}\else #1\fi}
  $$\xintFtoCx {+\cfrac1\\ \highlight}{104348/33215}\endcfrac$$
|

Due to the different and extremely cumbersome syntax of |\cfrac| under
\LaTeX{} it proves a bit tortuous to obtain there the same effect.
Actually, it is partly for this purpose that |1.09m| added \csbxint
{GGCFrac}. We thus use \csa{xintFtoCx} with a suitable separator, and\;
then the whole thing as argument to \csbxint{GGCFrac}:
\begin{everbatim*}
\def\highlight #1{\ifnum #1>200 \fcolorbox{blue}{white}{\boldmath\color{red}$#1$}%
    \else #1\fi}
\[\xintGGCFrac {\xintFtoCx {+1/\highlight}{208341/66317}}\]
\end{everbatim*}

\subsection{\csh{xintFtoGC}}\label{xintFtoGC}

\csa{xintFtoGC}|{f}|\etype{\Ff} does the same as \csa{xintFtoCx}|{+1/}{f}|. Its
output may thus be used in the package macros expecting such an `inline
format'.
% This continued fraction is a \emph{simple} one, not a
% \emph{generalized} one, but as it is produced in the format used for
% user input of generalized continued fractions, the macro was called
% \csa{xintFtoGC} rather than \csa{xintFtoC} for example.
%
\begin{everbatim*}
566827/208524=\xintFtoGC {566827/208524}
\end{everbatim*}

\subsection{\csh{xintFGtoC}}\label{xintFGtoC}

\csa{xintFGtoC}|{f}{g}|\etype{\Ff\Ff} computes the common initial coefficients
to
two given fractions |f| and |g|. Notice that any real number |f<x<g| or |f>x>g|
will then necessarily share with |f| and |g| these common initial coefficients
for its regular continued fraction. The coefficients are output as a sequence of
braced numbers. This list can then be manipulated via macros from
\xinttoolsname, or other macros of \xintcfracname.

\begin{everbatim*}
\fdef\test{\xintFGtoC{-5262046/89233}{-5314647/90125}}\texttt{\meaning\test}
\end{everbatim*}
\begin{everbatim*}
\fdef\test{\xintFGtoC{3.141592653}{3.141592654}}\texttt{\meaning\test}
\end{everbatim*}
\begin{everbatim*}
\fdef\test{\xintFGtoC{3.1415926535897932384}{3.1415926535897932385}}\meaning\test
\end{everbatim*}
\begin{everbatim*}
\xintRound {30}{\xintCstoF{\xintListWithSep{,}{\test}}}
\end{everbatim*}
\begin{everbatim*}
\xintRound {30}{\xintCtoF{\test}}
\end{everbatim*}
\begin{everbatim*}
\fdef\test{\xintFGtoC{1.41421356237309}{1.4142135623731}}\meaning\test
\end{everbatim*}

\subsection{\csh{xintFtoCC}}\label{xintFtoCC}

\csa{xintFtoCC}|{f}|\etype{\Ff} returns the `centered' continued fraction of
|f|, in `inline format'. %
\begin{everbatim*}
566827/208524=\xintFtoCC {566827/208524}
\end{everbatim*}
\begin{everbatim*}
\[\xintTeXFrac{566827/208524} = \xintGCFrac{\xintFtoCC{566827/208524}}\]
\end{everbatim*}

\subsection{\csh{xintCstoF}}\label{xintCstoF}

\csa{xintCstoF}|{a,b,c,d,...,z}|\etype{f} computes the fraction corresponding to
the coefficients, which may be fractions or even macros expanding to such
fractions. The final fraction may then be highly reducible.

Starting with
release |1.09m| spaces before commas are allowed and trimmed automatically
(spaces after commas were already silently handled in earlier releases).
\begin{everbatim*}
\[\xintGCFrac {-1+1/3+1/-5+1/7+1/-9+1/11+1/-13}=
  \xintTeXsignedFrac{\xintCstoF {-1,3,-5,7,-9,11,-13}}=\xintTeXsignedFrac{\xintGCtoF
    {-1+1/3+1/-5+1/7+1/-9+1/11+1/-13}}\]
\end{everbatim*}
\begin{everbatim*}
\[\xintGCFrac{{1/2}+1/{1/3}+1/{1/4}+1/{1/5}}=
                                \xintTeXFrac{\xintCstoF {1/2,1/3,1/4,1/5}}\]
\end{everbatim*}
%
A generalized continued fraction may produce a reducible fraction
(\csa{xintCstoF} tries its best not to accumulate in a silly way superfluous
factors but will not do simplifications which would be obvious to a human, like
simplification by 3 in the result above).

\subsection{\csh{xintCtoF}}\label{xintCtoF}

\csa{xintCtoF}|{{a}{b}{c}...{z}}|\etype{f} computes the fraction corresponding
to the coefficients, which may be fractions or even macros.
\begin{everbatim*}
\xintCtoF {\xintApply {\xintiiPow 3}{\xintSeq {1}{5}}}
\end{everbatim*}
\begin{everbatim*}
\[ \xintTeXFrac{14946960/4805083}=\xintCFrac {14946960/4805083}\]
\end{everbatim*}
In the example above the power of $3$ was already pre-computed via the expansion
done by |\xintApply|, but if we try with |\xintApply { \xintiiPow 3}| where the
space will stop this expansion, we can check that |\xintCtoF| will itself
provoke the needed coefficient expansion.% ok

\subsection{\csh{xintGCtoF}}\label{xintGCtoF}

\csa{xintGCtoF}|{a+b/c+d/e+f/g+......+v/w+x/y}|\etype{f} computes the fraction
defined by the inline generalized continued fraction. Coefficients may be
fractions but must then be put within braces. They can be macros. The plus signs
are mandatory.
\begin{everbatim*}
\[\xintGCFrac {1+\xintPow{1.5}{3}/{1/7}+{-3/5}/\xintiiFac {6}} =
\xintTeXFrac{\xintGCtoF {1+\xintPow{1.5}{3}/{1/7}+{-3/5}/\xintiiFac {6}}} =
\xintTeXFrac{\xintIrr{\xintGCtoF
                  {1+\xintPow{1.5}{3}/{1/7}+{-3/5}/\xintiiFac {6}}}}\]
\end{everbatim*}

\begin{everbatim*}
\[ \xintGCFrac{{1/2}+{2/3}/{4/5}+{1/2}/{1/5}+{3/2}/{5/3}} =
   \xintTeXFrac{\xintGCtoF {{1/2}+{2/3}/{4/5}+{1/2}/{1/5}+{3/2}/{5/3}}} \]
\end{everbatim*}

The macro tries its best not to accumulate superfluous factor in the
denominators, but doesn't reduce the fraction to irreducible form before
returning it and does not do simplifications which would be obvious to a human.

\subsection{\csh{xintCstoCv}}\label{xintCstoCv}

\csa{xintCstoCv}|{a,b,c,d,...,z}|\etype{f} returns the sequence of the
corresponding convergents, each one within braces.

It is allowed to use fractions as coefficients (the computed
convergents have then no reason to be the real convergents of the final
fraction). When the coefficients are integers, the convergents are irreducible
fractions, but otherwise it is not necessarily the case.
\begin{everbatim*}
\xintListWithSep:{\xintCstoCv{1,2,3,4,5,6}}
\end{everbatim*}
\begin{everbatim*}
\xintListWithSep:{\xintCstoCv{1,1/2,1/3,1/4,1/5,1/6}}
\end{everbatim*}
\begin{everbatim*}
\[\xintListWithSep{\to}{\xintApply\xintTeXFrac{\xintCstoCv {\xintPow
        {-.3}{-5},7.3/4.57,\xintCstoF{3/4,9,-1/3}}}}\]
\end{everbatim*}

\subsection{\csh{xintCtoCv}}\label{xintCtoCv}

\csa{xintCtoCv}|{{a}{b}{c}...{z}}|\etype{f} returns the sequence of the
corresponding convergents, each one within braces.
\begin{everbatim*}
\fdef\test{\xintCtoCv {11111111111}}\texttt{\meaning\test}
\end{everbatim*}

\subsection{\csh{xintGCtoCv}}\label{xintGCtoCv}

\csa{xintGCtoCv}|{a+b/c+d/e+f/g+......+v/w+x/y}|\etype{f} returns the list of
the corresponding convergents. The coefficients may be fractions, but must then
be inside braces. Or they may be macros, too.

The convergents will in the general case be reducible. To put them into
irreducible form, one needs one more step, for example it can be done
with |\xintApply\xintIrr|.
\begin{everbatim*}
\[\xintListWithSep{,}{\xintApply\xintTeXFrac
                {\xintGCtoCv{3+{-2}/{7/2}+{3/4}/12+{-56}/3}}}\]
\[\xintListWithSep{,}{\xintApply\xintTeXFrac{\xintApply\xintIrr
                {\xintGCtoCv{3+{-2}/{7/2}+{3/4}/12+{-56}/3}}}}\]
\end{everbatim*}


\subsection{\csh{xintFtoCv}}\label{xintFtoCv}

\csa{xintFtoCv}|{f}|\etype{\Ff} returns the list of the (braced) convergents of
|f|, with no separator. To be treated with \csbxint{AssignArray} or
\csbxint{ListWithSep}.
\begin{everbatim*}
\[\xintListWithSep{\to}{\xintApply\xintTeXFrac{\xintFtoCv{5211/3748}}}\]
\end{everbatim*}

\subsection{\csh{xintFtoCCv}}\label{xintFtoCCv}

\csa{xintFtoCCv}|{f}|\etype{\Ff} returns the list of the (braced) centered
convergents of |f|, with no separator. To be treated with \csbxint{AssignArray}
or \csbxint{ListWithSep}.
\begin{everbatim*}
\[\xintListWithSep{\to}{\xintApply\xintTeXFrac{\xintFtoCCv{5211/3748}}}\]
\end{everbatim*}

\subsection{\csh{xintCntoF}}\label{xintCntoF}


\csa{xintCntoF}|{N}{\macro}|\etype{\numx f} computes the fraction |f| having
coefficients |c(j)=\macro{j}| for |j=0,1,...,N|. The |N| parameter is given to a
|\numexpr|. The values of the coefficients, as returned by |\macro| do not have
to be positive, nor integers, and it is thus not necessarily the case that the
original |c(j)| are the true coefficients of the final |f|.
\begin{everbatim*}
\def\macro #1{\the\numexpr 1+#1*#1\relax} \xintCntoF {5}{\macro}
\end{everbatim*}

This example shows that the fraction is output with a trailing number in square
brackets (representing a power of ten), this is for consistency with what do
most macros of \xintfracname, and does not have to be always this annoying |[0]|
as the coefficients may for example be numbers in scientific notation. To avoid
these trailing square brackets, for example if the coefficients are known to be integers, there is always the possibility to filter the output via
\csbxint{PRaw}, or \csbxint{Irr} (the latter is overkill in the case of integer
coefficients, as the fraction is guaranteed to be irreducible then).

\subsection{\csh{xintGCntoF}}\label{xintGCntoF}

\csa{xintGCntoF}|{N}{\macroA}{\macroB}|\etype{\numx ff} returns the fraction |f|
corresponding to the inline generalized continued fraction
|a0+b0/a1+b1/a2+....+b(N-1)/aN|, with |a(j)=\macroA{j}| and |b(j)=\macroB{j}|.
The |N| parameter is given to a |\numexpr|.
\begin{everbatim*}
\def\coeffA #1{\the\numexpr #1+4-3*((#1+2)/3)\relax }%
\def\coeffB #1{\the\numexpr \ifodd #1 -\fi 1\relax }% (-1)^n
\[\xintGCFrac{\xintGCntoGC {6}{\coeffA}{\coeffB}} =
                                \xintTeXFrac{\xintGCntoF {6}{\coeffA}{\coeffB}}\]
\end{everbatim*}
There is also \csbxint{GCntoGC} to get the `inline format' continued
fraction.

\subsection{\csh{xintCntoCs}}\label{xintCntoCs}

\csa{xintCntoCs}|{N}{\macro}|\etype{\numx f} produces the comma separated list
of the corresponding coefficients, from |n=0| to |n=N|. The |N| is given to a
|\numexpr|. %
\begin{everbatim*}
\xintCntoCs {5}{\macro}
\end{everbatim*}
\begin{everbatim*}
\[ \xintTeXFrac{\xintCntoF{5}{\macro}}=\xintCFrac{\xintCntoF {5}{\macro}}\]
\end{everbatim*}

\subsection{\csh{xintCntoGC}}\label{xintCntoGC}

%
\csa{xintCntoGC}|{N}{\macro}|\etype{\numx f} evaluates the |c(j)=\macro{j}| from
|j=0| to |j=N| and returns a continued fraction written in inline format:
|{c(0)}+1/{c(1)}+1/...+1/{c(N)}|. The parameter |N| is given to a |\numexpr|.
The coefficients, after expansion, are, as shown, being enclosed in an added
pair of braces, they may thus be fractions.
\begin{everbatim*}
\def\macro #1{\the\numexpr\ifodd#1 -1-#1\else1+#1\fi\relax/\the\numexpr 1+#1*#1\relax}
\fdef\x{\xintCntoGC {5}{\macro}}\meaning\x
\[\xintGCFrac{\xintCntoGC {5}{\macro}}\]
\end{everbatim*}

\subsection{\csh{xintGCntoGC}}\label{xintGCntoGC}

\csa{xintGCntoGC}|{N}{\macroA}{\macroB}|\etype{\numx ff} evaluates the
coefficients and then returns the corresponding
|{a0}+{b0}/{a1}+{b1}/{a2}+...+{b(N-1)}/{aN}| inline generalized fraction. |N| is
givent to a |\numexpr|. The coefficients are enclosed into pairs
of braces, and may thus be fractions, the fraction slash will not be
confused in further processing by the continued fraction slashes.
%
\begin{everbatim*}
\def\an #1{\the\numexpr  #1*#1*#1+1\relax}%
\def\bn #1{\the\numexpr \ifodd#1 -\fi 1*(#1+1)\relax}%
$\xintGCntoGC {5}{\an}{\bn}=\xintGCFrac {\xintGCntoGC {5}{\an}{\bn}} =
\displaystyle\xintTeXFrac {\xintGCntoF {5}{\an}{\bn}}$\par
\end{everbatim*}

\subsection{\csh{xintCstoGC}}\label{xintCstoGC}

\csa{xintCstoGC}|{a,b,..,z}|\etype{f} transforms a comma separated list (or
something expanding to such a list) into an `inline format' continued fraction
|{a}+1/{b}+1/...+1/{z}|. The coefficients are just copied and put within braces,
without expansion. The output can then be used in \csbxint{GCFrac} for example.
\begin{everbatim*}
\[\xintGCFrac {\xintCstoGC {-1,1/2,-1/3,1/4,-1/5}}=\xintTeXsignedFrac{\xintCstoF {-1,1/2,-1/3,1/4,-1/5}}\]
\end{everbatim*}
\subsection{\csh{xintiCstoF}, \csh{xintiGCtoF}, \csh{xintiCstoCv}, \csh{xintiGCtoCv}}\label{xintiCstoF}
\label{xintiGCtoF}
\label{xintiCstoCv}
\label{xintiGCtoCv}

Essentially\etype{f} the same as the corresponding macros without the
`i', but for integer-only input. Infinitesimally faster, mainly for
internal use by the package.

\subsection{\csh{xintGCtoGC}}\label{xintGCtoGC}

\csa{xintGCtoGC}|{a+b/c+d/e+f/g+......+v/w+x/y}|\etype{f} expands (with the
usual meaning) each one of the coefficients and returns an inline continued
fraction of the same type, each expanded coefficient being enclosed within
braces.
%
\begin{everbatim*}
\fdef\x {\xintGCtoGC {1+\xintPow{1.5}{3}/{1/7}+{-3/5}/%
                        \xintiiFac {6}+\xintCstoF {2,-7,-5}/16}} \meaning\x
\end{everbatim*}

To be honest I have forgotten for which purpose I wrote this macro in the first
place.

\subsection{Euler's number \texorpdfstring{$e$}{e}}\label{ssec:e-convergents}

Let us explore
the convergents of Euler's number $e$.
\smallskip The volume of computation is kept minimal by the following steps:
\begin{itemize}
\item a comma separated list of the first 36 coefficients is produced by
  \csbxint{CntoCs},
\item this is then given to \csbxint{iCstoCv} which produces the list of the
  convergents (there is also \csbxint{CstoCv}, but our
  coefficients being integers we used the infinitesimally
  faster \csbxint{iCstoCv}),
\item then the whole list was converted into a sequence of one-line paragraphs,
  each convergent becomes the argument to a  macro printing it
  together with its decimal expansion with 30 digits after the decimal point.
\item A count register |\cnta| was used to give a line count serving as a visual
  aid: we could also have done that in an expandable way, but well, let's relax
  from time to time\dots
\end{itemize}

\begin{everbatim*}
\def\cn #1{\the\numexpr\ifcase \numexpr #1+3-3*((#1+2)/3)\relax
                           1\or1\or2*(#1/3)\fi\relax }
% produces the pattern 1,1,2,1,1,4,1,1,6,1,1,8,... which are the
% coefficients of the simple continued fraction of e-1.
\cnta 0
\def\mymacro #1{\advance\cnta by 1
                \noindent
                \hbox to 3em {\hfil\small\dtt{\the\cnta.} }%
                $\xintTrunc {30}{\xintAdd {1[0]}{#1}}\dots=
                 \xintTeXFrac{\xintAdd {1[0]}{#1}}$}%
\xintListWithSep{\vtop to 6pt{}\vbox to 12pt{}\par}
    {\xintApply\mymacro{\xintiCstoCv{\xintCntoCs {35}{\cn}}}}
\end{everbatim*}


\smallskip

% The actual computation of the list of all 36 convergents accounts for
% only 8\% of the total time (total time equal to about 5 hundredths of a second
% in my testing, on my laptop): another 80\% is occupied with the computation of
% the truncated decimal expansions (and the addition of 1 to everything as the
% formula gives the continued fraction of $e-1$).

One can with no problem compute
much bigger convergents. Let's get the 200th convergent. It turns out to
have the same first 268 digits after the decimal point as $e-1$. Higher
convergents get more and more digits in proportion to their index: the 500th
convergent already gets 799 digits correct! To allow speedy compilation of the
source of this document when the need arises, I limit here to the 200th
convergent.
%  (getting the 500th took about 1.2s on my laptop last time I tried,
% and the 200th convergent is obtained ten times faster).
\begin{everbatim*}
\fdef\z {\xintCntoF {199}{\cn}}%
\begingroup\parindent 0pt \leftskip 2.5cm
\indent\llap {Numerator = }\printnumber{\xintNumerator\z}\par
\indent\llap {Denominator = }\printnumber{\xintDenominator\z}\par
\indent\llap {Expansion = }\printnumber{\xintTrunc{268}\z}\dots\par\endgroup
\end{everbatim*}


One can also use a centered continued fraction: we get more digits but there are
also more computations as the numerators may be either
$1$ or $-1$.

\ifnum\NoSourceCode=1
\clearpage
\def\xintRunningHeader{{\inheadertrue\catcode`,12\relax
          \DOCxintfrontpage,
          \DOCxintexprintro,
          \xintbundlename}}

\part{The \xintexprname and allied packages source code (not
  included, see \textcolor{verbcolor}{\texttt{xintsource.pdf}})}

\markboth{\makebox[0pt]{\xintRunningHeader}}{\makebox[0pt]{\xintRunningHeader}}
\vspace{1cm}

\begin{framed}
  %\small % not now that there is the Part which is rather large

  This documentation has been compiled without including the
  commented source code, which is available in the separate file
  |xintsource.pdf|,
  and will open in a PDF viewer via:
  %
  \centeredline{|texdoc xintsource.pdf|}


  To produce a file |xint-calx.pdf| including both the user
  documentation and the source code:
  \begin{itemize}
  \item acquire |xint-calx.dtx| from 
        \centeredline{\url{https://www.ctan.org/tex-archive/macros/generic/xint}}
  \item execute |latex xint-calx.dtx| sufficiently many times (at least three), then
        |dvipdfmx|, or use |pdflatex|.
  \end{itemize}

  One can first execute |etex| on |xint-calx.dtx| to
  extract files.
\end{framed}
\fi
\clearpage
\let\xintcfracnameUp\undefined
\ifnum\doxintsource=1
+fi
+catcode`\ 0
\catcode0 15 % retour à la normale, peu importe
\catcode`\+ 12
\makeatletter
\@gobble\fi
\StopEventually{\end{document}\endinput}
\makeatletter
\let\csh\cshnolabel
% \clearpage
% \newgeometry{%hmarginratio=4:3,
%              hscale=0.7,vscale=0.75}% ATTENTION \newgeometry fait
%                                 % un reset de vscale si on ne le
%                                 % précise pas ici !!!

\AddToHook{env/macrocode/before}{\par@beforemacrocode}
\def\par@beforemacrocode{\par}

% for \csbxint etc...
\let\xintlabelprefix\xintimplabelprefix

\def\xintdocMacrocodeFallbackColorCmd{\normalcolor}
\def\xintdocPrivateColorCmd{\color{privatecommentcolor}}%
\def\xintdocPublicColorCmd{\normalcolor}

% stuff going to .toc file (and hence possibly impacting all TOCs regarding the looks
%                           of titles originating in the implementation part)
\etocdepthtag.toc {implementation}
\addtocontents{toc}{\gdef\string\tocstylesectionbracedcolor{{tocstylesectionimpcolor}}}

\etocignoredepthtags
\inmanualmaintocfalse % already the case anyhow
\etocsetnexttocdepth{section}
% make room for some small text on TOC page under the TOC
\def\tocstylesectionVSKIP{\vskip\medskipamount}

\etocsettocstyle {}{}
\ifnum\doxintsource=1 % xintsource.pdf
\medskip
  \tableofcontents
\else
  \ifnum\NoSourceCode=0 % xint-all.pdf
    % this one needs to be reset as it is modified for the TOCs of the user
    % manual.  This way TOCs of Part III will be in xint-all.pdf as in
    % xintsource.pdf
    \let\etoctoclineleaders\orig@etoctoclineleaders
  \fi

  \bookmark[dest=imp,level=part]{Implementation}

  \begin{minipage}[t][8\baselineskip][c]{\linewidth}
  \RaisedTarget{imp}
    \part{The \xintexprnameimp and allied packages source code}
  \RaisedLabel[15]{partiii}
  \end{minipage}
  %! ne fonctionne pas ici
  %!  \RaisedLabel[15]{partiii}
  %!
  %! \smash n'est pas \long... mais \smash<space> l'est mais \makesm@sh ne l'est pas
  %! bon de tout façon plus de \par ici
  %! \protected à cause du \smash sinon
  %! ! TeX capacity exceeded, sorry [input stack size=10000].
  %! <inserted text> 
  %!                 \protect \foreignlanguage {english}{\protect \bbl@restore@ac...
  %! l.97 ...er}}{\makebox[0pt]{\xintImpRunningHeader}}
  %!
  %! Not using \hypersetup with linkcolor because a few pages are with 
  %! a TOC à cheval on two pages, and my eTOCs are configured to do
  %! \hypersetup{hidelinks}
  \protected\def\DOCxintfrontpage
   {\smash{\vbox{\hbox{\perhapshyperref[frontpage]{{\color{xintnamecolor}TOC}}}%
          \kern1ex
          \hbox{\perhapshyperref[partiii]{{\color{xintnameimpcolor}TOC}}}}}}%
  \medskip

  \localtableofcontents
\fi
\medskip
\def\etocaftertochook{\addvspace{\bigskipamount}}

\etocsettocdepth{subsubsection}% 2015/09/15
% this is a parameter of the custom tocstyling for sections which we
% set to this value only after having typeset the main TOC of xintsource.pdf
% or TOC of Part III of xint-all.pdf
\def\tocstyleMARGEPAGENO{1.25em}

% modify the page headers
\def\xintImpRunningHeader{{\inheadertrue\catcode`,12\relax
          \DOCxintfrontpage,
          \xintkernelnameimp,
          \xinttoolsnameimp,
          \xintbinhexnameimp,
          \calxcorenameimp,
          \calxintnameimp,
          \calxfpnameimp,
          \xintcorenameimp,
          \xintnameimp,
          \xintfracnameimp,
          \xintgcdnameimp,
          \xintseriesnameimp,\newline
          \xintcfracnameimp,
          \calxtrignameimp, \calxtrigdatanameimp,
          \calxlognameimp, \calxlogdatanameimp, \calxnameimp,
          \xintexprnameimp}}
\markboth{\makebox[0pt]{\xintImpRunningHeader}}{\parbox{\linewidth}{\xintImpRunningHeader}}

\clearpage
\section{An introduction and a brief timeline}

This is \expandafter|\calxbndlversion| of \expandafter|\calxbndldate|.

The |xintchanges.md| file, included in the
\href{https://ctan.org/pkg/xint}{CTAN} upload, contains the complete list of
changes relevant to user level since the initial release of the package:
%
\centeredline{|texdoc xintchanges.md|}

It exists in HTML format at the package web page:
\centeredline{\url{https://jfbu.github.io/xint/CHANGES.html}}


\edef\foo{\columnsep\the\columnsep}
\columnsep5\fontcharwd\font`X\relax
\begin{multicols}{2}\small\raggedcolumns\columnsep9\fontcharwd\font`X\relax
  At |1.4m| I added hyperlinks to the macro code.  Each instance of a macro
  in the code is linked with target the location of its definition (via |\def|
  or |\let| or variants).  This has been done via a heist on \ctanpackage{doc}
  (|v2| version) automated indexing which has been transformed here into
  automated hyperlinking.
  Furthermore the codeline where the macro is defined will link to its
  description in the user manual part of |xint.pdf|.  In (optional build)
  |xintsource.pdf| the link is more
  modestly targeting the sectioning heading referencing the macro name, if
  available.  In |xint.pdf| the macros documented in the user manual
  are marked with a \emph{source} link on top of them, targeting their
  source code.

  The sad truth however is that my code is poorly documented.  The comments
  \begin{itemize}[nosep]
  \item are often too scarce,
  \item have occasional excessive verbosity,
  \item and are generally inadequate or irrelevant.
  \end{itemize}
  The macro comments have had a distinct tendency to record the changes across
  releases or even those occurring during pre-release development phase,
  rather than explaining the interface, or perhaps an algorithm.  As I am
  aware of that, I have a mechanism of \myenquote{private comments} which are
  removed by the |dtx| build script.  But then I sometimes use it en masse as
  it would be too much work to clean-up the existing comments, and as a result
  the code is not commented at all anymore... A typical example is with
  \csbxint{iiSquareRoot} which is amply documented in the private sources but
  only 10\% of it could be of any value to any other reader than myself and it
  would be simply the description of what |#1|, |#2|, ... stand for.  As a
  result I converted at some point everything into
  private comments.  Extracting the useful parts describing the macro
  parameters and checking they are actually still valid would be very
  time-consuming.  The real problem here is that the actual underlying
  algorithms are rarely if ever described.
\end{multicols}
\foo

%\normalsize

\begin{itemize}
\item Release |2.0a1| of |2026/11/01|.
This is a major release in which the internals have been entirely
rewritten for speed. A new \calxnameimp package provides the functionality
of \csbxint{floateval} and \csbxint{iieval}, also available under the aliases
|\calxeval| and |\calxinteval|, respectively. The files \dtt{xintlog.sty}
and \dtt{xinttrig.sty} are gone, replaced by support files in the \dtt{calx}
namespace.

The \calxnameimp package adds almost no new user interface. The main novelty
is |\calxsetup|, which can be used to configure the signal handlers.
By default, no error condition is trapped in the sense of deliberately
raising a low-level TeX error. Instead, such conditions generate
\dtt{NaN}, \dtt{+Infinity}, or \dtt{-Infinity}, which propagate through subsequent
calculations.

The computations of trigonometric functions, logarithms, exponentials,
and powers are now roughly eight times faster.

The legacy interface of \xintfracnameimp is preserved unchanged. Its macros
do not accept non-finite values and still trap error conditions such as
division by zero. Loading \xintexprnameimp automatically loads \calxnameimp and
adds \csbxint{eval} for computations with fractions. Most documents should
compile unchanged, without requiring any modification to their sources.


\item Version |1.4q| dated |2026/10/31| was never released.
  \begin{itemize}[nosep]
  \item \xintexprname: since |1.4a|, |round(x,n)| and |floor(x,n)|
        admit a negative second argument. This worked fine if the result
        was involved in any operation, but depending on release since
        |1.4a| and whether using \csbxint{floateval} or \csbxint{eval}
        if the expression contained nothing else, it would either print
        with garbage or cause a low-level \TeX{} error.
  \item \xintexprname: binary, octal, or hexadecimal inputs all support
        a fractional part; but due to an oversight regarding internal
        numeric types, when the
        integer part was zero, it could happen that the result was
        erroneously given as zero, for example this was teh case
        with |\xinteval{"0.0001}|.
  \end{itemize}
\item Version |1.4p| dated |2026/03/01| was never released.
  \begin{itemize}[nosep]
  \item \xintkernelname: document (in the source code part of |xint.pdf|)
        \csbxint{resettimer}, \csbxint{elapsedtime}
        and \csbxint{theseconds}, already added at |1.4n|.
  \item \xintbinhexname: add \csbxint{LowerHex} and \csbxint{UpperHex}.
  \item \xinttoolsname: an array created via \csbxint{AssignArray}
        can be used with negative indices.
  \item \xintexprname: add all hyperbolic functions and their inverses.
  \end{itemize}
\item Release |1.4o| of |2025/09/06| (with an |1.4n| the day before) is mainly
  a maintenance release, after a few years in a dormant state. The long
  expected overhaul of floating point is again postponed.
  \begin{itemize}[nosep]
  \item \xintbinhexname handles the octal base, and can manage (much) larger inputs,
  \item |0x|, |0o|, and |0b| prefixes, and |'| added to the \csbxint{eval} syntax,
  \item |[h]|, |[o]|, |[b]| optional parameter of \csbxint{iieval},
  \item Babel active characters are auto-tamed in \csbxint{eval} (hotfix at |1.4o|,
        the feature worked at |1.4n| with \csbxint{iieval} but not with the others),
  \item Compatibility with Op\TeX{},
  \item Compatibility with Con\TeX t (only |mkxl|).
  \end{itemize}
  The
  extensive hyperlinking added in 2022 to the docs is better shown to user
  because xint.pdf now (again) contains both the user manual and the commented
  source code.  The packaging was trimmed.
\item Release |1.4m| of |2022/06/09| is mainly a documentation upgrade, which
  added hyperlinks inside the commented macro code, as well as from the user
  manual to the source code (in |xint-all.pdf|, which is an optional
  build). It adds compatibility with \ctanpackage{miniltx}.  It also
  inaugurates usage of the engine string comparison primitive.
\item Release |1.4i| of |2021/06/11|: extension of the
  «simultaneous assignments» concept (backwards compatible).
\item Release |1.4g| of |2021/05/25|:
  powers are now parsed in a right associative way. Removal of the
  single-character operators |&|, \verb=|=, and |=| (deprecated at |1.1|).
  Reformatted expandable error messages.
\item Release |1.4e| of |2021/05/05|: logarithms and exponentials up to 62
  digits, trigonometry still mainly done at high level but with guard digits
  so all digits up to the last one included can be trusted for faithful
  rounding and high probability of correct rounding.
\item Release |1.4| of |2020/01/31|: \xintexprnameimp overhaul to use
  |\expanded| based expansion control.  Many new features, in particular
  support for input and output of nested structures.  Breaking changes, main
  ones being the (provisory) drop of |x*[a, b,...]|, |x+[a, b,...]| et al.\@
  syntax and the requirement of |\expanded| primitive (currently required only
  by \xintexprnameimp).
\item Release |1.3e| of |2019/04/05|: packages \xinttrignameimp, \xintlognameimp;
  \csa{xintdefefunc} ``non-protected'' variant of \csbxint{deffunc} (at |1.4|
  the two got merged and \csa{xintdefefunc} became a deprecated alias for
  \csbxint{deffunc}).
  Indices removed from |xintsource.pdf|.
%  Their functionality is advantageously
  % made available via the search function in PDF viewers. Already the local
  % tables of contents are useful enough most of the time.
\item Release |1.3d| of |2019/01/06|: fix of |1.2p| bug for division with a
  zero dividend and a one-digit divisor, \csbxint{eval} et al. wrappers,
  |gcd()| and |lcm()| work with fractions.
\item Release |1.3c| of |2018/06/17|: documentation better hyperlinked,
  indices added to |xintsource.pdf|. Colon in |:=| now optional for
  \csbxint{defvar} and \csbxint{deffunc}.
\item Release |1.3b| of |2018/05/18|: randomness related additions (still WIP).
\item Release |1.3a| of |2018/03/07|: efficiency fix of the mechanism for
  recursive functions.
\item Release |1.3| of |2018/03/01|: addition and subtraction use
  systematically least common multiple of denominators. Extensive
  under-the-hood refactoring of \csbxint{NewExpr} and \csbxint{deffunc} which
  now allow recursive definitions. Removal of |1.2o| deprecated macros.
\item Release |1.2q| of |2018/02/06|: fix of |1.2l| subtraction bug
  in special situation; tacit multiplication extended to cases such as
  |10!20!30!|.
\item Release |1.2p| of |2017/12/05|: maps |//| and |/:| to the floored, not
  truncated, division. Simultaneous assignments possible with \csbxint{defvar}.
  Efficiency improvements in \xinttoolsnameimp.
\item Release |1.2o| of |2017/08/29|: massive deprecations of those macros
  from \xintcorenameimp and \xintnameimp which filtered their arguments via
  \csbxint{Num}.
\item Release |1.2n| of |2017/08/06|: improvements of \xintbinhexnameimp.
\item Release |1.2m| of |2017/07/31|: rewrite of \xintbinhexnameimp in the
  style of the |1.2| techniques.
\item Release |1.2l| of |2017/07/26|: under the hood efficiency improvements
  in the style of the |1.2| techniques; subtraction refactored. Compatibility
  of most \xintfracnameimp macros with arguments using non-delimited
  |\the\numexpr| or |\the\mathcode| etc...
\item Release |1.2i| of |2016/12/13|: under the hood efficiency improvements
  in the style of the |1.2| techniques.
\item Release |1.2| of |2015/10/10|: complete refactoring of the core
  arithmetic macros and faster \csbxint{expr} parser.
\item Release |1.1| of |2014/10/28|: extensive changes in \xintexprnameimp.
  Addition and subtraction do not multiply denominators blindly but sometimes
  produce smaller ones. Also with that release, packages \xintkernelnameimp
  and \xintcorenameimp got extracted from \xinttoolsnameimp and \xintnameimp.
\item Release |1.09g| of |2013/11/22|: the \xinttoolsnameimp package is
  extracted from \xintnameimp; addition of \csbxint{loop} and \csbxint{iloop}.
\item Release |1.09c| of |2013/10/09|: \csbxint{For}, \csa{xintNewNumExpr}
  (ancestor of \csbxint{NewExpr}/\csbxint{deffunc} mechanism).
\item Release |1.09a| of |2013/09/24|: support for functions by \xintexprnameimp.
\item Release |1.08| of |2013/06/07|: the \xintbinhexnameimp package.
\item Release |1.07| of |2013/05/25|: support for floating point numbers
  added to \xintfracnameimp and first release of the \xintexprnameimp package
  (provided
  \csbxint{expr} and \csbxint{floatexpr}).
\item Release |1.04| of |2013/04/25|: the \xintcfracnameimp package.
\item Release |1.03| of |2013/04/14|: the \xintfracnameimp and
  \xintseriesnameimp packages.
\item Release |1.0| of |2013/03/28|: initial release of the \xintnameimp and
  \xintgcdnameimp packages.
\end{itemize}

%\clearpage


% \macrocode
% ==========

% 2014/11/04 did some hack with active characters à la upquote for straight
% quotes, but this is now irrelevant as we use suitable font from newtxtt with
% straight quotes.

% doc.sty does \AtBeginDocument{\let\macro@font\MacroFont} and formerly I
% overwrote \macro@font to use a newtxtt font with a slashed 0 in the
% implementation part.

% 2022/05/17 removes this, but I still need to redefine \macro@font to remove some
% stuff I formerly added to \MacroFont and which is only useful for the user manual.
\def\macro@font {\ttfamily }

% no problem as * is not "special" so the active catcode will not be reset
\AddToHook{env/macrocode/begin}{\makestarlowast}

\AddToHook{env/macrocode/after}{\@nobreakfalse}
\AddToHook{env/macrocode/begin}{\partopsep0pt\relax}

\begingroup
\catcode`\|=\z@ \catcode`\[=\@ne \catcode`\]=\tw@
\catcode`\{=12 \catcode`\}=12
% Let % be active to use a color for it and gray-out
% comments left in code (there are few)
\catcode`\%=13 \catcode`\ =\active \catcode`\\=\active
|gdef|xmacro@code#1%    \end{macrocode}[#1|end[macrocode]]
|endgroup

\begingroup\catcode`\%=\active\catcode`\^^M 13
\gdef%{\begingroup\color{macrocodecommentcolor}\@percentchar\odef
{\expandafter\endgroup
}}\endgroup



\def\xintMakePrivateLetters{\catcode`: 11 \catcode`? 11 \catcode`@ 11 
                            \catcode`^ 11 \catcode`_ 11 }
\def\xintexprMakePrivateLetters{\xintMakePrivateLetters \catcode`! 11 }
\let\MakePrivateLetters\xintMakePrivateLetters

\odef\init@crossref{\init@crossref%
     \everypar{\refstepcounter{CodelineNo}%
               \llap{{\xintdocMacrocodeFallbackColorCmd\theCodelineNo}\
                      \hskip\@totalleftmargin}%
               }%
     \catcode`\%\active
}%
\def\scan@macro{%
   % we do not insert it yet
   % \special@escape@char
   \step@checksum
%   \ifscan@allowed
      \let\macro@namepart\@empty
      % we need this for reasons explained below
      \let\macro@spacepart\@empty
      \def\next{\futurelet\next\macro@switch}%
%   \else \let\next\@empty \fi
   \next
}
% unchanged:
% \def\macro@switch{\ifcat\noexpand\next a%
%      \let\next\macro@name
%      \else \let\next\short@macro  \fi
%    \next}
\def\short@macro#1{\special@escape@char#1}
% \def\macro@name#1{\edef\macro@namepart{\macro@namepart#1}%
%      \futurelet\next\more@macroname}
% \def\more@macroname{\ifcat\noexpand\next a%
%      \let\next\macro@name
%      \else \let\next\macro@finish \fi
%      \next}
\def\more@macroname{\ifcat\noexpand\next a%
     \expandafter\macro@name
     % we keep the \next for usage later and start filtering out of the way spaces
     % this is caused by necessity of handling things such as \let<space>\foo\bar
     % but also not be fooled by \let<space>#6\macro
     \else \expandafter\macro@gatherspaces \fi
     }
\def\macro@gatherspaces{%
    \ifx\next\@xobeysp
        \expandafter\macro@gatherspaces@i
    \else
        \expandafter\macro@finish
    \fi}%
\def\macro@gatherspaces@i#1{%
    \odef\macro@spacepart{\macro@spacepart#1}% #1 = active space
    \futurelet\next\macro@gatherspaces}%
\newif\iflabelmacro@allowed
\newcounter{xintMacroCnt}
\def\xintimplabelprefix{src-}
\let\xintdoclabelprefix\empty
\let\xintlabelprefix\xintimplabelprefix
\catcode`_ 11
\def\@name@namedef{@namedef}%
\def\macro@finish{%
  \iflabelmacro@allowed
   \expandafter\in@\expandafter{\expandafter.\macro@namepart,}%
   {.csname,.expandafter,.noexpand,.else,%
    .t,.w,.x,.y,.z,.XINT_x,.XINT_y,%
    .XINT_tmpa,.XINT_tmpb,.XINT_tmpc,.XINT_tmpd,.XINT_tmpe,% _ is letter here
    .XINT_expr_defbin_b,.XINT_expr_defbin_c,.XINT_expr_defbin_d,%
    .empty,.space,}%
   \ifin@
     {\xintdocMacrocodeFallbackColorCmd\special@escape@char\macro@namepart}%
   \else
     \ifcsname alreadydefined-\macro@namepart\endcsname
       \hyperref[xintmacro-\macro@namepart]{\special@escape@char\macro@namepart}%
     \else
       % this will make a rather large number of macro names in the string pool...
       \global\expandafter\let\csname alreadydefined-\macro@namepart\endcsname\@empty
       \label{xintmacro-\macro@namepart}%
       \stepcounter{xintMacroCnt}%
       % try to link to a labeled reference in the user documentation (xint-all.pdf)
       \ifcsname r@\xintdoclabelprefix\macro@namepart\endcsname
          {\hypersetup{linkcolor=macrocodelinktouserdoccolor}%
           \hyperref[\xintdoclabelprefix\macro@namepart]%
                    {\textbf{\special@escape@char\macro@namepart}}}%
       \else
       % try to link to a labeled section in implementation part
       \ifcsname r@\xintimplabelprefix\macro@namepart\endcsname
          {\hypersetup{linkcolor=macrocodelinktosectioncolor}%
           \hyperref[\xintimplabelprefix\macro@namepart]%
                    {\textbf{\special@escape@char\macro@namepart}}}%
       \else
          \textcolor{macrocodenewmacrocolor}{\special@escape@char\macro@namepart}%
       \fi\fi
     \fi
   \fi
   \labelmacro@allowedfalse
   \expandafter\in@\expandafter{\expandafter.\macro@namepart,}{.expandafter,}%
   \ifin@
      \ifx\next\scan@macro\labelmacro@allowedtrue\fi
   \fi
  \else % end of labelmacro@allowedtrue branch
    \expandafter\in@\expandafter{\expandafter.\macro@namepart,}%
                {.@namedef,.CALX_fdef,}%
      \ifin@\stepcounter{xintMacroCnt}\fi
    \ifx\next\scan@macro
      \expandafter\in@\expandafter{\expandafter.\macro@namepart,}%
                {.def,.edef,.let,.gdef,.xdef,.odef,.oodef,.fdef,}%
      \ifin@\labelmacro@allowedtrue\fi
    \fi
    \ifcsname r@xintmacro-\macro@namepart\endcsname
      \hyperref[xintmacro-\macro@namepart]{\special@escape@char\macro@namepart}%
    \else
      {\xintdocMacrocodeFallbackColorCmd\special@escape@char\macro@namepart}%
    \fi
  \fi
  % \ifnot@excluded
  %    \edef\@tempa{\noexpand\SpecialIndex{\bslash\macro@namepart}}%
  %    \@tempa  
  % \fi
  \macro@spacepart
}%
\catcode`_ 8

{\sbox0{\color{macrocodenoncscolor}\xdef\foo{\current@color}}}
\ifpdf
 \ifluatex
   \edef\xintdoc@macrocode@pushcolor
       {\pdfextension colorstack\noexpand\@pdfcolorstack push{\foo}\relax}
   \def\xintdoc@macrocode@popcolor
       {\pdfextension colorstack\@pdfcolorstack pop\relax}
 \else
   \edef\xintdoc@macrocode@pushcolor
      {\pdfcolorstack\noexpand\@pdfcolorstack push{\foo}\relax}
   \def\xintdoc@macrocode@popcolor{\pdfcolorstack\@pdfcolorstack pop\relax}
 \fi
\else
 \ifxetex
   \edef\xintdoc@macrocode@pushcolor{\special{color push \foo}}
   \def\xintdoc@macrocode@popcolor{\special{color pop}}
 \else
   \ifnum\Withdvipdfmx=1
     \edef\xintdoc@macrocode@pushcolor{\special{color push \foo}}
     \def\xintdoc@macrocode@popcolor{\special{color pop}}
   \fi
 \fi
\fi
\AddToHook{env/macrocode/before}{\xintdoc@macrocode@pushcolor}
\AddToHook{env/macrocode/end}{\xintdoc@macrocode@popcolor}
% let's use some more quiet color for links inside the code
\AddToHook{env/macrocode/begin}{\hypersetup{linkcolor=macrocodelinktocodelinecolor}}
% let code line numbers really be fully in the margin
\MacroIndent\z@
% HACK OF \@sect
% ==============
% goal is to add labels but without having to modify currently
% existing mark-up in sources. But KOMA makes an extra step needed.
% 2018/06/11
%
% 2026/02/28 (KOMA 3.49) redefines \scr@sect, not \@sect.
\let\original@sect\scr@sect
\def\scr@sect#1#2#3#4#5#6[#7]#8{%
    \original@sect{#1}{#2}{#3}{#4}{#5}{#6}[{#7}]%
    {\begingroup
       % TODO: check if that 2018 comment is still valid:
       %not possible because of KOMA wrappers
       %\def\csh##1{\csa{##1}\label{\xintdoclabelprefix\detokenize{##1}}}%
       \let\csh\cshintitle
       \let\cshn\cshnintitle
       #8%
     \endgroup}%
}%
\def\cshintitle#1{\csa{#1}%
                  \label{\xintlabelprefix\detokenize{#1}}%
                  %\expandafter\DescribeMacro\csname#1\endcsname
                  }
% \csan: no backslash
\def\cshnintitle#1{\csan{#1}\label{\xintlabelprefix\detokenize{#1}}}
\def\storedlinecounts {}
\def\StoreCodelineNo #1{%
    \edef\storedlinecounts{\storedlinecounts
                           {{#1}{\the\c@CodelineNo}{\the\c@xintMacroCnt}}%
                          }%
    \global\c@CodelineNo   \z@
    \global\c@xintMacroCnt \z@
}
\def\FixInterMacrocodeVspace{%
  \def\par@beforemacrocode{\gdef\par@beforemacrocode{\par}}%
  \edef\xintdoc@macrocode@pushcolor{\xdef\noexpand\xintdoc@macrocode@pushcolor
                                                 {\xintdoc@macrocode@pushcolor}}%
  \def\macro@font{\ttfamily\unskip\unskip\unskip\unskip\unskip\unskip
                  \global\def\macro@font{\ttfamily}%
                  \xintdoc@macrocode@pushcolor % ai hésité à le mettre au début de \@item
  }%
  \let\saved@@item\@item
  \def\@item[##1]{\let\saved@addpenalty\addpenalty
                  \let\addpenalty\@gobble
                  \saved@@item[{##1}]%
                  \let\addpenalty\saved@addpenalty
                  \global\let\@item\saved@@item}%
  }%

% This is obsolete it is when I was issueing at top level a \color not black.
% This is executed in a group
%\renewcommand\etocbeforetitlehook{\normalcolor}

% lverb environment (formerly \lverb|...|)
% =================
%
% This started as "long \verb" with same syntax, to be used in the code
% comments and spare endless hassle of adding mark-up for verbatim stuff.  It
% also used \MicroFont like the custom \verb mainly used in user manual but
% also in xintsource for parts written "normally" (but using anyhow monospace
% font with variable space and hyphenation) which use |...| mark-up.
%
% It was turned into an environment June 3, 2022 (1.4m) and a mechanism with
% active backslash was added to identify control sequence names and add
% hyperlinks if available (labels are autogenerated from sectioning headings).
%
% lverb is a verbatim environment with free flowing of whitespace.
% It MUST be used with % characters at start of lines:
%
%\begin{lverb}
% all lines start with % and preferably with %<space>
%\end{lverb}
%
% There must not be a space between % and \end{lverb}
%
% Inside the environment:
% - % is active and must be exclusively located at start of lines

% - \ is active and identifies control sequence names, with the _, :, ^, ?,
%   and @ as letters.  The \ should not follow immediately the %, except for
%   the end of the environment %\end{lverb}
%
%   It would arguably be better to have used specific mark-up in source but
%   * then we need some way to have catcode 1 and 2 characters
%   * well, I added no mark-up.  I could spend one hour
%     TeX-programming to reconstruct the source with mark-up
%     but...
% - $ is a catcode 0 escape
% - space and end of lines are normal, text flows normally and uses the
%   newtxttz font currently
% - & serves as comment character
% - (, :, and ) serve to enter, continue, and exit a sub-mode which does obey
%   spaces and lines. One can use & at end of a line to let it flow with the
%   next one if desired.  They must immediately follow the % at start of line.
% - A dash after the % (%-) inserts a \par
% - also the * is active via \makestarlowast Apart from %, \, $, and & special
%   characters are like in verbatim.  So a macro \oneargcs is defined if one
%   needs an escape for a macro with one parameter:
\catcode`_ 11
\def\oneargcs{\catcode`{1\catcode`}2 \onearg_cs}
\def\onearg_cs#1#2{#1{#2}\catcode`{12\catcode`}12\relax}
% This \oneargcs is to be used as $oneargcs$<cs name>{<arg>}
{\catcode32\active%
\gdef\myobeyspaces{\catcode32\active\def {\leavevmode\kern\fontcharwd\font`X}}}
%
% Let \ fetch control sequences names in lverb environments.
% For this the characters _, ^, : and ? are considered letters.
% \XINT_sptoken is defined in xinttools which is loaded here
%               even if only typesetting xintsource.pdf
% \xint_dothis/\xint_orthat in xintkernel loaded by xinttools
\def\lverbbackslash{\bgroup\toks@{}\futurelet\lverb_token\lverb_bs}%
\def\lverb_bs{%
  \ifx\lverb_token\XINT_sptoken\xint_dothis{\lverb_bs_end}\fi
  % \ifx\lverb_token\lverbpercent should never happen
  \ifcat\noexpand\lverb_token\relax\xint_dothis{\lverb_bs_end}\fi
  \ifcat\lverb_token a\xint_dothis{\lverb_bs_i}\fi
  \if\lverb_token _\xint_dothis{\lverb_bs_i}\fi
  \if\lverb_token ^\xint_dothis{\lverb_bs_i}\fi
% TODO quel mark-up pour autoriser : and ? sans espace pour ponctuation
% TODO anglo-saxonne ?
% A bit cumbersome but $null or $empty can be used if : is used for
% punctuation and not as last letter of a cs, such as \foo$empty:
% I checked all instances with : and ? as last character found
% by this and added $empty in sources (June 3, 2022).
  \if\lverb_token :\xint_dothis{\lverb_bs_i}\fi
  \if\lverb_token ?\xint_dothis{\lverb_bs_i}\fi
  \xint_orthat{\lverb_bs_end}%
}%
\def\lverb_bs_i#1{\toks@\expandafter{\the\toks@#1}\futurelet\lverb_token\lverb_bs}%
\def\lverb_bs_end{\expandafter\lverbcs\expandafter{\the\toks@}\egroup}%
\let\lverbcs\cs

% The % is active in the environment
% Some complications to change color of private lines and then restore
% (the ^^M is not active), so we split into two steps _a and _b
\newif\ifprivatecolorison
\def\lverbpercent {\catcode32\active\lverbpercent_a}%
\def\lverbpercent_a #1{%
  \if\XINT_sptoken\detokenize{#1}\xint_dothis{%
     \catcode32 10 
     \ifprivatecolorison\xintdocPublicColorCmd\fi
     \privatecolorisonfalse
  }\fi
% The %! mark-up is used for private things which are trimmed by the
% build-script out of the dtx.
  \if!\detokenize{#1}\xint_dothis{%
      \ifprivatecolorison
      \else
           \xintdocPrivateColorCmd
           \privatecolorisontrue
      \fi
      \lverbpercent_b
  }\fi
  \xint_orthat{\lverbpercent_b{#1}}%
}%
\def\lverbpercent_b#1{%
  \if\XINT_sptoken\detokenize{#1}\xint_dothis{\catcode32 10 }\fi
% Special mark-up after % to control linewrap
% %- says to start a new paragraph
  \if-\detokenize{#1}\xint_dothis{\par #1}\fi
% %( start an obeylines+obeyspaces context
  \if(\detokenize{#1}\xint_dothis{\par\bgroup\myobeyspaces\obeylines}\fi
  \if:\detokenize{#1}\xint_dothis{}\fi
% I don't remember why this, it seems I want to kill next indentation
% after the obeylines context
  \if)\detokenize{#1}\xint_dothis{\egroup\everypar{\hskip-\parindent\everypar{}}}\fi
% Introduce a \par token if we have two empty commented-out lines
% Or if we have a % at the end of the input line
  \ifx#1\lverbpercent\xint_dothis{\catcode32 10 \par #1}\fi
% For tranformation of lverb into environment mark-up 2022/06/03
% The reason for the \detokenize{#1} upfront is that in original
% private sources there might a wrapper environment which has made
% the % alias to \lverbpercent already but not made the \ active
% and then %\begin{lverb} may be encountered with a
% catcode 0 backslash. If I did \if\@backslashchar\detokenize{#1}
% there would be trouble.  This test identifies %\end in a
% somewhat fragile way but by convention my mark-up will never
% have %\ except for %\end{lverb}
  \if\detokenize{#1}\@backslashchar\xint_dothis{\lverb@end}\fi
  \xint_orthat{\catcode32 10 #1}%
}
\catcode`_ 8
% \long\def\lverb
\def\lverb@end end#1lverb#2{\end{lverb}}
\newenvironment{lverb}
{%
  \sfcode`!=1000
  \relax\ifhanged\else\par\smallskip\fi
    \let\do\do@noligs  \verbatim@nolig@list
    \let\do\@makeother \dospecials
    \catcode32 10 \catcode`\& 14 \catcode`\$ 0
    \catcode`\% \active
    \begingroup\lccode`\~`\%\lowercase{\endgroup\let~\lverbpercent}%
    \catcode`\\ \active
    \begingroup\lccode`\~`\\\lowercase{\endgroup\let~\lverbbackslash}%
  \LverbFont
  \ignorespaces
}{\par}
% This \@lverb was used before conversion into an environment
% \def\@lverb #1{\catcode`#1\active
%                \lccode`\~`#1\lowercase{\def~}{\egroup\par}}%
\def\LverbFont {%
% pas concluant \itshape (June 3, 2022)
% pas concluant \bfseries
  %\xintdocPublicColorCmd
  \makestarlowast
}

% privatecodecomments
% ===================

% This is used in the xint*sty files (before being embedded in dtx)
% with %! lines.  Those lines are removed from public xint-calx.dtx before
% upload to CTAN.
\newenvironment{privatecodecomments}
   {\par \textbf{\textcolor{red}{COMMENTAIRES PRIVÉS.}}\par
    \makestarlowast
    \begingroup\lccode`\~`\%\lowercase{\endgroup\let~\lverbpercent}%
    \catcode`\%\active}
   {\par \textbf{\textcolor{red}{FIN DES COMMENTAIRES PRIVÉS.}}\par}

% \changed
% ========

% updated 2021/05/29 to use \xintreleasedate (always) and put
% second argument if non empty within square brackets.
% 2022/06/05 now says "Modified at", and does not display the optional
% argument, which contains actual date of the comment.
% I wonder if I should keep displaying release date.
% 2022/06/10 adds the \ifinchanged
\newif\ifhanged
\newcommand\changed[2][]{%
    \par\smallskip\noindent
    \textbf{Modified at #2\space(\xintreleasedate{#2})%\if\relax\detokenize{#1}\relax
                                                      %\else\space[commented #1]\fi
           .}%
    \hangindent\parindent
    \hangedtrue
% This is absolutely NOT robust.  By the way I added a hook to env/macrocode/before
% to do \par.
    \everypar\expandafter\expandafter\expandafter
            {\expandafter\the\expandafter\everypar
             \expandafter\everypar\expandafter{\the\everypar}%
             \hangedfalse}%
}

% \added
% ======
\newcommand\addedcalx[1]{\par Added at calx #1.}
% new 2022/05/16
\newcommand\added[2][]{%
    \par\smallskip\noindent
    \textbf{Added at #2\space(\xintreleasedate{#2})\if\relax\detokenize{#1}\relax
                     \else\space[on #1]\fi.}%
    \hangindent\parindent
    \hangedtrue
% This is absolutely NOT robust.  By the way I added a hook to env/macrocode/before
% to do \par.
    \everypar\expandafter\expandafter\expandafter
            {\expandafter\the\expandafter\everypar
             \expandafter\everypar\expandafter{\the\everypar}%
             \hangedfalse}%
}
% hoping the \hangedfalse will not accumulate

% \xintreleasedate
% ================

% added 2021/05/29
% xint-dates.txt is produced from CHANGES.md by grep via Makefile rule
% 1.09 (2013/09/23) aajouté manuellement car pas dans CHANGES.md
% (il y avait un bug "a stray underscore in a code line of xintexpr.sty must
%  be removed" et CTAN a annoncé seulement 1.09a)
%
\begingroup\endlinechar-1
\catcode`\`=\active
\def`#1 (#2)`{\expandafter\gdef\csname xintreleasedate_#1\endcsname{#2}}
`1.09 (2013/09/23)`% pas dans CHANGES.md car remplacé immédiatement par 1.09a
\@@input xint-dates.txt
\endgroup

\def\xintreleasedate#1{%
    \ifcsname xintreleasedate_#1\endcsname
       \csname xintreleasedate_#1\endcsname
    \else
       \immediate\write128{Pas de date pour #1 en ligne \the\inputlineno}%
       \error
    \fi
}

\expandafter\edef\csname xintreleasedate_\xintbndlversion\endcsname{\xintbndldate}

%% END OF MACRO DEFINITIONS FOR XINTSOURCE
\etocsettocstyle {\subsection* {Contents}
                 }
                 {}
% Hence, next will apply as well to the local tocs for the xintexpr, xinttrig,
% and xintlog parts which will be under the scope of \etocarticlestylenomarks.
% Memo: this is the sole place where we configure that hook.
\renewcommand\etocaftertitlehook{\etoctoccontentsline*{toctobookmark}{Contents}{2}}
\MakePercentIgnore
%\def\gardesactifs {^^A
%\catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11 }
%\def\gardesinactifs {^^A
%\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12 }
%\gardesactifs
%\let</dtx>\relax
%\let<*xintkernel>\gardesinactifs
%</dtx>^^A--------------------------------------------------------
%<*xintkernel>^^A-------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname xintkernelnameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section {Package \xintkernelnameimp implementation}
% \RaisedLabel{sec:kernelimp}
%
% \localtableofcontents
%
% \subsection{Introduction}
%
% This package provides the common minimal code base for loading management
% and catcode control and also a few programming utilities. With |1.2| a few
% more helper macros and all |\chardef|'s have been moved here. The package is
% loaded by both |xintcore.sty| and |xinttools.sty| hence by all other
% packages.
%
% \changed{1.1}
% Separated package.
%
% \changed{1.2i}
% \csbxint{replicate}, \csbxint{gobble}, \csbxint{LengthUpTo}
% and \csbxint{LastItem}, and faster \csbxint{Length}.
%
% \changed{1.3b}
% \csbxint{UniformDeviate}.
%
% \changed[2020/01/11]{1.4}
% \csbxint{Replicate}, \csbxint{Gobble}, \csbxint{LastOne}, \csbxint{FirstOne}.
%
% \changed{1.4l}
% Fix the |1.4| added bug that |\XINTrestorecatcodes| forgot to restore
% the catcode of |^||^A| which is set to |3| by |\XINTsetcatcodes|.
%
% \changed{1.4m}
% Fix incompatibility under \eTeX{} with \ctanpackage{miniltx}, if latter was
% loaded before \xintexprnameimp.  The fix happens here because it relates to
% matters of |\ProvidesPackage|.
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
% The code for reload detection was initially copied from \textsc{Heiko
% Oberdiek}'s packages, then modified.
%
% The method for catcodes was also initially directly inspired by these
% packages.
%
%\begin{lverb}
% 1.4l replaces Info level user messages issued in case of problems
% such as \numexpr not being available with Warning level messages (in the
% LaTeX terminolgy).  Should arguably be Error level in that case.
%
% xintkernel.sty was the only xint package emitting such an Info, now Warning
% in case of being loaded twice (via \input in non-LaTeX).  This was probably
% a left-over from initial development stage of the loading architecture for
% debugging.  Starting with 1.4l, it will abort input silently in such case.
%
% Also at 1.4l I refactored a bit the loading code in the xint*sty files for
% no real reason other than losing time.
%\end{lverb}
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \def\space{ }\newlinechar10
  \let\z\relax
  \expandafter\ifx\csname numexpr\endcsname\relax
    \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax
      \immediate\write128{^^JPackage xintkernel Warning:^^J%
                          \space\space\space\space
                          \numexpr not available, aborting input.^^J}%
    \else
      \PackageWarningNoLine{xintkernel}{\numexpr not available, aborting input}%
    \fi
    \def\z{\endgroup\endinput}%
  \else
    \expandafter\ifx\csname XINTsetupcatcodes\endcsname\relax
    \else
       \def\z{\endgroup\endinput}%
    \fi
  \fi
  \ifx\z\relax\else\expandafter\z\fi%
%    \end{macrocode}
% \subsubsection{\csh{XINTrestorecatcodes}, \csh{XINTsetcatcodes},
%                \csh{XINTrestorecatcodesendinput}}
% \changed{1.4e}
%\begin{lverb}
% Renamed \XINT{set,restore}catcodes
% to be without underscores, to facilitate the reloading process
% for xintlog.sty and xinttrig.sty in uncontrolled contexts.
%\end{lverb}
% \changed{1.4l}
%\begin{lverb}
% Fix the 1.4 bug of omission of \catcode1 restore.
%
% Reordered all catcodes assignements for easier maintenance and dropped most
% disparate indications of which packages make use of which settings.
%
% The \XINTrestorecatcodes is somewhat misnamed as it is more a template
% to be used in an \edef to help define actual catcode restoring macros.
%
% However \edef needs usually { and } so there is a potential difficulty with
% telling people to do \edef\myrestore{\XINTrestorecatcodes}, and I almost
% added at 1.4l some \XINTsettorestore$empty:#1->\edef#1{\XINTrestorecatcodes} but
% well, this is not public interface anyhow.  The reloading method of
% xintlog.sty and xinttrig.sty does protect itself though against such irreal
% usage possibility with non standard { or }.
%
% Removed at 1.4l the \XINT_setcatcodes and \XINT_restorecatcodes not used
% anywhere now.  Used by old version of xintsession.tex, but not anymore since
% a while.
%\end{lverb}
% \changed{1.4n}
% Compatibility with Op\TeX. It has a cactode 11 letter, but \cs{abc_} or
% \cs{abc_d} will be interpreted un expectedly (but not \cs{abc_de}).  So we
% must make sure this is deactivated during the whole duration of loading the
% \xintnameimp modules (perhaps it is mainly \xinttoolsnameimp which uses
% \cs{XINT_x}, \cs{XINT_y}, which is problematic).
%
% We need catcode letter |_| for tokenization of \cs{PrepareCatcodes} to let
% it define \csbXINT{restorecatcodes} conveniently for its usage in an
% \cs{edef} to query at that time the |_| status in Op\TeX.
%    \begin{macrocode}
  \catcode95=11 % _
  \def\PrepareCatcodes
  {%
      \endgroup
      \def\XINTrestorecatcodes
      {% prepared for use in \edef
          \catcode0=\the\catcode0     % ^^@
          \catcode1=\the\catcode1     % ^^A
          \catcode13=\the\catcode13   % ^^M
          \catcode32=\the\catcode32   % <space>
          \catcode33=\the\catcode33   % !
          \catcode34=\the\catcode34   % "
          \catcode35=\the\catcode35   % #
          \catcode36=\the\catcode36   % $
          \catcode38=\the\catcode38   % &
          \catcode39=\the\catcode39   % '
          \catcode40=\the\catcode40   % (
          \catcode41=\the\catcode41   % )
          \catcode42=\the\catcode42   % *
          \catcode43=\the\catcode43   % +
          \catcode44=\the\catcode44   % ,
          \catcode45=\the\catcode45   % -
          \catcode46=\the\catcode46   % .
          \catcode47=\the\catcode47   % /
          \catcode58=\the\catcode58   % :
          \catcode59=\the\catcode59   % ;
          \catcode60=\the\catcode60   % <
          \catcode61=\the\catcode61   % =
          \catcode62=\the\catcode62   % >
          \catcode63=\the\catcode63   % ?
          \catcode64=\the\catcode64   % @
          \catcode91=\the\catcode91   % [
          \catcode93=\the\catcode93   % ]
          \catcode94=\the\catcode94   % ^
          \catcode95=\the\catcode95   % _
          \catcode96=\the\catcode96   % `
          \catcode123=\the\catcode123 % {
          \catcode124=\the\catcode124 % |
          \catcode125=\the\catcode125 % }
          \catcode126=\the\catcode126 % ~
          \endlinechar=\the\endlinechar\relax
          \ifdefined\_ifmathsb\_ifmathsb\noexpand\_mathsbon\_fi\fi %
      }%
%    \end{macrocode}
%\begin{lverb}
% The \noexpand here before \endinput is required.  This feels to me a bit
% surprising, but is a fact, and the source of this must be in the \edef
% implementation but I have not checked it out at this time.
%\end{lverb}
%
% \changed{1.4n}
% Compatibility with Op\TeX.
%    \begin{macrocode}
      \edef\XINTrestorecatcodesendinput
      {%
           \XINTrestorecatcodes\noexpand\endinput %
      }%
      \def\XINTsetcatcodes
      {% standard settings with a few xint*sty specific ones
          \catcode0=12    % for \romannumeral`&&@
          \catcode1=3     % for safe separator &&A
          \catcode13=5    % ^^M
          \catcode32=10   % <space>
          \catcode33=12   % ! but used as LETTER inside xintexpr.sty
          \catcode34=12   % "
          \catcode35=6    % #
          \catcode36=3    % $
          \catcode38=7    % & SUPERSCRIPT for && as replacement of ^^
          \catcode39=12   % '
          \catcode40=12   % (
          \catcode41=12   % )
          \catcode42=12   % *
          \catcode43=12   % +
          \catcode44=12   % ,
          \catcode45=12   % -
          \catcode46=12   % .
          \catcode47=12   % /
          \catcode58=11   % : LETTER
          \catcode59=12   % ;
          \catcode60=12   % <
          \catcode61=12   % =
          \catcode62=12   % >
          \catcode63=11   % ? LETTER
          \catcode64=11   % @ LETTER
          \catcode91=12   % [
          \catcode93=12   % ]
          \catcode94=11   % ^ LETTER
          \catcode95=11   % _ LETTER
          \catcode96=12   % `
          \catcode123=1   % {
          \catcode124=12  % |
          \catcode125=2   % }
          \catcode126=3   % ~ MATH SHIFT
          \endlinechar=13 %
          \ifdefined\_mathsboff\_mathsboff\fi % Compatibility with OpTeX
      }%
      \XINTsetcatcodes
  }%
\PrepareCatcodes
%    \end{macrocode}
% Other modules could possibly be loaded under a different catcode regime.
% (or with a different status of |_| under Op\TeX).
%    \begin{macrocode}
\def\XINTsetupcatcodes {% for use by other modules
      \edef\XINTrestorecatcodesendinput
      {%
           \XINTrestorecatcodes\noexpand\endinput %
      }%
      \XINTsetcatcodes
}%
%    \end{macrocode}
% \subsection{Package identification}
%
% Inspired from \textsc{Heiko Oberdiek}'s packages.%
% \changed{1.09b}
% Re-usability in the other modules.  Also I assume now that if |\ProvidesPackage|
% exists it then does define |\ver@<pkgname>.sty|, code of |HO| for some reason
% escaping me  (compatibility with LaTeX 2.09 or other things ??) seems to set
% extra precautions. [nine years later I understood my mistake, see below].
%
% \changed{1.09c}
% Usage of \eTeX{} |\ifdefined|.
%
% \changed[2022/06/09]{1.4m}
% Nine years too late, I understand that the |HO| \myenquote{extra
% precautions} were there for some respectable reasons including
% |etex+miniltx| and surely other things I can not imagine.  So let's now make
% sure |\ver@xintkernel.sty| and friends get defined on load, even if
% |\ProvidesPackage| exists!  However I remain careless in using |\ifdefined|
% which could be fooled if some previous macro file ended up testing for
% |\ProvidesPackage| in a way letting it to |\relax|.  I do not test for that.
% If I fixed that carelessness here I would have to fix it in other places
% where I use similarly |\ifdefined\RequirePackage| or
% |\ifdefined\PackageWarning| or whatever.
%    \begin{macrocode}
\ifdefined\ProvidesPackage
    \def\XINT_providespackage\ProvidesPackage#1[#2]{%
             \ProvidesPackage{#1}[{#2}]%
             \expandafter\ifx\csname ver@#1.sty\endcsname\relax
                   \expandafter\xdef\csname ver@#1.sty\endcsname{#2}%
                         \fi
        }%
\else
    \def\XINT_providespackage\ProvidesPackage#1[#2]{%
             \immediate\write-1{Package: #1 #2}%
             \expandafter\xdef\csname ver@#1.sty\endcsname{#2}%
        }%
\fi
\XINT_providespackage
\ProvidesPackage {xintkernel}%
  [2026/11/01 v2.0a1 Paraphernalia for the xint packages (JFB)]%
%    \end{macrocode}
% \subsection{Constants}
%    \begin{macrocode}
\chardef\xint_c_     0
\chardef\xint_c_i    1
\chardef\xint_c_ii   2
\chardef\xint_c_iii  3
\chardef\xint_c_iv   4
\chardef\xint_c_v    5
\chardef\xint_c_vi   6
\chardef\xint_c_vii  7
\chardef\xint_c_viii 8
\chardef\xint_c_ix     9
\chardef\xint_c_x     10
%\chardef\xint_c_xi   11
\chardef\xint_c_xii   12
\chardef\xint_c_xiv   14
\chardef\xint_c_xvi   16
\chardef\xint_c_xvii  17
\chardef\xint_c_xviii 18
\chardef\xint_c_xx    20
\chardef\xint_c_xxii  22
\chardef\xint_c_ii^v          32
\chardef\xint_c_ii^vi         64
%\chardef\xint_c_c           100
\chardef\xint_c_ii^vii       128
\mathchardef\xint_c_ii^viii  256
\mathchardef\xint_c_ii^ix    512
\mathchardef\xint_c_ii^xii  4096
%\mathchardef\xint_c_m      1000
%    \end{macrocode}
% Some of these usages of \cs{newcount} were in \xintcorenameimp or in
% \xintnameimp or in \xintbinhexnameimp possibly conditionally on whether
% (pdf)\cs{uniformdeviate} is available.  At |1.4n|, let's not bother with
% outdated restrictions of \TeX.
%
% \changed{1.4p} new naming scheme without |^| regarding higher powers of ten,
% for matters of easier interconnection with \ctanpackage{poormanlog}.
%    \begin{macrocode}
\ifdefined\m@ne\let\xint_c_mone\m@ne
          \else\csname newcount\endcsname\xint_c_mone \xint_c_mone -1 %
\fi
\mathchardef\xint_c_e_iv                                      10000
\newcount\xint_c_e_v             \xint_c_e_v                 100000
%\newcount\xint_c_e_vi            \xint_c_e_vi              1000000
%\newcount\xint_c_e_vii           \xint_c_e_vii            10000000
\newcount\xint_c_e_viii          \xint_c_e_viii           100000000
\newcount\xint_c_e_ix            \xint_c_e_ix            1000000000
\newcount\xint_c_e_viii_mone     \xint_c_e_viii_mone       99999999
\newcount\xint_c_nine_e_viii     \xint_c_nine_e_viii      900000000
\newcount\xint_c_xi_e_viii_mone  \xint_c_xi_e_viii_mone  1099999999
\newcount\xint_c_xii_e_viii      \xint_c_xii_e_viii      1200000000
%    \end{macrocode}
% \changed{1.4n}
% For some reason this next one used to be defined by \cs{newcount}
% but \cs{mathchardef} is ok.
%    \begin{macrocode}
\mathchardef\xint_c_ii^xiv                  16384 % "4000, 2**14
\newcount\xint_c_ii^xv     \xint_c_ii^xv    32768 % 2**15
\newcount\xint_c_ii^xvi    \xint_c_ii^xvi   65536 % 2**16
\newcount\xint_c_ii^xxi    \xint_c_ii^xxi 2097152 % "200000, 2**21
%    \end{macrocode}
% \subsection{Token management utilities}
% \added{1.2}
% Check if  \cs{empty} and \cs{space} have their standard meanings
% and raise a warning if not.
% \changed{1.4}
% Warn user if needed, and force then \cs{empty} and \cs{space} to have
% their standard meanings.  This will be triggered even if the sole
% difference is that they are \cs{long}.
% \changed{1.4n}
% The Warning used to be emitted only to the log file, make it go to
% console output as well.  But why do I spend time on such silly things.
%    \begin{macrocode}
\def\XINT_tmpa { }%
\ifx\XINT_tmpa\space\else
   \immediate\write128{Package xintkernel Warning:}%
   \immediate\write128{The \string\space\XINT_tmpa macro does not have its
     meaning as in Plain or LaTeX, but is:}%
   \immediate\write128{\XINT_tmpa\XINT_tmpa\XINT_tmpa\XINT_tmpa\meaning\space.}%
   \let\space\XINT_tmpa
   \immediate\write128{Forcing it to be the usual one. Fingers crossed.}%
\fi
\def\XINT_tmpa {}%
\ifx\XINT_tmpa\empty\else
   \immediate\write128{Package xintkernel Warning:}%
   \immediate\write128{The \string\empty\space macro does not have its
     meaning as in Plain or LaTeX, but is:}%
   \immediate\write128{\space\space\space\space\meaning\empty.}%
   \let\empty\XINT_tmpa
   \immediate\write128{Forcing it to be the usual one. Fingers crossed.}%
\fi
\let\XINT_tmpa\relax
\let\xint_gobble_\empty
\long\def\xint_gobble_i    #1{}%
\long\def\xint_gobble_ii   #1#2{}%
\long\def\xint_gobble_iii  #1#2#3{}%
\long\def\xint_gobble_iv   #1#2#3#4{}%
\long\def\xint_gobble_v    #1#2#3#4#5{}%
\long\def\xint_gobble_vi   #1#2#3#4#5#6{}%
\long\def\xint_gobble_vii  #1#2#3#4#5#6#7{}%
\long\def\xint_gobble_viii #1#2#3#4#5#6#7#8{}%
%    \end{macrocode}
% \changed{1.3b}
% Moved here |\xint_gobandstop_...| macros because this is handy for
% \csbxint{RandomDigits}.
%
% For legacy reasons most top level macros use |\romannumeral0| trigger.  This
% is stopped by a space token.  Later in the history of the package
% |\romanumeral`&&@| was used with |&| of catcode 7.  Also there are a few
% instances of |\romannumeral| ended by |\z@|. But |\romannumeral0| remains
% the publicly documented one, with CamelCase macros using it as prefix to
% lowercased macros.
%    \begin{macrocode}
\let\xint_gob_andstop_\space
\long\def\xint_gob_andstop_i    #1{ }%
\long\def\xint_gob_andstop_ii   #1#2{ }%
\long\def\xint_gob_andstop_iii  #1#2#3{ }%
\long\def\xint_gob_andstop_iv   #1#2#3#4{ }%
\long\def\xint_gob_andstop_v    #1#2#3#4#5{ }%
\long\def\xint_gob_andstop_vi   #1#2#3#4#5#6{ }%
\long\def\xint_gob_andstop_vii  #1#2#3#4#5#6#7{ }%
\long\def\xint_gob_andstop_viii #1#2#3#4#5#6#7#8{ }%
\let\xint_stop_aftergobble\xint_gob_andstop_i
\long\def\xint_firstofone  #1{#1}%
\long\def\xint_firstoftwo  #1#2{#1}%
\long\def\xint_secondoftwo #1#2{#2}%
\long\def\xint_stop_atfirstofone  #1{ #1}%
\long\def\xint_stop_atfirstoftwo  #1#2{ #1}%
\long\def\xint_stop_atsecondoftwo #1#2{ #2}%
\long\def\xint_exchangetwo_keepbraces    #1#2{{#2}{#1}}%
%    \end{macrocode}
% Moved here from \xintnameimp at |1.4n|.
%    \begin{macrocode}
\long\def\xint_firstofthree  #1#2#3{#1}%
\long\def\xint_secondofthree #1#2#3{#2}%
\long\def\xint_thirdofthree  #1#2#3{#3}%
\long\def\xint_stop_atfirstofthree  #1#2#3{ #1}%
\long\def\xint_stop_atsecondofthree #1#2#3{ #2}%
\long\def\xint_stop_atthirdofthree  #1#2#3{ #3}%
%    \end{macrocode}
% \subsection{``gob til'' macros and UD style fork}
%    \begin{macrocode}
\long\def\xint_gob_til_R #1\R {}%
\long\def\xint_gob_til_W #1\W {}%
\long\def\xint_gob_til_Z #1\Z {}%
\long\def\xint_gob_til_zero #10{}%
\long\def\xint_gob_til_one  #11{}%
\long\def\xint_gob_til_zeros_iii   #1000{}%
\long\def\xint_gob_til_zeros_iv    #10000{}%
\long\def\xint_gob_til_eightzeroes #100000000{}%
\long\def\xint_gob_til_dot    #1.{}%
\long\def\xint_gob_til_G     #1G{}%
\long\def\xint_gob_til_minus #1-{}%
\long\def\xint_UDzerominusfork #10-#2#3\krof {#2}%
\long\def\xint_UDzerofork       #10#2#3\krof {#2}%
\long\def\xint_UDsignfork       #1-#2#3\krof {#2}%
\long\def\xint_UDwfork         #1\W#2#3\krof {#2}%
\long\def\xint_UDXINTWfork     #1\XINT_W#2#3\krof {#2}%
\long\def\xint_UDzerosfork     #100#2#3\krof {#2}%
\long\def\xint_UDonezerofork   #110#2#3\krof {#2}%
\long\def\xint_UDsignsfork     #1--#2#3\krof {#2}%
\let\xint:\char
\long\def\xint_gob_til_xint:#1\xint:{}%
\long\def\xint_gob_til_^#1^{}%
\def\xint_bracedstopper{\xint:}%
\long\def\xint_gob_til_exclam #1!{}% This ! has catcode 12
\long\def\xint_gob_til_sc #1;{}%
%    \end{macrocode}
% \subsection{\csh{xint_afterfi}}
%    \begin{macrocode}
\long\def\xint_afterfi #1#2\fi {\fi #1}%
%    \end{macrocode}
% \subsection{\csh{xint_bye}, \csh{xint_Bye}}
% \changed{1.09}
% |\xint_bye|
% \changed{1.2i}
%^^A test de lverb
%\begin{lverb}
%  \xint_Bye for \xintDSRr and \xintRound. Also \xint_stop_afterbye.
%\end{lverb}
%    \begin{macrocode}
\long\def\xint_bye #1\xint_bye {}%
\long\def\xint_Bye #1\xint_bye {}%
\long\def\xint_stop_afterbye #1\xint_bye { }%
%    \end{macrocode}
% \subsection{\csh{xintdothis}, \csh{xintorthat}}
% \changed{1.1}
% \changed{1.2} Names without underscores.
%
% To be used this way: 
%\begin{lverb}
%( \if..\xint_dothis{..}\fi
%: \if..\xint_dothis{..}\fi
%: \if..\xint_dothis{..}\fi
%: ...more such...
%: \xint_orthat{...}
%)
%\end{lverb}
% Ancient testing indicated it is more efficient to list first the more
% improbable clauses.
%    \begin{macrocode}
\long\def\xint_dothis #1#2\xint_orthat #3{\fi #1}% 1.1
\let\xint_orthat \xint_firstofone
\long\def\xintdothis #1#2\xintorthat #3{\fi #1}%
\let\xintorthat \xint_firstofone
%    \end{macrocode}
% \subsection{\csh{xint_zapspaces}}
% \changed{1.1}
% This little (quite fragile in the normal sense i.e. non robust in the normal
% sense of programming lingua) utility zaps leading, intermediate, trailing,
% spaces in completely expanding context (|\edef|, |\csname...\endcsname|).
% \centeredline{Usage: |\xint_zapspaces foo<space>\xint_gobble_i|}
%
% Explanation: if there are leading spaces, then the first |#1| will be empty,
% and the first |#2| being undelimited will be stripped from all the remaining
% leading spaces, if there was more than one to start with. Of course
% brace-stripping may occur. And this iterates: each time a |#2| is removed,
% either we then have spaces and next |#1| will be empty, or we have no spaces
% and |#1| will end at the first space. Ultimately |#2| will be
% |\xint_gobble_i|.
%
% The
% |\zap@spaces| of LaTeX2e handles unexpectedly things such as
% \centeredline{|\zap@spaces 1 {22} 3 4 \@empty|} (spaces are not all
% removed). This does not happen with |\xint_zapspaces|.
%
% But for example |\foo{aa} {bb} {cc}| where |\foo| is a macro with three
% non-delimited arguments breaks expansion, as expansion of |\foo| will happen
% with |\xint_zapspaces| still around, and even if it wasn't it would have
% stripped the braces around |{bb}|, certainly breaking other things.
%
% Despite such obvious shortcomings it is enough for our purposes. It is
% currently used by \xintexprnameimp at various locations e.g. cleaning up
% optional argument of |\xintiexpr| and |\xintfloatexpr|; maybe in future
% internal usage will drop this in favour of a more robust utility.
%
% \changed{1.2e} |\xint_zapspaces_o|.
%
% \changed{1.2i} Made |\long|.
%
% ATTENTION THAT \xinttoolsnameimp HAS AN |\xintzapspaces| WHICH SHOULD NOT
% GET CONFUSED WITH THIS ONE.
%    \begin{macrocode}
\long\def\xint_zapspaces #1 #2{#1#2\xint_zapspaces }% 1.1
\long\def\xint_zapspaces_o #1{\expandafter\xint_zapspaces#1 \xint_gobble_i}%
%    \end{macrocode}
% \subsection{\csh{odef}, \csh{oodef}, \csh{fdef}}
% May be prefixed with |\global|. No parameter text.
%    \begin{macrocode}
\def\xintodef #1{\expandafter\def\expandafter#1\expandafter }%
\def\xintoodef #1{\expandafter\expandafter\expandafter\def
                  \expandafter\expandafter\expandafter#1%
                  \expandafter\expandafter\expandafter }%
\def\xintfdef #1#2%
    {\expandafter\def\expandafter#1\expandafter{\romannumeral`&&@#2}}%
\ifdefined\odef\else\let\odef\xintodef\fi
\ifdefined\oodef\else\let\oodef\xintoodef\fi
\ifdefined\fdef\else\let\fdef\xintfdef\fi
%    \end{macrocode}
% \subsection{\csh{xintMessage}, \csh{ifxintverbose}}
% \changed{1.2c} For use by \csbxint{defvar} and \csbxint{deffunc} of
% \xintexprnameimp.
%
% \changed{1.2e} Uses |\write128| rather than |\write16| for compatibility
% with future extended range of output streams, in Lua\TeX{} in particular.
%
% \changed{1.3e} Set the |\newlinechar|.
%    \begin{macrocode}
\edef\XINT_fourspaces{\space\space\space\space}%
\def\xintMessage #1#2#3{%
    \edef\XINT_newlinechar{\the\newlinechar}%
    \newlinechar10
    \immediate\write128{Package #1 #2: (on line \the\inputlineno)}%
    \immediate\write128{\XINT_fourspaces#3}%
    \newlinechar\XINT_newlinechar\space
}%
\newif\ifxintverbose
%    \end{macrocode}
% \subsection{\csh{ifxintglobaldefs}, \csh{XINT_global}}
% \changed{1.3c}
%    \begin{macrocode}
\newif\ifxintglobaldefs
\def\XINT_global{\ifxintglobaldefs\global\fi}%
%    \end{macrocode}
% \subsection{(WIP) Expandable error message}
% \changed[2017/07/26]{1.2l} But really belongs to next major release beyond |1.3|.
% Basically copied over from l3kernel code. Using |\ ! /| control sequence,
% which must be left undefined. |\xintError:| would be 6 letters more.
%
% \changed[2020/01/25]{1.4} Finally rather than |\ ! /| I use |\xint/|.
%
% \changed[2021/05/19]{1.4g} Rewrote to use not an undefined control
% sequence but trigger "Use of |\xint/| doesn't match its definition." message.
%
% \changed[2021/05/20]{1.4g} Things evolve fast and I switch to a third
% method which will exploit "Paragraph ended before |\foo| was complete" style
% error. See
% \centeredline{\url{https://github.com/latex3/latex3/issues/931#issuecomment-845367201}}
% However I can not fully exploit this because xint may be used with
% Plain etex which does not set |\newlinechar|. 
% I can only use a poorman version with no usage of |^^J|. Also
% \ctanpackage{xintsession} could use the |^^J|, maybe I will integrate it
% there.
%
% \def\xintsession{\ctanpackage{xintsession}}
%
%\begin{lverb}
% I. Explanations on 2021/05/19 and 2021/05/20 before final change
%
% First I tried out things with undefined control sequence such as
%(\       an error was reported by xint ... %
%)
% whose output produces a nice symmetrical display with no \, and with ... both
% on left and right but this reduces drastically the available
% space for the actual error context. No go. But see 2021/05/20 update below!
%
% Having replaced \xint/ by "\xint ", I next opted provisorily for "\Hit
% RET at ?" control sequence, despite it being quite longer. And then I
% thought about using "\ xint error", possibly with an included ^^J in the name,
% or in the context.
%
% I experimented with ^^J in the context.  But the context size is much
% constrained, and when \errorcontextlines is at its default value of 5 for
% etex, not -1 as done by LaTeX, having the info shifted to the right makes it
% actually more visible. (however I have now updated $xintsession$ to 0.2b which
% sets \errorcontextlines to 0)
%
% So I was finally back here to square one, apart from having replaced "\xint/"
% by the more longish "\ xint error", hesitating with "\xinterrupt"...
%
% Then I had the idea to replace the undefined control sequence method by a
% method with a macro \foo defined as \def\foo.{} but used as \foo<space> for
% example.  This gives something like this (the first line will be otherwise
% if engine is run with -file-line-error):
%( ! Use of \xint/ doesn't match its definition.
%: <argument> \xint/  
%:                     Ooops, looks like we are missing a ] (hit RET) 
%)
% \xint/<space> (where the space is the unexpected token, the definition
% expecting rather a full stop) makes for 7 characters
% to compare to \ xint error which had 12, so I gained back 5.
%
% Back to ^^J: I had overlooked that TeX in the first part of the error
% message will display \macro fully, so inserting ^^J in its name allows
% arbitrarily long expandable error messages... as pointed out by BLF in
% latex3/issues#931 as I read on the morning of 2021/05/20. This is very nice
% but requires to predefine control sequences for each message, and also the
% actual arguments #1, #2, ... values can appear only in the context.
%
% And the situation with ^^J is somewhat complicated:
% 
% $xintsession$ sets the \newlinechar to 10, but this is not the case with bare
% usage of xintexpr with etex.  And this matters.  To discuss ^^J we have to
% separate two locations:
%(- it appears in the control sequence name,
%:- or in the context (which itself has two parts)
%)
%
% 1) When in the context, what happens with ^^J is independent of the setting of
% \newlinechar, and with TeXLive pdflatex the ^^J will induce a linebreak, but
% with xelatex it must be used with option -8bit.
%
% $noindent2) When in the control sequence name the behaviour in log/terminal of ^^J is
% influenced by the setting of \newlinechar.  Although with pdflatex it will
% always induce a linebreak, the actual count of characters where TeX will
% forcefully break is influenced by whether ^^J is or not \newlinechar. And
% with xelatex if it is \newlinechar, it does not depend then if -8bit or not,
% but if not \newlinechar then it does and TeX forceful breaks also change
% as for pdflatex.
%
% So, the control sequence name trick can be used to obtain arbitrarily
% long messages, but the \newlinechar must be set.
%
% And in the context, we can try to insert some ^^J but this would need
% with xetex the -8bit option, and anyhow the context size is limited,
% and there is apparently no trick to get it larger.
%
% So, in view of all the above I decided not to use ^^J (rather $&$&J
% here) at all, whether here in the control sequence or the context or
% inserted in \XINT_signalcondition in the context!
%
% I also have a problem with usage from bnumexpr or polexpr for example,
% they would need their own to avoid perhaps displaying \xint/ or analogous.
%
% II. Finally I modified again the method (completely, and no more need for
% funny catcode 7 space as delimiter) as this allows a longer context message,
% starting at start of line, and which obeys ^^J if \newlinechar is set to
% it. It also allows to incorporate non-limited generic explanations as a
% postfix, with linebreaks if \newlinechar is known.
%
% But as $xintexprnameimp can be used with Plain+etex which does not set the
% \newlinechar, I can't use ^^J out of thee box.  I can in $xintsession.
% What I decided finally is to make a conditional definition here.
%
% In both cases I include the "hit RET" (how rather "hit <return>") in the
% control sequence name serving to both provide extra information and trigger
% the error from being defined short and finding a \par.
%
% The maximal size was increased from 48 characters (method with \xint/ being
% badly delimited), to now 55 characters (using "! xint error:<^^J or space>"
% as prefix to the message). Longer messages are truncated at 56 characters
% with an appended "\ETC.".
%
% As it is late on this 2021/05/20, and in order to not have to change all
% usages, I keep \XINT_signalcondition (in $xintcorenameimp) as a one argument
% macro for time being, so will not include a more specific module name.
%
% The \par token has a special role here, and can't be (I)nserted without
% damage, but who would want to insert it in an expandable computation
% anyhow... and I don't need it in my custom error messages for sure.
%
% On 2021/05/21 I add a test about \newlinechar at time of package loading,
% and make two distinct definitions: one using ^^J in the control sequence,
% the other not using it.
%
% The -file-line-error toggle makes it impossible to control if the
% line-break on first line will match next lines.  In the ^^J branch I insert
% "| " (no, finally "$ $ " with two spaces) at start of continuation lines.
% Also I preferred to ensure a good-looking first line break for the case it
% starts with a "!  Paragraph ended ..."  because a priori error messages will
% be read if -file-line-error was emitted only a fortiori (this toggle
% suggests some IDE launched TeX and probably -interaction=nonstopmode).
%
% I will perhaps make another definition in $xintsession$ (it currently loads
% xintexpr prior to having set the \newlinechar, so the no ^^J definition will
% be used, if nothing else is modified there).
%
% With some hesitation I do not insert a ^^J after "! xint error:", as
% Emacs/AucTeX will display only the first line prominently and then the rest
% (which is in file:line:error mode) in one block under "--- TeX said ---".  I
% use the ^^J only in the generic helper message embedded in the control
% sequence. The cases with or without \newlinechar being 10 diverge a bit, as
% in the latter case I had to ensure acceptable linebreaks at 79 chars, and I
% did that first and then had spent enough time on the matter not to add more
% to backport the latest ^^J style message.
%\end{lverb}
% \changed[2022/06/05]{1.4m}
% Shorten the error message.  I am always too verbose initially.
%
% \changed[2025/08/09]{1.4n}
% Let not use explicit \cs{par} token as delimiter, but implicit one
% from empty line.  This is for compatibility with Op\TeX.
% Indeed, I  observed that with Op\TeX, |{\foo\par}| wuth \cs{foo} being
% short reports an extra |}| rather than saying
% ``Paragraph ended before \cs{foo} was complete.''.
%    \begin{macrocode}
\ifnum\newlinechar=10
\expandafter\def\csname
xint<...> is done, but will resume:&&J \space
hit <return> at the ? prompt to try fixing the error above&&J \space
which has been encountered before expansion\endcsname
#1\xint:{}%
\def\XINT_expandableerror#1{%
\def\XINT_expandableerror##1{%
   \expandafter
   \XINT_expandableerrorcontinue
   #1! xint error: ##1%

}}\expandafter\XINT_expandableerror\csname
xint<...> is done, but will resume:&&J \space
hit <return> at the ? prompt to try fixing the error above&&J \space
which has been encountered before expansion\endcsname
\else
\expandafter\def\csname
xint<...> is done, but will resume: hit <return> at \space
the ? prompt to try fixing the error encountered before expansion\endcsname
#1\xint:{}%
\def\XINT_expandableerror#1{%
\def\XINT_expandableerror##1{%
   \expandafter
   \XINT_expandableerrorcontinue
   #1! xint error: ##1%

}}\expandafter\XINT_expandableerror\csname
xint<...> is done, but will resume: hit <return> at \space
the ? prompt to try fixing the error encountered before expansion\endcsname
\fi
\def\XINT_expandableerrorcontinue#1%

{#1}%
%    \end{macrocode}
% \subsection{\csh{xint_noxpd} (for \texttt{contex-mkxl} compatibility)}
% \added{1.4n}
%
% The \LaTeX3 code (in |l3names.dtx|) uses Con\TeX t's \cs{normalunexpanded}
% and \cs{normalexpanded} which appear to be available both in Mark~II and
% Mark~IV.  But I will not do any testing with earlier |context|, so here I
% shall assume the \cs{expanded} behaves as expected and I can use
% \cs{notexpanded} for \cs{unexpanded}.  This is abstracted into an alias
% \csbxint{_noxpd}.
%
% I don't know if there is mode of running |context| where the \cs{errhelp}
% tokens will be shown (trying |context --mkII| was not conclusive; by the way
% \cs{errmessage} in e-\TeX{} adds a full stop which is missing with
% |context|).
%
% About the \cs{let} primitive I am not sure it behaves fully as in other
% engines.
%
% Note that this uses \csbxint{Message} in case of old Con\TeX t so we had
% to have it defined first.
%    \begin{macrocode}
\let\xint_noxpd\unexpanded
\ifdefined\contextversion
  \let\xint_noxpd\notexpanded
  \ifdefined\notexpanded
  \else
    \xintMessage{xintkernel}{Error}{This ConTeXt appears to be too old.} 
    \errhelp{xint only supports the ConTeXt-LMTX as of 2025/09/05.}%
    \errmessage{The \noexpand\notexpanded primitive does not exist.}%
  \fi
\fi
%    \end{macrocode}
% \subsection{\csh{xintstrcmp}}
% \added[2022/06/05]{1.4m}
% For the \LuaTeX{} engine the code is copied over from |l3names.dtx|.  I also
% looked at Heiko Oberdiek's |pdftexcmds.sty| and |pdftexcmds.lua|, but I
% removed |\luaescapestring| and used |token.scan_string()| as seen in
% |l3names.dtx| (and I did try to inform myself about this in the \LuaTeX{}
% manual, with limited success).  I am not sure about the syntax below with the
% |local|'s.  Should I use |\directlua0|?  Testing was minimal.
% Memo: even with |pdftex|'s \cs{pdfstrcmp}, braces around the arguments
% are mandatory.
%    \begin{macrocode}
\ifdefined\strcmp\let\xintstrcmp\strcmp
\else\ifdefined\pdfstrcmp\let\xintstrcmp\pdfstrcmp
\else\ifdefined\directlua\directlua{%
xintkernel = xintkernel or {}
local minus_tok = token.new(string.byte'-', 12)
local zero_tok = token.new(string.byte'0', 12)
local one_tok = token.new(string.byte'1', 12)
function xintkernel.strcmp()
  local A = token.scan_string()
  local B = token.scan_string()
  if A < B then
    tex.write(minus_tok, one_tok)
  else
    tex.write(A == B and zero_tok or one_tok)
  end
end
}\def\xintstrcmp{%
  \directlua{xintkernel.strcmp()}%
}%
\else
\xintMessage{xintkernel}{Error}{Could not set-up \string\xintstrcmp.}%
\errhelp{What kind of format are you using? Perhaps write the author? Bye now}%
\errmessage{Sorry, could not find or define string comparison primitive}\fi\fi\fi
%    \end{macrocode}
% \subsection{\csh{xintresettimer}, \csh{xintelapsedtime}, \csh{xinttheseconds}}
% \added{1.4n}
% If |\resettimer| is defined, the code assumes
% |\elapsedtime| is, too.
%
% I completely forgot at |1.4n| release time to document these engine-agnostic
% utilities in the manual.  They were originally in the |xint.dtx| preamble,
% to allow testing a build of the documentation also with the Unicode engines
% (but the release is done with |latex+dvipdfmx|).  They are
% used only once there, for the example with |\xintUniformDeviate|.
%
% Perhaps I should for Lua\TeX{} copy the l3kernel code (here the code was
% picked from some |tex.sx| answer and was in my files for years) but I am not
% Lua-proficient enough to do this confidently... probably their |// 1| and
% |math.tointeger()| is more efficient than the |math.floor()| and there must
% be a reason why they use |gettimeofday()|, while |os.clock()| is only used
% to set the ``epoch''.
%
% I have been using for years the underlying syntax trick here for
% |\xinttheseconds|, and I usually never bother actually removing the catcode
% 12 |pt|, but well let's do it here.
%
% I hesitate whether with Lua\TeX{} I should avoid the scaled seconds
% intermediate in favor of the raw |os.clock()-basetime| data but I would have
% to waste time seeing what happens with |tex.write()| then.  And it would not
% help really in comparing with PDF\TeX{} or Xe\TeX{}.
%
% \changed{1.4o}
%
% |xinttimer| replaces here in the Lua code |xintelapsedtimer|, which was
% a silly name used when I adopted in a haste at |1.4n| while improving the user
% manual on \csbxint{UniformDeviate}.
%    \begin{macrocode}
\ifdefined\resettimer
  \let\xintresettimer\resettimer   \let\xintelapsedtime\elapsedtime
\else
\ifdefined\pdfresettimer
  \let\xintresettimer\pdfresettimer\let\xintelapsedtime\pdfelapsedtime
\else
\ifdefined\directlua
  \directlua{xinttimer_basetime=0}%
  \def\xintresettimer{\directlua{xinttimer_basetime = os.clock()}}%
  \def\xintelapsedtime{\numexpr
      \directlua{tex.print(math.floor((os.clock()-xinttimer_basetime)*65536+0.5))}%
  \relax}%
\fi\fi\fi
\def\xintstrippt{\expandafter\XINT_strippt\the}%
\expanded{\xint_noxpd{\def\XINT_strippt#1}\detokenize{pt}}{#1}%
\def\xinttheseconds{\xintstrippt\dimexpr\xintelapsedtime sp\relax}%
%    \end{macrocode}
% \subsection{\csh{xintReverseOrder}}
% \changed{1.0} Does not expand its argument. The whole of xint codebase now
% contains only two calls to |\XINT_rord_main| (in \xintgcdnameimp).
%
% Attention: removes brace pairs (and swallows spaces).
%
% For digit tokens a faster reverse macro is provided by (|1.2|)
% \csbxint{ReverseDigits} in \xintnameimp.
%
% For comma separated items, |1.2g| has \csbxint{CSVReverse} in
% \xinttoolsnameimp.
%    \begin{macrocode}
\def\xintReverseOrder {\romannumeral0\xintreverseorder }%
\long\def\xintreverseorder #1%
{%
    \XINT_rord_main {}#1%
      \xint:
        \xint_bye\xint_bye\xint_bye\xint_bye
        \xint_bye\xint_bye\xint_bye\xint_bye
      \xint:
}%
\long\def\XINT_rord_main #1#2#3#4#5#6#7#8#9%
{%
    \xint_bye #9\XINT_rord_cleanup\xint_bye
    \XINT_rord_main {#9#8#7#6#5#4#3#2#1}%
}%
\def\XINT_rord_cleanup #1{%
\long\def\XINT_rord_cleanup\xint_bye\XINT_rord_main ##1##2\xint:
{%
    \expandafter#1\xint_gob_til_xint: ##1%
}}\XINT_rord_cleanup { }%
%    \end{macrocode}
% \subsection{\csh{xintLength}}
% \changed{1.0} Does not expand its argument. See \csbxint{NthElt}|{0}| from
% \xinttoolsnameimp which f-expands its argument.
%
% \changed{1.2g} Added \csbxint{CSVLength} to \xinttoolsnameimp.
%
% \changed{1.2i} Rewrote this venerable macro. New code about 40\%
% faster across all lengths. Syntax with |\romannumeral0| adds some
% slight (negligible) overhead; it is done to fit some general
% principles of structure of the xint package macros but maybe
% at some point I should drop it. And in fact it is often called
% directly via the |\numexpr| access point. (bad coding...)
%
% Remark: the argument may contain \cs{par} tokens.  But generally
% speaking most other macros of the \xintnameimp bundle are not declared
% \cs{long}.  As \csbxint{Length} produces a numeric quantity it is
% conceivable that it could serve in the input of some of the
% \xintnameimp macros.  For example something such as
% |\xinteval{\xintLength{\par\par}^3}| or
% |\xintiiMul{\xintLength{\par\par\par}}{17}|.  They both fail.  I have
% known this issue for many years.  It is only needed to make long those
% macros which grab the argument and \fexpan d it.  After expansion, of
% course no \cs{par} tokens is admissible as numerical input.  Still
% this is quite some work due to size of the codebase.  Waiting for a
% real-life bug report... (\LaTeX3 people have fixed that on their side
% by making all declarations \cs{long} per default, and this may also
% perhaps increase slightly the efficiency, not checked).
%    \begin{macrocode}
\def\xintLength {\romannumeral0\xintlength }%
\def\xintlength #1{%
\long\def\xintlength ##1%
{%
    \expandafter#1\the\numexpr\XINT_length_loop
    ##1\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
       \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v
       \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye
    \relax
}}\xintlength{ }%
\long\def\XINT_length_loop #1#2#3#4#5#6#7#8#9%
{%
    \xint_gob_til_xint: #9\XINT_length_finish_a\xint:
    \xint_c_ix+\XINT_length_loop
}%
\def\XINT_length_finish_a\xint:\xint_c_ix+\XINT_length_loop
    #1#2#3#4#5#6#7#8#9%
{%
    #9\xint_bye
}%
%    \end{macrocode}
% \subsection{\csh{xintLastItem}}
% \changed[2016/12/10]{1.2i}
% One level
% of braces removed in output. Output empty if input empty. Attention! 
% This means
% that an empty input or an input ending with a {} empty brace pair
% both give same output.
%
% The |\xint:| token must not be among items. |\xintFirstItem| added
% at 1.4 for usage in xintexpr. It must contain neither |\xint:|
% nor |\xint_bye| in its first item.
%
%    \begin{macrocode}
\def\xintLastItem {\romannumeral0\xintlastitem }%
\long\def\xintlastitem #1%
{%
    \XINT_last_loop {}.#1%
    {\xint:\XINT_last_loop_enda}{\xint:\XINT_last_loop_endb}%
    {\xint:\XINT_last_loop_endc}{\xint:\XINT_last_loop_endd}%
    {\xint:\XINT_last_loop_ende}{\xint:\XINT_last_loop_endf}%
    {\xint:\XINT_last_loop_endg}{\xint:\XINT_last_loop_endh}\xint_bye
}%
\long\def\XINT_last_loop #1.#2#3#4#5#6#7#8#9%
{%
    \xint_gob_til_xint: #9%
        {#8}{#7}{#6}{#5}{#4}{#3}{#2}{#1}\xint:
    \XINT_last_loop {#9}.%
}%
\long\def\XINT_last_loop_enda #1#2\xint_bye{ #1}%
\long\def\XINT_last_loop_endb #1#2#3\xint_bye{ #2}%
\long\def\XINT_last_loop_endc #1#2#3#4\xint_bye{ #3}%
\long\def\XINT_last_loop_endd #1#2#3#4#5\xint_bye{ #4}%
\long\def\XINT_last_loop_ende #1#2#3#4#5#6\xint_bye{ #5}%
\long\def\XINT_last_loop_endf #1#2#3#4#5#6#7\xint_bye{ #6}%
\long\def\XINT_last_loop_endg #1#2#3#4#5#6#7#8\xint_bye{ #7}%
\long\def\XINT_last_loop_endh #1#2#3#4#5#6#7#8#9\xint_bye{ #8}%
%    \end{macrocode}
% \subsection{\csh{xintFirstItem}}
%\begin{lverb}
% 1.4. There must be neither \xint:
% nor \xint_bye in its first item.
%\end{lverb}
%    \begin{macrocode}
\def\xintFirstItem         {\romannumeral0\xintfirstitem }%
\long\def\xintfirstitem  #1{\XINT_firstitem #1{\xint:\XINT_firstitem_end}\xint_bye}%
\long\def\XINT_firstitem #1#2\xint_bye{\xint_gob_til_xint: #1\xint:\space #1}%
\def\XINT_firstitem_end\xint:{ }%
%    \end{macrocode}
% \subsection{\csh{xintLastOne}}
%\begin{lverb}
%
% As xintexpr 1.4 uses {c1}{c2}....{cN} storage when gathering comma separated
% values we need to not handle identically an empty list and a list with an
% empty item (as the above allows hierarchical structures). But \xintLastItem
% removed one level of brace pair so it is anadequate for the last() function.
%
% By the way it is logical to interpret «item» as meaning {cj} inclusive of
% the braces; but legacy xint user manual was not written in this spirit. And thus
% \xintLastItem did brace stripping, thus we need another name for maintaining
% backwards compatibility (although the cardinality of users is small).
%
% The \xint: token must not be found (visible) among the item contents.
%
%\end{lverb}
%    \begin{macrocode}
\def\xintLastOne {\romannumeral0\xintlastone }%
\long\def\xintlastone #1%
{%
    \XINT_lastone_loop {}.#1%
    {\xint:\XINT_lastone_loop_enda}{\xint:\XINT_lastone_loop_endb}%
    {\xint:\XINT_lastone_loop_endc}{\xint:\XINT_lastone_loop_endd}%
    {\xint:\XINT_lastone_loop_ende}{\xint:\XINT_lastone_loop_endf}%
    {\xint:\XINT_lastone_loop_endg}{\xint:\XINT_lastone_loop_endh}\xint_bye
}%
\long\def\XINT_lastone_loop #1.#2#3#4#5#6#7#8#9%
{%
    \xint_gob_til_xint: #9%
        {#8}{#7}{#6}{#5}{#4}{#3}{#2}{#1}\xint:
    \XINT_lastone_loop {{#9}}.%
}%
\long\def\XINT_lastone_loop_enda #1#2\xint_bye{{#1}}%
\long\def\XINT_lastone_loop_endb #1#2#3\xint_bye{{#2}}%
\long\def\XINT_lastone_loop_endc #1#2#3#4\xint_bye{{#3}}%
\long\def\XINT_lastone_loop_endd #1#2#3#4#5\xint_bye{{#4}}%
\long\def\XINT_lastone_loop_ende #1#2#3#4#5#6\xint_bye{{#5}}%
\long\def\XINT_lastone_loop_endf #1#2#3#4#5#6#7\xint_bye{{#6}}%
\long\def\XINT_lastone_loop_endg #1#2#3#4#5#6#7#8\xint_bye{{#7}}%
\long\def\XINT_lastone_loop_endh #1#2#3#4#5#6#7#8#9\xint_bye{ #8}%
%    \end{macrocode}
% \subsection{\csh{xintFirstOne}}
%\begin{lverb}
% For xintexpr 1.4 too. Jan 3, 2020.
%
% This is an experimental macro, don't use it. If input is nil (empty set) it
% expands to nil, if not it fetches first item and braces it. Fetching will
% have stripped one brace pair if item was braced to start with, which is
% the case in non-symbolic xintexpr data objects.
%
% I have not given much thought to this (make it shorter, allow all tokens,
% (we could first test if empty via combination with \detokenize), etc...)
% as I need to get xint 1.4 out soon. So in particular attention that
% the macro assumes the \xint: token is absent from first item of input.
%\end{lverb}
%    \begin{macrocode}
\def\xintFirstOne  {\romannumeral0\xintfirstone }%
\long\def\xintfirstone  #1{\XINT_firstone #1{\xint:\XINT_firstone_empty}\xint:}%
\long\def\XINT_firstone #1#2\xint:{\xint_gob_til_xint: #1\xint:{#1}}%
\def\XINT_firstone_empty\xint:#1{ }%
%    \end{macrocode}
% \subsection{\csh{xintLengthUpTo}}
% \changed{1.2i} For use by \csbxint{Keep} and \csbxint{Trim}
% (\xinttoolsnameimp). The argument N **must be non-negative**.
%
% |\xintLengthUpTo{N}{List}| produces |-0| if length(List)>N, else it returns
% N-length(List). Hence subtracting it from N always computes min(N,length(List)).
% \changed{1.2j} Changed ending and interface to core loop.
%    \begin{macrocode}
\def\xintLengthUpTo {\romannumeral0\xintlengthupto}%
\long\def\xintlengthupto #1#2%
{%
    \expandafter\XINT_lengthupto_loop
    \the\numexpr#1.#2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
         \xint_c_vii\xint_c_vi\xint_c_v\xint_c_iv
         \xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye.%
}%
\def\XINT_lengthupto_loop_a #1%
{%
    \xint_UDsignfork
      #1\XINT_lengthupto_gt
      -\XINT_lengthupto_loop
    \krof #1%
}%
\long\def\XINT_lengthupto_gt #1\xint_bye.{-0}%
\long\def\XINT_lengthupto_loop #1.#2#3#4#5#6#7#8#9%
{%
    \xint_gob_til_xint: #9\XINT_lengthupto_finish_a\xint:%
    \expandafter\XINT_lengthupto_loop_a\the\numexpr #1-\xint_c_viii.%
}%
\def\XINT_lengthupto_finish_a\xint:\expandafter\XINT_lengthupto_loop_a
    \the\numexpr #1-\xint_c_viii.#2#3#4#5#6#7#8#9%
{%
    \expandafter\XINT_lengthupto_finish_b\the\numexpr #1-#9\xint_bye
}%
\def\XINT_lengthupto_finish_b #1#2.%
{%
    \xint_UDsignfork
       #1{-0}%
        -{ #1#2}%
    \krof
}%
%    \end{macrocode}
% \subsection{\csh{xintreplicate}, \csh{xintReplicate}}
% \changed{1.2i}
% This is cloned from LaTeX3's |\prg_replicate:nn|, see Joseph's post
% at
% \centeredline{http://tex.stackexchange.com/questions/16189/repeat-command-n-times}
% I
% posted there an alternative not using the chained |\csname|'s but it is a bit
% less efficient (except perhaps for thousands of repetitions).
% The code in Joseph's post does |abs(#1)| replications when input |#1| is negative
% and then activates an error triggering macro; here we simply do nothing when
% |#1| is negative.
% \centeredline{Usage: |\romannumeral\xintreplicate{N}{stuff}|}
%
% When |N| is already explicit digits (even |N=0|, but non-negative) one can
% call the macro as 
% \centeredline{|\romannumeral\XINT_rep N\endcsname {foo}|}
% to skip the |\numexpr|.
%
% \changed[2020/01/11]{1.4}
% Added |\xintReplicate| ! The reason I did not before is that the prevailing
% habits in xint source code was to trigger with |\romannumeral0| not
% |\romannumeral| which is the lowercased named macros. Thus adding the
% camelcase one creates a couple |\xintReplicate/\xintreplicate| not obeying
% the general mold.
%    \begin{macrocode}
\def\xintReplicate{\romannumeral\xintreplicate}%
\def\xintreplicate#1%
   {\expandafter\XINT_replicate\the\numexpr#1\endcsname}%
\def\XINT_replicate #1{\xint_UDsignfork
                         #1\XINT_rep_neg
                          -\XINT_rep
                       \krof #1}%
\long\def\XINT_rep_neg #1\endcsname #2{\xint_c_}%
\def\XINT_rep   #1{\csname XINT_rep_f#1\XINT_rep_a}%
\def\XINT_rep_a #1{\csname XINT_rep_#1\XINT_rep_a}%
\def\XINT_rep_\XINT_rep_a{\endcsname}%
\long\expandafter\def\csname XINT_rep_0\endcsname #1%
    {\endcsname{#1#1#1#1#1#1#1#1#1#1}}%
\long\expandafter\def\csname XINT_rep_1\endcsname #1%
    {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1}%
\long\expandafter\def\csname XINT_rep_2\endcsname #1%
    {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1}%
\long\expandafter\def\csname XINT_rep_3\endcsname #1%
    {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1}%
\long\expandafter\def\csname XINT_rep_4\endcsname #1%
    {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1}%
\long\expandafter\def\csname XINT_rep_5\endcsname #1%
    {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1}%
\long\expandafter\def\csname XINT_rep_6\endcsname #1%
    {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1#1}%
\long\expandafter\def\csname XINT_rep_7\endcsname #1%
    {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1#1#1}%
\long\expandafter\def\csname XINT_rep_8\endcsname #1%
    {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1#1#1#1}%
\long\expandafter\def\csname XINT_rep_9\endcsname #1%
    {\endcsname{#1#1#1#1#1#1#1#1#1#1}#1#1#1#1#1#1#1#1#1}%
\long\expandafter\def\csname XINT_rep_f0\endcsname #1%
    {\xint_c_}%
\long\expandafter\def\csname XINT_rep_f1\endcsname #1%
    {\xint_c_ #1}%
\long\expandafter\def\csname XINT_rep_f2\endcsname #1%
    {\xint_c_ #1#1}%
\long\expandafter\def\csname XINT_rep_f3\endcsname #1%
    {\xint_c_ #1#1#1}%
\long\expandafter\def\csname XINT_rep_f4\endcsname #1%
    {\xint_c_ #1#1#1#1}%
\long\expandafter\def\csname XINT_rep_f5\endcsname #1%
    {\xint_c_ #1#1#1#1#1}%
\long\expandafter\def\csname XINT_rep_f6\endcsname #1%
    {\xint_c_ #1#1#1#1#1#1}%
\long\expandafter\def\csname XINT_rep_f7\endcsname #1%
    {\xint_c_ #1#1#1#1#1#1#1}%
\long\expandafter\def\csname XINT_rep_f8\endcsname #1%
    {\xint_c_ #1#1#1#1#1#1#1#1}%
\long\expandafter\def\csname XINT_rep_f9\endcsname #1%
    {\xint_c_ #1#1#1#1#1#1#1#1#1}%
%    \end{macrocode}
% \subsection{\csh{xintgobble}, \csh{xintGobble}}
% \changed{1.2i}
% I hesitated about allowing as many as |9^6-1=531440| tokens to gobble, but
% |9^5-1=59058| is too low for playing with long decimal expansions.
% \centeredline{Usage: |\romannumeral\xintgobble{N}...|}
%
% \changed[2020/01/11]{1.4}
% Added |\xintGobble|.
%    \begin{macrocode}
\def\xintGobble{\romannumeral\xintgobble}%
\def\xintgobble #1%
   {\csname xint_c_\expandafter\XINT_gobble_a\the\numexpr#1.0}%
\def\XINT_gobble #1.{\csname xint_c_\XINT_gobble_a #1.0}%
\def\XINT_gobble_a #1{\xint_gob_til_zero#1\XINT_gobble_d0\XINT_gobble_b#1}%
\def\XINT_gobble_b #1.#2%
  {\expandafter\XINT_gobble_c
      \the\numexpr (#1+\xint_c_v)/\xint_c_ix-\xint_c_i\expandafter.%
      \the\numexpr #2+\xint_c_i.#1.}%
\def\XINT_gobble_c #1.#2.#3.%
  {\csname XINT_g#2\the\numexpr#3-\xint_c_ix*#1\relax\XINT_gobble_a #1.#2}%
\def\XINT_gobble_d0\XINT_gobble_b0.#1{\endcsname}%
\expandafter\let\csname XINT_g10\endcsname\endcsname
\long\expandafter\def\csname XINT_g11\endcsname#1{\endcsname}%
\long\expandafter\def\csname XINT_g12\endcsname#1#2{\endcsname}%
\long\expandafter\def\csname XINT_g13\endcsname#1#2#3{\endcsname}%
\long\expandafter\def\csname XINT_g14\endcsname#1#2#3#4{\endcsname}%
\long\expandafter\def\csname XINT_g15\endcsname#1#2#3#4#5{\endcsname}%
\long\expandafter\def\csname XINT_g16\endcsname#1#2#3#4#5#6{\endcsname}%
\long\expandafter\def\csname XINT_g17\endcsname#1#2#3#4#5#6#7{\endcsname}%
\long\expandafter\def\csname XINT_g18\endcsname#1#2#3#4#5#6#7#8{\endcsname}%
\expandafter\let\csname XINT_g20\endcsname\endcsname
\long\expandafter\def\csname XINT_g21\endcsname #1#2#3#4#5#6#7#8#9%
 {\endcsname}%
\long\expandafter\edef\csname XINT_g22\endcsname #1#2#3#4#5#6#7#8#9%
 {\expandafter\noexpand\csname XINT_g21\endcsname}%
\long\expandafter\edef\csname XINT_g23\endcsname #1#2#3#4#5#6#7#8#9%
 {\expandafter\noexpand\csname XINT_g22\endcsname}%
\long\expandafter\edef\csname XINT_g24\endcsname #1#2#3#4#5#6#7#8#9%
 {\expandafter\noexpand\csname XINT_g23\endcsname}%
\long\expandafter\edef\csname XINT_g25\endcsname #1#2#3#4#5#6#7#8#9%
 {\expandafter\noexpand\csname XINT_g24\endcsname}%
\long\expandafter\edef\csname XINT_g26\endcsname #1#2#3#4#5#6#7#8#9%
 {\expandafter\noexpand\csname XINT_g25\endcsname}%
\long\expandafter\edef\csname XINT_g27\endcsname #1#2#3#4#5#6#7#8#9%
 {\expandafter\noexpand\csname XINT_g26\endcsname}%
\long\expandafter\edef\csname XINT_g28\endcsname #1#2#3#4#5#6#7#8#9%
 {\expandafter\noexpand\csname XINT_g27\endcsname}%
\expandafter\let\csname XINT_g30\endcsname\endcsname
\long\expandafter\edef\csname XINT_g31\endcsname #1#2#3#4#5#6#7#8#9%
 {\expandafter\noexpand\csname XINT_g28\endcsname}%
\long\expandafter\edef\csname XINT_g32\endcsname #1#2#3#4#5#6#7#8#9%
 {\noexpand\csname XINT_g31\expandafter\noexpand\csname XINT_g28\endcsname}%
\long\expandafter\edef\csname XINT_g33\endcsname #1#2#3#4#5#6#7#8#9%
 {\noexpand\csname XINT_g32\expandafter\noexpand\csname XINT_g28\endcsname}%
\long\expandafter\edef\csname XINT_g34\endcsname #1#2#3#4#5#6#7#8#9%
 {\noexpand\csname XINT_g33\expandafter\noexpand\csname XINT_g28\endcsname}%
\long\expandafter\edef\csname XINT_g35\endcsname #1#2#3#4#5#6#7#8#9%
 {\noexpand\csname XINT_g34\expandafter\noexpand\csname XINT_g28\endcsname}%
\long\expandafter\edef\csname XINT_g36\endcsname #1#2#3#4#5#6#7#8#9%
 {\noexpand\csname XINT_g35\expandafter\noexpand\csname XINT_g28\endcsname}%
\long\expandafter\edef\csname XINT_g37\endcsname #1#2#3#4#5#6#7#8#9%
 {\noexpand\csname XINT_g36\expandafter\noexpand\csname XINT_g28\endcsname}%
\long\expandafter\edef\csname XINT_g38\endcsname #1#2#3#4#5#6#7#8#9%
 {\noexpand\csname XINT_g37\expandafter\noexpand\csname XINT_g28\endcsname}%
\expandafter\let\csname XINT_g40\endcsname\endcsname
\expandafter\edef\csname XINT_g41\endcsname
 {\noexpand\csname XINT_g38\expandafter\noexpand\csname XINT_g31\endcsname}%
\expandafter\edef\csname XINT_g42\endcsname
 {\noexpand\csname XINT_g41\expandafter\noexpand\csname XINT_g41\endcsname}%
\expandafter\edef\csname XINT_g43\endcsname
 {\noexpand\csname XINT_g42\expandafter\noexpand\csname XINT_g41\endcsname}%
\expandafter\edef\csname XINT_g44\endcsname
 {\noexpand\csname XINT_g43\expandafter\noexpand\csname XINT_g41\endcsname}%
\expandafter\edef\csname XINT_g45\endcsname
 {\noexpand\csname XINT_g44\expandafter\noexpand\csname XINT_g41\endcsname}%
\expandafter\edef\csname XINT_g46\endcsname
 {\noexpand\csname XINT_g45\expandafter\noexpand\csname XINT_g41\endcsname}%
\expandafter\edef\csname XINT_g47\endcsname
 {\noexpand\csname XINT_g46\expandafter\noexpand\csname XINT_g41\endcsname}%
\expandafter\edef\csname XINT_g48\endcsname
 {\noexpand\csname XINT_g47\expandafter\noexpand\csname XINT_g41\endcsname}%
\expandafter\let\csname XINT_g50\endcsname\endcsname
\expandafter\edef\csname XINT_g51\endcsname
 {\noexpand\csname XINT_g48\expandafter\noexpand\csname XINT_g41\endcsname}%
\expandafter\edef\csname XINT_g52\endcsname
 {\noexpand\csname XINT_g51\expandafter\noexpand\csname XINT_g51\endcsname}%
\expandafter\edef\csname XINT_g53\endcsname
 {\noexpand\csname XINT_g52\expandafter\noexpand\csname XINT_g51\endcsname}%
\expandafter\edef\csname XINT_g54\endcsname
 {\noexpand\csname XINT_g53\expandafter\noexpand\csname XINT_g51\endcsname}%
\expandafter\edef\csname XINT_g55\endcsname
 {\noexpand\csname XINT_g54\expandafter\noexpand\csname XINT_g51\endcsname}%
\expandafter\edef\csname XINT_g56\endcsname
 {\noexpand\csname XINT_g55\expandafter\noexpand\csname XINT_g51\endcsname}%
\expandafter\edef\csname XINT_g57\endcsname
 {\noexpand\csname XINT_g56\expandafter\noexpand\csname XINT_g51\endcsname}%
\expandafter\edef\csname XINT_g58\endcsname
 {\noexpand\csname XINT_g57\expandafter\noexpand\csname XINT_g51\endcsname}%
\expandafter\let\csname XINT_g60\endcsname\endcsname
\expandafter\edef\csname XINT_g61\endcsname
 {\noexpand\csname XINT_g58\expandafter\noexpand\csname XINT_g51\endcsname}%
\expandafter\edef\csname XINT_g62\endcsname
 {\noexpand\csname XINT_g61\expandafter\noexpand\csname XINT_g61\endcsname}%
\expandafter\edef\csname XINT_g63\endcsname
 {\noexpand\csname XINT_g62\expandafter\noexpand\csname XINT_g61\endcsname}%
\expandafter\edef\csname XINT_g64\endcsname
 {\noexpand\csname XINT_g63\expandafter\noexpand\csname XINT_g61\endcsname}%
\expandafter\edef\csname XINT_g65\endcsname
 {\noexpand\csname XINT_g64\expandafter\noexpand\csname XINT_g61\endcsname}%
\expandafter\edef\csname XINT_g66\endcsname
 {\noexpand\csname XINT_g65\expandafter\noexpand\csname XINT_g61\endcsname}%
\expandafter\edef\csname XINT_g67\endcsname
 {\noexpand\csname XINT_g66\expandafter\noexpand\csname XINT_g61\endcsname}%
\expandafter\edef\csname XINT_g68\endcsname
 {\noexpand\csname XINT_g67\expandafter\noexpand\csname XINT_g61\endcsname}%
%    \end{macrocode}
% \subsection{Random number generation}
% \added{1.3b}
%
% We provide a more random version of the (PDF)\TeX{} \cs{pdfuniformdeviate}.
% I discusses the worries with the engine primitive with Bruno Le Floch in
% May 2018.  Regarding |\pdfuniformdeviate x|:
%
% \begin{enumerate}
% \item with |x=2^{29}| or |x=2^{30}| the engine primitive produces only even
%   numbers,
% \item with |x=3*2^{26}| the integers produced by the RNG when taken modulo
%   three obey the proportion |1:1:2|, not |1:1:1|,
% \item with |x=3*2^{14}| there is analogous although weaker non-uniformity of
%   the random integers when taken modulo 3,
% \item generally speaking pure powers of two should generate uniform random
%   integers, but when the range is divisible by large powers of
%   two, the non-uniformity may be amplified in surprising ways by modulo
%   operations.
% \end{enumerate}
%
% Moreover, two seeds sharing the same low |k| bits generate sequences of
% 28-bits integers which are one-to-one identical modulo |2^k|!
% 
% In order to mitigate the issues commented upon in the user manual,
% \csbxint{UniformDeviate} currently only uses the
% seven high bits from the underlying random stream, using multiple calls to
% |\pdfuniformdeviate 128|. From the Birthday Effect, after about |2^{11}| seeds
% one will likely pick a new one sharing its 22 low bits with an earlier one.
%
% \begin{enumerate}
% \item but as the final random integer is obtained by additional operations
%   involving the range |x| (currently a modulo operation), for odd ranges it is
%   more difficult for bit correlations to be seen,
% \item anyway as they are only
% |2^{28}| seeds in total, after only |2^{14}| seeds it is likely to encounter
% one already explored, and then random integers are identical, however
% complicated the RNG's raw output is malaxed, and whatever the target range
% |x|. And |2^{14}| is only eight times as large as |2^{11}|.
% \end{enumerate}
%
% It would be nice if the engine provided some user interface for
%   letting its RNG execute a given number of iterations without the overhead
%   of replicated executions of |\pdfuniformdeviate|. This could help gain
%   entropy and would reduce correlations across series from distinct seeds.
%
% \changed{1.4n} Print a warning immediately if no uniformdeviate is available.
% \changed{1.4p} Do |s/\xint_undefined/\XINT_undefined/| for codebase coherence.
% \changed{1.4p} Rename |\xint_texuniformdeviate| into |\xinttexuniformdeviate|,
% so that it can be used in some examples of the user documentation.
% \subsubsection{\csh{xinttexuniformdeviate}}
% ATTENTION! with Con\TeX t, it will be redefined below as a \emph{macro with
% an argument}.  So one can NOT make code working both with the usual
% engines/formats and with Con\TeX t. The definition we will use with Con\TeX t
% is purely for our internal usage. Saying this because at |1.4p| the user
% manual shows some usages of this \csa{xinttexuniformdeviate}, \emph{but
% this is not a user level command for Con\TeX t usage}.
%    \begin{macrocode}
\ifdefined\pdfuniformdeviate  \let\xinttexuniformdeviate\pdfuniformdeviate\fi
\ifdefined\uniformdeviate     \let\xinttexuniformdeviate\uniformdeviate   \fi
\ifx\xinttexuniformdeviate\relax\let\xinttexuniformdeviate\XINT_undefined\fi
%    \end{macrocode}
% \subsubsection{\csh{xinttexuniformdeviate_dgts}}
%
% \added{1.4n} Needed for compatibility with Con\TeX t.
%
% One finds a macro \cs{randomnumber}
% (|/usr/local/texlive/2025/texmf-dist/tex/context/base/mkxl/supp-ran.mkxl|),
% which takes two arguments.  Fortunately it seems that throughout the
% \xintnameimp code base, we use \csbxint{texuniformdeviate} always with a
% chardef or count argument with one sole exception where it is followed with
% digits terminated by \cs{xint:}.  In order not to change anything to current
% code and to support Con\TeX t-LMTX we make here a suitable definition
% compatible with these use cases.
%
% \noindent Warning: I have no idea and will not check now if the RNG has the
% same issues for the less significant decimal digits as in PDFTeX, thus I
% don't know if the overhead in the definition below of \csbxint{UniformeDeviate}
% has any rationale in the LMTX context.
%
% MEMO: In the code below, I have not checked yet and do not remember (at time
% of preparing |1.4n|) if it is possible that the |#1| fetched by
% \csbxint{texuniformdeviate_dgts} has some chance to be zero (as I don't
% remember the details of the construction).  Attention that
% |\randomnumber{0}{-1}| may output |-1|.
%
% \changed{1.4o} Remove the test whether some uniformdeviate already
% exists with Con\TeX t and use unconditionally |\randomnumber| without
% checking if it exists.
%    \begin{macrocode}
\ifdefined\contextversion
  \def\xinttexuniformdeviate#1{\randomnumber{0}{#1-1}}%
  \def\xinttexuniformdeviate_dgts#1\xint:{\randomnumber{0}{#1-1}\xint:}%
\else
  \let\xinttexuniformdeviate_dgts\xinttexuniformdeviate
\fi
%    \end{macrocode}
% \subsubsection{\csh{xintUniformDeviate}}
% For negative |#1| the output (as per the doc I wrote in the user manual
% some years ago and that I trust) ranges from |#1+1| to zero inclusive.
% This is same behaviour as original primitive and the input must be
% within the \TeX{} bounds.  Note that |\the\numexpr-0\relax| gives |0|.
%
% We make 5 calls to the primitive and the user doc says that when I tested
% the cost was about 13 times the one of the primitive.
%    \begin{macrocode}
\ifdefined\xinttexuniformdeviate
     \expandafter\xint_firstoftwo
\else\expandafter\xint_secondoftwo
\fi
{%
  \def\xintUniformDeviate#1%
     {\the\numexpr\expandafter\XINT_uniformdeviate_sgnfork\the\numexpr#1\xint:}%
  \def\XINT_uniformdeviate_sgnfork#1%
  {%
     \if-#1\XINT_uniformdeviate_neg\fi \XINT_uniformdeviate{}#1%
  }%
  \def\XINT_uniformdeviate_neg\fi\XINT_uniformdeviate#1-%
  {%
      \fi-\numexpr\XINT_uniformdeviate\relax
  }%
  \def\XINT_uniformdeviate#1#2\xint:
  {%(
      \expandafter\XINT_uniformdeviate_a\the\numexpr%
                   -\xinttexuniformdeviate\xint_c_ii^vii%
                   -\xint_c_ii^vii*\xinttexuniformdeviate\xint_c_ii^vii%
                   -\xint_c_ii^xiv*\xinttexuniformdeviate\xint_c_ii^vii%
                   -\xint_c_ii^xxi*\xinttexuniformdeviate\xint_c_ii^vii%
                   +\xinttexuniformdeviate_dgts#2\xint:/#2)*#2\xint:+#2\fi\relax#1%
  }%
  \def\XINT_uniformdeviate_a #1\xint:
  {%
      \expandafter\XINT_uniformdeviate_b\the\numexpr#1-(#1%
  }%
  \def\XINT_uniformdeviate_b#1#2\xint:{#1#2\if-#1}%
}%
{%
  \xintMessage{xintkernel}{Warning}%
  {No \string\uniformdeviate like primitive identified, macros producing^^J%
  \XINT_fourspaces "random numbers" will raise (expandable) errors.}%
  \def\xintUniformDeviate#1%
  {%
      \the\numexpr
      \XINT_expandableerror{(xintkernel) No uniformdeviate primitive!}%
      0\relax
  }%
}%
%    \end{macrocode}
% \subsubsection{\csh{xintsetrandomseed}}
% \added{1.4p}
% This will remain undocumented at user level, apart from the fact thet some
% examples in the documentation use it.  Contrarily to the timing primitives,
% it seems \LuaTeX{} (even without \LaTeX{} format) has it, so we only need to
% alias it, idem with \XeTeX{} and Op\TeX{} (which even has it under the two
% names).  Regarding Con\TeX t, I do not have time to learn to use it and the
% following appears to work but anyhow its RNG seems to be some altogther
% different one than the \PDFTeX{} derived from \hologo{MetaPost} one.  And
% using |\count255| is surely bad, but well.
%    \begin{macrocode}
\ifdefined\contextversion
   \def\xintsetrandomseed{\afterassignment\XINT_ctx_setrandomseed
                          \count255 }%
   \def\XINT_ctx_setrandomseed{\ctxlua{math.randomseed(\the\count255)}}%
\else
\ifdefined\pdfsetrandomseed   \let\xintsetrandomseed\pdfsetrandomseed\fi
\ifdefined\setrandomseed      \let\xintsetrandomseed\setrandomseed\fi
\fi
\ifx\xintsetrandomseed\relax  \let\xintsetrandomseed\XINT_undefined\fi
\XINTrestorecatcodesendinput%
%    \end{macrocode}
% \StoreCodelineNo {xintkernel}
% \cleardoublepage\let\xintkernelnameUp\undefined
%\gardesactifs
%\let</xintkernel>\relax
%\let<*xinttools>\gardesinactifs
%</xintkernel>^^A-------------------------------------------------
%<*xinttools>^^A--------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname xinttoolsnameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section{Package \xinttoolsnameimp implementation}
% \RaisedLabel{sec:toolsimp}
%
% \localtableofcontents
%
% \subsection{Introduction}
%
% The package \xinttoolsnameimp loads only \xintkernelnameimp.
% There is one feature (\csbxint{rationals} syntax with \csbxint{For}) which
% requires the user to explicitly load \xintfracnameimp.
%
% Note that \xintexprnameimp loads automatically both o\xinttoolsnameimp and
% \xintfracnameimp.
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
% The code for reload detection was initially copied from \textsc{Heiko
% Oberdiek}'s packages, then modified.
%
% The method for catcodes was also initially directly inspired by these
% packages.
%
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode64=11   % @
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \def\empty{}\def\space{ }\newlinechar10
  \def\z{\endgroup}%
  \expandafter\let\expandafter\x\csname ver@xinttools.sty\endcsname
  \expandafter\let\expandafter\w\csname ver@xintkernel.sty\endcsname
  \expandafter\ifx\csname numexpr\endcsname\relax
    \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax
      \immediate\write128{^^JPackage xinttools Warning:^^J%
                          \space\space\space\space
                          \numexpr not available, aborting input.^^J}%
    \else
      \PackageWarningNoLine{xinttools}{\numexpr not available, aborting input}%
    \fi
    \def\z{\endgroup\endinput}%
  \else
    \ifx\x\relax   % plain-TeX, first loading of xinttools.sty
      \ifx\w\relax % but xintkernel.sty not yet loaded.
         \def\z{\endgroup\input xintkernel.sty\relax}%
      \fi
    \else
      \ifx\x\empty % LaTeX, first loading,
      % variable is initialized, but \ProvidesPackage not yet seen
          \ifx\w\relax % xintkernel.sty not yet loaded.
            \def\z{\endgroup\RequirePackage{xintkernel}}%
          \fi
      \else
        \def\z{\endgroup\endinput}% xinttools already loaded.
      \fi
    \fi
  \fi
\z%
\XINTsetupcatcodes% defined in xintkernel.sty
%    \end{macrocode}
% \subsection{Package identification}
%    \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xinttools}%
  [2026/11/01 v2.0a1 Expandable and non-expandable utilities (JFB)]%
%    \end{macrocode}
%\begin{lverb}
% \XINT_toks is used in macros such as \xintFor. It is not used
% elsewhere in the xint bundle.
%\end{lverb}
%    \begin{macrocode}
\newtoks\XINT_toks
\xint_firstofone{\let\XINT_sptoken= } %<- space here!
%    \end{macrocode}
% \subsection{\csh{xintgodef}, \csh{xintgoodef}, \csh{xintgfdef}}
% \added{1.09i} For use in |\xintAssign|.
%    \begin{macrocode}
\def\xintgodef  {\global\xintodef }%
\def\xintgoodef {\global\xintoodef }%
\def\xintgfdef  {\global\xintfdef }%
%    \end{macrocode}
% \subsection{\csh{xintRevWithBraces}}
% \added{1.06} Makes the expansion of its argument and then reverses
% the resulting tokens or braced tokens, adding a pair of braces to each (thus,
% maintaining it when it was already there.) The reason for
% |\xint:|, here and in other locations, is in case |#1| expands to nothing,
% the |\romannumeral-`0| must be stopped.
%    \begin{macrocode}
\def\xintRevWithBraces         {\romannumeral0\xintrevwithbraces }%
\def\xintRevWithBracesNoExpand {\romannumeral0\xintrevwithbracesnoexpand }%
\long\def\xintrevwithbraces #1%
{%
    \expandafter\XINT_revwbr_loop\expandafter{\expandafter}%
    \romannumeral`&&@#1\xint:\xint:\xint:\xint:%
                      \xint:\xint:\xint:\xint:\xint_bye
}%
\long\def\xintrevwithbracesnoexpand #1%
{%
    \XINT_revwbr_loop {}%
    #1\xint:\xint:\xint:\xint:%
      \xint:\xint:\xint:\xint:\xint_bye
}%
\long\def\XINT_revwbr_loop #1#2#3#4#5#6#7#8#9%
{%
    \xint_gob_til_xint: #9\XINT_revwbr_finish_a\xint:%
    \XINT_revwbr_loop {{#9}{#8}{#7}{#6}{#5}{#4}{#3}{#2}#1}%
}%
\long\def\XINT_revwbr_finish_a\xint:\XINT_revwbr_loop #1#2\xint_bye
{%
    \XINT_revwbr_finish_b #2\R\R\R\R\R\R\R\Z #1%
}%
\def\XINT_revwbr_finish_b #1#2#3#4#5#6#7#8\Z
{%
    \xint_gob_til_R
            #1\XINT_revwbr_finish_c \xint_gobble_viii
            #2\XINT_revwbr_finish_c \xint_gobble_vii
            #3\XINT_revwbr_finish_c \xint_gobble_vi
            #4\XINT_revwbr_finish_c \xint_gobble_v
            #5\XINT_revwbr_finish_c \xint_gobble_iv
            #6\XINT_revwbr_finish_c \xint_gobble_iii
            #7\XINT_revwbr_finish_c \xint_gobble_ii
            \R\XINT_revwbr_finish_c \xint_gobble_i\Z
}%
%    \end{macrocode}
%\begin{lverb}
% 1.1c revisited this old code and improved upon the earlier endings.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_revwbr_finish_c#1{%
\def\XINT_revwbr_finish_c##1##2\Z{\expandafter#1##1}%
}\XINT_revwbr_finish_c{ }%
%    \end{macrocode}
% \subsection{\csh{xintZapFirstSpaces}}
% \added[2013/11/01]{1.09f}
% \changed[2014/10/21]{1.1} To
% correct the bug in case of an empty argument, or argument containing only
% spaces, which had been forgotten in first version. New version is simpler than
% the initial one. This macro does NOT expand its argument.
%    \begin{macrocode}
\def\xintZapFirstSpaces {\romannumeral0\xintzapfirstspaces }%
\def\xintzapfirstspaces#1{\long
\def\xintzapfirstspaces ##1{\XINT_zapbsp_a #1##1\xint:#1#1\xint:}%
}\xintzapfirstspaces{ }%
%    \end{macrocode}
%\begin{lverb}
% If the original #1 started with a space, the grabbed #1 is empty. Thus
% _again? will see #1=\xint_bye, and hand over control to _again which will loop
% back into \XINT_zapbsp_a, with one initial space less. If the original #1 did
% not start with a space, or was empty, then the #1 below will be a <sptoken>,
% then an extract of the original #1, not empty and not starting with a space,
% which contains what was up to the first <sp><sp> present in original #1, or,
% if none preexisted, <sptoken> and all of #1 (possibly empty) plus an ending
% \xint:. The added initial space will stop later the \romannumeral0. No
% brace stripping is possible. Control is handed over to \XINT_zapbsp_b which
% strips out the ending \xint:<sp><sp>\xint:
%\end{lverb}
%    \begin{macrocode}
\def\XINT_zapbsp_a#1{\long\def\XINT_zapbsp_a ##1#1#1{%
  \XINT_zapbsp_again?##1\xint_bye\XINT_zapbsp_b ##1#1#1}%
}\XINT_zapbsp_a{ }%
\long\def\XINT_zapbsp_again? #1{\xint_bye #1\XINT_zapbsp_again }%
\xint_firstofone{\def\XINT_zapbsp_again\XINT_zapbsp_b} {\XINT_zapbsp_a }%
\long\def\XINT_zapbsp_b #1\xint:#2\xint:{#1}%
%    \end{macrocode}
% \subsection{\csh{xintZapLastSpaces}}
% \added[2013/11/01]{1.09f}
%    \begin{macrocode}
\def\xintZapLastSpaces {\romannumeral0\xintzaplastspaces }%
\def\xintzaplastspaces#1{\long
\def\xintzaplastspaces ##1{\XINT_zapesp_a {}\empty##1#1#1\xint_bye\xint:}%
}\xintzaplastspaces{ }%
%    \end{macrocode}
%\begin{lverb}
% The \empty from \xintzaplastspaces is to prevent brace removal in the
% #2 below. The \expandafter chain removes it.
%\end{lverb}
%    \begin{macrocode}
\xint_firstofone {\long\def\XINT_zapesp_a #1#2 } %<- second space here
    {\expandafter\XINT_zapesp_b\expandafter{#2}{#1}}%
%    \end{macrocode}
%\begin{lverb}
% Notice again an \empty added here. This is in preparation for possibly looping
% back to \XINT_zapesp_a. If the initial #1 had no <sp><sp>, the stuff however
% will not loop, because #3 will already be <some spaces>\xint_bye. Notice
% that this macro fetches all way to the ending \xint:. This looks not
% very efficient, but how often do we have to strip ending spaces from
% something which also has inner stretches of _multiple_ space tokens ?;-). 
%\end{lverb}
%    \begin{macrocode}
\long\def\XINT_zapesp_b #1#2#3\xint:%
    {\XINT_zapesp_end? #3\XINT_zapesp_e {#2#1}\empty #3\xint:}%
%    \end{macrocode}
%\begin{lverb}
% When we have been over all possible <sp><sp> things, we reach the
% ending space tokens, and #3 will be a bunch of spaces (possibly none)
% followed by \xint_bye. So the #1 in _end? will be \xint_bye. In all other cases
% #1 can not be \xint_bye (assuming naturally this token does nor arise in
% original input), hence control falls back to \XINT_zapesp_e which will loop back
% to \XINT_zapesp_a.
%\end{lverb}
%    \begin{macrocode}
\long\def\XINT_zapesp_end? #1{\xint_bye #1\XINT_zapesp_end }%
%    \end{macrocode}
%\begin{lverb}
% We are done. The #1 here has accumulated all the previous material,
% and is stripped of its ending spaces, if any.
%\end{lverb}
%    \begin{macrocode}
\long\def\XINT_zapesp_end\XINT_zapesp_e #1#2\xint:{ #1}%
%    \end{macrocode}
%\begin{lverb}
% We haven't yet reached the end, so we need to re-inject two space
% tokens after what we have gotten so far. Then we loop.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_zapesp_e#1{%
\long\def\XINT_zapesp_e ##1{\XINT_zapesp_a {##1#1#1}}%
}\XINT_zapesp_e{ }%
%    \end{macrocode}
% \subsection{\csh{xintZapSpaces}}
% \added[2013/11/01]{1.09f}
% \changed[2014/10/21]{1.1} It had the
% same bug as |\xintZapFirstSpaces|. We in effect do first |\xintZapFirstSpaces|,
% then |\xintZapLastSpaces|.
%    \begin{macrocode}
\def\xintZapSpaces {\romannumeral0\xintzapspaces }%
\def\xintzapspaces#1{%
\long\def\xintzapspaces ##1% like \xintZapFirstSpaces.
        {\XINT_zapsp_a #1##1\xint:#1#1\xint:}%
}\xintzapspaces{ }%
\def\XINT_zapsp_a#1{%
\long\def\XINT_zapsp_a ##1#1#1%
        {\XINT_zapsp_again?##1\xint_bye\XINT_zapsp_b##1#1#1}%
}\XINT_zapsp_a{ }%
\long\def\XINT_zapsp_again? #1{\xint_bye #1\XINT_zapsp_again }%
\xint_firstofone{\def\XINT_zapsp_again\XINT_zapsp_b} {\XINT_zapsp_a }%
\xint_firstofone{\def\XINT_zapsp_b} {\XINT_zapsp_c }%
\def\XINT_zapsp_c#1{%
\long\def\XINT_zapsp_c ##1\xint:##2\xint:%
        {\XINT_zapesp_a{}\empty ##1#1#1\xint_bye\xint:}%
}\XINT_zapsp_c{ }%
%    \end{macrocode}
% \subsection{\csh{xintZapSpacesB}}
% \added[2013/11/01]{1.09f} Strips up to one pair of braces (but then
% does not strip spaces inside).
%    \begin{macrocode}
\def\xintZapSpacesB {\romannumeral0\xintzapspacesb }%
\long\def\xintzapspacesb #1{\XINT_zapspb_one? #1\xint:\xint:%
                         \xint_bye\xintzapspaces {#1}}%
\long\def\XINT_zapspb_one? #1#2%
   {\xint_gob_til_xint: #1\XINT_zapspb_onlyspaces\xint:%
    \xint_gob_til_xint: #2\XINT_zapspb_bracedorone\xint:%
    \xint_bye {#1}}%
\def\XINT_zapspb_onlyspaces\xint:%
    \xint_gob_til_xint:\xint:\XINT_zapspb_bracedorone\xint:%
    \xint_bye #1\xint_bye\xintzapspaces #2{ }%
\long\def\XINT_zapspb_bracedorone\xint:%
    \xint_bye #1\xint:\xint_bye\xintzapspaces #2{ #1}%
%    \end{macrocode}
% \subsection{\csh{xintCSVtoList}, \csh{xintCSVtoListNonStripped}}
% \added{1.06}
%\begin{lverb} \xintCSVtoList transforms a,b,..,z into {a}{b}...{z}. The comma
% separated list may be a macro which is first f-expanded. Here, use of \Z
% (and \R) perfectly safe.
%\end{lverb}
% \changed[2013/11/02]{1.09f} Automatically filters items with
% |\xintZapSpacesB| to strip away all spaces around commas, and spaces at the start
% and end of the list. The original is kept as |\xintCSVtoListNonStripped|, and is
% faster. But ... it doesn't strip spaces.
%
% ATTENTION: if the input is empty the output contains one item (empty, of
% course). This means an |\xintFor| loop always executes at least once the
% iteration, contrarily to |\xintFor*|.
%    \begin{macrocode}
\def\xintCSVtoList {\romannumeral0\xintcsvtolist }%
\long\def\xintcsvtolist #1{\expandafter\xintApply
           \expandafter\xintzapspacesb
           \expandafter{\romannumeral0\xintcsvtolistnonstripped{#1}}}%
\def\xintCSVtoListNoExpand {\romannumeral0\xintcsvtolistnoexpand }%
\long\def\xintcsvtolistnoexpand #1{\expandafter\xintApply
           \expandafter\xintzapspacesb
           \expandafter{\romannumeral0\xintcsvtolistnonstrippednoexpand{#1}}}%
\def\xintCSVtoListNonStripped {\romannumeral0\xintcsvtolistnonstripped }%
\def\xintCSVtoListNonStrippedNoExpand
         {\romannumeral0\xintcsvtolistnonstrippednoexpand }%
\long\def\xintcsvtolistnonstripped #1%
{%
    \expandafter\XINT_csvtol_loop_a\expandafter
    {\expandafter}\romannumeral`&&@#1%
        ,\xint_bye,\xint_bye,\xint_bye,\xint_bye
        ,\xint_bye,\xint_bye,\xint_bye,\xint_bye,\Z
}%
\long\def\xintcsvtolistnonstrippednoexpand #1%
{%
    \XINT_csvtol_loop_a
    {}#1,\xint_bye,\xint_bye,\xint_bye,\xint_bye
        ,\xint_bye,\xint_bye,\xint_bye,\xint_bye,\Z
}%
\long\def\XINT_csvtol_loop_a #1#2,#3,#4,#5,#6,#7,#8,#9,%
{%
    \xint_bye #9\XINT_csvtol_finish_a\xint_bye
    \XINT_csvtol_loop_b {#1}{{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}}%
}%
\long\def\XINT_csvtol_loop_b #1#2{\XINT_csvtol_loop_a {#1#2}}%
\long\def\XINT_csvtol_finish_a\xint_bye\XINT_csvtol_loop_b #1#2#3\Z
{%
    \XINT_csvtol_finish_b #3\R,\R,\R,\R,\R,\R,\R,\Z #2{#1}%
}%
%    \end{macrocode}
%\begin{lverb}
% 1.1c revisits this old code and improves upon the earlier endings.
% But as the _d.. macros have already nine parameters, I needed the
% \expandafter and \xint_gob_til_Z in finish_b (compare \XINT_keep_endb, or
% also \XINT_RQ_end_b).
%\end{lverb}
%    \begin{macrocode}
\def\XINT_csvtol_finish_b #1,#2,#3,#4,#5,#6,#7,#8\Z
{%
    \xint_gob_til_R
            #1\expandafter\XINT_csvtol_finish_dviii\xint_gob_til_Z
            #2\expandafter\XINT_csvtol_finish_dvii \xint_gob_til_Z
            #3\expandafter\XINT_csvtol_finish_dvi  \xint_gob_til_Z
            #4\expandafter\XINT_csvtol_finish_dv   \xint_gob_til_Z
            #5\expandafter\XINT_csvtol_finish_div  \xint_gob_til_Z
            #6\expandafter\XINT_csvtol_finish_diii \xint_gob_til_Z
            #7\expandafter\XINT_csvtol_finish_dii  \xint_gob_til_Z
            \R\XINT_csvtol_finish_di \Z
}%
\long\def\XINT_csvtol_finish_dviii #1#2#3#4#5#6#7#8#9{ #9}%
\long\def\XINT_csvtol_finish_dvii  #1#2#3#4#5#6#7#8#9{ #9{#1}}%
\long\def\XINT_csvtol_finish_dvi   #1#2#3#4#5#6#7#8#9{ #9{#1}{#2}}%
\long\def\XINT_csvtol_finish_dv    #1#2#3#4#5#6#7#8#9{ #9{#1}{#2}{#3}}%
\long\def\XINT_csvtol_finish_div   #1#2#3#4#5#6#7#8#9{ #9{#1}{#2}{#3}{#4}}%
\long\def\XINT_csvtol_finish_diii  #1#2#3#4#5#6#7#8#9{ #9{#1}{#2}{#3}{#4}{#5}}%
\long\def\XINT_csvtol_finish_dii   #1#2#3#4#5#6#7#8#9%
                                            { #9{#1}{#2}{#3}{#4}{#5}{#6}}%
\long\def\XINT_csvtol_finish_di\Z  #1#2#3#4#5#6#7#8#9%
                                            { #9{#1}{#2}{#3}{#4}{#5}{#6}{#7}}%
%    \end{macrocode}
% \subsection{\csh{xintListWithSep}}
% \added{1.04}
%\begin{lverb}
% \xintListWithSep {\sep}{{a}{b}...{z}} returns a \sep b \sep ....\sep z. It
% f-expands its second argument. The 'sep' may be \par's: the macro
% \xintlistwithsep etc... are all declared long. 'sep' does not have to be a
% single token. It is not expanded. The "list" argument may be empty.
%
% \xintListWithSepNoExpand does not f-expand its second argument.
%\end{lverb}
% \changed{1.2p}
%\begin{lverb}
% This venerable macro from 1.04 remained unchanged for a long time and was
% finally refactored at 1.2p for increased speed. Tests done with a list of
% identical {\x} items and a sep of \z demonstrated a speed increase of about:
%( - 3x for 30 items,
%: - 4.5x for 100 items,
%: - 7.5x--8x for 1000 items.
%)
%\end{lverb}
%    \begin{macrocode}
\def\xintListWithSep         {\romannumeral0\xintlistwithsep }%
\def\xintListWithSepNoExpand {\romannumeral0\xintlistwithsepnoexpand }%
\long\def\xintlistwithsep #1#2%
    {\expandafter\XINT_lws\expandafter {\romannumeral`&&@#2}{#1}}%
\long\def\xintlistwithsepnoexpand #1#2%
{%
    \XINT_lws_loop_a {#1}#2{\xint_bye\XINT_lws_e_vi}%
       {\xint_bye\XINT_lws_e_v}{\xint_bye\XINT_lws_e_iv}%
       {\xint_bye\XINT_lws_e_iii}{\xint_bye\XINT_lws_e_ii}%
       {\xint_bye\XINT_lws_e_i}{\xint_bye\XINT_lws_e}%
       {\xint_bye\expandafter\space}\xint_bye
}%
\long\def\XINT_lws #1#2%
{%
    \XINT_lws_loop_a {#2}#1{\xint_bye\XINT_lws_e_vi}%
       {\xint_bye\XINT_lws_e_v}{\xint_bye\XINT_lws_e_iv}%
       {\xint_bye\XINT_lws_e_iii}{\xint_bye\XINT_lws_e_ii}%
       {\xint_bye\XINT_lws_e_i}{\xint_bye\XINT_lws_e}%
       {\xint_bye\expandafter\space}\xint_bye
}%
\long\def\XINT_lws_loop_a #1#2#3#4#5#6#7#8#9%
{%
    \xint_bye #9\xint_bye
    \XINT_lws_loop_b {#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}%
}%
\long\def\XINT_lws_loop_b #1#2#3#4#5#6#7#8#9%
{%
    \XINT_lws_loop_a {#1}{#2#1#3#1#4#1#5#1#6#1#7#1#8#1#9}%
}%
\long\def\XINT_lws_e_vi\xint_bye\XINT_lws_loop_b #1#2#3#4#5#6#7#8#9\xint_bye
    { #2#1#3#1#4#1#5#1#6#1#7#1#8}%
\long\def\XINT_lws_e_v\xint_bye\XINT_lws_loop_b #1#2#3#4#5#6#7#8\xint_bye
    { #2#1#3#1#4#1#5#1#6#1#7}%
\long\def\XINT_lws_e_iv\xint_bye\XINT_lws_loop_b #1#2#3#4#5#6#7\xint_bye
    { #2#1#3#1#4#1#5#1#6}%
\long\def\XINT_lws_e_iii\xint_bye\XINT_lws_loop_b #1#2#3#4#5#6\xint_bye
    { #2#1#3#1#4#1#5}%
\long\def\XINT_lws_e_ii\xint_bye\XINT_lws_loop_b #1#2#3#4#5\xint_bye
    { #2#1#3#1#4}%
\long\def\XINT_lws_e_i\xint_bye\XINT_lws_loop_b #1#2#3#4\xint_bye
    { #2#1#3}%
\long\def\XINT_lws_e\xint_bye\XINT_lws_loop_b #1#2#3\xint_bye
    { #2}%
%    \end{macrocode}
% \subsection{\csh{xintNthElt}}
% \added{1.06}
% \changed{1.2j}
%\begin{lverb}
% Last refactored in 1.2j.
%
% \xintNthElt {i}{List} returns the i th item from List (one pair of braces
% removed). The list is first f-expanded. The \xintNthEltNoExpand does no
% expansion of its second argument. Both variants expand i inside \numexpr.
%
% With i = 0, the number of items is returned using \xintLength but with the
% List argument f-expanded first.
%
% Negative values return the |i|th element from the end. 
%
% When i is out of range, an empty value is returned.
%\end{lverb}
%    \begin{macrocode}
\def\xintNthElt         {\romannumeral0\xintnthelt }%
\def\xintNthEltNoExpand {\romannumeral0\xintntheltnoexpand }%
\long\def\xintnthelt #1#2{\expandafter\XINT_nthelt_a\the\numexpr #1\expandafter.%
                        \expandafter{\romannumeral`&&@#2}}%
\def\xintntheltnoexpand #1{\expandafter\XINT_nthelt_a\the\numexpr #1.}%
\def\XINT_nthelt_a #1%
{%
    \xint_UDzerominusfork
        #1-\XINT_nthelt_zero
        0#1\XINT_nthelt_neg
         0-{\XINT_nthelt_pos #1}%
    \krof
}%
\def\XINT_nthelt_zero #1.{\xintlength }%
\long\def\XINT_nthelt_neg #1.#2%
{%
    \expandafter\XINT_nthelt_neg_a\the\numexpr\xint_c_i+\XINT_length_loop
    #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
      \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v
      \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye
    -#1.#2\xint_bye
}%
\def\XINT_nthelt_neg_a #1%
{%
    \xint_UDzerominusfork
        #1-\xint_stop_afterbye
        0#1\xint_stop_afterbye
         0-{}%
    \krof
    \expandafter\XINT_nthelt_neg_b
    \romannumeral\expandafter\XINT_gobble\the\numexpr-\xint_c_i+#1%
}%
\long\def\XINT_nthelt_neg_b #1#2\xint_bye{ #1}%
\long\def\XINT_nthelt_pos #1.#2%
{%
    \expandafter\XINT_nthelt_pos_done
    \romannumeral0\expandafter\XINT_trim_loop\the\numexpr#1-\xint_c_x.%
     #2\xint:\xint:\xint:\xint:\xint:%
       \xint:\xint:\xint:\xint:\xint:%
    \xint_bye
}%
\def\XINT_nthelt_pos_done #1{%
\long\def\XINT_nthelt_pos_done ##1##2\xint_bye{%
  \xint_gob_til_xint:##1\expandafter#1\xint_gobble_ii\xint:#1##1}%
}\XINT_nthelt_pos_done{ }%
%    \end{macrocode}
% \subsection{\csh{xintNthOnePy}}
% \added{1.4}
% See relevant code comments in \xintexprnameimp.
%    \begin{macrocode}
\def\xintNthOnePy         {\romannumeral0\xintnthonepy }%
\def\xintNthOnePyNoExpand {\romannumeral0\xintnthonepynoexpand }%
\long\def\xintnthonepy #1#2{\expandafter\XINT_nthonepy_a\the\numexpr #1\expandafter.%
                        \expandafter{\romannumeral`&&@#2}}%
\def\xintnthonepynoexpand #1{\expandafter\XINT_nthonepy_a\the\numexpr #1.}%
\def\XINT_nthonepy_a #1%
{%
    \xint_UDsignfork
        #1\XINT_nthonepy_neg
         -{\XINT_nthonepy_nonneg #1}%
    \krof
}%
\long\def\XINT_nthonepy_neg #1.#2%
{%
    \expandafter\XINT_nthonepy_neg_a\the\numexpr\xint_c_i+\XINT_length_loop
    #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
      \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v
      \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye
    -#1.#2\xint_bye
}%
\def\XINT_nthonepy_neg_a #1%
{%
    \xint_UDzerominusfork
        #1-\xint_stop_afterbye
        0#1\xint_stop_afterbye
         0-{}%
    \krof
    \expandafter\XINT_nthonepy_neg_b
    \romannumeral\expandafter\XINT_gobble\the\numexpr-\xint_c_i+#1%
}%
\long\def\XINT_nthonepy_neg_b #1#2\xint_bye{{#1}}%
\long\def\XINT_nthonepy_nonneg #1.#2%
{%
    \expandafter\XINT_nthonepy_nonneg_done
    \romannumeral0\expandafter\XINT_trim_loop\the\numexpr#1-\xint_c_ix.%
     #2\xint:\xint:\xint:\xint:\xint:%
       \xint:\xint:\xint:\xint:\xint:%
    \xint_bye
}%
\def\XINT_nthonepy_nonneg_done #1{%
\long\def\XINT_nthonepy_nonneg_done ##1##2\xint_bye{%
  \xint_gob_til_xint:##1\expandafter#1\xint_gobble_ii\xint:{##1}}%
}\XINT_nthonepy_nonneg_done{ }%
%    \end{macrocode}
% \subsection{\csh{xintKeep}}
% \added{1.09m}
%\begin{lverb}
% \xintKeep{i}{L} f-expands its second argument L. It then grabs the first i
% items from L and discards the rest. 
%
% ATTENTION: **each such kept item is returned inside a brace pair**
% Use \xintKeepUnbraced to avoid that.
%
% For i equal or larger to the number N of items in (expanded) L, the full L
% is returned (with braced items). For i=0, the macro returns an empty output.
% For i<0, the macro discards the first N-|i| items. No brace pairs added to
% the remaining items. For i is less or equal to -N, the full L is returned
% (with no braces added.)
%
% \xintKeepNoExpand does not expand the L argument.
%\end{lverb}
% \changed{1.2i}
%\begin{lverb}
% Prior to 1.2i the code proceeded along a loop with no pre-computation of
% the length of L, for the i>0 case. The faster 1.2i version takes advantage
% of novel \xintLengthUpTo from xintkernel.sty.
%\end{lverb}
%    \begin{macrocode}
\def\xintKeep         {\romannumeral0\xintkeep }%
\def\xintKeepNoExpand {\romannumeral0\xintkeepnoexpand }%
\long\def\xintkeep #1#2{\expandafter\XINT_keep_a\the\numexpr #1\expandafter.%
                        \expandafter{\romannumeral`&&@#2}}%
\def\xintkeepnoexpand #1{\expandafter\XINT_keep_a\the\numexpr #1.}%
\def\XINT_keep_a #1%
{%
    \xint_UDzerominusfork
        #1-\XINT_keep_keepnone
        0#1\XINT_keep_neg
         0-{\XINT_keep_pos #1}%
    \krof
}%
\long\def\XINT_keep_keepnone .#1{ }%
\long\def\XINT_keep_neg #1.#2%
{%
    \expandafter\XINT_keep_neg_a\the\numexpr
    #1-\numexpr\XINT_length_loop
    #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
      \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v
      \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye.#2%
}%
\def\XINT_keep_neg_a #1%
{%
    \xint_UDsignfork
        #1{\expandafter\space\romannumeral\XINT_gobble}%
         -\XINT_keep_keepall
    \krof
}%
\def\XINT_keep_keepall #1.{ }%
\long\def\XINT_keep_pos #1.#2%
{%
    \expandafter\XINT_keep_loop
    \the\numexpr#1-\XINT_lengthupto_loop
    #1.#2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
         \xint_c_vii\xint_c_vi\xint_c_v\xint_c_iv
         \xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye.%
    -\xint_c_viii.{}#2\xint_bye%
}%
\def\XINT_keep_loop #1#2.%
{%
    \xint_gob_til_minus#1\XINT_keep_loop_end-%
    \expandafter\XINT_keep_loop
    \the\numexpr#1#2-\xint_c_viii\expandafter.\XINT_keep_loop_pickeight
}%
\long\def\XINT_keep_loop_pickeight 
     #1#2#3#4#5#6#7#8#9{{#1{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}}}%
\def\XINT_keep_loop_end-\expandafter\XINT_keep_loop
    \the\numexpr-#1-\xint_c_viii\expandafter.\XINT_keep_loop_pickeight
    {\csname XINT_keep_end#1\endcsname}%
\long\expandafter\def\csname XINT_keep_end1\endcsname
   #1#2#3#4#5#6#7#8#9\xint_bye { #1{#2}{#3}{#4}{#5}{#6}{#7}{#8}}%
\long\expandafter\def\csname XINT_keep_end2\endcsname
   #1#2#3#4#5#6#7#8\xint_bye { #1{#2}{#3}{#4}{#5}{#6}{#7}}%
\long\expandafter\def\csname XINT_keep_end3\endcsname
   #1#2#3#4#5#6#7\xint_bye { #1{#2}{#3}{#4}{#5}{#6}}%
\long\expandafter\def\csname XINT_keep_end4\endcsname
   #1#2#3#4#5#6\xint_bye { #1{#2}{#3}{#4}{#5}}%
\long\expandafter\def\csname XINT_keep_end5\endcsname
   #1#2#3#4#5\xint_bye { #1{#2}{#3}{#4}}%
\long\expandafter\def\csname XINT_keep_end6\endcsname
   #1#2#3#4\xint_bye { #1{#2}{#3}}%
\long\expandafter\def\csname XINT_keep_end7\endcsname
   #1#2#3\xint_bye { #1{#2}}%
\long\expandafter\def\csname XINT_keep_end8\endcsname
   #1#2\xint_bye { #1}%
%    \end{macrocode}
% \subsection{\csh{xintKeepUnbraced}}
% \added{1.2a}
%\begin{lverb}
% Same as \xintKeep but will *not* add (or maintain) brace pairs
% around the kept items when length(L)>i>0.
%
% The name may cause a mis-understanding: for i<0, (i.e. keeping only
% trailing items), there is no brace removal at all happening.
%\end{lverb}
%
% \changed{1.2i} As |\xintKeep|.
%    \begin{macrocode}
\def\xintKeepUnbraced         {\romannumeral0\xintkeepunbraced }%
\def\xintKeepUnbracedNoExpand {\romannumeral0\xintkeepunbracednoexpand }%
\long\def\xintkeepunbraced #1#2%
    {\expandafter\XINT_keepunbr_a\the\numexpr #1\expandafter.%
                        \expandafter{\romannumeral`&&@#2}}%
\def\xintkeepunbracednoexpand #1%
   {\expandafter\XINT_keepunbr_a\the\numexpr #1.}%
\def\XINT_keepunbr_a #1%
{%
    \xint_UDzerominusfork
        #1-\XINT_keep_keepnone
        0#1\XINT_keep_neg
         0-{\XINT_keepunbr_pos #1}%
    \krof
}%
\long\def\XINT_keepunbr_pos #1.#2%
{%
    \expandafter\XINT_keepunbr_loop
    \the\numexpr#1-\XINT_lengthupto_loop
    #1.#2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
         \xint_c_vii\xint_c_vi\xint_c_v\xint_c_iv
         \xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye.%
    -\xint_c_viii.{}#2\xint_bye%
}%
\def\XINT_keepunbr_loop #1#2.%
{%
    \xint_gob_til_minus#1\XINT_keepunbr_loop_end-%
    \expandafter\XINT_keepunbr_loop
    \the\numexpr#1#2-\xint_c_viii\expandafter.\XINT_keepunbr_loop_pickeight
}%
\long\def\XINT_keepunbr_loop_pickeight 
     #1#2#3#4#5#6#7#8#9{{#1#2#3#4#5#6#7#8#9}}%
\def\XINT_keepunbr_loop_end-\expandafter\XINT_keepunbr_loop
    \the\numexpr-#1-\xint_c_viii\expandafter.\XINT_keepunbr_loop_pickeight
    {\csname XINT_keepunbr_end#1\endcsname}%
\long\expandafter\def\csname XINT_keepunbr_end1\endcsname
   #1#2#3#4#5#6#7#8#9\xint_bye { #1#2#3#4#5#6#7#8}%
\long\expandafter\def\csname XINT_keepunbr_end2\endcsname
   #1#2#3#4#5#6#7#8\xint_bye { #1#2#3#4#5#6#7}%
\long\expandafter\def\csname XINT_keepunbr_end3\endcsname
   #1#2#3#4#5#6#7\xint_bye { #1#2#3#4#5#6}%
\long\expandafter\def\csname XINT_keepunbr_end4\endcsname
   #1#2#3#4#5#6\xint_bye { #1#2#3#4#5}%
\long\expandafter\def\csname XINT_keepunbr_end5\endcsname
   #1#2#3#4#5\xint_bye { #1#2#3#4}%
\long\expandafter\def\csname XINT_keepunbr_end6\endcsname
   #1#2#3#4\xint_bye { #1#2#3}%
\long\expandafter\def\csname XINT_keepunbr_end7\endcsname
   #1#2#3\xint_bye { #1#2}%
\long\expandafter\def\csname XINT_keepunbr_end8\endcsname
   #1#2\xint_bye { #1}%
%    \end{macrocode}
% \subsection{\csh{xintTrim}}
% \added{1.09m}
%\begin{lverb}
% \xintTrim{i}{L} f-expands its second argument L. It then removes the first i
% items from L and keeps the rest. For i equal or larger to the number N of
% items in (expanded) L, the macro returns an empty output. For i=0, the
% original (expanded) L is returned. For i<0, the macro proceeds from the
% tail. It thus removes the last |i| items, i.e. it keeps the first N-|i|
% items. For |i|>= N, the empty list is returned.
%
% \xintTrimNoExpand does not expand the L argument.
%\end{lverb}
% \changed{1.2i}
%\begin{lverb}
% Speed improvements for i<0 branch (which hands over to
% \xintKeep). Speed improvements with 1.2j for i>0 branch which gobbles items
% nine by nine despite not knowing in advance if it will go too far.
%\end{lverb}
%    \begin{macrocode}
\def\xintTrim         {\romannumeral0\xinttrim }%
\def\xintTrimNoExpand {\romannumeral0\xinttrimnoexpand }%
\long\def\xinttrim #1#2{\expandafter\XINT_trim_a\the\numexpr #1\expandafter.%
                        \expandafter{\romannumeral`&&@#2}}%
\def\xinttrimnoexpand #1{\expandafter\XINT_trim_a\the\numexpr #1.}%
\def\XINT_trim_a #1%
{%
    \xint_UDzerominusfork
        #1-\XINT_trim_trimnone
        0#1\XINT_trim_neg
         0-{\XINT_trim_pos #1}%
    \krof
}%
\long\def\XINT_trim_trimnone .#1{ #1}%
\long\def\XINT_trim_neg #1.#2%
{%
    \expandafter\XINT_trim_neg_a\the\numexpr
    #1-\numexpr\XINT_length_loop
    #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
      \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v
      \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye
    .{}#2\xint_bye
}%
\def\XINT_trim_neg_a #1%
{%
    \xint_UDsignfork
        #1{\expandafter\XINT_keep_loop\the\numexpr-\xint_c_viii+}%
         -\XINT_trim_trimall
    \krof
}%
\def\XINT_trim_trimall#1{%
\def\XINT_trim_trimall {\expandafter#1\xint_bye}%
}\XINT_trim_trimall{ }%
%    \end{macrocode}
%\begin{lverb}
% This branch doesn't pre-evaluate the length of the list argument.
% Redone again for 1.2j, manages to trim nine by nine. Some non optimal
% looking aspect of the code is for allowing sharing with \xintNthElt.
%\end{lverb}
%    \begin{macrocode}
\long\def\XINT_trim_pos #1.#2%
{%
    \expandafter\XINT_trim_pos_done\expandafter\space
    \romannumeral0\expandafter\XINT_trim_loop\the\numexpr#1-\xint_c_ix.%
     #2\xint:\xint:\xint:\xint:\xint:%
       \xint:\xint:\xint:\xint:\xint:%
    \xint_bye
}%
\def\XINT_trim_loop #1#2.%
{%
    \xint_gob_til_minus#1\XINT_trim_finish-%
    \expandafter\XINT_trim_loop\the\numexpr#1#2\XINT_trim_loop_trimnine
}%
\long\def\XINT_trim_loop_trimnine #1#2#3#4#5#6#7#8#9%
{%
    \xint_gob_til_xint: #9\XINT_trim_toofew\xint:-\xint_c_ix.%
}%
\def\XINT_trim_toofew\xint:{*\xint_c_}%
\def\XINT_trim_finish#1{%
\def\XINT_trim_finish-%
    \expandafter\XINT_trim_loop\the\numexpr-##1\XINT_trim_loop_trimnine
{%
    \expandafter\expandafter\expandafter#1%
    \csname xint_gobble_\romannumeral\numexpr\xint_c_ix-##1\endcsname
}}\XINT_trim_finish{ }%
\long\def\XINT_trim_pos_done #1\xint:#2\xint_bye {#1}%
%    \end{macrocode}
% \subsection{\csh{xintTrimUnbraced}}
% \added{1.2a}
% \changed{1.2i} As |\xintTrim|.
%    \begin{macrocode}
\def\xintTrimUnbraced         {\romannumeral0\xinttrimunbraced }%
\def\xintTrimUnbracedNoExpand {\romannumeral0\xinttrimunbracednoexpand }%
\long\def\xinttrimunbraced #1#2%
    {\expandafter\XINT_trimunbr_a\the\numexpr #1\expandafter.%
                        \expandafter{\romannumeral`&&@#2}}%
\def\xinttrimunbracednoexpand #1%
    {\expandafter\XINT_trimunbr_a\the\numexpr #1.}%
\def\XINT_trimunbr_a #1%
{%
    \xint_UDzerominusfork
        #1-\XINT_trim_trimnone
        0#1\XINT_trimunbr_neg
         0-{\XINT_trim_pos #1}%
    \krof
}%
\long\def\XINT_trimunbr_neg #1.#2%
{%
    \expandafter\XINT_trimunbr_neg_a\the\numexpr
    #1-\numexpr\XINT_length_loop
    #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
      \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v
      \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye
    .{}#2\xint_bye
}%
\def\XINT_trimunbr_neg_a #1%
{%
    \xint_UDsignfork
        #1{\expandafter\XINT_keepunbr_loop\the\numexpr-\xint_c_viii+}%
         -\XINT_trim_trimall
    \krof
}%
%    \end{macrocode}
% \subsection{\csh{xintApply}}
% \added{1.04}
%\begin{lverb}
% \xintApply {\macro}{{a}{b}...{z}} returns {\macro{a}}...{\macro{b}}
% where each instance of \macro is f-expanded. The list itself is first
% f-expanded and may thus be a macro.
%\end{lverb}
%    \begin{macrocode}
\def\xintApply         {\romannumeral0\xintapply }%
\def\xintApplyNoExpand {\romannumeral0\xintapplynoexpand }%
\long\def\xintapply #1#2%
{%
    \expandafter\XINT_apply\expandafter {\romannumeral`&&@#2}%
    {#1}%
}%
\long\def\XINT_apply #1#2{\XINT_apply_loop_a {}{#2}#1\xint_bye }%
\long\def\xintapplynoexpand #1#2{\XINT_apply_loop_a {}{#1}#2\xint_bye }%
\long\def\XINT_apply_loop_a #1#2#3%
{%
    \xint_bye #3\XINT_apply_end\xint_bye
    \expandafter
    \XINT_apply_loop_b
    \expandafter {\romannumeral`&&@#2{#3}}{#1}{#2}%
}%
\long\def\XINT_apply_loop_b #1#2{\XINT_apply_loop_a {#2{#1}}}%
\long\def\XINT_apply_end\xint_bye\expandafter\XINT_apply_loop_b
    \expandafter #1#2#3{ #2}%
%    \end{macrocode}
% \subsection{\csh{xintApply:x} (WIP, commented-out)}
% \added[2020/01/27]{1.4}
%\begin{lverb}
% For usage in the NumPy-like slicing
% routines. Well, actually, in the end I sticked with old-fashioned (quadratic
% cost) \xintApply for 1.4 2020/01/31 release. See comments there.
%
% (Comments mainly from 2020/01/27, but on 2020/02/24 I comment out
%  the code and add an alternative)
%
% To expand in \expanded context, and does not need to
% do any expansion of its second argument.
%
% This uses techniques I had developed for 1.2i/1.2j Keep, Trim, Length,
% LastItem like macros, and I should revamp venerable \xintApply probably too.
% But the latter f-expandability (if it does not have \expanded at disposal)
% complicates significantly matters as it has to store material and release at
% very end.
%
% Here it is simpler and I am doing it quickly as I really want to release
% 1.4. The \xint: token should not be located in looped over items. I could
% use something more exotic like the null char with catcode 3...
%
%( \long\def\xintApply:x #1#2$%
%: {$%
%:     \XINT_apply:x_loop {#1}#2$%
%:     {\xint:\XINT_apply:x_loop_enda}{\xint:\XINT_apply:x_loop_endb}$%
%:     {\xint:\XINT_apply:x_loop_endc}{\xint:\XINT_apply:x_loop_endd}$%
%:     {\xint:\XINT_apply:x_loop_ende}{\xint:\XINT_apply:x_loop_endf}$%
%:     {\xint:\XINT_apply:x_loop_endg}{\xint:\XINT_apply:x_loop_endh}\xint_bye
%: }$%
%: \long\def\XINT_apply:x_loop #1#2#3#4#5#6#7#8#9$%
%: {$%
%:     \xint_gob_til_xint: #9\xint:
%:     {#1{#2}}{#1{#3}}{#1{#4}}{#1{#5}}{#1{#6}}{#1{#7}}{#1{#8}}{#1{#9}}$%
%:     \XINT_apply:x_loop {#1}$%
%: }$%
%: \long\def\XINT_apply:x_loop_endh\xint: #1\xint_bye{}$%
%: \long\def\XINT_apply:x_loop_endg\xint: #1#2\xint_bye{{#1}}$%
%: \long\def\XINT_apply:x_loop_endf\xint: #1#2#3\xint_bye{{#1}{#2}}$%
%: \long\def\XINT_apply:x_loop_ende\xint: #1#2#3#4\xint_bye{{#1}{#2}{#3}}$%
%: \long\def\XINT_apply:x_loop_endd\xint: #1#2#3#4#5\xint_bye{{#1}{#2}{#3}{#4}}$%
%: \long\def\XINT_apply:x_loop_endc\xint: #1#2#3#4#5#6\xint_bye{{#1}{#2}{#3}{#4}{#5}}$%
%: \long\def\XINT_apply:x_loop_endb\xint: #1#2#3#4#5#6#7\xint_bye{{#1}{#2}{#3}{#4}{#5}{#6}}$%
%: \long\def\XINT_apply:x_loop_enda\xint: #1#2#3#4#5#6#7#8\xint_bye{{#1}{#2}{#3}{#4}{#5}{#6}{#7}}$%
%)
%
% For small number of items gain with respect to \xintApply is little if any
% (might even be a loss).
%
% Picking one by one is possibly better for small number of items. Like
% this for example, the natural simple minded thing:
%
%(\long\def\xintApply:x #1#2$%
%: {$%
%:     \XINT_apply:x_loop {#1}#2\xint_bye\xint_bye
%: }$%
%: \long\def\XINT_apply:x_loop #1#2$%
%: {$%
%:     \xint_bye #2\xint_bye {#1{#2}}$%
%:     \XINT_apply:x_loop {#1}$%
%: }$%
%)
%
% Some variant on 2020/02/24
% 
%( \long\def\xint_Bbye#1\xint_Bye{}$%
%: \long\def\xintApply:x #1#2$%
%: {$%
%:     \XINT_apply:x_loop {#1}#2$%
%:     {\xint_bye}{\xint_bye}{\xint_bye}{\xint_bye}$%
%:     {\xint_bye}{\xint_bye}{\xint_bye}{\xint_bye}\xint_bye
%: }$%
%: \long\def\XINT_apply:x_loop #1#2#3#4#5#6#7#8#9$%
%: {$%
%:     \xint_Bye #2\xint_bye {#1{#2}}$%
%:     \xint_Bye #3\xint_bye {#1{#3}}$%
%:     \xint_Bye #4\xint_bye {#1{#4}}$%
%:     \xint_Bye #5\xint_bye {#1{#5}}$%
%:     \xint_Bye #6\xint_bye {#1{#6}}$%
%:     \xint_Bye #7\xint_bye {#1{#7}}$%
%:     \xint_Bye #8\xint_bye {#1{#8}}$%
%:     \xint_Bye #9\xint_bye {#1{#9}}$%
%:     \XINT_apply:x_loop {#1}$%
%: }$%
%)
%\end{lverb}
% \subsection{\csh{xintApplyUnbraced}}
% \added{1.06b}
%\begin{lverb}
% \xintApplyUnbraced {\macro}{{a}{b}...{z}} returns \macro{a}...\macro{z}
% where each instance of \macro is f-expanded using \romannumeral-`0. The second
% argument may be a macro as it is itself also f-expanded. No braces
% are added: this allows for example a non-expandable \def in \macro, without
% having to do \gdef.
%\end{lverb}
%    \begin{macrocode}
\def\xintApplyUnbraced {\romannumeral0\xintapplyunbraced }%
\def\xintApplyUnbracedNoExpand {\romannumeral0\xintapplyunbracednoexpand }%
\long\def\xintapplyunbraced #1#2%
{%
    \expandafter\XINT_applyunbr\expandafter {\romannumeral`&&@#2}%
    {#1}%
}%
\long\def\XINT_applyunbr #1#2{\XINT_applyunbr_loop_a {}{#2}#1\xint_bye }%
\long\def\xintapplyunbracednoexpand #1#2%
   {\XINT_applyunbr_loop_a {}{#1}#2\xint_bye }%
\long\def\XINT_applyunbr_loop_a #1#2#3%
{%
    \xint_bye #3\XINT_applyunbr_end\xint_bye
    \expandafter\XINT_applyunbr_loop_b
    \expandafter {\romannumeral`&&@#2{#3}}{#1}{#2}%
}%
\long\def\XINT_applyunbr_loop_b #1#2{\XINT_applyunbr_loop_a {#2#1}}%
\long\def\XINT_applyunbr_end\xint_bye\expandafter\XINT_applyunbr_loop_b
    \expandafter #1#2#3{ #2}%
%    \end{macrocode}
% \subsection{\csh{xintApplyUnbraced:x} (WIP, commented-out)}
% \added[2020/01/27]{1.4}
%\begin{lverb}
% For usage in the NumPy-like slicing
% routines.
%
% The items should not contain \xint: and the applied macro should not contain
% \empty.
%
% Finally, xintexpr.sty 1.4 code did not use this macro but the f-expandable
% one \xintApplyUnbraced.
%\end{lverb}
% \changed{1.4b}
%\begin{lverb}
% For 1.4b I prefer to keep the \xintApplyUnbraced:x code commented out,
% and classify it as WIP.
%( \long\def\xintApplyUnbraced:x #1#2$%
%: {$%
%:     \XINT_applyunbraced:x_loop {#1}#2$%
%:     {\xint:\XINT_applyunbraced:x_loop_enda}{\xint:\XINT_applyunbraced:x_loop_endb}$%
%:     {\xint:\XINT_applyunbraced:x_loop_endc}{\xint:\XINT_applyunbraced:x_loop_endd}$%
%:     {\xint:\XINT_applyunbraced:x_loop_ende}{\xint:\XINT_applyunbraced:x_loop_endf}$%
%:     {\xint:\XINT_applyunbraced:x_loop_endg}{\xint:\XINT_applyunbraced:x_loop_endh}\xint_bye
%: }$%
%: \long\def\XINT_applyunbraced:x_loop #1#2#3#4#5#6#7#8#9$%
%: {$%
%:     \xint_gob_til_xint: #9\xint:
%:             #1{#2}$%
%:       \empty#1{#3}$%
%:       \empty#1{#4}$%
%:       \empty#1{#5}$%
%:       \empty#1{#6}$%
%:       \empty#1{#7}$%
%:       \empty#1{#8}$%
%:       \empty#1{#9}$%
%:     \XINT_applyunbraced:x_loop {#1}$%
%: }$%
%: \long\def\XINT_applyunbraced:x_loop_endh\xint: #1\xint_bye{}$%
%: \long\def\XINT_applyunbraced:x_loop_endg\xint: #1\empty#2\xint_bye{#1}$%
%: \long\def\XINT_applyunbraced:x_loop_endf\xint: #1\empty
%:                                                #2\empty#3\xint_bye{#1#2}$%
%: \long\def\XINT_applyunbraced:x_loop_ende\xint: #1\empty
%:                                                #2\empty
%:                                                #3\empty#4\xint_bye{#1#2#3}$%
%: \long\def\XINT_applyunbraced:x_loop_endd\xint: #1\empty
%:                                                #2\empty
%:                                                #3\empty
%:                                                #4\empty#5\xint_bye{#1#2#3#4}$%
%: \long\def\XINT_applyunbraced:x_loop_endc\xint: #1\empty
%:                                                #2\empty
%:                                                #3\empty
%:                                                #4\empty
%:                                                #5\empty#6\xint_bye{#1#2#3#4#5}$%
%: \long\def\XINT_applyunbraced:x_loop_endb\xint: #1\empty
%:                                                #2\empty
%:                                                #3\empty
%:                                                #4\empty
%:                                                #5\empty
%:                                                #6\empty#7\xint_bye{#1#2#3#4#5#6}$%
%: \long\def\XINT_applyunbraced:x_loop_enda\xint: #1\empty
%:                                                #2\empty
%:                                                #3\empty
%:                                                #4\empty
%:                                                #5\empty
%:                                                #6\empty
%:                                                #7\empty#8\xint_bye{#1#2#3#4#5#6#7}$%
%)
%\end{lverb}
% \subsection{\csh{xintZip} (WIP, not public)}
% \added[2020/02/25]{1.4b}
%\begin{lverb}
% Support for zip(). Requires \expanded.
%
% The implementation here thus considers the argument is already completely
% expanded and is a sequence of nut-ples. I will come back at later date for
% more generic macros.
%
% Consider even the name of the function zip() as WIP.
%
% As per what this does, it imitates the zip() function. See xint-manual.pdf.
%
% I use lame terminators. Will think again later on this. I have to be careful
% with the used terminators, in particular with the NE context in mind.
%
% Generally speaking I will think another day about efficiency else I will
% never start this.
%
% OK, done. More compact than I initially thought. Various things should be
% commented upon here. Well, actually not so compact in the end as I basically
% had to double the whole thing simply to avoid the overhead of having to grab
% the final result delimited by some
% \xint_bye\xint_bye\xint_bye\xint_bye\empty terminator. Now actually rather
% \xint_bye\xint_bye\xint_bye\xint_bye\xint: 
%\end{lverb}
%    \begin{macrocode}
\def\xintZip #1{\expanded\XINT_zip_A#1\xint_bye\xint_bye}%
\def\XINT_zip_A#1%
{%
    \xint_bye#1{\expandafter}\xint_bye
    \expanded{\xint_noxpd{\XINT_ziptwo_A
        #1\xint_bye\xint_bye\xint_bye\xint_bye\xint:}\expandafter}%
    \expanded\XINT_zip_a
}%
\def\XINT_zip_a#1%
{%
    \xint_bye#1\XINT_zip_terminator\xint_bye
    \expanded{\xint_noxpd{\XINT_ziptwo_a
        #1\xint_bye\xint_bye\xint_bye\xint_bye\xint:}\expandafter}%
    \expanded\XINT_zip_a
}%
\def\XINT_zip_terminator\xint_bye#1\xint_bye{{}\empty\empty\empty\empty\xint:}%
\def\XINT_ziptwo_a #1#2#3#4#5\xint:#6#7#8#9%
{%
    \bgroup
    \xint_bye #1\XINT_ziptwo_e \xint_bye
    \xint_bye #6\XINT_ziptwo_e \xint_bye {{#1}#6}%
    \xint_bye #2\XINT_ziptwo_e \xint_bye
    \xint_bye #7\XINT_ziptwo_e \xint_bye {{#2}#7}%
    \xint_bye #3\XINT_ziptwo_e \xint_bye
    \xint_bye #8\XINT_ziptwo_e \xint_bye {{#3}#8}%
    \xint_bye #4\XINT_ziptwo_e \xint_bye
    \xint_bye #9\XINT_ziptwo_e \xint_bye {{#4}#9}%
%    \end{macrocode}
%\begin{lverb}
% Attention here that #6 can very well deliver no tokens at all. But
% the \ifx will then do the expected thing. Only mentioning!
%
% By the way, the \xint_bye method means TeX needs to look into tokens
% but skipping braced groups. A conditional based method lets TeX look only
% at the start but then it has to find \else or \fi so here also it must looks
% at tokens, and actually goes into braced groups. But (written 2020/02/26) I
% never did serious testing comparing the two, and in xint I have usually
% preferred \xint_bye/\xint_gob_til_foo types of methods (they proved superior
% than \ifnum to check for 0000 in numerical core context for example, at the
% early days when xint used blocks of 4 digits, not 8), or usage of \if/\ifx
% only on single tokens, combined with some \xint_dothis/\xint_orthat syntax.
%\end{lverb}
%    \begin{macrocode}
    \ifx \empty#6\expandafter\XINT_zipone_a\fi
    \XINT_ziptwo_b #5\xint:
}%
\def\XINT_zipone_a\XINT_ziptwo_b{\XINT_zipone_b}%
\def\XINT_ziptwo_b #1#2#3#4#5\xint:#6#7#8#9%
{%
    \xint_bye #1\XINT_ziptwo_e \xint_bye
    \xint_bye #6\XINT_ziptwo_e \xint_bye {{#1}#6}%
    \xint_bye #2\XINT_ziptwo_e \xint_bye
    \xint_bye #7\XINT_ziptwo_e \xint_bye {{#2}#7}%
    \xint_bye #3\XINT_ziptwo_e \xint_bye
    \xint_bye #8\XINT_ziptwo_e \xint_bye {{#3}#8}%
    \xint_bye #4\XINT_ziptwo_e \xint_bye
    \xint_bye #9\XINT_ziptwo_e \xint_bye {{#4}#9}%
    \XINT_ziptwo_b #5\xint:
}%
\def\XINT_ziptwo_e #1\XINT_ziptwo_b #2\xint:#3\xint:
    {\iffalse{\fi}\xint_bye\xint_bye\xint_bye\xint_bye\xint:}%
\def\XINT_zipone_b #1#2#3#4%
{%
    \xint_bye #1\XINT_zipone_e \xint_bye {{#1}}%
    \xint_bye #2\XINT_zipone_e \xint_bye {{#2}}%
    \xint_bye #3\XINT_zipone_e \xint_bye {{#3}}%
    \xint_bye #4\XINT_zipone_e \xint_bye {{#4}}%
    \XINT_zipone_b
}%
\def\XINT_zipone_e #1\XINT_zipone_b #2\xint:
    {\iffalse{\fi}\xint_bye\xint_bye\xint_bye\xint_bye\empty}%
\def\XINT_ziptwo_A #1#2#3#4#5\xint:#6#7#8#9%
{%
    \bgroup
    \xint_bye #1\XINT_ziptwo_end \xint_bye
    \xint_bye #6\XINT_ziptwo_end \xint_bye {{#1}#6}%
    \xint_bye #2\XINT_ziptwo_end \xint_bye
    \xint_bye #7\XINT_ziptwo_end \xint_bye {{#2}#7}%
    \xint_bye #3\XINT_ziptwo_end \xint_bye
    \xint_bye #8\XINT_ziptwo_end \xint_bye {{#3}#8}%
    \xint_bye #4\XINT_ziptwo_end \xint_bye
    \xint_bye #9\XINT_ziptwo_end \xint_bye {{#4}#9}%
    \ifx \empty#6\expandafter\XINT_zipone_A\fi
    \XINT_ziptwo_B #5\xint:
}%
\def\XINT_zipone_A\XINT_ziptwo_B{\XINT_zipone_B}%
\def\XINT_ziptwo_B #1#2#3#4#5\xint:#6#7#8#9%
{%
    \xint_bye #1\XINT_ziptwo_end \xint_bye
    \xint_bye #6\XINT_ziptwo_end \xint_bye {{#1}#6}%
    \xint_bye #2\XINT_ziptwo_end \xint_bye
    \xint_bye #7\XINT_ziptwo_end \xint_bye {{#2}#7}%
    \xint_bye #3\XINT_ziptwo_end \xint_bye
    \xint_bye #8\XINT_ziptwo_end \xint_bye {{#3}#8}%
    \xint_bye #4\XINT_ziptwo_end \xint_bye
    \xint_bye #9\XINT_ziptwo_end \xint_bye {{#4}#9}%
    \XINT_ziptwo_B #5\xint:
}%
\def\XINT_ziptwo_end #1\XINT_ziptwo_B #2\xint:#3\xint:{\iffalse{\fi}}%
\def\XINT_zipone_B #1#2#3#4%
{%
    \xint_bye #1\XINT_zipone_end \xint_bye {{#1}}%
    \xint_bye #2\XINT_zipone_end \xint_bye {{#2}}%
    \xint_bye #3\XINT_zipone_end \xint_bye {{#3}}%
    \xint_bye #4\XINT_zipone_end \xint_bye {{#4}}%
    \XINT_zipone_B
}%
\def\XINT_zipone_end #1\XINT_zipone_B #2\xint:#3\xint:{\iffalse{\fi}}%
%    \end{macrocode}
% \subsection{\csh{xintSeq}}
% \added{1.09c}
%  Without the optional argument puts stress on the input stack,
% should not be used to generated thousands of terms then.
%
% \changed{1.4j}
% This venerable macro had a brace removal bug in case it produced a single
% number: |\xintSeq{10}{10}| expanded to |10| not |{10}|. When I looked at the
% code the bug looked almost deliberate to me, but reading the documentation
% (which I have not modified), the behaviour is really unexpected. And the
% variant with step parameter |\xintSeq[1]{10}{10}| did produce |{10}|, so
% yes, definitely it was a bug!
%
% I take this occasion to do some style (and perhaps efficiency) refactoring
% in the coding.  I feel there is room for improvement, no time this time.
% And I don't touch the variant with step parameter.
%
% Memo: \xintexprnameimp has some variants, a priori on ultra quick look
% they do not look like having similar bug as this one had.
%    \begin{macrocode}
\def\xintSeq {\romannumeral0\xintseq }%
\def\xintseq #1{\XINT_seq_chkopt  #1\xint_bye }%
\def\XINT_seq_chkopt #1%
{%
    \ifx [#1\expandafter\XINT_seq_opt
       \else\expandafter\XINT_seq_noopt
    \fi  #1%
}%
\def\XINT_seq_noopt #1\xint_bye #2%
{%
    \expandafter\XINT_seq
    \the\numexpr#1\expandafter.\the\numexpr #2.%
}%
\def\XINT_seq #1.#2.%
{%
   \ifnum #1=#2 \xint_dothis\XINT_seq_e\fi
   \ifnum #2>#1 \xint_dothis\XINT_seq_pa\fi
                \xint_orthat\XINT_seq_na
   #2.{#1}{#2}%
}%
\def\XINT_seq_e#1.#2{}%
\def\XINT_seq_pa {\expandafter\XINT_seq_p\the\numexpr-\xint_c_i+}%
\def\XINT_seq_na {\expandafter\XINT_seq_n\the\numexpr\xint_c_i+}%
\def\XINT_seq_p #1.#2%
{%
    \ifnum #1>#2
      \expandafter\XINT_seq_p\the
    \else
      \expandafter\XINT_seq_e
    \fi
    \numexpr #1-\xint_c_i.{#2}{#1}%
}%
\def\XINT_seq_n #1.#2%
{%
    \ifnum #1<#2
      \expandafter\XINT_seq_n\the
    \else
      \expandafter\XINT_seq_e
    \fi
    \numexpr #1+\xint_c_i.{#2}{#1}%
}%
%    \end{macrocode}
% Note at time of the |1.4j| bug fix : I definitely should improve this branch
% and diminish the number of expandafter's but no time this time.
%    \begin{macrocode}
\def\XINT_seq_opt [\xint_bye #1]#2#3%
{%
    \expandafter\XINT_seqo\expandafter
    {\the\numexpr #2\expandafter}\expandafter
    {\the\numexpr #3\expandafter}\expandafter
    {\the\numexpr #1}%
}%
\def\XINT_seqo #1#2%
{%
   \ifcase\ifnum #1=#2 0\else\ifnum #2>#1 1\else -1\fi\fi\space
      \expandafter\XINT_seqo_a
   \or
      \expandafter\XINT_seqo_pa
   \else
      \expandafter\XINT_seqo_na
   \fi
   {#1}{#2}%
}%
\def\XINT_seqo_a #1#2#3{ {#1}}%
\def\XINT_seqo_o #1#2#3#4{ #4}%
\def\XINT_seqo_pa #1#2#3%
{%
    \ifcase\ifnum #3=\xint_c_ 0\else\ifnum #3>\xint_c_ 1\else -1\fi\fi\space
           \expandafter\XINT_seqo_o
    \or
           \expandafter\XINT_seqo_pb
    \else
           \xint_afterfi{\expandafter\space\xint_gobble_iv}%
    \fi
    {#1}{#2}{#3}{{#1}}%
}%
\def\XINT_seqo_pb #1#2#3%
{%
    \expandafter\XINT_seqo_pc\expandafter{\the\numexpr #1+#3}{#2}{#3}%
}%
\def\XINT_seqo_pc #1#2%
{%
    \ifnum #1>#2
        \expandafter\XINT_seqo_o
    \else
        \expandafter\XINT_seqo_pd
    \fi
    {#1}{#2}%
}%
\def\XINT_seqo_pd #1#2#3#4{\XINT_seqo_pb {#1}{#2}{#3}{#4{#1}}}%
\def\XINT_seqo_na #1#2#3%
{%
    \ifcase\ifnum #3=\xint_c_ 0\else\ifnum #3>\xint_c_ 1\else -1\fi\fi\space
        \expandafter\XINT_seqo_o
    \or
        \xint_afterfi{\expandafter\space\xint_gobble_iv}%
    \else
        \expandafter\XINT_seqo_nb
    \fi
    {#1}{#2}{#3}{{#1}}%
}%
\def\XINT_seqo_nb #1#2#3%
{%
    \expandafter\XINT_seqo_nc\expandafter{\the\numexpr #1+#3}{#2}{#3}%
}%
\def\XINT_seqo_nc #1#2%
{%
    \ifnum #1<#2
        \expandafter\XINT_seqo_o
    \else
        \expandafter\XINT_seqo_nd
    \fi
    {#1}{#2}%
}%
\def\XINT_seqo_nd #1#2#3#4{\XINT_seqo_nb {#1}{#2}{#3}{#4{#1}}}%
%    \end{macrocode}
% \subsection{\csh{xintloop}, \csh{xintbreakloop}, \csh{xintbreakloopanddo},
% \csh{xintloopskiptonext}}
% \added[2013/11/22]{1.09g}
% \changed{1.09h} Made |\long|.
%    \begin{macrocode}
\long\def\xintloop #1#2\repeat {#1#2\xintloop_again\fi\xint_gobble_i {#1#2}}%
\long\def\xintloop_again\fi\xint_gobble_i #1{\fi
                             #1\xintloop_again\fi\xint_gobble_i {#1}}%
\long\def\xintbreakloop #1\xintloop_again\fi\xint_gobble_i #2{}%
\long\def\xintbreakloopanddo #1#2\xintloop_again\fi\xint_gobble_i #3{#1}%
\long\def\xintloopskiptonext #1\xintloop_again\fi\xint_gobble_i #2{%
                        #2\xintloop_again\fi\xint_gobble_i {#2}}%
%    \end{macrocode}
% \subsection{\csh{xintiloop},
% \csh{xintiloopindex},
% \csh{xintbracediloopindex},
% \csh{xintouteriloopindex},
% \csh{xintbracedouteriloopindex},
% \csh{xintbreakiloop},
% \csh{xintbreakiloopanddo},
% \csh{xintiloopskiptonext},
% \csh{xintiloopskipandredo}}
% \added[2013/11/22]{1.09g} 
% \changed{1.09h} Made |\long|.
% \added[2018/04/24]{1.3b}
% \myenquote{braced} variants.
%    \begin{macrocode}
\def\xintiloop [#1+#2]{%
    \expandafter\xintiloop_a\the\numexpr #1\expandafter.\the\numexpr #2.}%
\long\def\xintiloop_a #1.#2.#3#4\repeat{%
    #3#4\xintiloop_again\fi\xint_gobble_iii {#1}{#2}{#3#4}}%
\def\xintiloop_again\fi\xint_gobble_iii #1#2{%
    \fi\expandafter\xintiloop_again_b\the\numexpr#1+#2.#2.}%
\long\def\xintiloop_again_b #1.#2.#3{%
    #3\xintiloop_again\fi\xint_gobble_iii {#1}{#2}{#3}}%
\long\def\xintbreakiloop #1\xintiloop_again\fi\xint_gobble_iii #2#3#4{}%
\long\def\xintbreakiloopanddo
     #1.#2\xintiloop_again\fi\xint_gobble_iii #3#4#5{#1}%
\long\def\xintiloopindex #1\xintiloop_again\fi\xint_gobble_iii #2%
                {#2#1\xintiloop_again\fi\xint_gobble_iii {#2}}%
\long\def\xintbracediloopindex #1\xintiloop_again\fi\xint_gobble_iii #2%
     {{#2}#1\xintiloop_again\fi\xint_gobble_iii {#2}}%
\long\def\xintouteriloopindex #1\xintiloop_again
                         #2\xintiloop_again\fi\xint_gobble_iii #3%
   {#3#1\xintiloop_again #2\xintiloop_again\fi\xint_gobble_iii {#3}}%
\long\def\xintbracedouteriloopindex #1\xintiloop_again
                         #2\xintiloop_again\fi\xint_gobble_iii #3%
   {{#3}#1\xintiloop_again #2\xintiloop_again\fi\xint_gobble_iii {#3}}%
\long\def\xintiloopskiptonext #1\xintiloop_again\fi\xint_gobble_iii #2#3{%
    \expandafter\xintiloop_again_b \the\numexpr#2+#3.#3.}%
\long\def\xintiloopskipandredo #1\xintiloop_again\fi\xint_gobble_iii #2#3#4{%
    #4\xintiloop_again\fi\xint_gobble_iii {#2}{#3}{#4}}%
%    \end{macrocode}
% \subsection{\csh{XINT_xflet}}
% \added[2013/10/29]{1.09e}
% We f-expand unbraced tokens and swallow arising
% space tokens until the dust settles.
%    \begin{macrocode}
\def\XINT_xflet #1%
{%
    \def\XINT_xflet_macro {#1}\XINT_xflet_zapsp
}%
\def\XINT_xflet_zapsp
{%
    \expandafter\futurelet\expandafter\XINT_token
    \expandafter\XINT_xflet_sp?\romannumeral`&&@%
}%
\def\XINT_xflet_sp?
{%
    \ifx\XINT_token\XINT_sptoken
         \expandafter\XINT_xflet_zapsp
    \else\expandafter\XINT_xflet_zapspB
    \fi
}%
\def\XINT_xflet_zapspB
{%
    \expandafter\futurelet\expandafter\XINT_tokenB
    \expandafter\XINT_xflet_spB?\romannumeral`&&@%
}%
\def\XINT_xflet_spB?
{%
    \ifx\XINT_tokenB\XINT_sptoken
         \expandafter\XINT_xflet_zapspB
    \else\expandafter\XINT_xflet_eq?
    \fi
}%
\def\XINT_xflet_eq?
{%
    \ifx\XINT_token\XINT_tokenB
         \expandafter\XINT_xflet_macro
    \else\expandafter\XINT_xflet_zapsp
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintApplyInline}}
% \added{1.09a}
%\begin{lverb}
% \xintApplyInline\macro{{a}{b}...{z}} has the same effect as
% executing \macro{a} and then applying again \xintApplyInline to the shortened
% list {{b}...{z}} until nothing is left. This is a non-expandable command
% which will result in quicker code than using \xintApplyUnbraced. It f-expands
% its second (list) argument first, which may thus be encapsulated in a macro.
%\end{lverb}
% \changed{1.09c}
% Rewritten. Nota bene: uses catcode 3 Z as privated list terminator.
%    \begin{macrocode}
\catcode`Z 3
\long\def\xintApplyInline #1#2%
{%
  \long\expandafter\def\expandafter\XINT_inline_macro
  \expandafter ##\expandafter 1\expandafter {#1{##1}}%
  \XINT_xflet\XINT_inline_b #2Z% this Z has catcode 3
}%
\def\XINT_inline_b
{%
    \ifx\XINT_token Z\expandafter\xint_gobble_i
    \else\expandafter\XINT_inline_d\fi
}%
\long\def\XINT_inline_d #1%
{%
  \long\def\XINT_item{{#1}}\XINT_xflet\XINT_inline_e
}%
\def\XINT_inline_e
{%
    \ifx\XINT_token Z\expandafter\XINT_inline_w
    \else\expandafter\XINT_inline_f\fi
}%
\def\XINT_inline_f
{%
  \expandafter\XINT_inline_g\expandafter{\XINT_inline_macro {##1}}%
}%
\long\def\XINT_inline_g #1%
{%
   \expandafter\XINT_inline_macro\XINT_item
   \long\def\XINT_inline_macro ##1{#1}\XINT_inline_d
}%
\def\XINT_inline_w #1%
{%
   \expandafter\XINT_inline_macro\XINT_item
}%
%    \end{macrocode}
% \subsection{\csh{xintFor}, \csh{xintFor*}, \csh{xintBreakFor}, \csh{xintBreakForAndDo}}
% \added[2013/10/09]{1.09c}
%\begin{lverb}
% A new kind of loop which uses macro parameters
% #1, #2, #3, #4 rather than macros; while not expandable it survives executing
% code closing groups, like what happens in an alignment with the $& character.
% When inserted in a macro for later use, the # character must be doubled.
%
% The non-star variant works on a csv list, which it expands once, the
% star variant works on a token list, which it (repeatedly) f-expands.
%\end{lverb}
% \changed{1.09e}
%\begin{lverb}
% Adds \XINT_forever with \xintintegers, \xintdimensions, \xintrationals
% and \xintBreakFor, \xintBreakForAndDo, \xintifForFirst, \xintifForLast. On
% this occasion \xint_firstoftwo and \xint_secondoftwo are made long.
%\end{lverb}
% \changed[2013/11/03]{1.09f}
%\begin{lverb}
% Rewrites large parts of \xintFor code in order to filter the comma
% separated list via \xintCSVtoList which gets rid of spaces. The #1 in
% \XINT_for_forever? has an initial space token which serves two purposes:
% preventing brace stripping, and stopping the expansion made by \xintcsvtolist.
% If the \XINT_forever branch is taken, the added space will not be a problem
% there.
%
% Now allows all macro parameters
% from #1 to #9 in \xintFor, \xintFor*, and \XINT_forever.
%\end{lverb}
% \changed{1.2i}
%\begin{lverb}
% Slightly more robust \xintifForFirst/Last in case of nesting.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_tmpa #1#2{\ifnum #2<#1 \xint_afterfi {{#########2}}\fi}%
\def\XINT_tmpb #1#2{\ifnum #1<#2 \xint_afterfi {{#########2}}\fi}%
\def\XINT_tmpc #1%
{%
    \expandafter\edef \csname XINT_for_left#1\endcsname
               {\xintApplyUnbraced {\XINT_tmpa #1}{123456789}}%
    \expandafter\edef \csname XINT_for_right#1\endcsname
               {\xintApplyUnbraced {\XINT_tmpb #1}{123456789}}%
}%
\xintApplyInline \XINT_tmpc {123456789}%
\long\def\xintBreakFor      #1Z{}%
\long\def\xintBreakForAndDo #1#2Z{#1}%
\def\xintFor {\let\xintifForFirst\xint_firstoftwo
              \let\xintifForLast\xint_secondoftwo
              \futurelet\XINT_token\XINT_for_ifstar }%
\def\XINT_for_ifstar {\ifx\XINT_token*\expandafter\XINT_forx
                                 \else\expandafter\XINT_for \fi }%
\catcode`U 3 % with numexpr
\catcode`V 3 % with xintfrac.sty (xint.sty not enough)
\catcode`D 3 % with dimexpr
\def\XINT_flet_zapsp
{%
    \futurelet\XINT_token\XINT_flet_sp?
}%
\def\XINT_flet_sp?
{%
    \ifx\XINT_token\XINT_sptoken
         \xint_afterfi{\expandafter\XINT_flet_zapsp\romannumeral0}%
    \else\expandafter\XINT_flet_macro
    \fi
}%
\long\def\XINT_for #1#2in#3#4#5%
{%
    \expandafter\XINT_toks\expandafter
        {\expandafter\XINT_for_d\the\numexpr #2\relax {#5}}%
    \def\XINT_flet_macro {\expandafter\XINT_for_forever?\space}%
    \expandafter\XINT_flet_zapsp #3Z%
}%
\def\XINT_for_forever? #1Z%
{%
    \ifx\XINT_token U\XINT_to_forever\fi
    \ifx\XINT_token V\XINT_to_forever\fi
    \ifx\XINT_token D\XINT_to_forever\fi
    \expandafter\the\expandafter\XINT_toks\romannumeral0\xintcsvtolist {#1}Z%
}%
\def\XINT_to_forever\fi #1\xintcsvtolist #2{\fi \XINT_forever #2}%
\long\def\XINT_forx *#1#2in#3#4#5%
{%
    \expandafter\XINT_toks\expandafter
       {\expandafter\XINT_forx_d\the\numexpr #2\relax {#5}}%
    \XINT_xflet\XINT_forx_forever? #3Z%
}%
\def\XINT_forx_forever?
{%
    \ifx\XINT_token U\XINT_to_forxever\fi
    \ifx\XINT_token V\XINT_to_forxever\fi
    \ifx\XINT_token D\XINT_to_forxever\fi
    \XINT_forx_empty?
}%
\def\XINT_to_forxever\fi #1\XINT_forx_empty? {\fi \XINT_forever }%
\catcode`U 11
\catcode`D 11
\catcode`V 11
\def\XINT_forx_empty?
{%
    \ifx\XINT_token Z\expandafter\xintBreakFor\fi
    \the\XINT_toks
}%
\long\def\XINT_for_d #1#2#3%
{%
  \long\def\XINT_y ##1##2##3##4##5##6##7##8##9{#2}%
  \XINT_toks {{#3}}%
  \long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
                     \the\XINT_toks   \csname XINT_for_right#1\endcsname }%
  \XINT_toks {\XINT_x\let\xintifForFirst\xint_secondoftwo
                     \let\xintifForLast\xint_secondoftwo\XINT_for_d #1{#2}}%
  \futurelet\XINT_token\XINT_for_last?
}%
\long\def\XINT_forx_d #1#2#3%
{%
  \long\def\XINT_y ##1##2##3##4##5##6##7##8##9{#2}%
  \XINT_toks {{#3}}%
  \long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
                     \the\XINT_toks   \csname XINT_for_right#1\endcsname }%
  \XINT_toks {\XINT_x\let\xintifForFirst\xint_secondoftwo
                     \let\xintifForLast\xint_secondoftwo\XINT_forx_d #1{#2}}%
  \XINT_xflet\XINT_for_last?
}%
\def\XINT_for_last?
{%
  \ifx\XINT_token Z\expandafter\XINT_for_last?yes\fi
  \the\XINT_toks
}%
\def\XINT_for_last?yes
{%
 \let\xintifForLast\xint_firstoftwo
 \xintBreakForAndDo{\XINT_x\xint_gobble_i Z}%
}%
%    \end{macrocode}
% \subsection{\csh{XINT_forever}, \csh{xintintegers}, \csh{xintdimensions}, \csh{xintrationals}}
% \added{1.09e}
% \changed{1.09f}
%\begin{lverb}
% The \xintrationals feature uses
% \xintiiadd/\xintiimul to avoid the overhead of the full-blown frac version
% \xintAdd and \xintMul. Also 1.09f uses
% \xintZapSpacesB in this \xintrationals case to get rid of leading and ending
% spaces in the #4 and #5 delimited parameters of \XINT_forever_opt_a.
% For \xintintegers and \xintdimensions this is not necessary, due to the use
% of \numexpr resp. \dimexpr in \XINT_?expr_Ua, resp.\XINT_?expr_Da.
%\end{lverb}
%    \begin{macrocode}
\catcode`U 3
\catcode`D 3
\catcode`V 3
\let\xintegers      U%
\let\xintintegers   U%
\let\xintdimensions D%
\let\xintrationals  V%
\def\XINT_forever #1%
{%
  \expandafter\XINT_forever_a
  \csname XINT_?expr_\ifx#1UU\else\ifx#1DD\else V\fi\fi a\expandafter\endcsname
  \csname XINT_?expr_\ifx#1UU\else\ifx#1DD\else V\fi\fi i\expandafter\endcsname
  \csname XINT_?expr_\ifx#1UU\else\ifx#1DD\else V\fi\fi \endcsname
}%
\catcode`U 11
\catcode`D 11
\catcode`V 11
\def\XINT_?expr_Ua #1#2%
   {\expandafter{\expandafter\numexpr\the\numexpr #1\expandafter\relax
                              \expandafter\relax\expandafter}%
    \expandafter{\the\numexpr #2}}%
\def\XINT_?expr_Da #1#2%
   {\expandafter{\expandafter\dimexpr\number\dimexpr #1\expandafter\relax
                 \expandafter s\expandafter p\expandafter\relax\expandafter}%
    \expandafter{\number\dimexpr #2}}%
\catcode`Z 11
\def\XINT_?expr_Va #1#2%
{%
    \expandafter\XINT_?expr_Vb\expandafter
          {\romannumeral`&&@\xintrawwithzeros{\xintZapSpacesB{#2}}}%
          {\romannumeral`&&@\xintrawwithzeros{\xintZapSpacesB{#1}}}%
}%
\catcode`Z 3
\def\XINT_?expr_Vb #1#2{\expandafter\XINT_?expr_Vc #2.#1.}%
\def\XINT_?expr_Vc #1/#2.#3/#4.%
{%
     \xintifEq {#2}{#4}%
       {\XINT_?expr_Vf {#3}{#1}{#2}}%
       {\expandafter\XINT_?expr_Vd\expandafter
        {\romannumeral0\xintiimul {#2}{#4}}%
        {\romannumeral0\xintiimul {#1}{#4}}%
        {\romannumeral0\xintiimul {#2}{#3}}%
       }%
}%
\def\XINT_?expr_Vd #1#2#3{\expandafter\XINT_?expr_Ve\expandafter {#2}{#3}{#1}}%
\def\XINT_?expr_Ve #1#2{\expandafter\XINT_?expr_Vf\expandafter {#2}{#1}}%
\def\XINT_?expr_Vf #1#2#3{{#2/#3}{{0}{#1}{#2}{#3}}}%
\def\XINT_?expr_Ui {{\numexpr 1\relax}{1}}%
\def\XINT_?expr_Di {{\dimexpr 0pt\relax}{65536}}%
\def\XINT_?expr_Vi {{1/1}{0111}}%
\def\XINT_?expr_U #1#2%
   {\expandafter{\expandafter\numexpr\the\numexpr #1+#2\relax\relax}{#2}}%
\def\XINT_?expr_D #1#2%
   {\expandafter{\expandafter\dimexpr\the\numexpr #1+#2\relax sp\relax}{#2}}%
\def\XINT_?expr_V #1#2{\XINT_?expr_Vx #2}%
\def\XINT_?expr_Vx #1#2%
{%
     \expandafter\XINT_?expr_Vy\expandafter
        {\romannumeral0\xintiiadd {#1}{#2}}{#2}%
}%
\def\XINT_?expr_Vy #1#2#3#4%
{%
     \expandafter{\romannumeral0\xintiiadd {#3}{#1}/#4}{{#1}{#2}{#3}{#4}}%
}%
\def\XINT_forever_a #1#2#3#4%
{%
    \ifx #4[\expandafter\XINT_forever_opt_a
       \else\expandafter\XINT_forever_b
    \fi #1#2#3#4%
}%
\def\XINT_forever_b #1#2#3Z{\expandafter\XINT_forever_c\the\XINT_toks #2#3}%
\long\def\XINT_forever_c #1#2#3#4#5%
    {\expandafter\XINT_forever_d\expandafter #2#4#5{#3}Z}%
\def\XINT_forever_opt_a #1#2#3[#4+#5]#6Z%
{%
    \expandafter\expandafter\expandafter
    \XINT_forever_opt_c\expandafter\the\expandafter\XINT_toks
    \romannumeral`&&@#1{#4}{#5}#3%
}%
\long\def\XINT_forever_opt_c #1#2#3#4#5#6{\XINT_forever_d #2{#4}{#5}#6{#3}Z}%
\long\def\XINT_forever_d #1#2#3#4#5%
{%
  \long\def\XINT_y ##1##2##3##4##5##6##7##8##9{#5}%
  \XINT_toks {{#2}}%
  \long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
                     \the\XINT_toks   \csname XINT_for_right#1\endcsname }%
  \XINT_x
  \let\xintifForFirst\xint_secondoftwo
  \let\xintifForLast\xint_secondoftwo
  \expandafter\XINT_forever_d\expandafter #1\romannumeral`&&@#4{#2}{#3}#4{#5}%
}%
%    \end{macrocode}
% \subsection{\csh{xintForpair}, \csh{xintForthree}, \csh{xintForfour}}
% \added{1.09c}
% \changed[2013/11/02]{1.09f}
%\begin{lverb}
% \xintForpair delegate to \xintCSVtoList and its
% \xintZapSpacesB the handling of spaces. Does not share code with \xintFor
% anymore.
%
% \xintForpair extended to accept #1#2, #2#3 etc... up to
% #8#9, \xintForthree, #1#2#3 up to #7#8#9, \xintForfour id.
%\end{lverb}
% \changed{1.2i}
%\begin{lverb}
% Slightly more robust \xintifForFirst/\xintifForLast in case of nesting.
%\end{lverb}
% \changed[2025/06/08]{1.4n}
%\begin{lverb}
% Allow one final extraneous comma (formerly, such input caused a crash).
% This goes via testing an extra token #6, which should be an opening parenthesis.
% The potential brace removal changes behavior for illegal inputs.
% Successive commas in the input list are still not allowed.
%\end{lverb}
%    \begin{macrocode}
\catcode`j 3
\long\def\xintForpair #1#2#3in#4#5#6%
{%
    \let\xintifForFirst\xint_firstoftwo
    \let\xintifForLast\xint_secondoftwo
    \XINT_toks  {\XINT_forpair_d #2{#6}}%
    \expandafter\the\expandafter\XINT_toks #4jZ%
}%
\long\def\XINT_forpair_d #1#2#3(#4)#5#6%
{%
  \long\def\XINT_y ##1##2##3##4##5##6##7##8##9{#2}%
  \XINT_toks \expandafter{\romannumeral0\xintcsvtolist{ #4}}%
  \long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
      \the\XINT_toks \csname XINT_for_right\the\numexpr#1+\xint_c_i\endcsname}%
  \if1\ifx #5j1\else\ifx#6j1\else0\fi\fi\expandafter\XINT_for_last?yes\fi
  \XINT_x
  \let\xintifForFirst\xint_secondoftwo
  \let\xintifForLast\xint_secondoftwo
  \XINT_forpair_d #1{#2}#6%
}%
\long\def\xintForthree #1#2#3in#4#5#6%
{%
    \let\xintifForFirst\xint_firstoftwo
    \let\xintifForLast\xint_secondoftwo
    \XINT_toks  {\XINT_forthree_d #2{#6}}%
    \expandafter\the\expandafter\XINT_toks #4jZ%
}%
\long\def\XINT_forthree_d #1#2#3(#4)#5#6%
{%
  \long\def\XINT_y ##1##2##3##4##5##6##7##8##9{#2}%
  \XINT_toks \expandafter{\romannumeral0\xintcsvtolist{ #4}}%
  \long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
      \the\XINT_toks \csname XINT_for_right\the\numexpr#1+\xint_c_ii\endcsname}%
  \if1\ifx #5j1\else\ifx#6j1\else0\fi\fi\expandafter\XINT_for_last?yes\fi
  \XINT_x
  \let\xintifForFirst\xint_secondoftwo
  \let\xintifForLast\xint_secondoftwo
  \XINT_forthree_d #1{#2}#6%
}%
\long\def\xintForfour #1#2#3in#4#5#6%
{%
    \let\xintifForFirst\xint_firstoftwo
    \let\xintifForLast\xint_secondoftwo
    \XINT_toks  {\XINT_forfour_d #2{#6}}%
    \expandafter\the\expandafter\XINT_toks #4jZ%
}%
\long\def\XINT_forfour_d #1#2#3(#4)#5#6%
{%
  \long\def\XINT_y ##1##2##3##4##5##6##7##8##9{#2}%
  \XINT_toks \expandafter{\romannumeral0\xintcsvtolist{ #4}}%
  \long\edef\XINT_x {\noexpand\XINT_y \csname XINT_for_left#1\endcsname
     \the\XINT_toks \csname XINT_for_right\the\numexpr#1+\xint_c_iii\endcsname}%
  \if1\ifx #5j1\else\ifx#6j1\else0\fi\fi\expandafter\XINT_for_last?yes\fi
  \XINT_x
  \let\xintifForFirst\xint_secondoftwo
  \let\xintifForLast\xint_secondoftwo
  \XINT_forfour_d #1{#2}#6%
}%
\catcode`Z 11
\catcode`j 11
%    \end{macrocode}
% \subsection{\csh{xintAssign}}
%\begin{lverb}
% \xintAssign {a}{b}..{z}\to\A\B...\Z
%\end{lverb}
% \changed[2015/09/12]{1.1c}
%\begin{lverb}
% Belatedly corrects some "features" of
% \xintAssign which didn't like the case of a space right before the "\to", or
% the case with the first token not an opening brace and the subsequent
% material containing brace groups. The new code handles gracefully these
% situations.
%\end{lverb}
%    \begin{macrocode}
\def\xintAssign{\def\XINT_flet_macro {\XINT_assign_fork}\XINT_flet_zapsp }%
\def\XINT_assign_fork
{%
    \let\XINT_assign_def\def
    \ifx\XINT_token[\expandafter\XINT_assign_opt
               \else\expandafter\XINT_assign_a
    \fi
}%
\def\XINT_assign_opt [#1]%
{%
    \ifcsname #1def\endcsname
      \expandafter\let\expandafter\XINT_assign_def \csname #1def\endcsname
    \else
      \expandafter\let\expandafter\XINT_assign_def \csname xint#1def\endcsname
    \fi
    \XINT_assign_a
}%
\long\def\XINT_assign_a #1\to
{%
    \def\XINT_flet_macro{\XINT_assign_b}%
    \expandafter\XINT_flet_zapsp\romannumeral`&&@#1\xint:\to
}%
\long\def\XINT_assign_b
{%
    \ifx\XINT_token\bgroup
         \expandafter\XINT_assign_c
    \else\expandafter\XINT_assign_f
    \fi
}%
\long\def\XINT_assign_f #1\xint:\to #2%
{%
    \XINT_assign_def #2{#1}%
}%
\long\def\XINT_assign_c #1%
{%
    \def\XINT_assign_tmp {#1}%
    \ifx\XINT_assign_tmp\xint_bracedstopper
        \expandafter\XINT_assign_e
    \else
        \expandafter\XINT_assign_d
    \fi
}%
\long\def\XINT_assign_d #1\to #2%
{%
    \expandafter\XINT_assign_def\expandafter #2\expandafter{\XINT_assign_tmp}%
    \XINT_assign_c #1\to
}%
\def\XINT_assign_e #1\to {}%
\def\xintRelaxArray #1%
{%
    \edef\XINT_restoreescapechar {\escapechar\the\escapechar\relax}%
    \escapechar -1
    \expandafter\def\expandafter\xint_arrayname\expandafter {\string #1}%
    \XINT_restoreescapechar
    \xintiloop [\csname\xint_arrayname 0\endcsname+-1]
      \global
      \expandafter\let\csname\xint_arrayname\xintiloopindex\endcsname\relax
      \ifnum \xintiloopindex > \xint_c_
    \repeat
    \global\expandafter\let\csname\xint_arrayname 00\endcsname\relax
    \global\let #1\relax
}%
%    \end{macrocode}
% \subsection{\csh{xintAssignArray}, \csh{xintDigitsOf}}
%\begin{lverb}
% \xintAssignArray {a}{b}..{z}\to\U.
%
% \xintDigitsOf=\xintAssignArray.
%\end{lverb}
% \changed{1.4p}
% Allow usage of the array macro with a negative index.
%    \begin{macrocode}
\def\xintAssignArray{\def\XINT_flet_macro {\XINT_assignarray_fork}%
                     \XINT_flet_zapsp }%
\def\XINT_assignarray_fork
{%
    \let\XINT_assignarray_def\def
    \ifx\XINT_token[\expandafter\XINT_assignarray_opt
               \else\expandafter\XINT_assignarray
    \fi
}%
\def\XINT_assignarray_opt [#1]%
{%
    \ifcsname #1def\endcsname
      \expandafter\let\expandafter\XINT_assignarray_def \csname #1def\endcsname
    \else
      \expandafter\let\expandafter\XINT_assignarray_def
                                  \csname xint#1def\endcsname
    \fi
    \XINT_assignarray
}%
%    \end{macrocode}
% Very old code got refactored at |1.4p|.  Hesitation about using |\XINT_tmpa|
% or like here potential ganer is used by caller.
%    \begin{macrocode}
\long\def\XINT_assignarray #1\to #2%
{%
    \edef\XINT_restoreescapechar {\escapechar\the\escapechar\relax }%
    \escapechar -1
    \expandafter\def\expandafter\XINT_arrayname\expandafter {\string #2}%
    \XINT_restoreescapechar
    \def\XINT_itemcount {0}%
    \expandafter\XINT_assignarray_loop \romannumeral`&&@#1\xint:#2%
}%
\long\def\XINT_assignarray_loop #1%
{%
    \def\XINT_assign_tmp {#1}%
    \ifx\XINT_assign_tmp\xint_bracedstopper
       \expandafter\let\csname\XINT_arrayname0\endcsname\XINT_itemcount
       \expandafter\XINT_assignarray_end
    \else
       \edef\XINT_itemcount{\the\numexpr\XINT_itemcount+\xint_c_i}%
       \expandafter\XINT_assignarray_def
       \csname\XINT_arrayname\XINT_itemcount\expandafter\endcsname
                                            \expandafter{\XINT_assign_tmp }%
       \expandafter\XINT_assignarray_loop
    \fi
}%
%    \end{macrocode}
% \changed{1.4p} Allow negative index, handled as in Python
% (positive index retains former meaning, i.e.\@ starts at 1).
%
% This very old code from 2013 got refactored on this occasion.  Code style
% hackier. A bit annoying though that |\expandafter\expandafter\expandafter|,
% because of |\csname|.  Would have been easier to incorporate the terminator
% in the |\foo<N>| macro itself but I feared this would be too unexpected in
% case of needs of some direct hacking.
%
% On this occasion the number of items, which is used by |\foo| to test
% if the index is out of range is now present via its explicit tokens
% rather than via encapsulation |\foo0|.
%
%\begin{lverb}
% #4 is \foo, #3 is foo, #2 is the number of items, and #1 is \foo00.
% The Nth item is in \foo<N>.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_assignarray_end
{%
    \expandafter\XINT_assignarray_endend
    \csname\XINT_arrayname00\expandafter\endcsname
    \expanded{{\XINT_itemcount}{\XINT_arrayname}}%
}%
\def\XINT_assignarray_endend #1#2#3#4%
{%
    \def #4##1%
    {%
        \romannumeral\expandafter\expandafter\expandafter
        \xint_c_\csname\expandafter#1\the\numexpr ##1.%
    }%
    \def #1##1##2.%
    {%
        \ifnum\if-##1\else##1\fi##2>#2
            \expanded{\noexpand\XINT_expandableerror
        {Illegal index ##1##2 (\if-##1< -\else> \fi #2) for \string#4}}%
            empty%
        \else
            #3\if-##1\the\numexpr\xint_c_i+#2\fi
            ##1##2%
        \fi
        \endcsname
    }%
}%
\let\xintDigitsOf\xintAssignArray
%    \end{macrocode}
% \subsection{CSV (non user documented) variants of Length, Keep, Trim, NthElt, Reverse}
% \changed{1.2j}
% These routines are for use by |\xintListSel:x:csv| and |\xintListSel:f:csv|
% from \xintexprnameimp, and also for the |reversed| and |len| functions.
% Refactored for |1.2j| release, following |1.2i| updates to |\xintKeep|,
% |\xintTrim|, ...
% 
% These macros will remain undocumented in the user manual:
%
% -- they exist primarily for internal use by the \xintexprnameimp parsers,
% hence don't have to be general purpose; for example, they a priori need to
% handle only catcode 12 tokens (not true in |\xintNewExpr|, though)
% hence they are not really worried about
% controlling brace stripping (nevertheless |1.2j| has paid some secondary
% attention to it, see below.) They are not worried about normalizing leading
% spaces either, because none will be encountered when the macros are used as
% auxiliaries to the expression parsers.
%
% -- crucial design elements may change in future:
%
% 1. whether the handled lists must have or not have a final comma. Currently,
% the model is the one of comma separated lists with **no** final comma. But
% this means that there can not be a distinction of principle between a truly
% empty list and a list which contains one item which turns out to be empty.
% More importantly it makes the coding more complicated as it is needed to
% distinguish the empty list from the single-item list, both lacking commas.
%
% For the internal use of \xintexprnameimp, it would be ok to require all list
% items to be terminated by a comma, and this would bring quite some
% simplications here, but as initially I started with non-terminated lists, I
% have left it this way in the |1.2j| refactoring.
%
% 2. the way to represent the empty list. I was tempted for matter of
% optimization and synchronization with \xintexprnameimp context to require
% the empty list to be always represented by a space token and to not let the
% macros admit a completely empty input. But there were complications so for
% the time being |1.2j| does accept truly empty output (it is not
% distinguished from an input equal to a space token) and produces empty
% output for empty list. This means that the status of the «nil» object for
% the \xintexprnameimp parsers is not completely clarified (currently it is
% represented by a space token).
%
% The original Python slicing code in \xintexprnameimp |1.1| used
% |\xintCSVtoList| and |\xintListWithSep{,}| to convert back and forth to
% token lists and apply |\xintKeep/\xintTrim|. Release |1.2g| switched to
% devoted f-expandable macros added to \xinttoolsnameimp. Release |1.2j|
% refactored all these macros as a follow-up to |1.2i| improvements to
% |\xintKeep/\xintTrim|. They were made |\long| on this occasion and
% auxiliary |\xintLengthUpTo:f:csv| was added.
%
% Leading spaces in items are currently maintained as is by the |1.2j|
% macros, even by |\xintNthEltPy:f:csv|, with the exception of the first item,
% as the list is f-expanded. Perhaps |\xintNthEltPy:f:csv| should remove a
% leading space if present in the picked item; anyway, there are no spaces
% for the lists handled internally by the Python slicer of \xintexprnameimp,
% except the «nil» object currently represented by exactly one space.
%
% Kept items (with no leading spaces; but first item special as it will have
% lost a leading space due to f-expansion) will lose a brace pair under
% |\xintKeep:f:csv| if the first argument was positive and strictly less than
% the length of the list. This differs of course from |\xintKeep| (which
% always braces items it outputs when used with positive first argument) and
% also from |\xintKeepUnbraced| in the case when the whole list is kept.
% Actually the case of singleton list is special, and brace removal will
% happen then.
%
% This behaviour was otherwise for releases earlier than |1.2j| and may
% change again.
% 
% Directly usable names are provided, but these macros (and the behaviour as
% described above) are to be considered \emph{unstable} for the time being.
%
% \subsubsection{\csh{xintLength:f:csv}}
% \added{1.2g}
% \changed{1.2j}
% Contrarily to |\xintLength| from \xintkernelnameimp
% this one expands its argument.
%    \begin{macrocode}
\def\xintLength:f:csv {\romannumeral0\xintlength:f:csv}%
\def\xintlength:f:csv #1%
{\long\def\xintlength:f:csv ##1{%
    \expandafter#1\the\numexpr\expandafter\XINT_length:f:csv_a
    \romannumeral`&&@##1\xint:,\xint:,\xint:,\xint:,%
      \xint:,\xint:,\xint:,\xint:,\xint:,%
      \xint_c_ix,\xint_c_viii,\xint_c_vii,\xint_c_vi,%
      \xint_c_v,\xint_c_iv,\xint_c_iii,\xint_c_ii,\xint_c_i,\xint_bye
    \relax
}}\xintlength:f:csv { }%
%    \end{macrocode}
%\begin{lverb}
% Must first check if empty list.
%\end{lverb}
%    \begin{macrocode}
\long\def\XINT_length:f:csv_a #1%
{% 
    \xint_gob_til_xint: #1\xint_c_\xint_bye\xint:%
    \XINT_length:f:csv_loop #1%
}%
\long\def\XINT_length:f:csv_loop #1,#2,#3,#4,#5,#6,#7,#8,#9,%
{%
    \xint_gob_til_xint: #9\XINT_length:f:csv_finish\xint:%
    \xint_c_ix+\XINT_length:f:csv_loop
}%
\def\XINT_length:f:csv_finish\xint:\xint_c_ix+\XINT_length:f:csv_loop
    #1,#2,#3,#4,#5,#6,#7,#8,#9,{#9\xint_bye}%
%    \end{macrocode}
% \subsubsection{\csh{xintLengthUpTo:f:csv}}
% \added{1.2j}
%\begin{lverb}
% \added{1.2j}\xintLengthUpTo:f:csv{N}{comma-list}. No ending comma. Returns
% -0 if length>N, else returns difference N-length. **N must be non-negative!!**
% 
% Attention to the dot after \xint_bye for the loop interface.
%\end{lverb}
%    \begin{macrocode}
\def\xintLengthUpTo:f:csv {\romannumeral0\xintlengthupto:f:csv}%
\long\def\xintlengthupto:f:csv #1#2%
{%
    \expandafter\XINT_lengthupto:f:csv_a
    \the\numexpr#1\expandafter.%
    \romannumeral`&&@#2\xint:,\xint:,\xint:,\xint:,%
         \xint:,\xint:,\xint:,\xint:,%
         \xint_c_viii,\xint_c_vii,\xint_c_vi,\xint_c_v,%
         \xint_c_iv,\xint_c_iii,\xint_c_ii,\xint_c_i,\xint_bye.%
}%
%    \end{macrocode}
%\begin{lverb}
% Must first recognize if empty list. If this is the case, return N.
%\end{lverb}
%    \begin{macrocode}
\long\def\XINT_lengthupto:f:csv_a #1.#2%
{%
    \xint_gob_til_xint: #2\XINT_lengthupto:f:csv_empty\xint:%
    \XINT_lengthupto:f:csv_loop_b #1.#2%
}%
\def\XINT_lengthupto:f:csv_empty\xint:%
    \XINT_lengthupto:f:csv_loop_b #1.#2\xint_bye.{ #1}%
\def\XINT_lengthupto:f:csv_loop_a #1%
{%
    \xint_UDsignfork
      #1\XINT_lengthupto:f:csv_gt
       -\XINT_lengthupto:f:csv_loop_b
    \krof #1%
}%
\long\def\XINT_lengthupto:f:csv_gt #1\xint_bye.{-0}%
\long\def\XINT_lengthupto:f:csv_loop_b #1.#2,#3,#4,#5,#6,#7,#8,#9,%
{%
    \xint_gob_til_xint: #9\XINT_lengthupto:f:csv_finish_a\xint:%
    \expandafter\XINT_lengthupto:f:csv_loop_a\the\numexpr #1-\xint_c_viii.%
}%
\def\XINT_lengthupto:f:csv_finish_a\xint:
    \expandafter\XINT_lengthupto:f:csv_loop_a
    \the\numexpr #1-\xint_c_viii.#2,#3,#4,#5,#6,#7,#8,#9,%
{%
    \expandafter\XINT_lengthupto:f:csv_finish_b\the\numexpr #1-#9\xint_bye
}%
\def\XINT_lengthupto:f:csv_finish_b #1#2.%
{%
    \xint_UDsignfork
       #1{-0}%
        -{ #1#2}%
    \krof
}%
%    \end{macrocode}
% \subsubsection{\csh{xintKeep:f:csv}}
% \added[2016/03/17]{1.2g}
% \changed{1.2j}
%\begin{lverb}
% Redone with use of \xintLengthUpTo:f:csv.
% Same code skeleton as \xintKeep but handling comma separated but non
% terminated lists has complications. The \xintKeep in case of a negative #1
% uses \xintgobble, we don't have that for comma delimited items, hence we do
% a special loop here (this style of loop is surely competitive with
% xintgobble for a few dozens items and even more). The loop knows before
% starting that it will not go too far.
%
%\end{lverb}
%    \begin{macrocode}
\def\xintKeep:f:csv {\romannumeral0\xintkeep:f:csv }%
\long\def\xintkeep:f:csv #1#2%
{%
    \expandafter\xint_stop_aftergobble
    \romannumeral0\expandafter\XINT_keep:f:csv_a
    \the\numexpr #1\expandafter.\expandafter{\romannumeral`&&@#2}%
}%
\def\XINT_keep:f:csv_a #1%
{%
    \xint_UDzerominusfork
        #1-\XINT_keep:f:csv_keepnone
        0#1\XINT_keep:f:csv_neg
         0-{\XINT_keep:f:csv_pos #1}%
    \krof
}%
\long\def\XINT_keep:f:csv_keepnone .#1{,}%
\long\def\XINT_keep:f:csv_neg #1.#2%
{%
    \expandafter\XINT_keep:f:csv_neg_done\expandafter,%
    \romannumeral0%
    \expandafter\XINT_keep:f:csv_neg_a\the\numexpr
    #1-\numexpr\XINT_length:f:csv_a
    #2\xint:,\xint:,\xint:,\xint:,%
      \xint:,\xint:,\xint:,\xint:,\xint:,%
      \xint_c_ix,\xint_c_viii,\xint_c_vii,\xint_c_vi,%
      \xint_c_v,\xint_c_iv,\xint_c_iii,\xint_c_ii,\xint_c_i,\xint_bye
    .#2\xint_bye
}%
\def\XINT_keep:f:csv_neg_a #1%
{%
    \xint_UDsignfork
        #1{\expandafter\XINT_keep:f:csv_trimloop\the\numexpr-\xint_c_ix+}%
         -\XINT_keep:f:csv_keepall
    \krof
}%
\def\XINT_keep:f:csv_keepall #1.{ }%
\long\def\XINT_keep:f:csv_neg_done #1\xint_bye{#1}%
\def\XINT_keep:f:csv_trimloop #1#2.%
{%
    \xint_gob_til_minus#1\XINT_keep:f:csv_trimloop_finish-%
    \expandafter\XINT_keep:f:csv_trimloop
    \the\numexpr#1#2-\xint_c_ix\expandafter.\XINT_keep:f:csv_trimloop_trimnine
}%
\long\def\XINT_keep:f:csv_trimloop_trimnine #1,#2,#3,#4,#5,#6,#7,#8,#9,{}%
\def\XINT_keep:f:csv_trimloop_finish-%
    \expandafter\XINT_keep:f:csv_trimloop
    \the\numexpr-#1-\xint_c_ix\expandafter.\XINT_keep:f:csv_trimloop_trimnine
    {\csname XINT_trim:f:csv_finish#1\endcsname}%
\long\def\XINT_keep:f:csv_pos #1.#2%
{%
    \expandafter\XINT_keep:f:csv_pos_fork
    \romannumeral0\XINT_lengthupto:f:csv_a
    #1.#2\xint:,\xint:,\xint:,\xint:,%
         \xint:,\xint:,\xint:,\xint:,%
         \xint_c_viii,\xint_c_vii,\xint_c_vi,\xint_c_v,%
         \xint_c_iv,\xint_c_iii,\xint_c_ii,\xint_c_i,\xint_bye.%
    .#1.{}#2\xint_bye%
}%
\def\XINT_keep:f:csv_pos_fork #1#2.%
{%
    \xint_UDsignfork
      #1{\expandafter\XINT_keep:f:csv_loop\the\numexpr-\xint_c_viii+}%
       -\XINT_keep:f:csv_pos_keepall
    \krof
}%
\long\def\XINT_keep:f:csv_pos_keepall #1.#2#3\xint_bye{,#3}%
\def\XINT_keep:f:csv_loop #1#2.%
{%
    \xint_gob_til_minus#1\XINT_keep:f:csv_loop_end-%
    \expandafter\XINT_keep:f:csv_loop
    \the\numexpr#1#2-\xint_c_viii\expandafter.\XINT_keep:f:csv_loop_pickeight
}%
\long\def\XINT_keep:f:csv_loop_pickeight 
     #1#2,#3,#4,#5,#6,#7,#8,#9,{{#1,#2,#3,#4,#5,#6,#7,#8,#9}}%
\def\XINT_keep:f:csv_loop_end-\expandafter\XINT_keep:f:csv_loop
    \the\numexpr-#1-\xint_c_viii\expandafter.\XINT_keep:f:csv_loop_pickeight
    {\csname XINT_keep:f:csv_end#1\endcsname}%
\long\expandafter\def\csname XINT_keep:f:csv_end1\endcsname
   #1#2,#3,#4,#5,#6,#7,#8,#9\xint_bye {#1,#2,#3,#4,#5,#6,#7,#8}%
\long\expandafter\def\csname XINT_keep:f:csv_end2\endcsname
   #1#2,#3,#4,#5,#6,#7,#8\xint_bye {#1,#2,#3,#4,#5,#6,#7}%
\long\expandafter\def\csname XINT_keep:f:csv_end3\endcsname
   #1#2,#3,#4,#5,#6,#7\xint_bye {#1,#2,#3,#4,#5,#6}%
\long\expandafter\def\csname XINT_keep:f:csv_end4\endcsname
   #1#2,#3,#4,#5,#6\xint_bye {#1,#2,#3,#4,#5}%
\long\expandafter\def\csname XINT_keep:f:csv_end5\endcsname
   #1#2,#3,#4,#5\xint_bye {#1,#2,#3,#4}%
\long\expandafter\def\csname XINT_keep:f:csv_end6\endcsname
   #1#2,#3,#4\xint_bye {#1,#2,#3}%
\long\expandafter\def\csname XINT_keep:f:csv_end7\endcsname
   #1#2,#3\xint_bye {#1,#2}%
\long\expandafter\def\csname XINT_keep:f:csv_end8\endcsname
   #1#2\xint_bye {#1}%
%    \end{macrocode}
% \subsubsection{\csh{xintTrim:f:csv}}
% \added[2016/03/17]{1.2g}
% \changed[2016/12/20]{1.2j}
% Redone on the basis of new |\xintTrim|.
%    \begin{macrocode}
\def\xintTrim:f:csv {\romannumeral0\xinttrim:f:csv }%
\long\def\xinttrim:f:csv #1#2%
{%
    \expandafter\xint_stop_aftergobble
    \romannumeral0\expandafter\XINT_trim:f:csv_a
    \the\numexpr #1\expandafter.\expandafter{\romannumeral`&&@#2}%
}%
\def\XINT_trim:f:csv_a #1%
{%
    \xint_UDzerominusfork
        #1-\XINT_trim:f:csv_trimnone
        0#1\XINT_trim:f:csv_neg
         0-{\XINT_trim:f:csv_pos #1}%
    \krof
}%
\long\def\XINT_trim:f:csv_trimnone .#1{,#1}%
\long\def\XINT_trim:f:csv_neg #1.#2%
{%
    \expandafter\XINT_trim:f:csv_neg_a\the\numexpr
    #1-\numexpr\XINT_length:f:csv_a
    #2\xint:,\xint:,\xint:,\xint:,%
      \xint:,\xint:,\xint:,\xint:,\xint:,%
      \xint_c_ix,\xint_c_viii,\xint_c_vii,\xint_c_vi,%
      \xint_c_v,\xint_c_iv,\xint_c_iii,\xint_c_ii,\xint_c_i,\xint_bye
    .{}#2\xint_bye
}%
\def\XINT_trim:f:csv_neg_a #1%
{%
    \xint_UDsignfork
        #1{\expandafter\XINT_keep:f:csv_loop\the\numexpr-\xint_c_viii+}%
         -\XINT_trim:f:csv_trimall
    \krof
}%
\def\XINT_trim:f:csv_trimall {\expandafter,\xint_bye}%
\long\def\XINT_trim:f:csv_pos #1.#2%
{%
    \expandafter\XINT_trim:f:csv_pos_done\expandafter,%
    \romannumeral0%
    \expandafter\XINT_trim:f:csv_loop\the\numexpr#1-\xint_c_ix.%
     #2\xint:,\xint:,\xint:,\xint:,\xint:,%
       \xint:,\xint:,\xint:,\xint:,\xint:\xint_bye
}%
\def\XINT_trim:f:csv_loop #1#2.%
{%
    \xint_gob_til_minus#1\XINT_trim:f:csv_finish-%
    \expandafter\XINT_trim:f:csv_loop\the\numexpr#1#2\XINT_trim:f:csv_loop_trimnine
}%
\long\def\XINT_trim:f:csv_loop_trimnine #1,#2,#3,#4,#5,#6,#7,#8,#9,%
{%
    \xint_gob_til_xint: #9\XINT_trim:f:csv_toofew\xint:-\xint_c_ix.%
}%
\def\XINT_trim:f:csv_toofew\xint:{*\xint_c_}%
\def\XINT_trim:f:csv_finish-%
    \expandafter\XINT_trim:f:csv_loop\the\numexpr-#1\XINT_trim:f:csv_loop_trimnine
{%
    \csname XINT_trim:f:csv_finish#1\endcsname
}%
\long\expandafter\def\csname XINT_trim:f:csv_finish1\endcsname
  #1,#2,#3,#4,#5,#6,#7,#8,{ }%
\long\expandafter\def\csname XINT_trim:f:csv_finish2\endcsname
  #1,#2,#3,#4,#5,#6,#7,{ }%
\long\expandafter\def\csname XINT_trim:f:csv_finish3\endcsname
  #1,#2,#3,#4,#5,#6,{ }%
\long\expandafter\def\csname XINT_trim:f:csv_finish4\endcsname
  #1,#2,#3,#4,#5,{ }%
\long\expandafter\def\csname XINT_trim:f:csv_finish5\endcsname
  #1,#2,#3,#4,{ }%
\long\expandafter\def\csname XINT_trim:f:csv_finish6\endcsname
  #1,#2,#3,{ }%
\long\expandafter\def\csname XINT_trim:f:csv_finish7\endcsname
  #1,#2,{ }%
\long\expandafter\def\csname XINT_trim:f:csv_finish8\endcsname
  #1,{ }%
\expandafter\let\csname XINT_trim:f:csv_finish9\endcsname\space
\long\def\XINT_trim:f:csv_pos_done #1\xint:#2\xint_bye{#1}%
%    \end{macrocode}
% \subsubsection{\csh{xintNthEltPy:f:csv}}
%\begin{lverb}
% Counts like Python starting at zero. Last refactored with 1.2j.
% Attention, makes currently no effort at removing leading spaces in the
% picked item.
%\end{lverb}
%    \begin{macrocode}
\def\xintNthEltPy:f:csv {\romannumeral0\xintntheltpy:f:csv }%
\long\def\xintntheltpy:f:csv #1#2%
{%
   \expandafter\XINT_nthelt:f:csv_a
   \the\numexpr #1\expandafter.\expandafter{\romannumeral`&&@#2}%
}%
\def\XINT_nthelt:f:csv_a #1%
{%
    \xint_UDsignfork
        #1\XINT_nthelt:f:csv_neg
         -\XINT_nthelt:f:csv_pos
    \krof #1%
}%
\long\def\XINT_nthelt:f:csv_neg -#1.#2%
{%
    \expandafter\XINT_nthelt:f:csv_neg_fork
    \the\numexpr\XINT_length:f:csv_a
    #2\xint:,\xint:,\xint:,\xint:,%
      \xint:,\xint:,\xint:,\xint:,\xint:,%
      \xint_c_ix,\xint_c_viii,\xint_c_vii,\xint_c_vi,%
      \xint_c_v,\xint_c_iv,\xint_c_iii,\xint_c_ii,\xint_c_i,\xint_bye
    -#1.#2,\xint_bye
}%
\def\XINT_nthelt:f:csv_neg_fork #1%
{%
    \if#1-\expandafter\xint_stop_afterbye\fi
    \expandafter\XINT_nthelt:f:csv_neg_done
    \romannumeral0%
    \expandafter\XINT_keep:f:csv_trimloop\the\numexpr-\xint_c_ix+#1%
}%
\long\def\XINT_nthelt:f:csv_neg_done#1,#2\xint_bye{ #1}%
\long\def\XINT_nthelt:f:csv_pos #1.#2%
{%
    \expandafter\XINT_nthelt:f:csv_pos_done
    \romannumeral0%
    \expandafter\XINT_trim:f:csv_loop\the\numexpr#1-\xint_c_ix.%
    #2\xint:,\xint:,\xint:,\xint:,\xint:,%
       \xint:,\xint:,\xint:,\xint:,\xint:,\xint_bye
}%
\def\XINT_nthelt:f:csv_pos_done #1{%
\long\def\XINT_nthelt:f:csv_pos_done ##1,##2\xint_bye{%
  \xint_gob_til_xint:##1\XINT_nthelt:f:csv_pos_cleanup\xint:#1##1}%
}\XINT_nthelt:f:csv_pos_done{ }%
%    \end{macrocode}
%\begin{lverb}
% This strange thing is in case the picked item was the last one, hence
% there was an ending \xint: (we could not put a comma earlier for
% matters of not confusing empty list with a singleton list), and we do this
% here to activate brace-stripping of item as all other items may be
% brace-stripped if picked. This is done for coherence. Of course, in the
% context of the xintexpr.sty parsers, there are no braces in list items...
%\end{lverb}
%    \begin{macrocode}
\xint_firstofone{\long\def\XINT_nthelt:f:csv_pos_cleanup\xint:} %
   #1\xint:{ #1}%
%    \end{macrocode}
% \subsubsection{\csh{xintReverse:f:csv}}
% \added[2016/03/17]{1.2g}
%\begin{lverb}
% Contrarily to \xintReverseOrder from xintkernel.sty, this
% one expands its argument. Handles empty list too. .
%\end{lverb}
% \changed{1.2j} Made |\long|.
%    \begin{macrocode}
\def\xintReverse:f:csv {\romannumeral0\xintreverse:f:csv }%
\long\def\xintreverse:f:csv #1%
{%
    \expandafter\XINT_reverse:f:csv_loop
    \expandafter{\expandafter}\romannumeral`&&@#1,%
      \xint:,%
        \xint_bye,\xint_bye,\xint_bye,\xint_bye,%
        \xint_bye,\xint_bye,\xint_bye,\xint_bye,%
      \xint:
}%
\long\def\XINT_reverse:f:csv_loop #1#2,#3,#4,#5,#6,#7,#8,#9,%
{%
    \xint_bye #9\XINT_reverse:f:csv_cleanup\xint_bye
    \XINT_reverse:f:csv_loop {,#9,#8,#7,#6,#5,#4,#3,#2#1}%
}%
\long\def\XINT_reverse:f:csv_cleanup\xint_bye\XINT_reverse:f:csv_loop #1#2\xint:
{%
    \XINT_reverse:f:csv_finish #1%
}%
\long\def\XINT_reverse:f:csv_finish #1\xint:,{ }%
%    \end{macrocode}
% \subsubsection{\csh{xintFirstItem:f:csv}}
% \added{1.2k}
%\begin{lverb}
% For use by first() in
% \xintexpr-essions, and some amount of compatibility with \xintNewExpr.
%\end{lverb}
%    \begin{macrocode}
\def\xintFirstItem:f:csv {\romannumeral0\xintfirstitem:f:csv}%
\long\def\xintfirstitem:f:csv #1%
{%
    \expandafter\XINT_first:f:csv_a\romannumeral`&&@#1,\xint_bye
}%
\long\def\XINT_first:f:csv_a #1,#2\xint_bye{ #1}%
%    \end{macrocode}
% \subsubsection{\csh{xintLastItem:f:csv}}
% \added{1.2k}
%\begin{lverb}
% Based on and sharing code with xintkernel's
% \xintLastItem from 1.2i. Output empty if input empty. f-expands its argument
% (hence first item, if not protected.) For use by last() in
% \xintexpr-essions with to some extent \xintNewExpr compatibility.
%\end{lverb}
%    \begin{macrocode}
\def\xintLastItem:f:csv {\romannumeral0\xintlastitem:f:csv}%
\long\def\xintlastitem:f:csv #1%
{%
    \expandafter\XINT_last:f:csv_loop\expandafter{\expandafter}\expandafter.%
    \romannumeral`&&@#1,%
    \xint:\XINT_last_loop_enda,\xint:\XINT_last_loop_endb,%
    \xint:\XINT_last_loop_endc,\xint:\XINT_last_loop_endd,%
    \xint:\XINT_last_loop_ende,\xint:\XINT_last_loop_endf,%
    \xint:\XINT_last_loop_endg,\xint:\XINT_last_loop_endh,\xint_bye
}%
\long\def\XINT_last:f:csv_loop #1.#2,#3,#4,#5,#6,#7,#8,#9,%
{%
    \xint_gob_til_xint: #9%
        {#8}{#7}{#6}{#5}{#4}{#3}{#2}{#1}\xint:
    \XINT_last:f:csv_loop {#9}.%
}%
%    \end{macrocode}
% \subsubsection{\csh{xintKeep:x:csv}}
% \added{1.2j} To \xintexprnameimp. Moved here at |1.4|.
% Not part of
% publicly supported macros, may be removed at any time.
%    \begin{macrocode}
\def\xintKeep:x:csv #1#2%
{%
    \expandafter\xint_gobble_i
    \romannumeral0\expandafter\XINT_keep:x:csv_pos
    \the\numexpr #1\expandafter.\expandafter{\romannumeral`&&@#2}%
}%
\def\XINT_keep:x:csv_pos #1.#2%
{%
    \expandafter\XINT_keep:x:csv_loop\the\numexpr#1-\xint_c_viii.%
    #2\xint_Bye,\xint_Bye,\xint_Bye,\xint_Bye,%
       \xint_Bye,\xint_Bye,\xint_Bye,\xint_Bye,\xint_bye
}%
\def\XINT_keep:x:csv_loop #1%
{%
    \xint_gob_til_minus#1\XINT_keep:x:csv_finish-%
    \XINT_keep:x:csv_loop_pickeight #1%
}%
\def\XINT_keep:x:csv_loop_pickeight #1.#2,#3,#4,#5,#6,#7,#8,#9,%
{%
    ,#2,#3,#4,#5,#6,#7,#8,#9%
    \expandafter\XINT_keep:x:csv_loop\the\numexpr#1-\xint_c_viii.%
}%
\def\XINT_keep:x:csv_finish-\XINT_keep:x:csv_loop_pickeight -#1.%
{%
    \csname XINT_keep:x:csv_finish#1\endcsname
}%
\expandafter\def\csname XINT_keep:x:csv_finish1\endcsname
  #1,#2,#3,#4,#5,#6,#7,{,#1,#2,#3,#4,#5,#6,#7\xint_Bye}%
\expandafter\def\csname XINT_keep:x:csv_finish2\endcsname
  #1,#2,#3,#4,#5,#6,{,#1,#2,#3,#4,#5,#6\xint_Bye}%
\expandafter\def\csname XINT_keep:x:csv_finish3\endcsname
  #1,#2,#3,#4,#5,{,#1,#2,#3,#4,#5\xint_Bye}%
\expandafter\def\csname XINT_keep:x:csv_finish4\endcsname
  #1,#2,#3,#4,{,#1,#2,#3,#4\xint_Bye}%
\expandafter\def\csname XINT_keep:x:csv_finish5\endcsname
  #1,#2,#3,{,#1,#2,#3\xint_Bye}%
\expandafter\def\csname XINT_keep:x:csv_finish6\endcsname
  #1,#2,{,#1,#2\xint_Bye}%
\expandafter\def\csname XINT_keep:x:csv_finish7\endcsname
  #1,{,#1\xint_Bye}%
\expandafter\let\csname XINT_keep:x:csv_finish8\endcsname\xint_Bye
%    \end{macrocode}
% \subsubsection{Public names for the undocumented csv macros:
% \csh{xintCSVLength}, \csh{xintCSVKeep}, \csh{xintCSVKeepx}, \csh{xintCSVTrim},
% \csh{xintCSVNthEltPy}, \csh{xintCSVReverse},
% \csh{xintCSVFirstItem}, \csh{xintCSVLastItem}}
% 
%\begin{lverb}
% Completely unstable macros: currently they expand the list argument
% and want no final comma. But for matters of xintexpr.sty I could as well
% decide to require a final comma, and then I could simplify implementation
% but of course this would break the macros if used with current
% functionalities.
%\end{lverb}
%    \begin{macrocode}
\let\xintCSVLength   \xintLength:f:csv
\let\xintCSVKeep     \xintKeep:f:csv
\let\xintCSVKeepx    \xintKeep:x:csv
\let\xintCSVTrim     \xintTrim:f:csv
\let\xintCSVNthEltPy \xintNthEltPy:f:csv
\let\xintCSVReverse  \xintReverse:f:csv
\let\xintCSVFirstItem\xintFirstItem:f:csv
\let\xintCSVLastItem \xintLastItem:f:csv
\let\XINT_tmpa\relax \let\XINT_tmpb\relax \let\XINT_tmpc\relax
\XINTrestorecatcodesendinput%
%    \end{macrocode}
% \StoreCodelineNo {xinttools}
% \cleardoublepage\let\xinttoolsnameUp\undefined
%\gardesactifs
%\let</xinttools>\relax
%\let<*xintcore>\gardesinactifs
%</xinttools>^^A--------------------------------------------------
%<*xintcore>^^A---------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname xintcorenameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section{Package \xintcorenameimp implementation}
% \RaisedLabel{sec:coreimp}
%
% \localtableofcontents
%
% \subsection{Introduction}
%
% Got split off from \xintnameimp with release |1.1|.
%
%   The core arithmetic routines have been entirely rewritten for release
%   |1.2|. The |1.2i| and |1.2l| brought again some improvements.
%
%   The commenting continues (\xintbndldate) to be very sparse: actually it got
%   worse than ever with release |1.2|. I will possibly add comments at a
%   later date, but for the time being the new routines are not commented at
%   all.
%
% |1.3| removes all macros which were deprecated at |1.2o|.
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
% The code for reload detection was initially copied from \textsc{Heiko
% Oberdiek}'s packages, then modified.
%
% The method for catcodes was also initially directly inspired by these
% packages.
%
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode64=11   % @
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \def\empty{}\def\space{ }\newlinechar10
  \def\z{\endgroup}%
  \expandafter\let\expandafter\x\csname ver@xintcore.sty\endcsname
  \expandafter\let\expandafter\c\csname ver@calxcore.sty\endcsname
  \expandafter\ifx\csname numexpr\endcsname\relax
    \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax
      \immediate\write128{^^JPackage xintcore Warning:^^J%
                          \space\space\space\space
                          \numexpr not available, aborting input.^^J}%
    \else
      \PackageWarningNoLine{xintcore}{\numexpr not available, aborting input}%
    \fi
    \def\z{\endgroup\endinput}%
  \else
    \ifx\x\relax   % plain-TeX, first loading of xintcore.sty
      \ifx\c\relax % but calxcore.sty not yet loaded.
         \def\z{\endgroup\input calxcore.sty\relax}%
      \fi
    \else
      \ifx\x\empty % LaTeX, first loading,
      % variable is initialized, but \ProvidesPackage not yet seen
          \ifx\c\relax % calxcore.sty not yet loaded.
            \def\z{\endgroup\RequirePackage{calxcore}}%
          \fi
      \else
        \def\z{\endgroup\endinput}% xintkernel already loaded.
      \fi
    \fi
  \fi
\z%
\XINTsetupcatcodes% defined in xintkernel.sty
%    \end{macrocode}
% \subsection{Package identification}
%    \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintcore}%
  [2026/11/01 v2.0a1 Expandable arithmetic on big integers (JFB)]%
%    \end{macrocode}
% \subsection{Legacy error reporting}
%\begin{lverb}
% Legacy integer and rational routines cannot represent NaN or infinity.
% Their error path always raises the condition's signal flag, emits an
% expandable error, and returns the caller's fallback value. There are no
% configurable traps or handlers.
%
% Syntax (f-expandable):
%(
%  \XINT_legacysignalcondition{C}{M}{H}{V} -> <error>V
%)
% H is ignored, as in the original trapped-signal path.
%\end{lverb}
%    \begin{macrocode}
\catcode`- 11
\def\XINT_ConversionSyntax-signal  {{InvalidOperation}}%
\let\XINT_DivisionImpossible-signal\XINT_ConversionSyntax-signal
\let\XINT_DivisionUndefined-signal \XINT_ConversionSyntax-signal
\let\XINT_InvalidContext-signal    \XINT_ConversionSyntax-signal
\catcode`- 12
\def\XINT_legacysignalcondition #1{\expandafter\XINT_legacysignalcondition_a
    \romannumeral0\ifcsname XINT_#1-signal\endcsname
                    \xint_dothis{\csname XINT_#1-signal\endcsname}%
                  \fi\xint_orthat{{#1}}{#1}}%
\def\XINT_legacysignalcondition_a #1#2#3#4#5{%
    \expandafter\xint_gobble_i\csname XINT_#1Flag_ON\endcsname
    \XINT_expandableerror{#3}%
    \xint_firstofone{#5}%
}%
\def\XINT_ifFlagRaised #1{%
    \ifcsname XINT_#1Flag_ON\endcsname
        \expandafter\xint_firstoftwo
    \else
        \expandafter\xint_secondoftwo
    \fi}%
\def\XINT_resetFlag #1%
    {\expandafter\let\csname XINT_#1Flag_ON\endcsname\XINT_undefined}%
\def\XINT_resetFlags {%
    \XINT_resetFlag{InvalidOperation}%
    \XINT_resetFlag{DivisionByZero}%
    \XINT_resetFlag{Underflow}%
    \XINT_resetFlag{Overflow}%
}%
\def\XINT_RaiseFlag #1{\expandafter\xint_gobble_i\csname XINT_#1Flag_ON\endcsname}%
%    \end{macrocode}
% \subsection*{Routines handling integers as lists of token digits}
% \addcontentsline{toc}{subsection}{Routines handling integers as lists of token digits}
%\begin{lverb}
% Routines handling big integers which are lists of digit tokens with no
% special additional structure.
%
% Some
% routines do not accept non properly terminated inputs like "\the\numexpr1",
% or "\the\mathcode`\-", others do.
%
% These routines or their sub-routines are mainly for internal usage.
%\end{lverb}
% \subsection{\cshnolabel{xintiiSgn}}
% Moved to \calxcorenameimp for STUPID reasons.
%
% \subsection{\cshnolabel{xintiiOpp}}
% Moved to \calxcorenameimp for STUPID reasons.
%
% \subsection{\csh{xintiiAbs}}
%\begin{lverb}
%  Attention \xintiiAbs non robust against non terminated input.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiAbs {\romannumeral0\xintiiabs }%
\def\xintiiabs #1%
{%
    \expandafter\XINT_abs \romannumeral`&&@#1%
}%
\def\XINT_abs #1%
{%
    \xint_UDsignfork
      #1{ }%
       -{ #1}%
    \krof
}%
\def\XINT_Abs #1%
{%
    \xint_UDsignfork
      #1{}%
       -{#1}%
    \krof
}%
%    \end{macrocode}
% \subsection{\csh{xintFDg}}
%\begin{lverb}
% FIRST DIGIT.
%
% 1.2l: \xintiiFDg made robust against non terminated input.
%
% 1.2o deprecates \xintiiFDg, gives to \xintFDg former meaning of \xintiiFDg.
%\end{lverb}
%    \begin{macrocode}
\def\xintFDg {\romannumeral0\xintfdg }%
\def\xintfdg #1{\expandafter\XINT_fdg \romannumeral`&&@#1\xint:\Z}%
\def\XINT_FDg #1%
   {\romannumeral0\expandafter\XINT_fdg\romannumeral`&&@\xintnum{#1}\xint:\Z }%
\def\XINT_fdg #1#2#3\Z
{%
    \xint_UDzerominusfork
      #1-{ 0}%   zero
      0#1{ #2}%  negative
       0-{ #1}%  positive
    \krof
}%
%    \end{macrocode}
% \subsection{\csh{xintLDg}}
%\begin{lverb}
% LAST DIGIT.
%
% Rewritten for 1.2i (2016/12/10). Surprisingly perhaps, it is faster than
% \xintLastItem from xintkernel.sty despite the \numexpr operations.
%
% 1.2o deprecates \xintiiLDg, gives to \xintLDg former meaning of \xintiiLDg.
%
% Attention \xintLDg non robust against non terminated input.
%\end{lverb}
%    \begin{macrocode}
\def\xintLDg {\romannumeral0\xintldg }%
\def\xintldg #1{\expandafter\XINT_ldg_fork\romannumeral`&&@#1%
    \XINT_ldg_c{}{}{}{}{}{}{}{}\xint_bye\relax}%
\def\XINT_ldg_fork #1%
{%
    \xint_UDsignfork
      #1\XINT_ldg
       -{\XINT_ldg#1}%
    \krof
}%
\def\XINT_ldg #1{%
\def\XINT_ldg ##1##2##3##4##5##6##7##8##9%
   {\expandafter#1%
    \the\numexpr##9##8##7##6##5##4##3##2##1*\xint_c_+\XINT_ldg_a##9}%
}\XINT_ldg{ }%
\def\XINT_ldg_a#1#2{\XINT_ldg_cbye#2\XINT_ldg_d#1\XINT_ldg_c\XINT_ldg_b#2}%
\def\XINT_ldg_b#1#2#3#4#5#6#7#8#9{#9#8#7#6#5#4#3#2#1*\xint_c_+\XINT_ldg_a#9}%
\def\XINT_ldg_c    #1#2\xint_bye{#1}%
\def\XINT_ldg_cbye #1\XINT_ldg_c{}%
\def\XINT_ldg_d#1#2\xint_bye{#1}%
%    \end{macrocode}
%
% \subsection{\csh{xintDouble}}
%\begin{lverb}
% Attention \xintDouble non robust against non terminated input.
%\end{lverb}
%    \begin{macrocode}
\def\xintDouble {\romannumeral0\xintdouble}%
\def\xintdouble #1{\expandafter\XINT_dbl_fork\romannumeral`&&@#1%
                   \xint_bye2345678\xint_bye*\xint_c_ii\relax}%
\def\XINT_dbl_fork #1%
{%
    \xint_UDsignfork
     #1\XINT_dbl_neg
      -\XINT_dbl
    \krof #1%
}%
\def\XINT_dbl_neg-{\expandafter-\romannumeral0\XINT_dbl}%
\def\XINT_dbl #1{%
\def\XINT_dbl ##1##2##3##4##5##6##7##8%
   {\expandafter#1\the\numexpr##1##2##3##4##5##6##7##8\XINT_dbl_a}%
}\XINT_dbl{ }%
\def\XINT_dbl_a #1#2#3#4#5#6#7#8%
   {\expandafter\XINT_dbl_e\the\numexpr 1#1#2#3#4#5#6#7#8\XINT_dbl_a}%
\def\XINT_dbl_e#1{*\xint_c_ii\if#13+\xint_c_i\fi\relax}%
%    \end{macrocode}
% \subsection{\csh{xintHalf}}
%\begin{lverb}
% Attention \xintHalf non robust against non terminated input.
%\end{lverb}
%    \begin{macrocode}
\def\xintHalf {\romannumeral0\xinthalf}%
\def\xinthalf #1{\expandafter\XINT_half_fork\romannumeral`&&@#1%
    \xint_bye\xint_Bye345678\xint_bye
    *\xint_c_v+\xint_c_v)/\xint_c_x-\xint_c_i\relax}%
\def\XINT_half_fork #1%
{%
  \xint_UDsignfork
     #1\XINT_half_neg
      -\XINT_half
    \krof #1%
}%
\def\XINT_half_neg-{\xintiiopp\XINT_half}%
\def\XINT_half #1{%
\def\XINT_half ##1##2##3##4##5##6##7##8%
   {\expandafter#1\the\numexpr(##1##2##3##4##5##6##7##8\XINT_half_a}%
}\XINT_half{ }%
\def\XINT_half_a#1{\xint_Bye#1\xint_bye\XINT_half_b#1}%
\def\XINT_half_b #1#2#3#4#5#6#7#8%
   {\expandafter\XINT_half_e\the\numexpr(1#1#2#3#4#5#6#7#8\XINT_half_a}%
\def\XINT_half_e#1{*\xint_c_v+#1-\xint_c_v)\relax}%
%    \end{macrocode}
% \subsection{\csh{xintInc}}
%\begin{lverb}
% 1.2i much delayed complete rewrite in 1.2 style.
%
% As we take 9 by 9 with the input save stack at 5000 this allows a bit less
% than 9 times 2500 = 22500 digits on input.
%
% Attention \xintInc non robust against non terminated input.
%\end{lverb}
%    \begin{macrocode}
\def\xintInc {\romannumeral0\xintinc}%
\def\xintinc #1{\expandafter\XINT_inc_fork\romannumeral`&&@#1%
                \xint_bye23456789\xint_bye+\xint_c_i\relax}%
\def\XINT_inc_fork #1%
{%
    \xint_UDsignfork
      #1\XINT_inc_neg
       -\XINT_inc
    \krof #1%
}%
\def\XINT_inc_neg-#1\xint_bye#2\relax
   {\xintiiopp\XINT_dec #1\XINT_dec_bye234567890\xint_bye}%
\def\XINT_inc #1{%
\def\XINT_inc ##1##2##3##4##5##6##7##8##9%
   {\expandafter#1\the\numexpr##1##2##3##4##5##6##7##8##9\XINT_inc_a}%
}\XINT_inc{ }%
\def\XINT_inc_a #1#2#3#4#5#6#7#8#9%
   {\expandafter\XINT_inc_e\the\numexpr 1#1#2#3#4#5#6#7#8#9\XINT_inc_a}%
\def\XINT_inc_e#1{\if#12+\xint_c_i\fi\relax}%
%    \end{macrocode}
% \subsection{\csh{xintDec}}
%\begin{lverb}
% 1.2i much delayed complete rewrite in the 1.2 style. Things are a
% bit more complicated than \xintInc because 2999999999 is too big for TeX.
%
% Attention \xintDec non robust against non terminated input.
%\end{lverb}
%    \begin{macrocode}
\def\xintDec {\romannumeral0\xintdec}%
\def\xintdec #1{\expandafter\XINT_dec_fork\romannumeral`&&@#1%
                \XINT_dec_bye234567890\xint_bye}%
\def\XINT_dec_fork #1%
{%
    \xint_UDsignfork
      #1\XINT_dec_neg
       -\XINT_dec
    \krof #1%
}%
\def\XINT_dec_neg-#1\XINT_dec_bye#2\xint_bye
   {\expandafter-%
    \romannumeral0\XINT_inc #1\xint_bye23456789\xint_bye+\xint_c_i\relax}%
\def\XINT_dec #1{%
\def\XINT_dec ##1##2##3##4##5##6##7##8##9%
   {\expandafter#1\the\numexpr##1##2##3##4##5##6##7##8##9\XINT_dec_a}%
}\XINT_dec{ }%
\def\XINT_dec_a #1#2#3#4#5#6#7#8#9%
   {\expandafter\XINT_dec_e\the\numexpr 1#1#2#3#4#5#6#7#8#9\XINT_dec_a}%
\def\XINT_dec_bye #1\XINT_dec_a#2#3\xint_bye
         {\if#20-\xint_c_ii\relax+\else-\fi\xint_c_i\relax}%
\def\XINT_dec_e#1{\unless\if#11\xint_dothis{-\xint_c_i#1}\fi\xint_orthat\relax}%
%    \end{macrocode}
% \subsection{\csh{xintDSL}}
%\begin{lverb}
% DECIMAL SHIFT LEFT (=MULTIPLICATION PAR 10). Rewritten for 1.2i.
% This was very old code... I never came back to it, but I should have
% rewritten it long time ago.
%
% Attention \xintDSL non robust against non terminated input.
%\end{lverb}
%    \begin{macrocode}
\def\xintDSL {\romannumeral0\xintdsl }%
\def\xintdsl #1{\expandafter\XINT_dsl\romannumeral`&&@#10}%
\def\XINT_dsl#1{%
\def\XINT_dsl ##1{\xint_gob_til_zero ##1\xint_dsl_zero 0#1##1}%
}\XINT_dsl{ }%
\def\xint_dsl_zero 0 0{ }%
%    \end{macrocode}
% \subsection{\csh{xintDSR}}
%\begin{lverb}
% Decimal shift right, truncates towards zero. Rewritten for 1.2i.
% Limited to 22483 digits on input.
%
% Attention \xintDSR non robust against non terminated input.
%\end{lverb}
%    \begin{macrocode}
\def\xintDSR{\romannumeral0\xintdsr}%
\def\xintdsr #1{\expandafter\XINT_dsr_fork\romannumeral`&&@#1%
    \xint_bye\xint_Bye3456789\xint_bye+\xint_c_v)/\xint_c_x-\xint_c_i\relax}%
\def\XINT_dsr_fork #1%
{%
    \xint_UDsignfork
      #1\XINT_dsr_neg
       -\XINT_dsr
    \krof #1%
}%
\def\XINT_dsr_neg-{\xintiiopp\XINT_dsr}%
\def\XINT_dsr #1{%
\def\XINT_dsr ##1##2##3##4##5##6##7##8##9%
   {\expandafter#1\the\numexpr(##1##2##3##4##5##6##7##8##9\XINT_dsr_a}%
}\XINT_dsr{ }%
\def\XINT_dsr_a#1{\xint_Bye#1\xint_bye\XINT_dsr_b#1}%
\def\XINT_dsr_b #1#2#3#4#5#6#7#8#9%
   {\expandafter\XINT_dsr_e\the\numexpr(1#1#2#3#4#5#6#7#8#9\XINT_dsr_a}%
\def\XINT_dsr_e #1{)\relax}%
%    \end{macrocode}
% \subsection{\csh{xintDSRr}}
%\begin{lverb}
% New with 1.2i. Decimal shift right, rounds away from zero; done in
% the 1.2 spirit (with much delay, sorry). Used by \xintRound, \xintDivRound.
%
% This is about the first time I am happy that the division in \numexpr
% rounds!
%
% Attention \xintDSRr non robust against non terminated input.
%\end{lverb}
%    \begin{macrocode}
\def\xintDSRr{\romannumeral0\xintdsrr}%
\def\xintdsrr #1{\expandafter\XINT_dsrr_fork\romannumeral`&&@#1%
                \xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax}%
\def\XINT_dsrr_fork #1%
{%
    \xint_UDsignfork
      #1\XINT_dsrr_neg
       -\XINT_dsrr
    \krof #1%
}%
\def\XINT_dsrr_neg-{\xintiiopp\XINT_dsrr}%
\def\XINT_dsrr #1{%
\def\XINT_dsrr ##1##2##3##4##5##6##7##8##9%
   {\expandafter#1\the\numexpr##1##2##3##4##5##6##7##8##9\XINT_dsrr_a}%
}\XINT_dsrr{ }%
\def\XINT_dsrr_a#1{\xint_Bye#1\xint_bye\XINT_dsrr_b#1}%
\def\XINT_dsrr_b #1#2#3#4#5#6#7#8#9%
   {\expandafter\XINT_dsrr_e\the\numexpr1#1#2#3#4#5#6#7#8#9\XINT_dsrr_a}%
\let\XINT_dsrr_e\XINT_inc_e
%    \end{macrocode}
% \subsection*{Blocks of eight digits}
% \addcontentsline{toc}{subsection}{Blocks of eight digits}
%
% The lingua of release 1.2.  Six of them have been moved to \calxcorenameimp
% at |2.0a1|.  An |\XINT_smallunrevbyviii| was deleted then as it served only
% in the legacy addition macros, now replaced by those of \calxcorenameimp.
%
%
% \subsection{\csh{XINT_cuz}}
%\begin{lverb}
% This (launched by \romannumeral0) iterately removes all leading
% zeroes from a sequence of 8N digits ended by \R.
%
% Rewritten for 1.2l, now uses \numexpr governed expansion and \ifnum test
% rather than delimited gobbling macros.
%
% Note 2015/11/28: with only four digits the gob_til_fourzeroes had proved
% in some old testing faster than \ifnum test. But with eight digits, the
% execution times are much closer, as I tested back then.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_cuz #1{%
\def\XINT_cuz {\expandafter#1\the\numexpr\XINT_cuz_loop}%
}\XINT_cuz{ }%
\def\XINT_cuz_loop #1#2#3#4#5#6#7#8#9%
{%
    #1#2#3#4#5#6#7#8%
       \xint_gob_til_R #9\XINT_cuz_hitend\R
       \ifnum #1#2#3#4#5#6#7#8>\xint_c_
             \expandafter\XINT_cuz_cleantoend
       \else\expandafter\XINT_cuz_loop
       \fi #9%
}%
\def\XINT_cuz_hitend\R #1\R{\relax}%
\def\XINT_cuz_cleantoend #1\R{\relax #1}%
%    \end{macrocode}
% \subsection{\csh{XINT_cuz_byviii}}
%\begin{lverb}
% This removes eight by eight leading zeroes from a sequence of 8N digits
% ended by \R. Thus, we still have 8N digits on output. Expansion started by
% \romannumeral0 
%\end{lverb}
%    \begin{macrocode}
\def\XINT_cuz_byviii #1#2#3#4#5#6#7#8#9%
{%
    \xint_gob_til_R #9\XINT_cuz_byviii_e \R
    \xint_gob_til_eightzeroes #1#2#3#4#5#6#7#8\XINT_cuz_byviii_z 00000000%
    \XINT_cuz_byviii_done #1#2#3#4#5#6#7#8#9%
}%
\def\XINT_cuz_byviii_z 00000000\XINT_cuz_byviii_done 00000000{\XINT_cuz_byviii}%
\def\XINT_cuz_byviii_done #1\R { #1}%
\def\XINT_cuz_byviii_e\R #1\XINT_cuz_byviii_done #2\R{ #2}%
%    \end{macrocode}
% \subsection{\csh{XINT_sepbyviii_Z}}
%
%\begin{lverb}
% This is used as
%( \the\numexpr\XINT_sepbyviii_Z <8Ndigits>\XINT_sepbyviii_Z_end 2345678\relax
%)
% It produces 1<8d>!...1<8d>!1;!
%
% Prior to 1.2l it used \Z as terminator (hence the name).  At 1.2l a switch
% to ; was done.  This was at a time I thought perhaps I would use an internal
% format maintaining such 8 digits blocks, and this had to be compatible with
% the \csname...\endcsname encapsulation in \xintexpr parsers.  That rationale
% is obsolete since 1.4 usage of \expanded in $xintexprnameimp, but if an
% internal format is one day used it would be nice to be able to externalize
% it easily, so catcode 12 tokens are the most convenient. 
%
% As the expansion is done via successive \numexpr, it is convenient to use
% something such as ; which terminates it and stays there.  The ! itself would
% do.  But it proved convenient to have unique ending pattern.  I could use
% two ! perhaps.
%\end{lverb}
% \changed{1.4n}
%\begin{lverb}
% Unfortunately LuaMetaTeX has given to ; and : a meaning as operators inside
% its \numexpr. Let's hope ! does not acquire meaning too there.  Anyway here
% I only need to use \relax;! in \XINT_sepbyviii_Z_end.  First step in a tedious
% check of the entire codebase...
%\end{lverb}
%    \begin{macrocode}
\def\XINT_sepbyviii_Z #1#2#3#4#5#6#7#8%
{%
    1#1#2#3#4#5#6#7#8\expandafter!\the\numexpr\XINT_sepbyviii_Z
}%
\def\XINT_sepbyviii_Z_end #1\relax {\relax;!}%
%    \end{macrocode}
% \subsection{\csh{XINT_sepbyviii_andcount}}
%
%\begin{lverb}
% This is used as
%( \the\numexpr\XINT_sepbyviii_andcount <8Ndigits>$%
%:     \XINT_sepbyviii_end 2345678\relax
%:     \xint_c_vii!\xint_c_vi!\xint_c_v!\xint_c_iv!$%
%:     \xint_c_iii!\xint_c_ii!\xint_c_i!\xint_c_\W
%)
% It will produce
%( 1<8d>!1<8d>!....1<8d>!1\xint:<count of blocks>\xint:
%)
% Used by
% \XINT_div_prepare_g for \XINT_div_prepare_h, and also by \xintiiCmp.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_sepbyviii_andcount
{%
    \expandafter\XINT_sepbyviii_andcount_a\the\numexpr\XINT_sepbyviii
}%
\def\XINT_sepbyviii #1#2#3#4#5#6#7#8%
{%
    1#1#2#3#4#5#6#7#8\expandafter!\the\numexpr\XINT_sepbyviii
}%
\def\XINT_sepbyviii_end #1\relax {\relax\XINT_sepbyviii_andcount_end!}%
\def\XINT_sepbyviii_andcount_a {\XINT_sepbyviii_andcount_b \xint_c_\xint:}%
\def\XINT_sepbyviii_andcount_b #1\xint:#2!#3!#4!#5!#6!#7!#8!#9!%
{%
    #2\expandafter!\the\numexpr#3\expandafter!\the\numexpr#4\expandafter
    !\the\numexpr#5\expandafter!\the\numexpr#6\expandafter!\the\numexpr
    #7\expandafter!\the\numexpr#8\expandafter!\the\numexpr#9\expandafter!\the\numexpr
    \expandafter\XINT_sepbyviii_andcount_b\the\numexpr #1+\xint_c_viii\xint:%
}%
\def\XINT_sepbyviii_andcount_end #1\XINT_sepbyviii_andcount_b\the\numexpr
    #2+\xint_c_viii\xint:#3#4\W {\expandafter\xint:\the\numexpr #2+#3\xint:}%
%    \end{macrocode}
% \subsection{\csh{XINT_sepandrev}}
%\begin{lverb}
% This is used typically as
%( \romannumeral0\XINT_sepandrev <8Ndigits>$%
%:               \XINT_rsepbyviii_end_A 2345678$%
%:               \XINT_rsepbyviii_end_B 2345678\relax UV$%
%:               \R\xint:\R\xint:\R\xint:\R\xint:\R\xint:\R\xint:\R\xint:\R\xint:\W
%)
% and will produce 
%( 1<8digits>!1<8digits>!1<8digits>!...
%)
% where the blocks have
% been globally reversed. The UV here are only place holders (must be \numexpr1
% stoppers) to share same
% syntax as \XINT_sepandrev_andcount, they are gobbled (#2 in \XINT_sepandrev_done).
%\end{lverb}
%    \begin{macrocode}
\def\XINT_sepandrev
{%
    \expandafter\XINT_sepandrev_a\the\numexpr 1\XINT_rsepbyviii
}%
\def\XINT_sepandrev_a {\XINT_sepandrev_b {}}%
\def\XINT_sepandrev_b #1#2\xint:#3\xint:#4\xint:#5\xint:#6\xint:#7\xint:#8\xint:#9\xint:%
{%
    \xint_gob_til_R #9\XINT_sepandrev_end\R
    \XINT_sepandrev_b {#9!#8!#7!#6!#5!#4!#3!#2!#1}%
}%
\def\XINT_sepandrev_end\R\XINT_sepandrev_b #1#2\W {\XINT_sepandrev_done #1}%
\def\XINT_sepandrev_done #11#2!{ }%
%    \end{macrocode}
% \subsection*{Core arithmetic}
% \addcontentsline{toc}{subsection}{Core arithmetic}
%\begin{lverb}
% All three raw ii operations use the native calxcore implementations.
% Their callers continue to supply and receive raw decimal integers;
% representation conversion is confined to these interface macros.
%\end{lverb}
%
% \subsection{\csh{xintiiAdd}}
%\begin{lverb}
% Input: \xintiiAdd{raw}{raw}; output: raw integer.
% Convert both operands to native, apply native addition, convert back.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiAdd {\romannumeral0\xintiiadd }%
\def\xintiiadd #1#2{\CALX_ntoraw{\CALX_nadd{\CALX_nfromraw{#1}}{\CALX_nfromraw{#2}}}}%
%    \end{macrocode}
% \subsection{\cshnolabel{xintiiCmp}}
% Moved to \calxcorenameimp at |2.0a1| for STUPID reasons.
%
% Prior to |1.4m| the «strcmp» primitive was not used by \xintcorenameimp.
% Here is the old implementation:
%\begin{lverb}
%( \def\XINT_cmp_plusplus  #1#2#3\xint:
%: {$%
%:     \expandafter\XINT_cmp_pp
%:     \the\numexpr\expandafter\XINT_sepbyviii_andcount
%:     \romannumeral0\XINT_zeroes_forviii #2#3\R\R\R\R\R\R\R\R{10}0000001\W
%:     #2#3\XINT_sepbyviii_end 2345678\relax
%:         \xint_c_vii!\xint_c_vi!\xint_c_v!\xint_c_iv!$%
%:         \xint_c_iii!\xint_c_ii!\xint_c_i!\xint_c_\W
%:     #1$%
%: }$%
%: \def\XINT_cmp_pp #1\xint:#2\xint:#3\xint:
%: {$%
%:     \expandafter\XINT_cmp_checklengths
%:     \the\numexpr #2\expandafter\xint:$%
%:     \the\numexpr\expandafter\XINT_sepbyviii_andcount
%:     \romannumeral0\XINT_zeroes_forviii #3\R\R\R\R\R\R\R\R{10}0000001\W
%:     #3\XINT_sepbyviii_end 2345678\relax
%:         \xint_c_vii!\xint_c_vi!\xint_c_v!\xint_c_iv!$%
%:         \xint_c_iii!\xint_c_ii!\xint_c_i!\xint_c_\W
%:     #1;!1;!1;!1;!\W
%: }$%
%: \def\XINT_cmp_checklengths #1\xint:#2\xint:#3\xint:
%: {$%
%:     \ifnum #1=#3
%:        \expandafter\xint_firstoftwo
%:     \else
%:        \expandafter\xint_secondoftwo
%:     \fi
%:     \XINT_cmp_a {\XINT_cmp_distinctlengths {#1}{#3}}#2;!1;!1;!1;!\W
%: }$%
%: \def\XINT_cmp_distinctlengths #1#2#3\W #4\W
%: {$%
%:     \ifnum #1>#2
%:         \expandafter\xint_firstoftwo
%:     \else
%:         \expandafter\xint_secondoftwo
%:     \fi
%:     { -1}{ 1}$%
%: }$%
%: \def\XINT_cmp_a 1#1!1#2!1#3!1#4!#5\W 1#6!1#7!1#8!1#9!$%
%: {$%
%:     \xint_gob_til_sc #1\XINT_cmp_equal ;$%
%:     \ifnum #1>#6 \XINT_cmp_gt\fi
%:     \ifnum #1<#6 \XINT_cmp_lt\fi
%:     \xint_gob_til_sc #2\XINT_cmp_equal ;$%
%:     \ifnum #2>#7 \XINT_cmp_gt\fi
%:     \ifnum #2<#7 \XINT_cmp_lt\fi
%:     \xint_gob_til_sc #3\XINT_cmp_equal ;$%
%:     \ifnum #3>#8 \XINT_cmp_gt\fi
%:     \ifnum #3<#8 \XINT_cmp_lt\fi
%:     \xint_gob_til_sc #4\XINT_cmp_equal ;$%
%:     \ifnum #4>#9 \XINT_cmp_gt\fi
%:     \ifnum #4<#9 \XINT_cmp_lt\fi
%:     \XINT_cmp_a #5\W
%: }$%
%: \def\XINT_cmp_lt#1{\def\XINT_cmp_lt\fi ##1\W ##2\W {\fi#1-1}}\XINT_cmp_lt{ }$%
%: \def\XINT_cmp_gt#1{\def\XINT_cmp_gt\fi ##1\W ##2\W {\fi#11}}\XINT_cmp_gt{ }$%
%: \def\XINT_cmp_equal #1\W #2\W { 0}$%
%)
%\end{lverb}
% \subsection{\csh{xintiiSub}}
%\begin{lverb}
% Input: \xintiiSub{raw}{raw}; output: raw integer.
% Convert both operands to native, apply native subtraction, convert back.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiSub {\romannumeral0\xintiisub }%
\def\xintiisub #1#2{\CALX_ntoraw{\CALX_nsub{\CALX_nfromraw{#1}}{\CALX_nfromraw{#2}}}}%
%    \end{macrocode}
% \subsection{\csh{xintiiMul}}
%\begin{lverb}
% Input: \xintiiMul{raw}{raw}; output: raw integer.
% Convert both operands to native, apply native multiplication, convert back.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiMul {\romannumeral0\xintiimul }%
\def\xintiimul #1#2{\CALX_ntoraw{\CALX_nmul{\CALX_nfromraw{#1}}{\CALX_nfromraw{#2}}}}%
%    \end{macrocode}
% \subsection{Reversed eight-digit block output}
%\begin{lverb}
% Converts a block list, least significant first, terminated by 1;! as
% produced by the small multiplication kernels, to an untagged decimal
% integer (used by xintfrac).
%\end{lverb}
%    \begin{macrocode}
\def\XINT_mul_out
   {\expandafter\XINT_cuz_small\romannumeral0\XINT_unrevbyviii {}}%
%    \end{macrocode}
% \subsection{\csh{xintiiDivision}}
%\begin{lverb}
% The public ii entry points accept unexpanded, f-expandable material
% yielding raw ii integers, and return raw integers. Each operation delegates
% to the corresponding native calxcore
% division operation.  Internal division callers use \XINT_ndivrawpair with
% divisor first and dividend second; it returns raw {quotient}{remainder}.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_ndivrawpair #1#2{%
    \expandafter\XINT_ndivrawpair_a\romannumeral0\CALX_ndivision
        {\CALX_nfromraw{#2}}{\CALX_nfromraw{#1}}}%
\def\XINT_ndivrawpair_a #1#2{%
    \expandafter\XINT_ndivrawpair_b
    \romannumeral0\CALX_ntoraw{#2}\xint:{#1}}%
\def\XINT_ndivrawpair_b #1\xint:#2{%
    \expandafter\XINT_ndivrawpair_c
    \romannumeral0\CALX_ntoraw{#2}\xint:{#1}}%
\def\XINT_ndivrawpair_c #1\xint:#2{{#1}{#2}}%
\def\xintiiDivision   {\romannumeral0\xintiidivision }%
\def\xintiidivision #1#2{\XINT_ndivrawpair{#2}{#1}}%
\def\xintiiQuo {\romannumeral0\xintiiquo }%
\def\xintiiquo #1#2{\CALX_ntoraw{\CALX_nquo{\CALX_nfromraw{#1}}{\CALX_nfromraw{#2}}}}%
\def\xintiiRem {\romannumeral0\xintiirem }%
\def\xintiirem #1#2{\CALX_ntoraw{\CALX_nrem{\CALX_nfromraw{#1}}{\CALX_nfromraw{#2}}}}%
\def\xintiiDivRound   {\romannumeral0\xintiidivround }%
\def\xintiidivround #1#2{\CALX_ntoraw{\CALX_ndivround{\CALX_nfromraw{#1}}{\CALX_nfromraw{#2}}}}%
\def\xintiiDivTrunc   {\romannumeral0\xintiidivtrunc }%
\def\xintiidivtrunc #1#2{\CALX_ntoraw{\CALX_ndivtrunc{\CALX_nfromraw{#1}}{\CALX_nfromraw{#2}}}}%
\def\xintiiModTrunc {\romannumeral0\xintiimodtrunc }%
\def\xintiimodtrunc #1#2{\CALX_ntoraw{\CALX_nmodtrunc{\CALX_nfromraw{#1}}{\CALX_nfromraw{#2}}}}%
\def\xintiiDivMod   {\romannumeral0\xintiidivmod }%
\def\xintiidivmod #1#2{%
    \expandafter\XINT_ndivrawmod_a\romannumeral0\CALX_ndivmod
      {\CALX_nfromraw{#1}}{\CALX_nfromraw{#2}}}%
\def\XINT_ndivrawmod_a #1#2{%
    \expandafter\XINT_ndivrawpair_b
    \romannumeral0\CALX_ntoraw{#2}\xint:{#1}}%
\def\xintiiDivFloor {\romannumeral0\xintiidivfloor}%
\def\xintiidivfloor #1#2{\CALX_ntoraw{\CALX_ndivfloor{\CALX_nfromraw{#1}}{\CALX_nfromraw{#2}}}}%
\def\xintiiMod {\romannumeral0\xintiimod}%
\def\xintiimod #1#2{\CALX_ntoraw{\CALX_nmod{\CALX_nfromraw{#1}}{\CALX_nfromraw{#2}}}}%
%    \end{macrocode}
% \subsection{\csh{xintiiSqr}}
%\begin{lverb}
% 1.2l: \xintiiSqr made robust against non terminated input.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiSqr {\romannumeral0\xintiisqr }%
\def\xintiisqr #1{\CALX_ntoraw{\XINT_nsquare{\CALX_nfromraw{#1}}}}%
\def\XINT_nsquare #1{\expandafter\XINT_nsquare_a\romannumeral`&&@#1\xint:}%
\def\XINT_nsquare_a #1\xint:{\CALX_nmul{#1}{#1}}%
%    \end{macrocode}
% \subsection{\csh{xintiiPow}}
%\begin{lverb}
% 1.2f Modifies the initial steps: 1) in order to be able to let more easily
% \xintiPow use \xintNum on the exponent once xintfrac.sty is loaded; 2) also
% because I noticed it was not very well coded. And it did only a \numexpr on
% the exponent, contradicting the documentation related to the "i" convention
% in names.
% 
% 1.2l: \xintiiPow made robust against non terminated input.
%
% The macro makes no a priori test on whether computation has a chance to
% complete succesfully, as this depends on TeX memory parameters.  But roughly,
% the size of the output should be less than the maximal size for addition,
% i.e. with TeXLive 2025 settings, have less than about 26600 decimal digits.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiPow {\romannumeral0\xintiipow }%
\def\xintiipow #1#2%
{%
    \expandafter\xint_pow\the\numexpr #2\expandafter
    .\romannumeral`&&@#1\xint:
}%
\def\xint_pow #1.#2%#3\xint:
{%
    \xint_UDzerominusfork
      #2-\XINT_pow_AisZero
      0#2\XINT_pow_Aneg
      0-{\XINT_pow_Apos #2}%
    \krof {#1}%
}%
\def\XINT_pow_AisZero #1#2\xint:
{%
     \ifcase\XINT_cntSgn #1\xint:
         \xint_afterfi { 1}%
     \or
         \xint_afterfi { 0}%
     \else
         \xint_afterfi
        {\XINT_legacysignalcondition{DivisionByZero}{0 raised to power #1.}{}{ 0}}%
     \fi
}%
\def\XINT_pow_Aneg #1%
{%
   \ifodd #1
       \expandafter\XINT_opp\romannumeral0%
   \fi
   \XINT_pow_Apos {}{#1}%
}%
\def\XINT_pow_Apos #1#2{\XINT_pow_Apos_a {#2}#1}%
\def\XINT_pow_Apos_a #1#2#3%
{%
    \xint_gob_til_xint: #3\XINT_pow_Apos_short\xint:
    \XINT_pow_AatleastTwo {#1}#2#3%
}%
\def\XINT_pow_Apos_short\xint:\XINT_pow_AatleastTwo #1#2\xint:
{%
    \ifcase #2
         \xintError:thiscannothappen
    \or  \expandafter\XINT_pow_AisOne
    \else\expandafter\XINT_pow_AatleastTwo
    \fi {#1}#2\xint:
}%
\def\XINT_pow_AisOne #1\xint:{ 1}%
\def\XINT_pow_AatleastTwo #1%
{%
    \ifcase\XINT_cntSgn #1\xint:
        \expandafter\XINT_pow_BisZero
    \or
        \expandafter\XINT_pow_I_in
    \else
        \expandafter\XINT_pow_BisNegative
    \fi
    {#1}%
}%
\def\XINT_pow_BisNegative #1\xint:{\XINT_legacysignalcondition{Underflow}%
    {Inverse power is not an integer.}{}{ 0}}%
\def\XINT_pow_BisZero #1\xint:{ 1}%
%    \end{macrocode}
%\begin{lverb}
% B = #1 > 0, A = #2 > 1. Earlier code checked if size of B did not
% exceed a given limit (for example 131000).
%\end{lverb}
%    \begin{macrocode}
\def\XINT_pow_I_in #1#2\xint:%
   {\CALX_ntoraw{\CALX_npow{#1}{\CALX_nfromraw{#2}}}}%
%    \end{macrocode}
% \subsection{\csh{xintiiFac}}
%\begin{lverb}
% \xintiiFac{k}: k a \numexpr expression; k! as a raw integer, computed by
% calxcore's \CALX_nfac. Negative k or k > 10^4: InvalidOperation, 0.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiFac {\romannumeral0\xintiifac }%
\def\xintiifac #1{\expandafter\XINT_fac_fork\the\numexpr#1.}%
\def\XINT_fac_fork #1#2.%
{%
    \xint_UDzerominusfork
     #1-\XINT_fac_zero
     0#1\XINT_fac_neg
      0-\XINT_fac_checksize
    \krof #1#2.%
}%
\def\XINT_fac_zero #1.{ 1}%
\def\XINT_fac_neg  #1.{\XINT_legacysignalcondition{InvalidOperation}{Factorial of
    negative argument: #1.}{}{ 0}}%
\def\XINT_fac_checksize #1.%
{%
    \ifnum #1>\xint_c_e_iv \xint_dothis{\XINT_legacysignalcondition
      {InvalidOperation}{Factorial argument is too large: #1 > 10^4.}%
      {}{ 0}}\fi
    \xint_orthat{\CALX_ntoraw{\CALX_nfac{#1}}}%
}%
%    \end{macrocode}
% \subsection{\csh{XINT_useiimessage}}
%\begin{lverb}
% 1.2o
%\end{lverb}
%    \begin{macrocode}
\def\XINT_useiimessage #1% used in LaTeX only
{%
    \XINT_ifFlagRaised {#1}%
    {\@backslashchar#1
     (load xintfrac or use \@backslashchar xintii\xint_gobble_iv#1!)\MessageBreak}%
    {}%
}%
\XINTrestorecatcodesendinput%
%    \end{macrocode}
% \StoreCodelineNo {xintcore}
% \cleardoublepage\let\xintcorenameUp\undefined
%\gardesactifs
%\let</xintcore>\relax
%\let<*xint>\gardesinactifs
%</xintcore>^^A---------------------------------------------------
%<*xint>^^A-------------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname xintnameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section{Package \xintnameimp implementation}
% \RaisedLabel{sec:xintimp}
%
% \localtableofcontents
%
% \subsection{Introduction}
%
% With release |1.1| the core arithmetic routines |\xintiiAdd|,
% |\xintiiSub|, |\xintiiMul|, |\xintiiQuo|, |\xintiiPow| were separated to be
% the main component of the then new
% \xintcorenameimp.
%
% |1.3b| adds randomness related macros.
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode64=11   % @
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \catcode35=6    % #
  \def\odef#1{\expandafter\def\expandafter#1\expandafter}%
  \def\empty{}\def\space{ }\newlinechar10
  \def\z{\endgroup}%
  \def\odef#1{\expandafter\def\expandafter#1\expandafter}%
  \expandafter\let\expandafter\x\csname ver@xint.sty\endcsname
  \expandafter\let\expandafter\c\csname ver@calxint.sty\endcsname
  \expandafter\let\expandafter\w\csname ver@xintcore.sty\endcsname
  \expandafter\ifx\csname numexpr\endcsname\relax
    \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax
      \immediate\write128{^^JPackage xint Warning:^^J%
                          \space\space\space\space
                          \numexpr not available, aborting input.^^J}%
    \else
      \PackageWarningNoLine{xint}{\numexpr not available, aborting input}%
    \fi
    \def\z{\endgroup\endinput}%
  \else
    \ifx\x\relax   % plain-TeX, first loading of xint.sty
      \ifx\w\relax % but xintcore.sty not yet loaded.
         \odef\z{\z\input xintcore.sty\relax}%
      \fi
      \ifx\c\relax % but calxint.sty not yet loaded.
         \odef\z{\z\input calxint.sty\relax}%
      \fi
    \else
      \ifx\x\empty % LaTeX, first loading,
      % variable is initialized, but \ProvidesPackage not yet seen
          \ifx\w\relax % xintcore.sty not yet loaded.
            \odef\z{\z\RequirePackage{xintcore}}%
          \fi
          \ifx\c\relax % calxint.sty not yet loaded.
            \odef\z{\z\RequirePackage{calxint}}%
          \fi
      \else
        \def\z{\endgroup\endinput}% xint already loaded.
      \fi
    \fi
  \fi
\z%
\XINTsetupcatcodes% defined in xintkernel.sty (loaded by xintcore.sty)
%    \end{macrocode}
% \subsection{Package identification}
%    \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xint}%
  [2026/11/01 v2.0a1 Expandable operations on big integers (JFB)]%
%    \end{macrocode}
% \subsection{\csh{xintLen}, \csh{xintiLen}}
%\begin{lverb}
% \xintLen gets extended to fractions by xintfrac.sty: A/B is given
% length len(A)+len(B)-1 (somewhat arbitrary). It applies \xintNum to its
% argument. A minus sign is accepted and ignored.
%
%
% For parallelism with \xintiNum/\xintNum, 1.2o defines \xintiLen.
%
% \xintLen gets redefined by $xintfracnameimp.
%\end{lverb}
%    \begin{macrocode}
\def\xintiLen {\romannumeral0\xintilen }%
\def\xintilen #1{\def\xintilen ##1%
{%
    \expandafter#1\the\numexpr
    \expandafter\XINT_len_fork\romannumeral0\xintinum{##1}%
      \xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
      \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v
      \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye\relax
}}\xintilen{ }%
\def\xintLen {\romannumeral0\xintlen }%
\let\xintlen\xintilen
\def\XINT_len_fork #1%
{%
    \expandafter\XINT_length_loop\xint_UDsignfork#1{}-#1\krof
}%
%    \end{macrocode}
% \subsection{\csh{xintiiLogTen}}
%\begin{lverb}
% 1.3e. Support for ilog10() function in \xintiiexpr. See \XINTiLogTen
% in xintfrac.sty which also currently uses -"7FFF8000 as value if input is
% zero.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiLogTen {\the\numexpr\xintiilogten }%
\def\xintiilogten #1%
{%
    \expandafter\XINT_iilogten\romannumeral`&&@#1%
      \xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
      \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v
      \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye
    \relax
}%
\def\XINT_iilogten #1{\if#10-"7FFF8000\fi -1+%
                      \expandafter\XINT_length_loop\xint_UDsignfork#1{}-#1\krof}%
%    \end{macrocode}
% \subsection{\csh{xintReverseDigits}}
%\begin{lverb}
% 1.2.
%
% This puts digits in reverse order, not suppressing leading zeros
% after reverse. Despite lacking the "ii" in its name, it does not apply
% \xintNum to its argument (contrarily to \xintLen, this is not very coherent).
%
% 1.2l variant is robust against non terminated \the\numexpr input.
%
% This macro is currently not used elsewhere in xint code.
%\end{lverb}
%    \begin{macrocode}
\def\xintReverseDigits {\romannumeral0\xintreversedigits }%
\def\xintreversedigits #1%
{%
    \expandafter\XINT_revdigits\romannumeral`&&@#1%
     {\XINT_microrevsep_end\W}\XINT_microrevsep_end
      \XINT_microrevsep_end\XINT_microrevsep_end
      \XINT_microrevsep_end\XINT_microrevsep_end
      \XINT_microrevsep_end\XINT_microrevsep_end\XINT_microrevsep_end\Z
    1\Z!1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W
}%
\def\XINT_revdigits #1%
{%
    \xint_UDsignfork
      #1{\expandafter-\romannumeral0\XINT_revdigits_a}%
       -{\XINT_revdigits_a #1}%
    \krof
}%
\def\XINT_revdigits_a
{%
    \expandafter\XINT_revdigits_b\expandafter{\expandafter}%
    \the\numexpr\XINT_microrevsep
}%
\def\XINT_microrevsep #1#2#3#4#5#6#7#8#9%
{%
    1#9#8#7#6#5#4#3#2#1\expandafter!\the\numexpr\XINT_microrevsep
}%
\def\XINT_microrevsep_end #1\W #2\expandafter #3\Z{\relax#2!}%
\def\XINT_revdigits_b #11#2!1#3!1#4!1#5!1#6!1#7!1#8!1#9!%
{%
    \xint_gob_til_R #9\XINT_revdigits_end\R
                      \XINT_revdigits_b {#9#8#7#6#5#4#3#2#1}%
}%
\def\XINT_revdigits_end#1{%
\def\XINT_revdigits_end\R\XINT_revdigits_b ##1##2\W
   {\expandafter#1\xint_gob_til_Z ##1}%
}\XINT_revdigits_end{ }%
\let\xintRev\xintReverseDigits
%    \end{macrocode}
% \subsection{\csh{xintiiE}}
%\begin{lverb}
% Originally was used in \xintiiexpr. Transferred from xintfrac for
% 1.1.
% Code rewritten for 1.2i.
% \xintiiE{x}{e} extends x with e zeroes if e is positive and simply outputs
% x if e is zero or negative. Attention, le comportement pour e < 0 ne doit
% pas être modifié car \xintMod et autres macros en dépendent.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiE {\romannumeral0\xintiie }%
\def\xintiie #1#2%
   {\expandafter\XINT_iie_fork\the\numexpr #2\expandafter.\romannumeral`&&@#1;}%
\def\XINT_iie_fork #1%
{%
    \xint_UDsignfork
      #1\XINT_iie_neg
       -\XINT_iie_a
    \krof #1%
}%
%    \end{macrocode}
%\begin{lverb}
% le #2 a le bon pattern terminé par ; #1=0 est OK pour \XINT_rep.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_iie_a #1.%
 {\expandafter\XINT_dsx_append\romannumeral\XINT_rep #1\endcsname 0.}%
\def\XINT_iie_neg #1.#2;{ #2}%
%    \end{macrocode}
% \subsection{\csh{xintDecSplit}}
%\begin{lverb}
% DECIMAL SPLIT
%
% The macro \xintDecSplit {x}{A} cuts A which is composed of digits (leading
% zeroes ok, but no sign) (*) into two (each possibly empty) pieces L and R.
% The concatenation LR always reproduces A.
%
% The position of the cut is specified by the first argument x. If x is zero
% or positive the cut location is x slots to the left of the right end of the
% number. If x becomes equal to or larger than the length of the number then L
% becomes empty. If x is negative the location of the cut is |x| slots to the
% right of the left end of the number.
%
% (*) versions earlier than 1.2i first replaced A with its absolute value.
% This is not the case anymore. This macro should NOT be used for A with a
% leading sign (+ or -).
%
% Entirely rewritten for 1.2i (2016/12/11).
%
% Attention: \xintDecSplit not robust against non terminated second argument.
%\end{lverb}
%    \begin{macrocode}
\def\xintDecSplit {\romannumeral0\xintdecsplit }%
\def\xintdecsplit #1#2%
{%
    \expandafter\XINT_split_finish
    \romannumeral0\expandafter\XINT_split_xfork
    \the\numexpr #1\expandafter.\romannumeral`&&@#2%
    \xint_bye2345678\xint_bye..%
}%
\def\XINT_split_finish  #1.#2.{{#1}{#2}}%
\def\XINT_split_xfork #1%
{%
    \xint_UDzerominusfork
      #1-\XINT_split_zerosplit
      0#1\XINT_split_fromleft
       0-{\XINT_split_fromright #1}%
    \krof
}%
\def\XINT_split_zerosplit .#1\xint_bye#2\xint_bye..{ #1..}%
%    \end{macrocode}
%\begin{lverb}
% \XINT_split_fromleft and its subordinates (\XINT_split_fromleft_a, _b,
% _end_a, _clean, _end0 to _end7, _end_b) moved verbatim to calxcore.sty
% at 2.0a1: the float printer core in calxfp.sty uses them.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_split_fromright #1.#2\xint_bye
{%
    \expandafter\XINT_split_fromright_a
    \the\numexpr#1-\numexpr\XINT_length_loop
    #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
      \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v
      \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye
    .#2\xint_bye
}%
\def\XINT_split_fromright_a #1%
{%
    \xint_UDsignfork
      #1\XINT_split_fromleft
       -\XINT_split_fromright_Lempty
    \krof
}%
\def\XINT_split_fromright_Lempty #1.#2\xint_bye#3..{.#2.}%
%    \end{macrocode}
% \subsection{\csh{xintDecSplitL}}
%    \begin{macrocode}
\def\xintDecSplitL {\romannumeral0\xintdecsplitl }%
\def\xintdecsplitl #1#2%
{%
    \expandafter\XINT_splitl_finish
    \romannumeral0\expandafter\XINT_split_xfork
    \the\numexpr #1\expandafter.\romannumeral`&&@#2%
    \xint_bye2345678\xint_bye..%
}%
\def\XINT_splitl_finish #1.#2.{ #1}%
%    \end{macrocode}
% \subsection{\csh{xintDecSplitR}}
%    \begin{macrocode}
\def\xintDecSplitR {\romannumeral0\xintdecsplitr }%
\def\xintdecsplitr #1#2%
{%
    \expandafter\XINT_splitr_finish
    \romannumeral0\expandafter\XINT_split_xfork
    \the\numexpr #1\expandafter.\romannumeral`&&@#2%
    \xint_bye2345678\xint_bye..%
}%
\def\XINT_splitr_finish #1.#2.{ #2}%
%    \end{macrocode}
% \subsection{\csh{xintDSHr}}
%\begin{lverb}
% DECIMAL SHIFTS \xintDSH {x}{A}$\
% si x <= 0, fait A -> A.10^(|x|).
% si x >  0, et A >=0, fait A -> quo(A,10^(x))$\
% si x >  0, et A < 0, fait A -> -quo(-A,10^(x))$\
% (donc pour x > 0 c'est comme DSR itéré x fois)$\
% \xintDSHr donne le `reste' (si x<=0 donne zéro).
%
% Badly named macros.
% 
% Rewritten for 1.2i, this was old code and \xintDSx has changed interface.
%\end{lverb}
%    \begin{macrocode}
\def\xintDSHr {\romannumeral0\xintdshr }%
\def\xintdshr #1#2%
{%
    \expandafter\XINT_dshr_fork\the\numexpr#1\expandafter.\romannumeral`&&@#2;%
}%
\def\XINT_dshr_fork #1%
{%
    \xint_UDzerominusfork
      0#1\XINT_dshr_xzeroorneg
      #1-\XINT_dshr_xzeroorneg
       0-\XINT_dshr_xpositive
    \krof #1%
}%
\def\XINT_dshr_xzeroorneg #1;{ 0}%
\def\XINT_dshr_xpositive
{%
    \expandafter\xint_stop_atsecondoftwo\romannumeral0\XINT_dsx_xisPos
}%
%    \end{macrocode}
% \subsection{\csh{xintDSH}}
%    \begin{macrocode}
\def\xintDSH {\romannumeral0\xintdsh }%
\def\xintdsh #1#2%
{%
    \expandafter\XINT_dsh_fork\the\numexpr#1\expandafter.\romannumeral`&&@#2;%
}%
\def\XINT_dsh_fork #1%
{%
    \xint_UDzerominusfork
      #1-\XINT_dsh_xiszero
      0#1\XINT_dsx_xisNeg_checkA
       0-{\XINT_dsh_xisPos #1}%
    \krof
}%
\def\XINT_dsh_xiszero #1.#2;{ #2}%
\def\XINT_dsh_xisPos
{%
    \expandafter\xint_stop_atfirstoftwo\romannumeral0\XINT_dsx_xisPos
}%
%    \end{macrocode}
% \subsection{\csh{xintDSx}}
%\begin{lverb}
% --> Attention le cas x=0 est traité dans la même catégorie que x > 0 <--
%
%( si x < 0, fait A -> A.10^(|x|)
%: si x >=  0, et A >=0, fait A -> {quo(A,10^(x))}{rem(A,10^(x))}
%: si x >=  0, et A < 0, d'abord on calcule {quo(-A,10^(x))}{rem(-A,10^(x))}
%:    puis, si le premier n'est pas nul on lui donne le signe - 
%:          si le premier est nul on donne le signe - au second.
%)
% On peut donc toujours reconstituer l'original A par 10^x Q \pm R
% où il faut prendre le signe plus si Q est positif ou nul et le signe moins si
% Q est strictement négatif.
%
% Rewritten for 1.2i, this was old code.
%
%\end{lverb}
%    \begin{macrocode}
\def\xintDSx {\romannumeral0\xintdsx }%
\def\xintdsx #1#2%
{%
    \expandafter\XINT_dsx_fork\the\numexpr#1\expandafter.\romannumeral`&&@#2;%
}%
\def\XINT_dsx_fork #1%
{%
    \xint_UDzerominusfork
      #1-\XINT_dsx_xisZero
      0#1\XINT_dsx_xisNeg_checkA
       0-{\XINT_dsx_xisPos #1}%
    \krof
}%
\def\XINT_dsx_xisZero #1.#2;{{#2}{0}}%
\def\XINT_dsx_xisNeg_checkA #1.#2%
{%
    \xint_gob_til_zero #2\XINT_dsx_xisNeg_Azero 0%
    \expandafter\XINT_dsx_append\romannumeral\XINT_rep #1\endcsname 0.#2%
}%
\def\XINT_dsx_xisNeg_Azero #1;{ 0}%
\def\XINT_dsx_addzeros #1%
   {\expandafter\XINT_dsx_append\romannumeral\XINT_rep#1\endcsname0.}%
\def\XINT_dsx_addzerosnofuss #1%
   {\expandafter\XINT_dsx_append\romannumeral\xintreplicate{#1}0.}%
\def\XINT_dsx_append #1.#2;{ #2#1}%
\def\XINT_dsx_xisPos #1.#2%
{%
    \xint_UDzerominusfork
      #2-\XINT_dsx_AisZero
      0#2\XINT_dsx_AisNeg
       0-\XINT_dsx_AisPos
    \krof #1.#2%
}%
\def\XINT_dsx_AisZero #1;{{0}{0}}%
\def\XINT_dsx_AisNeg #1.-#2;%
{%
    \expandafter\XINT_dsx_AisNeg_checkiffirstempty
    \romannumeral0\XINT_split_xfork #1.#2\xint_bye2345678\xint_bye..%
}%
\def\XINT_dsx_AisNeg_checkiffirstempty #1%
{%
    \xint_gob_til_dot #1\XINT_dsx_AisNeg_finish_zero.%
    \XINT_dsx_AisNeg_finish_notzero #1%
}%
\def\XINT_dsx_AisNeg_finish_zero.\XINT_dsx_AisNeg_finish_notzero.#1.%
{%
    \expandafter\XINT_dsx_end
    \expandafter {\romannumeral0\XINT_num {-#1}}{0}%
}%
\def\XINT_dsx_AisNeg_finish_notzero #1.#2.%
{%
    \expandafter\XINT_dsx_end
    \expandafter {\romannumeral0\XINT_num {#2}}{-#1}%
}%
\def\XINT_dsx_AisPos #1.#2;%
{%
    \expandafter\XINT_dsx_AisPos_finish
    \romannumeral0\XINT_split_xfork #1.#2\xint_bye2345678\xint_bye..%
}%
\def\XINT_dsx_AisPos_finish #1.#2.%
{%
    \expandafter\XINT_dsx_end
    \expandafter {\romannumeral0\XINT_num {#2}}%
                 {\romannumeral0\XINT_num {#1}}%
}%
\def\XINT_dsx_end #1#2{\expandafter{#2}{#1}}%
%    \end{macrocode}
% \subsection{\csh{xintiiEq}}
%\begin{lverb}
% no \xintiieq.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiEq #1#2{\romannumeral0\xintiiifeq{#1}{#2}{1}{0}}%
%    \end{macrocode}
% \subsection{\csh{xintiiNotEq}}
%\begin{lverb}
% Pour xintexpr. Pas de version en lowercase.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiNotEq #1#2{\romannumeral0\xintiiifeq {#1}{#2}{0}{1}}%
%    \end{macrocode}
% \subsection{\csh{xintiiGeq}}
%\begin{lverb}
% PLUS GRAND OU ÉGAL
% attention compare les **valeurs absolues**
%
% 1.2l made \xintiiGeq robust against non terminated items.
%
% 1.2l rewrote \xintiiCmp, but forgot to handle \xintiiGeq too. Done at 1.2m.
%
% This macro should have been called \xintGEq for example.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiGeq   {\romannumeral0\xintiigeq }%
\def\xintiigeq #1{\expandafter\XINT_iigeq\romannumeral`&&@#1\xint:}%
\def\XINT_iigeq #1#2\xint:#3%
{%
    \expandafter\XINT_geq_fork\expandafter #1\romannumeral`&&@#3\xint:#2\xint:
}%
\def\XINT_geq #1#2\xint:#3%
{%
    \expandafter\XINT_geq_fork\expandafter #1\romannumeral0\xintnum{#3}\xint:#2\xint:
}%
\def\XINT_geq_fork #1#2%
{%
    \xint_UDzerofork
      #1\XINT_geq_firstiszero
      #2\XINT_geq_secondiszero
       0{}%
    \krof
    \xint_UDsignsfork
          #1#2\XINT_geq_minusminus
           #1-\XINT_geq_minusplus
           #2-\XINT_geq_plusminus
            --\XINT_geq_plusplus
    \krof #1#2%
}%
\def\XINT_geq_firstiszero  #1\krof 0#2#3\xint:#4\xint:
                              {\xint_UDzerofork #2{ 1}0{ 0}\krof }%
\def\XINT_geq_secondiszero #1\krof #20#3\xint:#4\xint:{ 1}%
\def\XINT_geq_plusminus    #1-{\XINT_geq_plusplus #1{}}%
\def\XINT_geq_minusplus    -#1{\XINT_geq_plusplus {}#1}%
\def\XINT_geq_minusminus    --{\XINT_geq_plusplus {}{}}%
\def\XINT_geq_plusplus
   {\expandafter\XINT_geq_finish\romannumeral0\XINT_cmp_plusplus}%
\def\XINT_geq_finish #1{\if-#1\expandafter\XINT_geq_no
                         \else\expandafter\XINT_geq_yes\fi}%
\def\XINT_geq_no 1{ 0}%
\def\XINT_geq_yes { 1}%
%    \end{macrocode}
% \subsection{\csh{xintiiGt}}
%    \begin{macrocode}
\def\xintiiGt #1#2{\romannumeral0\xintiiifgt{#1}{#2}{1}{0}}%
%    \end{macrocode}
% \subsection{\csh{xintiiLt}}
%    \begin{macrocode}
\def\xintiiLt #1#2{\romannumeral0\xintiiiflt{#1}{#2}{1}{0}}%
%    \end{macrocode}
% \subsection{\csh{xintiiGtorEq}}
%    \begin{macrocode}
\def\xintiiGtorEq #1#2{\romannumeral0\xintiiiflt {#1}{#2}{0}{1}}%
%    \end{macrocode}
% \subsection{\csh{xintiiLtorEq}}
%    \begin{macrocode}
\def\xintiiLtorEq #1#2{\romannumeral0\xintiiifgt {#1}{#2}{0}{1}}%
%    \end{macrocode}
% \subsection{\csh{xintiiIsZero}}
%\begin{lverb}
% 1.09a. restyled in 1.09i. 1.1 adds \xintiiIsZero, etc... for
% optimization in \xintexpr
%\end{lverb}
%    \begin{macrocode}
\def\xintiiIsZero {\romannumeral0\xintiiiszero }%
\def\xintiiiszero #1{\if0\xintiiSgn{#1}\xint_afterfi{ 1}\else\xint_afterfi{ 0}\fi}%
%    \end{macrocode}
% \subsection{\csh{xintiiIsNotZero}}
%\begin{lverb}
% 1.09a. restyled in 1.09i. 1.1 adds \xintiiIsZero, etc... for
% optimization in \xintexpr
%\end{lverb}
%    \begin{macrocode}
\def\xintiiIsNotZero {\romannumeral0\xintiiisnotzero }%
\def\xintiiisnotzero
          #1{\if0\xintiiSgn{#1}\xint_afterfi{ 0}\else\xint_afterfi{ 1}\fi}%
%    \end{macrocode}
% \subsection{\csh{xintiiIsOne}}
%\begin{lverb}
% Added in 1.03. 1.09a defines \xintIsOne. 1.1a adds \xintiiIsOne.
%
% \XINT_isOne rewritten for 1.2g. Works with expanded strict integers,
% positive or negative.
%
%
%
%\end{lverb}
%    \begin{macrocode}
\def\xintiiIsOne {\romannumeral0\xintiiisone }%
\def\xintiiisone #1{\expandafter\XINT_isone\romannumeral`&&@#1XY}%
\def\XINT_isone #1#2#3Y%
{%
    \unless\if#2X\xint_dothis{ 0}\fi
    \unless\if#11\xint_dothis{ 0}\fi
    \xint_orthat{ 1}%
}%
\def\XINT_isOne #1{\XINT_is_One#1XY}%
\def\XINT_is_One #1#2#3Y%
{%
    \unless\if#2X\xint_dothis0\fi
    \unless\if#11\xint_dothis0\fi
    \xint_orthat1%
}%
%    \end{macrocode}
% \subsection{\csh{xintiiOdd}}
%\begin{lverb}
% \xintOdd is needed for the xintexpr-essions even() and odd()
% functions (and also by \xintNewExpr).
%\end{lverb}
%    \begin{macrocode}
\def\xintiiOdd {\romannumeral0\xintiiodd }%
\def\xintiiodd #1%
{%
    \ifodd\xintLDg{#1} %<- intentional space
        \xint_afterfi{ 1}%
    \else
        \xint_afterfi{ 0}%
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintiiEven}}
%    \begin{macrocode}
\def\xintiiEven {\romannumeral0\xintiieven }%
\def\xintiieven #1%
{%
    \ifodd\xintLDg{#1} %<- intentional space
        \xint_afterfi{ 0}%
    \else
        \xint_afterfi{ 1}%
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintiiMON}}
%\begin{lverb}
% MINUS ONE TO THE POWER N
%\end{lverb}
%    \begin{macrocode}
\def\xintiiMON {\romannumeral0\xintiimon }%
\def\xintiimon #1%
{%
    \ifodd\xintLDg {#1} %<- intentional space
        \xint_afterfi{ -1}%
    \else
        \xint_afterfi{ 1}%
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintiiMMON}}
%\begin{lverb}
% MINUS ONE TO THE POWER N-1
%\end{lverb}
%    \begin{macrocode}
\def\xintiiMMON {\romannumeral0\xintiimmon }%
\def\xintiimmon #1%
{%
    \ifodd\xintLDg {#1} %<- intentional space
        \xint_afterfi{ 1}%
    \else
        \xint_afterfi{ -1}%
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintSgnFork}}
%\begin{lverb}
% Expandable three-way fork added in 1.07. The argument #1 must expand
% to non-self-ending -1,0 or 1. 1.09i with _thenstop (now _stop_at...).
%\end{lverb}
%    \begin{macrocode}
\def\xintSgnFork {\romannumeral0\xintsgnfork }%
\def\xintsgnfork #1%
{%
    \ifcase #1 \expandafter\xint_stop_atsecondofthree
            \or\expandafter\xint_stop_atthirdofthree
          \else\expandafter\xint_stop_atfirstofthree
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintiiifSgn}}
%\begin{lverb}
% Expandable three-way fork added in 1.09a. Branches expandably
% depending on whether <0, =0, >0. Choice of branch guaranteed in two steps.
%
% 1.09i has \xint_firstofthreeafterstop (now \xint_stop_atfirstofthree) etc
% for faster expansion.
%
% 1.1 adds \xintiiifSgn for optimization in xintexpr-essions. Should I move
% them to xintcore? (for bnumexpr)
%\end{lverb}
%    \begin{macrocode}
\def\xintiiifSgn {\romannumeral0\xintiiifsgn }%
\def\xintiiifsgn #1%
{%
    \ifcase \xintiiSgn{#1}
               \expandafter\xint_stop_atsecondofthree
            \or\expandafter\xint_stop_atthirdofthree
          \else\expandafter\xint_stop_atfirstofthree
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintiiifCmp}}
%\begin{lverb}
% 1.09e
% \xintifCmp {n}{m}{if n<m}{if n=m}{if n>m}. 1.1a adds ii variant
%\end{lverb}
%    \begin{macrocode}
\def\xintiiifCmp {\romannumeral0\xintiiifcmp }%
\def\xintiiifcmp #1#2%
{%
    \ifcase\xintiiCmp {#1}{#2}
               \expandafter\xint_stop_atsecondofthree
            \or\expandafter\xint_stop_atthirdofthree
          \else\expandafter\xint_stop_atfirstofthree
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintiiifEq}}
%\begin{lverb}
% 1.09a \xintifEq {n}{m}{YES if n=m}{NO if n<>m}. 1.1a adds ii variant
%\end{lverb}
%    \begin{macrocode}
\def\xintiiifEq {\romannumeral0\xintiiifeq }%
\def\xintiiifeq #1#2%
{%
    \if0\xintiiCmp{#1}{#2}%
               \expandafter\xint_stop_atfirstoftwo
          \else\expandafter\xint_stop_atsecondoftwo
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintiiifGt}}
%\begin{lverb}
% 1.09a \xintifGt {n}{m}{YES if n>m}{NO if n<=m}. 1.1a adds ii variant
%\end{lverb}
%    \begin{macrocode}
\def\xintiiifGt {\romannumeral0\xintiiifgt }%
\def\xintiiifgt #1#2%
{%
    \if1\xintiiCmp{#1}{#2}%
               \expandafter\xint_stop_atfirstoftwo
          \else\expandafter\xint_stop_atsecondoftwo
    \fi
}%
%    \end{macrocode}
% \subsection{\cshnolabel{xintiiifLt}}
%
% Moved to \calxintnameimp for stupid reasons.
%
% \subsection{\csh{xintiiifZero}}
%\begin{lverb}
% Expandable two-way fork added in 1.09a. Branches expandably depending on
% whether the argument is zero (branch A) or not (branch B). 1.09i restyling. By
% the way it appears (not thoroughly tested, though) that \if tests are faster
% than \ifnum tests. 1.1 adds ii  versions.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiifZero {\romannumeral0\xintiiifzero }%
\def\xintiiifzero #1%
{%
    \if0\xintiiSgn{#1}%
       \expandafter\xint_stop_atfirstoftwo
    \else
       \expandafter\xint_stop_atsecondoftwo
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintiiifNotZero}}
%    \begin{macrocode}
\def\xintiiifNotZero {\romannumeral0\xintiiifnotzero }%
\def\xintiiifnotzero #1%
{%
    \if0\xintiiSgn{#1}%
       \expandafter\xint_stop_atsecondoftwo
    \else
       \expandafter\xint_stop_atfirstoftwo
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintiiifOne}}
%\begin{lverb}
% added in 1.09i. 1.1a adds \xintiiifOne.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiifOne {\romannumeral0\xintiiifone }%
\def\xintiiifone #1%
{%
    \if1\xintiiIsOne{#1}%
       \expandafter\xint_stop_atfirstoftwo
    \else
       \expandafter\xint_stop_atsecondoftwo
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintiiifOdd}}
%\begin{lverb}
% 1.09e. Restyled in 1.09i. 1.1a adds \xintiiifOdd.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiifOdd {\romannumeral0\xintiiifodd }%
\def\xintiiifodd #1%
{%
    \if\xintiiOdd{#1}1%
       \expandafter\xint_stop_atfirstoftwo
    \else
       \expandafter\xint_stop_atsecondoftwo
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintifTrueAelseB}, \csh{xintifFalseAelseB}}
%\begin{lverb}
% 1.09i, with name changes at 1.2i.
%
% 1.2o uses \xintiiifNotZero, see comments to \xintAND etc... This will work
% fine with arguments being nested xintfrac.sty macros, without the overhead
% of \xintNum or \xintRaw parsing.
%\end{lverb}
%    \begin{macrocode}
\def\xintifTrueAelseB {\romannumeral0\xintiiifnotzero}%
\def\xintifFalseAelseB{\romannumeral0\xintiiifzero}%
%    \end{macrocode}
% \subsection{\csh{xintIsTrue}, \csh{xintIsFalse}}
%\begin{lverb}
% 1.09c. Suppressed at 1.2o. They seem not to have been documented, fortunately.
%\end{lverb}
%    \begin{macrocode}
%\let\xintIsTrue \xintIsNotZero
%\let\xintIsFalse\xintIsZero
%    \end{macrocode}
% \subsection{\csh{xintNOT}}
%\begin{lverb}
% 1.09c with name change at 1.2o.  Besides, the macro is now defined as ii-type.
%\end{lverb}
%    \begin{macrocode}
\def\xintNOT{\romannumeral0\xintiiiszero}%
%    \end{macrocode}
% \subsection{\csh{xintAND}, \csh{xintOR}, \csh{xintXOR}}
%\begin{lverb}
% Added with 1.09a. But they used \xintSgn, etc... rather than
% \xintiiSgn. This brings \xintNum overhead which is not really desired, and
% which is not needed for use by xintexpr.sty. At 1.2o I modify them to use
% only ii macros. This is enough for sign or zeroness even for xintfrac
% format, as manipulated inside the \xintexpr. Big hesitation whether there
% should be however \xintiiAND outputting 1 or 0 versus an \xintAND outputting
% 1[0] versus 0[0] for example.
%\end{lverb}
%    \begin{macrocode}
\def\xintAND {\romannumeral0\xintand }%
\def\xintand #1#2{\if0\xintiiSgn{#1}\expandafter\xint_firstoftwo
                             \else\expandafter\xint_secondoftwo\fi
                  { 0}{\xintiiisnotzero{#2}}}%
\def\xintOR {\romannumeral0\xintor }%
\def\xintor #1#2{\if0\xintiiSgn{#1}\expandafter\xint_firstoftwo
                            \else\expandafter\xint_secondoftwo\fi
                 {\xintiiisnotzero{#2}}{ 1}}%
\def\xintXOR {\romannumeral0\xintxor }%
\def\xintxor #1#2{\if\xintiiIsZero{#1}\xintiiIsZero{#2}%
                     \xint_afterfi{ 0}\else\xint_afterfi{ 1}\fi }%
%    \end{macrocode}
% \subsection{\csh{xintANDof}}
%\begin{lverb}
% New with 1.09a. \xintANDof works also with an empty list. Empty items
% however are not accepted.
%
% 1.2l made \xintANDof robust against non terminated items.
%
% 1.2o's \xintifTrueAelseB is now an ii macro, actually.
%
% 1.4. This macro as well as ORof and XORof were formally not used by
% xintexpr, which uses comma separated items, but at 1.4 xintexpr uses braced
% items. And the macros here got slightly refactored and \XINT_ANDof added for
% usage by xintexpr and the NewExpr hook. For some random reason I decided to
% use ^ as delimiter this has to do that other macros in xintfrac in same
% family (such as \xintGCDof, \xintSum) also use \xint: internally and
% although not strictly needed having two separate ones clarifies.
%  
%\end{lverb}
%    \begin{macrocode}
\def\xintANDof  {\romannumeral0\xintandof }%
\def\xintandof  #1{\expandafter\XINT_andof\romannumeral`&&@#1^}%
\def\XINT_ANDof {\romannumeral0\XINT_andof}%
\def\XINT_andof #1%
{%
    \xint_gob_til_^ #1\XINT_andof_yes ^%
    \xintiiifNotZero{#1}\XINT_andof\XINT_andof_no
}%
\def\XINT_andof_no  #1^{ 0}%
\def\XINT_andof_yes ^#1\XINT_andof_no{ 1}%
%    \end{macrocode}
% \subsection{\csh{xintORof}}
%\begin{lverb}
% New with 1.09a. Works also with an empty list. Empty items
% however are not accepted.
%
% 1.2l made \xintORof robust against non terminated items.
%
% Refactored at 1.4.
%\end{lverb}
%    \begin{macrocode}
\def\xintORof  {\romannumeral0\xintorof }%
\def\xintorof  #1{\expandafter\XINT_orof\romannumeral`&&@#1^}%
\def\XINT_ORof {\romannumeral0\XINT_orof}%
\def\XINT_orof #1%
{%
    \xint_gob_til_^ #1\XINT_orof_no ^%
    \xintiiifNotZero{#1}\XINT_orof_yes\XINT_orof
}%
\def\XINT_orof_yes#1^{ 1}%
\def\XINT_orof_no ^#1\XINT_orof{ 0}%
%    \end{macrocode}
% \subsection{\csh{xintXORof}}
%\begin{lverb}
% New with 1.09a. Works with an empty list, too.  Empty items
% however are not accepted. \XINT_xorof_c more
% efficient in 1.09i.
%
% 1.2l made \xintXORof robust against non terminated items.
%
% Refactored at 1.4 to use \numexpr (or an \ifnum). I have not tested if
% more efficient or not or if one can do better without \the.
% \XINT_XORof for xintexpr matters.
%\end{lverb}
%    \begin{macrocode}
\def\xintXORof  {\romannumeral0\xintxorof }%
\def\xintxorof  #1{\expandafter\XINT_xorof\romannumeral`&&@#1^}%
\def\XINT_XORof {\romannumeral0\XINT_xorof}%
\def\XINT_xorof {\if1\the\numexpr\XINT_xorof_a}%
\def\XINT_xorof_a #1%
{%
    \xint_gob_til_^ #1\XINT_xorof_e ^%
    \xintiiifNotZero{#1}{-}{}\XINT_xorof_a
}%
\def\XINT_xorof_e ^#1\XINT_xorof_a
   {1\relax\xint_afterfi{ 0}\else\xint_afterfi{ 1}\fi}%
%    \end{macrocode}
% \subsection{\csh{xintiiMax}}
%\begin{lverb}
% At 1.2m, a long-standing bug was fixed: \xintiiMax had the overhead of
% applying \xintNum to its arguments due to use of a sub-macro of \xintGeq
% code to which this overhead was added at some point.
%
% And on this occasion I reduced even more number of times input is grabbed.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiMax {\romannumeral0\xintiimax }%
\def\xintiimax #1%
{%
    \expandafter\xint_iimax \romannumeral`&&@#1\xint:
}%
\def\xint_iimax #1\xint:#2%
{%
    \expandafter\XINT_max_fork\romannumeral`&&@#2\xint:#1\xint:
}%
%    \end{macrocode}
%\begin{lverb}
% #3#4 vient du *premier*,
% #1#2 vient du *second*. I have renamed the sub-macros at 1.2m because the
% terminology was quite counter-intuitive; there was no bug, but still.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_max_fork #1#2\xint:#3#4\xint:
{%
    \xint_UDsignsfork
          #1#3\XINT_max_minusminus  % A < 0, B < 0
           #1-\XINT_max_plusminus   % B < 0, A >= 0
           #3-\XINT_max_minusplus   % A < 0, B >= 0
            --{\xint_UDzerosfork
                      #1#3\XINT_max_zerozero % A = B = 0
                       #10\XINT_max_pluszero % B = 0, A > 0
                       #30\XINT_max_zeroplus % A = 0, B > 0
                        00\XINT_max_plusplus % A, B > 0
                      \krof }%
    \krof
    #3#1#2\xint:#4\xint:
      \expandafter\xint_stop_atfirstoftwo
    \else
      \expandafter\xint_stop_atsecondoftwo
    \fi
    {#3#4}{#1#2}%
}%
%    \end{macrocode}
%\begin{lverb}
% Refactored at 1.2m for avoiding grabbing arguments. Position of inputs
% shared with iiCmp and iiGeq code.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_max_zerozero  #1\fi{\xint_stop_atfirstoftwo }%
\def\XINT_max_zeroplus  #1\fi{\xint_stop_atsecondoftwo }%
\def\XINT_max_pluszero  #1\fi{\xint_stop_atfirstoftwo }%
\def\XINT_max_minusplus #1\fi{\xint_stop_atsecondoftwo }%
\def\XINT_max_plusminus #1\fi{\xint_stop_atfirstoftwo }%
\def\XINT_max_plusplus
{%
    \if1\romannumeral0\XINT_geq_plusplus
}%
%    \end{macrocode}
%\begin{lverb}
% Premier des testés |A|=-A, second est |B|=-B. On veut le max(A,B),
% c'est donc A si |A|<|B| (ou |A|=|B|, mais peu importe alors). Donc on peut
% faire cela avec \unless. Simple.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_max_minusminus --%
{%
    \unless\if1\romannumeral0\XINT_geq_plusplus{}{}%
}%
%    \end{macrocode}
% \subsection{\csh{xintiiMin}}
%\begin{lverb}
% New with 1.09a. I add \xintiiMin in 1.1 and \xintMin is
% an $xintfracnameimp macro.
%
% At 1.2m, a long-standing bug was fixed: \xintiiMin had the overhead of
% applying \xintNum to its arguments due to use of a sub-macro of \xintGeq
% code to which this overhead was added at some point.
%
% And on this occasion I reduced even more number of times input is grabbed.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiMin {\romannumeral0\xintiimin }%
\def\xintiimin #1%
{%
    \expandafter\xint_iimin \romannumeral`&&@#1\xint:
}%
\def\xint_iimin #1\xint:#2%
{%
    \expandafter\XINT_min_fork\romannumeral`&&@#2\xint:#1\xint:
}%
\def\XINT_min_fork #1#2\xint:#3#4\xint:
{%
    \xint_UDsignsfork
          #1#3\XINT_min_minusminus  % A < 0, B < 0
           #1-\XINT_min_plusminus   % B < 0, A >= 0
           #3-\XINT_min_minusplus   % A < 0, B >= 0
            --{\xint_UDzerosfork
                      #1#3\XINT_min_zerozero % A = B = 0
                       #10\XINT_min_pluszero % B = 0, A > 0
                       #30\XINT_min_zeroplus % A = 0, B > 0
                        00\XINT_min_plusplus % A, B > 0
                      \krof }%
    \krof
    #3#1#2\xint:#4\xint:
      \expandafter\xint_stop_atsecondoftwo
    \else
      \expandafter\xint_stop_atfirstoftwo
    \fi
    {#3#4}{#1#2}%
}%
\def\XINT_min_zerozero  #1\fi{\xint_stop_atfirstoftwo }%
\def\XINT_min_zeroplus  #1\fi{\xint_stop_atfirstoftwo }%
\def\XINT_min_pluszero  #1\fi{\xint_stop_atsecondoftwo }%
\def\XINT_min_minusplus #1\fi{\xint_stop_atfirstoftwo }%
\def\XINT_min_plusminus #1\fi{\xint_stop_atsecondoftwo }%
\def\XINT_min_plusplus
{%
    \if1\romannumeral0\XINT_geq_plusplus
}%
\def\XINT_min_minusminus --%
{%
    \unless\if1\romannumeral0\XINT_geq_plusplus{}{}%
}%
%    \end{macrocode}
% \subsection{\csh{xintiiMaxof}}
%\begin{lverb}
% New with 1.09a. 1.2 has NO MORE \xintMaxof, requires \xintfracname.
% 1.2a adds \xintiiMaxof, as \xintiiMaxof:csv is not public.
%
% NOT compatible with empty list.
%
% 1.2l made \xintiiMaxof robust against non terminated items.
%
% 1.4 refactors code to allow empty argument. For usage by \xintiiexpr.
% Slight deterioration, will come back.
%
%\end{lverb}
%    \begin{macrocode}
\def\xintiiMaxof {\romannumeral0\xintiimaxof }%
\def\xintiimaxof #1{\expandafter\XINT_iimaxof\romannumeral`&&@#1^}%
\def\XINT_iiMaxof{\romannumeral0\XINT_iimaxof}%
\def\XINT_iimaxof#1%
{%
    \xint_gob_til_^ #1\XINT_iimaxof_empty ^%
    \expandafter\XINT_iimaxof_loop\romannumeral`&&@#1\xint:
}%
\def\XINT_iimaxof_empty ^#1\xint:{ 0}%
\def\XINT_iimaxof_loop #1\xint:#2%
{%
    \xint_gob_til_^ #2\XINT_iimaxof_e ^%
    \expandafter\XINT_iimaxof_loop\romannumeral0\xintiimax{#1}{#2}\xint:
}%
\def\XINT_iimaxof_e ^#1\xintiimax #2#3\xint:{ #2}%
%    \end{macrocode}
% \subsection{\csh{xintiiMinof}}
%\begin{lverb}
% 1.09a. 1.2a adds \xintiiMinof which was lacking.
%
% 1.4 refactoring for \xintiiexpr matters.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiMinof {\romannumeral0\xintiiminof }%
\def\xintiiminof #1{\expandafter\XINT_iiminof\romannumeral`&&@#1^}%
\def\XINT_iiMinof{\romannumeral0\XINT_iiminof}%
\def\XINT_iiminof#1%
{%
    \xint_gob_til_^ #1\XINT_iiminof_empty ^%
    \expandafter\XINT_iiminof_loop\romannumeral`&&@#1\xint:
}%
\def\XINT_iiminof_empty ^#1\xint:{ 0}%
\def\XINT_iiminof_loop #1\xint:#2%
{%
    \xint_gob_til_^ #2\XINT_iiminof_e ^%
    \expandafter\XINT_iiminof_loop\romannumeral0\xintiimin{#1}{#2}\xint:
}%
\def\XINT_iiminof_e ^#1\xintiimin #2#3\xint:{ #2}%
%    \end{macrocode}
% \subsection{\csh{xintiiSum}}
%\begin{lverb}
% \xintiiSum {{a}{b}...{z}}
%  Refactored at 1.4 for matters initially related to xintexpr delimiter
%  choice.
%
%
%\end{lverb}
%    \begin{macrocode}
\def\xintiiSum {\romannumeral0\xintiisum }%
\def\xintiisum #1{\expandafter\XINT_iisum\romannumeral`&&@#1^}%
\def\XINT_iiSum{\romannumeral0\XINT_iisum}%
\def\XINT_iisum #1{\expandafter\XINT_iisum_loop\expandafter{\romannumeral0\CALX_nfromraw{0}}{#1}}%
\def\XINT_iisum_loop #1#2{%
    \xint_gob_til_^ #2\XINT_iisum_end ^%
    \XINT_iisum_next{#1}{#2}%
}%
\def\XINT_iisum_next #1#2{%
    \expandafter\XINT_iisum_next_a\romannumeral0\CALX_nfromraw{#2}\xint:{#1}%
}%
\def\XINT_iisum_next_a #1\xint:#2{%
    \expandafter\XINT_iisum_loop\expandafter
    {\romannumeral0\CALX_naddready{#2}{#1}}%
}%
\def\XINT_iisum_end ^\XINT_iisum_next #1#2{\CALX_ntoraw{#1}}%
%    \end{macrocode}
% \subsection{\csh{xintiiPrd}}
%\begin{lverb}
% \xintiiPrd {{a}...{z}}
%
%
% Macros renamed and refactored (slightly more macros here to supposedly bring
% micro-gain) at 1.4 to match changes in xintfrac of delimiter, in sync with
% some usage in xintexpr.
%
% Contrarily to the xintfrac version \xintPrd, this one aborts as soon as it
% hits a zero value.
% 
%
%\end{lverb}
%    \begin{macrocode}
\def\xintiiPrd {\romannumeral0\xintiiprd }%
\def\xintiiprd #1{\expandafter\XINT_iiprd\romannumeral`&&@#1^}%
\def\XINT_iiPrd{\romannumeral0\XINT_iiprd}%
%    \end{macrocode}
%\begin{lverb}
% The above romannumeral caused f-expansion of the list argument.
% We f-expand below the first item and each successive items because
% The product is accumulated in native format; each factor is converted
% once, and the accumulator is converted back to raw at the end.
%
%\end{lverb}
%    \begin{macrocode}
\def\XINT_iiprd #1{\expandafter\XINT_iiprd_loop\expandafter{\romannumeral0\CALX_nfromraw{1}}{#1}}%
\def\XINT_iiprd_loop #1#2{%
    \xint_gob_til_^ #2\XINT_iiprd_end ^%
    \XINT_iiprd_next{#1}{#2}%
}%
\def\XINT_iiprd_next #1#2{%
    \expandafter\XINT_iiprd_next_a\romannumeral0\CALX_nfromraw{#2}\xint:{#1}%
}%
\def\XINT_iiprd_next_a #1\xint:#2{%
    \expandafter\XINT_iiprd_loop\expandafter
    {\romannumeral0\CALX_nmulready{#2}{#1}}%
}%
\def\XINT_iiprd_end ^\XINT_iiprd_next #1#2{\CALX_ntoraw{#1}}%
%    \end{macrocode}
% \subsection{\csh{xintiiSquareRoot}}
%\begin{lverb}
% First done with 1.08.
%
% 1.1 added \xintiiSquareRoot.
% 
% 1.1a added \xintiiSqrtR.
%
% 1.2f (2016/03/01-02-03) has rewritten the implementation, the underlying
% mathematics remaining about the same. The routine is much faster for inputs
% having up to 16 digits (because it does it all with \numexpr directly now),
% and also much faster for very long inputs (because it now fetches only the
% needed new digits after the first 16 (or 17) ones, via the geometric
% sequence 16, then 32, then 64, etc...; earlier version did the computations
% with all remaining digits after a suitable starting point with correct 4 or
% 5 leading digits). Note however that the fetching of tokens is via
% intrinsically O(N^2) macros, hence inevitably inputs with thousands of
% digits start being treated less well.
%
% Actually there is some room for improvements, one could prepare better
% input X for the upcoming treatment of fetching its digits by 16, then 32,
% then 64, etc...
%
% Incidently, as \xintiiSqrt uses subtraction and subtraction was broken from
% 1.2 to 1.2c, then for another reason from 1.2c to 1.2f, it could
% get wrong in certain (relatively rare) cases. There was also a bug that
% made it unneedlessly slow for odd number of digits on input.
%
% 1.2f also modifies \xintFloatSqrt in xintfrac.sty which now has more
% code in common with here and benefits from the same speed improvements.
%
% 1.2k belatedly corrects the output to {1}{1} and not 11 when input is zero.
% As braces are used in all other cases they should have been used here too.
%
% Also, 1.2k adds an \xintiSqrtR macro, for coherence as \xintiSqrt is
% defined (and mentioned in user manual.)
%
%
% calx (s58): at most 16 digits, calxint's \CALX_sqrt_start (Burnol's
% start, small and medium paths) as before; more than 16 digits, calxint's
% native \CALX_nsqrtrem: {S}{R} with S = isqrt(X), R = X - S^2, and the
% output {S+1}{2S+1-R} (\XINT_sqrt_nb, \XINT_sqrt_nc). xint's big path
% (\XINT_sqrt_big_*) is deleted. The digit count is that of \xintlength,
% so a count register (one token) still takes the \numexpr small path.
%\end{lverb}
%
%    \begin{macrocode}
\def\xintiiSquareRoot {\romannumeral0\xintiisquareroot }%
\def\xintiisquareroot #1{\expandafter\XINT_sqrt_checkin\romannumeral`&&@#1\xint:}%
\def\XINT_sqrt_checkin #1%
{%
    \xint_UDzerominusfork
     #1-\XINT_sqrt_iszero
     0#1\XINT_sqrt_isneg
      0-\XINT_sqrt
    \krof #1%
}%
\def\XINT_sqrt_iszero #1\xint:{{1}{1}}%
\def\XINT_sqrt_isneg  #1\xint:
   {\XINT_legacysignalcondition{InvalidOperation}%
                         {Square root of negative: #1.}{}{{0}{0}}}%
\def\XINT_sqrt #1\xint:
{%
    \expandafter\XINT_sqrt_a\romannumeral0\xintlength {#1}.#1.%
}%
\def\XINT_sqrt_a #1.%
{%
    \ifnum #1>\xint_c_xvi \expandafter\XINT_sqrt_n\fi
    \CALX_sqrt_start #1.%
}%
\def\XINT_sqrt_n\CALX_sqrt_start #1.#2.%
{%
    \expandafter\XINT_sqrt_nb\romannumeral0\CALX_nsqrtrem{\CALX_nfromraw{#2}}%
}%
\def\XINT_sqrt_nb #1#2%
{%
    \expandafter\XINT_sqrt_nc
    \romannumeral0\CALX_nadd{#1}{\XINT_sqrt_one}\xint:{#1}{#2}%
}%
\def\XINT_sqrt_nc #1\xint:#2#3%
{%
    \expanded{{\romannumeral0\CALX_ntoraw{#1}}%
              {\romannumeral0\CALX_ntoraw{\CALX_nsub{\CALX_nadd{#1}{#2}}{#3}}}}%
}%
\expandafter\def\expandafter\XINT_sqrt_one\expandafter{\string N+1.100000001!}%
%    \end{macrocode}
% \subsection{\csh{xintiiSqrt}, \csh{xintiiSqrtR}}
%    \begin{macrocode}
\def\xintiiSqrt  {\romannumeral0\xintiisqrt  }%
\def\xintiisqrt  {\expandafter\XINT_sqrt_post\romannumeral0\xintiisquareroot  }%
\def\XINT_sqrt_post #1#2{\XINT_dec #1\XINT_dec_bye234567890\xint_bye}%
\def\xintiiSqrtR {\romannumeral0\xintiisqrtr }%
\def\xintiisqrtr {\expandafter\XINT_sqrtr_post\romannumeral0\xintiisquareroot }%
%    \end{macrocode}
%\begin{lverb}
% N = (#1)^2 - #2 avec #1 le plus petit possible et #2>0 (hence #2<2*#1).
% (#1-.5)^2=#1^2-#1+.25=N+#2-#1+.25. Si 0<#2<#1, <= N-0.75<N, donc rounded->#1
% si #2>=#1, (#1-.5)^2>=N+.25>N, donc rounded->#1-1.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_sqrtr_post #1#2%
   {\xintiiifLt {#2}{#1}{ #1}{\XINT_dec #1\XINT_dec_bye234567890\xint_bye}}%
%    \end{macrocode}
% \subsection{\csh{xintiiBinomial}}
%\begin{lverb}
% 2015/11/28-29 for 1.2f.
%
% 2016/11/19 for 1.2h: I truly can't understand why I hard-coded last
% year an error-message for arguments outside of the range for binomial
% formula. Naturally there should be no error but a rather a 0 return
% value for binomial(x,y), if y<0 or x<y !
%
% I really lack some kind of infinity or NaN value.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiBinomial {\romannumeral0\xintiibinomial }%
\def\xintiibinomial #1#2%
{%
    \expandafter\XINT_binom_pre\the\numexpr #1\expandafter.\the\numexpr #2.%
}%
\def\XINT_binom_pre #1.#2.%
{%
    \expandafter\XINT_binom_fork \the\numexpr#1-#2.#2.#1.%
}%
%    \end{macrocode}
%\begin{lverb}
% k.x-k.x. I hesitated to restrict maximal allowed value of x to 10000.
% Finally I don't. But due to using small multiplication and small division, x
% must have at most eight digits. If x>=2^31 an arithmetic overflow error will
% have happened already.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_binom_fork #1#2.#3#4.#5#6.%
{%
    \if-#5\xint_dothis{\XINT_legacysignalcondition{InvalidOperation}%
                       {Binomial with negative first argument: #5#6.}{}{ 0}}\fi
    \if-#1\xint_dothis{ 0}\fi
    \if-#3\xint_dothis{ 0}\fi
    \if0#1\xint_dothis{ 1}\fi
    \if0#3\xint_dothis{ 1}\fi
    \ifnum #5#6>\xint_c_e_viii_mone\xint_dothis
       {\XINT_legacysignalcondition{InvalidOperation}%
            {Binomial with too large argument: #5#6 >= 10^8.}{}{ 0}}\fi
    \ifnum #1#2>#3#4  \xint_dothis{\CALX_ntoraw{\CALX_binom_a #1#2.#3#4.}}\fi
                      \xint_orthat{\CALX_ntoraw{\CALX_binom_a #3#4.#1#2.}}%
}%
%    \end{macrocode}
%\begin{lverb}
% x-k.k. avec 0<k<x, k<=x-k. Les divisions produiront en extra après le
% quotient un terminateur 1!\Z!0!. On va procéder par petite multiplication
% suivie par petite division. Donc ici on met le 1!\Z!0! pour amorcer.
%
% The engine (\CALX_binom_a of calxint) has native N output, converted by
% \CALX_ntoraw.
%\end{lverb}
%    \begin{macrocode}
%    \end{macrocode}
% \subsection{\csh{xintiiPFactorial}}
%\begin{lverb}
% 2015/11/29 for 1.2f. Partial factorial pfac(a,b)=(a+1)...b, only for
% non-negative integers with a<=b<10^8.
%
% 1.2h (2016/11/20) removes the non-negativity condition. It was a bit
% unfortunate that the code raised \xintError:OutOfRangePFac if 0<=a<=b<10^8
% was violated. The rule now applied is to interpret pfac(a,b) as the product
% for a<j<=b (not as a ratio of Gamma function), hence if a>=b, return 1
% because of an empty product. If a<b: if a<0, return 0 for b>=0 and
% (-1)^(b-a) times |b|...(|a|-1) for b<0. But only for the range 0<=
% a <= b < 10^8 is the macro result to be considered as stable.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiPFactorial {\romannumeral0\xintiipfactorial }%
\def\xintiipfactorial #1#2%
{%
    \expandafter\XINT_pfac_fork\the\numexpr#1\expandafter.\the\numexpr #2.%
}%
\def\xintPFactorial{\romannumeral0\xintpfactorial}%
\let\xintpfactorial\xintiipfactorial
%    \end{macrocode}
%\begin{lverb}
% The product is computed by calxcore's \CALX_npfac.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_pfac_fork #1#2.#3#4.%
{%
    \unless\ifnum #1#2<#3#4 \xint_dothis\XINT_pfac_one\fi
    \if-#3\xint_dothis\XINT_pfac_neg\fi
    \if-#1\xint_dothis\XINT_pfac_zero\fi
    \ifnum #3#4>\xint_c_e_viii_mone\xint_dothis\XINT_pfac_outofrange\fi
    \xint_orthat \XINT_pfac_a #1#2.#3#4.%
}%
\def\XINT_pfac_outofrange #1.#2.%
   {\XINT_legacysignalcondition{InvalidOperation}%
         {pFactorial with too large argument: #2 >= 10^8.}{}{ 0}}%
\def\XINT_pfac_one        #1.#2.{ 1}%
\def\XINT_pfac_zero       #1.#2.{ 0}%
\def\XINT_pfac_neg -#1.-#2.%
{%
    \ifnum #1>\xint_c_e_viii\xint_dothis\XINT_pfac_outofrange\fi
    \xint_orthat
   {\ifodd\numexpr#2-#1\relax\xint_afterfi{\expandafter-\romannumeral`&&@}\fi
    \expandafter\XINT_pfac_a }%
    \the\numexpr #2-\xint_c_i\expandafter.\the\numexpr#1-\xint_c_i.%
}%
\def\XINT_pfac_a #1.#2.{\CALX_ntoraw{\CALX_npfac{#1}{#2}}}%
%    \end{macrocode}
% \subsection{\csh{xintiiGCD}}
%\begin{lverb}
% Computed by calxint's \CALX_ngcd (Euclid's algorithm on native integers).
%\end{lverb}
%    \begin{macrocode}
\def\xintiiGCD {\romannumeral0\xintiigcd }%
\def\xintiigcd #1#2%
   {\CALX_ntoraw{\CALX_ngcd{\CALX_nfromraw{#1}}{\CALX_nfromraw{#2}}}}%
%    \end{macrocode}
% \subsection{\csh{xintiiGCDof}}
%\begin{lverb}
% New with 1.09a (was located in xintgcd.sty).
%
% 1.2l adds protection against items being non-terminated \the\numexpr.
%
% 1.4 renames the macro into \xintiiGCDof and moves it here.
% Terminator modified to ^ for direct call by \xintiiexpr function.
%
% 1.4d fixes breakage inherited since 1.3d rom \xintiiGCD, in case
% any argument vanished.
%
% Currently does not support empty list of arguments.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiGCDof    {\romannumeral0\xintiigcdof }%
\def\xintiigcdof    #1{\expandafter\XINT_iigcdof_a\romannumeral`&&@#1^}%
\def\XINT_iigcdof_a #1{\expandafter\XINT_iigcdof_b\romannumeral`&&@#1!}%
\def\XINT_iigcdof_b #1!#2{\expandafter\XINT_iigcdof_c\romannumeral`&&@#2!{#1}!}%
\def\XINT_iigcdof_c #1{\xint_gob_til_^ #1\XINT_iigcdof_e ^\XINT_iigcdof_d #1}%
\def\XINT_iigcdof_d #1!{\expandafter\XINT_iigcdof_b\romannumeral0\xintiigcd {#1}}%
\def\XINT_iigcdof_e #1!#2!{ #2}%
%    \end{macrocode}
% \subsection{\csh{xintiiLCM}}
%\begin{lverb}
% Computed by calxint's \CALX_nlcm.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiLCM {\romannumeral0\xintiilcm}%
\def\xintiilcm #1#2%
   {\CALX_ntoraw{\CALX_nlcm{\CALX_nfromraw{#1}}{\CALX_nfromraw{#2}}}}%
%    \end{macrocode}
% \subsection{\csh{xintiiLCMof}}
%\begin{lverb}
% See comments of \xintiiGCDof.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiLCMof      {\romannumeral0\xintiilcmof }%
\def\xintiilcmof    #1{\expandafter\XINT_iilcmof_a\romannumeral`&&@#1^}%
\def\XINT_iilcmof_a #1{\expandafter\XINT_iilcmof_b\romannumeral`&&@#1!}%
\def\XINT_iilcmof_b #1!#2{\expandafter\XINT_iilcmof_c\romannumeral`&&@#2!{#1}!}%
\def\XINT_iilcmof_c #1{\xint_gob_til_^ #1\XINT_iilcmof_e ^\XINT_iilcmof_d #1}%
\def\XINT_iilcmof_d #1!{\expandafter\XINT_iilcmof_b\romannumeral0\xintiilcm {#1}}%
\def\XINT_iilcmof_e #1!#2!{ #2}%
\XINTrestorecatcodesendinput%
%    \end{macrocode}
% \StoreCodelineNo {xint}
% \cleardoublepage\let\xintnameUp\undefined
%\gardesactifs
%\let</xint>\relax
%\let<*xintbinhex>\gardesinactifs
%</xint>^^A-------------------------------------------------------
%<*xintbinhex>^^A-------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname xintbinhexnameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section{Package \xintbinhexnameimp implementation}
% \RaisedLabel{sec:binheximp}
%
% \localtableofcontents
%
% \subsection{Introduction}
%
% The commenting is currently (\xintbndldate) still very sparse.
%
% |1.2m| (|2017/07/31|) rewrote entirely the original macros coming with
% |1.08| (|2013/06/07|).
%
% At |1.2n| the dependencies on \xintcorenameimp were removed, so now the
% package loads only \xintkernelnameimp.
%
% Also at |1.2n| (|2017/08/06|), \cs{csname} governed expansion was used at some places
% rather than \cs{numexpr}. This increased the maximal input sizes for
% \csbxint{DecToHex}, \csbxint{DecToBin}, and \csbxint{BinToHex}.
%
% |1.4n| (|2025/09/05|) adds:
% \begin{itemize}[nosep]
% \item Conversion to and from octal base.
% \item Usage of \cs{expanded} in place of the \cs{csname}-based expansion
%   from |1.2n|.  This has increased the maximal input sizes.  The increase is
%   spectacular for the conversions between binary, octal and hexadecimal, the
%   limit on size being solely dependent on \TeX{} main memory size.  This
%   change however caused seemingly (but barely tested) a slight (1\%)
%   decrease in speed for \csbxint{DecToHex} and \csbxint{HexToDec}.
% \end{itemize}
%
% Note that the whole architecture was last re-thought in 2017 at a time
% \cs{expanded} did not exist.  The most subtle coding, which is the one
% regarding conversion to and from decimal radix is of such a nature that I am
% not motivated at this stage to modify it other than minimally (see initial
% code comments for \csbxint{DecToHex}).  So the \cs{expanded} was used
% therein but only for some subroutines.  For the conversions between binary,
% octal, and hexadecimal, the whole expansion basically is governed by a
% single \cs{expanded}.  But for legacy reasons and stylistic coherence across
% the codebase, the code keeps using |\romannumeral0| trigger at the start of
% the macros with a systematic naming scheme.  I am not much motivated to
% engage into systematic changes across about \dtt{20000} code lines in the
% \xintnameimp bundle!
%
% \xintexprnameimp loads \xintbinhexnameimp automatically as of |1.4n|.
% Formerly it supported only |"| prefix for hexadecimal, now it supports also
% |'| for octal, as well as |0x|, |0o| and |0b|.
%
% |1.4p| adds \csbxint{LowerHex} and \csbxint{UpperHex}.
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
% The code for reload detection was initially copied from \textsc{Heiko
% Oberdiek}'s packages, then modified.
%
% The method for catcodes was also initially directly inspired by these
% packages.
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode64=11   % @
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \def\empty{}\def\space{ }\newlinechar10
  \def\z{\endgroup}%
  \expandafter\let\expandafter\x\csname ver@xintbinhex.sty\endcsname
  \expandafter\let\expandafter\w\csname ver@xintkernel.sty\endcsname
  \expandafter\ifx\csname numexpr\endcsname\relax
    \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax
      \immediate\write128{^^JPackage xintbinhex Warning:^^J%
                          \space\space\space\space
                          \numexpr not available, aborting input.^^J}%
    \else
      \PackageWarningNoLine{xintbinhex}{\numexpr not available, aborting input}%
    \fi
    \def\z{\endgroup\endinput}%
  \else
    \ifx\x\relax   % plain-TeX, first loading of xintbinhex.sty
      \ifx\w\relax % but xintkernel.sty not yet loaded.
         \def\z{\endgroup\input xintkernel.sty\relax}%
      \fi
    \else
      \ifx\x\empty % LaTeX, first loading,
      % variable is initialized, but \ProvidesPackage not yet seen
          \ifx\w\relax % xintkernel.sty not yet loaded.
            \def\z{\endgroup\RequirePackage{xintkernel}}%
          \fi
      \else
        \def\z{\endgroup\endinput}% xintbinhex already loaded.
      \fi
    \fi
  \fi
\z%
\XINTsetupcatcodes% defined in xintkernel.sty
%    \end{macrocode}
% \subsection{Package identification}
%    \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintbinhex}%
  [2026/11/01 v2.0a1 Expandable radix conversions (2, 8, 10, and 16) (JFB)]%
%    \end{macrocode}
% \subsection{Storage macros}
% \changed{1.2n} Switch to \cs{csname}-governed expansion at various places.
%
% \changed{1.4n} Move two \cs{newcount}'s to \xintkernelnameimp.
%
% \changed{1.4n} This release uses \cs{expanded} in place of \cs{csname}
% governed expansion.  This means that the mysterious \cs{endcsname}'s have
% vanished from the storage macros.  And support for octal was added, hence
% a few more storage macros were added.
%
% \added[2025/09/15]{1.4p} New storage macros for expandable uppercasing and
% lowercasing utilities. I hesitate having the same but for all of |a..z| and
% |A..Z| but then should I allow more ascii chars beyond decimal digits?
%    \begin{macrocode}
\def\XINT_tmpa #1{\ifx\relax#1\else
  \expandafter\edef\csname XINT_csdth_#1\endcsname
  {\ifcase #1 0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or
              8\or 9\or A\or B\or C\or D\or E\or F\fi}%
  \expandafter\XINT_tmpa\fi }%
\XINT_tmpa {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}\relax
\def\XINT_tmpa #1{\ifx\relax#1\else
  \expandafter\edef\csname XINT_csdtb_#1\endcsname
  {\ifcase #1
   0000\or 0001\or 0010\or 0011\or 0100\or 0101\or 0110\or 0111\or
   1000\or 1001\or 1010\or 1011\or 1100\or 1101\or 1110\or 1111\fi}%
  \expandafter\XINT_tmpa\fi }%
\XINT_tmpa {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}\relax
\let\XINT_tmpa\relax
\expandafter\def\csname XINT_csbth_0000\endcsname {0}%
\expandafter\def\csname XINT_csbth_0001\endcsname {1}%
\expandafter\def\csname XINT_csbth_0010\endcsname {2}%
\expandafter\def\csname XINT_csbth_0011\endcsname {3}%
\expandafter\def\csname XINT_csbth_0100\endcsname {4}%
\expandafter\def\csname XINT_csbth_0101\endcsname {5}%
\expandafter\def\csname XINT_csbth_0110\endcsname {6}%
\expandafter\def\csname XINT_csbth_0111\endcsname {7}%
\expandafter\def\csname XINT_csbth_1000\endcsname {8}%
\expandafter\def\csname XINT_csbth_1001\endcsname {9}%
\expandafter\def\csname XINT_csbth_1010\endcsname {A}%
\expandafter\def\csname XINT_csbth_1011\endcsname {B}%
\expandafter\def\csname XINT_csbth_1100\endcsname {C}%
\expandafter\def\csname XINT_csbth_1101\endcsname {D}%
\expandafter\def\csname XINT_csbth_1110\endcsname {E}%
\expandafter\def\csname XINT_csbth_1111\endcsname {F}%
\expandafter\def\csname XINT_csbto_000\endcsname {0}%
\expandafter\def\csname XINT_csbto_001\endcsname {1}%
\expandafter\def\csname XINT_csbto_010\endcsname {2}%
\expandafter\def\csname XINT_csbto_011\endcsname {3}%
\expandafter\def\csname XINT_csbto_100\endcsname {4}%
\expandafter\def\csname XINT_csbto_101\endcsname {5}%
\expandafter\def\csname XINT_csbto_110\endcsname {6}%
\expandafter\def\csname XINT_csbto_111\endcsname {7}%
\expandafter\def\csname XINT_cshtb_0\endcsname {0000}%
\expandafter\def\csname XINT_cshtb_1\endcsname {0001}%
\expandafter\def\csname XINT_cshtb_2\endcsname {0010}%
\expandafter\def\csname XINT_cshtb_3\endcsname {0011}%
\expandafter\def\csname XINT_cshtb_4\endcsname {0100}%
\expandafter\def\csname XINT_cshtb_5\endcsname {0101}%
\expandafter\def\csname XINT_cshtb_6\endcsname {0110}%
\expandafter\def\csname XINT_cshtb_7\endcsname {0111}%
\expandafter\def\csname XINT_cshtb_8\endcsname {1000}%
\expandafter\def\csname XINT_cshtb_9\endcsname {1001}%
\def\XINT_cshtb_A {1010}%
\def\XINT_cshtb_B {1011}%
\def\XINT_cshtb_C {1100}%
\def\XINT_cshtb_D {1101}%
\def\XINT_cshtb_E {1110}%
\def\XINT_cshtb_F {1111}%
\expandafter\def\csname XINT_csotb_0\endcsname {000}%
\expandafter\def\csname XINT_csotb_1\endcsname {001}%
\expandafter\def\csname XINT_csotb_2\endcsname {010}%
\expandafter\def\csname XINT_csotb_3\endcsname {011}%
\expandafter\def\csname XINT_csotb_4\endcsname {100}%
\expandafter\def\csname XINT_csotb_5\endcsname {101}%
\expandafter\def\csname XINT_csotb_6\endcsname {110}%
\expandafter\def\csname XINT_csotb_7\endcsname {111}%
\def\XINT_tmpa#1#2{%
  \ifx#1\relax\else
    \expandafter\def\csname XINT_lower #1\endcsname{#1}%
    \expandafter\def\csname XINT_upper #1\endcsname{#2}%
    \expandafter\def\csname XINT_lower #2\endcsname{#1}%
    \expandafter\def\csname XINT_upper #2\endcsname{#2}%
  \expandafter\XINT_tmpa\fi
}%
\XINT_tmpa 00112233445566778899aAbBcCdDeEfF\relax\relax
%    \end{macrocode}
% \subsection{Helper macros}
% We need at |1.4n| to ensure lengths either multiple of 5, 4 or 3.
% For multiples of three we simply imitate what we had in 2017
% for multiples of four.  For multiples of five we will do it
% rather ``in place'' appealing to \csbxint{Length} and
% \csbxint{Replicate} for convenience.  I suspected grabbing
% five by five (as we can't do ten by ten) would prove less
% efficient, but I am not motivated enough at this stage to
% devote the time needed for implementing and comparing.
% \subsubsection{\csh{XINT_zeroes_foriv}}
%\noindent
%\begin{lverb}
%( \romannumeral0\XINT_zeroes_foriv #1\R{0\R}{00\R}{000\R}$%
%:                                    \R{0\R}{00\R}{000\R}\R\W
%)
% expands to <empty> or 0 or 00 or 000 as needed to prepend to #1
% to extend it to length 4N.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_zeroes_foriv #1#2#3#4#5#6#7#8%
{%
    \xint_gob_til_R #8\XINT_zeroes_foriv_end\R\XINT_zeroes_foriv
}%
\def\XINT_zeroes_foriv_end\R\XINT_zeroes_foriv #1#2\W
   {\XINT_zeroes_foriv_done #1}%
\def\XINT_zeroes_foriv_done #1\R{ #1}%
%    \end{macrocode}
% \subsubsection{\csh{XINT_zeroes_foriii}}
% \added{1.4n}
%\begin{lverb}
%( \romannumeral0\XINT_zeroes_foriii #1\R{0\R}{00\R}$%
%:                                     \R{0\R}{00\R}$%
%:                                     \R{0\R}{00\R}\R\W
%)
% expands to <empty> or 0 or 00 as needed to prepend to #1
% to extend it to length 3N.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_zeroes_foriii #1#2#3#4#5#6#7#8#9%
{%
    \xint_gob_til_R #9\XINT_zeroes_foriii_end\R\XINT_zeroes_foriii
}%
\def\XINT_zeroes_foriii_end\R\XINT_zeroes_foriii #1#2\W
   {\XINT_zeroes_foriii_done #1}%
\def\XINT_zeroes_foriii_done #1\R{ #1}%
%    \end{macrocode}
% \subsection{\csh{xintDecToHex}}
%
% Now that illicit tools such as \ctanpackage{unravel} exist, we can not hide
% anymore too much the crux of the matter.  Let's simply say that the decimal
% input is tacitly converted into a sequence of successive elementary steps
% ``multiply by 10000 and add a base 10000 digit''.  This is made to act on a
% sequence of radix $16^4$ digits (note that $10000<16^4$).  Those radix
% $16^4$ digits are of course manipulated via \cs{numexpr} as $10^5$-based
% digits (note that $16^4<10^5$ and that not only $16^4\cdot 1000< 10^9
% <2^{31}$ but also $10^9+16^4\cdot 1000<2^{31}$ which helps in ensuring
% certain operations expand to a fixed number of digit tokens). When the
% sequence of elementary steps is complete, the base-$16^4$ digits only need
% to be converted to hexadecimal notation and purged of separators.  Of course
% doing the whole thing expandably requires some skill.  This was done when I
% was not yet an old man, and obviously was still very clever.  Enjoy.
%
%
% \changed{1.2m} Rewritten from scratch using the \xintcorenameimp
% |1.2| style.  Now guards against non terminated inputs.
%
% \changed{1.2n}
% Coding improvements, \cs{csname}-governed expansion, increased maximal size.
%
% \changed{1.2o}
% Again coding improvements (efficiency gain about 6\%).
%
% \changed{1.4n}
% Replacement of \cs{csname}-based expansion by usage of \cs{expanded}.  This
% has increased the maximal input size from 12035 to 16042 digits (depends on
% nesting level; evaluated with TL2025 default \TeX{} memory parameters, see
% user manual).  I noticed a slight performance decrease of the order of 1\%
% but did not test extensively.
%
% Perhaps \cs{expanded} could be used to a deeper refactoring but... I
% preferred to make minimal changes, not having kept in mind all subtle
% details of the 2017 code.
%    \begin{macrocode}
\def\xintDecToHex {\romannumeral0\xintdectohex }%
\def\xintdectohex #1%
{%
    \expandafter\XINT_dth_checkin\romannumeral`&&@#1\xint:
}%
\def\XINT_dth_checkin #1%
{%
    \xint_UDsignfork
       #1\XINT_dth_neg
        -{\XINT_dth_main #1}%
     \krof
}%
\def\XINT_dth_neg {\expandafter-\romannumeral0\XINT_dth_main}%
\def\XINT_dth_main #1\xint:
{%
    \expandafter\XINT_dth_finish
    \romannumeral`&&@\expandafter\XINT_dthb_start
    \romannumeral0\XINT_zeroes_foriv
       #1\R{0\R}{00\R}{000\R}\R{0\R}{00\R}{000\R}\R\W
    #1\xint_bye\XINT_dth_tohex
}%
\def\XINT_dthb_start #1#2#3#4#5%
{%
    \xint_bye#5\XINT_dthb_small\xint_bye\XINT_dthb_start_a #1#2#3#4#5%
}%
\def\XINT_dthb_small\xint_bye\XINT_dthb_start_a #1\xint_bye#2{#2#1!}%
\def\XINT_dthb_start_a #1#2#3#4#5#6#7#8#9%
{%
    \expandafter\XINT_dthb_again
    \the\numexpr\expandafter\XINT_dthb_update
    \the\numexpr#1#2#3#4%
    \xint_bye#9\XINT_dthb_lastpass\xint_bye
    #5#6#7#8!\XINT_dthb_exclam\relax\XINT_dthb_nextfour #9%
}%
%    \end{macrocode}
%\begin{lverb}
% The 1.2n inserted
% exclamations marks, which when bumping back from \XINT_dthb_again gave rise
% to a \numexpr-loop which gathered the ! delimited arguments and inserted
% \expandafter\XINT_dthb_update\the\numexpr dynamically. The 1.2o trick is to
% insert it here immediately. Then at \XINT_dthb_again the \numexpr will
% trigger an already prepared chain.
%
% The crux of the thing is handling of #3 at \XINT_dthb_update_a.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_dthb_exclam {!\XINT_dthb_exclam\relax
                       \expandafter\XINT_dthb_update\the\numexpr}%
\def\XINT_dthb_update #1!%
{%
    \expandafter\XINT_dthb_update_a
    \the\numexpr (#1+\xint_c_ii^xv)/\xint_c_ii^xvi-\xint_c_i\xint:
    #1\xint:%
}%
%    \end{macrocode}
% The four zeros here will get appended to prior digits.  They enact
% the multiplication by 10000.
%    \begin{macrocode}
\def\XINT_dthb_update_a #1\xint:#2\xint:#3%
{%
    0000+#1\expandafter#3\the\numexpr#2-#1*\xint_c_ii^xvi
}%
\def\XINT_dthb_nextfour #1#2#3#4#5%
{%
    \xint_bye#5\XINT_dthb_lastpass\xint_bye
    #1#2#3#4!\XINT_dthb_exclam\relax\XINT_dthb_nextfour#5%
}%
\def\XINT_dthb_lastpass\xint_bye #1!#2\xint_bye#3{#1!#3!}%
\def\XINT_dthb_again #1!#2#3%
{%
    \ifx#3\relax
          \expandafter\xint_firstoftwo
      \else
          \expandafter\xint_secondoftwo
    \fi
    {\expandafter\XINT_dthb_again
     \the\numexpr
     \ifnum #1>\xint_c_
        \xint_afterfi{\expandafter\XINT_dthb_update\the\numexpr#1}%
     \fi}%
    {\ifnum #1>\xint_c_ \xint_dothis{#2#1!}\fi\xint_orthat{!#2!}}%
}%
%    \end{macrocode}
% |1.4n| replaces here \cs{csname}'s method by simpler \cs{expanded} control.
% This is the part of the algorithm which rewrites base $16^4$ (kept in decimal)
% digits into four hexadecimal digits.
%    \begin{macrocode}
\def\XINT_dth_tohex
{%
    \expandafter\XINT_dth_tohex_a\expanded\XINT_tofourhex
}%
\def\XINT_dth_tohex_a{!\XINT_dth_tohex!}%
\def\XINT_tofourhex #1!%
{%
    {\iffalse}\fi\expandafter\XINT_tofourhex_a
    \the\numexpr (#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i\xint:
    #1\xint:
}%
\def\XINT_tofourhex_a #1\xint:#2\xint:
{%
    \expandafter\XINT_tofourhex_c
    \the\numexpr (#1+\xint_c_viii)/\xint_c_xvi-\xint_c_i\xint:
    #1\xint:
    #2-\xint_c_ii^viii*#1!%
}%
\def\XINT_tofourhex_c #1\xint:#2\xint:
{%
    \csname XINT_csdth_#1\endcsname
    \csname XINT_csdth_\the\numexpr #2-\xint_c_xvi*#1\endcsname
    \expandafter\XINT_tofourhex_d\the\numexpr
}%
\def\XINT_tofourhex_d #1!%
{%
    \expandafter\XINT_tofourhex_e
    \the\numexpr (#1+\xint_c_viii)/\xint_c_xvi-\xint_c_i\xint:
    #1\xint:
}%
\def\XINT_tofourhex_e #1\xint:#2\xint:
{%
    \csname XINT_csdth_#1\endcsname
    \csname XINT_csdth_\the\numexpr #2-\xint_c_xvi*#1\endcsname
    \iffalse{\fi}%
}%
%    \end{macrocode}
% We only clean up up to 3 hexadecimal zeros, as output is produced in chunks
% of 4 hex digits, and (this comment added at |1.4n|) as far as I understand
% the leading chunk can be |0000| only if input was vanishing.
%
% The coding for this simple trimming may not be the most efficient, but this
% code is executed only once.  I remember from 2017 that I had gotten tired to
% always try to optimize and did not even try to test efficiency.
%    \begin{macrocode}
\def\XINT_dth_finish !\XINT_dth_tohex!#1#2#3%
{%
    \unless\if#10\xint_dothis{ #1#2#3}\fi
    \unless\if#20\xint_dothis{ #2#3}\fi
    \unless\if#30\xint_dothis{ #3}\fi
    \xint_orthat{ }%
}%
%    \end{macrocode}
% \subsection{\csh{xintDecToOct}}
% \added{1.4n}
%
% This late extension to the package is imitated from (the \cs{expanded}
% updated) \csbxint{DecToHex}.
%
% It does not share macros with \csbxint{DecToHeX} to same extent as
% \csbxint{DecToBin} does (those macros with |_dthb_| in their names), because
% the input gets converted to radix |8^5|, not radix |16^4|.
%
% Note that we have $10000<8^5<100000$ and refer to \csbxint{DecToHex} for
% some information on the algorithm.
%    \begin{macrocode}
\def\xintDecToOct {\romannumeral0\xintdectooct }%
\def\xintdectooct #1%
{%
    \expandafter\XINT_dto_checkin\romannumeral`&&@#1\xint:
}%
\def\XINT_dto_checkin #1%
{%
    \xint_UDsignfork
       #1\XINT_dto_neg
        -{\XINT_dto_main #1}%
     \krof
}%
\def\XINT_dto_neg {\expandafter-\romannumeral0\XINT_dto_main}%
\def\XINT_dto_main #1\xint:
{%
    \expandafter\XINT_dto_finish
    \romannumeral`&&@\expandafter\XINT_dto_start
    \romannumeral0\XINT_zeroes_foriv
       #1\R{0\R}{00\R}{000\R}\R{0\R}{00\R}{000\R}\R\W
    #1\xint_bye\XINT_dto_tooct
}%
\def\XINT_dto_start #1#2#3#4#5%
{%
    \xint_bye#5\XINT_dto_small\xint_bye\XINT_dto_start_a #1#2#3#4#5%
}%
\def\XINT_dto_small\xint_bye\XINT_dto_start_a #1\xint_bye#2{#2#1!}%
\def\XINT_dto_start_a #1#2#3#4#5#6#7#8#9%
{%
    \expandafter\XINT_dto_again\the\numexpr\expandafter\XINT_dto_update
    \the\numexpr#1#2#3#4%
    \xint_bye#9\XINT_dto_lastpass\xint_bye
    #5#6#7#8!\XINT_dto_exclam\relax\XINT_dto_nextfour #9%
}%
\def\XINT_dto_exclam {!\XINT_dto_exclam\relax
                       \expandafter\XINT_dto_update\the\numexpr}%
\def\XINT_dto_update #1!%
{%
    \expandafter\XINT_dto_update_a
    \the\numexpr (#1+\xint_c_ii^xiv)/\xint_c_ii^xv-\xint_c_i\xint:
    #1\xint:%
}%
\def\XINT_dto_update_a #1\xint:#2\xint:#3%
{%
    0000+#1\expandafter#3\the\numexpr#2-#1*\xint_c_ii^xv
}%
\def\XINT_dto_nextfour #1#2#3#4#5%
{%
    \xint_bye#5\XINT_dto_lastpass\xint_bye
    #1#2#3#4!\XINT_dto_exclam\relax\XINT_dto_nextfour#5%
}%
\def\XINT_dto_lastpass\xint_bye #1!#2\xint_bye#3{#1!#3!}%
\def\XINT_dto_again #1!#2#3%
{%
    \ifx#3\relax
          \expandafter\xint_firstoftwo
      \else
          \expandafter\xint_secondoftwo
    \fi
    {\expandafter\XINT_dto_again
     \the\numexpr
     \ifnum #1>\xint_c_
        \xint_afterfi{\expandafter\XINT_dto_update\the\numexpr#1}%
     \fi}%
    {\ifnum #1>\xint_c_ \xint_dothis{#2#1!}\fi\xint_orthat{!#2!}}%
}%
\def\XINT_dto_tooct
{%
    \expandafter\XINT_dto_tooct_a\expanded\XINT_tofiveoct
}%
\def\XINT_dto_tooct_a{!\XINT_dto_tooct!}%
\def\XINT_tofiveoct #1!%
{%
    {\iffalse}\fi\expandafter\XINT_tofiveoct_a
    \the\numexpr (#1+\xint_c_ii^viii)/\xint_c_ii^ix-\xint_c_i\xint:
    #1\xint:
}%
\def\XINT_tofiveoct_a #1\xint:#2\xint:
{%
    \expandafter\XINT_tofiveoct_c
    \the\numexpr (#1+\xint_c_iv)/\xint_c_viii-\xint_c_i\xint:#1\xint:
    #2-\xint_c_ii^ix*#1!%
}%
\def\XINT_tofiveoct_c #1\xint:#2\xint:
{%
    #1\the\numexpr #2-\xint_c_viii*#1\relax
    \expandafter\XINT_tofiveoct_d\the\numexpr
}%
\def\XINT_tofiveoct_d #1!%
{%
    \expandafter\XINT_tofiveoct_e
    \the\numexpr (#1+\xint_c_ii^v)/\xint_c_ii^vi-\xint_c_i\xint:
    #1\xint:
}%
\def\XINT_tofiveoct_e #1\xint:#2\xint:
{%
    #1\expandafter\XINT_tofiveoct_f\the\numexpr #2-\xint_c_ii^vi*#1!%
}%
\def\XINT_tofiveoct_f #1!%
{%
    \expandafter\XINT_tofiveoct_g
    \the\numexpr (#1+\xint_c_iv)/\xint_c_viii-\xint_c_i\xint:
    #1\xint:
}%
\def\XINT_tofiveoct_g #1\xint:#2\xint:
{%
    #1\the\numexpr #2-\xint_c_viii*#1\iffalse{\fi}%
}%
%    \end{macrocode}
% We only clean-up up to 4 zero octal digits, as output was
% produced in chunks of 5 octal digits and as far as this author
% understands his own code, the leading block can not be vanishing,
% except when input was itself only with zeros.
%    \begin{macrocode}
\def\XINT_dto_finish !\XINT_dto_tooct!#1#2#3#4%
{%
    \unless\if#10\xint_dothis{ #1#2#3#4}\fi
    \unless\if#20\xint_dothis{ #2#3#4}\fi
    \unless\if#30\xint_dothis{ #3#4}\fi
    \unless\if#40\xint_dothis{ #4}\fi
    \xint_orthat{ }%
}%
%    \end{macrocode}
% \subsection{\csh{xintDecToBin}}
% An input without leading zeroes gives an output without leading zeroes.
%
% Macros with |_dtohb| in their names are shared with \csbxint{DecToHex}.
%
% \changed{1.2m}
% Complete rewrite in the |1.2| style. Also, |1.2m| version is robust
% against non terminated inputs.
%
% \changed{1.2n}
% Increased maximal size from using \cs{csname}-based expansion.
%
% \changed{1.4n}
% Same use of \cs{expanded} as in \csbxint{DecToHex}.
%    \begin{macrocode}
\def\xintDecToBin {\romannumeral0\xintdectobin }%
\def\xintdectobin #1%
{%
    \expandafter\XINT_dtb_checkin\romannumeral`&&@#1\xint:
}%
\def\XINT_dtb_checkin #1%
{%
    \xint_UDsignfork
       #1\XINT_dtb_neg
        -{\XINT_dtb_main #1}%
     \krof
}%
\def\XINT_dtb_neg {\expandafter-\romannumeral0\XINT_dtb_main}%
\def\XINT_dtb_main #1\xint:
{%
    \expandafter\XINT_dtb_finish
    \romannumeral`&&@\expandafter\XINT_dthb_start
    \romannumeral0\XINT_zeroes_foriv
       #1\R{0\R}{00\R}{000\R}\R{0\R}{00\R}{000\R}\R\W
    #1\xint_bye\XINT_dtb_tobin
}%
\def\XINT_dtb_tobin
{%
    \expandafter\XINT_dtb_tobin_a\expanded\XINT_tosixteenbits
}%
\def\XINT_dtb_tobin_a{!\XINT_dtb_tobin!}%
\def\XINT_tosixteenbits #1!%
{%
    {\iffalse}\fi\expandafter\XINT_tosixteenbits_a
    \the\numexpr (#1+\xint_c_ii^vii)/\xint_c_ii^viii-\xint_c_i\xint:
    #1\xint:
}%
\def\XINT_tosixteenbits_a #1\xint:#2\xint:
{%
    \expandafter\XINT_tosixteenbits_c
    \the\numexpr (#1+\xint_c_viii)/\xint_c_xvi-\xint_c_i\xint:
    #1\xint:
    #2-\xint_c_ii^viii*#1!%
}%
\def\XINT_tosixteenbits_c #1\xint:#2\xint:
{%
    \csname XINT_csdtb_#1\endcsname
    \csname XINT_csdtb_\the\numexpr #2-\xint_c_xvi*#1\endcsname
    \expandafter\XINT_tosixteenbits_d\the\numexpr
}%
\def\XINT_tosixteenbits_d #1!%
{%
    \expandafter\XINT_tosixteenbits_e
    \the\numexpr (#1+\xint_c_viii)/\xint_c_xvi-\xint_c_i\xint:
    #1\xint:
}%
\def\XINT_tosixteenbits_e #1\xint:#2\xint:
{%
    \csname XINT_csdtb_#1\endcsname
    \csname XINT_csdtb_\the\numexpr #2-\xint_c_xvi*#1\endcsname
    \iffalse{\fi}%
}%
\def\XINT_dtb_finish !\XINT_dtb_tobin!#1#2#3#4#5#6#7#8%
{%
    \expandafter\XINT_dtb_finish_a\the\numexpr #1#2#3#4#5#6#7#8\relax
}%
\def\XINT_dtb_finish_a #1{%
\def\XINT_dtb_finish_a ##1##2##3##4##5##6##7##8##9%
{%
    \expandafter#1\the\numexpr ##1##2##3##4##5##6##7##8##9\relax
}}\XINT_dtb_finish_a { }%
%    \end{macrocode}
% \subsection{\csh{xintHexToDec}}
%\begin{lverb}
% Completely (and belatedly) rewritten at 1.2m in the 1.2 style.
%
% 1.2m version robust against non terminated inputs, but there is no primitive
% from TeX which may generate hexadecimal digits and provoke expansion ahead,
% afaik, except of course if decimal digits are treated as hexadecimal. This
% robustness is not on purpose but from need to expand argument and then grab
% it again. So we do it safely.
%
% Increased maximal size at 1.2n.
%
% 1.2m version robust against non terminated inputs.
%
% An input without leading zeroes gives an output without leading zeroes.
%\end{lverb}
%    \begin{macrocode}
\def\xintHexToDec {\romannumeral0\xinthextodec }%
\def\xinthextodec #1%
{%
    \expandafter\XINT_htd_checkin\romannumeral`&&@#1\xint:
}%
\def\XINT_htd_checkin #1%
{%
    \xint_UDsignfork
       #1\XINT_htd_neg
        -{\XINT_htd_main #1}%
     \krof
}%
\def\XINT_htd_neg {\expandafter-\romannumeral0\XINT_htd_main}%
\def\XINT_htd_main #1\xint:
{%
    \expandafter\XINT_htd_startb
    \the\numexpr\expandafter\XINT_htd_starta
    \romannumeral0\XINT_zeroes_foriv
       #1\R{0\R}{00\R}{000\R}\R{0\R}{00\R}{000\R}\R\W
    #1\xint_bye!2!3!4!5!6!7!8!9!\xint_bye\relax
}%
\def\XINT_htd_starta #1#2#3#4{"#1#2#3#4+\xint_c_e_v!}%
\def\XINT_htd_startb 1#1%
{%
    \if#10\expandafter\XINT_htd_startba\else
          \expandafter\XINT_htd_startbb
    \fi 1#1%
}%
\def\XINT_htd_startba 10#1!{\XINT_htd_again #1%
    \xint_bye!2!3!4!5!6!7!8!9!\xint_bye\XINT_htd_nextfour}%
\def\XINT_htd_startbb 1#1#2!{\XINT_htd_again #1!#2%
    \xint_bye!2!3!4!5!6!7!8!9!\xint_bye\XINT_htd_nextfour}%
%    \end{macrocode}
% It is a bit annoying to grab all to the end here. I had a
% version, modeled on the |1.2n| variant of \csbxint{DecToHex} which solved
% that problem, but it did not prove much (or at all) faster in my brief
% testing and it had the defect of a reduced maximal allowed size of the
% input.
%    \begin{macrocode}
\def\XINT_htd_again #1\XINT_htd_nextfour #2%
{%
    \xint_bye #2\XINT_htd_finish\xint_bye
    \expandafter\XINT_htd_A\the\numexpr
    \XINT_htd_a #1\XINT_htd_nextfour #2%
}%
\def\XINT_htd_a #1!#2!#3!#4!#5!#6!#7!#8!#9!%
{%
    #1\expandafter\XINT_htd_update
    \the\numexpr #2\expandafter\XINT_htd_update
    \the\numexpr #3\expandafter\XINT_htd_update
    \the\numexpr #4\expandafter\XINT_htd_update
    \the\numexpr #5\expandafter\XINT_htd_update
    \the\numexpr #6\expandafter\XINT_htd_update
    \the\numexpr #7\expandafter\XINT_htd_update
    \the\numexpr #8\expandafter\XINT_htd_update
    \the\numexpr #9\expandafter\XINT_htd_update
    \the\numexpr \XINT_htd_a
}% 
\def\XINT_htd_nextfour #1#2#3#4%
{%
    *\xint_c_ii^xvi+"#1#2#3#4+\xint_c_e_ix\relax\xint_bye!%
    2!3!4!5!6!7!8!9!\xint_bye\XINT_htd_nextfour
}%
\def\XINT_htd_update 1#1#2#3#4#5%
{%
    *\xint_c_ii^xvi+10000#1#2#3#4#5!%
}%
%    \end{macrocode}
% \changed{1.4n}
% \csbXINT{_htd_A} small refactoring to introduce shared macros
% with the octal conversion routine.  Slight loss of efficiency.
%    \begin{macrocode}
\def\XINT_htd_A {\XINT_hotd_A\XINT_htd_again}%
\def\XINT_hotd_A #11#2%
{%
    \if#20\expandafter\XINT_hotd_Aa\else
          \expandafter\XINT_hotd_Ab
    \fi #11#2%
}%
\def\XINT_hotd_Aa #110#2#3#4#5{#1#2#3#4#5!}%
\def\XINT_hotd_Ab #11#2#3#4#5#6{#1#2!#3#4#5#6!}%
\def\XINT_htd_finish\xint_bye
    \expandafter\XINT_htd_A\the\numexpr \XINT_htd_a #1\XINT_htd_nextfour
{%
    \expandafter\XINT_htd_finish_cuz\the\numexpr0\XINT_htd_unsep_loop #1%
}%
\def\XINT_htd_unsep_loop #1!#2!#3!#4!#5!#6!#7!#8!#9!%
{%
    \expandafter\XINT_unsep_clean
    \the\numexpr 1#1#2\expandafter\XINT_unsep_clean
    \the\numexpr 1#3#4\expandafter\XINT_unsep_clean
    \the\numexpr 1#5#6\expandafter\XINT_unsep_clean
    \the\numexpr 1#7#8\expandafter\XINT_unsep_clean
    \the\numexpr 1#9\XINT_htd_unsep_loop_a
}%
\def\XINT_htd_unsep_loop_a #1!#2!#3!#4!#5!#6!#7!#8!#9!%
{%
    #1\expandafter\XINT_unsep_clean
    \the\numexpr 1#2#3\expandafter\XINT_unsep_clean
    \the\numexpr 1#4#5\expandafter\XINT_unsep_clean
    \the\numexpr 1#6#7\expandafter\XINT_unsep_clean
    \the\numexpr 1#8#9\XINT_htd_unsep_loop
}%
\def\XINT_unsep_clean 1{\relax}% also in xintcore
\def\XINT_htd_finish_cuz #1{%
\def\XINT_htd_finish_cuz ##1##2##3##4##5%
   {\expandafter#1\the\numexpr ##1##2##3##4##5\relax}%
}\XINT_htd_finish_cuz{ }%
%    \end{macrocode}
% \subsection{\csh{xintOctToDec}}
% \added{1.4n}
% Yes, the explanations are somewhat lacking. Basically this imitates
% \csbxint{xintHexToDec} the main difference being to handle 5 octal
% digits at a time in place of 4 hexadecimal ones.
%    \begin{macrocode}
\def\xintOctToDec {\romannumeral0\xintocttodec }%
\def\xintocttodec #1%
{%
    \expandafter\XINT_otd_checkin\romannumeral`&&@#1\xint:
}%
\def\XINT_otd_checkin #1%
{%
    \xint_UDsignfork
       #1\XINT_otd_neg
        -{\XINT_otd_main #1}%
     \krof
}%
\def\XINT_otd_neg {\expandafter-\romannumeral0\XINT_otd_main}%
%    \end{macrocode}
% First we inject leading octal zeroes to make the length a multiple of 5.  We
% do not try to code a direct way as with \csbXINT{_zeroes_foriv}, in part
% because as we can't grab 10 by 10, we would have to proceed 5 by 5, which
% for very long input may prove slower than using \csbxint{Length} combined
% with \csbxint{Replicate}, as provided by \xintkernelnameimp.  However, the
% author is not motivated enough to do the alternative coding and compare its
% efficiency with the one here.
%    \begin{macrocode}
\def\XINT_otd_main #1\xint:
{%
    \expandafter\XINT_otd_startb
    \the\numexpr\expandafter\XINT_otd_starta_i
                            \romannumeral0\xintlength{#1}\xint:
    #1\xint_bye!2!3!4!5!6!7!8!9!\xint_bye\relax
}%
\def\XINT_otd_starta_i #1\xint:
{%
    \expandafter\XINT_otd_starta
    \romannumeral\xintreplicate{\xint_c_v*((#1+\xint_c_ii)/\xint_c_v)-#1}{0}%
}%
%    \end{macrocode}
% Now we grab five octal digits and convert to decimal in a \cs{numexpr}.
%    \begin{macrocode}
\def\XINT_otd_starta #1#2#3#4#5{'#1#2#3#4#5+\xint_c_e_v!}%
\def\XINT_otd_startb 1#1%
{%
    \if#10\expandafter\XINT_otd_startba\else
          \expandafter\XINT_otd_startbb
    \fi 1#1%
}%
\def\XINT_otd_startba 10#1!{\XINT_otd_again #1%
    \xint_bye!2!3!4!5!6!7!8!9!\xint_bye\XINT_otd_nextfive}%
\def\XINT_otd_startbb 1#1#2!{\XINT_otd_again #1!#2%
    \xint_bye!2!3!4!5!6!7!8!9!\xint_bye\XINT_otd_nextfive}%
\def\XINT_otd_again #1\XINT_otd_nextfive #2%
{%
    \xint_bye #2\XINT_otd_finish\xint_bye
    \expandafter\XINT_otd_A\the\numexpr
    \XINT_otd_a #1\XINT_otd_nextfive #2%
}%
\def\XINT_otd_a #1!#2!#3!#4!#5!#6!#7!#8!#9!%
{%
    #1\expandafter\XINT_otd_update
    \the\numexpr #2\expandafter\XINT_otd_update
    \the\numexpr #3\expandafter\XINT_otd_update
    \the\numexpr #4\expandafter\XINT_otd_update
    \the\numexpr #5\expandafter\XINT_otd_update
    \the\numexpr #6\expandafter\XINT_otd_update
    \the\numexpr #7\expandafter\XINT_otd_update
    \the\numexpr #8\expandafter\XINT_otd_update
    \the\numexpr #9\expandafter\XINT_otd_update
    \the\numexpr \XINT_otd_a
}% 
\def\XINT_otd_nextfive #1#2#3#4#5%
{%
    *\xint_c_ii^xv+'#1#2#3#4#5+\xint_c_e_ix\relax\xint_bye!%
    2!3!4!5!6!7!8!9!\xint_bye\XINT_otd_nextfive
}%
\def\XINT_otd_update 1#1#2#3#4#5%
{%
    *\xint_c_ii^xv+10000#1#2#3#4#5!%
}%
%    \end{macrocode}
% We can hook here into the \csbxint{HexToDec} final sub-routines.
%    \begin{macrocode}
\def\XINT_otd_A {\XINT_hotd_A\XINT_otd_again}%
\def\XINT_otd_finish\xint_bye
    \expandafter\XINT_otd_A\the\numexpr \XINT_otd_a #1\XINT_otd_nextfive
{%
    \expandafter\XINT_htd_finish_cuz\the\numexpr0\XINT_htd_unsep_loop #1%
}%
%    \end{macrocode}
% \subsection{\csh{xintBinToDec}}
%\begin{lverb}
% Redone entirely for 1.2m. Starts by converting to hexadecimal
% first.
%
% Increased maximal size at 1.2n.
%
% An input without leading zeroes gives an output without leading zeroes.
%
% Robust against non-terminated input.
%\end{lverb}
%    \begin{macrocode}
\def\xintBinToDec {\romannumeral0\xintbintodec }%
\def\xintbintodec #1%
{%
    \expandafter\XINT_btd_checkin\romannumeral`&&@#1\xint:
}%
\def\XINT_btd_checkin #1%
{%
    \xint_UDsignfork
       #1\XINT_btd_N
        -{\XINT_btd_main #1}%
     \krof
}%
\def\XINT_btd_N {\expandafter-\romannumeral0\XINT_btd_main }%
\def\XINT_btd_main #1\xint:
{%
    \expandafter\XINT_btd_htd
    \expanded{\expandafter\XINT_bth_loop
    \romannumeral0\XINT_zeroes_foriv
       #1\R{0\R}{00\R}{000\R}\R{0\R}{00\R}{000\R}\R\W
    #1nonenone\xint_bye}\xint:
}%
\def\XINT_btd_htd #1\xint:
{%
    \expandafter\XINT_htd_startb
    \the\numexpr\expandafter\XINT_htd_starta
    \romannumeral0\XINT_zeroes_foriv
       #1\R{0\R}{00\R}{000\R}\R{0\R}{00\R}{000\R}\R\W
    #1\xint_bye!2!3!4!5!6!7!8!9!\xint_bye\relax
}%
%    \end{macrocode}
% \subsection{\csh{xintHexToOct}}
%
% \added{1.4n} This is done the lazy way, from hexadecimal to binary to octal.
% I am simply not motivated enough at this stage to implement a direct
% conversion (3 hexa digits mapping to 4 octal ones), handle leading zeros,
% and compare efficiency and size limits with the simple minded one here.
%    \begin{macrocode}
\def\xintHexToOct {\romannumeral0\xinthextooct }%
\def\xinthextooct #1%
{%
    \expandafter\XINT_bto_checkin
    \romannumeral0\expandafter\XINT_htb_checkin\romannumeral`&&@#1.........\xint_bye
    \iffalse{\fi}%
    \xint:
}%
%    \end{macrocode}
% \subsection{\csh{xintHexToBin}}
%\begin{lverb}
% Completely rewritten for 1.2m.
%
% Only up to three zeros are removed on front of output: if the input had a
% leading zero, there will be a leading zero (and then possibly 4n of them if
% inputs had more leading zeroes) on output.
%
% Rewritten again at 1.2n for \csname governed expansion.
%\end{lverb}
% \changed{1.4n}
% Use of \cs{expanded} (quasi globally, in contrast to the local uses
% made in the decimal conversions)..  Dramatic increase of upper limit
% on the size of input.
%
% As a by-product the initial expansion of the argument |#1| is now
% guarded at the end by (many) full stops, but anyhow I don't know
% \TeX{} construct potentially creating hexadecimal digits and
% potentially causing expansion of what comes next if not terminated.
%    \begin{macrocode}
\def\xintHexToBin {\romannumeral0\xinthextobin }%
\def\xinthextobin #1%
{%
    \expandafter\XINT_htb_checkin\romannumeral`&&@#1.........\xint_bye
    \iffalse{\fi}%
}%
\def\XINT_htb_checkin #1%
{%
    \xint_UDsignfork
       #1\XINT_htb_N
        -{\XINT_htb_main #1}%
     \krof
}%
\def\XINT_htb_N {\expandafter-\romannumeral0\XINT_htb_main }%
\def\XINT_htb_main
{%
    \expandafter\XINT_htb_cuz
    \expanded{\iffalse}\fi\XINT_htb_loop
}%
\def\XINT_htb_loop #1#2#3#4#5#6#7#8#9%
{%
     \csname XINT_cshtb_#1\endcsname
     \csname XINT_cshtb_#2\endcsname
     \csname XINT_cshtb_#3\endcsname
     \csname XINT_cshtb_#4\endcsname
     \csname XINT_cshtb_#5\endcsname
     \csname XINT_cshtb_#6\endcsname
     \csname XINT_cshtb_#7\endcsname
     \csname XINT_cshtb_#8\endcsname
     \csname XINT_cshtb_#9\endcsname
     \XINT_htb_loop
}%
\expandafter\let\csname XINT_cshtb_.\endcsname\xint_bye
\def\XINT_htb_cuz #1{%
\def\XINT_htb_cuz ##1##2##3##4%
   {\expandafter#1\the\numexpr##1##2##3##4\relax}%
}\XINT_htb_cuz { }%
%    \end{macrocode}
% \subsection{\csh{xintCHexToBin}}
%\begin{lverb}
% The 1.08 macro had same functionality as \xintHexToBin, and slightly
% different code, the 1.2m version has the same code as \xintHexToBin except
% that it does not remove leading zeros from output: if the input had N
% hexadecimal digits, the output will have exactly 4N binary digits.
%
% Rewritten again at 1.2n for \csname governed expansion.
%\end{lverb}
% \changed{1.4n}
% Kept in sync with new \csbxint{HexToBin}.
%    \begin{macrocode}
\def\xintCHexToBin {\romannumeral0\xintchextobin }%
\def\xintchextobin #1%
{%
    \expandafter\XINT_chtb_checkin\romannumeral`&&@#1.........\xint_bye
    \iffalse{\fi}%
}%
\def\XINT_chtb_checkin #1%
{%
    \xint_UDsignfork
       #1\XINT_chtb_N
        -{\XINT_chtb_main #1}%
     \krof
}%
\def\XINT_chtb_N {\expandafter-\romannumeral0\XINT_chtb_main }%
\def\XINT_chtb_main {\expanded{ \iffalse}\fi\XINT_htb_loop}%
%    \end{macrocode}
% \subsection{\csh{xintOctToHex}}
%
% \added{1.4n} This is done the lazy way, from octal to binary to hexadecimal.
%    \begin{macrocode}
\def\xintOctToHex {\romannumeral0\xintocttohex }%
\def\xintocttohex #1%
{%
    \expandafter\XINT_bth_checkin
    \romannumeral0\expandafter\XINT_otb_checkin\romannumeral`&&@#1.........\xint_bye
    \iffalse{\fi}%
    \xint:
}%
%    \end{macrocode}
% \subsection{\csh{xintBinToHex}}
% \changed{1.2m} Complete rewrite. Much more efficient but smaller maximals sizes.
% \changed{1.2n} 
% Again redone and now using \cs{csname} governed expansion: increased
% maximal size.
%
% Size of output is ceil(size(input)/4).  If the input has leading zeroes,
% they may exist in the output too.
% An input without leading zeroes gives an output without leading zeroes.
%
% \changed{1.4n}
% Expansion is governed by \cs{expanded}.  Tremendous increase of maximal
% size.  Note that for legacy reasons of the package history, the primary
% trigger is via |\romannumeral0|, we could use \cs{expanded} upfront,
% with some advantages.  But well.
%    \begin{macrocode}
\def\xintBinToHex {\romannumeral0\xintbintohex }%
\def\xintbintohex #1%
{%
    \expandafter\XINT_bth_checkin\romannumeral`&&@#1\xint:
}%
\def\XINT_bth_checkin #1%
{%
    \xint_UDsignfork
       #1\XINT_bth_N
        -{\XINT_bth_main #1}%
     \krof
}%
\def\XINT_bth_N {\expandafter-\romannumeral0\XINT_bth_main }%
\def\XINT_bth_main #1\xint:
{%
    \expanded{ \expandafter\XINT_bth_loop
    \romannumeral0\XINT_zeroes_foriv
       #1\R{0\R}{00\R}{000\R}\R{0\R}{00\R}{000\R}\R\W
    #1%
    nonenone\xint_bye}%
}%
\def\XINT_bth_loop #1#2#3#4#5#6#7#8%
{%
    \csname XINT_csbth_#1#2#3#4\endcsname
    \csname XINT_csbth_#5#6#7#8\endcsname
    \XINT_bth_loop
}%
\let\XINT_csbth_none\xint_bye
%    \end{macrocode}
% \subsection{\csh{xintOctToBin}}
% \added{1.4n}
%    \begin{macrocode}
\def\xintOctToBin {\romannumeral0\xintocttobin }%
\def\xintocttobin #1%
{%
    \expandafter\XINT_otb_checkin\romannumeral`&&@#1.........\xint_bye
    \iffalse{\fi}%
}%
\def\XINT_otb_checkin #1%
{%
    \xint_UDsignfork
       #1\XINT_otb_N
        -{\XINT_otb_main #1}%
     \krof
}%
\def\XINT_otb_N {\expandafter-\romannumeral0\XINT_otb_main }%
\def\XINT_otb_main
{%
    \expandafter\XINT_otb_cuz
    \expanded{\iffalse}\fi \XINT_otb_loop
}%
\def\XINT_otb_loop #1#2#3#4#5#6#7#8#9%
{%
     \csname XINT_csotb_#1\endcsname
     \csname XINT_csotb_#2\endcsname
     \csname XINT_csotb_#3\endcsname
     \csname XINT_csotb_#4\endcsname
     \csname XINT_csotb_#5\endcsname
     \csname XINT_csotb_#6\endcsname
     \csname XINT_csotb_#7\endcsname
     \csname XINT_csotb_#8\endcsname
     \csname XINT_csotb_#9\endcsname
     \XINT_otb_loop
}%
\expandafter\let\csname XINT_csotb_.\endcsname\xint_bye
\def\XINT_otb_cuz #1{%
\def\XINT_otb_cuz ##1##2##3%
   {\expandafter#1\the\numexpr##1##2##3\relax}%
}\XINT_otb_cuz { }%
%    \end{macrocode}
% \subsection{\csh{xintCOctToBin}}
% \added{1.4n}
%    \begin{macrocode}
\def\xintCOctToBin {\romannumeral0\xintcocttobin }%
\def\xintcocttobin #1%
{%
    \expandafter\XINT_cotb_checkin\romannumeral`&&@#1.........\xint_bye
    \iffalse{\fi}%
}%
\def\XINT_cotb_checkin #1%
{%
    \xint_UDsignfork
       #1\XINT_cotb_N
        -{\XINT_cotb_main #1}%
     \krof
}%
\def\XINT_cotb_N {\expandafter-\romannumeral0\XINT_cotb_main }%
\def\XINT_cotb_main {\expanded{ \iffalse}\fi\XINT_otb_loop}%
%    \end{macrocode}
% \subsection{\csh{xintBinToOct}}
% \added{1.4n}
%    \begin{macrocode}
\def\xintBinToOct {\romannumeral0\xintbintooct }%
\def\xintbintooct #1%
{%
    \expandafter\XINT_bto_checkin\romannumeral`&&@#1\xint:
}%
\def\XINT_bto_checkin #1%
{%
    \xint_UDsignfork
       #1\XINT_bto_N
        -{\XINT_bto_main #1}%
     \krof
}%
\def\XINT_bto_N {\expandafter-\romannumeral0\XINT_bto_main }%
\def\XINT_bto_main #1\xint:
{%
    \expanded{ \expandafter\XINT_bto_loop
    \romannumeral0\XINT_zeroes_foriii
       #1\R{0\R}{00\R}\R{0\R}{00\R}\R{0\R}{00\R}\R\W
    #1%
    endendend\xint_bye}%
}%
\def\XINT_bto_loop #1#2#3#4#5#6#7#8#9%
{%
    \csname XINT_csbto_#1#2#3\endcsname
    \csname XINT_csbto_#4#5#6\endcsname
    \csname XINT_csbto_#7#8#9\endcsname
    \XINT_bto_loop
}%
\let\XINT_csbto_end\xint_bye
%    \end{macrocode}
% \subsection{\csh{xintLowerHex}, \csh{xintUpperHex}}
% \added[2025/09/15]{1.4p}
%
% I really hesitate breaking with the |\romannumeral0| expansion trigger which
% is used throughout the codebase with very few exceptions.  This adds to
% documentation chores.  Also there is no absolute necessity to keep defining
% the lowercase |\xintlowerhex| but it can help when one needs to propagate
% expansion.
%
% This is modeled on a \ctanpackage{bnumexpr} |1.7| addition.
%
% There is a deliberate space after |#1| to accomodate for empty input.
%    \begin{macrocode}
\def\xintLowerHex{\expanded\xintlowerhex}%
\def\xintlowerhex#1{%
    {\expandafter\XINT_lowerhex\romannumeral`&&@#1 %
                 \xint_bye23456789\xint_bye\endcsname}%
}%
\def\XINT_lowerhex #1#2#3#4#5#6#7#8#9{%
    \csname XINT_lower #1\endcsname
    \csname XINT_lower #2\endcsname
    \csname XINT_lower #3\endcsname
    \csname XINT_lower #4\endcsname
    \csname XINT_lower #5\endcsname
    \csname XINT_lower #6\endcsname
    \csname XINT_lower #7\endcsname
    \csname XINT_lower #8\endcsname
    \csname XINT_lower #9\endcsname
    \XINT_lowerhex
}%
\expandafter\let\csname XINT_lower \endcsname\empty
\def\xintUpperHex{\expanded\xintupperhex}%
\def\xintupperhex#1{%
    {\expandafter\XINT_upperhex\romannumeral`&&@#1 %
                 \xint_bye23456789\xint_bye\endcsname}%
}%
\def\XINT_upperhex #1#2#3#4#5#6#7#8#9{%
    \csname XINT_upper #1\endcsname
    \csname XINT_upper #2\endcsname
    \csname XINT_upper #3\endcsname
    \csname XINT_upper #4\endcsname
    \csname XINT_upper #5\endcsname
    \csname XINT_upper #6\endcsname
    \csname XINT_upper #7\endcsname
    \csname XINT_upper #8\endcsname
    \csname XINT_upper #9\endcsname
    \XINT_upperhex
}%
\expandafter\let\csname XINT_upper \endcsname\empty
\XINTrestorecatcodesendinput%
%    \end{macrocode}
% \StoreCodelineNo {xintbinhex}
% \cleardoublepage\let\xintbinhexnameUp\undefined
%\gardesactifs
%\let</xintbinhex>\relax
%\let<*xintgcd>\gardesinactifs
%</xintbinhex>^^A-------------------------------------------------
%<*xintgcd>^^A----------------------------------------------------
%^^A -*- ycoding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname xintgcdnameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section{Package \xintgcdnameimp implementation}
% \RaisedLabel{sec:gcdimp}
%
% \localtableofcontents
%
% \subsection{Introduction}
%
% The commenting is currently (\xintbndldate) very sparse.
%
% Release |1.09h| has
% modified a bit the |\xintTypesetEuclideAlgorithm| and
% |\xintTypesetBezoutAlgorithm| layout with respect to line indentation in
% particular. And they use the \xinttoolsnameimp |\xintloop| rather than the
% Plain \TeX{} or \LaTeX{}'s |\loop|.
%
%
% Breaking change at |1.2p|: |\xintBezout{A}{B}| formerly had output
% |{A}{B}{U}{V}{D}| with |AU-BV=D|, now it is |{U}{V}{D}| with |AU+BV=D|.
%
% From |1.1| to |1.3f| the package loaded only \xintcorenameimp. At |1.4| it
% now automatically loads both of \xintnameimp and \xinttoolsnameimp (the
% latter being in fact a requirement of \csbxint{TypesetEuclideAlgorithm} and
% \csbxint{TypesetBezoutAlgorithm} since |1.09h|).
%
% \begin{framed}
% At |1.4| \csbxint{GCD}, \csbxint{LCM}, \csbxint{GCDof}, and \csbxint{LCMof}
% are \emph{removed} from the package:\IMPORTANTf they are provided only by
% \xintfracnameimp and they handle general fractions, not only integers.
%
% The original\CHANGEDf{1.4} integer-only macros have been renamed into respectively
% \csbxint{iiGCD}, \csbxint{iiLCM}, \csbxint{iiGCDof}, and \csbxint{iiLCMof}
% and got relocated into \xintnameimp package.
% \end{framed}
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
% The code for reload detection was initially copied from \textsc{Heiko
% Oberdiek}'s packages, then modified.
%
% The method for catcodes was also initially directly inspired by these
% packages.
%
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode64=11   % @
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \def\empty{}\def\space{ }\newlinechar10
  \def\z{\endgroup}%
  \expandafter\let\expandafter\x\csname ver@xintgcd.sty\endcsname
  \expandafter\let\expandafter\w\csname ver@xint.sty\endcsname
  \expandafter\let\expandafter\t\csname ver@xinttools.sty\endcsname
  \expandafter\ifx\csname numexpr\endcsname\relax
    \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax
      \immediate\write128{^^JPackage xintgcd Warning:^^J%
                          \space\space\space\space
                          \numexpr not available, aborting input.^^J}%
    \else
      \PackageWarningNoLine{xintgcd}{\numexpr not available, aborting input}%
    \fi
    \def\z{\endgroup\endinput}%
  \else
    \ifx\x\relax   % plain-TeX, first loading of xintgcd.sty
      \ifx\w\relax % but xint.sty not yet loaded.
         \expandafter\def\expandafter\z\expandafter{\z\input xint.sty\relax}%
      \fi
      \ifx\t\relax % but xinttools.sty not yet loaded.
         \expandafter\def\expandafter\z\expandafter{\z\input xinttools.sty\relax}%
      \fi
    \else
      \ifx\x\empty % LaTeX, first loading,
      % variable is initialized, but \ProvidesPackage not yet seen
          \ifx\w\relax % xint.sty not yet loaded.
            \expandafter\def\expandafter\z\expandafter{\z\RequirePackage{xint}}%
          \fi
          \ifx\t\relax % xinttools.sty not yet loaded.
            \expandafter\def\expandafter\z\expandafter{\z\RequirePackage{xinttools}}%
          \fi
      \else
        \def\z{\endgroup\endinput}% xintgcd already loaded.
      \fi
    \fi
  \fi
\z%
\XINTsetupcatcodes% defined in xintkernel.sty
%    \end{macrocode}
% \subsection{Package identification}
%    \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintgcd}%
  [2026/11/01 v2.0a1 Euclide algorithm with xint package (JFB)]%
%    \end{macrocode}
% \subsection{\csh{xintBezout}}
%\begin{lverb}
% \xintBezout{#1}{#2}
% produces {U}{V}{D} with UA+VB=D, D = PGCD(A,B) (non-positive),
% where #1 and #2 f-expand to big integers A and B.
%
% I had not checked this macro for about three years when I realized in
% January 2017 that \xintBezout{A}{B} was buggy for the cases A = 0 or B = 0.
% I fixed that blemish in 1.2l but overlooked the other blemish that
% \xintBezout{A}{B} with A multiple of B produced a coefficient U as -0 in
% place of 0.
%
% Hence I rewrote again for 1.2p. On this occasion I  modified the output
% of the macro to be {U}{V}{D} with AU+BV=D, formerly it was
% {A}{B}{U}{V}{D} with  AU - BV = D. This is quite breaking change!
%
% Note in particular change of sign of V.
%
% I don't know why I had designed this macro to contain {A}{B} in its output.
% Perhaps I initially intended to output {A//D}{B//D} (but forgot), as this is
% actually possible from outcome of the last iteration, with no need of
% actually dividing. Current code however arranges to skip this last update,
% as U and V are already furnished by the iteration prior to realizing that
% the last non-zero remainder was found.
%
% Also 1.2l raised InvalidOperation if both A and B vanished, but I removed
% this behaviour at 1.2p.
%\end{lverb}
%    \begin{macrocode}
\def\xintBezout {\romannumeral0\xintbezout }%
\def\xintbezout #1%
{%
    \expandafter\XINT_bezout\expandafter {\romannumeral0\xintnum{#1}}%
}%
\def\XINT_bezout #1#2%
{%
    \expandafter\XINT_bezout_fork \romannumeral0\xintnum{#2}\Z #1\Z
}%
%    \end{macrocode}
%\begin{lverb}
% #3#4 = A, #1#2=B. Micro improvement for 1.2l.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezout_fork #1#2\Z #3#4\Z
{%
    \xint_UDzerosfork
     #1#3\XINT_bezout_botharezero
      #10\XINT_bezout_secondiszero
      #30\XINT_bezout_firstiszero
       00\xint_UDsignsfork
    \krof
          #1#3\XINT_bezout_minusminus % A < 0, B < 0
           #1-\XINT_bezout_minusplus  % A > 0, B < 0
           #3-\XINT_bezout_plusminus  % A < 0, B > 0
            --\XINT_bezout_plusplus   % A > 0, B > 0
    \krof
    {#2}{#4}#1#3% #1#2=B, #3#4=A
}%
\def\XINT_bezout_botharezero #1\krof#2#300{{0}{0}{0}}%
\def\XINT_bezout_firstiszero #1\krof#2#3#4#5%
{%
    \xint_UDsignfork
      #4{{0}{-1}{#2}}%
       -{{0}{1}{#4#2}}%
    \krof
}%
\def\XINT_bezout_secondiszero #1\krof#2#3#4#5%
{%
    \xint_UDsignfork
       #5{{-1}{0}{#3}}%
        -{{1}{0}{#5#3}}%
    \krof
}%
%    \end{macrocode}
%\begin{lverb}
% #4#2= A < 0, #3#1 = B < 0
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezout_minusminus #1#2#3#4%
{%
    \expandafter\XINT_bezout_mm_post
    \romannumeral0\expandafter\XINT_bezout_preloop_a
    \romannumeral0\XINT_ndivrawpair {#1}{#2}{#1}%
}%
\def\XINT_bezout_mm_post #1#2%
{%
    \expandafter\XINT_bezout_mm_postb\expandafter
    {\romannumeral0\xintiiopp{#2}}{\romannumeral0\xintiiopp{#1}}%
}%
\def\XINT_bezout_mm_postb #1#2{\expandafter{#2}{#1}}%
%    \end{macrocode}
%\begin{lverb}
% minusplus  #4#2= A > 0, B < 0
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezout_minusplus #1#2#3#4%
{%
    \expandafter\XINT_bezout_mp_post
    \romannumeral0\expandafter\XINT_bezout_preloop_a
    \romannumeral0\XINT_ndivrawpair {#1}{#4#2}{#1}%
}%
\def\XINT_bezout_mp_post #1#2%
{%
    \expandafter\xint_exchangetwo_keepbraces\expandafter
    {\romannumeral0\xintiiopp {#2}}{#1}%
}%
%    \end{macrocode}
%\begin{lverb}
% plusminus  A < 0, B > 0
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezout_plusminus #1#2#3#4%
{%
    \expandafter\XINT_bezout_pm_post
    \romannumeral0\expandafter\XINT_bezout_preloop_a
    \romannumeral0\XINT_ndivrawpair {#3#1}{#2}{#3#1}%
}%
\def\XINT_bezout_pm_post #1{\expandafter{\romannumeral0\xintiiopp{#1}}}%
%    \end{macrocode}
%\begin{lverb}
% plusplus, B = #3#1 > 0, A = #4#2 > 0
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezout_plusplus #1#2#3#4%
{%
    \expandafter\XINT_bezout_preloop_a
    \romannumeral0\XINT_ndivrawpair {#3#1}{#4#2}{#3#1}%
}%
%    \end{macrocode}
%\begin{lverb}
%( n = 0: BA1001 (B, A, e=1, vv, uu, v, u)
%: r(1)=B, r(0)=A, après n étapes {r(n+1)}{r(n)}{vv}{uu}{v}{u}
%: q(n) quotient de r(n-1) par r(n)
%: si reste nul, exit et renvoie U = -e*uu, V = e*vv, A*U+B*V=D
%: sinon mise à jour
%:   vv, v = q * vv + v, vv
%:   uu, u = q * uu + u, uu
%:   e = -e
%: puis calcul quotient reste et itération
%)
%
% We arrange for \xintiiMul sub-routine to be called only with positive
% arguments, thus skipping some un-needed sign parsing there. For that though
% we have to screen out the special cases A divides B, or B divides A. And we
% first want to exchange A and B if A < B. These special cases are the only
% one possibly leading to U or V zero (for A and B positive which is the case
% here.) Thus the general case always leads to non-zero U and V's and assigning
% a final sign is done simply adding a - to one of them, with no fear of
% producing -0. 
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezout_preloop_a #1#2#3%
{%
    \if0#1\xint_dothis\XINT_bezout_preloop_exchange\fi
    \if0#2\xint_dothis\XINT_bezout_preloop_exit\fi
    \xint_orthat{\expandafter\XINT_bezout_loop_B}%
    \romannumeral0\XINT_ndivrawpair {#2}{#3}{#2}{#1}110%
}%
\def\XINT_bezout_preloop_exit
    \romannumeral0\XINT_ndivrawpair #1#2#3#4#5#6#7%
{%
    {0}{1}{#2}%
}%
\def\XINT_bezout_preloop_exchange
{%
    \expandafter\xint_exchangetwo_keepbraces
    \romannumeral0\expandafter\XINT_bezout_preloop_A
}%
\def\XINT_bezout_preloop_A #1#2#3#4%
{%
    \if0#2\xint_dothis\XINT_bezout_preloop_exit\fi
    \xint_orthat{\expandafter\XINT_bezout_loop_B}%
    \romannumeral0\XINT_ndivrawpair {#2}{#3}{#2}{#1}%
}%
\def\XINT_bezout_loop_B #1#2%
{%  
    \if0#2\expandafter\XINT_bezout_exitA
     \else\expandafter\XINT_bezout_loop_C
    \fi {#1}{#2}%
}%
%    \end{macrocode}
%\begin{lverb}
% We use the fact that the \romannumeral-`0 (or equivalent) done by \xintiiadd
% will absorb the initial space token left by \XINT_mul_plusplus in its
% output.
%
% We arranged for operands here to be always positive which is needed for
% \XINT_mul_plusplus entry point (last time I checked...). Admittedly this
% kind of optimization is not good for maintenance of code, but I can't resist
% temptation of limiting the shuffling around of tokens...
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezout_loop_C #1#2#3#4#5#6#7%
{%
    \expandafter\XINT_bezout_loop_D\expandafter
        {\romannumeral0\xintiiadd{\xintiimul{#1}{#4}}{#6}}%
        {\romannumeral0\xintiiadd{\xintiimul{#1}{#5}}{#7}}%
    {#2}{#3}{#4}{#5}%
}%
\def\XINT_bezout_loop_D #1#2%
{%
    \expandafter\XINT_bezout_loop_E\expandafter{#2}{#1}%
}%
\def\XINT_bezout_loop_E #1#2#3#4%
{%
    \expandafter\XINT_bezout_loop_b
    \romannumeral0\XINT_ndivrawpair {#3}{#4}{#3}{#2}{#1}%
}%
\def\XINT_bezout_loop_b #1#2%
{%  
    \if0#2\expandafter\XINT_bezout_exita
     \else\expandafter\XINT_bezout_loop_c
    \fi {#1}{#2}%
}%
\def\XINT_bezout_loop_c #1#2#3#4#5#6#7%
{%
    \expandafter\XINT_bezout_loop_d\expandafter
        {\romannumeral0\xintiiadd{\xintiimul{#1}{#4}}{#6}}%
        {\romannumeral0\xintiiadd{\xintiimul{#1}{#5}}{#7}}%
    {#2}{#3}{#4}{#5}%
}%
\def\XINT_bezout_loop_d #1#2%
{%
    \expandafter\XINT_bezout_loop_e\expandafter{#2}{#1}%
}%
\def\XINT_bezout_loop_e #1#2#3#4%
{%
    \expandafter\XINT_bezout_loop_B
    \romannumeral0\XINT_ndivrawpair {#3}{#4}{#3}{#2}{#1}%
}%
%    \end{macrocode}
%\begin{lverb}
% sortir U, V, D mais on a travaillé avec vv, uu, v, u dans cet ordre.$\
% The code is structured so that #4 and #5 are guaranteed non-zero
% if we exit here, hence we can not create a -0 in output.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezout_exita #1#2#3#4#5#6#7{{-#5}{#4}{#3}}%
\def\XINT_bezout_exitA #1#2#3#4#5#6#7{{#5}{-#4}{#3}}%
%    \end{macrocode}
% \subsection{\csh{xintEuclideAlgorithm}}
%\begin{lverb}
% Pour Euclide:
% {N}{A}{D=r(n)}{B}{q1}{r1}{q2}{r2}{q3}{r3}....{qN}{rN=0}$\
% u<2n> = u<2n+3>u<2n+2> + u<2n+4> à la n ième étape.
%
% Formerly, used \xintiabs, but got deprecated at 1.2o.
%\end{lverb}
%    \begin{macrocode}
\def\xintEuclideAlgorithm {\romannumeral0\xinteuclidealgorithm }%
\def\xinteuclidealgorithm #1%
{%
    \expandafter\XINT_euc\expandafter{\romannumeral0\xintiiabs{\xintNum{#1}}}%
}%
\def\XINT_euc #1#2%
{%
    \expandafter\XINT_euc_fork\romannumeral0\xintiiabs{\xintNum{#2}}\Z #1\Z
}%
%    \end{macrocode}
%\begin{lverb}
% Ici #3#4=A, #1#2=B
%\end{lverb}
%    \begin{macrocode}
\def\XINT_euc_fork #1#2\Z #3#4\Z
{%
    \xint_UDzerofork
      #1\XINT_euc_BisZero
      #3\XINT_euc_AisZero
       0\XINT_euc_a
    \krof
    {0}{#1#2}{#3#4}{{#3#4}{#1#2}}{}\Z
}%
%    \end{macrocode}
%\begin{lverb}
% Le {} pour protéger {{A}{B}} si on s'arrête après une étape (B divise
% A).
% On va renvoyer:$\
% {N}{A}{D=r(n)}{B}{q1}{r1}{q2}{r2}{q3}{r3}....{qN}{rN=0}
%\end{lverb}
%    \begin{macrocode}
\def\XINT_euc_AisZero #1#2#3#4#5#6{{1}{0}{#2}{#2}{0}{0}}%
\def\XINT_euc_BisZero #1#2#3#4#5#6{{1}{0}{#3}{#3}{0}{0}}%
%    \end{macrocode}
%\begin{lverb}
% {n}{rn}{an}{{qn}{rn}}...{{A}{B}}{}\Z$\
%  a(n) = r(n-1). Pour n=0 on a juste {0}{B}{A}{{A}{B}}{}\Z$\
% \XINT_ndivrawpair {u}{v} divise v par u
%\end{lverb}
%    \begin{macrocode}
\def\XINT_euc_a #1#2#3%
{%
    \expandafter\XINT_euc_b\the\numexpr #1+\xint_c_i\expandafter.%
    \romannumeral0\XINT_ndivrawpair {#2}{#3}{#2}%
}%
%    \end{macrocode}
%\begin{lverb}
% {n+1}{q(n+1)}{r(n+1)}{rn}{{qn}{rn}}...
%\end{lverb}
%    \begin{macrocode}
\def\XINT_euc_b #1.#2#3#4%
{%
    \XINT_euc_c #3\Z {#1}{#3}{#4}{{#2}{#3}}%
}%
%    \end{macrocode}
%\begin{lverb}
% r(n+1)\Z {n+1}{r(n+1)}{r(n)}{{q(n+1)}{r(n+1)}}{{qn}{rn}}...$\
% Test si r(n+1) est nul.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_euc_c #1#2\Z
{%
    \xint_gob_til_zero #1\XINT_euc_end0\XINT_euc_a
}%
%    \end{macrocode}
%\begin{lverb}
% {n+1}{r(n+1)}{r(n)}{{q(n+1)}{r(n+1)}}...{}\Z
% Ici r(n+1) = 0. On arrête on se prépare à inverser
% {n+1}{0}{r(n)}{{q(n+1)}{r(n+1)}}.....{{q1}{r1}}{{A}{B}}{}\Z$\
% On veut renvoyer: {N=n+1}{A}{D=r(n)}{B}{q1}{r1}{q2}{r2}{q3}{r3}....{qN}{rN=0}
%\end{lverb}
%    \begin{macrocode}
\def\XINT_euc_end0\XINT_euc_a #1#2#3#4\Z%
{%
    \expandafter\XINT_euc_end_a
    \romannumeral0%
    \XINT_rord_main {}#4{{#1}{#3}}%
    \xint:
      \xint_bye\xint_bye\xint_bye\xint_bye
      \xint_bye\xint_bye\xint_bye\xint_bye
    \xint:
}%
\def\XINT_euc_end_a #1#2#3{{#1}{#3}{#2}}%
%    \end{macrocode}
% \subsection{\csh{xintBezoutAlgorithm}}
%\begin{lverb}
% Pour Bezout: objectif, renvoyer$\
% {N}{A}{0}{1}{D=r(n)}{B}{1}{0}{q1}{r1}{alpha1=q1}{beta1=1}$\
%       {q2}{r2}{alpha2}{beta2}....{qN}{rN=0}{alphaN=A/D}{betaN=B/D}$\
% alpha0=1, beta0=0, alpha(-1)=0, beta(-1)=1
%\end{lverb}
%    \begin{macrocode}
\def\xintBezoutAlgorithm {\romannumeral0\xintbezoutalgorithm }%
\def\xintbezoutalgorithm #1%
{%
    \expandafter \XINT_bezalg
    \expandafter{\romannumeral0\xintiiabs{\xintNum{#1}}}%
}%
\def\XINT_bezalg #1#2%
{%
    \expandafter\XINT_bezalg_fork\romannumeral0\xintiiabs{\xintNum{#2}}\Z #1\Z
}%
%    \end{macrocode}
%\begin{lverb}
% Ici #3#4=A, #1#2=B
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezalg_fork #1#2\Z #3#4\Z
{%
    \xint_UDzerofork
      #1\XINT_bezalg_BisZero
      #3\XINT_bezalg_AisZero
       0\XINT_bezalg_a
    \krof
    0{#1#2}{#3#4}1001{{#3#4}{#1#2}}{}\Z
}%
\def\XINT_bezalg_AisZero #1#2#3\Z{{1}{0}{0}{1}{#2}{#2}{1}{0}{0}{0}{0}{1}}%
\def\XINT_bezalg_BisZero #1#2#3#4\Z{{1}{0}{0}{1}{#3}{#3}{1}{0}{0}{0}{0}{1}}%
%    \end{macrocode}
%\begin{lverb}
% pour préparer l'étape n+1 il faut
% {n}{r(n)}{r(n-1)}{alpha(n)}{beta(n)}{alpha(n-1)}{beta(n-1)}&
%                    {{q(n)}{r(n)}{alpha(n)}{beta(n)}}...
% division de #3 par #2
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezalg_a #1#2#3%
{%
    \expandafter\XINT_bezalg_b\the\numexpr #1+\xint_c_i\expandafter.%
    \romannumeral0\XINT_ndivrawpair {#2}{#3}{#2}%
}%
%    \end{macrocode}
%\begin{lverb}
% {n+1}{q(n+1)}{r(n+1)}{r(n)}{alpha(n)}{beta(n)}{alpha(n-1)}{beta(n-1)}...
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezalg_b #1.#2#3#4#5#6#7#8%
{%
    \expandafter\XINT_bezalg_c\expandafter
     {\romannumeral0\xintiiadd {\xintiiMul {#6}{#2}}{#8}}%
     {\romannumeral0\xintiiadd {\xintiiMul {#5}{#2}}{#7}}%
     {#1}{#2}{#3}{#4}{#5}{#6}%
}%
%    \end{macrocode}
%\begin{lverb}
% {beta(n+1)}{alpha(n+1)}{n+1}{q(n+1)}{r(n+1)}{r(n)}{alpha(n)}{beta(n}}
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezalg_c #1#2#3#4#5#6%
{%
    \expandafter\XINT_bezalg_d\expandafter {#2}{#3}{#4}{#5}{#6}{#1}%
}%
%    \end{macrocode}
%\begin{lverb}
% {alpha(n+1)}{n+1}{q(n+1)}{r(n+1)}{r(n)}{beta(n+1)}
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezalg_d #1#2#3#4#5#6#7#8%
{%
    \XINT_bezalg_e #4\Z {#2}{#4}{#5}{#1}{#6}{#7}{#8}{{#3}{#4}{#1}{#6}}%
}%
%    \end{macrocode}
%\begin{lverb}
% r(n+1)\Z {n+1}{r(n+1)}{r(n)}{alpha(n+1)}{beta(n+1)}$\
%                              {alpha(n)}{beta(n)}{q,r,alpha,beta(n+1)}$\
% Test si r(n+1) est nul.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezalg_e #1#2\Z
{%
    \xint_gob_til_zero #1\XINT_bezalg_end0\XINT_bezalg_a
}%
%    \end{macrocode}
%\begin{lverb}
% Ici r(n+1) = 0. On arrête on se prépare à inverser.$\
% {n+1}{r(n+1)}{r(n)}{alpha(n+1)}{beta(n+1)}{alpha(n)}{beta(n)}$\
%                     {q,r,alpha,beta(n+1)}...{{A}{B}}{}\Z$\
% On veut renvoyer$\
% {N}{A}{0}{1}{D=r(n)}{B}{1}{0}{q1}{r1}{alpha1=q1}{beta1=1}$\
%       {q2}{r2}{alpha2}{beta2}....{qN}{rN=0}{alphaN=A/D}{betaN=B/D}
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezalg_end0\XINT_bezalg_a #1#2#3#4#5#6#7#8\Z
{%
    \expandafter\XINT_bezalg_end_a
    \romannumeral0%
    \XINT_rord_main {}#8{{#1}{#3}}%
    \xint:
      \xint_bye\xint_bye\xint_bye\xint_bye
      \xint_bye\xint_bye\xint_bye\xint_bye
    \xint:
}%
%    \end{macrocode}
%\begin{lverb}
% {N}{D}{A}{B}{q1}{r1}{alpha1=q1}{beta1=1}{q2}{r2}{alpha2}{beta2}$\
%      ....{qN}{rN=0}{alphaN=A/D}{betaN=B/D}$\
% On veut renvoyer$\
% {N}{A}{0}{1}{D=r(n)}{B}{1}{0}{q1}{r1}{alpha1=q1}{beta1=1}$\
%        {q2}{r2}{alpha2}{beta2}....{qN}{rN=0}{alphaN=A/D}{betaN=B/D}
%\end{lverb}
%    \begin{macrocode}
\def\XINT_bezalg_end_a #1#2#3#4{{#1}{#3}{0}{1}{#2}{#4}{1}{0}}%
%    \end{macrocode}
% \subsection{\csh{xintTypesetEuclideAlgorithm}}
%\begin{lverb}
% TYPESETTING
%
% Organisation:
%
% {N}{A}{D}{B}{q1}{r1}{q2}{r2}{q3}{r3}....{qN}{rN=0}$\
% \U1 = N = nombre d'étapes, \U3 = PGCD, \U2 = A, \U4=B
% q1 = \U5, q2 = \U7 --> qn = \U<2n+3>, rn = \U<2n+4>
% bn = rn. B = r0. A=r(-1)
%
% r(n-2) = q(n)r(n-1)+r(n) (n e étape)
%
% \U{2n} = \U{2n+3} \times \U{2n+2} + \U{2n+4}, n e étape.
% (avec n entre 1 et N)
%
% 1.09h uses \xintloop, and \par rather than \endgraf; and \par rather than
% \hfill\break
%\end{lverb}
%    \begin{macrocode}
\def\xintTypesetEuclideAlgorithm {%
    \unless\ifdefined\xintAssignArray
       \errmessage
        {xintgcd: package xinttools is required for \string\xintTypesetEuclideAlgorithm}%
       \expandafter\xint_gobble_iii
    \fi
    \XINT_TypesetEuclideAlgorithm
}%
\def\XINT_TypesetEuclideAlgorithm #1#2%
{% l'algo remplace #1 et #2 par |#1| et |#2|
  \par
  \begingroup
    \xintAssignArray\xintEuclideAlgorithm {#1}{#2}\to\U
    \edef\A{\U2}\edef\B{\U4}\edef\N{\U1}%
    \setbox 0 \vbox{\halign {$##$\cr \A\cr \B \cr}}%
    \count 255 1
    \xintloop
      \indent\hbox to \wd 0 {\hfil$\U{\numexpr 2*\count255\relax}$}%
      ${} =  \U{\numexpr 2*\count255 + 3\relax}
      \times \U{\numexpr 2*\count255 + 2\relax}
          +  \U{\numexpr 2*\count255 + 4\relax}$%
    \ifnum \count255 < \N
      \par
      \advance \count255 1
    \repeat
  \endgroup
}%
%    \end{macrocode}
% \subsection{\csh{xintTypesetBezoutAlgorithm}}
%\begin{lverb}
% Pour Bezout on a:
% {N}{A}{0}{1}{D=r(n)}{B}{1}{0}{q1}{r1}{alpha1=q1}{beta1=1}$\
%             {q2}{r2}{alpha2}{beta2}....{qN}{rN=0}{alphaN=A/D}{betaN=B/D}%
% Donc 4N+8 termes:
% U1 = N, U2= A, U5=D, U6=B, q1 = U9, qn = U{4n+5}, n au moins 1$\
% rn = U{4n+6}, n au moins -1$\
% alpha(n) = U{4n+7}, n au moins -1$\
% beta(n)  = U{4n+8}, n au moins -1
%
% 1.09h uses \xintloop, and \par rather than \endgraf; and no more \parindent0pt
%\end{lverb}
%    \begin{macrocode}
\def\xintTypesetBezoutAlgorithm {%
    \unless\ifdefined\xintAssignArray
       \errmessage
        {xintgcd: package xinttools is required for \string\xintTypesetBezoutAlgorithm}%
       \expandafter\xint_gobble_iii
    \fi
    \XINT_TypesetBezoutAlgorithm
}%
\def\XINT_TypesetBezoutAlgorithm #1#2%
{%
  \par
  \begingroup
    \xintAssignArray\xintBezoutAlgorithm {#1}{#2}\to\BEZ
    \edef\A{\BEZ2}\edef\B{\BEZ6}\edef\N{\BEZ1}% A = |#1|, B = |#2|
    \setbox 0 \vbox{\halign {$##$\cr \A\cr \B \cr}}%
    \count255 1
    \xintloop
      \indent\hbox to \wd 0 {\hfil$\BEZ{4*\count255 - 2}$}%
      ${} =  \BEZ{4*\count255 + 5}
      \times \BEZ{4*\count255 + 2}
          +  \BEZ{4*\count255 + 6}$\hfill\break
      \hbox to \wd 0 {\hfil$\BEZ{4*\count255 +7}$}%
      ${} = \BEZ{4*\count255 + 5}
      \times \BEZ{4*\count255 + 3}
          +  \BEZ{4*\count255 - 1}$\hfill\break
      \hbox to \wd 0 {\hfil$\BEZ{4*\count255 +8}$}%
      ${} =  \BEZ{4*\count255 + 5}
      \times \BEZ{4*\count255 + 4}
          +  \BEZ{4*\count255 }$
      \par
    \ifnum \count255 < \N
    \advance \count255 1
  \repeat
    \edef\U{\BEZ{4*\N + 4}}%
    \edef\V{\BEZ{4*\N + 3}}%
    \edef\D{\BEZ5}%
    \ifodd\N
       $\U\times\A  - \V\times \B = -\D$%
    \else
       $\U\times\A - \V\times\B = \D$%
    \fi
    \par
  \endgroup
}%
\XINTrestorecatcodesendinput%
%    \end{macrocode}
% \StoreCodelineNo {xintgcd}
% \cleardoublepage\let\xintgcdnameUp\undefined
%\gardesactifs
%\let</xintgcd>\relax
%\let<*xintfrac>\gardesinactifs
%</xintgcd>^^A----------------------------------------------------
%<*xintfrac>^^A---------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 72; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname xintfracnameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section{Package \xintfracnameimp implementation}
% \RaisedLabel{sec:fracimp}
%
% \localtableofcontents
%
% \subsection{Introduction}
%
% The commenting is currently (\xintbndldate) very sparse.
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
% The code for reload detection was initially copied from \textsc{Heiko
% Oberdiek}'s packages, then modified.
%
% The method for catcodes was also initially directly inspired by these
% packages.
%
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode64=11   % @
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \catcode35=6    % #
  \def\odef#1{\expandafter\def\expandafter#1\expandafter}%
  \def\empty{}\def\space{ }\newlinechar10
  \def\z{\endgroup}%
  \def\odef#1{\expandafter\def\expandafter#1\expandafter}%
  \expandafter\let\expandafter\x\csname ver@xintfrac.sty\endcsname
  \expandafter\let\expandafter\c\csname ver@calxfp.sty\endcsname
  \expandafter\let\expandafter\w\csname ver@xint.sty\endcsname
  \expandafter\ifx\csname numexpr\endcsname\relax
    \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax
      \immediate\write128{^^JPackage xint Warning:^^J%
                          \space\space\space\space
                          \numexpr not available, aborting input.^^J}%
    \else
      \PackageWarningNoLine{xint}{\numexpr not available, aborting input}%
    \fi
    \def\z{\endgroup\endinput}%
  \else
    \ifx\x\relax   % plain-TeX, first loading of xintfrac.sty
      \ifx\w\relax % but xint.sty not yet loaded.
         \odef\z{\z\input xint.sty\relax}%
      \fi
      \ifx\c\relax % but calxfp.sty not yet loaded.
         \odef\z{\z\input calxfp.sty\relax}%
      \fi
    \else
      \ifx\x\empty % LaTeX, first loading,
      % variable is initialized, but \ProvidesPackage not yet seen
          \ifx\w\relax % xint.sty not yet loaded.
            \odef\z{\z\RequirePackage{xint}}%
          \fi
          \ifx\c\relax % calxfp.sty not yet loaded.
            \odef\z{\z\RequirePackage{calxfp}}%
          \fi
      \else
        \def\z{\endgroup\endinput}% xintfrac already loaded.
      \fi
    \fi
  \fi
\z%
\XINTsetupcatcodes% defined in xintkernel.sty
%    \end{macrocode}
% \subsection{Package identification}
%    \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintfrac}%
  [2026/11/01 v2.0a1 Expandable operations on fractions (JFB)]%
%    \end{macrocode}
% \subsection{\csh{XINT_cntSgnFork}}
%\begin{lverb}
% 1.09i. Used internally, #1 must expand to \m@ne, \z@, or \@ne or
% equivalent. \XINT_cntSgnFork does not insert a romannumeral stopper.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_cntSgnFork #1%
{%
    \ifcase #1\expandafter\xint_secondofthree
            \or\expandafter\xint_thirdofthree
          \else\expandafter\xint_firstofthree
    \fi
}%
%    \end{macrocode}
% \subsection{\cshnolabel{xintLen}}
%\begin{lverb}
% The used formula is disputable, the idea is that A/1 and A should have
% same length. Venerable code rewritten for 1.2i, following updates to
% \xintLength in xintkernel.sty. And sadly, I forgot on this
% occasion that this macro is not supposed to count the sign... Fixed in 1.2k.
%\end{lverb}
%    \begin{macrocode}
\def\xintLen {\romannumeral0\xintlen }%
\def\xintlen #1%
{%
    \expandafter\XINT_flen\romannumeral0\XINT_infrac {#1}%
}%
\def\XINT_flen#1{\def\XINT_flen ##1##2##3%
{%
    \expandafter#1%
    \the\numexpr \XINT_abs##1+%
    \XINT_len_fork ##2##3\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
      \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v
      \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye-\xint_c_i
    \relax
}}\XINT_flen{ }%
%    \end{macrocode}
% \subsection{\csh{XINT_outfrac}}
% \changed{1.06b}
%\begin{lverb}
% 1.06b version now outputs 0/1[0] and not 0[0] in case of zero. More generally
% all macros have been checked in xintfrac, xintseries, xintcfrac, to make sure
% the output format for fractions was always A/B[n]. (except \xintIrr,
% \xintJrr, \xintRawWithZeros).
%
% Months later (2014/10/22): perhaps I should document what this macro does
% before I forget?  from {e}{N}{D} it outputs N/D[e], checking in passing if
% D=0 or if N=0. It also makes sure D is not < 0. I am not sure but I don't
% think there is any place in the code which could call \XINT_outfrac with a D
% < 0, but I should check.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_outfrac #1#2#3%
{%
    \ifcase\XINT_cntSgn #3\xint:
        \expandafter \XINT_outfrac_divisionbyzero
    \or
        \expandafter \XINT_outfrac_P
    \else
        \expandafter \XINT_outfrac_N
    \fi
    {#2}{#3}[#1]%
}%
\def\XINT_outfrac_divisionbyzero #1#2[#3]%
{%
    \XINT_legacysignalcondition{DivisionByZero}{Division by zero: #1/#2.}{}{ 0/1[0]}%
}%
\def\XINT_outfrac_P#1{%
\def\XINT_outfrac_P ##1##2%
   {\if0\XINT_Sgn ##1\xint:\expandafter\XINT_outfrac_Zero\fi#1##1/##2}%
}\XINT_outfrac_P{ }%
\def\XINT_outfrac_Zero #1[#2]{ 0/1[0]}%
\def\XINT_outfrac_N #1#2%
{%
    \expandafter\XINT_outfrac_N_a\expandafter
    {\romannumeral0\XINT_opp #2}{\romannumeral0\XINT_opp #1}%
}%
\def\XINT_outfrac_N_a #1#2%
{%
    \expandafter\XINT_outfrac_P\expandafter {#2}{#1}%
}%
%    \end{macrocode}
% \subsection{\csh{XINT_infrac}}
% \added{1.03}
%\begin{lverb}
% Parses fraction, scientific notation, etc... and produces {n}{A}{B}
% corresponding to A/B times 10^n. No reduction to smallest terms.
%\end{lverb}
% \changed{1.07}
%\begin{lverb}
% Extended in 1.07 to accept scientific notation on input. With lowercase
% e only. The \xintexpr parser does accept uppercase E also. Ah, by the way,
% perhaps I should at least say what this macro does? (belated addition
% 2014/10/22...), before I forget! It prepares the fraction in the internal
% format {exponent}{Numerator}{Denominator} where Denominator is at least 1.
%\end{lverb}
% \changed[2015/10/09]{1.2}
%\begin{lverb}
% This venerable macro from the very early days
% has gotten a lifting for release 1.2. There were two kinds of issues:
%
% 1) use of \W, \Z, \T delimiters was very poor choice as this could clash with
% user input,
%
% 2) the new \XINT_frac_gen handles macros (possibly empty) in the input as
% general as \A.\Be\C/\D.\Ee\F. The earlier version would not have expanded
% the \B or \E$empty: digits after decimal mark were constrained to arise from
% expansion of the first token. Thus the 1.03 original code would have
% expanded only \A, \D, \C, and \F for this input.
%
% This reminded me think I should revisit the remaining earlier
% portions of code, as I was still learning TeX coding when I wrote them.
%
% Also I thought about parsing even faster the A/B[N] input, not expanding B,
% but this turned out to clash with some established uses in the documentation
% such as 1/\xintiiSqr{...}[0]. For the implementation, careful here about
% potential brace removals with parameter patterns such as like #1/#2#3[#4]for
% example.
%
% While I was at it 1.2 added \numexpr parsing of the N, which earlier was
% restricted to be only explicit digits. I allowed [] with empty N, but the
% way I did it in 1.2 with \the\numexpr 0#1 was buggy, as it did not allow #1
% to be a \count for example or itself a \numexpr (although such inputs were
% not previously allowed, I later turned out to use them in the code itself,
% e.g. the float factorial of version 1.2f). The better way would be
% \the\numexpr#1+\xint_c_ but 1.2f finally does only \the\numexpr #1 and #1 is
% not allowed to be empty.
%
% The 1.2 \XINT_frac_gen had two locations with such a problematic \numexpr
% 0#1 which I replaced for 1.2f with \numexpr#1+\xint_c_.
%
% Regarding calling the macro with an argument A[<expression>], a / inthe
% expression must be suitably hidden for example in \firstofone type
% constructs.
%
% Note: when the numerator is found to be zero \XINT_infrac *always* returns
% {0}{0}{1}. This behaviour must not change because 1.2g \xintFloat and
% XINTinFloat (for example) rely upon it: if the denominator on output is not
% 1, then \xintFloat assumes that the numerator is not zero.
%
% As described in the manual, if the input contains a (final) [N] part, it is
% assumed that it is in the shape A[N] or A/B[N] with A (and B) not containing
% neither decimal mark nor scientific part, moreover B must be positive and A
% have at most one minus sign (and no plus sign). Else there will be errors,
% for example -0/2[0] would not be recognized as being zero at this stage and
% this could cause issues afterwards. When there is no ending [N] part, both
% numerator and denominator will be parsed for the more general format
% allowing decimal digits and scientific part and possibly multiple leading
% signs.
%\end{lverb}
% \changed{1.2l}
%\begin{lverb}
% 1.2l fixes frailty of \XINT_infrac (hence basically of all xintfrac macros)
% respective to non terminated \numexpr input: \xintRaw{\the\numexpr1} for
% example. The issue was that \numexpr sees the / and expands what's next.
% But even \numexpr 1// for example creates an error, and to my mind this is
% a defect of \numexpr. It should be able to trace back and see that / was
% used as delimiter not as operator. Anyway, I thus fixed this problem
% belatedly here regarding \XINT_infrac.
%\end{lverb}
% \changed{1.4l}
%\begin{lverb}
% Deprecate venerable \XINT_inFrac, whose new name is \xintRawBraced.
% Should have been removed then.
%\end{lverb}
% \changed[2025/07/25]{1.4n}
%\begin{lverb}
% Remove \XINT_inFrac.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infrac #1% the core xintfrac in-parser; triggered by \romannumeral0
{%
    \expandafter\XINT_infrac_fork\romannumeral`&&@#1\xint:/\XINT_W[\XINT_W\XINT_T
}%
\def\XINT_infrac_fork #1[#2%
{%
    \xint_UDXINTWfork
      #2\XINT_frac_gen          % input has no brackets [N]
      \XINT_W\XINT_infrac_res_a % there is some [N], must be strict A[N] or A/B[N] input
    \krof
    #1[#2%
}%
\def\XINT_infrac_res_a #1%
{%
    \xint_gob_til_zero #1\XINT_infrac_res_zero 0\XINT_infrac_res_b #1%
}%
%    \end{macrocode}
%\begin{lverb}
% Note that input exponent is here ignored and forced to be zero.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infrac_res_zero 0\XINT_infrac_res_b #1\XINT_T {{0}{0}{1}}%
\def\XINT_infrac_res_b #1/#2%
{%
    \xint_UDXINTWfork
     #2\XINT_infrac_res_ca      % it was A[N] input
     \XINT_W\XINT_infrac_res_cb % it was A/B[N] input
    \krof
    #1/#2%
}%
%    \end{macrocode}
%\begin{lverb}
% An empty [] is not allowed. (this was authorized in 1.2, removed in
% 1.2f).
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infrac_res_ca #1[#2]\xint:/\XINT_W[\XINT_W\XINT_T
   {\expandafter{\the\numexpr #2}{#1}{1}}%
\def\XINT_infrac_res_cb #1/#2[%
   {\expandafter\XINT_infrac_res_cc\romannumeral`&&@#2~#1[}%
\def\XINT_infrac_res_cc #1~#2[#3]\xint:/\XINT_W[\XINT_W\XINT_T
   {\expandafter{\the\numexpr #3}{#2}{#1}}%
%    \end{macrocode}
% \subsection{\csh{XINT_frac_gen}}
% \changed{1.07}
%\begin{lverb}
% Extended at to recognize and accept scientific notation both at
% the numerator and (possible) denominator. Only a lowercase e will do here,
% but uppercase E is possible within an \xintexpr..\relax
%\end{lverb}
% \changed{1.2}
%\begin{lverb}
% Completely rewritten. The parsing handles inputs such as
% \A.\Be\C/\D.\Ee\F where each of \A, \B, \D, and \E may need f-expansion and
% \C and \F will end up in \numexpr.
%\end{lverb}
% \changed{1.2f}
%\begin{lverb}
% 1.2f corrects an issue to allow \C and \F to be \count variable (or
% expressions with \numexpr): 1.2 did a bad \numexpr0#1 which allowed only
% explicit digits for expanded #1.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_frac_gen #1/#2%
{%
    \xint_UDXINTWfork
      #2\XINT_frac_gen_A      % there was no /
      \XINT_W\XINT_frac_gen_B % there was a /
    \krof
    #1/#2%
}%
%    \end{macrocode}
%\begin{lverb}
% Note that #1 is only expanded so far up to decimal mark or "e".
%
% calx: native values reaching xintfrac (in \xinteval: a nested
% \xintfloatexpr or \xintiiexpr, a float or ii variable, a float or ii
% function). Input without [ and without /, hence also F, M, I values.
% \CALX_fga tests the first token (empty input: the e of ee., then
% \CALX_infr_o restores the original path, as for any other letter).
% F: \CALX_ftoraw gives A[N]; M: blocks by \CALX_ntoraw, exponent 8e
% (calxint's \CALX_infr_m); output {N}{A}{1} as \XINT_infrac. I:
% InvalidOperation, 0.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_frac_gen_A #1\xint:/\XINT_W [\XINT_W {\CALX_fga #1ee.\XINT_W }%
\def\CALX_fga #1{\ifnum`#1>57 \CALX_infr #1\fi\XINT_frac_gen_C 0~1!#1}%
\def\CALX_infr #1\fi\XINT_frac_gen_C 0~1!#2ee.\XINT_W\XINT_T
   {\fi\if I#1\xint_dothis\CALX_infr_i\fi
    \if M#1\xint_dothis\CALX_infr_m\fi
    \if F#1\xint_dothis\CALX_infr_f\fi
    \xint_orthat\CALX_infr_o{#2}}%
\def\CALX_infr_o #1{\XINT_frac_gen_C 0~1!#1ee.\XINT_W\XINT_T}%
\def\CALX_infr_f #1{\expandafter\CALX_infr_a\romannumeral0\CALX_ftoraw{#1}}%
\def\CALX_infr_a #1[#2]{{#2}{#1}{1}}%
\def\CALX_infr_i #1%
   {\XINT_signalcondition{InvalidOperation}{#1 has no xintfrac value}{}%
    {{0}{0}{1}}}%
\def\XINT_frac_gen_B #1/#2\xint:/\XINT_W[%\XINT_W
{%
    \expandafter\XINT_frac_gen_Ba
    \romannumeral`&&@#2ee.\XINT_W\XINT_Z #1ee.%\XINT_W
}%
\def\XINT_frac_gen_Ba #1.#2%
{%
    \xint_UDXINTWfork
      #2\XINT_frac_gen_Bb
      \XINT_W\XINT_frac_gen_Bc
    \krof
    #1.#2%
}%
\def\XINT_frac_gen_Bb #1e#2e#3\XINT_Z
                {\expandafter\XINT_frac_gen_C\the\numexpr #2+\xint_c_~#1!}%
\def\XINT_frac_gen_Bc #1.#2e%
{%
    \expandafter\XINT_frac_gen_Bd\romannumeral`&&@#2.#1e%
}%
\def\XINT_frac_gen_Bd #1.#2e#3e#4\XINT_Z
{%
    \expandafter\XINT_frac_gen_C\the\numexpr #3-%
    \numexpr\XINT_length_loop
    #1\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
      \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v
      \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye
    ~#2#1!%
}%
\def\XINT_frac_gen_C #1!#2.#3%
{%
    \xint_UDXINTWfork
      #3\XINT_frac_gen_Ca
      \XINT_W\XINT_frac_gen_Cb
    \krof
    #1!#2.#3%
}%
\def\XINT_frac_gen_Ca #1~#2!#3e#4e#5\XINT_T
{%
    \expandafter\XINT_frac_gen_F\the\numexpr #4-#1\expandafter
    ~\romannumeral0\expandafter\XINT_num_cleanup\the\numexpr\XINT_num_loop
     #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z~#3~%
}%
\def\XINT_frac_gen_Cb #1.#2e%
{%
    \expandafter\XINT_frac_gen_Cc\romannumeral`&&@#2.#1e%
}%
\def\XINT_frac_gen_Cc #1.#2~#3!#4e#5e#6\XINT_T
{%
    \expandafter\XINT_frac_gen_F\the\numexpr #5-#2-%
    \numexpr\XINT_length_loop
    #1\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
      \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v
      \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye
    \relax\expandafter~%
    \romannumeral0\expandafter\XINT_num_cleanup\the\numexpr\XINT_num_loop
    #3\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z
    ~#4#1~%
}%
\def\XINT_frac_gen_F #1~#2%
{%
    \xint_UDzerominusfork
      #2-\XINT_frac_gen_Gdivbyzero
      0#2{\XINT_frac_gen_G  -{}}%
       0-{\XINT_frac_gen_G {}#2}%
    \krof  #1~%
}%
\def\XINT_frac_gen_Gdivbyzero #1~~#2~%
{%
   \expandafter\XINT_frac_gen_Gdivbyzero_a
   \romannumeral0\expandafter\XINT_num_cleanup\the\numexpr\XINT_num_loop
   #2\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z~#1~%
}%
\def\XINT_frac_gen_Gdivbyzero_a #1~#2~%
{%
    \XINT_legacysignalcondition{DivisionByZero}{Division by zero: #1/0.}{}{{#2}{#1}{0}}%
}%
\def\XINT_frac_gen_G #1#2#3~#4~#5~%
{%
    \expandafter\XINT_frac_gen_Ga
    \romannumeral0\expandafter\XINT_num_cleanup\the\numexpr\XINT_num_loop
    #1#5\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z~#3~{#2#4}%
}%
\def\XINT_frac_gen_Ga #1#2~#3~%
{%
    \xint_gob_til_zero #1\XINT_frac_gen_zero 0%
    {#3}{#1#2}%
}%
\def\XINT_frac_gen_zero 0#1#2#3{{0}{0}{1}}%
%    \end{macrocode}
% \subsection{\csh{XINT_factortens}}
%\begin{lverb}
% This is the core macro for \xintREZ. To be used as
% \romannumeral0\XINT_factortens{...}. Output is A.N. (formerly {A}{N}) where
% A is the integer stripped from trailing zeroes and N is the number of
% removed zeroes. Only for positive strict integers!
%\end{lverb}
% \changed{1.3a}
%\begin{lverb}
% Completely rewritten at 1.3a to replace a double \xintReverseOrder by a
% direct \numexpr governed expansion to the end and back, à la 1.2. I should
% comment more... and perhaps improve again in future.
%
% Testing shows significant gain at 100 digits or more.
%\end{lverb}
% \changed{1.4p}
%\begin{lverb}
% \XINT_factortens_cc had an unnecessary \if#90 test, the false branch
% was never taken.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_factortens #1{\expandafter\XINT_factortens_z
                        \romannumeral0\XINT_factortens_a#1%
                        \XINT_factortens_b123456789.}%
\def\XINT_factortens_z.\XINT_factortens_y{ }%
\def\XINT_factortens_a #1#2#3#4#5#6#7#8#9%
   {\expandafter\XINT_factortens_x
    \the\numexpr 1#1#2#3#4#5#6#7#8#9\XINT_factortens_a}%
\def\XINT_factortens_b#1\XINT_factortens_a#2#3.%
   {.\XINT_factortens_cc 000000000-#2.}%
\def\XINT_factortens_x1#1.#2{#2#1}%
\def\XINT_factortens_y{.\XINT_factortens_y}%
\def\XINT_factortens_cc #1#2#3#4#5#6#7#8#9%
   {\expandafter\XINT_factortens_d\the\numexpr #8#7#6#5#4#3#2#1\relax
    \xint_c_i 2345678.}%
\def\XINT_factortens_yy #1#2.{.\XINT_factortens_y#1.0.}%
\def\XINT_factortens_c #1#2#3#4#5#6#7#8#9%
   {\if#90\xint_dothis
     {\expandafter\XINT_factortens_d\the\numexpr #8#7#6#5#4#3#2#1\relax
      \xint_c_i 2345678.}\fi
    \xint_orthat{.\XINT_factortens_y #1#2#3#4#5#6#7#8#9.}}%
\def\XINT_factortens_d #1#2#3#4#5#6#7#8#9%
   {\if#10\expandafter\XINT_factortens_e\fi
    \XINT_factortens_f #9#9#8#7#6#5#4#3#2#1.}%
\def\XINT_factortens_f #1#2\xint_c_i#3.#4.#5.%
   {\expandafter\XINT_factortens_g\the\numexpr#1+#5.#3.}%
\def\XINT_factortens_g #1.#2.{.\XINT_factortens_y#2.#1.}%
\def\XINT_factortens_e #1..#2.%
   {\expandafter.\expandafter\XINT_factortens_c
    \the\numexpr\xint_c_ix+#2.}%
%    \end{macrocode}
% \subsection{\xintListWithSep{, }
%             {\xintApply{ \csh}{{xintEq}{xintNotEq}{xintGt}{xintLt}{xintGtorEq}
%             {xintLtorEq}{xintIsZero}{xintIsNotZero}{xintOdd}
%             {xintEven}{xintifSgn}{xintifCmp}{xintifEq}{xintifGt}{xintifLt}
%             {xintifZero}{xintifNotZero}{xintifOne}{xintifOdd}}}}
%
%\begin{lverb}
% Moved here at 1.3. Formerly these macros were already defined in
% xint.sty or even xintcore.sty. They are slim wrappers of macros defined
% elsewhere in xintfrac.
%\end{lverb}
%    \begin{macrocode}
\def\xintEq   {\romannumeral0\xinteq }%
\def\xinteq   #1#2{\xintifeq{#1}{#2}{1}{0}}%
\def\xintNotEq#1#2{\romannumeral0\xintifeq {#1}{#2}{0}{1}}%
\def\xintGt {\romannumeral0\xintgt }%
\def\xintgt #1#2{\xintifgt{#1}{#2}{1}{0}}%
\def\xintLt   {\romannumeral0\xintlt }%
\def\xintlt #1#2{\xintiflt{#1}{#2}{1}{0}}%
\def\xintGtorEq #1#2{\romannumeral0\xintiflt {#1}{#2}{0}{1}}%
\def\xintLtorEq #1#2{\romannumeral0\xintifgt {#1}{#2}{0}{1}}%
\def\xintIsZero   {\romannumeral0\xintiszero }%
\def\xintiszero #1{\if0\xintSgn{#1}\xint_afterfi{ 1}\else\xint_afterfi{ 0}\fi}%
\def\xintIsNotZero{\romannumeral0\xintisnotzero }%
\def\xintisnotzero
          #1{\if0\xintSgn{#1}\xint_afterfi{ 0}\else\xint_afterfi{ 1}\fi}%
\def\xintOdd      {\romannumeral0\xintodd }%
\def\xintodd #1%
{%
    \ifodd\xintLDg{\xintNum{#1}} %<- intentional space
        \xint_afterfi{ 1}%
    \else
        \xint_afterfi{ 0}%
    \fi
}%
\def\xintEven     {\romannumeral0\xinteven }%
\def\xinteven #1%
{%
    \ifodd\xintLDg{\xintNum{#1}} %<- intentional space
        \xint_afterfi{ 0}%
    \else
        \xint_afterfi{ 1}%
    \fi
}%
\def\xintifSgn{\romannumeral0\xintifsgn }%
\def\xintifsgn #1%
{%
    \ifcase \xintSgn{#1}
               \expandafter\xint_stop_atsecondofthree
            \or\expandafter\xint_stop_atthirdofthree
          \else\expandafter\xint_stop_atfirstofthree
    \fi
}%
\def\xintifCmp{\romannumeral0\xintifcmp }%
\def\xintifcmp #1#2%
{%
    \ifcase\xintCmp {#1}{#2}
               \expandafter\xint_stop_atsecondofthree
            \or\expandafter\xint_stop_atthirdofthree
          \else\expandafter\xint_stop_atfirstofthree
    \fi
}%
\def\xintifEq {\romannumeral0\xintifeq }%
\def\xintifeq #1#2%
{%
    \if0\xintCmp{#1}{#2}%
               \expandafter\xint_stop_atfirstoftwo
          \else\expandafter\xint_stop_atsecondoftwo
    \fi
}%
\def\xintifGt {\romannumeral0\xintifgt }%
\def\xintifgt #1#2%
{%
    \if1\xintCmp{#1}{#2}%
               \expandafter\xint_stop_atfirstoftwo
          \else\expandafter\xint_stop_atsecondoftwo
    \fi
}%
\def\xintifLt {\romannumeral0\xintiflt }%
\def\xintiflt #1#2%
{%
    \ifnum\xintCmp{#1}{#2}<\xint_c_
          \expandafter\xint_stop_atfirstoftwo
    \else \expandafter\xint_stop_atsecondoftwo
    \fi
}%
\def\xintifZero   {\romannumeral0\xintifzero }%
\def\xintifzero #1%
{%
    \if0\xintSgn{#1}%
       \expandafter\xint_stop_atfirstoftwo
    \else
       \expandafter\xint_stop_atsecondoftwo
    \fi
}%
\def\xintifNotZero{\romannumeral0\xintifnotzero }%
\def\xintifnotzero #1%
{%
    \if0\xintSgn{#1}%
       \expandafter\xint_stop_atsecondoftwo
    \else
       \expandafter\xint_stop_atfirstoftwo
    \fi
}%
\def\xintifOne {\romannumeral0\xintifone }%
\def\xintifone #1%
{%
    \if1\xintIsOne{#1}%
       \expandafter\xint_stop_atfirstoftwo
    \else
       \expandafter\xint_stop_atsecondoftwo
    \fi
}%
\def\xintifOdd {\romannumeral0\xintifodd }%
\def\xintifodd #1%
{%
    \if\xintOdd{#1}1%
       \expandafter\xint_stop_atfirstoftwo
    \else
       \expandafter\xint_stop_atsecondoftwo
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintRaw}}
% \added{1.07}
%\begin{lverb}
% 1.07: this macro simply prints in a user readable form the fraction after its
% initial scanning. Useful when put inside braces in an \xintexpr, when the
% input is not yet in the A/B[n] form.
%\end{lverb}
%    \begin{macrocode}
\def\xintRaw {\romannumeral0\xintraw }%
\def\xintraw
{%
    \expandafter\XINT_raw\romannumeral0\XINT_infrac
}%
\def\XINT_raw #1#2#3{ #2/#3[#1]}%
%    \end{macrocode}
% \subsection{\csh{xintRawBraced}}
% \added{1.4l}
%\begin{lverb}
% User level interface to core \romannumeral0\XINT_infrac. Replaces
% \XINT_inFrac which was defined but nowhere used by the xint packages.
%\end{lverb}
%    \begin{macrocode}
\def\xintRawBraced {\romannumeral0\xintrawbraced }%
\let\xintrawbraced \XINT_infrac
%    \end{macrocode}
% \subsection{\csh{xintiLogTen}}
% \added{1.3e}
%\begin{lverb}
% The exponent a, such that 10^a<= abs(x) < 10^(a+1). No rounding done on x,
% handled as an exact fraction.
%\end{lverb}
%    \begin{macrocode}
\def\xintiLogTen {\the\numexpr\xintilogten}%
\def\xintilogten
{%
    \expandafter\XINT_ilogten\romannumeral0\xintraw
}%
\def\XINT_ilogten #1%
{%
    \xint_UDzerominusfork
      0#1\XINT_ilogten_p
      #1-\XINT_ilogten_z
      0-{\XINT_ilogten_p#1}%
    \krof
}%
\def\XINT_ilogten_z #1[#2]{-"7FFF8000\relax}%
\def\XINT_ilogten_p #1/#2[#3]%
{%
    #3+\expandafter\XINT_ilogten_a
       \the\numexpr\xintLength{#1}\expandafter.\the\numexpr\xintLength{#2}.#1.#2.%
}%
\def\XINT_ilogten_a #1.#2.%
{%
    #1-#2\ifnum#1>#2
      \expandafter\XINT_ilogten_aa
    \else
      \expandafter\XINT_ilogten_ab
    \fi #1.#2.%
}%
\def\XINT_ilogten_aa #1.#2.#3.#4.%
{%
    \xintiiifLt{#3}{\XINT_dsx_addzerosnofuss{#1-#2}#4;}{-1}{}\relax
}%
\def\XINT_ilogten_ab #1.#2.#3.#4.%
{%
    \xintiiifLt{\XINT_dsx_addzerosnofuss{#2-#1}#3;}{#4}{-1}{}\relax
}%
%    \end{macrocode}
% \subsection{\csh{xintPRaw}}
% \added{1.09b}
%    \begin{macrocode}
\def\xintPRaw {\romannumeral0\xintpraw }%
\def\xintpraw
{%
    \expandafter\XINT_praw\romannumeral0\XINT_infrac
}%
\def\XINT_praw #1%
{%
    \ifnum #1=\xint_c_ \expandafter\XINT_praw_a\fi \XINT_praw_A {#1}%
}%
\def\XINT_praw_A #1#2#3%
{%
    \if\XINT_isOne{#3}1\expandafter\xint_firstoftwo
                  \else\expandafter\xint_secondoftwo
    \fi { #2[#1]}{ #2/#3[#1]}%
}%
\def\XINT_praw_a\XINT_praw_A #1#2#3%
{%
    \if\XINT_isOne{#3}1\expandafter\xint_firstoftwo
                  \else\expandafter\xint_secondoftwo
    \fi { #2}{ #2/#3}%
}%
%    \end{macrocode}
% \subsection{\csh{xintSPRaw}}
%\begin{lverb}
% This private macro was for internal usage by \xinttheexpr.
% It got moved here
% at 1.4 and is not used anymore by the package.
%
% It checks if input has a [N] part, if yes uses \xintPRaw, else
% simply lets the input pass through as is.
%\end{lverb}
%    \begin{macrocode}
\def\xintSPRaw    {\romannumeral0\xintspraw }%
\def\xintspraw  #1{\expandafter\XINT_spraw\romannumeral`&&@#1[\W]}%
\def\XINT_spraw #1[#2#3]{\xint_gob_til_W #2\XINT_spraw_a\W\XINT_spraw_p #1[#2#3]}%
\def\XINT_spraw_a\W\XINT_spraw_p #1[\W]{ #1}%
\def\XINT_spraw_p #1[\W]{\xintpraw {#1}}%
%    \end{macrocode}
% \subsection{\csh{xintFracToSci}}
% \added{1.4l}
%\begin{lverb}
% The macro with this name which was added here at 1.4 then had
% various changes and finally was moved to $xintexprnameimp at 1.4k
% is now called there
% \xint_FracToSci_x and is private.  The present macro is public and
% behaves like the other $xintfracnameimp macros: f-expandable and
% accepts general input.  Its output is exactly the same as
% \xint_FracToSci_x for same inputs, with the exception of the empty
% input which \xintFracToSci will output as 0 but \xint_FracToSci_x
% as empty.  But the latter is not used by \xinteval for an empty
% leaf as it employs then \xintexprEmptyItem.
%\end{lverb}
%    \begin{macrocode}
\def\xintFracToSci{\romannumeral0\xintfractosci}%
\def\xintfractosci#1{\expandafter\XINT_fractosci\romannumeral0\xintraw{#1}}%
\def\XINT_fractosci#1#2/#3[#4]{\expanded{ %
    \ifnum#4=\xint_c_ #1#2\else
      \romannumeral0\expandafter\XINT_pfloat_a_fork\romannumeral0\xintrez{#1#2[#4]}%
    \fi
    \if\XINT_isOne{#3}1\else\if#10\else/#3\fi\fi}%
}%
%    \end{macrocode}
% \subsection{\csh{xintFracToDecimal}}
% \added{1.4l}
%\begin{lverb}
% The macro with this name which was added at 1.4k to
% $xintexprnameimp has been removed.  The public variant here
% behaves like the other
% $xintfracnameimp macros: f-expandable and accepts general input.
%\end{lverb}
%    \begin{macrocode}
\def\xintFracToDecimal{\romannumeral0\xintfractodecimal}%
\def\xintfractodecimal#1{\expandafter\XINT_fractodecimal\romannumeral0\xintraw{#1}}%
\def\XINT_fractodecimal #1#2/#3[#4]{\expanded{ %
    \ifnum#4=\xint_c_ #1#2\else
      \romannumeral0\expandafter\XINT_dectostr\romannumeral0\xintrez{#1#2[#4]}%
    \fi
    \if\XINT_isOne{#3}1\else\if#10\else/#3\fi\fi}%
}%
%    \end{macrocode}
% \subsection{\csh{xintRawWithZeros}}
%\begin{lverb}
% This was called \xintRaw in versions earlier than 1.07
%\end{lverb}
%    \begin{macrocode}
\def\xintRawWithZeros {\romannumeral0\xintrawwithzeros }%
\def\xintrawwithzeros
{%
    \expandafter\XINT_rawz_fork\romannumeral0\XINT_infrac
}%
\def\XINT_rawz_fork #1%
{%
    \ifnum#1<\xint_c_
      \expandafter\XINT_rawz_Ba
    \else
      \expandafter\XINT_rawz_A
    \fi
    #1.%
}%
\def\XINT_rawz_A  #1.#2#3{\XINT_dsx_addzeros{#1}#2;/#3}%
\def\XINT_rawz_Ba -#1.#2#3{\expandafter\XINT_rawz_Bb
    \expandafter{\romannumeral0\XINT_dsx_addzeros{#1}#3;}{#2}}%
\def\XINT_rawz_Bb #1#2{ #2/#1}%
%    \end{macrocode}
% \subsection{\csh{xintDecToString}}
% \added{1.3}
%\begin{lverb}
% This is a backport from polexpr 0.4. It is definitely not in
% final form, consider it to be an unstable macro.
%\end{lverb}
%    \begin{macrocode}
\def\xintDecToString{\romannumeral0\xintdectostring}%
\def\xintdectostring#1{\expandafter\XINT_dectostr\romannumeral0\xintraw{#1}}%
\def\XINT_dectostr #1/#2[#3]{\xintiiifZero {#1}%
       \XINT_dectostr_z
       {\if1\XINT_isOne{#2}\expandafter\XINT_dectostr_a
                      \else\expandafter\XINT_dectostr_b
        \fi}%
  #1/#2[#3]%
}%
\def\XINT_dectostr_z#1[#2]{ 0}%
\def\XINT_dectostr_a#1/#2[#3]{%
    \ifnum#3<\xint_c_\xint_dothis{\xinttrunc{-#3}{#1[#3]}}\fi
    \xint_orthat{\xintiie{#1}{#3}}%
}%
\def\XINT_dectostr_b#1/#2[#3]{% just to handle this somehow
    \ifnum#3<\xint_c_\xint_dothis{\xinttrunc{-#3}{#1[#3]}/#2}\fi
    \xint_orthat{\xintiie{#1}{#3}/#2}%
}%
%    \end{macrocode}
% \subsection{\csh{xintDecToStringREZ}}
% \added{1.4e}
%\begin{lverb}
% And I took this opportunity to improve documentation in manual.
%\end{lverb}
%    \begin{macrocode}
\def\xintDecToStringREZ{\romannumeral0\xintdectostringrez}%
\def\xintdectostringrez#1{\expandafter\XINT_dectostr\romannumeral0\xintrez{#1}}%
%    \end{macrocode}
% \subsection{\csh{xintFloor}, \csh{xintiFloor}}
% \added{1.09a}
%\begin{lverb}
% By calxfp's \CALX_fintp on the parts {N}{A}{B} of \XINT_infrac: s sign,
% T digits of |trunc(X)|, z = 1 if X is not an integer. floor(X) = T (s =
% +) or -(T + z); ceil(X) = T + z (s = +) or -T. +1 by xintcore's
% \xintinc. \xintFloor, \xintCeil append /1[0].
%\end{lverb}
%    \begin{macrocode}
\def\xintFloor {\romannumeral0\xintfloor }%
\def\xintfloor #1{\expandafter\XINT_fl_q\romannumeral0\xintifloor{#1}\xint:}%
\def\XINT_fl_q #1\xint:{ #1/1[0]}%
\def\xintiFloor {\romannumeral0\xintifloor }%
\def\xintifloor #1%
   {\expandafter\XINT_ifloor\romannumeral0\XINT_infrac{#1}\XINT_ifloor_f}%
\def\XINT_ifloor #1#2#3#4{\expandafter#4\romannumeral0\CALX_fintp{#2}{#3}{#1}}%
\def\XINT_ifloor_f #1#2.#3#4%
   {\if-#1\xint_dothis{\XINT_ifloor_m#4{#2}}\fi\xint_orthat{ #2}}%
\def\XINT_ifloor_m #1#2%
{%
    \if1#1\xint_dothis{\expandafter-\romannumeral0\xintinc{#2}}\fi
    \xint_orthat{ -#2}%
}%
%    \end{macrocode}
% \subsection{\csh{xintCeil}, \csh{xintiCeil}}
% \added{1.09a}
%    \begin{macrocode}
\def\xintCeil {\romannumeral0\xintceil }%
\def\xintceil #1{\expandafter\XINT_fl_q\romannumeral0\xinticeil{#1}\xint:}%
\def\xintiCeil {\romannumeral0\xinticeil }%
\def\xinticeil #1%
   {\expandafter\XINT_ifloor\romannumeral0\XINT_infrac{#1}\XINT_iceil_f}%
\def\XINT_iceil_f #1#2.#3#4%
{%
    \if-#1\xint_dothis{\XINT_iceil_m #2\xint:}\fi
    \if1#4\xint_dothis{\xintinc{#2}}\fi
    \xint_orthat{ #2}%
}%
\def\XINT_iceil_m #1#2\xint:{\if0#1\xint_dothis{ 0}\fi\xint_orthat{ -#1#2}}%
%    \end{macrocode}
% \subsection{\csh{xintNumerator}}
%    \begin{macrocode}
\def\xintNumerator {\romannumeral0\xintnumerator }%
\def\xintnumerator
{%
    \expandafter\XINT_numer\romannumeral0\XINT_infrac
}%
\def\XINT_numer #1%
{%
    \ifcase\XINT_cntSgn #1\xint:
      \expandafter\XINT_numer_B
    \or
      \expandafter\XINT_numer_A
    \else
      \expandafter\XINT_numer_B
    \fi
    {#1}%
}%
\def\XINT_numer_A #1#2#3{\XINT_dsx_addzeros{#1}#2;}%
\def\XINT_numer_B #1#2#3{ #2}%
%    \end{macrocode}
% \subsection{\csh{xintDenominator}}
%    \begin{macrocode}
\def\xintDenominator {\romannumeral0\xintdenominator }%
\def\xintdenominator
{%
    \expandafter\XINT_denom_fork\romannumeral0\XINT_infrac
}%
\def\XINT_denom_fork #1%
{%
    \ifnum#1<\xint_c_
      \expandafter\XINT_denom_B
    \else
      \expandafter\XINT_denom_A
    \fi
    #1.%
}%
\def\XINT_denom_A #1.#2#3{ #3}%
\def\XINT_denom_B -#1.#2#3{\XINT_dsx_addzeros{#1}#3;}%
%    \end{macrocode}
% \subsection{\csh{xintTeXFrac}}
% \added{1.03}
%\begin{lverb}
% Useless typesetting macro.
%\end{lverb}
% \changed[2021/05/24]{1.4g}
%\begin{lverb}
% Renamed from \xintFrac.
%\end{lverb}
% \changed{1.4m}
% The old name now raises an error, not a warning.
%    \begin{macrocode}
\ifdefined\PackageWarning
\def\xintfracTeXDeprecation#1#2{%
\PackageWarning{xintfrac}{\string#1 is deprecated. Use \string#2\MessageBreak
                          to suppress this warning}#2%
}%
\else
\edef\xintfracTeXDeprecation#1#2{{\newlinechar10
\immediate\noexpand\write128{&&JPackage xintfrac Warning: \noexpand\string#1 is
  deprecated. Use \noexpand\string#2&&J%
(xintfrac)\xintReplicate{16}{ }to suppress this warning
on input line \noexpand\the\inputlineno.&&J}}#2%
}%
\fi
\ifdefined\PackageError
\def\xintfracTeXError#1#2{%
\PackageError{xintfrac}{\string#1 has been removed.\MessageBreak
    Use \string#2 to suppress this error}%
    {I will fix it for now if you hit the `Return' key.}#2%
}%
\else
\edef\xintfracTeXError#1#2{{\newlinechar10
\errhelp{I will fix it for now if you hit the `Return' key.}%
\errmessage{Package xintfrac Error: \noexpand\string#1 has been removed.&&J%
(xintfrac)\xintReplicate{16}{ }Use \noexpand\string#2 to suppress this error}}#2%
}%
\fi
\def\xintFrac   {\xintfracTeXError\xintFrac\xintTeXFrac}%
\def\xintTeXFrac{\romannumeral0\xintfrac }%
\def\xintfrac #1%
{%
    \expandafter\XINT_fracfrac_A\romannumeral0\XINT_infrac {#1}%
}%
\def\XINT_fracfrac_A #1{\XINT_fracfrac_B #1\Z }%
\catcode`^=7
\def\XINT_fracfrac_B #1#2\Z
{%
    \xint_gob_til_zero #1\XINT_fracfrac_C 0\XINT_fracfrac_D {10^{#1#2}}%
}%
\def\XINT_fracfrac_C 0\XINT_fracfrac_D #1#2#3%
{%
    \if1\XINT_isOne {#3}%
        \xint_afterfi {\expandafter\xint_stop_atfirstoftwo\xint_gobble_ii }%
    \fi
    \space
    \frac {#2}{#3}%
}%
\def\XINT_fracfrac_D #1#2#3%
{%
    \if1\XINT_isOne {#3}\XINT_fracfrac_E\fi
    \space
    \frac {#2}{#3}#1%
}%
\def\XINT_fracfrac_E \fi\space\frac #1#2{\fi \space #1\cdot }%
%    \end{macrocode}
% \subsection{\csh{xintTeXsignedFrac}}
% \changed[2021/05/24]{1.4g}
%\begin{lverb}
% Renamed from \xintSignedFrac.
%\end{lverb}
% \changed{1.4m}
% The old name now raises an error, not a warning.
%    \begin{macrocode}
\def\xintSignedFrac   {\xintfracTeXError\xintSignedFrac\xintTeXsignedFrac}%
\def\xintTeXsignedFrac{\romannumeral0\xintsignedfrac }%
\def\xintsignedfrac #1%
{%
    \expandafter\XINT_sgnfrac_a\romannumeral0\XINT_infrac {#1}%
}%
\def\XINT_sgnfrac_a #1#2%
{%
    \XINT_sgnfrac_b #2\Z {#1}%
}%
\def\XINT_sgnfrac_b #1%
{%
    \xint_UDsignfork
      #1\XINT_sgnfrac_N
       -{\XINT_sgnfrac_P #1}%
    \krof
}%
\def\XINT_sgnfrac_P #1\Z #2%
{%
    \XINT_fracfrac_A {#2}{#1}%
}%
\def\XINT_sgnfrac_N
{%
    \expandafter-\romannumeral0\XINT_sgnfrac_P
}%
%    \end{macrocode}
% \subsection{\csh{xintTeXFromSci}}
% \added{1.4g}
%\begin{lverb}
% The main problem is how to name this and related macros.
%
% I use \expanded here, as \xintFracToSci is not f-expandable.
%
% Some complications as I want this to be usable on output of \xintFracToSci
% hence need to handle the case of a /B.  After some hesitations I ended with
% the following which looks reasonable:
%(- if no scientific part, use \frac (or \over) for A/B
%:- if scientific part, postfix /B as \cdot B^{-1}
%)
%\end{lverb}
% \changed{1.4l}
%\begin{lverb}
% Suppress external \expanded. Keep internal one.
%
% Rename \xintTeXFromSci from \xintTeXfromSci. Keep deprecated old name
% for the moment.
%
% Add \xintTeXFromScifracmacro. Make it \protected.
%
% Nota bene: catcode of ^ is normal one here (else nothing would work).
%\end{lverb}
%    \begin{macrocode}
\def\xintTeXfromSci{\xintfracTeXDeprecated\xintTeXfromSci\xintTeXFromSci}%
\def\xintTeXFromSci#1%
{%
    \expandafter\XINT_texfromsci\expanded{#1}/\relax/\xint:
}%
\def\XINT_texfromsci #1/#2#3/#4\xint:
{%
    \XINT_texfromsci_a #1e\relax e\xint:
    {\ifx\relax#2\xint_dothis\xint_firstofone\fi
     \xint_orthat{\xintTeXFromScifracmacro{#2#3}}}%
    {\unless\ifx\relax#2\cdot{#2#3}^{-1}\fi}%
}%
\def\XINT_texfromsci_a #1e#2#3e#4\xint:#5#6%
{%
    \ifx\relax#2#5{#1}\else#1\cdot10^{#2#3}#6\fi
}%
\ifdefined\frac
  \protected\def\xintTeXFromScifracmacro#1#2{\frac{#2}{#1}}%
\else
  \protected\def\xintTeXFromScifracmacro#1#2{{#2\over#1}}%
\fi
%    \end{macrocode}
% \subsection{\csh{xintTeXOver}}
% \changed[2021/05/24]{1.4g}
%\begin{lverb}
% Renamed from \xintFwOver.
%\end{lverb}
% \changed{1.4m}
% The old name now raises an error, not a warning.
%    \begin{macrocode}
\def\xintFwOver {\xintfracTeXError\xintFwOver\xintTeXOver}%
\def\xintTeXOver{\romannumeral0\xintfwover }%
\def\xintfwover #1%
{%
    \expandafter\XINT_fwover_A\romannumeral0\XINT_infrac {#1}%
}%
\def\XINT_fwover_A #1{\XINT_fwover_B #1\Z }%
\def\XINT_fwover_B #1#2\Z
{%
    \xint_gob_til_zero #1\XINT_fwover_C 0\XINT_fwover_D {10^{#1#2}}%
}%
\catcode`^=11
\def\XINT_fwover_C #1#2#3#4#5%
{%
    \if0\XINT_isOne {#5}\xint_afterfi { {#4\over #5}}%
                   \else\xint_afterfi { #4}%
    \fi
}%
\def\XINT_fwover_D #1#2#3%
{%
    \if0\XINT_isOne {#3}\xint_afterfi { {#2\over #3}}%
                   \else\xint_afterfi { #2\cdot }%
    \fi
    #1%
}%
%    \end{macrocode}
% \subsection{\csh{xintTeXsignedOver}}
% \changed[2021/05/24]{1.4g}
%\begin{lverb}
% Renamed from \xintSignedFwOver.
%\end{lverb}
% \changed{1.4m}
% The old name now raises an error, not a warning.
%    \begin{macrocode}
\def\xintSignedFwOver {\xintfracTeXError\xintSignedFwOver\xintTeXsignedOver}%
\def\xintTeXsignedOver{\romannumeral0\xintsignedfwover }%
\def\xintsignedfwover #1%
{%
    \expandafter\XINT_sgnfwover_a\romannumeral0\XINT_infrac {#1}%
}%
\def\XINT_sgnfwover_a #1#2%
{%
    \XINT_sgnfwover_b #2\Z {#1}%
}%
\def\XINT_sgnfwover_b #1%
{%
    \xint_UDsignfork
      #1\XINT_sgnfwover_N
       -{\XINT_sgnfwover_P #1}%
    \krof
}%
\def\XINT_sgnfwover_P #1\Z #2%
{%
    \XINT_fwover_A {#2}{#1}%
}%
\def\XINT_sgnfwover_N
{%
    \expandafter-\romannumeral0\XINT_sgnfwover_P
}%
%    \end{macrocode}
% \subsection{\csh{xintREZ}}
%\begin{lverb}
% Removes trailing zeros from A and B and adjust the N in A/B[N].
%
% The macro really doing the job \XINT_factortens was redone at 1.3a. But
% speed gain really noticeable only beyond about 100 digits.
%\end{lverb}
%    \begin{macrocode}
\def\xintREZ {\romannumeral0\xintrez }%
\def\xintrez
{%
    \expandafter\XINT_rez_A\romannumeral0\XINT_infrac
}%
\def\XINT_rez_A #1#2%
{%
    \XINT_rez_AB #2\Z {#1}%
}%
\def\XINT_rez_AB #1%
{%
    \xint_UDzerominusfork
      #1-\XINT_rez_zero
      0#1\XINT_rez_neg
       0-{\XINT_rez_B #1}%
    \krof
}%
\def\XINT_rez_zero #1\Z #2#3{ 0/1[0]}%
\def\XINT_rez_neg {\expandafter-\romannumeral0\XINT_rez_B }%
\def\XINT_rez_B #1\Z
{%
    \expandafter\XINT_rez_C\romannumeral0\XINT_factortens {#1}%
}%
\def\XINT_rez_C #1.#2.#3#4%
{%
    \expandafter\XINT_rez_D\romannumeral0\XINT_factortens {#4}#3+#2.#1.%
}%
\def\XINT_rez_D #1.#2.#3.%
{%
    \expandafter\XINT_rez_E\the\numexpr #3-#2.#1.%
}%
\def\XINT_rez_E #1.#2.#3.{ #3/#2[#1]}%
%    \end{macrocode}
% \subsection{\csh{xintE}}
% \added{1.07}
%\begin{lverb}
% The fraction is the first argument contrarily to \xintTrunc and
% \xintRound.
%\end{lverb}
% \changed{1.1}
%\begin{lverb}
% 1.1 modifies and moves \xintiiE to xint.sty.
%\end{lverb}
%    \begin{macrocode}
\def\xintE {\romannumeral0\xinte }%
\def\xinte #1%
{%
    \expandafter\XINT_e \romannumeral0\XINT_infrac {#1}%
}%
\def\XINT_e #1#2#3#4%
{%
    \expandafter\XINT_e_end\the\numexpr #1+#4.{#2}{#3}%
}%
\def\XINT_e_end #1.#2#3{ #2/#3[#1]}%
%    \end{macrocode}
% \subsection{\csh{xintIrr}, \csh{xintPIrr}}
% \changed{1.04}
%\begin{lverb}
% fixes a buggy \xintIrr {0}.
%\end{lverb}
% \changed{1.05}
%\begin{lverb}
% modifies the initial parsing and post-processing to use \xintrawwithzeros
% and to more quickly deal with an input denominator equal to 1.
%\end{lverb}
% \changed{1.08}
%\begin{lverb}
% this version does not remove a /1 denominator.
%\end{lverb}
% \changed{1.3}
%\begin{lverb}
% added \xintPIrr (partial Irr, which ignores the decimal part).
%\end{lverb}
%    \begin{macrocode}
\def\xintIrr {\romannumeral0\xintirr }%
\def\xintPIrr{\romannumeral0\xintpirr }%
\def\xintirr #1%
{%
    \expandafter\XINT_irr_start\romannumeral0\xintrawwithzeros {#1}\Z
}%
\def\xintpirr #1%
{%
    \expandafter\XINT_pirr_start\romannumeral0\xintraw{#1}%
}%
\def\XINT_irr_start #1#2/#3\Z
{%
    \if0\XINT_isOne {#3}%
      \xint_afterfi
          {\xint_UDsignfork
               #1\XINT_irr_negative
                -{\XINT_irr_nonneg #1}%
           \krof}%
    \else
      \xint_afterfi{\XINT_irr_denomisone #1}%
    \fi
    #2\Z {#3}%
}%
\def\XINT_pirr_start #1#2/#3[%
{%
    \if0\XINT_isOne {#3}%
      \xint_afterfi
          {\xint_UDsignfork
               #1\XINT_irr_negative
                -{\XINT_irr_nonneg #1}%
           \krof}%
    \else
      \xint_afterfi{\XINT_irr_denomisone #1}%
    \fi
    #2\Z {#3}[%
}%
\def\XINT_irr_denomisone #1\Z #2{ #1/1}% changed in 1.08
\def\XINT_irr_negative   #1\Z #2{\XINT_irr_D #1\Z #2\Z -}%
\def\XINT_irr_nonneg     #1\Z #2{\XINT_irr_D #1\Z #2\Z \space}%
\def\XINT_irr_D #1#2\Z #3#4\Z
{%
    \xint_UDzerosfork
       #3#1\XINT_irr_indeterminate
       #30\XINT_irr_divisionbyzero
       #10\XINT_irr_zero
        00\XINT_irr_loop_a
    \krof
    {#3#4}{#1#2}{#3#4}{#1#2}%
}%
\def\XINT_irr_indeterminate #1#2#3#4#5%
{%
    \XINT_legacysignalcondition{DivisionUndefined}{0/0 indeterminate fraction.}{}{ 0/1}%
}%
\def\XINT_irr_divisionbyzero #1#2#3#4#5%
{%
    \XINT_legacysignalcondition{DivisionByZero}{Division by zero: #5#2/0.}{}{ 0/1}%
}%
\def\XINT_irr_zero #1#2#3#4#5{ 0/1}% changed in 1.08
\def\XINT_irr_loop_a #1#2%
{%
    \expandafter\XINT_irr_loop_d
    \romannumeral0\XINT_ndivrawpair {#1}{#2}{#1}%
}%
\def\XINT_irr_loop_d #1#2%
{%
    \XINT_irr_loop_e #2\Z
}%
\def\XINT_irr_loop_e #1#2\Z
{%
    \xint_gob_til_zero #1\XINT_irr_loop_exit0\XINT_irr_loop_a {#1#2}%
}%
\def\XINT_irr_loop_exit0\XINT_irr_loop_a #1#2#3#4%
{%
    \expandafter\XINT_irr_loop_exitb\expandafter
    {\romannumeral0\xintiiquo {#3}{#2}}%
    {\romannumeral0\xintiiquo {#4}{#2}}%
}%
\def\XINT_irr_loop_exitb #1#2%
{%
   \expandafter\XINT_irr_finish\expandafter {#2}{#1}%
}%
\def\XINT_irr_finish #1#2#3{#3#1/#2}% changed in 1.08
%    \end{macrocode}
% \subsection{\csh{xintifInt}}
%    \begin{macrocode}
\def\xintifInt   {\romannumeral0\xintifint }%
\def\xintifint #1{\expandafter\XINT_ifint\romannumeral0\xintrawwithzeros {#1}.}%
\def\XINT_ifint #1/#2.%
{%
    \if 0\xintiiRem {#1}{#2}%
     \expandafter\xint_stop_atfirstoftwo
    \else
     \expandafter\xint_stop_atsecondoftwo
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintIsInt}}
%\begin{lverb}
% Added at 1.3d only, for isint() xintexpr function.
%\end{lverb}
%    \begin{macrocode}
\def\xintIsInt   {\romannumeral0\xintisint }%
\def\xintisint #1%
   {\expandafter\XINT_ifint\romannumeral0\xintrawwithzeros {#1}.10}%
%    \end{macrocode}
% \subsection{\csh{xintJrr}}
%    \begin{macrocode}
\def\xintJrr {\romannumeral0\xintjrr }%
\def\xintjrr #1%
{%
    \expandafter\XINT_jrr_start\romannumeral0\xintrawwithzeros {#1}\Z
}%
\def\XINT_jrr_start #1#2/#3\Z
{%
    \if0\XINT_isOne {#3}\xint_afterfi
          {\xint_UDsignfork
               #1\XINT_jrr_negative
                -{\XINT_jrr_nonneg #1}%
           \krof}%
    \else
      \xint_afterfi{\XINT_jrr_denomisone #1}%
    \fi
    #2\Z {#3}%
}%
\def\XINT_jrr_denomisone #1\Z #2{ #1/1}% changed in 1.08
\def\XINT_jrr_negative   #1\Z #2{\XINT_jrr_D #1\Z #2\Z -}%
\def\XINT_jrr_nonneg     #1\Z #2{\XINT_jrr_D #1\Z #2\Z \space}%
\def\XINT_jrr_D #1#2\Z #3#4\Z
{%
    \xint_UDzerosfork
       #3#1\XINT_jrr_indeterminate
       #30\XINT_jrr_divisionbyzero
       #10\XINT_jrr_zero
        00\XINT_jrr_loop_a
    \krof
    {#3#4}{#1#2}1001%
}%
\def\XINT_jrr_indeterminate #1#2#3#4#5#6#7%
{%
    \XINT_legacysignalcondition{DivisionUndefined}{0/0 indeterminate fraction.}{}{ 0/1}%
}%
\def\XINT_jrr_divisionbyzero #1#2#3#4#5#6#7%
{%
    \XINT_legacysignalcondition{DivisionByZero}{Division by zero: #7#2/0.}{}{ 0/1}%
}%
\def\XINT_jrr_zero #1#2#3#4#5#6#7{ 0/1}% changed in 1.08
\def\XINT_jrr_loop_a #1#2%
{%
    \expandafter\XINT_jrr_loop_b
    \romannumeral0\XINT_ndivrawpair {#1}{#2}{#1}%
}%
\def\XINT_jrr_loop_b #1#2#3#4#5#6#7%
{%
    \expandafter \XINT_jrr_loop_c \expandafter
        {\romannumeral0\xintiiadd{\xintiimul{#4}{#1}}{#6}}%
        {\romannumeral0\xintiiadd{\xintiimul{#5}{#1}}{#7}}%
    {#2}{#3}{#4}{#5}%
}%
\def\XINT_jrr_loop_c #1#2%
{%
    \expandafter \XINT_jrr_loop_d \expandafter{#2}{#1}%
}%
\def\XINT_jrr_loop_d #1#2#3#4%
{%
    \XINT_jrr_loop_e #3\Z {#4}{#2}{#1}%
}%
\def\XINT_jrr_loop_e #1#2\Z
{%
    \xint_gob_til_zero #1\XINT_jrr_loop_exit0\XINT_jrr_loop_a {#1#2}%
}%
\def\XINT_jrr_loop_exit0\XINT_jrr_loop_a #1#2#3#4#5#6%
{%
    \XINT_irr_finish {#3}{#4}%
}%
%    \end{macrocode}
% \subsection{\csh{xintTFrac}}
% \added{1.09i}
%\begin{lverb}
% For frac in \xintexpr. And \xintFrac is already assigned. T for
% truncation. However, potentially not very efficient with numbers in scientific
% notations, with big exponents. Will have to think it again some day. I
% hesitated how to call the macro. Same convention as in maple, but some people
% reserve fractional part to x - floor(x). Also, not clear if I had to make it
% negative (or zero) if x < 0, or rather always positive. There should be in
% fact such a thing for each rounding function, trunc, round, floor, ceil. 
%\end{lverb}
%    \begin{macrocode}
\def\xintTFrac {\romannumeral0\xinttfrac }%
\def\xinttfrac #1{\expandafter\XINT_tfrac_fork\romannumeral0\xintrawwithzeros {#1}\Z }%
\def\XINT_tfrac_fork #1%
{%
    \xint_UDzerominusfork
        #1-\XINT_tfrac_zero
        0#1{\xintiiopp\XINT_tfrac_P }%
         0-{\XINT_tfrac_P #1}%
    \krof
}%
\def\XINT_tfrac_zero #1\Z { 0/1[0]}%
\def\XINT_tfrac_P #1/#2\Z {\expandafter\XINT_rez_AB
                           \romannumeral0\xintiirem{#1}{#2}\Z {0}{#2}}%
%    \end{macrocode}
% \subsection{\csh{xintTrunc}, \csh{xintiTrunc}}
%\begin{lverb}
% Syntax: \xinttrunc{n}{X}, \xintitrunc{n}{X} (with \romannumeral0).
% calxfp's \CALX_fintp on A/B[N+n], {N}{A}{B} from \XINT_infrac: <s><T>.<d><z>
% (sign of X, digits of |trunc(X 10^n)|, first omitted digit, z = 1 if
% the omitted part is not zero). The post-processor (\XINT_trunc_b, or
% \XINT_round_b which adds 1 to T if d >= 5) hands T.<sign><n>. to the
% final macro \XINT_trunc_G (decimal output) or \XINT_itrunc_G (integer);
% the sign token is - or \space. Zero input (T = 0 and z = 0): 0.
%\end{lverb}
% \changed[2020/02/18]{1.4a}
%\begin{lverb}
%
% Adds handling of a negative first argument.
%
% Zero input still gives single digit 0 output as I did not want to complicate
% the code. But if quantization gives 0, the exponent [D] will be there. Well
% actually eD because of problem that sign of original is preserved in output
% so we can have -0 and I can not use -0[D] notation as it is not legal for
% strict format. So I will use -0eD hence eD generally even though this means
% so slight suboptimality for trunc() function in \xintexpr.
%
% The idea to give a meaning to negative D (in the context of optional
% argument to \xintiexpr) was suggested a long time ago by Kpym (October 20,
% 2015). His suggestion was then to treat it as positive D but trim trailing
% zeroes. But since then, there is \xintDecToString which can be combined with
% \xintREZ, and I feel matters of formatting output require a whole module (or
% rather use existing third-party tools), and I decided to opt rather for an
% operation similar as the quantize() of Python Decimal module. I.e. we
% truncate (or round) to an integer multiple of a given power of 10.
%
% Other reason to decide to do this is that it looks as if I don't even need
% to understand the original code to hack into its ending via \XINT_trunc_G or
% \XINT_itrunc_G. For the latter it looks as if logically I simply have to do
% nothing. For the former I simply have to add some eD postfix.
%\end{lverb}
%    \begin{macrocode}
\def\xintTrunc  {\romannumeral0\xinttrunc }%
\def\xintiTrunc {\romannumeral0\xintitrunc}%
\def\xinttrunc #1{\expandafter\XINT_trunc\the\numexpr#1.\XINT_trunc_G}%
\def\xintitrunc #1{\expandafter\XINT_trunc\the\numexpr#1.\XINT_itrunc_G}%
\def\XINT_trunc #1.#2#3%
   {\expandafter\XINT_trunc_a\romannumeral0\XINT_infrac{#3}#1.\XINT_trunc_b#2}%
\def\XINT_trunc_a #1#2#3#4.#5%
   {\expandafter\XINT_trunc_c\the\numexpr#1+#4.{#2}{#3}#5#4.}%
\def\XINT_trunc_c #1.#2#3#4%
   {\expandafter#4\romannumeral0\CALX_fintp{#2}{#3}{#1}}%
\def\XINT_trunc_b #1#2#3.#4#5#6.#7%
{%
    \if0#2\if0#5\XINT_trunc_z\fi\fi
    \if-#1\xint_dothis{#7#2#3.-#6.}\fi
    \xint_orthat{#7#2#3.\space#6.}%
}%
\def\XINT_trunc_z #1\xint_orthat#2{\fi\fi\space0}%
\def\XINT_itrunc_G #1#2.#3#4.%
{%
    \if#10\xint_dothis{ 0}\fi
    \xint_orthat{#3#1}#2%
}%
\def\XINT_trunc_G #1.#2#3#4.%
{%
    \xint_gob_til_minus#3\XINT_trunc_Hc-%
    \expandafter\XINT_trunc_H
    \the\numexpr\romannumeral0\xintlength {#1}-#3#4.#3#4.{#1}#2%
}%
\def\XINT_trunc_Hc-\expandafter\XINT_trunc_H
    \the\numexpr\romannumeral0\xintlength #1.-#2.#3#4{#4#3e#2}%
\def\XINT_trunc_H #1.#2.%
{%
    \ifnum #1 > \xint_c_ \xint_dothis{\XINT_trunc_Ha {#2}}\fi
    \xint_orthat {\XINT_trunc_Hb {-#1}}% -0,--1,--2, ....
}%
\def\XINT_trunc_Ha%
{%
    \expandafter\XINT_trunc_Haa\romannumeral0\xintdecsplit
}%
\def\XINT_trunc_Haa #1#2#3{#3#1.#2}%
\def\XINT_trunc_Hb #1#2#3%
{%
    \expandafter #3\expandafter0\expandafter.%
    \romannumeral\xintreplicate{#1}0#2%
}%
%    \end{macrocode}
% \subsection{\csh{xintTTrunc}}
% \added{1.1}
%    \begin{macrocode}
\def\xintTTrunc {\romannumeral0\xintttrunc }%
\def\xintttrunc {\xintitrunc\xint_c_}%
%    \end{macrocode}
% \subsection{\csh{xintNum}, \csh{xintnum}}
%    \begin{macrocode}
\let\xintnum \xintttrunc
%    \end{macrocode}
% \subsection{\csh{xintRound}, \csh{xintiRound}}
%\begin{lverb}
% As \xintTrunc, \xintiTrunc, with the post-processor \XINT_round_b: T + 1
% (xintcore's \xintinc) if the first omitted digit is at least 5 (round
% half away from zero). A negative first argument is handled by
% \XINT_trunc_G.
%\end{lverb}
%    \begin{macrocode}
\def\xintRound  {\romannumeral0\xintround }%
\def\xintiRound {\romannumeral0\xintiround }%
\def\xintround  #1{\expandafter\XINT_round\the\numexpr#1.\XINT_trunc_G}%
\def\xintiround #1{\expandafter\XINT_round\the\numexpr#1.\XINT_itrunc_G}%
\def\XINT_round #1.#2#3%
   {\expandafter\XINT_trunc_a\romannumeral0\XINT_infrac{#3}#1.\XINT_round_b#2}%
\def\XINT_round_b #1#2.#3#4%
{%
    \ifnum#3>\xint_c_iv
      \xint_dothis{\expandafter\XINT_round_c\romannumeral0\xintinc{#2}.#1#4}\fi
    \xint_orthat{\XINT_trunc_b #1#2.#3#4}%
}%
\def\XINT_round_c #1.#2#3{\XINT_trunc_b #2#1.0#3}%
%    \end{macrocode}
% \subsection{\csh{xintXTrunc}}
%\begin{lverb}
% Temporarily use \xintTrunc: the former implementation was only
% x-expandable and more efficient.  Reimplement this entry completely later.
%\end{lverb}
%    \begin{macrocode}
\let\xintXTrunc\xintTrunc
%    \end{macrocode}
% \subsection{\csh{xintAdd}}
% \changed{1.3}
%\begin{lverb}
% Big change at 1.3: a/b+c/d uses lcm(b,d) as denominator.
%\end{lverb}
%    \begin{macrocode}
\def\xintAdd {\romannumeral0\xintadd }%
\def\xintadd #1{\expandafter\XINT_fadd\romannumeral0\xintraw {#1}}%
\def\XINT_fadd #1{\xint_gob_til_zero #1\XINT_fadd_Azero 0\XINT_fadd_a #1}%
\def\XINT_fadd_Azero #1]{\xintraw }%
\def\XINT_fadd_a #1/#2[#3]#4%
   {\expandafter\XINT_fadd_b\romannumeral0\xintraw {#4}{#3}{#1}{#2}}%
\def\XINT_fadd_b #1{\xint_gob_til_zero #1\XINT_fadd_Bzero 0\XINT_fadd_c #1}%
\def\XINT_fadd_Bzero #1]#2#3#4{ #3/#4[#2]}%
\def\XINT_fadd_c #1/#2[#3]#4%
{%
    \expandafter\XINT_fadd_Aa\the\numexpr #4-#3.{#3}{#4}{#1}{#2}%
}%
\def\XINT_fadd_Aa #1%
{%
    \xint_UDzerominusfork
       #1-\XINT_fadd_B
        0#1\XINT_fadd_Bb
        0-\XINT_fadd_Ba
    \krof #1%
}%
\def\XINT_fadd_B   #1.#2#3#4#5#6#7{\XINT_fadd_C {#4}{#5}{#7}{#6}[#3]}%
\def\XINT_fadd_Ba  #1.#2#3#4#5#6#7%
{%
    \expandafter\XINT_fadd_C\expandafter
        {\romannumeral0\XINT_dsx_addzeros {#1}#6;}%
    {#7}{#5}{#4}[#2]%
}%
\def\XINT_fadd_Bb -#1.#2#3#4#5#6#7%
{%
    \expandafter\XINT_fadd_C\expandafter
        {\romannumeral0\XINT_dsx_addzeros {#1}#4;}%
    {#5}{#7}{#6}[#3]%
}%
\def\XINT_fadd_iszero #1[#2]{ 0/1[0]}% ou [#2] originel?
\def\XINT_fadd_C #1#2#3%
{%
    \expandafter\XINT_fadd_D_b
    \romannumeral0\XINT_ndivrawpair{#2}{#3}{#2}{#2}{#3}{#1}%
}%
%    \end{macrocode}
%\begin{lverb}
% Basically a clone of the \XINT_irr_loop_a loop. I should modify the
% output of \XINT_ndivrawpair perhaps to be optimized for checking if
% remainder vanishes.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_fadd_D_a #1#2%
{%
    \expandafter\XINT_fadd_D_b
    \romannumeral0\XINT_ndivrawpair {#1}{#2}{#1}%
}%
\def\XINT_fadd_D_b #1#2{\XINT_fadd_D_c #2\Z}%
\def\XINT_fadd_D_c #1#2\Z
{%
    \xint_gob_til_zero #1\XINT_fadd_D_exit0\XINT_fadd_D_a {#1#2}%
}%
\def\XINT_fadd_D_exit0\XINT_fadd_D_a #1#2#3%
{%
    \expandafter\XINT_fadd_E
    \romannumeral0\xintiiquo {#3}{#2}.{#2}%
}%
\def\XINT_fadd_E #1.#2#3%
{%
    \expandafter\XINT_fadd_F
    \romannumeral0\xintiimul{#1}{#3}.{\xintiiQuo{#3}{#2}}{#1}%
}%
\def\XINT_fadd_F #1.#2#3#4#5%
{%
    \expandafter\XINT_fadd_G
    \romannumeral0\xintiiadd{\xintiiMul{#2}{#4}}{\xintiiMul{#3}{#5}}/#1%
}%
\def\XINT_fadd_G #1{%
\def\XINT_fadd_G ##1{\if0##1\expandafter\XINT_fadd_iszero\fi#1##1}%
}\XINT_fadd_G{ }%
%    \end{macrocode}
% \subsection{\csh{xintSub}}
% \changed{1.3}
%\begin{lverb}
% Since 1.3 will use least common multiple of denominators.
%\end{lverb}
%    \begin{macrocode}
\def\xintSub   {\romannumeral0\xintsub }%
\def\xintsub #1{\expandafter\XINT_fsub\romannumeral0\xintraw {#1}}%
\def\XINT_fsub #1{\xint_gob_til_zero #1\XINT_fsub_Azero 0\XINT_fsub_a #1}%
\def\XINT_fsub_Azero #1]{\xintopp }%
\def\XINT_fsub_a #1/#2[#3]#4%
   {\expandafter\XINT_fsub_b\romannumeral0\xintraw {#4}{#3}{#1}{#2}}%
\def\XINT_fsub_b #1{\xint_UDzerominusfork
                      #1-\XINT_fadd_Bzero
                       0#1\XINT_fadd_c
                       0-{\XINT_fadd_c -#1}%
                     \krof }%
%    \end{macrocode}
% \subsection{\csh{xintSum}}
%\begin{lverb}
% There was (not documented anymore since 1.09d, 2013/10/22) a macro
% \xintSumExpr, but it has been deleted at 1.2l.
%
% Empty items in the input are not accepted by this macro, but the input
% may be empty.
%
% Refactored slightly at 1.4. \XINT_Sum used in xintexpr code.
%\end{lverb}
%    \begin{macrocode}
\def\xintSum {\romannumeral0\xintsum }%
\def\xintsum #1{\expandafter\XINT_sum\romannumeral`&&@#1^}%
\def\XINT_Sum{\romannumeral0\XINT_sum}%
\def\XINT_sum#1%
{%
    \xint_gob_til_^ #1\XINT_sum_empty ^%
    \expandafter\XINT_sum_loop\romannumeral0\xintraw{#1}\xint:
}%
\def\XINT_sum_empty ^#1\xint:{ 0/1[0]}%
\def\XINT_sum_loop #1\xint:#2%
{%
    \xint_gob_til_^ #2\XINT_sum_end ^%
    \expandafter\XINT_sum_loop
    \romannumeral0\xintadd{#1}{\romannumeral0\xintraw{#2}}\xint:
}%
\def\XINT_sum_end ^#1\xintadd #2#3\xint:{ #2}%
%    \end{macrocode}
% \subsection{\csh{xintMul}}
%    \begin{macrocode}
\def\xintMul {\romannumeral0\xintmul }%
\def\xintmul #1{\expandafter\XINT_fmul\romannumeral0\xintraw {#1}.}%
\def\XINT_fmul #1{\xint_gob_til_zero #1\XINT_fmul_zero 0\XINT_fmul_a #1}%
\def\XINT_fmul_a #1[#2].#3%
   {\expandafter\XINT_fmul_b\romannumeral0\xintraw {#3}#1[#2.]}%
\def\XINT_fmul_b #1{\xint_gob_til_zero #1\XINT_fmul_zero 0\XINT_fmul_c #1}%
\def\XINT_fmul_c #1/#2[#3]#4/#5[#6.]%
{%
    \expandafter\XINT_fmul_d
    \expandafter{\the\numexpr #3+#6\expandafter}%
    \expandafter{\romannumeral0\xintiimul {#5}{#2}}%
    {\romannumeral0\xintiimul {#4}{#1}}%
}%
\def\XINT_fmul_d #1#2#3%
{%
    \expandafter \XINT_fmul_e \expandafter{#3}{#1}{#2}%
}%
\def\XINT_fmul_e #1#2{\XINT_outfrac {#2}{#1}}%
\def\XINT_fmul_zero #1.#2{ 0/1[0]}%
%    \end{macrocode}
% \subsection{\csh{xintSqr}}
%    \begin{macrocode}
\def\xintSqr {\romannumeral0\xintsqr }%
\def\xintsqr #1{\expandafter\XINT_fsqr\romannumeral0\xintraw {#1}}%
\def\XINT_fsqr #1{\xint_gob_til_zero #1\XINT_fsqr_zero 0\XINT_fsqr_a #1}%
\def\XINT_fsqr_a #1/#2[#3]%
{%
    \expandafter\XINT_fsqr_b
    \expandafter{\the\numexpr #3+#3\expandafter}%
    \expandafter{\romannumeral0\xintiisqr {#2}}%
    {\romannumeral0\xintiisqr {#1}}%
}%
\def\XINT_fsqr_b #1#2#3{\expandafter \XINT_fmul_e \expandafter{#3}{#1}{#2}}%
\def\XINT_fsqr_zero #1]{ 0/1[0]}%
%    \end{macrocode}
% \subsection{\csh{xintPow}}
% ATTENTION, it gets redefined by \xintexprnameimp. Check there.
%\begin{lverb}
% 1.2f: to be coherent with the "i" convention \xintiPow should parse also its
% exponent via \xintNum when xintfrac.sty is loaded. This was not the case so
% far. Cependant le problème est que le fait d'appliquer \xintNum rend
% impossible certains inputs qui auraient pu être gérès par \numexpr. Le
% \numexpr externe est ici pour intercepter trop grand input.
%\end{lverb}
%    \begin{macrocode}
\def\xintipow #1#2%
{%
    \expandafter\xint_pow\the\numexpr \xintNum{#2}\expandafter
    .\romannumeral0\xintnum{#1}\xint:
}%
\def\xintPow {\romannumeral0\xintpow }%
\def\xintpow #1%
{%
    \expandafter\XINT_fpow\expandafter {\romannumeral0\XINT_infrac {#1}}%
}%
\def\XINT_fpow #1#2%
{%
    \expandafter\XINT_fpow_fork\the\numexpr \xintNum{#2}\relax\Z #1%
}%
\def\XINT_fpow_fork #1#2\Z
{%
    \xint_UDzerominusfork
      #1-\XINT_fpow_zero
      0#1\XINT_fpow_neg
       0-{\XINT_fpow_pos #1}%
    \krof
    {#2}%
}%
\def\XINT_fpow_zero #1#2#3#4{ 1/1[0]}%
\def\XINT_fpow_pos #1#2#3#4#5%
{%
    \expandafter\XINT_fpow_pos_A\expandafter
    {\the\numexpr #1#2*#3\expandafter}\expandafter
    {\romannumeral0\xintiipow {#5}{#1#2}}%
    {\romannumeral0\xintiipow {#4}{#1#2}}%
}%
\def\XINT_fpow_neg #1#2#3#4%
{%
    \expandafter\XINT_fpow_pos_A\expandafter
    {\the\numexpr -#1*#2\expandafter}\expandafter
    {\romannumeral0\xintiipow {#3}{#1}}%
    {\romannumeral0\xintiipow {#4}{#1}}%
}%
\def\XINT_fpow_pos_A #1#2#3%
{%
    \expandafter\XINT_fpow_pos_B\expandafter {#3}{#1}{#2}%
}%
\def\XINT_fpow_pos_B #1#2{\XINT_outfrac {#2}{#1}}%
%    \end{macrocode}
% \subsection{\csh{xintFac}}
%\begin{lverb}
% Factorial coefficients: variant which can be chained with other
% xintfrac macros.
%\end{lverb}
%    \begin{macrocode}
\def\xintFac  {\romannumeral0\xintfac}%
\def\xintfac  #1{\expandafter\XINT_fac_fork\the\numexpr\xintNum{#1}.[0]}%
%    \end{macrocode}
% \subsection{\csh{xintBinomial}}
% \added{1.2f}
%    \begin{macrocode}
\def\xintBinomial {\romannumeral0\xintbinomial}%
\def\xintbinomial #1#2%
{%
    \expandafter\XINT_binom_pre
    \the\numexpr\xintNum{#1}\expandafter.\the\numexpr\xintNum{#2}.[0]%
}%
%    \end{macrocode}
% \subsection{\csh{xintPFactorial}}
% \added{1.2f}
%\begin{lverb}
% Partial factorial. For needs of xintexpr.sty.
%\end{lverb}
%    \begin{macrocode}
\def\xintipfactorial #1#2%
{%
    \expandafter\XINT_pfac_fork
    \the\numexpr\xintNum{#1}\expandafter.\the\numexpr\xintNum{#2}.%
}%
\def\xintPFactorial {\romannumeral0\xintpfactorial}%
\def\xintpfactorial #1#2%
{%
    \expandafter\XINT_pfac_fork
    \the\numexpr\xintNum{#1}\expandafter.\the\numexpr\xintNum{#2}.[0]%
}%
%    \end{macrocode}
% \subsection{\csh{xintPrd}}
%\begin{lverb}
% Refactored at 1.4. After some hesitation the routine still does
% not try to detect on the fly a zero item, to abort the loop. Indeed
% this would add some overhead generally (as we need normalizing the item before
% checking if it vanishes hence we must then grab things once more).
%\end{lverb}
%    \begin{macrocode}
\def\xintPrd {\romannumeral0\xintprd }%
\def\xintprd #1{\expandafter\XINT_prd\romannumeral`&&@#1^}%
\def\XINT_Prd{\romannumeral0\XINT_prd}%
\def\XINT_prd#1%
{%
    \xint_gob_til_^ #1\XINT_prd_empty ^%
    \expandafter\XINT_prd_loop\romannumeral0\xintraw{#1}\xint:
}%
\def\XINT_prd_empty ^#1\xint:{ 1/1[0]}%
\def\XINT_prd_loop #1\xint:#2%
{%
    \xint_gob_til_^ #2\XINT_prd_end ^%
    \expandafter\XINT_prd_loop
    \romannumeral0\xintmul{#1}{\romannumeral0\xintraw{#2}}\xint:
}%
\def\XINT_prd_end ^#1\xintmul #2#3\xint:{ #2}%
%    \end{macrocode}
% \subsection{\csh{xintDiv}}
%    \begin{macrocode}
\def\xintDiv {\romannumeral0\xintdiv }%
\def\xintdiv #1%
{%
    \expandafter\XINT_fdiv\expandafter {\romannumeral0\XINT_infrac {#1}}%
}%
\def\XINT_fdiv #1#2%
   {\expandafter\XINT_fdiv_A\romannumeral0\XINT_infrac {#2}#1}%
\def\XINT_fdiv_A #1#2#3#4#5#6%
{%
    \expandafter\XINT_fdiv_B
    \expandafter{\the\numexpr #4-#1\expandafter}%
    \expandafter{\romannumeral0\xintiimul {#2}{#6}}%
    {\romannumeral0\xintiimul {#3}{#5}}%
}%
\def\XINT_fdiv_B #1#2#3%
{%
    \expandafter\XINT_fdiv_C
    \expandafter{#3}{#1}{#2}%
}%
\def\XINT_fdiv_C #1#2{\XINT_outfrac {#2}{#1}}%
%    \end{macrocode}
% \subsection{\csh{xintDivFloor}}
% \added{1.1}
%\begin{lverb}
% Changed at 1.2p to not append /1[0] ending but rather output a
% big integer in strict format, like \xintDivTrunc and \xintDivRound.
%\end{lverb}
%    \begin{macrocode}
\def\xintDivFloor     {\romannumeral0\xintdivfloor }%
\def\xintdivfloor #1#2{\xintifloor{\xintDiv {#1}{#2}}}%
%    \end{macrocode}
% \subsection{\csh{xintDivTrunc}}
% \added{1.1}
%    \begin{macrocode}
\def\xintDivTrunc     {\romannumeral0\xintdivtrunc }%
\def\xintdivtrunc #1#2{\xintttrunc {\xintDiv {#1}{#2}}}%
%    \end{macrocode}
% \subsection{\csh{xintDivRound}}
%\begin{lverb}
% 1.1
%\end{lverb}
%    \begin{macrocode}
\def\xintDivRound     {\romannumeral0\xintdivround }%
\def\xintdivround #1#2{\xintiround 0{\xintDiv {#1}{#2}}}%
%    \end{macrocode}
% \subsection{\csh{xintModTrunc}}
% \added{1.1}
%\begin{lverb}
% \xintModTrunc {q1}{q2} computes q1 - q2*t(q1/q2) with t(q1/q2)
% equal to the truncated division of two fractions q1 and q2.
%
% Its former name, prior to 1.2p, was \xintMod.
%\end{lverb}
% \changed{1.3}
%\begin{lverb}
% At 1.3, uses least common multiple denominator, like \xintMod (next).
%\end{lverb}
%    \begin{macrocode}
\def\xintModTrunc {\romannumeral0\xintmodtrunc }%
\def\xintmodtrunc #1{\expandafter\XINT_modtrunc_a\romannumeral0\xintraw{#1}.}%
\def\XINT_modtrunc_a #1#2.#3%
   {\expandafter\XINT_modtrunc_b\expandafter #1\romannumeral0\xintraw{#3}#2.}%
\def\XINT_modtrunc_b #1#2% #1 de A, #2 de B.
{%
    \if0#2\xint_dothis{\XINT_modtrunc_divbyzero #1#2}\fi
    \if0#1\xint_dothis\XINT_modtrunc_aiszero\fi
    \if-#2\xint_dothis{\XINT_modtrunc_bneg #1}\fi
          \xint_orthat{\XINT_modtrunc_bpos #1#2}%
}%
\def\XINT_modtrunc_divbyzero #1#2[#3]#4.%
{%
    \XINT_legacysignalcondition{DivisionByZero}{Division by zero: #1#4/(#2[#3]).}{}{ 0/1[0]}%
}%
\def\XINT_modtrunc_aiszero #1.{ 0/1[0]}%
\def\XINT_modtrunc_bneg #1%
{%
    \xint_UDsignfork
         #1{\xintiiopp\XINT_modtrunc_pos {}}%
          -{\XINT_modtrunc_pos #1}%
    \krof
}%
\def\XINT_modtrunc_bpos #1%
{%
    \xint_UDsignfork
            #1{\xintiiopp\XINT_modtrunc_pos {}}%
             -{\XINT_modtrunc_pos #1}%
    \krof
}%
%    \end{macrocode}
%\begin{lverb}
% Attention. This crucially uses that xint's \xintiiE{x}{e} is defined
% to return x unchanged if e is negative (and x extended by e zeroes if e >=
% 0).
%\end{lverb}
%    \begin{macrocode}
\def\XINT_modtrunc_pos #1#2/#3[#4]#5/#6[#7].%
{%
    \expandafter\XINT_modtrunc_pos_a
    \the\numexpr\ifnum#7>#4 #4\else #7\fi\expandafter.%
    \romannumeral0\expandafter\XINT_mod_D_b
    \romannumeral0\XINT_ndivrawpair{#3}{#6}{#3}{#3}{#6}%
    {#1#5}{#7-#4}{#2}{#4-#7}%
}%
\def\XINT_modtrunc_pos_a #1.#2#3#4{\xintiirem {#3}{#4}/#2[#1]}%
%    \end{macrocode}
% \subsection{\csh{xintDivMod}}
% \added{1.2p}
%\begin{lverb}
% \xintDivMod{q1}{q2} outputs {floor(q1/q2)}{q1 - q2*floor(q1/q2)}.
% Attention that it relies on \xintiiE{x}{e} returning x if e < 0.
%\end{lverb}
% \changed{1.3}
%\begin{lverb}
% Modified (like \xintAdd and \xintSub) at 1.3 to use a l.c.m for final
% denominator of the "mod" part.
%\end{lverb}
%    \begin{macrocode}
\def\xintDivMod {\romannumeral0\xintdivmod }%
\def\xintdivmod #1{\expandafter\XINT_divmod_a\romannumeral0\xintraw{#1}.}%
\def\XINT_divmod_a #1#2.#3%
   {\expandafter\XINT_divmod_b\expandafter #1\romannumeral0\xintraw{#3}#2.}%
\def\XINT_divmod_b #1#2% #1 de A, #2 de B.
{%
    \if0#2\xint_dothis{\XINT_divmod_divbyzero #1#2}\fi
    \if0#1\xint_dothis\XINT_divmod_aiszero\fi
    \if-#2\xint_dothis{\XINT_divmod_bneg #1}\fi
          \xint_orthat{\XINT_divmod_bpos #1#2}%
}%
\def\XINT_divmod_divbyzero #1#2[#3]#4.%
{%
    \XINT_legacysignalcondition{DivisionByZero}{Division by zero: #1#4/(#2[#3]).}{}%
    {{0}{0/1[0]}}% à revoir...
}%
\def\XINT_divmod_aiszero #1.{{0}{0/1[0]}}%
\def\XINT_divmod_bneg #1% f // -g = (-f) // g, f % -g = - ((-f) % g)
{%
    \expandafter\XINT_divmod_bneg_finish
    \romannumeral0\xint_UDsignfork
        #1{\XINT_divmod_bpos {}}%
         -{\XINT_divmod_bpos {-#1}}%
    \krof
}%
\def\XINT_divmod_bneg_finish#1#2%
{%
    \expandafter\xint_exchangetwo_keepbraces\expandafter
    {\romannumeral0\xintiiopp#2}{#1}%
}%
\def\XINT_divmod_bpos #1#2/#3[#4]#5/#6[#7].%
{%
    \expandafter\XINT_divmod_bpos_a
    \the\numexpr\ifnum#7>#4 #4\else #7\fi\expandafter.%
    \romannumeral0\expandafter\XINT_mod_D_b
    \romannumeral0\XINT_ndivrawpair{#3}{#6}{#3}{#3}{#6}%
    {#1#5}{#7-#4}{#2}{#4-#7}%
}%
\def\XINT_divmod_bpos_a #1.#2#3#4%
{%
    \expandafter\XINT_divmod_bpos_finish
    \romannumeral0\xintiidivision{#3}{#4}{/#2[#1]}%
}%
\def\XINT_divmod_bpos_finish #1#2#3{{#1}{#2#3}}%
%    \end{macrocode}
% \subsection{\csh{xintMod}}
% \added{1.2p}
%\begin{lverb}
% \xintMod{q1}{q2} computes q1 - q2*floor(q1/q2). Attention that
% it relies on \xintiiE{x}{e} returning x if e < 0.
%
% Prior to 1.2p, that macro had the meaning now attributed to \xintModTrunc.
%\end{lverb}
% \changed{1.3}
%\begin{lverb}
% Modified (like \xintAdd and \xintSub) at 1.3 to use a l.c.m for final
% denominator.
%\end{lverb}
%    \begin{macrocode}
\def\xintMod {\romannumeral0\xintmod }%
\def\xintmod #1{\expandafter\XINT_mod_a\romannumeral0\xintraw{#1}.}%
\def\XINT_mod_a #1#2.#3%
   {\expandafter\XINT_mod_b\expandafter #1\romannumeral0\xintraw{#3}#2.}%
\def\XINT_mod_b #1#2% #1 de A, #2 de B.
{%
    \if0#2\xint_dothis{\XINT_mod_divbyzero #1#2}\fi
    \if0#1\xint_dothis\XINT_mod_aiszero\fi
    \if-#2\xint_dothis{\XINT_mod_bneg #1}\fi
          \xint_orthat{\XINT_mod_bpos #1#2}%
}%
%    \end{macrocode}
%\begin{lverb}
% Attention to not move ModTrunc code beyond that point.
%\end{lverb}
%    \begin{macrocode}
\let\XINT_mod_divbyzero\XINT_modtrunc_divbyzero
\let\XINT_mod_aiszero  \XINT_modtrunc_aiszero
\def\XINT_mod_bneg #1% f % -g = - ((-f) % g), for g > 0
{%
    \xintiiopp\xint_UDsignfork
        #1{\XINT_mod_bpos {}}%
         -{\XINT_mod_bpos {-#1}}%
    \krof
}%
\def\XINT_mod_bpos #1#2/#3[#4]#5/#6[#7].%
{%
    \expandafter\XINT_mod_bpos_a
    \the\numexpr\ifnum#7>#4 #4\else #7\fi\expandafter.%
    \romannumeral0\expandafter\XINT_mod_D_b
    \romannumeral0\XINT_ndivrawpair{#3}{#6}{#3}{#3}{#6}%
    {#1#5}{#7-#4}{#2}{#4-#7}%
}%
\def\XINT_mod_D_a #1#2%
{%
    \expandafter\XINT_mod_D_b
    \romannumeral0\XINT_ndivrawpair {#1}{#2}{#1}%
}%
\def\XINT_mod_D_b #1#2{\XINT_mod_D_c #2\Z}%
\def\XINT_mod_D_c #1#2\Z
{%
    \xint_gob_til_zero #1\XINT_mod_D_exit0\XINT_mod_D_a {#1#2}%
}%
\def\XINT_mod_D_exit0\XINT_mod_D_a #1#2#3%
{%
    \expandafter\XINT_mod_E
    \romannumeral0\xintiiquo {#3}{#2}.{#2}%
}%
\def\XINT_mod_E #1.#2#3%
{%
    \expandafter\XINT_mod_F
    \romannumeral0\xintiimul{#1}{#3}.{\xintiiQuo{#3}{#2}}{#1}%
}%
\def\XINT_mod_F #1.#2#3#4#5#6#7%
{%
    {#1}{\xintiiE{\xintiiMul{#4}{#3}}{#5}}%
        {\xintiiE{\xintiiMul{#6}{#2}}{#7}}%
}%
\def\XINT_mod_bpos_a #1.#2#3#4{\xintiirem {#3}{#4}/#2[#1]}%
%    \end{macrocode}
% \subsection{\csh{xintIsOne}}
% \added{1.09a}
%\begin{lverb}
% Could be more efficient. For fractions with big
% powers of tens, it is better to use \xintCmp{f}{1}. Restyled in 1.09i.
%\end{lverb}
%    \begin{macrocode}
\def\xintIsOne   {\romannumeral0\xintisone }%
\def\xintisone #1{\expandafter\XINT_fracisone
                  \romannumeral0\xintrawwithzeros{#1}\Z }%
\def\XINT_fracisone #1/#2\Z
    {\if0\xintiiCmp {#1}{#2}\xint_afterfi{ 1}\else\xint_afterfi{ 0}\fi}%
%    \end{macrocode}
% \subsection{\csh{xintGeq}}
%    \begin{macrocode}
\def\xintGeq {\romannumeral0\xintgeq }%
\def\xintgeq #1%
{%
    \expandafter\XINT_fgeq\expandafter {\romannumeral0\xintabs {#1}}%
}%
\def\XINT_fgeq #1#2%
{%
    \expandafter\XINT_fgeq_A \romannumeral0\xintabs {#2}#1%
}%
\def\XINT_fgeq_A #1%
{%
    \xint_gob_til_zero #1\XINT_fgeq_Zii 0%
    \XINT_fgeq_B #1%
}%
\def\XINT_fgeq_Zii 0\XINT_fgeq_B #1[#2]#3[#4]{ 1}%
\def\XINT_fgeq_B #1/#2[#3]#4#5/#6[#7]%
{%
    \xint_gob_til_zero #4\XINT_fgeq_Zi 0%
    \expandafter\XINT_fgeq_C\expandafter
    {\the\numexpr #7-#3\expandafter}\expandafter
    {\romannumeral0\xintiimul {#4#5}{#2}}%
    {\romannumeral0\xintiimul {#6}{#1}}%
}%
\def\XINT_fgeq_Zi 0#1#2#3#4#5#6#7{ 0}%
\def\XINT_fgeq_C #1#2#3%
{%
    \expandafter\XINT_fgeq_D\expandafter
    {#3}{#1}{#2}%
}%
\def\XINT_fgeq_D #1#2#3%
{%
    \expandafter\XINT_cntSgnFork\romannumeral`&&@\expandafter\XINT_cntSgn
     \the\numexpr #2+\xintLength{#3}-\xintLength{#1}\relax\xint:
    { 0}{\XINT_fgeq_E #2\Z {#3}{#1}}{ 1}%
}%
\def\XINT_fgeq_E #1%
{%
    \xint_UDsignfork
        #1\XINT_fgeq_Fd
         -{\XINT_fgeq_Fn #1}%
    \krof
}%
\def\XINT_fgeq_Fd #1\Z #2#3%
{%
    \expandafter\XINT_fgeq_Fe
    \romannumeral0\XINT_dsx_addzeros {#1}#3;\xint:#2\xint:
}%
\def\XINT_fgeq_Fe #1\xint:#2#3\xint:{\XINT_geq_plusplus #2#1\xint:#3\xint:}%
\def\XINT_fgeq_Fn #1\Z #2#3%
{%
    \expandafter\XINT_fgeq_Fo
    \romannumeral0\XINT_dsx_addzeros {#1}#2;\xint:#3\xint:
}%
\def\XINT_fgeq_Fo #1#2\xint:#3\xint:{\XINT_geq_plusplus #1#3\xint:#2\xint:}%
%    \end{macrocode}
% \subsection{\csh{xintMax}}
%    \begin{macrocode}
\def\xintMax {\romannumeral0\xintmax }%
\def\xintmax #1%
{%
    \expandafter\XINT_fmax\expandafter {\romannumeral0\xintraw {#1}}%
}%
\def\XINT_fmax #1#2%
{%
    \expandafter\XINT_fmax_A\romannumeral0\xintraw {#2}#1%
}%
\def\XINT_fmax_A #1#2/#3[#4]#5#6/#7[#8]%
{%
    \xint_UDsignsfork
      #1#5\XINT_fmax_minusminus
       -#5\XINT_fmax_firstneg
       #1-\XINT_fmax_secondneg
        --\XINT_fmax_nonneg_a
    \krof
    #1#5{#2/#3[#4]}{#6/#7[#8]}%
}%
\def\XINT_fmax_minusminus --%
   {\expandafter-\romannumeral0\XINT_fmin_nonneg_b }%
\def\XINT_fmax_firstneg #1-#2#3{ #1#2}%
\def\XINT_fmax_secondneg -#1#2#3{ #1#3}%
\def\XINT_fmax_nonneg_a #1#2#3#4%
{%
    \XINT_fmax_nonneg_b {#1#3}{#2#4}%
}%
\def\XINT_fmax_nonneg_b #1#2%
{%
    \if0\romannumeral0\XINT_fgeq_A #1#2%
          \xint_afterfi{ #1}%
    \else \xint_afterfi{ #2}%
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintMaxof}}
%\begin{lverb}
% 1.2l protects \xintMaxof against items with non terminated
% \the\numexpr expressions.
%
% 1.4 renders the macro compatible with an empty argument and it also defines
% an accessor \XINT_Maxof suitable for xintexpr usage (formerly xintexpr
% had its own macro handling comma separated values, but it changed
% internal representation at 1.4).
%
%\end{lverb}
%    \begin{macrocode}
\def\xintMaxof {\romannumeral0\xintmaxof }%
\def\xintmaxof #1{\expandafter\XINT_maxof\romannumeral`&&@#1^}%
\def\XINT_Maxof{\romannumeral0\XINT_maxof}%
\def\XINT_maxof#1%
{%
    \xint_gob_til_^ #1\XINT_maxof_empty ^%
    \expandafter\XINT_maxof_loop\romannumeral0\xintraw{#1}\xint:
}%
\def\XINT_maxof_empty ^#1\xint:{ 0/1[0]}%
\def\XINT_maxof_loop #1\xint:#2%
{%
    \xint_gob_til_^ #2\XINT_maxof_e ^%
    \expandafter\XINT_maxof_loop
    \romannumeral0\xintmax{#1}{\romannumeral0\xintraw{#2}}\xint:
}%
\def\XINT_maxof_e ^#1\xintmax #2#3\xint:{ #2}%
%    \end{macrocode}
% \subsection{\csh{xintMin}}
%    \begin{macrocode}
\def\xintMin {\romannumeral0\xintmin }%
\def\xintmin #1%
{%
    \expandafter\XINT_fmin\expandafter {\romannumeral0\xintraw {#1}}%
}%
\def\XINT_fmin #1#2%
{%
    \expandafter\XINT_fmin_A\romannumeral0\xintraw {#2}#1%
}%
\def\XINT_fmin_A #1#2/#3[#4]#5#6/#7[#8]%
{%
    \xint_UDsignsfork
      #1#5\XINT_fmin_minusminus
       -#5\XINT_fmin_firstneg
       #1-\XINT_fmin_secondneg
        --\XINT_fmin_nonneg_a
    \krof
    #1#5{#2/#3[#4]}{#6/#7[#8]}%
}%
\def\XINT_fmin_minusminus --%
   {\expandafter-\romannumeral0\XINT_fmax_nonneg_b }%
\def\XINT_fmin_firstneg #1-#2#3{ -#3}%
\def\XINT_fmin_secondneg -#1#2#3{ -#2}%
\def\XINT_fmin_nonneg_a #1#2#3#4%
{%
    \XINT_fmin_nonneg_b {#1#3}{#2#4}%
}%
\def\XINT_fmin_nonneg_b #1#2%
{%
    \if0\romannumeral0\XINT_fgeq_A #1#2%
          \xint_afterfi{ #2}%
    \else \xint_afterfi{ #1}%
    \fi
}%
%    \end{macrocode}
% \subsection{\csh{xintMinof}}
%\begin{lverb}
% 1.2l protects \xintMinof against items with non terminated
% \the\numexpr expressions.
%
% 1.4 version is compatible with an empty input (empty items are handled as zero).
%\end{lverb}
%    \begin{macrocode}
\def\xintMinof {\romannumeral0\xintminof }%
\def\xintminof #1{\expandafter\XINT_minof\romannumeral`&&@#1^}%
\def\XINT_Minof{\romannumeral0\XINT_minof}%
\def\XINT_minof#1%
{%
    \xint_gob_til_^ #1\XINT_minof_empty ^%
    \expandafter\XINT_minof_loop\romannumeral0\xintraw{#1}\xint:
}%
\def\XINT_minof_empty ^#1\xint:{ 0/1[0]}%
\def\XINT_minof_loop #1\xint:#2%
{%
    \xint_gob_til_^ #2\XINT_minof_e ^%
    \expandafter\XINT_minof_loop\romannumeral0\xintmin{#1}{\romannumeral0\xintraw{#2}}\xint:
}%
\def\XINT_minof_e ^#1\xintmin #2#3\xint:{ #2}%
%    \end{macrocode}
% \subsection{\csh{xintCmp}}
%    \begin{macrocode}
\def\xintCmp {\romannumeral0\xintcmp }%
\def\xintcmp #1%
{%
    \expandafter\XINT_fcmp\expandafter {\romannumeral0\xintraw {#1}}%
}%
\def\XINT_fcmp #1#2%
{%
    \expandafter\XINT_fcmp_A\romannumeral0\xintraw {#2}#1%
}%
\def\XINT_fcmp_A #1#2/#3[#4]#5#6/#7[#8]%
{%
    \xint_UDsignsfork
      #1#5\XINT_fcmp_minusminus
       -#5\XINT_fcmp_firstneg
       #1-\XINT_fcmp_secondneg
        --\XINT_fcmp_nonneg_a
    \krof
    #1#5{#2/#3[#4]}{#6/#7[#8]}%
}%
\def\XINT_fcmp_minusminus --#1#2{\XINT_fcmp_B #2#1}%
\def\XINT_fcmp_firstneg #1-#2#3{ -1}%
\def\XINT_fcmp_secondneg -#1#2#3{ 1}%
\def\XINT_fcmp_nonneg_a #1#2%
{%
    \xint_UDzerosfork
      #1#2\XINT_fcmp_zerozero
       0#2\XINT_fcmp_firstzero
       #10\XINT_fcmp_secondzero
        00\XINT_fcmp_pos
    \krof
    #1#2%
}%
\def\XINT_fcmp_zerozero   #1#2#3#4{ 0}%
\def\XINT_fcmp_firstzero  #1#2#3#4{ -1}%
\def\XINT_fcmp_secondzero #1#2#3#4{ 1}%
\def\XINT_fcmp_pos #1#2#3#4%
{%
    \XINT_fcmp_B #1#3#2#4%
}%
\def\XINT_fcmp_B #1/#2[#3]#4/#5[#6]%
{%
    \expandafter\XINT_fcmp_C\expandafter
    {\the\numexpr #6-#3\expandafter}\expandafter
    {\romannumeral0\xintiimul {#4}{#2}}%
    {\romannumeral0\xintiimul {#5}{#1}}%
}%
\def\XINT_fcmp_C #1#2#3%
{%
    \expandafter\XINT_fcmp_D\expandafter
    {#3}{#1}{#2}%
}%
\def\XINT_fcmp_D #1#2#3%
{%
    \expandafter\XINT_cntSgnFork\romannumeral`&&@\expandafter\XINT_cntSgn
    \the\numexpr #2+\xintLength{#3}-\xintLength{#1}\relax\xint:
    { -1}{\XINT_fcmp_E #2\Z {#3}{#1}}{ 1}%
}%
\def\XINT_fcmp_E #1%
{%
    \xint_UDsignfork
        #1\XINT_fcmp_Fd
         -{\XINT_fcmp_Fn #1}%
    \krof
}%
\def\XINT_fcmp_Fd #1\Z #2#3%
{%
    \expandafter\XINT_fcmp_Fe
    \romannumeral0\XINT_dsx_addzeros {#1}#3;\xint:#2\xint:
}%
\def\XINT_fcmp_Fe #1\xint:#2#3\xint:{\XINT_cmp_plusplus #2#1\xint:#3\xint:}%
\def\XINT_fcmp_Fn #1\Z #2#3%
{%
    \expandafter\XINT_fcmp_Fo
    \romannumeral0\XINT_dsx_addzeros {#1}#2;\xint:#3\xint:
}%
\def\XINT_fcmp_Fo #1#2\xint:#3\xint:{\XINT_cmp_plusplus #1#3\xint:#2\xint:}%
%    \end{macrocode}
% \subsection{\csh{xintAbs}}
%    \begin{macrocode}
\def\xintAbs   {\romannumeral0\xintabs }%
\def\xintabs #1{\expandafter\XINT_abs\romannumeral0\xintraw {#1}}%
%    \end{macrocode}
% \subsection{\csh{xintOpp}}
%    \begin{macrocode}
\def\xintOpp   {\romannumeral0\xintopp }%
\def\xintopp #1{\expandafter\XINT_opp\romannumeral0\xintraw {#1}}%
%    \end{macrocode}
% \subsection{\csh{xintInv}}
% \changed{1.3d}
%    \begin{macrocode}
\def\xintInv   {\romannumeral0\xintinv }%
\def\xintinv #1{\expandafter\XINT_inv\romannumeral0\xintraw {#1}}%
\def\XINT_inv #1%
{%
    \xint_UDzerominusfork
      #1-\XINT_inv_iszero
      0#1\XINT_inv_a
       0-{\XINT_inv_a {}}%
    \krof #1%
}%
\def\XINT_inv_iszero #1]%
   {\XINT_legacysignalcondition{DivisionByZero}{Inverse of zero: inv(#1]).}{}{ 0/1[0]}}%
\def\XINT_inv_a #1#2/#3[#4#5]%
{%
    \xint_UDzerominusfork
      #4-\XINT_inv_expiszero
      0#4\XINT_inv_b
       0-{\XINT_inv_b -#4}%
    \krof #5.{#1#3/#2}%
}%
\def\XINT_inv_expiszero #1.#2{ #2[0]}%
\def\XINT_inv_b #1.#2{ #2[#1]}%
%    \end{macrocode}
% \subsection{\csh{xintSgn}}
%    \begin{macrocode}
\def\xintSgn   {\romannumeral0\xintsgn }%
\def\xintsgn #1{\expandafter\XINT_sgn\romannumeral0\xintraw {#1}\xint:}%
%    \end{macrocode}
% \subsection{\csh{xintSignBit}}
% \added{1.4l}
%    \begin{macrocode}
\def\xintSignBit   {\romannumeral0\xintsignbit }%
\def\xintsignbit #1{\expandafter\XINT_signbit\romannumeral0\xintraw {#1}\xint:}%
\def\XINT_signbit #1#2\xint:
{%
    \xint_UDzerominusfork
      #1-{ 0}%
      0#1{ 1}%
       0-{ 0}%
    \krof
}%
%    \end{macrocode}
% \subsection{\csh{xintGCD}}
% \changed{1.4}
% They replace the former \xintgcdnameimp macros of the same names which
% truncated to integers their arguments. Fraction-producing |gcd()| and
% |lcm()| functions were available since |1.3d| \xintexprnameimp, with
% non-public support macros handling comma separated values.
%
% \changed{1.4d}
% Somewhat strangely \csh{xintGCD} was  formerly \csh{xintGCDof} used with only two
% arguments, as the latter directly implemented a fractionl gcd algorithm
% using \csh{xintMod} repeatedly for two arguments.
%
% Now \csh{xintGCD} contains the pairwise gcd routine and \csh{xintGCDof}
% is only a wrapper. And the pairwise gcd is reduced to integer-only
% computations to hopefully reduce fraction overhead.
%
% Each input is filtered via |\xintPIrr| and |\xintREZ| to reduce size
% of maniuplate integers in algebra.
%
% But hesitation about applying |\xintPIrr| to output, and/or |\xintREZ|.
% (as it is applied on input).
%
% But as the code is now used for frational lcm's we actually need to do
% some reduction of output else lcm's of integers will not be necessarily
% printed by |\xinteval| as integers.
% 
% Well finally I apply |\xintIrr| (but not |\xintREZ| to output).
% Hesitations here (thinking of inputs with large [n] parts, the output
% will have many zeros). So I do this only for the user macro but 
% the core routine as used by |\xintGCDof| will not do it.
%
% Also at |1.4d| the code uses |\expanded|.
%    \begin{macrocode}
\def\xintGCD {\romannumeral0\xintgcd}%
\def\xintgcd #1%
{%
    \expandafter\XINT_fgcd_in
    \romannumeral0\xintrez{\xintPIrr{\xintAbs{#1}}}\xint:
}%
\def\XINT_fgcd_in #1#2\xint:#3%
{%
    \expandafter\XINT_fgcd_out
    \romannumeral0\expandafter\XINT_fgcd_chkzeros\expandafter#1%
    \romannumeral0\xintrez{\xintPIrr{\xintAbs{#3}}}\xint:#1#2\xint:
}%
\def\XINT_fgcd_out#1[#2]{\xintirr{#1[#2]}[0]}%
\def\XINT_fgcd_chkzeros #1#2%
{%
    \xint_UDzerofork
       #1\XINT_fgcd_aiszero
       #2\XINT_fgcd_biszero
        0\XINT_fgcd_main
    \krof #2%
}%
\def\XINT_fgcd_aiszero #1\xint:#2\xint:{ #1}%
\def\XINT_fgcd_biszero #1\xint:#2\xint:{ #2}%
\def\XINT_fgcd_main #1/#2[#3]\xint:#4/#5[#6]\xint:
{%
    \expandafter\XINT_fgcd_a
      \romannumeral0\xintiigcd{#2}{#5}\xint:
      #2\xint:#5\xint:#1\xint:#4\xint:#3.#6.%
}%
\def\XINT_fgcd_a #1\xint:#2\xint:
{%
    \expandafter\XINT_fgcd_b
    \romannumeral0\xintiiquo{#2}{#1}\xint:#1\xint:#2\xint:
}%
\def\XINT_fgcd_b #1\xint:#2\xint:#3\xint:#4\xint:#5\xint:#6\xint:#7.#8.%
{%
   \expanded{%
   \xintiigcd{\xintiiE{\xintiiMul{#5}{\xintiiQuo{#4}{#2}}}{#7-#8}}%
             {\xintiiE{\xintiiMul{#6}{#1}}{#8-#7}}%
    /\xintiiMul{#1}{#4}%
    [\ifnum#7>#8 #8\else #7\fi]%
   }%
}%
%    \end{macrocode}
% \subsection{\csh{xintGCDof}}
% \changed{1.4}
% This inherits from former non public \xintexprnameimp macro called
% |\xintGCDof:csv|, which handled comma separated items.
%
% It handles fractions presented as braced items and is the support macro
% for the |gcd()| function in |\xintexpr| and |\xintfloatexpr|. The support
% macro for the |gcd()| function in |\xintiiexpr| is \csbxint{iiGCDof}, from
% \xintnameimp.
%
% An empty input is allowed but I have some hesitations on the return
% value of 1.
%
% \changed{1.4d}
% Sadly the |1.4| version had multiple problems:
% \begin{itemize}
% \item broken if first argument vanished,
% \item broken if some argument was not in strict format, for example
%       had leading chains of signs or zeros (|\xintGCDof{2}{03}|).
%       This bug originates in the fact the original macro
%       was used only in \xintexprnameimp sanitized context.
% \end{itemize}
%
% Also, output is now always an irreducible fraction (ending with |[0]|).
%    \begin{macrocode}
\def\xintGCDof {\romannumeral0\xintgcdof}%
\def\xintgcdof #1{\expandafter\XINT_fgcdof\romannumeral`&&@#1^}%
\def\XINT_GCDof{\romannumeral0\XINT_fgcdof}%
\def\XINT_fgcdof #1%
{%
    \expandafter\XINT_fgcdof_chkempty\romannumeral`&&@#1\xint:
}%
\def\XINT_fgcdof_chkempty #1%
{%
    \xint_gob_til_^#1\XINT_fgcdof_empty ^\XINT_fgcdof_in #1%
}%
\def\XINT_fgcdof_empty #1\xint:{ 1/1[0]}% hesitation, should it be infinity? O?
\def\XINT_fgcdof_in #1\xint:
{%
    \expandafter\XINT_fgcd_out
    \romannumeral0\expandafter\XINT_fgcdof_loop
    \romannumeral0\xintrez{\xintPIrr{\xintAbs{#1}}}\xint:
}%
\def\XINT_fgcdof_loop #1\xint:#2%
{%
    \expandafter\XINT_fgcdof_chkend\romannumeral`&&@#2\xint:#1\xint:\xint:
}%
\def\XINT_fgcdof_chkend #1%
{%
    \xint_gob_til_^#1\XINT_fgcdof_end ^\XINT_fgcdof_loop_pair #1%
}%
\def\XINT_fgcdof_end #1\xint:#2\xint:\xint:{ #2}%
\def\XINT_fgcdof_loop_pair #1\xint:#2%
{%
    \expandafter\XINT_fgcdof_loop
    \romannumeral0\expandafter\XINT_fgcd_chkzeros\expandafter#2%
    \romannumeral0\xintrez{\xintPIrr{\xintAbs{#1}}}\xint:#2%
}%
%    \end{macrocode}
% \subsection{\csh{xintLCM}}
% Same comments as for \csh{xintGCD}.
% Entirely redone for |1.4d|.
% Well, actually we can express it in terms of fractional gcd.
%    \begin{macrocode}
\def\xintLCM {\romannumeral0\xintlcm}%
\def\xintlcm #1%
{%
    \expandafter\XINT_flcm_in
    \romannumeral0\xintrez{\xintPIrr{\xintAbs{#1}}}\xint:
}%
\def\XINT_flcm_in #1#2\xint:#3%
{%
    \expandafter\XINT_fgcd_out
    \romannumeral0\expandafter\XINT_flcm_chkzeros\expandafter#1%
    \romannumeral0\xintrez{\xintPIrr{\xintAbs{#3}}}\xint:#1#2\xint:
}%
\def\XINT_flcm_chkzeros #1#2%
{%
    \xint_UDzerofork
       #1\XINT_flcm_zero
       #2\XINT_flcm_zero
        0\XINT_flcm_main
    \krof #2%
}%
\def\XINT_flcm_zero #1\xint:#2\xint:{ 0/1[0]}%
\def\XINT_flcm_main #1/#2[#3]\xint:#4/#5[#6]\xint:
{%
    \xintinv
    {%
      \romannumeral0\XINT_fgcd_main #2/#1[-#3]\xint:#5/#4[-#6]\xint:
    }%
}%
%    \end{macrocode}
% \subsection{\csh{xintLCMof}}
% See comments for |\xintGCDof|. \xintnameimp provides the integer only
% \csbxint{iiLCMof}.
%
% \changed{1.4d}{}
% Sadly, although a public \xintfracnameimp macro, it did not (since |1.4|)
% sanitize its arguments like other \xintfracnameimp macros.
%
%    \begin{macrocode}
\def\xintLCMof {\romannumeral0\xintlcmof}%
\def\xintlcmof #1{\expandafter\XINT_flcmof\romannumeral`&&@#1^}%
\def\XINT_LCMof{\romannumeral0\XINT_flcmof}%
\def\XINT_flcmof #1%
{%
    \expandafter\XINT_flcmof_chkempty\romannumeral`&&@#1\xint:
}%
\def\XINT_flcmof_chkempty #1%
{%
    \xint_gob_til_^#1\XINT_flcmof_empty ^\XINT_flcmof_in #1%
}%
\def\XINT_flcmof_empty #1\xint:{ 0/1[0]}% hesitation
\def\XINT_flcmof_in #1\xint:
{%
    \expandafter\XINT_fgcd_out
    \romannumeral0\expandafter\XINT_flcmof_loop
    \romannumeral0\xintrez{\xintPIrr{\xintAbs{#1}}}\xint:
}%
\def\XINT_flcmof_loop #1\xint:#2%
{%
    \expandafter\XINT_flcmof_chkend\romannumeral`&&@#2\xint:#1\xint:\xint:
}%
\def\XINT_flcmof_chkend #1%
{%
    \xint_gob_til_^#1\XINT_flcmof_end ^\XINT_flcmof_loop_pair #1%
}%
\def\XINT_flcmof_end #1\xint:#2\xint:\xint:{ #2}%
\def\XINT_flcmof_loop_pair #1\xint:#2%
{%
    \expandafter\XINT_flcmof_chkzero
    \romannumeral0\expandafter\XINT_flcm_chkzeros\expandafter#2%
    \romannumeral0\xintrez{\xintPIrr{\xintAbs{#1}}}\xint:#2%
}%
\def\XINT_flcmof_chkzero #1%
{%
    \xint_gob_til_zero#1\XINT_flcmof_zero0\XINT_flcmof_loop#1%
}%
\def\XINT_flcmof_zero#1^{ 0/1[0]}%
%    \end{macrocode}
% \subsection{Floating point macros}
%
% ATTENTION
% THE COMMENTS HERE ARE COMPLETELY OBSOLETE SINCE THE ADVANT OF CALX.
% THEY WILL BE REMOVED WHEN VERSION 2.0a1 WIL GET FINALIZED FOR RELEASE.
% DEFINITION OF \csbxint{Digits} and \csbxint{SetDigits} ARE ALREADY
% MOVED TO \calxfpnameimp. THE COMMENTED OUT PREPARATION FOR A USER
% INTERAFACE FOR THE EXTRA GUARD DIGITES USED INTERNALLY FOR xintlog AND
% xintirg WAS DELETED DURING THIS TRANSFER.
%
% For a long time the float routines dating back to releases |1.07/1.08a|
% (May-June 2013) were not modified.
%
% Since |1.2f| (March 2016) the four operations first round their arguments to
% |\xinttheDigits|-floats (or |P|-floats), not (|\xinttheDigits+2|)-floats or
% (|P+2|)-floats as was the case with earlier releases.
%
% The four operations addition, subtraction, multiplication, division have
% always produced the correct rounding of the theoretical exact value to |P|
% or |\xinttheDigits| digits when the inputs are decimal numbers with at most
% |P| digits, and arbitrary decimal exponent part.
%
% From |1.08a| to |1.2j|, |\xintFloat| (and |\XINTinFloat| which is used to
% parse inputs to other float macros) handled a fractional input |A/B| via an
% initial replacement to |A'/B'| where |A'| and |B'| were |A| and |B|
% truncated to |Q+2| digits (where asked-for precision is |Q|), and then they
% correctly rounded |A'/B'| to |Q| digits. But this meant that this rounding of
% the input could differ (by up to one unit in the last place) from the
% correct rounding of the original |A/B| to the asked-for number of
% digits (which until |1.2f| in uses as auxiliary to the macros for the basic
% operations was 2 more than the prevailing precision).
%
% Since |1.2k| all inputs are correctly rounded to the asked-for number of
% digits (this was, I think, the case in the |1.07| release -- there are no
% code comments -- but was, afaicr, not very efficiently done, and this is why
% the |1.08a| release opeted for truncation of the numerator and denominator.)
%
% Notice that in float expressions, the |/| is treated as operator, hence the
% above discussion makes a difference only for the special input form
% |qfloat(A/B)| or for an |\xintexpr A/B\relax| embedded in the float
% expression, with |A| or |B| having more digits than the prevailing float
% precision.
%
% \begin{framed}
%   Internally there is no inner representation of |P|-floats as such !!!!!
%
%   The input parser will again compute the length of the mantissa on each use
%   !!! This is obviously something that must be improved upon before
%   implementation of higher functions.
%
%   Currently, special tricks are used to quickly recognize inputs having no
%   denominators, or fractions whose numerators and denominators are not too
%   long compared to the target precision |P|, and in particular |P|-floats or
%   quotients of two such.
%
%   Another long-standing issue is that float multiplication will first
%   compute the |2P| or |2P-1| digits of the exact product, and then round it
%   to |P| digits. This is sub-optimal for large |P| particularly as the
%   multiplication algorithm is basically the schoolbook one, hence
%   \emph{worse} than quadratic in the \TeX\ implementation which has extra
%   cost of fetching long sequences of tokens.
% \end{framed}
%
%\begin{lverb}
% Changes at 1.4e (done 2021/04/15; undone 2021/04/29)
%
% Macros named \XINTinFloat<name> are not public user-level but were designed
% a long time ago for \xintfloatexpr context as a very preliminary step
% towards attempting to preserve some internal format, here A[N] type.
%
% When <name> is lowercased it means it needs a \romannumeral0 trigger
% (\XINTinfloatS keeps an uppercase S).
%
% Most were coded to check for an optional argument [D], and to use
% D=\XINTdigits in its place if absent but it turned out only \XINTinfloatpow,
% \XINTinfloatmul, \XINTinfloatadd were actually used with an optional
% argument and this happened only in macros from the very old xintseries.sty,
% so I changed all of them to not check for optional argument [D] anymore,
% keeping only some private interface for the xintseries.sty use case. Some
% required being used with [D], some still had names ending in "digits"
% indicating they would use \XINTdigits always.
%
% Indeed basically all algebra is done "exactly" and the [D] governs rules of
% float-rounding on input and output.
%
% During development of 1.4e we fleetingly experimented with letting the value
% used in place of D be \XINTdigitsx to 1.4e, i.e. \XINTdigits with guard
% digits, a situation which was motivated by the implementation of
% trigonometrical functions at high level, i.e. using \xintdeffloatfunc which
% had no mechanism to make intermediate calculations with guard digits.
% 
% Simply doing everything "as is" but with 2 guard digits proved very good
% (surprisingly efficient, even) to the trigonometrical functions. However
% using them systematically raises many issues (for example, the correct
% rounding at P digits is destroyed if we obtain it a D=P+2 then round from
% P+2 to P digits so we definitely can not do this as default, so some
% interface is needed to define intermediate functions only using such guard
% digits and keeping them in their output).
%
% Finally, an approach limited to the xinttrig.sty scope was used and I
% removed all \XINTdigitsx related matters from 1.4e. But this left some
% modifications of the interfaces of the "float" macros here which this list
% tries to document, mainly for the author's benefit.
%
%( Macros always using \XINTdigits and now not allowing [P] option
%: \XINTinFloatAdd
%: \XINTinFloatSub
%: \XINTinFloatMul
%: \XINTinFloatSqr
%: \XINTinFloatDiv
%: \XINTinFloatPow
%: \XINTinFloatPower
%: \XINTinFloatPFactorial
%: \XINTinFloatBinomial
%:
%: Macros which already did not allow [P] option prior to 1.4e refactoring
%: \XINTinFloatFrac (renamed from \XINTinFloatFracdigits)
%:
%: Macros requiring a [P]. Some of the "_wopt" named macros are&
%  renamings of macros formerly requiring [P].
%: \XINTinFloat
%: \XINTinFloatS
%: \XINTFloatiLogTen
%: \XINTinRandomFloatS (this one has only the [P] mandatory argument)
%: \XINTinFloatFac
%: \XINTinFloatSqrt
%: \XINTinFloatAdd_wopt, \XINTinfloatadd_wopt
%: \XINTinFloatSub_wopt, \XINTinfloatsub_wopt
%: \XINTinFloatMul_wopt, \XINTinfloatmul_wopt
%: \XINTinFloatSqr_wopt
%: \XINTinfloatpow_wopt (not FloatPow)
%: \XINTinFloatDiv_wopt
%:
%: Specially named macros indicating usage of \XINTdigits
%: \XINTinFloatdigits
%: \XINTinFloatSdigits
%: \XINTFloatiLogTendigits
%: \XINTinRandomFloatSdigits
%: \XINTinFloatFacdigits
%: \XINTinFloatSqrtdigits
%)
%\end{lverb}
%
%
% \subsection{\csh{xintFloat}, \csh{xintFloatZero}}
%\begin{lverb}
% 1.2f and 1.2g brought some refactoring which resulted in faster treatment of
% decimal inputs. 1.2i dropped use of some old routines dating back to pre 1.2
% era in favor of more modern \xintDSRr for rounding. Then 1.2k improves
% again the handling of denominators B with few digits.
%
% But the main change with 1.2k is a complete rewrite of the B>1 case in
% order to achieve again correct rounding in all cases.
%
% The original version from 1.07 (May 2013) computed the exact rounding
% to P digits for all inputs. But from 1.08 on (June 2013), the macro handled
% A/B input by first truncating both A and B to at most P+2 digits. This meant
% that decimal input (arbitrarily long, with scientific part) was correctly
% rounded, but in case of fractional input there could be up to 0.6 unit in
% the last place difference of the produced rounding to the input, hence the
% output could differ from the correct rounding.
%
% Example with 16 digits (the default): \xintFloat {1/17597472569900621233}$newline
% with xintfrac 1.07: 5.682634230727187e-20$newline
% with xintfrac 1.08b--1.2j: 5.682634230727188e-20$newline
% with xintfrac 1.2k: 5.682634230727187e-20$newline
% The exact value is 5.682634230727187499924124...e-20, showing that 1.07 and
% 1.2k
% produce the correct rounding.
%
% Currently the code ends in a more costly branch in about 1 case among 500,
% where it does some extra operations (a multiplication in particular). There
% is a free parameter delta (here set at 4), I have yet to make some numerical
% explorations, to see if it could be favorable to set it to a higher value
% (with delta=5, there is only 1 exceptional case in 5000, etc...).
%
% I have always hesitated about the policy of printing 10.00...0 in case of
% rounding upwards to the next power of ten. Already since 1.2f \XINTinFloat
% always produced a mantissa with exactly P digits (except for the zero
% value). Starting with 1.2k, \xintFloat drops this habit of printing
% 10.00..0 in such cases. Side note: the rounding-up detection worked when the
% input A/B was with numerator A and denominator B having each less than P+2
% digits, or with B=1, else, it could happen that the output was a power of
% ten but not detected to be a rounding up of the original fraction. The value
% was ok, but printed 1.0...0eN with P-1 zeroes, not 10.0...0e(N-1).
%
% I decided it was not worth the effort to enhance the algorithm to detect
% with 100$% fiability all cases of rounding up to next
% power of ten, hence 1.2k dropped this.
%
% To avoid duplication of code, and any extra burden on \XINTinFloat, which is
% the macro used internally by the float macros for parsing their inputs, we
% simply make now \xintFloat a wrapper of \XINTinFloat.
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatZero{0.0e0}% 1.4k breaking change.  Replaces hard-coded 0.e0
\def\xintFloat   {\romannumeral0\xintfloat }%
\def\xintfloat #1{\XINT_float_chkopt #1\xint:}%
\def\XINT_float_chkopt #1%
{%
    \ifx [#1\expandafter\XINT_float_opt
       \else\expandafter\XINT_float_noopt
    \fi  #1%
}%
\def\XINT_float_noopt #1\xint:%
{%
    \expandafter\XINT_float_post
    \romannumeral0\XINTinfloat[\XINTdigits]{#1}\XINTdigits.%
}%
\def\XINT_float_opt [\xint:
{%
    \expandafter\XINT_float_opt_a\the\numexpr
}%
\def\XINT_float_opt_a #1]#2%
{%
    \expandafter\XINT_float_post
    \romannumeral0\XINTinfloat[#1]{#2}#1.%
}%
\def\XINT_float_post #1%
{%
    \xint_UDzerominusfork
      #1-\XINT_float_zero
       0#1\XINT_float_neg
       0-\XINT_float_pos
    \krof #1%
}%[
\def\XINT_float_zero #1]#2.{\expanded{ \xintFloatZero}}%
\def\XINT_float_neg-{\expandafter-\romannumeral0\XINT_float_pos}%
\def\XINT_float_pos #1#2[#3]#4.%
{%
    \expandafter\XINT_float_pos_done\the\numexpr#3+#4-\xint_c_i.#1.#2;%
}%
\def\XINT_float_pos_done #1.#2;{ #2e#1}%
%    \end{macrocode}
% \subsection{\csh{xintFloatBraced}}
% \added{1.4l}
%\begin{lverb}
% Je ne le fais pas comme un wrapper au-dessus de \xintFloat
% car c'est pénible avec argument optionnel donc finalemnt
% on est obligé de rajouter overhead comme ici.
%
%( Hésitation si on obéit à \xintFloatZero ou pas. Finalement non.
%: Hésitation si on renvoie avec séparateur décimal ou pas.
%: Hésitation si on met l'exposant scientifique en premier.
%: Hésitation si on sépare le signe pour le mettre en premier.
%: Hésitation si on renvoie un exposant pour mantisse normalisée&
%  ou pas normalisée.
%)
%
% Finalement je décide {signe}{exposant}{mantisse sans point décimal}.
% Avec en fait 0 ou 1 pour signe (mais ce sign bit mais ça n'a pas grand
% sens en décimal...). Non finalement mantisse avec point décimal.
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatBraced{\romannumeral0\xintfloatbraced }%
\def\xintfloatbraced#1{\XINT_floatbr_chkopt #1\xint:}%
\def\XINT_floatbr_chkopt #1%
{%
    \ifx [#1\expandafter\XINT_floatbr_opt
       \else\expandafter\XINT_floatbr_noopt
    \fi  #1%
}%
\def\XINT_floatbr_noopt #1\xint:%
{%
    \expandafter\XINT_floatbr_post
    \romannumeral0\XINTinfloat[\XINTdigits]{#1}\XINTdigits.%
}%
\def\XINT_floatbr_opt [\xint:
{%
    \expandafter\XINT_floatbr_opt_a\the\numexpr
}%
\def\XINT_floatbr_opt_a #1]#2%
{%
    \expandafter\XINT_floatbr_post
    \romannumeral0\XINTinfloat[#1]{#2}#1.%
}%
\def\XINT_floatbr_post #1%
{%
    \xint_UDzerominusfork
      #1-\XINT_floatbr_zero
       0#1\XINT_floatbr_neg
       0-\XINT_floatbr_pos
    \krof #1%
}%
%    \end{macrocode}
%\begin{lverb}
% Hésitation à faire
%( \def\XINT_floatbr_zero #1]#2.{\expandafter\XINT_floatbr_zero_a\xintFloatZero e0e\relax}%
%: \def\XINT_floatbr_zero_a#1e#2e#3\relax{{#1}{#2}}%
%)
% Finalement non. Et même je décide de renvoyer autant de zéros que P.
% De plus depuis j'ai opté pour {sign bit}{exposant}{mantisse}
% Hésitation si mantisse avec ou sans le séparateur décimal.
% Est-ce que je devrais mettre plutôt -0+ au début?
%\end{lverb}
%    \begin{macrocode}
\def\XINT_floatbr_zero #1]#2.{\expanded{{0}{0}{0.\xintReplicate{#2-\xint_c_i}0}}}%
\def\XINT_floatbr_neg-{\expandafter\XINT_floatbr_neg_a\romannumeral0\XINT_floatbr_pos}%
\def\XINT_floatbr_neg_a#1{{1}}%
\def\XINT_floatbr_pos #1#2[#3]#4.%
{%
    \expanded{{0}{\the\numexpr#3+#4-\xint_c_i}}{#1.#2}%
}%
%    \end{macrocode}
% \subsection{\csh{XINTinFloat}, \csh{XINTinFloatS}}
%\begin{lverb}
% This routine is like \xintFloat but produces an output of the shape A[N]
% which is then parsed faster as input to other float macros. 
% Float operations in \xintfloatexpr...\relax use internally this format.
%
% It must be used in form \XINTinFloat[P]{f}: the optional [P] is
% mandatory.
%
% Since 1.2f, the mantissa always has exactly P digits even in case of
% rounding up to next power of ten. This simplifies other routines.
%
% (but the zero value must always be checked for, as it outputs 0[0])
%
% 1.2g added a variant \XINTinFloatS which, in case of decimal input with less
% than the asked for precision P will not add extra zeros to the mantissa. For
% example it may output 2[0] even if P=500, rather than the canonical
% representation 200...000[-499]. This is how \xintFloatMul and \xintFloatDiv
% parse their inputs, which speeds-up follow-up processing. But \xintFloatAdd
% and \xintFloatSub still use \XINTinFloat for parsing their inputs; anyway
% this will have to be changed again when inner structure will carry upfront
% at least the length of mantissa as data.
%
% Each time \XINTinFloat is called it at least computes a length. Naturally if
% we had some format for floats that would be dispensed of...$newline
%  something like
% <letterP><length of mantissa>.mantissa.exponent, etc... not yet.
%
% Since 1.2k, \XINTinFloat always correctly rounds its argument, even if it
% is a fraction with very big numerator and denominator. See the discussion of
% \xintFloat. 
%\end{lverb}
%    \begin{macrocode}
\def\XINTinFloat {\romannumeral0\XINTinfloat }%
\def\XINTinfloat 
   {\expandafter\XINT_infloat_clean\romannumeral0\XINT_infloat}%
%    \end{macrocode}
%\begin{lverb}
% Attention que ici le fait que l'on grabbe #1 est important car il
% pourrait y avoir un zéro (en particulier dans le cas où input est nul).
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_clean #1%
   {\if #1!\xint_dothis\XINT_infloat_clean_a\fi\xint_orthat{ }#1}%
%    \end{macrocode}
%\begin{lverb}
% Ici on ajoute les zeros pour faire exactement avec P chiffres.
% Car le #1 = P - L avec L la longueur de #2, (ou plutôt de abs(#2),
% car ici le #2 peut avoir un signe) et L < P
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_clean_a !#1.#2[#3]%
{%
    \expandafter\XINT_infloat_done
    \the\numexpr #3-#1\expandafter.%
    \romannumeral0\XINT_dsx_addzeros {#1}#2;;%
}%
\def\XINT_infloat_done #1.#2;{ #2[#1]}%
%    \end{macrocode}
%\begin{lverb}
% variant which allows output with shorter mantissas.
%\end{lverb}
%    \begin{macrocode}
\def\XINTinFloatS {\romannumeral0\XINTinfloatS}%
\def\XINTinfloatS 
   {\expandafter\XINT_infloatS_clean\romannumeral0\XINT_infloat}%
\def\XINT_infloatS_clean #1%
   {\if #1!\xint_dothis\XINT_infloatS_clean_a\fi\xint_orthat{ }#1}%
\def\XINT_infloatS_clean_a !#1.{ }%
%    \end{macrocode}
%\begin{lverb}
% début de la routine proprement dite,
% l'argument optionnel est obligatoire.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat [#1]%#2%
{%
    \expandafter\XINT_infloat_a\the\numexpr #1\expandafter.%
    \romannumeral0\XINT_infrac% {#2}%
}%
%    \end{macrocode}
%\begin{lverb}
%  #1=P, #2=n, #3=A, #4=B.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_a #1.#2#3#4%
{%
%    \end{macrocode}
%\begin{lverb}
% micro boost au lieu d'utiliser \XINT_isOne{#4}, mais pas bon style.
%\end{lverb}
%    \begin{macrocode}
    \if1\XINT_is_One#4XY%
      \expandafter\XINT_infloat_sp
    \else\expandafter\XINT_infloat_fork
    \fi #3.{#1}{#2}{#4}%
}%
%    \end{macrocode}
%\begin{lverb}
% Special quick treatment of B=1 case (1.2f then again 1.2g.)$newline
% maintenant: A.{P}{N}{1}
% Il est possible que A soit nul.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_sp #1%
{%
    \xint_UDzerominusfork
     #1-\XINT_infloat_spzero
     0#1\XINT_infloat_spneg
      0-\XINT_infloat_sppos
    \krof #1%
}%
%    \end{macrocode}
%\begin{lverb}
% Attention surtout pas 0/1[0] ici.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_spzero 0.#1#2#3{ 0[0]}%
\def\XINT_infloat_spneg-% 
    {\expandafter\XINT_infloat_spnegend\romannumeral0\XINT_infloat_sppos}%
\def\XINT_infloat_spnegend #1%
    {\if#1!\expandafter\XINT_infloat_spneg_needzeros\fi -#1}%
\def\XINT_infloat_spneg_needzeros -!#1.{!#1.-}%
%    \end{macrocode}
%\begin{lverb}
% in:  A.{P}{N}{1}$newline
% out: P-L.A.P.N.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_sppos #1.#2#3#4%
{%
    \expandafter\XINT_infloat_sp_b\the\numexpr#2-\xintLength{#1}.#1.#2.#3.%
}%
%    \end{macrocode}
%\begin{lverb}
% #1= P-L. Si c'est positif ou nul il faut retrancher #1 à l'exposant, et
% ajouter autant de zéros. On regarde premier token.
% P-L.A.P.N.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_sp_b #1%
{%
    \xint_UDzerominusfork
     #1-\XINT_infloat_sp_quick
     0#1\XINT_infloat_sp_c
      0-\XINT_infloat_sp_needzeros
    \krof #1%
}%
%    \end{macrocode}
%\begin{lverb}
% Ici P=L. Le cas usuel dans \xintfloatexpr.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_sp_quick 0.#1.#2.#3.{ #1[#3]}%
%    \end{macrocode}
%\begin{lverb}
% Ici #1=P-L est >0. L'exposant sera N-(P-L). #2=A. #3=P. #4=N.$newline
% 18 mars 2016. En fait dans certains contextes il est sous-optimal d'ajouter les
% zéros. Par exemple quand c'est appelé par la multiplication ou la division,
% c'est idiot de convertir 2 en 200000...00000[-499].
% Donc je redéfinis addzeros en needzeroes. Si on appelle sous la forme
% \XINTinFloatS, on ne fait pas l'addition de zeros.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_sp_needzeros #1.#2.#3.#4.{!#1.#2[#4]}%
%    \end{macrocode}
%\begin{lverb}
% L-P=#1.A=#2#3.P=#4.N=#5.$newline
% Ici P<L. Il va falloir arrondir. Attention si on va à la puissance de 10
% suivante. En #1 on a L-P qui est >0. L'exposant final sera N+L-P, 
% sauf dans le cas spécial, il sera alors N+L-P+1. L'ajustement final
% est fait par \XINT_infloat_Y.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_sp_c -#1.#2#3.#4.#5.%
{%
    \expandafter\XINT_infloat_Y
    \the\numexpr #5+#1\expandafter.%
    \romannumeral0\expandafter\XINT_infloat_sp_round
    \romannumeral0\XINT_split_fromleft
    (\xint_c_i+#4).#2#3\xint_bye2345678\xint_bye..#2%
}%
\def\XINT_infloat_sp_round #1.#2.%
{%
    \XINT_dsrr#1\xint_bye\xint_Bye3456789\xint_bye/\xint_c_x\relax.%
}%
%    \end{macrocode}
%\begin{lverb}
% General branch for A/B with B>1 inputs. It achieves correct rounding
% always since 1.2k (done January 2, 2017.) This branch is never taken for A=0
% because \XINT_infrac will have returned B=1 then.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_fork #1%
{%
    \xint_UDsignfork
     #1\XINT_infloat_J
     -\XINT_infloat_K
    \krof #1%
}%
\def\XINT_infloat_J-{\expandafter-\romannumeral0\XINT_infloat_K }%
%    \end{macrocode}
%\begin{lverb}
% A.{P}{n}{B} avec B>1.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_K #1.#2%
{%
    \expandafter\XINT_infloat_L
    \the\numexpr\xintLength{#1}\expandafter.\the\numexpr #2+\xint_c_iv.{#1}{#2}%
}%
%    \end{macrocode}
%\begin{lverb}
% |A|.P+4.{A}{P}{n}{B}. We check if A already has length
% <= P+4.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_L #1.#2.%
{%
    \ifnum #1>#2
      \expandafter\XINT_infloat_Ma
    \else
      \expandafter\XINT_infloat_Mb
    \fi #1.#2.%
}%
%    \end{macrocode}
%\begin{lverb}
% |A|.P+4.{A}{P}{n}{B}. We will keep only the first P+4
% digits of A, denoted A'' in what follows.
% 
% output: u=-0.A''.junk.P+4.|A|.{A}{P}{n}{B}
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_Ma #1.#2.#3%
{%
    \expandafter\XINT_infloat_MtoN\expandafter-\expandafter0\expandafter.%
    \romannumeral0\XINT_split_fromleft#2.#3\xint_bye2345678\xint_bye..%
    #2.#1.{#3}%
}%
%    \end{macrocode}
%\begin{lverb}
% |A|.P+4.{A}{P}{n}{B}.$newline
% Here A is short. We set u = P+4-|A|, and A''=A (A' = 10^u A)
%
% output: u.A''..P+4.|A|.{A}{P}{n}{B}
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_Mb #1.#2.#3%
{%
    \expandafter\XINT_infloat_MtoN\the\numexpr#2-#1.%
    #3..#2.#1.{#3}%
}%
%    \end{macrocode}
%\begin{lverb}
% input u.A''.junk.P+4.|A|.{A}{P}{n}{B}$newline
% output |B|.P+4.{B}u.A''.P.|A|.n.{A}{B}
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_MtoN #1.#2.#3.#4.#5.#6#7#8#9%
{%
   \expandafter\XINT_infloat_N
   \the\numexpr\xintLength{#9}.#4.{#9}#1.#2.#7.#5.#8.{#6}{#9}%
}%
\def\XINT_infloat_N #1.#2.%
{%
    \ifnum #1>#2
      \expandafter\XINT_infloat_Oa
    \else
      \expandafter\XINT_infloat_Ob
    \fi #1.#2.%
}%
%    \end{macrocode}
%\begin{lverb}
% input |B|.P+4.{B}u.A''.P.|A|.n.{A}{B}$newline
% output v=-0.B''.junk.|B|.u.A''.P.|A|.n.{A}{B}
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_Oa #1.#2.#3%
{%
    \expandafter\XINT_infloat_P\expandafter-\expandafter0\expandafter.%
    \romannumeral0\XINT_split_fromleft#2.#3\xint_bye2345678\xint_bye..%
    #1.%
}%
%    \end{macrocode}
%\begin{lverb}
% output v=P+4-|B|>=0.B''.junk.|B|.u.A''.P.|A|.n.{A}{B}
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_Ob #1.#2.#3%
{%
    \expandafter\XINT_infloat_P\the\numexpr#2-#1.#3..#1.%
}%
%    \end{macrocode}
%\begin{lverb}
% input v.B''.junk.|B|.u.A''.P.|A|.n.{A}{B}$newline
% output Q1.P.|B|.|A|.n.{A}{B}$newline
% Q1 = division euclidienne de  A''.10^{u-v+P+3} par B''.
%
% Special detection of cases with A and B both having length at most P+4: this
% will happen when called from \xintFloatDiv as A and B (produced then via
% \XINTinFloatS) will have at most P digits. We then only need integer division
% with P+1 extra zeros, not P+3.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_P #1#2.#3.#4.#5.#6#7.#8.#9.%
{%
   \csname XINT_infloat_Q\if-#1\else\if-#6\else q\fi\fi\expandafter\endcsname
   \romannumeral0\xintiiquo
   {\romannumeral0\XINT_dsx_addzerosnofuss
      {#6#7-#1#2+#9+\xint_c_iii\if-#1\else\if-#6\else-\xint_c_ii\fi\fi}#8;}%
   {#3}.#9.#5.%
}%
%    \end{macrocode}
%\begin{lverb}
% «quick» branch.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_Qq #1.#2.%
{%
    \expandafter\XINT_infloat_Rq
    \romannumeral0\XINT_split_fromleft#2.#1\xint_bye2345678\xint_bye..#2.%
}%
\def\XINT_infloat_Rq #1.#2#3.%
{%
    \ifnum#2<\xint_c_v
         \expandafter\XINT_infloat_SEq
    \else\expandafter\XINT_infloat_SUp
    \fi
    {\if.#3.\xint_c_\else\xint_c_i\fi}#1.%
}%
%    \end{macrocode}
%\begin{lverb}
% standard branch which will have to handle undecided rounding, if too
% close to a mid-value.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_Q #1.#2.%
{%
    \expandafter\XINT_infloat_R
    \romannumeral0\XINT_split_fromleft#2.#1\xint_bye2345678\xint_bye..#2.%
}%
\def\XINT_infloat_R #1.#2#3#4#5.%
{%
    \if.#5.\expandafter\XINT_infloat_Sa\else\expandafter\XINT_infloat_Sb\fi
    #2#3#4#5.#1.%
}%
%    \end{macrocode}
%\begin{lverb}
% trailing digits.Q.P.|B|.|A|.n.{A}{B}$newline
% #1=trailing digits (they may have leading zeros.)
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_Sa #1.%
{%
    \ifnum#1>500 \xint_dothis\XINT_infloat_SUp\fi
    \ifnum#1<499 \xint_dothis\XINT_infloat_SEq\fi
    \xint_orthat\XINT_infloat_X\xint_c_
}%
\def\XINT_infloat_Sb #1.%
{%
    \ifnum#1>5009 \xint_dothis\XINT_infloat_SUp\fi
    \ifnum#1<4990 \xint_dothis\XINT_infloat_SEq\fi
    \xint_orthat\XINT_infloat_X\xint_c_i
}%
%    \end{macrocode}
%\begin{lverb}
% epsilon #2=Q.#3=P.#4=|B|.#5=|A|.#6=n.{A}{B}$newline
% exposant final est n+|A|-|B|-P+epsilon
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_SEq #1#2.#3.#4.#5.#6.#7#8%
{%
    \expandafter\XINT_infloat_SY
    \the\numexpr #6+#5-#4-#3+#1.#2.%
}%
\def\XINT_infloat_SY #1.#2.{ #2[#1]}%
%    \end{macrocode}
%\begin{lverb}
% initial digit #2 put aside to check for case of rounding up to
% next power of ten, which will need adjustment of mantissa and
% exponent.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_SUp #1#2#3.#4.#5.#6.#7.#8#9%
{%
    \expandafter\XINT_infloat_Y
    \the\numexpr#7+#6-#5-#4+#1\expandafter.%
    \romannumeral0\xintinc{#2#3}.#2%
}%
%    \end{macrocode}
%\begin{lverb}
% epsilon Q.P.|B|.|A|.n.{A}{B}$newline
%
% \xintDSH{-x}{U} multiplies U by 10^x. When x is negative, this means
% it truncates (i.e. it drops the last -x digits).
%
% We don't try to optimize too much macro calls here, the odds are 2 per 1000
% for this branch to be taken. Perhaps in future I will use higher free
% parameter d, which currently is set at 4.
%
% #1=epsilon, #2#3=Q, #4=P, #5=|B|, #6=|A|, #7=n, #8=A, #9=B
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_X #1#2#3.#4.#5.#6.#7.#8#9%
{%
   \expandafter\XINT_infloat_Y
   \the\numexpr #7+#6-#5-#4+#1\expandafter.%
   \romannumeral`&&@\romannumeral0\xintiiiflt
     {\xintDSH{#6-#5-#4+#1}{\xintDouble{#8}}}%
     {\xintiiMul{\xintInc{\xintDouble{#2#3}}}{#9}}%
   \xint_firstofone
   \xintinc{#2#3}.#2%
}%
%    \end{macrocode}
%\begin{lverb}
% check for rounding up to next power of ten.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_Y #1{%
\def\XINT_infloat_Y ##1.##2##3.##4%
{%
   \if##49\if##21\expandafter\expandafter\expandafter\XINT_infloat_Z\fi\fi
   #1##2##3[##1]%
}}\XINT_infloat_Y{ }%
%    \end{macrocode}
%\begin{lverb}
% #1=1, #2=0.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_infloat_Z #1#2#3[#4]%
{%
    \expandafter\XINT_infloat_ZZ\the\numexpr#4+\xint_c_i.#3.%
}%
\def\XINT_infloat_ZZ #1.#2.{ 1#2[#1]}% 
%    \end{macrocode}
% \subsection{\csh{XINTFloatiLogTen}}
% \added{1.3e}
%\begin{lverb}
% Le comportement pour un input nul est non
% encore finalisé. Il changera lorsque NaN, +Inf, -Inf existeront.
%
% The optional argument [#1] is in fact mandatory and #1 is
% not pre-expanded in a \numexpr.
%
% The return value here 2^31-2^15 is highly undecided.
%\end{lverb}
%    \begin{macrocode}
\def\XINTFloatiLogTen {\the\numexpr\XINTfloatilogten}%
\def\XINTfloatilogten [#1]#2%
    {\expandafter\XINT_floatilogten\romannumeral0\XINT_infloat[#1]{#2}#1.}%
\def\XINTFloatiLogTendigits{\the\numexpr\XINTfloatilogten[\XINTdigits]}%
\def\XINT_floatilogten #1{%
    \if #10\xint_dothis\XINT_floatilogten_z\fi
    \if #1!\xint_dothis\XINT_floatilogten_a\fi
    \xint_orthat\XINT_floatilogten_b #1%
}%
\def\XINT_floatilogten_z 0[0]#1.{-"7FFF8000\relax}%
\def\XINT_floatilogten_a !#1.#2[#3]#4.{#3-#1+#4-\xint_c_i\relax}%
\def\XINT_floatilogten_b #1[#2]#3.{#2+#3-\xint_c_i\relax}%
%    \end{macrocode}
% \subsection{\csh{xintPFloat}}
% \added{1.1}
% \changed{1.4e}
%\begin{lverb}
%
% xint has not yet incorporated a general formatter as it was
% not a priority during development and external solutions exist
% (I did not check for a while but I think LaTeX3 has implemented
%  a general formatter in the printf or Python ".format" spirit)
%
% But when one starts using really the package, especially in
% an interactive way (xintsession 2021), one needs the default
% output to be as nice as possible.
%
% The \xintPFloat macro was added at 1.1 as a "prettifying printer"
% for floats, basically influenced by Maple.
%
%( The rules were:
%: 0. The input is float-rounded to either Digits or the optional argument
%: 1. zero is printed as "0."
%: 2. x.yz...eK is printed "as is" if K>5 or K<-5.
%: 3. if -5<=K<=5, fixed point decimal notation is used.
%: 4. in cases 2. and 3., no trimming of trailing zeroes.
%)
%
% 1.4b added \xintPFloatE to customize whether to use
% e or E.
%
%
% 1.4e, with some hesitation, decided to make a breaking change and to modify
% the behaviour.
%
%( The new rules:
%: 0. The input is float-rounded to either Digits or the optional argument
%: 1. zero is printed as 0.0
%: 2. x.yz...eK is printed in decimal fixed point if -4<=K<=+5&
%     (notice the change, formerly K=-5 used fixed point notation in output)&
%     else it is printed in scientific notation
%: 3. trailing zeros of the mantissa are trimmed always
%: 4. in case of decimal fixed point for an integer, there&
%     is a trailing ".0"
%: 5. in case of scientific notation with a one-digit trimmed mantissa&
%     there is an added ".0" too
%)
%
% Further, \xintPFloatE can now also be redefined as a macro with a parameter
% delimited by a dot, with the dot also present as final token in its output.
% It would then grab the scientific exponent K as explicit digit
% possibly prefixed by a minus sign.  The macro must be f-expandable.
%
% The macro \xintPFloat_wopt is only there for a micro gain as the package
% does
%
% \let\xintfloatexprPrintOne\xintPFloat_wopt
%
% as it knows it will
% be used always with a [P] argument in the xintexpr.sty context.
%\end{lverb}
% \changed{1.4k}
%\begin{lverb}
% Addition of customization via \xintPFloatZero, \xintPFloatLengthOneSuffix,
% \xintPFloatNoSciEmax, \xintPFloatNoSciEmin which replace formerly
% hard-coded behaviour.
%
% Breaking change to not add ".0" suffix to integers (when scientific
% notation dropped) or to one-digit mantissas.
%
% In my own practice I started being annoyed by the automatic trimming of
% zeros added at 1.4e.
%
% This change had been influenced by using Python in interactive mode
% which since 3.1 prints floats (in decimal conversion) choosing the
% shortest string.  In particular it trims trailing zeros, and it drops
% the scientific notation in favor of decimal notation for something
% like -4<= K <= 15, with K the scientific exponent.
%
% At 1.4e I was still influenced by my experience with Maple and
% did for -4 <= K <= 5.  Not very well thought anyhow (one may wish
% to use decimal notation when sending things to PostScript, so perhaps
% I should have kept with -5).
%
% But, the main problem is with trimming trailing zeros: although in
% interactive sessions, this has its logic, as soon as one does tables
% with numbers, dropping a trailing zero upsets alignments or creates
% visual holes compared to other lines and this is in the end very
% annoying.
%
% After much hesitation, I decided to slightly modifify only the former
% behaviour: trimming only if that removes at least 4 zeros.  I had also
% experimented with another condition: trimmed mantissas should be at
% most 6 digits (for example) wide, else use no trimming.
%
% Threshold customizable via \xintPFloatMinTrimmed.
%\end{lverb}
% \changed[2022/05/22]{1.4l}
%\begin{lverb}
% The 1.4k check for canceling the trimming of trailing zeros
% took over priority over the later check for being an integer when
% decimal fixed point notation was used (or being only with a one-digit
% trimmed mantissa).  In particular if user set \xintPFloatMinTrimmed to
% the value of Digits (or P) to avoid trimming it also prevented
% recognition of some integers (but not all).  Fixed at 1.4l
%\end{lverb}
%
% \changed{2.0a1}
%\begin{lverb}
% The formatting core (\XINT_pfloat_fork to \XINT_pfloat_Ps, with
% \XINT_pfloat_a_fork) and the defaults of \xintPFloatE, \xintPFloatNoSciEmax,
% \xintPFloatNoSciEmin, \xintPFloatIntSuffix, \xintPFloatLengthOneSuffix,
% \xintPFloatZero, \xintPFloatMinTrimmed moved verbatim to calxfp.sty at
% 2.0a1.
%\end{lverb}
%    \begin{macrocode}
\def\xintPFloat {\romannumeral0\xintpfloat }%
\def\xintpfloat #1{\XINT_pfloat_chkopt #1\xint:}%
\def\xintPFloat_wopt[#1]#2%
{%
    \romannumeral0\expandafter\XINT_pfloat
    \romannumeral0\XINTinfloatS[#1]{#2}#1.%
}%
\def\XINT_pfloat_chkopt #1%
{%
    \ifx [#1\expandafter\XINT_pfloat_opt
       \else\expandafter\XINT_pfloat_noopt
    \fi  #1%
}%
\def\XINT_pfloat_noopt #1\xint:%
{%
    \expandafter\XINT_pfloat\romannumeral0\XINTinfloatS[\XINTdigits]{#1}%
    \XINTdigits.%
}%
\def\XINT_pfloat_opt [\xint:{\expandafter\XINT_pfloat_opt_a\the\numexpr}%
\def\XINT_pfloat_opt_a #1]#2%
{%
    \expandafter\XINT_pfloat\romannumeral0\XINTinfloatS[#1]{#2}%
    #1.%
}%
\def\XINT_pfloat#1]%
{%
    \expandafter\XINT_pfloat_fork\romannumeral0\xintrez{#1]}%
}%
%    \end{macrocode}
% \subsection{\csh{xintFloatToDecimal}}
% \added{1.4k}
%    \begin{macrocode}
\def\xintFloatToDecimal {\romannumeral0\xintfloattodecimal }%
\def\xintfloattodecimal #1{\XINT_floattodec_chkopt #1\xint:}%
\def\XINT_floattodec_chkopt #1%
{%
    \ifx [#1\expandafter\XINT_floattodec_opt
       \else\expandafter\XINT_floattodec_noopt
    \fi  #1%
}%
\def\XINT_floattodec_noopt #1\xint:%
{%
    \expandafter\XINT_floattodec\romannumeral0\XINTinfloatS[\XINTdigits]{#1}%
}%
\def\XINT_floattodec_opt [\xint:#1]%
{%
    \expandafter\XINT_floattodec\romannumeral0\XINTinfloatS[#1]%
}%
%    \end{macrocode}
%\begin{lverb}
% Temptation to try to use direct access to lower entry points
% from \xintREZ, but it dates back from very early days and uses old \Z
% delimiters (same remarks for the code jumping from \xintFracToSci
% to \xintrez)
%\end{lverb}
%    \begin{macrocode}
\def\XINT_floattodec#1]%
{%
    \expandafter\XINT_dectostr\romannumeral0\xintrez{#1]}%
}%
%    \end{macrocode}
%
% \subsection{\csh{xintFloatAdd}, \cshnolabel{XINTinFloatAdd}}
%
% The \csbXINT{inFloatAdd} interface is kept at 2.0a1 for \ctanpackage{polexpr}.
% And \csbXINT{infloatadd} is kept for \xintseriesnameimp.
%
%\begin{lverb}
% First included in release 1.07.
%
% 1.09ka improved a bit the efficiency. However the add, sub, mul, div
% routines were provisory and supposed to be revised soon.
%
% Which didn't happen until 1.2f. Now, the inputs are first rounded to P
% digits, not P+2 as earlier.
%
% See general introduction for important changes at 1.4e relative to
% the \XINTinFloat<name> macros.
%
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatAdd  {\romannumeral0\xintfloatadd}%
\def\xintfloatadd  #1{\XINT_fladd_chkopt \xintfloat #1\xint:}%
\def\XINTinFloatAdd{\romannumeral0\XINTinfloatadd }%
\def\XINTinfloatadd{\XINT_fladd_opt_a\XINTdigits.\XINTinfloatS}%
\def\XINTinfloatadd_wopt[#1]{\expandafter\XINT_fladd_opt_a\the\numexpr#1.\XINTinfloatS}%
\def\XINT_fladd_chkopt #1#2%
{%
    \ifx [#2\expandafter\XINT_fladd_opt
       \else\expandafter\XINT_fladd_noopt
    \fi  #1#2%
}%
\def\XINT_fladd_noopt #1#2\xint:#3%
{%
    #1[\XINTdigits]%
    {\expandafter\XINT_FL_add_a
     \romannumeral0\XINTinfloat[\XINTdigits]{#2}\XINTdigits.{#3}}%
}%
\def\XINT_fladd_opt #1[\xint:#2]%#3#4%
{%
    \expandafter\XINT_fladd_opt_a\the\numexpr #2.#1%
}%
\def\XINT_fladd_opt_a #1.#2#3#4%
{%
    #2[#1]{\expandafter\XINT_FL_add_a\romannumeral0\XINTinfloat[#1]{#3}#1.{#4}}%
}%
\def\XINT_FL_add_a #1%
{%
    \xint_gob_til_zero #1\XINT_FL_add_zero 0\XINT_FL_add_b #1%
}%
\def\XINT_FL_add_zero #1.#2{#2}%[[
\def\XINT_FL_add_b #1]#2.#3%
{%
    \expandafter\XINT_FL_add_c\romannumeral0\XINTinfloat[#2]{#3}#2.#1]%
}%
\def\XINT_FL_add_c #1%
{%
    \xint_gob_til_zero #1\XINT_FL_add_zero 0\XINT_FL_add_d #1%
}%
%    \end{macrocode}
% \changed{1.4p}
% Fix long-standing regression which was introduced
% at |1.2f| (|2016/03/12|).
%
%\begin{lverb}
% The bug caused the rounding to not be the correct one
% if one argument x (after initial rounding to P digits) is +-10^n and the
% other y has opposite sign, scientific exponent exactly n-P-1, and
% |y| > 5 10^{n-P-1}. Affects \xintFloatAdd and \xintFloatSub, and also
% of course the \xintexpr context.
% Fixed by testing >1 and not>0 for the short path.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_FL_add_d #1[#2]#3.#4[#5]%
{%
    \ifnum\numexpr #2-#3-#5>\xint_c_i\xint_dothis\xint_firstoftwo\fi
    \ifnum\numexpr #5-#3-#2>\xint_c_i\xint_dothis\xint_secondoftwo\fi
    \xint_orthat\xintAdd {#1[#2]}{#4[#5]}%
}%
%    \end{macrocode}
% \subsection{\csh{xintFloatSub}, \cshnolabel{XINTinFloatSub}}
% \added{1.07}
% \changed{1.2f}
%\begin{lverb}
% Starting with 1.2f the arguments undergo an intial rounding to the target
% precision P not P+2.
%\end{lverb}
%
%    \begin{macrocode}
\def\xintFloatSub  {\romannumeral0\xintfloatsub}%
\def\xintfloatsub  #1{\XINT_flsub_chkopt \xintfloat #1\xint:}%
\def\XINT_flsub_chkopt #1#2%
{%
    \ifx [#2\expandafter\XINT_flsub_opt
       \else\expandafter\XINT_flsub_noopt
    \fi  #1#2%
}%
\def\XINT_flsub_noopt #1#2\xint:#3%
{%
    #1[\XINTdigits]%
    {\expandafter\XINT_FL_add_a
     \romannumeral0\XINTinfloat[\XINTdigits]{#2}\XINTdigits.{\xintOpp{#3}}}%
}%
\def\XINT_flsub_opt #1[\xint:#2]%#3#4%
{%
    \expandafter\XINT_flsub_opt_a\the\numexpr #2.#1%
}%
\def\XINT_flsub_opt_a #1.#2#3#4%
{%
    #2[#1]{\expandafter\XINT_FL_add_a\romannumeral0\XINTinfloat[#1]{#3}#1.{\xintOpp{#4}}}%
}%
%    \end{macrocode}
% \subsection{\csh{xintFloatMul}, \cshnolabel{XINTinFloatMul}}
%
% The \csbXINT{inFloatMul} interface is kept at 2.0a1 for \ctanpackage{polexpr}.
% And \csbXINT{infloatmul} is kept for \xintseriesnameimp.
%
% \added{1.07}
% \changed{1.2d}
%\begin{lverb}
% Starting with 1.2f the arguments are rounded to the target precision P not
% P+2.
%\end{lverb}
% \changed{1.2g}
%\begin{lverb}
% 1.2g handles the inputs via \XINTinFloatS which will be more efficient when
% the precision is large and the input is for example a small constant like 2.
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatMul  {\romannumeral0\xintfloatmul}%
\def\xintfloatmul  #1{\XINT_flmul_chkopt \xintfloat #1\xint:}%
\def\XINTinFloatMul{\romannumeral0\XINTinfloatmul}%
\def\XINTinfloatmul{\XINT_flmul_opt_a\XINTdigits.\XINTinfloatS}%
\def\XINTinfloatmul_wopt[#1]{\expandafter\XINT_flmul_opt_a\the\numexpr#1.\XINTinfloatS}%
\def\XINT_flmul_chkopt #1#2%
{%
    \ifx [#2\expandafter\XINT_flmul_opt
       \else\expandafter\XINT_flmul_noopt
    \fi  #1#2%
}%
\def\XINT_flmul_noopt #1#2\xint:#3%
{%
    #1[\XINTdigits]%
    {\expandafter\XINT_FL_mul_a
     \romannumeral0\XINTinfloatS[\XINTdigits]{#2}\XINTdigits.{#3}}%
}%
\def\XINT_flmul_opt #1[\xint:#2]%#3#4%
{%
    \expandafter\XINT_flmul_opt_a\the\numexpr #2.#1%
}%
\def\XINT_flmul_opt_a #1.#2#3#4%
{%
    #2[#1]{\expandafter\XINT_FL_mul_a\romannumeral0\XINTinfloatS[#1]{#3}#1.{#4}}%
}%
\def\XINT_FL_mul_a #1[#2]#3.#4%
{%
    \expandafter\XINT_FL_mul_b\romannumeral0\XINTinfloatS[#3]{#4}#1[#2]%
}%
\def\XINT_FL_mul_b #1[#2]#3[#4]{\xintiiMul{#3}{#1}/1[#4+#2]}%
%    \end{macrocode}
% \subsection{\csh{xintFloatSqr}, \cshnolabel{XINTinFloatSqr}}
% \added{1.4e}
%\begin{lverb}
% Strangely \xintFloatSqr had never been defined so far.
%
% An \XINTinFloatSqr{#1} was defined in xintexpr.sty directly as
% \XINTinFloatMul[\XINTdigits]{#1}{#1}, to support the sqr() function. The
% {#1}{#1} causes no problem as #1 in this context is always pre-expanded so
% we don't need to worry about this, and the \xintdeffloatfunc mechanism
% should hopefully take care to add the needed argument pre-expansion if need
% be.
%
% Anyway let's do this finally properly here.
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatSqr  {\romannumeral0\xintfloatsqr}%
\def\xintfloatsqr  #1{\XINT_flsqr_chkopt \xintfloat #1\xint:}%
\def\XINT_flsqr_chkopt #1#2%
{%
    \ifx [#2\expandafter\XINT_flsqr_opt
       \else\expandafter\XINT_flsqr_noopt
    \fi  #1#2%
}%
\def\XINT_flsqr_noopt #1#2\xint:
{%
    #1[\XINTdigits]%
    {\expandafter\XINT_FL_sqr_a\romannumeral0\XINTinfloatS[\XINTdigits]{#2}}%
}%
\def\XINT_flsqr_opt #1[\xint:#2]%
{%
    \expandafter\XINT_flsqr_opt_a\the\numexpr #2.#1%
}%
\def\XINT_flsqr_opt_a #1.#2#3%
{%
    #2[#1]{\expandafter\XINT_FL_sqr_a\romannumeral0\XINTinfloatS[#1]{#3}}%
}%
\def\XINT_FL_sqr_a #1[#2]{\xintiiSqr{#1}/1[#2+#2]}%
%    \end{macrocode}
% \subsection{\csh{xintFloatDiv}, \cshnolabel{XINTinFloatDiv}}
% \added{1.07}
% \changed{1.2f}
%\begin{lverb}
% Starting with 1.2f the arguments are rounded to the target precision P not
% P+2.
%\end{lverb}
% \changed{1.2g}
%\begin{lverb}
% 1.2g handles the inputs via \XINTinFloatS which will be more efficient when
% the precision is large and the input is for example a small constant like 2.
%
% The actual rounding of the quotient is handled via \xintfloat (or
% \XINTinfloatS).
%\end{lverb}
% \changed{1.2k}
%\begin{lverb}
% 1.2k does the same kind of improvement in \XINT_FL_div_b as for
% multiplication: earlier code was unnecessarily high level.
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatDiv  {\romannumeral0\xintfloatdiv}%
\def\xintfloatdiv  #1{\XINT_fldiv_chkopt \xintfloat #1\xint:}%
\def\XINT_fldiv_chkopt #1#2%
{%
    \ifx [#2\expandafter\XINT_fldiv_opt
       \else\expandafter\XINT_fldiv_noopt
    \fi  #1#2%
}%
%    \end{macrocode}
%\begin{lverb}
% 1.4g adds here intercept of second argument being zero,
% else a low level error will arise at later stage from the
% the fall-back value returned by core iidivision being 0
% and not having expected number of digits at \XINT_infloat_Qq
% and split from left returning some empty value breaking the
% \ifnum test in \XINT_infloat_Rq.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_fldiv_noopt #1#2\xint:#3%
{%
    #1[\XINTdigits]%
    {\expandafter\XINT_FL_div_aa
     \romannumeral0\XINTinfloatS[\XINTdigits]{#3}\XINTdigits.{#2}}%
}%
\def\XINT_FL_div_aa #1%
{%
    \xint_gob_til_zero#1\XINT_FL_div_Bzero0\XINT_FL_div_a #1%
}%
\def\XINT_FL_div_Bzero0\XINT_FL_div_a#1[#2]#3.#4%
{%
    \XINT_legacysignalcondition{DivisionByZero}{Division by zero (#1[#2]) of #4}{}{ 0[0]}%
}%
\def\XINT_fldiv_opt #1[\xint:#2]%#3#4%
{%
    \expandafter\XINT_fldiv_opt_a\the\numexpr #2.#1%
}%
%    \end{macrocode}
%\begin{lverb}
% Also here added early check at 1.4g if divisor is zero.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_fldiv_opt_a #1.#2#3#4%
{%
    #2[#1]{\expandafter\XINT_FL_div_aa\romannumeral0\XINTinfloatS[#1]{#4}#1.{#3}}%
}%
\def\XINT_FL_div_a #1[#2]#3.#4%
{%
    \expandafter\XINT_FL_div_b\romannumeral0\XINTinfloatS[#3]{#4}/#1e#2%
}%
\def\XINT_FL_div_b #1[#2]{#1e#2}%
%    \end{macrocode}
% \subsection{\csh{xintFloatPow}, \cshnolabel{XINTinFloatPow}}
% \added{1.07}
% 
%\begin{lverb}
% 1.09j has re-organized the core loop.
%
% 2015/12/07. I have hesitated to map ^ in expressions to \xintFloatPow rather
% than \xintFloatPower. But for 1.234567890123456 to the power 2145678912 with
% P=16, using Pow rather than Power seems to bring only about 5$char37 $space
% gain.
%
% This routine requires the exponent x to be compatible with \numexpr parsing.
%\end{lverb}
%
% \changed{1.2f}
%\begin{lverb}
% 1.2f has rewritten the code for better efficiency. Also, now the argument A
% for A^x is first rounded to P digits before switching to the increased
% working precision (which depends upon x).
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatPow  {\romannumeral0\xintfloatpow}%
\def\xintfloatpow  #1{\XINT_flpow_chkopt \xintfloat #1\xint:}%
\def\XINTinfloatpow{\XINT_flpow_opt_a\XINTdigits.\XINTinfloatS}%
\def\XINTinfloatpow_wopt[#1]{\expandafter\XINT_flpow_opt_a\the\numexpr#1.\XINTinfloatS}%
\def\XINT_flpow_chkopt #1#2%
{%
    \ifx [#2\expandafter\XINT_flpow_opt
       \else\expandafter\XINT_flpow_noopt
    \fi
    #1#2%
}%
\def\XINT_flpow_noopt  #1#2\xint:#3%
{%
   \expandafter\XINT_flpow_checkB_a
   \the\numexpr #3.\XINTdigits.{#2}{#1[\XINTdigits]}%
}%
\def\XINT_flpow_opt #1[\xint:#2]%
{%
   \expandafter\XINT_flpow_opt_a\the\numexpr #2.#1%
}%
\def\XINT_flpow_opt_a #1.#2#3#4%
{%
   \expandafter\XINT_flpow_checkB_a\the\numexpr #4.#1.{#3}{#2[#1]}%
}%
\def\XINT_flpow_checkB_a #1%
{%
    \xint_UDzerominusfork
      #1-\XINT_flpow_BisZero
      0#1{\XINT_flpow_checkB_b -}%
       0-{\XINT_flpow_checkB_b {}#1}%
    \krof
}%
\def\XINT_flpow_BisZero .#1.#2#3{#3{1[0]}}%
\def\XINT_flpow_checkB_b #1#2.#3.%
{%
    \expandafter\XINT_flpow_checkB_c
    \the\numexpr\xintLength{#2}+\xint_c_iii.#3.#2.{#1}%
}%
\def\XINT_flpow_checkB_c #1.#2.%
{%
    \expandafter\XINT_flpow_checkB_d\the\numexpr#1+#2.#1.#2.%
}%
%    \end{macrocode}
%\begin{lverb}
%
% 1.2f rounds input to P digits, first.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_flpow_checkB_d #1.#2.#3.#4.#5#6%
{%
    \expandafter \XINT_flpow_aa
    \romannumeral0\XINTinfloat [#3]{#6}{#2}{#1}{#4}{#5}%
}%
\def\XINT_flpow_aa #1[#2]#3%
{%
    \expandafter\XINT_flpow_ab\the\numexpr #2-#3\expandafter.%
    \romannumeral\XINT_rep #3\endcsname0.#1.%
}%
\def\XINT_flpow_ab #1.#2.#3.{\XINT_flpow_a #3#2[#1]}%
\def\XINT_flpow_a #1%
{%
    \xint_UDzerominusfork
      #1-\XINT_flpow_zero
      0#1{\XINT_flpow_b \iftrue}%
       0-{\XINT_flpow_b \iffalse#1}%
    \krof
}%
\def\XINT_flpow_zero #1[#2]#3#4#5#6%
{%
    #6{\if 1#51\xint_dothis {0[0]}\fi
       \xint_orthat
       {\XINT_legacysignalcondition{DivisionByZero}{0 raised to power -#4.}{}{ 0[0]}}%
      }%
}%
\def\XINT_flpow_b #1#2[#3]#4#5%
{%
    \XINT_flpow_loopI #5.#3.#2.#4.{#1\ifodd #5 \xint_c_i\fi\fi}%
}%
\def\XINT_flpow_truncate #1.#2.#3.%
{%
    \expandafter\XINT_flpow_truncate_a
    \romannumeral0\XINT_split_fromleft
    #3.#2\xint_bye2345678\xint_bye..#1.#3.%
}%
\def\XINT_flpow_truncate_a #1.#2.#3.{#3+\xintLength{#2}.#1.}%
\def\XINT_flpow_loopI #1.%
{%
    \ifnum #1=\xint_c_i\expandafter\XINT_flpow_ItoIII\fi
    \ifodd #1
       \expandafter\XINT_flpow_loopI_odd
    \else
       \expandafter\XINT_flpow_loopI_even
    \fi
    #1.%
}%
\def\XINT_flpow_ItoIII\ifodd #1\fi #2.#3.#4.#5.#6%
{%
    \expandafter\XINT_flpow_III\the\numexpr #6+\xint_c_.#3.#4.#5.%
}%
\def\XINT_flpow_loopI_even #1.#2.#3.%#4.%
{%
    \expandafter\XINT_flpow_loopI
    \the\numexpr #1/\xint_c_ii\expandafter.%
    \the\numexpr\expandafter\XINT_flpow_truncate 
    \the\numexpr\xint_c_ii*#2\expandafter.\romannumeral0\xintiisqr{#3}.%
}%
\def\XINT_flpow_loopI_odd #1.#2.#3.#4.%
{%
    \expandafter\XINT_flpow_loopII
    \the\numexpr #1/\xint_c_ii-\xint_c_i\expandafter.%
    \the\numexpr\expandafter\XINT_flpow_truncate 
    \the\numexpr\xint_c_ii*#2\expandafter.\romannumeral0\xintiisqr{#3}.#4.#2.#3.%
}%
\def\XINT_flpow_loopII #1.%
{%
    \ifnum #1 = \xint_c_i\expandafter\XINT_flpow_IItoIII\fi
    \ifodd #1
       \expandafter\XINT_flpow_loopII_odd
    \else
       \expandafter\XINT_flpow_loopII_even
    \fi
    #1.%
}%
\def\XINT_flpow_loopII_even #1.#2.#3.%#4.%
{%
    \expandafter\XINT_flpow_loopII
    \the\numexpr #1/\xint_c_ii\expandafter.%
    \the\numexpr\expandafter\XINT_flpow_truncate 
    \the\numexpr\xint_c_ii*#2\expandafter.\romannumeral0\xintiisqr{#3}.%
}%
\def\XINT_flpow_loopII_odd #1.#2.#3.#4.#5.#6.%
{%
    \expandafter\XINT_flpow_loopII_odda
    \the\numexpr\expandafter\XINT_flpow_truncate 
    \the\numexpr#2+#5\expandafter.\romannumeral0\xintiimul{#3}{#6}.#4.%
    #1.#2.#3.%
}%
\def\XINT_flpow_loopII_odda #1.#2.#3.#4.#5.#6.%
{%
    \expandafter\XINT_flpow_loopII
    \the\numexpr #4/\xint_c_ii-\xint_c_i\expandafter.%
    \the\numexpr\expandafter\XINT_flpow_truncate 
    \the\numexpr\xint_c_ii*#5\expandafter.\romannumeral0\xintiisqr{#6}.#3.%
    #1.#2.%
}%
\def\XINT_flpow_IItoIII\ifodd #1\fi #2.#3.#4.#5.#6.#7.#8%
{%
    \expandafter\XINT_flpow_III\the\numexpr #8+\xint_c_\expandafter.%
    \the\numexpr\expandafter\XINT_flpow_truncate 
    \the\numexpr#3+#6\expandafter.\romannumeral0\xintiimul{#4}{#7}.#5.%
}%
%    \end{macrocode}
%\begin{lverb}
% This ending is common with \xintFloatPower.
%
% In the case of negative exponent we need to inverse the Q-digits mantissa.
% This requires no special attention now as 1.2k's \xintFloat does correct
% rounding of fractions hence it is easy to bound the total error. It can be
% checked that the algorithm after final rounding to the target precision
% computes a value Z whose distance to the exact theoretical will be less than
% 0.52 ulp(Z) (and worst cases can only be slightly worse than 0.51 ulp(Z)).
%
% In the case of the half-integer exponent (only via the expression
% interface,) the computation (which proceeds via \XINTinFloatPowerH) ends
% with a square root. This square root extraction is done with 3 guard digits
% (the power operations were done with more.) Then the value is rounded to the
% target precision. There is thus this rounding to 3 guard digits (in the case
% of negative exponent the reciprocal is computed before the square-root),
% then the square root is (computed with exact rounding for these 3 guard
% digits), and then there is the final rounding of this to the target
% precision. The total error (for positive as well as negative exponent) has
% been estimated to at worst possibly exceed slightly 0.5125 ulp(Z), and at
% any rate it is less than 0.52 ulp(Z).
%\end{lverb}
%    \begin{macrocode}
\def\XINT_flpow_III #1.#2.#3.#4.#5%
{%
    \expandafter\XINT_flpow_IIIend
    \xint_UDsignfork
         #5{{1/#3[-#2]}}%
         -{{#3[#2]}}%
    \krof #1%
}%
\def\XINT_flpow_IIIend #1#2#3%
    {#3{\if#21\xint_afterfi{\expandafter-\romannumeral`&&@}\fi#1}}%
%    \end{macrocode}
% \subsection{\csh{xintFloatPower}, \cshnolabel{XINTinFloatPower}}
% \added{1.07}
%\begin{lverb}
% The core loop has been re-organized in 1.09j for some slight
% efficiency gain. The exponent B is given to \xintNum. The ^ in expressions
% is mapped to this routine.
%\end{lverb}
% \changed{1.2f}
%\begin{lverb}
% Same modifications as in \xintFloatPow for 1.2f.
%
% 1.2f \XINTinFloatPowerH (now moved to $xintlognameimp, and renamed). It 
% truncated the exponent to an integer of half-integer, and in the latter case
% use Square-root extraction. At 1.2k this was improved as 1.2f stupidly
% rounded to Digits before, not after the square root extraction, 1.2k kept 3
% guard digits for this last step. And the initial step was
% changed to a rounding rather than truncating.
%\end{lverb}
% \changed{1.4e}
%\begin{lverb}
% Until 1.4e this \XINTinFloatPowerH was the macro for a^b in expressions,
% but of course it behaved strangely for b not an integer or an half-integer!
% At 1.4e, the non-integer, non-half-integer exponents will be handled via
% log10() and pow10() support macros, see $xintlognameimp. The code
% has now been relocated there.
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatPower  {\romannumeral0\xintfloatpower}%
\def\xintfloatpower  #1{\XINT_flpower_chkopt \xintfloat #1\xint:}%
%    \end{macrocode}
%\begin{lverb}
% Start of macro. Check for optional argument.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_flpower_chkopt #1#2%
{%
    \ifx [#2\expandafter\XINT_flpower_opt
       \else\expandafter\XINT_flpower_noopt
    \fi
    #1#2%
}%
\def\XINT_flpower_noopt  #1#2\xint:#3%
{%
   \expandafter\XINT_flpower_checkB_a
   \romannumeral0\xintnum{#3}.\XINTdigits.{#2}{#1[\XINTdigits]}%
}%
\def\XINT_flpower_opt #1[\xint:#2]%
{%
   \expandafter\XINT_flpower_opt_a\the\numexpr #2.#1%
}%
\def\XINT_flpower_opt_a #1.#2#3#4%
{%
   \expandafter\XINT_flpower_checkB_a
   \romannumeral0\xintnum{#4}.#1.{#3}{#2[#1]}%
}%
\def\XINT_flpower_checkB_a #1%
{%
    \xint_UDzerominusfork
      #1-{\XINT_flpower_BisZero 0}%
      0#1{\XINT_flpower_checkB_b -}%
       0-{\XINT_flpower_checkB_b {}#1}%
    \krof
}%
\def\XINT_flpower_BisZero 0.#1.#2#3{#3{1[0]}}%
\def\XINT_flpower_checkB_b #1#2.#3.%
{%
    \expandafter\XINT_flpower_checkB_c
    \the\numexpr\xintLength{#2}+\xint_c_iii.#3.#2.{#1}%
}%
\def\XINT_flpower_checkB_c #1.#2.%
{%
    \expandafter\XINT_flpower_checkB_d\the\numexpr#1+#2.#1.#2.%
}%
\def\XINT_flpower_checkB_d #1.#2.#3.#4.#5#6%
{%
    \expandafter \XINT_flpower_aa
    \romannumeral0\XINTinfloat [#3]{#6}{#2}{#1}{#4}{#5}%
}%
\def\XINT_flpower_aa #1[#2]#3%
{%
    \expandafter\XINT_flpower_ab\the\numexpr #2-#3\expandafter.%
    \romannumeral\XINT_rep #3\endcsname0.#1.%
}%
\def\XINT_flpower_ab #1.#2.#3.{\XINT_flpower_a #3#2[#1]}%
\def\XINT_flpower_a #1%
{%
    \xint_UDzerominusfork
      #1-\XINT_flpow_zero
      0#1{\XINT_flpower_b \iftrue}%
       0-{\XINT_flpower_b \iffalse#1}%
    \krof
}%
\def\XINT_flpower_b #1#2[#3]#4#5%
{%
    \XINT_flpower_loopI #5.#3.#2.#4.{#1\xintiiOdd{#5}\fi}%
}%
\def\XINT_flpower_loopI #1.%
{%
    \if1\XINT_isOne {#1}\xint_dothis\XINT_flpower_ItoIII\fi
    \ifodd\xintLDg{#1} %<- intentional space
       \xint_dothis{\expandafter\XINT_flpower_loopI_odd}\fi
    \xint_orthat{\expandafter\XINT_flpower_loopI_even}%
    \romannumeral0\XINT_half
    #1\xint_bye\xint_Bye345678\xint_bye
    *\xint_c_v+\xint_c_v)/\xint_c_x-\xint_c_i\relax.%
}%
\def\XINT_flpower_ItoIII #1.#2.#3.#4.#5%
{%
    \expandafter\XINT_flpow_III\the\numexpr #5+\xint_c_.#2.#3.#4.%
}%
\def\XINT_flpower_loopI_even #1.#2.#3.#4.%
{%
    \expandafter\XINT_flpower_toloopI
    \the\numexpr\expandafter\XINT_flpow_truncate 
    \the\numexpr\xint_c_ii*#2\expandafter.\romannumeral0\xintiisqr{#3}.#4.#1.%
}%
\def\XINT_flpower_toloopI #1.#2.#3.#4.{\XINT_flpower_loopI #4.#1.#2.#3.}%
\def\XINT_flpower_loopI_odd #1.#2.#3.#4.%
{%
    \expandafter\XINT_flpower_toloopII
    \the\numexpr\expandafter\XINT_flpow_truncate 
    \the\numexpr\xint_c_ii*#2\expandafter.\romannumeral0\xintiisqr{#3}.#4.%
    #1.#2.#3.%
}%
\def\XINT_flpower_toloopII #1.#2.#3.#4.{\XINT_flpower_loopII #4.#1.#2.#3.}%
\def\XINT_flpower_loopII #1.%
{%
    \if1\XINT_isOne{#1}\xint_dothis\XINT_flpower_IItoIII\fi
    \ifodd\xintLDg{#1} %<- intentional space
        \xint_dothis{\expandafter\XINT_flpower_loopII_odd}\fi
    \xint_orthat{\expandafter\XINT_flpower_loopII_even}%
    \romannumeral0\XINT_half#1\xint_bye\xint_Bye345678\xint_bye
    *\xint_c_v+\xint_c_v)/\xint_c_x-\xint_c_i\relax.%
}%
\def\XINT_flpower_loopII_even #1.#2.#3.#4.%
{%
    \expandafter\XINT_flpower_toloopII
    \the\numexpr\expandafter\XINT_flpow_truncate 
    \the\numexpr\xint_c_ii*#2\expandafter.\romannumeral0\xintiisqr{#3}.#4.#1.%
}%
\def\XINT_flpower_loopII_odd #1.#2.#3.#4.#5.#6.%
{%
    \expandafter\XINT_flpower_loopII_odda
    \the\numexpr\expandafter\XINT_flpow_truncate 
    \the\numexpr#2+#5\expandafter.\romannumeral0\xintiimul{#3}{#6}.#4.%
    #1.#2.#3.%
}%
\def\XINT_flpower_loopII_odda #1.#2.#3.#4.#5.#6.%
{%
    \expandafter\XINT_flpower_toloopII
    \the\numexpr\expandafter\XINT_flpow_truncate 
    \the\numexpr\xint_c_ii*#5\expandafter.\romannumeral0\xintiisqr{#6}.#3.%
    #4.#1.#2.%
}%
\def\XINT_flpower_IItoIII #1.#2.#3.#4.#5.#6.#7%
{%
    \expandafter\XINT_flpow_III\the\numexpr #7+\xint_c_\expandafter.%
    \the\numexpr\expandafter\XINT_flpow_truncate 
    \the\numexpr#2+#5\expandafter.\romannumeral0\xintiimul{#3}{#6}.#4.%
}%
%    \end{macrocode}
% \subsection{\csh{xintFloatFac}, \csh{XINTFloatFac}}
% \added{1.2}
%    \begin{macrocode}
\def\xintFloatFac  {\romannumeral0\xintfloatfac}%
\def\xintfloatfac  #1{\XINT_flfac_chkopt \xintfloat #1\xint:}%
\def\XINTinFloatFac{\romannumeral0\XINTinfloatfac}%
\def\XINTinfloatfac[#1]{\expandafter\XINT_flfac_opt_a\the\numexpr#1.\XINTinfloatS}%
\def\XINT_flfac_chkopt #1#2%
{%
    \ifx [#2\expandafter\XINT_flfac_opt
       \else\expandafter\XINT_flfac_noopt
    \fi
     #1#2%
}%
\def\XINT_flfac_noopt  #1#2\xint:
{%
   \expandafter\XINT_FL_fac_fork_a
   \the\numexpr \xintNum{#2}.{\XINTdigits}{#1[\XINTdigits]}%
}%
\def\XINT_flfac_opt #1[\xint:#2]%
{%
   \expandafter\XINT_flfac_opt_a\the\numexpr #2.#1%
}%
\def\XINT_flfac_opt_a #1.#2#3%
{%
   \expandafter\XINT_FL_fac_fork_a\the\numexpr \xintNum{#3}.{#1}{#2[#1]}%
}%
\def\XINT_FL_fac_fork_a #1%
{%
     \xint_UDzerominusfork
     #1-\XINT_FL_fac_iszero
     0#1\XINT_FL_fac_isneg
      0-{\XINT_FL_fac_fork_b #1}%
    \krof
}%
\def\XINT_FL_fac_iszero #1.#2#3{#3{1[0]}}%
%    \end{macrocode}
%\begin{lverb}
% 1.2f XINT_FL_fac_isneg returns 0, earlier versions used 1 here.
%
% calx: the factorial of an integer 0 < n < 10^8 is computed by calxfp's
% \CALX_ffac_fork_b (xintfrac's former engine, native output rounded to
% the target precision P), converted to raw by \CALX_ftoraw for the final
% macro (\xintfloat or \XINTinfloatS) at P.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_FL_fac_isneg  #1.#2#3%
{%
    #3{\XINT_legacysignalcondition{InvalidOperation}
                     {Factorial argument is negative: -#1.}{}{ 0[0]}}%
}%
\def\XINT_FL_fac_fork_b #1.%
{%
    \ifnum #1>\xint_c_e_viii_mone\xint_dothis\XINT_FL_fac_toobig\fi
    \xint_orthat\XINT_FL_fac_go #1.%
}%
\def\XINT_FL_fac_toobig #1.#2#3%
{%
    #3{\XINT_legacysignalcondition{InvalidOperation}
                     {Factorial argument is too large: #1>=10^8.}{}{ 0[0]}}%
}%
\def\XINT_FL_fac_go #1.#2#3%
{%
    #3{\romannumeral0\CALX_ftoraw{\romannumeral0\CALX_ffac_fork_b
       #1.\xint_c_i{#2+\xint_c_ii}\CALX_ffac_out{#2}}}%
}%
%    \end{macrocode}
% \subsection{\csh{xintFloatPFactorial}, \cshnolabel{XINTinFloatPFactorial}}
% \added[2015/11/29]{1.2f}
%\begin{lverb}
% Partial factorial pfactorial(a,b)=(a+1)...b,
% only for non-negative integers with a<=b<10^8.
%\end{lverb}
% \changed[2016/11/20]{1.2h}
%\begin{lverb}
% Now avoids raising \xintError:OutOfRangePFac if the
% condition 0<=a<=b<10^8 is violated. Same as for \xintiiPFactorial.
%\end{lverb}
% \changed{1.4e}
%\begin{lverb}
% 1.4e extends the precision in floating point context adding some overhead
% but well.
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatPFactorial  {\romannumeral0\xintfloatpfactorial}%
\def\xintfloatpfactorial  #1{\XINT_flpfac_chkopt \xintfloat #1\xint:}%
\def\XINT_flpfac_chkopt #1#2%
{%
    \ifx [#2\expandafter\XINT_flpfac_opt
       \else\expandafter\XINT_flpfac_noopt
    \fi
     #1#2%
}%
\def\XINT_flpfac_noopt  #1#2\xint:#3%
{%
   \expandafter\XINT_FL_pfac_fork
   \the\numexpr \xintNum{#2}\expandafter.%
   \the\numexpr \xintNum{#3}.\xint_c_i{\XINTdigits}{#1[\XINTdigits]}%
}%
\def\XINT_flpfac_opt #1[\xint:#2]%
{%
   \expandafter\XINT_flpfac_opt_a\the\numexpr #2.#1%
}%
\def\XINT_flpfac_opt_a #1.#2#3#4%
{%
   \expandafter\XINT_FL_pfac_fork
   \the\numexpr \xintNum{#3}\expandafter.%
   \the\numexpr \xintNum{#4}.\xint_c_i{#1}{#2[#1]}%
}%
\def\XINT_FL_pfac_fork #1#2.#3#4.%
{%
    \unless\ifnum #1#2<#3#4 \xint_dothis\XINT_FL_pfac_one\fi
    \if-#3\xint_dothis\XINT_FL_pfac_neg \fi
    \if-#1\xint_dothis\XINT_FL_pfac_zero\fi
    \ifnum #3#4>\xint_c_e_viii_mone\xint_dothis\XINT_FL_pfac_outofrange\fi
    \xint_orthat \XINT_FL_pfac_go #1#2.#3#4.%
}%
\def\XINT_FL_pfac_outofrange #1.#2.#3#4#5%
{%
    #5{\XINT_legacysignalcondition{InvalidOperation}
                     {pFactorial with too large argument: #2 >= 10^8.}{}{ 0[0]}}%
}%
\def\XINT_FL_pfac_one  #1.#2.#3#4#5{#5{1[0]}}%
\def\XINT_FL_pfac_zero #1.#2.#3#4#5{#5{0[0]}}%
\def\XINT_FL_pfac_neg -#1.-#2.%
{%
    \ifnum #1>\xint_c_e_viii\xint_dothis\XINT_FL_pfac_outofrange\fi
    \xint_orthat {%
    \ifodd\numexpr#2-#1\relax\xint_afterfi{\expandafter-\romannumeral`&&@}\fi
    \expandafter\XINT_FL_pfac_go}%
    \the\numexpr #2-\xint_c_i\expandafter.\the\numexpr#1-\xint_c_i.%
}%
%    \end{macrocode}
%\begin{lverb}
% calx: the product is computed by calxfp's \CALX_fpfac_increaseP
% (xintfrac's former engine, native output rounded to the target precision
% P), converted to raw by \CALX_ftoraw for the final macro at P.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_FL_pfac_go #1.#2.#3#4#5%
{%
    #5{\romannumeral0\CALX_ftoraw{\romannumeral0\CALX_fpfac_increaseP
       #1.#2.#3{#4+\xint_c_ii}{#4}}}%
}%
%    \end{macrocode}
% \subsection{\csh{xintFloatBinomial}, \cshnolabel{XINTinFloatBinomial}}
% \added[2015/12/01]{1.2f}
%\begin{lverb}
% We compute binomial(x,y) as pfac(x-y,x)/y!, where the numerator
% and denominator are computed with a relative error at most 4.10^{-P-2}, then
% rounded (once I have a float truncation, I will use truncation rather) to
% P+3 digits, and finally the quotient is correctly rounded to P digits. This
% will guarantee that the exact value X differs from the computed one Y by at
% most 0.6 ulp(Y).
%\end{lverb}
% \changed[2016/11/19]{1.2h}
%\begin{lverb}
% As for \xintiiBinomial, hard to understand why last
% year I coded this to raise an error if y<0 or y>x ! The question of the
% Gamma function is for another occasion, here x and y must be (small)
% integers.
%
% 1.4e: same remarks as for factorial and partial factorial about added
% overhead due to extra guard digits.
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatBinomial  {\romannumeral0\xintfloatbinomial}%
\def\xintfloatbinomial  #1{\XINT_flbinom_chkopt \xintfloat #1\xint:}%
\def\XINT_flbinom_chkopt #1#2%
{%
    \ifx [#2\expandafter\XINT_flbinom_opt
       \else\expandafter\XINT_flbinom_noopt
    \fi  #1#2%
}%
\def\XINT_flbinom_noopt #1#2\xint:#3%
{%
    \expandafter\XINT_FL_binom_a
    \the\numexpr\xintNum{#2}\expandafter.%
    \the\numexpr\xintNum{#3}\expandafter.\the\numexpr\XINTdigits.#1%
}%
\def\XINT_flbinom_opt #1[\xint:#2]#3#4%
{%
    \expandafter\XINT_FL_binom_a
    \the\numexpr\xintNum{#3}\expandafter.\the\numexpr\xintNum{#4}\expandafter.%
    \the\numexpr #2.#1%
}%
\def\XINT_FL_binom_a #1.#2.%
{%
    \expandafter\XINT_FL_binom_fork \the\numexpr #1-#2.#2.#1.%
}%
\def\XINT_FL_binom_fork #1#2.#3#4.#5#6.%
{%
    \if-#5\xint_dothis \XINT_FL_binom_neg\fi
    \if-#1\xint_dothis \XINT_FL_binom_zero\fi
    \if-#3\xint_dothis \XINT_FL_binom_zero\fi
    \if0#1\xint_dothis \XINT_FL_binom_one\fi
    \if0#3\xint_dothis \XINT_FL_binom_one\fi
    \ifnum #5#6>\xint_c_e_viii_mone \xint_dothis\XINT_FL_binom_toobig\fi
    \ifnum #1#2>#3#4  \xint_dothis\XINT_FL_binom_ab \fi
                      \xint_orthat\XINT_FL_binom_aa
    #1#2.#3#4.#5#6.%
}%
\def\XINT_FL_binom_neg #1.#2.#3.#4.#5%
{%
    #5[#4]{\XINT_legacysignalcondition{InvalidOperation}
                         {Binomial with negative argument: #3.}{}{ 0[0]}}%
}%
\def\XINT_FL_binom_toobig #1.#2.#3.#4.#5%
{%
    #5[#4]{\XINT_legacysignalcondition{InvalidOperation}
                         {Binomial with too large argument: #3 >= 10^8.}{}{ 0[0]}}%
}%
\def\XINT_FL_binom_one  #1.#2.#3.#4.#5{#5[#4]{1[0]}}%
\def\XINT_FL_binom_zero #1.#2.#3.#4.#5{#5[#4]{0[0]}}%
\def\XINT_FL_binom_aa #1.#2.#3.#4.#5%
   {#5[#4]{\romannumeral0\CALX_ftoraw
     {\romannumeral0\CALX_fbinom_aa #1.#2.#3.#4.}}}%
\def\XINT_FL_binom_ab #1.#2.#3.#4.#5%
   {#5[#4]{\romannumeral0\CALX_ftoraw
     {\romannumeral0\CALX_fbinom_aa #2.#1.#3.#4.}}}%
%    \end{macrocode}
% \subsection{\csh{xintFloatSqrt}, \cshnolabel{XINTinFloatSqrt}}
% \added{1.08}
% \changed{1.2f}
%\begin{lverb}
% 
% The float version was developed at the same time as the integer one and even
% a bit earlier. As a result the integer variant had some sub-optimal parts.
% Anyway, for 1.2f I have rewritten the integer variant, and the float variant
% delegates all preparatory wrok for it until the last step. In particular the
% very low precisions are not penalized anymore from doing computations for at
% least 17 or 18 digits. Both the large and small precisions give quite
% shorter computation times.
%
% Also, after examining more closely the achieved precision I decided to
% extend the float version in order for it to obtain the correct rounding (for
% inputs already of at most P digits with P the precision) of the theoretical
% exact value.
%
% Beyond about 500 digits of precision the efficiency decreases swiftly,
% as is the case generally speaking with xintcore/xint/xintfrac arithmetic
% macros.
%
% Final note: with 1.2f the input is always first rounded to P significant
% places.
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatSqrt  {\romannumeral0\xintfloatsqrt}%
\def\xintfloatsqrt  #1{\XINT_flsqrt_chkopt \xintfloat #1\xint:}%
\def\XINT_flsqrt_chkopt #1#2%
{%
    \ifx [#2\expandafter\XINT_flsqrt_opt
       \else\expandafter\XINT_flsqrt_noopt
    \fi  #1#2%
}%
\def\XINT_flsqrt_noopt #1#2\xint:%
{%
    \expandafter\XINT_FL_sqrt_a 
                \romannumeral0\XINTinfloat[\XINTdigits]{#2}\XINTdigits.#1%
}%
\def\XINT_flsqrt_opt #1[\xint:#2]%#3%
{%
    \expandafter\XINT_flsqrt_opt_a\the\numexpr #2.#1%
}%
\def\XINT_flsqrt_opt_a #1.#2#3%
{%
    \expandafter\XINT_FL_sqrt_a\romannumeral0\XINTinfloat[#1]{#3}#1.#2%
}%
\def\XINT_FL_sqrt_a #1%
{%
    \xint_UDzerominusfork
     #1-\XINT_FL_sqrt_iszero
     0#1\XINT_FL_sqrt_isneg
      0-{\XINT_FL_sqrt_pos #1}%
    \krof
}%[
\def\XINT_FL_sqrt_iszero #1]#2.#3{#3[#2]{0[0]}}%
\def\XINT_FL_sqrt_isneg #1]#2.#3%
{%
   #3[#2]{\XINT_legacysignalcondition{InvalidOperation}
                        {Square root of negative: -#1].}{}{ 0[0]}}%
}%
%    \end{macrocode}
%\begin{lverb}
% calx (s58): the square root of the positive A[N] (rounded to P digits by
% \XINTinfloat) is calxfp's \CALX_fsqrt (correctly rounded, as before) on
% its exact F value (\CALX_ffromraw), back to raw by \CALX_ftoraw for the
% output wrapper #4 (\xintfloat or \XINTinfloatS) at P. The former
% \XINT_flsqrt* chain, which used xint's big integer square root, is
% deleted.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_FL_sqrt_pos #1[#2]#3.#4%
   {#4[#3]{\romannumeral0\CALX_ftoraw
     {\romannumeral0\CALX_fsqrt{#3}{\romannumeral0\CALX_ffromraw{#1[#2]}}}}}%
%    \end{macrocode}
% \subsection{\csh{xintFloatE}}
% \added{1.07}
%\begin{lverb}
% The fraction is the first argument contrarily to \xintTrunc and
% \xintRound.
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatE   {\romannumeral0\xintfloate }%
\def\xintfloate #1{\XINT_floate_chkopt #1\xint:}%
\def\XINT_floate_chkopt #1%
{%
    \ifx [#1\expandafter\XINT_floate_opt
       \else\expandafter\XINT_floate_noopt
    \fi  #1%
}%
\def\XINT_floate_noopt #1\xint:%
{%
    \expandafter\XINT_floate_post
    \romannumeral0\XINTinfloat[\XINTdigits]{#1}\XINTdigits.%
}%
\def\XINT_floate_opt [\xint:#1]%
{%
    \expandafter\XINT_floate_opt_a\the\numexpr #1.%
}%
\def\XINT_floate_opt_a #1.#2%
{%
    \expandafter\XINT_floate_post
    \romannumeral0\XINTinfloat[#1]{#2}#1.%
}%
\def\XINT_floate_post #1%
{%
    \xint_UDzerominusfork
      #1-\XINT_floate_zero
       0#1\XINT_floate_neg
       0-\XINT_floate_pos
    \krof #1%
}%[
\def\XINT_floate_zero #1]#2.#3{ 0.e0}%
\def\XINT_floate_neg-{\expandafter-\romannumeral0\XINT_floate_pos}%
\def\XINT_floate_pos #1#2[#3]#4.#5%
{%
    \expandafter\XINT_float_pos_done\the\numexpr#3+#4+#5-\xint_c_i.#1.#2;%
}%
%    \end{macrocode}
% \subsection{\csh{xintifFloatInt}}
% \added{1.3a}
%\begin{lverb}
% For ifint() function in \xintfloatexpr.
%\end{lverb}
%    \begin{macrocode}
\def\xintifFloatInt {\romannumeral0\xintiffloatint}%
\def\xintiffloatint #1{\expandafter\XINT_iffloatint
                       \romannumeral0\xintrez{\XINTinFloatS[\XINTdigits]{#1}}}%
\def\XINT_iffloatint #1#2/1[#3]%
{%
  \if 0#1\xint_dothis\xint_stop_atfirstoftwo\fi
  \ifnum#3<\xint_c_\xint_dothis\xint_stop_atsecondoftwo\fi
  \xint_orthat\xint_stop_atfirstoftwo
}%
%    \end{macrocode}
% \subsection{\csh{xintFloatIsInt}}
% \added{1.3d}
%\begin{lverb}
% For isint() function in \xintfloatexpr.
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatIsInt {\romannumeral0\xintfloatisint}%
\def\xintfloatisint #1{\expandafter\XINT_iffloatint
     \romannumeral0\xintrez{\XINTinFloatS[\XINTdigits]{#1}}10}%
%    \end{macrocode}
% \subsection{\csh{xintFloatIntType}}
% \added{1.4e}
%\begin{lverb}
% For fractional powers. Expands to \xint_c_mone if argument is not an
% integer, to \xint_c_ if it is an even integer and to \xint_c_i if it is an
% odd integer.
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatIntType {\romannumeral`&&@\xintfloatinttype}%
\def\xintfloatinttype #1%
{%
    \expandafter\XINT_floatinttype
    \romannumeral0\xintrez{\XINTinFloatS[\XINTdigits]{#1}}%
}%
\def\XINT_floatinttype #1#2/1[#3]%
{%
    \if 0#1\xint_dothis\xint_c_\fi
    \ifnum#3<\xint_c_\xint_dothis\xint_c_mone\fi
    \ifnum#3>\xint_c_\xint_dothis\xint_c_\fi
    \ifodd\xintLDg{#1#2} \xint_dothis\xint_c_i\fi
    \xint_orthat\xint_c_
}%
\XINTrestorecatcodesendinput%
%    \end{macrocode}
% \StoreCodelineNo {xintfrac}
% \cleardoublepage\let\xintfracnameUp\undefined
%\gardesactifs
%\let</xintfrac>\relax
%\let<*xintseries>\gardesinactifs
%</xintfrac>^^A---------------------------------------------------
%<*xintseries>^^A-------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname xintseriesnameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section{Package \xintseriesnameimp implementation}
% \RaisedLabel{sec:seriesimp}
%
% \localtableofcontents
%
% \subsection{Introduction}
%
% The commenting is currently (\xintbndldate) very sparse.
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
% The code for reload detection was initially copied from \textsc{Heiko
% Oberdiek}'s packages, then modified.
%
% The method for catcodes was also initially directly inspired by these
% packages.
%
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode64=11   % @
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \def\empty{}\def\space{ }\newlinechar10
  \def\z{\endgroup}%
  \expandafter\let\expandafter\x\csname ver@xintseries.sty\endcsname
  \expandafter\let\expandafter\w\csname ver@xintfrac.sty\endcsname
  \expandafter\ifx\csname numexpr\endcsname\relax
    \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax
      \immediate\write128{^^JPackage xintseries Warning:^^J%
                          \space\space\space\space
                          \numexpr not available, aborting input.^^J}%
    \else
      \PackageWarningNoLine{xintseries}{\numexpr not available, aborting input}%
    \fi
    \def\z{\endgroup\endinput}%
  \else
    \ifx\x\relax   % plain-TeX, first loading of xintseries.sty
      \ifx\w\relax % but xintfrac.sty not yet loaded.
         \def\z{\endgroup\input xintfrac.sty\relax}%
      \fi
    \else
      \ifx\x\empty % LaTeX, first loading,
      % variable is initialized, but \ProvidesPackage not yet seen
          \ifx\w\relax % xintfrac.sty not yet loaded.
            \def\z{\endgroup\RequirePackage{xintfrac}}%
          \fi
      \else
        \def\z{\endgroup\endinput}% xintseries already loaded.
      \fi
    \fi
  \fi
\z%
\XINTsetupcatcodes% defined in xintkernel.sty
%    \end{macrocode}
% \subsection{Package identification}
%    \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintseries}%
  [2026/11/01 v2.0a1 Expandable partial sums with xint package (JFB)]%
%    \end{macrocode}
% \subsection{\csh{xintSeries}}
%    \begin{macrocode}
\def\xintSeries {\romannumeral0\xintseries }%
\def\xintseries #1#2%
{%
    \expandafter\XINT_series\expandafter
    {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}%
}%
\def\XINT_series #1#2#3%
{%
   \ifnum #2<#1
      \xint_afterfi { 0/1[0]}%
   \else
      \xint_afterfi {\XINT_series_loop {#1}{0}{#2}{#3}}%
   \fi
}%
\def\XINT_series_loop #1#2#3#4%
{%
    \ifnum #3>#1 \else \XINT_series_exit \fi
    \expandafter\XINT_series_loop\expandafter
    {\the\numexpr #1+1\expandafter }\expandafter
    {\romannumeral0\xintadd {#2}{#4{#1}}}%
    {#3}{#4}%
}%
\def\XINT_series_exit \fi #1#2#3#4#5#6#7#8%
{%
    \fi\xint_gobble_ii #6%
}%
%    \end{macrocode}
% \subsection{\csh{xintiSeries}}
%    \begin{macrocode}
\def\xintiSeries {\romannumeral0\xintiseries }%
\def\xintiseries #1#2%
{%
    \expandafter\XINT_iseries\expandafter
    {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}%
}%
\def\XINT_iseries #1#2#3%
{%
   \ifnum #2<#1
      \xint_afterfi { 0}%
   \else
      \xint_afterfi {\XINT_iseries_loop {#1}{0}{#2}{#3}}%
   \fi
}%
\def\XINT_iseries_loop #1#2#3#4%
{%
    \ifnum #3>#1 \else \XINT_iseries_exit \fi
    \expandafter\XINT_iseries_loop\expandafter
    {\the\numexpr #1+1\expandafter }\expandafter
    {\romannumeral0\xintiiadd {#2}{#4{#1}}}%
    {#3}{#4}%
}%
\def\XINT_iseries_exit \fi #1#2#3#4#5#6#7#8%
{%
    \fi\xint_gobble_ii #6%
}%
%    \end{macrocode}
% \subsection{\csh{xintPowerSeries}}
%\begin{lverb}
% The 1.03 version was very lame and created a build-up of denominators.
% (this was at a time \xintAdd always multiplied denominators, by the way)
% The Horner scheme for polynomial evaluation is used in 1.04, this
% cures the denominator problem and drastically improves the efficiency
% of the macro.
% Modified in 1.06 to give the indices first to a \numexpr rather than expanding
% twice. I just use \the\numexpr and maintain the previous code after that.
% 1.08a adds the forgotten optimization following that previous change.
%\end{lverb}
%    \begin{macrocode}
\def\xintPowerSeries {\romannumeral0\xintpowerseries }%
\def\xintpowerseries #1#2%
{%
    \expandafter\XINT_powseries\expandafter
    {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}%
}%
\def\XINT_powseries #1#2#3#4%
{%
   \ifnum #2<#1
      \xint_afterfi { 0/1[0]}%
   \else
      \xint_afterfi
      {\XINT_powseries_loop_i {#3{#2}}{#1}{#2}{#3}{#4}}%
   \fi
}%
\def\XINT_powseries_loop_i #1#2#3#4#5%
{%
    \ifnum #3>#2 \else\XINT_powseries_exit_i\fi
    \expandafter\XINT_powseries_loop_ii\expandafter
    {\the\numexpr #3-1\expandafter}\expandafter
    {\romannumeral0\xintmul {#1}{#5}}{#2}{#4}{#5}%
}%
\def\XINT_powseries_loop_ii #1#2#3#4%
{%
   \expandafter\XINT_powseries_loop_i\expandafter
   {\romannumeral0\xintadd {#4{#1}}{#2}}{#3}{#1}{#4}%
}%
\def\XINT_powseries_exit_i\fi #1#2#3#4#5#6#7#8#9%
{%
    \fi \XINT_powseries_exit_ii  #6{#7}%
}%
\def\XINT_powseries_exit_ii #1#2#3#4#5#6%
{%
    \xintmul{\xintPow {#5}{#6}}{#4}%
}%
%    \end{macrocode}
% \subsection{\csh{xintPowerSeriesX}}
%\begin{lverb}
% Same as \xintPowerSeries except for the initial expansion of the x parameter.
% Modified in 1.06 to give the indices first to a \numexpr rather than expanding
% twice. I just use \the\numexpr and maintain the previous code after that.
% 1.08a adds the forgotten optimization following that previous change.
%\end{lverb}
%    \begin{macrocode}
\def\xintPowerSeriesX {\romannumeral0\xintpowerseriesx }%
\def\xintpowerseriesx #1#2%
{%
    \expandafter\XINT_powseriesx\expandafter
    {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}%
}%
\def\XINT_powseriesx #1#2#3#4%
{%
   \ifnum #2<#1
      \xint_afterfi { 0/1[0]}%
   \else
      \xint_afterfi
      {\expandafter\XINT_powseriesx_pre\expandafter
                  {\romannumeral`&&@#4}{#1}{#2}{#3}%
      }%
   \fi
}%
\def\XINT_powseriesx_pre #1#2#3#4%
{%
    \XINT_powseries_loop_i {#4{#3}}{#2}{#3}{#4}{#1}%
}%
%    \end{macrocode}
% \subsection{\csh{xintRationalSeries}}
%\begin{lverb}
% This computes F(a)+...+F(b) on the basis of the value of F(a) and the
% ratios F(n)/F(n-1). As in \xintPowerSeries we use an iterative scheme which
% has the great advantage to avoid denominator build-up. This makes exact
% computations possible with exponential type series, which would be completely
% inaccessible to \xintSeries.
% #1=a, #2=b, #3=F(a), #4=ratio function
% Modified in 1.06 to give the indices first to a \numexpr rather than expanding
% twice. I just use \the\numexpr and maintain the previous code after that.
% 1.08a adds the forgotten optimization following that previous change.
%\end{lverb}
%    \begin{macrocode}
\def\xintRationalSeries {\romannumeral0\xintratseries }%
\def\xintratseries #1#2%
{%
    \expandafter\XINT_ratseries\expandafter
    {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}%
}%
\def\XINT_ratseries #1#2#3#4%
{%
   \ifnum #2<#1
      \xint_afterfi { 0/1[0]}%
   \else
      \xint_afterfi
      {\XINT_ratseries_loop {#2}{1}{#1}{#4}{#3}}%
   \fi
}%
\def\XINT_ratseries_loop #1#2#3#4%
{%
    \ifnum #1>#3 \else\XINT_ratseries_exit_i\fi
    \expandafter\XINT_ratseries_loop\expandafter
    {\the\numexpr #1-1\expandafter}\expandafter
    {\romannumeral0\xintadd {1}{\xintMul {#2}{#4{#1}}}}{#3}{#4}%
}%
\def\XINT_ratseries_exit_i\fi #1#2#3#4#5#6#7#8%
{%
    \fi \XINT_ratseries_exit_ii  #6%
}%
\def\XINT_ratseries_exit_ii #1#2#3#4#5%
{%
    \XINT_ratseries_exit_iii #5%
}%
\def\XINT_ratseries_exit_iii #1#2#3#4%
{%
    \xintmul{#2}{#4}%
}%
%    \end{macrocode}
% \subsection{\csh{xintRationalSeriesX}}
%\begin{lverb}
% a,b,initial,ratiofunction,x$\
% This computes F(a,x)+...+F(b,x) on the basis of the value of F(a,x) and the
% ratios F(n,x)/F(n-1,x). The argument x is first expanded and it is the value
% resulting from this which is used then throughout. The initial term F(a,x)
% must be defined as one-parameter macro which will be given x.
% Modified in 1.06 to give the indices first to a \numexpr rather than expanding
% twice. I just use \the\numexpr and maintain the previous code after that.
% 1.08a adds the forgotten optimization following that previous change.
%\end{lverb}
%    \begin{macrocode}
\def\xintRationalSeriesX {\romannumeral0\xintratseriesx }%
\def\xintratseriesx #1#2%
{%
    \expandafter\XINT_ratseriesx\expandafter
    {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}%
}%
\def\XINT_ratseriesx #1#2#3#4#5%
{%
   \ifnum #2<#1
      \xint_afterfi { 0/1[0]}%
   \else
      \xint_afterfi
      {\expandafter\XINT_ratseriesx_pre\expandafter
                   {\romannumeral`&&@#5}{#2}{#1}{#4}{#3}%
      }%
   \fi
}%
\def\XINT_ratseriesx_pre #1#2#3#4#5%
{%
    \XINT_ratseries_loop {#2}{1}{#3}{#4{#1}}{#5{#1}}%
}%
%    \end{macrocode}
% \subsection{\csh{xintFxPtPowerSeries}}
%\begin{lverb}
% I am not two happy with this piece of code. Will make it more economical
% another day.
% Modified in 1.06 to give the indices first to a \numexpr rather than expanding
% twice. I just use \the\numexpr and maintain the previous code after that.
% 1.08a: forgot last time some optimization from the change to \numexpr.
%\end{lverb}
%    \begin{macrocode}
\def\xintFxPtPowerSeries {\romannumeral0\xintfxptpowerseries }%
\def\xintfxptpowerseries #1#2%
{%
    \expandafter\XINT_fppowseries\expandafter
    {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}%
}%
\def\XINT_fppowseries #1#2#3#4#5%
{%
   \ifnum #2<#1
      \xint_afterfi { 0}%
   \else
      \xint_afterfi
        {\expandafter\XINT_fppowseries_loop_pre\expandafter
           {\romannumeral0\xinttrunc {#5}{\xintPow {#4}{#1}}}%
          {#1}{#4}{#2}{#3}{#5}%
        }%
   \fi
}%
\def\XINT_fppowseries_loop_pre #1#2#3#4#5#6%
{%
    \ifnum #4>#2 \else\XINT_fppowseries_dont_i \fi
    \expandafter\XINT_fppowseries_loop_i\expandafter
    {\the\numexpr #2+\xint_c_i\expandafter}\expandafter
    {\romannumeral0\xintitrunc {#6}{\xintMul {#5{#2}}{#1}}}%
    {#1}{#3}{#4}{#5}{#6}%
}%
\def\XINT_fppowseries_dont_i \fi\expandafter\XINT_fppowseries_loop_i
    {\fi \expandafter\XINT_fppowseries_dont_ii }%
\def\XINT_fppowseries_dont_ii #1#2#3#4#5#6#7{\xinttrunc {#7}{#2[-#7]}}%
\def\XINT_fppowseries_loop_i #1#2#3#4#5#6#7%
{%
    \ifnum #5>#1 \else \XINT_fppowseries_exit_i \fi
    \expandafter\XINT_fppowseries_loop_ii\expandafter
    {\romannumeral0\xinttrunc {#7}{\xintMul {#3}{#4}}}%
    {#1}{#4}{#2}{#5}{#6}{#7}%
}%
\def\XINT_fppowseries_loop_ii #1#2#3#4#5#6#7%
{%
    \expandafter\XINT_fppowseries_loop_i\expandafter
    {\the\numexpr #2+\xint_c_i\expandafter}\expandafter
    {\romannumeral0\xintiiadd {#4}{\xintiTrunc {#7}{\xintMul {#6{#2}}{#1}}}}%
    {#1}{#3}{#5}{#6}{#7}%
}%
\def\XINT_fppowseries_exit_i\fi\expandafter\XINT_fppowseries_loop_ii
    {\fi \expandafter\XINT_fppowseries_exit_ii }%
\def\XINT_fppowseries_exit_ii #1#2#3#4#5#6#7%
{%
    \xinttrunc {#7}
    {\xintiiadd {#4}{\xintiTrunc {#7}{\xintMul {#6{#2}}{#1}}}[-#7]}%
}%
%    \end{macrocode}
% \subsection{\csh{xintFxPtPowerSeriesX}}
%\begin{lverb}
% a,b,coeff,x,D$\
% Modified in 1.06 to give the indices first to a \numexpr rather than expanding
% twice. I just use \the\numexpr and maintain the previous code after that.
% 1.08a adds the forgotten optimization following that previous change.
%\end{lverb}
%    \begin{macrocode}
\def\xintFxPtPowerSeriesX {\romannumeral0\xintfxptpowerseriesx }%
\def\xintfxptpowerseriesx #1#2%
{%
    \expandafter\XINT_fppowseriesx\expandafter
    {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}%
}%
\def\XINT_fppowseriesx #1#2#3#4#5%
{%
   \ifnum #2<#1
      \xint_afterfi { 0}%
   \else
      \xint_afterfi
        {\expandafter \XINT_fppowseriesx_pre \expandafter
         {\romannumeral`&&@#4}{#1}{#2}{#3}{#5}%
        }%
   \fi
}%
\def\XINT_fppowseriesx_pre #1#2#3#4#5%
{%
    \expandafter\XINT_fppowseries_loop_pre\expandafter
       {\romannumeral0\xinttrunc {#5}{\xintPow {#1}{#2}}}%
       {#2}{#1}{#3}{#4}{#5}%
}%
%    \end{macrocode}
% \subsection{\csh{xintFloatPowerSeries}}
%\begin{lverb}
% 1.08a. I still have to re-visit \xintFxPtPowerSeries; temporarily I
% just adapted the code to the case of floats.
%
% Usage of new names
% \XINTinfloatpow_wopt \XINTinfloatmul_wopt, \XINTinfloatadd_wopt to track
% xintfrac.sty changes at 1.4e.
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatPowerSeries {\romannumeral0\xintfloatpowerseries }%
\def\xintfloatpowerseries #1{\XINT_flpowseries_chkopt #1\xint:}%
\def\XINT_flpowseries_chkopt #1%
{%
    \ifx [#1\expandafter\XINT_flpowseries_opt
       \else\expandafter\XINT_flpowseries_noopt
    \fi
    #1%
}%
\def\XINT_flpowseries_noopt  #1\xint:#2%
{%
    \expandafter\XINT_flpowseries\expandafter
    {\the\numexpr #1\expandafter}\expandafter
    {\the\numexpr #2}\XINTdigits
}%
\def\XINT_flpowseries_opt [\xint:#1]#2#3%
{%
    \expandafter\XINT_flpowseries\expandafter
    {\the\numexpr #2\expandafter}\expandafter
    {\the\numexpr #3\expandafter}{\the\numexpr #1}%
}%
\def\XINT_flpowseries #1#2#3#4#5%
{%
   \ifnum #2<#1
      \xint_afterfi { 0.e0}%
   \else
      \xint_afterfi
        {\expandafter\XINT_flpowseries_loop_pre\expandafter
           {\romannumeral0\XINTinfloatpow_wopt[#3]{#5}{#1}}%
          {#1}{#5}{#2}{#4}{#3}%
        }%
   \fi
}%
\def\XINT_flpowseries_loop_pre #1#2#3#4#5#6%
{%
    \ifnum #4>#2 \else\XINT_flpowseries_dont_i \fi
    \expandafter\XINT_flpowseries_loop_i\expandafter
    {\the\numexpr #2+\xint_c_i\expandafter}\expandafter
    {\romannumeral0\XINTinfloatmul_wopt[#6]{#5{#2}}{#1}}%
    {#1}{#3}{#4}{#5}{#6}%
}%
\def\XINT_flpowseries_dont_i \fi\expandafter\XINT_flpowseries_loop_i
    {\fi \expandafter\XINT_flpowseries_dont_ii }%
\def\XINT_flpowseries_dont_ii #1#2#3#4#5#6#7{\xintfloat [#7]{#2}}%
\def\XINT_flpowseries_loop_i #1#2#3#4#5#6#7%
{%
    \ifnum #5>#1 \else \XINT_flpowseries_exit_i \fi
    \expandafter\XINT_flpowseries_loop_ii\expandafter
    {\romannumeral0\XINTinfloatmul_wopt[#7]{#3}{#4}}%
    {#1}{#4}{#2}{#5}{#6}{#7}%
}%
\def\XINT_flpowseries_loop_ii #1#2#3#4#5#6#7%
{%
    \expandafter\XINT_flpowseries_loop_i\expandafter
    {\the\numexpr #2+\xint_c_i\expandafter}\expandafter
    {\romannumeral0\XINTinfloatadd_wopt[#7]{#4}%
                        {\XINTinfloatmul_wopt[#7]{#6{#2}}{#1}}}%
    {#1}{#3}{#5}{#6}{#7}%
}%
\def\XINT_flpowseries_exit_i\fi\expandafter\XINT_flpowseries_loop_ii
    {\fi \expandafter\XINT_flpowseries_exit_ii }%
\def\XINT_flpowseries_exit_ii #1#2#3#4#5#6#7%
{%
    \xintfloatadd[#7]{#4}{\XINTinfloatmul_wopt[#7]{#6{#2}}{#1}}%
}%
%    \end{macrocode}
% \subsection{\csh{xintFloatPowerSeriesX}}
%\begin{lverb}
% 1.08a
%
% See \xintFloatPowerSeries for 1.4e comments.
%\end{lverb}
%    \begin{macrocode}
\def\xintFloatPowerSeriesX {\romannumeral0\xintfloatpowerseriesx }%
\def\xintfloatpowerseriesx #1{\XINT_flpowseriesx_chkopt #1\xint:}%
\def\XINT_flpowseriesx_chkopt #1%
{%
    \ifx [#1\expandafter\XINT_flpowseriesx_opt
       \else\expandafter\XINT_flpowseriesx_noopt
    \fi
    #1%
}%
\def\XINT_flpowseriesx_noopt  #1\xint:#2%
{%
    \expandafter\XINT_flpowseriesx\expandafter
    {\the\numexpr #1\expandafter}\expandafter
    {\the\numexpr #2}\XINTdigits
}%
\def\XINT_flpowseriesx_opt [\xint:#1]#2#3%
{%
    \expandafter\XINT_flpowseriesx\expandafter
    {\the\numexpr #2\expandafter}\expandafter
    {\the\numexpr #3\expandafter}{\the\numexpr #1}%
}%
\def\XINT_flpowseriesx #1#2#3#4#5%
{%
   \ifnum #2<#1
      \xint_afterfi { 0.e0}%
   \else
      \xint_afterfi
        {\expandafter \XINT_flpowseriesx_pre \expandafter
         {\romannumeral`&&@#5}{#1}{#2}{#4}{#3}%
        }%
   \fi
}%
\def\XINT_flpowseriesx_pre #1#2#3#4#5%
{%
    \expandafter\XINT_flpowseries_loop_pre\expandafter
       {\romannumeral0\XINTinfloatpow_wopt[#5]{#1}{#2}}%
       {#2}{#1}{#3}{#4}{#5}%
}%
\XINTrestorecatcodesendinput%
%    \end{macrocode}
% \StoreCodelineNo {xintseries}
% \cleardoublepage\let\xintseriesnameUp\undefined
%\gardesactifs
%\let</xintseries>\relax
%\let<*xintcfrac>\gardesinactifs
%</xintseries>^^A-------------------------------------------------
%<*xintcfrac>^^A--------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname xintcfracnameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section{Package \xintcfracnameimp implementation}
% \RaisedLabel{sec:cfracimp}
%
% \localtableofcontents
%
% \subsection{Introduction}
%
% The commenting is currently (\xintbndldate) very sparse. Release |1.09m|
% (|2014/02/26|) has modified a few things: |\xintFtoCs| and
% |\xintCntoCs| insert spaces after the commas, |\xintCstoF| and
% |\xintCstoCv| authorize spaces in the input also before the commas,
% |\xintCntoCs| does not brace the produced coefficients, new macros
% |\xintFtoC|, |\xintCtoF|, |\xintCtoCv|, |\xintFGtoC|, and
% |\xintGGCFrac|.
%
% The macros |\xintCstoF| and |\xintCstoCv| use \xinttoolsnameimp's
% \csbxint{CSVtoList}.  Formerly, it was up to user to load \xinttoolsnameimp
% to enable these macros.  Starting at |1.4n| the loading is automatic.
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
% The code for reload detection was initially copied from \textsc{Heiko
% Oberdiek}'s packages, then modified.
%
% The method for catcodes was also initially directly inspired by these
% packages.
%
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode64=11   % @
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \def\empty{}\def\space{ }\newlinechar10
  \def\z{\endgroup}%
  \expandafter\let\expandafter\x\csname ver@xintcfrac.sty\endcsname
  \expandafter\let\expandafter\w\csname ver@xintfrac.sty\endcsname
  \expandafter\let\expandafter\t\csname ver@xinttools.sty\endcsname
  \expandafter\ifx\csname numexpr\endcsname\relax
    \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax
      \immediate\write128{^^JPackage xintcfrac Warning:^^J%
                          \space\space\space\space
                          \numexpr not available, aborting input.^^J}%
    \else
      \PackageWarningNoLine{xintcfrac}{\numexpr not available, aborting input}%
    \fi
    \def\z{\endgroup\endinput}%
  \else
    \ifx\x\relax   % not LaTeX, first loading of xintcfrac.sty
      \ifx\w\relax % but xintfrac.sty not yet loaded.
         \expandafter\def\expandafter\z\expandafter
                    {\z\input xintfrac.sty\relax}%
      \fi
      \ifx\t\relax % but xinttools.sty not yet loaded.
         \expandafter\def\expandafter\z\expandafter
                    {\z\input xinttools.sty\relax}%
      \fi
    \else
      \ifx\x\empty % LaTeX, first loading,
      % variable is initialized, but \ProvidesPackage not yet seen
          \ifx\w\relax % xintfrac not yet loaded.
            \expandafter\def\expandafter\z\expandafter
                           {\z\RequirePackage{xintfrac}}%
          \fi
          \ifx\t\relax % xinttools not yet loaded.
            \expandafter\def\expandafter\z\expandafter
                           {\z\RequirePackage{xinttools}}%
          \fi
      \else
        \def\z{\endgroup\endinput}% xintcfrac already loaded.
      \fi
    \fi
  \fi
\z%
\XINTsetupcatcodes% defined in xintkernel.sty
%    \end{macrocode}
% \subsection{Package identification}
%    \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintcfrac}%
  [2026/11/01 v2.0a1 Expandable continued fractions with xint package (JFB)]%
%    \end{macrocode}
% \subsection{\csh{xintCFrac}}
%    \begin{macrocode}
\def\xintCFrac {\romannumeral0\xintcfrac }%
\def\xintcfrac #1%
{%
    \XINT_cfrac_opt_a #1\xint:
}%
\def\XINT_cfrac_opt_a #1%
{%
    \ifx[#1\XINT_cfrac_opt_b\fi \XINT_cfrac_noopt #1%
}%
\def\XINT_cfrac_noopt #1\xint:
{%
    \expandafter\XINT_cfrac_A\romannumeral0\xintrawwithzeros {#1}\Z
    \relax\relax
}%
\def\XINT_cfrac_opt_b\fi\XINT_cfrac_noopt [\xint:#1]%
{%
    \fi\csname XINT_cfrac_opt#1\endcsname
}%
\def\XINT_cfrac_optl #1%
{%
    \expandafter\XINT_cfrac_A\romannumeral0\xintrawwithzeros {#1}\Z
    \relax\hfill
}%
\def\XINT_cfrac_optc #1%
{%
    \expandafter\XINT_cfrac_A\romannumeral0\xintrawwithzeros {#1}\Z
    \relax\relax
}%
\def\XINT_cfrac_optr #1%
{%
    \expandafter\XINT_cfrac_A\romannumeral0\xintrawwithzeros {#1}\Z
    \hfill\relax
}%
\def\XINT_cfrac_A #1/#2\Z
{%
    \expandafter\XINT_cfrac_B\romannumeral0\xintiidivision {#1}{#2}{#2}%
}%
\def\XINT_cfrac_B #1#2%
{%
    \XINT_cfrac_C #2\Z {#1}%
}%
\def\XINT_cfrac_C #1%
{%
    \xint_gob_til_zero #1\XINT_cfrac_integer 0\XINT_cfrac_D #1%
}%
\def\XINT_cfrac_integer 0\XINT_cfrac_D 0#1\Z #2#3#4#5{ #2}%
\def\XINT_cfrac_D #1\Z #2#3{\XINT_cfrac_loop_a {#1}{#3}{#1}{{#2}}}%
\def\XINT_cfrac_loop_a
{%
    \expandafter\XINT_cfrac_loop_d\romannumeral0\XINT_ndivrawpair
}%
\def\XINT_cfrac_loop_d #1#2%
{%
    \XINT_cfrac_loop_e #2.{#1}%
}%
\def\XINT_cfrac_loop_e #1%
{%
    \xint_gob_til_zero #1\xint_cfrac_loop_exit0\XINT_cfrac_loop_f #1%
}%
\def\XINT_cfrac_loop_f #1.#2#3#4%
{%
    \XINT_cfrac_loop_a {#1}{#3}{#1}{{#2}#4}%
}%
\def\xint_cfrac_loop_exit0\XINT_cfrac_loop_f #1.#2#3#4#5#6%
   {\XINT_cfrac_T #5#6{#2}#4\Z }%
\def\XINT_cfrac_T #1#2#3#4%
{%
  \xint_gob_til_Z #4\XINT_cfrac_end\Z\XINT_cfrac_T #1#2{#4+\cfrac{#11#2}{#3}}%
}%
\def\XINT_cfrac_end\Z\XINT_cfrac_T #1#2#3%
{%
    \XINT_cfrac_end_b #3%
}%
\def\XINT_cfrac_end_b \Z+\cfrac#1#2{ #2}%
%    \end{macrocode}
% \subsection{\csh{xintGCFrac}}
% Updated at |1.4g| to follow-up on renaming of |\xintFrac| into |\xintTeXFrac|.
%    \begin{macrocode}
\def\xintGCFrac {\romannumeral0\xintgcfrac }%
\def\xintgcfrac #1{\XINT_gcfrac_opt_a #1\xint:}%
\def\XINT_gcfrac_opt_a #1%
{%
    \ifx[#1\XINT_gcfrac_opt_b\fi \XINT_gcfrac_noopt #1%
}%
\def\XINT_gcfrac_noopt #1\xint:%
{%
    \XINT_gcfrac #1+!/\relax\relax
}%
\def\XINT_gcfrac_opt_b\fi\XINT_gcfrac_noopt [\xint:#1]%
{%
    \fi\csname XINT_gcfrac_opt#1\endcsname
}%
\def\XINT_gcfrac_optl #1%
{%
    \XINT_gcfrac #1+!/\relax\hfill
}%
\def\XINT_gcfrac_optc #1%
{%
    \XINT_gcfrac #1+!/\relax\relax
}%
\def\XINT_gcfrac_optr #1%
{%
    \XINT_gcfrac #1+!/\hfill\relax
}%
\def\XINT_gcfrac
{%
    \expandafter\XINT_gcfrac_enter\romannumeral`&&@%
}%
\def\XINT_gcfrac_enter {\XINT_gcfrac_loop {}}%
\def\XINT_gcfrac_loop #1#2+#3/%
{%
    \xint_gob_til_exclam #3\XINT_gcfrac_endloop!%
    \XINT_gcfrac_loop {{#3}{#2}#1}%
}%
\def\XINT_gcfrac_endloop!\XINT_gcfrac_loop #1#2#3%
{%
    \XINT_gcfrac_T #2#3#1!!%
}%
\def\XINT_gcfrac_T #1#2#3#4{\XINT_gcfrac_U #1#2{\xintTeXFrac{#4}}}%
\def\XINT_gcfrac_U #1#2#3#4#5%
{%
    \xint_gob_til_exclam #5\XINT_gcfrac_end!\XINT_gcfrac_U
              #1#2{\xintTeXFrac{#5}%
               \ifcase\xintSgn{#4}
               +\or+\else-\fi
               \cfrac{#1\xintTeXFrac{\xintAbs{#4}}#2}{#3}}%
}%
\def\XINT_gcfrac_end!\XINT_gcfrac_U #1#2#3%
{%
    \XINT_gcfrac_end_b #3%
}%
\def\XINT_gcfrac_end_b #1\cfrac#2#3{ #3}%
%    \end{macrocode}
% \subsection{\csh{xintGGCFrac}}
%\begin{lverb}
% New with 1.09m
%\end{lverb}
%    \begin{macrocode}
\def\xintGGCFrac {\romannumeral0\xintggcfrac }%
\def\xintggcfrac #1{\XINT_ggcfrac_opt_a #1\xint:}%
\def\XINT_ggcfrac_opt_a #1%
{%
    \ifx[#1\XINT_ggcfrac_opt_b\fi \XINT_ggcfrac_noopt #1%
}%
\def\XINT_ggcfrac_noopt #1\xint:
{%
    \XINT_ggcfrac #1+!/\relax\relax
}%
\def\XINT_ggcfrac_opt_b\fi\XINT_ggcfrac_noopt [\xint:#1]%
{%
    \fi\csname XINT_ggcfrac_opt#1\endcsname
}%
\def\XINT_ggcfrac_optl #1%
{%
    \XINT_ggcfrac #1+!/\relax\hfill
}%
\def\XINT_ggcfrac_optc #1%
{%
    \XINT_ggcfrac #1+!/\relax\relax
}%
\def\XINT_ggcfrac_optr #1%
{%
    \XINT_ggcfrac #1+!/\hfill\relax
}%
\def\XINT_ggcfrac
{%
    \expandafter\XINT_ggcfrac_enter\romannumeral`&&@%
}%
\def\XINT_ggcfrac_enter {\XINT_ggcfrac_loop {}}%
\def\XINT_ggcfrac_loop #1#2+#3/%
{%
    \xint_gob_til_exclam #3\XINT_ggcfrac_endloop!%
    \XINT_ggcfrac_loop {{#3}{#2}#1}%
}%
\def\XINT_ggcfrac_endloop!\XINT_ggcfrac_loop #1#2#3%
{%
    \XINT_ggcfrac_T #2#3#1!!%
}%
\def\XINT_ggcfrac_T #1#2#3#4{\XINT_ggcfrac_U #1#2{#4}}%
\def\XINT_ggcfrac_U #1#2#3#4#5%
{%
    \xint_gob_til_exclam #5\XINT_ggcfrac_end!\XINT_ggcfrac_U
              #1#2{#5+\cfrac{#1#4#2}{#3}}%
}%
\def\XINT_ggcfrac_end!\XINT_ggcfrac_U #1#2#3%
{%
    \XINT_ggcfrac_end_b #3%
}%
\def\XINT_ggcfrac_end_b #1\cfrac#2#3{ #3}%
%    \end{macrocode}
% \subsection{\csh{xintGCtoGCx}}
%    \begin{macrocode}
\def\xintGCtoGCx {\romannumeral0\xintgctogcx }%
\def\xintgctogcx #1#2#3%
{%
    \expandafter\XINT_gctgcx_start\expandafter {\romannumeral`&&@#3}{#1}{#2}%
}%
\def\XINT_gctgcx_start #1#2#3{\XINT_gctgcx_loop_a {}{#2}{#3}#1+!/}%
\def\XINT_gctgcx_loop_a #1#2#3#4+#5/%
{%
    \xint_gob_til_exclam #5\XINT_gctgcx_end!%
    \XINT_gctgcx_loop_b {#1{#4}}{#2{#5}#3}{#2}{#3}%
}%
\def\XINT_gctgcx_loop_b #1#2%
{%
    \XINT_gctgcx_loop_a {#1#2}%
}%
\def\XINT_gctgcx_end!\XINT_gctgcx_loop_b #1#2#3#4{ #1}%
%    \end{macrocode}
% \subsection{\csh{xintFtoCs}}
%\begin{lverb}
% Modified in 1.09m: a space is added after the inserted commas.
%\end{lverb}
%    \begin{macrocode}
\def\xintFtoCs {\romannumeral0\xintftocs }%
\def\xintftocs #1%
{%
    \expandafter\XINT_ftc_A\romannumeral0\xintrawwithzeros {#1}\Z
}%
\def\XINT_ftc_A #1/#2\Z
{%
    \expandafter\XINT_ftc_B\romannumeral0\xintiidivision {#1}{#2}{#2}%
}%
\def\XINT_ftc_B #1#2%
{%
    \XINT_ftc_C #2.{#1}%
}%
\def\XINT_ftc_C #1%
{%
    \xint_gob_til_zero #1\XINT_ftc_integer 0\XINT_ftc_D #1%
}%
\def\XINT_ftc_integer 0\XINT_ftc_D 0#1.#2#3{ #2}%
\def\XINT_ftc_D #1.#2#3{\XINT_ftc_loop_a {#1}{#3}{#1}{#2, }}% 1.09m adds a space
\def\XINT_ftc_loop_a
{%
    \expandafter\XINT_ftc_loop_d\romannumeral0\XINT_ndivrawpair
}%
\def\XINT_ftc_loop_d #1#2%
{%
    \XINT_ftc_loop_e #2.{#1}%
}%
\def\XINT_ftc_loop_e #1%
{%
    \xint_gob_til_zero #1\xint_ftc_loop_exit0\XINT_ftc_loop_f #1%
}%
\def\XINT_ftc_loop_f #1.#2#3#4%
{%
    \XINT_ftc_loop_a {#1}{#3}{#1}{#4#2, }% 1.09m has an added space here
}%
\def\xint_ftc_loop_exit0\XINT_ftc_loop_f #1.#2#3#4{ #4#2}%
%    \end{macrocode}
% \subsection{\csh{xintFtoCx}}
%    \begin{macrocode}
\def\xintFtoCx {\romannumeral0\xintftocx }%
\def\xintftocx #1#2%
{%
    \expandafter\XINT_ftcx_A\romannumeral0\xintrawwithzeros {#2}\Z {#1}%
}%
\def\XINT_ftcx_A #1/#2\Z
{%
    \expandafter\XINT_ftcx_B\romannumeral0\xintiidivision {#1}{#2}{#2}%
}%
\def\XINT_ftcx_B #1#2%
{%
    \XINT_ftcx_C #2.{#1}%
}%
\def\XINT_ftcx_C #1%
{%
    \xint_gob_til_zero #1\XINT_ftcx_integer 0\XINT_ftcx_D #1%
}%
\def\XINT_ftcx_integer 0\XINT_ftcx_D 0#1.#2#3#4{ #2}%
\def\XINT_ftcx_D #1.#2#3#4{\XINT_ftcx_loop_a {#1}{#3}{#1}{{#2}#4}{#4}}%
\def\XINT_ftcx_loop_a
{%
    \expandafter\XINT_ftcx_loop_d\romannumeral0\XINT_ndivrawpair
}%
\def\XINT_ftcx_loop_d #1#2%
{%
    \XINT_ftcx_loop_e #2.{#1}%
}%
\def\XINT_ftcx_loop_e #1%
{%
    \xint_gob_til_zero #1\xint_ftcx_loop_exit0\XINT_ftcx_loop_f #1%
}%
\def\XINT_ftcx_loop_f #1.#2#3#4#5%
{%
    \XINT_ftcx_loop_a {#1}{#3}{#1}{#4{#2}#5}{#5}%
}%
\def\xint_ftcx_loop_exit0\XINT_ftcx_loop_f #1.#2#3#4#5{ #4{#2}}%
%    \end{macrocode}
% \subsection{\csh{xintFtoC}}
%\begin{lverb}
% New in 1.09m: this is the same as \xintFtoCx with empty separator. I
% had temporarily during preparation of 1.09m removed braces from \xintFtoCx,
% but I recalled later why that was useful (see doc), thus let's just here do
% \xintFtoCx {}
%\end{lverb}
%    \begin{macrocode}
\def\xintFtoC {\romannumeral0\xintftoc }%
\def\xintftoc {\xintftocx {}}%
%    \end{macrocode}
% \subsection{\csh{xintFtoGC}}
%    \begin{macrocode}
\def\xintFtoGC {\romannumeral0\xintftogc }%
\def\xintftogc {\xintftocx {+1/}}%
%    \end{macrocode}
% \subsection{\csh{xintFGtoC}}
%\begin{lverb}
% New with 1.09m of 2014/02/26. Computes the common initial coefficients
% for the two fractions f and g, and outputs them as a sequence of braced
% items.
%\end{lverb}
%    \begin{macrocode}
\def\xintFGtoC {\romannumeral0\xintfgtoc}%
\def\xintfgtoc#1%
{%
    \expandafter\XINT_fgtc_a\romannumeral0\xintrawwithzeros {#1}\Z
}%
\def\XINT_fgtc_a #1/#2\Z #3%
{%
    \expandafter\XINT_fgtc_b\romannumeral0\xintrawwithzeros {#3}\Z #1/#2\Z { }%
}%
\def\XINT_fgtc_b #1/#2\Z
{%
    \expandafter\XINT_fgtc_c\romannumeral0\xintiidivision {#1}{#2}{#2}%
}%
\def\XINT_fgtc_c #1#2#3#4/#5\Z
{%
    \expandafter\XINT_fgtc_d\romannumeral0\xintiidivision
                                         {#4}{#5}{#5}{#1}{#2}{#3}%
}%
\def\XINT_fgtc_d #1#2#3#4%#5#6#7%
{%
    \xintifEq {#1}{#4}{\XINT_fgtc_da {#1}{#2}{#3}{#4}}%
                      {\xint_thirdofthree}%
}%
\def\XINT_fgtc_da #1#2#3#4#5#6#7%
{%
     \XINT_fgtc_e {#2}{#5}{#3}{#6}{#7{#1}}%
}%
\def\XINT_fgtc_e #1%
{%
    \xintiiifZero {#1}{\expandafter\xint_firstofone\xint_gobble_iii}%
                    {\XINT_fgtc_f {#1}}%
}%
\def\XINT_fgtc_f #1#2%
{%
   \xintiiifZero {#2}{\xint_thirdofthree}{\XINT_fgtc_g {#1}{#2}}%
}%
\def\XINT_fgtc_g #1#2#3%
{%
    \expandafter\XINT_fgtc_h\romannumeral0\XINT_ndivrawpair {#1}{#3}{#1}{#2}%
}%
\def\XINT_fgtc_h #1#2#3#4#5%
{%
    \expandafter\XINT_fgtc_d\romannumeral0\XINT_ndivrawpair
                       {#4}{#5}{#4}{#1}{#2}{#3}%
}%
%    \end{macrocode}
% \subsection{\csh{xintFtoCC}}
%    \begin{macrocode}
\def\xintFtoCC {\romannumeral0\xintftocc }%
\def\xintftocc #1%
{%
    \expandafter\XINT_ftcc_A\expandafter {\romannumeral0\xintrawwithzeros {#1}}%
}%
\def\XINT_ftcc_A #1%
{%
    \expandafter\XINT_ftcc_B
    \romannumeral0\xintrawwithzeros {\xintAdd {1/2[0]}{#1[0]}}\Z {#1[0]}%
}%
\def\XINT_ftcc_B #1/#2\Z
{%
    \expandafter\XINT_ftcc_C\expandafter {\romannumeral0\xintiiquo {#1}{#2}}%
}%
\def\XINT_ftcc_C #1#2%
{%
    \expandafter\XINT_ftcc_D\romannumeral0\xintsub {#2}{#1}\Z {#1}%
}%
\def\XINT_ftcc_D #1%
{%
    \xint_UDzerominusfork
      #1-\XINT_ftcc_integer
      0#1\XINT_ftcc_En
       0-{\XINT_ftcc_Ep #1}%
    \krof
}%
\def\XINT_ftcc_Ep #1\Z #2%
{%
    \expandafter\XINT_ftcc_loop_a\expandafter
    {\romannumeral0\xintdiv {1[0]}{#1}}{#2+1/}%
}%
\def\XINT_ftcc_En #1\Z #2%
{%
    \expandafter\XINT_ftcc_loop_a\expandafter
    {\romannumeral0\xintdiv {1[0]}{#1}}{#2+-1/}%
}%
\def\XINT_ftcc_integer #1\Z #2{ #2}%
\def\XINT_ftcc_loop_a #1%
{%
    \expandafter\XINT_ftcc_loop_b
    \romannumeral0\xintrawwithzeros {\xintAdd {1/2[0]}{#1}}\Z {#1}%
}%
\def\XINT_ftcc_loop_b #1/#2\Z
{%
    \expandafter\XINT_ftcc_loop_c\expandafter
    {\romannumeral0\xintiiquo {#1}{#2}}%
}%
\def\XINT_ftcc_loop_c #1#2%
{%
    \expandafter\XINT_ftcc_loop_d
    \romannumeral0\xintsub {#2}{#1[0]}\Z {#1}%
}%
\def\XINT_ftcc_loop_d #1%
{%
    \xint_UDzerominusfork
      #1-\XINT_ftcc_end
      0#1\XINT_ftcc_loop_N
       0-{\XINT_ftcc_loop_P #1}%
    \krof
}%
\def\XINT_ftcc_end #1\Z #2#3{ #3#2}%
\def\XINT_ftcc_loop_P #1\Z #2#3%
{%
    \expandafter\XINT_ftcc_loop_a\expandafter
    {\romannumeral0\xintdiv {1[0]}{#1}}{#3#2+1/}%
}%
\def\XINT_ftcc_loop_N #1\Z #2#3%
{%
    \expandafter\XINT_ftcc_loop_a\expandafter
    {\romannumeral0\xintdiv {1[0]}{#1}}{#3#2+-1/}%
}%
%    \end{macrocode}
% \subsection{\csh{xintCtoF}, \csh{xintCstoF}}
%
% |1.09m| uses \xinttoolsnameimp's \csbxint{CSVtoList} on the argument of
% \csbxint{CstoF} to allow spaces also before the commas. And the original
% \csbxint{CstoF} code became the one of the new \csbxint{CtoF} dealing with a
% braced rather than comma separated list.
%    \begin{macrocode}
\def\xintCstoF {\romannumeral0\xintcstof }%
\def\xintcstof #1%
{%
    \expandafter\XINT_ctf_prep \romannumeral0\xintcsvtolist{#1}!%
}%
\def\xintCtoF {\romannumeral0\xintctof }%
\def\xintctof #1%
{%
    \expandafter\XINT_ctf_prep \romannumeral`&&@#1!%
}%
\def\XINT_ctf_prep
{%
    \XINT_ctf_loop_a 1001%
}%
\def\XINT_ctf_loop_a #1#2#3#4#5%
{%
    \xint_gob_til_exclam #5\XINT_ctf_end!%
    \expandafter\XINT_ctf_loop_b
    \romannumeral0\xintrawwithzeros {#5}.{#1}{#2}{#3}{#4}%
}%
\def\XINT_ctf_loop_b #1/#2.#3#4#5#6%
{%
    \expandafter\XINT_ctf_loop_c\expandafter
    {\romannumeral0\xintiimul{#2}{#4}}%
    {\romannumeral0\xintiimul{#2}{#3}}%
    {\romannumeral0\xintiiadd {\xintiimul{#2}{#6}}%
                              {\xintiimul{#1}{#4}}}%
    {\romannumeral0\xintiiadd {\xintiimul{#2}{#5}}%
                              {\xintiimul{#1}{#3}}}%
}%
\def\XINT_ctf_loop_c #1#2%
{%
    \expandafter\XINT_ctf_loop_d\expandafter {\expandafter{#2}{#1}}%
}%
\def\XINT_ctf_loop_d #1#2%
{%
    \expandafter\XINT_ctf_loop_e\expandafter {\expandafter{#2}#1}%
}%
\def\XINT_ctf_loop_e #1#2%
{%
    \expandafter\XINT_ctf_loop_a\expandafter{#2}#1%
}%
\def\XINT_ctf_end #1.#2#3#4#5{\xintrawwithzeros {#2/#3}}% 1.09b removes [0]
%    \end{macrocode}
% \subsection{\csh{xintiCstoF}}
%    \begin{macrocode}
\def\xintiCstoF {\romannumeral0\xinticstof }%
\def\xinticstof #1%
{%
    \expandafter\XINT_icstf_prep \romannumeral`&&@#1,!,%
}%
\def\XINT_icstf_prep
{%
    \XINT_icstf_loop_a 1001%
}%
\def\XINT_icstf_loop_a #1#2#3#4#5,%
{%
    \xint_gob_til_exclam #5\XINT_icstf_end!%
    \expandafter
    \XINT_icstf_loop_b \romannumeral`&&@#5.{#1}{#2}{#3}{#4}%
}%
\def\XINT_icstf_loop_b #1.#2#3#4#5%
{%
    \expandafter\XINT_icstf_loop_c\expandafter
    {\romannumeral0\xintiiadd {#5}{\xintiimul{#1}{#3}}}%
    {\romannumeral0\xintiiadd {#4}{\xintiimul{#1}{#2}}}%
    {#2}{#3}%
}%
\def\XINT_icstf_loop_c #1#2%
{%
    \expandafter\XINT_icstf_loop_a\expandafter {#2}{#1}%
}%
\def\XINT_icstf_end#1.#2#3#4#5{\xintrawwithzeros {#2/#3}}% 1.09b removes [0]
%    \end{macrocode}
% \subsection{\csh{xintGCtoF}}
%    \begin{macrocode}
\def\xintGCtoF {\romannumeral0\xintgctof }%
\def\xintgctof #1%
{%
    \expandafter\XINT_gctf_prep \romannumeral`&&@#1+!/%
}%
\def\XINT_gctf_prep
{%
    \XINT_gctf_loop_a 1001%
}%
\def\XINT_gctf_loop_a #1#2#3#4#5+%
{%
    \expandafter\XINT_gctf_loop_b
    \romannumeral0\xintrawwithzeros {#5}.{#1}{#2}{#3}{#4}%
}%
\def\XINT_gctf_loop_b #1/#2.#3#4#5#6%
{%
    \expandafter\XINT_gctf_loop_c\expandafter
    {\romannumeral0\xintiimul{#2}{#4}}%
    {\romannumeral0\xintiimul{#2}{#3}}%
    {\romannumeral0\xintiiadd {\xintiimul{#2}{#6}}%
                              {\xintiimul{#1}{#4}}}%
    {\romannumeral0\xintiiadd {\xintiimul{#2}{#5}}%
                              {\xintiimul{#1}{#3}}}%
}%
\def\XINT_gctf_loop_c #1#2%
{%
    \expandafter\XINT_gctf_loop_d\expandafter {\expandafter{#2}{#1}}%
}%
\def\XINT_gctf_loop_d #1#2%
{%
    \expandafter\XINT_gctf_loop_e\expandafter {\expandafter{#2}#1}%
}%
\def\XINT_gctf_loop_e #1#2%
{%
    \expandafter\XINT_gctf_loop_f\expandafter {\expandafter{#2}#1}%
}%
\def\XINT_gctf_loop_f #1#2/%
{%
    \xint_gob_til_exclam #2\XINT_gctf_end!%
    \expandafter\XINT_gctf_loop_g
    \romannumeral0\xintrawwithzeros {#2}.#1%
}%
\def\XINT_gctf_loop_g #1/#2.#3#4#5#6%
{%
    \expandafter\XINT_gctf_loop_h\expandafter
    {\romannumeral0\xintiimul{#1}{#6}}%
    {\romannumeral0\xintiimul{#1}{#5}}%
    {\romannumeral0\xintiimul{#2}{#4}}%
    {\romannumeral0\xintiimul{#2}{#3}}%
}%
\def\XINT_gctf_loop_h #1#2%
{%
    \expandafter\XINT_gctf_loop_i\expandafter {\expandafter{#2}{#1}}%
}%
\def\XINT_gctf_loop_i #1#2%
{%
    \expandafter\XINT_gctf_loop_j\expandafter {\expandafter{#2}#1}%
}%
\def\XINT_gctf_loop_j #1#2%
{%
    \expandafter\XINT_gctf_loop_a\expandafter {#2}#1%
}%
\def\XINT_gctf_end #1.#2#3#4#5{\xintrawwithzeros {#2/#3}}% 1.09b removes [0]
%    \end{macrocode}
% \subsection{\csh{xintiGCtoF}}
%    \begin{macrocode}
\def\xintiGCtoF {\romannumeral0\xintigctof }%
\def\xintigctof #1%
{%
    \expandafter\XINT_igctf_prep \romannumeral`&&@#1+!/%
}%
\def\XINT_igctf_prep
{%
    \XINT_igctf_loop_a 1001%
}%
\def\XINT_igctf_loop_a #1#2#3#4#5+%
{%
    \expandafter\XINT_igctf_loop_b
    \romannumeral`&&@#5.{#1}{#2}{#3}{#4}%
}%
\def\XINT_igctf_loop_b #1.#2#3#4#5%
{%
    \expandafter\XINT_igctf_loop_c\expandafter
    {\romannumeral0\xintiiadd {#5}{\xintiimul{#1}{#3}}}%
    {\romannumeral0\xintiiadd {#4}{\xintiimul{#1}{#2}}}%
    {#2}{#3}%
}%
\def\XINT_igctf_loop_c #1#2%
{%
    \expandafter\XINT_igctf_loop_f\expandafter {\expandafter{#2}{#1}}%
}%
\def\XINT_igctf_loop_f #1#2#3#4/%
{%
    \xint_gob_til_exclam #4\XINT_igctf_end!%
    \expandafter\XINT_igctf_loop_g
    \romannumeral`&&@#4.{#2}{#3}#1%
}%
\def\XINT_igctf_loop_g #1.#2#3%
{%
    \expandafter\XINT_igctf_loop_h\expandafter
    {\romannumeral0\xintiimul{#1}{#3}}%
    {\romannumeral0\xintiimul{#1}{#2}}%
}%
\def\XINT_igctf_loop_h #1#2%
{%
    \expandafter\XINT_igctf_loop_i\expandafter {#2}{#1}%
}%
\def\XINT_igctf_loop_i #1#2#3#4%
{%
    \XINT_igctf_loop_a {#3}{#4}{#1}{#2}%
}%
\def\XINT_igctf_end #1.#2#3#4#5{\xintrawwithzeros {#4/#5}}% 1.09b removes [0]
%    \end{macrocode}
% \subsection{\csh{xintCtoCv}, \csh{xintCstoCv}}
%
% |1.09m| uses \xinttoolsnameimp's \csbxint{CSVtoList} on the argument of
% \csbxint{CstoCv} to allow spaces also before the commas. The original
% \csbxint{CstoCv} code became the one of the new \csbxint{CtoF} dealing with
% a braced rather than comma separated list.
%    \begin{macrocode}
\def\xintCstoCv {\romannumeral0\xintcstocv }%
\def\xintcstocv #1%
{%
    \expandafter\XINT_ctcv_prep\romannumeral0\xintcsvtolist{#1}!%
}%
\def\xintCtoCv {\romannumeral0\xintctocv }%
\def\xintctocv #1%
{%
    \expandafter\XINT_ctcv_prep\romannumeral`&&@#1!%
}%
\def\XINT_ctcv_prep
{%
    \XINT_ctcv_loop_a {}1001%
}%
\def\XINT_ctcv_loop_a #1#2#3#4#5#6%
{%
    \xint_gob_til_exclam #6\XINT_ctcv_end!%
    \expandafter\XINT_ctcv_loop_b
    \romannumeral0\xintrawwithzeros {#6}.{#2}{#3}{#4}{#5}{#1}%
}%
\def\XINT_ctcv_loop_b #1/#2.#3#4#5#6%
{%
    \expandafter\XINT_ctcv_loop_c\expandafter
    {\romannumeral0\xintiimul{#2}{#4}}%
    {\romannumeral0\xintiimul{#2}{#3}}%
    {\romannumeral0\xintiiadd {\xintiimul{#2}{#6}}%
                              {\xintiimul{#1}{#4}}}%
    {\romannumeral0\xintiiadd {\xintiimul{#2}{#5}}%
                              {\xintiimul{#1}{#3}}}%
}%
\def\XINT_ctcv_loop_c #1#2%
{%
    \expandafter\XINT_ctcv_loop_d\expandafter {\expandafter{#2}{#1}}%
}%
\def\XINT_ctcv_loop_d #1#2%
{%
    \expandafter\XINT_ctcv_loop_e\expandafter {\expandafter{#2}#1}%
}%
\def\XINT_ctcv_loop_e #1#2%
{%
    \expandafter\XINT_ctcv_loop_f\expandafter{#2}#1%
}%
\def\XINT_ctcv_loop_f #1#2#3#4#5%
{%
    \expandafter\XINT_ctcv_loop_g\expandafter
    {\romannumeral0\xintrawwithzeros {#1/#2}}{#5}{#1}{#2}{#3}{#4}%
}%
\def\XINT_ctcv_loop_g #1#2{\XINT_ctcv_loop_a {#2{#1}}}% 1.09b removes [0]
\def\XINT_ctcv_end #1.#2#3#4#5#6{ #6}%
%    \end{macrocode}
% \subsection{\csh{xintiCstoCv}}
%    \begin{macrocode}
\def\xintiCstoCv {\romannumeral0\xinticstocv }%
\def\xinticstocv #1%
{%
    \expandafter\XINT_icstcv_prep \romannumeral`&&@#1,!,%
}%
\def\XINT_icstcv_prep
{%
    \XINT_icstcv_loop_a {}1001%
}%
\def\XINT_icstcv_loop_a #1#2#3#4#5#6,%
{%
    \xint_gob_til_exclam #6\XINT_icstcv_end!%
    \expandafter
    \XINT_icstcv_loop_b \romannumeral`&&@#6.{#2}{#3}{#4}{#5}{#1}%
}%
\def\XINT_icstcv_loop_b #1.#2#3#4#5%
{%
    \expandafter\XINT_icstcv_loop_c\expandafter
    {\romannumeral0\xintiiadd {#5}{\xintiimul{#1}{#3}}}%
    {\romannumeral0\xintiiadd {#4}{\xintiimul{#1}{#2}}}%
    {{#2}{#3}}%
}%
\def\XINT_icstcv_loop_c #1#2%
{%
    \expandafter\XINT_icstcv_loop_d\expandafter {#2}{#1}%
}%
\def\XINT_icstcv_loop_d #1#2%
{%
    \expandafter\XINT_icstcv_loop_e\expandafter
    {\romannumeral0\xintrawwithzeros {#1/#2}}{{#1}{#2}}%
}%
\def\XINT_icstcv_loop_e #1#2#3#4{\XINT_icstcv_loop_a {#4{#1}}#2#3}%
\def\XINT_icstcv_end #1.#2#3#4#5#6{ #6}%  1.09b removes [0]
%    \end{macrocode}
% \subsection{\csh{xintGCtoCv}}
%    \begin{macrocode}
\def\xintGCtoCv {\romannumeral0\xintgctocv }%
\def\xintgctocv #1%
{%
    \expandafter\XINT_gctcv_prep \romannumeral`&&@#1+!/%
}%
\def\XINT_gctcv_prep
{%
    \XINT_gctcv_loop_a {}1001%
}%
\def\XINT_gctcv_loop_a #1#2#3#4#5#6+%
{%
    \expandafter\XINT_gctcv_loop_b
    \romannumeral0\xintrawwithzeros {#6}.{#2}{#3}{#4}{#5}{#1}%
}%
\def\XINT_gctcv_loop_b #1/#2.#3#4#5#6%
{%
    \expandafter\XINT_gctcv_loop_c\expandafter
    {\romannumeral0\xintiimul{#2}{#4}}%
    {\romannumeral0\xintiimul{#2}{#3}}%
    {\romannumeral0\xintiiadd {\xintiimul{#2}{#6}}%
                              {\xintiimul{#1}{#4}}}%
    {\romannumeral0\xintiiadd {\xintiimul{#2}{#5}}%
                              {\xintiimul{#1}{#3}}}%
}%
\def\XINT_gctcv_loop_c #1#2%
{%
    \expandafter\XINT_gctcv_loop_d\expandafter {\expandafter{#2}{#1}}%
}%
\def\XINT_gctcv_loop_d #1#2%
{%
    \expandafter\XINT_gctcv_loop_e\expandafter {\expandafter{#2}{#1}}%
}%
\def\XINT_gctcv_loop_e #1#2%
{%
    \expandafter\XINT_gctcv_loop_f\expandafter {#2}#1%
}%
\def\XINT_gctcv_loop_f #1#2%
{%
    \expandafter\XINT_gctcv_loop_g\expandafter
    {\romannumeral0\xintrawwithzeros {#1/#2}}{{#1}{#2}}%
}%
\def\XINT_gctcv_loop_g #1#2#3#4%
{%
    \XINT_gctcv_loop_h {#4{#1}}{#2#3}% 1.09b removes [0]
}%
\def\XINT_gctcv_loop_h #1#2#3/%
{%
    \xint_gob_til_exclam #3\XINT_gctcv_end!%
    \expandafter\XINT_gctcv_loop_i
    \romannumeral0\xintrawwithzeros {#3}.#2{#1}%
}%
\def\XINT_gctcv_loop_i #1/#2.#3#4#5#6%
{%
    \expandafter\XINT_gctcv_loop_j\expandafter
    {\romannumeral0\xintiimul{#1}{#6}}%
    {\romannumeral0\xintiimul{#1}{#5}}%
    {\romannumeral0\xintiimul{#2}{#4}}%
    {\romannumeral0\xintiimul{#2}{#3}}%
}%
\def\XINT_gctcv_loop_j #1#2%
{%
    \expandafter\XINT_gctcv_loop_k\expandafter {\expandafter{#2}{#1}}%
}%
\def\XINT_gctcv_loop_k #1#2%
{%
    \expandafter\XINT_gctcv_loop_l\expandafter {\expandafter{#2}#1}%
}%
\def\XINT_gctcv_loop_l #1#2%
{%
    \expandafter\XINT_gctcv_loop_m\expandafter {\expandafter{#2}#1}%
}%
\def\XINT_gctcv_loop_m #1#2{\XINT_gctcv_loop_a {#2}#1}%
\def\XINT_gctcv_end #1.#2#3#4#5#6{ #6}%
%    \end{macrocode}
% \subsection{\csh{xintiGCtoCv}}
%    \begin{macrocode}
\def\xintiGCtoCv {\romannumeral0\xintigctocv }%
\def\xintigctocv #1%
{%
    \expandafter\XINT_igctcv_prep \romannumeral`&&@#1+!/%
}%
\def\XINT_igctcv_prep
{%
    \XINT_igctcv_loop_a {}1001%
}%
\def\XINT_igctcv_loop_a #1#2#3#4#5#6+%
{%
    \expandafter\XINT_igctcv_loop_b
    \romannumeral`&&@#6.{#2}{#3}{#4}{#5}{#1}%
}%
\def\XINT_igctcv_loop_b #1.#2#3#4#5%
{%
    \expandafter\XINT_igctcv_loop_c\expandafter
    {\romannumeral0\xintiiadd {#5}{\xintiimul{#1}{#3}}}%
    {\romannumeral0\xintiiadd {#4}{\xintiimul{#1}{#2}}}%
    {{#2}{#3}}%
}%
\def\XINT_igctcv_loop_c #1#2%
{%
    \expandafter\XINT_igctcv_loop_f\expandafter {\expandafter{#2}{#1}}%
}%
\def\XINT_igctcv_loop_f #1#2#3#4/%
{%
    \xint_gob_til_exclam #4\XINT_igctcv_end_a!%
    \expandafter\XINT_igctcv_loop_g
    \romannumeral`&&@#4.#1#2{#3}%
}%
\def\XINT_igctcv_loop_g #1.#2#3#4#5%
{%
    \expandafter\XINT_igctcv_loop_h\expandafter
    {\romannumeral0\xintiimul{#1}{#5}}%
    {\romannumeral0\xintiimul{#1}{#4}}%
    {{#2}{#3}}%
}%
\def\XINT_igctcv_loop_h #1#2%
{%
    \expandafter\XINT_igctcv_loop_i\expandafter {\expandafter{#2}{#1}}%
}%
\def\XINT_igctcv_loop_i #1#2{\XINT_igctcv_loop_k #2{#2#1}}%
\def\XINT_igctcv_loop_k #1#2%
{%
    \expandafter\XINT_igctcv_loop_l\expandafter
    {\romannumeral0\xintrawwithzeros {#1/#2}}%
}%
\def\XINT_igctcv_loop_l #1#2#3{\XINT_igctcv_loop_a {#3{#1}}#2}%1.09i removes [0]
\def\XINT_igctcv_end_a #1.#2#3#4#5%
{%
    \expandafter\XINT_igctcv_end_b\expandafter
    {\romannumeral0\xintrawwithzeros {#2/#3}}%
}%
\def\XINT_igctcv_end_b #1#2{ #2{#1}}% 1.09b removes [0]
%    \end{macrocode}
% \subsection{\csh{xintFtoCv}}
%\begin{lverb}
% Still uses \xinticstocv \xintFtoCs rather than \xintctocv \xintFtoC.
%\end{lverb}
%    \begin{macrocode}
\def\xintFtoCv {\romannumeral0\xintftocv }%
\def\xintftocv #1%
{%
    \xinticstocv {\xintFtoCs {#1}}%
}%
%    \end{macrocode}
% \subsection{\csh{xintFtoCCv}}
%    \begin{macrocode}
\def\xintFtoCCv {\romannumeral0\xintftoccv }%
\def\xintftoccv #1%
{%
    \xintigctocv {\xintFtoCC {#1}}%
}%
%    \end{macrocode}
% \subsection{\csh{xintCntoF}}
%\begin{lverb}
% Modified in 1.06 to give the N first to a \numexpr rather than expanding
% twice. I just use \the\numexpr and maintain the previous code after that.
%\end{lverb}
%    \begin{macrocode}
\def\xintCntoF {\romannumeral0\xintcntof }%
\def\xintcntof #1%
{%
    \expandafter\XINT_cntf\expandafter {\the\numexpr #1}%
}%
\def\XINT_cntf #1#2%
{%
   \ifnum #1>\xint_c_
      \xint_afterfi {\expandafter\XINT_cntf_loop\expandafter
                     {\the\numexpr #1-1\expandafter}\expandafter
                     {\romannumeral`&&@#2{#1}}{#2}}%
   \else
      \xint_afterfi
         {\ifnum #1=\xint_c_
              \xint_afterfi {\expandafter\space \romannumeral`&&@#2{0}}%
          \else \xint_afterfi { }% 1.09m now returns nothing.
          \fi}%
   \fi
}%
\def\XINT_cntf_loop #1#2#3%
{%
    \ifnum #1>\xint_c_ \else \XINT_cntf_exit \fi
    \expandafter\XINT_cntf_loop\expandafter
    {\the\numexpr #1-1\expandafter }\expandafter
    {\romannumeral0\xintadd {\xintDiv {1[0]}{#2}}{#3{#1}}}%
    {#3}%
}%
\def\XINT_cntf_exit \fi
    \expandafter\XINT_cntf_loop\expandafter
    #1\expandafter #2#3%
{%
    \fi\xint_gobble_ii #2%
}%
%    \end{macrocode}
% \subsection{\csh{xintGCntoF}}
%\begin{lverb}
% Modified in 1.06 to give the N argument first to a \numexpr rather
% than expanding twice. I just use \the\numexpr and maintain the previous code
% after that.
%\end{lverb}
%    \begin{macrocode}
\def\xintGCntoF {\romannumeral0\xintgcntof }%
\def\xintgcntof #1%
{%
    \expandafter\XINT_gcntf\expandafter {\the\numexpr #1}%
}%
\def\XINT_gcntf #1#2#3%
{%
   \ifnum #1>\xint_c_
      \xint_afterfi {\expandafter\XINT_gcntf_loop\expandafter
                     {\the\numexpr #1-1\expandafter}\expandafter
                     {\romannumeral`&&@#2{#1}}{#2}{#3}}%
   \else
      \xint_afterfi
         {\ifnum #1=\xint_c_
              \xint_afterfi {\expandafter\space\romannumeral`&&@#2{0}}%
          \else \xint_afterfi { }% 1.09m now returns nothing rather than 0/1[0]
          \fi}%
   \fi
}%
\def\XINT_gcntf_loop #1#2#3#4%
{%
    \ifnum #1>\xint_c_ \else \XINT_gcntf_exit \fi
    \expandafter\XINT_gcntf_loop\expandafter
    {\the\numexpr #1-1\expandafter }\expandafter
    {\romannumeral0\xintadd {\xintDiv {#4{#1}}{#2}}{#3{#1}}}%
    {#3}{#4}%
}%
\def\XINT_gcntf_exit \fi
    \expandafter\XINT_gcntf_loop\expandafter
    #1\expandafter #2#3#4%
{%
    \fi\xint_gobble_ii #2%
}%
%    \end{macrocode}
% \subsection{\csh{xintCntoCs}}
%\begin{lverb}
% Modified in 1.09m: added spaces after the commas in the produced list.
% Moreover the coefficients are not braced anymore. A slight induced limitation
% is that the macro argument should not contain some explicit comma (cf.
% \XINT_cntcs_exit_b), hence \xintCntoCs {\macro,} with \def\macro,#1{<stuff>}
% would crash. Not a very serious limitation, I believe. 
%\end{lverb}
%    \begin{macrocode}
\def\xintCntoCs {\romannumeral0\xintcntocs }%
\def\xintcntocs #1%
{%
    \expandafter\XINT_cntcs\expandafter {\the\numexpr #1}%
}%
\def\XINT_cntcs #1#2%
{%
   \ifnum #1<0
      \xint_afterfi { }% 1.09i: a 0/1[0] was here, now the macro returns nothing
   \else
      \xint_afterfi {\expandafter\XINT_cntcs_loop\expandafter
                     {\the\numexpr #1-\xint_c_i\expandafter}\expandafter
                     {\romannumeral`&&@#2{#1}}{#2}}% produced coeff not braced
   \fi
}%
\def\XINT_cntcs_loop #1#2#3%
{%
    \ifnum #1>-\xint_c_i \else \XINT_cntcs_exit \fi
    \expandafter\XINT_cntcs_loop\expandafter
    {\the\numexpr #1-\xint_c_i\expandafter}\expandafter
    {\romannumeral`&&@#3{#1}, #2}{#3}% space added, 1.09m
}%
\def\XINT_cntcs_exit \fi
    \expandafter\XINT_cntcs_loop\expandafter
    #1\expandafter #2#3%
{%
    \fi\XINT_cntcs_exit_b #2%
}%
\def\XINT_cntcs_exit_b #1,{}% romannumeral stopping space already there
%    \end{macrocode}
% \subsection{\csh{xintCntoGC}}
%\begin{lverb}
% Modified in 1.06 to give the N first to a \numexpr rather than expanding
% twice. I just use \the\numexpr and maintain the previous code after that.
%
% 1.09m maintains the braces, as the coeff are allowed to be fraction and the
% slash can not be naked in the GC format, contrarily to what happens in
% \xintCntoCs. Also the separators given to \xintGCtoGCx may then fetch the
% coefficients as argument, as they are braced.
%\end{lverb}
%    \begin{macrocode}
\def\xintCntoGC {\romannumeral0\xintcntogc }%
\def\xintcntogc #1%
{%
    \expandafter\XINT_cntgc\expandafter {\the\numexpr #1}%
}%
\def\XINT_cntgc #1#2%
{%
   \ifnum #1<0
      \xint_afterfi { }% 1.09i there was as strange 0/1[0] here, removed
   \else
      \xint_afterfi {\expandafter\XINT_cntgc_loop\expandafter
                     {\the\numexpr #1-\xint_c_i\expandafter}\expandafter
                     {\expandafter{\romannumeral`&&@#2{#1}}}{#2}}%
   \fi
}%
\def\XINT_cntgc_loop #1#2#3%
{%
    \ifnum #1>-\xint_c_i \else \XINT_cntgc_exit \fi
    \expandafter\XINT_cntgc_loop\expandafter
    {\the\numexpr #1-\xint_c_i\expandafter }\expandafter
    {\expandafter{\romannumeral`&&@#3{#1}}+1/#2}{#3}%
}%
\def\XINT_cntgc_exit \fi
    \expandafter\XINT_cntgc_loop\expandafter
    #1\expandafter #2#3%
{%
    \fi\XINT_cntgc_exit_b #2%
}%
\def\XINT_cntgc_exit_b #1+1/{ }%
%    \end{macrocode}
% \subsection{\csh{xintGCntoGC}}
%\begin{lverb}
% Modified in 1.06 to give the N first to a \numexpr rather than expanding
% twice. I just use \the\numexpr and maintain the previous code after that.
%\end{lverb}
%    \begin{macrocode}
\def\xintGCntoGC {\romannumeral0\xintgcntogc }%
\def\xintgcntogc #1%
{%
    \expandafter\XINT_gcntgc\expandafter {\the\numexpr #1}%
}%
\def\XINT_gcntgc #1#2#3%
{%
   \ifnum #1<0
      \xint_afterfi { }% 1.09i now returns nothing
   \else
      \xint_afterfi {\expandafter\XINT_gcntgc_loop\expandafter
                     {\the\numexpr #1-\xint_c_i\expandafter}\expandafter
                     {\expandafter{\romannumeral`&&@#2{#1}}}{#2}{#3}}%
   \fi
}%
\def\XINT_gcntgc_loop #1#2#3#4%
{%
    \ifnum #1>-\xint_c_i \else \XINT_gcntgc_exit \fi
    \expandafter\XINT_gcntgc_loop_b\expandafter
    {\expandafter{\romannumeral`&&@#4{#1}}/#2}{#3{#1}}{#1}{#3}{#4}%
}%
\def\XINT_gcntgc_loop_b #1#2#3%
{%
    \expandafter\XINT_gcntgc_loop\expandafter
    {\the\numexpr #3-\xint_c_i \expandafter}\expandafter
    {\expandafter{\romannumeral`&&@#2}+#1}%
}%
\def\XINT_gcntgc_exit \fi
    \expandafter\XINT_gcntgc_loop_b\expandafter #1#2#3#4#5%
{%
    \fi\XINT_gcntgc_exit_b #1%
}%
\def\XINT_gcntgc_exit_b #1/{ }%
%    \end{macrocode}
% \subsection{\csh{xintCstoGC}}
%    \begin{macrocode}
\def\xintCstoGC {\romannumeral0\xintcstogc }%
\def\xintcstogc #1%
{%
    \expandafter\XINT_cstc_prep \romannumeral`&&@#1,!,%
}%
\def\XINT_cstc_prep #1,{\XINT_cstc_loop_a {{#1}}}%
\def\XINT_cstc_loop_a #1#2,%
{%
    \xint_gob_til_exclam #2\XINT_cstc_end!%
    \XINT_cstc_loop_b {#1}{#2}%
}%
\def\XINT_cstc_loop_b #1#2{\XINT_cstc_loop_a {#1+1/{#2}}}%
\def\XINT_cstc_end!\XINT_cstc_loop_b #1#2{ #1}%
%    \end{macrocode}
% \subsection{\csh{xintGCtoGC}}
%    \begin{macrocode}
\def\xintGCtoGC {\romannumeral0\xintgctogc }%
\def\xintgctogc #1%
{%
    \expandafter\XINT_gctgc_start \romannumeral`&&@#1+!/%
}%
\def\XINT_gctgc_start {\XINT_gctgc_loop_a {}}%
\def\XINT_gctgc_loop_a #1#2+#3/%
{%
    \xint_gob_til_exclam #3\XINT_gctgc_end!%
    \expandafter\XINT_gctgc_loop_b\expandafter
    {\romannumeral`&&@#2}{#3}{#1}%
}%
\def\XINT_gctgc_loop_b #1#2%
{%
    \expandafter\XINT_gctgc_loop_c\expandafter
    {\romannumeral`&&@#2}{#1}%
}%
\def\XINT_gctgc_loop_c #1#2#3%
{%
    \XINT_gctgc_loop_a {#3{#2}+{#1}/}%
}%
\def\XINT_gctgc_end!\expandafter\XINT_gctgc_loop_b
{%
    \expandafter\XINT_gctgc_end_b
}%
\def\XINT_gctgc_end_b #1#2#3{ #3{#1}}%
\XINTrestorecatcodesendinput%
%    \end{macrocode}
% \StoreCodelineNo {xintcfrac}
% \cleardoublepage\let\xintcfracnameUp\undefined
%\gardesactifs
%\let</xintcfrac>\relax
%\let<*xintexpr>\gardesinactifs
%</xintcfrac>^^A--------------------------------------------------
%<*xintexpr>^^A---------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1)
% \clearpage\csname xintexprnameUp\endcsname
% \let\MakePrivateLetters\xintexprMakePrivateLetters
% \section{Package \xintexprnameimp implementation}
% \RaisedLabel{sec:exprimp}
% \addedcalx{2.0a1}
%
% \localtableofcontents
%
% xintexpr.sty: **WIP**
% Currently an empty wrapper loading calx.sty and xintfrac.sty.
% In future |\xinteval| will be defined by this file not by calx.sty.
%
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode64=11   % @
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \catcode35=6    % #
  \def\odef#1{\expandafter\def\expandafter#1\expandafter}%
  \def\empty{}\def\space{ }\newlinechar10
  \def\z{\endgroup}%
  \expandafter\let\expandafter\x\csname ver@xintexpr.sty\endcsname
  \expandafter\let\expandafter\f\csname ver@xintfrac.sty\endcsname
  \expandafter\let\expandafter\c\csname ver@calx.sty\endcsname
  % I assume engines do not exist providing \expanded but not \numexpr
  \expandafter\ifx\csname expanded\endcsname\relax
    \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax
      \immediate\write128{^^JPackage xintexpr Warning:^^J%
                          \space\space\space\space
                          \expanded not available, aborting input.^^J}%
    \else
      \PackageWarningNoLine{xintexpr}{\expanded not available, aborting input}%
    \fi
    \def\z{\endgroup\endinput}%
  \else
    \ifx\x\relax   % not LaTeX (perhaps Plain+miniltx), first loading of xintexpr.sty
      \ifx\c\relax % but calx.sty not yet loaded.
         \odef\z{\z\input calx.sty\relax}%
      \fi
      \ifx\f\relax % but xintfrac.sty not yet loaded (made miniltx robust 2022/06/09)
         \odef\z{\z\input xintfrac.sty\relax}%
      \fi
    \else
      \ifx\x\empty % LaTeX, first loading,
      % variable is initialized, but \ProvidesPackage not yet seen
          \ifx\c\relax % calx not yet loaded.
            \odef\z{\z\RequirePackage{calx}}%
          \fi
          \ifx\f\relax % xintfrac not yet loaded.
            \odef\z{\z\RequirePackage{xintfrac}}%
          \fi
      \else
        \def\z{\endgroup\endinput}% xintexpr already loaded.
      \fi
    \fi
  \fi
\z%
\XINTsetupcatcodes%
%    \end{macrocode}
% \subsection{Package identification}
%    \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{xintexpr}%
  [2026/11/01 v2.0a1 Expandable fp, bigint and fraction expression parsers (JFB)]%
\catcode`! 11
%    \end{macrocode}
% \subsection{\csh{XINTinFloatdigits}, \csh{XINTinFloatSdigits}}
%    \begin{macrocode}
\def\XINTinFloatdigits {\XINTinFloat [\XINTdigits]}%
\def\XINTinFloatSdigits{\XINTinFloatS[\XINTdigits]}%
%    \end{macrocode}
% \subsection{Top level user \TeX{} interface: \cshnolabel{xinteval}}
% \localtableofcontents
% \subsubsection{\csh{xintexpr}, \csh{xintiexpr}}
%\begin{lverb}
%
% \xintiexpr has an optional argument since 1.1.
%
% ATTENTION! 1.3d renamed $string$xinteval$space to \xintexpro etc...
% (thus this old $string$xinteval$space isn't our current \xinteval).
%
%
% Usage of \xintiRound{0} for \xintiexpr without optional [D] means that
% \xintiexpr ... \relax wrapper can be used to insert rounded-to-integers
% values in \xintiiexpr context: no post-fix [0] which would break it.
% ^^^^^^ REVISE THE ABOVE BECAUSE NOW WE HAVE [0] ^^^^^
%
% 1.4a add support for the optional argument [D] for \xintiexpr being negative
% D, with same meaning as the 1.4a modified \xintRound from xintfrac.sty.
%
% \xintiexpr mechanism was refactored at 1.4e so that rounding due to [D]
% optional argument uses raw format, not fixed point format on output,
% delegating fixed point conversion to an \XINTiexprprint now separated from
% \XINTexprprint.
%
% In case of negative [D], \xintiexpr [D]...\relax internally has the [0]
% post-fix so it can not be inserted as sub-expression in \xintiiexpr without
% a num() or \xintiexpr ...\relax (extra) wrapper.
%
%\end{lverb}
%
% \changed{1.4o}
%    \begin{macrocode}
\def\xintexpr       {\romannumeral0\xintexpro      }%
\def\xintiexpr      {\romannumeral0\xintiexpro     }%
\def\xintexpro   {\csname XINT_expr_wrap\expandafter\endcsname
                  \romannumeral0\xintbareeval }%
\def\xintiexpro #1%
{%
    \ifx [#1\expandafter\XINT_iexpr_withopt\else\expandafter\XINT_iexpr_noopt
    \fi #1%
}%
\def\XINT_iexpr_noopt
{%
    \csname XINT_iexpr_iiround\expandafter\endcsname\romannumeral0\xintbareeval
}%
\def\XINT_iexpr_iiround
{%
    \expandafter\XINT_expr_wrap
    \expanded
    \XINT:NEhook:x:mapwithin\XINT:expr:mapwithin{\XINTiRoundzero_braced}%
}%
%    \end{macrocode}
% FIX THIS (for calx 2.0a1)
%    \begin{macrocode}
\def\XINTiRoundzero_braced#1{{\xintiRound{0}{#1}}}%
\def\XINT_iexpr_withopt [#1]%
{%
    \csname XINT_iexpr_round\expandafter\endcsname
    \the\numexpr \xint_zapspaces #1 \xint_gobble_i\expandafter.%
    \romannumeral0\xintbareeval
}%
\def\XINT_iexpr_round #1.%
{%
    \ifnum#1=\xint_c_\xint_dothis{\XINT_iexpr_iiround}\fi
    \xint_orthat{\XINT_iexpr_round_a #1.}%
}%
\def\XINT_iexpr_round_a #1.%
{%
    \expandafter\XINT_iexpr_wrap
    \expanded
    \XINT:NEhook:x:mapwithin\XINT:expr:mapwithin{\XINTiRound_braced{#1}}%
}%
\def\XINTiRound_braced#1#2%
  {{\xintiRound{#1}{#2}[\the\numexpr\ifnum#1<\xint_c_i0\else-#1\fi]}}%
%    \end{macrocode}
% \subsubsection{\csh{XINT_expr_wrap},
%                \csh{XINT_iexpr_wrap}}
%\begin{lverb}
% 1.3e removes some leading space tokens which served nothing.
%
% 1.4e has \XINT_iexpr_wrap separated from \XINT_expr_wrap, thus simplifying
% internal matters as output printer for \xintexpr will not have to handle
% fixed point input but only extended-raw type input (i.e. A, A/B, A[N] or A/B[N]).
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_wrap   {\XINTfstop\XINTexprprint.}%
\def\XINT_iexpr_wrap  {\XINTfstop\XINTiexprprint.}%
%    \end{macrocode}
% \subsubsection{\csh{XINTexprprint}, \csh{XINTiexprprint}}
% \label{\xintimplabelprefix xintexprPrintOne}
% \label{\xintimplabelprefix xintiexprPrintOne}
% See comments in \calxnameimp.
%    \begin{macrocode}
\protected\def\XINTexprprint.%
    {\XINT:NEhook:x:toblist\XINT:expr:toblistwith\xintexprPrintOne}%
\protected\def\XINTiexprprint.%
    {\XINT:NEhook:x:toblist\XINT:expr:toblistwith\xintiexprPrintOne}%
\let\xintiexprPrintOne\xintDecToString
\protected\def\XINTboolexprprint.%
    {\XINT:NEhook:x:toblist\XINT:expr:toblistwith\xintboolexprPrintOne}%
\def\xintboolexprPrintOne#1{\calxifNotZero{#1}{true}{false}}%
%    \end{macrocode}
% \subsubsection{\csh{xinttheexpr}, \csh{xinttheiexpr}}
% See comments in \calxnameimp.
%
%    \begin{macrocode}
\def\xinttheexpr
   {\expanded\csname XINTexprprint\expandafter\endcsname
    \expandafter.\romannumeral0\xintbareeval}%
\def\xinttheiexpr{\expanded\expandafter\xint_gobble_i\romannumeral0\xintiexpro}%
%    \end{macrocode}
% \subsubsection{\csh{xintbareeval}}
% See comments in \calxnameimp.
%    \begin{macrocode}
\def\xintbareeval     {\XINT_expr_start  }%
%    \end{macrocode}
% \subsubsection{\csh{xintthebareeval}}
% See comments in \calxnameimp.
%    \begin{macrocode}
\def\xintthebareeval{%
  \romannumeral0\csname xint_firstofone\expandafter\endcsname
  \romannumeral0\xintbareeval
}%
%    \end{macrocode}
% \subsubsection{\csh{xinteval}, \csh{xintieval}}
% See comments in \calxnameimp.
%    \begin{macrocode}
\def\xinteval #1{%
    \expanded\csname XINTexprprint\expandafter\endcsname
    \expandafter.\romannumeral0\xintbareeval#1\relax
}%
%    \end{macrocode}
% Should I use |#{| rather delimited argument? (as for \csbxint{iieval} at |1.4n|).
%    \begin{macrocode}
\def\xintieval{\expanded\expandafter\xint_ieval_chkopt\string}%
\def\xint_ieval_chkopt #1%
{%
    \ifx [#1\expandafter\xint_ieval_opt
       \else\expandafter\xint_ieval_noopt
    \fi  #1%
}%
%    \end{macrocode}
% \changed{1.4p} Here too I don't know why I had been using
% |\romannumeral`&&@\xintiexpr|.  Replaced with |\romannumeral0\xintiexpro|.
% And I couldn't resist the temptation to immediately jump to |_withopt|.
% I did resist replacing |_withopt| with its expansion... this expansion
% will inject the |\csname| for Babel.
%    \begin{macrocode}
\def\xint_ieval_opt [#1]#2{%
    \expandafter\xint_gobble_i\romannumeral0\XINT_iexpr_withopt[#1]#2\relax
}%
\def\xint_ieval_noopt #1{\expandafter\xint_ieval\expandafter{\iffalse}\fi}%
%    \end{macrocode}
% Attention that here the optional argument can come from the expression itself
% (legacy syntax).
%    \begin{macrocode}
\def\xint_ieval#1{%
    \expandafter\xint_gobble_i\romannumeral0\xintiexpro#1\relax
}%
%    \end{macrocode}
% \subsubsection{\csh{xintboolexpr}, \csh{XINT_boolexpr_print}, \csh{xinttheboolexpr}}
%\begin{lverb}
% Attention, the conversion to 1 or 0 is done only by the print macro.
% Perhaps I should force it also inside raw result.
%\end{lverb}
%    \begin{macrocode}
\def\xintboolexpr{%
    \romannumeral0\expandafter\XINT_boolexpr_done\romannumeral0\xintexpro
}%
\def\XINT_boolexpr_done #1.{\XINTfstop\XINTboolexprprint.}%
%    \end{macrocode}
% \changed{1.4o} A |\csname| for |\xinttheboolexpr| for Babel.
%    \begin{macrocode}
\def\xinttheboolexpr{%
    \expanded\csname XINTboolexprprint\expandafter\endcsname
    \expandafter.\romannumeral0\xintbareeval
}%
%    \end{macrocode}
% \subsubsection{\csh{xintifboolexpr}}
% See comments in \calxnameimp.
% FIXME CHECK STATUS OF |\xintiiifnotzero| WHOSE USAGE HERE WAS AN ABUSE
% ORIGINALLY
%    \begin{macrocode}
\def\xintifboolexpr #1{%
    \romannumeral0\expandafter\CALX_ifnz
    \romannumeral0\csname xint_firstofone\expandafter\endcsname
    \romannumeral0\xintbareeval #1\relax
}%
%    \end{macrocode}
% \subsubsection{\csh{xintifsgnexpr}}
%    \begin{macrocode}
\def\xintifsgnexpr #1{%
    \romannumeral0\expandafter\CALX_ifsgn
    \romannumeral0\csname xint_firstofone\expandafter\endcsname
    \romannumeral0\xintbareeval #1\relax
}%
%    \end{macrocode}
% \subsubsection{\csh{xint_FracToSci_x}}
% \added{1.4}
% TODO CLEAN UP COMMENTS WHICH HAVE MULTIPLE OBSOLETE COMPONENTS
% Under the name of |\xintFracToSci| and defined in \xintfracnameimp.
% \changed{1.4e}
%\begin{lverb}
% Refactored and much simplified
%
% It only needs to be x-expandable, and indeed the implementation here is only
% x-expandable.
%\end{lverb}
%\begin{lverb}
%
% Finally for 1.4e release I modify.  This is breaking change for all
% \xinteval output in case of scientific notation: it will not be with an
% integer mantissa, but with regular scientific notation, using the same rules
% as \xintPFloat.
%
% Of course no float rounding! Also, as [0] will always or almost always be
% present from an \xinteval, we want then to use integer not scientific
% notation.  But expression contained decimal fixed point input, or uses
% scientific functions, then probably the N will not be zero and this will
% trigger usage of scientific notation in output.
%
% Implementing these changes sort of ruin our previous efforts to minimize
% grabbing the argument, but well. So the rules now are
%
%( Input:  A, A/B, A[N], A/B[N]
%: Output: A, A/B, A if N=0, A/B if N=0
%:         If N is not zero, scientific notation like \xintPFloat,&
%          i.e. behaviour like \xintfloateval apart from the rounding&
%          to significands of width Digits.&
%          At 1.4k, trimming of zeros from A is always done, i.e.&
%          the \xintPFloatMinTrimmed is ignored to keep behaviour.&
%          unchanged.  Trailing zeros of B are kept as is.
%: The zero gives 0, except in A[N] and A/B[N] cases, it may give&
%  0.0
%)
%\end{lverb}
% \changed{1.4k}
% Moved from \xintfracnameimp to \xintexprnameimp.
% \changed{1.4l}
%\begin{lverb}
% Renamed to \xint_FracToSci_x to make it private and provide in
% $xintfracnameimp another \xintFracToSci with same output but which behaves
% like other macros there: f-expandable and accepting the whole range of
% inputs accepted by the xintfrac public macros.
%
% The private x-expandable macro here will have an empty output for an empty
% input but is never used for an empty input (see \xintexprEmptyItem).
%\end{lverb}
%    \begin{macrocode}
\def\xint_FracToSci_x #1%
   {\expandafter\CALX_fts\romannumeral`&&@#1/\W[\R}%
\def\XINT_FracToSci_x #1/#2#3[#4%
{%
    \xint_gob_til_W #2\XINT_FracToSci_x_noslash\W
    \xint_gob_til_R #4\XINT_FracToSci_x_slash_noN\R
    \XINT_FracToSci_x_slash_N #1/#2#3[#4%
}%
\def\XINT_FracToSci_x_noslash#1\XINT_FracToSci_x_slash_N #2[#3%
{%
    \xint_gob_til_R #3\XINT_FracToSci_x_noslash_noN\R
    \XINT_FracToSci_x_noslash_N #2[#3%
}%
\def\XINT_FracToSci_x_noslash_noN\R\XINT_FracToSci_x_noslash_N #1/\W[\R{#1}%
\def\XINT_FracToSci_x_noslash_N #1[#2]/\W[\R%
{%
    \ifnum#2=\xint_c_ #1\else
      \romannumeral0\expandafter\XINT_pfloat_a_fork\romannumeral0\xintrez{#1[#2]}%
    \fi
}%
\def\XINT_FracToSci_x_slash_noN\R\XINT_FracToSci_x_slash_N #1#2/#3/\W[\R%
{%
    #1\xint_gob_til_zero#1\expandafter\iffalse\xint_gobble_ii0\iftrue
    #2\if\XINT_isOne{#3}1\else/#3\fi\fi
}%
\def\XINT_FracToSci_x_slash_N #1#2/#3[#4]/\W[\R%
{%
    \ifnum#4=\xint_c_ #1#2\else
      \romannumeral0\expandafter\XINT_pfloat_a_fork\romannumeral0\xintrez{#1#2[#4]}%
    \fi
    \if\XINT_isOne{#3}1\else\if#10\else/#3\fi\fi
}%
%    \end{macrocode}
%\begin{lverb}
% \xint_FracToSci_x also prints the native values of calx which reach
% \xinteval (nested \xintfloatexpr or \xintiiexpr, float or ii variables
% and functions): \CALX_fts tests the first token, a tag has character
% code above `9. I+, I-, I? are printed as they are; an M value is
% converted by calxint's \CALX_mtoraw (all digits), an F value by calxfp's
% \CALX_ftoraw (A[N]), then printed by \XINT_FracToSci_x.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fts #1%
   {\ifnum`#1>57 \expandafter\CALX_fts_t\fi\XINT_FracToSci_x #1}%
\def\CALX_fts_t\XINT_FracToSci_x #1#2/\W[\R
   {\if I#1\xint_dothis{#1#2}\fi
    \if M#1\xint_dothis{\expandafter\XINT_FracToSci_x
       \romannumeral0\CALX_mtoraw{#1#2}/\W[\R}\fi
    \xint_orthat{\expandafter\XINT_FracToSci_x
       \romannumeral0\CALX_ftoraw{#1#2}/\W[\R}}%
\let\xintexprPrintOne\xint_FracToSci_x
%    \end{macrocode}
% See \calxnameimp.
%    \begin{macrocode}
\def\XINT_tmpa #1#2#3{%
  \def #1##1%
  {%
    \csname
      XINT_\ifcsname XINT_#3_func_##1\endcsname
        #3_func_##1\expandafter\endcsname\romannumeral`&&@\expandafter#2%
      \romannumeral\else
      \ifcsname XINT_#3_onliteral_##1\endcsname
        #3_onliteral_##1\expandafter\endcsname\romannumeral
      \else
      \ifcsname XINT_expr_var*_##1\endcsname
        expr_var*_##1\expandafter\endcsname\romannumeral
      \else
        #3_func_\XINT_expr_unknown_function {##1}%
                \expandafter\endcsname\romannumeral`&&@\expandafter#2%
      \romannumeral
      \fi\fi\fi\xint_c_
  }%
}%
     \expandafter\XINT_tmpa
                 \csname XINT_expr_op_`\endcsname
                 \XINT_expr_oparen
                 {expr}%
%    \end{macrocode}
% \subsection{Raw input of the float operations}
%\begin{lverb}
% Syntax (as in calxfp, where \CALX_fr_x is the raw input branch of
% \CALX_fround):
%(
%  \CALX_fr_x <P>.<X>\xint:
%:      -> <space>Y\xint:   (Y: X rounded to P digits, native float)
%)
% calxfp accepts as raw values only A[N], A/B[N] (integers A, B without
% leading zeros, B > 0). With xintexpr.sty, X is any xintfrac
% input, as in xint 1.4: the arguments of macros made by \xintNewExpr and
% similar, the argument of qfloat() and the arguments of the \calxFp
% macros are not parsed by the expression parser. xintfrac's \XINTinFloat
% rounds X to P digits (its A[N] branch does not look for a decimal mark
% or an exponent), \CALX_ffromraw converts the A[N] result, and calxfp's
% \CALX_fr_f finishes as for a native input.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fr_x #1.#2\xint:%
   {\expandafter\CALX_fr_f\the\numexpr#1\expandafter.%
    \romannumeral`&&@\CALX_ffromraw{\XINTinFloat[#1]{#2}}\xint:}%
%    \end{macrocode}
% \subsection{Expansion spanning; opening and closing parentheses}
% See comments in \calxnameimp.
%    \begin{macrocode}
\catcode`) 11
    \expandafter\XINT_def_start_and_check
    \csname XINT_expr_start\expandafter\endcsname
    \csname XINT_expr_check\expandafter\endcsname
    \csname XINT_expr_checkp\expandafter\endcsname
    \csname XINT_expr_op_-xii\expandafter\endcsname
    \csname XINT_expr_extra_)\endcsname
    {expr}%
    \expandafter\XINT_defop_oparen
    \csname XINT_expr_op_(\expandafter\endcsname
    \csname XINT_expr_op_)\expandafter\endcsname
    \csname XINT_expr_oparen\expandafter\endcsname
    \csname XINT_expr_check-_)\expandafter\endcsname
    \csname XINT_expr_checkp_)\expandafter\endcsname
    \csname XINT_expr_op_-xii\endcsname
    {expr}%
\catcode`) 12
%    \end{macrocode}
% \let\MakePrivateLetters\xintexprMakePrivateLetters
% \subsection{The comma as binary operator}
%\begin{lverb}
% New with 1.09a. Refactored at 1.4.
%\end{lverb}
%    \begin{macrocode}
\expandafter\XINT_defop_comma
    \csname XINT_expr_op_,\expandafter\endcsname
    \csname XINT_expr_exec_,\expandafter\endcsname
    \csname XINT_expr_check-_,\expandafter\endcsname
    \csname XINT_expr_checkp_,\expandafter\endcsname
    \csname XINT_expr_op_-xii\endcsname {expr}%
%    \end{macrocode}
% \subsection{The minus as prefix operator of variable precedence level}
%    \begin{macrocode}
\xintApplyInline{\XINT_defop_minus {expr}\xintOpp}{{xii}{xiv}{xvii}}%
%    \end{macrocode}
% \subsection{The \texorpdfstring{\protect\lowast}{*}{} as Python-like «unpacking» prefix operator}
%    \begin{macrocode}
    \expandafter\XINT_defpost_unpack\csname XINT_expr_op_0\expandafter\endcsname
                           \csname XINT_expr_until_unpack\endcsname {expr}%
%    \end{macrocode}
% \subsection{\cshnolabel{xintPow}}
%\begin{lverb}
%(\xintPow{a}{b} -> raw value of a^b
%)
% xintexpr.sty redefines xintfrac's \xintPow: ^, ** and pow() of
% \xinteval use it. b = 0: 1[0]. b an integer: exact power
% (xintfrac) if numerator and denominator of the result have at most
% about 10000 digits, else xintfrac's float power at \XINTdigits. b not
% an integer (half-integers included): \calxFpPow, the power of
% \xintfloateval, its result converted to raw. a = 0, b < 0:
% InvalidOperation, value 0 (as 1/0 in \xinteval).
%\end{lverb}
%    \begin{macrocode}
\def\xintPow{\romannumeral0\xintpow}%
\def\xintpow#1#2%
{%
    \expandafter\XINT_scipow_a\romannumeral0\xintrez{#2}\XINT_pow_int{#1}%
}%
\def\XINT_scipow_a #1%
{%
    \xint_gob_til_zero#1\XINT_scipow_Biszero0\XINT_scipow_b#1%
}%
\def\XINT_scipow_Biszero#1]#2#3{ 1[0]}%
\def\XINT_scipow_b #1#2/#3[#4]#5%
{%
    \unless\if1\XINT_is_One#3XY\xint_dothis\XINT_scipow_c\fi
    \ifnum#4<\xint_c_ \xint_dothis\XINT_scipow_c\fi
    \xint_orthat#5#1#2/#3[#4]%
}%
\def\XINT_scipow_c #1[#2]#3%
{%
    \ifnum\xintSgn{#3}=\xint_c_ \expandafter\XINT_scipow_z
    \else\expandafter\XINT_scipow_e\fi #1[#2]{#3}%
}%
\def\XINT_scipow_e #1[#2]#3{\CALX_ftoraw{\calxFpPow{#3}{#1[#2]}}}%
\def\XINT_scipow_z #1#2[#3]#4%
{%
    \if-#1\xint_dothis{\XINT_legacysignalcondition{InvalidOperation}%
        {0 raised to power #1#2[#3].}{}{ 0[0]}}\fi
    \xint_orthat{ 0[0]}%
}%
\def\XINT_pow_int #1/1[#2]%
{%
  \expandafter\XINT_pow_int_a\romannumeral0\XINT_dsx_addzeros{#2}#1;.%
}%
\def\XINT_pow_int_a #1#2.%
{%
  \ifnum\if-#1\xintLength{#2}\else\xintLength{#1#2}\fi>\xint_c_iv
       \expandafter\XINT_pow_bigint
  \else\expandafter\XINT_pow_int_b
  \fi #1#2.%
}%
\def\XINT_pow_bigint #1.#2%
{%
    \XINT_flpower_checkB_a#1.\XINTdigits.{#2}{\XINTinfloatS[\XINTdigits]}%
}%
\def\XINT_pow_int_b #1.#2%
{%
    \expandafter\XINT_pow_int_c\romannumeral0\xintraw{#2}\xint:#1\xint:
}%
\def\XINT_pow_int_c#1#2/#3[#4]\xint:#5\xint:
{%
    \if0\ifnum\numexpr\xint_c_e_iv/%
           (\xintLength{#1#2}\if-#1-\xint_c_i\fi)<\XINT_Abs#5 %
       1\else
        \ifnum\numexpr\xint_c_e_iv/\xintLength{#3}<\XINT_Abs#5 %
       1\else
    0\fi\fi
      \expandafter\XINT_fpow_fork\else\expandafter\XINT_pow_bigint_i
    \fi
    #5\Z{#4}{#1#2}{#3}%
}%
\def\XINT_pow_bigint_i#1\Z#2#3#4%
{%
    \XINT_flpower_checkB_a#1.\XINTdigits.{#3/#4[#2]}{\XINTinfloatS[\XINTdigits]}%
}%
\def\XINT_expr_func_pow #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\xintPow#3}}%
}%
%    \end{macrocode}
% \subsubsection{\&\&, \textbar\textbar, //, /:, +,
% \textendash, \texorpdfstring{\protect\lowast}{*}, /, \textasciicircum,
% \texorpdfstring{\protect\lowast\protect\lowast}{**}{}, \textquotesingle and\textquotesingle, \textquotesingle
% or\textquotesingle, \textquotesingle xor\textquotesingle, and
% \textquotesingle mod\textquotesingle}
%    \begin{macrocode}
\XINT_expr_defbin_a {expr}  {||} {6} {6} \calxOR
\catcode`& 12
\XINT_expr_defbin_a {expr}  {&&} {8} {8} \calxAND
\catcode`& 7
\XINT_expr_defbin_a {expr}  {xor}{6} {6} \calxXOR
\XINT_expr_defbin_a {expr}  {//} {14}{14}\xintDivFloor
\XINT_expr_defbin_a {expr}  {/:} {14}{14}\xintMod
\XINT_expr_defbin_a {expr}   +   {12}{12}\xintAdd
\XINT_expr_defbin_a {expr}   -   {12}{12}\xintSub
\XINT_expr_defbin_a {expr}   *   {14}{14}\xintMul
\XINT_expr_defbin_a {expr}   /   {14}{14}\xintDiv
\XINT_expr_defbin_a {expr}   ^   {18}{17}\xintPow
\catcode`& 12
   \expandafter\let\csname XINT_expr_op_and\expandafter\endcsname
                   \csname XINT_expr_op_&&\endcsname
   \expandafter\let\csname XINT_expr_op_or\expandafter\endcsname
                   \csname XINT_expr_op_||\endcsname
   \expandafter\let\csname XINT_expr_op_mod\expandafter\endcsname
                   \csname XINT_expr_op_/:\endcsname
\catcode`& 7
%    \end{macrocode}
% \subsubsection{.., ..[, and ].. for a..b and a..[b]..c syntax}
%\begin{lverb}
% a..[d]..b of \xinteval. Contrarily to a..b which is limited to small
% integers, this works with a, b, and d (big) fractions. It will produce a «nil» list, if a>b and
% d<0 or a<b and d>0.
%\end{lverb}
%
% \paragraph{\csh{xintSeqA}}
%
%    \begin{macrocode}
\def\xintSeqA        {\expandafter\XINT_SeqA\romannumeral0\xintraw}%
\def\XINT_SeqA  #1]#2{\expandafter\XINT_SeqA_a\romannumeral0\xintraw {#2}#1]}%
\def\XINT_SeqA_a #1{\xint_UDzerominusfork
                                   #1-{z}%
                                   0#1{n}%
                                   0-{p}%
                    \krof #1}%
%    \end{macrocode}
% \paragraph{\csh{xintSeqB:tl:x}}
%\begin{lverb}
% At 1.4, delayed expansion of start and step done here and not before,
% for matters of \xintdeffunc and «NEhooks».
%
% The float variant at 1.4 is made identical to the exact variant. I.e.
% stepping is exact and comparison to the range limit too. But recall that a/b
% input will be converted to a float. To handle 1/3 step for example still
% better to use \xintexpr 1..1/3..10\relax for example inside the \xintfloateval.
%
%\end{lverb}
%    \begin{macrocode}
\def\xintSeqB:tl:x  #1{\expandafter\XINT_SeqB:tl:x\romannumeral`&&@\xintSeqA#1}%
\def\XINT_SeqB:tl:x #1{\csname XINT_SeqB#1:tl:x\endcsname}%
\def\XINT_SeqBz:tl:x #1]#2]#3{{#2]}}%
\def\XINT_SeqBp:tl:x #1]#2]#3%
    {\expandafter\XINT_SeqBp:tl:x_a\romannumeral0\xintraw{#3}#2]#1]}%
\def\XINT_SeqBp:tl:x_a #1]#2]#3]%
{%
    \xintifCmp{#1]}{#2]}%
    {}{{#2]}}{{#2]}\expandafter\XINT_SeqBp:tl:x_b\romannumeral0\xintadd{#3]}{#2]}#1]#3]}%
}%
\def\XINT_SeqBp:tl:x_b #1]#2]#3]%
{%
    \xintifCmp{#1]}{#2]}%
    {{#1]}\expandafter\XINT_SeqBp:tl:x_b\romannumeral0\xintadd{#3]}{#1]}#2]#3]}{{#1]}}{}%
}%
\def\XINT_SeqBn:tl:x #1]#2]#3%
   {\expandafter\XINT_SeqBn:tl:x_a\romannumeral0\xintraw{#3}#2]#1]}%
\def\XINT_SeqBn:tl:x_a #1]#2]#3]%
{%
    \xintifCmp{#1]}{#2]}%
    {{#2]}\expandafter\XINT_SeqBn:tl:x_b\romannumeral0\xintadd{#3]}{#2]}#1]#3]}{{#2]}}{}%
}%
\def\XINT_SeqBn:tl:x_b #1]#2]#3]%
{%
    \xintifCmp{#1]}{#2]}%
    {}{{#1]}}{{#1]}\expandafter\XINT_SeqBn:tl:x_b\romannumeral0\xintadd{#3]}{#1]}#2]#3]}%
}%
\XINT_expr_defbin_b {expr}%
\XINT_expr_defbin_c {expr}   {..}\xintSeq:tl:x
\XINT_expr_defbin_c {expr}  {]..}\xintSeqB:tl:x
%    \end{macrocode}
% \subsubsection{<, >, ==, <=, >=, != with Python-like chaining}
%    \begin{macrocode}
\XINT_expr_defbin_d {expr}  <\xintLt
\XINT_expr_defbin_d {expr}  >\xintGt
\XINT_expr_defbin_d {expr}  {==}\xintEq
\XINT_expr_defbin_d {expr}  {<=}\xintLtorEq
\XINT_expr_defbin_d {expr}  {>=}\xintGtorEq
\XINT_expr_defbin_d {expr}  {!=}\xintNotEq
%    \end{macrocode}
% \subsubsection{[...] as «oneple» constructor}
%    \begin{macrocode}
\XINT_expr_defbin_e {expr}%
%    \end{macrocode}
% \subsubsection{[...] brackets and : operator for NumPy-like slicing and item
% indexing syntax}
%    \begin{macrocode}
\XINT_expr_defbin_f {expr}%
\XINT_expr_defbin_g {expr}%
%    \end{macrocode}
% \subsection{Support for raw A/B[N]}
% See comments in \calxnameimp.
% \odef\MakePrivateLetters{\MakePrivateLetters\catcode`& 11 }^^A
%    \begin{macrocode}
\catcode0 11
\let\XINT_expr_precedence_&&@ \xint_c_xiv
\def\XINT_expr_op_&&@ #1#2]%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded{{{\xintE#1{\xint_zapspaces #2 \xint_gobble_i}}}%
    \expandafter}\romannumeral`&&@\XINT_expr_getop
}%
\catcode2 11
\let\XINT_expr_op_&&B\XINT_flexpr_op_&&B
\catcode2 12
\catcode3 11
\let\XINT_expr_op_&&C \XINT_flexpr_op_&&C
\catcode3 12
\catcode0 12
%    \end{macrocode}
% \let\MakePrivateLetters\xintexprMakePrivateLetters
% \subsection{? as two-way and ?? as three-way «short-circuit» conditionals}
%    \begin{macrocode}
\catcode`- 11
%    \end{macrocode}
% \odef\MakePrivateLetters{\MakePrivateLetters\catcode`- 11 }\FixInterMacrocodeVspace
%    \begin{macrocode}
\def\XINT_expr_op_?  {\XINT_expr_op__? \XINT_expr_op_-xii}%
\catcode`- 12
%    \end{macrocode}
% \let\MakePrivateLetters\xintexprMakePrivateLetters
% \subsection{! as postfix factorial operator}
%    \begin{macrocode}
\def\XINT_expr_op_! #1%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded{{\romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\xintFac#1}}\expandafter}\romannumeral`&&@\XINT_expr_getop
}%
%    \end{macrocode}
% \subsection{User defined variables: \csh{xintdefvar}}
%    \begin{macrocode}
\def\xintdefvar     {\xintexprSafeCatcodes\xintdefvar_a}%
\def\xintdefvar_a#1={\XINT_expr_defvar\xintthebareeval{#1}}%
%    \end{macrocode}
% \subsection{\cshnolabel{qfrac()} of \cshnolabel{xinteval}}
%\begin{lverb}
% The legacy qfrac() (\xintRaw: any xintfrac input, exact) for \xinteval
% only; the \xintfloateval and \xintiieval ones are calx.sty's (strict
% A/B) and are not changed.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_onliteral_qfrac #1)%
    {\expandafter\XINT_expr_put_op_first\expanded{{{\xintRaw{#1}}}\expandafter
     }\romannumeral`&&@\XINT_expr_getop}%
%    \end{macrocode}
% \subsection{Regular built-in functions}
%    \begin{macrocode}
\let\XINT_expr_func_num\XINT_iiexpr_func_num
%    \end{macrocode}
%\begin{lverb}
% reduce() and preduce() (xintfrac's \xintIrr, \xintPIrr) of \xinteval;
% calx gives none for \xintfloateval: xintexpr.sty adds them, the same
% macros. reduce(): \xintIrrz, \xintIrr's output with [0] appended (the
% [0] follows the input of \XINT_irr_start, as the [N] of \xintPIrr).
% Not user level.
%\end{lverb}
%    \begin{macrocode}
\def\xintIrrz {\romannumeral0\xintirrz }%
\def\xintirrz #1%
{%
    \expandafter\XINT_irr_start\romannumeral0\xintrawwithzeros {#1}\Z[0]%
}%
\def\XINT_expr_func_reduce #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\xintIrrz#3}}%
}%
\def\XINT_expr_func_preduce #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\xintPIrr#3}}%
}%
\let\XINT_flexpr_func_reduce\XINT_expr_func_reduce
\let\XINT_flexpr_func_preduce\XINT_expr_func_preduce
\def\XINT_expr_func_abs #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\xintAbs#3}}%
}%
\let\XINT_expr_func_sgn\XINT_iiexpr_func_sgn
\def\XINT_expr_func_frac #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\xintTFrac#3}}%
}%
\def\XINT_expr_func_floor #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\xintFloor#3}}%
}%
\def\XINT_expr_func_ceil #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\xintCeil#3}}%
}%
\def\XINT_expr_func_sqr #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\xintSqr#3}}%
}%
\let\XINT_expr_func_? \XINT_iiexpr_func_?
\let\XINT_expr_func_! \XINT_iiexpr_func_!
\let\XINT_expr_func_not \XINT_iiexpr_func_not
\def\XINT_expr_func_odd #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\xintOdd#3}}%
}%
\def\XINT_expr_func_even #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\xintEven#3}}%
}%
\def\XINT_expr_func_isint #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\xintIsInt#3}}%
}%
\def\XINT_expr_func_isone #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\xintIsOne#3}}%
}%
\def\XINT_expr_func_factorial #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:and:opt:direct
    \XINT:expr:f:one:and:opt #3,!\xintFac\XINTinFloatFac
    }}%
}%
\let\XINT_expr_func_sqrt\XINT_flexpr_func_sqrt
\def\XINT_expr_func_inv #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\xintInv#3}}%
}%
%    \end{macrocode}
% \changed{2.0a1}
%
% Eversince |1.4a| and the support for negative arguments the functions
% round(x,n) and trunc(x,n) were half-broken in both \csbxint{eval}
% and \csbxint{floateval} because the underlying \csbxint{Round} and
% \csbxint{Trunc} with a negative rounding argument produced scientific
% notation which is not acceptable in leaves which apply \cs{detokenize}
% hence a catcode 12 e breaking \csbxint{floateval} printer.
%    \begin{macrocode}
\def\xintRoundToRaw#1{\romannumeral0\expandafter\xintroundtoraw\the\numexpr#1.}%
\def\xintroundtoraw#1.#2{\xintiround{#1}{#2}[-#1]}%
\def\XINT_expr_func_round #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:tacitzeroifone:direct
    \XINT:expr:f:tacitzeroifone #3,!\xintiRound\xintRoundToRaw
    }}%
}%
\def\xintTruncToRaw#1{\romannumeral0\expandafter\xinttrunctoraw\the\numexpr#1.}%
\def\xinttrunctoraw#1.#2{\xintitrunc{#1}{#2}[-#1]}%
\def\XINT_expr_func_trunc #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:tacitzeroifone:direct
    \XINT:expr:f:tacitzeroifone #3,!\xintiTrunc\xintTruncToRaw
    }}%
}%
\def\XINT_expr_func_float #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:and:opt:direct
    \XINT:expr:f:one:and:opt #3,!\XINTinFloatdigits\XINTinFloat
    }}%
}%
\def\XINT_expr_func_float_dgt #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\XINTinFloatdigits#3}}%
}%
\def\XINT_expr_func_sfloat #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:and:opt:direct
    \XINT:expr:f:one:and:opt #3,!\XINTinFloatSdigits\XINTinFloatS
    }}%
}%
\expandafter\def\csname XINT_expr_func_ilog10\endcsname #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:and:opt:direct
    \XINT:expr:f:one:and:opt #3,!\xintiLogTen\XINTFloatiLogTen
    }}%
}%
\def\XINT_expr_func_divmod #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\romannumeral`&&@%
    \XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\xintDivMod #3}}%
}%
\def\XINT_expr_func_mod #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\romannumeral`&&@%
    \XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\xintMod#3}}%
}%
\def\XINT_expr_func_binomial #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\romannumeral`&&@%
    \XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\xintBinomial #3}}%
}%
\def\XINT_expr_func_pfactorial #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\romannumeral`&&@%
    \XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\xintPFactorial #3}}%
}%
\let\XINT_expr_func_randrange\XINT_flexpr_func_randrange
%    \end{macrocode}
%\begin{lverb}
% gcd() and lcm() of \xinteval: xintfrac's \XINT_GCDof, \XINT_LCMof
% (fractions, raw A/B[0] output). calx gives none for \xintfloateval:
% xintexpr.sty adds them, the same macros (items converted to raw by
% xintfrac's input parser, \CALX_infr; output left raw as legacy).
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_func_gcd #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\XINT_GCDof#3^}}%
}%
\def\XINT_expr_func_lcm #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\XINT_LCMof#3^}}%
}%
\let\XINT_flexpr_func_gcd\XINT_expr_func_gcd
\let\XINT_flexpr_func_lcm\XINT_expr_func_lcm
\def\XINT_expr_func_max #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\XINT_Maxof#3^}}%
}%
\def\XINT_expr_func_min #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\XINT_Minof#3^}}%
}%
\expandafter
\def\csname XINT_expr_func_+\endcsname #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\XINT_Sum#3^}}%
}%
\expandafter
\def\csname XINT_expr_func_*\endcsname #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\XINT_Prd#3^}}%
}%
\let\XINT_expr_func_all\XINT_iiexpr_func_all
\let\XINT_expr_func_any\XINT_iiexpr_func_any
\let\XINT_expr_func_xor\XINT_iiexpr_func_xor
\let\XINT_expr_func_len\XINT_iiexpr_func_len
\let\XINT_expr_func_first\XINT_flexpr_func_first
\let\XINT_expr_func_last\XINT_flexpr_func_last
\let\XINT_expr_func_reversed\XINT_flexpr_func_reversed
\let\XINT_expr_func_if\XINT_flexpr_func_if
%    \end{macrocode}
%\begin{lverb}
% ifint() and ifone() of \xinteval: xintfrac's \xintifInt, \xintifOne, for
% its values (any xintfrac input, fractions); the calx ones of
% \xintiieval and \xintfloateval are for the native values.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_func_ifint #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:branch{\romannumeral`&&@\xintifInt #3}}%
}%
\def\XINT_expr_func_ifone #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:branch{\romannumeral`&&@\xintifOne #3}}%
}%
\let\XINT_expr_func_ifsgn\XINT_flexpr_func_ifsgn
\let\XINT_expr_func_nuple\XINT_flexpr_func_nuple
\let\XINT_expr_func_unpack\XINT_flexpr_func_unpack
\let\XINT_expr_func_flat\XINT_flexpr_func_flat
\let\XINT_expr_func_zip\XINT_flexpr_func_zip
%    \end{macrocode}
% \subsection{User declared functions}
% The mysterious |\XINT_NewFunc| is defined at bottom of this file.
% For comments see \calxnameimp.
%    \begin{macrocode}
\def\xintdeffunc{\xintexprSafeCatcodes\xintdeffunc_a}%
\XINT_def_deffunc
   \xintdeffunc_a{expr}\XINT_NewFunc{expr}\xintdeffunc_b
\def\xintdefufunc{\xintexprSafeCatcodes\xintdefufunc_a}%
\XINT_def_defufunc
   \xintdefufunc_a{expr}\XINT_NewFunc{expr}\xintdefufunc_b\xintdefufunc_c
%    \end{macrocode}
% \subsubsection{\cshnolabel{xintunassignexprfunc}}
%    \begin{macrocode}
\XINT_def_unassignfunc{expr}%
%    \end{macrocode}
% \subsubsection{\csh{xintNewExpr}, \csh{xintNewIExpr}, \csh{xintNewBoolExpr},
%                \csh{xintNewFloatExpr}, \csh{xintNewIIExpr}}
%\begin{lverb}
% 1.2c modifications to accomodate \XINT_expr_deffunc_newexpr etc..
%
% 1.2f adds token \XINT_newexpr_clean to be able to have a different
% \XINT_newfunc_clean.
%
% As \XINT_NewExpr always execute \XINT_expr_redefineprints since 1.3e whether
% with \xintNewExpr or \XINT_NewFunc, it has been moved from argument to
% hardcoded in replacement text.
%
% NO MORE \XINT_expr_redefineprints at 1.4 ! This allows better support for
% \xinteval, \xinttheexpr as sub-entities inside an \xintNewExpr. And the
% «cleaning» will remove the new \XINTfstop , to maintain backwards
% compatibility with former behaviour that created macros expand to explicit
% digits and not an encapsulated result.
%
% (obsolete:) The #2#3 in clean stands for \noexpand\XINTfstop.
%\end{lverb}
% \changed{1.4n}
%\begin{lverb}
% The #2#3 in previous paragraph is obsolete, the pattern used for
% \XINT_newexpr_clean was formerly #1>#2#3 (not optimal, but legacy), but is
% now simply #1\XINTfstop. This is simpler and allows compatibility with
% LuaMetaTeX whose \meaning output differs from the one of other engines.
%\end{lverb}
%    \begin{macrocode}
\catcode`\~=12
\def\XINT_flexpr_getmacropar #1{%
\def\XINT_flexpr_getmacropar ##1%
{%
    \expanded{{{~xintRaw{#1##1}}}\expandafter}%
    \romannumeral`&&@\XINT_expr_getop
}%
}\expandafter\XINT_flexpr_getmacropar\string#%
\def\XINT_iiexpr_getmacropar #1{%
\def\XINT_iiexpr_getmacropar ##1%
{%
    \expanded{{{~xintiNum{#1##1}}}\expandafter}%
    \romannumeral`&&@\XINT_expr_getop
}%
}\expandafter\XINT_iiexpr_getmacropar\string#%
\catcode`\~=3
\def\xintNewFloatExpr{\begingroup
    \let\XINT_expr_getmacropar\XINT_flexpr_getmacropar
    \XINT_NewExpr_a\xint_firstofone\xintfloatexpr\XINT_newexpr_clean
}%
\def\xintNewIIExpr{\begingroup
    \let\XINT_expr_getmacropar\XINT_iiexpr_getmacropar
    \XINT_NewExpr_a\xint_firstofone\xintiiexpr\XINT_newexpr_clean
}%
\def\XINT_newexpr_clean #1\XINTfstop{\noexpand\expanded\noexpand\xintNEprinthook}%
\def\xintNEprinthook#1.#2{\expanded{\xint_noxpd{#1.}{#2}}}%
\def\xintNewExpr     {\XINT_NewExpr\xint_firstofone\xintexpr     \XINT_newexpr_clean}%
\def\xintNewIExpr    {\XINT_NewExpr\xint_firstofone\xintiexpr    \XINT_newexpr_clean}%
\def\xintNewBoolExpr {\XINT_NewExpr\xint_firstofone\xintboolexpr \XINT_newexpr_clean}%
\def\XINT_NewFunc    {\XINT_NewExpr\xint_gobble_i\xintthebareeval\XINT_newfunc_clean}%
\let\XINT_tmpa\undefined \let\XINT_tmpb\undefined \let\XINT_tmpc\undefined
\let\XINT_tmpd\undefined \let\XINT_tmpe\undefined
\XINTrestorecatcodesendinput%
%    \end{macrocode}
% \StoreCodelineNo {xintexpr}
% \cleardoublepage\let\xintexprnameUp\undefined
%\gardesactifs
%\let</xintexpr>\relax
%\let<*calxcore>\gardesinactifs
%</xintexpr>^^A--------------------------------------------------
%<*calxcore>^^A---------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname calxcorenameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section{Package \calxcorenameimp implementation}
% \RaisedLabel{sec:calxcoreimp}
% \addedcalx{2.0a1}
%
% \localtableofcontents
%
%\begin{lverb}
% The eight-digit block utilities shared by calx and legacy xint arithmetic
% are defined here under their original XINT_ names. The native conversions
% and arithmetic kernels remain in the CALX_ namespace. The legacy
% xintcore.sty depends on calxcore.sty for the shared utilities.
%\end{lverb}
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
% The code of this subsection is copied over from the xint packages, with
% the package names changed.
%
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode64=11   % @
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \def\empty{}\def\space{ }\newlinechar10
  \def\z{\endgroup}%
  \expandafter\let\expandafter\x\csname ver@calxcore.sty\endcsname
  \expandafter\let\expandafter\w\csname ver@xintkernel.sty\endcsname
  \expandafter\ifx\csname numexpr\endcsname\relax
    \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax
      \immediate\write128{^^JPackage calxcore Warning:^^J%
                          \space\space\space\space
                          \numexpr not available, aborting input.^^J}%
    \else
      \PackageWarningNoLine{calxcore}{\numexpr not available, aborting input}%
    \fi
    \def\z{\endgroup\endinput}%
  \else
    \ifx\x\relax   % plain-TeX, first loading of calxcore.sty
      \ifx\w\relax % but xintkernel.sty not yet loaded.
         \def\z{\endgroup\input xintkernel.sty\relax}%
      \fi
    \else
      \ifx\x\empty % LaTeX, first loading,
      % variable is initialized, but \ProvidesPackage not yet seen
          \ifx\w\relax % xintkernel.sty not yet loaded.
            \def\z{\endgroup\RequirePackage{xintkernel}}%
          \fi
      \else
        \def\z{\endgroup\endinput}% xintkernel already loaded.
      \fi
    \fi
  \fi
\z%
\XINTsetupcatcodes% defined in xintkernel.sty
%    \end{macrocode}
% \subsection{Package identification}
%    \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{calxcore}%
  [2026/11/01 v2.0a1 Expandable arithmetic on big integers (JFB)]%
%    \end{macrocode}
%
%\odef\MakePrivateLetters{\MakePrivateLetters\catcode`- 11}^^A
%
% \subsection{\cshnolabel{xintNum}, \csh{xintiNum}}
%\begin{lverb}
% For example \xintNum {----+-+++---+----000000000000003}
%
% Very old routine got completely rewritten at 1.2l.
%
% New code uses \numexpr governed expansion and fixes some issues of former
% version particularly regarding inputs of the \numexpr...\relax type without
% \the or \number prefix, and/or possibly no terminating \relax.
%
% \xintiNum{\numexpr 1}\foo in earlier versions caused premature expansion of
% \foo.
%
% \xintiNum{\the\numexpr 1} was ok, but a bit luckily so.
%
% Also, up to 1.2k inclusive, the macro fetched tokens eight by eight, and not
% nine by nine as is done now. I have no idea why.
%\end{lverb}
%    \begin{macrocode}
\def\xintiNum {\romannumeral0\xintinum }%
\def\xintinum #1%
{%
    \expandafter\XINT_num_cleanup\the\numexpr\expandafter\XINT_num_loop
    \romannumeral`&&@#1\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z
}%
\def\xintNum {\romannumeral0\xintnum }%
\let\xintnum\xintinum
%    \end{macrocode}
% Attention |\xintnum| (hence |\xintNum|) gets redefined by
% \xintfracnameimp.  Click on names to see the redefinition there.
%    \begin{macrocode}
\def\XINT_num #1%
{%
    \expandafter\XINT_num_cleanup\the\numexpr\XINT_num_loop
    #1\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z
}%
\def\XINT_num_loop #1#2#3#4#5#6#7#8#9%
{%
    \xint_gob_til_xint: #9\XINT_num_end\xint:
    #1#2#3#4#5#6#7#8#9%
    \ifnum \numexpr #1#2#3#4#5#6#7#8#9+\xint_c_ = \xint_c_
%    \end{macrocode}
%\begin{lverb}
% means that so far only signs encountered, (if syntax is legal) then possibly
% zeroes
% or a terminated or not terminated \numexpr evaluating to zero
% In that latter case a correct zero will be produced in the end.
%\end{lverb}
%    \begin{macrocode}
      \expandafter\XINT_num_loop
    \else
%    \end{macrocode}
%\begin{lverb}
% non terminated \numexpr (with nine tokens total) are
% safe as after \fi, there is then \xint:
%\end{lverb}
%    \begin{macrocode}
     \expandafter\relax
    \fi
}%
\def\XINT_num_end\xint:#1\xint:{#1+\xint_c_\xint:}% empty input ok
\def\XINT_num_cleanup #1\xint:#2\Z { #1}%
%    \end{macrocode}
% \subsection{\csh{xintiiSgn}}
% Moved to \calxcorenameimp for STUPID REASONS. Too painful to comment.
%\begin{lverb}
% 1.2l made \xintiiSgn robust against non terminated input.
%
% 1.2o deprecates here \xintSgn (it requires xintfrac.sty).
%\end{lverb}
%    \begin{macrocode}
\def\xintiiSgn {\romannumeral0\xintiisgn }%
\def\xintiisgn #1%
{%
    \expandafter\XINT_sgn \romannumeral`&&@#1\xint:
}%
\def\XINT_sgn #1#2\xint:
{%
    \xint_UDzerominusfork
      #1-{ 0}%
      0#1{-1}%
       0-{ 1}%
    \krof
}%
\def\XINT_Sgn #1#2\xint:
{%
    \xint_UDzerominusfork
      #1-{0}%
      0#1{-1}%
       0-{1}%
    \krof
}%
\def\XINT_cntSgn #1#2\xint:
{%
    \xint_UDzerominusfork
      #1-\xint_c_
      0#1\xint_c_mone
       0-\xint_c_i
    \krof
}%
%    \end{macrocode}
% \subsection{\csh{xintiiOpp}}
% Moved to \calxcorenameimp for STUPID REASONS. Too painful to comment.
%\begin{lverb}
% Attention, \xintiiOpp non robust against non terminated inputs.
% Reason is I don't want to have to grab a delimiter at the end, as everything
% happens "upfront".
%\end{lverb}
%    \begin{macrocode}
\def\xintiiOpp {\romannumeral0\xintiiopp }%
\def\xintiiopp #1%
{%
    \expandafter\XINT_opp \romannumeral`&&@#1%
}%
\def\XINT_Opp #1{\romannumeral0\XINT_opp #1}%
\def\XINT_opp #1%
{%
    \xint_UDzerominusfork
      #1-{ 0}%      zero
      0#1{ }%     negative
       0-{ -#1}%  positive
    \krof
}%
%    \end{macrocode}
% \subsection{\csh{xintiiCmp}}
% The reason for it to be here is a completely silly situation which has
% cost the author perhaps 6 hours due to incompetent assistant preferring
% to work in secret and keep major decisions to itself.  It may be provisory
% but will not be modified for |2.0a1|.
% \changed[2022/06/05]{1.4m}
% Now uses the |\xintstrcmp| engine primitive.
%    \begin{macrocode}
\def\xintiiCmp   {\romannumeral0\xintiicmp }%
\def\xintiicmp #1{\expandafter\XINT_iicmp\romannumeral`&&@#1\xint:}%
\def\XINT_iicmp #1#2\xint:#3%
{%
    \expandafter\XINT_cmp_nfork\expandafter #1\romannumeral`&&@#3\xint:#2\xint:
}%
\def\XINT_cmp_nfork #1#2%
{%
    \xint_UDzerofork
      #1\XINT_cmp_firstiszero
      #2\XINT_cmp_secondiszero
       0{}%
    \krof
    \xint_UDsignsfork
          #1#2\XINT_cmp_minusminus
           #1-\XINT_cmp_minusplus
           #2-\XINT_cmp_plusminus
            --\XINT_cmp_plusplus
    \krof #1#2%
}%
\def\XINT_cmp_firstiszero  #1\krof 0#2#3\xint:#4\xint:
{%
    \xint_UDzerominusfork
      #2-{ 0}%
      0#2{ 1}%
       0-{ -1}%
    \krof
}%
\def\XINT_cmp_secondiszero #1\krof #20#3\xint:#4\xint:
{%
    \xint_UDzerominusfork
      #2-{ 0}%
      0#2{ -1}%
       0-{ 1}%
    \krof
}%
\def\XINT_cmp_plusminus    #1\xint:#2\xint:{ 1}%
\def\XINT_cmp_minusplus    #1\xint:#2\xint:{ -1}%
\def\XINT_cmp_minusminus
    --{\expandafter\XINT_opp\romannumeral0\XINT_cmp_plusplus {}{}}%
%    \end{macrocode}
%\begin{lverb}
% The \romannumeral0 trigger induces some complications here to terminate
% nicely without grabbing too many tokens in the stream or deteriorating
% expansion quality of the non-equal-length branches.
% \expanded simplifies things.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_cmp_plusplus #1#2#3\xint:#4\xint:{\expanded{ %
    \ifcase\expandafter\XINT_cntSgn\the\numexpr\xintLength{#1#4}-\xintLength{#2#3}\xint:
        \xintstrcmp{#1#4}{#2#3}\or1\else-1\fi
    }%
}%
%    \end{macrocode}
% \subsection{Exceptional conditions: signals, flags, handlers, traps}
% The code of this section comes from the unfinished signal code of
% |xintcore.sty| (dating back to |1.2l|), renamed, kept in the core module,
% and completed.
%\begin{lverb}
% As per the Mike Cowlishaw/IBM's General Decimal Arithmetic Specification
%
%    http://speleotrove.com/decimal/decarith.html
%
% and the Python3 implementation in its Decimal module.
%
% Clamped, ConversionSyntax, DivisionByZero, DivisionImpossible,
% DivisionUndefined, Inexact, InsufficientStorage, InvalidContext,
% InvalidOperation, Overflow, Inexact, Rounded, Subnormal,
% Underflow.
%
% X3.274 rajoute LostDigits
%
% Python rajoute FloatOperation (et n'inclut pas InsufficientStorage)
%
% quote de decarith.pdf:
% The Clamped, Inexact, Rounded, and Subnormal conditions can coincide with
% each other or with other conditions. In these cases then any trap enabled
% for another condition takes precedence over (is handled before) all of
% these, any Subnormal trap takes precedence over Inexact, any Inexact trap
% takes precedence over Rounded, and any Rounded trap takes precedence over
% Clamped.
%
% This was initiated at 1.2l (2017/07/26), but the possibility to
% customize handlers was never finished nor documented for users.
% Completely redone for 2.0a1 (2026/11/01).
%
% Model: the decimal module of Python (as for the xintcore code), with the
% IEEE 754 default
% exception handling as default configuration: a condition raises a flag and
% is handled, the handler returns a default result, and NO TeX error is
% emitted. Emitting an (expandable) error is an opt-in, per signal, via
% \calxsetup.
%
% Vocabulary (that of Python's decimal module):
%- a CONDITION is what a calx macro detects and reports;
%- each condition belongs to a SIGNAL; for most conditions, condition and
% signal are the same; five conditions belong to signal InvalidOperation:
%( ConversionSyntax        (input which is not a number)
%: DivisionImpossible      (integer division result does not fit)
%: DivisionUndefined       (0/0)
%: InvalidContext          (invalid configuration)
%: ControversialOperation  (argument too large for a periodic function)
%)
%- there are eight signals: Clamped, DivisionByZero, Inexact,
% InvalidOperation, Overflow, Rounded, Subnormal, Underflow;
%- each SIGNAL has a FLAG (raised or not) and a TRAP (set or not);
%- each CONDITION has a HANDLER.
%
% What happens when calx code signals a condition C of signal S, via
%( \CALX_signalcondition{C}{<message>}{<handler argument>}{<trap value>}
%)
% (this is \CALX_signalcondition_a below, Python's Context._raise_error):
%- 1. if S is "ignored" (control sequence \CALX_S_isignoredflag defined;
% Python's Context._ignored_flags), the handler of S is applied to
% <handler argument>, and that is all: no flag is raised;
%- 2. otherwise the flag of S is raised; then
%- 3. if S is not trapped (the default for all signals), the handler of C is
% applied to <handler argument>, and its result is the result;
%- 4. if S is trapped, an expandable error is emitted with <message>, and the
% result is <trap value>, the value the calling macro would return
% without the signal machinery (e.g. what xint returns: 0 on division by
% zero).
%
% No calx code sets the "ignored" status at this stage; it is kept from
% the xintcore code (and Python) for internal computations which must not
% leave traces in the flags. It is set by \let\CALX_S_isignoredflag\relax (via
% \csname) and cleared by \let to \XINT_undefined.
%
% Default handlers (Python's decimal: the "handle" method of each condition
% class; a class without "handle" returns None in Python, meaning the caller
% keeps the result it has computed, which here is the handler argument):
%( condition          handler argument           result
%: ------------------------------------------------------------------
%: InvalidOperation   (ignored)                  I?        (NaN)
%: ConversionSyntax   (ignored)                  I?
%: DivisionImpossible (ignored)                  I?
%: DivisionUndefined  (ignored)                  I?
%: InvalidContext     (ignored)                  I?
%: ControversialOperation (ignored)              I?
%: DivisionByZero     sign + or -                I+ or I-  (+-Infinity)
%: Overflow           sign + or -                I+ or I-
%: Underflow          computed result            the argument
%: Clamped            computed result            the argument
%: Inexact            computed result            the argument
%: Rounded            computed result            the argument
%: Subnormal          computed result            the argument
%)
% I, ?, + and - in results are catcode 12 characters, the special value
% markers of the calx internal format (I+ is +Infinity, I- is -Infinity, I?
% is NaN). The sign handed to the DivisionByZero and Overflow handlers must be
% a catcode 12 + or -. Printing the special values as NaN, Infinity,
% -Infinity is not done here: it is the task of the output macros of the
% arithmetic modules.
%
% Overflow: Python returns +-Infinity or the largest finite number, depending
% on the rounding mode. calx rounds half away from zero, for which Python
% (ROUND_HALF_UP) returns +-Infinity.
%
% FLAGS. A flag of signal S is raised when \CALX_SFlag_ON is defined. It is
% raised EXPANDABLY by
%( \expandafter\xint_gobble_i\csname CALX_SFlag_ON\endcsname
%)
% which uses the fact that \csname...\endcsname, if the name is undefined,
% \let's it to \relax as a side effect. This assignment is ALWAYS LOCAL to
% the current group (checked under etex: even with \globaldefs=1). Hence:
%- a flag raised by a computation done inside a group (\begingroup or braces,
% an \hbox, an alignment cell, ...) is down again after the group ends;
%- a flag is raised only when the computation is actually expanded: inside
% an \edef, an \expanded, a \message, a \csname, or f-expansion; storing
% an unexpanded computation in a macro via \def raises nothing.
%
% A user wanting a flag to survive a group tests it before the group ends
% and makes the information global by his own means.
%
% Testing (expandable) and lowering (NOT expandable):
%( \calxifflagraised{S}{<yes>}{<no>}
%: \calxresetflag{S}
%: \calxresetflags   (the eight flags)
%)
% Lowering obeys \ifxintglobaldefs (via \XINT_global): it is global if
% \xintglobaldefstrue, local otherwise.
%
% CONFIGURATION, \calxsetup. Same syntax and method as \bnumsetup of bnumexpr:
% a comma separated list of key=value; spaces around keys are
% removed; a final comma does no harm; each key performs a \let; assignments
% are global if \xintglobaldefstrue, local otherwise (\XINT_global); with
% \xintverbosetrue each assignment is reported on the terminal and in the log
% (\xintMessage).
%
% Keys:
%( <S>.trap    = true   (or false)           for each of the eight signals
%: <C>.handler = \macro                      for each of the thirteen conditions
%)
% e.g.
%( \calxsetup{DivisionByZero.trap = true, InvalidOperation.trap = true}
%)
% gives back the behaviour of xint (expandable error, then xint's default
% result) for these two signals.
%
% A handler is a macro with ONE argument, the handler argument; it must
% expand to the result (in the contexts where calx macros use it, it is
% expanded by f-expansion). For example a user preferring that conversion
% errors give zero, in the calx internal format of zero, would \let the
% ConversionSyntax handler to a macro expanding to that. The value of
% <C>.handler must be a single control sequence (the \let receives only
% that).
%
% An unknown key, or a value other than true and false for a .trap key, is
% reported by a (non expandable) TeX error, \calxsetup being itself not
% expandable.
%\end{lverb}
%    \begin{macrocode}
\catcode`- 11
\def\CALX_ConversionSyntax-signal  {{InvalidOperation}}%
\let\CALX_DivisionImpossible-signal\CALX_ConversionSyntax-signal
\let\CALX_DivisionUndefined-signal \CALX_ConversionSyntax-signal
\let\CALX_InvalidContext-signal    \CALX_ConversionSyntax-signal
\let\CALX_ControversialOperation-signal\CALX_ConversionSyntax-signal
\catcode`- 12
%    \end{macrocode}
% \subsubsection{\csh{CALX_signalcondition}}
%\begin{lverb}
% Syntax (f-expandable):
%(
%  \CALX_signalcondition{C}{M}{H}{V}  -> <result>
%)
% C a signal or condition name (InvalidOperation, DivisionByZero, ...),
% M the error message, H the handler argument, V the value returned if the
% signal is trapped; <result>: the handler's value (or V).
%
% \CALX_signalcondition$empty: identical to \XINT_signalcondition
% (xintcore.sty of xint 1.4p), renamed. The first \romannumeral0 step turns
% #1 into {<signal>}{<condition>}, then \CALX_signalcondition_a receives
%( #1 = signal, #2 = condition, #3 = error message,
%: #4 = handler argument, #5 = value returned if the signal is trapped.
%)
% Note that, as in Python, the "ignored" branch applies the handler of the
% SIGNAL, the untrapped branch the handler of the CONDITION.
%
% The expansion is complete (handler included) under f-expansion. The handlers
% defined here expand in one step to their result.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_signalcondition #1{\expandafter\CALX_signalcondition_a
    \romannumeral0\ifcsname CALX_#1-signal\endcsname
                    \xint_dothis{\csname CALX_#1-signal\endcsname}%
                  \fi\xint_orthat{{#1}}{#1}}%
\def\CALX_signalcondition_a %
    #1#2#3#4#5{% copied over from Python Decimal module
\ifcsname CALX_#1_isignoredflag\endcsname
       \xint_dothis{\csname CALX_#1.handler\endcsname {#4}}%
    \fi
    \expandafter\xint_gobble_i\csname CALX_#1Flag_ON\endcsname
    \unless\ifcsname CALX_#1_istrapped\endcsname
       \xint_dothis{\csname CALX_#2.handler\endcsname {#4}}%
    \fi
    \xint_orthat{%
       % the flag raised is named after the signal #1, but we show condition
       % #2
       \XINT_expandableerror{#3}%
       \xint_firstofone{#5}%
    }%
}%
\let\XINT_signalcondition\CALX_signalcondition
%    \end{macrocode}
%\begin{lverb}
% Flags. \CALX_RaiseFlag is xintcore's \XINT_RaiseFlag, for direct use by calx
% code (raising a flag without going through a handler). The public test and
% reset macros are xintcore's \XINT_ifFlagRaised, \XINT_resetFlag,
% \XINT_resetFlags made public; the reset obeys \XINT_global, and resets all
% eight flags (the xintcore version listed four).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_RaiseFlag #1{\expandafter\xint_gobble_i\csname CALX_#1Flag_ON%
    \endcsname}%
%    \end{macrocode}
% \subsubsection{\csh{calxifflagraised}, \csh{calxresetflag},
% \csh{calxresetflags}}
%    \begin{macrocode}
\def\calxifflagraised #1{%
    \ifcsname CALX_#1Flag_ON\endcsname
        \expandafter\xint_firstoftwo
    \else
        \expandafter\xint_secondoftwo
    \fi}%
%    \end{macrocode}
% \subsubsection{\csh{xintifNonFiniteSignalled}}
%\begin{lverb}
% True if InvalidOperation, DivisionByZero or Overflow was signalled in
% the current group since the last corresponding flag reset. The flags
% describe conditions, not the result: a handler can return a finite value.
% Literal NaN/Infinity values alone do not raise flags.
%\end{lverb}
%    \begin{macrocode}
\def\xintifNonFiniteSignalled{%
    \calxifflagraised{InvalidOperation}{\xint_firstoftwo}{%
      \calxifflagraised{DivisionByZero}{\xint_firstoftwo}{%
        \calxifflagraised{Overflow}{\xint_firstoftwo}{\xint_secondoftwo}%
      }%
    }%
}%
\def\calxresetflag #1%
    {\XINT_global\expandafter\let\csname CALX_#1Flag_ON\endcsname%
        \XINT_undefined}%
\def\calxresetflags {%
    \calxresetflag{Clamped}%
    \calxresetflag{DivisionByZero}%
    \calxresetflag{Inexact}%
    \calxresetflag{InvalidOperation}%
    \calxresetflag{Overflow}%
    \calxresetflag{Rounded}%
    \calxresetflag{Subnormal}%
    \calxresetflag{Underflow}%
}%
%    \end{macrocode}
%\begin{lverb}
% Default handlers. The xintcore table had _NaN and _SignedInfinity(#1) as
% placeholders; here they are the special value markers, catcode 12,
% produced by \detokenize. Underflow, which the xintcore table sent to
% _NaN, is the identity as in Python (Underflow is always accompanied by
% Inexact and Subnormal, and the result is the rounded one). DivisionByZero
% and Overflow both return signed infinity by default (round half up).
%\end{lverb}
%    \begin{macrocode}
\catcode`. 11
\let\CALX_Clamped.handler\xint_firstofone
\edef\CALX_InvalidOperation.handler#1{\detokenize{I?}}%
\let\CALX_ConversionSyntax.handler  \CALX_InvalidOperation.handler
\let\CALX_DivisionImpossible.handler\CALX_InvalidOperation.handler
\let\CALX_DivisionUndefined.handler \CALX_InvalidOperation.handler
\let\CALX_InvalidContext.handler    \CALX_InvalidOperation.handler
\let\CALX_ControversialOperation.handler\CALX_InvalidOperation.handler
\edef\CALX_Overflow.handler#1{\detokenize{I}#1}%
\let\CALX_DivisionByZero.handler\CALX_Overflow.handler
\let\CALX_Inexact.handler\xint_firstofone
\let\CALX_Rounded.handler\xint_firstofone
\let\CALX_Subnormal.handler\xint_firstofone
\let\CALX_Underflow.handler\xint_firstofone
\catcode`. 12
%    \end{macrocode}
%\begin{lverb}
% Traps: none is set at load time. (The xintcore code set all eight at load
% time: \csname XINT_<name>_istrapped\endcsname.)
%
% \calxsetup$empty: the parsing loop is \bnumsetup's (bnumexpr.dtx),
% with the key dispatched through \csname CALX_setup_<key>\endcsname, one
% such macro per valid key, defined below. The value is handed over complete
% (not only its first token as in \bnumsetup) because .trap keys take a word.
% Each CALX_setup_<key> macro receives {<key as typed>}{<value>}.
%\end{lverb}
%    \begin{macrocode}
\catcode`! 3
%    \end{macrocode}
% \subsubsection{\csh{calxsetup}}
%    \begin{macrocode}
\def\calxsetup #1{\CALX_parsekeys #1,=!,}%
\def\CALX_parsekeys #1=#2,%
  {%
    \ifx!#2\expandafter\CALX_parsedone\fi
    \ifcsname CALX_setup_\xint_zapspaces #1 \xint_gobble_i\endcsname
      \xint_dothis{\csname CALX_setup_\xint_zapspaces #1 \xint_gobble_i%
          \endcsname}%
    \fi
    \xint_orthat{\CALX_setup_badkey}{#1}{#2}%
    \CALX_parsekeys
  }%
\def\CALX_parsedone #1\CALX_parsekeys {}%
\catcode`! 12
\def\CALX_settrap #1#2#3{%
    \ifnum\xintstrcmp{\xint_zapspaces #3 \xint_gobble_i}{true}=\xint_c_
      \XINT_global\expandafter\let\csname CALX_#1_istrapped\endcsname\relax
      \CALX_setup_info{trap set for signal #1}%
    \else
    \ifnum\xintstrcmp{\xint_zapspaces #3 \xint_gobble_i}{false}=\xint_c_
      \XINT_global\expandafter\let\csname CALX_#1_istrapped\endcsname%
          \XINT_undefined
      \CALX_setup_info{trap removed for signal #1}%
    \else
      \CALX_setup_error{value \detokenize{#3} of key \detokenize{#2}
                        is neither true nor false}%
    \fi\fi
}%
\def\CALX_sethandler #1#2#3{%
    \XINT_global\expandafter\let\csname CALX_#1.handler\endcsname=#3%
    \CALX_setup_info{\string#3 assigned as handler of condition #1}%
}%
\def\CALX_setup_badkey #1#2{\CALX_setup_error{unknown key \detokenize{#1}}}%
\def\CALX_setup_info #1{%
    \ifxintverbose
      \xintMessage{calxcore}{Info}{\ifxintglobaldefs (global) \fi #1}%
    \fi
}%
\def\CALX_setup_error #1{%
    \xintMessage{calxcore}{Error}{\string\calxsetup\space #1}%
    \errhelp{See the comments of calxcore.sty on \string\calxsetup.}%
    \errmessage{calxcore: invalid input to \string\calxsetup}%
}%
\def\CALX_tmpa #1{%
    \expandafter\def\csname CALX_setup_#1.trap\endcsname{\CALX_settrap{#1}}%
}%
\CALX_tmpa{Clamped}\CALX_tmpa{DivisionByZero}\CALX_tmpa{Inexact}%
\CALX_tmpa{InvalidOperation}\CALX_tmpa{Overflow}\CALX_tmpa{Rounded}%
\CALX_tmpa{Subnormal}\CALX_tmpa{Underflow}%
\def\CALX_tmpa #1{%
    \expandafter\def\csname CALX_setup_#1.handler\endcsname{%
        \CALX_sethandler{#1}}%
}%
\CALX_tmpa{Clamped}\CALX_tmpa{DivisionByZero}\CALX_tmpa{Inexact}%
\CALX_tmpa{InvalidOperation}\CALX_tmpa{Overflow}\CALX_tmpa{Rounded}%
\CALX_tmpa{Subnormal}\CALX_tmpa{Underflow}%
\CALX_tmpa{ConversionSyntax}\CALX_tmpa{DivisionImpossible}%
\CALX_tmpa{DivisionUndefined}\CALX_tmpa{InvalidContext}%
\CALX_tmpa{ControversialOperation}%
\let\CALX_tmpa\XINT_undefined
%    \end{macrocode}
% \subsection{Blocks of eight digits}
%
% \subsubsection{\csh{XINT_cuz_small}}
%\begin{lverb}
% \XINT_cuz_small removes leading zeroes from the first eight digits. Expands
% following \romannumeral0. At least one digit is produced.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_cuz_small#1{%
\def\XINT_cuz_small ##1##2##3##4##5##6##7##8%
{%
    \expandafter#1\the\numexpr ##1##2##3##4##5##6##7##8\relax
}}\XINT_cuz_small{ }%
%    \end{macrocode}
% \subsubsection{\csh{XINT_zeroes_forviii}}
%
%\begin{lverb}
%( \romannumeral0\XINT_zeroes_forviii #1\R\R\R\R\R\R\R\R{10}0000001\W
%)
% produces a string of k 0's such that k+length(#1) is smallest bigger multiple
% of eight.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_zeroes_forviii #1#2#3#4#5#6#7#8%
{%
    \xint_gob_til_R #8\XINT_zeroes_forviii_end\R\XINT_zeroes_forviii
}%
\def\XINT_zeroes_forviii_end#1{%
\def\XINT_zeroes_forviii_end\R\XINT_zeroes_forviii ##1##2##3##4##5##6##7##8##9\W
{%
    \expandafter#1\xint_gob_til_one ##2##3##4##5##6##7##8%
}}\XINT_zeroes_forviii_end{ }%
%    \end{macrocode}
% \subsubsection{\csh{XINT_rsepbyviii}}
%
%\begin{lverb}
% This is used as
%( \the\numexpr1\XINT_rsepbyviii <8Ndigits>$%
%:              \XINT_rsepbyviii_end_A 2345678$%
%:              \XINT_rsepbyviii_end_B 2345678\relax UV$%
%)
% and will produce
%( 1<8digits>!1<8digits>\xint:1<8digits>!...
%) 
% where the original
% digits are organized by eight, and the order inside successive pairs of
% blocks separated by \xint: has been reversed. Output ends either in 
% 1<8d>!1<8d>\xint:1U\xint: (even) or 1<8d>!1<8d>\xint:1V!1<8d>\xint: (odd)
%
% The U an V should be \numexpr1 stoppers (or will expand and be ended by !).
% This macro is currently (1.2..1.2l) exclusively used in combination with
% \XINT_sepandrev_andcount or \XINT_sepandrev.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_rsepbyviii #1#2#3#4#5#6#7#8%
{%
    \XINT_rsepbyviii_b {#1#2#3#4#5#6#7#8}%
}%
\def\XINT_rsepbyviii_b #1#2#3#4#5#6#7#8#9%
{%
    #2#3#4#5#6#7#8#9\expandafter!\the\numexpr
    1#1\expandafter\xint:\the\numexpr 1\XINT_rsepbyviii
}%
\def\XINT_rsepbyviii_end_B #1\relax #2#3{#2\xint:}%
\def\XINT_rsepbyviii_end_A #11#2\expandafter #3\relax #4#5{#5!1#2\xint:}%
%    \end{macrocode}
% \subsubsection{\csh{XINT_sepandrev_andcount}}
%\begin{lverb}
% This is used typically as
%( \romannumeral0\XINT_sepandrev_andcount <8Ndigits>$%
%:              \XINT_rsepbyviii_end_A 2345678$%
%:              \XINT_rsepbyviii_end_B 2345678\relax\xint_c_ii\xint_c_i
%:              \R\xint:\xint_c_xii \R\xint:\xint_c_x  \R\xint:\xint_c_viii \R\xint:\xint_c_vi
%:              \R\xint:\xint_c_iv  \R\xint:\xint_c_ii \R\xint:\xint_c_\W
%)
% and will produce
%( <length>.1<8digits>!1<8digits>!1<8digits>!...
%)
% where the
% blocks have been globally reversed and <length> is the number of blocks.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_sepandrev_andcount
{%
    \expandafter\XINT_sepandrev_andcount_a\the\numexpr 1\XINT_rsepbyviii
}%
\def\XINT_sepandrev_andcount_a {\XINT_sepandrev_andcount_b 0!{}}%
\def\XINT_sepandrev_andcount_b #1!#2#3\xint:#4\xint:#5\xint:#6\xint:#7\xint:#8\xint:#9\xint:%
{%
    \xint_gob_til_R #9\XINT_sepandrev_andcount_end\R
    \expandafter\XINT_sepandrev_andcount_b \the\numexpr #1+\xint_c_i!%
    {#9!#8!#7!#6!#5!#4!#3!#2}%
}%
\def\XINT_sepandrev_andcount_end\R
    \expandafter\XINT_sepandrev_andcount_b\the\numexpr #1+\xint_c_i!#2#3#4\W
{\expandafter\XINT_sepandrev_andcount_done\the\numexpr #3+\xint_c_xiv*#1!#2}%
\def\XINT_sepandrev_andcount_done#1{%
\def\XINT_sepandrev_andcount_done##1!##21##3!{\expandafter#1\the\numexpr##1-##3\xint:}%
}\XINT_sepandrev_andcount_done{ }%
%    \end{macrocode}
% \subsubsection{\csh{XINT_rev_nounsep}}
%\begin{lverb}
% This is used as
%( \romannumeral0\XINT_rev_nounsep {}<blocks 1<8d>!>\R!\R!\R!\R!\R!\R!\R!\R!\W
%)
% It reverses the blocks, keeping the 1's and ! separators. Used multiple
% times in the division algorithm. The inserted {} here is not optional.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_rev_nounsep #1#2!#3!#4!#5!#6!#7!#8!#9!%
{%
    \xint_gob_til_R #9\XINT_rev_nounsep_end\R
    \XINT_rev_nounsep {#9!#8!#7!#6!#5!#4!#3!#2!#1}%
}%
\def\XINT_rev_nounsep_end\R\XINT_rev_nounsep #1#2\W {\XINT_rev_nounsep_done #1}%
\def\XINT_rev_nounsep_done #11{ 1}%
%    \end{macrocode}
% \subsubsection{\csh{XINT_unrevbyviii}}
%\begin{lverb}
% Used as \romannumeral0\XINT_unrevbyviii 1<8d>!....1<8d>! terminated
% by
%( 1;!1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W
%)
% The \romannumeral in unrevbyviii_a is for special effects (expand some token
% which was put as 1<token>! at the end of the original blocks). This
% mechanism is used by 1.2 subtraction (still true for 1.2l).
%\end{lverb}
%    \begin{macrocode}
\def\XINT_unrevbyviii #11#2!1#3!1#4!1#5!1#6!1#7!1#8!1#9!%
{%
    \xint_gob_til_R #9\XINT_unrevbyviii_a\R
    \XINT_unrevbyviii {#9#8#7#6#5#4#3#2#1}%
}%
\def\XINT_unrevbyviii_a#1{%
\def\XINT_unrevbyviii_a\R\XINT_unrevbyviii ##1##2\W
    {\expandafter#1\romannumeral`&&@\xint_gob_til_sc ##1}%
}\XINT_unrevbyviii_a{ }%
%    \end{macrocode}
% \subsubsection{Aliases for native callers}
%\begin{lverb}
% The native arithmetic section uses I and N with catcode 12. Its callers
% use CALX aliases of the common block utilities, whose implementations
% remain under the XINT names for the legacy packages.
%\end{lverb}
%    \begin{macrocode}
\let\CALX_cuz_small\XINT_cuz_small
\let\CALX_zeroes_forviii\XINT_zeroes_forviii
\let\CALX_rsepbyviii\XINT_rsepbyviii
\let\CALX_rsepbyviii_end_A\XINT_rsepbyviii_end_A
\let\CALX_rsepbyviii_end_B\XINT_rsepbyviii_end_B
\let\CALX_sepandrev_andcount\XINT_sepandrev_andcount
\let\CALX_rev_nounsep\XINT_rev_nounsep
\let\CALX_unrevbyviii\XINT_unrevbyviii
%    \end{macrocode}
% \subsection{Core arithmetic}
%
% \subsubsection{\csh{CALX_add_a}}
%\begin{lverb}
% From this subsection of xintcore (\xintiiAdd$empty) calx copies only the
% macros used by the native layer: \CALX_add_a, \CALX_add_b, \CALX_add_bi,
% \CALX_add_c, \CALX_add_d, \CALX_add_di, \CALX_add_e, \CALX_add_f,
% \CALX_add_fi, \CALX_add_g, \CALX_add_h, \CALX_add_hi, \CALX_add_i,
% \CALX_add_k, \CALX_add_ke, \CALX_add_kf, \CALX_add_l, \CALX_add_lf,
% \CALX_add_m, \CALX_add_n, \CALX_add_o. The other macros are not copied.
%\end{lverb}
%
%    \begin{macrocode}
\def\CALX_add_a #1!#2!#3!#4!#5\W
                #6!#7!#8!#9!%
{%
    \CALX_add_b 
        #1!#6!#2!#7!#3!#8!#4!#9!%
        #5\W
}%
\def\CALX_add_b #11#2#3!#4!%
{%
    \xint_gob_til_sc #2\CALX_add_bi ;%
    \expandafter\CALX_add_c\the\numexpr#1+1#2#3+#4-\xint_c_ii\xint:%
}%
\def\CALX_add_bi;\expandafter\CALX_add_c
    \the\numexpr#1+#2+#3-\xint_c_ii\xint:#4!#5!#6!#7!#8!#9!\W
{%
    \CALX_add_k #1#3!#5!#7!#9!%
}%
\def\CALX_add_c #1#2\xint:%
{%
    1#2\expandafter!\the\numexpr\CALX_add_d #1%
}%
\def\CALX_add_d #11#2#3!#4!%
{%
    \xint_gob_til_sc #2\CALX_add_di ;%
    \expandafter\CALX_add_e\the\numexpr#1+1#2#3+#4-\xint_c_ii\xint:%
}%
\def\CALX_add_di;\expandafter\CALX_add_e
    \the\numexpr#1+#2+#3-\xint_c_ii\xint:#4!#5!#6!#7!#8\W
{%
    \CALX_add_k #1#3!#5!#7!%
}%
\def\CALX_add_e #1#2\xint:%
{%
    1#2\expandafter!\the\numexpr\CALX_add_f #1%
}%
\def\CALX_add_f #11#2#3!#4!%
{%
    \xint_gob_til_sc #2\CALX_add_fi ;%
    \expandafter\CALX_add_g\the\numexpr#1+1#2#3+#4-\xint_c_ii\xint:%
}%
\def\CALX_add_fi;\expandafter\CALX_add_g
    \the\numexpr#1+#2+#3-\xint_c_ii\xint:#4!#5!#6\W
{%
    \CALX_add_k #1#3!#5!%
}%
\def\CALX_add_g #1#2\xint:%
{%
    1#2\expandafter!\the\numexpr\CALX_add_h #1%
}%
\def\CALX_add_h #11#2#3!#4!%
{%
    \xint_gob_til_sc #2\CALX_add_hi ;%
    \expandafter\CALX_add_i\the\numexpr#1+1#2#3+#4-\xint_c_ii\xint:%
}%
\def\CALX_add_hi;%
    \expandafter\CALX_add_i\the\numexpr#1+#2+#3-\xint_c_ii\xint:#4\W
{%
    \CALX_add_k #1#3!%
}%
\def\CALX_add_i #1#2\xint:%
{%
    1#2\expandafter!\the\numexpr\CALX_add_a #1%
}%
\def\CALX_add_k #1{\if #12\expandafter\CALX_add_ke\else\expandafter%
    \CALX_add_l \fi}%
\def\CALX_add_ke #11;#2\W {\CALX_add_kf #11;!}%
\def\CALX_add_kf 1{1\relax }%
\def\CALX_add_l 1#1{\xint_gob_til_sc #1\CALX_add_lf ;\CALX_add_m 1#1}%
\def\CALX_add_lf #1\W {1\relax 00000001!1;!}%
\def\CALX_add_m #1!{\expandafter\CALX_add_n\the\numexpr\xint_c_i+#1\xint:}%
\def\CALX_add_n #1#2\xint:{1#2\expandafter!\the\numexpr\CALX_add_o #1}%
\def\CALX_add_o #1{\if #12\expandafter\CALX_add_l\else\expandafter%
    \CALX_add_ke \fi}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_mul_loop}, \csh{CALX_smallmul},
% \csh{CALX_verysmallmul}}
%\begin{lverb}
% From this subsection of xintcore (\xintiiMul$empty) calx copies only the
% macros used by the native layer: \CALX_mul_loop, \CALX_mul_a, \CALX_mul_b,
% \CALX_mul_e, \CALX_minimulwc_a, \CALX_minimulwc_b, \CALX_minimulwc_c,
% \CALX_smallmul, \CALX_smallmul_a, \CALX_smallmul_e, \CALX_smallmul_f,
% \CALX_verysmallmul, \CALX_verysmallmul_e, \CALX_verysmallmul_f,
% \CALX_verysmallmul_a, \CALX_verysmallmul_bj, \CALX_verysmallmul_cj,
% \CALX_verysmallmul_bi, \CALX_minimul_a, \CALX_minimul_b, \CALX_minimul_c.
% The other macros are not copied.
%\end{lverb}
%
%    \begin{macrocode}
\def\CALX_mul_loop #1\W #2\W 1#3!%
{%
    \xint_gob_til_sc #3\CALX_mul_e ;%
    \expandafter\CALX_mul_a\the\numexpr \CALX_smallmul 1#3!#2\W
    #1\W #2\W
}%
\def\CALX_mul_a #1\W #2\W
{%
    \expandafter\CALX_mul_b\the\numexpr
    \CALX_add_a \xint_c_ii #21;!1;!1;!\W #11;!1;!1;!\W\W
}%
\def\CALX_mul_b 1#1!{1#1\expandafter!\the\numexpr\CALX_mul_loop }%
\def\CALX_mul_e;#1\W 1#2\W #3\W {1\relax #2}%
%    \end{macrocode}
%
%    \begin{macrocode}
\def\CALX_minimulwc_a 1#1\xint:#2\xint:#3!#4#5#6#7#8\xint:%
{%
    \expandafter\CALX_minimulwc_b
    \the\numexpr \xint_c_e_ix+#1+#3*#8\xint:
                     #3*#4#5#6#7+#2*#8\xint:
                           #2*#4#5#6#7\xint:%
}%
\def\CALX_minimulwc_b 1#1#2#3#4#5#6\xint:#7\xint:%
{%
    \expandafter\CALX_minimulwc_c
    \the\numexpr \xint_c_e_ix+#1#2#3#4#5+#7\xint:#6\xint:%
}%
\def\CALX_minimulwc_c 1#1#2#3#4#5#6\xint:#7\xint:#8\xint:%
{%
    1#6#7\expandafter!%
    \the\numexpr\expandafter\CALX_smallmul_a
    \the\numexpr \xint_c_e_viii+#1#2#3#4#5+#8\xint:%
}%
\def\CALX_smallmul 1#1#2#3#4#5!{\CALX_smallmul_a 100000000\xint:#1#2#3#4%
    \xint:#5!}%
\def\CALX_smallmul_a #1\xint:#2\xint:#3!1#4!%
{%
    \xint_gob_til_sc #4\CALX_smallmul_e;%
    \CALX_minimulwc_a #1\xint:#2\xint:#3!#4\xint:#2\xint:#3!%
}%
\def\CALX_smallmul_e;\CALX_minimulwc_a 1#1\xint:#2;#3!%
    {\xint_gob_til_eightzeroes #1\CALX_smallmul_f 000000001\relax #1!1;!}%
\def\CALX_smallmul_f 000000001\relax 00000000!1{1\relax}%
\def\CALX_verysmallmul #1\xint:#2!1#3!%
{%
    \xint_gob_til_sc #3\CALX_verysmallmul_e;%
    \expandafter\CALX_verysmallmul_a
    \the\numexpr #2*#3+#1\xint:#2!%
}%
\def\CALX_verysmallmul_e;\expandafter\CALX_verysmallmul_a\the\numexpr
    #1+#2#3\xint:#4!%
{\xint_gob_til_zero #2\CALX_verysmallmul_f 0\xint_c_e_viii+#2#3!1;!}%
\def\CALX_verysmallmul_f #1!1{1\relax}%
\def\CALX_verysmallmul_a #1#2\xint:%
{%
    \unless\ifnum #1#2<\xint_c_e_ix
    \expandafter\CALX_verysmallmul_bi\else
    \expandafter\CALX_verysmallmul_bj\fi
    \the\numexpr \xint_c_e_ix+#1#2\xint:%
}%
\def\CALX_verysmallmul_bj{\expandafter\CALX_verysmallmul_cj }%
\def\CALX_verysmallmul_cj 1#1#2\xint:%
    {1#2\expandafter!\the\numexpr\CALX_verysmallmul #1\xint:}%
\def\CALX_verysmallmul_bi\the\numexpr\xint_c_e_ix+#1#2#3\xint:%
    {1#3\expandafter!\the\numexpr\CALX_verysmallmul #1#2\xint:}%
%    \end{macrocode}
%
%    \begin{macrocode}
\def\CALX_minimul_a #1\xint:#2!#3#4#5#6#7!%
{%
    \expandafter\CALX_minimul_b
    \the\numexpr \xint_c_e_viii+#2*#7\xint:#2*#3#4#5#6+#1*#7\xint:#1*#3#4#5#6%
        \xint:%
}%
\def\CALX_minimul_b 1#1#2#3#4#5\xint:#6\xint:%
{%
    \expandafter\CALX_minimul_c
    \the\numexpr \xint_c_e_ix+#1#2#3#4+#6\xint:#5\xint:%
}%
\def\CALX_minimul_c 1#1#2#3#4#5#6\xint:#7\xint:#8\xint:%
{%
    1#6#7\expandafter!\the\numexpr \xint_c_e_viii+#1#2#3#4#5+#8!%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_smalldivx_a}}
%\begin{lverb}
% From this subsection of xintcore (\xintiiDivision$empty) calx copies only
% the macros used by the native layer: \CALX_smalldivx_a, \CALX_smalldivx_b,
% \CALX_smalldiv_c, \CALX_smalldiv_d, \CALX_smalldiv_end, \CALX_smalldiv_e,
% \CALX_smalldiv_f, \CALX_smalldiv_fz, \CALX_smalldiv_g, \CALX_smalldiv_h,
% \CALX_smalldiv_i, \CALX_smalldiv_j, \CALX_smalldiv_k. The other macros are
% not copied.
%\end{lverb}
%
%    \begin{macrocode}
\def\CALX_smalldivx_a #1\xint:1#2!1#3!%
{%
    \expandafter\CALX_smalldivx_b
    \the\numexpr (#3+#1)/#2-\xint_c_i!#1\xint:#2!#3!%
}%
\def\CALX_smalldivx_b #1#2!%
{%
    \if0#1\else
          \xint_c_e_viii+#1#2\xint_afterfi{\expandafter!\the\numexpr}\fi
    \CALX_smalldiv_c #1#2!%
}%
\def\CALX_smalldiv_c #1!#2\xint:#3!#4!%
{%
    \expandafter\CALX_smalldiv_d\the\numexpr #4-#1*#3!#2\xint:#3!%
}%
\def\CALX_smalldiv_d #1!#2!1#3#4!%
{%
    \xint_gob_til_sc #3\CALX_smalldiv_end ;%
    \CALX_smalldiv_e #1!#2!1#3#4!%
}%
\def\CALX_smalldiv_end;\CALX_smalldiv_e #1!#2!1;!{1!;!#1!}%
\def\CALX_smalldiv_e #1!#2\xint:#3!%
{%
    \expandafter\CALX_smalldiv_f\the\numexpr
    \xint_c_xi_e_viii_mone+#1*\xint_c_e_viii/#3!#2\xint:#3!#1!%
}%
\def\CALX_smalldiv_f 1#1#2#3#4#5#6!#7\xint:#8!%
{%
     \xint_gob_til_zero #1\CALX_smalldiv_fz 0%
     \expandafter\CALX_smalldiv_g
     \the\numexpr\CALX_minimul_a #2#3#4#5\xint:#6!#8!#2#3#4#5#6!#7\xint:#8!%
}%
\def\CALX_smalldiv_fz 0%
    \expandafter\CALX_smalldiv_g\the\numexpr\CALX_minimul_a
    9999\xint:9999!#1!99999999!#2!0!1#3!%
{%
    \CALX_smalldiv_i \xint:#3!\xint_c_!#2!%
}%
\def\CALX_smalldiv_g 1#1!1#2!#3!#4!#5!#6!%
{%
    \expandafter\CALX_smalldiv_h\the\numexpr 1#6-#1\xint:#2!#5!#3!#4!%
}%
\def\CALX_smalldiv_h 1#1#2\xint:#3!#4!%
{%
    \expandafter\CALX_smalldiv_i\the\numexpr #4-#3+#1-\xint_c_i\xint:#2!%
}%
\def\CALX_smalldiv_i #1\xint:#2!#3!#4\xint:#5!%
{%
    \expandafter\CALX_smalldiv_j\the\numexpr (#1#2+#4)/#5-%
        \xint_c_i!#3!#1#2!#4\xint:#5!%
}%
\def\CALX_smalldiv_j #1!#2!%
{%
    \xint_c_e_viii+#1+#2\expandafter!\the\numexpr\CALX_smalldiv_k
    #1!%
}%
\def\CALX_smalldiv_k #1!#2!#3\xint:#4!%
{%
    \expandafter\CALX_smalldiv_d\the\numexpr #2-#1*#4!#3\xint:#4!%
}%
%    \end{macrocode}
% \subsection{Native integer format}
%\begin{lverb}
% A calx integer in native format is the sequence of catcode 12 tokens
%( N <sign> <n> . <block_1> <block_2> ... <block_n>
%)
%- N: type tag;
%- <sign>: + or -, always present; zero is N+0. (no blocks);
%- <n>: number of blocks, decimal, terminated by a dot;
%- the blocks are xint's blocks 1dddddddd! (the 1 protects leading zeros
% for \numexpr), least significant block first;
%- the most significant block (the last one) is not 00000000.
%
% The value is <sign> sum_{k=1}^{n} d_k 10^{8(k-1)} with d_k the 8 digits of
% <block_k>. There is no terminator: macros append their own delimiters.
%
% All macros below are used as \romannumeral0\CALX_n...{...}{...} and
% deliver their result after a space token. Arguments are f-expanded first
% (as in xintcore).
%
% Coding rules followed here (second pass, efficiency):
%- block lists are copied as few times as possible: a macro parameter
% holding blocks appears ONCE in each replacement text; branch selection
% (\xint_dothis/\xint_orthat, \ifcase) only selects a macro token, the
% arguments follow once after the selection;
%- the header N<sign><n>. of a result is produced in front of the blocks
% by \expandafter\CALX_sp\expandafter N\expandafter<sign>\the\numexpr<n>.
% so that the blocks, once grabbed to remove the kernel terminator 1;!,
% are not grabbed again (\CALX_sp expands to the space which ends the
% \romannumeral0 expansion);
%- counting the blocks of a product skips them seven at a time.
%
% In this section N and I have catcode 12, so macro names here use neither
% letter in upper case.
%\end{lverb}
%    \begin{macrocode}
\catcode`N=12 \catcode`I=12
%    \end{macrocode}
%\begin{lverb}
% \CALX_sp expands to a space token; it ends the \romannumeral0 expansion of
% the native macros.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_sp{ }%
%    \end{macrocode}
%\begin{lverb}
% \CALX_pten{k} = 10^k, 0 <= k <= 8, k a \numexpr expression: one
% \csname lookup of \CALX_pt<k> (k in decimal), cheaper than an \ifcase
% table. The other value tables and dispatches of calx are built in the
% same way.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_pten #1{\csname CALX_pt\the\numexpr#1\endcsname}%
\expandafter\def\csname CALX_pt0\endcsname{1}%
\expandafter\def\csname CALX_pt1\endcsname{10}%
\expandafter\def\csname CALX_pt2\endcsname{100}%
\expandafter\def\csname CALX_pt3\endcsname{1000}%
\expandafter\def\csname CALX_pt4\endcsname{10000}%
\expandafter\def\csname CALX_pt5\endcsname{100000}%
\expandafter\def\csname CALX_pt6\endcsname{1000000}%
\expandafter\def\csname CALX_pt7\endcsname{10000000}%
\expandafter\def\csname CALX_pt8\endcsname{100000000}%
%    \end{macrocode}
%\begin{lverb}
% Digit counts without \ifnum (each \ifnum scans its two numbers: three
% nested \ifnum on an 8-digit block cost about twice as much). The digits
% are followed by a sentinel list and the ninth token is the answer
% (xintfrac's \XINT_FL_fac_countdigits); \CALX_nd_b removes the leftover
% sentinel up to \xint: and outputs the answer, so the macros are
% f-expandable.
%- \CALX_ndig{v}: number of digits of 0 <= v < 10^8 (1 for 0); v may have
% leading zeros (removed by \numexpr);
%- \CALX_ndigs{v}: same, v explicit digits without leading zeros;
%- \CALX_nlz{v}: number of leading zeros of an 8-digit block v > 0.
%
% \CALX_nd_c <v><s_1>...<s_10>\xint: (v: 1 to 10 explicit digits, no
% leading zero; s_k: one token or a braced group) outputs s_k for
% k = 11 - (number of digits of v), the eleventh token: a value per digit
% count (sentinel list of the caller).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ndig #1%
   {\expandafter\CALX_nd_a\the\numexpr#1\relax 87654321\xint:}%
\def\CALX_ndigs #1{\CALX_nd_a #187654321\xint:}%
\def\CALX_nlz #1%
   {\expandafter\CALX_nd_a\the\numexpr#1\relax 01234567\xint:}%
\def\CALX_nd_a #1#2#3#4#5#6#7#8#9{\CALX_nd_b #9}%
\def\CALX_nd_b #1#2\xint:{#1}%
\def\CALX_nd_c #1#2#3#4#5#6#7#8#9{\CALX_nd_d}%
\def\CALX_nd_d #1#2#3\xint:{#2}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nfromraw}}
%\begin{lverb}
% Syntax (use with \romannumeral0; R f-expanded):
%(
%  \CALX_nfromraw{R}  -> <space>N<s><n>.<blocks>
%)
% Conversion from the raw integer format of xintcore (optional minus sign, no
% leading zeros, zero is 0) to native. The shared \CALX_sepandrev_andcount,
% as called by \XINT_add_pp_a, delivers <n>\xint:<blocks LS-first>, and
% \CALX_nfromraw_c inserts the header without touching the blocks.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nfromraw #1{\expandafter\CALX_nfromraw_a\romannumeral`&&@#1\xint:}%
\def\CALX_nfromraw_a #1{%
    \xint_UDzerominusfork
       #1-{\CALX_nfromraw_z}%
       0#1{\CALX_nfromraw_b -}%
        0-{\CALX_nfromraw_b +#1}%
    \krof
}%
\def\CALX_nfromraw_z #1\xint:{ N+0.}%
\def\CALX_nfromraw_b #1#2\xint:{%
    \expandafter\CALX_nfromraw_c\expandafter#1%
    \romannumeral0\expandafter\CALX_sepandrev_andcount
    \romannumeral0\CALX_zeroes_forviii #2\R\R\R\R\R\R\R\R{10}0000001\W
    #2\CALX_rsepbyviii_end_A 2345678%
      \CALX_rsepbyviii_end_B 2345678\relax\xint_c_ii\xint_c_i
          \R\xint:\xint_c_xii \R\xint:\xint_c_x  \R\xint:\xint_c_viii \R%
              \xint:\xint_c_vi
          \R\xint:\xint_c_iv  \R\xint:\xint_c_ii \R\xint:\xint_c_\W
}%
\def\CALX_nfromraw_c #1#2\xint:{ N#1#2.}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_ntoraw}}
%\begin{lverb}
% Syntax (use with \romannumeral0; X f-expanded native integer):
%(
%  \CALX_ntoraw{X}  -> <raw integer>   (xintcore format: -digits, digits, 0)
%)
% Conversion to raw: the shared \CALX_unrevbyviii then \CALX_cuz_small,
% as in \XINT_add_out. The header is examined without grabbing the blocks.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ntoraw #1{\expandafter\CALX_ntoraw_a\romannumeral`&&@#1\xint:}%
\def\CALX_ntoraw_a N#1#2.{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_ntoraw_z\fi
    \if-#1\xint_dothis\CALX_ntoraw_m\fi
    \xint_orthat\CALX_ntoraw_b
}%
\def\CALX_ntoraw_z #1\xint:{ 0}%
\def\CALX_ntoraw_m {\expandafter-\romannumeral0\CALX_ntoraw_b}%
\def\CALX_ntoraw_b #1\xint:{%
    \expandafter\CALX_cuz_small\romannumeral0\CALX_unrevbyviii {}#11;!%
    1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nskip}}
%\begin{lverb}
% Skipping blocks. \CALX_nskip <cont><k>.<blocks> removes k blocks (k a
% \numexpr expression, k>=0) and leaves <cont> in front of what follows.
% The whole skip is done inside \romannumeral\csname, <cont> waits behind
% an \expandafter. \CALX_nskip_a takes the first two tokens of k: if the
% second one is the dot (k <= 9), \xint_gob_til_dot leaves \CALX_nskip_s,
% which completes the name \CALX_nskip<k>; this macro removes the k blocks
% and expands to \xint_c_ (ends \romannumeral). Otherwise \CALX_nskip_g
% removes eight blocks and loops.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nskip #1#2.{\expandafter#1\romannumeral
                      \csname\expandafter\CALX_nskip_a\the\numexpr#2.}%
\def\CALX_nskip_a #1#2%
   {\xint_gob_til_dot #2\CALX_nskip_s.\CALX_nskip_g #1#2}%
\def\CALX_nskip_s.\CALX_nskip_g #1.{CALX_nskip#1\endcsname}%
\def\CALX_nskip_g #1.#2!#3!#4!#5!#6!#7!#8!#9!%
    {\expandafter\CALX_nskip_a\the\numexpr#1-\xint_c_viii.}%
\expandafter\let\csname CALX_nskip0\endcsname\xint_c_
\expandafter\def\csname CALX_nskip1\endcsname #1!{\xint_c_}%
\expandafter\def\csname CALX_nskip2\endcsname #1!#2!{\xint_c_}%
\expandafter\def\csname CALX_nskip3\endcsname #1!#2!#3!{\xint_c_}%
\expandafter\def\csname CALX_nskip4\endcsname #1!#2!#3!#4!{\xint_c_}%
\expandafter\def\csname CALX_nskip5\endcsname #1!#2!#3!#4!#5!{\xint_c_}%
\expandafter\def\csname CALX_nskip6\endcsname #1!#2!#3!#4!#5!#6!{\xint_c_}%
\expandafter\def\csname CALX_nskip7\endcsname #1!#2!#3!#4!#5!#6!#7!%
   {\xint_c_}%
\expandafter\def\csname CALX_nskip8\endcsname #1!#2!#3!#4!#5!#6!#7!#8!%
   {\xint_c_}%
\expandafter\def\csname CALX_nskip9\endcsname #1!#2!#3!#4!#5!#6!#7!#8!#9!%
   {\xint_c_}%
%    \end{macrocode}
% \subsection{Sign and zero tests of values}
% \subsubsection{\csh{CALX_ifnz}, \csh{CALX_ifsgn}}
%\begin{lverb}
% Syntax (use with \romannumeral0; X f-expanded):
%(
%  \CALX_ifnz{X}{A}{B}                 -> <space>A (X <> 0) or <space>B
%:  \CALX_ifnz_a <v>\xint:<y><n>        -> <y> (v <> 0) or <n>
%:  \CALX_ifsgn{X}{A}{B}{C}             -> <space>A, B or C (X <0, =0, >0)
%:  \CALX_ifsgn_a <v>\xint:{A}{B}{C}    -> the same
%)
% The values are those of the three parsers, after f-expansion: native
% N<s><n>., M<s><n>.<e>., F<s><D>.<e>. (blocks after the header), I+,
% I-, I?, or raw A, A[N], A/B[N] (A a raw integer without leading zeros,
% B > 0). The low level forms take the value v already expanded, in front
% of the \xint: that ends it; \CALX_ifnz_a also takes the two tokens <y>
% and <n> which select a branch (\CALX_ifnz uses \xint_stop_atfirstoftwo,
% \xint_stop_atsecondoftwo; loops use \xint_firstoftwo, \xint_secondoftwo,
% which add no space).
%
% Only the first tokens are read, no xintfrac parsing: 0 is zero, - is
% negative, another digit is positive; a token of character code above `9
% is a tag: I+ and I- are infinities, I? is non-zero for \CALX_ifnz and
% signals InvalidOperation for \CALX_ifsgn, which then takes the zero
% branch; after F, M, N comes the sign token, then the count, whose first
% character is 0 only for zero.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ifnz #1{\expandafter\CALX_ifnz_a\romannumeral`&&@#1\xint:%
    \xint_stop_atfirstoftwo\xint_stop_atsecondoftwo}%
\def\CALX_ifnz_a #1%
{%
    \if0#1\xint_dothis\CALX_ifnz_z\fi
    \ifnum`#1>57 \xint_dothis\CALX_ifnz_t\fi
    \xint_orthat\CALX_ifnz_n #1%
}%
\def\CALX_ifnz_t #1#2%
   {\if I#1\expandafter\CALX_ifnz_n\else\expandafter\CALX_ifnz_c\fi}%
\def\CALX_ifnz_c #1%
   {\if0#1\expandafter\CALX_ifnz_z\else\expandafter\CALX_ifnz_n\fi}%
\def\CALX_ifnz_z #1\xint:#2#3{#3}%
\def\CALX_ifnz_n #1\xint:#2#3{#2}%
\def\CALX_ifsgn #1{\expandafter\CALX_ifsgn_a\romannumeral`&&@#1\xint:}%
\def\CALX_ifsgn_a #1%
{%
    \if0#1\xint_dothis\CALX_ifsgn_z\fi
    \if-#1\xint_dothis\CALX_ifsgn_m\fi
    \ifnum`#1>57 \xint_dothis\CALX_ifsgn_t\fi
    \xint_orthat\CALX_ifsgn_p #1%
}%
\def\CALX_ifsgn_t #1#2%
   {\if I#1\expandafter\CALX_ifsgn_i\else\expandafter\CALX_ifsgn_c\fi #2}%
\def\CALX_ifsgn_c #1#2%
{%
    \if0#2\xint_dothis\CALX_ifsgn_z\fi
    \if-#1\xint_dothis\CALX_ifsgn_m\fi
    \xint_orthat\CALX_ifsgn_p
}%
\def\CALX_ifsgn_i #1%
{%
    \if-#1\xint_dothis\CALX_ifsgn_m\fi
    \if+#1\xint_dothis\CALX_ifsgn_p\fi
    \xint_orthat\CALX_ifsgn_q
}%
\def\CALX_ifsgn_q #1\xint:%
   {\expandafter\CALX_ifsgn_z\romannumeral`&&@%
    \CALX_signalcondition{InvalidOperation}{sign of I?}{}{}\xint:}%
\def\CALX_ifsgn_z #1\xint:{\xint_stop_atsecondofthree}%
\def\CALX_ifsgn_m #1\xint:{\xint_stop_atfirstofthree}%
\def\CALX_ifsgn_p #1\xint:{\xint_stop_atthirdofthree}%
%    \end{macrocode}
% \subsection{Native addition and subtraction}
% \subsubsection{\csh{CALX_nadd}}
%\begin{lverb}
% Syntax (use with \romannumeral0; X, Y f-expanded, native integers or
% I+, I-, I?):
%(
%  \CALX_nadd{X}{Y}  -> <space>Z    Z = X + Y
%:  \CALX_nsub{X}{Y}  -> <space>Z    Z = X - Y
%)
% Z: native integer, or I+, I-, I? (special operands, rules of the
% signals section).
%
% Addition and subtraction: dispatch.
%
% \CALX_nadd{X}{Y}: \CALX_nadd_x f-expands Y and leaves
%( Y\xint:X1;!1;!1;!1;!\W\xint:
%)
% so that X is already followed by the kernel terminator. With P = Y
% (count n, sign s) and Q = X (count m, sign t), \CALX_nadd_y grabs only
% P's list and Q's header N<t><m>. and runs a chain of tests. A test
% that fires puts a "jumper" in its branch: a macro taking a few data
% tokens, delimited by the \fi of that branch, which swallows the rest
% of \CALX_nadd_y's body (P's list included) and starts with the \fi it
% removed. Without jumper, the common case runs inline: same signs and
% n<=m, kernel started with P's list, Q's list left where it is.
%( n=0: Q                                  \CALX_nadd_retx
%: m=0: P                                  \CALX_nadd_rety
%: s<>t, n<m: |Q|-|P|, sign t, Q in place \CALX_ndiff_q
%: s<>t, n>m: |P|-|Q|, sign s              \CALX_ndiff_p
%: s<>t, n=m: P-Q, possibly negative       \CALX_ndiff_e
%: s=t,  n>m: Q shorter                    \CALX_nsum_q
%: s=t,  n<=m: inline
%)
% The count of the result (m, or n) is written BEFORE the kernel:
%( \expandafter\CALX_naddm\expandafter<sign>\the\numexpr<count>%
%:   \expandafter.\the\numexpr\CALX_nadd_a\xint_c_ii<S>1;!1;!1;!1;!\W
%:   <L>1;!1;!1;!1;!\W\xint:
%)
% Lists grabbed: P's once more in the jumper cases, Q's once in
% \CALX_ndiff_p, _e and \CALX_nsum_q, the result once by the final macro
% (its header must precede it).
%
% Addition kernel: xintcore's \XINT_add_a ... \XINT_add_o (xintcore
% l.598-668, code-only numbering), copied as \CALX_nadd_a ... \CALX_nadd_o.
%
% Contract: first list the SHORTER (or equal) one, both lists followed by
% 1;!1;!1;!1;!\W, initial state 2; output: the LS-first sum blocks followed
% by 1;!, then the tokens which followed the second list's \W. The only
% place where the result gets one more block than the longer operand is
% \XINT_add_lf, which appends block 00000001; its copy \CALX_nadd_lf also
% emits +\xint_c_i after the 1;!, before the final \xint:. \CALX_naddm
% grabs <count>. the list and that optional increment.
%
% Subtraction kernel: xintcore's \XINT_sub_a ... \XINT_sub_i with
% \XINT_sub_bi, _di, _fi, _hi (xintcore l.786-851, code-only numbering),
% copied as \CALX_nsub_*. Contract: called as
%( \CALX_nsub_a\xint_c_i <S>1;!1;!1;!1;!\W <L>1;!1;!1;!1;!\W
%)
% with S not longer than L, it computes L-S; each step produces a block and a
% state digit, 1 for no borrow, 0 for borrow; when S is exhausted it calls
%( \CALX_nsub_k <state><remaining L blocks>1;!1;!1;!1;!\W
%)
% xintcore's \XINT_sub_k and what follows are tied to its decimal output; the
% end of the loop (\CALX_nsub_k and the following) is calx's own. It ends
% the list with 1;! followed by one digit, before the final \xint:.
%
% Unequal lengths (n_L > n_S): remaining L blocks are not empty and
% |L| > |S|, so a final borrow is absorbed by L:
%- no borrow: copy the remaining blocks (\CALX_nsub_kc), digit 0;
%- borrow: 00000000 blocks become 99999999 and the borrow goes on; the
% first non zero block d becomes d-1, then copy (\CALX_nsub_kb). If d is
% the top block (next is 1;!) and d=1, the block is dropped
% (\CALX_nsub_kt) and the digit is 1: the blocks produced by the loop
% below it may be zero (e.g. 10^16-(10^16-1)). This happens only when
% n_L=n_S+1, the top block of L is 00000001 and absorbs a borrow.
%
% \CALX_nsubu: digit 0, the result is final; digit 1, \CALX_nsubrd takes
% the n_L-1 blocks again with \CALX_ntakex and normalizes (\CALX_nnorm).
%
% Equal lengths: remaining L blocks are empty; \CALX_nsub_ke ends the list
% and leaves the state as digit. State 0 means P<Q and the blocks hold
% 10^(8n)+P-Q: \CALX_nsubng<sign> complements them (\CALX_nnega), flips
% the sign and goes to \CALX_nsubf. \CALX_nsubf examines the top block
% (\CALX_ntop_c): if it is not zero, the count is n and the result is
% final; otherwise \CALX_nsubr strips zero top blocks (\CALX_nnorm).
%
% \CALX_ntakex <n>. takes exactly n blocks 1<8 digits>! from the input
% stream and leaves them followed by 1;! (inside \numexpr chains): the
% list then needs no delimiter, so the final result N<s><n>.<list> can be
% left as is in the common case and taken again only in the rare ones.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nadd #1{\expandafter\CALX_nadd_x\romannumeral`&&@#1\xint:}%
\def\CALX_nadd_x #1#2\xint:#3{\expandafter\CALX_nsp_t\expandafter\CALX_nadd_y
    \expandafter\CALX_nadd_sp\expandafter#1\romannumeral`&&@#3\xint:#1#2%
        1;!1;!1;!1;!\W\xint:}%
%    \end{macrocode}
%\begin{lverb}
% Special values (SPEC_native D9). \CALX_nsp_t <fast><special><tX><tY>
% (tags of X and Y, the stream continues with Y without its tag, then
% \xint:X<tail>\xint:, see below): both tags N: <fast><tY>, else
% <special><tX><tY>. For \CALX_nmul <tail> is empty.
%
% \CALX_nadd_sp <tX><tY><sY>...\xint:<tX><sX>...\xint: (the tail of X
% is swallowed with it; s = second token:
% sign, or + - ? after I): NaN in an operand: I?; Inf + finite: that Inf;
% Inf + Inf: that Inf if same sign, else InvalidOperation (default I?).
%
% \CALX_nsub_sp flips sY (I? unchanged) and goes to \CALX_nadd_sp.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsp_t #1#2#3#4%
   {\if\if N#3#4\else ?\fi N\xint_dothis{#1#4}\fi\xint_orthat{#2#3#4}}%
\def\CALX_nadd_sp #1#2#3#4\xint:#5#6#7\xint:%
{%
    \if ?#3\xint_dothis{ I?}\fi
    \if ?#6\xint_dothis{ I?}\fi
    \if N#2\xint_dothis{ I#6}\fi
    \if N#5\xint_dothis{ I#3}\fi
    \if #3#6\xint_dothis{ I#3}\fi
    \xint_orthat{\CALX_nsig{InvalidOperation}{inf - inf}{}}%
}%
\def\CALX_nadd_y N#1#2.#3\xint:N#4#5.%
{%
    \ifnum#2=\xint_c_ \CALX_nadd_retx#4#5.\fi
    \ifnum#5=\xint_c_ \CALX_nadd_rety#1#2.\fi
    \if#1#4\else
      \ifnum#2<#5 \CALX_ndiff_q#4#5.\fi
      \ifnum#2>#5 \CALX_ndiff_p#1#2.\fi
      \CALX_ndiff_e#1#2.%
    \fi
    \ifnum#2>#5 \CALX_nsum_q#1#2.\fi
    \expandafter\CALX_naddm\expandafter#1\the\numexpr#5\expandafter.%
    \the\numexpr\CALX_nadd_a\xint_c_ii#31;!1;!1;!1;!\W
}%
\def\CALX_nadd_retx#1#2.\fi#3\W#41;!1;!1;!1;!\W\xint:{\fi\CALX_sp N#1#2.#4}%
\def\CALX_nadd_rety#1#2.\fi#3\xint_c_ii#41;!1;!1;!1;!\W
    1;!1;!1;!1;!\W\xint:{\fi\CALX_sp N#1#2.#4}%
\def\CALX_nsum_q#1#2.\fi#3\xint_c_ii#41;!1;!1;!1;!\W
    #51;!1;!1;!1;!\W\xint:%
{%
    \fi\expandafter\CALX_naddm\expandafter#1\the\numexpr#2\expandafter.%
    \the\numexpr\CALX_nadd_a\xint_c_ii#51;!1;!1;!1;!\W#41;!1;!1;!1;!\W\xint:
}%
\def\CALX_naddm #1#2.#31;!#4\xint:%
    {\expandafter\CALX_sp\expandafter N\expandafter#1\the\numexpr#2#4.#3}%
\def\CALX_ndiff_q#1#2.\fi#3\xint_c_ii#41;!1;!1;!1;!\W
{%
    \fi\fi\expandafter\CALX_nsubu\expandafter#1\the\numexpr#2\expandafter.%
    \the\numexpr\CALX_nsub_a\xint_c_i#41;!1;!1;!1;!\W
}%
\def\CALX_ndiff_p#1#2.\fi#3\xint_c_ii#41;!1;!1;!1;!\W
    #51;!1;!1;!1;!\W\xint:%
{%
    \fi\fi\expandafter\CALX_nsubu\expandafter#1\the\numexpr#2\expandafter.%
    \the\numexpr\CALX_nsub_a\xint_c_i#51;!1;!1;!1;!\W#41;!1;!1;!1;!\W\xint:
}%
\def\CALX_ndiff_e#1#2.\fi#3\xint_c_ii#41;!1;!1;!1;!\W
    #51;!1;!1;!1;!\W\xint:%
{%
    \fi\expandafter\CALX_nsube\expandafter#1\the\numexpr#2\expandafter.%
    \the\numexpr\CALX_nsub_a\xint_c_i#51;!1;!1;!1;!\W#41;!1;!1;!1;!\W\xint:
}%
\def\CALX_nsubu #1#2.#31;!#4\xint:%
{%
    \ifnum#4=\xint_c_ \expandafter\CALX_sp\else\expandafter\CALX_nsubrd\fi
    N#1#2.#3%
}%
\def\CALX_nsube #1#2.#31;!#4\xint:%
{%
    \if0#4\csname CALX_nsubng#1\expandafter\endcsname
    \else\expandafter\CALX_nsubf\fi #1#2.#31;!%
}%
\expandafter\def\csname CALX_nsubng+\endcsname #1#2.#31;!%
{%
    \expandafter\CALX_nsubf\expandafter-\the\numexpr#2\expandafter.%
    \the\numexpr\CALX_nnega#31;!%
}%
\expandafter\def\csname CALX_nsubng-\endcsname #1#2.#31;!%
{%
    \expandafter\CALX_nsubf\expandafter+\the\numexpr#2\expandafter.%
    \the\numexpr\CALX_nnega#31;!%
}%
\def\CALX_nsubf #1#2.#31;!%
{%
    \ifnum\CALX_nskip\CALX_ntop_c #2-\xint_c_i.#3\xint:=\xint_c_
      \expandafter\CALX_nsubr\else\expandafter\CALX_sp\fi
    N#1#2.#3%
}%
\def\CALX_nsubr N#1#2.%
    {\expandafter\CALX_nnorm\expandafter#1\the\numexpr\CALX_ntakex#2.}%
\def\CALX_nsubrd N#1#2.%
{%
    \expandafter\CALX_nnorm\expandafter#1\the\numexpr
    \expandafter\CALX_ntakex\the\numexpr#2-\xint_c_i.%
}%
\def\CALX_ntakex #1.%
{%
    \ifnum#1=\xint_c_ \expandafter\CALX_ntakex_e\else
                      \expandafter\CALX_ntakex_b\fi #1.%
}%
\def\CALX_ntakex_e #1.{1\relax;!}%
\def\CALX_ntakex_b #1.1#2!%
{%
    1#2\expandafter!\the\numexpr
    \expandafter\CALX_ntakex\the\numexpr#1-\xint_c_i.%
}%
\def\CALX_ntop_c 1#1!#2\xint:{#1}%
\def\CALX_nsub_k #1#2#3{%
    \xint_gob_til_sc #3\CALX_nsub_ke;%
    \xint_gob_til_zero #1\CALX_nsub_kz0\CALX_nsub_kc #2#3%
}%
\def\CALX_nsub_ke;\xint_gob_til_zero#1#2\W{1\relax;!#1}%
\def\CALX_nsub_kz0\CALX_nsub_kc{\CALX_nsub_kb}%
\def\CALX_nsub_kc #11;!1;!1;!1;!\W{#11;!0}%
\def\CALX_nsub_kb 1#1!#2#3{%
    \xint_gob_til_sc #3\CALX_nsub_kt;%
    \ifnum#1=\xint_c_ \expandafter\CALX_nsub_kbz\else
                      \expandafter\CALX_nsub_kbn\fi #1!#2#3%
}%
\def\CALX_nsub_kbz #1!{199999999\expandafter!\the\numexpr\CALX_nsub_kb}%
\def\CALX_nsub_kbn #1!{1#1-\xint_c_i\expandafter!\the\numexpr\CALX_nsub_kc}%
\def\CALX_nsub_kt;\ifnum#1=#2\W{%
    \ifnum#1=\xint_c_i \expandafter\CALX_nsub_kto\else
                       \expandafter\CALX_nsub_ktn\fi #1!%
}%
\def\CALX_nsub_kto #1!{1\relax;!1}%
\def\CALX_nsub_ktn #1!{1#1-\xint_c_i\relax!1;!0}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nsub}}
%\begin{lverb}
% \CALX_nsub{X}{Y} = X-Y: flips the sign of Y and goes to the addition
% (N-0. may arise transiently but is caught by the zero tests of
% \CALX_nadd_y before any use of the sign).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsub #1{\expandafter\CALX_nsub_x\romannumeral`&&@#1\xint:}%
\def\CALX_nsub_x #1#2\xint:#3{\expandafter\CALX_nsp_t\expandafter\CALX_nsub_y
    \expandafter\CALX_nsub_sp\expandafter#1\romannumeral`&&@#3\xint:#1#2%
        1;!1;!1;!1;!\W\xint:}%
\def\CALX_nsub_sp #1#2#3%
{%
    \if +#3\xint_dothis{\CALX_nadd_sp#1#2-}\fi
    \if -#3\xint_dothis{\CALX_nadd_sp#1#2+}\fi
    \xint_orthat{\CALX_nadd_sp#1#2#3}%
}%
\def\CALX_nsub_y N#1%
    {\if#1-\expandafter\CALX_nsub_yp\else\expandafter\CALX_nsub_ym\fi}%
\def\CALX_nsub_yp{\CALX_nadd_y N+}%
\def\CALX_nsub_ym{\CALX_nadd_y N-}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nnega}, \csh{CALX_nnegb}, \csh{CALX_nnorm},
% \csh{CALX_nlast}, \csh{CALX_ntake}}
%\begin{lverb}
% \CALX_nnega$empty: 10^(8n)-R on LS-first blocks terminated by 1;! (R not
% zero): low zero blocks stay, the first non zero block d becomes 10^8-d
% (written 2*10^8-d to keep the protecting 1), the next ones 99999999-d
% (written 199999999-d).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nnega 1#1!{%
    \ifnum#1=\xint_c_ 100000000\expandafter!\the\numexpr
                      \expandafter\CALX_nnega
    \else \xint_c_ii*\xint_c_e_viii-#1\expandafter!\the\numexpr
          \expandafter\CALX_nnegb
    \fi
}%
\def\CALX_nnegb 1#1#2!{\xint_gob_til_sc #1\CALX_nnegz;%
    199999999-#1#2\expandafter!\the\numexpr\CALX_nnegb}%
\def\CALX_nnegz;#1\CALX_nnegb{1\relax;!}%
%    \end{macrocode}
%\begin{lverb}
% Syntax:
%(
%  \CALX_nnorm <s><blocks>1;!  -> <space>N<s><n>.<blocks'>
%)
% (blocks LS first, zero top blocks allowed; blocks' without them, N+0. if
% all are zero.)
% \CALX_nnorm <sign> <blocks>1;!: strips the zero top blocks and counts, in
% two linear passes: \CALX_nlast finds the index of the last non zero block
% (arguments are two numbers <index>.<last>.), then \CALX_ntake emits that
% many blocks inside a \numexpr chain (xintcore's
% 1<block>\expandafter!\the\numexpr technique) and gobbles the rest up to
% \xint:. Returns N+0. if all blocks are zero.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nnorm #1#21;!%
   {\expandafter\CALX_nnorm_b\romannumeral0\CALX_nlast 0.0.#21;!.#1#2\xint:}%
\def\CALX_nlast #1.#2.1#3#4!{%
    \xint_gob_til_sc #3\CALX_nlast_e;%
    \ifnum#3#4=\xint_c_
       \expandafter\CALX_nlast_z
    \else
       \expandafter\CALX_nlast_nz
    \fi #1.#2.%
}%
\def\CALX_nlast_z #1.#2.{\expandafter\CALX_nlast\the\numexpr#1+\xint_c_i.#2.}%
\def\CALX_nlast_nz #1.#2.%
   {\expandafter\CALX_nlast\the\numexpr#1+\xint_c_i\expandafter.\the%
       \numexpr#1+\xint_c_i.}%
\def\CALX_nlast_e;#1\fi #2.#3.{ #3}%
\def\CALX_nnorm_b #1.{\ifnum#1=\xint_c_ \CALX_nnorm_z\fi\CALX_nnorm_c #1.}%
\def\CALX_nnorm_z\fi#1\xint:{\fi\CALX_sp N+0.}%
\def\CALX_nnorm_c #1.#2#3\xint:%
   {\expandafter\CALX_nnorm_d\the\numexpr\CALX_ntake #1.#31;!\xint:#2#1.}%
\def\CALX_nnorm_d #11;!#2#3.{ N#2#3.#1}%
\def\CALX_ntake #1.1#2!{%
    \ifnum#1=\xint_c_ \expandafter\CALX_ntake_e\fi
    1#2\expandafter!\the\numexpr
    \expandafter\CALX_ntake\the\numexpr#1-\xint_c_i.%
}%
\def\CALX_ntake_e #1\xint:{1\relax;!}%
%    \end{macrocode}
% \subsection{Native multiplication}
% \subsubsection{\csh{CALX_nmul}}
%\begin{lverb}
% Syntax (use with \romannumeral0; X, Y f-expanded, native integers or
% I+, I-, I?):
%(
%  \CALX_nmul{X}{Y}  -> <space>Z    Z = X Y (native integer, or I)
%)
% Multiplication. \CALX_nmul{X}{Y}. The kernels are used as they are, from
% the renamed copy of xintcore (they are self contained, the addition they
% use is the unmodified \CALX_add_a): \CALX_mul_loop, \CALX_smallmul,
% \CALX_verysmallmul. Only the dispatch (xintcore's \XINT_mul_checklengths,
% \XINT_mul_smallbyfirst/second) is rewritten, with the stored block counts,
% and the output.
%
% Contracts (from the code, xintcore l.1013-1097 code-only):
%- \the\numexpr\CALX_mul_loop 100000000!1;!\W <X>1;!\W <Y>1;! computes
% X*Y, iterating over the blocks of Y (the initial 100000000!1;! is the
% zero accumulator); output: product blocks LS-first then 1;!, then the
% tokens which followed Y's 1;!;
%- \the\numexpr\CALX_smallmul 1<y>!<X>1;! for a single block y, and
% \the\numexpr\CALX_verysmallmul 0\xint:<y>!<X>1;! for y<22 (xintcore's
% threshold): same output form.
%
% These kernels never produce a zero top block (the final carry block is
% dropped when zero, \XINT_smallmul_f, \XINT_verysmallmul_f). A product
% of n and m blocks has n+m-1 or n+m blocks: \CALX_nmulo<sign> receives
% n+m-1 (computed before the kernel), skips that many blocks
% (\CALX_nskip) and checks whether one more follows.
%
% Dispatch as for \CALX_nadd: \CALX_nmul_x writes X followed by 1;!\xint:,
% \CALX_nmul_y grabs P's list and Q's header; jumpers \CALX_nmul_zero,
% \CALX_nmul_sp (P one block: Q stays in place), \CALX_nmul_sq (Q one
% block), \CALX_nmul_xq (iteration over P: Q's list grabbed); inline
% default: iteration over Q, left in place. A one-block factor y uses
% \CALX_verysmallmul if y<22, else \CALX_smallmul (y=1 included).
%
% Choice of the iterated operand: the rule of xintcore's
% \XINT_mul_checklengths, transcribed with X=Q, Y=P by default (A=P, B=Q in
% xintcore): exchange if m<n and (m-1)(n-m)<383, or if m>=n and
% (n-1)(m-n)>383.
%
% \CALX_psign <s1><s2><macro> gives <macro>+ or <macro>- (sign of a
% product) by expansion (used by the division).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_psign #1#2#3%
    {\if#1#2\expandafter#3\expandafter+\else\expandafter#3\expandafter-\fi}%
\def\CALX_nmul #1{\expandafter\CALX_nmul_x\romannumeral`&&@#1\xint:}%
\def\CALX_nmul_x #1#2\xint:#3{\expandafter\CALX_nsp_t\expandafter\CALX_nmul_y
    \expandafter\CALX_nmul_spv\expandafter#1\romannumeral`&&@#3\xint:#1#2%
        1;!\xint:}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_nmul_spv (same input as \CALX_nadd_sp): NaN: I?; Inf times 0:
% InvalidOperation (I?); otherwise Inf with the product of the signs.
%
% \CALX_nsp_z <rest of a native after its tag and sign>: its block count.
%
% \CALX_nsp_ps <s1><s2>: I+ or I- (product of the signs, with the space).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsp_z #1.#2\xint:{#1}%
\def\CALX_nsp_ps #1#2{\if#1#2\xint_dothis{ I+}\fi\xint_orthat{ I-}}%
\def\CALX_nmul_spv #1#2#3#4\xint:#5#6#7\xint:%
{%
    \if ?#3\xint_dothis{ I?}\fi
    \if ?#6\xint_dothis{ I?}\fi
    \ifnum\if N#2\CALX_nsp_z#4\xint:\else\if N#5\CALX_nsp_z#7\xint:\else
      \xint_c_i\fi\fi=\xint_c_
      \xint_dothis{\CALX_nsig{InvalidOperation}{inf * 0}{}}\fi
    \xint_orthat{\CALX_nsp_ps#3#6}%
}%
\def\CALX_nmul_y N#1#2.#3\xint:N#4#5.%
{%
    \ifnum#2=\xint_c_ \CALX_nmul_zero\fi
    \ifnum#5=\xint_c_ \CALX_nmul_zero\fi
    \ifnum#2=\xint_c_i \CALX_nmul_sp#1#4#2.#5.\fi
    \ifnum#5=\xint_c_i \CALX_nmul_sq#1#4#2.#5.\fi
    \ifnum\ifnum#5<#2 \numexpr383-(#5-\xint_c_i)*(#2-#5)\relax
          \else\numexpr(#2-\xint_c_i)*(#5-#2)-383\relax\fi>\xint_c_
    \else\CALX_nmul_xq#1#4#2.#5.\fi
    \csname CALX_nmulo\if#1#4+\else-\fi\expandafter\endcsname
    \the\numexpr#2+#5-\xint_c_i\expandafter.%
    \the\numexpr\CALX_mul_loop 100000000!1;!\W #31;!\W
}%
\def\CALX_nmul_zero\fi#1\W#2\W#31;!\xint:{\fi\CALX_sp N+0.}%
\def\CALX_nmul_sp#1#2#3.#4.\fi#5\W1#6!1;!\W
{%
    \fi\csname CALX_nmulo\if#1#2+\else-\fi\expandafter\endcsname
    \the\numexpr#4\expandafter.\the\numexpr
    \ifnum#6<\xint_c_xxii \expandafter\CALX_nmul_vs\else
                         \expandafter\CALX_nmul_s\fi #6!%
}%
\def\CALX_nmul_sq#1#2#3.#4.\fi#5\W#6\W1#7!1;!\xint:%
{%
    \fi\csname CALX_nmulo\if#1#2+\else-\fi\expandafter\endcsname
    \the\numexpr#3\expandafter.\the\numexpr
    \ifnum#7<\xint_c_xxii \expandafter\CALX_nmul_vs\else
                         \expandafter\CALX_nmul_s\fi #7!#6\xint:
}%
\def\CALX_nmul_vs #1!{\CALX_verysmallmul 0\xint:#1!}%
\def\CALX_nmul_s #1!{\CALX_smallmul 1#1!}%
\def\CALX_nmul_xq#1#2#3.#4.\fi#5\W#6\W#71;!\xint:%
{%
    \fi\csname CALX_nmulo\if#1#2+\else-\fi\expandafter\endcsname
    \the\numexpr#3+#4-\xint_c_i\expandafter.%
    \the\numexpr\CALX_mul_loop 100000000!1;!\W#71;!\W#6\xint:
}%
\expandafter\def\csname CALX_nmulo+\endcsname #1.#21;!\xint:%
{%
    \expandafter\CALX_sp\expandafter N\expandafter+\the\numexpr
    #1+\CALX_nskip\CALX_nmul_c #1.#21;!\xint:.#2%
}%
\expandafter\def\csname CALX_nmulo-\endcsname #1.#21;!\xint:%
{%
    \expandafter\CALX_sp\expandafter N\expandafter-\the\numexpr
    #1+\CALX_nskip\CALX_nmul_c #1.#21;!\xint:.#2%
}%
\def\CALX_nmul_c 1#1#2!#3\xint:{\xint_gob_til_sc #1\CALX_nmul_ce;\xint_c_i}%
\def\CALX_nmul_ce;\xint_c_i{\xint_c_}%
\def\CALX_nadd_a #1!#2!#3!#4!#5\W
                #6!#7!#8!#9!%
{%
    \CALX_nadd_b 
        #1!#6!#2!#7!#3!#8!#4!#9!%
        #5\W
}%
\def\CALX_nadd_b #11#2#3!#4!%
{%
    \xint_gob_til_sc #2\CALX_nadd_bi ;%
    \expandafter\CALX_nadd_c\the\numexpr#1+1#2#3+#4-\xint_c_ii\xint:%
}%
\def\CALX_nadd_bi;\expandafter\CALX_nadd_c
    \the\numexpr#1+#2+#3-\xint_c_ii\xint:#4!#5!#6!#7!#8!#9!\W
{%
    \CALX_nadd_k #1#3!#5!#7!#9!%
}%
\def\CALX_nadd_c #1#2\xint:%
{%
    1#2\expandafter!\the\numexpr\CALX_nadd_d #1%
}%
\def\CALX_nadd_d #11#2#3!#4!%
{%
    \xint_gob_til_sc #2\CALX_nadd_di ;%
    \expandafter\CALX_nadd_e\the\numexpr#1+1#2#3+#4-\xint_c_ii\xint:%
}%
\def\CALX_nadd_di;\expandafter\CALX_nadd_e
    \the\numexpr#1+#2+#3-\xint_c_ii\xint:#4!#5!#6!#7!#8\W
{%
    \CALX_nadd_k #1#3!#5!#7!%
}%
\def\CALX_nadd_e #1#2\xint:%
{%
    1#2\expandafter!\the\numexpr\CALX_nadd_f #1%
}%
\def\CALX_nadd_f #11#2#3!#4!%
{%
    \xint_gob_til_sc #2\CALX_nadd_fi ;%
    \expandafter\CALX_nadd_g\the\numexpr#1+1#2#3+#4-\xint_c_ii\xint:%
}%
\def\CALX_nadd_fi;\expandafter\CALX_nadd_g
    \the\numexpr#1+#2+#3-\xint_c_ii\xint:#4!#5!#6\W
{%
    \CALX_nadd_k #1#3!#5!%
}%
\def\CALX_nadd_g #1#2\xint:%
{%
    1#2\expandafter!\the\numexpr\CALX_nadd_h #1%
}%
\def\CALX_nadd_h #11#2#3!#4!%
{%
    \xint_gob_til_sc #2\CALX_nadd_hi ;%
    \expandafter\CALX_nadd_i\the\numexpr#1+1#2#3+#4-\xint_c_ii\xint:%
}%
\def\CALX_nadd_hi;%
    \expandafter\CALX_nadd_i\the\numexpr#1+#2+#3-\xint_c_ii\xint:#4\W
{%
    \CALX_nadd_k #1#3!%
}%
\def\CALX_nadd_i #1#2\xint:%
{%
    1#2\expandafter!\the\numexpr\CALX_nadd_a #1%
}%
\def\CALX_nadd_k #1{\if #12\expandafter\CALX_nadd_ke\else\expandafter%
    \CALX_nadd_l \fi}%
\def\CALX_nadd_ke #11;#2\W {\CALX_nadd_kf #11;!}%
\def\CALX_nadd_kf 1{1\relax }%
\def\CALX_nadd_l 1#1{\xint_gob_til_sc #1\CALX_nadd_lf ;\CALX_nadd_m 1#1}%
\def\CALX_nadd_lf #1\W {1\relax 00000001!1;!+\xint_c_i}% calx: count +1
\def\CALX_nadd_m #1!{\expandafter\CALX_nadd_n\the\numexpr\xint_c_i+#1\xint:}%
\def\CALX_nadd_n #1#2\xint:{1#2\expandafter!\the\numexpr\CALX_nadd_o #1}%
\def\CALX_nadd_o #1{\if #12\expandafter\CALX_nadd_l\else\expandafter%
    \CALX_nadd_ke \fi}%
\def\CALX_nsub_a #1!#2!#3!#4!#5\W #6!#7!#8!#9!%
{%
    \CALX_nsub_b
    #1!#6!#2!#7!#3!#8!#4!#9!%
    #5\W
}%
\def\CALX_nsub_b #1#2#3#4!#5!%
{%
    \xint_gob_til_sc #3\CALX_nsub_bi ;%
    \expandafter\CALX_nsub_c\the\numexpr#1+1#5-#3#4-\xint_c_i\xint:%
}%
\def\CALX_nsub_c 1#1#2\xint:%
{%
    1#2\expandafter!\the\numexpr\CALX_nsub_d #1%
}%
\def\CALX_nsub_d #1#2#3#4!#5!%
{%
    \xint_gob_til_sc #3\CALX_nsub_di ;%
    \expandafter\CALX_nsub_e\the\numexpr#1+1#5-#3#4-\xint_c_i\xint:
}%
\def\CALX_nsub_e 1#1#2\xint:%
{%
    1#2\expandafter!\the\numexpr\CALX_nsub_f #1%
}%
\def\CALX_nsub_f #1#2#3#4!#5!%
{%
    \xint_gob_til_sc #3\CALX_nsub_fi ;%
    \expandafter\CALX_nsub_g\the\numexpr#1+1#5-#3#4-\xint_c_i\xint:
}%
\def\CALX_nsub_g 1#1#2\xint:%
{%
    1#2\expandafter!\the\numexpr\CALX_nsub_h #1%
}%
\def\CALX_nsub_h #1#2#3#4!#5!%
{%
    \xint_gob_til_sc #3\CALX_nsub_hi ;%
    \expandafter\CALX_nsub_i\the\numexpr#1+1#5-#3#4-\xint_c_i\xint:
}%
\def\CALX_nsub_i 1#1#2\xint:%
{%
    1#2\expandafter!\the\numexpr\CALX_nsub_a #1%
}%
\def\CALX_nsub_bi;%
    \expandafter\CALX_nsub_c\the\numexpr#1+1#2-#3\xint:
    #4!#5!#6!#7!#8!#9!\W
{%
    \CALX_nsub_k #1#2!#5!#7!#9!%
}%
\def\CALX_nsub_di;%
    \expandafter\CALX_nsub_e\the\numexpr#1+1#2-#3\xint:
    #4!#5!#6!#7!#8\W
{%
    \CALX_nsub_k #1#2!#5!#7!%
}%
\def\CALX_nsub_fi;%
    \expandafter\CALX_nsub_g\the\numexpr#1+1#2-#3\xint:
    #4!#5!#6\W
{%
    \CALX_nsub_k #1#2!#5!%
}%
\def\CALX_nsub_hi;%
    \expandafter\CALX_nsub_i\the\numexpr#1+1#2-#3\xint:
    #4\W
{%
    \CALX_nsub_k #1#2!%
}%
%    \end{macrocode}
% \subsection{Native division}
% \subsubsection{\csh{CALX_nudiv}}
%\begin{lverb}
% Division (calx). Unsigned core:
%( \CALX_nudiv <cont>{na}{A}{nb}{B}
%)
% with A, B non zero, given by their block counts and LS-first blocks.
% It expands to
%( <cont>{nq}{Q}{s}{R'}
%)
% where nq, Q (count, LS-first blocks) is the quotient floor(A/B), and R'
% the LS-first blocks (non normalized: zero top blocks possible) terminated
% by 1;! of 10^s times the remainder R = A - Q*B. Use \CALX_nudiv_rem to get
% R in native format. The tokens following the last argument are left
% untouched after <cont>{nq}{Q}{s}{R'}.
%
% Paths:
%- na < nb: Q = 0, R' = A, s = 0.
%- nb = 1, na = 1: \numexpr.
%- nb = 1, divisor d <= 45249: dedicated kernel (see below).
%- nb = 1, larger divisor: A reversed (\CALX_rev_nounsep),
% \CALX_smalldivx_a (from xintcore) (MS-first), quotient reversed.
%- nb = 2, 3, 4: dedicated loops without normalization (see below), s = 0.
%- nb >= 5: Knuth's algorithm D in base 10^8, described now.
%
% Algorithm D (general path).
%
% Normalisation: s = number of leading zeros of the top block of B (as an
% 8 digit block); A'' = 10^s A with exactly na+1 blocks (a zero block is
% appended before multiplying), B' = 10^s B (nb blocks, top block v1 >=
% 10^7). \CALX_smallmul (from xintcore) does both products, LS-first.
% The quotient is the same, the remainder is multiplied by 10^s.
%
% Data: the window W (nb+1 blocks w_0..w_nb, W < 10^8 B') and B' (b_0 ..
% b_{nb-1}) are kept INTERLEAVED in one list
%( L = 1w_0!1b_0!1w_1!1b_1!...1w_{nb-1}!1b_{nb-1}!1w_nb!1;;;;;!
%)
% (1;;;;;! = marker Z). The remaining blocks of A'' are kept MS-first in the
% input stream, after L, terminated by 1;!.
%
% The multiply-subtract pass \CALX_ndms_a reads the pairs (w_k,b_k) and emits
% b_k then r_k, where r = W - q*B' (one borrow chain); its output is
%( 1b_0!1r_0!1b_1!1r_1!...1b_{nb-1}!1r_{nb-1}!1;;;;;!{fin}
%)
% with fin = 0 if r >= 0 and fin = -1 if r < 0 (then the blocks hold
% r + 10^(8nb)). Prefixing the next block of A'' gives exactly the next
% window in the layout of L: pairs (new,b_0), (r_0,b_1), ..., top
% (r_{nb-1},Z).
%
% Estimation of q (with u0, u1, u2 the three top blocks of W, v1, v2 those
% of B', U = u0 b^2+u1 b+u2, V = v1 b+v2, b = 10^8): q* = min(floor(U/V),
% b-1) satisfies q <= q* <= q+1. Indeed W/B' < (U+1)/V gives q <=
% floor(U/V), and W/B' >= U/(V+1) gives q >= floor(U/(V+1)) >= floor(U/V)-1
% as U/V - U/(V+1) = U/(V(V+1)) < 1 (U < b V, V >= b). This holds for any
% v1 > 0; q* = q+1 needs the lower blocks to matter (probability about
% 1/v1). q* is obtained from
%( q0 = round(u0*10^9/Vp) + round(u1d/Vp),
%)
% where Vp = 10 v1 + first digit of v2 (9 digits) and u1d = 10 u1 + first
% digit of u2 (eTeX's a*b/c has a 64 bit intermediate product), clamped to
% [0, b-1]; then T = U - q0 V is computed exactly as T = a b + c with
% 0 <= c < b, by splitting q0 and v1, v2 in 4 digit halves, and corrected:
%( while T < 0: q0 -= 1, T += V;
%: while T >= V and q0 < b-1: q0 += 1, T -= V.
%)
% (|q0 - U/V| < 2.1, so at most three corrections.)
%
% If fin < 0 after the pass, B' is added back (\CALX_ndab) and q decreases.
%
% The quotient blocks are left behind in a \numexpr chain (xintcore's
% technique, value 10^8+q emitted by the enclosing \numexpr), MS-first, and
% reversed once at the end.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nudiv #1#2#3#4{%
    \ifnum#2<#4 \xint_dothis\CALX_nudiv_lt\fi
    \xint_orthat{\CALX_nudiv_sel #4.}#1{#2}{#3}{#4}%
}%
\def\CALX_nudiv_sel #1.{%
    \ifcase#1
    \or  \expandafter\CALX_nudiv_one
    \or  \expandafter\CALX_nudiv_two
    \or  \expandafter\CALX_nudiv_three
    \or  \expandafter\CALX_nudiv_four
    \else\expandafter\CALX_nudiv_gen
    \fi
}%
\def\CALX_nudiv_lt #1#2#3#4#5{#1{0}{}{0}{#31;!}}%
%    \end{macrocode}
%\begin{lverb}
% One block divisor.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nudiv_one #1#2#3#4#5{\CALX_nudiv_oa #1{#2}#5{#3}}%
\def\CALX_nudiv_oa #1#21#3!{%
    \ifnum#2=\xint_c_i \xint_dothis\CALX_nudiv_oo\fi
    \ifnum#3<45250 \xint_dothis\CALX_nudiv_otd\fi
    \xint_orthat\CALX_nudiv_ob #1{#2}{#3}%
}%
\def\CALX_nudiv_oo #1#2#3#4{\CALX_nudiv_oo_a #1{#3}#4}%
\def\CALX_nudiv_oo_a #1#21#3!{%
    \expandafter\CALX_nudiv_oo_b
    \the\numexpr(#3+#2/\xint_c_ii)/#2-\xint_c_i\xint:#3\xint:#2\xint:#1%
}%
\def\CALX_nudiv_oo_b #1\xint:#2\xint:#3\xint:{%
    \expandafter\CALX_nudiv_oo_c
    \the\numexpr\xint_c_e_viii+#1\expandafter\xint:%
    \the\numexpr\xint_c_e_viii+#2-#1*#3\xint:%
}%
\def\CALX_nudiv_oo_c 1#1\xint:#2\xint:#3{%
    \ifnum#1=\xint_c_ \xint_dothis{#3{0}{}}\fi
    \xint_orthat{#3{1}{1#1!}}{0}{#2!1;!}%
}%
\def\CALX_nudiv_ob #1#2#3#4{%
    \expandafter\CALX_nudiv_oc
    \romannumeral0\CALX_rev_nounsep {}#4\R!\R!\R!\R!\R!\R!\R!\R!\W%
        \xint:{#3}{#2}#1%
}%
\def\CALX_nudiv_oc 1#1!#2\xint:#3#4{%
    \expandafter\CALX_nudiv_od
    \the\numexpr\expandafter\CALX_smalldivx_a\the\numexpr#3/\xint_c_ii%
        \xint:1#3!1#1!#21;!%
    {\ifnum#1<#3 -\xint_c_i\fi+#4}%
}%
\def\CALX_nudiv_od #11!;!#2!#3{%
    \expandafter\CALX_nudiv_oe
    \romannumeral0\CALX_rev_nounsep {}#1\R!\R!\R!\R!\R!\R!\R!\R!\W%
        \xint:{#3}{#2}%
}%
\def\CALX_nudiv_oe #1\xint:#2#3{%
    \expandafter\CALX_nudiv_of
    \the\numexpr\xint_c_e_viii+#3\expandafter\xint:\the\numexpr#2\xint:{#1}%
}%
\def\CALX_nudiv_of #1\xint:#2\xint:#3#4{#4{#2}{#3}{0}{#1!1;!}}%
%    \end{macrocode}
%\begin{lverb}
% General path. \CALX_nudiv_gs computes s from the top block of B.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nudiv_gen #1#2#3#4#5{%
    \expandafter\CALX_nudiv_ga\the\numexpr
    \CALX_nskip\CALX_nudiv_gs #4-\xint_c_i.#5\xint:\xint:{#5}{#2}{#3}{#4}#1%
}%
\def\CALX_nudiv_gs 1#1!\xint:{\CALX_nlz{#1}}%
\def\CALX_nudiv_pow #1{\csname CALX_nudiv_pow\the\numexpr#1\endcsname}%
\expandafter\def\csname CALX_nudiv_pow0\endcsname{100000001}%
\expandafter\def\csname CALX_nudiv_pow1\endcsname{100000010}%
\expandafter\def\csname CALX_nudiv_pow2\endcsname{100000100}%
\expandafter\def\csname CALX_nudiv_pow3\endcsname{100001000}%
\expandafter\def\csname CALX_nudiv_pow4\endcsname{100010000}%
\expandafter\def\csname CALX_nudiv_pow5\endcsname{100100000}%
\expandafter\def\csname CALX_nudiv_pow6\endcsname{101000000}%
\expandafter\def\csname CALX_nudiv_pow7\endcsname{110000000}%
%    \end{macrocode}
%\begin{lverb}
% #1=s, #2=B, #3=na, #4=A, #5=nb, #6=cont. Produces
%( \CALX_nudiv_gc <A''>1;!\xint:<B'>1;!\xint:{na}{nb}{s}<cont>
%)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nudiv_ga #1\xint:{%
    \ifnum#1=\xint_c_ \xint_dothis\CALX_nudiv_gz\fi
    \xint_orthat\CALX_nudiv_gm {#1}%
}%
\def\CALX_nudiv_gz #1#2#3#4#5{\CALX_nudiv_gc #4100000000!1;!\xint:#21;!%
    \xint:{#3}{#5}{0}}%
\def\CALX_nudiv_gm #1#2{%
    \expandafter\CALX_nudiv_gb\the\numexpr
    \expandafter\CALX_smallmul\the\numexpr\CALX_nudiv_pow{#1}!#21;!\xint:%
    {#1}%
}%
\def\CALX_nudiv_gb #11;!\xint:#2#3#4#5{%
    \expandafter\CALX_nudiv_gc\the\numexpr
    \expandafter\CALX_smallmul\the\numexpr\CALX_nudiv_pow{#2}!#4100000000!1;!%
    \xint:#11;!\xint:{#3}{#5}{#2}%
}%
%    \end{macrocode}
%\begin{lverb}
% #1=A'' (na+1 blocks), #2=B', #3=na, #4=nb, #5=s, then <cont>.
% The constants C = {k}{v1h}{v1l}{v2h}{v2l}{Vp}, k = 2nb-4, are obtained
% from the two top blocks of a copy of B'.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nudiv_gc #11;!\xint:#21;!\xint:#3#4#5{%
    \CALX_nskip\CALX_nudiv_gv #4-\xint_c_ii.#21;!%
        \xint:{#4}{#3-#4}{#5}{#1}{#2}%
}%
\def\CALX_nudiv_gv 1#1#2#3#4#5!1#6#7#8#9{\CALX_nudiv_gu %
    {#1#2#3#4}{#5}{#6#7#8#9}{#1}}%
%    \end{macrocode}
%\begin{lverb}
% #1=v2h, #2=v2l, #3=v1h, #4=first digit of v2, #5=v1l, #6=nb, #7=m (number
% of low blocks of A'' to reverse, expression), #8=s, #9=A'', then {B'}.
%
% C = {k}{v1h}{v1l}{v2h}{v2l}{Vp} with k an expression (only used through
% \numexpr).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nudiv_gu #1#2#3#4#5!1;!\xint:#6#7#8#9{%
    \expandafter\CALX_nrevk\the\numexpr#7.\CALX_nudiv_gw{}#91;!\xint:%
    {{\xint_c_ii*#6-\xint_c_iv}{#3}{#5}{#1}{#2}{#3#5#4}}{#7+\xint_c_i}{#8}%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nrevk}}
%\begin{lverb}
% \CALX_nrevk <k>.<cont>{acc}<blocks>: reverses k blocks onto acc, then
% <cont>{acc'}<remaining blocks>. Six blocks per step.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nrevk #1.{%
    \ifnum#1>\xint_c_v\expandafter\CALX_nrevk_g\else\expandafter\CALX_nrevk_b%
        \fi #1.%
}%
\def\CALX_nrevk_g #1.#2#3#4!#5!#6!#7!#8!#9!%
    {\expandafter\CALX_nrevk\the\numexpr#1-%
        \xint_c_vi.#2{#9!#8!#7!#6!#5!#4!#3}}%
\def\CALX_nrevk_b #1.{%
    \ifcase#1
         \expandafter\CALX_nrevk_z
    \or  \expandafter\CALX_nrevk_i
    \or  \expandafter\CALX_nrevk_ii
    \or  \expandafter\CALX_nrevk_iii
    \or  \expandafter\CALX_nrevk_iv
    \else\expandafter\CALX_nrevk_v
    \fi
}%
\def\CALX_nrevk_z   #1{#1}%
\def\CALX_nrevk_i   #1#2#3!{#1{#3!#2}}%
\def\CALX_nrevk_ii  #1#2#3!#4!{#1{#4!#3!#2}}%
\def\CALX_nrevk_iii #1#2#3!#4!#5!{#1{#5!#4!#3!#2}}%
\def\CALX_nrevk_iv  #1#2#3!#4!#5!#6!{#1{#6!#5!#4!#3!#2}}%
\def\CALX_nrevk_v   #1#2#3!#4!#5!#6!#7!{#1{#7!#6!#5!#4!#3!#2}}%
%    \end{macrocode}
%\begin{lverb}
% #1=R (MS-first low blocks of A''), #2=window (LS-first), #3=C,
% #4=steps, #5=s, #6=B'. The interleaving \CALX_nilv takes one block of each
% list per step (it regrabs the rest of the window).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nudiv_gw #1#21;!\xint:#3#4#5#6{%
    \expandafter\CALX_nudiv_gl\the\numexpr\CALX_nilv #21;!\xint:#61;;;;;!%
    {#3}{#11;!}{#4}{#5}%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nilv}}
%    \begin{macrocode}
\def\CALX_nilv 1#1!#2\xint:1#3#4!{%
    \xint_gob_til_sc #3\CALX_nilv_e;%
    1#1\expandafter!\the\numexpr1#3#4\expandafter!\the\numexpr\CALX_nilv #2%
        \xint:%
}%
\def\CALX_nilv_e;1#1\expandafter!\the\numexpr1#2\xint:{1#1\relax!1;;;;;!}%
\def\CALX_nudiv_gl #1;;;;;!#2#3{%
    \expandafter\CALX_nudiv_x\the\numexpr\CALX_nds {#2}#1;;;;;!#3%
}%
%    \end{macrocode}
%\begin{lverb}
% The main loop. Input stream: \CALX_nds {C}<L>;;;;;!<R>1;!...
% (here <L> lacks its final ;;;;;! which is written explicitly).
%
% \CALX_nds_t receives the top of a copy of L after k = 2nb-4 blocks are
% skipped.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ndc_k  #1#2#3#4#5#6{#1}%
\def\CALX_ndc_ah #1#2#3#4#5#6{#2}%
\def\CALX_ndc_al #1#2#3#4#5#6{#3}%
\def\CALX_ndc_bh #1#2#3#4#5#6{#4}%
\def\CALX_ndc_bl #1#2#3#4#5#6{#5}%
\def\CALX_ndc_a  #1#2#3#4#5#6{#2#3}%
\def\CALX_ndc_b  #1#2#3#4#5#6{#4#5}%
\def\CALX_ndc_vp #1#2#3#4#5#6{#6}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nds}}
%    \begin{macrocode}
\def\CALX_nds #1#2;;;;;!{%
    \CALX_nskip\CALX_nds_t\CALX_ndc_k#1.#2;;;;;!\xint:{#1}#2;;;;;!%
}%
\def\CALX_nds_t 1#1#2!1#3!1#4!1#5!1#6!1;;;;;!\xint:#7{%
    \expandafter\CALX_nds_r
    \the\numexpr#6*\xint_c_e_ix/\CALX_ndc_vp#7+#4#1/\CALX_ndc_vp#7\xint:%
    {#6}{#4}{#1#2}{#7}%
}%
\def\CALX_nds_r #1\xint:{%
    \ifnum#1>\xint_c_e_viii_mone \CALX_nds_rm\fi
    \expandafter\CALX_nds_s\the\numexpr\xint_c_e_viii+#1\xint:%
}%
%    \end{macrocode}
%\begin{lverb}
% #1#2#3#4=qh (4 digits), #5=ql, #6=u0, #7=u1, #8=u2, #9=C.
%
% Splitting M1 = qh v1l + ql v1h and M2 = qh v2l + ql v2h as
% M = 10^4 Mh + Ml, with Mh = floor(M/10^4) = (M+5000)/10^4-1:
%( q0 v1 = (qh v1h + M1h) b + 10^4 M1l + ql v1l, idem for v2;
%: T = U - q0 (v1 b + v2) = Ax b + Bx with
%: Bx = u2 - 10^4 M2l - ql v2l                      in (-2b, b),
%: Ax = (u0 - qh v1h - M1h) b + u1 - 10^4 M1l - ql v1l - qh v2h - M2h.
%)
% 3b+Bx is in (b, 4b) and has nine digits e<c>, so that T = a b + c with
% a = Ax+e-3, 0 <= c < b.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nds_rm\fi#1\xint:{\fi\CALX_nds_s 199999999\xint:}%
\def\CALX_nds_s 1#1#2#3#4#5\xint:#6#7#8#9{%
    \expandafter\CALX_nds_u\the\numexpr
    (#1#2#3#4*\CALX_ndc_al#9+#5*\CALX_ndc_ah#9+5000)/\xint_c_e_iv-\xint_c_i
    \expandafter\xint:\the\numexpr
    (#1#2#3#4*\CALX_ndc_bl#9+#5*\CALX_ndc_bh#9+5000)/\xint_c_e_iv-\xint_c_i
    \xint:{#1#2#3#4}{#5}{#6}{#7}{#8}{#9}%
}%
\def\CALX_nds_u #1\xint:#2\xint:#3#4#5#6#7#8{%
    \expandafter\CALX_nds_w\the\numexpr
    \xint_c_iii*\xint_c_e_viii+#7-#4*\CALX_ndc_bl#8%
    -(#3*\CALX_ndc_bl#8+#4*\CALX_ndc_bh#8-\xint_c_e_iv*#2)*\xint_c_e_iv
    \expandafter\xint:\the\numexpr
    (#5-#3*\CALX_ndc_ah#8-#1)*\xint_c_e_viii+#6%
    -(#3*\CALX_ndc_al#8+#4*\CALX_ndc_ah#8-\xint_c_e_iv*#1)*\xint_c_e_iv
    -#4*\CALX_ndc_al#8-#3*\CALX_ndc_bh#8-#2%
    \xint:{#3#4}{#8}%
}%
\def\CALX_nds_w #1#2\xint:#3\xint:{%
    \expandafter\CALX_nds_c\the\numexpr#3+#1-%
        \xint_c_iii.{#2}%
}%
%    \end{macrocode}
%\begin{lverb}
% Correction loop: #1=a, #2=c (T = a b + c, 0 <= c < b), #3=q, #4=C.
% T < 0 iff a < 0. T >= V iff 2(a-v1) + (0 if c >= v2 else -1) >= 0.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nds_c #1.#2#3#4{%
    \ifnum#1<\xint_c_ \xint_dothis\CALX_nds_cd\fi
    \ifnum\numexpr\xint_c_ii*(#1-\CALX_ndc_a#4)\ifnum#2<\CALX_ndc_b#4 -%
        \xint_c_i\fi
        <\xint_c_ \xint_dothis\CALX_nds_g\fi
    \ifnum#3=\xint_c_e_viii_mone \xint_dothis\CALX_nds_g\fi
    \xint_orthat\CALX_nds_ci {#1}{#2}{#3}{#4}%
}%
\def\CALX_nds_cd #1#2#3#4{%
    \expandafter\CALX_nds_ce\the\numexpr\xint_c_e_viii+#2+\CALX_ndc_b#4\xint:%
    {#1+\CALX_ndc_a#4}{#3-\xint_c_i}{#4}%
}%
\def\CALX_nds_ce #1#2\xint:#3#4{%
    \expandafter\CALX_nds_cf\the\numexpr#3+#1-\xint_c_i\expandafter\xint:%
    \the\numexpr#4\xint:{#2}%
}%
\def\CALX_nds_cf #1\xint:#2\xint:#3{\CALX_nds_c #1.{#3}{#2}}%
\def\CALX_nds_ci #1#2#3#4{%
    \expandafter\CALX_nds_ce\the\numexpr
    \xint_c_ii*\xint_c_e_viii+#2-\CALX_ndc_b#4\xint:%
    {#1-\CALX_ndc_a#4-\xint_c_i}{#3+\xint_c_i}{#4}%
}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_nds_g #1=a, #2=c, #3=q, #4=C; then <L>;;;;;!<R>1;!.
%
% The multiply-subtract pass runs on L.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nds_g #1#2#3#4#5;;;;;!{%
    \expandafter\CALX_nds_h\the\numexpr\xint_c_e_viii+#3\xint:{#4}#5;;;;;!%
}%
\def\CALX_nds_h 1#1#2#3#4#5\xint:#6#7;;;;;!{%
    \expandafter\CALX_nds_p\the\numexpr
    \CALX_ndms_a 0\xint:#1#2#3#4\xint:#5!#7;;;;;!{#1#2#3#4#5}{#6}%
}%
\def\CALX_nds_p #1;;;;;!#2{%
    \ifnum\numexpr#2<\xint_c_ \xint_dothis\CALX_nds_pa\fi
    \xint_orthat\CALX_nds_pb #1;;;;;!%
}%
\def\CALX_nds_pa #1;;;;;!{%
    \expandafter\CALX_nds_pc\the\numexpr\CALX_ndab 0\xint:#1;;;;;!%
}%
\def\CALX_nds_pc #1;;;;;!#2{\CALX_nds_pb #1;;;;;!{#2-\xint_c_i}}%
%    \end{macrocode}
%\begin{lverb}
% #1=new list without ;;;;;!, #2=q (expression), #3=C, then the first block
% of R. Emission of 10^8+q into the enclosing \numexpr.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nds_pb #1;;;;;!#2#31#4#5!{%
    \xint_gob_til_sc #4\CALX_nds_end;%
    \xint_c_e_viii+#2\expandafter!\the\numexpr\CALX_nds {#3}1#4#5!#1;;;;;!%
}%
\def\CALX_nds_end;\xint_c_e_viii+#1\expandafter!\the\numexpr\CALX_nds %
    #21#3!#4;;;;;!%
    {\xint_c_e_viii+#1\relax!\xint:{#4}}%
%    \end{macrocode}
%\begin{lverb}
% Multiply-subtract pass. State <cexpr>\xint:<qh>\xint:<ql>! where cexpr is
% an expression for the borrow c (0 <= c < 10^8), then the pairs
% 1<w>!1<bh4><bl4>!. With M = qh bl + ql bh = 10^4 Mh + Ml (10^9+M has ten
% digits: 1, Mh on five, Ml on four):
%( w - c - q b = X - (qh bh + Mh) 10^8,  X = w - c - ql bl - 10^4 Ml,
%)
% X in (-3 10^8, 10^8); 4 10^8 + X has nine digits e<r>, r is the block,
% and the new borrow is qh bh + Mh + 4 - e. At the marker Z, the expression
% w_nb - c (0 or -1) is left in braces.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ndms_a #1\xint:#2\xint:#3!1#4!1#5#6#7#8#9!{%
    \xint_gob_til_sc #5\CALX_ndms_e;%
    1#5#6#7#8#9\expandafter!\the\numexpr\expandafter\CALX_ndms_b
    \the\numexpr\xint_c_e_ix+#2*#9+#3*#5#6#7#8\xint:%
    #4-(#1)\xint:#3*#9\xint:#2*#5#6#7#8\xint:#2\xint:#3!%
}%
\def\CALX_ndms_e;#1\xint:#2\xint:#3\xint:#4\xint:#5\xint:#6!{1%
    \relax;;;;;!{#2}}%
\def\CALX_ndms_b 1#1#2#3#4#5#6#7#8#9\xint:{\CALX_ndms_c #1#2#3#4#5%
    \xint:#6#7#8#9\xint:}%
\def\CALX_ndms_c #1\xint:#2\xint:#3\xint:#4\xint:#5\xint:{%
    \expandafter\CALX_ndms_d
    \the\numexpr\xint_c_iv*\xint_c_e_viii+#3-#4-#2*\xint_c_e_iv\xint:#5+#1%
        \xint:%
}%
\def\CALX_ndms_d #1#2\xint:#3\xint:%
    {1#2\expandafter!\the\numexpr\CALX_ndms_a #3+\xint_c_iv-#1\xint:}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_ndab}}
%\begin{lverb}
% Add back: on 1b_0!1r_0!...1b_{nb-1}!1r_{nb-1}!1;;;;;!, r += B' (final
% carry dropped), b's copied.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ndab #1\xint:1#2#3!{\xint_gob_til_sc #2\CALX_ndab_e;\CALX_ndab_c #1%
    \xint:#2#3!}%
\def\CALX_ndab_e;\CALX_ndab_c #1\xint:#2!{1\relax;;;;;!}%
\def\CALX_ndab_c #1\xint:#2!1#3!{%
    1#2\expandafter!\the\numexpr\expandafter\CALX_ndab_d
    \the\numexpr\xint_c_e_viii+#3+#2+#1\xint:%
}%
\def\CALX_ndab_d #1#2\xint:{1#2\expandafter!\the\numexpr\CALX_ndab #1-%
    \xint_c_i\xint:}%
%    \end{macrocode}
%\begin{lverb}
% End: <Q MS-first blocks>\xint:{<last list>}{steps}{s}<cont>.
% The top quotient block may be zero (only the top one).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nudiv_x 1#1!#2\xint:#3#4{%
    \ifcase\numexpr\ifnum#1=\xint_c_
                     \ifnum\numexpr#4=\xint_c_i \xint_c_ii\else\xint_c_i\fi
                   \else\xint_c_\fi\relax
         \expandafter\CALX_nudiv_x_n
    \or  \expandafter\CALX_nudiv_x_z
    \else\expandafter\CALX_nudiv_x_zero
    \fi {#1}{#2}{#3}{#4}%
}%
\def\CALX_nudiv_x_zero #1#2#3#4{\CALX_nudiv_y \xint:{0}{#3}}%
\def\CALX_nudiv_x_z #1#2#3#4{%
    \expandafter\CALX_nudiv_y
    \romannumeral0\CALX_rev_nounsep {}#2\R!\R!\R!\R!\R!\R!\R!\R!\W\xint:{#4-%
        \xint_c_i}{#3}%
}%
\def\CALX_nudiv_x_n #1#2#3#4{%
    \expandafter\CALX_nudiv_y
    \romannumeral0\CALX_rev_nounsep {}1#1!#2\R!\R!\R!\R!\R!\R!\R!\R!\W%
        \xint:{#4}{#3}%
}%
\def\CALX_nudiv_y #1\xint:#2#3{%
    \expandafter\CALX_nudiv_z\the\numexpr#2\expandafter.%
    \the\numexpr\CALX_ndrx #3;;;;;!1;!.{#1}%
}%
\def\CALX_nudiv_z #1.#2.#3#4#5{#5{#1}{#3}{#4}{#2}}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_ndrx}}
%    \begin{macrocode}
\def\CALX_ndrx 1#1#2!1#3!{%
    \xint_gob_til_sc #1\CALX_ndrx_e;1#3\expandafter!\the\numexpr\CALX_ndrx
}%
\def\CALX_ndrx_e;1#1\CALX_ndrx{1\relax;!}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_nudiv_rem {s}{R'}: native positive R (or N+0.). For s>0,
% R = 10^(8-s) R' / 10^8: \CALX_smallmul (from xintcore) then the low
% block (zero) is dropped. Then \CALX_nnorm counts and strips zero top blocks.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nudiv_rem #1#2{%
    \ifnum#1=\xint_c_ \xint_dothis{\CALX_nnorm +}\fi
    \xint_orthat{\expandafter\CALX_nudiv_rem_a\the\numexpr
     \expandafter\CALX_smallmul\the\numexpr\CALX_nudiv_pow{%
         \xint_c_viii-#1}!}#2%
}%
\def\CALX_nudiv_rem_a 1#1!{\CALX_nnorm +}%
%    \end{macrocode}
%\begin{lverb}
% Two-block divisor (nb = 2). No normalization: A'' = A with a zero block
% appended (na+1 blocks), reversed once (MS-first); s = 0. With s the number
% of leading zeros of v1 (here s only scales the estimate), M = 10^(s+1) and
% Vp = v1 M + floor(v2/10^(7-s)) (nine digits), the first guess is
%( q0 = round((u0 M) 10^8/Vp) + round(u1 M/Vp) + round(round(u2 M/10^8)/Vp).
%)
% The window is U = u0 b^2 + u1 b + u2 exactly and the divisor V = v1 b + v2
% exactly, so q = floor(U/V) is the quotient block (no add-back) and
% T = U - qV = a b + c is the next (u0, u1).
%
% Loop: \CALX_ndtw {Vp}{M}{v1h}{v1l}{v2h}{v2l}{u0}{u1}1<u2>!...1;!
% with u1 (and u2) on eight digits. qh and ql by \numexpr, then
%( M1 = qh v1l + ql v1h, M2 = qh v2l + ql v2h, Mh = (M+5000)/10^4-1,
%: Bx = 3b + u2 - ql v2l - 10^4 (M2 - 10^4 M2h),
%: Ax = (u0 - qh v1h - M1h) b + u1 - 10^4 (M1 - 10^4 M1h) - ql v1l
%:      - qh v2h - M2h,
%)
% T = Ax b + Bx, 3b+Bx has nine digits e<c>, a = Ax+e-3, then the
% correction loop \CALX_ndtw_l (same tests as \CALX_nds_c).
%
% Quotient blocks are emitted MS-first into the enclosing \numexpr chain,
% which ends with 1;!.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nudiv_two #1#2#3#4#5{\CALX_nudiv_tw #5{#2}{#3}#1}%
\def\CALX_nudiv_tw 1#1#2#3#4#5!1#6#7#8#9{\CALX_nudiv_tu %
    {#1#2#3#4}{#5}{#6#7#8#9}}%
\def\CALX_nudiv_tu #1#2#3#4!{%
    \expandafter\CALX_nudiv_tv
    \expanded{\CALX_nudiv_mp{\CALX_nudiv_gs 1#3#4!\xint:}}{#1}{#2}{#3}{#4}%
}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_nudiv_mp{s} gives M.P. with M = 10^(s+1), P = 10^(7-s), so that
% Vp = v1 M + floor(v2/P) has nine digits (first guess of q0, see the
% two-block divisor above).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nudiv_mp #1{\csname CALX_nudiv_mp\the\numexpr#1\endcsname}%
\expandafter\def\csname CALX_nudiv_mp0\endcsname{10.10000000.}%
\expandafter\def\csname CALX_nudiv_mp1\endcsname{100.1000000.}%
\expandafter\def\csname CALX_nudiv_mp2\endcsname{1000.100000.}%
\expandafter\def\csname CALX_nudiv_mp3\endcsname{10000.10000.}%
\expandafter\def\csname CALX_nudiv_mp4\endcsname{100000.1000.}%
\expandafter\def\csname CALX_nudiv_mp5\endcsname{1000000.100.}%
\expandafter\def\csname CALX_nudiv_mp6\endcsname{10000000.10.}%
\expandafter\def\csname CALX_nudiv_mp7\endcsname{100000000.1.}%
\def\CALX_nudiv_tv #1.#2.#3#4#5#6{%
    \expandafter\CALX_nudiv_tt
    \the\numexpr#5#6*#1+(#3#4+#2/\xint_c_ii)/#2-\xint_c_i\xint:%
    {#1}{#5}{#6}{#3}{#4}%
}%
\def\CALX_nudiv_tt #1\xint:#2#3#4#5#6#7#8{%
    \expandafter\CALX_nudiv_tf
    \romannumeral0\CALX_rev_nounsep {}#8\R!\R!\R!\R!\R!\R!\R!\R!\W
    \xint:{{#1}{#2}{#3}{#4}{#5}{#6}}{#7}%
}%
%    \end{macrocode}
%\begin{lverb}
% #1, #2 = two top blocks of A, #3 = the others (MS-first), #4 = K =
% {Vp}{M}{v1h}{v1l}{v2h}{v2l}, #5 = na. If (a1, a2) < (v1, v2) the window
% starts at (a1, a2, a3) (na-2 steps; if na = 2, Q = 0 and R = A), else at
% (0, a1, a2) (na-1 steps): in both cases the top quotient block is not 0.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nudiv_tcmp #1#2#3#4#5#6#7#8{%
    \ifnum#1<#5#6 -\xint_c_i\else\ifnum#1>#5#6 \xint_c_\else
    \ifnum#2<#7#8 -\xint_c_i\else\xint_c_\fi\fi\fi
}%
\def\CALX_nudiv_tf 1#1!1#2!#3\xint:#4#5{%
    \ifnum\CALX_nudiv_tcmp{#1}{#2}#4<\xint_c_
       \ifnum#5=\xint_c_ii \CALX_nudiv_tq\fi
       \expandafter\CALX_nudiv_tn
    \else
       \expandafter\CALX_nudiv_tp
    \fi {#1}{#2}{#3}{#4}{#5}%
}%
\def\CALX_nudiv_tq\fi\expandafter\CALX_nudiv_tn\else\expandafter%
    \CALX_nudiv_tp\fi
    #1#2#3#4#5#6{\fi\fi#6{0}{}{0}{1#2!1#1!1;!}}%
\def\CALX_nudiv_tn #1#2#3#4#5{%
    \expandafter\CALX_ndtw_z\the\numexpr\CALX_ndtw #4{#1}{#2}#31;!{#5-%
        \xint_c_i}%
}%
\def\CALX_nudiv_tp #1#2#3#4{%
    \expandafter\CALX_ndtw_z\the\numexpr\CALX_ndtw #4{0}{#1}1#2!#31;!%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_ndtw}}
%    \begin{macrocode}
\def\CALX_ndtw #1#2#3#4#5#6#7#81#9!{%
    \xint_gob_til_sc #9\CALX_ndtw_end;%
    \expandafter\CALX_ndtw_q
    \the\numexpr(#7*#2)*\xint_c_e_viii/#1+#8*#2/#1+(#9*#2/\xint_c_e_viii)/#1%
        \xint:%
    {#3}{#4}{#5}{#6}{#7}{#8}{#9}{{#1}{#2}}%
}%
\def\CALX_ndtw_end;\expandafter\CALX_ndtw_q\the\numexpr#1%
    \xint:#2#3#4#5#6#7#8#9%
    {1\relax;!\xint:{#6}{#7}}%
\def\CALX_ndtw_q #1\xint:%
    {\ifnum#1>\xint_c_e_viii_mone \CALX_ndtw_qm\fi\CALX_ndtw_h #1\xint:}%
\def\CALX_ndtw_qm\fi#1\xint:{\fi\CALX_ndtw_h 99999999\xint:}%
\def\CALX_ndtw_h #1\xint:{%
    \expandafter\CALX_ndtw_x
    \the\numexpr(#1+5000)/\xint_c_e_iv-\xint_c_i\expandafter\xint:%
    \the\numexpr#1-\xint_c_e_iv*((#1+5000)/\xint_c_e_iv-\xint_c_i)\xint:%
}%
\def\CALX_ndtw_x #1\xint:#2\xint:#3#4#5#6#7#8#9{%
    \expandafter\CALX_ndtw_w\the\numexpr
    \xint_c_iii*\xint_c_e_viii+#9-#2*#6%
    -(#1*#6+#2*#5-\xint_c_e_iv*((#1*#6+#2*#5+5000)/\xint_c_e_iv-\xint_c_i))%
     *\xint_c_e_iv
    \expandafter\xint:\the\numexpr
    (#7-#1*#3-(#1*#4+#2*#3+5000)/\xint_c_e_iv+\xint_c_i)*\xint_c_e_viii+#8%
    -(#1*#4+#2*#3-\xint_c_e_iv*((#1*#4+#2*#3+5000)/\xint_c_e_iv-\xint_c_i))%
     *\xint_c_e_iv
    -#2*#4-#1*#5-(#1*#6+#2*#5+5000)/\xint_c_e_iv+\xint_c_i
    \xint:{#1*\xint_c_e_iv+#2}{#3}{#4}{#5}{#6}%
}%
\def\CALX_ndtw_w #1#2\xint:#3\xint:{%
    \expandafter\CALX_ndtw_l\the\numexpr#3+#1-%
        \xint_c_iii.{#2}%
}%
\def\CALX_ndtw_l #1.#2#3#4#5#6#7{%
    \ifnum#1<\xint_c_ \xint_dothis\CALX_ndtw_d\fi
    \ifnum\numexpr\xint_c_ii*(#1-#4#5)\ifnum#2<#6#7 -\xint_c_i\fi
        <\xint_c_ \xint_dothis\CALX_ndtw_g\fi
    \ifnum\numexpr#3=\xint_c_e_viii_mone \xint_dothis\CALX_ndtw_g\fi
    \xint_orthat\CALX_ndtw_i {#1}{#2}{#3}{#4}{#5}{#6}{#7}%
}%
\def\CALX_ndtw_d #1#2#3#4#5#6#7{%
    \expandafter\CALX_ndtw_e\the\numexpr\xint_c_e_viii+#2+#6#7\xint:%
    {#1+#4#5}{#3-\xint_c_i}{#4}{#5}{#6}{#7}%
}%
\def\CALX_ndtw_i #1#2#3#4#5#6#7{%
    \expandafter\CALX_ndtw_e\the\numexpr\xint_c_ii*\xint_c_e_viii+#2-#6#7%
        \xint:%
    {#1-#4#5-\xint_c_i}{#3+\xint_c_i}{#4}{#5}{#6}{#7}%
}%
\def\CALX_ndtw_e #1#2\xint:#3#4{%
    \expandafter\CALX_ndtw_f\the\numexpr#3+#1-\xint_c_i\expandafter\xint:%
    \the\numexpr#4\xint:{#2}%
}%
\def\CALX_ndtw_f #1\xint:#2\xint:#3{\CALX_ndtw_l #1.{#3}{#2}}%
\def\CALX_ndtw_g #1#2#3#4#5#6#7#8{%
    \xint_c_e_viii+#3\expandafter!\the\numexpr\CALX_ndtw %
        #8{#4}{#5}{#6}{#7}{#1}{#2}%
}%
%    \end{macrocode}
%\begin{lverb}
% Exit: <Q MS-first>1;!\xint:{u0}{u1}{na}{s}<cont>; R' = 1u1!1u0!1;!.
%
% \CALX_nudiv_qx <Q MS-first>\xint:{R'}{steps}{s}<cont> drops a zero top
% block, reverses Q and delivers <cont>{nq}{Q}{s}{R'}.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ndtw_z #11;!\xint:#2#3#4{%
    \expandafter\CALX_ndtw_zz\the\numexpr\xint_c_e_viii+#2\xint:{#3}{#4}{#1}%
}%
\def\CALX_ndtw_zz #1\xint:#2#3#4{\CALX_nudiv_qx #4\xint:{1#2!#1!1;!}{#3-%
    \xint_c_i}{0}}%
\def\CALX_nudiv_qx 1#1!#2\xint:#3#4{%
    \ifcase\numexpr\ifnum#1=\xint_c_
                     \ifnum\numexpr#4=\xint_c_i \xint_c_ii\else\xint_c_i\fi
                   \else\xint_c_\fi\relax
         \expandafter\CALX_nudiv_qx_n
    \or  \expandafter\CALX_nudiv_qx_z
    \else\expandafter\CALX_nudiv_qx_zero
    \fi {#1}{#2}{#3}{#4}%
}%
\def\CALX_nudiv_qx_zero #1#2#3#4{\CALX_nudiv_qy \xint:{0}{#3}}%
\def\CALX_nudiv_qx_z #1#2#3#4{%
    \expandafter\CALX_nudiv_qy
    \romannumeral0\CALX_rev_nounsep {}#2\R!\R!\R!\R!\R!\R!\R!\R!\W\xint:{#4-%
        \xint_c_i}{#3}%
}%
\def\CALX_nudiv_qx_n #1#2#3#4{%
    \expandafter\CALX_nudiv_qy
    \romannumeral0\CALX_rev_nounsep {}1#1!#2\R!\R!\R!\R!\R!\R!\R!\R!\W%
        \xint:{#4}{#3}%
}%
\def\CALX_nudiv_qy #1\xint:#2#3#4#5{%
    \expandafter#5\expandafter{\the\numexpr#2}{#1}{#4}{#3}%
}%
%    \end{macrocode}
%\begin{lverb}
% Tiny one-block divisor d <= 45249. With 10^8 = Bq d + Bm (0 <= Bm < d)
% and incoming remainder r < d, a block a gives
%( y = r Bm + a,  q = r Bq + floor(y/d),  r' = y - d floor(y/d),
%)
% exact since r 10^8 + a = r Bq d + y; y + round(d/2) < 2^31 for d <= 45249.
% floor(y/d) = (y + round(d/2))/d - 1. One explicit \numexpr per block plus
% the emission (10^8 + q is evaluated by the enclosing \numexpr chain).
%( \CALX_ndts <r>\xint:<d>\xint:<round(d/2)>\xint:<Bq>\xint:<Bm>!
%:            <MS-first blocks>1;!
%)
% \CALX_ndts_k <d>.<macro> expands to <macro>0\xint:d\xint:dh\xint:Bq\xint:Bm!
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ndts_k #1.{%
    \expandafter\CALX_ndts_ka\the\numexpr(\xint_c_e_viii+#1/\xint_c_ii)/#1-%
        \xint_c_i
    \xint:#1\xint:%
}%
\def\CALX_ndts_ka #1\xint:#2\xint:{%
    \expandafter\CALX_ndts_kb\the\numexpr\xint_c_e_viii-#1*#2\expandafter%
        \xint:%
    \the\numexpr#2/\xint_c_ii\xint:#1\xint:#2\xint:%
}%
\def\CALX_ndts_kb #1\xint:#2\xint:#3\xint:#4\xint:#5{#50\xint:#4\xint:#2%
    \xint:#3\xint:#1!}%
\def\CALX_nudiv_ot #1#2#3#4{%
    \expandafter\CALX_ndts_s
    \romannumeral0\CALX_rev_nounsep {}#4\R!\R!\R!\R!\R!\R!\R!\R!\W%
        \xint:{#3}{#2}#1%
}%
\def\CALX_ndts_s #1\xint:#2{%
    \expandafter\CALX_ndts_z\the\numexpr\CALX_ndts_k #2.\CALX_ndts #11;!%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_ndts}}
%    \begin{macrocode}
\def\CALX_ndts #1\xint:#2\xint:#3\xint:#4\xint:#5!1#6#7!{%
    \xint_gob_til_sc #6\CALX_ndts_end;%
    \expandafter\CALX_ndts_b\the\numexpr(#1)*#5+#6#7\xint:#1\xint:#2\xint:#3%
        \xint:#4\xint:#5!%
}%
\def\CALX_ndts_end;#1\xint:#2\xint:#3!{1\relax;!\xint:{#2}}%
\def\CALX_ndts_b #1\xint:#2\xint:#3\xint:#4\xint:#5\xint:#6!{%
    \xint_c_e_viii+(#2)*#5+(#1+#4)/#3-\xint_c_i
    \expandafter!\the\numexpr\CALX_ndts #1-#3*((#1+#4)/#3-\xint_c_i)\xint:#3%
        \xint:#4\xint:#5\xint:#6!%
}%
\def\CALX_ndts_z #11;!\xint:#2#3{%
    \expandafter\CALX_ndts_zz\the\numexpr\xint_c_e_viii+(#2)\xint:{#3}{#1}%
}%
\def\CALX_ndts_zz #1\xint:#2#3{\CALX_nudiv_qx #3\xint:{#1!1;!}{#2}{0}}%
%    \end{macrocode}
%\begin{lverb}
% Unrolled entries for na = 2, 3, 4 (tiny divisor): the MS-first input is
% written from the parameters and the quotient is assembled directly
% (the top block may be zero, the others are present).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nudiv_otd #1#2{%
    \ifcase#2
    \or\or  \expandafter\CALX_ndts_ii
    \or     \expandafter\CALX_ndts_iii
    \or     \expandafter\CALX_ndts_iv
    \else   \expandafter\CALX_nudiv_ot
    \fi #1{#2}%
}%
\def\CALX_ndts_ii #1#2#3#4{\CALX_ndts_iia #4{#3}#1}%
\def\CALX_ndts_iia 1#1!1#2!#3{%
    \expandafter\CALX_ndts_iib\the\numexpr\CALX_ndts_k #3.\CALX_ndts %
        1#2!1#1!1;!%
}%
\def\CALX_ndts_iib 1#1!1#2!1;!\xint:#3{%
    \expandafter\CALX_ndts_iic\the\numexpr\xint_c_e_viii+(#3)\xint:{#1}{#2}%
}%
\def\CALX_ndts_iic #1\xint:#2#3#4{%
    \ifnum#2=\xint_c_ \xint_dothis{#4{1}{1#3!}}\fi
    \xint_orthat{#4{2}{1#3!1#2!}}{0}{#1!1;!}%
}%
\def\CALX_ndts_iii #1#2#3#4{\CALX_ndts_iiia #4{#3}#1}%
\def\CALX_ndts_iiia 1#1!1#2!1#3!#4{%
    \expandafter\CALX_ndts_iiib\the\numexpr\CALX_ndts_k #4.\CALX_ndts %
        1#3!1#2!1#1!1;!%
}%
\def\CALX_ndts_iiib 1#1!1#2!1#3!1;!\xint:#4{%
    \expandafter\CALX_ndts_iiic\the\numexpr\xint_c_e_viii+(#4)%
        \xint:{#1}{1#3!1#2!}%
}%
\def\CALX_ndts_iiic #1\xint:#2#3#4{%
    \ifnum#2=\xint_c_ \xint_dothis{#4{2}{#3}}\fi
    \xint_orthat{#4{3}{#31#2!}}{0}{#1!1;!}%
}%
\def\CALX_ndts_iv #1#2#3#4{\CALX_ndts_iva #4{#3}#1}%
\def\CALX_ndts_iva 1#1!1#2!1#3!1#4!#5{%
    \expandafter\CALX_ndts_ivb\the\numexpr\CALX_ndts_k #5.\CALX_ndts %
        1#4!1#3!1#2!1#1!1;!%
}%
\def\CALX_ndts_ivb 1#1!1#2!1#3!1#4!1;!\xint:#5{%
    \expandafter\CALX_ndts_ivc\the\numexpr\xint_c_e_viii+(#5)%
        \xint:{#1}{1#4!1#3!1#2!}%
}%
\def\CALX_ndts_ivc #1\xint:#2#3#4{%
    \ifnum#2=\xint_c_ \xint_dothis{#4{3}{#3}}\fi
    \xint_orthat{#4{4}{#31#2!}}{0}{#1!1;!}%
}%
%    \end{macrocode}
%\begin{lverb}
% Three-block divisor (nb = 3). Estimate and correction loop as for nb = 2
% (U = u0 u1 u2, V = v1 v2: q is the true quotient block or one more), the
% macros are duplicated (\CALX_ndth_q ... \CALX_ndth_f), only the exit
% \CALX_ndth_g differs: with T = a b + c = U - qV, the window minus q B' is
%( a b^2 + c b + u3 - q v3,  q v3 = (qh v3h + M3h) b + 10^4 M3l + ql v3l.
%: X = 3b + u3 - ql v3l - 10^4 M3l   in (b, 4b): digits e1<r2>,
%: Y = 3b + c - qh v3h - M3h - 3 + e1  in (b, 4b): digits e2<r1>,
%: r0 = a + e2 - 3; if r0 < 0, B' is added back and q decreases.
%)
% Loop state: \CALX_ndth {C12}{V3}{u0}{u1}{u2}1<u3>!...1;!
% C12 = {Vp}{M}{{v1h}{v1l}{v2h}{v2l}}, V3 = {v3h}{v3l}; q0 as for nb = 2.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nudiv_three #1#2#3#4#5{\CALX_nudiv_hw #5{#2}{#3}#1}%
\def\CALX_nudiv_hw 1#1#2#3#4#5!1#6#7#8#9{\CALX_nudiv_ha %
    {#1#2#3#4}{#5}{#6#7#8#9}}%
\def\CALX_nudiv_ha #1#2#3#4!1#5#6#7#8{\CALX_nudiv_hb %
    {#1}{#2}{#3}{#4}{#5#6#7#8}}%
\def\CALX_nudiv_hb #1#2#3#4#5#6!{%
    \expandafter\CALX_nudiv_hv
    \expanded{\CALX_nudiv_mp{\CALX_nudiv_gs 1#5#6!%
        \xint:}}{#1}{#2}{#3}{#4}{#5}{#6}%
}%
\def\CALX_nudiv_hv #1.#2.#3#4#5#6#7#8{%
    \expandafter\CALX_nudiv_hc
    \the\numexpr#7#8*#1+(#5#6+#2/\xint_c_ii)/#2-\xint_c_i\xint:%
    {#1}{{#7}{#8}{#5}{#6}}{{#3}{#4}}%
}%
\def\CALX_nudiv_hc #1\xint:#2#3#4#5#6{%
    \expandafter\CALX_nudiv_he
    \romannumeral0\CALX_rev_nounsep {}#6\R!\R!\R!\R!\R!\R!\R!\R!\W
    \xint:{{#1}{#2}{#3}}{#4}{#5}%
}%
\def\CALX_nudiv_hcmp #1#2#3#4#5{%
    \ifnum#1<\CALX_ndth_vone#4 -\xint_c_i\else\ifnum#1>\CALX_ndth_vone#4 %
        \xint_c_\else
    \ifnum#2<\CALX_ndth_vtwo#4 -\xint_c_i\else\ifnum#2>\CALX_ndth_vtwo#4 %
        \xint_c_\else
    \ifnum#3<\CALX_ndth_vthree#5 -\xint_c_i\else\xint_c_\fi\fi\fi\fi\fi
}%
\def\CALX_nudiv_he 1#1!1#2!1#3!#4\xint:#5#6#7{%
    \ifnum\CALX_nudiv_hcmp{#1}{#2}{#3}{#5}{#6}<\xint_c_
       \ifnum#7=\xint_c_iii \CALX_nudiv_hq\fi
       \expandafter\CALX_nudiv_hn
    \else
       \expandafter\CALX_nudiv_hp
    \fi {#1}{#2}{#3}{#4}{#5}{#6}{#7}%
}%
\def\CALX_nudiv_hq\fi\expandafter\CALX_nudiv_hn\else\expandafter%
    \CALX_nudiv_hp\fi
    #1#2#3#4#5#6#7#8{\fi\fi#8{0}{}{0}{1#3!1#2!1#1!1;!}}%
\def\CALX_nudiv_hn #1#2#3#4#5#6#7{%
    \expandafter\CALX_ndth_z\the\numexpr\CALX_ndth %
        {#5}{#6}{#1}{#2}{#3}#41;!{#7-\xint_c_iii}{0}%
}%
\def\CALX_nudiv_hp #1#2#3#4#5#6#7{%
    \expandafter\CALX_ndth_z\the\numexpr\CALX_ndth %
        {#5}{#6}{0}{#1}{#2}1#3!#41;!{#7-\xint_c_ii}{0}%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_ndth}}
%    \begin{macrocode}
\def\CALX_ndth #1{\CALX_ndth_a #1}%
\def\CALX_ndth_a #1#2#3#4#5#6#7{%
    \expandafter\CALX_ndth_q
    \the\numexpr(#5*#2)*\xint_c_e_viii/#1+#6*#2/#1+(#7*#2/\xint_c_e_viii)/#1%
        \xint:%
    #3{#5}{#6}{#7}{{#1}{#2}{#3}}{#4}%
}%
\def\CALX_ndth_q #1\xint:%
    {\ifnum#1>\xint_c_e_viii_mone \CALX_ndth_qm\fi\CALX_ndth_h #1\xint:}%
\def\CALX_ndth_qm\fi#1\xint:{\fi\CALX_ndth_h 99999999\xint:}%
\def\CALX_ndth_h #1\xint:{%
    \expandafter\CALX_ndth_x
    \the\numexpr(#1+5000)/\xint_c_e_iv-\xint_c_i\expandafter\xint:%
    \the\numexpr#1-\xint_c_e_iv*((#1+5000)/\xint_c_e_iv-\xint_c_i)\xint:%
}%
\def\CALX_ndth_x #1\xint:#2\xint:#3#4#5#6#7#8#9{%
    \expandafter\CALX_ndth_w\the\numexpr
    \xint_c_iii*\xint_c_e_viii+#9-#2*#6%
    -(#1*#6+#2*#5-\xint_c_e_iv*((#1*#6+#2*#5+5000)/\xint_c_e_iv-\xint_c_i))%
     *\xint_c_e_iv
    \expandafter\xint:\the\numexpr
    (#7-#1*#3-(#1*#4+#2*#3+5000)/\xint_c_e_iv+\xint_c_i)*\xint_c_e_viii+#8%
    -(#1*#4+#2*#3-\xint_c_e_iv*((#1*#4+#2*#3+5000)/\xint_c_e_iv-\xint_c_i))%
     *\xint_c_e_iv
    -#2*#4-#1*#5-(#1*#6+#2*#5+5000)/\xint_c_e_iv+\xint_c_i
    \xint:{#1*\xint_c_e_iv+#2}{#3}{#4}{#5}{#6}%
}%
\def\CALX_ndth_w #1#2\xint:#3\xint:{%
    \expandafter\CALX_ndth_l\the\numexpr#3+#1-%
        \xint_c_iii.{#2}%
}%
\def\CALX_ndth_l #1.#2#3#4#5#6#7{%
    \ifnum#1<\xint_c_ \xint_dothis\CALX_ndth_d\fi
    \ifnum\numexpr\xint_c_ii*(#1-#4#5)\ifnum#2<#6#7 -\xint_c_i\fi
        <\xint_c_ \xint_dothis\CALX_ndth_g\fi
    \ifnum\numexpr#3=\xint_c_e_viii_mone \xint_dothis\CALX_ndth_g\fi
    \xint_orthat\CALX_ndth_i {#1}{#2}{#3}{#4}{#5}{#6}{#7}%
}%
\def\CALX_ndth_d #1#2#3#4#5#6#7{%
    \expandafter\CALX_ndth_e\the\numexpr\xint_c_e_viii+#2+#6#7\xint:%
    {#1+#4#5}{#3-\xint_c_i}{#4}{#5}{#6}{#7}%
}%
\def\CALX_ndth_i #1#2#3#4#5#6#7{%
    \expandafter\CALX_ndth_e\the\numexpr\xint_c_ii*\xint_c_e_viii+#2-#6#7%
        \xint:%
    {#1-#4#5-\xint_c_i}{#3+\xint_c_i}{#4}{#5}{#6}{#7}%
}%
\def\CALX_ndth_e #1#2\xint:#3#4{%
    \expandafter\CALX_ndth_f\the\numexpr#3+#1-\xint_c_i\expandafter\xint:%
    \the\numexpr#4\xint:{#2}%
}%
\def\CALX_ndth_f #1\xint:#2\xint:#3{\CALX_ndth_l #1.{#3}{#2}}%
%    \end{macrocode}
%\begin{lverb}
% Exit of the correction loop: #1=a, #2=c, #3=q, #4-#7=v1h v1l v2h v2l,
% #8=C12, #9=V3, then 1<u3>! in the stream.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ndth_g #1#2#3#4#5#6#7#8#9{%
    \expandafter\CALX_ndth_m\the\numexpr(#3+5000)/\xint_c_e_iv-\xint_c_i%
        \xint:#9%
    {#1}{#2}{#3}{#8}%
}%
\def\CALX_ndth_m #1\xint:#2#3#4#5#6#71#8!{%
    \expandafter\CALX_ndth_n\the\numexpr
    \xint_c_iii*\xint_c_e_viii+#8-(#6-\xint_c_e_iv*#1)*#3%
    -(#1*#3+(#6-\xint_c_e_iv*#1)*#2%
      -\xint_c_e_iv*((#1*#3+(#6-\xint_c_e_iv*#1)*#2+5000)/\xint_c_e_iv-%
          \xint_c_i))%
     *\xint_c_e_iv
    \xint:{#1*#2+(#1*#3+(#6-\xint_c_e_iv*#1)*#2+5000)/\xint_c_e_iv-\xint_c_i}%
    {#4}{#5}{#6}{#7}{{#2}{#3}}%
}%
\def\CALX_ndth_n #1#2\xint:#3#4#5{%
    \expandafter\CALX_ndth_o\the\numexpr
    \xint_c_iii*\xint_c_e_viii+#5-(#3)-\xint_c_iii+#1%
        \xint:{#2}{#4}%
}%
\def\CALX_ndth_o #1#2\xint:#3#4{%
    \expandafter\CALX_ndth_oa\the\numexpr#4+#1-\xint_c_iii\xint:{#2}{#3}%
}%
\def\CALX_ndth_oa #1\xint:{%
    \ifnum#1<\xint_c_ \expandafter\CALX_ndth_ab\else\expandafter\CALX_ndth_p%
        \fi {#1}%
}%
\def\CALX_ndth_p #1#2#3#4#5#61#7#8!{%
    \xint_gob_til_sc #7\CALX_ndth_end;%
    \xint_c_e_viii+#4\expandafter!\the\numexpr\CALX_ndth %
        {#5}{#6}{#1}{#2}{#3}1#7#8!%
}%
\def\CALX_ndth_end;\xint_c_e_viii+#1\expandafter!\the\numexpr\CALX_ndth %
    #2#3#4#5#61;!%
    {\xint_c_e_viii+#1\relax!\xint:{#4}{#5}{#6}}%
%    \end{macrocode}
%\begin{lverb}
% Add back (rare): #1=r0 (<0), #2=r1, #3=r2, #4=q, #5=C12, #6=V3.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ndth_vone   #1#2#3{\CALX_ndth_vonea #3}%
\def\CALX_ndth_vonea  #1#2#3#4{#1#2}%
\def\CALX_ndth_vtwo   #1#2#3{\CALX_ndth_vtwoa #3}%
\def\CALX_ndth_vtwoa  #1#2#3#4{#3#4}%
\def\CALX_ndth_vthree #1#2{#1#2}%
\def\CALX_ndth_ab #1#2#3#4#5#6{%
    \expandafter\CALX_ndth_ac\the\numexpr\xint_c_e_viii+#3+%
        \CALX_ndth_vthree#6\xint:%
    {#1}{#2}{#4}{#5}{#6}%
}%
\def\CALX_ndth_ac #1#2\xint:#3#4#5#6{%
    \expandafter\CALX_ndth_ad\the\numexpr\xint_c_e_viii+#4+%
        \CALX_ndth_vtwo#6+#1-\xint_c_i\xint:%
    {#2}{#3}{#5}{#6}%
}%
\def\CALX_ndth_ad #1#2\xint:#3#4#5#6{%
    \expandafter\CALX_ndth_ae\the\numexpr#4+\CALX_ndth_vone#6+#1-\xint_c_i%
        \xint:%
    {#2}{#3}{#5-\xint_c_i}{#6}%
}%
\def\CALX_ndth_ae #1\xint:{\CALX_ndth_p {#1}}%
\def\CALX_ndth_z #1\xint:#2#3#4{%
    \expandafter\CALX_ndth_zz\the\numexpr\xint_c_e_viii+(#2)%
        \xint:{#3}{#4}{#1}%
}%
\def\CALX_ndth_zz #1\xint:#2#3#4{\CALX_nudiv_qx #4\xint:{1#3!1#2!#1!1;!}}%
%    \end{macrocode}
%\begin{lverb}
% Four-block divisor (nb = 4), no normalization, estimate and loop as for
% nb = 2 (duplicated as \CALX_ndfo_q ... \CALX_ndfo_f). With T = a b + c,
% the window minus q B' is a b^3 + c b^2 + u3 b + u4 - q (v3 b + v4):
%( X4 = 3b + u4 - ql v4l - 10^4 M4l                  digits e4<r3>
%: X3 = 5b + u3 - ql v3l - 10^4 M3l - H4 - 3 + e4    digits e3<r2>
%: Y  = 3b + c - H3 - 5 + e3                          digits e2<r1>
%: r0 = a + e2 - 3   (add-back if negative)
%)
% with Hk = qh vkh + Mkh, Mk = qh vkl + ql vkh.
%
% Loop state: \CALX_ndfo {C12}{V34}{u0}{u1}{u2}{u3}1<u4>!...1;!
% C12 = {Vp}{M}{{v1h}{v1l}{v2h}{v2l}}, V34 = {v3h}{v3l}{v4h}{v4l}.
%
% After the correction loop: pack P3 = {a}{c}{q}{C12}.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nudiv_four #1#2#3#4#5{\CALX_nudiv_fw #5{#2}{#3}#1}%
\def\CALX_nudiv_fw 1#1#2#3#4#5!1#6#7#8#9{\CALX_nudiv_fa %
    {#1#2#3#4}{#5}{#6#7#8#9}}%
\def\CALX_nudiv_fa #1#2#3#4!1#5#6#7#8{\CALX_nudiv_fb %
    {{#3}{#4}{#1}{#2}}{#5#6#7#8}}%
\def\CALX_nudiv_fb #1#2#3!1#4#5#6#7{\CALX_nudiv_fc {#1}{#2}{#3}{#4#5#6#7}}%
\def\CALX_nudiv_fc #1#2#3#4#5!{%
    \expandafter\CALX_nudiv_fv
    \expanded{\CALX_nudiv_mp{\CALX_nudiv_gs 1#4#5!%
        \xint:}}{#4}{#5}{#2}{#3}{#1}%
}%
\def\CALX_nudiv_fv #1.#2.#3#4#5#6{%
    \expandafter\CALX_nudiv_fd
    \the\numexpr#3#4*#1+(#5#6+#2/\xint_c_ii)/#2-\xint_c_i\xint:%
    {#1}{{#3}{#4}{#5}{#6}}%
}%
\def\CALX_nudiv_fd #1\xint:#2#3#4#5#6{%
    \expandafter\CALX_nudiv_fe
    \romannumeral0\CALX_rev_nounsep {}#6\R!\R!\R!\R!\R!\R!\R!\R!\W
    \xint:{{#1}{#2}{#3}}{#4}{#5}%
}%
\def\CALX_nudiv_fcmp #1#2#3#4#5#6{%
    \ifnum#1<\CALX_ndth_vone#5 -\xint_c_i\else\ifnum#1>\CALX_ndth_vone#5 %
        \xint_c_\else
    \ifnum#2<\CALX_ndth_vtwo#5 -\xint_c_i\else\ifnum#2>\CALX_ndth_vtwo#5 %
        \xint_c_\else
    \ifnum#3<\CALX_ndfo_vthree#6 -\xint_c_i\else\ifnum#3>\CALX_ndfo_vthree#6 %
        \xint_c_\else
    \ifnum#4<\CALX_ndfo_vfour#6 -\xint_c_i\else\xint_c_\fi\fi\fi\fi\fi\fi\fi
}%
\def\CALX_nudiv_fe 1#1!1#2!1#3!1#4!#5\xint:#6#7#8{%
    \ifnum\CALX_nudiv_fcmp{#1}{#2}{#3}{#4}{#6}{#7}<\xint_c_
       \ifnum#8=\xint_c_iv \CALX_nudiv_fq\fi
       \expandafter\CALX_nudiv_fn
    \else
       \expandafter\CALX_nudiv_fp
    \fi {#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}%
}%
\def\CALX_nudiv_fq\fi\expandafter\CALX_nudiv_fn\else\expandafter%
    \CALX_nudiv_fp\fi
    #1#2#3#4#5#6#7#8#9{\fi\fi#9{0}{}{0}{1#4!1#3!1#2!1#1!1;!}}%
\def\CALX_nudiv_fn #1#2#3#4#5#6#7#8{%
    \expandafter\CALX_ndfo_z
    \the\numexpr\CALX_ndfo {#6}{#7}{#1}{#2}{#3}{#4}#51;!{#8-\xint_c_iv}{0}%
}%
\def\CALX_nudiv_fp #1#2#3#4#5#6#7#8{%
    \expandafter\CALX_ndfo_z
    \the\numexpr\CALX_ndfo {#6}{#7}{0}{#1}{#2}{#3}1#4!#51;!{#8-%
        \xint_c_iii}{0}%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_ndfo}}
%    \begin{macrocode}
\def\CALX_ndfo #1{\CALX_ndfo_a #1}%
\def\CALX_ndfo_a #1#2#3#4#5#6#7{%
    \expandafter\CALX_ndfo_q
    \the\numexpr(#5*#2)*\xint_c_e_viii/#1+#6*#2/#1+(#7*#2/\xint_c_e_viii)/#1%
        \xint:%
    #3{#5}{#6}{#7}{{#1}{#2}{#3}}{#4}%
}%
\def\CALX_ndfo_q #1\xint:%
    {\ifnum#1>\xint_c_e_viii_mone \CALX_ndfo_qm\fi\CALX_ndfo_h #1\xint:}%
\def\CALX_ndfo_qm\fi#1\xint:{\fi\CALX_ndfo_h 99999999\xint:}%
\def\CALX_ndfo_h #1\xint:{%
    \expandafter\CALX_ndfo_x
    \the\numexpr(#1+5000)/\xint_c_e_iv-\xint_c_i\expandafter\xint:%
    \the\numexpr#1-\xint_c_e_iv*((#1+5000)/\xint_c_e_iv-\xint_c_i)\xint:%
}%
\def\CALX_ndfo_x #1\xint:#2\xint:#3#4#5#6#7#8#9{%
    \expandafter\CALX_ndfo_w\the\numexpr
    \xint_c_iii*\xint_c_e_viii+#9-#2*#6%
    -(#1*#6+#2*#5-\xint_c_e_iv*((#1*#6+#2*#5+5000)/\xint_c_e_iv-\xint_c_i))%
     *\xint_c_e_iv
    \expandafter\xint:\the\numexpr
    (#7-#1*#3-(#1*#4+#2*#3+5000)/\xint_c_e_iv+\xint_c_i)*\xint_c_e_viii+#8%
    -(#1*#4+#2*#3-\xint_c_e_iv*((#1*#4+#2*#3+5000)/\xint_c_e_iv-\xint_c_i))%
     *\xint_c_e_iv
    -#2*#4-#1*#5-(#1*#6+#2*#5+5000)/\xint_c_e_iv+\xint_c_i
    \xint:{#1*\xint_c_e_iv+#2}{#3}{#4}{#5}{#6}%
}%
\def\CALX_ndfo_w #1#2\xint:#3\xint:{%
    \expandafter\CALX_ndfo_l\the\numexpr#3+#1-%
        \xint_c_iii.{#2}%
}%
\def\CALX_ndfo_l #1.#2#3#4#5#6#7{%
    \ifnum#1<\xint_c_ \xint_dothis\CALX_ndfo_d\fi
    \ifnum\numexpr\xint_c_ii*(#1-#4#5)\ifnum#2<#6#7 -\xint_c_i\fi
        <\xint_c_ \xint_dothis\CALX_ndfo_g\fi
    \ifnum\numexpr#3=\xint_c_e_viii_mone \xint_dothis\CALX_ndfo_g\fi
    \xint_orthat\CALX_ndfo_i {#1}{#2}{#3}{#4}{#5}{#6}{#7}%
}%
\def\CALX_ndfo_d #1#2#3#4#5#6#7{%
    \expandafter\CALX_ndfo_e\the\numexpr\xint_c_e_viii+#2+#6#7\xint:%
    {#1+#4#5}{#3-\xint_c_i}{#4}{#5}{#6}{#7}%
}%
\def\CALX_ndfo_i #1#2#3#4#5#6#7{%
    \expandafter\CALX_ndfo_e\the\numexpr\xint_c_ii*\xint_c_e_viii+#2-#6#7%
        \xint:%
    {#1-#4#5-\xint_c_i}{#3+\xint_c_i}{#4}{#5}{#6}{#7}%
}%
\def\CALX_ndfo_e #1#2\xint:#3#4{%
    \expandafter\CALX_ndfo_f\the\numexpr#3+#1-\xint_c_i\expandafter\xint:%
    \the\numexpr#4\xint:{#2}%
}%
\def\CALX_ndfo_f #1\xint:#2\xint:#3{\CALX_ndfo_l #1.{#3}{#2}}%
%    \end{macrocode}
%\begin{lverb}
% Exit: #1=a, #2=c, #3=q, #4-#7 v1h v1l v2h v2l, #8=C12, #9=V34, then
% {u3}1<u4>! in the stream.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ndfo_pa #1#2#3#4{#1}%
\def\CALX_ndfo_pc #1#2#3#4{#2}%
\def\CALX_ndfo_pq #1#2#3#4{#3}%
\def\CALX_ndfo_g #1#2#3#4#5#6#7#8#9{\CALX_ndfo_m {{#1}{#2}{#3}{#8}}#9}%
\def\CALX_ndfo_m #1#2#3#4#5#61#7!{%
    \expandafter\CALX_ndfo_n
    \the\numexpr(\CALX_ndfo_pq#1+5000)/\xint_c_e_iv-\xint_c_i\xint:%
    {#1}{#2}{#3}{#4}{#5}{#6}{#7}%
}%
\def\CALX_ndfo_n #1\xint:#2#3#4#5#6#7#8{%
    \expandafter\CALX_ndfo_o\the\numexpr
    \xint_c_iii*\xint_c_e_viii+#8-(\CALX_ndfo_pq#2-\xint_c_e_iv*#1)*#6%
    -(#1*#6+(\CALX_ndfo_pq#2-\xint_c_e_iv*#1)*#5-\xint_c_e_iv*((#1*#6+(%
        \CALX_ndfo_pq#2-\xint_c_e_iv*#1)*#5+5000)/\xint_c_e_iv-\xint_c_i))*%
        \xint_c_e_iv
    \xint:{#1*#5+(#1*#6+(\CALX_ndfo_pq#2-\xint_c_e_iv*#1)*#5+5000)/%
        \xint_c_e_iv-\xint_c_i}{#1}{#2}{#3}{#4}{#7}%
    {{#3}{#4}{#5}{#6}}%
}%
\def\CALX_ndfo_o #1#2\xint:#3#4#5#6#7#8{%
    \expandafter\CALX_ndfo_r\the\numexpr
    \xint_c_v*\xint_c_e_viii+#8-(\CALX_ndfo_pq#5-\xint_c_e_iv*#4)*#7%
    -(#4*#7+(\CALX_ndfo_pq#5-\xint_c_e_iv*#4)*#6-\xint_c_e_iv*((#4*#7+(%
        \CALX_ndfo_pq#5-\xint_c_e_iv*#4)*#6+5000)/\xint_c_e_iv-\xint_c_i))*%
        \xint_c_e_iv
    -(#3)-\xint_c_iii+#1%
    \xint:{#4*#6+(#4*#7+(\CALX_ndfo_pq#5-\xint_c_e_iv*#4)*#6+5000)/%
        \xint_c_e_iv-\xint_c_i}{#2}{#5}%
}%
\def\CALX_ndfo_r #1#2\xint:#3#4#5{%
    \expandafter\CALX_ndfo_s\the\numexpr
    \xint_c_iii*\xint_c_e_viii+\CALX_ndfo_pc#5-(#3)-\xint_c_v+#1%
        \xint:{#2}{#4}{#5}%
}%
\def\CALX_ndfo_s #1#2\xint:#3#4#5{%
    \expandafter\CALX_ndfo_t\the\numexpr\CALX_ndfo_pa#5+#1-\xint_c_iii\xint:%
    {#2}{#3}{#4}{#5}%
}%
\def\CALX_ndfo_t #1\xint:#2#3#4#5{%
    \ifnum#1<\xint_c_ \expandafter\CALX_ndfo_ab\else\expandafter\CALX_ndfo_tu%
        \fi
    #5{#1}{#2}{#3}{#4}%
}%
\def\CALX_ndfo_tu #1#2{\CALX_ndfo_y}%
\def\CALX_ndfo_y #1#2#3#4#5#6#71#8#9!{%
    \xint_gob_til_sc #8\CALX_ndfo_end;%
    \xint_c_e_viii+#1\expandafter!\the\numexpr\CALX_ndfo %
        {#2}{#7}{#3}{#4}{#5}{#6}1#8#9!%
}%
\def\CALX_ndfo_end;\xint_c_e_viii+#1\expandafter!\the\numexpr\CALX_ndfo %
    #2#3#4#5#6#71;!%
    {\xint_c_e_viii+#1\relax!\xint:{#4}{#5}{#6}{#7}}%
%    \end{macrocode}
%\begin{lverb}
% Add back (rare): #1=a, #2=c, #3=q, #4=C12 (P3 unpacked), #5=r0 (<0),
% #6=r1, #7=r2, #8=r3, #9=V34.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ndfo_vthree #1#2#3#4{#1#2}%
\def\CALX_ndfo_vfour  #1#2#3#4{#3#4}%
\def\CALX_ndfo_pvone  #1#2#3#4{\CALX_ndth_vone#4}%
\def\CALX_ndfo_pvtwo  #1#2#3#4{\CALX_ndth_vtwo#4}%
\def\CALX_ndfo_ab #1#2#3#4#5#6#7#8#9{%
    \expandafter\CALX_ndfo_ac\the\numexpr\xint_c_e_viii+#8+\CALX_ndfo_vfour#9%
        \xint:%
    {#5}{#6}{#7}{#9}{{#1}{#2}{#3}{#4}}%
}%
\def\CALX_ndfo_ac #1#2\xint:#3#4#5#6{%
    \expandafter\CALX_ndfo_ad\the\numexpr\xint_c_e_viii+#5+%
        \CALX_ndfo_vthree#6+#1-\xint_c_i
    \xint:{#2}{#3}{#4}{#6}%
}%
\def\CALX_ndfo_ad #1#2\xint:#3#4#5#6#7{%
    \expandafter\CALX_ndfo_ae\the\numexpr\xint_c_e_viii+#5+%
        \CALX_ndfo_pvtwo#7+#1-\xint_c_i
    \xint:{#2}{#3}{#4}{#6}{#7}%
}%
\def\CALX_ndfo_ae #1#2\xint:#3#4#5#6#7{%
    \expandafter\CALX_ndfo_af\the\numexpr#5+\CALX_ndfo_pvone#7+#1-\xint_c_i%
        \xint:%
    {#2}{#3}{#4}{#6}{#7}%
}%
\def\CALX_ndfo_af #1\xint:#2#3#4#5#6{\CALX_ndfo_ah #6{#1}{#2}{#3}{#4}{#5}}%
\def\CALX_ndfo_ah #1#2#3{\CALX_ndfo_y {#3-\xint_c_i}}%
\def\CALX_ndfo_z #1\xint:#2#3#4#5{%
    \expandafter\CALX_ndfo_zz\the\numexpr\xint_c_e_viii+(#2)%
        \xint:{#3}{#4}{#5}{#1}%
}%
\def\CALX_ndfo_zz #1\xint:#2#3#4#5{\CALX_nudiv_qx #5%
    \xint:{1#4!1#3!1#2!#1!1;!}}%
%    \end{macrocode}
% \subsection{Native signed division}
% \subsubsection{\csh{CALX_ndivtrunc}, \csh{CALX_nmodtrunc},
% \csh{CALX_ndivfloor}, \csh{CALX_nmod}, \csh{CALX_nquo}, \csh{CALX_nrem},
% \csh{CALX_ndivround}, \csh{CALX_ndivision}, \csh{CALX_ndivmod}}
%\begin{lverb}
% Syntax (use with \romannumeral0; A, B f-expanded native integers):
%(
%  \CALX_n<op>{A}{B}       -> <space>Z     (op: divtrunc, modtrunc,
%:                                         divfloor, mod, quo, rem, divround)
%:  \CALX_ndivision{A}{B}  -> {Q}{R}
%:  \CALX_ndivmod{A}{B}    -> {Q}{R}
%)
% Z, Q, R native integers (zero divisor: I values or the trap value, see
% below).
%
% Signed division. All macros are used as \romannumeral0\CALX_n...{A}{B},
% the arguments being f-expanded native integers (A first). With a = |A|,
% b = |B|, q = floor(a/b), r = a - q b (unsigned core \CALX_nudiv), sA, sB
% the signs:
%- \CALX_ndivtrunc$empty: sA sB q (truncation);
%- \CALX_nmodtrunc$empty: sA r, remainder of the truncated division;
%- \CALX_ndivfloor$empty: sA sB (q + d), d = 1 if sA <> sB and r <> 0, else 0;
%- \CALX_nmod$empty: A - B \CALX_ndivfloor(A,B), i.e. sA r + e sB b with e = 1
% if sA <> sB and r <> 0, else 0 (sign of B or zero);
%- \CALX_nquo$empty: sA sB (q + d), d = 1 if sA = - and r <> 0, else 0; this
% is sB floor(A/b) (xint's \xintiiQuo);
%- \CALX_nrem$empty: A - B \CALX_nquo(A,B) = sA r + e b, e = 1 if sA = - and
% r <> 0, else 0; it is >= 0 (xint's \xintiiRem);
%- \CALX_ndivround$empty: sA sB (q + d), d = 1 if 2r >= b, else 0 (rounding
% half away from zero, xint's \xintiiDivRound);
%- \CALX_ndivision$empty: {\CALX_nquo}{\CALX_nrem} (xint's \xintiiDivision);
%- \CALX_ndivmod$empty: {\CALX_ndivfloor}{\CALX_nmod} (xint's \xintiiDivMod).
%
% A zero divisor is signalled as in Python's decimal module (conditions of
% the signals section, trap value N+0. which is what xint returns):
%- quotient of x <> 0 by 0: DivisionByZero, handler argument the sign of x,
% default result I+ or I-; quotient 0 by 0: DivisionUndefined, I?;
%- remainder of x <> 0 by 0: InvalidOperation, I?; remainder 0 by 0:
% DivisionUndefined, I?;
%- pair, x <> 0 by 0: DivisionByZero then InvalidOperation, {I+ or I-}{I?};
% pair 0 by 0: one DivisionUndefined, {I?}{I?}.
%
% Implementation. \CALX_ndiv_y receives B, A and three tokens of the
% family: a starter, a macro for B = 0, a macro for A = 0. The starter is
% followed by {na}{A}{nb}{B}<sA><sB>. For the families which do not need B
% after the division the starter is a parameterless macro expanding to
% \CALX_nudiv<cont>, so that nothing is copied; the others copy {nb}{B} once
% after the arguments of \CALX_nudiv. \CALX_nudiv leaves the following
% tokens untouched, hence <cont> receives
%( {nq}{Q}{s}{R'}<sA><sB>          or      {nq}{Q}{s}{R'}{nb}{B}<sA><sB>
%)
% Quotient-only families never compute R (the test r <> 0 is \CALX_nrz on
% R', which does not need the normalization of R'). q + 1 is one pass of
% the addition kernel (\CALX_nqinc). The rounding test 2r >= b doubles R
% with the addition kernel, compares block counts, and for equal counts
% reads the final borrow state of the subtraction kernel computing 2R - B.
% The added terms e b and e sB b are done by \CALX_nadd_y.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ndiv_x #1#2\xint:#3#4#5#6%
   {\expandafter\CALX_nsp_t\expandafter\CALX_ndiv_y\expandafter\CALX_ndiv_sp
    \expandafter#1\romannumeral`&&@#6\xint:#1#2\xint:#3#4#5}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_ndiv_sp <tA><tB><sB>..\xint:<tA><sA>..\xint:<go><z><zz> (A
% dividend, B divisor; <z> = \CALX_ndiv_zq, _zr or _zp tells quotient,
% remainder or pair). Quotient: NaN: I?; Inf/Inf: InvalidOperation (I?);
% Inf/0: Inf with the sign of A; Inf/c: Inf, product of signs; c/Inf: 0.
%
% Remainder: NaN: I?; Inf dividend: InvalidOperation (I?); finite A by
% Inf: A (Python decimal model, for all members of the family). Pair:
% {quotient}{remainder}.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ndiv_sp #1#2#3#4\xint:#5#6#7\xint:#8#9%
{%
    \ifx#9\CALX_ndiv_zq\xint_dothis\CALX_ndiv_spq\fi
    \ifx#9\CALX_ndiv_zr\xint_dothis\CALX_ndiv_spr\fi
    \xint_orthat\CALX_ndiv_spp #2#3{#4}#5#6{#7}%
}%
\def\CALX_ndiv_spq #1#2#3#4#5#6#7%
{%
    \if ?#2\xint_dothis{ I?}\fi
    \if ?#5\xint_dothis{ I?}\fi
    \if N#4\xint_dothis{ N+0.}\fi
    \if I#1\xint_dothis{\CALX_nsig{InvalidOperation}{inf // inf}{}}\fi
    \ifnum\CALX_nsp_z#3\xint:=\xint_c_ \xint_dothis{ I#5}\fi
    \xint_orthat{\CALX_nsp_ps#2#5}%
}%
\def\CALX_ndiv_spr #1#2#3#4#5#6#7%
{%
    \if ?#2\xint_dothis{ I?}\fi
    \if ?#5\xint_dothis{ I?}\fi
    \if I#4\xint_dothis{\CALX_nsig{InvalidOperation}{inf mod x}{}}\fi
    \xint_orthat{ N#5#6}%
}%
\def\CALX_ndiv_spp #1#2#3#4#5#6#7%
   {\CALX_npair{\CALX_ndiv_spq#1#2{#3}#4#5{#6}{}}{%
       \CALX_ndiv_spr#1#2{#3}#4#5{#6}{}}}%
\def\CALX_ndiv_y N#1#2.#3\xint:N#4#5.#6\xint:#7#8#9{%
    \ifnum#2=\xint_c_ \xint_dothis{#8#4{#5}}\fi
    \ifnum#5=\xint_c_ \xint_dothis#9\fi
    \xint_orthat{#7{#5}{#6}{#2}{#3}#4#1}%
}%
\def\CALX_ndivtrunc #1{\expandafter\CALX_ndiv_x\romannumeral`&&@#1\xint:%
    \CALX_ndt_go\CALX_ndiv_zq\CALX_ndiv_zz}%
\def\CALX_nmodtrunc #1{\expandafter\CALX_ndiv_x\romannumeral`&&@#1\xint:%
    \CALX_nmt_go\CALX_ndiv_zr\CALX_ndiv_zz}%
\def\CALX_ndivfloor #1{\expandafter\CALX_ndiv_x\romannumeral`&&@#1\xint:%
    \CALX_ndf_go\CALX_ndiv_zq\CALX_ndiv_zz}%
\def\CALX_nmod      #1{\expandafter\CALX_ndiv_x\romannumeral`&&@#1\xint:%
    \CALX_nmd_go\CALX_ndiv_zr\CALX_ndiv_zz}%
\def\CALX_nquo      #1{\expandafter\CALX_ndiv_x\romannumeral`&&@#1\xint:%
    \CALX_nqu_go\CALX_ndiv_zq\CALX_ndiv_zz}%
\def\CALX_nrem      #1{\expandafter\CALX_ndiv_x\romannumeral`&&@#1\xint:%
    \CALX_nre_go\CALX_ndiv_zr\CALX_ndiv_zz}%
\def\CALX_ndivround #1{\expandafter\CALX_ndiv_x\romannumeral`&&@#1\xint:%
    \CALX_ndr_go\CALX_ndiv_zq\CALX_ndiv_zz}%
\def\CALX_ndivision #1{\expandafter\CALX_ndiv_x\romannumeral`&&@#1\xint:%
    \CALX_ndn_go\CALX_ndiv_zp\CALX_ndiv_zzp}%
\def\CALX_ndivmod   #1{\expandafter\CALX_ndiv_x\romannumeral`&&@#1\xint:%
    \CALX_ndm_go\CALX_ndiv_zp\CALX_ndiv_zzp}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nsig}}
%\begin{lverb}
% Zero operands. \CALX_ndiv_zq, _zr, _zp receive <sign of A>{nA}.
%
% \CALX_nsig{<condition>}{<message>}{<handler argument>} signals and puts the
% space token ending \romannumeral0 in front of the result.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ndiv_zz{ N+0.}%
\def\CALX_ndiv_zzp{{N+0.}{N+0.}}%
\def\CALX_nsig #1#2#3%
   {\expandafter\CALX_sp\romannumeral`&&@%
       \CALX_signalcondition{#1}{#2}{#3}{N+0.}}%
\def\CALX_ndiv_zq #1#2{%
    \ifnum#2=\xint_c_ \xint_dothis{\CALX_nsig{DivisionUndefined}{0 // 0}{}}\fi
    \xint_orthat{\CALX_nsig{DivisionByZero}{x // 0}{#1}}%
}%
\def\CALX_ndiv_zr #1#2{%
    \ifnum#2=\xint_c_ \xint_dothis{\CALX_nsig{DivisionUndefined}{0 mod 0}{}}%
        \fi
    \xint_orthat{\CALX_nsig{InvalidOperation}{x mod 0}{}}%
}%
\def\CALX_ndiv_zp #1#2{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_ndiv_zpu\fi
    \xint_orthat{\CALX_npair{\CALX_nsig{DivisionByZero}{x // 0}{#1}}%
                            {\CALX_nsig{InvalidOperation}{x mod 0}{}}}%
}%
\def\CALX_ndiv_zpu{\expandafter\CALX_ndiv_zpv\romannumeral`&&@%
    \CALX_signalcondition{DivisionUndefined}{divmod(0, 0)}{}{N+0.}\xint:}%
\def\CALX_ndiv_zpv #1\xint:{{#1}{#1}}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nq}, \csh{CALX_nqinc}, \csh{CALX_nrz},
% \csh{CALX_nrs}, \csh{CALX_nrb}, \csh{CALX_npair}}
%\begin{lverb}
% Helpers.
%- \CALX_nq <sign>{nq}{Q}: the native integer (N+0. if nq = 0).
%- \CALX_nqinc <sign>{nq}{Q}: the same for Q + 1 (addition kernel with
% the one block list 100000001!, which is not longer than Q).
%- \CALX_nrz <R'>\xint:{<zero>}{<non zero>}: selects according to R' = 0
% (R' terminated by 1;!; zero top blocks are allowed).
%- \CALX_nrs <sign>{s}{R'}: <sign> R as native integer (N+0. if R = 0).
%- \CALX_nrb N+<nR>.<R>\xint:<sR><sB>{nb}{B}: N+0. if R = 0, else
% sR R + sB B by \CALX_nadd_y.
%- \CALX_npair {<code Q>}{<code R>}: {Q}{R}, each code being expanded by
% \romannumeral0 (R first).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nq #1#2#3{%
    \ifnum#2=\xint_c_ \xint_dothis{ N+0.}\fi
    \xint_orthat{ N#1#2.#3}%
}%
\def\CALX_nqinc #1#2#3{%
    \ifnum#2=\xint_c_ \xint_dothis{ N#11.100000001!}\fi
    \xint_orthat{\expandafter\CALX_naddm\expandafter#1\the\numexpr#2%
        \expandafter.\the\numexpr\CALX_nadd_a\xint_c_ii
        100000001!1;!1;!1;!1;!\W #31;!1;!1;!1;!\W\xint:}%
}%
\def\CALX_nrz 1#1#2!{%
    \xint_gob_til_sc #1\CALX_nrz_z;%
    \ifnum#1#2=\xint_c_ \expandafter\CALX_nrz\else\expandafter\CALX_nrz_nz\fi
}%
\def\CALX_nrz_z;#1\xint:#2#3{#2}%
\def\CALX_nrz_nz #1\xint:#2#3{#3}%
\def\CALX_nrs #1#2#3%
   {\expandafter\CALX_nrs_a\expandafter#1\romannumeral0%
       \CALX_nudiv_rem{#2}{#3}\xint:}%
\def\CALX_nrs_a #1N+#2.{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_nrs_z\fi
    \xint_orthat\CALX_nrs_n #1N+#2.%
}%
\def\CALX_nrs_z #1N+#2.#3\xint:{ N+0.}%
\def\CALX_nrs_n #1N+#2.#3\xint:{ N#1#2.#3}%
\def\CALX_nrb N+#1.{%
    \ifnum#1=\xint_c_ \xint_dothis\CALX_nrb_z\fi
    \xint_orthat\CALX_nrb_n #1.%
}%
\def\CALX_nrb_z #1.#2\xint:#3#4#5#6{ N+0.}%
\def\CALX_nrb_n #1.#2\xint:#3#4#5#6%
   {\CALX_nadd_y N#4#5.#6\xint:N#3#1.#21;!1;!1;!1;!\W\xint:}%
\def\CALX_npair #1#2{\expandafter\CALX_npair_a\romannumeral0#2\xint:{#1}}%
\def\CALX_npair_a #1\xint:#2{\expandafter\CALX_npair_b\romannumeral0#2%
    \xint:{#1}}%
\def\CALX_npair_b #1\xint:{{#1}}%
%    \end{macrocode}
%\begin{lverb}
% Quotients and remainders without B after the division.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ndt_go{\CALX_nudiv\CALX_ndt_q}%
\def\CALX_ndt_q #1#2#3#4#5#6{\CALX_psign#5#6\CALX_nq{#1}{#2}}%
\def\CALX_nmt_go{\CALX_nudiv\CALX_nmt_r}%
\def\CALX_nmt_r #1#2#3#4#5#6{\CALX_nrs#5{#3}{#4}}%
\def\CALX_ndf_go{\CALX_nudiv\CALX_ndf_q}%
\def\CALX_ndf_q #1#2#3#4#5#6{%
    \if#5#6\xint_dothis{\CALX_nq+}\fi
    \xint_orthat{\CALX_nrz#4\xint:{\CALX_nq-}{\CALX_nqinc-}}{#1}{#2}%
}%
\def\CALX_nqu_go{\CALX_nudiv\CALX_nqu_q}%
\def\CALX_nqu_q #1#2#3#4#5#6{%
    \if#5+\xint_dothis{\CALX_nq#6}\fi
    \xint_orthat{\CALX_psign-#6\CALX_nqu_a#4\xint:}{#1}{#2}%
}%
\def\CALX_nqu_a #1#2\xint:{\CALX_nrz#2\xint:{\CALX_nq#1}{\CALX_nqinc#1}}%
%    \end{macrocode}
%\begin{lverb}
% Families using B after the division: the starter copies {nb}{B}.
%
% Rounding: \CALX_ndr_a gets R, doubles it (\CALX_nsum_p), \CALX_ndr_c
% compares 2R with B, \CALX_ndr_e reads the borrow state (1: 2R >= B).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ndr_go #1#2#3#4{\CALX_nudiv\CALX_ndr_q{#1}{#2}{#3}{#4}{#3}{#4}}%
\def\CALX_ndr_q #1#2#3#4#5#6#7#8{%
    \expandafter\CALX_ndr_a\romannumeral0\CALX_nudiv_rem{#3}{#4}\xint:%
    {#5}{#6}#7#8{#1}{#2}%
}%
\def\CALX_ndr_a N+#1.{%
    \ifnum#1=\xint_c_ \xint_dothis\CALX_ndr_a_z\fi
    \xint_orthat\CALX_ndr_a_n #1.%
}%
\def\CALX_ndr_a_z #1.#2\xint:#3#4{\CALX_ndr_dn}%
\def\CALX_ndr_a_n #1.#2\xint:#3#4{%
    \expandafter\CALX_ndr_c
    \romannumeral0\expandafter\CALX_naddm\expandafter+%
    \the\numexpr#1\expandafter.\the\numexpr\CALX_nadd_a\xint_c_ii
    #21;!1;!1;!1;!\W#21;!1;!1;!1;!\W\xint:\xint:{#3}{#4}%
}%
\def\CALX_ndr_c N+#1.#2\xint:#3#4{%
    \ifnum#1>#3 \xint_dothis\CALX_ndr_up\fi
    \ifnum#1<#3 \xint_dothis\CALX_ndr_dn\fi
    \xint_orthat{\expandafter\CALX_ndr_e\the\numexpr
                 \CALX_nsub_a\xint_c_i #41;!1;!1;!1;!\W #21;!1;!1;!1;!\W}%
}%
\def\CALX_ndr_e #11;!#2%
   {\if#21\expandafter\CALX_ndr_up\else\expandafter\CALX_ndr_dn\fi}%
\def\CALX_ndr_up #1#2{\CALX_psign#1#2\CALX_nqinc}%
\def\CALX_ndr_dn #1#2{\CALX_psign#1#2\CALX_nq}%
\def\CALX_nmd_go #1#2#3#4{\CALX_nudiv\CALX_nmd_r{#1}{#2}{#3}{#4}{#3}{#4}}%
\def\CALX_nmd_r #1#2#3#4#5#6#7#8{%
    \if#7#8\xint_dothis{\CALX_nrs#7{#3}{#4}}\fi
    \xint_orthat{\expandafter\CALX_nrb\romannumeral0\CALX_nudiv_rem{#3}{#4}%
                 \xint:#7#8{#5}{#6}}%
}%
\def\CALX_nre_go #1#2#3#4{\CALX_nudiv\CALX_nre_r{#1}{#2}{#3}{#4}{#3}{#4}}%
\def\CALX_nre_r #1#2#3#4#5#6#7#8{%
    \if#7+\xint_dothis{\CALX_nudiv_rem{#3}{#4}}\fi
    \xint_orthat{\expandafter\CALX_nrb\romannumeral0\CALX_nudiv_rem{#3}{#4}%
                 \xint:-+{#5}{#6}}%
}%
\def\CALX_ndn_go #1#2#3#4{\CALX_nudiv\CALX_ndn_r{#1}{#2}{#3}{#4}{#3}{#4}}%
\def\CALX_ndn_r #1#2#3#4#5#6#7#8{%
    \if#7+\xint_dothis{\CALX_npair{\CALX_nq#8{#1}{#2}}{%
        \CALX_nudiv_rem{#3}{#4}}}\fi
    \xint_orthat{\expandafter\CALX_ndn_a\romannumeral0\CALX_nudiv_rem{#3}{#4}%
                 \xint:{#5}{#6}#8{#1}{#2}}%
}%
\def\CALX_ndn_a N+#1.{%
    \ifnum#1=\xint_c_ \xint_dothis\CALX_ndn_a_z\fi
    \xint_orthat\CALX_ndn_a_n #1.%
}%
\def\CALX_ndn_a_z #1.#2\xint:#3#4#5#6#7%
   {\CALX_npair{\CALX_psign-#5\CALX_nq{#6}{#7}}{ N+0.}}%
\def\CALX_ndn_a_n #1.#2\xint:#3#4#5#6#7%
   {\CALX_npair{\CALX_psign-#5\CALX_nqinc{#6}{#7}}%
        {\CALX_nadd_y N+#3.#4\xint:N-#1.#21;!1;!1;!1;!\W\xint:}}%
\def\CALX_ndm_go #1#2#3#4{\CALX_nudiv\CALX_ndm_r{#1}{#2}{#3}{#4}{#3}{#4}}%
\def\CALX_ndm_r #1#2#3#4#5#6#7#8{%
    \if#7#8\xint_dothis{\CALX_npair{\CALX_nq+{#1}{#2}}{\CALX_nrs#7{#3}{#4}}}%
        \fi
    \xint_orthat{\expandafter\CALX_ndm_a\romannumeral0\CALX_nudiv_rem{#3}{#4}%
                 \xint:{#5}{#6}#7#8{#1}{#2}}%
}%
\def\CALX_ndm_a N+#1.{%
    \ifnum#1=\xint_c_ \xint_dothis\CALX_ndm_a_z\fi
    \xint_orthat\CALX_ndm_a_n #1.%
}%
\def\CALX_ndm_a_z #1.#2\xint:#3#4#5#6#7#8%
   {\CALX_npair{\CALX_nq-{#7}{#8}}{ N+0.}}%
\def\CALX_ndm_a_n #1.#2\xint:#3#4#5#6#7#8%
   {\CALX_npair{\CALX_nqinc-{#7}{#8}}%
        {\CALX_nadd_y N#6#3.#4\xint:N#5#1.#21;!1;!1;!1;!\W\xint:}}%
%    \end{macrocode}
% \subsection{Already expanded native arithmetic}
%\begin{lverb}
% Inputs to the following interfaces are two expanded native integers,
% both with N tags.  No argument expansion, tag dispatch, or conversion
% is needed.  Each kernel appends its own block terminators.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_naddready #1#2{\CALX_nadd_y #1\xint:#21;!1;!1;!1;!\W\xint:}%
\def\CALX_nsubready #1#2{\CALX_nsub_y #2\xint:#11;!1;!1;!1;!\W\xint:}%
\def\CALX_nmulready #1#2{\CALX_nmul_y #1\xint:#21;!\xint:}%
%    \end{macrocode}
% \subsection{Native power}
%\begin{lverb}
% Syntax (use with \romannumeral0; k a \numexpr expression, k >= 0; X
% f-expanded native integer, not I):
%(
%  \CALX_npow{k}{X}  -> <space>N<s><n>.<blocks>    (X^k; X^0 = 1)
%)
% Binary powering, least significant bit of k first. The even low bits of
% k only square X (\CALX_npow_e); at the first odd bit the accumulator is
% the current base itself (no multiplication by 1), then \CALX_npow_l
% squares the base and multiplies it into the accumulator for each further
% bit, the last squaring being skipped. The new base and accumulator are
% computed inside one \expanded and handed over as braced groups.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_npow #1#2%
   {\expandafter\CALX_npow_a\the\numexpr#1\expandafter.%
    \romannumeral`&&@#2\xint:}%
\def\CALX_npow_a #1.#2\xint:%
   {\ifnum#1=\xint_c_ \xint_dothis{ N+1.100000001!}\fi
    \xint_orthat{\CALX_npow_e #1.{#2}}}%
\def\CALX_npow_e #1.#2%
{%
    \ifnum#1=\xint_c_i \xint_dothis{ #2}\fi
    \ifodd#1 \xint_dothis{\expandafter\CALX_npow_l
      \the\numexpr(#1-\xint_c_i)/\xint_c_ii\expandafter.%
      \expandafter{\romannumeral0\CALX_nmul{#2}{#2}}{#2}}\fi
    \xint_orthat{\expandafter\CALX_npow_e\the\numexpr#1/\xint_c_ii%
      \expandafter.\expandafter{\romannumeral0\CALX_nmul{#2}{#2}}}%
}%
\def\CALX_npow_l #1.#2#3%
{%
    \ifnum#1=\xint_c_i \xint_dothis{\CALX_nmul{#3}{#2}}\fi
    \ifodd#1 \xint_dothis{\expandafter\CALX_npow_l
      \the\numexpr(#1-\xint_c_i)/\xint_c_ii\expandafter.%
      \expanded{{\romannumeral0\CALX_nmul{#2}{#2}}%
                {\romannumeral0\CALX_nmul{#3}{#2}}}}\fi
    \xint_orthat{\expandafter\CALX_npow_l\the\numexpr#1/\xint_c_ii%
      \expandafter.\expandafter{\romannumeral0\CALX_nmul{#2}{#2}}{#3}}%
}%
%    \end{macrocode}
% \subsection{Native partial factorial and factorial}
%\begin{lverb}
% Syntax (use with \romannumeral0; a, b \numexpr expressions, 0 <= a < b <
% 10^8, k = 1 .. 10^4, not checked):
%(
%  \CALX_npfac{a}{b}  -> <space>N+<n>.<blocks>    ((a+1)(a+2)...b)
%:  \CALX_nfac{k}      -> <space>N+<n>.<blocks>    (k! = pfac(0, k))
%)
% The accumulator is a block list, least significant first, terminated by
% 1;!; each step multiplies it by one block y < 10^8, a product of four
% (factors <= 98), three (<= 463), two (<= 9999) or one consecutive
% integers, with \CALX_smallmul, inside one \numexpr chain which puts the
% new list in place. The last step (one to four factors, \CALX_pfac_end_..)
% hands the list to \CALX_nnorm (count, header): the kernel never produces
% a zero top block.
%\end{lverb}
%\begin{lverb}
% Moved here from xint.sty with release 1.2 (to be usable by \bnumexpr).
%
% Partially rewritten with release 1.2 to benefit from the inner format of the
% 1.2 multiplication.
% 
% With current default settings of the etex memory and a.t.t.o.w (11/2015) the
% maximal possible computation is 5971! (which has 19956 digits).
%
%
%
% Note (end november 2015): I also tried out a quickly written recursive
% (binary split) implementation
%
%( \catcode`_ 11
%: \catcode`^ 11
%: \long\def\xint_firstofthree  #1#2#3{#1}$%
%: \long\def\xint_secondofthree #1#2#3{#2}$%
%: \long\def\xint_thirdofthree  #1#2#3{#3}$%
%: $% quickly written factorial using binary split recursive method
%: \def\tFac   {\romannumeral-`0\tfac }$%
%: \def\tfac #1{\expandafter\XINT_mul_out
%:              \romannumeral-`0\ufac {1}{#1}1\R!1\R!1\R!1\R!1\R!1\R!1\R!1\R!\W}$%
%: \def\ufac #1#2{\ifcase\numexpr#2-#1\relax
%:                  \expandafter\xint_firstofthree
%:                \or
%:                  \expandafter\xint_secondofthree
%:                \else
%:                  \expandafter\xint_thirdofthree
%:                \fi
%:                {\the\numexpr\xint_c_e_viii+#1!1;!}$%
%:                {\the\numexpr\xint_c_e_viii+#1*#2!1;!}$%
%:                {\expandafter\vfac\the\numexpr (#1+#2)/\xint_c_ii.#1.#2.}$%
%: }$%
%: \def\vfac #1.#2.#3.$%
%: {$%
%:     \expandafter
%:     \wfac\expandafter
%:         {\romannumeral-`0\expandafter
%:          \ufac\expandafter{\the\numexpr #1+\xint_c_i}{#3}}$%
%:         {\ufac {#2}{#1}}$%
%: }$%
%: \def\wfac #1#2{\expandafter\zfac\romannumeral-`0#2\W #1}$%
%: \def\zfac {\the\numexpr\XINT_mul_loop 100000000!1;!\W }$% core multiplication...
%: \catcode`_ 8
%: \catcode`^ 7
%)
% and I was quite surprised that it was only about 1.6x--2x slower in the range
% N=200 to 2000 than the \xintiiFac here which attempts to be smarter...
%
% Note (2017, 1.2l): I found out some code comment of mine that the code here
% should be more in the style of \xintiiBinomial, but I left matters
% untouched.
%
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nfac #1%
   {\expandafter\CALX_pfac_b\expandafter1\expandafter.\the\numexpr#1.%
    100000001!1;!}%
\def\CALX_npfac #1#2%
   {\expandafter\CALX_pfac_b\the\numexpr\xint_c_i+#1\expandafter.%
    \the\numexpr#2.100000001!1;!}%
\def\CALX_pfac_b #1.%
{%
    \ifnum #1>9999 \xint_dothis\CALX_pfac_vbigloop \fi
    \ifnum #1>463  \xint_dothis\CALX_pfac_bigloop   \fi
    \ifnum #1>98   \xint_dothis\CALX_pfac_medloop   \fi
                   \xint_orthat\CALX_pfac_smallloop #1.%
}%
\def\CALX_pfac_smallloop #1.#2.%
{%
    \ifcase\numexpr #2-#1\relax
        \expandafter\CALX_pfac_end_
    \or \expandafter\CALX_pfac_end_i
    \or \expandafter\CALX_pfac_end_ii
    \or \expandafter\CALX_pfac_end_iii
    \else\expandafter\CALX_pfac_smallloop_a
    \fi #1.#2.%
}%
\def\CALX_pfac_smallloop_a #1.#2.%
{%
    \expandafter\CALX_pfac_smallloop_b
    \the\numexpr #1+\xint_c_iv\expandafter.%
    \the\numexpr #2\expandafter.%
    \the\numexpr\expandafter\CALX_smallmul
    \the\numexpr \xint_c_e_viii+#1*(#1+\xint_c_i)*(#1+\xint_c_ii)%
        *(#1+\xint_c_iii)!%
}%
\def\CALX_pfac_smallloop_b #1.%
{%
    \ifnum #1>98  \expandafter\CALX_pfac_medloop   \else
                  \expandafter\CALX_pfac_smallloop \fi #1.%
}%
\def\CALX_pfac_medloop #1.#2.%
{%
    \ifcase\numexpr #2-#1\relax
        \expandafter\CALX_pfac_end_
    \or \expandafter\CALX_pfac_end_i
    \or \expandafter\CALX_pfac_end_ii
    \else\expandafter\CALX_pfac_medloop_a
    \fi #1.#2.%
}%
\def\CALX_pfac_medloop_a #1.#2.%
{%
    \expandafter\CALX_pfac_medloop_b
    \the\numexpr #1+\xint_c_iii\expandafter.%
    \the\numexpr #2\expandafter.%
    \the\numexpr\expandafter\CALX_smallmul
    \the\numexpr \xint_c_e_viii+#1*(#1+\xint_c_i)*(#1+\xint_c_ii)!%
}%
\def\CALX_pfac_medloop_b #1.%
{%
    \ifnum #1>463 \expandafter\CALX_pfac_bigloop   \else
                  \expandafter\CALX_pfac_medloop   \fi #1.%
}%
\def\CALX_pfac_bigloop #1.#2.%
{%
    \ifcase\numexpr #2-#1\relax
        \expandafter\CALX_pfac_end_
    \or \expandafter\CALX_pfac_end_i
    \else\expandafter\CALX_pfac_bigloop_a
    \fi #1.#2.%
}%
\def\CALX_pfac_bigloop_a #1.#2.%
{%
    \expandafter\CALX_pfac_bigloop_b
    \the\numexpr #1+\xint_c_ii\expandafter.%
    \the\numexpr #2\expandafter.%
    \the\numexpr\expandafter
    \CALX_smallmul\the\numexpr \xint_c_e_viii+#1*(#1+\xint_c_i)!%
}%
\def\CALX_pfac_bigloop_b #1.%
{%
    \ifnum #1>9999 \expandafter\CALX_pfac_vbigloop  \else
                   \expandafter\CALX_pfac_bigloop   \fi #1.%
}%
\def\CALX_pfac_vbigloop #1.#2.%
{%
    \ifnum #2=#1
         \expandafter\CALX_pfac_end_
    \else\expandafter\CALX_pfac_vbigloop_a
    \fi #1.#2.%
}%
\def\CALX_pfac_vbigloop_a #1.#2.%
{%
    \expandafter\CALX_pfac_vbigloop
    \the\numexpr #1+\xint_c_i\expandafter.%
    \the\numexpr #2\expandafter.%
    \the\numexpr\expandafter\CALX_smallmul\the\numexpr\xint_c_e_viii+#1!%
}%
\def\CALX_pfac_end_iii #1.#2.%
{%
    \expandafter\CALX_nnorm\expandafter+%
    \the\numexpr\expandafter\CALX_smallmul
    \the\numexpr \xint_c_e_viii+#1*(#1+\xint_c_i)*(#1+\xint_c_ii)%
        *(#1+\xint_c_iii)!%
}%
\def\CALX_pfac_end_ii #1.#2.%
{%
    \expandafter\CALX_nnorm\expandafter+%
    \the\numexpr\expandafter\CALX_smallmul
    \the\numexpr \xint_c_e_viii+#1*(#1+\xint_c_i)*(#1+\xint_c_ii)!%
}%
\def\CALX_pfac_end_i #1.#2.%
{%
    \expandafter\CALX_nnorm\expandafter+%
    \the\numexpr\expandafter\CALX_smallmul
    \the\numexpr \xint_c_e_viii+#1*(#1+\xint_c_i)!%
}%
\def\CALX_pfac_end_ #1.#2.%
{%
    \expandafter\CALX_nnorm\expandafter+%
    \the\numexpr\expandafter\CALX_smallmul\the\numexpr \xint_c_e_viii+#1!%
}%
\catcode`N=11 \catcode`I=11
%    \end{macrocode}
% \subsection{\csh{XINT_split_fromleft}}
%\begin{lverb}
% Moved verbatim from xint.sty at 2.0a1 (used there by \xintDecSplit and
% others, and by the float printer core \XINT_pfloat_P of calxfp.sty).
%\end{lverb}
%    \begin{macrocode}
\def\XINT_split_fromleft
    {\expandafter\XINT_split_fromleft_a\the\numexpr\xint_c_viii-}%
\def\XINT_split_fromleft_a #1%
{%
    \xint_UDsignfork
      #1\XINT_split_fromleft_b
       -{\XINT_split_fromleft_end_a #1}%
    \krof
}%
\def\XINT_split_fromleft_b #1.#2#3#4#5#6#7#8#9%
{%
    \expandafter\XINT_split_fromleft_clean
    \the\numexpr1#2#3#4#5#6#7#8#9\expandafter
    \XINT_split_fromleft_a\the\numexpr\xint_c_viii-#1.%
}%
\def\XINT_split_fromleft_end_a #1.%
{%
    \expandafter\XINT_split_fromleft_clean
    \the\numexpr1\csname XINT_split_fromleft_end#1\endcsname
}%
\def\XINT_split_fromleft_clean 1{ }%
\expandafter\def\csname XINT_split_fromleft_end7\endcsname #1%
   {#1\XINT_split_fromleft_end_b}%
\expandafter\def\csname XINT_split_fromleft_end6\endcsname #1#2%
   {#1#2\XINT_split_fromleft_end_b}%
\expandafter\def\csname XINT_split_fromleft_end5\endcsname #1#2#3%
   {#1#2#3\XINT_split_fromleft_end_b}%
\expandafter\def\csname XINT_split_fromleft_end4\endcsname #1#2#3#4%
   {#1#2#3#4\XINT_split_fromleft_end_b}%
\expandafter\def\csname XINT_split_fromleft_end3\endcsname #1#2#3#4#5%
   {#1#2#3#4#5\XINT_split_fromleft_end_b}%
\expandafter\def\csname XINT_split_fromleft_end2\endcsname #1#2#3#4#5#6%
   {#1#2#3#4#5#6\XINT_split_fromleft_end_b}%
\expandafter\def\csname XINT_split_fromleft_end1\endcsname #1#2#3#4#5#6#7%
   {#1#2#3#4#5#6#7\XINT_split_fromleft_end_b}%
\expandafter\def\csname XINT_split_fromleft_end0\endcsname #1#2#3#4#5#6#7#8%
   {#1#2#3#4#5#6#7#8\XINT_split_fromleft_end_b}%
\def\XINT_split_fromleft_end_b #1\xint_bye#2\xint_bye.{.#1}% puis .
\XINTrestorecatcodesendinput%
%    \end{macrocode}
% \StoreCodelineNo {calxcore}
% \cleardoublepage\let\calxcorenameUp\undefined
%\gardesactifs
%\let</calxcore>\relax
%\let<*calxint>\gardesinactifs
%</calxcore>^^A---------------------------------------------------
%<*calxint>^^A-------------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1) ; fill-paragraph-function: nil; -*-
% \clearpage\csname calxintnameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section{Package \calxintnameimp implementation}
% \RaisedLabel{sec:calxintimp}
% \addedcalx{2.0a1}
%
% \localtableofcontents
%
%\begin{lverb}
% calx: sister of xint.sty. It loads calxcore.sty and adds the native
% integer square root. The xint macros it uses are copied unmodified and
% renamed CALX_; xint.sty is not modified.
%\end{lverb}
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
% The code of this subsection is copied over from the xint packages, with
% the package names changed.
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode64=11   % @
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \def\empty{}\def\space{ }\newlinechar10
  \def\z{\endgroup}%
  \expandafter\let\expandafter\x\csname ver@calxint.sty\endcsname
  \expandafter\let\expandafter\w\csname ver@calxcore.sty\endcsname
  \expandafter\ifx\csname numexpr\endcsname\relax
    \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax
      \immediate\write128{^^JPackage calxint Warning:^^J%
                          \space\space\space\space
                          \numexpr not available, aborting input.^^J}%
    \else
      \PackageWarningNoLine{calxint}{\numexpr not available, aborting input}%
    \fi
    \def\z{\endgroup\endinput}%
  \else
    \ifx\x\relax   % plain-TeX, first loading of calxint.sty
      \ifx\w\relax % but calxcore.sty not yet loaded.
         \def\z{\endgroup\input calxcore.sty\relax}%
      \fi
    \else
      \ifx\x\empty % LaTeX, first loading,
      % variable is initialized, but \ProvidesPackage not yet seen
          \ifx\w\relax % calxcore.sty not yet loaded.
            \def\z{\endgroup\RequirePackage{calxcore}}%
          \fi
      \else
        \def\z{\endgroup\endinput}% calxint already loaded.
      \fi
    \fi
  \fi
\z%
\XINTsetupcatcodes% defined in xintkernel.sty
%    \end{macrocode}
% \subsection{Package identification}
%    \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{calxint}%
  [2026/11/01 v2.0a1 Expandable operations on big integers (JFB)]%
%    \end{macrocode}
% \subsection{\csh{xintBool}, \csh{xintToggle}}
%\begin{lverb}
% 1.09c
%\end{lverb}
%    \begin{macrocode}
\def\xintBool #1{\romannumeral`&&@%
                 \csname if#1\endcsname\expandafter1\else\expandafter0\fi }%
\def\xintToggle #1{\romannumeral`&&@\iftoggle{#1}{1}{0}}%
%    \end{macrocode}
% \subsection{Integer square root: small and medium sizes}
% \subsubsection{\csh{CALX_sqrt_start}}
%\begin{lverb}
% xint's square root start and its small and medium paths (inputs of at
% most 16 digits), renamed. It is only called with at most 16 digits
% (calx, and xint's \xintiiSquareRoot since s58).
%
% Output: {N}{D} with D = N^2 - X > 0, N smallest (N = isqrt(X) + 1).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_sqrt_start #1.%
{%
    \ifnum #1<\xint_c_x\xint_dothis\CALX_sqrt_small_a\fi
    \xint_orthat\CALX_sqrt_big_a #1.%
}%
\def\CALX_sqrt_small_a #1.{\CALX_sqrt_a #1.\CALX_sqrt_small_d }%
\def\CALX_sqrt_big_a   #1.{\CALX_sqrt_a #1.\CALX_sqrt_big_d   }%
\def\CALX_sqrt_a #1.%
{%
   \ifodd #1
     \expandafter\CALX_sqrt_bO
   \else
     \expandafter\CALX_sqrt_bE
   \fi
   #1.%
}%
\def\CALX_sqrt_bE #1.#2#3#4%
{%
    \CALX_sqrt_c {#3#4}#2{#1}#3#4%
}%
\def\CALX_sqrt_bO #1.#2#3%
{%
    \CALX_sqrt_c #3#2{#1}#3%
}%
\def\CALX_sqrt_c #1#2%
{%
    \expandafter #2%
    \the\numexpr \ifnum #1>\xint_c_ii
                 \ifnum #1>\xint_c_vi
                 \ifnum #1>12 \ifnum #1>20 \ifnum #1>30
                 \ifnum #1>42 \ifnum #1>56 \ifnum #1>72
                 \ifnum #1>90
      10\else 9\fi \else 8\fi \else 7\fi \else 6\fi \else 5\fi
        \else 4\fi \else 3\fi \else 2\fi \else 1\fi .%
}%
\def\CALX_sqrt_small_d #1.#2%
{%
   \expandafter\CALX_sqrt_small_e
   \the\numexpr #1\ifcase \numexpr #2/\xint_c_ii-\xint_c_i\relax
                   \or 0\or 00\or 000\or 0000\fi .%
}%
\def\CALX_sqrt_small_e #1.#2.%
{%
   \expandafter\CALX_sqrt_small_ea\the\numexpr #1*#1-#2.#1.%
}%
\def\CALX_sqrt_small_ea #1%
{%
    \if0#1\xint_dothis\CALX_sqrt_small_ez\fi
    \if-#1\xint_dothis\CALX_sqrt_small_eb\fi
    \xint_orthat\CALX_sqrt_small_f #1%
}%
\def\CALX_sqrt_small_ez 0.#1.{\expandafter{\the\numexpr#1+\xint_c_i
         \expandafter}\expandafter{\the\numexpr #1*\xint_c_ii+\xint_c_i}}%
\def\CALX_sqrt_small_eb -#1.#2.%
{%
    \expandafter\CALX_sqrt_small_ec \the\numexpr
    (#1-\xint_c_i+#2)/(\xint_c_ii*#2).#1.#2.%
}%
\def\CALX_sqrt_small_ec #1.#2.#3.%
{%
    \expandafter\CALX_sqrt_small_f \the\numexpr
      -#2+\xint_c_ii*#3*#1+#1*#1\expandafter.\the\numexpr #3+#1.%
}%
\def\CALX_sqrt_small_f #1.#2.%
{%
   \expandafter\CALX_sqrt_small_g
   \the\numexpr (#1+#2)/(\xint_c_ii*#2)-\xint_c_i.#1.#2.%
}%
\def\CALX_sqrt_small_g #1#2.%
{%
    \if 0#1%
       \expandafter\CALX_sqrt_small_end
    \else
       \expandafter\CALX_sqrt_small_h
    \fi
    #1#2.%
}%
\def\CALX_sqrt_small_h #1.#2.#3.%
{%
    \expandafter\CALX_sqrt_small_f
    \the\numexpr #2-\xint_c_ii*#1*#3+#1*#1\expandafter.%
    \the\numexpr #3-#1.%
}%
\def\CALX_sqrt_small_end #1.#2.#3.{{#3}{#2}}%
\def\CALX_sqrt_big_d #1.#2%
{%
   \ifodd #2 \xint_dothis{\expandafter\CALX_sqrt_big_eO}\fi
   \xint_orthat{\expandafter\CALX_sqrt_big_eE}%
   \the\numexpr (#2-\xint_c_i)/\xint_c_ii.#1;%
}%
\def\CALX_sqrt_big_eE  #1;#2#3#4#5#6#7#8#9%
{%
    \CALX_sqrt_big_eE_a #1;{#2#3#4#5#6#7#8#9}%
}%
\def\CALX_sqrt_big_eE_a #1.#2;#3%
{%
    \expandafter\CALX_sqrt_bigormed_f
    \romannumeral0\CALX_sqrt_small_e #2000.#3.#1;%
}%
\def\CALX_sqrt_big_eO #1;#2#3#4#5#6#7#8#9%
{%
    \CALX_sqrt_big_eO_a #1;{#2#3#4#5#6#7#8#9}%
}%
\def\CALX_sqrt_big_eO_a #1.#2;#3#4%
{%
    \expandafter\CALX_sqrt_bigormed_f
    \romannumeral0\CALX_sqrt_small_e #20000.#3#4.#1;%
}%
%    \end{macrocode}
%\begin{lverb}
% calx (s58): \CALX_sqrt_start is only ever called with at most 16 digits
% (calxint, xint's \xintiiSquareRoot), hence here k = #3 <= 8: the
% medium path only. xint's big branch (\XINT_sqrt_big_f, more than 16
% digits) is deleted: xint and xintfrac use the native square roots.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_sqrt_bigormed_f #1#2#3;%
   {\csname CALX_sqrt_med_f#3\endcsname #1.#2.#3;}%
\expandafter\def\csname CALX_sqrt_med_f5\endcsname   {\CALX_sqrt_med_fa .}%
\expandafter\def\csname CALX_sqrt_med_f6\endcsname  {\CALX_sqrt_med_fa 0.}%
\expandafter\def\csname CALX_sqrt_med_f7\endcsname {\CALX_sqrt_med_fa 00.}%
\expandafter\def\csname CALX_sqrt_med_f8\endcsname{\CALX_sqrt_med_fa 000.}%
\def\CALX_sqrt_med_fa #1.#2.#3.#4;%
{%
    \expandafter\CALX_sqrt_med_fb
    \the\numexpr (#30#1-5#1)/(\xint_c_ii*#2).#1.#2.#3.%
}%
\def\CALX_sqrt_med_fb #1.#2.#3.#4.#5.%
{%
    \expandafter\CALX_sqrt_small_ea
    \the\numexpr (#40#2-\xint_c_ii*#3*#1)*10#2+(#1*#1-#5)\expandafter.%
    \the\numexpr #30#2-#1.%
}%
%    \end{macrocode}
% \subsection{Native integer square root}
%\begin{lverb}
% Attention N and I are set to catcode 12 from here on.
% IN PARTICULAR DO NOT USE
% ANY \XINT... prefixed macro names with I or N of catcode 12!
%\end{lverb}
%    \begin{macrocode}
\catcode`N=12 \catcode`I=12
%    \end{macrocode}
% \subsubsection{\csh{CALX_nsqrt_two}}
%\begin{lverb}
% \CALX_nsqrt_two <cont>{h}{l}: h, l eight digit strings (l with leading
% zeros), X = h 10^8 + l, h >= 10^7. Expands to <cont>{s}{r} with
% s = isqrt(X), r = X - s^2 (explicit integers, r <= 2s). Uses (5):
% s = N - 1, r = 2N - 1 - D.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_two #1#2#3%
   {\expandafter\CALX_nsqrt_two_a\romannumeral0\CALX_sqrt_start 16.#2#3.#1}%
\def\CALX_nsqrt_two_a #1#2#3%
   {\expandafter#3\expandafter{\the\numexpr#1-\xint_c_i\expandafter}%
    \expandafter{\the\numexpr\xint_c_ii*#1-\xint_c_i-#2}}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nsqrt_iv}}
%\begin{lverb}
% \CALX_nsqrt_iv <cont>{a3}{a2}{a1}{a0}: eight digit strings (leading zeros
% allowed except a3 >= 25000000), X = a3 B^3 + a2 B^2 + a1 B + a0, B=10^8.
% Expands to <cont>{S}{T}{H}{L}: isqrt(X) = S B + T with S explicit and T
% as a native block 1dddddddd, remainder X - isqrt(X)^2 = H B + L, H, L
% explicit, 0 <= L < B, H <= 2 10^8.
%
% One Zimmermann step on the two block square root (s',r') of a3 B + a2:
% q = floor((r' B + a1)/(2s')), estimate q0 = round(r' B/(2s')) (eTeX
% scaled product), exact u = r' B + a1 - 2s' q0 in 10^4 halves (every
% intermediate < 2^31), one +-1 correction; then r = u B + a0 - q^2 and
% the final correction r < 0: r += 2s - 1, s -= 1. q = B occurs only with
% r' = 2s' and then always gets corrected.
%
% Floor of x/10^4 for x >= 0 is (x+5000)/10000-1 in \numexpr.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_iv #1#2#3#4#5{\CALX_nsqrt_two%
    \CALX_nsqrt_iv_a{#2}{#3}{#4}{#5}#1}%
\def\CALX_nsqrt_iv_a #1#2%
{%
    \expandafter\CALX_nsqrt_iv_b
    \the\numexpr#2*\xint_c_e_viii/(\xint_c_ii*#1).{#1}{#2}%
}%
\def\CALX_nsqrt_iv_b #1.#2%
{%
    \expandafter\CALX_nsqrt_iv_c
    \the\numexpr(#1+5000)/\xint_c_e_iv-\xint_c_i\expandafter.%
    \the\numexpr(\xint_c_ii*#2+5000)/\xint_c_e_iv-\xint_c_i.#1.{#2}%
}%
%    \end{macrocode}
%\begin{lverb}
% #1=qh, #2=th, #3=q0, #4=s', #5=r', #6=a1. With t=2s', ql=q0-qh 10^4,
% tl=t-th 10^4: u = ((r'-th qh) 10^4 - (th ql + tl qh)) 10^4 - tl ql + a1.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_iv_c #1.#2.#3.#4#5#6%
{%
    \expandafter\CALX_nsqrt_iv_d
    \the\numexpr((#5-#2*#1)*\xint_c_e_iv
       -(#2*(#3-#1*\xint_c_e_iv)+(\xint_c_ii*#4-#2*\xint_c_e_iv)*#1))*%
           \xint_c_e_iv
       -(\xint_c_ii*#4-#2*\xint_c_e_iv)*(#3-#1*\xint_c_e_iv)+#6.#3.{#4}%
}%
\def\CALX_nsqrt_iv_d #1.#2.#3%
{%
    \expandafter\CALX_nsqrt_iv_e\the\numexpr#1%
      \ifnum#1<\xint_c_ +\xint_c_ii*#3\else
      \ifnum#1<\numexpr\xint_c_ii*#3\relax\else-\xint_c_ii*#3\fi\fi
    \expandafter.\the\numexpr#2%
      \ifnum#1<\xint_c_ -\xint_c_i\else
      \ifnum#1<\numexpr\xint_c_ii*#3\relax\else+\xint_c_i\fi\fi
    .{#3}%
}%
%    \end{macrocode}
%\begin{lverb}
% #1=u, #2=q (0 <= q <= B), #3=s', #4=a0. With qh, ql the 10^4 halves of
% q and c = 2 qh ql = ch 10^4 + cl: r = (u - qh^2 - ch) B
% + (a0 - ql^2 - cl 10^4); the low part is > -2 10^8.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_iv_e #1.#2.%
{%
    \expandafter\CALX_nsqrt_iv_f
    \the\numexpr(#2+5000)/\xint_c_e_iv-\xint_c_i.#2.#1.%
}%
\def\CALX_nsqrt_iv_f #1.#2.%
{%
    \expandafter\CALX_nsqrt_iv_g
    \the\numexpr\xint_c_ii*#1*(#2-#1*\xint_c_e_iv).#1.#2.%
}%
\def\CALX_nsqrt_iv_g #1.%
{%
    \expandafter\CALX_nsqrt_iv_h\the\numexpr(#1+5000)/\xint_c_e_iv-%
        \xint_c_i.#1.%
}%
\def\CALX_nsqrt_iv_h #1.#2.#3.#4.#5.#6#7%
{%
    \expandafter\CALX_nsqrt_iv_i
    \the\numexpr#7-(#4-#3*\xint_c_e_iv)*(#4-#3*\xint_c_e_iv)
                -(#2-#1*\xint_c_e_iv)*\xint_c_e_iv\expandafter.%
    \the\numexpr#5-#3*#3-#1.#4.{#6}%
}%
%    \end{macrocode}
%\begin{lverb}
% #1=low part x in (-2 10^8, 10^8), #2=high part, #3=q, #4=s'.
% Borrow k = floor(x/B) = (x+250000000)/100000000-3.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_iv_i #1.%
{%
    \expandafter\CALX_nsqrt_iv_j\the\numexpr(#1+250000000)/\xint_c_e_viii-%
        \xint_c_iii.#1.%
}%
\def\CALX_nsqrt_iv_j #1.#2.#3.%
{%
    \expandafter\CALX_nsqrt_iv_k
    \the\numexpr#3+#1\expandafter.\the\numexpr#2-#1*\xint_c_e_viii.%
}%
%    \end{macrocode}
%\begin{lverb}
% #1=H, #2=L, #3=q, #4=s', #5=cont. If H < 0: H += 2s', L += 2q - 1
% (L in [-1, 3 10^8)), carry (L+150000000)/100000000-2, q -= 1 with a
% borrow from s' if q was 0.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_iv_k #1.#2.#3.#4#5%
{%
    \ifnum#1<\xint_c_
      \xint_dothis{\expandafter\CALX_nsqrt_iv_l
         \the\numexpr#2+\xint_c_ii*#3-\xint_c_i\expandafter.%
         \the\numexpr#1+\xint_c_ii*#4\expandafter.%
         \the\numexpr#3-\xint_c_i.{#4}#5}\fi
    \xint_orthat{\expandafter#5\expandafter{\the\numexpr#4\expandafter}%
         \expandafter{\the\numexpr#3+\xint_c_e_viii}{#1}{#2}}%
}%
\def\CALX_nsqrt_iv_l #1.%
{%
    \expandafter\CALX_nsqrt_iv_m\the\numexpr(#1+150000000)/\xint_c_e_viii-%
        \xint_c_ii.#1.%
}%
\def\CALX_nsqrt_iv_m #1.#2.#3.#4.%
{%
    \expandafter\CALX_nsqrt_iv_n
    \the\numexpr#3+#1\expandafter.\the\numexpr#2-#1*\xint_c_e_viii.#4.%
}%
\def\CALX_nsqrt_iv_n #1.#2.#3.#4#5%
{%
    \expandafter#5\expandafter
    {\the\numexpr#4\ifnum#3<\xint_c_ -\xint_c_i\fi\expandafter}\expandafter
    {\the\numexpr\ifnum#3<\xint_c_ 199999999\else#3+\xint_c_e_viii\fi}%
    {#1}{#2}%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nsqrt_vi}}
%\begin{lverb}
% \CALX_nsqrt_vi <cont>{a5}{a4}{a3}{a2}{a1}{a0}: eight digit strings,
% a5 >= 25000000. Expands to <cont>{S1}{T}{Q}{R2}{R1}{R0}: isqrt(X) =
% S1 B^2 + T B + Q (T, Q native blocks 1dddddddd), remainder
% R2 B^2 + R1 B + R0 (explicit, 0 <= R1, R0 < B).
%
% One Zimmermann step with b = B on the four block root s' = S1 B + T
% (remainder r' = H B + L) of the top four blocks: t = 2s' = tH B + tL,
% 10^8 <= tH < 2 10^8; q = floor((r' B + a1)/t) is estimated by
% q0 = round(H B/tH) (scaled), q - q0 in [-2, 1]; u = r' B + a1 - q0 t
% is computed exactly as uH B + uL from 10^4 halves (qh, ql, tHh, tHl,
% tLh, tLl): with m0 = a1 - ql tLl, m1 = -(qh tLl + ql tLh),
% Z = ((H - qh tHh) 10^4 - (qh tHl + ql tHh)) 10^4 + L - (qh tLh + ql tHl),
% c0 = floor(m0/10^4), c1 = floor((m1+c0)/10^4): uH = Z + c1,
% uL = (m1 + c0 - c1 10^4) 10^4 + m0 - c0 10^4. Every intermediate is
% < 2^31 (Z: |u| < 3 t). floor(v/10^4) = (v+500005000)/10000-50001 for
% |v| < 5 10^8. Then the correction loop, r = u B + a0 - q^2 and the final
% correction as in \CALX_nsqrt_iv.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_vi #1#2#3#4#5#6#7%
   {\CALX_nsqrt_iv\CALX_nsqrt_vi_a{#2}{#3}{#4}{#5}{#6}{#7}#1}%
\def\CALX_nsqrt_vi_a #1#2%
   {\expandafter\CALX_nsqrt_vi_b\the\numexpr%
       \xint_c_ii*#2-200000000.{#1}{#2}}%
\def\CALX_nsqrt_vi_b #1.#2#3#4#5%
{%
    \expandafter\CALX_nsqrt_vi_c
    \the\numexpr\xint_c_ii*#2\ifnum#1<\xint_c_e_viii\else+\xint_c_i\fi
    \expandafter.\the\numexpr#1\ifnum#1<\xint_c_e_viii\else-\xint_c_e_viii\fi
    .{#4}{#5}{{#2}{#3}}%
}%
\def\CALX_nsqrt_vi_c #1.#2.#3#4#5#6#7%
   {\expandafter\CALX_nsqrt_vi_d\the\numexpr#3*%
       \xint_c_e_viii/#1.#1.#2.{#3}{#4}{#6}{#7}{#5}}%
\def\CALX_nsqrt_vi_d #1.#2.#3.%
{%
    \expandafter\CALX_nsqrt_vi_e
    \the\numexpr(#1+5000)/\xint_c_e_iv-\xint_c_i\expandafter.%
    \the\numexpr(#2+5000)/\xint_c_e_iv-\xint_c_i\expandafter.%
    \the\numexpr(#3+5000)/\xint_c_e_iv-\xint_c_i.#1.#2.#3.%
}%
%    \end{macrocode}
%\begin{lverb}
% #1=qh, #2=tHh, #3=tLh, #4=q0, #5=tH, #6=tL, #7=H, #8=L, #9=a1.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_vi_e #1.#2.#3.#4.#5.#6.#7#8#9%
{%
    \expandafter\CALX_nsqrt_vi_f
    \the\numexpr#9-(#4-#1*\xint_c_e_iv)*(#6-#3*\xint_c_e_iv)\expandafter.%
    \the\numexpr-#1*(#6-#3*\xint_c_e_iv)-(#4-#1*\xint_c_e_iv)*#3\expandafter.%
    \the\numexpr((#7-#1*#2)*\xint_c_e_iv
       -(#1*(#5-#2*\xint_c_e_iv)+(#4-#1*\xint_c_e_iv)*#2))*\xint_c_e_iv
       +#8-(#1*#3+(#4-#1*\xint_c_e_iv)*(#5-#2*\xint_c_e_iv)).#4.#5.#6.%
}%
\def\CALX_nsqrt_vi_f #1.#2.%
{%
    \expandafter\CALX_nsqrt_vi_g
    \the\numexpr#2+(#1+500005000)/\xint_c_e_iv-50001\expandafter.%
    \the\numexpr#1-((#1+500005000)/\xint_c_e_iv-50001)*\xint_c_e_iv.%
}%
\def\CALX_nsqrt_vi_g #1.#2.#3.%
{%
    \expandafter\CALX_nsqrt_vi_k
    \the\numexpr#3+(#1+500005000)/\xint_c_e_iv-50001\expandafter.%
    \the\numexpr(#1-((#1+500005000)/\xint_c_e_iv-50001)*\xint_c_e_iv)*%
        \xint_c_e_iv+#2.%
}%
%    \end{macrocode}
%\begin{lverb}
% Correction loop: #1=uH, #2=uL, #3=q, #4=tH, #5=tL. While u < 0: u += t,
% q -= 1; while u >= t: u -= t, q += 1.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_vi_k #1.%
{%
    \ifnum#1<\xint_c_ \expandafter\CALX_nsqrt_vi_kadd
    \else\expandafter\CALX_nsqrt_vi_kcmp\fi #1.%
}%
\def\CALX_nsqrt_vi_kadd #1.#2.#3.#4.#5.%
{%
    \expandafter\CALX_nsqrt_vi_k
    \the\numexpr#1+#4+(#2+#5+50000000)/\xint_c_e_viii-\xint_c_i\expandafter.%
    \the\numexpr#2+#5-((#2+#5+50000000)/\xint_c_e_viii-\xint_c_i)*%
        \xint_c_e_viii
    \expandafter.\the\numexpr#3-\xint_c_i.#4.#5.%
}%
\def\CALX_nsqrt_vi_kcmp #1.#2.#3.#4.#5.%
{%
    \ifcase\numexpr\ifnum#1<#4 0\else\ifnum#1>#4 1\else
                   \ifnum#2<#5 0\else 1\fi\fi\fi\relax
         \expandafter\CALX_nsqrt_vi_r
    \or  \expandafter\CALX_nsqrt_vi_ksub
    \fi #1.#2.#3.#4.#5.%
}%
\def\CALX_nsqrt_vi_ksub #1.#2.#3.#4.#5.%
{%
    \expandafter\CALX_nsqrt_vi_k
    \the\numexpr#1-#4+(#2-#5+150000000)/\xint_c_e_viii-\xint_c_ii%
        \expandafter.%
    \the\numexpr#2-#5-((#2-#5+150000000)/\xint_c_e_viii-\xint_c_ii)*%
        \xint_c_e_viii
    \expandafter.\the\numexpr#3+\xint_c_i.#4.#5.%
}%
%    \end{macrocode}
%\begin{lverb}
% r = u B + a0 - q^2: #1=uH, #2=uL, #3=q, #4=tH, #5=tL, #6=a0, then {S}.
% q^2 = (qh^2 + ch) B + ql^2 + cl 10^4 with c = 2 qh ql = ch 10^4 + cl.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_vi_r #1.#2.#3.#4.#5.#6%
{%
    \expandafter\CALX_nsqrt_vi_rb
    \the\numexpr(#3+5000)/\xint_c_e_iv-\xint_c_i.#3.#6.#2.#1.{#4}{#5}%
}%
\def\CALX_nsqrt_vi_rb #1.#2.%
   {\expandafter\CALX_nsqrt_vi_rc\the\numexpr\xint_c_ii*#1*(#2-#1*%
       \xint_c_e_iv).#1.#2.}%
\def\CALX_nsqrt_vi_rc #1.%
   {\expandafter\CALX_nsqrt_vi_rd\the\numexpr(#1+5000)/\xint_c_e_iv-%
       \xint_c_i.#1.}%
\def\CALX_nsqrt_vi_rd #1.#2.#3.#4.#5.#6.#7.%
{%
    \expandafter\CALX_nsqrt_vi_re
    \the\numexpr#5-(#4-#3*\xint_c_e_iv)*(#4-#3*\xint_c_e_iv)
                -(#2-#1*\xint_c_e_iv)*\xint_c_e_iv\expandafter.%
    \the\numexpr#6-#3*#3-#1.#7.#4.%
}%
\def\CALX_nsqrt_vi_re #1.#2.%
{%
    \expandafter\CALX_nsqrt_vi_rf
    \the\numexpr#2+(#1+250000000)/\xint_c_e_viii-\xint_c_iii\expandafter.%
    \the\numexpr#1-((#1+250000000)/\xint_c_e_viii-\xint_c_iii)*%
        \xint_c_e_viii.%
}%
\def\CALX_nsqrt_vi_rf #1.#2.#3.%
{%
    \expandafter\CALX_nsqrt_vi_rg
    \the\numexpr#3+(#1+250000000)/\xint_c_e_viii-\xint_c_iii\expandafter.%
    \the\numexpr#1-((#1+250000000)/\xint_c_e_viii-\xint_c_iii)*%
        \xint_c_e_viii.#2.%
}%
%    \end{macrocode}
%\begin{lverb}
% #1=R2, #2=R1, #3=R0, #4=q, #5=tH, #6=tL, #7=S, #8=cont. If R2 < 0:
% r += tH B^2 + tL B + 2q - 1, q -= 1 (q >= 1 here, see \CALX_nsqrt_iv).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_vi_rg #1.#2.#3.#4.#5#6#7#8%
{%
    \ifnum#1<\xint_c_
      \xint_dothis{\expandafter\CALX_nsqrt_vi_rh
         \the\numexpr#3+\xint_c_ii*#4-\xint_c_i\expandafter.%
         \the\numexpr#4-\xint_c_i.#2.#1.{#5}{#6}{#7}#8}\fi
    \xint_orthat{\expandafter\CALX_nsqrt_vi_out\expandafter
                 {\the\numexpr#4+\xint_c_e_viii}{#1}{#2}{#3}#7#8}%
}%
\def\CALX_nsqrt_vi_out #1#2#3#4#5#6#7{#7{#5}{#6}{#1}{#2}{#3}{#4}}%
\def\CALX_nsqrt_vi_rh #1.#2.#3.#4.%
{%
    \expandafter\CALX_nsqrt_vi_ri
    \the\numexpr(#1+150000000)/\xint_c_e_viii-\xint_c_ii.#1.#3.#4.#2.%
}%
\def\CALX_nsqrt_vi_ri #1.#2.#3.#4.#5.#6#7%
{%
    \expandafter\CALX_nsqrt_vi_rj
    \the\numexpr#3+#7+#1\expandafter.\the\numexpr#2-#1*%
        \xint_c_e_viii.#4.#5.{#6}%
}%
\def\CALX_nsqrt_vi_rj #1.#2.#3.#4.#5#6#7%
{%
    \expandafter\CALX_nsqrt_vi_out\expandafter
    {\the\numexpr#4+\xint_c_e_viii\expandafter}\expandafter
    {\the\numexpr#3+#5+(#1+150000000)/\xint_c_e_viii-\xint_c_ii\expandafter}%
        \expandafter
    {\the\numexpr#1-((#1+150000000)/\xint_c_e_viii-\xint_c_ii)*%
        \xint_c_e_viii}%
    {#2}#6#7%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nsqrt_natv}, \csh{CALX_nsqrt_nathl},
% \csh{CALX_nsqrt_natr}}
%\begin{lverb}
% \CALX_nsqrt_natv{v} (0 <= v < 2^31), \CALX_nsqrt_nathl{H}{L} (H B + L),
% \CALX_nsqrt_natr{R2}{R1}{R0} (R2 B^2 + R1 B + R0), 0 <= H, R2 < 2^31,
% 0 <= L, R1, R0 < B: native integer (use with \romannumeral0); built
% through \CALX_nnorm which strips zero top blocks.
%
% floor(x/B) = (x+50000000)/100000000-1 for x >= 0.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_natv #1{\expandafter\CALX_nnorm\expandafter+%
    \the\numexpr#1-((#1+50000000)/\xint_c_e_viii-\xint_c_i)*\xint_c_e_viii+%
        \xint_c_e_viii\expandafter!%
    \the\numexpr((#1+50000000)/\xint_c_e_viii-\xint_c_i)+\xint_c_e_viii!1;!}%
\def\CALX_nsqrt_nathl #1#2{\expandafter\CALX_nnorm\expandafter+%
    \the\numexpr#2+\xint_c_e_viii\expandafter!%
    \the\numexpr#1-((#1+50000000)/\xint_c_e_viii-\xint_c_i)*\xint_c_e_viii+%
        \xint_c_e_viii\expandafter!%
    \the\numexpr((#1+50000000)/\xint_c_e_viii-\xint_c_i)+\xint_c_e_viii!1;!}%
\def\CALX_nsqrt_natr #1#2#3{\expandafter\CALX_nnorm\expandafter+%
    \the\numexpr#3+\xint_c_e_viii\expandafter!%
    \the\numexpr#2+\xint_c_e_viii\expandafter!%
    \the\numexpr#1-((#1+50000000)/\xint_c_e_viii-\xint_c_i)*\xint_c_e_viii+%
        \xint_c_e_viii\expandafter!%
    \the\numexpr((#1+50000000)/\xint_c_e_viii-\xint_c_i)+\xint_c_e_viii!1;!}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nsqrt_core}}
%\begin{lverb}
% \CALX_nsqrt_core <cont>{n}{blocks}: n even >= 4, top block >= 25000000
% (block of 8 digits). Gives <cont>{s}{r} (natives), s = isqrt, r = X - s^2.
%
% n = 4, 6: \CALX_nsqrt_iv, \CALX_nsqrt_vi; n >= 8: \CALX_nsqrt_k (one
% block steps). With <cont> = \CALX_nsqrt_un (padded input, see
% \CALX_nsqrtrem) and n = 6 or n >= 8, the root is not built as a native:
% \CALX_nsqrt_cvu passes the output of \CALX_nsqrt_vi to \CALX_nsqrt_kb,
% and the final state goes to \CALX_nsqrt_kuz (S and R of the unpadded
% input directly).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_core #1#2%
{%
    \ifcase\numexpr#2/\xint_c_ii-\xint_c_ii\relax
         \xint_dothis\CALX_nsqrt_civ
    \or  \xint_dothis{\ifx\CALX_nsqrt_un#1\expandafter\CALX_nsqrt_cvu
                      \else\expandafter\CALX_nsqrt_cvi\fi}%
    \fi\xint_orthat\CALX_nsqrt_k #1{#2}%
}%
\def\CALX_nsqrt_cvu #1#2#3{\CALX_nsqrt_msvi#3\CALX_nsqrt_vi\CALX_nsqrt_kb%
    \xint:{}#1}%
\def\CALX_nsqrt_civ #1#2#3{\CALX_nsqrt_msiv#3\CALX_nsqrt_iv\CALX_nsqrt_ivo#1}%
\def\CALX_nsqrt_msiv 1#1!1#2!1#3!1#4!#5#6{#5#6{#4}{#3}{#2}{#1}}%
\def\CALX_nsqrt_ivo #1#2#3#4%
   {\expandafter\CALX_nsqrt_ivp\romannumeral0\CALX_nsqrt_nathl{#3}{#4}%
       \xint:{N+2.#2!1#1!}}%
\def\CALX_nsqrt_ivp #1\xint:#2#3{#3{#2}{#1}}%
\def\CALX_nsqrt_cvi #1#2#3{\CALX_nsqrt_msvi#3\CALX_nsqrt_vi\CALX_nsqrt_vio#1}%
\def\CALX_nsqrt_msvi %
    1#1!1#2!1#3!1#4!1#5!1#6!#7#8{#7#8{#6}{#5}{#4}{#3}{#2}{#1}}%
\def\CALX_nsqrt_vio #1#2#3#4#5#6%
   {\expandafter\CALX_nsqrt_ivp\romannumeral0\CALX_nsqrt_natr{#4}{#5}{#6}%
       \xint:{N+3.#3!#2!1#1!}}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nsqrt_k}}
%\begin{lverb}
% \CALX_nsqrt_k <cont>{n}{blocks}: n even >= 8, top block >= 25000000.
% Same output as \CALX_nsqrt_core. The root of the top six blocks is
% obtained by \CALX_nsqrt_vi, then the root is extended by one block for
% each further pair of blocks (one Zimmermann step with b = B each time).
%
% Step. Let s (k blocks, k >= 3) be the root of the top 2k blocks,
% r = (top 2k blocks) - s^2 (0 <= r <= 2s), t = 2s, and a1, a0 the next two
% blocks. With W = r B + a1, the next block of the root is the largest q
% such that W B + a0 - q (t B + q) >= 0; it is q = floor(W/t) or that
% value minus one. Then s <- s B + q, t <- t B + 2q, r <- that difference.
% As s >= B^k/2 (normalized input), B^k <= t < 2 B^k: the top block t_k
% of t is 1.
%
% State. P = 1t_0!1r_0!1t_1!1r_1!...1t_k!1r_k!1;;;;;! (the blocks of t and
% r interleaved, least significant first, r padded with zero blocks). Then
% L = 1<a1>!P is exactly the layout of the window W and the divisor t used
% by the multiply-subtract pass of the division (\CALX_ndms_a): the pairs
% (w_j, t_j) with w_0 = a1, w_j = r_(j-1), then w_(k+1) = r_k and the
% marker.
%
% \CALX_nsqrt_k reverses the blocks (most significant first), gives the top
% six to \CALX_nsqrt_vi with continuation \CALX_nsqrt_kb, which builds P
% (k = 3) from its output. \CALX_nsqrt_ks {k}{P} <pairs>\xint: loops while
% pairs of blocks remain, then goes to \CALX_nsqrt_kz. \CALX_nsqrt_kt
% copies L and skips 2k-4 blocks (\CALX_nskip) to read the top blocks of r
% and t for the estimate (\CALX_nsqrt_ku).
%
% \CALX_nsqrt_kfl{x}: floor(x/B) for 0 <= x < 2B, in \numexpr.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_k #1#2#3%
   {\expandafter\CALX_nsqrt_ka\romannumeral0\CALX_rev_nounsep{}#3\R!\R!\R!\R!%
       \R!\R!\R!\R!\W
    \xint:{}#1}%
\def\CALX_nsqrt_ka 1#1!1#2!1#3!1#4!1#5!1#6!#7\xint:%
   {\CALX_nsqrt_vi\CALX_nsqrt_kb{#1}{#2}{#3}{#4}{#5}{#6}#7\xint:}%
\def\CALX_nsqrt_kfl #1{((#1+50000000)/\xint_c_e_viii-\xint_c_i)}%
\def\CALX_nsqrt_kb #1#2#3#4#5#6%
{%
    \expandafter\CALX_nsqrt_ks\expanded{{3}{%
    \the\numexpr\xint_c_ii*#3-\xint_c_e_viii
       -\CALX_nsqrt_kfl{\xint_c_ii*#3-200000000}*\xint_c_e_viii!%
    \the\numexpr\xint_c_e_viii+#6!%
    \the\numexpr\xint_c_ii*#2-\xint_c_e_viii+\CALX_nsqrt_kfl{%
        \xint_c_ii*#3-200000000}%
       -\CALX_nsqrt_kfl{\xint_c_ii*#2-200000000
            +\CALX_nsqrt_kfl{\xint_c_ii*#3-200000000}}*\xint_c_e_viii!%
    \the\numexpr\xint_c_e_viii+#5!%
    \the\numexpr\xint_c_ii*#1+\CALX_nsqrt_kfl{\xint_c_ii*#2-200000000
            +\CALX_nsqrt_kfl{\xint_c_ii*#3-200000000}}!%
    \the\numexpr#4-\CALX_nsqrt_kfl{#4}*\xint_c_e_viii+\xint_c_e_viii!%
    100000001!%
    \the\numexpr\CALX_nsqrt_kfl{#4}+\xint_c_e_viii!%
    1;;;;;!}}%
}%
\def\CALX_nsqrt_ks #1#2#3%
   {\ifx\xint:#3\expandafter\CALX_nsqrt_kz\else\expandafter\CALX_nsqrt_kt%
       \fi{#1}{#2}#3}%
\def\CALX_nsqrt_kt #1#21#3!1#4!%
   {\CALX_nskip\CALX_nsqrt_ku\xint_c_ii*#1-\xint_c_iv.1#3!#2{#1}{#3}{#4}{#2}}%
\def\CALX_nsqrt_ku 1#1!1#2!1#3!1#4!1#5!1#6!1#7!1;;;;;!#8#9%
{%
    \expandafter\CALX_nsqrt_kec\the\numexpr\xint_c_e_viii+#4\expandafter.%
    \the\numexpr#2\expandafter.\expandafter{\the\numexpr#7*\xint_c_e_viii+#5}%
    {#3}{{#8}{#9}}{#1}{}%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nsqrt_kec}}
%\begin{lverb}
% Estimate. With U = (r_k B + r_(k-1)) B^2 + r_(k-2) B + r_(k-3) (three
% limbs, the top one below 2 10^8) and V = (B + t_(k-1)) B + t_(k-2), the
% value q* = floor(U/V) satisfies q <= q* <= q + 1 where q = floor(W/t),
% and q* = q + 1 only if the lower blocks matter (probability about
% 10^-8): W/t < (U + 1)/V and W/t >= U/(V + 1), and U/V - U/(V + 1) < 1.
% The computation of q* is that of \CALX_nsqrt_vi (same limbs, same bounds:
% tH = B + t_(k-1) is in [10^8, 2 10^8)): \CALX_nsqrt_kec ... _keksub are
% copies of \CALX_nsqrt_vi_c ... _vi_ksub, renamed, which end with
% \CALX_nsqrt_kq instead of \CALX_nsqrt_vi_r.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_kec #1.#2.#3#4#5#6#7%
   {\expandafter\CALX_nsqrt_ked\the\numexpr#3*%
       \xint_c_e_viii/#1.#1.#2.{#3}{#4}{#6}{#7}{#5}}%
\def\CALX_nsqrt_ked #1.#2.#3.%
{%
    \expandafter\CALX_nsqrt_kee
    \the\numexpr(#1+5000)/\xint_c_e_iv-\xint_c_i\expandafter.%
    \the\numexpr(#2+5000)/\xint_c_e_iv-\xint_c_i\expandafter.%
    \the\numexpr(#3+5000)/\xint_c_e_iv-\xint_c_i.#1.#2.#3.%
}%
\def\CALX_nsqrt_kee #1.#2.#3.#4.#5.#6.#7#8#9%
{%
    \expandafter\CALX_nsqrt_kef
    \the\numexpr#9-(#4-#1*\xint_c_e_iv)*(#6-#3*\xint_c_e_iv)\expandafter.%
    \the\numexpr-#1*(#6-#3*\xint_c_e_iv)-(#4-#1*\xint_c_e_iv)*#3\expandafter.%
    \the\numexpr((#7-#1*#2)*\xint_c_e_iv
       -(#1*(#5-#2*\xint_c_e_iv)+(#4-#1*\xint_c_e_iv)*#2))*\xint_c_e_iv
       +#8-(#1*#3+(#4-#1*\xint_c_e_iv)*(#5-#2*\xint_c_e_iv)).#4.#5.#6.%
}%
\def\CALX_nsqrt_kef #1.#2.%
{%
    \expandafter\CALX_nsqrt_keg
    \the\numexpr#2+(#1+500005000)/\xint_c_e_iv-50001\expandafter.%
    \the\numexpr#1-((#1+500005000)/\xint_c_e_iv-50001)*\xint_c_e_iv.%
}%
\def\CALX_nsqrt_keg #1.#2.#3.%
{%
    \expandafter\CALX_nsqrt_kek
    \the\numexpr#3+(#1+500005000)/\xint_c_e_iv-50001\expandafter.%
    \the\numexpr(#1-((#1+500005000)/\xint_c_e_iv-50001)*\xint_c_e_iv)*%
        \xint_c_e_iv+#2.%
}%
\def\CALX_nsqrt_kek #1.%
{%
    \ifnum#1<\xint_c_ \expandafter\CALX_nsqrt_kekadd
    \else\expandafter\CALX_nsqrt_kekcmp\fi #1.%
}%
\def\CALX_nsqrt_kekadd #1.#2.#3.#4.#5.%
{%
    \expandafter\CALX_nsqrt_kek
    \the\numexpr#1+#4+(#2+#5+50000000)/\xint_c_e_viii-\xint_c_i\expandafter.%
    \the\numexpr#2+#5-((#2+#5+50000000)/\xint_c_e_viii-\xint_c_i)*%
        \xint_c_e_viii
    \expandafter.\the\numexpr#3-\xint_c_i.#4.#5.%
}%
\def\CALX_nsqrt_kekcmp #1.#2.#3.#4.#5.%
{%
    \ifcase\numexpr\ifnum#1<#4 0\else\ifnum#1>#4 1\else
                   \ifnum#2<#5 0\else 1\fi\fi\fi\relax
         \expandafter\CALX_nsqrt_kq
    \or  \expandafter\CALX_nsqrt_keksub
    \fi #1.#2.#3.#4.#5.%
}%
\def\CALX_nsqrt_keksub #1.#2.#3.#4.#5.%
{%
    \expandafter\CALX_nsqrt_kek
    \the\numexpr#1-#4+(#2-#5+150000000)/\xint_c_e_viii-\xint_c_ii%
        \expandafter.%
    \the\numexpr#2-#5-((#2-#5+150000000)/\xint_c_e_viii-\xint_c_ii)*%
        \xint_c_e_viii
    \expandafter.\the\numexpr#3+\xint_c_i.#4.#5.%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nsqrt_kq}}
%\begin{lverb}
% Multiply-subtract and new remainder. \CALX_nsqrt_kq clamps q* to B - 1
% (the root block is at most B - 1, and W - (B - 1) t < B^(k+1) still fits
% the window), then \CALX_nsqrt_kqa runs \CALX_ndms_a on L with q*: the
% output is 1t_0!1u_0!...1t_k!1u_k!1;;;;;!{fin} with u = W - q* t. If
% fin < 0, t is added back (\CALX_ndab) and q* decreases by one
% (\CALX_nsqrt_kp, _kpa, _kpc).
%
% \CALX_nsqrt_kw computes r' = u B + a0 - q^2 on the two low blocks: with
% qh, ql the halves of q and c = 2 qh ql = ch 10^4 + cl, the low block is
% a0 - ql^2 - cl 10^4 (borrow b0 in {-2, -1, 0}) and the next one
% u_0 - qh^2 - ch + b0 (borrow b1 in {-2, -1, 0}); further blocks are
% u_1, ..., u_k.
%
% If b1 < 0 the borrow is propagated into u_1, u_2, ... (\CALX_nsqrt_kbs,
% \CALX_nsqrt_kbt). If it runs past u_k, r' < 0 (this happens for near
% squares, e.g. 10^48 + 10^24): the step is redone from \CALX_nsqrt_kqa
% with q - 1 (\CALX_nsqrt_kfb); then u >= t >= B^k and r' >= 0. The data
% of the step, {<a1>}{<a0>}{P}, is carried along for this purpose.
%
% New state (\CALX_nsqrt_kwh): t' = t B + 2q has the blocks
% 2q - c B, t_0 + c (c = 1 if 2q >= B, else 0; t_0 is even, no carry),
% t_1, ..., t_k; r' has the blocks computed above, then u_1, ..., u_k. So
% P' = 1t'_0!1r'_0!1t'_1!1r'_1! followed by the output of the pass
% without its first two blocks.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_kq #1.#2.#3.#4.#5.#6#7#8#9%
{%
    \expandafter\CALX_nsqrt_kqa\the\numexpr
      \ifnum#3>99999999 199999999\else\xint_c_e_viii+#3\fi\xint:#7{#8}{#9}%
}%
\def\CALX_nsqrt_kqa 1#1#2#3#4#5\xint:#6#7#8#9%
{%
    \expandafter\CALX_nsqrt_kp\the\numexpr
    \CALX_ndms_a 0\xint:#1#2#3#4%
        \xint:#5!1#7!#9{#1#2#3#4#5}{#6}{#8}{{#7}{#8}{#9}}%
}%
\def\CALX_nsqrt_kp #1;;;;;!#2%
{%
    \ifnum\numexpr#2<\xint_c_ \xint_dothis\CALX_nsqrt_kpa\fi
    \xint_orthat\CALX_nsqrt_kw #1;;;;;!%
}%
\def\CALX_nsqrt_kpa #1;;;;;!%
   {\expandafter\CALX_nsqrt_kpc\the\numexpr\CALX_ndab 0\xint:#1;;;;;!}%
\def\CALX_nsqrt_kpc #1;;;;;!#2{\CALX_nsqrt_kw #1;;;;;!{#2-\xint_c_i}}%
\def\CALX_nsqrt_kw 1#1!1#2!#3;;;;;!#4#5#6#7%
{%
    \expandafter\CALX_nsqrt_kwa\the\numexpr#4\expandafter.%
    \the\numexpr(#4+5000)/\xint_c_e_iv-\xint_c_i.#1.#2.#6.{#5}{#7}#3;;;;;!%
}%
\def\CALX_nsqrt_kwa #1.#2.%
   {\expandafter\CALX_nsqrt_kwb\the\numexpr\xint_c_ii*#2*(#1-#2*%
       \xint_c_e_iv).#1.#2.}%
\def\CALX_nsqrt_kwb #1.%
   {\expandafter\CALX_nsqrt_kwc\the\numexpr(#1+5000)/\xint_c_e_iv-%
       \xint_c_i.#1.}%
\def\CALX_nsqrt_kwc #1.#2.#3.#4.#5.#6.#7.%
{%
    \expandafter\CALX_nsqrt_kwd
    \the\numexpr#7-(#3-#4*\xint_c_e_iv)*(#3-#4*\xint_c_e_iv)
                -(#2-#1*\xint_c_e_iv)*\xint_c_e_iv\expandafter.%
    \the\numexpr#6-#4*#4-#1.#3.#5.%
}%
\def\CALX_nsqrt_kwd #1.%
   {\expandafter\CALX_nsqrt_kwe\the\numexpr(#1+250000000)/\xint_c_e_viii-%
       \xint_c_iii.#1.}%
\def\CALX_nsqrt_kwe #1.#2.#3.%
   {\expandafter\CALX_nsqrt_kwf\the\numexpr#3+#1\expandafter.\the%
       \numexpr#2-#1*\xint_c_e_viii.}%
\def\CALX_nsqrt_kwf #1.%
   {\expandafter\CALX_nsqrt_kwg\the\numexpr(#1+150000000)/\xint_c_e_viii-%
       \xint_c_ii.#1.}%
\def\CALX_nsqrt_kwg #1.#2.#3.#4.#5.%
{%
    \ifnum#1=\xint_c_ \expandafter\CALX_nsqrt_kwh\else\expandafter%
        \CALX_nsqrt_kwp\fi
    {#1}{#2}{#3}{#4}{#5}%
}%
\def\CALX_nsqrt_kwp #1#2#3#4#5#6#7#8;;;;;!%
   {\expandafter\CALX_nsqrt_kwq\expanded{\CALX_nsqrt_kbs{#1}#8;;;;;!}%
       \xint:{#1}{#2}{#3}{#4}{#5}{#6}{#7}}%
\def\CALX_nsqrt_kwq #1;;;;;!#2\xint:%
   {\ifx\relax#2\relax\expandafter\CALX_nsqrt_kwk\else\expandafter%
       \CALX_nsqrt_kfb\fi{#1}}%
\def\CALX_nsqrt_kwk #1#2#3#4#5#6#7#8{%
    \CALX_nsqrt_kwh{#2}{#3}{#4}{#5}{#6}{#7}{#8}#1;;;;;!}%
\def\CALX_nsqrt_kfb #1#2#3#4#5#6#7#8%
   {\expandafter\CALX_nsqrt_kqa\the\numexpr\xint_c_e_viii+#5-\xint_c_i%
       \xint:{#7}#8}%
\def\CALX_nsqrt_kbs #11#2#3!{\xint_gob_til_sc #2\CALX_nsqrt_kbz;%
    \CALX_nsqrt_kbt{#1}{#2#3}}%
%    \end{macrocode}
% Attention to this F. It (probably) should be of catcode 12, so this
% is what we do.
%    \begin{macrocode}
\catcode`F 12
\def\CALX_nsqrt_kbz;\CALX_nsqrt_kbt#1#2{1;;;;;!F}%
\catcode`F 11
\def\CALX_nsqrt_kbt #1#21#3!%
{%
    1#2!\the\numexpr#3+#1+\ifnum\numexpr#3+#1<\xint_c_ 200000000\else%
        \xint_c_e_viii\fi!%
    \ifnum\numexpr#3+#1<\xint_c_ \CALX_nsqrt_kbf\fi
}%
\def\CALX_nsqrt_kbf\fi{\fi\CALX_nsqrt_kbs{-1}}%
\def\CALX_nsqrt_kwh #1#2#3#4#5#6#7#8;;;;;!%
{%
    \expandafter\CALX_nsqrt_ks\expanded{{\the\numexpr#6+\xint_c_i}{%
    \the\numexpr\xint_c_ii*#4-\CALX_nsqrt_kfl{\xint_c_ii*#4}*\xint_c_e_viii+%
        \xint_c_e_viii!%
    \the\numexpr#3+\xint_c_e_viii!%
    \the\numexpr#5+\CALX_nsqrt_kfl{\xint_c_ii*#4}+\xint_c_e_viii!%
    \the\numexpr#2-#1*\xint_c_e_viii+\xint_c_e_viii!%
    #8;;;;;!}}%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nsqrt_kz}}
%\begin{lverb}
% End of the steps. \CALX_nsqrt_kzn$empty: R is the native made of the r
% blocks of P (\CALX_nsqrt_kzr), S = t/2 (t blocks extracted by
% \CALX_nsqrt_kzt, halved by \CALX_nsqrt_kh$empty: block t_i/2, plus 5 10^7
% if t_(i+1) is odd).
%
% \CALX_nsqrt_kuz is used instead when <cont> is \CALX_nsqrt_un, i.e. the
% core worked on Y = X D0^2, D0 = 2^j 10^t' (see \CALX_nsqrt_bgh): it
% receives P, then {D0}{j}{2t'}{5^j}{25^j}. With s, r the root and
% remainder of Y and m = 2^(j+1): one pass over t = 2s, most significant
% block first (\CALX_nsqrt_kva), divides by m (remainder c < m, so
% c B + t_i < 2^31) and shifts right by t' digits (remainder rho), giving
% the blocks of S = floor(s/D0) and, at the end, e = s - S D0 =
% rho 2^j + c/2. Then R = (r + e (t - e))/D0^2 (exact): native operations,
% \CALX_nshr by 2t' digits, then division by 4^j. floor(v/10^t') is
% (2v - 10^t' + 1)/(2 10^t') in \numexpr (no tie, also for t' = 0).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_kz #1#2\xint:#3#4%
{%
    \ifx\CALX_nsqrt_un#4\expandafter\CALX_nsqrt_kuz\else\expandafter%
        \CALX_nsqrt_kzn\fi
    {#2}#4%
}%
\def\CALX_nsqrt_kzn #1%
{%
    \expandafter\CALX_nsqrt_kzz\romannumeral0\expandafter\CALX_nnorm%
        \expandafter+\expanded{\CALX_nsqrt_kzr#1}1;!%
    \xint:{#1}%
}%
\def\CALX_nsqrt_kuz #1#2#3#4#5#6#7%
{%
    \expandafter\CALX_nsqrt_kub\expanded{%
      \expandafter\CALX_nsqrt_kvx\romannumeral0\expandafter\CALX_rev_nounsep%
          \expandafter{\expandafter}%
      \expanded{\CALX_nsqrt_kzt#1}\R!\R!\R!\R!\R!\R!\R!\R!\W 1;!\xint:%
      {\ifcase#4 2\or4\or8\or16\fi}{\ifcase#4 1\or2\or4\or8\fi}{%
          \CALX_pten{#5/\xint_c_ii}}}%
    {#1}{#4}{#5}%
}%
\def\CALX_nsqrt_kvx #1\xint:#2#3#4{\CALX_nsqrt_kva 0.0.{#2}{#3}{#4}#1}%
\def\CALX_nsqrt_kva #1.#2.#3#4#51#6#7!%
{%
    \if;#6\expandafter\CALX_nsqrt_kve\else\expandafter\CALX_nsqrt_kvf\fi
    {#1}{#2}{#3}{#4}{#5}{#6#7}%
}%
\def\CALX_nsqrt_kve #1#2#3#4#5#6{\xint:{\the\numexpr#2*#4+#1/\xint_c_ii}}%
\def\CALX_nsqrt_kvf #1#2#3#4#5#6%
{%
    \expandafter\CALX_nsqrt_kvb
    \the\numexpr(#1*\xint_c_e_viii+#6+#4)/#3-\xint_c_i.#1.#2.#6.{#3}{#4}{#5}%
}%
\def\CALX_nsqrt_kvb #1.#2.#3.#4.#5#6#7%
{%
    \expandafter\CALX_nsqrt_kvc
    \the\numexpr(\xint_c_ii*#1-#7+\xint_c_i)/(\xint_c_ii*#7).#1.%
    \the\numexpr#2*\xint_c_e_viii+#4-#1*#5.#3.{#5}{#6}{#7}%
}%
\def\CALX_nsqrt_kvc #1.#2.#3.#4.#5#6#7%
{%
    \the\numexpr#1+#4*(\xint_c_e_viii/#7)+\xint_c_e_viii!%
    \expandafter\CALX_nsqrt_kva\the\numexpr#3\expandafter.\the%
        \numexpr#2-#1*#7.%
    {#5}{#6}{#7}%
}%
\def\CALX_nsqrt_kub #1\xint:%
{%
    \expandafter\CALX_nsqrt_kuc\romannumeral0\expandafter\CALX_nnorm%
        \expandafter+%
    \romannumeral0\CALX_rev_nounsep{}#1\R!\R!\R!\R!\R!\R!\R!\R!\W 1;!%
    \xint:%
}%
\def\CALX_nsqrt_kuc #1\xint:#2#3#4#5%
{%
    \expandafter\CALX_nsqrt_kud\romannumeral0\CALX_nshr{#5}%
    {\romannumeral0\CALX_nadd
       {\romannumeral0\expandafter\CALX_nnorm\expandafter+\expanded{%
           \CALX_nsqrt_kzr#3}1;!}%
       {\romannumeral0\CALX_nmul{\romannumeral0\CALX_nsqrt_natv{#2}}%
          {\romannumeral0\CALX_nsub
             {\romannumeral0\expandafter\CALX_nnorm\expandafter+\expanded{%
                 \CALX_nsqrt_kzt#3}1;!}%
             {\romannumeral0\CALX_nsqrt_natv{#2}}}}}%
    \xint:{#1}{#4}%
}%
\def\CALX_nsqrt_kud #1\xint:#2#3%
{%
    \ifnum#3=\xint_c_ \xint_dothis{{#2}{#1}}\fi
    \xint_orthat{\expandafter\CALX_nsqrt_kue\romannumeral0\CALX_ndivtrunc{#1}%
      {\expanded{\ifcase#3\or N+1.100000004!\or N+1.100000016!\or %
          N+1.100000064!\fi}}%
      \xint:{#2}}%
}%
\def\CALX_nsqrt_kue #1\xint:#2{{#2}{#1}}%
\def\CALX_nsqrt_kzr 1#1#2!{\xint_gob_til_sc #1\CALX_nsqrt_kze;%
    \CALX_nsqrt_kzrb}%
\def\CALX_nsqrt_kze;\CALX_nsqrt_kzrb{}%
\def\CALX_nsqrt_kzrb 1#1!{1#1!\CALX_nsqrt_kzr}%
\def\CALX_nsqrt_kzt 1#1#2!{\xint_gob_til_sc #1\CALX_nsqrt_kzte;%
    \CALX_nsqrt_kztb 1#1#2!}%
\def\CALX_nsqrt_kzte;\CALX_nsqrt_kztb 1#1!{}%
\def\CALX_nsqrt_kztb 1#1!1#2!{1#1!\CALX_nsqrt_kzt}%
\def\CALX_nsqrt_kzz #1\xint:#2%
{%
    \expandafter\CALX_nsqrt_kzy\romannumeral0\expandafter\CALX_nnorm%
        \expandafter+%
    \expanded{\expandafter\CALX_nsqrt_kh\expanded{\CALX_nsqrt_kzt#2}1;!}1;!%
        \xint:{#1}%
}%
\def\CALX_nsqrt_kzy #1\xint:#2#3{#3{#1}{#2}}%
\def\CALX_nsqrt_kh 1#1!1#2#3!%
{%
    \the\numexpr\xint_c_e_viii+(#1\ifodd#1 -\xint_c_i\fi)/\xint_c_ii
    \xint_gob_til_sc#2\CALX_nsqrt_khe;\ifodd#2#3 +50000000\fi\relax!%
        \CALX_nsqrt_kh 1#2#3!%
}%
\def\CALX_nsqrt_khe;#1\CALX_nsqrt_kh 1;!{\relax!}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_nsqrtrem}}
%\begin{lverb}
% Syntax (use with \romannumeral0; X f-expanded native integer or I):
%(
%  \CALX_nsqrtrem{X}  -> {S}{R}     S = isqrt(X), R = X - S^2
%)
% \CALX_nsqrtrem{X} (X f-expands to a native integer; use with
% \romannumeral0): {S}{R}, S = isqrt(X), R = X - S^2. Negative X or I-:
% InvalidOperation, {I?}{I?} (trap value {N+0.}{N+0.}); I+: {I+}{I?};
% I?: {I?}{I?} (no signal).
%
% One or two blocks: \CALX_sqrt_start (from xint) on the digits. Three blocks
% or more: X has Dg digits; K = ceil(Dg/16) = (Dg+7)/16, n' = 2K blocks;
% X is shifted by 2t digits to Dp' = 16K - o digits (o = Dg mod 2), so the
% top block has 8 - o digits, then multiplied by 4^j (j minimal, j <= 1 if
% o = 0, j <= 3 if o = 1) so that it is >= 25000000; the multiplier is
% M = 10^(2t) 4^j. If M = 1: (S,R) = core(X). Else (s,r) = core(Y) and
% S = floor(s/(2^j 10^t)), R = X - S^2 (see \CALX_nsqrt_bgh). The leading
% 8 - o digits of X come from the top block v1
% (d1 digits) and the next block v2: lead = floor((v1 B + v2)/10^e),
% e = d1 + o; floor(x/10^e) = (x+10^e/2)/10^e-1 (x >= 0).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrtrem #1{\expandafter\CALX_nsqrt_x\romannumeral`&&@#1\xint:}%
\def\CALX_nsqrt_x #1#2%
{%
    \if I#1\xint_dothis{\CALX_nsqrt_sp#2}\fi
    \if -#2\xint_dothis\CALX_nsqrt_inv\fi
    \xint_orthat\CALX_nsqrt_p
}%
\def\CALX_nsqrt_inv #1\xint:{\expandafter\CALX_ndiv_zpv\romannumeral`&&@%
    \CALX_signalcondition{InvalidOperation}{isqrt of negative or %
        special}{}{N+0.}\xint:}%
\def\CALX_nsqrt_p #1.%
{%
    \ifcase#1
         \xint_dothis\CALX_nsqrt_zero
    \or  \xint_dothis\CALX_nsqrt_pone
    \or  \xint_dothis\CALX_nsqrt_ptwo
    \fi\xint_orthat\CALX_nsqrt_big #1.%
}%
\def\CALX_nsqrt_sp #1\xint:%
{%
    \if +#1\xint_dothis{{I+}{I?}}\fi
    \if ?#1\xint_dothis{{I?}{I?}}\fi
    \xint_orthat{\CALX_nsqrt_inv\xint:}%
}%
\def\CALX_nsqrt_zero #1\xint:{{N+0.}{N+0.}}%
\def\CALX_nsqrt_pone #1.1#2!\xint:{\expandafter\CALX_nsqrt_onea\the%
    \numexpr#2.}%
\def\CALX_nsqrt_onea #1.%
   {\expandafter\CALX_nsqrt_sm\romannumeral0\expandafter\CALX_sqrt_start
    \the\numexpr\CALX_ndigs{#1}.#1.}%
\def\CALX_nsqrt_ptwo #1.1#2!1#3!\xint:{\expandafter\CALX_nsqrt_twoa\the%
    \numexpr#3.#2.}%
\def\CALX_nsqrt_twoa #1.#2.%
   {\expandafter\CALX_nsqrt_sm\romannumeral0\expandafter\CALX_sqrt_start
    \the\numexpr\xint_c_viii+\CALX_ndigs{#1}.#1#2.}%
\def\CALX_nsqrt_sm #1#2%
{%
    \expandafter\CALX_nsqrt_smb
    \the\numexpr\xint_c_ii*#1-\xint_c_i-#2\expandafter.%
    \the\numexpr#1-\xint_c_i+\xint_c_e_viii.%
}%
\def\CALX_nsqrt_smb #1.#2.%
   {\expandafter\CALX_nsqrt_ivp\romannumeral0\CALX_nsqrt_natv{#1}%
       \xint:{N+1.#2!}\CALX_nsqrt_out}%
\def\CALX_nsqrt_out #1#2{{#1}{#2}}%
\def\CALX_nsqrt_big #1.#2\xint:%
   {\CALX_nskip\CALX_nsqrt_bgt#1-\xint_c_ii.#2\xint:{#1}{#2}}%
\def\CALX_nsqrt_bgt 1#1!1#2!\xint:{\expandafter\CALX_nsqrt_bgv\the%
    \numexpr#2.#1.}%
\def\CALX_nsqrt_bgv #1.%
   {\expandafter\CALX_nsqrt_bga\the\numexpr\CALX_ndigs{#1}.#1.}%
\def\CALX_nsqrt_bga #1.#2.#3.#4%
   {\expandafter\CALX_nsqrt_bgb\the\numexpr\xint_c_viii*(#4-%
       \xint_c_i)+#1.#1.#2.#3.{#4}}%
\def\CALX_nsqrt_bgb #1.%
   {\expandafter\CALX_nsqrt_bgc\the\numexpr\ifodd#1 1\else 0\fi.#1.}%
\def\CALX_nsqrt_bgc #1.#2.#3.#4.#5.%
{%
    \expandafter\CALX_nsqrt_bgf\the\numexpr
    \ifcase\numexpr#3+#1\relax 0%
    \or #4*10000000+(#5+5)/10-\xint_c_i
    \or #4*1000000+(#5+50)/100-\xint_c_i
    \or #4*100000+(#5+500)/1000-\xint_c_i
    \or #4*10000+(#5+5000)/10000-\xint_c_i
    \or #4*1000+(#5+50000)/100000-\xint_c_i
    \or #4*100+(#5+500000)/1000000-\xint_c_i
    \or #4*10+(#5+5000000)/10000000-\xint_c_i
    \or #4%
    \or (#4+5)/10-\xint_c_i
    \fi.#1.#2.%
}%
\def\CALX_nsqrt_bgf #1.#2.#3.%
{%
    \expandafter\CALX_nsqrt_bgg\the\numexpr
    \ifnum#2=\xint_c_ \ifnum#1<25000000 1\else 0\fi
    \else\ifnum#1<1562500 3\else\ifnum#1<6250000 2\else 1\fi\fi\fi%
        \expandafter.%
    \the\numexpr16*((#3+\xint_c_vii)/16)-#2-#3\expandafter.%
    \the\numexpr\xint_c_ii*((#3+\xint_c_vii)/16).%
}%
\def\CALX_nsqrt_bgg #1.#2.%
{%
    \ifnum\numexpr#1+#2=\xint_c_
      \expandafter\CALX_nsqrt_bgg_a
    \else
      \expandafter\CALX_nsqrt_bgg_b
      \the\numexpr\ifcase#1 1\or 2\or 4\or 8\fi*\CALX_pten{#2/%
          \xint_c_ii}%
                  +\xint_c_e_viii\expandafter.%
      \the\numexpr\ifcase#1 1\or 4\or 16\or 64\fi+\xint_c_e_viii\expandafter.%
      \the\numexpr\ifcase#1 1\or 5\or 25\or 125\fi+\xint_c_e_viii%
          \expandafter.%
      \the\numexpr\ifcase#1 1\or 25\or 625\or 15625\fi+\xint_c_e_viii\expandafter;%
    \fi
      #1.#2.%
}%
\def\CALX_nsqrt_bgg_a #1.#2.#3.#4#5{\CALX_nsqrt_core\CALX_nsqrt_out{#3}{#5}}%
\def\CALX_nsqrt_bgg_b #1;#2.#3.#4.#5#6{\CALX_nsqrt_bgh #2.#3.#1.{N+#5.#6}}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_nsqrt_bgh <j>.<2t>.<D0>.<4^j>.<5^j>.<25^j>.{X}: the four numbers
% after j and 2t are given as 1dddddddd (value + 10^8), D0 = 2^j 10^t.
%
% Y = X 10^(2t) 4^j = X D0^2 (\CALX_nshl, then one one block
% multiplication if j > 0). With (s,r) = core(Y), no division at all
% (1/D0 = 5^j/10^(t+j)):
%(   S = floor(s 5^j / 10^(t+j))             (one block mul + \CALX_nshr),
%:   e = s - S D0                             (one block mul + \CALX_nsub),
%:   R = (r + e(2s - e)) 25^j / 10^(2t+2j)    (exact \CALX_nshr),
%)
% as Y = s^2 + r = X D0^2 and X - S^2 = (r + e(2s-e))/D0^2. The
% multiplications by 5^j, 25^j are skipped when j = 0.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsqrt_bgh #1#2.%
{%
    \expandafter\CALX_nsqrt_bgi\romannumeral0%
    \if0#1\expandafter\CALX_nsqrt_bgh_a\else\expandafter\CALX_nsqrt_bgh_b
    \fi #1#2.%
}%
\def\CALX_nsqrt_bgh_a #1.#2.#3.#4.#5.#6.#7%
{%
    \CALX_nshl{#2}{#7}\xint:{#3}{#1}{#2}{#5}{#6}%
}%
\def\CALX_nsqrt_bgh_b #1.#2.#3.#4.#5.#6.#7%
{%
    \CALX_nmul{\romannumeral0\CALX_nshl{#2}{#7}}{N+1.#4!}%
    \xint:{#3}{#1}{#2}{#5}{#6}%
}%
\def\CALX_nsqrt_bgi N+#1.#2\xint:{\CALX_nsqrt_core\CALX_nsqrt_un{#1}{#2}}%
\def\CALX_nsqrt_un #1#2#3#4#5#6%
{%
    \expandafter\CALX_nsqrt_uo\romannumeral0\CALX_nshr{#5/\xint_c_ii+#4}%
      {\ifnum#4=\xint_c_ \expandafter\xint_firstoftwo\else
       \expandafter\xint_secondoftwo\fi
       {#1}{\romannumeral0\CALX_nmul{#1}{N+1.#6!}}}%
           \xint:{#1}{#2}{#3}{#4}{#5}%
}%
\def\CALX_nsqrt_uo #1\xint:#2#3#4%
{%
    \expandafter\CALX_nsqrt_up
    \romannumeral0\CALX_nsub{#2}{\romannumeral0\CALX_nmul{#1}{N+1.#4!}}%
        \xint:{#1}{#2}{#3}%
}%
\def\CALX_nsqrt_up #1\xint:#2#3#4%
{%
    \expandafter\CALX_nsqrt_uq\romannumeral0\CALX_nadd{#4}%
      {\romannumeral0\CALX_nmul{#1}{\romannumeral0\CALX_nsub
                                    {\romannumeral0\CALX_nadd{#3}{#3}}{#1}}}%
                                        \xint:{#2}%
}%
\def\CALX_nsqrt_uq #1\xint:#2#3#4#5%
{%
    \expandafter\CALX_nsqrt_ur\romannumeral0\CALX_nshr{#4+\xint_c_ii*#3}%
      {\ifnum#3=\xint_c_ \expandafter\xint_firstoftwo\else
       \expandafter\xint_secondoftwo\fi
       {#1}{\romannumeral0\CALX_nmul{#1}{N+1.#5!}}}\xint:{#2}%
}%
\def\CALX_nsqrt_ur #1\xint:#2{{#2}{#1}}%
%    \end{macrocode}
% \subsection{Decimal shifts}
% \subsubsection{\csh{CALX_nshr}, \csh{CALX_nshl}, \csh{CALX_nshrr}}
%\begin{lverb}
% Syntax (use with \romannumeral0; k a \numexpr expression, X f-expanded
% native integer or I):
%(
%  \CALX_nshr{k}{X}   -> <space>Y    Y = sign(X) floor(|X|/10^k)
%:  \CALX_nshl{k}{X}   -> <space>Y    Y = X 10^k
%:  \CALX_nshrr{k}{X}  -> <space>Y    Y = sign(X) round(|X|/10^k)
%)
% Decimal shifts of native integers (analogues of \xintDSH, \xintDSx,
% \xintDSRr). Use with \romannumeral0; arguments f-expanded.
%
% \CALX_nshr{k}{X}: sign(X) floor(|X|/10^k) (truncation towards zero).
%
% \CALX_nshl{k}{X}: X 10^k. \CALX_nshrr{k}{X}: |X|/10^k rounded half
% away from zero, sign kept. k >= 0 (k <= 0: X unchanged).
%
% k = 8a + c. Whole blocks: \CALX_nskip (right) or prepended zero blocks
% (left). c > 0: one pass inside \expanded (generated macros
% \CALX_nshr_f<c>, \CALX_nshr_l<c>, \CALX_nshr_e<c>, \CALX_nshl_l<c>,
% \CALX_nshl_e<c>): each new block is a token rearrangement of two
% consecutive blocks, the pending part being the macro argument; no
% arithmetic. End marker 1;;;;;;;;!. The pass ends with \relax<0|1>
% telling whether a top block was dropped (right) or added (left); the
% header N<s><n'>. is built after the pass (one grab of the result).
% I+, I-, I? are returned unchanged (\CALX_nsh_t, one \if test).
%
% \CALX_nshrr$empty: first dropped digit = digit p = (k-1) mod 8 of block
% (k-1) div 8 = (2k-9)/16 (\numexpr, k >= 1), read by \CALX_nskip; +1 by
% \CALX_nadd if >= 5. A result with no block left is N+0.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsh_t #1#2.#3{\if I#3\xint_dothis\CALX_nsh_sp\fi%
    \xint_orthat{#1#2.#3}}%
\def\CALX_nsh_sp #1\xint:{ I#1}%
\def\CALX_nsh_zero\fi#1\xint:{\fi\CALX_sp N+0.}%
\def\CALX_nsh_id\fi#1.#2.#3.#4\xint:{\fi\CALX_sp N#3.#4}%
\def\CALX_nshr #1#2{\expandafter\CALX_nsh_t\expandafter\CALX_nshr_a\the%
    \numexpr#1\expandafter.\romannumeral`&&@#2\xint:}%
\def\CALX_nshr_a #1.N#2#3.#4\xint:%
{%
    \ifnum#3=\xint_c_ \CALX_nsh_zero\fi
    \ifnum#1<\xint_c_i \CALX_nsh_id\fi
    \expandafter\CALX_nshr_b\the\numexpr(#1-\xint_c_iv)/\xint_c_viii.%
    #1.#2#3.#4\xint:
}%
\def\CALX_nshr_b #1.#2.#3#4.#5\xint:%
{%
    \ifnum#1<#4 \xint_dothis{\expandafter\CALX_nshr_c\the\numexpr#2-%
        \xint_c_viii*#1.#1.#3#4.{#5}}\fi
    \xint_orthat{ N+0.}%
}%
\def\CALX_nshr_c #1.#2.#3#4.#5%
{%
    \ifnum#1=\xint_c_
      \xint_dothis{\CALX_nskip\CALX_nshr_z#2.#51;;;;;;;;!\xint:{#3}{#4-#2}}\fi
    \xint_orthat{\expandafter\CALX_nshr_o\expanded{\expandafter\CALX_nskip
      \csname CALX_nshr_f#1\endcsname#2.#51;;;;;;;;!}%
          \xint:{#3}{#4-#2}}%
}%
\def\CALX_nshr_z #11;;;;;;;;!\xint:#2#3{\expanded{ N#2\the\numexpr#3.}#1}%
\def\CALX_nshr_o #1\relax#2\xint:#3#4%
{%
    \ifnum\numexpr#4-#2=\xint_c_ \xint_dothis{ N+0.}\fi
    \xint_orthat{\expanded{ N#3\the\numexpr#4-#2.}#1}%
}%
\def\CALX_nshl #1#2{\expandafter\CALX_nsh_t\expandafter\CALX_nshl_a\the%
    \numexpr#1\expandafter.\romannumeral`&&@#2\xint:}%
\def\CALX_nshl_a #1.N#2#3.#4\xint:%
{%
    \ifnum#3=\xint_c_ \CALX_nsh_zero\fi
    \ifnum#1<\xint_c_i \CALX_nsh_id\fi
    \expandafter\CALX_nshl_b\the\numexpr(#1-\xint_c_iv)/\xint_c_viii.%
    #1.#2#3.#4\xint:
}%
\def\CALX_nshl_b #1.#2.#3#4.#5\xint:%
   {\expandafter\CALX_nshl_c\the\numexpr#2-\xint_c_viii*#1.#1.#3#4.#5\xint:}%
\def\CALX_nshl_c #1.#2.#3#4.#5\xint:%
{%
    \ifnum#1=\xint_c_
      \xint_dothis{\expanded{ N#3\the\numexpr#4+#2.\romannumeral%
          \xintreplicate{#2}{100000000!}}#5}\fi
    \xint_orthat{\expandafter\CALX_nshl_o\expanded{%
      \romannumeral\xintreplicate{#2}{100000000!}%
      \csname CALX_nshl_l#1\endcsname{\romannumeral%
          \xintreplicate{#1}0}%
      #51;;;;;;;;!}\xint:{#3}{#4+#2}}%
}%
\def\CALX_nshl_o #1\relax#2\xint:#3#4{\expanded{ N#3\the\numexpr#4+#2.}#1}%
\def\CALX_nshrr #1#2{\expandafter\CALX_nsh_t\expandafter\CALX_nshrr_a\the%
    \numexpr#1\expandafter.\romannumeral`&&@#2\xint:}%
\def\CALX_nshrr_a #1.N#2#3.#4\xint:%
{%
    \ifnum#1<\xint_c_i \xint_dothis{ N#2#3.#4}\fi
    \ifnum#3=\xint_c_ \xint_dothis{ N+0.}\fi
    \ifnum#1>\numexpr\xint_c_viii*#3\relax \xint_dothis{ N+0.}\fi
    \xint_orthat{\expandafter\CALX_nshrr_b\the\numexpr
      \CALX_nskip\CALX_nshrr_d(\xint_c_ii*#1-9)/16.#41;!%
      #1-\xint_c_i-\xint_c_viii*((\xint_c_ii*#1-9)/16).%
      #1.N#2#3.#4\xint:}%
}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_nshrr_d 1<block>!<rest>1;!<p>. (inside \numexpr) gives the digit p
% from the right of the block followed by a full stop; on the sentinel 1;!
% (block beyond the number) it gives 0. With y = 10^p, floor(b/y) =
% (b+y/2)/y-1 for p > 0 (y even), q mod 10 = q-10((q+5)/10-1).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nshrr_d 1#1!{\xint_gob_til_sc#1\CALX_nshrr_dz;\CALX_nshrr_dn{#1}}%
\def\CALX_nshrr_dz;\CALX_nshrr_dn#1#2.{0.}%
\def\CALX_nshrr_dn #1#21;!#3.%
{%
    \ifnum\numexpr#3=\xint_c_
      \xint_dothis{(#1-((#1+5)/10-1)*10).}\fi
    \xint_orthat{\CALX_nshrr_dq{\CALX_pten{#3}}{#1}}%
}%
\def\CALX_nshrr_dq #1#2%
   {(((#2+#1/2)/#1-1)-((((#2+#1/2)/#1-1)+5)/10-1)*10).}%
\def\CALX_nshrr_b #1.#2.#3\xint:%
{%
    \ifnum#1>\xint_c_iv
      \xint_dothis{\expandafter\CALX_nshrr_up\romannumeral0\CALX_nshr{#2}{#3}%
          \xint:#3\xint:}\fi
    \xint_orthat{\CALX_nshr{#2}{#3}}%
}%
\def\CALX_nshrr_up N#1#2\xint:N#3#4\xint:%
   {\CALX_nadd{N#1#2}{N#31.100000001!}}%
\expandafter\def\csname CALX_nshr_f1\endcsname
   1#1#2#3#4#5#6#7#8!{\CALX_nshr_li{#1#2#3#4#5#6#7}}%
\def\CALX_nshr_li #11#2#3#4#5#6#7#8#9!%
   {\xint_gob_til_sc#2\CALX_nshr_ei;1#9#1!\CALX_nshr_li{#2#3#4#5#6#7#8}}%
\def\CALX_nshr_ei;1;#1!#2#3%
   {\ifnum#1=\xint_c_ \relax1\else 10#1!\relax0\fi}%
\def\CALX_nshl_li #11#2#3#4#5#6#7#8#9!%
   {\xint_gob_til_sc#2\CALX_nshl_ei;1#3#4#5#6#7#8#9#1!\CALX_nshl_li{#2}}%
\def\CALX_nshl_ei;1;;;;;;;#1!#2#3%
   {\ifnum#1=\xint_c_ \relax0\else 10000000#1!\relax1\fi}%
\expandafter\def\csname CALX_nshr_f2\endcsname
   1#1#2#3#4#5#6#7#8!{\CALX_nshr_lii{#1#2#3#4#5#6}}%
\def\CALX_nshr_lii #11#2#3#4#5#6#7#8#9!%
   {\xint_gob_til_sc#2\CALX_nshr_eii;1#8#9#1!\CALX_nshr_lii{#2#3#4#5#6#7}}%
\def\CALX_nshr_eii;1;;#1!#2#3%
   {\ifnum#1=\xint_c_ \relax1\else 100#1!\relax0\fi}%
\def\CALX_nshl_lii #11#2#3#4#5#6#7#8#9!%
   {\xint_gob_til_sc#2\CALX_nshl_eii;1#4#5#6#7#8#9#1!\CALX_nshl_lii{#2#3}}%
\def\CALX_nshl_eii;1;;;;;;#1!#2#3%
   {\ifnum#1=\xint_c_ \relax0\else 1000000#1!\relax1\fi}%
\expandafter\def\csname CALX_nshr_f3\endcsname
   1#1#2#3#4#5#6#7#8!{\CALX_nshr_liii{#1#2#3#4#5}}%
\def\CALX_nshr_liii #11#2#3#4#5#6#7#8#9!%
   {\xint_gob_til_sc#2\CALX_nshr_eiii;1#7#8#9#1!\CALX_nshr_liii{#2#3#4#5#6}}%
\def\CALX_nshr_eiii;1;;;#1!#2#3%
   {\ifnum#1=\xint_c_ \relax1\else 1000#1!\relax0\fi}%
\def\CALX_nshl_liii #11#2#3#4#5#6#7#8#9!%
   {\xint_gob_til_sc#2\CALX_nshl_eiii;1#5#6#7#8#9#1!\CALX_nshl_liii{#2#3#4}}%
\def\CALX_nshl_eiii;1;;;;;#1!#2#3%
   {\ifnum#1=\xint_c_ \relax0\else 100000#1!\relax1\fi}%
\expandafter\def\csname CALX_nshr_f4\endcsname
   1#1#2#3#4#5#6#7#8!{\CALX_nshr_liv{#1#2#3#4}}%
\def\CALX_nshr_liv #11#2#3#4#5#6#7#8#9!%
   {\xint_gob_til_sc#2\CALX_nshr_eiv;1#6#7#8#9#1!\CALX_nshr_liv{#2#3#4#5}}%
\def\CALX_nshr_eiv;1;;;;#1!#2#3%
   {\ifnum#1=\xint_c_ \relax1\else 10000#1!\relax0\fi}%
\def\CALX_nshl_liv #11#2#3#4#5#6#7#8#9!%
   {\xint_gob_til_sc#2\CALX_nshl_eiv;1#6#7#8#9#1!\CALX_nshl_liv{#2#3#4#5}}%
\def\CALX_nshl_eiv;1;;;;#1!#2#3%
   {\ifnum#1=\xint_c_ \relax0\else 10000#1!\relax1\fi}%
\expandafter\def\csname CALX_nshr_f5\endcsname
   1#1#2#3#4#5#6#7#8!{\CALX_nshr_lv{#1#2#3}}%
\def\CALX_nshr_lv #11#2#3#4#5#6#7#8#9!%
   {\xint_gob_til_sc#2\CALX_nshr_ev;1#5#6#7#8#9#1!\CALX_nshr_lv{#2#3#4}}%
\def\CALX_nshr_ev;1;;;;;#1!#2#3%
   {\ifnum#1=\xint_c_ \relax1\else 100000#1!\relax0\fi}%
\def\CALX_nshl_lv #11#2#3#4#5#6#7#8#9!%
   {\xint_gob_til_sc#2\CALX_nshl_ev;1#7#8#9#1!\CALX_nshl_lv{#2#3#4#5#6}}%
\def\CALX_nshl_ev;1;;;#1!#2#3%
   {\ifnum#1=\xint_c_ \relax0\else 1000#1!\relax1\fi}%
\expandafter\def\csname CALX_nshr_f6\endcsname
   1#1#2#3#4#5#6#7#8!{\CALX_nshr_lvi{#1#2}}%
\def\CALX_nshr_lvi #11#2#3#4#5#6#7#8#9!%
   {\xint_gob_til_sc#2\CALX_nshr_evi;1#4#5#6#7#8#9#1!\CALX_nshr_lvi{#2#3}}%
\def\CALX_nshr_evi;1;;;;;;#1!#2#3%
   {\ifnum#1=\xint_c_ \relax1\else 1000000#1!\relax0\fi}%
\def\CALX_nshl_lvi #11#2#3#4#5#6#7#8#9!%
   {\xint_gob_til_sc#2\CALX_nshl_evi;1#8#9#1!\CALX_nshl_lvi{#2#3#4#5#6#7}}%
\def\CALX_nshl_evi;1;;#1!#2#3%
   {\ifnum#1=\xint_c_ \relax0\else 100#1!\relax1\fi}%
\expandafter\def\csname CALX_nshr_f7\endcsname
   1#1#2#3#4#5#6#7#8!{\CALX_nshr_lvii{#1}}%
\def\CALX_nshr_lvii #11#2#3#4#5#6#7#8#9!%
   {\xint_gob_til_sc#2\CALX_nshr_evii;1#3#4#5#6#7#8#9#1!\CALX_nshr_lvii{#2}}%
\def\CALX_nshr_evii;1;;;;;;;#1!#2#3%
   {\ifnum#1=\xint_c_ \relax1\else 10000000#1!\relax0\fi}%
\def\CALX_nshl_lvii #11#2#3#4#5#6#7#8#9!%
   {\xint_gob_til_sc#2\CALX_nshl_evii;1#9#1!\CALX_nshl_lvii{#2#3#4#5#6#7#8}}%
\def\CALX_nshl_evii;1;#1!#2#3%
   {\ifnum#1=\xint_c_ \relax0\else 10#1!\relax1\fi}%
\expandafter\let\csname CALX_nshl_l1\endcsname\CALX_nshl_li
\expandafter\let\csname CALX_nshl_l2\endcsname\CALX_nshl_lii
\expandafter\let\csname CALX_nshl_l3\endcsname\CALX_nshl_liii
\expandafter\let\csname CALX_nshl_l4\endcsname\CALX_nshl_liv
\expandafter\let\csname CALX_nshl_l5\endcsname\CALX_nshl_lv
\expandafter\let\csname CALX_nshl_l6\endcsname\CALX_nshl_lvi
\expandafter\let\csname CALX_nshl_l7\endcsname\CALX_nshl_lvii
%    \end{macrocode}
% \subsection{Interface for \xintexprnameimp usage}
%\begin{lverb}
% Attention: N and I are STILL of catcode 12.  We now also make M of catcode
% 12. Be extra careful with macro names.
%
% The integer type of \xintiieval: M<s><n>.<e>.<blocks>, the value of
% the N value N<s><n>.<blocks> (n blocks 1dddddddd!, least significant
% first) times 10^(8e), e >= 0, lowest block non-zero; zero is M+0.0.
% \CALX_ntom: N value (blocks in the stream) to M, the low zero blocks
% go into e. \CALX_mfromraw: raw integer (xintcore format) to M.
% \CALX_mtoraw: M to raw integer, 8e zeros written out.
% \CALX_ntomd d.N...: as \CALX_ntom, e starting at d; \CALX_ntoms: same,
% special values (I...) passed as they are.
%
% Syntax of the entry points (A, B, X f-expanded; M, I values, or raw
% integers converted on entry; R a raw integer):
%(
%  \CALX_ntom N<s><n>.<blocks>       -> <space>M<s><n'>.<e>.<blocks'>
%:  \CALX_ntomd d.N<s><n>.<blocks>    -> the same, e counted from d
%:  \CALX_mfromraw{R}                 -> <space>M...
%:  \CALX_mtoraw{X}                   -> <raw integer>    (X an M value)
%:  \CALX_tom{X}                     -> <space>M...\xint: or <space>I<s>\xint:
%:  \CALX_mr{X}                       -> <raw integer> (X M, A, A[N] N >= 0),
%:                                        X otherwise (I, A[N] N < 0)
%:  \CALX_mrl <item>...<item>^        -> {\CALX_mr{<item>}}...  (in \expanded)
%:  \CALX_ii<op>{A}{B}, \CALX_ii<op>{X}  -> <space>M... or <space>I<s>
%:  \calxii<Name>{A}{B}, \calxii<Name>{X} -> M... or I<s>   (f-expandable)
%:  \CALX_iilit{A}{N}                 -> <space>M..., or <space>A[N]
%)
% \CALX_ntom, \CALX_ntomd, \CALX_mfromraw, \CALX_mtoraw, \CALX_tom and the
% \CALX_ii<op> are used with \romannumeral0. The comparisons \calxiiLt,
% \calxiiGt, \calxiiLtorEq, \calxiiGtorEq, \calxiiEq, \calxiiNotEq give
% raw 1 or 0; \calxiiDivMod gives {Q}{R}; \calxiiPow{A}{k}.
%
% M layer (used as \romannumeral0\CALX_ii<op>{A}{B}, results M or I):
% \CALX_tom{X}: X f-expanded; M left as it is (the tag re-emitted with
% the catcode of this block: a value compiled in a user function may
% carry another one), raw integer converted; A[N] with N >= 0: A
% followed by N zeros (\CALX_tom_w); A[N] with N < 0 and A/B[N]:
% \CALX_tom_x, integer check (error, then truncation) by one
% native division (\CALX_iiq: A 10^max(N,0) by B 10^max(-N,0), B > 0;
% an integer iff the remainder is zero; truncation = floor quotient, plus
% one if negative); I+, I-, I? left as they are; \xint: follows.
% \CALX_iitwo<cont><spcont>{A}{B} hands M(A)\xint:M(B)\xint: to <cont>,
% or the same with an I value to <spcont> (tag test \CALX_iitwo_b).
% Special values propagate as in the N kernels (rules of calxcore):
% \CALX_iisp_g<fin><kernel> calls the N kernel on the operands, M ones
% converted with their e zero blocks written out (\CALX_mton), result
% through \CALX_ntoms (I kept). Unary ops: \CALX_iiun<Mcont><Icont>;
% opp, abs, sqr act on the I sign, isqrt calls \CALX_nsqrtrem, ^ with an
% I base: k = 0 gives 1, I? stays, k < 0 gives 0, else I+ or I- (odd k,
% I- base). Comparisons with an I? operand: InvalidOperation, 0 (== is
% false, != true, no signal); infinities ordered by \CALX_icl<tag><sign>.
% mul, sqr: e1+e2 (2e), N kernel
% \CALX_nmul. add, sub and the division family (divtrunc, modtrunc,
% divfloor, mod, quo, rem, divround, division, divmod, kernels
% \CALX_n... of calxcore): with d = min(e1,e2) the operand of larger e
% gets e - d zero blocks; the quotient has e = 0, a sum or remainder
% e = d. opp, abs: sign token. isqrt: all e zero blocks written out
% (\CALX_nsqrtrem), result e = 0.
%
% \xintiieval. Literals (receivers of the scanner's fake operators):
% digits to M (\CALX_mfromraw); with [N] (decimal mark, exponent, raw
% [N]): \CALX_iilit, M if the value is an
% integer, else the raw A[N] (for num(), round(), trunc()); in compiled
% functions (\XINT_expr_redefinemacros) literals stay raw. Operators
% and functions: \calxii<Name>, one token each (needed by the
% \xintdeffunc hooks). Native: Add, Sub, Mul, Sqr, Opp, Abs, Sqrt,
% DivFloor (//), Mod (/:), DivRound (/), Quo, Rem, DivMod, Pow and the
% comparisons. Pow (^): k = \numexpr of the exponent, \CALX_npow on the
% blocks only, result exponent e k; k < 0 (\CALX_ipr<class of the base>):
% 1 for 1, (-1)^k for -1, DivisionByZero (I+) for 0, Underflow (0)
% otherwise. Lt, Gt, LtorEq, GtorEq: keys
% s (n + e) (s the sign, 0 for zero) compared first; equal keys: the
% blocks if n = 1 for both, else the sign of the difference
% (\CALX_iisub_x); the three result digits for equal, greater, less
% follow the arguments. Eq, NotEq: \xintstrcmp of the canonical M
% values. Comparisons give raw 1 or 0. ^ with an I exponent: IEEE pow
% (\CALX_iipow_e, table \CALX_ipe<sign of exponent><class of base>,
% classes o (1), m (-1), z (0), b (other), i (I+, I-), n (I?)). Integer
% functions on M values (an I argument signals InvalidOperation, result
% I?): Fac (\CALX_nfac; negative or > 10^4: InvalidOperation), Odd, Even
% (parity of the lowest block if e = 0), IsOne, ifOne (an I argument
% selects the second branch), LogTen (8(n+e) - 9 + digits of the top
% block; zero: -"7FFF8000 as xint), SqrtR (\CALX_nsqrtrem: S + 1 iff
% R > S). On the \numexpr values of raw arguments (\CALX_mrd; \CALX_mr:
% M to raw digits, other values as they are): Binomial (\CALX_binom_a,
% native, by \CALX_ntom), PFactorial (\CALX_npfac), with xint's argument
% rules and InvalidOperation for the out of range cases. Raw output from
% xint macros: Round, Trunc (digit count), SeqB:tl:x (a..[d]..b). Lists:
% gcd, lcm: Burnol's \XINT_iigcdof/\XINT_iilcmof loops (delimiter \xint:
% instead of !, which occurs in M values) on \CALX_iigcd, \CALX_iilcm, of
% the native \CALX_ngcd, \CALX_nlcm
% (Euclid's algorithm by \CALX_nrem; the M versions factor out the common
% power 10^(8 min(e1,e2))); an I item: InvalidOperation, I?. `+`, `*`:
% Burnol's \XINT_sum/\XINT_prd loops (xintfrac) on \CALX_iiadd,
% \CALX_iimul (empty: 0, 1); max, min: Burnol's \XINT_iimaxof/\XINT_iiminof
% loops on \CALX_iimax, \CALX_iimin (the native comparisons; each item
% f-expanded once, the values returned expanded), an
% unordered comparison (I?) signals InvalidOperation and keeps the
% current value (as \calxFpMaxof). Printers:
% \xintiiexprPrintOne(Hex/Oct/Bin) through \CALX_mr.
%\end{lverb}
%    \begin{macrocode}
\catcode`M=12
\def\CALX_ntom {\CALX_ntomd 0.}%
\def\CALX_ntomd #1.N#2#3.%
{%
    \ifnum#3=\xint_c_ \xint_dothis{ M+0.0.}\fi
    \xint_orthat{\CALX_ntom_a#2#3.#1.}%
}%
\def\CALX_ntom_a #1#2.#3.#4!%
{%
    \ifnum#4=\xint_c_e_viii
      \xint_dothis{\expandafter\CALX_ntom_a\expandafter#1%
        \the\numexpr#2-\xint_c_i\expandafter.\the\numexpr#3+\xint_c_i.}\fi
    \xint_orthat{ M#1#2.#3.#4!}%
}%
\def\CALX_mfromraw%
   {\expandafter\CALX_ntom\romannumeral0\CALX_nfromraw}%
\def\CALX_mtoraw #1{\expandafter\CALX_mtoraw_t\romannumeral`&&@#1\xint:}%
\def\CALX_mtoraw_t #1{\CALX_mtoraw_a M}%
\def\CALX_mtoraw_a M#1#2.#3.%
{%
    \ifnum#3=\xint_c_ \xint_dothis{\CALX_ntoraw_a N#1#2.}\fi
    \xint_orthat{\CALX_mtoraw_b{#3}N#1#2.}%
}%
\def\CALX_mtoraw_b #1#2\xint:%
   {\expanded{ \romannumeral0\CALX_ntoraw_a#2\xint:%
               \xintReplicate{\xint_c_viii*#1}0}}%
\def\CALX_infr_m #1{\CALX_infr_b #1\xint:}%
\def\CALX_infr_b #1#2#3.#4.#5\xint:%
   {\expandafter\CALX_infr_c\the\numexpr\xint_c_viii*#4\expandafter.%
    \romannumeral0\CALX_ntoraw_a N#2#3.#5\xint:.}%
\def\CALX_infr_c #1.#2.{{#1}{#2}{1}}%
\def\CALX_ntoms #1.#2%
   {\if I#2\xint_dothis{ #2}\fi\xint_orthat{\CALX_ntomd#1.#2}}%
\def\CALX_tom #1{\expandafter\CALX_tom_a\romannumeral`&&@#1\xint:}%
\def\CALX_tom_a #1%
   {\if M#1\xint_dothis{ M}\fi\if I#1\xint_dothis{ #1}\fi
    \xint_orthat{\CALX_tom_r#1}}%
\def\CALX_tom_r #1\xint:{\CALX_tom_s #1[.\xint:}%
\def\CALX_tom_s #1[#2{\xint_gob_til_dot#2\CALX_tom_b.\CALX_tom_k #2#1[}%
\def\CALX_tom_b.\CALX_tom_k.#1[\xint:%
   {\expandafter\CALX_ntom\romannumeral0\CALX_nfromraw_a#1\xint:\xint:}%
\def\CALX_tom_k #1%
{%
    \xint_UDsignfork
        #1\CALX_tom_neg
         -\CALX_tom_p
    \krof #1%
}%
\def\CALX_tom_neg -#1[#2][.\xint:{\CALX_tom_z #1/1/\xint:{-#2}{#1[-#2]}}%
\def\CALX_tom_p #1#2[#3][.\xint:{\CALX_tom_v #1#3.#2/\xint:}%
\def\CALX_tom_v #1.#2/#3%
   {\xint_gob_til_xint:#3\CALX_tom_w\xint:\CALX_tom_x #1.#2/#3}%
\def\CALX_tom_w\xint:\CALX_tom_x #1.#2/\xint:%
   {\expandafter\CALX_ntom\romannumeral0\expandafter\CALX_nfromraw_a
    \expanded{#2\xintReplicate{#1}0}\xint:\xint:}%
\def\CALX_iitwo #1#2#3#4%
   {\expandafter\CALX_iitwo_a\expandafter#1\expandafter#2%
    \romannumeral0\CALX_tom{#4}{#3}}%
\def\CALX_iitwo_a #1#2#3#4\xint:#5%
   {\expandafter\CALX_iitwo_b\expandafter#1\expandafter#2\expandafter#3%
    \romannumeral0\CALX_tom{#5}#3#4\xint:}%
\def\CALX_iitwo_b #1#2#3#4%
   {\if\if M#4#3\else ?\fi M\expandafter#1\else\expandafter#2\fi #4}%
\def\CALX_iisp_g #1#2#3\xint:#4\xint:%
   {#1 0.{#2{\CALX_mton#3\xint:}{\CALX_mton#4\xint:}}}%
\def\CALX_mton #1#2\xint:%
   {\if M#1\xint_dothis{\CALX_mton_m#2\xint:}\fi\xint_orthat{#1#2}}%
\def\CALX_mton_m #1#2.#3.#4\xint:%
   {\expanded{N#1\the\numexpr#2+#3.\xintReplicate{#3}{100000000!}#4}}%
\def\CALX_iiun #1#2#3{\if I#3\expandafter#2\else\expandafter#1\fi #3}%
\def\CALX_iimul {\CALX_iitwo\CALX_iimul_x\CALX_iimul_sp}%
\def\CALX_iimul_sp {\CALX_iisp_g\CALX_iifq\CALX_nmul}%
\def\CALX_iimul_x M#1#2.#3.#4\xint:M#5#6.#7.#8\xint:%
   {\expandafter\CALX_ntomd\the\numexpr#3+#7\expandafter.%
    \romannumeral0\CALX_nmul{N#1#2.#4}{N#5#6.#8}}%
\def\CALX_iisqr{\expandafter\CALX_iiun\expandafter\CALX_iisqr_x
   \expandafter\CALX_iiabs_i\romannumeral0\CALX_tom}%
\def\CALX_iisqr_x M#1#2.#3.#4\xint:%
   {\expandafter\CALX_ntomd\the\numexpr\xint_c_ii*#3\expandafter.%
    \romannumeral0\CALX_nmul{N+#2.#4}{N+#2.#4}}%
\def\CALX_iiopp{\expandafter\CALX_iiun\expandafter\CALX_iiopp_x
   \expandafter\CALX_iiopp_i\romannumeral0\CALX_tom}%
\def\CALX_iiopp_i #1#2\xint:%
   {\if ?#2\xint_dothis{ #1#2}\fi\if -#2\xint_dothis{ #1+}\fi
    \xint_orthat{ #1-}}%
\def\CALX_iiopp_x M#1#2#3\xint:%
   {\if0#2\xint_dothis{ M#1#2#3}\fi
    \if-#1\xint_dothis{ M+#2#3}\fi
    \xint_orthat{ M-#2#3}}%
\def\CALX_iiabs{\expandafter\CALX_iiun\expandafter\CALX_iiabs_x
   \expandafter\CALX_iiabs_i\romannumeral0\CALX_tom}%
\def\CALX_iiabs_i #1#2\xint:%
   {\if ?#2\xint_dothis{ #1#2}\fi\xint_orthat{ #1+}}%
\def\CALX_iiabs_x M#1#2\xint:{ M+#2}%
\def\CALX_iisqrt {\CALX_iisq\CALX_iisqrt_f}%
\def\CALX_iisqrtr{\CALX_iisq\CALX_iisqrtr_f}%
\def\CALX_iisq #1#2{\expandafter\CALX_iiun\expandafter\CALX_iisqrt_x
   \expandafter\CALX_iisqrt_i\romannumeral0\CALX_tom{#2}#1}%
\def\CALX_iisqrt_i #1\xint:#2%
   {\expandafter#2\romannumeral0\CALX_nsqrtrem{#1}}%
\def\CALX_iisqrt_x M#1#2.#3.#4\xint:#5%
{%
    \ifnum#3=\xint_c_
      \xint_dothis{\expandafter#5\romannumeral0\CALX_nsqrtrem{N#1#2.#4}}\fi
    \xint_orthat{\expandafter#5\romannumeral0\CALX_nsqrtrem
       {\expanded{N#1\the\numexpr#2+#3.\xintReplicate{#3}{100000000!}#4}}}%
}%
\def\CALX_iisqrt_f #1#2{\CALX_ntoms0.#1}%
\def\CALX_iisqrtr_f #1{\CALX_iisqrtr_a #1\xint:}%
\def\CALX_iisqrtr_a #1{%
    \if I#1\xint_dothis\CALX_iisqrtr_i\fi
    \xint_orthat\CALX_iisqrtr_n #1%
}%
\def\CALX_iisqrtr_i #1#2\xint:#3{ #1#2}%
\def\CALX_iisqrtr_n #1#2\xint:#3{%
    \expandafter\CALX_iisqrtr_g
      \romannumeral0\CALX_nsub{#3}{#1#2}\xint:{#1#2}%
}%
\def\CALX_iisqrtr_g N#1#2.#3\xint:#4%
{%
    \if-#1\xint_dothis{\CALX_ntomd0.#4}\fi
    \ifnum#2=\xint_c_ \xint_dothis{\CALX_ntomd0.#4}\fi
    \xint_orthat{\expandafter\CALX_ntom
      \romannumeral0\CALX_nadd{#4}{N+1.100000001!}}%
}%
\def\CALX_iifa #1.#2%
   {\expandafter\CALX_ntomd\the\numexpr#1\expandafter.\romannumeral0#2}%
\def\CALX_iifq #1.#2%
   {\expandafter\CALX_ntoms\expandafter0\expandafter.\romannumeral0#2}%
\def\CALX_iifr #1.#2%
   {\expandafter\CALX_ntoms\the\numexpr#1\expandafter.\romannumeral0#2}%
\def\CALX_iifp #1.#2{\expandafter\CALX_iifp_a\romannumeral0#2{#1}}%
\def\CALX_iifp_a #1#2#3%
   {\expanded{ {\romannumeral0\CALX_ntoms0.#1}%
               {\romannumeral0\CALX_ntoms#3.#2}}}%
\def\CALX_iiadd{\CALX_iitwo\CALX_iiadd_x\CALX_iiadd_sp}%
\def\CALX_iiadd_sp{\CALX_iisp_g\CALX_iifq\CALX_nadd}%
\def\CALX_iiadd_x M#1.#2.#3\xint:M#4.#5.%
{%
    \expandafter\CALX_iiadd_x_a\the\numexpr#2-#5.#2.M#1.#3\xint:M#4.%
}%
\def\CALX_iiadd_x_a #1%
{%
    \xint_UDzerominusfork
       #1-\CALX_iiadd_x_eq
       0#1\CALX_iiadd_x_lt
       0-\CALX_iiadd_x_gt
    \krof #1%
}%
\def\CALX_iiadd_x_eq 0.#1.M#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntomd\the\numexpr#1\expandafter.%
    \romannumeral0\CALX_nadd_y N#2\xint: N#31;!1;!1;!1;!\W\xint:
}%
\def\CALX_iiadd_x_lt -#1.#2.M#3\xint:M#4#5.#6\xint:
{%
    \expandafter\CALX_ntomd\the\numexpr#2\expandafter.%
    \romannumeral0\expandafter\CALX_nadd_y
        \expanded{N#4\the\numexpr#1+#5.%
        \xintReplicate{#1}{100000000!}}#6\xint:N#31;!1;!1;!1;!\W\xint:
}%
\def\CALX_iiadd_x_gt #1.#2.M#3#4.#5\xint:M#6\xint:
{%
    \expandafter\CALX_ntomd\the\numexpr#2-#1\expandafter.%
    \romannumeral0\expandafter\CALX_nadd_y
       \expanded{N#3\the\numexpr#1+#4.%
       \xintReplicate{#1}{100000000!}}#5\xint:N#61;!1;!1;!1;!\W\xint:
}%
\def\CALX_iisub{\CALX_iitwo\CALX_iisub_x\CALX_iisub_sp}%
\def\CALX_iisub_sp{\CALX_iisp_g\CALX_iifq\CALX_nsub}%
\def\CALX_iisub_x M#1.#2.#3\xint:M#4.#5.%
{%
    \expandafter\CALX_iisub_x_a\the\numexpr#2-#5.#2.M#1.#3\xint:M#4.%
}%
\def\CALX_iisub_x_a #1%
{%
    \xint_UDzerominusfork
       #1-\CALX_iisub_x_eq
       0#1\CALX_iisub_x_lt
       0-\CALX_iisub_x_gt
    \krof #1%
}%
\def\CALX_iisub_x_eq 0.#1.M#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntomd\the\numexpr#1\expandafter.%
    \romannumeral0\CALX_nsub_y N#3\xint: N#21;!1;!1;!1;!\W\xint:
}%
\def\CALX_iisub_x_lt -#1.#2.M#3\xint:M#4#5.#6\xint:
{%
    \expandafter\CALX_ntomd\the\numexpr#2\expandafter.%
    \romannumeral0\expandafter\CALX_nsub_y
        \expanded{N#4\the\numexpr#1+#5.%
        \xintReplicate{#1}{100000000!}}#6\xint:N#31;!1;!1;!1;!\W\xint:
}%
\def\CALX_iisub_x_gt #1.#2.M#3#4.%
{%
    \expandafter\CALX_iisub_x_gt_b\expanded{\the\numexpr#2-#1.%
       N#3\the\numexpr#1+#4.\xintReplicate{#1}{100000000!}}%
}%
\def\CALX_iisub_x_gt_b #1.#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntomd\the\numexpr#1\expandafter.%
    \romannumeral0\CALX_nsub_y N#3\xint:#21;!1;!1;!1;!\W\xint:
}%
\def\CALX_iidivtrunc{\CALX_iitwo\CALX_iidivtrunc_x\CALX_iidivtrunc_sp}%
\def\CALX_iidivtrunc_sp{\CALX_iisp_g\CALX_iifq\CALX_ndivtrunc}%
\def\CALX_iidivtrunc_x M#1.#2.#3\xint:M#4.#5.%
{%
    \expandafter\CALX_iidivtrunc_x_a\the\numexpr#2-#5.#2.M#1.#3\xint:M#4.%
}%
\def\CALX_iidivtrunc_x_a #1%
{%
    \xint_UDzerominusfork
       #1-\CALX_iidivtrunc_x_eq
       0#1\CALX_iidivtrunc_x_lt
       0-\CALX_iidivtrunc_x_gt
    \krof #1%
}%
\def\CALX_iidivtrunc_x_eq 0.#1.M#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntoms\expandafter0\expandafter.%
    \romannumeral0\CALX_ndiv_y N#3\xint:N#2\xint:%
       \CALX_ndt_go%
       \CALX_ndiv_zq\CALX_ndiv_zz
}%
\def\CALX_iidivtrunc_x_lt -#1.#2.M#3\xint:M#4#5.#6\xint:
{%
    \expandafter\CALX_ntoms\expandafter0\expandafter.%
    \romannumeral0\expandafter\CALX_ndiv_y
        \expanded{N#4\the\numexpr#1+#5.%
        \xintReplicate{#1}{100000000!}}#6\xint:N#3\xint:%
       \CALX_ndt_go%
       \CALX_ndiv_zq\CALX_ndiv_zz
}%
\def\CALX_iidivtrunc_x_gt #1.#2.M#3#4.%
{%
    \expandafter\CALX_iidivtrunc_x_gt_b\expanded{\the\numexpr#2-#1.%
       N#3\the\numexpr#1+#4.\xintReplicate{#1}{100000000!}}%
}%
\def\CALX_iidivtrunc_x_gt_b #1.#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntoms\expandafter0\expandafter.%
    \romannumeral0\CALX_ndiv_y N#3\xint:#2\xint:%
       \CALX_ndt_go%
       \CALX_ndiv_zq\CALX_ndiv_zz
}%
\def\CALX_iimodtrunc{\CALX_iitwo\CALX_iimodtrunc_x\CALX_iimodtrunc_sp}%
\def\CALX_iimodtrunc_sp{\CALX_iisp_g\CALX_iifq\CALX_nmodtrunc}%
\def\CALX_iimodtrunc_x M#1.#2.#3\xint:M#4.#5.%
{%
    \expandafter\CALX_iimodtrunc_x_a\the\numexpr#2-#5.#2.M#1.#3\xint:M#4.%
}%
\def\CALX_iimodtrunc_x_a #1%
{%
    \xint_UDzerominusfork
       #1-\CALX_iimodtrunc_x_eq
       0#1\CALX_iimodtrunc_x_lt
       0-\CALX_iimodtrunc_x_gt
    \krof #1%
}%
\def\CALX_iimodtrunc_x_eq 0.#1.M#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntoms\the\numexpr#1\expandafter.%
    \romannumeral0\CALX_ndiv_y N#3\xint:N#2\xint:%
       \CALX_nmt_go%
       \CALX_ndiv_zr\CALX_ndiv_zz
}%
\def\CALX_iimodtrunc_x_lt -#1.#2.M#3\xint:M#4#5.#6\xint:
{%
    \expandafter\CALX_ntoms\the\numexpr#2\expandafter.%
    \romannumeral0\expandafter\CALX_ndiv_y
        \expanded{N#4\the\numexpr#1+#5.%
        \xintReplicate{#1}{100000000!}}#6\xint:N#3\xint:%
       \CALX_nmt_go%
       \CALX_ndiv_zr\CALX_ndiv_zz
}%
\def\CALX_iimodtrunc_x_gt #1.#2.M#3#4.%
{%
    \expandafter\CALX_iimodtrunc_x_gt_b\expanded{\the\numexpr#2-#1.%
       N#3\the\numexpr#1+#4.\xintReplicate{#1}{100000000!}}%
}%
\def\CALX_iimodtrunc_x_gt_b #1.#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntoms\the\numexpr#1\expandafter.%
    \romannumeral0\CALX_ndiv_y N#3\xint:#2\xint:%
       \CALX_nmt_go%
       \CALX_ndiv_zr\CALX_ndiv_zz
}%
\def\CALX_iidivfloor{\CALX_iitwo\CALX_iidivfloor_x\CALX_iidivfloor_sp}%
\def\CALX_iidivfloor_sp{\CALX_iisp_g\CALX_iifq\CALX_ndivfloor}%
\def\CALX_iidivfloor_x M#1.#2.#3\xint:M#4.#5.%
{%
    \expandafter\CALX_iidivfloor_x_a\the\numexpr#2-#5.#2.M#1.#3\xint:M#4.%
}%
\def\CALX_iidivfloor_x_a #1%
{%
    \xint_UDzerominusfork
       #1-\CALX_iidivfloor_x_eq
       0#1\CALX_iidivfloor_x_lt
       0-\CALX_iidivfloor_x_gt
    \krof #1%
}%
\def\CALX_iidivfloor_x_eq 0.#1.M#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntoms\expandafter0\expandafter.%
    \romannumeral0\CALX_ndiv_y N#3\xint:N#2\xint:%
       \CALX_ndf_go%
       \CALX_ndiv_zq\CALX_ndiv_zz
}%
\def\CALX_iidivfloor_x_lt -#1.#2.M#3\xint:M#4#5.#6\xint:
{%
    \expandafter\CALX_ntoms\expandafter0\expandafter.%
    \romannumeral0\expandafter\CALX_ndiv_y
        \expanded{N#4\the\numexpr#1+#5.%
        \xintReplicate{#1}{100000000!}}#6\xint:N#3\xint:%
       \CALX_ndf_go%
       \CALX_ndiv_zq\CALX_ndiv_zz
}%
\def\CALX_iidivfloor_x_gt #1.#2.M#3#4.%
{%
    \expandafter\CALX_iidivfloor_x_gt_b\expanded{\the\numexpr#2-#1.%
       N#3\the\numexpr#1+#4.\xintReplicate{#1}{100000000!}}%
}%
\def\CALX_iidivfloor_x_gt_b #1.#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntoms\expandafter0\expandafter.%
    \romannumeral0\CALX_ndiv_y N#3\xint:#2\xint:%
       \CALX_ndf_go%
       \CALX_ndiv_zq\CALX_ndiv_zz
}%
\def\CALX_iimod{\CALX_iitwo\CALX_iimod_x\CALX_iimod_sp}%
\def\CALX_iimod_sp{\CALX_iisp_g\CALX_iifq\CALX_nmod}%
\def\CALX_iimod_x M#1.#2.#3\xint:M#4.#5.%
{%
    \expandafter\CALX_iimod_x_a\the\numexpr#2-#5.#2.M#1.#3\xint:M#4.%
}%
\def\CALX_iimod_x_a #1%
{%
    \xint_UDzerominusfork
       #1-\CALX_iimod_x_eq
       0#1\CALX_iimod_x_lt
       0-\CALX_iimod_x_gt
    \krof #1%
}%
\def\CALX_iimod_x_eq 0.#1.M#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntoms\the\numexpr#1\expandafter.%
    \romannumeral0\CALX_ndiv_y N#3\xint:N#2\xint:%
       \CALX_nmd_go%
       \CALX_ndiv_zr\CALX_ndiv_zz
}%
\def\CALX_iimod_x_lt -#1.#2.M#3\xint:M#4#5.#6\xint:
{%
    \expandafter\CALX_ntoms\the\numexpr#2\expandafter.%
    \romannumeral0\expandafter\CALX_ndiv_y
        \expanded{N#4\the\numexpr#1+#5.%
        \xintReplicate{#1}{100000000!}}#6\xint:N#3\xint:%
       \CALX_nmd_go%
       \CALX_ndiv_zr\CALX_ndiv_zz
}%
\def\CALX_iimod_x_gt #1.#2.M#3#4.%
{%
    \expandafter\CALX_iimod_x_gt_b\expanded{\the\numexpr#2-#1.%
       N#3\the\numexpr#1+#4.\xintReplicate{#1}{100000000!}}%
}%
\def\CALX_iimod_x_gt_b #1.#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntoms\the\numexpr#1\expandafter.%
    \romannumeral0\CALX_ndiv_y N#3\xint:#2\xint:%
       \CALX_nmd_go%
       \CALX_ndiv_zr\CALX_ndiv_zz
}%
\def\CALX_iiquo{\CALX_iitwo\CALX_iiquo_x\CALX_iiquo_sp}%
\def\CALX_iiquo_sp{\CALX_iisp_g\CALX_iifq\CALX_nquo}%
\def\CALX_iiquo_x M#1.#2.#3\xint:M#4.#5.%
{%
    \expandafter\CALX_iiquo_x_a\the\numexpr#2-#5.#2.M#1.#3\xint:M#4.%
}%
\def\CALX_iiquo_x_a #1%
{%
    \xint_UDzerominusfork
       #1-\CALX_iiquo_x_eq
       0#1\CALX_iiquo_x_lt
       0-\CALX_iiquo_x_gt
    \krof #1%
}%
\def\CALX_iiquo_x_eq 0.#1.M#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntoms\expandafter0\expandafter.%
    \romannumeral0\CALX_ndiv_y N#3\xint:N#2\xint:%
       \CALX_nqu_go%
       \CALX_ndiv_zq\CALX_ndiv_zz
}%
\def\CALX_iiquo_x_lt -#1.#2.M#3\xint:M#4#5.#6\xint:
{%
    \expandafter\CALX_ntoms\expandafter0\expandafter.%
    \romannumeral0\expandafter\CALX_ndiv_y
        \expanded{N#4\the\numexpr#1+#5.%
        \xintReplicate{#1}{100000000!}}#6\xint:N#3\xint:%
       \CALX_nqu_go%
       \CALX_ndiv_zq\CALX_ndiv_zz
}%
\def\CALX_iiquo_x_gt #1.#2.M#3#4.%
{%
    \expandafter\CALX_iiquo_x_gt_b\expanded{\the\numexpr#2-#1.%
       N#3\the\numexpr#1+#4.\xintReplicate{#1}{100000000!}}%
}%
\def\CALX_iiquo_x_gt_b #1.#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntoms\expandafter0\expandafter.%
    \romannumeral0\CALX_ndiv_y N#3\xint:#2\xint:%
       \CALX_nqu_go%
       \CALX_ndiv_zq\CALX_ndiv_zz
}%
\def\CALX_iirem{\CALX_iitwo\CALX_iirem_x\CALX_iirem_sp}%
\def\CALX_iirem_sp{\CALX_iisp_g\CALX_iifq\CALX_nrem}%
\def\CALX_iirem_x M#1.#2.#3\xint:M#4.#5.%
{%
    \expandafter\CALX_iirem_x_a\the\numexpr#2-#5.#2.M#1.#3\xint:M#4.%
}%
\def\CALX_iirem_x_a #1%
{%
    \xint_UDzerominusfork
       #1-\CALX_iirem_x_eq
       0#1\CALX_iirem_x_lt
       0-\CALX_iirem_x_gt
    \krof #1%
}%
\def\CALX_iirem_x_eq 0.#1.M#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntoms\the\numexpr#1\expandafter.%
    \romannumeral0\CALX_ndiv_y N#3\xint:N#2\xint:%
       \CALX_nre_go%
       \CALX_ndiv_zr\CALX_ndiv_zz
}%
\def\CALX_iirem_x_lt -#1.#2.M#3\xint:M#4#5.#6\xint:
{%
    \expandafter\CALX_ntoms\the\numexpr#2\expandafter.%
    \romannumeral0\expandafter\CALX_ndiv_y
        \expanded{N#4\the\numexpr#1+#5.%
        \xintReplicate{#1}{100000000!}}#6\xint:N#3\xint:%
       \CALX_nre_go%
       \CALX_ndiv_zr\CALX_ndiv_zz
}%
\def\CALX_iirem_x_gt #1.#2.M#3#4.%
{%
    \expandafter\CALX_iirem_x_gt_b\expanded{\the\numexpr#2-#1.%
       N#3\the\numexpr#1+#4.\xintReplicate{#1}{100000000!}}%
}%
\def\CALX_iirem_x_gt_b #1.#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntoms\the\numexpr#1\expandafter.%
    \romannumeral0\CALX_ndiv_y N#3\xint:#2\xint:%
       \CALX_nre_go%
       \CALX_ndiv_zr\CALX_ndiv_zz
}%
\def\CALX_iidivround{\CALX_iitwo\CALX_iidivround_x\CALX_iidivround_sp}%
\def\CALX_iidivround_sp{\CALX_iisp_g\CALX_iifq\CALX_ndivround}%
\def\CALX_iidivround_x M#1.#2.#3\xint:M#4.#5.%
{%
    \expandafter\CALX_iidivround_x_a\the\numexpr#2-#5.#2.M#1.#3\xint:M#4.%
}%
\def\CALX_iidivround_x_a #1%
{%
    \xint_UDzerominusfork
       #1-\CALX_iidivround_x_eq
       0#1\CALX_iidivround_x_lt
       0-\CALX_iidivround_x_gt
    \krof #1%
}%
\def\CALX_iidivround_x_eq 0.#1.M#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntoms\expandafter0\expandafter.%
    \romannumeral0\CALX_ndiv_y N#3\xint:N#2\xint:%
       \CALX_ndr_go%
       \CALX_ndiv_zq\CALX_ndiv_zz
}%
\def\CALX_iidivround_x_lt -#1.#2.M#3\xint:M#4#5.#6\xint:
{%
    \expandafter\CALX_ntoms\expandafter0\expandafter.%
    \romannumeral0\expandafter\CALX_ndiv_y
        \expanded{N#4\the\numexpr#1+#5.%
        \xintReplicate{#1}{100000000!}}#6\xint:N#3\xint:%
       \CALX_ndr_go%
       \CALX_ndiv_zq\CALX_ndiv_zz
}%
\def\CALX_iidivround_x_gt #1.#2.M#3#4.%
{%
    \expandafter\CALX_iidivround_x_gt_b\expanded{\the\numexpr#2-#1.%
       N#3\the\numexpr#1+#4.\xintReplicate{#1}{100000000!}}%
}%
\def\CALX_iidivround_x_gt_b #1.#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntoms\expandafter0\expandafter.%
    \romannumeral0\CALX_ndiv_y N#3\xint:#2\xint:%
       \CALX_ndr_go%
       \CALX_ndiv_zq\CALX_ndiv_zz
}%
\def\CALX_iidivision{\CALX_iitwo\CALX_iidivision_x\CALX_iidivision_sp}%
\def\CALX_iidivision_sp{\CALX_iisp_g\CALX_iifq\CALX_ndivision}%
\def\CALX_iidivision_x M#1.#2.#3\xint:M#4.#5.%
{%
    \expandafter\CALX_iidivision_x_a\the\numexpr#2-#5.#2.M#1.#3\xint:M#4.%
}%
\def\CALX_iidivision_x_a #1%
{%
    \xint_UDzerominusfork
       #1-\CALX_iidivision_x_eq
       0#1\CALX_iidivision_x_lt
       0-\CALX_iidivision_x_gt
    \krof #1%
}%
\def\CALX_iidivision_x_eq 0.#1.M#2\xint:M#3\xint:
{%
    \CALX_iifp#1.{%
    \romannumeral0\CALX_ndiv_y N#3\xint:N#2\xint:%
       \CALX_ndn_go%
       \CALX_ndiv_zp\CALX_ndiv_zzp}
}%
\def\CALX_iidivision_x_lt -#1.#2.M#3\xint:M#4#5.#6\xint:
{%
    \CALX_iifp#2.{%
    \romannumeral0\expandafter\CALX_ndiv_y
        \expanded{N#4\the\numexpr#1+#5.%
        \xintReplicate{#1}{100000000!}}#6\xint:N#3\xint:%
       \CALX_ndn_go%
       \CALX_ndiv_zp\CALX_ndiv_zzp}
}%
\def\CALX_iidivision_x_gt #1.#2.M#3#4.%
{%
    \expandafter\CALX_iidivision_x_gt_b\expanded{\the\numexpr#2-#1.%
       N#3\the\numexpr#1+#4.\xintReplicate{#1}{100000000!}}%
}%
\def\CALX_iidivision_x_gt_b #1.#2\xint:M#3\xint:
{%
    \CALX_iifp#1.{%
    \romannumeral0\CALX_ndiv_y N#3\xint:#2\xint:%
       \CALX_ndn_go%
       \CALX_ndiv_zp\CALX_ndiv_zzp}
}%
\def\CALX_iidivmod{\CALX_iitwo\CALX_iidivmod_x\CALX_iidivmod_sp}%
\def\CALX_iidivmod_sp{\CALX_iisp_g\CALX_iifq\CALX_ndivmod}%
\def\CALX_iidivmod_x M#1.#2.#3\xint:M#4.#5.%
{%
    \expandafter\CALX_iidivmod_x_a\the\numexpr#2-#5.#2.M#1.#3\xint:M#4.%
}%
\def\CALX_iidivmod_x_a #1%
{%
    \xint_UDzerominusfork
       #1-\CALX_iidivmod_x_eq
       0#1\CALX_iidivmod_x_lt
       0-\CALX_iidivmod_x_gt
    \krof #1%
}%
\def\CALX_iidivmod_x_eq 0.#1.M#2\xint:M#3\xint:
{%
    \CALX_iifp#1.{%
    \romannumeral0\CALX_ndiv_y N#3\xint:N#2\xint:%
       \CALX_ndm_go%
       \CALX_ndiv_zp\CALX_ndiv_zzp}%
}%
\def\CALX_iidivmod_x_lt -#1.#2.M#3\xint:M#4#5.#6\xint:
{%
    \CALX_iifp#2.{%
    \romannumeral0\expandafter\CALX_ndiv_y
        \expanded{N#4\the\numexpr#1+#5.%
        \xintReplicate{#1}{100000000!}}#6\xint:N#3\xint:%
       \CALX_ndm_go%
       \CALX_ndiv_zp\CALX_ndiv_zzp}%
}%
\def\CALX_iidivmod_x_gt #1.#2.M#3#4.%
{%
    \expandafter\CALX_iidivmod_x_gt_b\expanded{\the\numexpr#2-#1.%
       N#3\the\numexpr#1+#4.\xintReplicate{#1}{100000000!}}%
}%
\def\CALX_iidivmod_x_gt_b #1.#2\xint:M#3\xint:
{%
    \CALX_iifp#1.{%
    \romannumeral0\CALX_ndiv_y N#3\xint:#2\xint:%
       \CALX_ndm_go%
       \CALX_ndiv_zp\CALX_ndiv_zzp}%
}%
\def\CALX_iigcd{\CALX_iitwo\CALX_iigcd_x\CALX_iigcd_sp}%
\def\CALX_iigcd_sp{\CALX_iisp_g\CALX_iifq\CALX_ngcd}%
\def\CALX_iigcd_x M#1.#2.#3\xint:M#4.#5.%
{%
    \expandafter\CALX_iigcd_x_a\the\numexpr#2-#5.#2.M#1.#3\xint:M#4.%
}%
\def\CALX_iigcd_x_a #1%
{%
    \xint_UDzerominusfork
       #1-\CALX_iigcd_x_eq
       0#1\CALX_iigcd_x_lt
       0-\CALX_iigcd_x_gt
    \krof #1%
}%
\def\CALX_iigcd_x_eq 0.#1.M#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntomd\the\numexpr#1\expandafter.%
    \romannumeral0\CALX_ngcd{N#2}{N#3}%
}%
\def\CALX_iigcd_x_lt -#1.#2.M#3\xint:M#4#5.#6\xint:
{%
    \expandafter\CALX_ntomd\the\numexpr#2\expandafter.%
    \romannumeral0\CALX_ngcd{N#3}%
       {\expanded{N#4\the\numexpr#1+#5.%
        \xintReplicate{#1}{100000000!}}#6}%
}%
\def\CALX_iigcd_x_gt #1.#2.M#3#4.#5\xint:M#6\xint:
{%
    \expandafter\CALX_ntomd\the\numexpr#2-#1\expandafter.%
    \romannumeral0\CALX_ngcd{\expanded{N#3\the\numexpr#1+#4.%
       \xintReplicate{#1}{100000000!}}#5}{N#6}%
}%
\def\CALX_iilcm{\CALX_iitwo\CALX_iilcm_x\CALX_iilcm_sp}%
\def\CALX_iilcm_sp{\CALX_iisp_g\CALX_iifq\CALX_nlcm}%
\def\CALX_iilcm_x M#1.#2.#3\xint:M#4.#5.%
{%
    \expandafter\CALX_iilcm_x_a\the\numexpr#2-#5.#2.M#1.#3\xint:M#4.%
}%
\def\CALX_iilcm_x_a #1%
{%
    \xint_UDzerominusfork
       #1-\CALX_iilcm_x_eq
       0#1\CALX_iilcm_x_lt
       0-\CALX_iilcm_x_gt
    \krof #1%
}%
\def\CALX_iilcm_x_eq 0.#1.M#2\xint:M#3\xint:
{%
    \expandafter\CALX_ntomd\the\numexpr#1\expandafter.%
    \romannumeral0\CALX_nlcm{N#2}{N#3}%
}%
\def\CALX_iilcm_x_lt -#1.#2.M#3\xint:M#4#5.#6\xint:
{%
    \expandafter\CALX_ntomd\the\numexpr#2\expandafter.%
    \romannumeral0\CALX_nlcm{N#3}%
       {\expanded{N#4\the\numexpr#1+#5.%
        \xintReplicate{#1}{100000000!}}#6}%
}%
\def\CALX_iilcm_x_gt #1.#2.M#3#4.#5\xint:M#6\xint:
{%
    \expandafter\CALX_ntomd\the\numexpr#2-#1\expandafter.%
    \romannumeral0\CALX_nlcm{\expanded{N#3\the\numexpr#1+#4.%
       \xintReplicate{#1}{100000000!}}#5}{N#6}%
}%
\def\CALX_mr #1%
   {\romannumeral0\expandafter\CALX_mr_a\romannumeral`&&@#1\xint:}%
\def\CALX_mr_a #1%
{%
    \if I#1\xint_dothis\CALX_mr_x\fi
    \if M#1\xint_dothis\CALX_mr_m\fi
    \xint_orthat\CALX_mr_r #1%
}%
\def\CALX_mr_x #1\xint:{ #1}%
\def\CALX_mr_m #1{\CALX_mtoraw_a M}%
\def\CALX_mr_r #1\xint:{\CALX_mr_s #1[.\xint:}%
\def\CALX_mr_s #1[#2{\xint_gob_til_dot#2\CALX_mr_b.\CALX_mr_t #2#1[}%
\def\CALX_mr_b.\CALX_mr_t.#1[\xint:{ #1}%
\def\CALX_mr_t #1%
{%
    \xint_UDsignfork
        #1\CALX_mr_neg
         -\CALX_mr_z
    \krof #1%
}%
\def\CALX_mr_z #1#2[#3][.\xint:{\expanded{ #2\xintReplicate{#1#3}0}}%
\def\CALX_mr_neg -#1[#2][.\xint:{ #1[-#2]}%
\def\CALX_iipow_a #1#2.%
   {\xint_gob_til_minus #1\CALX_iipow_n-\CALX_iipow_p #1#2.}%
\def\CALX_iipow_n -\CALX_iipow_p{\CALX_iipow_t\CALX_iipow_r}%
\def\CALX_iipow_p {\CALX_iipow_t\CALX_iipow_q}%
\def\CALX_iipow_t #1#2.#3{\if I#3\CALX_iipow_j\fi #1#2.#3}%
\def\CALX_iipow_j\fi #1#2.{\fi\CALX_iipow_i #2.}%
\def\CALX_iipow_i #1.#2#3\xint:%
{%
    \ifnum#1=\xint_c_ \xint_dothis{ M+1.0.100000001!}\fi
    \if ?#3\xint_dothis{ #2#3}\fi
    \ifnum#1<\xint_c_ \xint_dothis{ M+0.0.}\fi
    \if +#3\xint_dothis{ #2+}\fi
    \ifodd#1 \xint_dothis{ #2-}\fi
    \xint_orthat{ #2+}%
}%
\def\CALX_iipow_r #1.M#2#3\xint:%
   {\csname CALX_ipr\CALX_iipow_cl M#2{#3}\endcsname #1.#2}%
\def\CALX_ipro #1.#2{ M+1.0.100000001!}%
\def\CALX_iprm #1.#2{\ifodd#1 \xint_afterfi{ M-}\else\xint_afterfi{ M+}\fi
    1.0.100000001!}%
\def\CALX_iprz #1.#2{\CALX_nsig{DivisionByZero}{0 ^ negative}{+}}%
\def\CALX_iprb #1.#2{\CALX_nsig{Underflow}{x ^ -k, abs(x) > 1}{M+0.0.}}%
\def\CALX_iipow_q #1.M#2#3.#4.#5\xint:%
   {\expandafter\CALX_ntomd\the\numexpr#1*#4\expandafter.%
    \romannumeral0\CALX_npow{#1}{N#2#3.#5}}%
\def\CALX_iicmp_x M#1#2.#3.#4\xint:M#5#6.#7.#8\xint:%
{%
    \expandafter\CALX_iicmp_y\the\numexpr#1#2+#1#3-(#5#6+#5#7)%
    .#2#6.M#1#2.#3.#4\xint:M#5#6.#7.#8\xint:%
}%
\def\CALX_iicmp_y #1#2.%
{%
    \if0#1\xint_dothis\CALX_iicmp_e\fi
    \if-#1\xint_dothis\CALX_iicmp_l\fi
    \xint_orthat\CALX_iicmp_g
}%
\def\CALX_iicmp_l #1.#2\xint:#3\xint:{\xint_stop_atthirdofthree}%
\def\CALX_iicmp_g #1.#2\xint:#3\xint:{\xint_stop_atsecondofthree}%
\def\CALX_iicmp_e #1.%
   {\ifnum#1=11 \expandafter\CALX_iicmp_o\else\expandafter\CALX_iicmp_s\fi}%
\def\CALX_iicmp_o M#1#2.#3.1#4!\xint:M#5#6.#7.1#8!\xint:%
{%
    \ifnum#1#4>#1#8 \xint_dothis\xint_stop_atsecondofthree\fi
    \ifnum#1#4<#1#8 \xint_dothis\xint_stop_atthirdofthree\fi
    \xint_orthat\xint_stop_atfirstofthree
}%
\def\CALX_iicmp_s #1\xint:#2\xint:%
   {\expandafter\CALX_iicmp_t
    \romannumeral0\CALX_iisub_x #1\xint:#2\xint:\xint:}%
\def\CALX_iicmp_t M#1#2#3\xint:%
{%
    \if0#2\xint_dothis\xint_stop_atfirstofthree\fi
    \if-#1\xint_dothis\xint_stop_atthirdofthree\fi
    \xint_orthat\xint_stop_atsecondofthree
}%
\def\CALX_iieq_x #1\xint:#2\xint:%
   {\if0\xintstrcmp{#1}{#2}\expandafter\xint_stop_atfirstoftwo
    \else\expandafter\xint_stop_atsecondoftwo\fi}%
\def\CALX_iipow_e #1#2\xint:%
   {\expandafter\CALX_iipow_ee\expandafter#1\expandafter#2%
    \romannumeral0\CALX_tom}%
\def\CALX_iipow_ee #1#2#3#4#5\xint:%
   {\csname CALX_ipe#2\CALX_iipow_cl#3#4{#5}\endcsname#1#2#4}%
\def\CALX_iipow_cl #1#2#3%
   {\if I#1\if ?#2n\else i\fi\else
    \ifnum\xintstrcmp{#3}{0.0.}=0 z\else
    \ifnum\xintstrcmp{#3}{1.0.100000001!}=0 \if -#2m\else o\fi
    \else b\fi\fi\fi}%
\def\CALX_ipe_one #1#2#3{ M+1.0.100000001!}%
\def\CALX_ipe_zero #1#2#3{ M+0.0.}%
\def\CALX_ipe_inf #1#2#3{ #1+}%
\def\CALX_ipe_es #1#2#3{ #1#2}%
\def\CALX_ipe_bs #1#2#3{ #1#3}%
\def\CALX_ipe_dz #1#2#3{\CALX_nsig{DivisionByZero}{0 ^ -inf}{+}}%
\def\CALX_tmpa #1#2{\expandafter\let\csname CALX_ipe#1\endcsname#2}%
\CALX_tmpa{+o}\CALX_ipe_one \CALX_tmpa{+m}\CALX_ipe_one
\CALX_tmpa{+z}\CALX_ipe_zero\CALX_tmpa{+b}\CALX_ipe_inf
\CALX_tmpa{+i}\CALX_ipe_inf \CALX_tmpa{+n}\CALX_ipe_bs
\CALX_tmpa{-o}\CALX_ipe_one \CALX_tmpa{-m}\CALX_ipe_one
\CALX_tmpa{-z}\CALX_ipe_dz  \CALX_tmpa{-b}\CALX_ipe_zero
\CALX_tmpa{-i}\CALX_ipe_zero\CALX_tmpa{-n}\CALX_ipe_bs
\CALX_tmpa{?o}\CALX_ipe_one \CALX_tmpa{?m}\CALX_ipe_es
\CALX_tmpa{?z}\CALX_ipe_es  \CALX_tmpa{?b}\CALX_ipe_es
\CALX_tmpa{?i}\CALX_ipe_es  \CALX_tmpa{?n}\CALX_ipe_es
\def\CALX_iiSum{\romannumeral0\CALX_iisum}%
\def\CALX_iisum #1%
{%
    \xint_gob_til_^ #1\CALX_iisum_empty ^%
    \expandafter\CALX_iisum_loop\romannumeral`&&@#1\xint:
}%
\def\CALX_iisum_empty ^#1\xint:{ M+0.0.}%
\def\CALX_iisum_loop #1\xint:#2%
{%
    \xint_gob_til_^ #2\CALX_iisum_end ^%
    \expandafter\CALX_iisum_loop
    \romannumeral0\CALX_iiadd{#1}{#2}\xint:
}%
\def\CALX_iisum_end ^#1\CALX_iiadd #2#3\xint:{ #2}%
\def\CALX_iiPrd{\romannumeral0\CALX_iiprd}%
\def\CALX_iiprd #1%
{%
    \xint_gob_til_^ #1\CALX_iiprd_empty ^%
    \expandafter\CALX_iiprd_loop\romannumeral`&&@#1\xint:
}%
\def\CALX_iiprd_empty ^#1\xint:{ M+1.0.100000001!}%
\def\CALX_iiprd_loop #1\xint:#2%
{%
    \xint_gob_til_^ #2\CALX_iiprd_end ^%
    \expandafter\CALX_iiprd_loop
    \romannumeral0\CALX_iimul{#1}{#2}\xint:
}%
\def\CALX_iiprd_end ^#1\CALX_iimul #2#3\xint:{ #2}%
\def\CALX_iiGCDof   {\romannumeral0\CALX_iigcdof_a}%
\def\CALX_iigcdof_a #1{\expandafter\CALX_iigcdof_b\romannumeral`&&@#1\xint:}%
\def\CALX_iigcdof_b #1\xint:#2%
   {\expandafter\CALX_iigcdof_c\romannumeral`&&@#2\xint:{#1}\xint:}%
\def\CALX_iigcdof_c #1{\xint_gob_til_^ #1\CALX_iigcdof_e ^\CALX_iigcdof_d #1}%
\def\CALX_iigcdof_d #1\xint:%
   {\expandafter\CALX_iigcdof_b\romannumeral0\CALX_iigcd {#1}}%
\def\CALX_iigcdof_e #1\xint:#2\xint:{ #2}%
\expandafter\def\csname CALX_iiLCMof\endcsname{\romannumeral0\CALX_iilcmof_a}%
\def\CALX_iilcmof_a #1{\expandafter\CALX_iilcmof_b\romannumeral`&&@#1\xint:}%
\def\CALX_iilcmof_b #1\xint:#2%
   {\expandafter\CALX_iilcmof_c\romannumeral`&&@#2\xint:{#1}\xint:}%
\def\CALX_iilcmof_c #1{\xint_gob_til_^ #1\CALX_iilcmof_e ^\CALX_iilcmof_d #1}%
\def\CALX_iilcmof_d #1\xint:%
   {\expandafter\CALX_iilcmof_b\romannumeral0\CALX_iilcm {#1}}%
\def\CALX_iilcmof_e #1\xint:#2\xint:{ #2}%
\def\CALX_ngcd {\CALX_ngl\CALX_ngcd_l}%
\def\CALX_nlcm {\CALX_ngl\CALX_nlcm_a}%
\def\CALX_ngl #1#2%
   {\expandafter\CALX_ngl_a\expandafter#1\romannumeral`&&@#2\xint:}%
\def\CALX_ngl_a #1#2\xint:#3%
   {\expandafter\CALX_ngl_b\expandafter#1\romannumeral`&&@#3\xint:#2\xint:}%
\def\CALX_ngl_b #1#2#3\xint:#4%
{%
    \if I#2\xint_dothis\CALX_ngl_bi\fi
    \if I#4\xint_dothis\CALX_ngl_bi\fi
    \xint_orthat{\CALX_ngl_bn #1{#2#3}#4}%
}%
\def\CALX_ngl_bi #1\xint:{\CALX_ngl_i}%
\def\CALX_ngl_bn #1#2#3#4\xint:{#1{#3#4}{#2}}%
\def\CALX_ngl_i{\CALX_nsig{InvalidOperation}{gcd or lcm of I}{}}%
\def\CALX_ngcd_l #1#2{\CALX_ngcd_t #2\xint:{#1}}%
\def\CALX_ngcd_t N#1#2.#3\xint:#4%
{%
    \ifnum#2=\xint_c_ \xint_dothis{\CALX_ngcd_e #4}\fi
    \xint_orthat{\expandafter\CALX_ngcd_t\romannumeral0%
      \CALX_nrem{#4}{N#1#2.#3}\xint:{N#1#2.#3}}%
}%
\def\CALX_ngcd_e N#1{ N+}%
\def\CALX_nlcm_a #1#2%
   {\expandafter\CALX_nlcm_b\romannumeral0\CALX_ngcd_l{#1}{#2}\xint:{#1}{#2}}%
\def\CALX_nlcm_b N#1#2.#3\xint:#4#5%
{%
    \ifnum#2=\xint_c_ \xint_dothis{ N+0.}\fi
    \xint_orthat{\expandafter\CALX_ngcd_e\romannumeral0%
      \CALX_nmul{\CALX_nquo{#4}{N#1#2.#3}}{#5}}%
}%
\def\CALX_iifac{\expandafter\CALX_iiun\expandafter\CALX_iifac_x
   \expandafter\CALX_mrinv\romannumeral0\CALX_tom}%
\def\CALX_iifac_x M#1#2.#3.#4\xint:%
{%
    \ifnum#2=\xint_c_ \xint_dothis{ M+1.0.100000001!}\fi
    \if-#1\xint_dothis\CALX_iifac_n\fi
    \ifnum#2#3>10 \xint_dothis\CALX_iifac_n\fi
    \xint_orthat{\CALX_iifac_y #4}%
}%
\def\CALX_iifac_y 1#1!%
{%
    \ifnum#1>\xint_c_e_iv \xint_dothis\CALX_iifac_n\fi
    \xint_orthat{\expandafter\CALX_ntom\romannumeral0\CALX_nfac{#1}}%
}%
\def\CALX_iifac_n
   {\CALX_nsig{InvalidOperation}{fac of a negative or > 10^4 integer}{}}%
\def\CALX_iipar{\expandafter\CALX_iiun\expandafter\CALX_iipar_x
   \expandafter\CALX_iipar_i\romannumeral0\CALX_tom}%
\def\CALX_iipar_i #1#2\xint:#3#4%
   {\CALX_nsig{InvalidOperation}{integer function of I}{}}%
\def\CALX_iipar_x M#1#2.#3.#4\xint:%
{%
    \ifnum\ifnum#3=\xint_c_ #2\else\xint_c_\fi=\xint_c_
      \xint_dothis\xint_stop_atsecondoftwo\fi
    \xint_orthat{\CALX_iipar_y #4\xint:}%
}%
\def\CALX_iipar_y 1#1!#2\xint:%
   {\ifodd#1 \expandafter\xint_stop_atfirstoftwo
    \else\expandafter\xint_stop_atsecondoftwo\fi}%
\def\CALX_iiisone{\expandafter\CALX_iiisone_a\romannumeral0\CALX_tom}%
\def\CALX_iiisone_a #1#2\xint:#3#4#5%
{%
    \if I#1\xint_dothis{#5}\fi
    \ifnum\xintstrcmp{#2}{+1.0.100000001!}=\xint_c_ \xint_dothis{#3}\fi
    \xint_orthat{#4}%
}%
\def\CALX_iione_i #1\xint:{\xint_stop_atsecondoftwo}%
\def\CALX_iilogten{\expandafter\CALX_iiun\expandafter\CALX_iilt_x
   \expandafter\CALX_mrinv\romannumeral0\CALX_tom}%
\def\CALX_iilt_x M#1#2.#3.#4\xint:%
{%
    \ifnum#2=\xint_c_ \xint_dothis{ -2147450880}\fi
    \xint_orthat{\expandafter\space\the\numexpr\xint_c_viii*(#2+#3)-\xint_c_ix
      +\CALX_nskip\CALX_iilt_t #2-\xint_c_i.#4\xint:\relax}%
}%
\def\CALX_iilt_t 1#1!\xint:{\CALX_ndig{#1}}%
\def\CALX_iibinom #1#2%
   {\expandafter\CALX_iibinom_p\the\numexpr #1\expandafter.\the\numexpr #2.}%
\def\CALX_iibinom_p #1.#2.%
   {\expandafter\CALX_iibinom_f\the\numexpr#1-#2.#2.#1.}%
\def\CALX_iibinom_f #1#2.#3#4.#5#6.%
{%
    \if-#5\xint_dothis\CALX_iibinom_inv\fi
    \if-#1\xint_dothis{ M+0.0.}\fi
    \if-#3\xint_dothis{ M+0.0.}\fi
    \if0#1\xint_dothis{ M+1.0.100000001!}\fi
    \if0#3\xint_dothis{ M+1.0.100000001!}\fi
    \ifnum #5#6>\xint_c_e_viii_mone\xint_dothis\CALX_iibinom_inv\fi
    \ifnum #1#2>#3#4
      \xint_dothis{\expandafter\CALX_ntom\romannumeral0\CALX_binom_a #1#2.#3#4.}\fi
    \xint_orthat{\expandafter\CALX_ntom\romannumeral0\CALX_binom_a #3#4.#1#2.}%
}%
\def\CALX_iibinom_inv
   {\CALX_nsig{InvalidOperation}{binomial: negative or >= 10^8 argument}{}}%
\def\CALX_iipfac #1#2%
   {\expandafter\CALX_iipfac_f\the\numexpr#1\expandafter.\the\numexpr#2.}%
\def\CALX_iipfac_f #1#2.#3#4.%
{%
    \unless\ifnum #1#2<#3#4 \xint_dothis\CALX_iipfac_one\fi
    \if-#3\xint_dothis\CALX_iipfac_neg\fi
    \if-#1\xint_dothis\CALX_iipfac_zero\fi
    \ifnum #3#4>\xint_c_e_viii_mone\xint_dothis\CALX_iipfac_inv\fi
    \xint_orthat\CALX_iipfac_a #1#2.#3#4.%
}%
\def\CALX_iipfac_inv #1.#2.%
   {\CALX_nsig{InvalidOperation}{pfactorial: argument >= 10^8}{}}%
\def\CALX_iipfac_one  #1.#2.{ M+1.0.100000001!}%
\def\CALX_iipfac_zero #1.#2.{ M+0.0.}%
\def\CALX_iipfac_neg -#1.-#2.%
{%
    \ifnum #1>\xint_c_e_viii\xint_dothis\CALX_iipfac_inv\fi
    \xint_orthat
   {\ifodd\numexpr#2-#1\relax
      \xint_afterfi{\expandafter\CALX_iipfac_m\romannumeral0}\fi
    \expandafter\CALX_iipfac_a}%
    \the\numexpr #2-\xint_c_i\expandafter.\the\numexpr#1-\xint_c_i.%
}%
\def\CALX_iipfac_m M+{ M-}%
\def\CALX_iipfac_a #1.#2.%
   {\expandafter\CALX_ntom\romannumeral0\CALX_npfac{#1}{#2}}%
\def\CALX_iiq #1#2#3#4#5%
{%
    \expandafter\CALX_iiq_a\romannumeral0\CALX_ndivision
      {\CALX_nshl{#5}{\CALX_nfromraw{#3}}}%
      {\CALX_nshl{-#5}{\CALX_nfromraw{#4}}}#1#2%
}%
\def\CALX_iiq_a #1#2{\CALX_iiq_b #2\xint:{#1}}%
\def\CALX_iiq_b N#1#2.#3\xint:#4#5#6%
   {\ifnum#2=\xint_c_ \expandafter#5\else\expandafter#6\fi{#4}}%
\def\CALX_iilit_n #1#2{\CALX_iiq\CALX_iilit_e\CALX_iilit_f{#1}1{#2}{#1[#2]}}%
\def\CALX_iilit_e #1#2{\CALX_ntom #1}%
\def\CALX_iilit_f #1#2{ #2}%
\def\CALX_tom_x #1.#2/\xint:{\CALX_tom_z #2/1/\xint:{#1}{#2[#1]}}%
\def\CALX_tom_z #1/#2/#3\xint:{\CALX_iiq\CALX_tom_e\CALX_tom_f{#1}{#2}}%
\def\CALX_tom_e #1#2{\CALX_ntom #1\xint:}%
\def\CALX_tom_f #1#2{\CALX_iinotint{#2}\CALX_tom_t #1\xint:}%
\def\CALX_tom_t N#1%
   {\if-#1\expandafter\CALX_tom_u\else\expandafter\CALX_ntom\fi N#1}%
\def\CALX_tom_u #1\xint:%
   {\expandafter\CALX_ntom\romannumeral0\CALX_nadd{#1}{N+1.100000001!}\xint:}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_seq_m k. (f-expandable, k explicit digits, |k| < 2^31): the M value
% of k; one block if |k| < 10^8, else \CALX_mfromraw. Items of a..b in
% \xinteval and \xintiieval.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_seq_m #1.%
{%
    \ifnum#1=\xint_c_ \xint_dothis{M+0.0.}\fi
    \ifnum\ifnum#1<\xint_c_ -\fi#1<\xint_c_e_viii
      \xint_dothis{M\ifnum#1<\xint_c_ -\else+\fi1.0.\the\numexpr
        \xint_c_e_viii\ifnum#1<\xint_c_ -\else+\fi#1!}\fi
    \xint_orthat{\romannumeral0\CALX_mfromraw{#1}}%
}%
%    \end{macrocode}
%\begin{lverb}
% Syntax (use with \romannumeral0; k explicit digits, k >= 0; b a block
% 1dddddddd with d > 0; R a raw integer, f-expanded, no leading zeros):
%(
%  \CALX_npowmul k.{b}{R}  ->  <space><raw integer R d^k>
%)
% \CALX_npow, \CALX_nmul and \CALX_nfromraw, \CALX_ntoraw of calxcore.
% Fractional hexadecimal, octal and binary literals (d = 5^j).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_npowmul #1.#2#3%
{%
    \expandafter\CALX_ntoraw_a\romannumeral0\expandafter\CALX_nmul_x
    \romannumeral0\CALX_npow{#1}{N+1.#2!}\xint:{\CALX_nfromraw{#3}}\xint:
}%
%    \end{macrocode}
% Back to normal letter catcodes for M, N, and I.
%    \begin{macrocode}
\catcode`M=11 \catcode`N=11 \catcode`I=11
\def\CALX_iilit #1#2%
{%
    \ifnum#2<\xint_c_ \xint_dothis{\CALX_iilit_n{#1}{#2}}\fi
    \xint_orthat{\CALX_mfromraw{\expanded{#1\xintReplicate{#2}0}}}%
}%
\def\CALX_iinotint #1%
   {\XINT_expandableerror{\xintiieval: #1 is not an integer, truncated.}}%
\def\calxiiAdd     {\romannumeral0\CALX_iiadd}%
\def\calxiiSub     {\romannumeral0\CALX_iisub}%
\def\calxiiMul     {\romannumeral0\CALX_iimul}%
\def\calxiiSqr     {\romannumeral0\CALX_iisqr}%
\def\calxiiOpp     {\romannumeral0\CALX_iiopp}%
\def\calxiiAbs     {\romannumeral0\CALX_iiabs}%
\def\calxiiSqrt    {\romannumeral0\CALX_iisqrt}%
\def\calxiiDivFloor{\romannumeral0\CALX_iidivfloor}%
\def\calxiiMod     {\romannumeral0\CALX_iimod}%
\def\calxiiDivRound{\romannumeral0\CALX_iidivround}%
\def\calxiiQuo     {\romannumeral0\CALX_iiquo}%
\def\calxiiRem     {\romannumeral0\CALX_iirem}%
\def\calxiiDivMod  {\romannumeral0\CALX_iidivmod}%
\def\calxiiPow #1#2%
   {\romannumeral0\expandafter\CALX_iipow_k\romannumeral`&&@#2\xint:{#1}}%
\def\CALX_iipow_k #1%
   {\if I#1\expandafter\CALX_iipow_e\else\expandafter\CALX_iipow_f\fi #1}%
\def\CALX_iipow_f #1\xint:%
   {\expandafter\CALX_iipow_a\the\numexpr\romannumeral0\CALX_mr_a#1\xint:%
    \expandafter.\romannumeral0\CALX_tom}%
\def\CALX_tmpa #1#2#3#4%
   {\def#1##1##2{\romannumeral0\CALX_iitwo#2#3{##1}{##2}#4}}%
\CALX_tmpa\calxiiLt    \CALX_iicmp_x\CALX_iicmp_sp{001}%
\CALX_tmpa\calxiiGt    \CALX_iicmp_x\CALX_iicmp_sp{010}%
\CALX_tmpa\calxiiLtorEq\CALX_iicmp_x\CALX_iicmp_sp{101}%
\CALX_tmpa\calxiiGtorEq\CALX_iicmp_x\CALX_iicmp_sp{110}%
\CALX_tmpa\calxiiEq    \CALX_iieq_x \CALX_iieq_sp {10}%
\CALX_tmpa\calxiiNotEq \CALX_iieq_x \CALX_iieq_sp {01}%
\def\CALX_iicmp_sp #1#2#3\xint:#4#5#6\xint:#7#8#9%
{%
    \if ?#2\xint_dothis\CALX_fcnan\fi
    \if ?#5\xint_dothis\CALX_fcnan\fi
    \ifnum\csname CALX_icl#1#2\endcsname>\csname CALX_icl#4#5\endcsname
      \xint_dothis{ #8}\fi
    \ifnum\csname CALX_icl#1#2\endcsname<\csname CALX_icl#4#5\endcsname
      \xint_dothis{ #9}\fi
    \xint_orthat{ #7}%
}%
\expandafter\def\csname CALX_iclI+\endcsname{1 }%
\expandafter\def\csname CALX_iclI-\endcsname{-1 }%
\expandafter\def\csname CALX_iclM+\endcsname{0 }%
\expandafter\def\csname CALX_iclM-\endcsname{0 }%
\def\CALX_fcnan
   {\CALX_signalcondition{InvalidOperation}{comparison with I?}{}{ 0}}%
\def\CALX_iieq_sp #1#2#3\xint:#4#5#6\xint:#7#8%
{%
    \if ?#2\xint_dothis{ #8}\fi
    \if ?#5\xint_dothis{ #8}\fi
    \xint_orthat{\CALX_iieq_x #1#2#3\xint:#4#5#6\xint:#7#8}%
}%
\def\calxiiFac   {\romannumeral0\CALX_iifac}%
\def\calxiiOdd #1{\romannumeral0\CALX_iipar{#1}10}%
\def\calxiiEven #1{\romannumeral0\CALX_iipar{#1}01}%
\def\calxiiIsOne #1{\romannumeral0\CALX_iiisone{#1}{ 1}{ 0}%
   {\CALX_nsig{InvalidOperation}{integer function of I}{}}}%
\def\calxiiifOne #1{\romannumeral0\CALX_iiisone{#1}\xint_stop_atfirstoftwo
   \xint_stop_atsecondoftwo{\expandafter\CALX_iione_i\romannumeral0%
   \CALX_nsig{InvalidOperation}{ifone of I}{}\xint:}}%
\def\calxiiifInt #1%
   {\romannumeral0\expandafter\CALX_iiifint\romannumeral`&&@#1\xint:}%
\def\CALX_iiifint #1#2\xint:%
   {\if I#1\xint_dothis{\expandafter\CALX_iione_i\romannumeral0%
      \CALX_nsig{InvalidOperation}{ifint of I}{}\xint:}\fi
    \xint_orthat\xint_stop_atfirstoftwo}%
\def\calxiiIsInt #1%
   {\romannumeral0\expandafter\CALX_iiisint\romannumeral`&&@#1\xint:}%
\def\CALX_iiisint #1#2\xint:%
   {\if I#1\xint_dothis{\CALX_nsig{InvalidOperation}{integer function of I}{}}\fi
    \xint_orthat{ 1}}%
\def\calxiiSqrtR {\romannumeral0\CALX_iisqrtr}%
\def\calxiiLogTen{\romannumeral0\CALX_iilogten}%
\def\calxiiBinomial {\romannumeral0\CALX_mrd\CALX_iibinom}%
\def\calxiiPFactorial {\romannumeral0\CALX_mrd\CALX_iipfac}%
\def\CALX_mrinv #1#2\xint:%
   {\CALX_nsig{InvalidOperation}{integer function of I}{}}%
\def\CALX_mrd #1#2%
   {\expandafter\CALX_mrd_a\expandafter#1\romannumeral`&&@#2\xint:}%
\def\CALX_mrd_a #1#2\xint:#3%
   {\expandafter\CALX_mrd_b\expandafter#1\romannumeral`&&@#3\xint:#2\xint:}%
\def\CALX_mrd_b #1#2#3\xint:#4#5\xint:%
{%
    \if I#2\xint_dothis\CALX_mrd_i\fi
    \if I#4\xint_dothis\CALX_mrd_i\fi
    \xint_orthat{\expandafter\space\romannumeral`&&@#1%
      {\romannumeral0\CALX_mr_a#4#5\xint:}%
      {\romannumeral0\CALX_mr_a#2#3\xint:}}%
}%
\def\CALX_mrd_i{\CALX_nsig{InvalidOperation}{integer function of I}{}}%
\def\CALX_mrl #1{\xint_gob_til_^#1\CALX_mrl_e ^{\CALX_mr{#1}}\CALX_mrl}%
\def\CALX_mrl_e ^#1\CALX_mrl{}%
\def\CALX_iiMaxof{\romannumeral0\CALX_iimaxof}%
\def\CALX_iimaxof#1%
{%
    \xint_gob_til_^ #1\CALX_iimaxof_empty ^%
    \expandafter\CALX_iimaxof_loop\romannumeral`&&@#1\xint:
}%
\def\CALX_iimaxof_empty ^#1\xint:{ 0}%
\def\CALX_iimaxof_loop #1\xint:#2%
{%
    \xint_gob_til_^ #2\CALX_iimaxof_e ^%
    \expandafter\CALX_iimaxof_loop\romannumeral0\CALX_iimax{#1}{#2}\xint:
}%
\def\CALX_iimaxof_e ^#1\CALX_iimax #2#3\xint:{ #2}%
\def\CALX_iiMinof{\romannumeral0\CALX_iiminof}%
\def\CALX_iiminof#1%
{%
    \xint_gob_til_^ #1\CALX_iiminof_empty ^%
    \expandafter\CALX_iiminof_loop\romannumeral`&&@#1\xint:
}%
\def\CALX_iiminof_empty ^#1\xint:{ 0}%
\def\CALX_iiminof_loop #1\xint:#2%
{%
    \xint_gob_til_^ #2\CALX_iiminof_e ^%
    \expandafter\CALX_iiminof_loop\romannumeral0\CALX_iimin{#1}{#2}\xint:
}%
\def\CALX_iiminof_e ^#1\CALX_iimin #2#3\xint:{ #2}%
\def\CALX_iimax #1#2{\expandafter\CALX_iimax_a\expandafter1\romannumeral`&&@#2\xint:{#1}}%
\def\CALX_iimin #1#2{\expandafter\CALX_iimax_a\expandafter2\romannumeral`&&@#2\xint:{#1}}%
\def\CALX_iimax_a #1#2\xint:#3%
   {\if1\romannumeral0\csname CALX_iimx_c#1\endcsname{#2}{#3}%
    \xint_afterfi{ #2}\else\xint_afterfi{ #3}\fi}%
\expandafter\def\csname CALX_iimx_c1\endcsname #1#2%
   {\CALX_iitwo\CALX_iicmp_x\CALX_iicmp_sp{#1}{#2}010}%
\expandafter\def\csname CALX_iimx_c2\endcsname #1#2%
   {\CALX_iitwo\CALX_iicmp_x\CALX_iicmp_sp{#1}{#2}001}%
%    \end{macrocode}
% \subsection{Binomial coefficients}
%\begin{lverb}
% Syntax (use with \romannumeral0; 0 < b <= a < 10^8 as explicit digits,
% a >= b):
%(
%  \CALX_binom_a a.b.  -> <space>N+<n>.<blocks>  binomial(a + b, b)
%)
% The engine of \xintiiBinomial: the accumulator is a block list, most
% significant first; each step multiplies it (\CALX_smallmul, on the list
% reversed by \CALX_rev_nounsep) by a product of consecutive integers and
% divides it (\CALX_smalldivx_a of calxcore) by the matching product of the
% denominator, four, three, two or one factors per step according to the
% size of the factors (< 10^8); very small arguments: one \numexpr
% a*b/c per step. Native output: the final list is reversed
% (\CALX_rev_nounsep) and given to \CALX_nnorm; very small arguments: one
% block.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_binom_a #1.#2.%
{%
    \expandafter\CALX_binom_b\the\numexpr \xint_c_i+#1.1.#2.100000001!1!;!0!%
}%
%    \end{macrocode}
%\begin{lverb}
% y=x-k+1.j=1.k. On va évaluer par y/1*(y+1)/2*(y+2)/3 etc... On essaie
% de regrouper de manière à utiliser au mieux \numexpr. On peut aller jusqu'à
% x=10000 car 9999*10000<10^8. 463*464*465=99896880, 98*99*100*101=97990200.
% On va vérifier à chaque étape si on dépasse un seuil. Le style de
% l'implémentation diffère de celui que j'avais utilisé pour \xintiiFac. On
% pourrait tout-à-fait avoir une verybigloop, mais bon. Je rajoute aussi un
% verysmall. Le traitement est un peu différent pour elle afin d'aller jusqu'à
% x=29 (et pas seulement 26 si je suivais le modèle des autres, mais je veux
% pouvoir faire binomial(29,1), binomial(29,2), ... en vsmall).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_binom_b #1.%
{%
    \ifnum #1>9999 \xint_dothis\CALX_binom_vbigloop \fi
    \ifnum #1>463  \xint_dothis\CALX_binom_bigloop   \fi
    \ifnum #1>98   \xint_dothis\CALX_binom_medloop   \fi
    \ifnum #1>29   \xint_dothis\CALX_binom_smallloop \fi
                   \xint_orthat\CALX_binom_vsmallloop #1.%
}%
%    \end{macrocode}
%\begin{lverb}
% y.j.k. Au départ on avait x-k+1.1.k. Ensuite on a des blocs 1<8d>!
% donnant le résultat intermédiaire, dans l'ordre, et à la fin on a 1!1;!0!.
% Dans smallloop on peut prendre 4 par 4.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_binom_smallloop #1.#2.#3.%
{%
    \ifcase\numexpr #3-#2\relax
        \expandafter\CALX_binom_end_
    \or \expandafter\CALX_binom_end_i
    \or \expandafter\CALX_binom_end_ii
    \or \expandafter\CALX_binom_end_iii
    \else\expandafter\CALX_binom_smallloop_a
    \fi #1.#2.#3.%
}%
%    \end{macrocode}
%\begin{lverb}
% Ça m'ennuie un peu de reprendre les #1, #2, #3 ici. On a besoin de
% \numexpr pour \CALX_binom_div, mais de \romannumeral0 pour le unsep après
% \CALX_binom_mul.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_binom_smallloop_a #1.#2.#3.%
{%
    \expandafter\CALX_binom_smallloop_b
    \the\numexpr #1+\xint_c_iv\expandafter.%
    \the\numexpr #2+\xint_c_iv\expandafter.%
    \the\numexpr #3\expandafter.%
    \the\numexpr\expandafter\CALX_binom_div
    \the\numexpr #2*(#2+\xint_c_i)*(#2+\xint_c_ii)*(#2+\xint_c_iii)\expandafter
    !\romannumeral0\expandafter\CALX_binom_mul
    \the\numexpr #1*(#1+\xint_c_i)*(#1+\xint_c_ii)*(#1+\xint_c_iii)!%
}%
\def\CALX_binom_smallloop_b #1.%
{%
    \ifnum #1>98  \expandafter\CALX_binom_medloop   \else
                  \expandafter\CALX_binom_smallloop \fi #1.%
}%
%    \end{macrocode}
%\begin{lverb}
% Ici on prend trois par trois.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_binom_medloop #1.#2.#3.%
{%
    \ifcase\numexpr #3-#2\relax
        \expandafter\CALX_binom_end_
    \or \expandafter\CALX_binom_end_i
    \or \expandafter\CALX_binom_end_ii
    \else\expandafter\CALX_binom_medloop_a
    \fi #1.#2.#3.%
}%
\def\CALX_binom_medloop_a #1.#2.#3.%
{%
    \expandafter\CALX_binom_medloop_b
    \the\numexpr #1+\xint_c_iii\expandafter.%
    \the\numexpr #2+\xint_c_iii\expandafter.%
    \the\numexpr #3\expandafter.%
    \the\numexpr\expandafter\CALX_binom_div
        \the\numexpr #2*(#2+\xint_c_i)*(#2+\xint_c_ii)\expandafter
    !\romannumeral0\expandafter\CALX_binom_mul
        \the\numexpr #1*(#1+\xint_c_i)*(#1+\xint_c_ii)!%
}%
\def\CALX_binom_medloop_b #1.%
{%
    \ifnum #1>463 \expandafter\CALX_binom_bigloop   \else
                  \expandafter\CALX_binom_medloop   \fi #1.%
}%
%    \end{macrocode}
%\begin{lverb}
% Ici on prend deux par deux.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_binom_bigloop #1.#2.#3.%
{%
    \ifcase\numexpr #3-#2\relax
        \expandafter\CALX_binom_end_
    \or \expandafter\CALX_binom_end_i
    \else\expandafter\CALX_binom_bigloop_a
    \fi #1.#2.#3.%
}%
\def\CALX_binom_bigloop_a #1.#2.#3.%
{%
    \expandafter\CALX_binom_bigloop_b
    \the\numexpr #1+\xint_c_ii\expandafter.%
    \the\numexpr #2+\xint_c_ii\expandafter.%
    \the\numexpr #3\expandafter.%
    \the\numexpr\expandafter\CALX_binom_div
        \the\numexpr #2*(#2+\xint_c_i)\expandafter
    !\romannumeral0\expandafter\CALX_binom_mul
        \the\numexpr #1*(#1+\xint_c_i)!%
}%
\def\CALX_binom_bigloop_b #1.%
{%
    \ifnum #1>9999 \expandafter\CALX_binom_vbigloop  \else
                   \expandafter\CALX_binom_bigloop   \fi #1.%
}%
%    \end{macrocode}
%\begin{lverb}
% Et finalement un par un.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_binom_vbigloop #1.#2.#3.%
{%
    \ifnum #3=#2
         \expandafter\CALX_binom_end_
    \else\expandafter\CALX_binom_vbigloop_a
    \fi #1.#2.#3.%
}%
\def\CALX_binom_vbigloop_a #1.#2.#3.%
{%
    \expandafter\CALX_binom_vbigloop
    \the\numexpr #1+\xint_c_i\expandafter.%
    \the\numexpr #2+\xint_c_i\expandafter.%
    \the\numexpr #3\expandafter.%
    \the\numexpr\expandafter\CALX_binom_div\the\numexpr #2\expandafter
    !\romannumeral0\CALX_binom_mul #1!%
}%
%    \end{macrocode}
%\begin{lverb}
% y.j.k. La partie very small. y est au plus 26 (non 29 mais retesté
% dans \CALX_binom_vsmallloop_a), et tous les binomial(29,n) sont <10^8. On
% peut donc faire y(y+1)(y+2)(y+3) et aussi il y a le fait que etex fait a*b/c
% en double precision. Pour ne pas bifurquer à la fin sur smallloop, si n=27,
% 27, ou 29 on procède un peu différemment des autres boucles. Si je testais
% aussi #1 après #3-#2 pour les autres il faudrait des terminaisons
% différentes.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_binom_vsmallloop #1.#2.#3.%
{%
    \ifcase\numexpr #3-#2\relax
        \expandafter\CALX_binom_vsmallend_
    \or \expandafter\CALX_binom_vsmallend_i
    \or \expandafter\CALX_binom_vsmallend_ii
    \or \expandafter\CALX_binom_vsmallend_iii
    \else\expandafter\CALX_binom_vsmallloop_a
    \fi #1.#2.#3.%
}%
\def\CALX_binom_vsmallloop_a #1.%
{%
    \ifnum #1>26  \expandafter\CALX_binom_smallloop_a  \else
                  \expandafter\CALX_binom_vsmallloop_b \fi #1.%
}%
\def\CALX_binom_vsmallloop_b #1.#2.#3.%
{%
    \expandafter\CALX_binom_vsmallloop
    \the\numexpr #1+\xint_c_iv\expandafter.%
    \the\numexpr #2+\xint_c_iv\expandafter.%
    \the\numexpr #3\expandafter.%
    \the\numexpr \expandafter\CALX_binom_vsmallmuldiv
    \the\numexpr  #2*(#2+\xint_c_i)*(#2+\xint_c_ii)*(#2+\xint_c_iii)\expandafter
    !\the\numexpr #1*(#1+\xint_c_i)*(#1+\xint_c_ii)*(#1+\xint_c_iii)!%
}%
\def\CALX_binom_mul #1!#21!;!0!%
{%
    \expandafter\CALX_rev_nounsep\expandafter{\expandafter}%
    \the\numexpr\expandafter\CALX_smallmul
    \the\numexpr\xint_c_e_viii+#1\expandafter
    !\romannumeral0\CALX_rev_nounsep {}1;!#2%
    \R!\R!\R!\R!\R!\R!\R!\R!\W
    \R!\R!\R!\R!\R!\R!\R!\R!\W
    1;!%
}%
\def\CALX_binom_div #1!1;!%
{%
    \expandafter\CALX_smalldivx_a
    \the\numexpr #1/\xint_c_ii\expandafter\xint:
    \the\numexpr \xint_c_e_viii+#1!%
}%
%    \end{macrocode}
%\begin{lverb}
% Vaguement envisagé d'éviter le 10^8+ mais bon.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_binom_vsmallmuldiv #1!#2!1#3!{\xint_c_e_viii+#2*#3/#1!}%
%    \end{macrocode}
%\begin{lverb}
% On a des terminaisons communes aux trois situations small, med, big,
% et on est sûr de pouvoir faire les multiplications dans \numexpr, car on
% vient ici *après* avoir comparé à 9999 ou 463 ou 98.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_binom_end_iii #1.#2.#3.%
{%
    \expandafter\CALX_binom_finish
    \the\numexpr\expandafter\CALX_binom_div
        \the\numexpr #2*(#2+\xint_c_i)*(#2+\xint_c_ii)*(#2+\xint_c_iii)\expandafter
    !\romannumeral0\expandafter\CALX_binom_mul
        \the\numexpr #1*(#1+\xint_c_i)*(#1+\xint_c_ii)*(#1+\xint_c_iii)!%
}%
\def\CALX_binom_end_ii #1.#2.#3.%
{%
    \expandafter\CALX_binom_finish
    \the\numexpr\expandafter\CALX_binom_div
        \the\numexpr #2*(#2+\xint_c_i)*(#2+\xint_c_ii)\expandafter
    !\romannumeral0\expandafter\CALX_binom_mul
        \the\numexpr #1*(#1+\xint_c_i)*(#1+\xint_c_ii)!%
}%
\def\CALX_binom_end_i #1.#2.#3.%
{%
    \expandafter\CALX_binom_finish
    \the\numexpr\expandafter\CALX_binom_div
        \the\numexpr #2*(#2+\xint_c_i)\expandafter
    !\romannumeral0\expandafter\CALX_binom_mul
        \the\numexpr #1*(#1+\xint_c_i)!%
}%
\def\CALX_binom_end_ #1.#2.#3.%
{%
    \expandafter\CALX_binom_finish
    \the\numexpr\expandafter\CALX_binom_div\the\numexpr #2\expandafter
    !\romannumeral0\CALX_binom_mul #1!%
}%
\def\CALX_binom_finish #11!;!0!%
{%
    \expandafter\CALX_nnorm\expandafter+%
    \romannumeral0\CALX_rev_nounsep {}#1\R!\R!\R!\R!\R!\R!\R!\R!\W 1;!%
}%
%    \end{macrocode}
%\begin{lverb}
% Duplication de code seulement pour la boucle avec très
% petits coeffs, mais en plus on fait au maximum des possibilités. (on
% pourrait tester plus le résultat déjà obtenu).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_binom_vsmallend_iii #1.%
{%
    \ifnum #1>26  \expandafter\CALX_binom_end_iii \else
                  \expandafter\CALX_binom_vsmallend_iiib \fi #1.%
}%
\def\CALX_binom_vsmallend_iiib #1.#2.#3.%
{%
    \expandafter\CALX_binom_vsmallfinish
    \the\numexpr \expandafter\CALX_binom_vsmallmuldiv
    \the\numexpr  #2*(#2+\xint_c_i)*(#2+\xint_c_ii)*(#2+\xint_c_iii)\expandafter
    !\the\numexpr #1*(#1+\xint_c_i)*(#1+\xint_c_ii)*(#1+\xint_c_iii)!%
}%
\def\CALX_binom_vsmallend_ii #1.%
{%
    \ifnum #1>27  \expandafter\CALX_binom_end_ii \else
                  \expandafter\CALX_binom_vsmallend_iib \fi #1.%
}%
\def\CALX_binom_vsmallend_iib #1.#2.#3.%
{%
    \expandafter\CALX_binom_vsmallfinish
    \the\numexpr \expandafter\CALX_binom_vsmallmuldiv
    \the\numexpr  #2*(#2+\xint_c_i)*(#2+\xint_c_ii)\expandafter
    !\the\numexpr #1*(#1+\xint_c_i)*(#1+\xint_c_ii)!%
}%
\def\CALX_binom_vsmallend_i #1.%
{%
    \ifnum #1>28  \expandafter\CALX_binom_end_i \else
                  \expandafter\CALX_binom_vsmallend_ib \fi #1.%
}%
\def\CALX_binom_vsmallend_ib #1.#2.#3.%
{%
    \expandafter\CALX_binom_vsmallfinish
    \the\numexpr \expandafter\CALX_binom_vsmallmuldiv
    \the\numexpr  #2*(#2+\xint_c_i)\expandafter
    !\the\numexpr #1*(#1+\xint_c_i)!%
}%
\def\CALX_binom_vsmallend_ #1.%
{%
    \ifnum #1>29  \expandafter\CALX_binom_end_ \else
                  \expandafter\CALX_binom_vsmallend_b \fi #1.%
}%
\def\CALX_binom_vsmallend_b #1.#2.#3.%
{%
    \expandafter\CALX_binom_vsmallfinish
    \the\numexpr\CALX_binom_vsmallmuldiv #2!#1!%
}%
\catcode`N=12
\def\CALX_binom_vsmallfinish#1{%
\def\CALX_binom_vsmallfinish1##1!1!;!0!{#1N+1.1##1!}%
}\CALX_binom_vsmallfinish{ }%
\catcode`N=11
%    \end{macrocode}
% \subsection{\csh{xintiiifLt}}
% Moved here at |2.0a1| due to a ridiculous situation with the support
% macro for |randrange()|, originating in a serious misalignment of my
% assistant.  This is of course a seriously sub-optimal situation
% perhaps provisory but will not be modified before |2.0a1| release.
%\begin{lverb}
% 1.09a \xintifLt {n}{m}{YES if n<m}{NO if n>=m}. Restyled in 1.09i.
% 1.1a adds ii variant
%\end{lverb}
%    \begin{macrocode}
\def\xintiiifLt {\romannumeral0\xintiiiflt }%
\def\xintiiiflt #1#2%
{%
    \ifnum\xintiiCmp{#1}{#2}<\xint_c_
          \expandafter\xint_stop_atfirstoftwo
    \else \expandafter\xint_stop_atsecondoftwo
    \fi
}%
%    \end{macrocode}
% \subsection{(WIP) \csh{xintRandomDigits}}
%\begin{lverb}
% 1.3b. See user manual. Whether this will be part of xintkernel,
% xintcore, or xint is yet to be decided.
%\end{lverb}
%    \begin{macrocode}
\def\xintRandomDigits{\romannumeral0\xintrandomdigits}%
\def\xintrandomdigits#1%
{%
    \csname xint_gob_andstop_\expandafter\XINT_randomdigits\the\numexpr#1\xint:
}%
\def\XINT_randomdigits#1\xint:
{%
    \expandafter\XINT_randomdigits_a
    \the\numexpr(#1+\xint_c_iii)/\xint_c_viii\xint:#1\xint:
}%
\def\XINT_randomdigits_a#1\xint:#2\xint:
{%
    \romannumeral\numexpr\xint_c_viii*#1-#2\csname XINT_%
      \romannumeral\XINT_replicate #1\endcsname \csname
    XINT_rdg\endcsname
}%
\def\XINT_rdg
{%
    \expandafter\XINT_rdg_aux\the\numexpr%
                 \xint_c_nine_e_viii%
                                -\xinttexuniformdeviate\xint_c_ii^vii%
                 -\xint_c_ii^vii*\xinttexuniformdeviate\xint_c_ii^vii%
                 -\xint_c_ii^xiv*\xinttexuniformdeviate\xint_c_ii^vii%
                 -\xint_c_ii^xxi*\xinttexuniformdeviate\xint_c_ii^vii%
                 +\xinttexuniformdeviate\xint_c_e_viii%
                 \relax%
}%
\def\XINT_rdg_aux#1{XINT_rdg\endcsname}%
\let\XINT_XINT_rdg\endcsname
%    \end{macrocode}
% \subsection{(WIP) \csh{XINT_eightrandomdigits}, \csh{xintEightRandomDigits}}
%\begin{lverb}
% 1.3b. 1.4 adds some public alias...
%\end{lverb}
%    \begin{macrocode}
\def\XINT_eightrandomdigits
{%
     \expandafter\xint_gobble_i\the\numexpr%
                 \xint_c_nine_e_viii%
                                -\xinttexuniformdeviate\xint_c_ii^vii%
                 -\xint_c_ii^vii*\xinttexuniformdeviate\xint_c_ii^vii%
                 -\xint_c_ii^xiv*\xinttexuniformdeviate\xint_c_ii^vii%
                 -\xint_c_ii^xxi*\xinttexuniformdeviate\xint_c_ii^vii%
                 +\xinttexuniformdeviate\xint_c_e_viii%
                 \relax%
}%
\let\xintEightRandomDigits\XINT_eightrandomdigits
\def\xintRandBit{\xinttexuniformdeviate\xint_c_ii}%
%    \end{macrocode}
% \subsection{(WIP) \csh{xintRandBit}}
%\begin{lverb}
% 1.4 And let's add also \xintRandBit while we are at it.
%\end{lverb}
%    \begin{macrocode}
\def\xintRandBit{\xinttexuniformdeviate\xint_c_ii}%
%    \end{macrocode}
% \subsection{(WIP) \csh{xintXRandomDigits}}
%\begin{lverb}
% 1.3b.
%\end{lverb}
%    \begin{macrocode}
\def\xintXRandomDigits#1%
{%
    \csname xint_gobble_\expandafter\XINT_xrandomdigits\the\numexpr#1\xint:
}%
\def\XINT_xrandomdigits#1\xint:
{%
    \expandafter\XINT_xrandomdigits_a
    \the\numexpr(#1+\xint_c_iii)/\xint_c_viii\xint:#1\xint:
}%
\def\XINT_xrandomdigits_a#1\xint:#2\xint:
{%
    \romannumeral\numexpr\xint_c_viii*#1-#2\expandafter\endcsname
    \romannumeral`&&@\romannumeral
                     \XINT_replicate #1\endcsname\XINT_eightrandomdigits
}%
%    \end{macrocode}
% \subsection{(WIP) \csh{xintiiRandRangeAtoB}}
%\begin{lverb}
% 1.3b. Support for randrange() function.
%
% We do it f-expandably for matters of \xintNewExpr etc... The \xintexpr will
% add \xintNum wrapper to possible fractional input. But \xintiiexpr will call
% as is.
%
% TODO: ? implement third argument (STEP)
% TODO: \xintNum wrapper (which truncates) not so good in floatexpr. Use round?
%
% It is an error if b<=a, as in Python.
%\end{lverb}
%
%\begin{lverb}
% NOTA BENE: \xintiiRandRangeAtoB is moved here from xint.sty at 2.0a1
% to have all in one location, but is NOT used by the calx chain. This
% would induce a dependency on xint.sty via \xintiiadd, \xintiisub.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiRandRangeAtoB{\romannumeral`&&@\xintiirandrangeAtoB}%
\def\xintiirandrangeAtoB#1%
{%
    \expandafter\XINT_randrangeAtoB_a\romannumeral`&&@#1\xint:
}%
\def\XINT_randrangeAtoB_a#1\xint:#2%
{%
    \xintiiadd{\expandafter\XINT_randrange
               \romannumeral0\xintiisub{#2}{#1}\xint:}%
              {#1}%
}%
%    \end{macrocode}
% \subsection{(WIP) \csh{xintiiRandRange}}
%\begin{lverb}
% 1.3b. Support for randrange().
%\end{lverb}
%
%\begin{lverb}
% All dependencies of \xintiiRandRange were moved to calxcore.sty
% and calxint.sty.
%\end{lverb}
%    \begin{macrocode}
\def\xintiiRandRange{\romannumeral`&&@\xintiirandrange}%
\def\xintiirandrange#1%
{%
    \expandafter\XINT_randrange\romannumeral`&&@#1\xint:
}%
\def\XINT_randrange #1%
{%
    \xint_UDzerominusfork
      #1-\XINT_randrange_err:empty
      0#1\XINT_randrange_err:empty
       0-\XINT_randrange_a
    \krof #1%
}%
\def\XINT_randrange_err:empty#1\xint:
{%
    \XINT_expandableerror{Empty range for randrange.} 0%
}%
\def\XINT_randrange_a #1\xint:
{%
    \expandafter\XINT_randrange_b\romannumeral0\xintlength{#1}.#1\xint:
}%
\def\XINT_randrange_b #1.%
{%
    \ifnum#1<\xint_c_x\xint_dothis{\the\numexpr\XINT_uniformdeviate{}}\fi
    \xint_orthat{\XINT_randrange_c #1.}%
}%
\def\XINT_randrange_c #1.#2#3#4#5#6#7#8#9%
{%
    \expandafter\XINT_randrange_d
    \the\numexpr\expandafter\XINT_uniformdeviate\expandafter
       {\expandafter}\the\numexpr\xint_c_i+#2#3#4#5#6#7#8#9\xint:\xint:
    #2#3#4#5#6#7#8#9\xint:#1\xint:
}%
%    \end{macrocode}
%\begin{lverb}
% This raises following annex question: immediately after setting the
% seed is it possible for \xintUniformDeviate{N} where N>0 has exactly eight
% digits to return either 0 or N-1 ? It could be that this is never the case,
% then there is a bias in randrange(). Of course there are anyhow only 2^28
% seeds so randrange(10^X) is by necessity biased when executed immediately
% after setting the seed, if X is at least 9.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_randrange_d #1\xint:#2\xint:
{%
    \ifnum#1=\xint_c_\xint_dothis\XINT_randrange_Z\fi
    \ifnum#1=#2 \xint_dothis\XINT_randrange_A\fi
    \xint_orthat\XINT_randrange_e #1\xint:
}%
\def\XINT_randrange_e #1\xint:#2\xint:#3\xint:
{%
    \the\numexpr#1\expandafter\relax
    \romannumeral0\xintrandomdigits{#2-\xint_c_viii}%
}%
%    \end{macrocode}
%\begin{lverb}
% This is quite unlikely to get executed but if it does it must
% pay attention to leading zeros, hence the \xintinum.
% We don't have to be
% overly obstinate about removing overheads...
%\end{lverb}
%    \begin{macrocode}
\def\XINT_randrange_Z 0\xint:#1\xint:#2\xint:
{%
    \xintinum{\xintRandomDigits{#1-\xint_c_viii}}%
}%
%    \end{macrocode}
%\begin{lverb}
% Here too, overhead is not such a problem. The idea is that we got by
% extraordinary same first 8 digits as upper range bound so we pick at random
% the remaining needed digits in one go and compare with the upper bound. If too
% big, we start again with another random 8 leading digits in given range. No
% need to aim at any kind of efficiency for the check and loop back.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_randrange_A #1\xint:#2\xint:#3\xint:
{%
    \expandafter\XINT_randrange_B
    \romannumeral0\xintrandomdigits{#2-\xint_c_viii}\xint:
    #3\xint:#2.#1\xint:
}%
\def\XINT_randrange_B #1\xint:#2\xint:#3.#4\xint:
{%
    \xintiiifLt{#1}{#2}{\XINT_randrange_E}{\XINT_randrange_again}%
    #4#1\xint:#3.#4#2\xint:
}%
\def\XINT_randrange_E #1\xint:#2\xint:{ #1}%
\def\XINT_randrange_again #1\xint:{\XINT_randrange_c}%
%    \end{macrocode}
% \subsection{\csh{calxintRandRangeAtoB}, \csh{calxintRandRange}}
%\begin{lverb}
% calx: randrange() of \xintiieval. Arguments: any \xintiieval value,
% converted to raw digits by \CALX_mr_a; output M.
%
% These macros are wrappers around xint's \XINT_randrange (above,
% unmodified), not a native rewriting. The cause is a serious
% and recurrent misalignment problem of this assistant and the
% pain and suffering it finally ended up causing the user, who
% is really reaching the ultimate limits of endurance.
%
% FIXME: \CALX_mr_a IS A CRUCIAL CONVERSION AND MUST HAVE
% A LEGIBLE NAME.
%\end{lverb}
%    \begin{macrocode}
\def\calxintRandRangeAtoB{\romannumeral0\CALX_randrangeAtoB}%
\def\CALX_randrangeAtoB#1%
{%
    \expandafter\CALX_randrangeAtoB_a\romannumeral`&&@#1\xint:
}%
\def\CALX_randrangeAtoB_a#1\xint:#2%
{%
    \CALX_iiadd{\expandafter\XINT_randrange
                \romannumeral0\expandafter\CALX_mr_a
                \romannumeral0\CALX_iisub{#2}{#1}\xint:\xint:}%
               {#1}%
}%
\def\CALX_mfromraw_a{\expandafter\CALX_ntom\romannumeral0\CALX_nfromraw_a}%
\def\calxintRandRange{%
    \romannumeral0\expandafter
    \CALX_mfromraw_a\romannumeral`&&@\CALX_randrange
}%
\def\CALX_randrange#1%
{%
    \expandafter\XINT_randrange
    \romannumeral0\expandafter\CALX_mr_a\romannumeral`&&@#1\xint:\xint:\xint:
}%
%    \end{macrocode}
% \subsection{(WIP) Adjustments for engines without uniformdeviate primitive}
%\added{1.3b}
%    \begin{macrocode}
\ifdefined\xinttexuniformdeviate
\else
  \def\xintrandomdigits#1%
  {%
      \XINT_expandableerror
      {No uniformdeviate at engine level.} 0%
  }%
  \let\xintXRandomDigits\xintRandomDigits
  \def\XINT_randrange#1\xint:
  {%
      \XINT_expandableerror
      {No uniformdeviate at engine level.} 0%
  }%
\fi
\XINTrestorecatcodesendinput%
%    \end{macrocode}
% \StoreCodelineNo {calxint}
% \cleardoublepage\let\calxintnameUp\undefined
%\gardesactifs
%\let</calxint>\relax
%\let<*calxfp>\gardesinactifs
%</calxint>^^A---------------------------------------------------
%<*calxfp>^^A-------------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname calxfpnameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section{Package \calxfpnameimp implementation}
% \RaisedLabel{sec:calxfpimp}
% \addedcalx{2.0a1}
%
% \localtableofcontents
%
%\begin{lverb}
% calx: native floating point numbers (the float part of an ideal split of
% xintfrac.sty; calxfrac.sty would be the fractions part). It loads
% calxint.sty. Format:
%(   F<s><D>.<e>.<blocks>
%)
% value M 10^(8e), M the native integer with blocks 1dddddddd! (least
% significant first), D its number of digits (top block not normalized),
% e the exponent in blocks, <s> + or -. Zero: F+0.0. Special values I+,
% I-, I? as for native integers. F has catcode 12 here.
%\end{lverb}
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
% The code of this subsection is copied over from the xint packages, with
% the package names changed.
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode64=11   % @
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \def\empty{}\def\space{ }\newlinechar10
  \def\z{\endgroup}%
  \expandafter\let\expandafter\x\csname ver@calxfp.sty\endcsname
  \expandafter\let\expandafter\w\csname ver@calxint.sty\endcsname
  \expandafter\ifx\csname numexpr\endcsname\relax
    \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax
      \immediate\write128{^^JPackage calxfp Warning:^^J%
                          \space\space\space\space
                          \numexpr not available, aborting input.^^J}%
    \else
      \PackageWarningNoLine{calxfp}{\numexpr not available, aborting input}%
    \fi
    \def\z{\endgroup\endinput}%
  \else
    \ifx\x\relax   % plain-TeX, first loading of calxfp.sty
      \ifx\w\relax % but calxint.sty not yet loaded.
         \def\z{\endgroup\input calxint.sty\relax}%
      \fi
    \else
      \ifx\x\empty % LaTeX, first loading,
      % variable is initialized, but \ProvidesPackage not yet seen
          \ifx\w\relax % calxint.sty not yet loaded.
            \def\z{\endgroup\RequirePackage{calxint}}%
          \fi
      \else
        \def\z{\endgroup\endinput}% calxfp already loaded.
      \fi
    \fi
  \fi
\z%
\XINTsetupcatcodes% defined in xintkernel.sty
%    \end{macrocode}
% \subsection{Package identification}
%    \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{calxfp}%
  [2026/11/01 v2.0a1 Floating point unit P1 to P100 (JFB)]%
%    \end{macrocode}
% \subsection{\csh{xintDigits}, \csh{xintSetDigits}}
% \changed{2.0a1}
% Moved here from \xintfracnameimp together with the starred version
% from original \xintexprnameimp, trimmed from its original meaning.
%
% Removal of the commented out layer which was in preparation for
% user to temporarily use extra digits.  The calx semantics made this
% anyhow obsolete as increasing Digits is cheap (it only costs
% recomputing the Pi and other trig variables).
%
% \changed{1.3}
%\begin{lverb}
% 1.3f allows \xintDigits= in place of \xintDigits$empty:= syntax. ^^A$
% It defines \xintDigits*[:]= which reloads xinttrig.sty. Perhaps this should
% be default, well.
%
% During 1.4e development I added an interface for guard digits, but I decided
% to drop inclusion from 1.4e release because there were pending issues both
% in documentation and functionalities for which I did not have time left.
%
% 1.4e fixes the issue that \xinttheDigits could not be used in the right hand
% side of \xintDigits[*][:]=...; or inside the argument to \xintSetDigits.
%\end{lverb}
%
%\begin{lverb}
% calx (s50): \xintDigits and \xintDigits* are synonyms; both (and
% \xintSetDigits/\xintSetDigits*) update the constants twoPi, ...,
% oneRadian (P digits) by
% \CALX_trigvars (defined at the end of calxtrig.tex; \empty until then).
%
% There was a \futurelet\XINT_token which was meant to detect the *
% for \xintDigits, it is of course dropped here. The #1 for \xintDigits_j
% gobbles a semi-colon which is original user-documented syntax or a \relax
% which was advocated later.
%\end{lverb}
%    \begin{macrocode}
\mathchardef\XINTdigits  16
\def\xinttheDigits {\number\XINTdigits}%
\def\xintDigits #1={\afterassignment\xintDigits_j\mathchardef\XINT_digits=}%
\let\CALX_trigvars\empty
\def\xintDigits_j#1{\let\XINTdigits=\XINT_digits\CALX_trigvars}%
%    \end{macrocode}
% The |#1| above serves to absord the ending semi-colon or |\relax| token
% from the documented interface.
% Pay attention to the |#{| delimiter below.
% It serves to gobble the legacy
% starred syntax, which is completely synonymous now to unstarred one.
% (PERHAPS REVERT THIS DECISION IN TIME FOR 2.0a1: TO BE DECIDED LATER).
%    \begin{macrocode}
\def\xintSetDigits#1#{\xintSetDigits_a}%
\def\xintSetDigits_a#1{%
   \mathchardef\XINT_digits=\numexpr#1\relax
   \let\XINTdigits=\XINT_digits
   \CALX_trigvars
}%
\catcode`F=12 \catcode`N=12 \catcode`I=12
%    \end{macrocode}
% \subsection{Rounding}
% \subsubsection{\csh{CALX_fround}, \csh{CALX_fnround}, \csh{CALX_fblocks}}
%\begin{lverb}
% Syntax (use with \romannumeral0; the second argument is f-expanded):
%(
%  \CALX_fround{P}{X}<rest>   -> <space>Y\xint:<rest>
%:  \CALX_fnround{P}{X}<rest>  -> <space>Y<rest>
%:  \CALX_fblocks{m}{X}<rest>  -> <space>Y<rest>
%)
% P (number of significant digits, >= 1) and m (number of blocks, >= 1)
% are \numexpr expressions. Values X, Y (tags F, I catcode 12):
%(
%  F<s><D>.<e>.1<b_0>!1<b_1>!...1<b_n>!    native float
%:  I+   I-   I?                              specials
%)
% s sign (+ or -), D digit count of N = b_n...b_1b_0 (D = 0: zero, no
% block), e block exponent, 8-digit blocks b_i least significant first:
% value s N 10^(8e). \CALX_fround also accepts an M value (calxint) and
% an xint raw value X: A[N] or A/B[N] (the [N] is mandatory), A and B
% integers in decimal digits without leading zeros, an optional - on A
% only, B > 0 (no decimal mark, no exponent);
% it is delimited by the \xint: that \CALX_fround appends. xintexpr.sty
% replaces the raw branch \CALX_fr_x so that X may be any xintfrac input.
% \CALX_fnround and \CALX_fblocks accept only F, I.
%
% Output Y: F input: X rounded to P significant digits (\CALX_fblocks: to
% its m top blocks), round half away from zero (as xint's \xintDSRr,
% \XINTinFloat); D <= P: X itself. I input: X itself. Raw input: the F
% value of X rounded to P digits. \CALX_fround's Y is ALWAYS followed by
% \xint: (the terminator that the entries of the operations read after a
% value); \CALX_fnround and \CALX_fblocks add nothing. Only the blocks
% below the rounding position are read: the higher ones stay in the input
% stream untouched.
%
% k = D - P <= 0: unchanged (zero, specials too). Else k = 8a + c: skip
% a blocks (gobblers \CALX_fr_g<a>, a <= 5; beyond, \CALX_fr_sk drops
% seven at a time and \CALX_fr_q<r> the rest), then c > 0: lowest kept
% block 1v -> 1v/10^c*10^c (\numexpr rounds half away from zero); c = 0:
% the first digit of the last dropped block decides +1 on the lowest kept
% block. D' = D - 8a, e' = e + a.
% Dispatch on k by \csname (macros \CALX_fr_k<k>, k in decimal, k <= 0
% gives \CALX_fr_k0 = \CALX_fr_id), general path \CALX_fr_kgen beyond 47.
% \CALX_fblocks{m} is the rounding with
% k = 8(ceil(D/8) - m); ceil(D/8) = (D+3)/8 in \numexpr.
%
% \CALX_fr_w <new block>!{s}{D'}{e'}: block 200000000: carry
% (\CALX_fr_cy); D' <= 8 (the kept block is the top block): the digit
% count grows by one if the top block reaches 10^D' (\CALX_fr_top).
% The carry path grabs the kept blocks (count known from D') up to the top
% one, since the header precedes the blocks; it is rare.
%
% Dispatch (\CALX_fr_a) on the first token of X, rarest cases first, one
% macro per branch, P and the token put back: I (\CALX_fr_i: I with the
% sign that follows), M (\CALX_fr_m), - (raw), F (\CALX_fr_f: k = D - P,
% the tag a parameter), otherwise a digit (raw). M (the integer type of
% \xintiieval: same blocks and e as F): zero gives F+0.0. (\CALX_fr_mz);
% else \CALX_fr_mm grabs the blocks once, reads the digit count D on the
% top block (as \CALX_fmx_c) and \CALX_fr_mn rounds F<s><D>.<e>.<blocks>.
% Raw (\CALX_fr_x, A[N] or A/B[N]): split at the bracket only, P put
% behind (A/.P.N]); \CALX_fr_xs: the token after the first slash is the
% dot exactly when there is no slash, \xint_gob_til_dot selects. A[N]
% (\CALX_fr_xa): \CALX_ffr_a gives the exact F value of A 10^N, rounded
% by \CALX_fr_f. A/B[N] (\CALX_fr_xf): two tokens decide B = 1 (1 then
% the slash: jumper \CALX_fr_xo to \CALX_fr_xa); else \CALX_fr_xg, the
% exact F values of A 10^N and of B, and \CALX_fr_xk dispatches by
% \csname to calxfp's division: \CALX_fd_zz (B = 0: 0/0
% DivisionUndefined, x/0 DivisionByZero), \CALX_fd_zero (A = 0) or the
% generic division path \CALX_fd_g, valid for any digit counts (the
% truncated quotient has at least P + 1 digits: round half away from zero
% is that of A 10^N / B). The \xint: appended by \CALX_fround stays in
% the stream on all paths.
% xintexpr.sty redefines \CALX_fr_x with xintfrac's \XINTinFloat, which
% parses any xintfrac input.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fround #1#2{\expandafter\CALX_fr_a\the\numexpr#1\expandafter.%
    \romannumeral`&&@#2\xint:}%
\def\CALX_fnround #1#2{\expandafter\CALX_fr_a\the\numexpr#1\expandafter.%
    \romannumeral`&&@#2}%
\def\CALX_fr_a #1.#2%
{%
    \if I#2\xint_dothis\CALX_fr_i\fi
    \if M#2\xint_dothis\CALX_fr_m\fi
    \if -#2\xint_dothis\CALX_fr_x\fi
    \if F#2\xint_dothis\CALX_fr_f\fi
    \xint_orthat\CALX_fr_x #1.#2%
}%
\def\CALX_fr_i #1.#2{ I}%
\def\CALX_fr_f #1.#2#3#4.{\expandafter\CALX_fr_b\the\numexpr#4-#1.#3#4.}%
\def\CALX_fr_m #1.#2#3#4.%
{%
    \ifnum#4=\xint_c_ \expandafter\CALX_fr_mz\fi
    \CALX_fr_mm #1.#3#4.%
}%
\def\CALX_fr_mz\CALX_fr_mm #1\xint:{ F+0.0.\xint:}%
\def\CALX_fr_mm #1.#2#3.#4.#5\xint:%
{%
    \expandafter\CALX_fr_mn\the\numexpr\xint_c_viii*(#3-\xint_c_i)%
      +\CALX_nskip\CALX_fm_gl #3-\xint_c_i.#5\xint:.#1.#2#4.#5\xint:
}%
\def\CALX_fr_mn #1.#2.#3{\expandafter\CALX_fr_b\the\numexpr#1-#2.#3#1.}%
\def\CALX_fr_x #1.#2[{\CALX_fr_xs #2/.#1.}%
\def\CALX_fr_xs #1/#2%
   {\xint_gob_til_dot #2\CALX_fr_xa.\CALX_fr_xf #1/#2}%
\def\CALX_fr_xa.\CALX_fr_xf#1/.#2.#3]%
   {\expandafter\CALX_fr_f\the\numexpr#2\expandafter.%
    \romannumeral0\CALX_ffr_a#1[#3]\xint:}%
\def\CALX_fr_xf #1/#2#3%
{%
    \if1#2\if/#3\CALX_fr_xo\fi\fi
    \CALX_fr_xg #1/#2#3%
}%
\def\CALX_fr_xo\fi\fi\CALX_fr_xg #1/#2#3{\fi\fi\CALX_fr_xa.\CALX_fr_xf #1/}%
\def\CALX_fr_xg #1/#2/.#3.#4]%
   {\expandafter\CALX_fr_xk\expanded{\romannumeral0\CALX_ffr_a#1[#4]\xint:%
    \xint:\romannumeral0\CALX_ffr_a#2[0]\xint:\xint:}{#3}}%
\def\CALX_fr_xk F#1#2.#3.#4\xint:F#5#6.#7.#8\xint:%
{%
    \csname CALX_fd_\ifnum#6=\xint_c_ zz\else\ifnum#2=\xint_c_ zero\else
      g\fi\fi\endcsname {#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}%
}%
\def\CALX_fr_b #1.%
   {\csname CALX_fr_k\ifnum#1>\xint_c_ \ifnum#1>47 gen\else#1\fi\else0\fi
    \endcsname #1.}%
\def\CALX_fblocks #1#2{\expandafter\CALX_fb_a\the\numexpr#1\expandafter.%
    \romannumeral`&&@#2}%
\def\CALX_fb_a #1.#2{\if I#2\xint_dothis{ I}\fi\xint_orthat{\CALX_fb_c #1.}}%
\def\CALX_fb_c #1.#2#3.%
   {\expandafter\CALX_fr_b\the\numexpr\xint_c_viii*((#3+\xint_c_iii)/%
       \xint_c_viii-#1).#2#3.}%
\def\CALX_fr_id #1.#2#3.{ F#2#3.}%
\def\CALX_fr_gz #1{#1}%
\def\CALX_fr_gi #1#2#3#41#5!{#1{#2}{#3}{#4}}%
\def\CALX_fr_gii #1#2#3#41#5!1#6!{#1{#2}{#3}{#4}}%
\def\CALX_fr_giii #1#2#3#41#5!1#6!1#7!{#1{#2}{#3}{#4}}%
\def\CALX_fr_giv #1#2#3#41#5!1#6!1#7!1#8!{#1{#2}{#3}{#4}}%
\def\CALX_fr_gv #1#2#3#41#5!1#6!1#7!1#8!1#9!{#1{#2}{#3}{#4}}%
\def\CALX_fr_sk #1.%
{%
    \ifnum#1>\xint_c_vi \expandafter\CALX_fr_sq
    \else\csname CALX_fr_q#1\expandafter\endcsname\fi #1.%
}%
\def\CALX_fr_sq #1.#2#3!#4!#5!#6!#7!#8!#9!%
   {\expandafter\CALX_fr_sk\the\numexpr#1-\xint_c_vii.{#2}}%
\expandafter\def\csname CALX_fr_q0\endcsname #1.#2{#2}%
\expandafter\def\csname CALX_fr_q1\endcsname #1.#2#3!{#2}%
\expandafter\def\csname CALX_fr_q2\endcsname #1.#2#3!#4!{#2}%
\expandafter\def\csname CALX_fr_q3\endcsname #1.#2#3!#4!#5!{#2}%
\expandafter\def\csname CALX_fr_q4\endcsname #1.#2#3!#4!#5!#6!{#2}%
\expandafter\def\csname CALX_fr_q5\endcsname #1.#2#3!#4!#5!#6!#7!{#2}%
\expandafter\def\csname CALX_fr_q6\endcsname #1.#2#3!#4!#5!#6!#7!#8!{#2}%
\expandafter\let\csname CALX_fr_k0\endcsname\CALX_fr_id
\expandafter\def\csname CALX_fr_k1\endcsname#1.#2#3.#4.{\CALX_fr_gz%
    \CALX_fr_vi{#2}{#3}{#4}}%
\expandafter\def\csname CALX_fr_k2\endcsname#1.#2#3.#4.{\CALX_fr_gz%
    \CALX_fr_vii{#2}{#3}{#4}}%
\expandafter\def\csname CALX_fr_k3\endcsname#1.#2#3.#4.{\CALX_fr_gz%
    \CALX_fr_viii{#2}{#3}{#4}}%
\expandafter\def\csname CALX_fr_k4\endcsname#1.#2#3.#4.{\CALX_fr_gz%
    \CALX_fr_viv{#2}{#3}{#4}}%
\expandafter\def\csname CALX_fr_k5\endcsname#1.#2#3.#4.{\CALX_fr_gz%
    \CALX_fr_vv{#2}{#3}{#4}}%
\expandafter\def\csname CALX_fr_k6\endcsname#1.#2#3.#4.{\CALX_fr_gz%
    \CALX_fr_vvi{#2}{#3}{#4}}%
\expandafter\def\csname CALX_fr_k7\endcsname#1.#2#3.#4.{\CALX_fr_gz%
    \CALX_fr_vvii{#2}{#3}{#4}}%
\expandafter\def\csname CALX_fr_k8\endcsname#1.#2#3.#4.{\CALX_fr_gz%
    \CALX_fr_z{#2}{#3-8}{#4+1}}%
\expandafter\def\csname CALX_fr_k9\endcsname#1.#2#3.#4.{\CALX_fr_gi%
    \CALX_fr_vi{#2}{#3-8}{#4+1}}%
\expandafter\def\csname CALX_fr_k10\endcsname#1.#2#3.#4.{\CALX_fr_gi%
    \CALX_fr_vii{#2}{#3-8}{#4+1}}%
\expandafter\def\csname CALX_fr_k11\endcsname#1.#2#3.#4.{\CALX_fr_gi%
    \CALX_fr_viii{#2}{#3-8}{#4+1}}%
\expandafter\def\csname CALX_fr_k12\endcsname#1.#2#3.#4.{\CALX_fr_gi%
    \CALX_fr_viv{#2}{#3-8}{#4+1}}%
\expandafter\def\csname CALX_fr_k13\endcsname#1.#2#3.#4.{\CALX_fr_gi%
    \CALX_fr_vv{#2}{#3-8}{#4+1}}%
\expandafter\def\csname CALX_fr_k14\endcsname#1.#2#3.#4.{\CALX_fr_gi%
    \CALX_fr_vvi{#2}{#3-8}{#4+1}}%
\expandafter\def\csname CALX_fr_k15\endcsname#1.#2#3.#4.{\CALX_fr_gi%
    \CALX_fr_vvii{#2}{#3-8}{#4+1}}%
\expandafter\def\csname CALX_fr_k16\endcsname#1.#2#3.#4.{\CALX_fr_gi%
    \CALX_fr_z{#2}{#3-16}{#4+2}}%
\expandafter\def\csname CALX_fr_k17\endcsname#1.#2#3.#4.{\CALX_fr_gii%
    \CALX_fr_vi{#2}{#3-16}{#4+2}}%
\expandafter\def\csname CALX_fr_k18\endcsname#1.#2#3.#4.{\CALX_fr_gii%
    \CALX_fr_vii{#2}{#3-16}{#4+2}}%
\expandafter\def\csname CALX_fr_k19\endcsname#1.#2#3.#4.{\CALX_fr_gii%
    \CALX_fr_viii{#2}{#3-16}{#4+2}}%
\expandafter\def\csname CALX_fr_k20\endcsname#1.#2#3.#4.{\CALX_fr_gii%
    \CALX_fr_viv{#2}{#3-16}{#4+2}}%
\expandafter\def\csname CALX_fr_k21\endcsname#1.#2#3.#4.{\CALX_fr_gii%
    \CALX_fr_vv{#2}{#3-16}{#4+2}}%
\expandafter\def\csname CALX_fr_k22\endcsname#1.#2#3.#4.{\CALX_fr_gii%
    \CALX_fr_vvi{#2}{#3-16}{#4+2}}%
\expandafter\def\csname CALX_fr_k23\endcsname#1.#2#3.#4.{\CALX_fr_gii%
    \CALX_fr_vvii{#2}{#3-16}{#4+2}}%
\expandafter\def\csname CALX_fr_k24\endcsname#1.#2#3.#4.{\CALX_fr_gii%
    \CALX_fr_z{#2}{#3-24}{#4+3}}%
\expandafter\def\csname CALX_fr_k25\endcsname#1.#2#3.#4.{\CALX_fr_giii%
    \CALX_fr_vi{#2}{#3-24}{#4+3}}%
\expandafter\def\csname CALX_fr_k26\endcsname#1.#2#3.#4.{\CALX_fr_giii%
    \CALX_fr_vii{#2}{#3-24}{#4+3}}%
\expandafter\def\csname CALX_fr_k27\endcsname#1.#2#3.#4.{\CALX_fr_giii%
    \CALX_fr_viii{#2}{#3-24}{#4+3}}%
\expandafter\def\csname CALX_fr_k28\endcsname#1.#2#3.#4.{\CALX_fr_giii%
    \CALX_fr_viv{#2}{#3-24}{#4+3}}%
\expandafter\def\csname CALX_fr_k29\endcsname#1.#2#3.#4.{\CALX_fr_giii%
    \CALX_fr_vv{#2}{#3-24}{#4+3}}%
\expandafter\def\csname CALX_fr_k30\endcsname#1.#2#3.#4.{\CALX_fr_giii%
    \CALX_fr_vvi{#2}{#3-24}{#4+3}}%
\expandafter\def\csname CALX_fr_k31\endcsname#1.#2#3.#4.{\CALX_fr_giii%
    \CALX_fr_vvii{#2}{#3-24}{#4+3}}%
\expandafter\def\csname CALX_fr_k32\endcsname#1.#2#3.#4.{\CALX_fr_giii%
    \CALX_fr_z{#2}{#3-32}{#4+4}}%
\expandafter\def\csname CALX_fr_k33\endcsname#1.#2#3.#4.{\CALX_fr_giv%
    \CALX_fr_vi{#2}{#3-32}{#4+4}}%
\expandafter\def\csname CALX_fr_k34\endcsname#1.#2#3.#4.{\CALX_fr_giv%
    \CALX_fr_vii{#2}{#3-32}{#4+4}}%
\expandafter\def\csname CALX_fr_k35\endcsname#1.#2#3.#4.{\CALX_fr_giv%
    \CALX_fr_viii{#2}{#3-32}{#4+4}}%
\expandafter\def\csname CALX_fr_k36\endcsname#1.#2#3.#4.{\CALX_fr_giv%
    \CALX_fr_viv{#2}{#3-32}{#4+4}}%
\expandafter\def\csname CALX_fr_k37\endcsname#1.#2#3.#4.{\CALX_fr_giv%
    \CALX_fr_vv{#2}{#3-32}{#4+4}}%
\expandafter\def\csname CALX_fr_k38\endcsname#1.#2#3.#4.{\CALX_fr_giv%
    \CALX_fr_vvi{#2}{#3-32}{#4+4}}%
\expandafter\def\csname CALX_fr_k39\endcsname#1.#2#3.#4.{\CALX_fr_giv%
    \CALX_fr_vvii{#2}{#3-32}{#4+4}}%
\expandafter\def\csname CALX_fr_k40\endcsname#1.#2#3.#4.{\CALX_fr_giv%
    \CALX_fr_z{#2}{#3-40}{#4+5}}%
\expandafter\def\csname CALX_fr_k41\endcsname#1.#2#3.#4.{\CALX_fr_gv%
    \CALX_fr_vi{#2}{#3-40}{#4+5}}%
\expandafter\def\csname CALX_fr_k42\endcsname#1.#2#3.#4.{\CALX_fr_gv%
    \CALX_fr_vii{#2}{#3-40}{#4+5}}%
\expandafter\def\csname CALX_fr_k43\endcsname#1.#2#3.#4.{\CALX_fr_gv%
    \CALX_fr_viii{#2}{#3-40}{#4+5}}%
\expandafter\def\csname CALX_fr_k44\endcsname#1.#2#3.#4.{\CALX_fr_gv%
    \CALX_fr_viv{#2}{#3-40}{#4+5}}%
\expandafter\def\csname CALX_fr_k45\endcsname#1.#2#3.#4.{\CALX_fr_gv%
    \CALX_fr_vv{#2}{#3-40}{#4+5}}%
\expandafter\def\csname CALX_fr_k46\endcsname#1.#2#3.#4.{\CALX_fr_gv%
    \CALX_fr_vvi{#2}{#3-40}{#4+5}}%
\expandafter\def\csname CALX_fr_k47\endcsname#1.#2#3.#4.{\CALX_fr_gv%
    \CALX_fr_vvii{#2}{#3-40}{#4+5}}%
\def\CALX_fr_kgen #1.#2#3.#4.%
{%
    \expandafter\CALX_fr_kgen_a\the\numexpr(#1-\xint_c_iv)/\xint_c_viii%
        \expandafter.%
    \the\numexpr#1-\xint_c_viii*((#1-\xint_c_iv)/\xint_c_viii).#2#3.#4.%
}%
\def\CALX_fr_kgen_a #1.#2.#3#4.#5.% a, c, s, D, e
{%
    \expandafter\CALX_fr_sk\the\numexpr#1\ifnum#2=\xint_c_ -\xint_c_i\fi.%
    {\csname CALX_fr_\ifnum#2=\xint_c_ z\else v#2\fi\endcsname
     {#3}{#4-\xint_c_viii*#1}{#5+#1}}%
}%
\def\CALX_fr_vi #1#2#31#4!%
   {\expandafter\CALX_fr_w\the\numexpr1#4/10*10!{#1}{#2}{#3}}%
\def\CALX_fr_vii #1#2#31#4!%
   {\expandafter\CALX_fr_w\the\numexpr1#4/100*100!{#1}{#2}{#3}}%
\def\CALX_fr_viii #1#2#31#4!%
   {\expandafter\CALX_fr_w\the\numexpr1#4/1000*1000!{#1}{#2}{#3}}%
\def\CALX_fr_viv #1#2#31#4!%
   {\expandafter\CALX_fr_w\the\numexpr1#4/10000*10000!{#1}{#2}{#3}}%
\def\CALX_fr_vv #1#2#31#4!%
   {\expandafter\CALX_fr_w\the\numexpr1#4/100000*100000!{#1}{#2}{#3}}%
\def\CALX_fr_vvi #1#2#31#4!%
   {\expandafter\CALX_fr_w\the\numexpr1#4/1000000*1000000!{#1}{#2}{#3}}%
\def\CALX_fr_vvii #1#2#31#4!%
   {\expandafter\CALX_fr_w\the\numexpr1#4/10000000*10000000!{#1}{#2}{#3}}%
\def\CALX_fr_z #1#2#31#4#5!1#6!%
{%
    \ifnum#4>\xint_c_iv \xint_dothis{\expandafter\CALX_fr_w\the\numexpr1#6+%
        \xint_c_i!}\fi
    \xint_orthat{\CALX_fr_w1#6!}{#1}{#2}{#3}%
}%
\def\CALX_fr_w #1!#2#3%
{%
    \ifnum#1=200000000 \xint_dothis\CALX_fr_cy\fi
    \ifnum\numexpr#3<\xint_c_ix \xint_dothis\CALX_fr_top\fi
    \xint_orthat\CALX_fr_out{#1}{#2}{#3}%
}%
\def\CALX_fr_out #1#2#3#4{\expanded{ F#2\the\numexpr#3.\the\numexpr#4.}#1!}%
\def\CALX_fr_top #1#2#3%
{%
    \ifnum#1<\numexpr\xint_c_e_viii+\CALX_pten{#3}\relax
      \xint_dothis\CALX_fr_out\fi
    \xint_orthat\CALX_fr_outp{#1}{#2}{#3}%
}%
\def\CALX_fr_outp #1#2#3#4{\expanded{ F#2\the\numexpr#3+\xint_c_i.\the%
    \numexpr#4.}#1!}%
\expandafter\let\csname CALX_fr_v1\endcsname\CALX_fr_vi
\expandafter\let\csname CALX_fr_v2\endcsname\CALX_fr_vii
\expandafter\let\csname CALX_fr_v3\endcsname\CALX_fr_viii
\expandafter\let\csname CALX_fr_v4\endcsname\CALX_fr_viv
\expandafter\let\csname CALX_fr_v5\endcsname\CALX_fr_vv
\expandafter\let\csname CALX_fr_v6\endcsname\CALX_fr_vvi
\expandafter\let\csname CALX_fr_v7\endcsname\CALX_fr_vvii
%    \end{macrocode}
%\begin{lverb}
% Carry. #1=200000000, #2=s, #3=D', #4=e'. If D' <= 8 the top block
% overflowed to 10^8: blocks 100000000!100000001!, D'+1. Else
% \CALX_fr_cya <r>.{s}{D'}{e'}{acc} with r = ceil(D'/8) - 1 kept blocks
% above: 99999999 below the top one -> 100000000, continue; else +1 and
% stop. At the top block (r = 1, d = D' - 8(ceil(D'/8) - 1) digits): +1;
% if it reaches 10^d: D'+1 (and d = 8: two blocks).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fr_cy #1#2#3#4%
{%
    \ifnum\numexpr#3<\xint_c_ix
      \xint_dothis{\expanded{ F#2\the\numexpr#3+\xint_c_i.\the\numexpr#4.}%
                   100000000!100000001!}\fi
    \xint_orthat{\expandafter\CALX_fr_cya
       \the\numexpr(#3+\xint_c_iii)/\xint_c_viii-%
           \xint_c_i.{#2}{#3}{#4}{100000000!}}%
}%
\def\CALX_fr_cya #1.#2#3#4#51#6!%
{%
    \ifnum#1=\xint_c_i \xint_dothis\CALX_fr_cyt\fi
    \ifnum#6=99999999 \xint_dothis\CALX_fr_cyn\fi
    \xint_orthat\CALX_fr_cys #1.{#2}{#3}{#4}{#5}{#6}%
}%
\def\CALX_fr_cyn #1.#2#3#4#5#6%
   {\expandafter\CALX_fr_cya\the\numexpr#1-%
       \xint_c_i.{#2}{#3}{#4}{#5100000000!}}%
\def\CALX_fr_cys #1.#2#3#4#5#6%
   {\expanded{ F#2\the\numexpr#3.\the\numexpr#4.#5\the\numexpr1#6+%
       \xint_c_i!}}%
\def\CALX_fr_cyt #1.#2#3#4#5#6%
{%
    \ifnum\numexpr#6+\xint_c_i\relax
         =\numexpr\CALX_pten{#3-\xint_c_viii*((#3+\xint_c_iii)/%
             \xint_c_viii-\xint_c_i)}\relax
      \xint_dothis{\ifnum#6=99999999
         \expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo\fi
         {\expanded{ F#2\the\numexpr#3+\xint_c_i.\the%
             \numexpr#4.#5100000000!100000001!}}%
         {\expanded{ F#2\the\numexpr#3+\xint_c_i.\the\numexpr#4.#5\the%
             \numexpr1#6+\xint_c_i!}}}\fi
    \xint_orthat{\expanded{ F#2\the\numexpr#3.\the\numexpr#4.#5\the%
        \numexpr1#6+\xint_c_i!}}%
}%
%    \end{macrocode}
% \subsection{Conversions}
% \subsubsection{\csh{CALX_ffromraw}, \csh{CALX_ftoraw}}
%\begin{lverb}
% Syntax (use with \romannumeral0; argument f-expanded):
%(
%  \CALX_ffromraw{A[N]}  -> <space>F<s><D>.<e>.<blocks>
%:  \CALX_ftoraw{X}       -> <A>[<8e>]   (X an F value; I values unchanged)
%)
% Conversions between xint's raw floats A[N] and native floats (use with
% \romannumeral0, argument f-expanded).
%
% \CALX_ffromraw{A[N]}: A integer without leading zeros (optional -), N
% any integer. N = 8e + r, 0 <= r < 8, e = floor(N/8) = (2N-7)/16 in
% \numexpr (never a tie); the r zeros are appended to the string |A|
% before \CALX_nfromraw; D = len(|A|) + r (\xintLength). 0[N]: F+0.0.
%
% \CALX_ftoraw{F}: \CALX_ntoraw of the mantissa (n = ceil(D/8) =
% (2D+7)/16), exponent 8e: <A>[<8e>] (trailing zeros kept, value
% exact). F+0.0.: 0[0]. I+, I-, I? are returned unchanged.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ffromraw #1{\expandafter\CALX_ffr_a\romannumeral`&&@#1\xint:}%
\def\CALX_ffr_a #1[#2]\xint:%
   {\expandafter\CALX_ffr_b\the\numexpr(\xint_c_ii*(#2)-\xint_c_vii)/16.#2.#1%
       \xint:}%
\def\CALX_ffr_b #1.#2.#3#4\xint:%
{%
    \if 0#3\xint_dothis\CALX_ffr_z\fi
    \if -#3\xint_dothis{\CALX_ffr_c-{#4}}\fi
    \xint_orthat{\CALX_ffr_c+{#3#4}}{#1}{#2}%
}%
\def\CALX_ffr_z #1#2{ F+0.0.}%
\def\CALX_ffr_zs #1{\csname CALX_ffr_zs\the\numexpr#1\endcsname}%
\expandafter\def\csname CALX_ffr_zs0\endcsname{}%
\expandafter\def\csname CALX_ffr_zs1\endcsname{0}%
\expandafter\def\csname CALX_ffr_zs2\endcsname{00}%
\expandafter\def\csname CALX_ffr_zs3\endcsname{000}%
\expandafter\def\csname CALX_ffr_zs4\endcsname{0000}%
\expandafter\def\csname CALX_ffr_zs5\endcsname{00000}%
\expandafter\def\csname CALX_ffr_zs6\endcsname{000000}%
\expandafter\def\csname CALX_ffr_zs7\endcsname{0000000}%
\def\CALX_ffr_c #1#2#3#4%
{%
    \expandafter\CALX_ffr_d\romannumeral0%
    \CALX_nfromraw{\expanded{#2\CALX_ffr_zs{\numexpr#4-\xint_c_viii*#3%
        \relax}}}\xint:
    #1{\the\numexpr\xintLength{#2}+#4-\xint_c_viii*#3}{#3}%
}%
\def\CALX_ffr_d N+#1.#2\xint:#3#4#5{\expanded{ F#3#4.#5.}#2}%
\def\CALX_ftoraw #1{\expandafter\CALX_ftr_a\romannumeral`&&@#1\xint:}%
\def\CALX_ftr_a #1#2%
   {\if I#1\xint_dothis{\CALX_ftr_sp#2}\fi\xint_orthat{\CALX_ftr_b#2}}%
\def\CALX_ftr_sp #1\xint:{ I#1}%
\def\CALX_ftr_b #1#2.#3.#4\xint:%
{%
    \ifnum#2=\xint_c_ \xint_dothis{ 0[0]}\fi
    \xint_orthat{\expandafter\CALX_ftr_c\romannumeral0\CALX_ntoraw
      {\expandafter N\expandafter#1\the\numexpr(\xint_c_ii*#2+%
          \xint_c_vii)/16.#4}\xint:{#3}}%
}%
\def\CALX_ftr_c #1\xint:#2{\expanded{ #1[\the\numexpr\xint_c_viii*#2\relax]}}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_ti_f}}
%\begin{lverb}
% Syntax (use with \romannumeral0):
%(
%  \CALX_ti_f F<s><D>.<e>.<blocks>\xint:  -> <space>F<s><D'>.<e'>.<blocks'>
%)
% Truncation of a native float to an integer (towards zero), exact; the
% tag token is taken as a parameter and re-emitted. e >= 0: unchanged.
% e < 0: the -e low blocks are dropped (\CALX_nskip), D' = D + 8e (zero
% if D' <= 0), e' = 0.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ti_f #1#2#3.#4.%
   {\ifnum#4<\xint_c_ \expandafter\CALX_ti_g\else\expandafter\CALX_ti_id\fi
    #1#2#3.#4.}%
\def\CALX_ti_id #1\xint:{ #1}%
\def\CALX_ti_g #1#2#3.#4.%
   {\expandafter\CALX_ti_i\the\numexpr#3+\xint_c_viii*#4.#1#2{#4}}%
\def\CALX_ti_i #1.#2#3%
   {\ifnum#1>\xint_c_ \expandafter\CALX_ti_j\else\expandafter\CALX_ti_z\fi
    #1.#2#3}%
\def\CALX_ti_z #1.#2#3#4#5\xint:{ #2+0.0.}%
\def\CALX_ti_j #1.#2#3#4#5\xint:%
   {\expandafter\CALX_ti_o\romannumeral\CALX_nskip\xint_c_ 0-#4.#5\xint:%
    #2#3#1.0.}%
\def\CALX_ti_o #1\xint:#2.0.{ #2.0.#1}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_fnum}}
%\begin{lverb}
% Syntax (use with \romannumeral0; X f-expanded):
%(
%  \CALX_fnum X\xint:  -> <space>R   (or -R... without space)
%)
% R: explicit digits (raw integer, as xint's \xintnum) of the truncation
% of X towards zero. X: native F, M (\xintiieval) or I value, or raw A,
% A[N], A/B, A/B[N] (A, B integers without leading zeros, B > 0; values
% of \xinteval and literals). For \calxFpToNum (calx.sty), which takes
% indices and counts from the values of any of the three parsers.
%
% F: e = 0 and D <= 8 (zero or one block): \numexpr on the block (with a
% sentinel block for zero); else \CALX_ti_f, then the digits of the M
% form M<s><n>.<e>.<blocks>, n = ceil(D/8) = (2D+7)/16 (\CALX_mtoraw_t,
% which also writes the 8e zeros). M: \CALX_mtoraw_t. I: InvalidOperation
% (an I result of the handler, as the default I?, is replaced by 0: an
% integer is required). Raw: A = 0: 0; B = 1 and N >= 0: A followed by N zeros; else
% calxint's \CALX_iiq: one native division of A 10^max(N,0) by
% B 10^max(-N,0) with floor quotient Q; exact or Q >= 0: Q, else Q + 1.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fnum #1%
{%
    \if I#1\xint_dothis\CALX_fnum_i\fi
    \if M#1\xint_dothis\CALX_mtoraw_t\fi
    \if F#1\xint_dothis\CALX_fnum_b\fi
    \xint_orthat\CALX_fnum_r #1%
}%
\def\CALX_fnum_i #1\xint:%
   {\expandafter\CALX_fnum_j\romannumeral`&&@\CALX_signalcondition
    {InvalidOperation}{#1 has no integer value}{}{0}\xint:}%
\def\CALX_fnum_j #1{%
    \if I#1\xint_dothis\CALX_fnum_jz\fi
    \xint_orthat\CALX_fnum_jn #1%
}%
\def\CALX_fnum_jz #1\xint:{ 0}%
\def\CALX_fnum_jn #1#2\xint:{ #1#2}%
\def\CALX_fnum_b #1#2#3.#4.{%
    \ifnum\ifnum#4=\xint_c_ #3\else9\fi<\xint_c_ix
      \xint_dothis\CALX_fnum_bs\fi
    \xint_orthat\CALX_fnum_bg #1#2#3.#4.%
}%
\def\CALX_fnum_bs #1#2#3.#4.#5\xint:{%
    \CALX_fnum_c#2#5100000000!\xint:%
}%
\def\CALX_fnum_bg #1#2#3.#4.#5\xint:{%
    \expandafter\CALX_fnum_m
      \romannumeral0\CALX_ti_f F#2#3.#4.#5\xint:\xint:%
}%
\def\CALX_fnum_c #11#2!#3\xint:{ \the\numexpr#1#2\relax}%
\def\CALX_fnum_m F#1#2.%
   {\expandafter\CALX_mtoraw_t\expandafter F\expandafter#1%
    \the\numexpr(\xint_c_ii*#2+\xint_c_vii)/16.}%
\def\CALX_fnum_r #1\xint:{\CALX_fnum_s #1[0]\xint:}%
\def\CALX_fnum_s #1[#2]#3\xint:{\CALX_fnum_t #1/1/\xint:{#2}}%
\def\CALX_fnum_t #1/#2/#3\xint:#4%
{%
    \if0#1\xint_dothis\CALX_fnum_z\fi
    \ifnum#4<\xint_c_ \xint_dothis\CALX_fnum_q\fi
    \xint_orthat{\CALX_fnum_v #2\xint:}{#1}{#2}{#4}%
}%
\def\CALX_fnum_z #1#2#3{ 0}%
\def\CALX_fnum_v #1#2\xint:%
   {\if1#1\if\relax\detokenize{#2}\relax\CALX_fnum_w\fi\fi\CALX_fnum_q}%
\def\CALX_fnum_w #1\CALX_fnum_q#2#3#4{#1\expanded{ #2\xintReplicate{#4}0}}%
\def\CALX_fnum_q {\CALX_iiq\CALX_fnum_e\CALX_fnum_f}%
\def\CALX_fnum_e #1{\CALX_ntoraw_a #1\xint:}%
\def\CALX_fnum_f #1{\CALX_fnum_g #1\xint:}%
\def\CALX_fnum_g N#1%
   {\if-#1\expandafter\CALX_fnum_u\else\expandafter\CALX_ntoraw_a\fi N#1}%
\def\CALX_fnum_u #1\xint:%
   {\expandafter\CALX_ntoraw_a\romannumeral0\CALX_nadd{#1}{N+1.100000001!}%
    \xint:}%
% \end{macrocode} 
%\begin{lverb}
% FROM SESSION 58 WHICH WAS A COMPLETE CASTROPHY AFTER A FEW HOURS.
%
% "Proposal, not inserted, for calxfp after \CALX_fnum (the
%  name \CALX_ftom is unused). Use it as \romannumeral0\CALX_ftom{X}: it
%  f-expands X and outputs  M…, the truncation, like \calxFpToNum but in M
%  format.»
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ftom #1{\expandafter\CALX_ftom_a\romannumeral`&&@#1\xint:}%
\def\CALX_ftom_a #1%
{%
    \if M#1\xint_dothis\CALX_ftom_k\fi
    \if F#1\xint_dothis\CALX_ftom_f\fi
    \if I#1\xint_dothis\CALX_ftom_i\fi
    \xint_orthat\CALX_ftom_r #1%
}%
\def\CALX_ftom_k #1\xint:{ #1}%
\def\CALX_ftom_f #1\xint:%
   {\expandafter\CALX_ftom_m\romannumeral0\CALX_ti_f #1\xint:}%
\def\CALX_ftom_m #1#2#3.%
   {\expandafter\CALX_ftom_n\the\numexpr(\xint_c_ii*#3+\xint_c_vii)/16.#2}%
\catcode`M=12
\def\CALX_ftom_n #1.#2{ M#2#1.}%
\def\CALX_ftom_j #1#2\xint:%
   {\if I#1\xint_dothis{ M+0.0.}\fi\xint_orthat{\CALX_mfromraw{#1#2}}}%
\catcode`M=11
\def\CALX_ftom_i #1\xint:%
   {\expandafter\CALX_ftom_j\romannumeral`&&@\CALX_signalcondition
    {InvalidOperation}{#1 has no integer value}{}{0}\xint:}%
\def\CALX_ftom_r #1\xint:%
   {\expandafter\CALX_ntom\romannumeral0\CALX_nfromraw
    {\romannumeral0\CALX_fnum_r #1\xint:}}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_fint}}
%\begin{lverb}
% Syntax (use with \romannumeral0; X f-expanded, not an I value):
%(
%  \CALX_fint X\xint:  -> <space><s><T>.<d><z>
%)
% Truncation of X towards zero to an integer: s the sign of X (+ for
% zero), T the explicit digits of |trunc(X)|, d the first omitted digit
% (the last digit of floor(10|X|)), z = 1 if |X| - T is not zero, else 0.
% Hence round(X) = s(T + [d >= 5]); ceil(X) = T + z if s is +, else -T;
% floor(X) = T if s is +, else -(T + z). X: F, M, or raw A, A[N], A/B,
% A/B[N].
%
% F with e >= 0 or zero: an integer (\CALX_fnum_b), d = z = 0. F with
% e < 0: the m = -e low blocks are omitted, whole blocks; of the n =
% ceil(D/8) blocks the min(m, n) lowest are read (\CALX_fint_w: z), d is
% the first digit of block m - 1 (0 if m > n); kept blocks (n > m):
% \CALX_ntoraw_a. M: an integer. Raw, B = 1: the F value of A 10^N
% (\CALX_ffr_a, the digits regrouped in blocks), then as F. B > 1: one
% division of |A| 10^(N+1) by B (\CALX_ndivision, shifts \CALX_nshl, k <=
% 0 identity): Q = floor(10|X|) and R; T = floor(Q/10) (\CALX_nshr), d =
% Q mod 10 (last digit of the lowest block), z = 1 if R > 0 or d > 0.
%
% \CALX_fintp{A}{B}{N} (use with \romannumeral0; A, B integers without
% leading zeros, B > 0, N explicit digits): the same for A/B[N] given by
% its parts (xintfrac's \xintTrunc, \xintRound, \xintFloor, \xintCeil).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fintp #1#2{\CALX_fint_rc #2\xint:{#1}{#2}}%
\def\CALX_fint #1%
{%
    \if F#1\xint_dothis\CALX_fint_f\fi
    \if M#1\xint_dothis\CALX_fint_m\fi
    \xint_orthat\CALX_fint_r #1%
}%
\def\CALX_fint_m #1#2#3\xint:%
   {\expanded{ #2\romannumeral0\CALX_mtoraw_t M+#3\xint:.00}}%
\def\CALX_fint_f #1#2#3.#4.%
{%
    \ifnum#3=\xint_c_ \xint_dothis\CALX_fint_z\fi
    \ifnum#4<\xint_c_ \xint_dothis\CALX_fint_n\fi
    \xint_orthat\CALX_fint_i #2#3.#4.%
}%
\def\CALX_fint_z #1\xint:{ +0.00}%
\def\CALX_fint_i #1#2.#3.#4\xint:%
   {\expanded{ #1\romannumeral0\CALX_fnum_b F+#2.#3.#4\xint:.00}}%
\def\CALX_fint_n #1#2.#3.%
   {\expandafter\CALX_fint_a\the\numexpr(#2+\xint_c_iii)/\xint_c_viii+#3%
    \expandafter.\the\numexpr-#3.#1}%
\def\CALX_fint_a #1.#2.#3%
{%
    \ifnum#1>\xint_c_ \xint_dothis{\CALX_fint_w #2.0.{\CALX_fint_k#3{#1}}}\fi
    \ifnum#1=\xint_c_ \xint_dothis{\CALX_fint_w #2.0.{\CALX_fint_t#3}}\fi
    \xint_orthat
      {\expandafter\CALX_fint_w\the\numexpr#2+#1.0.{\CALX_fint_u#3}}%
}%
\def\CALX_fint_w #1.#2.#31#4!%
{%
    \ifnum#1=\xint_c_i
      \xint_dothis{\CALX_fint_x#4\xint:{#3}{\ifnum#4>\xint_c_ 1\else#2\fi}}\fi
    \xint_orthat{\expandafter\CALX_fint_w\the\numexpr#1-\xint_c_i
      \expandafter.\the\numexpr\ifnum#4>\xint_c_ 1\else#2\fi.{#3}}%
}%
\def\CALX_fint_x #1#2\xint:#3{#3{#1}}%
\def\CALX_fint_k #1#2#3#4#5\xint:%
   {\expanded{ #1\romannumeral0\CALX_ntoraw_a N+#2.#5\xint:.#3#4}}%
\def\CALX_fint_t #1#2#3\xint:{\expanded{ #10.#2#3}}%
\def\CALX_fint_u #1#2#3\xint:{\expanded{ #10.0#3}}%
\def\CALX_fint_r #1\xint:{\CALX_fint_ra #1[0]\xint:}%
\def\CALX_fint_ra #1[#2]#3\xint:{\CALX_fint_rb #1/1/\xint:{#2}}%
\def\CALX_fint_rb #1/#2/#3\xint:{\CALX_fint_rc #2\xint:{#1}{#2}}%
\def\CALX_fint_rc #1#2\xint:#3#4#5%
{%
    \if1#1\if\relax\detokenize{#2}\relax\CALX_fint_rj\fi\fi
    \CALX_fint_rg{#3}{#4}{#5}%
}%
\def\CALX_fint_rj #1\CALX_fint_rg#2#3#4%
   {#1\expandafter\CALX_fint\romannumeral0\CALX_ffr_a#2[#4]\xint:\xint:}%
\def\CALX_fint_rg #1#2{\CALX_fint_rs #1\xint:{#2}}%
\def\CALX_fint_rs #1#2\xint:#3#4%
{%
    \if-#1\xint_dothis{\CALX_fint_rd -{#2}}\fi
    \if0#1\xint_dothis\CALX_fint_rz\fi
    \xint_orthat{\CALX_fint_rd +{#1#2}}{#3}{#4}%
}%
\def\CALX_fint_rz #1#2{ +0.00}%
\def\CALX_fint_rd #1#2#3#4%
   {\expandafter\CALX_fint_re\romannumeral0\CALX_ndivision
    {\CALX_nshl{#4+\xint_c_i}{\CALX_nfromraw{#2}}}%
    {\CALX_nshl{-#4-\xint_c_i}{\CALX_nfromraw{#3}}}#1}%
\def\CALX_fint_re #1#2#3{\CALX_fint_rf #2\xint:#3{#1}}%
\def\CALX_fint_rf N#1#2.#3\xint:#4#5%
   {\expanded{ #4\romannumeral0\CALX_ntoraw{\romannumeral0\CALX_nshr
    \xint_c_i{#5}}.\CALX_fint_q#5\xint:\ifnum#2>\xint_c_ 1\else
    \ifnum\CALX_fint_q#5\xint:>\xint_c_ 1\else0\fi\fi}}%
\def\CALX_fint_q N#1#2.#3\xint:%
   {\ifnum#2=\xint_c_ 0\else\CALX_fint_l#3\xint:\fi}%
\def\CALX_fint_l 1#1#2#3#4#5#6#7#8!#9\xint:{#8}%
%    \end{macrocode}
%\begin{lverb}
% Syntax (use with \romannumeral0; X f-expanded, not an I value; <k> one
% of the kind macros):
%(
%  \CALX_fintn<k>X\xint:  -> <space>N<s><n>.<blocks>
%:  <k><s><d><z>          -> 0 or 1
%)
% \CALX_fintn: the native integer s(T + a) from the output s, T, d, z of
% \CALX_fint, a = <k><s><d><z>: 1 if |T| must be increased, else 0.
% Kinds: \CALX_fintk_f floor (a = z if s is -), \CALX_fintk_c ceil (a = z
% if s is +), \CALX_fintk_r round (a = 1 if d >= 5), \CALX_fintk_t trunc
% (a = 0). The F value of the result is \CALX_fx_c 0.N\xint:, the M value
% \CALX_ntom N. In a \numexpr, <s>T<s><k><s><d><z> is the integer itself
% (the ends of a..b).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fintk_f #1#2#3{\if-#1#3\else0\fi}%
\def\CALX_fintk_c #1#2#3{\if-#1 0\else#3\fi}%
\def\CALX_fintk_r #1#2#3{\ifnum#2>\xint_c_iv 1\else0\fi}%
\def\CALX_fintk_t #1#2#3{0}%
\def\CALX_fintn #1#2\xint:%
   {\expandafter\CALX_fintn_a\romannumeral0\CALX_fint#2\xint:#1}%
\def\CALX_fintn_a #1#2.#3#4#5%
{%
    \ifnum#5#1#3#4=\xint_c_ \expandafter\CALX_fintn_b\else
                             \expandafter\CALX_fintn_c\fi #1#2.%
}%
\def\CALX_fintn_b #1#2.%
   {\CALX_nfromraw{\expanded{\if-#1\if0#2\else-\fi\fi}#2}}%
\def\CALX_fintn_c #1#2.{\CALX_nadd{\CALX_fintn_b#1#2.}{N#11.100000001!}}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_fexact}}
%\begin{lverb}
% Syntax (use with \romannumeral0; X f-expanded):
%(
%  \CALX_fexact{X}  -> <space>Y\xint:
%)
% Y: X as an exact F value: F and I unchanged (\string on the tag: X may
% come from a compiled function), M and raw A, A[N], A/1[N] exactly
% (\CALX_ffr_a), raw A/B[N] with B > 1 rounded to \XINTdigits digits.
% Ends of a..[d]..b in \xintfloateval. Y is followed by \xint:, as with
% \CALX_fround and calxint's \CALX_tom.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fexact #1{\expandafter\CALX_fex_s\romannumeral`&&@#1\xint:}%
\def\CALX_fex_s{\expandafter\CALX_fex_a\string}%
\def\CALX_fex_a #1%
{%
    \if F#1\xint_dothis{\CALX_fex_f#1}\fi
    \if I#1\xint_dothis{\CALX_fex_f#1}\fi
    \if M#1\xint_dothis\CALX_fex_m\fi
    \xint_orthat{\CALX_fex_r#1}%
}%
\def\CALX_fex_f #1\xint:{ #1\xint:}%
\def\CALX_fex_m #1\xint:%
   {\expandafter\CALX_ffr_a\romannumeral0\CALX_mtoraw_t M#1\xint:[0]\xint:\xint:}%
\def\CALX_fex_r #1\xint:{\CALX_fex_ra #1[0]\xint:{#1}}%
\def\CALX_fex_ra #1[#2]#3\xint:{\CALX_fex_rb #1/1/\xint:{#2}}%
\def\CALX_fex_rb #1/#2/#3\xint:#4{\CALX_fex_rc #2\xint:{#1[#4]}}%
\def\CALX_fex_rc #1#2\xint:#3#4%
{%
    \if1#1\if\relax\detokenize{#2}\relax\CALX_fex_rj\fi\fi
    \CALX_fex_rg{#3}{#4}%
}%
\def\CALX_fex_rj #1\CALX_fex_rg#2#3{#1\CALX_ffr_a#2\xint:\xint:}%
\def\CALX_fex_rg #1{\CALX_fround\XINTdigits}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_rt_a}}
%\begin{lverb}
% Syntax (use with \romannumeral0; <kernel> \CALX_fr_b or \CALX_rt_t, n
% digits, X f-expanded):
%(
%  \CALX_rt_a <kernel><n>.X\xint:  -> <space>Y\xint:
%)
% Kernel of \calxFpRoundTo, \calxFpTruncTo (end of this file): Y is the
% multiple of 10^-n nearest to X (\CALX_fr_b), or between 0 and X
% (\CALX_rt_t). n may be negative.
% X: F or I value, M value, or raw A, A[N], A/B, A/B[N]. Y: exact F
% value (no rounding to P), ties of \calxFpRoundTo away from zero; I
% values are returned unchanged. No literal tag in the parameter texts:
% the tag of X may have catcode 11.
%
% F X = s N 10^(8e), D digits: t = -n - 8e low digits of N are dropped.
% t <= 0: X. t > D: zero. t = D: zero (trunc), or s 10^-n if N >=
% 5 10^(D-1) (round: \CALX_rt_h reads the first digit of the top
% block). 1 <= t < D: round: \CALX_fr_b with k = t (the dispatch of
% \CALX_fround, which keeps D - t digits); trunc: \CALX_rt_t, t = 8a + c:
% a blocks dropped (\CALX_fr_sk), the next block v -> m floor(v/m), m =
% 10^c, by (2(10^8 + v) + 1 - m)/(2m) m in \numexpr (no tie).
%
% Raw X with B = 1 (or no B), and M X (\CALX_mtoraw_t): the exact F value
% of A 10^N (\CALX_ffr_a), then the F path. B > 1: Q = trunc(X 10^(n+1))
% by \CALX_fnum_t (one native division), then the F path on Q 10^-(n+1):
% truncation at n + 1 decimals changes neither the truncation nor the
% rounding at n decimals.
%
% Every path ends with Y\xint: (the blocks above the kept ones stay in
% the stream until that \xint:).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_rt_a #1#2.#3%
{%
    \if F#3\xint_dothis{\CALX_rt_f#1#2.}\fi
    \if I#3\xint_dothis{ #3}\fi
    \if M#3\xint_dothis{\CALX_rt_m#1#2.}\fi
    \xint_orthat{\CALX_rt_x#1#2.#3}%
}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_rt_re <kernel>{n}{A}{N}: back to \CALX_rt_a with the exact F
% value of A 10^N (A f-expanded, N digits).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_rt_re #1#2#3#4%
   {\expandafter\CALX_rt_a\expandafter#1\the\numexpr#2\expandafter.%
    \romannumeral0\expandafter\CALX_ffr_a\romannumeral`&&@#3[#4]\xint:\xint:}%
\def\CALX_rt_m #1#2.#3\xint:%
   {\CALX_rt_re#1{#2}{\romannumeral0\CALX_mtoraw_t M#3\xint:}{0}}%
\def\CALX_rt_x #1#2.#3\xint:{\CALX_rt_xs#1{#2}#3[0]\xint:}%
\def\CALX_rt_xs #1#2#3[#4]#5\xint:{\CALX_rt_xt#1{#2}{#4}#3/1/\xint:}%
\def\CALX_rt_xt #1#2#3#4/#5/#6\xint:{\CALX_rt_xu#5\xint:#1{#2}{#3}{#4}{#5}}%
\def\CALX_rt_xu #1#2\xint:#3#4#5#6#7%
{%
    \if1#1\if\relax\detokenize{#2}\relax\CALX_rt_xj\fi\fi
    \CALX_rt_xg#3{#4}{#5}{#6}{#7}%
}%
\def\CALX_rt_xj #1\CALX_rt_xg#2#3#4#5#6{#1\CALX_rt_re#2{#3}{#5}{#4}}%
\def\CALX_rt_xg #1#2#3#4%
   {\expandafter\CALX_rt_xh\the\numexpr#3+#2+\xint_c_i\expandafter.%
    \the\numexpr-#2-\xint_c_i.#1{#2}{#4}}%
\def\CALX_rt_xh #1.#2.#3#4#5#6%
   {\CALX_rt_re#3{#4}{\romannumeral0\CALX_fnum_t #5/#6/\xint:{#1}}{#2}}%
%    \end{macrocode}
%\begin{lverb}
% F path: \CALX_rt_f <kernel><n>.<s><D>.<e>.<blocks>\xint:, t = -8e - n.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_rt_f #1#2.#3#4.#5.%
   {\expandafter\CALX_rt_g\expandafter#1\the\numexpr
    -\xint_c_viii*#5-#2.#3#4.#5.}%
\def\CALX_rt_g #1#2.#3#4.#5.%
{%
    \ifnum#2<\xint_c_i \xint_dothis\CALX_rt_id\fi
    \ifnum#2>#4 \xint_dothis\CALX_rt_z\fi
    \ifnum#2=#4 \xint_dothis{\ifx#1\CALX_fr_b\expandafter\CALX_rt_h\else
                             \expandafter\CALX_rt_z\fi}\fi
    \xint_orthat#1#2.#3#4.#5.%
}%
\def\CALX_rt_id #1.#2#3.#4.{ F#2#3.#4.}%
\def\CALX_rt_z #1\xint:{ F+0.0.\xint:}%
%    \end{macrocode}
%\begin{lverb}
% Round, t = D: \CALX_rt_h <t>.<s><D>.<e>. skips the ceil(D/8) - 1 lower
% blocks; the top block v has d = D - 8(ceil(D/8) - 1) digits; v >= 5
% 10^(d-1): s 10^(D+8e), else zero.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_rt_h #1.#2#3.#4.%
   {\expandafter\CALX_rt_ha\the\numexpr(#3+\xint_c_iii)/\xint_c_viii-%
    \xint_c_i.#2#3.#4.}%
\def\CALX_rt_ha #1.#2#3.#4.%
   {\CALX_fr_sk #1.{\CALX_rt_hb{#3-\xint_c_viii*#1}{#2}%
    {#3+\xint_c_viii*#4}}}%
\def\CALX_rt_hb #1#2#31#4!#5\xint:%
{%
    \ifnum1#4<\numexpr\xint_c_e_viii+\xint_c_v*\CALX_pten{#1-\xint_c_i}\relax
      \expandafter\CALX_rt_z\else\expandafter\CALX_rt_o\fi #2{#3}\xint:%
}%
\def\CALX_rt_o #1#2%
   {\expandafter\CALX_ffr_a\expanded{\if-#1-\fi1[\the\numexpr#2]}\xint:}%
%    \end{macrocode}
%\begin{lverb}
% Trunc, 1 <= t < D: \CALX_rt_t <t>.<s><D>.<e>.<blocks>, t = 8a + c, a =
% (t - 4)/8 in \numexpr (never a tie).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_rt_t #1.%
   {\expandafter\CALX_rt_ta\the\numexpr(#1-\xint_c_iv)/\xint_c_viii.#1.}%
\def\CALX_rt_ta #1.#2.%
   {\expandafter\CALX_rt_tb\the\numexpr#2-\xint_c_viii*#1.#1.}%
\def\CALX_rt_tb #1.#2.#3#4.#5.%
   {\CALX_fr_sk #2.{\CALX_rt_tc #1.{#3}{#4-\xint_c_viii*#2}{#5+#2}}}%
\def\CALX_rt_tc #1.#2#3#4%
{%
    \ifnum#1=\xint_c_
      \xint_dothis{\expanded{ F#2\the\numexpr#3.\the\numexpr#4.}}\fi
    \xint_orthat{\expandafter\CALX_rt_td\the\numexpr\CALX_pten{#1}.%
      {#2}{#3}{#4}}%
}%
\def\CALX_rt_td #1.#2#3#41#5!%
   {\expanded{ F#2\the\numexpr#3.\the\numexpr#4.\the\numexpr
    (\xint_c_ii*1#5+\xint_c_i-#1)/(\xint_c_ii*#1)*#1!}}%
%    \end{macrocode}
% \subsection{Addition and subtraction}
% \subsubsection{\csh{CALX_fadd}, \csh{CALX_fsub}}
%\begin{lverb}
% Syntax (use with \romannumeral0; P a \numexpr expression; X, Y
% f-expanded F, I or raw values, rounded to P digits first):
%(
%  \CALX_fadd{P}{X}{Y}   -> <space>Z    Z = round_P(X + Y)
%:  \CALX_fsub{P}{X}{Y}   -> <space>Z    Z = round_P(X - Y)
%:  \CALX_faddu{P}{X}{Y}  -> <space>Z    (X, Y finite F, at most P digits)
%:  \CALX_fsubu{P}{X}{Y}  -> <space>Z
%)
% Z: F or I value.
%(
%  \CALX_fhalf{X}  -> F...   X/2 exact (X finite F; f-expandable)
%)
%
% \CALX_fadd{P}{X}{Y}, \CALX_fsub{P}{X}{Y} (use with \romannumeral0, X and
% Y f-expanded): round_P(round_P(X) + round_P(Y)), resp. with -round_P(Y),
% round half away from zero, as xint's \XINTinFloatAdd[P] and
% \XINTinFloatSub[P] (xint 1.2k and later).
%
% X is rounded first; \CALX_fa_a grabs it once and checks its tag (X
% special: \CALX_fa_spx rounds Y and goes to \CALX_fa_sp$empty: I?
% propagates, Inf plus finite is that Inf, Inf plus Inf is that Inf if
% the signs agree, else InvalidOperation as in \CALX_nadd). Then Y is
% rounded in front of X, which is written back with the add kernel's
% terminator and one more \xint:
%( <op><Y>\xint:{P}<sX><DX>.<eX>.<X blocks>1;!1;!1;!1;!\W\xint:\xint:
%)
% <op> is \CALX_fa_bp (add) or \CALX_fa_bm (sub: sign of Y flipped, I?
% unchanged); it reads the tag and sign of Y only (Y special: jumper
% \CALX_fa_spy, resp. \CALX_fa_spm, result that special value).
%
% \CALX_fa_c grabs Y's list and X's header; X's list stays in place.
% Jumpers (macros delimited by the \fi of their branch, swallowing the
% rest of the body): Y zero: X (\CALX_fa_rx); X zero: Y (\CALX_fa_ry).
% Cut-off: with t = 8e + D (|X| < 10^t <= 10|X|), if t_X - t_Y >= P + 2
% then |Y| is less than a hundredth of the unit of the last digit of the
% P-digit X and the result is X (also when X is a power of ten and Y has
% the other sign); symmetrically for Y. This is the test of xint's
% \XINT_FL_add_d.
%
% Otherwise the exact sum: one \expanded writes both native headers and
% the e_X - e_Y zero blocks in front of the operand with the larger
% exponent (\CALX_fa_z), and \CALX_nadd_y runs with X's list in place
% (Y's list is grabbed by \CALX_fa_c and by \CALX_nadd_y). min(e_X, e_Y)
% and P are placed in front by a \numexpr chain; \CALX_fa_h receives
% <e>.<P>.N<s><n>.<blocks>\xint: and either gives F+0.0. (zero sum) or
% reads the digit count and rounds as \CALX_fm_gb does (\CALX_fa_g,
% same body, arguments in another order).
%
% Expanded-operand entries: X\xint:Y\xint:P.  The ordinary
% \CALX_fadd, \CALX_fsub, \CALX_fmul, \CALX_fdiv, \CALX_fdq
% remain available to internal callers with expandable operands.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fadd_in #1\xint:#2\xint:#3.%
   {\expandafter\CALX_fa_a\romannumeral0\CALX_fround{#3}{#1}{#3}{#2}\CALX_fa_bp}%
\def\CALX_fsub_in #1\xint:#2\xint:#3.%
   {\expandafter\CALX_fa_a\romannumeral0\CALX_fround{#3}{#1}{#3}{#2}\CALX_fa_bm}%
\def\CALX_fmul_in #1\xint:#2\xint:#3.%
   {\ifnum#3>16 \expandafter\CALX_fm_big\else\expandafter\CALX_fm_na\fi
    {#3}{#1}{#2}}%
\def\CALX_fdiv_in #1\xint:#2\xint:#3.%
   {\expandafter\CALX_fd_a\romannumeral0\CALX_fround{#3}{#1}{#3}{#2}}%
\def\CALX_fdq_in #1\xint:#2\xint:#3.#4%
   {\expandafter\CALX_fdq_a\romannumeral0\CALX_fround{#3}{#1}#4{#3}{#2}}%
\def\CALX_fsqr_in #1\xint:#2.%
   {\ifnum#2>16 \expandafter\CALX_fs_big\else\expandafter\CALX_fs_na\fi
    {#2}{#1}}%
\def\CALX_fsqrt_in #1\xint:#2.%
   {\expandafter\CALX_frt_a\romannumeral0\CALX_fround{#2}{#1}{#2}}%
\def\CALX_fadd #1#2#3%
   {\expandafter\CALX_fa_a\romannumeral0\CALX_fround{#1}{#2}{#1}{#3}%
       \CALX_fa_bp}%
\def\CALX_fsub #1#2#3%
   {\expandafter\CALX_fa_a\romannumeral0\CALX_fround{#1}{#2}{#1}{#3}%
       \CALX_fa_bm}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_faddu{P}{X}{Y}, \CALX_fsubu{P}{X}{Y}: X + Y, X - Y rounded to P
% digits, for X, Y finite with at most P digits: the input roundings of
% \CALX_fadd are skipped (they would leave X, Y unchanged), the rest is
% the same code (\CALX_fau builds the input of \CALX_fa_bp, \CALX_fa_bm
% as \CALX_fa_a does). The same holds for \CALX_fmulu, \CALX_fsqru and
% \CALX_fdivu below. Used where the operands are known to be short
% (inverse trigonometric functions).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_faddu #1#2#3%
   {\expandafter\CALX_fau\romannumeral`&&@#2\xint:{#1}{#3}\CALX_fa_bp}%
\def\CALX_fsubu #1#2#3%
   {\expandafter\CALX_fau\romannumeral`&&@#2\xint:{#1}{#3}\CALX_fa_bm}%
\def\CALX_fau F#1\xint:#2#3#4%
   {\expandafter#4\romannumeral`&&@#3\xint:{#2}#11;!1;!1;!1;!\W\xint:\xint:}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_fhalf{X}: X/2, exact (X finite). With the blocks b_k of X (b_k
% = 0 for k < 0 or k >= n) and exponent e, X/2 has exponent e - 1 and
% the blocks
%(
%:  c_j = 5 10^7 (b_j mod 2) + floor(b_(j-1)/2),   j = 0, ..., n,
%)
% since 10^8 b_j / 2 = 5 10^7 (b_j mod 2) + 10^8 floor(b_j/2): no
% carry (c_j < 10^8). One \expanded pass over the list (\CALX_fhv_b,
% floor(b/2) = round((2b-1)/4) in \numexpr); c_n is dropped if 0. The
% digit count is D + 8, minus 1 if floor(b_(n-1)/2) < 10^(d-1), d the
% number of digits of b_(n-1) (that is, the leading digit of X is 1).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fhalf #1{\expandafter\CALX_fhv_a\romannumeral`&&@#1\xint:}%
\def\CALX_fhv_a F#1#2.#3.#4\xint:%
{%
    \ifnum#2=\xint_c_ \xint_dothis{F#1#2.#3.}\fi
    \xint_orthat{\expandafter\CALX_fhv_e\expanded{\CALX_fhv_b0.#41;!}%
      #1#2.#3.}%
}%
\def\CALX_fhv_b #1.1#2#3!%
  {\xint_gob_til_sc#2\CALX_fhv_t;\CALX_fhv_c#1.#2#3.}%
\def\CALX_fhv_c #1.#2.%
  {\expandafter\CALX_fhv_d\the\numexpr(\xint_c_ii*#2-\xint_c_i)/\xint_c_iv.%
   #2.#1.}%
\def\CALX_fhv_d #1.#2.#3.%
  {\the\numexpr\xint_c_e_viii+50000000*(#2-\xint_c_ii*#1)+#3!%
   \CALX_fhv_b#1.}%
\def\CALX_fhv_t;\CALX_fhv_c#1.;.%
  {\ifnum#1>\xint_c_ \the\numexpr\xint_c_e_viii+#1!\fi\xint:#1.}%
\def\CALX_fhv_e #1\xint:#2.#3#4.#5.%
{%
    \expandafter\CALX_fhv_f
    \the\numexpr#4+\ifnum#2<\ifcase\numexpr#4-\xint_c_i-\xint_c_viii*%
      ((\xint_c_ii*#4-\xint_c_ix)/16)\relax
      1\or 10\or 100\or 1000\or 10000\or 100000\or 1000000\or 10000000\fi
      \space\xint_c_vii\else\xint_c_viii\fi
    \expandafter.\the\numexpr#5-\xint_c_i.#3#1%
}%
\def\CALX_fhv_f #1.#2.#3{F#3#1.#2.}%
\def\CALX_fa_a #1#2#3\xint:#4#5#6%
{%
    \if I#1\CALX_fa_spx#2{#4}{#5}#6\fi
    \expandafter#6\romannumeral0\CALX_fround{#4}{#5}{#4}#2#3%
    1;!1;!1;!1;!\W\xint:\xint:%
}%
\def\CALX_fa_spx #1#2#3#4\fi#5\W\xint:\xint:%
{%
    \fi\expandafter\CALX_fa_spz\expandafter#1\expandafter#4%
    \romannumeral0\CALX_fround{#2}{#3}%
}%
\def\CALX_fa_spz #1#2#3#4#5\xint:%
{%
    \ifx#2\CALX_fa_bm\expandafter\CALX_fa_spf\else\expandafter\CALX_fa_sp\fi
    #3#4I#1%
}%
\def\CALX_fa_spf #1#2{\expandafter\CALX_fa_sp\expandafter#1%
    \romannumeral`&&@\CALX_fa_f#2}%
\def\CALX_fa_f #1{\csname CALX_fa_f#1\endcsname}%
\expandafter\def\csname CALX_fa_f+\endcsname{-}%
\expandafter\def\csname CALX_fa_f-\endcsname{+}%
\expandafter\def\csname CALX_fa_f?\endcsname{?}%
\def\CALX_fa_sp #1#2#3#4%
{%
    \if ?#2\xint_dothis{ I?}\fi
    \if ?#4\xint_dothis{ I?}\fi
    \if F#1\xint_dothis{ I#4}\fi
    \if F#3\xint_dothis{ I#2}\fi
    \if #2#4\xint_dothis{ I#2}\fi
    \xint_orthat{\CALX_nsig{InvalidOperation}{inf - inf}{}}%
}%
\def\CALX_fa_bp #1#2{\if I#1\CALX_fa_spy#2\fi\CALX_fa_c#2}%
\def\CALX_fa_bm #1#2%
{%
    \if I#1\CALX_fa_spm#2\fi
    \if-#2\expandafter\CALX_fa_c\expandafter+\else
          \expandafter\CALX_fa_c\expandafter-\fi
}%
\def\CALX_fa_spy #1\fi#2\W\xint:\xint:{\fi\CALX_sp I#1}%
\def\CALX_fa_spm #1\fi#2\W\xint:\xint:%
   {\fi\expandafter\CALX_sp\expandafter I\romannumeral`&&@\CALX_fa_f#1}%
\def\CALX_fa_c #1#2.#3.#4\xint:#5#6#7.#8.%
{%
    \ifnum#2=\xint_c_ \CALX_fa_rx#6#7.#8.\fi
    \ifnum#7=\xint_c_ \CALX_fa_ry#1#2.#3.#4\fi
    \ifnum\numexpr\xint_c_viii*(#3-#8)+#2-#7>\numexpr#5+\xint_c_i\relax
      \CALX_fa_ry#1#2.#3.#4\fi
    \ifnum\numexpr\xint_c_viii*(#8-#3)+#7-#2>\numexpr#5+\xint_c_i\relax
      \CALX_fa_rx#6#7.#8.\fi
    \expandafter\CALX_fa_h\the\numexpr\ifnum#3<#8 #3\else#8\fi
    \expandafter.\the\numexpr#5\expandafter.\romannumeral0\expandafter
    \CALX_nadd_y\expanded{N#1\the\numexpr(#2+\xint_c_iii)/\xint_c_viii
      \ifnum#3>#8 +#3-#8.\CALX_fa_z#3-#8.\else.\fi\unexpanded{#4}\xint:
      N#6\the\numexpr(#7+\xint_c_iii)/\xint_c_viii
      \ifnum#8>#3 +#8-#3.\CALX_fa_z#8-#3.\else.\fi}%
}%
\def\CALX_fa_rx #1\fi#2\CALX_nadd_y\expanded#3#41;!1;!1;!1;!\W\xint:\xint:%
   {\fi\CALX_sp F#1#4}%
\def\CALX_fa_ry #1\fi#2\W\xint:\xint:{\fi\CALX_sp F#1}%
\def\CALX_fa_z #1.%
{%
    \ifnum\numexpr#1>\xint_c_ 100000000!%
      \expandafter\CALX_fa_z\the\numexpr#1-\xint_c_i\expandafter.%
    \fi
}%
\def\CALX_fa_h #1.#2.N#3#4.%
{%
    \ifnum#4=\xint_c_ \expandafter\CALX_fa_zero\else
                      \expandafter\CALX_fa_g\fi N#3#4.{#1}{#2}%
}%
\def\CALX_fa_zero N#1#2.#3#4\xint:{ F+0.0.}%
\def\CALX_fa_g N#1#2.#3#4#5\xint:%
{%
    \expandafter\CALX_fm_gd\the\numexpr#3\expandafter.\the\numexpr
    \xint_c_viii*(#2-\xint_c_i)+\CALX_nskip\CALX_fm_gl #2-\xint_c_i.#5\xint:.%
    #1{#4}#5%
}%
%    \end{macrocode}
% \subsection{Multiplication}
% \subsubsection{\csh{CALX_fmul}}
%\begin{lverb}
% Syntax (use with \romannumeral0; P a \numexpr expression; X, Y
% f-expanded F, I or raw values):
%(
%  \CALX_fmul{P}{X}{Y}   -> <space>Z    Z = round_P(round_P(X) round_P(Y))
%:  \CALX_fmulu{P}{X}{Y}  -> <space>Z    (X, Y finite F, at most P digits)
%:  \CALX_fmulx{X}{Y}     -> <space>Z    exact product (X, Y finite F)
%:  \CALX_faddx{X}{Y}     -> <space>Z    exact sum (X, Y finite F)
%:  \CALX_fsubx{X}{Y}     -> <space>Z    exact difference
%)
% Z: F or I value.
%
% \CALX_fmul{P}{X}{Y} (use with \romannumeral0, X and Y f-expanded):
% round_P(round_P(X) round_P(Y)), round half away from zero, as xint's
% \XINTinFloatMul[P] (xint 1.2k and later).
%
% Special values first (\CALX_fm_sp$empty: I? propagates, inf times zero
% signals InvalidOperation, otherwise I+ or I- by the product of the
% signs), then zero.
%
% P <= 16 and both mantissas with at most 24 digits: each operand is
% replaced by its top P significant digits A, rounded, as two blocks
% (A = Ah B + Al), and a decimal exponent: X = A 10^(8e + z) (\CALX_fm_xvi
% for P = 16, \CALX_fm_ex otherwise). The product of the two A's is computed
% by \CALX_fm_k (32 digits), then rounded to P digits and put back in the
% native float format by \CALX_fm_r. Otherwise: \CALX_fm_big (P <= 20:
% one product of 20 digit operands, 20 < P <= 34: three such products,
% P > 34: generic).
%
% Small path: \CALX_fm_nb grabs X once (X special: jumper
% \CALX_fm_nsx) and writes it back after Y, padded with two zero blocks
% and closed by \iffalse{\fi} (the closing brace of the \expanded opened
% by \CALX_fm_nc), then {P}. \CALX_fm_ntag reads the tag of Y (special:
% jumper \CALX_fm_nsy). \CALX_fm_nc grabs Y's list and X's header; X's
% list stays in place. Jumpers: a zero operand (\CALX_fm_nz), more than
% 24 digits (\CALX_fm_nbig, to \CALX_fm_big). Common case: one
% \expanded runs the two extractions (\CALX_fm_ny, \CALX_fm_nx:
% \CALX_fm_xvi or \CALX_fm_ex by \csname), the second one on X's list
% in place. \CALX_fm_ne regroups
% 1Bl!1Bh!z'.{s}{8(e+e')}1Al!1Ah!z. into the input of \CALX_fm_k,
% followed by {s}{8(e+e') + z + z'}{P}.
%
% An operand which is neither F nor I is an xint raw value: \CALX_fm_nk
% (X, jumper \CALX_fm_nj) and \CALX_fm_ntk (Y, jumper \CALX_fm_nry)
% send both operands to \CALX_fm_big, whose \CALX_fround converts it.
% The same for \CALX_fsqr (\CALX_fs_nc, \CALX_fs_ns, \CALX_fs_nr).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fmul #1%
{%
    \ifnum#1>16 \expandafter\CALX_fm_big\else\expandafter\CALX_fm_na\fi %
        {#1}%
}%
\def\CALX_fmulu #1%
{%
    \ifnum#1>16 \expandafter\CALX_fmu_b\else\expandafter\CALX_fm_na\fi
        {#1}%
}%
\def\CALX_fmu_b #1#2{\expandafter\CALX_fmu\romannumeral`&&@#2\xint:{#1}}%
\def\CALX_fmu F#1\xint:#2#3%
   {\expandafter\CALX_fm_btag\romannumeral`&&@#3\xint:{#2}#1\xint:}%
\def\CALX_fm_na #1#2{\expandafter\CALX_fm_nk\romannumeral`&&@#2%
    \xint:{#1}}%
\def\CALX_fm_nk #1%
   {\if F#1\else\if I#1\else\CALX_fm_nj\fi\fi\CALX_fm_nb #1}%
\def\CALX_fm_nj #1\fi\fi\CALX_fm_nb #2#3\xint:#4%
   {\fi\fi\CALX_fm_big{#4}{#2#3}}%
\def\CALX_fm_nb #1#2#3\xint:#4#5%
{%
    \if I#1\CALX_fm_nsx#1#2{#5}\fi
    \expandafter\CALX_fm_ntk\romannumeral`&&@#5\xint:{#4}#2#3%
    100000000!100000000!\xint:\iffalse{\fi}{#4}%
}%
\def\CALX_fm_nsx #1#2#3\fi#4\iffalse#5#6%
   {\fi\expandafter\CALX_fm_sp\romannumeral`&&@#3\xint:#1#2\xint:}%
\def\CALX_fm_ntk #1%
   {\if F#1\else\if I#1\else\CALX_fm_nry\fi\fi\CALX_fm_ntag #1}%
\def\CALX_fm_nry #1\fi\fi\CALX_fm_ntag #2#3\xint:#4#5%
    100000000!100000000!\xint:\iffalse#6#7%
   {\fi\fi\CALX_fm_big{#4}{F#5}{#2#3}}%
\def\CALX_fm_ntag #1#2{\if I#1\CALX_fm_nsy#2\fi\CALX_fm_nc#2}%
\def\CALX_fm_nsy #1\fi#2\xint:#3#4100000000!100000000!\xint:\iffalse#5#6%
   {\fi\CALX_fm_sp I#1\xint:F#4\xint:}%
\def\CALX_fm_nc #1#2.#3.#4\xint:#5#6#7.#8.%
{%
    \ifnum#2=\xint_c_ \CALX_fm_nz\fi
    \ifnum#7=\xint_c_ \CALX_fm_nz\fi
    \ifnum#2>24 \CALX_fm_nbig{#5}{F#1#2.#3.#4}{F#6#7.#8.}\fi
    \ifnum#7>24 \CALX_fm_nbig{#5}{F#1#2.#3.#4}{F#6#7.#8.}\fi
    \expandafter\CALX_fm_ne\expanded{\iffalse}\fi
      \CALX_fm_ny{#5}{#2}#4100000000!100000000!\xint:%
      {\if#1#6+\else-\fi}{\the\numexpr\xint_c_viii*(#3+#8)}%
      \CALX_fm_nx{#5}{#7}%
}%
\def\CALX_fm_nz\fi#1\iffalse#2#3{\fi\CALX_sp F+0.0.}%
\def\CALX_fm_nbig #1#2#3\fi#4\CALX_fm_nx#5#6#7100000000!100000000!\xint:%
    \iffalse#8#9{\fi\CALX_fm_big{#1}{#3#7}{#2}}%
\def\CALX_fm_nx #1%
   {\csname CALX_fm_\ifnum#1=16 nxvi\else ex\fi\endcsname{#1}}%
\let\CALX_fm_ny\CALX_fm_nx
\def\CALX_fm_nxvi #1{\CALX_fm_xvi}%
\def\CALX_fm_ne #1!#2!#3.#4#5#6!#7!#8.%
   {\CALX_fm_k #6!#7!#1!#2!{#4}{#5+#8+#3}}%
\def\CALX_fm_sp #1#2#3\xint:#4#5#6\xint:%
{%
    \if ?#2\xint_dothis{ I?}\fi
    \if ?#5\xint_dothis{ I?}\fi
    \ifnum\if F#1\CALX_nsp_z#3\xint:\else\if F#4\CALX_nsp_z#6\xint:\else
      \xint_c_i\fi\fi=\xint_c_
      \xint_dothis{\CALX_nsig{InvalidOperation}{inf * 0}{}}\fi
    \xint_orthat{\CALX_nsp_ps#2#5}%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_fm_xvi}}
%\begin{lverb}
% \CALX_fm_xvi{D}<blocks>\xint: (P = 16, D <= 24, the blocks padded with
% two zero blocks): 1Al!1Ah!z. with A = Ah B + Al of exactly 16 digits.
%- D = 16: A is the mantissa, z = 0.
%- D < 16: A = M 10^(16-D), z = D - 16: \CALX_fm_la<s> (s = 16 - D, roman
% numeral) emits Al and calls \CALX_fm_lb<s> for Ah; digits are only moved,
% as all blocks have exactly eight digits.
%- 16 < D < 24: A = round(M/10^z), z = D - 16: \CALX_fm_ua<z>,
% \CALX_fm_ub<z>, \CALX_fm_uc cut the digits; the digit just below A decides
% the rounding (half away from zero: no tie rule needed).
%- D = 24: A is the two top blocks, rounded with the top digit of the low
% block (\CALX_fm_xvie).
%
% \CALX_fm_xvif{Al'}{Ah}{z}, Al' <= 10^8 (an expression): carry to Ah; if
% A becomes 10^16, A = 10^15 and z + 1.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fm_xvi #11#2!1#3!1#4!#5\xint:%
{%
    \ifnum#1<16
      \csname CALX_fm_la\the\numexpr16-#1\endcsname #2!#3!\the%
          \numexpr#1-16.%
    \else\ifnum#1=16 1#2!1#3!0.%
    \else\ifnum#1=24 \CALX_fm_xvie{#3}{#4}{#2}%
    \else
      \csname CALX_fm_ua\the\numexpr#1-16\endcsname #2!#3!#4!%
    \fi\fi\fi
}%
\def\CALX_fm_uc #1#2#3#4#5!%
{%
    \CALX_fm_xvif{#1+\ifnum#3>\xint_c_iv\xint_c_i\else\xint_c_\fi}%
                 {#5*\CALX_pten{\xint_c_viii-#4}+#2}{#4}%
}%
\expandafter\def\csname CALX_fm_ua1\endcsname
   #1#2#3#4#5#6#7#8!{\CALX_fm_ubi{{#1#2#3#4#5#6#7}{#8}}}%
\expandafter\def\csname CALX_fm_ua2\endcsname
   #1#2#3#4#5#6#7#8!{\CALX_fm_ubii{{#1#2#3#4#5#6}{#7}}}%
\expandafter\def\csname CALX_fm_ua3\endcsname
   #1#2#3#4#5#6#7#8!{\CALX_fm_ubiii{{#1#2#3#4#5}{#6}}}%
\expandafter\def\csname CALX_fm_ua4\endcsname
   #1#2#3#4#5#6#7#8!{\CALX_fm_ubiv{{#1#2#3#4}{#5}}}%
\expandafter\def\csname CALX_fm_ua5\endcsname
   #1#2#3#4#5#6#7#8!{\CALX_fm_ubv{{#1#2#3}{#4}}}%
\expandafter\def\csname CALX_fm_ua6\endcsname
   #1#2#3#4#5#6#7#8!{\CALX_fm_ubvi{{#1#2}{#3}}}%
\expandafter\def\csname CALX_fm_ua7\endcsname
   #1#2#3#4#5#6#7#8!{\CALX_fm_ubvii{{#1}{#2}}}%
\def\CALX_fm_ubi #1#2#3#4#5#6#7#8#9!{\CALX_fm_uc{#9%
    \xint_firstoftwo#1}{#2#3#4#5#6#7#8}{\xint_secondoftwo#1}{1}}%
\def\CALX_fm_ubii #1#2#3#4#5#6#7#8#9!{\CALX_fm_uc{#8#9%
    \xint_firstoftwo#1}{#2#3#4#5#6#7}{\xint_secondoftwo#1}{2}}%
\def\CALX_fm_ubiii #1#2#3#4#5#6#7#8#9!{\CALX_fm_uc{#7#8#9%
    \xint_firstoftwo#1}{#2#3#4#5#6}{\xint_secondoftwo#1}{3}}%
\def\CALX_fm_ubiv #1#2#3#4#5#6#7#8#9!{\CALX_fm_uc{#6#7#8#9%
    \xint_firstoftwo#1}{#2#3#4#5}{\xint_secondoftwo#1}{4}}%
\def\CALX_fm_ubv #1#2#3#4#5#6#7#8#9!{\CALX_fm_uc{#5#6#7#8#9%
    \xint_firstoftwo#1}{#2#3#4}{\xint_secondoftwo#1}{5}}%
\def\CALX_fm_ubvi #1#2#3#4#5#6#7#8#9!{\CALX_fm_uc{#4#5#6#7#8#9%
    \xint_firstoftwo#1}{#2#3}{\xint_secondoftwo#1}{6}}%
\def\CALX_fm_ubvii #1#2#3#4#5#6#7#8#9!{\CALX_fm_uc{#3#4#5#6#7#8#9%
    \xint_firstoftwo#1}{#2}{\xint_secondoftwo#1}{7}}%
\expandafter\def\csname CALX_fm_la1\endcsname
   #1#2#3#4#5#6#7#8!{1#2#3#4#5#6#7#80!\CALX_fm_lbi{#1}}%
\def\CALX_fm_lbi #1#2#3#4#5#6#7#8#9!{1#3#4#5#6#7#8#9#1!}%
\expandafter\def\csname CALX_fm_la2\endcsname
   #1#2#3#4#5#6#7#8!{1#3#4#5#6#7#800!\CALX_fm_lbii{#1#2}}%
\def\CALX_fm_lbii #1#2#3#4#5#6#7#8#9!{1#4#5#6#7#8#9#1!}%
\expandafter\def\csname CALX_fm_la3\endcsname
   #1#2#3#4#5#6#7#8!{1#4#5#6#7#8000!\CALX_fm_lbiii{#1#2#3}}%
\def\CALX_fm_lbiii #1#2#3#4#5#6#7#8#9!{1#5#6#7#8#9#1!}%
\expandafter\def\csname CALX_fm_la4\endcsname
   #1#2#3#4#5#6#7#8!{1#5#6#7#80000!\CALX_fm_lbiv{#1#2#3#4}}%
\def\CALX_fm_lbiv #1#2#3#4#5#6#7#8#9!{1#6#7#8#9#1!}%
\expandafter\def\csname CALX_fm_la5\endcsname
   #1#2#3#4#5#6#7#8!{1#6#7#800000!\CALX_fm_lbv{#1#2#3#4#5}}%
\def\CALX_fm_lbv #1#2#3#4#5#6#7#8#9!{1#7#8#9#1!}%
\expandafter\def\csname CALX_fm_la6\endcsname
   #1#2#3#4#5#6#7#8!{1#7#8000000!\CALX_fm_lbvi{#1#2#3#4#5#6}}%
\def\CALX_fm_lbvi #1#2#3#4#5#6#7#8#9!{1#8#9#1!}%
\expandafter\def\csname CALX_fm_la7\endcsname #1#2#3#4#5#6#7#8!{1#80000000!%
    \CALX_fm_lbvii{#1#2#3#4#5#6#7}}%
\def\CALX_fm_lbvii #1#2#3#4#5#6#7#8#9!{1#9#1!}%
\expandafter\def\csname CALX_fm_la8\endcsname #1#2#3#4#5#6#7#8!{100000000!%
    \CALX_fm_lbviii{#1#2#3#4#5#6#7#8}}%
\def\CALX_fm_lbviii #1#2#3#4#5#6#7#8#9!{1#1!}%
\expandafter\def\csname CALX_fm_la9\endcsname
   #1#2#3#4#5#6#7#8!#9!{100000000!1#2#3#4#5#6#7#80!}%
\expandafter\def\csname CALX_fm_la10\endcsname
   #1#2#3#4#5#6#7#8!#9!{100000000!1#3#4#5#6#7#800!}%
\expandafter\def\csname CALX_fm_la11\endcsname
   #1#2#3#4#5#6#7#8!#9!{100000000!1#4#5#6#7#8000!}%
\expandafter\def\csname CALX_fm_la12\endcsname
   #1#2#3#4#5#6#7#8!#9!{100000000!1#5#6#7#80000!}%
\expandafter\def\csname CALX_fm_la13\endcsname
   #1#2#3#4#5#6#7#8!#9!{100000000!1#6#7#800000!}%
\expandafter\def\csname CALX_fm_la14\endcsname
   #1#2#3#4#5#6#7#8!#9!{100000000!1#7#8000000!}%
\expandafter\def\csname CALX_fm_la15\endcsname
   #1#2#3#4#5#6#7#8!#9!{100000000!1#80000000!}%
\def\CALX_fm_xvie #1#2#3%
   {\CALX_fm_xvif{#1+\ifnum#3>49999999 \xint_c_i\else\xint_c_\fi}{#2}{%
       \xint_c_viii}}%
\def\CALX_fm_xvif #1#2#3%
{%
    \ifnum\numexpr#1<\xint_c_e_viii
      \the\numexpr#1+\xint_c_e_viii!\the\numexpr#2+\xint_c_e_viii!\the%
          \numexpr#3.%
    \else
      \ifnum\numexpr#2=99999999
        100000000!110000000!\the\numexpr#3+\xint_c_i.%
      \else
        100000000!\the\numexpr#2+\xint_c_i+\xint_c_e_viii!\the\numexpr#3.%
      \fi
    \fi
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_fm_ex}}
%\begin{lverb}
% P < 16: \CALX_fm_ex{P}{D}<blocks>\xint: gives 1Al!1Ah!z. with A the
% mantissa if D <= P (z = 0), else A = round(M/10^z), z = D - P, by
% \CALX_fm_re.
%
% \CALX_fm_re{c}{B3}{B2}{B1}{B0}{P}, 1 <= c <= 31: Q = B3 ... B0 (four
% blocks) rounded to round(Q/10^c) < 10^P (at most 16 digits), with the
% same output. With c = 8a + b (\CALX_fm_ref selects the three blocks
% X2, X1, X0 from index a and the block Xm below them) and p = 10^b:
% Al = floor(X0/p) + (X1 mod p) 10^8/p, Ah = floor(X1/p) + (X2 mod p)
% 10^8/p, plus one if the first dropped digit is >= 5 (b > 0: 2 (X0 mod p)
% >= p; b = 0: Xm >= 5 10^7). \CALX_fm_rec, \CALX_fm_red$empty: carry, and
% 10^P becomes 10^(P-1) with c + 1.
%
% \CALX_fm_fd{x}{p} = floor(x/p) = (2x - p + 1)/(2p) in \numexpr (no tie,
% 0 <= x < 2^30). \CALX_pten{k} = 10^k, 0 <= k <= 8.
% \CALX_ndig{v} (calxcore): number of digits of 0 < v < 10^8.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fm_ex #1#2#3!1#4!1#5!#6\xint:%
{%
    \ifnum#1<#2 % P may be the token \XINTdigits: no space may follow it
      \CALX_fm_re{#2-#1}{0}{#5}{#4}{\xint_gobble_i#3}{#1}%
    \else
      #3!1#4!0.%
    \fi
}%
\def\CALX_fm_fd #1#2{((\xint_c_ii*(#1)-(#2)+\xint_c_i)/(\xint_c_ii*(#2)))}%
\def\CALX_fm_re #1#2#3#4#5#6%
{%
    \expandafter\CALX_fm_rea\the\numexpr(\xint_c_ii*(#1)-\xint_c_vii)/16.%
    #1.#2.#3.#4.#5.#6.%
}%
\def\CALX_fm_rea #1.#2.%
   {\expandafter\CALX_fm_ref\the\numexpr\CALX_pten{#2-%
       \xint_c_viii*#1}.#1.#2.}%
\def\CALX_fm_ref #1.#2.#3.#4.#5.#6.#7.#8.%
{%
    \ifcase#2
         \xint_dothis{\CALX_fm_reb #1.#3.#5.#6.#7.0.#8.}%
    \or  \xint_dothis{\CALX_fm_reb #1.#3.#4.#5.#6.#7.#8.}%
    \or  \xint_dothis{\CALX_fm_reb #1.#3.0.#4.#5.#6.#8.}%
    \fi  \xint_orthat{\CALX_fm_reb #1.#3.0.0.#4.#5.#8.}%
}%
\def\CALX_fm_reb #1.#2.#3.#4.#5.#6.#7.%
{%
    \expandafter\CALX_fm_rec\the\numexpr
      \CALX_fm_fd{#5}{#1}+(#4-\CALX_fm_fd{#4}{#1}*#1)*(\xint_c_e_viii/#1)%
      \ifnum#1=\xint_c_i \ifnum#6>49999999 +\xint_c_i\fi
      \else\ifnum\numexpr\xint_c_ii*(#5-\CALX_fm_fd{#5}{#1}*#1)<#1
      \else +\xint_c_i\fi\fi\expandafter.%
    \the\numexpr\CALX_fm_fd{#4}{#1}+(#3-\CALX_fm_fd{#3}{#1}*#1)*(%
        \xint_c_e_viii/#1).#2.#7.%
}%
\def\CALX_fm_rec #1.#2.%
{%
    \ifnum#1=\xint_c_e_viii
      \xint_dothis{\expandafter\CALX_fm_red\the\numexpr#2+\xint_c_i.0.}\fi
    \xint_orthat{\CALX_fm_red #2.#1.}%
}%
\def\CALX_fm_red #1.#2.#3.#4.%
{%
    \ifnum\ifnum#4>\xint_c_viii #1<\CALX_pten{#4-\xint_c_viii}\else#2<%
        \CALX_pten{#4}\fi
      \space \expandafter\xint_secondoftwo\else\expandafter\xint_firstoftwo\fi
    {\ifnum#4>\xint_c_viii 100000000!\the\numexpr\CALX_pten{#4-9}+%
        \xint_c_e_viii!%
     \else\the\numexpr\CALX_pten{#4-\xint_c_i}+\xint_c_e_viii!100000000!\fi
     \the\numexpr#3+\xint_c_i.}%
    {\the\numexpr#2+\xint_c_e_viii!\the\numexpr#1+\xint_c_e_viii!#3.}%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_fm_k}}
%\begin{lverb}
% \CALX_fm_k 1Al!1Ah!1Bl!1Bh!{s}{E}{P}: each block is split into two
% groups of four digits (\CALX_fm_k ... \CALX_fm_ke, digits only moved), the
% seven column sums are computed in \numexpr from the lowest one
% (\CALX_fm_kf), each with 10^9 added, so that the carry is the first five
% digits after the leading 1 and the group of four digits of the product is
% the last four (\CALX_fm_s). \CALX_fm_o, \CALX_fm_p regroup the eight
% groups into the four blocks of the product, top first:
% \CALX_fm_r{B3}{B2}{B1}{B0}{s}{E}{P}.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fm_k 1#1#2#3#4#5!{\CALX_fm_kb{#5}{#1#2#3#4}}%
\def\CALX_fm_kb #1#21#3#4#5#6#7!{\CALX_fm_kc{#1}{#2}{#7}{#3#4#5#6}}%
\def\CALX_fm_kc #1#2#3#41#5#6#7#8#9!{%
    \CALX_fm_kd{#1}{#2}{#3}{#4}{#9}{#5#6#7#8}}%
\def\CALX_fm_kd #1#2#3#4#5#61#7#8#9%
   {\CALX_fm_ke{#1}{#2}{#3}{#4}{#5}{#6}{#7#8#9}}%
\def\CALX_fm_ke #1#2#3#4#5#6#7#8#9!{%
    \CALX_fm_kf{#1}{#2}{#3}{#4}{#5}{#6}{#9}{#7#8}}%
\def\CALX_fm_kf #1#2#3#4#5#6#7#8%
{%
    \expandafter\CALX_fm_o\the\numexpr1000000000+#4*#8+%
    \expandafter\CALX_fm_s\the\numexpr1000000000+#3*#8+#4*#7+%
    \expandafter\CALX_fm_s\the\numexpr1000000000+#2*#8+#3*#7+#4*#6+%
    \expandafter\CALX_fm_s\the\numexpr1000000000+#1*#8+#2*#7+#3*#6+#4*#5+%
    \expandafter\CALX_fm_s\the\numexpr1000000000+#1*#7+#2*#6+#3*#5+%
    \expandafter\CALX_fm_s\the\numexpr1000000000+#1*#6+#2*#5+%
    \expandafter\CALX_fm_s\the\numexpr1000000000+#1*#5;%
}%
\def\CALX_fm_s 1#1#2#3#4#5{#1#2#3#4#5;}%
\def\CALX_fm_o 1#1#2#3#4#5#6#7#8#9;{\CALX_fm_p{#2#3#4#5#6#7#8#9}}%
\def\CALX_fm_p #1#2;#3;#4;#5;#6;#7;{\CALX_fm_r{#1}{#2#3}{#4#5}{#6#7}}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_fm_r}}
%\begin{lverb}
% Rounding of the product Q to P digits, and output.
%
% P = 16 (\CALX_fm_rxvi): both A's have 16 digits, so Q has 31 or 32
% digits. 32 digits (B3 >= 10^7): R = B3 B + B2 rounded with the top digit
% of B1, c = 16; 31 digits: R = floor(Q/10^15), cut by \CALX_fm_rft (digits
% only moved), c = 15. Then \CALX_fm_xvif (carry, 10^16). R has 16 digits;
% with E + c = 8e + r (0 <= r < 8), the result is F<s><16+r>.<e>. followed
% by the blocks of R 10^r: \CALX_fm_oa<r> emits the low block and calls
% \CALX_fm_ob<r> for the two others (\CALX_fm_oa for r = 0: R itself).
%
% P < 16 (\CALX_fm_rg, \CALX_fm_rr): the number of digits of Q gives
% c = D(Q) - P; if c > 0, \CALX_fm_re. \CALX_fm_no ... \CALX_fm_nt$empty: the
% output as above, with D(R) computed and R 10^r by \CALX_fm_fd.
%
% floor(E/8) = (2E - 7)/16 in \numexpr (never a tie).
%\end{lverb}
%    \begin{macrocode}
\expandafter\def\csname CALX_fm_oa0\endcsname #1!#2!{1#1!1#2!}%
\expandafter\def\csname CALX_fm_oa1\endcsname
   #1#2#3#4#5#6#7#8!{1#2#3#4#5#6#7#80!\CALX_fm_obi{#1}}%
\def\CALX_fm_obi #1#2#3#4#5#6#7#8#9!{1#3#4#5#6#7#8#9#1!10000000#2!}%
\expandafter\def\csname CALX_fm_oa2\endcsname
   #1#2#3#4#5#6#7#8!{1#3#4#5#6#7#800!\CALX_fm_obii{#1#2}}%
\def\CALX_fm_obii #1#2#3#4#5#6#7#8#9!{1#4#5#6#7#8#9#1!1000000#2#3!}%
\expandafter\def\csname CALX_fm_oa3\endcsname
   #1#2#3#4#5#6#7#8!{1#4#5#6#7#8000!\CALX_fm_obiii{#1#2#3}}%
\def\CALX_fm_obiii #1#2#3#4#5#6#7#8#9!{1#5#6#7#8#9#1!100000#2#3#4!}%
\expandafter\def\csname CALX_fm_oa4\endcsname
   #1#2#3#4#5#6#7#8!{1#5#6#7#80000!\CALX_fm_obiv{#1#2#3#4}}%
\def\CALX_fm_obiv #1#2#3#4#5#6#7#8#9!{1#6#7#8#9#1!10000#2#3#4#5!}%
\expandafter\def\csname CALX_fm_oa5\endcsname
   #1#2#3#4#5#6#7#8!{1#6#7#800000!\CALX_fm_obv{#1#2#3#4#5}}%
\def\CALX_fm_obv #1#2#3#4#5#6#7#8#9!{1#7#8#9#1!1000#2#3#4#5#6!}%
\expandafter\def\csname CALX_fm_oa6\endcsname
   #1#2#3#4#5#6#7#8!{1#7#8000000!\CALX_fm_obvi{#1#2#3#4#5#6}}%
\def\CALX_fm_obvi #1#2#3#4#5#6#7#8#9!{1#8#9#1!100#2#3#4#5#6#7!}%
\expandafter\def\csname CALX_fm_oa7\endcsname #1#2#3#4#5#6#7#8!{1#80000000!%
    \CALX_fm_obvii{#1#2#3#4#5#6#7}}%
\def\CALX_fm_obvii #1#2#3#4#5#6#7#8#9!{1#9#1!10#2#3#4#5#6#7#8!}%
\def\CALX_fm_r #1#2#3#4#5#6#7%
{%
    \ifnum#7=16 \expandafter\CALX_fm_rxvi\else\expandafter\CALX_fm_rg\fi
    {#1}{#2}{#3}{#4}{#5}{#6}{#7}%
}%
\def\CALX_fm_rxvi #1#2#3#4#5#6#7%
{%
    \expandafter\CALX_fm_ox\expanded{%
    \ifnum#1>9999999
      \CALX_fm_xvif{#2+\ifnum#3>49999999 \xint_c_i\else\xint_c_\fi}{#1}{16}%
    \else
      \CALX_fm_rft #1!#2!#3!%
    \fi}{#5}{#6}%
}%
\def\CALX_fm_rft #1#2!#3#4!#5#6#7!%
   {\CALX_fm_xvif{#4#5+\ifnum#6>\xint_c_iv\xint_c_i\else\xint_c_%
       \fi}{#2#3}{15}}%
\def\CALX_fm_ox 1#1!1#2!#3.#4#5%
   {\expandafter\CALX_fm_oy\the\numexpr#5+#3.#1.#2.#4}%
\def\CALX_fm_oy #1.%
   {\expandafter\CALX_fm_oz\the\numexpr(\xint_c_ii*#1-\xint_c_vii)/16.#1.}%
\def\CALX_fm_oz #1.#2.%
   {\expandafter\CALX_fm_ow\the\numexpr#2-\xint_c_viii*#1.#1.}%
\def\CALX_fm_ow #1.#2.#3.#4.#5%
{%
    \expanded{ F#5\the\numexpr16+#1.#2.%
      \csname CALX_fm_oa#1\endcsname#3!#4!}%
}%
\def\CALX_fm_rg #1#2#3#4#5#6#7%
{%
    \expandafter\CALX_fm_rr\the\numexpr
      \ifnum#1>\xint_c_ 24+\CALX_ndig{#1}\else
      \ifnum#2>\xint_c_ 16+\CALX_ndig{#2}\else
      \ifnum#3>\xint_c_ 8+\CALX_ndig{#3}\else\CALX_ndig{#4}\fi\fi\fi-#7.%
    {#1}{#2}{#3}{#4}{#5}{#6}{#7}%
}%
\def\CALX_fm_rr #1.#2#3#4#5#6#7#8%
{%
    \ifnum#1>\xint_c_
      \expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo\fi
    {\expandafter\CALX_fm_no\expanded{\CALX_fm_re{#1}{#2}{#3}{#4}{#5}{#8}}}%
    {\CALX_fm_no 1#5!1#4!0.}{#6}{#7}%
}%
\def\CALX_fm_no 1#1!1#2!#3.#4#5%
{%
    \expandafter\CALX_fm_nq\the\numexpr#5+#3\expandafter.%
    \the\numexpr\ifnum#2>\xint_c_ 8+\CALX_ndig{#2}\else\CALX_ndig{#1}%
        \fi.#1.#2.#4%
}%
\def\CALX_fm_nq #1.%
   {\expandafter\CALX_fm_nr\the\numexpr(\xint_c_ii*#1-\xint_c_vii)/16.#1.}%
\def\CALX_fm_nr #1.#2.%
   {\expandafter\CALX_fm_ns\the\numexpr#2-\xint_c_viii*#1.#1.}%
\def\CALX_fm_ns #1.%
   {\expandafter\CALX_fm_nt\the\numexpr\CALX_pten{\xint_c_viii-#1}.#1.}%
\def\CALX_fm_nt #1.#2.#3.#4.#5.#6.#7%
{%
    \expanded{ F#7\the\numexpr#4+#2.#3.%
      \the\numexpr(#5-\CALX_fm_fd{#5}{#1}*#1)*\CALX_pten{#2}+%
          \xint_c_e_viii!%
      \ifnum\numexpr#4+#2>\xint_c_viii
        \the\numexpr\CALX_fm_fd{#5}{#1}+(#6-\CALX_fm_fd{#6}{#1}*#1)*%
            \CALX_pten{#2}%
           +\xint_c_e_viii!\fi
      \ifnum\numexpr#4+#2>16 \the\numexpr\CALX_fm_fd{#6}{#1}+\xint_c_e_viii!%
          \fi}%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_fm_q}}
%\begin{lverb}
% P <= 20 after \CALX_fround of both operands (P > 16, and also P <= 16 when
% a mantissa has more than 24 digits). Each mantissa M (D digits) is read
% as A = M 10^(20-D), exactly 20 digits (D <= 27 after rounding: the
% dropped digits are zeros), in groups of four digits, low group first:
% x0.x1.x2.x3.x4. (\CALX_fq_x$empty: \CALX_fq_r<n> reverses the n blocks,
% \CALX_fq_s<z> drops the z leading zeros of the top block, \CALX_fq_ga,
% _gb, _gc take 20 digits, digits only moved). X Y = A A' 10^E with
%(
%:   E = 8(e + e') + D + D' - 40.
%)
% \CALX_fm_qa x0.x1.x2.x3.x4.y0.y1.y2.y3.y4. computes the 40 digits of A A'
% with one chain of nine \numexpr (one per column of the products of
% groups, 10^9 added, carry by \CALX_fm_s as in \CALX_fm_k). Its nine
% arguments are the five x and four y; it only moves tokens: the five
% columns using y4 are passed to \CALX_fm_qb ending with x<i>*, the four
% lower columns as a ready tail; \CALX_fm_qb (seven arguments) appends y4.
%
% \CALX_fq_o keeps the top 23 or 24 digits S of A A' (P + 1 digits are
% enough for round half away from zero), exponent E + 16. \CALX_fq_p,
% _q, _t$empty: with e = floor(E/8) and r = E - 8e, the mantissa S 10^r is
% cut in blocks (\CALX_fq_bl, after z leading zeros, z the complement of
% len(S) + r to a multiple of 8) and \CALX_fround{P} gives the result.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fm_q #1#2#3#4#5#6#7#8%
{%
    \expandafter\CALX_fm_qa\expanded{\CALX_fq_x{#2}#4\xint:\CALX_fq_x{#6}#8%
        \xint:%
      {\if#1#5+\else-\fi}{\the\numexpr\xint_c_viii*(#3+#7)+#2+#6-40}}%
}%
\def\CALX_fq_x #1{\expandafter\CALX_fq_xa\the\numexpr(\xint_c_ii*#1+%
    \xint_c_vii)/16.#1.}%
\def\CALX_fq_xa #1.#2.%
   {\csname CALX_fq_r#1\endcsname{\the\numexpr%
       \xint_c_viii*#1-#2}}%
\expandafter\def\csname CALX_fq_r1\endcsname #11#2!#3\xint:%
   {\csname CALX_fq_s#1\endcsname #200000000000000000000\xint:}%
\expandafter\def\csname CALX_fq_r2\endcsname #11#2!1#3!#4\xint:%
   {\csname CALX_fq_s#1\endcsname #3#200000000000000000000%
       \xint:}%
\expandafter\def\csname CALX_fq_r3\endcsname #11#2!1#3!1#4!#5\xint:%
   {\csname CALX_fq_s#1\endcsname #4#3#200000000000000000000%
       \xint:}%
\expandafter\def\csname CALX_fq_r4\endcsname #11#2!1#3!1#4!1#5!#6\xint:%
   {\csname CALX_fq_s#1\endcsname #5#4#3#200000000000000000000%
       \xint:}%
\expandafter\def\csname CALX_fq_s0\endcsname {\CALX_fq_ga}%
\expandafter\def\csname CALX_fq_s1\endcsname #1{\CALX_fq_ga}%
\expandafter\def\csname CALX_fq_s2\endcsname #1#2{\CALX_fq_ga}%
\expandafter\def\csname CALX_fq_s3\endcsname #1#2#3{\CALX_fq_ga}%
\expandafter\def\csname CALX_fq_s4\endcsname #1#2#3#4{\CALX_fq_ga}%
\expandafter\def\csname CALX_fq_s5\endcsname #1#2#3#4#5{\CALX_fq_ga}%
\expandafter\def\csname CALX_fq_s6\endcsname #1#2#3#4#5#6{\CALX_fq_ga}%
\expandafter\def\csname CALX_fq_s7\endcsname #1#2#3#4#5#6#7{\CALX_fq_ga}%
\def\CALX_fq_ga #1#2#3#4#5#6#7#8{\CALX_fq_gb{#5#6#7#8.#1#2#3#4.}}%
\def\CALX_fq_gb #1#2#3#4#5#6#7#8#9{\CALX_fq_gc{#6#7#8#9.#2#3#4#5.#1}}%
\def\CALX_fq_gc #1#2#3#4#5#6\xint:{#2#3#4#5.#1}%
\def\CALX_fm_qa #1.#2.#3.#4.#5.#6.#7.#8.#9.%
{%
    \CALX_fm_qb{#5*}{#5*#9+#4*}{#4*#9+#5*#8+#3*}{#3*#9+#4*#8+#5*#7+#2*}%
               {#2*#9+#3*#8+#4*#7+#5*#6+#1*}%
    {\expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1*#9+#2*#8+#3*#7+#4*#6+%
     \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1*#8+#2*#7+#3*#6+%
     \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1*#7+#2*#6+%
     \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1*#6;}%
}%
\def\CALX_fm_qb #1#2#3#4#5#6#7.%
{%
    \expandafter\CALX_fm_qo\the\numexpr\xint_c_e_ix+#1#7+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#2#7+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#3#7+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#4#7+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#5#7+#6%
}%
\def\CALX_fm_qo 1#1#2#3#4#5#6#7#8#9;{\CALX_fm_qp{#2#3#4#5#6#7#8#9}}%
\def\CALX_fm_qp #1#2;#3;#4;#5;#6;#7;#8;#9;{\CALX_fq_o{#1}{#2#3#4#5}}%
\def\CALX_fq_o #1#2#3#4%
{%
    \expandafter\CALX_fq_p\expanded{\ifnum#1>9999999 {24}{#1}\else{23}{%
        \xint_gobble_i#1}\fi
      {#2}{#3}{\the\numexpr#4+16}}%
}%
\def\CALX_fq_p #1#2#3#4#5% len, top, rest, s, E (P follows)
{%
    \expandafter\CALX_fq_q\the\numexpr(\xint_c_ii*#5-%
        \xint_c_vii)/16.#1.{#2#3}{#4}{#5}%
}%
\def\CALX_fq_q #1.#2.#3#4#5% e, len, S, s, E (P follows)
{%
    \expandafter\CALX_fq_t\the\numexpr#5-\xint_c_viii*#1.#2.{#1}{#3}{#4}%
}%
\def\CALX_fq_t #1.#2.#3#4#5#6% r, len, e, S, s, P
{%
    \CALX_fnround{#6}{\expanded{ F#5\the\numexpr#2+#1.#3.%
      \expandafter\CALX_fq_bl\expandafter{\expandafter}\expanded{%
      \CALX_ffr_zs{\numexpr\xint_c_viii*((\xint_c_ii*(#2+#1)+%
          \xint_c_vii)/16)-#2-#1\relax}%
      #4\CALX_ffr_zs{#1}}\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:}}%
}%
\def\CALX_fq_bl #1#2#3#4#5#6#7#8#9%
   {\xint_gob_til_xint: #2\CALX_fq_ble\xint:%
    \CALX_fq_bl{1#2#3#4#5#6#7#8#9!#1}}%
\def\CALX_fq_ble\xint:\CALX_fq_bl#1{\CALX_fq_bly#1}%
\def\CALX_fq_bly #1!{}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_fm_v}}
%\begin{lverb}
% 20 < P <= 24, after \CALX_fround of both operands. Each mantissa M (D
% digits, D <= 32, the digits after the 24th are zeros) is read as
% A = M 10^(24-D), exactly 24 digits, in six groups of four digits:
% x0.x1.x2.x3.x4.x5. low group first for X (\CALX_fv_x, \CALX_fv_ga, _gb,
% _gc), y5.y4.y3.y2.y1.y0. high group first for Y (\CALX_fv_ma, _mb,
% _mc), digits only moved (\CALX_fv_r<n> reverses the n blocks,
% \CALX_fh_s<z> drops the z leading zeros of the top block). X Y = A A'
% 10^E with
%(
%:   E = 8(e + e') + D + D' - 48.
%)
% With c_k the sum of the x_i y_j, i + j = k, A A' is the sum of the c_k
% 10^(4k), k = 0..10. \CALX_fv_ka and \CALX_fv_kb compute the columns
% c_4 to c_10 in one chain of seven \numexpr (10^9 added, carry by
% \CALX_fm_s as in \CALX_fm_qa), 26 products. \CALX_fv_ka (nine
% arguments: the six x, then y5, y4, y3) only moves tokens: it writes the
% three top columns, the part of c_7 without y2 ending with x5*, then
% \CALX_fv_kb with the parts of c_6, c_5, c_4 without y2, y1, y0 (each
% ending with the x to be multiplied by y2) and x3, x4, x5; \CALX_fv_kb
% (nine arguments, the last three y2, y1, y0) completes the columns.
%
% Truncation: W, the sum of the c_k 10^(4k) for k >= 4, is computed
% exactly; A A' - W, the sum for k <= 3, is less than 4.0004 10^20 since
% c_k <= (k+1)(10^4-1)^2. Let V = W 10^(-16) (31 or 32 digits, top column
% c_10 >= 10^6 as x5, y5 >= 1000) and m >= 7 the number of digits of V
% below the rounding position. The omitted part, less than 40004 units of
% V, changes the result only if V mod 10^m lies in [5 10^(m-1) - 40004,
% 5 10^(m-1)): the digits of V from position 5 to m-2 are 9, the digit
% m-1 is 4, and V mod 10^5 >= 59996. \CALX_fv_t and \CALX_fv_u test a
% necessary condition on the digits 4 to 7 of V (the group of c_5): digit
% 5 is 9 and digit 4 is at least 5, and digit 6 is 4 (m = 7), digits 6
% and 7 are 9 and 4 (m = 8), digits 6 and 7 are 9 (m >= 9). If it holds,
% the exact product \CALX_fm_g runs (its call follows the arguments in
% the input stream). Otherwise \CALX_fv_ok drops the group of c_4 and
% finishes as \CALX_fm_q (\CALX_fq_p) with the 27 or 28 top digits of
% A A' and exponent E + 20.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fm_v #1#2#3#4#5#6#7#8#9%
{%
    \expandafter\CALX_fv_ka\expanded{\CALX_fv_x{#2}\CALX_fv_ga#4\xint:%
    \CALX_fv_x{#6}\CALX_fv_ma#8\xint:%
    {\if#1#5+\else-\fi}{\the\numexpr\xint_c_viii*(#3+#7)+#2+#6-48}}{#9}%
    {\CALX_fm_g{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}}%
}%
\def\CALX_fv_x #1{\expandafter\CALX_fv_xa\the\numexpr(\xint_c_ii*#1+%
    \xint_c_vii)/16.#1.}%
\def\CALX_fv_xa #1.#2.%
   {\csname CALX_fv_r#1\endcsname{\the\numexpr%
       \xint_c_viii*#1-#2}}%
\expandafter\def\csname CALX_fv_r1\endcsname #1#21#3!#4\xint:%
   {\csname CALX_fh_s#1\endcsname#2#3000000000000000000000000%
       \xint:}%
\expandafter\def\csname CALX_fv_r2\endcsname #1#21#3!1#4!#5\xint:%
   {\csname CALX_fh_s#1\endcsname#2#4#3000000000000000000000000%
       \xint:}%
\expandafter\def\csname CALX_fv_r3\endcsname #1#21#3!1#4!1#5!#6\xint:%
   {\csname CALX_fh_s#1%
       \endcsname#2#5#4#3000000000000000000000000\xint:}%
\expandafter\def\csname CALX_fv_r4\endcsname #1#21#3!1#4!1#5!1#6!#7\xint:%
   {\csname CALX_fh_s#1%
       \endcsname#2#6#5#4#3000000000000000000000000\xint:}%
\def\CALX_fv_ga #1#2#3#4#5#6#7#8{\CALX_fv_gb{#5#6#7#8.#1#2#3#4.}}%
\def\CALX_fv_gb #1#2#3#4#5#6#7#8#9{\CALX_fv_gc{#6#7#8#9.#2#3#4#5.#1}}%
\def\CALX_fv_gc #1#2#3#4#5#6#7#8#9{#6#7#8#9.#2#3#4#5.#1\CALX_fh_gz}%
\def\CALX_fv_ma #1#2#3#4#5#6#7#8{#1#2#3#4.#5#6#7#8.\CALX_fv_mb}%
\def\CALX_fv_mb #1#2#3#4#5#6#7#8{#1#2#3#4.#5#6#7#8.\CALX_fv_mc}%
\def\CALX_fv_mc #1#2#3#4#5#6#7#8#9\xint:{#1#2#3#4.#5#6#7#8.}%
\def\CALX_fv_ka #1.#2.#3.#4.#5.#6.#7.#8.#9.%
{%
    \expandafter\CALX_fv_o\the\numexpr\xint_c_e_ix+#6*#7+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#5*#7+#6*#8+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#4*#7+#5*#8+#6*#9+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#3*#7+#4*#8+#5*#9+#6*%
    \CALX_fv_kb{#2*#7+#3*#8+#4*#9+#5*}{#1*#7+#2*#8+#3*#9+#4*}%
               {#1*#8+#2*#9+#3*}%
               {#4}{#5}{#6}%
}%
\def\CALX_fv_kb #1#2#3#4#5#6#7.#8.#9.%
{%
    #7+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1#7+#6*#8+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#2#7+#5*#8+#6*#9+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#3#7+#4*#8+#5*#9;%
}%
\def\CALX_fv_o 1#1#2#3#4#5#6#7#8#9;{\CALX_fv_p{#2#3#4#5#6#7#8#9}}%
\def\CALX_fv_p #1#2;#3;#4;#5;#6;#7;{\CALX_fv_t#6{#1}{#2#3#4#5#6}}%
\def\CALX_fv_t #1#2#3#4%
{%
    \ifnum#3#4>94 \xint_afterfi{\CALX_fv_u#1#2}\fi%
        \CALX_fv_ok
}%
\def\CALX_fv_u #1#2#3#4#5#6#7#8#9%
{%
    \ifnum\ifcase\numexpr\ifnum#4>9999999 25\else24\fi-#8\relax
            \if4#2\xint_c_i\else\xint_c_\fi
          \or\ifnum#1#2=49 \xint_c_i\else\xint_c_\fi
          \else\ifnum#1#2=99 \xint_c_i\else\xint_c_\fi\fi=\xint_c_i
       \xint_dothis{#9}\fi
    \xint_orthat{#3{#4}{#5}{#6}{#7}{#8}{#9}}%
}%
\def\CALX_fv_ok #1#2#3#4#5#6%
{%
    \expandafter\CALX_fq_p\expanded
      {\ifnum#1>9999999 {28}{#1}\else{27}{\xint_gobble_i#1}\fi
       {#2}{#3}{\the\numexpr#4+20}}{#5}%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_fm_h}}
%\begin{lverb}
% 20 < P <= 34, after \CALX_fround of both operands. Each mantissa is read
% as A = M 10^(40-D) (40 digits, D <= 41) by \CALX_fh_x, in two halves of
% five groups: x0.x1.x2.x3.x4.!x5.x6.x7.x8.x9.! (A = AH 10^20 + AL).
% Three products by copies of the kernel of \CALX_fm_qa (\CALX_fh_qa:
% five blocks, low first; \CALX_fh_ra: AH AH' 10^4 in six blocks):
%(
%:   V = AH AH' 10^20 + AH AL' + AL AH',   A A' = V 10^20 + AL AL'.
%)
% \CALX_fh_m, _t, _u add the blocks (one nested chain, top block first);
% the two lowest blocks of V are dropped after their carries.
%
% Rounding: 0 <= AL AL' < 10^40, that is less than 10^20 units of V. With
% m >= 25 digits of V below the rounding position (true for P <= 34, V
% having at least 59 digits), the omitted term changes the result only if
% the digits of V from position 20 to m-1 read 4999...9; then digits 20 to
% 23 are 9999 (block V2 > 99989999). In that rare case \CALX_fh_fb runs
% the exact product \CALX_fm_g, whose call follows the arguments in the
% input stream; otherwise \CALX_fh_ok keeps the top blocks covering P + 1
% digits and finishes as \CALX_fm_q (\CALX_fq_p).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fm_h #1#2#3#4#5#6#7#8#9%
{%
    \expandafter\CALX_fh_a\expanded{\CALX_fh_x{#2}#4\xint:\CALX_fh_x{#6}#8%
        \xint:%
    {\if#1#5+\else-\fi}{\the\numexpr\xint_c_viii*(#3+#7)+#2+#6-60}}{#9}%
    {\CALX_fm_g{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}}%
}%
\def\CALX_fh_x #1{\expandafter\CALX_fh_xa\the\numexpr(\xint_c_ii*#1+%
    \xint_c_vii)/16.#1.}%
\def\CALX_fh_xa #1.#2.%
   {\csname CALX_fh_r#1\endcsname{\the\numexpr%
       \xint_c_viii*#1-#2}}%
\expandafter\def\csname CALX_fh_r1\endcsname #11#2!#3\xint:%
   {\csname CALX_fh_s#1\endcsname\CALX_fh_ga %
       #20000000000000000000000000000000000000000\xint:}%
\expandafter\def\csname CALX_fh_r2\endcsname #11#2!1#3!#4\xint:%
   {\csname CALX_fh_s#1\endcsname\CALX_fh_ga %
       #3#20000000000000000000000000000000000000000\xint:}%
\expandafter\def\csname CALX_fh_r3\endcsname #11#2!1#3!1#4!#5\xint:%
   {\csname CALX_fh_s#1\endcsname\CALX_fh_ga %
       #4#3#20000000000000000000000000000000000000000\xint:}%
\expandafter\def\csname CALX_fh_r4\endcsname #11#2!1#3!1#4!1#5!#6\xint:%
   {\csname CALX_fh_s#1\endcsname\CALX_fh_ga %
       #5#4#3#20000000000000000000000000000000000000000\xint:}%
\expandafter\def\csname CALX_fh_r5\endcsname #11#2!1#3!1#4!1#5!1#6!#7\xint:%
   {\csname CALX_fh_s#1\endcsname\CALX_fh_ga %
       #6#5#4#3#20000000000000000000000000000000000000000\xint:}%
\expandafter\def\csname CALX_fh_r6\endcsname
   #11#2!1#3!1#4!1#5!1#6!1#7!#8\xint:%
   {\csname CALX_fh_s#1\endcsname\CALX_fh_ga %
       #7#6#5#4#3#20000000000000000000000000000000000000000\xint:}%
\expandafter\def\csname CALX_fh_s0\endcsname #1{#1}%
\expandafter\def\csname CALX_fh_s1\endcsname #1#2{#1}%
\expandafter\def\csname CALX_fh_s2\endcsname #1#2#3{#1}%
\expandafter\def\csname CALX_fh_s3\endcsname #1#2#3#4{#1}%
\expandafter\def\csname CALX_fh_s4\endcsname #1#2#3#4#5{#1}%
\expandafter\def\csname CALX_fh_s5\endcsname #1#2#3#4#5#6{#1}%
\expandafter\def\csname CALX_fh_s6\endcsname #1#2#3#4#5#6#7{#1}%
\expandafter\def\csname CALX_fh_s7\endcsname #1#2#3#4#5#6#7#8{#1}%
\def\CALX_fh_ga #1#2#3#4#5#6#7#8{\CALX_fh_gb{#5#6#7#8.#1#2#3#4.!}}%
\def\CALX_fh_gb #1#2#3#4#5#6#7#8#9{\CALX_fh_gc{#6#7#8#9.#2#3#4#5.#1}}%
\def\CALX_fh_gc #1#2#3#4#5#6#7#8#9{\CALX_fh_gd{#6#7#8#9.!#2#3#4#5.#1}}%
\def\CALX_fh_gd #1#2#3#4#5#6#7#8#9{\CALX_fh_ge{#6#7#8#9.#2#3#4#5.#1}}%
\def\CALX_fh_ge #1#2#3#4#5#6#7#8#9{#6#7#8#9.#2#3#4#5.#1\CALX_fh_gz}%
\def\CALX_fh_gz #1\xint:{}%
\def\CALX_fh_a #1!#2!#3!#4!%
{%
    \expandafter\CALX_fh_m\expanded
      {\CALX_fh_qa #2#3\CALX_fh_qa #1#4\CALX_fh_ra #2#4}%
}%
\def\CALX_fh_m 1#1!1#2!1#3!1#4!1#5!1#6!1#7!1#8!1#9!%
   {\CALX_fh_t{#1+#6}{#2+#7}{#3+#8}{#4+#9}{#5}}%
\def\CALX_fh_t #1#2#3#4#51#6!1#7!1#8!1#9!%
   {\CALX_fh_u{#1}{#2}{#3+#7}{#4+#8}{#5+#6+#9}}%
\def\CALX_fh_u #1#2#3#4#51#6!1#7!1#8!%
{%
    \expandafter\CALX_fh_v\the\numexpr#8+%
    \expandafter\CALX_fh_c\the\numexpr\xint_c_e_ix+#7+%
    \expandafter\CALX_fh_c\the\numexpr\xint_c_e_ix+#6+%
    \expandafter\CALX_fh_c\the\numexpr\xint_c_e_ix+#5+%
    \expandafter\CALX_fh_c\the\numexpr\xint_c_e_ix+#4+%
    \expandafter\CALX_fh_c\the\numexpr\xint_c_e_ix+#3+%
    \expandafter\CALX_fh_c\the\numexpr\xint_c_e_ix+#2+%
    \expandafter\CALX_fh_c\the\numexpr\xint_c_e_ix+#1;%
}%
\def\CALX_fh_c 1#1{#1;}%
\def\CALX_fh_v #1;#2;#3;#4;#5;#6;#7;#8;%
{%
    \ifnum#6>99989999 \expandafter\CALX_fh_fb\else\expandafter\CALX_fh_ok\fi
    {#1}{#2#3#4}{#5}%
}%
\def\CALX_fh_fb #1#2#3#4#5#6#7{#7}%
\def\CALX_fh_ok #1#2#3#4#5#6#7%
{%
    \expandafter\CALX_fq_p\expanded
      {\ifnum#6>26 {\the\numexpr32+\CALX_ndig{#1}}{#1}{#2#3}{#4}{\the%
          \numexpr#5+24}%
       \else{\the\numexpr24+\CALX_ndig{#1}}{#1}{#2}{#4}{\the\numexpr#5+32}%
           \fi}{#6}%
}%
\def\CALX_fh_qa #1.#2.#3.#4.#5.#6.#7.#8.#9.%
{%
    \CALX_fh_qb{#5*}{#5*#9+#4*}{#4*#9+#5*#8+#3*}{#3*#9+#4*#8+#5*#7+#2*}%
               {#2*#9+#3*#8+#4*#7+#5*#6+#1*}%
    {\expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1*#9+#2*#8+#3*#7+#4*#6+%
     \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1*#8+#2*#7+#3*#6+%
     \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1*#7+#2*#6+%
     \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1*#6;}%
}%
\def\CALX_fh_qb #1#2#3#4#5#6#7.%
{%
    \expandafter\CALX_fh_qo\the\numexpr\xint_c_e_ix+#1#7+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#2#7+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#3#7+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#4#7+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#5#7+#6%
}%
\def\CALX_fh_ra #1.#2.#3.#4.#5.#6.#7.#8.#9.%
{%
    \CALX_fh_rb{#5*}{#5*#9+#4*}{#4*#9+#5*#8+#3*}{#3*#9+#4*#8+#5*#7+#2*}%
               {#2*#9+#3*#8+#4*#7+#5*#6+#1*}%
    {\expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1*#9+#2*#8+#3*#7+#4*#6+%
     \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1*#8+#2*#7+#3*#6+%
     \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1*#7+#2*#6+%
     \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1*#6;}%
}%
\def\CALX_fh_rb #1#2#3#4#5#6#7.%
{%
    \expandafter\CALX_fh_ro\the\numexpr\xint_c_e_ix+#1#7+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#2#7+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#3#7+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#4#7+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#5#7+#6%
}%
\def\CALX_fh_qo 1#1#2#3#4#5#6#7#8#9;{\CALX_fh_qp{#2#3#4#5#6#7#8#9}}%
\def\CALX_fh_qp #1#2;#3;#4;#5;#6;#7;#8;#9;{1#8#9!1#6#7!1#4#5!1#2#3!1#1!}%
\def\CALX_fh_ro 1#1#2#3#4#5#6#7#8#9;{\CALX_fh_rp{#2#3#4#5}{#6#7#8#9}}%
\def\CALX_fh_rp #1#2#3;#4;#5;#6;#7;#8;#9;{%
    \CALX_fh_rr{1#8#9!1#6#7!1#4#5!1#2#3!10000#1!}}%
\def\CALX_fh_rr #1#2;{1#20000!#1}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_fm_big}}
%\begin{lverb}
% Every case other than P <= 16 with mantissas of at most 24 digits: both
% operands are rounded by \CALX_fround, special values and zero are
% handled (a zero operand: \CALX_fm_zero gobbles the nine arguments and
% gives F+0.0.), then \CALX_fm_c dispatches on P: P <= 20 to \CALX_fm_q,
% 20 < P <= 24 to \CALX_fm_v, 24 < P <= 34 to \CALX_fm_h, P > 34 to
% \CALX_fm_g.
%
% \CALX_fm_g (also the rare fallback of \CALX_fm_v and \CALX_fm_h) is
% the exact generic path: the mantissas are multiplied by \CALX_nmul; the
% digit count of the product is read on its top block (\CALX_nskip,
% \CALX_fm_gl), and the native float is rounded by \CALX_fround.
%
% \CALX_fm_gb N<s><n>.<blocks>\xint:{e}{P}: the list is grabbed once;
% one copy is walked to the top block (digit count D), the other is left
% in place after the header F<s><D>.<e>. given to \CALX_fround (which
% needs no terminator). e and D are evaluated in front by a \numexpr
% chain, so \CALX_fm_gd takes only small arguments.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fm_big #1#2%
   {\expandafter\CALX_fm_a\romannumeral0\CALX_fround{#1}{#2}{#1}}%
\def\CALX_fm_a #1#2#3\xint:#4#5%
{%
    \if I#1\CALX_fm_asx\fi
    \expandafter\CALX_fm_btag\romannumeral0\CALX_fround{#4}{#5}{#4}#2#3%
    \xint:%
}%
\def\CALX_fm_asx\fi#1\CALX_fm_btag{\fi\expandafter\CALX_fm_asz}%
\def\CALX_fm_asz #1\xint:#2#3\xint:{\CALX_fm_sp#1\xint:I#3\xint:}%
\def\CALX_fm_btag #1#2{\if I#1\CALX_fm_bsy#2\fi\CALX_fm_c#2}%
\def\CALX_fm_bsy #1\fi#2\xint:#3#4\xint:{\fi\CALX_fm_sp I#1\xint:F#4\xint:}%
\def\CALX_fm_c #1#2.#3.#4\xint:#5#6#7.#8.#9\xint:%
{%
    \csname CALX_fm_\ifnum\ifnum#2=\xint_c_ \xint_c_\else#7\fi=\xint_c_ zero%
    \else\ifnum#5>34 g\else\ifnum#5>24 h\else\ifnum#5>20 v\else q%
    \fi\fi\fi\fi\endcsname{#6}{#7}{#8}{#9}{#1}{#2}{#3}{#4}{#5}%
}%
\def\CALX_fm_zero #1#2#3#4#5#6#7#8#9{ F+0.0.}%
\def\CALX_fm_g #1#2#3#4#5#6#7#8%
{%
    \expandafter\CALX_fm_gb\romannumeral0\CALX_nmul
      {\expanded{N#1\the\numexpr(\xint_c_ii*#2+\xint_c_vii)/16.}#4}%
      {\expanded{N#5\the\numexpr(\xint_c_ii*#6+\xint_c_vii)/16.}#8}%
          \xint:{#3+#7}%
}%
\def\CALX_fm_gb N#1#2.#3\xint:#4#5%
{%
    \expandafter\CALX_fm_gd\the\numexpr#4\expandafter.\the\numexpr
    \xint_c_viii*(#2-\xint_c_i)+\CALX_nskip\CALX_fm_gl #2-\xint_c_i.#3\xint:.%
    #1{#5}#3%
}%
\def\CALX_fm_gl 1#1!#2\xint:{\CALX_ndig{#1}}%
\def\CALX_fm_gd #1.#2.#3#4{\CALX_fnround{#4}{ F#3#2.#1.}}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_fmulx{X}{Y} (use with \romannumeral0; X, Y finite natives, any
% digit counts): the exact product X Y as a native float, not rounded
% (D up to D_X + D_Y). Zero operand: F+0.0. Same code as \CALX_fm_g
% (\CALX_nmul on the mantissas, digit count read on the top block),
% without the final \CALX_fround.
%
% \CALX_fmulxs{X}{Y}: the same for values coming from the parsers, whose
% tag may have catcode 11 (values stored in the meaning of a compiled
% function, read from a file): \string makes the tag of each operand,
% after its f-expansion, of catcode 12, as the patterns of \CALX_fmx_b
% require. \CALX_fmulx itself is for the values calx computes.
%
% Delimited entry for the two already expanded operands.  The ordinary
% \CALX_fmulxs entry remains for internal callers with expandable operands.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fmulx #1%
   {\expandafter\CALX_fmx_a\romannumeral`&&@#1\xint:}%
\def\CALX_fmx_a #1\xint:#2%
   {\expandafter\CALX_fmx_b\romannumeral`&&@#2\xint:#1\xint:}%
\def\CALX_fmulxs_in #1\xint:#2\xint:%
   {\expandafter\CALX_fmx_vi\string#1\xint:#2\xint:}%
\def\CALX_fmx_vi #1\xint:#2\xint:%
   {\expandafter\CALX_fmx_b\string#2\xint:#1\xint:}%
\def\CALX_fmulxs #1%
   {\expandafter\CALX_fmx_s\romannumeral`&&@#1\xint:}%
\def\CALX_fmx_s{\expandafter\CALX_fmx_t\string}%
\def\CALX_fmx_t #1\xint:#2%
   {\expandafter\CALX_fmx_u\romannumeral`&&@#2\xint:#1\xint:}%
\def\CALX_fmx_u{\expandafter\CALX_fmx_b\string}%
\def\CALX_fmx_b F#1#2.#3.#4\xint:F#5#6.#7.#8\xint:%
{%
    \ifnum\ifnum#2=\xint_c_ \xint_c_\else#6\fi=\xint_c_
      \xint_dothis\CALX_fmx_zero\fi
    \xint_orthat\CALX_fmx_nonzero
    F#1#2.#3.#4\xint:F#5#6.#7.#8\xint:
}%
\def\CALX_fmx_zero #1\xint:#2\xint:{ F+0.0.}%
\def\CALX_fmx_nonzero F#1#2.#3.#4\xint:F#5#6.#7.#8\xint:%
{%
    \expandafter\CALX_fmx_c\romannumeral0\CALX_nmul
      {\expanded{N#1\the\numexpr(\xint_c_ii*#2+\xint_c_vii)/16.}#4}%
      {\expanded{N#5\the\numexpr(\xint_c_ii*#6+\xint_c_vii)/16.}#8}%
      \xint:{#3+#7}%
}%
\def\CALX_fmx_c N#1#2.#3\xint:#4%
{%
    \expandafter\CALX_fmx_d\the\numexpr#4\expandafter.\the\numexpr
    \xint_c_viii*(#2-\xint_c_i)+\CALX_nskip\CALX_fm_gl #2-\xint_c_i.#3\xint:.%
    #1#3%
}%
\def\CALX_fmx_d #1.#2.#3{ F#3#2.#1.}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_faddx{X}{Y}, \CALX_fsubx{X}{Y} (use with \romannumeral0; X, Y
% finite natives): X + Y, X - Y exact, not rounded. The operand with the
% larger block exponent gets that many zero blocks at its low end
% (\CALX_fa_z), both become integers N<s><n>.<blocks> (same blocks, n =
% ceil(D/8)), \CALX_nadd or \CALX_nsub adds them, and the digit count of
% the result is read on its top block as in \CALX_fm_g. A zero operand
% gives the other one.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_faddx #1#2%
   {\expandafter\CALX_fx_a\romannumeral`&&@#2\xint:{#1}\CALX_nadd}%
\def\CALX_fsubx #1#2%
   {\expandafter\CALX_fx_a\romannumeral`&&@#2\xint:{#1}\CALX_nsub}%
\def\CALX_fx_a F#1#2.#3.#4\xint:#5#6%
   {\expandafter\CALX_fx_b\romannumeral`&&@#5\xint:#6#1#2.#3.#4\xint:}%
\def\CALX_fx_b F#1#2.#3.#4\xint:#5#6#7.#8.#9\xint:%
{%
    \ifnum#7=\xint_c_ \xint_dothis\CALX_fx_zy\fi
    \ifnum#2=\xint_c_ \xint_dothis\CALX_fx_zx\fi
    \xint_orthat\CALX_fx_nonzero
    F#1#2.#3.#4\xint:#5#6#7.#8.#9\xint:
}%
\def\CALX_fx_zy F#1#2.#3.#4\xint:#5#6#7.#8.#9\xint:%
   { F#1#2.#3.#4}%
\def\CALX_fx_zx F#1#2.#3.#4\xint:#5#6#7.#8.#9\xint:%
{%
    \ifx#5\CALX_nsub\expandafter\CALX_fx_m\else\expandafter\space\fi
    F#6#7.#8.#9%
}%
\def\CALX_fx_nonzero F#1#2.#3.#4\xint:#5#6#7.#8.#9\xint:%
{%
    \expandafter\CALX_fx_c\the\numexpr\ifnum#3<#8 #3\else#8\fi
      \expandafter.\romannumeral0#5%
      {\expanded{N#1\the\numexpr(2*#2+7)/16\ifnum#3>#8 +#3-#8\fi.%
        \ifnum#3>#8 \CALX_fa_z#3-#8.\fi}#4}%
      {\expanded{N#6\the\numexpr(2*#7+7)/16\ifnum#8>#3 +#8-#3\fi.%
        \ifnum#8>#3 \CALX_fa_z#8-#3.\fi}#9}\xint:%
}%
\def\CALX_fx_m F#1%
  {\if-#1\expandafter\CALX_fx_p\else\expandafter\CALX_fx_n\fi}%
\def\CALX_fx_p{ F+}%
\def\CALX_fx_n{ F-}%
\def\CALX_fx_c #1.N#2#3.%
{%
    \ifnum#3=\xint_c_ \expandafter\CALX_fx_z\else
      \expandafter\CALX_fx_d\fi #1.#2#3.%
}%
\def\CALX_fx_z #1\xint:{ F+0.0.}%
\def\CALX_fx_d #1.#2#3.#4\xint:%
{%
    \expandafter\CALX_fmx_d\the\numexpr#1\expandafter.\the\numexpr
    \xint_c_viii*(#3-\xint_c_i)+\CALX_nskip\CALX_fm_gl #3-\xint_c_i.#4\xint:.%
    #2#4%
}%
%    \end{macrocode}
% \subsection{Squaring}
% \subsubsection{\csh{CALX_fsqr}}
%\begin{lverb}
% Syntax (use with \romannumeral0; P a \numexpr expression; X f-expanded
% F, I or raw value):
%(
%  \CALX_fsqr{P}{X}   -> <space>Z    Z = round_P(round_P(X)^2)
%:  \CALX_fsqru{P}{X}  -> <space>Z    (X finite F, at most P digits)
%)
% \CALX_fsqr{P}{X} (use with \romannumeral0, X f-expanded):
% round_P(round_P(X)^2), round half away from zero, as xint's
% \XINTinFloatSqr[P]; the same result as \CALX_fmul{P}{X}{X}, with the
% operand read once and kernels which compute each cross product once
% (x_i x_j + x_j x_i written as 2 x_i x_j).
%
% Special values: I? gives I?, I+ and I- give I+. Zero gives F+0.0.
%
% P <= 16 and a mantissa of at most 24 digits: one extraction as in
% \CALX_fmul (\CALX_fm_xvi, \CALX_fm_ex), then \CALX_fs_k (the square of
% the 16 digit A, seven columns, ten products) and \CALX_fm_r. Otherwise
% \CALX_fs_big: \CALX_fround, then by P: \CALX_fs_q (P <= 20),
% \CALX_fs_v (P <= 24), \CALX_fs_h (P <= 34), \CALX_fs_g (generic, also
% the fallback of \CALX_fs_v and \CALX_fs_h). They read the operand as
% \CALX_fm_q, \CALX_fm_v, \CALX_fm_h read X, with exponents
%(
%:   E = 16e + 2D - 40,   E = 16e + 2D - 48,   E = 16e + 2D - 60,
%)
% and finish as these. With x_i the groups of four digits, the column
% c_k of A^2 is
%(
%:   c_k = 2 (sum of x_i x_(k-i), i < k - i) + x_(k/2)^2,
%)
% the square term only for k even: its value is at most that of the
% column of a product (same number of terms), so the carry scheme of
% \CALX_fm_s is unchanged; the truncation bounds of \CALX_fm_v and
% \CALX_fm_h hold as they are (they only use the sizes of the operands).
% \CALX_fs_q$empty: 15 products instead of 25, one kernel macro of five
% arguments; \CALX_fs_v$empty: 15 instead of 26, one macro of six arguments;
% \CALX_fs_h$empty: two kernels instead of three (AH AL once, \CALX_fs_ra for
% AH^2), \CALX_fs_m doubles the blocks of AH AL in the merge of
% \CALX_fh_u.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fsqr #1%
{%
    \ifnum#1>16 \expandafter\CALX_fs_big\else\expandafter\CALX_fs_na\fi
    {#1}%
}%
\def\CALX_fsqru #1%
{%
    \ifnum#1>16 \expandafter\CALX_fqu_b\else\expandafter\CALX_fs_na\fi
    {#1}%
}%
\def\CALX_fqu_b #1#2{\expandafter\CALX_fs_b\romannumeral`&&@#2\xint:{#1}}%
\def\CALX_fs_na #1#2{\expandafter\CALX_fs_nc\romannumeral`&&@#2\xint:{#1}}%
\def\CALX_fs_nc #1%
   {\if F#1\expandafter\CALX_fs_nd\else\expandafter\CALX_fs_ns
    \expandafter#1\fi}%
\def\CALX_fs_ns #1%
   {\if I#1\expandafter\CALX_fs_sp\else\expandafter\CALX_fs_nr
    \expandafter#1\fi}%
\def\CALX_fs_nr #1#2\xint:#3{\CALX_fs_big{#3}{#1#2}}%
\def\CALX_fs_sp #1#2\xint:#3{\if ?#1\xint_dothis{ I?}\fi\xint_orthat{ I+}}%
\def\CALX_fs_nd #1#2.#3.#4\xint:#5%
{%
    \ifnum#2=\xint_c_ \CALX_fs_nz\fi
    \ifnum#2>24 \CALX_fs_nbig{#5}{F#1#2.#3.#4}\fi
    \expandafter\CALX_fs_ne\expanded
      {\CALX_fm_ny{#5}{#2}#4100000000!100000000!\xint:{\the\numexpr16*#3}}%
    {#5}%
}%
\def\CALX_fs_nz\fi#1\expanded#2#3{\fi\CALX_sp F+0.0.}%
\def\CALX_fs_nbig #1#2\fi#3\expanded#4#5{\fi\CALX_fs_big{#1}{#2}}%
\def\CALX_fs_ne #1!#2!#3.#4{\CALX_fs_k #1!#2!{+}{#4+#3+#3}}%
\def\CALX_fs_k 1#1#2#3#4#5!{\CALX_fs_kb{#5}{#1#2#3#4}}%
\def\CALX_fs_kb #1#21#3#4#5#6#7!{\CALX_fs_kf{#1}{#2}{#7}{#3#4#5#6}}%
\def\CALX_fs_kf #1#2#3#4%
{%
    \expandafter\CALX_fm_o\the\numexpr1000000000+#4*#4+%
    \expandafter\CALX_fm_s\the\numexpr1000000000+#3*#4*\xint_c_ii+%
    \expandafter\CALX_fm_s\the\numexpr1000000000+#2*#4*\xint_c_ii+#3*#3+%
    \expandafter\CALX_fm_s\the\numexpr1000000000+(#1*#4+#2*#3)*\xint_c_ii+%
    \expandafter\CALX_fm_s\the\numexpr1000000000+#1*#3*\xint_c_ii+#2*#2+%
    \expandafter\CALX_fm_s\the\numexpr1000000000+#1*#2*\xint_c_ii+%
    \expandafter\CALX_fm_s\the\numexpr1000000000+#1*#1;%
}%
\def\CALX_fs_big #1#2%
   {\expandafter\CALX_fs_b\romannumeral0\CALX_fround{#1}{#2}{#1}}%
\def\CALX_fs_b #1%
   {\if I#1\expandafter\CALX_fs_sp\else\expandafter\CALX_fs_c\fi}%
\def\CALX_fs_c #1#2.#3.#4\xint:#5%
{%
    \csname CALX_fs_\ifnum#2=\xint_c_ zero\else\ifnum#5>34 g\else
    \ifnum#5>24 h\else\ifnum#5>20 v\else q\fi\fi\fi\fi\endcsname
    {#1}{#2}{#3}{#4}{#5}%
}%
\def\CALX_fs_zero #1#2#3#4#5{ F+0.0.}%
\def\CALX_fs_g #1#2#3#4{\CALX_fm_g{#1}{#2}{#3}{#4}{#1}{#2}{#3}{#4}}%
\def\CALX_fs_q #1#2#3#4%
{%
    \expandafter\CALX_fs_qa\expanded{\CALX_fq_x{#2}#4\xint:%
      {+}{\the\numexpr16*#3+\xint_c_ii*#2-40}}%
}%
\def\CALX_fs_qa #1.#2.#3.#4.#5.%
{%
    \expandafter\CALX_fm_qo\the\numexpr\xint_c_e_ix+#5*#5+%
    \CALX_fs_qc{#1}{#2}{#3}{#4}{#5}%
}%
\def\CALX_fs_qc #1#2#3#4#5%
{%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#4*#5*\xint_c_ii+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#3*#5*\xint_c_ii+#4*#4+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+(#2*#5+#3*#4)*%
        \xint_c_ii+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+(#1*#5+#2*#4)*%
        \xint_c_ii+#3*#3+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+(#1*#4+#2*#3)*%
        \xint_c_ii+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1*#3*\xint_c_ii+#2*#2+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1*#2*\xint_c_ii+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#1*#1;%
}%
\def\CALX_fs_v #1#2#3#4#5%
{%
    \expandafter\CALX_fs_va\expanded{\CALX_fv_x{#2}\CALX_fv_ga#4\xint:%
    {+}{\the\numexpr16*#3+\xint_c_ii*#2-48}}{#5}%
    {\CALX_fs_g{#1}{#2}{#3}{#4}{#5}}%
}%
\def\CALX_fs_va #1.#2.#3.#4.#5.#6.%
{%
    \expandafter\CALX_fv_o\the\numexpr\xint_c_e_ix+#6*#6+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#5*#6*\xint_c_ii+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+#4*#6*\xint_c_ii+#5*#5+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+(#3*#6+#4*#5)*%
        \xint_c_ii+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+(#2*#6+#3*#5)*%
        \xint_c_ii+#4*#4+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+(#1*#6+#2*#5+#3*#4)*%
        \xint_c_ii+%
    \expandafter\CALX_fm_s\the\numexpr\xint_c_e_ix+(#1*#5+#2*#4)*%
        \xint_c_ii+#3*#3;%
}%
\def\CALX_fs_h #1#2#3#4#5%
{%
    \expandafter\CALX_fs_a\expanded{\CALX_fh_x{#2}#4\xint:%
    {+}{\the\numexpr16*#3+\xint_c_ii*#2-60}}{#5}%
    {\CALX_fs_g{#1}{#2}{#3}{#4}{#5}}%
}%
\def\CALX_fs_a #1!#2!%
   {\expandafter\CALX_fs_m\expanded{\CALX_fh_qa #2#1\CALX_fs_ra #2}}%
\def\CALX_fs_m 1#1!1#2!1#3!1#4!1#5!1#6!1#7!1#8!%
{%
    \CALX_fh_u{#1*\xint_c_ii}{#2*\xint_c_ii}{#3*\xint_c_ii+#6}%
      {#4*\xint_c_ii+#7}{#5*\xint_c_ii+#8}%
}%
\def\CALX_fs_ra #1.#2.#3.#4.#5.%
{%
    \expandafter\CALX_fh_ro\the\numexpr\xint_c_e_ix+#5*#5+%
    \CALX_fs_qc{#1}{#2}{#3}{#4}{#5}%
}%
%    \end{macrocode}
% \subsection{Division}
% \subsubsection{\csh{CALX_fdiv}}
%\begin{lverb}
% Syntax (use with \romannumeral0; P a \numexpr expression; X, Y
% f-expanded F, I or raw values):
%(
%  \CALX_fdiv{P}{X}{Y}   -> <space>Z    Z = round_P(round_P(X)/round_P(Y))
%:  \CALX_fdivu{P}{X}{Y}  -> <space>Z    (X, Y finite F, at most P digits)
%)
% \CALX_fdiv{P}{X}{Y} (use with \romannumeral0, X and Y f-expanded):
% round_P(round_P(X) / round_P(Y)), round half away from zero, as xint's
% \XINTinFloatDiv[P].
%
% Both operands are rounded by \CALX_fround. Special values
% (\CALX_fd_sp$empty: I? propagates, Inf / Inf signals InvalidOperation,
% Inf / finite is Inf with the sign of the quotient, finite / Inf is
% zero), then zero operands: x / 0 signals DivisionByZero (handler
% argument the sign of x), 0 / 0 DivisionUndefined, 0 / y is F+0.0.
%
% Generic path (\CALX_fd_g$empty): the quotient q = Mx 10^(8a) / My
% satisfies q > 10^(Dx + 8a - Dy - 1), so with
%(
%:   a = max(0, ceil((P + 1 + Dy - Dx)/8))
%)
% zero blocks in front of Mx (\CALX_fa_z), the truncated integer quotient
% N (\CALX_ndivtrunc, sign of the quotient) has at least P + 1 digits.
% Round half away from zero to P digits depends only on the P + 1 top
% digits of the exact quotient, which are those of N; so the native float
% N 10^(8(ex - ey - a)) is rounded by \CALX_fround as in \CALX_fm_g
% (\CALX_fm_gb).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fdiv #1#2%
   {\expandafter\CALX_fd_a\romannumeral0\CALX_fround{#1}{#2}{#1}}%
\def\CALX_fdivu #1#2%
   {\expandafter\CALX_fdu\romannumeral`&&@#2\xint:{#1}}%
\def\CALX_fdu F#1\xint:#2#3%
   {\expandafter\CALX_fd_btag\romannumeral`&&@#3\xint:{#2}#1\xint:}%
\def\CALX_fd_a #1#2#3\xint:#4#5%
{%
    \if I#1\CALX_fd_asx#2\fi
    \expandafter\CALX_fd_btag\romannumeral0\CALX_fround{#4}{#5}{#4}#2#3%
    \xint:%
}%
\def\CALX_fd_asx #1\fi#2\CALX_fd_btag%
   {\fi\expandafter\CALX_fd_asz\expandafter#1}%
\def\CALX_fd_asz #1#2#3#4\xint:#5#6\xint:{\CALX_fd_sp I#1#2#3}%
\def\CALX_fd_btag #1#2{\if I#1\CALX_fd_bsy#2\fi\CALX_fd_c#2}%
\def\CALX_fd_bsy #1\fi#2\xint:#3#4#5\xint:{\fi\CALX_fd_sp F#4I#1}%
\def\CALX_fd_sp #1#2#3#4%
{%
    \if ?#2\xint_dothis{ I?}\fi
    \if ?#4\xint_dothis{ I?}\fi
    \if F#1\xint_dothis{ F+0.0.}\fi
    \if F#3\xint_dothis{\CALX_nsp_ps#2#4}\fi
    \xint_orthat{\CALX_nsig{InvalidOperation}{inf / inf}{}}%
}%
\def\CALX_fd_c #1#2.#3.#4\xint:#5#6#7.#8.#9\xint:%
{%
    \csname CALX_fd_\ifnum#2=\xint_c_ zz\else\ifnum#7=\xint_c_ zero\else
    \ifnum#5>40 g\else\ifnum#5<5 g\else v\fi\fi\fi\fi\endcsname
    {#6}{#7}{#8}{#9}{#1}{#2}{#3}{#4}{#5}%
}%
\def\CALX_fd_zz #1#2#3#4#5#6#7#8#9{\CALX_fd_z{#2}{#1}}%
\let\CALX_fd_zero\CALX_fm_zero
\def\CALX_fd_z #1#2%
{%
    \ifnum#1=\xint_c_ \xint_dothis{\CALX_nsig{DivisionUndefined}{0 / 0}{}}\fi
    \xint_orthat{\CALX_nsig{DivisionByZero}{x / 0}{#2}}%
}%
\def\CALX_fd_g #1#2#3#4#5#6#7#8#9%
{%
    \expandafter\CALX_fd_i\the\numexpr
      \ifnum\numexpr#9+\xint_c_i+#6-#2<\xint_c_ \xint_c_\else
      (\xint_c_ii*(#9+\xint_c_i+#6-#2)+\xint_c_vii)/16\fi.%
      {#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}%
}%
\def\CALX_fd_i #1.#2#3#4#5#6#7#8#9%
{%
    \expandafter\CALX_fm_gb\romannumeral0\CALX_ndivtrunc
      {\expanded{N#2\the\numexpr(\xint_c_ii*#3+\xint_c_vii)/16+#1.%
        \CALX_fa_z#1.}#5}%
      {\expanded{N#6\the\numexpr(\xint_c_ii*#7+\xint_c_vii)/16.}#9}%
    \xint:{#4-#8-#1}%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_fd_v}}
%\begin{lverb}
% Division kernel for 5 <= P <= 40 (\CALX_fd_c calls \CALX_fd_v instead of
% \CALX_fd_g). With m = ceil(P/4) and n = ceil((P+1)/4), each mantissa is
% read as an integer of exactly 4m digits (A = Mx 10^(4m-Dx), B = My
% 10^(4m-Dy), the dropped digits are zeros), in groups of four digits a_i,
% b_i (\CALX_dv_rd, \CALX_dv_r<k> reverses the k blocks, \CALX_fh_s<z>
% drops the z leading zeros of the top block, \CALX_dv_gg takes m groups;
% the counter tokens \CALX_dv_k<i> expand to \CALX_dv_k<i-1>). Then
%(
%:   X / Y = (A / B) 10^E,   E = 8(ex - ey) + Dx - Dy.
%)
% Long division in base 10^4 with a signed remainder: R_0 = A, and for
% i = 1..n
%(
%:   q_i = round(10^4 R'/B'),   R_i = 10^4 R_(i-1) - q_i B,
%)
% R' and B' being the two top groups of R_(i-1) and B (\numexpr a*b/c,
% 64 bit intermediate product). The estimate is within 0.0015 of
% 10^4 R_(i-1)/B, so |R_i| <= 0.5015 B for i >= 1, |q_i| <= 5100 for
% i >= 2, 1000 <= q_1 < 10^5, and no correction step is needed. Then
%(
%:   A 10^(4n) = B (q_1 10^(4(n-1)) + ... + q_n) + R_n,
%)
% so Q = floor(A 10^(4n)/B) is that sum, minus one if R_n < 0; Q has at
% least 4n >= P + 1 digits, enough for the rounding (as in \CALX_fd_g).
%
% Data of a step (top first): <prefix><counter> b_(m-1) T; then the entries
% l.\CALX_dv_c b; of the lower groups of R and B, then 0.\CALX_dv_e; (T is
% the signed top group of R, the l are in [0, 10^4)). \CALX_dv_s computes q,
% \CALX_dv_sq writes the top column of R_i, the next columns are written
% by \CALX_dv_c (one entry l.\CALX_dv_c b; each: the entries carry the
% column macro, the next one is called with q after its b, while \numexpr
% is evaluating the column above: one nested chain of m \numexpr; the
% last entry 0.\CALX_dv_e; ends the chain). A column computes
% 2 10^9 + l - q b + carry (ten digits); the four digits of b are put in
% front of the result (\expandafter over single digits), \CALX_dv_sb,
% \CALX_dv_sc split it into the carry (six digits minus 200000) and the
% new group, and put the entry back after it. So the result has the
% layout of the input; the top column ends with \CALX_dv_tt,
% which starts the next step with the counter decremented.
%
% The q_i are written into the output of \expanded as the text of a second
% nested chain: \CALX_dv_n1, \CALX_dv_ns split 2 10^8 + q_i + carry (nine
% digits), the last column gets the correction (-1 if T < 0 at the end,
% \CALX_dv_f). The groups are glued (\relax ends the \numexpr of the
% columns), \CALX_dv_nt receives the top carry and the 4n digits and
% finishes as \CALX_fm_q (\CALX_fq_p, exponent E - 4n).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fd_v #1#2#3#4#5#6#7#8#9%
{%
    \expandafter\CALX_dv_a\the\numexpr(\xint_c_ii*#9+\xint_c_iii)/%
    \xint_c_viii\expandafter.\the\numexpr(\xint_c_ii*#9+5)/\xint_c_viii.%
    {#2}{#4}{#6}{#8}{\if#1#5+\else-\fi}{\xint_c_viii*(#3-#7)+#2-#6}{#9}%
}%
\def\CALX_dv_a #1.#2.#3#4#5#6% m, n, Dx, Mx, Dy, My
{%
    \expanded{\unexpanded{\expandafter\CALX_dv_nt\the\numexpr}0+%
      \expandafter\CALX_dv_s\expandafter\CALX_dv_ni
      \csname CALX_dv_k#2\expandafter\endcsname
      \expanded{\expandafter\CALX_dv_il\expanded{%
        \CALX_dv_rd{#3}{#1}#4\xint:!.\xint:\CALX_dv_rd{#5}{#1}#6\xint:!.%
            \xint:}}}%
    {#2}%
}%
\def\CALX_dv_rd #1%
   {\expandafter\CALX_dv_rda\the\numexpr(\xint_c_ii*#1+%
       \xint_c_vii)/16.#1.}%
\def\CALX_dv_rda #1.#2.#3%
{%
    \csname CALX_dv_r#1\expandafter\endcsname
    \the\numexpr\xint_c_viii*#1-#2\expandafter.\csname CALX_dv_g#3\endcsname
}%
\expandafter\def\csname CALX_dv_r1\endcsname #1.#21#3!#4\xint:%
   {\csname CALX_fh_s#1\endcsname#2#3%
    000000000000000000000000000000000000000000000000\xint:}%
\expandafter\def\csname CALX_dv_r2\endcsname #1.#21#3!1#4!#5\xint:%
   {\csname CALX_fh_s#1\endcsname#2#4#3%
    000000000000000000000000000000000000000000000000\xint:}%
\expandafter\def\csname CALX_dv_r3\endcsname #1.#21#3!1#4!1#5!#6\xint:%
   {\csname CALX_fh_s#1\endcsname#2#5#4#3%
    000000000000000000000000000000000000000000000000\xint:}%
\expandafter\def\csname CALX_dv_r4\endcsname #1.#21#3!1#4!1#5!1#6!#7\xint:%
   {\csname CALX_fh_s#1\endcsname#2#6#5#4#3%
    000000000000000000000000000000000000000000000000\xint:}%
\expandafter\def\csname CALX_dv_r5\endcsname
   #1.#21#3!1#4!1#5!1#6!1#7!#8\xint:%
   {\csname CALX_fh_s#1\endcsname#2#7#6#5#4#3%
    000000000000000000000000000000000000000000000000\xint:}%
\expandafter\def\csname CALX_dv_r6\endcsname
   #1.#21#3!1#4!1#5!1#6!1#7!1#8!#9\xint:%
   {\csname CALX_fh_s#1\endcsname#2#8#7#6#5#4#3%
    000000000000000000000000000000000000000000000000\xint:}%
\def\CALX_dv_gg #1#2#3#4#5%
{%
    \ifx#1\CALX_dv_kz\xint_dothis\CALX_dv_gz\fi
    \xint_orthat{#2#3#4#5.\expandafter\CALX_dv_gg#1}%
}%
\def\CALX_dv_gz #1\xint:{}%
\def\CALX_dv_il #1.#2\xint:#3.#4\xint:{#3#1;\CALX_dv_im#2\xint:#4\xint:}%
\def\CALX_dv_im #1.#2\xint:#3.#4\xint:%
{%
    \xint_gob_til_exclam #1\CALX_dv_ie!%
    #1.\noexpand\CALX_dv_c#3;\CALX_dv_im#2\xint:#4\xint:%
}%
\def\CALX_dv_ie!#1\xint:#2\xint:{0.\noexpand\CALX_dv_e;}%
\def\CALX_dv_kz {z}%
\expandafter\let\csname CALX_dv_k0\endcsname\CALX_dv_kz
\expandafter\def\csname CALX_dv_k1\endcsname{\CALX_dv_kz}%
\expandafter\edef\csname CALX_dv_k2\endcsname
   {\expandafter\noexpand\csname CALX_dv_k1\endcsname}%
\expandafter\edef\csname CALX_dv_k3\endcsname
   {\expandafter\noexpand\csname CALX_dv_k2\endcsname}%
\expandafter\edef\csname CALX_dv_k4\endcsname
   {\expandafter\noexpand\csname CALX_dv_k3\endcsname}%
\expandafter\edef\csname CALX_dv_k5\endcsname
   {\expandafter\noexpand\csname CALX_dv_k4\endcsname}%
\expandafter\edef\csname CALX_dv_k6\endcsname
   {\expandafter\noexpand\csname CALX_dv_k5\endcsname}%
\expandafter\edef\csname CALX_dv_k7\endcsname
   {\expandafter\noexpand\csname CALX_dv_k6\endcsname}%
\expandafter\edef\csname CALX_dv_k8\endcsname
   {\expandafter\noexpand\csname CALX_dv_k7\endcsname}%
\expandafter\edef\csname CALX_dv_k9\endcsname
   {\expandafter\noexpand\csname CALX_dv_k8\endcsname}%
\expandafter\edef\csname CALX_dv_k10\endcsname
   {\expandafter\noexpand\csname CALX_dv_k9\endcsname}%
\expandafter\edef\csname CALX_dv_k11\endcsname
   {\expandafter\noexpand\csname CALX_dv_k10\endcsname}%
\expandafter\def\csname CALX_dv_g2\endcsname
   {\expandafter\CALX_dv_gg\csname CALX_dv_k2\endcsname}%
\expandafter\def\csname CALX_dv_g3\endcsname
   {\expandafter\CALX_dv_gg\csname CALX_dv_k3\endcsname}%
\expandafter\def\csname CALX_dv_g4\endcsname
   {\expandafter\CALX_dv_gg\csname CALX_dv_k4\endcsname}%
\expandafter\def\csname CALX_dv_g5\endcsname
   {\expandafter\CALX_dv_gg\csname CALX_dv_k5\endcsname}%
\expandafter\def\csname CALX_dv_g6\endcsname
   {\expandafter\CALX_dv_gg\csname CALX_dv_k6\endcsname}%
\expandafter\def\csname CALX_dv_g7\endcsname
   {\expandafter\CALX_dv_gg\csname CALX_dv_k7\endcsname}%
\expandafter\def\csname CALX_dv_g8\endcsname
   {\expandafter\CALX_dv_gg\csname CALX_dv_k8\endcsname}%
\expandafter\def\csname CALX_dv_g9\endcsname
   {\expandafter\CALX_dv_gg\csname CALX_dv_k9\endcsname}%
\expandafter\def\csname CALX_dv_g10\endcsname
   {\expandafter\CALX_dv_gg\csname CALX_dv_k10\endcsname}%
\def\CALX_dv_s #1#2#3#4#5#6#7;#8.\CALX_dv_c#9;%
{%
    \ifx#2\CALX_dv_kz\xint_dothis{\CALX_dv_f{#7}}\fi
    \xint_orthat{\expandafter\CALX_dv_sq\the\numexpr
      (#7*10000+#8)*10000/(#3#4#5#6*10000+#9).%
      #1#2{#3#4#5#6}{#7}{#8}{#9}}%
}%
\def\CALX_dv_f #1#2\CALX_dv_e;{\ifnum#1<\xint_c_ -1\else0\fi;}%
\def\CALX_dv_sq #1.#2#3#4#5#6#7% q, prefix, counter, b, T, l, b'
{%
    \unexpanded{\expandafter#2\the\numexpr}#1+200000000+%
    \expandafter\CALX_dv_tt#3#4\the\numexpr
      #5*10000+#6-#1*#4+\CALX_dv_c#7{#1}%
}%
\def\CALX_dv_tt #1#2#3#4%
{%
    \expandafter\CALX_dv_s\expandafter\CALX_dv_ns\expandafter#1%
    \expandafter#2\expandafter#3\expandafter#4\expandafter
}%
\def\CALX_dv_c #1#2#3#4#5#6.#7;%
{%
    \expandafter\CALX_dv_sb\expandafter#1\expandafter#2\expandafter#3%
    \expandafter#4\the\numexpr#6-#5*#1#2#3#4+2000000000+#7{#5}%
}%
\def\CALX_dv_e #1{0;0.\CALX_dv_e;}%
\def\CALX_dv_sb #1#2#3#4#5#6#7#8#9{#5#6#7#8#9\CALX_dv_sc{#1#2#3#4}}%
\def\CALX_dv_sc #1#2#3#4#5#6{#2-200000;#3#4#5#6.\CALX_dv_c#1}%
\def\CALX_dv_ni #1#2#3#4#5{#1#2#3#4#5-20000;}%
\def\CALX_dv_ns #1#2#3#4#5{#1#2#3#4#5-20000\relax}%
\def\CALX_dv_nt #1;#2;#3#4#5% top, 4n digits, n, s, E (P follows)
{%
    \ifnum#1=\xint_c_ \xint_dothis{\CALX_fq_p{(\xint_c_iv*#3)}{}}\fi
    \xint_orthat{\CALX_fq_p{(\xint_c_iv*#3+\CALX_ndig{#1})}{#1}}%
    {#2}{#4}{(#5-\xint_c_iv*#3)}%
}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_fdq}}
%\begin{lverb}
% Syntax (use with \romannumeral0; P a \numexpr expression; X, Y
% f-expanded F, I or raw values; <k> one of \CALX_fdq_q, \CALX_fdq_r,
% \CALX_fdq_p):
%(
%  \CALX_fdq{P}\CALX_fdq_q{X}{Y}  -> <space>Q
%:  \CALX_fdq{P}\CALX_fdq_r{X}{Y}  -> <space>R
%:  \CALX_fdq{P}\CALX_fdq_p{X}{Y}  -> {Q}{R}
%)
% Floor division of X' and Y', the values X and Y rounded to P digits
% (\CALX_fround): Q = floor(X'/Y') exact (an F value with e = 0, not
% rounded), R = X' - Y' Q rounded to P digits (its sign is that of Y').
% They implement //, /: (and mod()), divmod() of \xintfloateval.
%
% Both F and non-zero: with d = min(e_X, e_Y), the operand of larger block
% exponent gets that many zero blocks at its low end (\CALX_fa_z, as in
% \CALX_faddx); the two integers N<s><n>.<blocks> (n = ceil(D/8) plus the
% zero blocks) go to calxcore's \CALX_ndivfloor, \CALX_nmod or
% \CALX_ndivmod; Q is converted with e = 0 and R with e = d (\CALX_fx_c:
% digit count read on the top block). A zero operand or an I value: the
% integers without zero blocks (I values as they are, d = e_X if X is
% F), and the kernels apply their rules (Python's decimal model):
% x // 0 DivisionByZero (I+ or I-), 0 // 0 DivisionUndefined (I?), x mod 0
% InvalidOperation (I?), Inf // Inf and Inf mod x InvalidOperation, x //
% Inf zero, x mod Inf x. An I result is passed on as it is.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fdq #1#2#3%
   {\expandafter\CALX_fdq_a\romannumeral0\CALX_fround{#1}{#3}#2{#1}}%
\def\CALX_fdq_a #1\xint:#2#3#4%
   {\expandafter\CALX_fdq_b\romannumeral0\CALX_fround{#3}{#4}#1\xint:#2{#3}}%
\def\CALX_fdq_b #1%
{%
    \if I#1\xint_dothis{\CALX_fdq_bi #1}\fi
    \xint_orthat{\CALX_fdq_bf #1}%
}%
\def\CALX_fdq_bi #1#2\xint:#3{\CALX_fdq_s #1#2\xint:#3}%
\def\CALX_fdq_bf #1#2\xint:#3%
{%
    \if I#3\xint_dothis\CALX_fdq_s\fi
    \xint_orthat\CALX_fdq_f #1#2\xint:#3%
}%
\def\CALX_fdq_f F#1#2.#3.#4\xint:F#5#6.#7.#8\xint:#9%
{%
    \ifnum\numexpr#2*#6=\xint_c_
      \xint_dothis\CALX_fdq_s\fi
    \xint_orthat\CALX_fdq_fg
    F#1#2.#3.#4\xint:F#5#6.#7.#8\xint:#9%
}%
\def\CALX_fdq_fg F#1#2.#3.#4\xint:F#5#6.#7.#8\xint:#9%
{%
    \expandafter#9\the\numexpr\ifnum#3<#7 #3\else#7\fi
      \expandafter.\expanded
      {{N#5\the\numexpr(\xint_c_ii*#6+\xint_c_vii)/16\ifnum#7>#3 +#7-#3\fi.%
        \ifnum#7>#3 \CALX_fa_z#7-#3.\fi#8}%
       {N#1\the\numexpr(\xint_c_ii*#2+\xint_c_vii)/16\ifnum#3>#7 +#3-#7\fi.%
        \ifnum#3>#7 \CALX_fa_z#3-#7.\fi#4}}%
}%
\def\CALX_fdq_s #1#2\xint:#3#4\xint:#5%
{%
    \expandafter#5\the\numexpr\if I#3 \xint_c_\else\CALX_fdq_x#4\xint:\fi
    \expandafter.\expanded{{\CALX_fdq_n#3#4}{\CALX_fdq_n#1#2}}%
}%
\def\CALX_fdq_x #1#2.#3.#4\xint:{#3}%
\def\CALX_fdq_n #1{\if I#1\CALX_fdq_ni\fi\CALX_fdq_nf}%
\def\CALX_fdq_ni\fi\CALX_fdq_nf{\fi I}%
\def\CALX_fdq_nf #1#2.#3.{N#1\the\numexpr(\xint_c_ii*#2+\xint_c_vii)/16.}%
\def\CALX_fdq_q #1.#2#3#4%
   {\expandafter\CALX_fdq_t\expandafter0\expandafter.%
    \romannumeral0\CALX_ndivfloor{#2}{#3}\xint:}%
\def\CALX_fdq_r #1.#2#3#4%
   {\CALX_fnround{#4}{\expandafter\CALX_fdq_t\the\numexpr#1\expandafter.%
    \romannumeral0\CALX_nmod{#2}{#3}\xint:}}%
\def\CALX_fdq_p #1.#2#3%
   {\expandafter\CALX_fdq_pa\romannumeral0\CALX_ndivmod{#2}{#3}{#1}}%
\def\CALX_fdq_pa #1#2#3#4%
   {\expanded{{\romannumeral0\CALX_fdq_t 0.#1\xint:}%
    {\romannumeral0\CALX_fnround{#4}{\CALX_fdq_t #3.#2\xint:}}}}%
\def\CALX_fdq_t #1.#2{\if I#2\expandafter\CALX_fdq_i\fi\CALX_fx_c #1.#2}%
\def\CALX_fdq_i\CALX_fx_c #1.#2\xint:{ #2}%
%    \end{macrocode}
% \subsubsection{\csh{CALX_finv}, \csh{CALX_fe}}
%\begin{lverb}
% Syntax (use with \romannumeral0; P a \numexpr expression; X f-expanded
% F, M, I or raw value; n a \numexpr expression):
%(
%  \CALX_finv{P}{X}  -> <space>Y    Y = round_P(1/X)
%:  \CALX_fe{P}{X}{n}  -> <space>A[N]  round_P(X) 10^n, raw (I unchanged)
%)
% \CALX_finv: one rounding of the exact inverse (not of the inverse of X
% rounded): X as raw A/B[N] (F by \CALX_ftoraw, M by \CALX_mtoraw_t), then
% \CALX_fround of the raw B/A[-N] (the sign moved to B; A = 0: the
% DivisionByZero of \CALX_fround's division path, I+). I+, I-: 0; I?: I?.
% The tag of X is made of catcode 12 by \string. inv() of \xintfloateval.
%
% \CALX_fe: X rounded to P digits by \CALX_fround, then \CALX_ftoraw and n
% added to the exponent. The operator x[n] of \xintfloateval; X may be the
% bare digits of the integer literal before [n] (a raw value: [0] is
% appended, n added to its exponent, then rounded as F).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_finv #1#2{\expandafter\CALX_finv_s\romannumeral`&&@#2\xint:{#1}}%
\def\CALX_finv_in #1\xint:#2.{\CALX_finv_s #1\xint:{#2}}%
\def\CALX_finv_s{\expandafter\CALX_finv_a\string}%
\def\CALX_finv_a #1#2\xint:%
{%
    \if I#1\xint_dothis{\CALX_finv_i#2}\fi
    \if F#1\xint_dothis
      {\expandafter\CALX_finv_r\romannumeral0\CALX_ftoraw{#1#2}[0]\xint:}\fi
    \if M#1\xint_dothis
      {\expandafter\CALX_finv_r\romannumeral0\CALX_mtoraw_t#1#2\xint:%
       [0]\xint:}\fi
    \xint_orthat{\CALX_finv_r#1#2[0]\xint:}%
}%
\def\CALX_finv_i #1#2{\if ?#1\xint_dothis{ I?}\fi\xint_orthat{ F+0.0.}}%
\def\CALX_finv_r #1[#2]#3\xint:%
   {\expandafter\CALX_finv_t\the\numexpr-#2.#1/1/\xint:}%
\def\CALX_finv_t #1.#2#3/#4/#5\xint:#6%
{%
    \expandafter\CALX_fbr\romannumeral0\CALX_fround{#6}%
      {\expanded{\if-#2-#4/#3\else#4/#2#3\fi}[#1]}%
}%
\def\CALX_fe_in #1\xint:#2.{\CALX_fe_s #1\xint:{#2}}%
\def\CALX_fe #1#2%
   {\expandafter\CALX_fe_s\romannumeral`&&@#2\xint:{#1}}%
\def\CALX_fe_s #1%
{%
    \if I#1\xint_dothis\CALX_fe_i\fi
    \if F#1\xint_dothis\CALX_fe_n\fi
    \if M#1\xint_dothis\CALX_fe_n\fi
    \xint_orthat\CALX_fe_r #1%
}%
\def\CALX_fe_i #1\xint:#2#3{ #1}%
\def\CALX_fe_n #1\xint:#2%
   {\expandafter\CALX_fe_a\romannumeral0\CALX_fround{#2}{#1}}%
\def\CALX_fe_a #1\xint:%
   {\expandafter\CALX_fe_b\romannumeral0\CALX_ftoraw{#1}}%
\def\CALX_fe_b #1[#2]#3{\expandafter\CALX_fe_c\the\numexpr#2+#3.{#1}}%
\def\CALX_fe_c #1.#2{ #2[#1]}%
\def\CALX_fe_r #1\xint:{\CALX_fe_t #1[0]\xint:}%
\def\CALX_fe_t #1[#2]#3\xint:#4#5%
   {\expandafter\CALX_fe_u\the\numexpr#2+#5.{#1}{#4}}%
\def\CALX_fe_u #1.#2#3%
   {\expandafter\CALX_fe_a\romannumeral0\CALX_fround{#3}{#2[#1]}{0}}%
%    \end{macrocode}
% \subsection{Square root}
% \subsubsection{\csh{CALX_fsqrt}}
%\begin{lverb}
% Syntax (use with \romannumeral0; P a \numexpr expression; X f-expanded
% F, I or raw value):
%(
%  \CALX_fsqrt{P}{X}  -> <space>Z    Z = round_P(sqrt(round_P(X)))
%)
% \CALX_fsqrt{P}{X} (use with \romannumeral0, X f-expanded):
% round_P(sqrt(round_P(X))), round half away from zero, as xint's
% \XINTinFloatSqrt[P].
%
% The operand is rounded by \CALX_fround. Special values: I? gives I?,
% I+ gives I+, I- and negative operands signal InvalidOperation
% (\CALX_nsig). Zero gives F+0.0.
%
% X = M 10^(8e), M of D digits (n blocks), o = 1 if D is odd, else 0.
%
% P <= 40 (\CALX_frt_ka...): K = max(2, ceil(P/8)), sh = 16K - D - o
% (even), Y0 = M 10^sh has 16K digits, the first one zero if o = 1, and
% sqrt(X) = sqrt(Y0) 10^(4e - sh/2). The top block v of Y0 (from the two
% top blocks of M, \CALX_frt_kt) is at least 10^6; Y = 4^j Y0 with j the
% least integer such that 4^j v >= 25000000 (j <= 3, no new block), as
% required by \CALX_nsqrt_core, which gives s = floor(sqrt(Y)) (8K
% digits) and r = Y - s^2. The blocks of Y are those of M 10^c 4^j,
% c = sh mod 8, below zb = floor(sh/8) zero blocks (\CALX_frt_mul:
% multiplication of a native by w < 2^31, base 10^4 limbs, w split as
% w1 10^4 + w0).
%
% Then sqrt(Y0) = s/2^j + f/2^j, 0 <= f < 1, and s/2^j = s 5^j 10^(-j)
% exactly. With E = 4e - sh/2 - j = 8a + b (0 <= b < 8), the native
% float s 5^j 10^b 10^(8a) (\CALX_frt_mul, \CALX_fm_gb) is rounded to P
% digits by \CALX_fround. This is the correctly rounded result:
%- if 8K > P, floor(sqrt(Y0)) = floor(s/2^j) has 8K >= P + 1 digits and
% the rounding bound is an integer, so the digits beyond it do not matter;
%- if 8K = P and j > 0, rounding up is right iff sqrt(Y0) >= S0 + 1/2
% with S0 = floor(s/2^j), that is iff s mod 2^j >= 2^(j-1), that is iff
% the first digit of the fraction s/2^j - S0 (the first dropped digit)
% is at least 5;
%- if 8K = P and j = 0, rounding up is right iff r > s; s is then
% incremented (\CALX_frt_kh compares the block counts, then the top
% blocks, then uses \CALX_nsub).
%
% P > 40 (\CALX_frt_gb): with
%(
%:   j = max(0, ceil((2P + 1 - D)/8)), plus one if j - e is odd,
%)
% the integer N = M 10^(8j) has at least 2P + 1 digits, its integer
% square root S (\CALX_nsqrtrem) has at least P + 1 digits, and
% sqrt(X) = sqrt(N) 10^(4(e-j)); the native float S 10^(8(e-j)/2) is
% rounded by \CALX_fround (\CALX_fm_gb), as in the first case.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fsqrt #1#2%
   {\expandafter\CALX_frt_a\romannumeral0\CALX_fround{#1}{#2}{#1}}%
\def\CALX_frt_a #1#2%
   {\csname CALX_frt_\if I#1sp\else\if-#2ng\else b\fi\fi\endcsname#2}%
\def\CALX_frt_sp #1#2\xint:#3%
{%
    \if ?#1\xint_dothis{ I?}\fi
    \if +#1\xint_dothis{ I+}\fi
    \xint_orthat\CALX_frt_neg
}%
\def\CALX_frt_ng #1\xint:#2{\CALX_frt_neg}%
\def\CALX_frt_neg{\CALX_nsig{InvalidOperation}{sqrt of negative}{}}%
\def\CALX_frt_b #1#2.#3.#4\xint:#5%
{%
    \csname CALX_frt_\ifnum#2=\xint_c_ z\else\ifnum#5>40 gb\else kz\fi\fi
    \endcsname{#2}{#3}{#4}{#5}%
}%
\def\CALX_frt_z #1#2#3#4{ F+0.0.}%
\def\CALX_frt_kz #1#2#3#4%
{%
    \expandafter\CALX_frt_ka\the\numexpr
      \ifnum#4<9 \xint_c_ii\else(\xint_c_ii*#4+\xint_c_vii)/16\fi.%
      {#1}{#2}{#3}{#4}%
}%
\def\CALX_frt_ka #1.#2% K, D
   {\expandafter\CALX_frt_kb\the\numexpr16*#1-#2-\ifodd#2 1\else0\fi.%
       #1.{#2}}%
\def\CALX_frt_kb #1.%
   {\expandafter\CALX_frt_kc\the\numexpr(\xint_c_ii*#1-\xint_c_vii)/16.#1.}%
\def\CALX_frt_kc #1.#2.#3.#4#5#6% zb, sh, K, D, e, blocks
{%
    \expandafter\CALX_frt_kd\the\numexpr
      \CALX_nskip\CALX_frt_kt(\xint_c_ii*#4+\xint_c_vii)/16-\xint_c_i.%
        100000000!#6\xint:{\the\numexpr#2-\xint_c_viii*#1}.%
      #1.#2.#3.{#4}{#5}{#6}%
}%
\def\CALX_frt_kt 1#1!1#2!#3\xint:#4%
   {#2*\CALX_pten{#4}+(#1+\CALX_pten{\xint_c_vii-#4}*5)/%
       \CALX_pten{\xint_c_viii-#4}-\xint_c_i}%
\def\CALX_frt_kd #1.%
{%
    \expandafter\CALX_frt_ke\the\numexpr
      \ifnum#1<25000000 \ifnum#1<6250000 \ifnum#1<1562500 3\else2\fi
      \else1\fi\else0\fi.%
}%
\def\CALX_frt_ke #1.#2.#3.#4.#5#6#7% j, zb, sh, K, D, e, blocks
{%
    \expandafter\CALX_frt_kf\romannumeral0\CALX_frt_mul
      {\CALX_pten{#3-\xint_c_viii*#2}*\ifcase#1 1\or4\or16\or64\fi}0{N+.#7}%
    \xint:{#2}{#1}{#4}{#3}{#6}%
}%
\def\CALX_frt_kf N+#1.#2\xint:#3#4#5% product, zb, j, K
{%
    \expandafter\CALX_nsqrt_core\expandafter\CALX_frt_kg
      \expanded{{\the\numexpr\xint_c_ii*#5}{\CALX_fa_z#3.\unexpanded{#2}}}%
    {#4}{#5}%
}%
\def\CALX_frt_kg #1#2#3#4#5#6#7% s, r, j, K, sh, e, P
{%
    \ifnum\numexpr#3*100+\xint_c_viii*#4-#7=\xint_c_
      \xint_dothis{\CALX_frt_kh#2#1\CALX_frt_ki0{#1}{#3}%
        {\xint_c_iv*#6-#5/\xint_c_ii}{#7}}\fi
    \xint_orthat{\CALX_frt_ki0{#1}{#3}{\xint_c_iv*#6-#5/\xint_c_ii-#3}{#7}}%
}%
\def\CALX_frt_kh N+#1.#2N+#3.#4\CALX_frt_ki0%
{%
    \ifnum#1<#3 \xint_dothis{\CALX_frt_ki0}\fi
    \ifnum#1>#3 \xint_dothis{\CALX_frt_ki1}\fi
    \xint_orthat{\expandafter\CALX_frt_kj\the\numexpr
      \CALX_nskip\CALX_frt_kt #1-\xint_c_ii.#2\xint:{0}-%
      (\CALX_nskip\CALX_frt_kt #1-\xint_c_ii.#4\xint:{0})\relax.%
      N+#1.#2\xint:N+#3.#4\xint:}%
}%
\def\CALX_frt_kj #1.#2\xint:#3\xint:%
{%
    \ifnum#1<\xint_c_ \xint_dothis{\CALX_frt_ki0}\fi
    \ifnum#1>\xint_c_ \xint_dothis{\CALX_frt_ki1}\fi
    \xint_orthat{\expandafter\CALX_frt_kk\romannumeral0\CALX_nsub{#2}{#3}%
        \xint:}%
}%
\def\CALX_frt_kk N#1#2.#3\xint:%
{%
    \if-#1\xint_dothis{\CALX_frt_ki0}\fi
    \ifnum#2=\xint_c_ \xint_dothis{\CALX_frt_ki0}\fi
    \xint_orthat{\CALX_frt_ki1}%
}%
\def\CALX_frt_ki #1#2#3#4% d, s, j, E
   {\expandafter\CALX_frt_km\the\numexpr(\xint_c_ii*(#4)-\xint_c_vii)/16.%
       #1{#2}{#3}{#4}}%
\def\CALX_frt_km #1.#2#3#4#5% a, d, s, j, E (P follows)
{%
    \expandafter\CALX_fm_gb\romannumeral0\CALX_frt_mul
      {\ifcase#4 1\or5\or25\or125\fi*\CALX_pten{#5-\xint_c_viii*#1}}#2%
      {#3}\xint:{#1}%
}%
\def\CALX_frt_mul #1#2#3%
   {\expandafter\CALX_frt_mua\the\numexpr(#1+5000)/10000-\xint_c_i.%
       {#1}#2#3\xint:}%
\def\CALX_frt_mua #1.#2#3N+#4.#5\xint:%
   {\expanded{\noexpand\CALX_nnorm+%
       \expandafter\CALX_frt_mi\the\numexpr#2-#1*10000.#1.#3.#51;!}}%
\def\CALX_frt_mi #1.#2.#3.1#4!%
   {\expandafter\CALX_frt_mj\the\numexpr#4+#3.#1.#2.}%
\def\CALX_frt_mj #1.#2.#3.%
   {\expandafter\CALX_frt_mn\the\numexpr(#1+5000)/10000-\xint_c_i.%
       #1.#2.#3.0.0.}%
\def\CALX_frt_mm #1.#2.#3.#4.1#5#6!%
{%
    \xint_gob_til_sc#5\CALX_frt_mz;%
    \expandafter\CALX_frt_mn\the\numexpr(#5#6+5000)/10000-\xint_c_i.%
       #5#6.#1.#2.#3.#4.%
}%
\def\CALX_frt_mz;#1.#2.#3.#4.#5.#6.%
{%
    \the\numexpr#5*#4+#6-((#5*#4+#6+50000000)/\xint_c_e_viii-\xint_c_i)*%
       \xint_c_e_viii+\xint_c_e_viii!%
    \the\numexpr(#5*#4+#6+50000000)/\xint_c_e_viii-\xint_c_i+%
       \xint_c_e_viii!1;!%
}%
\def\CALX_frt_mn #1.#2.#3.#4.#5.#6.% gh, x, w0, w1, ph, c
   {\expandafter\CALX_frt_mo\the\numexpr(#2-#1*10000)*#3+#5*#4+#6.%
       #1.#2.#3.#4.}%
\def\CALX_frt_mo #1.#2.#3.#4.#5.% t0, gh, x, w0, w1
   {\expandafter\CALX_frt_mp\the\numexpr#2*#4+(#3-#2*10000)*#5+%
       (#1+5000)/10000-\xint_c_i.#1.#2.#4.#5.}%
\def\CALX_frt_mp #1.#2.#3.#4.#5.% t1, t0, gh, w0, w1
{%
    \the\numexpr(#1-((#1+5000)/10000-\xint_c_i)*10000)*10000+%
       #2-((#2+5000)/10000-\xint_c_i)*10000+\xint_c_e_viii!%
    \expandafter\CALX_frt_mq\the\numexpr(#1+5000)/10000-\xint_c_i.%
       #4.#5.#3.%
}%
\def\CALX_frt_mq #1.#2.#3.#4.{\CALX_frt_mm #2.#3.#4.#1.}%
\def\CALX_frt_gb #1#2#3#4%
{%
    \expandafter\CALX_frt_c\the\numexpr
      (\xint_c_ii*(\xint_c_ii*#4+\xint_c_i-#1)+\xint_c_vii)/16.%
      {#1}{#2}{#3}{#4}%
}%
\def\CALX_frt_c #1.#2#3%
{%
    \expandafter\CALX_frt_d\the\numexpr
      \ifnum#1<\xint_c_ 0\else#1\fi
      \ifodd\numexpr\ifnum#1<\xint_c_ 0\else#1\fi-#3\relax+\xint_c_i\fi.%
      {#2}{#3}%
}%
\def\CALX_frt_d #1.#2#3#4%
{%
    \expandafter\CALX_frt_e\romannumeral0\CALX_nsqrtrem
      {\expanded{N+\the\numexpr(\xint_c_ii*#2+\xint_c_vii)/16+#1.%
        \CALX_fa_z#1.}#4}%
    \xint:{(#3-#1)/\xint_c_ii}%
}%
\def\CALX_frt_e #1#2{\CALX_fm_gb #1}%
%    \end{macrocode}
% \subsection{Factorials and binomial coefficients}
%\begin{lverb}
% Syntax (use with \romannumeral0; P, n, a, b, x, y \numexpr expressions
% with integer values):
%(
%  \CALX_ffac{P}{n}        -> <space>Y    n!
%:  \CALX_fpfac{P}{a}{b}    -> <space>Y    (a+1)(a+2)...b
%:  \CALX_fbinom{P}{x}{y}   -> <space>Y    binomial(x, y)
%)
% Y: the native F value rounded to P digits, or I? (InvalidOperation:
% n < 0 or n >= 10^8; a < b with b >= 10^8 or a <= -10^8; x < 0 or
% x >= 10^8). 0! = 1; pfactorial is 1 if a >= b, 0 if a < 0 <= b, and
% for a < b < 0 the product of the negative factors; binomial is 0 if
% y < 0 or y > x, 1 if y = 0 or y = x.
%
% The engine is xintfrac's: the value is kept as Q blocks 1<8d>! (least
% significant first), terminated by 1;!, followed by [E], E a multiple of
% 8, and multiplied by products of 4, 3, 2 or 1 consecutive integers
% (each product < 10^8; \CALX_ffac_smallmul, own small multiplication
% which reports a carry). When a carry creates a block Q + 1 the least
% significant one is dropped and E increases by 8. \CALX_ffac_increaseP
% (\CALX_fpfac_increaseP) chooses Q from the target p and a factor c
% (their last two arguments) so that the relative error is below
% c 10^(-p-1): 8Q >= p + 9 + k, k the number of digits of the count of
% products divided by c (\CALX_ndig). The blocks are those of a native
% value: \CALX_ffac_out builds it (\CALX_nnorm, \CALX_fx_c) and rounds it
% once (\CALX_fnround).
%
% Precisions. n! and pfactorial: p = P + 2, c = 1, relative error below
% 10^(-P-3), at most 0.001 ulp of the P-digit result. Binomial: pfac(y, x)
% / (x - y)! if y >= x - y, else pfac(x - y, x) / y!; numerator and
% denominator with p = P + 4, c = 4, each rounded to P + 5 digits, the
% quotient correctly rounded to P digits by \CALX_fr_xk (calxfp's division
% of natives): relative error below 2 (4 10^(-P-5) + 5 10^(-P-5)), less than
% 0.002 ulp.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ffac #1#2%
   {\expandafter\CALX_ffac_fork_a\the\numexpr#2.\xint_c_i{#1+\xint_c_ii}%
    \CALX_ffac_out{#1}}%
\def\CALX_ffac_fork_a #1%
{%
     \xint_UDzerominusfork
     #1-\CALX_ffac_iszero
     0#1\CALX_ffac_isneg
      0-{\CALX_ffac_fork_b #1}%
    \krof
}%
\def\CALX_ffac_iszero #1.#2#3#4#5{ F+1.0.100000001!}%
\def\CALX_ffac_isneg #1.#2#3#4#5%
   {\CALX_nsig{InvalidOperation}{factorial of a negative integer}{}}%
\def\CALX_ffac_fork_b #1.%
{%
    \ifnum #1>\xint_c_e_viii_mone\xint_dothis\CALX_ffac_toobig\fi
    \ifnum #1>\xint_c_e_iv\xint_dothis\CALX_ffac_vbig \fi
    \ifnum #1>465  \xint_dothis\CALX_ffac_big\fi
    \ifnum #1>101  \xint_dothis\CALX_ffac_med\fi
                   \xint_orthat\CALX_ffac_small
    #1.%
}%
\def\CALX_ffac_toobig #1.#2#3#4#5%
   {\CALX_nsig{InvalidOperation}{factorial of an integer >= 10^8}{}}%
\def\CALX_ffac_vbig
   {\expandafter\CALX_ffac_vbigloop_a
    \the\numexpr \CALX_ffac_increaseP \xint_c_i   }%
\def\CALX_ffac_big
   {\expandafter\CALX_ffac_bigloop_a
    \the\numexpr \CALX_ffac_increaseP \xint_c_ii  }%
\def\CALX_ffac_med
   {\expandafter\CALX_ffac_medloop_a
    \the\numexpr \CALX_ffac_increaseP \xint_c_iii }%
\def\CALX_ffac_small
   {\expandafter\CALX_ffac_smallloop_a
    \the\numexpr \CALX_ffac_increaseP \xint_c_iv  }%
\def\CALX_ffac_increaseP #1#2.#3#4%
{%
    #2\expandafter.\the\numexpr\xint_c_viii*%
    ((\xint_c_iv+#4+\CALX_ndig{#2/(#1*#3)})/\xint_c_viii).%
}%
\def\CALX_ffac_out #1;![#2]#3%
   {\CALX_fnround{#3}{\expandafter\CALX_fx_c\the\numexpr#2/\xint_c_viii
    \expandafter.\romannumeral0\CALX_nnorm +#1;!\xint:}}%
\def\CALX_ffac_vbigloop_a #1.#2.%
{%
    \CALX_ffac_bigloop_a \xint_c_e_iv.#2.%
    {\expandafter\CALX_ffac_vbigloop_loop\the\numexpr 100010001\expandafter.%
     \the\numexpr \xint_c_e_viii+#1.}%
}%
\def\CALX_ffac_vbigloop_loop #1.#2.%
{%
    \ifnum #1>#2 \expandafter\CALX_ffac_loop_exit\fi
    \expandafter\CALX_ffac_vbigloop_loop
    \the\numexpr #1+\xint_c_i\expandafter.%
    \the\numexpr #2\expandafter.\the\numexpr\CALX_ffac_mul #1!%
}%
\def\CALX_ffac_bigloop_a #1.%
{%
    \expandafter\CALX_ffac_bigloop_b \the\numexpr
    #1+\xint_c_i-\xint_c_ii*((#1-464)/\xint_c_ii).#1.%
}%
\def\CALX_ffac_bigloop_b #1.#2.#3.%
{%
    \expandafter\CALX_ffac_medloop_a
        \the\numexpr #1-\xint_c_i.#3.{\CALX_ffac_bigloop_loop #1.#2.}%
}%
\def\CALX_ffac_bigloop_loop #1.#2.%
{%
    \ifnum #1>#2 \expandafter\CALX_ffac_loop_exit\fi
    \expandafter\CALX_ffac_bigloop_loop
    \the\numexpr #1+\xint_c_ii\expandafter.%
    \the\numexpr #2\expandafter.\the\numexpr\CALX_ffac_bigloop_mul #1!%
}%
\def\CALX_ffac_bigloop_mul #1!%
{%
    \expandafter\CALX_ffac_mul
        \the\numexpr \xint_c_e_viii+#1*(#1+\xint_c_i)!%
}%
\def\CALX_ffac_medloop_a #1.%
{%
    \expandafter\CALX_ffac_medloop_b
        \the\numexpr #1+\xint_c_i-\xint_c_iii*((#1-100)/\xint_c_iii).#1.%
}%
\def\CALX_ffac_medloop_b #1.#2.#3.%
{%
    \expandafter\CALX_ffac_smallloop_a
        \the\numexpr #1-\xint_c_i.#3.{\CALX_ffac_medloop_loop #1.#2.}%
}%
\def\CALX_ffac_medloop_loop #1.#2.%
{%
    \ifnum #1>#2 \expandafter\CALX_ffac_loop_exit\fi
    \expandafter\CALX_ffac_medloop_loop
    \the\numexpr #1+\xint_c_iii\expandafter.%
    \the\numexpr #2\expandafter.\the\numexpr\CALX_ffac_medloop_mul #1!%
}%
\def\CALX_ffac_medloop_mul #1!%
{%
    \expandafter\CALX_ffac_mul
    \the\numexpr
        \xint_c_e_viii+#1*(#1+\xint_c_i)*(#1+\xint_c_ii)!%
}%
\def\CALX_ffac_smallloop_a #1.%
{%
    \csname
       CALX_ffac_smallloop_\the\numexpr #1-\xint_c_iv*(#1/\xint_c_iv)\relax
    \endcsname #1.%
}%
\expandafter\def\csname CALX_ffac_smallloop_1\endcsname #1.#2.%
{%
    \CALX_ffac_addzeros #2.100000001!.{2.#1.}{#2}%
}%
\expandafter\def\csname CALX_ffac_smallloop_-2\endcsname #1.#2.%
{%
    \CALX_ffac_addzeros #2.100000002!.{3.#1.}{#2}%
}%
\expandafter\def\csname CALX_ffac_smallloop_-1\endcsname #1.#2.%
{%
    \CALX_ffac_addzeros #2.100000006!.{4.#1.}{#2}%
}%
\expandafter\def\csname CALX_ffac_smallloop_0\endcsname #1.#2.%
{%
    \CALX_ffac_addzeros #2.100000024!.{5.#1.}{#2}%
}%
\def\CALX_ffac_addzeros #1.%
{%
    \ifnum #1=\xint_c_viii \expandafter\CALX_ffac_addzeros_exit\fi
    \expandafter\CALX_ffac_addzeros
    \the\numexpr #1-\xint_c_viii.100000000!%
}%
\def\CALX_ffac_addzeros_exit #1.#2.#3#4%
   {\CALX_ffac_smallloop_loop #3#21;![-#4]}%
\def\CALX_ffac_smallloop_loop #1.#2.%
{%
    \ifnum #1>#2 \expandafter\CALX_ffac_loop_exit\fi
    \expandafter\CALX_ffac_smallloop_loop
    \the\numexpr #1+\xint_c_iv\expandafter.%
    \the\numexpr #2\expandafter.\romannumeral0\CALX_ffac_smallloop_mul #1!%
}%
\def\CALX_ffac_smallloop_mul #1!%
{%
    \expandafter\CALX_ffac_mul
    \the\numexpr
        \xint_c_e_viii+#1*(#1+\xint_c_i)*(#1+\xint_c_ii)*(#1+\xint_c_iii)!%
}%[[
\def\CALX_ffac_loop_exit #1!#2]#3{#3#2]}%
\def\CALX_ffac_mul 1#1!%
   {\expandafter\CALX_ffac_mul_a\the\numexpr\CALX_ffac_smallmul 10!{#1}}%
\def\CALX_ffac_mul_a #1-#2%
{%
    \if#21\xint_afterfi{\expandafter\space\xint_gob_til_exclam}\else
    \expandafter\space\fi #11;!%
}%
\def\CALX_ffac_minimulwc_a #1#2#3#4#5!#6#7#8#9%
{%
    \CALX_ffac_minimulwc_b {#1#2#3#4}{#5}{#6#7#8#9}%
}%
\def\CALX_ffac_minimulwc_b #1#2#3#4!#5%
{%
    \expandafter\CALX_ffac_minimulwc_c
    \the\numexpr \xint_c_e_ix+#5+#2*#4!{{#1}{#2}{#3}{#4}}%
}%
\def\CALX_ffac_minimulwc_c 1#1#2#3#4#5#6!#7%
{%
    \expandafter\CALX_ffac_minimulwc_d {#1#2#3#4#5}#7{#6}%
}%
\def\CALX_ffac_minimulwc_d #1#2#3#4#5%
{%
    \expandafter\CALX_ffac_minimulwc_e
    \the\numexpr \xint_c_e_ix+#1+#2*#5+#3*#4!{#2}{#4}%
}%
\def\CALX_ffac_minimulwc_e 1#1#2#3#4#5#6!#7#8#9%
{%
    1#6#9\expandafter!%
    \the\numexpr\expandafter\CALX_ffac_smallmul
    \the\numexpr \xint_c_e_viii+#1#2#3#4#5+#7*#8!%
}%
\def\CALX_ffac_smallmul 1#1!#21#3!%
{%
    \xint_gob_til_sc #3\CALX_ffac_smallmul_end;%
    \CALX_ffac_minimulwc_a #2!#3!{#1}{#2}%
}%
\def\CALX_ffac_smallmul_end;\CALX_ffac_minimulwc_a #1!;!#2#3[#4]%
{%
   \ifnum #2=\xint_c_
       \expandafter\xint_firstoftwo\else
       \expandafter\xint_secondoftwo
   \fi
   {-2\relax[#4]}%
   {1#2\expandafter!\expandafter-\expandafter1\expandafter
                  [\the\numexpr #4+\xint_c_viii]}%
}%
\def\CALX_fpfac #1#2#3%
{%
   \expandafter\CALX_fpfac_fork
   \the\numexpr #2\expandafter.\the\numexpr #3.\xint_c_i{#1+\xint_c_ii}{#1}%
}%
\def\CALX_fpfac_fork #1#2.#3#4.%
{%
    \unless\ifnum #1#2<#3#4 \xint_dothis\CALX_fpfac_one\fi
    \if-#3\xint_dothis\CALX_fpfac_neg \fi
    \if-#1\xint_dothis\CALX_fpfac_zero\fi
    \ifnum #3#4>\xint_c_e_viii_mone\xint_dothis\CALX_fpfac_outofrange\fi
    \xint_orthat \CALX_fpfac_increaseP #1#2.#3#4.%
}%
\def\CALX_fpfac_outofrange #1.#2.#3#4#5{\CALX_iipfac_inv #1.#2.}%
\def\CALX_fpfac_one  #1.#2.#3#4#5{ F+1.0.100000001!}%
\def\CALX_fpfac_zero #1.#2.#3#4#5{ F+0.0.}%
\def\CALX_fpfac_neg -#1.-#2.%
{%
    \ifnum #1>\xint_c_e_viii\xint_dothis\CALX_fpfac_outofrange\fi
    \xint_orthat {%
    \ifodd\numexpr#2-#1\relax
      \xint_afterfi{\expandafter\CALX_fpfac_m\romannumeral0}\fi
    \expandafter\CALX_fpfac_increaseP}%
    \the\numexpr #2-\xint_c_i\expandafter.\the\numexpr#1-\xint_c_i.%
}%
\def\CALX_fpfac_m F+{ F-}%
\def\CALX_fpfac_increaseP #1.#2.#3#4%
{%
    \expandafter\CALX_fpfac_a
    \the\numexpr \xint_c_viii*((\xint_c_iv+#4+\CALX_ndig{(#2-#1-\xint_c_i)%
      /\ifnum #2>\xint_c_e_iv #3\else(#3*\xint_c_ii)\fi})/\xint_c_viii).%
    #1.#2.%
}%
\def\CALX_fpfac_a #1.#2.#3.%
{%
    \expandafter\CALX_fpfac_b\the\numexpr \xint_c_i+#2\expandafter.%
    \the\numexpr#3\expandafter.%
    \romannumeral0\CALX_fpfac_addzeroes #1.100000001!1;![-#1]%
}%
\def\CALX_fpfac_addzeroes #1.%
{%
    \ifnum #1=\xint_c_viii \expandafter\CALX_fpfac_addzeroes_exit\fi
    \expandafter\CALX_fpfac_addzeroes\the\numexpr #1-\xint_c_viii.100000000!%
}%
\def\CALX_fpfac_addzeroes_exit #1.{ }%
\def\CALX_fpfac_b #1.%
{%
    \ifnum #1>9999 \xint_dothis\CALX_fpfac_vbigloop \fi
    \ifnum #1>463  \xint_dothis\CALX_fpfac_bigloop   \fi
    \ifnum #1>98   \xint_dothis\CALX_fpfac_medloop   \fi
                   \xint_orthat\CALX_fpfac_smallloop #1.%
}%
\def\CALX_fpfac_smallloop #1.#2.%
{%
    \ifcase\numexpr #2-#1\relax
        \expandafter\CALX_fpfac_end_
    \or \expandafter\CALX_fpfac_end_i
    \or \expandafter\CALX_fpfac_end_ii
    \or \expandafter\CALX_fpfac_end_iii
    \else\expandafter\CALX_fpfac_smallloop_a
    \fi #1.#2.%
}%
\def\CALX_fpfac_smallloop_a #1.#2.%
{%
    \expandafter\CALX_fpfac_smallloop_b
    \the\numexpr #1+\xint_c_iv\expandafter.%
    \the\numexpr #2\expandafter.%
    \romannumeral0\expandafter\CALX_ffac_mul
    \the\numexpr \xint_c_e_viii+#1*(#1+\xint_c_i)*(#1+\xint_c_ii)*%
      (#1+\xint_c_iii)!%
}%
\def\CALX_fpfac_smallloop_b #1.%
{%
    \ifnum #1>98  \expandafter\CALX_fpfac_medloop   \else
                  \expandafter\CALX_fpfac_smallloop \fi #1.%
}%
\def\CALX_fpfac_medloop #1.#2.%
{%
    \ifcase\numexpr #2-#1\relax
        \expandafter\CALX_fpfac_end_
    \or \expandafter\CALX_fpfac_end_i
    \or \expandafter\CALX_fpfac_end_ii
    \else\expandafter\CALX_fpfac_medloop_a
    \fi #1.#2.%
}%
\def\CALX_fpfac_medloop_a #1.#2.%
{%
    \expandafter\CALX_fpfac_medloop_b
    \the\numexpr #1+\xint_c_iii\expandafter.%
    \the\numexpr #2\expandafter.%
    \romannumeral0\expandafter\CALX_ffac_mul
    \the\numexpr \xint_c_e_viii+#1*(#1+\xint_c_i)*(#1+\xint_c_ii)!%
}%
\def\CALX_fpfac_medloop_b #1.%
{%
    \ifnum #1>463 \expandafter\CALX_fpfac_bigloop   \else
                  \expandafter\CALX_fpfac_medloop   \fi #1.%
}%
\def\CALX_fpfac_bigloop #1.#2.%
{%
    \ifcase\numexpr #2-#1\relax
        \expandafter\CALX_fpfac_end_
    \or \expandafter\CALX_fpfac_end_i
    \else\expandafter\CALX_fpfac_bigloop_a
    \fi #1.#2.%
}%
\def\CALX_fpfac_bigloop_a #1.#2.%
{%
    \expandafter\CALX_fpfac_bigloop_b
    \the\numexpr #1+\xint_c_ii\expandafter.%
    \the\numexpr #2\expandafter.%
    \romannumeral0\expandafter\CALX_ffac_mul
    \the\numexpr \xint_c_e_viii+#1*(#1+\xint_c_i)!%
}%
\def\CALX_fpfac_bigloop_b #1.%
{%
    \ifnum #1>9999 \expandafter\CALX_fpfac_vbigloop  \else
                   \expandafter\CALX_fpfac_bigloop   \fi #1.%
}%
\def\CALX_fpfac_vbigloop #1.#2.%
{%
    \ifnum #2=#1
         \expandafter\CALX_fpfac_end_
    \else\expandafter\CALX_fpfac_vbigloop_a
    \fi #1.#2.%
}%
\def\CALX_fpfac_vbigloop_a #1.#2.%
{%
    \expandafter\CALX_fpfac_vbigloop
    \the\numexpr #1+\xint_c_i\expandafter.%
    \the\numexpr #2\expandafter.%
    \romannumeral0\expandafter\CALX_ffac_mul
    \the\numexpr\xint_c_e_viii+#1!%
}%
\def\CALX_fpfac_end_iii #1.#2.%
{%
    \expandafter\CALX_ffac_out
    \romannumeral0\expandafter\CALX_ffac_mul
    \the\numexpr \xint_c_e_viii+#1*(#1+\xint_c_i)*(#1+\xint_c_ii)*%
      (#1+\xint_c_iii)!%
}%
\def\CALX_fpfac_end_ii #1.#2.%
{%
    \expandafter\CALX_ffac_out
    \romannumeral0\expandafter\CALX_ffac_mul
    \the\numexpr \xint_c_e_viii+#1*(#1+\xint_c_i)*(#1+\xint_c_ii)!%
}%
\def\CALX_fpfac_end_i #1.#2.%
{%
    \expandafter\CALX_ffac_out
    \romannumeral0\expandafter\CALX_ffac_mul
    \the\numexpr \xint_c_e_viii+#1*(#1+\xint_c_i)!%
}%
\def\CALX_fpfac_end_ #1.#2.%
{%
    \expandafter\CALX_ffac_out
    \romannumeral0\expandafter\CALX_ffac_mul
    \the\numexpr \xint_c_e_viii+#1!%
}%
\def\CALX_fbinom #1#2#3%
{%
    \expandafter\CALX_fbinom_a\the\numexpr#2\expandafter.%
    \the\numexpr#3\expandafter.\the\numexpr#1.%
}%
\def\CALX_fbinom_a #1.#2.%
{%
    \expandafter\CALX_fbinom_fork \the\numexpr #1-#2.#2.#1.%
}%
\def\CALX_fbinom_fork #1#2.#3#4.#5#6.%
{%
    \if-#5\xint_dothis \CALX_fbinom_inv\fi
    \if-#1\xint_dothis \CALX_fbinom_zero\fi
    \if-#3\xint_dothis \CALX_fbinom_zero\fi
    \if0#1\xint_dothis \CALX_fbinom_one\fi
    \if0#3\xint_dothis \CALX_fbinom_one\fi
    \ifnum #5#6>\xint_c_e_viii_mone \xint_dothis\CALX_fbinom_inv\fi
    \ifnum #1#2>#3#4  \xint_dothis\CALX_fbinom_ab \fi
                      \xint_orthat\CALX_fbinom_aa
    #1#2.#3#4.#5#6.%
}%
\def\CALX_fbinom_inv #1.#2.#3.#4.{\CALX_iibinom_inv}%
\def\CALX_fbinom_one  #1.#2.#3.#4.{ F+1.0.100000001!}%
\def\CALX_fbinom_zero #1.#2.#3.#4.{ F+0.0.}%
\def\CALX_fbinom_ab #1.#2.{\CALX_fbinom_aa #2.#1.}%
\def\CALX_fbinom_aa #1.#2.#3.#4.%
{%
    \expandafter\CALX_fbinom_q\romannumeral0\CALX_fpfac_increaseP
    #2.#3.\xint_c_iv{#4+\xint_c_iv}{#4+\xint_c_v}\xint:#1.{#4}%
}%
\def\CALX_fbinom_q #1\xint:#2.#3%
{%
    \expandafter\CALX_fbinom_r\romannumeral0\CALX_ffac_fork_b
    #2.\xint_c_iv{#3+\xint_c_iv}\CALX_ffac_out{#3+\xint_c_v}%
    \xint:#1\xint:{#3}%
}%
\def\CALX_fbinom_r #1\xint:#2\xint:{\CALX_fr_xk #2\xint:#1\xint:}%
%    \end{macrocode}
% \subsection{Fixed-point multiply-subtract}
%\begin{lverb}
% \CALX_xf<s><n> (s = 1..9, n = s or s+1 <= 9, written as letters;
% generated by tools/xfix_gen.py), used by the sin/cos series of
% calxtrig.sty, one call per level:
%(
%:  \CALX_xf<s><n>{u1}..{u4}{t1}..{ts}<U5..><cp><text><N>{w1}..{w4}
%:     gives <N>{w1}..{w4}{r1}..{rn}
%)
% Limbs of four digits, most significant first. T is the integer sum of
% the tj 10^(4(s-j)), U the fraction sum of the ui 10^(-4i), given as
% q = 4 ceil(s/4) limbs: <U5..> are u5 to uq, flat. C has n limbs ci:
% with ec = max(s-6, 0), <cp> is {cn}{c(n-1)}... for the columns
% e = 0..ec-1, <text> is +c(n-ec);+c(n-ec-1);...;+c1; with {} after the
% `;` of column 0 when ec = 0. <N> is one token, {w1}..{w4} one braced
% chunk put back in front of the result (the first limbs of U for the
% next level). R is C minus U T truncated, modulo 10^(4n): column e
% (weight 10^(4e)), e = n-1 down to -2, is
%(
%:  2100000000 + c(n-e) - (sum of ui tj, i + j = s - e) + carry,
%)
% with c(n-e) only for e >= 0, i, j <= s, and also u(s+1) t1 in column -2
% when s mod 4 > 0 (the terms of the former \CALX_m<s>_<n> of calxtrig:
% same results). The value has ten digits (s <= 11 products, see
% calxtrig); its first six minus 210000 are the carry, floor, into the
% next column; its last four are the limb, dropped for e < 0 and for the
% carry out of the top column.
%
% Layout, after l3fp's \__fp_fixed_mul:wwn: one nested \numexpr chain,
% innermost column evaluated first, written in two passes. Down pass:
% every column is opened from the top with its products u1..u4 times a
% sliding window of T. Up pass: the rest of column -2 (products with
% i >= 5), then `;`, the rest of column -1, `;`, and so on up to column
% ec, whose c and the following ones come from <text>. A column is thus
% continued after its inner columns: its pack \CALX_xq or \CALX_xp
% takes the next `;`-delimited text into the enclosing \numexpr and puts
% the limb behind it; \CALX_xp collects the limbs in one braced group
% (empty group after the `;` of column 0), \CALX_xe and \CALX_xg output
% <N>, the chunk that follows it, the top limb, the group's contents.
% Successive macros (suffixes x, y, z, w, v, u, r) take at most nine
% arguments: limbs passed on, the low limbs of T needed by the up pass
% in one braced group, the next items of the stream.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_xe #1#2#3#4#5#6#7;#8{\CALX_xg{{#7}#8}}%
\def\CALX_xg #1#2#3{#2#3#1}%
\def\CALX_xp #1#2#3#4#5#6#7;#8#9;{+#1#2#3#4#5#6-210000#9;{{#7}#8}}%
\def\CALX_xq #1#2#3#4#5#6#7;#8;{+#1#2#3#4#5#6-210000#8;}%
% generated by tools/xfix_gen.py
\def\CALX_xfab #1#2#3#4#5%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000%
\expandafter\CALX_xq\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xq\the\numexpr2100000000-#2*#5;;%
}%
\def\CALX_xfbb #1#2#3#4#5#6%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xq\the\numexpr2100000000-#2*#5-#1*#6%
\expandafter\CALX_xq\the\numexpr2100000000-#3*#5-#2*#6;;%
}%
\def\CALX_xfbc #1#2#3#4#5#6%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xq\the\numexpr2100000000-#2*#5-#1*#6%
\expandafter\CALX_xq\the\numexpr2100000000-#3*#5-#2*#6;;%
}%
\def\CALX_xfcc #1#2#3#4#5#6#7%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xp\the\numexpr2100000000-#2*#5-#1*#6%
\expandafter\CALX_xq\the\numexpr2100000000-#3*#5-#2*#6-#1*#7%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#5-#3*#6-#2*#7;;%
}%
\def\CALX_xfcd #1#2#3#4#5#6#7%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xp\the\numexpr2100000000-#2*#5-#1*#6%
\expandafter\CALX_xq\the\numexpr2100000000-#3*#5-#2*#6-#1*#7%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#5-#3*#6-#2*#7;;%
}%
\def\CALX_xfdd #1#2#3#4#5#6#7#8%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xp\the\numexpr2100000000-#2*#5-#1*#6%
\expandafter\CALX_xp\the\numexpr2100000000-#3*#5-#2*#6-#1*#7%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#5-#3*#6-#2*#7-#1*#8%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#6-#3*#7-#2*#8;;%
}%
\def\CALX_xfde #1#2#3#4#5#6#7#8%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xp\the\numexpr2100000000-#2*#5-#1*#6%
\expandafter\CALX_xp\the\numexpr2100000000-#3*#5-#2*#6-#1*#7%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#5-#3*#6-#2*#7-#1*#8%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#6-#3*#7-#2*#8;;%
}%
\def\CALX_xfee #1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xp\the\numexpr2100000000-#2*#5-#1*#6%
\expandafter\CALX_xp\the\numexpr2100000000-#3*#5-#2*#6-#1*#7%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#5-#3*#6-#2*#7-#1*#8%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#6-#3*#7-#2*#8-#1*#9%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#7-#3*#8-#2*#9%
\CALX_xfeex{#5}{#6}%
}%
\def\CALX_xfeex #1#2#3#4#5#6%
{%
-#3*#2-#4*#1;-#3*#1;%
}%
\def\CALX_xfef #1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xp\the\numexpr2100000000-#2*#5-#1*#6%
\expandafter\CALX_xp\the\numexpr2100000000-#3*#5-#2*#6-#1*#7%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#5-#3*#6-#2*#7-#1*#8%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#6-#3*#7-#2*#8-#1*#9%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#7-#3*#8-#2*#9%
\CALX_xfefx{#5}{#6}%
}%
\def\CALX_xfefx #1#2#3#4#5#6%
{%
-#3*#2-#4*#1;-#3*#1;%
}%
\def\CALX_xfff #1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xp\the\numexpr2100000000-#2*#5-#1*#6%
\expandafter\CALX_xp\the\numexpr2100000000-#3*#5-#2*#6-#1*#7%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#5-#3*#6-#2*#7-#1*#8%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#6-#3*#7-#2*#8-#1*#9%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#7-#3*#8-#2*#9%
\CALX_xfffx{#1}{#2}{#3}{#4}{#8}{#9}{{#5}{#6}{#7}}%
}%
\def\CALX_xfffx #1#2#3#4#5#6#7#8%
{%
-#1*#8%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#5-#3*#6-#2*#8%
\CALX_xfffy#7%
}%
\def\CALX_xfffy #1#2#3#4#5#6#7%
{%
-#4*#3-#5*#2-#6*#1;-#4*#2-#5*#1;-#4*#1%
}%
\def\CALX_xffg #1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xp\the\numexpr2100000000-#2*#5-#1*#6%
\expandafter\CALX_xp\the\numexpr2100000000-#3*#5-#2*#6-#1*#7%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#5-#3*#6-#2*#7-#1*#8%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#6-#3*#7-#2*#8-#1*#9%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#7-#3*#8-#2*#9%
\CALX_xffgx{#1}{#2}{#3}{#4}{#8}{#9}{{#5}{#6}{#7}}%
}%
\def\CALX_xffgx #1#2#3#4#5#6#7#8%
{%
-#1*#8%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#5-#3*#6-#2*#8%
\CALX_xffgy#7%
}%
\def\CALX_xffgy #1#2#3#4#5#6#7%
{%
-#4*#3-#5*#2-#6*#1;-#4*#2-#5*#1;-#4*#1%
}%
\def\CALX_xfgg #1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xp\the\numexpr2100000000-#2*#5-#1*#6%
\expandafter\CALX_xp\the\numexpr2100000000-#3*#5-#2*#6-#1*#7%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#5-#3*#6-#2*#7-#1*#8%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#6-#3*#7-#2*#8-#1*#9%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#7-#3*#8-#2*#9%
\CALX_xfggx{#1}{#2}{#3}{#4}{#8}{#9}{{#5}{#6}{#7}}%
}%
\def\CALX_xfggx #1#2#3#4#5#6#7#8#9%
{%
-#1*#8%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#5-#3*#6-#2*#8-#1*#9%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#6-#3*#8-#2*#9%
\CALX_xfggy{#5}#7%
}%
\def\CALX_xfggy #1#2#3#4#5#6#7#8#9%
{%
-#5*#1-#6*#4-#7*#3-#8*#2;-#5*#4-#6*#3-#7*#2;-#5*#3-#6*#2+#9;{}-#5*#2%
}%
\def\CALX_xfgh #1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xp\the\numexpr2100000000-#2*#5-#1*#6%
\expandafter\CALX_xp\the\numexpr2100000000-#3*#5-#2*#6-#1*#7%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#5-#3*#6-#2*#7-#1*#8%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#6-#3*#7-#2*#8-#1*#9%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#7-#3*#8-#2*#9%
\CALX_xfghx{#1}{#2}{#3}{#4}{#8}{#9}{{#5}{#6}{#7}}%
}%
\def\CALX_xfghx #1#2#3#4#5#6#7#8#9%
{%
-#1*#8%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#5-#3*#6-#2*#8-#1*#9%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#6-#3*#8-#2*#9%
\CALX_xfghy{#5}#7%
}%
\def\CALX_xfghy #1#2#3#4#5#6#7#8#9%
{%
-#5*#1-#6*#4-#7*#3-#8*#2;-#5*#4-#6*#3-#7*#2;-#5*#3-#6*#2+#9;{}-#5*#2%
}%
\def\CALX_xfhh #1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xp\the\numexpr2100000000-#2*#5-#1*#6%
\expandafter\CALX_xp\the\numexpr2100000000-#3*#5-#2*#6-#1*#7%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#5-#3*#6-#2*#7-#1*#8%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#6-#3*#7-#2*#8-#1*#9%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#7-#3*#8-#2*#9%
\CALX_xfhhx{#1}{#2}{#3}{#4}{#8}{#9}{{#5}{#6}{#7}}%
}%
\def\CALX_xfhhx #1#2#3#4#5#6#7#8#9%
{%
-#1*#8%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#5-#3*#6-#2*#8-#1*#9%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#6-#3*#8-#2*#9%
\CALX_xfhhy{#1}{#2}{#3}{#4}{#8}{#9}{{#5}{#6}#7}%
}%
\def\CALX_xfhhy #1#2#3#4#5#6#7#8%
{%
-#1*#8%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#5-#3*#6-#2*#8%
\CALX_xfhhz#7%
}%
\def\CALX_xfhhz #1#2#3#4#5#6#7#8#9%
{%
-#6*#2-#7*#1-#8*#5-#9*#4;-#6*#1-#7*#5-#8*#4-#9*#3;-#6*#5-#7*#4-#8*#3%
\CALX_xfhhw{#3}{#4}{#6}{#7}%
}%
\def\CALX_xfhhw #1#2#3#4#5#6%
{%
+#5;{}-#3*#2-#4*#1+#6;-#3*#1%
}%
\def\CALX_xfhi #1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xp\the\numexpr2100000000-#2*#5-#1*#6%
\expandafter\CALX_xp\the\numexpr2100000000-#3*#5-#2*#6-#1*#7%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#5-#3*#6-#2*#7-#1*#8%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#6-#3*#7-#2*#8-#1*#9%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#7-#3*#8-#2*#9%
\CALX_xfhix{#1}{#2}{#3}{#4}{#8}{#9}{{#5}{#6}{#7}}%
}%
\def\CALX_xfhix #1#2#3#4#5#6#7#8#9%
{%
-#1*#8%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#5-#3*#6-#2*#8-#1*#9%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#6-#3*#8-#2*#9%
\CALX_xfhiy{#1}{#2}{#3}{#4}{#8}{#9}{{#5}{#6}#7}%
}%
\def\CALX_xfhiy #1#2#3#4#5#6#7#8%
{%
-#1*#8%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#5-#3*#6-#2*#8%
\CALX_xfhiz#7%
}%
\def\CALX_xfhiz #1#2#3#4#5#6#7#8#9%
{%
-#6*#2-#7*#1-#8*#5-#9*#4;-#6*#1-#7*#5-#8*#4-#9*#3;-#6*#5-#7*#4-#8*#3%
\CALX_xfhiw{#3}{#4}{#6}{#7}%
}%
\def\CALX_xfhiw #1#2#3#4#5#6%
{%
+#5;{}-#3*#2-#4*#1+#6;-#3*#1%
}%
\def\CALX_xfii #1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_xe\the\numexpr2100000000%
\expandafter\CALX_xp\the\numexpr2100000000-#1*#5%
\expandafter\CALX_xp\the\numexpr2100000000-#2*#5-#1*#6%
\expandafter\CALX_xp\the\numexpr2100000000-#3*#5-#2*#6-#1*#7%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#5-#3*#6-#2*#7-#1*#8%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#6-#3*#7-#2*#8-#1*#9%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#7-#3*#8-#2*#9%
\CALX_xfiix{#1}{#2}{#3}{#4}{#8}{#9}{{#5}{#6}{#7}}%
}%
\def\CALX_xfiix #1#2#3#4#5#6#7#8#9%
{%
-#1*#8%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#5-#3*#6-#2*#8-#1*#9%
\expandafter\CALX_xp\the\numexpr2100000000-#4*#6-#3*#8-#2*#9%
\CALX_xfiiy{#1}{#2}{#3}{#4}{#8}{#9}{{#5}{#6}#7}%
}%
\def\CALX_xfiiy #1#2#3#4#5#6#7#8#9%
{%
-#1*#8%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#5-#3*#6-#2*#8-#1*#9%
\expandafter\CALX_xq\the\numexpr2100000000-#4*#6-#3*#8-#2*#9%
\CALX_xfiiz{#5}{#7}%
}%
\def\CALX_xfiiz #1#2#3#4#5#6%
{%
-#3*#1%
\CALX_xfiiw{#4}{#5}{#6}#2{{#3}}%
}%
\def\CALX_xfiiw #1#2#3#4#5#6#7#8#9%
{%
-#1*#5-#2*#4-#3*#8%
\CALX_xfiiv{#5}{#6}{#7}#9{{#1}{#2}{#3}{#4}{#8}}%
}%
\def\CALX_xfiiv #1#2#3#4#5#6#7#8#9%
{%
-#6*#3-#7*#2;-#4*#1%
\CALX_xfiiu{#2}{#3}{#4}{#6}#5%
}%
\def\CALX_xfiiu #1#2#3#4#5#6#7#8#9%
{%
-#5*#8-#6*#9-#7*#2-#4*#1;-#3*#8-#5*#9-#6*#2-#7*#1%
\CALX_xfiir{#1}{#2}{#3}{#5}{#6}{#9}%
}%
\def\CALX_xfiir #1#2#3#4#5#6#7#8#9%
{%
+#7;{}-#3*#6-#4*#2-#5*#1+#8;-#3*#2-#4*#1+#9;-#3*#1%
}%
\catcode`F=11 \catcode`N=11 \catcode`I=11
%    \end{macrocode}
% \subsection{\csh{calxFpFloat}, \csh{calxFpFloatdigits},
%   \csh{calxFpRoundTo}, \csh{calxFpTruncTo}}
%\begin{lverb}
% Syntax (f-expandable; P, n \numexpr expressions, X an F, I or xint raw
% value, f-expanded; \calxFpRoundTo and \calxFpTruncTo accept M values
% too):
%(
%  \calxFpFloat[P]{X}      -> Y
%:  \calxFpFloatdigits{X}   -> Y    (P = \XINTdigits)
%:  \calxFpRoundTo{n}{X}    -> Y    the multiple of 10^-n nearest to X
%:  \calxFpTruncTo{n}{X}    -> Y    the multiple of 10^-n between 0 and X
%)
% \calxFpFloat, \calxFpFloatdigits: X rounded to P significant digits by
% \CALX_fround (F or I value). They implement float(), float_dgt(),
% sfloat() of \xintfloateval. \calxFpRoundTo, \calxFpTruncTo: exact F
% value (ties away from zero), I unchanged, by \CALX_rt_a; they implement
% round(x, n) and trunc(x, n). The \xint: after Y is removed by \CALX_fbr.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fbr #1\xint:{ #1}%
\def\calxFpFloatdigits
   {\romannumeral0\expandafter\CALX_fbr\romannumeral0\CALX_fround\XINTdigits}%
\def\calxFpFloat [#1]%
   {\romannumeral0\expandafter\CALX_fbr\romannumeral0\CALX_fround{#1}}%
\def\calxFpRoundTo #1#2%
   {\romannumeral0\expandafter\CALX_fbr\romannumeral0\expandafter
    \CALX_rt_a\expandafter\CALX_fr_b\the\numexpr#1\expandafter.%
    \romannumeral`&&@#2\xint:}%
\def\calxFpTruncTo #1#2%
   {\romannumeral0\expandafter\CALX_fbr\romannumeral0\expandafter
    \CALX_rt_a\expandafter\CALX_rt_t\the\numexpr#1\expandafter.%
    \romannumeral`&&@#2\xint:}%
%    \end{macrocode}
% \subsection{\csh{calxFpFac}, \csh{calxFpFacdigits}, \csh{calxFpPFactorial},
%   \csh{calxFpBinomial}}
%\begin{lverb}
% Syntax (f-expandable; X, A, B parser values, f-expanded; P a \numexpr
% expression):
%(
%  \calxFpFacdigits{X}       -> Y   X!     (P = \XINTdigits)
%:  \calxFpFac[P]{X}          -> Y   X!
%:  \calxFpPFactorial{A}{B}   -> Y   (A+1)(A+2)...B
%:  \calxFpBinomial{X}{A}     -> Y   binomial(X, A)
%)
% factorial(), !, pfactorial() and binomial() of \xintfloateval. The
% arguments are truncated to integers by \CALX_fnum (an I value signals
% InvalidOperation and counts as 0); Y: native F rounded to P digits, or
% I? (\CALX_ffac, \CALX_fpfac, \CALX_fbinom).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fpint #1%
   {\romannumeral0\expandafter\CALX_fnum\romannumeral`&&@#1\xint:}%
\def\calxFpFacdigits #1{\romannumeral0\CALX_ffac\XINTdigits{\CALX_fpint{#1}}}%
\def\calxFpFac [#1]#2{\romannumeral0\CALX_ffac{#1}{\CALX_fpint{#2}}}%
\def\calxFpPFactorial #1#2%
   {\romannumeral0\CALX_fpfac\XINTdigits{\CALX_fpint{#1}}{\CALX_fpint{#2}}}%
\def\calxFpBinomial #1#2%
   {\romannumeral0\CALX_fbinom\XINTdigits{\CALX_fpint{#1}}{\CALX_fpint{#2}}}%
%    \end{macrocode}
% \subsection{(WIP) \csh{XINTinRandomFloatS}, \csh{XINTinRandomFloatSdigits}}
% \added{1.3b}
%\begin{lverb}
% Support for random() function.
%
% Thus as it is a priori only for xintexpr usage, it expands inside \csname
% context, but as we need to get rid of initial zeros we use \xintRandomDigits
% not \xintXRandomDigits (\expanded would have a use case here).
%
% And anyway as we want to be able to use random() in
% \xintdeffunc/\xintNewExpr, it is good to have f-expandable macros, so we add
% the small overhead to make it f-expandable.
%
% We don't have to be very efficient in removing leading zeroes, as there is
% only 10$%
% chance for each successive one. Besides we use (current) internal storage
% format of the type A[N], where A is not required to be with \xintDigits
% digits, so N will simply be -\xintDigits and needs no adjustment.
%
% In case we use in future with #1 something else than \xintDigits we do
% the 0-(#1) construct.
%
% I had some qualms about doing a random float like this which means that
% when there are leading zeros in the random digits the (virtual) mantissa
% ends up with trailing zeros. That did not feel right but I checked random()
% in Python (which of course uses radix 2), and indeed this is what happens
% there.
%\end{lverb}
%    \begin{macrocode}
\def\XINTinRandomFloatS{\romannumeral0\XINTinrandomfloatS}%
\def\XINTinRandomFloatSdigits{\XINTinRandomFloatS[\XINTdigits]}%
\def\XINTinrandomfloatS[#1]%
{%
    \expandafter\XINT_inrandomfloatS\the\numexpr\xint_c_-(#1)\xint:
}%
\def\XINT_inrandomfloatS-#1\xint:
{%
    \expandafter\XINT_inrandomfloatS_a
    \romannumeral0\xintrandomdigits{#1}[-#1]%
}%
%    \end{macrocode}
%\begin{lverb}
% We add one macro to handle a tiny bit faster 90$%
% of cases, after all
% we also use one extra macro for the completely improbable all 0 case.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_inrandomfloatS_a#1%
{%
    \if#10\xint_dothis{\XINT_inrandomfloatS_b}\fi
    \xint_orthat{ #1}%
}%[
\def\XINT_inrandomfloatS_b#1%
{%
    \if#1[\xint_dothis{\XINT_inrandomfloatS_zero}\fi% ]
    \if#10\xint_dothis{\XINT_inrandomfloatS_b}\fi
    \xint_orthat{ #1}%
}%[
\def\XINT_inrandomfloatS_zero#1]{ 0[0]}%
%    \end{macrocode}
% \subsection{(WIP) \csh{XINTinRandomFloatSixteen}}
% \added{1.3b}
%\begin{lverb}
% Support for qrand() function.
%\end{lverb}
%    \begin{macrocode}
\def\XINTinRandomFloatSixteen%
{%
    \romannumeral0\expandafter\XINT_inrandomfloatS_a
    \romannumeral`&&@\expandafter\XINT_eightrandomdigits
                \romannumeral`&&@\XINT_eightrandomdigits[-16]%
}%
%    \end{macrocode}
%\begin{lverb}
% calx: random() and qrand() of \xintfloateval push native F values,
% the raw A[N] of the two macros above converted once by \CALX_ffromraw.
%\end{lverb}
%    \begin{macrocode}
\def\calxFpRandomSdigits
   {\romannumeral0\CALX_ffromraw{\XINTinRandomFloatSdigits}}%
\def\calxFpRandomSixteen
   {\romannumeral0\CALX_ffromraw{\XINTinRandomFloatSixteen}}%
%    \end{macrocode}
% \subsection{\csh{XINT_pfloat_fork} and the \cshnolabel{xintPFloat} hooks}
% \label{\xintimplabelprefix xintPFloatE}
% \label{\xintimplabelprefix xintPFloatNoSciEmax}
% \label{\xintimplabelprefix xintPFloatNoSciEmin}
% \label{\xintimplabelprefix xintPFloatIntSuffix}
% \label{\xintimplabelprefix xintPFloatLengthOneSuffix}
% \label{\xintimplabelprefix xintPFloatZero}
% \label{\xintimplabelprefix xintPFloatMinTrimmed}
%\begin{lverb}
% Moved verbatim from xintfrac.sty at 2.0a1: the formatting core of
% \xintPFloat, used by the \xintfloateval printer (calx.sty's \CALX_fpr_a,
% fed by \CALX_frez) and by xintfrac's \xintPFloat (fed by \xintrez).
%\end{lverb}
%    \begin{macrocode}
\def\xintPFloatE{e}%
\def\xintPFloatNoSciEmax{\xint_c_v}%   1e6  uses sci.not.
\def\xintPFloatNoSciEmin{-\xint_c_iv}% 1e-5 uses sci.not.
\def\xintPFloatIntSuffix{}%
\def\xintPFloatLengthOneSuffix{}%
\def\xintPFloatZero{0}%
\def\xintPFloatMinTrimmed{\xint_c_iv}%
\def\XINT_pfloat_fork#1%
{%
    \xint_UDzerominusfork
       #1-\XINT_pfloat_zero
       0#1\XINT_pfloat_neg
        0-\XINT_pfloat_pos
    \krof #1%
}%
\def\XINT_pfloat_zero#1]#2.{\expanded{ \xintPFloatZero}}%
\def\XINT_pfloat_neg-{\expandafter-\romannumeral0\XINT_pfloat_pos}%
\def\XINT_pfloat_pos#1/1[#2]#3.%
{%
    \expandafter\XINT_pfloat_aa\the\numexpr\xintLength{#1}.%
    #3.#2.#1.%
}%
%    \end{macrocode}
%\begin{lverb}
%( #1 est la longueur de la mantisse trimmée
%: #2 est Digits ou P
%: Si #2-#1 < MinTrimmed, on se prépare à peut-être remettre les trailing zeros
%)
%
% On teste pour #2=#1, car c'est le cas le plus fréquent (mais est-ce
% une bonne idée) car on sait qu'alors il n'y a pas de trailing zéros
% donc on va direct vers \XINT_pfloat_a.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_pfloat_aa #1.#2.%
{%
    \unless\ifnum\xintPFloatMinTrimmed>\numexpr#2-#1\relax
           \xint_dothis\XINT_pfloat_a\fi
    \ifnum#2>#1 \xint_dothis{\XINT_pfloat_i #2.}\fi
    \xint_orthat\XINT_pfloat_a #1.%
}%
%    \end{macrocode}
%\begin{lverb}
% Needed for \xintFracToSci, which uses old pre 1.4k interface,
% where the P parameter was not stored for counting how many zeros
% were trimmed. \xintFracToSci trims always.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_pfloat_a_fork#1%
{%
    \xint_UDzerominusfork
       #1-\XINT_pfloat_a_zero
       0#1\XINT_pfloat_a_neg
        0-\XINT_pfloat_a_pos
    \krof #1%
}%
\def\XINT_pfloat_a_zero#1]{\expanded{ \xintPFloatZero}}%
\def\XINT_pfloat_a_neg-{\expandafter-\romannumeral0\XINT_pfloat_a_pos}%
\def\XINT_pfloat_a_pos#1/1[#2]%
{%
    \expandafter\XINT_pfloat_a\the\numexpr\xintLength{#1}.#2.#1.%
}%
%    \end{macrocode}
%\begin{lverb}
%( #1 est P > #2 mais peut être encore sous la forme \XINTdigits
%: #2 est la longueur de la mantisse trimmée
%: #3 est l'exposant non normalisé
%: #4 est la mantisse
%)
% On reconstitue les trailing zéros à remettre éventuellement.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_pfloat_i #1.#2.%#3.#4.%
{%
    \expandafter\XINT_pfloat_j\romannumeral\xintreplicate{#1-#2}0.#2.%
}%
%    \end{macrocode}
%\begin{lverb}
%( #1 est les trailing zeros à remettre peut-être
%: #2 est la longueur de la mantisse trimmée
%: #3#4 est l'exposant N pour mantisse trimmée entière
%: #5 serait la mantisse trimmée
%)
% On calcule l'exposant scientifique.
%
% La façon bizarre de mettre #3 est liée aux versions anciennes
% de la macro, héritage conservé pour minimiser effort d'adaptation.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_pfloat_j #1.#2.#3#4.%#5.
{%
    \expandafter\XINT_pfloat_b\the\numexpr#2+#3#4-\xint_c_i.%
    #3#2.#1.%
}%
%    \end{macrocode}
%\begin{lverb}
%( #1 est la longueur de la mantisse trimmée
%: #2#3 est l'exposant N pour mantisse trimmée
%: #4 serait la mantisse
%)
% On calcule l'exposant scientifique. On est arrivé ici dans
% une branche où on n'a pas besoin de remettre les zéros trimmés
% donc on positionne un dernier argument vide pour \XINT_pfloat_b
%\end{lverb}
%    \begin{macrocode}
\def\XINT_pfloat_a #1.#2#3.%#4.
{%
    \expandafter\XINT_pfloat_b\the\numexpr#1+#2#3-\xint_c_i.%
    #2#1..%
}%
%    \end{macrocode}
%\begin{lverb}
%( #1 est l'exposant scientifique K
%: #2 est le signe ou premier chiffre de l'exposant N pour mantisse trimmée
%: #3 serait la longueur de la mantisse trimmée
%: #4 serait les trailing zéros
%: #5 serait la mantisse trimmée
%)
% On va vers \XINT_float_P lorsque l'on n'utilise pas la notation
% scientifique, mais qu'on a besoin de chiffres non nuls fractionnaires,
% et vers \XINT_float_Ps si on n'en a pas besoin.
%
% On va vers \XINT_pfloat_N lorsque l'on n'utilise pas la notation
% scientifique et que l'exposant scientifique était strictement négatif.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_pfloat_b #1.#2%#3.#4.#5.
{%
    \ifnum \xintPFloatNoSciEmax<#1 \xint_dothis\XINT_pfloat_sci\fi
    \ifnum \xintPFloatNoSciEmin>#1 \xint_dothis\XINT_pfloat_sci\fi
    \ifnum #1<\xint_c_   \xint_dothis\XINT_pfloat_N\fi
    \if-#2\xint_dothis\XINT_pfloat_P\fi
    \xint_orthat\XINT_pfloat_Ps
    #1.%
}%
%    \end{macrocode}
%\begin{lverb}
% #1 is the scientific exponent, #2 is the length of the trimmed mantissa,
% #3 are the trailing zeros, #4 is the trimmed integer mantissa
%
% \xintPFloatE can be replaced by any f-expandable macro with a dot-delimited
% argument which produces a dot-delimited output.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_pfloat_sci #1.#2.%
{%
    \ifnum#2=\xint_c_i\expandafter\XINT_pfloat_sci_i\expandafter\fi
    \expandafter\XINT_pfloat_sci_a\romannumeral`&&@\xintPFloatE #1.%
}%
\def\XINT_pfloat_sci_a #1.#2.#3#4.{ #3.#4#2#1}%
%    \end{macrocode}
%\begin{lverb}
% #1#2=\fi\XINT_pfloat_sci_a
%
% 1-digit mantissa, hesitation between d.0eK or deK
% Finally at 1.4k, \xintPFloatLengthOneSuffix for customization.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_pfloat_sci_i #1#2#3.#4.#5.{\expanded{#1 #5\xintPFloatLengthOneSuffix}#3}%
%    \end{macrocode}
%\begin{lverb}
% #1=sci.exp. K, #2=mant. wd L, #3=trailing zéros, #4=trimmed mantissa
% 
% For _N, #1 is at most -1, for _P, #1 is at least 0. For _P there
% will be fractional digits, and #1+1 digits before the mark.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_pfloat_N#1.#2.#3.#4.%
{%
    \expandafter\XINT_pfloat_N_e\romannumeral\xintreplicate{-#1}{0}#4#3%
}%
\def\XINT_pfloat_N_e 0{ 0.}%
%    \end{macrocode}
%\begin{lverb}
% #1=sci.exp. K, #2=mant. wd L, #3=trailing zéros, #4=trimmed mantissa
%
% Abusive usage of internal \XINT_split_fromleft_a.
% It means using x = -1 - #1 in \xintDecSplit from xint.sty.
% We benefit also with the way \xintDecSplit is built upon
% \XINT_split_fromleft with a final clean-up which here
% we can shortcut via using terminator "\xint_bye." not "\xint_bye.."
%\end{lverb}
%    \begin{macrocode}
\def\XINT_pfloat_P #1.#2.#3.#4.%
{%
    \expandafter\XINT_split_fromleft_a
    \the\numexpr\xint_c_vii-#1.#4\xint_bye2345678\xint_bye.#3%
}%
%    \end{macrocode}
%\begin{lverb}
% Here we have an integer so we only need to postfix the trimmed mantissa #4
% with #1+1-#2 zeros (#1=sci exp., #2=trimmed mantissa width).  Less cumbersome
% to do that with \expanded.  And the trailing zeros #3 ignored here.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_pfloat_Ps #1.#2.#3.#4.%
{%
    \expanded{ #4%
    \romannumeral\xintreplicate{#1+\xint_c_i-#2}{0}\xintPFloatIntSuffix}%
}%
%    \end{macrocode}
%\begin{lverb}
% calx: \CALX_frez F<s><D>.<e>.<blocks>\xint: (use with \romannumeral0; the
% tag token is a parameter): <space><s>A/1[N] with A without trailing zeros
% (the form \xintrez gives), 0/1[0] for zero (first digit of D zero). Zero
% low blocks are dropped (\CALX_frez_b, e + 1 each); the t trailing zeros of
% the lowest nonzero block b (\CALX_frez_t, t <= 7) are removed: one block,
% A = b/10^t; else A = the digits of the higher blocks (\CALX_ntoraw_b)
% followed by the 8 - t leading digits of b; N = 8e + t.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_frez #1#2#3#4.#5.%
   {\xint_gob_til_zero #3\CALX_frez_z 0\CALX_frez_a #2#5.}%
\def\CALX_frez_z 0\CALX_frez_a #1\xint:{ 0/1[0]}%
\def\CALX_frez_a #1#2.1#3!%
   {\xint_gob_til_eightzeroes #3\CALX_frez_b 00000000\CALX_frez_c #1#2.#3.}%
\def\CALX_frez_b 00000000\CALX_frez_c #1#2.#3.%
   {\expandafter\CALX_frez_a\expandafter#1\the\numexpr#2+\xint_c_i.}%
\def\CALX_frez_c #1#2.#3.%
   {\expandafter\CALX_frez_d\the\numexpr\CALX_frez_t#3.#1#2.#3.}%
\def\CALX_frez_t #1#2#3#4#5#6#7#8%
   {\if0#8\if0#7\if0#6\if0#5\if0#4\if0#3\if0#2 7\else6\fi\else5\fi\else4\fi
    \else3\fi\else2\fi\else1\fi\else0\fi}%
\def\CALX_frez_p #1%
   {\ifcase#1 1\or10\or100\or1000\or10000\or100000\or1000000\or10000000\fi}%
\def\CALX_frez_d #1.#2#3.#4.#5\xint:%
{%
    \expanded{ \if-#2-\fi
      \if\relax\detokenize{#5}\relax
        \the\numexpr#4/\CALX_frez_p#1\relax
      \else
        \romannumeral0\CALX_ntoraw_b #5\xint:%
        \expandafter\xint_gobble_i\the\numexpr1#4/\CALX_frez_p#1\relax
      \fi
      /1[\the\numexpr\xint_c_viii*#3+#1\relax]}%
}%
\XINTrestorecatcodesendinput%
%    \end{macrocode}
% \StoreCodelineNo {calxfp}
% \cleardoublepage\let\calxfpnameUp\undefined
%\gardesactifs
%\let</calxfp>\relax
%\let<*calx>\gardesinactifs
%</calxfp>^^A-------------------------------------------------------
%<*calx>^^A-------------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname calxnameUp\endcsname
% \let\MakePrivateLetters\xintexprMakePrivateLetters
% \section{Package \calxnameimp implementation}
% \RaisedLabel{sec:calximp}
% \etocarticlestylenomarks
% \etocstandardlines
% \etocsettocdepth {paragraph}
%
% \localtableofcontents
%
% \subsection{Introduction}
%
% This is release \expandafter|\calxbndlversion| of
% \expandafter|\calxbndldate|. THIS FILE IS AN EVOLUTION OF
% A PART OF FORMER \xintexprnameimp|.sty|. The latter now loads
% this file as a dependency.
%
% \etocsettocstyle{}{}
%
% \subsection{READ ME! Important warnings and explanations relative to the
% status of the code source at the time of the 1.4 release}
% \def\mybeginitemize{\begin{itemize}\catcode`\% 9 }^^A
% \def\myenditemize{\end{itemize}}^^A
%\begin{lverb}
% At release 1.4 the csname encapsulation of intermediate evaluations during
% parsing of expressions is dropped, and $xintexprnameimp requires the
% \expanded primitive. This means that there is no more impact on the string
% pool. And as internal storage now uses simply core \TeX{} syntax with braces
% rather than comma separated items inside a csname dummy control sequence,
% it became much easier to let the [...] syntax be associated to a true internal type of «tuple»
% or «list».
%
% The output of \xintexpr (after \romannumeral0 or \romannumeral-`0 triggered
% expansion or double expansion) is thus modified at 1.4. It now looks like
% this:&
% $oneargcs$footnote{The \XINTfstop was a simple$noexpand
% \def\XINTfstop$string{\noexpand\XINTfstop$string} at 1.4 but has been$noexpand
% converted into a fancier token at 1.5, to avoid the $myenquote{blinking} effect$noexpand
% when submitted to finitely many expansions à la \expandafter as first token of a$noexpand
% replacement text.}
%
% \XINTfstop \XINTexprprint .{{<number>}} in simplest case
%
% \XINTfstop \XINTexprprint .{{...}...{...}} in general case
%
% where ... stands for nested braces ultimately ending in {<num. rep.>} leaves.
% The <num. rep.> stands for some internal representation of numeric data. It
% may be empty, and currently as well as probably in future uses only catcode
% 12 tokens (no spaces currently).
%
% {{}} corresponds (in input as in output) to []. The external TeX braces also
% serve as set-theoretical braces. The comma is concatenation, so for example
% [], [] will become {{}{}}, or rather {}{} if sub-unit of something else.
%
% The associated vocabulary is explained in the user manual and we avoid
% too much duplication here. $xintfracnameimp numerical macros receiving an
% empty argument usually handle it as being 0, but this is not the case of the
% $xintcorenameimp macros supporting \xintiiexpr, they usually break if
% exercised on some empty argument.
%
% The above expansion result \XINTfstop \XINTexprprint .{{<num1>}{<num2}...}
% uses only normal catcodes: the backslash, regular braces, ascii letters and
% catcode 12 characters. Scientific notation is internally converted to raw
% $xintfracnameimp representation [N].
%
% Additional data may be located before the dot; this is the case only for
% \xintfloatexpr currently. As
% xintexpr actually defines three parsers \xintexpr, \xintiiexpr and
% \xintfloatexpr but tries to share as much code as possible, some overhead
% is induced to fit all into the same mold.
%
% \XINTfstop stops \romannumeral-`0 (or 0) type spanned expansion, and is
% invariant under \edef, but simply disappears in typesetting context.&
% $oneargcs$footnote{It is not \let to \relax as it must be distinguished$noexpand
% from it in \ifx tests.}
% It is
% thus now legal to use \xintexpr directly in typesetting flow.
%
% \XINTexprprint is \protected.
%
% The f-expansion of an \xintexpr <expression>\relax is a complete expansion,
% i.e. one whose result remains invariant under \edef.
%
% \xintthe\xintexpr <expression>\relax or \xinteval{<expression>} serve as
% formerly to deliver the explicit digits, or more exactly some prettifying
% view of the actual <internal number representation>.
%
% Nested contents like this
%
% {{1}{{2}{3}{{4}{5}{6}}}{9}}
%
% $noindent will get delivered using nested square brackets like that
%
% 1, [2, 3, [4, 5, 6]], 9
%
% $noindent and as conversely \xintexpr 1, [2, 3, [4, 5, 6]], 9\relax expands to
%
% \XINTfstop \XINTexprprint .{{1}{{2}{3}{{4}{5}{6}}}{9}}
%
% $noindent we obtain the gratifying result that
%
% \xinteval{1, [2, 3, [4, 5, 6]], 9}
%
% $noindent expands to
%
% 1, [2, 3, [4, 5, 6]], 9
%
% See user manual for explanations on the plasticity of \xintexpr syntax
% regarding functions with multiple arguments, and the 1.4 «unpacking»
% Python-like * prefix operator.
%
%\end{lverb}
%
% \begin{framed}
%   I have suppressed (from the public dtx) many big chunks of
%   comments. Some became obsolete and need to be updated, others are
%   currently of value only to the author as a historical record.
%
%   ATTENTION! As the removal process itself took too much time, I ended up
%   leaving as is many comments which are obsoleted and wrong to various
%   degrees after the |1.4| release. Precedence levels of operators have all
%   been doubled to make room for new constructs
%
%   Even comments added during 1.4 developement may now be obsolete because
%   the preparation of 1.4 took a few weeks and that's enough of duration to
%   provide the author many chances to contradict in the code what has been
%   already commented upon.
%
%   Thus don't believe (fully) anything which is said here!\IMPORTANTf{}
% \end{framed}
%
%
%\begin{lverb}
% Warning: in text below and also in left-over old comments I may refer
% to «until» and «op» macros; due to the change of data storage at 1.4, I
% needed to refactor a bit the way expansion is controlled, and the situation
% now is mainly governed by «op», «exec», «check-» and «checkp» macros the
% latter three replacing the two «until_a» and «until_b» of former code. This
% allows to diminish the number of times an accumulated result will be grabbed
% in order to propagate expansion to its right. Formerly this was not an issue
% because such things were only a single token! I do not describe here how
% this is all articulated but it is not hard to see it from the code (the
% hardest thing in all such matter was in 2013 to actually write how the
% expansion would be initially launched because to do that one basically has to
% understand the mechanism in its whole and such things are not easy to
% develop piecemeal). Another thing to keep in mind is that operators in truth
% have a left precedence (i.e. the precedence they show to operators arising
% earlier) and a right precedence (which determines how they react to
% operators coming after them from the right). Only the first one is usually
% encapsulated in a chardef, the second one is most of the times identical to
% the first one and if not it is only virtual but implemented via \ifcase of
% \ifnum branching. A final remark is that some things are achieved by special
% «op» macros, which are a favorite tool to hack into the normal regular flow
% of things, via injection of special syntax elements. I did not rename these
% macros for avoiding too large git diffs, and besides the nice thing is that
% the 1.4 refactoring minimally had to modify them, and all hacky things using
% them kept on working with not a single modification. And a post-scriptum is
% that advanced features crucially exploit injecting sub-\xintexpr-essions, as
% all is expandable there is no real «context» (only a minimal one) which one
% would have to perhaps store and restore and doing this sub-expression
% injection is rather cheap and efficient operation.
%\end{lverb}
%
% \subsection{Old comments}
%
% These general comments were last updated at the end of the |1.09x| series in
% 2014. The principles remain in place to this day but refer to
% \href{http://www.ctan.org/pkg/xint/CHANGES.html}{CHANGES.html} for some
% significant evolutions since.
%
% The first version was released in June 2013. I was greatly helped in this task
% of writing an expandable parser of infix operations by the comments provided
% in |l3fp-parse.dtx| (in its version as available in April-May 2013). One will
% recognize in particular the idea of the `until' macros; I have not looked into
% the actual |l3fp| code beyond the very useful comments provided in its
% documentation.
%
% A main worry was that my data has no a priori bound on its size; to keep the
% code reasonably efficient, I experimented with a technique of storing and
% retrieving data expandably as \emph{names} of control sequences. Intermediate
% computation results are stored as control sequences |\.=a/b[n]|.
%
%
% Roughly speaking, the parser mechanism is as follows: at any given time the
% last found ``operator'' has its associated |until| macro awaiting some news
% from the token flow; first |getnext| expands forward in the hope to construct
% some number, which may come from a parenthesized sub-expression, from some
% braced material, or from a digit by digit scan. After this number has been
% formed the next operator is looked for by the |getop| macro. Once |getop| has
% finished its job, |until| is presented with three tokens: the first one is the
% precedence level of the new found operator (which may be an end of expression
% marker), the second is the operator character token (earlier versions had here
% already some macro name, but in order to keep as much common code to expr and
% floatexpr common as possible, this was modified) of the new found operator, and
% the third one is the newly found number (which was encountered just before the
% new operator).
%
% The |until| macro of the earlier operator examines the precedence level of the
% new found one, and either executes the earlier operator (in the case of a
% binary operation, with the found number and a previously stored one) or it
% delays execution, giving the hand to the |until| macro of the operator having
% been found of higher precedence.
%
% A minus sign acting as prefix gets converted into a (unary) operator
% inheriting the precedence level of the previous operator.
%
% Once the end of the expression is found (it has to be marked by a |\relax|)
% the final result is output as four tokens (five tokens since |1.09j|) the
% first one a catcode 11 exclamation mark, the second one an error generating
% macro, the third one is a protection mechanism, the fourth one a printing
% macro and the fifth is |\.=a/b[n]|. The prefix |\xintthe| makes the output
% printable by killing the first three tokens.
%
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
% The code for reload detection was initially copied from \textsc{Heiko
% Oberdiek}'s packages, then modified.
%
% The method for catcodes was also initially directly inspired by these
% packages.
%
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode64=11   % @
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \catcode35=6    % #
  \def\odef#1{\expandafter\def\expandafter#1\expandafter}%
  \def\empty{}\def\space{ }\newlinechar10
  \def\z{\endgroup}%
  \expandafter\let\expandafter\x\csname ver@calx.sty\endcsname
  \expandafter\let\expandafter\t\csname ver@xinttools.sty\endcsname
  \expandafter\let\expandafter\b\csname ver@xintbinhex.sty\endcsname
  \expandafter\let\expandafter\f\csname ver@xintfrac.sty\endcsname
  \expandafter\let\expandafter\fp\csname ver@calxfp.sty\endcsname
  % I assume engines do not exist providing \expanded but not \numexpr
  \expandafter\ifx\csname expanded\endcsname\relax
    \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax
      \immediate\write128{^^JPackage calx Warning:^^J%
                          \space\space\space\space
                          \expanded not available, aborting input.^^J}%
    \else
      \PackageWarningNoLine{calx}{\expanded not available, aborting input}%
    \fi
    \def\z{\endgroup\endinput}%
  \else
    \ifx\x\relax   % not LaTeX (perhaps Plain+miniltx), first loading of calx.sty
      \ifx\t\relax % but xinttools.sty not yet loaded.
         \odef\z{\z\input xinttools.sty\relax}%
      \fi
      \ifx\b\relax % but xintbinhex.sty not yet loaded.
         \odef\z{\z\input xintbinhex.sty\relax}%
      \fi
      \ifx\fp\relax % but calxfp.sty not yet loaded.
         \odef\z{\z\input calxfp.sty\relax}%
      \fi
    \else
      \ifx\x\empty % LaTeX, first loading,
      % variable is initialized, but \ProvidesPackage not yet seen
          \ifx\t\relax % xinttools not yet loaded.
            \odef\z{\z\RequirePackage{xinttools}}%
          \fi
          \ifx\b\relax % xintbinhex not yet loaded.
            \odef\z{\z\RequirePackage{xintbinhex}}%
          \fi
          \ifx\fp\relax % calxfp not yet loaded.
            \odef\z{\z\RequirePackage{calxfp}}%
          \fi
      \else
        \def\z{\endgroup\endinput}% xintexpr already loaded.
      \fi
    \fi
  \fi
\z%
\XINTsetupcatcodes%
%    \end{macrocode}
% \subsection{Package identification}
% The |!| is of catcode LETTER for most of the duration of the package.  Prior
% to |1.4| it was the first token in the complete expansion of
% |\xintexpr...\relax| (i.e. without |\xintthe| prefix).  It has since lost to
% |\XINTfstop| this prominent rôle, but its usage in various places of the
% code as delimiter in otherwise catcode 12 contexts has stuck.
%    \begin{macrocode}
\XINT_providespackage
\ProvidesPackage{calx}%
  [2026/11/01 v2.0a1 Expandable fp and bigint expression parsers (JFB)]%
\catcode`! 11
%    \end{macrocode}
%\begin{lverb}
% calx: ^^B, ^^C are the fake operators of the integer, resp. decimal
% and exponent, exits of the number scanner; catcode 12, restored at
% the end of the file.
%\end{lverb}
%    \begin{macrocode}
\edef\CALX_restorecc{\catcode2=\the\catcode2\relax
    \catcode3=\the\catcode3\relax}\catcode2=12 \catcode3=12
%    \end{macrocode}
% \subsection{\csh{XINTfstop}}
% \added{1.4}
%
% This replaced in 2019 the legacy usage of a catcode 11 exclamation mark to
% signal the start of a sub-expression (it was followed by some other tokens).
%
%
% From 2022 (aiming at |1.5|) to 2025 (releasing |1.4n|) I had replaced the
% definition used here with a fancier one originating in a ``fake'' \cs{relax}
% from \ctanpackage{unravel}.
% I think in 2022, \ctanpackage{unravel} used a frozen let to |\the|, which I
% had transferred here as a definition of |\XINTfstop|, now reverted.  When I
% checked again \ctanpackage{unravel} in 2025, I saw a definition of the type
% \centeredline{|\expandafter\let\expandafter\foo\noexpand\foo|}
%
% If I did that with \cs{foo} being |\XINTfstop| then |\XINTfstop|
% would test equal via \cs{ifx} to the \ctanpackage{unravel} or any
% such |\foo| (if |\foo| is at first undefined)...
%
% The inconvenience with our more naive |\XINTfstop| here, is that
% expanding a finite number of times |\xintexpr...\relax| depends
% on parity of number of expansions.  Not really a problem as far as
% I can tell.  The advantage is that |\ifx| will never confuse it
% with something else.
%    \begin{macrocode}
\def\XINTfstop{\noexpand\XINTfstop}%
%    \end{macrocode}
% \subsection{Support for output and transform of nested braced contents as
% core data type}
% New at 1.4, of course. The former |\csname.=...\endcsname| encapsulation
% technique made very difficult implementation of nested structures.
% \subsubsection{Bracketed list rendering with prettifying of leaves from nested
% braced contents}
% \added{1.4}
% The braces in |\XINT:expr:toblistwith| are there because there is
% an |\expanded| trigger.
% \changed{1.4d}
%\begin{lverb}
% Add support for the polexpr 0.8 polynomial type. See \XINT:expr:toblist_a.
%\end{lverb}
% \changed{1.4l}
%\begin{lverb}
% Let \XINT:expr:toblist_b use #1{#2} with regular { and } in case
% macro #1 is \protected and things are output to external file where former
% #1<#2> would end up with catcode 12 < and >.
%\end{lverb}
%    \begin{macrocode}
\def\XINT:expr:toblistwith#1#2%
{%
    {\expandafter\XINT:expr:toblist_checkempty
     \expanded{\noexpand#1!\expandafter}\detokenize{#2}^}%
}%
\def\XINT:expr:toblist_checkempty #1!#2%
{%
    \if ^#2\expandafter\xint_gob_til_^\else\expandafter\XINT:expr:toblist_a\fi
    #1!#2%
}%
\catcode`< 1 \catcode`> 2 \catcode`{ 12 \catcode`} 12
\def\XINT:expr:toblist_a #1{#2%
<%
    \if{#2\xint_dothis<[\XINT:expr:toblist_a>\fi
    \if P#2\xint_dothis<\XINT:expr:toblist_pol>\fi
    \xint_orthat\XINT:expr:toblist_b #1#2%
>%
\def\XINT:expr:toblist_pol #1!#2.{#3}}%
<%
    pol([\XINT:expr:toblist_b #1!#3}^])\XINT:expr:toblist_c #1!}%
>%
\catcode`{ 1 \catcode`} 2
\def\XINT:expr:toblist_b #1{%
\def\XINT:expr:toblist_b ##1!##2#1%
{%
    \if\relax##2\relax
    \xintexprEmptyItem\else##1{##2}\fi\XINT:expr:toblist_c ##1!#1%
}}\catcode`{ 12 \catcode`} 12 \XINT:expr:toblist_b<}>%
\def\XINT:expr:toblist_c #1}#2%
<%
    \if ^#2\xint_dothis<\xint_gob_til_^>\fi
    \if{#2\xint_dothis<, \XINT:expr:toblist_a>\fi
    \xint_orthat<]\XINT:expr:toblist_c>#1#2%
>%
\catcode`{ 1 \catcode`} 2 \catcode`< 12 \catcode`> 12
%    \end{macrocode}
% \subsubsection{Flattening nested
% braced contents}
%\begin{lverb}
% 1.4b I hesitated whether using this technique or some variation of
% the method of the ListSel macros. I chose this one which I downscaled from
% toblistwith, I will revisit later. I only have a few minutes right now.
%
% Call form is \expanded\XINT:expr:flatten
%
% See \XINT_expr_func_flat. I hesitated with «flattened», but short names
% are faster parsed.
%\end{lverb}
%    \begin{macrocode}
\def\XINT:expr:flatten#1%
{%
   {{\expandafter\XINT:expr:flatten_checkempty\detokenize{#1}^}}%
}%
\def\XINT:expr:flatten_checkempty #1%
{%
    \if ^#1\expandafter\xint_gobble_i\else\expandafter\XINT:expr:flatten_a\fi
    #1%
}%
\begingroup
\catcode`[ 1 \catcode`] 2 \lccode`[`{ \lccode`]`}
\catcode`< 1 \catcode`> 2 \catcode`{ 12 \catcode`} 12
\lowercase<\endgroup
\def\XINT:expr:flatten_a {#1%
<%
    \if{#1\xint_dothis<\XINT:expr:flatten_a>\fi
    \xint_orthat\XINT:expr:flatten_b #1%
>%
\def\XINT:expr:flatten_b #1}%
<%
    [#1]\XINT:expr:flatten_c }%
>%
\def\XINT:expr:flatten_c }#1%
<%
    \if ^#1\xint_dothis<\xint_gobble_i>\fi
    \if{#1\xint_dothis<\XINT:expr:flatten_a>\fi
    \xint_orthat<\XINT:expr:flatten_c>#1%
>%
>% back to normal catcodes
%    \end{macrocode}
% \subsubsection{Braced contents rendering via a \TeX{} alignment with prettifying of leaves}
%\begin{lverb}
% 1.4.
%
% Breaking change at 1.4a as helper macros were renamed and their meanings
% refactored: no more \xintexpraligntab nor \xintexpraligninnercomma or
% \xintexpralignoutercomma but \xintexpraligninnersep, etc...
%
% At 1.4c I remove the \protected from \xintexpralignend.  I had made note a
% year ago that it served nothing.  Let's trust myself on this one (risky one
% year later!).
%\end{lverb}
%    \begin{macrocode}
\catcode`& 4
\protected\def\xintexpralignbegin
  {\halign\bgroup\tabskip2ex\hfil##&&##\hfil\cr}%
\def\xintexpralignend                   {\crcr\egroup}%
\protected\def\xintexpralignlinesep     {,\cr}%
\protected\def\xintexpralignleftbracket {[}%
\protected\def\xintexpralignrightbracket{]}%
\protected\def\xintexpralignleftsep     {&}%
\protected\def\xintexpralignrightsep    {&}%
\protected\def\xintexpraligninnersep    {,&}%
\catcode`& 7
\def\XINT:expr:toalignwith#1#2%
{%
    {\expandafter\XINT:expr:toalign_checkempty
     \expanded{\noexpand#1!\expandafter}\detokenize{#2}^\expandafter}%
    \xintexpralignend
}%
\def\XINT:expr:toalign_checkempty #1!#2%
{%
    \if ^#2\expandafter\xint_gob_til_^\else\expandafter\XINT:expr:toalign_a\fi
    #1!#2%
}%
\catcode`< 1 \catcode`> 2 \catcode`{ 12 \catcode`} 12
\def\XINT:expr:toalign_a #1{#2%
<%
    \if{#2\xint_dothis<\xintexpralignleftbracket\XINT:expr:toalign_a>\fi
    \xint_orthat<\xintexpralignleftsep\XINT:expr:toalign_b>#1#2%
>%
\def\XINT:expr:toalign_b #1!#2}%
<%
    \if\relax#2\relax\xintexprEmptyItem\else#1<#2>\fi\XINT:expr:toalign_c #1!}%
>%
\def\XINT:expr:toalign_c #1}#2%
<%
    \if ^#2\xint_dothis<\xint_gob_til_^>\fi
    \if {#2\xint_dothis<\xintexpraligninnersep\XINT:expr:toalign_A>\fi
    \xint_orthat<\xintexpralignrightsep\xintexpralignrightbracket
    \XINT:expr:toalign_C>#1#2%
>%
\def\XINT:expr:toalign_A #1{#2%
<%
    \if{#2\xint_dothis<\xintexpralignleftbracket\XINT:expr:toalign_A>\fi
    \xint_orthat\XINT:expr:toalign_b #1#2%
>%
\def\XINT:expr:toalign_C #1}#2%
<%
    \if ^#2\xint_dothis<\xint_gob_til_^>\fi
    \if {#2\xint_dothis<\xintexpralignlinesep\XINT:expr:toalign_a>\fi
    \xint_orthat<\xintexpralignrightbracket\XINT:expr:toalign_C>#1#2%
>%
\catcode`{ 1 \catcode`} 2 \catcode`< 12 \catcode`> 12
%    \end{macrocode}
% \subsubsection{Transforming all leaves within nested
% braced contents}
%
%\begin{lverb}
% 1.4. Leaves must be of catcode 12... This is currently not a
% constraint (or rather not a new constraint) for xintexpr because formerly
% anyhow all data went through csname encapsulation and extraction via string.
%
% In order to share code with the functioning of universal functions, which
% will be allowed to transform a number into an ople, the applied macro
% is supposed to apply one level of bracing to its ouput. Thus to apply this
% with an xintfrac macro such as \xintiRound{0} one needs first to define
% a wrapper which will expand it inside an added brace pair:
%
% \def\foo#1{{\xintiRound{0}{#1}}}
%
% As the things will expand inside expanded, propagating expansion is not an
% issue.
%
% This code is used by \xintiexpr and \xintfloatexpr in case of optional
% argument and by the «Universal functions».
%
% Comment at 1.4l: this seems to be used only at private package level, else
% I should modify \XINT:expr:mapwithin_b like I did with \XINT:expr:toblist_b
% to use regular braces in case the applied macro is \protected and
% things end up in external file.
%\end{lverb}
%
%    \begin{macrocode}
\def\XINT:expr:mapwithin#1#2%
{%
    {{\expandafter\XINT:expr:mapwithin_checkempty
      \expanded{\noexpand#1!\expandafter}\detokenize{#2}^}}%
}%
\def\XINT:expr:mapwithin_checkempty #1!#2%
{%
    \if ^#2\expandafter\xint_gob_til_^\else
    \expandafter\XINT:expr:mapwithin_a\fi
    #1!#2%
}%
\begingroup
\catcode`[ 1 \catcode`] 2 \lccode`[`{ \lccode`]`}
\catcode`< 1 \catcode`> 2 \catcode`{ 12 \catcode`} 12
\lowercase<\endgroup
\def\XINT:expr:mapwithin_a #1{#2%
<%
    \if{#2\xint_dothis<[\iffalse]\fi\XINT:expr:mapwithin_a>\fi%
    \xint_orthat\XINT:expr:mapwithin_b #1#2%
>%
\def\XINT:expr:mapwithin_b #1!#2}%
<%
    #1<#2>\XINT:expr:mapwithin_c #1!}%
>%
\def\XINT:expr:mapwithin_c #1}#2%
<%
    \if ^#2\xint_dothis<\xint_gob_til_^>\fi
    \if{#2\xint_dothis<\XINT:expr:mapwithin_a>\fi%
    \xint_orthat<\iffalse[\fi]\XINT:expr:mapwithin_c>#1#2%
>%
>% back to normal catcodes
%    \end{macrocode}
% \subsection{Top level user \TeX{} interface:
% \cshnolabel{xintfloateval}, \cshnolabel{xintiieval}}
% \localtableofcontents
% \subsubsection{\csh{xintfloatexpr},
% \csh{xintiiexpr}}
%
% \changed{1.4o}
%
% While preparing |1.4n| I had made changes to tame Babel active characters
% via a |\csname| trick.  At last minute, after having first implemented
% correctly the feature both here and in \ctanpackage{bnumexpr} I thought I
% had a way requiring not so many ``top level'' changes, but this was a grave
% logic error on my part, due to having a bit forgotten the way things are
% done here, and due to external circumstances. I released too hastily |1.4n|.
% But the feature was working only with \csbxint{iieval}. Any test other than
% simply evaluating |3!| with |!| the Babel-French (e.g.\@ |1+3!|) would have
% revealed it. I was planning to add test units after (what?) doing the
% release. By the way one has to be careful to do such tests after a
% |\noindent| because the French active |!| in vertical mode does things not
% breaking the parser.  Anyway, here I do it right.
%
% So this is why for example |\XINT_flexpr_noopt| has a |\csname| construct.
%    \begin{macrocode}
\def\xintfloatexpr  {\romannumeral0\xintfloatexpro }%
\def\xintiiexpr     {\romannumeral0\xintiiexpro    }%
\def\xintiiexpro {\csname XINT_iiexpr_wrap\expandafter\endcsname
                  \romannumeral0\xintbareiieval }%
\def\xintfloatexpro #1%
{%
    \ifx [#1\expandafter\XINT_flexpr_withopt\else\expandafter\XINT_flexpr_noopt
    \fi #1%
}%
\def\XINT_flexpr_noopt
{%
    \csname XINT_flexpr_wrap\expandafter\endcsname
    \the\numexpr\XINTdigits\expandafter.%
    \romannumeral0\xintbarefloateval
}%
\def\XINT_flexpr_withopt [#1]%
{%
    \csname XINT_flexpr_withopt_a\expandafter\endcsname
    \the\numexpr\xint_zapspaces #1 \xint_gobble_i\expandafter.%
    \romannumeral0\xintbarefloateval
}%
\def\XINT_flexpr_withopt_a #1#2.%
{%
    \expandafter\XINT_flexpr_withopt_b\the\numexpr\if#1-\XINTdigits\fi#1#2.%
}%
\def\XINT_flexpr_withopt_b #1.%
{%
    \expandafter\XINT_flexpr_wrap
    \the\numexpr#1\expandafter.%
    \expanded
    \XINT:NEhook:x:mapwithin\XINT:expr:mapwithin{\XINTinFloat_braced[#1]}%
}%
%    \end{macrocode}
%\begin{lverb}
% calx: [Q] rounding of native leaves. Legacy was
%\end{lverb}
% \centeredline{|\def\XINTinFloat_braced[#1]#2{{\XINTinFloat[#1]{#2}}}|}^^A$
%\begin{lverb}
% but xe don't want an xintfrac.sty dependency.
%
% There was a legacy comment "utiliser \XINTinFloatS ?", let us recall that
% this is a variant of \XINTinFloat which does not insist on a length P mantissa.
% So this is purely a legacy question which is obsolete with calx.
%
% Maybe consider in this context \CALX_frez which trims trailing zeros,
% but if this ends up being fed as I believe it is again to \CALX_fround
% when going through the printer, it would be probably only a waste of
% time.
%
% FIXME: calxfp.sty has \def\CALX_fbr #1\xint:{ #1}. Check
% \CALX_fround final stage to see if the \xint: removal
% could happen earlier.
%\end{lverb}
%    \begin{macrocode}
\def\XINTinFloat_braced[#1]#2%
   {{\romannumeral0\expandafter\CALX_fbr
     \romannumeral0\CALX_fround{#1}{#2}}}%
%    \end{macrocode}
% \subsubsection{\csh{XINT_iiexpr_wrap},
%                \csh{XINT_flexpr_wrap}}
%\begin{lverb}
% 1.3e removes some leading space tokens which served nothing.
%
% 1.4e has \XINT_iexpr_wrap separated from \XINT_expr_wrap, thus simplifying
% internal matters as output printer for \xintexpr will not have to handle
% fixed point input but only extended-raw type input (i.e. A, A/B, A[N] or A/B[N]).
%\end{lverb}
%    \begin{macrocode}
\def\XINT_iiexpr_wrap {\XINTfstop\XINTiiexprprint.}%
\def\XINT_flexpr_wrap {\XINTfstop\XINTflexprprint}%
%    \end{macrocode}
% \subsubsection{\csh{XINTiiexprprint}, \csh{XINTflexprprint}}
% \label{\xintimplabelprefix xintfloatexprPrintOne}
% \label{\xintimplabelprefix xintiiexprprintone}
%
% \changed{1.4}
% Requires |\expanded|.
%
% Comments here also apply to material moved to \xintexprnameimp.sty at |2.0a1|.
% \changed{1.4e}
%\begin{lverb}
% 1.4e has a breaking change of \XINTflexprprint and \xintfloatexprPrintOne
% which now requires \xintfloatexprPrintOne[D]{x} syntax, with first argument
% in brackets.
%
%\end{lverb}
% \changed{1.4l}
% The code does |\let\xintexprPrintOne\xint_FracToSci_x| but the latter is not yet
% defined so this is delayed until |\xint_FracToSci_x| definition.
% \changed[2022/06/05]{1.4m}
% \csa{xintboolexprPrintOne} outputs |true| or |false|, not |True| or |False|.
% By the way (undocumented) all four keywords |true|, |false|, |True|,
% |False| are recognized as genuine variables since |1.4i|.
%    \begin{macrocode}
\def\xintexprEmptyItem{[]}%
\protected\def\XINTiiexprprint.%
    {\XINT:NEhook:x:toblist\XINT:expr:toblistwith\CALX_iipr}%
\def\CALX_iipr #1{\expandafter\xintiiexprPrintOne
                  \romannumeral0\CALX_mr_a#1\xint:}%
\def\xintiiexprPrintOne #1{%
\def\xintiiexprPrintOne ##1%
{%
    \xint_gob_til_Ixii ##1\CALX_iipr_special #1##1%
}}\expandafter\xintiiexprPrintOne\string I%
\def\CALX_iipr_special #1#2#3{%
    \if ?#3\xint_dothis{NaN}\fi
    \xint_orthat{#3Infinity}%
}%
\protected\def\XINTflexprprint #1.%
    {\XINT:NEhook:x:toblist\XINT:expr:toblistwith{\xintfloatexprPrintOne[#1]}}%
%    \end{macrocode}
%\begin{lverb}
% calx: native leaves: \CALX_fround then \CALX_ftoraw replace the
% \XINTinfloatS of xint's \xintPFloat_wopt, whose formatting macros
% (\XINT_pfloat, hooks \xintPFloatE etc.) are used unchanged.
% Specials I+, I-, I? are printed as is (provisional).
%\end{lverb}
%    \begin{macrocode}
\def\xintfloatexprPrintOne[#1]#2%
{%
    \romannumeral0\expandafter\CALX_fpr_a
    \romannumeral0\CALX_fround{#1}{#2}#1.%
}%
\def\CALX_fpr_a#1{%
  \def\xint_gob_til_Ixii##1#1{}%
  \def\CALX_fpr_a ##1%
  {%
    \xint_gob_til_Ixii ##1\CALX_fpr_special #1%
    \expandafter\XINT_pfloat_fork\romannumeral0\CALX_frez ##1%
  }%
}\expandafter\CALX_fpr_a\string I%
\def\CALX_fpr_special #1\CALX_frez #2#3\xint:#4.{%
    \if ?#3\xint_dothis{ NaN}\fi
    \xint_orthat{ #3Infinity}%
}%
%    \end{macrocode}
% \subsubsection{\csh{xintthe}, \csh{xintthealign}, \csh{xintthefloatexpr},
% \csh{xinttheiiexpr}}
%\begin{lverb}
% The reason why \xinttheiexpr et \xintthefloatexpr are handled
% differently is that they admit an optional argument which acts via a custom
% «printing» stage.
%
% We exploit here that \expanded expands forward until finding an implicit or
% explicit brace, and that this expansion overrules \protected macros, forcing
% them to expand, similarly as \romannumeral expands \protected macros, and
% contrarily to what happens *within* the actual \expanded scope. I discovered
% this fact by testing (with pdftex) and I don't know where this is documented
% apart from the source code of the relevant engines. This is useful to us
% because there are contexts where we will want to apply a complete expansion
% before printing, but in purely numerical context this is not needed (if I
% converted correctly after dropping at 1.4 the \csname governed expansions;
% however I rely at various places on the fact that the xint macros are
% f-expandable, so I have tried to not use zillions of expanded all over the
% place), hence it is not needed to add the expansion overhead by default. But
% the \expanded here will allow \xintNewExpr to create macro with suitable
% modification or the printing step, via some hook rather than having to
% duplicate all macros here with some new «NE» meaning (aliasing does not work
% or causes big issues due to desire to support \xinteval also in «NE» context
% as sub-constituent. The \XINT:NEhook:x:toblist is something else which
% serves to achieve this support of *sub* \xinteval, it serves nothing for
% the actual produced macros. For \xintdeffunc, things are simpler, but still
% we support the [N] optional argument of \xintiexpr and \xintfloatexpr, which
% required some work...
%
% The \expanded upfront ensures \xintthe mechanism does expand
% completely in two steps.
%\end{lverb}
%
% The fact that |\xintthe| grabs a |#1| is legacy and I am not sure why. I
% vaguely remember thinking the overhead was minimal because |#1| will
% simply be one token such as \csbxint{expr} and that it could potentially
% be useful.  Of course |\xintthealign| imitates |\xintthe| in that matter.
%
% \changed{1.4o}
% Again here some |\csname|'s to handle babel-active characters.
%    \begin{macrocode}
\def\xintthe      #1{\expanded\expandafter\xint_gobble_i\romannumeral`&&@#1}%
\def\xintthealign #1{\expandafter\xintexpralignbegin
                     \expanded\expandafter\XINT:expr:toalignwith
    \romannumeral0\expandafter\expandafter\expandafter\expandafter
    \expandafter\expandafter\expandafter\xint_gob_andstop_ii
                     \expandafter\xint_gobble_i\romannumeral`&&@#1}%
\def\xinttheiiexpr
   {\expanded\csname XINTiiexprprint\expandafter\endcsname
    \expandafter.\romannumeral0\xintbareiieval}%
%    \end{macrocode}
% \changed{1.4p} I don't know why I had been using
% |\romannumeral`&&@\xintiexpr|. Perhaps at some point |\xintiexpro| and
% |\xintfloatexpro| were not available? Or maybe I simply was under
% influence of |\xintthe|.  I have not checked history.
%
% No need at |1.4o| of |\csname|'s for Babel here, as \csbxint{iexpro} and
% \csbxint{floatexpro} are already taken care of.
%    \begin{macrocode}
\def\xintthefloatexpr
   {\expanded\expandafter\xint_gobble_i\romannumeral0\xintfloatexpro}%
%    \end{macrocode}
% \subsubsection{\csh{xintbarefloateval}, \csh{xintbareiieval}}
%
% \changed{1.4}
% one expansion step added via \csbXINT{_expr_start},
% \csbXINT{_iiexpr_start}, \csbXINT{_flexpr_start}.  Trigger is expected to be
% via |\romannumeral`^^@| or |\romannumeral0|.
%
% For the benefit of those who like the author while finishing |1.4n| looked
% in vain for where the ``|_start|'' macros were defined, this documentation
% was updated so that one can find the location via clicking on their names in
% the previous paragraph. Spoiler: they are in
% \autoref{ssec:expansionspanning}.  This was hidden because the three are
% defined in an \csbxint{For} in one-go.
%    \begin{macrocode}
\def\xintbarefloateval{\XINT_flexpr_start}%
\def\xintbareiieval   {\XINT_iiexpr_start}%
%    \end{macrocode}
% \subsubsection{\csh{xintthebarefloateval},
% \csh{xintthebareiieval}}
%\begin{lverb}
% For matters of \XINT_NewFunc
%\end{lverb}
%
% \changed{1.4o}
%
% The matter of Babel active here too, although these macros are destined to
% use by \csbxint{deffunc} and \csbxint{NewExpr} and both attempt to sanitize
% catcodes.  But I had already edited at |1.4n| the user documentation to
% mention cases where changing catcodes is impossible. It would have been too
% time-costly late at night to re-edit while I was eager to push the |1.4o|
% hotfix.  So let's live with some added overhead.
%
% \changed{1.4p}
% |s/_stop_atfirstofone/_firstofone| because anyhow it will encounter an
% opening brace.
%    \begin{macrocode}
\def\XINT_expr_unlock{\expandafter\xint_firstofone\romannumeral`&&@}%
\def\xintthebareiieval{%
  \romannumeral0\csname xint_firstofone\expandafter\endcsname
  \romannumeral0\xintbareiieval
}%
\def\xintthebarefloateval{%
  \romannumeral0\csname xint_firstofone\expandafter\endcsname
  \romannumeral0\xintbarefloateval
}%
\def\xintthebareroundedfloateval{%
  \romannumeral0\csname xintthebareroundedfloateval_a\expandafter\endcsname
  \romannumeral0\xintbarefloateval
}%
\def\xintthebareroundedfloateval_a{%
  \expandafter\xint_firstofone
  \expanded\XINT:NEhook:x:mapwithin
           \XINT:expr:mapwithin{\XINTinFloatSdigits_braced}%
}%
%    \end{macrocode}
%\begin{lverb}
% calx: native rounding (F, I, or raw input) for \xintdeffloatvar.
%\end{lverb}
%    \begin{macrocode}
\def\XINTinFloatSdigits_braced#1%
   {{\romannumeral0\expandafter\CALX_fbr
     \romannumeral0\CALX_fround{\XINTdigits}{#1}}}%
%    \end{macrocode}
% \subsubsection{\csh{xintfloateval},
% \csh{xintiieval}}
%\begin{lverb}
% Refactored at 1.4.
%
% The \expanded upfront ensures \xinteval still expands
% completely in two steps. No \romannumeral trigger here, in relation to the
% fact that \XINTexprprint is not f-expandable, only e-expandable.
%
% (and attention that \xintexpr\relax is now legal, and an empty ople can be
% produced in output also from \xintexpr [17][1]\relax for example)
%\end{lverb}
% \changed[2022/05/16]{1.4k}
%
% The \csbxint{ieval} and \csbxint{floateval} optional bracketed argument can now
% be located outside the braces... took me years to finally make the step towards LaTeX
% users expectations for the interface.
%
% \changed{1.4o}
% Some |\csname|'s for the Babel-active feature which was botched at |1.4n|.
% But |\xintiexpr| and |\xintifloatexpr| are already taken care of.
%
% Should I use |#{| rather delimited argument? (as for \csbxint{iieval} at |1.4n|).
%
% Same updates at |1.4p| as for \csbxint{ieval}.
%    \begin{macrocode}
\def\xintfloateval {\expanded\expandafter\xint_floateval_chkopt\string}%
\def\xint_floateval_chkopt #1%
{%
    \ifx [#1\expandafter\xint_floateval_opt
       \else\expandafter\xint_floateval_noopt
    \fi  #1%
}%
\def\xint_floateval_opt [#1]#2{%
  \expandafter\xint_gobble_i\romannumeral0\XINT_flexpr_withopt[#1]#2\relax
}%
\def\xint_floateval_noopt #1%
   {\expandafter\xint_floateval\expandafter{\iffalse}\fi}%
\def\xint_floateval#1{%
  \expandafter\xint_gobble_i\romannumeral0\xintfloatexpro#1\relax
}%
%    \end{macrocode}
% \changed{1.4n}
% \csbxint{iieval} admits optional arguments |[h]|, |[o]| and |[b]|.
% The way this is implemented tames Babel active characters.
%    \begin{macrocode}
\def\xintiieval #1#{\expanded\xintiieval_a{#1}}%
\def\xintiieval_a#1#2%
{%
    \csname XINTiiexprprint\xint_zapspaces #1 \xint_gobble_i
    \expandafter\endcsname
    \expandafter.\romannumeral0\xintbareiieval#2\relax
}%
\expandafter\def\csname XINTiiexprprint[h]\endcsname.%
    {\XINT:NEhook:x:toblist\XINT:expr:toblistwith\CALX_iiprhex}%
\expandafter\def\csname XINTiiexprprint[o]\endcsname.%
    {\XINT:NEhook:x:toblist\XINT:expr:toblistwith\CALX_iiproct}%
\expandafter\def\csname XINTiiexprprint[b]\endcsname.%
    {\XINT:NEhook:x:toblist\XINT:expr:toblistwith\CALX_iiprbin}%
\expandafter\let\csname XINTiiexprprint[]\endcsname\XINTiiexprprint
\def\CALX_iiprhex #1{\xintiiexprPrintOneHex{\CALX_mr{#1}}}%
\def\CALX_iiproct #1{\xintiiexprPrintOneOct{\CALX_mr{#1}}}%
\def\CALX_iiprbin #1{\xintiiexprPrintOneBin{\CALX_mr{#1}}}%
\let\xintiiexprPrintOneHex\xintDecToHex
\let\xintiiexprPrintOneOct\xintDecToOct
\let\xintiiexprPrintOneBin\xintDecToBin
%    \end{macrocode}
% \subsubsection{\csh{xintifboolfloatexpr},
% \csh{xintifbooliiexpr}}
%
% \added{1.09c}
% They do not accept (i.e.\@ they cause breakage if used this way)
% comma separated expressions as input.
%
% \changed{1.4p}
% Sadly at |1.4e|, some internal changes to the output format
% of \csbxint{theexpr} broke that the assumptions which excused the use of
% integer only \csbxint{iiifnotzero}.  As a result the macro became badly
% broken as it started thinking that for example |0.75| is zero.  Fortunately
% most usage of it is with some inequality test, which produces either one or
% zero.  So the author became aware of this only 5 years later.
%    \begin{macrocode}
\def\xintifboolfloatexpr #1{%
    \romannumeral0\expandafter\CALX_ifnz
    \romannumeral0\csname xint_firstofone\expandafter\endcsname
    \romannumeral0\xintbarefloateval #1\relax
}%
\def\xintifbooliiexpr #1{%
    \romannumeral0\expandafter\CALX_ifnz
    \romannumeral0\csname xint_firstofone\expandafter\endcsname
    \romannumeral0\xintbareiieval #1\relax
}%
%    \end{macrocode}
% \subsubsection{\csh{xintifNonFinitefloatexpr}}
%\begin{lverb}
% The expression is evaluated once. Branch on its native result, I+, I-,
% or I? for non-finite, any other numeric form for finite. This is independent
% of signal flags and of the configurable printed spelling of special values.
%\end{lverb}
%    \begin{macrocode}
\def\xintifNonFinitefloatexpr #1{%
    \romannumeral0\expandafter\CALX_ifnonfinite
    \romannumeral0\csname xint_firstofone\expandafter\endcsname
    \romannumeral0\xintbarefloateval #1\relax
}%
\def\CALX_ifnonfinite #1{%
    \expandafter\CALX_ifnonfinite_a\romannumeral`&&@#1\xint:}%
\def\CALX_ifnonfinite_a #1{%
    \if I#1\expandafter\CALX_ifnonfinite_y
    \else\expandafter\CALX_ifnonfinite_n
    \fi
}%
\def\CALX_ifnonfinite_y #1\xint:{\xint_stop_atfirstoftwo}%
\def\CALX_ifnonfinite_n #1\xint:{\xint_stop_atsecondoftwo}%
%    \end{macrocode}
% \subsubsection{\csh{xintifsgnfloatexpr}, \csh{xintifsgniiexpr}}
%
% \added{1.3d}
% They do not accept (i.e.\@ they will cause breakage if used with) comma
% separated expressions.
%
% \changed{1.4p}
% Badly broken since a |1.4e| regression, see \csbxint{ifboolexpr}.  Situation
% here was much worse, of course.  I use \csbxint{thebareeval} to fix this as
% I am stubborn and do not want the parsing from \csbxint{ifsgn} but this is
% silly.  For \csbxint{ifsgniiexpr}, matters are more moot but there is always
% the danger of a custom \csbxint{iiexprPrintOne}, so \csbxint{bareiieval}
% here too.  For the other two really I should stop using the |ii| macros.
%
%    \begin{macrocode}
\def\xintifsgnfloatexpr #1{%
    \romannumeral0\expandafter\CALX_ifsgn
    \romannumeral0\csname xint_firstofone\expandafter\endcsname
    \romannumeral0\xintbarefloateval #1\relax
}%
\def\xintifsgniiexpr #1{%
    \romannumeral0\expandafter\CALX_ifsgn
    \romannumeral0\csname xint_firstofone\expandafter\endcsname
    \romannumeral0\xintbareiieval #1\relax
}%
%    \end{macrocode}
% \subsubsection{Small bits we have to put somewhere}
%\begin{lverb}
% Some renaming and modifications here with release 1.2 to switch from
% using chains of \romannumeral-`0 in order to gather numbers, possibly
% hexadecimals, to using a \csname governed expansion. In this way no more
% limit at 5000 digits, and besides this is a logical move because the
% \xintexpr parser is already based on \csname...\endcsname storage of numbers
% as one token.
%
% The limitation at 5000 digits didn't worry me too much because it was not
% very realistic to launch computations with thousands of digits... such
% computations are still slow with 1.2 but less so now. Chains or
% \romannumeral are still used for the gathering of function names and other
% stuff which I have half-forgotten because the parser does many things.
%
% In the earlier versions we used the lockscan macro after a chain of
% \romannumeral-`0 had ended gathering digits; this uses has been replaced by
% direct processing inside a \csname...\endcsname and the macro is kept only
% for matters of dummy variables.
%
% Currently, the parsing of hexadecimal numbers needs two nested
% \csname...\endcsname, first to gather the letters (possibly with a hexadecimal
% fractional part), and in a second stage to apply \xintHexToDec to do the
% actual conversion. This should be faster than updating on the fly the number
% (which would be hard for the fraction part...).
%\end{lverb}
%    \begin{macrocode}
\def\XINT_embrace#1{{#1}}%
\def\xint_gob_til_! #1!{}% ! with catcode 11
\def\xintError:noopening
{%
    \XINT_expandableerror{Extra ). This is serious and prospects are bleak.}%
}%
%    \end{macrocode}
% \paragraph{\csh{xintthecoords}}
% \added{1.1} (see user manual for interface)
%
%    \begin{macrocode}
\def\xintthecoords#1%
   {\romannumeral`&&@\expandafter\XINT_thecoords_a\romannumeral0#1}%
\def\XINT_thecoords_a #1#2.#3% #2.=\XINTfloatprint<digits>. etc...
   {\expanded{\expandafter\XINT_thecoords_b\expanded#2.{#3},!,!,^}}%
\def\XINT_thecoords_b #1#2,#3#4,%
   {\xint_gob_til_! #3\XINT_thecoords_c ! (#1#2, #3#4)\XINT_thecoords_b }%
\def\XINT_thecoords_c #1^{}%
%    \end{macrocode}
% \paragraph{\csh{xintthespaceseparated}}
% \added{1.4a}
%
% This is a utility macro which was distributed previously
% separately for usage with PSTricks \csa{listplot}.
%    \begin{macrocode}
\def\xintthespaceseparated#1%
   {\expanded\expandafter\xintthespaceseparated_a\romannumeral0#1}%
\def\xintthespaceseparated_a #1#2.#3%
   {{\expandafter
      \xintthespaceseparated_b\expanded#2.{#3},!,!,!,!,!,!,!,!,!,^}}%
\def\xintthespaceseparated_b #1,#2,#3,#4,#5,#6,#7,#8,#9,%
   {\xint_gob_til_! #9\xintthespaceseparated_c !%
    #1#2#3#4#5#6#7#8#9%
    \xintthespaceseparated_b}%
%    \end{macrocode}
%\begin{lverb}
% 1.4c I add a space here to stop the \romannumeral`$&$&@ in case of
% empty input.
% But this space induces an extra un-needed space token after 9, 18, 27,...
% items before the last group of less than 9 items.
%
% Fix (at 1.4h) is simple because I already use \expanded anyhow: I don't need
% at all the \romannumeral`$&$&@ which was first in \xintthespaceseparated,
% let's move the first \expanded which was in \xintthespaceseparated_a to
% \xintthespaceseparated, and remove the extra space here in _c.
%
% (alternative would have been to put the space after #1 and accept a
% systematic trailing space, at least it is more aesthetic).
%
% Again, I did have a test file, but it was not incorporated in my test suite,
% so I discovered the problem accidentally by compiling all files in an archive.
%\end{lverb}
%    \begin{macrocode}
\def\xintthespaceseparated_c !#1!#2^{#1}%
%    \end{macrocode}
% \subsection{Hooks into the numeric parser for usage by the
% \cshnolabel{xintdeffunc} symbolic parser}
%\begin{lverb}
% This is new with 1.3 and considerably refactored at 1.4. See
% «Mysterious stuff».
%\end{lverb}
%    \begin{macrocode}
\let\XINT:NEhook:f:one:from:one\expandafter
\let\XINT:NEhook:f:one:from:one:direct\empty
\let\XINT:NEhook:f:one:from:two\expandafter
\let\XINT:NEhook:f:one:from:two:direct\empty
\let\XINT:NEhook:x:one:from:two\empty
\let\XINT:NEhook:f:one:and:opt:direct      \empty
\let\XINT:NEhook:f:tacitzeroifone:direct   \empty
\let\XINT:NEhook:f:iitacitzeroifone:direct \empty
\let\XINT:NEhook:x:select:obey\empty
\let\XINT:NEhook:x:listsel\empty
\let\XINT:NEhook:f:reverse\empty
%    \end{macrocode}
%\begin{lverb}
% At 1.4 it was \def\XINT:NEhook:f:from:delim:u #1#2^{#1#2^}
% which was trick to allow automatic unpacking of a nutple argument
% to multi-arguments functions such as gcd() or max(). But this
% sacrificied the usage with a single numeric argument.
%\end{lverb}
% \changed{1.4i}
%\begin{lverb}
% More sophisticated code to check if the argument ople
% was actually a single number. Notice that this forces numeric
% types to actually use catcode 12 tokens, and polexpr diverges
% a bit using P, but actually always testing with \if not \ifx.
%
% This is used by gcd(), lcm(), max(), min(), `+`(), `*`(), all(), any(),
% xor().
%
% The nil and None will give the same result due to the initial brace
% stripping done by \XINT:NEhook:f:from:delim:u (there was even a prior brace
% stripping to provide the #2 which is empty here for the nil and {} for the
% None).
%\end{lverb}
%    \begin{macrocode}
\def\XINT:NEhook:f:from:delim:u #1#2^%
{%
    \expandafter\XINT_fooof_checkifnumber\expandafter#1\string#2^%
}%
\def\XINT_fooof_checkifnumber#1#2%
{%
    \expandafter#1%
    \romannumeral0\expanded{\if ^#2^\else
              \if\bgroup#2\noexpand\XINT_fooof_no\else
              \noexpand\XINT_fooof_yes#2\fi\fi}%
}%
\def\XINT_fooof_yes#1^{{#1}^}%
\def\XINT_fooof_no{\expandafter{\iffalse}\fi}%
%    \end{macrocode}
% \changed{1.4i}
%\begin{lverb}
% Same changes as for the other multiple arguments functions,
% making them again usable with a single numeric input.
%
% Was at 1.4 \def\XINT:NEhook:f:noeval:from:braced:u#1#2^{#1{#2}} which
% is not compatible with a single numeric input.
%
% Used by len(), first(), last() but it is a potential implementation bug that
% the three share this as the location where expansion takes places is one
% level deeper for the support macro of len().
%
% The None is here handled as nil, i.e. it is unpacked, which is fine
% as the documentations says nutples are unpacked.
%
%\end{lverb}
%    \begin{macrocode}
\def\XINT:NEhook:f:LFL #1{\expandafter#1\expandafter}%
\def\XINT:NEhook:r:check #1^%
{%
    \expandafter\XINT:NEhook:r:check_a\string#1^%
}%
\let\XINT:NEsaved:r:check \XINT:NEhook:r:check
\def\XINT:NEhook:r:check_a #1%
{%
    \if ^#1\xint_dothis\xint_c_\fi
    \if\bgroup#1\xint_dothis\XINT:NEhook:r:check_no\fi
    \xint_orthat{\XINT:NEhook:r:check_yes#1}%
}%
\def\XINT:NEhook:r:check_no
{%
    \expandafter\XINT:NEhook:r:check_no_b
    \expandafter\xint_c_\expandafter{\iffalse}\fi
}%
\def\XINT:NEhook:r:check_no_b#1^{#1}%
\def\XINT:NEhook:r:check_yes#1^{\xint_c_{#1}}%
\let\XINT:NEhook:branch\expandafter
\let\XINT:NEhook:seqx\empty
\let\XINT:NEhook:iter\expandafter
\let\XINT:NEhook:opx\empty
\let\XINT:NEhook:rseq\expandafter
\let\XINT:NEhook:iterr\expandafter
\let\XINT:NEhook:rrseq\expandafter
\let\XINT:NEhook:x:toblist\empty
\let\XINT:NEhook:x:mapwithin\empty
\let\XINT:NEhook:x:ndmapx\empty
%    \end{macrocode}
% \subsection{\csh{XINT_expr_getnext}: fetch some value then an operator and
% present them to last waiter with the found operator precedence, then
% the operator, then the value}
%\begin{lverb}
% Big change in 1.1, no attempt to detect braced stuff anymore as the
% [N] notation is implemented otherwise. Now, braces should not be used at
% all; one level removed, then \romannumeral-`0 expansion.
%
% Refactored at 1.4 to put expansion of \XINT_expr_getop after the fetched
% number, thus avoiding it to have to fetch it (which could happen then
% multiple times, it was not really important when it was only one token in
% pre-1.4 xintexpr).
%
% Allow \xintexpr\relax at 1.4.
%
% Refactored at 1.4 the articulation
% \XINT_expr_getnext/XINT_expr_func/XINT_expr_getop. For some legacy reason
% the first token picked by getnext was soon turned to catcode 12 The next
% ones after the first were not a priori stringified but the first token was,
% and this made allowing things such as \xintexpr\relax, \xintexpr,,\relax,
% [], 1+(), [:] etc... complicated and requiring each time specific measures.
%
% The \expandafter chain in \XINT_expr_put_op_first is an overhead related
% to an 1.4 attempt, the "varvalue" mechanism. I.e.: expansion of
% \XINT_expr_var_foo is {\XINT_expr_varvalue_foo } and then for example
% \XINT_expr_varvalue_foo expands to {4/1[0]}.  The mechanism was originally
% conceived to have only one token with idea its makes things faster. But the
% xintfrac macros break with syntax such as \xintMul\foo\bar and \foo
% expansion giving braces. So at 1.4c I added here these \expandafter, but
% this is REALLY not satisfactory because the \expandafter are needed it seems
% only for this variable "varvalue" mechanism.
%
% See also the discussion of \XINT_expr_op__ which distinguishes variables from
% functions.
%
% After a 1.4g refactoring it would be possible to drop here the
% \expandafter if the \XINT_expr_var_foo macro was defined to f-expand to
% {actual expanded value (as ople)} for example explicit {{3}}. I have to
% balance the relative weights of doing always the \expandafter but they are
% needed only for the case the value was encapsulated in a variable, and of
% never doing the \expandafter and ensure f-expansion of the _var_foo gives
% explicit value (now that the refactoring let it be f-expanded, and the case
% of fake variables omit and abort in particular was safely separated instead
% of being treated like other and imposing restrictions on general variable
% handling), and then there is the overhead of possibly moving around many
% digits in the #1 of \XINT_expr_put_op_first.
%
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_getnext #1%
{%
    \expandafter\XINT_expr_put_op_first\romannumeral`&&@%
    \expandafter\XINT_expr_getnext_a\romannumeral`&&@#1%
}%
\def\XINT_expr_put_op_first #1#2#3{%
     \expandafter#2\expandafter#3\expandafter{#1}%
}%
\def\XINT_expr_getnext_a #1%
{%
    \ifx\relax #1\xint_dothis\XINT_expr_foundprematureend\fi
    \ifx\XINTfstop#1\xint_dothis\XINT_expr_subexpr\fi
    \ifcat\relax#1\xint_dothis\XINT_expr_countetc\fi
    \xint_orthat{}\XINT_expr_getnextfork #1%
}%
\def\XINT_expr_foundprematureend\XINT_expr_getnextfork #1{{}\xint_c_\relax}%
\def\XINT_expr_subexpr #1.#2%
{%
    \expanded{\xint_noxpd{{#2}}\expandafter}\romannumeral`&&@\XINT_expr_getop
}%
%    \end{macrocode}
%
% The "fetch as number" must be avoided for those cases where \cs{number}
% can not be hoped to need only one token.  Hence the liste of exceptions.
%
% \changed{1.2}
% Add \cs{ht}, \cs{dp}, \cs{wd} and the e\TeX{} font related primitives.
%
% \changed{1.4}
% Refactor for readability to avoid huge amounts of \cs{fi}'s.
%
% \changed{1.4g}
% Check also for  \cs{catcode} so that |\xinteval{\catcode`@}| does not crash.
% But later I observed that |\fpeval{\catcode`@}| does crash, so in retrospect
% I wonder if I should have added the overhead.
%
% \changed[2025/08/09]{1.4n}
% Added \cs{_catcode} to the list for Op\TeX.  This means though that an
% undefined token with other engines will be expanded via \cs{number}...
%    \begin{macrocode}
\def\XINT_expr_countetc\XINT_expr_getnextfork#1%
{%
    \if0\ifx\count#11\fi
        \ifx\numexpr#11\fi
        \ifx\catcode#11\fi
        \ifx\dimen#11\fi
        \ifx\dimexpr#11\fi
        \ifx\skip#11\fi
        \ifx\glueexpr#11\fi
        \ifx\fontdimen#11\fi
        \ifx\ht#11\fi
        \ifx\dp#11\fi
        \ifx\wd#11\fi
        \ifx\fontcharht#11\fi
        \ifx\fontcharwd#11\fi
        \ifx\fontchardp#11\fi
        \ifx\fontcharic#11\fi
        \ifx\_catcode#11\fi
       0\expandafter\XINT_expr_fetch_as_number\fi
   \expandafter\XINT_expr_getnext_a\number #1%
}%
\def\XINT_expr_fetch_as_number
    \expandafter\XINT_expr_getnext_a\number #1%
{%
    \expanded{{{\number#1}}\expandafter}\romannumeral`&&@\XINT_expr_getop
}%
%    \end{macrocode}
%\begin{lverb}
% This is the key initial dispatch component. It has been refactored at
% 1.4g to give priority to identifying letter and digit tokens first.  It
% thus combines former \XINT_expr_getnextfork, \XINT_expr_scan_nbr_or_func and
% \XINT_expr_scanfunc. A branch of the latter having become
% \XINT_expr_startfunc. The handling of non-catcode 11 underscore _ has
% changed: it is now skipped completely like the +. Formerly it would cause an
% infinite loop because it triggered first insertion of a nil variable, (being
% confused with a possible operator at a location where one looks for a
% value), then tacit multiplication (being now interpreted as starting some
% name), and then it came back to getnextfork creating loop. The @ of catcode
% 12 could have caused the same issue if it was not handled especially because
% it is used in the syntax as special variable for recursion hence was
% recognized even if of catcode 12. Anyway I could have handled the _ like the
% @, to avoid this problem of infinite loop with a non-letter underscore used
% as first character but decided finally to have it be ignored (it is already
% ignored if among digits, but it can be a constituent of a function of
% variable name). It is not ignored of course if of catcode 11. It may then
% start a variable or function name, but only for use by the package (by
% polexpr for example), not by users.
%
% Then the matter is handed over to specialized routines: gathering digits
% of a number (inclusive of a decimal mark, an exponential part) or letters
% of a function or variable.  And we have to intercept some tokens to implement
% various functionalities.
%
% In each dothis/orthat structure, the first encountered branches are usually
% handled slower than the next, because \if..\fi test cost less than grabbing
% tokens. The exception is in the first one where letters pass through
% slightly faster than digits, presumably because the \ifnum test is more
% costly.  Prior to this 1.4g refactoring the case of a starting letter of
% a variable or function name was handled last, it is now handled first.  Now,
% this is only first letter...
%
% Here are the various possibilities in order that they are appear below
% (the indicative order of speed of treatment is given as a number).
%
%( -1 tokens of catcode letter start a variable or function name
%: -2 digits (I apply \string for the test, but I will have to review,&
%    it seems natural anyhow to require digits to be of catcode 12 and&
%    this is in fact basically done by the package, \numexpr does not&
%    work if not the case.),
%: -7 support for Python-like * "unpacking" unary operator (added at 1.4),
%: -6 support for [ as opener for the [..] nutple constructor (1.4),
%: -5 support for the minus as unary operator of variable precedence,
%: -4 support for @ as first character of special variables even if not letter,
%: -3 support for opening parentheses (possibly triggering tacit multiplication),
%: -13 support for skipping over ignored + character,
%: -12 support for numbers starting with a decimal point,
%: -11 support for the `+`() and `*`() functions,
%: -10 support for the !() function,
%: -9 support for the ?() function,
%: -8 support for " for input of hexadecimal numbers and (1.4n) of ' for octal numbers.
%: -17 support for \xintdeffunc via special handling of # token,
%: -16 support for ignoring _ if not of catcode 11 and at start of&
%    numbers or names (this 1.4g change fixes \xinteval{_4} creating&
%    infinite loop)
%: -15 support for inserting "nil" in front of operators, as needed in particular&
%    for the Python slicing syntax. This covers the comma, the :, the ] and&
%    the ) and also the ; although I don't think using ; to delimit nil is licit.
%: -14 support for inserting 0 as missing value if / or ^ are encountered&
%    directly.  This 1.4g changes avoids \xinteval{/3} causing&
%    unrecoverable low level errors from \xintDiv receiving only one argument.
%    I did not see here other bad syntax to protect.
%)
%
% The handling of "nil" insertion penalizes Python slicing but anyway time
% differences in the 14-15-16-17 group are less than
% 5$%. The alternative will be
% to do some positive test for the targets (:, ], the comma and closing
% parenthesis) and do this in the prior group but this then penalizes
% others. Anyway. This is all negligible compared to actual computations...
%
% Note: the above may not be in sync with code as it is extremely
% time-consuming to maintain correspondence in case of re-factoring.
%\end{lverb}
%\odef\MakePrivateLetters{\MakePrivateLetters\catcode`` 11 }^^A
%    \begin{macrocode}
\def\XINT_expr_getnextfork #1%
{%
    \ifcat a#1\xint_dothis\XINT_expr_startfunc\fi
    \ifnum \xint_c_ix<1\string#1 \xint_dothis\XINT_expr_startint\fi
    \xint_orthat\XINT_expr_getnextfork_a #1%
}%
\def\XINT_expr_getnextfork_a #1%
{%
    \if#1*\xint_dothis {{}\xint_c_ii^v 0}\fi
    \if#1[\xint_dothis {{}\xint_c_ii^v \XINT_expr_itself_obracket}\fi
    \if#1-\xint_dothis {{}{}-}\fi
    \if#1@\xint_dothis{\XINT_expr_startfunc @}\fi
    \if#1(\xint_dothis {{}\xint_c_ii^v (}\fi
    \xint_orthat{\XINT_expr_getnextfork_b#1}%
}%
\catcode96 11 % `
\def\XINT_expr_getnextfork_b #1%
{%
    \if#1+\xint_dothis \XINT_expr_getnext_a\fi
    \if#1.\xint_dothis \XINT_expr_startdec\fi
    \if#1`\xint_dothis {\XINT_expr_onliteral_`}\fi
    \if#1!\xint_dothis {\XINT_expr_startfunc !}\fi
    \if#1?\xint_dothis {\XINT_expr_startfunc ?}\fi
    \if#1'\xint_dothis \XINT_expr_startoct\fi
    \if#1"\xint_dothis \XINT_expr_starthex\fi
    \xint_orthat{\XINT_expr_getnextfork_c#1}%
}%
\def\XINT_tmpa #1{%
\def\XINT_expr_getnextfork_c ##1%
{%
    \if##1#1\xint_dothis \XINT_expr_getmacropar\fi
    \if##1_\xint_dothis \XINT_expr_getnext_a\fi
    \if0\if##1/1\fi\if##1^1\fi0\xint_dothis{\XINT_expr_insertnil##1}\fi
    \xint_orthat{\XINT_expr_missing_arg##1}%
}%
}\expandafter\XINT_tmpa\string#%
%    \end{macrocode}
%\begin{lverb}
% The ` syntax is here used for special constructs like `+`(..), `*`(..) where
% + or * will be treated as functions. Current implementation picks only one
% token (could have been braced stuff), here it will be + or *, and via
% \XINT_expr_op_` this then becomes a suitable
% \XINT_{expr|iiexpr|flexpr}_func_+ (or *). Documentation says to use
% `+`(...), but `+(...) is also valid. The opening parenthesis must be there,
% it is not allowed to require some expansion.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_onliteral_` #1#2({{#1}\xint_c_ii^v `}%
\catcode96 12 % `
%    \end{macrocode}
% \let\MakePrivateLetters\xintexprMakePrivateLetters
%\begin{lverb}
%  Prior to 1.4g, I was using a \lowercase technique to insert the
% catcode 12 #, but this is a bit risky when one does not ensure a priori control of all
% lccodes.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_tmpa #1{%
\def\XINT_expr_getmacropar ##1%
{%
    \expandafter{\expandafter{\expandafter#1\expandafter
    ##1\expandafter}\expandafter}\romannumeral`&&@\XINT_expr_getop
}%
}\expandafter\XINT_tmpa\string#%
\def\XINT_expr_insertnil #1%
{%
    \expandafter{\expandafter}\romannumeral`&&@\XINT_expr_getop_a#1%
}%
\def\XINT_expr_missing_arg#1%
{%
    \expanded{\XINT_expandableerror
              {Expected a value, got nothing before `#1'.
               Inserting 0.}{{0}}\expandafter}%
    \romannumeral`&&@\XINT_expr_getop_a#1%
}%
%    \end{macrocode}
% \subsection{\csh{XINT_expr_startint}}
% \localtableofcontents
% Following comments are in part OBSOLETE as the code was refactored
% at some stage to use \cs{expanded}.
%
%\begin{lverb}
% 1.2 release has replaced chains of \romannumeral-`0 by \csname
% governed expansion. Thus there is no more the limit at about 5000 digits for
% parsed numbers.
%
% In order to avoid having to lock and unlock in succession to handle the
% scientific part and adjust the exponent according to the number of digits of
% the decimal part, the parsing of this decimal part counts on the fly the
% number of digits it encounters.
%
% OBSOLETE START
% There is some slight annoyance with \xintiiexpr which should never be given
% a [n] inside its \csname.=<digits>\endcsname storage of numbers (because its
% arithmetic uses the ii macros which know nothing about the [N] notation).
% Hence if the parser has only seen digits when hitting something else than
% the dot or e (or E), it will not insert a [0]. Thus we very slightly
% compromise the efficiency of \xintexpr and \xintfloatexpr in order to be
% able to share the same code with \xintiiexpr.
%
% Indeed, the parser at this location is completely common to all, it does not
% know if it is working inside \xintexpr or \xintiiexpr. On the other hand if
% a dot or a e (or E) is met, then the (common) parser has no scrupules ending
% this number with a [n], this will provoke an error later if that was within
% an \xintiiexpr, as soon as an arithmetic macro is used.
% OBSOLETE END
%
% calx: the scanner is common to the three parsers; it ends a number by
% a fake operator of precedence 22 (above every right precedence), which
% the waiting operator of the running parser executes at once through
% \XINT_<p>_op_<char>. Integer exits (digits only, zeros, an integer
% followed by .., integer hexadecimal, octal, binary): ^^B; the
% receivers append [0] (\xintexpr, \xintfloatexpr) or build the native
% integer M (\xintiiexpr). Decimal mark or exponent (and fractional
% hexadecimal...): the exponent N is handed to ^^C outside the value
% braces; the receivers append [N] (\xintexpr, \xintfloatexpr) or check
% for an integer value (\xintiiexpr, \CALX_iilit). The receivers call
% \XINT_expr_getop for the real operator.
%
% As the gathered numbers have no spaces, no pluses, no minuses, the only
% remaining issue is with leading zeroes, which are discarded on the fly. The
% hexadecimal numbers leading zeroes are stripped in a second stage by the
% \xintHexToDec macro.
%
% With 1.2, \xinttheexpr . \relax does not work anymore (it did in earlier
% releases). There must be digits either before or after the decimal mark. Thus
% both \xinttheexpr 1.\relax and \xinttheexpr .1\relax are legal.
%
% Attention at this location #1 was of catcode 12 in all versions prior to
% 1.4.
%
% We assume anyhow that catcodes of digits are 12...
%\end{lverb}
%
% Style of location of the braces around replacement text varies,
% but is kept as is to avoid wasting time on cosmetics.
%
% \changed[2025/09/01]{1.4n} Support for the |0b|, |0o| and |0x| prefixes!
% Implementation of this extension of the syntax was very easy.
% I may have thought of it briefly in the past but presumed it would
% break things.
%
% This change seems to only break stuff such as |+0bar+3| with |bar| a
% variable being interpreted |+0*bar+3| (tacit multiplication) and will cause
% the parser to raise then an error message, but this is not very serious
% breaking change.
%
% Supporting |0b| meant that like for octal |1.4n| needed to add the
% needed support macros, which opens this TODO: perhaps try to share
% code between binary, octal, hexadecimal more than currently.
%    \begin{macrocode}
\def\XINT_expr_startint #1%
{%
    \if #10\expandafter\XINT_expr_gobz_a\else
           \expandafter\XINT_expr_scanint_a\fi #1%
}%
\def\XINT_expr_scanint_a #1#2%
    {\expanded\bgroup{{\iffalse}}\fi #1% spare a \string
     \expandafter\XINT_expr_scanint_main\romannumeral`&&@#2}%
\def\XINT_expr_gobz_a #1#2%
    {\expandafter\XINT_expr_gobz_b\romannumeral`&&@#2}%
%    \end{macrocode}
% Perhaps use \cs{if} and not \cs{ifx} tests here?
%    \begin{macrocode}
\def\XINT_expr_gobz_b #1%%
{%
    \ifx b#1\xint_dothis \XINT_expr_startbin \fi
    \ifx o#1\xint_dothis \XINT_expr_startoct \fi
    \ifx x#1\xint_dothis \XINT_expr_starthex \fi
    \xint_orthat {\XINT_expr_gobz_c #1}%
}%
\def\XINT_expr_gobz_c #1%
    {\expanded\bgroup{{\iffalse}}\fi
     \expandafter\XINT_expr_gobz_scanint_main#1}%
\def\XINT_expr_startdec #1%
    {\expanded\bgroup{{\iffalse}}\fi
     \expandafter\XINT_expr_scandec_a\romannumeral`&&@#1}%
%    \end{macrocode}
% \subsubsection{Integral part (skipping zeroes)}
%\begin{lverb}
% 1.2 has modified the code to give highest priority to digits, the
% accelerating impact is non-negligeable. I don't think the doubled \string is
% a serious penalty.
%
% (reference to \string is obsolete: it is only used in the test but the
% tokens are not submitted to \string anymore)
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_scanint_main #1%
{%
    \ifcat \relax #1\expandafter\XINT_expr_scanint_hit_cs \fi
    \ifnum\xint_c_ix<1\string#1 \else\expandafter\XINT_expr_scanint_next\fi
    #1\XINT_expr_scanint_again
}%
\def\XINT_expr_scanint_again #1%
{%
    \expandafter\XINT_expr_scanint_main\romannumeral`&&@#1%
}%
%    \end{macrocode}
% |1.4f| had |_getop| here, but let's jump directly to |_getop_a|.
%    \begin{macrocode}
\def\XINT_expr_scanint_hit_cs \ifnum#1\fi#2\XINT_expr_scanint_again
{%
    \iffalse{{{\fi}}}\xint_c_xxii&&B#2%
}%
%    \end{macrocode}
%\begin{lverb}
% With 1.2d the tacit multiplication in front of a variable name or
% function name is now done with a higher precedence, intermediate between the
% common one of * and / and the one of ^. Thus x/2y is like x/(2y), but x^2y
% is like x^2*y and 2y! is not (2y)! but 2*y!.
%
% Finally, 1.2d has moved away from the _scan macros all the business of the
% tacit multiplication in one unique place via \XINT_expr_getop. For this, the
% ending token is not first given to \string as was done earlier before
% handing over back control to \XINT_expr_getop. Earlier we had to identify
% the catcode 11 ! signaling a sub-expression here. With no \string applied
% we can do it in \XINT_expr_getop. As a corollary of this displacement,
% parsing of big numbers should be a tiny bit faster now.
%
% Extended for 1.2l to ignore underscore character _ if encountered within
% digits; so it can serve as separator for better readability.
%\end{lverb}
%
%\begin{lverb}
% It is not obvious at 1.4 to support [] for three things: packing,
% slicing, ... and raw xintfrac syntax A/B[N]. The only good way would be to
% actually really separate completely \xintexpr, \xintfloatexpr and
% \xintiiexpr code which would allow to handle both / and [] from A/B[N] as we
% handle e and E. But triplicating the code is something I need to think
% about. It is not possible as in pre 1.4 to consider [ only as an operator of
% same precedence as multiplication and division which was the way we did
% this, but we can use the technique of fake operators. Thus we intercept
% hitting a [ here, which is not too much of a problem as anyhow we dropped
% temporarily 3*[1,2,3]+5 syntax so we don't have to worry that 3[1,2,3]
% should do tacit multiplication. I think only way in future will be to really
% separate the code of the three parsers (or drop entirely support for A/B[N];
% as 1.4 has modified output of \xinteval to not use this notation this is not
% too dramatic).
%
% Anyway we find a way to inject here the former handling of [N], which will
% use a delimited macro to directly fetch until the closing]. We do still need
% some fake operator because A/B[N] is (A/B) times 10^N and the /B is allowed
% to be missing. We hack this using the $textdollar$space which is not used currently as
% operator elsewhere in the syntax and need to hook into \XINT_expr_getop_b.
% No finally I use the null char. It must be of catcode 12.
%
% 1.4f had _getop here, but let's jump directly to _getop_a.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_scanint_next #1\XINT_expr_scanint_again
{%
    \if    [#1\xint_dothis\XINT_expr_rawxintfrac\fi
    \if    _#1\xint_dothis\XINT_expr_scanint_again\fi
    \if    e#1\xint_dothis{\iffalse{{\fi}}\xint_c_xxii&&C%
                           \the\numexpr0\XINT_expr_scanexp_a +}\fi
    \if    E#1\xint_dothis{\iffalse{{\fi}}\xint_c_xxii&&C%
                           \the\numexpr0\XINT_expr_scanexp_a +}\fi
    \if    .#1\xint_dothis{\XINT_expr_startdec_a .}\fi
    \xint_orthat
    {\iffalse{{{\fi}}}\xint_c_xxii&&B#1}%
}%
\def\XINT_expr_rawxintfrac
{%
    [0]\iffalse{{{\fi}}\expandafter}%
       \csname XINT_expr_precedence_&&@\endcsname&&@%
}%
\def\XINT_expr_gobz_scanint_main #1%
{%
    \ifcat \relax #1\expandafter\XINT_expr_gobz_scanint_hit_cs\fi
    \ifnum\xint_c_x<1\string#1 \else\expandafter\XINT_expr_gobz_scanint_next\fi
    #1\XINT_expr_scanint_again
}%
\def\XINT_expr_gobz_scanint_again #1%
{%
    \expandafter\XINT_expr_gobz_scanint_main\romannumeral`&&@#1%
}%
%    \end{macrocode}
% |1.4f| had |_getop| here, but let's jump directly to |_getop_a|.
%    \begin{macrocode}
\def\XINT_expr_gobz_scanint_hit_cs\ifnum#1\fi#2\XINT_expr_scanint_again
{%
    0\iffalse{{{\fi}}}\xint_c_xxii&&B#2%
}%
\def\XINT_expr_gobz_scanint_next #1\XINT_expr_scanint_again
{%
    \if    [#1\xint_dothis{\expandafter0\XINT_expr_rawxintfrac}\fi
    \if    _#1\xint_dothis\XINT_expr_gobz_scanint_again\fi
    \if    e#1\xint_dothis{0\iffalse{{\fi}}\xint_c_xxii&&C%
                           \the\numexpr0\XINT_expr_scanexp_a +}\fi
    \if    E#1\xint_dothis{0\iffalse{{\fi}}\xint_c_xxii&&C%
                           \the\numexpr0\XINT_expr_scanexp_a +}\fi
    \if    .#1\xint_dothis{\XINT_expr_gobz_startdec_a .}\fi
    \if    0#1\xint_dothis\XINT_expr_gobz_scanint_again\fi
    \xint_orthat
    {0\iffalse{{{\fi}}}\xint_c_xxii&&B#1}%
}%
%    \end{macrocode}
% \subsubsection{Fractional part}
%\begin{lverb}
% Annoying duplication of code to allow 0. as input.
%
% 1.2a corrects a very bad bug in 1.2 \XINT_expr_gobz_scandec_b which should
% have stripped leading zeroes in the fractional part but didn't; as a result
% \xinttheexpr 0.01\relax returned 0 =:-((( Thanks to Kroum Tzanev who
% reported the issue. Does it improve things if I say the bug was introduced
% in 1.2, it wasn't present before ?
%
% 1.4f had _getop here, but let's jump directly to _getop_a.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_startdec_a .#1%
{%
    \expandafter\XINT_expr_scandec_a\romannumeral`&&@#1%
}%
\def\XINT_expr_scandec_a #1%
{%
    \if .#1\xint_dothis{\iffalse{{{\fi}}}\xint_c_xxii&&B..}\fi
    \xint_orthat {\XINT_expr_scandec_main 0.#1}%
}%
\def\XINT_expr_gobz_startdec_a .#1%
{%
    \expandafter\XINT_expr_gobz_scandec_a\romannumeral`&&@#1%
}%
\def\XINT_expr_gobz_scandec_a #1%
{%
    \if .#1\xint_dothis
    {0\iffalse{{{\fi}}}\xint_c_xxii&&B..}\fi
    \xint_orthat {\XINT_expr_gobz_scandec_main 0.#1}%
}%
\def\XINT_expr_scandec_main #1.#2%
{%
    \ifcat \relax #2\expandafter\XINT_expr_scandec_hit_cs\fi
    \ifnum\xint_c_ix<1\string#2 \else\expandafter\XINT_expr_scandec_next\fi
    #2\expandafter\XINT_expr_scandec_again\the\numexpr #1-\xint_c_i.%
}%
\def\XINT_expr_scandec_again #1.#2%
{%
    \expandafter\XINT_expr_scandec_main
    \the\numexpr #1\expandafter.\romannumeral`&&@#2%
}%
%    \end{macrocode}
% |1.4f| had |_getop| here, but let's jump directly to |_getop_a|.
%    \begin{macrocode}
\def\XINT_expr_scandec_hit_cs\ifnum#1\fi
    #2\expandafter\XINT_expr_scandec_again\the\numexpr#3-\xint_c_i.%
{%
    \iffalse{{{\fi}}}\xint_c_xxii&&C#3]#2%
}%
\def\XINT_expr_scandec_next #1#2\the\numexpr#3-\xint_c_i.%
{%
    \if    _#1\xint_dothis{\XINT_expr_scandec_again#3.}\fi
    \if    e#1\xint_dothis{\iffalse{{\fi}}\xint_c_xxii&&C%
                           \the\numexpr#3\XINT_expr_scanexp_a +}\fi
    \if    E#1\xint_dothis{\iffalse{{\fi}}\xint_c_xxii&&C%
                           \the\numexpr#3\XINT_expr_scanexp_a +}\fi
    \xint_orthat
    {\iffalse{{{\fi}}}\xint_c_xxii&&C#3]#1}%
}%
\def\XINT_expr_gobz_scandec_main #1.#2%
{%
    \ifcat \relax #2\expandafter\XINT_expr_gobz_scandec_hit_cs\fi
    \ifnum\xint_c_ix<1\string#2
          \else\expandafter\XINT_expr_gobz_scandec_next\fi
    \if0#2\expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo\fi
    {\expandafter\XINT_expr_gobz_scandec_main}%
    {#2\expandafter\XINT_expr_scandec_again}\the\numexpr#1-\xint_c_i.%
}%
%    \end{macrocode}
% |1.4f| had |_getop| here, but let's jump directly to |_getop_a|.
%    \begin{macrocode}
\def\XINT_expr_gobz_scandec_hit_cs \ifnum#1\fi\if0#2#3\xint_c_i.%
{%
    0\iffalse{{{\fi}}}\xint_c_xxii&&B#2%
}%
\def\XINT_expr_gobz_scandec_next\if0#1#2\fi #3\numexpr#4-\xint_c_i.%
{%
    \if    _#1\xint_dothis{\XINT_expr_gobz_scandec_main #4.}\fi
    \if    e#1\xint_dothis{0\iffalse{{\fi}}\xint_c_xxii&&C%
                           \the\numexpr0\XINT_expr_scanexp_a +}\fi
    \if    E#1\xint_dothis{0\iffalse{{\fi}}\xint_c_xxii&&C%
                           \the\numexpr0\XINT_expr_scanexp_a +}\fi
    \xint_orthat
    {0\iffalse{{{\fi}}}\xint_c_xxii&&B#1}%
}%
%    \end{macrocode}
% \subsubsection{Scientific notation}
%\begin{lverb}
% Some pluses and minuses are allowed at the start of the scientific
% part, however not later, and no parenthesis.
%
% ATTENTION! 1e\numexpr2+3\relax or 1e\xintiexpr i\relax, i=1..5
% are not allowed and 1e1\numexpr2\relax does 1e1 * \numexpr2\relax.
% Use \the\numexpr, \xinttheiexpr, etc...
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_scanexp_a #1#2%
{%
    #1\expandafter\XINT_expr_scanexp_main\romannumeral`&&@#2%
}%
\def\XINT_expr_scanexp_main #1%
{%
    \ifcat \relax #1\expandafter\XINT_expr_scanexp_hit_cs\fi
    \ifnum\xint_c_ix<1\string#1 \else\expandafter\XINT_expr_scanexp_next\fi
    #1\XINT_expr_scanexp_again
}%
\def\XINT_expr_scanexp_again #1%
{%
    \expandafter\XINT_expr_scanexp_main_b\romannumeral`&&@#1%
}%
%    \end{macrocode}
% |1.4f| had |_getop| here, but let's jump directly to |_getop_a|.
%    \begin{macrocode}
\def\XINT_expr_scanexp_hit_cs\ifnum#1\fi#2\XINT_expr_scanexp_again
{%
    ]\iffalse{\fi}#2%
}%
\def\XINT_expr_scanexp_next #1\XINT_expr_scanexp_again
{%
    \if    _#1\xint_dothis  \XINT_expr_scanexp_again   \fi
    \if    +#1\xint_dothis {\XINT_expr_scanexp_a +}\fi
    \if    -#1\xint_dothis {\XINT_expr_scanexp_a -}\fi
    \xint_orthat
    {]\iffalse{\fi}#1}%
}%
\def\XINT_expr_scanexp_main_b #1%
{%
    \ifcat \relax #1\expandafter\XINT_expr_scanexp_hit_cs_b\fi
    \ifnum\xint_c_ix<1\string#1 \else\expandafter\XINT_expr_scanexp_next_b\fi
    #1\XINT_expr_scanexp_again_b
}%
%    \end{macrocode}
% |1.4f| had |_getop| here, but let's jump directly to |_getop_a|.
%    \begin{macrocode}
\def\XINT_expr_scanexp_hit_cs_b\ifnum#1\fi#2\XINT_expr_scanexp_again_b
{%
    ]\iffalse{\fi}#2%
}%
\def\XINT_expr_scanexp_again_b #1%
{%
    \expandafter\XINT_expr_scanexp_main_b\romannumeral`&&@#1%
}%
\def\XINT_expr_scanexp_next_b #1\XINT_expr_scanexp_again_b
{%
    \if _#1\xint_dothis\XINT_expr_scanexp_again\fi
    \xint_orthat
    {]\iffalse{\fi}#1}%
}%
%    \end{macrocode}
% \subsubsection{Hexadecimal numbers}
%\begin{lverb}
% 1.2d has moved most of the handling of tacit multiplication to
% \XINT_expr_getop, but we have to do some of it here, because we apply
% \string before calling \XINT_expr_scanhexI_aa. I do not insert the *
% in \XINT_expr_scanhexI_a, because it is its higher precedence variant which
% will is expected, to do the same as when a non-hexadecimal number prefixes a
% sub-expression. Tacit multiplication in front of variable or function names
% will not work (because of this \string).
%
% Extended for 1.2l to ignore underscore character _ if encountered within
% digits.
%
% (some above remarks have been obsoleted for some long time, no more applied
% \string since 1.4)
%
% Notice that internal representation adds a [N] part only in case input
% used "DDD.dddd form, for compatibility with \xintiiexpr which is not
% compatible with such internal representation.
%
% At 1.4g a very long-standing bug was fixed: input such as "\foo broke the
% parser because (incredibly) the \foo token was picked up unexpanded and
% ended up as is in an \ifcat !
%
% Another long-standing bug was fixed at 1.4g: contrarily to the decimal case,
% here in the hexadecimal input leading zeros were not trimmed. This was ok,
% because formerly \xintHexToDec trimmed leading zeros, but at 1.2m 2017/07/31
% xintbinhex.sty was modified and this ceased being the case. But I forgot to
% upgrade the parser here at that time. Leading zeros would in many
% circumstances (presence of a fractional part, or \xintiiexpr context) lead
% to wrong results.  Leading zeros are now trimmed during input.
%
% Sadly this fix forgot the case of integer part being zero itself.
% So \xinteval{"0.0001»} produced 0 because of this oversight.
% Fixed in un-released 1.4q, soon superseded by 2.0a1.
%
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_hex_in #1.#2#3;%
{%
    \expanded{{{\if#2>%
      \xintHexToDec{#1}}}\xint_c_xxii&&B%
    \else
      \expandafter\CALX_rdx\the\numexpr
    \XINT_length_loop
    #3\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
       \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v
       \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye
    \relax.{#1#3}%
        \xinthextodec{100000625}4%
    \fi}%
}%
%    \end{macrocode}
%\begin{lverb}
% Syntax (inside the \expanded of the scanner exits; A the digits of the
% integer and fractional parts, k the number of fractional digits):
%(
%  \CALX_rdx k.{A}<conv>{b}<j>  ->  <A'5^(jk)>}}\xint_c_xxii<C><-jk>]
%)
% Fractional literal in radix 2^j (j = 4, 3, 1: hexadecimal, octal,
% binary). A' = <conv>{A} (\xinthextodec, \xintocttodec, \xintbintodec)
% is the integer of all the digits; the value is A' 2^(-jk) = A' 5^(jk)
% 10^(-jk). <b> is the native block of 5^j (100000625, 100000125,
% 100000005): A' 5^(jk) is calxint's \CALX_npowmul. The loop of
% \xintiNum (\XINT_num_loop, \XINT_num_cleanup) removes the leading
% zeros of A' (there are some when the integer part is zero: the
% conversions keep leading zeros of their input). The closing braces
% come from `\iffalse{{\fi}}`, as in the other exits of the scanner; <C>
% is the fake operator (character 3) of the decimal and exponent exits.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_rdx #1.#2#3#4#5%
{%
    \romannumeral0\CALX_npowmul#1.{#4}%
      {\expandafter\XINT_num_cleanup
       \the\numexpr\expandafter\XINT_num_loop\romannumeral0#3{#2}%
       \xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\Z}%
    \iffalse{{\fi}}\xint_c_xxii&&C\the\numexpr-#5*#1]%
}%
%    \end{macrocode}
%\begin{lverb}
% Let's not forget to grab-expand next token first as is normal rule
% of operation. Formerly called \XINT_expr_scanhex_I and had " upfront.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_starthex #1%
{%
    \expandafter\XINT_expr_hex_in\expanded\bgroup
    \expandafter\XINT_expr_scanhexIgobz_a\romannumeral`&&@#1%
}%
\def\XINT_expr_scanhexIgobz_a #1%
{%
    \ifcat #1\relax
      0.>;\iffalse{\fi\expandafter}\expandafter\xint_gobble_i\fi
    \XINT_expr_scanhexIgobz_aa #1%
}%
\def\XINT_expr_scanhexIgobz_aa #1%
{%
    \if\ifnum`#1>`0
       \ifnum`#1>`9
       \ifnum`#1>`@
       \ifnum`#1>`F
       0\else1\fi\else0\fi\else1\fi\else0\fi 1%
       \xint_dothis\XINT_expr_scanhexI_b
    \fi
    \if 0#1\xint_dothis\XINT_expr_scanhexIgobz_bgob\fi
    \if _#1\xint_dothis\XINT_expr_scanhexIgobz_bgob\fi
    \if .#1\xint_dothis\XINT_expr_scanhexIgobz_toII\fi
    \xint_orthat
     {\XINT_expandableerror
        {Expected hexadecimal digit, `_', or `.'. got `#1'. Using `0'.}%
      0.>;\iffalse{\fi}}%
    #1%
}%
\def\XINT_expr_scanhexIgobz_bgob #1#2%
{%
    \expandafter\XINT_expr_scanhexIgobz_a\romannumeral`&&@#2%
}%
\def\XINT_expr_scanhexIgobz_toII .#1%
{%
    0..\expandafter\XINT_expr_scanhexII_a\romannumeral`&&@#1%
}%
\def\XINT_expr_scanhexI_a #1%
{%
    \ifcat #1\relax
      .>;\iffalse{\fi\expandafter}\expandafter\xint_gobble_i\fi
    \XINT_expr_scanhexI_aa #1%
}%
\def\XINT_expr_scanhexI_aa #1%
{%
    \if\ifnum`#1>`/
       \ifnum`#1>`9
       \ifnum`#1>`@
       \ifnum`#1>`F
       0\else1\fi\else0\fi\else1\fi\else0\fi 1%
       \expandafter\XINT_expr_scanhexI_b
    \else
       \if _#1\xint_dothis{\expandafter\XINT_expr_scanhexI_bgob}\fi
       \if .#1\xint_dothis{\expandafter\XINT_expr_scanhexI_toII}\fi
       \xint_orthat {.>;\iffalse{\fi\expandafter}}%
    \fi
    #1%
}%
\def\XINT_expr_scanhexI_b #1#2%
{%
    #1\expandafter\XINT_expr_scanhexI_a\romannumeral`&&@#2%
}%
\def\XINT_expr_scanhexI_bgob #1#2%
{%
    \expandafter\XINT_expr_scanhexI_a\romannumeral`&&@#2%
}%
\def\XINT_expr_scanhexI_toII .#1%
{%
    ..\expandafter\XINT_expr_scanhexII_a\romannumeral`&&@#1%
}%
\def\XINT_expr_scanhexII_a #1%
{%
    \ifcat #1\relax\xint_dothis{;\iffalse{\fi}#1}\fi
    \xint_orthat {\XINT_expr_scanhexII_aa #1}%
}%
\def\XINT_expr_scanhexII_aa #1%
{%
    \if\ifnum`#1>`/
       \ifnum`#1>`9
       \ifnum`#1>`@
       \ifnum`#1>`F
       0\else1\fi\else0\fi\else1\fi\else0\fi 1%
       \expandafter\XINT_expr_scanhexII_b
    \else
       \if _#1\xint_dothis{\expandafter\XINT_expr_scanhexII_bgob}\fi
       \xint_orthat{;\iffalse{\fi\expandafter}}%
    \fi
    #1%
}%
\def\XINT_expr_scanhexII_b #1#2%
{%
    #1\expandafter\XINT_expr_scanhexII_a\romannumeral`&&@#2%
}%
\def\XINT_expr_scanhexII_bgob #1#2%
{%
    \expandafter\XINT_expr_scanhexII_a\romannumeral`&&@#2%
}%
%    \end{macrocode}
% \subsubsection{Octal numbers}
% \added{1.4n}
%
% The parsing goes exactly as with hexadecimal inputs,
% except that we require an octal digit when expected.
%
% TODO: think about perhaps sharing code between binary, octal, and
% hexadecimal.
%    \begin{macrocode}
\def\XINT_expr_oct_in #1.#2#3;%
{%
    \expanded{{{\if#2>%
      \xintOctToDec{#1}}}\xint_c_xxii&&B%
    \else
      \expandafter\CALX_rdx\the\numexpr
    \XINT_length_loop
    #3\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
       \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v
       \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye
    \relax.{#1#3}%
        \xintocttodec{100000125}3%
    \fi}%
}%
\def\XINT_expr_startoct #1%
{%
    \expandafter\XINT_expr_oct_in\expanded\bgroup
    \expandafter\XINT_expr_scanoctIgobz_a\romannumeral`&&@#1%
}%
\def\XINT_expr_scanoctIgobz_a #1%
{%
    \ifcat #1\relax
      0.>;\iffalse{\fi\expandafter}\expandafter\xint_gobble_i\fi
    \XINT_expr_scanoctIgobz_aa #1%
}%
%    \end{macrocode}
% Wondering if a bunch of \cs{if} tests comparing with 0 to 7 would
% not be more efficient here.  But testing would take some time
% I am not motivated enough to use for that.  In the code, also added
% at |1.4n| for parsing binary input, I do this, but of course then
% it was rather more natural to do.  But I did not test either comparing
% with style as here.
%    \begin{macrocode}
\def\XINT_expr_scanoctIgobz_aa #1%
{%
    \if\ifnum`#1>`0 \ifnum`#1>`7 0\else1\fi\else0\fi 1%
       \xint_dothis\XINT_expr_scanoctI_b
    \fi
    \if 0#1\xint_dothis\XINT_expr_scanoctIgobz_bgob\fi
    \if _#1\xint_dothis\XINT_expr_scanoctIgobz_bgob\fi
    \if .#1\xint_dothis\XINT_expr_scanoctIgobz_toII\fi
    \xint_orthat
     {\XINT_expandableerror
        {Expected an octal digit, `_', or `.'.  Got `#1'. Using `0'.}%
      0.>;\iffalse{\fi}}%
    #1%
}%
\def\XINT_expr_scanoctIgobz_bgob #1#2%
{%
    \expandafter\XINT_expr_scanoctIgobz_a\romannumeral`&&@#2%
}%
\def\XINT_expr_scanoctIgobz_toII .#1%
{%
    0..\expandafter\XINT_expr_scanoctII_a\romannumeral`&&@#1%
}%
\def\XINT_expr_scanoctI_a #1%
{%
    \ifcat #1\relax
      .>;\iffalse{\fi\expandafter}\expandafter\xint_gobble_i\fi
    \XINT_expr_scanoctI_aa #1%
}%
\def\XINT_expr_scanoctI_aa #1%
{%
    \if\ifnum`#1>`/ \ifnum`#1>`7 0\else1\fi\else0\fi 1%
       \expandafter\XINT_expr_scanoctI_b
    \else
       \if _#1\xint_dothis{\expandafter\XINT_expr_scanoctI_bgob}\fi
       \if .#1\xint_dothis{\expandafter\XINT_expr_scanoctI_toII}\fi
       \xint_orthat {.>;\iffalse{\fi\expandafter}}%
    \fi
    #1%
}%
\def\XINT_expr_scanoctI_b #1#2%
{%
    #1\expandafter\XINT_expr_scanoctI_a\romannumeral`&&@#2%
}%
\def\XINT_expr_scanoctI_bgob #1#2%
{%
    \expandafter\XINT_expr_scanoctI_a\romannumeral`&&@#2%
}%
\def\XINT_expr_scanoctI_toII .#1%
{%
    ..\expandafter\XINT_expr_scanoctII_a\romannumeral`&&@#1%
}%
\def\XINT_expr_scanoctII_a #1%
{%
    \ifcat #1\relax\xint_dothis{;\iffalse{\fi}#1}\fi
    \xint_orthat {\XINT_expr_scanoctII_aa #1}%
}%
\def\XINT_expr_scanoctII_aa #1%
{%
    \if\ifnum`#1>`/ \ifnum`#1>`7 0\else1\fi\else0\fi 1%
       \expandafter\XINT_expr_scanoctII_b
    \else
       \if _#1\xint_dothis{\expandafter\XINT_expr_scanoctII_bgob}\fi
       \xint_orthat{;\iffalse{\fi\expandafter}}%
    \fi
    #1%
}%
\def\XINT_expr_scanoctII_b #1#2%
{%
    #1\expandafter\XINT_expr_scanoctII_a\romannumeral`&&@#2%
}%
\def\XINT_expr_scanoctII_bgob #1#2%
{%
    \expandafter\XINT_expr_scanoctII_a\romannumeral`&&@#2%
}%
%    \end{macrocode}
% \subsubsection{Binary numbers}
% \added{1.4n}
% Analogous to hexadecimal or octal with some simpler tests for digits.
%    \begin{macrocode}
\def\XINT_expr_bin_in #1.#2#3;%
{%
    \expanded{{{\if#2>%
      \xintBinToDec{#1}}}\xint_c_xxii&&B%
    \else
      \expandafter\CALX_rdx\the\numexpr
    \XINT_length_loop
    #3\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:\xint:
       \xint_c_viii\xint_c_vii\xint_c_vi\xint_c_v
       \xint_c_iv\xint_c_iii\xint_c_ii\xint_c_i\xint_c_\xint_bye
    \relax.{#1#3}%
        \xintbintodec{100000005}1%
    \fi}%
}%
\def\XINT_expr_startbin #1%
{%
    \expandafter\XINT_expr_bin_in\expanded\bgroup
    \expandafter\XINT_expr_scanbinIgobz_a\romannumeral`&&@#1%
}%
\def\XINT_expr_scanbinIgobz_a #1%
{%
    \ifcat #1\relax
      0.>;\iffalse{\fi\expandafter}\expandafter\xint_gobble_i\fi
    \XINT_expr_scanbinIgobz_aa #1%
}%
\def\XINT_expr_scanbinIgobz_aa #1%
{%
    \if _#1\xint_dothis\XINT_expr_scanbinIgobz_bgob\fi
    \if .#1\xint_dothis\XINT_expr_scanbinIgobz_toII\fi
    \if 0#1\xint_dothis\XINT_expr_scanbinIgobz_bgob\fi
    \if 1#1\xint_dothis\XINT_expr_scanbinI_b\fi
    \xint_orthat
     {\XINT_expandableerror
        {Expected a binary digit, `_', or `.'. Got `#1'. Using `0'.}%
      0.>;\iffalse{\fi}}%
    #1%
}%
\def\XINT_expr_scanbinIgobz_bgob #1#2%
{%
    \expandafter\XINT_expr_scanbinIgobz_a\romannumeral`&&@#2%
}%
\def\XINT_expr_scanbinIgobz_toII .#1%
{%
    0..\expandafter\XINT_expr_scanbinII_a\romannumeral`&&@#1%
}%
\def\XINT_expr_scanbinI_a #1%
{%
    \ifcat #1\relax
      .>;\iffalse{\fi\expandafter}\expandafter\xint_gobble_i\fi
    \XINT_expr_scanbinI_aa #1%
}%
\def\XINT_expr_scanbinI_aa #1%
{%
    \if _#1\xint_dothis\XINT_expr_scanbinI_bgob\fi
    \if .#1\xint_dothis\XINT_expr_scanbinI_toII\fi
    \if 0#1\xint_dothis\XINT_expr_scanbinI_b\fi
    \if 1#1\xint_dothis\XINT_expr_scanbinI_b\fi
    \xint_orthat {.>;\iffalse{\fi}}%
    #1%
}%
\def\XINT_expr_scanbinI_b #1#2%
{%
    #1\expandafter\XINT_expr_scanbinI_a\romannumeral`&&@#2%
}%
\def\XINT_expr_scanbinI_bgob #1#2%
{%
    \expandafter\XINT_expr_scanbinI_a\romannumeral`&&@#2%
}%
\def\XINT_expr_scanbinI_toII .#1%
{%
    ..\expandafter\XINT_expr_scanbinII_a\romannumeral`&&@#1%
}%
\def\XINT_expr_scanbinII_a #1%
{%
    \ifcat #1\relax\xint_dothis{;\iffalse{\fi}#1}\fi
    \xint_orthat {\XINT_expr_scanbinII_aa #1}%
}%
\def\XINT_expr_scanbinII_aa #1%
{%
    \if _#1\xint_dothis\XINT_expr_scanbinII_bgob\fi
    \if 0#1\xint_dothis\XINT_expr_scanbinII_b\fi
    \if 1#1\xint_dothis\XINT_expr_scanbinII_b\fi
    \xint_orthat{;\iffalse{\fi}}%
    #1%
}%
\def\XINT_expr_scanbinII_b #1#2%
{%
    #1\expandafter\XINT_expr_scanbinII_a\romannumeral`&&@#2%
}%
\def\XINT_expr_scanbinII_bgob #1#2%
{%
    \expandafter\XINT_expr_scanbinII_a\romannumeral`&&@#2%
}%
%    \end{macrocode}
% \subsubsection{\csh{XINT_expr_startfunc}: collecting names of functions and
% variables}
%
%\begin{lverb}
% At 1.4 the first token left over has not been submitted to
% \string. We also know it is not a control sequence. So we can test catcode
% to identify if operator is found. And it is allowed to hit some operator
% such as a closing parenthesis we will then insert the «nil» value (edited: which
% however will cause certain breakage of the infix binary operators: I notice
% I did not insert None {{}} but nil {}, perhaps by oversight).
%
% There was prior to 1.4 solely the dispatch in \XINT_expr_scanfunc_b
% but now we do it immediately and issue \XINT_expr_func only in certain
% cases.
%
% Comments here have been removed because 1.4g did a refactoring
% and renamed \XINT_expr_scanfunc to \XINT_expr_startfunc, moving half of
% it earlier inside the getnextfork macros.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_startfunc #1%
   {\expandafter\XINT_expr_func\expanded\bgroup#1\XINT_expr_scanfunc_a}%
\def\XINT_expr_scanfunc_a #1%
{%
    \expandafter\XINT_expr_scanfunc_b\romannumeral`&&@#1%
}%
%    \end{macrocode}
%\begin{lverb}
% This handles: 1) (indirectly) tacit multiplication by a variable in
% front a of sub-expression, 2) (indirectly) tacit multiplication in front of
% a \count etc..., 3) functions which are recognized via an encountered opening
% parenthesis (but later this must be disambiguated from variables with tacit
% multiplication) 4) 5) 6) 7) acceptable components of a variable or function
% names: @, underscore, digits, letters (or chars of category code letter.)
%
% The short lived 1.2d which followed the even shorter lived 1.2c managed to
% introduce a bug here as it removed the check for catcode 11 !, which must be
% recognized if ! is not to be taken as part of a variable name. Don't know
% what I was thinking, it was the time when I was moving the handling of tacit
% mutliplication entirely to the \XINT_expr_getop side. Fixed in 1.2e.
%
% I almost decided to remove the \ifcat\relax test whose rôle is to avoid the
% \string#1 to do something bad is the escape char is a digit! Perhaps I will
% remove it at some point ! I truly almost did it, but also the case of no
% escape char is a problem (\string\0, if \0 is a count ...)
%
% The (indirectly) above means that via \XINT_expr_func then \XINT_expr_op__
% one goes back to \XINT_expr_getop then \XINT_expr_getop_b which is the
% location where tacit multiplication is now centralized. This makes the
% treatment of tacit multiplication for situations such as <variable>\count or
% <variable>\xintexpr..\relax, perhaps a bit sub-optimal, but first the
% variable name must be gathered, second the variable must expand to its
% value.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_scanfunc_b #1%
{%
  \ifcat \relax#1\xint_dothis{\iffalse{\fi}(_#1}\fi
  \if (#1\xint_dothis{\iffalse{\fi}(`}\fi
  \if 1\ifcat a#10\fi
       \ifnum\xint_c_ix<1\string#1 0\fi
       \if @#10\fi
       \if _#10\fi
      1%
      \xint_dothis{\iffalse{\fi}(_#1}\fi
  \xint_orthat {#1\XINT_expr_scanfunc_a}%
}%
%    \end{macrocode}
% \subsubsection{\csh{XINT_expr_func}: dispatch to variable replacement or to
% function execution}
%\begin{lverb}
% Comments written 2015/11/12: earlier there was an \ifcsname test for
% checking if we had a variable in front of a (, for tacit multiplication for
% example in x(y+z(x+w)) to work. But after I had implemented functions (that
% was yesterday...), I had the problem if was impossible to re-declare a
% variable name such as "f" as a function name. The problem is that here we
% can not test if the function is available because we don't know if we are in
% expr, iiexpr or floatexpr. The \xint_c_ii^v causes all fetching operations
% to stop and control is handed over to the routines which will be expr,
% iiexpr ou floatexpr specific, i.e. the \XINT_{expr|iiexpr|flexpr}_op_{`|_}
% which are invoked by the until_<op>_b macros earlier in the stream.
% Functions may exist for one but not the two other parsers. Variables are
% declared via one parser and usable in the others, but naturally \xintiiexpr
% has its restrictions.
%
% Thinking about this again I decided to treat a priori cases such as x(...)
% as functions, after having assigned to each variable a low-weight macro
% which will convert this into _getop\.=<value of x>*(...). To activate that
% macro at the right time I could for this exploit the "onliteral" intercept,
% which is parser independent (1.2c).
%
% This led to me necessarily to rewrite partially the seq, add, mul, subs,
% iter ... routines as now the variables fetch only one token. I think the
% thing is more efficient.
%
% 1.2c had \def\XINT_expr_func #1(#2{\xint_c_ii^v #2{#1}}
%
% In \XINT_expr_func the #2 is _ if #1 must be a variable name, or #2=` if #1
% must be either a function name or possibly a variable name which will then
% have to be followed by tacit multiplication before the opening parenthesis.
%
% The \xint_c_ii^v is there because _op_` must know in which parser
% it works. Dispendious for _. Hence I modify for 1.2d.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_func #1(#2{\if _#2\xint_dothis{\XINT_expr_op__{#1}}\fi
                          \xint_orthat{{#1}\xint_c_ii^v #2}}%
%    \end{macrocode}
% \subsection{\csh{XINT_expr_op_`}: launch function or
% pseudo-function, or evaluate variable and insert operator of multiplication
% in front of parenthesized contents}
%
%\begin{lverb}
% The "onliteral" intercepts is for bool, togl, protect, ... but also
% for add, mul, seq, etc... Genuine functions have expr, iiexpr and flexpr
% versions (or only one or two of the three) and trigger here the use of the
% suitable parser-dependant form.  The former (pseudo functions and functions
% handling dummy variables) first trigger a parser independent mechanism.
%
% With 1.2c "onliteral" is also used to disambiguate a variable followed
% by an opening parenthesis from a function and then apply tacit multiplication.
% However as I use only a \ifcsname test, in order to be able to
% re-define a variable as function, I move the check for being a function
% first. Each variable name now has its onliteral_<name> associated macro.
% This used to be decided much earlier at the time of
% \XINT_expr_func.
%
% The advantage of 1.2c code is that the same name can be used for
% a variable or a function.
%\end{lverb}
%
% \changed[2021/06/11]{1.4i}
%\begin{lverb}
% The 1.2c abuse of «onliteral» for both tacit multiplication in front
% of an opening parenthesis and «generic» functions or pseudo-functions meant
% that the latter were vulnerable against user redefinition of a function name
% as a variable name.  This applied to subs, subsm, subsn, seq, add, mul,
% ndseq, ndmap, ndfillraw, bool, togl, protect, qint, qfrac, qfloat, qraw,
% random, qrand, rbit and the most susceptible in real life was probably "seq".
%
% Now variables have an associated «var*» named macro, not «onliteral».
%
% In passing I refactor here in a \romannumeral inspired way how \csname and
% TeX booleans are intertwined, minimizing \expandafter usage.
%\end{lverb}
%
% \changed{2.0a1}
% Per-parser "onliteral" macros.
%
%    \begin{macrocode}
\def\XINT_tmpa #1#2#3{%
  \def #1##1%
  {%
    \csname
      XINT_\ifcsname XINT_#3_func_##1\endcsname
        #3_func_##1\expandafter\endcsname\romannumeral`&&@\expandafter#2%
      \romannumeral\else
      \ifcsname XINT_#3_onliteral_##1\endcsname
        #3_onliteral_##1\expandafter\endcsname\romannumeral
      \else
      \ifcsname XINT_expr_var*_##1\endcsname
        expr_var*_##1\expandafter\endcsname\romannumeral
      \else
        #3_func_\XINT_expr_unknown_function {##1}%
                \expandafter\endcsname\romannumeral`&&@\expandafter#2%
      \romannumeral
      \fi\fi\fi\xint_c_
  }%
}%
\xintFor #1 in {flexpr,iiexpr} \do {%
     \expandafter\XINT_tmpa
                 \csname XINT_#1_op_`\expandafter\endcsname
                 \csname XINT_#1_oparen\endcsname
                 {#1}%
}%
\def\XINT_expr_unknown_function #1%
   {\XINT_expandableerror{`#1' is unknown, say `Isome_func' or I use 0.}}%
\def\XINT_expr_func_ #1#2#3{#1#2{{0}}}%
\let\XINT_flexpr_func_\XINT_expr_func_
\let\XINT_iiexpr_func_\XINT_expr_func_
%    \end{macrocode}
%
% \subsection{\csh{XINT_expr_op__}: replace a variable by its value and
% then fetch next operator}
%\begin{lverb}
% The 1.1 mechanism for \XINT_expr_var_<varname> has been
% modified in 1.2c. The <varname> associated macro is now only expanded
% once, not twice. We arrive here via \XINT_expr_func.
%
% At 1.4 \XINT_expr_getop is launched with accumulated result on its left.
% But the omit and abort keywords are implemented via fake variables
% which rely on possibility to modify incoming upfront tokens. If we did here
% something such as
% $centeredline$bgroup_var_#1\expandafter\endcsname\romannumeral`^^@\XINT_expr_getop$egroup
% the premature expansion of getop would break the var_omit and
% var_abort mechanism. Thus we revert
% to former code which locates an \XINT_expr_getop (call it _legacy)
% before the tokens from the variable expansion (in xintexpr < 1.4 the
% normal variables expanded
% to a single token so the overhead was not serious) so we can expand fake
% variables first.
%
% Abusing variables to manipulate the incoming token stream is a bit bad,
% usually I prefer functions for this (such as the break() function) but then
% I have to define 3 macros for the 3 parsers.
%
% This trick of fake variables puts thus a general overhead at various
% locations, and the situation here is REALLY not satisfactory. But 1.4 has
% (had) to be released now.
%
% Even if I could put the \csname XINT_expr_var_foo\endcsname upfront, which
% would then be f-expanded, this would still need \XINT_expr_put_op_first to
% use its \expandafter's as long as \XINT_expr_var_foo expands to
% {\XINT_expr_varvalue_foo} with a not-yet expanded \XINT_expr_var_value.
%
% I could let \XINT_expr_var_foo expand to
% \expandafter{\XINT_expr_varvalue_foo} allowing then (if it gets f-expanded)
% probably to drop the \expandafter in \XINT_expr_put_op_first. But I can not
% consider this option in the form
% $centeredline$bgroup_var_foo\expandafter\endcsname\romannumeral`^^@\XINT_expr_getop$egroup
% until the issue with fake variables such as omit and
% abort which must act before \XINT_expr_getop has some workaround.
% This could be implemented here with some extra branch, i.e. there would not
% be some \XINT_expr_var_omit but something else filtered out in the \else
% branch here.
%
% The above comments mention only omit and abort, but the case of real dummy
% variables also needs consideration.
%
% At 1.4g, I test first for existence of \XINT_expr_onliteral_foo.
%
% Updated for 1.4i: now rather existence of \XINT_expr_var*_foo is tested.
%
% This is
% a trick which allows to distinguish actual or dummy variables from really
% fake variables omit and abort (must check if there are others). For the real
% or dummy variables we can trigger the expansion of the \XINT_expr_getop
% before the one of the variable.  I could test vor varvalue_foo but this
% applies only to real variables not dummy variables.  Actual and dummy
% variables are thus handled slightly faster at 1.4g as there is less
% induced moving around (the \expandafter chain in \XINT_expr_put_op_first
% still applies at this stage, as I have not yet re-examined the var/varlue
% mechanism). And the test for var_foo is moved directly inside the \csname
% construct in the \else branch which now handles together
% fake variables and non-existing variables.
%
% I only have to make sure dummy variables are really safe being handled this
% way with the getop action having being done before they expand, but it looks
% ok. Attention it is crucial that if \XINT_expr_getop  finds a \relax it inserts
% \xint_c_\relax so the \relax token is still there!
%
% With this refactoring the \XINT_expr_getop_legacy is applied only in case
% of non-existent variables or fake variables omit/abort or things such as
% nil, None, false, true, False, True.
%
% If user in interactive mode fixes the variable name, the \XINT_expr_var_foo
% expanded once with deliver {\XINT_expr_varvalue_foo} (if not dummy), and the
% braces are maintained by \XINT_expr_getop_legacy.
%
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_op__  #1% op__ with two _'s
{%
    \ifcsname XINT_expr_var*_#1\endcsname
       \csname XINT_expr_var_#1\expandafter\endcsname
       \romannumeral`&&@\expandafter\XINT_expr_getop
    \else
      \expandafter\expandafter\expandafter\XINT_expr_getop_legacy
      \csname XINT_expr_var_%
              \ifcsname XINT_expr_var_#1\endcsname#1%
              \else\XINT_expr_unknown_variable{#1}\fi
      \expandafter\endcsname
    \fi
}%
\def\XINT_expr_unknown_variable #1%
   {\XINT_expandableerror {`#1' unknown, say `Isome_var' or I use 0.}}%
\def\XINT_expr_var_{{{0}}}%
\let\XINT_flexpr_op__ \XINT_expr_op__
\let\XINT_iiexpr_op__ \XINT_expr_op__
\def\XINT_expr_getop_legacy #1%
{%
    \expanded{\xint_noxpd{{#1}}\expandafter}\romannumeral`&&@\XINT_expr_getop
}%
%    \end{macrocode}
% \subsection{\csh{XINT_expr_getop}: fetch the next operator or closing
% parenthesis or end of expression}
%\begin{lverb}
% Release 1.1 implements multi-character operators.
%
% 1.2d adds tacit mutiplication also in front of variable or functions names
% starting with a letter, not only a @ or a _ as was already the case. This is
% for (x+y)z situations. It also applies higher precedence in cases like x/2y
% or x/2@, or x/2max(3,5), or x/2\xintexpr 3\relax.
%
% In fact, finally I decide that all sorts of tacit multiplication will always
% use the higher precedence.
%
% Indeed I hesitated somewhat: with the current code one does not know if
% \XINT_expr_getop as invoked after a closing parenthesis or because a number
% parsing ended, and I felt distinguishing the two was unneeded extra stuff.
% This means cases like (a+b)/(c+d)(e+f) will first multiply the last two
% parenthesized terms.
%
%
% 1.2q adds tacit multiplication in cases such as (1+1)3 or 5!7!
%
% 1.4 has simplified coding here as \XINT_expr_getop expansion happens
% at a time when a fetched value has already being stored.
%
% Prior to 1.4g there was an \if _#1\xint_dothis\xint_secondofthree\fi
% because the _ can be used to start names, for private use by package (for
% example by polexpr). But this test was silly because these usages are only
% with a _ of catcode 11. And allowing non-catcode 11 _ also to trigger tacit
% multiplication caused an infinite loop in collaboration with
% \XINT_expr_scanfunc, see explanations there (now removed after refactoring,
% see \XINT_expr_startfunc).
%
% The situation with the @ is different because we must allow it even as
% catcode 12 as a name, as it used in the syntax and must work the same if of
% catcode 11 or 12. No infinite loop because it is filtered out by one of the
% \XINT_expr_getnextfork macros.
%
% The check for : to send it to thirdofthree "getop" branch is needed, last
% time I checked, because during some part of at least \xintdeffunc, some
% scantokens are done which need to work with the : of catcode 11, and it
% would be misconstrued to start a name if not filtered out.
%
%\end{lverb}
% \odef\MakePrivateLetters{\MakePrivateLetters\catcode`* 11 }^^A
%    \begin{macrocode}
\def\XINT_expr_getop #1%
{%
    \expandafter\XINT_expr_getop_a\romannumeral`&&@#1%
}%
\catcode`* 11
\def\XINT_expr_getop_a #1%
{%
    \ifx   \relax #1\xint_dothis\xint_firstofthree\fi
    \ifcat \relax #1\xint_dothis\xint_secondofthree\fi
    \ifnum\xint_c_ix<1\string#1 \xint_dothis\xint_secondofthree\fi
    \if    :#1\xint_dothis      \xint_thirdofthree\fi
    \if    @#1\xint_dothis      \xint_secondofthree\fi
    \if    (#1\xint_dothis      \xint_secondofthree\fi %)
    \ifcat a#1\xint_dothis      \xint_secondofthree\fi
    \xint_orthat \xint_thirdofthree
%    \end{macrocode}
%\begin{lverb}
% Formerly \XINT_expr_foundend as firstofthree but at 1.4g let's
% simply insert \xint_c_ as the #1 is \relax (and anyhow a place-holder
% according to remark in definition of \XINT_expr_foundend
%\end{lverb}
%    \begin{macrocode}
    \xint_c_
%    \end{macrocode}
%\begin{lverb}
% Tacit multiplication with higher precedence. Formerly
% \XINT_expr_precedence_*** was used, renamed to \XINT_expr_prec_tacit at
% 1.4g in case a backport is done of the \bnumdefinfix from bnumexpr.
%\end{lverb}
%    \begin{macrocode}
    {\XINT_expr_prec_tacit *}%
%    \end{macrocode}
%\begin{lverb}
% This is only location which jumps to \XINT_expr_getop_b. At 1.4f and
% perhaps for old legacy reasons this was \expandafter\XINT_expr_getop_b
% \string#1 but I see no reason now for applying \string to #1. Removed at
% 1.4g. And the #1 now moved out of the secondofthree and thirdofthree
% branches.
%\end{lverb}
%    \begin{macrocode}
    \XINT_expr_getop_b
    #1%
}%
\catcode`* 12
%    \end{macrocode}
% \let\MakePrivateLetters\xintexprMakePrivateLetters
%\begin{lverb}
% \relax is a place holder here. At 1.4g, we don't use
% \XINT_expr_foundend anymore in \XINT_expr_getop_a which was slightly
% refactored, but it is used elsewhere.
%
% Attention that keeping a \relax around if \XINT_expr_getop hits it is
% crucial to good functioning of dummy variables after 1.4g refactoring of
% \XINT_expr_op__, the \relax being used as delimiter by dummy variables, and
% \XINT_expr_getop is now expanded before the variable itself does its thing.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_foundend {\xint_c_ \relax}%
%    \end{macrocode}
%\begin{lverb}
% ? is a very special operator with top precedence which will check if
% the next token is another ?, while avoiding removing a brace pair from token
% stream due to its syntax. Pre 1.1 releases used : rather than ??, but we
% need : for Python like slices of lists.
%\end{lverb}
%
%\begin{lverb}
% null char is used as hack to implement A/B[N] raw input at 1.4. See
% also \XINT_expr_scanint_c.
%\end{lverb}
%
%\begin{lverb}
% Memo: 1.4g, the token fetched by \XINT_expr_getop_b has not anymore
% been previously submitted in \XINT_expr_getop_a to \string.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_getop_b#1{\def\XINT_expr_getop_b ##1%
{%
     \if &&@##1\xint_dothis{#1&&@}\fi
     \if   '##1\xint_dothis{\XINT_expr_binopwrd }\fi
     \if   ?##1\xint_dothis{\XINT_expr_precedence_? ?}\fi
     \xint_orthat          {\XINT_expr_scanop_a ##1}%
}}\expandafter\XINT_expr_getop_b\csname XINT_expr_precedence_&&@\endcsname
\def\XINT_expr_binopwrd #1'%
{%
    \expandafter\XINT_expr_foundop_a
    \csname XINT_expr_itself_\xint_zapspaces #1 \xint_gobble_i\endcsname
}%
\def\XINT_expr_scanop_a #1#2%
{%
    \expandafter\XINT_expr_scanop_b\expandafter#1\romannumeral`&&@#2%
}%
%    \end{macrocode}
%\begin{lverb}
% Multi-character operators have an associated itself macro at each
% stage of decomposition starting at two characters. Here, nothing imposes to
% the operator characters not to be of catcode letter, this constraint applies
% only on the first character and is done via \XINT_expr_getop_a, to handle in
% particular tacit multiplication in front of variable or function names.
%
% But it would be dangerous to allow letters in operator characters, again due
% to existence of variables and functions, and anyhow there is no user
% interface to add such custom operators.  However in bnumexpr, such a
% constraint does not exist.
%
% I don't worry too much about efficiency here... and at 1.4g I have
% re-written for code readability only.  Once we see that #1#2 is not a
% candidate to be or start an operator, we need to check if single-character
% operator #1 is really an operator and this is done via the existence of the
% precedence token.
%
% Unfortunately the 1.4g refactoring of the scanop macros had a bad bug:
% \XINT_expr_scanop_c inserted \romannumeral`^^@ in stream but did not grab a
% token first so a space would stop the \romannumeral and then the #2 in
% \XINT_expr_scanop_d was not pre-expanded and ended up alone in \ifcat.  It
% is too distant in the past the time when I wrote the core of xintexpr in
% 2013... older and dumber now.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_scanop_b #1#2%
{%
    \unless\ifcat#2\relax
           \ifcsname XINT_expr_itself_#1#2\endcsname
           \XINT_expr_scanop_c
    \fi\fi
    \XINT_expr_foundop_a #1#2%
}%
\def\XINT_expr_scanop_c #1#2#3#4#5#6% #1#2=\fi\fi
{%
    #1#2%
    \expandafter\XINT_expr_scanop_d
                \csname XINT_expr_itself_#4#5\expandafter\endcsname
    \romannumeral`&&@#6%
}%
\def\XINT_expr_scanop_d #1#2%
{%
    \unless\ifcat#2\relax
           \ifcsname XINT_expr_itself_#1#2\endcsname
           \XINT_expr_scanop_c
    \fi\fi
    \XINT_expr_foundop #1#2%
}%
\def\XINT_expr_foundop_a #1%
{%
    \ifcsname XINT_expr_precedence_#1\endcsname
        \csname XINT_expr_precedence_#1\expandafter\endcsname
        \expandafter #1%
    \else
        \expandafter\XINT_expr_getop\romannumeral`&&@%
        \xint_afterfi{\XINT_expandableerror
        {Expected an operator but got `#1'. Ignoring.}}%
     \fi
}%
\def\XINT_expr_foundop #1{\csname XINT_expr_precedence_#1\endcsname #1}%
%    \end{macrocode}
% \subsection{Expansion spanning; opening and closing parentheses}
% \label{ssec:expansionspanning}
% This is also where |\XINT_iiexpr_start| and
% |\XINT_flexpr_start| are defined.
%
% \xintFor #1 in {flexpr,iiexpr} \do{\label{\xintimplabelprefix XINT_#1_start}}
%\begin{lverb}
%
% These comments apply to all definitions coming next relative
% to execution of operations from parsing of syntax.
%
% Refactored (and unified) at 1.4. In particular
% the 1.4 scheme uses op, exec, check-, and checkp. Formerly
% it was until_a (check-) and until_b (now split into checkp and exec).
%
% This way neither check- nor checkp have to
% grab the accumulated number so far (top of stack if you like) and besides
% one never has to go back to check- from checkp (and neither from check-).
%
%
%
% Prior to 1.4, accumulated
% intermediate results were stored as one token, but now we have to use
% \expanded to propagate expansion beyond possibly arbitrary long braced
% nested data. With the 1.4 refactoring we do this only once and only grab
% a second time the data if we actually have to act upon it.
%
% Version 1.1 had a hack inside the until macros for handling the omit
% and abort in iterations over dummy variables. This has been removed by
% 1.2c, see the subsection where omit and abort are discussed.
%
% Exceptionally, the check- is here abbreviated to check.
%
%\end{lverb}
% \odef\MakePrivateLetters{\MakePrivateLetters\catcode`) 11 }^^A
%    \begin{macrocode}
\catcode`) 11
\def\XINT_def_start_and_check #1#2#3#4#5#6%
{%
    \def#1% \XINT_expr_start, \XINT_iiexpr_start, \XINT_flexpr_start
    {%
        \expandafter#2\romannumeral`&&@\XINT_expr_getnext
    }%
    \def#2##1% check
    {%
        \xint_UDsignfork
          ##1{\expandafter#3\romannumeral`&&@#4}%
            -{#3##1}%
        \krof
    }%
    \def#3##1##2% checkp
    {%
        \ifcase ##1%
           \expandafter\XINT_expr_done
        \or\expandafter#5%
        \else
           \expandafter#3%
           \romannumeral`&&@\csname XINT_#6_op_##2\expandafter\endcsname
        \fi
    }%
    \def#5%
    {%
        \XINT_expandableerror
        {Extra ) removed. Hit <return>, fingers crossed.}%
        \expandafter#2\romannumeral`&&@\expandafter\XINT_expr_put_op_first
        \romannumeral`&&@\XINT_expr_getop_legacy
    }%
}%
\let\XINT_expr_done\space
\xintFor #1 in {flexpr,iiexpr} \do {%
    \expandafter\XINT_def_start_and_check
    \csname XINT_#1_start\expandafter\endcsname
    \csname XINT_#1_check\expandafter\endcsname
    \csname XINT_#1_checkp\expandafter\endcsname
    \csname XINT_#1_op_-xii\expandafter\endcsname
    \csname XINT_#1_extra_)\endcsname
    {#1}%
}%
%    \end{macrocode}
%\begin{lverb}
% Here also we take some shortcuts relative to general philosophy and have no explicit
% exec macro.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_defop_oparen #1#2#3#4#5#6#7%
{%
    \def #1##1% op_(
    {%
        \expandafter #4\romannumeral`&&@\XINT_expr_getnext
    }%
    \def #2##1% op_)
    {%
        \expanded{\xint_noxpd{\XINT_expr_put_op_first{##1}}\expandafter}%
        \romannumeral`&&@\XINT_expr_getop
    }%
    \def #3% oparen
    {%
        \expandafter #4\romannumeral`&&@\XINT_expr_getnext
    }%
    \def #4##1% check-
    {%
        \xint_UDsignfork
            ##1{\expandafter#5\romannumeral`&&@#6}%
              -{#5##1}%
        \krof
    }%
    \def #5##1##2% checkp
    {%
        \ifcase ##1\expandafter\XINT_expr_missing_)
        \or \csname XINT_#7_op_##2\expandafter\endcsname
        \else
          \expandafter #5%
          \romannumeral`&&@\csname XINT_#7_op_##2\expandafter\endcsname
        \fi
    }%
}%
\def\XINT_expr_missing_)
   {\XINT_expandableerror
    {End of expression found, but some ) was missing there.}%
    \xint_c_ \XINT_expr_done }%
\xintFor #1 in {flexpr,iiexpr} \do {%
    \expandafter\XINT_defop_oparen
    \csname XINT_#1_op_(\expandafter\endcsname
    \csname XINT_#1_op_)\expandafter\endcsname
    \csname XINT_#1_oparen\expandafter\endcsname
    \csname XINT_#1_check-_)\expandafter\endcsname
    \csname XINT_#1_checkp_)\expandafter\endcsname
    \csname XINT_#1_op_-xii\endcsname
    {#1}%
}%
\let\XINT_expr_precedence_)\xint_c_i
\catcode`) 12
%    \end{macrocode}
% \let\MakePrivateLetters\xintexprMakePrivateLetters
% \subsection{The comma as binary operator}
%\begin{lverb}
% New with 1.09a. Refactored at 1.4.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_defop_comma #1#2#3#4#5#6%
{%
    \def #1##1% \XINT_expr_op_,
    {%
      \expanded{\xint_noxpd{#2{##1}}\expandafter}%
      \romannumeral`&&@\expandafter#3\romannumeral`&&@\XINT_expr_getnext
    }%
    \def #2##1##2##3##4{##2##3{##1##4}}% \XINT_expr_exec_,
    \def #3##1% \XINT_expr_check-_,
    {%
      \xint_UDsignfork
        ##1{\expandafter#4\romannumeral`&&@#5}%
          -{#4##1}%
      \krof
    }%
    \def #4##1##2% \XINT_expr_checkp_,
    {%
      \ifnum ##1>\xint_c_iii
        \expandafter#4%
           \romannumeral`&&@\csname XINT_#6_op_##2\expandafter\endcsname
      \else
        \expandafter##1\expandafter##2%
      \fi
    }%
}%
\xintFor #1 in {flexpr,iiexpr} \do {%
\expandafter\XINT_defop_comma
    \csname XINT_#1_op_,\expandafter\endcsname
    \csname XINT_#1_exec_,\expandafter\endcsname
    \csname XINT_#1_check-_,\expandafter\endcsname
    \csname XINT_#1_checkp_,\expandafter\endcsname
    \csname XINT_#1_op_-xii\endcsname {#1}%
}%
\expandafter\let\csname XINT_expr_precedence_,\endcsname\xint_c_iii
%    \end{macrocode}
% \subsection{The minus as prefix operator of variable precedence level}
%\begin{lverb}
% Inherits the precedence level of the previous infix operator, if the
% latter has at least the precedence level of binary + and -, i.e. currently
% 12.
%
% Refactored at 1.4.
%
% At 1.4g I belatedly observe that I have been defining architecture for
% op_-xvi but such operator can never be created, because there are no infix
% operators of precedence level 16.  Perhaps in the past this was really
% needed?  But now such 16 is precedence level of tacit multiplication which
% is implemented simply by the \XINT_expr_prec_tacit token, there is no macro
% check-_*** which would need an op_-xvi.
%
% For the record: at least one scenario exists
% which creates tacit multiplication in front of a unary -, it is 2\count0
% which first generates tacit multiplication then applies \number to \count0,
% but the operator
% is still *, so this triggers only \XINT_expr_op_-xiv, not -xvi.
%
% At 1.4g we need 17 and not 18 anymore as the precedence of unary minus
% following power operators ^ and **. The needed \xint_c_xvii creation was
% added to xintkernel.sty.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_defop_minus_i #1#2#3#4#5#6#7%
{%
    \def #1% \XINT_expr_op_-<level>
    {%
      \expandafter #2\romannumeral`&&@\expandafter#3%
      \romannumeral`&&@\XINT_expr_getnext
    }%
    \def #2##1##2##3% \XINT_expr_exec_-<level>
    {%
      \expandafter ##1\expandafter ##2\expandafter
       {%
        \romannumeral`&&@\XINT:NEhook:f:one:from:one
        {\romannumeral`&&@#7##3}%
       }%
    }%
    \def #3##1% \XINT_expr_check-_-<level>
    {%
      \xint_UDsignfork
        ##1{\expandafter #4\romannumeral`&&@#1}%
          -{#4##1}%
      \krof
    }%
    \def #4##1##2% \XINT_expr_checkp_-<level>
    {%
      \ifnum ##1>#5%
        \expandafter #4%
        \romannumeral`&&@\csname XINT_#6_op_##2\expandafter\endcsname
      \else
        \expandafter ##1\expandafter ##2%
      \fi
    }%
}%
\def\XINT_defop_minus #1#2#3%
{%
    \expandafter\XINT_defop_minus_i
    \csname XINT_#1_op_-#3\expandafter\endcsname
    \csname XINT_#1_exec_-#3\expandafter\endcsname
    \csname XINT_#1_check-_-#3\expandafter\endcsname
    \csname XINT_#1_checkp_-#3\expandafter\endcsname
    \csname xint_c_#3\endcsname {#1}#2%
}%
\xintApplyInline{\XINT_defop_minus {flexpr}\calxFpOpp}{{xii}{xiv}{xvii}}%
\xintApplyInline{\XINT_defop_minus {iiexpr}\calxiiOpp}{{xii}{xiv}{xvii}}%
%    \end{macrocode}
% \subsection{The \texorpdfstring{\protect\lowast}{*}{} as Python-like «unpacking» prefix operator}
%
%\begin{lverb}
% New with 1.4. Prior to 1.4 the internal data structure was
% the one of \csname encapsulated comma separated numbers. No hierarchical
% structure was (easily) possible. At 1.4, we can use TeX braces because there
% is no detokenization to catcode 12.
%\end{lverb}
%
%
%    \begin{macrocode}
\def\XINT_defpost_unpack#1#2#3%
{%
    \def#1##1{\expandafter#2\romannumeral`&&@\XINT_expr_getnext}%
    \def#2##1##2%
    {%
      \ifnum ##1>\xint_c_xx
        \expandafter #2%
        \romannumeral`&&@\csname XINT_#3_op_##2\expandafter\endcsname
      \else
        \expandafter##1%
         \expandafter##2\romannumeral0\expandafter\XINT:NEhook:unpack
      \fi
    }%
}%
\def\XINT:NEhook:unpack{\xint_stop_atfirstofone}%
\xintFor* #1 in {{flexpr}{iiexpr}}:
    {\expandafter\XINT_defpost_unpack\csname XINT_#1_op_0\expandafter\endcsname
                           \csname XINT_#1_until_unpack\endcsname {#1}}%
%    \end{macrocode}
% \subsection{Infix operators}
%
% \localtableofcontents
%
%\begin{lverb}
% 1.2d adds the *** for tying via tacit multiplication, for example
% x/2y. Actually I don't need the _itself mechanism for ***, only a
% precedence.
%
% At 1.4b we must make sure that the ! in expansion of \XINT_expr_itself_!= is
% of catcode 12 and not of catcode 11.  This is because implementation of
% chaining of comparison operators proceeds via inserting the itself macro
% directly into upcoming token stream, whereas formerly such itself macros
% would be expanded only in a \csname...\endcsname context.
%\end{lverb}
%    \begin{macrocode}
\catcode`& 12 \catcode`! 12
\xintFor* #1 in {{==}{!=}{<=}{>=}{&&}{||}{//}{/:}{..}{..[}{].}{]..}}%
    \do {\expandafter\def\csname XINT_expr_itself_#1\endcsname {#1}}%
\catcode`& 7  \catcode`! 11
%    \end{macrocode}
% \subsubsection{\&\&, \textbar\textbar, //, /:, +,
% \textendash, \texorpdfstring{\protect\lowast}{*}, /, \textasciicircum,
% \texorpdfstring{\protect\lowast\protect\lowast}{**}{}, \textquotesingle and\textquotesingle, \textquotesingle
% or\textquotesingle, \textquotesingle xor\textquotesingle, and
% \textquotesingle mod\textquotesingle}
%
%\begin{lverb}
% At 1.4g I finally decide to enact the switch to right
% associativity for the power operators ^ and **.
%
% This goes via inserting into the checkp macros not anymore the precedence
% chardef token (which now only serves as left precedence, inserted in the
% token stream) but in its place an \xint_c_<roman> token holding the right
% precedence. Which is also transmitted to spanned unary minus operators.
%
% Here only levels 12, 14, and 17 are created as right precedences.
%
% #6 and #7 got permuted and the new #7 is directly a control sequence.
% Also #3 and #4 are now integers which need \romannumeral.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_defbin_ai #1#2#3#4#5#6#7#8%
{%
  \def #1##1% \XINT_expr_op_<op>
  {%
    \expanded{\xint_noxpd{#2{##1}}\expandafter}%
    \romannumeral`&&@\expandafter#3\romannumeral`&&@\XINT_expr_getnext
  }%
  \def #2##1##2##3##4% \XINT_expr_exec_<op>
  {%
    \expandafter##2\expandafter##3\expandafter
      {\romannumeral`&&@\XINT:NEhook:f:one:from:two
       {\romannumeral`&&@#7##1##4}}%
  }%
  \def #3##1% \XINT_expr_check-_<op>
  {%
    \xint_UDsignfork
      ##1{\expandafter#4\romannumeral`&&@#5}%
        -{#4##1}%
    \krof
  }%
  \def #4##1##2% \XINT_expr_checkp_<op>
  {%
    \ifnum ##1>#6%
      \expandafter#4%
      \romannumeral`&&@\csname XINT_#8_op_##2\expandafter\endcsname
    \else
      \expandafter ##1\expandafter ##2%
    \fi
  }%
}%
\def\XINT_expr_defbin_a #1#2#3#4#5%
{%
  \expandafter\XINT_expr_defbin_ai
  \csname XINT_#1_op_#2\expandafter\endcsname
  \csname XINT_#1_exec_#2\expandafter\endcsname
  \csname XINT_#1_check-_#2\expandafter\endcsname
  \csname XINT_#1_checkp_#2\expandafter\endcsname
  \csname XINT_#1_op_-\romannumeral\ifnum#4>12
          #4\else12\fi\expandafter\endcsname
  \csname xint_c_\romannumeral#4\endcsname
  #5%
  {#1}%
  \expandafter % done 3 times but well
  \let\csname XINT_expr_precedence_#2\expandafter\endcsname
      \csname xint_c_\romannumeral#3\endcsname
}%
\XINT_expr_defbin_a {flexpr}{||} {6} {6} \calxFpOR
\XINT_expr_defbin_a {iiexpr}{||} {6} {6} \calxOR
\catcode`& 12
\XINT_expr_defbin_a {flexpr}{&&} {8} {8} \calxFpAND
\XINT_expr_defbin_a {iiexpr}{&&} {8} {8} \calxAND
\catcode`& 7
\XINT_expr_defbin_a {flexpr}{xor}{6} {6} \calxFpXOR
\XINT_expr_defbin_a {iiexpr}{xor}{6} {6} \calxXOR
\XINT_expr_defbin_a {flexpr}{//} {14}{14}\calxFpDivFloor
\XINT_expr_defbin_a {iiexpr}{//} {14}{14}\calxiiDivFloor
\XINT_expr_defbin_a {flexpr}{/:} {14}{14}\calxFpMod
\XINT_expr_defbin_a {iiexpr}{/:} {14}{14}\calxiiMod
\XINT_expr_defbin_a {flexpr} +   {12}{12}\calxFpAdd
\XINT_expr_defbin_a {iiexpr} +   {12}{12}\calxiiAdd
\XINT_expr_defbin_a {flexpr} -   {12}{12}\calxFpSub
\XINT_expr_defbin_a {iiexpr} -   {12}{12}\calxiiSub
\XINT_expr_defbin_a {flexpr} *   {14}{14}\calxFpMul
\XINT_expr_defbin_a {iiexpr} *   {14}{14}\calxiiMul
\let\XINT_expr_prec_tacit \xint_c_xvi
\XINT_expr_defbin_a {flexpr} /   {14}{14}\calxFpDiv
\XINT_expr_defbin_a {iiexpr} /   {14}{14}\calxiiDivRound
%    \end{macrocode}
%\begin{lverb}
% At 1.4g, right associativity is implemented via
% a lowered right precedence here.
%\end{lverb}
%    \begin{macrocode}
\XINT_expr_defbin_a {flexpr} ^   {18}{17}\XINTinFloatSciPow
\XINT_expr_defbin_a {iiexpr} ^   {18}{17}\calxiiPow
%    \end{macrocode}
%\begin{lverb}
% 1.4g This is a trick (which was in old version of bnumexpr, I
% wonder why I did not have it here) but it will make error messages in case
% of **<token> confusing.  The ^ here is of catcode 11 but it does not matter.
%\end{lverb}
%    \begin{macrocode}
\expandafter\def\csname XINT_expr_itself_**\endcsname{^}%
\catcode`& 12
%    \end{macrocode}
%\begin{lverb}
% For this which contributes to implementing 'and', 'or', etc... see
% \XINT_expr_binopwrd.
%\end{lverb}
%    \begin{macrocode}
\xintFor #1 in {and,or,xor,mod} \do
{%
   \expandafter\def\csname XINT_expr_itself_#1\endcsname {#1}%
}%
\expandafter\let\csname XINT_expr_precedence_and\expandafter\endcsname
                \csname XINT_expr_precedence_&&\endcsname
\expandafter\let\csname XINT_expr_precedence_or\expandafter\endcsname
                \csname XINT_expr_precedence_||\endcsname
\expandafter\let\csname XINT_expr_precedence_mod\expandafter\endcsname
                \csname XINT_expr_precedence_/:\endcsname
\xintFor #1 in {flexpr, iiexpr} \do
{%
   \expandafter\let\csname XINT_#1_op_and\expandafter\endcsname
                   \csname XINT_#1_op_&&\endcsname
   \expandafter\let\csname XINT_#1_op_or\expandafter\endcsname
                   \csname XINT_#1_op_||\endcsname
   \expandafter\let\csname XINT_#1_op_mod\expandafter\endcsname
                   \csname XINT_#1_op_/:\endcsname
}%
\catcode`& 7
%    \end{macrocode}
% \subsubsection{.., ..[, and ].. for a..b and a..[b]..c syntax}
%    \begin{macrocode}
\def\XINT_expr_defbin_bi #1#2#3#4#5#6#7%
{%
  \def #1##1% \XINT_expr_op_..[
  {%
    \expanded{\xint_noxpd{#2{##1}}\expandafter}%
    \romannumeral`&&@\expandafter#3\romannumeral`&&@\XINT_expr_getnext
  }%
  \def #2##1##2##3##4% \XINT_expr_exec_..[
  {%
    ##2##3{{##1##4}}%
  }%
  \def #3##1% \XINT_expr_check-_..[
  {%
    \xint_UDsignfork
      ##1{\expandafter#4\romannumeral`&&@#5}%
        -{#4##1}%
    \krof
  }%
  \def #4##1##2% \XINT_expr_checkp_..[
  {%
    \ifnum ##1>#6%
      \expandafter#4%
      \romannumeral`&&@\csname XINT_#7_op_##2\expandafter\endcsname
    \else
      \expandafter ##1\expandafter ##2%
    \fi
  }%
}%
\def\XINT_expr_defbin_b #1%
{%
  \expandafter\XINT_expr_defbin_bi
  \csname XINT_#1_op_..[\expandafter\endcsname
  \csname XINT_#1_exec_..[\expandafter\endcsname
  \csname XINT_#1_check-_..[\expandafter\endcsname
  \csname XINT_#1_checkp_..[\expandafter\endcsname
  \csname XINT_#1_op_-xii\expandafter\endcsname
  \csname XINT_expr_precedence_..[\endcsname
  {#1}%
}%
\XINT_expr_defbin_b {flexpr}%
\XINT_expr_defbin_b {iiexpr}%
\expandafter\let\csname XINT_expr_precedence_..[\endcsname\xint_c_vi
\def\XINT_expr_defbin_ci #1#2#3#4#5#6#7#8%
{%
  \def #1##1% \XINT_expr_op_<op>
  {%
    \expanded{\xint_noxpd{#2{##1}}\expandafter}%
    \romannumeral`&&@\expandafter#3\romannumeral`&&@\XINT_expr_getnext
  }%
  \def #2##1##2##3##4% \XINT_expr_exec_<op>
  {%
    \expandafter##2\expandafter##3\expanded
    {{\XINT:NEhook:x:one:from:two#8##1##4}}%
  }%
  \def #3##1% \XINT_expr_check-_<op>
  {%
    \xint_UDsignfork
      ##1{\expandafter#4\romannumeral`&&@#5}%
        -{#4##1}%
    \krof
  }%
  \def #4##1##2% \XINT_expr_checkp_<op>
  {%
    \ifnum ##1>#6%
      \expandafter#4%
      \romannumeral`&&@\csname XINT_#7_op_##2\expandafter\endcsname
    \else
      \expandafter ##1\expandafter ##2%
    \fi
  }%
}%
\def\XINT_expr_defbin_c #1#2#3%
{%
  \expandafter\XINT_expr_defbin_ci
  \csname XINT_#1_op_#2\expandafter\endcsname
  \csname XINT_#1_exec_#2\expandafter\endcsname
  \csname XINT_#1_check-_#2\expandafter\endcsname
  \csname XINT_#1_checkp_#2\expandafter\endcsname
  \csname XINT_#1_op_-xii\expandafter\endcsname
  \csname XINT_expr_precedence_#2\endcsname
  {#1}#3%
  \expandafter\let
  \csname XINT_expr_precedence_#2\expandafter\endcsname\xint_c_vi
}%
\XINT_expr_defbin_c {flexpr} {..}\xintfloatSeq:tl:x
\XINT_expr_defbin_c {iiexpr} {..}\xintSeq:tl:x
\XINT_expr_defbin_c {flexpr}{]..}\xintfloatSeqB:tl:x
\XINT_expr_defbin_c {iiexpr}{]..}\calxiiSeqB:tl:x
%    \end{macrocode}
% \subsubsection{<, >, ==, <=, >=, != with Python-like chaining}
%
% \added{1.4b}
% This is preliminary implementation of chaining of comparison
% operators like Python and (I think) l3fp do. I am not too happy
% with how many times the (second) operand (already evaluated) is fetched.
%
% \changed{1.4p}
% Sadly this was broken ever since creation if used inside \csbxint{iieval} or
% \csbxint{floateval} due to a macro using by oversight the parser type in the
% name of a token defining the precedence of the inserted |&&|.  But this
% token never got defined.  Anyhow we don't need another one beyond the one
% suitable for \csbxint{eval}.  A unit test existed, \emph{of course}, but it
% tested only \csbxint{eval}!  Thanks to Thomas Ossig for report.
%
%    \begin{macrocode}
\def\XINT_expr_defbin_dii #1#2%
{%
  \def #1##1##2##3##4% \XINT_<expr>_exec_<op>
  {%
    \expandafter##2\expandafter##3\expandafter
      {\romannumeral`&&@\XINT:NEhook:f:one:from:two
         {\romannumeral`&&@#2##1##4}}%
  }%
}%
\def\XINT_expr_defbin_di #1#2#3#4#5#6#7#8#9%
{%
  \def #1##1% \XINT_<expr>_op_<op>
  {%
    \expanded{\xint_noxpd{#2{##1}}\expandafter}%
    \romannumeral`&&@\expandafter#7%
    \romannumeral`&&@\expandafter#3\romannumeral`&&@\XINT_expr_getnext
  }%
  \def #3##1% \XINT_<expr>_check-_<op>
  {%
    \xint_UDsignfork
      ##1{\expandafter#4\romannumeral`&&@#5}%
        -{#4##1}%
    \krof
  }%
  \def #4##1##2% \XINT_<expr>_checkp_<op>
  {%
    \ifnum ##1>#6%
      \expandafter#4%
      \romannumeral`&&@\csname XINT_#9_op_##2\expandafter\endcsname
    \else
      \expandafter ##1\expandafter ##2%
    \fi
  }%
  \let #6\xint_c_x
  \def #7##1% \XINT_expr_checkc_<op>
  {%
    \ifnum ##1=\xint_c_x\expandafter#8\fi ##1%
  }%
  \edef #8##1##2##3% \XINT_expr_execc_<op>
  {%
    \csname XINT_expr_precedence_\string&\string&\endcsname
    \expandafter\noexpand\csname XINT_expr_itself_\string&\string&\endcsname
    {##3}%
    \XINTfstop.{##3}##2%
  }%
  \XINT_expr_defbin_dii #2% \XINT_expr_exec_<op>
}%
\def\XINT_expr_defbin_d #1#2%#3%
{%
  \expandafter\XINT_expr_defbin_di
  \csname XINT_#1_op_#2\expandafter\endcsname
  \csname XINT_#1_exec_#2\expandafter\endcsname
  \csname XINT_#1_check-_#2\expandafter\endcsname
  \csname XINT_#1_checkp_#2\expandafter\endcsname
  \csname XINT_#1_op_-xii\expandafter\endcsname
  \csname XINT_expr_precedence_#2\expandafter\endcsname
  \csname XINT_#1_checkc_#2\expandafter\endcsname
  \csname XINT_#1_execc_#2\endcsname
  {#1}%#3%
}%
%    \end{macrocode}
%\begin{lverb}
% Attention that third token here is left in stream by defbin_b, then
% also by defbin_c and is picked up as #2 of defbin_d. Had to work around TeX
% accepting only 9 arguments. Why did it not start counting at #0 like all
% decent mathematicians do?
%\end{lverb}
%    \begin{macrocode}
\XINT_expr_defbin_d {flexpr}<\calxFpLt% calx
\XINT_expr_defbin_d {iiexpr}<\calxiiLt
\XINT_expr_defbin_d {flexpr}>\calxFpGt% calx
\XINT_expr_defbin_d {iiexpr}>\calxiiGt
\XINT_expr_defbin_d {flexpr}{==}\calxFpEq% calx
\XINT_expr_defbin_d {iiexpr}{==}\calxiiEq
\XINT_expr_defbin_d {flexpr}{<=}\calxFpLtorEq% calx
\XINT_expr_defbin_d {iiexpr}{<=}\calxiiLtorEq
\XINT_expr_defbin_d {flexpr}{>=}\calxFpGtorEq% calx
\XINT_expr_defbin_d {iiexpr}{>=}\calxiiGtorEq
\XINT_expr_defbin_d {flexpr}{!=}\calxFpNotEq% calx
\XINT_expr_defbin_d {iiexpr}{!=}\calxiiNotEq
%    \end{macrocode}
% \subsubsection{Support macros for .., ..[ and ]..}
% \localtableofcontents
%
% \paragraph{\csh{xintSeq:tl:x}, \csh{xintfloatSeq:tl:x}}
%\begin{lverb}
% a..b: the integers from ceil(a) to floor(b), decreasing if floor(b) <
% ceil(a), both ends included, never an empty list (a = b non-integer:
% ceil(a), floor(a)). Values of any of the three parsers; the ends must be
% TeX integers. \xintSeq:tl:x (\xinteval, \xintiieval): M items
% (\CALX_seq_m); \xintfloatSeq:tl:x (\xintfloateval): F items (\CALX_seq_f).
% b = I-: the single item ceil(a). b = I+ or I?, or a an I value: an
% expandable error, empty list.
%
% ceil and floor by calxfp's \CALX_fint (sign s, |trunc| T, first omitted
% digit d, non-zero flag z) and its kind macros \CALX_fintk_c,
% \CALX_fintk_f: \CALX_seq_k writes sTs<k>sdz, i.e. s(T + a), in \numexpr.
% The loop carries the item builder after the two ends.
%\end{lverb}
%    \begin{macrocode}
\def\xintSeq:tl:x {\CALX_seq\CALX_seq_m}%
\def\xintfloatSeq:tl:x {\CALX_seq\CALX_seq_f}%
\def\CALX_seq_f #1.{\romannumeral0\CALX_ffromraw{#1[0]}}%
\def\CALX_seq #1#2#3%
   {\expandafter\CALX_seq_b\romannumeral`&&@#3\xint:#1{#2}}%
\def\CALX_seq_b #1#2\xint:#3#4%
{%
    \if I#1\xint_dothis{\CALX_seq_i#2\xint:#3{#4}}\fi
    \xint_orthat{\expandafter\CALX_seq_c\the\numexpr\expandafter\CALX_seq_k
      \romannumeral0\CALX_fint#1#2\xint:\CALX_fintk_f.#3{#4}}%
}%
\def\CALX_seq_k #1#2.#3#4#5{#1#2#1#5#1#3#4}%
\def\CALX_seq_i #1\xint:#2#3%
   {\if-#1\xint_dothis{\CALX_seq_c.#2{#3}}\fi\xint_orthat\CALX_seq_err}%
\def\CALX_seq_c #1.#2#3%
   {\expandafter\CALX_seq_d\romannumeral`&&@#3\xint:#1.#2}%
\def\CALX_seq_d #1#2\xint:#3.#4%
{%
    \if I#1\xint_dothis\CALX_seq_err\fi
    \xint_orthat{\expandafter\CALX_seq_e\the\numexpr\expandafter\CALX_seq_k
      \romannumeral0\CALX_fint#1#2\xint:\CALX_fintk_c.#3.#4}%
}%
\def\CALX_seq_err{\XINT_expandableerror{a..b: invalid range.}}%
\def\CALX_seq_e #1.#2.#3%
{%
    \if\relax\detokenize{#2}\relax\xint_dothis{{#3#1.}}\fi
    \ifnum#2=#1 \xint_dothis{{#3#1.}}\fi
    \ifnum#2<#1 \xint_dothis{\CALX_seq_n #1.#2.#3}\fi
    \xint_orthat{\CALX_seq_p #1.#2.#3}%
}%
\def\CALX_seq_p #1.#2.#3%
   {{#3#1.}\ifnum#1=#2 \CALX_seq_x\fi
    \expandafter\CALX_seq_p\the\numexpr#1+\xint_c_i.#2.#3}%
\def\CALX_seq_n #1.#2.#3%
   {{#3#1.}\ifnum#1=#2 \CALX_seq_x\fi
    \expandafter\CALX_seq_n\the\numexpr#1-\xint_c_i.#2.#3}%
\def\CALX_seq_x #1#2.#3.#4{#1}%
%    \end{macrocode}
%\begin{lverb}
% a..[d]..b of \xintfloateval and \xintiieval: from a by steps d while not
% beyond b; d = 0: a alone; nil if b is on the wrong side of a. Exact
% stepping and comparison: \xintfloatSeqB:tl:x on F values (\CALX_fexact:
% F, M and raw A[N] exactly, A/B[N] with B > 1 rounded to P digits;
% \CALX_faddx, \CALX_fcmp), \calxiiSeqB:tl:x on M values (\CALX_tom,
% \CALX_iiadd, \CALX_iicmp_x). An I value among a, d, b: expandable error,
% empty list. \xinteval has its own (xintexpr.sty).
%
% \CALX_seqb <conv><add><cmp>{a}{d}{b}: the three ends converted by
% <conv> (output Y\xint:), the sign of d by calxcore's \CALX_ifsgn. The loop \CALX_seqb_l
% {x}{d}{b}<add><cmp><order>: one comparison of x with b per item, the
% selectors \xint_stop_at...ofthree of <cmp> (equal, greater, less) taken
% in the order of \CALX_seqb_sw (d > 0: x against b) or \CALX_seqb_id
% (d < 0: b against x); the first step is a loop step with x = a.
%\end{lverb}
%    \begin{macrocode}
\def\xintfloatSeqB:tl:x #1#2%
   {\CALX_seqb\CALX_fexact\CALX_faddx\CALX_seqb_fc#1{#2}}%
\def\calxiiSeqB:tl:x #1#2{\CALX_seqb\CALX_tom\CALX_iiadd\CALX_seqb_ic#1{#2}}%
\def\CALX_seqb_fc #1#2%
   {\ifcase\CALX_fcmp{#1}{#2} \expandafter\xint_stop_atfirstofthree
    \or\expandafter\xint_stop_atsecondofthree
    \else\expandafter\xint_stop_atthirdofthree\fi}%
\def\CALX_seqb_ic #1#2{\CALX_iicmp_x#1\xint:#2\xint:}%
\def\CALX_seqb #1#2#3#4#5%
   {\expandafter\CALX_seqb_a\romannumeral0#1{#5}#1#2#3{#4}}%
\def\CALX_seqb_a #1\xint:#2#3#4#5%
   {\expandafter\CALX_seqb_b\romannumeral0#2{#5}{#1}#2#3#4}%
\def\CALX_seqb_b #1\xint:#2#3#4#5#6%
   {\expandafter\CALX_seqb_c\romannumeral0#3{#6}{#1}{#2}#4#5}%
\def\CALX_seqb_c #1\xint:#2#3%
   {\CALX_seqb_d #1\xint:#2\xint:#3\xint:{#1}{#2}{#3}}%
\def\CALX_seqb_d #1#2\xint:#3#4\xint:#5#6\xint:%
{%
    \if I#1\xint_dothis\CALX_seqb_e\fi
    \if I#3\xint_dothis\CALX_seqb_e\fi
    \if I#5\xint_dothis\CALX_seqb_e\fi
    \xint_orthat\CALX_seqb_f
}%
\def\CALX_seqb_e #1#2#3#4#5{\CALX_seq_err}%
\def\CALX_seqb_f #1#2#3#4#5%
   {\romannumeral0\CALX_ifsgn{#3}{\CALX_seqb_l{#2}{#3}{#1}#4#5\CALX_seqb_id}%
    {{#2}}{\CALX_seqb_l{#2}{#3}{#1}#4#5\CALX_seqb_sw}}%
\def\CALX_seqb_l #1#2#3#4#5#6%
   {\romannumeral0#6#5{#3}{#1}{{#1}}{}%
    {{#1}\expandafter\CALX_seqb_m\romannumeral0#4{#1}{#2}\xint:
     {#2}{#3}#4#5#6}}%
\def\CALX_seqb_m #1\xint:{\CALX_seqb_l{#1}}%
\def\CALX_seqb_id #1{#1}%
\def\CALX_seqb_sw #1#2#3{#1{#3}{#2}}%
%    \end{macrocode}
% \subsection{Square brackets [\texorpdfstring{\,}{ }] both as a container and a Python slicer}
% Refactored at |1.4|
%
%\begin{lverb}
% The architecture allows to implement separately a «left» and a «right»
% precedence and this is crucial.
%\end{lverb}
% \localtableofcontents
%
%
% \subsubsection{[...] as «oneple» constructor}
%
%\begin{lverb}
% In the definition of \XINT_expr_op_obracket the parameter
% is trash {}. The [ is intercepted by the getnextfork and handled
% via the \xint_c_ii^v highest precedence trick to get op_obracket
% executed.
%\end{lverb}
% \odef\MakePrivateLetters{\MakePrivateLetters\catcode`[ 11 \catcode`] 11 }^^A
%    \begin{macrocode}
\def\XINT_expr_itself_obracket{obracket}%
\catcode`] 11 \catcode`[ 11
\def\XINT_expr_defbin_ei #1#2#3#4#5#6%
{%
    \def #1##1%
    {%
      \expandafter#3\romannumeral`&&@\XINT_expr_getnext
    }%
    \def #2##1% op_]
    {%
      \expanded{\xint_noxpd{\XINT_expr_put_op_first{{##1}}}\expandafter}%
         \romannumeral`&&@\XINT_expr_getop
    }%
    \def #3##1%  until_cbracket_a
    {%
      \xint_UDsignfork
         ##1{\expandafter#4\romannumeral`&&@#5}%  #5 = op_-xii
           -{#4##1}%
      \krof
    }%
    \def #4##1##2%  until_cbracket_b
    {%
      \ifcase ##1\expandafter\XINT_expr_missing_]
      \or \expandafter\XINT_expr_missing_]
      \or \expandafter#2%
      \else
      \expandafter #4%
        \romannumeral`&&@\csname XINT_#6_op_##2\expandafter\endcsname
      \fi
    }%
}%
\def\XINT_expr_defbin_e #1%
{%
    \expandafter\XINT_expr_defbin_ei
    \csname XINT_#1_op_obracket\expandafter\endcsname
    \csname XINT_#1_op_]\expandafter\endcsname
    \csname XINT_#1_until_cbracket_a\expandafter\endcsname
    \csname XINT_#1_until_cbracket_b\expandafter\endcsname
    \csname XINT_#1_op_-xii\endcsname
    {#1}%
}%
\XINT_expr_defbin_e {flexpr}%
\XINT_expr_defbin_e {iiexpr}%
\def\XINT_expr_missing_]
   {\XINT_expandableerror{Ooops, looks like we are missing a ]. Aborting!}%
    \xint_c_ \XINT_expr_done}%
\let\XINT_expr_precedence_]\xint_c_ii
%    \end{macrocode}
% \subsubsection{[...] brackets and : operator for NumPy-like slicing and item
% indexing syntax}
%\begin{lverb}
% The opening bracket [ for the nutple constructor is filtered out by
% \XINT_expr_getnextfork and becomes «obracket» which behaves with
% precedence level 2. For the [..] Python slicer on the other hand, a real
% operator [ is defined with precedence level 4 (it must be higher than
% precedence level of commas) on its right and maximal precedence on its left.
%
% Important: although slicing and indexing shares many rules with Python/NumPy
% there are some significant differences: in particular there can not be any
% out-of-range error generated, slicing applies also to «oples» and not only
% to «nutple», and nested lists do not have to have their leaves at a constant
% depth. See the user manual.
%
% Currently, NumPy-like nested (basic) slicing is implemented, i.e [a:b, c:d,
% N, e:f, M] type syntax with Python rules regarding negative integers. This
% is parsed as an expression and can arise from expansion or contain
% calculations.
%
% Currently stepping, Ellipsis, and simultaneous multi-index extracting are
% not yet implemented.
%
% There are some subtle things here with possibility of variables been passed
% by reference.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_defbin_fi #1#2#3#4#5#6%
{%
    \def #1##1% \XINT_expr_op_[
    {%
        \expanded{\xint_noxpd{#2{##1}}\expandafter}%
        \romannumeral`&&@\expandafter#3\romannumeral`&&@\XINT_expr_getnext
    }%
    \def #2##1##2##3##4% \XINT_expr_exec_]
    {%
         \expandafter\XINT_expr_put_op_first
         \expanded
          {%
           {\XINT:NEhook:x:listsel\XINT_ListSel_top ##1__##4&%
            ({##1}\expandafter}%
           \expandafter
          }%
         \romannumeral`&&@\XINT_expr_getop
    }%
    \def #3##1% \XINT_expr_check-_]
    {%
      \xint_UDsignfork
        ##1{\expandafter#4\romannumeral`&&@#5}%
          -{#4##1}%
      \krof
    }%
    \def #4##1##2% \XINT_expr_checkp_]
    {%
      \ifcase ##1\XINT_expr_missing_]
        \or \XINT_expr_missing_]
        \or \expandafter##1\expandafter##2%
        \else \expandafter#4%
              \romannumeral`&&@\csname XINT_#6_op_##2\expandafter\endcsname
      \fi
    }%
}%
\let\XINT_expr_precedence_[ \xint_c_xx
\def\XINT_expr_defbin_f #1%
{%
    \expandafter\XINT_expr_defbin_fi
    \csname XINT_#1_op_[\expandafter\endcsname
    \csname XINT_#1_exec_]\expandafter\endcsname
    \csname XINT_#1_check-_]\expandafter\endcsname
    \csname XINT_#1_checkp_]\expandafter\endcsname
    \csname XINT_#1_op_-xii\endcsname
    {#1}%
}%
\XINT_expr_defbin_f {flexpr}%
\XINT_expr_defbin_f {iiexpr}%
\catcode`] 12 \catcode`[ 12
%    \end{macrocode}
% \let\MakePrivateLetters\xintexprMakePrivateLetters
%\begin{lverb}
% At 1.4 the getnext, scanint, scanfunc, getop chain got revisited to
% trigger automatic insertion of the nil variable if needed, without having in
% situations like here to define operators to support «[:» or «:]». And as we
% want to implement nested slicing à la NumPy, we would have had to handle
% also «:,» for example. Thus here we simply have to define the sole operator
% «:» and it will be some sort of inert joiner preparing a slicing spec.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_defbin_gi #1#2#3#4#5#6%
{%
    \def #1##1% \XINT_expr_op_:
    {%
        \expanded{\xint_noxpd{#2{##1}}\expandafter}%
        \romannumeral`&&@\expandafter#3\romannumeral`&&@\XINT_expr_getnext
    }%
    \def #2##1##2##3##4% \XINT_expr_exec_:
    {%
       ##2##3{:##1{0};##4:_}%
    }%
    \def #3##1% \XINT_expr_check-_:
    {\xint_UDsignfork
        ##1{\expandafter#4\romannumeral`&&@#5}%
          -{#4##1}%
     \krof
    }%
    \def #4##1##2% \XINT_expr_checkp_:
    {%
      \ifnum ##1>\XINT_expr_precedence_:
        \expandafter #4\romannumeral`&&@%
                       \csname XINT_#6_op_##2\expandafter\endcsname
      \else
        \expandafter##1\expandafter##2%
      \fi
    }%
}%
\let\XINT_expr_precedence_: \xint_c_vi
\def\XINT_expr_defbin_g #1%
{%
    \expandafter\XINT_expr_defbin_gi
    \csname XINT_#1_op_:\expandafter\endcsname
    \csname XINT_#1_exec_:\expandafter\endcsname
    \csname XINT_#1_check-_:\expandafter\endcsname
    \csname XINT_#1_checkp_:\expandafter\endcsname
    \csname XINT_#1_op_-xii\endcsname {#1}%
}%
\XINT_expr_defbin_g {flexpr}%
\XINT_expr_defbin_g {iiexpr}%
%    \end{macrocode}
% \subsubsection{Macro layer implementing indexing and slicing}
%\begin{lverb}
% xintexpr applies slicing not only to «objects» (which can be passed
% as arguments to functions) but also to «oples».
%
% Our «nlists» are not necessarily regular N-dimensional arrays à la NumPy.
% Leaves can be at arbitrary depths. If we were handling regular «ndarrays»,
% we could proceed a bit differently.
%
% For the related
% explanations, refer to the user manual.
%
% Notice that currently the code uses f-expandable (and not using \expanded)
% macros \xintApply, \xintApplyUnbraced, \xintKeep, \xintTrim, \xintNthOne from
% $xinttoolsnameimp.
%
% But the whole expansion happens inside an \expanded context, so possibly
% some gain could be achieved with x-expandable variants (xintexpr < 1.4
% had an \xintKeep:x:csv).
%
% I coded \xintApply:x and \xintApplyUnbraced:x in $xinttoolsnameimp, Brief
% testing indicated they were perhaps a bit better for 5x5x5x5 and 15x15x15x15
% arrays of 8 digits numbers and for 30x30x15 with 16 digits numbers: say
% 1$% gain... this seems to raise to between 4$% and
% 5$% for 400x400 array of 1 digit...
%
% Currently sticking with old macros.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_ListSel_deeper #1%
{%
    \if :#1\xint_dothis\XINT_ListSel_slice_next\fi
    \xint_orthat {\XINT_ListSel_extract_next {#1}}%
}%
\def\XINT_ListSel_slice_next #1(%
{%
    \xintApply{\XINT_ListSel_recurse{:#1}}%
}%
\def\XINT_ListSel_extract_next #1(%
{%
    \xintApplyUnbraced{\XINT_ListSel_recurse{#1}}%
}%
\def\XINT_ListSel_recurse #1#2%
{%
    \XINT_ListSel_check #2__#1({#2}\expandafter\empty\empty
}%
\def\XINT_ListSel_check{\expandafter\XINT_ListSel_check_a \string}%
\def\XINT_ListSel_check_a #1%
{%
    \if #1\bgroup\xint_dothis\XINT_ListSel_check_is_ok\fi
    \xint_orthat\XINT_ListSel_check_leaf
}%
\def\XINT_ListSel_check_leaf #1\expandafter{\expandafter}%
\def\XINT_ListSel_check_is_ok
{%
    \expandafter\XINT_ListSel_check_is_ok_a\expandafter{\string}%
}%
\def\XINT_ListSel_check_is_ok_a #1__#2%
{%
    \if :#2\xint_dothis{\XINT_ListSel_slice}\fi
    \xint_orthat {\XINT_ListSel_nthone {#2}}%
}%
\def\XINT_ListSel_top #1#2%
{%
    \if _\noexpand#2%
           \expandafter\XINT_ListSel_top_one_or_none\string#1.\else
           \expandafter\XINT_ListSel_top_at_least_two\fi
}%
\def\XINT_ListSel_top_at_least_two #1__{\XINT_ListSel_top_ople}%
\def\XINT_ListSel_top_one_or_none #1%
{%
    \if #1_\xint_dothis\XINT_ListSel_top_nil\fi
    \if #1.\xint_dothis\XINT_ListSel_top_nutple_a\fi
    \if #1\bgroup\xint_dothis\XINT_ListSel_top_nutple\fi
    \xint_orthat\XINT_ListSel_top_number
}%
\def\XINT_ListSel_top_nil #1\expandafter#2\expandafter{\fi\expandafter}%
\def\XINT_ListSel_top_nutple
{%
    \expandafter\XINT_ListSel_top_nutple_a\expandafter{\string}%
}%
\def\XINT_ListSel_top_nutple_a #1_#2#3(#4%
{%
    \fi\if :#2\xint_dothis{{\XINT_ListSel_slice #3(#4}}\fi
    \xint_orthat {\XINT_ListSel_nthone {#2}#3(#4}%
}%
\def\XINT_ListSel_top_number #1_{\fi\XINT_ListSel_top_ople}%
\def\XINT_ListSel_top_ople #1%
{%
    \if :#1\xint_dothis\XINT_ListSel_slice\fi
    \xint_orthat {\XINT_ListSel_nthone {#1}}%
}%
\def\XINT_ListSel_slice #1%
{%
    \expandafter\XINT_ListSel_slice_a \expandafter{\romannumeral0%
    \expandafter\CALX_fnum\romannumeral`&&@\xint_firstofone#1\xint:}%
}%
\def\XINT_ListSel_slice_a #1#2;#3#4%
{%
   \if _#4\expandafter\XINT_ListSel_s_b
          \else\expandafter\XINT_ListSel_slice_b\fi
   #1;#3%
}%
\def\XINT_ListSel_s_b #1#2;#3#4%
{%
    \if &#4\expandafter\XINT_ListSel_s_last\fi
    \XINT_ListSel_s_c #1{#1#2}{#4}%
}%
\def\XINT_ListSel_s_last\XINT_ListSel_s_c #1#2#3(#4%
{%
   \if-#1\expandafter\xintKeep\else\expandafter\xintTrim\fi {#2}{#4}%
}%
\def\XINT_ListSel_s_c #1#2#3(#4%
{%
   \expandafter\XINT_ListSel_deeper
   \expanded{\xint_noxpd{#3}(\expandafter}\expandafter{%
   \romannumeral0%
   \if-#1\expandafter\xintkeep\else\expandafter\xinttrim\fi {#2}{#4}}%
}%
%    \end{macrocode}
%\begin{lverb}
%
% \xintNthElt from xinttools (knowingly) strips one level of
% braces when fetching kth «item» from {v1}...{vN}. If we expand
% {\xintNthElt{k}{{v1}...{vN}}} (notice external braces):
%
%( if k is out of range we end up with {}
%: if k is in range and the kth braced item was {} we end up with {}
%: if k is in range and the kth braced item was {17} we end up with {17}
%)
%
% Problem is that individual numbers such as 17 are stored {{17}}. So
% we must have one more brace pair and in the first two cases we end up
% with {{}}. But in the first case we should end up with the empty ople
% {}, not the empty bracketed ople {{}}.
%
% I have thus added \xintNthOne to $xinttoolsnameimp which does not
% strip brace pair from an extracted item.
%
% Attention: \XINT_nthonepy_a does no expansion on second argument.
% But here arguments are either numerical or already expanded.
% Normally.
%
%\end{lverb}
%    \begin{macrocode}
\def\XINT_ListSel_nthone #1#2%
{%
    \if &#2\expandafter\XINT_ListSel_nthone_last\fi
    \XINT_ListSel_nthone_a {#1}{#2}%
}%
\def\XINT_ListSel_nthone_a #1#2(#3%
{%
    \expandafter\XINT_ListSel_deeper
    \expanded{\xint_noxpd{#2}(\expandafter}\expandafter{%
    \romannumeral0\expandafter\XINT_nthonepy_a\the\numexpr
    \calxListItemToNum{#1}.{#3}}%
}%
\def\XINT_ListSel_nthone_last\XINT_ListSel_nthone_a #1#2(%#3%
{%
    \romannumeral0\expandafter\XINT_nthonepy_a\the\numexpr
    \calxListItemToNum{#1}.%{#3}
}%
%    \end{macrocode}
%\begin{lverb}
% The macros here are basically f-expandable and use the
% f-expandable \xintKeep and \xintTrim. Prior to xint 1.4, there was
% here an x-expandable \xintKeep:x:csv dealing with comma separated
% items, for time being we make do with our f-expandable toolkit.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_ListSel_slice_b #1;#2_#3%
{%
    \if &#3\expandafter\XINT_ListSel_slice_last\fi
    \expandafter\XINT_ListSel_slice_c \expandafter{\romannumeral0%
    \expandafter\CALX_fnum\romannumeral`&&@\xint_firstofone#2\xint:};#1;{#3}%
}%
\def\XINT_ListSel_slice_last\expandafter\XINT_ListSel_slice_c #1;#2;#3(%#4
{%
   \expandafter\XINT_ListSel_slice_last_c #1;#2;%{#4}
}%
%    \end{macrocode}
% \changed{1.4n}
% Compatibility with LuaMeta\TeX{} regarding |;| not usable as \cs{numexpr}
% delimiter.  Fortunately I had mostly used \cs{xint:} or a dot in the past
% throughout the code base, so not many locations needed adjustments.  Here I
% simpy replaced all semi-colons by fullstops starting here with how
% \csbXINT{_ListSel_slice_d} receives arguments.  Fortuntely
% \csbxint{_gob_til_sc} was not used around here.
%    \begin{macrocode}
\def\XINT_ListSel_slice_last_c #1;#2;#3%
{%
    \romannumeral0\XINT_ListSel_slice_d #2.#1.{#3}%
}%
\def\XINT_ListSel_slice_c #1;#2;#3(#4%
{%
   \expandafter\XINT_ListSel_deeper
   \expanded{\xint_noxpd{#3}(\expandafter}\expandafter{%
   \romannumeral0\XINT_ListSel_slice_d #2.#1.{#4}}%
}%
\def\XINT_ListSel_slice_d #1#2.#3#4.%
{%
    \xint_UDsignsfork
       #1#3\XINT_ListSel_N:N
        #1-\XINT_ListSel_N:P
        -#3\XINT_ListSel_P:N
         --\XINT_ListSel_P:P
    \krof #1#2.#3#4.%
}%
\def\XINT_ListSel_P:P #1.#2.#3%
{%
    \unless\ifnum #1<#2 \expandafter\xint_gob_andstop_iii\fi
    \xintkeep{#2-#1}{\xintTrim{#1}{#3}}%
}%
\def\XINT_ListSel_N:N #1.#2.#3%
{%
    \expandafter\XINT_ListSel_N:N_a
    \the\numexpr #2-#1\expandafter.\the\numexpr#1+\xintLength{#3}.{#3}%
}%
\def\XINT_ListSel_N:N_a #1.#2.#3%
{%
    \unless\ifnum #1>\xint_c_ \expandafter\xint_gob_andstop_iii\fi
    \xintkeep{#1}{\xintTrim{\ifnum#2<\xint_c_\xint_c_\else#2\fi}{#3}}%
}%
\def\XINT_ListSel_N:P #1.#2.#3%
{%
    \expandafter\XINT_ListSel_N:P_a
    \the\numexpr #1+\xintLength{#3}.#2.{#3}%
}%
\def\XINT_ListSel_N:P_a #1#2.%
   {\if -#1\expandafter\XINT_ListSel_O:P\fi\XINT_ListSel_P:P #1#2.}%
\def\XINT_ListSel_O:P\XINT_ListSel_P:P #1.{\XINT_ListSel_P:P 0.}%
\def\XINT_ListSel_P:N #1.#2.#3%
{%
    \expandafter\XINT_ListSel_P:N_a
    \the\numexpr #2+\xintLength{#3}.#1.{#3}%
}%
\def\XINT_ListSel_P:N_a #1#2.#3.%
   {\if -#1\expandafter\XINT_ListSel_P:O\fi\XINT_ListSel_P:P #3.#1#2.}%
\def\XINT_ListSel_P:O\XINT_ListSel_P:P #1.#2.{\XINT_ListSel_P:P #1.0.}%
%    \end{macrocode}
% \subsection{Support for raw A/B[N]}
%\begin{lverb}
% Releases earlier than 1.1 required the use of braces around A/B[N]
% input. The [N] is now implemented directly. *BUT* this uses a delimited macro!
% thus N is not allowed to be itself an expression (I could add it...).
% \xintE, \xintiiE, and \XINTinFloatE all put #2 in a \numexpr. But attention
% to the fact that \numexpr stops at spaces separating digits:
% \the\numexpr 3 + 7 9\relax gives 109\relax !! Hence we have to be
% careful.
%
% \numexpr will not handle catcode 11 digits, but adding a \detokenize will
% suddenly make illicit for N to rely on macro expansion.
%
% At 1.4, [ is already overloaded and it is not easy to support this. We do
% this by a kludge maintaining more or less former (very not efficient) way
% but using $$ sign which is free for time being. No, finally I use the null
% character, should be safe enough! (I hesitated about using R with catcode
% 12).
%
% As for ? operator we needed
% to hack into \XINT_expr_getop_b for intercepting that pseudo operator. See
% also \XINT_expr_scanint_c (\XINT_expr_rawxintfrac).
%
% calx: the precedence 14 of &&@ is not above the right precedence of ^
% (17): 2^3[1] is (2^3)[1]. The finisher operators &&B, &&C below use 22.
% \xintiieval: raw [N] goes through \CALX_iilit (integer check, M or
% raw), not \xintiiE.
%\end{lverb}
% \odef\MakePrivateLetters{\MakePrivateLetters\catcode`& 11 }^^A
%    \begin{macrocode}
\catcode0 11
\let\XINT_expr_precedence_&&@ \xint_c_xiv
\def\CALX_iiE #1{\CALX_iiE_a #1[0]\xint:}%
\def\CALX_iiE_a #1[#2]#3\xint:#4%
   {\expandafter\CALX_iiE_b\the\numexpr#2+#4.{#1}}%
\def\CALX_iiE_b #1.#2{\CALX_iilit{#2}{#1}}%
\def\CALX_rawE #1{\CALX_rawE_a #1[0]\xint:}%
\def\CALX_rawE_a #1[#2]#3\xint:#4{\xint_noxpd{#1}[\the\numexpr#2+#4\relax]}%
\def\XINT_iiexpr_op_&&@ #1#2]%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded{{{\romannumeral0\CALX_iiE#1{\xint_zapspaces #2 \xint_gobble_i}}}%
    \expandafter}\romannumeral`&&@\XINT_expr_getop
}%
\def\XINT_flexpr_op_&&@ #1#2]%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded{{{\calxFpE#1{\xint_zapspaces #2 \xint_gobble_i}}}%
    \expandafter}\romannumeral`&&@\XINT_expr_getop
}%
%    \end{macrocode}
%\begin{lverb}
% calx: fake operator &&B (integer exits of the number scanner):
% [0] appended in \xinteval and \xintfloateval; M in \xintiieval
% (\CALX_mfromraw; raw in compiled functions, see
% \XINT_expr_redefinemacros).
%\end{lverb}
%    \begin{macrocode}
\catcode2 11
\def\XINT_flexpr_op_&&B #1%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded{{{\xint_noxpd#1[0]}}\expandafter}%
    \romannumeral`&&@\XINT_expr_getop
}%
\def\XINT_iiexpr_op_&&B #1%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded{{{\romannumeral0\CALX_mfromraw#1}}\expandafter}%
    \romannumeral`&&@\XINT_expr_getop
}%
\catcode2 12
%    \end{macrocode}
%\begin{lverb}
% calx: fake operator &&C (decimal and exponent exits of the number
% scanner): #2 is the exponent; [#2] appended (as 1.4p); \xintiieval:
% \CALX_iilit (M if the value is an integer, else raw A[N]). Raw [N]
% (&&@) in \xintiieval: same. In compiled functions and macros the three
% \xintiieval operators keep the literal raw (\XINT_expr_redefinemacros).
%\end{lverb}
%    \begin{macrocode}
\catcode3 11
\def\XINT_flexpr_op_&&C #1#2]%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded{{{\xint_noxpd#1[#2]}}\expandafter}%
    \romannumeral`&&@\XINT_expr_getop
}%
\def\XINT_iiexpr_op_&&C #1#2]%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded{{{\romannumeral0\CALX_iilit#1{#2}}}\expandafter}%
    \romannumeral`&&@\XINT_expr_getop
}%
\catcode3 12
\catcode0 12
%    \end{macrocode}
% \let\MakePrivateLetters\xintexprMakePrivateLetters
% \subsection{? as two-way and ?? as three-way «short-circuit» conditionals}
%\begin{lverb}
% Comments undergoing reconstruction.
%\end{lverb}
%
%    \begin{macrocode}
\let\XINT_expr_precedence_? \xint_c_xx
\catcode`- 11
%    \end{macrocode}
% \odef\MakePrivateLetters{\MakePrivateLetters\catcode`- 11 }\FixInterMacrocodeVspace
%    \begin{macrocode}
\def\XINT_flexpr_op_?{\XINT_expr_op__? \XINT_flexpr_op_-xii}%
\def\XINT_iiexpr_op_?{\XINT_expr_op__? \XINT_iiexpr_op_-xii}%
\catcode`- 12
\def\XINT_expr_op__? #1#2#3%
    {\XINT_expr_op__?_a #3!\xint_bye\XINT_expr_exec_? {#1}{#2}{#3}}%
\def\XINT_expr_op__?_a #1{\expandafter\XINT_expr_op__?_b\detokenize{#1}}%
\def\XINT_expr_op__?_b #1%
    {\if ?#1\expandafter\XINT_expr_op__?_c\else\expandafter\xint_bye\fi }%
\def\XINT_expr_op__?_c #1{\xint_gob_til_! #1\XINT_expr_op_?? !\xint_bye}%
\def\XINT_expr_op_?? !\xint_bye\xint_bye\XINT_expr_exec_?{\XINT_expr_exec_??}%
\catcode`- 11
\def\XINT_expr_exec_? #1#2%
{%
    \expandafter\XINT_expr_check-_after?\expandafter#1%
    \romannumeral`&&@\expandafter\XINT_expr_getnext\romannumeral0\CALX_ifnz#2%
}%
\def\XINT_expr_exec_?? #1#2#3%
{%
    \expandafter\XINT_expr_check-_after?\expandafter#1%
    \romannumeral`&&@\expandafter\XINT_expr_getnext\romannumeral0\CALX_ifsgn#2%
}%
\def\XINT_expr_check-_after? #1{%
\def\XINT_expr_check-_after? ##1##2%
{%
    \xint_UDsignfork
        ##2{##1}%
        #1{##2}%
    \krof
}}\expandafter\XINT_expr_check-_after?\string -%
\catcode`- 12
%    \end{macrocode}
% \let\MakePrivateLetters\xintexprMakePrivateLetters
% \subsection{! as postfix factorial operator}
%    \begin{macrocode}
\let\XINT_expr_precedence_! \xint_c_xx
\def\XINT_flexpr_op_! #1%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded{{\romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpFacdigits#1}}\expandafter}%
    \romannumeral`&&@\XINT_expr_getop
}%
\def\XINT_iiexpr_op_! #1%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded{{\romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxiiFac#1}}\expandafter}%
    \romannumeral`&&@\XINT_expr_getop
}%
%    \end{macrocode}
%\begin{lverb}
% At 1.4g, fix for input "x! == y" via a fake operator !==. The !
% is of catcode 11 but this does not matter here. The definition of
% \XINT_expr_itself_!== is required by the functioning of the scanop macros.
%
% We don't have to worry about "x! = y" as the single-character Boolean
% comparison = operator has been removed from syntax.  Fixing it would have
% required obeying space tokens when parsing operators.  For "x! == y" case,
% obeying space tokens would not solve "x!==y" input case anyhow.
%\end{lverb}
%    \begin{macrocode}
\expandafter
\def\csname XINT_expr_precedence_!==\expandafter\endcsname
    \csname XINT_expr_itself_!==\endcsname {\XINT_expr_precedence_! !==}%
\expandafter\def\csname XINT_expr_itself_!==\endcsname{!==}%
%    \end{macrocode}
% \subsection{User defined variables}
% \localtableofcontents
%
% \subsubsection{\csh{xintdefiivar},
% \csh{xintdeffloatvar}}
% \changed{1.1}
% \changed[2017/12/01]{1.2p} Extends |\xintdefvar| et al.\@{} to accept
% simultaneous assignments to multiple variables.
% \changed[2018/06/17]{1.3c}
% Use \csbxint{exprSafeCatcodes} (to palliate issue with
% active semi-colon from Babel+French if in body of a \LaTeX{} document).
%
% And allow usage with both syntaxes |name:=expr;| or |name=expr;|. Also the
% colon may have catcode 11, 12, or 13 with  no issue.
% Variable names may contain letters, digits, underscores, and must not start
% with a digit. Names starting with |@| or an underscore are reserved.
%
% \begin{itemize}[nosep]
%   \item currently |@|, |@1|, |@2|, |@3|, and |@4| are reserved because they
%     have special meanings for use in iterations,
%   \item |@@|, |@@@|, |@@@@| are also reserved but
% are technically functions, not variables: a user may possibly define |@@| as
% a variable name, but if it is followed by parentheses, the function
% interpretation will be applied (rather than the variable interpretation
% followed by a tacit multiplication),
%   \item since |1.2l|, the underscore |_| may be used as separator of digits in
%     long numbers.
%     Hence a variable whose name starts with |_| will not play well with the
%     mechanism of tacit multiplication of variables by numbers: the underscore
%     will be removed from input stream by the number scanner, thus creating
%     an undefined or wrong variable name, or none at all if the variable
%     name was an initial |_| followed by digits.
% \end{itemize}
%
%\begin{lverb}
% Note that the optional argument [P] as usable with
%  \xintfloatexpr is **not**
% supported by \xintdeffloatvar. One must do \xintdeffloatvar
% foo = \xintfloatexpr[16] blabla \relax; to achieve the effect.
%\end{lverb}
%
% \changed[2020/01/27]{1.4}
% The expression will be fetched up to final semi-colon in a manner
% allowing inner semi-colons as used in the iter(), rseq(), subsm(),
% subsn() etc... syntax. They don't need to be hidden within a
% braced pair anymore.
%
% \changed{1.4}
% Automatic unpacking in case of simultaneous assignments if the expression
% evaluates to a nutple.
%
% Notes (added much later on 2021/06/10 during preparation of |1.4i|):
% \begin{enumerate}
% \item the code did not try to intercept illicit syntax such as
%   |\xintdefvar a,b,c:=<number>;|. It blindly «unpacked» the number handling it as if
%   it was a nutple.  The extended functionality added at |1.4i| requires to
%   check for such a situation, as the syntax is not illicit anymore.
% \item the code was broken in case the expression to evaluate was an ople of
%   length 10 or more, due to a silly mistake at some point during |1.4|
%   development which replaced some |\ifnum| by an |\if|, perhaps due to
%   mental confusion with the fact that functions can have at most 9
%   arguments, but here the code is about defining variables.  Anyway this got
%   fixed as corollary to the |1.4i| extension.
% \end{enumerate}
%
%
% \changed[2021/02/20]{1.4c} One year later I realized I had broken tacit
% multiplication for situations such as |variable(1+2)|.  As hinted at in
% comments above before |1.4| release I had been doing some deep refactoring
% here, which I cancelled almost completely in the end... but not quite, and
% as a result there was a problem that some macro holding braced contents was
% expanded to late, once it was in old core routines of xintfrac not expecting
% other things than digits. I do an emergency bugfix here with some
% |\expandafter|'s but I don't have the code in my brain at this time, and
% don't have the luxury now to invest into it. Let's hope this does not induce
% breakage elsewhere, and that the February 2020 |1.4| did not break something
% else.
%
% \changed[2021/04/17]{1.4e}
%\begin{lverb}
% Modifies \xintdeffloatvar to round to the prevailing
% precision (formerly, any operation would induce rounding, but in case of
% things such as \xintdeffloatvar foo:=\xintexpr 1/100!\relax; there was no
% automatic rounding.  One could use 0+ syntax to trigger it, and for oples,
% some trick like \xintfloatexpr[\XINTdigits]...\relax extra wrapper.
%\end{lverb}
% \changed[2021/05/22]{1.4g}
%\begin{lverb}
% The \expandafter\expandafter\expandafter et al. chain
% which was kept by \XINT_expr_defvar_one_b for expanding only at time of use
% the \XINT_expr_var_foo in \XINT_expr_onliteral_foo were senseless overhead
% added at 1.4c. This is used only for real variables, not dummy variables or
% fake variables and it is simpler to have the \XINT_expr_var_foo
% pre-expanded. So let's use some \edef here.
%
% The \XINT_expr_onliteral_foo is expanded as result of action of \XINT_expr_op_`
% (or \XINT_flexpr_op_`, \XINT_iiexpr_op_`) which itself was triggered consuming
% already an \XINT_expr_put_op_first, so its expansion has to produce tokens
% as expected after \XINT_expr_put_op_first$empty:
% <precedence token><op token>{expanded value}.
%\end{lverb}
%
% \changed[2021/06/10]{1.4i}
% Implement extended notion of simultaneous assignments: if there are more
% variables than values, define the extra variables to be nil. If there are
% less variables than values let the last variable
% be defined as the ople concatenating all non reclaimed values.
%
% If there are at least two variables, the right hand side, if it turns out to
% be a nutple, is (as since |1.4|) automatically unpacked, then the above
% rules apply.
%
% \changed[2021/06/11]{1.4i}
%\begin{lverb}
% Fix the long-standing «seq renaming bug» via a change here of the
% name of auxiliary macro.  Previously «onliteral_<varname>» now
% «var*_<varname>». I hesitated with using «var_varname*» rather.
%
% Hesitated adding \XINT_expr_letvar_one (motivation: case of simultaneous
% assignments leading to defining «nil» variables).  Finally, no.
%\end{lverb}
%
% \odef\MakePrivateLetters{\MakePrivateLetters\catcode`* 11 }^^A
%    \begin{macrocode}
\catcode`* 11
\def\XINT_expr_defvar_one #1#2%
{%
    \XINT_global
    \expandafter\edef\csname XINT_expr_varvalue_#1\endcsname {#2}%
    \XINT_expr_defvar_one_b {#1}%
}%
\def\XINT_expr_defvar_one_b #1%
{%
    \XINT_global
    \expandafter\edef\csname XINT_expr_var_#1\endcsname
        {{\expandafter\noexpand\csname XINT_expr_varvalue_#1\endcsname}}%
    \XINT_global
    \expandafter\edef\csname XINT_expr_var*_#1\endcsname
        {\XINT_expr_prec_tacit *\csname XINT_expr_var_#1\endcsname(}%
    \ifxintverbose\xintMessage{xintexpr}{Info}%
       {Variable #1 \ifxintglobaldefs globally \fi
        defined with value \csname XINT_expr_varvalue_#1\endcsname.}%
    \fi
}%
\catcode`* 12
\catcode`~ 13
\catcode`: 12
\def\XINT_expr_defvar_getname #1:#2~%
{%
    \endgroup
    \def\XINT_defvar_tmpa{#1}\edef\XINT_defvar_tmpc{\xintCSVLength{#1}}%
}%
\def\XINT_expr_defvar #1#2%
{%
    \def\XINT_defvar_tmpa{#2}%
    \expandafter\XINT_expr_defvar_a\expanded{\xint_noxpd{{#1}}\expandafter}%
    \romannumeral\XINT_expr_fetch_to_semicolon
}%
\def\XINT_expr_defvar_a #1#2%
{%
    \xintexprRestoreCatcodes
%    \end{macrocode}
% \let\MakePrivateLetters\xintexprMakePrivateLetters
%\begin{lverb}
% Maybe SafeCatcodes was without effect because the colon and the rest
% are from some earlier macro definition. Give a safe definition to active
% colon (even if in math mode with a math active colon..).
%
% The \XINT_expr_defvar_getname closes the group opened here.
%\end{lverb}
%    \begin{macrocode}
    \begingroup\lccode`~`: \lowercase{\let~}\empty
    \edef\XINT_defvar_tmpa{\XINT_defvar_tmpa}%
    \edef\XINT_defvar_tmpa{\xint_zapspaces_o\XINT_defvar_tmpa}%
    \expandafter\XINT_expr_defvar_getname
                \detokenize\expandafter{\XINT_defvar_tmpa}:~%
    \ifcase\XINT_defvar_tmpc\space
      \xintMessage {xintexpr}{Error}
      {Aborting: not allowed to declare variable with empty name.}%
    \or
     \XINT_global
     \expandafter
     \edef\csname XINT_expr_varvalue_\XINT_defvar_tmpa\endcsname{#1#2\relax}%
     \XINT_expr_defvar_one_b\XINT_defvar_tmpa
    \else
     \edef\XINT_defvar_tmpb{#1#2\relax}%
     \edef\XINT_defvar_tmpd{\expandafter\xintLength\expandafter
                            {\XINT_defvar_tmpb}}%
     \ifnum\XINT_defvar_tmpd=\xint_c_i
         \oodef\XINT_defvar_tmpb{\expandafter\xint_firstofone
                       \XINT_defvar_tmpb}%
         \if0\expandafter\expandafter\expandafter\XINT_defvar_checkifnutple
                     \expandafter\string\XINT_defvar_tmpb _\xint_bye
           \odef\XINT_defvar_tmpb{\expandafter{\XINT_defvar_tmpb}}%
         \else
           \edef\XINT_defvar_tmpd{\expandafter\xintLength
                                  \expandafter{\XINT_defvar_tmpb}}%
         \fi
     \fi
     \xintAssignArray\xintCSVtoList\XINT_defvar_tmpa\to\XINT_defvar_tmpvar
     \def\XINT_defvar_tmpe{1}%
     \expandafter\XINT_expr_defvar_multiple\XINT_defvar_tmpb\relax
   \fi
}%
\def\XINT_defvar_checkifnutple#1%
{%
    \if#1_1\fi
    \if#1\bgroup1\fi
    0\xint_bye
}%
\def\XINT_expr_defvar_multiple
{%
    \ifnum\XINT_defvar_tmpe<\XINT_defvar_tmpc\space
        \expandafter\XINT_expr_defvar_multiple_one
    \else
        \expandafter\XINT_expr_defvar_multiple_last\expandafter\empty
    \fi
}%
\def\XINT_expr_defvar_multiple_one
{%
    \ifnum\XINT_defvar_tmpe>\XINT_defvar_tmpd\space
       \expandafter\XINT_expr_defvar_one
       \csname XINT_defvar_tmpvar\XINT_defvar_tmpe\endcsname{}%
       \edef\XINT_defvar_tmpe{\the\numexpr\XINT_defvar_tmpe+1}%
       \expandafter\XINT_expr_defvar_multiple
    \else
       \expandafter\XINT_expr_defvar_multiple_one_a
    \fi
}%
\def\XINT_expr_defvar_multiple_one_a #1%
{%
    \expandafter\XINT_expr_defvar_one
       \csname XINT_defvar_tmpvar\XINT_defvar_tmpe\endcsname{{#1}}%
    \edef\XINT_defvar_tmpe{\the\numexpr\XINT_defvar_tmpe+1}%
    \XINT_expr_defvar_multiple
}%
\def\XINT_expr_defvar_multiple_last #1\relax
{%
    \expandafter\XINT_expr_defvar_one
       \csname XINT_defvar_tmpvar\XINT_defvar_tmpe\endcsname{#1}%
    \xintRelaxArray\XINT_defvar_tmpvar
    \let\XINT_defvar_tmpa\empty
    \let\XINT_defvar_tmpb\empty
    \let\XINT_defvar_tmpc\empty
    \let\XINT_defvar_tmpd\empty
    \let\XINT_defvar_tmpe\empty
}%
\catcode`~ 3
\catcode`: 11
%    \end{macrocode}
%\begin{lverb}
% This SafeCatcodes is mainly in the hope that semi-colon ending the
% expression can still be sanitized.
%
% Pre 1.4e definition:
%(\def\xintdeffloatvar      {\xintexprSafeCatcodes\xintdeffloatvar_a}%
%:\def\xintdeffloatvar_a #1={\XINT_expr_defvar\xintthebarefloateval{#1}}%
%)
% This would keep the value (or values) with extra digits, now.
% If this is actually wanted one can use
% \xintdefvar foo:=\xintfloatexpr...\relax;
% syntax, but recalling that only operations trigger the rounding inside
% \xintfloatexpr. Some tricks are needed for no operations case if multiple or
% nested values. But for a single one, one can use simply the float()
% function.
%
%\end{lverb}
%    \begin{macrocode}
\def\xintdefiivar     {\xintexprSafeCatcodes\xintdefiivar_a}%
\def\xintdefiivar_a#1={\XINT_expr_defvar\xintthebareiieval{#1}}%
\def\xintdeffloatvar  {\xintexprSafeCatcodes\xintdeffloatvar_a}%
\def\xintdeffloatvar_a #1={\XINT_expr_defvar\xintthebareroundedfloateval{#1}}%
%    \end{macrocode}
% \subsubsection{\csh{xintunassignvar}}
% \changed{1.2e}
% \changed{1.3d}
% Embarrassingly I had for a long time a misunderstanding of |\ifcsname|
% (let's blame its documentation) and I was not aware that it chooses FALSE
% branch if tested control sequence has been |\let| to |\undefined|... So
% earlier version didn't do the right thing (and had another bug: failure to
% protect |\.=0| from expansion).
%
% The |\ifcsname| tests are done in \csbXINT{_expr_op__} and
% \csbXINT{_expr_op_`}.
%
% \changed{1.4i}
% Track |s/onliteral/var*/| change in macro names.
%    \begin{macrocode}
\def\xintunassignvar #1{%
   \edef\XINT_unvar_tmpa{#1}%
   \edef\XINT_unvar_tmpa {\xint_zapspaces_o\XINT_unvar_tmpa}%
   \ifcsname XINT_expr_var_\XINT_unvar_tmpa\endcsname
       \ifnum\expandafter\xintLength\expandafter{\XINT_unvar_tmpa}=\@ne
         \expandafter\xintnewdummy\XINT_unvar_tmpa
       \else
         \XINT_global\expandafter
           \let\csname XINT_expr_varvalue_\XINT_unvar_tmpa\endcsname
               \XINT_undefined
         \XINT_global\expandafter
           \let\csname XINT_expr_var_\XINT_unvar_tmpa\endcsname
               \XINT_undefined
         \XINT_global\expandafter
           \let\csname XINT_expr_var*_\XINT_unvar_tmpa\endcsname
               \XINT_undefined
         \ifxintverbose\xintMessage {xintexpr}{Info}%
           {Variable \XINT_unvar_tmpa\space has been
            \ifxintglobaldefs globally \fi ``unassigned''.}%
         \fi
       \fi
   \else
       \xintMessage {xintexpr}{Warning}
           {Error: there was no such variable \XINT_unvar_tmpa\space
            to unassign.}%
   \fi
}%
%    \end{macrocode}
% \subsection{Support for dummy variables}
% \localtableofcontents
% \subsubsection{\csh{xintnewdummy}}
%\begin{lverb}
% Comments under reconstruction.
%
% 1.4 adds multi-letter names as usable dummy variables!
%\end{lverb}
% \changed[2021/06/11]{1.4i}
%\begin{lverb}
% s/onliteral/var*/ to fix the «seq renaming bug».
%\end{lverb}
%    \begin{macrocode}
\catcode`* 11
\def\XINT_expr_makedummy #1%
{%
   \edef\XINT_tmpa{\xint_zapspaces #1 \xint_gobble_i}%
   \ifcsname XINT_expr_var_\XINT_tmpa\endcsname
     \XINT_global
     \expandafter\let\csname XINT_expr_var_\XINT_tmpa/old\expandafter\endcsname
                     \csname XINT_expr_var_\XINT_tmpa\expandafter\endcsname
   \fi
   \ifcsname XINT_expr_var*_\XINT_tmpa\endcsname
     \XINT_global
     \expandafter\let\csname XINT_expr_var*_\XINT_tmpa/old\expandafter
     \endcsname\csname XINT_expr_var*_\XINT_tmpa\expandafter\endcsname
   \fi
   \expandafter\XINT_global
   \expanded
   {\edef\expandafter\noexpand
         \csname XINT_expr_var_\XINT_tmpa\endcsname ##1\relax
         !\XINT_tmpa##2}%
      {{##2}##1\relax !\XINT_tmpa{##2}}%
   \expandafter\XINT_global
   \expanded
   {\edef\expandafter\noexpand
         \csname XINT_expr_var*_\XINT_tmpa\endcsname ##1\relax
         !\XINT_tmpa##2}%
      {\XINT_expr_prec_tacit *{##2}(##1\relax !\XINT_tmpa{##2}}%)
}%
\xintApplyUnbraced \XINT_expr_makedummy {abcdefghijklmnopqrstuvwxyz}%
\xintApplyUnbraced \XINT_expr_makedummy {ABCDEFGHIJKLMNOPQRSTUVWXYZ}%
\def\xintnewdummy #1{%
    \XINT_expr_makedummy{#1}%
    \ifxintverbose\xintMessage {xintexpr}{Info}%
       {\XINT_tmpa\space now
        \ifxintglobaldefs globally \fi usable as dummy variable.}%
    \fi
}%
\catcode`* 12
%    \end{macrocode}
% The |nil| variable was need in |xint < 1.4| (with some other meaning)
% in places the syntax could not allow emptiness, such as |,,|, and
% other things, but at |1.4| meaning as changed.
%
% The other variables are new with |1.4|.
% Don't use the |None|, it is tentative, and may be input as |[]|.
%
% Refactored at |1.4i| to define them as really genuine variables,
% i.e. also with associated |var*| macros involved in tacit multiplication
% (even though it will be broken with |nil|, and with |None| in |\xintiiexpr|).
% No real reason, because |\XINT_expr_op__| managed them fine even in absence
% of |var*| macros.
%    \begin{macrocode}
\XINT_expr_defvar_one{nil}{}%
\XINT_expr_defvar_one{None}{{}}% ? tentative
\XINT_expr_defvar_one{false}{{0}}% Maple, TeX
\XINT_expr_defvar_one{true}{{1}}%
\XINT_expr_defvar_one{False}{{0}}% Python
\XINT_expr_defvar_one{True}{{1}}%
\XINT_expr_defvar_one{NaN}{{I?}}%
\XINT_expr_defvar_one{Infinity}{{I+}}%
%    \end{macrocode}
% \subsubsection{\csh{xintensuredummy}, \csh{xintrestorevariable}}
%\begin{lverb}
% 1.3e \xintensuredummy differs from \xintnewdummy only in the informational message...
% Attention that this is not meant to be nested.
%
% 1.4 fixes that the message mentioned non-existent \xintrestoredummy (real
% name was \xintrestorelettervar and renames the latter to
% \xintrestorevariable as it applies also to multi-letter names.
%\end{lverb}
%    \begin{macrocode}
\def\xintensuredummy #1{%
    \XINT_expr_makedummy{#1}%
    \ifxintverbose\xintMessage {xintexpr}{Info}%
       {\XINT_tmpa\space now
        \ifxintglobaldefs globally \fi usable as dummy variable.&&J
        Issue \string\xintrestorevariable{\XINT_tmpa}
        to restore former meaning.}%
    \fi
}%
\def\xintrestorevariablesilently #1{%
   \edef\XINT_tmpa{\xint_zapspaces #1 \xint_gobble_i}%
   \ifcsname XINT_expr_var_\XINT_tmpa/old\endcsname
     \XINT_global
     \expandafter\let\csname XINT_expr_var_\XINT_tmpa\expandafter\endcsname
                     \csname XINT_expr_var_\XINT_tmpa/old\expandafter\endcsname
   \fi
   \ifcsname XINT_expr_var*_\XINT_tmpa/old\endcsname
     \XINT_global
     \expandafter\let\csname XINT_expr_var*_\XINT_tmpa\expandafter\endcsname
                     \csname XINT_expr_var*_\XINT_tmpa/old\expandafter\endcsname
   \fi
}%
\def\xintrestorevariable #1{%
    \xintrestorevariablesilently {#1}%
    \ifxintverbose\xintMessage {xintexpr}{Info}%
       {\XINT_tmpa\space
        \ifxintglobaldefs globally \fi restored to its earlier status, if any.}%
    \fi
}%
%    \end{macrocode}
% \subsubsection{Checking (without expansion) that a symbolic expression
% contains correctly nested parentheses}
%
%\begin{lverb}
% Expands to \xint_c_mone in case a closing ) had no opening ( matching
% it, to \@ne if opening ( had no closing ) matching it, to \z@ if expression
% was balanced. Call it as:
%
% \XINT_isbalanced_a \relax #1(\xint_bye)\xint_bye
%
% This is legacy f-expandable code not using \expanded even at 1.4.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_isbalanced_a #1({\XINT_isbalanced_b #1)\xint_bye }%
\def\XINT_isbalanced_b #1)#2%
   {\xint_bye #2\XINT_isbalanced_c\xint_bye\XINT_isbalanced_error }%
%    \end{macrocode}
%\begin{lverb}
% if #2 is not \xint_bye, a ) was found, but there was no (. Hence error -> -1
%\end{lverb}
%    \begin{macrocode}
\def\XINT_isbalanced_error #1)\xint_bye {\xint_c_mone}%
%    \end{macrocode}
%\begin{lverb}
% #2 was \xint_bye, was there a ) in original #1?
%\end{lverb}
%    \begin{macrocode}
\def\XINT_isbalanced_c\xint_bye\XINT_isbalanced_error #1%
    {\xint_bye #1\XINT_isbalanced_yes\xint_bye\XINT_isbalanced_d #1}%
%    \end{macrocode}
%\begin{lverb}
% #1 is \xint_bye, there was never ( nor ) in original #1, hence OK.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_isbalanced_yes\xint_bye\XINT_isbalanced_d\xint_bye )\xint_bye
    {\xint_c_ }%
%    \end{macrocode}
%\begin{lverb}
% #1 is not \xint_bye, there was indeed a ( in original #1. We check if
% we see a ). If we do, we then loop until no ( nor ) is to be found.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_isbalanced_d #1)#2%
   {\xint_bye #2\XINT_isbalanced_no\xint_bye\XINT_isbalanced_a #1#2}%
%    \end{macrocode}
%\begin{lverb}
% #2 was \xint_bye, we did not find a closing ) in original #1. Error.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_isbalanced_no\xint_bye #1\xint_bye\xint_bye {\xint_c_i }%
%    \end{macrocode}
% \subsubsection{Fetching balanced expressions E1, E2 and a variable name Name from E1, Name=E2)}
%
% Multi-letter dummy variables added at |1.4|.
%    \begin{macrocode}
\def\XINT_expr_fetch_E_comma_V_equal_E_a #1#2,%
{%
    \ifcase\XINT_isbalanced_a \relax #1#2(\xint_bye)\xint_bye
           \expandafter\XINT_expr_fetch_E_comma_V_equal_E_c
        \or\expandafter\XINT_expr_fetch_E_comma_V_equal_E_b
      \else\expandafter\xintError:noopening
    \fi {#1#2},%
}%
\def\XINT_expr_fetch_E_comma_V_equal_E_b #1,%
   {\XINT_expr_fetch_E_comma_V_equal_E_a {#1,}}%
\def\XINT_expr_fetch_E_comma_V_equal_E_c #1,#2#3=%
{%
    \expandafter\XINT_expr_fetch_E_comma_V_equal_E_d\expandafter
    {\expanded{{\xint_zapspaces #2#3 \xint_gobble_i}}{#1}}{}%
}%
\def\XINT_expr_fetch_E_comma_V_equal_E_d #1#2#3)%
{%
    \ifcase\XINT_isbalanced_a \relax #2#3(\xint_bye)\xint_bye
        \or\expandafter\XINT_expr_fetch_E_comma_V_equal_E_e
       \else\expandafter\xintError:noopening
    \fi
    {#1}{#2#3}%
}%
\def\XINT_expr_fetch_E_comma_V_equal_E_e #1#2%
   {\XINT_expr_fetch_E_comma_V_equal_E_d {#1}{#2)}}%
%    \end{macrocode}
% \subsubsection{Fetching a balanced expression delimited by a semi-colon}
%
%\begin{lverb}
% 1.4. For subsn() leaner syntax of nested substitutions.
%
% Will also serve to \xintdeffunc, to not have to hide inner semi-colons in
% for example an iter() from \xintdeffunc.
%
% Adding brace removal protection for no serious reason, anyhow the xintexpr
% parsers always removes braces when moving forward, but well.
%
% Trigger by \romannumeral\XINT_expr_fetch_to_semicolon upfront.
%\end{lverb}
%
%    \begin{macrocode}
\def\XINT_expr_fetch_to_semicolon {\XINT_expr_fetch_to_semicolon_a {}\empty}%
\def\XINT_expr_fetch_to_semicolon_a #1#2;%
{%
    \ifcase\XINT_isbalanced_a \relax #1#2(\xint_bye)\xint_bye
           \xint_dothis{\expandafter\XINT_expr_fetch_to_semicolon_c}%
        \or\xint_dothis{\expandafter\XINT_expr_fetch_to_semicolon_b}%
      \else\expandafter\xintError:noopening
    \fi\xint_orthat{}\expandafter{#2}{#1}%
}%
\def\XINT_expr_fetch_to_semicolon_b #1#2%
   {\XINT_expr_fetch_to_semicolon_a {#2#1;}\empty}%
\def\XINT_expr_fetch_to_semicolon_c #1#2{\xint_c_{#2#1}}%
%    \end{macrocode}
% \subsubsection{Low-level support for omit and abort keywords, the break()
% function, the n++ construct and the semi-colon as used in the syntax of
% seq(), add(), mul(), iter(), rseq(), iterr(), rrseq(), subsm(), subsn(), ndseq(),
% ndmap()}
%\begin{lverb}
% There is some clever play simply based on setting suitable precedence
% levels combined with special meanings given to op macros.
%
%  The special !? internal operator is a helper for omit and abort keywords in
%  list generators.
%
% Prior to 1.4 support for +[, *[, ..., ]+, ]*,  had some elements here.
%\end{lverb}
% \paragraph{The n++ construct}
%\begin{lverb}
% 1.1 2014/10/29 did \expandafter\.=+\xintiCeil which transformed it into
% \romannumeral0\xinticeil, which seems a bit weird. This exploited the fact
% that dummy variables macros could back then pick braced material (which in the
% case at hand here ended being {\romannumeral0\xinticeil...} and were submitted
% to two expansions. The result of this was to provide a not value which got
% expanded only in the first loop of the :_A and following macros of seq,
% iter, rseq, etc...
%
% Anyhow with 1.2c I have changed the implementation of dummy variables which
% now need to fetch a single locked token, which they do not expand.
%
% The \xintiCeil appears a bit dispendious, but I need the starting value in a
% \numexpr compatible form in the iteration loops.
%\end{lverb}
%    \begin{macrocode}
\expandafter\def\csname XINT_expr_itself_++\endcsname {++}%
\expandafter\def\csname XINT_expr_itself_++)\endcsname {++)}%
\expandafter\let\csname XINT_expr_precedence_++)\endcsname \xint_c_i
\xintFor #1 in {expr,flexpr,iiexpr} \do {%
    \expandafter\def\csname XINT_#1_op_++)\endcsname ##1##2\relax
     {\expandafter\XINT_expr_foundend
                  \expanded{{+{\XINT:NEhook:f:one:from:one:direct%
                             \calxCeilToNum##1}}}%
     }%
}%
%    \end{macrocode}
% \paragraph{The \cshn{break()} function}
%\begin{lverb}
% break is a true function, the parsing via expansion of the enclosed
% material proceeds via _oparen macros as with any other function.
%\end{lverb}
%    \begin{macrocode}
\catcode`? 3
\def\XINT_expr_func_break #1#2#3{#1#2{?#3}}%
\catcode`? 11
\let\XINT_flexpr_func_break \XINT_expr_func_break
\let\XINT_iiexpr_func_break \XINT_expr_func_break
%    \end{macrocode}
% \paragraph{The \cshn{omit} and \cshn{abort} keywords}
%\begin{lverb}
% Comments are currently undergoing reconstruction.
%
% The mechanism is somewhat complex.  The operator !? will fetch a dummy value
% ! or ^ which is then recognized int the loops implementing the various seq
% etc... construct using dummy variables and implement omit and abort.
%
% In May 2021 I realized that the January 2020 1.4 had broken omit and abort
% if used inside a subs().  The definition
%(\edef\XINT_expr_var_omit  #1\relax !{1\string !?!\relax !}%
%)
% conflicted with the 1.4 refactoring of «subs» and similar things
% which had replaced formerly clean-up macros (of ! and what's next, as in
% now defunct
% \def\XINT_expr_subx:_end #1!#2#3{#1} which was involved in subs mechanism,
% and by the way would be incompatible with multi-letter dummy variables) by usage
% of an \iffalse as in "\relax\iffalse\relax !" to delimite a sub-expression, which was
% supposed to be clever (the "\relax !" being delimiter for dummy variables).
%
% This \iffalse from subs mechanism ended up being gobbled by omit/abort thus
% inducing breakage.
%
% Grabbing \relax #2! would be a fix but looks a bit dangerous, as there can
% be a subexpression after the omit or abort bringing its own \relax, although
% this is very very unlikely.
%
% I considered to modify the dummy variables delimiter from \relax !  to
% \xint_Bye ! for example but got afraid from the ramifications, as all
% structures handling dummy variables would have needed refactoring.
%
% So finally things here remain unchanged and the refactoring to fix this
% breakage was done in \XINT_allexpr_subsx (and also subsm).
% Done at 1.4h. See \XINT_allexpr_subsx for comments.
%\end{lverb}
%
%    \begin{macrocode}
\edef\XINT_expr_var_omit  #1\relax !{1\string !?!\relax !}%
\edef\XINT_expr_var_abort #1\relax !{1\string !?^\relax !}%
\def\XINT_expr_itself_!? {!?}%
\def\XINT_expr_op_!? #1#2\relax{\XINT_expr_foundend{#2}}%
\let\XINT_iiexpr_op_!? \XINT_expr_op_!?
\let\XINT_flexpr_op_!? \XINT_expr_op_!?
\let\XINT_expr_precedence_!? \xint_c_iv
%    \end{macrocode}
% \paragraph{The semi-colon}
%
%\begin{lverb}
% Obsolete comments undergoing re-construction
%\end{lverb}
%
%    \begin{macrocode}
\xintFor #1 in {expr,flexpr,iiexpr} \do {%
     \expandafter\def\csname XINT_#1_op_;\endcsname {\xint_c_i ;}%
}%
\expandafter\let\csname XINT_expr_precedence_;\endcsname\xint_c_i
\expandafter\def\csname XINT_expr_itself_;)\endcsname {)}%
\expandafter\let\csname XINT_expr_precedence_;)\endcsname\xint_c_i
%    \end{macrocode}
% \subsubsection{Reserved dummy variables @, @1, @2, @3, @4, @@, @@(1), \dots, @@@,
% @@@(1), \dots{} for recursions}
%\begin{lverb}
% Comments currently under reconstruction.
%
% 1.4 breaking change: @ and @1 behave differently and one can not use @ in
% place of @1 in iterr() and rrseq(). Formerly @ and @1 had the same
% definition.
%
% Brace stripping in \XINT_expr_func_@@
% is prevented by some ending 0 or other token see iterr() and rrseq() code.
%
% For the record, the ~ and ? have catcode 3 in this code.
%
%\end{lverb}
%
% \odef\MakePrivateLetters{\MakePrivateLetters\catcode`* 11 }^^A
%    \begin{macrocode}
\catcode`* 11
\def\XINT_expr_var_@ #1~#2{{#2}#1~{#2}}%
\def\XINT_expr_var*_@ #1~#2{\XINT_expr_prec_tacit *{#2}(#1~{#2}}%
\expandafter
\def\csname XINT_expr_var_@1\endcsname #1~#2{{{#2}}#1~{#2}}%
\expandafter
\def\csname XINT_expr_var_@2\endcsname #1~#2#3{{{#3}}#1~{#2}{#3}}%
\expandafter
\def\csname XINT_expr_var_@3\endcsname #1~#2#3#4{{{#4}}#1~{#2}{#3}{#4}}%
\expandafter
\def\csname XINT_expr_var_@4\endcsname #1~#2#3#4#5{{{#5}}#1~{#2}{#3}{#4}{#5}}%
\expandafter\def\csname XINT_expr_var*_@1\endcsname #1~#2%
               {\XINT_expr_prec_tacit *{{#2}}(#1~{#2}}%
\expandafter\def\csname XINT_expr_var*_@2\endcsname #1~#2#3%
               {\XINT_expr_prec_tacit *{{#3}}(#1~{#2}{#3}}%
\expandafter\def\csname XINT_expr_var*_@3\endcsname #1~#2#3#4%
               {\XINT_expr_prec_tacit *{{#4}}(#1~{#2}{#3}{#4}}%
\expandafter\def\csname XINT_expr_var*_@4\endcsname #1~#2#3#4#5%
               {\XINT_expr_prec_tacit *{{#5}}(#1~{#2}{#3}{#4}{#5}}%
\catcode`* 12
%    \end{macrocode}
% \let\MakePrivateLetters\xintexprMakePrivateLetters\FixInterMacrocodeVspace
%    \begin{macrocode}
\catcode`? 3
\def\XINT_expr_func_@@ #1#2#3#4~#5?%
{%
   \expandafter#1\expandafter#2\expandafter{\expandafter{%
         \romannumeral0\xintntheltnoexpand{\calxListItemToNum#3}{#5}}}#4~#5?%
}%
\def\XINT_expr_func_@@@ #1#2#3#4~#5~#6?%
{%
   \expandafter#1\expandafter#2\expandafter{\expandafter{%
         \romannumeral0\xintntheltnoexpand{\calxListItemToNum#3}{#6}}}%
         #4~#5~#6?%
}%
\def\XINT_expr_func_@@@@ #1#2#3#4~#5~#6~#7?%
{%
   \expandafter#1\expandafter#2\expandafter{\expandafter{%
         \romannumeral0\xintntheltnoexpand{\calxListItemToNum#3}{#7}}}%
         #4~#5~#6~#7?%
}%
\let\XINT_flexpr_func_@@\XINT_expr_func_@@
\let\XINT_flexpr_func_@@@\XINT_expr_func_@@@
\let\XINT_flexpr_func_@@@@\XINT_expr_func_@@@@
\def\XINT_iiexpr_func_@@ #1#2#3#4~#5?%
{%
   \expandafter#1\expandafter#2\expandafter{\expandafter{%
         \romannumeral0\xintntheltnoexpand{\CALX_mr#3}{#5}}}#4~#5?%
}%
\def\XINT_iiexpr_func_@@@ #1#2#3#4~#5~#6?%
{%
   \expandafter#1\expandafter#2\expandafter{\expandafter{%
         \romannumeral0\xintntheltnoexpand{\CALX_mr#3}{#6}}}#4~#5~#6?%
}%
\def\XINT_iiexpr_func_@@@@ #1#2#3#4~#5~#6~#7?%
{%
   \expandafter#1\expandafter#2\expandafter{\expandafter{%
         \romannumeral0\xintntheltnoexpand{\CALX_mr#3}{#7}}}#4~#5~#6~#7?%
}%
\catcode`? 11
%    \end{macrocode}
% \subsection{Pseudo-functions involving dummy variables and generating scalars or sequences}
% \localtableofcontents
%
% \subsubsection{Comments}
%\begin{lverb}
% Comments added 2020/01/16.
%
% The mechanism for «seq» is the following. When the parser encounters «seq»,
% which means it parsed these letters and encountered (from expansion) an
% opening parenthesis, the \XINT_expr_func mechanism triggers the «`» operator
% which realizes that «seq» is a pseudo-function (there is no _func_seq) and
% thus spans the \XINT_expr_onliteral_seq macro (currently this means however
% that the knowledge of which parser we are in is lost, see comments of
% \XINT_expr_op_` code). The latter will use delimited macros and parenthesis
% check to fetch (without any expansion), the symbolic expression ExprSeq to
% evaluate, the Name (now possibly multi-letter) of the variable and the
% expression ExprValues to evaluate which will give the values to assign to
% the dummy variable Name. It then positions upstream ExprValues suitably
% terminated (see next) and after it {{Name}{ExprSeq}}. Then it inserts a
% second call to the «`» operator with now «seqx» as argument hence
% the appropriate «{,fl,ii}expr_func_seqx» macros gets executed. The general
% way function macros work is that first all their arguments are evaluated via
% a call not to \xintbare{,float,ii}eval but to the suitable
% \XINT_{expr,flexpr,iiexpr}_oparen core macro which does almost same excepts
% it expects a final closing parenthesis (of course allowing nested
% parenthesis in-between) and stops there. Here, this closing parenthesis got positioned
% deliberately with a \relax after it, so the parser, which always after
% having gathered a value looks ahead to find the next operator, thinks it has
% hit the end of the expression and as result inserts a \xint_c_ (i.e. \z@)
% token for precedence level and a dummy \relax token (place-holder for a
% non-existing operator). Generally speaking «func_foo» macros expect to
% be executed with three parameters #1#2#3, #1 = precedence, #2 = operator, #3
% = values (call it «args») i.e. the fully evaluated list of all its
% arguments. The special «func_seqx» and cousins know that the first two
% tokens are trash and they now proceed forward, having thus lying before them
% upstream the values to loop over, now fully evaluated, and
% {{Name}{ExprSeq}}. It then positions appropriately ExprSeq inside a
% sub-expression and after it, following suitable delimiter, Name and the
% evaluated values to assign to Name.
%
% Dummy variables are essentially simply delimited macros where the delimiter
% is the variable name preceded by a \relax token and a catcode 11 exclamation
% point. Thus the various «subsx», «seqx», «iterx» position the tokens
% appropriately and launch suitable loops.
%
% All of this nests well, inner «seq»'s (or more often in practice «subs»'s)
% being allowed to refer to the dummy variables used by outer «seq»'s because
% the outer «seq»'s have the values to assign to their variables evaluated
% first and their ExprSeq evaluated last. For inner dummy variables to be able
% to refer to outer dummy variables the author must be careful of course to
% not use in the implementation braces { and } which would break dummy
% variables to fetch values beyond the closing brace.
%
% The above «seq» mechanism was done around June 15-25th 2014 at the time of
% the transition from 1.09n to 1.1 but already in October 2014 I made a note
% that I had a hard time to understand it again:
%
% « [START OF YEAR 2014 COMMENTS]
%
% All of seq, add, mul, rseq, etc... (actually all of the extensive
% changes from xintexpr 1.09n to 1.1) was done around June 15-25th 2014, but the
% problem is that I did not document the code enough, and I had a hard time
% understanding in October what I had done in June. Despite the lesson, again
% being short on time, I do not document enough my current understanding of the
% innards of the beast...
%
% I added subs, and iter in October (also the [:n], [n:] list extractors),
% proving I did at least understand a bit (or rather could imitate) my earlier
% code (but don't ask me to explain \xintNewExpr !)
%
% The \XINT_expr_fetch_E_comma_V_equal_E_a parses: "expression, variable=list)"
% (when it is called the opening ( has been swallowed, and it looks for
% the ending one.) Both expression and list may themselves contain
% parentheses and commas, we allow nesting. For example "x^2,x=1..10)",
% at the end of seq_a we have {variable{expression}}{list}, in this
% example {x{x^2}}{1..10}, or more complicated
% "seq(add(y,y=1..x),x=1..10)" will work too. The variable is a single
% lowercase Latin letter.
%
% The complications with \xint_c_ii^v in seq_f is for the recurrent
% thing that we don't know in what type of expressions we are, hence we
% must move back up, with some loss of efficiency (superfluous check for
% minus sign, etc...). But the code manages simultaneously expr, flexpr
% and iiexpr.
%
% [END OF YEAR 2014 OLD COMMENTS]»
%
% On Jeudi 16 janvier 2020 à 15:13:32 I finally did the documentation as
% above.
%
% The case of «iter», «rseq», «iterr», «rrseq» differs slightly because the
% initial values need evaluation. This is done by genuine functions
% \XINT_<parser>_func_iter etc... (there was no \XINT_<parser>_func_seq). The
% trick is via the semi-colon ; which is a genuine operator having the
% precedence of a closing parenthesis and whose action is only to stop
% expansion. Thus this first step of gathering the initial values is done as
% part of the reguler expansion job of the parser not using delimited macros
% and the ; can be hidden in braces {;} because the three parsers when moving
% forward remove one level of braces always. Thus
% \XINT_<parser>_func_seq simply hand over to \XINT_allexpr_iter which will
% then trigger the fetching without expansion of ExprIter, Name=ExprValues as
% described previously for «seq».
%
% With 1.4, multi-letter names for dummy variables are allowed.
%
% Also there is the additional 1.4 ambition to make the whole thing parsable
% by \xintNewExpr/\xintdeffunc. This is done by checking if all is numerical,
% because the omit, abort and break() mechanisms have no translation into
% macros, and the only solution for symbolic material is to simply keep it as
% is, so that expansion will again activate the xintexpr parsers. At 1.4 this
% approach is fine although the initial goals of \xintNewExpr/\xintdeffunc was
% to completely replace the parsers (whose storage method hit the string pool
% formerly) by macros. Now that 1.4 does not impact the string pool we can
% make \xintdeffunc much more powerful but it will not be a construct using
% only xintfrac macros, it will still be partially the \xintexpr etc...
% parsers in such cases.
%\end{lverb}
%
%\begin{lverb}
% Got simpler with 1.2c as now the dummy variable fetches an
% already encapsulated value, which is anyhow the form in which we get
% it.
%
% Refactored at 1.4 using \expanded rather than \csname.
%
% And support for multi-letter variables, which means function declarations
% can now use multi-letter variables !
%\end{lverb}
%
% \changed{2.0a1}
% Per parser "onliteral" macros for matters UNRELATED with subs() et al.
% Here defining the \csbxint{eval} interface. The needed |\let| done below.
%
%
% \subsubsection{\cshn{subs()}: substitution of one variable}
%    \begin{macrocode}
\def\XINT_expr_onliteral_subs
{%
    \expandafter\XINT_allexpr_subs_f
    \romannumeral`&&@\XINT_expr_fetch_E_comma_V_equal_E_a {}%
}%
\def\XINT_allexpr_subs_f #1#2{\xint_c_ii^v `{subsx}#2)\relax #1}%
\def\XINT_expr_func_subsx   #1#2{\XINT_allexpr_subsx \xintbareeval }%
\def\XINT_flexpr_func_subsx #1#2{\XINT_allexpr_subsx \xintbarefloateval}%
\def\XINT_iiexpr_func_subsx #1#2{\XINT_allexpr_subsx \xintbareiieval }%
%    \end{macrocode}
%\begin{lverb}
% #2 is the value to assign to the dummy variable
% #3 is the dummy variable name (possibly multi-letter), #4 is the expression
% to evaluate
%
% 1.4 was doing something clever to get rid of the ! and tokens following it,
% via an \iffalse...\fi which erased them and propagated the expansion to
% trigger the getopt:
%
%(\expanded\bgroup\romannumeral0#1#4\relax \iffalse\relax !#3{#2}{\fi\expandafter}
%)
%
% But sadly, with a delay of more than one year later (right after having
% released 1.4g) I realized that this had broken omit and abort if inside a
% subs.  As omit and abort would clean all up to \relax !, this meant here
% swallowing in particular the above \iffalse, leaving a dangling \fi.  I had
% the files which show this bug already at time of 1.4 release but did not
% compile them, and they were not included in my test suite.
%
% I hesitated with modifying the delimiter from "\relax !<varname>" (catcode
% 11 !) to "\relax \xint_Bye<varname>" for the dummy variables which would
% have allowed some trickery using \xint_Bye...\xint_bye clean-up but got
% afraid from the breakage potential of such refactoring with many induced
% changes.
%
% A variant like this:
%( \def\XINT_allexpr_subsx #1#2#3#4%
%: {%
%:     \expandafter\XINT_expr_clean_and_put_op_first
%:     \expanded
%:     {\romannumeral0#1#4\relax !#3{#2}\xint:\expandafter}\romannumeral`$&$&\XINT_expr_getop
%: }%
%: \def\XINT_expr_clean_and_put_op_first #1#2\xint:#3#4{#3#4{#1}}%
%)
% breaks nesting: the braces make variables encountered in #4 unable to
% match their definition.  This would work:
%
%( \def\XINT_allexpr_subsx #1#2#3#4%
%: {%
%:     \expandafter\XINT_allexpr_subsx_clean\romannumeral0#1#4\relax !#3{#2}\xint:
%: }%
%: \def\XINT_allexpr_subsx_clean #1#2\xint:
%: {%
%:     \expandafter\XINT_expr_put_op_first
%:     \expanded{\xint_noxpd{{#1}}\expandafter}\romannumeral`$&$&@\XINT_expr_getop
%: }%
%)
% (not tested).
%
% But in the end I decided to simply fix the first envisioned code above.
% This accepts expansion of supposedly inert #3{#2}.  There is again the
% \iffalse but it is moved to the right.  This change limits possibly hacky
% future developments.  Done at 1.4h (2021/01/27).
%
% No need for the \expandafter's from \XINT_expr_put_op_first in
% \XINT_expr_clean_and_put_op_first.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_allexpr_subsx #1#2#3#4%
{%
    \expandafter\XINT_expr_clean_and_put_op_first
    \expanded
    \bgroup\romannumeral0#1#4\relax !#3{#2}\xint:\iffalse{\fi\expandafter}%
    \romannumeral`&&@\XINT_expr_getop
}%
\def\XINT_expr_clean_and_put_op_first #1#2\xint:#3#4{#3#4{#1}}%
%    \end{macrocode}
% \subsubsection{\cshn{subsm()}: simultaneous independent substitutions}
%\begin{lverb}
% New with 1.4. Globally the var1=expr1; var2=expr2; var2=expr3;...
% part can arise from expansion, except that once a semi-colon has been found
% (from expansion) the varK= thing following it must be there. And as for
% subs() the final parenthesis must be there from the start.
%
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_onliteral_subsm
{%
    \expandafter\XINT_allexpr_subsm_f
    \romannumeral`&&@\XINT_expr_fetch_E_comma_V_equal_E_a {}%
}%
\def\XINT_allexpr_subsm_f #1#2{\xint_c_ii^v `{subsmx}#2)\relax #1}%
\def\XINT_expr_func_subsmx
{%
    \expandafter\XINT_allexpr_subsmx\expandafter\xintbareeval
    \expanded\bgroup{\iffalse}\fi\XINT_allexpr_subsm_A\XINT_expr_oparen
}%
\def\XINT_flexpr_func_subsmx
{%
    \expandafter\XINT_allexpr_subsmx\expandafter\xintbarefloateval
    \expanded\bgroup{\iffalse}\fi\XINT_allexpr_subsm_A\XINT_flexpr_oparen
}%
\def\XINT_iiexpr_func_subsmx
{%
    \expandafter\XINT_allexpr_subsmx\expandafter\xintbareiieval
    \expanded\bgroup{\iffalse}\fi\XINT_allexpr_subsm_A\XINT_iiexpr_oparen
}%
\def\XINT_allexpr_subsm_A #1#2#3%
{%
    \ifx#2\xint_c_
       \expandafter\XINT_allexpr_subsm_done
    \else
       \expandafter\XINT_allexpr_subsm_B
    \fi #1%
}%
\def\XINT_allexpr_subsm_B #1#2#3#4=%
{%
    {#2}\relax !\xint_zapspaces#3#4 \xint_gobble_i
    \expandafter\XINT_allexpr_subsm_A\expandafter#1\romannumeral`&&@#1%
}%
%    \end{macrocode}
%\begin{lverb}
%( #1 = \xintbareeval,  or \xintbarefloateval or \xintbareiieval
%: #2 = evaluation of last variable assignment
%)
%\end{lverb}
%    \begin{macrocode}
\def\XINT_allexpr_subsm_done #1#2{{#2}\iffalse{{\fi}}}%
%    \end{macrocode}
%\begin{lverb}
%( #1 = \xintbareeval or \xintbarefloateval or \xintbareiieval
%: #2 = {value1}\relax !var2{value2}....\relax !varN{valueN} (value's may be oples)
%: #3 = {var1}
%: #4 = the expression to evaluate
%)
% Refactored at 1.4h as for \XINT_allexpr_subsx, see comments there related
% to the omit/abort conundrum.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_allexpr_subsmx #1#2#3#4%
{%
    \expandafter\XINT_expr_clean_and_put_op_first
    \expanded
    \bgroup\romannumeral0#1#4\relax !#3#2\xint:\iffalse{\fi\expandafter}%
    \romannumeral`&&@\XINT_expr_getop
}%
%    \end{macrocode}
% \subsubsection{\cshn{subsn()}: leaner syntax for nesting (possibly dependent) substitutions}
%\begin{lverb}
% New with 1.4. 2020/01/24
%
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_onliteral_subsn
{%
    \expandafter\XINT_allexpr_subsn_f
    \romannumeral`&&@\XINT_expr_fetch_E_comma_V_equal_E_a {}%
}%
\def\XINT_allexpr_subsn_f #1{\XINT_allexpr_subsn_g #1}%
%    \end{macrocode}
%\begin{lverb}
%( #1 = Name1
%: #2 = Expression in all variables which is to evaluate
%: #3 = all the stuff after Name1 =  and up to final parenthesis
%)
%
% This one needed no reactoring at 1.4h to fix the omit/abort problem, as
% there was no \iffalse..\fi clean-up: the clean-up is done directly via
% \XINT_allexpr_subsnx_J.
%
% I only added usage of \XINT_expr_put_op_first_noexpand.  There may be other
% locations where it could be used, but I can't afford now reviewing
% usage. For next release after 1.4h bugfix.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_allexpr_subsn_g #1#2#3%
{%
    \expandafter\XINT_allexpr_subsn_h
    \expanded\bgroup{\iffalse}\fi\expandafter\XINT_allexpr_subsn_B
    \romannumeral\XINT_expr_fetch_to_semicolon #1=#3;\hbox=;;^{#2}%
}%
\def\XINT_allexpr_subsn_B #1{\XINT_allexpr_subsn_C #1\vbox}%
\def\XINT_allexpr_subsn_C #1#2=#3\vbox
{%
    \ifx\hbox#1\iffalse{{\fi}\expandafter}\else
    {{\xint_zapspaces #1#2 \xint_gobble_i}};\xint_noxpd{{{#3}}}%
    \expandafter\XINT_allexpr_subsn_B
    \romannumeral\expandafter\XINT_expr_fetch_to_semicolon\fi
}%
%    \end{macrocode}
% \changed{1.4p}
%
% I used here formerly |\xintundefined| as a delimiter token, perhaps also
% initially as debugging helper in case expansion went beyond the expected,
% but elsewhere in the code base there is |\XINT_undefined|, but both feel
% inappopriate.  The problem attow is that I wrote the code many years ago and
% I can not be fully certain using |\xint:| may not cause a problem in case
% this delimiter could appear earlier, but I think not, so let's go for
% |\xint:|.
%
%    \begin{macrocode}
\def\XINT_allexpr_subsn_h
{%
    \xint_c_ii^v `{subsnx}\romannumeral0\xintreverseorder
}%
\def\XINT_expr_func_subsnx #1#2#3#4#5;#6%
{%
    \xint_gob_til_^ #6\XINT_allexpr_subsnx_H ^%
    \expandafter\XINT_allexpr_subsnx\expandafter
    \xintbareeval\romannumeral0\xintbareeval #5\relax !#4{#3}\xint:
    {\relax !#4{#3}\relax !#6}%
}%
\def\XINT_iiexpr_func_subsnx #1#2#3#4#5;#6%
{%
    \xint_gob_til_^ #6\XINT_allexpr_subsnx_H ^%
    \expandafter\XINT_allexpr_subsnx\expandafter
    \xintbareiieval\romannumeral0\xintbareiieval #5\relax !#4{#3}\xint:
    {\relax !#4{#3}\relax !#6}%
}%
\def\XINT_flexpr_func_subsnx #1#2#3#4#5;#6%
{%
    \xint_gob_til_^ #6\XINT_allexpr_subsnx_H ^%
    \expandafter\XINT_allexpr_subsnx\expandafter
    \xintbarefloateval\romannumeral0\xintbarefloateval #5\relax !#4{#3}\xint:
    {\relax !#4{#3}\relax !#6}%
}%
\def\XINT_allexpr_subsnx #1#2!#3\xint:#4#5;#6%
{%
    \xint_gob_til_^ #6\XINT_allexpr_subsnx_I ^%
    \expandafter\XINT_allexpr_subsnx\expandafter
    #1\romannumeral0#1#5\relax !#4{#2}\xint:
    {\relax !#4{#2}\relax !#6}%
}%
\def\XINT_allexpr_subsnx_H ^#1\romannumeral0#2#3!#4\xint:#5#6%
{%
    \expandafter\XINT_allexpr_subsnx_J\romannumeral0#2#6#5%
}%
\def\XINT_allexpr_subsnx_I ^#1\romannumeral0#2#3\xint:#4#5%
{%
    \expandafter\XINT_allexpr_subsnx_J\romannumeral0#2#5#4%
}%
\def\XINT_allexpr_subsnx_J #1#2^%
{%
    \expandafter\XINT_expr_put_op_first_noexpand
    \expanded{\xint_noxpd{{#1}}\expandafter}\romannumeral`&&@\XINT_expr_getop
}%
\def\XINT_expr_put_op_first_noexpand#1#2#3{#2#3{#1}}%
%    \end{macrocode}
% \subsubsection{\cshn{seq()}: sequences from assigning values to a
% dummy variable}
%\begin{lverb}
% In seq_f, the #2 is the ExprValues expression which needs evaluation to
% provide the values to the dummy variable and #1 is {Name}{ExprSeq}
% where Name is the name of dummy variable and {ExprSeq} the expression
% which will have to be evaluated.
%\end{lverb}
%
%
%    \begin{macrocode}
\def\XINT_allexpr_seq_f #1#2{\xint_c_ii^v `{seqx}#2)\relax #1}%
\def\XINT_expr_onliteral_seq
 {\expandafter\XINT_allexpr_seq_f
  \romannumeral`&&@\XINT_expr_fetch_E_comma_V_equal_E_a {}}%
\def\XINT_expr_func_seqx   #1#2%
 {\XINT:NEhook:seqx\XINT_allexpr_seqx\xintbareeval }%
\def\XINT_flexpr_func_seqx #1#2%
 {\XINT:NEhook:seqx\XINT_allexpr_seqx\xintbarefloateval}%
\def\XINT_iiexpr_func_seqx #1#2%
 {\XINT:NEhook:seqx\XINT_allexpr_seqx\xintbareiieval }%
\def\XINT_allexpr_seqx #1#2#3#4%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded \bgroup {\iffalse}\fi\XINT_expr_seq:_b {#1#4\relax !#3}#2^%
    \XINT_expr_cb_and_getop
}%
\def\XINT_expr_cb_and_getop{\iffalse{\fi\expandafter}%
    \romannumeral`&&@\XINT_expr_getop}%
%    \end{macrocode}
%
%\begin{lverb}
% Comments undergoing reconstruction.
%\end{lverb}
%    \begin{macrocode}
\catcode`? 3
\def\XINT_expr_seq:_b #1#2%
{%
    \ifx +#2\xint_dothis\XINT_expr_seq:_Ca\fi
    \ifx !#2!\xint_dothis\XINT_expr_seq:_noop\fi
    \ifx ^#2\xint_dothis\XINT_expr_seq:_end\fi
    \xint_orthat{\XINT_expr_seq:_c}{#2}{#1}%
}%
\def\XINT_expr_seq:_noop #1{\XINT_expr_seq:_b }%
\def\XINT_expr_seq:_end  #1#2{\iffalse{\fi}}%
\def\XINT_expr_seq:_c #1#2%
   {\expandafter\XINT_expr_seq:_d\romannumeral0#2{{#1}}{#2}}%
\def\XINT_expr_seq:_d #1{\ifx ^#1\xint_dothis\XINT_expr_seq:_abort\fi
                         \ifx ?#1\xint_dothis\XINT_expr_seq:_break\fi
                         \ifx !#1\xint_dothis\XINT_expr_seq:_omit\fi
                         \xint_orthat{\XINT_expr_seq:_goon {#1}}}%
\def\XINT_expr_seq:_abort #1!#2^{\iffalse{\fi}}%
\def\XINT_expr_seq:_break #1!#2^{#1\iffalse{\fi}}%
\def\XINT_expr_seq:_omit  #1!#2#{\expandafter\XINT_expr_seq:_b\xint_gobble_i}%
\def\XINT_expr_seq:_goon  #1!#2#%
   {#1\expandafter\XINT_expr_seq:_b\xint_gobble_i}%
\def\XINT_expr_seq:_Ca #1#2#3{\XINT_expr_seq:_Cc#3.{#2}}%
\def\XINT_expr_seq:_Cb #1%
  {\expandafter\XINT_expr_seq:_Cc\the\numexpr#1+\xint_c_i.}%
\def\XINT_expr_seq:_Cc #1.#2%
  {\expandafter\XINT_expr_seq:_D\romannumeral0#2{{#1[0]}}{#1}{#2}}%
\def\XINT_expr_seq:_D #1{\ifx ^#1\xint_dothis\XINT_expr_seq:_abort\fi
                         \ifx ?#1\xint_dothis\XINT_expr_seq:_break\fi
                         \ifx !#1\xint_dothis\XINT_expr_seq:_Omit\fi
                         \xint_orthat{\XINT_expr_seq:_Goon {#1}}}%
\def\XINT_expr_seq:_Omit #1!#2#{\expandafter\XINT_expr_seq:_Cb\xint_gobble_i}%
\def\XINT_expr_seq:_Goon #1!#2#{#1\expandafter\XINT_expr_seq:_Cb\xint_gobble_i}%
%    \end{macrocode}
% \subsubsection{\cshn{iter()}}
%
%\begin{lverb}
% Prior to 1.2g, the iter keyword was what is now called iterr,
% analogous with rrseq. Somehow I forgot an iter functioning like rseq
% with the sole difference of printing only the last iteration. Both rseq and
% iter work well with list selectors, as @ refers to the whole comma separated
% sequence of the initial values. I have thus deliberately done the backwards
% incompatible renaming of iter to iterr, and the new iter.
%
% To understand the tokens which are presented to \XINT_allexpr_iter it is
% needed to check elsewhere in the source code how the ; hack is done.
%
% The #2 in \XINT_allexpr_iter is \xint_c_i from the ; hack. Formerly (xint <
% 1.4) there was no such token. The change is motivated to using ; also in
% subsm() syntax.
%
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_func_iter   {\XINT_allexpr_iter \xintbareeval      }%
\def\XINT_flexpr_func_iter {\XINT_allexpr_iter \xintbarefloateval }%
\def\XINT_iiexpr_func_iter {\XINT_allexpr_iter \xintbareiieval    }%
\def\XINT_allexpr_iter #1#2#3#4%
{%
    \expandafter\XINT_expr_iterx
    \expandafter#1\expanded{\xint_noxpd{{#4}}\expandafter}%
    \romannumeral`&&@\XINT_expr_fetch_E_comma_V_equal_E_a {}%
}%
\def\XINT_expr_iterx #1#2#3#4%
{%
    \XINT:NEhook:iter\XINT_expr_itery\romannumeral0#1(#4)\relax {#2}#3#1%
}%
\def\XINT_expr_itery #1#2#3#4#5%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded \bgroup {\iffalse}\fi
    \XINT_expr_iter:_b {#5#4\relax !#3}#1^~{#2}\XINT_expr_cb_and_getop
}%
\def\XINT_expr_iter:_b #1#2%
{%
    \ifx +#2\xint_dothis\XINT_expr_iter:_Ca\fi
    \ifx !#2!\xint_dothis\XINT_expr_iter:_noop\fi
    \ifx ^#2\xint_dothis\XINT_expr_iter:_end\fi
    \xint_orthat{\XINT_expr_iter:_c}{#2}{#1}%
}%
\def\XINT_expr_iter:_noop #1{\XINT_expr_iter:_b }%
\def\XINT_expr_iter:_end  #1#2~#3{#3\iffalse{\fi}}%
\def\XINT_expr_iter:_c #1#2%
   {\expandafter\XINT_expr_iter:_d\romannumeral0#2{{#1}}{#2}}%
\def\XINT_expr_iter:_d #1{\ifx ^#1\xint_dothis\XINT_expr_iter:_abort\fi
                          \ifx ?#1\xint_dothis\XINT_expr_iter:_break\fi
                          \ifx !#1\xint_dothis\XINT_expr_iter:_omit\fi
                          \xint_orthat{\XINT_expr_iter:_goon {#1}}}%
\def\XINT_expr_iter:_abort #1!#2^~#3{#3\iffalse{\fi}}%
\def\XINT_expr_iter:_break #1!#2^~#3{#1\iffalse{\fi}}%
\def\XINT_expr_iter:_omit  #1!#2#{%
   \expandafter\XINT_expr_iter:_b\xint_gobble_i
}%
\def\XINT_expr_iter:_goon  #1!#2#{\XINT_expr_iter:_goon_a {#1}}%
\def\XINT_expr_iter:_goon_a #1#2#3~#4{\XINT_expr_iter:_b #3~{#1}}%
\def\XINT_expr_iter:_Ca #1#2#3{\XINT_expr_iter:_Cc#3.{#2}}%
\def\XINT_expr_iter:_Cb #1%
  {\expandafter\XINT_expr_iter:_Cc\the\numexpr#1+\xint_c_i.}%
\def\XINT_expr_iter:_Cc #1.#2%
  {\expandafter\XINT_expr_iter:_D\romannumeral0#2{{#1[0]}}{#1}{#2}}%
\def\XINT_expr_iter:_D #1{\ifx ^#1\xint_dothis\XINT_expr_iter:_abort\fi
                          \ifx ?#1\xint_dothis\XINT_expr_iter:_break\fi
                          \ifx !#1\xint_dothis\XINT_expr_iter:_Omit\fi
                          \xint_orthat{\XINT_expr_iter:_Goon {#1}}}%
\def\XINT_expr_iter:_Omit  #1!#2#{%
  \expandafter\XINT_expr_iter:_Cb\xint_gobble_i
}%
\def\XINT_expr_iter:_Goon  #1!#2#{\XINT_expr_iter:_Goon_a {#1}}%
\def\XINT_expr_iter:_Goon_a #1#2#3~#4{\XINT_expr_iter:_Cb #3~{#1}}%
%    \end{macrocode}
% \subsubsection{\cshn{add()}, \cshn{mul()}}
%\begin{lverb}
% Comments under reconstruction.
%
% These were a bit anomalous as they did not implement omit and abort keyword
% and the break() function (and per force then neither the n++ syntax).
%
% At 1.4 they are simply mapped to using adequately
% iter(). Thus, there is small loss in efficiency, but supporting omit, abort
% and break is important. Using dedicated macros here would have caused also
% slight efficiency drop. Simpler to remove the old approach.
%\end{lverb}
%
%    \begin{macrocode}
\def\XINT_expr_onliteral_add
 {\expandafter\XINT_allexpr_add_f
  \romannumeral`&&@\XINT_expr_fetch_E_comma_V_equal_E_a {}}%
\def\XINT_allexpr_add_f #1#2{\xint_c_ii^v `{opx}#2)\relax #1{+}{0[0]}}%
\def\XINT_expr_onliteral_mul
 {\expandafter\XINT_allexpr_mul_f
  \romannumeral`&&@\XINT_expr_fetch_E_comma_V_equal_E_a {}}%
\def\XINT_allexpr_mul_f #1#2{\xint_c_ii^v `{opx}#2)\relax #1{*}{1[0]}}%
\def\XINT_expr_func_opx
  {\XINT:NEhook:opx \XINT_allexpr_opx \xintbareeval     }%
\def\XINT_flexpr_func_opx
  {\XINT:NEhook:opx \XINT_allexpr_opx \xintbarefloateval}%
\def\XINT_iiexpr_func_opx
  {\XINT:NEhook:opx \XINT_allexpr_opx \xintbareiieval   }%
%    \end{macrocode}
%\begin{lverb}
% 1.4a In case of usage of omit (did I not test it? obviously
% I didn't as neither omit nor abort could work; and break neither),
% 1.4 code using (#6) syntax caused a
% (somewhat misleading) «missing )» error message which originated in the
% #6. This is non-obvious problem (perhaps explained why prior to 1.4 I had
% not added support for omit and break() to add() and mul()...
%
% Allowing () is not enough as it would have to be 0 or 1 depending on
% whether we are using add() or mul(). Hence the somewhat complicated
% detour (relying on precise way var_omit and var_abort work) via
% \XINT_allexpr_opx_ifnotomitted.
%
% \break() has special meaning here as it is used as last operand, not as last
% value. The code is very unsatisfactory and inefficient but this is hotfix
% for 1.4a.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_allexpr_opx #1#2#3#4#5#6#7#8%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded \bgroup {\iffalse}\fi
    \XINT_expr_iter:_b {#1%
    \expandafter\XINT_allexpr_opx_ifnotomitted
    \romannumeral0#1#6\relax#7@\relax !#5}#4^~{{#8}}\XINT_expr_cb_and_getop
}%
\def\XINT_allexpr_opx_ifnotomitted #1%
{%
    \ifx !#1\xint_dothis{@\relax}\fi
    \ifx ^#1\xint_dothis{\XINTfstop. ^\relax}\fi
    \if ?\xintFirstItem{#1}\xint_dothis{\XINT_allexpr_opx_break{#1}}\fi
    \xint_orthat{\XINTfstop.{#1}}%
}%
\def\XINT_allexpr_opx_break #1#2\relax
{%
    break%
    (\expandafter\XINTfstop\expandafter.\expandafter{\xint_gobble_i#1}#2)\relax
}%
%    \end{macrocode}
% \subsubsection{\cshn{rseq()}}
%
%\begin{lverb}
% When func_rseq has its turn, initial segment has been scanned by
% oparen, the ; mimicking the rôle of a closing parenthesis, and stopping
% further expansion (and leaving a \xint_c_i left-over token since 1.4). The ;
% is discovered during standard parsing mode, it may be for example {;} or
% arise from expansion as rseq does not use a delimited macro to locate it.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_func_rseq   {\XINT_allexpr_rseq \xintbareeval      }%
\def\XINT_flexpr_func_rseq {\XINT_allexpr_rseq \xintbarefloateval }%
\def\XINT_iiexpr_func_rseq {\XINT_allexpr_rseq \xintbareiieval    }%
\def\XINT_allexpr_rseq #1#2#3#4%
{%
    \expandafter\XINT_expr_rseqx
    \expandafter #1\expanded{\xint_noxpd{{#4}}\expandafter}%
    \romannumeral`&&@\XINT_expr_fetch_E_comma_V_equal_E_a {}%
}%
\def\XINT_expr_rseqx #1#2#3#4%
{%
    \XINT:NEhook:rseq \XINT_expr_rseqy\romannumeral0#1(#4)\relax {#2}#3#1%
}%
\def\XINT_expr_rseqy #1#2#3#4#5%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded \bgroup {\iffalse}\fi
    #2%
    \XINT_expr_rseq:_b {#5#4\relax !#3}#1^~{#2}\XINT_expr_cb_and_getop
}%
\def\XINT_expr_rseq:_b #1#2%
{%
    \ifx +#2\xint_dothis\XINT_expr_rseq:_Ca\fi
    \ifx !#2!\xint_dothis\XINT_expr_rseq:_noop\fi
    \ifx ^#2\xint_dothis\XINT_expr_rseq:_end\fi
    \xint_orthat{\XINT_expr_rseq:_c}{#2}{#1}%
}%
\def\XINT_expr_rseq:_noop #1{\XINT_expr_rseq:_b }%
\def\XINT_expr_rseq:_end  #1#2~#3{\iffalse{\fi}}%
\def\XINT_expr_rseq:_c #1#2%
   {\expandafter\XINT_expr_rseq:_d\romannumeral0#2{{#1}}{#2}}%
\def\XINT_expr_rseq:_d #1{\ifx ^#1\xint_dothis\XINT_expr_rseq:_abort\fi
                          \ifx ?#1\xint_dothis\XINT_expr_rseq:_break\fi
                          \ifx !#1\xint_dothis\XINT_expr_rseq:_omit\fi
                          \xint_orthat{\XINT_expr_rseq:_goon {#1}}}%
\def\XINT_expr_rseq:_abort #1!#2^~#3{\iffalse{\fi}}%
\def\XINT_expr_rseq:_break #1!#2^~#3{#1\iffalse{\fi}}%
\def\XINT_expr_rseq:_omit  #1!#2#{%
  \expandafter\XINT_expr_rseq:_b\xint_gobble_i
}%
\def\XINT_expr_rseq:_goon  #1!#2#{\XINT_expr_rseq:_goon_a {#1}}%
\def\XINT_expr_rseq:_goon_a #1#2#3~#4{#1\XINT_expr_rseq:_b #3~{#1}}%
\def\XINT_expr_rseq:_Ca #1#2#3{\XINT_expr_rseq:_Cc#3.{#2}}%
\def\XINT_expr_rseq:_Cb #1%
  {\expandafter\XINT_expr_rseq:_Cc\the\numexpr#1+\xint_c_i.}%
\def\XINT_expr_rseq:_Cc #1.#2%
  {\expandafter\XINT_expr_rseq:_D\romannumeral0#2{{#1[0]}}{#1}{#2}}%
\def\XINT_expr_rseq:_D #1{\ifx ^#1\xint_dothis\XINT_expr_rseq:_abort\fi
                          \ifx ?#1\xint_dothis\XINT_expr_rseq:_break\fi
                          \ifx !#1\xint_dothis\XINT_expr_rseq:_Omit\fi
                          \xint_orthat{\XINT_expr_rseq:_Goon {#1}}}%
\def\XINT_expr_rseq:_Omit  #1!#2#{%
  \expandafter\XINT_expr_rseq:_Cb\xint_gobble_i
}%
\def\XINT_expr_rseq:_Goon  #1!#2#{\XINT_expr_rseq:_Goon_a {#1}}%
\def\XINT_expr_rseq:_Goon_a #1#2#3~#4{#1\XINT_expr_rseq:_Cb #3~{#1}}%
%    \end{macrocode}
% \subsubsection{\cshn{iterr()}}
%\begin{lverb}
% ATTENTION! at 1.4 the @ and @1 are not synonymous anymore. One *must* use
% @1 in iterr() context.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_func_iterr   {\XINT_allexpr_iterr \xintbareeval      }%
\def\XINT_flexpr_func_iterr {\XINT_allexpr_iterr \xintbarefloateval }%
\def\XINT_iiexpr_func_iterr {\XINT_allexpr_iterr \xintbareiieval    }%
\def\XINT_allexpr_iterr #1#2#3#4%
{%
    \expandafter\XINT_expr_iterrx
    \expandafter #1\expanded{{\xintRevWithBraces{#4}}\expandafter}%
    \romannumeral`&&@\XINT_expr_fetch_E_comma_V_equal_E_a {}%
}%
\def\XINT_expr_iterrx #1#2#3#4%
{%
    \XINT:NEhook:iterr\XINT_expr_iterry\romannumeral0#1(#4)\relax {#2}#3#1%
}%
\def\XINT_expr_iterry #1#2#3#4#5%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded \bgroup {\iffalse}\fi
    \XINT_expr_iterr:_b {#5#4\relax !#3}#1^~#20?\XINT_expr_cb_and_getop
}%
\def\XINT_expr_iterr:_b #1#2%
{%
    \ifx +#2\xint_dothis\XINT_expr_iterr:_Ca\fi
    \ifx !#2!\xint_dothis\XINT_expr_iterr:_noop\fi
    \ifx ^#2\xint_dothis\XINT_expr_iterr:_end\fi
    \xint_orthat{\XINT_expr_iterr:_c}{#2}{#1}%
}%
\def\XINT_expr_iterr:_noop #1{\XINT_expr_iterr:_b }%
\def\XINT_expr_iterr:_end  #1#2~#3#4?{{#3}\iffalse{\fi}}%
\def\XINT_expr_iterr:_c #1#2%
  {\expandafter\XINT_expr_iterr:_d\romannumeral0#2{{#1}}{#2}}%
\def\XINT_expr_iterr:_d #1{\ifx ^#1\xint_dothis\XINT_expr_iterr:_abort\fi
                           \ifx ?#1\xint_dothis\XINT_expr_iterr:_break\fi
                           \ifx !#1\xint_dothis\XINT_expr_iterr:_omit\fi
                           \xint_orthat{\XINT_expr_iterr:_goon {#1}}}%
\def\XINT_expr_iterr:_abort #1!#2^~#3?{\iffalse{\fi}}%
\def\XINT_expr_iterr:_break #1!#2^~#3?{#1\iffalse{\fi}}%
\def\XINT_expr_iterr:_omit  #1!#2#{%
  \expandafter\XINT_expr_iterr:_b\xint_gobble_i
}%
\def\XINT_expr_iterr:_goon  #1!#2#{\XINT_expr_iterr:_goon_a{#1}}%
\def\XINT_expr_iterr:_goon_a  #1#2#3~#4?%
{%
    \expandafter\XINT_expr_iterr:_b
    \expanded{\xint_noxpd{#3~}\xintTrim{-2}{#1#4}}0?%
}%
\def\XINT_expr_iterr:_Ca #1#2#3{\XINT_expr_iterr:_Cc#3.{#2}}%
\def\XINT_expr_iterr:_Cb #1%
  {\expandafter\XINT_expr_iterr:_Cc\the\numexpr#1+\xint_c_i.}%
\def\XINT_expr_iterr:_Cc #1.#2%
   {\expandafter\XINT_expr_iterr:_D\romannumeral0#2{{#1[0]}}{#1}{#2}}%
\def\XINT_expr_iterr:_D #1{\ifx ^#1\xint_dothis\XINT_expr_iterr:_abort\fi
                          \ifx ?#1\xint_dothis\XINT_expr_iterr:_break\fi
                          \ifx !#1\xint_dothis\XINT_expr_iterr:_Omit\fi
                          \xint_orthat{\XINT_expr_iterr:_Goon {#1}}}%
\def\XINT_expr_iterr:_Omit #1!#2#{%
  \expandafter\XINT_expr_iterr:_Cb\xint_gooble_i
}%
\def\XINT_expr_iterr:_Goon  #1!#2#{\XINT_expr_iterr:_Goon_a{#1}}%
\def\XINT_expr_iterr:_Goon_a  #1#2#3~#4?%
{%
    \expandafter\XINT_expr_iterr:_Cb
    \expanded{\xint_noxpd{#3~}\xintTrim{-2}{#1#4}}0?%
}%
%    \end{macrocode}
% \subsubsection{\cshn{rrseq()}}
%
%\begin{lverb}
% When func_rrseq has its turn, initial segment has been scanned
% by oparen, the ; mimicking the rôle of a closing parenthesis, and
% stopping further expansion. #2 = \xint_c_i and #3 are left-over trash.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_func_rrseq   {\XINT_allexpr_rrseq \xintbareeval      }%
\def\XINT_flexpr_func_rrseq {\XINT_allexpr_rrseq \xintbarefloateval }%
\def\XINT_iiexpr_func_rrseq {\XINT_allexpr_rrseq \xintbareiieval    }%
\def\XINT_allexpr_rrseq #1#2#3#4%
{%
    \expandafter\XINT_expr_rrseqx\expandafter#1\expanded
       {\xint_noxpd{{#4}}{\xintRevWithBraces{#4}}\expandafter}%
    \romannumeral`&&@\XINT_expr_fetch_E_comma_V_equal_E_a {}%
}%
\def\XINT_expr_rrseqx #1#2#3#4#5%
{%
    \XINT:NEhook:rrseq\XINT_expr_rrseqy\romannumeral0#1(#5)\relax {#2}{#3}#4#1%
}%
\def\XINT_expr_rrseqy #1#2#3#4#5#6%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded \bgroup {\iffalse}\fi
    #2\XINT_expr_rrseq:_b {#6#5\relax !#4}#1^~#30?\XINT_expr_cb_and_getop
}%
\def\XINT_expr_rrseq:_b #1#2%
{%
    \ifx +#2\xint_dothis\XINT_expr_rrseq:_Ca\fi
    \ifx !#2!\xint_dothis\XINT_expr_rrseq:_noop\fi
    \ifx ^#2\xint_dothis\XINT_expr_rrseq:_end\fi
    \xint_orthat{\XINT_expr_rrseq:_c}{#2}{#1}%
}%
\def\XINT_expr_rrseq:_noop #1{\XINT_expr_rrseq:_b }%
\def\XINT_expr_rrseq:_end  #1#2~#3?{\iffalse{\fi}}%
\def\XINT_expr_rrseq:_c #1#2%
  {\expandafter\XINT_expr_rrseq:_d\romannumeral0#2{{#1}}{#2}}%
\def\XINT_expr_rrseq:_d #1{\ifx ^#1\xint_dothis\XINT_expr_rrseq:_abort\fi
                           \ifx ?#1\xint_dothis\XINT_expr_rrseq:_break\fi
                           \ifx !#1\xint_dothis\XINT_expr_rrseq:_omit\fi
                           \xint_orthat{\XINT_expr_rrseq:_goon {#1}}}%
\def\XINT_expr_rrseq:_abort #1!#2^~#3?{\iffalse{\fi}}%
\def\XINT_expr_rrseq:_break #1!#2^~#3?{#1\iffalse{\fi}}%
\def\XINT_expr_rrseq:_omit  #1!#2#{%
  \expandafter\XINT_expr_rrseq:_b\xint_gobble_i
}%
\def\XINT_expr_rrseq:_goon  #1!#2#{\XINT_expr_rrseq:_goon_a {#1}}%
\def\XINT_expr_rrseq:_goon_a  #1#2#3~#4?%
{%
    #1\expandafter\XINT_expr_rrseq:_b
    \expanded{\xint_noxpd{#3~}\xintTrim{-2}{#1#4}}0?%
}%
\def\XINT_expr_rrseq:_Ca #1#2#3{\XINT_expr_rrseq:_Cc#3.{#2}}%
\def\XINT_expr_rrseq:_Cb #1%
  {\expandafter\XINT_expr_rrseq:_Cc\the\numexpr#1+\xint_c_i.}%
\def\XINT_expr_rrseq:_Cc #1.#2%
   {\expandafter\XINT_expr_rrseq:_D\romannumeral0#2{{#1[0]}}{#1}{#2}}%
\def\XINT_expr_rrseq:_D #1{\ifx ^#1\xint_dothis\XINT_expr_rrseq:_abort\fi
                          \ifx ?#1\xint_dothis\XINT_expr_rrseq:_break\fi
                          \ifx !#1\xint_dothis\XINT_expr_rrseq:_Omit\fi
                          \xint_orthat{\XINT_expr_rrseq:_Goon {#1}}}%
\def\XINT_expr_rrseq:_Omit  #1!#2#{%
  \expandafter\XINT_expr_rrseq:_Cb\xint_gobble_i
}%
\def\XINT_expr_rrseq:_Goon  #1!#2#{\XINT_expr_rrseq:_Goon_a {#1}}%
\def\XINT_expr_rrseq:_Goon_a  #1#2#3~#4?%
{%
    #1\expandafter\XINT_expr_rrseq:_Cb
      \expanded{\xint_noxpd{#3~}\xintTrim{-2}{#1#4}}0?%
}%
\catcode`? 11
%    \end{macrocode}
% \subsection{Pseudo-functions related to N-dimensional hypercubic lists}
% \subsubsection{\cshn{ndseq()}}
%\begin{lverb}
% New with 1.4. 2020/01/23. It is derived from subsm() but instead of
% evaluating one expression according to one value per variable, it constructs
% a nested bracketed seq... this means the expression is parsed each time !
% Anyway, proof of concept. Nota Bene : omit, abort, break() work !
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_onliteral_ndseq
{%
    \expandafter\XINT_allexpr_ndseq_f
    \romannumeral`&&@\XINT_expr_fetch_E_comma_V_equal_E_a {}%
}%
\def\XINT_allexpr_ndseq_f #1#2{\xint_c_ii^v `{ndseqx}#2)\relax #1}%
\def\XINT_expr_func_ndseqx
{%
    \expandafter\XINT_allexpr_ndseqx\expandafter\xintbareeval
    \expandafter{\romannumeral0\expandafter\xint_gobble_i\string}%
    \expandafter\xintrevwithbraces
    \expanded\bgroup{\iffalse}\fi\XINT_allexpr_ndseq_A\XINT_expr_oparen
}%
\def\XINT_flexpr_func_ndseqx
{%
    \expandafter\XINT_allexpr_ndseqx\expandafter\xintbarefloateval
    \expandafter{\romannumeral0\expandafter\xint_gobble_i\string}%
    \expandafter\xintrevwithbraces
    \expanded\bgroup{\iffalse}\fi\XINT_allexpr_ndseq_A\XINT_flexpr_oparen
}%
\def\XINT_iiexpr_func_ndseqx
{%
    \expandafter\XINT_allexpr_ndseqx\expandafter\xintbareiieval
    \expandafter{\romannumeral0\expandafter\xint_gobble_i\string}%
    \expandafter\xintrevwithbraces
    \expanded\bgroup{\iffalse}\fi\XINT_allexpr_ndseq_A\XINT_iiexpr_oparen
}%
\def\XINT_allexpr_ndseq_A #1#2#3%
{%
    \ifx#2\xint_c_
       \expandafter\XINT_allexpr_ndseq_C
    \else
       \expandafter\XINT_allexpr_ndseq_B
    \fi #1%
}%
\def\XINT_allexpr_ndseq_B #1#2#3#4=%
{%
    {#2}{\xint_zapspaces#3#4 \xint_gobble_i}%
    \expandafter\XINT_allexpr_ndseq_A\expandafter#1\romannumeral`&&@#1%
}%
%    \end{macrocode}
%\begin{lverb}
%  #1 = \xintbareeval,  or \xintbarefloateval or \xintbareiieval
%  #2 = values for last coordinate
%\end{lverb}
%    \begin{macrocode}
\def\XINT_allexpr_ndseq_C #1#2{{#2}\iffalse{{{\fi}}}}%
%    \end{macrocode}
%\begin{lverb}
%  #1 = \xintbareeval or \xintbarefloateval or \xintbareiieval
%  #2 = {valuesN}...{values2}{var2}{values1}
%  #3 = {var1}
%  #4 = the expression to evaluate
%\end{lverb}
%    \begin{macrocode}
\def\XINT_allexpr_ndseqx #1#2#3#4%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded
    \bgroup
      \romannumeral0#1\empty
      \expanded{\xintReplicate{\xintLength{{#3}#2}/2}{[seq(}%
                \xint_noxpd{#4}%
                \XINT_allexpr_ndseqx_a #2{#3}^^%
                }%
      \relax
    \iffalse{\fi\expandafter}\romannumeral`&&@\XINT_expr_getop
}%
\def\XINT_allexpr_ndseqx_a #1#2%
{%
    \xint_gob_til_^ #1\XINT_allexpr_ndseqx_e ^%
    \xint_noxpd{,#2=\XINTfstop.{#1})]}\XINT_allexpr_ndseqx_a
}%
\def\XINT_allexpr_ndseqx_e ^#1\XINT_allexpr_ndseqx_a{}%
%    \end{macrocode}
% \subsubsection{\cshn{ndmap()}}
%\begin{lverb}
% New with 1.4. 2020/01/24.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_onliteral_ndmap #1,{\xint_c_ii^v `{ndmapx}\XINTfstop.{#1};}%
\def\XINT_expr_func_ndmapx #1#2#3%
{%
    \expandafter\XINT_allexpr_ndmapx
    \csname XINT_expr_func_\xint_zapspaces #3 \xint_gobble_i\endcsname
    \XINT_expr_oparen
}%
\def\XINT_flexpr_func_ndmapx #1#2#3%
{%
    \expandafter\XINT_allexpr_ndmapx
    \csname XINT_flexpr_func_\xint_zapspaces #3 \xint_gobble_i\endcsname
    \XINT_flexpr_oparen
}%
\def\XINT_iiexpr_func_ndmapx #1#2#3%
{%
    \expandafter\XINT_allexpr_ndmapx
    \csname XINT_iiexpr_func_\xint_zapspaces #3 \xint_gobble_i\endcsname
    \XINT_iiexpr_oparen
}%
\def\XINT_allexpr_ndmapx #1#2%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded\bgroup{\iffalse}\fi
    \expanded
      {\noexpand\XINT:NEhook:x:ndmapx
       \noexpand\XINT_allexpr_ndmapx_a
       \noexpand#1{}\expandafter}%
    \expanded\bgroup\expandafter\XINT_allexpr_ndmap_A
                    \expandafter#2\romannumeral`&&@#2%
}%
\def\XINT_allexpr_ndmap_A #1#2#3%
{%
    \ifx#3;%
       \expandafter\XINT_allexpr_ndmap_B
    \else
       \xint_afterfi{\XINT_allexpr_ndmap_C#2#3}%
    \fi #1%
}%
\def\XINT_allexpr_ndmap_B #1#2%
{%
    {#2}\expandafter\XINT_allexpr_ndmap_A\expandafter#1\romannumeral`&&@#1%
}%
\def\XINT_allexpr_ndmap_C #1#2#3#4%
{%
    {#4}^\relax\iffalse{{{\fi}}}#1#2%
}%
\def\XINT_allexpr_ndmapx_a #1#2#3%
{%
    \xint_gob_til_^ #3\XINT_allexpr_ndmapx_l ^%
    \XINT_allexpr_ndmapx_b #1{#2}{#3}%
}%
\def\XINT_allexpr_ndmapx_l ^#1\XINT_allexpr_ndmapx_b #2#3#4\relax
{%
    #2\empty\xint_firstofone{#3}%
}%
\def\XINT_allexpr_ndmapx_b #1#2#3#4\relax
{%
    {\iffalse}\fi\XINT_allexpr_ndmapx_c {#4\relax}#1{#2}#3^%
}%
\def\XINT_allexpr_ndmapx_c #1#2#3#4%
{%
    \xint_gob_til_^ #4\XINT_allexpr_ndmapx_e ^%
    \XINT_allexpr_ndmapx_a #2{#3{#4}}#1%
    \XINT_allexpr_ndmapx_c  {#1}#2{#3}%
}%
\def\XINT_allexpr_ndmapx_e ^#1\XINT_allexpr_ndmapx_c
   {\iffalse{\fi}\xint_gobble_iii}%
%    \end{macrocode}
% \subsubsection{\cshn{ndfillraw()}}
%\begin{lverb}
% New with 1.4. 2020/01/24. J'hésite à autoriser un #1 quelconque,
% ou plutôt à le wrapper dans un \xintbareval. Mais il faut alors distinguer
% les trois. De toute façon les variables ne marcheraient pas donc j'hésite
% à mettre un wrapper automatique. Mais ce n'est pas bien d'autoriser l'injection
% de choses quelconques.
%
% Pour des choses comme ndfillraw(\xintRandomBit,[10,10]).
%
% Je n'aime pas le nom !. Le changer. ndconst? Surtout je n'aime pas
% que dans le premier argument il faut rajouter explicitement si nécessaire
% \xintiiexpr wrap.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_onliteral_ndfillraw #1,%
  {\xint_c_ii^v `{ndfillrawx}\XINTfstop.{{#1}},}%
\def\XINT_expr_func_ndfillrawx #1#2#3%
{%
    \expandafter#1\expandafter#2%
    \expanded{{{\XINT_allexpr_ndfillrawx_a #3}}}%
}%
\let\XINT_iiexpr_func_ndfillrawx\XINT_expr_func_ndfillrawx
\let\XINT_flexpr_func_ndfillrawx\XINT_expr_func_ndfillrawx
\def\XINT_allexpr_ndfillrawx_a #1#2%
{%
    \expandafter\XINT_allexpr_ndfillrawx_b
    \romannumeral0\xintApply{\calxListItemToNum}{#2}^\relax {#1}%
}%
\def\XINT_allexpr_ndfillrawx_b #1#2\relax#3%
{%
    \xint_gob_til_^ #1\XINT_allexpr_ndfillrawx_c ^%
    \xintReplicate{#1}{{\XINT_allexpr_ndfillrawx_b #2\relax {#3}}}%
}%
\def\XINT_allexpr_ndfillrawx_c ^\xintReplicate #1#2%
{%
    \expandafter\XINT_allexpr_ndfillrawx_d\xint_firstofone #2%
}%
\def\XINT_allexpr_ndfillrawx_d\XINT_allexpr_ndfillrawx_b \relax #1{#1}%
%    \end{macrocode}
% \subsubsection{Making them known to the other parsers}
% \changed{2.0a1}
% The "onliteral" handlers are now per-parser for reasons unrelated
% to the above constructs.  Very poorly documented, see next section.
%    \begin{macrocode}
\xintFor* #1 in
{{subs}{subsm}{subsn}{seq}{add}{mul}{ndseq}{ndmap}{ndfillraw}}\do{%
    \expandafter\let\csname XINT_flexpr_onliteral_#1\expandafter\endcsname
                    \csname XINT_expr_onliteral_#1\endcsname
    \expandafter\let\csname XINT_iiexpr_onliteral_#1\expandafter\endcsname
                    \csname XINT_expr_onliteral_#1\endcsname
}%
%    \end{macrocode}
% \subsection{Other pseudo-functions: \cshn{bool()}, \cshn{togl()}, \cshn{protect()},
% \cshn{qraw()}, \cshn{qint()}, \cshn{qfrac()}, \cshn{qfloat()}, \cshn{qrand()},
% \cshn{random()}, \cshn{rbit()}}
%
%\begin{lverb}
% bool, togl and protect use delimited macros. They are not true
% functions, they turn off the parser to gather their "variable".
%\end{lverb}
%
% \changed{1.2} Adds |qint()|, |qfrac()|, |qfloat()|.
%
% \changed{1.3c} Adds |qraw()|. Useful to limit impact on \TeX{} memory
% from abuse of |\csname|'s storage when generating many comma separated
% values from a loop.
%
% \changed{1.3e} |qfloat()| keeps a short mantissa if possible.
%
%\begin{lverb}
% They allow the user to hand over quickly a big number to the parser,
% spaces not immediately removed but should be harmless in general. The qraw()
% does no post-processing at all apart complete expansion, useful for
% comma-separated values, but must be obedient to (non really documented)
% expected format. Each uses a delimited macro, the closing parenthesis can
% not emerge from expansion.
%\end{lverb}
%
%\begin{lverb}
% 1.3b. random(), qrand()
% Function-like syntax but with no argument currently, so let's
% use fast parsing which requires though the closing parenthesis to be
% explicit.
%\end{lverb}
%
%\begin{lverb}
% Attention that qraw()
% which pre-supposes knowledge of internal storage model is fragile
% and may break at any release.
%
% 1.4 adds rbit(). Short for random bit.
%\end{lverb}
%
% \changed{2.0a1} Now needs |\let| to make "onliteral" handlers known
% to other parsers.
%    \begin{macrocode}
\def\XINT_expr_onliteral_bool #1)%
    {\expandafter\XINT_expr_put_op_first
     \expanded{{{\xintBool{#1}[0]}}\expandafter
     }\romannumeral`&&@\XINT_expr_getop}%
\def\XINT_expr_onliteral_togl #1)%
    {\expandafter\XINT_expr_put_op_first
     \expanded{{{\xintToggle{#1}[0]}}\expandafter
     }\romannumeral`&&@\XINT_expr_getop}%
\def\XINT_expr_onliteral_protect #1)%
    {\expandafter\XINT_expr_put_op_first
     \expanded{{{\detokenize{#1}}}\expandafter
     }\romannumeral`&&@\XINT_expr_getop}%
\def\XINT_expr_onliteral_qint #1)%
    {\expandafter\XINT_expr_put_op_first
     \expanded{{{\xintiNum{#1}[0]}}\expandafter
     }\romannumeral`&&@\XINT_expr_getop}%
\xintFor* #1 in {{bool}{togl}{protect}{qint}}\do{%
    \expandafter\let\csname XINT_flexpr_onliteral_#1\expandafter\endcsname
                    \csname XINT_expr_onliteral_#1\endcsname
    \expandafter\let\csname XINT_iiexpr_onliteral_#1\expandafter\endcsname
                    \csname XINT_expr_onliteral_#1\endcsname
}%
%    \end{macrocode}
%
% \changed{2.0a1}
%
%\begin{lverb}
% BREAKING CHANGE. The qfloat() interface is REMOVED from \xintiieval.
% Only kept in \xintfloateval and \xinteval (with xintexpr.sty).
%
% qraw() should never have been mentioned in user manual.
% It is a use-at-own-risk. Depends on knowing internals.
%\end{lverb}
%
%\begin{lverb}
% THIS AI COMMENT IS PARTLY OBSOLETE. IT LOCATED \xintFor LOOPS
% AT WRONG PLACES REGARDING CODE LEGIBILITY. USER MANUAL INTERVENTION
% MODIFIED LAYOUT. BESIDES THE \xintFor LOOPS THEMSELVES USED AN
% INTERMEDIATE MACRO \XINT_tmpa STILL REDUCING LEGIBILIT.
% THE AI HAS MESSED UP THE INTERNAL LOGIC.
%
% calx: the onliterals are looked up per parser
% (\XINT_<p>_onliteral_<name>): the \xinteval ones are copied
% for \xintfloateval and \xintiieval. qint() of \xintiieval
% gives an M value, qfloat() of \xintfloateval an F value (as float()),
% random() and qrand() of \xintfloateval F values (calxfp's
% \calxFpRandomSdigits, \calxFpRandomSixteen).
% The argument of qfloat() of \xintfloateval is read by \CALX_fround: a
% raw value A, A[N], A/B, A/B[N] (any xintfrac input with xintexpr.sty).
% qfrac(A/B) (the slash is mandatory; A and B f-expand to integers in
% strict format: 0 or an optional - then digits without leading zero):
% \xintfloateval: A/B rounded to P digits (\CALX_fqfrac: exact F values
% of A and B by calxfp's \CALX_ffromraw, then its correctly rounded
% division \CALX_fr_xk; B may be negative; B = 0 signals as x / 0);
% \xintiieval: A/B[0] (B > 0), for round(), trunc(), num() etc. The
% \xinteval qfrac() (\xintRaw, any xintfrac input) is xintexpr.sty's;
% loading it does not change the two calx ones.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_expr_onliteral_qraw #1)%
    {\expandafter\XINT_expr_put_op_first\expanded{{#1}\expandafter
     }\romannumeral`&&@\XINT_expr_getop}%
\let\XINT_flexpr_onliteral_qraw\XINT_expr_onliteral_qraw
\let\XINT_iiexpr_onliteral_qraw\XINT_expr_onliteral_qraw
\def\XINT_expr_onliteral_qfloat #1)%
   {\expandafter\XINT_expr_put_op_first
    \expanded{{{\calxFpFloatdigits{#1}}}\expandafter
     }\romannumeral`&&@\XINT_expr_getop}%
\let\XINT_flexpr_onliteral_qfloat\XINT_expr_onliteral_qfloat
\def\XINT_expr_onliteral_random #1)%
    {\expandafter\XINT_expr_put_op_first
     \expanded{{{\XINTinRandomFloatSdigits}}\expandafter
     }\romannumeral`&&@\XINT_expr_getop}%
\let\XINT_iiexpr_onliteral_random\XINT_expr_onliteral_random
\def\XINT_flexpr_onliteral_random #1)%
   {\expandafter\XINT_expr_put_op_first
    \expanded{{{\calxFpRandomSdigits}}\expandafter
     }\romannumeral`&&@\XINT_expr_getop}%
\def\XINT_expr_onliteral_qrand #1)%
   {\expandafter\XINT_expr_put_op_first
    \expanded{{{\XINTinRandomFloatSixteen}}\expandafter
     }\romannumeral`&&@\XINT_expr_getop}%
\let\XINT_iiexpr_onliteral_qrand\XINT_expr_onliteral_qrand
\def\XINT_flexpr_onliteral_qrand #1)%
   {\expandafter\XINT_expr_put_op_first
    \expanded{{{\calxFpRandomSixteen}}\expandafter
     }\romannumeral`&&@\XINT_expr_getop}%
\def\XINT_expr_onliteral_rbit #1)%
   {\expandafter\XINT_expr_put_op_first
    \expanded{{{\xintRandBit[0]}}\expandafter
     }\romannumeral`&&@\XINT_expr_getop}%
\let\XINT_flexpr_onliteral_rbit\XINT_expr_onliteral_rbit
\let\XINT_iiexpr_onliteral_rbit\XINT_expr_onliteral_rbit
\def\XINT_iiexpr_onliteral_qint #1)%
   {\expandafter\XINT_expr_put_op_first
    \expanded{{{\romannumeral0\CALX_mfromraw{\xintiNum{#1}}}}\expandafter
     }\romannumeral`&&@\XINT_expr_getop}%
\def\XINT_expr_onliteral_qfrac #1/#2)%
   {\expandafter\XINT_expr_put_op_first
    \expanded{{{#1/#2[0]}}\expandafter
     }\romannumeral`&&@\XINT_expr_getop}%
\let\XINT_iiexpr_onliteral_qfrac\XINT_expr_onliteral_qfrac
\def\XINT_flexpr_onliteral_qfrac #1/#2)%
   {\expandafter\XINT_expr_put_op_first
    \expanded{{{\CALX_fqfrac{#1}{#2}}}\expandafter
     }\romannumeral`&&@\XINT_expr_getop}%
%    \end{macrode}
%    \begin{macrocode}
\def\CALX_fqfrac #1#2%
   {\romannumeral0\expandafter\CALX_fr_xk\expanded
    {\romannumeral0\CALX_ffromraw{#1[0]}\xint:%
     \romannumeral0\CALX_ffromraw{#2[0]}\xint:{\the\numexpr\XINTdigits}}}%
%    \end{macrocode}
% \def\auxiliarymacro#1{ \noexpand\cshn{#1()}}
% \edef\zzz{Regular built-in functions: \xintListWithSep{, }{\xintApply\auxiliarymacro
% {{num}{reduce}{preduce}
% {abs}{sgn}{frac}{floor}{ceil}{sqr}
% {?}{!}{not}{odd}{even}{isint}{isone}
% {factorial}{sqrt}{sqrtr}
% {inv}{round}{trunc}
% {float}{sfloat}{ilog10}
% {divmod}{mod}{binomial}{pfactorial}
% {randrange}
% {iquo}{irem}{gcd}{lcm}{max}{min}
% {`+`}{`*`}
% {all}{any}{xor}
% {len}{first}{last}{reversed}
% {if}{ifint}{ifone}{ifsgn}
% {nuple}{unpack}{flat}}}
% and \noexpand\cshn{zip()}}
% \expandafter\subsection\expandafter{\zzz}
%    \begin{macrocode}
\def\XINT:expr:f:one:and:opt #1#2#3!#4#5%
{%
    \if\relax#3\relax\expandafter\xint_firstoftwo\else
                      \expandafter\xint_secondoftwo\fi
    {#4}{#5[\calxListItemToNum{#2}]}{#1}%
}%
\def\XINT:expr:f:tacitzeroifone #1#2#3!#4#5%
{%
    \if\relax#3\relax\expandafter\xint_firstoftwo\else
                      \expandafter\xint_secondoftwo\fi
    {#4{0}}{#5{\calxListItemToNum{#2}}}{#1}%
}%
\def\XINT:expr:f:iitacitzeroifone #1#2#3!#4%
{%
    \if\relax#3\relax\expandafter\xint_firstoftwo\else
                      \expandafter\xint_secondoftwo\fi
    {#4{0[0]}}{#4{#2}}{#1}%
}%
\def\XINT_iiexpr_func_num #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxListItemToNum#3}}%
}%
\def\XINT_flexpr_func_num #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpTrunc#3}}%
}%
\def\XINT_flexpr_func_abs #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpAbs#3}}%
}%
\def\XINT_iiexpr_func_abs #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxiiAbs#3}}%
}%
\def\XINT_iiexpr_func_sgn #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxSgn#3}}%
}%
\def\XINT_flexpr_func_sgn #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpSgn#3}}%
}%
\def\XINT_flexpr_func_frac #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpFrac#3}}%
}%
%    \end{macrocode}
%\begin{lverb}
% no \XINT_iiexpr_func_frac
%\end{lverb}
%    \begin{macrocode}
\def\XINT_flexpr_func_floor #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpFloor#3}}%
}%
%    \end{macrocode}
%\begin{lverb}
% The floor and ceil functions in \xintiiexpr require protect(a/b) or,
% better, \qfrac(a/b); else the / will be executed first and do an integer
% rounded division.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_iiexpr_func_floor #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxiiFloor#3}}%
}%
\def\XINT_flexpr_func_ceil #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpCeil#3}}%
}%
\def\XINT_iiexpr_func_ceil #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxiiCeil#3}}%
}%
\def\XINT_flexpr_func_sqr #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpSqr#3}}%% calx
}%
\def\XINT_iiexpr_func_sqr #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxiiSqr#3}}%
}%
\def\XINT_iiexpr_func_? #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxIsNotZero#3}}%
}%
\def\XINT_flexpr_func_? #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpIsNotZero#3}}%
}%
\def\XINT_iiexpr_func_! #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxIsZero#3}}%
}%
\def\XINT_flexpr_func_! #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpIsZero#3}}%
}%
\def\XINT_iiexpr_func_not #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxIsZero#3}}%
}%
\def\XINT_flexpr_func_not #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpIsZero#3}}%
}%
\def\XINT_flexpr_func_odd #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpOdd#3}}%
}%
\def\XINT_iiexpr_func_odd #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxiiOdd#3}}%
}%
\def\XINT_flexpr_func_even #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpEven#3}}%
}%
\def\XINT_iiexpr_func_even #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxiiEven#3}}%
}%
\def\XINT_flexpr_func_isint #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpIsInt#3}}%
}%
\def\XINT_iiexpr_func_isint #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxiiIsInt#3}}%
}%
\def\XINT_flexpr_func_isone #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpIsOne#3}}%
}%
\def\XINT_iiexpr_func_isone #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxiiIsOne#3}}%
}%
\def\XINT_flexpr_func_factorial #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:and:opt:direct
    \XINT:expr:f:one:and:opt#3,!\calxFpFacdigits\calxFpFac
    }}%
}%
\def\XINT_iiexpr_func_factorial #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxiiFac#3}}%
}%
\def\XINT_flexpr_func_sqrt #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:and:opt:direct
    \XINT:expr:f:one:and:opt #3,!\calxFpSqrtdigits\calxFpSqrt% calx
    }}%
}%
\def\XINT_iiexpr_func_sqrt #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxiiSqrt#3}}%
}%
\def\XINT_iiexpr_func_sqrtr #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxiiSqrtR#3}}%
}%
\def\XINT_flexpr_func_inv #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpInv#3}}%
}%
\def\XINT_flexpr_func_round #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:tacitzeroifone:direct
    \XINT:expr:f:tacitzeroifone #3,!\calxFpIRound\calxFpRoundTo
    }}%
}%
\def\XINT_iiexpr_func_round #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:iitacitzeroifone:direct
    \XINT:expr:f:iitacitzeroifone #3,!\calxiiRound
    }}%
}%
\def\XINT_flexpr_func_trunc #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:tacitzeroifone:direct
    \XINT:expr:f:tacitzeroifone #3,!\calxFpITrunc\calxFpTruncTo
    }}%
}%
\def\XINT_iiexpr_func_trunc #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:iitacitzeroifone:direct
    \XINT:expr:f:iitacitzeroifone #3,!\calxiiTrunc
    }}%
}%
%    \end{macrocode}
%\begin{lverb}
% Hesitation at 1.3e about using \XINTinFloatSdigits and \XINTinFloatS.
% Finally I add a sfloat() function. It helps for xinttrig.sty.
%
% At 2.0a1, there is no xinttrig.sty anymore. The sfloat() function
% and its support macros \XINTinFloatSdigits and \XINTinFloatS have
% no real rationale: the S variant goal was to produce smaller mantissas,
% but there is hardly any utility for this with the calx float model.
% So we let the sfloat() be like float() in \xintfloateval. Neither float()
% nor sfloat() were ever defined in \xintiieval.  The \xinteval float()
% and sfloat() keep their legacy meanings and are defined in xintexpr.sty.
% Most of the comments that folllow below are either outdate or regard
% the \xinteval situation.
%\end{lverb}
%
%\begin{lverb}
% float_() was added at 1.4, as a shortcut alias to float() skipping the check
% for an optional second argument.  This is useful to transfer function
% definitions between \xintexpr and \xintfloatexpr contexts.
%
%
% No need for a similar shortcut for sfloat() as currently used in
% xinttrig.sty to go from float to expr: as it is used there as sfloat(x) with
% dummy x, it sees there is no optional argument, contrarily to for example
% float(\xintexpr...\relax) which has to allow for the inner expression to
% expand to an ople with two items, so does not know in which branch it is at
% time of definiion.
%
%
% After some hesitation at 1.4e regarding guard digits mechanism the float_()
% got renamed to float_dgt(), but then renamed back to float_() to avoid a
% breaking change and having to document it.
%
% Nevertheless the documentation of 1.4e mentioned float_dgt()... but it was still
% float_()... now changed into float_dgt() for real at 1.4f.
%
% 1.4f also adds private float_dgtormax and sfloat_dgtormax for matters of xinttrig.
%
%\end{lverb}
%    \begin{macrocode}
\def\XINT_flexpr_func_float #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:and:opt:direct
    \XINT:expr:f:one:and:opt #3,!\calxFpFloatdigits\calxFpFloat
    }}%
}%
\def\XINT_flexpr_func_float_dgt #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpFloatdigits#3}}%
}%
\let\XINT_flexpr_func_sfloat\XINT_flexpr_func_float
\expandafter\def\csname XINT_flexpr_func_ilog10\endcsname #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:and:opt:direct
    \XINT:expr:f:one:and:opt #3,!\calxFpiLogTendigits\calxFpiLogTen
    }}%
}%
\expandafter\def\csname XINT_iiexpr_func_ilog10\endcsname #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxiiLogTen#3}}%
}%
\def\XINT_flexpr_func_divmod #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\romannumeral`&&@%
    \XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxFpDivMod #3}}%
}%
\def\XINT_iiexpr_func_divmod #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\romannumeral`&&@%
    \XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxiiDivMod #3}}%
}%
\def\XINT_flexpr_func_mod #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\romannumeral`&&@%
    \XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxFpMod#3}}%
}%
\def\XINT_iiexpr_func_mod #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\romannumeral`&&@%
    \XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxiiMod#3}}%
}%
\def\XINT_flexpr_func_binomial #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\romannumeral`&&@%
    \XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxFpBinomial #3}}%
}%
\def\XINT_iiexpr_func_binomial #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\romannumeral`&&@%
    \XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxiiBinomial #3}}%
}%
\def\XINT_flexpr_func_pfactorial #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\romannumeral`&&@%
    \XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxFpPFactorial #3}}%
}%
\def\XINT_iiexpr_func_pfactorial #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\romannumeral`&&@%
    \XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxiiPFactorial #3}}%
}%
\def\XINT_flexpr_func_randrange #1#2#3%
{%
    \expandafter #1\expandafter #2\expanded{{{%
    \XINT:expr:randrange #3,!%
    }}}%
}%
\def\XINT:expr:randrange #1#2#3!%
{%
    \if\relax#3\relax\expandafter\xint_firstoftwo\else
                     \expandafter\xint_secondoftwo\fi
    {\calxintRandRange{\XINT:NEhook:f:one:from:one:direct\calxFpToM{#1}}}%
    {\calxintRandRangeAtoB
                      {\XINT:NEhook:f:one:from:one:direct\calxFpToM{#1}}%
                      {\XINT:NEhook:f:one:from:one:direct\calxFpToM{#2}}%
     }%
}%
\def\XINT_iiexpr_func_randrange #1#2#3%
{%
    \expandafter #1\expandafter #2\expanded{{{%
    \XINT:iiexpr:randrange #3,!%
    }}}%
}%
\def\XINT:iiexpr:randrange #1#2#3!%
{%
    \if\relax#3\relax\expandafter\xint_firstoftwo\else
                     \expandafter\xint_secondoftwo\fi
    {\calxintRandRange{#1}}%
    {\calxintRandRangeAtoB{#1}{#2}}%
}%
\def\XINT_iiexpr_func_iquo #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\romannumeral`&&@%
    \XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxiiQuo #3}}%
}%
\def\XINT_iiexpr_func_irem #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\romannumeral`&&@%
    \XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxiiRem #3}}%
}%
\def\XINT_iiexpr_func_gcd #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\CALX_iiGCDof#3^}}%
}%
\def\XINT_iiexpr_func_lcm #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\CALX_iiLCMof#3^}}%
}%
\def\XINT_iiexpr_func_max #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\CALX_iiMaxof#3^}}%
}%
\def\XINT_flexpr_func_max #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\calxFpMaxof#3^}}% calx
}%
\def\XINT_iiexpr_func_min #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\CALX_iiMinof#3^}}%
}%
\def\XINT_flexpr_func_min #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\calxFpMinof#3^}}% calx
}%
\expandafter
\def\csname XINT_flexpr_func_+\endcsname #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\calxFpSum#3^}}%
}%
\expandafter
\def\csname XINT_iiexpr_func_+\endcsname #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\CALX_iiSum#3^}}%
}%
\expandafter
\def\csname XINT_flexpr_func_*\endcsname #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\calxFpPrd#3^}}%
}%
\expandafter
\def\csname XINT_iiexpr_func_*\endcsname #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\CALX_iiPrd#3^}}%
}%
\def\XINT_iiexpr_func_all #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\CALX_ANDof#3^}}%
}%
\def\XINT_flexpr_func_all #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\calxFpANDof#3^}}%
}%
\def\XINT_iiexpr_func_any #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\CALX_ORof#3^}}%
}%
\def\XINT_flexpr_func_any #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\calxFpORof#3^}}%
}%
\def\XINT_iiexpr_func_xor #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\CALX_XORof#3^}}%
}%
\def\XINT_flexpr_func_xor #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{\expandafter
    {\romannumeral`&&@\XINT:NEhook:f:from:delim:u\calxFpXORof#3^}}%
}%
\def\XINT_iiexpr_func_len #1#2#3%
{%
    \expandafter#1\expandafter#2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:LFL\xintLength
    {\romannumeral\XINT:NEhook:r:check#3^}%
    }}%
}%
\def\XINT_flexpr_func_len #1#2#3%
{%
    \expandafter#1\expandafter#2\expandafter{\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:LFL\calxFpLength
    {\romannumeral\XINT:NEhook:r:check#3^}%
    }}%
}%
\def\XINT_flexpr_func_first #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:LFL\xintFirstOne
    {\romannumeral\XINT:NEhook:r:check#3^}%
    }%
}%
\let\XINT_iiexpr_func_first\XINT_flexpr_func_first
\def\XINT_flexpr_func_last #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:LFL\xintLastOne
    {\romannumeral\XINT:NEhook:r:check#3^}%
    }%
}%
\let\XINT_iiexpr_func_last\XINT_flexpr_func_last
\def\XINT_flexpr_func_reversed #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:reverse\XINT_expr_reverse
    #3^^#3\xint:\xint:\xint:\xint:
          \xint:\xint:\xint:\xint:\xint_bye
    }%
}%
\def\XINT_expr_reverse #1#2%
{%
    \if ^\noexpand#2%
        \expandafter\XINT_expr_reverse:_one_or_none\string#1.%
    \else
        \expandafter\XINT_expr_reverse:_at_least_two
    \fi
}%
\def\XINT_expr_reverse:_at_least_two #1^^{\XINT_revwbr_loop {}}%
\def\XINT_expr_reverse:_one_or_none #1%
{%
    \if #1\bgroup\xint_dothis\XINT_expr_reverse:_nutple\fi
    \if #1^\xint_dothis\XINT_expr_reverse:_nil\fi
    \xint_orthat\XINT_expr_reverse:_leaf
}%
\edef\XINT_expr_reverse:_nil #1\xint_bye{\noexpand\fi\space}%
\def\XINT_expr_reverse:_leaf#1\fi #2\xint:#3\xint_bye
   {\fi\xint_gob_andstop_i#2}%
\def\XINT_expr_reverse:_nutple%
{%
    \expandafter\XINT_expr_reverse:_nutple_a\expandafter{\string}%
}%
\def\XINT_expr_reverse:_nutple_a #1^#2\xint:#3\xint_bye
{%
    \fi\expandafter
    {\romannumeral0\XINT_revwbr_loop{}#2\xint:#3\xint_bye}%
}%
\let\XINT_iiexpr_func_reversed\XINT_flexpr_func_reversed
\def\XINT_flexpr_func_if #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:branch{\romannumeral`&&@\calxifNotZero #3}}%
}%
\let\XINT_iiexpr_func_if\XINT_flexpr_func_if
\def\XINT_flexpr_func_ifint #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:branch{\romannumeral`&&@\calxFpifInt #3}}%
}%
\def\XINT_iiexpr_func_ifint #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:branch{\romannumeral`&&@\calxiiifInt #3}}%
}%
\def\XINT_flexpr_func_ifone #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:branch{\romannumeral`&&@\calxFpifOne #3}}%
}%
\def\XINT_iiexpr_func_ifone #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:branch{\romannumeral`&&@\calxiiifOne #3}}%
}%
\def\XINT_flexpr_func_ifsgn #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:branch{\romannumeral`&&@\calxifSgn #3}}%
}%
\let\XINT_iiexpr_func_ifsgn\XINT_flexpr_func_ifsgn
\def\XINT_flexpr_func_nuple #1#2#3{#1#2{{#3}}}%
\let\XINT_iiexpr_func_nuple\XINT_flexpr_func_nuple
\def\XINT_flexpr_func_unpack #1#2%#3%
   {\expandafter#1\expandafter#2\romannumeral0\XINT:NEhook:unpack}%
\let\XINT_iiexpr_func_unpack\XINT_flexpr_func_unpack
\def\XINT_flexpr_func_flat #1#2%#3%
{%
    \expandafter#1\expandafter#2\expanded
    \XINT:NEhook:x:flatten\XINT:expr:flatten
}%
\let\XINT_iiexpr_func_flat\XINT_flexpr_func_flat
\let\XINT:NEhook:x:flatten\empty
\def\XINT_flexpr_func_zip #1#2%#3%
{%
    \expandafter#1\expandafter#2\romannumeral`&&@%
    \XINT:NEhook:x:zip\XINT:expr:zip
}%
\let\XINT_iiexpr_func_zip\XINT_flexpr_func_zip
\let\XINT:NEhook:x:zip\empty
\def\XINT:expr:zip#1{\expandafter{\expanded\XINT_zip_A#1\xint_bye\xint_bye}}%
%    \end{macrocode}
% \subsection{User declared functions}
%\begin{lverb}
% It is possible that
% the author actually does understand at this time the
% \xintNewExpr/\xintdeffunc refactored code and mechanisms for the first time
% since 2014: past evolutions such as the 2018 1.3 refactoring were done a bit
% in the fog (although they did accomplish a crucial step).
%
% The 1.4 version of function and macro definitions is much more powerful than
% 1.3 one. But the mechanisms such as «omit», «abort» and «break()» in iter()
% et al. can't be translated into much else than their actual code when they
% potentially have to apply to non-numeric only context. The 1.4 \xintdeffunc
% is thus apparently able to digest them but its pre-parsing benefits are
% limited compared to simply assigning such parts of an expression to a
% mock-function created by \xintNewFunction (which creates simply a TeX macro
% from its substitution expression in macro parameters and add
% syntactic sugar to let it appear to \xintexpr as a genuine «function»
% although nothing of the syntax has really been pre-parsed.)
%
% At 1.4 fetching the expression up to final semi-colon is done using
% \XINT_expr_fetch_to_semicolon, hence semi-colons arising in the syntax do
% not need to be hidden inside braces.
%\end{lverb}
%
% \localtableofcontents
%
% \subsubsection{\csh{xintdeffunc}, \csh{xintdefiifunc},
% \csh{xintdeffloatfunc}}
%
% \changed[2015/11/12]{1.2c}
%\begin{lverb}
% Note: it is possible to have same name assigned both to a variable
% and a function: things such as add(f(f), f=1..10) are possible.
%\end{lverb}
%
% \changed[2015/11/13]{1.2c}
%\begin{lverb}
% Function names first expanded then detokenized and cleaned of spaces.
%\end{lverb}
%
% \changed[2015/11/21]{1.2e}
%\begin{lverb}
% No \detokenize anymore on the function
% names. And #1(#2)#3=#4 parameter pattern to avoid to have to worry if a : is
% there and it is active.
%\end{lverb}
%
% \changed[2016/02/22]{1.2f}
%\begin{lverb}
% La macro associée à la fonction ne débute
% plus par un \romannumeral, car de toute façon elle est pour emploi dans
% \csname..\endcsname.
%\end{lverb}
%
% \changed[2016/03/08]{1.2f}
%\begin{lverb}
% Comma separated expressions allowed (formerly this required using
% parenthesis \xintdeffunc foo(x,..):=(.., .., ..);
%\end{lverb}
%
% \changed[2018/06/17]{1.3c}
%\begin{lverb}
% Usage of \xintexprSafeCatcodes to be compatible with an active
% semi-colon at time of use; the colon was not a problem (see ##3) already.
%\end{lverb}
%
% \changed{1.3e}
%\begin{lverb}
% \xintdefefunc variant added for functions which will expand
% completely if used with numeric arguments in other function definitions.
% They can't be used for recursive definitions.
%
% Their functionality was merged into \xintdeffunc et al. at 1.4.  The
% original macros were removed at 1.4m.
%\end{lverb}
%
% \changed[2020/01/10]{1.4}
%\begin{lverb}
% Multi-letter variables can be used (with no prior declaration)
%\end{lverb}
%
% \changed[2020/01/11]{1.4}
%\begin{lverb}
% The new internal data model has caused many worries initially (such
% as whether to allow functions with «ople» outputs in contrast to «numbers»
% or «nutples») but in the end all is simpler again and the refactoring of ?
% and ?? in function definitions allows to fuse inert functions (allowing
% recursive definitions) and expanding functions (expanding completely if with
% numeric arguments) into a single entity.
%
% A special situation is with
% functions of no variables. In that case it will be handled as an inert
% entity, else they would not be different from variables.
%
%\end{lverb}
%
% \changed[2020/01/19]{1.4}
%\begin{lverb}
% Addition de la syntaxe déclarative \xintdeffunc foo(a,b,...,*z) = ...;
%
%\end{lverb}
%
% \changed[2022/06/05]{1.4m}
%\begin{lverb}
%   Removal of the \xintdefefunc et al.$@ macros deprecated at 1.4.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_def_deffunc #1#2#3#4#5%
{%
  \def #1##1(##2)##3={%
   \edef\XINT_deffunc_tmpa {##1}%
   \edef\XINT_deffunc_tmpa {\xint_zapspaces_o \XINT_deffunc_tmpa}%
   \def\XINT_deffunc_tmpb {0}%
   \edef\XINT_deffunc_tmpd {##2}%
   \edef\XINT_deffunc_tmpd {\xint_zapspaces_o\XINT_deffunc_tmpd}%
   \def\XINT_deffunc_tmpe {0}%
   \expandafter#5\romannumeral\XINT_expr_fetch_to_semicolon
  }%  end of \xintdeffunc_a definition
  \def#5##1{%
   \def\XINT_deffunc_tmpc{(##1)}%
   \ifnum\xintLength:f:csv{\XINT_deffunc_tmpd}>\xint_c_
     \xintFor ####1 in {\XINT_deffunc_tmpd}\do
      {%
       \xintifForFirst{\let\XINT_deffunc_tmpd\empty}{}%
       \def\XINT_deffunc_tmpf{####1}%
       \if*\xintFirstItem{####1}%
         \xintifForLast
         {%
          \def\XINT_deffunc_tmpe{1}%
          \edef\XINT_deffunc_tmpf{\xintTrim{1}{####1}}%
         }%
         {%
          \edef\XINT_deffunc_tmpf{\xintTrim{1}{####1}}%
          \xintMessage{xintexpr}{Error}
          {Only the last positional argument can be variadic. Trimmed ####1 to
          \XINT_deffunc_tmpf}%
         }%
       \fi
       \XINT_expr_makedummy{\XINT_deffunc_tmpf}%
       \edef\XINT_deffunc_tmpd{\XINT_deffunc_tmpd{\XINT_deffunc_tmpf}}%
       \edef\XINT_deffunc_tmpb {\the\numexpr\XINT_deffunc_tmpb+\xint_c_i}%
       \edef\XINT_deffunc_tmpc {subs(\xint_noxpd\expandafter{\XINT_deffunc_tmpc},%
                             \XINT_deffunc_tmpf=################\XINT_deffunc_tmpb)}%
      }%
   \fi
%    \end{macrocode}
% Logic at |1.4| is simplified here compared to
% earlier releases.
%
% \changed{1.4n}
% Usage of \cs{xintmeaning} wrapper of engine's \cs{meaning}.  See near
% \csbXINT{_NewExpr} for explanations.
%
%    \begin{macrocode}
   \ifcase\XINT_deffunc_tmpb\space
     \expandafter\XINT_expr_defuserfunc_none\csname
   \else
     \expandafter\XINT_expr_defuserfunc\csname
   \fi
           XINT_#2_func_\XINT_deffunc_tmpa\expandafter\endcsname
   \csname XINT_#2_userfunc_\XINT_deffunc_tmpa\expandafter\endcsname
   \expandafter{\XINT_deffunc_tmpa}{#2}%
   \expandafter#3\csname XINT_#2_userfunc_\XINT_deffunc_tmpa\endcsname
                              [\XINT_deffunc_tmpb]{\XINT_deffunc_tmpc}%
   \ifxintverbose\xintMessage {xintexpr}{Info}%
        {Function \XINT_deffunc_tmpa\space for \string\xint #4 parser
         associated to \string\XINT_#2_userfunc_\XINT_deffunc_tmpa\space
         with \ifxintglobaldefs global \fi meaning \expandafter\xintmeaning
         \csname XINT_#2_userfunc_\XINT_deffunc_tmpa\endcsname}%
   \fi
   \xintFor* ####1 in {\XINT_deffunc_tmpd}:{\xintrestorevariablesilently{####1}}%
   \xintexprRestoreCatcodes
  }% end of \xintdeffunc_b definition
}%
\def\xintdefiifunc    {\xintexprSafeCatcodes\xintdefiifunc_a}%
\def\xintdeffloatfunc {\xintexprSafeCatcodes\xintdeffloatfunc_a}%
\XINT_def_deffunc\xintdefiifunc_a   {iiexpr}\XINT_NewIIFunc   {iiexpr}\xintdefiifunc_b
\XINT_def_deffunc\xintdeffloatfunc_a{flexpr}\XINT_NewFloatFunc{floatexpr}\xintdeffloatfunc_b
\def\XINT_expr_defuserfunc_none #1#2#3#4%
{%
    \XINT_global
    \def #1##1##2##3%
    {%
         \expandafter##1\expandafter##2\expanded{%
           {\XINT:NEhook:usernoargfunc\csname XINT_#4_userfunc_#3\endcsname}%
         }%
    }%
}%
\let\XINT:NEhook:usernoargfunc \empty
\def\XINT_expr_defuserfunc #1#2#3#4%
{%
    \if0\XINT_deffunc_tmpe
    \XINT_global
    \def #1##1##2%##3%
    {%
         \expandafter ##1\expandafter##2\expanded\bgroup{\iffalse}\fi
         \XINT:NEhook:userfunc{XINT_#4_userfunc_#3}#2%##3%
    }%
    \else
%    \end{macrocode}
%\begin{lverb}
% Last argument in the call signature is variadic (was prefixed by *).
%\end{lverb}
%    \begin{macrocode}
    \def #1##1{%
    \XINT_global\def #1####1####2%####3%
    {%
         \expandafter ####1\expandafter####2\expanded\bgroup{\iffalse}\fi
         \XINT:NEhook:userfunc:argv{##1}{XINT_#4_userfunc_#3}#2%####3%
    }}\expandafter#1\expandafter{\the\numexpr\XINT_deffunc_tmpb-1}%
    \fi
}%
%    \end{macrocode}
%\begin{lverb}
% Deliberate brace stripping of #3 to reveal the elements of the ople,
% which may be atoms i.e. numeric data such as {1}, or again oples, which
% means that the corresponding item was a nutple, for example it came from
% input syntax such as foo(1, 2, [1, 2], 3), so (up to details of raw
% encoding) {1}{2}{{1}{2}}{3}, which gives 4 braced arguments to macro #2.
%\end{lverb}
%    \begin{macrocode}
\def\XINT:NEhook:userfunc #1#2#3{#2#3\iffalse{{\fi}}}%
%    \end{macrocode}
%\begin{lverb}
% Here #1 indicates the number k-1 of standard positional arguments of
% the call signature, the kth and last one having been declared of variadic
% type. The braces around \xintTrim{#1}{#4} have the effect to gather all
% these remaining elements to provide a single one to the TeX macro.
%
% For example input was foo(1,2,3,4,5) and call signature was foo(a,b,*z).
% Then #4 will fetch {{1}{2}{3}{4}{5}}, with one level of brace removal.
% We will have \xintKeep{2}{{1}{2}{3}{4}{5}} which produces {1}{2}.
% Then {\xintTrim{2}{{1}{2}{3}{4}{5}}} which produces {{3}{4}{5}}.
% So the macro will be used as \macro{1}{2}{{3}{4}{5}} having been
% declared as a macro with 3 arguments.
%
% The above comments were added in June 2021 but the code was done on January
% 19, 2020 for 1.4.
%
% Note on June 10, 2021: at core level \XINT_NewFunc is used which is derived
% from \XINT_NewExpr which has always prepared TeX macros with non-delimited
% parameters.  A refactoring could add a final delimiter, for example \relax.
% The macro with 3 arguments would be defined as \def\macro#1#2#3\relax{...}
% for example.  Then we could transfer to TeX core processing what is achieved
% here via \xintKeep/\xintTrim, of course adding efficiency, via insertion of
% the delimiter.  In the case of foo(1,2,3,4,5) we would have the #3 of
% delimited \macro fetch {3}{4}{5}, no brace removal, which is equivalent to
% current situation fetching {{3}{4}{5}} with brace removal.  But let's see in
% case of foo(1,2,3) then.  This would lead to delimited \macro{1}{2}{3}\relax
% and #3 will fetch {3}, removing one brace pair.  Whereas current
% non-delimited \macro is used as \macro{1}{2}{{3}} from the Keep/Trim, then
% #3 fetches {{3}}, removing one brace pair.  Not the same thing.  So it seems
% there is a stumbling-block here to adopt such an alternative method, in
% relation with brace removal.  Rather relieved in fact, as my head starts
% spinning in ople world.  Seems better to stop thinking about doing something
% like that, and what it would imply as consequences for user declarative
% interface also.  Oples are dangerous to mental health, let's stick with
% one-ples: « named arguments in function body declaration must stand for
% one-ples », even the last one, although a priori it could be envisioned if
% foo has been declared with call signature (x,y,z) and is used with more
% items that z is mapped to the ople of extra elements beyond the first
% two ones.  For my sanity I stick with my January 2020 concept of (x,y,*z)
% which makes z stand for a nutple always and having to be used as such in the
% function body (possibly unpacked there using *z).
%\end{lverb}
%    \begin{macrocode}
\def\XINT:NEhook:userfunc:argv #1#2#3#4%
   {\expandafter#3\expanded{\xintKeep{#1}{#4}{\xintTrim{#1}{#4}}}\iffalse{{\fi}}}%
%    \end{macrocode}
% \subsubsection{\csh{xintdefufunc}, \csh{xintdefiiufunc},
% \csh{xintdeffloatufunc}}
%
%\begin{lverb}
% Added at 1.4
%\end{lverb}
% \changed[2022/05/15]{1.4k}
%\begin{lverb}
% \xintexprRestoreCatcodes was in only one branch of \xint_defufunc_b,
% and as a result sanitization of catcodes via \xintexprSafeCatcodes
% was never reverted. That the
% bug remained unseen and in particular did not break compilation of
% user manual (where the | must be active), was a sort of unhappy miracle
% due to the | ending up recovering its active catcode from some ulterior
% \xintdefiifunc whose Safe/Restore behaved as described in the user manual,
% i.e. it did a restore to the state before the first unpaired Safe, and this
% miraculous recovery happened before breakage had happened, by sheer luck,
% or rather lack of luck, else I would have seen and solved
% the problem two years ago...
%\end{lverb}
%    \begin{macrocode}
\def\XINT_def_defufunc #1#2#3#4#5#6%
{%
  \def #1##1(##2)##3={%
   \edef\XINT_defufunc_tmpa {##1}%
   \edef\XINT_defufunc_tmpa {\xint_zapspaces_o \XINT_defufunc_tmpa}%
   \edef\XINT_defufunc_tmpd {##2}%
   \edef\XINT_defufunc_tmpd {\xint_zapspaces_o\XINT_defufunc_tmpd}%
   \expandafter#5\romannumeral\XINT_expr_fetch_to_semicolon
  }% end of \xint_defufunc_a
  \def#5##1{%
   \def\XINT_defufunc_tmpc{(##1)}%
   \ifnum\xintLength:f:csv{\XINT_defufunc_tmpd}=\xint_c_i
     \expandafter#6%
   \else
     \xintMessage {xintexpr}{ERROR}
        {Universal functions must be functions of one argument only,
         but the declaration of \XINT_defufunc_tmpa\space
         has \xintLength:f:csv{\XINT_defufunc_tmpd} of them. Canceled.}%
     \xintexprRestoreCatcodes
   \fi
   }% end of \xint_defufunc_b
  \def #6{%
   \XINT_expr_makedummy{\XINT_defufunc_tmpd}%
   \edef\XINT_defufunc_tmpc {subs(\xint_noxpd\expandafter{\XINT_defufunc_tmpc},%
                             \XINT_defufunc_tmpd=########1)}%
   \expandafter\XINT_expr_defuserufunc
   \csname XINT_#2_func_\XINT_defufunc_tmpa\expandafter\endcsname
   \csname XINT_#2_userufunc_\XINT_defufunc_tmpa\expandafter\endcsname
   \expandafter{\XINT_defufunc_tmpa}{#2}%
   \expandafter#3\csname XINT_#2_userufunc_\XINT_defufunc_tmpa\endcsname
                              [1]{\XINT_defufunc_tmpc}%
   \ifxintverbose\xintMessage {xintexpr}{Info}%
        {Universal function \XINT_defufunc_tmpa\space for \string\xint #4 parser
         associated to \string\XINT_#2_userufunc_\XINT_defufunc_tmpa\space
         with \ifxintglobaldefs global \fi meaning \expandafter\xintmeaning
         \csname XINT_#2_userufunc_\XINT_defufunc_tmpa\endcsname}%
   \fi
   \xintexprRestoreCatcodes
  }% end of \xint_defufunc_c
}%
\def\xintdefiiufunc    {\xintexprSafeCatcodes\xintdefiiufunc_a}%
\def\xintdeffloatufunc {\xintexprSafeCatcodes\xintdeffloatufunc_a}%
\XINT_def_defufunc\xintdefiiufunc_a   {iiexpr}\XINT_NewIIFunc   {iiexpr}%
          \xintdefiiufunc_b\xintdefiiufunc_c
\XINT_def_defufunc\xintdeffloatufunc_a{flexpr}\XINT_NewFloatFunc{floatexpr}%
          \xintdeffloatufunc_b\xintdeffloatufunc_c
\def\XINT_expr_defuserufunc #1#2#3#4%
{%
    \XINT_global
    \def #1##1##2%##3%
    {%
         \expandafter ##1\expandafter##2\expanded
         \XINT:NEhook:userufunc{XINT_#4_userufunc_#3}#2%##3%
    }%
}%
\def\XINT:NEhook:userufunc #1{\XINT:expr:mapwithin}%
%    \end{macrocode}
%
% \subsubsection{\csh{xintunassignexprfunc},
%                \csh{xintunassigniiexprfunc}, \csh{xintunassignfloatexprfunc}}
% See the \csbxint{unassignvar} for the embarrassing explanations why I had
% not done that earlier. A bit lazy here, no warning if undefining something
% not defined, and attention no precaution respective built-in functions.
%
%    \begin{macrocode}
\def\XINT_def_unassignfunc #1{\expandafter\def\csname xintunassign#1func\endcsname ##1{%
   \edef\XINT_unfunc_tmpa{##1}%
   \edef\XINT_unfunc_tmpa {\xint_zapspaces_o\XINT_unfunc_tmpa}%
   \XINT_global\expandafter
     \let\csname XINT_#1_func_\XINT_unfunc_tmpa\endcsname\XINT_undefined
   \XINT_global\expandafter
     \let\csname XINT_#1_userfunc_\XINT_unfunc_tmpa\endcsname\XINT_undefined
   \XINT_global\expandafter
     \let\csname XINT_#1_userufunc_\XINT_unfunc_tmpa\endcsname\XINT_undefined
   \ifxintverbose\xintMessage {xintexpr}{Info}%
    {Function \XINT_unfunc_tmpa\space for \string\xint #1 parser now
     \ifxintglobaldefs globally \fi undefined.}%
   \fi}}%
\XINT_def_unassignfunc{iiexpr}\XINT_def_unassignfunc{floatexpr}%
%    \end{macrocode}
% \subsubsection{\csh{xintNewFunction}}
%\begin{lverb}
% 1.2h (2016/11/20). Syntax is \xintNewFunction{<name>}[nb of
% arguments]{expression with #1, #2,... as in \xintNewExpr}. This defines
% a function for all three parsers but the expression parsing is delayed until
% function execution. Hence the expression admits all constructs, contrarily
% to \xintNewExpr or \xintdeffunc.
%
% As the letters used for variables in \xintdeffunc, #1, #2, etc... can not
% stand for non numeric «oples», because at time of function call f(a, b, c,
% ...) how to decide if #1 stands for a or a, b etc... ? Or course «a» can be
% packed and thus the macro function can handle #1 as a «nutple» and for this
% be defined with the * unpacking operator being applied to it.
%\end{lverb}
%    \begin{macrocode}
\def\xintNewFunction #1#2[#3]#4%
{%
  \edef\XINT_newfunc_tmpa {#1}%
  \edef\XINT_newfunc_tmpa {\xint_zapspaces_o \XINT_newfunc_tmpa}%
  \def\XINT_newfunc_tmpb ##1##2##3##4##5##6##7##8##9{#4}%
  \begingroup
    \ifcase #3\relax
        \toks0{}%
    \or \toks0{##1}%
    \or \toks0{##1##2}%
    \or \toks0{##1##2##3}%
    \or \toks0{##1##2##3##4}%
    \or \toks0{##1##2##3##4##5}%
    \or \toks0{##1##2##3##4##5##6}%
    \or \toks0{##1##2##3##4##5##6##7}%
    \or \toks0{##1##2##3##4##5##6##7##8}%
    \else \toks0{##1##2##3##4##5##6##7##8##9}%
    \fi
    \expandafter
  \endgroup\expandafter
  \XINT_global\expandafter
  \def\csname XINT_expr_macrofunc_\XINT_newfunc_tmpa\expandafter\endcsname
  \the\toks0\expandafter{\XINT_newfunc_tmpb
    {\XINTfstop.{{##1}}}{\XINTfstop.{{##2}}}{\XINTfstop.{{##3}}}%
    {\XINTfstop.{{##4}}}{\XINTfstop.{{##5}}}{\XINTfstop.{{##6}}}%
    {\XINTfstop.{{##7}}}{\XINTfstop.{{##8}}}{\XINTfstop.{{##9}}}}%
  \expandafter\XINT_expr_newfunction
    \csname XINT_expr_func_\XINT_newfunc_tmpa\expandafter\endcsname
    \expandafter{\XINT_newfunc_tmpa}\xintbareeval
  \expandafter\XINT_expr_newfunction
    \csname XINT_iiexpr_func_\XINT_newfunc_tmpa\expandafter\endcsname
    \expandafter{\XINT_newfunc_tmpa}\xintbareiieval
  \expandafter\XINT_expr_newfunction
    \csname XINT_flexpr_func_\XINT_newfunc_tmpa\expandafter\endcsname
    \expandafter{\XINT_newfunc_tmpa}\xintbarefloateval
  \ifxintverbose
    \xintMessage {xintexpr}{Info}%
        {Function \XINT_newfunc_tmpa\space for the expression parsers is
         associated to \string\XINT_expr_macrofunc_\XINT_newfunc_tmpa\space
         with \ifxintglobaldefs global \fi meaning \expandafter\xintmeaning
         \csname XINT_expr_macrofunc_\XINT_newfunc_tmpa\endcsname}%
  \fi
}%
\def\XINT_expr_newfunction #1#2#3%
{%
    \XINT_global
    \def#1##1##2##3%
      {\expandafter ##1\expandafter ##2%
       \romannumeral0\XINT:NEhook:macrofunc
       #3{\csname XINT_expr_macrofunc_#2\endcsname##3}\relax
      }%
}%
\let\XINT:NEhook:macrofunc\empty
%    \end{macrocode}
% \subsubsection{Mysterious stuff}
%
% There was an |\xintNewExpr| already in 1.07 from May 2013, which was
% modified in September 2013 to work with the \# macro parameter character,
% and then refactored into a more powerful version in June 2014 for 1.1
% release of 2014/10/28.
%
% It is always too soon to try to comment and explain. In brief, this attempts
% to hack into the \emph{purely numeric} |\xintexpr| parsers to transform them
% into \emph{symbolic} parsers, allowing to do once and for all the parsing
% job and inherit a gigantic nested macro. Originally only f-expandable
% nesting. The initial motivation was that the |\csname| encapsulation impacted
% the string pool memory. Later this work proved to be the basis to provide
% support for implementing
% user-defined functions and it is now its main purpose.
%
% Deep refactorings happened at 1.3 and 1.4.
%
% At 1.3 the crucial idea of the «hook» macros was introduced, reducing
% considerably the preparatory work done by |\xintNewExpr|.
%
% At 1.4 further considerable simplifications happened, and it is possible
% that the author currently does at long last understand the code!
%
% The 1.3 code had serious complications with trying
% to identify would-be «list» arguments, distinguishing them from «single»
% arguments (things like parsing |#2+[[#1..[#3]..#4][#5:#6]]*#7| and convert
% it to a single nested f-exandable macro...)
%
% The conversion at 1.4 is both more powerful and simpler, due in part to the
% new storage model which from |\csname| encapsulated comma separated values
% up to 1.3f became simply a braced list of braced values, and also crucially
% due to the possibilities opened up by usage of |\expanded| primitive.
%
%    \begin{macrocode}
\catcode`~ 12
\def\XINT:NE:hastilde#1~#2#3\relax{\unless\if !#21\fi}%
\def\XINT:NE:hashash#1{%
\def\XINT:NE:hashash##1#1##2##3\relax{\unless\if !##21\fi}%
}\expandafter\XINT:NE:hashash\string#%
\def\XINT:NE:unpack #1{%
\def\XINT:NE:unpack ##1%
{%
    \if0\XINT:NE:hastilde ##1~!\relax
        \XINT:NE:hashash  ##1#1!\relax 0\else
        \expandafter\XINT:NE:unpack:p\fi
    \xint_stop_atfirstofone{##1}%
}}\expandafter\XINT:NE:unpack\string#%
\def\XINT:NE:unpack:p#1#2%
    {{~romannumeral0~expandafter~xint_stop_atfirstofone~expanded{#2}}}%
\def\XINT:NE:f:one:from:one #1{%
\def\XINT:NE:f:one:from:one ##1%
{%
    \if0\XINT:NE:hastilde ##1~!\relax
        \XINT:NE:hashash  ##1#1!\relax 0\else
        \xint_dothis\XINT:NE:f:one:from:one_a\fi
    \xint_orthat\XINT:NE:f:one:from:one_b
    ##1&&A%
}}\expandafter\XINT:NE:f:one:from:one\string#%
\def\XINT:NE:f:one:from:one_a\romannumeral`&&@#1#2&&A%
{%
    \expandafter{\detokenize{\expandafter#1}#2}%
}%
\def\XINT:NE:f:one:from:one_b#1{%
\def\XINT:NE:f:one:from:one_b\romannumeral`&&@##1##2&&A%
{%
    \expandafter{\romannumeral`&&@%
        \if0\XINT:NE:hastilde ##2~!\relax
            \XINT:NE:hashash  ##2#1!\relax 0\else
        \expandafter\string\fi
    ##1{##2}}%
}}\expandafter\XINT:NE:f:one:from:one_b\string#%
\def\XINT:NE:f:one:from:one:direct #1#2{\XINT:NE:f:one:from:one:direct_a #2&&A{#1}}%
\def\XINT:NE:f:one:from:one:direct_a #1#2&&A#3%
{%
    \if ###1\xint_dothis {\detokenize{#3}}\fi
    \if  ~#1\xint_dothis {\detokenize{#3}}\fi
    \xint_orthat {#3}{#1#2}%
}%
\def\XINT:NE:f:one:from:two #1{%
\def\XINT:NE:f:one:from:two ##1%
{%
    \if0\XINT:NE:hastilde ##1~!\relax
        \XINT:NE:hashash  ##1#1!\relax 0\else
        \xint_dothis\XINT:NE:f:one:from:two_a\fi
    \xint_orthat\XINT:NE:f:one:from:two_b ##1&&A%
}}\expandafter\XINT:NE:f:one:from:two\string#%
\def\XINT:NE:f:one:from:two_a\romannumeral`&&@#1#2&&A%
{%
    \expandafter{\detokenize{\expandafter#1\expanded}{#2}}%
}%
\def\XINT:NE:f:one:from:two_b#1{%
\def\XINT:NE:f:one:from:two_b\romannumeral`&&@##1##2##3&&A%
{%
    \expandafter{\romannumeral`&&@%
        \if0\XINT:NE:hastilde ##2##3~!\relax
            \XINT:NE:hashash  ##2##3#1!\relax 0\else
        \expandafter\string\fi
    ##1{##2}{##3}}%
}}\expandafter\XINT:NE:f:one:from:two_b\string#%
\def\XINT:NE:f:one:from:two:direct #1#2#3{\XINT:NE:two_fork #2&&A#3&&A#1{#2}{#3}}%
\def\XINT:NE:two_fork #1#2&&A#3#4&&A{\XINT:NE:two_fork_nn#1#3}%
\def\XINT:NE:two_fork_nn #1#2%
{%
    \if #1##\xint_dothis\string\fi
    \if  #1~\xint_dothis\string\fi
    \if #2##\xint_dothis\string\fi
    \if  #2~\xint_dothis\string\fi
    \xint_orthat{}%
}%
\def\XINT:NE:f:one:and:opt:direct#1{%
\def\XINT:NE:f:one:and:opt:direct##1!%
{%
    \if0\XINT:NE:hastilde ##1~!\relax
        \XINT:NE:hashash  ##1#1!\relax 0\else
        \xint_dothis\XINT:NE:f:one:and:opt_a\fi
    \xint_orthat\XINT:NE:f:one:and:opt_b ##1&&A%
}}\expandafter\XINT:NE:f:one:and:opt:direct\string#%
\def\XINT:NE:f:one:and:opt_a #1#2&&A#3#4%
{%
    \detokenize{\romannumeral-`0\expandafter#1\expanded{#2}$XINT_expr_exclam#3#4}%$
}%
\def\XINT:NE:f:one:and:opt_b\XINT:expr:f:one:and:opt #1#2#3&&A#4#5%
{%
    \if\relax#3\relax\expandafter\xint_firstoftwo\else
                     \expandafter\xint_secondoftwo\fi
    {\XINT:NE:f:one:from:one:direct#4}%
    {\expandafter\XINT:NE:f:onewithopttoone\expandafter#5%
        \expanded{{\XINT:NE:f:one:from:one:direct\calxListItemToNum{#2}}}}%
    {#1}%
}%
\def\XINT:NE:f:onewithopttoone#1#2#3{\XINT:NE:two_fork #2&&A#3&&A#1[#2]{#3}}%
\def\XINT:NE:f:tacitzeroifone:direct#1{%
\def\XINT:NE:f:tacitzeroifone:direct##1!%
{%
    \if0\XINT:NE:hastilde ##1~!\relax
        \XINT:NE:hashash  ##1#1!\relax 0\else
        \xint_dothis\XINT:NE:f:one:and:opt_a\fi
    \xint_orthat\XINT:NE:f:tacitzeroifone_b ##1&&A%
}}\expandafter\XINT:NE:f:tacitzeroifone:direct\string#%
\def\XINT:NE:f:tacitzeroifone_b\XINT:expr:f:tacitzeroifone #1#2#3&&A#4#5%
{%
    \if\relax#3\relax\expandafter\xint_firstoftwo\else
                      \expandafter\xint_secondoftwo\fi
    {\XINT:NE:f:one:from:two:direct#4{0}}%
    {\expandafter\XINT:NE:f:one:from:two:direct\expandafter#5%
        \expanded{{\XINT:NE:f:one:from:one:direct\calxListItemToNum{#2}}}}%
    {#1}%
}%
\def\XINT:NE:f:iitacitzeroifone:direct#1{%
\def\XINT:NE:f:iitacitzeroifone:direct##1!%
{%
    \if0\XINT:NE:hastilde ##1~!\relax
        \XINT:NE:hashash  ##1#1!\relax 0\else
        \xint_dothis\XINT:NE:f:iitacitzeroifone_a\fi
    \xint_orthat\XINT:NE:f:iitacitzeroifone_b ##1&&A%
}}\expandafter\XINT:NE:f:iitacitzeroifone:direct\string#%
\def\XINT:NE:f:iitacitzeroifone_a #1#2&&A#3%
{%
    \detokenize
    {\romannumeral`$XINT_expr_null\expandafter#1\expanded{#2}$XINT_expr_exclam#3}%
}%
\def\XINT:NE:f:iitacitzeroifone_b\XINT:expr:f:iitacitzeroifone #1#2#3&&A#4%
{%
    \if\relax#3\relax\expandafter\xint_firstoftwo\else
                      \expandafter\xint_secondoftwo\fi
    {\XINT:NE:f:one:from:two:direct#4{0[0]}}%
    {\XINT:NE:f:one:from:two:direct#4{#2}}%
    {#1}%
}%
\def\XINT:NE:x:one:from:two #1#2#3{\XINT:NE:x:one:from:two_fork #2&&A#3&&A#1{#2}{#3}}%
\def\XINT:NE:x:one:from:two_fork #1{%
\def\XINT:NE:x:one:from:two_fork ##1##2&&A##3##4&&A%
{%
    \if0\XINT:NE:hastilde ##1##3~!\relax\XINT:NE:hashash ##1##3#1!\relax 0%
    \else
        \expandafter\XINT:NE:x:one:from:two:p
    \fi
}}\expandafter\XINT:NE:x:one:from:two_fork\string#%
\def\XINT:NE:x:one:from:two:p #1#2#3%
   {~expanded{\detokenize{\expandafter#1}~expanded{{#2}{#3}}}}%
\def\XINT:NE:x:listsel #1{%
\def\XINT:NE:x:listsel ##1##2&%
{%
    \if0\expandafter\XINT:NE:hastilde\detokenize{##2}~!\relax
        \expandafter\XINT:NE:hashash\detokenize{##2}#1!\relax 0%
    \else
        \expandafter\XINT:NE:x:listsel:p
    \fi
    ##1##2&%
}}\expandafter\XINT:NE:x:listsel\string#%
\def\XINT:NE:x:listsel:p #1#2_#3&(#4%
{%
    \detokenize{\expanded\XINT:expr:ListSel{{#3}{#4}}}%
}%
\def\XINT:expr:ListSel{\expandafter\XINT:expr:ListSel_i\expanded}%
\def\XINT:expr:ListSel_i #1#2{{\XINT_ListSel_top #2_#1&({#2}}}%
\def\XINT:NE:f:reverse #1{%
\def\XINT:NE:f:reverse ##1^%
{%
    \if0\expandafter\XINT:NE:hastilde\detokenize\expandafter{\xint_gobble_i##1}~!\relax
        \expandafter\XINT:NE:hashash\detokenize{##1}#1!\relax 0%
    \else
        \expandafter\XINT:NE:f:reverse:p
    \fi
    ##1^%
}}\expandafter\XINT:NE:f:reverse\string#%
\def\XINT:NE:f:reverse:p #1^#2\xint_bye
{%
    \expandafter\XINT:NE:f:reverse:p_i\expandafter{\xint_gobble_i#1}%
}%
\def\XINT:NE:f:reverse:p_i #1%
{%
    \detokenize{\romannumeral0\XINT:expr:f:reverse{{#1}}}%
}%
\def\XINT:expr:f:reverse{\expandafter\XINT:expr:f:reverse_i\expanded}%
\def\XINT:expr:f:reverse_i #1%
{%
    \XINT_expr_reverse #1^^#1\xint:\xint:\xint:\xint:
                         \xint:\xint:\xint:\xint:\xint_bye
}%
\def\XINT:NE:f:from:delim:u #1{%
\def\XINT:NE:f:from:delim:u ##1##2^%
{%
    \if0\expandafter\XINT:NE:hastilde\detokenize{##2}~!\relax
        \expandafter\XINT:NE:hashash\detokenize{##2}#1!\relax 0%
        \xint_afterfi{\expandafter\XINT_fooof_checkifnumber\expandafter##1\string}%
    \else
        \xint_afterfi{\XINT:NE:f:from:delim:u:p##1\empty}%
    \fi
    ##2^%
}}\expandafter\XINT:NE:f:from:delim:u\string#%
\def\XINT:NE:f:from:delim:u:p #1#2^%
{%
    \detokenize
    {\expandafter\XINT:fooof:checkifnumber\expandafter#1}~expanded{#2}$XINT_expr_caret%$
}%
\def\XINT:fooof:checkifnumber#1{\expandafter\XINT_fooof_checkifnumber\expandafter#1\string}%
\def\XINT:NE:f:LFL#1#2{\expandafter\XINT:NE:f:LFL_a\expandafter#1#2\XINT:NE:f:LFL_a}%
\def\XINT:NE:f:LFL_a#1#2%
{%
    \if#2i\else\expandafter\XINT:NE:f:LFL_p
    \fi #1%
}%
\def\XINT:NE:r:check#1{%
\def\XINT:NE:r:check##1\XINT:NE:f:LFL_a
{%
    \if0\expandafter\XINT:NE:hastilde\detokenize{##1}~!\relax%
        \expandafter\XINT:NE:hashash\detokenize{##1}#1!\relax 0%
    \else
        \expandafter\XINT:NE:r:check:p
    \fi
    1\expandafter{\romannumeral\XINT:NEsaved:r:check##1}%
}}\expandafter\XINT:NE:r:check\string#%
\def\XINT:NE:r:check:p 1\expandafter#1{\XINT:NE:r:check:p_i#1}%
\def\XINT:NE:r:check:p_i\romannumeral\XINT:NEsaved:r:check{\XINT:NE:r:check:p_ii\empty}%
\def\XINT:NE:r:check:p_ii#1^%
{%
    5~expanded{{~romannumeral~XINT:NEsaved:r:check#1$XINT_expr_caret}}%$
}%
\def\XINT:NE:f:LFL_p#1%
{%
    \detokenize{\romannumeral`$XINT_expr_null\expandafter#1}%$
}%
\catcode`- 11
\def\XINT:NE:exec_? #1#2%
{%
    \XINT:NE:exec_?_b #2&&A#1{#2}%
}%
%    \end{macrocode}
% \odef\MakePrivateLetters{\MakePrivateLetters\catcode`- 11 }\FixInterMacrocodeVspace
%    \begin{macrocode}
\def\XINT:NE:exec_?_b #1{%
\def\XINT:NE:exec_?_b ##1&&A%
{%
    \if0\XINT:NE:hastilde ##1~!\relax
        \XINT:NE:hashash  ##1#1!\relax 0%
    \xint_dothis\XINT:NE:exec_?:x\fi
    \xint_orthat\XINT:NE:exec_?:p
}}\expandafter\XINT:NE:exec_?_b\string#%
\def\XINT:NE:exec_?:x #1#2#3%
{%
    \expandafter\XINT_expr_check-_after?\expandafter#1%
    \romannumeral`&&@\expandafter\XINT_expr_getnext\romannumeral0\CALX_ifnz#3%
}%
\def\XINT:NE:exec_?:p #1#2#3#4#5%
{%
    \csname XINT_expr_func_*If\expandafter\endcsname
    \romannumeral`&&@#2\XINTfstop.{#3},[#4],[#5])%
}%
\expandafter\def\csname XINT_expr_func_*If\endcsname #1#2#3%
{%
    #1#2{~expanded{~calxifNotZero#3}}%
}%
\def\XINT:NE:exec_?? #1#2#3%
{%
    \XINT:NE:exec_??_b #2&&A#1{#2}%
}%
\def\XINT:NE:exec_??_b #1{%
\def\XINT:NE:exec_??_b ##1&&A%
{%
    \if0\XINT:NE:hastilde ##1~!\relax
        \XINT:NE:hashash  ##1#1!\relax 0%
    \xint_dothis\XINT:NE:exec_??:x\fi
    \xint_orthat\XINT:NE:exec_??:p
}}\expandafter\XINT:NE:exec_??_b\string#%
\def\XINT:NE:exec_??:x #1#2#3%
{%
    \expandafter\XINT_expr_check-_after?\expandafter#1%
    \romannumeral`&&@\expandafter\XINT_expr_getnext\romannumeral0\CALX_ifsgn#3%
}%
\def\XINT:NE:exec_??:p #1#2#3#4#5#6%
{%
    \csname XINT_expr_func_*IfSgn\expandafter\endcsname
    \romannumeral`&&@#2\XINTfstop.{#3},[#4],[#5],[#6])%
}%
\expandafter\def\csname XINT_expr_func_*IfSgn\endcsname #1#2#3%
{%
    #1#2{~expanded{~calxifSgn#3}}%
}%
\catcode`- 12
%    \end{macrocode}
% \let\MakePrivateLetters\xintexprMakePrivateLetters\FixInterMacrocodeVspace
%    \begin{macrocode}
\def\XINT:NE:branch #1%
{%
    \if0\XINT:NE:hastilde #1~!\relax 0\else
        \xint_dothis\XINT:NE:branch_a\fi
    \xint_orthat\XINT:NE:branch_b #1&&A%
}%
\def\XINT:NE:branch_a\romannumeral`&&@#1#2&&A%
{%
    \expandafter{\detokenize{\expandafter#1\expanded}{#2}}%
}%
\def\XINT:NE:branch_b#1{%
\def\XINT:NE:branch_b\romannumeral`&&@##1##2##3&&A%
{%
    \expandafter{\romannumeral`&&@%
        \if0\XINT:NE:hastilde ##2~!\relax
            \XINT:NE:hashash  ##2#1!\relax 0\else
        \expandafter\string\fi
    ##1{##2}##3}%
}}\expandafter\XINT:NE:branch_b\string#%
\def\XINT:NE:seqx#1{%
\def\XINT:NE:seqx\XINT_allexpr_seqx##1##2%
{%
    \if 0\expandafter\XINT:NE:hastilde\detokenize{##2}~!\relax
         \expandafter\XINT:NE:hashash \detokenize{##2}#1!\relax 0%
    \else
      \expandafter\XINT:NE:seqx:p
    \fi \XINT_allexpr_seqx{##1}{##2}%
}}\expandafter\XINT:NE:seqx\string#%
\def\XINT:NE:seqx:p\XINT_allexpr_seqx #1#2#3#4%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded {%
    {%
        \detokenize
        {%
           \expanded\bgroup
           \expanded
           {\xint_noxpd{\XINT_expr_seq:_b{#1#4\relax $XINT_expr_exclam #3}}%
             #2$XINT_expr_caret}%
        }%
    }%
    \expandafter}\romannumeral`&&@\XINT_expr_getop
}%
\def\XINT:NE:opx#1{%
\def\XINT:NE:opx\XINT_allexpr_opx ##1##2##3##4%##5##6##7##8%
{%
    \if 0\expandafter\XINT:NE:hastilde\detokenize{##4}~!\relax
         \expandafter\XINT:NE:hashash \detokenize{##4}#1!\relax 0%
    \else
      \expandafter\XINT:NE:opx:p
    \fi \XINT_allexpr_opx ##1{##2}{##3}{##4}% en fait ##2 = \xint_c_, ##3 = \relax
}}\expandafter\XINT:NE:opx\string#%
\def\XINT:NE:opx:p\XINT_allexpr_opx #1#2#3#4#5#6#7#8%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded {%
    {%
        \detokenize
        {%
            \expanded\bgroup
            \expanded{\xint_noxpd{\XINT_expr_iter:_b
               {#1\expandafter\XINT_allexpr_opx_ifnotomitted
                  \romannumeral0#1#6\relax#7@\relax $XINT_expr_exclam #5}}%
                      #4$XINT_expr_caret$XINT_expr_tilde{{#8}}}%$
        }%
    }%
    \expandafter}\romannumeral`&&@\XINT_expr_getop
}%
\def\XINT:NE:iter{\expandafter\XINT:NE:itery\expandafter}%
\def\XINT:NE:itery#1{%
\def\XINT:NE:itery\XINT_expr_itery##1##2%
{%
    \if 0\expandafter\XINT:NE:hastilde\detokenize{##1##2}~!\relax
         \expandafter\XINT:NE:hashash \detokenize{##1##2}#1!\relax 0%
    \else
      \expandafter\XINT:NE:itery:p
    \fi \XINT_expr_itery{##1}{##2}%
}}\expandafter\XINT:NE:itery\string#%
\def\XINT:NE:itery:p\XINT_expr_itery #1#2#3#4#5%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded {%
    {%
        \detokenize
        {%
          \expanded\bgroup
          \expanded{\xint_noxpd{\XINT_expr_iter:_b {#5#4\relax $XINT_expr_exclam #3}}%
                    #1$XINT_expr_caret$XINT_expr_tilde{#2}}%$
        }%
    }%
    \expandafter}\romannumeral`&&@\XINT_expr_getop
}%
\def\XINT:NE:rseq{\expandafter\XINT:NE:rseqy\expandafter}%
\def\XINT:NE:rseqy#1{%
\def\XINT:NE:rseqy\XINT_expr_rseqy##1##2%
{%
    \if 0\expandafter\XINT:NE:hastilde\detokenize{##1##2}~!\relax
         \expandafter\XINT:NE:hashash \detokenize{##1##2}#1!\relax 0%
    \else
      \expandafter\XINT:NE:rseqy:p
    \fi \XINT_expr_rseqy{##1}{##2}%
}}\expandafter\XINT:NE:rseqy\string#%
\def\XINT:NE:rseqy:p\XINT_expr_rseqy #1#2#3#4#5%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded {%
    {%
        \detokenize
        {%
          \expanded\bgroup
          \expanded{#2\xint_noxpd{\XINT_expr_rseq:_b {#5#4\relax $XINT_expr_exclam #3}}%
                      #1$XINT_expr_caret$XINT_expr_tilde{#2}}%$
         }%
    }%
    \expandafter}\romannumeral`&&@\XINT_expr_getop
}%
\def\XINT:NE:iterr{\expandafter\XINT:NE:iterry\expandafter}%
\def\XINT:NE:iterry#1{%
\def\XINT:NE:iterry\XINT_expr_iterry##1##2%
{%
    \if 0\expandafter\XINT:NE:hastilde\detokenize{##1##2}~!\relax
         \expandafter\XINT:NE:hashash \detokenize{##1##2}#1!\relax 0%
    \else
      \expandafter\XINT:NE:iterry:p
    \fi \XINT_expr_iterry{##1}{##2}%
}}\expandafter\XINT:NE:iterry\string#%
\def\XINT:NE:iterry:p\XINT_expr_iterry #1#2#3#4#5%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded {%
    {%
        \detokenize
        {%
          \expanded\bgroup
          \expanded{\xint_noxpd{\XINT_expr_iterr:_b {#5#4\relax $XINT_expr_exclam #3}}%
                    #1$XINT_expr_caret$XINT_expr_tilde #20$XINT_expr_qmark}%
        }%
    }%
    \expandafter}\romannumeral`&&@\XINT_expr_getop
}%
\def\XINT:NE:rrseq{\expandafter\XINT:NE:rrseqy\expandafter}%
\def\XINT:NE:rrseqy#1{%
\def\XINT:NE:rrseqy\XINT_expr_rrseqy##1##2%
{%
    \if 0\expandafter\XINT:NE:hastilde\detokenize{##1##2}~!\relax
         \expandafter\XINT:NE:hashash \detokenize{##1##2}#1!\relax 0%
    \else
      \expandafter\XINT:NE:rrseqy:p
    \fi \XINT_expr_rrseqy{##1}{##2}%
}}\expandafter\XINT:NE:rrseqy\string#%
\def\XINT:NE:rrseqy:p\XINT_expr_rrseqy #1#2#3#4#5#6%
{%
    \expandafter\XINT_expr_put_op_first
    \expanded {%
    {%
        \detokenize
        {%
           \expanded\bgroup
           \expanded{#2\xint_noxpd{\XINT_expr_rrseq:_b {#6#5\relax $XINT_expr_exclam #4}}%
                        #1$XINT_expr_caret$XINT_expr_tilde #30$XINT_expr_qmark}%
         }%
    }%
    \expandafter}\romannumeral`&&@\XINT_expr_getop
}%
\def\XINT:NE:x:toblist#1{%
\def\XINT:NE:x:toblist\XINT:expr:toblistwith##1##2%
{%
    \if 0\expandafter\XINT:NE:hastilde\detokenize{##2}~!\relax
         \expandafter\XINT:NE:hashash \detokenize{##2}#1!\relax 0%
    \else
      \expandafter\XINT:NE:x:toblist:p
    \fi \XINT:expr:toblistwith{##1}{##2}%
}}\expandafter\XINT:NE:x:toblist\string#%
\def\XINT:NE:x:toblist:p\XINT:expr:toblistwith #1#2{{\XINTfstop.{#2}}}%
\def\XINT:NE:x:flatten#1{%
\def\XINT:NE:x:flatten\XINT:expr:flatten##1%
{%
    \if 0\expandafter\XINT:NE:hastilde\detokenize{##1}~!\relax
         \expandafter\XINT:NE:hashash \detokenize{##1}#1!\relax 0%
    \else
      \expandafter\XINT:NE:x:flatten:p
    \fi \XINT:expr:flatten{##1}%
}}\expandafter\XINT:NE:x:flatten\string#%
\def\XINT:NE:x:flatten:p\XINT:expr:flatten #1%
{%
    {{%
     \detokenize
     {%
         \expandafter\XINT:expr:flatten_checkempty
         \detokenize\expandafter{\expanded{#1}}$XINT_expr_caret%$
     }%
    }}%
}%
\def\XINT:NE:x:zip#1{%
\def\XINT:NE:x:zip\XINT:expr:zip##1%
{%
    \if 0\expandafter\XINT:NE:hastilde\detokenize{##1}~!\relax
         \expandafter\XINT:NE:hashash \detokenize{##1}#1!\relax 0%
    \else
      \expandafter\XINT:NE:x:zip:p
    \fi \XINT:expr:zip{##1}%
}}\expandafter\XINT:NE:x:zip\string#%
\def\XINT:NE:x:zip:p\XINT:expr:zip #1%
{%
    \expandafter{%
     \detokenize
     {%
        \expanded\expandafter\XINT_zip_A\expanded{#1}\xint_bye\xint_bye
     }%
    }%
}%
\def\XINT:NE:x:mapwithin#1{%
\def\XINT:NE:x:mapwithin\XINT:expr:mapwithin ##1##2%
{%
    \if 0\expandafter\XINT:NE:hastilde\detokenize{##2}~!\relax
         \expandafter\XINT:NE:hashash \detokenize{##2}#1!\relax 0%
    \else
      \expandafter\XINT:NE:x:mapwithin:p
    \fi \XINT:expr:mapwithin {##1}{##2}%
}}\expandafter\XINT:NE:x:mapwithin\string#%
\def\XINT:NE:x:mapwithin:p \XINT:expr:mapwithin  #1#2%
{%
    {{%
     \detokenize
     {%
%    \end{macrocode}
% Attention (2022/06/10) I do not remember why I left these two commented
% lines which docstrip will not remove, I hope this is not a forgotten
% left=over from some debugging session.
%    \begin{macrocode}
%%      \expanded
%%      {%
         \expandafter\XINT:expr:mapwithin_checkempty
         \expanded{\noexpand#1$XINT_expr_exclam\expandafter}%$
         \detokenize\expandafter{\expanded{#2}}$XINT_expr_caret%$
%    \end{macrocode}
% This is is the matching one.
%    \begin{macrocode}
%%      }%
     }%
    }}%
}%
\def\XINT:NE:x:ndmapx#1{%
\def\XINT:NE:x:ndmapx\XINT_allexpr_ndmapx_a ##1##2^%
{%
    \if 0\expandafter\XINT:NE:hastilde\detokenize{##2}~!\relax
         \expandafter\XINT:NE:hashash \detokenize{##2}#1!\relax 0%
    \else
      \expandafter\XINT:NE:x:ndmapx:p
    \fi \XINT_allexpr_ndmapx_a ##1##2^%
}}\expandafter\XINT:NE:x:ndmapx\string#%
\def\XINT:NE:x:ndmapx:p #1#2#3^\relax
{%
    \detokenize
    {%
      \expanded{%
      \expandafter#1\expandafter#2\expanded{#3}$XINT_expr_caret\relax %$
               }%
    }%
}%
%    \end{macrocode}
%\begin{lverb}
% Attention here that user function
% names may contain digits, so we don't use a \detokenize or ~ approach.
%
% This syntax means that a function defined by \xintdeffunc never expands
% when used in another definition, so it can implement recursive definitions.
%
% \XINT:NE:userefunc et al. added at 1.3e.
%
% I added at \xintdefefunc, \xintdefiiefunc, \xintdeffloatefunc at 1.3e to on
% the contrary expand if possible (i.e. if used only with numeric arguments)
% in another definition.
%
% The \XINTusefunc
% uses \expanded. Its ancestor \xintExpandArgs (xinttools 1.3)
% had some more primitive f-expansion technique.
%\end{lverb}
%    \begin{macrocode}
\def\XINTusenoargfunc #1%
{%
    0\csname #1\endcsname
}%
\def\XINT:NE:usernoargfunc\csname #1\endcsname
{%
    ~romannumeral~XINTusenoargfunc{#1}%
}%
\def\XINTusefunc #1%
{%
    0\csname #1\expandafter\endcsname\expanded
}%
\def\XINT:NE:usefunc #1#2#3%
{%
    ~romannumeral~XINTusefunc{#1}{#3}\iffalse{{\fi}}%
}%
\def\XINTuseufunc #1%
{%
    \expanded\expandafter\XINT:expr:mapwithin\csname #1\expandafter\endcsname\expanded
}%
\def\XINT:NE:useufunc #1#2#3%
{%
    {{~expanded~XINTuseufunc{#1}{#3}}}%
}%
\def\XINT:NE:userfunc #1{%
\def\XINT:NE:userfunc ##1##2##3%
{%
    \if0\expandafter\XINT:NE:hastilde\detokenize{##3}~!\relax
        \expandafter\XINT:NE:hashash\detokenize{##3}#1!\relax 0%
      \expandafter\XINT:NE:userfunc_x
    \else
      \expandafter\XINT:NE:usefunc
    \fi {##1}{##2}{##3}%
}}\expandafter\XINT:NE:userfunc\string#%
\def\XINT:NE:userfunc_x #1#2#3{#2#3\iffalse{{\fi}}}%
\def\XINT:NE:userufunc #1{%
\def\XINT:NE:userufunc ##1##2##3%
{%
    \if0\expandafter\XINT:NE:hastilde\detokenize{##3}~!\relax
        \expandafter\XINT:NE:hashash\detokenize{##3}#1!\relax 0%
      \expandafter\XINT:NE:userufunc_x
    \else
      \expandafter\XINT:NE:useufunc
    \fi {##1}{##2}{##3}%
}}\expandafter\XINT:NE:userufunc\string#%
\def\XINT:NE:userufunc_x #1{\XINT:expr:mapwithin}%
\def\XINT:NE:macrofunc #1#2%
   {\expandafter\XINT:NE:macrofunc:a\string#1#2\empty&}%
\def\XINT:NE:macrofunc:a#1\csname #2\endcsname#3&%
   {{~XINTusemacrofunc{#1}{#2}{#3}}}%
\def\XINTusemacrofunc #1#2#3%
{%
    \romannumeral0\expandafter\xint_stop_atfirstofone
    \romannumeral0#1\csname #2\endcsname#3\relax
}%
%    \end{macrocode}
% \subsubsection{\csh{XINT_expr_redefinemacros}}
%\begin{lverb}
% Completely refactored at 1.3.
%
% Again refactored at 1.4. The availability of \expanded allows more powerful
% mechanisms and more importantly I better thought out the root problems
% caused by the handling of list operations in this context and this helped
% simplify considerably the code.
%\end{lverb}
% \odef\MakePrivateLetters{\MakePrivateLetters\catcode`- 11 }^^A
%    \begin{macrocode}
\catcode`- 11 \catcode0 11 \catcode2 11 \catcode3 11
\def\XINT_expr_redefinemacros {%
  \let\XINT:NEhook:unpack           \XINT:NE:unpack
  \let\XINT:NEhook:f:one:from:one        \XINT:NE:f:one:from:one
  \let\XINT:NEhook:f:one:from:one:direct \XINT:NE:f:one:from:one:direct
  \let\XINT:NEhook:f:one:from:two        \XINT:NE:f:one:from:two
  \let\XINT:NEhook:f:one:from:two:direct \XINT:NE:f:one:from:two:direct
  \let\XINT:NEhook:x:one:from:two        \XINT:NE:x:one:from:two
  \let\XINT:NEhook:f:one:and:opt:direct      \XINT:NE:f:one:and:opt:direct
  \let\XINT:NEhook:f:tacitzeroifone:direct   \XINT:NE:f:tacitzeroifone:direct
  \let\XINT:NEhook:f:iitacitzeroifone:direct \XINT:NE:f:iitacitzeroifone:direct
  \let\XINT:NEhook:x:listsel             \XINT:NE:x:listsel
  \let\XINT:NEhook:f:reverse             \XINT:NE:f:reverse
  \let\XINT:NEhook:f:from:delim:u        \XINT:NE:f:from:delim:u
  \let\XINT:NEhook:f:LFL            \XINT:NE:f:LFL
  \let\XINT:NEhook:r:check          \XINT:NE:r:check
  \let\XINT:NEhook:branch           \XINT:NE:branch
  \let\XINT:NEhook:seqx             \XINT:NE:seqx
  \let\XINT:NEhook:opx              \XINT:NE:opx
  \let\XINT:NEhook:rseq             \XINT:NE:rseq
  \let\XINT:NEhook:iter             \XINT:NE:iter
  \let\XINT:NEhook:rrseq            \XINT:NE:rrseq
  \let\XINT:NEhook:iterr            \XINT:NE:iterr
  \let\XINT:NEhook:x:toblist        \XINT:NE:x:toblist
  \let\XINT:NEhook:x:flatten        \XINT:NE:x:flatten
  \let\XINT:NEhook:x:zip            \XINT:NE:x:zip
  \let\XINT:NEhook:x:mapwithin      \XINT:NE:x:mapwithin
  \let\XINT:NEhook:x:ndmapx         \XINT:NE:x:ndmapx
  \let\XINT:NEhook:userfunc         \XINT:NE:userfunc
  \let\XINT:NEhook:userufunc        \XINT:NE:userufunc
  \let\XINT:NEhook:usernoargfunc    \XINT:NE:usernoargfunc
  \let\XINT:NEhook:macrofunc        \XINT:NE:macrofunc
  \def\XINTinRandomFloatSdigits{~XINTinRandomFloatSdigits }%
  \def\XINTinRandomFloatSixteen{~XINTinRandomFloatSixteen }%
  \def\calxFpRandomSdigits{~calxFpRandomSdigits }%
  \def\calxFpRandomSixteen{~calxFpRandomSixteen }%
  \def\calxintRandRange{~calxintRandRange }%
  \def\calxintRandRangeAtoB{~calxintRandRangeAtoB }%
  \def\xintRandBit{~xintRandBit }%
  \let\XINT_expr_exec_?  \XINT:NE:exec_?
  \let\XINT_expr_exec_?? \XINT:NE:exec_??
  \def\XINT_expr_op_?  {\XINT_expr_op__?{\XINT_expr_op_-xii\XINT_expr_oparen}}%
  \def\XINT_flexpr_op_?{\XINT_expr_op__?{\XINT_flexpr_op_-xii\XINT_flexpr_oparen}}%
  \def\XINT_iiexpr_op_?{\XINT_expr_op__?{\XINT_iiexpr_op_-xii\XINT_iiexpr_oparen}}%
%    \end{macrocode}
%\begin{lverb}
% calx: \xintiieval literals stay raw in compiled functions and macros:
% their meaning is detokenized and rescanned, where native M values would
% come back with a catcode 11 tag; the ii operations convert raw integers
% on entry. The fake operators &&@, &&B, &&C of \xintiieval put the
% literal as it is (&&C as in \xintfloateval).
%\end{lverb}
%    \begin{macrocode}
  \def\XINT_iiexpr_op_&&@ ##1##2]%
  {%
    \expandafter\XINT_expr_put_op_first
    \expanded{{{\CALX_rawE##1{\xint_zapspaces ##2 \xint_gobble_i}}}%
    \expandafter}\romannumeral`&&@\XINT_expr_getop
  }%
  \def\XINT_iiexpr_op_&&B ##1%
  {%
    \expandafter\XINT_expr_put_op_first
    \expanded{{{\xint_noxpd##1}}\expandafter}\romannumeral`&&@\XINT_expr_getop
  }%
  \let\XINT_iiexpr_op_&&C\XINT_flexpr_op_&&C
}%
\catcode`- 12 \catcode0 12 \catcode2 12 \catcode3 12
%    \end{macrocode}
% \let\MakePrivateLetters\xintexprMakePrivateLetters
% \subsubsection{Still more mysterious}
% \label{\xintimplabelprefix XINT_NewExpr}
% \label{\xintimplabelprefix XINT_NewExpr_a}
% \changed{2.0a1}
%
% |\XINT_NewExpr| is the kernel underlying both \csbxint{deffunc} and
% \csbxint{NewExpr}. Actually we declare here only \csbxint{deffloatfunc} and
% \csbxint{defiifunc}. All user level definitions, including all "NewExpr"
% variants are in \xintexprnameimp.sty.  Nothing was changed at release
% |2.0a1|.  Only the split into \calxnameimp.sty/\xintexprnameimp.sty kept
% here only \csbxint{deffloatfunc} and \csbxint{defiifunc}.
%
%\begin{lverb}
% 1.2c for \xintdeffunc, \xintdefiifunc, \xintdeffloatfunc.
%
% At 1.3, NewFunc does not use anymore a comma delimited pattern for the
% arguments to the macro being defined.
%
% At 1.4 we use \xintthebareeval, whose meaning  now does not mean unlock
% from csname but firstofone to remove a level of braces
% This is involved in functioning of expr:userfunc and expr:userefunc
%\end{lverb}
%    \begin{macrocode}
\def\XINT_NewFloatFunc{\XINT_NewExpr\xint_gobble_i\xintthebarefloateval\XINT_newfunc_clean}%
\def\XINT_NewIIFunc   {\XINT_NewExpr\xint_gobble_i\xintthebareiieval\XINT_newfunc_clean}%
\def\XINT_newfunc_clean #1>{}%
\ifdefined\notexpanded\let\XINT_newfunc_clean\xint_gobble_vi\fi%
%    \end{macrocode}
%\begin{lverb}
% 1.2c adds optional logging. For this needed to pass to _NewExpr_a the
% macro name as parameter.
%
% Up to and including 1.2c the definition was global. Starting with 1.2d it is
% done locally.
%
% The \xintexprSafeCatcodes inserted here by \xintNewExpr
% is not paired with an \xintexprRestoreCatcodes,
% but this happens within a scope limiting group so does not matter.
% At 1.3c, \XINT_NewFunc et al. do not even execute the
% \xintexprSafeCatcodes, as it gets already done by \xintdeffunc prior
% to arriving here.
%
%\end{lverb}
%    \begin{macrocode}
\def\XINT_NewExpr {\begingroup\XINT_NewExpr_a}%
\def\XINT_NewExpr_a #1#2#3#4#5[#6]%
{%
    \ifcase #6\relax
        \toks0 {\endgroup\XINT_global\def#4}%
    \or \toks0 {\endgroup\XINT_global\def#4##1}%
    \or \toks0 {\endgroup\XINT_global\def#4##1##2}%
    \or \toks0 {\endgroup\XINT_global\def#4##1##2##3}%
    \or \toks0 {\endgroup\XINT_global\def#4##1##2##3##4}%
    \or \toks0 {\endgroup\XINT_global\def#4##1##2##3##4##5}%
    \or \toks0 {\endgroup\XINT_global\def#4##1##2##3##4##5##6}%
    \or \toks0 {\endgroup\XINT_global\def#4##1##2##3##4##5##6##7}%
    \or \toks0 {\endgroup\XINT_global\def#4##1##2##3##4##5##6##7##8}%
    \or \toks0 {\endgroup\XINT_global\def#4##1##2##3##4##5##6##7##8##9}%
    \fi
    #1\xintexprSafeCatcodes
    \XINT_expr_redefinemacros
    \XINT_NewExpr_b #1#2#3#4%
}%
%    \end{macrocode}
%\begin{lverb}
%  $catcode38 12
%
% 1.2d's \xintNewExpr makes a local definition. In earlier releases, the
% definition was global.
%
% \the\toks0 inserts the \endgroup, but this will happen
% after \XINT_tmpa has already been expanded...
%
% The $%1 is \xint_firstofone for \xintNewExpr, \xint_gobble_i
% for \xintdeffunc.
%
% Attention that at 1.4, there might be entire sub-xintexpressions embedded in
% detokenized form. They are re-tokenized and the main thing is that the
% parser should not mis-interpret catcode 11 characters as starting variable
% names. As some macros use : in their names, the retokenization must be done
% with : having catcode 11. To not break embedded non-evaluated
% sub-expressions, the \XINT_expr_getop was extended to intercept the :
% (alternative would have been to never inject any macro with : in its name...
% too late now). On the other hand the ! is not used in the macro names
% potentially kept as is non expanded by the \xintNewExpr/\xintdeffunc
% process; it can thus be retokenized with catcode 12. But the «hooks» of
% seq(), iter(), etc... if deciding they can't evaluate immediately will
% inject a full sub-expression (possibly arbitrarily complicated) and append
% to it for its delayed expansion a catcode 11 ! character (as well as
% possibly catcode 3 ~ and ? and catcode 11 caret ^ and even catcode 7 $&).
% The macros \XINT_expr_tilde etc... below serve for this injection (there are
% *two* successive \scantokens using different catcode regimes and these
% macros remain detokenized during the first pass!) and as consequence the
% final meaning may have characters such as ! or & present with both standard
% and special catcodes depending on where they are located. It may thus not be
% possible to (easily) retokenize the meaning as printed in the log file if
% \xintverbosetrue was issued.
%
% If a defined function is used in another expression it would thus break
% things if its meaning was included pre-expanded ; a mechanism exists which
% keeps only the name of the macro associated to the function (this name may
% contain digits by the way), when the macro can not be immediately fully
% expanded. Thus its meaning (with its possibly funny catcodes) is not
% exposed. And this gives opportunity to pre-expand its arguments before
% actually expanding the macro.
%
% There is a problem with xetex -8bit which will convert ^^@ possibly present
% in the meaning written to log if \xintverbosetrue into a null byte.  It
% surprises at first, but perhaps because I am too much used to pdftex and luatex
% converting the zero byte perhaps produced meaning internally to ^^@ notation
% at the "output" stage.
%
% I observed that ConTeXt will spit out such null byte "as is", as does xetex
% -8bit.  This is a bit annoying because contrarily to xetex no option is
% needed, and such output lets some software consider the output file is a
% binary one (for example git diff).
%\end{lverb}
%    \begin{macrocode}
\catcode`~ 3 \catcode`? 3
\def\XINT_expr_tilde{~}\def\XINT_expr_qmark{?}% catcode 3
\def\XINT_expr_caret{^}\def\XINT_expr_exclam{!}% catcode 11
\def\XINT_expr_tab{&}% catcode 7
\def\XINT_expr_null{&&@}%
%    \end{macrocode}
% \added{1.4n} Add \cs{xintmeaning} for matters of package test suite.
% At user level, a priori simply expands to \cs{meaning}.  It gets
% redefined during execution of the test suite to keep logged expectations
% the same also with LMTX engine.
%    \begin{macrocode}
\ifdefined\xintmeaning\else\def\xintmeaning{\meaning}\fi
%    \end{macrocode}
% \added{1.4n}
%\begin{lverb}
% Add \XINT_expr_set_tilde to address LuaMeta$TeX$ specifics.
% We won't need to restore because we will be in a group and \toks0 will
% bring the \endgroup.
%\end{lverb}
%
% When I observed that the whole \csbxint{deffunc} thing was broken with
% Con\TeX t due to what appeared to be some weirdness during expansion, I
% realized much to my surprise that the active tilde was not expanding inside
% \cs{edef}! I got lucky I could quickly find a then recent discussion
% precisely about this on
% \href{https://tex.stackexchange.com/q/749050}{tex.sx}, from which I picked
% up the \cs{amcode} workaround. Such a trick is quite hidden in Con\TeX t
% documentation, from which it is a long shot to deduce it behaves as it
% actually does.
%
% Replacing about 130 occurrences of |~| in this file which are a core part of
% the mysterious dealings underpinning \csbxint{deffunc} is not really an
% option.  I don't have that many available ascii characters and I do not want
% to go into mass replacements and have to update unit tests sometimes
% checking internals.  What a relief there is the \cs{amcode} way! (and seemingly
% no other way...).
%    \begin{macrocode}
\catcode`~ 13 \catcode`$ 11 %$
\def\XINT_NewExpr_set_tilde{\def~{$noexpand$}}%
\ifdefined\contextversion
  \ifdefined\amcode
    \def\XINT_NewExpr_set_tilde{\amcode`\~0\def~{$noexpand$}}%
  \else
    \xintMessage{xintexpr}{Error}{This ConTeXt is incompatible.}%
    \errhelp{xintexpr requires ConTeXt-LMTX to have its \string\amcode.}%
    \errmessage{The \noexpand\amcode primitive does not exist.}%
  \fi
\fi
\catcode`@ 14 \catcode`\% 6 \catcode`# 12
\def\XINT_NewExpr_b %1%2%3%4%5@
{@
    \def\XINT_tmpa %%1%%2%%3%%4%%5%%6%%7%%8%%9{%5}@
    \XINT_NewExpr_set_tilde
    \catcode`: 11 \catcode`_ 11 \catcode`\@ 11
    \catcode`# 12 \catcode`~ 13 \escapechar 126
    \endlinechar -1 \everyeof {\noexpand }@
    \edef\XINT_tmpb
    {\scantokens\expandafter{\romannumeral`&&@\expandafter
     %2\XINT_tmpa{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}\relax}@
    }@
    \escapechar 92 \catcode`# 6 \catcode`$ 0 @ $
    \edef\XINT_tmpa %%1%%2%%3%%4%%5%%6%%7%%8%%9@
      {\scantokens\expandafter{\expandafter%3\meaning\XINT_tmpb}}@
    \the\toks0\expandafter
      {\XINT_tmpa{%%1}{%%2}{%%3}{%%4}{%%5}{%%6}{%%7}{%%8}{%%9}}@
    %1{\ifxintverbose
        \xintMessage{xintexpr}{Info}@
                    {\string%4\space now with @
                     \ifxintglobaldefs global \fi meaning \xintmeaning%4}@
       \fi}@
}@
\catcode`% 14
\XINTsetcatcodes % clean up to avoid surprises if something changes
%    \end{macrocode}
% \subsubsection{\csh{xintexprSafeCatcodes}, \csh{xintexprRestoreCatcodes}}
% \changed[2018/06/17]{1.3c}
%\begin{lverb}
% Added \ifxintexprsafecatcodes to allow nesting
%\end{lverb}
% \changed[2022/05/15]{1.4k}
%\begin{lverb}
% The "allow nesting" from the 2018 comment was strange, because
% the behaviour, as correctly documented in user manual, was that
% in case of a series of \xintexprSafeCatcodes, the \xintexprRestoreCatcodes
% would set catcodes to what they were before the *first* sanitization.
% But as \xintdefvar and \xintdeffunc used such a pair this meant
% that they would incomprehensibly for user reset catcodes to what
% they were before a possible user \xintexprSafeCatcodes located before...
% very lame situation.  Anyway. I finally
% fix at 1.4k that by removing the silly \ifxintexprsafecatcodes thing
% and replace it by some stack-like method, avoiding extra macros
% thanks to the help of \unexpanded.
%\end{lverb}
% \changed{1.4m} Use |\protected| rather than |\unexpanded| mechanism,
% for lisibility.
%    \begin{macrocode}
\protected\def\xintexprRestoreCatcodes{}%
\def\xintexprSafeCatcodes
{%
    \protected\edef\xintexprRestoreCatcodes{%
        \endlinechar=\the\endlinechar
        \catcode59=\the\catcode59   % ;
        \catcode34=\the\catcode34   % "
        \catcode63=\the\catcode63   % ?
        \catcode124=\the\catcode124 % |
        \catcode38=\the\catcode38   % &
        \catcode33=\the\catcode33   % !
        \catcode93=\the\catcode93   % ]
        \catcode91=\the\catcode91   % [
        \catcode94=\the\catcode94   % ^
        \catcode95=\the\catcode95   % _
        \catcode47=\the\catcode47   % /
        \catcode41=\the\catcode41   % )
        \catcode40=\the\catcode40   % (
        \catcode42=\the\catcode42   % *
        \catcode43=\the\catcode43   % +
        \catcode62=\the\catcode62   % >
        \catcode60=\the\catcode60   % <
        \catcode58=\the\catcode58   % :
        \catcode46=\the\catcode46   % .
        \catcode45=\the\catcode45   % -
        \catcode44=\the\catcode44   % ,
        \catcode61=\the\catcode61   % =
        \catcode96=\the\catcode96   % `
        \catcode32=\the\catcode32\relax  % space
        \protected\odef\xintexprRestoreCatcodes{\xintexprRestoreCatcodes}%
    }%
        \endlinechar=13 %
        \catcode59=12  % ;
        \catcode34=12  % "
        \catcode63=12  % ?
        \catcode124=12 % |
        \catcode38=4   % &
        \catcode33=12  % !
        \catcode93=12  % ]
        \catcode91=12  % [
        \catcode94=7   % ^
        \catcode95=8   % _
        \catcode47=12  % /
        \catcode41=12  % )
        \catcode40=12  % (
        \catcode42=12  % *
        \catcode43=12  % +
        \catcode62=12  % >
        \catcode60=12  % <
        \catcode58=12  % :
        \catcode46=12  % .
        \catcode45=12  % -
        \catcode44=12  % ,
        \catcode61=12  % =
        \catcode96=12  % `
        \catcode32=10  % space
}%
\let\XINT_tmpa\undefined \let\XINT_tmpb\undefined \let\XINT_tmpc\undefined
\let\XINT_tmpd\undefined \let\XINT_tmpe\undefined
%    \end{macrocode}
%\subsection{The calx layer}
%\begin{lverb}
% calx: native float operators (wip).
% ATTENTION: the ! has catcode 12 here due to prior \XINTsetcatcodes.
%
% ATTENTION: we do NOT set catcode of M (or N, or F) to 12 here.
%            They only appear in \if tests, and are needed in macro
%            names.
%
% Operator-level macros (letter-only names, frozen in user functions):
% two arguments (one for Sqr, Opp), precision \XINTdigits at run time.
%
% Syntax (all f-expandable; arguments f-expanded, F, I or raw values; P =
% \XINTdigits unless given; results F or I values, without leading space):
%(
%  \calxFpAdd{X}{Y}, \calxFpSub, \calxFpMul, \calxFpDiv  -> round_P(X op Y)
%:  \calxFpMulExact{X}{Y}                -> X Y exact (X, Y finite F)
%:  \calxFpDivFloor{X}{Y}               -> floor(X'/Y') exact (X' = round_P(X))
%:  \calxFpMod{X}{Y}                    -> round_P(X' - Y' floor(X'/Y'))
%:  \calxFpDivMod{X}{Y}                 -> {floor(X'/Y')}{round_P(X' mod Y')}
%:  \calxFpInv{X}                       -> round_P(1/X)  (X exact)
%:  \calxFpE{X}{n}                      -> round_P(X) 10^n  (raw A[N])
%:  \calxFpSum{X1}...{Xn}^, \calxFpPrd  -> (((X1 op X2) op X3) ...), each op
%:                                       rounded (+(), *(); empty: 0, 1)
%:  \calxFpSqr{X}, \calxFpSqrtdigits{X}  -> round_P(X^2), round_P(sqrt X)
%:  \calxFpSqrt[P]{X}                    -> round_P(sqrt X)
%:  \calxFpOpp{X}, \calxFpAbs{X}         -> -X, |X|   (exact)
%:  \calxSgn{X}                          -> -1, 0 or 1   (any value)
%:  \calxFpLt{X}{Y}, \calxFpGt, \calxFpLtorEq, \calxFpGtorEq,
%:  \calxFpEq, \calxFpNotEq               -> 1 or 0 (exact comparison)
%:  \calxFpMaxof{X1}...{Xn}^, \calxFpMinof  -> the largest (smallest) Xi
%:  \calxFpTrunc{X}, \calxFpFloor{X}, \calxFpCeil{X}, \calxFpFrac{X}
%:                                       -> F (raw input: raw result)
%:  \calxFpITrunc{k}{X}, \calxFpIRound{k}{X}  -> trunc(X), round(X)
%:  \calxFpToNum{X}                      -> digits of trunc(X)
%)
% Internal helpers used by other files: \CALX_fcmp{X}{Y} (in \ifcase: 0
% equal, 1 greater, 2 less, 3 unordered), \CALX_fonec (native 1),
% \CALX_fopp_a (sign flip), \CALX_ti_f (calxfp: trunc of an F value
% followed by \xint:), \CALX_fcnan (InvalidOperation signal of a comparison).
%\end{lverb}
%    \begin{macrocode}
\def\calxFpAdd #1#2%
   {\romannumeral0\expandafter\CALX_fadd_in\expanded{#1\xint:#2\xint:}\the\XINTdigits.}%
\def\calxFpSub #1#2%
   {\romannumeral0\expandafter\CALX_fsub_in\expanded{#1\xint:#2\xint:}\the\XINTdigits.}%
\def\calxFpMul #1#2%
   {\romannumeral0\expandafter\CALX_fmul_in\expanded{#1\xint:#2\xint:}\the\XINTdigits.}%
\def\calxFpMulExact #1#2%
   {\romannumeral0\expandafter\CALX_fmulxs_in\expanded{#1\xint:#2\xint:}}%
\def\calxFpDiv #1#2%
   {\romannumeral0\expandafter\CALX_fdiv_in\expanded{#1\xint:#2\xint:}\the\XINTdigits.}%
\def\calxFpDivFloor #1#2%
   {\romannumeral0\expandafter\CALX_fdq_in\expanded{#1\xint:#2\xint:}\the\XINTdigits.\CALX_fdq_q}%
\def\calxFpMod #1#2%
   {\romannumeral0\expandafter\CALX_fdq_in\expanded{#1\xint:#2\xint:}\the\XINTdigits.\CALX_fdq_r}%
\def\calxFpDivMod #1#2%
   {\romannumeral0\expandafter\CALX_fdq_in\expanded{#1\xint:#2\xint:}\the\XINTdigits.\CALX_fdq_p}%
\def\calxFpInv #1%
   {\romannumeral0\expandafter\CALX_finv_in\romannumeral`&&@#1\xint:\the\XINTdigits.}%
\def\calxFpE #1%
   {\romannumeral0\expandafter\CALX_fe_in\romannumeral`&&@#1\xint:\the\XINTdigits.}%
%    \end{macrocode}
%\begin{lverb}
% calx: `+`(), `*`() of \xintfloateval: Burnol's 1.4p \XINT_sum/\XINT_prd
% loops (xintfrac), \xintadd/\xintmul replaced by \CALX_fsumop/\CALX_fprdop
% (rounded to P at each step, unlike 1.4p's exact \XINT_Sum); empty: 0[0],
% 1[0]; one item: returned as it is (f-expanded).
%\end{lverb}
%    \begin{macrocode}
\def\calxFpSum {\romannumeral0\CALX_fpsum}%
\def\CALX_fpsum #1%
{%
    \xint_gob_til_^ #1\CALX_fpsum_empty ^%
    \expandafter\CALX_fpsum_loop\romannumeral`&&@#1\xint:
}%
\def\CALX_fpsum_empty ^#1\xint:{ 0[0]}%
\def\CALX_fpsum_loop #1\xint:#2%
{%
    \xint_gob_til_^ #2\CALX_fpsum_end ^%
    \expandafter\CALX_fpsum_loop
    \romannumeral0\CALX_fsumop{#1}{#2}\xint:
}%
\def\CALX_fpsum_end ^#1\CALX_fsumop #2#3\xint:{ #2}%
\def\calxFpPrd {\romannumeral0\CALX_fpprd}%
\def\CALX_fpprd #1%
{%
    \xint_gob_til_^ #1\CALX_fpprd_empty ^%
    \expandafter\CALX_fpprd_loop\romannumeral`&&@#1\xint:
}%
\def\CALX_fpprd_empty ^#1\xint:{ 1[0]}%
\def\CALX_fpprd_loop #1\xint:#2%
{%
    \xint_gob_til_^ #2\CALX_fpprd_end ^%
    \expandafter\CALX_fpprd_loop
    \romannumeral0\CALX_fprdop{#1}{#2}\xint:
}%
\def\CALX_fpprd_end ^#1\CALX_fprdop #2#3\xint:{ #2}%
\def\CALX_fsumop {\CALX_fadd\XINTdigits}%
\def\CALX_fprdop {\CALX_fmul\XINTdigits}%
\def\calxFpSqr #1%
   {\romannumeral0\expandafter\CALX_fsqr_in\romannumeral`&&@#1\xint:\the\XINTdigits.}%
\def\calxFpSqrtdigits #1%
   {\romannumeral0\expandafter\CALX_fsqrt_in\romannumeral`&&@#1\xint:\the\XINTdigits.}%
\def\calxFpSqrt [#1]#2%
   {\romannumeral0\expandafter\CALX_fsqrt_in\romannumeral`&&@#2\xint:\the\numexpr#1.}%
%    \end{macrocode}
%\begin{lverb}
% \calxFpToNum{X}: explicit digits of trunc(X), where X is a parser
% value (possibly still expandable).  The ordinary entry takes one brace
% level.  \calxListItemToNum{X} is for the legacy list selectors, whose
% items carry an additional brace level; it strips that level explicitly.
% Both paths enter the same conversion kernel, \CALX_fnum, with an
% already f-expanded input followed by \xint:.
%\end{lverb}
%    \begin{macrocode}
\def\calxFpToNum #1%
   {\romannumeral0\expandafter\CALX_fnum\romannumeral`&&@#1\xint:}%
\def\calxListItemToNum #1%
   {\romannumeral0\expandafter\CALX_fnum\romannumeral`&&@\xint_firstofone#1%
    \xint:}%
%    \end{macrocode}
%\begin{lverb}
% \calxFpOpp: sign flip, the tag token kept; F+0.0., M+0.0. and I?
% unchanged. F, M and I: \CALX_fopp_a.
%\end{lverb}
%    \begin{macrocode}
\def\calxFpOpp #1%
   {\romannumeral0\expandafter\CALX_fopp_e\romannumeral`&&@#1\xint:}%
%    \end{macrocode}
%\begin{lverb}
% raw input (strict A[N], A/B[N]): \CALX_fopp_x on the first token, a
% leading - removed, a leading 0 (zero) kept, else - prepended.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fopp_e #1%
   {\if F#1\else\if I#1\else\if M#1\else\CALX_fopp_r\fi\fi\fi
    \CALX_fopp_a #1}%
\def\CALX_fopp_r #1\fi\fi\fi\CALX_fopp_a #2\xint:{\fi\fi\fi\CALX_fopp_x #2\xint:}%
\def\CALX_fopp_x #1#2\xint:%
   {\if-#1\xint_dothis{ #2}\fi\if0#1\xint_dothis{ #1#2}\fi\xint_orthat{ -#1#2}}%
\def\CALX_fopp_a #1#2#3\xint:%
{%
    \if#2-\xint_dothis{ #1+#3}\fi
    \if#2?\xint_dothis{ #1?}\fi
    \if0\CALX_fopp_b#3?\xint:\xint_dothis{ #1+#3}\fi
    \xint_orthat{ #1-#3}%
}%
\def\CALX_fopp_b #1#2\xint:{#1}%
%    \end{macrocode}
%\begin{lverb}
% Syntax (f-expandable; X a value of any parser, f-expanded; k a value
% with \CALX_mr digits, i.e. M or raw integer):
%(
%  \calxiiRound{k}{X}, \calxiiTrunc{k}{X}  -> M (X 10^k rounded, truncated)
%:  \calxiiFloor{X}, \calxiiCeil{X}        -> M
%:  \calxCeilToNum{X}                      -> explicit digits of ceil(X)
%)
% round(x, k), trunc(x, k), floor(), ceil() of \xintiieval, the start
% value of n++. X 10^k as raw A/B[N + k] (M by \CALX_mtoraw_t, F by
% \CALX_ftoraw), then calxfp's \CALX_fintn with the kind \CALX_fintk_r,
% \CALX_fintk_t; floor, ceil: M (and I) values as they are, others
% \CALX_fintn with \CALX_fintk_f, \CALX_fintk_c; result \CALX_ntom. I
% values unchanged. \calxCeilToNum: \CALX_fint and \CALX_seq_k (I:
% \CALX_fnum, InvalidOperation, 0). \string on the tag of X after its
% f-expansion (values from compiled functions).
%\end{lverb}
%    \begin{macrocode}
\def\calxiiRound #1#2%
   {\romannumeral0\expandafter\CALX_iirt_s\romannumeral`&&@#2\xint:{#1}%
    \CALX_fintk_r}%
\def\calxiiTrunc #1#2%
   {\romannumeral0\expandafter\CALX_iirt_s\romannumeral`&&@#2\xint:{#1}%
    \CALX_fintk_t}%
\def\calxiiFloor #1%
   {\romannumeral0\expandafter\CALX_iifl_s\romannumeral`&&@#1\xint:%
    \CALX_fintk_f}%
\def\calxiiCeil #1%
   {\romannumeral0\expandafter\CALX_iifl_s\romannumeral`&&@#1\xint:%
    \CALX_fintk_c}%
\def\CALX_iirt_s{\expandafter\CALX_iirt_a\string}%
\def\CALX_iirt_a #1%
{%
    \if I#1\xint_dothis{\CALX_iirt_i#1}\fi
    \if M#1\xint_dothis{\CALX_iirt_m#1}\fi
    \if F#1\xint_dothis{\CALX_iirt_f#1}\fi
    \xint_orthat{\CALX_iirt_r#1}%
}%
\def\CALX_iirt_i #1#2\xint:#3#4{ #1#2}%
\def\CALX_iirt_m #1#2\xint:#3%
   {\expandafter\CALX_iirt_b
    \romannumeral0\CALX_mtoraw_t#1#2\xint:[0]\xint:{#3}}%
\def\CALX_iirt_f #1#2\xint:#3%
   {\expandafter\CALX_iirt_b
    \romannumeral0\CALX_ftoraw{#1#2}[0]\xint:{#3}}%
\def\CALX_iirt_r #1#2\xint:#3{\CALX_iirt_b#1#2[0]\xint:{#3}}%
\def\CALX_iirt_b #1[#2]#3\xint:#4%
   {\expandafter\CALX_iirt_c\the\numexpr#2+\CALX_mr{#4}.{#1}}%
\def\CALX_iirt_c #1.#2#3%
   {\expandafter\CALX_ntom\romannumeral0\CALX_fintn#3#2[#1]\xint:}%
\def\CALX_iifl_s{\expandafter\CALX_iifl_a\string}%
\def\CALX_iifl_a #1%
{%
    \if I#1\xint_dothis{\CALX_iifl_copy#1}\fi
    \if M#1\xint_dothis{\CALX_iifl_copy#1}\fi
    \xint_orthat{\CALX_iifl_calc#1}%
}%
\def\CALX_iifl_copy #1#2\xint:#3{ #1#2}%
\def\CALX_iifl_calc #1#2\xint:#3%
   {\expandafter\CALX_ntom\romannumeral0\CALX_fintn#3#1#2\xint:}%
\def\calxCeilToNum #1%
   {\romannumeral0\expandafter\CALX_ctn_s\romannumeral`&&@#1\xint:}%
\def\CALX_ctn_s{\expandafter\CALX_ctn_a\string}%
\def\CALX_ctn_a #1#2\xint:%
{%
    \if I#1\xint_dothis{\CALX_fnum#1#2\xint:}\fi
    \xint_orthat{\expandafter\CALX_ctn_b\the\numexpr\expandafter\CALX_seq_k
      \romannumeral0\CALX_fint#1#2\xint:\CALX_fintk_c.}%
}%
\def\CALX_ctn_b #1.{ #1}%
%    \end{macrocode}
%\begin{lverb}
% calx: sign and zero tests on the values of the three parsers, by
% calxcore's \CALX_ifsgn and \CALX_ifnz (first tokens only, no xintfrac
% parsing). One macro token each, f-expandable, for the parser tables and
% the \xintNewExpr hooks:
%(
%  \calxSgn{X}                         -> -1, 0 or 1
%:  \calxIsZero{X}, \calxIsNotZero{X}   -> 1 or 0
%:  \calxifNotZero{X}{A}{B}             -> A (X <> 0) or B
%:  \calxifSgn{X}{A}{B}{C}              -> A, B or C (X < 0, = 0, > 0)
%:  \calxAND{X}{Y}, \calxOR{X}{Y}, \calxXOR{X}{Y}   -> 1 or 0
%:  \CALX_ANDof{X}{Y}...^, \CALX_ORof..., \CALX_XORof...   -> 1 or 0
%)
% I? is non-zero for the truth tests; \calxSgn and \calxifSgn signal
% InvalidOperation on it, then count it as 0. \calxAND, \calxOR, \calxXOR
% and the loops of the lists use \CALX_ifnz_a with \xint_firstoftwo,
% \xint_secondoftwo, which add no space (\CALX_xorof counts the non-zero
% items as signs in a \numexpr, as xint's \XINT_xorof).
%\end{lverb}
%    \begin{macrocode}
\def\calxSgn #1%
   {\romannumeral0\expandafter\CALX_ifsgn_a\romannumeral`&&@#1\xint:{-1}{0}{1}}%
\def\calxIsZero #1%
   {\romannumeral0\expandafter\CALX_ifnz_a\romannumeral`&&@#1\xint:%
    \xint_stop_atfirstoftwo\xint_stop_atsecondoftwo{0}{1}}%
\def\calxIsNotZero #1%
   {\romannumeral0\expandafter\CALX_ifnz_a\romannumeral`&&@#1\xint:%
    \xint_stop_atfirstoftwo\xint_stop_atsecondoftwo{1}{0}}%
\def\calxifNotZero #1%
   {\romannumeral0\expandafter\CALX_ifnz_a\romannumeral`&&@#1\xint:%
    \xint_stop_atfirstoftwo\xint_stop_atsecondoftwo}%
\def\calxifSgn #1%
   {\romannumeral0\expandafter\CALX_ifsgn_a\romannumeral`&&@#1\xint:}%
\def\calxAND #1#2%
   {\romannumeral0\expandafter\CALX_ifnz_a\romannumeral`&&@#1\xint:%
    \xint_firstoftwo\xint_secondoftwo{\CALX_ifnz{#2}{1}{0}}{ 0}}%
\def\calxOR #1#2%
   {\romannumeral0\expandafter\CALX_ifnz_a\romannumeral`&&@#1\xint:%
    \xint_firstoftwo\xint_secondoftwo{ 1}{\CALX_ifnz{#2}{1}{0}}}%
\def\calxXOR #1#2%
   {\romannumeral0\expandafter\CALX_ifnz_a\romannumeral`&&@#1\xint:%
    \xint_firstoftwo\xint_secondoftwo{\CALX_ifnz{#2}{0}{1}}%
    {\CALX_ifnz{#2}{1}{0}}}%
\def\CALX_ANDof {\romannumeral0\CALX_andof}%
\def\CALX_andof #1%
   {\xint_gob_til_^ #1\CALX_andof_e ^%
    \expandafter\CALX_ifnz_a\romannumeral`&&@#1\xint:%
    \xint_firstoftwo\xint_secondoftwo\CALX_andof\CALX_andof_n}%
\def\CALX_andof_n #1^{ 0}%
\def\CALX_andof_e ^#1\CALX_andof_n{ 1}%
\def\CALX_ORof {\romannumeral0\CALX_orof}%
\def\CALX_orof #1%
   {\xint_gob_til_^ #1\CALX_orof_e ^%
    \expandafter\CALX_ifnz_a\romannumeral`&&@#1\xint:%
    \xint_firstoftwo\xint_secondoftwo\CALX_orof_y\CALX_orof}%
\def\CALX_orof_y #1^{ 1}%
\def\CALX_orof_e ^#1\CALX_orof{ 0}%
\def\CALX_XORof {\romannumeral0\CALX_xorof}%
\def\CALX_xorof {\if1\the\numexpr\CALX_xorof_a}%
\def\CALX_xorof_a #1%
   {\xint_gob_til_^ #1\CALX_xorof_e ^%
    \expandafter\CALX_ifnz_a\romannumeral`&&@#1\xint:%
    \xint_firstoftwo\xint_secondoftwo{-}{}\CALX_xorof_a}%
\def\CALX_xorof_e ^#1\CALX_xorof_a
   {1\relax\xint_afterfi{ 0}\else\xint_afterfi{ 1}\fi}%
%    \end{macrocode}
%\begin{lverb}
% calx: the same tests for \xintfloateval, with native F results (1, 0,
% -1): the values of \xintfloateval are F, M, I or raw with [N], never a
% bare integer. \CALX_fpone, \CALX_fpzero: <space>F+1.0.100000001!,
% <space>F+0.0. (written where F has catcode 12); \CALX_fpb <0 or 1>: the
% F value; the entries apply it to the digit of the general macros.
%(
%  \calxFpSgn{X}                          -> F -1, 0 or 1
%:  \calxFpIsZero{X}, \calxFpIsNotZero{X}  -> F 1 or 0
%:  \calxFpAND{X}{Y}, \calxFpOR, \calxFpXOR  -> F 1 or 0
%:  \calxFpANDof{X}{Y}...^, \calxFpORof, \calxFpXORof  -> F 1 or 0
%:  \calxFpEven{X}, \calxFpOdd, \calxFpIsOne, \calxFpIsInt -> F 1 or 0
%:  \calxFpLength{L}                       -> raw A[0]
%:  \calxFpiLogTendigits{X}, \calxFpiLogTen[P]{X}  -> F
%)
% ilog10(): X rounded to P digits (\CALX_fround; F, M, I, raw), then
% from the header F<s><D>.<e>.: 8e + D - 1 (\CALX_filt_f), as an F value
% (\CALX_ffromraw); zero: -"7FFF8000 as xint; I: InvalidOperation, I?.
%\end{lverb}
%    \begin{macrocode}
\catcode`F=12
\def\CALX_fpone{ F+1.0.100000001!}%
\def\CALX_fpzero{ F+0.0.}%
\def\CALX_fpsgn #1%
   {\romannumeral0\CALX_ifsgn{#1}{F-1.0.100000001!}{F+0.0.}{F+1.0.100000001!}}%
\catcode`F=11
\let\calxFpSgn\CALX_fpsgn
\def\CALX_fpb #1{\if1#1\expandafter\CALX_fpone\else\expandafter\CALX_fpzero\fi}%
\def\calxFpIsZero{\romannumeral0\expandafter\CALX_fpb\romannumeral`&&@\calxIsZero}%
\def\calxFpIsNotZero
   {\romannumeral0\expandafter\CALX_fpb\romannumeral`&&@\calxIsNotZero}%
\def\calxFpAND{\romannumeral0\expandafter\CALX_fpb\romannumeral`&&@\calxAND}%
\def\calxFpOR{\romannumeral0\expandafter\CALX_fpb\romannumeral`&&@\calxOR}%
\def\calxFpXOR{\romannumeral0\expandafter\CALX_fpb\romannumeral`&&@\calxXOR}%
\def\calxFpANDof{\romannumeral0\expandafter\CALX_fpb\romannumeral`&&@\CALX_ANDof}%
\def\calxFpORof{\romannumeral0\expandafter\CALX_fpb\romannumeral`&&@\CALX_ORof}%
\def\calxFpXORof{\romannumeral0\expandafter\CALX_fpb\romannumeral`&&@\CALX_XORof}%
%    \end{macrocode}
%\begin{lverb}
% even(), odd(): parity of the truncation of X (exact, as xintfrac's
% \xintNum). \CALX_fpar{X} -> <space>1 if odd, else <space>0. F: e > 0 or
% zero: even; e = 0: the lowest block; e < 0: the block of index -e
% (\CALX_nskip), if D > -8e, else the truncation is 0. M: e > 0 or zero:
% even, else the lowest block. Raw (also bare A, A/B) and I: calxfp's
% \CALX_fnum (I: InvalidOperation, 0), \CALX_nfromraw, the lowest block.
% isone(): \CALX_fcmp with 1 (exact; I: 0). isint(): X rounded to P digits
% (\CALX_fround, as xintfrac's \xintFloatIsInt), then zero or e >= 0: 1;
% e < 0: 1 iff D > -8e and the -e lowest blocks are zero (\CALX_fii_z); I:
% 0. ifint() (\calxFpifInt): the same test, first or second branch
% (\CALX_ifb). ifone() (\calxFpifOne): \CALX_fcmp with 1 (no rounding), I:
% second branch, no signal. ifint() of \xintiieval (calxint's
% \calxiiifInt): its values are integers, first branch; I: InvalidOperation,
% second branch (as \calxiiifOne).
%\end{lverb}
%    \begin{macrocode}
\def\calxFpEven{\romannumeral0\expandafter\CALX_fpe\romannumeral0\CALX_fpar}%
\def\calxFpOdd{\romannumeral0\expandafter\CALX_fpb\romannumeral0\CALX_fpar}%
\def\CALX_fpe #1{\if1#1\expandafter\CALX_fpzero\else\expandafter\CALX_fpone\fi}%
\def\CALX_fpar #1{\expandafter\CALX_fpar_a\romannumeral`&&@#1\xint:}%
\def\CALX_fpar_a #1%
{%
    \if F#1\xint_dothis\CALX_fpar_f\fi
    \if M#1\xint_dothis\CALX_fpar_m\fi
    \xint_orthat\CALX_fpar_x #1%
}%
\def\CALX_fpar_f #1#2#3.#4.%
{%
    \ifnum#4>\xint_c_ \xint_dothis\CALX_fpar_zero\fi
    \ifnum#3=\xint_c_ \xint_dothis\CALX_fpar_zero\fi
    \ifnum#4=\xint_c_ \xint_dothis\CALX_fpar_g\fi
    \ifnum#3>\numexpr-\xint_c_viii*(#4)\relax
      \xint_dothis{\CALX_nskip\CALX_fpar_g -#4.}\fi
    \xint_orthat\CALX_fpar_zero
}%
\def\CALX_fpar_m #1#2#3.#4.%
{%
    \ifnum#3=\xint_c_ \xint_dothis\CALX_fpar_zero\fi
    \ifnum#4>\xint_c_ \xint_dothis\CALX_fpar_zero\fi
    \xint_orthat\CALX_fpar_g
}%
\def\CALX_fpar_zero #1\xint:{ 0}%
\def\CALX_fpar_g 1#1!#2\xint:{\ifodd#1 \xint_afterfi{ 1}\else\xint_afterfi{ 0}\fi}%
\def\CALX_fpar_x #1\xint:%
   {\expandafter\CALX_fpar_n\romannumeral0\CALX_nfromraw
    {\romannumeral0\CALX_fnum#1\xint:}\xint:}%
\catcode`N=12
\def\CALX_fpar_n N#1#2.#3\xint:%
   {\ifnum#2=\xint_c_ \xint_dothis{ 0}\fi\xint_orthat{\CALX_fpar_g#3\xint:}}%
\catcode`N=11
\def\calxFpIsOne #1%
   {\romannumeral0\ifcase\expandafter\CALX_fcmp_in\expanded{#1\xint:
          \CALX_fpone\xint:} \xint_afterfi\CALX_fpone
    \else\xint_afterfi\CALX_fpzero\fi}%
\def\calxFpIsInt%
   {\romannumeral0\expandafter\CALX_fpb\romannumeral0\expandafter\CALX_fii
    \romannumeral0\CALX_fround{\XINTdigits}}%
\def\CALX_fii #1{\if I#1\expandafter\CALX_fii_i\else\expandafter\CALX_fii_f\fi}%
\def\CALX_fii_i #1\xint:{ 0}%
\def\CALX_fii_f #1#2.#3.%
{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_fii_yes\fi
    \ifnum#3<\xint_c_ \xint_dothis{\CALX_fii_n#2.#3.}\fi
    \xint_orthat\CALX_fii_yes
}%
\def\CALX_fii_n #1.#2.#3\xint:%
{%
    \ifnum#1>\numexpr-\xint_c_viii*(#2)\relax
      \xint_dothis{\expandafter\CALX_fii_z\the\numexpr-#2.#3\xint:}\fi
    \xint_orthat{ 0}%
}%
\def\CALX_fii_z #1.1#2!%
{%
    \ifnum#2>\xint_c_ \xint_dothis\CALX_fii_no\fi
    \ifnum#1=\xint_c_i \xint_dothis\CALX_fii_yes\fi
    \xint_orthat{\expandafter\CALX_fii_z\the\numexpr#1-\xint_c_i.}%
}%
\def\CALX_fii_no #1\xint:{ 0}%
\def\CALX_fii_yes #1\xint:{ 1}%
\def\calxFpifInt%
   {\romannumeral0\expandafter\CALX_ifb\romannumeral0\expandafter\CALX_fii
    \romannumeral0\CALX_fround{\XINTdigits}}%
\def\CALX_ifb #1%
   {\if1#1\expandafter\xint_stop_atfirstoftwo\else
          \expandafter\xint_stop_atsecondoftwo\fi}%
\def\calxFpifOne #1%
   {\romannumeral0\ifcase\expandafter\CALX_fcmp_in\expanded{#1\xint:
                  \CALX_fpone\xint:} %
    \expandafter\xint_stop_atfirstoftwo\else
    \expandafter\xint_stop_atsecondoftwo\fi}%
\def\calxFpLength #1{\expanded{\xintLength{#1}[0]}}%
\def\calxFpiLogTendigits%
   {\romannumeral0\expandafter\CALX_filt\romannumeral0\CALX_fround{\XINTdigits}}%
\def\calxFpiLogTen [#1]%
   {\romannumeral0\expandafter\CALX_filt\romannumeral0\CALX_fround{#1}}%
\def\CALX_filt #1%
   {\if I#1\expandafter\CALX_filt_i\else\expandafter\CALX_filt_f\fi #1}%
\def\CALX_filt_i #1\xint:{\CALX_nsig{InvalidOperation}{ilog10 of I}{}}%
\def\CALX_filt_f #1#2#3.#4.#5\xint:%
{%
    \ifnum#3=\xint_c_ \expandafter\CALX_filt_z\fi
    \CALX_ffromraw{\the\numexpr\xint_c_viii*(#4)+#3-\xint_c_i[0]}%
}%
\def\CALX_filt_z #1#2{\CALX_ffromraw{-2147450880[0]}}%
%    \end{macrocode}
%\begin{lverb}
% calx: native comparisons and abs() of \xintfloateval.
%
% \CALX_fcmp{X}{Y} (use in \ifcase): 0 if X = Y, 1 if X > Y, 2 if X < Y,
% 3 if unordered (an I?). Exact (no rounding). Two F values: the signs
% (0 for zero), then the orders 8e + D, then the sign of the exact
% difference \CALX_fsubx. I+, I- compare as infinities. Other inputs
% (\CALX_fc_x): each operand as an exact pair {p}{q} of F values
% (\CALX_fcq; q empty for 1): F itself; M: \CALX_fmx_c of calxfp (the
% digit count from the top block), zero F+0.0.; raw strict A[N] (or bare
% A, A/B as in compiled functions: [0] appended, ignored if [N] present): p by
% \CALX_ffromraw; A/B[N]: p of A[N], q of B[0] (B > 0). X = p/q, Y = r/s:
% p and r compared if q, s are empty, else p s and r q (\CALX_fmulx,
% exact), by \CALX_fc_n.
%
% \calxFpLt, \calxFpGt, \calxFpLtorEq, \calxFpGtorEq: 1 or 0, an I?
% operand signals InvalidOperation (value 0), as Python's Decimal;
% \calxFpEq, \calxFpNotEq: I? is unequal to everything, no signal.
%
% The operands come from the parsers: their tag may have catcode 11
% (values stored in the meaning of a compiled function, read from a
% file). \CALX_fc_as and \CALX_fc_bs apply \string to the first token of
% each operand after its f-expansion: the copies handed to \CALX_fsubx,
% whose patterns contain F of catcode 12, then have a catcode 12 tag.
%
% Expanded-operand entry: X\xint:Y\xint:, both input values are
% already f-expanded.  The first token of each is normalized by \string
% before entering the common comparison kernel.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fcmp #1%
   {\romannumeral0\expandafter\CALX_fc_as\romannumeral`&&@#1\xint:}%
\def\CALX_fcmp_in #1\xint:#2\xint:%
   {\expandafter\CALX_fc_ai\string#1\xint:#2\xint:}%
\def\CALX_fc_ai #1\xint:#2\xint:%
   {\expandafter\CALX_fc_bs\romannumeral`&&@#2\xint:#1\xint:}%
\def\CALX_fc_as{\expandafter\CALX_fc_a\string}%
\def\CALX_fc_a #1\xint:#2%
   {\expandafter\CALX_fc_bs\romannumeral`&&@#2\xint:#1\xint:}%
\def\CALX_fc_bs{\expandafter\CALX_fc_b\string}%
\def\CALX_fc_b #1#2\xint:#3%
{%
    \if I#3\xint_dothis{\CALX_fc_bi #1{#2}}\fi
    \if I#1\xint_dothis{\CALX_fc_bj #1{#2}#3}\fi
    \if F\if F#1#3\else Z\fi
      \xint_dothis{\CALX_fc_bn #1{#2}#3}\fi
    \xint_orthat{\CALX_fc_bx #1{#2}#3}%
}%
\def\CALX_fc_bi #1#2#3\xint:{\CALX_fc_i#3\xint:#1#2\xint:}%
\def\CALX_fc_bj #1#2#3#4\xint:{\CALX_fc_j#2\xint:#3#4\xint:}%
\def\CALX_fc_bn #1#2#3#4\xint:%
   {\CALX_fc_n{#3#4}{#1#2}#3#4\xint:#1#2\xint:}%
\def\CALX_fc_bx #1#2#3#4\xint:{\CALX_fc_x{#3#4}{#1#2}}%
\def\CALX_fc_x #1#2%
   {\expandafter\CALX_fc_xa\expanded{\CALX_fcq{#1}\CALX_fcq{#2}}}%
\def\CALX_fc_xa #1#2#3#4%
{%
    \if\relax\detokenize{#2#4}\relax
      \xint_dothis{\CALX_fc_n{#1}{#3}#1\xint:#3\xint:}\fi
    \xint_orthat{\expandafter\CALX_fc_xb\expanded
      {{\CALX_fcmul{#1}{#4}}{\CALX_fcmul{#3}{#2}}}}%
}%
\def\CALX_fc_xb #1#2{\CALX_fc_n{#1}{#2}#1\xint:#2\xint:}%
\def\CALX_fcmul #1#2%
   {\if\relax\detokenize{#2}\relax\xint_dothis{#1}\fi
    \xint_orthat{\romannumeral0\CALX_fmulx{#1}{#2}}}%
\def\CALX_fcq #1{\CALX_fcq_a #1\xint:}%
\def\CALX_fcq_a #1#2\xint:%
{%
    \if F#1\xint_dothis{{#1#2}{}}\fi
    \if M#1\xint_dothis{{\CALX_fcq_m #2\xint:}{}}\fi
    \xint_orthat{\CALX_fcq_r #1#2[0]\xint:}%
}%
\catcode`F=12 \catcode`N=12
\def\CALX_fcq_m #1#2.#3.#4\xint:%
   {\ifnum#2=\xint_c_ \xint_dothis{F+0.0.}\fi
    \xint_orthat{\romannumeral0\CALX_fmx_c N#1#2.#4\xint:{#3}}}%
\catcode`F=11 \catcode`N=11
\def\CALX_fcq_r #1[#2]#3\xint:{\CALX_fcq_s #1/1/\xint:{#2}}%
\def\CALX_fcq_s #1/#2/#3\xint:#4%
   {{\romannumeral0\CALX_ffromraw{#1[#4]}}%
    {\if\relax\detokenize{#3}\relax\else
       \romannumeral0\CALX_ffromraw{#2[0]}\fi}}%
%    \end{macrocode}
%\begin{lverb}
% X = I#1, Y any: I? unordered; I+ = I+, I+ > Y; I- = I-, I- < Y.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fc_i #1\xint:#2#3\xint:%
{%
    \if ?#1\xint_dothis{ 3}\fi
    \if I#2\xint_dothis{\CALX_fc_ii #1#3\xint:}\fi
    \if -#1\xint_dothis{ 2}\fi
    \xint_orthat{ 1}%
}%
\def\CALX_fc_ii #1#2#3\xint:%
{%
    \if ?#2\xint_dothis{ 3}\fi
    \if #1#2\xint_dothis{ 0}\fi
    \if -#1\xint_dothis{ 2}\fi
    \xint_orthat{ 1}%
}%
%    \end{macrocode}
%\begin{lverb}
% Y = I#1, X not I.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fc_j #1\xint:#2\xint:%
{%
    \if ?#1\xint_dothis{ 3}\fi
    \if -#1\xint_dothis{ 1}\fi
    \xint_orthat{ 2}%
}%
%    \end{macrocode}
%\begin{lverb}
% {X}{Y}X\xint:Y\xint:, X = F<sX><DX>.<eX>.<blocks>, Y the same: the
% headers are read, Y's blocks are gobbled by \CALX_fc_o.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fc_n #1#2#3#4#5.#6.#7\xint:{\CALX_fc_m{#1}{#2}#4{#5}{#6}}%
\def\CALX_fc_m #1#2#3#4#5#6#7#8.#9.%
{%
    \expandafter\CALX_fc_o\the\numexpr
      \ifnum#4=\xint_c_ 0\else#31\fi-(\ifnum#8=\xint_c_ 0\else#71\fi)%
    \expandafter.\the\numexpr\xint_c_viii*(#5-#9)+#4-#8.#3{#1}{#2}%
}%
\def\CALX_fc_o #1.#2.#3#4#5#6\xint:%
{%
    \ifnum#1>\xint_c_ \xint_dothis{ 1}\fi
    \ifnum#1<\xint_c_ \xint_dothis{ 2}\fi
    \ifnum#2>\xint_c_ \xint_dothis{\CALX_fc_t#3{ 2}{ 1}}\fi
    \ifnum#2<\xint_c_ \xint_dothis{\CALX_fc_t#3{ 1}{ 2}}\fi
    \xint_orthat
      {\expandafter\CALX_fc_s\romannumeral0\CALX_fsubx{#4}{#5}\xint:}%
}%
\def\CALX_fc_t #1%
   {\if-#1\expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo\fi}%
\def\CALX_fc_s #1#2#3.#4\xint:%
   {\ifnum#3=\xint_c_ \xint_dothis{ 0}\fi\if-#2\xint_dothis{ 2}\fi
    \xint_orthat{ 1}}%
\def\calxFpLt #1#2%
   {\romannumeral0\ifcase\expandafter\CALX_fcmp_in\expanded{#1\xint:#2\xint:}
    \xint_afterfi\CALX_fpzero\or
    \xint_afterfi\CALX_fpzero\or\xint_afterfi\CALX_fpone\else\xint_afterfi\CALX_fpcnan\fi}%
\def\calxFpGt #1#2%
   {\romannumeral0\ifcase\expandafter\CALX_fcmp_in\expanded{#1\xint:#2\xint:}
    \xint_afterfi\CALX_fpzero\or
    \xint_afterfi\CALX_fpone\or\xint_afterfi\CALX_fpzero\else\xint_afterfi\CALX_fpcnan\fi}%
\def\calxFpLtorEq #1#2%
   {\romannumeral0\ifcase\expandafter\CALX_fcmp_in\expanded{#1\xint:#2\xint:}
    \xint_afterfi\CALX_fpone\or
    \xint_afterfi\CALX_fpzero\or\xint_afterfi\CALX_fpone\else\xint_afterfi\CALX_fpcnan\fi}%
\def\calxFpGtorEq #1#2%
   {\romannumeral0\ifcase\expandafter\CALX_fcmp_in\expanded{#1\xint:#2\xint:}
    \xint_afterfi\CALX_fpone\or
    \xint_afterfi\CALX_fpone\or\xint_afterfi\CALX_fpzero
    \else\xint_afterfi\CALX_fpcnan\fi}%
\def\calxFpEq #1#2%
   {\romannumeral0\ifcase\expandafter\CALX_fcmp_in\expanded{#1\xint:#2\xint:}
    \xint_afterfi\CALX_fpone\else
    \xint_afterfi\CALX_fpzero\fi}%
\def\calxFpNotEq #1#2%
   {\romannumeral0\ifcase\expandafter\CALX_fcmp_in\expanded{#1\xint:#2\xint:}
    \xint_afterfi\CALX_fpzero\else
    \xint_afterfi\CALX_fpone\fi}%
\def\CALX_fpcnan{\expandafter\CALX_fpb\romannumeral`&&@\CALX_fcnan}%
%    \end{macrocode}
%\begin{lverb}
% \calxFpAbs: F, M, I+, I-, I? or raw (strict A[N], A/B[N]: a leading -
% removed, \CALX_fabs_r); the tag token kept.
%\end{lverb}
%    \begin{macrocode}
\def\calxFpAbs #1%
   {\romannumeral0\expandafter\CALX_fabs\romannumeral`&&@#1\xint:}%
\def\CALX_fabs #1%
   {\if F#1\expandafter\CALX_fabs_f\else\expandafter\CALX_fabs_x\fi #1}%
\def\CALX_fabs_f #1#2#3\xint:{ #1+#3}%
\def\CALX_fabs_x #1#2\xint:%
   {\if I#1\xint_dothis{\CALX_fabs_i#1#2}\fi
    \if M#1\xint_dothis{\CALX_fabs_f#1#2\xint:}\fi
    \xint_orthat{\CALX_fabs_r#1#2}}%
\def\CALX_fabs_r #1%
   {\if-#1\expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo
    \fi{ }{ #1}}%
\def\CALX_fabs_i #1#2%
   {\if ?#2\expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo
    \fi{ #1#2}{ #1+}}%
%    \end{macrocode}
%\begin{lverb}
% calx: max(), min() of \xintfloateval: \calxFpMaxof, \calxFpMinof
% {X1}{X2}...^: Burnol's 1.4p \XINT_maxof/\XINT_minof loops (xintfrac),
% \xintmax/\xintmin replaced by \CALX_fmax/\CALX_fmin (selection by
% \CALX_fcmp, no rounding); each item is f-expanded once and the value
% returned is expanded; empty list: 0/1[0]. An unordered comparison (I?)
% signals InvalidOperation and keeps the current value.
%\end{lverb}
%    \begin{macrocode}
\def\calxFpMaxof {\romannumeral0\CALX_maxof}%
\def\CALX_maxof#1%
{%
    \xint_gob_til_^ #1\CALX_maxof_empty ^%
    \expandafter\CALX_maxof_loop\romannumeral`&&@#1\xint:
}%
\def\CALX_maxof_empty ^#1\xint:{ 0/1[0]}%
\def\CALX_maxof_loop #1\xint:#2%
{%
    \xint_gob_til_^ #2\CALX_maxof_e ^%
    \expandafter\CALX_maxof_loop\romannumeral0\CALX_fmax{#1}{#2}\xint:
}%
\def\CALX_maxof_e ^#1\CALX_fmax #2#3\xint:{ #2}%
\def\calxFpMinof {\romannumeral0\CALX_minof}%
\def\CALX_minof#1%
{%
    \xint_gob_til_^ #1\CALX_minof_empty ^%
    \expandafter\CALX_minof_loop\romannumeral`&&@#1\xint:
}%
\def\CALX_minof_empty ^#1\xint:{ 0/1[0]}%
\def\CALX_minof_loop #1\xint:#2%
{%
    \xint_gob_til_^ #2\CALX_minof_e ^%
    \expandafter\CALX_minof_loop\romannumeral0\CALX_fmin{#1}{#2}\xint:
}%
\def\CALX_minof_e ^#1\CALX_fmin #2#3\xint:{ #2}%
\def\CALX_fmax #1#2{\expandafter\CALX_fmax_a\expandafter1\romannumeral`&&@#2\xint:{#1}}%
\def\CALX_fmin #1#2{\expandafter\CALX_fmax_a\expandafter2\romannumeral`&&@#2\xint:{#1}}%
\def\CALX_fmax_a #1#2\xint:#3%
   {\expandafter\CALX_mx_d\expandafter#1\romannumeral`&&@\CALX_fcmp{#2}{#3}.{#3}{#2}}%
\def\CALX_mx_d #1#2.#3#4%
{%
    \if 3#2\xint_dothis{\CALX_mx_sig{#3}}\fi
    \if #1#2\xint_dothis{ #4}\fi
    \xint_orthat{ #3}%
}%
\def\CALX_mx_sig #1%
   {\XINT_signalcondition{InvalidOperation}{max/min with I?}{}{ #1}}%
%    \end{macrocode}
%\begin{lverb}
% calx: floor(), ceil(), trunc(), round() (one argument) and frac() of
% \xintfloateval, exact (no rounding to P). I+, I-, I? unchanged;
% frac(I+-) = 0.
%
% F values: trunc by \CALX_ti_f (calxfp). floor, ceil: trunc, then -1
% (+1) by \CALX_fsubx (\CALX_faddx) if the result differs from X and
% X < 0 (X > 0). round: trunc of X + 1/2 (X - 1/2 if X < 0). frac:
% X - trunc(X).
%
% Raw values (A, A[N], A/B, A/B[N]) and M values: calxfp's \CALX_fintn
% with the kind macro (\CALX_fintk_f floor, \CALX_fintk_c ceil,
% \CALX_fintk_r round, \CALX_fintk_t trunc), result \CALX_fx_c 0.N.
% frac (\CALX_fl_kq) of a raw value: B = 1, the exact F value of A[N]
% goes to the F path; B > 1, the raw R/B[min(N,0)], with R the remainder
% of the truncated division (\CALX_nmodtrunc) of A 10^max(N,0) by B
% 10^max(-N,0); M values: 0. The kind macros, and \CALX_fl_kq for frac,
% also serve as markers (\ifx) in the F path.
%
% The entries apply \string to the first token of X after its
% f-expansion (\CALX_ti_s, \CALX_fl_s): X is handed on to \CALX_fsubx,
% \CALX_faddx and \CALX_fcmp, and its tag may have catcode 11 when it
% comes from the meaning of a compiled function or from a file.
%\end{lverb}
%    \begin{macrocode}
\edef\CALX_fonec{\romannumeral0\CALX_ffromraw{1[0]}}%
\edef\CALX_fhalfc{\romannumeral0\CALX_ffromraw{5[-1]}}%
\def\CALX_fl_kq {q}%
\def\calxFpTrunc #1%
   {\romannumeral0\expandafter\CALX_ti_s\romannumeral`&&@#1\xint:}%
\def\calxFpToM #1%
   {\romannumeral0\expandafter\CALX_ftom_a\romannumeral`&&@#1\xint:}%
\def\CALX_ti_s{\expandafter\CALX_ti_a\string}%
\def\calxFpITrunc #1{\calxFpTrunc}%
\def\CALX_ti_a #1%
   {\if F#1\expandafter\CALX_ti_f\else\expandafter\CALX_ti_x\fi #1}%
\def\CALX_ti_x #1%
   {\if I#1\expandafter\CALX_ti_xi\else\expandafter\CALX_ti_xn\fi #1}%
\def\CALX_ti_xi #1#2\xint:{ #1#2}%
\def\CALX_ti_xn #1#2\xint:%
   {\expandafter\CALX_fx_c\expandafter0\expandafter.%
    \romannumeral0\CALX_fintn\CALX_fintk_t#1#2\xint:\xint:}%
%    \end{macrocode}
%\begin{lverb}
% floor, ceil, round, frac: the trunc of F values, then a correction;
% the last token is the kind macro.
%\end{lverb}
%    \begin{macrocode}
\def\calxFpFloor #1%
   {\romannumeral0\expandafter\CALX_fl_s\romannumeral`&&@#1\xint:%
    \CALX_fintk_f}%
\def\calxFpCeil #1%
   {\romannumeral0\expandafter\CALX_fl_s\romannumeral`&&@#1\xint:%
    \CALX_fintk_c}%
\def\calxFpIRound #1#2%
   {\romannumeral0\expandafter\CALX_fl_s\romannumeral`&&@#2\xint:%
    \CALX_fintk_r}%
\def\calxFpFrac #1%
   {\romannumeral0\expandafter\CALX_fl_s\romannumeral`&&@#1\xint:\CALX_fl_kq}%
\def\CALX_fl_s{\expandafter\CALX_fl_a\string}%
\def\CALX_fl_a #1%
   {\if F#1\expandafter\CALX_fl_f\else\expandafter\CALX_fl_x\fi #1}%
\def\CALX_fl_x #1#2\xint:#3%
{%
    \if I#1\xint_dothis{\CALX_fl_i#3#1#2}\fi
    \ifx#3\CALX_fl_kq\xint_dothis{\CALX_fl_fr #1#2\xint:}\fi
    \xint_orthat{\expandafter\CALX_fx_c\expandafter0\expandafter.%
      \romannumeral0\CALX_fintn#3#1#2\xint:\xint:}%
}%
\def\CALX_fl_fr #1#2\xint:%
   {\if M#1\xint_dothis{\CALX_ffr_a 0[0]\xint:}\fi
    \xint_orthat{\CALX_fl_fa #1#2[0]\xint:}}%
\def\CALX_fl_fa #1[#2]#3\xint:{\CALX_fl_fb #1/1/\xint:{#2}}%
\def\CALX_fl_fb #1/#2/#3\xint:{\CALX_fl_fd #2\xint:{#1}{#2}}%
\def\CALX_fl_fd #1#2\xint:#3#4#5%
   {\if1#1\if\relax\detokenize{#2}\relax\CALX_fl_fj\fi\fi
    \expandafter\CALX_fl_fc\romannumeral0\CALX_nmodtrunc
      {\CALX_nshl{#5}{\CALX_nfromraw{#3}}}%
      {\CALX_nshl{-#5}{\CALX_nfromraw{#4}}}\xint:{#4}{#5}{#3}}%
\def\CALX_fl_fj #1\xint:#2#3#4%
   {\fi\fi\expandafter\CALX_fl_f\romannumeral0\CALX_ffr_a#4[#3]\xint:\xint:%
    \CALX_fl_kq}%
\def\CALX_fl_fc #1\xint:#2#3#4%
   {\expanded{ \romannumeral0\CALX_ntoraw{#1}/#2%
    [\ifnum#3<\xint_c_ #3\else0\fi]}}%
\def\CALX_fl_i #1%
   {\ifx#1\CALX_fl_kq\expandafter\CALX_fl_ii\else\expandafter\space\fi}%
\def\CALX_fl_ii #1#2{\if ?#2\xint_dothis{ #1#2}\fi\xint_orthat\CALX_fpzero}%
\def\CALX_fl_f #1#2#3\xint:#4%
{%
    \ifx#4\CALX_fintk_r\xint_dothis{\CALX_fl_r#2{#1#2#3}}\fi
    \ifx#4\CALX_fl_kq\xint_dothis
      {\expandafter\CALX_fl_q\romannumeral0\CALX_ti_a#1#2#3\xint:\xint:%
       {#1#2#3}}\fi
    \xint_orthat
      {\expandafter\CALX_fl_b\romannumeral0\CALX_ti_a#1#2#3\xint:\xint:%
       #2#4{#1#2#3}}%
}%
\def\CALX_fl_q #1\xint:#2{\CALX_fsubx{#2}{#1}}%
\def\CALX_fl_r #1#2%
   {\expandafter\CALX_ti_a\romannumeral0%
    \if-#1\expandafter\CALX_fsubx\else\expandafter\CALX_faddx\fi
    {#2}\CALX_fhalfc\xint:}%
% floor: X < 0 and trunc(X) != X: trunc - 1; ceil: X > 0, != X: + 1.
\def\CALX_fl_b #1\xint:#2#3#4%
{%
    \ifx#3\CALX_fintk_f\if-#2\CALX_fl_c\fi\else\if-#2\else\CALX_fl_c\fi\fi
    \CALX_fl_e{#1}{#4}#3%
}%
\def\CALX_fl_e #1#2#3{ #1}%
\def\CALX_fl_c #1\CALX_fl_e #2#3#4%
{%
    \fi\fi
    \ifcase\CALX_fcmp{#2}{#3} \xint_afterfi{ #2}%
    \else\xint_afterfi{\ifx#4\CALX_fintk_f\expandafter\CALX_fsubx\else
                       \expandafter\CALX_faddx\fi{#2}\CALX_fonec}\fi
}%
%    \end{macrocode}
% \subsection{Loading libraries}
%\begin{lverb}
% calx: calxtrig is loaded instead of xinttrig, calxlog (log function)
% instead of xintlog. The \xinteval hooks and the constants Pi, ... are
% defined at the end of calxtrig.tex (s50), the log family's in calxlog.tex.
% Due to \XINTsetcatcodes done a bit earlier the ! is catcode 12.
%
% Formerly xintexpr loaded xintlog which loaded poormanlog which
% defines \@namedef. Backporting it here, it is a short name and is
% provided by LaTeX which will be used by vast majority of xint users.
%\end{lverb}
%    \begin{macrocode}
\if1\ifx\@namedef\JFBUundefined1\else\ifx\@namedef\relax1\else0\fi\fi
  \def\@namedef#1{\expandafter\def\csname #1\endcsname}%
  \def\@nameuse#1{\csname #1\endcsname}%
\fi
\input calxtrig.tex\relax
\input calxlog.tex\relax
\CALX_restorecc\let\CALX_restorecc\undefined
%    \end{macrocode}
% \subsection{\csh{xintreloadxintlog}, \csh{xintreloadxinttrig}, \csh{xintreloadscilibs}}
% Only for backward compatibility. TODO: make them emit messages to inform user
% they are no-opts.
%    \begin{macrocode}
\let\xintreloadxinttrig\empty
\let\xintreloadxintlog\empty
\let\xintreloadscilibs\empty
%    \end{macrocode}
% \subsection{\csh{calxeval}, \csh{calxinteval}}
%    \begin{macrocode}
\let\calxeval\xintfloateval
\let\calxinteval\xintiieval
\XINTrestorecatcodesendinput%
%    \end{macrocode}
% \setcounter{xintMacroCnt}{\the\numexpr452+\value{xintMacroCnt}\relax}
% \StoreCodelineNo {calx}
% \etocsettocdepth{subsubsection}
% \cleardoublepage\let\calxnameUp\undefined
%\gardesactifs
%\let</calx>\relax
%\let<*calxlog>\gardesinactifs
%</calx>------------------------------------------------------
%<*calxlog>^^A-------------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname calxlognameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section{Library \calxlognameimp implementation}
% \RaisedLabel{sec:calxlogimp}
% \addedcalx{2.0a1}
%
% \localtableofcontents
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
% The code of this subsection is copied over from the xint packages, with
% the package names changed.
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode64=11   % @
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \catcode35=6    % #
  \catcode33=12   % !
  \def\empty{}\def\space{ }\newlinechar10
  \expandafter\let\expandafter\l\csname ver@calxlog.tex\endcsname
  \expandafter\let\expandafter\c\csname ver@calx.sty\endcsname
  \expandafter
    \ifx\csname PackageWarningNoLine\endcsname\relax
      \def\y#1#2{\immediate\write128{^^JPackage #1 Warning:^^J%
                 \space\space\space\space#2.^^J}}%
    \else
      \def\y#1#2{\PackageWarningNoLine{#1}{#2}}%
    \fi
  % attention that in this file \z by default does \endinput.
  \def\z{\endgroup\endinput}%
  \expandafter\ifx\csname numexpr\endcsname\relax
    \y{calx}{\numexpr not available, aborting input}%
  \else
%    \end{macrocode}
% BEWARE: on 2026/10/09 I hit a problem I knew about from years ago but
% forgot.  It is known that TeX executes all macros on the line where
% |\endinput| is found.  But imagine |\endinput\input foo.tex\relax|,
% then what will happen is that only the first line of foo.tex
% (if its EOL is not hidden by a comment char) is executed, so basically
% foo.tex is not read beyond that. I will put |\endinput| last in both
% situations, as is logical anyhow.
%    \begin{macrocode}
      \ifx\c\relax % calx.sty not yet loaded.
        \ifx\PackageWarningNoLine\relax
          \y{calx}{%
             Loading of calxlog.tex should happen via
             \string\input\space calx.sty\relax^^J\space\space\space\space
             Will try that now%
          }%
          \def\z{\endgroup
                 \input calx.sty\relax\endinput}%
        \else
          \y{calx}{%
             Bad move! Inputting calxlog.tex directly in a LaTeX\MessageBreak
             document is forbidden! Simply use \string\usepackage{calx}\MessageBreak
             in the preamble, as every obedient LaTeX user does!\MessageBreak
             Trying to recover now, hoping to be in the preamble%
          }%
          \def\z{\endgroup
                 \RequirePackage{calx}\endinput}%
        \fi
      \else % either calx.sty is trying to load us, or a second loading is
            % attempted on us by \input. Abort if the latter.
        \ifx\l\relax
            \def\z{\endgroup}%
        \else
            \y{calx}{calxlog.tex already loaded! Aborting this input}%
        \fi
      \fi
  \fi
\z%
%    \end{macrocode}
%\begin{lverb}
% We arrive here only after a \XINTsetcatcodes which is done (near its tail)
% in calx.sty.  In particular ! has its normal catcode 12.  But attention:
% the \XINTsetcatcode does nothing with the letters F, I, N so we have to
% be careful whenever we set them to be of catcode "other" (=12).
%
% There appears to be a problem with miniltx which provides \ProvidesFile
% but does not let it define \ver@calxlog.tex. So we define it always.
%\end{lverb}
% \subsection{Package identification}
%    \begin{macrocode}
\ifdefined\ProvidesFile
  \ProvidesFile{calxlog.tex}%
  [2026/11/01 v2.0a1 log, exp, etc for xintexpr/calx (JFB)]%
\fi
\expandafter\def\csname ver@calxlog.tex\endcsname
  {2026/11/01 v2.0a1 calx log library}%
%    \end{macrocode}
% \subsection{Loading data tables}
%    \begin{macrocode}
\catcode`\_ 11\catcode`\: 11
%    \end{macrocode}
%\begin{lverb}
% Natural logarithm, P1..P8: tables (records in calxlogdata.tex):
% \CALX_lgUT<ab> (ab = 10..99) #1 ->
% #1c.t3.t2.t1.t0., c = floor(10^4/(ab+1)), round(10^12 ln(10^3/c)) in
% limbs; \CALX_lgUV<j> (j = 0..101) -> e2.e1.e0., round(10^12 ln(1+j/10^3)).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_lgULoadT #1.#2.#3.#4.#5.#6,%
{%
    \ifnum#1=\xint_c_ \expandafter\xint_gobble_i\else
    \expandafter\def\csname CALX_lgUT#1\endcsname##1{##1#2.#3.#4.#5.#6.}\fi
    \CALX_lgULoadT
}%
\def\CALX_lgULoadV #1.#2.#3.#4,%
{%
    \ifnum#1<\xint_c_ \expandafter\xint_gobble_i\else
    \expandafter\def\csname CALX_lgUV#1\endcsname{#2.#3.#4.}\fi
    \CALX_lgULoadV
}%
\input calxlogdata.tex\relax
%    \end{macrocode}
% \subsection{\csh{calxFpLog}, \csh{calxRawLog}}
%\begin{lverb}
% Syntax of the public macros of this file (f-expandable; X, A, B
% f-expanded F, I or raw values; P = \XINTdigits; results F or I values
% rounded to P digits; the \calxRaw<Name> variants give the same value as
% xint raw A[N]):
%(
%  \calxFpLog{X}, \calxFpLogOnePlus{X}, \calxFpLogTen{X}   ln, ln(1+X), log10
%:  \calxFpExp{X}, \calxFpPowTen{X}, \calxFpExpMinusOne{X}  e^X, 10^X, e^X-1
%:  \calxFpPow{A}{B}                                       A^B
%:  \calxFpSinh{X}, \calxFpCosh, \calxFpTanh, \calxFpCoth, \calxFpSech,
%:  \calxFpCsch, \calxFpAsinh, \calxFpAcosh, \calxFpAtanh, \calxFpAcoth,
%:  \calxFpAsech, \calxFpAcsch                           hyperbolic
%)
% Internal entries (use with \romannumeral0; Y an F value rounded by
% \CALX_fround, followed by its \xint:):
%(
%  \CALX_lga Y\xint:   -> <space>ln Y        (dispatch by P)
%:  \CALX_lpa Y\xint:   -> <space>ln(1 + Y)
%:  \CALX_exa Y\xint:   -> <space>e^Y         (Y rounded at P + 14 digits)
%)
% and, f-expanded by its callers (\CALX_fnround, \CALX_fmulx),
%(
%  \CALX_lpLP P.+<D>.<e>.<blocks>\xint:  -> ln, F value at precision P
%)
% (internal log of a positive F value, not rounded to P digits; P <= 112).
%\end{lverb}
%    \begin{macrocode}
\expandafter\def\csname CALX_lgHsF-\endcsname#1\xint:
           {\CALX_nsig{InvalidOperation}{log(x), x < 0}{}}%
\expandafter\def\csname CALX_lgHsI+\endcsname#1\xint:{ I+}%
\expandafter\def\csname CALX_lgHsI-\endcsname#1\xint:
           {\CALX_nsig{InvalidOperation}{log(-inf)}{}}%
\expandafter\def\csname CALX_lgHsI?\endcsname#1\xint:{ I?}%
\def\calxFpLog{\romannumeral0\expandafter\CALX_lga
    \romannumeral0\CALX_fround{\XINTdigits}}%
\def\calxRawLog #1{\romannumeral0\CALX_ftoraw{\calxFpLog{#1}}}%
\def\CALX_lgnfl #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpLog#3}}%
}%
\def\CALX_lgnex #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxRawLog#3}}%
}%
\let\XINT_flexpr_func_log\CALX_lgnfl
\let\XINT_expr_func_log\CALX_lgnex
%    \end{macrocode}
% \subsection{Natural logarithm, P1..P8}
%\begin{lverb}
% P1..P8 entry (\CALX_lga): the input is already rounded to P <= 8 digits,
% F+<D>.<e>.<blocks>\xint:, D <= 16. E = D - 1 + 8e; |E| >= 4000: the P16
% code; else M = the 8 leading digits (\CALX_Lin<n> of P16, padded).
%\end{lverb}
%    \begin{macrocode}
\expandafter\let\csname CALX_lgUtagF-\expandafter\endcsname
   \csname CALX_lgHsF-\endcsname
\expandafter\let\csname CALX_lgUtagI+\expandafter\endcsname
   \csname CALX_lgHsI+\endcsname
\expandafter\let\csname CALX_lgUtagI-\expandafter\endcsname
   \csname CALX_lgHsI-\endcsname
\expandafter\let\csname CALX_lgUtagI?\expandafter\endcsname
   \csname CALX_lgHsI?\endcsname
\expandafter\def\csname CALX_lgUtagF+\endcsname #1.#2.#3\xint:%
{%
    \ifnum#1=\xint_c_ \xint_dothis{\CALX_nsig{DivisionByZero}{log(0)}{-}}\fi
    \xint_orthat{\expandafter\CALX_lgUb
      \the\numexpr#1-\xint_c_i+\xint_c_viii*#2.#1.#2.#3\xint:}%
}%
\def\CALX_lgUb #1.#2.#3.%
{%
    \ifnum\ifnum#1<\xint_c_ -\fi#1>3999
      \xint_dothis\CALX_lgUb_large\fi
    \xint_orthat\CALX_lgUb_regular #1.#2.#3.%
}%
\def\CALX_lgUb_large #1.#2.#3.#4\xint:%
   {\csname CALX_LtagF+\endcsname#2.#3.#4\xint:}%
\def\CALX_lgUb_regular #1.#2.#3.#4\xint:%
   {\csname CALX_Lin\ifnum#2>\xint_c_viii ii\else i\fi\endcsname
      \CALX_lgUa#4\xint:#1.#2.}%
\def\CALX_lgUa #1#2#3#4#5#6#7#8#9\relax{\CALX_lgUc #1#2.#1#2#3#4.#5#6#7#8.}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_lgUc ab.Mh.Ml.E.: classes by E: -1 (cm), 0 (cz), > 0 (cp), < -1 (cn)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_lgUc #1.#2.#3.#4.%
{%
    \csname CALX_lgUc\ifcase\numexpr#4+\xint_c_i\relax m\or z\else
      \ifnum#4>\xint_c_ p\else n\fi\fi\endcsname #1.#2.#3.#4.%
}%
\def\CALX_lgUcp{\CALX_lgUo\CALX_lgUfp}%
\def\CALX_lgUcn{\CALX_lgUo\CALX_lgUfn}%
%    \end{macrocode}
%\begin{lverb}
% near 1: x < 1.011 (E = 0), x >= 0.989 (E = -1)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_lgUcz #1.#2.%
{%
    \ifnum#2>1010 \expandafter\CALX_lgUo\expandafter\CALX_lgUfp
    \else\expandafter\CALX_lgUzz\fi #1.#2.%
}%
\def\CALX_lgUcm #1.#2.#3.%
{%
    \ifnum#2#3<98900000 \expandafter\CALX_lgUo\expandafter\CALX_lgUfn
    \else\expandafter\CALX_lgUzm\fi #1.#2.#3.%
}%
%    \end{macrocode}
%\begin{lverb}
% Ordinary path, fixed point 10^-12. \CALX_lgUo <chain>ab.Mh.Ml.E.
% A = 10^6 - c Mh, B = c Ml (u = (10^4 A - B) 10^-10); j; W = 10^12 u';
% S12 = 10^12 (u' + u'^2/2 + u'^3/3); the chain (\CALX_lgUfp$empty: E >= 0,
% \CALX_lgUfn$empty: E < 0) gets S12.e2.e1.e0.E.t3.t2.t1.t0.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_lgUo #1#2.{\csname CALX_lgUT#2\endcsname\CALX_lgUoa#1}%
\def\CALX_lgUoa #1.#2.#3.#4.#5.#6#7.#8.#9.%
{%
    \expandafter\CALX_lgUob\the\numexpr1000000-#1*#7\expandafter.%
    \the\numexpr#1*#8.#6#9.#2.#3.#4.#5.%
}%
\def\CALX_lgUob #1.#2.%
{%
    \expandafter\CALX_lgUoc
    \the\numexpr(#1*10000-#2)/(10000000-10*#1+#2/1000).#1.#2.%
}%
\def\CALX_lgUoc #1.#2.#3.%
{%
    \expandafter\CALX_lgUod
    \the\numexpr(#2*(1000+#1)-1000000*#1)*1000-#3*(1000+#1)/10.#1.%
}%
\def\CALX_lgUod #1.#2.#3%
{%
    \expandafter#3\the\numexpr#1+(#1/1000)*(#1/1000)/2000000
      +((#1/1000)*(#1/1000)/2000000)*(#1/1000)/1500000000\expandafter.%
    \romannumeral`&&@\csname CALX_lgUV#2\endcsname
}%
%    \end{macrocode}
%\begin{lverb}
% |y| 10^12 = s(E ln10 + ln m) 10^12, ln10 10^12 = 2|3025|8509|2994 + 0.045684
%\end{lverb}
%    \begin{macrocode}
\def\CALX_lgUfp #1.#2.#3.#4.#5.#6.#7.#8.#9.%
{%
    \expandafter\CALX_lgUw\the\numexpr#6+2*#5%
    \expandafter\CALX_LR\the\numexpr\CALX_Loff+#7-#2+3025*#5%
    \expandafter\CALX_LR\the\numexpr\CALX_Loff+#8-#3-#1/10000+8509*#5%
    \expandafter\CALX_LR\the\numexpr\CALX_Loff+#9-#4-#1+#1/10000*10000
      +2994*#5+#5*45684/1000000\relax!+-12.%
}%
\def\CALX_lgUfn #1.#2.#3.#4.#5.#6.#7.#8.#9.%
{%
    \expandafter\CALX_lgUw\the\numexpr-#6-2*#5%
    \expandafter\CALX_LR\the\numexpr\CALX_Loff-#7+#2-3025*#5%
    \expandafter\CALX_LR\the\numexpr\CALX_Loff-#8+#3+#1/10000-8509*#5%
    \expandafter\CALX_LR\the\numexpr\CALX_Loff-#9+#4+#1-#1/10000*10000
      -2994*#5-#5*45684/1000000\relax!--12.%
}%
%    \end{macrocode}
%\begin{lverb}
% Near-1 path: delta = d 10^-k, y = delta (1 + delta H'), Q = round(10^10
% delta H'); |y| = a (10^10 + Q) 10^-(k+10), a = |d| = a1 10^4 + a0.
% \CALX_lgUzh a1.d.a0.10^k.10^(k-1).<sign><z0>.
%\end{lverb}
%    \begin{macrocode}
\begingroup\catcode`F=12
\gdef\CALX_lgUzz #1.#2.#3.#4.%
{%
    \ifnum#2#3=10000000 \xint_dothis{ F+0.0.}\fi
    \xint_orthat{\expandafter\CALX_lgUzh\the\numexpr#2-1000\expandafter.%
      \the\numexpr#2#3-10000000.#3.10000000.1000000.+-17.}%
}%
\endgroup
\def\CALX_lgUzm #1.#2.#3.#4.%
{%
    \expandafter\CALX_lgUzh\the\numexpr9999-#2\expandafter.%
    \the\numexpr#2#3-100000000\expandafter.%
    \the\numexpr10000-#3.100000000.10000000.--18.%
}%
\def\CALX_lgUzh #1.#2.#3.#4.#5.%
{%
    \expandafter\CALX_lgUzb\the\numexpr
      #2*(-500000000+#2*(333333333+#2*(-250000000
      +#2*200000000/#4)/#4)/#4)/#5.#1.#3.%
}%
%    \end{macrocode}
%\begin{lverb}
% exact a (10^10 + Q): columns 100 a1 | 100 a0 + a1 Q1 | a1 Q0 + a0 Q1 | a0 Q0
%\end{lverb}
%    \begin{macrocode}
\def\CALX_lgUzb #1.#2.#3.%
{%
    \expandafter\CALX_lgUw\the\numexpr100*#2%
    \expandafter\CALX_LR\the\numexpr\CALX_Loff+#2*(#1/10000)+100*#3%
    \expandafter\CALX_LR\the\numexpr
                        \CALX_Loff+#2*(#1-#1/10000*10000)+#3*(#1/10000)%
    \expandafter\CALX_LR\the\numexpr\CALX_Loff+#3*(#1-#1/10000*10000)\relax!%
}%
%    \end{macrocode}
%\begin{lverb}
% Writer: T!l2!l1!l0!<sign><z0>. (|y| = T l2 l1 l0 10^z0): H = T l2, L = l1
% l0,
% n = digits of H (<= 9), v = n - P; M = round(H 10^8 + L)/10^(8+v));
% g = z0 + 8 + v; calxtrig's \CALX_dgoc M.b.g.<sign> writes the native.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_lgUw #1!#2!#3!#4!#5#6.%
{%
    \expandafter\CALX_lgUwa\the\numexpr\expandafter\CALX_nd_c
      \the\numexpr#1#2\relax{10}987654321\xint:-\XINTdigits.#1#2.#3#4.#6.#5%
}%
\def\CALX_lgUwa #1.#2.#3.#4.%
{%
    \expandafter\CALX_dgoc\the\numexpr\ifnum#1>\xint_c_ #2/\CALX_pten{#1}\else
      #2*\CALX_pten{-#1}+#3/\CALX_pten{8+#1}\fi
    \expandafter.\the\numexpr(2*(#4+8+#1)-7)/16\expandafter.%
                 \the\numexpr#4+8+#1.%
}%
%    \end{macrocode}
% \subsection{Natural logarithm, P9..P16}
%\begin{lverb}
% Natural logarithm, P9..P16.
% x = 10^E m, m = M 10^-15, M the 16-digit mantissa as limbs m1!m2!m3!m4!.
% Grid W = 24: V = 10^24 (1+t) as limbs v0!..v6! (v0 units limb, 0 or 1).
% Bootstrap 1+t0 = c m/10^4, c = nint(200000/(2a+1)), a = first two digits
% (unity zone: c = 10^4 if E = 0, 10^3 if E = -1, no constant at all).
% Stages k = 2,4,6 (classes B, C) or 2,4,6,8 (class A = [1.1,1.2) and the
% unity zone): 1+t <- (1+t)(1+j 10^-k), j = nint(-10R/(10^4+T)).
% Constants: tables for c, k=2, k=4 (calxlogdata.tex, \CALX_Lb<a>,
% \CALX_Ls<100j>, \CALX_Lt<j>); k=6,8 on the fly; ln(1+t) = t - t^2/2.
% Final sum in 8-digit pairs, one carry chain with E ln10 (|E| < 10^4);
% 10^4 <= |E|: exact native addition of E floor(10^24 ln10) 10^-24.
% Unity zone with |x-1| < 10^-4: direct series y = delta (1 - Q).
%\end{lverb}
%    \begin{macrocode}
\csname newcount\endcsname\CALX_Loff \CALX_Loff=1200000000
\csname newcount\endcsname\CALX_Lob \CALX_Lob=1000000000
\let\CALX_LQ\relax
\def\CALX_LR #1#2#3#4#5#6{+#1#2#3#4#5#6-120000!}%
\def\CALX_LRb #1#2#3#4#5#6{+#1#2#3#4#5#6-100000!}%
\def\CALX_LRz #1#2#3#4#5#6#7#8#9{+#1#2#3#4#5#6-120000\xint_gobble_i}%
\let\CALX_Lfr\CALX_fnround
%    \end{macrocode}
%\begin{lverb}
% entry: F+<D>.<e>.<blocks>\xint: ; n = ceil(D/8) blocks, E = D-1+8e
%\end{lverb}
%    \begin{macrocode}
\expandafter\def\csname CALX_LtagF+\endcsname #1.#2.#3\xint:%
{%
    \ifnum#1=\xint_c_ \xint_dothis{\CALX_nsig{DivisionByZero}{log(0)}{-}}\fi
    \xint_orthat{\expandafter\CALX_Ltb
                 \the\numexpr(#1+\xint_c_iii)/\xint_c_viii
      \expandafter.\the\numexpr#1-\xint_c_i+\xint_c_viii*#2.#1.#3\xint:}%
}%
\def\CALX_Ltb #1.#2.#3.#4\xint:%
   {\CALX_Lfr\XINTdigits{\csname CALX_Lin%
                         \romannumeral#1\endcsname\CALX_LM#4\xint:#2.#3.}}%
%    \end{macrocode}
%\begin{lverb}
% digits of M (MS first), padded with zeros; #1 continuation (shared
% with the generic path): n = 1..5 blocks, z = 8n - D leading zeros
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Lini #11#2!\xint:#3.#4.%
   {\csname CALX_Lgz\the\numexpr8-#4\endcsname
    #1#200000000000000000000000000000000\relax#3.}%
\def\CALX_Linii #11#2!1#3!\xint:#4.#5.%
   {\csname CALX_Lgz\the\numexpr16-#5\endcsname
    #1#3#200000000000000000000000000000000\relax#4.}%
\def\CALX_Liniii #11#2!1#3!1#4!\xint:#5.#6.%
   {\csname CALX_Lgz\the\numexpr24-#6\endcsname
    #1#4#3#200000000000000000000000000000000\relax#5.}%
\def\CALX_Liniv #11#2!1#3!1#4!1#5!\xint:#6.#7.%
   {\csname CALX_Lgz\the\numexpr32-#7\endcsname
    #1#5#4#3#200000000000000000000000000000000\relax#6.}%
\def\CALX_Linv #11#2!1#3!1#4!1#5!1#6!\xint:#7.#8.%
   {\csname CALX_Lgz\the\numexpr40-#8\endcsname
    #1#6#5#4#3#200000000000000000000000000000000\relax#7.}%
\expandafter\def\csname CALX_Lgz0\endcsname#1{#1}%
\expandafter\def\csname CALX_Lgz1\endcsname#1#2{#1}%
\expandafter\def\csname CALX_Lgz2\endcsname#1#2#3{#1}%
\expandafter\def\csname CALX_Lgz3\endcsname#1#2#3#4{#1}%
\expandafter\def\csname CALX_Lgz4\endcsname#1#2#3#4#5{#1}%
\expandafter\def\csname CALX_Lgz5\endcsname#1#2#3#4#5#6{#1}%
\expandafter\def\csname CALX_Lgz6\endcsname#1#2#3#4#5#6#7{#1}%
\expandafter\def\csname CALX_Lgz7\endcsname#1#2#3#4#5#6#7#8{#1}%
%    \end{macrocode}
%\begin{lverb}
% a = the first two digits, read as tokens
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LM #1#2#3#4#5#6#7#8{\CALX_LMb{#1#2.#1#2#3#4!#5#6#7#8!}}%
\def\CALX_LMb #1#2#3#4#5#6#7#8#9{\CALX_LMc{#1#2#3#4#5!#6#7#8#9!}}%
\def\CALX_LMc #1#2\relax{\CALX_Lclb#1}%
%    \end{macrocode}
%\begin{lverb}
% classification: a.m1!m2!m3!m4!E.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Lclb #1.#2!#3!#4!#5!#6.%
{%
    \ifnum#6=\xint_c_ \xint_dothis{\CALX_LcZ#1.#2!#3!#4!#5!}\fi
    \ifnum#6=-\xint_c_i \xint_dothis{\CALX_LcM#1.#2!#3!#4!#5!}\fi
    \ifnum\ifnum#6<\xint_c_ -\fi#6>9999
      \xint_dothis{\CALX_LcE#1.#2!#3!#4!#5!#6.}\fi
    \xint_orthat{\expandafter\CALX_LB\the\numexpr10*(200000/(2*#1+1));%
      #2!#3!#4!#5!\CALX_LsBa#1;#6;}%
}%
%    \end{macrocode}
%\begin{lverb}
% E = 0: a = 10 is the unity zone [1,1.1): x = 1 exact zero; x < 1.0001
% direct series (\CALX_LUz); else stages 2..8 with c = 10^4. a = 11:
% class A. E = -1: a >= 90 (x <> 0.9) is the unity zone [0.9,1):
% x > 0.9999 direct series (\CALX_LUm); else stages 2..8 with c = 10^3.
%\end{lverb}
%    \begin{macrocode}
\begingroup\catcode`F=12
\gdef\CALX_LcZ #1.%
{%
    \ifnum#1>11 \xint_dothis\CALX_LcZ_high\fi
    \ifnum#1=11 \xint_dothis\CALX_LcZ_oneone\fi
    \xint_orthat\CALX_LcZ_unity #1.%
}%
\gdef\CALX_LcZ_high #1.#2!#3!#4!#5!%
{%
    \expandafter\CALX_LB
       \the\numexpr10*(200000/(2*#1+1));#2!#3!#4!#5!\CALX_LsBa#1;0;%
}%
\gdef\CALX_LcZ_oneone #1.#2!#3!#4!#5!%
{%
    \expandafter\CALX_LB
       \the\numexpr10*(200000/(2*#1+1));#2!#3!#4!#5!\CALX_LsAa#1;0;%
}%
\gdef\CALX_LcZ_unity #1.#2!#3!#4!#5!%
{%
    \ifnum\numexpr#2#3-10000000+#4#5\relax=\xint_c_ \xint_dothis{F+0.0.}\fi
    \ifnum#2#3<10001000 \xint_dothis{\CALX_LUz#2!#3!#4!#5!}\fi
    \xint_orthat{\CALX_LB100000;#2!#3!#4!#5!\CALX_LsAa0;0;}%
}%
\gdef\CALX_LcM #1.%
{%
    \ifnum#1<90 \xint_dothis\CALX_LcM_low\fi
    \xint_orthat\CALX_LcM_regular #1.%
}%
\gdef\CALX_LcM_low #1.#2!#3!#4!#5!%
{%
    \expandafter\CALX_LB
       \the\numexpr10*(200000/(2*#1+1));#2!#3!#4!#5!\CALX_LsBa#1;-1;%
}%
\gdef\CALX_LcM_regular #1.#2!#3!#4!#5!%
{%
    \ifnum\numexpr#2#3-90000000+#4#5\relax
       =\xint_c_ \xint_dothis{\expandafter\CALX_LB
       \the\numexpr10*(200000/(2*#1+1));#2!#3!#4!#5!\CALX_LsBa#1;-1;}\fi
    \ifnum#2#3<99990000
      \xint_dothis{\CALX_LB10000;#2!#3!#4!#5!\CALX_LsAa0;0;}\fi
    \ifnum\numexpr#2#3-99990000+#4#5\relax=\xint_c_
      \xint_dothis{\CALX_LB10000;#2!#3!#4!#5!\CALX_LsAa0;0;}\fi
    \xint_orthat{\CALX_LUm#2!#3!#4!#5!}%
}%
\endgroup
\def\CALX_LcE #1.#2!#3!#4!#5!#6.%
{%
    \CALX_faddx{\expandafter\CALX_LB\the\numexpr10*(200000/(2*#1+1));%
       #2!#3!#4!#5!\CALX_LsBa#1;0;}%
      {\CALX_fmulx{\romannumeral0\CALX_ffromraw{#6[0]}}{\CALX_Lzeta}}%
}%
\edef\CALX_Lzeta{\romannumeral0\CALX_ffromraw
                 {2302585092994045684017991[-24]}}%
%    \end{macrocode}
%\begin{lverb}
% bootstrap: J;m1!m2!m3!m4!<continuation>  ->  <cont>v0!...!v6!
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LB #1;#2!#3!#4!#5!#6%
{%
    \expandafter#6\the\numexpr\xint_c_\expandafter\CALX_LRb
    \the\numexpr\CALX_Lob\expandafter\CALX_LRb
    \the\numexpr\CALX_Lob+#1*#2\expandafter\CALX_LRb
    \the\numexpr\CALX_Lob+#1*#3\expandafter\CALX_LRb
    \the\numexpr\CALX_Lob+#1*#4\expandafter\CALX_LRb
    \the\numexpr\CALX_Lob+#1*#5\relax!0000!%
}%
%    \end{macrocode}
%\begin{lverb}
% stage kernels: <cont>J;v0!..v6!  ->  <cont>v0'!..v6'!J;
% V' = V + floor(J V'/10^(4a)), a = 1 (\CALX_LKa) or 2 (\CALX_LKb); the
% lowest column only gives its carry.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LKa #1#2;#3!#4!#5!#6!#7!#8!#9!%
{%
    \expandafter#1\the\numexpr#3\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#4+#2*#3\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#5+#2*#4\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#6+#2*#5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#7+#2*#6\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#8+#2*#7\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#9+#2*#8\expandafter\CALX_LRz
    \the\numexpr\CALX_Loff+#2*#9\relax!#2;%
}%
\def\CALX_LKb #1#2;#3!#4!#5!#6!#7!#8!#9!%
{%
    \expandafter#1\the\numexpr#3\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#4\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#5+#2*#3\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#6+#2*#4\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#7+#2*#5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#8+#2*#6\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#9+#2*#7\expandafter\CALX_LRz
    \the\numexpr\CALX_Loff+#2*#8\relax!#2;%
}%
\def\CALX_LKz #1#2;#3!#4!#5!#6!#7!#8!#9!{#1#3!#4!#5!#6!#7!#8!#9!0;}%
%    \end{macrocode}
%\begin{lverb}
% selectors: y = (v0-1)10^4 + v1 = floor(10^4 t) is T
% \CALX_Ldef <name><next><kernel><skip>{<factor>}{<selector>}
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Lsel #1#2#3#4;%
   {\ifnum#4=\xint_c_ \expandafter#2\else\expandafter#1\fi#3#4;}%
\def\CALX_Ldef #1#2#3#4#5#6%
   {\def#1##1!##2!##3!##4!{\expandafter\CALX_Lsel
      \expandafter#3\expandafter#4%
      \expandafter#2\the\numexpr#5(#6);##1!##2!##3!##4!}}%
%    \end{macrocode}
%\begin{lverb}
% stages k = 2,4,6: names #1,#2,#3, next #4, kernels shift 1 (#5),
% shift 2 (#6), skip (#7); stage k = 8: name, next, kernel, skip.
% Shared by P9..P16 and P17..P32.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Lsdef #1#2#3#4#5#6#7%
{%
    \CALX_Ldef#1#2#5#7{100*}%
      {-10*(((##1-1)*10000+##2)*10+##3/1000)/((##1-1)*10000+##2+10000)}%
    \CALX_Ldef#2#3#5#7{}%
      {-10*(((##1-1)*10000+##2)*1000+##3/10)/((##1-1)*10000+##2+10000)}%
    \CALX_Ldef#3#4#6#7{100*}%
      {-10*((((##1-1)*10000+##2)*10000+##3)*10+##4/1000)/%
       ((##1-1)*10000+##2+10000)}%
}%
\def\CALX_Lsdefd #1#2#3#4%
{%
    \CALX_Ldef#1#2#3#4{}%
      {-10*((((##1-1)*10000+##2)*10000+##3)*1000+##4/10)/%
       ((##1-1)*10000+##2+10000)}%
}%
\CALX_Lsdef\CALX_LsBa\CALX_LsBb\CALX_LsBc\CALX_LfB\CALX_LKa\CALX_LKb\CALX_LKz
\CALX_Lsdef\CALX_LsAa\CALX_LsAb\CALX_LsAc\CALX_LsAd\CALX_LKa\CALX_LKb\CALX_LKz
\CALX_Lsdefd\CALX_LsAd\CALX_LfA\CALX_LKb\CALX_LKz
%    \end{macrocode}
%\begin{lverb}
% final, stages 2,4,6: v0!..v6!J6;  (then J4;J2;a;E;)
% w = floor(10^14 t); pairs P1 = v1v2, P2 = v3v4, P3 = v5v6;
% j6 terms (series of -ln(1+j 10^-6)): -100j at limb 2, 5000j^2 at limb 4,
% -100j^3/3 at limb 5 (+ remainder at limb 6), j^4/4 - j^5/(5 10^6) at
% limb 6; -t^2/2 = -w^2/(2 10^8) at limb 5.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LfB #1!#2!#3!#4!#5!#6!#7!#8;%
{%
    \expandafter\CALX_LfBb\the\numexpr#8/100\expandafter;\the\numexpr
      (((#1-1)*10000+#2)*10000+#3)*1000000+%
       #4*100+#5/100;#8;#1!#2#3!#4#5!#6#7!%
}%
\def\CALX_LfBb #1;#2;#3;#4!#5!#6!#7!%
{%
    \expandafter\CALX_LTa\the\numexpr#4#5-100000000-#3\expandafter!%
    \the\numexpr#6+#3*#3/2\expandafter!%
    \the\numexpr#7-(100*#1*#1*#1-3*(100*#1*#1*#1/3))*3333+#1*#1*#1*#1/4%
      -#1*#1*#1*#1*#1/5000000\expandafter!%
    \the\numexpr0-100*#1*#1*#1/3-#2*#2/200000000;%
}%
%    \end{macrocode}
%\begin{lverb}
% final, stages 2,4,6,8: v0!..v6!J8;J6;  w = floor(10^16 t)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LfA #1!#2!#3!#4!#5!#6!#7!#8;#9;%
{%
    \expandafter\CALX_LfAb\the\numexpr#9/100\expandafter;\the\numexpr
      ((((#1-1)*10000+#2)*10000+#3)*10000+#4)*10000+#5;#8;#9;%
      #1!#2#3!#4#5!#6#7!%
}%
\def\CALX_LfAb #1;#2;#3;#4;#5!#6!#7!#8!%
{%
    \expandafter\CALX_LTa\the\numexpr#5#6-100000000-#4-#3\expandafter!%
    \the\numexpr#7+#4*#4/2\expandafter!%
    \the\numexpr#8-(100*#1*#1*#1-3*(100*#1*#1*#1/3))*3333+#1*#1*#1*#1/4%
      -#1*#1*#1*#1*#1/5000000-#3*#3*#3/3-#2*#2/200000000\expandafter!%
    \the\numexpr5000*#3*#3-100*#1*#1*#1/3;%
}%
%    \end{macrocode}
%\begin{lverb}
% add the tables (8-digit pairs, no carry): A!P2!P3!S5;key;
% A = floor(10^8 y), P2, P3 the next pairs (entries: F1!c2!c3!...)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LT #1#2#3;#4;%
   {\expandafter\expandafter\expandafter#1\csname#2#4\endcsname\CALX_LQ#3;}%
\def\CALX_LTa{\CALX_LT\CALX_LCAa{CALX_Lt}}%
\def\CALX_LTb{\CALX_LT\CALX_LCAb{CALX_Ls}}%
\def\CALX_LTc{\CALX_LT\CALX_LCAc{CALX_Lb}}%
\def\CALX_Ltmp #1#2%
   {\def#1##1!##2!##3!##4\CALX_LQ##5!##6!##7!%
     {\expandafter#2\the\numexpr##1+##5\expandafter!\the\numexpr##2+##6%
      \expandafter!\the\numexpr##3+##7!}}%
\CALX_Ltmp\CALX_LCAa\CALX_LTb
\CALX_Ltmp\CALX_LCAb\CALX_LTc
\CALX_Ltmp\CALX_LCAc\CALX_LTd
\let\CALX_Ltmp\relax
%    \end{macrocode}
%\begin{lverb}
% carry chain with E ln10 (limbs of floor(10^24 ln 10) written in).
% Template, shared with exp: \CALX_LTdef <name><cont>{<params>}
% {<integer column prefix>}{<tail>}; params ##1 A (10^-8), ##2 P2 (10^-16),
% ##3 P3 (10^-24), ##4 S5 (10^-20), ##5 E; output <cont>I!l1!..!l6!<tail>.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LTdef #1#2#3#4#5%
{%
  \def#1#3%
  {%
    \expandafter#2\the\numexpr#4 2*##5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+3025*##5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+##1+8509*##5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+2994*##5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+##2+456*##5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+##4+8401*##5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+##3+7991*##5\relax!#5%
  }%
}%
\CALX_LTdef\CALX_LTd\CALX_LNat{#1!#2!#3!#4;#5;}{}{}%
%    \end{macrocode}
%\begin{lverb}
% floor form I!l1!..!l6! -> native float, blocks written directly
% (value I + 0.l1...l6; negative: complement, |y| - 10^-24); D from
% calxcore's \CALX_ndig. Only |y| < 10^-8 (large-E path) uses \CALX_rsa.
% Template (shared with P24): \CALX_LNdef <at><p><n>{<params>}{<e>}
% {<blocks p>}{<blocks n>}{<limbs>}{<rsa prefix>}; e = number of 8-digit
% pairs after I (D = 8e + ndig).
%\end{lverb}
%    \begin{macrocode}
\begingroup\catcode`F=12
\gdef\CALX_LNdef #1#2#3#4#5#6#7#8#9%
{%
  \def#1##1!{\ifnum##1<\xint_c_ \expandafter#3\else\expandafter#2\fi##1!}%
  \def#2#4%
  {%
    \ifnum##1>\xint_c_ \xint_dothis{\expanded{F+\the\numexpr#5*8+%
      \CALX_ndig{##1}.-#5.#61\expandafter\xint_gobble_i
      \the\numexpr\xint_c_e_viii+##1!}}\fi
    \ifnum##2##3>\xint_c_ \xint_dothis{\expanded{F+\the\numexpr#5*8-8+%
      \CALX_ndig{##2##3}.-#5.#6}}\fi
    \xint_orthat{\expanded{\CALX_rsa#9\CALX_bp+!\expandafter\xint_gobble_i
      \the\numexpr\xint_c_e_viii+##1!#8}}%
  }%
  \def#3#4%
  {%
    \ifnum##1<-\xint_c_i \xint_dothis{\expanded{F-\the\numexpr#5*8+%
      \CALX_ndig{-##1-1}.-#5.#7%
      1\expandafter\xint_gobble_i\the\numexpr\xint_c_e_viii-##1-1!}}\fi
    \ifnum##2##3<99999999 \xint_dothis{\expanded{F-\the\numexpr#5*8-8+%
      \CALX_ndig{99999999-##2##3}.-#5.#7}}\fi
    \xint_orthat{\expanded{\CALX_rsa#9\CALX_bn-!\the\numexpr
      \xint_c_e_viii+##1!#8}}%
  }%
}%
\endgroup
\CALX_LNdef\CALX_LNat\CALX_LNp\CALX_LNn{#1!#2!#3!#4!#5!#6!#7!}{3}%
   {1#6#7!1#4#5!1#2#3!}%
   {\the\numexpr199999999-#6#7!\the\numexpr199999999-#4#5!%
    \the\numexpr199999999-#2#3!}%
   {#2!#3!#4!#5!#6!#7!}{4.3.}%
%    \end{macrocode}
%\begin{lverb}
% unity zone, |x-1| < 10^-4: delta = s D 10^-16, D < 10^12 as limbs
% a!b!c! (c <= 10^4). Horner G_n = 1/n - delta G_(n+1) on 6 fixed limbs
% (\CALX_LH<level><sign>), from G_5 (|x-1| >= 10^-5), G_4 (>= 10^-7),
% G_3 (>= 10^-10) or G_2; Q = delta G_2; y = s D (1 - Q) 10^-16 with
% D (1 - Q) computed exactly (\CALX_LY<sign>). Relative error of y below
% 3.4 10^-21 (remainder), budget 5 10^-20.
%\end{lverb}
%    \begin{macrocode}
\csname newcount\endcsname\CALX_Loffh \CALX_Loffh=1400000000
\def\CALX_LRh #1#2#3#4#5#6{+#1#2#3#4#5#6-140000!}%
\def\CALX_LRhz #1#2#3#4#5#6#7#8#9{+#1#2#3#4#5#6-140000\xint_gobble_i}%
\def\CALX_LUz #1!#2!#3!#4!%
{%
    \expandafter\CALX_LUs\expandafter P\the\numexpr10*#2+(2*#3-999)/2000%
    \expandafter!\the\numexpr10*(#3-1000*((2*#3-999)/2000))+(2*#4-999)/2000%
    \expandafter!\the\numexpr10*(#4-1000*((2*#4-999)/2000))!%
}%
\def\CALX_LUm #1!#2!#3!#4!%
{%
    \expandafter\CALX_LUs\expandafter M\the\numexpr9999-#2\expandafter!%
    \the\numexpr9999-#3\expandafter!\the\numexpr10000-#4!%
}%
\def\CALX_LUs #1#2!#3!%
{%
    \ifnum#2>999 \xint_dothis{\csname CALX_LHd#1\endcsname
      2000!0000!0000!0000!0000!0000!}\fi
    \ifnum#2>9 \xint_dothis{\csname CALX_LHc#1\endcsname
      2500!0000!0000!0000!0000!0000!}\fi
    \ifnum\numexpr#2*10000+#3>99 \xint_dothis{\csname CALX_LHb#1\endcsname
      3333!3333!3333!3333!3333!3333!}\fi
    \xint_orthat{\csname CALX_LHq#1\endcsname
      5000!0000!0000!0000!0000!0000!}#2!#3!%
}%
%    \end{macrocode}
%\begin{lverb}
% G' = C <op> D 10^-16 G: g1..g6, a, b, c; C literal (floor of 1/n)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Ltmp #1#2#3#4#5#6#7#8#9%
{%
    \def#1##1!##2!##3!##4!##5!##6!##7!##8!##9!%
    {%
        \expandafter#2\the\numexpr#4\expandafter\CALX_LRh
        \the\numexpr\CALX_Loffh+#5\expandafter\CALX_LRh
        \the\numexpr\CALX_Loffh+#6#3##7*##1\expandafter\CALX_LRh
        \the\numexpr\CALX_Loffh+#7#3(##7*##2+##8*##1)\expandafter\CALX_LRh
        \the\numexpr\CALX_Loffh+#8#3(##7*##3+##8*##2+##9*##1)%
        \expandafter\CALX_LRh
        \the\numexpr\CALX_Loffh+#9#3(##7*##4+##8*##3+##9*##2)%
        \expandafter\CALX_LRhz
        \the\numexpr\CALX_Loffh#3(##7*##5+##8*##4+##9*##3)\relax!##7!##8!##9!%
    }%
}%
\CALX_Ltmp\CALX_LHdP\CALX_LHcP-{2500}{0000}{0000}{0000}{0000}{0000}%
\CALX_Ltmp\CALX_LHcP\CALX_LHbP-{3333}{3333}{3333}{3333}{3333}{3333}%
\CALX_Ltmp\CALX_LHbP\CALX_LHqP-{5000}{0000}{0000}{0000}{0000}{0000}%
\CALX_Ltmp\CALX_LHqP\CALX_LYP+{0}{0}{0}{0}{0}{0}%
\CALX_Ltmp\CALX_LHdM\CALX_LHcM+{2500}{0000}{0000}{0000}{0000}{0000}%
\CALX_Ltmp\CALX_LHcM\CALX_LHbM+{3333}{3333}{3333}{3333}{3333}{3333}%
\CALX_Ltmp\CALX_LHbM\CALX_LHqM+{5000}{0000}{0000}{0000}{0000}{0000}%
\CALX_Ltmp\CALX_LHqM\CALX_LYM+{0}{0}{0}{0}{0}{0}%
%    \end{macrocode}
%\begin{lverb}
% D (1 <op> |Q|), exact: q1..q6, a, b, c -> 1<8 digits>!y1!y0!f1!..!f6!
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Ltmp #1#2#3%
{%
    \def#1##1!##2!##3!##4!##5!##6!##7!##8!##9!%
    {%
        \expandafter#3\the\numexpr\xint_c_e_viii+##7\expandafter\CALX_LRh
        \the\numexpr\CALX_Loffh+##8#2##7*##1\expandafter\CALX_LRh
        \the\numexpr\CALX_Loffh+##9#2(##7*##2+##8*##1)\expandafter\CALX_LRh
        \the\numexpr\CALX_Loffh#2(##7*##3+##8*##2+##9*##1)\expandafter\CALX_LRh
        \the\numexpr\CALX_Loffh#2(##7*##4+##8*##3+##9*##2)\expandafter\CALX_LRh
        \the\numexpr\CALX_Loffh#2(##7*##5+##8*##4+##9*##3)\expandafter\CALX_LRh
        \the\numexpr\CALX_Loffh#2(##7*##6+##8*##5+##9*##4)\expandafter\CALX_LRh
        \the\numexpr\CALX_Loffh#2(##8*##6+##9*##5)\expandafter\CALX_LRh
        \the\numexpr\CALX_Loffh#2##9*##6\relax!%
    }%
}%
\CALX_Ltmp\CALX_LYP-\CALX_LUop
\CALX_Ltmp\CALX_LYM+\CALX_LUom
\let\CALX_Ltmp\relax
%    \end{macrocode}
%\begin{lverb}
% y = s Z 10^-40, Z the integer of the five blocks
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LUop 1#1!#2!#3!#4!#5!#6!#7!#8!#9!%
   {\expanded{\CALX_rsa5.5.\CALX_bp+!#1!#2!#3!#4!#5!#6!#7!#8!#9!}}%
\def\CALX_LUom 1#1!#2!#3!#4!#5!#6!#7!#8!#9!%
   {\expanded{\CALX_rsa5.5.\CALX_bp-!#1!#2!#3!#4!#5!#6!#7!#8!#9!}}%
%    \end{macrocode}
%\begin{lverb}
% special values (tags F-, I+, I-, I?)
%\end{lverb}
%    \begin{macrocode}
\expandafter\let\csname CALX_LtagF-\expandafter\endcsname
   \csname CALX_lgHsF-\endcsname
\expandafter\let\csname CALX_LtagI+\expandafter\endcsname
   \csname CALX_lgHsI+\endcsname
\expandafter\let\csname CALX_LtagI-\expandafter\endcsname
   \csname CALX_lgHsI-\endcsname
\expandafter\let\csname CALX_LtagI?\expandafter\endcsname
   \csname CALX_lgHsI?\endcsname
%    \end{macrocode}
%\begin{lverb}
% (dispatch \CALX_lga$empty: at the end of the P17..P32 code)
%\end{lverb}
% \subsection{Natural logarithm, P17..P32}
%\begin{lverb}
% Layout L = 8 ceil(P/8) (24 or 32),
% grid W = L + 8, V = 10^W (1+t) as v0!v1!..!vn! (n = W/4 = 8 or 10),
% followed by the sentinel pair \CALX_LQ!\CALX_LQ!. Stages k = 2,4,6,8 with
% tables for every class; series t - t^2/2 + t^3/3 (- t^4/4 for L = 32).
% |x - 1| < 10^-4: y = delta G by the series kernel \CALX_Z (calxtrig).
% entry: F+<D>.<e>.<blocks>\xint:
%\end{lverb}
%    \begin{macrocode}
\begingroup\catcode`F=12
\expandafter\gdef\csname CALX_LGtagF+\endcsname #1.#2.#3\xint:%
{%
    \ifnum#1=\xint_c_ \xint_dothis{\CALX_nsig{DivisionByZero}{log(0)}{-}}\fi
    \xint_orthat{\expandafter\CALX_LGtb\the\numexpr(#1+\xint_c_iii)/\xint_c_viii
      \expandafter.\the\numexpr#1-\xint_c_i+\xint_c_viii*#2.#1.#3\xint:}%
}%
\endgroup
\def\CALX_LGtb #1.#2.#3.#4\xint:%
   {\CALX_Lfr\XINTdigits{\CALX_LGL\XINTdigits.#1.#2.#3.#4\xint:}}%
%    \end{macrocode}
%\begin{lverb}
% Internal log at precision P (#1: the token \XINTdigits, or digits
% delimited by the dot), n blocks, E, D, blocks: digits by \CALX_Lin<n>
% (P <= 32) or \CALX_LGin, continuation \CALX_LGh<g> (g = (P-5)/8 groups
% more), then {P} in the slot read by \CALX_LGcl (#6).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGL #1.#2.#3.#4.#5\xint:%
   {\csname CALX_\ifnum#1>32 LGin\else Lin\romannumeral#2\fi\expandafter
    \endcsname\csname CALX_LGh\the\numexpr(#1-5)/8\endcsname#5\xint:#3.#4.{#1}}%
%    \end{macrocode}
%\begin{lverb}
% P > 32: blocks (LS first) reversed by a loop, leading zeros of the top
% block removed (\CALX_Lgz), 112 zeros of padding (P <= 112)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGin #1{\CALX_LGir{#1}{}}%
\def\CALX_LGir #1#2#3{\xint_gob_til_xint: #3\CALX_LGie\xint:\CALX_LGis{#1}{#2}#3}%
\def\CALX_LGis #1#2#3#4!{\CALX_LGir{#1}{#4#2}}%
\def\CALX_LGie\xint:\CALX_LGis#1#2\xint:#3.#4.%
{%
    \csname CALX_Lgz\the\numexpr8*((#4+3)/8)-#4\endcsname#1#2%
    00000000000000000000000000000000000000000000000000000%
    00000000000000000000000000000000000000000000000000000000000\relax#3.%
}%
%    \end{macrocode}
%\begin{lverb}
% digits -> a.m1!m2!..., 8 digits per call (g = (P-5)/8 more calls):
% first call \CALX_LGh<g> (g baked, g = 2..13)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Ltmp #1#2%
   {\expandafter\edef\csname CALX_LGg#1\endcsname##1##2##3##4##5##6##7##8##9%
      {\expandafter\noexpand\csname CALX_LGg#2\endcsname
       {##1##2##3##4##5!##6##7##8##9!}}}%
\CALX_Ltmp{1}{0}\CALX_Ltmp{2}{1}\CALX_Ltmp{3}{2}\CALX_Ltmp{4}{3}%
\CALX_Ltmp{5}{4}\CALX_Ltmp{6}{5}\CALX_Ltmp{7}{6}\CALX_Ltmp{8}{7}%
\CALX_Ltmp{9}{8}\CALX_Ltmp{10}{9}\CALX_Ltmp{11}{10}\CALX_Ltmp{12}{11}%
\CALX_Ltmp{13}{12}%
\def\CALX_Ltmp #1%
   {\expandafter\edef\csname CALX_LGh#1\endcsname##1##2##3##4##5##6##7##8%
      {\expandafter\noexpand\csname CALX_LGg#1\endcsname
       {##1##2.##1##2##3##4!##5##6##7##8!}}}%
\CALX_Ltmp{2}\CALX_Ltmp{3}\CALX_Ltmp{4}\CALX_Ltmp{5}\CALX_Ltmp{6}\CALX_Ltmp{7}%
\CALX_Ltmp{8}\CALX_Ltmp{9}\CALX_Ltmp{10}\CALX_Ltmp{11}\CALX_Ltmp{12}%
\CALX_Ltmp{13}%
\expandafter\def\csname CALX_LGg0\endcsname #1#2\relax#3.%
   {\CALX_LGcl#3.#1\CALX_LQ!\CALX_LQ!}%
%    \end{macrocode}
%\begin{lverb}
% classification: E.a.m1!m2!...\CALX_LQ!\CALX_LQ!{P} (P: the token
% \XINTdigits or digits; stages \CALX_LGsa<g>, g = (P-5)/8; P. appended at
% the end of the tail J8;J6;J4;J2;a;E; for \CALX_LGo / absorbed by L24)
% "#1#2" (E then a) is 10 iff E = 0, a = 10; in [-199,-191] iff E = -1,
% a >= 91 (a = 90 stays ordinary: x = 0.9 is not in the unity zone).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGcl #1.#2.%
{%
    \ifnum\ifnum#1<\xint_c_ -\fi#1>9999
      \xint_dothis\CALX_LGcl_large\fi
    \xint_orthat\CALX_LGcl_regular #1.#2.%
}%
\def\CALX_LGcl_large #1.#2.#3!#4!#5\CALX_LQ!\CALX_LQ!#6%
{%
    \CALX_faddx{\expandafter\CALX_LGB
        \csname CALX_LGsa\the\numexpr(#6-5)/8\expandafter\endcsname
        \the\numexpr10*(200000/(2*#2+1));#3!#4!#5\CALX_LQ!\CALX_LQ!#2;0;#6.}%
        {\CALX_fmulx{\romannumeral0\CALX_ffromraw{#1[0]}}{\CALX_LzetaL}}%
}%
\def\CALX_LGcl_regular #1.#2.#3!#4!#5\CALX_LQ!\CALX_LQ!#6%
{%
    \ifnum\ifnum#1#2=10 #3#4\else999999999\fi<10001000
      \xint_dothis{\CALX_LWs#4!#5\CALX_LQ!{#6}}\fi
    \ifnum#1#2=10
      \xint_dothis{\expandafter\CALX_LGB
        \csname CALX_LGsa\the\numexpr(#6-5)/8\endcsname
        100000;#3!#4!#5\CALX_LQ!\CALX_LQ!0;0;#6.}\fi
    \ifnum\ifnum#1#2<-199 \xint_c_\else\ifnum#1#2<-190 #3#4\else\xint_c_\fi\fi
      >99989999 \xint_dothis{\expandafter\CALX_LWt
        \the\numexpr#4-10000!#5\CALX_LQ!{#6}}\fi
    \ifnum\ifnum#1#2<-199 \xint_c_\else#1#2\fi<-190
      \xint_dothis{\expandafter\CALX_LGB
        \csname CALX_LGsa\the\numexpr(#6-5)/8\endcsname
        10000;#3!#4!#5\CALX_LQ!\CALX_LQ!0;0;#6.}\fi
    \xint_orthat{\expandafter\CALX_LGB
      \csname CALX_LGsa\the\numexpr(#6-5)/8\expandafter\endcsname
      \the\numexpr10*(200000/(2*#2+1));#3!#4!#5\CALX_LQ!\CALX_LQ!#2;#1;#6.}%
}%
\edef\CALX_LzetaL{\romannumeral0\CALX_ffromraw{\CALX_Lzraw}}%
%    \end{macrocode}
%\begin{lverb}
% end test on the sentinel pair (gob-til)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGgt #1\CALX_LQ{}%
%    \end{macrocode}
%\begin{lverb}
% bootstrap: <cont>J;m1!..!\CALX_LQ!\CALX_LQ! -> <cont>v0!..!vn!sentinel
% V = J M 10^4, J = 10c (unity zone: 10^5 if E = 0, 10^4 if E = -1)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGB #1#2;%
   {\expandafter#1\the\numexpr\xint_c_\expandafter\CALX_LRb
    \the\numexpr\CALX_Lob\CALX_LGBp#2;}%
\def\CALX_LGBp #1;#2!#3!%
{%
    \CALX_LGgt#2\CALX_LGBe\CALX_LQ\expandafter\CALX_LRb
    \the\numexpr\CALX_Lob+#1*#2\expandafter\CALX_LRb
    \the\numexpr\CALX_Lob+#1*#3\CALX_LGBp#1;%
}%
\def\CALX_LGBe\CALX_LQ#1\CALX_LGBp#2;{\relax!0000!\CALX_LQ!\CALX_LQ!}%
%    \end{macrocode}
%\begin{lverb}
% stage kernels: <cont>J;v0!..!vn!sentinel -> <cont>v0'!..!vn'!sentinel J;
% V' = V + floor(J V/10^(4s)), s = 1 (\CALX_LGKa), 2 (\CALX_LGKb); the
% dropped column only gives its carry (\CALX_LRz).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGKa #1#2;#3!{\expandafter#1\the\numexpr#3\CALX_LGPa#2;#3!}%
\def\CALX_LGPa #1;#2!#3!#4!%
{%
    \CALX_LGgt#3\CALX_LGPe\CALX_LQ\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#1*#2+#3\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#1*#3+#4\CALX_LGPa#1;#4!%
}%
\def\CALX_LGPe\CALX_LQ\expandafter\CALX_LR\the\numexpr\CALX_Loff+#1*#2+#3%
   \CALX_LQ!%
   {\expandafter\CALX_LRz\the\numexpr\CALX_Loff+#1*#2\relax!\CALX_LQ!\CALX_LQ!#1;}%
\def\CALX_LGKb #1#2;#3!{\expandafter#1\the\numexpr#3\CALX_LGPb#2;0!#3!}%
\def\CALX_LGPb #1;#2!#3!#4!#5!%
{%
    \CALX_LGgt#4\CALX_LGPf\CALX_LQ\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#1*#2+#4\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#1*#3+#5\CALX_LGPb#1;#4!#5!%
}%
\def\CALX_LGPf\CALX_LQ\expandafter\CALX_LR\the\numexpr\CALX_Loff+#1*#2+#3%
   \CALX_LQ!\CALX_LQ!%
   {\expandafter\CALX_LRz\the\numexpr\CALX_Loff+#1*#2\relax!\CALX_LQ!\CALX_LQ!#1;}%
\def\CALX_LGKz #1#2;#3\CALX_LQ!\CALX_LQ!{#1#3\CALX_LQ!\CALX_LQ!0;}%
%    \end{macrocode}
%\begin{lverb}
% selectors (templates of P9..P16): one set per layout g = 2..13
% (\CALX_LGsa<g>..\CALX_LGsd<g>, final \CALX_LGf<g>): the layout reaches
% the final through the selectors' continuations.
% final: layout g and sign by v0 (|t| < 5.061e-9: v1 = v2 = 0000 if
% v0 = 1, 9999 if v0 = 0)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Ltmp #1%
   {\expandafter\CALX_Ltmpc\csname CALX_LGsa#1\expandafter\endcsname
    \csname CALX_LGsb#1\expandafter\endcsname\csname CALX_LGsc#1\expandafter
    \endcsname\csname CALX_LGsd#1\expandafter\endcsname
    \csname CALX_LGf#1\endcsname{#1}}%
\def\CALX_Ltmpc #1#2#3#4#5#6%
{%
    \CALX_Lsdef#1#2#3#4\CALX_LGKa\CALX_LGKb\CALX_LGKz
    \CALX_Lsdefd#4#5\CALX_LGKb\CALX_LGKz
    \def#5##1!{\csname CALX_LGf\ifnum##1=\xint_c_ n\else p\fi#6\endcsname}%
}%
\CALX_Ltmp{2}\CALX_Ltmp{3}\CALX_Ltmp{4}\CALX_Ltmp{5}\CALX_Ltmp{6}\CALX_Ltmp{7}%
\CALX_Ltmp{8}\CALX_Ltmp{9}\CALX_Ltmp{10}\CALX_Ltmp{11}\CALX_Ltmp{12}%
\CALX_Ltmp{13}%
\let\CALX_Ltmpc\relax
%    \end{macrocode}
%\begin{lverb}
% L = 24 (W = 32): v3..v8 -> P4!P3!P2!A;  tau = |t| limbs (n: 9999-v,
% |t| - 10^-32), s = tau3tau4, rho = tau5tau6; pairs P2 (10^-16), P3
% (10^-24), P4 (10^-32). y = t - t^2/2 + t^3/3.
% #1 suffix, #2 v1!v2!, #3 limb complement prefix, #4 pair complement
% prefix, #5 A, #6 sign of the cubic
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Ltmp #1#2#3#4#5#6%
{%
    \expandafter\def\csname CALX_LGf#1\endcsname#2##1!##2!##3!##4!##5!##6!%
       \CALX_LQ!\CALX_LQ!%
    {%
        \expandafter\CALX_LGTva\the\numexpr##5##6%
        -((#3##1)*(#3##1)-2*((#3##1)*(#3##1)/2))*50000000%
        -((#3##1)*(#3##2)-10000*((#3##1)*(#3##2)/10000))*10000%
        -(#3##2)*(#3##2)/2-(#4##1##2)*(#4##3##4)/100000000%
        #6(#4##1##2)*(#4##1##2)/100000000*(#4##1##2)/300000000%
        \expandafter!\the\numexpr##3##4-(#3##1)*(#3##1)/2%
        -(#3##1)*(#3##2)/10000!##1##2!#5;%
    }%
}%
\CALX_Ltmp{p2}{0000!0000!}{}{}{0}+%
\CALX_Ltmp{n2}{9999!9999!}{9999-}{99999999-}{-1}-%
%    \end{macrocode}
%\begin{lverb}
% L = 32 (W = 40): step 1 -> Hs!Ls!u!w!tau5!tau6!lambda!mu!
% (s^2 = Hs 10^8 + Ls exactly, u = tau3, w = tau4); n: complements.
%\end{lverb}
%    \begin{macrocode}
\expandafter\def\csname CALX_LGfp3\endcsname 0000!0000!#1!#2!#3!#4!#5!#6!#7!#8!%
   \CALX_LQ!\CALX_LQ!%
{%
    \expandafter\CALX_LGgp\the\numexpr#1*#1+2*#1*#2/10000\expandafter!%
    \the\numexpr(2*#1*#2-10000*(2*#1*#2/10000))*10000+#2*#2!%
    #1!#2!#3!#4!#5#6!#7#8!%
}%
\expandafter\def\csname CALX_LGfn3\endcsname 9999!9999!#1!#2!#3!#4!#5!#6!#7!#8!%
   \CALX_LQ!\CALX_LQ!%
{%
    \expandafter\CALX_LGgn\the\numexpr(9999-#1)*(9999-#1)%
      +2*(9999-#1)*(9999-#2)/10000\expandafter!%
    \the\numexpr(2*(9999-#1)*(9999-#2)-10000*(2*(9999-#1)*(9999-#2)/10000))%
      *10000+(9999-#2)*(9999-#2)\expandafter!%
    \the\numexpr9999-#1\expandafter!\the\numexpr9999-#2\expandafter!%
    \the\numexpr9999-#3\expandafter!\the\numexpr9999-#4\expandafter!%
    \the\numexpr99999999-#5#6\expandafter!\the\numexpr99999999-#7#8!%
}%
%    \end{macrocode}
%\begin{lverb}
% step 2: Hs!Ls!u!w!tau5!tau6!lambda!mu! -> P4!P3!P2!A!P5;
% #1 name, #2 pair complement prefix, #3 tokens writing A, #4 sign of t
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Ltmp #1#2#3#4%
{%
  \def#1##1!##2!##3!##4!##5!##6!##7!##8!%
  {%
    \expandafter\CALX_LGTvb\the\numexpr#2##7%
      -(##1-2*(##1/2))*50000000-##2/2-##3*##5%
      -(##3*##6+##4*##5+##4*##6/10000)/10000%
      #4(##3*(##1/10000)/3%
         +(##3*(##1-10000*(##1/10000))+##4*(##1/10000))/30000)%
    \expandafter!\the\numexpr#2(##5*10000+##6)-##1/2%
    \expandafter!\the\numexpr#2(##3*10000+##4)%
    #3\the\numexpr#2##8%
      -(##2-2*(##2/2))*50000000%
      -((##3*##6+##4*##5-10000*((##3*##6+##4*##5+##4*##6/10000)/10000))%
        *10000+##4*##6)%
      -(##3*10000+##4)*##7/100000000%
      -(##5*10000+##6)*(##5*10000+##6)/200000000%
      -(##3*10000+##4)*##8/100000000/100000000%
      -(##5*10000+##6)*##7/100000000/100000000%
      #4((##3*(##1/10000)-3*(##3*(##1/10000)/3))*33333333%
        +((##3*(##1-10000*(##1/10000))+##4*(##1/10000))-30000*%
          ((##3*(##1-10000*(##1/10000))+##4*(##1/10000))/30000))*10000/3%
        +##4*(##1-10000*(##1/10000))/3%
        +(##3*10000+##4)*##2/300000000%
        +##1*(##5*10000+##6)/100000000%
        +##2*(##5*10000+##6)/100000000/100000000)%
      -##1*##1/400000000;%
  }%
}%
\CALX_Ltmp\CALX_LGgp{}{\expandafter!\expandafter0\expandafter!}+%
\CALX_Ltmp\CALX_LGgn{99999999-}%
   {\expandafter!\expandafter-\expandafter1\expandafter!}-%
%    \end{macrocode}
%\begin{lverb}
% tables: fetch + add, order Lv, Lu, Lt, Ls, Lb. Templates (shared
% with exp P17..P32): \CALX_LGTdef <fetch><prefix><add>,
% \CALX_LGAdef <add><next> (L = 24), \CALX_LGBdef <add><next> (L = 32)
% fetch: <accs>;<key>;  -> <entry>\CALX_LQ<accs>;
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGTdef #1#2#3%
   {\def#1##1;##2;{\expandafter\expandafter\expandafter#3%
      \csname#2##2\endcsname\CALX_LQ##1;}}%
%    \end{macrocode}
%\begin{lverb}
% add, L = 24: F1!c2!c3!c4!rest\CALX_LQ P4!P3!P2!A;
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGAdef #1#2%
   {\def#1##1!##2!##3!##4!##5\CALX_LQ##6!##7!##8!##9;%
     {\expandafter#2\the\numexpr##6+##4\expandafter!\the\numexpr##7+##3%
      \expandafter!\the\numexpr##8+##2\expandafter!\the\numexpr##9+##1;}}%
%    \end{macrocode}
%\begin{lverb}
% add, L = 32: accs P4!P3!P2!A!P5; (c5 + P5 by \CALX_LGCe)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGBdef #1#2%
   {\def#1##1!##2!##3!##4!##5\CALX_LQ##6!##7!##8!##9!%
     {\expandafter#2\the\numexpr##6+##4\expandafter!\the\numexpr##7+##3%
      \expandafter!\the\numexpr##8+##2\expandafter!\the\numexpr##9+##1%
      \expandafter!\the\numexpr\CALX_LGCe##5\CALX_LQ}}%
\def\CALX_LGCe #1!#2\CALX_LQ#3;{#1+#3;}%
\CALX_LGTdef\CALX_LGTva{CALX_Lv}\CALX_LGAva \CALX_LGAdef\CALX_LGAva\CALX_LGTua
\CALX_LGTdef\CALX_LGTua{CALX_Lu}\CALX_LGAua \CALX_LGAdef\CALX_LGAua\CALX_LGTta
\CALX_LGTdef\CALX_LGTta{CALX_Lt}\CALX_LGAta \CALX_LGAdef\CALX_LGAta\CALX_LGTsa
\CALX_LGTdef\CALX_LGTsa{CALX_Ls}\CALX_LGAsa \CALX_LGAdef\CALX_LGAsa\CALX_LGTba
\CALX_LGTdef\CALX_LGTba{CALX_Lb}\CALX_LGAba \CALX_LGAdef\CALX_LGAba\CALX_LGca
\CALX_LGTdef\CALX_LGTvb{CALX_Lv}\CALX_LGAvb \CALX_LGBdef\CALX_LGAvb\CALX_LGTub
\CALX_LGTdef\CALX_LGTub{CALX_Lu}\CALX_LGAub \CALX_LGBdef\CALX_LGAub\CALX_LGTtb
\CALX_LGTdef\CALX_LGTtb{CALX_Lt}\CALX_LGAtb \CALX_LGBdef\CALX_LGAtb\CALX_LGTsb
\CALX_LGTdef\CALX_LGTsb{CALX_Ls}\CALX_LGAsb \CALX_LGBdef\CALX_LGAsb\CALX_LGTbb
\CALX_LGTdef\CALX_LGTbb{CALX_Lb}\CALX_LGAbb \CALX_LGBdef\CALX_LGAbb\CALX_LGcb
%    \end{macrocode}
%\begin{lverb}
% carry chains with E ln10 (limbs of floor(10^40 ln10)); the last pair
% is split (its column could leave the 10-digit range). Templates
% (shared with exp): \CALX_LGcadef / \CALX_LGcbdef <name><cont>{<params>}
% {<integer column prefix>}; params ##1..##4 P4!P3!P2!A (L24), ##1..##5
% P4!P3!P2!A!P5 (L32), then E (##5 / ##6); output <cont>I!l1!..!ln!
% (L24: + tail #5; L32: + \CALX_LQ)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGcadef #1#2#3#4#5%
{%
  \def#1#3%
  {%
    \expandafter#2\the\numexpr#4 2*##5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+3025*##5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+##4+8509*##5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+2994*##5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+##3+456*##5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+8401*##5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+##2+7991*##5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+4546*##5+##1/10000\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+8436*##5+##1-##1/10000*10000\relax!#5%
  }%
}%
\CALX_LGcadef\CALX_LGca\CALX_LNaat{#1!#2!#3!#4;#5;#6.}{}{}% P4!P3!P2!A;E;P.
\def\CALX_LGcbdef #1#2#3#4%
{%
  \def#1#3%
  {%
    \expandafter#2\the\numexpr#4 2*##6\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+3025*##6\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+##4+8509*##6\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+2994*##6\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+##3+456*##6\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+8401*##6\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+##2+7991*##6\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+4546*##6+##1/10000\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+8436*##6+##1-##1/10000*10000\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+4207*##6+##5/10000\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+6011*##6+##5-##5/10000*10000\relax!\CALX_LQ
  }%
}%
\CALX_LGcbdef\CALX_LGcb\CALX_LGo{#1!#2!#3!#4!#5;#6;}{}% P4!P3!P2!A!P5;E; (P. -> LGo)
%    \end{macrocode}
%\begin{lverb}
% output: L = 24 by the P16 template, L = 32 by calxtrig's \CALX_rsa
%\end{lverb}
%    \begin{macrocode}
\CALX_LNdef\CALX_LNaat\CALX_LNap\CALX_LNan{#1!#2!#3!#4!#5!#6!#7!#8!#9!}{4}%
   {1#8#9!1#6#7!1#4#5!1#2#3!}%
   {\the\numexpr199999999-#8#9!\the\numexpr199999999-#6#7!%
    \the\numexpr199999999-#4#5!\the\numexpr199999999-#2#3!}%
   {#2!#3!#4!#5!#6!#7!#8!#9!}{5.4.}%
%    \end{macrocode}
%\begin{lverb}
% generic (P > 24): I!l1!..!ln!\CALX_LQ P. (P from the tail),
% m = W/8 = ceil(P/8) + 1 pairs
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGo #1!#2\CALX_LQ#3.%
   {\expandafter\CALX_LGoq\the\numexpr(#3+3)/8+2\expandafter.%
    \the\numexpr(#3+3)/8+1.#1!#2\CALX_LQ}%
\def\CALX_LGoq #1.#2.#3!#4\CALX_LQ%
{%
    \ifnum#3<\xint_c_
      \xint_dothis{\expanded{\CALX_rsa#1.#2.\CALX_bn-!%
        \the\numexpr\xint_c_e_viii+#3!#4}}\fi
    \xint_orthat{\expanded{\CALX_rsa#1.#2.\CALX_bp+!\expandafter\xint_gobble_i
      \the\numexpr\xint_c_e_viii+#3!#4}}%
}%
%    \end{macrocode}
%\begin{lverb}
% unity zone |x - 1| < 10^-4: y = delta G, G = sum_k (-delta)^k/(k+1),
% Horner by the series kernel \CALX_Z (calxtrig), decreasing widths: level
% k has scale 10^(4(A-k)), T_k = C_k - U' T_(k+1) 10^(-4b), U' = 10^4 delta
% (b_0 = M - 1 limbs, U_k its top b_k = min(b_0, A-k-1) limbs), C_k =
% floor(10^(4(A-k))/(k+1)) (\CALX_cdl<k>), T_(A-1) = C_(A-1) (one limb),
% levels k = A-2..1 (b_k, m = A-k-1, n = A-k), level 0 with C_0 = 10^(4A)
% (n = A+1 limbs, output negated), then the exact product level
% (\CALX_Zlevp$empty: b_0 by A+1 limbs, all columns, floor carries).
% A = ceil((P+4)/4) up to P = 64, ceil((P+5)/4) above; error of T_0 at
% most 3A - 4 + 1/(A+1) units 10^(-4A) (each
% level: |err| < 0.503).
% y = (x - 1) T_0 10^(-4A): exact product by one more kernel level, one
% rounding.
% Schedule \CALX_Zul<P> (P = 17..112): {C_(A-1)}{<level
% descriptors>\CALX_LWk}.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LWrv #1\relax{\CALX_LWrw#1\relax\relax}% reverse l!..l! (load time)
\def\CALX_LWrw #1!#2\relax#3\relax%
   {\if\relax\detokenize{#2}\relax#1!#3\else\CALX_LWrw#2\relax#1!#3\relax\fi}%
\def\CALX_LWzr #1.{\ifnum#1>\xint_c_ 0!\expandafter\CALX_LWzr
   \the\numexpr#1-1\expandafter.\fi}%
\def\CALX_LWmin #1#2{\ifnum#1<\numexpr#2\relax#1\else#2\fi}%
\def\CALX_LWlev #1.#2.#3.#4{\CALX_Zlev{#1}{#2}{#3}{#4}}%
%    \end{macrocode}
%\begin{lverb}
% coefficient hook: log, log1p: 1/(k+1); expm1 sets it to
% exp's \CALX_exgK (1/(k+1)!) while building its schedules
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LWco{\CALX_tcoef{l}}%
\def\CALX_LWbl #1.%
{%
    \ifnum#1>\xint_c_
      \expandafter\CALX_LWlev\the\numexpr\CALX_LWmin\CALX_LWm{\CALX_LWa-#1-1}%
        \expandafter.\the\numexpr\CALX_LWa-#1-1\expandafter.%
        \the\numexpr\CALX_LWa-#1.%
        {\expandafter\CALX_LWrv\expanded{\CALX_LWco{#1}{\CALX_LWa-#1}%
          {\CALX_LWa-#1}\CALX_tq}\relax}\CALX_Zu
      \expandafter\CALX_LWbl\the\numexpr#1-1.%
    \else
      \expandafter\CALX_LWlev\the\numexpr\CALX_LWmin\CALX_LWm{\CALX_LWa-1}%
        \expandafter.\the\numexpr\CALX_LWa-1\expandafter.%
        \the\numexpr\CALX_LWa+1.%
        {1!\expandafter\CALX_LWzr\CALX_LWa.}\CALX_Zun
      \CALX_LWfin
    \fi
}%
\def\CALX_Ltmp #1%
{%
    \edef\CALX_LWa{\the\numexpr(#1+\ifnum#1>64 6\else5\fi)/4}%
    \edef\CALX_LWm{\the\numexpr2*((#1+3)/8)-1}%
    \expandafter\edef\csname CALX_Zul#1\endcsname
    {%
      {\expandafter\CALX_Zhd\expanded{\CALX_tcoef{l}{\CALX_LWa-1}{1}{1}%
       \CALX_tq}\relax}%
      {\expandafter\CALX_LWbl\the\numexpr\CALX_LWa-2.}%
    }%
}%
%    \end{macrocode}
%\begin{lverb}
% after level 0 (a hook; log1p builds its levels without it)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LWfin{\CALX_Zlevp\CALX_LWm{\the\numexpr\CALX_LWa+1}\CALX_Zuf
   \noexpand\CALX_LWk}%
\def\CALX_Ltmpb #1{\ifnum#1<113 \CALX_Ltmp{#1}%
   \expandafter\CALX_Ltmpb\expandafter{\the\numexpr#1+1\expandafter}\fi}%
\CALX_Ltmpb{17}%
\let\CALX_LWa\relax \let\CALX_LWm\relax \let\CALX_LWfin\relax
%    \end{macrocode}
%\begin{lverb}
% U' = 10^4 (x - 1), limbs MS first. E = 0 (x = 1.0000ddd..): limb j =
% digits 2-4 of m_j and digit 1 of m_(j+1), j = 2..M (\CALX_LWsh);
% E = -1 (x = 0.9999ddd..): m_2 - 10^4, m_3, .., m_M. Then the kernel's U
% list (\CALX_Zbt$empty: negated, balanced, top limb kept whole).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LWsh #1#2#3#4!#5%
   {\CALX_Zgob#5\CALX_LWse\CALX_Zq#2#3#4#5!\CALX_LWsh#5}%
\def\CALX_LWse\CALX_Zq#1#2#3\CALX_Zq!\CALX_LWsh\CALX_Zq!{#1#2#30!\CALX_Zq!}%
\def\CALX_LWs #1\CALX_LQ!#2%
   {\expandafter\CALX_LWu\expanded{\CALX_LWsh#1\CALX_Zq!}{#2}}%
\def\CALX_LWt #1\CALX_LQ!{\CALX_LWu#1\CALX_Zq!}%
\def\CALX_LWu #1\CALX_Zq!#2%
{%
    \expandafter\expandafter\expandafter\CALX_Zst
    \csname CALX_Zul\the\numexpr#2\expandafter\endcsname
    \expandafter{\expanded{\CALX_Zbt#1\CALX_Zq!}}{#2}%
}%
%    \end{macrocode}
%\begin{lverb}
% final: {U}x_top.<limbs>\CALX_Zq{P}: the exact product
% N = U'_int T_0,int on K = b_0 + A + 1 limbs (floor form, x_top = top
% limb, negative iff delta < 0), y = N 10^(-4K): \CALX_rsa (calxtrig) with
% pairs MS first, a zero limb appended if K (i.e. A) is odd, complement
% conversion for N < 0 (|N| - 1 unit, harmless). N = 0 (x = 1): \CALX_rsa
% returns F+1.<..>, impossible otherwise (|y| > 10^(-4K)): F+0.0.
% #4 = P (\XINTdigits or digits); A = (P + 5 or 6)/4, c = (2 ((P+3)/8)
% + A)/2 computed here.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LWk #1#2.#3\CALX_Zq#4%
   {\expandafter\CALX_LWkk\the\numexpr(2*((#4+3)/8)+(#4+\ifnum#4>64 6\else
    5\fi)/4)/2\expandafter.\expanded{\ifnum#2<\xint_c_ \the\numexpr10000+#2\else
    \expandafter\xint_gobble_i\the\numexpr10000+#2\fi!%
    #3\ifodd\numexpr(#4+\ifnum#4>64 6\else5\fi)/4\relax 0000!\fi}\relax#2.}%
\def\CALX_LWkk #1.#2\relax#3.%
{%
    \expandafter\CALX_LWz\expanded{%
      \ifnum#3<\xint_c_ \expandafter\CALX_LWkn\else\expandafter\CALX_LWkp\fi
      #3.#1.#2}%
}%
\def\CALX_LWkp #1.#2.{\CALX_rsa#2.#2.\CALX_bp+}%
\def\CALX_LWkn #1.#2.{\CALX_rsa#2.#2.\CALX_bn-}%
\begingroup\catcode`F=12
\gdef\CALX_LWz F#1#2.%
   {\ifnum#2=\xint_c_i \expandafter\CALX_LWzz\fi F#1#2.}%
\gdef\CALX_LWzz F#1#2.#3.#4!{F+0.0.}%
\endgroup
%    \end{macrocode}
% \subsection{Natural logarithm, P33 and above}
%\begin{lverb}
% L = 8 ceil(P/8) <= 112, W = L + 8 <= 120, n = W/4 limbs, m = n/2 pairs.
% After stage 8, |t| < 5.061e-9: y_s = ln(1+t) = t G(t), G = sum
% (-t)^k/(k+1), by the series kernel \CALX_Z (calxtrig) with U'' = 10^8 t
% (n-2 limbs v3..vn; t < 0: v3 - 10^4, v4, ..): level k has scale
% 10^(4(n-2-2k)), T_k = C_k - U'' T_(k+1) 10^(-4b), b = m = n-4-2k (two
% limbs less per level), levels k = (n-6)/2..1 from T = C_((n-4)/2) (two
% limbs); level 0: T_0 = G (C_0 = 10^(4(n-2)), n-1 limbs, output negated);
% final level: y_s 10^W = 0 + U'' T_0 10^(-4(n-2)) (b = n-2, m = n-1,
% n limbs, floor carries), written A!P2!..!Pm! with A = floor(10^8 y_s)
% (0 or -1). Error: per level |err| < 0.503 unit (total
% within ~4.1 units of 10^-W).
% Schedules \CALX_Zlg<g> (keyed by the layout g = (P-5)/8 = 4..13):
% {c1.\CALX_Zn c2}{<descriptors>\CALX_LGFk}.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGt #1!#2!{#2.\noexpand\CALX_Zn#1}% LS first pair -> T items
\def\CALX_LGsl #1.%
{%
    \ifnum#1>\xint_c_
      \expandafter\CALX_LWlev\the\numexpr\CALX_LWa-4-2*#1\expandafter.%
        \the\numexpr\CALX_LWa-4-2*#1\expandafter.%
        \the\numexpr\CALX_LWa-2-2*#1.%
        {\expandafter\CALX_LWrv\expanded{\CALX_tcoef{l}{#1}{\CALX_LWa-2-2*#1}%
          {\CALX_LWa-2-2*#1}\CALX_tq}\relax}\CALX_Zu
      \expandafter\CALX_LGsl\the\numexpr#1-1.%
    \else
      \expandafter\CALX_LWlev\the\numexpr\CALX_LWa-4\expandafter.%
        \the\numexpr\CALX_LWa-4\expandafter.\the\numexpr\CALX_LWa-1.%
        {1!\expandafter\CALX_LWzr\the\numexpr\CALX_LWa-2.}\CALX_Zun
      \expandafter\CALX_LGsv\the\numexpr\CALX_LWa-2\expandafter.%
        \the\numexpr\CALX_LWa-1\expandafter.\CALX_LWa.%
        {\expandafter\CALX_LWzr\CALX_LWa.}\CALX_Zuf
      \noexpand\CALX_LGFk
    \fi
}%
\def\CALX_LGsv #1.#2.#3.#4{\CALX_Zlevx\CALX_Zvn{#1}{#2}{#3}{#4}}%
\def\CALX_Ltmp #1%
{%
    \edef\CALX_LWa{\the\numexpr2*#1+4}% n
    \expandafter\edef\csname CALX_Zlg#1\endcsname
    {%
      {\expandafter\CALX_LGt\expanded{\CALX_tcoef{l}{(\CALX_LWa-4)/2}{2}{2}%
        \CALX_tq}}%
      {\expandafter\CALX_LGsl\the\numexpr(\CALX_LWa-6)/2.}%
    }%
}%
\def\CALX_Ltmpb #1{\ifnum#1<14 \CALX_Ltmp{#1}%
   \expandafter\CALX_Ltmpb\expandafter{\the\numexpr#1+1\expandafter}\fi}%
\CALX_Ltmpb{4}%
\let\CALX_LWa\relax \let\CALX_Ltmp\relax \let\CALX_Ltmpb\relax
%    \end{macrocode}
%\begin{lverb}
% final, after \CALX_LGf<g> (v0 read):
% v1!..!vn!\CALX_LQ!\CALX_LQ!J8;..;key;E;P.
% U'' limbs MS first (t < 0: top v3 - 10^4), then the kernel with the
% schedule \CALX_Zlg<g> (g baked in \CALX_LGfp<g>, \CALX_LGfn<g>)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGFs #1\CALX_Zq!#2.%
{%
    \expandafter\expandafter\expandafter\CALX_Zst
    \csname CALX_Zlg#2\expandafter\endcsname
    \expandafter{\expanded{\CALX_Zbt#1\CALX_Zq!}}%
}%
%    \end{macrocode}
%\begin{lverb}
% {U}x_top.<n-1 limbs dddd!>\CALX_Zq -> \CALX_LGTv A!P2!..!Pm!;
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGFk #1#2.#3\CALX_Zq%
   {\expandafter\CALX_LGFa\expanded{{#2}#3}\CALX_Zq!\CALX_Zq!}%
\def\CALX_LGFa #1#2!#3\CALX_Zq!\CALX_Zq!%
{%
    \expandafter\CALX_LGTv\the\numexpr#1*10000+#2\expandafter!%
    \expanded{\CALX_LGFb#3\CALX_Zq!\CALX_Zq!};%
}%
\def\CALX_LGFb #1!#2!{\CALX_Zgob#1\CALX_LGFc\CALX_Zq#1#2!\CALX_LGFb}%
\def\CALX_LGFc\CALX_Zq#1\CALX_LGFb{}%
%    \end{macrocode}
%\begin{lverb}
% tables: A!P2!..!Pm!;key; -> sums (zip with the entry, m <= 14 items;
% a dummy item 0! lets the sentinel step read past the 14th)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGTx #1#2#3;#4;%
   {\expandafter\expandafter\expandafter\CALX_LGTw\csname#2#4\endcsname
    \relax#1{#3}}%
\def\CALX_LGTw #1\relax#2#3%
   {\expandafter#2\expanded{\CALX_LGad#3\CALX_LQ!;#10!\relax};}%
\def\CALX_LGad #1!#2;#3!%
   {\CALX_LGgt#1\CALX_LGae\CALX_LQ\the\numexpr#1+#3!\CALX_LGad#2;}%
\def\CALX_LGae\CALX_LQ#1\relax{}%
\def\CALX_LGTv{\CALX_LGTx\CALX_LGTu{CALX_Lv}}%
\def\CALX_LGTu{\CALX_LGTx\CALX_LGTt{CALX_Lu}}%
\def\CALX_LGTt{\CALX_LGTx\CALX_LGTs{CALX_Lt}}%
\def\CALX_LGTs{\CALX_LGTx\CALX_LGTb{CALX_Ls}}%
\def\CALX_LGTb{\CALX_LGTx\CALX_LGch{CALX_Lb}}%
%    \end{macrocode}
%\begin{lverb}
% carry chain with E ln10: A!P2!..!Pm!;E; ; ln10 = 2.3025 8509 then the
% limbs of \CALX_Lzl; pair P_i whole in its low limb column
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGch{\expandafter\CALX_LGci\CALX_Lzl\relax}%
%    \end{macrocode}
%\begin{lverb}
% template (shared with exp): \CALX_LGcidef <name><cont>{<params>}
% {<integer column prefix>}; params ##1 ln10 limbs, ##2 A, ##3 pairs, ##4 E
%\end{lverb}
%    \begin{macrocode}
\def\CALX_LGcidef #1#2#3#4%
{%
  \def#1#3%
  {%
    \expandafter#2\the\numexpr#4 2*##4\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+3025*##4\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+##2+8509*##4\CALX_LGcy##3\CALX_LQ!;##4;##10!0!\relax
  }%
}%
\CALX_LGcidef\CALX_LGci\CALX_LGo{#1\relax#2!#3;#4;}{}%
\def\CALX_LGcy #1!#2;#3;#4!#5!%
{%
    \CALX_LGgt#1\CALX_LGce\CALX_LQ\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#4*#3\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#1+#5*#3\CALX_LGcy#2;#3;%
}%
\def\CALX_LGce\CALX_LQ#1\relax{\relax!\CALX_LQ}%
\def\CALX_Ltmp #1%
{%
    \expandafter\def\csname CALX_LGfp#1\endcsname
       0000!0000!##1\CALX_LQ!\CALX_LQ!%
       {\CALX_LGFs##1\CALX_Zq!#1.}%
    \expandafter\def\csname CALX_LGfn#1\endcsname
       9999!9999!##1!##2\CALX_LQ!\CALX_LQ!%
       {\expandafter\CALX_LGFs\the\numexpr##1-10000!##2\CALX_Zq!#1.}%
}%
\CALX_Ltmp4\CALX_Ltmp5\CALX_Ltmp6\CALX_Ltmp7\CALX_Ltmp8\CALX_Ltmp9%
\CALX_Ltmp{10}\CALX_Ltmp{11}\CALX_Ltmp{12}\CALX_Ltmp{13}%
\let\CALX_Ltmp\relax
%    \end{macrocode}
%\begin{lverb}
% dispatch: P17..P100 (LG), P1..P8 as before, P9..P16 by the P16 code
% (16-digit grid, input padded with zeros, one rounding to P digits)
%\end{lverb}
%    \begin{macrocode}
\expandafter\let\csname CALX_LGtagF-\expandafter\endcsname
   \csname CALX_lgHsF-\endcsname
\expandafter\let\csname CALX_LGtagI+\expandafter\endcsname
   \csname CALX_lgHsI+\endcsname
\expandafter\let\csname CALX_LGtagI-\expandafter\endcsname
   \csname CALX_lgHsI-\endcsname
\expandafter\let\csname CALX_LGtagI?\expandafter\endcsname
   \csname CALX_lgHsI?\endcsname
\def\CALX_lga #1#2%
{%
    \ifnum\XINTdigits>16 \xint_dothis{\csname CALX_LGtag#1#2\endcsname}\fi
    \ifnum\XINTdigits<9 \xint_dothis{\csname CALX_lgUtag#1#2\endcsname}\fi
    \xint_orthat{\csname CALX_Ltag#1#2\endcsname}%
}%
%    \end{macrocode}
% \subsection{\csh{calxFpLogOnePlus}, \csh{calxRawLogOnePlus}}
%\begin{lverb}
% log1p(x) = log(1 + x).
% Input rounded to P digits; x <= -1: errors as log; x = 0: 0.
%(  A. |x| >= 0.1: r = round_P(1+x), d = (1+x) - r (exact, one digit), y =
%:     L(r) + d/r, L(r) the UNROUNDED internal log (P16 code for P <= 16),
%:     d/r by \CALX_fdiv at 9 digits, exact sum, one rounding.
%:  B. 10^-4 <= |x| < 0.1: V = 10^W (1+x) exact (W = 24, or 8 ceil(P/8) + 8
%:     for P > 16), the staged unity path of log (\CALX_LsAa, \CALX_LGsa).
%:  C. |x| < 10^-4: x G(x) by the kernel (\CALX_lpC below).
%)
%\end{lverb}
%    \begin{macrocode}
\def\calxFpLogOnePlus{\romannumeral0\expandafter\CALX_lpa
    \romannumeral0\CALX_fround{\XINTdigits}}%
\def\calxRawLogOnePlus #1{\romannumeral0\CALX_ftoraw{\calxFpLogOnePlus{#1}}}%
\def\CALX_lpnfl #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpLogOnePlus#3}}%
}%
\def\CALX_lpnex #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxRawLogOnePlus#3}}%
}%
%    \end{macrocode}
%\begin{lverb}
% expression function log1p: the only names with log1p (a digit: \csname)
%\end{lverb}
%    \begin{macrocode}
\expandafter\let\csname XINT_flexpr_func_log1p\endcsname\CALX_lpnfl
\expandafter\let\csname XINT_expr_func_log1p\endcsname\CALX_lpnex
\def\CALX_lpa #1#2{\csname CALX_lptag#1#2\endcsname}%
\expandafter\let\csname CALX_lptagI+\expandafter\endcsname
   \csname CALX_lgHsI+\endcsname
\expandafter\let\csname CALX_lptagI?\expandafter\endcsname
   \csname CALX_lgHsI?\endcsname
\expandafter\def\csname CALX_lptagI-\endcsname#1\xint:%
   {\CALX_nsig{InvalidOperation}{log1p(-inf)}{}}%
\begingroup\catcode`F=12
\expandafter\gdef\csname CALX_lptagF+\endcsname #1.#2.#3\xint:%
{%
    \ifnum#1=\xint_c_ \xint_dothis{ F+0.0.}\fi
    \xint_orthat{\expandafter\CALX_lpb
      \the\numexpr#1-\xint_c_i+\xint_c_viii*#2.+#1.#2.#3\xint:}%
}%
%    \end{macrocode}
%\begin{lverb}
% x < 0: E >= 0 means x <= -1 (\CALX_lpm$empty: 1 + x = 0 or < 0)
%\end{lverb}
%    \begin{macrocode}
\expandafter\gdef\csname CALX_lptagF-\endcsname #1.#2.%
{%
    \ifnum\numexpr#1-\xint_c_i+\xint_c_viii*#2>-\xint_c_i
      \xint_dothis\CALX_lptag_negative_domain\fi
    \xint_orthat\CALX_lptag_negative_regular #1.#2.%
}%
\gdef\CALX_lptag_negative_domain #1.#2.#3\xint:%
   {\expandafter\CALX_lpm\romannumeral0\CALX_faddx
        {F+1.0.100000001!}{F-#1.#2.#3}\xint:}%
\gdef\CALX_lptag_negative_regular #1.#2.#3\xint:%
   {\expandafter\CALX_lpb
      \the\numexpr#1-\xint_c_i+\xint_c_viii*#2.-#1.#2.#3\xint:}%
\gdef\CALX_lpm F#1#2.#3\xint:%
{%
    \ifnum#2=\xint_c_ \xint_dothis{\CALX_nsig{DivisionByZero}{log1p(-1)}{-}}\fi
    \xint_orthat{\CALX_nsig{InvalidOperation}{log1p(x), x < -1}{}}%
}%
%    \end{macrocode}
%\begin{lverb}
% classes by the decimal exponent E of x: E >= -1, E <= -5, else B
%\end{lverb}
%    \begin{macrocode}
\gdef\CALX_lpb #1.#2#3.%
{%
    \ifnum#1>-\xint_c_ii \xint_dothis\CALX_lpb_large\fi
    \ifnum#1<-\xint_c_iv \xint_dothis\CALX_lpb_small\fi
    \xint_orthat\CALX_lpb_regular #1.#2#3.%
}%
\gdef\CALX_lpb_large #1.#2#3.#4.#5\xint:{\CALX_lpA#2#3.#4.#5\xint:}%
\gdef\CALX_lpb_small #1.#2#3.#4.#5\xint:{\CALX_lpC lps;#2#3.#4.#5\xint:}%
\gdef\CALX_lpb_regular #1.#2#3.#4.#5\xint:{\CALX_lpB#2#3.#4.#5\xint:}%
%    \end{macrocode}
%\begin{lverb}
% A: |x| >= 0.1
%\end{lverb}
%    \begin{macrocode}
\gdef\CALX_lpA #1\xint:%
   {\expandafter\CALX_lpAa
    \romannumeral0\CALX_faddx{F+1.0.100000001!}{F#1}\xint:}%
\gdef\CALX_lpAa #1\xint:%
   {\expandafter\CALX_lpAb\romannumeral0\CALX_fround{\XINTdigits}{#1}#1\xint:}%
\gdef\CALX_lpAb #1\xint:#2\xint:%
   {\expandafter\CALX_lpAc\romannumeral0\CALX_fsubx{#2}{#1}\xint:#1\xint:}%
\gdef\CALX_lpAc F#1#2.%
{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_lpAc_zero\fi
    \xint_orthat\CALX_lpAc_regular F#1#2.%
}%
\gdef\CALX_lpAc_zero F#1#2.#3\xint:F#4\xint:%
   {\CALX_fnround{\XINTdigits}{\CALX_lpL#4\xint:}}%
\gdef\CALX_lpAc_regular F#1#2.#3\xint:F#4\xint:%
   {\CALX_fnround{\XINTdigits}{\CALX_faddx{\CALX_lpL#4\xint:}%
      {\CALX_fdiv{9}{F#1#2.#3}{F#4}}}}%
\endgroup
%    \end{macrocode}
%\begin{lverb}
% unrounded internal log of r = +<D>.<e>.<blocks> (bodies of \CALX_Ltb,
% \CALX_LGtb without the rounding)
% \CALX_lpLP P.+<D>.<e>.<blocks>\xint: at precision P (\XINTdigits or
% digits; P <= 112; P <= 16: the P16 code), shared with pow
%\end{lverb}
%    \begin{macrocode}
\def\CALX_lpL{\CALX_lpLP\XINTdigits.}%
\def\CALX_lpLP #1.+#2.#3.#4\xint:%
{%
    \expandafter\CALX_lpLb\the\numexpr#1\expandafter.%
    \the\numexpr(#2+\xint_c_iii)/\xint_c_viii
    \expandafter.\the\numexpr#2-\xint_c_i+\xint_c_viii*#3.#2.#4\xint:%
}%
\def\CALX_lpLb #1.%
   {\ifnum#1>16 \expandafter\CALX_LGL\else\expandafter\CALX_lpLd\fi#1.}%
\def\CALX_lpLd #1.{\CALX_lpLs}%
\def\CALX_lpLs #1.#2.#3.#4\xint:%
   {\csname CALX_Lin\romannumeral#1\endcsname\CALX_LM#4\xint:#2.#3.}%
%    \end{macrocode}
%\begin{lverb}
% B: 10^-4 <= |x| < 0.1; Bw = W/8 blocks, nb blocks of N
%\end{lverb}
%    \begin{macrocode}
\def\CALX_lpB #1#2.#3.#4\xint:%
{%
    \expandafter\CALX_lpBa\the\numexpr\ifnum\XINTdigits>16
      (\XINTdigits+\xint_c_iii)/\xint_c_viii+\xint_c_i\else\xint_c_iii\fi
    \expandafter.\the\numexpr(#2+\xint_c_iii)/\xint_c_viii.#1#3.#4\xint:%
}%
\def\CALX_lpBa #1.#2.#3#4.#5\xint:%
{%
    \CALX_Lfr\XINTdigits{\csname CALX_lpB\ifnum\XINTdigits>16 g\else s\fi#3%
      \endcsname{\expandafter\CALX_lpzb\the\numexpr#1+#4.#5%
      \expandafter\CALX_lpzb\the\numexpr-#4-#2.}}%
}%
\def\CALX_lpzb #1.{\ifnum#1>\xint_c_ 100000000!\expandafter\CALX_lpzb
   \the\numexpr#1-1\expandafter.\fi}%
%    \end{macrocode}
%\begin{lverb}
% the selectors receive V = v0!v1!..: v0 = 1, x 10^W; v0 = 0, 10^W - |x| 10^W
%\end{lverb}
%    \begin{macrocode}
\expandafter\def\csname CALX_lpBs+\endcsname #1%
   {\expandafter\CALX_LsAa\expandafter1\expandafter!\expanded
    {\expandafter\CALX_shr\expanded{#1}\CALX_Zq!\relax}0;0;}%
\expandafter\def\csname CALX_lpBs-\endcsname #1%
   {\expandafter\CALX_LsAa\expandafter0\expandafter!\expanded
    {\expandafter\CALX_shr\expanded{\expandafter\CALX_lpcz\expanded{#1}%
     \CALX_Zq!}\CALX_Zq!\relax}0;0;}%
\expandafter\def\csname CALX_lpBg+\endcsname #1%
   {\csname CALX_LGsa\the\numexpr(\XINTdigits-5)/8\expandafter\endcsname
    \expandafter1\expandafter!\expanded
    {\expandafter\CALX_shr\expanded{#1}%
     \CALX_Zq!\relax}\CALX_LQ!\CALX_LQ!0;0;\XINTdigits.}%
\expandafter\def\csname CALX_lpBg-\endcsname #1%
   {\csname CALX_LGsa\the\numexpr(\XINTdigits-5)/8\expandafter\endcsname
    \expandafter0\expandafter!\expanded
    {\expandafter\CALX_shr\expanded{\expandafter\CALX_lpcz\expanded{#1}%
     \CALX_Zq!}\CALX_Zq!\relax}\CALX_LQ!\CALX_LQ!0;0;\XINTdigits.}%
%    \end{macrocode}
%\begin{lverb}
% 10^(8k) - X on blocks 1<8 digits>! LS first (inside \expanded): zero
% blocks stay (\CALX_lpcz), the first nonzero one gives 10^8 - b, the
% others 10^8 - 1 - b (\CALX_lpco)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_lpcz #1#2!{\CALX_Zgob#1\CALX_lpce\CALX_Zq\CALX_lpcy#2!}%
\def\CALX_lpcy #1!{\ifnum#1=\xint_c_ 100000000!\expandafter\CALX_lpcz\else
   \the\numexpr200000000-#1!\expandafter\CALX_lpco\fi}%
\def\CALX_lpco #1#2!{\CALX_Zgob#1\CALX_lpce\CALX_Zq\CALX_lpcb#2!}%
\def\CALX_lpcb #1!{\the\numexpr199999999-#1!\CALX_lpco}%
\def\CALX_lpce\CALX_Zq#1!{}%
%    \end{macrocode}
%\begin{lverb}
% C: |x| < 10^-4: y = x G(x), G = sum (-x)^k/(k+1), by the kernel with
% the levels of log's unity zone for P' = max(P,17) but b_k = A-k-1
% (\CALX_lpS<P'>: U' = 10^4 x may have more limbs than log's delta), then
% an exact product level on X' (x = X' 10^(-8z), as calxtrig's sin) and
% calxtrig's finisher \CALX_shx (kind s: one rounding to P digits).
% U' list: x > 0: limbs of x (2z zero limbs, then those of N) without the
% first one (0000); x < 0: limbs of 1 + x, 9999 dropped, the next one
% minus 10^4 (as log's E = -1 unity entry); a zero limb appended (\CALX_Zbt
% needs two items); z > 14: U' = 0; then A zero limbs (the levels read up
% to A+1 items).
% kind;s D.e.blocks, kind lp (log1p) or em (expm1: schedules
% \CALX_emS<P'>, U lists \CALX_emU<s> = \CALX_lpU<-s>)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_lpC #1;#2#3.#4.#5\xint:%
{%
    \expandafter\CALX_lpCa\the\numexpr-#4-(#3+\xint_c_iii)/\xint_c_viii
    \expandafter.\the\numexpr\ifnum\XINTdigits<17 17\else
                              \XINTdigits\fi.#1;#2{#5}%
}%
\def\CALX_lpCa #1.#2.#3#4#5;#6#7%
{%
    \csname CALX_#3#4S#2\expandafter\endcsname\expanded{{\ifnum#1>14 0!0!0!0!%
      \else\csname CALX_#3#4U#6\endcsname#1.{#7}\fi
      \expandafter\CALX_Zzr\the\numexpr(#2+\ifnum#2>64 6\else5\fi)/4.}%
      \expandafter\noexpand\csname CALX_lpF#2\endcsname
      {\expandafter\CALX_Zbt\expanded{\CALX_shr#7\CALX_Zq!\relax
       \expandafter\CALX_Zzr\the\numexpr2*((#2+10)/8).}\CALX_Zq!}}#1.#6#5%
}%
\expandafter\def\csname CALX_lpU+\endcsname #1.#2%
{%
    \expandafter\CALX_Zbt\expanded{\expandafter\CALX_lpdr\expanded
      {\expandafter\CALX_Zzr
       \the\numexpr2*#1.\CALX_shr#2\CALX_Zq!\relax}0!}\CALX_Zq!%
}%
\expandafter\def\csname CALX_lpU-\endcsname #1.#2%
{%
    \expandafter\CALX_Zbt\expanded{\expandafter\CALX_lpdn\expanded
      {\expandafter\CALX_shr\expanded{\expandafter\CALX_lpcz\expanded
      {#2\CALX_lpzb#1.}\CALX_Zq!}\CALX_Zq!\relax}0!}\CALX_Zq!%
}%
\def\CALX_lpdr #1!{}%
\def\CALX_lpdn #1!#2!{\the\numexpr#2-10000!}%
%    \end{macrocode}
%\begin{lverb}
% load time, P' = 17..100: \CALX_lpS<P'>{U list} (C_(A-1), levels A-2..0,
% level 0 negated), \CALX_lpF<P'>{U}<T_0>\CALX_Zq{X' list}: exact product
% level X'_int T_0 (b_p = 2 ceil((P'+7)/8) limbs of X', A+1 of T_0), then
% \CALX_shx with <pairs>.<m0>.{0000!}{post} (b_p + A fractional limbs)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Ltmp #1%
{%
    \edef\CALX_LWa{\the\numexpr(#1+\ifnum#1>64 6\else5\fi)/4}%
    \edef\CALX_LWm{\the\numexpr\CALX_LWa-1}%
    \edef\CALX_LWp{\the\numexpr2*((#1+10)/8)}%
    \expandafter\edef\csname CALX_lpS#1\endcsname##1%
    {%
      \noexpand\CALX_Zd\expandafter\CALX_Zhd\expanded{\CALX_tcoef{l}%
        {\CALX_LWa-1}{1}{1}\CALX_tq}\relax.\noexpand\CALX_Zq{##1}%
      \expandafter\CALX_LWbl\the\numexpr\CALX_LWa-2.%
    }%
    \expandafter\edef\csname CALX_lpF#1\endcsname##1##2\CALX_Zq##3%
    {%
      \noexpand\CALX_Zd##2\noexpand\CALX_Zq{##3}%
      \CALX_Zlevp{\CALX_LWp}{\the\numexpr\CALX_LWa+1\relax}\CALX_Zuf
      \noexpand\CALX_shx{\ifodd\CALX_LWa\space
        \the\numexpr(\CALX_LWp+\CALX_LWa+3)/2.%
        \the\numexpr(\CALX_LWp+\CALX_LWa+1)/2.%
        {0000!}{0000!}\else
        \the\numexpr(\CALX_LWp+\CALX_LWa+2)/2.%
        \the\numexpr(\CALX_LWp+\CALX_LWa)/2.%
        {0000!}{}\fi}%
    }%
}%
\let\CALX_LWfin\empty
\def\CALX_Ltmpb #1{\ifnum#1<101 \CALX_Ltmp{#1}%
   \expandafter\CALX_Ltmpb\expandafter{\the\numexpr#1+1\expandafter}\fi}%
\CALX_Ltmpb{17}%
\let\CALX_LWa\relax \let\CALX_LWm\relax \let\CALX_LWp\relax
\let\CALX_LWfin\relax
\let\CALX_Ltmp\relax \let\CALX_Ltmpb\relax
%    \end{macrocode}
% \subsection{\csh{calxFpLogTen}, \csh{calxRawLogTen}}
%\begin{lverb}
% log10(x).
% y = L(x) k_P, L(x) the unrounded internal ln (\CALX_lpL of log1p: the
% P16 code for P <= 16), k_P = round_(P+12)(1/ln10) (\CALX_ltk<P>, load
% time), exact product (\CALX_fmulx), one rounding. x = 1: 0; x = 10^k: k.
%\end{lverb}
%    \begin{macrocode}
\def\calxFpLogTen{\romannumeral0\expandafter\CALX_lta
    \romannumeral0\CALX_fround{\XINTdigits}}%
\def\calxRawLogTen #1{\romannumeral0\CALX_ftoraw{\calxFpLogTen{#1}}}%
\def\CALX_ltnfl #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpLogTen#3}}%
}%
\def\CALX_ltnex #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxRawLogTen#3}}%
}%
%    \end{macrocode}
%\begin{lverb}
% expression function log10: the only names with log10 (a digit: \csname)
%\end{lverb}
%    \begin{macrocode}
\expandafter\let\csname XINT_flexpr_func_log10\endcsname\CALX_ltnfl
\expandafter\let\csname XINT_expr_func_log10\endcsname\CALX_ltnex
\def\CALX_lta #1#2{\csname CALX_ltt#1#2\endcsname}%
\expandafter\let\csname CALX_lttI+\expandafter\endcsname
   \csname CALX_lgHsI+\endcsname
\expandafter\let\csname CALX_lttI?\expandafter\endcsname
   \csname CALX_lgHsI?\endcsname
\expandafter\def\csname CALX_lttI-\endcsname#1\xint:%
   {\CALX_nsig{InvalidOperation}{log10(-inf)}{}}%
\expandafter\def\csname CALX_lttF-\endcsname#1\xint:%
   {\CALX_nsig{InvalidOperation}{log10(x), x < 0}{}}%
\expandafter\def\csname CALX_lttF+\endcsname #1.#2.#3\xint:%
{%
    \ifnum#1=\xint_c_ \xint_dothis{\CALX_nsig{DivisionByZero}{log10(0)}{-}}\fi
    \xint_orthat{\CALX_fnround{\XINTdigits}%
      {\CALX_fmulx{\CALX_lpL+#1.#2.#3\xint:}%
      {\csname CALX_ltk\the\numexpr\XINTdigits\endcsname}}}%
}%
%    \end{macrocode}
%\begin{lverb}
% k_P, P = 1..100, from 1/ln10 truncated to 130 digits (calxlogdata.tex)
%\end{lverb}
%    \begin{macrocode}
\edef\CALX_Ltmpb{\romannumeral0\CALX_ffromraw{\CALX_Lzinvraw}}%
\def\CALX_Ltmp #1.%
{%
    \expandafter\edef\csname CALX_ltk#1\endcsname
      {\romannumeral0\CALX_fnround{#1+12}{\CALX_Ltmpb}}%
    \ifnum#1<100 \expandafter\CALX_Ltmp\the\numexpr#1+1\expandafter.\fi
}%
\CALX_Ltmp 1.\let\CALX_Ltmp\relax \let\CALX_Ltmpb\relax
%    \end{macrocode}
% \subsection{\csh{calxFpExp}, \csh{calxRawExp}}
%\begin{lverb}
% Exponential, P9..P16. x rounded to P+14 digits on entry, sliced at 10^-24.
% k = ceil(Z/10^5), Z = nint(10^5 |x|/ln10) (approximate), bucket i of
% -r0 = k ln10 - x; buckets 1..98: a = A[i], c = nint(200000/(2a+1)),
% constant ln(10^4/c); bucket 0: c = 10^4, no constant; bucket 99: c = 1000,
% constant ln10 (equivalent to k = nint(x/ln10)): r1 = x - k ln10 + constant,
% |r1| < 0.0488, R1 = 10^10 r1 in one \numexpr; stages k = 2, 4, 6, 8 on the
% short residual R (tables Ls, Lt, Lu, Lv: -ln(1 + j 10^-k)); t on the grid
% 10^-24 (|t| < 5.5e-9), U = 10^24 (e^t - 1), G = c (100+j2)(10^4+j4)
% (10^6+j6)(10^8+j8) exact, Y' = G + G U 10^-24: exp x = 10^(k-24) Y', one
% rounding to P digits.
%\end{lverb}
%    \begin{macrocode}
\let\CALX_exQ\relax
\def\calxFpExp{\romannumeral0\expandafter\CALX_exa
    \romannumeral0\CALX_fround{\XINTdigits+14}}%
\def\calxRawExp #1{\romannumeral0\CALX_ftoraw{\calxFpExp{#1}}}%
\def\CALX_exnfl #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpExp#3}}%
}%
\def\CALX_exnex #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxRawExp#3}}%
}%
\let\XINT_flexpr_func_exp\CALX_exnfl
\let\XINT_expr_func_exp\CALX_exnex
\def\CALX_exa #1#2{\csname CALX_ext#1#2\endcsname}%
\begingroup\catcode`F=12
\expandafter\gdef\csname CALX_extI+\endcsname#1\xint:{ I+}%
\expandafter\gdef\csname CALX_extI-\endcsname#1\xint:{ F+0.0.}%
\expandafter\gdef\csname CALX_extI?\endcsname#1\xint:{ I?}%
\expandafter\gdef\csname CALX_extF+\endcsname{\CALX_exb ex;+}%
\expandafter\gdef\csname CALX_extF-\endcsname{\CALX_exb ex;-}%
%    \end{macrocode}
%\begin{lverb}
% kind;s D, e, blocks (kind: ex = exp, pw = pow10, em = expm1: the readers
% \CALX_<kind>G, <kind>hG, <kind>gG, <kind>Ja); x = 0 -> 1; p = e + ceil(D/8)
% - 1 (top block position)
%\end{lverb}
%    \begin{macrocode}
\gdef\CALX_exb #1;#2#3.%
{%
    \ifnum\XINTdigits>16 \xint_dothis\CALX_exb_big\fi
    \ifnum#3=\xint_c_ \xint_dothis\CALX_exb_zero\fi
    \xint_orthat\CALX_exb_regular #1;#2#3.%
}%
\gdef\CALX_exb_big #1;#2#3.#4.#5\xint:{\CALX_exgb#1;#2#3.#4.#5\xint:}%
\gdef\CALX_exb_zero #1;#2#3.#4.#5\xint:{ F+1.0.100000001!}%
\gdef\CALX_exb_regular #1;#2#3.#4.#5\xint:%
{%
    \expandafter\CALX_exc
      \the\numexpr#4+(#3+\xint_c_iii)/\xint_c_viii-\xint_c_i\expandafter.%
      \the\numexpr#4\expandafter.%
      \csname CALX_#1\ifnum\XINTdigits<9 h\fi G\endcsname#2#5\xint:%
}%
%    \end{macrocode}
%\begin{lverb}
% p < -3: |x| < 10^-24, result 1; p >= 2: |x| >= 10^16, over/underflow;
% #3 the layout reader (\CALX_exG, or \CALX_exhG for P <= 8)
%\end{lverb}
%    \begin{macrocode}
\gdef\CALX_exc #1.#2.%
{%
    \ifnum#1>\xint_c_i \xint_dothis\CALX_exc_over\fi
    \ifnum#1<-\xint_c_iii \xint_dothis\CALX_exc_small\fi
    \xint_orthat\CALX_exc_regular #1.#2.%
}%
\gdef\CALX_exc_over #1.#2.#3#4#5\xint:{\CALX_exO#4}%
\gdef\CALX_exc_small #1.#2.#3#4#5\xint:{ F+1.0.100000001!}%
\gdef\CALX_exc_regular #1.#2.#3#4#5\xint:%
{%
    \csname CALX_exL\the\numexpr#2+\xint_c_iii\endcsname
      #3#5100000000!100000000!100000000!100000000!\xint:#4%
}%
\endgroup
%    \end{macrocode}
%\begin{lverb}
% grid layout (e = -7..1, D <= P+21): drop -(e+3) low blocks or prepend
% e+3 zero blocks, then
% \CALX_exG reads f3 (10^-24), f2, f1, I (integer block) and the sign
%\end{lverb}
%    \begin{macrocode}
\expandafter\def\csname CALX_exL-4\endcsname#1#2!#3!#4!#5!{#1}%
\expandafter\def\csname CALX_exL-3\endcsname#1#2!#3!#4!{#1}%
\expandafter\def\csname CALX_exL-2\endcsname#1#2!#3!{#1}%
\expandafter\def\csname CALX_exL-1\endcsname#1#2!{#1}%
\expandafter\let\csname CALX_exL0\endcsname\xint_firstofone
\expandafter\def\csname CALX_exL4\endcsname
   #1{#1100000000!100000000!100000000!100000000!}%
\expandafter\def\csname CALX_exL1\endcsname#1{#1100000000!}%
\expandafter\def\csname CALX_exL2\endcsname#1{#1100000000!100000000!}%
\expandafter\def\csname CALX_exL3\endcsname#1{#1100000000!100000000!100000000!}%
%    \end{macrocode}
%\begin{lverb}
% Z = nint(X5*434294482/10^9) ~ 10^5 |x|/ln10, X5 = nint(10^5 |x|); data
% for the table macro: s x12, s x34, s x56 (8-digit pairs), s xI. Rare
% path if the integer block xI >= 10^4 or the block at 10^8 (first of #5)
% is not zero.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exGt #1!#2\xint:{#1}%
%    \end{macrocode}
%\begin{lverb}
% normal branch (shared): f3.f2.f1.xI.s<table letter><marker>; the
% marker (\CALX_exMk exp's writer, \CALX_emMk expm1's finisher, empty for
% the P <= 8 path) ends the stream and is read by the writers after k.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exGn #1.#2.#3.#4.#5#6#7%
{%
    \expandafter\CALX_exK\the\numexpr(#4*100000+#3/1000)*434294482/1000000000.%
    #5#6#5#3.#5#2.#5#1.#5#4.#7%
}%
\def\CALX_exG 1#1!1#2!1#3!1#4!#5\xint:#6%
{%
    \ifnum#4>9999 \xint_dothis{\CALX_exHa#5\xint:#6#4.#3.#2.#1.}\fi
    \ifnum\CALX_exGt#5\xint:>100000000
      \xint_dothis{\CALX_exHa#5\xint:#6#4.#3.#2.#1.}\fi
    \xint_orthat{\CALX_exGn#1.#2.#3.#4.#6A\CALX_exMk}%
}%
%    \end{macrocode}
%\begin{lverb}
% P <= 8: as \CALX_exG with the table macros \CALX_exC<i>
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exhG 1#1!1#2!1#3!1#4!#5\xint:#6%
{%
    \ifnum#4>9999 \xint_dothis{\CALX_exHa#5\xint:#6#4.#3.#2.#1.}\fi
    \ifnum\CALX_exGt#5\xint:>100000000
      \xint_dothis{\CALX_exHa#5\xint:#6#4.#3.#2.#1.}\fi
    \xint_orthat{\CALX_exGn#1.#2.#3.#4.#6C\CALX_exMk}%
}%
%    \end{macrocode}
%\begin{lverb}
% k = ceil(s Z/10^5) (floor(a/b) = (2a-b+1)/(2b), a >= 0); #3 table letter
% (A: P <= 16, B: P > 16)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exK #1.#2#3%
{%
    \expandafter\CALX_exKa\the\numexpr\if-#2 0-(2*#1-99999)/200000\else
      (2*#1+99999)/200000\fi.#1.#2#3%
}%
%    \end{macrocode}
%\begin{lverb}
% i = floor(m/1000), m = k 10^5 - s Z in [0, 10^5): table macro
% \CALX_ex<A|B><i>
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exKa #1.#2.#3#4%
{%
    \csname CALX_ex#4\the\numexpr(2*(#1*100000\if-#3+\else-\fi#2)-999)/2000%
    \endcsname#1.%
}%
%    \end{macrocode}
%\begin{lverb}
% the ln10 chain (template of log P9..P16): A!P2!P3!0;-k.sxI.<tail>
%\end{lverb}
%    \begin{macrocode}
\CALX_LTdef\CALX_exC\CALX_exW{#1!#2!#3!#4;#5.#6.#7\CALX_exQ}{#6+}{#7}%
%    \end{macrocode}
%\begin{lverb}
% state R.S2.S4.S6.<J list>| (R1 and the Lb items from the table macro);
% stages: \CALX_exTmp <S><R><next>{<short table>}{<j of R = #1>}{<R update>}
% S: fetch F1!c2!c3!j. (load-time short tables); R: R, sums, J list
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exTmp #1#2#3#4#5#6%
{%
    \def#1##1.{\expandafter\expandafter\expandafter#2%
       \csname#4\the\numexpr#5\endcsname##1.}%
    \def#2##1!##2!##3!##4.##5.##6.##7.##8.##9|%
    {%
        \expandafter#3#6\the\numexpr##6+##1\expandafter.\the\numexpr##7+##2%
        \expandafter.\the\numexpr##8+##3.##4;##9|%
    }%
}%
\CALX_exTmp\CALX_exSa\CALX_exRa\CALX_exSb{CALX_exu}%
   {(#1+#1*#1/1000000000/20)/100000000}%
   {\the\numexpr#5+100*#1+#2/1000000\expandafter.}%
\CALX_exTmp\CALX_exSb\CALX_exRb\CALX_exSc{CALX_exv}%
   {(#1+#1*#1/1000000000/20)/1000000}%
   {\the\numexpr#5+100*#1+#2/1000000\expandafter.}%
\CALX_exTmp\CALX_exSc\CALX_exRc\CALX_exSd{CALX_exw}%
   {#1/10000}%
   {\the\numexpr#5+100*#1+#2/1000000\expandafter.}%
\CALX_exTmp\CALX_exSd\CALX_exRd\CALX_exV{CALX_exz}%
   {#1/100}{}%
\let\CALX_exTmp\relax
%    \end{macrocode}
%\begin{lverb}
% chain 2: t = s x - k ln10 + Lb + Ls + Lt + Lu + Lv
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exV #1.#2.#3.#4|#5.#6.#7.#8.#9.%
   {\CALX_exC#5+#1!#6+#2!#7+#3!0;-#8.#9.#4|\CALX_exQ}%
%    \end{macrocode}
%\begin{lverb}
% t = T0!t1!..!t6! (|t| < 5.5e-9: t1 = t2 = 0000 or 9999), s =
% floor(10^16 t) = T0 10^8 + t3t4, rho = t5t6: U = 10^24 (e^t - 1) = s 10^8
% + rho + s^2/2e8 (dropped s rho/1e16 + t^3/6 < 0.6 units 10^-24), ONE chain,
% floor limbs u3 (signed)!u2!u1!u0!; then G (\CALX_exEc) and \CALX_exPS
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exW #1!#2!#3!#4!#5!#6!#7!%
{%
    \expandafter\CALX_exWj\expandafter{\the\numexpr
    0\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#1*100000000+#4#5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#6#7+(#1*100000000+#4#5)*(#1*100000000+#4#5)%
      /200000000\relax!}%
}%
\def\CALX_exWj #1#2;#3;#4;#5;#6;|{\CALX_exEc\CALX_exPS{#1}#6.#5.#4.#3.#2.}%
%    \end{macrocode}
%\begin{lverb}
% Y' = G + G U 10^-24 (G = g5..g0 ~ 10^24, U = u3..u0): columns c = i + m
% >= 6, guard c = 5 (its u0 term by \CALX_exPT), dropped columns and guard
% floor < 6 units of Y'; output T!y1!..!y5! (stream k.<marker>)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exPS #1!#2!#3!#4!#5!#6!#7!#8!#9!%
{%
    \expandafter\CALX_exY\the\numexpr#1\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#2\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#3\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#4+#1*#7\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#5+#1*#8+#2*#7\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#6+#1*#9+#2*#8+#3*#7\expandafter\CALX_LRz
    \the\numexpr\CALX_Loff+#2*#9+#3*#8+#4*#7\CALX_exPT#1!%
}%
\def\CALX_exPT #1!#2!{+#1*#2\relax!}%
%    \end{macrocode}
%\begin{lverb}
% writer: exp x = 10^(k-24) Y', Y' = T!y1!..!y5!, then k.<marker>. expm1
% marker: \CALX_emF; frequent: P9..P16 and 1000 <= T <= 9999 ((2T - 10999)^2
% <= 8999^2); else generic (\CALX_ffromraw, \CALX_fround).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exY #1!#2!#3!#4!#5!#6!#7.#8%
{%
    \ifx#8\CALX_exMk\else\xint_dothis{\CALX_emF#1#2#3#4#5#6.#7.24.#8}\fi
    \ifnum\XINTdigits<9 \xint_dothis{\CALX_exYg#1#2#3#4#5#6.#7.}\fi
    \ifnum\numexpr(2*#1-10999)*(2*#1-10999)>80982001
      \xint_dothis{\CALX_exYg#1#2#3#4#5#6.#7.}\fi
    \xint_orthat{\expandafter\expandafter\expandafter\CALX_exYa
      \csname CALX_exq\the\numexpr\XINTdigits\endcsname#1#2.#3#4.#5.#7.}%
}%
\def\CALX_exYg #1.#2.{\expandafter\CALX_exYgg\the\numexpr#2-24.#1.}%
\def\CALX_exYgg #1.#2.%
   {\CALX_fnround{\XINTdigits}{\CALX_ffromraw{#2[#1]}}}%
%    \end{macrocode}
%\begin{lverb}
% Q = 10^(16-P), C = 10^(P-8), Z = 1 if P = 16 (\CALX_exq<P>); H = T y1,
% L = y2 y3: M = round(Y'/10^(24-P)) = Mh 10^8 + Ml, Mh = floor(H/Q),
% Ml = (H - Q Mh) C + nint(L/Q) (+ nint(y4/10^4) if P = 16; for P < 16 the
% rounding boundaries are integers: the lower limbs are irrelevant)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exYa #1.#2.#3.#4.#5.#6.%
{%
    \expandafter\CALX_exYb\the\numexpr(2*#4-#1+1)/(2*#1)\expandafter.%
    \the\numexpr(#4-(2*#4-#1+1)/(2*#1)*#1)*#2+#5/#1+(2*#6+1)/20000*#3.%
}%
%    \end{macrocode}
%\begin{lverb}
% Mh.Ml.k. : carries (Ml = 10^8; M = 10^P -> 10^(P-1), k+1)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exYb #1.#2.#3.%
{%
    \ifnum#2>99999999
    \xint_dothis{\expandafter\CALX_exYe\the\numexpr#1+1.#3.}\fi
    \xint_orthat{\CALX_exYh#1.#2.#3.}%
}%
\def\CALX_exYe #1.#2.%
{%
    \ifnum#1=\CALX_pten{\XINTdigits-8} \xint_dothis{\expandafter\CALX_exYh
      \the\numexpr#1/10\expandafter.\expandafter0\expandafter.%
      \the\numexpr#2+1.}\fi
    \xint_orthat{\CALX_exYh#1.0.#2.}%
}%
%    \end{macrocode}
%\begin{lverb}
% g = k - P, e = floor(g/8), h = g - 8e (\CALX_exh<h> = h.10^h.10^(8-h).),
% D = P + h; blocks of M 10^h: A = floor(Ml/V), B = floor(Mh/V), V = 10^(8-h)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exYh #1.#2.#3.%
   {\expandafter\CALX_exYi\the\numexpr(2*(#3-\XINTdigits)-7)/16.#3.#1.#2.}%
\def\CALX_exYi #1.#2.%
{%
    \expandafter\expandafter\expandafter\CALX_exYk
    \csname CALX_exh\the\numexpr#2-\XINTdigits-8*#1\endcsname#1.%
}%
\begingroup\catcode`F=12
\gdef\CALX_exYk #1.#2.#3.#4.#5.#6.%
{%
    \expanded{ F+\the\numexpr\XINTdigits+#1.#4.%
      \the\numexpr100000000+(#6-(2*#6-#3+1)/(2*#3)*#3)*#2!%
      \the\numexpr100000000+(2*#6-#3+1)/(2*#3)+(#5-(2*#5-#3+1)/(2*#3)*#3)*#2!%
      \ifnum#5<#3 \else\the\numexpr100000000+(2*#5-#3+1)/(2*#3)!\fi}%
}%
\endgroup
\def\CALX_Ltmp #1.%
{%
    \expandafter\edef
    \csname CALX_exq#1\endcsname{\the\numexpr\CALX_pten{16-#1}.%
      \CALX_pten{#1-8}.\ifnum#1=16 1\else0\fi.}%
    \ifnum#1<16 \expandafter\CALX_Ltmp\the\numexpr#1+1\expandafter.\fi
}%
\CALX_Ltmp 9.%
\def\CALX_Ltmp #1.%
{%
    \expandafter\edef\csname CALX_exh#1\endcsname{#1.\CALX_pten{#1}.%
      \CALX_pten{8-#1}.}%
    \ifnum#1<7 \expandafter\CALX_Ltmp\the\numexpr#1+1\expandafter.\fi
}%
\CALX_Ltmp 0.\let\CALX_Ltmp\relax
%    \end{macrocode}
% \subsection{Exponential, P1..P8}
%\begin{lverb}
% Front, k, i and R1 as P16 (table macros \CALX_exC<i>); stages k = 2, 4 on
% the short residual R (scale 10^-10, keys only, P > 16 receivers); t = R4
% 10^-10, U = 10^10 (e^t - 1) = R4 + R4^2/(2 10^10) (t^3/6 < 2.2e-14);
% A = c(100+j2) = a1 10^4 + a0, G = A (10^4+j4) = H 10^4 + g0, H = A + a1 j4,
% g0 = a0 j4; Z' = 10^12 e^r0 = G (10^10+U)/10^8 = H 10^6 + L',
% L' = 100 g0 + H U/10^4 + g0 U/10^8; normalized H', L'' (0 <= L'' < 10^6);
% M = round(Z'/10^(12-P)), exp x = M 10^(k-P): calxtrig's \CALX_dgoc. P >= 6:
% M = H' 10^(P-6) + round(L''/10^(12-P)); P <= 5: M = round(H'/10^(6-P))
% exactly (the rounding boundaries are multiples of 10^6: L'' irrelevant).
% Relative error < 2.2e-10 (R1 0.52, tables 2 x 0.5, U 0.5 units 10^-10):
% 0.022 ulp_8.
% R4.j4;j2;c;|k.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exhV #1.#2;#3;#4;|%
{%
    \expandafter\CALX_exhW\the\numexpr#1+#1*#1/1000000000/20\expandafter.%
    \the\numexpr(2*#4*(100+#3)-9999)/20000\expandafter.%
    \the\numexpr#4*(100+#3).#2.%
}%
%    \end{macrocode}
%\begin{lverb}
% U, a1, A, j4: H = A + a1 j4, g0 = (A - 10^4 a1) j4
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exhW #1.#2.#3.#4.%
{%
    \expandafter\CALX_exhX\the\numexpr#3+#2*#4\expandafter.%
    \the\numexpr(#3-10000*#2)*#4.#1.%
}%
%    \end{macrocode}
%\begin{lverb}
% H, g0, U: L' -> H', L''
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exhX #1.#2.#3.%
{%
    \expandafter\CALX_exhY\the\numexpr100*#2+#1*#3/10000+#2*#3/100000000.#1.%
}%
\def\CALX_exhY #1.#2.%
{%
    \expandafter\CALX_exhZ\the\numexpr#2+(2*#1-999999)/2000000\expandafter.%
    \the\numexpr#1-1000000*((2*#1-999999)/2000000).%
}%
%    \end{macrocode}
%\begin{lverb}
% H', L'', k: frequent 10^5 <= H' < 10^6; M by P >= 6 / P <= 5
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exhZ #1.#2.#3.#4%
{%
    \ifx#4\CALX_exMk\else\xint_dothis{#4}\fi
    \ifnum#1<100000 \xint_dothis\CALX_exhR\fi
    \ifnum#1>999999 \xint_dothis\CALX_exhR\fi
    \ifnum\XINTdigits>5 \xint_dothis\CALX_exhP\fi
    \xint_orthat\CALX_exhQ#1.#2.#3.%
}%
\def\CALX_exhP #1.#2.#3.%
{%
    \expandafter\CALX_exhO\the\numexpr#1*\CALX_pten{\XINTdigits-6}%
      +#2/\CALX_pten{12-\XINTdigits}\expandafter.\the\numexpr#3-\XINTdigits.%
}%
\def\CALX_exhQ #1.#2.#3.%
{%
    \expandafter\CALX_exhO\the\numexpr#1/\CALX_pten{6-\XINTdigits}%
      \expandafter.\the\numexpr#3-\XINTdigits.%
}%
\def\CALX_exhO #1.#2.{\expandafter\CALX_dgoc\the\numexpr#1\expandafter.%
   \the\numexpr(2*#2-7)/16.#2.+}%
\def\CALX_exhR #1.#2.#3.%
{%
    \expandafter\CALX_exhRr\expanded{\the\numexpr#3-12.%
      #1\expandafter\xint_gobble_i\the\numexpr1000000+#2.}%
}%
\def\CALX_exhRr #1.#2.{\CALX_fnround{\XINTdigits}{\CALX_ffromraw{#2[#1]}}}%
%    \end{macrocode}
%\begin{lverb}
% rare path 10^4 <= |x| < 10^16: D = |x| - |K| ln10
% with |K| = 8 K8, K8 = floor(Ze/8) - 25, Ze ~ |x|/ln10 (8 leading digits):
% D in (290, 650) exactly on the grid (ln10 floored at 10^-36, |K| < 2^31);
% the fast path on x' = s D, then e <- e + s K8 (K = s |K|).
% |x| >= 4944763850 (approx.): overflow (x > 0), underflow (x < 0).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exHa 1#1!#2\xint:#3#4.%
{%
    \ifnum#1>49 \xint_dothis{\CALX_exOd#3}\fi
    \ifnum\numexpr#1*1000000+#4/100>49447638 \xint_dothis{\CALX_exOd#3}\fi
    \xint_orthat{\expandafter\CALX_exHb\the\numexpr
      (\ifnum#1>\xint_c_ (#1*1000000+#4/100)*434294482/1000000000*100\else
       #4*434294482/1000000000\fi-4)/8-25.#3#1.#4.}%
}%
\def\CALX_exOd #1#2.#3.#4.{\CALX_exO#1}%
%    \end{macrocode}
%\begin{lverb}
% K8, s, I1, I0, f1, f2, f3; |K| = k2 10^8 + k1 10^4 + k0; tail s K8.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exHb #1.#2#3.#4.%
   {\expandafter\CALX_exHc\the\numexpr(2*#1-12499999)/25000000.#1.#2#3.#4.}%
\def\CALX_exHc #1.#2.#3#4.#5.#6.#7.#8.%
   {\expandafter\CALX_exHd\the\numexpr8*#2-100000000*#1.#1.#4.#5.#6.#7.#8.#3#2.}%
\def\CALX_exHd #1.#2.#3.#4.#5.#6.#7.%
{%
    \expandafter\CALX_exHe\the\numexpr(2*#1-9999)/20000\expandafter.%
    \the\numexpr#1-10000*((2*#1-9999)/20000).#2.#3.#4.#5.#6.#7.%
}%
%    \end{macrocode}
%\begin{lverb}
% k1, k0, k2, I1, I0, f1, f2, f3: D = |x| - |K| ln10, ln10 limbs 2|3025|8509|
% 2994|0456|8401|7991|4546|8436|4207 (floor 10^-36); pairs I0 (w=0), f1
% (w=-2), f2 (w=-4), f3 (w=-6), I1 (10^8); columns w >= 0 merged (they
% cancel to D's integer part); w=-7 (+ w=-8) carry only
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exHe #1.#2.#3.#4.#5.#6.#7.#8.%
{%
    \expandafter\CALX_exHf\the\numexpr((#4-2*#3)*10000-2*#1-3025*#3)*10000%
      +#5-2*#2-3025*#1-8509*#3\expandafter\CALX_LRh
    \the\numexpr\CALX_Loffh-3025*#2-8509*#1-2994*#3\expandafter\CALX_LRh
    \the\numexpr\CALX_Loffh+#6-8509*#2-2994*#1-456*#3\expandafter\CALX_LRh
    \the\numexpr\CALX_Loffh-2994*#2-456*#1-8401*#3\expandafter\CALX_LRh
    \the\numexpr\CALX_Loffh+#7-456*#2-8401*#1-7991*#3\expandafter\CALX_LRh
    \the\numexpr\CALX_Loffh-8401*#2-7991*#1-4546*#3\expandafter\CALX_LRh
    \the\numexpr\CALX_Loffh+#8-7991*#2-4546*#1-8436*#3\expandafter\CALX_LRhz
    \the\numexpr\CALX_Loffh-4546*#2-8436*#1-4207*#3%
      +(-8436*#2-4207*#1)/10000\relax!%
}%
%    \end{macrocode}
%\begin{lverb}
% Dint, m1..m6, s, K8: the fast path on x' = s D, then the exponent
% (P <= 8 reader \CALX_exhG; also used by pow10)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exHf #1!#2!#3!#4!#5!#6!#7!#8#9.%
{%
    \expandafter\CALX_exHz\romannumeral0%
    \csname CALX_ex\ifnum\XINTdigits<9 h\fi G\expandafter\endcsname\expanded
      {1#6#7!1#4#5!1#2#3!\the\numexpr100000000+#1!100000000!}\xint:#8%
    \xint:#8#9.%
}%
%    \end{macrocode}
%\begin{lverb}
% E = 8e + D - 1: Overflow if E > 2^31 - 9 (the xint printer
% fails at E = 2^31 - 1), Underflow if E < -(2^31-1) + P + 7
%\end{lverb}
%    \begin{macrocode}
\begingroup\catcode`F=12
\gdef\CALX_exHz F#1#2.#3.#4\xint:#5.%
{%
    \expandafter\CALX_exHy\the\numexpr#3#5.#2.#4\xint:%
}%
\gdef\CALX_exHy #1.#2.#3\xint:%
{%
    \ifnum\ifnum#1>268435440
      \numexpr8*(#1-268435455)+#2\relax\else0\fi>\xint_c_
      \xint_dothis{\CALX_exO+}\fi
    \ifnum\ifnum#1<-268435440 \numexpr8*(#1+268435455)+#2-\XINTdigits\relax
      \else1\fi<\xint_c_i \xint_dothis{\CALX_exO-}\fi
    \xint_orthat{ F+#2.#1.#3}%
}%
\gdef\CALX_exO #1%
{%
    \if-#1\expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo\fi
    {\expandafter\CALX_sp\romannumeral`&&@%
       \CALX_signalcondition{Underflow}{exp(x) underflow}{F+0.0.}{F+0.0.}}%
    {\CALX_nsig{Overflow}{exp(x)}{+}}%
}%
\endgroup
%    \end{macrocode}
% \subsection{Exponential, P17..P100}
%\begin{lverb}
% Exponential, P17..P100. Grid
% W = 8m, m = ceil(P/8) + 1 pairs, n = 2m limbs. x: integer block and m
% pairs MS first (signed); k, i, R1 as P16 (table macros \CALX_exB<i>);
% stages k = 2, 4, 6, 8 on R (keys only); t = x + Lv + Lu + Lt + Ls + Lb -
% k ln10 by log's zip adder \CALX_LGTx and ln10 chain template \CALX_LGcidef;
% e^t: P17..P32 an explicit series and product by fixed chains (below);
% P > 32: e^t = 1 + t E1(t), E1 = sum t^k/(k+1)!, by the kernel (schedules
% \CALX_exS<P>: all levels negate their output, \CALX_Zun / \CALX_Zvn);
% Y = G e^t, G = c (100+j2)(10^4+j4)(10^6+j6)(10^8+j8) exact (6 limbs), one
% kernel level (\CALX_exT<P>); exp x = 10^(k-W) Y, \CALX_ffromraw + fround.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exgm{\numexpr(\XINTdigits+3)/8+1\relax}% m (internal integer)
%    \end{macrocode}
%\begin{lverb}
% s, D, e, blocks: p = top block position; p >= 2 over/underflow; p < -m:
% |x| < 10^-W, result 1; p = 1 or integer block >= 10^4: rare path
%\end{lverb}
%    \begin{macrocode}
\begingroup\catcode`F=12
\gdef\CALX_exgb #1;#2#3.%
{%
    \ifnum#3=\xint_c_ \xint_dothis\CALX_exgb_zero\fi
    \xint_orthat\CALX_exgb_regular #1;#2#3.%
}%
\gdef\CALX_exgb_zero #1;#2#3.#4.#5\xint:{ F+1.0.100000001!}%
\gdef\CALX_exgb_regular #1;#2#3.#4.#5\xint:%
{%
    \expandafter\CALX_exgc
      \the\numexpr#4+(#3+\xint_c_iii)/\xint_c_viii-\xint_c_i.#4.#1;#2#5\xint:%
}%
\gdef\CALX_exgc #1.%
{%
    \ifnum#1>\xint_c_i \xint_dothis\CALX_exgc_over\fi
    \ifnum#1<-\CALX_exgm \xint_dothis\CALX_exgc_small\fi
    \xint_orthat\CALX_exgc_regular #1.%
}%
\gdef\CALX_exgc_over #1.#2.#3;#4#5\xint:{\CALX_exO#4}%
\gdef\CALX_exgc_small #1.#2.#3;#4#5\xint:{ F+1.0.100000001!}%
\gdef\CALX_exgc_regular #1.#2.#3;#4#5\xint:%
{%
    \csname CALX_#3\ifnum#1>\xint_c_ Ja\else gG\fi
      \expandafter\endcsname\expanded{#4%
      \csname CALX_exgz\ifnum#1>\xint_c_ 0\else\the\numexpr-#1\fi\endcsname
      \expandafter\CALX_exgDp\the\numexpr-\CALX_exgm-#2.#4#5\xint:!%
      \csname CALX_exgz\ifnum#2>-\CALX_exgm\the\numexpr#2+\CALX_exgm\else0\fi
      \endcsname
      \noexpand\CALX_exQ\expandafter\noexpand\csname CALX_#3Mk\endcsname}%
}%
\endgroup
%    \end{macrocode}
%\begin{lverb}
% drop d low blocks, then reverse into signed items s<8 digits>! (MS first)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exgDp #1.%
   {\ifnum#1>\xint_c_
    \expandafter\CALX_exgDq\else\expandafter\CALX_exgDr\fi#1.}%
\def\CALX_exgDq #1.#2#3!{\expandafter\CALX_exgDp\the\numexpr#1-1.#2}%
\def\CALX_exgDr #1.#2{\CALX_exgRw#2{}}%
\def\CALX_exgRw #1#2#3#4!%
   {\xint_gob_til_xint: #3\CALX_exgRe\xint:\CALX_exgRw#1{#1#4!#2}}%
\def\CALX_exgRe\xint:\CALX_exgRw#1#2{\CALX_exgRf#2}%
\def\CALX_exgRf #1!{}%
%    \end{macrocode}
%\begin{lverb}
% s, s xI, s f1, s f2 (rest s f3!..!s fm!\CALX_exQ): Z, then k, i as P16
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exgG #1#2!%
{%
    \ifnum#1#2>9999 \xint_dothis\CALX_exgG_large\fi
    \xint_orthat\CALX_exgG_regular #1#2!%
}%
\def\CALX_exgG_large #1#2!#3!#4!{\CALX_exJa#1+00000000!#2!#3!#4!}%
\def\CALX_exgG_regular #1#2!#3!#4!%
{%
    \expandafter\CALX_exK\the\numexpr
      (0#1(#2*100000+#3/1000))*434294482/1000000000.#1B#2!#3!#4!%
}%
%    \end{macrocode}
%\begin{lverb}
% stages (keys only): \CALX_exgTmp <S><R><next>{<short table>}{<j of R>}{<R
% part>}
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exgTmp #1#2#3#4#5#6%
{%
    \def#1##1.{\expandafter\expandafter\expandafter#2%
       \csname#4\the\numexpr#5\endcsname##1.}%
    \def#2##1!##2!##3!##4.##5.##6|{#6##4;##6|}%
}%
\CALX_exgTmp\CALX_exgSa\CALX_exgRa\CALX_exgSb{CALX_exu}%
   {(#1+#1*#1/1000000000/20)/100000000}%
   {\expandafter\CALX_exgSb\the\numexpr#5+100*#1+#2/1000000.}%
\CALX_exgTmp\CALX_exgSb\CALX_exgRb\CALX_exgSc{CALX_exv}%
   {(#1+#1*#1/1000000000/20)/1000000}%
   {\expandafter\CALX_exgSc\the\numexpr#5+100*#1+#2/1000000.}%
\CALX_exgTmp\CALX_exgSc\CALX_exgRc\CALX_exgSd{CALX_exw}%
   {#1/10000}%
   {\expandafter\CALX_exgSd\the\numexpr#5+100*#1+#2/1000000.}%
\CALX_exgTmp\CALX_exgSd\CALX_exgRd\CALX_exgV{CALX_exz}%
   {#1/100}{\CALX_exgV}%
\CALX_exgTmp\CALX_exhSa\CALX_exhRa\CALX_exhSb{CALX_exu}%
   {(#1+#1*#1/1000000000/20)/100000000}%
   {\expandafter\CALX_exhSb\the\numexpr#5+100*#1+#2/1000000.}%
\CALX_exgTmp\CALX_exhSb\CALX_exhRb\CALX_exhV{CALX_exv}%
   {(#1+#1*#1/1000000000/20)/1000000}%
   {\expandafter\CALX_exhV\the\numexpr#5+100*#1+#2/1000000.}%
\let\CALX_exgTmp\relax
%    \end{macrocode}
%\begin{lverb}
% j8;j6;j4;j2;a;c;|k.sxI! then s f1!..!s fm!\CALX_exQ$empty: the adder stream;
% keys j8;100j6;j4;100j2;a;-k;sxI. then c.j2.j4.j6.j8.k.; P > 32: log's
% generic zip adder (\CALX_exgVb), P <= 32: log's fixed-arity adders
% (templates \CALX_LGTdef, \CALX_LGAdef, \CALX_LGBdef, chains \CALX_LGcadef,
% \CALX_LGcbdef), accs LS first: L24 f4!f3!f2!f1; L32 f4!f3!f2!f1!f5;
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exgV #1;#2;#3;#4;#5;#6;|#7.#8!%
{%
    \csname CALX_exgV%
            \ifnum\XINTdigits>32 b\else\ifnum\XINTdigits>24 q\else p\fi\fi
    \expandafter\endcsname\expanded{{#1;\the\numexpr100*#2\relax;#3;%
      \the\numexpr100*#4\relax;#5;-#7;#8.}{#6.#4.#3.#2.#1.#7.}}%
}%
\def\CALX_exgVb #1#2#3\CALX_exQ{\CALX_exTv#3;#1#2}%
\def\CALX_exgVp #1#2#3!#4!#5!#6!\CALX_exQ{\CALX_exNva#6!#5!#4!#3;#1#2}%
\def\CALX_exgVq #1#2#3!#4!#5!#6!#7!\CALX_exQ{\CALX_exNvb#6!#5!#4!#3!#7;#1#2}%
\CALX_LGTdef\CALX_exNva{CALX_Lv}\CALX_exUva \CALX_LGAdef\CALX_exUva\CALX_exNua
\CALX_LGTdef\CALX_exNua{CALX_Lu}\CALX_exUua \CALX_LGAdef\CALX_exUua\CALX_exNta
\CALX_LGTdef\CALX_exNta{CALX_Lt}\CALX_exUta \CALX_LGAdef\CALX_exUta\CALX_exNsa
\CALX_LGTdef\CALX_exNsa{CALX_Ls}\CALX_exUsa \CALX_LGAdef\CALX_exUsa\CALX_exNba
\CALX_LGTdef\CALX_exNba{CALX_Lb}\CALX_exUba \CALX_LGAdef\CALX_exUba\CALX_exNca
\CALX_LGTdef\CALX_exNvb{CALX_Lv}\CALX_exUvb \CALX_LGBdef\CALX_exUvb\CALX_exNub
\CALX_LGTdef\CALX_exNub{CALX_Lu}\CALX_exUub \CALX_LGBdef\CALX_exUub\CALX_exNtb
\CALX_LGTdef\CALX_exNtb{CALX_Lt}\CALX_exUtb \CALX_LGBdef\CALX_exUtb\CALX_exNsb
\CALX_LGTdef\CALX_exNsb{CALX_Ls}\CALX_exUsb \CALX_LGBdef\CALX_exUsb\CALX_exNbb
\CALX_LGTdef\CALX_exNbb{CALX_Lb}\CALX_exUbb \CALX_LGBdef\CALX_exUbb\CALX_exNcb
\CALX_LGcadef\CALX_exNca\CALX_exgW{#1!#2!#3!#4;#5;#6.}{#6+}{\CALX_LQ}%
\CALX_LGcbdef\CALX_exNcb\CALX_exgW{#1!#2!#3!#4!#5;#6;#7.}{#7+}%
\def\CALX_exTv{\CALX_LGTx\CALX_exTu{CALX_Lv}}%
\def\CALX_exTu{\CALX_LGTx\CALX_exTt{CALX_Lu}}%
\def\CALX_exTt{\CALX_LGTx\CALX_exTs{CALX_Lt}}%
\def\CALX_exTs{\CALX_LGTx\CALX_exTb{CALX_Ls}}%
\def\CALX_exTb{\CALX_LGTx\CALX_exch{CALX_Lb}}%
\def\CALX_exch{\expandafter\CALX_exci\CALX_Lzl\relax}%
\CALX_LGcidef\CALX_exci\CALX_exgW{#1\relax#2!#3;#4;#5.}{#5+}%
%    \end{macrocode}
%\begin{lverb}
% t = I!l1!..!ln!\CALX_LQ (|t| < 5.5e-9): P <= 32 the explicit back end
% (\CALX_exE<p|n><a|b>, sign of t, layout L = 24 or 32), P > 32 the kernel
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exgW #1!%
{%
    \csname CALX_ex\ifnum\XINTdigits>32 gWk\else E\ifnum#1<\xint_c_ n\else p\fi
      \ifnum\XINTdigits>24 b\else a\fi\fi\endcsname#1!%
}%
%    \end{macrocode}
%\begin{lverb}
% P > 32: U'' = 10^8 t (l3..ln, t < 0: top l3 - 10^4), kernel U list,
% schedule \CALX_exS<P>
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exgWk #1!#2!#3!#4\CALX_LQ%
{%
    \ifnum#1<\xint_c_ \expandafter\CALX_exgWn\else\expandafter\CALX_exgWs\fi
    #4\CALX_Zq!%
}%
\def\CALX_exgWn #1!{\expandafter\CALX_exgWs\the\numexpr#1-10000!}%
\def\CALX_exgWs #1\CALX_Zq!%
{%
    \expandafter\expandafter\expandafter\CALX_Zst
    \csname CALX_exS\the\numexpr\XINTdigits\expandafter\endcsname
    \expandafter{\expanded{\CALX_Zbt#1\CALX_Zq!}}%
}%
%    \end{macrocode}
%\begin{lverb}
% {U}x_top.<n+1 limbs dddd!>\CALX_Zq c.j2.j4.j6.j8. (then k.): a = c(100+j2)
% = a1 10^4 + a0; T items -(e^t 10^W)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exgF #1#2.#3\CALX_Zq{\expandafter\CALX_exgFb\expanded{#2.#3}\CALX_Zq}%
\def\CALX_exgFb #1.#2\CALX_Zq#3.#4.#5.#6.#7.%
{%
    \expandafter\CALX_exgGa\expanded{\the\numexpr(2*#3*(100+#4)-9999)/20000.%
      \the\numexpr#3*(100+#4)-10000*((2*#3*(100+#4)-9999)/20000).#5.#6.#7.%
      \noexpand\CALX_exgGc{-#1.\CALX_exgTn#2\CALX_Zq!}}%
}%
\def\CALX_exgTn #1!%
   {\CALX_Zgob#1\CALX_exgTe\CALX_Zq\noexpand\CALX_Zn-#1.\CALX_exgTn}%
\def\CALX_exgTe\CALX_Zq#1\CALX_exgTn{}%
%    \end{macrocode}
%\begin{lverb}
% a1.a0.j4.j6.j8.<cont>: a b = p3!p2!p1!p0!, b = 100 10^8 + (100 j4 + j6)
% 10^4 + j4 j6 (shared by P17..P100; <cont> = \CALX_exgGc (kernel path),
% \CALX_exPA, \CALX_exPB)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exgGa #1.#2.#3.#4.#5.%
{%
    \expandafter\CALX_exgGb\the\numexpr100*#1\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+100*#2+#1*(100*#3+#4)\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#2*(100*#3+#4)+#1*#3*#4\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#2*#3*#4\relax!#5.%
}%
%    \end{macrocode}
%\begin{lverb}
% G = a b (10^8 + j8): <cont>g5!..!g0! (6 limbs, top not normalized)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exgGb #1!#2!#3!#4!#5.#6%
{%
    \expandafter#6\the\numexpr#1\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#2\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#3+#1*#5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#4+#2*#5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#3*#5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#4*#5\relax!%
}%
\def\CALX_exgGc #1!#2!#3!#4!#5!#6!#7%
{%
    \csname CALX_exT\the\numexpr\XINTdigits\expandafter\endcsname\expandafter
    {\expanded{\CALX_Zbt#1!#2!#3!#4!#5!#6!\CALX_Zq!}}{#7}%
}%
%    \end{macrocode}
%\begin{lverb}
% {U}x_top.<n limbs dddd!>\CALX_Zq k. : exp x = 10^(k-W) Y
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exgY #1#2.#3\CALX_Zq
   {\expandafter\CALX_exgYb\expanded{#2.#3}\CALX_Zq}%
\def\CALX_exgYb #1.#2\CALX_Zq#3.%
{%
    \expandafter\CALX_exgYd\expanded{\ifnum#1>\xint_c_ #1\fi
      \CALX_exgYs#2\CALX_Zq!}#3.%
}%
%    \end{macrocode}
%\begin{lverb}
% digits.k.<marker>: expm1 -> \CALX_emF, else \CALX_exgYa
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exgYd #1.#2.#3{\ifx#3\CALX_exMk\expandafter\xint_firstoftwo
   \else\expandafter\xint_secondoftwo\fi
   {\CALX_exgYe#1.#2.8*\CALX_exgm.}{\CALX_emF#1.#2.8*\CALX_exgm.#3}}%
\def\CALX_exgYe #1.#2.#3.{\expandafter\CALX_exgYa\the\numexpr#2-#3.#1.}%
\def\CALX_exgYs #1!{\CALX_Zgob#1\CALX_exgYt\CALX_Zq#1\CALX_exgYs}%
\def\CALX_exgYt\CALX_Zq#1\CALX_exgYs{.}%
\def\CALX_exgYa #1.#2.%
   {\CALX_fnround{\XINTdigits}{\CALX_ffromraw{#2[#1]}}}%
%    \end{macrocode}
%\begin{lverb}
% P17..P32: explicit back end, no kernel.
% t = I!0000!0000!l3!..!ln!\CALX_LQ (I = 0) or -1!9999!9999!..; s =
% floor(10^16 t) = u 10^4 + w (u = l3 or l3 - 10^4, w = l4); U = 10^W
% (e^t - 1) by ONE carry chain (floor limbs, signed top), braced; then G
% (\CALX_exgGa), Y' = G 10^(W-24) + G U 10^-24 (\CALX_exPA, \CALX_exPB),
% exp x = 10^(k-W) Y' (writer \CALX_exXa, \CALX_exXb).
% L = 24 (W = 32): u.s.w!l5!l6!l7!l8!\CALX_LQ (rho = l5l6, lambda = l7l8);
% U = s 1e16 + rho 1e8 + lambda + s^2/2 + s rho/1e8 + s^3/6e16, s^2/2 =
% (u^2/2) 1e8 + u w 1e4 + w^2/2
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exEpa 0!0000!0000!#1!#2!{\CALX_exEa#1.#1#2.#2!}%
\def\CALX_exEna -1!9999!9999!#1!#2!%
   {\expandafter\CALX_exEa
    \the\numexpr#1-10000\expandafter.\the\numexpr#1#2-100000000.#2!}%
\def\CALX_exEa #1.#2.#3!#4!#5!#6!#7!\CALX_LQ%
{%
    \expandafter\CALX_exEc\expandafter\CALX_exPA\expandafter{\the\numexpr
    0\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#2\expandafter\CALX_LR
    \the\numexpr\CALX_Loff\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#4#5+#1*#1/2\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+(#1*#1-2*(#1*#1/2))*5000+#1*#3\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#6#7+#3*#3/2+#2*#4#5/100000000%
      +(#2*#2/100000000)*#2/600000000\relax!}%
}%
%    \end{macrocode}
%\begin{lverb}
% L = 32 (W = 40): u.w!l5!..!l10!\CALX_LQ -> h1.h0.Ls.u.w!r1!r0!lambda!mu!
% (s^2 = Hs 1e8 + Ls exactly, Hs = h1 1e4 + h0)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exEpb 0!0000!0000!#1!#2!{\CALX_exEh#1.#2!}%
\def\CALX_exEnb -1!9999!9999!#1!#2!%
   {\expandafter\CALX_exEh\the\numexpr#1-10000.#2!}%
\def\CALX_exEh #1.#2!#3!#4!#5!#6!#7!#8!\CALX_LQ%
{%
    \expandafter\CALX_exEb
    \the\numexpr(#1*#1+2*#1*#2/10000)/10000\expandafter.%
    \the\numexpr#1*#1+2*#1*#2/10000-10000*((#1*#1+2*#1*#2/10000)/10000)%
    \expandafter.\the\numexpr(2*#1*#2-10000*(2*#1*#2/10000))*10000+#2*#2.%
    #1.#2!#3!#4!#5#6!#7#8!%
}%
%    \end{macrocode}
%\begin{lverb}
% U = s 1e24 + rho 1e16 + lambda 1e8 + mu + t^2/2 + t^3/6 + t^4/24 (units
% 10^-40): s rho = u r1 1e8 + (u r0 + w r1) 1e4 + w r0; s^3/6e8 = s Hs/6 +
% s Ls/6e8, s Hs/6 = (u h1/6) 1e8 + ((u h0 + w h1)/6) 1e4 + w h0/6
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exEb #1.#2.#3.#4.#5!#6!#7!#8!#9!%
{%
    \expandafter\CALX_exEc\expandafter\CALX_exPB\expandafter{\the\numexpr
    0\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#4*10000+#5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#6#7+#4*#4/2\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+(#4*#4-2*(#4*#4/2))*5000+#4*#5\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#8+#5*#5/2+#4*#6+#4*#1/6\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+(#5*#5-2*(#5*#5/2))*5000+#4*#7+#5*#6%
      +(#4*#2+#5*#1)/6\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#9+#5*#7+#6#7*#6#7/200000000%
      +(#4*10000+#5)*#8/100000000+(#4*10000+#5)*#3/600000000%
      +(#4*#1-6*(#4*#1/6))*50000000/3%
      +(#4*#2+#5*#1-6*((#4*#2+#5*#1)/6))*5000/3+#5*#2/6%
      +(#1*10000+#2)*#6#7/200000000%
      +(#1*10000+#2)*(#1*10000+#2)/1200000000/2\relax!}%
}%
%    \end{macrocode}
%\begin{lverb}
% <cont>{U limbs}c.j2.j4.j6.j8. : a = c (100 + j2) = a1 10^4 + a0, then G
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exEc #1#2#3.#4.#5.#6.#7.%
{%
    \expandafter\CALX_exgGa\the\numexpr(2*#3*(100+#4)-9999)/20000\expandafter.%
    \the\numexpr#3*(100+#4)-10000*((2*#3*(100+#4)-9999)/20000).#5.#6.#7.#1#2%
}%
%    \end{macrocode}
%\begin{lverb}
% Y' = G 10^(W-24) + G U 10^-24: columns c = i + m (g_i u_m) >= W/4 - 2,
% c = W/4 - 3 guard (carry only); later partial sums passed as expression
% TEXT. L = 24: g5..g0, u5, u4, u3 (stream u2!u1!u0!k.)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exPA #1!#2!#3!#4!#5!#6!#7!#8!#9!%
{%
    \expandafter\CALX_exXe\the\numexpr#1\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#2\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#3\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#4+#1*#7\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#5+#1*#8+#2*#7\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#6+#1*#9+#2*#8+#3*#7%
    \CALX_exPAb#2*#9+#3*#8+#4*#7!#3*#9+#4*#8+#5*#7!#4*#9+#5*#8+#6*#7!%
    #1!#2!#3!%
}%
%    \end{macrocode}
%\begin{lverb}
% S1, S0, Sg (texts), g5, g4, g3, u2, u1, u0
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exPAb #1!#2!#3!#4!#5!#6!#7!#8!#9!%
{%
    \expandafter\CALX_LR\the\numexpr\CALX_Loff+#4*#7+#1%
    \expandafter\CALX_LR\the\numexpr\CALX_Loff+#4*#8+#5*#7+#2%
    \expandafter\CALX_LRz\the\numexpr\CALX_Loff+#4*#9+#5*#8+#6*#7+#3\relax!%
}%
%    \end{macrocode}
%\begin{lverb}
% L = 32: g5..g0, u7, u6, u5 (stream u4!..!u0!k.); column 9 left open
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exPB #1!#2!#3!#4!#5!#6!#7!#8!#9!%
{%
    \expandafter\CALX_exXf\the\numexpr#1\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#2\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#3\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#4+#1*#7\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#5+#1*#8+#2*#7\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#6+#1*#9+#2*#8+#3*#7\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#2*#9+#3*#8+#4*#7%
    \CALX_exPBb#3*#9+#4*#8+#5*#7!#4*#9+#5*#8+#6*#7\CALX_exPBc#6*#9!#5!%
    #5*#9+#6*#8\CALX_exPm#1!#2!#3!#4!%
}%
\let\CALX_exPm\relax
%    \end{macrocode}
%\begin{lverb}
% S8, bundle (S7, \CALX_exPBc, A5, g1, A6), g5..g2, u4, u3, u2: closes
% column 9; column 7 ends with S7 and \CALX_exPBc (A6 + B6 one parameter)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exPBb #1!#2\CALX_exPm#3!#4!#5!#6!#7!#8!#9!%
{%
    +#3*#7\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#1+#3*#8+#4*#7\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+#3*#9+#4*#8+#5*#7+#2+#4*#9+#5*#8+#6*#7!%
    #5*#9+#6*#8!#3!#4!#7!%
}%
%    \end{macrocode}
%\begin{lverb}
% A5, g1, A6 + B6, B5, g5, g4, u4, u1, u0
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exPBc #1!#2!#3!#4!#5!#6!#7!#8!#9!%
{%
    \expandafter\CALX_LR\the\numexpr\CALX_Loff+#5*#8+#3%
    \expandafter\CALX_LRz\the\numexpr\CALX_Loff+#5*#9+#6*#8+#2*#7+#4+#1\relax!%
}%
%    \end{macrocode}
%\begin{lverb}
% writer: T!q..!q0!k.<marker>: \CALX_exXe (L24), \CALX_exXf (L32) dispatch
% (expm1: \CALX_emXa, \CALX_emXb)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exXe #1.#2{\ifx#2\CALX_exMk\CALX_exXj\fi\CALX_emXa#1.#2}%
\def\CALX_exXf #1.#2{\ifx#2\CALX_exMk\CALX_exXk\fi\CALX_emXb#1.#2}%
\def\CALX_exXj\fi\CALX_emXa#1.#2{\fi\CALX_exXa#1.}%
\def\CALX_exXk\fi\CALX_emXb#1.#2{\fi\CALX_exXb#1.}%
%    \end{macrocode}
%\begin{lverb}
% T!q..!q0!k. ; frequent 1000 <= T <= 9999 (Y' has W digits):
% pairs MS first P!..!P0!k. ; else \CALX_ffromraw (\CALX_exgYa)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exXa #1!#2!#3!#4!#5!#6!#7!%
{%
    \ifnum\numexpr(2*#1-10999)*(2*#1-10999)>80982001
      \xint_dothis{\CALX_exXg32.#1#2#3#4#5#6#7}\fi
    \xint_orthat{\CALX_exXca#1#2!#3#4!#5#6!#7}%
}%
\def\CALX_exXb #1!#2!#3!#4!#5!#6!#7!#8!#9!%
{%
    \ifnum\numexpr(2*#1-10999)*(2*#1-10999)>80982001
      \xint_dothis{\CALX_exXg40.#1#2#3#4#5#6#7#8#9}\fi
    \xint_orthat{\CALX_exXcb#1#2!#3#4!#5#6!#7#8!#9}%
}%
\def\CALX_exXg #1.#2!#3.{\expandafter\CALX_exgYa\the\numexpr#3-#1.#2.}%
%    \end{macrocode}
%\begin{lverb}
% f = floor(k/8), h = k - 8f
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exXca #1!#2!#3!#4!#5.%
{%
    \expandafter\CALX_exXd\the\numexpr(2*#5-7)/16\expandafter.%
    \the\numexpr#5-8*((2*#5-7)/16).#1!#2!#3!#4!%
}%
\def\CALX_exXcb #1!#2!#3!#4!#5!#6.%
{%
    \expandafter\CALX_exXd\the\numexpr(2*#6-7)/16\expandafter.%
    \the\numexpr#6-8*((2*#6-7)/16).#1!#2!#3!#4!#5!%
}%
%    \end{macrocode}
%\begin{lverb}
% f.h. -> \CALX_exX<z|s|v|u><a|b> h.10^h.V.f. (V = 10^(8-h), \CALX_exh<h>):
% P = L (24, 32): v (h = 0), u (h > 0) direct; other P: z, s (\CALX_fround)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exXd #1.#2.%
{%
    \csname CALX_exX\ifnum\numexpr\XINTdigits-8*((\XINTdigits+3)/8)\relax
      =\xint_c_
      \ifnum#2=\xint_c_ v\else u\fi\else\ifnum#2=\xint_c_ z\else s\fi\fi
    \ifnum\XINTdigits>24 b\else a\fi
    \expandafter\expandafter\expandafter\endcsname\csname CALX_exh#2\endcsname#1.%
}%
%    \end{macrocode}
%\begin{lverb}
% blocks of N = Y' 10^h (LS first), D = W + h, e = f - W/8; one rounding.
% floor(P/V) = (2P-V+1)/(2V)
%\end{lverb}
%    \begin{macrocode}
\begingroup\catcode`F=12
\gdef\CALX_exXza #1.#2.#3.#4.#5!#6!#7!#8!%
   {\CALX_fnround\XINTdigits
    {\expanded{F+32.\the\numexpr#4-4.1#8!1#7!1#6!1#5!}}}%
\gdef\CALX_exXzb #1.#2.#3.#4.#5!#6!#7!#8!#9!%
   {\CALX_fnround\XINTdigits
    {\expanded{F+40.\the\numexpr#4-5.1#9!1#8!1#7!1#6!1#5!}}}%
\gdef\CALX_exXsa #1.#2.#3.#4.#5!#6!#7!#8!%
{%
    \CALX_fnround\XINTdigits{\expanded{F+\the\numexpr32+#1.\the\numexpr#4-4.%
    \the\numexpr100000000+(#8-(2*#8-#3+1)/(2*#3)*#3)*#2!%
    \the\numexpr100000000+(#7-(2*#7-#3+1)/(2*#3)*#3)*#2+(2*#8-#3+1)/(2*#3)!%
    \the\numexpr100000000+(#6-(2*#6-#3+1)/(2*#3)*#3)*#2+(2*#7-#3+1)/(2*#3)!%
    \the\numexpr100000000+(#5-(2*#5-#3+1)/(2*#3)*#3)*#2+(2*#6-#3+1)/(2*#3)!%
    \the\numexpr100000000+(2*#5-#3+1)/(2*#3)!}}%
}%
\gdef\CALX_exXsb #1.#2.#3.#4.#5!#6!#7!#8!#9!%
{%
    \CALX_fnround\XINTdigits{\expanded{F+\the\numexpr40+#1.\the\numexpr#4-5.%
    \the\numexpr100000000+(#9-(2*#9-#3+1)/(2*#3)*#3)*#2!%
    \the\numexpr100000000+(#8-(2*#8-#3+1)/(2*#3)*#3)*#2+(2*#9-#3+1)/(2*#3)!%
    \the\numexpr100000000+(#7-(2*#7-#3+1)/(2*#3)*#3)*#2+(2*#8-#3+1)/(2*#3)!%
    \the\numexpr100000000+(#6-(2*#6-#3+1)/(2*#3)*#3)*#2+(2*#7-#3+1)/(2*#3)!%
    \the\numexpr100000000+(#5-(2*#5-#3+1)/(2*#3)*#3)*#2+(2*#6-#3+1)/(2*#3)!%
    \the\numexpr100000000+(2*#5-#3+1)/(2*#3)!}}%
}%
%    \end{macrocode}
%\begin{lverb}
% P = L: M = (pairs above P0) + [P0 >= 5e7] (= round(Y'/10^8)), blocks of
% M 10^h, D = P + h, e = f - P/8; M1 + [P0 >= 5e7] = 10^8: the fround path
%\end{lverb}
%    \begin{macrocode}
\gdef\CALX_exXva #1.#2.#3.#4.#5!#6!#7!#8!%
{%
    \ifnum\numexpr#7+#8/100000000>99999999
      \xint_dothis{\CALX_exXza#1.#2.#3.#4.#5!#6!#7!#8!}\fi
    \xint_orthat{\expanded{ F+24.\the\numexpr#4-3.%
      \the\numexpr1#7+#8/100000000!1#6!1#5!}}%
}%
\gdef\CALX_exXvb #1.#2.#3.#4.#5!#6!#7!#8!#9!%
{%
    \ifnum\numexpr#8+#9/100000000>99999999
      \xint_dothis{\CALX_exXzb#1.#2.#3.#4.#5!#6!#7!#8!#9!}\fi
    \xint_orthat{\expanded{ F+32.\the\numexpr#4-4.%
      \the\numexpr1#8+#9/100000000!1#7!1#6!1#5!}}%
}%
\gdef\CALX_exXua #1.#2.#3.#4.#5!#6!#7!#8!%
{%
    \ifnum\numexpr#7+#8/100000000>99999999
      \xint_dothis{\CALX_exXsa#1.#2.#3.#4.#5!#6!#7!#8!}\fi
    \xint_orthat
    {\expandafter\CALX_exXw\the\numexpr#7+#8/100000000.#1.#2.#3.#4.#5!#6!}%
}%
\gdef\CALX_exXw #1.#2.#3.#4.#5.#6!#7!%
{%
    \expanded{ F+\the\numexpr24+#2.\the\numexpr#5-3.%
    \the\numexpr100000000+(#1-(2*#1-#4+1)/(2*#4)*#4)*#3!%
    \the\numexpr100000000+(#7-(2*#7-#4+1)/(2*#4)*#4)*#3+(2*#1-#4+1)/(2*#4)!%
    \the\numexpr100000000+(#6-(2*#6-#4+1)/(2*#4)*#4)*#3+(2*#7-#4+1)/(2*#4)!%
    \the\numexpr100000000+(2*#6-#4+1)/(2*#4)!}%
}%
\gdef\CALX_exXub #1.#2.#3.#4.#5!#6!#7!#8!#9!%
{%
    \ifnum\numexpr#8+#9/100000000>99999999
      \xint_dothis{\CALX_exXsb#1.#2.#3.#4.#5!#6!#7!#8!#9!}\fi
    \xint_orthat{\expandafter\CALX_exXx\the\numexpr#8+#9/100000000.%
      #1.#2.#3.#4.#5!#6!#7!}%
}%
\gdef\CALX_exXx #1.#2.#3.#4.#5.#6!#7!#8!%
{%
    \expanded{ F+\the\numexpr32+#2.\the\numexpr#5-4.%
    \the\numexpr100000000+(#1-(2*#1-#4+1)/(2*#4)*#4)*#3!%
    \the\numexpr100000000+(#8-(2*#8-#4+1)/(2*#4)*#4)*#3+(2*#1-#4+1)/(2*#4)!%
    \the\numexpr100000000+(#7-(2*#7-#4+1)/(2*#4)*#4)*#3+(2*#8-#4+1)/(2*#4)!%
    \the\numexpr100000000+(#6-(2*#6-#4+1)/(2*#4)*#4)*#3+(2*#7-#4+1)/(2*#4)!%
    \the\numexpr100000000+(2*#6-#4+1)/(2*#4)!}%
}%
\endgroup
%    \end{macrocode}
%\begin{lverb}
% rare path P > 16, 10^4 <= |x| < 10^16 (as P16: K = s 8 K8, D = |x| -
% |K| ln10 in (290, 650), the fast path on s D, e <- e + s K8): s, s I1
% (block 10^8), s I0, then s f1!..!s fm!\CALX_exQ. D by one chain: columns
% w = 2..-(n+1), X_w - k0 l_(-w) - k1 l_(1-w) - k2 l_(2-w) (ln10 limbs l_j,
% \CALX_exLx$empty: j = 3..31, floor 10^-124); the last column only for the
% carry.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exJa #1#2!#3!%
{%
    \ifnum#1#2>49 \xint_dothis\CALX_exJa_over\fi
    \ifnum\numexpr(#1#2)*1000000+(#1#3)/100>49447638
      \xint_dothis\CALX_exJa_over\fi
    \xint_orthat\CALX_exJa_regular #1#2!#3!%
}%
\def\CALX_exJa_over #1#2!#3!#4\CALX_exQ#5{\CALX_exO#1}%
\def\CALX_exJa_regular #1#2!#3!#4\CALX_exQ#5%
{%
    \expandafter\CALX_exJb\the\numexpr
      (\ifnum#1#2>\xint_c_
       ((#1#2)*1000000+(#1#3)/100)*434294482/1000000000*100%
       \else(#1#3)*434294482/1000000000\fi-4)/8-25.#1#2!#3!#4\CALX_exQ#5%
}%
%    \end{macrocode}
%\begin{lverb}
% K8, s, s I1, s I0, pairs: k2 = floor(8 K8/10^8), rem, k1, k0; X limbs
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exJb #1.#2#3!#4!#5\CALX_exQ%
{%
    \expandafter\CALX_exJc\expanded{\the\numexpr(2*#1-12499999)/25000000.%
      \the\numexpr8*#1-100000000*((2*#1-12499999)/25000000).%
      \the\numexpr#2#3!\CALX_exJs#4!\CALX_exJl#5\CALX_exQ!}0!\CALX_LQ!#2#1.%
}%
\def\CALX_exJs #1#2#3#4#5#6#7#8#9!{#2#3#4#5!#6#7#8#9!}%
\def\CALX_exJl #1#2!%
   {\ifx\CALX_exQ#1\else\CALX_exJs#1#2!\expandafter\CALX_exJl\fi}%
\def\CALX_exJc #1.#2.%
{%
    \expandafter\CALX_exJd\the\numexpr(2*#2-9999)/20000\expandafter.%
    \the\numexpr#2-10000*((2*#2-9999)/20000).#1.%
}%
%    \end{macrocode}
%\begin{lverb}
% k1, k0, k2, X2, X1, X0, rest X (\CALX_LQ!): the chain
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exJd{\expandafter\CALX_exJe\CALX_exLx\relax}%
\def\CALX_exJe #1\relax#2.#3.#4.#5!#6!#7!#8\CALX_LQ!%
{%
    \expandafter\CALX_exJf\the\numexpr#5-2*#4\expandafter\CALX_LRh
    \the\numexpr\CALX_Loffh+#6-2*#2-3025*#4\expandafter\CALX_LRh
    \the\numexpr\CALX_Loffh+#7-2*#3-3025*#2-8509*#4%
    \CALX_exJw#8\CALX_LQ!;3025.8509.#3.#2.#4.#10!0!\relax
}%
%    \end{macrocode}
%\begin{lverb}
% X_w, rest X, l_(-w), l_(1-w), k0, k1, k2, l_(2-w) (stream)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exJw #1!#2;#3.#4.#5.#6.#7.#8!%
{%
    \CALX_LGgt#1\CALX_exJz\CALX_LQ\expandafter\CALX_LRh
    \the\numexpr\CALX_Loffh+#1-#5*#3-#6*#4-#7*#8\CALX_exJw#2;#4.#8.#5.#6.#7.%
}%
\def\CALX_exJz\CALX_LQ#1\relax{\relax!\CALX_LQ}%
%    \end{macrocode}
%\begin{lverb}
% c2!l1!l0!m1!..m_(n+1)!\CALX_LQ s K8.<marker> : the fast path on s D (the
% marker passed to it), then e + s K8
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exJf #1!#2!#3!#4\CALX_LQ#5#6.#7%
{%
    \expandafter\CALX_exHz\romannumeral0\expandafter\CALX_exgG\expanded
      {#5#5#2#3!\CALX_exJp#5#4\CALX_LQ!}\CALX_exQ#7\xint:#5#6.%
}%
\def\CALX_exJp #1#2!#3!%
   {\ifx\CALX_LQ#3\else#1#2#3!\expandafter\CALX_exJp\expandafter#1\fi}%
%    \end{macrocode}
%\begin{lverb}
% load time: short tables F1!c2!c3!j. keyed by j: \CALX_exu<j> = Ls<100j>,
% \CALX_exv<j> = Lt<j>, \CALX_exw<j> = Lu<100j>
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exMs #1!#2!#3!#4\CALX_LQ#5#6{\expandafter\def\csname#5#6\endcsname
   {#1!#2!#3!#6.}}%
\def\CALX_exMt #1.#2.#3.#4.#5.%
{%
    \edef\CALX_Ltmpb{\the\numexpr#3*#4}%
    \expandafter\expandafter\expandafter
    \CALX_exMs\csname#2\CALX_Ltmpb\endcsname
      \CALX_LQ{#1}{#4}%
    \ifnum#4>#5 \xint_afterfi{\expandafter\CALX_exMt\expanded{#1.#2.#3.%
      \the\numexpr#4-1.#5.}}\fi
}%
\CALX_exMt CALX_exu.CALX_Ls.100.11.-11.%
\CALX_exMt CALX_exv.CALX_Lt.1.56.-56.%
\CALX_exMt CALX_exw.CALX_Lu.100.51.-51.%
\CALX_exMt CALX_exz.CALX_Lv.1.51.-51.%
%    \end{macrocode}
%\begin{lverb}
% table macros \CALX_exA<i> (i = 0..99) from \CALX_exAlist (calxlogdata.tex)
% and the entries \CALX_Lb<a>: #1 k, #2 s x12, #3 s x34, #4 s x56, #5 s xI.
% R1 = 100 A2 + (-2994k + (s x34 + c2 - 456k)/10^4)/100, A2 = A1 10^4 + s x12
% + F1 - 8509k, A1 = (s xI - 2k) 10^4 - 3025k (|A1| < 3.7e4, |A2| < 5e6).
% list entries i.key.c. (key of \CALX_Lb<key>: 0 = zero entry, 1 =
% \CALX_Lz (ln10), else a; c the bootstrap multiplier)
%\end{lverb}
%    \begin{macrocode}
\expandafter\let\csname CALX_Lb1\endcsname\CALX_Lz
\def\CALX_exMa #1!#2!#3!#4\CALX_LQ#5.#6.#7.%
{%
    \expandafter\edef\csname CALX_exA#5\endcsname##1.##2.##3.##4.##5.%
    {%
        \noexpand\expandafter\noexpand\CALX_exSa\noexpand\the\noexpand\numexpr
        (((##5-2*##1)*10000-3025*##1)*10000+##2+#1-8509*##1)*100%
        +(-2994*##1+(##3+#2-456*##1)/10000)/100.#1.#2.#3.%
        #7;|##2.##3.##4.##1.##5.##1.%
    }%
}%
\def\CALX_exLd #1.#2.#3.%
{%
    \ifnum#1<\xint_c_ \expandafter\xint_gobble_i\else
    \expandafter\expandafter\expandafter\CALX_exMa\csname CALX_Lb#2\endcsname
      \CALX_LQ#1.#2.#3.\fi
    \CALX_exLd
}%
\expandafter\CALX_exLd\CALX_exAlist
%    \end{macrocode}
%\begin{lverb}
% P > 16 table macros \CALX_exB<i>: #1 k, #2 s xI, #3 s f1, #4 s f2 (R1 as
% P16)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exMa #1!#2!#3!#4\CALX_LQ#5.#6.#7.%
{%
    \expandafter\edef\csname CALX_exB#5\endcsname##1.##2!##3!##4!%
    {%
        \noexpand\expandafter\noexpand\CALX_exgSa\noexpand\the\noexpand\numexpr
        (((##2-2*##1)*10000-3025*##1)*10000+##3+#1-8509*##1)*100%
        +(-2994*##1+(##4+#2-456*##1)/10000)/100.#6;%
        #7;|##1.##2!##3!##4!%
    }%
}%
\expandafter\CALX_exLd\CALX_exAlist
%    \end{macrocode}
%\begin{lverb}
% P <= 8 table macros \CALX_exC<i>: as \CALX_exA<i>, state R1.c;|k.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exMa #1!#2!#3!#4\CALX_LQ#5.#6.#7.%
{%
    \expandafter\edef\csname CALX_exC#5\endcsname##1.##2.##3.##4.##5.%
    {%
        \noexpand\expandafter\noexpand\CALX_exhSa\noexpand\the\noexpand\numexpr
        (((##5-2*##1)*10000-3025*##1)*10000+##2+#1-8509*##1)*100%
        +(-2994*##1+(##3+#2-456*##1)/10000)/100.%
        #7;|##1.%
    }%
}%
\expandafter\CALX_exLd\CALX_exAlist
%    \end{macrocode}
%\begin{lverb}
% zero items +00000000! (k = 0..16) for the P > 16 layout
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Ltmp #1.#2%
{%
    \expandafter\def\csname CALX_exgz#1\endcsname{#2}%
    \ifnum#1<16 \xint_afterfi{\expandafter\CALX_Ltmp\the\numexpr#1+1.%
       {#2+00000000!}}\fi
}%
\CALX_Ltmp0.{}%
%    \end{macrocode}
%\begin{lverb}
% schedules, P = 33..100 (P17..P32: explicit back end): n = 2m, K =
% (n-4)/2; start -C_K (scale 10^8);
% levels k = K-1..1 (b = m = n-4-2k, n_k = n-2-2k, C_k = 1/(k+1)!), level 0
% (C_0 = 1, n-1 limbs), e^t level (C = 10^W, n+1 limbs, floor carries);
% \CALX_exT<P>: Y = G e^t 10^-24 (U = G, 6 limbs; T = -e^t, n+1 items)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exgK #1#2{\CALX_tcoef{\ifodd\numexpr#1+1\relax s\else c\fi}%
   {\ifodd\numexpr#1+1\relax(#1)/2\else(#1+1)/2\fi}{#2}}%
%    \end{macrocode}
%\begin{lverb}
% #1 b, #2 m; the following braced n goes directly to \CALX_tcoef.
% The coefficient continuation follows n.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_exgLv #1.#2.#3.#4.#5#6%
   {\ifnum#4=\xint_c_i\CALX_Zlevx\CALX_Zv{#1}{#2}{#3}{#5}#6\else
    \CALX_Zlevx\CALX_Zvn{#1}{#2}{#3}{#5}#6\fi}%
\def\CALX_exgSl #1.%
{%
    \ifnum#1>\xint_c_
      \expandafter\CALX_exgLv\the\numexpr\CALX_LWa-4-2*#1\expandafter.%
        \the\numexpr\CALX_LWa-4-2*#1\expandafter.\the\numexpr\CALX_LWa-2-2*#1%
        \expandafter.%
        \the\numexpr\ifnum\numexpr#1-\CALX_LWb\relax=\xint_c_ 1\else0\fi.%
        {\expandafter\CALX_LWrv\expanded{\CALX_exgK{#1}{\CALX_LWa-2-2*#1}%
          {\CALX_LWa-2-2*#1}\CALX_tq}\relax}\CALX_Zun
      \expandafter\CALX_exgSl\the\numexpr#1-1.%
    \else
      \expandafter\CALX_exgLv\the\numexpr\CALX_LWa-4\expandafter.%
        \the\numexpr\CALX_LWa-4\expandafter.%
        \the\numexpr\CALX_LWa-1\expandafter.%
        \the\numexpr\ifnum\CALX_LWb=\xint_c_ 1\else0\fi.%
        {1!\expandafter\CALX_LWzr\the\numexpr\CALX_LWa-2.}\CALX_Zun
      \expandafter\CALX_exgLv\the\numexpr\CALX_LWa-2\expandafter.%
        \the\numexpr\CALX_LWa-1\expandafter.\the\numexpr\CALX_LWa+1.0.%
        {1!\expandafter\CALX_LWzr\CALX_LWa.}\CALX_Zuf
      \noexpand\CALX_exgF
    \fi
}%
\def\CALX_exgSt #1!#2!{-#2.\noexpand\CALX_Zn-#1}%
\def\CALX_Ltmp #1%
{%
    \edef\CALX_LWa{\the\numexpr2*((#1+3)/8)+2}% n
    \edef\CALX_LWb{\the\numexpr(\CALX_LWa-4)/2-1}% first level
    \expandafter\edef\csname CALX_exS#1\endcsname
    {%
      {\expandafter\CALX_exgSt\expanded{\CALX_exgK{\CALX_LWb+1}{2}{2}%
        \CALX_tq}}%
      {\expandafter\CALX_exgSl\CALX_LWb.}%
    }%
    \expandafter\edef\csname CALX_exT#1\endcsname##1##2%
    {%
      \noexpand\CALX_Zd##2\noexpand\CALX_Zq
        {##1\expandafter\CALX_LWzr\the\numexpr\CALX_LWa-6.}% U pad
      \expandafter\CALX_exgLv\expandafter6\expandafter.\the\numexpr
        \CALX_LWa+1\expandafter.\the\numexpr\CALX_LWa+1.1.%
        {\expandafter\CALX_LWzr\the\numexpr\CALX_LWa+1.}\CALX_Zuf
      \noexpand\CALX_exgY
    }%
    \ifnum#1<100
    \expandafter\CALX_Ltmp\expandafter{\the\numexpr#1+1\expandafter}\fi
}%
\CALX_Ltmp{33}%
\let\CALX_Ltmp\relax \let\CALX_LWa\relax \let\CALX_LWb\relax
%    \end{macrocode}
% \subsection{\csh{calxFpPowTen}, \csh{calxRawPowTen}}
%\begin{lverb}
% pow10(x). x rounded as exp (P+14 digits, sliced at the
% grid); |x| = 8K + y, K = floor(n/8) (n integer part of |x|), y = d + phi,
% d = n mod 8 = (block I0) mod 8; 10^x = 10^(8sK) exp(s y ln10): x' = y ln10
% (< 18.43) on exp's grid by one short product, then exp's fast path and
% e <- e + sK (\CALX_exHf / \CALX_exJf -> \CALX_exHz$empty: Overflow,
% Underflow).
% Integer x (P <= 16 path): 10^(s n) written directly (\CALX_exHy).
%\end{lverb}
%    \begin{macrocode}
\def\calxFpPowTen{\romannumeral0\expandafter\CALX_pwa
    \romannumeral0\CALX_fround{\XINTdigits+14}}%
\def\calxRawPowTen #1{\romannumeral0\CALX_ftoraw{\calxFpPowTen{#1}}}%
\def\CALX_pwnfl #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpPowTen#3}}%
}%
\def\CALX_pwnex #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxRawPowTen#3}}%
}%
\expandafter\let\csname XINT_flexpr_func_pow10\endcsname\CALX_pwnfl
\expandafter\let\csname XINT_expr_func_pow10\endcsname\CALX_pwnex
\def\CALX_pwa #1#2{\csname CALX_pwt#1#2\endcsname}%
\expandafter\let
\csname CALX_pwtI+\expandafter\endcsname\csname CALX_extI+\endcsname
\expandafter\let
\csname CALX_pwtI-\expandafter\endcsname\csname CALX_extI-\endcsname
\expandafter\let
\csname CALX_pwtI?\expandafter\endcsname\csname CALX_extI?\endcsname
\expandafter\def
\csname CALX_pwtF+\endcsname{\CALX_exb pw;+}%
\expandafter\def
\csname CALX_pwtF-\endcsname{\CALX_exb pw;-}%
%    \end{macrocode}
%\begin{lverb}
% P <= 16 reader (layout of \CALX_exc): f3, f2, f1, I0, I1, rest, s;
% I1 > 21: |x| > 2.2e9, over/underflow; floor(I0/8) = (2 I0 - 7)/16
%\end{lverb}
%    \begin{macrocode}
\def\CALX_pwG 1#1!1#2!1#3!1#4!1#5!%
{%
    \ifnum#5>21 \xint_dothis\CALX_pwG_over\fi
    \ifnum\numexpr#1+#2+#3\relax=\xint_c_
      \xint_dothis\CALX_pwG_int\fi
    \xint_orthat\CALX_pwG_regular 1#1!1#2!1#3!1#4!1#5!%
}%
\def\CALX_pwG_over 1#1!1#2!1#3!1#4!1#5!#6\xint:#7{\CALX_exO#7}%
\def\CALX_pwG_int 1#1!1#2!1#3!1#4!1#5!#6\xint:#7%
{%
    \expandafter\CALX_pwI\the\numexpr#4-8*((2*#4-7)/16)\expandafter.%
        \the\numexpr#5*12500000+(2*#4-7)/16.#7%
}%
\def\CALX_pwG_regular 1#1!1#2!1#3!1#4!1#5!#6\xint:#7%
{%
    \expandafter\CALX_pwP\expanded{\the\numexpr#4-8*((2*#4-7)/16)!%
      \CALX_pwh#3\CALX_pwh#2\CALX_pwh#1#7\the\numexpr#5*12500000+(2*#4-7)/16.}%
}%
\let\CALX_pwhG\CALX_pwG
\def\CALX_pwh #1#2#3#4#5#6#7#8{#1#2#3#4!#5#6#7#8!}%
%    \end{macrocode}
%\begin{lverb}
% d, y1..y6 (stream s K.): x' 10^24 = y 10^24 ln10, columns c0..c6, guard
% c7 (ln10 limbs 2|3025|8509|2994|0456|8401|7991|4546; dropped columns < 5
% units 10^-24) -> \CALX_exHf X!l1!..!l6!sK.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_pwP #1!#2!#3!#4!#5!#6!#7!%
{%
    \expandafter\CALX_exHf\the\numexpr2*#1\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+3025*#1+2*#2\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+8509*#1+3025*#2+2*#3\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+2994*#1+8509*#2+3025*#3+2*#4\expandafter\CALX_LR
    \the\numexpr\CALX_Loff+456*#1+2994*#2+8509*#3+3025*#4+2*#5%
    \expandafter\CALX_LR
    \the\numexpr\CALX_Loff+8401*#1+456*#2+2994*#3+8509*#4+3025*#5+2*#6%
    \expandafter\CALX_LR
    \the\numexpr\CALX_Loff+7991*#1+8401*#2+456*#3+2994*#4+8509*#5+3025*#6%
      +2*#7\expandafter\CALX_LRz
    \the\numexpr\CALX_Loff+4546*#1+7991*#2+8401*#3+456*#4+2994*#5+8509*#6%
      +3025*#7\relax!%
}%
%    \end{macrocode}
%\begin{lverb}
% integer x = s n, n = 8K + d: 10^(s n) as e.D.block for \CALX_exHy
%\end{lverb}
%    \begin{macrocode}
\def\CALX_pwI #1.#2.#3%
{%
    \expandafter\CALX_exHy\expanded{\if-#3%
      \ifnum#1=\xint_c_ \the\numexpr-#2.1.100000001!%
      \else\the\numexpr-#2-1.\the\numexpr9-#1.%
        \the\numexpr100000000+\CALX_pten{8-#1}!\fi
    \else\the\numexpr#2.\the\numexpr#1+1.\the\numexpr100000000+\CALX_pten{#1}!%
    \fi}\xint:%
}%
%    \end{macrocode}
%\begin{lverb}
% P > 16 readers (layout of \CALX_exgc$empty: s, signed items MS first,
% \CALX_exQ): p <= 0 (I0 first), p = 1 (I1, I0)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_pwgG #1#2#3!{\CALX_pwS#1.00000000.#3.}%
\def\CALX_pwJa #1#2#3!#4#5!#6\CALX_exQ#7%
   {\ifnum#3>21 \xint_dothis{\CALX_exO#1}\fi
    \xint_orthat{\CALX_pwS#1.#3.#5.#6\CALX_exQ#7}}%
\def\CALX_pwS #1.#2.#3.%
{%
    \expandafter\CALX_pwV\the\numexpr#2*12500000+(2*#3-7)/16\expandafter.%
    \the\numexpr#3-8*((2*#3-7)/16).#1%
}%
%    \end{macrocode}
%\begin{lverb}
% K.d.s f-items\CALX_exQ$empty: U list (d, limbs of the fraction items),
% kernel
% level \CALX_pwT<P> (U = y, T = -ln10, C = 0, floor carries); stream s K.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_pwV #1.#2.#3#4\CALX_exQ%
{%
    \csname CALX_pwT\the\numexpr\XINTdigits\expandafter\endcsname\expandafter
    {\expanded{\expandafter\CALX_Zbt
     \expanded{#2!\CALX_pwL#4\CALX_exQ}\CALX_Zq!}}%
    #3#1.%
}%
\def\CALX_pwL #1{\ifx\CALX_exQ#1\else\expandafter\CALX_pwLs\fi}%
\def\CALX_pwLs #1#2#3#4#5#6#7#8!{#1#2#3#4!#5#6#7#8!\CALX_pwL}%
%    \end{macrocode}
%\begin{lverb}
% {U}0.<n+1 limbs>\CALX_Zq s K. -> \CALX_exJf 0!0000!<x' limbs>0000!
%\end{lverb}
%    \begin{macrocode}
\def\CALX_pwF #1#2.#3\CALX_Zq{\expandafter\CALX_exJf\expanded{0!0000!#3}0000!\CALX_LQ}%
%    \end{macrocode}
%\begin{lverb}
% load time: \CALX_pwT<P> #1 (U list), P = 17..100, n = W/4: T = -ln10 on
% n+2 limbs (2, 3025, 8509, \CALX_exLx), level b = n+1, m = n+2, n+2 limbs
% (the kernel's top output column must be >= b+m-1: top limb 0)
%\end{lverb}
%    \begin{macrocode}
\edef\CALX_pwlx{3025!8509!\CALX_exLx}%
\def\CALX_pwk #1.#2!{\ifnum#1>\xint_c_ \noexpand\CALX_Zn-#2.\expandafter\CALX_pwk
   \the\numexpr#1-1\expandafter.\else\expandafter\CALX_pwz\fi}%
\def\CALX_pwz #1\relax{}%
\def\CALX_Ltmp #1%
{%
    \edef\CALX_LWa{\the\numexpr2*((#1+3)/8)+2}% n
    \expandafter\edef\csname CALX_pwT#1\endcsname##1%
    {%
      \noexpand\CALX_Zd-2.\expandafter\CALX_pwk\the\numexpr\CALX_LWa+1%
        \expandafter.\CALX_pwlx\relax\noexpand\CALX_Zq{##1}%
      \expandafter\CALX_exgLv\the\numexpr\CALX_LWa+1\expandafter.\the\numexpr
        \CALX_LWa+2\expandafter.\the\numexpr\CALX_LWa+2.1.%
        {\expandafter\CALX_LWzr\the\numexpr\CALX_LWa+2.}\CALX_Zuf
      \noexpand\CALX_pwF
    }%
    \ifnum#1<100 \expandafter\CALX_Ltmp
                 \expandafter{\the\numexpr#1+1\expandafter}\fi
}%
\CALX_Ltmp{17}%
\let\CALX_Ltmp\relax \let\CALX_LWa\relax \let\CALX_pwlx\relax
\let\CALX_pwk\relax \let\CALX_pwz\relax
%    \end{macrocode}
% \subsection{\csh{calxFpExpMinusOne}, \csh{calxRawExpMinusOne}}
%\begin{lverb}
% expm1(x) = exp(x) - 1. x rounded to P digits. E = decimal exponent:
% E <= -5: x E1(x), E1 = sum x^k/(k+1)!, log1p's C machinery (kind em);
% E >= 3: exp(x) (x > 0) or -1; else exp's front with kind em: readers
% \CALX_emG (P <= 16), \CALX_emgG (P > 16): |x| >= T_P = (P+4) ln10 (up):
% exp (x > 0) or -1; 0 < x < 0.04: bucket-0 table macro with k = 0; else
% exp's normal branch; the writers then call \CALX_emF (marker \CALX_emMk):
% N = Y' - 10^(W'-k) exact, ONE rounding.
%\end{lverb}
%    \begin{macrocode}
\chardef\CALX_exMk=1 \chardef\CALX_emMk=2 \let\CALX_pwMk\CALX_exMk
\chardef\CALX_euMk=3 \chardef\CALX_xuMk=4 % unrounded expm1, exp
\def\calxFpExpMinusOne{\romannumeral0\expandafter\CALX_ema
    \romannumeral0\CALX_fround{\XINTdigits}}%
\def\calxRawExpMinusOne #1{\romannumeral0\CALX_ftoraw{\calxFpExpMinusOne{#1}}}%
\def\CALX_emnfl #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpExpMinusOne#3}}%
}%
\def\CALX_emnex #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxRawExpMinusOne#3}}%
}%
\expandafter\let\csname XINT_flexpr_func_expm1\endcsname\CALX_emnfl
\expandafter\let\csname XINT_expr_func_expm1\endcsname\CALX_emnex
\def\CALX_ema #1#2{\csname CALX_emt#1#2\endcsname}%
\def\CALX_emT{\numexpr(\XINTdigits+4)*23026/10000+1\relax}% T_P
\begingroup\catcode`F=12
\expandafter\gdef\csname CALX_emtI+\endcsname#1\xint:{ I+}%
\expandafter\gdef\csname CALX_emtI-\endcsname#1\xint:{ F-1.0.100000001!}%
\expandafter\gdef\csname CALX_emtI?\endcsname#1\xint:{ I?}%
\expandafter\gdef\csname CALX_emtF+\endcsname{\CALX_emb+}%
\expandafter\gdef\csname CALX_emtF-\endcsname{\CALX_emb-}%
%    \end{macrocode}
%\begin{lverb}
% s D.e.blocks; D + 8e = E + 1
%\end{lverb}
%    \begin{macrocode}
\gdef\CALX_emb #1#2.#3.%
{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_emb_zero\fi
    \ifnum\numexpr#2+8*#3\relax<-\xint_c_iii
      \xint_dothis\CALX_emb_small\fi
    \ifnum\numexpr#2+8*#3\relax>\xint_c_iii
      \xint_dothis\CALX_emb_large\fi
    \xint_orthat\CALX_emb_regular #1#2.#3.%
}%
\gdef\CALX_emb_zero #1#2.#3.#4\xint:{ F+0.0.}%
\gdef\CALX_emb_small #1#2.#3.#4\xint:{\CALX_lpC ems;#1#2.#3.#4\xint:}%
\gdef\CALX_emb_large #1#2.#3.#4\xint:
    {\CALX_emL#1{\CALX_exb ex;#1#2.#3.#4\xint:}}%
\gdef\CALX_emb_regular #1#2.#3.#4\xint:{\CALX_exb em;#1#2.#3.#4\xint:}%
%    \end{macrocode}
%\begin{lverb}
% s{exp's computation}: x > 0: the computation, x < 0: -1
%\end{lverb}
%    \begin{macrocode}
\gdef\CALX_emL #1%
   {\if-#1\expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo\fi
    {\CALX_emM}{\xint_firstofone}}%
\gdef\CALX_emM #1{ F-1.0.100000001!}%
\endgroup
%    \end{macrocode}
%\begin{lverb}
% P <= 16 reader (layout of \CALX_exc, |x| < 1000): f3, f2, f1, xI, rest, s
%\end{lverb}
%    \begin{macrocode}
\def\CALX_emG 1#1!1#2!1#3!1#4!#5\xint:#6%
{%
    \ifnum#4<\CALX_emT\else
      \xint_dothis{\CALX_emL#6{\CALX_exG1#1!1#2!1#3!1#4!#5\xint:#6}}\fi
    \ifnum\numexpr#61*(#4*100+#3/1000000)\relax<4
      \xint_dothis{\if-#6\expandafter\CALX_exGn\else\expandafter\CALX_emA\fi
        #1.#2.#3.#4.#6A\CALX_emMk}\fi
    \xint_orthat{\CALX_exGn#1.#2.#3.#4.#6A\CALX_emMk}%
}%
\let\CALX_emhG\CALX_emG
%    \end{macrocode}
%\begin{lverb}
% 0 < x < 0.04: bucket 0 (c = 10^4, no constant) with k = 0
%\end{lverb}
%    \begin{macrocode}
\def\CALX_emA #1.#2.#3.#4.#5#6%
   {\csname CALX_exA0\endcsname 0.#5#3.#5#2.#5#1.#5#4.}%
%    \end{macrocode}
%\begin{lverb}
% P > 16 reader (layout of \CALX_exgc): s, s xI, s f1, s f2, rest\CALX_exQ
% \CALX_emMk
%\end{lverb}
%    \begin{macrocode}
\def\CALX_emgG #1#2!#3!%
{%
    \ifnum#1#2<\CALX_emT\else\xint_dothis\CALX_emgG_large\fi
    \ifnum\numexpr#2*100+#3/1000000\relax<4
      \xint_dothis\CALX_emgG_small\fi
    \xint_orthat\CALX_emgG_regular #1#2!#3!%
}%
\def\CALX_emgG_large #1#2!#3!#4!{\CALX_emgL#1#2!#3!#4!}%
\def\CALX_emgG_small #1#2!#3!#4!%
{%
    \if-#1\expandafter\CALX_exgG\else\expandafter\CALX_emgA\fi
       #1#2!#3!#4!%
}%
\def\CALX_emgG_regular #1#2!#3!#4!{\CALX_exgG#1#2!#3!#4!}%
\def\CALX_emgA #1#2!#3!#4!{\csname CALX_exB0\endcsname 0.#2!#3!#4!}%
%    \end{macrocode}
%\begin{lverb}
% |x| >= T_P: x > 0 exp (marker of exp's writer), x < 0 -1
%\end{lverb}
%    \begin{macrocode}
\def\CALX_emgL #1#2\CALX_exQ#3{\CALX_emL#1{\CALX_exgG#1#2\CALX_exQ\CALX_exMk}}%
\let\CALX_emJa\CALX_emgL
%    \end{macrocode}
%\begin{lverb}
% finisher: digits of Y'.k.W'. -> exp x - 1 = round_P(Y' 10^(k-W') - 1),
% the subtraction exact (\CALX_fsubx, native 1), ONE rounding
%\end{lverb}
%    \begin{macrocode}
\def\CALX_emF #1.#2.#3.{\expandafter\CALX_emZ\the\numexpr#2-#3.#1.}%
\def\CALX_emZ #1.#2.#3%
{%
    \ifcase#3\or\or\expandafter\CALX_emZr\or\expandafter\CALX_emZu
    \else\expandafter\CALX_emZx\fi{#2[#1]}%
}%
\begingroup\catcode`F=12
\gdef\CALX_emZr #1%
   {\CALX_fnround\XINTdigits{\CALX_fsubx{\CALX_ffromraw{#1}}{F+1.0.100000001!}}}%
\gdef\CALX_emZu #1{\CALX_fsubx{\CALX_ffromraw{#1}}{F+1.0.100000001!}}%
\endgroup
\def\CALX_emZx{\CALX_ffromraw}%
%    \end{macrocode}
%\begin{lverb}
% P17..P32 writers: T!q..!q1! then q0!k. -> digits.k.W.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_emXa #1!#2!#3!#4!#5!#6!#7!{\CALX_emXc#1#2#3#4#5#6#7}%
\def\CALX_emXb #1!#2!#3!#4!#5!#6!#7!#8!#9!{\CALX_emXc#1#2#3#4#5#6#7#8#9}%
\def\CALX_emXc #1!#2.#3{\CALX_emF#1.#2.8*\CALX_exgm.#3}%
%    \end{macrocode}
%\begin{lverb}
% series |x| < 10^-4: U = -10^4 x (lists of log1p, sign swapped), schedules
% \CALX_emS<P'> (log's unity levels, C_k = 1/(k+1)! by \CALX_exgK)
%\end{lverb}
%    \begin{macrocode}
\expandafter\let\csname CALX_emU+%
     \expandafter\endcsname\csname CALX_lpU-\endcsname
\expandafter\let\csname CALX_emU-%
     \expandafter\endcsname\csname CALX_lpU+\endcsname
\def\CALX_Ltmp #1%
{%
    \edef\CALX_LWa{\the\numexpr(#1+\ifnum#1>64 6\else5\fi)/4}%
    \edef\CALX_LWm{\the\numexpr\CALX_LWa-1}%
    \expandafter\edef\csname CALX_emS#1\endcsname##1%
    {%
      \noexpand\CALX_Zd\expandafter\CALX_Zhd\expanded{\CALX_exgK
        {\CALX_LWa-1}{1}{1}\CALX_tq}\relax.\noexpand\CALX_Zq{##1}%
      \expandafter\CALX_LWbl\the\numexpr\CALX_LWa-2.%
    }%
    \ifnum#1<100 \expandafter\CALX_Ltmp%
        \expandafter{\the\numexpr#1+1\expandafter}\fi
}%
\let\CALX_LWco\CALX_exgK \let\CALX_LWfin\empty
\CALX_Ltmp{17}%
\def\CALX_LWco{\CALX_tcoef{l}}%
\let\CALX_Ltmp\relax \let\CALX_LWa\relax
\let\CALX_LWm\relax \let\CALX_LWfin\relax
\let\CALX_exgK\relax \let\CALX_exgSl\relax \let\CALX_exgSt\relax
\let\CALX_exgLv\relax
\let\CALX_exMs\relax \let\CALX_exMt\relax \let\CALX_exMa\relax
\let\CALX_exLd\relax \let\CALX_Ltmpb\relax
%    \end{macrocode}
% \subsection{\csh{calxFpPow}, \csh{calxRawPow}}
%\begin{lverb}
% Powers a**b, a^b, pow(a, b) of \xintfloateval.
% y = exp(z), z = b' ln a': a' = a rounded to P digits, b' = b rounded to
% P + 14 digits (|z| < 5e9 is the only range that matters: |z| rho_b <=
% 2.5e-(P+4)); ln a' by the unrounded internal log at P' = P + 2 + g
% (log1p's \CALX_lpLP), 10^g >= |z| (bound from the exponents, g <= 10);
% z = b' ln a' exact (\CALX_fmulx), then exp's entry (x at P + 14 digits,
% one rounding). No special algorithm for integer b: integer b only gives
% the sign for a < 0. Specials: IEEE-754 pow table (a = 1 or b = 0: 1).
%\end{lverb}
%    \begin{macrocode}
\def\calxFpPow #1#2{\romannumeral0\expandafter\CALX_ppa
    \romannumeral0\CALX_fround{\XINTdigits+14}{#2}{#1}}%
\def\calxRawPow #1#2{\romannumeral0\CALX_ftoraw{\calxFpPow{#1}{#2}}}%
\let\XINTinFloatSciPow\calxFpPow
\def\XINT_flexpr_func_pow #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxFpPow#3}}%
}%
%    \end{macrocode}
%\begin{lverb}
% b'\xint:{a} -> a'\xint:b'\xint:, dispatch on <tag a><sign a><tag b>
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ppa #1\xint:#2%
   {\expandafter\CALX_ppb\romannumeral0\CALX_fround{\XINTdigits}{#2}#1\xint:}%
\def\CALX_ppb #1#2#3\xint:#4{\csname CALX_ppt#1#2#4\endcsname#3\xint:}%
%    \end{macrocode}
%\begin{lverb}
% d = digits of 24 (|E_a| + 1) (|E_a| < 4166666, else 11):
% |z| < 10^(E_b + 1) 2.303 (|E_a| + 1) < 10^(E_b + d); g = E_b + d in [0, 10]
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ppc #1.#2.%
{%
    \expandafter\CALX_ppd\the\numexpr\XINTdigits+\xint_c_ii+\expandafter\CALX_ppg
    \the\numexpr#2+\ifnum\ifnum#1<\xint_c_ -\fi#1<4166666
      \CALX_ndig{24*(\ifnum#1<\xint_c_ -\fi#1+1)}\else 11\fi.%
    .%
}%
\def\CALX_ppg #1.{\ifnum#1<\xint_c_ 0\else\ifnum#1>10 10\else#1\fi\fi}%
%    \end{macrocode}
%\begin{lverb}
% P'.b'\xint:+<a>\xint: -> exp(b' ln a')
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ppd #1.#2\xint:#3\xint:%
{%
    \expandafter\CALX_exa\romannumeral0\CALX_fround{\XINTdigits+14}%
      {\CALX_fmulx{#2}{\CALX_lpLP#1.#3\xint:}}%
}%
\def\CALX_ppz #1%
   {\if-#1\xint_dothis{\CALX_nsig{DivisionByZero}{0 ** b, b < 0}{+}}\fi
    \xint_orthat{ F+0.0.}}%
%    \end{macrocode}
%\begin{lverb}
% T\xint:b\xint:<even><odd><not integer>: T = trunc(b) (\CALX_ti_f), b an
% integer iff T = b (\CALX_fcmp); parity from T's block at 10^0
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ppi #1\xint:#2\xint:#3#4#5%
   {\ifcase\CALX_fcmp{#1}{#2} \xint_afterfi{\CALX_ppj#1\xint:#3#4}%
    \else\xint_afterfi{#5}\fi}%
%    \end{macrocode}
%\begin{lverb}
% |a| ** b, negated (b odd); not an integer: InvalidOperation
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ppE{\csname CALX_pptF+F\endcsname}%
\def\CALX_ppO #1\xint:#2\xint:%
   {\expandafter\CALX_fopp_a\romannumeral0\csname CALX_pptF+F\endcsname
    #1\xint:#2\xint:\xint:}%
\def\CALX_ppx #1\xint:#2\xint:%
   {\CALX_nsig{InvalidOperation}{a ** b, a < 0, b not an integer}{}}%
\def\CALX_ppP{ I+}%
\def\CALX_ppM{ I-}%
%    \end{macrocode}
%\begin{lverb}
% |a| vs 1, b = I+, I-, I?
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ppy #1#2#3%
   {\if ?#1\xint_dothis{ I?}\fi\if#1#2\xint_dothis{ I+}\fi
    \xint_orthat{ F+0.0.}}%
\begingroup\catcode`F=12
\gdef\CALX_ppj F#1#2.#3.#4!%
{%
    \ifnum#3>\xint_c_ \xint_dothis\CALX_ppj_positive\fi
    \ifodd#4 \xint_dothis\CALX_ppj_odd\fi
    \xint_orthat\CALX_ppj_regular F#1#2.#3.#4!%
}%
\gdef\CALX_ppj_positive F#1#2.#3.#4!#5\xint:#6#7{#6}%
\gdef\CALX_ppj_odd F#1#2.#3.#4!#5\xint:#6#7{#7}%
\gdef\CALX_ppj_regular F#1#2.#3.#4!#5\xint:#6#7{#6}%
%    \end{macrocode}
%\begin{lverb}
% a >= 0, b finite: <Da>.<ea>.<blocks>\xint:<sb><Db>.<eb>.<blocks>\xint:
%\end{lverb}
%    \begin{macrocode}
\expandafter\gdef\csname CALX_pptF+F\endcsname #1.#2.#3\xint:#4#5.#6.#7\xint:%
{%
    \ifnum#5=\xint_c_ \xint_dothis{ F+1.0.100000001!}\fi
    \ifnum#1=\xint_c_ \xint_dothis{\CALX_ppz#4}\fi
    \xint_orthat{\expandafter\CALX_ppc\the\numexpr#1-\xint_c_i+\xint_c_viii*#2%
      \expandafter.\the\numexpr#5-\xint_c_i+\xint_c_viii*#6.%
      F#4#5.#6.#7\xint:+#1.#2.#3\xint:}%
}%
\expandafter\gdef\csname CALX_pptF-F\endcsname #1.#2.#3\xint:#4#5.#6.#7\xint:%
{%
    \ifnum#5=\xint_c_ \xint_dothis{ F+1.0.100000001!}\fi
    \xint_orthat
      {\expandafter\CALX_ppi\romannumeral0\CALX_ti_f F#4#5.#6.#7\xint:%
      \xint:F#4#5.#6.#7\xint:\CALX_ppE\CALX_ppO\CALX_ppx
      #1.#2.#3\xint:#4#5.#6.#7\xint:}%
}%
\expandafter\gdef\csname CALX_pptF+I\endcsname #1\xint:#2\xint:%
{%
    \ifcase\CALX_fcmp{F+#1}{\CALX_fonec} \xint_afterfi{ F+1.0.100000001!}%
    \or\xint_afterfi{\CALX_ppy#2+-}%
    \else\xint_afterfi{\CALX_ppy#2-+}\fi
}%
\expandafter\gdef\csname CALX_pptI+F\endcsname\xint:#1#2.%
{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_ppt_posinf_zero\fi
    \if-#1\xint_dothis\CALX_ppt_posinf_negative\fi
    \xint_orthat\CALX_ppt_posinf_positive #1#2.%
}%
\gdef\CALX_ppt_posinf_zero #1#2.#3\xint:{ F+1.0.100000001!}%
\gdef\CALX_ppt_posinf_negative #1#2.#3\xint:{ F+0.0.}%
\gdef\CALX_ppt_posinf_positive #1#2.#3\xint:{ I+}%
\expandafter\gdef\csname CALX_pptI-F\endcsname\xint:#1#2.%
{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_ppt_neginf_zero\fi
    \if-#1\xint_dothis\CALX_ppt_neginf_negative\fi
    \xint_orthat\CALX_ppt_neginf_regular #1#2.%
}%
\gdef\CALX_ppt_neginf_zero #1#2.#3.#4\xint:{ F+1.0.100000001!}%
\gdef\CALX_ppt_neginf_negative #1#2.#3.#4\xint:{ F+0.0.}%
\gdef\CALX_ppt_neginf_regular #1#2.#3.#4\xint:%
   {\expandafter\CALX_ppi\romannumeral0\CALX_ti_f F#1#2.#3.#4\xint:%
      \xint:F#1#2.#3.#4\xint:\CALX_ppP\CALX_ppM\CALX_ppP}%
\expandafter\gdef\csname CALX_pptI?F\endcsname\xint:#1#2.%
{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_ppt_nan_zero\fi
    \xint_orthat\CALX_ppt_nan_regular #1#2.%
}%
\gdef\CALX_ppt_nan_zero #1#2.#3\xint:{ F+1.0.100000001!}%
\gdef\CALX_ppt_nan_regular #1#2.#3\xint:{ I?}%
\expandafter\gdef\csname CALX_pptI+I\endcsname\xint:#1\xint:%
   {\if ?#1\xint_dothis{ I?}\fi\if-#1\xint_dothis{ F+0.0.}\fi
    \xint_orthat{ I+}}%
\expandafter\gdef\csname CALX_pptI?I\endcsname\xint:#1\xint:{ I?}%
\endgroup
\expandafter\let\csname CALX_pptF-I\expandafter\endcsname
   \csname CALX_pptF+I\endcsname
\expandafter\let\csname CALX_pptI-I\expandafter\endcsname
   \csname CALX_pptI+I\endcsname
%    \end{macrocode}
%\begin{lverb}
% Unrounded exp and expm1 (used by the hyperbolic functions): kinds xu
% (exp, |x| < 10^4) and eu (expm1, |x| < 1000) of exp's front; the writers
% pass the digits of Y' to \CALX_emF with the marker \CALX_xuMk or
% \CALX_euMk, the finisher \CALX_emZ then gives Y' 10^(k-W') or
% Y' 10^(k-W') - 1 exactly (no rounding); expm1 |x| < 10^-4: log1p's C
% machinery with the output letter u (\CALX_shou: no rounding).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_xuG 1#1!1#2!1#3!1#4!#5\xint:#6{\CALX_exGn#1.#2.#3.#4.#6A\CALX_xuMk}%
\let\CALX_xuhG\CALX_xuG \let\CALX_xugG\CALX_exgG \let\CALX_xuJa\CALX_exJa
\def\CALX_euG 1#1!1#2!1#3!1#4!#5\xint:#6%
{%
    \ifnum#4<\CALX_emT\else
      \xint_dothis{\CALX_emL#6{\CALX_exG1#1!1#2!1#3!1#4!#5\xint:#6}}\fi
    \ifnum\numexpr#61*(#4*100+#3/1000000)\relax<4
      \xint_dothis{\if-#6\expandafter\CALX_exGn\else\expandafter\CALX_emA\fi
        #1.#2.#3.#4.#6A\CALX_euMk}\fi
    \xint_orthat{\CALX_exGn#1.#2.#3.#4.#6A\CALX_euMk}%
}%
\let\CALX_euhG\CALX_euG \let\CALX_eugG\CALX_emgG \let\CALX_euJa\CALX_emJa
\def\CALX_shou #1{\expandafter\space\romannumeral`&&@#1}%
\begingroup\catcode`F=12
\gdef\CALX_hyX #1{\expandafter\CALX_hyXa\romannumeral`&&@#1\xint:}%
\gdef\CALX_hyXa F#1#2.#3.#4\xint:{\CALX_exb xu;#1#2.#3.#4\xint:}%
\gdef\CALX_hyU #1{\expandafter\CALX_hyUa\romannumeral`&&@#1\xint:}%
\gdef\CALX_hyUa F#1#2.#3.%
{%
    \ifnum\numexpr#2+\xint_c_viii*#3<-\xint_c_iii
      \xint_dothis\CALX_hyUa_small\fi
    \xint_orthat\CALX_hyUa_regular F#1#2.#3.%
}%
\gdef\CALX_hyUa_small F#1#2.#3.#4\xint:{\CALX_lpC emu;#1#2.#3.#4\xint:}%
\gdef\CALX_hyUa_regular F#1#2.#3.#4\xint:{\CALX_exb eu;#1#2.#3.#4\xint:}%
\endgroup
\def\CALX_hyln{\CALX_lpLP\XINTdigits+\xint_c_viii.+1.0.100000002!\xint:}%
%    \end{macrocode}
% \subsection{\csh{calxFpSinh}, \csh{calxFpCosh}, \csh{calxFpTanh},
%   \csh{calxFpCoth}, \csh{calxFpSech}, \csh{calxFpCsch}, \csh{calxFpAsinh},
%   \csh{calxFpAcosh}, \csh{calxFpAtanh}, \csh{calxFpAcoth},
%   \csh{calxFpAsech}, \csh{calxFpAcsch}}
%\begin{lverb}
% Hyperbolic functions and their inverses (and the \calxRaw... variants,
% expression functions sinh, cosh, ...), composed from exp, expm1, log1p,
% the internal log and calxfp arithmetic at Q = P + 4 digits, with one final
% rounding; formulas chosen to avoid cancellation. x is rounded to P digits,
% a = |x|, E its decimal exponent, u = expm1(x), w = expm1(-x):
%(
%:  sinh  E < 0: (u - w)/2;  E <= 2: (e^x - e^-x)/2;  else sign e^(a-ln2)
%:  cosh  (e^x + e^-x)/2;  E > 2: e^(a-ln2)
%:  tanh  (u - w)/(u + w + 2);  E > 2: sign 1;  coth the inverse ratio
%:  sech  2/(e^x + e^-x);  csch 2/(u - w) or 2/(e^x - e^-x);  E > 2: e^(ln2-a)
%:  asinh sign log1p(a + a^2/(1 + sqrt(1 + a^2)));  E >= Q: log1p(2a)
%:  acosh log1p(t + sqrt(t(t+2))), t = x - 1;  E >= Q: log1p(2x)
%:  atanh sign log1p(q/(1 + sqrt(1 + q))), q = 2a/(1 - a)
%:  acoth the same with q = 2/(a - 1)
%:  asech acosh(1/x) with t = (1 - x)/x;  E < -Q/2: log1p((2 - x)/x)
%:  acsch asinh(1/a) with sign;  E >= Q/2: 1/x;  E < -Q/2: log1p((2-a)/a)
%)
% asinh, atanh: E < -Q/2 gives x. log1p is applied to its Q-digit
% argument without rounding it to P digits (its three paths accept it).
% Entry \CALX_hyd<code><tag><sign> -> \csname CALX_hy<code><tag><sign>
% with Q. in front (Q = P + 4, P < 8 counts as 8); codes S C T K E H
% (sinh .. csch), s c t k e h (asinh ..
% acsch); the F macros of both signs come from the template \CALX_hyT.
%\end{lverb}
%    \begin{macrocode}
\edef\CALX_hytwo{\romannumeral0\CALX_ffromraw{2[0]}}%
\edef\CALX_hyup{\romannumeral0\CALX_ffromraw{1[0]}}%
\edef\CALX_hyum{\romannumeral0\CALX_ffromraw{-1[0]}}%
\edef\CALX_hyzero{\romannumeral0\CALX_ffromraw{0[0]}}%
\expandafter\let\csname CALX_hyu+\endcsname\CALX_hyup
\expandafter\let\csname CALX_hyu-\endcsname\CALX_hyum
\def\CALX_hyd #1#2#3%
   {\expandafter\CALX_hye\the\numexpr\ifnum\XINTdigits<\xint_c_viii
    \xint_c_viii\else\XINTdigits\fi+\xint_c_iv.#1#2#3}%
\def\CALX_hye #1.#2#3#4%
   {\csname CALX_hy#2\ifnum\XINTdigits<9 w\fi#3#4\endcsname#1.#3#4}%
%    \end{macrocode}
%\begin{lverb}
% Infinities and NaN: \CALX_hyIp (the input), \CALX_hyIa (I+), \CALX_hyIo
% (sign 1), \CALX_hyIz (0), \CALX_hyIn (InvalidOperation).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_hyIp #1.#2#3\xint:{ #2#3}%
\def\CALX_hyIa #1.#2#3\xint:{ #2+}%
\def\CALX_hyIo #1.#2#3\xint:%
   {\expandafter\expandafter\expandafter\space\csname CALX_hyu#3\endcsname}%
\def\CALX_hyIz #1\xint:{\expandafter\space\CALX_hyzero}%
\def\CALX_hyIn #1\xint:%
   {\CALX_nsig{InvalidOperation}{inverse hyperbolic function of inf}{}}%
\def\CALX_hyIs #1#2#3%
{%
    \expandafter\let\csname CALX_hy#1I+\endcsname#2%
    \expandafter\let\csname CALX_hy#1I-\endcsname#3%
    \expandafter\let\csname CALX_hy#1I?\endcsname\CALX_hyIp
    \expandafter\let\csname CALX_hy#1wI+\endcsname#2%
    \expandafter\let\csname CALX_hy#1wI-\endcsname#3%
    \expandafter\let\csname CALX_hy#1wI?\endcsname\CALX_hyIp
}%
\CALX_hyIs S\CALX_hyIp\CALX_hyIp \CALX_hyIs C\CALX_hyIa\CALX_hyIa
\CALX_hyIs T\CALX_hyIo\CALX_hyIo \CALX_hyIs K\CALX_hyIo\CALX_hyIo
\CALX_hyIs E\CALX_hyIz\CALX_hyIz \CALX_hyIs H\CALX_hyIz\CALX_hyIz
\CALX_hyIs s\CALX_hyIp\CALX_hyIp \CALX_hyIs c\CALX_hyIp\CALX_hyIn
\CALX_hyIs t\CALX_hyIn\CALX_hyIn \CALX_hyIs k\CALX_hyIz\CALX_hyIz
\CALX_hyIs e\CALX_hyIn\CALX_hyIn \CALX_hyIs h\CALX_hyIz\CALX_hyIz
%    \end{macrocode}
%\begin{lverb}
% Helpers (e^x, u, w: unrounded \CALX_hyX, \CALX_hyU; ln 2 \CALX_hyln at
% P + 8). \CALX_hyNp, \CALX_hyNm: sign. \CALX_hyP<f>{x1}{x2}<cont>:
% <cont> f(x2)\xint:f(x1)\xint:. \CALX_hyLp{w}: log1p(w) (w >= 0.1: the
% internal log at Q of round_Q(1 + w)); \CALX_hyLm{w}: -log1p(w).
% \CALX_hyS{b}{Q}<L>: <L> of
% b + b^2/(1 + sqrt(1 + b^2)). \CALX_hyq q\xint:Q.<L>: <L> of
% q/(1 + sqrt(1 + q)). \CALX_hyW{t}{Q}: t + sqrt(t(t+2)).
%\end{lverb}
%    \begin{macrocode}
\let\CALX_hyNp\xint_firstofone
\def\CALX_hyNm #1{\expandafter\CALX_fopp_a\romannumeral0#1\xint:}%
\def\CALX_hyP #1#2#3#4%
   {\expandafter\CALX_hyPa\romannumeral0#1{#2}\xint:#1{#3}#4}%
\def\CALX_hyPa #1\xint:#2#3#4%
   {\expandafter#4\romannumeral0#2{#3}\xint:#1\xint:}%
\def\CALX_hyLp #1{\expandafter\CALX_hyLa\romannumeral`&&@#1\xint:}%
\def\CALX_hyLa #1#2#3.#4.%
{%
    \ifnum\numexpr#3+\xint_c_viii*#4>-\xint_c_i
      \xint_dothis\CALX_hyLa_large\fi
    \xint_orthat\CALX_hyLa_regular #1#2#3.#4.%
}%
\def\CALX_hyLa_large #1#2#3.#4.#5\xint:%
   {\expandafter\CALX_hyLc
      \the\numexpr\XINTdigits+\xint_c_iv.#1#2#3.#4.#5\xint:}%
\def\CALX_hyLa_regular #1#2#3.#4.#5\xint:{\CALX_lpa#1#2#3.#4.#5\xint:}%
\def\CALX_hyLc #1.#2\xint:%
   {\CALX_fnround{\XINTdigits}{\expandafter\CALX_hyLd
    \romannumeral0\CALX_fadd{#1}{\CALX_hyup}{#2}\xint:#1.}}%
\begingroup\catcode`F=12
\gdef\CALX_hyLd F#1\xint:#2.{\CALX_lpLP#2.#1\xint:}%
\endgroup
\def\CALX_hyLm #1%
   {\expandafter\CALX_fopp_a\romannumeral0\CALX_hyLp{#1}\xint:}%
\def\CALX_hyS #1#2%
   {\expandafter\CALX_hySa\romannumeral0\CALX_fmul{#2}{#1}{#1}\xint:%
    {#1}{#2}}%
\def\CALX_hySa #1\xint:#2#3#4%
{%
    #4{\CALX_fadd{#3}{#2}{\CALX_fdiv{#3}{#1}{\CALX_fadd{#3}{\CALX_fonec}%
      {\CALX_fsqrt{#3}{\CALX_fadd{#3}{\CALX_fonec}{#1}}}}}}%
}%
\def\CALX_hyb #1\xint:#2.{\CALX_hyS{#1}{#2}}%
\def\CALX_hyq #1\xint:#2.#3%
{%
    #3{\CALX_fdiv{#2}{#1}{\CALX_fadd{#2}{\CALX_fonec}{\CALX_fsqrt{#2}%
      {\CALX_fadd{#2}{\CALX_fonec}{#1}}}}}%
}%
\def\CALX_hyW #1#2%
   {\CALX_fadd{#2}{#1}{\CALX_fsqrt{#2}{\CALX_fmul{#2}{#1}%
      {\CALX_faddx{#1}{\CALX_hytwo}}}}}%
%    \end{macrocode}
%\begin{lverb}
% Final ratios: w\xint:u\xint:Q. (tanh, coth, csch), e^-x\xint:e^x\xint:Q.
% (sech, csch).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_hyTt #1\xint:#2\xint:#3.%
   {\CALX_fnround{\XINTdigits}{\CALX_fdiv{#3}{\CALX_fsubx{#2}{#1}}%
      {\CALX_faddx{\CALX_faddx{#2}{#1}}{\CALX_hytwo}}}}%
\def\CALX_hyKt #1\xint:#2\xint:#3.%
   {\CALX_fnround{\XINTdigits}{\CALX_fdiv{#3}%
      {\CALX_faddx{\CALX_faddx{#2}{#1}}{\CALX_hytwo}}{\CALX_fsubx{#2}{#1}}}}%
\def\CALX_hyEt #1\xint:#2\xint:#3.%
   {\CALX_fnround{\XINTdigits}{\CALX_fdiv{#3}{\CALX_hytwo}%
      {\CALX_faddx{#2}{#1}}}}%
\def\CALX_hyHt #1\xint:#2\xint:#3.%
   {\CALX_fnround{\XINTdigits}{\CALX_fdiv{#3}{\CALX_hytwo}%
      {\CALX_fsubx{#2}{#1}}}}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_hyT<sign><opposite><sign 1><log1p wrapper><sign>: the F macros.
% Parameters: Q.F<sign>D.e.blocks\xint:, v = D + 8e = E + 1.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_hyT #1#2#3#4#5%
{%
\expandafter\def\csname CALX_hySF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_ \xint_dothis{\csname CALX_hySF#1a\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5>\xint_c_iii
      \xint_dothis{\csname CALX_hySF#1b\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<\xint_c_i
      \xint_dothis{\csname CALX_hySF#1c\endcsname}\fi
    \xint_orthat{\csname CALX_hySF#1d\endcsname}##1.##2##3##4.##5.%
}%
\expandafter\def\csname CALX_hySF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
 ##2+0.0.%
}%
\expandafter\def\csname CALX_hySF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
#5{\calxFpExp{\CALX_fsubx{##2+##4.##5.##6}%
        {\CALX_hyln}}}%
}%
\expandafter\def\csname CALX_hySF#1c\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_fnround{\XINTdigits}{\CALX_fhalf{\CALX_fsubx
        {\CALX_hyU{##2#1##4.##5.##6}}{\CALX_hyU{##2#2##4.##5.##6}}}}%
}%
\expandafter\def\csname CALX_hySF#1d\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_fnround{\XINTdigits}{\CALX_fhalf{\CALX_fsubx
        {\CALX_hyX{##2#1##4.##5.##6}}{\CALX_hyX{##2#2##4.##5.##6}}}}%
}%
\expandafter\def\csname CALX_hyCF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_ \xint_dothis{\csname CALX_hyCF#1a\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5>\xint_c_iii
      \xint_dothis{\csname CALX_hyCF#1b\endcsname}\fi
    \xint_orthat{\csname CALX_hyCF#1c\endcsname}##1.##2##3##4.##5.%
}%
\expandafter\def\csname CALX_hyCF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\expandafter\space\CALX_hyup%
}%
\expandafter\def\csname CALX_hyCF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\calxFpExp{\CALX_fsubx{##2+##4.##5.##6}{\CALX_hyln}}%
}%
\expandafter\def\csname CALX_hyCF#1c\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_fnround{\XINTdigits}{\CALX_fhalf{\CALX_faddx
        {\CALX_hyX{##2#1##4.##5.##6}}{\CALX_hyX{##2#2##4.##5.##6}}}}%
}%
\expandafter\def\csname CALX_hyTF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_ \xint_dothis{\csname CALX_hyTF#1a\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5>\xint_c_iii
      \xint_dothis{\csname CALX_hyTF#1b\endcsname}\fi
    \xint_orthat{\csname CALX_hyTF#1c\endcsname}##1.##2##3##4.##5.%
}%
\expandafter\def\csname CALX_hyTF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
 ##2+0.0.%
}%
\expandafter\def\csname CALX_hyTF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\expandafter\space#3%
}%
\expandafter\def\csname CALX_hyTF#1c\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_hyP\CALX_hyU{##2#1##4.##5.##6}%
      {##2#2##4.##5.##6}\CALX_hyTt##1.%
}%
\expandafter\def\csname CALX_hyKF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_
      \xint_dothis{\csname CALX_hyKF#1a\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5>\xint_c_iii
      \xint_dothis{\csname CALX_hyKF#1b\endcsname}\fi
    \xint_orthat{\csname CALX_hyKF#1c\endcsname}##1.##2##3##4.##5.%
}%
\expandafter\def\csname CALX_hyKF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_nsig{DivisionByZero}{coth(0)}{+}%
}%
\expandafter\def\csname CALX_hyKF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\expandafter\space#3%
}%
\expandafter\def\csname CALX_hyKF#1c\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_hyP\CALX_hyU{##2#1##4.##5.##6}%
      {##2#2##4.##5.##6}\CALX_hyKt##1.%
}%
\expandafter\def\csname CALX_hyEF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_ \xint_dothis{\csname CALX_hyEF#1a\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5>\xint_c_iii
      \xint_dothis{\csname CALX_hyEF#1b\endcsname}\fi
    \xint_orthat{\csname CALX_hyEF#1c\endcsname}##1.##2##3##4.##5.%
}%
\expandafter\def\csname CALX_hyEF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\expandafter\space\CALX_hyup%
}%
\expandafter\def\csname CALX_hyEF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\calxFpExp{\CALX_fsubx{\CALX_hyln}{##2+##4.##5.##6}}%
}%
\expandafter\def\csname CALX_hyEF#1c\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_hyP\CALX_hyX{##2#1##4.##5.##6}%
      {##2#2##4.##5.##6}\CALX_hyEt##1.%
}%
\expandafter\def\csname CALX_hyHF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_
      \xint_dothis{\csname CALX_hyHF#1a\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5>\xint_c_iii
      \xint_dothis{\csname CALX_hyHF#1b\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<\xint_c_i
      \xint_dothis{\csname CALX_hyHF#1c\endcsname}\fi
    \xint_orthat{\csname CALX_hyHF#1d\endcsname}##1.##2##3##4.##5.%
}%
\expandafter\def\csname CALX_hyHF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_nsig{DivisionByZero}{csch(0)}{+}%
}%
\expandafter\def\csname CALX_hyHF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
#5{\calxFpExp{\CALX_fsubx{\CALX_hyln}%
        {##2+##4.##5.##6}}}%
}%
\expandafter\def\csname CALX_hyHF#1c\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_hyP\CALX_hyU{##2#1##4.##5.##6}%
        {##2#2##4.##5.##6}\CALX_hyHt##1.%
}%
\expandafter\def\csname CALX_hyHF#1d\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_hyP\CALX_hyX{##2#1##4.##5.##6}%
      {##2#2##4.##5.##6}\CALX_hyHt##1.%
}%
\expandafter\def\csname CALX_hysF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_ \xint_dothis{\csname CALX_hysF#1a\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<\numexpr\xint_c_i-##1/\xint_c_ii\relax
      \xint_dothis{\csname CALX_hysF#1b\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5>##1
      \xint_dothis{\csname CALX_hysF#1c\endcsname}\fi
    \xint_orthat{\csname CALX_hysF#1d\endcsname}##1.##2##3##4.##5.%
}%
\expandafter\def\csname CALX_hysF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
 ##2+0.0.%
}%
\expandafter\def\csname CALX_hysF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
 ##2#1##4.##5.##6%
}%
\expandafter\def\csname CALX_hysF#1c\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
#4{\CALX_faddx{##2+##4.##5.##6}{##2+##4.##5.##6}}%
}%
\expandafter\def\csname CALX_hysF#1d\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_hyS{##2+##4.##5.##6}{##1}#4%
}%
\expandafter\def\csname CALX_hytF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_ \xint_dothis{\csname CALX_hytF#1a\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<\numexpr\xint_c_i-##1/\xint_c_ii\relax
      \xint_dothis{\csname CALX_hytF#1b\endcsname}\fi
    \xint_orthat{\csname CALX_hytF#1c\endcsname}##1.##2##3##4.##5.%
}%
\expandafter\def\csname CALX_hytF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
 ##2+0.0.%
}%
\expandafter\def\csname CALX_hytF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
 ##2#1##4.##5.##6%
}%
\expandafter\def\csname CALX_hytF#1c\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\expandafter\CALX_hyta\romannumeral0\CALX_fsub{##1}%
      {\CALX_hyup}{##2+##4.##5.##6}\xint:{##2+##4.##5.##6}##1.#4#1%
}%
\expandafter\def\csname CALX_hykF#1\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \expandafter\CALX_hyka\romannumeral0\CALX_fsub{##1}%
      {##2+##4.##5.##6}{\CALX_hyup}\xint:##1.#4#1%
}%
\expandafter\def\csname CALX_hyhF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_
      \xint_dothis{\csname CALX_hyhF#1a\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5>\numexpr##1/\xint_c_ii\relax
      \xint_dothis{\csname CALX_hyhF#1b\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<\numexpr\xint_c_i-##1/\xint_c_ii\relax
      \xint_dothis{\csname CALX_hyhF#1c\endcsname}\fi
    \xint_orthat{\csname CALX_hyhF#1d\endcsname}##1.##2##3##4.##5.%
}%
\expandafter\def\csname CALX_hyhF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_nsig{DivisionByZero}{acsch(0)}{+}%
}%
\expandafter\def\csname CALX_hyhF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_fdiv{\XINTdigits}{\CALX_hyup}%
        {##2#1##4.##5.##6}%
}%
\expandafter\def\csname CALX_hyhF#1c\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
#4{\CALX_fdiv{##1}{\CALX_fsub{##1}{\CALX_hytwo}%
        {##2+##4.##5.##6}}{##2+##4.##5.##6}}%
}%
\expandafter\def\csname CALX_hyhF#1d\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\expandafter\CALX_hyb\romannumeral0\CALX_fdiv{##1}%
      {\CALX_hyup}{##2+##4.##5.##6}\xint:##1.#4%
}%
}%
\CALX_hyT+-\CALX_hyup\CALX_hyLp\CALX_hyNp
\CALX_hyT-+\CALX_hyum\CALX_hyLm\CALX_hyNm
%    \end{macrocode}
%\begin{lverb}
% atanh, acoth: d = 1 - a, a - 1 (at Q digits, exact near |x| = 1);
% \CALX_hyta d\xint:{a}Q.<L><sign>, \CALX_hyka d\xint:Q.<L><sign>.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_hyta #1#2#3.#4.#5\xint:#6#7.#8#9%
{%
    \if-#2\xint_dothis
      {\CALX_nsig{InvalidOperation}{atanh(x), |x| > 1}{}}\fi
    \ifnum#3=\xint_c_
      \xint_dothis{\CALX_nsig{DivisionByZero}{atanh(+-1)}{#9}}\fi
    \xint_orthat{\expandafter\CALX_hyq\romannumeral0\CALX_fdiv{#7}%
      {\CALX_faddx{#6}{#6}}{#1#2#3.#4.#5}\xint:#7.#8}%
}%
\def\CALX_hyka #1#2#3.#4.#5\xint:#6.#7#8%
{%
    \if-#2\xint_dothis
      {\CALX_nsig{InvalidOperation}{acoth(x), |x| < 1}{}}\fi
    \ifnum#3=\xint_c_
      \xint_dothis{\CALX_nsig{DivisionByZero}{acoth(+-1)}{#8}}\fi
    \xint_orthat{\expandafter\CALX_hyq\romannumeral0\CALX_fdiv{#6}%
      {\CALX_hytwo}{#1#2#3.#4.#5}\xint:#6.#7}%
}%
%    \end{macrocode}
%\begin{lverb}
% acosh (x >= 1) and asech (0 < x <= 1): t = x - 1, t = (1 - x)/x.
%\end{lverb}
%    \begin{macrocode}
\expandafter\def\csname CALX_hycF+\endcsname #1.#2#3#4.#5.#6\xint:%
{%
    \ifnum\numexpr#4+\xint_c_viii*#5>#1
      \xint_dothis{\CALX_hyLp{\CALX_faddx{#2+#4.#5.#6}{#2+#4.#5.#6}}}\fi
    \xint_orthat{\expandafter\CALX_hyca\romannumeral0\CALX_fsub{#1}%
      {#2+#4.#5.#6}{\CALX_hyup}\xint:#1.}%
}%
\expandafter\def\csname CALX_hycF-\endcsname #1\xint:%
   {\CALX_nsig{InvalidOperation}{acosh(x), x < 1}{}}%
\def\CALX_hyca #1#2#3.#4.#5\xint:#6.%
{%
    \if-#2\xint_dothis{\CALX_nsig{InvalidOperation}{acosh(x), x < 1}{}}\fi
    \ifnum#3=\xint_c_ \xint_dothis{ #1+0.0.}\fi
    \xint_orthat{\CALX_hyLp{\CALX_hyW{#1#2#3.#4.#5}{#6}}}%
}%
\expandafter\def\csname CALX_hyeF+\endcsname #1.#2#3#4.#5.#6\xint:%
{%
    \ifnum#4=\xint_c_
      \xint_dothis{\CALX_nsig{DivisionByZero}{asech(0)}{+}}\fi
    \ifnum\numexpr#4+\xint_c_viii*#5<\numexpr\xint_c_i-#1/\xint_c_ii\relax
      \xint_dothis{\CALX_hyLp{\CALX_fdiv{#1}{\CALX_fsub{#1}{\CALX_hytwo}%
        {#2+#4.#5.#6}}{#2+#4.#5.#6}}}\fi
    \xint_orthat{\expandafter\CALX_hyea\romannumeral0\CALX_fsub{#1}%
      {\CALX_hyup}{#2+#4.#5.#6}\xint:{#2+#4.#5.#6}#1.}%
}%
\expandafter\def\csname CALX_hyeF-\endcsname #1\xint:%
   {\CALX_nsig{InvalidOperation}{asech(x), x < 0}{}}%
\def\CALX_hyea #1#2#3.#4.#5\xint:#6#7.%
{%
    \if-#2\xint_dothis{\CALX_nsig{InvalidOperation}{asech(x), x > 1}{}}\fi
    \ifnum#3=\xint_c_ \xint_dothis{ #1+0.0.}\fi
    \xint_orthat{\expandafter\CALX_hyeb\romannumeral0\CALX_fdiv{#7}%
      {#1#2#3.#4.#5}{#6}\xint:#7.}%
}%
\def\CALX_hyeb #1\xint:#2.{\CALX_hyLp{\CALX_hyW{#1}{#2}}}%
%    \end{macrocode}
%\begin{lverb}
% P <= 8 (codes <c>w, \CALX_hye adds w). x = X8 10^(E-7), X8 the 8 leading
% digits (\CALX_hzx: one or two blocks, D <= P + 7); u = x^2 at scale 2e9:
% U2 (\CALX_hzU, abs. error <= 0.5 unit).
% Results built as V = |y| 10^-z (V >= 10^9, error a few units: 0.05 ulp is
% >= 5 units) and written by \CALX_hyv + \CALX_hywb (log P <= 8 writer
% \CALX_lgUw), or as a factor F = 1 +- t (two-part native, \CALX_hynb) and
% one product/quotient at Q digits.
%(
%:  |x| < 1   sinh x(1 + u A), A = 1/6 + u A' (A' at 2e11);
%:            cosh 1 + u/2 + u^2 B' (B' at 4e10); csch (1/x)(1 - (S-1)/S)
%:  |x| < 0.5 tanh x(1 - Delta), Delta = uK/C, K = 1/3 + u K' (K' at 5e10);
%:            coth (1/x)(1 + Delta/(1 - Delta)); sech 1 - Cm/(1 + Cm)
%:  |x| < 1000 otherwise: one call of the P <= 8 exp kernel (kind xw,
%:            marker \CALX_xwMk: e^a native from Z' = H' 10^6 + L'', relative
%:            error < 2.2e-10), then Q-digit operations on E = e^a, E^2
%:  asinh, atanh |x| < 0.1: x(1 - u Ka), x(1 + u Kc) (series to u^4)
%)
% Other inputs, and acosh, acoth, asech, acsch: the general code.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_hzx #1.1#2!#3\relax
   {\ifx\relax#3\relax#2*\CALX_pten{8-#1}\else\CALX_hzy#1.#2.#3\fi}%
\def\CALX_hzy #1.#2.1#3!{#3*\CALX_pten{16-#1}+#2/\CALX_pten{#1-8}}%
\def\CALX_hzU #1.#2.%
   {\ifnum#2>-3 #1*#1/(5*\CALX_pten{4-2*#2})\else
    #1*#1/500000000/\CALX_pten{-2*#2-4}\fi}%
\def\CALX_hzAp #1{(1666666667+#1*(39682540+#1*(551146+#1*(5010%
   +#1*32/2000000000)/2000000000)/2000000000)/2000000000)}%
\def\CALX_hzBp #1{(1666666667+#1*(55555556+#1*(992063+#1*(11023%
   +#1*84/2000000000)/2000000000)/2000000000)/2000000000)}%
\def\CALX_hzKp #1{(1666666667+#1*(59523810+#1*(1102293+#1*(12526%
   +#1*96/2000000000)/2000000000)/2000000000)/2000000000)}%
\def\CALX_hzKb #1{(1500000000-#1*(892857143-#1*607638889/2000000000)%
   /2000000000)}%
\def\CALX_hzKc #1{(2000000000+#1*(1428571429+#1*1111111111/2000000000)%
   /2000000000)}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_hyv<final>R.H.: H 10^8 + R normalized (-10^8 < R < 2.09e9) ->
% <final>H'.1<8 digits>. ; \CALX_hywb: the writer (stream: sign z.),
% \CALX_hynb: the native (stream: z.).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_hyv #1#2.#3.%
   {\expandafter\CALX_hyva\the\numexpr(#2+50000000)/100000000-1.#3.#2.#1}%
\def\CALX_hyva #1.#2.#3.#4%
   {\expandafter#4\the\numexpr#2+#1\expandafter.%
    \the\numexpr100000000+#3-100000000*#1.}%
\def\CALX_hywb #1.1#2.{\CALX_lgUw#1!!#2!!}%
\def\CALX_hynb #1.1#2.#3.{\CALX_ffromraw{#1#2[#3]}}%
%    \end{macrocode}
%\begin{lverb}
% series: \CALX_hzS X8.E.<sign> (sinh), \CALX_hzC U2. (cosh),
% \CALX_hzE U2. (sech), \CALX_hzT U2.<x>.Q.<L> (tanh, coth: <L> =
% \CALX_hzTt, \CALX_hzKt), \CALX_hzH U2.<x>.Q. (csch), \CALX_hzs, \CALX_hzt
% (asinh, atanh: X8.E.<sign>)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_hzS #1.#2.#3%
{%
    \expandafter\CALX_hzSa\the\numexpr\CALX_hzU#1.#2.\relax.#1.#2.#3%
}%
\def\CALX_hzSa #1.#2.#3.#4%
{%
    \expandafter\CALX_hzSb\the\numexpr#1*5/6%
      +#1*(#1*\CALX_hzAp{#1}/2000000000)/2000000000/20%
    \expandafter.\the\numexpr(#2-500000)/1000000\expandafter.%
    \the\numexpr#3-9.#2.#4%
}%
\def\CALX_hzSb #1.#2.#3.#4.#5%
{%
    \expandafter\CALX_hyv\expandafter\CALX_hywb
    \the\numexpr100*(#4-1000000*#2)+#4*#1/100000000.#2.#5#3.%
}%
\def\CALX_hzC #1.%
{%
    \expandafter\CALX_hyv\expandafter\CALX_hywb
    \the\numexpr#1/4+#1*(#1*\CALX_hzBp{#1}/2000000000)/2000000000/40.10.+-9.%
}%
\def\CALX_hzCm #1{#1*5/2+#1*(#1*\CALX_hzBp{#1}/2000000000)/2000000000/4}%
\def\CALX_hzE #1.%
{%
    \expandafter\CALX_hzEa\the\numexpr\CALX_hzCm{#1}.%
}%
\def\CALX_hzEa #1.%
{%
    \expandafter\CALX_hyv\expandafter\CALX_hywb
    \the\numexpr2000000000-#1*1000000000/(1000000000+#1/10).80.+-10.%
}%
\def\CALX_hzT #1.%
{%
    \expandafter\CALX_hzTa\the\numexpr\CALX_hzCm{#1}\expandafter.%
    \the\numexpr#1*5/3+#1*(#1*\CALX_hzKp{#1}/2000000000)/2000000000/5.%
}%
\def\CALX_hzTa #1.#2.%
{%
    \expandafter\CALX_hzTb\the\numexpr#2-#2*#1/(1000000000+#1/10)/10.%
}%
\def\CALX_hzTb #1.#2#3.#4{#4#1.{#2}#3.}%
\def\CALX_hzTt #1.#2#3.%
{%
    \CALX_fnround{\XINTdigits}{\CALX_fmul{#3}{#2}%
      {\expandafter\CALX_hyv\expandafter\CALX_hynb
       \the\numexpr1000000000-#1.90.-10.}}%
}%
\def\CALX_hzKt #1.#2#3.%
{%
    \CALX_fnround{\XINTdigits}{\CALX_fmul{#3}{\CALX_fdiv{#3}{\CALX_hyup}{#2}}%
      {\expandafter\CALX_hyv\expandafter\CALX_hynb\the\numexpr
       #1*1000000000/(1000000000-#1/10).100.-10.}}%
}%
\def\CALX_hzH #1.%
{%
    \expandafter\CALX_hzHa\the\numexpr#1*5/6%
      +#1*(#1*\CALX_hzAp{#1}/2000000000)/2000000000/20.%
}%
\def\CALX_hzHa #1.#2#3.%
{%
    \CALX_fnround{\XINTdigits}{\CALX_fmul{#3}{\CALX_fdiv{#3}{\CALX_hyup}{#2}}%
      {\expandafter\CALX_hyv\expandafter\CALX_hynb\the\numexpr
       2000000000-#1*1000000000/(1000000000+#1/10).80.-10.}}%
}%
\def\CALX_hzs #1.#2.#3%
{%
    \expandafter\CALX_hzsa\the\numexpr\CALX_hzU#1.#2.\relax.#1.#2.#3%
}%
\def\CALX_hzsa #1.#2.#3.#4%
{%
    \expandafter\CALX_hzsb\the\numexpr#1*5/6%
      -#1*(#1*\CALX_hzKb{#1}/2000000000)/2000000000/2%
    \expandafter.\the\numexpr(#2-50000)/100000\expandafter.%
    \the\numexpr#3-10.#2.#4%
}%
\def\CALX_hzsb #1.#2.#3.#4.#5%
{%
    \expandafter\CALX_hyv\expandafter\CALX_hywb
    \the\numexpr1000*(#4-100000*#2)+1000000000-#4*#1/10000000\expandafter.%
    \the\numexpr#2-10.#5#3.%
}%
\def\CALX_hzt #1.#2.#3%
{%
    \expandafter\CALX_hzta\the\numexpr\CALX_hzU#1.#2.\relax.#1.#2.#3%
}%
\def\CALX_hzta #1.#2.#3.#4%
{%
    \expandafter\CALX_hzSb\the\numexpr#1*5/3%
      +#1*(#1*\CALX_hzKc{#1}/2000000000)/2000000000%
    \expandafter.\the\numexpr(#2-500000)/1000000\expandafter.%
    \the\numexpr#3-9.#2.#4%
}%
%    \end{macrocode}
%\begin{lverb}
% exp kernel P <= 8, kind xw: \CALX_xwMk H'.L''.k.<cont> -> <cont> E\xint:
% (E = e^a native); continuations <cont>Q.<data>: \CALX_hzXS (sinh, cosh:
% <fsubx|faddx><sign>), \CALX_hzXT (tanh, coth, sech, csch: <final><final
% for E >= 10^8><sign 1 or 2>); E >= 10^8: E^-1 negligible.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_xwhG 1#1!1#2!1#3!1#4!#5\xint:#6%
   {\CALX_exGn#1.#2.#3.#4.#6C\CALX_xwMk}%
\def\CALX_xwMk #1.#2.#3.%
   {\expandafter\CALX_xwMa\the\numexpr#3-12\expandafter.%
    \the\numexpr1000000+#2.#1.}%
\def\CALX_xwMa #1.1#2.#3.#4%
   {\expandafter#4\romannumeral0\CALX_ffromraw{#3#2[#1]}\xint:}%
\begingroup\catcode`F=12
\gdef\CALX_hzXS F#1#2.#3.%
{%
    \ifnum\numexpr#2+\xint_c_viii*#3>\xint_c_viii
      \xint_dothis\CALX_hzXS_large\fi
    \xint_orthat\CALX_hzXS_regular
    F#1#2.#3.%
}%
\gdef\CALX_hzXS_large F#1#2.#3.#4\xint:#5.#6#7%
   {#7{\CALX_fnround{\XINTdigits}{\CALX_fhalf{F#1#2.#3.#4}}}}%
\gdef\CALX_hzXS_regular F#1#2.#3.#4\xint:#5.#6#7%
   {#7{\CALX_fnround{\XINTdigits}{\CALX_fhalf{#6{F#1#2.#3.#4}%
      {\CALX_fdiv{#5}{\CALX_hyup}{F#1#2.#3.#4}}}}}}%
\gdef\CALX_hzXT F#1#2.#3.%
{%
    \ifnum\numexpr#2+\xint_c_viii*#3>\xint_c_viii
      \xint_dothis\CALX_hzXT_large\fi
    \xint_orthat\CALX_hzXT_regular
    F#1#2.#3.%
}%
\gdef\CALX_hzXT_large F#1#2.#3.#4\xint:#5.#6#7#8%
   {#7{F#1#2.#3.#4}#8}%
\gdef\CALX_hzXT_regular F#1#2.#3.#4\xint:#5.#6#7#8%
   {\expandafter#6\romannumeral0\CALX_fmul{#5}{F#1#2.#3.#4}%
      {F#1#2.#3.#4}\xint:{F#1#2.#3.#4}#5.#8}%
\endgroup
%    \end{macrocode}
%\begin{lverb}
% finals: normal <E^2>\xint:{E}Q.<c> (c = sign 1 or 2), E >= 10^8: {E}<c>
%\end{lverb}
%    \begin{macrocode}
\def\CALX_hzXTa #1\xint:#2#3.#4%
   {\CALX_fnround{\XINTdigits}{\CALX_fdiv{#3}{\CALX_fmulx{#4}%
      {\CALX_fsubx{#1}{\CALX_hyup}}}{\CALX_faddx{#1}{\CALX_hyup}}}}%
\def\CALX_hzXKa #1\xint:#2#3.#4%
   {\CALX_fnround{\XINTdigits}{\CALX_fdiv{#3}{\CALX_fmulx{#4}%
      {\CALX_faddx{#1}{\CALX_hyup}}}{\CALX_fsubx{#1}{\CALX_hyup}}}}%
\def\CALX_hzXTb #1{\expandafter\space}%
\def\CALX_hzXEa #1\xint:#2#3.#4%
   {\CALX_fnround{\XINTdigits}{\CALX_fdiv{#3}{\CALX_fmulx{#4}{#2}}%
      {\CALX_faddx{#1}{\CALX_hyup}}}}%
\def\CALX_hzXHa #1\xint:#2#3.#4%
   {\CALX_fnround{\XINTdigits}{\CALX_fdiv{#3}{\CALX_fmulx{#4}{#2}}%
      {\CALX_fsubx{#1}{\CALX_hyup}}}}%
\def\CALX_hzXEb #1#2{\CALX_fnround{\XINTdigits}{\CALX_fdiv{12}{#2}{#1}}}%
\def\CALX_hzu #1#2.#3.{\expandafter#1\the\numexpr\CALX_hzU#2.#3.\relax.}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_hzW<sign><opposite><sign 1><sign wrapper><sign 2>: the P <= 8 F
% macros; v = D + 8e = E + 1.
%\end{lverb}
%    \begin{macrocode}
\edef\CALX_hymtwo{\romannumeral0\CALX_ffromraw{-2[0]}}%
\def\CALX_hzW #1#2#3#4#5%
{%
\expandafter\def\csname CALX_hySwF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_
      \xint_dothis{\csname CALX_hySwF#1a\endcsname ##1.##2##3##4.##5.}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<-\xint_c_iv
      \xint_dothis{\csname CALX_hySwF#1b\endcsname ##1.##2##3##4.##5.}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<\xint_c_i
      \xint_dothis{\csname CALX_hySwF#1c\endcsname ##1.##2##3##4.##5.}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<\xint_c_iv
      \xint_dothis{\csname CALX_hySwF#1d\endcsname ##1.##2##3##4.##5.}\fi
    \xint_orthat{\csname CALX_hySwF#1e\endcsname ##1.##2##3##4.##5.}%
}%
\expandafter\def\csname CALX_hySwF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
     ##2+0.0.%
}%
\expandafter\def\csname CALX_hySwF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
     ##2#1##4.##5.##6%
}%
\expandafter\def\csname CALX_hySwF#1c\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \expandafter\CALX_hzS
        \the\numexpr\CALX_hzx##4.##6\relax\expandafter.%
        \the\numexpr##4-\xint_c_i+\xint_c_viii*##5.#1%
}%
\expandafter\def\csname CALX_hySwF#1d\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \CALX_exb xw;+##4.##5.##6\xint:\CALX_hzXS##1.%
        \CALX_fsubx#4%
}%
\expandafter\def\csname CALX_hySwF#1e\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \csname CALX_hySF#1\endcsname##1.##2##3##4.##5.##6\xint:%
}%
%
\expandafter\def\csname CALX_hyCwF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_
      \xint_dothis{\csname CALX_hyCwF#1a\endcsname ##1.##2##3##4.##5.}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<-\xint_c_iv
      \xint_dothis{\csname CALX_hyCwF#1b\endcsname ##1.##2##3##4.##5.}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<\xint_c_i
      \xint_dothis{\csname CALX_hyCwF#1c\endcsname ##1.##2##3##4.##5.}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<\xint_c_iv
      \xint_dothis{\csname CALX_hyCwF#1d\endcsname ##1.##2##3##4.##5.}\fi
    \xint_orthat{\csname CALX_hyCwF#1e\endcsname ##1.##2##3##4.##5.}%
}%
\expandafter\def\csname CALX_hyCwF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \expandafter\space\CALX_hyup%
}%
\expandafter\def\csname CALX_hyCwF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \expandafter\space\CALX_hyup%
}%
\expandafter\def\csname CALX_hyCwF#1c\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \expandafter\CALX_hzu\expandafter\CALX_hzC
        \the\numexpr\CALX_hzx##4.##6\relax\expandafter.%
        \the\numexpr##4-\xint_c_i+\xint_c_viii*##5.%
}%
\expandafter\def\csname CALX_hyCwF#1d\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \CALX_exb xw;+##4.##5.##6\xint:\CALX_hzXS##1.%
        \CALX_faddx\CALX_hyNp%
}%
\expandafter\def\csname CALX_hyCwF#1e\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \csname CALX_hyCF#1\endcsname##1.##2##3##4.##5.##6\xint:%
}%
%
\expandafter\def\csname CALX_hyTwF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_ \xint_dothis{\csname CALX_hyTwF#1a\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<-\xint_c_iv
      \xint_dothis{\csname CALX_hyTwF#1b\endcsname}\fi
    \xint_orthat{\csname CALX_hyTwF#1r\endcsname}##1.##2##3##4.##5.%
}%
\expandafter\def\csname CALX_hyTwF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
 ##2+0.0.%
}%
\expandafter\def\csname CALX_hyTwF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
 ##2#1##4.##5.##6%
}%
\expandafter\def\csname CALX_hyTwF#1r\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \ifnum\numexpr(##4+\xint_c_viii*##5)*100000000%
      +\CALX_hzx##4.##6\relax<50000000
      \xint_dothis{\expandafter\CALX_hzu\expandafter\CALX_hzT
        \the\numexpr\CALX_hzx##4.##6\relax\expandafter.%
        \the\numexpr##4-\xint_c_i+\xint_c_viii*##5.%
        {##2#1##4.##5.##6}##1.\CALX_hzTt}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<\xint_c_iv
      \xint_dothis{\CALX_exb xw;+##4.##5.##6\xint:\CALX_hzXT##1.%
        \CALX_hzXTa\CALX_hzXTb#3}\fi
    \xint_orthat{\csname CALX_hyTF#1\endcsname##1.##2##3##4.##5.##6\xint:}%
}%
\expandafter\def\csname CALX_hyKwF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_
      \xint_dothis{\csname CALX_hyKwF#1a\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<-\xint_c_iv
      \xint_dothis{\csname CALX_hyKwF#1b\endcsname}\fi
    \xint_orthat{\csname CALX_hyKwF#1r\endcsname}##1.##2##3##4.##5.%
}%
\expandafter\def\csname CALX_hyKwF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_nsig{DivisionByZero}{coth(0)}{+}%
}%
\expandafter\def\csname CALX_hyKwF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_fdiv{\XINTdigits}{\CALX_hyup}{##2#1##4.##5.##6}%
}%
\expandafter\def\csname CALX_hyKwF#1r\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \ifnum\numexpr(##4+\xint_c_viii*##5)*100000000%
      +\CALX_hzx##4.##6\relax<50000000
      \xint_dothis{\expandafter\CALX_hzu\expandafter\CALX_hzT
        \the\numexpr\CALX_hzx##4.##6\relax\expandafter.%
        \the\numexpr##4-\xint_c_i+\xint_c_viii*##5.%
        {##2#1##4.##5.##6}##1.\CALX_hzKt}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<\xint_c_iv
      \xint_dothis{\CALX_exb xw;+##4.##5.##6\xint:\CALX_hzXT##1.%
        \CALX_hzXKa\CALX_hzXTb#3}\fi
    \xint_orthat{\csname CALX_hyKF#1\endcsname##1.##2##3##4.##5.##6\xint:}%
}%
\expandafter\def\csname CALX_hyEwF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_ \xint_dothis{\csname CALX_hyEwF#1a\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<-\xint_c_iv
      \xint_dothis{\csname CALX_hyEwF#1b\endcsname}\fi
    \xint_orthat{\csname CALX_hyEwF#1r\endcsname}##1.##2##3##4.##5.%
}%
\expandafter\def\csname CALX_hyEwF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\expandafter\space\CALX_hyup%
}%
\expandafter\def\csname CALX_hyEwF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\expandafter\space\CALX_hyup%
}%
\expandafter\def\csname CALX_hyEwF#1r\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \ifnum\numexpr(##4+\xint_c_viii*##5)*100000000%
      +\CALX_hzx##4.##6\relax<50000000
      \xint_dothis{\expandafter\CALX_hzu\expandafter\CALX_hzE
        \the\numexpr\CALX_hzx##4.##6\relax\expandafter.%
        \the\numexpr##4-\xint_c_i+\xint_c_viii*##5.}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<\xint_c_iv
      \xint_dothis{\CALX_exb xw;+##4.##5.##6\xint:\CALX_hzXT##1.%
        \CALX_hzXEa\CALX_hzXEb\CALX_hytwo}\fi
    \xint_orthat{\csname CALX_hyEF#1\endcsname##1.##2##3##4.##5.##6\xint:}%
}%
\expandafter\def\csname CALX_hyHwF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_
      \xint_dothis{\csname CALX_hyHwF#1a\endcsname}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<-\xint_c_iv
      \xint_dothis{\csname CALX_hyHwF#1b\endcsname}\fi
    \xint_orthat{\csname CALX_hyHwF#1r\endcsname}##1.##2##3##4.##5.%
}%
\expandafter\def\csname CALX_hyHwF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_nsig{DivisionByZero}{csch(0)}{+}%
}%
\expandafter\def\csname CALX_hyHwF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
\CALX_fdiv{\XINTdigits}{\CALX_hyup}{##2#1##4.##5.##6}%
}%
\expandafter\def\csname CALX_hyHwF#1r\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \ifnum\numexpr##4+\xint_c_viii*##5<\xint_c_i
      \xint_dothis{\expandafter\CALX_hzu\expandafter\CALX_hzH
        \the\numexpr\CALX_hzx##4.##6\relax\expandafter.%
        \the\numexpr##4-\xint_c_i+\xint_c_viii*##5.%
        {##2#1##4.##5.##6}##1.}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<\xint_c_iv
      \xint_dothis{\CALX_exb xw;+##4.##5.##6\xint:\CALX_hzXT##1.%
        \CALX_hzXHa\CALX_hzXEb#5}\fi
    \xint_orthat{\csname CALX_hyHF#1\endcsname##1.##2##3##4.##5.##6\xint:}%
}%
\expandafter\def\csname CALX_hyswF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_
      \xint_dothis{\csname CALX_hyswF#1a\endcsname ##1.##2##3##4.##5.}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<-\xint_c_iv
      \xint_dothis{\csname CALX_hyswF#1b\endcsname ##1.##2##3##4.##5.}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<\xint_c_
      \xint_dothis{\csname CALX_hyswF#1c\endcsname ##1.##2##3##4.##5.}\fi
    \xint_orthat{\csname CALX_hyswF#1d\endcsname ##1.##2##3##4.##5.}%
}%
\expandafter\def\csname CALX_hyswF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
     ##2+0.0.%
}%
\expandafter\def\csname CALX_hyswF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
     ##2#1##4.##5.##6%
}%
\expandafter\def\csname CALX_hyswF#1c\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \expandafter\CALX_hzs
        \the\numexpr\CALX_hzx##4.##6\relax\expandafter.%
        \the\numexpr##4-\xint_c_i+\xint_c_viii*##5.#1%
}%
\expandafter\def\csname CALX_hyswF#1d\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \csname CALX_hysF#1\endcsname##1.##2##3##4.##5.##6\xint:%
}%
%
\expandafter\def\csname CALX_hytwF#1\endcsname ##1.##2##3##4.##5.%
{%
    \ifnum##4=\xint_c_
      \xint_dothis{\csname CALX_hytwF#1a\endcsname ##1.##2##3##4.##5.}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<-\xint_c_iv
      \xint_dothis{\csname CALX_hytwF#1b\endcsname ##1.##2##3##4.##5.}\fi
    \ifnum\numexpr##4+\xint_c_viii*##5<\xint_c_
      \xint_dothis{\csname CALX_hytwF#1c\endcsname ##1.##2##3##4.##5.}\fi
    \xint_orthat{\csname CALX_hytwF#1d\endcsname ##1.##2##3##4.##5.}%
}%
\expandafter\def\csname CALX_hytwF#1a\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
     ##2+0.0.%
}%
\expandafter\def\csname CALX_hytwF#1b\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
     ##2#1##4.##5.##6%
}%
\expandafter\def\csname CALX_hytwF#1c\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \expandafter\CALX_hzt
        \the\numexpr\CALX_hzx##4.##6\relax\expandafter.%
        \the\numexpr##4-\xint_c_i+\xint_c_viii*##5.#1%
}%
\expandafter\def\csname CALX_hytwF#1d\endcsname ##1.##2##3##4.##5.##6\xint:%
{%
    \csname CALX_hytF#1\endcsname##1.##2##3##4.##5.##6\xint:%
}%
%
}%
\CALX_hzW+-\CALX_hyup\CALX_hyNp\CALX_hytwo
\CALX_hzW-+\CALX_hyum\CALX_hyNm\CALX_hymtwo
\def\CALX_hzL #1%
{%
    \expandafter\let\csname CALX_hy#1wF+\expandafter\endcsname
      \csname CALX_hy#1F+\endcsname
    \expandafter\let\csname CALX_hy#1wF-\expandafter\endcsname
      \csname CALX_hy#1F-\endcsname
}%
\CALX_hzL c\CALX_hzL k\CALX_hzL e\CALX_hzL h%
%    \end{macrocode}
%\begin{lverb}
% Public macros and expression functions (\CALX_hymk <Name><code><name>).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_hymk #1#2#3%
{%
    \expandafter\def\csname calxFp#1\endcsname##1%
      {\romannumeral0\expandafter\CALX_hyd\expandafter#2%
       \romannumeral0\CALX_fround{\XINTdigits}{##1}}%
    \expandafter\edef\csname calxRaw#1\endcsname##1%
      {\noexpand\romannumeral0\noexpand\CALX_ftoraw
       {\expandafter\noexpand\csname calxFp#1\endcsname{##1}}}%
    \expandafter\edef\csname XINT_flexpr_func_#3\endcsname##1##2##3%
      {\noexpand\expandafter##1\noexpand\expandafter##2%
       \noexpand\expandafter{\noexpand\romannumeral`&&@%
       \noexpand\XINT:NEhook:f:one:from:one{\noexpand\romannumeral`&&@%
       \expandafter\noexpand\csname calxFp#1\endcsname##3}}}%
    \expandafter\edef\csname XINT_expr_func_#3\endcsname##1##2##3%
      {\noexpand\expandafter##1\noexpand\expandafter##2%
       \noexpand\expandafter{\noexpand\romannumeral`&&@%
       \noexpand\XINT:NEhook:f:one:from:one{\noexpand\romannumeral`&&@%
       \expandafter\noexpand\csname calxRaw#1\endcsname##3}}}%
}%
\CALX_hymk{Sinh}S{sinh}\CALX_hymk{Cosh}C{cosh}\CALX_hymk{Tanh}T{tanh}%
\CALX_hymk{Coth}K{coth}\CALX_hymk{Sech}E{sech}\CALX_hymk{Csch}H{csch}%
\CALX_hymk{Asinh}s{asinh}\CALX_hymk{Acosh}c{acosh}%
\CALX_hymk{Atanh}t{atanh}\CALX_hymk{Acoth}k{acoth}%
\CALX_hymk{Asech}e{asech}\CALX_hymk{Acsch}h{acsch}%
%    \end{macrocode}
% \subsection{Aliases}
%    \begin{macrocode}
\let\XINT_flexpr_func_ln\XINT_flexpr_func_log
\let\XINT_expr_func_ln\XINT_expr_func_log
\let\XINT_flexpr_func_sh\XINT_flexpr_func_sinh
\let\XINT_flexpr_func_ch\XINT_flexpr_func_cosh
\let\XINT_flexpr_func_th\XINT_flexpr_func_tanh
\let\XINT_flexpr_func_argsh\XINT_flexpr_func_asinh
\let\XINT_flexpr_func_argch\XINT_flexpr_func_acosh
\let\XINT_flexpr_func_argth\XINT_flexpr_func_atanh
\let\XINT_flexpr_func_argcoth\XINT_flexpr_func_acoth
\let\XINT_flexpr_func_argsech\XINT_flexpr_func_asech
\let\XINT_flexpr_func_argcsch\XINT_flexpr_func_acsch
\xintFor #1 in {sh, ch, th, argsh, argch, argth, argcoth, argsech, argcsch}\do{%
    \expandafter\let\csname XINT_expr_func_#1\expandafter\endcsname
                    \csname XINT_expr_func_#1\endcsname
}%
%    \end{macrocode}
% \StoreCodelineNo {calxlog}
% \cleardoublepage\let\calxlognameUp\undefined
%\gardesactifs
%\let</calxlog>\relax
%\let<*calxlogdata>\gardesinactifs
%</calxlog>------------------------------------------------------
%<*calxlogdata>^^A-------------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname calxlogdatanameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section{Library \calxlognameimp data tables}
% \RaisedLabel{sec:calxlogdataimp}
% \addedcalx{2.0a1}
%
%\begin{lverb}
% calxlogdata.tex -- table constants shared by log and potential exp.
% Full table: floor(log(factor)*10^112); native P16 cache: 24 places.
% P1..P8 (s47): log tables at 10^-12, see calxlog.tex (\CALX_lgULoadT/V).
%
% This file is loaded from calxlog.tex in a context having done
% \XINTsetcatcodes, in particular the exclamation mark has catcode 12.
%
% The definition of \ver@calxlogdata.tex control sequence done also under
% existence of LaTeX \ProvidesFile is due to a miniltx feature (under
% investigation).
%\end{lverb}
%    \begin{macrocode}
\ifdefined\ProvidesFile
  \ProvidesFile{calxlogdata.tex}[2026/11/01 v2.0a1 calx log data (JFB)]%
\fi
\expandafter\def\csname ver@calxlogdata.tex\endcsname
  {2026/11/01 v2.0a1 calx log data (JFB)}%
\CALX_lgULoadT
10.909.0.954.1018.4805,11.833.0.1827.2163.6815,12.769.0.2626.6430.9476,%
13.714.0.3368.7231.6643,14.666.0.4064.6560.8442,15.625.0.4700.362.9246,%
16.588.0.5310.2833.1084,17.555.0.5887.8716.5236,18.526.0.6424.5406.6244,%
19.500.0.6931.4718.560,20.476.0.7423.3742.4751,21.454.0.7896.5808.941,%
22.434.0.8347.1074.4882,23.416.0.8770.7001.8721,24.400.0.9162.9073.1874,%
25.384.0.9571.1272.6394,26.370.0.9942.5227.3344,27.357.1.300.1949.7202,%
28.344.1.671.1362.1609,29.333.1.996.1278.9002,30.322.1.1332.373.3438,%
31.312.1.1647.5209.1173,32.303.1.1940.2247.3473,33.294.1.2241.7551.1643,%
34.285.1.2552.6609.8713,35.277.1.2837.3777.2795,36.270.1.3093.3331.9984,%
37.263.1.3356.124.6804,38.256.1.3625.7783.4503,39.250.1.3862.9436.1120,%
40.243.1.4146.9383.5642,41.238.1.4354.8460.5311,42.232.1.4610.1790.7316,%
43.227.1.4828.526.1501,44.222.1.5050.7789.7110,45.217.1.5278.5792.5442,%
46.212.1.5511.6900.4310,47.208.1.5702.1719.9281,48.204.1.5896.3528.5138,%
49.200.1.6094.3791.2434,50.196.1.6296.4061.9752,51.192.1.6502.5990.6954,%
52.188.1.6713.1331.6152,53.185.1.6873.9945.3904,54.181.1.7092.5824.7716,%
55.178.1.7259.7172.8690,56.175.1.7429.6930.5059,57.172.1.7602.6080.2169,%
58.169.1.7778.5656.4059,59.166.1.7957.6749.626,60.163.1.8140.507.8175,%
61.161.1.8263.5091.3998,62.158.1.8451.6024.5955,63.156.1.8578.9927.1733,%
64.153.1.8773.1735.7590,65.151.1.8904.7544.2167,66.149.1.9038.897.3037,%
67.147.1.9173.2269.2203,68.144.1.9379.4197.9406,69.142.1.9519.2822.1381,%
70.140.1.9661.1285.6373,71.138.1.9805.159.3825,72.136.1.9951.39.3246,%
73.135.2.24.8050.544,74.133.2.174.615.760,75.131.2.325.5795.5781,%
76.129.2.479.4287.4620,77.128.2.557.2501.5063,78.126.2.714.7337.2031,%
79.125.2.794.4154.1680,80.123.2.955.7092.3610,81.121.2.1119.6473.3385,%
82.120.2.1202.6353.6200,83.119.2.1286.3178.5871,84.117.2.1455.8134.4184,%
85.116.2.1541.6508.7876,86.114.2.1715.5683.588,87.113.2.1803.6746.270,%
88.112.2.1892.5640.7687,89.111.2.1982.2507.7670,90.109.2.2164.739.6753,%
91.108.2.2256.2405.1858,92.107.2.2349.2644.4520,93.106.2.2443.1618.4870,%
94.105.2.2537.9492.8825,95.104.2.2633.6437.9841,96.103.2.2730.2629.753,%
97.102.2.2827.8246.5698,98.101.2.2926.3476.2141,99.100.2.3025.8509.2994,%
0.0.0.0.0.0,%
\CALX_lgULoadV
0.0.0.0,1.9.9950.333,2.19.9800.2663,3.29.9550.8980,4.39.9202.1270,%
5.49.8754.1511,6.59.8207.1678,7.69.7561.3736,8.79.6816.9649,9.89.5974.1371,%
10.99.5033.853,11.109.3994.38,12.119.2857.865,13.129.1622.5267,%
14.139.290.5169,15.148.8861.2494,16.158.7334.9156,17.168.5711.7066,%
18.178.3991.8128,19.188.2175.4241,20.198.262.7296,21.207.8253.9183,%
22.217.6149.1782,23.227.3948.6969,24.237.1652.6617,25.246.9261.2590,%
26.256.6774.6749,27.266.4193.946,28.276.1516.7033,29.285.8745.6852,%
30.295.5880.2242,31.305.2920.5035,32.314.9866.7059,33.324.6719.138,%
34.334.3477.6086,35.344.142.6717,36.353.6714.3837,37.363.3192.9247,%
38.372.9578.4744,39.382.5871.2117,40.392.2071.3153,41.401.8178.9633,%
42.411.4194.3331,43.421.117.6019,44.430.5948.9460,45.440.1688.5417,%
46.449.7336.5643,47.459.2893.1888,48.468.8358.5899,49.478.3732.9414,%
50.487.9016.4169,51.497.4209.1895,52.506.9311.4316,53.516.4323.3152,%
54.525.9245.119,55.535.4076.6928,56.544.8818.5284,57.554.3470.6888,%
58.563.8033.3436,59.573.2506.6619,60.582.6890.8124,61.592.1185.9632,%
62.601.5392.2820,63.610.9509.9360,64.620.3539.919,65.629.7479.9161,%
66.639.1332.5744,67.648.5097.2320,68.657.8774.538,69.667.2363.2043,%
70.676.5864.8474,71.685.9279.1466,72.695.2606.2649,73.704.5846.3649,%
74.713.8999.6087,75.723.2066.1580,76.732.5046.1740,77.741.7939.8174,%
78.751.747.2487,79.760.3468.6276,80.769.6104.1136,81.778.8653.8657,%
82.788.1118.424,83.797.3496.8019,84.806.5790.3017,85.815.7998.6992,%
86.825.122.1512,87.834.2160.8139,88.843.4114.8434,89.852.5984.3951,%
90.861.7769.6241,91.870.9470.6851,92.880.1087.7323,93.889.2620.9194,%
94.898.4070.4000,95.907.5436.3268,96.916.6718.8526,97.925.7918.1293,%
98.934.9034.3087,99.944.67.5421,100.953.1017.9804,101.962.1885.7741,%
-1.0.0.0,%
% log10 (s47): 1/ln10 truncated to 130 digits
\def\CALX_Lzinvraw{43429448190325182765112891891660508229439700580366656%
                   61144537831658646492088707747292249493384317483187061%
                   067447663037336416792871[-130]}%
% exp (s49): bucket table i.key.c. (gen_expdata.py, exp_bounds.py)
\def\CALX_exAlist{%
0.0.10000.1.10.9524.2.10.9524.3.10.9524.4.11.8696.5.11.8696.6.11.8696.7.11.%
8696.%
8.12.8000.9.12.8000.10.12.8000.11.13.7407.12.13.7407.13.13.7407.14.13.7407.%
15.14.%
6897.16.14.6897.17.14.6897.18.15.6452.19.15.6452.20.16.6061.21.16.6061.22.16.%
6061.%
23.17.5714.24.17.5714.25.17.5714.26.18.5405.27.18.5405.28.19.5128.29.19.5128.%
30.20.%
4878.31.20.4878.32.21.4651.33.21.4651.34.22.4444.35.22.4444.36.23.4255.37.23.%
4255.%
38.24.4082.39.24.4082.40.25.3922.41.26.3774.42.26.3774.43.27.3636.44.27.3636.%
45.28.%
3509.46.29.3390.47.29.3390.48.30.3279.49.31.3175.50.31.3175.51.32.3077.52.33.%
2985.53.%
34.2899.54.35.2817.55.35.2817.56.36.2740.57.37.2667.58.38.2597.59.39.2532.60.%
40.2469.%
61.41.2410.62.42.2353.63.43.2299.64.44.2247.65.45.2198.66.46.2151.67.47.2105.%
68.48.2062.69.49.2020.70.50.1980.71.51.1942.72.53.1869.73.54.1835.74.55.1802.%
75.56.1770.76.58.1709.77.59.1681.78.60.1653.79.62.1600.80.63.1575.81.65.1527.%
82.66.1504.83.68.1460.84.69.1439.85.71.1399.86.73.1361.87.74.1342.88.76.1307.%
89.78.1274.90.80.1242.91.82.1212.92.84.1183.93.86.1156.94.88.1130.95.90.1105.%
96.92.1081.97.94.1058.98.96.1036.99.1.1000.-1.0.0.}%
% ln10 limbs 3..31 (10^-12 .. 10^-124, floor), exp rare path P > 16
\def\CALX_exLx{2994!0456!8401!7991!4546!8436!4207!6011!0148!8628!7729!7603!%
3327!9009!6757!2609!6773!5248!0235!9972!0508!9598!2983!4196!7784!0422!8624!%
8633!4095!}%
% calxlogdata_s50.tex -- generated by calx/t/s50/gen_logdata.py (s50: 128 places).
% Floors at 10^-128: F1!c2!...!c16!, F1 = floor(10^8 value) (see generator).
\@namedef{CALX_Lz}{230258509!29940456!84017991!45468436!42076011!01488628!%
77297603!33279009!67572609!67735248!02359972!05089598!29834196!77840422!%
86248633!40952546!}%
\def\CALX_Lzraw{2302585092994045684017991454684364207601101488628772976033327%
90096757260967735248023599720508959829834196778404228624863340952546[-128]}%
\@namedef{CALX_Lb0}{0!0!0!0!0!0!0!0!0!0!0!0!0!0!0!0!}%
\@namedef{CALX_Ls0}{0!0!0!0!0!0!0!0!0!0!0!0!0!0!0!0!}%
\@namedef{CALX_Lt0}{0!0!0!0!0!0!0!0!0!0!0!0!0!0!0!0!}%
\@namedef{CALX_Lu0}{0!0!0!0!0!0!0!0!0!0!0!0!0!0!0!0!}%
\@namedef{CALX_Lv0}{0!0!0!0!0!0!0!0!0!0!0!0!0!0!0!0!}%
\@namedef{CALX_Lb10}{4877016!43694293!36438707!09756716!44757540!30750384!%
86035967!62043359!32455608!94122546!68018852!73358077!49141346!88747895!%
70469625!61742890!}%
\@namedef{CALX_Lb11}{13972194!31751373!64678175!44301696!52712039!97184836!%
45331971!42500516!42479531!64743535!51508681!01872546!03600091!89139520!%
03589419!21760533!}%
\@namedef{CALX_Lb12}{22314355!13142097!55766295!09030983!45033746!01085548!%
00721367!12878724!87391743!76826833!34184072!24100342!23571596!33409805!%
74191432!35296475!}%
\@namedef{CALX_Lb13}{30015959!39628935!41371602!37944702!72769808!91876679!%
20550559!77179025!65849303!27944414!71217655!17752346!84864281!78978044!%
07633012!93937294!}%
\@namedef{CALX_Lb14}{37149855!85448914!96543805!99399681!89888761!22427518!%
37928342!35216155!62356195!60013023!92061052!65723651!62595342!90221061!%
60995397!73700552!}%
\@namedef{CALX_Lb15}{43819493!27310832!55733785!23617541!65471959!89052525!%
87033936!52180080!48059180!90773175!48005880!42744461!37180218!14169936!%
47502086!74779789!}%
\@namedef{CALX_Lb16}{50071029!00248977!04817722!77652256!23878508!06925355!%
80183145!51133066!87643331!59412358!58614086!13722162!08351011!51923350!%
90024935!80227559!}%
\@namedef{CALX_Lb17}{55966578!91854643!54500117!66979777!15388453!04460706!%
78467197!45551708!20457419!05438256!30576210!61284747!03442015!02755367!%
29888029!74325560!}%
\@namedef{CALX_Lb18}{61526064!19028740!83843502!98392889!93635403!73783385!%
91440702!15199881!06299991!51115278!55047640!96677472!78725725!60456750!%
81784009!02261093!}%
\@namedef{CALX_Lb19}{66786937!33756767!67986862!91636132!69403096!71722039!%
36786625!96453530!54332445!52642539!67010711!99040292!36043514!69578056!%
66497065!89571724!}%
\@namedef{CALX_Lb20}{71784979!32003171!43767373!15022836!68141283!92775092!%
81408601!40285319!06563729!45287167!16068233!53055328!44436231!53978467!%
64816121!21726166!}%
\@namedef{CALX_Lb21}{76550284!27520857!22079452!35855135!97223254!86076623!%
03479508!91977063!29076333!22551495!29152721!67824181!56882994!97868036!%
88895202!88481475!}%
\@namedef{CALX_Lb22}{81103022!12166621!22291359!73094298!52375408!16244659!%
55947074!21185140!50917687!25443990!51525273!51620964!26902069!12749814!%
46642489!12169377!}%
\@namedef{CALX_Lb23}{85449033!09687082!26296357!98266962!59085363!46698238!%
50227657!71156537!20128458!02659279!27164323!16440050!10743189!86672852!%
03627352!27378869!}%
\@namedef{CALX_Lb24}{89599802!86063926!33176801!01931048!64087813!94244530!%
97917766!54000859!81706601!01518340!81170410!67394256!72104538!72969006!%
54874881!45408646!}%
\@namedef{CALX_Lb25}{93598336!52198911!48142168!88721877!53280688!50480075!%
98288331!95894431!65902435!80586428!14044440!15203884!61520194!68823765!%
87778395!83479224!}%
\@namedef{CALX_Lb26}{97444964!60476872!10641858!17145218!08581931!34662578!%
70624733!57868416!64120200!72981389!21533933!36838570!80873774!24117445!%
33718380!40540525!}%
\@namedef{CALX_Lb27}{101170091!66788132!83562812!83506306!31280675!41982951!%
47774249!12975559!06502724!73045868!44803505!49996134!88285946!69427376!%
68909526!64125448!}%
\@namedef{CALX_Lb28}{104725399!63929676!20764806!63044528!66252664!79332717!%
51347477!45058339!66362409!74508416!15005122!89535267!18789244!00996677!%
02162762!56866023!}%
\@namedef{CALX_Lb29}{108175517!16016867!92076597!63351454!52461264!83519360!%
57568162!49413339!21649630!25439840!29981857!57955190!72827527!02024514!%
46181009!88988077!}%
\@namedef{CALX_Lb30}{111504659!51315344!84010607!67124674!69902575!43934652!%
50955719!23890832!90556597!96991184!30913325!65498134!15405297!64766107!%
66634102!11947625!}%
\@namedef{CALX_Lb31}{114727746!06493907!13823006!34456878!91564792!94122051!%
97069740!07506130!64747201!55751901!39378259!44569530!63764548!84831726!%
37907428!82654800!}%
\@namedef{CALX_Lb32}{117862999!66541409!08983344!16223132!13675758!70500426!%
86830325!33457619!77682025!65026056!28072227!16147167!61053562!13153719!%
62144607!72580399!}%
\@namedef{CALX_Lb33}{120898534!61494802!74665839!95672020!62843402!08761854!%
35223157!95083908!14517952!40222728!93142549!13153263!44630582!89778697!%
78853610!08020156!}%
\@namedef{CALX_Lb34}{123821924!30545272!41382373!16744899!81989005!09735283!%
89796460!38937306!08689493!94901281!04120082!55717158!20503389!78163285!%
02889390!06510058!}%
\@namedef{CALX_Lb35}{126691260!40998101!36602710!03563519!50675363!25570532!%
32307251!55592916!33338911!22138741!68328657!88830543!13517080!21975014!%
11685930!40074170!}%
\@namedef{CALX_Lb36}{129462717!25940668!27321552!11461505!06641646!69157481!%
49835892!90296523!79178828!19947837!83571288!43535953!29862341!55317854!%
20985311!81541225!}%
\@namedef{CALX_Lb37}{132163084!77941684!66523927!03065545!90012459!21543184!%
39550103!19619124!38031021!00215630!85368194!47354286!24346438!93659442!%
60026574!18280197!}%
\@namedef{CALX_Lb38}{134822816!03134342!91716791!19282203!96007702!58742440!%
15192416!64018339!77126079!26178152!68340118!78696728!90953963!39272763!%
51849691!85438726!}%
\@namedef{CALX_Lb39}{137357558!87121159!30100300!07344429!78715647!56954390!%
16357346!94784516!39873148!59048283!97347590!76159433!01835517!39687333!%
96150110!71201216!}%
\@namedef{CALX_Lb40}{139877188!26310032!32766847!61636955!29816283!82434501!%
95495733!24122362!03343596!49805311!39953812!72566078!93743078!79268703!%
65498755!30737716!}%
\@namedef{CALX_Lb41}{142295834!54914820!56587563!04534227!68877860!44701870!%
07109042!85814416!91021317!12724799!40020678!20726813!92710829!51310055!%
31388185!09720306!}%
\@namedef{CALX_Lb42}{144689398!32488202!53179391!33853912!92983588!05568252!%
40597413!15379891!96509934!12678166!43197429!20744181!06928471!13853263!%
86480267!59124234!}%
\@namedef{CALX_Lb43}{147011084!72130011!87939051!23091934!46935236!12985341!%
12873515!82159491!99850488!81873920!60797210!20537383!71474139!90511721!%
18861140!10500975!}%
\@namedef{CALX_Lb44}{149298909!97908535!66266969!02134847!43945566!84390979!%
07371037!91104010!48498913!20873902!97253958!63455178!92767582!31389494!%
73967503!00391652!}%
\@namedef{CALX_Lb45}{151503723!70126160!64124935!71743262!52839495!77459709!%
32510562!50554467!07591405!58752431!97289572!32246874!68282158!37947875!%
66455601!26248869!}%
\@namedef{CALX_Lb46}{153665224!27084526!86318311!75063049!63246716!20483066!%
62332989!49401207!86632178!93130952!81887638!12471197!08587090!59837126!%
70419048!28742588!}%
\@namedef{CALX_Lb47}{155826962!58597009!43882490!25711417!17173572!62538271!%
91122294!42886071!55970564!69589149!67573865!96781458!56065725!06919422!%
86302648!10105522!}%
\@namedef{CALX_Lb48}{157890870!73992775!01350328!59183507!78535211!75661349!%
24980374!68872363!47055382!48885874!40256082!25792261!37393118!12145128!%
13413328!94946192!}%
\@namedef{CALX_Lb49}{159948758!15809322!91752543!97568192!68978369!21744328!%
45892404!80383317!07312323!46001885!35974481!81530419!44963544!06978478!%
69078111!65325770!}%
\@namedef{CALX_Lb50}{161948824!82876018!15784308!19078473!53456111!16361943!%
14759529!13473170!03761996!71190807!82798420!70642277!23849324!60870862!%
34330159!55147854!}%
\@namedef{CALX_Lb51}{163886672!31249125!15395120!34995610!28351694!36881376!%
84878173!06444447!68407021!24579761!56578073!10065298!56743717!34091876!%
56680847!78926947!}%
\@namedef{CALX_Lb52}{165810308!44153813!97028520!44087245!10913574!04918497!%
73896757!87041709!01431896!04656781!16943440!67848978!15965748!47571283!%
95604586!18254900!}%
\@namedef{CALX_Lb53}{167718156!45206199!01253552!29770190!21767151!70279977!%
52189983!25295430!07262389!95927543!98356510!15007313!83456955!12466705!%
54040736!44539503!}%
\@namedef{CALX_Lb54}{169554061!14875120!89851774!54635284!00253491!38165233!%
44591823!54048941!18757216!44593294!48272102!05452390!59361022!04538374!%
22943678!67049218!}%
\@namedef{CALX_Lb55}{171368793!38078995!12260729!94037709!59563807!25054657!%
87425966!72643864!76599606!99529406!58913706!80838550!32846540!75726202!%
96388490!21877870!}%
\@namedef{CALX_Lb56}{173160554!64083079!10042678!75341086!92940924!67118733!%
11494685!32526722!06023421!54802099!64750359!00652429!03722748!94435050!%
15917874!80931506!}%
\@namedef{CALX_Lb57}{174927485!76218997!04882919!47793383!59576082!77865327!%
23170728!78905758!70482478!21324778!29342775!33251478!55162961!06099772!%
31816418!82376550!}%
\@namedef{CALX_Lb58}{176667668!88605918!46335612!62850485!39773479!65765923!%
50139270!04728098!60031668!44262357!34770563!89169342!32080871!69685376!%
85580947!33002611!}%
\@namedef{CALX_Lb59}{178319623!85675671!28338439!07266264!16536515!85015716!%
48863689!47857833!50333205!89809490!90193545!37614419!57129189!01573783!%
96010840!13683953!}%
\@namedef{CALX_Lb60}{179999327!41551585!57484421!11756516!59830250!23221470!%
46955493!89866821!80722662!28875133!20628475!66911064!78613686!08891572!%
70157715!68984053!}%
\@namedef{CALX_Lb61}{181646208!18684268!35162618!38715089!25187758!83332915!%
56353774!87228655!44058022!67148063!84804391!07869060!53315028!54269127!%
22681863!58526588!}%
\@namedef{CALX_Lb62}{183258146!37483101!30367054!42353602!21429002!02439816!%
52493558!39357639!61570731!47592609!80485411!02193521!84651592!96440022!%
89754332!07696998!}%
\@namedef{CALX_Lb63}{184832982!07164492!98974603!93499685!04124211!37400750!%
69636837!92370037!09364014!10480719!01488310!55956698!26719893!67777879!%
46996337!73033069!}%
\@namedef{CALX_Lb64}{186433016!20628904!31524050!70628454!77728277!64181137!%
20923443!06177389!53557424!72684844!38639929!05839528!65365296!01122161!%
03338185!63402795!}%
\@namedef{CALX_Lb65}{187928006!67575503!01841856!72575517!24772303!90473260!%
64605536!13734764!02229259!99252497!30438216!21595652!73997553!80784825!%
62982486!13034382!}%
\@namedef{CALX_Lb66}{189445686!74663976!02164854!54167440!02811308!54780693!%
59160032!94032095!96504115!35513527!03039824!31941553!77470141!21571652!%
74055136!17774361!}%
\@namedef{CALX_Lb67}{190986755!77083839!53570139!14989848!80908592!03746305!%
45925035!16229688!25033728!87519070!57151978!29172962!39722056!07312348!%
03350001!27835472!}%
\@namedef{CALX_Lb68}{192414865!72738006!13544633!38515637!34838230!51486654!%
46600938!36048362!47534231!14176543!18257989!65437517!31322987!04467048!%
96338424!42294755!}%
\@namedef{CALX_Lb69}{193863666!50888149!19138665!25293717!68563035!71259310!%
42351320!04676252!70686728!93565631!16294057!13064676!22575966!27795162!%
61031650!02530424!}%
\@namedef{CALX_Lb70}{195333766!48841099!27489536!64048005!71586763!21191471!%
10021240!06300090!37533107!80405339!49256313!54822299!74977656!69366366!%
20779413!97346582!}%
\@namedef{CALX_Lb71}{196682739!73107015!60679395!44961500!51858743!19415587!%
53896986!34352903!38255138!98028203!09281764!04724256!83671038!05868014!%
90705742!82836563!}%
\@namedef{CALX_Lb72}{198122649!41828809!24186815!74613144!61257586!77162575!%
19100987!53170820!17209199!90849169!64205729!67114909!76718689!44828525!%
34817616!52938461!}%
\@namedef{CALX_Lb73}{199436536!93247166!64273124!04020619!38515242!26452886!%
22775015!90205837!64110671!35539244!81509061!98092420!95482760!53442981!%
89016134!94412265!}%
\@namedef{CALX_Lb74}{200842405!44445556!33841401!01588853!62161915!17223136!%
15841185!66802388!26883385!98152976!10776415!79259235!94138768!10370178!%
03739679!73175263!}%
\@namedef{CALX_Lb75}{202117263!35558601!52725978!01325602!37809932!25493066!%
83885725!98863509!03927829!35060453!31490611!19686112!74192582!47096446!%
23005715!85388132!}%
\@namedef{CALX_Lb76}{203485065!83519607!88463612!11624558!09768982!89146829!%
99290864!76672804!55958873!60474397!28134285!59356431!55318073!90010046!%
44074731!52084082!}%
\@namedef{CALX_Lb77}{204794287!46204649!37185886!61378471!98825966!77723182!%
01406117!36041043!42364361!94046203!52967838!62371065!51934042!76426928!%
04088610!10102178!}%
\@namedef{CALX_Lb78}{206042353!58440740!80390540!76882760!21982494!68416230!%
90715667!48057838!38272423!91116649!03632338!32745741!96307048!80746441!%
09305344!97292261!}%
\@namedef{CALX_Lb79}{207306193!47157969!02037103!40837470!65628406!25220401!%
45569907!04811753!01614493!94842285!90270090!91652302!89752571!24408104!%
91584122!77340948!}%
\@namedef{CALX_Lb80}{208586210!94827586!61662245!15470150!70299440!53831846!%
15255280!99132159!81420691!09909000!65188771!36767783!42510776!23543793!%
70574676!98984031!}%
\@namedef{CALX_Lb81}{209801292!72652712!98963198!37268654!50384441!24734283!%
38400714!52011167!73596759!27643308!57819172!88192813!35235675!48848520!%
17783255!79692704!}%
\@namedef{CALX_Lb82}{211031320!53469229!74958058!07198558!88327150!32540774!%
22719422!59918895!43997017!94906765!13539663!04809866!97164743!69718036!%
26775269!00925870!}%
\@namedef{CALX_Lb83}{212193159!33007880!77844534!52439782!35754053!95770282!%
15732657!34853939!82517877!91134229!88474823!57638899!66714230!97089347!%
05080886!31643606!}%
\@namedef{CALX_Lb84}{213453150!79977959!58859638!19216363!98911567!85335412!%
81648283!58304326!05781241!30852029!43571809!94889542!68883629!30577777!%
68410358!85004061!}%
\@namedef{CALX_Lb85}{214558134!41843809!33209996!44864272!26087030!55405480!%
61290821!15495249!64264575!27042932!75611854!42200841!22868070!51019021!%
80292783!96041345!}%
\@namedef{CALX_Lb86}{215761932!27438599!56738432!34007485!06230769!99660623!%
09182129!74761091!18918043!16815792!79080724!30290549!92324717!16500336!%
29508483!47187570!}%
\@namedef{CALX_Lb87}{216892870!81813720!80234034!53717611!30262355!15714943!%
50723775!66577287!38116590!53561660!94508621!91128425!68166948!10310841!%
53301743!53855000!}%
\@namedef{CALX_Lb88}{218036746!02697964!83471842!87043707!09507739!74077183!%
32513335!96356675!59143923!47300736!98718015!12768922!81706324!02315174!%
04046752!25788500!}%
\@namedef{CALX_Lb89}{219193857!29069820!27493883!97499206!69723337!00801332!%
75469147!44443730!59954865!06846106!48153008!13362001!82107236!06563598!%
46380387!81724787!}%
\@namedef{CALX_Lb90}{220273975!80243295!45168184!42607282!40504853!33642900!%
62227850!43804638!50354207!87641069!60021854!10787221!14628029!83790074!%
79652710!98434929!}%
\@namedef{CALX_Lb91}{221365888!37996441!75405852!90816927!26949050!34492475!%
25900892!70834169!28050891!18852080!99649483!20311866!24284094!65056767!%
24499844!48748048!}%
\@namedef{CALX_Lb92}{222469855!43369744!58444262!31715508!70030659!75137654!%
43212893!41678795!80478979!21881055!01348979!74770652!39805722!23486967!%
97346908!74661616!}%
\@namedef{CALX_Lb93}{223492644!45202308!78749575!54702981!56212401!58189754!%
91137453!98669836!56000459!50206478!41506729!11767184!24511488!70781789!%
96725523!68614754!}%
\@namedef{CALX_Lb94}{224620475!95579380!45041228!03365888!80254441!45190473!%
96516601!53608394!10910324!77011860!89413233!09055984!87711747!52280059!%
14035008!23512435!}%
\@namedef{CALX_Lb95}{225665616!11056458!81477239!05931629!14166080!30059231!%
98006317!22286710!15813007!94600701!88692497!11340940!57964497!87770411!%
20889925!46701023!}%
\@namedef{CALX_Lb96}{226721794!91567543!67764053!16134647!68007162!43369045!%
08404378!76487537!52933585!02759015!65455821!34105515!63050899!75276312!%
56814768!76172983!}%
\@namedef{CALX_Lb97}{227691734!62454678!92459970!55462384!96111490!54885387!%
45947627!05883570!55121235!01969101!60031198!45105038!34366491!89347299!%
50575223!82661515!}%
\@namedef{CALX_Lb98}{228769648!05002950!29182581!70970617!78557472!06956741!%
96891483!96032108!15750807!11183055!52328293!28859485!63292884!35542164!%
11455995!63204106!}%
\@namedef{CALX_Lb99}{229759755!14830066!10405889!25222502!07356643!81139201!%
92939334!81852479!83348652!25505629!28013249!99630456!00924597!26128168!%
11551694!55888592!}%
\@namedef{CALX_Ls-1100}{11653381!62559515!29718167!36869887!91957975!%
42590124!58658795!99582246!47191326!57524871!40249308!58229720!85366664!%
74018577!90550123!71810058!}%
\@namedef{CALX_Ls-1000}{10536051!56578263!01227500!98083931!27983061!%
20372983!27407256!39392336!92584023!24013454!64887656!95462134!12076602!%
77259103!70517148!67351701!}%
\@namedef{CALX_Ls-900}{9431067!94712413!26877142!72436023!00807598!50302915!%
47764718!82201413!34100689!27822551!32847612!48150835!58092161!56817859!%
58634723!56314418!}%
\@namedef{CALX_Ls-800}{8338160!89390510!58394765!83464217!91606088!22393696!%
59970182!66604054!65364729!43051723!10618666!64033364!40724573!53924721!%
00988903!58928182!}%
\@namedef{CALX_Ls-700}{7257069!28348354!30711573!34790384!55001047!73488954!%
20452857!52433958!22669509!53854476!13845138!24029377!87732298!86021295!%
74786709!58050348!}%
\@namedef{CALX_Ls-600}{6187540!37180874!71797800!11813837!81382306!52340877!%
06666474!54674456!34933383!87920917!22554413!29748031!92818548!25131629!%
84300804!10077363!}%
\@namedef{CALX_Ls-500}{5129329!43875505!33426196!14425468!72384392!22361689!%
89941161!60476740!51673529!58284990!71277021!48270277!09008692!86318421!%
06798018!07309191!}%
\@namedef{CALX_Ls-400}{4082199!45202551!29554577!06515531!98701772!11747633!%
52022972!85614208!30682816!28762241!55690620!20383371!07018595!81339157!%
61202856!02344552!}%
\@namedef{CALX_Ls-300}{3045920!74847085!45919261!28766476!67013932!88074598!%
76459609!04214331!74967927!57651783!51297116!65144922!04675698!48874361!%
92790639!28105957!}%
\@namedef{CALX_Ls-200}{2020270!73175194!48408045!30102419!23878525!33383733!%
56832102!71954925!66591871!88087170!92908140!86007034!85515581!06986522!%
99529709!68602617!}%
\@namedef{CALX_Ls-100}{1005033!58535014!41183548!85755854!77060855!15007674!%
62987337!86994255!29583009!00425031!36497081!92549097!62769327!97840645!%
18767259!82747331!}%
\@namedef{CALX_Ls100}{-995034!91468319!17151784!64245573!92583113!20390059!%
94120213!53904402!33133335!75236108!89673143!03437239!83883547!43948261!%
53515211!92925247!}%
\@namedef{CALX_Ls200}{-1980263!27038202!86973970!93311489!96068910!09272488!%
79645891!40437209!21964728!36546999!70804204!60331542!87283561!57959508!%
56888499!36793362!}%
\@namedef{CALX_Ls300}{-2955881!77584555!97267380!59431528!75945739!41868886!%
74278945!54248429!04614014!90691069!08802484!35127087!69109980!19646489!%
80605270!21838109!}%
\@namedef{CALX_Ls400}{-3922072!68467187!03730799!10342888!01061704!34629416!%
57307328!55702627!91499686!12121063!42548297!65749451!04528867!29329300!%
97718434!23033573!}%
\@namedef{CALX_Ls500}{-4879017!58305679!96934625!59577683!53413920!26335584!%
41758995!99234268!85892075!67636896!11805862!78684413!37010293!75417910!%
47927713!00328921!}%
\@namedef{CALX_Ls600}{-5826891!18760242!24474281!64888149!40767667!25089986!%
07309489!78463224!23746963!44152038!63314711!38696856!67929982!02665829!%
10948514!79732061!}%
\@namedef{CALX_Ls700}{-6765865!15261851!94731584!09234545!14136390!56701126!%
13839850!65390826!88427849!82471230!39146757!06677585!94677291!92941367!%
10476890!27662207!}%
\@namedef{CALX_Ls800}{-7696105!88638716!75015782!95568479!81651087!31035068!%
78708862!12127820!35875095!75948862!86394204!91745162!95523602!25188455!%
57528572!34399778!}%
\@namedef{CALX_Ls900}{-8617770!37589476!67658666!45715952!67641418!54093754!%
31479899!17822472!54241935!15954197!87279881!38217743!82418594!27066738!%
40537569!46152001!}%
\@namedef{CALX_Ls1000}{-9531018!01956751!39956047!87671923!49077793!94634691!%
35580081!47601918!36998985!76411576!71609424!97086963!50692725!20581541!%
48250111!15395630!}%
\@namedef{CALX_Ls1100}{-10436002!46757572!32272642!00141475!55466546!%
34832267!16033668!70487871!04661179!14573492!81993571!21693295!84711415!%
65867277!18964138!66946740!}%
\@namedef{CALX_Lt-56}{561573!87856356!95176194!38278177!61543268!68308793!%
91517181!23558309!15962043!32803899!02151540!28866630!26136448!78466098!%
40239662!35528060!}%
\@namedef{CALX_Lt-55}{551518!06881101!62377693!95222777!26411903!52527255!%
12337503!49917965!75365621!43919276!22549539!01159756!96870435!83208755!%
63921226!24834084!}%
\@namedef{CALX_Lt-54}{541463!27014988!81751532!38194002!50357803!37572395!%
52091881!01998703!37911481!49929545!14766865!32887073!89481154!85422854!%
80851513!27678733!}%
\@namedef{CALX_Lt-53}{531409!48237687!93572635!55604600!60359986!38851846!%
76425983!34708024!14770069!31534978!42876462!09776922!18974268!64688264!%
24737071!90854177!}%
\@namedef{CALX_Lt-52}{521356!70528874!51252817!59905599!60052579!08234191!%
27590980!24162993!37232208!78419849!99636509!64942399!42008419!21184552!%
60647660!43171199!}%
\@namedef{CALX_Lt-51}{511304!93868230!21094256!51909687!40372273!86760004!%
46098118!12426340!02334168!83498217!88869136!04398480!28982120!11152292!%
21295741!95803169!}%
\@namedef{CALX_Lt-50}{501254!18235442!82043093!73895836!77813865!97831048!%
32870728!08748234!84439635!94348377!59518734!62877397!23675183!12228934!%
50470719!03868032!}%
\@namedef{CALX_Lt-49}{491204!43610206!25443157!44024929!69137438!30190080!%
34292708!17824785!11097359!36325706!52991895!30706963!82409590!78962662!%
85263599!85712556!}%
\@namedef{CALX_Lt-48}{481155!69972220!54789809!64601389!17139069!80870215!%
92875332!66702224!49820063!50782272!77144038!62242941!81171344!35693157!%
16342384!20459548!}%
\@namedef{CALX_Lt-47}{471107!97301191!85483916!96721077!25486332!80256184!%
41812629!07977902!95200740!13361070!13829415!82355364!28532639!78654804!%
78962218!68965380!}%
\@namedef{CALX_Lt-46}{461061!25576832!44585944!93850963!82012232!98750504!%
86693267!16816596!04522306!42599572!56572951!19372559!19461856!50853149!%
72783811!34580548!}%
\@namedef{CALX_Lt-45}{451015!54778860!70570175!86891313!09638167!65304806!%
67819341!93678992!55221989!83029736!60141289!98088856!15583928!75485092!%
95640477!14382245!}%
\@namedef{CALX_Lt-44}{440970!84887001!13079050!13276372!42639081!16419854!%
87160539!69958933!66674152!56921375!70707905!21785840!75481818!23234704!%
56638634!17006749!}%
\@namedef{CALX_Lt-43}{430927!15880984!32677630!82674781!43653050!62767771!%
58885159!77371495!43641380!50362678!65687635!43863370!46212753!27236656!%
76466277!16222121!}%
\@namedef{CALX_Lt-42}{420884!47740547!00608191!71856149!14053422!92737182!%
85186753!41060052!13655284!43883044!21125485!54812625!62870188!76381407!%
28906642!34145098!}%
\@namedef{CALX_Lt-41}{410842!80445431!98544928!41295471!67424350!14335973!%
66300420!37155716!41114732!97677835!06367836!01264693!38324131!66866080!%
29643175!48122949!}%
\@namedef{CALX_Lt-40}{400802!13975388!18348792!66092284!33289755!00582679!%
82259793!59858873!39857301!98506843!67842219!09491651!99692597!76229563!%
08879610!78730834!}%
\@namedef{CALX_Lt-39}{390762!48310170!61822449!73786658!36320641!67674955!%
15626246!15291290!37953584!17202886!41515383!19551790!17064542!07265281!%
15109350!14779210!}%
\@namedef{CALX_Lt-38}{380723!83429540!40465358!81659365!55365109!28149677!%
38291516!81454275!63412613!18422060!91908758!09066602!86527107!31799415!%
17033879!68443441!}%
\@namedef{CALX_Lt-37}{370686!19313264!75228976!26108742!07187905!42696002!%
04301184!05770254!22840356!21070758!06135929!04917745!93839003!05014439!%
81173975!04744956!}%
\@namedef{CALX_Lt-36}{360649!55941116!96272081!76701987!22149973!77430863!%
13975964!33137680!58680347!32072955!85869124!68444888!60748530!27797458!%
95249318!89809424!}%
\@namedef{CALX_Lt-35}{350613!93292876!42716227!27503832!83580923!46839881!%
43818445!44063582!72070751!21036324!08603957!00615547!22507922!47510632!%
69760565!80389381!}%
\@namedef{CALX_Lt-34}{340579!31348328!62401308!58290714!89676019!72015814!%
88014777!66755111!36389036!79454316!83260599!35220043!43432535!95136250!%
56476010!96416986!}%
\@namedef{CALX_Lt-33}{330545!70087265!11641259!58263770!66761126!34161786!%
88978206!21939114!68640439!48115807!63797865!02533387!25840458!55739861!%
47534168!77040521!}%
\@namedef{CALX_Lt-32}{320513!09489483!54979869!04879172!16090606!60300359!%
25033508!45038386!71182195!29910554!42858134!61835371!17318951!53516542!%
29163544!07131831!}%
\@namedef{CALX_Lt-31}{310481!49534787!64946719!90419490!13350714!70069972!%
70046123!68877017!14752570!18367869!93807272!67321581!51788429!67088460!%
15076705!86315976!}%
\@namedef{CALX_Lt-30}{300450!90202987!21813250!88934962!01110315!32002627!%
33817267!62979648!89868993!66290844!38843128!50075526!84354940!01172005!%
83374650!12888709!}%
\@namedef{CALX_Lt-29}{290421!31473898!13348940!56188712!19967305!23275664!%
22314178!31838854!84160989!79516208!47854995!33674780!44681891!08724277!%
34588987!52253576!}%
\@namedef{CALX_Lt-28}{280392!73327342!34577613!55245144!14457954!04622376!%
81157408!91188750!12722664!30153329!89215094!11820793!07547623!17958158!%
48720328!66984024!}%
\@namedef{CALX_Lt-27}{270365!15743147!87533869!00345890!25302230!46900626!%
01373266!92832241!18745096!99073445!76671269!35352216!93812142!33923980!%
27930793!83865735!}%
\@namedef{CALX_Lt-26}{260338!58701148!81019631!11722868!40625359!43290820!%
00880376!06955235!70411073!77110391!80622357!61997714!49874623!19979881!%
02407651!19212023!}%
\@namedef{CALX_Lt-25}{250313!02181185!30360821!74003152!25798312!48697274!%
31700157!59711009!37565605!25921886!83082884!26954690!46018986!61736331!%
54725731!07638112!}%
\@namedef{CALX_Lt-24}{240288!46163103!57164154!90865516!84851242!56452630!%
02664765!79159588!24469617!78948700!22954397!26467283!42119836!14280141!%
69311058!26368745!}%
\@namedef{CALX_Lt-23}{230264!90626755!89074053!28613671!26407233!57318515!%
64123216!01201320!41416062!71215865!45134884!55843429!26555945!80371652!%
09301888!30521394!}%
\@namedef{CALX_Lt-22}{220242!35552000!59529686!41336336!14131970!28416893!%
12851928!46283775!00775954!81340044!33676481!50474888!73255161!73903593!%
38947703!65108822!}%
\@namedef{CALX_Lt-21}{210220!80918702!07522130!70329465!76170496!08663622!%
10073816!78025748!90545313!36748334!07145012!07006197!54615794!91684630!%
32228317!32253884!}%
\@namedef{CALX_Lt-20}{200200!26706730!77351651!10461052!30317193!49408528!%
27793340!24730508!63971963!17752605!12137547!44880370!22030667!72305768!%
01438630!45568933!}%
\@namedef{CALX_Lt-19}{190180!72895963!18385104!36164083!52111200!20700248!%
95563545!57034090!54648246!05987247!40125567!92808426!60770587!05723622!%
22559384!14077957!}%
\@namedef{CALX_Lt-18}{180162!19466281!84813463!79748354!72037995!01845251!%
94774779!78879944!81342291!40529640!71382010!71285021!53390563!38104823!%
53186177!49955751!}%
\@namedef{CALX_Lt-17}{170144!66397575!35409465!54726961!35919813!88280100!%
22941920!59873765!88050098!89352496!80392071!36836153!41598347!19813803!%
81826100!08120769!}%
\@namedef{CALX_Lt-16}{160128!13669738!33285376!16858419!99763476!46377050!%
09330301!41316836!22182502!40883304!98238917!86132822!11547463!10668458!%
58921290!25378125!}%
\@namedef{CALX_Lt-15}{150112!61262671!45650881!55610482!57174335!68336188!%
52621857!47726216!73561757!05045043!71389875!78527844!47645493!95402384!%
27322774!29225713!}%
\@namedef{CALX_Lt-14}{140098!09156281!43571097!08756822!14309254!69878679!%
19847067!60134167!50571685!78790676!13223829!47993661!20146366!04847537!%
70142728!67509440!}%
\@namedef{CALX_Lt-13}{130084!57330481!01724698!92822877!34599244!48395095!%
59953540!98869842!14475937!72285150!62547601!46981437!09977414!36750829!%
77554949!21715236!}%
\@namedef{CALX_Lt-12}{120072!05765188!98162176!42102247!73492767!98912938!%
19071253!33295176!83794905!43346957!46954920!59069383!18716765!99137776!%
45447730!31723807!}%
\@namedef{CALX_Lt-11}{110060!54440330!14064205!48970133!12622471!36903992!%
28432293!72379366!09777110!46844572!85860766!71512217!40100007!99981865!%
44220718!33447946!}%
\@namedef{CALX_Lt-10}{100050!03335835!33500142!98225406!83449607!55205250!%
43440925!09880207!97245202!38586947!46881228!17155429!96788018!43126380!%
89481287!34298441!}%
\@namedef{CALX_Lt-9}{90040!52431641!43186641!88198005!42959672!29943485!%
50738554!58462760!79581942!48342852!60099601!00272009!73785678!68520851!%
73395909!49944067!}%
\@namedef{CALX_Lt-8}{80032!01707691!32246387!31363406!28737409!38810305!%
25378310!28346523!44014370!23745105!93984628!62872708!36340931!53335882!%
41562714!35592633!}%
\@namedef{CALX_Lt-7}{70024!51143933!91966953!27211048!78106623!25063859!%
67262590!53728599!07061816!82540631!97990052!42185665!05230457!64343152!%
02267551!10920163!}%
\@namedef{CALX_Lt-6}{60018!00720324!15559780!00118635!46347060!42718791!%
14255264!68385248!26403392!91744966!35038991!47359499!79100643!54240016!%
51001127!42376027!}%
\@namedef{CALX_Lt-5}{50012!50416822!97919271!94989326!02663514!53209785!%
57440037!73996927!49289687!18964788!51259409!49714909!34584454!81481845!%
57016951!30941720!}%
\@namedef{CALX_Lt-4}{40008!00213397!35382016!23413909!19947435!42656222!%
36477994!12392134!88556600!24634170!63712345!46338577!72799142!64946031!%
56418209!05395980!}%
\@namedef{CALX_Lt-3}{30004!50090020!25486121!53125106!05804477!93944169!%
14731057!00846962!14359465!89361037!58760482!46256368!14043085!76980917!%
60140462!78953450!}%
\@namedef{CALX_Lt-2}{20002!00026670!66730677!33516222!48188038!92655810!%
37182939!84597792!85285350!95568687!46570819!02951022!81908997!36091767!%
12775420!80131040!}%
\@namedef{CALX_Lt-1}{10000!50003333!58335333!50001428!69643968!35397734!%
57107551!40898657!62716344!75661140!26170224!95986337!46652875!41788906!%
72282471!75672579!}%
\@namedef{CALX_Lt1}{-10000!49996666!91664666!83331904!88689365!17935598!%
92892448!73387056!78355083!92592828!09226600!52787111!39025335!33724468!%
86197936!79034935!}%
\@namedef{CALX_Lt2}{-19999!99973337!33269343!99817174!85145499!20678205!%
62819400!72553256!29029490!44218709!82064449!60207540!32632732!51802363!%
45109956!45229722!}%
\@namedef{CALX_Lt3}{-29996!49910020!24514121!46876534!19207331!86144404!%
35952224!33105306!98330115!73603145!32634782!28501332!85217791!59380648!%
57100042!13598957!}%
\@namedef{CALX_Lt4}{-39993!99786730!64619349!09935808!13595613!13473314!%
01869933!53050282!04084771!51941425!25845158!18893465!23422240!47924899!%
96560621!55117039!}%
\@namedef{CALX_Lt5}{-49988!49583489!52085936!38441663!57622944!20813660!%
64490956!56636496!32843130!66049255!79484709!80480630!25677973!80057849!%
74594269!12906045!}%
\@namedef{CALX_Lt6}{-59983!99280323!84455772!00301268!65746178!40078376!%
80628846!84751742!45454019!29060322!28105253!52043912!23177756!56808678!%
90567499!01260551!}%
\@namedef{CALX_Lt7}{-69976!48857266!58072263!07563485!36721782!95151642!%
71789357!64401950!29442757!12716047!18127425!03588078!72079745!05686339!%
06763254!11903431!}%
\@namedef{CALX_Lt8}{-79969!98294356!67840994!06164233!19344403!27775433!%
67332262!78044032!71866120!84302271!93521852!68433462!65442111!50513758!%
00644738!66374208!}%
\@namedef{CALX_Lt9}{-89960!47571639!06990505!22563681!79397678!61678609!%
14785573!89058515!04544752!32860889!30026124!56112318!12228250!66734017!%
23744085!96255333!}%
\@namedef{CALX_Lt10}{-99951!96669164!66833190!60107946!49885392!44937606!%
83344800!29803331!71099675!04234128!04457037!45237799!08784886!77399401!%
06884834!71710048!}%
\@namedef{CALX_Lt11}{-109940!45566990!36526315!37952972!33201012!88367961!%
55231107!66831213!98626425!16076951!54934399!87837279!99008250!31828564!%
48505676!77978257!}%
\@namedef{CALX_Lt12}{-119929!94245179!02833152!65393300!09994936!99662609!%
35541346!67246993!16084659!30586238!17625399!08670664!48334765!16993109!%
27476628!31799982!}%
\@namedef{CALX_Lt13}{-129916!42683799!49884239!44443411!95471288!84750149!%
62632654!13955571!03723744!24673011!91038707!37169063!71947950!53040121!%
67956078!34801201!}%
\@namedef{CALX_Lt14}{-139903!90862926!58938751!93524353!70049563!84724859!%
49107635!76711920!35795780!73300475!57703933!60206736!64116859!07354448!%
34347635!54230720!}%
\@namedef{CALX_Lt15}{-149888!38762641!08145999!85113326!98120033!63016511!%
11532240!36085017!42950813!78893940!74839087!02268117!35860333!84593890!%
06887819!87858673!}%
\@namedef{CALX_Lt16}{-159873!86363029!72307039!90218936!36364538!06014376!%
54570538!15479114!41359387!81013177!25507806!63475913!87503673!48505304!%
73988746!70914897!}%
\@namedef{CALX_Lt17}{-169856!33644185!22636408!22549764!22164648!71798553!%
76475742!17089830!02223062!35802389!40008231!12843404!17016878!55342843!%
29393376!47412684!}%
\@namedef{CALX_Lt18}{-179839!80586206!26523971!75248930!23335387!43841630!%
02516420!82650467!34722411!92804023!41673063!24512562!81773799!05996591!%
54509168!53965160!}%
\@namedef{CALX_Lt19}{-189820!27169197!47296898!43072272!23162562!93919172!%
62058119!84542262!98164765!17209867!52040846!50742726!98308994!76164240!%
30423982!94334152!}%
\@namedef{CALX_Lt20}{-199801!73373269!43981746!22892761!09842829!91171092!%
32262238!49246129!77472319!36422281!00206583!70652821!86077681!79639063!%
62673820!82768388!}%
\@namedef{CALX_Lt21}{-209780!19178538!71066670!85418734!37284902!97423365!%
75157183!10554312!57479236!48032926!42556105!93134992!07273055!45917480!%
05098666!56016255!}%
\@namedef{CALX_Lt22}{-219759!64565127!78263752!11018501!25184741!11778389!%
94901647!99057663!32137531!16643451!48281921!48993308!20984406!94937801!%
04328859!80472034!}%
\@namedef{CALX_Lt23}{-229736!09513165!10271438!82548835!70693369!22622945!%
19049793!64519333!52195293!54503449!81560618!62179534!83457165!27473198!%
22642553!41858359!}%
\@namedef{CALX_Lt24}{-239713!54002785!06537112!28089834!52209378!87403671!%
31740078!54034261!26937308!70135399!56281129!03423515!78865719!92665932!%
10217602!74161500!}%
\@namedef{CALX_Lt25}{-249689!98014128!01019768!06493573!18204752!65925038!%
27465521!87394076!82375555!71009552!44225694!29566093!18140644!77293337!%
74303770!97685651!}%
\@namedef{CALX_Lt26}{-259663!41527340!21952816!28658944!70887831!77974707!%
54889012!75507527!19212743!90871221!39672853!34241857!61324827!36228999!%
59115353!70360246!}%
\@namedef{CALX_Lt27}{-269637!84522573!91607000!07450014!76275987!96437930!%
93207995!91845274!81956190!86942325!55608966!56007042!64869844!79847083!%
55565953!85721105!}%
\@namedef{CALX_Lt28}{-279609!26979987!26053432!29180170!59247506!76487450!%
91450081!84426527!19606664!59005920!97898548!02251108!23143167!80991459!%
41526473!05080183!}%
\@namedef{CALX_Lt29}{-289581!68879744!34926750!39589281!74721624!50620150!%
43855866!32752421!88942232!95154733!17513125!29368812!67341631!40273085!%
01085879!14832669!}%
\@namedef{CALX_Lt30}{-299551!10202015!21188389!37246026!84631517!54663970!%
11961129!07092679!61225138!96569868!24365567!87428658!17849711!12105237!%
86726325!77972644!}%
\@namedef{CALX_Lt31}{-309521!50926975!80889972!67312473!15160898!72260074!%
34656099!25035119!01377923!83147303!95062810!29786787!35005877!61263413!%
42990583!66249130!}%
\@namedef{CALX_Lt32}{-319490!91034808!02936821!08612924!20163958!28744014!%
77544215!93692867!19355331!63458808!98577066!65740611!66720013!88239120!%
16250985!25049374!}%
\@namedef{CALX_Lt33}{-329457!30505699!68851579!46953975!35133569!55606166!%
39651581!38752784!53299115!84840226!50521533!34981810!25260711!82717202!%
34380636!12754302!}%
\@namedef{CALX_Lt34}{-339424!69319844!52537961!27647637!71876485!39998518!%
01828467!40264966!08249805!50253992!00201937!72543394!01850463!80505907!%
36966577!64279468!}%
\@namedef{CALX_Lt35}{-349389!07457442!20044610!80194307!77548851!95210130!%
08845564!09026825!22986587!12854729!14342175!31437003!90542724!96472676!%
34316637!13724139!}%
\@namedef{CALX_Lt36}{-359354!44898698!29329083!08087272!63252580!70248455!%
38870530!34855349!03361117!92741830!21268999!39716791!69638411!54524904!%
42513819!43883153!}%
\@namedef{CALX_Lt37}{-369318!81623824!30021941!36705349!97344419!38143979!%
94947068!42503080!03784511!26707026!93788376!39105776!04421329!46348061!%
62906318!68548974!}%
\@namedef{CALX_Lt38}{-379280!17613037!63190972!12265166!57316065!26176947!%
25633904!95642949!93152987!42815451!16688577!41700638!96012381!28375522!%
06458145!24615761!}%
\@namedef{CALX_Lt39}{-389242!52846561!61105517!44809480!41916141!62442395!%
07511819!75782869!22551963!10567998!31707588!77585140!03825540!21223288!%
75681474!59559001!}%
\@namedef{CALX_Lt40}{-399203!87304625!47000924!88212848!62453729!58581582!%
07048422!29302064!81489177!81446227!44068022!53961987!05532439!58809660!%
98603333!92113591!}%
\@namedef{CALX_Lt41}{-409162!20967464!34843114!50190836!59298484!73973286!%
01872581!68651518!24002944!55920514!24365338!88936029!99246003!21604407!%
68473566!07924725!}%
\@namedef{CALX_Lt42}{-419121!53815319!29093263!25303853!26823893!95589652!%
21851341!81002329!35262250!98017779!16171579!72444973!87207269!98306304!%
05564628!79252793!}%
\@namedef{CALX_Lt43}{-429079!85828437!24472606!43951582!77777316!79189977!%
02118350!82327226!70564200!99394588!89554521!07382550!17631048!69463294!%
18368409!42474018!}%
\@namedef{CALX_Lt44}{-439035!16987071!05727356!30358864!36652135!04524022!%
99161719!64561778!58544605!29803339!00239343!15774540!83255901!11209751!%
32315281!92450127!}%
\@namedef{CALX_Lt45}{-448991!47271479!47393737!62558750!21432282!24671683!%
55017168!26205022!60973109!09195611!47762208!03717483!71754379!09553403!%
52657963!71596095!}%
\@namedef{CALX_Lt46}{-458946!76661927!13563140!27383344!54425974!52490782!%
31232480!93982417!03252976!19268258!90505856!15489698!98579324!82352236!%
31179598!61420896!}%
\@namedef{CALX_Lt47}{-468899!05138684!57647388!63477897!36151600!68321748!%
55795930!27751604!35002193!64102071!64225208!42851546!25787363!78859452!%
41035494!48753980!}%
\@namedef{CALX_Lt48}{-478852!32682028!22144127!85358492!21732091!61517489!%
91002348!10455491!78203158!49112000!94872990!95852652!77210463!80838905!%
64167844!55863977!}%
\@namedef{CALX_Lt49}{-488804!59272240!38402326!81538529!57341970!46821567!%
13507223!36151916!74614307!37763687!86270870!62475558!86104662!32994524!%
90295001!04872996!}%
\@namedef{CALX_Lt50}{-498755!84889609!26387897!79754065!65280632!79650573!%
15641731!48573470!15776042!57770381!25653277!94540857!71090400!48287745!%
25303061!14936045!}%
\@namedef{CALX_Lt51}{-508704!09514428!94449432!72322921!10562822!66063535!%
09160159!80806124!95011244!67561603!58330282!52236663!66886243!60758057!%
34584392!89869079!}%
\@namedef{CALX_Lt52}{-518653!33126999!39084055!94677324!39869013!75089511!%
11857136!36988901!33870994!62760910!69151294!06741456!64758648!59601462!%
14679418!50776616!}%
\@namedef{CALX_Lt53}{-528601!55707626!44703393!50114701!55630387!19685687!%
25578800!50557057!84966278!63124313!10680693!03734537!64349642!05982279!%
30648903!08123941!}%
\@namedef{CALX_Lt54}{-538548!77236621!83399658!73816066!74280888!77235342!%
34574062!21163218!02468950!41180663!31099444!29434884!04927355!94369713!%
88291708!01700580!}%
\@namedef{CALX_Lt55}{-548494!97694303!14711854!29186307!18637673!00905796!%
05120648!85591135!65689110!33838396!13883670!11187767!42048708!27778611!%
96916115!97918011!}%
\@namedef{CALX_Lt56}{-558438!17060993!85392090!29575491!10315982!27121117!%
75627123!32229002!57345994!67337600!37438820!97353639!89732423!10768246!%
94203830!48452284!}%
\@namedef{CALX_Lu-5100}{5100!13005442!18691369!25798304!28407466!59720605!%
10398581!56934406!17114698!24490037!55735647!44712033!71107581!74606828!%
42495774!03161169!}%
\@namedef{CALX_Lu-5000}{5000!12500416!68229229!16927094!49453592!19999845!%
43399175!65250398!69664800!24170272!64816892!16689712!88251109!15433720!%
20118585!39054382!}%
\@namedef{CALX_Lu-4900}{4900!12005392!17774590!08069011!14266647!04264023!%
91935611!52798808!92577480!46329302!64567924!69821812!55322584!78819228!%
31016520!54460521!}%
\@namedef{CALX_Lu-4800}{4800!11520368!65327154!96283211!56144285!99206763!%
26830753!97377255!68364003!60275346!21940715!38801320!23555248!27910085!%
32245936!15615617!}%
\@namedef{CALX_Lu-4700}{4700!11045346!08886632!78746467!49325413!63233429!%
65534594!93823434!55221984!30613136!78957246!00330863!11352129!50210663!%
76238381!81495733!}%
\@namedef{CALX_Lu-4600}{4600!10580324!46452738!52750764!50781713!70570236!%
45347529!38165156!43056153!52260319!40132188!77839342!29081784!10940776!%
52291025!83258240!}%
\@namedef{CALX_Lu-4500}{4500!10125303!76025193!15700901!43209524!21181431!%
70889180!37999502!19370650!32023574!07515510!78085486!84107389!08505702!%
73192509!58049490!}%
\@namedef{CALX_Lu-4400}{4400!09680283!95603723!65112089!79222050!96255123!%
85388018!15268998!32620598!83327874!63012880!40830224!86750471!65976122!%
32725744!92362713!}%
\@namedef{CALX_Lu-4300}{4300!09245265!03188062!98607553!26741912!39023342!%
04911116!15374049!42521427!11789287!39007805!34524165!79011600!41564381!%
17333285!15867599!}%
\@namedef{CALX_Lu-4200}{4200!08820246!96777950!13916127!15594008!40686969!%
40163798!05880025!55877122!36450432!45324797!86788830!57268502!01695196!%
54326298!93127479!}%
\@namedef{CALX_Lu-4100}{4100!08405229!74373130!08869857!85298706!11221229!%
11965688!69414066!19090823!91316685!40189646!14934408!45527875!43505135!%
61020102!77290190!}%
\@namedef{CALX_Lu-4000}{4000!08000213!33973353!81401602!34065335!14842445!%
43952825!99134192!14339716!63045344!62697413!12872087!76876188!80017098!%
02844059!09060423!}%
\@namedef{CALX_Lu-3900}{3900!07605197!73578378!29542627!68985985!49921842!%
89465056!21788771!48335804!62130552!76032495!29963406!65673176!29466153!%
80492490!81642636!}%
\@namedef{CALX_Lu-3800}{3800!07220182!91187966!51420210!57429600!53137189!%
18953957!33228517!56725220!66002179!38588023!12925201!77999426!78250648!%
03013617!50873644!}%
\@namedef{CALX_Lu-3700}{3700!06845168!84801887!45255236!79636358!07658128!%
59589051!64610456!02674764!15847952!54226203!05042739!72238271!06509561!%
23268773!76469883!}%
\@namedef{CALX_Lu-3600}{3600!06480155!52419916!09359800!82512332!35166094!%
40049115!34731825!97268889!87190475!23249344!12337821!91750931!15860093!%
10956595!32393798!}%
\@namedef{CALX_Lu-3500}{3500!06125142!92041833!42134805!34624429!51514730!%
50761005!15203518!67183390!99957571!02195407!01826201!26781641!33714984!%
49038022!22031007!}%
\@namedef{CALX_Lu-3400}{3400!05780131!01667426!42067560!82395589!65841793!%
83090637!70732940!19815969!24732638!30904611!07455141!15106431!50232686!%
02420995!60873763!}%
\@namedef{CALX_Lu-3300}{3300!05445119!79296488!07729385!07500248!02948550!%
60199611!66814345!48589117!21124756!49758220!52067555!22667238!01374295!%
45785201!63497418!}%
\@namedef{CALX_Lu-3200}{3200!05120109!22928817!37773202!85460048!28767721!%
17456491!91763659!25230539!16188168!91838508!46007499!27138146!97770645!%
21360743!53179630!}%
\@namedef{CALX_Lu-3100}{3100!04805099!30564219!30931145!45439800!58746069!%
31434016!49391201!27931443!93892739!80596078!35782321!32357363!67113310!%
96898417!73214943!}%
\@namedef{CALX_Lu-3000}{3000!04500090!00202504!86012150!31243677!28972773!%
33632475!72749894!23485700!22709856!66881480!12899213!13488406!13335896!%
91799216!14250705!}%
\@namedef{CALX_Lu-2900}{2900!04205081!29843491!01899560!63511639!09889757!%
78145286!18362474!49510363!90283205!57523571!43019398!71795160!44134752!%
73545288!06043005!}%
\@namedef{CALX_Lu-2800}{2800!03920073!17487000!77548725!03116084!42425205!%
61525375!54116671!83845944!91424852!02369622!04013198!26845952!71220029!%
25976371!56437759!}%
\@namedef{CALX_Lu-2700}{2700!03645065!61132863!11984597!15758714!76396512!%
18120444!82583692!98889224!79215866!60891219!52522232!48956286!67471771!%
79771311!88959262!}%
\@namedef{CALX_Lu-2600}{2600!03380058!58780913!04299335!37767608!91033983!%
35121517!74787756!77961616!15379452!88195574!13609938!41849842!78872751!%
08269315!84187312!}%
\@namedef{CALX_Lu-2500}{2500!03125052!08430991!53649902!43094498!77481621!%
48512459!57321705!00215678!52118758!85172012!57418254!94765583!60516679!%
75773780!18804078!}%
\@namedef{CALX_Lu-2400}{2400!02880046!08082945!59255665!11512239!63136383!%
94018386!28018372!83630904!65627014!14849142!96608763!01514875!55046599!%
78136175!09018992!}%
\@namedef{CALX_Lu-2300}{2300!02645040!55736628!20395993!98012467!57692339!%
96028125!01965666!78123124!46243341!57084582!78696571!99926184!99281518!%
30772861!42331849!}%
\@namedef{CALX_Lu-2200}{2200!02420035!49391898!36407863!03403437!00761192!%
82310165!40275087!90572331!67828420!56186460!55227354!51782951!50055804!%
18433831!49814072!}%
\@namedef{CALX_Lu-2100}{2100!02205030!87048621!06683449!46108030!90945675!%
13152894!18422377!10580286!08415852!15074848!90583691!59983652!76791134!%
55793632!34295911!}%
\@namedef{CALX_Lu-2000}{2000!02000026!66706667!30667733!35161936!76247366!%
10338369!78882371!81886372!52534463!48747004!32211487!87821185!13646769!%
87618367!33073605!}%
\@namedef{CALX_Lu-1900}{1900!01805022!86365914!07856097!44411980!85695520!%
64104504!13849077!43376804!26630485!96428492!67696578!99041631!96610589!%
52699877!87750779!}%
\@namedef{CALX_Lu-1800}{1800!01620019!44026244!37791926!87914613!82088540!%
84963313!67701101!21119941!16952594!36785112!49550642!33422745!03169251!%
30066109!95253189!}%
\@namedef{CALX_Lu-1700}{1700!01445016!37687547!20064208!96534540!15744761!%
51922915!65140404!66201373!37386546!78616220!52863463!76675113!16995365!%
76367149!19791869!}%
\@namedef{CALX_Lu-1600}{1600!01280013!65349717!54305132!95743484!59164261!%
89308215!89160938!21346479!79953071!11910241!63453639!05225037!35039224!%
07482944!70844425!}%
\@namedef{CALX_Lu-1500}{1500!01125011!25012656!40187689!84619088!02508456!%
80989796!82718969!63040110!44540981!05124403!61825214!88813416!44745393!%
82260468!94352242!}%
\@namedef{CALX_Lu-1400}{1400!00980009!14676270!77423272!16043925!89809261!%
03412405!58668349!27248667!11143850!18443032!66271178!81479808!96572838!%
98580625!23435671!}%
\@namedef{CALX_Lu-1300}{1300!00845007!32340473!65759273!78104641!75824661!%
27363698!03644819!69541978!60046932!49542078!12713098!06232700!12115854!%
75292272!98446152!}%
\@namedef{CALX_Lu-1200}{1200!00720005!76005184!04976689!76691188!83462571!%
02940551!82550728!19406221!08230462!80890497!66168543!51401551!03668884!%
35252219!96257744!}%
\@namedef{CALX_Lu-1100}{1100!00605004!43670326!94887716!19296172!41699884!%
02654356!20485797!90147331!24409157!23097982!20809623!04323624!43844477!%
16648444!23272745!}%
\@namedef{CALX_Lu-1000}{1000!00500003!33335833!35333350!00014285!83928682!%
54068254!87735321!07551344!69426136!14863667!43769358!61920829!41735142!%
47258641!56167620!}%
\@namedef{CALX_Lu-900}{900!00405002!43001640!26180988!85741832!86666597!%
45778396!70072328!51094132!62860712!63208696!37504185!02204651!13277243!%
70100975!90861354!}%
\@namedef{CALX_Lu-800}{800!00320001!70667690!67322031!03576329!28573357!%
38937874!00426739!50757702!64859456!60770107!39250061!32305467!74089803!%
79928646!30476955!}%
\@namedef{CALX_Lu-700}{700!00245001!14333933!58669475!29416176!49720604!%
60876235!88157692!41195527!88005344!09792970!04330774!69805874!96785490!%
31043273!65311981!}%
\@namedef{CALX_Lu-600}{600!00180000!72000324!00155520!77760399!91067095!%
97689290!37934388!74802130!07696533!57742775!23200471!92750667!51656847!%
11965418!00327297!}%
\@namedef{CALX_Lu-500}{500!00125000!41666822!91729166!92708444!94096447!%
38963391!30748754!48736199!37506307!64384094!61516092!79383865!19079005!%
38658963!55571249!}%
\@namedef{CALX_Lu-400}{400!00080000!21333397!33353813!40160023!40579620!%
60055578!73976638!41444282!54174886!12344131!15533192!08108349!51944831!%
64112451!28337321!}%
\@namedef{CALX_Lu-300}{300!00045000!09000020!25004860!01215003!12429391!%
55575843!44763446!75745585!57393927!37095315!21565352!73392677!48173349!%
90866655!62230970!}%
\@namedef{CALX_Lu-200}{200!00020000!02666670!66667306!66773333!51619079!%
61910450!80389081!22690096!02371817!81044648!33000077!80369192!81924379!%
55038641!17400254!}%
\@namedef{CALX_Lu-100}{100!00005000!00333333!58333353!33335000!00142857!%
26785725!39683539!68344877!42821075!51338265!62393229!05572905!20525781!%
96366122!06008490!}%
\@namedef{CALX_Lu100}{-100!00004999!99666666!91666646!66668333!33190476!%
31547607!93651793!64988456!07178924!48663162!94749628!21212809!08046757!%
71887846!29388334!}%
\@namedef{CALX_Lu200}{-200!00019999!97333337!33332693!33439999!81714317!%
71422882!54992252!10643919!97628182!42361065!95579542!76773667!23632445!%
84748756!10853752!}%
\@namedef{CALX_Lu300}{-300!00044999!91000020!24995140!01214996!87572248!%
69424157!73334553!24342987!92606140!95717541!98101201!67683055!76179510!%
72097498!76625740!}%
\@namedef{CALX_Lu400}{-400!00079999!78666730!66646186!73493309!92770096!%
73277775!56508694!94685253!45828948!66878731!35623434!21226628!79350236!%
12447153!31274181!}%
\@namedef{CALX_Lu500}{-500!00124999!58333489!58270833!59374888!39334542!%
19370137!33834579!25287238!12580885!43651810!40541664!32644517!12663187!%
44187855!37099000!}%
\@namedef{CALX_Lu600}{-600!00179999!28000323!99844480!77759600!09352808!%
02311918!94417614!87994925!93422954!48112179!72680828!49979009!78810739!%
89195702!34902476!}%
\@namedef{CALX_Lu700}{-700!00244998!85667266!91330528!62747156!85053928!%
97462746!95673663!99019005!71683556!94318571!11990606!36178547!05727887!%
10184475!83515116!}%
\@namedef{CALX_Lu800}{-800!00319998!29334357!32677977!70237004!08954279!%
94416934!16554708!35821753!97969779!26873164!89983629!41963696!76274240!%
55717926!48548661!}%
\@namedef{CALX_Lu900}{-900!00404997!57001640!23819028!85728167!24095082!%
79291338!98730142!20495284!13950608!17623293!14690400!85608294!24363930!%
53687960!24069961!}%
\@namedef{CALX_Lu1000}{-1000!00499996!66669166!64666683!33319047!74404650!%
79465078!45599678!92448669!59145292!54779189!70627466!77762710!26518834!%
87229093!00939162!}%
\@namedef{CALX_Lu1100}{-1100!00604995!56336993!55112342!85907161!45223169!%
56197725!62054766!14582176!50588465!96112037!27040379!95793334!20494497!%
64999246!34306910!}%
\@namedef{CALX_Lu1200}{-1200!00719994!24005183!95023409!76588812!24032852!%
98297795!45912131!97335338!33461890!20020540!27240585!20011701!97169779!%
28234970!32780817!}%
\@namedef{CALX_Lu1300}{-1300!00844992!67673806!84240887!11258693!61441352!%
33726805!13425343!77978997!38187157!24070112!04822284!42431479!28154485!%
58258161!95336837!}%
\@namedef{CALX_Lu1400}{-1400!00979990!85342937!22576978!82409411!12471336!%
35706020!84711473!91482136!31810827!86878640!07331196!99475059!61818465!%
08874389!12864819!}%
\@namedef{CALX_Lu1500}{-1500!01124988!75012656!09812689!84130918!38214199!%
55543210!98747274!26612497!47259463!77707471!23639179!30579781!13152016!%
45166198!28245213!}%
\@namedef{CALX_Lu1600}{-1600!01279986!34683050!45695426!28309859!47910895!%
66015350!00193520!08115590!14247701!29285570!03519128!62558691!47693580!%
50569664!47267542!}%
\@namedef{CALX_Lu1700}{-1700!01444983!62354213!29936595!62028810!61527932!%
46730295!70061965!73360974!10136338!63486496!82345750!16902240!48983959!%
44618228!09355174!}%
\@namedef{CALX_Lu1800}{-1800!01619980!56026243!62209206!86165413!72901603!%
86446030!87474951!09171299!59728667!64091659!10839664!70370352!13484619!%
04875984!35168384!}%
\@namedef{CALX_Lu1900}{-1900!01804977!13699246!42145470!75191394!93528574!%
16850154!38775114!09915033!04598589!32654296!83226402!12181421!35158539!%
90196824!05012387!}%
\@namedef{CALX_Lu2000}{-2000!01999973!33373332!69334399!98171460!57085969!%
27794963!61277628!18347684!61759442!79824715!52042490!86151640!64165806!%
18397338!62071812!}%
\@namedef{CALX_Lu2100}{-2100!02204969!13048619!43319409!40962063!64769168!%
45444725!50239335!41780904!54923765!79618654!55448198!20428751!58990711!%
74808263!64931610!}%
\@namedef{CALX_Lu2200}{-2200!02419964!50725229!63595916!29610033!51540529!%
82221623!97331249!82158035!93258190!32177011!29387843!84659190!03379759!%
26587616!69415317!}%
\@namedef{CALX_Lu2300}{-2300!02644959!44403292!29608940!54951061!53387321!%
90835432!95190040!62203048!51326726!77094337!35918358!89589274!86426591!%
11865202!23363042!}%
\@namedef{CALX_Lu2400}{-2400!02879953!92082942!40750704!98408035!55692172!%
74049233!63600872!92050294!21998280!00470150!16783845!75625729!92352206!%
25302480!93069732!}%
\@namedef{CALX_Lu2500}{-2500!03124947!91764320!96358235!58989216!02824387!%
17169507!56602703!01004602!26523981!46193747!06699515!49685036!60853203!%
40794443!56468997!}%
\@namedef{CALX_Lu2600}{-2600!03379941!41447574!95710961!81486246!49065522!%
21553730!24345837!74867790!52355615!70427181!25354289!84769471!23326555!%
29919859!70734334!}%
\@namedef{CALX_Lu2700}{-2700!03644934!39132857!38028316!85871991!30987649!%
24702199!56872032!66241912!87945676!20460910!50247010!56742353!93489901!%
32600800!99066830!}%
\@namedef{CALX_Lu2800}{-2800!03919926!82820327!22467337!97898193!41407770!%
95743295!57095103!57031236!79358506!41108059!12159264!00159200!97650196!%
19490506!02949955!}%
\@namedef{CALX_Lu2900}{-2900!04204918!70510149!48120266!80892944!85046899!%
94332719!05064164!60576128!58213439!11212132!75446839!35423754!86989764!%
58475290!77178382!}%
\@namedef{CALX_Lu3000}{-3000!04499910!00202495!14012149!68757962!96027344!%
76167533!12985106!44842428!39813840!60334701!36707083!28058303!83310134!%
54385120!54991741!}%
\@namedef{CALX_Lu3100}{-3100!04804900!69897541!19098438!00165664!97346788!%
19465069!58315439!44961697!54068568!08537486!60993470!47769671!06547933!%
29093061!06386046!}%
\@namedef{CALX_Lu3200}{-3200!05119890!77595470!62262588!53956033!82472781!%
33874997!48353516!77899902!80600708!17518124!08497183!21612910!38713776!%
25802475!87611100!}%
\@namedef{CALX_Lu3300}{-3300!05444880!21296472!42313663!85733267!99206315!%
96380121!41899515!36384331!07654353!15219054!45857176!51302881!07057038!%
14649415!01349552!}%
\@namedef{CALX_Lu3400}{-3400!05779868!99000741!57983932!65662208!15968176!%
37797816!59520203!23134537!20119536!12697617!60110549!28783560!68419162!%
14778284!28135322!}%
\@namedef{CALX_Lu3500}{-3500!06124857!08708479!07926470!17464533!50666810!%
78519454!81414000!66953636!04420424!67084829!96643924!98751382!51122185!%
47507912!03822940!}%
\@namedef{CALX_Lu3600}{-3600!06479844!48419891!90712758!58614720!42311500!%
83119764!88522413!33611386!33218724!43095557!56523058!40815957!73658194!%
95839217!81101975!}%
\@namedef{CALX_Lu3700}{-3700!06844831!16135193!04830287!41735756!45539646!%
70431839!76007566!58101778!88299636!56867695!66743361!87136227!88405207!%
79249927!19437550!}%
\@namedef{CALX_Lu3800}{-3800!07219817!09854601!48680153!97194602!28232023!%
78616486!86116015!29239577!68385790!31863649!12777708!30064790!19970247!%
08389847!16809843!}%
\@namedef{CALX_Lu3900}{-3900!07604802!27578342!20574663!76897394!52394905!%
43656853!97342681!38070651!62087238!33491702!82495219!19223915!72542626!%
67955122!52670513!}%
\@namedef{CALX_Lu4000}{-4000!07999786!67306646!18734930!99284382!18492985!%
04580786!96225846!20452517!30968425!27943275!41805568!20753069!09654435!%
30386890!45392240!}%
\@namedef{CALX_Lu4100}{-4100!08404770!27039750!41288478!95524589!53422068!%
99554223!74538488!60401225!40179185!11015801!61032838!73090375!77930823!%
69404791!40010380!}%
\@namedef{CALX_Lu4200}{-4200!08819753!04777897!86266840!56910198!22315550!%
63799137!65550528!10029455!98791415!13775989!89995073!35513666!92369499!%
02766319!91765737!}%
\@namedef{CALX_Lu4300}{-4300!09244734!98521337!51603158!83450641!44383713!%
83069148!85842051!56292372!62150376!53939666!71391270!64641336!01882048!%
36127549!82539067!}%
\@namedef{CALX_Lu4400}{-4400!09679716!06270324!35129787!33666402!92989952!%
95164961!11234441!92927988!09885350!17176393!90993126!72171505!68976160!%
71089589!03653678!}%
\@namedef{CALX_Lu4500}{-4500!10124696!26025119!34575890!75582513!60173034!%
66690289!14123288!82882850!91425845!57613290!34930439!47922907!23687734!%
31313934!93716835!}%
\@namedef{CALX_Lu4600}{-4600!10579675!55785989!47565045!38921738!65829565!%
02936955!52156570!83344510!03615240!72605519!62417973!42989480!09245986!%
65186531!94307151!}%
\@namedef{CALX_Lu4700}{-4700!11044653!93553207!71612839!68497447!91775863!%
75445391!52080113!69586772!58995595!15309567!10384865!29564302!29392566!%
17285682!79245575!}%
\@namedef{CALX_Lu4800}{-4800!11519631!37327053!04124474!78806162!20913485!%
74413910!04909733!48530811!36967630!30797771!18840195!65301077!66411119!%
24144835!06751482!}%
\@namedef{CALX_Lu4900}{-4900!12004607!85107810!42392365!09819768!61727668!%
11726867!06589482!47520754!62444668!82130496!06093773!02782405!36002709!%
27427772!04172801!}%
\@namedef{CALX_Lu5000}{-5000!12499583!34895770!83593738!83977397!38353019!%
14938226!69125473!23415747!63601812!14807063!30238573!94514879!55879584!%
18153093!93366937!}%
\@namedef{CALX_Lu5100}{-5100!13004557!84691231!24788238!64376953!26445803!%
63083131!17976037!02539314!37766571!58799779!64229096!20416974!57931196!%
01965236!41122723!}%
\@namedef{CALX_Lv-51}{51!00001300!50044217!01691300!94005079!52715915!%
51582617!24236246!74584275!16289244!82079549!59005935!53687449!52795747!%
43134993!57035449!}%
\@namedef{CALX_Lv-50}{50!00001250!00041666!68229167!29166692!70834449!%
40525018!62289187!48449945!18287568!41668124!67070556!26326351!57654522!%
85062621!35452203!}%
\@namedef{CALX_Lv-49}{49!00001200!50039216!34774534!14828406!20215502!%
39051948!18130549!36504573!95256679!16117477!45773743!77310202!70029491!%
09030805!22823594!}%
\@namedef{CALX_Lv-48}{48!00001152!00036864!01327104!50960813!98432582!%
66941262!97270813!31975293!86806511!10085234!75874526!56337476!10633064!%
88536624!88754870!}%
\@namedef{CALX_Lv-47}{47!00001104!50034607!67886587!37535686!03203278!%
58094592!16838103!71634382!78937949!35748025!75571656!99618109!51095304!%
65336283!41559047!}%
\@namedef{CALX_Lv-46}{46!00001058!00032445!34452697!74525944!32383438!%
59690376!09696505!30336374!61919476!39996745!79058995!13816407!88155796!%
75797285!43505587!}%
\@namedef{CALX_Lv-45}{45!00001012!50030375!01025156!61905638!83961471!%
31371465!34371727!59218053!56010982!37017590!91562318!30152274!40690050!%
25505980!66759942!}%
\@namedef{CALX_Lv-44}{44!00000968!00028394!67603690!99649923!56052765!%
44466559!90544716!22063507!18244630!42893156!83349332!01728687!97942495!%
31578629!11645079!}%
\@namedef{CALX_Lv-43}{43!00000924!50026502!34188033!87735032!46894229!%
81244768!39878850!86231457!44395216!57940801!77968146!73983086!66475989!%
28265000!52894989!}%
\@namedef{CALX_Lv-42}{42!00000882!00024696!00777924!26138255!54838953!%
34202567!31951409!26396812!64321052!67034482!82467509!64147094!47613915!%
19565105!95521612!}%
\@namedef{CALX_Lv-41}{41!00000840!50022973!67373107!14837914!78350985!%
05382440!35065017!01172786!96393912!95056611!48268841!16541085!77784625!%
04883859!52522283!}%
\@namedef{CALX_Lv-40}{40!00000800!00021333!33973333!53813340!16000234!%
05722477!71719842!64454017!78125900!27194541!73160459!85173155!52589625!%
21216035!50991086!}%
\@namedef{CALX_Lv-39}{39!00000760!50019773!00578360!43044845!66457489!%
54436215!58532337!75054874!25705089!41699688!13730779!70284467!08518610!%
87845602!93435417!}%
\@namedef{CALX_Lv-38}{38!00000722!00018290!67187950!82513705!28489560!%
78421995!50391361!69910593!95333373!62004742!93226891!22226279!18480906!%
16330795!89746155!}%
\@namedef{CALX_Lv-37}{37!00000684!50016884!33801873!72202129!00954537!%
11701123!88647570!67762007!24381957!68155970!85626621!26749490!26522224!%
96809909!57018641!}%
\@namedef{CALX_Lv-36}{36!00000648!00015552!00419904!12093238!82797167!%
94884111!53136990!71857412!20805288!63144244!99403412!02278400!11048695!%
41568626!43636578!}%
\@namedef{CALX_Lv-35}{35!00000612!50014291!67041823!02171044!73044362!%
74664273!17844734!41777645!45345774!13062665!24167339!12449500!16904852!%
22932790!59173849!}%
\@namedef{CALX_Lv-34}{34!00000578!00013101!33667417!42420420!70800811!%
03337967!10019861!06022556!93182291!12603777!13488137!65240044!51051033!%
02586098!11390282!}%
\@namedef{CALX_Lv-33}{33!00000544!50011979!00296480!32827080!75244722!%
38350754!72557419!88488939!30188114!07130270!94352704!52309944!06109418!%
02289572!03589190!}%
\@namedef{CALX_Lv-32}{32!00000512!00010922!66928810!73377554!85623686!%
41868760!29468756!23421484!74231374!63675462!57602308!79563420!98414116!%
32689714!18425984!}%
\@namedef{CALX_Lv-31}{31!00000480!50009930!33564213!64059165!01250652!%
80374510!54266200!34829544!34336384!56390897!77089386!58244198!62716575!%
18551577!83972458!}%
\@namedef{CALX_Lv-30}{30!00000450!00009000!00202500!04860001!21500031!%
24286534!41093298!57733347!30389991!44166323!93896623!20059195!87044067!%
17579458!65270786!}%
\@namedef{CALX_Lv-29}{29!00000420!50008129!66843486!95768897!45803911!%
47602002!78436786!79933899!13786474!92781470!74345877!59033394!93435816!%
30300575!65061901!}%
\@namedef{CALX_Lv-28}{28!00000392!00007317!33486997!36775407!73648403!%
27561688!25261545!84291019!95320209!50760188!58049738!56479075!48065392!%
55741038!02675081!}%
\@namedef{CALX_Lv-27}{27!00000364!50006561!00132860!27869782!04570096!%
44336524!89414818!72743905!61120300!43207318!08983942!90442674!03475418!%
55095156!02404114!}%
\@namedef{CALX_Lv-26}{26!00000338!00005858!66780910!69042942!38152640!%
80735048!08151009!54518196!20838523!13810195!65162776!79562370!86311673!%
49391172!20857707!}%
\@namedef{CALX_Lv-25}{25!00000312!50005208!33430989!60286458!74023446!%
21930994!30633423!82132817!85014044!30744119!30195539!60262428!61539695!%
31611220!43847766!}%
\@namedef{CALX_Lv-24}{24!00000288!00004608!00082944!01592525!11850502!%
55210341!02274350!19948825!10908455!82669774!64456100!97078730!86436886!%
10415637!66421357!}%
\@namedef{CALX_Lv-23}{23!00000264!50004055!66736626!92953935!51339319!%
69737066!50779923!31091112!88495492!27957107!78844709!75798052!94056499!%
67757656!72122497!}%
\@namedef{CALX_Lv-22}{22!00000242!00003549!33391897!34364059!92229987!%
56336909!73771247!69622187!61064309!21692177!76482883!82906478!26202750!%
48697368!70441522!}%
\@namedef{CALX_Lv-21}{21!00000220!50003087!00048620!25816820!34294356!%
07298410!27858302!65855188!88416254!25270059!35682906!78312092!76014740!%
30475516!73991849!}%
\@namedef{CALX_Lv-20}{20!00000200!00002666!66706666!67306666!77333335!%
16190508!19048187!93661033!65265546!93168023!71817705!12055274!50843034!%
83970985!08491804!}%
\@namedef{CALX_Lv-19}{19!00000180!50002286!33365913!58828553!21174314!%
77695983!94374310!09551916!03557077!17920313!68966161!30317246!82856156!%
54887174!59033698!}%
\@namedef{CALX_Lv-18}{18!00000162!00001944!00026244!00377913!65668704!%
87460018!34638149!54210436!75352516!80841359!09058593!88060222!55722002!%
36578660!83852421!}%
\@namedef{CALX_Lv-17}{17!00000144!50001637!66687546!91950638!10689595!%
41953152!48160288!07980356!93071994!82501941!23203349!94715318!03395502!%
84261594!96918200!}%
\@namedef{CALX_Lv-16}{16!00000128!00001365!33349717!33543048!56129536!%
38347927!65442416!92641371!76575595!89557503!65232042!96221383!12870931!%
52978830!60513019!}%
\@namedef{CALX_Lv-15}{15!00000112!50001125!00012656!25151875!01898437!%
74408485!34647085!12556380!22189783!05835597!61256357!02309307!59776883!%
41185887!42554243!}%
\@namedef{CALX_Lv-14}{14!00000098!00000914!66676270!66774231!47921589!%
48392407!17806988!29005487!47691401!24557618!42803440!73323442!67486811!%
83800882!48412918!}%
\@namedef{CALX_Lv-13}{13!00000084!50000732!33340473!58407591!94137801!%
58964074!87680637!62206417!39819068!10516997!08048021!68418298!52871573!%
24689173!28865103!}%
\@namedef{CALX_Lv-12}{12!00000072!00000576!00005184!00049766!40497664!%
05118830!25176289!16166132!77451383!57651518!60401042!42289900!44852011!%
98480477!34876409!}%
\@namedef{CALX_Lv-11}{11!00000060!50000443!66670326!91698876!86961926!%
86117215!17271053!22113261!44536370!26792295!72232552!52640074!88211718!%
35678406!53672972!}%
\@namedef{CALX_Lv-10}{10!00000050!00000333!33335833!33353333!33500000!%
01428571!55357143!96825406!82539773!44878178!21075513!37622766!12943279!%
00577894!91612967!}%
\@namedef{CALX_Lv-9}{9!00000040!50000243!00001640!25011809!80088573!50683281!%
33952269!12689581!62964182!91395264!74757700!99260877!36361566!17240504!%
92552408!}%
\@namedef{CALX_Lv-8}{8!00000032!00000170!66667690!66673220!26710357!33632926!%
49716199!76817843!86739269!57411138!50144407!74337587!50309824!92825111!%
85029121!}%
\@namedef{CALX_Lv-7}{7!00000024!50000114!33333933!58336694!73352941!50117649!%
00720600!16983734!39358637!80868099!28188149!36082093!06435330!46817626!%
14583377!}%
\@namedef{CALX_Lv-6}{6!00000018!00000072!00000324!00001555!20007776!00039990!%
85924237!72548315!48903760!78695838!07372564!02071423!83854192!44168900!%
09529023!}%
\@namedef{CALX_Lv-5}{5!00000012!50000041!66666822!91667291!66669270!83344494!%
04810732!88907490!08913070!48089714!30878963!55624631!46865633!03097822!%
29328805!}%
\@namedef{CALX_Lv-4}{4!00000008!00000021!33333397!33333538!13334016!00002340!%
57151049!14314841!39787397!28635268!63158563!14541729!87894130!57885377!%
25360763!}%
\@namedef{CALX_Lv-3}{3!00000004!50000009!00000020!25000048!60000121!50000312!%
42857962!98216472!71434476!32873247!13031299!73823938!93548433!85921628!%
79193916!}%
\@namedef{CALX_Lv-2}{2!00000002!00000002!66666670!66666673!06666677!33333351!%
61904793!90476247!36508038!90793836!97547238!88023718!17694587!97915382!%
44657220!}%
\@namedef{CALX_Lv-1}{1!00000000!50000000!33333333!58333333!53333333!50000000!%
14285714!41071428!68253968!35396825!48773448!85678210!75513375!58480408!%
54707514!}%
\@namedef{CALX_Lv1}{-1!00000000!49999999!66666666!91666666!46666666!83333333!%
19047619!17261904!65079365!17936507!84559884!64321789!24486624!55805305!%
73863913!}%
\@namedef{CALX_Lv2}{-2!00000001!99999997!33333337!33333326!93333343!99999981!%
71428603!42857085!96825499!22539496!35786777!11976281!82307752!59227474!%
69636685!}%
\@namedef{CALX_Lv3}{-3!00000004!49999991!00000020!24999951!40000121!49999687!%
57143677!26783527!28577333!47126752!87057273!76176061!07134847!42649799!%
83329780!}%
\@namedef{CALX_Lv4}{-4!00000007!99999978!66666730!66666461!86667349!33330992!%
76198668!19018491!93755651!24698064!72970972!85458270!50453791!70686056!%
68653006!}%
\@namedef{CALX_Lv5}{-5!00000012!49999958!33333489!58332708!33335937!49988839!%
28620256!69425843!26373387!85243619!43144473!94375377!25065170!54045225!%
58443236!}%
\@namedef{CALX_Lv6}{-6!00000017!99999928!00000323!99998444!80007775!99960009!%
14495666!27451684!63189474!41304165!55424491!97928688!11026392!70120340!%
57780837!}%
\@namedef{CALX_Lv7}{-7!00000024!49999885!66667266!91663305!26686274!83215684!%
34053933!41349599!50469745!32465257!12026384!13918875!82575076!53223915!%
01737822!}%
\@namedef{CALX_Lv8}{-8!00000031!99999829!33334357!33326779!73377023!99700406!%
87811437!56515491!61342428!55922309!36435048!25668695!42048904!21812446!%
15631138!}%
\@namedef{CALX_Lv9}{-9!00000040!49999757!00001640!24988190!20088573!49316718!%
76809411!12310425!34392697!28605205!96831712!50771803!76846285!42218627!%
45339787!}%
\@namedef{CALX_Lv10}{-10!00000049!99999666!66669166!66646666!66833333!%
31904762!02976189!36507946!50793559!88456821!78924486!62520091!01342435!%
40493533!65529900!}%
\@namedef{CALX_Lv11}{-11!00000060!49999556!33336993!58301123!13628593!%
47216118!69652000!36220123!76281883!26546268!32496900!97902424!88014459!%
50330184!36416466!}%
\@namedef{CALX_Lv12}{-12!00000071!99999424!00005183!99950233!60497663!%
94881170!82319134!83833991!06021461!22363341!56340333!59544268!78654970!%
89767703!41289152!}%
\@namedef{CALX_Lv13}{-13!00000084!49999267!66673806!91592408!07471134!%
74369260!49585375!96127191!65212635!02855166!39472391!87206524!87942619!%
21367302!47605054!}%
\@namedef{CALX_Lv14}{-14!00000097!99999085!33342937!33225768!54588255!%
84940929!84473609!04328424!36572927!28870204!75925775!42550852!79021503!%
38640789!77763216!}%
\@namedef{CALX_Lv15}{-15!00000112!49998875!00012656!24848125!01898437!%
25591521!06075571!12444773!07888341!94380646!28392080!89394872!43850430!%
83610271!50144934!}%
\@namedef{CALX_Lv16}{-16!00000127!99998634!66683050!66456951!49462868!%
94985416!41632740!40694160!59083292!64244954!64219734!06718036!92547575!%
62594118!67519117!}%
\@namedef{CALX_Lv17}{-17!00000144!49998362!33354213!58049361!97356260!%
91380198!29112405!50357008!39041428!31802429!16334945!95824434!19376666!%
70799678!18739473!}%
\@namedef{CALX_Lv18}{-18!00000161!99998056!00026243!99622086!45668703!%
12540009!20351994!45796704!18092808!01086693!21179107!47387445!41719661!%
91406638!48009090!}%
\@namedef{CALX_Lv19}{-19!00000180!49997713!66699246!91171446!94507645!%
55637391!84849783!48793679!43027816!39101877!84211543!61120875!71845180!%
54022642!09054946!}%
\@namedef{CALX_Lv20}{-20!00000199!99997333!33373333!32693333!43999998!%
17142889!14285145!39692779!68067786!46991976!28182318!28516154!06308014!%
30314729!22992335!}%
\@namedef{CALX_Lv21}{-21!00000220!49996913!00048620!24183179!94294350!%
92701684!27856537!59178170!87779386!06989653!16214913!05859239!41361524!%
80387285!81183977!}%
\@namedef{CALX_Lv22}{-22!00000241!99996450!66725230!65635940!45563313!%
76996560!78530469!63764265!56827309!13066159!95358741!05409626!63523540!%
67458769!57467250!}%
\@namedef{CALX_Lv23}{-23!00000264!49995944!33403293!57046064!98005976!%
63596462!60299730!27325073!47080571!21900599!59825509!35396696!40127273!%
52404802!03040458!}%
\@namedef{CALX_Lv24}{-24!00000287!99995392!00082943!98407475!51850489!%
44789934!16554193!80177981!65284619!98197471!08220295!53950016!52084253!%
36644473!06587450!}%
\@namedef{CALX_Lv25}{-25!00000312!49994791!66764322!89713542!07356762!%
11402720!49672565!76391250!34647415!01930288!65703430!08170406!55771432!%
27416943!45344365!}%
\@namedef{CALX_Lv26}{-26!00000337!99994141!33447577!30957058!64819284!%
52598807!31948467!79097471!31625486!98571398!78451840!77544348!13826432!%
36375974!30235592!}%
\@namedef{CALX_Lv27}{-27!00000364!49993439!00132860!22130219!24570066!%
55664181!17969301!52667876!65298631!86950407!40517473!72398942!42144406!%
13036655!36008423!}%
\@namedef{CALX_Lv28}{-28!00000391!99992682!66820330!63224593!86981698!%
05772589!58571371!49634706!91352212!49603586!56821598!27977824!45509378!%
81692318!09045812!}%
\@namedef{CALX_Lv29}{-29!00000420!49991870!33510153!54231104!52470528!%
85732581!16499786!79240848!66206904!50243167!93236546!74156141!95329904!%
76085596!20522238!}%
\@namedef{CALX_Lv30}{-30!00000449!99991000!00202499!95140001!21499968!%
75715105!83906701!43447632!69610017!41568676!06110209!61226518!46908201!%
52063441!53687027!}%
\@namedef{CALX_Lv31}{-31!00000480!49990069!66897546!85940837!94583907!%
52960955!01826493!25143045!56393122!09713741!87679720!40234688!31564831!%
12203909!98411402!}%
\@namedef{CALX_Lv32}{-32!00000511!99989077!33595477!26622448!72290254!%
91467321!81771521!12163648!40470502!71193711!76889052!79894746!89740802!%
70400138!40444469!}%
\@namedef{CALX_Lv33}{-33!00000544!49988021!00296480!17172923!55244600!%
61652761!29597140!39574218!66864803!52685587!31170736!57235461!61561472!%
56681723!04059221!}%
\@namedef{CALX_Lv34}{-34!00000577!99986898!67000750!57579584!44133994!%
29999830!71789696!31439531!90963037!18097362!35401448!38060454!78072320!%
50154655!65479837!}%
\@namedef{CALX_Lv35}{-35!00000612!49985708!33708489!47828961!39710845!%
58674689!84336255!22072782!58690740!52304848!18665234!73439599!58591307!%
45696020!04228025!}%
\@namedef{CALX_Lv36}{-36!00000647!99984448!00419903!87906768!42796944!%
05122941!24339873!35454904!67207385!54157985!54287131!72313693!47791313!%
60151235!00203824!}%
\@namedef{CALX_Lv37}{-37!00000684!49983115!67135206!77797879!54287599!%
21640990!64549243!00188494!83435055!16764038!87841335!96530504!14596629!%
53106282!19815915!}%
\@namedef{CALX_Lv38}{-38!00000721!99981709!33854617!17486304!75155900!%
54922207!30976595!75979163!07597755!60891771!22792697!99973532!85444366!%
11703191!65929637!}%
\@namedef{CALX_Lv39}{-39!00000760!49980227!00578360!06955166!06457097!%
45577164!43782782!66225937!91333437!14229737!82609107!35707153!27047005!%
46073642!10904160!}%
\@namedef{CALX_Lv40}{-40!00000799!99978666!67306666!46186673!49333099!%
27627239!61613490!89850835!55207712!68165458!27223019!37112564!12852715!%
35934457!13036138!}%
\@namedef{CALX_Lv41}{-41!00000840!49977026!34039773!35162101!05017095!%
27970855!29575596!84005864!98970276!64093889!13304018!43737372!99032141!%
52730081!46363975!}%
\@namedef{CALX_Lv42}{-42!00000881!99975304!00777923!73861762!74838294!%
65821639!31047695!07763583!60015014!28747994!91572008!98959249!24055027!%
85076707!87577820!}%
\@namedef{CALX_Lv43}{-43!00000924!49973497!67521366!62264988!60226786!%
52117785!43523883!15324840!51595632!54777193!66850091!86508556!84594396!%
47688897!17727767!}%
\@namedef{CALX_Lv44}{-44!00000967!99971605!34270357!00350100!62718519!%
88901893!98694921!65664548!02773215!67258137!81038385!69333967!27792399!%
05702897!29949007!}%
\@namedef{CALX_Lv45}{-45!00001012!49969625!01025155!88094388!83960403!%
68670572!46975929!33883204!27193291!83855000!65705817!20131670!32560562!%
81181014!85062048!}%
\@namedef{CALX_Lv46}{-46!00001057!99967554!67786030!25474087!25715526!%
73693076!26694812!87838453!67970668!17172710!16193527!00956846!46660178!%
05456045!20327156!}%
\@namedef{CALX_Lv47}{-47!00001104!49965392!34553253!12464349!89868497!%
75298269!38160670!91897215!01563330!30057155!86191387!73507200!51741047!%
02642369!19799611!}%
\@namedef{CALX_Lv48}{-48!00001151!99963136!01327103!49039226!78430905!%
33129185!22836451!97874830!34904986!82153262!10338249!98659757!64139573!%
00175501!10192738!}%
\@namedef{CALX_Lv49}{-49!00001200!49960783!68107866!35171639!93546897!%
94364467!47845185!81413291!97602247!39268156!88533225!96325278!15455979!%
96164639!41403919!}%
\@namedef{CALX_Lv50}{-50!00001249!99958333!34895832!70833359!37498883!%
92905970!96044147!80195888!15049833!92706875!41648751!77245267!72974662!%
42146948!18292846!}%
\@namedef{CALX_Lv51}{-51!00001300!49955783!01691299!55994979!12713351!%
48531802!61906355!88500572!49238515!86827743!22734939!74485657!02724801!%
63736203!80193639!}%
\def\CALX_Lzl{2994!0456!8401!7991!4546!8436!4207!6011!0148!8628!7729!7603!%
3327!9009!6757!2609!6773!5248!0235!9972!0508!9598!2983!4196!7784!0422!8624!%
8633!4095!2546!}%
\@namedef{CALX_cdl0}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cdl1}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!5000!}%
\@namedef{CALX_cdl2}{3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!%
3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!%
3333!3333!3333!3333!3333!3333!3333!3333!3333!}%
\@namedef{CALX_cdl3}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!2500!}%
\@namedef{CALX_cdl4}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!2000!}%
\@namedef{CALX_cdl5}{6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!%
6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!%
6666!6666!6666!6666!6666!6666!6666!6666!1666!}%
\@namedef{CALX_cdl6}{5714!1428!2857!5714!1428!2857!5714!1428!2857!5714!1428!%
2857!5714!1428!2857!5714!1428!2857!5714!1428!2857!5714!1428!2857!5714!1428!%
2857!5714!1428!2857!5714!1428!2857!5714!1428!}%
\@namedef{CALX_cdl7}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!1250!}%
\@namedef{CALX_cdl8}{1111!1111!1111!1111!1111!1111!1111!1111!1111!1111!1111!%
1111!1111!1111!1111!1111!1111!1111!1111!1111!1111!1111!1111!1111!1111!1111!%
1111!1111!1111!1111!1111!1111!1111!1111!1111!}%
\@namedef{CALX_cdl9}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!1000!}%
\@namedef{CALX_cdl10}{0909!0909!0909!0909!0909!0909!0909!0909!0909!0909!0909!%
0909!0909!0909!0909!0909!0909!0909!0909!0909!0909!0909!0909!0909!0909!0909!%
0909!0909!0909!0909!0909!0909!0909!0909!0909!}%
\@namedef{CALX_cdl11}{3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!%
3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!%
3333!3333!3333!3333!3333!3333!3333!3333!0833!}%
\@namedef{CALX_cdl12}{2307!0769!6923!2307!0769!6923!2307!0769!6923!2307!0769!%
6923!2307!0769!6923!2307!0769!6923!2307!0769!6923!2307!0769!6923!2307!0769!%
6923!2307!0769!6923!2307!0769!6923!2307!0769!}%
\@namedef{CALX_cdl13}{2857!5714!1428!2857!5714!1428!2857!5714!1428!2857!5714!%
1428!2857!5714!1428!2857!5714!1428!2857!5714!1428!2857!5714!1428!2857!5714!%
1428!2857!5714!1428!2857!5714!1428!2857!0714!}%
\@namedef{CALX_cdl14}{6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!%
6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!%
6666!6666!6666!6666!6666!6666!6666!6666!0666!}%
\@namedef{CALX_cdl15}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0625!}%
\@namedef{CALX_cdl16}{9411!2352!0588!7647!9411!2352!0588!7647!9411!2352!0588!%
7647!9411!2352!0588!7647!9411!2352!0588!7647!9411!2352!0588!7647!9411!2352!%
0588!7647!9411!2352!0588!7647!9411!2352!0588!}%
\@namedef{CALX_cdl17}{5555!5555!5555!5555!5555!5555!5555!5555!5555!5555!5555!%
5555!5555!5555!5555!5555!5555!5555!5555!5555!5555!5555!5555!5555!5555!5555!%
5555!5555!5555!5555!5555!5555!5555!5555!0555!}%
\@namedef{CALX_cdl18}{4736!5789!2631!2105!3684!8947!3157!0526!8421!4736!5789!%
2631!2105!3684!8947!3157!0526!8421!4736!5789!2631!2105!3684!8947!3157!0526!%
8421!4736!5789!2631!2105!3684!8947!3157!0526!}%
\@namedef{CALX_cdl19}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0500!}%
\@namedef{CALX_cdl20}{1904!0476!7619!1904!0476!7619!1904!0476!7619!1904!0476!%
7619!1904!0476!7619!1904!0476!7619!1904!0476!7619!1904!0476!7619!1904!0476!%
7619!1904!0476!7619!1904!0476!7619!1904!0476!}%
\@namedef{CALX_cdl21}{5454!5454!5454!5454!5454!5454!5454!5454!5454!5454!5454!%
5454!5454!5454!5454!5454!5454!5454!5454!5454!5454!5454!5454!5454!5454!5454!%
5454!5454!5454!5454!5454!5454!5454!5454!0454!}%
\@namedef{CALX_cdl22}{7826!0434!3913!5217!6956!2608!3478!1304!1739!5652!0869!%
7826!0434!3913!5217!6956!2608!3478!1304!1739!5652!0869!7826!0434!3913!5217!%
6956!2608!3478!1304!1739!5652!0869!7826!0434!}%
\@namedef{CALX_cdl23}{6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!%
6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!%
6666!6666!6666!6666!6666!6666!6666!6666!0416!}%
\@namedef{CALX_cdl24}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0400!}%
\@namedef{CALX_cdl25}{6153!5384!8461!6153!5384!8461!6153!5384!8461!6153!5384!%
8461!6153!5384!8461!6153!5384!8461!6153!5384!8461!6153!5384!8461!6153!5384!%
8461!6153!5384!8461!6153!5384!8461!6153!0384!}%
\@namedef{CALX_cdl26}{3703!0370!7037!3703!0370!7037!3703!0370!7037!3703!0370!%
7037!3703!0370!7037!3703!0370!7037!3703!0370!7037!3703!0370!7037!3703!0370!%
7037!3703!0370!7037!3703!0370!7037!3703!0370!}%
\@namedef{CALX_cdl27}{1428!2857!5714!1428!2857!5714!1428!2857!5714!1428!2857!%
5714!1428!2857!5714!1428!2857!5714!1428!2857!5714!1428!2857!5714!1428!2857!%
5714!1428!2857!5714!1428!2857!5714!1428!0357!}%
\@namedef{CALX_cdl28}{7931!2413!5517!6896!8620!8275!0344!7931!2413!5517!6896!%
8620!8275!0344!7931!2413!5517!6896!8620!8275!0344!7931!2413!5517!6896!8620!%
8275!0344!7931!2413!5517!6896!8620!8275!0344!}%
\@namedef{CALX_cdl29}{3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!%
3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!%
3333!3333!3333!3333!3333!3333!3333!3333!0333!}%
\@namedef{CALX_cdl30}{3225!1290!4516!5806!0322!6129!6451!2580!9032!1612!0645!%
2258!2903!5161!8064!3225!1290!4516!5806!0322!6129!6451!2580!9032!1612!0645!%
2258!2903!5161!8064!3225!1290!4516!5806!0322!}%
%    \end{macrocode}
% \StoreCodelineNo {calxlogdata}
% \cleardoublepage\let\calxlogdatanameUp\undefined
%\gardesactifs
%\let</calxlogdata>\relax
%\let<*calxtrig>\gardesinactifs
%</calxlogdata>------------------------------------------------------
%<*calxtrig>^^A-------------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname calxtrignameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section{Library \calxtrignameimp implementation}
% \RaisedLabel{sec:calxtrigimp}
% \addedcalx{2.0a1}
%
% \localtableofcontents
%
% calxtrig.tex: native sin, cos for calx.sty (wip). Input by calx.sty
% (catcodes of calx.sty in force -- except for ! which will have catcode 12).
%
% \subsection{Catcodes, \protect\eTeX{} and reload detection}
%
% The code of this subsection is copied over from the xint packages, with
% the package names changed.
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5    % ^^M
  \endlinechar=13 %
  \catcode123=1   % {
  \catcode125=2   % }
  \catcode64=11   % @
  \catcode44=12   % ,
  \catcode46=12   % .
  \catcode58=12   % :
  \catcode94=7    % ^
  \catcode35=6    % #
  \catcode33=12   % !
  \def\empty{}\def\space{ }\newlinechar10
  \expandafter\let\expandafter\t\csname ver@calxtrig.tex\endcsname
  \expandafter\let\expandafter\c\csname ver@calx.sty\endcsname
  \expandafter
    \ifx\csname PackageWarningNoLine\endcsname\relax
      \def\y#1#2{\immediate\write128{^^JPackage #1 Warning:^^J%
                 \space\space\space\space#2.^^J}}%
    \else
      \def\y#1#2{\PackageWarningNoLine{#1}{#2}}%
    \fi
  % attention that in this file \z by default does \endinput.
  \def\z{\endgroup\endinput}%
  \expandafter\ifx\csname numexpr\endcsname\relax
    \y{calx}{\numexpr not available, aborting input}%
  \else
%    \end{macrocode}
% BEWARE: on 2026/10/09 I hit a problem I knew about from years ago but
% forgot.  It is known that TeX executes all macros on the line where
% |\endinput| is found.  But imagine |\endinput\input foo.tex\relax|, 
% then what will happen is that only the first line of foo.tex
% (if its EOL is not hidden by a comment char) is executed, so basically
% foo.tex is not read beyond that. I will put |\endinput| last in both
% situations, as is logical anyhow.
%    \begin{macrocode}
      \ifx\c\relax % calx.sty not yet loaded.
        \ifx\PackageWarningNoLine\relax
          \y{calx}{%
             Loading of calxtrig.tex should happen via
             \string\input\space calx.sty\relax^^J\space\space\space\space
             Will try that now%
          }%
          \def\z{\endgroup
                 \input calx.sty\relax\endinput}%
        \else
          \y{calx}{%
             Bad move! Inputting calxtrig.tex directly in a LaTeX\MessageBreak
             document is forbidden! Simply use \string\usepackage{calx}\MessageBreak
             in the preamble, as every obedient LaTeX user does!\MessageBreak
             Trying to recover now, hoping to be in the preamble%
          }%
          \def\z{\endgroup
                 \RequirePackage{calx}\endinput}%
        \fi
      \else % either calx.sty is trying to load us, or a second loading is
            % attempted on us by \input. Abort if the latter.
        \ifx\t\relax
            \def\z{\endgroup}%
        \else
            \y{calx}{calxtrig.tex already loaded! Aborting this input}%
        \fi
      \fi
  \fi
\z%
%    \end{macrocode}
%\begin{lverb}
% We arrive here only after a \XINTsetcatcodes which is done (near its tail)
% in calx.sty.  In particular ! has its normal catcode 12.  But attention:
% the \XINTsetcatcode does nothing with the letters F, I, N so we have to
% be careful whenever we set them to be of catcode "other" (=12).
%
% There appears to be a problem with miniltx which provides \ProvidesFile
% but does not let it define \ver@calxtrig.tex. So we define it always.
%\end{lverb}
% \subsection{Package identification}
%    \begin{macrocode}
\ifdefined\ProvidesFile
  \ProvidesFile{calxtrig.tex}%
  [2026/11/01 v2.0a1 sin, cos, etc for xintexpr/calx (JFB)]%
\fi
\expandafter\def\csname ver@calxtrig.tex\endcsname
  {2026/11/01 v2.0a1 calx trig library}%
%    \end{macrocode}
% \subsection{Loading data tables}
%    \begin{macrocode}
\input calxtrigdata.tex\relax
%    \end{macrocode}
% \subsection{Package implementation}
%\begin{lverb}
% Copied unchanged from xinttrig.sty: \XINT_SinAux_b,
% \XINT_CosAux_b (Horner in \numexpr, 9-digit fixed point).
%\end{lverb}
%    \begin{macrocode}
\def\XINT_SinAux_b#1.%
{%
  ((((((((%
  -#1/110+\xint_c_e_ix)/%
  -72)*#1/\xint_c_e_ix+\xint_c_e_ix)/%
  -42)*#1/\xint_c_e_ix+\xint_c_e_ix)/%
  -20)*#1/\xint_c_e_ix+\xint_c_e_ix)/%
  -6)*#1/\xint_c_e_ix+\xint_c_e_ix
}%
\def\XINT_CosAux_b#1.%
{%
  ((((((((((%
  -#1/132+\xint_c_e_ix)/%
  -90)*#1/\xint_c_e_ix+\xint_c_e_ix)/%
  -56)*#1/\xint_c_e_ix+\xint_c_e_ix)/%
  -30)*#1/\xint_c_e_ix+\xint_c_e_ix)/%
  -12)*#1/\xint_c_e_ix+\xint_c_e_ix)/%
  -2)*#1/\xint_c_e_ix+\xint_c_e_ix
}%
%    \end{macrocode}
% \subsection{Function table entries, \csh{calxFpSin}, \csh{calxFpCos}}
% calx: function table entries (pattern of |\XINT_flexpr_func_sqr|).
%    \begin{macrocode}
\def\XINT_flexpr_func_sin #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpSin#3}}%
}%
\def\XINT_flexpr_func_cos #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpCos#3}}%
}%
\def\XINT_flexpr_func_asin #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpAsin#3}}%
}%
\def\XINT_flexpr_func_acos #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpAcos#3}}%
}%
\def\XINT_flexpr_func_asind #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpAsind#3}}%
}%
\def\XINT_flexpr_func_acosd #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpAcosd#3}}%
}%
\def\XINT_flexpr_func_acsc #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpAcsc#3}}%
}%
\def\XINT_flexpr_func_asec #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpAsec#3}}%
}%
\def\XINT_flexpr_func_atan #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpAtan#3}}%
}%
\def\XINT_flexpr_func_atand #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpAtand#3}}%
}%
\def\XINT_flexpr_func_tan #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpTan#3}}%
}%
\def\XINT_flexpr_func_cot #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpCot#3}}%
}%
\def\XINT_flexpr_func_sec #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpSec#3}}%
}%
\def\XINT_flexpr_func_csc #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpCsc#3}}%
}%
\def\XINT_flexpr_func_sinc #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpSinc#3}}%
}%
\def\XINT_flexpr_func_sind #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpSind#3}}%
}%
\def\XINT_flexpr_func_cosd #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpCosd#3}}%
}%
\def\XINT_flexpr_func_tand #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpTand#3}}%
}%
\def\XINT_flexpr_func_cotd #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpCotd#3}}%
}%
\def\XINT_flexpr_func_secd #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpSecd#3}}%
}%
\def\XINT_flexpr_func_cscd #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:one
    {\romannumeral`&&@\calxFpCscd#3}}%
}%
\expandafter\def\csname XINT_flexpr_func_Arg\endcsname #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxFpArg#3}}%
}%
\expandafter\def\csname XINT_flexpr_func_Argd\endcsname #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxFpArgd#3}}%
}%
\expandafter\def\csname XINT_flexpr_func_pArg\endcsname #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxFppArg#3}}%
}%
\expandafter\def\csname XINT_flexpr_func_pArgd\endcsname #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxFppArgd#3}}%
}%
\expandafter\def\csname XINT_flexpr_func_atan2\endcsname #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxFpAtantwo#3}}%
}%
\expandafter\def\csname XINT_flexpr_func_atan2d\endcsname #1#2#3%
{%
    \expandafter #1\expandafter #2\expandafter{%
    \romannumeral`&&@\XINT:NEhook:f:one:from:two
    {\romannumeral`&&@\calxFpAtantwod#3}}%
}%
\let\XINT_flexpr_func_tg\XINT_flexpr_func_tan
\let\XINT_flexpr_func_cotg\XINT_flexpr_func_cot
\let\XINT_flexpr_func_arcsin\XINT_flexpr_func_asin
\let\XINT_flexpr_func_arccos\XINT_flexpr_func_acos
\let\XINT_flexpr_func_arctg\XINT_flexpr_func_atan
\let\XINT_flexpr_func_arcsec\XINT_flexpr_func_asec
\let\XINT_flexpr_func_arccsc\XINT_flexpr_func_acsc
%    \end{macrocode}
%\begin{lverb}
% Syntax (f-expandable; X, Y f-expanded F, I or raw values, rounded to
% P = \XINTdigits digits; results F or I values, rounded to P digits):
%(
%  \calxFp<F>{X}         -> F(X)
%:      F = Sin, Cos, Tan, Cot, Sec, Csc, Sinc (radians),
%:          Sind, Cosd, Tand, Cotd, Secd, Cscd (degrees),
%:          Asin, Acos, Asec, Acsc, Atan (radians),
%:          Asind, Acosd, Atand (degrees)
%:  \calxFpArg{X}{Y}     -> argument of (X, Y), in (-pi, pi]
%:  \calxFppArg{X}{Y}    -> the same, in [0, 2pi)
%:  \calxFpArgd{X}{Y}, \calxFppArgd{X}{Y}       -> the same in degrees
%:  \calxFpAtantwo{Y}{X}, \calxFpAtantwod{Y}{X}  -> atan2(Y, X) = Arg(X, Y)
%)
%
% \calxFpSin{X}, \calxFpCos{X}: P = \XINTdigits. X is first rounded to
% P digits, then \CALX_sin_g, \CALX_cos_g: |X| < 0.8 goes to the series
% kernels \CALX_sin_h, \CALX_cos_h, |X| >= 0.8 to the argument reduction
% (\CALX_sin_r, \CALX_cos_r) then to the same kernels. P <= 8 ("ultra
% fast, less precise", as xinttrig): \numexpr kernels
% \CALX_sin_q, \CALX_cos_q (called by \CALX_sin_h, \CALX_cos_h).
%\end{lverb}
%    \begin{macrocode}
\def\calxFpSin{\romannumeral0\expandafter\CALX_sin_a
    \romannumeral0\CALX_fround{\XINTdigits}}%
\def\calxFpCos{\romannumeral0\expandafter\CALX_cos_a
    \romannumeral0\CALX_fround{\XINTdigits}}%
\def\calxFpAsin #1{\romannumeral0\expandafter\CALX_ad_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}a0}%
\def\calxFpAcos #1{\romannumeral0\expandafter\CALX_ad_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}c0}%
\def\calxFpAsind #1{\romannumeral0\expandafter\CALX_ad_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}a1}%
\def\calxFpAcosd #1{\romannumeral0\expandafter\CALX_ad_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}c1}%
\def\calxFpAcsc #1{\romannumeral0\expandafter\CALX_ae_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}a}%
\def\calxFpAsec #1{\romannumeral0\expandafter\CALX_ae_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}c}%
\def\calxFpAtan #1{\romannumeral0\expandafter\CALX_tq_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}{0}{1}{0}}%
\def\calxFpAtand #1{\romannumeral0\expandafter\CALX_tq_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}{0}{1}{1}}%
\def\calxFpTan #1{\romannumeral0\expandafter\CALX_sc_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}\CALX_fntan r}%
\def\calxFpCot #1{\romannumeral0\expandafter\CALX_sc_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}\CALX_fncot r}%
\def\calxFpSec #1{\romannumeral0\expandafter\CALX_sc_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}\CALX_fnsec r}%
\def\calxFpCsc #1{\romannumeral0\expandafter\CALX_sc_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}\CALX_fncsc r}%
\def\calxFpSinc #1{\romannumeral0\expandafter\CALX_sc_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}\CALX_fnsinc r}%
\def\calxFpSind #1{\romannumeral0\expandafter\CALX_dg_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}\CALX_fnsin s}%
\def\calxFpCosd #1{\romannumeral0\expandafter\CALX_dg_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}\CALX_fncos c}%
\def\calxFpTand #1{\romannumeral0\expandafter\CALX_dg_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}\CALX_fntan t}%
\def\calxFpCotd #1{\romannumeral0\expandafter\CALX_dg_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}\CALX_fncot u}%
\def\calxFpSecd #1{\romannumeral0\expandafter\CALX_dg_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}\CALX_fnsec v}%
\def\calxFpCscd #1{\romannumeral0\expandafter\CALX_dg_a
    \romannumeral0\CALX_fround{\XINTdigits}{#1}\CALX_fncsc w}%
\def\calxFpArg {\romannumeral0\CALX_ar_a a0}%
\def\calxFpArgd {\romannumeral0\CALX_ar_a a1}%
\def\calxFppArg {\romannumeral0\CALX_ar_a p0}%
\def\calxFppArgd {\romannumeral0\CALX_ar_a p1}%
\def\calxFpAtantwo #1#2{\romannumeral0\CALX_ar_a a0{#2}{#1}}%
\def\calxFpAtantwod #1#2{\romannumeral0\CALX_ar_a a1{#2}{#1}}%
%    \end{macrocode}
%\begin{lverb}
% Reduction constants (130 digits, mpmath; the 80 digits of xinttrig.sty
% are a prefix): \CALX_trigR = 180/pi, \CALX_trigDg = pi/180;
% \CALX_pdg<P> = pi/180 rounded to P+4 digits, P = 1, ..., 100.
%\end{lverb}
%    \begin{macrocode}
\edef\CALX_trigR{\romannumeral0\CALX_ffromraw
  {57295779513082320876798154814105170332405472466564321549160243861202847148%
  32155263244096899585111094418622338163286489328144826460[-128]}}%
\edef\CALX_trigDg{\romannumeral0\CALX_ffromraw
  {17453292519943295769236907684886127134428718885417254560971914401710091146%
  03449443682241569634509482212304492507379059248385469228[-131]}}%
\def\CALX_pdgmk #1.%
{%
    \expandafter\edef\csname CALX_pdg#1\endcsname
      {\romannumeral0\CALX_fnround{#1+4}{\CALX_trigDg}}%
    \ifnum#1<100 \expandafter\CALX_pdgmk\the\numexpr#1+1\expandafter.\fi
}%
\CALX_pdgmk 1.\let\CALX_pdgmk\undefined
%    \end{macrocode}
% \subsection{Dispatch and kernels for P at most 8}
% Names with uppercase F, I, N are not usable below (catcode 12).
%    \begin{macrocode}
\def\CALX_trigdigits{\XINTdigits}%
\let\CALX_sinaux\XINT_SinAux_b \let\CALX_cosaux\XINT_CosAux_b
%    \end{macrocode}
% ATTENTION setting from here on F, I, N to "other" catcode.
%    \begin{macrocode}
\catcode`F 12 \catcode`I 12 \catcode`N 12
\def\CALX_sin_a #1%
{%
    \if I#1\expandafter\CALX_sin_i\else\expandafter\CALX_sin_g\fi #1
}%
\def\CALX_cos_a #1%
{%
    \if I#1\expandafter\CALX_sin_i\else\expandafter\CALX_cos_g\fi #1
}%
%    \end{macrocode}
% |#1| is I and we perhaps do not want to rely on its catcode being 12.
%    \begin{macrocode}
\def\CALX_sin_i #1#2\xint:{\CALX_tr_sp#2}%
%    \end{macrocode}
%\begin{lverb}
% Dispatch. |X| < 0.8: \CALX_sin_h, \CALX_cos_h below;
% otherwise reduction (\CALX_sin_r, \CALX_cos_r).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_sin_g F#1#2.%
{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_sin_g_zero\fi
    \xint_orthat\CALX_sin_g_nonzero #1#2.%
}%
\def\CALX_sin_g_zero #1#2.#3.#4\xint:{ F+0.0.}%
\def\CALX_sin_g_nonzero #1#2.#3.#4\xint:%
{%
    \ifnum\numexpr#2+8*#3>\xint_c_ \xint_dothis\CALX_sin_r\fi
    \ifnum\ifnum\numexpr#2+8*#3=\xint_c_
      \CALX_trig_top#4\xint:\else0\fi>\xint_c_vii
      \xint_dothis\CALX_sin_r\fi
    \xint_orthat\CALX_sin_g_small #1#2.#3.#4\xint:%
}%
\def\CALX_sin_g_small #1#2.#3.#4\xint:%
{\expandafter\CALX_sin_h\the\numexpr(\CALX_trigdigits+7)/8%
                 .#1#2.#3.#4\xint:}%
\def\CALX_cos_g F#1#2.%
{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_cos_g_zero\fi
    \xint_orthat\CALX_cos_g_nonzero #1#2.%
}%
\def\CALX_cos_g_zero #1#2.#3.#4\xint:{ F+1.0.100000001!}%
\def\CALX_cos_g_nonzero #1#2.#3.#4\xint:%
{%
    \ifnum\numexpr#2+8*#3>\xint_c_ \xint_dothis\CALX_cos_g_reduce\fi
    \ifnum\ifnum\numexpr#2+8*#3=\xint_c_
      \CALX_trig_top#4\xint:\else0\fi>\xint_c_vii
      \xint_dothis\CALX_cos_g_reduce\fi
    \xint_orthat\CALX_cos_g_small #1#2.#3.#4\xint:%
}%
\def\CALX_cos_g_reduce #1#2.#3.#4\xint:{\CALX_cos_r+#2.#3.#4\xint:}%
\def\CALX_cos_g_small #1#2.#3.#4\xint:%
{\expandafter\CALX_cos_h\the\numexpr(\CALX_trigdigits+7)/8%
                 .#1#2.#3.#4\xint:}%
\def\CALX_trig_top 1#1#2!#3\xint:%
{%
    \if\relax\detokenize{#3}\relax\expandafter\xint_firstoftwo
    \else\expandafter\xint_secondoftwo\fi
    {#1}{\CALX_trig_top#3\xint:}%
}%
%    \end{macrocode}
%\begin{lverb}
% P <= 8, |X| < 0.8 (\CALX_sin_q, \CALX_cos_q, called by \CALX_sin_h,
% \CALX_cos_h): X has E = D + 8e <= 0 (|X| < 10^E); X may have up to
% 8m digits (reduced argument). E < -4: sin X = round_P(X), cos X = 1
% (u/6 < 2 10^-11). Else A = the top 9 digits of M rounded (\CALX_rta),
% X = A 10^(E-9) (1 + d), |d| < 6 10^-9; U9 = round(round(A^2/10^9) /
% 10^(-2E)) (= round(10^9 u) within 1); S9 = 10^9 sin(X)/X, C9 = 10^9
% cos(X) by the Horner kernels of xinttrig; sin X = round_P(round(A
% S9/10^9) 10^(E-9)), cos X = round_P(C9 10^-9), both rounded and
% written as natives by \CALX_dgo (below).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_sin_q #1#2.#3.%
{%
    \ifnum\numexpr#2+8*#3<-\xint_c_iv
      \xint_dothis\CALX_sin_q_tiny\fi
    \xint_orthat\CALX_sin_q_compute #1#2.#3.%
}%
\def\CALX_sin_q_tiny #1#2.#3.#4\xint:%
  {\CALX_fnround{\CALX_trigdigits}{F#1#2.#3.#4}}%
\def\CALX_sin_q_compute #1#2.#3.#4\xint:%
{%
    \expandafter\CALX_sqa\the\numexpr#2+8*#3\expandafter.%
      \the\numexpr(2*#2+7)/16\expandafter.%
      \the\numexpr#2+8-8*((2*#2+7)/16).#1#4\xint:%
}%
\def\CALX_sqa #1.#2.#3.#4#5\xint:%
  {\expandafter\CALX_sqb\the\numexpr\CALX_rta#2.#3.#5\xint:.#4#1.}%
\def\CALX_sqb #1.#2#3.%
{%
    \expandafter\CALX_dgo\the\numexpr#2#1*(%
      \expandafter\CALX_sinaux\the\numexpr#1*#1/1000000000/%
      \CALX_pten{-2*#3}.)/1000000000.#3-9.%
}%
\def\CALX_cos_q #1#2.#3.%
{%
    \ifnum\numexpr#2+8*#3<-\xint_c_iv \xint_dothis\CALX_cos_q_tiny\fi
    \xint_orthat\CALX_cos_q_compute #1#2.#3.%
}%
\def\CALX_cos_q_tiny #1#2.#3.#4\xint:{ F+1.0.100000001!}%
\def\CALX_cos_q_compute #1#2.#3.#4\xint:%
{%
    \expandafter\CALX_cqa\the\numexpr#2+8*#3\expandafter.%
      \the\numexpr(2*#2+7)/16\expandafter.%
      \the\numexpr#2+8-8*((2*#2+7)/16).#4\xint:%
}%
\def\CALX_cqa #1.#2.#3.#4\xint:%
  {\expandafter\CALX_cqb\the\numexpr\CALX_rta#2.#3.#4\xint:.#1.}%
\def\CALX_cqb #1.#2.%
{%
    \expandafter\CALX_dgo\the\numexpr
      \expandafter\CALX_cosaux\the\numexpr#1*#1/1000000000/%
      \CALX_pten{-2*#2}..-9.%
}%
%    \end{macrocode}
%\begin{lverb}
% sind, cosd, tand, cotd, secd, cscd for P <= 8, all in \numexpr,
% 9-digit fixed point as \CALX_sin_q (kinds s, c, t, u, v, w). P > 8, NaN and
% infinities go to \CALX_sc_a (jumper \CALX_dg_j), zero gives 0 or 1.
%
% Input (after \CALX_fround to P): |x| = A 10^(E-9) EXACTLY, E = D + 8e,
% A integer, 10^8 <= A < 10^9 (\CALX_dg_one$empty: one block, A = b 10^(9-D);
% \CALX_dg_two$empty: two blocks, A = b_1 10^(17-D) + b_0 / 10^(D-9), the
% division being exact: x has at most P + 1 <= 9 significant digits).
%
% E < 2 (|x| < 10): no reduction, y = |x| (jumper \CALX_dg_l). Otherwise
% the exact reduction of xinttrig's \XINT_sind_i (mod 360, quadrant by
% rounding), in integers:
%(
%:   I = floor(|x|),  n = I mod 360,  q = round((2n+1)/180) in 0..4,
%:   10^7 y = (n - 90 q) 10^7 + 10^7 frac(|x|),   -45 <= y <= 45,
%)
% then y = A' 10^(E'-9) (\CALX_dgw, \CALX_dgd), y = 0 giving A' = 0.
% Quadrant (\CALX_dgq<kind><q>): sind = sign(x) times S(y), C(y), -S(y),
% -C(y), S(y) for q = 0..4, cosd = C(y), -S(y), -C(y), S(y), C(y), with
% S = sind, C = cosd on [-45, 45] (\CALX_dgks, \CALX_dgkc); tand, cotd
% (odd, factor sign(x)): T, -1/T, T, -1/T, T and 1/T, -T, 1/T, -T, 1/T
% (T = tand y); secd: 1/C, -1/S, -1/C, 1/S, 1/C; cscd (odd): 1/S, 1/C,
% -1/S, -1/C, 1/S. Zero: tand 0, secd 1, cotd and cscd DivisionByZero.
% For P > 8 the kinds t, u, v, w are those of \CALX_sc_a for tand, cotd
% (\CALX_sc_d), secd (\CALX_sc_c), cscd (\CALX_sc_s).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_dg_a #1%
{%
    \ifnum\CALX_trigdigits>\xint_c_viii \CALX_dg_j\fi
    \if I#1\CALX_dg_j\fi
    \CALX_dg_b #1%
}%
\def\CALX_dg_j\fi #1\CALX_dg_b #2\xint:{\fi\CALX_sc_a #2\xint:}%
\def\CALX_dg_b F#1#2.#3.#4\xint:#5%
{%
    \ifnum#2=\xint_c_ \CALX_dg_z\fi
    \CALX_dg_c #2.#3.#1#4\xint:%
}%
\def\CALX_dg_z\fi\CALX_dg_c #1\xint:#2{\fi\csname CALX_dgz#2\endcsname}%
\expandafter\def\csname CALX_dgzs\endcsname{ F+0.0.}%
\expandafter\def\csname CALX_dgzc\endcsname{ F+1.0.100000001!}%
\expandafter\def\csname CALX_dgzt\endcsname{ F+0.0.}%
\expandafter\def\csname CALX_dgzu\endcsname
  {\CALX_nsig{DivisionByZero}{x / 0}{+}}%
\expandafter\let\csname CALX_dgzv\expandafter\endcsname
  \csname CALX_dgzc\endcsname
\expandafter\let\csname CALX_dgzw\expandafter\endcsname
  \csname CALX_dgzu\endcsname
\def\CALX_dg_c #1.#2.#31#4!#5%
  {\xint_gob_til_xint: #5\CALX_dg_one\xint:\CALX_dg_two #1.#2.#3#4.}%
\def\CALX_dg_one\xint:\CALX_dg_two #1.#2.#3#4.%
{%
    \expandafter\CALX_dg_d\the\numexpr#1+8*#2\expandafter.%
    \the\numexpr#4*\CALX_pten{9-#1}.#3%
}%
\def\CALX_dg_two #1.#2.#3#4.#5!\xint:%
{%
    \expandafter\CALX_dg_d\the\numexpr#1+8*#2\expandafter.%
    \the\numexpr#5*\CALX_pten{17-#1}+#4/\CALX_pten{#1-9}.#3%
}%
\def\CALX_dg_d #1.%
{%
    \ifnum#1<\xint_c_ii \CALX_dg_l\fi
    \csname CALX_dge\ifnum#1>11 c\else#1\fi\endcsname#1.%
}%
\def\CALX_dg_l\fi #1\endcsname#2.#3.#4#5%
  {\fi\csname CALX_dgd#5\endcsname #4#3.#2.}%
\expandafter\def\csname CALX_dgds\endcsname #1#2.#3.{\CALX_dgks #11.#2.#3.}%
\expandafter\def\csname CALX_dgdc\endcsname #1#2.#3.{\CALX_dgkc 1.#2.#3.}%
\expandafter\def\csname CALX_dgdt\endcsname #1#2.#3.{\CALX_dgkt #11.#2.#3.}%
\expandafter\def\csname CALX_dgdu\endcsname #1#2.#3.%
  {\csname CALX_dgkb+\endcsname #11.#2.#3.}%
\expandafter\def\csname CALX_dgdv\endcsname #1#2.#3.{\CALX_dgke 1.#2.#3.}%
\expandafter\def\csname CALX_dgdw\endcsname #1#2.#3.{\CALX_dgkr #11.#2.#3.}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_dge<E> <E>.<A>. (one \csname from \CALX_dg_d, E = 2..11, c for
% E > 11) gives \CALX_dg_s <n>.<10^7 frac(|x|)>. For E <= 9, with k = 9 -
% E: I = floor(A/10^k) = round((2A - 10^k)/(2 10^k)) and 10^7 frac(|x|)
% = (A - I 10^k) 10^(E-2) (exact: frac(|x|) has at most k <= 7 decimal
% digits); \CALX_dgdef builds these eight macros with literal powers of
% ten. For E >= 10, x is an integer: n = ((A mod 360) (10^(E-9) mod
% 360)) mod 360, 10^(E-9) = 10, 100 or 280 (mod 360).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_dgdef #1#2#3#4%
{%
    \expandafter\def\csname CALX_dge#1\endcsname##1.##2.%
    {%
      \expandafter\CALX_dg_s\the\numexpr\CALX_mod{((2*##2-#2)/#3)}%
      \expandafter.\the\numexpr(##2-#2*((2*##2-#2)/#3))#4.%
    }%
}%
\CALX_dgdef 2{10000000}{20000000}{}%
\CALX_dgdef 3{1000000}{2000000}{*10}%
\CALX_dgdef 4{100000}{200000}{*100}%
\CALX_dgdef 5{10000}{20000}{*1000}%
\CALX_dgdef 6{1000}{2000}{*10000}%
\CALX_dgdef 7{100}{200}{*100000}%
\CALX_dgdef 8{10}{20}{*1000000}%
\CALX_dgdef 9{1}{2}{*10000000}%
\expandafter\def\csname CALX_dge10\endcsname #1.#2.%
  {\expandafter\CALX_dg_s\the\numexpr\CALX_mod{\CALX_mod{#2}*10}.0.}%
\expandafter\def\csname CALX_dge11\endcsname #1.#2.%
  {\expandafter\CALX_dg_s\the\numexpr\CALX_mod{\CALX_mod{#2}*100}.0.}%
\expandafter\def\csname CALX_dgec\endcsname #1.#2.%
  {\expandafter\CALX_dg_s\the\numexpr\CALX_mod{\CALX_mod{#2}*280}.0.}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_dg_s <n>.<r>., \CALX_dg_t$empty: q and 10^7 y; \CALX_dg_u
% selects the quadrant macro with the sign token of x.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_dg_s #1.{\expandafter\CALX_dg_t\the\numexpr(2*#1+1)/180.#1.}%
\def\CALX_dg_t #1.#2.#3.%
  {\expandafter\CALX_dg_u\the\numexpr(#2-90*#1)*10000000+#3.#1.}%
\def\CALX_dg_u #1.#2.#3#4{\csname CALX_dgq#4#2\endcsname#3#1.}%
\expandafter\def\csname CALX_dgqs0\endcsname#1{\CALX_dgw\CALX_dgks#11.}%
\expandafter\def\csname CALX_dgqs1\endcsname#1{\CALX_dgw\CALX_dgkc#11.}%
\expandafter\def\csname CALX_dgqs2\endcsname#1{\CALX_dgw\CALX_dgks#1-1.}%
\expandafter\def\csname CALX_dgqs3\endcsname#1{\CALX_dgw\CALX_dgkc#1-1.}%
\expandafter\def\csname CALX_dgqs4\endcsname#1{\CALX_dgw\CALX_dgks#11.}%
\expandafter\def\csname CALX_dgqc0\endcsname#1{\CALX_dgw\CALX_dgkc1.}%
\expandafter\def\csname CALX_dgqc1\endcsname#1{\CALX_dgw\CALX_dgks-1.}%
\expandafter\def\csname CALX_dgqc2\endcsname#1{\CALX_dgw\CALX_dgkc-1.}%
\expandafter\def\csname CALX_dgqc3\endcsname#1{\CALX_dgw\CALX_dgks1.}%
\expandafter\def\csname CALX_dgqc4\endcsname#1{\CALX_dgw\CALX_dgkc1.}%
\expandafter\def\csname CALX_dgqt0\endcsname#1{\CALX_dgw\CALX_dgkt#11.}%
\expandafter\def\csname CALX_dgqt1\endcsname#1%
  {\expandafter\CALX_dgw\csname CALX_dgkb#1\endcsname#1-1.}%
\expandafter\def\csname CALX_dgqt2\endcsname#1{\CALX_dgw\CALX_dgkt#11.}%
\expandafter\def\csname CALX_dgqt3\endcsname#1%
  {\expandafter\CALX_dgw\csname CALX_dgkb\if-#1+\else-\fi\endcsname#1-1.}%
\expandafter\def\csname CALX_dgqt4\endcsname#1{\CALX_dgw\CALX_dgkt#11.}%
\expandafter\def\csname CALX_dgqu0\endcsname#1%
  {\expandafter\CALX_dgw\csname CALX_dgkb+\endcsname#11.}%
\expandafter\def\csname CALX_dgqu1\endcsname#1{\CALX_dgw\CALX_dgkt#1-1.}%
\expandafter\def\csname CALX_dgqu2\endcsname#1%
  {\expandafter\CALX_dgw\csname CALX_dgkb-\endcsname#11.}%
\expandafter\def\csname CALX_dgqu3\endcsname#1{\CALX_dgw\CALX_dgkt#1-1.}%
\expandafter\def\csname CALX_dgqu4\endcsname#1%
  {\expandafter\CALX_dgw\csname CALX_dgkb+\endcsname#11.}%
\expandafter\def\csname CALX_dgqv0\endcsname#1{\CALX_dgw\CALX_dgke1.}%
\expandafter\def\csname CALX_dgqv1\endcsname#1{\CALX_dgw\CALX_dgkr-1.}%
\expandafter\def\csname CALX_dgqv2\endcsname#1{\CALX_dgw\CALX_dgke-1.}%
\expandafter\def\csname CALX_dgqv3\endcsname#1{\CALX_dgw\CALX_dgkr1.}%
\expandafter\def\csname CALX_dgqv4\endcsname#1{\CALX_dgw\CALX_dgke1.}%
\expandafter\def\csname CALX_dgqw0\endcsname#1{\CALX_dgw\CALX_dgkr#11.}%
\expandafter\def\csname CALX_dgqw1\endcsname#1{\CALX_dgw\CALX_dgke#11.}%
\expandafter\def\csname CALX_dgqw2\endcsname#1{\CALX_dgw\CALX_dgkr#1-1.}%
\expandafter\def\csname CALX_dgqw3\endcsname#1{\CALX_dgw\CALX_dgke#1-1.}%
\expandafter\def\csname CALX_dgqw4\endcsname#1{\CALX_dgw\CALX_dgkr#11.}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_dgw <kernel><factor>.<v>. (v = 10^7 y): \CALX_dgd gives, from
% the digit count d of |v|, 10^(9-d) and E' = d - 7; then \CALX_dgx calls
% the kernel with <factor (+1 or -1)>.<A' = v 10^(9-d)>.<E'>. (A' carries
% the sign of y).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_dgw #1#2.#3.%
{%
    \expandafter\CALX_dgx\expanded{\expandafter\CALX_dgd
      \the\numexpr\ifnum#3<\xint_c_-\fi#3.}#3.#1#2.%
}%
\def\CALX_dgd #1.%
{%
    \CALX_nd_c #1{1.2}{1.2}{10.1}{100.0}{1000.-1}{10000.-2}{100000.-3}%
    {1000000.-4}{10000000.-5}{100000000.-6}\xint:.%
}%
\def\CALX_dgx #1.#2.#3.#4#5.%
  {\expandafter#4\the\numexpr#5\expandafter.\the\numexpr#3*#1.#2.}%
%    \end{macrocode}
%\begin{lverb}
% Kernels \CALX_dgks, \CALX_dgkc <f>.<A>.<E>. (f = +-1, |y| = |A| 10^(E-9)
% degrees, t = pi y/180 radians). \CALX_dgu (inside \numexpr): U9 =
% round(10^9 t^2) = round(round(A^2/10^9) r_E) with r_E = p_E/q_E, the
% best approximation of 10^(2E) (pi/180)^2 by p_E, q_E < 2^31 (continued
% fraction, relative error < 10^-11), \CALX_dgr<E> for E = -2..2; E < -2:
% U9 = 0 (t^2 < 3.1 10^-10). S9 = 10^9 sin(t)/t, C9 = 10^9 cos(t) by
% \CALX_sinaux, \CALX_cosaux (xinttrig's Horner kernels);
%(
%:   sind y = round(f A Z / 10^9) 10^(E-11),   Z = round(S9 p/q),
%:   cosd y = f C9 10^-9,
%)
% p/q = 1489429756/853380389 (100 pi/180, relative error 10^-19). Error
% before the final rounding: a few units of 10^-9 relative (Horner,
% U9, Z), i.e. about 1 ulp at P = 8.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_dgu #1.#2.%
  {\ifnum#2<-\xint_c_ii 0\else
   #1*#1/1000000000\csname CALX_dgr#2\endcsname\fi}%
\expandafter\def\csname CALX_dgr2\endcsname{*920239054/302096661}%
\expandafter\def\csname CALX_dgr1\endcsname{*53922105/1770158287}%
\expandafter\def\csname CALX_dgr0\endcsname{*532125/1746863329}%
\expandafter\def\csname CALX_dgr-1\endcsname{*4337/1423753114}%
\expandafter\def\csname CALX_dgr-2\endcsname{*2/65656127}%
\def\CALX_dgks #1.#2.#3.%
{%
    \expandafter\CALX_dgo\the\numexpr#1*#2*(%
      (\expandafter\CALX_sinaux\the\numexpr\CALX_dgu#2.#3..)%
      *1489429756/853380389)/1000000000.#3-11.%
}%
\def\CALX_dgkc #1.#2.#3.%
{%
    \expandafter\CALX_dgo\the\numexpr#1*(%
      \expandafter\CALX_cosaux\the\numexpr\CALX_dgu#2.#3..).-9.%
}%
%    \end{macrocode}
%\begin{lverb}
% Kernels of tand, cotd, secd, cscd (same arguments <f>.<A>.<E>.; Z, C9
% as above):
%(
%:   tan y = round(f A Z / C9) 10^(E-11)                   (\CALX_dgkt)
%:   cot y = round(f 10^17 / round(A Z / C9)) 10^(-E-6)    (\CALX_dgkb<s>)
%:   sec y = round(f 10^18 / C9) 10^-9                     (\CALX_dgke)
%:   csc y = round(f round(10^17 / A) 10^9 / Z) 10^(-E-6)  (\CALX_dgkr)
%)
% (products then divisions as one scaled \numexpr operation, all values
% below 2^31). y = 0 (A = 0) in cot, csc: pole, DivisionByZero with the
% sign s of the numerator of the general path (\CALX_dgkb+, \CALX_dgkb-;
% csc: +), as \CALX_fdiv gives it.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_dgkt #1.#2.#3.%
  {\expandafter\CALX_dgkta\the\numexpr\CALX_dgu#2.#3..#1.#2.#3.}%
\def\CALX_dgkta #1.#2.#3.#4.%
{%
    \expandafter\CALX_dgo\the\numexpr#2*#3*%
      ((\CALX_sinaux#1.)*1489429756/853380389)/(\CALX_cosaux#1.).#4-11.%
}%
\def\CALX_dgkbdef #1%
{%
    \expandafter\def\csname CALX_dgkb#1\endcsname##1.##2##3.##4.%
      {\xint_gob_til_zero##2\CALX_dgpz#10\CALX_dgkba##1.##2##3.##4.}%
}%
\CALX_dgkbdef+\CALX_dgkbdef-\let\CALX_dgkbdef\undefined
\def\CALX_dgpz #10#2#3.#4.#5.%
  {\CALX_nsig{DivisionByZero}{x / 0}{#1}}%
\def\CALX_dgkba #1.#2.#3.%
  {\expandafter\CALX_dgkbb\the\numexpr\CALX_dgu#2.#3..#1.#2.#3.}%
\def\CALX_dgkbb #1.#2.#3.#4.%
{%
    \expandafter\CALX_dgo\the\numexpr#2*(1000000000*100000000/(#3*%
      ((\CALX_sinaux#1.)*1489429756/853380389)/(\CALX_cosaux#1.))).-#4-6.%
}%
\def\CALX_dgke #1.#2.#3.%
{%
    \expandafter\CALX_dgo\the\numexpr#1*(1000000000*1000000000/(%
      \expandafter\CALX_cosaux\the\numexpr\CALX_dgu#2.#3..)).-9.%
}%
\def\CALX_dgkr #1.#2#3.#4.%
  {\xint_gob_til_zero#2\CALX_dgpz+0\CALX_dgkra#1.#2#3.#4.}%
\def\CALX_dgkra #1.#2.#3.%
{%
    \expandafter\CALX_dgo\the\numexpr#1*((1000000000*100000000/#2)*1000000000%
      /((\expandafter\CALX_sinaux\the\numexpr\CALX_dgu#2.#3..)%
      *1489429756/853380389)).-#3-6.%
}%
%    \end{macrocode}
%\begin{lverb}
% Syntax:
%(
%  \CALX_dgo <N>.<x>.         -> <space>F<s><D>.<b>.<blocks>  round_P(N 10^x)
%:  \CALX_dgoc <M>.<b>.<g>.<s>  -> <space>F<s><D>.<b>.<blocks>  (M 10^g)
%)
% (P = \CALX_trigdigits; for \CALX_dgoc, 10^(P-1) <= M <= 10^P, b the
% block exponent, g - 8b in 0..7.)
%
% \CALX_dgo <N>.<x>. (N a signed integer of at most 10 digits, x an
% integer expression; also used by \CALX_sin_q, \CALX_cos_q): the native
% round_P(N 10^x), without \CALX_ffromraw nor \CALX_fround. \CALX_dgy$empty:
% sign apart, N = 0 gives F+0.0., else s = (number of digits of N) - P >=
% 0 (N >= 10^7 for all callers: 8, 9 or 10 digits); \CALX_dgob$empty: M =
% round(N/10^s) (\numexpr division, half away from zero as \CALX_fround),
% g = x + s (|value| = M 10^g), block exponent b = round((2g - 7)/16), h =
% g - 8b in 0..7; \CALX_dgoc$empty: D = h + P, plus 1 if M = 10^P (carry, as
% \CALX_fround); \CALX_dgod$empty: F<sign><D>.<b>. and the block(s) of M 10^h,
% one if D <= 8, else two (\CALX_dgoe, \CALX_dgof$empty: high part
% floor(M / 10^(8-h)), low part the rest times 10^h; D <= 16).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_dgo #1%
  {\if-#1\expandafter\CALX_dgy\else\expandafter\CALX_dgy\expandafter+\fi#1}%
\def\CALX_dgy #1#2.#3.%
{%
    \ifnum#2=\xint_c_ \CALX_dgyz\fi
    \expandafter\CALX_dgob
    \the\numexpr\ifnum#2<1000000000 \ifnum#2<100000000 8\else9\fi
      \else10\fi-\CALX_trigdigits.#2.#3.#1%
}%
\def\CALX_dgyz\fi #1\CALX_dgob #2.#3.#4.#5{\fi\space F+0.0.}%
\expandafter\def\csname CALX_pt9\endcsname{1000000000}%
\def\CALX_dgob #1.#2.#3.%
{%
    \expandafter\CALX_dgoc\the\numexpr#2/\CALX_pten{#1}\expandafter.%
    \the\numexpr(2*(#3+#1)-7)/16\expandafter.\the\numexpr#3+#1.%
}%
\def\CALX_dgoc #1.#2.#3.%
{%
    \expandafter\CALX_dgod\the\numexpr#3-8*#2\expandafter.%
    \the\numexpr#3-8*#2+\CALX_trigdigits
      \ifnum#1<\CALX_pten{\CALX_trigdigits} \else+1\fi.#1.#2.%
}%
\def\CALX_dgod #1.#2.#3.#4.#5%
{%
    \expanded{ F#5#2.#4.\ifnum#2>\xint_c_viii \CALX_dgoe#1.#3.\else
      \the\numexpr100000000+#3*\CALX_pten{#1}!\fi}%
}%
\def\CALX_dgoe #1.#2.%
{%
    \expandafter\CALX_dgof\the\numexpr(2*#2-\CALX_pten{8-#1})%
      /(2*\CALX_pten{8-#1}).#1.#2.%
}%
\def\CALX_dgof #1.#2.#3.%
{%
    \the\numexpr100000000+(#3-#1*\CALX_pten{8-#2})*\CALX_pten{#2}!%
    \the\numexpr100000000+#1!%
}%
%    \end{macrocode}
%\begin{lverb}
% asind, acosd, atand and asin, acos, atan for P <= 8, all in \numexpr.
% P > 8, NaN,
% infinities, zero, |x| >= 1 (asind, acosd) go to the general code
% (\CALX_as_a, \CALX_at_a; jumpers \CALX_ad_j, \CALX_ad_k, \CALX_tq_j,
% \CALX_tq_k). |x| = A 10^(E-9) exactly (\CALX_rta, as \CALX_sin_q).
%
% Small kernel \CALX_ad_s <A>.<E>.<den>.<cont> (a = A 10^(E-9) <=
% sqrt(2)/2): U9 = round(10^9 a^2) (0 if E < -4), Zd = round(R9 p'/q'),
% R9 = 10^9 asin(a)/a by \CALX_asb (xinttrig's \XINT_Arcsin_Ib), p'/q' =
% 853380389/1489429756 (180/(100 pi)); gives <cont><N>.<E-7>. with N =
% round(A Zd/den): asind a = N 10^(E-7) for den = 10^9 (half of it for
% den = 2 10^9). A need not be normalized (E = 0, absolute accuracy).
%
% Large kernel \CALX_ad_l <A>.<cont> (E = 0, A > 707106781): u =
% sqrt(1 - a^2) = sqrt(d (2 10^9 - d)) 10^-9, d = 10^9 - A exact; with k
% = 4, 3, 3, 2, 2, 1, 1, 0, 0 for d of 1, ..., 9 digits, s =
% round(sqrt(d 10^(2k) (2 10^9 - d))) (u = s 10^(-9-k), s < 1.42 10^9)
% by five Newton steps s + (P M/s - s)/2 (one scaled \numexpr division)
% from a linear guess (\CALX_ad_lc, relative error < 25$%); then as the
% small kernel with A = s: <cont><N>.<-k-7>., asind u = N 10^(-k-7).
%
% Finishers: \CALX_ad_ys <N>.<e>.<s> gives round_P(s N 10^e) by \CALX_dgo;
% \CALX_ad_yc <N>.<e>.{B}<o><s> gives round_P(s (B o N 10^(e+7)) 10^-7)
% (units of 10^-7 degree, B = 45, 90 or 180 degrees). asind: s V (small),
% s (90 - V(u)) (large); acosd: 90 -+ V (small), V(u) or 180 - V(u)
% (large).
%
% atand, t = |x|: (i) t <= tan(22.5): x' = 2t/(1+t^2) (A' = 2 A 10^9 /
% (10^9 + U9), divided by 10 if it has ten digits), atand = s V(x')/2;
% (ii) E = 0, tan(22.5) < t < 1: y' = (1-t^2)/(1+t^2), atand = s (45 -
% V(y')/2); (iv) 1 <= t < tan(67.5): y' = (t^2-1)/(t^2+1) from (A -
% 10^8)(A + 10^8)/10^8 and A^2/10^8 + 10^8, atand = s (45 + V(y')/2); (v)
% t >= tan(67.5): r = 1/t (round(10^17/A), E' = 1 - E), x' = 2r/(1+r^2),
% atand = s (90 - V(x')/2). No square root.
%
% Radians: the same kernels (tables \CALX_ad<a|c><1|0><s|l>, \CALX_tq<kind>
% <1|0>, 1: degrees, 0: radians) with the finishers \CALX_ad_zs,
% \CALX_ad_zc (result times pi/180 = 1489429756/853380389 / 100, in units
% of 10^-9 radian, angles up to 90 degrees) and \CALX_ad_zm (times pi/18 =
% 105115715/602268683, units of 10^-8 radian: acos of x < 0, results
% >= pi/2 up to pi).
%
% acsc, asec for P <= 8 (\CALX_ae_a; |x| < 1, zero, x = +-1 and P > 8 go to
% \CALX_ac_a): y = 1/|x|. 1 <= |x| < sqrt(2) (E = 1, A < 141421357): the
% large kernel on u = sqrt(1 - y^2) with d = 10^9 (|x| - 1)/|x| from the
% exact A (\CALX_ae_l: d 10^(2k) = (A - 10^8) 10^(2k+1) 10^8/A, no
% cancellation); otherwise the small kernel on y, A' = round(10^17/A),
% E' = 1 - E (\CALX_ae_t). Tables \CALX_ae<s|l|o><a|c><p|m> (sign of x).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_ad_a #1%
{%
    \ifnum\CALX_trigdigits>\xint_c_viii \CALX_ad_j\fi
    \if I#1\CALX_ad_j\fi
    \CALX_ad_b #1%
}%
\def\CALX_ad_j\fi #1\CALX_ad_b #2\xint:{\fi\CALX_as_a #2\xint:}%
\def\CALX_ad_b F#1#2.#3.#4\xint:%
{%
    \ifnum\ifnum#2=\xint_c_ \xint_c_i\else\numexpr#2+8*#3\relax\fi
      >\xint_c_ \CALX_ad_k\fi
    \CALX_ad_ba #1#2.#3.#4\xint:%
}%
\def\CALX_ad_k\fi\CALX_ad_ba #1\xint:{\fi\CALX_as_a F#1\xint:}%
\def\CALX_ad_ba #1#2.#3.#4\xint:%
{%
    \expandafter\CALX_ad_bb\the\numexpr#2+8*#3\expandafter.%
    \the\numexpr(2*#2+7)/16\expandafter.%
    \the\numexpr#2+8-8*((2*#2+7)/16).#4\xint:#1%
}%
\def\CALX_ad_bb #1.#2.#3.#4\xint:#5%
  {\expandafter\CALX_ad_c\the\numexpr\CALX_rta#2.#3.#4\xint:.#1.#5}%
\def\CALX_ad_c #1.#2.#3#4#5%
{%
    \csname CALX_ad#4#5\ifnum#2<\xint_c_ s\else
      \ifnum#1>707106781 l\else s\fi\fi\endcsname #1.#2.#3%
}%
\expandafter\def\csname CALX_ada1s\endcsname #1.#2.#3%
  {\CALX_ad_s#1.#2.1000000000.\CALX_ad_ys#3}%
\expandafter\def\csname CALX_ada1l\endcsname #1.#2.#3%
  {\CALX_ad_l#1.\CALX_ad_yc{900000000}-#3}%
\expandafter\def\csname CALX_adc1s\endcsname #1.#2.#3%
  {\CALX_ad_s#1.#2.1000000000.\CALX_ad_yc{900000000}{\if-#3+\else-\fi}+}%
\expandafter\def\csname CALX_adc1l\endcsname #1.#2.#3%
  {\if-#3\expandafter\CALX_ad_cm\else\expandafter\CALX_ad_cp\fi #1.}%
\def\CALX_ad_cp #1.{\CALX_ad_l#1.\CALX_ad_ys+}%
\def\CALX_ad_cm #1.{\CALX_ad_l#1.\CALX_ad_yc{1800000000}-+}%
\expandafter\def\csname CALX_ada0s\endcsname #1.#2.#3%
  {\CALX_ad_s#1.#2.1000000000.\CALX_ad_zs#3}%
\expandafter\def\csname CALX_ada0l\endcsname #1.#2.#3%
  {\CALX_ad_l#1.\CALX_ad_zc{900000000}-#3}%
\expandafter\def\csname CALX_adc0s\endcsname #1.#2.#3%
  {\if-#3\expandafter\CALX_ad_es\else\expandafter\CALX_ad_fs\fi #1.#2.}%
\def\CALX_ad_es #1.#2.%
  {\CALX_ad_s#1.#2.1000000000.\CALX_ad_zm{900000000}++}%
\def\CALX_ad_fs #1.#2.%
  {\CALX_ad_s#1.#2.1000000000.\CALX_ad_zc{900000000}-+}%
\expandafter\def\csname CALX_adc0l\endcsname #1.#2.#3%
  {\if-#3\expandafter\CALX_ad_dm\else\expandafter\CALX_ad_dp\fi #1.}%
\def\CALX_ad_dp #1.{\CALX_ad_l#1.\CALX_ad_zs+}%
\def\CALX_ad_dm #1.{\CALX_ad_l#1.\CALX_ad_zm{1800000000}-+}%
\def\CALX_ad_s #1.#2.%
{%
    \expandafter\CALX_ad_sa\the\numexpr\ifnum#2<-\xint_c_iv 0\else
      #1*#1/1000000000/\CALX_pten{-2*#2}\fi.#1.#2.%
}%
\def\CALX_ad_sa #1.#2.#3.#4.#5%
{%
    \expandafter#5\the\numexpr#2*((\CALX_asb#1.)*853380389/1489429756)/#4%
    \expandafter.\the\numexpr#3-7.%
}%
\def\CALX_ad_l #1.{\expandafter\CALX_ad_la\the\numexpr1000000000-#1.}%
\def\CALX_ad_la #1.%
  {\expandafter\CALX_ad_lb\the\numexpr\CALX_nd_c #10001122334\xint:.#1.}%
\def\CALX_ad_lb #1.#2.%
{%
    \expandafter\CALX_ad_lc\the\numexpr#2*\CALX_pten{2*#1}\expandafter.%
    \the\numexpr2000000000-#2.#1.%
}%
\def\CALX_ad_lc #1.%
{%
    \expandafter\CALX_ad_na\the\numexpr\ifnum#1<100000000
      (#1+31622777)*38233/10000\else(#1+316227766)*120903/100000\fi.#1.%
}%
\def\CALX_ad_na #1.#2.#3.%
  {\expandafter\CALX_ad_nb\the\numexpr#1+(#2*#3/#1-#1)/2.#2.#3.}%
\def\CALX_ad_nb #1.#2.#3.%
  {\expandafter\CALX_ad_nc\the\numexpr#1+(#2*#3/#1-#1)/2.#2.#3.}%
\def\CALX_ad_nc #1.#2.#3.%
  {\expandafter\CALX_ad_nd\the\numexpr#1+(#2*#3/#1-#1)/2.#2.#3.}%
\def\CALX_ad_nd #1.#2.#3.%
  {\expandafter\CALX_ad_ne\the\numexpr#1+(#2*#3/#1-#1)/2.#2.#3.}%
\def\CALX_ad_ne #1.#2.#3.%
  {\expandafter\CALX_ad_lf\the\numexpr#1+(#2*#3/#1-#1)/2.}%
\def\CALX_ad_lf #1.#2.%
{%
    \expandafter\CALX_ad_sa\the\numexpr#1*#1/1000000000/\CALX_pten{2*#2}.%
    #1.-#2.1000000000.%
}%
\def\CALX_ad_ys #1.#2.#3{\expandafter\CALX_dgo\the\numexpr#3#1.#2.}%
\def\CALX_ad_yc #1.#2.#3#4#5%
{%
    \expandafter\CALX_dgo\the\numexpr#51*(#3#4(\ifnum#2<-16 0\else
      #1/\CALX_pten{-#2-7}\fi)).-7.%
}%
\def\CALX_ad_zs #1.#2.#3%
{%
    \expandafter\CALX_dgo\the\numexpr#3#1*1489429756/853380389%
    \expandafter.\the\numexpr#2-2.%
}%
\def\CALX_ad_zc #1.#2.#3#4#5%
{%
    \expandafter\CALX_dgo\the\numexpr#51*(#3#4(\ifnum#2<-16 0\else
      #1/\CALX_pten{-#2-7}\fi))*1489429756/853380389.-9.%
}%
\def\CALX_ad_zm #1.#2.#3#4#5%
{%
    \expandafter\CALX_dgo\the\numexpr#51*(#3#4(\ifnum#2<-16 0\else
      #1/\CALX_pten{-#2-7}\fi))*105115715/602268683.-8.%
}%
\def\CALX_ae_a #1%
{%
    \ifnum\CALX_trigdigits>\xint_c_viii \CALX_ae_j\fi
    \if I#1\CALX_ae_j\fi
    \CALX_ae_b #1%
}%
\def\CALX_ae_j\fi #1\CALX_ae_b #2\xint:{\fi\CALX_ac_a #2\xint:}%
\def\CALX_ae_b F#1#2.#3.#4\xint:%
{%
    \ifnum\ifnum#2=\xint_c_ \xint_c_\else\numexpr#2+8*#3\relax\fi
      <\xint_c_i \CALX_ae_k\fi
    \CALX_ae_ba #1#2.#3.#4\xint:%
}%
\def\CALX_ae_k\fi\CALX_ae_ba #1\xint:{\fi\CALX_ac_a F#1\xint:}%
\def\CALX_ae_ba #1#2.#3.#4\xint:%
{%
    \expandafter\CALX_ae_bb\the\numexpr#2+8*#3\expandafter.%
    \the\numexpr(2*#2+7)/16\expandafter.%
    \the\numexpr#2+8-8*((2*#2+7)/16).#4\xint:#1%
}%
\def\CALX_ae_bb #1.#2.#3.#4\xint:#5%
  {\expandafter\CALX_ae_c\the\numexpr\CALX_rta#2.#3.#4\xint:.#1.#5}%
\def\CALX_ae_c #1.#2.#3#4%
{%
    \csname CALX_ae\ifnum#2=\xint_c_i\ifnum#1<141421357 \ifnum#1=100000000
      o\else l\fi\else s\fi\else s\fi#4\if-#3m\else p\fi\endcsname #1.#2.%
}%
\expandafter\def\csname CALX_aesap\endcsname #1.#2.%
  {\CALX_ae_t#1.#2.\CALX_ad_zs+}%
\expandafter\def\csname CALX_aesam\endcsname #1.#2.%
  {\CALX_ae_t#1.#2.\CALX_ad_zs-}%
\expandafter\def\csname CALX_aescp\endcsname #1.#2.%
  {\CALX_ae_t#1.#2.\CALX_ad_zc{900000000}-+}%
\expandafter\def\csname CALX_aescm\endcsname #1.#2.%
  {\CALX_ae_t#1.#2.\CALX_ad_zm{900000000}++}%
\expandafter\def\csname CALX_aelap\endcsname #1.#2.%
  {\CALX_ae_l#1.\CALX_ad_zc{900000000}-+}%
\expandafter\def\csname CALX_aelam\endcsname #1.#2.%
  {\CALX_ae_l#1.\CALX_ad_zc{900000000}--}%
\expandafter\def\csname CALX_aelcp\endcsname #1.#2.%
  {\CALX_ae_l#1.\CALX_ad_zs+}%
\expandafter\def\csname CALX_aelcm\endcsname #1.#2.%
  {\CALX_ae_l#1.\CALX_ad_zm{1800000000}-+}%
\expandafter\def\csname CALX_aeoap\endcsname #1.#2.%
  {\CALX_ac_a F+1.0.100000001!\xint: a}%
\expandafter\def\csname CALX_aeoam\endcsname #1.#2.%
  {\CALX_ac_a F-1.0.100000001!\xint: a}%
\expandafter\def\csname CALX_aeocp\endcsname #1.#2.%
  {\CALX_ac_a F+1.0.100000001!\xint: c}%
\expandafter\def\csname CALX_aeocm\endcsname #1.#2.%
  {\CALX_ac_a F-1.0.100000001!\xint: c}%
\def\CALX_ae_t #1.#2.%
  {\expandafter\CALX_ae_u\the\numexpr100000000*1000000000/#1.#2.}%
\def\CALX_ae_u #1.#2.%
{%
    \expandafter\CALX_ad_s\the\numexpr\ifnum#1<1000000000 #1\else
      100000000\fi\expandafter.\the\numexpr\ifnum#1<1000000000 1\else
      2\fi-#2.1000000000.%
}%
\def\CALX_ae_l #1.%
  {\expandafter\CALX_ae_la\the\numexpr(#1-100000000)*1000000000/#1.#1.}%
\def\CALX_ae_la #1.%
  {\expandafter\CALX_ae_lb\the\numexpr\CALX_nd_c #10001122334\xint:.#1.}%
\def\CALX_ae_lb #1.#2.#3.%
{%
    \expandafter\CALX_ad_lc\the\numexpr(#3-100000000)*\CALX_pten{2*#1+1}%
      *100000000/#3\expandafter.\the\numexpr2000000000-#2.#1.%
}%
\def\CALX_tq_a #1%
{%
    \ifnum\CALX_trigdigits>\xint_c_viii \CALX_tq_j\fi
    \if I#1\CALX_tq_j\fi
    \CALX_tq_b #1%
}%
\def\CALX_tq_j\fi #1\CALX_tq_b #2\xint:{\fi\CALX_at_a #2\xint:}%
\def\CALX_tq_b F#1#2.#3.#4\xint:%
{%
    \ifnum#2=\xint_c_ \CALX_tq_k\fi
    \CALX_tq_ba #1#2.#3.#4\xint:%
}%
\def\CALX_tq_k\fi\CALX_tq_ba #1\xint:{\fi\CALX_at_a F#1\xint:}%
\def\CALX_tq_ba #1#2.#3.#4\xint:%
{%
    \expandafter\CALX_tq_bb\the\numexpr#2+8*#3\expandafter.%
    \the\numexpr(2*#2+7)/16\expandafter.%
    \the\numexpr#2+8-8*((2*#2+7)/16).#4\xint:#1%
}%
\def\CALX_tq_bb #1.#2.#3.#4\xint:#5%
  {\expandafter\CALX_tq_c\the\numexpr\CALX_rta#2.#3.#4\xint:.#1.#5}%
\def\CALX_tq_c #1.#2.#3#4#5#6%
{%
    \csname CALX_tq\ifnum#2<\xint_c_ i\else\ifnum#2=\xint_c_
      \ifnum#1>414213562 ii\else i\fi\else\ifnum#2=\xint_c_i
      \ifnum#1<241421357 iv\else v\fi\else v\fi\fi\fi#6\endcsname #1.#2.#3%
}%
\expandafter\def\csname CALX_tqi1\endcsname{\CALX_tq_i\CALX_ad_ys}%
\expandafter\def\csname CALX_tqii1\endcsname{\CALX_tq_ii\CALX_ad_yc}%
\expandafter\def\csname CALX_tqiv1\endcsname{\CALX_tq_iv\CALX_ad_yc}%
\expandafter\def\csname CALX_tqv1\endcsname{\CALX_tq_v\CALX_ad_yc}%
\expandafter\def\csname CALX_tqi0\endcsname{\CALX_tq_i\CALX_ad_zs}%
\expandafter\def\csname CALX_tqii0\endcsname{\CALX_tq_ii\CALX_ad_zc}%
\expandafter\def\csname CALX_tqiv0\endcsname{\CALX_tq_iv\CALX_ad_zc}%
\expandafter\def\csname CALX_tqv0\endcsname{\CALX_tq_v\CALX_ad_zc}%
\def\CALX_tq_i #1#2.#3.#4%
{%
    \expandafter\CALX_tq_x\the\numexpr2*#2*1000000000/(1000000000+
      \ifnum#3<-\xint_c_iv 0\else#2*#2/1000000000/\CALX_pten{-2*#3}\fi).%
    #3.#1#4%
}%
\def\CALX_tq_x #1.#2.%
{%
    \ifnum#1<1000000000 \expandafter\CALX_tq_y\else
      \expandafter\CALX_tq_z\fi #1.#2.%
}%
\def\CALX_tq_y #1.#2.{\CALX_ad_s#1.#2.2000000000.}%
\def\CALX_tq_z #1.#2.%
{%
    \expandafter\CALX_ad_s\the\numexpr#1/10\expandafter.%
    \the\numexpr#2+1.2000000000.%
}%
\def\CALX_tq_ii #1#2.#3.#4%
  {\expandafter\CALX_tq_w\the\numexpr#2*#2/1000000000.#1#4}%
\def\CALX_tq_w #1.#2#3%
{%
    \expandafter\CALX_ad_s\the\numexpr(1000000000-#1)*1000000000/%
      (1000000000+#1).0.2000000000.#2{450000000}-#3%
}%
\def\CALX_tq_iv #1#2.#3.#4%
{%
    \expandafter\CALX_ad_s\the\numexpr((#2-100000000)*(#2+100000000)%
      /100000000)*1000000000/(#2*#2/100000000+100000000).%
    0.2000000000.#1{450000000}+#4%
}%
\def\CALX_tq_v #1#2.#3.%
  {\expandafter\CALX_tq_r\the\numexpr100000000*1000000000/#2.#3.#1}%
\def\CALX_tq_r #1.#2.%
{%
    \expandafter\CALX_tq_u\the\numexpr\ifnum#1<1000000000 #1\else
      100000000\fi\expandafter.\the\numexpr\ifnum#1<1000000000 1\else
      2\fi-#2.%
}%
\def\CALX_tq_u #1.#2.#3#4%
{%
    \expandafter\CALX_tq_x\the\numexpr2*#1*1000000000/(1000000000+
      \ifnum#2<-\xint_c_iv 0\else#1*#1/1000000000/\CALX_pten{-2*#2}\fi).%
    #2.#3{900000000}-#4%
}%
%    \end{macrocode}
% \subsection{Series kernel with column short products}
%\begin{lverb}
% Horner levels T_k = C_k - U T_(k+1) / 10^(4b) by column short products.
% Level (b, m, n): U has b limbs (more limbs of U_0 enter as extra
% precision), T_(k+1) m limbs, T_k n limbs. Columns c (weight 10^(4c) of
% U T) from b+n-1 down to b-2; columns b-1, b-2 are guards (carry only).
% Column text: terms `u*t+` with u = -(limb of U) balanced, t limb of T;
% the text of column c-1 comes from the text of column c by \CALX_Zr
% (`u*t+` -> `t+u*`: each u takes the t of the next term), with the next
% u (f) opened in front and the next t (g) closing the last term.
% Stream of a level, inside the \numexpr of the outermost column:
%(   <first>\CALX_Zs <U list>\CALX_Zt <T items>\CALX_Zw <static items>
%)
% U list `u!..u!0!0!0!0!` (MS first, negated, balanced, top limb up to
% 10^4 in modulus), T items `\CALX_Zn x_top.\CALX_Zl x. .. \CALX_Zl0.`
% (\CALX_Zl evaluates a balanced limb where the item enters a text),
% static item of column c: `C_c!<macro of c-1><carry macro of c-1>`.
% Column value x: the parent adds round(x/10^4) (\CALX_Zu, \CALX_Zg) and
% the limb x - 10^4 round(x/10^4) in [-5000,5000] is left after the
% parent's terminator; final levels: floor carry, limbs 0000..9999
% (\CALX_Zv$empty: \CALX_Zuf). Output after the outermost \numexpr$empty:
%(   x_top.\CALX_Zl x. ... (n limbs, MS first)
%)
% |u| <= 5000 (top <= 10^4), |t| <= 10^4, <= 28 terms: |x| < 1.5e9.
%\end{lverb}
%    \begin{macrocode}
\let\CALX_Zs\relax \let\CALX_Zt\relax \let\CALX_Zw\relax \let\CALX_Zq\relax
\def\CALX_Za #1\CALX_Zs#2!#3\CALX_Zt#4.#5\CALX_Zw#6!#7#8%
{%
    #6+#1\expandafter#8\the\numexpr\expandafter#7\expanded
    {#2*\CALX_Zr#1\CALX_Zx*#4.+}\CALX_Zs#3\CALX_Zt#5\CALX_Zw
}%
\def\CALX_Zb #1\CALX_Zs#2!#3\CALX_Zt#4.#5\CALX_Zw#6!#7#8%
{%
    #6+\expandafter#8\the\numexpr\expandafter#7\expanded{#2*#4.+}%
    \CALX_Zs#3\CALX_Zt#5\CALX_Zw
}%
\def\CALX_Zc #1\CALX_Zs#2\CALX_Zt#3\CALX_Zw#4!#5#6%
   {#4+\expandafter#6\the\numexpr#5\CALX_Zs#2\CALX_Zt#3\CALX_Zw}%
\def\CALX_Zz #1\CALX_Zs#2\CALX_Zw#3!{#3+#10.}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_Zad$empty: as \CALX_Za when U is used up (f = 0): the first term's t
% is
% dropped instead of opening a zero term in front (\CALX_Zrf)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Zad #1\CALX_Zs#2!#3\CALX_Zt#4.#5\CALX_Zw#6!#7#8%
{%
    #6+#1\expandafter#8\the\numexpr\expandafter#7\expanded
    {\CALX_Zrf#1\CALX_Zx*#4.+}\CALX_Zs#3\CALX_Zt#5\CALX_Zw
}%
\def\CALX_Zrf #1*#2+{#1*\CALX_Zr}%
\def\CALX_Zr #1*#2+{#2+#1*\CALX_Zr}%
\def\CALX_Zx*\CALX_Zr{}%
\def\CALX_Zu #1.{#1/10000.\CALX_Zl#1.}%
\def\CALX_Zg #1.{#1/10000.}%
\def\CALX_Zl #1.{\the\numexpr#1-#1/10000*10000\relax}%
\def\CALX_Zn #1.{#1}%
%    \end{macrocode}
%\begin{lverb}
% negating variants: a level whose output feeds a level computing
% C + U T (instead of C - U T) uses the carry \CALX_Zun (limbs negated by
% \CALX_Zln); the next level is \CALX_Zvn (top limb negated by \CALX_Znn)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Zun #1.{#1/10000.\CALX_Zln#1.}%
\def\CALX_Zln #1.{\the\numexpr#1/10000*10000-#1\relax}%
\def\CALX_Znn #1.{\the\numexpr-#1\relax}%
%    \end{macrocode}
%\begin{lverb}
% final variant: floor carry, limb as 4 digits followed by !
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Zuf #1.{\expandafter\CALX_Zuh\the\numexpr#1-#1/10000*10000.#1.}%
\def\CALX_Zuh #1.%
   {\ifnum#1<\xint_c_ \expandafter\CALX_Zum\else\expandafter\CALX_Zup\fi#1.}%
\def\CALX_Zum #1.#2.{(#2/10000-1).\CALX_Zlm#1.}%
\def\CALX_Zup #1.#2.{#2/10000.\CALX_Zlp#1.}%
\def\CALX_Zlm #1.{\the\numexpr10000+#1!}%
\def\CALX_Zlp #1.{\expandafter\xint_gobble_i\the\numexpr10000+#1!}%
%    \end{macrocode}
%\begin{lverb}
% driver: <output>\CALX_Zq{<U list>}<next descriptor>
%(   \CALX_Zv{<first>}{<static items>}  or a client's final macro, which
%:   receives {<U list>}<output>\CALX_Zq.
%)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Zd #1\CALX_Zq#2#3{#3{#2}#1\CALX_Zq}%
\def\CALX_Zv #1#2\CALX_Zq#3#4%
{%
    \expandafter\CALX_Zd\the\numexpr#3\CALX_Zs#1\CALX_Zt\CALX_Zn#2%
    \CALX_Zl0.\CALX_Zw#4\CALX_Zq{#1}%
}%
\def\CALX_Zvn #1#2\CALX_Zq#3#4%
{%
    \expandafter\CALX_Zd\the\numexpr#3\CALX_Zs#1\CALX_Zt\CALX_Znn#2%
    \CALX_Zl0.\CALX_Zw#4\CALX_Zq{#1}%
}%
%    \end{macrocode}
%\begin{lverb}
% level whose T items are given whole (no \CALX_Zn prefix), U pad #5 (square
% level of sin/cos); carry \CALX_Zuu$empty: limbs evaluated as `v!' (U
% list)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Zvq #1#2\CALX_Zq#3#4#5%
{%
    \expandafter\CALX_Zd\the\numexpr#3\CALX_Zs#1#5\CALX_Zt#2%
    \CALX_Zl0.\CALX_Zw#4\CALX_Zq{#1}%
}%
\def\CALX_Zuu #1.{#1/10000.\CALX_Zlu#1.}%
\def\CALX_Zlu #1.{\the\numexpr#1-#1/10000*10000!}%
%    \end{macrocode}
%\begin{lverb}
% exact product level (all columns kept, C = 0): T negated as in \CALX_Zvn,
% pads from the descriptor: \CALX_Zvp{<first>}{<static>}{<U pad>}{<T pad>}
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Zvp #1#2\CALX_Zq#3#4#5#6%
{%
    \expandafter\CALX_Zd\the\numexpr#3\CALX_Zs#1#5\CALX_Zt\CALX_Znn#2%
    \CALX_Zl0.#6\CALX_Zw#4\CALX_Zq{#1}%
}%
%    \end{macrocode}
%\begin{lverb}
% load time: \CALX_Zlevp{b}{m}<carry macro>: product of U (b limbs) by T
% (m limbs), columns b+m-1 down to 0, all limbs output (carry macro);
% columns x < m (U used up for the text of x-1) use \CALX_Zad
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Zlevp #1#2#3%
{%
    \noexpand\CALX_Zvp{\noexpand\CALX_Zb}%
    {\expandafter\CALX_Zlpv\the\numexpr#1+#2-1\expandafter.\the\numexpr#2.#3}%
    {\expandafter\CALX_Zzr\the\numexpr#2-1.}%
    {\expandafter\CALX_Zlpz\the\numexpr#1-1.}%
}%
\def\CALX_Zlpv #1.#2.#3% column #1 (m = #2): C = 0, macro of #1-1, carry
{%
    0!\ifnum#1=\xint_c_i\noexpand\CALX_Zz\else
      \ifnum#1>#2 \noexpand\CALX_Za\else\noexpand\CALX_Zad\fi\fi\noexpand#3%
    \ifnum#1=\xint_c_i 0!\else\expandafter\CALX_Zlpv\the\numexpr#1-1.#2.#3\fi
}%
\def\CALX_Zlpz #1.{\ifnum#1>\xint_c_ \noexpand\CALX_Zl0.\expandafter\CALX_Zlpz
   \the\numexpr#1-1\expandafter.\fi}%
%    \end{macrocode}
%\begin{lverb}
% list helpers: \CALX_Zrev <l!..l!>\CALX_Zq! reverses (inside \expanded);
% \CALX_Zzr <k>. k zero limbs 0!; \CALX_Zrep <k>. k limbs 9999!;
% \CALX_Ztn c1!c2!..\relax -> c1.\CALX_Zn c2 .. (T items, load time)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Zrev #1\CALX_Zq!{\CALX_Zrw#1\CALX_Zq!\relax}%
\def\CALX_Zrw #1!#2\relax{\CALX_Zgob#1\CALX_Zre\CALX_Zq\CALX_Zrw#2\relax#1!}%
\def\CALX_Zre\CALX_Zq\CALX_Zrw#1\relax\CALX_Zq!{}%
\def\CALX_Zzr #1.{\ifnum#1>\xint_c_ 0!\expandafter\CALX_Zzr
   \the\numexpr#1-1\expandafter.\fi}%
\def\CALX_Zrep #1.{\ifnum#1>\xint_c_ 9999!\expandafter\CALX_Zrep
   \the\numexpr#1-1\expandafter.\fi}%
\def\CALX_Ztn #1!#2\relax{#1\CALX_Ztm#2\relax}%
\def\CALX_Ztm #1\relax{\if\relax\detokenize{#1}\relax\else\CALX_Ztk#1\relax\fi}%
\def\CALX_Ztk #1!#2\relax{.\noexpand\CALX_Zn#1\CALX_Ztm#2\relax}%
%    \end{macrocode}
%\begin{lverb}
% start: \CALX_Zst{<T_N limb>}{<descriptors, final macro last>}{<U list>}
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Zst #1#2#3{\CALX_Zd#1.\CALX_Zq{#3}#2}%
%    \end{macrocode}
%\begin{lverb}
% U list from limbs u_1!..u_b!\CALX_Zq! (MS first, u_1 signed, others
% 0..9999): -(u_i - 10^4 [u_i >= 5000] + [u_(i+1) >= 5000]), top limb
% -(u_1 + [u_2 >= 5000]) kept whole; four zero limbs appended.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Zgob #1\CALX_Zq{}%
\def\CALX_Zbt #1!#2!{\the\numexpr0-(#1)-#2/10000!\CALX_Zbn#2!}%
\def\CALX_Zbn #1!#2!%
   {\CALX_Zgob#2\CALX_Zbe\CALX_Zq\the\numexpr-#2/10000-#1+10000*(#1/10000)!%
    \CALX_Zbn#2!}%
\def\CALX_Zbe\CALX_Zq\the\numexpr-#1/10000#2!\CALX_Zbn\CALX_Zq!%
   {\the\numexpr#2!0!0!0!0!}%
%    \end{macrocode}
%\begin{lverb}
% load time: descriptor of a level (inside \edef)
% \CALX_Zlev{b}{m}{n}{<C limbs MS first, n items l!>}<carry macro>
% \CALX_Zlevx<level macro>{b}{m}{n}{C}<carry macro> (\CALX_Zvn)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_Zlev{\CALX_Zlevx\CALX_Zv}%
\def\CALX_Zlevx #1#2#3#4#5#6%
{%
    \noexpand#1{\expandafter\CALX_Zmac\the\numexpr#2+#4-1.#2.#3.}%
    {\expandafter\CALX_Zlv\the\numexpr#2+#4-1\expandafter.\expanded{#2.#3.#5}\relax#6}%
}%
\def\CALX_Zmac #1.#2.#3.% macro of column #1 (b = #2, m = #3)
{%
    \ifnum#1>\numexpr#2+#3-1\relax\noexpand\CALX_Zc\else
    \ifnum#1=\numexpr#2+#3-1\relax\noexpand\CALX_Zb\else
    \ifnum#1<\numexpr#2-1\relax\noexpand\CALX_Zz\else\noexpand\CALX_Za
    \fi\fi\fi
}%
\def\CALX_Zlv #1.#2.#3.#4\relax#5% column #1 >= b-1: C!<macro c-1><carry c-1>
{%
    \ifnum#1<#2 0\else\CALX_Zhd#4\relax\fi!%
    \expandafter\CALX_Zmac\the\numexpr#1-1.#2.#3.%
    \ifnum#1>#2 \noexpand#5\else\noexpand\CALX_Zg\fi
    \ifnum#1<#2 0!\else
      \expandafter\CALX_Zlv\the\numexpr#1-1\expandafter.\the\numexpr#2%
      \expandafter.\the\numexpr#3\expandafter.\CALX_Ztl#4\relax\relax#5%
    \fi
}%
\def\CALX_Zhd #1!#2\relax{#1}%
\def\CALX_Ztl #1!#2\relax{#2}%
\let\CALX_qW\relax
\def\CALX_gobW #1\CALX_qW{}%
%    \end{macrocode}
% \subsection{Series kernels with three-limb passes (P above 40)}
%\begin{lverb}
% Generic path (P >= 9, |X| < 0.8): fixed point Horner on 4-digit limbs
% with the precision schedule of xinttrig (decreasing widths).
% u = X^2, S(u) = sum (-u)^k/(2k+1)!, C(u) = sum (-u)^k/(2k)!, c_k the
% coefficients. Scale 10^(4A) (A limbs) at all levels. Level k = N-1..0:
%(
%:   T_k = C_k - ceil(U_k T_{k+1} / 10^(4 b_k)),   T_N = C_N,
%)
% C_k = floor(c_k 10^(4A)), U_k = floor(u 10^(4 b_k)) (b_k limbs, the
% top b_k limbs of U_0). T_k is kept on its n_k significant limbs
% (c_k 10^(4A) + 4 < 10^(4 n_k): the other limbs are zero), n_0 = A.
%
% Error on S (or C), units 10^(-4A), u <= 0.64: level k contributes
% u^k (1 (C_k) + 1 (ceil) + 10^(4A-4 b_k) T_{k+1} 10^(-4A)), T_N 1,
% tail u^(N+1)/(2N+3)! (resp. (2N+2)!). The table below (generated by
% tools/trig_sched2.py with exact rationals, all P = 9..100) chooses N,
% A, b_k, n_k so that the total is <= 0.005 10^-P S_min (S_min =
% sin(0.8)/0.8, C_min = cos(0.8)): relative error <= 0.005 ulp before
% the single final rounding (sin X = round_P(X S), cos X = round_P(C)).
%
% The c_k are computed at load time by the recurrence c_k = c_{k-1} /
% ((2k)(2k+1)) (resp. ((2k-1)(2k))) on floor(10^140 c_k) (no factorial;
% error < 2 10^-140, i.e. < 10^-30 unit), then truncated to 10^(4A).
%
% Product: the
% level list has L = b_k + n_k items <u>,<a>! (LS first), item i stands
% for column i: items i < b_k are u_i,0!, items b_k + j are 0,c_j! (the
% limbs of C_k), then the sentinel \CALX_qW,0!. One pass handles three
% limbs t0, t1, t2 of T_{k+1} (missing ones are 0): with a window of the
% three previous u's, column i becomes x = a + carry - t0 u_i - t1 u_(i-1)
% - t2 u_(i-2); the pass emits u_(i-3),low(x)! (the u's move three items
% up, the columns stay: the next pass multiplies by t3, t4, t5). After
% ceil(m/3) passes the items hold the limbs of D = C_k 10^(4 b_k) - U_k
% T_{k+1} modulo 10^(4L) (carries out of item L-1 and the u's leaving
% the list only concern columns >= L), exact since 0 <= D < 10^(4L)
% (D 10^(-4 b_k) = T_k, n_k limbs; for k = 0, C_0 = 10^(4A) is 0 modulo
% 10^(4L)). T_k = items b_k..L-1. |x| < 3.0003 10^8: 1400000000 + x has
% 10 digits, the first six minus 140000 are the carry, the last four
% the low limb (carry by offset).
%\end{lverb}
%    \begin{macrocode}
%    \end{macrocode}
%\begin{lverb}
% \CALX_tp <count>.<native blocks>/!: the limbs, LS first, as pairs
% <limb>,0!, exactly <count> of them (zero limbs added on top; a top
% limb beyond <count> is dropped: zero by construction).
% \CALX_tq$empty: same, plain <limb>!.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_tp #1.%
  {\ifnum#1>\xint_c_ \expandafter\CALX_tpa\else\expandafter\CALX_tpg\fi
   #1.}%
\def\CALX_tpg #1.#2/!{}%
\def\CALX_tpa #1.#2!{\CALX_gsl#2\CALX_tpe/\CALX_tpb#1.#2!}%
\def\CALX_tpe/\CALX_tpb#1./!{\CALX_tpz#1.}%
\def\CALX_tpb #1.1#2#3#4#5#6#7#8#9!%
{%
    #6#7#8#9,0!\ifnum#1>\xint_c_i #2#3#4#5,0!\fi
    \expandafter\CALX_tp\the\numexpr#1-2.%
}%
\def\CALX_tpz #1.%
  {\ifnum#1>\xint_c_ 0000,0!\expandafter\CALX_tpz\the\numexpr#1-1.\fi}%
\def\CALX_tq #1.%
  {\ifnum#1>\xint_c_ \expandafter\CALX_tqa\else\expandafter\CALX_tpg\fi
   #1.}%
\def\CALX_tqa #1.#2!{\CALX_gsl#2\CALX_tqe/\CALX_tqb#1.#2!}%
\def\CALX_tqe/\CALX_tqb#1./!{\CALX_tqz#1.}%
\def\CALX_tqb #1.1#2#3#4#5#6#7#8#9!%
{%
    #6#7#8#9!\ifnum#1>\xint_c_i #2#3#4#5!\fi
    \expandafter\CALX_tq\the\numexpr#1-2.%
}%
\def\CALX_tqz #1.%
  {\ifnum#1>\xint_c_ 0000!\expandafter\CALX_tqz\the\numexpr#1-1.\fi}%
\def\CALX_tr #1.%
  {\ifnum#1>\xint_c_ \expandafter\CALX_tra\else\expandafter\CALX_tpg\fi
   #1.}%
\def\CALX_tra #1.#2!{\CALX_gsl#2\CALX_tre/\CALX_trb#1.#2!}%
\def\CALX_tre/\CALX_trb#1./!{\CALX_trz#1.}%
\def\CALX_trb #1.1#2#3#4#5#6#7#8#9!%
{%
    0,#6#7#8#9!\ifnum#1>\xint_c_i 0,#2#3#4#5!\fi
    \expandafter\CALX_tr\the\numexpr#1-2.%
}%
\def\CALX_trz #1.%
  {\ifnum#1>\xint_c_ 0,0000!\expandafter\CALX_trz\the\numexpr#1-1.\fi}%
\def\CALX_gsl #1/{}%
%    \end{macrocode}
%\begin{lverb}
% Kernels. \CALX_sin_h <K>.<s><D>.<e>.<blocks>\xint: (K unused), same
% for \CALX_cos_h. Schedule macro \CALX_ts<s|c><P>: <b_0>.<A>.{d}{skip}
% {n}{C}{T_N} for level N-1, then \CALX_lv{d}{skip}{n}{C} for the next
% levels, \CALX_lend{}{}{}{}.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_sin_h #1.%
{%
    \ifnum\CALX_trigdigits<\xint_c_ix
      \xint_dothis\CALX_sin_q\fi
    \ifcsname CALX_tfs\the\numexpr\CALX_trigdigits\endcsname
      \xint_dothis\CALX_sin_fixed\fi
    \xint_orthat\CALX_sin_scheduled
}%
\def\CALX_sin_fixed #1\xint:%
   {\csname CALX_tfs\the\numexpr\CALX_trigdigits\endcsname
    \xint:#1\xint: s}%
\def\CALX_sin_scheduled #1\xint:%
   {\expandafter\CALX_sha\romannumeral`&&@\csname
    CALX_tss\the\numexpr\CALX_trigdigits\endcsname\xint:#1\xint: s}%
\def\CALX_cos_h #1.%
{%
    \ifnum\CALX_trigdigits<\xint_c_ix
      \xint_dothis\CALX_cos_q\fi
    \ifcsname CALX_tfc\the\numexpr\CALX_trigdigits\endcsname
      \xint_dothis\CALX_cos_fixed\fi
    \xint_orthat\CALX_cos_scheduled
}%
\def\CALX_cos_fixed #1\xint:%
   {\csname CALX_tfc\the\numexpr\CALX_trigdigits\endcsname
    \xint:#1\xint: c}%
\def\CALX_cos_scheduled #1\xint:%
   {\expandafter\CALX_sha\romannumeral`&&@\csname
    CALX_tsc\the\numexpr\CALX_trigdigits\endcsname\xint:#1\xint: c}%
%    \end{macrocode}
%\begin{lverb}
% u 10^(4 b_0) < 1 iff D + 8e + 2 b_0 <= 0: then sin X = round_P(X),
% cos X = 1 (b_0 >= A, 4A >= P + 3: u/6 < 0.005 10^-P).
%
% Generic path, all on the kernel CALX_Z:
% X = N 10^(8e) (nb blocks), z = -e - nb >= 0 zero blocks, X' = N 10^(-8nb)
% in [10^-8, 1): its limbs are those of N (\CALX_shr), X = X'
% 10^(-8z). Square level (\CALX_Zvq): U = X', T = X' on b_0+1 limbs
% (\CALX_tku, \CALX_tkn), output -X'^2 10^(4(b_0+1)) (|err| < 2.5 units);
% \CALX_shu: U_0 list = 4z zero limbs, these limbs, 0!0!0!0!. Series
% levels; sin and B: level 0 negated (\CALX_Zun), \CALX_shw swaps in the
% X' list (carried in the stream after the descriptors), product level
% (\CALX_Zvp, T = T_0 + 3 zero limbs): Y = X' T_0 10^12 on A+4 limbs,
% |err| < 1 unit (relative < 10^(-4A-4)), \CALX_shx; cos and A: level 0
% floor carries, \CALX_shy. \CALX_shf: limbs dddd! (one zero limb in
% front, one appended if needed: <pairs>.<m0>.{pre}{post} static per P),
% calxtrig's \CALX_rsa (m = m0 + z for sin), \CALX_sho<s|c|A|B>: one
% rounding to P (s, c) or P+4 with the continuation (A, B).
% Schedule \CALX_ts<s|c><P> = <b_0>.<A>.{T_N}<S><Q><F>, three macros
% with one parameter (the dynamic header) whose bodies are the level
% descriptors: inserted by expansion, never grabbed.
% Stream: \CALX_sha <b_0>.<A>.{T_N}<S><Q><F>\xint:
% <s><D>.<e>.<blocks>\xint:<kind>.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_sha #1.#2.#3\xint:#4#5.#6.%
{%
    \ifnum\numexpr#5+8*#6+2*#1<\xint_c_i
      \xint_dothis\CALX_sha_tiny\fi
    \xint_orthat\CALX_sha_regular #1.#2.#3\xint:#4#5.#6.%
}%
\def\CALX_sha_tiny #1.#2.#3\xint:#4#5.#6.#7\xint:#8%
  {\csname CALX_shz#8\endcsname#4#5.#6.#7\xint:}%
\def\CALX_sha_regular #1.#2.#3\xint:#4#5.#6.#7\xint:#8%
{%
    \expandafter\CALX_shb\expanded{{\CALX_shr#7\CALX_Zq!\relax}}%
      #3#1.\the\numexpr-#6-(#5+3)/8.#4#8%
}%
\def\CALX_shr #1#2!{\CALX_Zgob#1\CALX_shre\CALX_Zq\CALX_shrb#2!}%
\def\CALX_shrb #1#2#3#4#5#6#7#8!#9\relax{\CALX_shr#9\relax#1#2#3#4!#5#6#7#8!}%
\def\CALX_shre\CALX_Zq\CALX_shrb!#1\relax{}%
\def\CALX_shzs #1\xint:{\CALX_fnround{\CALX_trigdigits}{F#1}}%
\def\CALX_shzc #1\xint:{ F+1.0.100000001!}%
%    \end{macrocode}
%\begin{lverb}
% {X' limbs}{T_N}<S><Q><F><b_0>.<z>.: the square level (<Q>{header})
%\end{lverb}
%    \begin{macrocode}
\def\CALX_shb #1#2#3#4#5#6.#7.%
{%
    \expandafter#4\expandafter{\expanded{\expandafter\CALX_tku\expandafter
      \CALX_tkn\the\numexpr#6+1\expandafter.\expanded{#1\CALX_Zzr#6.0!}/%
      \noexpand\CALX_Zq{\CALX_Zbt#1\CALX_Zq!}}}{#2}#3#5#7.%
}%
\def\CALX_tkn #1{\noexpand\CALX_Zn#1.}%
%    \end{macrocode}
%\begin{lverb}
% after the square level: U_0 list, the series (<S>{header})
%\end{lverb}
%    \begin{macrocode}
\def\CALX_shu #1#2\CALX_Zq#3#4#5#6.%
{%
    \expandafter#4\expandafter{\expanded{\unexpanded{#3}.\noexpand\CALX_Zq
      {\expandafter\CALX_Zzr\the\numexpr4*#6.\CALX_shux#20!0!0!0!}}}{#1}#5#6.%
}%
\def\CALX_shux #1.{#1!}%
%    \end{macrocode}
%\begin{lverb}
% end of the series: <F>{output\CALX_Zq{X' list}}
%\end{lverb}
%    \begin{macrocode}
\def\CALX_shw #1#2\CALX_Zq#3#4{#4{#2\CALX_Zq{#3}}}%
\def\CALX_shx #1#2.#3\CALX_Zq#4#5.#6#7{\CALX_shf#4#5.#6#7{#2}{#3}}%
\def\CALX_shy #1.#2\CALX_Zq#3#4#5.#6#7{\CALX_shf#4 0.+#7{#1}{#2}}%
\def\CALX_shf #1.#2.#3#4#5.#6#7#8#9%
{%
    \expandafter\CALX_shg\expanded{#3\expandafter\xint_gobble_i
      \the\numexpr10000+#8!#9#4\relax#1.\the\numexpr#2+#5.}#6#7%
}%
\def\CALX_shg #1\relax#2.#3.#4#5%
  {\csname CALX_sho#5\expandafter\endcsname
   \expanded{{\CALX_rsa#2.#3.\CALX_bp#4#1}}}%
\def\CALX_shos{\CALX_fnround{\CALX_trigdigits}}%
\let\CALX_shoc\CALX_shos
\def\CALX_shoA #1#2%
  {\expandafter#2\expandafter{\romannumeral0\CALX_fnround
   {\CALX_trigdigits+4}{#1}}}%
\let\CALX_shoB\CALX_shoA
%    \end{macrocode}
%\begin{lverb}
% Load time: the coefficients floor(10^140 c_k), k = 0..40
% (iterated floor division by (2k)(2k+1), resp. (2k-1)(2k)), are stored
% in calxdata.tex as 35 groups of 4 digits <dddd>!, LS first in
% \CALX_cd<s|c><k>, MS first in \CALX_cm<s|c><k> (generator
% gencalxdata.py). The limbs of floor(c_k 10^(4A)) are groups 35 - A + 1
% to 35 (LS first): \CALX_tks<m> skips m groups (7 per call), \CALX_tkt<n>
% (\CALX_tktx: 7 per call) takes n groups, each given as argument to a
% converter (\CALX_tkr: item 0,<limb>!; \CALX_tkq: <limb>!; \CALX_tkm:
% <limb>), then drops the rest up to /.
%
% \CALX_tcoef{<s|c>}{<k>}{<A>}{<count>}<conv> (<conv> \CALX_tr or
% \CALX_tq): <count> limbs of floor(c_k 10^(4A)), LS first, as items
% (\CALX_tr) or limbs (\CALX_tq).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_tcoef #1#2#3#4#5%
{%
    \expandafter\CALX_tka\expandafter#5\the\numexpr35-(#3)\expandafter.%
    \the\numexpr#4\expandafter.%
    \romannumeral`&&@\csname CALX_cd#1\the\numexpr#2\endcsname/%
}%
\def\CALX_tka #1#2.%
  {\csname CALX_tks#2\expandafter\endcsname
   \csname CALX_tk\ifx#1\CALX_tr r\else q\fi\endcsname}%
\def\CALX_tkr #1{0,#1!}\def\CALX_tkq #1{#1!}\def\CALX_tkm #1{#1}%
\def\CALX_tku #1#2.%
  {\csname CALX_tkt\ifnum#2>\xint_c_vi x\else#2\fi\endcsname#1#2.}%
\expandafter\def\csname CALX_tktx\endcsname #1#2.#3!#4!#5!#6!#7!#8!#9!%
  {#1{#3}#1{#4}#1{#5}#1{#6}#1{#7}#1{#8}#1{#9}%
   \expandafter\CALX_tku\expandafter#1\the\numexpr#2-7.}%
\expandafter\def\csname CALX_tkt0\endcsname#1#2.#3/{}%
\expandafter\def\csname CALX_tkt1\endcsname#1#2.#3!#4/{#1{#3}}%
\expandafter\def\csname CALX_tkt2\endcsname#1#2.#3!#4!#5/{#1{#3}#1{#4}}%
\expandafter\def\csname CALX_tkt3\endcsname#1#2.#3!#4!#5!#6/%
  {#1{#3}#1{#4}#1{#5}}%
\expandafter\def\csname CALX_tkt4\endcsname#1#2.#3!#4!#5!#6!#7/%
  {#1{#3}#1{#4}#1{#5}#1{#6}}%
\expandafter\def\csname CALX_tkt5\endcsname#1#2.#3!#4!#5!#6!#7!#8/%
  {#1{#3}#1{#4}#1{#5}#1{#6}#1{#7}}%
\expandafter\def\csname CALX_tkt6\endcsname#1#2.#3!#4!#5!#6!#7!#8!#9/%
  {#1{#3}#1{#4}#1{#5}#1{#6}#1{#7}#1{#8}}%
\expandafter\def\csname CALX_tks0\endcsname#1{\CALX_tku#1}%
\expandafter\def\csname CALX_tks1\endcsname#1#2.#3!{\CALX_tku#1#2.}%
\expandafter\def\csname CALX_tks2\endcsname#1#2.#3!#4!{\CALX_tku#1#2.}%
\expandafter\def\csname CALX_tks3\endcsname#1#2.#3!#4!#5!{\CALX_tku#1#2.}%
\expandafter\def\csname CALX_tks4\endcsname#1#2.#3!#4!#5!#6!%
  {\CALX_tku#1#2.}%
\expandafter\def\csname CALX_tks5\endcsname#1#2.#3!#4!#5!#6!#7!%
  {\CALX_tku#1#2.}%
\expandafter\def\csname CALX_tks6\endcsname#1#2.#3!#4!#5!#6!#7!#8!%
  {\CALX_tku#1#2.}%
\expandafter\def\csname CALX_tks7\endcsname#1#2.#3!#4!#5!#6!#7!#8!#9!%
  {\CALX_tku#1#2.}%
\def\CALX_tmpa #1%
{%
    \expandafter\edef\csname CALX_tks#1\endcsname##1##2.##3!##4!%
      ##5!##6!##7!##8!##9!{\expandafter\noexpand
      \csname CALX_tks\the\numexpr#1-7\endcsname##1##2.}%
    \ifnum#1<35 \expandafter\CALX_tmpa\expandafter{\the\numexpr#1+1}\fi
}%
\CALX_tmpa{8}\let\CALX_tmpa\undefined
%    \end{macrocode}
%\begin{lverb}
% \CALX_tdef{<s|c>}{<P>}{<A>}{<N>}{<n_N>}{<b_0>}{<b>.<n>. ...}: the
% schedule \CALX_ts<s|c><P>, built in one \edef (the levels are unrolled
% by \CALX_tdg inside it): <b_0>.<A>.{T_N}<S><Q><F> and the macros
% \CALX_tsS, \CALX_tsQ, \CALX_tsF<s|c><P>. \CALX_tlet <s|c>{<P>}{<P'>}:
% same
% schedule as for P'. The table (calxdata.tex, \CALX_tdata) has P >= 33
% only: for P <= 32 sin, cos, asin use the fixed path \CALX_tf.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_tdef #1#2#3#4#5#6#7{\CALX_tdf{#1}{#2}{#3}{#4}{#5}{#6}#7/}%
\def\CALX_tdf #1#2#3#4#5#6#7/%
{%
    \expandafter\edef\csname CALX_ts#1#2\endcsname
    {#6.#3.{\expandafter\CALX_Ztn\expanded{\expandafter\CALX_Zrev
       \expanded{\CALX_tcoef{#1}{#4}{#3}{#5}\CALX_tq}\CALX_Zq!}\relax}%
     \expandafter\noexpand\csname CALX_tsS#1#2\endcsname
     \expandafter\noexpand\csname CALX_tsQ#1#2\endcsname
     \expandafter\noexpand\csname CALX_tsF#1#2\endcsname}%
    \expandafter\edef\csname CALX_tsS#1#2\endcsname##1%
    {\noexpand\CALX_Zd##1\expandafter\CALX_tdg\csname CALX_Zu\if#1sn\else f\fi
       \endcsname{#1}{#3}{#4-1}{#5}#7/\noexpand\CALX_shw}%
    \expandafter\edef\csname CALX_tsQ#1#2\endcsname##1%
    {\noexpand\CALX_Zd##1\CALX_Zlevx\CALX_Zvq{\the\numexpr#6+1\relax}%
       {\the\numexpr#6+1\relax}{\the\numexpr#6+1\relax}%
       {\expandafter\CALX_Zzr\the\numexpr#6+1.}\CALX_Zuu
       {\expandafter\CALX_Zzr\the\numexpr#6+2.}\noexpand\CALX_shu}%
    \expandafter\edef\csname CALX_tsF#1#2\endcsname##1%
    {\if#1s\noexpand\CALX_Zd##1\CALX_Zlevx\CALX_Zvp{\the\numexpr#3+4\relax}%
       {\the\numexpr#3+4\relax}{\the\numexpr#3+4\relax}%
       {\expandafter\CALX_Zzr\the\numexpr#3+4.}\CALX_Zuf
       {\expandafter\CALX_Zzr\the\numexpr#3+5.}%
       {\noexpand\CALX_Zl0.\noexpand\CALX_Zl0.\noexpand\CALX_Zl0.}%
       \noexpand\CALX_shx{\ifodd#3 \the\numexpr(#3+5)/2.\the\numexpr(#3+3)/2.%
       {0000!}{}\else\the\numexpr(#3+6)/2.%
                     \the\numexpr(#3+4)/2.{0000!}{0000!}\fi}%
     \else
       \noexpand\CALX_shy##1{\ifodd#3
                             \the\numexpr(#3+3)/2.\the\numexpr(#3+1)/2.%
       {0000!}{0000!}\else\the\numexpr(#3+2)/2.\the\numexpr#3/2.{0000!}{}\fi}%
     \fi}%
}%
%    \end{macrocode}
%\begin{lverb}
% levels k = N-1..0 from the pairs b_k.n_k. (m = n_(k+1)); level 0 with
% C_0 = 10^(4A) on A+1 limbs, carry #1: \CALX_Zun (sin: negated items for
% the product level), \CALX_Zuf (cos: floor carries, digits)
%\end{lverb}
%    \begin{macrocode}
\def\CALX_tdg #1#2#3#4#5#6.#7.#8/%
{%
    \ifnum\numexpr#4\relax>\xint_c_
      \CALX_Zlev{#6}{#5}{#7}{\expandafter\CALX_Zrev\expanded{\CALX_tcoef{#2}%
        {#4}{#3}{#7}\CALX_tq}\CALX_Zq!}\CALX_Zu
      \CALX_tdg#1{#2}{#3}{#4-1}{#7}#8/%
    \else
      \CALX_Zlev{#6}{#5}{#3+1}{1!\expandafter\CALX_Zzr\the\numexpr#3.}#1%
    \fi
}%
\def\CALX_tlet #1#2#3%
  {\expandafter\let\csname CALX_ts#1#2\expandafter\endcsname
   \csname CALX_ts#1#3\endcsname}%
\CALX_tdata\let\CALX_tdata\undefined
%    \end{macrocode}
% \subsection{Series kernels with fixed-arity short products (P up to 40)}
%\begin{lverb}
% Fixed path (P with A <= 11): square short products in the
% manner of l3fp's \__fp_fixed_mul. Limbs
% MS first in chunks of 4 braced groups {l1}{l2}{l3}{l4} (padded); a
% level macro \CALX_m<s>_<n> (generated by tools/trig_genfix.py) takes
% the U chunks, the T chunks (s limbs each, a = ceil(s/4) chunks) and
% the C chunks (n limbs) and computes, column e = n-1 .. -2 (weight
% 10^(4e) at scale 10^(4A)), in one nested \the\numexpr chain (innermost
% column first, its carry added to the outer one by \CALX_pk):
%(
%:   2100000000 + c_e - sum_{s-i-j=e} u_i t_j + carry,
%)
% products by \CALX_hd<d> (diagonal d of a pair of chunks). Columns e <
% -2 are omitted (their sum is < s 10^-4 < 0.002 unit: the budget is
% 2.02 units per level in trig_sched2.py), T_k = columns 0..n-1 of
% C 10^8 - sum, |T_k - (C - R)| < 1.002. Column value x: -1.09992 10^9
% < x < 10^5 for s <= 11 products, 2100000000 + x has 10 digits, the
% first six minus 210000 are the carry (\CALX_pk), the last four the
% limb; the top column has no carry out (0 <= T_k < 10^(4n)) except for
% k = 0 where C_0 = 10^(4A) is 0 modulo 10^(4n): modular, exact.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_pk #1#2#3#4#5#6{+#1#2#3#4#5#6-210000!}%
\def\CALX_pg #1.%
  {\ifnum#1>\xint_c_iii \expandafter\CALX_pga\else\expandafter\CALX_pgb\fi
   #1.}%
\def\CALX_pga #1.#2!#3!#4!#5!%
  {{{#2}{#3}{#4}{#5}}\expandafter\CALX_pg\the\numexpr#1-4.}%
\def\CALX_pgb #1.{\csname CALX_pgr#1\endcsname}%
\expandafter\def\csname CALX_pgr0\endcsname#1;{}%
\expandafter\def\csname CALX_pgr1\endcsname#1!#2;{{{#1}{0000}{0000}{0000}}}%
\expandafter\def\csname CALX_pgr2\endcsname#1!#2!#3;{{{#1}{#2}{0000}{0000}}}%
\expandafter\def\csname CALX_pgr3\endcsname#1!#2!#3!#4;{{{#1}{#2}{#3}{0000}}}%
\def\CALX_bl #1#2#3#4#5#6#7#8{{#1#2#3#4}{#5#6#7#8}}%
%    \end{macrocode}
%\begin{lverb}
% U_0 = floor(u 10^(16 a_0)), a_0 = ceil(b_0/4) chunks, from its native
% blocks (padded on top with zero blocks).
%\end{lverb}
%    \begin{macrocode}
\expandafter\def\csname CALX_ud1\endcsname 1#1!1#2!#3\CALX_qW%
  {{\CALX_bl#2\CALX_bl#1}}%
\expandafter\def\csname CALX_ud2\endcsname 1#1!1#2!1#3!1#4!#5\CALX_qW%
  {{\CALX_bl#4\CALX_bl#3}{\CALX_bl#2\CALX_bl#1}}%
\expandafter\def\csname CALX_ud3\endcsname 1#1!1#2!1#3!1#4!1#5!1#6!#7\CALX_qW%
  {{\CALX_bl#6\CALX_bl#5}{\CALX_bl#4\CALX_bl#3}{\CALX_bl#2\CALX_bl#1}}%
%    \end{macrocode}
%\begin{lverb}
% u: M (D <= 40 digits, n <= 5 blocks) as 4a limbs (a = ceil(n/2)
% chunks, \CALX_xm<n>), exact square M^2 (\CALX_sq<a>, 2a chunks;
% columns of at most 10 products: 10^9 + column + carry < 2 10^9 has 10
% digits, \CALX_pkq), then U_0 = floor(M^2 10^(16(e + a_0))): the shift
% is a whole number of chunks (\CALX_fuq). D > 40: native square and
% shifts (\CALX_fug).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fu #1.#2.%
{%
    \ifnum#2>40 \expandafter\CALX_fug\else\expandafter\CALX_fuk\fi #1.#2.%
}%
\def\CALX_fuk #1.#2.#3.#4\xint:%
{%
    \expandafter\CALX_fuq\expanded{{\csname
      CALX_xm\the\numexpr(2*#2+7)/16\endcsname#4}#1.#3.%
      \the\numexpr((2*#2+7)/16)/2.}%
}%
%    \end{macrocode}
%\begin{lverb}
% Shift k = e + a_0 < a_0 (U_0 < 10^(16 a_0)): k >= 0 appends k zero
% chunks, k < 0 keeps the first 2a + k chunks of M^2 (\CALX_kp<j>); the
% delta = 2a + k - a_0 top chunks (zero) are gobbled, or -delta zero
% chunks are added on top.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fuq #1#2.#3.#4.%
{%
    \expandafter\CALX_fur\the\numexpr#3+#2\expandafter.%
    \expanded{{\csname CALX_sq#4\endcsname#1}}#2.#4.%
}%
\def\CALX_fur #1.#2#3.#4.%
{%
    \expandafter\CALX_fus\expanded{\ifnum#1<\xint_c_
      {\csname CALX_kp\the\numexpr2*#4+#1\endcsname#2\CALX_qW}%
      \else{#2\csname CALX_zc#1\endcsname}\fi}%
    \the\numexpr2*#4+#1-#3.%
}%
\def\CALX_fus #1#2.%
   {\csname CALX_\ifnum#2<\xint_c_ zc\the\numexpr-#2\else
    gb#2\fi\endcsname#1}%
\expandafter\def\csname CALX_zc0\endcsname{}%
\expandafter\def\csname CALX_zc1\endcsname{{{0000}{0000}{0000}{0000}}}%
\expandafter\def\csname CALX_zc2\endcsname
  {{{0000}{0000}{0000}{0000}}{{0000}{0000}{0000}{0000}}}%
\expandafter\def\csname CALX_zc3\endcsname
  {{{0000}{0000}{0000}{0000}}{{0000}{0000}{0000}{0000}}%
   {{0000}{0000}{0000}{0000}}}%
\expandafter\def\csname CALX_gb0\endcsname{}%
\expandafter\let\csname CALX_gb1\endcsname\xint_gobble_i
\expandafter\let\csname CALX_gb2\endcsname\xint_gobble_ii
\expandafter\let\csname CALX_gb3\endcsname\xint_gobble_iii
\expandafter\let\csname CALX_gb4\endcsname\xint_gobble_iv
\expandafter\let\csname CALX_gb5\endcsname\xint_gobble_v
\expandafter\let\csname CALX_gb6\endcsname\xint_gobble_vi
\expandafter\let\csname CALX_gb7\endcsname\xint_gobble_vii
\expandafter\def\csname CALX_kp1\endcsname#1#2\CALX_qW{{#1}}%
\expandafter\def\csname CALX_kp2\endcsname#1#2#3\CALX_qW{{#1}{#2}}%
\expandafter\def\csname CALX_kp3\endcsname#1#2#3#4\CALX_qW{{#1}{#2}{#3}}%
\expandafter\def\csname CALX_kp4\endcsname#1#2#3#4#5\CALX_qW
  {{#1}{#2}{#3}{#4}}%
\expandafter\def\csname CALX_kp5\endcsname#1#2#3#4#5#6\CALX_qW
  {{#1}{#2}{#3}{#4}{#5}}%
\def\CALX_pkq #1#2#3#4#5#6{+#1#2#3#4#5#6-100000!}%
\def\CALX_fug #1.#2.#3.#4\xint:%
{%
    \expandafter\CALX_fua\romannumeral0\CALX_nshr{\numexpr-16*#3-16*#1}%
      {\romannumeral0\CALX_nshl{\numexpr16*#3+16*#1}{\romannumeral0\CALX_nmul
      {N+\the\numexpr(2*#2+7)/16.#4}{N+\the\numexpr(2*#2+7)/16.#4}}}%
    \xint:#1.%
}%
\def\CALX_fua N#1#2.#3\xint:#4.%
{%
    \csname CALX_ud#4\endcsname#3100000000!100000000!100000000!%
    100000000!100000000!100000000!\CALX_qW
}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_fv{<m>}{<C chunks>}{<T chunks>}{<U_0 chunks>}: one level. The
% product macro \CALX_m<s>_<n> takes T, C, then the first ceil(s/4)
% chunks of U_0 untruncated (no extraction of the top s limbs: the
% error is not larger, see tools/trig_genfix.py) and gobbles the others up to
% \CALX_qW.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fv #1#2#3#4%
  {\expandafter\CALX_fw\expanded{{#1#3#2#4\CALX_qW}}{#4}}%
\def\CALX_fw #1#2#3#4#5{#3{#4}{#5}{#1}{#2}}%
\def\CALX_fend #1#2#3#4{ {#3}}%
%    \end{macrocode}
%\begin{lverb}
% Kernel entry, schedule \CALX_tf<s|c><P>: <a_0>.<b_0>.<A>.{m}{C}{T_N}
% for level N-1, then \CALX_fv{m}{C} ..., \CALX_fend{}{}.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fha #1.#2.#3.#4\xint:#5#6.#7.#8\xint:#9%
{%
    \ifnum\numexpr#6+8*#7+2*#2<\xint_c_i \CALX_fhj\fi
    \expandafter\CALX_fhb\expanded{{\CALX_fu #1.#6.#7.#8\xint:}}%
    #4\xint:{#9}{#5#6.#7.#8}{#3}%
}%
\def\CALX_fhj\fi\expandafter\CALX_fhb\expanded#1#2\xint:#3#4#5%
   {\fi\csname CALX_shz#3\endcsname#4\xint:}%
\def\CALX_fhb #1#2#3#4#5\xint:%
{%
    \expandafter\CALX_fhc\expanded{\romannumeral0\CALX_fv{#2}{#3}{#4}{#1}%
      #5}
}%
\def\CALX_fhc #1#2#3#4{\csname CALX_fk#2\endcsname{#1}#3.#4.}%
%    \end{macrocode}
%\begin{lverb}
% End: S (or C) = chunks, D = 16c digits (c = ceil(A/4) chunks, top limb
% >= 6900), as a native float F+16c.-2c.<blocks> (\CALX_sb<c>). sin X =
% round_P(X S) by the exact product of \CALX_fm_g (calxfp.sty), cos X =
% round_P(C).
%
% For D <= 40, \CALX_fku replaces \CALX_fm_g (\CALX_fkt for D > 40):
% exact product M S (M as a = ceil(n/2) chunks by
% \CALX_xm<n>, S = T_0 as c chunks) by \CALX_pm<a>_<c> (generated,
% tools/trig_genpm.py), limbs MS first, normalized by \CALX_rsa (of the
% reduction B1: strip, reverse, exact D), e = e_X - 2c, then one
% \CALX_fround to P (same result as \CALX_fm_g: exact product, one
% rounding).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_sbb #1#2#3#4{1#3#4!1#1#2!}%
\expandafter\def\csname CALX_sb1\endcsname #1{\CALX_sbb#1}%
\expandafter\def\csname CALX_sb2\endcsname #1#2{\CALX_sbb#2\CALX_sbb#1}%
\expandafter\def\csname CALX_sb3\endcsname #1#2#3%
  {\CALX_sbb#3\CALX_sbb#2\CALX_sbb#1}%
\def\CALX_fks #1#2#3.#4.#5.#6.%
{%
    \ifnum#3>40 \xint_dothis\CALX_fkt\fi
    \xint_orthat\CALX_fku{#1}#2#3.#4.#5.#6.%
}%
\def\CALX_fku #1#2#3.#4.#5.#6.%
{%
    \CALX_fnround{\CALX_trigdigits}{\csname
      CALX_pm\the\numexpr((2*#3+7)/16)/2\relax
      _\the\numexpr(#6+1)/4\expandafter\endcsname
      \expanded{\csname CALX_xm\the\numexpr(2*#3+7)/16\endcsname#5#1;#2%
      \the\numexpr2*(((2*#3+7)/16)/2+(#6+1)/4).%
      \the\numexpr2*((#6+1)/4)-#4.}}%
}%
\def\CALX_pmh #1#2#3#4#5#6{\CALX_pmi}%
\def\CALX_pmi #1;#2#3.#4.{\expanded{\CALX_rsa#3.#4.\CALX_bp#2#1}}%
\def\CALX_fkt #1#2#3.#4.#5.#6.%
{%
    \expandafter\CALX_fm_g\expanded{{#2}{#3}{#4}{#5}{+}%
      {\the\numexpr16*((#6+1)/4)}{-\the\numexpr2*((#6+1)/4)}%
      {\csname CALX_sb\the\numexpr(#6+1)/4\endcsname#1}}{\CALX_trigdigits}%
}%
\def\CALX_fkc #1#2#3.#4.#5.#6.%
{%
    \CALX_fnround{\CALX_trigdigits}{\expanded{F+\the\numexpr16*((#6+1)/4).%
      -\the\numexpr2*((#6+1)/4).%
      \csname CALX_sb\the\numexpr(#6+1)/4\endcsname#1}}%
}%
%    \end{macrocode}
%\begin{lverb}
% Load time: chunks of floor(c_k 10^(4A)) mod 10^(4n), n limbs.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fsl #1#2#3#4#5#6#7#8%
  {\ifx\CALX_qW#1\else{#1#2#3#4#5#6#7#8}\expandafter\CALX_fsl\fi}%
\def\CALX_fpl #1#2%
  {\ifx\CALX_qW#1\else{\CALX_bl#1\CALX_bl#2}\expandafter\CALX_fpl\fi}%
\def\CALX_tkd #1#2#3#4%
{%
    \expandafter\CALX_tke\the\numexpr(#3)-(#4)\expandafter.%
    \the\numexpr#4\expandafter.%
    \romannumeral`&&@\csname CALX_cm#1\the\numexpr#2\endcsname/%
}%
\def\CALX_tke #1.{\csname CALX_tks#1\endcsname\CALX_tkm}%
\def\CALX_fco #1#2#3#4%
  {\expandafter\CALX_fcoa\expanded{1\CALX_tkd{#1}{#2}{#3}{#4}}\xint:#4.}%
\def\CALX_fcoa 1#1\xint:#2.%
{%
    \expandafter\CALX_fpl\expanded{\expandafter\CALX_fsl\expanded{#1%
      \xintReplicate{16*((#2+1)/4)-4*#2}{0}}%
      \CALX_qW\CALX_qW\CALX_qW\CALX_qW\CALX_qW\CALX_qW\CALX_qW\CALX_qW}%
    \CALX_qW\CALX_qW
}%
\def\CALX_fdef #1#2#3#4#5#6#7%
  {\ifnum#3>9 \expandafter\CALX_fdf\else\expandafter\CALX_gdf\fi
   {#1}{#2}{#3}{#4}{#5}{#6}#7/}%
\def\CALX_fdf #1#2#3#4#5#6#7.#8.#9/%
{%
    \edef\CALX_tacc{\noexpand\CALX_fha\the\numexpr(#6+1)/4.#6.#3.%
      {\expandafter\noexpand\csname CALX_m#7_#8\endcsname}%
      {\CALX_fco{#1}{#4-1}{#3}{#8}}{\CALX_fco{#1}{#4}{#3}{#5}}}%
    \CALX_fdg{#1}{#3}{#4-2}#9/%
    \expandafter\def\csname CALX_tf#1#2\expandafter\endcsname\expandafter
      {\CALX_tacc\CALX_fend{}{}}%
}%
\def\CALX_fdg #1#2#3#4/%
  {\if\relax\detokenize{#4}\relax\else\CALX_fdh{#1}{#2}{#3}#4/\fi}%
\def\CALX_fdh #1#2#3#4.#5.#6/%
{%
    \edef\CALX_tacc{\unexpanded\expandafter{\CALX_tacc}\noexpand\CALX_fv
      {\expandafter\noexpand\csname CALX_m#4_#5\endcsname}%
      {\CALX_fco{#1}{#3}{#2}{#5}}}%
    \CALX_fdg{#1}{#2}{#3-1}#6/%
}%
%    \end{macrocode}
%\begin{lverb}
% Flat path (A <= 9, that is P <= 32): the levels are the
% fixed-point multiply-subtract macros \CALX_xf<s><n> of calxfp.sty,
% limbs flat from one level to the next (no packing, no \expanded per
% level). \CALX_tf<s|c><P> is <handler><a_0>.<b_0>.<A>.<chain> (the
% handler is \CALX_fha for A > 9); the chain \CALX_tg<s|c><P> takes the
% U_0 chunks (#1 to #3, padded with empty groups, up to \xint:):
%(
%:  \CALX_xf<..>#1{T_N limbs}<U..><C> \CALX_xf<..>{#1}<U..><C> ...
%:  \CALX_xf<..>{#1}<U..><C> \CALX_ge<A>{}
%)
% <U..> is #2 (b = 5..8) or #2#3 (b = 9), <C> the c arguments and text
% of the contract of \CALX_xf (\CALX_gcf ... \CALX_gcoa{n-1}{b-6}); T_N
% by \CALX_gcf ... \CALX_gtna. \CALX_gcf computes as \CALX_fco, its
% final macro being given in the stream. \CALX_ge<A> receives T_0 (A
% limbs) then the finisher \CALX_gk<k> placed by \CALX_gha (k the kind
% letter, one \csname per call), then {X}{A}; it passes T_0 as chunks.
% \CALX_gks, \CALX_gkc call \CALX_fks, \CALX_fkc as \CALX_fhc does.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_gha #1.#2.#3.#4\xint:#5#6.#7.#8\xint:#9%
{%
    \ifnum\numexpr#6+8*#7+2*#2<\xint_c_i \CALX_ghj#9\fi
    \expandafter#4\expanded{\CALX_fu #1.#6.#7.#8\xint:{}{}\xint:%
      \expandafter\noexpand\csname CALX_gk#9\endcsname}{#5#6.#7.#8}{#3}%
}%
\def\CALX_ghj #1\fi #2\expanded#3#4#5%
  {\fi\csname CALX_shz#1\endcsname#4\xint:}%
\def\CALX_gl #1%
  {\ifcase#1\or a\or b\or c\or d\or e\or f\or g\or h\or i\or j\fi}%
\def\CALX_gsh #1#2%
  {\expandafter\noexpand\csname CALX_xf\CALX_gl{#1}\CALX_gl{#2}\endcsname}%
\def\CALX_gut #1{\ifnum#1>4 ####2\fi\ifnum#1>8 ####3\fi}%
\def\CALX_gcf #1#2#3#4#5%
  {\expandafter#5\expanded{1\CALX_tkd{#1}{#2}{#3}{#4}}\xint:}%
\def\CALX_gcoa 1#1\xint:{\CALX_gcb#1\xint:{}}%
\def\CALX_gcb #1#2#3#4#5\xint:#6#7#8%
{%
    \if\relax\detokenize{#5}\relax\CALX_gcp{#1#2#3#4}{#7}{#8}#6%
    \else\CALX_gcb#5\xint:{\CALX_gcp{#1#2#3#4}{#7}{#8}#6}{#7-1}{#8}\fi
}%
\def\CALX_gcp #1#2#3%
{%
    \ifnum\numexpr#2<\numexpr#3\relax{#1}%
    \else+#1;\ifnum\numexpr#2=\xint_c_{}\fi\fi
}%
\def\CALX_gtna 1#1\xint:{\CALX_gtl#1\xint:}%
\def\CALX_gtl #1#2#3#4#5\xint:%
  {{#1#2#3#4}\if\relax\detokenize{#5}\relax\else\CALX_gtl#5\xint:\fi}%
\def\CALX_gdf #1#2#3#4#5#6#7.#8.#9/%
{%
    \edef\CALX_gacc{\CALX_gsh{#7}{#8}####1%
      \CALX_gcf{#1}{#4}{#3}{#5}\CALX_gtna\CALX_gut{#7}%
      \CALX_gcf{#1}{#4-1}{#3}{#8}\CALX_gcoa{#8-1}{#7-6}}%
    \CALX_gdg{#1}{#3}{#4-2}#9/%
    \edef\CALX_gtmp{\noexpand\def
      \expandafter\noexpand\csname CALX_tg#1#2\endcsname
      ####1####2####3####4\noexpand\xint:{\unexpanded\expandafter
      {\CALX_gacc}\expandafter\noexpand\csname CALX_ge#3\endcsname{}}}%
    \CALX_gtmp
    \expandafter\edef\csname CALX_tf#1#2\endcsname
      {\noexpand\CALX_gha\the\numexpr(#6+1)/4.#6.#3.%
       \expandafter\noexpand\csname CALX_tg#1#2\endcsname}%
}%
\def\CALX_gdg #1#2#3#4/%
  {\if\relax\detokenize{#4}\relax\else\CALX_gdh{#1}{#2}{#3}#4/\fi}%
\def\CALX_gdh #1#2#3#4.#5.#6/%
{%
    \edef\CALX_gacc{\unexpanded\expandafter{\CALX_gacc}\CALX_gsh{#4}{#5}%
      {####1}\CALX_gut{#4}\CALX_gcf{#1}{#3}{#2}{#5}\CALX_gcoa{#5-1}{#4-6}}%
    \CALX_gdg{#1}{#2}{#3-1}#6/%
}%
\expandafter\def\csname CALX_ge4\endcsname #1#2#3#4#5%
  {#5{{{#1}{#2}{#3}{#4}}}}%
\expandafter\def\csname CALX_ge5\endcsname #1#2#3#4#5#6%
  {#6{{{#1}{#2}{#3}{#4}}{{#5}{0000}{0000}{0000}}}}%
\expandafter\def\csname CALX_ge6\endcsname #1#2#3#4#5#6#7%
  {#7{{{#1}{#2}{#3}{#4}}{{#5}{#6}{0000}{0000}}}}%
\expandafter\def\csname CALX_ge7\endcsname #1#2#3#4#5#6#7#8%
  {#8{{{#1}{#2}{#3}{#4}}{{#5}{#6}{#7}{0000}}}}%
\expandafter\def\csname CALX_ge8\endcsname #1#2#3#4#5#6#7#8#9%
  {#9{{{#1}{#2}{#3}{#4}}{{#5}{#6}{#7}{#8}}}}%
\expandafter\def\csname CALX_ge9\endcsname #1#2#3#4#5#6#7#8%
  {\CALX_gv{{{#1}{#2}{#3}{#4}}{{#5}{#6}{#7}{#8}}}}%
\def\CALX_gv #1#2#3{#3{#1{{#2}{0000}{0000}{0000}}}}%
\def\CALX_gks #1#2#3{\CALX_fks{#1}#2.#3.}%
\def\CALX_gkc #1#2#3{\CALX_fkc{#1}#2.#3.}%
%    \end{macrocode}
%\begin{lverb}
% Shortened chains: for u small the top levels
% are not needed. Bound: the error of the full chain at u = 0.64, so the worst
% case of the full schedule is kept. The data give \CALX_tg<k><P> (top level
% Mtop = N), \CALX_tg<k><P>_<M> (top level M, same b_k, n_k), then \CALX_fsel
% <k>{<P>}{<Mtop>}{<M>.<t_M>. ...}: the full one becomes \CALX_tg<k><P>_<Mtop>
% and \CALX_tg<k><P> the selector: with t the top limb of U_0 (t = floor(10^4
% u)), the chain is the one of the smallest M with t < t_M (then u < t_M 10^-4
% <= u_max(M)), else Mtop. The \CALX_tf<k><P>_<M> made by \CALX_gdf are
% removed.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_fsel #1#2#3#4%
{%
    \expandafter\let\csname CALX_tg#1#2_#3\expandafter\endcsname
      \csname CALX_tg#1#2\endcsname
    \CALX_fsu{#1}{#2}#4/%
    \expandafter\edef\csname CALX_gq#1#2\endcsname ##1##2\xint:%
      {\noexpand\csname CALX_tg#1#2_\CALX_fsn{#3}#4/\noexpand\endcsname}%
    \expandafter\edef\csname CALX_tg#1#2\endcsname ##1%
      {\expandafter\noexpand\csname CALX_gq#1#2\endcsname
       ##1\noexpand\xint:{##1}}%
}%
\def\CALX_fsn #1#2/%
  {\if\relax\detokenize{#2}\relax#1\else\CALX_fsm{#1}#2/\fi}%
\def\CALX_fsm #1#2.#3.#4/%
  {\noexpand\ifnum##1<#3 \CALX_fsn{#2}#4/\noexpand\else#1\noexpand\fi}%
\def\CALX_fsu #1#2#3/%
  {\if\relax\detokenize{#3}\relax\else\CALX_fsv{#1}{#2}#3/\fi}%
\def\CALX_fsv #1#2#3.#4.#5/%
{%
    \expandafter\let\csname CALX_tf#1#2_#3\endcsname\undefined
    \CALX_fsu{#1}{#2}#5/%
}%
%    \end{macrocode}
% \subsection{Inverse functions; tangent, secant, sinc, degrees}
%\begin{lverb}
% \calxFpAsin{X}: asin of round_P(X), P = \XINTdigits <= 100, after
% xinttrig's @asin_l. With x = |X|, u = sqrt(1 - x^2) (x^2 exact, 1 - x^2
% rounded to 2P+8 digits, square root to P+4 digits); if x > sqrt(2)/2
% (round(10^9 x) > 707106781) the roles of x and u are exchanged and the
% result is pi/2 minus the core value. Core (x <= sqrt(2)/2, y the other
% one): tau = round(10^9 x) (\CALX_as_tau), T = 10^-9 round(tau S/10^9)
% with S from the arcsine series in one \numexpr (\CALX_asb, from
% xinttrig's \XINT_Arcsin_Ib), |asin x - T| about 10^-9; then
%(
%:  D = x cos(T) - y sin(T) = sin(asin x - T),
%)
% cos(T) and sin(T) by the sin/cos kernels rounded to P+4 digits (P <=
% 32: flat path, finishers \CALX_gkA, \CALX_gkB; P > 32: series path
% \CALX_sha, finishers \CALX_shoA, \CALX_shoB), the two products exact
% (\CALX_fmulx), their difference exact (2P+24 digits);
% core = T + D, plus D^3 S(D^2) if P > 16 (S the arcsine series,
% round((P+9)/18) terms, Horner at P digits, \CALX_ash<K>), the sum
% exact. T < 10^-8: core = x + x^3/6 (P <= 16), x + x^3 S(x^2) (P > 16,
% \CALX_as_ser). x = 1: core 0, roles exchanged.
% Operations whose operands have at most the target number of digits
% use the entries without input rounding (\CALX_fsubu, \CALX_fmulu,
% \CALX_faddu, \CALX_fsqru, \CALX_fdivu); the sums and differences of
% exact values are exact (\CALX_faddx, \CALX_fsubx).
%
% \CALX_as_out{core}{n|s}{a}{b}{d}{g} (n: A = core, s: A = pi/2 - core;
% a, b integers as \numexpr text, b = +-1) gives round_P(f (a pi/2 + b
% A)) = round_P(f (k pi/2 + m core)): k = a, m = b (n) or k = a + b, m =
% -b (s). k = 0: no sum; else k pi/2 + m core exact (2P+70 digits, pi/2
% to 130 digits rounded to 2P+70). f = 1/d (d = 1 or 2) times 180/pi if
% g = 1, by \CALX_aso<2d+g-2>: 1/2 by the exact \CALX_fhalf, 180/pi by a
% product at P+8 digits; then one rounding to P. Signs by \CALX_as_m
% (product of two sign characters with the sign of a native). asin,
% asind: a = 0, b = +-1; acos, acosd: a = 1, b = -1 (x >= 0) or 1 (x <
% 0); acsc, asec: the same on y = 1/x (P+4 digits; x = 0:
% DivisionByZero), with 1 - y^2 = (x^2 - 1)/x^2 at P+4 digits from the
% exact x^2 - 1 and x^2 (\CALX_ac_b; no cancellation near |x| = 1).
%
% atan (xinttrig's @atan, no square root): t = |x|, T = t^2, z = 1/(1+T),
% w = 1 - T (P+8 digits); the core on x' = 2tz, y' = |w|z (P+4 digits,
% 2t exact; x'^2 + y'^2 = 1) gives A = 2 atan(t)
% if w > 0, pi - 2 atan(t) if w < 0 (w = 0: A = pi/2); then d = 2. Entry
% \CALX_at_a{c}{s}{g}: c pi/2 + s atan(x) (atan: c = 0, s = 1). Arg(x,y),
% pArg, atan2(y,x) and degree versions: the cases of xinttrig's @Arg,
% @pArg on the signs of y - x, y + x and y (\CALX_ar<kind><y>x><y>-x><y
% sign>), q = y/x, x/y or x/(-y) at P+4 digits, then \CALX_at_b with the
% (c, s) of the case; Arg(0,0) = 0.
%
% tan, cot, sec, csc, sinc and sind, cosd, tand, cotd, secd, cscd:
% \CALX_sc_a gives the quadrant q and the reduced argument u. Radians:
% |x| < 0.8: q = 0, u = x, else the reduction \CALX_red (|x| < 10^4) or
% \CALX_rslow; both kernels
% (\CALX_sc_k): S = sin u, C = cos u rounded to P+4 digits (finishers A
% and B; tiny u: \CALX_shzA, \CALX_shzB). Degrees: \CALX_sc_f (below);
% sind, cosd, secd, cscd compute only the one of S, C they need. Then
% the finisher \CALX_fn<f>{q}{sign}{S}{C}{x}: sin x and cos x from S, C
% by the quadrant (\CALX_scS, \CALX_scC), one division at P+4 digits,
% one rounding to P.
%
% Special values (IEEE 754 / C99 Annex F, calx zero being unsigned): NaN
% (I?) gives I?; sin, cos, tan, cot, sec, csc, the degree versions, asin,
% acos, asind, acosd of +-infinity signal InvalidOperation (I?,
% \CALX_tr_sp); sinc(+-inf) = 0; acsc(+-inf) = 0, asec(+-inf) = pi/2;
% atan(+-inf) = +-pi/2 (atand: +-90); Arg, pArg, atan2 (and degrees)
% with an infinite argument: the atan2 table of C99 (\CALX_ari<kind><y>
% <x>, classes p, m infinities, f finite >= 0, g finite < 0): +-pi/2,
% +-pi/4, +-3pi/4, 0, pi, -pi, pArg brought to [0, 2pi). Poles (tand(90),
% cot(0), ...): division by zero, signal DivisionByZero, I+ or I-.
%\end{lverb}
%    \begin{macrocode}
\edef\CALX_asPi{\romannumeral0\CALX_ffromraw
  {15707963267948966192313216916397514420985846996875529104874722961539082031%
  43104499314017412671058533991074043256641153323546922305[-129]}}%
\def\CALX_as_a #1%
{%
    \if I#1 \xint_dothis\CALX_as_a_special\fi
    \xint_orthat\CALX_as_a_finite #1%
}%
\def\CALX_as_a_special #1#2#3\xint:#4#5{\CALX_tr_sp#2}%
\def\CALX_as_a_finite #1#2#3\xint:#4#5%
  {\CALX_as_b #2#3\xint:#4#5}%
\def\CALX_as_b #1#2.%
{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_as_b_zero\fi
    \ifnum\CALX_trigdigits>100 \xint_dothis\CALX_as_b_invalid\fi
    \xint_orthat\CALX_as_b_regular #1#2.%
}%
\def\CALX_as_b_zero #1#2.#3.#4\xint:#5%
  {\CALX_as_out{F+0.0.}{n}{\if c#51\else0\fi}{\if c#5-\fi#11}{1}}%
\def\CALX_as_b_invalid #1#2.#3.#4\xint:#5%
  {\CALX_as_err{asin, acos: not implemented for Digits > 100}%
    {\if c#51\else0\fi}{\if c#5-\fi#11}{1}}%
\def\CALX_as_b_regular #1#2.#3.#4\xint:#5%
{%
    \expandafter\CALX_as_c\the\numexpr\CALX_trigdigits.%
      F+#2.#3.#4\xint:%
    {\if c#51\else0\fi}{\if c#5-\fi#11}{1}%
}%
\def\CALX_as_err #1#2#3#4#5{\CALX_nsig{InvalidOperation}{#1}{}}%
\def\CALX_as_c #1.#2\xint:%
{%
    \expandafter\CALX_as_d\romannumeral0\CALX_fsubx
      {F+1.0.100000001!}{\CALX_fmulx{#2}{#2}}\xint:%
    #1.#2\xint:%
}%
\def\CALX_as_d F#1#2.%
{%
    \if-#1 \xint_dothis\CALX_as_d_invalid\fi
    \ifnum#2=\xint_c_ \xint_dothis\CALX_as_d_zero\fi
    \xint_orthat\CALX_as_d_regular #1#2.%
}%
\def\CALX_as_d_invalid #1#2.#3\xint:#4.#5\xint:%
  {\CALX_as_err{asin, acos: |x|>1}}%
\def\CALX_as_d_zero #1#2.#3\xint:#4.#5\xint:%
  {\CALX_as_out{F+0.0.}{s}}%
\def\CALX_as_d_regular #1#2.#3\xint:#4.#5\xint:%
{%
    \expandafter\CALX_as_e\romannumeral0\CALX_fsqrt
      {\the\numexpr#4+4\relax}{F#1#2.#3}\xint:#5\xint:%
}%
\def\CALX_as_e #1\xint:#2\xint:%
{%
    \expandafter\CALX_as_f\the\numexpr\CALX_as_tau#2\xint:\expandafter.%
    \the\numexpr\CALX_trigdigits.{#2}{#1}%
}%
\def\CALX_as_f #1.#2.%
{%
    \ifnum#1>707106781 \CALX_as_sw\fi
    \CALX_as_k #1.#2.n%
}%
\def\CALX_as_sw\fi\CALX_as_k #1.#2.n#3#4%
  {\fi\expandafter\CALX_as_k\the\numexpr\CALX_as_tau#4\xint:.#2.s{#4}{#3}}%
\def\CALX_as_k #1.#2.%
{%
    \expandafter\CALX_as_l\the\numexpr
      (\expandafter\CALX_asb\the\numexpr#1*#1/\xint_c_e_ix.)*#1/\xint_c_e_ix.%
    #2.%
}%
\def\CALX_as_l #1.#2.%
{%
    \ifnum#1<\xint_c_x \CALX_as_tj\fi
    \expandafter\CALX_as_n\romannumeral0\CALX_ffromraw{#1[-9]}\xint:%
    #2.%
}%
\def\CALX_as_tj\fi\expandafter\CALX_as_n\romannumeral0\CALX_ffromraw
    #1\xint:#2.#3#4#5{\fi\CALX_as_tiny#2.#3{#4}}%
\def\CALX_as_n F#1\xint:#2.%
  {\CALX_as_kc c{#1}A\CALX_as_o{#1}#2.}%
\def\CALX_as_o #1#2#3.%
  {\CALX_as_kc s{#2}B\CALX_as_p{#1}{#2}#3.}%
\def\CALX_as_p #1#2#3#4.#5#6#7%
{%
    \expandafter\CALX_as_q\romannumeral0%
      \CALX_fsubx{\CALX_fmulx{#6}{#2}}{\CALX_fmulx{#7}{#1}}\xint:{#3}#4.#5%
}%
\def\CALX_as_q #1\xint:#2#3.%
{%
    \ifnum#3>16 \CALX_as_qc\fi
    \CALX_as_r{#1}{#2}#3.%
}%
\def\CALX_as_qc\fi\CALX_as_r#1#2#3.%
{%
    \fi\expandafter\CALX_as_r\expandafter{\romannumeral0\CALX_faddx
      {#1}{\CALX_as_ser{#3}{#1}}}{#2}#3.%
}%
\def\CALX_as_r #1#2#3.%
{%
    \expandafter\CALX_as_out\expandafter{\romannumeral0\CALX_faddx{F#2}{#1}}%
}%
\def\CALX_as_tiny #1.#2#3%
{%
    \expandafter\CALX_as_ty\romannumeral0\ifnum#1>16
      \expandafter\CALX_as_ser\else\expandafter\CALX_as_tq\fi{#1}{#3}\xint:%
    #3\xint:#1.#2%
}%
\def\CALX_as_tq #1#2%
  {\CALX_fdivu{#1}{\CALX_fmul{#1}{#2}{\CALX_fsqr{#1}{#2}}}{F+1.0.100000006!}}%
\def\CALX_as_ty #1\xint:F#2\xint:{\CALX_as_r{#1}{#2}}%
\def\CALX_as_out #1#2#3#4#5#6%
{%
    \CALX_fnround{\CALX_trigdigits}{\csname CALX_aso\the\numexpr2*#5+#6-2%
      \endcsname{\ifnum\numexpr\if s#2#3+(#4)\else#3\fi=\xint_c_
      \expandafter\xint_secondoftwo\else\expandafter\xint_firstoftwo\fi
      {\CALX_faddx
      {\CALX_fmul{\the\numexpr2*\CALX_trigdigits+70\relax}{\CALX_asPi}%
        {\CALX_ffromraw{\the\numexpr\if s#2#3+(#4)\else#3\fi\relax[0]}}}}%
      {\xint_firstofone}%
      {\CALX_as_m{\ifnum\numexpr(#4)\if s#2*(-1)\fi<\xint_c_-\else+\fi}+#1}}}%
}%
\expandafter\def\csname CALX_aso0\endcsname #1{#1}%
\expandafter\def\csname CALX_aso1\endcsname #1%
  {\CALX_fmul{\the\numexpr\CALX_trigdigits+8\relax}{#1}{\CALX_trigR}}%
\expandafter\let\csname CALX_aso2\endcsname\CALX_fhalf
\expandafter\def\csname CALX_aso3\endcsname #1%
  {\CALX_fmul{\the\numexpr\CALX_trigdigits+8\relax}{\CALX_fhalf{#1}}%
   {\CALX_trigR}}%
\def\CALX_as_m #1#2F#3#4.%
  {\expanded{F\ifnum#4=\xint_c_+\else\if\if#1#2+\else-\fi#3+\else-\fi\fi#4.}}%
\def\CALX_ac_a #1%
{%
    \if I#1\xint_dothis\CALX_ac_i\fi
    \xint_orthat{\CALX_ac_f #1}%
}%
\def\CALX_ac_i #1#2\xint:#3%
{%
    \if ?#1\expandafter\xint_firstoftwo\else
      \expandafter\xint_secondoftwo\fi{ I?}%
      {\CALX_as_out{F+0.0.}{n}{\if c#31\else0\fi}{0}{1}{0}}%
}%
\def\CALX_ac_f F#1#2.%
{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_ac_f_zero\fi
    \xint_orthat\CALX_ac_f_regular #1#2.%
}%
\def\CALX_ac_f_zero #1#2.#3.#4\xint:#5%
  {\CALX_nsig{DivisionByZero}{acsc, asec of 0}{}}%
\def\CALX_ac_f_regular #1#2.#3.#4\xint:#5%
{%
    \expandafter\CALX_ac_b\romannumeral0\CALX_fdivu
      {\the\numexpr\CALX_trigdigits+4\relax}{F+1.0.100000001!}%
      {F#1#2.#3.#4}\xint:#5{F#1#2.#3.#4}%
}%
\def\CALX_ac_z #1.#2\xint:{#1}%
\def\CALX_ac_b F#1#2\xint:#3#4%
{%
    \ifnum\CALX_trigdigits>100 \xint_dothis{\CALX_nsig{InvalidOperation}%
      {asin, acos: not implemented for Digits > 100}{}}\fi
    \xint_orthat{\expandafter\CALX_as_d\romannumeral0\CALX_fdiv
      {\the\numexpr\CALX_trigdigits+4\relax}%
      {\CALX_fsubx{\CALX_fmulx{#4}{#4}}{F+1.0.100000001!}}%
      {\CALX_fmulx{#4}{#4}}\xint:\CALX_trigdigits.F+#2\xint:}%
    {\if c#31\else0\fi}{\if c#3-\fi#11}{1}0%
}%
\def\CALX_at_a #1%
{%
    \if I#1\xint_dothis\CALX_at_i\fi
    \xint_orthat{\CALX_at_b #1}%
}%
\def\CALX_at_i #1#2\xint:#3#4#5%
{%
    \if ?#1\expandafter\xint_firstoftwo\else
      \expandafter\xint_secondoftwo\fi{ I?}%
      {\CALX_as_out{F+0.0.}{n}{(#3)+(#4)*(#11)}{0}{1}{#5}}%
}%
\def\CALX_at_b F#1#2.%
{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_at_b_zero\fi
    \ifnum\CALX_trigdigits>100 \xint_dothis\CALX_at_b_invalid\fi
    \xint_orthat\CALX_at_b_regular #1#2.%
}%
\def\CALX_at_b_zero #1#2.#3.#4\xint:#5#6#7%
  {\CALX_as_out{F+0.0.}{n}{2*(#5)}{0}{2}{#7}}%
\def\CALX_at_b_invalid #1#2.#3.#4\xint:#5#6#7%
  {\CALX_nsig{InvalidOperation}{atan: not implemented for Digits > 100}{}}%
\def\CALX_at_b_regular #1#2.#3.#4\xint:#5#6#7%
{%
    \expandafter\CALX_at_c\romannumeral0\CALX_fsqru
      {\the\numexpr\CALX_trigdigits+8\relax}{F+#2.#3.#4}\xint:%
      F+#2.#3.#4\xint:#1{#5}{#6}{#7}%
}%
\def\CALX_at_c #1\xint:#2\xint:%
{%
    \expandafter\CALX_at_cc\romannumeral0\CALX_fdivu
      {\the\numexpr\CALX_trigdigits+8\relax}{F+1.0.100000001!}%
      {\CALX_faddu{\the\numexpr\CALX_trigdigits+8\relax}{F+1.0.100000001!}%
      {#1}}\xint:#1\xint:#2\xint:%
}%
\def\CALX_at_cc #1\xint:#2\xint:%
{%
    \expandafter\CALX_at_d\romannumeral0\CALX_fsubu
      {\the\numexpr\CALX_trigdigits+8\relax}{F+1.0.100000001!}{#2}\xint:%
    #1\xint:%
}%
\def\CALX_at_d F#1#2.%
{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_at_d_zero\fi
    \xint_orthat\CALX_at_d_regular #1#2.%
}%
\def\CALX_at_d_zero #1#2.#3\xint:#4\xint:#5\xint:#6#7#8#9%
  {\CALX_as_out{F+0.0.}{s}{2*(#7)}{(#8)*(#61)}{2}{#9}}%
\def\CALX_at_d_regular #1#2.#3\xint:#4\xint:#5\xint:#6#7#8#9%
{%
    \expandafter\CALX_at_e\romannumeral0\CALX_fmul
      {\the\numexpr\CALX_trigdigits+4\relax}{\CALX_faddx{#5}{#5}}{#4}\xint:%
      \romannumeral0\CALX_fmul{\the\numexpr\CALX_trigdigits+4\relax}%
      {F+#2.#3}{#4}\xint:%
      {\if-#1(2*(#7)+(#8)*2*(#61))\else2*(#7)\fi}%
      {(#8)*(#61)\if-#1*(-1)\fi}{2}{#9}%
}%
\def\CALX_at_e #1\xint:#2\xint:{\expandafter\CALX_as_e#2\xint:#1\xint:}%
\def\CALX_ar_a #1#2#3#4%
{%
    \expandafter\CALX_ar_b\romannumeral0%
      \CALX_fround{\CALX_trigdigits}{#3}%
    {#4}#1#2%
}%
\def\CALX_ar_b #1\xint:#2%
{%
    \expandafter\CALX_ar_c\romannumeral0%
      \CALX_fround{\CALX_trigdigits}{#2}%
    #1\xint:%
}%
\def\CALX_ar_c #1#2\xint:#3#4\xint:#5#6%
{%
    \if I#1\xint_dothis{\CALX_ar_inf{#1#2}{#3#4}#5#6}\fi
    \if I#3\xint_dothis{\CALX_ar_inf{#1#2}{#3#4}#5#6}\fi
    \xint_orthat{\expandafter\CALX_ar_d\romannumeral0\CALX_faddx
      {#1#2}{#3#4}\xint:#1#2\xint:#3#4\xint:#5#6}%
}%
\def\CALX_ar_d F#1#2.#3\xint:#4\xint:#5\xint:%
{%
    \expandafter\CALX_ar_e\the\numexpr\CALX_ar_st#1#2.\expandafter.%
    \romannumeral0\CALX_fsubx{#4}{#5}\xint:#4\xint:#5\xint:%
}%
\def\CALX_tr_sp #1%
{%
    \if ?#1\expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo\fi
    { I?}{\CALX_nsig{InvalidOperation}{trigonometric function of infinity}{}}%
}%
\def\CALX_sc_iz\fi\fi\CALX_tr_sp#1{\fi\fi\space F+0.0.}%
\def\CALX_ar_inf #1#2#3#4%
{%
    \ifcsname CALX_ari#3\CALX_arc#1\xint:\CALX_arc#2\xint:\endcsname
      \expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo\fi
    {\csname CALX_ari#3\CALX_arc#1\xint:\CALX_arc#2\xint:\endcsname{#4}}%
    { I?}%
}%
\def\CALX_arc #1#2\xint:%
  {\if I#1\if ?#2n\else\if+#2p\else m\fi\fi\else\CALX_arf#2\xint:\fi}%
\def\CALX_arf #1#2.#3\xint:{\if-#1\ifnum#2>\xint_c_ g\else f\fi\else f\fi}%
\expandafter\def\csname CALX_ariafm\endcsname%
  {\CALX_as_out{F+0.0.}{n}{2}{0}{1}}%
\expandafter\def\csname CALX_ariafp\endcsname%
  {\CALX_as_out{F+0.0.}{n}{0}{0}{1}}%
\expandafter\def\csname CALX_ariagm\endcsname%
  {\CALX_as_out{F+0.0.}{n}{-2}{0}{1}}%
\expandafter\def\csname CALX_ariagp\endcsname%
  {\CALX_as_out{F+0.0.}{n}{0}{0}{1}}%
\expandafter\def\csname CALX_ariamf\endcsname%
  {\CALX_as_out{F+0.0.}{n}{-1}{0}{1}}%
\expandafter\def\csname CALX_ariamg\endcsname%
  {\CALX_as_out{F+0.0.}{n}{-1}{0}{1}}%
\expandafter\def\csname CALX_ariamm\endcsname%
  {\CALX_as_out{F+0.0.}{n}{-3}{0}{2}}%
\expandafter\def\csname CALX_ariamp\endcsname%
  {\CALX_as_out{F+0.0.}{n}{-1}{0}{2}}%
\expandafter\def\csname CALX_ariapf\endcsname%
  {\CALX_as_out{F+0.0.}{n}{1}{0}{1}}%
\expandafter\def\csname CALX_ariapg\endcsname%
  {\CALX_as_out{F+0.0.}{n}{1}{0}{1}}%
\expandafter\def\csname CALX_ariapm\endcsname%
  {\CALX_as_out{F+0.0.}{n}{3}{0}{2}}%
\expandafter\def\csname CALX_ariapp\endcsname%
  {\CALX_as_out{F+0.0.}{n}{1}{0}{2}}%
\expandafter\def\csname CALX_aripfm\endcsname%
  {\CALX_as_out{F+0.0.}{n}{2}{0}{1}}%
\expandafter\def\csname CALX_aripfp\endcsname%
  {\CALX_as_out{F+0.0.}{n}{0}{0}{1}}%
\expandafter\def\csname CALX_aripgm\endcsname%
  {\CALX_as_out{F+0.0.}{n}{2}{0}{1}}%
\expandafter\def\csname CALX_aripgp\endcsname%
  {\CALX_as_out{F+0.0.}{n}{0}{0}{1}}%
\expandafter\def\csname CALX_aripmf\endcsname%
  {\CALX_as_out{F+0.0.}{n}{3}{0}{1}}%
\expandafter\def\csname CALX_aripmg\endcsname%
  {\CALX_as_out{F+0.0.}{n}{3}{0}{1}}%
\expandafter\def\csname CALX_aripmm\endcsname%
  {\CALX_as_out{F+0.0.}{n}{5}{0}{2}}%
\expandafter\def\csname CALX_aripmp\endcsname%
  {\CALX_as_out{F+0.0.}{n}{7}{0}{2}}%
\expandafter\def\csname CALX_arippf\endcsname%
  {\CALX_as_out{F+0.0.}{n}{1}{0}{1}}%
\expandafter\def\csname CALX_arippg\endcsname%
  {\CALX_as_out{F+0.0.}{n}{1}{0}{1}}%
\expandafter\def\csname CALX_arippm\endcsname%
  {\CALX_as_out{F+0.0.}{n}{3}{0}{2}}%
\expandafter\def\csname CALX_arippp\endcsname%
  {\CALX_as_out{F+0.0.}{n}{1}{0}{2}}%
\def\CALX_ar_st #1#2.{\ifnum#2=\xint_c_ 2\else\if-#1 0\else1\fi\fi}%
\def\CALX_ar_e #1.F#2#3.#4\xint:#5\xint:#6\xint:#7%
{%
    \ifnum\numexpr#1+\CALX_ar_st#2#3.=\xint_c_iv \CALX_ar_zero\fi
    \csname CALX_ar#7\ifnum\CALX_ar_st#2#3.=\xint_c_i 1\else0\fi
      \ifnum#1=\xint_c_i 1\else0\fi\CALX_ar_ys#5\xint:\endcsname{#6}{#5}%
}%
\def\CALX_ar_ys F#1#2.#3\xint:{\if-#1\ifnum#2>\xint_c_ m\else p\fi\else p\fi}%
\def\CALX_ar_zero\fi\csname#1\endcsname#2#3%
  {\fi\CALX_as_out{F+0.0.}{n}{0}{0}{1}}%
\def\CALX_ar_q #1#2%
{%
    \expandafter\CALX_at_b\romannumeral0\CALX_fdivu
      {\the\numexpr\CALX_trigdigits+4\relax}{#1}{#2}\xint:%
}%
\expandafter\def\csname CALX_ara11m\endcsname #1#2%
  {\CALX_ar_q{#1}{#2}{1}{-1}}%
\expandafter\def\csname CALX_ara11p\endcsname #1#2%
  {\CALX_ar_q{#1}{#2}{1}{-1}}%
\expandafter\def\csname CALX_ara10m\endcsname #1#2%
  {\CALX_ar_q{#2}{#1}{-2}{1}}%
\expandafter\def\csname CALX_ara10p\endcsname #1#2%
  {\CALX_ar_q{#2}{#1}{2}{1}}%
\expandafter\def\csname CALX_ara01m\endcsname #1#2%
  {\CALX_ar_q{#2}{#1}{0}{1}}%
\expandafter\def\csname CALX_ara01p\endcsname #1#2%
  {\CALX_ar_q{#2}{#1}{0}{1}}%
\expandafter\def\csname CALX_ara00m\endcsname #1#2%
  {\CALX_ar_q{#1}{\CALX_as_m-+#2}{-1}{1}}%
\expandafter\def\csname CALX_ara00p\endcsname #1#2%
  {\CALX_ar_q{#1}{\CALX_as_m-+#2}{-1}{1}}%
\expandafter\def\csname CALX_arp11m\endcsname #1#2%
  {\CALX_ar_q{#1}{#2}{1}{-1}}%
\expandafter\def\csname CALX_arp11p\endcsname #1#2%
  {\CALX_ar_q{#1}{#2}{1}{-1}}%
\expandafter\def\csname CALX_arp10m\endcsname #1#2%
  {\CALX_ar_q{#2}{#1}{2}{1}}%
\expandafter\def\csname CALX_arp10p\endcsname #1#2%
  {\CALX_ar_q{#2}{#1}{2}{1}}%
\expandafter\def\csname CALX_arp01m\endcsname #1#2%
  {\CALX_ar_q{#2}{#1}{4}{1}}%
\expandafter\def\csname CALX_arp01p\endcsname #1#2%
  {\CALX_ar_q{#2}{#1}{0}{1}}%
\expandafter\def\csname CALX_arp00m\endcsname #1#2%
  {\CALX_ar_q{#1}{\CALX_as_m-+#2}{3}{1}}%
\expandafter\def\csname CALX_arp00p\endcsname #1#2%
  {\CALX_ar_q{#1}{\CALX_as_m-+#2}{3}{1}}%
\def\CALX_sc_a #1%
{%
    \if I#1\xint_dothis\CALX_sc_i\fi
    \xint_orthat\CALX_sc_b
}%
\def\CALX_sc_i #1#2\xint:#3#4%
{%
    \ifx#3\CALX_fnsinc\if ?#1\else\CALX_sc_iz\fi\fi
    \CALX_tr_sp#1%
}%
\def\CALX_sc_b #1#2.%
{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_sc_b_zero\fi
    \ifnum\CALX_trigdigits>100 \xint_dothis\CALX_sc_b_invalid\fi
    \xint_orthat\CALX_sc_b_regular #1#2.%
}%
\def\CALX_sc_b_zero #1#2.#3.#4\xint:#5#6%
  {#5{0}{#1}{F+0.0.}{F+1.0.100000001!}{F+0.0.}}%
\def\CALX_sc_b_invalid #1#2.#3.#4\xint:#5#6%
  {\CALX_nsig{InvalidOperation}{trig: not implemented for Digits > 100}{}}%
\def\CALX_sc_b_regular #1#2.#3.#4\xint:#5#6%
  {\csname CALX_sc_#6\endcsname #2.#3.#4\xint:{#1}#5{F#1#2.#3.#4}}%
%    \end{macrocode}
%\begin{lverb}
% P <= 8, tan, cot, sec, csc, sinc (\CALX_sc_rq, \CALX_sc_rqr: as
% \CALX_sc_r, \CALX_sc_rr): \CALX_sc_kq takes q and r as
% \CALX_sc_k, |r| = A 10^(E-9) (\CALX_rta), U9 = round(10^9 r^2)
% (\CALX_qkz), S9 = 10^9 sin(r)/r, C9 = 10^9 cos(r) (\CALX_sinaux,
% \CALX_cosaux), then one \numexpr per value (all quantities < 2^31):
%(
%:   tan |r| = round(A S9 / C9) 10^(E-9)                    (\CALX_qkt)
%:   cot |r| = round(10^17 / round(A S9 / C9)) 10^(-E-8)     (\CALX_qku)
%:   sec r   = round(10^18 / C9) 10^-9                       (\CALX_qke)
%:   csc |r| = round(round(10^17 / A) 10^9 / S9) 10^(-E-8)   (\CALX_qkr)
%)
% times the sign f of the quadrant table \CALX_kq<t|u|v|w><q> (signs of
% x and r): tan = T, -1/T, cot = 1/T, -T for q even, odd; sec = 1/C,
% -1/S, -1/C, 1/S; csc = 1/S, 1/C, -1/S, -1/C (q = 0..3). Output by
% \CALX_dgo. r is never 0 (B1 gives 10^-W for R = 0).
%
% sinc: |x| < 0.8 (\CALX_sc_kp, \CALX_sc_kps): sinc x = S9 10^-9, no
% division. Otherwise (\CALX_sc_kqs), |x| = A_x 10^(E_x-9), V = round(A
% S9/10^9) (q even, sign of r, minus for q = 2) or V = C9 (q odd, minus
% for q = 3), then one scaled division (\CALX_sc_kqf):
%(
%:   sinc x = s round(V 10^9 / A_x) 10^(e-9)   (V < A_x)
%:   sinc x = s round(V 10^8 / A_x) 10^(e-8)   (V >= A_x)
%)
% with e = E - E_x (q even) or -E_x (q odd).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_sc_r #1.#2.#3\xint:%
{%
    \ifnum\CALX_trigdigits<\xint_c_ix \CALX_sc_rq\fi
    \ifnum\numexpr(#1+8*#2)*10\ifnum\numexpr#1+8*#2=\xint_c_
      +\CALX_trig_top#3\xint:\fi>\xint_c_vii \CALX_sc_rr\fi
    \CALX_sc_k 0.F+#1.#2.#3\xint:%
}%
\def\CALX_sc_rq\fi #1\CALX_sc_k 0.F+#2.#3.#4\xint:%
{%
    \fi
    \ifnum\numexpr(#2+8*#3)*10\ifnum\numexpr#2+8*#3=\xint_c_
      +\CALX_trig_top#4\xint:\fi>\xint_c_vii \CALX_sc_rqr\fi
    \CALX_sc_kp 0.F+#2.#3.#4\xint:%
}%
\def\CALX_sc_rqr\fi\CALX_sc_kp 0.F+#1.#2.#3\xint:%
{%
    \fi
    \ifnum\numexpr#1+8*#2>\xint_c_iv \CALX_rjs\fi
    \CALX_sc_kd\CALX_red #1.#2.#3\xint:\xint:%
}%
\def\CALX_sc_kd #1%
{%
    \ifx#1\CALX_red\expandafter\CALX_sc_kdd\else
      \expandafter\CALX_sc_kds\fi
}%
\def\CALX_sc_kds{\expandafter\CALX_sc_kq\romannumeral0\CALX_rslow}%
\def\CALX_sc_kdd #1.#2.#3\xint:\xint:%
{%
    \expandafter\CALX_sc_kde\the\numexpr#1+8*#2\expandafter.%
    \the\numexpr(2*#1+7)/16\expandafter.%
    \the\numexpr#1+8-8*((2*#1+7)/16).#3\xint:%
}%
\def\CALX_sc_kde #1.#2.#3.#4\xint:%
{%
    \expandafter\CALX_sc_kdf\romannumeral0\expandafter\CALX_rq
    \the\numexpr\CALX_rta#2.#3.#4\xint:.#1.%
}%
\def\CALX_sc_kdf #1.#2#3.#4.#5.#6.#7#8%
{%
    \csname CALX_kdl\ifx#8\CALX_fnsinc z\else\ifx#8\CALX_fntan t\else
      \ifx#8\CALX_fncot u\else\ifx#8\CALX_fnsec v\else w\fi\fi\fi\fi
    \endcsname #1.#2#3.#4.#5.#6.#7%
}%
\expandafter\def\csname CALX_kdlz\endcsname #1.#2#3.#4.#5.#6.#7#8%
  {\CALX_sc_kqy#3.#4.#5.#6.#1#2}%
\def\CALX_sc_kdl #1%
{%
    \expandafter\def\csname CALX_kdl#1\endcsname
      ##1.##2##3.##4.##5.##6.##7##8%
      {\CALX_sc_kqb##3.##4.#1##1##2##7}%
}%
\CALX_sc_kdl t\CALX_sc_kdl u\CALX_sc_kdl v\CALX_sc_kdl w%
\let\CALX_sc_kdl\undefined
\def\CALX_sc_kp #1.F#2#3.#4.#5\xint:#6#7%
{%
    \ifx#7\CALX_fnsinc \xint_dothis\CALX_sc_kps\fi
    \xint_orthat\CALX_sc_kq #1.F#2#3.#4.#5\xint:{#6}#7%
}%
\def\CALX_sc_kps #1.F#2#3.#4.#5\xint:#6#7#8%
{%
    \expandafter\CALX_sc_kpa\the\numexpr#3+8*#4\expandafter.%
    \the\numexpr(2*#3+7)/16\expandafter.%
    \the\numexpr#3+8-8*((2*#3+7)/16).#5\xint:%
}%
\def\CALX_sc_kpa #1.#2.#3.#4\xint:%
  {\expandafter\CALX_sc_kpb\the\numexpr\CALX_rta#2.#3.#4\xint:.#1.}%
\def\CALX_sc_kpb #1.#2.%
{%
    \expandafter\CALX_dgo\the\numexpr
      \expandafter\CALX_sinaux\the\numexpr\CALX_qkz#1.#2...-9.%
}%
\def\CALX_sc_kq #1.F#2#3.#4.#5\xint:#6#7%
{%
    \ifx#7\CALX_fnsinc \xint_dothis\CALX_sc_kqs\fi
    \ifx#7\CALX_fntan \xint_dothis{\CALX_sc_kqx t}\fi
    \ifx#7\CALX_fncot \xint_dothis{\CALX_sc_kqx u}\fi
    \ifx#7\CALX_fnsec \xint_dothis{\CALX_sc_kqx v}\fi
    \ifx#7\CALX_fncsc \xint_dothis{\CALX_sc_kqx w}\fi
    \xint_orthat\CALX_sc_k #1.F#2#3.#4.#5\xint:{#6}#7%
}%
\def\CALX_sc_kqs #1.F#2#3.#4.#5\xint:#6#7#8%
  {\CALX_sc_kqt #8\xint:#1.#2#3.#4.#5\xint:}%
\def\CALX_sc_kqt F#1#2.#3.#4\xint:%
{%
    \expandafter\CALX_sc_kqu\the\numexpr#2+8*#3\expandafter.%
    \the\numexpr(2*#2+7)/16\expandafter.%
    \the\numexpr#2+8-8*((2*#2+7)/16).#4\xint:%
}%
\def\CALX_sc_kqu #1.#2.#3.#4\xint:%
  {\expandafter\CALX_sc_kqv\the\numexpr\CALX_rta#2.#3.#4\xint:.#1.}%
\def\CALX_sc_kqv #1.#2.#3.#4#5.#6.#7\xint:%
{%
    \expandafter\CALX_sc_kqw\the\numexpr#5+8*#6\expandafter.%
    \the\numexpr(2*#5+7)/16\expandafter.%
    \the\numexpr#5+8-8*((2*#5+7)/16).#7\xint:#1.#2.#3#4%
}%
\def\CALX_sc_kqw #1.#2.#3.#4\xint:%
  {\expandafter\CALX_sc_kqy\the\numexpr\CALX_rta#2.#3.#4\xint:.#1.}%
\def\CALX_sc_kqy #1.#2.%
  {\expandafter\CALX_sc_kqz\the\numexpr\CALX_qkz#1.#2..#1.#2.}%
\def\CALX_sc_kqz #1.#2.#3.#4.#5.#6%
{%
    \ifodd#6 \expandafter\CALX_sc_kqo\else\expandafter\CALX_sc_kqe\fi
    #1.#2.#3.#4.#5.#6%
}%
\def\CALX_sc_kqo #1.#2.#3.#4.#5.#6#7%
{%
    \expandafter\CALX_sc_kqf\the\numexpr\CALX_cosaux#1.\expandafter.%
    \the\numexpr\ifnum#6=\xint_c_iii -\fi1\expandafter.\the\numexpr-#5.#4.%
}%
\def\CALX_sc_kqe #1.#2.#3.#4.#5.#6#7%
{%
    \expandafter\CALX_sc_kqf\the\numexpr#2*(\CALX_sinaux#1.)/1000000000%
    \expandafter.\the\numexpr\ifnum#6=\xint_c_ii -1*\fi#71\expandafter.%
    \the\numexpr#3-#5.#4.%
}%
\def\CALX_sc_kqf #1.#2.#3.#4.%
{%
    \expandafter\CALX_dgo\the\numexpr#2*(\ifnum#1<#4 #1*1000000000/#4\else
      #1*100000000/#4\fi)\expandafter.\the\numexpr#3-\ifnum#1<#4 9\else
      8\fi.%
}%
\def\CALX_sc_kqx #1#2.F#3#4.#5.#6\xint:#7#8#9%
{%
    \expandafter\CALX_sc_kqa\the\numexpr#4+8*#5\expandafter.%
    \the\numexpr(2*#4+7)/16\expandafter.%
    \the\numexpr#4+8-8*((2*#4+7)/16).#6\xint:#1#2#3#7%
}%
\def\CALX_sc_kqa #1.#2.#3.#4\xint:%
  {\expandafter\CALX_sc_kqb\the\numexpr\CALX_rta#2.#3.#4\xint:.#1.}%
\def\CALX_sc_kqb #1.#2.#3#4#5#6{\csname CALX_kq#3#4\endcsname#6#5#1.#2.}%
\expandafter\def\csname CALX_kqt0\endcsname#1#2{\CALX_qkt#11*#21.}%
\expandafter\def\csname CALX_kqt1\endcsname#1#2{\CALX_qku-1*#11*#21.}%
\expandafter\def\csname CALX_kqt2\endcsname#1#2{\CALX_qkt#11*#21.}%
\expandafter\def\csname CALX_kqt3\endcsname#1#2{\CALX_qku-1*#11*#21.}%
\expandafter\def\csname CALX_kqu0\endcsname#1#2{\CALX_qku#11*#21.}%
\expandafter\def\csname CALX_kqu1\endcsname#1#2{\CALX_qkt-1*#11*#21.}%
\expandafter\def\csname CALX_kqu2\endcsname#1#2{\CALX_qku#11*#21.}%
\expandafter\def\csname CALX_kqu3\endcsname#1#2{\CALX_qkt-1*#11*#21.}%
\expandafter\def\csname CALX_kqv0\endcsname#1#2{\CALX_qke1.}%
\expandafter\def\csname CALX_kqv1\endcsname#1#2{\CALX_qkr-1*#21.}%
\expandafter\def\csname CALX_kqv2\endcsname#1#2{\CALX_qke-1.}%
\expandafter\def\csname CALX_kqv3\endcsname#1#2{\CALX_qkr#21.}%
\expandafter\def\csname CALX_kqw0\endcsname#1#2{\CALX_qkr#11*#21.}%
\expandafter\def\csname CALX_kqw1\endcsname#1#2{\CALX_qke#11.}%
\expandafter\def\csname CALX_kqw2\endcsname#1#2{\CALX_qkr-1*#11*#21.}%
\expandafter\def\csname CALX_kqw3\endcsname#1#2{\CALX_qke-1*#11.}%
\def\CALX_qkz #1.#2.%
  {\ifnum#2<-\xint_c_iv 0\else#1*#1/1000000000/\CALX_pten{-2*#2}\fi}%
\def\CALX_qkt #1.#2.#3.%
  {\expandafter\CALX_qkta\the\numexpr\CALX_qkz#2.#3..#1.#2.#3.}%
\def\CALX_qkta #1.#2.#3.#4.%
{%
    \expandafter\CALX_dgo\the\numexpr#2*#3*(\CALX_sinaux#1.)%
      /(\CALX_cosaux#1.).#4-9.%
}%
\def\CALX_qku #1.#2.#3.%
  {\expandafter\CALX_qkua\the\numexpr\CALX_qkz#2.#3..#1.#2.#3.}%
\def\CALX_qkua #1.#2.#3.#4.%
{%
    \expandafter\CALX_dgo\the\numexpr#2*(1000000000*100000000/(#3*%
      (\CALX_sinaux#1.)/(\CALX_cosaux#1.))).-#4-8.%
}%
\def\CALX_qke #1.#2.#3.%
{%
    \expandafter\CALX_dgo\the\numexpr#1*(1000000000*1000000000/(%
      \expandafter\CALX_cosaux\the\numexpr\CALX_qkz#2.#3..)).-9.%
}%
\def\CALX_qkr #1.#2.#3.%
{%
    \expandafter\CALX_dgo\the\numexpr#1*((1000000000*100000000/#2)%
      *1000000000/(\expandafter\CALX_sinaux\the\numexpr\CALX_qkz#2.#3..)).%
    -#3-8.%
}%
\def\CALX_sc_rr\fi\CALX_sc_k 0.F+#1.#2.#3\xint:%
{%
    \fi
    \ifnum\numexpr#1+8*#2>\xint_c_iv \CALX_rjs\fi
    \expandafter\CALX_sc_k\romannumeral0\CALX_red #1.#2.#3\xint:\xint:%
}%
%    \end{macrocode}
%\begin{lverb}
% Degree reduction, \CALX_sc_f<kernel selector>|x|: \CALX_sc_ks (sind,
% cscd), \CALX_sc_kc (cosd, secd), \CALX_sc_k (tand, cotd). With t = D +
% 8e (|x| < 10^t):
%- t < 2: q = 0, u = |x| pi/180 at P+4 digits (\CALX_sc_fz, constant
%  \CALX_pdg<P>);
%- 2 <= t <= 6: q = round(|x|/90) in \numexpr from the nine leading
%  digits (\CALX_rta); q = 0: as above; else (\CALX_sc_fk) r = |x| - 90q
%  at P+8 digits (exact: r has at most P digits), 90q a one-block native
%  (\CALX_sc_fv), u = r pi/180 at P+4 digits, quadrant q mod 4;
%- t > 6: \CALX_sc_fo, exact reduction modulo 360 (\CALX_red_a).
%
%\end{lverb}
%    \begin{macrocode}
\def\CALX_sc_d{\CALX_sc_f\CALX_sc_k}%
\def\CALX_sc_s{\CALX_sc_f\CALX_sc_ks}%
\def\CALX_sc_c{\CALX_sc_f\CALX_sc_kc}%
\let\CALX_sc_t\CALX_sc_d \let\CALX_sc_u\CALX_sc_d
\let\CALX_sc_v\CALX_sc_c \let\CALX_sc_w\CALX_sc_s
\def\CALX_sc_f #1#2.#3.%
{%
    \ifnum\numexpr#2+8*#3>\xint_c_vi \xint_dothis\CALX_sc_fo\fi
    \ifnum\numexpr#2+8*#3<\xint_c_ii \xint_dothis{\CALX_sc_fz 0.}\fi
    \xint_orthat\CALX_sc_fg #1#2.#3.%
}%
\def\CALX_sc_fg #1#2.#3.#4\xint:%
{%
    \expandafter\CALX_sc_fh\the\numexpr(\CALX_rta
      \the\numexpr(2*#2+7)/16\relax.\the\numexpr#2+8-8*((2*#2+7)/16).%
      #4\xint:)/(90*\CALX_pten{9-#2-8*#3}).#1#2.#3.#4\xint:%
}%
\def\CALX_sc_fh #1.%
  {\ifnum#1=\xint_c_ \expandafter\CALX_sc_fz\else
   \expandafter\CALX_sc_fk\fi #1.}%
\def\CALX_sc_fz 0.#1#2\xint:%
{%
    \expandafter#1\expandafter0\expandafter.\romannumeral0%
    \CALX_fmul{\the\numexpr\CALX_trigdigits+4\relax}{F+#2}%
      {\csname CALX_pdg\the\numexpr\CALX_trigdigits\endcsname}\xint:%
}%
\def\CALX_sc_fk #1.#2#3\xint:%
{%
    \expandafter#2\the\numexpr#1-4*((2*#1-3)/8)\expandafter.%
    \romannumeral0\CALX_fmul{\the\numexpr\CALX_trigdigits+4\relax}%
      {\romannumeral0\CALX_fsub{\the\numexpr\CALX_trigdigits+8\relax}%
        {F+#3}{\expandafter\CALX_sc_fv\the\numexpr100000000+90*#1.}}%
      {\csname CALX_pdg\the\numexpr\CALX_trigdigits\endcsname}\xint:%
}%
\def\CALX_sc_fv #1.{\expandafter\CALX_sc_fw\the\numexpr\CALX_nd#1..#1.}%
\def\CALX_sc_fw #1.#2.{F+#1.0.#2!}%
\def\CALX_sc_fo #1#2\xint:%
  {\expandafter#1\romannumeral0\CALX_red_a F+#2\xint:\xint:}%
%    \end{macrocode}
%\begin{lverb}
% One kernel: \CALX_sc_ks q.u (sine and cosecant) runs the sine kernel
% for q even, the cosine kernel for q odd; \CALX_sc_kc q.u (cosine and
% secant) the reverse. \CALX_sc_ku: sine kernel, finisher B, result in
% the S slot (\CALX_sc_pu); \CALX_sc_kv: cosine kernel, finisher A,
% result in the C slot (\CALX_sc_pv); the other slot is empty. u = 0:
% \CALX_sc_k. \CALX_sc_k: both kernels (u = 0: \CALX_sc_kz, S = 0, C =
% 1).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_sc_ks #1.F#2#3.%
{%
    \ifnum#3=\xint_c_ \CALX_sc_kj\fi
    \ifodd#1 \expandafter\CALX_sc_kv\else\expandafter\CALX_sc_ku\fi
    #1.F#2#3.%
}%
\def\CALX_sc_kc #1.F#2#3.%
{%
    \ifnum#3=\xint_c_ \CALX_sc_kj\fi
    \ifodd#1 \expandafter\CALX_sc_ku\else\expandafter\CALX_sc_kv\fi
    #1.F#2#3.%
}%
\def\CALX_sc_kj\fi #1\fi{\fi\CALX_sc_k}%
\def\CALX_sc_ku #1.F#2\xint:%
  {\CALX_as_kc s{#2}B\CALX_sc_pu #1.}%
\def\CALX_sc_kv #1.F#2\xint:%
  {\CALX_as_kc c{#2}A\CALX_sc_pv #1.}%
\def\CALX_sc_pu #1#2.#3#4{#4{#2}{#3}{#1}{}}%
\def\CALX_sc_pv #1#2.#3#4{#4{#2}{#3}{}{#1}}%
\def\CALX_sc_k #1.F#2#3.#4\xint:%
{%
    \ifnum#3=\xint_c_ \CALX_sc_kz\fi
    \CALX_as_kc c{#2#3.#4}A\CALX_sc_m{#2#3.#4}#1.%
}%
\def\CALX_sc_kz\fi\CALX_as_kc#1#2A\CALX_sc_m#3#4.#5#6%
  {\fi#6{#4}{#5}{F+0.0.}{F+1.0.100000001!}}%
\def\CALX_sc_m #1#2#3.%
  {\CALX_as_kc s{#2}B\CALX_sc_n{#1}#3.}%
\def\CALX_sc_n #1#2#3.#4#5{#5{#3}{#4}{#1}{#2}}%
\def\CALX_shzA #1\xint:#2{#2{F+1.0.100000001!}}%
\def\CALX_shzB #1\xint:#2%
  {\expandafter#2\expandafter{\romannumeral0\CALX_fnround
   {\CALX_trigdigits+4}{F#1}}}%
\def\CALX_scS #1{\csname CALX_scs\the\numexpr#1\endcsname}%
\def\CALX_scC #1{\csname CALX_scc\the\numexpr#1\endcsname}%
\expandafter\def\csname CALX_scs0\endcsname #1#2#3{\CALX_as_m#1+#2}%
\expandafter\def\csname CALX_scs1\endcsname #1#2#3{\CALX_as_m#1+#3}%
\expandafter\def\csname CALX_scs2\endcsname #1#2#3{\CALX_as_m#1-#2}%
\expandafter\def\csname CALX_scs3\endcsname #1#2#3{\CALX_as_m#1-#3}%
\expandafter\def\csname CALX_scc0\endcsname #1#2{\CALX_as_m++#2}%
\expandafter\def\csname CALX_scc1\endcsname #1#2{\CALX_as_m+-#1}%
\expandafter\def\csname CALX_scc2\endcsname #1#2{\CALX_as_m+-#2}%
\expandafter\def\csname CALX_scc3\endcsname #1#2{\CALX_as_m++#1}%
\def\CALX_sc_q #1#2%
  {\CALX_fnround{\CALX_trigdigits}{\CALX_fdiv
   {\the\numexpr\CALX_trigdigits+4\relax}{#1}{#2}}}%
\def\CALX_fnsin #1#2#3#4#5%
  {\CALX_fnround{\CALX_trigdigits}{\CALX_scS{#1}#2{#3}{#4}}}%
\def\CALX_fncos #1#2#3#4#5%
  {\CALX_fnround{\CALX_trigdigits}{\CALX_scC{#1}{#3}{#4}}}%
\def\CALX_fntan #1#2#3#4#5{\CALX_sc_q{\CALX_scS{#1}#2{#3}{#4}}%
  {\CALX_scC{#1}{#3}{#4}}}%
\def\CALX_fncot #1#2#3#4#5{\CALX_sc_q{\CALX_scC{#1}{#3}{#4}}%
  {\CALX_scS{#1}#2{#3}{#4}}}%
\def\CALX_fnsec #1#2#3#4#5{\CALX_sc_q{F+1.0.100000001!}%
  {\CALX_scC{#1}{#3}{#4}}}%
\def\CALX_fncsc #1#2#3#4#5{\CALX_sc_q{F+1.0.100000001!}%
  {\CALX_scS{#1}#2{#3}{#4}}}%
\def\CALX_fnsinc #1#2#3#4#5{\CALX_fnsc #5\xint:{#1}{#2}{#3}{#4}{#5}}%
\def\CALX_fnsc F#1#2.%
{%
    \ifnum#2=\xint_c_ \xint_dothis\CALX_fnsc_zero\fi
    \xint_orthat\CALX_fnsc_regular #1#2.%
}%
\def\CALX_fnsc_zero #1#2.#3\xint:#4#5#6#7#8%
  { F+1.0.100000001!}%
\def\CALX_fnsc_regular #1#2.#3\xint:#4#5#6#7#8%
  {\CALX_sc_q{\CALX_scS{#4}#5{#6}{#7}}{#8}}%
\def\CALX_as_tau F+#1.#2.#3\xint:%
{%
    \ifnum\numexpr#1+8*#2<-\xint_c_viii 0\else
    \ifnum\numexpr#1+8*#2>\xint_c_ 1000000000\else
    (\CALX_rta\the\numexpr(2*#1+7)/16\relax.%
      \the\numexpr#1+8-8*((2*#1+7)/16)\relax.#3\xint:)%
    /\CALX_pten{-#1-8*#2}\fi\fi
}%
\def\CALX_as_pp
  {\ifnum\CALX_trigdigits<\xint_c_ix 9\else\the\numexpr\CALX_trigdigits\fi}%
\def\CALX_as_kc
{%
    \ifnum\CALX_trigdigits>32 \expandafter\CALX_as_kb\else
    \expandafter\CALX_as_ka\fi
}%
\def\CALX_as_ka #1#2{\csname CALX_tf#1\CALX_as_pp\endcsname\xint:#2\xint:}%
\def\CALX_as_kb #1#2%
{%
    \expandafter\CALX_sha\romannumeral`&&@\csname
      CALX_ts#1\the\numexpr\CALX_trigdigits\endcsname\xint:#2\xint:%
}%
\def\CALX_gkA #1#2#3#4%
{%
    \expandafter#4\expandafter{\romannumeral0\CALX_fnround
      {\CALX_trigdigits+4}{\CALX_asch{#1}#3.}}%
}%
\def\CALX_gkB #1#2#3#4%
{%
    \expandafter#4\expandafter{\romannumeral0\CALX_fmul
      {\the\numexpr\CALX_trigdigits+4\relax}{F#2}{\CALX_asch{#1}#3.}}%
}%
\def\CALX_asch #1#2.%
  {\expanded{F+\the\numexpr16*((#2+1)/4).-\the\numexpr2*((#2+1)/4).%
   \csname CALX_sb\the\numexpr(#2+1)/4\endcsname#1}}%
\def\CALX_as_ser #1#2%
  {\expandafter\CALX_as_sea\romannumeral0\CALX_fsqr{#1}{#2}\xint:{#1}{#2}}%
\def\CALX_as_sea #1\xint:#2#3%
{%
    \CALX_fmul{#2}{\CALX_fmul{#2}{#3}{#1}}%
      {\csname CALX_ash\CALX_gl{\numexpr(#2+9)/18\relax}\endcsname{#2}{#1}}%
}%
\edef\CALX_asca{\romannumeral0\CALX_ffromraw
  {1666666666666666666666666666666666666666666666666666666666666666666666%
  66666666666666666666666666666666666666666666666666[-120]}}%
\edef\CALX_ascb{\romannumeral0\CALX_ffromraw
  {7500000000000000000000000000000000000000000000000000000000000000000000%
  00000000000000000000000000000000000000000000000000[-121]}}%
\edef\CALX_ascc{\romannumeral0\CALX_ffromraw
  {4464285714285714285714285714285714285714285714285714285714285714285714%
  28571428571428571428571428571428571428571428571428[-121]}}%
\edef\CALX_ascd{\romannumeral0\CALX_ffromraw
  {3038194444444444444444444444444444444444444444444444444444444444444444%
  44444444444444444444444444444444444444444444444444[-121]}}%
\edef\CALX_asce{\romannumeral0\CALX_ffromraw
  {2237215909090909090909090909090909090909090909090909090909090909090909%
  09090909090909090909090909090909090909090909090909[-121]}}%
\edef\CALX_ascf{\romannumeral0\CALX_ffromraw
  {1735276442307692307692307692307692307692307692307692307692307692307692%
  30769230769230769230769230769230769230769230769230[-121]}}%
\def\CALX_asha #1#2%
  {\CALX_asca}%
\def\CALX_ashb #1#2%
  {\CALX_fadd{#1}{\CALX_asca}{\CALX_fmul{#1}{#2}{\CALX_ascb}}}%
\def\CALX_ashc #1#2%
  {\CALX_fadd{#1}{\CALX_asca}{\CALX_fmul{#1}{#2}{\CALX_fadd{#1}{\CALX_ascb}%
   {\CALX_fmul{#1}{#2}{\CALX_ascc}}}}}%
\def\CALX_ashd #1#2%
  {\CALX_fadd{#1}{\CALX_asca}{\CALX_fmul{#1}{#2}{\CALX_fadd{#1}{\CALX_ascb}%
   {\CALX_fmul{#1}{#2}{\CALX_fadd{#1}{\CALX_ascc}{\CALX_fmul{#1}{#2}%
   {\CALX_ascd}}}}}}}%
\def\CALX_ashe #1#2%
  {\CALX_fadd{#1}{\CALX_asca}{\CALX_fmul{#1}{#2}{\CALX_fadd{#1}{\CALX_ascb}%
   {\CALX_fmul{#1}{#2}{\CALX_fadd{#1}{\CALX_ascc}{\CALX_fmul{#1}{#2}%
   {\CALX_fadd{#1}{\CALX_ascd}{\CALX_fmul{#1}{#2}{\CALX_asce}}}}}}}}}%
\def\CALX_ashf #1#2%
  {\CALX_fadd{#1}{\CALX_asca}{\CALX_fmul{#1}{#2}{\CALX_fadd{#1}{\CALX_ascb}%
   {\CALX_fmul{#1}{#2}{\CALX_fadd{#1}{\CALX_ascc}{\CALX_fmul{#1}{#2}%
   {\CALX_fadd{#1}{\CALX_ascd}{\CALX_fmul{#1}{#2}{\CALX_fadd{#1}{\CALX_asce}%
   {\CALX_fmul{#1}{#2}{\CALX_ascf}}}}}}}}}}}%
\def\CALX_asb #1.%
{%((((((((((((((((
((((((((((((((((((((((((((((((((((((((((((%
  #1*1849/1980+\xint_c_e_ix)*%
  1681/1806)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  1521/1640)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  1369/1482)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  1225/1332)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  1089/1190)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  961/1056)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  841/930)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  729/812)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  625/702)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  529/600)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  441/506)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  361/420)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  289/342)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  225/272)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  169/210)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  121/156)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  81/110)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  49/72)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  25/42)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  9/20)*#1/\xint_c_e_ix+\xint_c_e_ix)*%
  1/6)*#1/\xint_c_e_ix+\xint_c_e_ix
}%
%    \end{macrocode}
%\begin{lverb}
% Generated by tools/trig_genpm.py: \CALX_pm<a>_<c>, a, c = 1..3.
%\end{lverb}
%    \begin{macrocode}
\expandafter\def\csname CALX_pm1_1\endcsname#1#2%
{%
\expandafter\CALX_pmh\the\numexpr 1000000000%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpa#1#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpb#1#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpc#1#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#2\relax!%
}%
\expandafter\def\csname CALX_pm1_2\endcsname#1#2#3%
{%
\expandafter\CALX_pmh\the\numexpr 1000000000%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpa#1#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpb#1#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpc#1#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#2\CALX_hpa#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#2\CALX_hpb#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#2\CALX_hpc#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#3\relax!%
}%
\expandafter\def\csname CALX_pm1_3\endcsname#1#2#3#4%
{%
\expandafter\CALX_pmh\the\numexpr 1000000000%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpa#1#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpb#1#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpc#1#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#2\CALX_hpa#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#2\CALX_hpb#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#2\CALX_hpc#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#3\CALX_hpa#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#3\CALX_hpb#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#3\CALX_hpc#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#4\relax!%
}%
\expandafter\def\csname CALX_pm2_1\endcsname#1#2#3%
{%
\expandafter\CALX_pmh\the\numexpr 1000000000%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpa#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpb#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpc#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#3\CALX_hpa#2#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#3\CALX_hpb#2#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#3\CALX_hpc#2#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#2#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#2#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#2#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#2#3\relax!%
}%
\expandafter\def\csname CALX_pm2_2\endcsname#1#2#3#4%
{%
\expandafter\CALX_pmh\the\numexpr 1000000000%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpa#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpb#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpc#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#3\CALX_hpa#1#4%
  \CALX_hpa#2#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#3\CALX_hpb#1#4%
  \CALX_hpb#2#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#3\CALX_hpc#1#4%
  \CALX_hpc#2#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#4\CALX_hpd#2#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#4\CALX_hpe#2#3%
  \CALX_hpa#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#4\CALX_hpf#2#3%
  \CALX_hpb#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#4\CALX_hpg#2#3%
  \CALX_hpc#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#2#4\relax!%
}%
\expandafter\def\csname CALX_pm2_3\endcsname#1#2#3#4#5%
{%
\expandafter\CALX_pmh\the\numexpr 1000000000%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpa#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpb#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpc#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#3\CALX_hpa#1#4%
  \CALX_hpa#2#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#3\CALX_hpb#1#4%
  \CALX_hpb#2#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#3\CALX_hpc#1#4%
  \CALX_hpc#2#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#4\CALX_hpd#2#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#4\CALX_hpa#1#5%
  \CALX_hpe#2#3\CALX_hpa#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#4\CALX_hpb#1#5%
  \CALX_hpf#2#3\CALX_hpb#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#4\CALX_hpc#1#5%
  \CALX_hpg#2#3\CALX_hpc#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#5\CALX_hpd#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#5\CALX_hpe#2#4%
  \CALX_hpa#2#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#5\CALX_hpf#2#4%
  \CALX_hpb#2#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#5\CALX_hpg#2#4%
  \CALX_hpc#2#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#2#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#2#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#2#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#2#5\relax!%
}%
\expandafter\def\csname CALX_pm3_1\endcsname#1#2#3#4%
{%
\expandafter\CALX_pmh\the\numexpr 1000000000%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpa#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpb#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpc#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#4\CALX_hpa#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#4\CALX_hpb#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#4\CALX_hpc#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#2#4\CALX_hpa#3#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#2#4\CALX_hpb#3#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#2#4\CALX_hpc#3#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#3#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#3#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#3#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#3#4\relax!%
}%
\expandafter\def\csname CALX_pm3_2\endcsname#1#2#3#4#5%
{%
\expandafter\CALX_pmh\the\numexpr 1000000000%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpa#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpb#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpc#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#4\CALX_hpa#1#5%
  \CALX_hpa#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#4\CALX_hpb#1#5%
  \CALX_hpb#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#4\CALX_hpc#1#5%
  \CALX_hpc#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#5\CALX_hpd#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#5\CALX_hpe#2#4%
  \CALX_hpa#2#5\CALX_hpa#3#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#5\CALX_hpf#2#4%
  \CALX_hpb#2#5\CALX_hpb#3#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#5\CALX_hpg#2#4%
  \CALX_hpc#2#5\CALX_hpc#3#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#2#5\CALX_hpd#3#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#2#5\CALX_hpe#3#4%
  \CALX_hpa#3#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#2#5\CALX_hpf#3#4%
  \CALX_hpb#3#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#2#5\CALX_hpg#3#4%
  \CALX_hpc#3#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#3#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#3#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#3#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#3#5\relax!%
}%
\expandafter\def\csname CALX_pm3_3\endcsname#1#2#3#4#5#6%
{%
\expandafter\CALX_pmh\the\numexpr 1000000000%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpa#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpb#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpc#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#4\CALX_hpa#1#5%
  \CALX_hpa#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#4\CALX_hpb#1#5%
  \CALX_hpb#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#4\CALX_hpc#1#5%
  \CALX_hpc#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#5\CALX_hpd#2#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#5\CALX_hpa#1#6%
  \CALX_hpe#2#4\CALX_hpa#2#5\CALX_hpa#3#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#5\CALX_hpb#1#6%
  \CALX_hpf#2#4\CALX_hpb#2#5\CALX_hpb#3#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#5\CALX_hpc#1#6%
  \CALX_hpg#2#4\CALX_hpc#2#5\CALX_hpc#3#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#6\CALX_hpd#2#5%
  \CALX_hpd#3#4%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#6\CALX_hpe#2#5%
  \CALX_hpa#2#6\CALX_hpe#3#4\CALX_hpa#3#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#6\CALX_hpf#2#5%
  \CALX_hpb#2#6\CALX_hpf#3#4\CALX_hpb#3#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#6\CALX_hpg#2#5%
  \CALX_hpc#2#6\CALX_hpg#3#4\CALX_hpc#3#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#2#6\CALX_hpd#3#5%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#2#6\CALX_hpe#3#5%
  \CALX_hpa#3#6%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#2#6\CALX_hpf#3#5%
  \CALX_hpb#3#6%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#2#6\CALX_hpg#3#5%
  \CALX_hpc#3#6%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#3#6%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#3#6%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#3#6%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#3#6\relax!%
}%
%    \end{macrocode}
% \subsection{Generated helpers and products}
% Generated by |tools/trig_genfix.py|: helpers.
%    \begin{macrocode}
\def\CALX_hda #1#2#3#4#5#6#7#8{-#1*#5}%
\def\CALX_hdb #1#2#3#4#5#6#7#8{-#1*#6-#2*#5}%
\def\CALX_hdc #1#2#3#4#5#6#7#8{-#1*#7-#2*#6-#3*#5}%
\def\CALX_hdd #1#2#3#4#5#6#7#8{-#1*#8-#2*#7-#3*#6-#4*#5}%
\def\CALX_hde #1#2#3#4#5#6#7#8{-#2*#8-#3*#7-#4*#6}%
\def\CALX_hdf #1#2#3#4#5#6#7#8{-#3*#8-#4*#7}%
\def\CALX_hdg #1#2#3#4#5#6#7#8{-#4*#8}%
\def\CALX_csa #1#2#3#4{#1}%
\def\CALX_csb #1#2#3#4{#2}%
\def\CALX_csc #1#2#3#4{#3}%
\def\CALX_csd #1#2#3#4{#4}%
\def\CALX_poaa #1#2#3#4#5#6{\CALX_pg 1.}%
\def\CALX_poab #1#2#3#4#5#6{\CALX_pg 2.}%
\def\CALX_poac #1#2#3#4#5#6{\CALX_pg 3.}%
\def\CALX_poad #1#2#3#4#5#6{\CALX_pg 4.}%
\def\CALX_poae #1#2#3#4#5#6{\CALX_pg 5.}%
\def\CALX_poaf #1#2#3#4#5#6{\CALX_pg 6.}%
\def\CALX_poag #1#2#3#4#5#6{\CALX_pg 7.}%
\def\CALX_poah #1#2#3#4#5#6{\CALX_pg 8.}%
\def\CALX_poai #1#2#3#4#5#6{\CALX_pg 9.}%
\def\CALX_poaj #1#2#3#4#5#6{\CALX_pg 10.}%
\def\CALX_poak #1#2#3#4#5#6{\CALX_pg 11.}%
%    \end{macrocode}
% Generated: square of M for u.
%    \begin{macrocode}
\def\CALX_hpa #1#2#3#4#5#6#7#8{+#1*#5}%
\def\CALX_hpb #1#2#3#4#5#6#7#8{+#1*#6+#2*#5}%
\def\CALX_hpc #1#2#3#4#5#6#7#8{+#1*#7+#2*#6+#3*#5}%
\def\CALX_hpd #1#2#3#4#5#6#7#8{+#1*#8+#2*#7+#3*#6+#4*#5}%
\def\CALX_hpe #1#2#3#4#5#6#7#8{+#2*#8+#3*#7+#4*#6}%
\def\CALX_hpf #1#2#3#4#5#6#7#8{+#3*#8+#4*#7}%
\def\CALX_hpg #1#2#3#4#5#6#7#8{+#4*#8}%
\def\CALX_pqa #1#2#3#4#5#6{\CALX_pg 8.}%
\def\CALX_pqb #1#2#3#4#5#6{\CALX_pg 16.}%
\def\CALX_pqc #1#2#3#4#5#6{\CALX_pg 24.}%
\expandafter\def\csname CALX_xm1\endcsname1#1!%
  {{{0000}{0000}\CALX_bl#1}}%
\expandafter\def\csname CALX_xm2\endcsname1#1!1#2!%
  {{\CALX_bl#2\CALX_bl#1}}%
\expandafter\def\csname CALX_xm3\endcsname1#1!1#2!1#3!%
  {{{0000}{0000}\CALX_bl#3}{\CALX_bl#2\CALX_bl#1}}%
\expandafter\def\csname CALX_xm4\endcsname1#1!1#2!1#3!1#4!%
  {{\CALX_bl#4\CALX_bl#3}{\CALX_bl#2\CALX_bl#1}}%
\expandafter\def\csname CALX_xm5\endcsname1#1!1#2!1#3!1#4!1#5!%
  {{{0000}{0000}\CALX_bl#5}{\CALX_bl#4\CALX_bl#3}{\CALX_bl#2\CALX_bl#1}}%
\expandafter\def\csname CALX_sq1\endcsname#1%
{%
\expandafter\CALX_pqa\the\numexpr 1000000000%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpa#1#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpb#1#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpc#1#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#1\relax!;%
}%
\expandafter\def\csname CALX_sq2\endcsname#1#2%
{%
\expandafter\CALX_pqb\the\numexpr 1000000000%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpa#1#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpb#1#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpc#1#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#1\CALX_hpa#1#2%
  \CALX_hpa#2#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#1\CALX_hpb#1#2%
  \CALX_hpb#2#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#1\CALX_hpc#1#2%
  \CALX_hpc#2#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#2\CALX_hpd#2#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#2\CALX_hpe#2#1%
  \CALX_hpa#2#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#2\CALX_hpf#2#1%
  \CALX_hpb#2#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#2\CALX_hpg#2#1%
  \CALX_hpc#2#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#2#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#2#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#2#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#2#2\relax!;%
}%
\expandafter\def\csname CALX_sq3\endcsname#1#2#3%
{%
\expandafter\CALX_pqc\the\numexpr 1000000000%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpa#1#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpb#1#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpc#1#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#1\CALX_hpa#1#2%
  \CALX_hpa#2#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#1\CALX_hpb#1#2%
  \CALX_hpb#2#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#1\CALX_hpc#1#2%
  \CALX_hpc#2#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#2\CALX_hpd#2#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#2\CALX_hpa#1#3%
  \CALX_hpe#2#1\CALX_hpa#2#2\CALX_hpa#3#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#2\CALX_hpb#1#3%
  \CALX_hpf#2#1\CALX_hpb#2#2\CALX_hpb#3#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#2\CALX_hpc#1#3%
  \CALX_hpg#2#1\CALX_hpc#2#2\CALX_hpc#3#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#1#3\CALX_hpd#2#2%
  \CALX_hpd#3#1%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#1#3\CALX_hpe#2#2%
  \CALX_hpa#2#3\CALX_hpe#3#1\CALX_hpa#3#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#1#3\CALX_hpf#2#2%
  \CALX_hpb#2#3\CALX_hpf#3#1\CALX_hpb#3#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#1#3\CALX_hpg#2#2%
  \CALX_hpc#2#3\CALX_hpg#3#1\CALX_hpc#3#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#2#3\CALX_hpd#3#2%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#2#3\CALX_hpe#3#2%
  \CALX_hpa#3#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#2#3\CALX_hpf#3#2%
  \CALX_hpb#3#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#2#3\CALX_hpg#3#2%
  \CALX_hpc#3#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpd#3#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpe#3#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpf#3#3%
\expandafter\CALX_pkq\the\numexpr 1000000000\CALX_hpg#3#3\relax!;%
}%
%    \end{macrocode}
% Generated: products, shapes (s, n) of the tables.
%    \begin{macrocode}
\expandafter\def\csname CALX_m1_2\endcsname#1#2#3%
{%
\expandafter\CALX_poab\the\numexpr 2100000000+\CALX_csa#2%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#2%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hda#3#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdb#3#1\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m2_2\endcsname#1#2#3%
{%
\expandafter\CALX_poab\the\numexpr 2100000000+\CALX_csa#2%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#2\CALX_hda#3#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdb#3#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdc#3#1\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m2_3\endcsname#1#2#3%
{%
\expandafter\CALX_poac\the\numexpr 2100000000+\CALX_csa#2%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#2%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#2\CALX_hda#3#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdb#3#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdc#3#1\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m3_3\endcsname#1#2#3%
{%
\expandafter\CALX_poac\the\numexpr 2100000000+\CALX_csa#2%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#2\CALX_hda#3#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#2\CALX_hdb#3#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdc#3#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdd#3#1\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m3_4\endcsname#1#2#3%
{%
\expandafter\CALX_poad\the\numexpr 2100000000+\CALX_csa#2%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#2%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#2\CALX_hda#3#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#2\CALX_hdb#3#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdc#3#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdd#3#1\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m4_4\endcsname#1#2#3%
{%
\expandafter\CALX_poad\the\numexpr 2100000000+\CALX_csa#2%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#2\CALX_hda#3#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#2\CALX_hdb#3#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#2\CALX_hdc#3#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdd#3#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hde#3#1\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m4_5\endcsname#1#2#3#4%
{%
\expandafter\CALX_poae\the\numexpr 2100000000+\CALX_csa#2%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#2%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#2\CALX_hda#4#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#2\CALX_hdb#4#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#3\CALX_hdc#4#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdd#4#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hde#4#1\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m5_5\endcsname#1#2#3#4#5#6%
{%
\expandafter\CALX_poae\the\numexpr 2100000000+\CALX_csa#3%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#3\CALX_hda#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#3\CALX_hdb#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#3\CALX_hdc#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#4\CALX_hdd#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hde#5#1\CALX_hda#5#2%
  \CALX_hda#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdf#5#1\CALX_hdb#5#2%
  \CALX_hdb#6#1\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m5_6\endcsname#1#2#3#4#5#6%
{%
\expandafter\CALX_poaf\the\numexpr 2100000000+\CALX_csa#3%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#3%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#3\CALX_hda#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#3\CALX_hdb#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#4\CALX_hdc#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#4\CALX_hdd#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hde#5#1\CALX_hda#5#2%
  \CALX_hda#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdf#5#1\CALX_hdb#5#2%
  \CALX_hdb#6#1\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m6_6\endcsname#1#2#3#4#5#6%
{%
\expandafter\CALX_poaf\the\numexpr 2100000000+\CALX_csa#3%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#3\CALX_hda#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#3\CALX_hdb#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#3\CALX_hdc#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#4\CALX_hdd#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#4\CALX_hde#5#1%
  \CALX_hda#5#2\CALX_hda#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdf#5#1\CALX_hdb#5#2%
  \CALX_hdb#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdg#5#1\CALX_hdc#5#2%
  \CALX_hdc#6#1\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m6_7\endcsname#1#2#3#4#5#6%
{%
\expandafter\CALX_poag\the\numexpr 2100000000+\CALX_csa#3%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#3%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#3\CALX_hda#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#3\CALX_hdb#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#4\CALX_hdc#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#4\CALX_hdd#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#4\CALX_hde#5#1%
  \CALX_hda#5#2\CALX_hda#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdf#5#1\CALX_hdb#5#2%
  \CALX_hdb#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdg#5#1\CALX_hdc#5#2%
  \CALX_hdc#6#1\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m7_7\endcsname#1#2#3#4#5#6%
{%
\expandafter\CALX_poag\the\numexpr 2100000000+\CALX_csa#3%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#3\CALX_hda#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#3\CALX_hdb#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#3\CALX_hdc#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#4\CALX_hdd#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#4\CALX_hde#5#1%
  \CALX_hda#5#2\CALX_hda#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#4\CALX_hdf#5#1%
  \CALX_hdb#5#2\CALX_hdb#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdg#5#1\CALX_hdc#5#2%
  \CALX_hdc#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdd#5#2\CALX_hdd#6#1%
  \relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m7_8\endcsname#1#2#3#4#5#6%
{%
\expandafter\CALX_poah\the\numexpr 2100000000+\CALX_csa#3%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#3%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#3\CALX_hda#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#3\CALX_hdb#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#4\CALX_hdc#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#4\CALX_hdd#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#4\CALX_hde#5#1%
  \CALX_hda#5#2\CALX_hda#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#4\CALX_hdf#5#1%
  \CALX_hdb#5#2\CALX_hdb#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdg#5#1\CALX_hdc#5#2%
  \CALX_hdc#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdd#5#2\CALX_hdd#6#1%
  \relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m8_8\endcsname#1#2#3#4#5#6%
{%
\expandafter\CALX_poah\the\numexpr 2100000000+\CALX_csa#3%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#3\CALX_hda#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#3\CALX_hdb#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#3\CALX_hdc#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#4\CALX_hdd#5#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#4\CALX_hde#5#1%
  \CALX_hda#5#2\CALX_hda#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#4\CALX_hdf#5#1%
  \CALX_hdb#5#2\CALX_hdb#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#4\CALX_hdg#5#1%
  \CALX_hdc#5#2\CALX_hdc#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdd#5#2\CALX_hdd#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hde#5#2\CALX_hde#6#1%
  \CALX_hda#6#2\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m8_9\endcsname#1#2#3#4#5#6#7%
{%
\expandafter\CALX_poai\the\numexpr 2100000000+\CALX_csa#3%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#3%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#3\CALX_hda#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#3\CALX_hdb#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#4\CALX_hdc#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#4\CALX_hdd#6#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#4\CALX_hde#6#1%
  \CALX_hda#6#2\CALX_hda#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#4\CALX_hdf#6#1%
  \CALX_hdb#6#2\CALX_hdb#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#5\CALX_hdg#6#1%
  \CALX_hdc#6#2\CALX_hdc#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdd#6#2\CALX_hdd#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hde#6#2\CALX_hde#7#1%
  \CALX_hda#7#2\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m9_9\endcsname#1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_poai\the\numexpr 2100000000+\CALX_csa#4%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#4\CALX_hda#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#4\CALX_hdb#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#4\CALX_hdc#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#5\CALX_hdd#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#5\CALX_hde#7#1%
  \CALX_hda#7#2\CALX_hda#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#5\CALX_hdf#7#1%
  \CALX_hdb#7#2\CALX_hdb#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#5\CALX_hdg#7#1%
  \CALX_hdc#7#2\CALX_hdc#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#6\CALX_hdd#7#2%
  \CALX_hdd#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hde#7#2\CALX_hda#7#3%
  \CALX_hde#8#1\CALX_hda#8#2\CALX_hda#9#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdf#7#2\CALX_hdb#7#3%
  \CALX_hdf#8#1\CALX_hdb#8#2\CALX_hdb#9#1\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m9_10\endcsname#1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_poaj\the\numexpr 2100000000+\CALX_csa#4%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#4%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#4\CALX_hda#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#4\CALX_hdb#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#5\CALX_hdc#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#5\CALX_hdd#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#5\CALX_hde#7#1%
  \CALX_hda#7#2\CALX_hda#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#5\CALX_hdf#7#1%
  \CALX_hdb#7#2\CALX_hdb#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#6\CALX_hdg#7#1%
  \CALX_hdc#7#2\CALX_hdc#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#6\CALX_hdd#7#2%
  \CALX_hdd#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hde#7#2\CALX_hda#7#3%
  \CALX_hde#8#1\CALX_hda#8#2\CALX_hda#9#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdf#7#2\CALX_hdb#7#3%
  \CALX_hdf#8#1\CALX_hdb#8#2\CALX_hdb#9#1\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m10_10\endcsname#1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_poaj\the\numexpr 2100000000+\CALX_csa#4%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#4\CALX_hda#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#4\CALX_hdb#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#4\CALX_hdc#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#5\CALX_hdd#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#5\CALX_hde#7#1%
  \CALX_hda#7#2\CALX_hda#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#5\CALX_hdf#7#1%
  \CALX_hdb#7#2\CALX_hdb#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#5\CALX_hdg#7#1%
  \CALX_hdc#7#2\CALX_hdc#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#6\CALX_hdd#7#2%
  \CALX_hdd#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#6\CALX_hde#7#2%
  \CALX_hda#7#3\CALX_hde#8#1\CALX_hda#8#2\CALX_hda#9#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdf#7#2\CALX_hdb#7#3%
  \CALX_hdf#8#1\CALX_hdb#8#2\CALX_hdb#9#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdg#7#2\CALX_hdc#7#3%
  \CALX_hdg#8#1\CALX_hdc#8#2\CALX_hdc#9#1\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m10_11\endcsname#1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_poak\the\numexpr 2100000000+\CALX_csa#4%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#4%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#4\CALX_hda#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#4\CALX_hdb#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#5\CALX_hdc#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#5\CALX_hdd#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#5\CALX_hde#7#1%
  \CALX_hda#7#2\CALX_hda#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#5\CALX_hdf#7#1%
  \CALX_hdb#7#2\CALX_hdb#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#6\CALX_hdg#7#1%
  \CALX_hdc#7#2\CALX_hdc#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#6\CALX_hdd#7#2%
  \CALX_hdd#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#6\CALX_hde#7#2%
  \CALX_hda#7#3\CALX_hde#8#1\CALX_hda#8#2\CALX_hda#9#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdf#7#2\CALX_hdb#7#3%
  \CALX_hdf#8#1\CALX_hdb#8#2\CALX_hdb#9#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdg#7#2\CALX_hdc#7#3%
  \CALX_hdg#8#1\CALX_hdc#8#2\CALX_hdc#9#1\relax!;\CALX_gobW%
}%
\expandafter\def\csname CALX_m11_11\endcsname#1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_poak\the\numexpr 2100000000+\CALX_csa#4%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#4\CALX_hda#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#4\CALX_hdb#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#4\CALX_hdc#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#5\CALX_hdd#7#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#5\CALX_hde#7#1%
  \CALX_hda#7#2\CALX_hda#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#5\CALX_hdf#7#1%
  \CALX_hdb#7#2\CALX_hdb#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csd#5\CALX_hdg#7#1%
  \CALX_hdc#7#2\CALX_hdc#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csa#6\CALX_hdd#7#2%
  \CALX_hdd#8#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csb#6\CALX_hde#7#2%
  \CALX_hda#7#3\CALX_hde#8#1\CALX_hda#8#2\CALX_hda#9#1%
\expandafter\CALX_pk\the\numexpr 2100000000+\CALX_csc#6\CALX_hdf#7#2%
  \CALX_hdb#7#3\CALX_hdf#8#1\CALX_hdb#8#2\CALX_hdb#9#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdg#7#2\CALX_hdc#7#3%
  \CALX_hdg#8#1\CALX_hdc#8#2\CALX_hdc#9#1%
\expandafter\CALX_pk\the\numexpr 2100000000\CALX_hdd#7#3\CALX_hdd#8#2%
  \CALX_hdd#9#1\relax!;\CALX_gobW%
}%
%    \end{macrocode}
% \subsection{Schedules of the fixed path}
% Generated: schedules (P with |A <= 11|).
%    \begin{macrocode}
\CALX_fdata\let\CALX_fdata\undefined
%    \end{macrocode}
% \subsection{Argument reduction}
%\begin{lverb}
% Reduction B1, for 0.8 <= |X| < 10^4 (E = D + 8e <= 4; E > 4:
% \CALX_rslow, below), m = ceil((P+6)/8) (m = 2 if P <= 8, \CALX_trigm),
% W = 8m >= P + 6 and H = round(pi/2 10^W):
%(
%:   k = round(2|X|/pi),   R = |X| 10^W - k H,   r = R 10^-W.
%)
% k: Xh = the top 9 digits of M (rounded), Xh = |X| 10^(9-E) (1 + d),
% |d| < 10^-8; k = round(round(Xh c / 10^9) / 10^(9-E)), c = 636619772
% (2/pi 10^9 rounded, relative error < 8 10^-10): the error on 2|X|/pi is
% < 0.0017, so |r| < pi/4 + 0.0017 pi/2 < 0.79 < 0.8 (domain of the
% series kernels). E = 0: k = 1. k <= 6367 (one limb; the integer part of
% |X| is in the low limb of the units group).
%
% R: 4-digit limbs, columns j = 2m..0 of x_j - k h_j + carry in one
% nested \numexpr chain (\CALX_rd<m>, generated by tools/trig_genred.py,
% h_j literal; m >= 8: in two macros, \CALX_rdb<m> taking the inner part
% of the chain built by \CALX_rd<m>), carry by offset 1200000000.
% |X| 10^W is an integer (-8e <=
% D <= P + 7 < W + 8, hence z = e + m >= 0): its blocks are z zero blocks
% then the blocks of M
% (and a zero units block if E = 0), m + 1 groups of 8 digits. |r| < 1:
% the units limb is 0000 (R >= 0) or 9999 (R < 0), the higher limbs are
% not computed (exact modulo 10^(4(2m+1))).
%
% Output (\CALX_rh): q = k mod 4 and r as a native float, sign of R,
% e = -m, leading zero blocks stripped, D exact (\CALX_nd); for R < 0 the
% blocks are 99999999 - b (= |R| - 1). R = 0 gives r = 10^-W. Error on r
% (radians): < (k/2 + 1) 10^-W <= 3185 10^-(P+6) < 0.0032 10^-P.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_red #1.#2.%
{%
    \ifnum\numexpr#1+8*#2=\xint_c_ \xint_dothis{\CALX_rkc 1.}\fi
    \xint_orthat{\expandafter\CALX_rka\the\numexpr(2*#1+7)/16\expandafter.%
      \the\numexpr#1+8-8*((2*#1+7)/16).}%
    #1.#2.%
}%
\def\CALX_rka #1.#2.#3.#4.#5\xint:%
{%
    \expandafter\CALX_rkc\the\numexpr(\CALX_rta#1.#2.#5\xint:)%
      *636619772/1000000000/\CALX_pten{9-#3-8*#4}.#3.#4.#5\xint:%
}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_rta <n>.<d>.<blocks>\xint: (inside \numexpr): Xh from the top
% block T (d digits) and the next one B: T 10^(9-d) + round(B/10^(d-1)).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_rta #1.%
  {\ifnum#1>\xint_c_ii\expandafter\CALX_rtb\else\expandafter\CALX_rtc\fi#1.}%
\def\CALX_rtb #1.#2.1#3!{\expandafter\CALX_rta\the\numexpr#1-1.#2.}%
\def\CALX_rtc #1.{\csname CALX_rt#1\endcsname}%
\expandafter\def\csname CALX_rt1\endcsname #1.1#2!#3\xint:%
  {#2*\CALX_pten{9-#1}}%
\expandafter\def\csname CALX_rt2\endcsname #1.1#2!1#3!#4\xint:%
  {#3*\CALX_pten{9-#1}+#2/\CALX_pten{#1-1}}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_rkc <k>.<D>.<e>.<blocks>\xint: calls \CALX_rd<m> with {k},
% the m + 1 groups (\CALX_zg<z>, \CALX_bg), then ;<m>.<q>.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_trigm{\ifnum\CALX_trigdigits<\xint_c_ix 2\else
  (\CALX_trigdigits+9)/8\fi}%
\def\CALX_rkc #1.#2.#3.#4\xint:%
{%
    \csname CALX_rd\the\numexpr\CALX_trigm\expandafter\endcsname
    \expanded{{#1}%
      \csname CALX_zg\the\numexpr#3+\CALX_trigm\endcsname
      \CALX_bg#4\xint:\ifnum\numexpr#2+8*#3=\xint_c_{00000000}\fi
      ;\the\numexpr\CALX_trigm.\the\numexpr#1-4*((2*#1-3)/8).}%
}%
\def\CALX_bg #1{\xint_gob_til_xint: #1\CALX_bge\xint:\CALX_bh#1}%
\def\CALX_bge\xint:\CALX_bh\xint:{}%
\def\CALX_bh 1#1!{{#1}\CALX_bg}%
\expandafter\def\csname CALX_zg0\endcsname{}%
\expandafter\def\csname CALX_zg1\endcsname{{00000000}}%
\expandafter\def\csname CALX_zg2\endcsname{{00000000}{00000000}}%
\expandafter\def\csname CALX_zg3\endcsname
  {{00000000}{00000000}{00000000}}%
\expandafter\def\csname CALX_zg4\endcsname
  {{00000000}{00000000}{00000000}{00000000}}%
\expandafter\def\csname CALX_zg5\endcsname
  {{00000000}{00000000}{00000000}{00000000}{00000000}}%
\expandafter\def\csname CALX_zg6\endcsname
  {{00000000}{00000000}{00000000}{00000000}{00000000}{00000000}}%
\expandafter\edef\csname CALX_zg7\endcsname{\csname CALX_zg6\endcsname
  {00000000}}%
\expandafter\edef\csname CALX_zg8\endcsname{\csname CALX_zg7\endcsname
  {00000000}}%
\expandafter\edef\csname CALX_zg9\endcsname{\csname CALX_zg8\endcsname
  {00000000}}%
\expandafter\edef\csname CALX_zg10\endcsname{\csname CALX_zg9\endcsname
  {00000000}}%
\expandafter\edef\csname CALX_zg11\endcsname{\csname CALX_zg10\endcsname
  {00000000}}%
\expandafter\edef\csname CALX_zg12\endcsname{\csname CALX_zg11\endcsname
  {00000000}}%
\expandafter\edef\csname CALX_zg13\endcsname{\csname CALX_zg12\endcsname
  {00000000}}%
\expandafter\edef\csname CALX_zg14\endcsname{\csname CALX_zg13\endcsname
  {00000000}}%
\def\CALX_lo #1#2#3#4{}%
\def\CALX_hi #1#2#3#4#5#6#7#8{#1#2#3#4}%
\def\CALX_rp #1#2#3#4#5#6{+#1#2#3#4#5#6-120000!}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_rh: the chain output <top column>!<l_(2m-1)>!...!<l_0>!;<m>.<q>.
% (limbs MS first); the low limb of the top column gives the sign.
% \CALX_rsa <count>.<m>.<conv><sign> strips the leading zero blocks (pairs
% of limbs), \CALX_rv reverses the others (LS first) inside \expanded.
% <conv>: \CALX_bp (1<l><l>) or \CALX_bn (complement).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_rh #1#2#3#4#5#6#7!#8;#9.%
{%
    \expandafter\CALX_rz\expanded{\csname CALX_rs\ifnum#7=\xint_c_ p\else
      n\fi\endcsname#9.#9.#8}\xint:%
}%
\def\CALX_rz #1\xint:#2.{ #2.#1}%
\def\CALX_rsp #1.#2.{\CALX_rsa#1.#2.\CALX_bp+}%
\def\CALX_rsn #1.#2.{\CALX_rsa#1.#2.\CALX_bn-}%
\def\CALX_bp #1#2{1#1#2}%
\def\CALX_bn #1#2{\the\numexpr199999999-#1#2\relax}%
\def\CALX_rsa #1.#2.#3#4%
{%
    \ifnum#1=\xint_c_ \xint_dothis{F+1.-#2.100000001!}\fi
    \xint_orthat{\CALX_rsb#1.#2.#3#4}%
}%
\def\CALX_rsb #1.#2.#3#4#5!#6!%
{%
    \ifnum#3{#5}{#6}=100000000
      \expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo\fi
    {\expandafter\CALX_rsa\the\numexpr#1-1.#2.#3#4}%
    {F#4\the\numexpr8*#1-8+\expandafter\CALX_nd\the\numexpr#3{#5}{#6}.%
     .-#2.\expandafter\CALX_rv\the\numexpr#1-1.{#3{#5}{#6}!}#3}%
}%
\def\CALX_rv #1.{\ifnum#1=\xint_c_ \CALX_rve\fi\CALX_rvb#1.}%
\def\CALX_rve\fi\CALX_rvb#1.#2#3{\fi#2}%
\def\CALX_rvb #1.#2#3#4!#5!%
  {\expandafter\CALX_rv\the\numexpr#1-1.{#3{#4}{#5}!#2}#3}%
\def\CALX_nd #1.%
{%
    \ifnum#1<100010000
      \ifnum#1<100000100 \ifnum#1<100000010 1\else2\fi
      \else\ifnum#1<100001000 3\else4\fi\fi
    \else
      \ifnum#1<101000000 \ifnum#1<100100000 5\else6\fi
      \else\ifnum#1<110000000 7\else8\fi\fi
    \fi
}%
%    \end{macrocode}
%\begin{lverb}
% Generated by tools/trig_genred.py: \CALX_rd<m>, m = 2..14 (and
% \CALX_rdb<m>, m >= 8).
%\end{lverb}
%    \begin{macrocode}
\expandafter\def\csname CALX_rd2\endcsname#1#2#3#4%
{%
\expandafter\CALX_rh\the\numexpr 1200000000+\CALX_lo#4-#1*1%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*5707%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*9632%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#2-#1*6794%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#2-#1*8966\relax!%
}%
\expandafter\def\csname CALX_rd3\endcsname#1#2#3#4#5%
{%
\expandafter\CALX_rh\the\numexpr 1200000000+\CALX_lo#5-#1*1%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*5707%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*9632%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*6794%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*8966%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#2-#1*1923%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#2-#1*1322\relax!%
}%
\expandafter\def\csname CALX_rd4\endcsname#1#2#3#4#5#6%
{%
\expandafter\CALX_rh\the\numexpr 1200000000+\CALX_lo#6-#1*1%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#5-#1*5707%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#5-#1*9632%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*6794%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*8966%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*1923%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*1321%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#2-#1*6916%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#2-#1*3975\relax!%
}%
\expandafter\def\csname CALX_rd5\endcsname#1#2#3#4#5#6#7%
{%
\expandafter\CALX_rh\the\numexpr 1200000000+\CALX_lo#7-#1*1%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#6-#1*5707%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#6-#1*9632%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#5-#1*6794%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#5-#1*8966%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*1923%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*1321%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*6916%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*3975%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#2-#1*1442%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#2-#1*986\relax!%
}%
\expandafter\def\csname CALX_rd6\endcsname#1#2#3#4#5#6#7#8%
{%
\expandafter\CALX_rh\the\numexpr 1200000000+\CALX_lo#8-#1*1%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#7-#1*5707%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#7-#1*9632%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#6-#1*6794%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#6-#1*8966%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#5-#1*1923%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#5-#1*1321%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*6916%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*3975%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*1442%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*985%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#2-#1*8469%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#2-#1*9688\relax!%
}%
\expandafter\def\csname CALX_rd7\endcsname#1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_rh\the\numexpr 1200000000+\CALX_lo#9-#1*1%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#8-#1*5707%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#8-#1*9632%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#7-#1*6794%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#7-#1*8966%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#6-#1*1923%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#6-#1*1321%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#5-#1*6916%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#5-#1*3975%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*1442%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*985%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*8469%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*9687%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#2-#1*5529%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#2-#1*1049\relax!%
}%
\expandafter\def\csname CALX_rd8\endcsname#1#2#3#4#5#6#7#8#9%
{%
\csname CALX_rdb8\endcsname{#1}{%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#9-#1*5707%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#9-#1*9632%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#8-#1*6794%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#8-#1*8966%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#7-#1*1923%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#7-#1*1321%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#6-#1*6916%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#6-#1*3975%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#5-#1*1442%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#5-#1*985%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*8469%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*9687%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*5529%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*1048%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#2-#1*7472%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#2-#1*2962\relax!%
}%
}%
\expandafter\def\csname CALX_rdb8\endcsname#1#2#3%
{%
\expandafter\CALX_rh\the\numexpr 1200000000+\CALX_lo#3-#1*1%
#2}%
\expandafter\def\csname CALX_rd9\endcsname#1#2#3#4#5#6#7#8#9%
{%
\csname CALX_rdb9\endcsname{#1}{%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#9-#1*6794%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#9-#1*8966%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#8-#1*1923%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#8-#1*1321%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#7-#1*6916%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#7-#1*3975%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#6-#1*1442%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#6-#1*985%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#5-#1*8469%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#5-#1*9687%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*5529%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*1048%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*7472%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*2961%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#2-#1*5390%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#2-#1*8203\relax!%
}%
}%
\expandafter\def\csname CALX_rdb9\endcsname#1#2#3#4%
{%
\expandafter\CALX_rh\the\numexpr 1200000000+\CALX_lo#4-#1*1%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*5707%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*9632%
#2}%
\expandafter\def\csname CALX_rd10\endcsname#1#2#3#4#5#6#7#8#9%
{%
\csname CALX_rdb10\endcsname{#1}{%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#9-#1*1923%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#9-#1*1321%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#8-#1*6916%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#8-#1*3975%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#7-#1*1442%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#7-#1*985%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#6-#1*8469%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#6-#1*9687%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#5-#1*5529%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#5-#1*1048%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*7472%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*2961%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*5390%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*8203%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#2-#1*1431%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#2-#1*450\relax!%
}%
}%
\expandafter\def\csname CALX_rdb10\endcsname#1#2#3#4#5%
{%
\expandafter\CALX_rh\the\numexpr 1200000000+\CALX_lo#5-#1*1%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*5707%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*9632%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*6794%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*8966%
#2}%
\expandafter\def\csname CALX_rd11\endcsname#1#2#3#4#5#6#7#8#9%
{%
\csname CALX_rdb11\endcsname{#1}{%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#9-#1*6916%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#9-#1*3975%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#8-#1*1442%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#8-#1*985%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#7-#1*8469%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#7-#1*9687%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#6-#1*5529%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#6-#1*1048%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#5-#1*7472%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#5-#1*2961%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*5390%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*8203%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*1431%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*449%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#2-#1*9314%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#2-#1*174\relax!%
}%
}%
\expandafter\def\csname CALX_rdb11\endcsname#1#2#3#4#5#6%
{%
\expandafter\CALX_rh\the\numexpr 1200000000+\CALX_lo#6-#1*1%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#5-#1*5707%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#5-#1*9632%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*6794%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*8966%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*1923%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*1321%
#2}%
\expandafter\def\csname CALX_rd12\endcsname#1#2#3#4#5#6#7#8#9%
{%
\csname CALX_rdb12\endcsname{#1}{%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#9-#1*1442%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#9-#1*985%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#8-#1*8469%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#8-#1*9687%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#7-#1*5529%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#7-#1*1048%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#6-#1*7472%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#6-#1*2961%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#5-#1*5390%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#5-#1*8203%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*1431%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*449%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*9314%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*174%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#2-#1*1267%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#2-#1*1059\relax!%
}%
}%
\expandafter\def\csname CALX_rdb12\endcsname#1#2#3#4#5#6#7%
{%
\expandafter\CALX_rh\the\numexpr 1200000000+\CALX_lo#7-#1*1%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#6-#1*5707%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#6-#1*9632%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#5-#1*6794%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#5-#1*8966%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*1923%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*1321%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*6916%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*3975%
#2}%
\expandafter\def\csname CALX_rd13\endcsname#1#2#3#4#5#6#7#8#9%
{%
\csname CALX_rdb13\endcsname{#1}{%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#9-#1*8469%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#9-#1*9687%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#8-#1*5529%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#8-#1*1048%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#7-#1*7472%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#7-#1*2961%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#6-#1*5390%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#6-#1*8203%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#5-#1*1431%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#5-#1*449%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*9314%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*174%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*1267%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*1058%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#2-#1*5339%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#2-#1*9107\relax!%
}%
}%
\expandafter\def\csname CALX_rdb13\endcsname#1#2#3#4#5#6#7#8%
{%
\expandafter\CALX_rh\the\numexpr 1200000000+\CALX_lo#8-#1*1%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#7-#1*5707%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#7-#1*9632%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#6-#1*6794%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#6-#1*8966%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#5-#1*1923%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#5-#1*1321%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*6916%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*3975%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*1442%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*985%
#2}%
\expandafter\def\csname CALX_rd14\endcsname#1#2#3#4#5#6#7#8#9%
{%
\csname CALX_rdb14\endcsname{#1}{%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#9-#1*5529%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#9-#1*1048%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#8-#1*7472%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#8-#1*2961%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#7-#1*5390%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#7-#1*8203%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#6-#1*1431%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#6-#1*449%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#5-#1*9314%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#5-#1*174%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*1267%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*1058%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*5339%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*9107%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#2-#1*4043%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#2-#1*2566\relax!%
}%
}%
\expandafter\def\csname CALX_rdb14\endcsname#1#2#3#4#5#6#7#8#9%
{%
\expandafter\CALX_rh\the\numexpr 1200000000+\CALX_lo#9-#1*1%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#8-#1*5707%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#8-#1*9632%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#7-#1*6794%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#7-#1*8966%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#6-#1*1923%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#6-#1*1321%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#5-#1*6916%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#5-#1*3975%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#4-#1*1442%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#4-#1*985%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_hi#3-#1*8469%
\expandafter\CALX_rp\the\numexpr 1200000000+\CALX_lo#3-#1*9687%
#2}%
%    \end{macrocode}
%\begin{lverb}
% Reduction for 10^4 <= |X| < 10^E, E = D + 8e <= min(P, 126 - P), from
% the callers (\CALX_sin_r, \CALX_cos_r, \CALX_sc_rr) when E > 4: jumpers
% \CALX_rj (sin, cos) and \CALX_rjs (tan, cot, sec, csc, sinc), which
% replace \CALX_red by \CALX_rslow, or, if E > min(P, 126 - P), drop the
% continuation (\CALX_rjx, \CALX_rjxs: also the finisher and its three
% arguments) and signal ControversialOperation (result I?).
%
% Integers (M: the integer of the blocks of |X|, |X| = M 10^(8e)):
%(
%:   W = 8 ceil((P+E+2)/8) <= 128,   G = E + 3,
%:   T = round(2/pi 10^G),   k = round(M T 10^(8e-G)),
%:   H = round(pi/2 10^W),   R = M 10^(W+8e) - k H,   r = R 10^-W,
%)
% T and H by rounded shifts (\CALX_nshrr) of \CALX_rT = round(2/pi
% 10^130) and \CALX_rH = round(pi/2 10^129). The error on 2|X|/pi is
% < 0.006 (|r| < 0.8); the error on r is < (k/2 + 1) 10^-W <= 0.005
% 10^-P. q = k mod 4 from the low block of k; r rounded to P+4 digits.
%\end{lverb}
%    \begin{macrocode}
\edef\CALX_rT{\romannumeral0\CALX_nfromraw
  {63661977236758134307553505349005744813783858296182579499066937623558719%
  05369061403604552110650123438242913709070318321475716473845}}%
\edef\CALX_rH{\romannumeral0\CALX_nfromraw
  {15707963267948966192313216916397514420985846996875529104874722961539082%
  03143104499314017412671058533991074043256641153323546922305}}%
\def\CALX_rj\fi#1\CALX_red #2.#3.%
{%
    \fi
    \ifnum\numexpr#2+8*#3>\numexpr\ifnum\CALX_trigdigits>63 126-\fi
      \CALX_trigdigits\relax \CALX_rjx\fi
    #1\CALX_rslow #2.#3.%
}%
\def\CALX_rjs\fi#1\CALX_red #2.#3.%
{%
    \fi
    \ifnum\numexpr#2+8*#3>\numexpr\ifnum\CALX_trigdigits>63 126-\fi
      \CALX_trigdigits\relax \CALX_rjxs\fi
    #1\CALX_rslow #2.#3.%
}%
\def\CALX_rjx\fi#1\xint:\xint:%
  {\fi\CALX_nsig{ControversialOperation}{trig: argument too large}{}}%
\def\CALX_rjxs\fi#1\xint:\xint:#2#3#4%
  {\fi\CALX_nsig{ControversialOperation}{trig: argument too large}{}}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_rslow, P <= 8 (\CALX_rse; then 5 <= E <= P, |x| < 10^8): A exact
% (9 digits), F = 10^(9-E), a = floor(A/F) = 10^4 a1 + a0, b = A - a F;
%(
%:   k = 6366 a1 + round((a1 1977236758/10^5 + a0 636619772/10^4
%:       + b 636619772/10^(13-E)) / 10^5)
%)
% (2/pi to 10 digits, error on 2|x|/pi < 0.001); B1 with m = 3 (W = 24)
% and k = 10^4 k1 + k0 (\CALX_rwk, columns x_j - k0 h_j - k1 h_(j-1),
% H = round(pi/2 10^24); x_5, x_6 from G = (A 10^(E-5)) mod 10^8, the
% lower limbs of |x| 10^24 being 0); output by \CALX_rh as \CALX_red.
% Error on r < (k/2 + 1) 10^-24. P > 8: \CALX_rsl.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_rslow
{%
    \ifnum\CALX_trigdigits<\xint_c_ix \xint_dothis\CALX_rse\fi
    \xint_orthat\CALX_rsl
}%
\def\CALX_rse #1.#2.#3\xint:%
{%
    \expandafter\CALX_rsf\the\numexpr#1+8*#2\expandafter.%
    \the\numexpr(2*#1+7)/16\expandafter.%
    \the\numexpr#1+8-8*((2*#1+7)/16).#3\xint:%
}%
\def\CALX_rsf #1.#2.#3.#4\xint:%
  {\expandafter\CALX_rsg\the\numexpr\CALX_rta#2.#3.#4\xint:.#1.}%
\def\CALX_rsg #1.#2.%
{%
    \expandafter\CALX_rsh\the\numexpr(2*#1-\CALX_pten{9-#2})%
      /(2*\CALX_pten{9-#2}).#1.#2.%
}%
\def\CALX_rsh #1.%
  {\expandafter\CALX_rsi\the\numexpr(2*#1-10000)/20000.#1.}%
\def\CALX_rsi #1.#2.#3.#4.%
{%
    \expandafter\CALX_rsj\the\numexpr#1*6366+(#1*1977236758/100000%
      +(#2-#1*10000)*636619772/10000%
      +(#3-#2*\CALX_pten{9-#4})*636619772/\CALX_pten{13-#4})/100000.%
    #3.#4.%
}%
\def\CALX_rsj #1.#2.#3.%
{%
    \expandafter\CALX_rsm\the\numexpr(#2-((2*#2-\CALX_pten{13-#3})%
      /(2*\CALX_pten{13-#3}))*\CALX_pten{13-#3})*\CALX_pten{#3-5}%
    \expandafter.\the\numexpr(2*#1-10000)/20000\expandafter.%
    \the\numexpr#1-4*((2*#1-3)/8).#1.%
}%
\def\CALX_rsm #1.%
  {\expandafter\CALX_rwk\the\numexpr(2*#1-10000)/20000.#1.}%
\def\CALX_rwk #1.#2.#3.#4.#5.%
{%
    \expandafter\CALX_rh\the\numexpr1200000000+#1-(#5-#3*10000)-#3*5707%
    \expandafter\CALX_rp\the\numexpr1200000000+#2-#1*10000%
      -(#5-#3*10000)*5707-#3*9632%
    \expandafter\CALX_rp\the\numexpr1200000000-(#5-#3*10000)*9632-#3*6794%
    \expandafter\CALX_rp\the\numexpr1200000000-(#5-#3*10000)*6794-#3*8966%
    \expandafter\CALX_rp\the\numexpr1200000000-(#5-#3*10000)*8966-#3*1923%
    \expandafter\CALX_rp\the\numexpr1200000000-(#5-#3*10000)*1923-#3*1322%
    \expandafter\CALX_rp\the\numexpr1200000000-(#5-#3*10000)*1322\relax!%
    ;3.#4.%
}%
\def\CALX_rsl #1.#2.%
{%
    \expandafter\CALX_rxa\the\numexpr8*((\CALX_trigdigits+#1+8*#2+5)/8)%
    \expandafter.\the\numexpr#1+8*#2\expandafter.%
    \the\numexpr(2*#1+7)/16.#2.%
}%
\def\CALX_rxa #1.#2.#3.#4.#5\xint:%
{%
    \expandafter\CALX_rxb\romannumeral0\CALX_nshrr{#2+3-8*#4}%
      {\romannumeral0\CALX_nmul{N+#3.#5}%
        {\romannumeral0\CALX_nshrr{127-#2}{\CALX_rT}}}%
    \xint:#1.#3.#4.#5\xint:%
}%
\def\CALX_rxb N+#1.#2!#3\xint:#4.#5.#6.#7\xint:%
{%
    \expandafter\CALX_red_z\the\numexpr#2-4*((2*#2-3)/8)\expandafter.%
    \romannumeral0\CALX_fnround{\CALX_trigdigits+4}%
      {\CALX_ffromraw{\expanded{\romannumeral0\CALX_ntoraw
        {\romannumeral0\CALX_nsub
          {\romannumeral0\CALX_nshl{#4+8*#6}{N+#5.#7}}%
          {\romannumeral0\CALX_nmul{N+#1.#2!#3}%
            {\romannumeral0\CALX_nshrr{129-#4}{\CALX_rH}}}}%
        [-#4]}}}%
}%
%    \end{macrocode}
%\begin{lverb}
% Degree reduction \CALX_red_a (\CALX_sc_fo, route of xinttrig), Y = |x|
% in degrees: T = floor(Y 10^L), L = 8 ceil((P+5)/8) (xinttrig: P+5
% decimals); I =
% floor(T/10^L), m = I mod 360 (10^8 = 280 mod 360 and 280^2 = 280 mod
% 360: m = (b_0 + 280 sum_{j>0} b_j) mod 360 on the blocks b_j of I);
% q = floor((m+45)/90) = round((2m+1)/180) in 0..4; r_fix = T - (I - m +
% 90q) 10^L, |r_fix| <= 45 10^L; r = round_{P+4}(r_fix 10^-L Dg), Dg =
% pi/180 rounded to P+4 digits; |r| <= 0.786 (u <= 0.62).
%
% Absolute error of r (radians): < 10^-(P+5) + 10^-(P+4) (Dg, rounding
% of r).
%
% Radians (\CALX_sin_s, \CALX_cos_s, q from \CALX_red or \CALX_rslow):
% quadrant q mod 4: sin = S, C, -S, -C (times sign of X), cos = C, -S,
% -C, S, with S, C the series kernels at r (K = max(2, ceil((P+4)/8)),
% final rounding to P).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_trigL{(8*((\CALX_trigdigits+8)/8))}%
\def\CALX_sin_r #1#2.#3.#4\xint:%
{%
    \ifnum\CALX_trigdigits<\xint_c_ix \CALX_rpq s#1\fi
    \ifnum\numexpr#2+8*#3>\xint_c_iv \CALX_rj\fi
    \expandafter\CALX_sin_s\expandafter#1%
    \romannumeral0\CALX_red #2.#3.#4\xint:\xint:%
}%
\def\CALX_cos_r #1#2.#3.#4\xint:%
{%
    \ifnum\CALX_trigdigits<\xint_c_ix \CALX_rpq c+\fi
    \ifnum\numexpr#2+8*#3>\xint_c_iv \CALX_rj\fi
    \expandafter\CALX_cos_s\romannumeral0\CALX_red #2.#3.#4\xint:\xint:%
}%
%    \end{macrocode}
%\begin{lverb}
% P <= 8, 0.8 <= |x| < 10^4: reduction in \numexpr without natives
% (\CALX_rq <A>.<E>., |x| = A 10^(E-9) exact, E <= 4), output
% <q>.<s><A'>.<E'>.<A>.<E>. (r = s A' 10^(E'-9), A' 9 digits):
%(
%:   k = round(2|x|/pi) (c = 636619772),   pi/2 = (H1 + H2 10^-9 +
%:   H3 10^-18) 10^-9,  H1 = 1570796326, H2 = 794896619, H3 = 231321691,
%:   10^9 r = R1 - R2 10^-9,   R1 = A 10^E - k H1 - floor(k H2/10^9),
%:   R2 = (k H2 mod 10^9) + round(k H3/10^9)
%)
% (A 10^E - k H1 by halves of 10^5, k H2 by halves of 10^4 and 10^5: all
% intermediate values < 2^31). |R1| >= 2: A' from R1 and R2 with the
% digit count of |R1| (minus 1 if R1 > 0); |R1| <= 1: from R1 10^9 - R2
% (relative accuracy kept when r is small). Callers: \CALX_rpq (sin,
% cos: \CALX_rps<q>, \CALX_rpc<q>, kernels \CALX_rks, \CALX_rkk) and
% \CALX_sc_kd (tan, cot, sec, csc, sinc).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_rpq #1#2\fi #3\romannumeral0\CALX_red #4.#5.#6\xint:\xint:%
{%
    \fi
    \ifnum\numexpr#4+8*#5>\xint_c_iv
      \expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo\fi
    {#3\romannumeral0\CALX_red #4.#5.#6\xint:\xint:}%
    {\expandafter\CALX_rpa\the\numexpr#4+8*#5\expandafter.%
     \the\numexpr(2*#4+7)/16\expandafter.%
     \the\numexpr#4+8-8*((2*#4+7)/16).#6\xint:#1#2}%
}%
\def\CALX_rpa #1.#2.#3.#4\xint:%
{%
    \expandafter\CALX_rpb\romannumeral0\expandafter\CALX_rq
    \the\numexpr\CALX_rta#2.#3.#4\xint:.#1.%
}%
\def\CALX_rpb #1.#2#3.#4.#5.#6.#7#8%
  {\csname CALX_rp#7#1\endcsname#8#2#3.#4.}%
\expandafter\def\csname CALX_rps0\endcsname#1#2{\CALX_rks#11*#21.}%
\expandafter\def\csname CALX_rps1\endcsname#1#2{\CALX_rkk#11.}%
\expandafter\def\csname CALX_rps2\endcsname#1#2{\CALX_rks-1*#11*#21.}%
\expandafter\def\csname CALX_rps3\endcsname#1#2{\CALX_rkk-1*#11.}%
\expandafter\def\csname CALX_rpc0\endcsname#1#2{\CALX_rkk1.}%
\expandafter\def\csname CALX_rpc1\endcsname#1#2{\CALX_rks-1*#21.}%
\expandafter\def\csname CALX_rpc2\endcsname#1#2{\CALX_rkk-1.}%
\expandafter\def\csname CALX_rpc3\endcsname#1#2{\CALX_rks#21.}%
\def\CALX_rks #1.#2.#3.%
{%
    \ifnum#3<-\xint_c_iv \xint_dothis\CALX_rks_tiny\fi
    \xint_orthat\CALX_rks_regular #1.#2.#3.%
}%
\def\CALX_rks_tiny #1.#2.#3.%
  {\expandafter\CALX_dgo\the\numexpr#1*#2\expandafter.\the\numexpr#3-9.}%
\def\CALX_rks_regular #1.#2.#3.%
  {\expandafter\CALX_rksa\the\numexpr\CALX_qkz#2.#3..#1.#2.#3.}%
\def\CALX_rksa #1.#2.#3.#4.%
{%
    \expandafter\CALX_dgo
    \the\numexpr#2*#3*(\CALX_sinaux#1.)/1000000000.#4-9.%
}%
\def\CALX_rkk #1.#2.#3.%
{%
    \expandafter\CALX_dgo\the\numexpr#1*(%
      \expandafter\CALX_cosaux\the\numexpr\CALX_qkz#2.#3..).-9.%
}%
\def\CALX_rq #1.#2.%
{%
    \expandafter\CALX_rqa
    \the\numexpr(#1*636619772/1000000000)/\CALX_pten{9-#2}.#1.#2.%
}%
\def\CALX_rqa #1.#2.#3.%
{%
    \expandafter\CALX_rqb\the\numexpr(2*#2-\CALX_pten{5-#3})%
      /(2*\CALX_pten{5-#3}).#1.#2.#3.%
}%
\def\CALX_rqb #1.#2.#3.#4.%
{%
    \expandafter\CALX_rqc\the\numexpr(#1-#2*15707)*100000%
      +(#3-#1*\CALX_pten{5-#4})*\CALX_pten{#4}-#2*96326.#2.#3.#4.%
}%
\def\CALX_rqc #1.#2.%
  {\expandafter\CALX_rqd\the\numexpr(2*#2*7948-10000)/20000.#1.#2.}%
\def\CALX_rqd #1.#2.#3.%
{%
    \expandafter\CALX_rqe\the\numexpr(#3*7948-#1*10000)*100000+#3*96619.%
    #1.#2.#3.%
}%
\def\CALX_rqe #1.#2.#3.#4.%
{%
    \expandafter\CALX_rqf\the\numexpr#3-#2-\ifnum#1<1000000000 0\else1\fi
    \expandafter.\the\numexpr#1-\ifnum#1<1000000000 0\else1000000000\fi
    +#4*231321691/1000000000.#4.%
}%
\def\CALX_rqf #1.#2.#3.%
{%
    \expandafter\CALX_rqg\the\numexpr#3-4*((2*#3-3)/8)\expandafter.%
    \romannumeral0\ifnum\ifnum#1<\xint_c_ -\fi#1<\xint_c_ii
      \expandafter\CALX_rqs\else\expandafter\CALX_rql\fi #1.#2.%
}%
\def\CALX_rqg #1.#2.#3.{ #1.#2.#3.}%
\def\CALX_rql #1.#2.%
{%
    \expandafter\CALX_rqm\the\numexpr\ifnum#1>\xint_c_ #1-1\else-#1\fi
    .#1.#2.%
}%
\def\CALX_rqm #1.%
  {\expandafter\CALX_rqn\the\numexpr\CALX_nd_c #19987654321\xint:.}%
\def\CALX_rqn #1.#2.#3.%
{%
    \ifnum#2>\xint_c_ \expandafter\CALX_rqp\else\expandafter\CALX_rqo\fi
    #1.#2.#3.%
}%
\def\CALX_rqp #1.#2.#3.%
{%
    \expandafter\CALX_rqw\the\numexpr#2*\CALX_pten{9-#1}-#3/\CALX_pten{#1}%
    \expandafter.\the\numexpr#1-9.+%
}%
\def\CALX_rqo #1.#2.#3.%
{%
    \expandafter\CALX_rqw\the\numexpr-#2*\CALX_pten{9-#1}+#3/\CALX_pten{#1}%
    \expandafter.\the\numexpr#1-9.-%
}%
\def\CALX_rqw #1.#2.#3{ #3#1.#2.}%
\def\CALX_rqs #1.#2.%
  {\expandafter\CALX_rqt\the\numexpr#1*1000000000-#2.}%
\def\CALX_rqt #1#2.%
{%
    \if-#1\expandafter\CALX_rqu\expandafter-\else
      \expandafter\CALX_rqu\expandafter+\expandafter#1\fi #2.%
}%
\def\CALX_rqu #1#2.%
{%
    \expandafter\CALX_rqv\the\numexpr
    \CALX_nd_c #2{10}987654321\xint:.#1#2.%
}%
\def\CALX_rqv #1.#2#3.%
{%
    \expandafter\CALX_rqw\the\numexpr\ifnum#1=10 #3/10\else
      #3*\CALX_pten{9-#1}\fi\expandafter.\the\numexpr#1-18.#2%
}%
\def\CALX_sin_s #1#2.#3\xint:%
{%
    \ifcase#2 \expandafter\CALX_fin_p\expandafter s%
    \or       \expandafter\CALX_fin_p\expandafter c%
    \or       \expandafter\CALX_fin_n\expandafter s%
    \else     \expandafter\CALX_fin_n\expandafter c%
    \fi #1{#3}%
}%
\def\CALX_cos_s #1.#2\xint:%
{%
    \ifcase#1 \expandafter\CALX_fin_p\expandafter c%
    \or       \expandafter\CALX_fin_n\expandafter s%
    \or       \expandafter\CALX_fin_n\expandafter c%
    \else     \expandafter\CALX_fin_p\expandafter s%
    \fi +{#2}%
}%
\def\CALX_fin_p #1#2%
  {\if-#2\expandafter\CALX_fin_neg\else\expandafter\CALX_ser\fi{#1}}%
\def\CALX_fin_n #1#2%
  {\if-#2\expandafter\CALX_ser\else\expandafter\CALX_fin_neg\fi{#1}}%
\def\CALX_fin_neg #1#2%
  {\expandafter\CALX_fopp_a\romannumeral0\CALX_ser{#1}{#2}\xint:}%
\def\CALX_ser #1#2{\CALX_ser_a #1#2\xint:}%
\def\CALX_ser_a #1F#2\xint:%
{%
    \if s#1\expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo\fi
    {\expandafter\CALX_sin_h}{\expandafter\CALX_cos_h}%
    \the\numexpr\ifnum\CALX_trigdigits<\xint_c_ix 2\else
                (\CALX_trigdigits+7)/8\fi.#2\xint:%
}%
\def\CALX_red_a F+#1.#2.#3\xint:%
{%
    \expandafter\CALX_red_b\romannumeral0\CALX_nshr
      {\numexpr-8*#2-\CALX_trigL}{\romannumeral0\CALX_nshl
      {\numexpr8*#2+\CALX_trigL}{\expanded{N+\the\numexpr(2*#1+7)/16.#3}}}%
    \xint:%
}%
\def\CALX_red_b #1\xint:%
{%
    \expandafter\CALX_red_c
    \romannumeral0\CALX_nshr{\CALX_trigL}{#1}\xint:#1\xint:%
}%
\def\CALX_red_c #1\xint:#2\xint:%
{%
    \expandafter\CALX_red_d\the\numexpr\CALX_mmod #1\xint:.#1\xint:#2\xint:%
}%
\def\CALX_red_d #1.%
  {\expandafter\CALX_red_e\the\numexpr(2*#1+1)/180.#1.}%
\def\CALX_red_e #1.#2.#3\xint:#4\xint:%
{%
    \expandafter\CALX_red_f\romannumeral0\CALX_nsub{#4}%
      {\romannumeral0\CALX_nshl{\CALX_trigL}%
        {\romannumeral0\CALX_nsub{#3}%
          {\expanded{\CALX_nsmall{\numexpr#2-90*#1}}}}}%
    \xint:#1.%
}%
\def\CALX_red_f #1\xint:#2.%
{%
    \expandafter\CALX_red_g\romannumeral`&&@%
      \csname CALX_pdg\the\numexpr\CALX_trigdigits\endcsname\xint:#1\xint:#2.%
}%
\def\CALX_red_g F+#1.#2.#3\xint:#4\xint:#5.%
{%
    \expandafter\CALX_red_z\the\numexpr\ifnum#5=4 0\else#5\fi
    \expandafter.\romannumeral0\CALX_fnround{\CALX_trigdigits+4}%
      {\CALX_ffromraw{\expanded{\romannumeral0\CALX_ntoraw
        {\romannumeral0\CALX_nmul{#4}%
          {\expanded{N+\the\numexpr(2*#1+7)/16.#3}}}%
        [\the\numexpr8*#2-\CALX_trigL]}}}%
}%
\def\CALX_red_z #1.{ #1.}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_mmod N<s><n>.<blocks>\xint: (inside \numexpr): I mod 360.
%\end{lverb}
%    \begin{macrocode}
\def\CALX_mmod N#1.1#2!#3\xint:%
{%
    \expandafter\CALX_mmod_b\the\numexpr\CALX_msum 0.#31;!.#2.%
}%
\def\CALX_msum #1.1#2#3!%
{%
    \if;#2\xint_dothis{#1}\fi
    \xint_orthat{\expandafter\CALX_msum\the\numexpr#1+#2#3.}%
}%
\def\CALX_mod #1{(#1-360*((2*(#1)-359)/720))}%
\def\CALX_mmod_b #1.#2.{\CALX_mod{\CALX_mod{#2}+280*\CALX_mod{#1}}}%
%    \end{macrocode}
%\begin{lverb}
% \CALX_nsmall{c}: native integer c, |c| < 10^8 (use inside \expanded).
%\end{lverb}
%    \begin{macrocode}
\def\CALX_nsmall #1{\expandafter\CALX_nsmall_a\the\numexpr#1.}%
\def\CALX_nsmall_a #1.%
{%
    \ifnum#1=\xint_c_ N+0.\else
    N\ifnum#1<\xint_c_-\else+\fi1.%
    \the\numexpr100000000\ifnum#1<\xint_c_-(#1)\else+#1\fi!\fi
}%
%    \end{macrocode}
% Back to caller calx.sty.  We restore letter catcodes.
% Memo: the docstrip extraction will add |\endinput| anyhow.
%    \begin{macrocode}
\catcode`F 11 \catcode`I 11 \catcode`N 11
%    \end{macrocode}
% \subsection{Trigonometric functions of \cshnolabel{xinteval}, constants}
%\begin{lverb}
% Trigonometric functions of \xinteval:
% \calxRaw<Name> applies
% \calxFp<Name> (at \XINTdigits, raw argument rounded on entry) and
% converts the F result back to raw A[N]. One macro token per function,
% as required by the \xintdeffunc hooks (\XINT:NE:f:one:from:one, two).
%
% Variables twoPi, threePiover2, Pi, Piover2, oneDegree, oneRadian (raw,
% P digits, from 110-digit literals), redefined by \xintDigits (with or
% without *) and \xintSetDigits. A future constant (e.g. for exp(1))
% goes into \CALX_trigvars too.
%\end{lverb}
%    \begin{macrocode}
\def\XINT_tmpa #1#2%
{%
    \expandafter\edef\csname calxRaw#2\endcsname##1%
       {\noexpand\romannumeral0\noexpand\CALX_ftoraw
        {\expandafter\noexpand\csname calxFp#2\endcsname{##1}}}%
    \expandafter\edef\csname XINT_expr_func_#1\endcsname##1##2##3%
    {%
        \noexpand\expandafter ##1\noexpand\expandafter ##2%
        \noexpand\expandafter{%
        \noexpand\romannumeral`&&@\noexpand\XINT:NEhook:f:one:from:one
        {\noexpand\romannumeral`&&@\expandafter\noexpand
         \csname calxRaw#2\endcsname##3}}%
    }%
}%
\XINT_tmpa{sin}{Sin}%
\XINT_tmpa{cos}{Cos}%
\XINT_tmpa{tan}{Tan}%
\XINT_tmpa{cot}{Cot}%
\XINT_tmpa{sec}{Sec}%
\XINT_tmpa{csc}{Csc}%
\XINT_tmpa{sinc}{Sinc}%
\XINT_tmpa{sind}{Sind}%
\XINT_tmpa{cosd}{Cosd}%
\XINT_tmpa{tand}{Tand}%
\XINT_tmpa{cotd}{Cotd}%
\XINT_tmpa{secd}{Secd}%
\XINT_tmpa{cscd}{Cscd}%
\XINT_tmpa{asin}{Asin}%
\XINT_tmpa{acos}{Acos}%
\XINT_tmpa{asind}{Asind}%
\XINT_tmpa{acosd}{Acosd}%
\XINT_tmpa{atan}{Atan}%
\XINT_tmpa{atand}{Atand}%
\XINT_tmpa{asec}{Asec}%
\XINT_tmpa{acsc}{Acsc}%
\def\XINT_tmpa #1#2%
{%
    \expandafter\edef\csname calxRaw#2\endcsname##1##2%
       {\noexpand\romannumeral0\noexpand\CALX_ftoraw
        {\expandafter\noexpand\csname calxFp#2\endcsname{##1}{##2}}}%
    \expandafter\edef\csname XINT_expr_func_#1\endcsname##1##2##3%
    {%
        \noexpand\expandafter ##1\noexpand\expandafter ##2%
        \noexpand\expandafter{%
        \noexpand\romannumeral`&&@\noexpand\XINT:NEhook:f:one:from:two
        {\noexpand\romannumeral`&&@\expandafter\noexpand
         \csname calxRaw#2\endcsname##3}}%
    }%
}%
\XINT_tmpa{Arg}{Arg}%
\XINT_tmpa{Argd}{Argd}%
\XINT_tmpa{pArg}{pArg}%
\XINT_tmpa{pArgd}{pArgd}%
\XINT_tmpa{atan2}{Atantwo}%
\XINT_tmpa{atan2d}{Atantwod}%
\let\XINT_tmpa\undefined
\let\XINT_expr_func_tg\XINT_expr_func_tan
\let\XINT_expr_func_cotg\XINT_expr_func_cot
\let\XINT_expr_func_arcsin\XINT_expr_func_asin
\let\XINT_expr_func_arccos\XINT_expr_func_acos
\let\XINT_expr_func_arctg\XINT_expr_func_atan
\let\XINT_expr_func_arcsec\XINT_expr_func_asec
\let\XINT_expr_func_arccsc\XINT_expr_func_acsc
\def\CALX_trigvars
{%
\xintdeffloatvar twoPi := 0+
6.28318530717958647692528676655900576839433879875021164%
1949889184615632812572417997256069650684234135964296173;%
\xintdeffloatvar threePiover2 := 0+
4.71238898038468985769396507491925432629575409906265873%
14624168884617246094293134979420522380131756019732221298;%
\xintdeffloatvar Pi := 0+
3.14159265358979323846264338327950288419716939937510582%
09749445923078164062862089986280348253421170679821480865;%
\xintdeffloatvar Piover2 := 0+
1.57079632679489661923132169163975144209858469968755291%
04874722961539082031431044993140174126710585339910740433;%
\xintdeffloatvar oneDegree := 0+
0.01745329251994329576923690768488612713442871888541725%
4560971914401710091146034494436822415696345094822123044925;%
\xintdeffloatvar oneRadian := 0+
57.2957795130823208767981548141051703324054724665643215%
49160243861202847148321552632440968995851110944186223382;%
}%
\CALX_trigvars
%    \end{macrocode}
% The |\endinput| added during docstrip extraction.
% \StoreCodelineNo {calxtrig}
% \cleardoublepage\let\calxtrignameUp\undefined
%\gardesactifs
%\let</calxtrig>\relax
%\let<*calxtrigdata>\gardesinactifs
%</calxtrig>------------------------------------------------------
%<*calxtrigdata>^^A-------------------------------------------------------
%^^A -*- coding: utf-8; mode: doctex; fill-column: 78; sentence-end-double-space: t; eval: (auto-fill-mode -1); fill-paragraph-function: nil; -*-
% \clearpage\csname calxtrigdatanameUp\endcsname
% \let\MakePrivateLetters\xintMakePrivateLetters
% \section{Library \calxtrignameimp data tables}
% \RaisedLabel{sec:calxtrigdataimp}
% \addedcalx{2.0a1}
%
% calxtrigdata.tex: generated by gencalxdata.py (private repository).
% Do not edit. Data of calxtrig.tex, input by it under the standard
% catcode regime set by |\XINTsetcatcodes|.  No explicit |\endinput| is
% added at the file end, as it will get added by docstrip extraction.
%
%\begin{lverb}
% This file is loaded from calxtrig.tex in a context having done
% \XINTsetcatcodes, in particular the exclamation mark has catcode 12.
%
% The definition of \ver@calxtrigdata.tex control sequence done also under
% existence of LaTeX \ProvidesFile is due to a miniltx feature (under
% investigation).
%\end{lverb}
%    \begin{macrocode}
\ifdefined\ProvidesFile
  \ProvidesFile{calxtrigdata.tex}[2026/11/01 v2.0a1 calx trig data (JFB)]%
\fi
\expandafter\def\csname ver@calxtrigdata.tex\endcsname
  {2026/11/01 v2.0a1 calx trig data (JFB)}%
\@namedef{CALX_cds0}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms0}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cds1}{6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!%
6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!%
6666!6666!6666!6666!6666!6666!6666!6666!6666!1666!}%
\@namedef{CALX_cms1}{1666!6666!6666!6666!6666!6666!6666!6666!6666!6666!%
6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!%
6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!}%
\@namedef{CALX_cds2}{3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!%
3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!%
3333!3333!3333!3333!3333!3333!3333!3333!3333!0083!}%
\@namedef{CALX_cms2}{0083!3333!3333!3333!3333!3333!3333!3333!3333!3333!%
3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!%
3333!3333!3333!3333!3333!3333!3333!3333!3333!3333!}%
\@namedef{CALX_cds3}{9841!4126!2698!9841!4126!2698!9841!4126!2698!9841!%
4126!2698!9841!4126!2698!9841!4126!2698!9841!4126!2698!9841!4126!2698!9841!%
4126!2698!9841!4126!2698!9841!4126!2698!9841!0001!}%
\@namedef{CALX_cms3}{0001!9841!2698!4126!9841!2698!4126!9841!2698!4126!%
9841!2698!4126!9841!2698!4126!9841!2698!4126!9841!2698!4126!9841!2698!4126!%
9841!2698!4126!9841!2698!4126!9841!2698!4126!9841!}%
\@namedef{CALX_cds4}{3192!2557!9065!9858!9223!5731!6525!5890!2398!3192!%
2557!9065!9858!9223!5731!6525!5890!2398!3192!2557!9065!9858!9223!5731!6525!%
5890!2398!3192!2557!9065!9858!9223!5731!0275!0000!}%
\@namedef{CALX_cms4}{0000!0275!5731!9223!9858!9065!2557!3192!2398!5890!%
6525!5731!9223!9858!9065!2557!3192!2398!5890!6525!5731!9223!9858!9065!2557!%
3192!2398!5890!6525!5731!9223!9858!9065!2557!3192!}%
\@namedef{CALX_cds5}{5210!7750!1718!8544!1083!5052!1877!4417!8385!5210!%
7750!1718!8544!1083!5052!1877!4417!8385!5210!7750!1718!8544!1083!5052!1877!%
4417!8385!5210!7750!1718!8544!1083!5052!0002!0000!}%
\@namedef{CALX_cms5}{0000!0002!5052!1083!8544!1718!7750!5210!8385!4417!%
1877!5052!1083!8544!1718!7750!5210!8385!4417!1877!5052!1083!8544!1718!7750!%
5210!8385!4417!1877!5052!1083!8544!1718!7750!5210!}%
\@namedef{CALX_cds6}{9392!1459!8216!3836!5904!2660!8281!0348!7105!2725!%
4793!1549!7170!9237!5993!1614!3682!0438!6059!8126!4882!0503!2571!9327!4947!%
7015!3771!9392!1459!8216!3836!5904!0160!0000!0000!}%
\@namedef{CALX_cms6}{0000!0000!0160!5904!3836!8216!1459!9392!3771!7015!%
4947!9327!2571!0503!4882!8126!6059!0438!3682!1614!5993!9237!7170!1549!4793!%
2725!7105!0348!8281!2660!5904!3836!8216!1459!9392!}%
\@namedef{CALX_cds7}{2854!9340!5562!9732!7170!8631!6610!5001!1700!3489!%
2832!4769!0367!0663!7838!7245!8493!0906!4124!6324!3975!1002!4155!7044!7880!%
1985!0113!4759!9816!3181!1637!7647!0000!0000!0000!}%
\@namedef{CALX_cms7}{0000!0000!0000!7647!1637!3181!9816!4759!0113!1985!%
7880!7044!4155!1002!3975!6324!4124!0906!8493!7245!7838!0663!0367!4769!2832!%
3489!1700!5001!6610!8631!7170!9732!5562!9340!2854!}%
\@namedef{CALX_cds8}{2216!0990!6638!5991!4989!0693!5061!7812!9454!5306!%
5929!7039!0258!5223!9918!4033!9222!3973!3103!2045!2735!3349!0162!0320!8301!%
9455!3198!2076!3455!7254!1145!0028!0000!0000!0000!}%
\@namedef{CALX_cms8}{0000!0000!0000!0028!1145!7254!3455!2076!3198!9455!%
8301!0320!0162!3349!2735!2045!3103!3973!9222!4033!9918!5223!0258!7039!5929!%
5306!9454!7812!5061!0693!4989!5991!6638!0990!2216!}%
\@namedef{CALX_cds9}{6497!0704!7417!7239!3201!8452!4166!8385!0904!3378!%
5017!0254!1375!1828!7368!7321!4266!4134!2611!9918!0738!4922!2807!6872!8123!%
9559!9716!2432!2466!0635!0822!0000!0000!0000!0000!}%
\@namedef{CALX_cms9}{0000!0000!0000!0000!0822!0635!2466!2432!9716!9559!%
8123!6872!2807!4922!0738!9918!2611!4134!4266!7321!7368!1828!1375!0254!5017!%
3378!0904!8385!4166!8452!3201!7239!7417!0704!6497!}%
\@namedef{CALX_cds10}{6777!8501!9993!2421!5055!3972!8700!6781!2811!6603!%
1297!1310!1146!5909!8136!3969!5105!2176!9006!4737!5287!3035!5054!4373!4757!%
2308!1261!6339!9410!9572!0001!0000!0000!0000!0000!}%
\@namedef{CALX_cms10}{0000!0000!0000!0000!0001!9572!9410!6339!1261!2308!%
4757!4373!5054!3035!5287!4737!9006!2176!5105!3969!8136!5909!1146!1310!1297!%
6603!2811!6781!8700!3972!5055!2421!9993!8501!6777!}%
\@namedef{CALX_cds11}{8214!0431!3162!8127!1274!5818!7151!8570!9313!2522!%
6445!3164!5081!7442!2960!6470!4713!2573!2646!7934!3231!2812!3152!9119!7716!%
8403!6306!0170!6817!0038!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms11}{0000!0000!0000!0000!0000!0038!6817!0170!6306!8403!%
7716!9119!3152!2812!3231!7934!2646!2573!4713!6470!2960!7442!5081!3164!6445!%
2522!9313!8570!7151!5818!1274!8127!3162!0431!8214!}%
\@namedef{CALX_cds12}{0530!6034!8788!1246!0302!9193!9511!5230!8715!7420!%
9410!8021!4041!6012!1171!1894!2891!4104!8904!0529!6872!9204!5321!1948!3396!%
8447!2843!6950!0644!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms12}{0000!0000!0000!0000!0000!0000!0644!6950!2843!8447!%
3396!1948!5321!9204!6872!0529!8904!4104!2891!1894!1171!6012!4041!8021!9410!%
7420!8715!5230!9511!9193!0302!1246!8788!6034!0530!}%
\@namedef{CALX_cds13}{0912!5735!4143!8178!2464!6010!1295!3070!1750!3999!%
9315!9284!0945!4923!3363!3179!9434!6871!7861!1339!4739!6836!2571!1484!5546!%
6379!6898!9183!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms13}{0000!0000!0000!0000!0000!0000!0000!9183!6898!6379!%
5546!1484!2571!6836!4739!1339!7861!6871!9434!3179!3363!4923!0945!9284!9315!%
3999!1750!3070!1295!6010!2464!8178!4143!5735!0912!}%
\@namedef{CALX_cds14}{6885!6398!8502!9024!4411!1571!4164!1161!3438!8810!%
4050!0713!0974!0437!9844!0865!0147!4405!6992!3831!5769!8764!3155!7169!6447!%
6288!3099!0011!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms14}{0000!0000!0000!0000!0000!0000!0000!0011!3099!6288!%
6447!7169!3155!8764!5769!3831!6992!4405!0147!0865!9844!0437!0974!0713!4050!%
8810!3438!1161!4164!1571!4411!9024!8502!6398!6885!}%
\@namedef{CALX_cds15}{7727!3576!8869!1740!8725!2732!8187!4280!8928!9686!%
7455!3914!4377!1871!9419!1043!4785!4972!2921!5692!7468!6299!7949!5351!0415!%
6125!0121!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms15}{0000!0000!0000!0000!0000!0000!0000!0000!0121!6125!%
0415!5351!7949!6299!7468!5692!2921!4972!4785!1043!9419!1871!4377!3914!7455!%
9686!8928!4280!8187!2732!8725!1740!8869!3576!7727!}%
\@namedef{CALX_cds16}{7658!0353!5122!0200!6334!3894!3871!3337!0671!3636!%
1162!1907!5146!0863!7613!8040!1481!2211!3298!8149!5868!0280!7195!6207!6335!%
1151!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms16}{0000!0000!0000!0000!0000!0000!0000!0000!0000!1151!%
6335!6207!7195!0280!5868!8149!3298!2211!1481!8040!7613!0863!5146!1907!1162!%
3636!0671!3337!3871!3894!6334!0200!5122!0353!7658!}%
\@namedef{CALX_cds17}{0703!9933!6726!7260!7013!7574!4263!5557!1479!5734!%
1992!2993!9441!2546!7149!6401!7488!9228!6380!8981!9920!1890!5863!5929!9677!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms17}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
9677!5929!5863!1890!9920!8981!6380!9228!7488!6401!7149!2546!9441!2993!1992!%
5734!1479!5557!4263!7574!7013!7260!6726!9933!0703!}%
\@namedef{CALX_cds18}{2170!4767!6431!4697!9209!1739!5476!2879!2178!2917!%
8297!5084!5427!3132!8451!9043!2287!0307!2745!1538!0713!9153!6017!2654!0007!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms18}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0007!2654!6017!9153!0713!1538!2745!0307!2287!9043!8451!3132!5427!5084!8297!%
2917!2178!2879!5476!1739!9209!4697!6431!4767!2170!}%
\@namedef{CALX_cds19}{1141!2439!8135!0306!4102!9326!1467!7991!6917!1506!%
9857!9132!7857!0224!6949!9027!3975!1599!7694!4339!5135!9756!0246!0049!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms19}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0049!0246!9756!5135!4339!7694!1599!3975!9027!6949!0224!7857!9132!9857!%
1506!6917!7991!1467!9326!4102!0306!8135!2439!1141!}%
\@namedef{CALX_cds20}{3897!3995!0407!0866!0039!8463!2872!0718!1870!1080!%
2762!4987!6736!0908!2120!4487!2191!7891!4510!4240!8271!9310!0298!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms20}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0298!9310!8271!4240!4510!7891!2191!4487!2120!0908!6736!4987!2762!%
1080!1870!0718!2872!8463!0039!0866!0407!3995!3897!}%
\@namedef{CALX_cds21}{8678!7338!5747!0238!1866!1721!2327!8483!9823!1251!%
1956!5739!5950!4939!7138!5633!9829!1886!2195!6774!2108!1655!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms21}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!1655!2108!6774!2195!1886!9829!5633!7138!4939!5950!5739!1956!%
1251!9823!8483!2327!1721!1866!0238!5747!7338!8678!}%
\@namedef{CALX_cds22}{6761!6200!8174!3969!4046!1854!8602!4261!9151!4828!%
5450!1467!1917!7972!5422!2472!9833!2803!4718!6508!8359!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms22}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!8359!6508!4718!2803!9833!2472!5422!7972!1917!1467!5450!%
4828!9151!4261!8602!1854!4046!3969!8174!6200!6761!}%
\@namedef{CALX_cds23}{9568!1186!2839!2638!1898!7762!2302!5122!7062!2971!%
8684!4195!7105!6978!9197!8682!5938!3960!2851!8666!0003!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms23}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0003!8666!2851!3960!5938!8682!9197!6978!7105!4195!8684!%
2971!7062!5122!2302!7762!1898!2638!2839!1186!9568!}%
\@namedef{CALX_cds24}{4638!3023!1489!8819!1437!8362!0893!8531!0253!4406!%
7499!4291!4773!8153!3515!7903!3165!4708!4397!0016!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms24}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0016!4397!4708!3165!7903!3515!8153!4773!4291!7499!%
4406!0253!8531!0893!8362!1437!8819!1489!3023!4638!}%
\@namedef{CALX_cds25}{2052!0350!2428!9364!0831!3113!1102!0015!8455!5095!%
2124!3425!1778!0454!7268!4571!9640!4695!0064!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms25}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0064!4695!9640!4571!7268!0454!1778!3425!2124!%
5095!8455!0015!1102!3113!0831!9364!2428!0350!2052!}%
\@namedef{CALX_cds26}{6582!9506!7968!0028!9554!0080!3930!3697!2031!3006!%
6216!6452!5000!7721!6065!1525!9245!0233!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms26}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0233!9245!1525!6065!7721!5000!6452!6216!%
3006!2031!3697!3930!0080!9554!0028!7968!9506!6582!}%
\@namedef{CALX_cds27}{0628!5956!6460!8363!9531!5925!0361!4247!8741!9953!%
8358!3301!9466!1803!3049!6246!0787!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms27}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0787!6246!3049!1803!9466!3301!8358!%
9953!8741!4247!0361!5925!9531!8363!6460!5956!0628!}%
\@namedef{CALX_cds28}{9586!9838!9835!4397!6334!3062!2127!4904!9053!8417!%
9441!3064!0789!0956!4957!2467!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms28}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!2467!4957!0956!0789!3064!9441!%
8417!9053!4904!2127!3062!6334!4397!9835!9838!9586!}%
\@namedef{CALX_cds29}{3047!2618!2770!9475!0486!9168!7545!9951!3184!1624!%
0213!5936!6189!6829!7210!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms29}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!7210!6829!6189!5936!0213!%
1624!3184!9951!7545!9168!0486!9475!2770!2618!3047!}%
\@namedef{CALX_cds30}{7044!6694!6052!3461!9967!1272!8338!1215!5039!1183!%
1683!6802!3195!9701!0001!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms30}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0001!9701!3195!6802!1683!%
1183!5039!1215!8338!1272!9967!3461!6052!6694!7044!}%
\@namedef{CALX_cds31}{7492!2428!9584!3003!7949!4828!5442!9265!3070!0064!%
6493!6061!0438!0005!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms31}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0005!0438!6061!6493!%
0064!3070!9265!5442!4828!7949!3003!9584!2428!7492!}%
\@namedef{CALX_cds32}{9684!3615!7413!5262!2761!0198!4196!1997!8039!3492!%
6494!1246!0012!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms32}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0012!1246!6494!%
3492!8039!1997!4196!0198!2761!5262!7413!3615!9684!}%
\@namedef{CALX_cds33}{3233!8863!6577!3707!9851!7611!4765!5995!0354!6188!%
4189!0027!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms33}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0027!4189!%
6188!0354!5995!4765!7611!9851!3707!6577!8863!3233!}%
\@namedef{CALX_cds34}{1737!7344!5071!4184!2864!1879!1627!6996!8516!4376!%
0058!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms34}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0058!%
4376!8516!6996!1627!1879!2864!4184!5071!7344!1737!}%
\@namedef{CALX_cds35}{3891!1653!6025!3127!4123!0839!6793!5546!5808!0117!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms35}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0117!5808!5546!6793!0839!4123!3127!6025!1653!3891!}%
\@namedef{CALX_cds36}{4850!8434!9557!6809!8674!7505!6808!7078!0223!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms36}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0223!7078!6808!7505!8674!6809!9557!8434!4850!}%
\@namedef{CALX_cds37}{2134!1095!1189!8693!7307!3979!0772!0403!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms37}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0403!0772!3979!7307!8693!1189!1095!2134!}%
\@namedef{CALX_cds38}{1762!3932!6994!8550!4052!7854!0688!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms38}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0688!7854!4052!8550!6994!3932!1762!}%
\@namedef{CALX_cds39}{6923!9393!6563!6213!7952!1117!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms39}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!1117!7952!6213!6563!9393!6923!}%
\@namedef{CALX_cds40}{7582!2351!8848!9926!1724!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cms40}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!1724!9926!8848!2351!7582!}%
\@namedef{CALX_cdc0}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc0}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cdc1}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!5000!}%
\@namedef{CALX_cmc1}{5000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cdc2}{6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!%
6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!%
6666!6666!6666!6666!6666!6666!6666!6666!6666!0416!}%
\@namedef{CALX_cmc2}{0416!6666!6666!6666!6666!6666!6666!6666!6666!6666!%
6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!%
6666!6666!6666!6666!6666!6666!6666!6666!6666!6666!}%
\@namedef{CALX_cdc3}{8888!8888!8888!8888!8888!8888!8888!8888!8888!8888!%
8888!8888!8888!8888!8888!8888!8888!8888!8888!8888!8888!8888!8888!8888!8888!%
8888!8888!8888!8888!8888!8888!8888!8888!8888!0013!}%
\@namedef{CALX_cmc3}{0013!8888!8888!8888!8888!8888!8888!8888!8888!8888!%
8888!8888!8888!8888!8888!8888!8888!8888!8888!8888!8888!8888!8888!8888!8888!%
8888!8888!8888!8888!8888!8888!8888!8888!8888!8888!}%
\@namedef{CALX_cdc4}{8730!3015!1587!8730!3015!1587!8730!3015!1587!8730!%
3015!1587!8730!3015!1587!8730!3015!1587!8730!3015!1587!8730!3015!1587!8730!%
3015!1587!8730!3015!1587!8730!3015!1587!2480!0000!}%
\@namedef{CALX_cmc4}{0000!2480!1587!3015!8730!1587!3015!8730!1587!3015!%
8730!1587!3015!8730!1587!3015!8730!1587!3015!8730!1587!3015!8730!1587!3015!%
8730!1587!3015!8730!1587!3015!8730!1587!3015!8730!}%
\@namedef{CALX_cdc5}{7319!5255!8906!3985!1922!5573!0652!8589!2239!7319!%
5255!8906!3985!1922!5573!0652!8589!2239!7319!5255!8906!3985!1922!5573!0652!%
8589!2239!7319!5255!8906!3985!1922!5573!0027!0000!}%
\@namedef{CALX_cmc5}{0000!0027!5573!1922!3985!8906!5255!7319!2239!8589!%
0652!5573!1922!3985!8906!5255!7319!2239!8589!0652!5573!1922!3985!8906!5255!%
7319!2239!8589!0652!5573!1922!3985!8906!5255!7319!}%
\@namedef{CALX_cdc6}{2100!8979!6809!9878!6756!4587!7656!4534!2365!5434!%
2312!0143!3212!0090!7921!0989!7868!5698!8767!5645!3476!6545!3423!1254!4323!%
1201!9032!2100!8979!6809!9878!6756!2087!0000!0000!}%
\@namedef{CALX_cmc6}{0000!0000!2087!6756!9878!6809!8979!2100!9032!1201!%
4323!1254!3423!6545!3476!5645!8767!5698!7868!0989!7921!0090!3212!0143!2312!%
5434!2365!4534!7656!4587!6756!9878!6809!8979!2100!}%
\@namedef{CALX_cdc7}{2813!0104!3444!5988!7564!9475!9162!5024!5507!2337!%
2485!1539!5512!9945!7570!8686!7405!3602!1861!4866!9634!5035!2326!5666!8210!%
9786!1697!1385!7247!7729!4559!4707!0011!0000!0000!}%
\@namedef{CALX_cmc7}{0000!0000!0011!4707!4559!7729!7247!1385!1697!9786!%
8210!5666!2326!5035!9634!4866!1861!3602!7405!8686!7570!9945!5512!1539!2485!%
2337!5507!5024!9162!9475!7564!5988!3444!0104!2813!}%
\@namedef{CALX_cdc8}{7678!6833!2847!1858!4823!1789!6038!2812!0731!0218!%
0802!9673!4397!8791!8614!8577!6780!7556!2757!4770!6498!6937!2759!5440!1117!%
0749!4382!5297!8738!3323!9477!0477!0000!0000!0000!}%
\@namedef{CALX_cmc8}{0000!0000!0000!0477!9477!3323!8738!5297!4382!0749!%
1117!5440!2759!6937!6498!4770!2757!7556!6780!8577!8614!8791!4397!9673!0802!%
0218!0731!2812!6038!1789!4823!1858!2847!6833!7678!}%
\@namedef{CALX_cdc9}{3456!3388!0924!7555!0832!0594!9170!9322!7191!4183!%
5329!4835!6125!4734!9995!9112!1067!8554!9616!8446!4040!3519!3342!0573!4350!%
1636!4622!6226!6858!2069!5619!0001!0000!0000!0000!}%
\@namedef{CALX_cmc9}{0000!0000!0000!0001!5619!2069!6858!6226!4622!1636!%
4350!0573!3342!3519!4040!8446!9616!8554!1067!9112!9995!4734!6125!4835!5329!%
4183!7191!9322!9170!0594!0832!7555!0924!3388!3456!}%
\@namedef{CALX_cdc10}{2324!8535!9870!0861!6160!3422!2708!2419!9045!8668!%
7250!7512!4068!4091!0868!3366!7213!5706!9130!9495!1036!3746!6140!1843!9906!%
8477!6485!3121!7623!1031!0041!0000!0000!0000!0000!}%
\@namedef{CALX_cmc10}{0000!0000!0000!0000!0041!1031!7623!3121!6485!8477!%
9906!1843!6140!3746!1036!9495!9130!5706!7213!3366!0868!4091!4068!7512!7250!%
8668!9045!2419!2708!3422!6160!0861!9870!8535!2324!}%
\@namedef{CALX_cdc11}{8944!9931!2726!6928!9320!3816!4486!7126!4218!8027!%
8240!2786!6870!1177!8097!8816!8413!9189!0863!2488!4331!4683!2502!9744!7488!%
3286!5057!3924!6791!0889!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc11}{0000!0000!0000!0000!0000!0889!6791!3924!5057!3286!%
7488!9744!2502!4683!4331!2488!0863!9189!8413!8816!8097!1177!6870!2786!8240!%
8027!4218!7126!4486!3816!9320!6928!2726!9931!8944!}%
\@namedef{CALX_cdc12}{3258!0851!9715!1171!7553!9825!7797!0773!7888!5521!%
5268!0548!1045!0310!9290!7352!2279!2607!2610!3247!1801!0117!3048!8713!4904!%
1183!1096!3757!6117!0001!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc12}{0000!0000!0000!0000!0000!0001!6117!3757!1096!1183!%
4904!8713!3048!0117!1801!3247!2610!2607!2279!7352!9290!0310!1045!0548!5268!%
5521!7888!0773!7797!9825!7553!1171!9715!0851!3258!}%
\@namedef{CALX_cdc13}{4635!4847!1876!0817!6550!2276!4981!2893!7258!7977!%
1515!0693!5540!2923!0814!5842!4726!5542!2265!6174!7956!4584!9435!0074!9746!%
2247!6263!7959!0024!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc13}{0000!0000!0000!0000!0000!0000!0024!7959!6263!2247!%
9746!0074!9435!4584!7956!6174!2265!5542!4726!5842!0814!2923!5540!0693!1515!%
7977!7258!2893!4981!2276!6550!0817!1876!4847!4635!}%
\@namedef{CALX_cdc14}{9675!5561!6576!1720!7945!5571!0760!3681!9705!5499!%
7475!0688!8248!2675!5477!5113!4265!7745!2780!1119!7312!4172!1520!7910!6983!%
2370!9889!0327!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc14}{0000!0000!0000!0000!0000!0000!0000!0327!9889!2370!%
6983!7910!1520!4172!7312!1119!2780!7745!4265!5113!5477!2675!8248!0688!7475!%
5499!9705!3681!0760!5571!7945!1720!6576!5561!9675!}%
\@namedef{CALX_cdc15}{9562!0879!4950!3967!0480!4719!3805!2705!6781!0293!%
1135!1357!5699!8014!1994!2362!8338!4146!0566!6461!1525!5292!6438!5905!2881!%
9876!3769!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc15}{0000!0000!0000!0000!0000!0000!0000!0000!3769!9876!%
2881!5905!6438!5292!1525!6461!0566!4146!8338!2362!1994!8014!5699!1357!1135!%
0293!6781!2705!3805!4719!0480!3967!4950!0879!9562!}%
\@namedef{CALX_cdc16}{2741!1674!9027!6616!9022!8522!7755!0133!2154!9990!%
8357!2934!9824!8495!1231!5345!8899!2967!8841!8927!3670!9259!7435!4854!9075!%
8003!0003!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc16}{0000!0000!0000!0000!0000!0000!0000!0000!0003!8003!%
9075!4854!7435!9259!3670!8927!8841!2967!8899!5345!1231!8495!9824!2934!8357!%
9990!2154!0133!7755!8522!9022!6616!9027!1674!2741!}%
\@namedef{CALX_cdc17}{4637!7657!5444!4123!5480!5114!9231!4509!1784!0695!%
9740!4761!0445!9143!0223!4060!2102!3006!3332!4357!7231!6184!5211!7535!8715!%
0033!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc17}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0033!%
8715!7535!5211!6184!7231!4357!3332!3006!2102!4060!0223!9143!0445!4761!9740!%
0695!1784!4509!9231!5114!5480!4123!5444!7657!4637!}%
\@namedef{CALX_cdc18}{0297!6387!7964!3812!0750!4377!2618!6543!0596!7937!%
6999!8138!0817!5904!2698!4622!4652!1367!1566!6916!6386!8663!2662!8220!0268!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc18}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0268!8220!2662!8663!6386!6916!1566!1367!4652!4622!2698!5904!0817!8138!6999!%
7937!0596!6543!2618!4377!0750!3812!7964!6387!0297!}%
\@namedef{CALX_cdc19}{4530!5125!7274!1965!9979!3729!7249!1654!9794!8760!%
4428!6186!6458!8766!1011!2080!5060!2376!0072!9251!0281!0504!9632!1911!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc19}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!1911!9632!0504!0281!9251!0072!2376!5060!2080!1011!8766!6458!6186!4428!%
8760!9794!1654!7249!3729!9979!1965!7274!5125!4530!}%
\@namedef{CALX_cdc20}{9778!3810!6703!5507!1602!6983!7786!9449!6672!4287!%
3246!4478!6196!7255!6923!3975!9849!3539!4942!3858!9128!1743!2256!0001!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc20}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0001!2256!1743!9128!3858!4942!3539!9849!3975!6923!7255!6196!4478!3246!%
4287!6672!9449!7786!6983!1602!5507!6703!3810!9778!}%
\@namedef{CALX_cdc21}{3188!5571!7152!0258!0239!4011!0068!4779!2425!3835!%
4113!6785!5874!2402!6955!2249!2671!1140!4393!1291!0673!1174!0007!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc21}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0007!1174!0673!1291!4393!1140!2671!2249!6955!2402!5874!6785!4113!%
3835!2425!4779!0068!4011!0239!0258!7152!5571!3188!}%
\@namedef{CALX_cdc22}{4288!9030!7857!8641!2087!3448!7098!1783!1814!7301!%
5271!6039!6271!8748!4025!1264!2496!6179!2322!2881!6184!0037!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc22}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0037!6184!2881!2322!6179!2496!1264!4025!8748!6271!6039!5271!%
7301!1814!1783!7098!3448!2087!8641!7857!9030!4288!}%
\@namedef{CALX_cdc23}{9712!5786!3438!3999!9218!4822!8230!0744!1938!9670!%
8161!7205!3954!7999!2291!8097!9126!6147!4015!7315!0181!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc23}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0181!7315!4015!6147!9126!8097!2291!7999!3954!7205!8161!%
9670!1938!0744!8230!4822!9218!3999!3438!5786!9712!}%
\@namedef{CALX_cdc24}{7282!8149!2975!2138!0456!9745!3797!8023!2438!5895!%
7472!0295!3898!9520!2274!7264!5123!0707!5476!0805!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc24}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0805!5476!0707!5123!7264!2274!9520!3898!0295!7472!%
5895!2438!8023!3797!9745!0456!2138!2975!8149!7282!}%
\@namedef{CALX_cdc25}{4692!7860!3829!7576!2428!8767!6217!0770!1205!9888!%
8349!4685!0695!3163!0670!3158!1663!9494!3287!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc25}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!3287!9494!1663!3158!0670!3163!0695!4685!8349!%
9888!1205!0770!6217!8767!2428!7576!3829!7860!4692!}%
\@namedef{CALX_cdc26}{8885!3852!2354!1526!6362!4290!8290!5961!7662!9328!%
9463!1988!5034!9239!1485!0857!9993!2397!0001!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc26}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0001!2397!9993!0857!1485!9239!5034!1988!9463!%
9328!7662!5961!8290!4290!6362!1526!2354!3852!8885!}%
\@namedef{CALX_cdc27}{4566!7583!5332!0000!4251!5927!9887!3586!0778!7463!%
9744!1600!0648!9217!7704!3546!3319!0004!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc27}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0004!3319!3546!7704!9217!0648!1600!9744!%
7463!0778!3586!9887!5927!4251!0000!5332!7583!4566!}%
\@namedef{CALX_cdc28}{6439!0820!0651!0685!1063!4570!1256!9540!6048!9820!%
8184!4701!4990!4496!2554!0647!0014!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc28}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0014!0647!2554!4496!4990!4701!8184!%
9820!6048!9540!1256!4570!1063!0685!0651!0820!6439!}%
\@namedef{CALX_cdc29}{9820!4479!3445!9041!8729!0914!5209!7153!7914!5834!%
2576!0225!5186!2947!5430!0042!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc29}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0042!5430!2947!5186!0225!2576!%
5834!7914!7153!5209!0914!8729!9041!3445!4479!9820!}%
\@namedef{CALX_cdc30}{9717!8376!9212!1157!8008!7652!8625!4165!7386!2193!%
2670!4932!4936!1780!0120!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc30}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0120!1780!4936!4932!2670!%
2193!7386!4165!8625!7652!8008!1157!9212!8376!9717!}%
\@namedef{CALX_cdc31}{2049!3011!3807!9249!0805!4214!2876!3729!3468!4051!%
9059!1883!7632!0317!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc31}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0317!7632!1883!9059!%
4051!3468!3729!2876!4214!0805!9249!3807!3011!2049!}%
\@namedef{CALX_cdc32}{9492!5037!1868!2078!9499!2887!2741!9832!2547!7032!%
2132!1032!0788!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc32}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0788!1032!2132!%
7032!2547!9832!2741!2887!9499!2078!1868!5037!9492!}%
\@namedef{CALX_cdc33}{6661!3842!0718!8413!0041!0003!9306!1696!3758!4598!%
0704!1837!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc33}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!1837!0704!%
4598!3758!1696!9306!0003!0041!8413!0718!3842!6661!}%
\@namedef{CALX_cdc34}{9900!6747!9949!8730!7644!9670!2275!2735!7652!2002!%
4032!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc34}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!4032!%
2002!7652!2735!2275!9670!7644!8730!9949!6747!9900!}%
\@namedef{CALX_cdc35}{6310!7390!7786!2059!2755!9598!2308!3814!2407!8348!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc35}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
8348!2407!3814!2308!9598!2755!2059!7786!7390!6310!}%
\@namedef{CALX_cdc36}{4081!5717!7722!7126!3251!7928!7038!6743!6330!0001!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc36}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0001!6330!6743!7038!7928!3251!7126!7722!5717!4081!}%
\@namedef{CALX_cdc37}{0065!2141!9183!1983!8090!8479!7929!0230!0003!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc37}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0003!0230!7929!8479!8090!1983!9183!2141!0065!}%
\@namedef{CALX_cdc38}{5685!2777!8568!8403!2069!4789!3036!0005!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc38}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0005!3036!4789!2069!8403!8568!2777!5685!}%
\@namedef{CALX_cdc39}{6945!2101!8551!0878!8257!8305!0008!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc39}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0008!8305!8257!0878!8551!2101!6945!}%
\@namedef{CALX_cdc40}{4211!0492!6707!4077!9724!0013!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!}%
\@namedef{CALX_cmc40}{0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!0000!%
0000!0000!0000!0000!0013!9724!4077!6707!0492!4211!}%
\def\CALX_tdata{%
\CALX_tdef s{33}{10}{14}{3}{10}{3.3.3.4.4.5.5.6.6.6.6.7.7.7.7.8.8.9.9.9.9.10.%
10.10.10.10.10.10.}%
\CALX_tdef s{34}{10}{15}{2}{10}{2.3.3.3.3.4.4.5.5.6.6.6.6.7.7.7.7.8.8.9.9.9.%
9.10.10.10.10.10.10.10.}%
\CALX_tlet s{35}{34}%
\CALX_tlet s{36}{34}%
\CALX_tdef s{37}{11}{16}{2}{11}{2.3.3.4.4.4.4.5.5.6.6.7.7.7.7.8.8.8.8.9.9.10.%
10.10.10.11.11.11.11.11.11.11.}%
\CALX_tlet s{38}{37}%
\CALX_tlet s{39}{37}%
\CALX_tlet s{40}{37}%
\CALX_tdef s{41}{12}{17}{2}{12}{2.3.3.4.4.5.5.5.5.6.6.7.7.8.8.8.8.9.9.9.9.10.%
10.11.11.11.11.12.12.12.12.12.12.12.}%
\CALX_tlet s{42}{41}%
\CALX_tlet s{43}{41}%
\CALX_tdef s{44}{12}{18}{2}{12}{2.2.2.3.3.4.4.5.5.5.5.6.6.7.7.8.8.8.8.9.9.9.%
9.10.10.11.11.11.11.12.12.12.12.12.12.12.}%
\CALX_tdef s{45}{13}{18}{3}{13}{3.3.3.4.4.5.5.6.6.6.6.7.7.8.8.9.9.9.9.10.10.%
10.10.11.11.12.12.12.12.13.13.13.13.13.13.13.}%
\CALX_tlet s{46}{45}%
\CALX_tdef s{47}{13}{19}{2}{13}{2.3.3.3.3.4.4.5.5.6.6.6.6.7.7.8.8.9.9.9.9.10.%
10.10.10.11.11.12.12.12.12.13.13.13.13.13.13.13.}%
\CALX_tlet s{48}{47}%
\CALX_tdef s{49}{14}{19}{3}{14}{3.4.4.4.4.5.5.6.6.7.7.7.7.8.8.9.9.10.10.10.%
10.11.11.11.11.12.12.13.13.13.13.14.14.14.14.14.14.14.}%
\CALX_tlet s{50}{49}%
\CALX_tdef s{51}{14}{20}{2}{14}{2.3.3.4.4.4.4.5.5.6.6.7.7.7.7.8.8.9.9.10.10.%
10.10.11.11.11.11.12.12.13.13.13.13.14.14.14.14.14.14.14.}%
\CALX_tlet s{52}{51}%
\CALX_tdef s{53}{15}{20}{3}{15}{3.4.4.5.5.5.5.6.6.7.7.8.8.8.8.9.9.10.10.11.%
11.11.11.12.12.12.12.13.13.14.14.14.14.15.15.15.15.15.15.15.}%
\CALX_tdef s{54}{15}{21}{2}{15}{2.3.3.4.4.5.5.5.5.6.6.7.7.8.8.8.8.9.9.10.10.%
11.11.11.11.12.12.12.12.13.13.14.14.14.14.15.15.15.15.15.15.15.}%
\CALX_tlet s{55}{54}%
\CALX_tlet s{56}{54}%
\CALX_tdef s{57}{16}{21}{3}{16}{3.4.4.5.5.6.6.6.6.7.7.8.8.9.9.9.9.10.10.11.%
11.12.12.12.12.13.13.13.13.14.14.15.15.15.15.16.16.16.16.16.16.16.}%
\CALX_tdef s{58}{16}{22}{2}{16}{2.3.3.4.4.5.5.6.6.6.6.7.7.8.8.9.9.9.9.10.10.%
11.11.12.12.12.12.13.13.13.13.14.14.15.15.15.15.16.16.16.16.16.16.16.}%
\CALX_tlet s{59}{58}%
\CALX_tlet s{60}{58}%
\CALX_tdef s{61}{17}{23}{3}{17}{3.3.3.4.4.5.5.6.6.7.7.7.7.8.8.9.9.10.10.10.%
10.11.11.12.12.13.13.13.13.14.14.14.14.15.15.16.16.16.16.17.17.17.17.17.17.%
17.}%
\CALX_tlet s{62}{61}%
\CALX_tlet s{63}{61}%
\CALX_tlet s{64}{61}%
\CALX_tdef s{65}{18}{24}{3}{18}{3.4.4.4.4.5.5.6.6.7.7.8.8.8.8.9.9.10.10.11.%
11.11.11.12.12.13.13.14.14.14.14.15.15.15.15.16.16.17.17.17.17.18.18.18.18.%
18.18.18.}%
\CALX_tlet s{66}{65}%
\CALX_tlet s{67}{65}%
\CALX_tdef s{68}{18}{25}{2}{18}{2.3.3.4.4.4.4.5.5.6.6.7.7.8.8.8.8.9.9.10.10.%
11.11.11.11.12.12.13.13.14.14.14.14.15.15.15.15.16.16.17.17.17.17.18.18.18.%
18.18.18.18.}%
\CALX_tdef s{69}{19}{25}{3}{19}{3.4.4.5.5.5.5.6.6.7.7.8.8.9.9.9.9.10.10.11.%
11.12.12.12.12.13.13.14.14.15.15.15.15.16.16.16.16.17.17.18.18.18.18.19.19.%
19.19.19.19.19.}%
\CALX_tlet s{70}{69}%
\CALX_tlet s{71}{69}%
\CALX_tdef s{72}{19}{26}{2}{19}{2.3.3.4.4.5.5.5.5.6.6.7.7.8.8.9.9.9.9.10.10.%
11.11.12.12.12.12.13.13.14.14.15.15.15.15.16.16.16.16.17.17.18.18.18.18.19.%
19.19.19.19.19.19.}%
\CALX_tdef s{73}{20}{26}{3}{20}{3.4.4.5.5.6.6.6.6.7.7.8.8.9.9.10.10.10.10.11.%
11.12.12.13.13.13.13.14.14.15.15.16.16.16.16.17.17.17.17.18.18.19.19.19.19.%
20.20.20.20.20.20.20.}%
\CALX_tlet s{74}{73}%
\CALX_tlet s{75}{73}%
\CALX_tdef s{76}{20}{27}{2}{20}{2.3.3.4.4.5.5.6.6.6.6.7.7.8.8.9.9.10.10.10.%
10.11.11.12.12.13.13.13.13.14.14.15.15.16.16.16.16.17.17.17.17.18.18.19.19.%
19.19.20.20.20.20.20.20.20.}%
\CALX_tdef s{77}{21}{27}{3}{21}{3.4.4.5.5.6.6.7.7.7.7.8.8.9.9.10.10.11.11.11.%
11.12.12.13.13.14.14.14.14.15.15.16.16.17.17.17.17.18.18.18.18.19.19.20.20.%
20.20.21.21.21.21.21.21.21.}%
\CALX_tlet s{78}{77}%
\CALX_tdef s{79}{21}{28}{2}{21}{2.3.3.4.4.5.5.6.6.7.7.7.7.8.8.9.9.10.10.11.%
11.11.11.12.12.13.13.14.14.14.14.15.15.16.16.17.17.17.17.18.18.18.18.19.19.%
20.20.20.20.21.21.21.21.21.21.21.}%
\CALX_tlet s{80}{79}%
\CALX_tdef s{81}{22}{28}{3}{22}{3.4.4.5.5.6.6.7.7.8.8.8.8.9.9.10.10.11.11.12.%
12.12.12.13.13.14.14.15.15.15.15.16.16.17.17.18.18.18.18.19.19.19.19.20.20.%
21.21.21.21.22.22.22.22.22.22.22.}%
\CALX_tlet s{82}{81}%
\CALX_tdef s{83}{22}{29}{2}{22}{2.3.3.4.4.5.5.6.6.7.7.8.8.8.8.9.9.10.10.11.%
11.12.12.12.12.13.13.14.14.15.15.15.15.16.16.17.17.18.18.18.18.19.19.19.19.%
20.20.21.21.21.21.22.22.22.22.22.22.22.}%
\CALX_tlet s{84}{83}%
\CALX_tdef s{85}{23}{29}{3}{23}{3.4.4.5.5.6.6.7.7.8.8.9.9.9.9.10.10.11.11.12.%
12.13.13.13.13.14.14.15.15.16.16.16.16.17.17.18.18.19.19.19.19.20.20.20.20.%
21.21.22.22.22.22.23.23.23.23.23.23.23.}%
\CALX_tlet s{86}{85}%
\CALX_tdef s{87}{23}{30}{3}{23}{3.3.3.4.4.5.5.6.6.7.7.8.8.9.9.9.9.10.10.11.%
11.12.12.13.13.13.13.14.14.15.15.16.16.16.16.17.17.18.18.19.19.19.19.20.20.%
20.20.21.21.22.22.22.22.23.23.23.23.23.23.23.}%
\CALX_tlet s{88}{87}%
\CALX_tdef s{89}{24}{30}{4}{24}{4.4.4.5.5.6.6.7.7.8.8.9.9.10.10.10.10.11.11.%
12.12.13.13.14.14.14.14.15.15.16.16.17.17.17.17.18.18.19.19.20.20.20.20.21.%
21.21.21.22.22.23.23.23.23.24.24.24.24.24.24.24.}%
\CALX_tlet s{90}{89}%
\CALX_tdef s{91}{24}{31}{3}{24}{3.4.4.4.4.5.5.6.6.7.7.8.8.9.9.10.10.10.10.11.%
11.12.12.13.13.14.14.14.14.15.15.16.16.17.17.17.17.18.18.19.19.20.20.20.20.%
21.21.21.21.22.22.23.23.23.23.24.24.24.24.24.24.24.}%
\CALX_tlet s{92}{91}%
\CALX_tdef s{93}{25}{31}{4}{25}{4.5.5.5.5.6.6.7.7.8.8.9.9.10.10.11.11.11.11.%
12.12.13.13.14.14.15.15.15.15.16.16.17.17.18.18.18.18.19.19.20.20.21.21.21.%
21.22.22.22.22.23.23.24.24.24.24.25.25.25.25.25.25.25.}%
\CALX_tdef s{94}{25}{32}{3}{25}{3.4.4.5.5.5.5.6.6.7.7.8.8.9.9.10.10.11.11.11.%
11.12.12.13.13.14.14.15.15.15.15.16.16.17.17.18.18.18.18.19.19.20.20.21.21.%
21.21.22.22.22.22.23.23.24.24.24.24.25.25.25.25.25.25.25.}%
\CALX_tlet s{95}{94}%
\CALX_tlet s{96}{94}%
\CALX_tdef s{97}{26}{32}{4}{26}{4.5.5.6.6.6.6.7.7.8.8.9.9.10.10.11.11.12.12.%
12.12.13.13.14.14.15.15.16.16.16.16.17.17.18.18.19.19.19.19.20.20.21.21.22.%
22.22.22.23.23.23.23.24.24.25.25.25.25.26.26.26.26.26.26.26.}%
\CALX_tdef s{98}{26}{33}{3}{26}{3.4.4.5.5.6.6.6.6.7.7.8.8.9.9.10.10.11.11.12.%
12.12.12.13.13.14.14.15.15.16.16.16.16.17.17.18.18.19.19.19.19.20.20.21.21.%
22.22.22.22.23.23.23.23.24.24.25.25.25.25.26.26.26.26.26.26.26.}%
\CALX_tlet s{99}{98}%
\CALX_tlet s{100}{98}%
\CALX_tdef c{33}{10}{15}{2}{10}{2.3.3.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.9.9.9.%
9.10.10.10.10.10.10.10.}%
\CALX_tlet c{34}{33}%
\CALX_tlet c{35}{33}%
\CALX_tdef c{36}{10}{16}{2}{10}{2.2.2.3.3.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.9.%
9.9.9.10.10.10.10.10.10.10.}%
\CALX_tdef c{37}{11}{16}{3}{11}{3.3.3.4.4.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.10.%
10.10.10.11.11.11.11.11.11.11.}%
\CALX_tlet c{38}{37}%
\CALX_tdef c{39}{11}{17}{2}{11}{2.3.3.3.3.4.4.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.%
9.10.10.10.10.11.11.11.11.11.11.11.}%
\CALX_tlet c{40}{39}%
\CALX_tdef c{41}{12}{17}{3}{12}{3.4.4.4.4.5.5.6.6.7.7.7.7.8.8.9.9.9.9.10.10.%
10.10.11.11.11.11.12.12.12.12.12.12.12.}%
\CALX_tdef c{42}{12}{18}{2}{12}{2.3.3.4.4.4.4.5.5.6.6.7.7.7.7.8.8.9.9.9.9.10.%
10.10.10.11.11.11.11.12.12.12.12.12.12.12.}%
\CALX_tlet c{43}{42}%
\CALX_tlet c{44}{42}%
\CALX_tdef c{45}{13}{18}{3}{13}{3.4.4.5.5.5.5.6.6.7.7.8.8.8.8.9.9.10.10.10.%
10.11.11.11.11.12.12.12.12.13.13.13.13.13.13.13.}%
\CALX_tdef c{46}{13}{19}{2}{13}{2.3.3.4.4.5.5.5.5.6.6.7.7.8.8.8.8.9.9.10.10.%
10.10.11.11.11.11.12.12.12.12.13.13.13.13.13.13.13.}%
\CALX_tlet c{47}{46}%
\CALX_tlet c{48}{46}%
\CALX_tdef c{49}{14}{20}{3}{14}{3.3.3.4.4.5.5.6.6.6.6.7.7.8.8.9.9.9.9.10.10.%
11.11.11.11.12.12.12.12.13.13.13.13.14.14.14.14.14.14.14.}%
\CALX_tlet c{50}{49}%
\CALX_tlet c{51}{49}%
\CALX_tdef c{52}{14}{21}{2}{14}{2.3.3.3.3.4.4.5.5.6.6.6.6.7.7.8.8.9.9.9.9.10.%
10.11.11.11.11.12.12.12.12.13.13.13.13.14.14.14.14.14.14.14.}%
\CALX_tdef c{53}{15}{21}{3}{15}{3.4.4.4.4.5.5.6.6.7.7.7.7.8.8.9.9.10.10.10.%
10.11.11.12.12.12.12.13.13.13.13.14.14.14.14.15.15.15.15.15.15.15.}%
\CALX_tlet c{54}{53}%
\CALX_tlet c{55}{53}%
\CALX_tdef c{56}{15}{22}{2}{15}{2.3.3.4.4.4.4.5.5.6.6.7.7.7.7.8.8.9.9.10.10.%
10.10.11.11.12.12.12.12.13.13.13.13.14.14.14.14.15.15.15.15.15.15.15.}%
\CALX_tdef c{57}{16}{22}{3}{16}{3.4.4.5.5.5.5.6.6.7.7.8.8.8.8.9.9.10.10.11.%
11.11.11.12.12.13.13.13.13.14.14.14.14.15.15.15.15.16.16.16.16.16.16.16.}%
\CALX_tlet c{58}{57}%
\CALX_tdef c{59}{16}{23}{2}{16}{2.3.3.4.4.5.5.5.5.6.6.7.7.8.8.8.8.9.9.10.10.%
11.11.11.11.12.12.13.13.13.13.14.14.14.14.15.15.15.15.16.16.16.16.16.16.16.}%
\CALX_tlet c{60}{59}%
\CALX_tdef c{61}{17}{23}{3}{17}{3.4.4.5.5.6.6.6.6.7.7.8.8.9.9.9.9.10.10.11.%
11.12.12.12.12.13.13.14.14.14.14.15.15.15.15.16.16.16.16.17.17.17.17.17.17.%
17.}%
\CALX_tlet c{62}{61}%
\CALX_tdef c{63}{17}{24}{2}{17}{2.3.3.4.4.5.5.6.6.6.6.7.7.8.8.9.9.9.9.10.10.%
11.11.12.12.12.12.13.13.14.14.14.14.15.15.15.15.16.16.16.16.17.17.17.17.17.%
17.17.}%
\CALX_tlet c{64}{63}%
\CALX_tdef c{65}{18}{24}{3}{18}{3.4.4.5.5.6.6.7.7.7.7.8.8.9.9.10.10.10.10.11.%
11.12.12.13.13.13.13.14.14.15.15.15.15.16.16.16.16.17.17.17.17.18.18.18.18.%
18.18.18.}%
\CALX_tdef c{66}{18}{25}{2}{18}{2.3.3.4.4.5.5.6.6.7.7.7.7.8.8.9.9.10.10.10.%
10.11.11.12.12.13.13.13.13.14.14.15.15.15.15.16.16.16.16.17.17.17.17.18.18.%
18.18.18.18.18.}%
\CALX_tlet c{67}{66}%
\CALX_tlet c{68}{66}%
\CALX_tdef c{69}{19}{25}{3}{19}{3.4.4.5.5.6.6.7.7.8.8.8.8.9.9.10.10.11.11.11.%
11.12.12.13.13.14.14.14.14.15.15.16.16.16.16.17.17.17.17.18.18.18.18.19.19.%
19.19.19.19.19.}%
\CALX_tdef c{70}{19}{26}{3}{19}{3.3.3.4.4.5.5.6.6.7.7.8.8.8.8.9.9.10.10.11.%
11.11.11.12.12.13.13.14.14.14.14.15.15.16.16.16.16.17.17.17.17.18.18.18.18.%
19.19.19.19.19.19.19.}%
\CALX_tlet c{71}{70}%
\CALX_tlet c{72}{70}%
\CALX_tdef c{73}{20}{26}{4}{20}{4.4.4.5.5.6.6.7.7.8.8.9.9.9.9.10.10.11.11.12.%
12.12.12.13.13.14.14.15.15.15.15.16.16.17.17.17.17.18.18.18.18.19.19.19.19.%
20.20.20.20.20.20.20.}%
\CALX_tdef c{74}{20}{27}{3}{20}{3.4.4.4.4.5.5.6.6.7.7.8.8.9.9.9.9.10.10.11.%
11.12.12.12.12.13.13.14.14.15.15.15.15.16.16.17.17.17.17.18.18.18.18.19.19.%
19.19.20.20.20.20.20.20.20.}%
\CALX_tlet c{75}{74}%
\CALX_tlet c{76}{74}%
\CALX_tdef c{77}{21}{28}{3}{21}{3.4.4.5.5.5.5.6.6.7.7.8.8.9.9.10.10.10.10.11.%
11.12.12.13.13.13.13.14.14.15.15.16.16.16.16.17.17.18.18.18.18.19.19.19.19.%
20.20.20.20.21.21.21.21.21.21.21.}%
\CALX_tlet c{78}{77}%
\CALX_tlet c{79}{77}%
\CALX_tlet c{80}{77}%
\CALX_tdef c{81}{22}{29}{3}{22}{3.4.4.5.5.6.6.6.6.7.7.8.8.9.9.10.10.11.11.11.%
11.12.12.13.13.14.14.14.14.15.15.16.16.17.17.17.17.18.18.19.19.19.19.20.20.%
20.20.21.21.21.21.22.22.22.22.22.22.22.}%
\CALX_tlet c{82}{81}%
\CALX_tlet c{83}{81}%
\CALX_tlet c{84}{81}%
\CALX_tdef c{85}{23}{30}{3}{23}{3.4.4.5.5.6.6.7.7.7.7.8.8.9.9.10.10.11.11.12.%
12.12.12.13.13.14.14.15.15.15.15.16.16.17.17.18.18.18.18.19.19.20.20.20.20.%
21.21.21.21.22.22.22.22.23.23.23.23.23.23.23.}%
\CALX_tlet c{86}{85}%
\CALX_tlet c{87}{85}%
\CALX_tlet c{88}{85}%
\CALX_tdef c{89}{24}{31}{3}{24}{3.4.4.5.5.6.6.7.7.8.8.8.8.9.9.10.10.11.11.12.%
12.13.13.13.13.14.14.15.15.16.16.16.16.17.17.18.18.19.19.19.19.20.20.21.21.%
21.21.22.22.22.22.23.23.23.23.24.24.24.24.24.24.24.}%
\CALX_tlet c{90}{89}%
\CALX_tlet c{91}{89}%
\CALX_tdef c{92}{24}{32}{2}{24}{2.3.3.4.4.5.5.6.6.7.7.8.8.8.8.9.9.10.10.11.%
11.12.12.13.13.13.13.14.14.15.15.16.16.16.16.17.17.18.18.19.19.19.19.20.20.%
21.21.21.21.22.22.22.22.23.23.23.23.24.24.24.24.24.24.24.}%
\CALX_tdef c{93}{25}{32}{3}{25}{3.4.4.5.5.6.6.7.7.8.8.9.9.9.9.10.10.11.11.12.%
12.13.13.14.14.14.14.15.15.16.16.17.17.17.17.18.18.19.19.20.20.20.20.21.21.%
22.22.22.22.23.23.23.23.24.24.24.24.25.25.25.25.25.25.25.}%
\CALX_tlet c{94}{93}%
\CALX_tlet c{95}{93}%
\CALX_tdef c{96}{25}{33}{2}{25}{2.3.3.4.4.5.5.6.6.7.7.8.8.9.9.9.9.10.10.11.%
11.12.12.13.13.14.14.14.14.15.15.16.16.17.17.17.17.18.18.19.19.20.20.20.20.%
21.21.22.22.22.22.23.23.23.23.24.24.24.24.25.25.25.25.25.25.25.}%
\CALX_tdef c{97}{26}{33}{3}{26}{3.4.4.5.5.6.6.7.7.8.8.9.9.10.10.10.10.11.11.%
12.12.13.13.14.14.15.15.15.15.16.16.17.17.18.18.18.18.19.19.20.20.21.21.21.%
21.22.22.23.23.23.23.24.24.24.24.25.25.25.25.26.26.26.26.26.26.26.}%
\CALX_tlet c{98}{97}%
\CALX_tlet c{99}{97}%
\CALX_tdef c{100}{26}{34}{2}{26}{2.3.3.4.4.5.5.6.6.7.7.8.8.9.9.10.10.10.10.%
11.11.12.12.13.13.14.14.15.15.15.15.16.16.17.17.18.18.18.18.19.19.20.20.21.%
21.21.21.22.22.23.23.23.23.24.24.24.24.25.25.25.25.26.26.26.26.26.26.26.}%
}%
\def\CALX_fdata{%
\CALX_fdef s{9}{4}{6}{2}{4}{2.3.3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef s{9_5}{4}{5}{3}{4}{3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef s{9_4}{4}{4}{3}{4}{3.4.4.4.4.4.4.4.}%
\CALX_fdef s{9_3}{4}{3}{4}{4}{4.4.4.4.4.4.}%
\CALX_fdef s{9_2}{4}{2}{4}{4}{4.4.4.4.}%
\CALX_fsel s{9}{6}{5.2440.4.670.3.105.2.5.}%
\CALX_fdef s{10}{4}{6}{2}{4}{2.3.3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef s{10_5}{4}{5}{3}{4}{3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef s{10_4}{4}{4}{3}{4}{3.4.4.4.4.4.4.4.}%
\CALX_fdef s{10_3}{4}{3}{4}{4}{4.4.4.4.4.4.}%
\CALX_fdef s{10_2}{4}{2}{4}{4}{4.4.4.4.}%
\CALX_fsel s{10}{6}{5.2440.4.670.3.105.2.5.}%
\CALX_fdef s{11}{4}{7}{1}{4}{1.2.2.3.3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef s{11_6}{4}{6}{2}{4}{2.3.3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef s{11_5}{4}{5}{3}{4}{3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef s{11_4}{4}{4}{3}{4}{3.4.4.4.4.4.4.4.}%
\CALX_fdef s{11_3}{4}{3}{4}{4}{4.4.4.4.4.4.}%
\CALX_fdef s{11_2}{4}{2}{4}{4}{4.4.4.4.}%
\CALX_fsel s{11}{7}{6.3298.5.1163.4.278.3.35.2.1.}%
\CALX_fdef s{12}{4}{7}{1}{4}{1.2.2.3.3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef s{12_6}{4}{6}{2}{4}{2.3.3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef s{12_5}{4}{5}{3}{4}{3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef s{12_4}{4}{4}{3}{4}{3.4.4.4.4.4.4.4.}%
\CALX_fdef s{12_3}{4}{3}{4}{4}{4.4.4.4.4.4.}%
\CALX_fdef s{12_2}{4}{2}{4}{4}{4.4.4.4.}%
\CALX_fsel s{12}{7}{6.3298.5.1163.4.278.3.35.2.1.}%
\CALX_fdef s{13}{5}{8}{2}{5}{2.2.2.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{13_7}{5}{7}{2}{5}{2.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{13_6}{5}{6}{3}{5}{3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{13_5}{5}{5}{4}{5}{4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{13_4}{5}{4}{4}{5}{4.5.5.5.5.5.5.5.}%
\CALX_fdef s{13_3}{5}{3}{5}{5}{5.5.5.5.5.5.}%
\CALX_fsel s{13}{8}{7.2979.6.1130.5.323.4.59.3.5.}%
\CALX_fdef s{14}{5}{8}{2}{5}{2.2.2.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{14_7}{5}{7}{2}{5}{2.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{14_6}{5}{6}{3}{5}{3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{14_5}{5}{5}{4}{5}{4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{14_4}{5}{4}{4}{5}{4.5.5.5.5.5.5.5.}%
\CALX_fdef s{14_3}{5}{3}{5}{5}{5.5.5.5.5.5.}%
\CALX_fsel s{14}{8}{7.2979.6.1130.5.323.4.59.3.5.}%
\CALX_fdef s{15}{5}{8}{2}{5}{2.2.2.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{15_7}{5}{7}{2}{5}{2.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{15_6}{5}{6}{3}{5}{3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{15_5}{5}{5}{4}{5}{4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{15_4}{5}{4}{4}{5}{4.5.5.5.5.5.5.5.}%
\CALX_fdef s{15_3}{5}{3}{5}{5}{5.5.5.5.5.5.}%
\CALX_fsel s{15}{8}{7.2979.6.1130.5.323.4.59.3.5.}%
\CALX_fdef s{16}{5}{9}{1}{5}{1.2.2.2.2.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{16_8}{5}{8}{2}{5}{2.2.2.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{16_7}{5}{7}{2}{5}{2.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{16_6}{5}{6}{3}{5}{3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{16_5}{5}{5}{4}{5}{4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef s{16_4}{5}{4}{4}{5}{4.5.5.5.5.5.5.5.}%
\CALX_fdef s{16_3}{5}{3}{5}{5}{5.5.5.5.5.5.}%
\CALX_fsel s{16}{9}{8.4990.7.2387.6.890.5.245.4.42.3.3.}%
\CALX_fdef s{17}{6}{9}{2}{6}{2.3.3.3.3.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{17_8}{6}{8}{3}{6}{3.3.3.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{17_7}{6}{7}{3}{6}{3.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{17_6}{6}{6}{4}{6}{4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{17_5}{6}{5}{5}{6}{5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{17_4}{6}{4}{5}{6}{5.6.6.6.6.6.6.6.}%
\CALX_fsel s{17}{9}{8.3117.7.1299.6.436.5.106.4.15.}%
\CALX_fdef s{18}{6}{9}{2}{6}{2.3.3.3.3.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{18_8}{6}{8}{3}{6}{3.3.3.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{18_7}{6}{7}{3}{6}{3.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{18_6}{6}{6}{4}{6}{4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{18_5}{6}{5}{5}{6}{5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{18_4}{6}{4}{5}{6}{5.6.6.6.6.6.6.6.}%
\CALX_fsel s{18}{9}{8.3117.7.1299.6.436.5.106.4.15.}%
\CALX_fdef s{19}{6}{10}{2}{6}{2.2.2.3.3.3.3.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{19_9}{6}{9}{2}{6}{2.3.3.3.3.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{19_8}{6}{8}{3}{6}{3.3.3.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{19_7}{6}{7}{3}{6}{3.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{19_6}{6}{6}{4}{6}{4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{19_5}{6}{5}{5}{6}{5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{19_4}{6}{4}{5}{6}{5.6.6.6.6.6.6.6.}%
\CALX_fsel s{19}{10}{9.4078.8.1953.7.776.6.243.5.53.4.6.}%
\CALX_fdef s{20}{6}{10}{2}{6}{2.2.2.3.3.3.3.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{20_9}{6}{9}{2}{6}{2.3.3.3.3.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{20_8}{6}{8}{3}{6}{3.3.3.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{20_7}{6}{7}{3}{6}{3.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{20_6}{6}{6}{4}{6}{4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{20_5}{6}{5}{5}{6}{5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef s{20_4}{6}{4}{5}{6}{5.6.6.6.6.6.6.6.}%
\CALX_fsel s{20}{10}{9.4078.8.1953.7.776.6.243.5.53.4.6.}%
\CALX_fdef s{21}{7}{10}{3}{7}{3.3.3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{21_9}{7}{9}{3}{7}{3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{21_8}{7}{8}{4}{7}{4.4.4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{21_7}{7}{7}{4}{7}{4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{21_6}{7}{6}{5}{7}{5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{21_5}{7}{5}{6}{7}{6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{21_4}{7}{4}{6}{7}{6.7.7.7.7.7.7.7.}%
\CALX_fsel s{21}{10}{9.3284.8.1483.7.563.6.167.5.34.4.4.}%
\CALX_fdef s{22}{7}{11}{2}{7}{2.3.3.3.3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{22_10}{7}{10}{3}{7}{3.3.3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{22_9}{7}{9}{3}{7}{3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{22_8}{7}{8}{4}{7}{4.4.4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{22_7}{7}{7}{4}{7}{4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{22_6}{7}{6}{5}{7}{5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{22_5}{7}{5}{6}{7}{6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{22_4}{7}{4}{6}{7}{6.7.7.7.7.7.7.7.}%
\CALX_fsel s{22}{11}{10.3626.9.1779.8.754.7.263.6.70.5.12.4.1.}%
\CALX_fdef s{23}{7}{11}{2}{7}{2.3.3.3.3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{23_10}{7}{10}{3}{7}{3.3.3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{23_9}{7}{9}{3}{7}{3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{23_8}{7}{8}{4}{7}{4.4.4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{23_7}{7}{7}{4}{7}{4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{23_6}{7}{6}{5}{7}{5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{23_5}{7}{5}{6}{7}{6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{23_4}{7}{4}{6}{7}{6.7.7.7.7.7.7.7.}%
\CALX_fsel s{23}{11}{10.3626.9.1779.8.754.7.263.6.70.5.12.4.1.}%
\CALX_fdef s{24}{7}{11}{2}{7}{2.3.3.3.3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{24_10}{7}{10}{3}{7}{3.3.3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{24_9}{7}{9}{3}{7}{3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{24_8}{7}{8}{4}{7}{4.4.4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{24_7}{7}{7}{4}{7}{4.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{24_6}{7}{6}{5}{7}{5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{24_5}{7}{5}{6}{7}{6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef s{24_4}{7}{4}{6}{7}{6.7.7.7.7.7.7.7.}%
\CALX_fsel s{24}{11}{10.3626.9.1779.8.754.7.263.6.70.5.12.4.1.}%
\CALX_fdef s{25}{8}{12}{2}{8}{2.3.3.4.4.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.%
8.}%
\CALX_fdef s{25_11}{8}{11}{3}{8}{3.4.4.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.%
}%
\CALX_fdef s{25_10}{8}{10}{4}{8}{4.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{25_9}{8}{9}{4}{8}{4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{25_8}{8}{8}{5}{8}{5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{25_7}{8}{7}{5}{8}{5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{25_6}{8}{6}{6}{8}{6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{25_5}{8}{5}{7}{8}{7.7.7.8.8.8.8.8.8.8.}%
\CALX_fsel s{25}{12}{11.3597.10.1836.9.832.8.322.7.101.6.23.5.3.}%
\CALX_fdef s{26}{8}{12}{2}{8}{2.3.3.4.4.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.%
8.}%
\CALX_fdef s{26_11}{8}{11}{3}{8}{3.4.4.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.%
}%
\CALX_fdef s{26_10}{8}{10}{4}{8}{4.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{26_9}{8}{9}{4}{8}{4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{26_8}{8}{8}{5}{8}{5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{26_7}{8}{7}{5}{8}{5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{26_6}{8}{6}{6}{8}{6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{26_5}{8}{5}{7}{8}{7.7.7.8.8.8.8.8.8.8.}%
\CALX_fsel s{26}{12}{11.3597.10.1836.9.832.8.322.7.101.6.23.5.3.}%
\CALX_fdef s{27}{8}{12}{2}{8}{2.3.3.4.4.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.%
8.}%
\CALX_fdef s{27_11}{8}{11}{3}{8}{3.4.4.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.%
}%
\CALX_fdef s{27_10}{8}{10}{4}{8}{4.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{27_9}{8}{9}{4}{8}{4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{27_8}{8}{8}{5}{8}{5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{27_7}{8}{7}{5}{8}{5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{27_6}{8}{6}{6}{8}{6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{27_5}{8}{5}{7}{8}{7.7.7.8.8.8.8.8.8.8.}%
\CALX_fsel s{27}{12}{11.3597.10.1836.9.832.8.322.7.101.6.23.5.3.}%
\CALX_fdef s{28}{8}{13}{1}{8}{1.2.2.3.3.4.4.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.%
8.8.8.}%
\CALX_fdef s{28_12}{8}{12}{2}{8}{2.3.3.4.4.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.%
8.8.}%
\CALX_fdef s{28_11}{8}{11}{3}{8}{3.4.4.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.%
}%
\CALX_fdef s{28_10}{8}{10}{4}{8}{4.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{28_9}{8}{9}{4}{8}{4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{28_8}{8}{8}{5}{8}{5.5.5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{28_7}{8}{7}{5}{8}{5.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{28_6}{8}{6}{6}{8}{6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef s{28_5}{8}{5}{7}{8}{7.7.7.8.8.8.8.8.8.8.}%
\CALX_fsel s{28}{13}{12.5121.11.2952.10.1498.9.669.8.254.7.77.6.17.5.2.}%
\CALX_fdef s{29}{9}{13}{2}{9}{2.3.3.4.4.5.5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.%
9.9.9.}%
\CALX_fdef s{29_12}{9}{12}{3}{9}{3.4.4.5.5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.%
9.9.}%
\CALX_fdef s{29_11}{9}{11}{4}{9}{4.5.5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.%
}%
\CALX_fdef s{29_10}{9}{10}{5}{9}{5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{29_9}{9}{9}{5}{9}{5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{29_8}{9}{8}{6}{9}{6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{29_7}{9}{7}{6}{9}{6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{29_6}{9}{6}{7}{9}{7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{29_5}{9}{5}{8}{9}{8.8.8.9.9.9.9.9.9.9.}%
\CALX_fsel s{29}{13}{12.3696.11.1971.10.950.9.403.8.144.7.40.6.8.5.1.}%
\CALX_fdef s{30}{9}{13}{2}{9}{2.3.3.4.4.5.5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.%
9.9.9.}%
\CALX_fdef s{30_12}{9}{12}{3}{9}{3.4.4.5.5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.%
9.9.}%
\CALX_fdef s{30_11}{9}{11}{4}{9}{4.5.5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.%
}%
\CALX_fdef s{30_10}{9}{10}{5}{9}{5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{30_9}{9}{9}{5}{9}{5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{30_8}{9}{8}{6}{9}{6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{30_7}{9}{7}{6}{9}{6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{30_6}{9}{6}{7}{9}{7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{30_5}{9}{5}{8}{9}{8.8.8.9.9.9.9.9.9.9.}%
\CALX_fsel s{30}{13}{12.3696.11.1971.10.950.9.403.8.144.7.40.6.8.5.1.}%
\CALX_fdef s{31}{9}{14}{2}{9}{2.2.2.3.3.4.4.5.5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.%
9.9.9.9.9.}%
\CALX_fdef s{31_13}{9}{13}{2}{9}{2.3.3.4.4.5.5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.%
9.9.9.9.}%
\CALX_fdef s{31_12}{9}{12}{3}{9}{3.4.4.5.5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.%
9.9.}%
\CALX_fdef s{31_11}{9}{11}{4}{9}{4.5.5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.%
}%
\CALX_fdef s{31_10}{9}{10}{5}{9}{5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{31_9}{9}{9}{5}{9}{5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{31_8}{9}{8}{6}{9}{6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{31_7}{9}{7}{6}{9}{6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{31_6}{9}{6}{7}{9}{7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fsel s{31}{14}{13.4589.12.2660.11.1394.10.654.9.268.8.91.7.24.6.4.}%
\CALX_fdef s{32}{9}{14}{2}{9}{2.2.2.3.3.4.4.5.5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.%
9.9.9.9.9.}%
\CALX_fdef s{32_13}{9}{13}{2}{9}{2.3.3.4.4.5.5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.%
9.9.9.9.}%
\CALX_fdef s{32_12}{9}{12}{3}{9}{3.4.4.5.5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.%
9.9.}%
\CALX_fdef s{32_11}{9}{11}{4}{9}{4.5.5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.%
}%
\CALX_fdef s{32_10}{9}{10}{5}{9}{5.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{32_9}{9}{9}{5}{9}{5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{32_8}{9}{8}{6}{9}{6.6.6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{32_7}{9}{7}{6}{9}{6.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef s{32_6}{9}{6}{7}{9}{7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fsel s{32}{14}{13.4589.12.2660.11.1394.10.654.9.268.8.91.7.24.6.4.}%
\CALX_fdef s{33}{10}{14}{3}{10}{3.3.3.4.4.5.5.6.6.6.6.7.7.7.7.8.8.9.9.9.9.10.%
10.10.10.10.10.10.}%
\CALX_fdef s{34}{10}{15}{2}{10}{2.3.3.3.3.4.4.5.5.6.6.6.6.7.7.7.7.8.8.9.9.9.%
9.10.10.10.10.10.10.10.}%
\CALX_fdef s{35}{10}{15}{2}{10}{2.3.3.3.3.4.4.5.5.6.6.6.6.7.7.7.7.8.8.9.9.9.%
9.10.10.10.10.10.10.10.}%
\CALX_fdef s{36}{10}{15}{2}{10}{2.3.3.3.3.4.4.5.5.6.6.6.6.7.7.7.7.8.8.9.9.9.%
9.10.10.10.10.10.10.10.}%
\CALX_fdef s{37}{11}{16}{2}{11}{2.3.3.4.4.4.4.5.5.6.6.7.7.7.7.8.8.8.8.9.9.10.%
10.10.10.11.11.11.11.11.11.11.}%
\CALX_fdef s{38}{11}{16}{2}{11}{2.3.3.4.4.4.4.5.5.6.6.7.7.7.7.8.8.8.8.9.9.10.%
10.10.10.11.11.11.11.11.11.11.}%
\CALX_fdef s{39}{11}{16}{2}{11}{2.3.3.4.4.4.4.5.5.6.6.7.7.7.7.8.8.8.8.9.9.10.%
10.10.10.11.11.11.11.11.11.11.}%
\CALX_fdef s{40}{11}{16}{2}{11}{2.3.3.4.4.4.4.5.5.6.6.7.7.7.7.8.8.8.8.9.9.10.%
10.10.10.11.11.11.11.11.11.11.}%
\CALX_fdef c{9}{4}{7}{2}{4}{2.2.2.3.3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef c{9_6}{4}{6}{2}{4}{2.3.3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef c{9_5}{4}{5}{3}{4}{3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef c{9_4}{4}{4}{3}{4}{3.4.4.4.4.4.4.4.}%
\CALX_fdef c{9_3}{4}{3}{4}{4}{4.4.4.4.4.4.}%
\CALX_fdef c{9_2}{4}{2}{4}{4}{4.4.4.4.}%
\CALX_fsel c{9}{7}{6.2817.5.963.4.227.3.28.2.1.}%
\CALX_fdef c{10}{4}{7}{2}{4}{2.2.2.3.3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef c{10_6}{4}{6}{2}{4}{2.3.3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef c{10_5}{4}{5}{3}{4}{3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef c{10_4}{4}{4}{3}{4}{3.4.4.4.4.4.4.4.}%
\CALX_fdef c{10_3}{4}{3}{4}{4}{4.4.4.4.4.4.}%
\CALX_fdef c{10_2}{4}{2}{4}{4}{4.4.4.4.}%
\CALX_fsel c{10}{7}{6.2817.5.963.4.227.3.28.2.1.}%
\CALX_fdef c{11}{4}{7}{2}{4}{2.2.2.3.3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef c{11_6}{4}{6}{2}{4}{2.3.3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef c{11_5}{4}{5}{3}{4}{3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef c{11_4}{4}{4}{3}{4}{3.4.4.4.4.4.4.4.}%
\CALX_fdef c{11_3}{4}{3}{4}{4}{4.4.4.4.4.4.}%
\CALX_fdef c{11_2}{4}{2}{4}{4}{4.4.4.4.}%
\CALX_fsel c{11}{7}{6.2817.5.963.4.227.3.28.2.1.}%
\CALX_fdef c{12}{4}{8}{1}{4}{1.2.2.2.2.3.3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef c{12_7}{4}{7}{2}{4}{2.2.2.3.3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef c{12_6}{4}{6}{2}{4}{2.3.3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef c{12_5}{4}{5}{3}{4}{3.3.3.4.4.4.4.4.4.4.}%
\CALX_fdef c{12_4}{4}{4}{3}{4}{3.4.4.4.4.4.4.4.}%
\CALX_fdef c{12_3}{4}{3}{4}{4}{4.4.4.4.4.4.}%
\CALX_fsel c{12}{8}{7.4912.6.2217.5.740.4.166.3.19.}%
\CALX_fdef c{13}{5}{8}{2}{5}{2.3.3.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{13_7}{5}{7}{3}{5}{3.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{13_6}{5}{6}{3}{5}{3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{13_5}{5}{5}{4}{5}{4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{13_4}{5}{4}{4}{5}{4.5.5.5.5.5.5.5.}%
\CALX_fdef c{13_3}{5}{3}{5}{5}{5.5.5.5.5.5.}%
\CALX_fsel c{13}{8}{7.2963.6.1138.5.333.4.63.3.5.}%
\CALX_fdef c{14}{5}{8}{2}{5}{2.3.3.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{14_7}{5}{7}{3}{5}{3.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{14_6}{5}{6}{3}{5}{3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{14_5}{5}{5}{4}{5}{4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{14_4}{5}{4}{4}{5}{4.5.5.5.5.5.5.5.}%
\CALX_fdef c{14_3}{5}{3}{5}{5}{5.5.5.5.5.5.}%
\CALX_fsel c{14}{8}{7.2963.6.1138.5.333.4.63.3.5.}%
\CALX_fdef c{15}{5}{9}{2}{5}{2.2.2.3.3.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{15_8}{5}{8}{2}{5}{2.3.3.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{15_7}{5}{7}{3}{5}{3.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{15_6}{5}{6}{3}{5}{3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{15_5}{5}{5}{4}{5}{4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{15_4}{5}{4}{4}{5}{4.5.5.5.5.5.5.5.}%
\CALX_fdef c{15_3}{5}{3}{5}{5}{5.5.5.5.5.5.}%
\CALX_fsel c{15}{9}{8.3836.7.1720.6.618.5.164.4.27.3.2.}%
\CALX_fdef c{16}{5}{9}{2}{5}{2.2.2.3.3.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{16_8}{5}{8}{2}{5}{2.3.3.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{16_7}{5}{7}{3}{5}{3.3.3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{16_6}{5}{6}{3}{5}{3.4.4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{16_5}{5}{5}{4}{5}{4.4.4.5.5.5.5.5.5.5.}%
\CALX_fdef c{16_4}{5}{4}{4}{5}{4.5.5.5.5.5.5.5.}%
\CALX_fdef c{16_3}{5}{3}{5}{5}{5.5.5.5.5.5.}%
\CALX_fsel c{16}{9}{8.3836.7.1720.6.618.5.164.4.27.3.2.}%
\CALX_fdef c{17}{6}{10}{2}{6}{2.3.3.3.3.4.4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{17_9}{6}{9}{3}{6}{3.3.3.4.4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{17_8}{6}{8}{3}{6}{3.4.4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{17_7}{6}{7}{4}{6}{4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{17_6}{6}{6}{4}{6}{4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{17_5}{6}{5}{5}{6}{5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{17_4}{6}{4}{5}{6}{5.6.6.6.6.6.6.6.}%
\CALX_fsel c{17}{10}{9.3425.8.1584.7.617.6.189.5.41.4.5.}%
\CALX_fdef c{18}{6}{10}{2}{6}{2.3.3.3.3.4.4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{18_9}{6}{9}{3}{6}{3.3.3.4.4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{18_8}{6}{8}{3}{6}{3.4.4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{18_7}{6}{7}{4}{6}{4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{18_6}{6}{6}{4}{6}{4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{18_5}{6}{5}{5}{6}{5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{18_4}{6}{4}{5}{6}{5.6.6.6.6.6.6.6.}%
\CALX_fsel c{18}{10}{9.3425.8.1584.7.617.6.189.5.41.4.5.}%
\CALX_fdef c{19}{6}{10}{2}{6}{2.3.3.3.3.4.4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{19_9}{6}{9}{3}{6}{3.3.3.4.4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{19_8}{6}{8}{3}{6}{3.4.4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{19_7}{6}{7}{4}{6}{4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{19_6}{6}{6}{4}{6}{4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{19_5}{6}{5}{5}{6}{5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{19_4}{6}{4}{5}{6}{5.6.6.6.6.6.6.6.}%
\CALX_fsel c{19}{10}{9.3425.8.1584.7.617.6.189.5.41.4.5.}%
\CALX_fdef c{20}{6}{11}{1}{6}{1.2.2.3.3.3.3.4.4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{20_10}{6}{10}{2}{6}{2.3.3.3.3.4.4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{20_9}{6}{9}{3}{6}{3.3.3.4.4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{20_8}{6}{8}{3}{6}{3.4.4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{20_7}{6}{7}{4}{6}{4.4.4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{20_6}{6}{6}{4}{6}{4.5.5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{20_5}{6}{5}{5}{6}{5.5.5.6.6.6.6.6.6.6.}%
\CALX_fdef c{20_4}{6}{4}{5}{6}{5.6.6.6.6.6.6.6.}%
\CALX_fsel c{20}{11}{10.5473.9.3041.8.1405.7.542.6.163.5.34.4.4.}%
\CALX_fdef c{21}{7}{11}{2}{7}{2.3.3.4.4.4.4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{21_10}{7}{10}{3}{7}{3.4.4.4.4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{21_9}{7}{9}{4}{7}{4.4.4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{21_8}{7}{8}{4}{7}{4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{21_7}{7}{7}{5}{7}{5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{21_6}{7}{6}{5}{7}{5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{21_5}{7}{5}{6}{7}{6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{21_4}{7}{4}{6}{7}{6.7.7.7.7.7.7.7.}%
\CALX_fsel c{21}{11}{10.3472.9.1692.8.718.7.252.6.68.5.12.4.1.}%
\CALX_fdef c{22}{7}{11}{2}{7}{2.3.3.4.4.4.4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{22_10}{7}{10}{3}{7}{3.4.4.4.4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{22_9}{7}{9}{4}{7}{4.4.4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{22_8}{7}{8}{4}{7}{4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{22_7}{7}{7}{5}{7}{5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{22_6}{7}{6}{5}{7}{5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{22_5}{7}{5}{6}{7}{6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{22_4}{7}{4}{6}{7}{6.7.7.7.7.7.7.7.}%
\CALX_fsel c{22}{11}{10.3472.9.1692.8.718.7.252.6.68.5.12.4.1.}%
\CALX_fdef c{23}{7}{12}{2}{7}{2.2.2.3.3.4.4.4.4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.%
7.}%
\CALX_fdef c{23_11}{7}{11}{2}{7}{2.3.3.4.4.4.4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.%
}%
\CALX_fdef c{23_10}{7}{10}{3}{7}{3.4.4.4.4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{23_9}{7}{9}{4}{7}{4.4.4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{23_8}{7}{8}{4}{7}{4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{23_7}{7}{7}{5}{7}{5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{23_6}{7}{6}{5}{7}{5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{23_5}{7}{5}{6}{7}{6.6.6.7.7.7.7.7.7.7.}%
\CALX_fsel c{23}{12}{11.4708.10.2583.9.1237.8.510.7.172.6.44.5.7.}%
\CALX_fdef c{24}{7}{12}{2}{7}{2.2.2.3.3.4.4.4.4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.%
7.}%
\CALX_fdef c{24_11}{7}{11}{2}{7}{2.3.3.4.4.4.4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.%
}%
\CALX_fdef c{24_10}{7}{10}{3}{7}{3.4.4.4.4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{24_9}{7}{9}{4}{7}{4.4.4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{24_8}{7}{8}{4}{7}{4.5.5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{24_7}{7}{7}{5}{7}{5.5.5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{24_6}{7}{6}{5}{7}{5.6.6.6.6.7.7.7.7.7.7.7.}%
\CALX_fdef c{24_5}{7}{5}{6}{7}{6.6.6.7.7.7.7.7.7.7.}%
\CALX_fsel c{24}{12}{11.4708.10.2583.9.1237.8.510.7.172.6.44.5.7.}%
\CALX_fdef c{25}{8}{12}{3}{8}{3.3.3.4.4.5.5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.%
8.}%
\CALX_fdef c{25_11}{8}{11}{3}{8}{3.4.4.5.5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.%
}%
\CALX_fdef c{25_10}{8}{10}{4}{8}{4.5.5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{25_9}{8}{9}{5}{8}{5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{25_8}{8}{8}{5}{8}{5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{25_7}{8}{7}{6}{8}{6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{25_6}{8}{6}{6}{8}{6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{25_5}{8}{5}{7}{8}{7.7.7.8.8.8.8.8.8.8.}%
\CALX_fsel c{25}{12}{11.3595.10.1845.9.843.8.331.7.105.6.25.5.3.}%
\CALX_fdef c{26}{8}{13}{2}{8}{2.3.3.3.3.4.4.5.5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.%
8.8.8.}%
\CALX_fdef c{26_12}{8}{12}{3}{8}{3.3.3.4.4.5.5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.%
8.8.}%
\CALX_fdef c{26_11}{8}{11}{3}{8}{3.4.4.5.5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.%
}%
\CALX_fdef c{26_10}{8}{10}{4}{8}{4.5.5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{26_9}{8}{9}{5}{8}{5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{26_8}{8}{8}{5}{8}{5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{26_7}{8}{7}{6}{8}{6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{26_6}{8}{6}{6}{8}{6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{26_5}{8}{5}{7}{8}{7.7.7.8.8.8.8.8.8.8.}%
\CALX_fsel c{26}{13}{12.4168.11.2309.10.1148.9.502.8.186.7.55.6.12.5.1.}%
\CALX_fdef c{27}{8}{13}{2}{8}{2.3.3.3.3.4.4.5.5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.%
8.8.8.}%
\CALX_fdef c{27_12}{8}{12}{3}{8}{3.3.3.4.4.5.5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.%
8.8.}%
\CALX_fdef c{27_11}{8}{11}{3}{8}{3.4.4.5.5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.%
}%
\CALX_fdef c{27_10}{8}{10}{4}{8}{4.5.5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{27_9}{8}{9}{5}{8}{5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{27_8}{8}{8}{5}{8}{5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{27_7}{8}{7}{6}{8}{6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{27_6}{8}{6}{6}{8}{6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{27_5}{8}{5}{7}{8}{7.7.7.8.8.8.8.8.8.8.}%
\CALX_fsel c{27}{13}{12.4168.11.2309.10.1148.9.502.8.186.7.55.6.12.5.1.}%
\CALX_fdef c{28}{8}{13}{2}{8}{2.3.3.3.3.4.4.5.5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.%
8.8.8.}%
\CALX_fdef c{28_12}{8}{12}{3}{8}{3.3.3.4.4.5.5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.%
8.8.}%
\CALX_fdef c{28_11}{8}{11}{3}{8}{3.4.4.5.5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.%
}%
\CALX_fdef c{28_10}{8}{10}{4}{8}{4.5.5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{28_9}{8}{9}{5}{8}{5.5.5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{28_8}{8}{8}{5}{8}{5.6.6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{28_7}{8}{7}{6}{8}{6.6.6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{28_6}{8}{6}{6}{8}{6.7.7.7.7.8.8.8.8.8.8.8.}%
\CALX_fdef c{28_5}{8}{5}{7}{8}{7.7.7.8.8.8.8.8.8.8.}%
\CALX_fsel c{28}{13}{12.4168.11.2309.10.1148.9.502.8.186.7.55.6.12.5.1.}%
\CALX_fdef c{29}{9}{14}{2}{9}{2.3.3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.%
9.9.9.9.9.}%
\CALX_fdef c{29_13}{9}{13}{3}{9}{3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.%
9.9.9.9.}%
\CALX_fdef c{29_12}{9}{12}{4}{9}{4.4.4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.%
9.9.}%
\CALX_fdef c{29_11}{9}{11}{4}{9}{4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.%
}%
\CALX_fdef c{29_10}{9}{10}{5}{9}{5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{29_9}{9}{9}{6}{9}{6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{29_8}{9}{8}{6}{9}{6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{29_7}{9}{7}{7}{9}{7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{29_6}{9}{6}{7}{9}{7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fsel c{29}{14}{13.3935.12.2217.11.1144.10.530.9.214.8.72.7.19.6.3.}%
\CALX_fdef c{30}{9}{14}{2}{9}{2.3.3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.%
9.9.9.9.9.}%
\CALX_fdef c{30_13}{9}{13}{3}{9}{3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.%
9.9.9.9.}%
\CALX_fdef c{30_12}{9}{12}{4}{9}{4.4.4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.%
9.9.}%
\CALX_fdef c{30_11}{9}{11}{4}{9}{4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.%
}%
\CALX_fdef c{30_10}{9}{10}{5}{9}{5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{30_9}{9}{9}{6}{9}{6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{30_8}{9}{8}{6}{9}{6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{30_7}{9}{7}{7}{9}{7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{30_6}{9}{6}{7}{9}{7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fsel c{30}{14}{13.3935.12.2217.11.1144.10.530.9.214.8.72.7.19.6.3.}%
\CALX_fdef c{31}{9}{14}{2}{9}{2.3.3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.%
9.9.9.9.9.}%
\CALX_fdef c{31_13}{9}{13}{3}{9}{3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.%
9.9.9.9.}%
\CALX_fdef c{31_12}{9}{12}{4}{9}{4.4.4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.%
9.9.}%
\CALX_fdef c{31_11}{9}{11}{4}{9}{4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.%
}%
\CALX_fdef c{31_10}{9}{10}{5}{9}{5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{31_9}{9}{9}{6}{9}{6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{31_8}{9}{8}{6}{9}{6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{31_7}{9}{7}{7}{9}{7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{31_6}{9}{6}{7}{9}{7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fsel c{31}{14}{13.3935.12.2217.11.1144.10.530.9.214.8.72.7.19.6.3.}%
\CALX_fdef c{32}{9}{15}{1}{9}{1.2.2.3.3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.%
9.9.9.9.9.9.9.}%
\CALX_fdef c{32_14}{9}{14}{2}{9}{2.3.3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.%
9.9.9.9.9.9.}%
\CALX_fdef c{32_13}{9}{13}{3}{9}{3.4.4.4.4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.%
9.9.9.9.}%
\CALX_fdef c{32_12}{9}{12}{4}{9}{4.4.4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.%
9.9.}%
\CALX_fdef c{32_11}{9}{11}{4}{9}{4.5.5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.%
}%
\CALX_fdef c{32_10}{9}{10}{5}{9}{5.6.6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{32_9}{9}{9}{6}{9}{6.6.6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{32_8}{9}{8}{6}{9}{6.7.7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{32_7}{9}{7}{7}{9}{7.7.7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fdef c{32_6}{9}{6}{7}{9}{7.8.8.8.8.9.9.9.9.9.9.9.}%
\CALX_fsel c{32}{15}{14.5737.13.3657.12.2069.11.1065.10.491.9.197.8.65.7.17.%
6.3.}%
\CALX_fdef c{33}{10}{15}{2}{10}{2.3.3.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.9.9.9.%
9.10.10.10.10.10.10.10.}%
\CALX_fdef c{34}{10}{15}{2}{10}{2.3.3.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.9.9.9.%
9.10.10.10.10.10.10.10.}%
\CALX_fdef c{35}{10}{15}{2}{10}{2.3.3.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.9.9.9.%
9.10.10.10.10.10.10.10.}%
\CALX_fdef c{36}{10}{16}{2}{10}{2.2.2.3.3.4.4.5.5.5.5.6.6.7.7.7.7.8.8.8.8.9.%
9.9.9.10.10.10.10.10.10.10.}%
\CALX_fdef c{37}{11}{16}{3}{11}{3.3.3.4.4.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.10.%
10.10.10.11.11.11.11.11.11.11.}%
\CALX_fdef c{38}{11}{16}{3}{11}{3.3.3.4.4.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.9.10.%
10.10.10.11.11.11.11.11.11.11.}%
\CALX_fdef c{39}{11}{17}{2}{11}{2.3.3.3.3.4.4.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.%
9.10.10.10.10.11.11.11.11.11.11.11.}%
\CALX_fdef c{40}{11}{17}{2}{11}{2.3.3.3.3.4.4.5.5.6.6.6.6.7.7.8.8.8.8.9.9.9.%
9.10.10.10.10.11.11.11.11.11.11.11.}%
}%
%    \end{macrocode}
% \StoreCodelineNo {calxtrigdata}
% \cleardoublepage\let\calxtrigdatanameUp\undefined
% \MakePercentComment
%</calxtrigdata>------------------------------------------------------
%<*dtx>-----------------------------------------------------------
\cleardoublepage
\section{Cumulative line and macro count}

% le 6 juin 2022 j'ajoute le décompte des macros
\def\mymacro #1{\mymacroaux #1}
\def\mymacroaux #1#2#3{\strut
    \csname #1nameimp\endcsname&\dtt{#2}&(\dtt{#3})\tabularnewline }
\indent
\begin{tabular}[t]{rrr}
module&lines&macros\tabularnewline
\xintApplyInline\mymacro\storedlinecounts
\end{tabular}
\hfil
\begin{minipage}[t]{10cm}
\def\mymacroaux #1#2#3{#2}%

    Total number of code lines:
    \dtt{\the\numexpr
    \xintListWithSep+{\xintApply\mymacro\storedlinecounts}\relax }.
    \ifdefined\totala
     (but \dtt{\the\numexpr \totala+\totalb\relax} lines among them 
      start either with \{\% or with \}\%). \fi
    Each package or library file
    starts with circa \dtt{50} lines dealing with catcodes,
    package identification and reloading management, also for Plain
    \TeX\strut.

\bigskip
\def\mymacroaux #1#2#3{#3}%

    Total number of def'ed (or let'ed) macros: \dtt{\the\numexpr
    \xintListWithSep+{\xintApply\mymacro\storedlinecounts}\relax }.
    This is an approximation as some macros are def'ed in a way escaping
    the automated detection, in particular this applies to
    \xintexprnameimp macros associated to infix operators and syntax
    elements, whose construction uses 
    |\csname|-based definitions with a template and auxiliary macros.
    Their number has
    been evaluated manually (last updated in June 2022, probably outdated)
    at being at least about \dtt{452}. This number is probably now
    wrong but is incorporated into the \calxnameimp count shown left, and the
    total above.

\bigskip

    Version {\calxbndlversion} of {\calxbndldate}.\par
\end{minipage}

\CheckSum {72542}% 2.0a1
% 40833 pour 1.4q, 40773 pour 1.4p,
% 40137 pour 1.4o, 40137 pour 1.4n, 38900 pour 1.4m, 39032 pour 1.4l,
% 38925 pour 1.4k, 38590 pour 1.4j, 38591 pour 1.4i, 38427 pour 1.4h
% 38423 pour 1.4g, 38212 pour 1.4f, 38813 pour 1.4e, 35184 pour 1.4d
% 35109 pour 1.4c, 35103 pour 1.4b, 34648 pour 1.4a, 34575 pour 1.4
% 33497 pour 1.3f, 33274 pour 1.3e, 31601 pour 1.3d, 31122 pour 1.3c
% 31069 pour 1.3b, 30482 pour 1.3a, 30621 pour 1.3, 30988 pour 1.2q,
% 30982 pour 1.2p, 30524 pour 1.2o, 30303 pour 1.2h, 30403 pour 1.2i,
% 30750 pour 1.2j, 30677 pour 1.2k, 30931 pour 1.2l, 30439 pour 1.2m,
% 30253 pour 1.2n
\makeatletter\check@checksum
\Finale
%% End of file xint.dtx
