moving to c++
use a faster is-power-of-two method (dasJ)