Is there a way to perform a circular bit shift in C#?

后端 未结 6 954
太阳男子
太阳男子 2020-11-29 04:58

I know that the following is true

int i = 17; //binary 10001
int j = i << 1; //decimal 34, binary 100010

But, if you shift too far, t

6条回答
  •  -上瘾入骨i
    2020-11-29 05:36

    One year ago I've to implement MD4 for my undergraduate thesis. Here it is my implementation of circular bit shift using a UInt32.

    private UInt32 RotateLeft(UInt32 x, Byte n)
    {
          return UInt32((x << n) | (x >> (32 - n)));
    }
    

提交回复
热议问题