DeveloperX wrote:
On 21 Nov, 14:17, "Ramtin Kazemi" <ramtin.kaz...@yahoo.comwrote:
>Hi
How can i perform bitwise rotation in C#?
int x = 1;
x<<=3;
Console.WriteLine(x.ToString()); //writes 8
Taking the question literally, that's not bitwise rotation, it's bitwise
shifting. The difference is what happens when you start shifting bits
off of one end, with shifting you lose them, with rotation they come
back in on the other end.
There is no built-in bitwise rotation operator in .NET that I'm aware
of, perhaps in 3.5 there could be something somewhere that I don't know
of, but in 2.0 I'm suspecting you have to roll your own.
--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/