_lrotl, _lrotr

將位元向左 (_lrotl) 或向右 (_lrotr) 旋轉。

語法

unsigned long _lrotl( unsigned long value, int shift );
unsigned long _lrotr( unsigned long value, int shift );

參數

value
要旋轉的值。

shift
要移位 value 的位數。

傳回值

這兩個函式會傳回旋轉的值。 沒有傳回錯誤。

備註

和 函式會依位旋轉 shiftvalue_lrotl_lrotr _lrotl 將值向左旋轉,朝更重要的位旋轉。 _lrotr 向右旋轉值,朝較不重要的位旋轉。 這兩個函式都會將位換成一端的旋轉至另一端 value

需求

常式 必要的標頭
_lrotl, _lrotr <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

另請參閱

數學和浮點支援
_rotl, _rotl64, _rotr, _rotr64