From: Hans Mackowiak Date: 2012-10-17T04:42:50+09:00 Subject: Re: Converting binary string to integer for a Ruby newbie "011001".each_char.reverse_each.with_index.inject(0) {|v,(dig,i)| v + (dig == '1' ? 2**i : 0 )} #=> 25 or use rubys cool features: Integer("0b" + "011001") #=> 25 -- Posted via http://www.ruby-forum.com/.