Hi,
I'm in need of circular shifting, which isn't supported in VB.NET.
To make things a bit more complicated (no pun intended ),
I only want to use the first 3 bits to do the rotation. (Just imagine a 3 bit integer)
I've come up with some solutions,
but I hope there is a more elegant, maybe faster solution.
Shift to the right:
X = ((X >> 1) Or ((X Mod 2) << 2))
Shift to the left:
X = (X << 1 Or ( (8 And (X << 1) ) >> 3)) And 7
Note:
I only need to shift by one, never more.
I'm in need of circular shifting, which isn't supported in VB.NET.
To make things a bit more complicated (no pun intended ),
I only want to use the first 3 bits to do the rotation. (Just imagine a 3 bit integer)
I've come up with some solutions,
but I hope there is a more elegant, maybe faster solution.
Shift to the right:
X = ((X >> 1) Or ((X Mod 2) << 2))
Shift to the left:
X = (X << 1 Or ( (8 And (X << 1) ) >> 3)) And 7
Note:
I only need to shift by one, never more.