返回顶部

收藏

Binary bit shift left and right

更多
(0b1011 << 1).to_s(2)   # => '10110'   11 << 1 => 22
(0b10110 >> 2).to_s(2)  # => '101'     22 >> 2 => 5

标签:Ruby,Number

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2015-12-21 17:32:13Declare the Variables to Store the Details by 杨洋
  2. 2015-12-29 10:22:18if a value is a zero or not. by JustForFly
  3. 2016-02-07 10:37:24Inspect a not-a-number by 胡晋
  4. 2016-02-10 09:31:53Get the next integer with next (or its alias succ): by LeoSun
  5. 2016-02-16 13:34:46split a big number by 杨洋
  6. 2016-04-24 14:34:38Add value to BigDecimal by 永明
  7. 2016-08-28 17:29:27try weird conversions by 杨洋
  8. 2016-08-28 21:37:46Is a float finite by 永明
  9. 2016-08-29 12:34:06More Math Methods by digua
  10. 2016-09-10 10:41:08Number Introduction by 胡晋
  11. 2016-09-28 20:43:32NoMethodError: undefined method 'new' for Fixnum:Class by zetaliang

发表评论