diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/math')
5 files changed, 94 insertions, 21 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex b/Master/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex index 0c11f544594..fd3eea1b0bf 100644 --- a/Master/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex @@ -7,17 +7,20 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\ifx\pgfmathsetlength\undefined + +% Guard against reading twice +\ifx\pgfmathloaded\pgfutil@undefined + \let\pgfmathloaded=\relax \else \expandafter\endinput \fi -\input pgfmathcalc.code.tex - -\ifx\pgfkeysloaded\undefined - \let\pgfkeysloaded=\relax -\else - \expandafter\input pgfmathfloat.code.tex +% We need keys: +\ifx\pgfkeysloaded\pgfutil@undefined + \input pgfkeys.code.tex \fi +\input pgfmathcalc.code.tex +\input pgfmathfloat.code.tex + \endinput
\ No newline at end of file diff --git a/Master/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex b/Master/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex index 34a5e406a68..006d6ea4046 100644 --- a/Master/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex @@ -805,7 +805,7 @@ } \newif\ifpgfmathfloatround@allow@empty@mantissa -\def\pgfmathfloatround@mantissa@ONE{1.0}% +\def\pgfmathfloatround@mantissa@ONE{1pt }% % #1: sign % #2: mantissa @@ -821,10 +821,38 @@ \ifcase#1\relax \pgfmathprintnumber@fixed@style{#2}#1#2e0\relax% \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}% - \or\pgfmathprintnumber@fixed@style{#2}#1#2e0\relax% - \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}% - \or\pgfmathprintnumber@fixed@style{-#2}#1#2e0\relax% - \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}% + \or + \def\pgfmathfloat@loc@TMPa{1}% "should draw mantissa=1" + \ifpgfmathfloatround@allow@empty@mantissa + \else + \ifdim#2pt=\pgfmathfloatround@mantissa@ONE + \def\pgfmathfloat@loc@TMPa{0}% do not draw it. + \fi + \fi + % + \if1\pgfmathfloat@loc@TMPa + \pgfmathprintnumber@fixed@style{#2}#1#2e0\relax% + \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}% + \else + \def\pgfmathfloat@loc@TMPa{0}% + \pgfmathfloatrounddisplaystyle@shared@impl@{#5}{#6}% + \fi + \or + \def\pgfmathfloat@loc@TMPa{1}% "should draw mantissa=1" + \ifpgfmathfloatround@allow@empty@mantissa + \else + \ifdim#2pt=\pgfmathfloatround@mantissa@ONE + \def\pgfmathfloat@loc@TMPa{0}% do not draw it. + \fi + \fi + % + \if1\pgfmathfloat@loc@TMPa + \pgfmathprintnumber@fixed@style{-#2}#1#2e0\relax% + \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}% + \else + \def\pgfmathfloat@loc@TMPa{0}% + \pgfmathfloatrounddisplaystyle@shared@impl@{-#5}{#6}% + \fi \or \pgfmathfloatrounddisplaystyle@shared@impl@@{\hbox{NaN}}{}% \or @@ -1049,8 +1077,15 @@ @sci exponent mark=, }% }, -% sci may skip mantissa/.is if=pgfmathfloatround@allow@empty@mantissa, -% sci may skip mantissa/.default=true, + retain unit mantissa/.is if=pgfmathfloatround@allow@empty@mantissa, + retain unit mantissa/.default=true, + retain unit mantissa=true, + % + % allows to replace the implementation, for example + % 'implementation=\num'. This is experimental -- it is inclear + % if all consumers work well since they rely on the keys in + % /pgf/number format. + implementation/.code={\def\pgfmathprintnumber@protected{#1}}, } @@ -1121,7 +1156,7 @@ } \def\pgfmathprintnumber@RELATIVE@choice@roundtofixed@warn{% - \immediate\write16{! Package pgf warning: the use of /pgf/number format/relative is discouraged (buggy). Please use 'relative*' instead or type \string\pgfkeys{/pgf/number format/relative round mode=fixed} into your preamble.}% + \pgf@typeout{! Package pgf warning: the use of /pgf/number format/relative is discouraged (buggy). Please use 'relative*' instead or type \string\pgfkeys{/pgf/number format/relative round mode=fixed} into your preamble.}% \global\let\pgfmathprintnumber@RELATIVE@choice@roundtofixed@warn=\relax } @@ -1389,7 +1424,7 @@ \ifnum\pgfmathresultdenom>1000 \pgfutil@ifundefined{FPdiv}{% \pgfmathfloattosci@\pgfmathfloat@arg - \immediate\write16{! Package pgf /pgf/number format/frac warning=true: /pgf/number format/frac of `\pgfmathresult' = \the\pgfmathresultnumerator\space / \the\pgfmathresultdenom\space might be large due to instabilities. Try \string\usepackage{fp} to improve accuracy.}% + \pgf@typeout{! Package pgf /pgf/number format/frac warning=true: /pgf/number format/frac of `\pgfmathresult' = \the\pgfmathresultnumerator\space / \the\pgfmathresultdenom\space might be large due to instabilities. Try \string\usepackage{fp} to improve accuracy.}% }{}% \fi \fi diff --git a/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integerarithmetics.code.tex b/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integerarithmetics.code.tex index f11704c94c2..9094da50dc9 100644 --- a/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integerarithmetics.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integerarithmetics.code.tex @@ -121,4 +121,4 @@ \pgfmath@smuggleone\pgfmathresult \endgroup} -\endinput
\ No newline at end of file +\endinput diff --git a/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code.tex b/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code.tex index 03f9ca270ae..07f7b8b6d90 100644 --- a/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code.tex @@ -39,17 +39,28 @@ \pgfmathdeclarefunction{floor}{1}{% \begingroup% \expandafter\pgfmath@x#1pt\relax% - \afterassignment\pgfmath@gobbletilpgfmath@% - \expandafter\c@pgfmath@counta\the\pgfmath@x\relax\pgfmath@% + \afterassignment\pgfmathfloor@collect@remainder% + \expandafter\c@pgfmath@counta\the\pgfmath@x\pgfmath@% \expandafter\pgfmath@x#1pt\relax% \ifdim\pgfmath@x<0pt\relax% - \advance\c@pgfmath@counta by -1\relax% + \ifdim\pgfmathfloor@remainder>0pt + \advance\c@pgfmath@counta by -1\relax% + \else + % ok, we stripped only '0'. + \fi \fi% \pgfmath@x\c@pgfmath@counta pt\relax% \pgfmath@returnone\pgfmath@x% \endgroup% }% +\def\pgfmathfloor@collect@remainder#1\pgfmath@{% + \def\pgfmathfloor@remainder{#1}% + \ifx\pgfmathfloor@remainder\pgfutil@empty + \def\pgfmathfloor@remainder{0}% + \fi +}% + % ceil function. % \pgfmathdeclarefunction{ceil}{1}{% diff --git a/Master/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex b/Master/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex index e2c78d1fdf4..0ede2314cfe 100644 --- a/Master/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex @@ -160,6 +160,24 @@ \def\pgfmathresultunitscale{1} + +% A utility function which evaluates expression '#1' and invokes '#2' +% if the expression is true and '#3' if it is false. +\def\pgfmathifexpression#1#2#3{% + \pgfmathparse{#1}% + \pgfmath@iftrue{#2}{#3}% +}% +% Executes '#1' if \pgfmathresult is 'true', '#2' otherwise. +% WARNING : overwritten in fpu lib! +\def\pgfmath@iftrue{% + \ifdim\pgfmathresult pt=1.0pt % + \let\pgfmath@next=\pgfutil@firstoftwo + \else + \let\pgfmath@next=\pgfutil@secondoftwo + \fi + \pgfmath@next% +}% + % Stuff for compatability with the calc package. % \def\pgfmath@calc@real#1{#1} @@ -261,6 +279,10 @@ \fi \pgfmath@parse@next} +% TT: If false, octal parsing is switched off (needed for time parsing) +\newif\ifpgfmath@octalparsing +\pgfmath@octalparsingtrue + % I (CJ) *think* it replaces |{| and |}| by |\pgfmath@bgroup| and % |\pgfmath@egroup|? \def\pgfmath@parse@@@ifbgroup#1{% @@ -312,7 +334,9 @@ \let\pgfmath@base=\pgfmath@empty% \let\pgfmath@token@next=\pgfmath@token% \if#10% Check for octal prefix. - \def\pgfmath@base{8}% + \ifpgfmath@octalparsing% + \def\pgfmath@base{8}% + \fi% \fi% \let\pgfmath@parse@next=\pgfmath@parse@number% \else% |