Generally speaking, bit offset ( >> , <<) allows you to divide / multiply by^2
Example:
9 (base 10): 00000000000000000000000000001001 (base 2)
--------------------------------
9 >> 2 (base 10): 00000000000000000000000000000010 (base 2)
= 2 (base 10)
For negative numbers:
Similarly, -9 >> 2it gives -3, because the sign is preserved:
-9 (base 10): 11111111111111111111111111110111 (base 2)
--------------------------------
-9 >> 2 (base 10): 11111111111111111111111111111101 (base 2) = -3 (base 10)
But looking at >>>, which acts the same for positive numbers, m, but behaves differently for negative numbers:
mdn
Zero bits are shifted to the left.
I cannot find the reason / use for the offset 0on the left (which makes the integer positive) on the left:
-9 (base 10): 11111111111111111111111111110111 (base 2)
--------------------------------
-9 >>> 2 (base 10): 00111111111111111111111111111101 (base 2) = 1073741821 (base 10)
Question:
>>>? , - .