diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex | 1429 |
1 files changed, 453 insertions, 976 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex index e199d44f811..3d0cad1b196 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmathfloat.code.tex @@ -10,7 +10,7 @@ % This file contains methods for basic floating point arithmetics, rounding % to arbitrary precision and number pretty printing. % -% Version 0.9.4 2008/03/18 +% Version 1.0 2008/09/17 \global\newif\ifpgfmathfloatcomparison \newif\ifpgfmathfloatroundhasperiod @@ -90,12 +90,11 @@ \def\pgfmathfloatparsenumber#1{% \begingroup \edef\pgfmathresult{#1}% - \expandafter\pgfmathfloatparsenumber@impl\pgfmathresult\pgfmathfloat@EOI + \expandafter\pgfflt@impl\pgfmathresult\pgfflt@EOI \ifpgfmathfloatparsenumberpendingperiod \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.0}% \fi - \edef\pgfmathresult{% - \the\pgfmathfloat@a@S\the\pgfmathfloat@a@Mtok e\the\pgfmathfloat@a@E}% + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% \pgfmath@smuggleone\pgfmathresult \endgroup } @@ -103,18 +102,27 @@ % The same as \pgfmathfloatparsenumber, but does not perform sanity checking. \def\pgfmathfloatqparsenumber#1{% \begingroup - \let\pgfmathfloatparsenumber@sanitize@digit=\relax \edef\pgfmathresult{#1}% - \expandafter\pgfmathfloatparsenumber@impl\pgfmathresult\pgfmathfloat@EOI + \expandafter\pgfflt@impl\pgfmathresult\pgfflt@EOI \ifpgfmathfloatparsenumberpendingperiod \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.0}% \fi - \edef\pgfmathresult{% - \the\pgfmathfloat@a@S\the\pgfmathfloat@a@Mtok e\the\pgfmathfloat@a@E}% + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% \pgfmath@smuggleone\pgfmathresult \endgroup } +% Assigns \pgfmathresult to be a float encoded as +% <FLAGS><MANTISSE>e<EXPONENT> +% +% example: +% \pgfmathfloatcreate{1}{2.0}{10} +% \pgfmathfloat@to@FMeE@style\pgfmathresult +% -> +% \pgfmathresult is now '12.0e10' regardless of the internal float +% format. +\def\pgfmathfloat@to@FMeE@style#1{\expandafter\pgfmathfloat@to@FMeE@style@#1\relax}% +\def\pgfmathfloat@to@FMeE@style@#1Y#2e#3]\relax{\def\pgfmathresult{#1#2e#3}}% % decomposes a lowlevel floating point representation into flags, % mantisse and exponent. @@ -122,22 +130,22 @@ % #4: integer register for the flags. % #5: dimen registers for the mantisse. % #6: integer register for the exponent. -\def\pgfmathfloat@decompose#1#2e#3\relax#4#5#6{% +\def\pgfmathfloat@decompose#1Y#2e#3]\relax#4#5#6{% #4=#1\relax #5=#2pt% #6=#3\relax% } % overloaded, #5 needs to be a token register for the mantisse. -\def\pgfmathfloat@decompose@tok#1#2e#3\relax#4#5#6{% +\def\pgfmathfloat@decompose@tok#1Y#2e#3]\relax#4#5#6{% #4=#1\relax #5={#2}% #6=#3\relax% } % overloaded, returns only ONE of the three components into #4: -\def\pgfmathfloat@decompose@F#1#2e#3\relax#4{#4=#1\relax}% -\def\pgfmathfloat@decompose@M#1#2e#3\relax#4{#4=#2pt}% -\def\pgfmathfloat@decompose@Mtok#1#2e#3\relax#4{#4={#2}}% -\def\pgfmathfloat@decompose@E#1#2e#3\relax#4{#4=#3\relax}% +\def\pgfmathfloat@decompose@F#1Y#2e#3]\relax#4{#4=#1\relax}% +\def\pgfmathfloat@decompose@M#1Y#2e#3]\relax#4{#4=#2pt}% +\def\pgfmathfloat@decompose@Mtok#1Y#2e#3]\relax#4{#4={#2}}% +\def\pgfmathfloat@decompose@E#1Y#2e#3]\relax#4{#4=#3\relax}% % Takes a floating point number #1 as input and writes flags to macro % #2, mantisse to macro #3 and exponent to macro #4. @@ -187,525 +195,15 @@ % % All arguments are characters and will be expanded using '\edef'. \def\pgfmathfloatcreate#1#2#3{% - \edef\pgfmathresult{#1#2e#3}% -}% - - -% Compares #1 with #2 and sets \pgfmathresult either to 1.0 or 0.0. -% -% It also sets the boolean \ifpgfmathfloatcomparison (globally. -\def\pgfmathfloatlessthan@#1#2{% -%\def\pgfmathfloatlessthan#1#2#3\and#4#5#6{% - \global\pgfmathfloatcomparisonfalse - \begingroup - \expandafter\pgfmathfloat@decompose#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@M\pgfmathfloat@a@E - \expandafter\pgfmathfloat@decompose#2\relax\pgfmathfloat@b@S\pgfmathfloat@b@M\pgfmathfloat@b@E - \ifcase\pgfmathfloat@a@S - % x = 0 -> (x<y <=> y >0) - \ifnum1=\pgfmathfloat@b@S - \global\pgfmathfloatcomparisontrue - \fi - \or - % x > 0 -> (x<y <=> ( y > 0 && |x| < |y|) ) - \ifnum1=\pgfmathfloat@b@S - % y>0: - \pgfmathfloatlessthan@positive - \fi - \or - % x < 0 -> (x<y <=> (y >= 0 || |x| > |y|) ) - \ifnum2=\pgfmathfloat@b@S - % 'y<0': - \pgfmathfloatgreaterthan@positive - \else - \global\pgfmathfloatcomparisontrue - \fi - \else - \pgfmath@error{Sorry, 'pgfmathfloatlessthan@{#1}{#2}' not yet supported.}% - \fi - \endgroup - \ifpgfmathfloatcomparison - \def\pgfmathresult{1.0}% - \else - \def\pgfmathresult{0.0}% - \fi -} -\let\pgfmathfloatlessthan=\pgfmathfloatlessthan@ - -% compares \pgfmathfloat@a@[SME] < \pgfmathfloat@b@[SME] -\def\pgfmathfloatlessthan@positive{% - \ifnum\pgfmathfloat@a@E<\pgfmathfloat@b@E - \global\pgfmathfloatcomparisontrue - \else - \ifnum\pgfmathfloat@a@E=\pgfmathfloat@b@E - \ifdim\pgfmathfloat@a@M<\pgfmathfloat@b@M - \global\pgfmathfloatcomparisontrue - \fi - \fi - \fi -} - -% compares \pgfmathfloat@a@[SME] > \pgfmathfloat@b@[SME] -\def\pgfmathfloatgreaterthan@positive{% - \ifnum\pgfmathfloat@a@E>\pgfmathfloat@b@E - \global\pgfmathfloatcomparisontrue - \else - \ifnum\pgfmathfloat@a@E=\pgfmathfloat@b@E - \ifdim\pgfmathfloat@a@M>\pgfmathfloat@b@M - \global\pgfmathfloatcomparisontrue - \fi - \fi - \fi -} - - -\def\pgfmathfloatmax@#1#2{% - \pgfmathfloatlessthan{#1}{#2}% - \ifpgfmathfloatcomparison - \edef\pgfmathresult{#2}% - \else - \edef\pgfmathresult{#1}% - \fi -} -\let\pgfmathfloatmax=\pgfmathfloatmax@ - -\def\pgfmathfloatmin@#1#2{% - \pgfmathfloatlessthan{#1}{#2}% - \ifpgfmathfloatcomparison - \edef\pgfmathresult{#1}% - \else - \edef\pgfmathresult{#2}% - \fi -} -\let\pgfmathfloatmin=\pgfmathfloatmin@ - -% Renormalizes #1 to extended precision mantisse, meaning -% 100 <= m < 1000 -% instead of 1 <= m < 10. -% -% The 'extended precision' means we have higher accuracy when we apply pgfmath operations to mantisses. -% -% The input argument is expected to be a normalized floating point number; the output argument is a non-normalized floating point number (well, normalized to extended precision). -% -% The operation is supposed to be very fast. -\def\pgfmathfloattoextentedprecision#1{% - \begingroup - \pgfmathfloattoextentedprecision@a{#1}% - \pgfmathfloatcreate{\pgfmathfloat@a@S}{\pgfmathresult}{\pgfmathfloat@a@E}% - \pgfmath@smuggleone\pgfmathresult - \endgroup -}% - -\def\pgfmathfloattoextentedprecision@@zero#1\pgfmathfloat@EOI{% - \edef\pgfmathresult{#1}% -}% -\def\pgfmathfloattoextentedprecision@@one#1.#2#3\pgfmathfloat@EOI{% - \edef\pgfmathresult{#1#2.#3}% -}% -\def\pgfmathfloattoextentedprecision@@two#1.#2#3#4\pgfmathfloat@EOI{% - \edef\pgfmathresult{#1#2#3.#4}% -}% - -% Sets extended precision to 10^#1. -% -% The default is 10^2, which means mantissas in extended precision are -% normalised to 100 <= m < 1000. -% -% The case 10^1 means they are normalised to 10 <= m < 100 and 10^0 -% deactivates extended precision. -% -% #1 is the exponent, #1 = 0,1 or 2. -% -% This setting applies to \pgfmathfloattoextentedprecision. -\def\pgfmathfloatsetextprecision#1{% - \ifcase#1\relax - \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@zero - \def\pgfmathfloatextprec@shift{0}% - \or - \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@one - \def\pgfmathfloatextprec@shift{1}% - \else - \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@two - \def\pgfmathfloatextprec@shift{2}% - \fi + \edef\pgfmathresult{#1Y#2e#3]}% }% -\pgfmathfloatsetextprecision{2}% +% This is the character present in any low-level floating point +% number. It is assumed to be the SECOND character of a float (after +% the flags integer). +\def\pgfmathfloat@POSTFLAGSCHAR{Y} -% Does the same work as \pgfmathfloattoextentedprecision, but this one here fills the -% registers \pgfmathfloat@a@S and \pgfmathfloat@a@E with the flags and (renormalized) exponent. -% It destroys the content of \pgfmathfloat@a@Mtok. -\def\pgfmathfloattoextentedprecision@a#1{% - \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E - \ifnum\pgfmathfloat@a@S<3 - \advance\pgfmathfloat@a@E by-\pgfmathfloatextprec@shift\relax% compensate for shift - \expandafter\pgfmathfloattoextentedprecision@@\the\pgfmathfloat@a@Mtok 00\pgfmathfloat@EOI - \else - \edef\pgfmathresult{#1}% - \fi -}% -% Similar to \pgfmathfloattoextentedprecision@a, this one here fills the '@b' registers. -\def\pgfmathfloattoextentedprecision@b#1{% - \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@b@S\pgfmathfloat@a@Mtok\pgfmathfloat@b@E - \ifnum\pgfmathfloat@b@S<3 - \advance\pgfmathfloat@b@E by-\pgfmathfloatextprec@shift\relax - \expandafter\pgfmathfloattoextentedprecision@@\the\pgfmathfloat@a@Mtok 00\pgfmathfloat@EOI - \else - \edef\pgfmathresult{#1}% - \fi -}% - -% Addition of two floating point numbers using 8 significant digits. -\def\pgfmathfloatadd@#1#2{% - \begingroup - % - % renormalize argument to 100 <= m < 1000 for extended accuracy: - \pgfmathfloattoextentedprecision@a{#1}% - \let\pgfmathfloat@arga=\pgfmathresult - % - \pgfmathfloattoextentedprecision@b{#2}% - \let\pgfmathfloat@argb=\pgfmathresult - % - \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. - \ifcase\pgfmathfloat@a@S - \edef\pgfmathresult{#2}% - \pgfmathfloatcomparisonfalse - \or - \or - \edef\pgfmathfloat@arga{-\pgfmathfloat@arga}% - \else - \pgfmathfloatcomparisonfalse - \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{0.0}{0}% - \fi - \ifcase\pgfmathfloat@b@S - \edef\pgfmathresult{#1}% - \pgfmathfloatcomparisonfalse - \or - \or - \edef\pgfmathfloat@argb{-\pgfmathfloat@argb}% - \else - \pgfmathfloatcomparisonfalse - \pgfmathfloatcreate{\the\pgfmathfloat@b@S}{0.0}{0}% - \fi - \ifpgfmathfloatcomparison - % Shift lesser mantisse to fit the larger one: - \ifnum\pgfmathfloat@a@E<\pgfmathfloat@b@E - \pgfmathfloatadd@shift{\pgfmathfloat@arga}{\pgfmathfloat@a@E}{\pgfmathfloat@b@E}% - \else - \pgfmathfloatadd@shift{\pgfmathfloat@argb}{\pgfmathfloat@b@E}{\pgfmathfloat@a@E}% - \fi - % add them! - \pgfmathadd@{\pgfmathfloat@arga}{\pgfmathfloat@argb}% - % renormalize sum. This is the only part were an expensive routine comes into play: - \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% - \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% - \fi - \pgfmath@smuggleone\pgfmathresult - \endgroup -}% - - -% #1=mantisse which needs to be shifted (with smaller exponent) -% #2=smaller exponent -% #3=larger exponent -% -% ATTENTION: this helper method DESTROYS contents of \pgfmathfloat@a@S. -\def\pgfmathfloatadd@shift#1#2#3{% - \pgf@xa=#1 pt% - \pgfmathfloat@a@S=#3\relax - \advance\pgfmathfloat@a@S by-#2\relax - \ifcase\pgfmathfloat@a@S - \or - \divide\pgf@xa by10\relax - \or - \divide\pgf@xa by100\relax - \or - \divide\pgf@xa by1000\relax - \or - \divide\pgf@xa by10000\relax - \or - \divide\pgf@xa by10000\relax - \divide\pgf@xa by10\relax - \or - \divide\pgf@xa by10000\relax - \divide\pgf@xa by100\relax - \or - \divide\pgf@xa by10000\relax - \divide\pgf@xa by1000\relax - \or - \divide\pgf@xa by10000\relax - \divide\pgf@xa by10000\relax - \else - \pgf@xa=0pt% - \fi - #2=#3\relax - \edef#1{\pgf@sys@tonumber\pgf@xa}% -} - -\let\pgfmathfloatadd=\pgfmathfloatadd@ - - -% Subtracts two floating point numbers. -\def\pgfmathfloatsubtract@#1#2{% - \begingroup - \expandafter\pgfmathfloat@decompose@tok#2\relax\pgfmathfloat@b@S\pgfmathfloat@a@Mtok\pgfmathfloat@b@E - \ifcase\pgfmathfloat@b@S - \edef\pgfmathresult{#1}% - \or - \pgfmathfloatcreate{2}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@b@E}% - \let\pgfmathfloatsub@arg=\pgfmathresult - \pgfmathfloatadd@{#1}{\pgfmathfloatsub@arg}% - \or - \pgfmathfloatcreate{1}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@b@E}% - \let\pgfmathfloatsub@arg=\pgfmathresult - \pgfmathfloatadd@{#1}{\pgfmathfloatsub@arg}% - \else - \pgfmathfloatcreate{\the\pgfmathfloat@b@S}{0.0}{0}% - \fi - \pgfmath@smuggleone\pgfmathresult - \endgroup -}% - -\let\pgfmathfloatsubtract=\pgfmathfloatsubtract@ - -% Scales a floating point number #1 with a fixed point number #2 using pgfmathmultiply. -% -% Use this method if #2 is small number. -\def\pgfmathfloatmultiplyfixed@#1#2{% - \begingroup - % - % renormalize argument to 100 <= m < 1000 for extended accuracy: - \pgfmathfloattoextentedprecision@a{#1}% - \let\pgfmathfloat@arga=\pgfmathresult - % - \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. - \ifcase\pgfmathfloat@a@S - \edef\pgfmathresult{#1}% - \pgfmathfloatcomparisonfalse - \or - \or - \edef\pgfmathfloat@arga{-\pgfmathfloat@arga}% - \else - \pgfmathfloatcomparisonfalse - \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{0.0}{0}% - \fi - \ifpgfmathfloatcomparison - \pgfmathmultiply@{\pgfmathfloat@arga}{#2}% - % renormalize product. This is the only part were an expensive routine comes into play: - \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% - \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% - \fi - \pgfmath@smuggleone\pgfmathresult - \endgroup -}% - -\let\pgfmathfloatmultiplyfixed=\pgfmathfloatmultiplyfixed@ - - -\def\pgfmathfloatmultiply@#1#2{% - \begingroup - \pgfmathfloatsetextprecision{1}% - \pgfmathfloattoextentedprecision@a{#1}% - \let\pgfmathfloat@arga=\pgfmathresult - % - \pgfmathfloattoextentedprecision@b{#2}% - \let\pgfmathfloat@argb=\pgfmathresult - % - \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. - \ifcase\pgfmathfloat@a@S - % 0 - \pgfmathfloatcreate{0}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or% + - \ifcase\pgfmathfloat@b@S - \pgfmathfloatcreate{0}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \def\pgfmathresult@S{1}% - \or - \def\pgfmathresult@S{2}% - \else - \expandafter\pgfmathfloatcreate\the\pgfmathfloat@b@S{0.0}{0}% - \pgfmathfloatcomparisonfalse - \fi - \or% - - \ifcase\pgfmathfloat@b@S - \pgfmathfloatcreate{0}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \def\pgfmathresult@S{2}% - \or - \def\pgfmathresult@S{1}% - \or - \pgfmathfloatcreate{3}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{5}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{4}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \fi - \or% nan - \pgfmathfloatcreate{3}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or% +infty - \ifcase\pgfmathfloat@b@S - \pgfmathfloatcreate{0}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{4}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{5}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{3}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{4}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{5}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \fi - \or% -infty - \ifcase\pgfmathfloat@b@S - \pgfmathfloatcreate{0}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{5}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{4}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{3}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{5}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{4}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \fi - \fi - \ifpgfmathfloatcomparison - \pgfmathmultiply@{\pgfmathfloat@arga}{\pgfmathfloat@argb}% - \advance\pgfmathfloat@a@E by\pgfmathfloat@b@E - % renormalize sum. This is the only part were an expensive routine comes into play: - \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% - \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% - \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E - \pgfmathfloatcreate{\pgfmathresult@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% - \fi - \pgfmath@smuggleone\pgfmathresult - \endgroup -}% -\let\pgfmathfloatmultiply=\pgfmathfloatmultiply@ - -\def\pgfmathfloatdivide@#1#2{% - \begingroup - \pgfmathfloatsetextprecision{1}% - \pgfmathfloattoextentedprecision@a{#1}% - \let\pgfmathfloat@arga=\pgfmathresult - % - \pgfmathfloattoextentedprecision@b{#2}% - \let\pgfmathfloat@argb=\pgfmathresult - % - \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases. - \ifcase\pgfmathfloat@a@S - % 0 - \pgfmathfloatcreate{0}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or% + - \ifcase\pgfmathfloat@b@S - \pgfmathfloatcreate{4}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \def\pgfmathresult@S{1}% - \or - \def\pgfmathresult@S{2}% - \or - \pgfmathfloatcreate{3}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \else - \pgfmathfloatcreate{0}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \fi - \or% - - \ifcase\pgfmathfloat@b@S - \pgfmathfloatcreate{5}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \def\pgfmathresult@S{2}% - \or - \def\pgfmathresult@S{1}% - \or - \pgfmathfloatcreate{3}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \else - \pgfmathfloatcreate{0}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \fi - \or% nan - \pgfmathfloatcreate{3}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or% +infty - \ifcase\pgfmathfloat@b@S - \pgfmathfloatcreate{4}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{4}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{5}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{3}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{4}{0.0}{0}% what is inf/inf ? - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{5}{0.0}{0}% or inf/-inf ? - \pgfmathfloatcomparisonfalse - \fi - \or% -infty - \ifcase\pgfmathfloat@b@S - \pgfmathfloatcreate{5}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{5}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{4}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{3}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{5}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \or - \pgfmathfloatcreate{4}{0.0}{0}% - \pgfmathfloatcomparisonfalse - \fi - \fi - \ifpgfmathfloatcomparison - \pgfmathdivide@{\pgfmathfloat@arga}{\pgfmathfloat@argb}% - \advance\pgfmathfloat@a@E by-\pgfmathfloat@b@E - % renormalize sum. This is the only part were an expensive routine comes into play: - \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}% - \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}% - \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E - \pgfmathfloatcreate{\pgfmathresult@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}% - \fi - \pgfmath@smuggleone\pgfmathresult - \endgroup -}% -\let\pgfmathfloatdivide=\pgfmathfloatdivide@ - % Converts a composed floating point representation to fixed point. % % Example: @@ -720,7 +218,8 @@ \expandafter\pgfmathfloattofixed@impl\the\pgfmathfloat@a@Mtok\relax \or \expandafter\pgfmathfloattofixed@impl\the\pgfmathfloat@a@Mtok\relax - \edef\pgfmathresult{-\pgfmathresult}% + \pgfmathfloat@a@Mtok=\expandafter{\pgfmathresult}% + \edef\pgfmathresult{-\the\pgfmathfloat@a@Mtok}% \or\def\pgfmathresult{nan}% \or\def\pgfmathresult{inf}% \or\def\pgfmathresult{-inf}% @@ -751,127 +250,6 @@ }% \let\pgfmathfloattosci=\pgfmathfloattosci@ -% Divides or multiplies the input number by 10^#4 using an arithmetic -% left/right shift. -% -% Input: -% #1 a normalised floating point number. -% #2 a positive or negative integer number denoting the shift. -% -% Example: -% \pgfmathfloatshift{11e3}{4}% -% -> pgfmathresult = 11e7 -\def\pgfmathfloatshift@#1#2{% - \begingroup - \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E - \expandafter\advance\expandafter\pgfmathfloat@a@E#2\relax - \edef\pgfmathresult{\the\pgfmathfloat@a@S\the\pgfmathfloat@a@Mtok e\the\pgfmathfloat@a@E}% - \pgfmath@smuggleone\pgfmathresult - \endgroup -} -\let\pgfmathfloatshift=\pgfmathfloatshift@ - -% Computes a good guess for log(X.XXXX) where the input number should -% be between 0 < x < 10. -% -% If it is not in this range, the returned value will be bad. -% -% For use in the newton implementation of log(x). Please note that we -% first compute a normalized floating point representation of x, and -% the mantisse is always between 0 and 10. -\def\pgfmathlog@smaller@ten@newton@startval#1.#2\to#3{% - \ifcase#1 - \pgfmath@error{pgfmathlog@newton: INTERNAL ERROR: should not happen! - [\#1=0 should have been caught before!]}% - \or#3=0.530628pt - \or#3=0.993pt - \or#3=1.308pt - \or#3=1.5pt - \or#3=1.71pt - \or#3=1.872pt - \or#3=2.01pt - \or#3=2.145pt - \or#3=2.24pt - \fi -} - -% FIXME : eliminate \pgfmathlog@invoke@expanded ? - -% Expands #2 using \edef and invokes #1 with the resulting string. -% -% Example: -% \pgfmath@y=7.9pt -% \pgfmathlog@invoke@expanded\pgfmathexp@{{\pgf@sys@tonumber{\pgfmath@y}}}% -% will invoke -% \pgfmathexp@{7.9} -\def\pgfmathlog@invoke@expanded#1#2{% - \edef\pgfmath@resulttemp{#2}% - \expandafter#1\pgfmath@resulttemp -} - -% This implementation of log(X) is done with a newton method applied to x-exp(y) = 0. -% The implementation \pgfmathexp is used for exp(y). -% -% see \pgfmathlog@ -\def\pgfmathlog@newton#1{% - \pgfmathfloatparsenumber{#1}% - \pgfmathlog@newton@float{\pgfmathresult}% -} - -% the same as \pgfmathlog@newton, but this one takes a floating point number as input. -\def\pgfmathlog@newton@float#1{% - \begingroup% - % compute #1 = M*10^E with normalised mantisse M = [+-]*[1-9].XXXXX - \expandafter\pgfmathfloat@decompose#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@M\pgfmathfloat@a@E - \let\pgfmathlog@loopcount=\pgfmathfloat@b@S% this counter is not used here... use it as loop counter. - % - \ifnum\pgfmathfloat@a@S=1 - % Now, compute log(#1) = log(M) + E*log(10) - \expandafter\pgfmathlog@smaller@ten@newton@startval\the\pgfmathfloat@a@M.\to\pgfmathfloat@b@M - \pgfmathlog@loopcount=0 - \pgfutil@loop - \ifnum\pgfmathlog@loopcount<3 - \pgfmathlog@invoke@expanded\pgfmathexp@{{\pgf@sys@tonumber{\pgfmathfloat@b@M}}}% - \let\pgfmathlog@tmp=\pgfmathresult - \pgfmathlog@invoke@expanded\pgfmathdivide@{{\pgf@sys@tonumber{\pgfmathfloat@a@M}}{\pgfmathlog@tmp}}% - \expandafter\pgfmath@ya\pgfmathresult pt - \advance\pgfmathfloat@b@M by\pgfmath@ya - \advance\pgfmathfloat@b@M by-1pt - \advance\pgfmathlog@loopcount by1 - \pgfutil@repeat - \pgfmathfloat@a@M=2.302585pt% = log(10) - \multiply\expandafter\pgfmathfloat@a@M\pgfmathfloat@a@E - \advance\pgfmathfloat@b@M by\pgfmathfloat@a@M - \edef\pgfmathresult{\pgf@sys@tonumber{\pgfmathfloat@b@M}}% - \else - \let\pgfmathresult=\pgfutil@empty% - \fi - \pgfmath@smuggleone\pgfmathresult - \endgroup% -} - -% Computes log(x) into \pgfmathresult. -% -% REMARK -% This method does NOT use TeX Registers to represent the numbers! The -% computation is COMPLETELY STRING BASED. -% This allows numbers such at 10000000 or 5.23e-10 to be represented -% properly, although TeX-registers would produce overflow/underflow -% errors in these cases. -% -% The natural logarithm is computed using log(X*10^Y) = log(X) + log(10)*Y -\let\pgfmathlog@=\pgfmathlog@newton - -\let\pgfmathlog@float=\pgfmathlog@newton@float - -% Public interface method. This is expected to use \pgfmathparse but -% it DOESN'T do that. \pgfmathparse naturally can't handle numbers -% which exceed TeX's numerical capabilities. However, exponentials are -% typically either too large or too small for TeX. -% -% @see \pgfmathnormalisedfloatingpoint for how we parse arguments. -% @see \pgfmathlog@ -\let\pgfmathlog=\pgfmathlog@newton % Rounds a fixed point number #1 to \pgfmathfloat@round@precision digits precision and returns % the result into \pgfmathresult. @@ -891,7 +269,7 @@ % -> \pgfmathresult = '20000' % % Arguments: -% #1 may be either a number or a macro expanding to a number. +% #1 may be either a number or a macro (\pgfmathresult is allowed) expanding to a number. % % SIDE EFFECT: the global variable \ifpgfmathfloatroundhasperiod will be set. \def\pgfmathroundto#1{% @@ -984,15 +362,20 @@ \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall}% \else - \advance\c@pgf@counta by1% counta:= total number of digits, N. - \c@pgf@countb=\c@pgf@counta - \divide\c@pgf@countb by3% countb := N DIV 3 - \c@pgf@countc=\c@pgf@countb - \multiply\c@pgf@countc by3 - \advance\c@pgf@counta by-\c@pgf@countc% now counta := N MOD 3 - \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% - \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printsign - }% + \ifnum\c@pgf@counta<\pgfkeysvalueof{/pgf/number format/min exponent for 1000 sep}\relax + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printall}% + \else + \advance\c@pgf@counta by1 % counta:= total number of digits, N. + \c@pgf@countb=\c@pgf@counta + \divide\c@pgf@countb by3 % countb := N DIV 3 + \c@pgf@countc=\c@pgf@countb + \multiply\c@pgf@countc by3 + \advance\c@pgf@counta by-\c@pgf@countc% now counta := N MOD 3 + \def\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT{% + \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@printsign + }% + \fi \fi \fi \pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT @@ -1069,7 +452,7 @@ % \def\pgfmathfloat@loc@TMPc{#1#2#3}% % \ifx\pgfmathfloat@loc@TMPc\pgfmathfloat@loc@TMPb % \else - % \pgfmath@error{INTERNAL ERROR in fixed style - The input sequence did not terminate as expected; which indicates a wrong exponent argument provided to \string\pgfmathprintnumber@fixed@style}% + % \pgfmath@error{INTERNAL ERROR in fixed style - The input sequence did not terminate as expected; which indicates a wrong exponent argument provided to \string\pgfmathprintnumber@fixed@style}{}% % \fi %-------------------------------------------------- \let\pgfmathprintnumber@fixed@styleDEFAULT@impl@noperiod@NEXT=\relax @@ -1120,7 +503,9 @@ % Input: % #1 the fixed point number to be displayed (maybe a macro). -% #2#3e#4: the (possibly unformatted) floating point representation which belongs to #1. +% #2#3e#4: the (possibly unformatted) floating point representation +% which belongs to #1. This format is returned (only!) by +% \pgfmathfloat@to@FMeE@style. % It is used to determine sign and exponent. \let\pgfmathprintnumber@fixed@style=\pgfmathprintnumber@fixed@styleDEFAULT @@ -1182,15 +567,15 @@ \or\pgfmathprintnumber@fixed@style{-#2}#1#2e0\relax% \expandafter\pgfmathfloatrounddisplaystyle@shared@impl@\expandafter{\pgfmathresult}{#4#6}% \or - \pgfmathfloatrounddisplaystyle@shared@impl@{NaN}{}% + \pgfmathfloatrounddisplaystyle@shared@impl@@{NaN}{}% \or \ifpgfmathprintnumber@showpositive - \pgfmathfloatrounddisplaystyle@shared@impl@{+\infty}{}% + \pgfmathfloatrounddisplaystyle@shared@impl@@{+\infty}{}% \else - \pgfmathfloatrounddisplaystyle@shared@impl@{\infty}{}% + \pgfmathfloatrounddisplaystyle@shared@impl@@{\infty}{}% \fi \or - \pgfmathfloatrounddisplaystyle@shared@impl@{-\infty}{}% + \pgfmathfloatrounddisplaystyle@shared@impl@@{-\infty}{}% \fi } @@ -1203,6 +588,17 @@ }% \let\pgfmathresult=\pgfmathfloat@glob@TMP }% +% Same as \pgfmathfloatrounddisplaystyle@shared@impl@, but it also +% inserts the '@dec sep mark' at the end. +\def\pgfmathfloatrounddisplaystyle@shared@impl@@#1#2{% + {\toks0={#1}% + \toks1=\expandafter{\pgfmathfloatrounddisplaystyle@e@mark #2}% + \pgfkeysgetvalue{/pgf/number format/@dec sep mark}\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP@MARK + \toks2=\expandafter{\pgfmathprintnumber@fixed@styleDEFAULT@DEC@SEP@MARK}% + \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 \the\toks2 }% + }% + \let\pgfmathresult=\pgfmathfloat@glob@TMP +} \def\pgfmathfloatrounddisplaystyle@std#1#2e#3\relax{% \pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{\cdot}{}{10^{#3}}% @@ -1210,6 +606,9 @@ \def\pgfmathfloatrounddisplaystyle@subscript#1#2e#3\relax{% \pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{}{1}{_{#3}}% } +\def\pgfmathfloatrounddisplaystyle@superscript#1#2e#3\relax{% + \pgfmathfloatrounddisplaystyle@shared@impl#1#2e#3\relax{}{1}{^{#3}}% +} \def\pgfmathfloatrounddisplaystyle@e#1#2e#3\relax{% \ifnum#3<0\relax {\count0=#3\relax @@ -1237,7 +636,7 @@ \expandafter\pgfmathfloat@loc@TMPb\expandafter{\pgfmathresult}% } -% A macro which takes three arguments, sign, mantisse and exponent and +% A macro which takes the argument '<SIGN><MANTISSE>e<EXPONENT>' and % expands to the final TeX-representation for that floating point % number. % @@ -1245,9 +644,8 @@ % the floating point number has already been rounded properly and % the mantisse has been rounded correcty. % -% #1: SIGN -% #2: MANTISSE -% #3: EXPONENT +% The argument needs to be in the format returned by +% \pgfmathfloat@to@FMeE@style and terminated by '\relax'. \let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@std \newif\ifpgfmathfloat@usezerofill@sci \newif\ifpgfmathfloat@usezerofill@fixed @@ -1278,6 +676,7 @@ @sci exponent mark/.initial=, set thousands separator/.initial=, 1000 sep/.style={/pgf/number format/set thousands separator=#1}, + min exponent for 1000 sep/.initial=0, use period/.style= {/pgf/number format/set decimal separator={.},/pgf/number format/set thousands separator={{{,}}}}, use comma/.style= {/pgf/number format/set decimal separator={{{,}}},/pgf/number format/set thousands separator={.}}, showpos/.is if=pgfmathprintnumber@showpositive, @@ -1293,6 +692,7 @@ sci e/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@e}, sci E/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@E}, sci subscript/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@subscript}, + sci superscript/.code= {\let\pgfmathfloatrounddisplaystyle=\pgfmathfloatrounddisplaystyle@superscript}, % sci may skip mantisse/.is if=pgfmathfloatround@allow@empty@mantisse, % sci may skip mantisse/.default=true, } @@ -1302,6 +702,7 @@ \def\pgfmathprintnumber@STD#1{% % parse the input: \pgfmathfloatparsenumber{#1}% + \pgfmathfloat@to@FMeE@style\pgfmathresult \expandafter\pgfmathprintnumber@STD@issci\pgfmathresult\relax } @@ -1329,6 +730,7 @@ \def\pgfmathprintnumber@INT@TRUNC#1{% \pgfmathfloatparsenumber{#1}% + \pgfmathfloat@to@FMeE@style\pgfmathresult \expandafter\pgfmathprintnumber@INT@TRUNC@issci\pgfmathresult\relax } @@ -1338,7 +740,8 @@ } \def\pgfmathprintnumber@INT@TRUNC@issci#1#2e#3\relax{% \ifnum#1<3\relax - \pgfmathfloattofixed{#1#2e#3}% + \pgfmathfloatcreate{#1}{#2}{#3}% + \pgfmathfloattofixed{\pgfmathresult}% \expandafter\pgfmathprintnumber@INT@TRUNC@impl\pgfmathresult\relax#1#2e#3\relax \else \pgfmathfloatrounddisplaystyle#1#2e#3\relax% @@ -1348,13 +751,15 @@ \def\pgfmathprintnumber@INT@DETECT#1{% \pgfmathfloatparsenumber{#1}% + \pgfmathfloat@to@FMeE@style\pgfmathresult \expandafter\pgfmathprintnumber@INT@DETECT@issci\pgfmathresult\relax } \def\pgfmathprintnumber@INT@DETECT@issci#1#2e#3\relax{% \begingroup \ifnum#1<3\relax - \pgfmathfloattofixed{#1#2e#3}% + \pgfmathfloatcreate{#1}{#2}{#3}% + \pgfmathfloattofixed{\pgfmathresult}% \def\pgfmathfloat@round@precision{6}% \expandafter\pgfmathroundto\expandafter{\pgfmathresult}% \ifpgfmathfloatroundhasperiod @@ -1371,13 +776,15 @@ \def\pgfmathprintnumber@FIXED#1{% \pgfmathfloatparsenumber{#1}% + \pgfmathfloat@to@FMeE@style\pgfmathresult \expandafter\pgfmathprintnumber@FIXED@issci\pgfmathresult\relax } \def\pgfmathprintnumber@FIXED@issci#1#2e#3\relax{% \begingroup \ifnum#1<3 - \pgfmathfloattofixed{#1#2e#3}% + \pgfmathfloatcreate{#1}{#2}{#3}% + \pgfmathfloattofixed{\pgfmathresult}% \ifpgfmathfloat@usezerofill@fixed \expandafter\pgfmathroundtozerofill\expandafter{\pgfmathresult}% \else @@ -1401,15 +808,18 @@ \def\pgfmathprintnumber@SCI#1{% \pgfmathfloatparsenumber{#1}% + \pgfmathfloat@to@FMeE@style\pgfmathresult \expandafter\pgfmathprintnumber@SCI@issci\pgfmathresult\relax } \def\pgfmathprintnumber@SCI@issci#1#2e#3\relax{% + \pgfmathfloatcreate{#1}{#2}{#3}% \ifpgfmathfloat@usezerofill@sci - \pgfmathfloatroundzerofill{#1#2e#3}% + \pgfmathfloatroundzerofill{\pgfmathresult}% \else - \pgfmathfloatround{#1#2e#3}% + \pgfmathfloatround{\pgfmathresult}% \fi + \pgfmathfloat@to@FMeE@style\pgfmathresult \expandafter\pgfmathfloatrounddisplaystyle\pgfmathresult\relax } @@ -1426,6 +836,7 @@ \def\pgfmathprintnumber@noopt#1{% \pgfmathprintnumber@{#1}% \ifpgfmathprintnumber@assumemathmode + \pgfmathresult \else \pgfutilensuremath{\pgfmathresult}% \fi @@ -1435,6 +846,7 @@ \pgfqkeys{/pgf/number format}{#1}% \pgfmathprintnumber@{#2}% \ifpgfmathprintnumber@assumemathmode + \pgfmathresult \else \pgfutilensuremath{\pgfmathresult}% \fi @@ -1519,12 +931,12 @@ % current TeX group. % \ifpgfmathfloatroundmayneedrenormalize will be set globally \def\pgfmathroundto@impl#1{% + \edef\pgfmathround@input{#1}% \global\pgfmathfloatroundmayneedrenormalizefalse \pgfmathfloat@tmptoks={}% \let\pgfmathround@next=\pgfutil@empty \let\pgfmathround@cur=\pgfutil@empty \let\pgfmathresult=\pgfutil@empty - \edef\pgfmathround@input{#1}% \expandafter\c@pgfmathroundto@prec\pgfmathfloat@round@precision\relax \c@pgfmathroundto@lastzeros=0 \c@pgfmathroundto@offsetbehindperiod=-1 % means: no period found so far @@ -1628,14 +1040,14 @@ \fi \else %\ifnum\c@pgfmathroundto@offsetbehindperiod>\c@pgfmathroundto@prec - % \pgfmath@error{Internal logic error in pgfmathroundto at [I] - should not have happened!?}% + % \pgfmath@error{Internal logic error in pgfmathroundto at [I] - should not have happened!?}{}% %\fi \pgfmathroundto@impl@finish@with@truncation \fi \else %\ifnum\c@pgfmathroundto@offsetbehindperiod=\c@pgfmathroundto@prec %\else - % \pgfmath@error{Internal logic error in pgfmathroundto at [II] - should not have happened!? I have offsetbehindperiod=\the\c@pgfmathroundto@offsetbehindperiod and prec = \the\c@pgfmathroundto@prec}% + % \pgfmath@error{Internal logic error in pgfmathroundto at [II] - should not have happened!? I have offsetbehindperiod=\the\c@pgfmathroundto@offsetbehindperiod and prec = \the\c@pgfmathroundto@prec}{}% %\fi \expandafter\ifnum\pgfmathround@next<5\relax \pgfmathroundto@impl@finish@with@truncation @@ -1909,7 +1321,7 @@ \fi \advance\pgfmathfloat@a@E by1 \fi - \edef\pgfmathresult{\the\pgfmathfloat@a@S\pgfmathresult e\the\pgfmathfloat@a@E}% + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\pgfmathresult}{\the\pgfmathfloat@a@E}% } \def\pgfmathfloatround@impl@renormalize#1#2.#3\pgfmathfloat@EOI{% @@ -1924,12 +1336,36 @@ % collects everything into \pgfmathresult \def\pgfmathfloattofixed@impl#1.#2\relax{% \ifnum\pgfmathfloat@a@E<0 - \pgfmathfloat@a@Mtok={0.}% - \pgfutil@loop - \ifnum\pgfmathfloat@a@E<-1 - \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok 0}% - \advance\pgfmathfloat@a@E by1 - \pgfutil@repeat + \ifcase-\pgfmathfloat@a@E + \or%e-1 + \pgfmathfloat@a@Mtok={0.}% + \or%e-2 + \pgfmathfloat@a@Mtok={0.0}% + \or%e-3 + \pgfmathfloat@a@Mtok={0.00}% + \or%e-4 + \pgfmathfloat@a@Mtok={0.000}% + \or%e-5 + \pgfmathfloat@a@Mtok={0.0000}% + \or%e-6 + \pgfmathfloat@a@Mtok={0.00000}% + \or%e-7 + \pgfmathfloat@a@Mtok={0.000000}% + \or%e-8 + \pgfmathfloat@a@Mtok={0.0000000}% + \or%e-9 + \pgfmathfloat@a@Mtok={0.00000000}% + \or%e-10 + \pgfmathfloat@a@Mtok={0.000000000}% + \else%<= -11 + \pgfmathfloat@a@Mtok={0.0000000000}% + \advance\pgfmathfloat@a@E by10 + \pgfutil@loop + \ifnum\pgfmathfloat@a@E<-1 + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok 0}% + \advance\pgfmathfloat@a@E by1 + \pgfutil@repeat + \fi \def\pgfmathfloat@loc@TMPb{#2}% \def\pgfmathfloat@loc@TMPc{0}% \ifx\pgfmathfloat@loc@TMPb\pgfmathfloat@loc@TMPc @@ -1938,15 +1374,48 @@ \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok #1#2}% \fi \else - \ifnum\pgfmathfloat@a@E=0% - \edef\pgfmathresult{#1.#2}% - \else - \pgfmathfloat@a@Mtok={#1}% - \pgfmathfloattofixed@impl@collectmantisse#2\count\pgfmathfloat@a@E - \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok}% - \fi + %-------------------------------------------------- + % \ifnum\pgfmathfloat@a@E=0% + % \edef\pgfmathresult{#1.#2}% + % \else + % \pgfmathfloat@a@Mtok={#1}% + % \pgfmathfloattofixed@impl@collectmantisse#2\count\pgfmathfloat@a@E + % \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok}% + % \fi + %-------------------------------------------------- + \pgfmathfloat@a@Mtok{#1}% + \pgfmathfloattofixed@impl@pos#2000000000\pgfmathfloat@EOI + \edef\pgfmathresult{\the\pgfmathfloat@a@Mtok}% + \fi +} + +% FIXME: this implementation here is very fast, but it introduces trailing zeros. Is that acceptable? +\def\pgfmathfloattofixed@impl@pos#1#2#3#4#5#6#7#8#9\pgfmathfloat@EOI{% + \ifcase\pgfmathfloat@a@E + % e+0 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok .#1#2#3#4#5#6#7#8#9}% + \or%e+1 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1.#2#3#4#5#6#7#8#9}% + \or%e+2 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2.#3#4#5#6#7#8#9}% + \or%e+3 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3.#4#5#6#7#8#9}% + \or%e+4 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4.#5#6#7#8#9}% + \or%e+5 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4#5.#6#7#8#9}% + \or%e+6 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4#5#6.#7#8#9}% + \or%e+7 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4#5#6#7.#8#9}% + \or%e+8 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4#5#6#7#8.#9}% + \else%>=9 + \pgfmathfloat@a@Mtok\expandafter{\the\pgfmathfloat@a@Mtok #1#2#3#4#5#6#7#8}% + \advance\pgfmathfloat@a@E by-8 + \pgfmathfloattofixed@impl@collectmantisse#9\count\pgfmathfloat@a@E \fi -} +}% \def\pgfmathfloattofixed@impl@collectmantisse#1#2\count#3{% \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok #1}% @@ -1977,117 +1446,124 @@ % % ============================================ - % accepted parser tokens: -\def\pgfmathfloatparsenumber@tok@ONE{1} -\def\pgfmathfloatparsenumber@tok@TWO{2} -\def\pgfmathfloatparsenumber@tok@THREE{3} -\def\pgfmathfloatparsenumber@tok@FOUR{4} -\def\pgfmathfloatparsenumber@tok@FIVE{5} -\def\pgfmathfloatparsenumber@tok@SIX{6} -\def\pgfmathfloatparsenumber@tok@SEVEN{7} -\def\pgfmathfloatparsenumber@tok@EIGHT{8} -\def\pgfmathfloatparsenumber@tok@NINE{9} \def\pgfmathfloatparsenumber@tok@ZERO{0} -\def\pgfmathfloatparsenumber@tok@e{e} -\def\pgfmathfloatparsenumber@tok@E{E} \def\pgfmathfloatparsenumber@tok@PLUS{+} \def\pgfmathfloatparsenumber@tok@MINUS{-} -\def\pgfmathfloatparsenumber@tok@n{n} -\def\pgfmathfloatparsenumber@tok@N{N} -\def\pgfmathfloatparsenumber@tok@i{i} -\def\pgfmathfloatparsenumber@tok@I{I} \def\pgfmathfloatparsenumber@tok@PERIOD{.} \newif\ifpgfmathfloatparsenumberpendingperiod +\def\pgfflt@EOI{p@EOI}% + % Starts a finite-start-machine parser to read a number. % +% The machine's state is represented by the macro which is currently +% processed; state transitions are realised using \csname...#1\endcsname +% constructions. +% % It assigns \pgfmathfloat@a@S, \pgfmathfloat@a@Mtok, \pgfmathfloat@a@E. -\def\pgfmathfloatparsenumber@impl#1{% +\def\pgfflt@impl#1{% \pgfmathfloatparsenumberpendingperiodfalse \pgfmathfloat@tmptoks={}% this register is used to collect PENDING ZEROS \pgfmathfloat@a@E=0 % start parsing: check for sign: - \def\pgfmathfloatparsenumber@curtok{#1}% - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@PLUS - \pgfmathfloat@a@S=1\relax% - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@init}% + \expandafter\ifx\csname pgfflt@#1\endcsname\relax + \pgfmathfloat@a@S=1 + \expandafter\pgfflt@init\expandafter#1% \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@MINUS - \pgfmathfloat@a@S=2\relax% - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@init}% - \else - \pgfmathfloat@a@S=1\relax% - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@init#1}% - \fi + \expandafter\expandafter\csname pgfflt@#1\endcsname + \fi +} +% State transitions: +\expandafter\def\csname pgfflt@+\endcsname{% + \pgfmathfloat@a@S=1 % + \pgfflt@init}% +\expandafter\def\csname pgfflt@-\endcsname{% + \pgfmathfloat@a@S=2 % + \pgfflt@init}% +\expandafter\def\csname pgfflt@\pgfflt@EOI\endcsname{% + \pgfmathfloatparsenumber@handleerror{empty number}{}{}}% + +\pgfkeys{ + /pgf/fpu/handlers/empty number/.style 2 args={% + /pgf/fpu/handlers/invalid number={#1}{#2}% + }, + /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'.}{}% + }, +} + +% #1 the error handler +% #2 the number which was invalid. +% #3 the part which produced the error +\def\pgfmathfloatparsenumber@handleerror#1#2#3{% + \let\pgfmathresult=\pgfutil@empty + \pgfmathfloatparsenumberpendingperiodfalse + \pgfkeys{/pgf/fpu/handlers/#1={#2}{#3}}% + \ifx\pgfmathresult\pgfutil@empty + \pgfmathfloat@a@S=3 + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0 + \else + \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E \fi - \pgfmathfloatparsenumber@NEXT } +\def\pgfflt@error#1\pgfflt@EOI{% + \begingroup + \pgfmathfloat@a@Mtok={#1}% + \xdef\pgfmathfloat@glob@TMP{% + \noexpand\pgfmathfloatparsenumber@handleerror + {invalid number}{\pgfmathresult}{\the\pgfmathfloat@a@Mtok}}% + \endgroup + \pgfmathfloat@glob@TMP +}% + -\def\pgfmathfloatparsenumber@sanitize@digit{% - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ONE - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@TWO - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@THREE - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@FOUR - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@FIVE - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@SIX - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@SEVEN - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@EIGHT - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@NINE - \else - \def\pgfmathfloatparsenumber@NEXT{\expandafter\pgfmathfloatparsenumber@impl@error\pgfmathfloatparsenumber@curtok}% - \fi\fi\fi\fi\fi\fi\fi\fi\fi -} % FROM: checksign. % -\def\pgfmathfloatparsenumber@impl@init#1{% - \def\pgfmathfloatparsenumber@curtok{#1}% - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@n - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readnan}% +\def\pgfflt@init#1{% + \expandafter\ifx\csname pgffltA@#1\endcsname\relax + \expandafter\pgfflt@error\expandafter#1% \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@i - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readinf}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ZERO - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@leadingzero}% - \else - \def\pgfmathfloatparsenumber@NEXT{% - \pgfmathfloat@a@Mtok={#1}% - \pgfmathfloatparsenumberpendingperiodtrue - \pgfmathfloatparsenumber@impl@positiveexp}% - \pgfmathfloatparsenumber@sanitize@digit - \fi - \fi - \fi - \pgfmathfloatparsenumber@NEXT -} - -\def\pgfmathfloatparsenumber@impl@error#1\pgfmathfloat@EOI{% - \begingroup + \expandafter\expandafter\csname pgffltA@#1\endcsname + \fi} +% state transitions: +\expandafter\def\csname pgffltA@0\endcsname{\pgfflt@leadingzero}% FIXME: inline optimization! +\expandafter\def\csname pgffltA@1\endcsname{\pgfflt@nonzerodigit1}% +\expandafter\def\csname pgffltA@2\endcsname{\pgfflt@nonzerodigit2}% +\expandafter\def\csname pgffltA@3\endcsname{\pgfflt@nonzerodigit3}% +\expandafter\def\csname pgffltA@4\endcsname{\pgfflt@nonzerodigit4}% +\expandafter\def\csname pgffltA@5\endcsname{\pgfflt@nonzerodigit5}% +\expandafter\def\csname pgffltA@6\endcsname{\pgfflt@nonzerodigit6}% +\expandafter\def\csname pgffltA@7\endcsname{\pgfflt@nonzerodigit7}% +\expandafter\def\csname pgffltA@8\endcsname{\pgfflt@nonzerodigit8}% +\expandafter\def\csname pgffltA@9\endcsname{\pgfflt@nonzerodigit9}% +\def\pgfflt@nonzerodigit#1{% \pgfmathfloat@a@Mtok={#1}% - \pgfmath@error{Could not read input number, sorry. The unreadable part was near '\the\pgfmathfloat@a@Mtok'.}% - \endgroup -}% + \pgfmathfloatparsenumberpendingperiodtrue + \pgfflt@positiveexp}% +\expandafter\def\csname pgffltA@n\endcsname{\pgfflt@readnan}% FIXME: inlining? +\expandafter\def\csname pgffltA@N\endcsname{\pgfflt@readNaN}% FIXME: inlining? +\expandafter\def\csname pgffltA@i\endcsname{\pgfflt@readinf}% FIXME: inlining? +\expandafter\def\csname pgffltA@I\endcsname{\pgfflt@readINF}% FIXME: inlining? -\def\pgfmathfloatparsenumber@impl@finish#1\pgfmathfloat@EOI{} +\def\pgfflt@finish#1\pgfflt@EOI{} -\def\pgfmathfloatparsenumber@impl@readnan an{% +\def\pgfflt@readnan an{% + \pgfmathfloat@a@S=3\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0% + \pgfflt@finish +} +\def\pgfflt@readNaN aN{% \pgfmathfloat@a@S=3\relax% \pgfmathfloat@a@Mtok={0.0}% \pgfmathfloat@a@E=0% - \pgfmathfloatparsenumber@impl@finish + \pgfflt@finish } -\def\pgfmathfloatparsenumber@impl@readinf nf{% +\def\pgfflt@readinf nf{% \ifnum\pgfmathfloat@a@S=1 \pgfmathfloat@a@S=4\relax% \pgfmathfloat@a@Mtok={0.0}% @@ -2096,227 +1572,228 @@ \pgfmathfloat@a@Mtok={0.0}% \fi \pgfmathfloat@a@E=0% - \pgfmathfloatparsenumber@impl@finish + \pgfflt@finish } -\def\pgfmathfloatparsenumber@impl@leadingzero#1{% - \def\pgfmathfloatparsenumber@curtok{#1}% - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ZERO - \def\pgfmathfloatparsenumber@NEXT{% - \pgfmathfloatparsenumber@impl@leadingzero}% +\def\pgfflt@readINF NF{% + \ifnum\pgfmathfloat@a@S=1 + \pgfmathfloat@a@S=4\relax% + \pgfmathfloat@a@Mtok={0.0}% \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@PERIOD - \def\pgfmathfloatparsenumber@NEXT{% - \pgfmathfloat@a@E=-1 - \pgfmathfloatparsenumber@impl@leadingzero@foundperiod}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@e - \def\pgfmathfloatparsenumber@NEXT{% - \pgfmathfloat@a@S=0\relax% - \pgfmathfloat@a@Mtok={0.0}% - \pgfmathfloat@a@E=0% - \pgfmathfloatparsenumber@impl@readexponent}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@E - \def\pgfmathfloatparsenumber@NEXT{% - \pgfmathfloat@a@S=0\relax% - \pgfmathfloat@a@Mtok={0.0}% - \pgfmathfloat@a@E=0% - \pgfmathfloatparsenumber@impl@readexponent}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloat@EOI - \def\pgfmathfloatparsenumber@NEXT{% - \pgfmathfloat@a@S=0\relax% - \pgfmathfloat@a@Mtok={0.0}% - \pgfmathfloat@a@E=0% - }% - \else - \def\pgfmathfloatparsenumber@NEXT{% - \pgfmathfloat@a@Mtok={#1}% - \pgfmathfloatparsenumberpendingperiodtrue - \pgfmathfloatparsenumber@impl@positiveexp}% - \pgfmathfloatparsenumber@sanitize@digit - \fi\fi\fi - \fi + \pgfmathfloat@a@S=5\relax% + \pgfmathfloat@a@Mtok={0.0}% \fi - \pgfmathfloatparsenumber@NEXT + \pgfmathfloat@a@E=0% + \pgfflt@finish } +\def\pgfflt@leadingzero#1{% + \expandafter\ifx\csname pgffltB@#1\endcsname\relax + \expandafter\pgfflt@error\expandafter#1% + \else + \expandafter\expandafter\csname pgffltB@#1\endcsname + \fi} +% State transitions: +\expandafter\def\csname pgffltB@0\endcsname{\pgfflt@leadingzero}% +\expandafter\def\csname pgffltB@1\endcsname{\pgfmathfloat@a@Mtok={1}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@2\endcsname{\pgfmathfloat@a@Mtok={2}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@3\endcsname{\pgfmathfloat@a@Mtok={3}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@4\endcsname{\pgfmathfloat@a@Mtok={4}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@5\endcsname{\pgfmathfloat@a@Mtok={5}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@6\endcsname{\pgfmathfloat@a@Mtok={6}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@7\endcsname{\pgfmathfloat@a@Mtok={7}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@8\endcsname{\pgfmathfloat@a@Mtok={8}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@9\endcsname{\pgfmathfloat@a@Mtok={9}\pgfmathfloatparsenumberpendingperiodtrue \pgfflt@positiveexp} +\expandafter\def\csname pgffltB@\pgfmathfloat@POSTFLAGSCHAR\endcsname{\pgfmathfloat@a@Mtok={0}\pgfflt@readlowlevelfloat}% +\expandafter\def\csname pgffltB@.\endcsname{% + \pgfmathfloat@a@E=-1 + \pgfflt@leadingzero@foundperiod}% +\expandafter\def\csname pgffltB@e\endcsname{% + \pgfmathfloat@a@S=0\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0% + \pgfflt@readexponent}% +\let\pgffltB@E=\pgffltB@e +\expandafter\def\csname pgffltB@\pgfflt@EOI\endcsname{% + \pgfmathfloat@a@S=0\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0}% -\def\pgfmathfloatparsenumber@impl@leadingzero@foundperiod#1{% - \def\pgfmathfloatparsenumber@curtok{#1}% - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ZERO - \def\pgfmathfloatparsenumber@NEXT{% - \advance\pgfmathfloat@a@E by-1 - \pgfmathfloatparsenumber@impl@leadingzero@foundperiod}% +\def\pgfflt@leadingzero@foundperiod#1{% + \expandafter\ifx\csname pgffltC@#1\endcsname\relax + \expandafter\pgfflt@error\expandafter#1% \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@e - \def\pgfmathfloatparsenumber@NEXT{% - \pgfmathfloat@a@S=0\relax% - \pgfmathfloat@a@Mtok={0.0}% - \pgfmathfloat@a@E=0% - \pgfmathfloatparsenumber@impl@readexponent}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@E - \def\pgfmathfloatparsenumber@NEXT{% - \pgfmathfloat@a@S=0\relax% - \pgfmathfloat@a@Mtok={0.0}% - \pgfmathfloat@a@E=0% - \pgfmathfloatparsenumber@impl@readexponent}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloat@EOI - \def\pgfmathfloatparsenumber@NEXT{% - \pgfmathfloat@a@S=0\relax% - \pgfmathfloat@a@Mtok={0.0}% - \pgfmathfloat@a@E=0% - }% - \else - \def\pgfmathfloatparsenumber@NEXT{% - \pgfmathfloat@a@Mtok={#1}% - \pgfmathfloatparsenumberpendingperiodtrue - \pgfmathfloatparsenumber@impl@finish@number@after@period}% - \pgfmathfloatparsenumber@sanitize@digit - \fi\fi\fi - \fi - \pgfmathfloatparsenumber@NEXT -} + \expandafter\expandafter\csname pgffltC@#1\endcsname + \fi} +% State transitions: +\expandafter\def\csname pgffltC@0\endcsname{% + \advance\pgfmathfloat@a@E by-1 + \pgfflt@leadingzero@foundperiod}% +\expandafter\def\csname pgffltC@1\endcsname{\pgfmathfloat@a@Mtok={1}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@2\endcsname{\pgfmathfloat@a@Mtok={2}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@3\endcsname{\pgfmathfloat@a@Mtok={3}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@4\endcsname{\pgfmathfloat@a@Mtok={4}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@5\endcsname{\pgfmathfloat@a@Mtok={5}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@6\endcsname{\pgfmathfloat@a@Mtok={6}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@7\endcsname{\pgfmathfloat@a@Mtok={7}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@8\endcsname{\pgfmathfloat@a@Mtok={8}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@9\endcsname{\pgfmathfloat@a@Mtok={9}\pgfmathfloatparsenumberpendingperiodtrue\pgfflt@finish@number@after@period}% +\expandafter\def\csname pgffltC@e\endcsname{% + \pgfmathfloat@a@S=0\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0% + \pgfflt@readexponent}% +\let\pgffltC@E=\pgffltC@e +\expandafter\def\csname pgffltC@\pgfflt@EOI\endcsname{% + \pgfmathfloat@a@S=0\relax% + \pgfmathfloat@a@Mtok={0.0}% + \pgfmathfloat@a@E=0}% -\def\pgfmathfloatparsenumber@impl@positiveexp#1{% - \def\pgfmathfloatparsenumber@curtok{#1}% - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ZERO - \def\pgfmathfloatparsenumber@NEXT{% - \advance\pgfmathfloat@a@E by1 - \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% - \pgfmathfloatparsenumber@impl@pendingzeros@positiveexp}% +\def\pgfflt@positiveexp#1{% + \expandafter\ifx\csname pgffltD@#1\endcsname\relax + \expandafter\pgfflt@error\expandafter#1% \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@PERIOD - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@finish@number@after@period}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@e - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@E - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloat@EOI - \def\pgfmathfloatparsenumber@NEXT{}% - \else - \def\pgfmathfloatparsenumber@NEXT{% - \advance\pgfmathfloat@a@E by1 - \ifpgfmathfloatparsenumberpendingperiod - \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% - \pgfmathfloatparsenumberpendingperiodfalse - \fi - \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% - \pgfmathfloatparsenumber@impl@positiveexp}% - \pgfmathfloatparsenumber@sanitize@digit - \fi\fi\fi - \fi + \expandafter\expandafter\csname pgffltD@#1\endcsname + \fi} +% State transitions: +\expandafter\def\csname pgffltD@0\endcsname{% + \advance\pgfmathfloat@a@E by1 + \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% + \pgfflt@pendingzeros@positiveexp}% +\expandafter\def\csname pgffltD@1\endcsname{\pgffltD@nonzerodigit1}% +\expandafter\def\csname pgffltD@2\endcsname{\pgffltD@nonzerodigit2}% +\expandafter\def\csname pgffltD@3\endcsname{\pgffltD@nonzerodigit3}% +\expandafter\def\csname pgffltD@4\endcsname{\pgffltD@nonzerodigit4}% +\expandafter\def\csname pgffltD@5\endcsname{\pgffltD@nonzerodigit5}% +\expandafter\def\csname pgffltD@6\endcsname{\pgffltD@nonzerodigit6}% +\expandafter\def\csname pgffltD@7\endcsname{\pgffltD@nonzerodigit7}% +\expandafter\def\csname pgffltD@8\endcsname{\pgffltD@nonzerodigit8}% +\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@e\endcsname{\pgfflt@readexponent}% FIXME : inlining? +\let\pgffltD@E=\pgffltD@e +\expandafter\def\csname pgffltD@\pgfflt@EOI\endcsname{}% NOP +\def\pgffltD@nonzerodigit#1{% + \advance\pgfmathfloat@a@E by1 + \ifpgfmathfloatparsenumberpendingperiod + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% + \pgfmathfloatparsenumberpendingperiodfalse \fi - \pgfmathfloatparsenumber@NEXT -} + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% + \pgfflt@positiveexp}% -\def\pgfmathfloatparsenumber@impl@readexponent#1\pgfmathfloat@EOI{% +% Read a low-level floating point. +% Since we are in the second state, \pgfmathfloat@a@Mtok contains the +% FLAGS. The post-flags-char has also been read. +\def\pgfflt@readlowlevelfloat#1e#2]\pgfflt@EOI{% + \pgfmathfloatparsenumberpendingperiodfalse + \pgfmathfloat@a@S=\the\pgfmathfloat@a@Mtok\relax + \pgfmathfloat@a@Mtok={#1}% + \pgfmathfloat@a@E=#2 +}% + +\def\pgfflt@readexponent#1\pgfflt@EOI{% \advance\pgfmathfloat@a@E by#1\relax } -\def\pgfmathfloatparsenumber@impl@pendingzeros@positiveexp#1{% - \def\pgfmathfloatparsenumber@curtok{#1}% - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ZERO - \def\pgfmathfloatparsenumber@NEXT{% - \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% - \advance\pgfmathfloat@a@E by1 - \pgfmathfloatparsenumber@impl@pendingzeros@positiveexp}% +\def\pgfflt@pendingzeros@positiveexp#1{% + \expandafter\ifx\csname pgffltE@#1\endcsname\relax + \expandafter\pgfflt@error\expandafter#1% \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@PERIOD - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@finish@number@after@period}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@e - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@E - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloat@EOI - \def\pgfmathfloatparsenumber@NEXT{}% - \else - \def\pgfmathfloatparsenumber@NEXT{% - \advance\pgfmathfloat@a@E by1 - \ifpgfmathfloatparsenumberpendingperiod - \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% - \pgfmathfloatparsenumberpendingperiodfalse - \fi - \pgfmathfloat@a@Mtok=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfmathfloat@a@Mtok\the\pgfmathfloat@tmptoks}% - \pgfmathfloat@tmptoks={}% - \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% - \pgfmathfloatparsenumber@impl@positiveexp}% - \pgfmathfloatparsenumber@sanitize@digit - \fi\fi\fi - \fi + \expandafter\expandafter\csname pgffltE@#1\endcsname + \fi} +% State transitions: +\expandafter\def\csname pgffltE@0\endcsname{% + \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% + \advance\pgfmathfloat@a@E by1 + \pgfflt@pendingzeros@positiveexp}% +\expandafter\def\csname pgffltE@1\endcsname{\pgffltE@nonzerodigit1}% +\expandafter\def\csname pgffltE@2\endcsname{\pgffltE@nonzerodigit2}% +\expandafter\def\csname pgffltE@3\endcsname{\pgffltE@nonzerodigit3}% +\expandafter\def\csname pgffltE@4\endcsname{\pgffltE@nonzerodigit4}% +\expandafter\def\csname pgffltE@5\endcsname{\pgffltE@nonzerodigit5}% +\expandafter\def\csname pgffltE@6\endcsname{\pgffltE@nonzerodigit6}% +\expandafter\def\csname pgffltE@7\endcsname{\pgffltE@nonzerodigit7}% +\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? +\def\pgffltE@e{\pgfflt@readexponent}% FIXME : inlining? +\let\pgffltE@E=\pgffltE@e +\expandafter\def\csname pgffltE@\pgfflt@EOI\endcsname{}% NOP +\def\pgffltE@nonzerodigit#1{% + \advance\pgfmathfloat@a@E by1 + \ifpgfmathfloatparsenumberpendingperiod + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% + \pgfmathfloatparsenumberpendingperiodfalse \fi - \pgfmathfloatparsenumber@NEXT -} + \pgfmathfloat@a@Mtok=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfmathfloat@a@Mtok\the\pgfmathfloat@tmptoks}% + \pgfmathfloat@tmptoks={}% + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% + \pgfflt@positiveexp}% -\def\pgfmathfloatparsenumber@impl@finish@number@after@period#1{% - \def\pgfmathfloatparsenumber@curtok{#1}% - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ZERO - \def\pgfmathfloatparsenumber@NEXT{% - \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% - \pgfmathfloatparsenumber@impl@pendingzeros}% +\def\pgfflt@finish@number@after@period#1{% + \expandafter\ifx\csname pgffltF@#1\endcsname\relax + \expandafter\pgfflt@error\expandafter#1% \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@e - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@E - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloat@EOI - \def\pgfmathfloatparsenumber@NEXT{}% - \else - \def\pgfmathfloatparsenumber@NEXT{% - \ifpgfmathfloatparsenumberpendingperiod - \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% - \pgfmathfloatparsenumberpendingperiodfalse - \fi - \pgfmathfloat@a@Mtok=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfmathfloat@a@Mtok\the\pgfmathfloat@tmptoks}% - \pgfmathfloat@tmptoks={}% - \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% - \pgfmathfloatparsenumber@impl@finish@number@after@period}% - \pgfmathfloatparsenumber@sanitize@digit - \fi\fi\fi + \expandafter\expandafter\csname pgffltF@#1\endcsname + \fi} +% State transitions: +\expandafter\def\csname pgffltF@0\endcsname{% + \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% + \pgfflt@pendingzeros}% +\expandafter\def\csname pgffltF@1\endcsname{\pgffltF@nonzerodigit1}% +\expandafter\def\csname pgffltF@2\endcsname{\pgffltF@nonzerodigit2}% +\expandafter\def\csname pgffltF@3\endcsname{\pgffltF@nonzerodigit3}% +\expandafter\def\csname pgffltF@4\endcsname{\pgffltF@nonzerodigit4}% +\expandafter\def\csname pgffltF@5\endcsname{\pgffltF@nonzerodigit5}% +\expandafter\def\csname pgffltF@6\endcsname{\pgffltF@nonzerodigit6}% +\expandafter\def\csname pgffltF@7\endcsname{\pgffltF@nonzerodigit7}% +\expandafter\def\csname pgffltF@8\endcsname{\pgffltF@nonzerodigit8}% +\expandafter\def\csname pgffltF@9\endcsname{\pgffltF@nonzerodigit9}% +\def\pgffltF@e{\pgfflt@readexponent}% +\let\pgffltF@E=\pgffltF@e +\expandafter\def\csname pgffltF@\pgfflt@EOI\endcsname{}% NOP +\def\pgffltF@nonzerodigit#1{% + \ifpgfmathfloatparsenumberpendingperiod + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% + \pgfmathfloatparsenumberpendingperiodfalse \fi - \pgfmathfloatparsenumber@NEXT -} + \pgfmathfloat@a@Mtok=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfmathfloat@a@Mtok\the\pgfmathfloat@tmptoks}% + \pgfmathfloat@tmptoks={}% + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% + \pgfflt@finish@number@after@period}% -\def\pgfmathfloatparsenumber@impl@pendingzeros#1{% - \def\pgfmathfloatparsenumber@curtok{#1}% - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@ZERO - \def\pgfmathfloatparsenumber@NEXT{% - \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% - \pgfmathfloatparsenumber@impl@pendingzeros}% + +\def\pgfflt@pendingzeros#1{% + \expandafter\ifx\csname pgffltG@#1\endcsname\relax + \expandafter\pgfflt@error\expandafter#1% \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@e - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloatparsenumber@tok@E - \def\pgfmathfloatparsenumber@NEXT{\pgfmathfloatparsenumber@impl@readexponent}% - \else - \ifx\pgfmathfloatparsenumber@curtok\pgfmathfloat@EOI - \def\pgfmathfloatparsenumber@NEXT{}% - \else - \def\pgfmathfloatparsenumber@NEXT{% - \ifpgfmathfloatparsenumberpendingperiod - \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% - \pgfmathfloatparsenumberpendingperiodfalse - \fi - \pgfmathfloat@a@Mtok=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfmathfloat@a@Mtok\the\pgfmathfloat@tmptoks}% - \pgfmathfloat@tmptoks={}% - \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% - \pgfmathfloatparsenumber@impl@finish@number@after@period}% - \pgfmathfloatparsenumber@sanitize@digit - \fi\fi\fi + \expandafter\expandafter\csname pgffltG@#1\endcsname + \fi} +% State transitions: +\expandafter\def\csname pgffltG@0\endcsname{% + \pgfmathfloat@tmptoks=\expandafter{\the\pgfmathfloat@tmptoks0}% + \pgfflt@pendingzeros}% +\expandafter\def\csname pgffltG@1\endcsname{\pgffltG@nonzerodigit1}% +\expandafter\def\csname pgffltG@2\endcsname{\pgffltG@nonzerodigit2}% +\expandafter\def\csname pgffltG@3\endcsname{\pgffltG@nonzerodigit3}% +\expandafter\def\csname pgffltG@4\endcsname{\pgffltG@nonzerodigit4}% +\expandafter\def\csname pgffltG@5\endcsname{\pgffltG@nonzerodigit5}% +\expandafter\def\csname pgffltG@6\endcsname{\pgffltG@nonzerodigit6}% +\expandafter\def\csname pgffltG@7\endcsname{\pgffltG@nonzerodigit7}% +\expandafter\def\csname pgffltG@8\endcsname{\pgffltG@nonzerodigit8}% +\expandafter\def\csname pgffltG@9\endcsname{\pgffltG@nonzerodigit9}% +\def\pgffltG@e{\pgfflt@readexponent}% FIXME: inlining? +\let\pgffltG@E=\pgffltG@e +\expandafter\def\csname pgffltG@\pgfflt@EOI\endcsname{}% NOP +\def\pgffltG@nonzerodigit#1{% + \ifpgfmathfloatparsenumberpendingperiod + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok.}% + \pgfmathfloatparsenumberpendingperiodfalse \fi - \pgfmathfloatparsenumber@NEXT -} - - + \pgfmathfloat@a@Mtok=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\pgfmathfloat@a@Mtok\the\pgfmathfloat@tmptoks}% + \pgfmathfloat@tmptoks={}% + \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}% + \pgfflt@finish@number@after@period}% +\endinput |