in reply to Most Significant Set Bit

Though this sort of bit-twiddling code can be hard to understand (which is why I agree with hv that your constants are more clearly expressed in binary or hex) it can also be lots of fun, and mind-bogglingly fast, as I learned a few years ago (in both Perl and C++) when implementing Conway's Game of Life.

References Added Later

PDL:

See Also

Updated: fixed broken links. Added more references. Adjusted attribution of Inline modules (thanks etj).

👁️🍾👍🦟

Replies are listed 'Best First'.
Re^2: Most Significant Set Bit (Bit Twiddling References)
by etj (Priest) on Mar 17, 2024 at 22:01 UTC
    Nit: while I'm the most recent releaser of Inline::C, it's not really "by" me, but by Ingy (with quite a few contributors).

      Thanks. I've updated the list of References.

      👁️🍾👍🦟