Morton Goldberg
2/8/2007 5:11:00 AM
On Feb 7, 2007, at 9:13 PM, Minxing Liu wrote:
> I love Ruby very much and now Ruby is my first language.But now I
> meet a
> problem on Ruby.I want to do as follows:
> 1:Open a file in binary mode
> 2:Shift the bit in a algorithm
> 3:Save the file
>
> I don't know how to shift the bit stream in Ruby.Can any one give
> me an
> advice???
The bit-shift operator is <<. Example:
<code>
n = 1
n = n << 2 # => 4 (left shift)
n << -1 # => 2 (right shift)
</code>
Regards, Morton