C#按位向左旋转和向右旋转 [英] C# bitwise rotate left and rotate right
本文介绍了C#按位向左旋转和向右旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是C#当量(.NET 2.0)的 _rotl
和 _rotr
从C ++?
What is the C# equivalent (.NET 2.0) of _rotl
and _rotr
from C++?
推荐答案
这就是你正在尝试做的?
Is this what you are trying to do?
基本上你想要的是
(左)
(original << bits) | (original >> (32 -bits))
或
(右)
(original >> bits) | (original << (32 -bits))
同样,如迈赫达德已经建议,这仅适用于UINT,这是例子,乔恩给出以及
Also, as Mehrdad has already suggested, this only works for uint, which is the example that Jon gives as well.
这篇关于C#按位向左旋转和向右旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文