Mega Code Archive

 
Categories / Ruby / Number
 

Binary bit shift left and right

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