From 3c45ead856093bda97671c92bbc3fa9768918e91 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 12 Jan 2006 23:56:09 +0000 Subject: fp git-svn-id: svn://tug.org/texlive/trunk@939 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/fp/fp-pas.sty | 118 ++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/fp/fp-pas.sty (limited to 'Master/texmf-dist/tex/latex/fp/fp-pas.sty') diff --git a/Master/texmf-dist/tex/latex/fp/fp-pas.sty b/Master/texmf-dist/tex/latex/fp/fp-pas.sty new file mode 100644 index 00000000000..8cef34d97a4 --- /dev/null +++ b/Master/texmf-dist/tex/latex/fp/fp-pas.sty @@ -0,0 +1,118 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{fp-pas}[1994/08/29] + +%version information +\def\FP@pasversion{1.0} +\message{% + `Fixed Point Pascal Triangle',% + \space\space\space% + Version \FP@pasversion\space% + \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\FPpascal#1#2{\FP@pascal{#1}{#2}}%pascal triangle for lines 0,...,63 + +%%%private fp-area (don't use these macros)%%% + +%allocation of registers +\countdef\FP@pas=50 +\countdef\FP@pasc=51 + +%addition of two natural numbers +\def\FP@pasadd#1#2#3{% + % #1 macro, which gets the result + % #2 1st value + % #3 2nd value + {\FP@removeleadingzeros#2\relax% + \expandafter\FP@setintcounter\FP@tmp000000000000000000\relax% + \FP@xia=\FP@rega% + \FP@xib=\FP@regb% + % + \FP@removeleadingzeros#3\relax% + \expandafter\FP@setintcounter\FP@tmp000000000000000000\relax% + \FP@yia=\FP@rega% + \FP@yib=\FP@regb% + % + \advance\FP@xia\FP@yia% + \advance\FP@xib\FP@yib% + \ifnum\FP@xib<1000000000\relax\else% + \advance\FP@xia1\relax% + \advance\FP@xib-1000000000\relax% + \fi% + \ifnum\FP@xia<1000000000\relax\else% + \FP@errmessage{Overflow}% + \fi% + % + \ifnum\FP@xia=0\relax% + \edef\FP@tmpa{\the\FP@xib}% + \else% + \advance\FP@xib1000000000% + \edef\FP@tmpa{\the\FP@xia\expandafter\FP@ignorenext\the\FP@xib}% + \fi% + % + \global\let\FP@tmpa\FP@tmpa% + }% + % + \let#1\FP@tmpa% +} + +%the first two entries of the pascal-triangle +\expandafter\edef\csname FP@pas0\endcsname{[1]} +\expandafter\edef\csname FP@pas1\endcsname{[1,1]} + +%which is the highest line of the pascal-triangle we have already computed? +\expandafter\edef\csname FP@pascount\endcsname{1} + +%compute next line of pascal-triangle +\def\FP@pasdouble[#1]{% + % #1 previous line of pascal-triangle + \edef\FP@old{}% + \edef\FP@tmpb{}% + \@for\FP@new:=#1\do{% + \expandafter\if!\FP@old!\relax% + \edef\FP@old{\FP@new}% + \else% + \FP@pasadd{\FP@tmpa}{\FP@old}{\FP@new}% + \edef\FP@tmpb{\FP@tmpb,\FP@tmpa}% + \edef\FP@old{\FP@new}% + \fi% + }% + \global\edef\FP@tmpb{[1\FP@tmpb,1]}% +} + +%compute n-th line of pascal-triangle +\def\FP@pascomp#1{% + % #1 which line to compute + \expandafter\FP@pasc\FP@pascount\relax% + \ifnum\FP@pasc<#1\relax% + \loop% + \ifnum\FP@pasc<#1\relax% + \expandafter\expandafter\expandafter\FP@pasdouble\csname FP@pas\the\FP@pasc\endcsname% + \advance\FP@pasc1\relax% + \edef\next{\noexpand\global\noexpand\let\csname FP@pas\the\FP@pasc\endcsname\noexpand\FP@tmpb}% + \next% + \repeat% + \fi% + \global\edef\FP@pascount{\the\FP@pasc}% +} + +\def\FP@pascal#1#2{% + % #1 macro, which gets the result + % #2 which line of the pascal-triangle to compute + {\FP@beginmessage{PASCAL}% + % + \FP@pas#2\relax% + \FP@pascomp\FP@pas% + \global\edef\FP@tmp{\csname FP@pas\the\FP@pas\endcsname}% + % + \FP@endmessage{}% + }% + \let#1\FP@tmp% +} -- cgit v1.2.3