Problem with Bitwise Barrel Shift Rotate left and right in C#

心已入冬 提交于 2019-12-02 03:53:25

You should use int type for the right side variable in shift operators.

You will have to cast the right side of the bitshift operator to int. If you cast like (int)(32 - bits), it should not affect your intended purpose. The right side is just expecting an int, probably because it's simpler that way and highly unlikely you'll ever want to shift more than 2 billion bits.

The right operand must be always type int.

 int x << int bits
 uint x << int bits
 long x << int bits
 ulong x << int bits
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!