将位向左 (_lrotl) 或向右 (_lrotr) 旋转。
语法
unsigned long _lrotl( unsigned long value, int shift );
unsigned long _lrotr( unsigned long value, int shift );
参数
value
要旋转的值。
shift
要移动 value 的位数。
返回值
两个函数均返回旋转的值。 无错误返回。
备注
_lrotl 和 _lrotr 函数将 value 旋转 shift 位。 _lrotl 将值向左旋转,转向更加重要的位。 _lrotr 将值向右旋转,转向不太重要的位。 两个函数将旋转的位从 value 的一端移到另一端。
要求
| 例程 | 必需的标头 | 
|---|---|
| %> | <stdlib.h> | 
有关兼容性的详细信息,请参阅 兼容性。
示例
// crt_lrot.c
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
   unsigned long val = 0x0fac35791;
   printf( "0x%8.8lx rotated left eight bits is 0x%8.8lx\n",
            val, _lrotl( val, 8 ) );
   printf( "0x%8.8lx rotated right four bits is 0x%8.8lx\n",
            val, _lrotr( val, 4 ) );
}
0xfac35791 rotated left eight bits is 0xc35791fa
0xfac35791 rotated right four bits is 0x1fac3579