summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/bnumexpr
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-09-23 21:34:07 +0000
committerKarl Berry <karl@freefriends.org>2014-09-23 21:34:07 +0000
commit809ee2bda7e5afc20f6e22fe1d7a322af86b225e (patch)
tree453a7395692f6769ed653fea3aca2f0a9bbca089 /Master/texmf-dist/tex/latex/bnumexpr
parent0e0fc7e759639635f5874e0c328b0b3a959a93d9 (diff)
bnumexpr (23sep14)
git-svn-id: svn://tug.org/texlive/trunk@35239 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/bnumexpr')
-rw-r--r--Master/texmf-dist/tex/latex/bnumexpr/bnumexpr.sty67
1 files changed, 45 insertions, 22 deletions
diff --git a/Master/texmf-dist/tex/latex/bnumexpr/bnumexpr.sty b/Master/texmf-dist/tex/latex/bnumexpr/bnumexpr.sty
index 748e392c117..f10bc5da65f 100644
--- a/Master/texmf-dist/tex/latex/bnumexpr/bnumexpr.sty
+++ b/Master/texmf-dist/tex/latex/bnumexpr/bnumexpr.sty
@@ -25,14 +25,14 @@
%% Copyright (C) 2014 by Jean-Francois Burnol
%%----------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}%
-\ProvidesPackage{bnumexpr}[2014/09/21 v1.1 Expressions with big integers (jfB)]%
+\ProvidesPackage{bnumexpr}[2014/09/22 v1.1a Expressions with big integers (jfB)]%
\edef\BNErestorecatcodes {\catcode`\noexpand\!\the\catcode`\!
\catcode`\noexpand\?\the\catcode`\?
\catcode`\noexpand\_\the\catcode`\_
\catcode`\noexpand\:\the\catcode`\:\relax }%
-\catcode`\! 11
-\catcode`\? 11
-\catcode`\_ 11
+\catcode`\! 11 % some other catcodes will be manipulated: comma, (, ),
+\catcode`\? 11 % but we reset them to their standard values, thus
+\catcode`\_ 11 % \BNErestorecatcodes is a bit pedantic here.
\catcode`\: 11
\def\BNE_tmpa {0}%
\DeclareOption {custom}{\def\BNE_tmpa {1}%
@@ -46,6 +46,11 @@
Option bigintcalc: the macros from package bigintcalc are used.^^J
Notice that / is mapped to \protect\bigintcalcDiv\space which does truncated division}%
}%
+\DeclareOption {l3bigint}{\def\BNE_tmpa {3}%
+ \PackageWarningNoLine{bnumexpr}{^^J
+ Option l3bigint: the macros from package l3bigint are used.^^J
+ There is no power operation, currently}%
+}%
\DeclareOption {nocsv}{%
\PackageInfo{bnumexpr}{Comma separated expressions disabled}%
\AtEndOfPackage{\expandafter\let\csname BNE_precedence_,\endcsname
@@ -61,22 +66,29 @@
\def\BNE_allowpower {1}%
}%
\ProcessOptions\relax
-\if2\BNE_tmpa % Toggle to load bigintcalc.sty
-\RequirePackage{bigintcalc}%
-\let\bnumexprAdd\bigintcalcAdd
-\let\bnumexprSub\bigintcalcSub
-\let\bnumexprMul\bigintcalcMul
-\let\bnumexprDiv\bigintcalcDiv % NOTE: THIS DOES TRUNCATED DIVISION
-\if1\BNE_allowpower\let\bnumexprPow\bigintcalcPow\fi
-\fi
-\if0\BNE_tmpa % Toggle to load xint.sty (and also xinttools.sty)
-\RequirePackage{xint}%
-\let\bnumexprAdd\xintiiAdd
-\let\bnumexprSub\xintiiSub
-\let\bnumexprMul\xintiiMul
-\if1\BNE_allowpower\let\bnumexprPow\xintiiPow\fi
-\def\bnumexprDiv {\romannumeral0\bnumexprdiv }%
-\def\bnumexprdiv #1{\expandafter\BNE_div \romannumeral-`0#1\Z }%
+\def\bnumexprUsesxint {%
+ \let\bnumexprAdd\xintiiAdd
+ \let\bnumexprSub\xintiiSub
+ \let\bnumexprMul\xintiiMul
+ \let\bnumexprDiv\BNE_xintiiDivRound
+ \let\bnumexprPow\xintiiPow
+}%
+\def\bnumexprUsesbigintcalc {%
+ \let\bnumexprAdd\bigintcalcAdd
+ \let\bnumexprSub\bigintcalcSub
+ \let\bnumexprMul\bigintcalcMul
+ \let\bnumexprDiv\bigintcalcDiv % NOTE: THIS DOES TRUNCATED DIVISION
+ \let\bnumexprPow\bigintcalcPow
+}%
+\def\bnumexprUsesliiibigint {%
+ \let\bnumexprAdd\bigint_add:nn
+ \let\bnumexprSub\bigint_sub:nn
+ \let\bnumexprMul\bigint_mul:nn
+ \let\bnumexprDiv\bigint_div_round:nn
+ \let\bnumexprPow\bigint_pow:nn % does not exist!
+}%
+\def\BNE_xintiiDivRound {\romannumeral0\BNE_xintiidivround }%
+\def\BNE_xintiidivround #1{\expandafter\BNE_div \romannumeral-`0#1\Z }%
\def\BNE_div #1#2\Z #3{\expandafter\BNE_div_a\expandafter #1%
\romannumeral-`0#3\Z #2\Z }%
\def\BNE_div_a #1#2% #1 de A, #2 de B.
@@ -115,6 +127,17 @@
\def\BNE_div_pos_small\Z\BNE_div_pos_c #1#2{\ifnum #1>\xint_c_iv\expandafter
\xint_secondoftwo\else\expandafter
\xint_firstoftwo\fi { 0}{ 1}}%
+\if0\BNE_tmpa % Toggle to load xint.sty (and also xinttools.sty)
+ \RequirePackage{xint}%
+ \bnumexprUsesxint
+\fi
+\if2\BNE_tmpa % Toggle to load bigintcalc.sty
+ \RequirePackage{bigintcalc}%
+ \bnumexprUsesbigintcalc
+\fi
+\if3\BNE_tmpa % Toggle to load l3bigint.sty
+ \RequirePackage{l3bigint}%
+ \bnumexprUsesliiibigint
\fi
\chardef\xint_c_ 0
\chardef\xint_c_i 1
@@ -148,7 +171,7 @@
\def\BNE_eval {\expandafter\BNE_until_end_a\romannumeral-`0\BNE_getnext }%
\def\BNE_wrap { !\BNE_usethe\BNE_protect\BNE_unlock }%
\protected\def\BNE_usethe\BNE_protect {\BNE:missing_bnethe!}%
-\def\BNE_protect {\noexpand\BNE_protect\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 }%
@@ -398,7 +421,7 @@
{!##1}{\expandafter\BNE_scan_nbr_b\string ##1}%
}%
}%
-\let\BNE_tmpa\relax \let\BNE_tmpb\relax \let\BNE_tmpc\relax \let\BNE_allowpower\relax
+\let\BNE_tmpa\relax \let\BNE_tmpb\relax \let\BNE_tmpc\relax
\BNErestorecatcodes
\endinput
%%