On Fri, Jul 02, 2004 at 12:29:00AM +0200, Ruud H.G. van Tol wrote:
Toen wij Ruud H.G. van Tol kietelden, kwam er dit uit:
I need a general division recipe.
It's not as general as I hoped it would be,
but it's general enough for now:
http://www.xs4all.nl/~rvtol/procmail --> inc --> div.inc
--
Grtz, Ruud
Cool beans. Fwiw, my aborted attempt from a couple of months
ago got as far as to work on positive integers only, even
though I incorporated David's trick (which I'd been saving
since 2002 when he first posted about it).
division.rc:
# N (numerator) and D (denominator) fed from command-line
NL = "
"
SMALL = .000001
ITERATIONS = 0
REMAINDER = $N
INCLUDERC = divide-recursion.rc
LOG = "$NL $N / $D = $ITERATIONS, remainder $REMAINDER $NL"
divide-recursion.rc
:0
* $ $REMAINDER ^ 0
* $ $D ^-2 HOST ?? ^^.|.^^
* $ $SMALL ^ 0
{
REMAINDER = $=
:0
* $ ${ITERATIONS:-0} ^0
* 1 ^0
{ ITERATIONS = $= }
INCLUDERC = divide-recursion.rc
}
Example:
% procmail -m N=54 D=5 DEFAULT=/dev/null division.rc < /dev/null
54 / 5 = 10, remainder 4
--
dman
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail