From: Zangief Ief Date: 2008-01-23T08:29:10+09:00 Subject: Re: Circular shift Mental Guy wrote: > 1. take 134 ( 10000110 ) > 2. split it into two parts ( 100 00110 ) > 3. swap them ( 00110 100 ) > 4. put the result back together ( 00110100 ) > > -mental Wow, it's perfect! Sorry, I haven't understood because of the padding in the step 4. Now it's okay. Here is an example of file: block = 753 shift = 2 length = block.to_s(2).length new_block = circular_shift_left(block, block.to_s(2).length, shift) puts "input: #{block.to_s(2)}" puts "output: #{new_block.to_s(2)}" And when I execute it: $ ruby circular_shift.rb input: 1011110001 output: 1111000110 THANKS A LOT :) -- Posted via http://www.ruby-forum.com/.