diff options
author | Karl Berry <karl@freefriends.org> | 2006-01-12 23:56:09 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-01-12 23:56:09 +0000 |
commit | 3c45ead856093bda97671c92bbc3fa9768918e91 (patch) | |
tree | 7cd45d8624b1693f5f61f9221074075d817feab2 /Master/texmf-dist/tex/latex/fp/fp-snap.sty | |
parent | f608edbff24385a77c97e230f31fe5c1fb422a71 (diff) |
fp
git-svn-id: svn://tug.org/texlive/trunk@939 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/fp/fp-snap.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/fp/fp-snap.sty | 242 |
1 files changed, 242 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/fp/fp-snap.sty b/Master/texmf-dist/tex/latex/fp/fp-snap.sty new file mode 100644 index 00000000000..f4961b7d3fd --- /dev/null +++ b/Master/texmf-dist/tex/latex/fp/fp-snap.sty @@ -0,0 +1,242 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{fp-snap}[1995/04/05] + +%version information +\def\FP@snapversion{1.0a} +\message{% + `Fixed Point Snap Off',% + \space\space\space\space\space\space\space\space\space\space% + Version \FP@snapversion% + \space(C) Michael Mehlich% + \space\space\space\space\space\space\space% + \space\space\space\space\space\space% +} + +%resolve dependencies +\RequirePackage{fp-basic} + +%%%public area (macros which may be used)%%% + +\def\FPround#1#2#3{\FP@calld\FP@round#1{#2}{#3}} +\def\FPtrunc#1#2#3{\FP@calld\FP@trunc#1{#2}{#3}} +\def\FPclip#1#2{\FP@calld\FP@clip#1{#2}} + +%%%private fp-area (don't use these macros)%%% + +%round value +\def\FP@round#1#2.#3.#4\relax#5{% + % #1 macro, which gets the result + % #2 integer part of value + % #3 fractional part of value + % #4 dummy to swallow everything after the second '.' + % #5 round position + {\FP@beginmessage{ROUND}% + % + \FP@count=#5\relax% + % + \ifnum\FP@count<0\relax% + \FP@errmessage{Rounding value before point not allowed}% + \else% + \FP@readvalue{x}{#2}{#3}% + \ifnum\FP@count=0\relax% + \ifnum\FP@xfa<500000000\relax% + \edef\FP@tmp{#2}% + \else% + \advance\FP@xib1\relax% + \ifnum\FP@xib<1000000000\relax\else% + \advance\FP@xia1\relax% + \advance\FP@xib-1000000000\relax% + \fi% + \ifnum\FP@xs<0\relax% + \edef\FP@tmp{-}% + \else% + \edef\FP@tmp{}% + \fi% + \ifnum\FP@xia=0\relax% + \edef\FP@tmp{\FP@tmp\the\FP@xib}% + \else% + \advance\FP@xib1000000000\relax% + \edef\FP@tmp{\FP@tmp\the\FP@xia\expandafter\FP@ignorenext\the\FP@xib}% + \fi% + \fi% + \else% + \ifnum\FP@count>18\relax% + \FP@count=18\relax% + \fi% + \advance\FP@xfa1000000000\relax% + \advance\FP@xfb1000000000\relax% + \edef\FP@tmp{\expandafter\FP@ignorenext\the\FP@xfa\expandafter\FP@ignorenext\the\FP@xfb}% + \edef\FP@rd{}% + \FP@shift=\FP@count% + \FP@times=1\relax% + \loop% + \ifnum\FP@count>0\relax% + \edef\FP@rd{\FP@rd\expandafter\FP@first\FP@tmp\noexpand\relax}% + \edef\FP@tmp{\expandafter\FP@ignorenext\FP@tmp}% + \advance\FP@count-1\relax% + \multiply\FP@times10\relax\ifnum\FP@times=1000000000\relax\FP@times=1\relax\fi% + \repeat% + \edef\FP@tmp{\expandafter\FP@first\FP@tmp\noexpand\relax}% + \expandafter\FP@rega\FP@tmp\relax% + \ifnum\FP@rega>4\relax% + \ifnum\FP@shift>8\relax% + \FP@ninesplit\FP@rd% + \expandafter\FP@rega\expandafter0\FP@rd\relax% + \advance\FP@rega1\relax% + \ifnum\FP@rega<\FP@times% + \advance\FP@rega\FP@times% + \advance\FP@res1000000000\relax% + \else% + \advance\FP@res1\relax% + \ifnum\FP@res<1000000000\relax% + \advance\FP@res1000000000\relax% + \else% + \advance\FP@xib1\relax% + \ifnum\FP@xib<1000000000\relax\else% + \advance\FP@xia1\relax% + \advance\FP@xib-1000000000\relax% + \fi% + \fi% + \fi% + \edef\FP@tmpa{\expandafter\FP@ignorenext\the\FP@res\expandafter\FP@ignorenext\the\FP@rega}% + \else% + \expandafter\FP@rega\FP@rd\relax% + \advance\FP@rega1\relax% + \ifnum\FP@rega<\FP@times% + \advance\FP@rega\FP@times% + \else% + \advance\FP@xib1\relax% + \ifnum\FP@xib<1000000000\relax\else% + \advance\FP@xia1\relax% + \advance\FP@xib-1000000000\relax% + \fi% + \fi% + \edef\FP@tmpa{\expandafter\FP@ignorenext\the\FP@rega}% + \fi% + \else% + \edef\FP@tmpa{\FP@rd}% + \fi% + \ifnum\FP@xs<0\relax% + \edef\FP@tmp{-}% + \else% + \edef\FP@tmp{}% + \fi% + \ifnum\FP@xia=0\relax% + \edef\FP@tmp{\FP@tmp\the\FP@xib.\FP@tmpa}% + \else% + \advance\FP@xib1000000000\relax% + \edef\FP@tmp{\FP@tmp\the\FP@xia\expandafter\FP@ignorenext\the\FP@xib.\FP@tmpa}% + \fi% + \fi% + \fi% + % + \global\let\FP@tmp\FP@tmp% + % + \FP@endmessage{}% + }% + \let#1\FP@tmp% +} + +%trunc value + +\def\FP@trunc#1#2.#3.#4\relax#5{% + % #1 macro, which gets the result + % #2 integer part of value + % #3 fractional part of value + % #4 dummy to swallow everything after the second '.' + % #5 trunc position + {\FP@beginmessage{TRUNC}% + % + \FP@count=#5\relax% + % + \ifnum\FP@count<0\relax% + \FP@errmessage{Truncating value before point not allowed}% + \else\ifnum\FP@count=0\relax% + \edef\FP@tmp{#2}% + \else% + \ifnum\FP@count>18\relax% + \FP@count=18\relax% + \fi% + \FP@readvalue{x}{#2}{#3}% + \advance\FP@xfa1000000000\relax% + \advance\FP@xfb1000000000\relax% + \edef\FP@tmp{\expandafter\FP@ignorenext\the\FP@xfa\expandafter\FP@ignorenext\the\FP@xfb}% + \edef\FP@tmpa{}% + \loop% + \ifnum\FP@count>0\relax% + \edef\FP@tmpa{\FP@tmpa\expandafter\FP@first\FP@tmp\noexpand\relax}% + \edef\FP@tmp{\expandafter\FP@ignorenext\FP@tmp}% + \advance\FP@count-1\relax% + \repeat% + \ifnum\FP@xs<0\relax% + \edef\FP@tmp{-}% + \else% + \edef\FP@tmp{}% + \fi% + \ifnum\FP@xia=0\relax% + \edef\FP@tmp{\FP@tmp\the\FP@xib.\FP@tmpa}% + \else% + \advance\FP@xib1000000000\relax% + \edef\FP@tmp{\FP@tmp\the\FP@xia\expandafter\FP@ignorenext\the\FP@xib.\FP@tmpa}% + \fi% + \fi\fi% + % + \global\let\FP@tmp\FP@tmp% + % + \FP@endmessage{}% + }% + \let#1\FP@tmp% +} + +%clip value + +\def\FP@revert#1#2{% + % #1 macro, which gets the result + % #2 value + {\edef\FP@tmpa{#2}% + \edef\FP@tmp{}% + \loop% + \expandafter\if!\FP@tmpa!\relax\else% + \edef\FP@tmpb{\expandafter\FP@first\FP@tmpa\noexpand\relax}% + \edef\FP@tmpa{\expandafter\FP@ignorenext\FP@tmpa}% + \edef\FP@tmp{\FP@tmpb\FP@tmp}% + \repeat% + \global\let\FP@tmp\FP@tmp% + }% + \let#1\FP@tmp% +} + +\def\FP@clip#1#2.#3.#4\relax{% + % #1 macro, which gets the result + % #2 integer part of value + % #3 fractional part of value + % #4 dummy to swallow everthing after the 2nd '.' + % + {\FP@beginmessage{CLIP}% + % + \FP@revert\FP@tmpb{#3}% + \FP@removeleadingzeros\FP@tmpb\relax% + \FP@revert\FP@tmpb\FP@tmp% + \edef\FP@tmpa{#2}% + \FP@removeleadingzeros\FP@tmpa\relax% + \edef\FP@tmpa{\FP@tmp}% + \expandafter\if!\FP@tmpa!\relax% + \expandafter\if!\FP@tmpb!\relax% + \edef\FP@tmp{0}% + \else% + \edef\FP@tmp{0.\FP@tmpb}% + \fi% + \else% + \expandafter\if!\FP@tmpb!\relax% + \edef\FP@tmp{\FP@tmpa}% + \else% + \edef\FP@tmp{\FP@tmpa.\FP@tmpb}% + \fi% + \fi% + % + \global\let\FP@tmp\FP@tmp% + % + \FP@endmessage{}% + }% + \let#1\FP@tmp% +} |