summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/latex/bnumexpr/README34
-rw-r--r--Master/texmf-dist/doc/latex/bnumexpr/bnumexpr.pdfbin90610 -> 92322 bytes
-rw-r--r--Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx347
3 files changed, 206 insertions, 175 deletions
diff --git a/Master/texmf-dist/doc/latex/bnumexpr/README b/Master/texmf-dist/doc/latex/bnumexpr/README
index 113af60fe75..1f29ae7836a 100644
--- a/Master/texmf-dist/doc/latex/bnumexpr/README
+++ b/Master/texmf-dist/doc/latex/bnumexpr/README
@@ -1,5 +1,5 @@
Source: bnumexpr.dtx
-Version: v1.1b, 2014/10/28
+Version: v1.1b, 2014/10/28 (doc: 2014/11/04)
Author: Jean-Francois Burnol
Info: Expressions with big integers
License: LPPL 1.3c or later
@@ -24,28 +24,31 @@ is like
with the difference of accepting or producing arbitrarily big integers.
For example,
- \thebnumexpr 30*(21-43*(512-67*(6133-812*2897)))\relax
+ \thebnumexpr 2*1234567890\relax
-outputs -202785405180 and this computation would have created an
-arithmetic overflow in \numexpr.
+outputs 2469135780 which would have created an arithmetic overflow in
+\numexpr as it exceeds the maximal allowed TeX integer 2147483647.
\bnumexpr...\relax is a scaled down version of \xintiiexpr...\relax from
package xintexpr.[1]
-By default, bnumexpr loads xintcore [2] for its arithmetic macros doing
-addition, subtraction, multiplication, division.
+- by default, bnumexpr loads xintcore [2] for its arithmetic macros
+ doing addition, subtraction, multiplication, division (and powers).
-- With option _custom_, xintcore is not loaded and it is up to the
- user to define suitably the expandable macros\bnumexprAdd,
- \bnumexprSub, \bnumexprMul, and \bnumexprDiv.
+- option _allowpower_ enables ^ as power operator, for example:
-- Option _bigintcalc_ loads package bigintcalc [3] and uses its
+ \thebnumexpr 2^31\relax % smallest integer exceeding the TeX bound
+
+- option _bigintcalc_ loads package bigintcalc [3] and uses its
arithmetic macros rather than those from xintcore.
-- Option _l3bigint_ loads rather package l3bigint [4], which is in the
- experimental trunk of the on-going LaTeX3 project.
+- option _l3bigint_ loads package l3bigint [4], from the experimental
+ trunk of the on-going LaTeX3 project.
-Option _allowpower_ enables ^ as power operator.
+- with option _custom_, no extra package is loaded and it is up to the
+ user to define suitably expandable macros \bnumexprAdd,
+ \bnumexprSub, \bnumexprMul, and \bnumexprDiv doing the basic
+ arithmetic operations.
Installation
@@ -77,13 +80,12 @@ bnumexpr.tex
Ignore dvipdfmx warnings, but if the pdf file has problems with
fonts (possibly from an old dvipdfmx), use then rather pdflatex.
- - with pdflatex: set the suitable toggle in bnumexpr.tex to
- disable dvipdfmx settings then "pdflatex bnumexpr.tex" (thrice).
+ - with pdflatex: "pdflatex bnumexpr.tex" (thrice).
In both cases files bnumexprReadme.md and bnumexpr.changes must be
present in the same repertory.
-Without bnumexpr.tex:
+without bnumexpr.tex:
"pdflatex bnumexpr.dtx" (thrice) extracts all files and
simultaneously generates the pdf documentation.
diff --git a/Master/texmf-dist/doc/latex/bnumexpr/bnumexpr.pdf b/Master/texmf-dist/doc/latex/bnumexpr/bnumexpr.pdf
index 65240f9613d..dcdee91d82f 100644
--- a/Master/texmf-dist/doc/latex/bnumexpr/bnumexpr.pdf
+++ b/Master/texmf-dist/doc/latex/bnumexpr/bnumexpr.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx b/Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx
index 36269c7582d..76e0475319d 100644
--- a/Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx
+++ b/Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx
@@ -1,18 +1,18 @@
% -*- coding: iso-latin-1; time-stamp-format: "%02d-%02m-%:y at %02H:%02M:%02S %Z" -*-
%<*dtx>
-\def\bnedtxtimestamp {Time-stamp: <28-10-2014 at 22:49:58 CET>}
-\iffalse
+\def\bnedtxtimestamp {Time-stamp: <04-11-2014 at 12:11:09 CET>}
+\iffalse
%</dtx>
%<*drv>
%% ---------------------------------------------------------------
-\def\bnedocdate {2014/10/28} % package bnumexpr documentation date
+\def\bnedocdate {2014/11/04} % package bnumexpr documentation date
\def\bnepackdate{2014/10/28} % package bnumexpr date
\def\bneversion {1.1b} % package bnumexpr version
%</drv>
%<*readme>--------------------------------------------------------
| Source: bnumexpr.dtx
-| Version: v1.1b, 2014/10/28
+| Version: v1.1b, 2014/10/28 (doc: 2014/11/04)
| Author: Jean-Francois Burnol
| Info: Expressions with big integers
| License: LPPL 1.3c or later
@@ -36,29 +36,31 @@ is like
with the difference of accepting or producing arbitrarily big
integers. For example,
- \thebnumexpr 30*(21-43*(512-67*(6133-812*2897)))\relax
+ \thebnumexpr 2*1234567890\relax
-outputs `-202785405180` and this computation would have created an
-arithmetic overflow in `\numexpr`.
+outputs `2469135780` which would have created an arithmetic overflow in
+`\numexpr` as it exceeds the maximal allowed TeX integer `2147483647`.
`\bnumexpr...\relax` is a scaled down version of `\xintiiexpr...\relax`
from package xintexpr.[^1]
-By default, bnumexpr loads xintcore [^1] for its arithmetic macros
-doing addition, subtraction, multiplication, division.
+- by default, bnumexpr loads xintcore [^1] for its arithmetic macros doing
+ addition, subtraction, multiplication, division (and powers).
-- With option _custom_, xintcore is not loaded and it is up to
- the user to define suitably the expandable macros`\bnumexprAdd`,
- `\bnumexprSub`, `\bnumexprMul`, and `\bnumexprDiv`.
+- option _allowpower_ enables `^` as power operator, for example:
-- Option _bigintcalc_ loads package bigintcalc [^2] and uses
- its arithmetic macros rather than those from xintcore.
+ \thebnumexpr 2^31\relax % smallest integer exceeding the TeX bound
-- Option _l3bigint_ loads rather package l3bigint [^3],
- which is in the experimental trunk of the on-going
- [LaTeX3 project](http://latex-project.org).
+- option _bigintcalc_ loads package bigintcalc [^2] and uses its
+ arithmetic macros rather than those from xintcore.
-Option _allowpower_ enables `^` as power operator.
+- option _l3bigint_ loads package l3bigint [^3], from the experimental
+ trunk of the on-going [LaTeX3 project](http://latex-project.org).
+
+- with option _custom_, no extra package is loaded and it is up to the
+ user to define suitably expandable macros `\bnumexprAdd`,
+ `\bnumexprSub`, `\bnumexprMul`, and `\bnumexprDiv` doing the basic
+ arithmetic operations.
[^1]: <http://www.ctan.org/pkg/xint>
@@ -96,13 +98,12 @@ Both `"tex bnumexpr.ins"` and `"tex bnumexpr.dtx"` extract from
Ignore dvipdfmx warnings, but if the pdf file has problems with
fonts (possibly from an old dvipdfmx), use then rather pdflatex.
- - with pdflatex: set the suitable toggle in `bnumexpr.tex` to
- disable dvipdfmx settings then `"pdflatex bnumexpr.tex"` (thrice).
+ - with pdflatex: `"pdflatex bnumexpr.tex"` (thrice).
In both cases files `bnumexprReadme.md` and `bnumexpr.changes` must
be present in the same repertory.
-Without `bnumexpr.tex`:
+without `bnumexpr.tex`:
: `"pdflatex bnumexpr.dtx"` (thrice) extracts all files and
simultaneously generates the pdf documentation.
@@ -152,11 +153,11 @@ and the derived files
%<*!readme>
%% ---------------------------------------------------------------
%% The bnumexpr package: Expressions with big integers
-%% Copyright (C) 2014 by Jean-Francois Burnol
+%% Copyright (C) 2014 by Jean-Francois Burnol
%%
%</!readme>
%<*changes>-------------------------------------------------------
-\item[1.1b (2014/10/28)]
+\item[1.1b (2014/10/28)]
\begin{itemize}
\item README converted to |markdown/pandoc| syntax,
\item the package now loads only |xintcore|, which belongs to |xint| bundle
@@ -164,7 +165,7 @@ and the derived files
operations as used by |bnumexpr|.
\end{itemize}
-\item[1.1a (2014/09/22)]
+\item[1.1a (2014/09/22)]
\begin{itemize}
\item added |l3bigint| option to use experimental \LaTeX3
package of the same name,
@@ -188,11 +189,11 @@ and the derived files
the power operator |^| as an option.
%</changes>-------------------------------------------------------
%<*drv>-----------------------------------------------------------
-%% latex bnumexpr.tex (thrice) && dvipdfmx bnumexpr.dvi
+%% latex bnumexpr.tex (thrice) && dvipdfmx bnumexpr.dvi
%% to produce bnumexpr.pdf
-%%
-%% alternative: pdflatex bnumexpr.tex, but the \Withdvipdfmx toggle
-%% below must be set to 0 first.
+%%
+%% or pdflatex bnumexpr.tex (no need to change \Withdvipdfmx toggle,
+%% pdf engine will be detected automatically)
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{bnumexpr.tex}%
@@ -225,7 +226,7 @@ and the derived files
\Msg{* To finish the installation you have to move the following}
\Msg{* files into a directory searched by TeX:}
\Msg{*}
-\Msg{* bnumexpr.sty}
+\Msg{* bnumexpr.sty}
\Msg{*}
\Msg{* To produce the documentation run latex thrice on bnumexpr.tex}
\Msg{* then dvipdfmx on bnumexpr.dvi. (ignore the dvipdfmx warnings)}
@@ -248,10 +249,10 @@ and the derived files
% latex run is on bnumexpr.dtx, we will extract all files
\chardef\extractfiles 1 % 1 = extract and typeset, 2=only typeset
\chardef\Withdvipdfmx 0 % 0 = pdflatex or latex+dvips, 1 = dvipdfmx
- \chardef\NoSourceCode 0 % 0 = include source code, 1 = do note
+ \chardef\NoSourceCode 0 % 0 = include source code, 1 = do not
\NeedsTeXFormat{LaTeX2e}%
- \PassOptionsToClass{a4paper,fontsize=11pt}{scrdoc}%
- \else % latex run is on bnumexpr.tex,
+ \PassOptionsToClass{a4paper,fontsize=11pt}{scrdoc}%
+ \else % latex run is on bnumexpr.tex,
\chardef\extractfiles 2 % no extractions
\fi
\ProvidesFile{bnumexpr.dtx}[bundle source (\bnedtxtimestamp)]%
@@ -287,7 +288,7 @@ and the derived files
\file{bnumexpr.sty}{\from{bnumexpr.dtx}{package}}}
\endgroup
\fi % end of file extraction
-\ifnum\extractfiles=0
+\ifnum\extractfiles=0
% direct tex/etex/xetex on bnumexpr.dtx, files now extracted, stop
\MessageDeFin\expandafter\end
\fi
@@ -353,7 +354,7 @@ and the derived files
\colorlet {softwrapicon}{blue}
\def\cdbx@SetSoftWrapBox{%
- \setbox\cdbx@SoftWrapIcon\hb@xt@\z@
+ \setbox\cdbx@SoftWrapIcon\hb@xt@\z@
{\hb@xt@\fontdimen2\font
{\hss{\color{softwrapicon}\usefont{U}{MdSymbolC}{m}{n}\char"97}\hss}%
\hss}%
@@ -375,78 +376,95 @@ pdfsubject={Arithmetic with TeX},%
pdfkeywords={Expansion, arithmetic, TeX},%
pdfstartview=FitH,%
pdfpagemode=UseOutlines}
-\usepackage{bookmark}
+\usepackage{bookmark}
%---- \verb, and verbatim like `environments'. \MicroFont et \MacroFont
\makeatletter
-\def\MicroFont {\ttfamily \cdbx@SetSoftWrapBox}
-\def\MacroFont {\ttfamily\baselineskip12pt\relax}
+\def\MicroFont {\ttfamily \cdbx@SetSoftWrapBox }
+
+% \MacroFont est utilisé par macrocode, mais sa définition est figée dans
+% \macro@font au \begin{document}
+
+\def\MacroFont {\ttfamily \baselineskip12pt\relax }
+
+%--- November 4, 2014 making quotes straight.
+%
+% there is no hook in \macrocode after \dospecials etc. Thus I will need to
+% take the risk that some future evolution of doc.sty (or perhaps scrdoc)
+% invalidates the following.
+%
+% Actually, I should not at all rely on the doc class, I should do it all by
+% myself.
+
+\def\macrocode{\macro@code
+ \frenchspacing \@vobeyspaces
+ \makestarlowast\makequotesstraight
+ \xmacro@code }
+
+%--- lower * symbol in text
\def\lowast{\raisebox{-.25\height}{*}}
-\begingroup
- \catcode`* 13
- \gdef\makestarlowast {\let*\lowast\catcode`\*\active}%
-\endgroup
+\catcode`* \active
+\def\makestarlowast {\let*\lowast\catcode`\*\active}%
+\catcode`* 12
+
+%--- straight quotes, added (finally...) Nov 4, 2014
+
+\begingroup\makeatletter
+ \catcode`\'\active
+ \catcode`\`\active
+\@firstofone {\endgroup
+ \def\makequotesstraight {% textcomp package has been loaded by newtxtt
+ \let`\textasciigrave
+ \let'\textquotesingle
+ \catcode39\active
+ \catcode96\active }%
+}
-% modif de \do@noligs: \char`#1} --> \char`#1 }
-\def\do@noligs #1%
-{%
- \catcode `#1\active
- \begingroup \lccode `\~=`#1\relax
- \lowercase {\endgroup \def ~{\leavevmode \kern \z@ \char `#1 }}%
-}%
% Tentative, Mardi 09 septembre 2014 à 22:41:28
-\def\verb
+% (not usable in footnotes)
+\def\verb
% on pourrait mettre le #1 ici et économiser \@@jfverb
{%
\relax\leavevmode\null
\begingroup\MicroFont
- \let\do\do@noligs \verbatim@nolig@list % voir plus tard si vraiment
- % nécessaire maintenant
- \let\do\@makeother \dospecials
- \makestarlowast
- \@vobeyspaces \fboxsep0pt
- \@@jfverb
-}%
+ %\let\do\do@noligs \verbatim@nolig@list % not needed here
+ \let\do\@makeother \dospecials
+ \makestarlowast \makequotesstraight % added here Nov 4, 2014
+% I should also take care of verbatim environment, but this is not needed in
+% bnumexpr.dtx
+ \@vobeyspaces \fboxsep\z@
+ \@@jfverb
+}%
\def\@@jfverb #1{\catcode`#1 3 \@@@jfverb }
\def\@@@jfverb #1{\ifcat\noexpand#1$% $
- \endgroup\else
+ \endgroup\else
% \penalty\z@
\discretionary{\copy\cdbx@SoftWrapIcon}{}{}%
- \colorbox{jfverbcolor}{\strut #1}%
+ \colorbox{jfverbcolor}{\strut #1}% unfortunately, impacts pdf size
\expandafter\@@@jfverb\fi }
\makeatother
-\catcode`\_=11
-
-\def\csa_aux #1{\ttfamily\hyphenchar\font45 \char`\\%
- \scantokens{#1}\endgroup }
+% currently, used only in (sub)-section titles from implementation part
+% let's use there also sans font, not monotype
-\DeclareRobustCommand\csa {\begingroup\catcode`\_=11
- \everyeof{\noexpand}\endlinechar -1
- \makeatother
- \makestarlowast
- \csa_aux }
-\newcommand\csh[1]{\texorpdfstring{\csa{#1}}{\textbackslash #1}}
-\catcode`\_=8
+\DeclareRobustCommand\csa [1]{{\char92\detokenize{#1}}}
+\newcommand\csh[1]{\texorpdfstring{\csa{#1}}{\textbackslash\detokenize{#1}}}
\usepackage{xspace}
\def\bnename
{\texorpdfstring
- {\hyperref[sec:bnumexpr]%
- {{\color{joli}\bfseries\ttfamily bnumexpr}}}
+ {\hyperref[sec:bnumexpr]{{\color{joli}\ttzfamily bnumexpr}}}
{bnumexpr}%
\xspace }%
\def\bnenameimp
{\texorpdfstring
- {\hyperref[sec:bnumexprcode]%
- {{\color[named]{RoyalPurple}%
- \bfseries\ttfamily bnumexpr}}}
- {bnumexpr}%
+ {\hyperref[sec:bnumexprcode]{{\color[named]{RoyalPurple}\ttzfamily bnumexpr}}}
+ {bnumexpr}%
\xspace }%
@@ -462,16 +480,16 @@ pdfpagemode=UseOutlines}
\pdfbookmark[1]{Title page}{TOP}
{%
-\normalfont\Large\parindent0pt \parfillskip 0pt\relax
+\normalfont\Large\parindent0pt \parfillskip 0pt\relax
\leftskip 2cm plus 1fil \rightskip 2cm plus 1fil
The \bnename package\par
}
{\centering
\textsc{Jean-François Burnol}\par
- \footnotesize
+ \footnotesize
jfbu (at) free (dot) fr\par
- Package version: \bneversion\ (\bnepackdate);
+ Package version: \bneversion\ (\bnepackdate);
documentation date: \bnedocdate.\par
{From source file \texttt{bnumexpr.dtx}. \bnedtxtimestamp.}\par
}
@@ -487,8 +505,9 @@ pdfpagemode=UseOutlines}
\parindent\z@
\let\do\do@noligs\verbatim@nolig@list
\let\do\@makeother\dospecials
- \def\par{\leavevmode \null\@@par\penalty\interlinepenalty}%
- \makestarlowast
+ \makestarlowast\makequotesstraight
+ %\def\par{\leavevmode\null\@@par\penalty\interlinepenalty}%
+ \def\par{\leavevmode\null\@@par\pagebreak[1]}%
\@vobeyspaces\obeylines
\noindent\kern\parindent\input bnumexprReadme.md
\endgroup }\x
@@ -501,50 +520,64 @@ Package \bnename provides |\bnumexpr...\relax| which is analogous to
|\numexpr...\relax|, while allowing arbitrarily big
integers. Important items:
\begin{enumerate}
-\item the |\relax| token ending the expression is mandatory,
\item one must use either |\thebnumexpr| or |\bnethe\bnumexpr| to get a
printable result, as |\bnumexpr...\relax| expands to a private format;
however one may embed directly one |\bnumexpr...\relax| in another
|\bnumexpr...\relax|,
-\item one may do |\edef\tmp{\bnumexpr 1+2\relax}|, and then either use |\tmp| in
- another |\bnumexpr...\relax|, or print it via |\bnethe\tmp|. The computation
- is done at the time of the |\edef| (and two expansion steps suffice),
+
+\item contrarily to |\numexpr|, the |\bnumexpr| parser stops only after having
+ found (and swallowed) the mandatory ending |\relax| token,
+
+\item in particular spaces between digits do not stop |\bnumexpr|, in contrast
+ with |\numexpr|:
+
+ |\the\numexpr 3 5+79\relax| expands (in one step) to \expandafter|\the\numexpr 3 5+79\relax|
+
+ |\thebnumexpr 3 5+79\relax| expands (in two steps) to \expandafter\expandafter\expandafter|\thebnumexpr 3 5+79\relax|
+
+\item one may do |\edef\tmp{\bnumexpr 1+2\relax}|, and then either use |\tmp|
+ in another |\bnumexpr...\relax|, or print it via |\bnethe\tmp|. The
+ computation is done at the time of the |\edef| (and two expansion steps
+ suffice). This is again in contrast with |\numexpr...\relax| which, without
+ |\the| or |\number| as prefix would not expand in an |\edef|,
+
\item tacit multiplication applies in front of parenthesized sub-expressions, or
sub |\bnumexpr...\relax| (or |\numexpr...\relax|), or in front of a |\count|
or |\dimen| register. This may be de-activated by option |notacitmul|,
+
\item expressions may be comma separated. On input, spaces are ignored,
naturally, and on output the values are comma separated with a space after
each comma. This functionality may be turned off via option |nocsv|,
+
\item even with options |notacitmul| and |nocsv| the syntax is more flexible
- than with |\numexpr|: things such as
+ than with |\numexpr|: things such as
|\bnumexpr -(1+1)\relax| are legal.
\end{enumerate}
The parser |\bnumexpr| is a scaled-down version of parser |\xintiiexpr| from
-package \href{http://www.ctan.org/pkg/xint}{xintexpr}: support for boolean
-operators, functions such as |abs|, |max|, |lcm|, the |!| as factorial, handling
-of hexadecimal numbers, etc\dots has been removed. The goal here is to extend
-|\numexpr| only to the extent of accepting big integers. Thus by default, the
-syntax allows |+,-,*,/|, parentheses, and also |\count| or |\dimen| registers or
-variables. Option |allowpower| enables |^| as power operator. It may well be
-that the code of the parser is in some places quite sub-optimal from the fact
-that it was derived from code handling much more stuff.
+package \href{http://www.ctan.org/pkg/xint}{xintexpr}. The goal here is to
+extend |\numexpr| only to the extent of accepting big integers. Thus by
+default, the syntax allows |+,-,*,/|, parentheses, and also |\count| or
+|\dimen| registers or variables. Option |allowpower| is a bonus which enables
+|^| as power operator. It may well be that the code of the parser is in some
+places quite sub-optimal as it was derived from code handling far more stuff.
The |\xintNewExpr| construct has been left out.
-The package \bnename needs some underlying big integer engine to provide the
+Package \bnename needs some underlying big integer engine to provide the
macros doing the actual computations. By default, it loads package |xintcore| (a
subset of \href{http://www.ctan.org/pkg/xint}{xint}) and its |\xintiiAdd|,
|\xintiiSub|, |\xintiiMul|, and |\xintiiDivRound| macros (also |\xintiiPow| if
option |allowpower| is made use of).
See the discussion of options |bigintcalc|, |l3bigint| and |custom| in
-the next section %\autoref{sec:options}
+the next section %\autoref{sec:options}
for alternatives.
I recall from documentation of |xintexpr| that there is a potential impact on
the memory of \TeX{} (the hash table) because each arithmetic operation is
done inside a dummy |\csname...\endcsname| used as single token to move
-around in one-go the possibly hundreds of digits composing a number.
+around in one-go the possibly hundreds of digits composing a number. This
+becomes apparent only if the document does (tens of) thousands of evaluations.
\section{Options}\label{sec:options}
@@ -561,9 +594,9 @@ The package does by default:
% thus sufficient to do |\let\bnumexprDiv\xintiiQuo| after loading the package.
Option |bigintcalc| says to not load
-\href{http://www.ctan.org/pkg/xint}{xintcore}
+\href{http://www.ctan.org/pkg/xint}{xintcore}
but to use rather the macros from package
-\href{http://www.ctan.org/pkg/bigintcalc}{bigintcalc}
+\href{http://www.ctan.org/pkg/bigintcalc}{bigintcalc}
by \textsc{Heiko Oberdiek}. Note though that |/| is mapped to |\bigintcalcDiv|
which does \emph{truncated} (not rounded) division.
@@ -584,7 +617,7 @@ as those of |bigintcalc.sty|) are expandable in a stronger sense (only two
expansion steps suffice). Perhaps speed gains are achievable from dropping these
stronger requirements.
-Option |nocsv| makes comma separated expressions illegal.
+Option |nocsv| makes comma separated expressions illegal.
Option |notacitmul| removes the possibility of tacit multiplication in front of
parentheses, \string\count\space registers, sub-expressions.
@@ -594,13 +627,14 @@ Option |allowpower| enables the |^| as power operator (left associative).
\section{Further commands}
The package provides |\bnumexprUsesxint|, |\bnumexprUsesbigintcalc| and
-|\bnumexprUsesliiibigint| which allow to use in the same document more than one
-of the available big integer mathematical engines.
+|\bnumexprUsesliiibigint|: after issuing one of these commands,
+|\bnumexpr...\relax| will use the arithmetic macros from the corresponding
+package. But it is up to the user to have issued the necessary |\usepackage|
+or |\RequirePackage| in the preamble. It does not matter if the packages are
+loaded before or after \bnename.
-It is up to the user to have issued the necessary |\usepackage| or
-|\RequirePackage| in the preamble, and this may be done after having loaded
-|bnumexpr.sty|. Recall that |xintcore| is loaded by default, but is not loaded
-in case of one of the options |custom|, |bigintcalc|, |l3bigint|.
+Recall that |xintcore| is loaded by default, but is not loaded in case of one
+of the options |custom|, |bigintcalc|, |l3bigint|.
\section{Examples}
@@ -625,20 +659,20 @@ in case of one of the options |custom|, |bigintcalc|, |l3bigint|.
|\thebnumexpr \cnta*\cnta*\cnta/\cntb+\cntb*\cntb*\cntb/\cnta\relax| %
\thebnumexpr \cnta*\cnta*\cnta/\cntb+\cntb*\cntb*\cntb/\cnta\relax {}
-% |\the\numexpr \cnta*\cnta*(\cnta/\cntb)+\cntb*\cntb*(\cntb/\cnta)\relax|
+% |\the\numexpr \cnta*\cnta*(\cnta/\cntb)+\cntb*\cntb*(\cntb/\cnta)\relax|
% \the\numexpr \cnta*\cnta*(\cnta/\cntb)+\cntb*\cntb*(\cntb/\cnta)\relax {}
-% |\thebnumexpr \cnta*\cnta*(\cnta/\cntb)+\cntb*\cntb*(\cntb/\cnta)\relax|
+% |\thebnumexpr \cnta*\cnta*(\cnta/\cntb)+\cntb*\cntb*(\cntb/\cnta)\relax|
% \thebnumexpr \cnta*\cnta*(\cnta/\cntb)+\cntb*\cntb*(\cntb/\cnta)\relax {}
|\the\numexpr 123/188*188\relax|, |\the\numexpr 123/(188*188)\relax|, %
-|\thebnumexpr 123/188*188\relax|, |\thebnumexpr 123/(188*188)\relax|.
+|\thebnumexpr 123/188*188\relax|, |\thebnumexpr 123/(188*188)\relax|.
\the\numexpr 123/188*188\relax, \the\numexpr 123/(188*188)\relax, %
\thebnumexpr 123/188*188\relax, \thebnumexpr 123/(188*188)\relax.
\edef\tmp {\bnumexpr 121873197*123-218137917*188\relax}
|\edef\tmp {\bnumexpr 121873197*123-218137917*188\relax}\bnethe\tmp|
\bnethe\tmp {}
-|\meaning\tmp|
-\meaning\tmp {}
+|\meaning\tmp|
+\meaning\tmp {}
|\thebnumexpr \tmp*(173197129797-\tmp)*(2179171982-\tmp)\relax|
\thebnumexpr \tmp*(173197129797-\tmp)*(2179171982-\tmp)\relax
@@ -646,14 +680,16 @@ in case of one of the options |custom|, |bigintcalc|, |l3bigint|.
|\the\cnta| %
\cnta \thebnumexpr 2152966419779999/987654321\relax\space \the\cnta
-|\thebnumexpr 2179878*987654321-2152966419779999, 2179879*987654321-2152966419779999\relax| %
-\thebnumexpr 2179878*987654321-2152966419779999,2179879*987654321-2152966419779999\relax\ \ \ (there was indeed rounding of the exact quotient.)
+|\thebnumexpr 2179878*987654321-2152966419779999, 2179879*987654321-2152966419779999\relax|
+\thebnumexpr 2179878*987654321-2152966419779999,2179879*987654321-2152966419779999\relax\ (there was indeed rounding of the exact quotient.)
-An example with the power operator |^| (option |allowpower|, not compatible with
-|l3bigint|): %
+Some example with the power operator |^|:
+\ \ \ \ (requires option |allowpower|, not compatible with |l3bigint|)
|\thebnumexpr (1^10+2^10+3^10+4^10+5^10+6^10)^3\relax| %
\thebnumexpr (1^10+2^10+3^10+4^10+5^10+6^10)^3\relax
+|\thebnumexpr 2^31-1,2^31,2^31+1,2^100\relax|
+\thebnumexpr 2^31-1,2^31,2^31+1,2^100\relax
\end{flushleft}
\section{Changes}
@@ -669,7 +705,7 @@ An example with the power operator |^| (option |allowpower|, not compatible with
% précise pas ici !!!
\MakePercentIgnore
-%
+%
% \catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11
% \let</dtx>\relax
% \def<*package>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12 }
@@ -679,7 +715,7 @@ An example with the power operator |^| (option |allowpower|, not compatible with
% \section{Package \bnenameimp implementation}
% \label{sec:bnumexprcode}
%
-% \localtableofcontents \bigskip
+% \localtableofcontents \bigskip
%
% Comments are sparse. Error handling by the parser is kept to a minimum; if
% something goes wrong, the offensive token gets discarded, and some undefined
@@ -708,7 +744,7 @@ An example with the power operator |^| (option |allowpower|, not compatible with
\def\BNE_tmpa {0}%
\DeclareOption {custom}{\def\BNE_tmpa {1}%
\PackageWarningNoLine{bnumexpr}{^^J
- Option custom: package xintcore not loaded. Definitions are needed for:^^J
+ Option custom: package xintcore not loaded. Definitions are needed for:^^J
\protect\bnumexprAdd, \protect\bnumexprSub,
\protect\bnumexprMul\space and \protect\bnumexprDiv }%
}%
@@ -724,7 +760,7 @@ An example with the power operator |^| (option |allowpower|, not compatible with
}%
\DeclareOption {nocsv}{%
\PackageInfo{bnumexpr}{Comma separated expressions disabled}%
- \AtEndOfPackage{\expandafter\let\csname BNE_precedence_,\endcsname
+ \AtEndOfPackage{\expandafter\let\csname BNE_precedence_,\endcsname
\undefined }%
}%
\DeclareOption {notacitmul}{%
@@ -742,7 +778,7 @@ An example with the power operator |^| (option |allowpower|, not compatible with
% In case option |bigintcalc| is used, notice that |/| is mapped to the macro
% |\bigintcalcDiv| which does truncated division. We did not add the extra code
% for rounded division in that case.
-%
+%
% With option |l3bigint|, there is no power operation available currently.
% Furthermore the package is part of the experimental trunk of the \LaTeX3
% project hence the names of its macros could change.
@@ -823,11 +859,6 @@ An example with the power operator |^| (option |allowpower|, not compatible with
% thus the macro is designed to go fast when it is not needed... and as
% everything happens inside a |\csname...\endcsname|, we can leave some
% trailing |\fi|'s.
-%
-% Note: the |1.09n| |\xintiiexpr| currently on CTAN has a
-% bug related to leading zeros, |\xinttheiiexpr 001+1\relax| does not return
-% |2|. This bug is absent from |\xintexpr|, |\xintfloatexpr|, |\xintiexpr| and
-% only present in |\xintiiexpr|.
% \begin{macrocode}
\edef\BNE_lock #1!{\noexpand\expandafter\space\noexpand
\csname .=\noexpand\BNE_num #1\endcsname }%
@@ -850,11 +881,11 @@ An example with the power operator |^| (option |allowpower|, not compatible with
\protected\def\BNE_usethe\BNE_protect {\BNE:missing_bnethe!}%
\def\BNE_protect\BNE_unlock {\noexpand\BNE_protect\noexpand\BNE_unlock\noexpand }%
\let\BNE_done\space
-\def\thebnumexpr
+\def\thebnumexpr
{\romannumeral-`0\expandafter\BNE_unlock\romannumeral0\BNE_eval }%
\def\bnethe #1{\romannumeral-`0\expandafter\xint_gobble_iii\romannumeral-`0#1}%
% \end{macrocode}
-% \subsection{\csh{BNE\_getnext}}
+% \subsection{\csh{BNE_getnext}}
% The getnext scans forward to find a number: after expansion of what comes
% next, an opening parenthesis signals a parenthesized sub-expression, a |!|
% with catcode 11 signals there was there a sub |\bnumexpr...\relax| (now
@@ -895,13 +926,13 @@ An example with the power operator |^| (option |allowpower|, not compatible with
\BNE_getnext\number #1%
{%
\fi\fi\fi\fi\fi\fi\fi
- \expandafter\BNE_getop\csname .=\number#1\endcsname
+ \expandafter\BNE_getop\csname .=\number#1\endcsname
}%
% \end{macrocode}
% This is quite simplified here compared to |\xintexpr|, for various reasons: we
% have dropped the |\xintNewExpr| thing, and we can treat the |(| directly as we
% don't have to get back to check if we are in an |\xintexpr|,
-% |\xintfloatexpr|, etc..
+% |\xintfloatexpr|, etc..
% \begin{macrocode}
\def\BNE_gn_fork #1{%
\if#1+\xint_dothis \BNE_getnext\fi
@@ -913,10 +944,9 @@ An example with the power operator |^| (option |allowpower|, not compatible with
% \subsection{Parsing an integer}
% We gather a string of digits, plus and minus prefixes have already been
% swallowed. There might be some leading string of zeros which will have to be
-% removed. In the full |\xintexpr| the situation is more involved as it has to
-% recognize and accept decimal numbers, numbers in scientific notation, also
-% hexadecimal numbers, function names, etc... and variable names in current
-% development version |1.1| (not yet finished).
+% removed. In the full |\xintexpr 1.1| the situation is more involved as it
+% has to recognize and accept decimal numbers, numbers in scientific notation,
+% also hexadecimal numbers, function names, variable names\dots
% \begin{macrocode}
\def\BNE_scan_number #1% this #1 has necessarily here catcode 12
{%
@@ -953,17 +983,16 @@ An example with the power operator |^| (option |allowpower|, not compatible with
% \end{macrocode}
% \begin{macrocode}
% \end{macrocode}
-% \subsection{\csh{BNE\_getop}}
+% \subsection{\csh{BNE_getop}}
% This finds the next infix operator or closing parenthesis or expression end.
-% It then leaves in the token flow <precedence> <operator> <locked number>. The
-% <precedence> stops expansion and ultimately gives back
-% control to a |\BNE_until_<op>| command. The code here is derived from more
-% involved context where the actual macro associated to the operator may vary,
+% It then leaves in the token flow <precedence> <operator> <locked number>.
+% The <precedence> stops expansion and ultimately gives back control to a
+% |\BNE_until_<op>| command. The code here is derived from more involved
+% context where the actual macro associated to the operator may vary,
% depending if we are in |\xintexpr|, |\xintfloatexpr| or |\xintiiexpr|. Here
% things are simpler but I have kept the general scheme, thus the actual macro
-% to be used for the <operator> is not decided immediately (development version
-% of |xintexpr.sty| has extra things to allow multi-characters operators like
-% |&&|).
+% to be used for the <operator> is not decided immediately (|xintexpr.sty| has
+% extra things to allow multi-characters operators like |&&|).
% \begin{macrocode}
\def\BNE_getop #1#2% this #1 is the current locked computed value
{%
@@ -985,7 +1014,7 @@ An example with the power operator |^| (option |allowpower|, not compatible with
}%
\catcode`* 12
\def\BNE_foundend {\xint_c_ \relax }% \relax is only a place-holder here.
-\def\BNE_foundop #1%
+\def\BNE_foundop #1%
{%
\ifcsname BNE_precedence_#1\endcsname
\csname BNE_precedence_#1\expandafter\endcsname
@@ -997,7 +1026,7 @@ An example with the power operator |^| (option |allowpower|, not compatible with
\def\BNE_notanoperator #1{\BNE:not_an_operator! \xint_gobble_i {#1}}%
% \end{macrocode}
% \subsection{Until macros for global expression and parenthesized sub-ones}
-% The minus sign as prefix is treated here.
+% The minus sign as prefix is treated here.
% \begin{macrocode}
\catcode`) 11
\def\BNE_tmpa #1{% #1=\BNE_op_-vi token
@@ -1006,16 +1035,16 @@ An example with the power operator |^| (option |allowpower|, not compatible with
\xint_UDsignfork
##1{\expandafter\BNE_until_end_a\romannumeral-`0#1}%
-{\BNE_until_end_b ##1}%
- \krof
+ \krof
}%
}\expandafter\BNE_tmpa\csname BNE_op_-vi\endcsname
\def\BNE_until_end_b #1#2%
{%
- \ifcase #1\expandafter\BNE_done
+ \ifcase #1\expandafter\BNE_done
\or
\xint_afterfi{\BNE:extra_)_?\expandafter
\BNE_until_end_a\romannumeral-`0\BNE_getop }%
- \else
+ \else
\xint_afterfi{\expandafter\BNE_until_end_a
\romannumeral-`0\csname BNE_op_#2\endcsname }%
\fi
@@ -1034,14 +1063,14 @@ An example with the power operator |^| (option |allowpower|, not compatible with
{%
\ifcase #1\expandafter \BNE_missing_)_? % missing ) ?
\or\expandafter \BNE_getop % found closing )
- \else \xint_afterfi
+ \else \xint_afterfi
{\expandafter \BNE_until_)_a\romannumeral-`0\csname BNE_op_#2\endcsname }%
\fi
}%
\def\BNE_missing_)_? {\BNE:missing_)_inserted \xint_c_ \BNE_done }%
\let\BNE_precedence_) \xint_c_i
-\let\BNE_op_) \BNE_getop
-\catcode`) 12
+\let\BNE_op_) \BNE_getop
+\catcode`) 12
% \end{macrocode}
% \subsection{The arithmetic operators.}
% This is where the infix operators are mapped to actual macros. These macros
@@ -1054,11 +1083,11 @@ An example with the power operator |^| (option |allowpower|, not compatible with
{% keep value, get next number and operator, then do until
\expandafter #2\expandafter ##1\romannumeral-`0\expandafter\BNE_getnext }%
\def #2##1##2% \BNE_until_<op>_a
- {\xint_UDsignfork
+ {\xint_UDsignfork
##2{\expandafter #2\expandafter ##1\romannumeral-`0#4}%
-{#3##1##2}%
\krof }%
- \def #3##1##2##3##4% \BNE_until_<op>_b
+ \def #3##1##2##3##4% \BNE_until_<op>_b
{% either execute next operation now, or first do next (possibly unary)
\ifnum ##2>#5%
\xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0%
@@ -1070,12 +1099,12 @@ An example with the power operator |^| (option |allowpower|, not compatible with
}%
\def\BNE_tmpb #1#2#3%
{%
- \expandafter\BNE_tmpc
+ \expandafter\BNE_tmpc
\csname BNE_op_#1\expandafter\endcsname
- \csname BNE_until_#1_a\expandafter\endcsname
- \csname BNE_until_#1_b\expandafter\endcsname
- \csname BNE_op_-#2\expandafter\endcsname
- \csname xint_c_#2\expandafter\endcsname
+ \csname BNE_until_#1_a\expandafter\endcsname
+ \csname BNE_until_#1_b\expandafter\endcsname
+ \csname BNE_op_-#2\expandafter\endcsname
+ \csname xint_c_#2\expandafter\endcsname
\csname #3\expandafter\endcsname
\csname BNE_precedence_#1\endcsname
}%
@@ -1099,9 +1128,9 @@ An example with the power operator |^| (option |allowpower|, not compatible with
}%
\def\BNE_tmpb #1#2#3#4%
{%
- \def #1% \BNE_op_-<level>
+ \def #1% \BNE_op_-<level>
{% get next number+operator then switch to _until macro
- \expandafter #2\romannumeral-`0\BNE_getnext
+ \expandafter #2\romannumeral-`0\BNE_getnext
}%
\def #2##1% \BNE_until_-<level>_a
{\xint_UDsignfork
@@ -1139,7 +1168,7 @@ An example with the power operator |^| (option |allowpower|, not compatible with
\catcode`, 11
\def\BNE_op_, #1%
{%
- \expandafter \BNE_until_,_a\expandafter #1\romannumeral-`0\BNE_getnext
+ \expandafter \BNE_until_,_a\expandafter #1\romannumeral-`0\BNE_getnext
}%
\def\BNE_tmpa #1{% #1 = \BNE_op_-vi
\def\BNE_until_,_a ##1##2%
@@ -1181,7 +1210,7 @@ An example with the power operator |^| (option |allowpower|, not compatible with
% \end{macrocode}
% \subsection{Cleanup}
% \begin{macrocode}
-\let\BNE_tmpa\relax \let\BNE_tmpb\relax \let\BNE_tmpc\relax
+\let\BNE_tmpa\relax \let\BNE_tmpb\relax \let\BNE_tmpc\relax
\BNErestorecatcodes
% \end{macrocode}
% \MakePercentComment