Bitwise rotation (Circular shift)

前端 未结 5 1799
粉色の甜心
粉色の甜心 2021-01-05 08:04

I was trying to make some code in C++ about “bitwise rotation” and I would like to make this by the left shif. I didn’t know how to code this, but I found a little code in “

5条回答
  •  臣服心动
    2021-01-05 08:09

    It's because you're using an int which is 32 bits, so it worked as expected by wrapping the most significant bits to the front. Use a smaller data structure like an unsigned char to make this more managable.

提交回复
热议问题