> but tried to keep the code somewhat readable > (yeah, except for that power-of-two business...) Rich, here is a trick you can use in C. Multiplying or dividing by two is equivalent to bit-shifting. e.g. 2*2*2*2*2*2*2*2*2*2 == 1024 == 1 << 10 1024/2/2/2/2/2/2/2/2/2/2 == 1 == 1024 >> 10 -- Rob