On Wed, Feb 3, 2010 at 5:43 AM, <markus.proel...@ifm.com> wrote: > > Hello, > > the following operation seems strange to me > > >>> np.left_shift(2,-1) > 0 > > I would have expected a right_shift by one. > > The result of a shift by a negative number is undefined in the C language; the gcc compiler will issue a warning if it can determine that that is the case. Even so, the result in your example is normally 1. There is something else going on:
In [26]: x = array([2]) In [27]: x << -2 Out[27]: array([-9223372036854775808]) In [28]: x << 62 Out[28]: array([-9223372036854775808]) In [29]: x << 63 Out[29]: array([0]) In [30]: x << 64 Out[30]: array([2]) This for 64 bit integers. Looks almost like the shift is taken mod 64, which is a bit weird. Chuck
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion