%% %% This is file `bnumexpr.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% bnumexpr.dtx (with options: `package') %% %% IMPORTANT NOTICE: %% %% For the copyright see the source file. %% %% Any modified versions of this file must be renamed %% with new filenames distinct from bnumexpr.sty. %% %% For distribution of the original source see the terms %% for copying and modification in the file bnumexpr.dtx. %% %% This generated file may be distributed as long as the %% original source files, as listed above, are part of the %% same distribution. (The sources need not necessarily be %% in the same archive or directory.) %% --------------------------------------------------------------- %% The bnumexpr package: Expressions with big integers %% Copyright (C) 2014-2019 by Jean-Francois Burnol %% \NeedsTeXFormat{LaTeX2e}% \ProvidesPackage{bnumexpr}[2019/01/08 v1.2e Expressions with big integers (JFB)]% \edef\BNErestorecatcodes {\catcode`\noexpand\!\the\catcode`\! \catcode`\noexpand\?\the\catcode`\? \catcode`\noexpand\_\the\catcode`\_ \catcode`\noexpand\:\the\catcode`\: \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 \catcode`\, 12 \catcode`\* 12 \catcode`\( 12 \chardef\xint_c_ 0 \chardef\xint_c_i 1 \chardef\xint_c_ii 2 \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 \long\def\xint_gobble_i #1{}% \long\def\xint_gobble_iii #1#2#3{}% \long\def\xint_firstofone #1{#1}% \long\def\xint_firstoftwo #1#2{#1}% \long\def\xint_secondoftwo #1#2{#2}% \long\def\xint_firstofthree #1#2#3{#1}% \long\def\xint_secondofthree #1#2#3{#2}% \long\def\xint_thirdofthree #1#2#3{#3}% \def\xint_gob_til_! #1!{}% this ! has catcode 11 \long\def\xint_UDsignfork #1-#2#3\krof {#2}% \long\def\xint_afterfi #1#2\fi {\fi #1}% \long\def\xint_dothis #1#2\xint_orthat #3{\fi #1}% \let\xint_orthat \xint_firstofone \long\def\xint_zapspaces #1 #2{#1#2\xint_zapspaces }% \catcode`! 3 \def\bnumexprsetup #1{\BNE_parsekeys #1,=!,}% \def\BNE_parsekeys #1=#2#3,{\ifx!#2\expandafter\BNE_parsedone\fi \expandafter \let\csname BNE_Op_\xint_zapspaces #1 \xint_gobble_i\endcsname=#2\BNE_parsekeys }% \catcode`! 11 \def\BNE_parsedone #1\BNE_parsekeys {}% \def\BNE_tmpa {0}% \DeclareOption {custom}{\def\BNE_tmpa {1}}% \ProcessOptions\relax \if0\BNE_tmpa % Default is to load xintcore.sty \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 \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 }% \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 {\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.={}% \def\BNE_getnext #1% {% \expandafter\BNE_getnext_a\romannumeral-`0#1% }% \def\BNE_getnext_a #1% {% \xint_gob_til_! #1\BNE_gn_foundexpr !% this ! has catcode 11 \ifcat\relax#1% \count or \numexpr etc... token or count, dimen, skip cs \expandafter\BNE_gn_countetc \else \expandafter\expandafter\expandafter\BNE_gn_fork\expandafter\string \fi #1% }% \def\BNE_gn_foundexpr !#1\fi !{\expandafter\BNE_getop\xint_gobble_iii }% \def\BNE_gn_countetc #1% {% \ifx\count#1\else\ifx\dimen#1\else\ifx\numexpr#1\else\ifx\dimexpr#1\else \ifx\skip#1\else\ifx\glueexpr#1\else\ifx\fontdimen#1\else\ifx\ht#1\else \ifx\dp#1\else\ifx\wd#1\else\ifx\fontcharht#1\else\ifx\fontcharwd#1\else \ifx\fontchardp#1\else\ifx\fontcharic#1\else \BNE_gn_unpackvar \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \expandafter\BNE_getnext\number #1% }% \def\BNE_gn_unpackvar\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \expandafter\BNE_getnext\number #1% {% \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \expandafter\BNE_getop\csname .=\number#1\endcsname }% \def\BNE_gn_fork #1{% \if#1+\xint_dothis \BNE_getnext\fi \if#1-\xint_dothis -\fi \if#1(\xint_dothis \BNE_oparen \fi \xint_orthat {\BNE_scan_number #1}% }% \def\BNE_scan_number #1% this #1 has necessarily here catcode 12 {% \ifnum \xint_c_ix<1#1 \else\expandafter\BNE_notadigit\fi \BNE_scan_nbr #1% }% \def\BNE_notadigit\BNE_scan_nbr #1{\BNE:not_a_digit!\BNE_getnext }% \def\BNE_scan_nbr #1% {% the #1 here is a catcode 12 digit \if#10\expandafter\BNE_scan_nbr_gobzeroes \else \expandafter\BNE_scan_nbr_start \fi #1% }% \def\BNE_scan_nbr_start #1#2% {% \expandafter\BNE_getop\csname.=#1% \expandafter\BNE_scanint_b\romannumeral-`0#2% }% \def\BNE_scan_nbr_gobzeroes #1% {% \expandafter\BNE_getop\csname.=% \expandafter\BNE_gobz_scanint_b\romannumeral-`0#1% }% \def\BNE_scanint_b #1% {% \ifcat \relax #1\expandafter\BNE_scanint_endbycs\expandafter #1\fi \ifnum\xint_c_ix<1\string#1 \else\expandafter\BNE_scanint_c\fi \string#1\BNE_scanint_d }% \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% }% \def\BNE_scanint_d #1% {% \expandafter\BNE_scanint_b\romannumeral-`0#1% }% \def\BNE_gobz_scanint_b #1% {% \ifcat \relax #1\expandafter\BNE_gobz_scanint_endbycs\expandafter #1\fi \ifnum\xint_c_x<1\string#1 \else\expandafter\BNE_gobz_scanint_c\fi \string#1\BNE_scanint_d }% \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}% }% \def\BNE_gobz_scanint_d #1% {% \expandafter\BNE_gobz_scanint_b\romannumeral-`0#1% }% \def\BNE_getop #1#2% this #1 is the current locked computed value {% \expandafter\BNE_getop_a\expandafter #1\romannumeral-`0#2% }% \catcode`* 11 \def\BNE_getop_a #1#2% {% if a control sequence is found, must be \relax, or possibly register or % variable if tacit multiplication is allowed \ifx \relax #2\xint_dothis\xint_firstofthree\fi % tacit multiplications: \ifcat \relax #2\xint_dothis\xint_secondofthree\fi \if (#2\xint_dothis \xint_secondofthree\fi \ifx !#2\xint_dothis \xint_secondofthree\fi \xint_orthat \xint_thirdofthree {\BNE_foundend #1}% {\BNE_precedence_* *#1#2}% tacit multiplication {\BNE_scanop_a #2#1}% }% \catcode`* 12 \def\BNE_foundend {\xint_c_ \relax }% \relax is only a place-holder here. \def\BNE_scanop_a #1#2#3% {\expandafter\BNE_scanop_b\expandafter #1\expandafter #2\romannumeral-`0#3}% \def\BNE_scanop_b #1#2#3% {% \ifcat#3\relax\xint_dothis{\BNE_foundop #1#2#3}\fi \ifcsname BNE_itself_#1#3\endcsname \xint_dothis {\expandafter\BNE_foundop\csname BNE_itself_#1#3\endcsname #2}\fi \xint_orthat {\BNE_foundop #1#2#3}% }% \def\BNE_foundop #1% {% \ifcsname BNE_precedence_#1\endcsname \csname BNE_precedence_#1\expandafter\endcsname \expandafter #1% \else \BNE_notanoperator {#1}\expandafter\BNE_getop \fi }% \def\BNE_notanoperator #1{\BNE:not_an_operator! \xint_gobble_i {#1}}% \catcode`) 11 \def\BNE_tmpa #1{% \def\BNE_until_end_a ##1% {% \xint_UDsignfork ##1{\expandafter\BNE_until_end_a\romannumeral-`0#1}% -{\BNE_until_end_b ##1}% \krof }% }\expandafter\BNE_tmpa\csname BNE_op_-vi\endcsname \def\BNE_until_end_b #1#2% {% \ifcase #1\expandafter\BNE_done \or \xint_afterfi{\BNE:extra_)_?\expandafter \BNE_until_end_a\romannumeral-`0\BNE_getop }% \else \xint_afterfi{\expandafter\BNE_until_end_a \romannumeral-`0\csname BNE_op_#2\endcsname }% \fi }% \catcode`( 11 \def\BNE_op_( {\expandafter\BNE_until_)_a\romannumeral-`0\BNE_getnext }% \let\BNE_oparen\BNE_op_( \catcode`( 12 \def\BNE_tmpa #1{% \def\BNE_until_)_a ##1{\xint_UDsignfork ##1{\expandafter \BNE_until_)_a\romannumeral-`0#1}% -{\BNE_until_)_b ##1}% \krof }% }\expandafter\BNE_tmpa\csname BNE_op_-vi\endcsname \def \BNE_until_)_b #1#2% {% \ifcase #1\expandafter \BNE_missing_)_? % missing ) ? \or\expandafter \BNE_getop % found closing ) \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 \def\BNE_tmpc #1#2#3#4#5#6#7% {% \def #1##1% \BNE_op_ {% 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__a {\xint_UDsignfork ##2{\expandafter #2\expandafter ##1\romannumeral-`0#4}% -{#3##1##2}% \krof }% \def #3##1##2##3##4% \BNE_until__b {% either execute next operation now, or first do next (possibly unary) \ifnum ##2>#5% \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0% \csname BNE_op_##3\endcsname {##4}}% \else \xint_afterfi {\expandafter ##2\expandafter ##3% \csname .=#6{\BNE_unlock ##1}{\BNE_unlock ##4}\endcsname }% \fi }% \let #7#5% }% \def\BNE_tmpb #1#2#3% {% \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 #3\expandafter\endcsname \csname BNE_precedence_#1\endcsname }% \BNE_tmpb +{vi}{BNE_Op_add}% \BNE_tmpb -{vi}{BNE_Op_sub}% \BNE_tmpb *{vii}{BNE_Op_mul}% \BNE_tmpb /{vii}{BNE_Op_divround}% \BNE_tmpb ^{viii}{BNE_Op_pow}% \expandafter\def\csname BNE_itself_**\endcsname {^}% shortcut for alias \expandafter\def\csname BNE_itself_//\endcsname {//}% \expandafter\def\csname BNE_itself_/:\endcsname {/:}% \BNE_tmpb {//}{vii}{BNE_Op_div}% \BNE_tmpb {/:}{vii}{BNE_Op_mod}% \let\BNE_precedence_! \xint_c_x \def\BNE_op_! #1% {\expandafter\BNE_getop\csname .=\BNE_Op_fac{\BNE_unlock #1}\endcsname }% \def\BNE_tmpa #1% {% \expandafter\BNE_tmpb \csname BNE_op_-#1\expandafter\endcsname \csname BNE_until_-#1_a\expandafter\endcsname \csname BNE_until_-#1_b\expandafter\endcsname \csname xint_c_#1\endcsname }% \def\BNE_tmpb #1#2#3#4% {% \def #1% \BNE_op_- {% get next number+operator then switch to _until macro \expandafter #2\romannumeral-`0\BNE_getnext }% \def #2##1% \BNE_until_-_a {\xint_UDsignfork ##1{\expandafter #2\romannumeral-`0#1}% -{#3##1}% \krof }% \def #3##1##2##3% \BNE_until_-_b {% \ifnum ##1>#4% \xint_afterfi {\expandafter #2\romannumeral-`0% \csname BNE_op_##2\endcsname {##3}}% \else \xint_afterfi {\expandafter ##1\expandafter ##2% \csname .=\expandafter\BNE_Op_opp \romannumeral-`0\BNE_unlock ##3\endcsname }% \fi }% }% \BNE_tmpa {vi}% \BNE_tmpa {vii}% \BNE_tmpa {viii}% \def\BNE_Op_opp #1{\if-#1\else\if0#10\else-#1\fi\fi }% \catcode`, 11 \def\BNE_op_, #1% {% \expandafter \BNE_until_,_a\expandafter #1\romannumeral-`0\BNE_getnext }% \def\BNE_tmpa #1{% #1 = \BNE_op_-vi \def\BNE_until_,_a ##1##2% {% \xint_UDsignfork ##2{\expandafter \BNE_until_,_a\expandafter ##1\romannumeral-`0#1}% -{\BNE_until_,_b ##1##2}% \krof }% }\expandafter\BNE_tmpa\csname BNE_op_-vi\endcsname \def\BNE_until_,_b #1#2#3#4% {% \ifnum #2>\xint_c_ii \xint_afterfi {\expandafter \BNE_until_,_a \expandafter #1\romannumeral-`0% \csname BNE_op_#3\endcsname {#4}}% \else \xint_afterfi {\expandafter #2\expandafter #3% \csname .=\BNE_unlock #1, \BNE_unlock #4\endcsname }% \fi }% \let \BNE_precedence_, \xint_c_ii \let\BNE_tmpa\relax \let\BNE_tmpb\relax \let\BNE_tmpc\relax \BNErestorecatcodes \endinput %% %% End of file `bnumexpr.sty'.