> Can someone tell me if there's a better way to do this? It takes a > number and returns the next power of 2 up (or the original if it was > already a power of 2) Specifically, are there features of Ruby that I > should be using in this case? Try this: def log2(x) Math.log(x) / Math.log(2) end def nextPowerOf2(x) 2 ** (log2(x).ceil) end Hadley