From: Alex Young Date: 2006-08-08T01:04:07+09:00 Subject: Re: nextPowerOf2(n) Robert Klemme wrote: > Did we have this solution already? > > class Integer > def next_power > x = self > c = 0 > > until x == 0 > x >>= 1 > c += 1 > end > > 1 << c > end > end Neat, but hits an infinite loop for negative x. Then again, that wasn't part of the original problem... -- Alex