summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-10-29 00:31:31 +0000
committerKarl Berry <karl@freefriends.org>2010-10-29 00:31:31 +0000
commit6bc1f5497cfb2f56d65c80a4c36ea3bad6dc046c (patch)
treef7751da75030fb1e06653eeb44e579fcee09c65f /Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code.tex
parented0c7c756e441b2d2ba3633da233fc24361ac0d3 (diff)
pgf 2.10 (28oct10)
git-svn-id: svn://tug.org/texlive/trunk@20236 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code.tex')
-rw-r--r--Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code.tex112
1 files changed, 112 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code.tex b/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code.tex
new file mode 100644
index 00000000000..03f9ca270ae
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code.tex
@@ -0,0 +1,112 @@
+% Copyright 2007 by Mark Wibrow
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+%
+% See the file doc/generic/pgf/licenses/LICENSE for more details.
+
+% This file defines the mathematical functions and operators.
+%
+% Version 1.414213 29/9/2007
+
+% round function. Uses asymmetric half-up rounding.
+%
+\pgfmathdeclarefunction{round}{1}{%
+ \begingroup%
+ \expandafter\pgfmath@x#1pt\relax%
+ \afterassignment\pgfmath@xa%
+ \expandafter\c@pgfmath@counta\the\pgfmath@x\relax%
+ \pgfmath@xb\pgfmath@x%
+ \ifdim\pgfmath@xb<0pt\relax%
+ \ifdim\pgfmath@xa<0.5pt\relax%
+ \else%
+ \advance\c@pgfmath@counta-1\relax%
+ \fi%
+ \else%
+ \ifdim\pgfmath@xa<0.5pt\relax%
+ \else%
+ \advance\c@pgfmath@counta1\relax%
+ \fi%
+ \fi%
+ \pgfmath@returnone\the\c@pgfmath@counta pt%
+ \endgroup%
+}%
+
+% floor function.
+%
+\pgfmathdeclarefunction{floor}{1}{%
+ \begingroup%
+ \expandafter\pgfmath@x#1pt\relax%
+ \afterassignment\pgfmath@gobbletilpgfmath@%
+ \expandafter\c@pgfmath@counta\the\pgfmath@x\relax\pgfmath@%
+ \expandafter\pgfmath@x#1pt\relax%
+ \ifdim\pgfmath@x<0pt\relax%
+ \advance\c@pgfmath@counta by -1\relax%
+ \fi%
+ \pgfmath@x\c@pgfmath@counta pt\relax%
+ \pgfmath@returnone\pgfmath@x%
+ \endgroup%
+}%
+
+% ceil function.
+%
+\pgfmathdeclarefunction{ceil}{1}{%
+ \begingroup%
+ \expandafter\pgfmath@x#1pt\relax%
+ \afterassignment\pgfmath@gobbletilpgfmath@%
+ \expandafter\c@pgfmath@counta\the\pgfmath@x\relax\pgfmath@%
+ \pgfmath@y\pgfmath@x%
+ \advance\pgfmath@y-\c@pgfmath@counta pt\relax%
+ \pgfmath@x\c@pgfmath@counta pt\relax%
+ \ifdim\pgfmath@y>0pt\relax%
+ \advance\pgfmath@x1pt\relax%
+ \fi%
+ \pgfmath@returnone\pgfmath@x%
+ \endgroup%
+}%
+
+% int function
+%
+\pgfmathdeclarefunction{int}{1}{%
+ \begingroup%
+ \expandafter\pgfmathint@@#1.\pgfmath@stop
+ \pgfmath@smuggleone\pgfmathresult%
+ \endgroup}
+
+\def\pgfmathint@@#1.#2\pgfmath@stop{%
+ \def\pgfmath@temp{#1}%
+ \ifx\pgfmath@temp\pgfmath@empty%
+ \def\pgfmathresult{0}%
+ \else%
+ \pgfmath@in@{#1}{+-+0-0}%
+ \ifpgfmath@in@
+ \def\pgfmathresult{0}%
+ \else%
+ \def\pgfmathresult{#1}%
+ \fi%
+ \fi}
+
+% frac function.
+%
+\pgfmathdeclarefunction{frac}{1}{%
+ \begingroup%
+ \expandafter\pgfmathfrac@@#1.\pgfmath@stop%
+ \pgfmath@smuggleone\pgfmathresult%
+ \endgroup}
+
+\def\pgfmathfrac@@#1.{%
+ \pgfmath@ifnextchar\pgfmath@stop{\def\pgfmathresult{0.0}\pgfmath@gobbleone}{\pgfmathfrac@@@}%
+}
+\def\pgfmathfrac@@@#1.\pgfmath@stop{\def\pgfmathresult{0.#1}}
+
+% real function.
+%
+\pgfmathdeclarefunction{real}{1}{%
+ \begingroup%
+ \pgfmath@x=#1pt\relax%
+ \edef\pgfmathresult{\pgfmath@tonumber{\pgfmath@x}}%
+ \pgfmath@smuggleone\pgfmathresult%
+ \endgroup%
+}