(Numeric) should -7 % 5 = -2 ?
Louis M. Pecora
pecora at anvil.nrl.navy.mil
Sun Jun 29 08:17:19 EDT 2003
In article <mailman.1056836805.17229.python-list at python.org>, Fredrik
Lundh <fredrik at pythonware.com> wrote:
> > >>> -7 % 5
> > 3
> > >>> Numeric.array(-7) % 5
> > -2
> > >>> Numeric.remainder(-7, 5)
> > -2
>
> looks like Numeric implements C semantics, which is different
> from how Python does it.
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.
*
--
Lou Pecora
- My views are my own.
More information about the Python-list
mailing list