My Python version is
'3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31) [MSC v.1600 64 bit (AMD64)]'
I have some work that need bit shift operation but I found in Python it works strange.
The problem is I can not limit my number's length. In JS:
1 << 63 = -2147483648
However, in Python:
1 << 63 = 9223372036854775808
Further more, in JS we have >>>
operator which ignore negative numbers.
I know in Python
A right shift by n bits is defined as floor division by pow(2,n). A left shift by n bits is defined as multiplication with pow(2,n).
But how to simulate these js/c++ bit operations in Python?