Okay, I feel stupid asking this, but I have a question about a basic
function, "mod".

My ported computations from CC become all wrong if I use Perl's built-in
"%" operator. After a few trial and errors, it seemed like when CC mentions

   R = N mod M

it's actually computing a fractional number. For example, 15.1 mod 4
would be 3.1. If I take that to be true, most of my computations work.
However, now I'm having problems with taking a modulo of a negative value.

Specifically, I'm trying to implement solar_longitude_after() (p.184)
function -- but it chokes when the difference between $phi and
solar_longitude($t) is a negative number to compute the value of $tau:

   $tau = $t + $rate * mod($phi - solar_longitude($t), 360);

It seems like the output of mod() is expected to be something other than
what I've been computing... (The reason I suspect that is because the
solar terms that are generated by this function turns out wrong only if
$phi - solar_longitude($t) is negative ).

Does anybody know how this is supposed to work? I tried a bunch of
things, but I just can't seem to get it right. Does anybody know how
this *should* be done?

TIA
--d

Reply via email to