On Wed, Feb 3, 2010 at 8:43 PM, <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. >
I wouldn't expect anything, the behavior is simply not defined. Python returns an error: In [17]: 2 << -1 --------------------------------------------------------------------------- ValueError .... > > The documentation on > > http://docs.scipy.org/doc/numpy/reference/generated/numpy.left_shift.html#numpy.left_shift > also says that the operation is equivalent to multiplying x1 by 2**x2. > That's not the case! > The line before that says "Bits are shifted to the left by appending `x2` 0s at the right of `x1`." What does it mean to append a negative number of zeros? The docs could explicitly mention that x2 has to be non-negative, if that would make it clearer. Cheers, Ralf
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion