Detecting single one-bit streams within an integer
问题 I have to check a number if it satisfies the following criteria: in binary, all one-bits must be successive. the number must have at least one bit set. the successive one-bits may start at the MSB or end at the LSB, so it's perfectly valid if the number is made up of a single one-bit stream followed by a zero-bit stream or vice versa. I wrote a code that checks for these conditions for a real-world problem (checking data-file integrity). It works without problems and it's anything but time