diff options
author | Karl Berry <karl@freefriends.org> | 2016-07-21 21:17:50 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-07-21 21:17:50 +0000 |
commit | e8a6c5f6d758797dbff323e9d5e9012da75628d3 (patch) | |
tree | d014e2618393764a66d7d7548c687b11f131a86d /Master/texmf-dist/tex/latex/datatool/datatool-pgfmath.sty | |
parent | 21e06c4cf543502d43e374b7ba6868a9e3b82406 (diff) |
datatool (21jul16)
git-svn-id: svn://tug.org/texlive/trunk@41744 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/datatool/datatool-pgfmath.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/datatool/datatool-pgfmath.sty | 75 |
1 files changed, 61 insertions, 14 deletions
diff --git a/Master/texmf-dist/tex/latex/datatool/datatool-pgfmath.sty b/Master/texmf-dist/tex/latex/datatool/datatool-pgfmath.sty index 7d7608f9995..f588ec69d68 100644 --- a/Master/texmf-dist/tex/latex/datatool/datatool-pgfmath.sty +++ b/Master/texmf-dist/tex/latex/datatool/datatool-pgfmath.sty @@ -39,7 +39,7 @@ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{datatool-pgfmath}[2016/01/18 v2.25 (NLCT)] +\ProvidesPackage{datatool-pgfmath}[2016/07/20 v2.26 (NLCT)] \RequirePackage{xkeyval} \RequirePackage{pgfrcs,pgfkeys,pgfmath} \ProcessOptionsX @@ -47,33 +47,38 @@ \newcommand*{\dtlifnumeq}[4]{% \def\@dtl@truepart{#3}% \def\@dtl@falsepart{#4}% - \pgfmathifthenelse{0#1==0#2}{"\noexpand\@dtl@truepart"}{"\noexpand\@dtl@falsepart"}% + \pgfmathifthenelse{\number0#1==\number0#2}% + {"\noexpand\@dtl@truepart"}{"\noexpand\@dtl@falsepart"}% \pgfmathresult } \RequirePackage{datatool-base} \newcommand*{\dtlifnumlt}[4]{% \def\@dtl@truepart{#3}% \def\@dtl@falsepart{#4}% - \pgfmathifthenelse{0#1 < 0#2}{"\noexpand\@dtl@truepart"}{"\noexpand\@dtl@falsepart"}% + \pgfmathifthenelse{\number0#1 < \number0#2}% + {"\noexpand\@dtl@truepart"}{"\noexpand\@dtl@falsepart"}% \pgfmathresult } \newcommand*{\dtlifnumgt}[4]{% \def\@dtl@truepart{#3}% \def\@dtl@falsepart{#4}% - \pgfmathifthenelse{0#1 > 0#2}{"\noexpand\@dtl@truepart"}{"\noexpand\@dtl@falsepart"}% + \pgfmathifthenelse{\number0#1 > \number0#2}% + {"\noexpand\@dtl@truepart"}{"\noexpand\@dtl@falsepart"}% \pgfmathresult } \newcommand*{\dtlifnumopenbetween}[5]{% \def\@dtl@truepart{#4}% \def\@dtl@falsepart{#5}% - \pgfmathifthenelse{(0#2 < 0#1) && (0#1 < 0#3)} + \pgfmathifthenelse + {(\number0#2 < \number0#1) && (\number0#1 < \number0#3)}% {"\noexpand\@dtl@truepart"}{"\noexpand\@dtl@falsepart"}% \pgfmathresult } \newcommand*{\dtlifnumclosedbetween}[5]{% \def\@dtl@truepart{#4}% \def\@dtl@falsepart{#5}% - \pgfmathifthenelse{(0#2 <= #1) && (0#1 <= 0#3)} + \pgfmathifthenelse + {(\number0#2 <= \number0#1) && (\number0#1 <= \number0#3)} {"\noexpand\@dtl@truepart"}{"\noexpand\@dtl@falsepart"}% \pgfmathresult } @@ -98,16 +103,58 @@ \let#1\pgfmathresult } \newcommand*{\dtlround}[3]{% - \pgfmathparse{10^#3}% - \let\dtl@tmpshift\pgfmathresult - \pgfmathparse{round(#2 * \dtl@tmpshift) / \dtl@tmpshift}% - \let#1\pgfmathresult + \ifnum#3=0\relax + \pgfmathparse{int(round(#2))}% + \let#1\pgfmathresult + \else + \pgfmathparse{int(10^#3)}% + \let\dtl@tmpshift\pgfmathresult + \pgfmathparse{int(floor(#2))}% + \let\dtl@int@round\pgfmathresult + \pgfmathparse{int(round((#2-\dtl@int@round) * \dtl@tmpshift))}% + \@dtl@tmpcount=0\relax + \expandafter\@dtl@countdigits\pgfmathresult.\relax + \advance\@dtl@tmpcount by -#3\relax + \def\@dtl@intpart{}% + \def\@dtl@fracpart{}% + \expandafter\@dtl@gatherintfrac\pgfmathresult\relax + \edef\@dtl@intpart{\number\numexpr\dtl@int@round + +\number0\@dtl@intpart}% + \edef#1{\@dtl@intpart.\@dtl@fracpart}% + \fi +} +\newcommand*{\@dtl@gatherintfrac}[1]{% + \ifx\relax#1\relax + \else + \advance\@dtl@tmpcount by -1\relax + \ifnum\@dtl@tmpcount<0\relax + \edef\@dtl@fracpart{\@dtl@fracpart#1}% + \else + \edef\@dtl@intpart{\@dtl@intpart#1}% + \fi + \expandafter\@dtl@gatherintfrac + \fi } \newcommand*{\dtltrunc}[3]{% - \pgfmathparse{10^#3}% - \let\dtl@tmpshift\pgfmathresult - \pgfmathparse{floor(#2 * \dtl@tmpshift) / \dtl@tmpshift}% - \let#1\pgfmathresult + \ifnum#3=0\relax + \pgfmathparse{int(floor(#2))}% + \let#1\pgfmathresult + \else + \pgfmathparse{int(10^#3)}% + \let\dtl@tmpshift\pgfmathresult + \pgfmathparse{int(floor(#2))}% + \let\dtl@int@trunc\pgfmathresult + \pgfmathparse{int(floor((#2-\dtl@int@trunc) * \dtl@tmpshift))}% + \@dtl@tmpcount=0\relax + \expandafter\@dtl@countdigits\pgfmathresult.\relax + \advance\@dtl@tmpcount by -#3\relax + \def\@dtl@intpart{}% + \def\@dtl@fracpart{}% + \expandafter\@dtl@gatherintfrac\pgfmathresult\relax + \edef\@dtl@intpart{\number\numexpr\dtl@int@trunc + +\number0\@dtl@intpart}% + \edef#1{\@dtl@intpart.\@dtl@fracpart}% + \fi } \newcommand*{\dtlclip}[2]{% \edef#1{#2}% |