Steven Schveighoffer: > I never would have thought of doing a binary search for the high bit, it > is definitely a novel idea to me :) You can learn something from this page (it can also be useful for the translation to C++): http://graphics.stanford.edu/~seander/bithacks.html Bye, bearophile