Toen wij David W. Tamkin kietelden, kwam er dit uit:
I need a general division recipe.
I now have this:
* 1^0
*$ $a^0
*$ -$b^0
Why are you making sure that a >= b?
That was to make 99/100 become 0.
The problem you'll run into is with $=. It will always report an
integer, any fractional part being rounded in the direction toward +1.
So unless a is a multiple of b, you won't get an accurate answer anyway.
See "The result c is an integer value, rounded down towards 0."
That is one of the goals. :) I am trying to make a DIV.
Now that you made me remember the "toward +1", I checked my
b64.inc.inc again. It does the check as above, a few times.
Under some constraints (like that a >=0 and/or b > 0,
or that a <= b < 0) this will work:
dot = "."
:0
*$ $a^0
*$ $b^0
{ } ab = $=
:0
*$ dot ?? $ab^1 > $b
* -1^0
{ } c = $=
Some problems left:
-1 / -100 --> 1
-10 / -100 --> 1
Working version:
c = 0
abs_a = $a
abs_b = $b
:0
* abs_a ?? ^^-\/.*
{ abs_a = $MATCH }
:0
* abs_b ?? ^^-\/.*
{ abs_b = $MATCH }
:0
* 1^0
*$ $abs_a^0
*$ -$abs_b^0
{
:0
*$ dot ?? $a^1 > $b
{ } c = $=
}
In an example of mktime-source at
http://samba.org/doxygen/samba_2_2/replace_8c-source.html
there are a few divisions, where 'a' is the current year -1
and 'b' is 4, 100 or 400.
(1969 / 4 - 1969 / 100 + 1969 / 400) can be simplified
to (492 - 19 + 4) is 477.
(a / 4 - a / 100 + a / 400) is easy to calculate.
If the month > Feb then make 'a' equal to the current year,
to get rid of the MODs further down.
--
Grtz, Ruud
____________________________________________________________
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