+ return (1 << (32 - __builtin_clz(x - 1))); I don't know if the use of gcc guarantees that int will always be 32 bit, otherwise maybe use sizeof(int)*8 instead of 32? Or even sizeof(int)*CHAR_BIT for good measures. Although probably the robots have taken over before this becomes necessary :) Tormod