• Bert (unregistered)

    As always, this page is indespensable.

    https://graphics.stanford.edu/~seander/bithacks.html#IntegerLogObvious

  • Anonymous (unregistered)

    Bernie's comment shows he doesn't really understand what's going on here. Neither do many of the commenters. Basically the algorithm is doing a binary search over the bits of the input to find the highest 1 with just 5 comparisons. It looks ugly but it's pretty much the most efficient way to implement this function.

Leave a comment on “It's Log, Log, Log”

Log In or post as a guest

Replying to comment #:

« Return to Article