Email address obfuscation in effect -- please
click here to turn it off.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
On Wed, 5 Jan 2000, Tymm Twillman wrote:
> or perhaps Matlab is broken too, or I'm reading things wrong. But I
> usually trust C on this stuff.
>
> http://www.ind2.polymtl.ca/matlab/techdoc/ref/mod.html (matlab
> documentation for mod)
>
> it claims modulus is the *signed* remainder after division.
OK, but if you test this in MATLAB, you get the same result as in perl:
# mod(-98,100)
ans =
2
And MATLAB documentation says:
M = mod(X,Y) returns the remainder X - Y.*floor(X./Y) for nonzero Y, and
returns X otherwise.
Which does the *same* thing as perl unless Y is zero, in which case perl
returns "Illegal modulus zero" and MATLAB returns X.
So it looks like perl and MATLAB are OK, but C and awk give wrong answers.
This is what Jon and Steve said originally and I agree with them.
Regards,
Mike
--
Michael B. Miller
University of Missouri--Columbia
http://taxa.psyc.missouri.edu/~mbmiller/