diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex | 65 |
1 files changed, 63 insertions, 2 deletions
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 727af976f8d..34a5e406a68 100644 --- a/Master/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex @@ -427,8 +427,29 @@ % Expands a floating point number to scientific format 1.234e5. % % This operation is very fast. -\def\pgfmathfloatvalueof#1{\expandafter\pgfmathfloatvalueof@@#1\relax}% -\def\pgfmathfloatvalueof@@#1Y#2e#3]\relax{% +\def\pgfmathfloatvalueof#1{\expandafter\pgfmathfloatvalueof@@#1@@}% + +% Make it fool proof such that the following arguments work: +% \pgfmathfloatvalueof{1Y1.0e1} -> 1.0e1 +% \pgfmathfloatvalueof{2Y1.0e1} -> -1.0e1 +% and wrong arguments as well: +% \pgfmathfloatvalueof{1} -> 1 +% \pgfmathfloatvalueof{1e2} -> 1e2 +\def\pgfmathfloatvalueof@@#1#2{% + \if#2Y% + % keep in mind that \pgfmathfloatvalueof should be expandable! + % We must not use \let here. Let's hope that #1 and #2 are + % single tokens (not something which was enclosed by curly + % braces...) + \expandafter\pgfmathfloatvalueof@@@\expandafter#1\expandafter#2% + \else + % Oh - no float!? Ok, we cannot report errors in this context. + % So: make it a feature and return the input argument as-is. + % Might be useful, in fact... + \expandafter\pgfmathfloatvalueof@abort\expandafter#1\expandafter#2% + \fi +} +\def\pgfmathfloatvalueof@@@#1Y#2e#3]@@{% \ifcase#1 % 0.0e0% \or @@ -440,6 +461,8 @@ \or -inf% \fi }% +\def\pgfmathfloatvalueof@abort#1@@{#1}% + % Rounds a fixed point number #1 to \pgfmathfloat@round@precision digits precision and returns @@ -907,6 +930,7 @@ \newif\ifpgfmathprintnumber@showpositive \newif\ifpgfmathprintnumber@frac@warn \newif\ifpgfmathprintnumber@frac@whole +\newif\ifpgfmathparsenumber@comma@as@period \long\def\pgfmathfloatfrac@verbatim#1#2{#1/#2}% @@ -987,6 +1011,8 @@ showpos/.default=true, print sign/.is if=pgfmathprintnumber@showpositive, print sign/.default=true, + read comma as period/.is if=pgfmathparsenumber@comma@as@period, + read comma as period/.default=true, skip 0./.is if=pgfmathprintnumberskipzeroperiod, skip 0./.default=true, skip 0.= false, @@ -2245,6 +2271,9 @@ \pgfmathfloatcreate{0}{0.0}{0}% }% },% + /pgf/fpu/handlers/invalid separator/.code 2 args={% + \pgfmath@error{Could not parse input '#1' as a floating point number, sorry. The unreadable part was near the decimal separator '#2'. Do you need the option 'read comma as period'?}{}% + }, /pgf/fpu/handlers/invalid number/.code 2 args={% \pgfmath@error{Could not parse input '#1' as a floating point number, sorry. The unreadable part was near '#2'.}{}% }, @@ -2317,6 +2346,30 @@ \expandafter\def\csname pgffltA@.\endcsname{% read '.9' like '0.9' \pgfmathfloat@a@E=-1 \pgfflt@leadingzero@foundperiod}% +\expandafter\def\csname pgffltA@,\endcsname{% read ',9' like '0,9' + \pgfmathfloat@frenchinput{% + \pgfmathfloat@a@E=-1 + \pgfflt@leadingzero@foundperiod + }% +}% + +\def\pgfmathfloat@frenchinput#1{% + \ifpgfmathparsenumber@comma@as@period + \def\pgf@marshal{#1}% + \expandafter\pgf@marshal + \else + \expandafter\pgfflt@error@separator\expandafter,% + \fi +}% +\def\pgfflt@error@separator#1\pgfflt@EOI{% + \begingroup + \pgfmathfloat@a@Mtok={#1}% + \xdef\pgfmathfloat@glob@TMP{% + \noexpand\pgfmathfloatparsenumber@handleerror + {invalid separator}{\pgfmathresult}{\the\pgfmathfloat@a@Mtok}}% + \endgroup + \pgfmathfloat@glob@TMP +}% \def\pgfflt@finish#1\pgfflt@EOI{} @@ -2374,6 +2427,12 @@ \expandafter\def\csname pgffltB@.\endcsname{% \pgfmathfloat@a@E=-1 \pgfflt@leadingzero@foundperiod}% +\expandafter\def\csname pgffltB@,\endcsname{% + \pgfmathfloat@frenchinput{% + \pgfmathfloat@a@E=-1 + \pgfflt@leadingzero@foundperiod + }% +}% \expandafter\def\csname pgffltB@e\endcsname{% \pgfmathfloat@a@S=0\relax% \pgfmathfloat@a@Mtok={0.0}% @@ -2438,6 +2497,7 @@ \expandafter\def\csname pgffltD@9\endcsname{\pgffltD@nonzerodigit9}% \expandafter\def\csname pgffltD@\pgfmathfloat@POSTFLAGSCHAR\endcsname{\pgfflt@readlowlevelfloat}% \expandafter\def\csname pgffltD@.\endcsname{\pgfflt@finish@number@after@period}% FIXME : inlining? +\expandafter\def\csname pgffltD@,\endcsname{\pgfmathfloat@frenchinput{\pgfflt@finish@number@after@period}}% \expandafter\def\csname pgffltD@e\endcsname{\pgfflt@readexponent}% FIXME : inlining? \let\pgffltD@E=\pgffltD@e \expandafter\def\csname pgffltD@\pgfflt@EOI\endcsname{}% NOP @@ -2497,6 +2557,7 @@ \expandafter\def\csname pgffltE@8\endcsname{\pgffltE@nonzerodigit8}% \expandafter\def\csname pgffltE@9\endcsname{\pgffltE@nonzerodigit9}% \expandafter\def\csname pgffltE@.\endcsname{\pgfflt@finish@number@after@period}% FIXME : inlining? +\expandafter\def\csname pgffltE@,\endcsname{\pgfmathfloat@frenchinput{\pgfflt@finish@number@after@period}}% FIXME : inlining? \def\pgffltE@e{\pgfflt@readexponent}% FIXME : inlining? \let\pgffltE@E=\pgffltE@e \expandafter\def\csname pgffltE@\pgfflt@EOI\endcsname{}% NOP |