This sample code from Mozilla\'s JS reference uses the >> and >>> operators with a RHS argument of 0. I guess this is an alternative to Math.floor() that has a performance a
It converts them to numbers that can be expressed as 32-bit unsigned ints. So yes it will make it a (typeof number) as a floored int, it will also make it a 32-bit unsigned, which JS programming loves :)
The main difference is the signed vs unsigned.
From the MDN Article:
>>
is a Sign-propagating right shift:
Shifts a in binary representation b (< 32) bits to the right, discarding bits shifted off.
>>>
is a Zero-fill right shift:
Shifts a in binary representation b (< 32) bits to the right, discarding bits shifted off, and shifting in zeroes from the left.
So the difference is that one will shift in zeroes from the left.
From this stackoverflow answer talking about a zero-shift:
So doing a bitwise operation with no actual effect, like a rightward-shift of 0 bits >>0, is a quick way to round a number and ensure it is in the 32-bit int range. Additionally, the triple >>> operator, after doing its unsigned operation, converts the results of its calculation to Number as an unsigned integer rather than the signed integer the others do, so it can be used to convert negatives to the 32-bit-two's-complement version as a large Number. Using >>>0 ensures you've got an integer between 0 and 0xFFFFFFFF.