Hello,
I'm new to bitwise operation, so sorry if I speak incorrectly.
I need to write a function that takes two ints. One is the number to work on, the other is the number of bits to shift the number over. It also has to replace the bits on the right end with the bits that are shifted off the left end, thus rotating the bits. So something like this will shift the bits:
unsigned int shift(unsigned int x, int y)
{
x <<= y
return (x)
}
But, how do I get the bits to reappear on the other side?
If x = 129 (10000001) and y = 2
then
x <<= y == 6 (00000110)
I don't want the code, just a starting point. I use the MS C++ compiler if that helps (I know some compilers handle bits differently).
Thanks in advance for your help.
-Tyler
I'm new to bitwise operation, so sorry if I speak incorrectly.
I need to write a function that takes two ints. One is the number to work on, the other is the number of bits to shift the number over. It also has to replace the bits on the right end with the bits that are shifted off the left end, thus rotating the bits. So something like this will shift the bits:
unsigned int shift(unsigned int x, int y)
{
x <<= y
return (x)
}
But, how do I get the bits to reappear on the other side?
If x = 129 (10000001) and y = 2
then
x <<= y == 6 (00000110)
I don't want the code, just a starting point. I use the MS C++ compiler if that helps (I know some compilers handle bits differently).
Thanks in advance for your help.
-Tyler