(Numeric) should -7 % 5 = -2 ?

Bob Gailer bgailer at alum.rpi.edu
Tue Jul 1 21:47:57 CEST 2003


At 11:19 AM 7/1/2003 -0400, Louis M. Pecora wrote:

>In article <3g32gvcolis4485956egtc35akm6lh3uq5 at 4ax.com>, Tim Roberts
><timr at probo.com> wrote:
>
> > >Hmmm...  "remainder" makes sense.  But "%" is mod, right.  IIRC from my
> > >abstract algebra days (only 30 yrs ago :-) ) The "X mod n" function
> > >maps onto the postive integers from 0 to n-1.  So sounds like numeric
> > >contradicts the math texts.  Not good since it's a math module.
> >
> > That's a bit harsh.
>
>You may be right.  I got to work and checked my old Abstract Algebra
>book.  The defintion is,
>
>We write  a=b mod m if m divides (a-b) (i.e. no remeinder).
>
>The defintion does not say how to compute the mod, rather it is an
>expression of a relationship between a and b.  Hence, writing -2=-7 mod
>5 appears to be OK.
>[snip]

To quote from "Number Theory and its History" by Oystein Ore, page 213f:
"When an integer a is divided by another m, one has
         a = km + r
where the remainder is some positive integer less than m. Thus for any 
number a there exists a congruence
         a (is congruent to) r (mod m)
where r is a unique one among the numbers 0, 2, 1, .... m-1"

Bob Gailer
bgailer at alum.rpi.edu
303 442 2625
-------------- next part --------------

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.492 / Virus Database: 291 - Release Date: 6/24/2003


More information about the Python-list mailing list