8000 Shift operator cycles for int32 and int64 (Trac #1856) · Issue #2449 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
Shift operator cycles for int32 and int64 (Trac #1856) #2449
Closed
@numpy-gitbot

Description

@numpy-gitbot

Original ticket http://projects.scipy.org/numpy/ticket/1856 on 2011-06-02 by trac user klasj, assigned to unknown.

The bitshift operations, both right and left cycles when they are shifted more bits than
the length of the datatype. This happens for both int32 and int64 but not for int16,
unsigned integers works as expected. In the example below version 1.6.1 is used but
this is also present in at least 1.5.0.

In [1]: import numpy as np

In [2]: np.right_shift(np.int32(8),32)

Out[2]: 8

In [3]: np.right_shift(np.int64(8),64)

Out[3]: 8

In [4]: np.right_shift(np.int16(8),16)

Out[4]: 0

In [5]: np.left_shift(np.int32(8),32)

Out[5]: 8

In [6]: np.left_shift(np.int64(8),64)

Out[6]: 8

In [7]: np.left_shift(np.int16(8),16)

Out[7]: 524288

In [8]: np.version.full_version

Out[8]: '1.6.1.dev-08953ea'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0