Target >> 0 and >>> 0

This sample code from the Mozilla JS link uses the → and →> operators with the RHS 0 argument. I assume this is an alternative to Math.floor (), which has a performance advantage because instead of the built-in operator, you need to look for a function instead. But what difference does → vs →> make with zero shift?

+4
source share
2 answers

From MDN Article :

>>is the Sign-shift to the right of the shift :

Shifts a in binary representation b (<32) bits to the right, discarding bits shifted from.

>>>is the Zero Zero Shift :

a b (< 32) , , , .

, , .

fooobar.com/questions/1179/... :

, , 0 → 0, 32- int. , triple → > Number , , , 32- . → > 0 , 0 0xFFFFFFFF.

+2

, 32- int. , , (typeof number) floored int, 32- , JS- :)

- vs .

+1

Source: https://habr.com/ru/post/1624327/


All Articles