Finding N contiguous zero bits in an integer to the left of the MSB position of another integer
- by James Morris
The problem is: given an integer val1 find the position of the highest bit set (Most Significant Bit) then, given a second integer val2 find a contiguous region of unset bits, with the minimum number of zero bits given by width to the left of the position (ie, in the higher bits).
Here is the C code for my solution:
typedef unsigned int t;…