I was just wondering if there was a way to bit shift a number “in place”?
I’ve googled exactly that, and I can’t find anything that pertains to what I want to do.
Say I have the number 0b01001101, and I want to shift it twice to the right “in place”, appending any numbers that fall off to the beginning. So it would look like 0b01010011.
Is there any function in c++ that would allow me to bit shift left or right like that?
I was just wondering if there was a way to bit shift a number
Share
You want to implement a rotational shift
Here’s a templatized version that should work with all types of ints (including shorts, chars, ints, and unsigned/signed alike).