开发者

What does "<<" in "1000 << 16" mean in ruby?

What does "<<" in "1000 << 16" mean in ruby?

I know that for strings << can be used for concatenati开发者_运维百科on, but I don't understand what it does for ints. Could someone please explain?


This is the left shift bitwise operator.


What it should do is take the binary representation of one thousand and shift the bits to the left sixteen spaces. Effectively, it multiplies the number by 65,536.


You can look it up in RDoc: http://www.ruby-doc.org/core/classes/Fixnum.html#M001102

fix << count → integer

Shifts fix left count positions (right if count is negative).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜