Re: Modular Arithmetic
- From: fishfry <BLOCKSPAMfishfry@xxxxxxxxxxxxxxxx>
- Date: Wed, 12 Jul 2006 08:40:22 -0700
In article <wood-1207060725250001@xxxxxxxxxxxxxxxxxxxxxxxx>,
wood@xxxxxxxxxxxxxxxx (J. B. Wood) wrote:
Hello, all. Can the result of the expression
N mod M
where N and M are integers with M > N ever be negative? Most references
I've come across (including the Excel MOD function) will give the result
(remainder) in this case as N but a least one paper I've read would
interpret the result as N-M. This appears to imply "multiply M by 1 and
subtract the result from N."
I'm wondering if there is one accepted math definition to cover this
case. Thanks for your time and comment. Sincerely,
There are two different but related usages of mod.
In math, we say that two integers, a and b, are congruent mod n, if n
divides the difference of a and b.
So for example 2 and 7 are congruent mod 5, because 5 divides 7 - 2.
It would also be true that, for example, 12 = 2 (mod 5) or 22 = -3 (mod
5) for the same reason.
[note ... in books, the '=' is written with three horizontal bars to
indicate equivalence rather than equality.]
Now, in computer programming, there is a mod operator that returns the
result of an expression ... so that mod(12, 5) = 2.
In math, mod is an equivalence relation ... it's a function that returns
true or false, given a pair of numbers and a modulus.
In programming, mod is a function that returns a numerical value.
So it's true that in excel or in programming languages, 12 mod 5 = 2,
always, and never -3.
But in math, 12 = -3 (mod 5) because 5 divides 12 - (-3).
.
- References:
- Modular Arithmetic
- From: J. B. Wood
- Modular Arithmetic
- Prev by Date: Re: An uncountable countable set
- Next by Date: Re: An uncountable countable set
- Previous by thread: Re: Modular Arithmetic
- Next by thread: Re: Modular Arithmetic
- Index(es):
Relevant Pages
|