On Jan 5, 2006, at 10:37 AM, Kero wrote: >> Tristan's solution makes use of bit operations, because they tend >> to be faster >> than multiplication and division. All you need to know about >> these is that n << >> 1 == n * 2 and n >> 1 == n / 2. > > Are they really faster? Ruby bits are not directly in CPU registers. > > My rule of thumb is that every method call in Ruby takes a huge > amount of > time, whether it is a bitshift or a multiplication (or even a > regexp check). > For the record, I did a quick test: As I suspected. Stupid C idioms. :) ~ ryan ~