My apologies if this has been asked/answered before but I'm honestly not even sure how to word this as a question properly. I have the following bit pattern:
0110110110110110110110110110110110110110110110110110110110110110
I'm trying to perform a shift that'll preserve my underlying pattern; my first instinct was to use right rotation ((x >> count) | (x << (-count & 63)))
but the asymmetry in my bit pattern results in:
0011011011011011011011011011011011011011011011011011011011011011
<--- wrong
The problem is that the most significant (far left) bit ends up being 0 instead of the desired 1:
1011011011011011011011011011011011011011011011011011011011011011
<--- right
Is there a colloquial name for this function I'm looking for? If not, how could I go about implementing this idea?
Additional Information:
- While the question is language agnostic I'm currently trying to solve this using C#.
- The bit patterns I'm using are entirely predictable and always have the same structure; the pattern starts with a single zero followed by
n - 1
ones (wheren
is an odd number) and then repeats infinitely. - I'd like to accomplish this without conditional operations since they'd defeat the purpose of using bitwise manipulation in the first place but maybe I have no choice...