Debian Codegraph @

texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgflibraryfpu.code.tex

raw
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %%% This file is a copy of some part of PGF/Tikz.
3 %%% It has been copied here to provide :
4 %%% - compatibility with older PGF versions
5 %%% - availability of PGF contributions by Christian Feuersaenger
6 %%% which are necessary or helpful for pgfplots.
7 %%%
8 %%% For reasons of simplicity, I have copied the whole file, including own contributions AND
9 %%% PGF parts. The copyrights are as they appear in PGF.
10 %%%
11 %%% Note that pgfplots has compatible licenses.
12 %%%
13 %%% This copy has been modified in the following ways:
14 %%% - nested \input commands have been updated
15 %%%
16 %
17 % Support for the contents of this file will NOT be done by the PGF/TikZ team.
18 % Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
19 % with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
20 % This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22 %%% Date of this copy: Mo 30. Apr 17:24:35 CEST 2018 %%%
23
24
25
26 % Copyright 2008/2009 by Christian Feuersaenger
27 %
28 % This file may be distributed and/or modified
29 %
30 % 1. under the LaTeX Project Public License and/or
31 % 2. under the GNU General Public License.
32 %
33 % See the file doc/generic/pgf/licenses/LICENSE for more details.
34
35 \newif\ifpgfmathfloatparseactive
36 \newif\ifpgfmathfloat@scaleactive
37
38 % public macro which invokes '#1' if the fpu is installed and ready and '#2'
39 % otherwise.
40 \def\pgflibraryfpuifactive#1#2{%
41 \ifpgfmathfloatparseactive
42 #1%
43 \else
44 #2%
45 \fi
46 }%
47
48 \pgfqkeys{/pgf}{
49 % enable the FPU parser if it is not yet active
50 %
51 % It will be deactivated after the current TeX group
52 fpu/.is choice,
53 fpu/true/.code={%
54 \ifpgfmathfloatparseactive
55 \else
56 \pgfutil@ifundefined{pgfmathdeclarefunction}{%
57 % Ohoh - we are running on a TeX distribution with
58 % PGF 2.00 which doesn't have the new math engine.
59 % I can provide special treatment here, provided that
60 % all float commands are still able to run (that means
61 % more information needs to be copied from the pgf cvs
62 % to pgf 2.00 - for example pgfmathfloat.code.tex).
63 %
64 % I employ this to work with pgfplots and pgf 2.00
65 % using all new features.
66 \pgfmathfloat@parser@install@pgf@two@null@null%
67 }{%
68 \pgfmathfloat@parser@install%
69 }%
70 \pgfmathfloatparseactivetrue
71 % improve compatibility with Marks FP library:
72 \pgfkeysalso{/pgf/fixed point arithmetic/.prefix style={/pgf/fpu=false}}%
73 \fi
74 },%
75 fpu/false/.code={%
76 \ifpgfmathfloatparseactive
77 \pgfmathfloat@uninstall%
78 \pgfmathfloatparseactivefalse
79 \fi
80 },%
81 fpu/.default=true,
82 % Use this to introduce a result scaling.
83 % Every expression in which the prefix '*' occurs
84 % will be multiplied with the result and converted to fixed point
85 % representation.
86 fpu/scale results/.code={%
87 \ifpgfmathfloatparseactive
88 \pgfmathparse{#1}%
89 \else
90 \pgfmathfloatparsenumber{#1}%
91 \fi
92 \let\pgfmathfloatscale=\pgfmathresult%
93 },%
94 % determines the output format of each complete expression parsing
95 % process. If 'scale results' is active, 'fixed' is assumed
96 % automatically.
97 fpu/output format/.is choice,
98 fpu/output format/float/.code= {%
99 \def\pgfmathfloatparse@output@choice{Y}%
100 \let\pgfmathfloatparse@output=\relax
101 },
102 fpu/output format/sci/.code= {%
103 \def\pgfmathfloatparse@output@choice{S}%
104 \def\pgfmathfloatparse@output{\pgfmathfloattosci@{\pgfmathresult}}%
105 },
106 fpu/output format/fixed/.code= {%
107 \def\pgfmathfloatparse@output@choice{F}%
108 \def\pgfmathfloatparse@output{\pgfmathfloattofixed@{\pgfmathresult}}%
109 },
110 fpu/output format/float,
111 fpu/rel thresh/.code={%
112 \pgfmathfloatparsenumber{#1}%
113 \let\pgfmathfloat@relthresh=\pgfmathresult
114 },
115 fpu/rel thresh=1e-4,
116 }
117
118 \pgfmathfloatcreate{1}{1.0}{0}\let\pgfmathfloatscale=\pgfmathresult
119
120 \let\pgfmathfloatone=\pgfmathresult
121
122 % This is the replacement parser invocation.
123 % It does two things which are different to \pgfmathparse:
124 % 1. it disables any dimension dependand scalings,
125 % 2. it implements the 'scale results' feature.
126 \def\pgfmathfloatparse{%
127 \begingroup%
128 % disable any dimension-dependant scalings:
129 \let\pgfmathpostparse=\relax%
130 \pgfmath@catcodes%
131 \pgfmath@quickparsefalse%
132 \pgfmathfloatparse@}
133
134 % for pgf 2.00 :
135 \def\pgfmathfloatparse@pgf@two@null@null{%
136 \pgfmath@quickparsefalse%
137 \pgfmathfloatparse@}
138
139 \def\pgfmathfloatparse@#1{%
140 \edef\pgfmathfloat@expression{#1}%
141 \expandafter\pgfmathfloatparse@@\pgfmathfloat@expression\pgfmathfloat@
142 \ifpgfmathfloat@scaleactive
143 \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfmathfloatscale}
144 \pgfmathfloattofixed{\pgfmathresult}%
145 \else
146 \pgfmathfloatparse@output
147 \fi
148 }
149
150 \def\pgfmathfloat@char@asterisk{*}
151 \def\pgfmathfloatparse@@#1#2\pgfmathfloat@{%
152 \def\pgfmathfloat@test{#1}%
153 \ifx\pgfmathfloat@test\pgfmathfloat@char@asterisk%
154 \def\pgfmathfloat@expression{#2}%
155 \pgfmathfloat@scaleactivetrue
156 \fi%
157 \expandafter\pgfmathparse@\expandafter{\pgfmathfloat@expression}%
158 % \endgroup provided by \pgfpathmarse@end
159 }
160
161 % Crude handling of file plots
162 %
163 \pgfkeys{/pgf/fpu/.cd,
164 scale file plot x/.code=\pgfmathfloatparse{#1}\edef\pgfmathfloatplotscalex{\pgfmathresult*},
165 scale file plot y/.code=\pgfmathfloatparse{#1}\edef\pgfmathfloatplotscaley{\pgfmathresult*},
166 scale file plot z/.code=\pgfmathfloatparse{#1}\edef\pgfmathfloatplotscalez{\pgfmathresult*}
167 }
168
169 \def\pgfmathfloat@uninstall@appendcmd#1{%
170 \expandafter\gdef\expandafter\pgfmathfloat@uninstall\expandafter{\pgfmathfloat@uninstall #1}%
171 }%
172
173 % If the uninstall command is already assembled, it will skip the
174 % uninstall assemblation.
175 \def\pgfmathfloat@plots@checkuninstallcmd{%
176 \pgfutil@ifundefined{pgfmathfloat@uninstall}{%
177 \global\let\pgfmathfloat@uninstall=\pgfutil@empty
178 }{%
179 % We already HAVE an uninstall command (prepared globally).
180 % So: don't waste time assembling one!
181 \def\pgfmathfloat@uninstall@appendcmd##1{}%
182 \def\pgfmathfloat@prepareuninstallcmd##1{}%
183 }%
184 }%
185
186 % This assembles an uninstall command globally ON FIRST USAGE.
187 % See \pgfmathfloat@plots@checkuninstallcmd
188 \def\pgfmathfloat@prepareuninstallcmd#1{%
189 % and store backup information (globally - I don't want to do that
190 % all the time when the FPU is used!):
191 \expandafter\global\expandafter\let\csname pgfmathfloat@backup@\string#1\endcsname=#1%
192 \expandafter\gdef\expandafter\pgfmathfloat@uninstall\expandafter{\pgfmathfloat@uninstall
193 \expandafter\let\expandafter#1\csname pgfmathfloat@backup@\string#1\endcsname%
194 }%
195 }
196
197 \def\pgfmathfloat@install#1=#2{%
198 \pgfmathfloat@prepareuninstallcmd{#1}%
199 \let#1=#2%
200 }
201 \def\pgfmathfloat@install@csname#1#2{%
202 \expandafter\pgfmathfloat@prepareuninstallcmd\csname #1\endcsname%
203 \pgfutil@namelet{#1}{#2}%
204 }
205 \def\pgfmathfloat@install@unimplemented#1{%
206 \expandafter\pgfmathfloat@prepareuninstallcmd\csname pgfmath#1@\endcsname%
207 \expandafter\def\csname pgfmath#1@\endcsname##1{\pgfmathfloat@notimplemented{#1}}%
208 }
209 \def\pgfmathfloat@plots@install{%
210 \let\pgfmathfloatplotscalex=\pgfutil@empty
211 \let\pgfmathfloatplotscaley=\pgfutil@empty
212 \let\pgfmathfloatplotscalez=\pgfutil@empty
213 \pgfmathfloat@install\pgf@parsexyline=\pgfmathfloat@parsexyline%
214 \pgfmathfloat@install\pgf@parsexyzline=\pgfmathfloat@parsexyzline%
215 }
216 \def\pgfmathfloat@parsexyline#1 #2 #3\pgf@stop{%
217 \edef\pgfmathfloat@marshal{%
218 \noexpand\pgfplotstreampoint{\noexpand\pgfpointxy{\pgfmathfloatplotscalex#1}{\pgfmathfloatplotscaley#2}}%
219 }%
220 \pgfmathfloat@marshal%
221 }
222 \def\pgfmathfloat@parsexyzline#1 #2 #3 #4\pgf@stop{%
223 \edef\pgfmathfloat@marshal{%
224 \noexpand\pgfplotstreampoint{%
225 \noexpand\pgfpointxyz{\pgfmathfloatplotscalex#1}{\pgfmathfloatplotscaley#2}{\pgfmathfloatplotscalez#3}%
226 }%
227 }%
228 \pgfmathfloat@marshal%
229 }
230
231 %
232 \def\pgfmathfloat@parser@install@functions{%
233 % Install float commands...
234 %
235 \pgfmathfloat@install\pgfmathadd@=\pgfmathfloatadd@%
236 \pgfmathfloat@install\pgfmathsubtract@=\pgfmathfloatsubtract@%
237 \pgfmathfloat@install\pgfmathneg@=\pgfmathfloatneg@%
238 \pgfmathfloat@install\pgfmathmultiply@=\pgfmathfloatmultiply@%
239 \pgfmathfloat@install\pgfmathdivide@=\pgfmathfloatdivide@%
240 \pgfmathfloat@install\pgfmathabs@=\pgfmathfloatabs@%
241 \pgfmathfloat@install\pgfmathsign@=\pgfmathfloatsign@%
242 \pgfmathfloat@install\pgfmathround@=\pgfmathfloatround@%
243 \pgfmathfloat@install\pgfmathfloor@=\pgfmathfloatfloor@%
244 \pgfmathfloat@install\pgfmathceil@=\pgfmathfloatceil@
245 \pgfmathfloat@install\pgfmathint@=\pgfmathfloatint@
246 \pgfmathfloat@install\pgfmathmod@=\pgfmathfloatmod@%
247 \pgfmathfloat@install\pgfmathmax@=\pgfmathfloatmax@%
248 \pgfmathfloat@install\pgfmathmin@=\pgfmathfloatmin@%
249 \pgfmathfloat@install\pgfmathsin@=\pgfmathfloatsin@%
250 \pgfmathfloat@install\pgfmathcos@=\pgfmathfloatcos@%
251 \pgfmathfloat@install\pgfmathtan@=\pgfmathfloattan@%
252 \pgfmathfloat@install\pgfmathdeg@=\pgfmathfloatdeg@%
253 \pgfmathfloat@install\pgfmathrad@=\pgfmathfloatrad@%
254 \pgfmathfloat@install\pgfmathatan@=\pgfmathfloatatan@%
255 \pgfmathfloat@install\pgfmathasin@=\pgfmathfloatasin@%
256 \pgfmathfloat@install\pgfmathacos@=\pgfmathfloatacos@%
257 \pgfmathfloat@install\pgfmathcot@=\pgfmathfloatcot@%
258 \pgfmathfloat@install\pgfmathsec@=\pgfmathfloatsec@%
259 \pgfmathfloat@install\pgfmathcosec@=\pgfmathfloatcosec@%
260 \pgfmathfloat@install\pgfmathexp@=\pgfmathfloatexp@%
261 \pgfmathfloat@install\pgfmathln@=\pgfmathfloatln@%
262 \pgfmathfloat@install@csname{pgfmathlog10@}{pgfmathfloatlog10@}%
263 \pgfmathfloat@install@csname{pgfmathlog2@}{pgfmathfloatlog2@}%
264 \pgfmathfloat@install\pgfmathsqrt@=\pgfmathfloatsqrt@%
265 \pgfmathfloat@install\pgfmath@pi=\pgfmathfloatpi@%
266 \pgfmathfloat@install\pgfmathpi=\pgfmathfloatpi@%
267 \pgfmathfloat@install\pgfmathe@=\pgfmathfloate@%
268 \pgfmathfloat@install\pgfmathe=\pgfmathfloate@%
269 \pgfmathfloat@install\pgfmathlessthan@=\pgfmathfloatlessthan@%
270 \pgfmathfloat@install\pgfmathnotless@=\pgfmathfloatnotless@%
271 \pgfmathfloat@install\pgfmathnotgreater@=\pgfmathfloatnotgreater@%
272 \pgfmathfloat@install\pgfmathless@=\pgfmathfloatlessthan@%
273 \pgfmathfloat@install\pgfmathgreaterthan@=\pgfmathfloatgreaterthan@%
274 \pgfmathfloat@install\pgfmathgreater@=\pgfmathfloatgreaterthan@%
275 \pgfmathfloat@install\pgfmathifthenelse@=\pgfmathfloatifthenelse@%
276 \pgfmathfloat@install\pgfmathequal@=\pgfmathfloatequal@%
277 \pgfmathfloat@install\pgfmathequalto@=\pgfmathfloatequal@%
278 \pgfmathfloat@install\pgfmathnotequal@=\pgfmathfloatnotequal@%
279 \pgfmathfloat@install\pgfmathnotequalto@=\pgfmathfloatnotequal@%
280 \pgfmathfloat@install\pgfmathpow@=\pgfmathfloatpow@
281 \pgfmathfloat@install\pgfmathrand@=\pgfmathfloatrand@
282 \pgfmathfloat@install\pgfmathrand=\pgfmathfloatrand@
283 \pgfmathfloat@install\pgfmathrnd@=\pgfmathfloatrnd@
284 \pgfmathfloat@install\pgfmathrnd=\pgfmathfloatrnd@
285 \pgfmathfloat@install\pgfmathtrue@=\pgfmathfloattrue@
286 \pgfmathfloat@install\pgfmathfalse@=\pgfmathfloatfalse@
287 \pgfmathfloat@install\pgfmathnot@=\pgfmathfloatnot@
288 \pgfmathfloat@install\pgfmathhex@=\pgfmathfloathex@
289 \pgfmathfloat@install\pgfmathHex@=\pgfmathfloatHex@
290 \pgfmathfloat@install\pgfmathoct@=\pgfmathfloatoct@
291 \pgfmathfloat@install\pgfmathbin@=\pgfmathfloatbin@
292 \pgfmathfloat@install\pgfmathand@=\pgfmathfloatand@
293 \pgfmathfloat@install\pgfmathor@=\pgfmathfloator@
294 \pgfmathfloat@install\pgfmathfactorial@=\pgfmathfloatfactorial@
295 \pgfmathfloat@install\pgfmathveclen@=\pgfmathfloatveclen@
296 \pgfmathfloat@install\pgfmathcosh@=\pgfmathfloatcosh@
297 \pgfmathfloat@install\pgfmathsinh@=\pgfmathfloatsinh@
298 \pgfmathfloat@install\pgfmathtanh@=\pgfmathfloattanh@
299 \pgfmathfloat@install\pgfmath@iftrue=\pgfmathfloat@iftrue
300 \expandafter\pgfmathfloat@install\csname pgfmathatan2@\endcsname=\pgfmathfloatatantwo@
301 \pgfmathfloat@install@unimplemented{isprime}%
302 \pgfmathfloat@install@unimplemented{iseven}%
303 \pgfmathfloat@install@unimplemented{isodd}%
304 \pgfmathfloat@install@unimplemented{gcd}%
305 \pgfmathfloat@install@unimplemented{frac}%
306 \pgfmathfloat@install@unimplemented{random}%
307 \pgfmathfloat@install@unimplemented{setseed}%
308 \pgfmathfloat@install@unimplemented{Mod}%
309 \pgfmathfloat@install@unimplemented{div}%
310 \pgfmathfloat@install@unimplemented{real}%
311 % \pgfmathfloat@install@unimplemented{height}%
312 %
313 %
314 \pgfmathfloat@install\pgfmathscientific=\pgfmathfloatscientific%
315 }
316
317 \def\pgfmathfloat@iftrue{%
318 \if Y\pgfmathfloatparse@output@choice
319 \let\pgfmathfloat@@iftrue@v=\pgfmathfloatone
320 \let\pgfmathfloat@@iftrue@next=\pgfmathfloat@iftrue@
321 \else
322 \if S\pgfmathfloatparse@output@choice
323 \def\pgfmathfloat@@iftrue@v{1.0e0}%
324 \let\pgfmathfloat@@iftrue@next=\pgfmathfloat@iftrue@
325 \else
326 \def\pgfmath@next{\pgfutilifstartswith{1.0}}%
327 \expandafter\pgfmath@next\expandafter{\pgfmathresult}{%
328 \ifdim\pgfmathresult pt=1.0pt %
329 \let\pgfmathfloat@@iftrue@next=\pgfutil@firstoftwo
330 \else
331 \let\pgfmathfloat@@iftrue@next=\pgfutil@secondoftwo
332 \fi
333 }{%
334 \let\pgfmathfloat@@iftrue@next=\pgfutil@secondoftwo
335 }%
336 \fi
337 \fi
338 \pgfmathfloat@@iftrue@next
339 }%
340 \def\pgfmathfloat@iftrue@{%
341 \ifx\pgfmathresult\pgfmathfloat@@iftrue@v
342 \let\pgfmath@next=\pgfutil@firstoftwo
343 \else
344 \let\pgfmath@next=\pgfutil@secondoftwo
345 \fi
346 \pgfmath@next
347 }%
348
349 \def\pgfmathfloat@parser@install{%
350 \pgfmathfloat@plots@checkuninstallcmd
351 \pgfmathfloat@plots@install%
352 \pgfmathfloat@parser@install@functions
353 %
354 %
355 %
356 % The following methods actually enable the parser to work with
357 % the internal floating point number representation.
358 %
359 % The idea is as follows:
360 % 1. Every operand must be given in internal float representation.
361 % 2. The internal float repr can be distinguished by a normal
362 % number. This is accomplished by introducing a new "exponent"
363 % token.
364 % 3. The stack-push-operation checks whether the argument is a
365 % float. If not, it is parsed properly before pushing it.
366 \pgfmath@tokens@make{exponent}{\pgfmathfloat@POSTFLAGSCHAR}%
367 \pgfmathfloat@uninstall@appendcmd{%
368 \expandafter\let\csname pgfmath@token@exponent@\pgfmathfloat@POSTFLAGSCHAR\endcsname=\relax
369 }%
370 \let\pgfmath@basic@parse@exponent=\pgfmath@parse@exponent%
371 \let\pgfmath@basic@stack@push@operand=\pgfmath@stack@push@operand
372 \pgfmathfloat@install\pgfmath@stack@push@operand=\pgfmathfloat@stack@push@operand
373 \pgfmathfloat@install\pgfmath@parse@operand@quote=\pgfmathfloat@parse@operand@quote
374 \pgfmathfloat@install\pgfmath@parse@exponent=\pgfmathfloat@parse@float@or@exponent
375 %
376 \pgfmathfloat@install\pgfmathparse=\pgfmathfloatparse%
377 %\pgfmathfloat@install\pgfmathparse@trynumber@token=\pgfmathfloat@parse@trynumber@token
378 \pgfmathfloat@install\pgfmathparse@expression@is@number=\pgfmathfloat@parse@expression@is@number
379 }%
380
381 % This here might bring speed improvements... if implemented
382 % correctly.
383 % However, this heuristics might fail in cases like "1+1" vs "1e+1" ...
384 %\def\pgfmathfloat@parse@trynumber@token{numericfpu}
385 %\pgfmath@tokens@make{numericfpu}{eE+-Y.0123456789}
386
387 \def\pgfmathfloat@parse@expression@is@number{%
388 \pgfmathfloatparsenumber{\pgfmath@expression}%
389 \pgfmath@smuggleone\pgfmathresult%
390 \endgroup
391 \ignorespaces
392 }%
393
394 \def\pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG#1{%
395 \edef\pgfmathfloat@loc@TMPa{%
396 \noexpand\def\expandafter\noexpand\csname pgfmath@parsefunction@#1\endcsname{%
397 \noexpand\let\noexpand\pgfmath@parsepostgroup\expandafter\noexpand\csname pgfmath@parsefunction@#1@\endcsname%
398 \noexpand\expandafter\noexpand\pgfmath@parse@}%
399 \noexpand\def\expandafter\noexpand\csname pgfmath@parsefunction@#1@\endcsname{%
400 \noexpand\expandafter\expandafter\noexpand\csname pgfmath#1@\endcsname\noexpand\expandafter{\noexpand\pgfmathresult}%
401 \noexpand\pgfmath@postfunction%
402 }%
403 }%
404 \pgfmathfloat@loc@TMPa
405 }%
406 \def\pgfmathfloat@parser@install@pgf@two@null@null{%
407 \pgfmathfloat@plots@checkuninstallcmd
408 \pgfmathfloat@plots@install%
409 \pgfmathfloat@parser@install@functions
410 \let\pgfmathrand@=\pgfmath@basic@rand@
411 \let\pgfmathrnd@=\pgfmath@basic@rnd@
412 \pgfmathfloat@install\pgfmathmax@=\pgfmathfloatmaxtwo%
413 \pgfmathfloat@install\pgfmathmin@=\pgfmathfloatmintwo%
414 \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{factorial}%
415 \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{hex}%
416 \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{bin}%
417 \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{oct}%
418 \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{tanh}%
419 \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{sinh}%
420 \pgfmathfloat@defineadapter@for@pgf@two@null@null@ONEARG{cosh}%
421 %
422 % The following methods actually enable the parser to work with
423 % the internal floating point number representation.
424 %
425 % The idea is as follows:
426 % 1. Every operand must be given in internal float representation.
427 % 2. The internal float repr can be distinguished by a normal
428 % number. This is accomplished by introducing a new "exponent"
429 % token.
430 % 3. The stack-push-operation checks whether the argument is a
431 % float. If not, it is parsed properly before pushing it.
432 \let\pgfmath@basic@parsedecimalpoint=\pgfmath@parsedecimalpoint%
433 \let\pgfmath@basic@stack@push@operand=\pgfmath@stackpushoperand
434 \pgfmathfloat@install\pgfmath@stackpushoperand=\pgfmathfloat@stack@push@operand
435 \pgfmathfloat@install\pgfmath@parsedecimalpoint=\pgfmathfloat@parsedecimalpoint@pgf@two@null@null
436 \pgfmathfloat@install\pgfmath@endparse=\pgfmathfloat@endparse@pgf@two@null@null
437 \pgfmathfloat@install\pgfmath@endparsegroup=\pgfmathfloat@endparsegroup@pgf@two@null@null
438 \pgfmathfloat@install\pgfmath@postfunction=\pgfmathfloat@postfunction@pgf@two@null@null
439 \pgfmathfloat@install\pgfmath@@parseoperandgroup=\pgfmathfloat@@parseoperandgroup
440 %
441 \pgfmathfloat@install\pgfmathparse=\pgfmathfloatparse@pgf@two@null@null%
442 }%
443
444 \pgfutil@ifundefined{pgfmathdeclarefunction}{%
445 % BACKWARDS COMPATIBILITY: We have PGF 2.00 :
446 \def\pgfmathdeclarepseudoconstant#1#2{%
447 \begingroup
448 \toks0=\expandafter{\csname pgfmath#1@\endcsname}%
449 \toks1={\pgfmath@postfunction}%
450 \xdef\pgfmathfloat@glob@TMP{\the\toks0 \the\toks1 }%
451 \xdef\pgfmathfloat@glob@TMPb{\the\toks0 }%
452 \endgroup
453 \expandafter\let\csname pgfmath@parsefunction@#1\endcsname=\pgfmathfloat@glob@TMP
454 \expandafter\let\csname pgfmath#1\endcsname=\pgfmathfloat@glob@TMPb
455 \expandafter\def\csname pgfmath#1@\endcsname{#2}%
456 }%
457 \let\pgfmathredeclarepseudoconstant=\pgfmathdeclarepseudoconstant
458 }{%
459 \pgfutil@ifundefined{pgfmathdeclarepseudoconstant}{%
460 \def\pgfmathdeclarepseudoconstant#1#2{\pgfmathdeclarefunction*{#1}{0}{#2}}
461 }{}%
462 }%
463
464 \pgfmathdeclarepseudoconstant{inf}{\def\pgfmathresult{inf}}
465 \pgfmathdeclarepseudoconstant{INF}{\def\pgfmathresult{inf}}
466 \pgfmathdeclarepseudoconstant{Inf}{\def\pgfmathresult{inf}}
467 \pgfmathdeclarepseudoconstant{infty}{\def\pgfmathresult{inf}}
468 \pgfmathdeclarepseudoconstant{nan}{\def\pgfmathresult{nan}}
469 \pgfmathdeclarepseudoconstant{NaN}{\def\pgfmathresult{nan}}
470
471 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
472 %
473 % Hacks to the basic level pgf math engine:
474 %
475 % WARNING: These methods rely heavily on the internal float representation!
476 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
477
478 % for pgf2.00 :
479 \def\pgfmathfloat@parsedecimalpoint@pgf@two@null@null#1{%
480 \expandafter\ifx\pgfmathfloat@POSTFLAGSCHAR#1% check whether it is a float
481 \let\pgfmath@next=\pgfmathfloat@return@float@pgf@two@null@null%
482 \else
483 \def\pgfmath@next{\pgfmath@basic@parsedecimalpoint#1}%
484 \fi
485 \pgfmath@next
486 }
487 % for pgf2.00:
488 \def\pgfmathfloat@return@float@pgf@two@null@null#1]{%
489 \edef\pgfmathresult{\the\c@pgfmath@parsecounta\pgfmathfloat@POSTFLAGSCHAR#1]}%
490 \let\pgfmath@resulttemp=\pgfmathresult
491 \pgfmath@parseoperator%
492 }%
493 % for pgf2.00:
494 \def\pgfmathfloat@endparse@pgf@two@null@null#1\pgfmath@empty{%
495 \pgfmath@processalloperations%
496 \pgfmath@stackpop{\pgfmathresult}%
497 % delete the final unit scalings
498 \pgfmath@smuggleone{\pgfmathresult}%
499 \endgroup%
500 \ignorespaces%
501 }
502 % for pgf2.00:
503 \def\pgfmathfloat@endparsegroup@pgf@two@null@null{%
504 \pgfmath@processalloperations%
505 \pgfmath@stackpop{\pgfmathresult}%
506 % eliminated register usage here...
507 \pgfmath@smuggleone{\pgfmathresult}%
508 \endgroup%
509 \pgfmath@parsepostgroup%
510 }
511 % for pgf2.00:
512 \def\pgfmathfloat@postfunction@pgf@two@null@null{%
513 \let\pgfmath@parsepostgroup\pgfmath@parseoperator%
514 \ifnum\pgfmath@sign1<0
515 \pgfmathfloatneg@{\pgfmathresult}%
516 \let\pgfmath@sign\pgfutil@empty
517 \fi
518 \pgfmath@parseoperator}
519 % for pgf2.00:
520 \def\pgfmathfloat@@parseoperandgroup{%
521 \let\pgfmath@postparsegroup\pgfmath@parseoperator%
522 \ifnum\pgfmath@sign1<0
523 \pgfmathfloatneg@{\pgfmathresult}%
524 \let\pgfmath@sign\pgfutil@empty
525 \fi
526 \pgfmath@parseoperator%
527 }
528
529
530
531
532
533
534 % PRECONDITION:
535 % either
536 % <number>e
537 % ^
538 % -> read the exponent.
539 % or
540 % <sign>\pgfmathfloat@POSTFLAGSCHAR
541 % ^
542 % -> we have a parsed floating point number -> read it.
543 \def\pgfmathfloat@parse@float@or@exponent{%
544 \if\pgfmath@token \pgfmathfloat@POSTFLAGSCHAR%
545 % Ok, we actually HAVE a pre-parsed floating point number!
546 % Return it.
547 \expandafter\pgfmathfloat@return@float\expandafter\pgfmath@token@next
548 \else
549 % We have a standard number in scientific format. Parse it.
550 \expandafter\pgfmath@basic@parse@exponent
551 \fi
552 }%
553 \def\pgfmathfloat@return@float#1]{%
554 \edef\pgfmathresult{\pgfmath@number \pgfmathfloat@POSTFLAGSCHAR#1]}%
555 \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathresult}%
556 \pgfmath@parse@@operator%
557 }%
558
559 \def\pgfmathfloat@parse@operand@quote#1"{%
560 \edef\pgfmathresult{\pgfmath@fpu@stringmarker #1}%
561 \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathresult}%
562 \pgfmath@parse@@operator%
563 }
564
565 \def\pgfmath@fpu@stringmarker{@@str@@:}%
566
567 % This extends the functionality of the basic level operand stack: it
568 % assures every element on the stack is a float.
569 \def\pgfmathfloat@stack@push@operand#1{%
570 \pgfutil@ifnextchar\bgroup{%
571 \let\pgfmathfloat@stack@push@operand@list@=\pgfutil@empty
572 \pgfmathfloat@stack@push@operand@list
573 }{%
574 \pgfmathfloat@stack@push@operand@single
575 }%
576 #1\relax
577 }%
578 \def\pgfmathfloat@stack@push@operand@single#1\relax{%
579 \expandafter\pgfutil@in@\pgfmathfloat@POSTFLAGSCHAR{#1}%
580 \ifpgfutil@in@
581 \pgfmath@basic@stack@push@operand{#1}%
582 \else
583 \expandafter\pgfutil@in@\expandafter{\pgfmath@fpu@stringmarker}{#1}%
584 \ifpgfutil@in@
585 \pgfmathfloat@stack@push@operand@single@str#1\relax
586 \else
587 \pgfmathfloatparsenumber{#1}%
588 \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathresult}%
589 \fi
590 \fi
591 }%
592
593 \expandafter\def\expandafter\pgfmathfloat@stack@push@operand@single@str\pgfmath@fpu@stringmarker #1\relax{%
594 \pgfmath@basic@stack@push@operand{#1}%
595 }%
596 \def\pgfmathfloat@stack@push@operand@GOBBLE#1\relax{}%
597 \def\pgfmathfloat@stack@push@operand@list#1{%
598 \expandafter\pgfutil@in@ \pgfmathfloat@POSTFLAGSCHAR{#1}%
599 \ifpgfutil@in@
600 \expandafter\def\expandafter\pgfmathfloat@stack@push@operand@list@\expandafter{%
601 \pgfmathfloat@stack@push@operand@list@{#1}%
602 }%
603 \else
604 \pgfmathfloatparsenumber{#1}%
605 \begingroup
606 \toks0=\expandafter{\pgfmathfloat@stack@push@operand@list@}%
607 \toks1=\expandafter{\pgfmathresult}%
608 \xdef\pgfmathfloat@glob@TMP{\the\toks0 {\the\toks1}}%
609 \endgroup
610 \let\pgfmathfloat@stack@push@operand@list@=\pgfmathfloat@glob@TMP
611 \fi
612 \pgfutil@ifnextchar\relax{%
613 \expandafter\pgfmath@basic@stack@push@operand\expandafter{\pgfmathfloat@stack@push@operand@list@}%
614 \pgfmathfloat@stack@push@operand@GOBBLE
615 }{%
616 \pgfmathfloat@stack@push@operand@list
617 }%
618 }%
619 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
620 %
621 % --- END --- Hacks to the basic level pgf math engine
622 %
623 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
624
625
626
627 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
628 %
629 % Here starts the implementation of the floating point
630 % routines.
631 %
632 % They can be used even if the FPU parser is not active.
633 %
634 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
635
636 % Remember the basic math commands. They will be invoked as subroutines in floating point routines.
637 \let\pgfmath@basic@add@=\pgfmathadd@
638 \let\pgfmath@basic@subtract@=\pgfmathsubtract@
639 \let\pgfmath@basic@multiply@=\pgfmathmultiply@
640 \let\pgfmath@basic@divide@=\pgfmathdivide@
641 \let\pgfmath@basic@reciprocal@=\pgfmathreciprocal@
642 \let\pgfmath@basic@abs@=\pgfmathabs@
643 \let\pgfmath@basic@round@=\pgfmathround@
644 \let\pgfmath@basic@rand@=\pgfmathrand@
645 \let\pgfmath@basic@rnd@=\pgfmathrnd@
646 \let\pgfmath@basic@setseed@=\pgfmathsetseed@
647 \let\pgfmath@basic@random@=\pgfmathrandom@
648 \let\pgfmath@basic@floor@=\pgfmathfloor@
649 \let\pgfmath@basic@ceil@=\pgfmathceil@
650 \let\pgfmath@basic@mod@=\pgfmathmod@
651 \let\pgfmath@basic@max@=\pgfmathmax@
652 \let\pgfmath@basic@min@=\pgfmathmin@
653 \let\pgfmath@basic@sin@=\pgfmathsin@
654 \let\pgfmath@basic@cos@=\pgfmathcos@
655 \let\pgfmath@basic@tan@=\pgfmathtan@
656 \let\pgfmath@basic@deg@=\pgfmathdeg@
657 \let\pgfmath@basic@rad@=\pgfmathrad@
658 \let\pgfmath@basic@atan@=\pgfmathatan@
659 \let\pgfmath@basic@asin@=\pgfmathasin@
660 \let\pgfmath@basic@acos@=\pgfmathacos@
661 \let\pgfmath@basic@cot@=\pgfmathcot@
662 \let\pgfmath@basic@sec@=\pgfmathsec@
663 \let\pgfmath@basic@cosec@=\pgfmathcosec@
664 \let\pgfmath@basic@pow@=\pgfmathpow@
665 \let\pgfmath@basic@exp@=\pgfmathexp@
666 \let\pgfmath@basic@ln@=\pgfmathln@
667 \let\pgfmath@basic@sqrt@=\pgfmathsqrt@
668 \let\pgfmath@basic@@pi=\pgfmath@pi
669 \let\pgfmath@basic@veclen@=\pgfmathveclen@
670 \let\pgfmath@basic@e@=\pgfmathe@
671 \let\pgfmath@basic@lessthan@=\pgfmathlessthan@
672 \let\pgfmath@basic@greaterthan@=\pgfmathgreaterthan@
673 \let\pgfmath@basic@equalto@=\pgfmathequalto@
674 \let\pgfmath@basic@equal@=\pgfmathequal@
675 \let\pgfmath@basic@true@=\pgfmathtrue@
676 \let\pgfmath@basic@false@=\pgfmathfalse@
677
678 \def\pgfmathfloatscientific#1#2{%
679 \edef\pgfmathresult{#1e#2}%
680 \expandafter\pgfmathfloatparsenumber\expandafter{\pgfmathresult}%
681 }
682 % Compares #1 with #2 and sets \pgfmathresult either to 1.0 or 0.0.
683 %
684 % It also sets the boolean \ifpgfmathfloatcomparison (globally).
685 \def\pgfmathfloatlessthan@#1#2{%
686 %\def\pgfmathfloatlessthan#1#2#3\and#4#5#6{%
687 \global\pgfmathfloatcomparisonfalse
688 \begingroup
689 \edef\pgfmathfloat@loc@TMPa{#1}%
690 \edef\pgfmathfloat@loc@TMPb{#2}%
691 \expandafter\pgfmathfloat@decompose\pgfmathfloat@loc@TMPa\relax\pgfmathfloat@a@S\pgfmathfloat@a@M\pgfmathfloat@a@E
692 \expandafter\pgfmathfloat@decompose\pgfmathfloat@loc@TMPb\relax\pgfmathfloat@b@S\pgfmathfloat@b@M\pgfmathfloat@b@E
693 \ifcase\pgfmathfloat@a@S
694 % x = 0 -> (x<y <=> y >0)
695 \ifcase\pgfmathfloat@b@S
696 % y = 0
697 \or% y > 0
698 \global\pgfmathfloatcomparisontrue
699 \or% y < 0
700 \or% y = nan
701 \or% y = + infty
702 \global\pgfmathfloatcomparisontrue
703 \or% y = -infty
704 \fi
705 \or
706 % x > 0 -> (x<y <=> ( y > 0 && |x| < |y|) )
707 \ifcase\pgfmathfloat@b@S
708 % y = 0
709 \or% y>0:
710 \pgfmathfloatlessthan@positive
711 \or% y < 0
712 \or% y = nan
713 \or% y = + infty
714 \global\pgfmathfloatcomparisontrue
715 \or% y = -infty
716 \fi
717 \or
718 % x < 0 -> (x<y <=> (y >= 0 || |x| > |y|) )
719 \ifcase\pgfmathfloat@b@S
720 % y = 0
721 \global\pgfmathfloatcomparisontrue
722 \or%y > 0
723 \global\pgfmathfloatcomparisontrue
724 \or% 'y<0':
725 \pgfmathfloatgreaterthan@positive
726 \or% y = nan
727 \or% y = + infty
728 \global\pgfmathfloatcomparisontrue
729 \or% y = -infty
730 \fi
731 \or
732 % x = nan.
733 \or
734 % x = +infty
735 \or
736 % x = -infty
737 \ifnum\pgfmathfloat@b@S=3
738 \else
739 \global\pgfmathfloatcomparisontrue
740 \fi
741 \fi
742 \endgroup
743 \ifpgfmathfloatcomparison
744 \def\pgfmathresult{1.0}%
745 \else
746 \def\pgfmathresult{0.0}%
747 \fi
748 }
749 \let\pgfmathfloatlessthan=\pgfmathfloatlessthan@
750 \let\pgfmathfloatless@=\pgfmathfloatlessthan@
751
752 % ! (#1 < #2) <=> (#1 >= #2)
753 \def\pgfmathfloatnotless@#1#2{%
754 \pgfmathfloatless@{#1}{#2}%
755 \ifpgfmathfloatcomparison
756 \def\pgfmathresult{0.0}%
757 \else
758 \def\pgfmathresult{1.0}%
759 \fi
760 }%
761 % ! (#1 > #2) <=> (#1 <= #2)
762 \def\pgfmathfloatnotgreater@#1#2{%
763 \pgfmathfloatless@{#2}{#1}%
764 \ifpgfmathfloatcomparison
765 \def\pgfmathresult{0.0}%
766 \else
767 \def\pgfmathresult{1.0}%
768 \fi
769 }%
770
771 % compares \pgfmathfloat@a@[SME] < \pgfmathfloat@b@[SME]
772 \def\pgfmathfloatlessthan@positive{%
773 \ifnum\pgfmathfloat@a@E<\pgfmathfloat@b@E
774 \global\pgfmathfloatcomparisontrue
775 \else
776 \ifnum\pgfmathfloat@a@E=\pgfmathfloat@b@E
777 \ifdim\pgfmathfloat@a@M<\pgfmathfloat@b@M
778 \global\pgfmathfloatcomparisontrue
779 \fi
780 \fi
781 \fi
782 }
783
784 % compares \pgfmathfloat@a@[SME] > \pgfmathfloat@b@[SME]
785 \def\pgfmathfloatgreaterthan@positive{%
786 \ifnum\pgfmathfloat@a@E>\pgfmathfloat@b@E
787 \global\pgfmathfloatcomparisontrue
788 \else
789 \ifnum\pgfmathfloat@a@E=\pgfmathfloat@b@E
790 \ifdim\pgfmathfloat@a@M>\pgfmathfloat@b@M
791 \global\pgfmathfloatcomparisontrue
792 \fi
793 \fi
794 \fi
795 }
796
797
798 \def\pgfmathfloatgreaterthan@#1#2{\pgfmathfloatlessthan@{#2}{#1}}
799 \let\pgfmathfloatgreaterthan=\pgfmathfloatgreaterthan@
800 \let\pgfmathfloatgreater@=\pgfmathfloatgreaterthan@
801
802 \def\pgfmathfloatmax@#1{%
803 \begingroup
804 \pgfmathfloatcreate{2}{1.0}{2147483644}%
805 \let\pgfmathmaxsofar=\pgfmathresult
806 \pgfmathfloatmax@@#1{}%
807 }%
808 \def\pgfmathfloatmax@@#1{%
809 \def\pgfmath@temp{#1}%
810 \ifx\pgfmath@temp\pgfmath@empty%
811 \expandafter\pgfmathfloatmax@@@%
812 \else%
813 \pgfmathfloatlessthan{\pgfmathmaxsofar}{#1}%
814 \ifpgfmathfloatcomparison
815 \edef\pgfmathmaxsofar{#1}%
816 \fi
817 \expandafter\pgfmathfloatmax@@%
818 \fi%
819 }%
820 \def\pgfmathfloatmax@@@{%
821 \let\pgfmathresult=\pgfmathmaxsofar
822 \pgfmath@smuggleone{\pgfmathresult}%
823 \endgroup
824 }%
825 \def\pgfmathfloatmin@#1{%
826 \begingroup
827 \pgfmathfloatcreate{1}{1.0}{2147483644}%
828 \let\pgfmathminsofar=\pgfmathresult
829 \pgfmathfloatmin@@#1{}%
830 }%
831 \def\pgfmathfloatmin@@#1{%
832 \def\pgfmath@temp{#1}%
833 \ifx\pgfmath@temp\pgfmath@empty%
834 \expandafter\pgfmathfloatmin@@@%
835 \else%
836 \pgfmathfloatlessthan{#1}{\pgfmathminsofar}%
837 \ifpgfmathfloatcomparison
838 \edef\pgfmathminsofar{#1}%
839 \fi
840 \expandafter\pgfmathfloatmin@@%
841 \fi%
842 }%
843 \def\pgfmathfloatmin@@@{%
844 \let\pgfmathresult=\pgfmathminsofar
845 \pgfmath@smuggleone{\pgfmathresult}%
846 \endgroup
847 }%
848
849 \def\pgfmathfloatmaxtwo#1#2{%
850 \pgfmathfloatlessthan{#1}{#2}%
851 \ifpgfmathfloatcomparison
852 \edef\pgfmathresult{#2}%
853 \else
854 \edef\pgfmathresult{#1}%
855 \fi
856 }
857 \let\pgfmathfloatmax=\pgfmathfloatmaxtwo
858
859 \def\pgfmathfloatmintwo#1#2{%
860 \pgfmathfloatlessthan{#1}{#2}%
861 \ifpgfmathfloatcomparison
862 \edef\pgfmathresult{#1}%
863 \else
864 \edef\pgfmathresult{#2}%
865 \fi
866 }
867 \let\pgfmathfloatmin=\pgfmathfloatmintwo
868
869 % Renormalizes #1 to extended precision mantisse, meaning
870 % 100 <= m < 1000
871 % instead of 1 <= m < 10.
872 %
873 % The 'extended precision' means we have higher accuracy when we apply pgfmath operations to mantissas.
874 %
875 % 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).
876 %
877 % The operation is supposed to be very fast.
878 %
879 % @see \pgfmathfloatsetextprecision
880 %
881 % There is a routine for internal usage,
882 % \pgfmathfloattoextentedprecision@a. It also provides exponent and
883 % sign of #1 in output arguments and may be used to increase speed.
884 \def\pgfmathfloattoextentedprecision#1{%
885 \begingroup
886 \pgfmathfloattoextentedprecision@a{#1}%
887 \pgfmathfloatcreate{\pgfmathfloat@a@S}{\pgfmathresult}{\pgfmathfloat@a@E}%
888 \pgfmath@smuggleone\pgfmathresult
889 \endgroup
890 }%
891
892 \def\pgfmathfloattoextentedprecision@@zero#1\pgfmathfloat@EOI{%
893 \edef\pgfmathresult{#1}%
894 }%
895 \def\pgfmathfloattoextentedprecision@@one#1.#2#3\pgfmathfloat@EOI{%
896 \edef\pgfmathresult{#1#2.#3}%
897 }%
898 \def\pgfmathfloattoextentedprecision@@two#1.#2#3#4\pgfmathfloat@EOI{%
899 \edef\pgfmathresult{#1#2#3.#4}%
900 }%
901 \def\pgfmathfloattoextentedprecision@@three#1.#2#3#4#5\pgfmathfloat@EOI{%
902 \edef\pgfmathresult{#1#2#3#4.#5}%
903 }%
904
905 % Sets extended precision to 10^#1.
906 %
907 % The different choices are
908 %
909 % - 0: normalization 0 <= m < 1 (disable extended precision)
910 % - 1: normalization 10 <= m < 100
911 % - 2: normalization 100 <= m < 1000 (default)
912 % - 3: normalization 1000 <= m < 10000
913 %
914 % #1 is the exponent, #1 = 0,1,2 or 3.
915 %
916 % This setting applies to \pgfmathfloattoextentedprecision and friends.
917 \def\pgfmathfloatsetextprecision#1{%
918 \ifcase#1\relax
919 \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@zero
920 \def\pgfmathfloatextprec@shift{0}%
921 \or
922 \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@one
923 \def\pgfmathfloatextprec@shift{1}%
924 \or
925 \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@two
926 \def\pgfmathfloatextprec@shift{2}%
927 \else
928 \let\pgfmathfloattoextentedprecision@@=\pgfmathfloattoextentedprecision@@three
929 \def\pgfmathfloatextprec@shift{3}%
930 \fi
931 }%
932 \pgfmathfloatsetextprecision{2}%
933
934 % Does the "hard" work for \pgfmathfloattoextentedprecision. It
935 % provides additional outputs.
936 %
937 % INPUT:
938 % #1 normalized floating point number. Maybe a macro (it will be expanded ONCE)
939 %
940 % OUTPUT:
941 % - \pgfmathresult : the mantisse in extended precision
942 % - \pgfmathfloat@a@S : the sign of #1
943 % - \pgfmathfloat@a@E : the exponent of #1, adjusted for extended precision
944 % - \pgfmathfloat@a@Mtok : undefined (its contents will be destroyed.
945 %
946 \def\pgfmathfloattoextentedprecision@a#1{%
947 \edef\pgfmathresult{#1}%
948 \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
949 \ifnum\pgfmathfloat@a@S<3
950 \advance\pgfmathfloat@a@E by-\pgfmathfloatextprec@shift\relax% compensate for shift
951 \expandafter\pgfmathfloattoextentedprecision@@\the\pgfmathfloat@a@Mtok 000\pgfmathfloat@EOI
952 \fi
953 }%
954
955
956 % Similar to \pgfmathfloattoextentedprecision@a, this one here fills the '@b' registers.
957 \def\pgfmathfloattoextentedprecision@b#1{%
958 \edef\pgfmathresult{#1}%
959 \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@b@S\pgfmathfloat@a@Mtok\pgfmathfloat@b@E
960 \ifnum\pgfmathfloat@b@S<3
961 \advance\pgfmathfloat@b@E by-\pgfmathfloatextprec@shift\relax
962 \expandafter\pgfmathfloattoextentedprecision@@\the\pgfmathfloat@a@Mtok 00\pgfmathfloat@EOI
963 \fi
964 }%
965
966 % Addition of two floating point numbers using 8 significant digits.
967 \def\pgfmathfloatadd@#1#2{%
968 \begingroup
969 %
970 % renormalize argument to 100 <= m < 1000 for extended accuracy:
971 \pgfmathfloattoextentedprecision@a{#1}%
972 \let\pgfmathfloat@arga=\pgfmathresult
973 %
974 \pgfmathfloattoextentedprecision@b{#2}%
975 \let\pgfmathfloat@argb=\pgfmathresult
976 %
977 \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases.
978 \ifcase\pgfmathfloat@a@S
979 \edef\pgfmathresult{#2}%
980 \pgfmathfloatcomparisonfalse
981 \or
982 \or
983 \edef\pgfmathfloat@arga{-\pgfmathfloat@arga}%
984 \else
985 \pgfmathfloatcomparisonfalse
986 \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{0.0}{0}%
987 \fi
988 \ifcase\pgfmathfloat@b@S
989 \edef\pgfmathresult{#1}%
990 \pgfmathfloatcomparisonfalse
991 \or
992 \or
993 \edef\pgfmathfloat@argb{-\pgfmathfloat@argb}%
994 \else
995 \pgfmathfloatcomparisonfalse
996 \pgfmathfloatcreate{\the\pgfmathfloat@b@S}{0.0}{0}%
997 \fi
998 \ifpgfmathfloatcomparison
999 % Shift lesser mantisse to fit the larger one:
1000 \ifnum\pgfmathfloat@a@E<\pgfmathfloat@b@E
1001 \pgfmathfloatadd@shift{\pgfmathfloat@arga}{\pgfmathfloat@a@E}{\pgfmathfloat@b@E}%
1002 \else
1003 \pgfmathfloatadd@shift{\pgfmathfloat@argb}{\pgfmathfloat@b@E}{\pgfmathfloat@a@E}%
1004 \fi
1005 % add them!
1006 \pgfmath@basic@add@{\pgfmathfloat@arga}{\pgfmathfloat@argb}%
1007 % renormalize sum. This is the only part were an expensive routine comes into play:
1008 \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}%
1009 \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}%
1010 \fi
1011 \pgfmath@smuggleone\pgfmathresult
1012 \endgroup
1013 }%
1014
1015 % #1= floating point number
1016 % #2= TeX code to execute if #1 == 0
1017 % #3= TeX code to execute if #1 != 0
1018 \def\pgfmathfloatifzero#1#2#3{%
1019 \pgfmathfloatgetflagstomacro{#1}\pgfmathfloat@loc@TMPa
1020 \if\pgfmathfloat@loc@TMPa0 #2\else#3\fi
1021 }%
1022
1023 \def\pgfmathfloatiffinite#1#2#3{%
1024 \pgfmathfloatgetflagstomacro{#1}\pgfmathfloatiffinite@
1025 \ifnum\pgfmathfloatiffinite@>2 #3\else #2\fi
1026 }%
1027
1028 \def\pgfmathfloatifthenelse@#1#2#3{%
1029 \pgfmathfloatifflags{#1}{0}{%
1030 \edef\pgfmathresult{#3}%%
1031 }{%
1032 \edef\pgfmathresult{#2}%
1033 }%
1034 }
1035 \def\pgfmathfloatequal@#1#2{%
1036 \pgfmathfloatifapproxequalrel{#1}{#2}{%
1037 \def\pgfmathresult{1}%
1038 \pgfmathfloatcomparisontrue
1039 }{%
1040 \def\pgfmathresult{0}%
1041 \pgfmathfloatcomparisonfalse
1042 }%
1043 }
1044 \let\pgfmathfloatequalto@=\pgfmathfloatequal@
1045
1046 \def\pgfmathfloatnotequal@#1#2{%
1047 \pgfmathfloatifapproxequalrel{#1}{#2}{%
1048 \def\pgfmathresult{0}%
1049 \pgfmathfloatcomparisonfalse
1050 }{%
1051 \def\pgfmathresult{1}%
1052 \pgfmathfloatcomparisontrue
1053 }%
1054 }
1055 \let\pgfmathfloatnotequalto@=\pgfmathfloatnotequal@
1056
1057 % Computes the relative error between #1 and #2 (assuming #2 != 0) and
1058 % invokes #3 if the relative error is below `/pgf/fpu/rel thresh' and
1059 % #4 if that is not the case.
1060 \long\def\pgfmathfloatifapproxequalrel#1#2#3#4{%
1061 \begingroup
1062 \pgfmathfloatparsenumber{#1}%
1063 \let\pgfmathfloatarga=\pgfmathresult
1064 \pgfmathfloatparsenumber{#2}%
1065 \let\pgfmathfloatargb=\pgfmathresult
1066 \pgfmathfloatrelerror@\pgfmathfloatarga\pgfmathfloatargb
1067 \let\pgfmathfloatarga=\pgfmathresult
1068 \pgfmathfloatlessthan@\pgfmathfloatarga\pgfmathfloat@relthresh
1069 \ifpgfmathfloatcomparison
1070 \def\pgfmathfloat@loc@TMPa{#3}%
1071 \else
1072 \def\pgfmathfloat@loc@TMPa{#4}%
1073 \fi
1074 \expandafter\endgroup
1075 \pgfmathfloat@loc@TMPa
1076 }%
1077
1078 % Invokes code '#3' if the flags of the floating point number '#1'
1079 % match the flag provided in '#2'.
1080 %
1081 % \pgfmathfloatcreate{1}{1.0}{2}
1082 % \pgfmathfloatifflags{\pgfmathresult}{0}{It's zero!}{It's not zero!}%
1083 % \pgfmathfloatifflags{\pgfmathresult}{1}{It's positive!}{It's not positive!}%
1084 % \pgfmathfloatifflags{\pgfmathresult}{2}{It's negative!}{It's not negative!}%
1085 % or, equivalently
1086 % \pgfmathfloatifflags{\pgfmathresult}{+}{It's positive!}{It's not positive!}%
1087 % \pgfmathfloatifflags{\pgfmathresult}{-}{It's negative!}{It's not negative!}%
1088 % it also supports #2=u which means 'unbounded'
1089 \def\pgfmathfloatifflags#1#2#3#4{%
1090 \if#2-%
1091 \pgfmathfloatifflags{#1}{2}{#3}{#4}%
1092 \else
1093 \if#2+%
1094 \pgfmathfloatifflags{#1}{1}{#3}{#4}%
1095 \else
1096 \pgfmathfloatgetflagstomacro{#1}\pgfmathfloat@loc@TMPa
1097 \if#2u%
1098 \ifnum\pgfmathfloat@loc@TMPa>2
1099 #3\relax
1100 \else
1101 #4\relax
1102 \fi
1103 \else
1104 \if\pgfmathfloat@loc@TMPa#2%
1105 #3\relax
1106 \else
1107 #4\relax
1108 \fi
1109 \fi
1110 \fi
1111 \fi
1112 }%
1113
1114 % #1=mantisse which needs to be shifted (with smaller exponent)
1115 % #2=smaller exponent
1116 % #3=larger exponent
1117 %
1118 % ATTENTION: this helper method DESTROYS contents of \pgfmathfloat@a@S.
1119 \def\pgfmathfloatadd@shift#1#2#3{%
1120 \pgf@xa=#1 pt%
1121 \pgfmathfloat@a@S=#3\relax
1122 \advance\pgfmathfloat@a@S by-#2\relax
1123 \ifcase\pgfmathfloat@a@S
1124 \or
1125 \divide\pgf@xa by10\relax
1126 \or
1127 \divide\pgf@xa by100\relax
1128 \or
1129 \divide\pgf@xa by1000\relax
1130 \or
1131 \divide\pgf@xa by10000\relax
1132 \or
1133 \divide\pgf@xa by10000\relax
1134 \divide\pgf@xa by10\relax
1135 \or
1136 \divide\pgf@xa by10000\relax
1137 \divide\pgf@xa by100\relax
1138 \or
1139 \divide\pgf@xa by10000\relax
1140 \divide\pgf@xa by1000\relax
1141 \or
1142 \divide\pgf@xa by10000\relax
1143 \divide\pgf@xa by10000\relax
1144 \else
1145 \pgf@xa=0pt%
1146 \fi
1147 #2=#3\relax
1148 \edef#1{\pgf@sys@tonumber\pgf@xa}%
1149 }
1150
1151 \let\pgfmathfloatadd=\pgfmathfloatadd@
1152
1153
1154 % Subtracts two floating point numbers.
1155 \def\pgfmathfloatsubtract@#1#2{%
1156 \begingroup
1157 \edef\pgfmathresult{#2}%
1158 \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@b@S\pgfmathfloat@a@Mtok\pgfmathfloat@b@E
1159 \ifcase\pgfmathfloat@b@S
1160 \edef\pgfmathresult{#1}%
1161 \or
1162 \pgfmathfloatcreate{2}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@b@E}%
1163 \let\pgfmathfloatsub@arg=\pgfmathresult
1164 \pgfmathfloatadd@{#1}{\pgfmathfloatsub@arg}%
1165 \or
1166 \pgfmathfloatcreate{1}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@b@E}%
1167 \let\pgfmathfloatsub@arg=\pgfmathresult
1168 \pgfmathfloatadd@{#1}{\pgfmathfloatsub@arg}%
1169 \else
1170 \pgfmathfloatcreate{\the\pgfmathfloat@b@S}{0.0}{0}%
1171 \fi
1172 \pgfmath@smuggleone\pgfmathresult
1173 \endgroup
1174 }%
1175
1176 \let\pgfmathfloatsubtract=\pgfmathfloatsubtract@
1177
1178 % Scales a floating point number #1 with a fixed point number #2 using pgfmathmultiply.
1179 %
1180 % Use this method if #2 is small number.
1181 \def\pgfmathfloatmultiplyfixed@#1#2{%
1182 \begingroup
1183 %
1184 % renormalize argument to 100 <= m < 1000 for extended accuracy:
1185 \pgfmathfloattoextentedprecision@a{#1}%
1186 \let\pgfmathfloat@arga=\pgfmathresult
1187 %
1188 \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases.
1189 \ifcase\pgfmathfloat@a@S
1190 \edef\pgfmathresult{#1}%
1191 \pgfmathfloatcomparisonfalse
1192 \or
1193 \or
1194 \edef\pgfmathfloat@arga{-\pgfmathfloat@arga}%
1195 \else
1196 \pgfmathfloatcomparisonfalse
1197 \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{0.0}{0}%
1198 \fi
1199 \ifpgfmathfloatcomparison
1200 \pgfmath@basic@multiply@{\pgfmathfloat@arga}{#2}%
1201 % renormalize product. This is the only part were an expensive routine comes into play:
1202 \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}%
1203 \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}%
1204 \fi
1205 \pgfmath@smuggleone\pgfmathresult
1206 \endgroup
1207 }%
1208
1209 \let\pgfmathfloatmultiplyfixed=\pgfmathfloatmultiplyfixed@
1210
1211
1212 \def\pgfmathfloatmultiply@#1#2{%
1213 \begingroup
1214 \pgfmathfloatsetextprecision{1}%
1215 \pgfmathfloattoextentedprecision@a{#1}%
1216 \let\pgfmathfloat@arga=\pgfmathresult
1217 %
1218 \pgfmathfloattoextentedprecision@b{#2}%
1219 \let\pgfmathfloat@argb=\pgfmathresult
1220 %
1221 \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases.
1222 \ifcase\pgfmathfloat@a@S
1223 % 0
1224 \pgfmathfloatcreate{0}{0.0}{0}%
1225 \pgfmathfloatcomparisonfalse
1226 \or% +
1227 \ifcase\pgfmathfloat@b@S
1228 \pgfmathfloatcreate{0}{0.0}{0}%
1229 \pgfmathfloatcomparisonfalse
1230 \or
1231 \def\pgfmathresult@S{1}%
1232 \or
1233 \def\pgfmathresult@S{2}%
1234 \else
1235 \expandafter\pgfmathfloatcreate\the\pgfmathfloat@b@S{0.0}{0}%
1236 \pgfmathfloatcomparisonfalse
1237 \fi
1238 \or% -
1239 \ifcase\pgfmathfloat@b@S
1240 \pgfmathfloatcreate{0}{0.0}{0}%
1241 \pgfmathfloatcomparisonfalse
1242 \or
1243 \def\pgfmathresult@S{2}%
1244 \or
1245 \def\pgfmathresult@S{1}%
1246 \or
1247 \pgfmathfloatcreate{3}{0.0}{0}%
1248 \pgfmathfloatcomparisonfalse
1249 \or
1250 \pgfmathfloatcreate{5}{0.0}{0}%
1251 \pgfmathfloatcomparisonfalse
1252 \or
1253 \pgfmathfloatcreate{4}{0.0}{0}%
1254 \pgfmathfloatcomparisonfalse
1255 \fi
1256 \or% nan
1257 \pgfmathfloatcreate{3}{0.0}{0}%
1258 \pgfmathfloatcomparisonfalse
1259 \or% +infty
1260 \ifcase\pgfmathfloat@b@S
1261 \pgfmathfloatcreate{0}{0.0}{0}%
1262 \pgfmathfloatcomparisonfalse
1263 \or
1264 \pgfmathfloatcreate{4}{0.0}{0}%
1265 \pgfmathfloatcomparisonfalse
1266 \or
1267 \pgfmathfloatcreate{5}{0.0}{0}%
1268 \pgfmathfloatcomparisonfalse
1269 \or
1270 \pgfmathfloatcreate{3}{0.0}{0}%
1271 \pgfmathfloatcomparisonfalse
1272 \or
1273 \pgfmathfloatcreate{4}{0.0}{0}%
1274 \pgfmathfloatcomparisonfalse
1275 \or
1276 \pgfmathfloatcreate{5}{0.0}{0}%
1277 \pgfmathfloatcomparisonfalse
1278 \fi
1279 \or% -infty
1280 \ifcase\pgfmathfloat@b@S
1281 \pgfmathfloatcreate{0}{0.0}{0}%
1282 \pgfmathfloatcomparisonfalse
1283 \or
1284 \pgfmathfloatcreate{5}{0.0}{0}%
1285 \pgfmathfloatcomparisonfalse
1286 \or
1287 \pgfmathfloatcreate{4}{0.0}{0}%
1288 \pgfmathfloatcomparisonfalse
1289 \or
1290 \pgfmathfloatcreate{3}{0.0}{0}%
1291 \pgfmathfloatcomparisonfalse
1292 \or
1293 \pgfmathfloatcreate{5}{0.0}{0}%
1294 \pgfmathfloatcomparisonfalse
1295 \or
1296 \pgfmathfloatcreate{4}{0.0}{0}%
1297 \pgfmathfloatcomparisonfalse
1298 \fi
1299 \fi
1300 \ifpgfmathfloatcomparison
1301 \pgfmath@basic@multiply@{\pgfmathfloat@arga}{\pgfmathfloat@argb}%
1302 \advance\pgfmathfloat@a@E by\pgfmathfloat@b@E
1303 % renormalize sum. This is the only part were an expensive routine comes into play:
1304 \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}%
1305 \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}%
1306 \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
1307 \pgfmathfloatcreate{\pgfmathresult@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
1308 \fi
1309 \pgfmath@smuggleone\pgfmathresult
1310 \endgroup
1311 }%
1312 \let\pgfmathfloatmultiply=\pgfmathfloatmultiply@
1313
1314 % Defines \pgfmathresult to be #1 / #2 for two floating point numbers.
1315 %
1316 % It employs the basic math engine internally to divide mantissas.
1317 \def\pgfmathfloatdivide@#1#2{%
1318 \begingroup
1319 \pgfmathfloatsetextprecision{1}% is not too important, I think. After all, 0.1 <= #1/#2 < 10 or so due to normalization (no matter, which)
1320 \edef\pgfmathfloat@arga{#1}%
1321 \pgfmathfloattoextentedprecision@a{\pgfmathfloat@arga}%
1322 \let\pgfmathfloat@arga=\pgfmathresult
1323 %
1324 \edef\pgfmathfloat@argb{#2}%
1325 \pgfmathfloattoextentedprecision@b{\pgfmathfloat@argb}%
1326 \let\pgfmathfloat@argb=\pgfmathresult
1327 %
1328 \pgfmathfloatcomparisontrue% re-use this boolean here to handle special cases.
1329 \ifcase\pgfmathfloat@a@S
1330 % 0
1331 \pgfmathfloatcreate{0}{0.0}{0}%
1332 \pgfmathfloatcomparisonfalse
1333 \or% +
1334 \ifcase\pgfmathfloat@b@S
1335 \pgfmathfloatcreate{4}{0.0}{0}%
1336 \pgfmathfloatcomparisonfalse
1337 \or
1338 \def\pgfmathresult@S{1}%
1339 \or
1340 \def\pgfmathresult@S{2}%
1341 \or
1342 \pgfmathfloatcreate{3}{0.0}{0}%
1343 \pgfmathfloatcomparisonfalse
1344 \else
1345 \pgfmathfloatcreate{0}{0.0}{0}%
1346 \pgfmathfloatcomparisonfalse
1347 \fi
1348 \or% -
1349 \ifcase\pgfmathfloat@b@S
1350 \pgfmathfloatcreate{5}{0.0}{0}%
1351 \pgfmathfloatcomparisonfalse
1352 \or
1353 \def\pgfmathresult@S{2}%
1354 \or
1355 \def\pgfmathresult@S{1}%
1356 \or
1357 \pgfmathfloatcreate{3}{0.0}{0}%
1358 \pgfmathfloatcomparisonfalse
1359 \else
1360 \pgfmathfloatcreate{0}{0.0}{0}%
1361 \pgfmathfloatcomparisonfalse
1362 \fi
1363 \or% nan
1364 \pgfmathfloatcreate{3}{0.0}{0}%
1365 \pgfmathfloatcomparisonfalse
1366 \or% +infty
1367 \ifcase\pgfmathfloat@b@S
1368 \pgfmathfloatcreate{4}{0.0}{0}%
1369 \pgfmathfloatcomparisonfalse
1370 \or
1371 \pgfmathfloatcreate{4}{0.0}{0}%
1372 \pgfmathfloatcomparisonfalse
1373 \or
1374 \pgfmathfloatcreate{5}{0.0}{0}%
1375 \pgfmathfloatcomparisonfalse
1376 \or
1377 \pgfmathfloatcreate{3}{0.0}{0}%
1378 \pgfmathfloatcomparisonfalse
1379 \or
1380 \pgfmathfloatcreate{4}{0.0}{0}% what is inf/inf ?
1381 \pgfmathfloatcomparisonfalse
1382 \or
1383 \pgfmathfloatcreate{5}{0.0}{0}% or inf/-inf ?
1384 \pgfmathfloatcomparisonfalse
1385 \fi
1386 \or% -infty
1387 \ifcase\pgfmathfloat@b@S
1388 \pgfmathfloatcreate{5}{0.0}{0}%
1389 \pgfmathfloatcomparisonfalse
1390 \or
1391 \pgfmathfloatcreate{5}{0.0}{0}%
1392 \pgfmathfloatcomparisonfalse
1393 \or
1394 \pgfmathfloatcreate{4}{0.0}{0}%
1395 \pgfmathfloatcomparisonfalse
1396 \or
1397 \pgfmathfloatcreate{3}{0.0}{0}%
1398 \pgfmathfloatcomparisonfalse
1399 \or
1400 \pgfmathfloatcreate{5}{0.0}{0}%
1401 \pgfmathfloatcomparisonfalse
1402 \or
1403 \pgfmathfloatcreate{4}{0.0}{0}%
1404 \pgfmathfloatcomparisonfalse
1405 \fi
1406 \fi
1407 \ifpgfmathfloatcomparison
1408 \pgfmath@basic@divide@{\pgfmathfloat@arga}{\pgfmathfloat@argb}%
1409 \advance\pgfmathfloat@a@E by-\pgfmathfloat@b@E
1410 % renormalize. This is the only part were an expensive float routine comes into play:
1411 \edef\pgfmathresult{\pgfmathresult e\the\pgfmathfloat@a@E}%
1412 \expandafter\pgfmathfloatqparsenumber\expandafter{\pgfmathresult}%
1413 % And re-insert the proper sign:
1414 \expandafter\pgfmathfloat@decompose@tok\pgfmathresult\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
1415 \pgfmathfloatcreate{\pgfmathresult@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
1416 \fi
1417 \pgfmath@smuggleone\pgfmathresult
1418 \endgroup
1419 }%
1420 \let\pgfmathfloatdivide=\pgfmathfloatdivide@
1421
1422 \def\pgfmathfloatreciprocal@#1{%
1423 \begingroup
1424 % FIXME optimize
1425 \edef\pgfmathfloat@loc@TMPa{#1}%
1426 \pgfmathfloatcreate{1}{1.0}{0}%
1427 \pgfmathfloatdivide@{\pgfmathresult}{\pgfmathfloat@loc@TMPa}%
1428 \pgfmath@smuggleone\pgfmathresult
1429 \endgroup
1430 }%
1431
1432 % Computes sqrt(#1) in floating point arithmetics.
1433 %
1434 % It employs sqrt( m * 10^e ) = sqrt(m) * sqrt(10^e).
1435 \def\pgfmathfloatsqrt@#1{%
1436 \begingroup
1437 \pgfmathfloatsetextprecision{3}%
1438 \edef\pgfmathfloat@arga{#1}%
1439 \pgfmathfloattoextentedprecision@a{\pgfmathfloat@arga}%
1440 \let\pgfmathfloat@arga=\pgfmathresult
1441 %
1442 \ifcase\pgfmathfloat@a@S
1443 % 0
1444 \pgfmathfloatcreate{0}{0.0}{0}%
1445 \or% +
1446 \pgfmath@basic@sqrt@{\pgfmathfloat@arga}%
1447 \ifodd\pgfmathfloat@a@E
1448 \ifnum\pgfmathfloat@a@E>0
1449 \expandafter\pgfmath@basic@multiply@\expandafter{\pgfmathresult}{3.16227766}% * sqrt(10)
1450 \else
1451 \expandafter\pgfmath@basic@multiply@\expandafter{\pgfmathresult}{0.316227766}% * sqrt(0.1)
1452 \fi
1453 \fi
1454 \divide\pgfmathfloat@a@E by2 % sqrt(10^e) = 10^{e/2} (see above for odd e)
1455 % renormalize sum. This is the only part were an expensive routine comes into play:
1456 \edef\pgfmathfloat@arga{\pgfmathresult e\the\pgfmathfloat@a@E}%
1457 \pgfmathfloatqparsenumber{\pgfmathfloat@arga}%
1458 \or% -
1459 \pgfmathfloatcreate{3}{0.0}{0}%
1460 \or% nan
1461 \pgfmathfloatcreate{3}{0.0}{0}%
1462 \or% +infty
1463 \pgfmathfloatcreate{4}{0.0}{0}%
1464 \or% -infty
1465 \pgfmathfloatcreate{3}{0.0}{0}%
1466 \fi
1467 \pgfmath@smuggleone\pgfmathresult
1468 \endgroup
1469 }%
1470 \let\pgfmathfloatsqrt=\pgfmathfloatsqrt@
1471
1472 % Returns the integer part of the floating point number #1.
1473 %
1474 % The result is returned as floating point as well.
1475 %
1476 % This operation is not limited to TeX's range of count registers (it
1477 % works symbolly)
1478 %
1479 % @see \pgfmathfloattoint
1480 % POSTCONDITION: \pgfmathresult contains the result and
1481 % \pgfmathfloatintwasnoop=1 if there was nothing to do
1482 % \pgfmathfloatintwasnoop=0 if there where non-zero digits after the period
1483 % \pgfmathfloatintwasnoop=2 if there where digits after the period. The digits will be stored in \pgfmathfloatintremainder in this case.
1484 \def\pgfmathfloatint@#1{%
1485 \begingroup
1486 \edef\pgfmathfloatint@input{#1}%
1487 \expandafter\pgfmathfloat@decompose@tok\pgfmathfloatint@input\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
1488 \gdef\pgfmathfloatintwasnoop{1}%
1489 \gdef\pgfmathfloatintremainder{}%
1490 \ifcase\pgfmathfloat@a@S
1491 % 0: nothing to do.
1492 \or% +
1493 \expandafter\pgfmathfloatint@@\the\pgfmathfloat@a@Mtok\pgfmathfloat@EOI
1494 \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
1495 \or% -
1496 \expandafter\pgfmathfloatint@@\the\pgfmathfloat@a@Mtok\pgfmathfloat@EOI
1497 \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
1498 \else
1499 % nothing to do
1500 \fi
1501 %\message{ XXXXX int(\pgfmathfloatint@input) = \pgfmathresult -> was no op = \pgfmathfloatintwasnoop\space (remainder \pgfmathfloatintremainder)^^J}%
1502 \pgfmath@smuggleone\pgfmathresult
1503 \endgroup
1504 }%
1505 \def\pgfmathfloatint@@#1.{%
1506 \ifnum\pgfmathfloat@a@E<0
1507 \pgfmathfloat@a@S=0
1508 \pgfmathfloat@a@Mtok={0.0}%
1509 \pgfmathfloat@a@E=0
1510 \gdef\pgfmathfloatintwasnoop{0}%
1511 \expandafter\pgfmathfloatint@@loop@gobble
1512 \else
1513 \pgfmathfloat@a@Mtok={#1.}%
1514 \pgfmathfloat@b@E=\pgfmathfloat@a@E
1515 \expandafter\pgfmathfloatint@@loop
1516 \fi
1517 }%
1518 \def\pgfmathfloatint@@loop#1{%
1519 \def\pgfmathfloatint@@loop@{#1}%
1520 \ifx\pgfmathfloatint@@loop@\pgfmathfloat@EOI
1521 \gdef\pgfmathfloatintwasnoop{1}%
1522 \let\pgfmathfloatint@@loop@next=\relax
1523 \else
1524 \ifnum\pgfmathfloat@b@E=0
1525 \def\pgfmathfloatint@@loop@next{\pgfmathfloatint@@loop@gobble#1}%
1526 \else
1527 \pgfmathfloat@a@Mtok=\expandafter{\the\pgfmathfloat@a@Mtok#1}%
1528 \advance\pgfmathfloat@b@E by-1
1529 \let\pgfmathfloatint@@loop@next=\pgfmathfloatint@@loop
1530 \fi
1531 \fi
1532 \pgfmathfloatint@@loop@next
1533 }%
1534 \def\pgfmathfloatint@@loop@gobble#1\pgfmathfloat@EOI{%
1535 \if0\pgfmathfloatintwasnoop
1536 \else
1537 \gdef\pgfmathfloatintwasnoop{2}%
1538 \gdef\pgfmathfloatintremainder{#1}%
1539 \fi
1540 }%
1541 \let\pgfmathfloatint=\pgfmathfloatint@
1542
1543 \def\pgfmathfloatfloor#1{%
1544 \edef\pgfmath@orig{#1}%
1545 \pgfmathfloatint@{#1}%
1546 \pgfmathfloatifflags{\pgfmath@orig}{2}{%
1547 \let\pgfmath@trunc=\pgfmathresult
1548 \ifcase\pgfmathfloatintwasnoop\relax
1549 % ah - we stripped something! Round DOWN
1550 \pgfmathfloatcreate{2}{1.0}{0}% -1
1551 \expandafter\pgfmathfloatadd@\expandafter{\pgfmathresult}{\pgfmath@trunc}%
1552 \or
1553 % was no-op
1554 \let\pgfmathresult=\pgfmath@trunc
1555 \else
1556 % ok, we have to inspect the remainder:
1557 \pgfmathfloatparsenumber{0.\pgfmathfloatintremainder}%
1558 \pgfmathfloatifflags{\pgfmathresult}{1}{%
1559 % ah - we stripped a non-zero remainder! Round DOWN
1560 \pgfmathfloatcreate{2}{1.0}{0}% -1
1561 \expandafter\pgfmathfloatadd@\expandafter{\pgfmathresult}{\pgfmath@trunc}%
1562 }{%
1563 % was no-op
1564 \let\pgfmathresult=\pgfmath@trunc
1565 }%
1566 \fi
1567 }{}%
1568 }
1569 \let\pgfmathfloatfloor@=\pgfmathfloatfloor
1570
1571 \def\pgfmathfloatceil#1{%
1572 \edef\pgfmath@orig{#1}%
1573 \pgfmathfloatint@{#1}%
1574 \pgfmathfloatifflags{\pgfmath@orig}{1}{%
1575 \let\pgfmath@trunc=\pgfmathresult
1576 \ifcase\pgfmathfloatintwasnoop\relax
1577 % ah - we stripped something! Round UP
1578 \pgfmathfloatcreate{1}{1.0}{0}% +1
1579 \expandafter\pgfmathfloatadd@\expandafter{\pgfmathresult}{\pgfmath@trunc}%
1580 \or
1581 % was no-op
1582 \let\pgfmathresult=\pgfmath@trunc
1583 \else
1584 % ok, we have to inspect the remainder:
1585 \pgfmathfloatparsenumber{0.\pgfmathfloatintremainder}%
1586 \pgfmathfloatifflags{\pgfmathresult}{1}{%
1587 % ah - we stripped a non-zero remainder! Round UP
1588 \pgfmathfloatcreate{1}{1.0}{0}% +1
1589 \expandafter\pgfmathfloatadd@\expandafter{\pgfmathresult}{\pgfmath@trunc}%
1590 }{%
1591 % was no-op
1592 \let\pgfmathresult=\pgfmath@trunc
1593 }%
1594 \fi
1595 }{}%
1596 }
1597 \let\pgfmathfloatceil@=\pgfmathfloatceil
1598
1599 \def\pgfmathfloat@notimplemented#1{%
1600 \pgfmath@error{Sorry, the operation '#1' has not yet been implemented in the floating point unit}{}%
1601 \pgfmathfloatcreate{0}{0.0}{0}%
1602 }%
1603
1604 % Divides or multiplies the input number by 10^#4 using an arithmetic
1605 % left/right shift.
1606 %
1607 % Input:
1608 % #1 a normalised floating point number.
1609 % #2 a positive or negative integer number denoting the shift.
1610 %
1611 % Example:
1612 % \pgfmathfloatshift{11e3}{4}%
1613 % -> pgfmathresult = 11e7
1614 \def\pgfmathfloatshift@#1#2{%
1615 \begingroup
1616 \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
1617 \advance\pgfmathfloat@a@E by#2\relax
1618 \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
1619 \pgfmath@smuggleone\pgfmathresult
1620 \endgroup
1621 }
1622 \let\pgfmathfloatshift=\pgfmathfloatshift@
1623
1624 % Defines \pgfmathresult to be |#1|, the absolute value of the
1625 % normalized floating point number #1.
1626 \def\pgfmathfloatabs@#1{%
1627 \begingroup
1628 \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
1629 \ifcase\pgfmathfloat@a@S
1630 % 0: do nothing.
1631 \or
1632 % +: ok, is positive.
1633 \or
1634 % -: multiply with -1:
1635 \pgfmathfloat@a@S=1
1636 \or
1637 % nan: do nothing.
1638 \or
1639 % +infty: ok.
1640 \or
1641 % -infty: multiply with -1:
1642 \pgfmathfloat@a@S=4
1643 \fi
1644 \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
1645 \pgfmath@smuggleone\pgfmathresult
1646 \endgroup
1647 }%
1648 %
1649 % Defines \pgfmathresult to be sign(#1)
1650 \def\pgfmathfloatsign@#1{%
1651 \begingroup
1652 \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
1653 \ifcase\pgfmathfloat@a@S
1654 % 0:
1655 \pgfmathfloatcreate{0}{0.0}{0}%
1656 \or
1657 % +: ok, is positive.
1658 \pgfmathfloatcreate{1}{1.0}{0}%
1659 \or
1660 % -:
1661 \pgfmathfloatcreate{2}{1.0}{0}%
1662 \or
1663 % nan: do nothing.
1664 \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
1665 \or
1666 % +infty:.
1667 \pgfmathfloatcreate{1}{1.0}{0}%
1668 \or
1669 % -infty:
1670 \pgfmathfloatcreate{2}{1.0}{0}%
1671 \fi
1672 \pgfmath@smuggleone\pgfmathresult
1673 \endgroup
1674 }%
1675 \let\pgfmathfloatsign=\pgfmathfloatsign@
1676
1677 % Computes the absolute error |#1 - #2| into \pgfmathresult.
1678 \def\pgfmathfloatabserror@#1#2{%
1679 \pgfmathfloatsubtract@{#1}{#2}%
1680 \pgfmathfloatabs@{\pgfmathresult}%
1681 }%
1682 \let\pgfmathfloatabserror=\pgfmathfloatabserror@
1683
1684 % Computes the relative error |#1 - #2|/|#2| into \pgfmathresult,
1685 % assuming #2 != 0.
1686 \def\pgfmathfloatrelerror@#1#2{%
1687 \pgfmathfloatsubtract@{#1}{#2}%
1688 \let\pgfmathfloat@subtract=\pgfmathresult
1689 \pgfmathfloatifflags{#2}{0}{%
1690 \let\pgfmathresult=\pgfmathfloat@subtract
1691 }{%
1692 \pgfmathfloatdivide@{\pgfmathfloat@subtract}{#2}%
1693 }%
1694 \pgfmathfloatabs@{\pgfmathresult}%
1695 }%
1696 \let\pgfmathfloatrelerror=\pgfmathfloatrelerror@
1697
1698 % Computes \pgfmathresult = #1 mod #2 using truncated division.
1699 %
1700 \def\pgfmathfloatmod@#1#2{%
1701 \begingroup
1702 \pgfmathfloattoint{#1}%
1703 \let\pgfmathfloat@loc@TMPa=\pgfmathresult
1704 \pgfmathfloattoint{#2}%
1705 \let\pgfmathfloat@loc@TMPb=\pgfmathresult
1706 \c@pgfmath@counta=\pgfmathfloat@loc@TMPa\relax
1707 \divide\c@pgfmath@counta by\pgfmathfloat@loc@TMPb\relax
1708 \expandafter\pgfmathfloatparsenumber\expandafter{\the\c@pgfmath@counta}%
1709 %
1710 \let\pgfmathfloat@loc@TMPa=\pgfmathresult
1711 \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{#2}%
1712 \let\pgfmathfloat@loc@TMPb=\pgfmathresult
1713 \pgfmathfloatsubtract@{#1}{\pgfmathfloat@loc@TMPb}%
1714 \pgfmath@smuggleone\pgfmathresult
1715 \endgroup
1716 }
1717 \let\pgfmathfloatmod=\pgfmathfloatmod@
1718
1719
1720 % A modification of \pgfmathfloatmod@ where #3 = 1/#2 is already
1721 % known. This may be faster.
1722 \def\pgfmathfloatmodknowsinverse@#1#2#3{%
1723 \pgfmathfloatmod@{#1}{#2}%
1724 %--------------------------------------------------
1725 % \begingroup
1726 % % FIXME : is this function correct? \pgfmathfloatmod had a
1727 % % rounding flaw...
1728 % \pgfmathfloatmultiply@{#1}{#3}%
1729 % \pgfmathfloatint@{\pgfmathresult}%
1730 % \let\pgfmathfloat@loc@TMPa=\pgfmathresult
1731 % \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{#2}%
1732 % \let\pgfmathfloat@loc@TMPb=\pgfmathresult
1733 % \pgfmathfloatsubtract@{#1}{\pgfmathfloat@loc@TMPb}%
1734 % \pgfmath@smuggleone\pgfmathresult
1735 % \endgroup
1736 %--------------------------------------------------
1737 }
1738 \let\pgfmathfloatmodknowsinverse=\pgfmathfloatmodknowsinverse@
1739
1740 \def\pgfmathfloatpi@{%
1741 \pgfmathfloatcreate{1}{3.14159265358979}{0}%
1742 }%
1743 \let\pgfmathfloatpi=\pgfmathfloatpi@
1744
1745 \def\pgfmathfloate@{%
1746 \pgfmathfloatcreate{1}{2.71828182845905}{0}%
1747 }
1748 \let\pgfmathfloate=\pgfmathfloate@
1749
1750 % Converts #1 from radians to degrees.
1751 \def\pgfmathfloatdeg@#1{%
1752 \expandafter\ifx\csname pgfmfltdeg@factor\endcsname\relax
1753 % Lazy evaluation:
1754 \pgfmathfloatcreate{1}{5.72957795130823}{1}%
1755 \global\let\pgfmfltdeg@factor=\pgfmathresult
1756 \fi
1757 \pgfmathfloatmultiply@{#1}\pgfmfltdeg@factor%
1758 }
1759 \let\pgfmathfloatdeg=\pgfmathfloatdeg@
1760
1761 % Converts #1 from degree to radians.
1762 \def\pgfmathfloatrad@#1{%
1763 \expandafter\ifx\csname pgfmfltrad@factor\endcsname\relax
1764 % Lazy evaluation:
1765 \pgfmathfloatcreate{1}{1.74532925199433}{-2}%
1766 \global\let\pgfmfltrad@factor=\pgfmathresult
1767 \fi
1768 \pgfmathfloatmultiply@{#1}\pgfmfltrad@factor%
1769 }
1770 \let\pgfmathfloatrad=\pgfmathfloatrad@
1771
1772 % Computes #1(#2) where #1 is a trigonometric function, i.e.
1773 % #1(#2) = #1( #2 + r*360 )
1774 %
1775 % #1 is a one-argument macro which assigns \pgfmathresult.
1776 \def\pgfmathfloatTRIG@#1#2{%
1777 \if0\pgfmath@trig@format@choice
1778 % trig format=deg
1779 \expandafter\ifx\csname pgfmathfloatTRIG@NUM\endcsname\relax%
1780 % Lazy evaluation:
1781 \pgfmathfloatcreate{1}{3.6}{2}%
1782 \global\let\pgfmathfloatTRIG@NUM=\pgfmathresult
1783 \pgfmathfloatcreate{1}{2.77777777777778}{-3}%
1784 \global\let\pgfmathfloatTRIG@NUM@INV=\pgfmathresult
1785 \fi
1786 \pgfmathfloatmodknowsinverse@{#2}{\pgfmathfloatTRIG@NUM}{\pgfmathfloatTRIG@NUM@INV}%
1787 \else
1788 % trig format=rad
1789 \expandafter\ifx\csname pgfmathfloatTRIG@rad@NUM\endcsname\relax%
1790 % Lazy evaluation:
1791 \pgfmathfloatcreate{1}{6.28318530717959}{0}%
1792 \global\let\pgfmathfloatTRIG@rad@NUM=\pgfmathresult
1793 \pgfmathfloatcreate{1}{1.59154943091895}{-1}%
1794 \global\let\pgfmathfloatTRIG@rad@NUM@INV=\pgfmathresult
1795 \fi
1796 \pgfmathfloatmodknowsinverse@{#2}{\pgfmathfloatTRIG@rad@NUM}{\pgfmathfloatTRIG@rad@NUM@INV}%
1797 \fi
1798 \pgfmathfloattofixed@{\pgfmathresult}%
1799 \expandafter#1\expandafter{\pgfmathresult}%
1800 \pgfmathfloatparsenumber{\pgfmathresult}%
1801 }%
1802
1803 \def\pgfmathfloatsin@#1{\pgfmathfloatTRIG@\pgfmath@basic@sin@{#1}}
1804 \let\pgfmathfloatsin=\pgfmathfloatsin@
1805 \def\pgfmathfloatcos@#1{\pgfmathfloatTRIG@\pgfmath@basic@cos@{#1}}
1806 \let\pgfmathfloatcos=\pgfmathfloatcos@
1807 \def\pgfmathfloattan@#1{%
1808 % compute sin(#1) / cos(#1)
1809 \begingroup
1810 \pgfmathfloatcos@{#1}%
1811 \let\pgfmathfloat@loc@TMPa=\pgfmathresult
1812 \pgfmathfloatsin@{#1}%
1813 \expandafter\pgfmathfloatdivide@\expandafter{\pgfmathresult}{\pgfmathfloat@loc@TMPa}%
1814 \pgfmath@smuggleone\pgfmathresult
1815 \endgroup
1816 }
1817 \let\pgfmathfloattan=\pgfmathfloattan@
1818
1819 \def\pgfmathfloatcot@#1{%
1820 % compute cos(#1) / sin(#1)
1821 \begingroup
1822 \pgfmathfloatsin@{#1}%
1823 \let\pgfmathfloat@loc@TMPa=\pgfmathresult
1824 \pgfmathfloatcos@{#1}%
1825 \expandafter\pgfmathfloatdivide@\expandafter{\pgfmathresult}{\pgfmathfloat@loc@TMPa}%
1826 \pgfmath@smuggleone\pgfmathresult
1827 \endgroup
1828 }%
1829 \let\pgfmathfloatcot=\pgfmathfloatcot@
1830
1831 \def\pgfmathfloatatan@#1{%
1832 \begingroup
1833 \expandafter\ifx\csname pgfmathfloatatan@TMP\endcsname\relax%
1834 \pgfmathfloatcreate{1}{1.6}{4}%
1835 \global\let\pgfmathfloatatan@TMP=\pgfmathresult
1836 \pgfmathfloatcreate{2}{1.6}{4}%
1837 \global\let\pgfmathfloatatan@TMPB=\pgfmathresult
1838 \fi
1839 \pgfmathfloatgreaterthan@{#1}{\pgfmathfloatatan@TMP}%
1840 \ifpgfmathfloatcomparison
1841 \pgfmathiftrigonometricusesdeg{%
1842 \pgfmathfloatcreate{1}{9.0}{1}%
1843 }{%
1844 \pgfmathfloatcreate{1}{1.570796326794}{0}%
1845 }%
1846 \else
1847 \pgfmathfloatlessthan{#1}{\pgfmathfloatatan@TMPB}%
1848 \ifpgfmathfloatcomparison
1849 \pgfmathiftrigonometricusesdeg{%
1850 \pgfmathfloatcreate{2}{9.0}{1}%
1851 }{%
1852 \pgfmathfloatcreate{2}{1.570796326794}{0}%
1853 }%
1854 \else
1855 \pgfmathfloattofixed@{#1}%
1856 \expandafter\pgfmath@basic@atan@\expandafter{\pgfmathresult}%
1857 \pgfmathfloatparsenumber{\pgfmathresult}%
1858 \fi
1859 \fi
1860 \pgfmath@smuggleone\pgfmathresult
1861 \endgroup
1862 }%
1863 \let\pgfmathfloatatan=\pgfmathfloatatan@
1864
1865 \def\pgfmathfloatatantwo#1#2{%
1866 % Note: first parameter is y (!), second is x (!)
1867 \begingroup%
1868 \let\pgfmath@trig@format@choice@@=\pgfmath@trig@format@choice
1869 \def\pgfmath@trig@format@choice{0}%
1870 %
1871 \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
1872 \expandafter\pgfmathfloat@decompose#2\relax\pgfmathfloat@b@S\pgfmathfloat@b@M\pgfmathfloat@b@E
1873 \ifnum\pgfmathfloat@a@S=0
1874 % ok, #1 = 0. Substitute by 1e-16 such that the next \ifnum catches it:
1875 \pgfmathfloat@a@E=-16 %
1876 \fi
1877 %
1878 \ifnum\pgfmathfloat@a@E<-3 %
1879 \ifnum\pgfmathfloat@b@S=2 %
1880 % #2 < 0
1881 \pgfmathfloatcreate{1}{1.8}{2}% +180
1882 \else
1883 \ifnum\pgfmathfloat@b@S=1 %
1884 % #2 >0
1885 \pgfmathfloatcreate{0}{0.0}{0}%
1886 \else
1887 % + or - 90, just use the sign of #1:
1888 \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{9.0}{1}%
1889 \fi
1890 \fi
1891 \else%
1892 \pgfmathfloatabs@{#1}\let\pgfmath@tempa\pgfmathresult%
1893 \pgfmathfloatabs@{#2}\let\pgfmath@tempb\pgfmathresult%
1894 \pgfmathfloatgreaterthan@{\pgfmath@tempa}{\pgfmath@tempb}%
1895 \ifpgfmathfloatcomparison
1896 \pgfmathfloatdivide@{#2}{\pgfmath@tempa}%
1897 \expandafter\pgfmathfloatatan@\expandafter{\pgfmathresult}%
1898 \let\pgfmath@tempa=\pgfmathresult
1899 \pgfmathfloatcreate{1}{9.0}{1}%
1900 \let\pgfmath@tempb=\pgfmathresult
1901 \pgfmathfloatsubtract@{\pgfmath@tempb}{\pgfmath@tempa}%
1902 \else%
1903 \pgfmathfloatdivide@{\pgfmath@tempa}{#2}%
1904 \expandafter\pgfmathfloatatan@\expandafter{\pgfmathresult}%
1905 \expandafter\pgfmathfloatifflags\expandafter{\pgfmathresult}{2}{%
1906 \let\pgfmath@tempa=\pgfmathresult
1907 \pgfmathfloatcreate{1}{1.8}{2}%
1908 \let\pgfmath@tempb=\pgfmathresult
1909 \pgfmathfloatadd@{\pgfmath@tempa}{\pgfmath@tempb}%
1910 }{}%
1911 \fi%
1912 %
1913 \pgfmathfloatifflags{#1}{-}{%
1914 % #1 < 0:
1915 \pgfmathfloatmultiplyfixed@{\pgfmathresult}{-1}%
1916 }{}%
1917 \fi%
1918 \if1\pgfmath@trig@format@choice@@
1919 % trig format=rad
1920 \pgfmathfloat@scale@deg@to@rad\pgfmathresult
1921 \fi
1922 \pgfmath@smuggleone\pgfmathresult%
1923 \endgroup%
1924 }%
1925 \let\pgfmathfloatatantwo@=\pgfmathfloatatantwo
1926 \expandafter\let\csname pgfmathfloatatan2\endcsname=\pgfmathfloatatantwo
1927 \expandafter\let\csname pgfmathfloatatan2@\endcsname=\pgfmathfloatatantwo@
1928
1929 \def\pgfmathfloat@scale@deg@to@rad#1{%
1930 \edef\pgfmathfloat@loc@TMPb{#1}%
1931 \pgfmathfloatcreate{1}{1.74532925199433}{-2}% = pi / 180
1932 \pgfmathfloatmultiply@{\pgfmathresult}{\pgfmathfloat@loc@TMPb}%
1933 }%
1934
1935 \def\pgfmathfloatsec@#1{\pgfmathfloatTRIG@\pgfmath@basic@cos@{#1}\pgfmathfloatreciprocal@{\pgfmathresult}}
1936 \let\pgfmathfloatsec=\pgfmathfloatsec@
1937 \def\pgfmathfloatcosec@#1{\pgfmathfloatTRIG@\pgfmath@basic@sin@{#1}\pgfmathfloatreciprocal@{\pgfmathresult}}
1938 \let\pgfmathfloatcosec=\pgfmathfloatcosec@
1939
1940 % Expands #2 using \edef and invokes #1 with the resulting string.
1941 %
1942 % DEPRECATED
1943 % Example:
1944 % \pgfmath@y=7.9pt
1945 % \pgfmathlog@invoke@expanded\pgfmathexp@{{\pgf@sys@tonumber{\pgfmath@y}}}%
1946 % will invoke
1947 % \pgfmathexp@{7.9}
1948 \def\pgfmathlog@invoke@expanded#1#2{%
1949 \edef\pgfmath@resulttemp{#2}%
1950 \expandafter#1\pgfmath@resulttemp
1951 }
1952
1953 \def\pgfmathfloatln@#1{%
1954 \pgfmathlog@float{#1}%
1955 \ifx\pgfmathresult\pgfutil@empty
1956 \pgfmathfloatcreate{3}{0.0}{0}%
1957 \else
1958 \pgfmathfloatparsenumber{\pgfmathresult}%
1959 \fi
1960 }
1961 \let\pgfmathfloatln=\pgfmathfloatln@
1962
1963 \expandafter\def\csname pgfmathfloatlog10@\endcsname#1{%
1964 \pgfmathfloatln@{#1}%
1965 \let\pgfmathfloat@log@e=\pgfmathresult
1966 \pgfmathfloatcreate{1}{4.34294481903252}{-1}% 1/ln(10)
1967 \pgfmathfloatmultiply@{\pgfmathresult}{\pgfmathfloat@log@e}%
1968 }%
1969 \pgfutil@namelet{pgfmathfloatlog10}{pgfmathfloatlog10@}%
1970
1971 \expandafter\def\csname pgfmathfloatlog2@\endcsname#1{%
1972 \pgfmathfloatln@{#1}%
1973 \let\pgfmathfloat@log@e=\pgfmathresult
1974 \pgfmathfloatcreate{1}{1.44269504088896}{0}% 1/ln(2)
1975 \pgfmathfloatmultiply@{\pgfmathresult}{\pgfmathfloat@log@e}%
1976 }%
1977 \pgfutil@namelet{pgfmathfloatlog2}{pgfmathfloatlog2@}%
1978
1979 \expandafter\let\expandafter\pgfmathfloatlogtwo\csname pgfmathfloatlog2\endcsname
1980 \expandafter\let\expandafter\pgfmathfloatlogtwo@\csname pgfmathfloatlog2@\endcsname
1981 \expandafter\let\expandafter\pgfmathfloatlogten\csname pgfmathfloatlog10\endcsname
1982 \expandafter\let\expandafter\pgfmathfloatlogten@\csname pgfmathfloatlog10@\endcsname
1983
1984 % Computes log(x) into \pgfmathresult.
1985 %
1986 % This allows numbers such at 10000000 or 5.23e-10 to be represented
1987 % properly, although TeX-registers would produce overflow/underflow
1988 % errors in these cases.
1989 %
1990 % The natural logarithm is computed using log(X*10^Y) = log(X) + log(10)*Y
1991 %
1992 % FIXME This routine is only kept for backwards compatibility!
1993 % It does not work as expected because
1994 % 1. it calls \pgfmathfloatparsenumber
1995 % 2. it returns the result as fixed point number
1996 % Use \pgfmathln@ instead!
1997 \def\pgfmathlog@#1{%
1998 \pgfmathfloatparsenumber{#1}%
1999 \pgfmathlog@float{\pgfmathresult}%
2000 }
2001 \let\pgfmathlog=\pgfmathlog@
2002 \def\pgfmathlog@float#1{%
2003 \begingroup%
2004 % compute #1 = M*10^E with normalised mantisse M = [+-]*[1-9].XXXXX
2005 \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
2006 \ifnum\pgfmathfloat@a@S=1
2007 % Now, compute log(#1) = log(M) + E*log(10)
2008 \expandafter\pgfmath@basic@ln@\expandafter{\the\pgfmathfloat@a@Mtok}%
2009 \pgfmathfloat@b@M=\pgfmathresult pt%
2010 \pgfmathfloat@a@M=2.302585pt% = log(10)
2011 \multiply\pgfmathfloat@a@M by\pgfmathfloat@a@E\relax
2012 \advance\pgfmathfloat@b@M by\pgfmathfloat@a@M
2013 \edef\pgfmathresult{\pgf@sys@tonumber{\pgfmathfloat@b@M}}%
2014 \else
2015 \let\pgfmathresult=\pgfutil@empty%
2016 \fi
2017 \pgfmath@smuggleone\pgfmathresult
2018 \endgroup%
2019 }
2020
2021
2022 % Computes exp(#1) in floating point.
2023 %
2024 % The algorithm employs the identity
2025 % exp(x) = exp(x - log(10^k) + log(10^k)
2026 % = 10^k exp( x - k*log 10 )
2027 % with k choosen such that exp( x - k*log10) can be computed with the
2028 % basic level math engine.
2029 %
2030 % The precision (relative error) is between 10^{-4} and 10^{-6}. For
2031 % #1 = 700, it is even 10^{-3}. I will need to improve that someday.
2032 \def\pgfmathfloatexp@#1{%
2033 \begingroup
2034 \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
2035 \ifcase\pgfmathfloat@a@S
2036 % #1 = 0:
2037 \pgfmathfloatcreate{1}{1.0}{0}%
2038 \or% #1 > 0
2039 \pgfmathfloatexp@@{#1}%
2040 \or% #1 < 0
2041 \pgfmathfloatexp@@{#1}%
2042 \else
2043 \edef\pgfmathresult{#1}%
2044 \fi
2045 \pgfmath@smuggleone\pgfmathresult
2046 \endgroup
2047 }%
2048 \def\pgfmathfloatexp@@#1{%
2049 % Employ the identity
2050 % exp(x) = exp(x - log(10^k) + log(10^k)) = 10^k exp( x - k *log(10))
2051 %
2052 % I'd like to have x - k*log(10) <= 1
2053 % => compute k := int( (x - 1) * 1/log(10) )
2054 % that should suffice since \pgfmathexp@ should be
2055 % accurate enough for those numbers.
2056 %
2057 % please note that we can do all this in TeX registers.
2058 % exp(700) is almost the maximum of double precision
2059 % anyway, and exp(16000) is certainly the largest we will
2060 % ever need.
2061 \pgfmathfloattofixed@{#1}%
2062 \pgf@xa=\pgfmathresult pt
2063 \pgf@xa=0.434294481\pgf@xa\relax
2064 \edef\pgfmathfloat@loc@TMPa{\pgf@sys@tonumber{\pgf@xa}}%
2065 \expandafter\pgfmathfloatexp@@toint\pgfmathfloat@loc@TMPa\relax
2066 \pgf@xa=2.302585092pt
2067 \multiply\pgf@xa by-\pgfmathfloat@k\relax
2068 \advance\pgf@xa by\pgfmathresult pt
2069 \edef\pgfmathfloat@loc@TMPa{\pgf@sys@tonumber{\pgf@xa}}%
2070 %\message{computing exp(\pgfmathresult) = 10^\pgfmathfloat@k * exp(\pgfmathfloat@loc@TMPa)...}%
2071 \pgfmath@basic@exp@{\pgfmathfloat@loc@TMPa}%
2072 \let\pgfmathfloat@loc@TMPa=\pgfmathresult
2073 \pgfmathfloatparsenumber{\pgfmathfloat@loc@TMPa}%
2074 \let\pgfmathfloat@loc@TMPa=\pgfmathresult
2075 \pgfmathfloatshift@{\pgfmathfloat@loc@TMPa}{\pgfmathfloat@k}%
2076 }
2077 % determine 'k'. This is a heuristics. The exponential series
2078 % converges best for |x| <= 1. However, the fixed point arithmetics
2079 % for tex results in best results for large |x|. Well, I'll need to
2080 % tune this here.
2081 \def\pgfmathfloatexp@@toint#1.#2\relax{%
2082 \c@pgf@counta=#1\relax
2083 \ifnum\c@pgf@counta<0
2084 \advance\c@pgf@counta by-1 % FIXME . this is a test for optimizations.
2085 \c@pgf@countb=#2\relax
2086 \ifnum\c@pgf@countb>0
2087 \advance\c@pgf@counta by-1
2088 \fi
2089 \fi
2090 \edef\pgfmathfloat@k{\the\c@pgf@counta}%
2091 }%
2092 \let\pgfmathfloatexp=\pgfmathfloatexp@
2093
2094 \def\pgfmathfloatround@#1{%
2095 \begingroup
2096 \pgfkeysvalueof{/pgf/number format/precision/.@cmd}0\pgfeov
2097 \pgfmathfloattofixed{#1}%
2098 \pgfmathroundto{\pgfmathresult}%
2099 \pgfmathfloatparsenumber{\pgfmathresult}%
2100 \pgfmath@smuggleone\pgfmathresult
2101 \endgroup
2102 }%
2103
2104
2105 \def\pgfmathfloatneg@#1{%
2106 \begingroup
2107 \expandafter\pgfmathfloat@decompose@tok#1\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
2108 \ifcase\pgfmathfloat@a@S\relax
2109 % 0:
2110 \edef\pgfmathresult{#1}%
2111 \or
2112 % +:
2113 \pgfmathfloatcreate{2}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
2114 \or
2115 % -:
2116 \pgfmathfloatcreate{1}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
2117 \or
2118 % nan:
2119 \edef\pgfmathresult{#1}%
2120 \or
2121 % +infty:
2122 \pgfmathfloatcreate{5}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
2123 \or
2124 % -infty:
2125 \pgfmathfloatcreate{4}{\the\pgfmathfloat@a@Mtok}{\the\pgfmathfloat@a@E}%
2126 \fi
2127 \pgfmath@smuggleone\pgfmathresult
2128 \endgroup
2129 }%
2130
2131
2132 \def\pgfmathfloatpow@#1#2{%
2133 \begingroup%
2134 \expandafter\pgfmathfloat@decompose@tok#2\relax\pgfmathfloat@a@S\pgfmathfloat@a@Mtok\pgfmathfloat@a@E
2135 \ifcase\pgfmathfloat@a@S\relax
2136 % #1 ^ 0 = 1
2137 \pgfmathfloatcreate{1}{1.0}{0}%
2138 \or
2139 % #2 > 0
2140 \pgfmathfloatpow@@{#1}{#2}%
2141 \or
2142 % #2 < 0
2143 \pgfmathfloatpow@@{#1}{#2}%
2144 \or
2145 % #2 = nan
2146 \edef\pgfmathresult{#2}%
2147 \or
2148 % #2 = inf
2149 \edef\pgfmathresult{#2}%
2150 \or
2151 % #2 = -inf
2152 \pgfmathfloatcreate{0}{0.0}{0}%
2153 \fi
2154 \pgfmath@smuggleone\pgfmathresult
2155 \endgroup
2156 }%
2157
2158 % computes #1^#2
2159 % PRECONDITIONS
2160 % - #2 is positive.
2161 \def\pgfmathfloatpow@@#1#2{%
2162 \pgfmathfloattofixed@{#2}%
2163 \afterassignment\pgfmath@x%
2164 \expandafter\c@pgfmath@counta\pgfmathresult pt\relax%
2165 \ifdim\pgfmath@x=0pt %
2166 % loop "manually"; we have an integer exponent!
2167 \ifnum\c@pgfmath@counta<0
2168 \pgfmathfloatreciprocal@{#1}%
2169 \let\pgfmathfloat@loc@TMPa=\pgfmathresult
2170 \c@pgfmath@counta=-\c@pgfmath@counta
2171 \else
2172 \edef\pgfmathfloat@loc@TMPa{#1}%
2173 \fi
2174 \pgfmathfloatcreate{1}{1.0}{0}%
2175 \let\pgfmathfloat@loc@TMPb=\pgfmathresult
2176 \pgfmathloop
2177 \ifnum\c@pgfmath@counta>0\relax%
2178 \ifodd\c@pgfmath@counta%
2179 \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPb}{\pgfmathfloat@loc@TMPa}%
2180 \let\pgfmathfloat@loc@TMPb=\pgfmathresult
2181 \fi
2182 \ifnum\c@pgfmath@counta>1\relax%
2183 \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{\pgfmathfloat@loc@TMPa}%
2184 \let\pgfmathfloat@loc@TMPa=\pgfmathresult
2185 \fi%
2186 \divide\c@pgfmath@counta by2\relax%
2187 \repeatpgfmathloop%
2188 \else
2189 \pgfmathfloatgetflags{#1}\c@pgfmath@counta
2190 \ifnum0=\c@pgfmath@counta
2191 % ah: 0^x
2192 \pgfmathfloatgetflags{#2}\c@pgfmath@counta
2193 \ifnum0=\c@pgfmath@counta
2194 % ah: 0^0
2195 \pgfmathfloatcreate{1}{1.0}{0}%
2196 \else
2197 % ah: 0^x with x!=0:
2198 \pgfmathfloatcreate{0}{0.0}{0}%
2199 \fi
2200 \else
2201 % employ #1^#2 = exp( #2 * ln(#1) )
2202 \pgfmathfloatln@{#1}%
2203 \let\pgfmathfloat@loc@TMPa=\pgfmathresult
2204 \edef\pgfmathfloat@loc@TMPb{#2}%
2205 \pgfmathfloatmultiply@{\pgfmathfloat@loc@TMPa}{\pgfmathfloat@loc@TMPb}%
2206 \pgfmathfloatexp@{\pgfmathresult}%
2207 \fi
2208 \fi
2209 }
2210
2211 \def\pgfmathfloat@definemethodfrombasic@NOARG#1{%
2212 \pgfutil@ifundefined{pgfmath@basic@#1@}{%
2213 \pgfutil@namelet{pgfmath@basic@#1@}{pgfmath#1@}%
2214 }{}%
2215 \edef\pgfmathfloat@glob@TMP{%
2216 \expandafter\noexpand\csname pgfmath@basic@#1@\endcsname
2217 \noexpand\pgfmathfloatparsenumber{\noexpand\pgfmathresult}%
2218 }%
2219 \expandafter\let\csname pgfmathfloat#1@\endcsname=\pgfmathfloat@glob@TMP%
2220 \expandafter\let\csname pgfmathfloat#1\endcsname=\pgfmathfloat@glob@TMP%
2221 }%
2222 \def\pgfmathfloat@definemethodfrombasic@ONEARG#1{%
2223 \pgfutil@ifundefined{pgfmath@basic@#1@}{%
2224 \pgfutil@namelet{pgfmath@basic@#1@}{pgfmath#1@}%
2225 }{}%
2226 \edef\pgfmathfloat@glob@TMP##1{%
2227 \noexpand\pgfmathfloattofixed{##1}%
2228 \noexpand\expandafter
2229 \expandafter\noexpand\csname pgfmath@basic@#1@\endcsname\noexpand\expandafter%
2230 {\noexpand\pgfmathresult}%
2231 \noexpand\pgfmathfloatparsenumber{\noexpand\pgfmathresult}%
2232 }%
2233 \expandafter\let\csname pgfmathfloat#1@\endcsname=\pgfmathfloat@glob@TMP%
2234 \expandafter\let\csname pgfmathfloat#1\endcsname=\pgfmathfloat@glob@TMP%
2235 }%
2236 \def\pgfmathfloat@definemethodfrombasic@TWOARGS#1{%
2237 \pgfutil@ifundefined{pgfmath@basic@#1@}{%
2238 \pgfutil@namelet{pgfmath@basic@#1@}{pgfmath#1@}%
2239 }{}%
2240 \edef\pgfmathfloat@glob@TMP##1##2{%
2241 \noexpand\pgfmathfloattofixed{##2}%
2242 \noexpand\let\noexpand\pgfmathfloat@loc@TMPa=\noexpand\pgfmathresult
2243 \noexpand\pgfmathfloattofixed{##1}%
2244 \noexpand\expandafter
2245 \expandafter\noexpand\csname pgfmath@basic@#1@\endcsname\noexpand\expandafter%
2246 {\noexpand\pgfmathresult}{\noexpand\pgfmathfloat@loc@TMPa}%
2247 \noexpand\pgfmathfloatparsenumber{\noexpand\pgfmathresult}%
2248 }%
2249 \expandafter\let\csname pgfmathfloat#1@\endcsname=\pgfmathfloat@glob@TMP%
2250 \expandafter\let\csname pgfmathfloat#1\endcsname=\pgfmathfloat@glob@TMP%
2251 }%
2252 \pgfmathfloat@definemethodfrombasic@NOARG{rand}
2253 \pgfmathfloat@definemethodfrombasic@NOARG{rnd}
2254 \pgfmathfloat@definemethodfrombasic@NOARG{false}
2255 \pgfmathfloat@definemethodfrombasic@NOARG{true}
2256 % arcsin, arccos
2257 \pgfmathfloat@definemethodfrombasic@ONEARG{asin}
2258 \pgfmathfloat@definemethodfrombasic@ONEARG{acos}
2259 \pgfmathfloat@definemethodfrombasic@ONEARG{not}
2260 \pgfmathfloat@definemethodfrombasic@ONEARG{hex}
2261 \pgfmathfloat@definemethodfrombasic@ONEARG{Hex}
2262 \pgfmathfloat@definemethodfrombasic@ONEARG{oct}
2263 \pgfmathfloat@definemethodfrombasic@ONEARG{bin}
2264 \pgfmathfloat@definemethodfrombasic@TWOARGS{and}
2265 \pgfmathfloat@definemethodfrombasic@TWOARGS{or}
2266
2267 \pgfutil@ifundefined{pgfmathdeclarefunction}{%
2268 % special treatment: \pgfmathrand@ was not properly defined for pgf 2.00:
2269 \let\pgfmath@basic@rand=\pgfmathrand
2270 \let\pgfmath@basic@rand@=\pgfmathrand@
2271 \def\pgfmathfloatrand@{%
2272 \pgfmath@basic@rand
2273 \pgfmathfloatparsenumber{\pgfmathresult}%
2274 }%
2275 \let\pgfmathfloatrand=\pgfmathfloatrand@%
2276 %
2277 % special treatment: \pgfmathrnd@ was not properly defined for pgf 2.00:
2278 \let\pgfmath@basic@rnd=\pgfmathrnd
2279 \let\pgfmath@basic@rnd@=\pgfmathrnd@
2280 \def\pgfmathfloatrnd@{%
2281 \pgfmath@basic@rnd
2282 \pgfmathfloatparsenumber{\pgfmathresult}%
2283 }%
2284 \let\pgfmathfloatrnd=\pgfmathfloatrnd@%
2285 }{}
2286
2287 % Implements the factorial of '#1'.
2288 % This does only work if '#1 < 2^32'.
2289 \def\pgfmathfloatfactorial@#1{%
2290 \begingroup
2291 \pgfmathfloattofixed{#1}%
2292 % collect integer part into a 32 bit register:
2293 \afterassignment\pgfmath@gobbletilpgfmath@%
2294 \expandafter\c@pgfmath@counta\pgfmathresult\relax\pgfmath@%
2295 \pgfmathfloatcreate{1}{1.0}{0}%
2296 \let\pgfmathfloat@loc@TMPa=\pgfmathresult
2297 \pgfmathloop
2298 \ifnum\c@pgfmath@counta<2 %
2299 \else
2300 \expandafter\pgfmathfloatparsenumber\expandafter{\the\c@pgfmath@counta}%
2301 \expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfmathfloat@loc@TMPa}%
2302 \let\pgfmathfloat@loc@TMPa=\pgfmathresult
2303 \advance\c@pgfmath@counta by-1\relax%
2304 \repeatpgfmathloop
2305 \pgfmath@smuggleone\pgfmathresult
2306 \endgroup
2307 }%
2308
2309 % Implements the vector length of a 2D vector.
2310 %
2311 % ATTENTION: this does NOT use the improved code of the basic layer!
2312 % It simply computed sqrt( #1^2 + #2^2 )!
2313 \def\pgfmathfloatveclen@#1#2{%
2314 \begingroup
2315 \edef\pgfmathfloat@@a{#1}%
2316 \pgfmathfloatmultiply@{\pgfmathfloat@@a}{\pgfmathfloat@@a}%
2317 \let\pgfmathfloat@@a=\pgfmathresult
2318 %
2319 \edef\pgfmathfloat@@b{#2}%
2320 \pgfmathfloatmultiply@{\pgfmathfloat@@b}{\pgfmathfloat@@b}%
2321 \let\pgfmathfloat@@b=\pgfmathresult
2322 %
2323 \pgfmathfloatadd@{\pgfmathfloat@@a}{\pgfmathfloat@@b}%
2324 \pgfmathfloatsqrt@{\pgfmathresult}%
2325 \pgfmath@smuggleone\pgfmathresult
2326 \endgroup
2327 }%
2328
2329 \def\pgfmathfloatcosh@#1{%
2330 \begingroup
2331 \pgfmathfloatexp@{#1}%
2332 \let\pgfmathfloat@@a=\pgfmathresult
2333 %
2334 \pgfmathfloatneg@{#1}%
2335 \pgfmathfloatexp@{\pgfmathresult}%
2336 %
2337 \pgfmathfloatadd@{\pgfmathresult}{\pgfmathfloat@@a}%
2338 \expandafter\pgfmathfloatmultiplyfixed@\expandafter{\pgfmathresult}{0.5}%
2339 %
2340 \pgfmath@smuggleone\pgfmathresult
2341 \endgroup
2342 }%
2343 \def\pgfmathfloatsinh@#1{%
2344 \begingroup
2345 \pgfmathfloatexp@{#1}%
2346 \let\pgfmathfloat@@a=\pgfmathresult
2347 %
2348 \pgfmathfloatneg@{#1}%
2349 \pgfmathfloatexp@{\pgfmathresult}%
2350 %
2351 \pgfmathfloatsubtract@{\pgfmathfloat@@a}{\pgfmathresult}%
2352 \expandafter\pgfmathfloatmultiplyfixed@\expandafter{\pgfmathresult}{0.5}%
2353 %
2354 \pgfmath@smuggleone\pgfmathresult
2355 \endgroup
2356 }%
2357 \def\pgfmathfloattanh@#1{%
2358 \begingroup
2359 \pgfmathfloatsinh@{#1}%
2360 \let\pgfmathfloat@@a=\pgfmathresult
2361 %
2362 \pgfmathfloatcosh@{#1}%
2363 \let\pgfmathfloat@@b=\pgfmathresult
2364 %
2365 \pgfmathfloatdivide@{\pgfmathfloat@@a}{\pgfmathfloat@@b}%
2366 %
2367 \pgfmath@smuggleone\pgfmathresult
2368 \endgroup
2369 }%
2370 \endinput