From ac3c55a3216b5988f0e48ba9414ddb059f19a699 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 11 Jan 2006 22:58:36 +0000 Subject: trunk/Master/texmf-dist/metapost git-svn-id: svn://tug.org/texlive/trunk@104 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/metapost/base/sarith.mp | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Master/texmf-dist/metapost/base/sarith.mp (limited to 'Master/texmf-dist/metapost/base/sarith.mp') diff --git a/Master/texmf-dist/metapost/base/sarith.mp b/Master/texmf-dist/metapost/base/sarith.mp new file mode 100644 index 00000000000..26f99c0fa61 --- /dev/null +++ b/Master/texmf-dist/metapost/base/sarith.mp @@ -0,0 +1,47 @@ +% Macros for arithmetic on strings that represent big numbers +% All the macros below except ordinary numeric values as well + +% Scvnum % convert to an ordinary numeric +% Sabs % absolute value +% Sadd % add +% Ssub % subtract +% Smul % multiply +% Sdiv % divide +% Sleq % compare <= +% Sneq % numeric compare <> + +% All other externally visible names start with `S' and end with `_' + + +if unknown Mzero: + begingroup interim % marith.mp starts with `warningcheck:=0' + input marith + endgroup; % restore warningcheck; we zero it when necessary +fi + + +vardef Sunop_(expr x)(text o) = + interim warningcheck:=0; + o if numeric x: decimal fi x +enddef; + + +vardef Sbinop_@#(expr a, b)(text o) = + interim warningcheck:=0; + @# (Mlog_Str a o Mlog_Str b) +enddef; + + +def Ssbinop_ = Sbinop_.Mexp_str enddef; + + +vardef Sabs primary x = Sunop_(x, Mexp_str Mabs Mlog_str) enddef; +vardef Scvnum primary x = Sunop_(x, Mexp Mlog_str) enddef; +% The inverse of Scvnum is the `decimal' primitive. + +primarydef a Smul b = Ssbinop_(a,b,Mmul) enddef; +primarydef a Sdiv b = Ssbinop_(a,b,Mdiv) enddef; +secondarydef a Sadd b = Ssbinop_(a,b,Madd) enddef; +secondarydef a Ssub b = Ssbinop_(a,b,Msub) enddef; +tertiarydef a Sleq b = Sbinop_(a,b,Mleq) enddef; +tertiarydef a Sneq b = Sbinop_(a,b,<>) enddef; -- cgit v1.2.3