What does “somevar >> 0” mean?

匿名 (未验证) 提交于 2019-12-03 08:30:34

问题:


What does the notation somevar >> 0 mean in javascript?

Thanks

回答1:

In a >> b, >> is a bitwise operator that shifts a in binary representation b (https://developer.mozilla.org/en/JavaScript/Reference/Operators/Bitwise_Operators



回答2:

Bitwise right shift. Although somevar >> 0 looks weird.



回答3:

It's a bitwise operator. In this case, for shifting the first operand in binary representation the number of bits to the right specified in the second operand, discarding bits shifted off.

With a 0 as second operand, I guess it has no effect (shifting 0 bits, is getting the same value?).

I was wrong with this last. As explained at this @Gumbo's comment.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!