# [Matrix-SIG] -1%2 = 1 and array([-1])%2 = array([-1]) Why?

**Konrad Hinsen
**
hinsen@cnrs-orleans.fr

*Mon, 15 Nov 1999 16:11:45 +0100*

>* I just tried the following:
*>*
*>* >>> -1%2
*>* 1
*>* >>> array([-1])%2
*>* array([-1])
*>*
*>* I would have expected array([+1]).
*>*
*>* What is the philosophical reason Numerical should give another result than
*>* nude python?
*
Python has a well-defined rule for the modulo operator. NumPy just
applies the C modulo operator, which if I remember correctly gives
different results on different machines, guaranteeing only that
b*(a/b) + (a%b) == a. I have pointed out the different outcome a while
ago, but noone else seemed to see this as a problem.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron | Fax: +33-2.38.63.15.17
45071 Orleans Cedex 2 | Deutsch/Esperanto/English/
France | Nederlands/Francais
-------------------------------------------------------------------------------