summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-01-07 22:12:39 +0000
committerKarl Berry <karl@freefriends.org>2019-01-07 22:12:39 +0000
commit03838df8a8d0cc947a09ecb93b1d1c81d55ba73e (patch)
tree79d82c7f501978b07024419eda822c06a9d18299 /Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx
parent3b440d44096a31f17207f6fffb3b1ddd6d722b60 (diff)
bnumexpr (7jan19)
git-svn-id: svn://tug.org/texlive/trunk@49633 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx')
-rw-r--r--Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx140
1 files changed, 82 insertions, 58 deletions
diff --git a/Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx b/Master/texmf-dist/source/latex/bnumexpr/bnumexpr.dtx
index bf3200dc29d..d1d162b7042 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: <05-12-2017 at 15:54:19 CET>}
+\def\bnedtxtimestamp {Time-stamp: <07-01-2019 at 11:53:27 CET>}
\iffalse
%</dtx>
%<*drv>
%% ---------------------------------------------------------------
-\def\bnedocdate {2017/12/05}% package bnumexpr documentation date
-\def\bnepackdate{2017/12/05}% package bnumexpr date
-\def\bneversion {1.2c} % package bnumexpr version
+\def\bnedocdate {2019/01/07}% package bnumexpr documentation date
+\def\bnepackdate{2019/01/07}% package bnumexpr date
+\def\bneversion {1.2d} % package bnumexpr version
%</drv>
%<*readme>--------------------------------------------------------
| Source: bnumexpr.dtx
-| Version: v1.2c, 2017/12/05 (doc: 2017/12/05)
+| Version: v1.2d, 2019/01/07 (doc: 2019/01/07)
| Author: Jean-Francois Burnol
| Info: Expressions with big integers
| License: LPPL 1.3c
@@ -24,8 +24,8 @@ Usage
-----
The package `bnumexpr` allows _expandable_ computations with big
-integers and the four infix operators `+`, `-`, `*`, `/` (which does
-rounded integer division) familiar from the `\numexpr` e-TeX parser.
+integers and the four infix operators `+`, `-`, `*`, `/` 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
@@ -37,27 +37,25 @@ numbers, for better readability of the input.
For example:
- \thebnumexpr ( 92_874_927_979^5 - 31_9792_7979^6 ) / 30!\relax
+ \bnumeval{( 92_874_927_979^5 - 31_9792_7979^6 ) / 30!}
-expands (in two steps) to `-4006240736596543944035189`.
-
-The `\relax` ending token is mandatory and will be removed as a
-result of the evaluation.
+ The above expands (in two steps) to `-4006240736596543944035189`
+ (the `/` does rounded division to match the `\numexpr` behaviour).
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).
+parser as provided by package xintexpr[^1]: it does not handle
+hexadecimal input, boolean operators, dummy or user defined variables,
+functions, etc...
-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.
+By default, the package loads xintcore[^1] (release 1.3d is then
+required) but it is possible via option _custom_ and macro
+`\bnumexprsetup` to map the operators to macros of one's own choice. It
+is the responsability of the user to load the packages providing these
+custom macros.
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
+computations a private internal representation (especially tailored
either for the xintcore macros or new ones which would be included
within `bnumexpr.sty` itself) and the constraints this implies may
render optional use of other macros impossible.
@@ -118,7 +116,7 @@ discarded.
License
-------
-Copyright (C) 2014-2017 by Jean-Francois Burnol
+Copyright (C) 2014-2019 by Jean-Francois Burnol
| This Work may be distributed and/or modified under the
| conditions of the LaTeX Project Public License 1.3c.
@@ -143,10 +141,16 @@ and the derived files
%<*!readme>
%% ---------------------------------------------------------------
%% The bnumexpr package: Expressions with big integers
-%% Copyright (C) 2014-2017 by Jean-Francois Burnol
+%% Copyright (C) 2014-2019 by Jean-Francois Burnol
%%
%</!readme>
%<*changes>-------------------------------------------------------
+\item[1.2d (2019/01/07)]
+ \begin{itemize}
+ \item requires \xintcorename |1.3d| or later (if not using option |custom|).
+ \item adds |\bnumeval|\marg{expression} user interface.
+ \end{itemize}
+
\item[1.2c (2017/12/05)] \textbf{Breaking changes:}
\begin{itemize}
\item requires \xintcorename |1.2p| or later (if not using option |custom|).
@@ -336,16 +340,6 @@ and the derived files
\makeatother
\pagestyle{headings}
-\makeatletter
-\def\buggysectionmark #1{% KOMA 3.12 as released to CTAN December 2013
- \if@twoside\expandafter\markboth\else\expandafter\markright\fi
- {\MakeMarkcase{\ifnumbered{section}{\sectionmarkformat\fi}{}#1}}{}}
-\ifx\buggysectionmark\sectionmark
-\def\sectionmark #1{%
- \if@twoside\expandafter\markboth\else\expandafter\markright\fi
- {\MakeMarkcase{\ifnumbered{section}{\sectionmarkformat}{}#1}}{}}
-\fi
-\makeatother
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
@@ -363,8 +357,9 @@ and the derived files
\definecolor{joli}{RGB}{225,95,0}
\definecolor{JOLI}{RGB}{225,95,0}
\definecolor{BLUE}{RGB}{0,0,255}
-\definecolor{niceone}{RGB}{38,128,192}
-\colorlet{smallverbcolor}{RoyalPurple}% \colorlet{jfverbcolor}{yellow!5}
+%\definecolor{niceone}{RGB}{38,128,192}% utilisé avant pour urlcolor
+%\colorlet{smallverbcolor}{RoyalPurple}% \colorlet{jfverbcolor}{yellow!5}
+\colorlet{smallverbcolor}{NavyBlue}%
\colorlet{softwrapcolor}{blue}
\colorlet{digitscolor}{OrangeRed}
@@ -389,8 +384,8 @@ and the derived files
%linktoc=all,%
breaklinks=true,%
colorlinks=true,%
-urlcolor=niceone,%
-linkcolor=blue,%
+urlcolor=SkyBlue,%
+linkcolor=PineGreen,%
pdfauthor={Jean-Fran\c cois Burnol},%
pdftitle={The bnumexpr package},%
pdfsubject={Arithmetic with TeX},%
@@ -493,6 +488,8 @@ pdfpagemode=UseOutlines}
\catcode`| \active
\def\bneshow #1%
{|\thebnumexpr#1\relax|$$\color{digitscolor}\thebnumexpr#1\relax$$}
+ \def\bneshoweval #1%
+ {|\bnumeval{#1}|$$\color{digitscolor}\bnumeval{#1}$$}
\catcode`| 12
\DeclareRobustCommand\csa [1]{{\char92\detokenize{#1}}}
@@ -582,19 +579,37 @@ pdfpagemode=UseOutlines}
\section{Examples}
\label{sec:bnumexpr}
-Package \bnumname provides |\thebnumexpr...\relax| which is analogous to
-|\the\numexpr...\relax|, while allowing arbitrarily big integers, powers,
-factorials, floored division, modulo, and comma separated expressions.
+Package \bnumname provides |\thebnumexpr|\marg{expression}|\relax| which is
+analogous to |\the\numexpr|\marg{expression}|\relax|, with these extensions:
+\begin{itemize}
+\item it allows arbitrarily big integers,
+\item it computes powers (with either |**| or |^| as infix operator),
+\item it computes factorials (with |!| as postfix operator),
+\item it has an operator |//| for floored division and |/:| for the
+ associated modulo,
+\item the space character can be used to separate in the source blocks of
+digits for better readability of long numbers,
+\item since |1.2b| the underscore |_| may also be used as visual digit
+ separator,
+\item comma separated expressions are allowed.
+\end{itemize}
+It expands completely, but in two steps (whereas
+|\the\numexpr|\marg{expression}|\relax| expands in one step only, and
+|\numexpr| by itself is not expandable).
+
+|1.2d| adds a |\bnumeval|\marg{expression} interface. The |\bnumeval| macro
+also expands completely in two steps.
+
Examples:
-\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)}%
+\noindent\bneshow {1 208 637 867 * (2 187 917 891 + 3 109 197 072)}%
+\bneshoweval {(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)}%
+\bneshoweval {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}%
+\bneshoweval {13^50/12^50, 12^50}%
\bneshow {(1^10+2^10+3^10+4^10+5^10+6^10+7^10+8^10+9^10)^3}%
-\bneshow {100!/36^100}%
+\bneshoweval {100!/36^100}%
\section{Differences from \csh{numexpr}}
@@ -753,7 +768,7 @@ minus signs inherit the precedence level of the previously encountered infix
operators.
In case of equal precedence the operations are left-associative,
-hence:\newline \bneshow{2^3^4, (2^3)^4, 2^(3^4)}
+hence:\newline \bneshoweval{2^3^4, (2^3)^4, 2^(3^4)}
The underscore |_| can be used to separate digits in long numbers, for
readability of the input.
@@ -768,7 +783,7 @@ package \xintcorename.
Package \bnumname needs that some big integer engine provides the macros
doing the actual computations. By default, it loads package
\xintcorename (a subset of \href{http://www.ctan.org/pkg/xint}{xint};
-version |1.2p| is required) and uses \csa{bnumexprsetup} in the following
+version |1.3d| is required) and uses \csa{bnumexprsetup} in the following
way:
\begin{verbatim}
\usepackage{xintcore}
@@ -777,7 +792,7 @@ way:
mod=\xintiiMod, pow=\xintiiPow, fac=\xintiiFac}
\end{verbatim}
-The keys given to \csa{bnumexprsetup} must be lowercased. If
+If
using \csa{bnumexprsetup}, it is not necessary to specify all keys,
for example one can do |\bnumexprsetup{mul=\MyFasterMul}|, and only
multiplication will be changed.
@@ -858,9 +873,10 @@ macros of the same math engine. Its effect obeys the local scope.
% least |2| for more meaningful context.
%
% \subsection{Package identification and catcode setup}
+% |v1.2c| forgot to identify itself as such |:(|. Fixed (of course) at |v1.2d|.
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}%
-\ProvidesPackage{bnumexpr}[2017/07/09 v1.2b Expressions with big integers (JFB)]%
+\ProvidesPackage{bnumexpr}[2019/01/07 v1.2d Expressions with big integers (JFB)]%
\edef\BNErestorecatcodes {\catcode`\noexpand\!\the\catcode`\!
\catcode`\noexpand\?\the\catcode`\?
\catcode`\noexpand\_\the\catcode`\_
@@ -921,19 +937,20 @@ macros of the same math engine. Its effect obeys the local scope.
\def\BNE_parsedone #1\BNE_parsekeys {}%
% \end{macrocode}
% \subsection{Package options}
-% |v1.2c| replaces former key |divtrunc| by |div|.
+% |v1.2c| replaces former key |divtrunc| by |div|. |v1.2d| requires (by
+% default) |xintcore 1.3d|.
% \begin{macrocode}
\def\BNE_tmpa {0}%
\DeclareOption {custom}{\def\BNE_tmpa {1}}%
\ProcessOptions\relax
\if0\BNE_tmpa % Default is to load xintcore.sty
- \RequirePackage{xintcore}[2017/12/04]%
+ \RequirePackage{xintcore}[2019/01/06]% xintcore 1.3d
\bnumexprsetup{add=\xintiiAdd, sub=\xintiiSub, mul=\xintiiMul,
divround=\xintiiDivRound, div=\xintiiDivFloor,
mod=\xintiiMod, pow=\xintiiPow, fac=\xintiiFac}%
\fi
% \end{macrocode}
-% \subsection{\csh{bnumexpr}, \csh{bnethe}, \csh{thebnumexpr}, \dots}
+% \subsection{\csh{bnumexpr}, \csh{thebnumexpr}, \csh{bnethe}, \csh{bnumeval}}
% In the full |\xintexpr|, the final unlocking may involve post-treatment of
% the comma separated values, hence there are |_print| macros to handle the
% possibly comma separated values. Here we may just identify |_print| with
@@ -941,17 +958,24 @@ macros of the same math engine. Its effect obeys the local scope.
%
% With |v1.2a| the gathering of numbers happens directly inside
% |\csname...\endcsname|. There is no more a ``locking'' macro.
+%
+% Attention |v1.2d| gives new meaning to |\bnumeval|, the former meaning is
+% now named |\bnumexpro|. The leading space in |\BNE_wrap| is removed at it
+% served to nothing.
% \begin{macrocode}
-\def\bnumexpr {\romannumeral0\bnumeval }%
-\def\bnumeval {\expandafter\BNE_wrap\romannumeral0\BNE_eval }%
+\def\bnumexpr {\romannumeral0\bnumexpro }%
+\def\bnumexpro{\expandafter\BNE_wrap\romannumeral0\BNE_eval }%
\def\BNE_eval {\expandafter\BNE_until_end_a\romannumeral-`0\BNE_getnext }%
-\def\BNE_wrap { !\BNE_usethe\BNE_protect\BNE_unlock }%
+\def\BNE_wrap {!\BNE_usethe\BNE_protect\BNE_unlock }%
\protected\def\BNE_usethe\BNE_protect {\BNE:missing_bnethe!}%
-\def\BNE_protect\BNE_unlock {\noexpand\BNE_protect\noexpand\BNE_unlock\noexpand }%
+\def\BNE_protect\BNE_unlock
+ {\noexpand\BNE_protect\noexpand\BNE_unlock\noexpand }%
\let\BNE_done\space
\def\thebnumexpr
- {\romannumeral-`0\expandafter\BNE_unlock\romannumeral0\BNE_eval }%
+ {\romannumeral-`0\expandafter\BNE_unlock\romannumeral0\BNE_eval }%
\def\bnethe #1{\romannumeral-`0\expandafter\xint_gobble_iii\romannumeral-`0#1}%
+\def\bnumeval#1%
+ {\romannumeral-`0\expandafter\BNE_unlock\romannumeral0\BNE_eval#1\relax}%
\def\BNE_unlock {\expandafter\BNE_unlock_a\string }%
\def\BNE_unlock_a #1.={}%
% \end{macrocode}
@@ -1354,7 +1378,7 @@ macros of the same math engine. Its effect obeys the local scope.
Right bracket \] Circumflex \^ Underscore \_
Grave accent \` Left brace \{ Vertical bar \|
Right brace \} Tilde \~}
-\CheckSum {873}
+\CheckSum {881}
\makeatletter\check@checksum\makeatother
\Finale
%% End of file xint.dtx