summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/bnumexpr
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-07-27 21:26:37 +0000
committerKarl Berry <karl@freefriends.org>2017-07-27 21:26:37 +0000
commit489bf93080c55ee77ca42507502afcbfdec203aa (patch)
treec4fe2f155d614279d3d821534d46f270786d7769 /Master/texmf-dist/source/latex/bnumexpr
parentfe6cc7d43e9608cb5bb2533480000837d7cf4827 (diff)
bnumexpr (27jul17)
git-svn-id: svn://tug.org/texlive/trunk@44901 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/bnumexpr')
-rw-r--r--Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx104
-rw-r--r--Master/texmf-dist/source/latex/bnumexpr/bnumexpr.ins2
2 files changed, 65 insertions, 41 deletions
diff --git a/Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx b/Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx
index 7b7b67c6c23..180eda3beba 100644
--- a/Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx
+++ b/Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx
@@ -1,21 +1,21 @@
% -*- coding: iso-latin-1; time-stamp-format: "%02d-%02m-%:y at %02H:%02M:%02S %Z" -*-
%<*dtx>
-\def\bnedtxtimestamp {Time-stamp: <14-10-2015 at 16:24:00 CEST>}
+\def\bnedtxtimestamp {Time-stamp: <26-07-2017 at 23:19:38 CEST>}
\iffalse
%</dtx>
%<*drv>
%% ---------------------------------------------------------------
-\def\bnedocdate {2015/10/14} % package bnumexpr documentation date
-\def\bnepackdate{2015/10/14} % package bnumexpr date
-\def\bneversion {1.2a} % package bnumexpr version
+\def\bnedocdate {2017/07/09}% package bnumexpr documentation date
+\def\bnepackdate{2017/07/09}% package bnumexpr date
+\def\bneversion {1.2b} % package bnumexpr version
%</drv>
%<*readme>--------------------------------------------------------
| Source: bnumexpr.dtx
-| Version: v1.2a, 2015/10/14 (doc: 2015/10/14)
+| Version: v1.2b, 2017/07/09 (doc: 2017/07/09)
| Author: Jean-Francois Burnol
| Info: Expressions with big integers
-| License: LPPL 1.3c or later
+| License: LPPL 1.3c
README: [Usage], [Installation], [License]
==========================================
@@ -24,22 +24,29 @@ Usage
-----
The package `bnumexpr` allows _expandable_ computations with big
-integers, the four infix operators `+`, `-`, `*`, `/` (which does
-rounded division), the power operators `^` or `**`, the factorial
-`!`, the truncated division `//`, and its associated modulo `/:`.
+integers and the four infix operators `+`, `-`, `*`, `/` (which does
+rounded integer division) familiar from the `\numexpr` e-TeX parser.
+
+Besides extending the scope to arbitrarily big numbers (and having a
+more complete syntax, for example `-(1)` is legal input), it adds the
+truncated division operator `//`, and its associated modulo `/:`, the
+power operator `^` (or equivalently `**`), and the factorial post-fix
+operator `!`. The space character as well as the underscore character
+`_` both may serve to optionally separate digits in long numbers, for
+better readability of the input.
For example:
- \thebnumexpr (92874927979^5-3197927979^6)/30!\relax
+ \thebnumexpr ( 92_874_927_979^5 - 31_9792_7979^6 ) / 30!\relax
-outputs `-4006240736596543944035189`.
+expands (in two steps) to `-4006240736596543944035189`.
The `\relax` ending token is mandatory and will be removed as a
result of the evaluation.
-The expression parser is scaled-down from `\xinttheiiexpr...\relax`
-from package xintexpr[^1], it does not handle boolean operators,
-conditional branching, variables and recognizes no functions.
+The expression parser is scaled-down from the `\xinttheiiexpr...\relax`
+parser as provided by package xintexpr[^1]: it does not handle boolean
+operators, dummy or user defined variables, functions, etc...
By default the underlying arithmetic macros are the ones provided
by package xintcore[^1] (its release 1.2 is required).
@@ -48,10 +55,6 @@ bnumexpr has only one option _custom_ which says to not load
xintcore, and a command `\bnumexprsetup` to inform the package
which macros to use if not those from xintcore.
-This is a breaking release: some options and commands from `v1.1`
-are not defined anymore (as `\bnumexprsetup` provides a new
-interface), and documents which used them will need updating.
-
Notice that the possibility not to use the xintcore macros might be
removed in the future: perhaps a future release will maintain during
computations a private internal representation (especially taylored
@@ -115,7 +118,7 @@ discarded.
License
-------
-Copyright (C) 2014-2015 by Jean-Francois Burnol
+Copyright (C) 2014-2017 by Jean-Francois Burnol
| This Work may be distributed and/or modified under the
| conditions of the LaTeX Project Public License 1.3c.
@@ -140,10 +143,16 @@ and the derived files
%<*!readme>
%% ---------------------------------------------------------------
%% The bnumexpr package: Expressions with big integers
-%% Copyright (C) 2014-2015 by Jean-Francois Burnol
+%% Copyright (C) 2014-2017 by Jean-Francois Burnol
%%
%</!readme>
%<*changes>-------------------------------------------------------
+\item[1.2b (2017/07/09)]
+ \begin{itemize}
+ \item the |_| may be used to separate visually blocks of digits in long
+ numbers.
+ \end{itemize}
+
\item[1.2a (2015/10/14)]
\begin{itemize}
\item requires \xintcorename |1.2| or later (if not using option |custom|).
@@ -196,7 +205,7 @@ and the derived files
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{bnumexpr.tex}%
[\bnepackdate\space v\bneversion\space driver file for %
- bnumexpr documentation (jfB)]%
+ bnumexpr documentation (JFB)]%
\PassOptionsToClass{a4paper,fontsize=11pt}{scrdoc}
\chardef\Withdvipdfmx 1 %
\chardef\NoSourceCode 0 % replace 0 by 1 for not including source code
@@ -534,8 +543,9 @@ Package \bnumname provides |\thebnumexpr...\relax| which is analogous to
factorials, truncated division, modulo, and comma separated expressions.
Examples:
-\noindent\bneshow {1208637867168*(2187917891279+3109197072870)}%
-\bneshow {(1380891090-30018902902)*(108319083901-10982903890)}%
+\noindent\bneshow {1_208_637_867_168*(2_187_917_891_279+3_109_197_072_870)}%
+\bneshow {(13_8089_1090-300_1890_2902)*(1083_1908_3901-109_8290_3890)}%
+\bneshow{(92_874_927_979**5-31_9792_7979**6)/30!}%
\bneshow {30!/20!/21/22/23/24/25/(26*27*28*29)}%
\bneshow {13^50//12^50, 13^50/:12^50}%
\bneshow {13^50/12^50, 12^50}%
@@ -586,6 +596,9 @@ differences between |\bnumexpr| and |\numexpr|:
\item |\bnumexpr -(1+1)\relax| is legal contrarily to |\numexpr -(1+1)\relax|
which raises an error.
+
+\item the |_| is legal within the digits composing a number and is silently
+ ignored.
\end{enumerate}
An important thing to keep in mind is that if one has a calculation
@@ -602,21 +615,27 @@ boolean operators, square roots and other functions, variables, hexadecimal
inputs, etc... it may be slightly faster when handling complicated
expressions as it does not have to check so many things.
-I recall from the documentation of \xintexprname that there is a
-potential impact on the memory of \TeX{} (the string pool, the hash
-table) because each intermediate number is stored as a dummy control
-sequence name during processing. After thousands of evaluations with
-numbers having hundreds of digits parts of the \TeX{} memory will become
-saturated and end the \verb?latex|pdflatex? run (but the problem can in theory be
-avoided through the use of a ``bigger'' |pdfetex| compiled with enlarged
-memory parameters). Anyhow, computations with thousands of digits take
-time, and this is probably a more stringent constraint.
-
-If the same expression needs to be evaluated again and again tens of
-thousands of times, it may be necessary to drop use of \bnumname and
-either use directly the macros from package \xintcorename, or apply
-|\xintNewIIExpr| from package \xintexprname to first construct the
-possibly very complicated nested macro.
+The documentation of \xintexprname explains that there is an
+impact on the memory of \TeX{} (the string pool, the hash table) as each
+intermediate number is stored as a dummy control sequence name during
+processing. After thousands of evaluations with numbers having hundreds of
+digits, parts of the \TeX{} memory can become saturated and end the
+\verb?latex|pdflatex? run, but the problem can be avoided via enlarged memory
+parameters for |pdftex|, as made possible by modern TeX installations.
+Anyhow, computations with thousands of digits take time, and this is probably
+a more stringent constraint.
+
+If the same operations need to be repeated again and again tens of thousands
+of times on varying (big) numbers, the memory problem mentioned above may be
+avoided by using nested macros rather than |\bnumexpr| or |\xintexpr|
+expressions. Utility |\xintNewIIExpr| from package \xintexprname can be used
+to construct the possibly very complicated nested macro from a given
+expression with the needed operators and usual {\catcode`# 12 |#1, #2, #3,
+ ...|} placeholders.
+
+% je voulais dire qu'une telle macro pouvait être préparée séparément, mais il
+% faudrait expliquer qu'il faut récupérer son \meaning, et j'ai le problème de
+% mes \romannumeral`&&@ maintenant... note 2015/10/27. Donc je laisse tomber.
The \eTeX{} extensions are required (this is the default on all modern
installations for \verb?latex|pdflatex? and also for \verb?xelatex|lualatex?).
@@ -662,6 +681,9 @@ with truncated division |//|.
The factorial postfix |!| has highest precedence. The minus signs
inherit the precedence level of the previously encountered infix operators.
+The underscore |_| can be used to separated digits in long numbers, for
+readability of the input.
+
\section{Option custom, \csh{bnumexprsetup}}\label{sec:options}
Package \bnumname needs that some big integer engine provides the macros
@@ -758,7 +780,7 @@ The sole package option is |custom|: it tells \bnumname not to load
% \subsection{Package identification and catcode setup}
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}%
-\ProvidesPackage{bnumexpr}[2015/10/14 v1.2a Expressions with big integers (jfB)]%
+\ProvidesPackage{bnumexpr}[2017/07/09 v1.2b Expressions with big integers (JFB)]%
\edef\BNErestorecatcodes {\catcode`\noexpand\!\the\catcode`\!
\catcode`\noexpand\?\the\catcode`\?
\catcode`\noexpand\_\the\catcode`\_
@@ -961,6 +983,7 @@ The sole package option is |custom|: it tells \bnumname not to load
\def\BNE_scanint_endbycs#1#2\BNE_scanint_d{\endcsname #1}%
\def\BNE_scanint_c\string #1\BNE_scanint_d
{%
+ \if _#1\xint_dothis{\expandafter\BNE_scanint_d\xint_gobble_i}\fi
\ifcat a#1\xint_dothis{\endcsname*}\fi % tacit multiplication
\xint_orthat {\expandafter\endcsname \string}#1%
}%
@@ -977,6 +1000,7 @@ The sole package option is |custom|: it tells \bnumname not to load
\def\BNE_gobz_scanint_endbycs#1#2\BNE_scanint_d{0\endcsname #1}%
\def\BNE_gobz_scanint_c\string #1\BNE_scanint_d
{%
+ \if _#1\xint_dothis\BNE_gobz_scanint_d\fi
\ifcat a#1\xint_dothis{0\endcsname*#1}\fi % tacit multiplication
\if 0#1\xint_dothis\BNE_gobz_scanint_d\fi
\xint_orthat {0\expandafter\endcsname \string#1}%
@@ -1247,7 +1271,7 @@ The sole package option is |custom|: it tells \bnumname not to load
Right bracket \] Circumflex \^ Underscore \_
Grave accent \` Left brace \{ Vertical bar \|
Right brace \} Tilde \~}
-\CheckSum {861}
+\CheckSum {871}
\makeatletter\check@checksum\makeatother
\Finale
%% End of file xint.dtx
diff --git a/Master/texmf-dist/source/latex/bnumexpr/bnumexpr.ins b/Master/texmf-dist/source/latex/bnumexpr/bnumexpr.ins
index 21f9c79e120..28cd4ffc185 100644
--- a/Master/texmf-dist/source/latex/bnumexpr/bnumexpr.ins
+++ b/Master/texmf-dist/source/latex/bnumexpr/bnumexpr.ins
@@ -22,7 +22,7 @@
%% in the same archive or directory.)
%% ---------------------------------------------------------------
%% The bnumexpr package: Expressions with big integers
-%% Copyright (C) 2014-2015 by Jean-Francois Burnol
+%% Copyright (C) 2014-2017 by Jean-Francois Burnol
%%
%% tex bnumexpr.ins will extract bnumexpr.sty from bnumexpr.dtx
%%