Francesc Altet once provided an example that for integer division, numpy uses the C99 rule: round towards 0. This is different than Python's rule for integer division: round towards negative infinity. But I cannot reproduce his example. (NumPy 1.3.) Did this behavior change at some point? Thanks, Alan Isaac
la, 2010-03-13 kello 15:32 -0500, Alan G Isaac kirjoitti:
Francesc Altet once provided an example that for integer division, numpy uses the C99 rule: round towards 0. This is different than Python's rule for integer division: round towards negative infinity.
But I cannot reproduce his example. (NumPy 1.3.) Did this behavior change at some point?
It was changed in r5888. What the rationale was is not clear from the commit message. Pauli
On Sat, Mar 13, 2010 at 3:04 PM, Pauli Virtanen <pav@iki.fi> wrote:
la, 2010-03-13 kello 15:32 -0500, Alan G Isaac kirjoitti:
Francesc Altet once provided an example that for integer division, numpy uses the C99 rule: round towards 0. This is different than Python's rule for integer division: round towards negative infinity.
But I cannot reproduce his example. (NumPy 1.3.) Did this behavior change at some point?
It was changed in r5888. What the rationale was is not clear from the commit message.
The change was before that, the logic of the loop after r5888 is the same as before. I suspect the change was made, whenever that was, in order to conform to python. Chuck
On 3/13/2010 8:57 PM, Charles R Harris wrote:
I suspect the change was made, whenever that was, in order to conform to python.
So is there an actual polcy? When C99 behavior and Python behavior differ, will NumPy follow Python as a *rule*? Thanks, Alan Isaac
On Mon, Mar 22, 2010 at 4:11 PM, Alan G Isaac <aisaac@american.edu> wrote:
On 3/13/2010 8:57 PM, Charles R Harris wrote:
I suspect the change was made, whenever that was, in order to conform to python.
So is there an actual polcy? When C99 behavior and Python behavior differ, will NumPy follow Python as a *rule*?
I don't know if it is official policy, but in python3.x integer division becomes true division and the old behaviour has to be gotten by using //. This will no doubt cause some problems... Chuck
participants (3)
-
Alan G Isaac
-
Charles R Harris
-
Pauli Virtanen