[Numpy-discussion] Oddity with numpy.int64 integer division

Christian Marquardt christian@marquardt...
Tue Apr 24 16:34:29 CDT 2007


On Tue, April 24, 2007 23:31, Christian Marquardt wrote:
> On Tue, April 24, 2007 23:08, Robert Kern wrote:
>> Christian Marquardt wrote:
>>> Restore the invariant, and follow python.
>>>
>>> This
>>>
>>>    >>> -5 // 6
>>>    -1
>>>
>>> and
>>>
>>>    >>> array([-5])[0] // 6
>>>    0
>>>
>>> simply doesn't make sense - in any language, you would expect that
>>> all basic operators provide you with the same same answer when
>>> applied to the same number, no?
>>
>> Not if they are different types, you don't, e.g. -5.0 / 6 .
>
> But I would regard an integer and an array of integers as the same type.

By the way:

   >>> -5.0 // 6
   -1.0
   >>> array([-5.0]) // 6
   array([-1.])

  Christian.





More information about the Numpy-discussion mailing list