I am looking for a solution of finding pop count in bitstring between two positions eg:
popcnt( 10(0101), 0, 3) = 1
popcnt( 100101(), 0, 0) = 0
popcnt( 10010(1), 0, 1) = 0
** I am assuming open range and assuming Right to Left order
using standard bit operators and possibly popcnt or equivalent.
If it makes difference, I am looking to find the popcnt between the difference of two strings. Lets say i have string b
and i swap bits in two positions, eg 0101110 -> 1101100 => 3
- I need the popcnt between the bits that changed - in the case of 0101110 -> 1101100
the bits between the two are 10110
and so popcnt is 3
Do you see some ingenious way to do so with bithacks?