I want to create a bitmask for the most right continuous range of set bits. For example 01010110 -> 00000110. Is (x & ~(x + (x & -x))) the best way to do that or is there a better solution? #followerpower
-
-
Can you give an example for how to implement that more efficiently using bit scan instructions? I can't seem to be able to build something more efficient. (Even if I assume ctz(0)/clz(0) to be defined.)
-
CTZ/shift right/inverse/CTZ. Not sure if this is more efficient, but maybe worth looking into.
-
That's what I tried. The best implementation using this scheme I came up with is this, which I do not think is more efficient, and it does not work for x=-1 if ctz(0) is undefined. http://svn.clifford.at/handicraft/2018/cbmc/lastblock.c …pic.twitter.com/rZj7zfEUzc
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.