On Wed, Feb 3, 2010 at 5:43 AM, 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
On Wed, Feb 3, 2010 at 8:43 PM, 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
--
Hello,
the following operation seems strange to me
>>> np.left_shift(2,-1)
0
I would have expected a right_shift by one.
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 b