[Numpy-discussion] Oddity with numpy.int64 integer division
Christian Marquardt
christian at marquardt.sc
Mon Apr 23 16:41:56 EDT 2007
Hmmm,
On Mon, April 23, 2007 22:29, Christian Marquardt wrote:
> Actually,
>
> it happens for normal integers as well:
>
> >>> n = np.array([-5, -100, -150])
> >>> n // 100
> array([ 0, -1, -1])
> >>> -5//100, -100//100, -150//100
> (-1, -1, -2)
and finally:
>>> n % 100
array([95, 0, 50])
>>> -5 % 100, -100 % 100, -150 % 100
(95, 0, 50)
So plain python / using long provides consistent results across //
and %, but numpy doesn't...
Christian.
> On Mon, April 23, 2007 22:20, Christian Marquardt wrote:
>> Dear all,
>>
>> this is odd:
>>
>> >>> import numpy as np
>> >>> fact = 28250000L * 86400L
>> >>> nn = np.array([-20905000L])
>> >>> nn
>> array([-20905000], dtype=int64)
>> >>> nn[0] // fact
>> 0
>>
>> But:
>>
>> >>> long(nn[0]) // fact
>> -1L
>>
>> Is this a bug in numpy, or in python's implementation of longs? I would
>> think both should give the same, really... (Python 2.5, numpy
>> 1.0.3dev3725,
>> Linux, Intel compilers...)
>>
>> Many thanks for any ideas / advice,
>>
>> Christian
>>
>> _______________________________________________
>> Numpy-discussion mailing list
>> Numpy-discussion at scipy.org
>> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>>
>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
More information about the NumPy-Discussion
mailing list